From: Chandler Carruth Date: Fri, 4 Nov 2016 06:11:54 +0000 (+0000) Subject: Add an assert to further check the invariant that a null pointer X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=bff9f7176a483c4f85fe486ad38eddd700deffb2;p=clang 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@285982 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaExprObjC.cpp b/lib/Sema/SemaExprObjC.cpp index d208a322c8..e7d0d2f6b0 100644 --- a/lib/Sema/SemaExprObjC.cpp +++ b/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 =