]> granicus.if.org Git - clang/commitdiff
Fix regression in modeling assignments of an address of a variable to itself. Fixes...
authorTed Kremenek <kremenek@apple.com>
Fri, 22 Feb 2013 01:39:26 +0000 (01:39 +0000)
committerTed Kremenek <kremenek@apple.com>
Fri, 22 Feb 2013 01:39:26 +0000 (01:39 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175852 91177308-0d34-0410-b5e6-96231b3b80d8

lib/StaticAnalyzer/Core/ExprEngineC.cpp
test/Analysis/stack-addr-ps.cpp

index b656bbd83bed0c62a9ea60907aa1183c373e7769..b392c43dd334733e4eb9712b2049e1927ada75fd 100644 (file)
@@ -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<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);
index a27bef793c47a862844176d73e7cc242aa40e445..9dd63f83c674d0d9b5b7b4ce498961eff8600406 100644 (file)
@@ -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}}
+}
+