[cfe-commits] r48299 - /cfe/trunk/Analysis/GRSimpleVals.cpp

Ted Kremenek kremenek at apple.com
Wed Mar 12 14:04:08 PDT 2008


Author: kremenek
Date: Wed Mar 12 16:04:07 2008
New Revision: 48299

URL: http://llvm.org/viewvc/llvm-project?rev=48299&view=rev
Log:
In GRSimpleVals, added the generation of symbolic values for the return values
of function calls. This is useful in pruning paths.

Modified:
    cfe/trunk/Analysis/GRSimpleVals.cpp

Modified: cfe/trunk/Analysis/GRSimpleVals.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Analysis/GRSimpleVals.cpp?rev=48299&r1=48298&r2=48299&view=diff

==============================================================================
--- cfe/trunk/Analysis/GRSimpleVals.cpp (original)
+++ cfe/trunk/Analysis/GRSimpleVals.cpp Wed Mar 12 16:04:07 2008
@@ -414,18 +414,32 @@
                             CallExpr* CE, LVal L,
                             ExplodedNode<ValueState>* Pred) {
   
-  ValueState* St = Pred->getState();
+  ValueStateManager& StateMgr = Eng.getStateManager();
+  ValueState* St = Builder.GetState(Pred);
   
   // Invalidate all arguments passed in by reference (LVals).
 
   for (CallExpr::arg_iterator I = CE->arg_begin(), E = CE->arg_end();
         I != E; ++I) {
 
-    RVal V = Eng.getStateManager().GetRVal(St, *I);
+    RVal V = StateMgr.GetRVal(St, *I);
     
     if (isa<LVal>(V))
-      St = Eng.getStateManager().SetRVal(St, cast<LVal>(V), UnknownVal());
+      St = StateMgr.SetRVal(St, cast<LVal>(V), UnknownVal());
   }
+  
+  // Make up a symbol for the return value of this function.
+  
+  if (CE->getType() != Eng.getContext().VoidTy) {    
+    unsigned Count = Builder.getCurrentBlockCount();
+    SymbolID Sym = Eng.getSymbolManager().getCallRetValSymbol(CE, Count);
+        
+    RVal X = CE->getType()->isPointerType() 
+             ? cast<RVal>(lval::SymbolVal(Sym)) 
+             : cast<RVal>(nonlval::SymbolVal(Sym));
+    
+    St = StateMgr.SetRVal(St, CE, X, Eng.getCFG().isBlkExpr(CE), false);
+  }  
     
   Builder.Nodify(Dst, CE, Pred, St);
 }





More information about the cfe-commits mailing list