[cfe-commits] r65047 - /cfe/trunk/lib/Analysis/CFRefCount.cpp

Ted Kremenek kremenek at apple.com
Thu Feb 19 10:18:49 PST 2009


Author: kremenek
Date: Thu Feb 19 12:18:48 2009
New Revision: 65047

URL: http://llvm.org/viewvc/llvm-project?rev=65047&view=rev
Log:
retain/release checker: Fix crasher when the leak site is the same expression that allocates an object.

Modified:
    cfe/trunk/lib/Analysis/CFRefCount.cpp

Modified: cfe/trunk/lib/Analysis/CFRefCount.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/CFRefCount.cpp?rev=65047&r1=65046&r2=65047&view=diff

==============================================================================
--- cfe/trunk/lib/Analysis/CFRefCount.cpp (original)
+++ cfe/trunk/lib/Analysis/CFRefCount.cpp Thu Feb 19 12:18:48 2009
@@ -2586,7 +2586,6 @@
   
   while (LeakN) {
     ProgramPoint P = LeakN->getLocation();
-
     
     if (const PostStmt *PS = dyn_cast<PostStmt>(&P))
       S = PS->getStmt();
@@ -2597,18 +2596,27 @@
       // Scan 'S' for uses of Sym.
       GRStateRef state(LeakN->getState(), BR.getStateManager());
       bool foundSymbol = false;
-    
-      for (Stmt::child_iterator I=S->child_begin(), E=S->child_end();
-            I!=E; ++I)
-        if (Expr *Ex = dyn_cast_or_null<Expr>(*I)) {
-          SVal X = state.GetSVal(Ex);
-          if (isa<loc::SymbolVal>(X) && 
-              cast<loc::SymbolVal>(X).getSymbol() == Sym){
-            foundSymbol = true;        
-            break;
+      
+      // First check if 'S' itself binds to the symbol.
+      if (Expr *Ex = dyn_cast<Expr>(S)) {
+        SVal X = state.GetSVal(Ex);
+        if (isa<loc::SymbolVal>(X) && 
+            cast<loc::SymbolVal>(X).getSymbol() == Sym)
+          foundSymbol = true;
+      }
+        
+      if (!foundSymbol)
+        for (Stmt::child_iterator I=S->child_begin(), E=S->child_end();
+             I!=E; ++I)
+          if (Expr *Ex = dyn_cast_or_null<Expr>(*I)) {
+            SVal X = state.GetSVal(Ex);
+            if (isa<loc::SymbolVal>(X) && 
+                cast<loc::SymbolVal>(X).getSymbol() == Sym){
+              foundSymbol = true;        
+              break;
+            }
           }
-        }
-
+      
       if (foundSymbol)
         break;
     }





More information about the cfe-commits mailing list