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

Ted Kremenek kremenek at apple.com
Thu Jul 3 16:26:32 PDT 2008


Author: kremenek
Date: Thu Jul  3 18:26:32 2008
New Revision: 53125

URL: http://llvm.org/viewvc/llvm-project?rev=53125&view=rev
Log:
Use conjured symbols for variables whose values are invalidated when
passed-by-reference to a function. This allows us to build up constraints for
their new values and restore some lost path-sensitivity. This addresses a few
false positives since in Adium.

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=53125&r1=53124&r2=53125&view=diff

==============================================================================
--- cfe/trunk/lib/Analysis/CFRefCount.cpp (original)
+++ cfe/trunk/lib/Analysis/CFRefCount.cpp Thu Jul  3 18:26:32 2008
@@ -1389,8 +1389,35 @@
       }
     }  
     else if (isa<LVal>(V)) {
+#if 0
       // Nuke all arguments passed by reference.
       StateMgr.Unbind(StVals, cast<LVal>(V));
+#else
+      if (lval::DeclVal* DV = dyn_cast<lval::DeclVal>(&V)) {      
+        
+        // FIXME: Either this logic should also be replicated in GRSimpleVals
+        //  or should be pulled into a separate "constraint engine."
+        // FIXME: We can have collisions on the conjured symbol if the
+        //  expression *I also creates conjured symbols.  We probably want
+        //  to identify conjured symbols by an expression pair: the enclosing
+        //  expression (the context) and the expression itself.  This should
+        //  disambiguate conjured symbols.        
+        
+        // Invalidate the values of all variables passed by reference.
+        // Set the value of the variable to be a conjured symbol.
+        unsigned Count = Builder.getCurrentBlockCount();
+        SymbolID NewSym = Eng.getSymbolManager().getConjuredSymbol(*I, Count);
+      
+        StateMgr.BindVar(StVals, DV->getDecl(),
+                         LVal::IsLValType(DV->getDecl()->getType())
+                         ? cast<RVal>(lval::SymbolVal(NewSym))
+                         : cast<RVal>(nonlval::SymbolVal(NewSym)));
+      }
+      else {
+        // Nuke all other arguments passed by reference.
+        StateMgr.Unbind(StVals, cast<LVal>(V));
+      }
+#endif
     }
     else if (isa<nonlval::LValAsInteger>(V))
       StateMgr.Unbind(StVals, cast<nonlval::LValAsInteger>(V).getLVal());





More information about the cfe-commits mailing list