From: Ted Kremenek Date: Fri, 22 Feb 2013 01:39:26 +0000 (+0000) Subject: Fix regression in modeling assignments of an address of a variable to itself. Fixes... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f08740ba5903d089a53cc315c19286e2189f9ff3;p=clang Fix regression in modeling assignments of an address of a variable to itself. Fixes . git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175852 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/StaticAnalyzer/Core/ExprEngineC.cpp b/lib/StaticAnalyzer/Core/ExprEngineC.cpp index b656bbd83b..b392c43dd3 100644 --- a/lib/StaticAnalyzer/Core/ExprEngineC.cpp +++ b/lib/StaticAnalyzer/Core/ExprEngineC.cpp @@ -471,9 +471,7 @@ void ExprEngine::VisitDeclStmt(const DeclStmt *DS, ExplodedNode *Pred, SVal InitVal = state->getSVal(InitEx, LC); - if (InitVal == state->getLValue(VD, LC) || - (VD->getType()->isArrayType() && - isa(InitEx->IgnoreImplicit()))) { + if (isa(InitEx->IgnoreImplicit())) { // We constructed the object directly in the variable. // No need to bind anything. B.generateNode(DS, UpdatedN, state); diff --git a/test/Analysis/stack-addr-ps.cpp b/test/Analysis/stack-addr-ps.cpp index a27bef793c..9dd63f83c6 100644 --- a/test/Analysis/stack-addr-ps.cpp +++ b/test/Analysis/stack-addr-ps.cpp @@ -90,3 +90,9 @@ int* f5() { int& i = i; // expected-warning {{Assigned value is garbage or undefined}} expected-note {{binding reference variable 'i' here}} expected-warning{{reference 'i' is not yet bound to a value when used within its own initialization}} return &i; // expected-warning {{address of stack memory associated with local variable 'i' returned}} } + +void *radar13226577() { + void *p = &p; + return p; // expected-warning {{stack memory associated with local variable 'p' returned to caller}} +} +