Add an assert to further check the invariant that a null pointer

corresponds to another argument being valid.

This makes it clear that the code is correct despite the PVS-Studio
report that a pointer might be dereferenced prior to being checked for
whether it is null. It likely is also enough for static analyzers to not
flag the code.

llvm-svn: 285982
This commit is contained in:
Chandler Carruth 2016-11-04 06:11:54 +00:00
parent 22349ffa5d
commit 3d40284570
1 changed files with 4 additions and 0 deletions

View File

@ -2539,6 +2539,10 @@ ExprResult Sema::BuildInstanceMessage(Expr *Receiver,
SourceLocation RBracLoc,
MultiExprArg ArgsIn,
bool isImplicit) {
assert((Receiver || SuperLoc.isValid()) && "If the Receiver is null, the "
"SuperLoc must be valid so we can "
"use it instead.");
// The location of the receiver.
SourceLocation Loc = SuperLoc.isValid()? SuperLoc : Receiver->getLocStart();
SourceRange RecRange =