r175852 - Fix regression in modeling assignments of an address of a variable to itself. Fixes <rdar://problem/13226577>.
Ted Kremenek
kremenek at apple.com
Thu Feb 21 17:39:26 PST 2013
Author: kremenek
Date: Thu Feb 21 19:39:26 2013
New Revision: 175852
URL: http://llvm.org/viewvc/llvm-project?rev=175852&view=rev
Log:
Fix regression in modeling assignments of an address of a variable to itself. Fixes <rdar://problem/13226577>.
Modified:
cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineC.cpp
cfe/trunk/test/Analysis/stack-addr-ps.cpp
Modified: cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineC.cpp?rev=175852&r1=175851&r2=175852&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineC.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineC.cpp Thu Feb 21 19:39:26 2013
@@ -471,9 +471,7 @@ void ExprEngine::VisitDeclStmt(const Dec
SVal InitVal = state->getSVal(InitEx, LC);
- if (InitVal == state->getLValue(VD, LC) ||
- (VD->getType()->isArrayType() &&
- isa<CXXConstructExpr>(InitEx->IgnoreImplicit()))) {
+ if (isa<CXXConstructExpr>(InitEx->IgnoreImplicit())) {
// We constructed the object directly in the variable.
// No need to bind anything.
B.generateNode(DS, UpdatedN, state);
Modified: cfe/trunk/test/Analysis/stack-addr-ps.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/stack-addr-ps.cpp?rev=175852&r1=175851&r2=175852&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/stack-addr-ps.cpp (original)
+++ cfe/trunk/test/Analysis/stack-addr-ps.cpp Thu Feb 21 19:39:26 2013
@@ -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}}
+}
+
More information about the cfe-commits
mailing list