diff options
| author | Chandler Carruth <chandlerc@gmail.com> | 2016-11-04 06:11:54 +0000 |
|---|---|---|
| committer | Chandler Carruth <chandlerc@gmail.com> | 2016-11-04 06:11:54 +0000 |
| commit | 3d40284570058560a3cfd92ba74ef37988746a31 (patch) | |
| tree | ae17a743aae6d9943f03acaa1fe2a013d59dbba3 /clang | |
| parent | 22349ffa5db7e6c8b83c07d7993a799bb5419f0a (diff) | |
| download | bcm5719-llvm-3d40284570058560a3cfd92ba74ef37988746a31.tar.gz bcm5719-llvm-3d40284570058560a3cfd92ba74ef37988746a31.zip | |
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
Diffstat (limited to 'clang')
| -rw-r--r-- | clang/lib/Sema/SemaExprObjC.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaExprObjC.cpp b/clang/lib/Sema/SemaExprObjC.cpp index d208a322c83..e7d0d2f6b03 100644 --- a/clang/lib/Sema/SemaExprObjC.cpp +++ b/clang/lib/Sema/SemaExprObjC.cpp @@ -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 = |

