From: Ted Kremenek Date: Wed, 23 Sep 2009 01:30:01 +0000 (+0000) Subject: Fix PR 4988 by removing an invalid assertion (a function can be referenced in X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=657406dd407a3f17c594205d65fec049cf1304dd;p=clang Fix PR 4988 by removing an invalid assertion (a function can be referenced in GRExprEngine::VisitDeclRefExpr without 'asLValue' being true). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@82598 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Analysis/GRExprEngine.cpp b/lib/Analysis/GRExprEngine.cpp index a6c3c66a0a..735949cd4a 100644 --- a/lib/Analysis/GRExprEngine.cpp +++ b/lib/Analysis/GRExprEngine.cpp @@ -1006,7 +1006,7 @@ void GRExprEngine::VisitDeclRefExpr(DeclRefExpr *Ex, ExplodedNode *Pred, return; } else if (const FunctionDecl* FD = dyn_cast(D)) { - assert(asLValue); + // This code is valid regardless of the value of 'isLValue'. SVal V = ValMgr.getFunctionPointer(FD); MakeNode(Dst, Ex, Pred, state->BindExpr(Ex, V), ProgramPoint::PostLValueKind); diff --git a/test/Analysis/misc-ps.m b/test/Analysis/misc-ps.m index f877d4449c..9c27029d66 100644 --- a/test/Analysis/misc-ps.m +++ b/test/Analysis/misc-ps.m @@ -650,3 +650,10 @@ CGFloat rdar7242006(CGFloat x) { return y.width; // no-warning } +// PR 4988 - This test exhibits a case where a function can be referenced +// when not explicitly used in an "lvalue" context (as far as the analyzer is +// concerned). This previously triggered a crash due to an invalid assertion. +void pr_4988(void) { + pr_4988; // expected-warning{{expression result unused}} +} +