[cfe-commits] r49804 - in /cfe/trunk: include/clang/Analysis/PathSensitive/GRExprEngine.h include/clang/Analysis/PathSensitive/GRTransferFuncs.h lib/Analysis/GRExprEngine.cpp

Ted Kremenek kremenek at apple.com
Wed Apr 16 11:39:07 PDT 2008


Author: kremenek
Date: Wed Apr 16 13:39:06 2008
New Revision: 49804

URL: http://llvm.org/viewvc/llvm-project?rev=49804&view=rev
Log:
Hook up "EvalStore" from GRTransferFuncs to GRExprEngine.

Modified:
    cfe/trunk/include/clang/Analysis/PathSensitive/GRExprEngine.h
    cfe/trunk/include/clang/Analysis/PathSensitive/GRTransferFuncs.h
    cfe/trunk/lib/Analysis/GRExprEngine.cpp

Modified: cfe/trunk/include/clang/Analysis/PathSensitive/GRExprEngine.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/PathSensitive/GRExprEngine.h?rev=49804&r1=49803&r2=49804&view=diff

==============================================================================
--- cfe/trunk/include/clang/Analysis/PathSensitive/GRExprEngine.h (original)
+++ cfe/trunk/include/clang/Analysis/PathSensitive/GRExprEngine.h Wed Apr 16 13:39:06 2008
@@ -602,11 +602,12 @@
     TF->EvalObjCMessageExpr(Dst, *this, *Builder, ME, Pred);
   }
   
+  void VisitStore(NodeSet& Dst, Expr* E, NodeTy* Pred, ValueState* St,
+                 LVal TargetLV, RVal Val);
+  
   void EvalStore(NodeSet& Dst, Expr* E, NodeTy* Pred, ValueState* St,
                  LVal TargetLV, RVal Val) {
-    
-    assert (Builder && "GRStmtNodeBuilder must be defined.");
-    MakeNode(Dst, E, Pred, SetRVal(St, TargetLV, Val));    
+    TF->EvalStore(Dst, *this, *Builder, E, Pred, St, TargetLV, Val);
   }
   
   ValueState* MarkBranch(ValueState* St, Stmt* Terminator, bool branchTaken);

Modified: cfe/trunk/include/clang/Analysis/PathSensitive/GRTransferFuncs.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/PathSensitive/GRTransferFuncs.h?rev=49804&r1=49803&r2=49804&view=diff

==============================================================================
--- cfe/trunk/include/clang/Analysis/PathSensitive/GRTransferFuncs.h (original)
+++ cfe/trunk/include/clang/Analysis/PathSensitive/GRTransferFuncs.h Wed Apr 16 13:39:06 2008
@@ -32,7 +32,7 @@
     return NULL;
   }
   
-  virtual void RegisterChecks(GRExprEngine& Eng) {}
+  virtual void RegisterChecks(GRExprEngine& Eng);
   
   // Casts.
   
@@ -72,6 +72,15 @@
                                    ObjCMessageExpr* ME,
                                    ExplodedNode<ValueState>* Pred) = 0;
   
+  // Stores.
+  
+  virtual void EvalStore(ExplodedNodeSet<ValueState>& Dst,
+                         GRExprEngine& Engine,
+                         GRStmtNodeBuilder<ValueState>& Builder,
+                         Expr* E, ExplodedNode<ValueState>* Pred,
+                         ValueState* St, LVal TargetLV, RVal Val) {}
+                         
+  
   // End-of-path.
   
   virtual void EvalEndPath(GRExprEngine& Engine,

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

==============================================================================
--- cfe/trunk/lib/Analysis/GRExprEngine.cpp (original)
+++ cfe/trunk/lib/Analysis/GRExprEngine.cpp Wed Apr 16 13:39:06 2008
@@ -689,7 +689,7 @@
 }
  
 //===----------------------------------------------------------------------===//
-// Transfer functions: DeclRefExprs (loads, getting l-values).
+// Transfer functions: Loads and stores.
 //===----------------------------------------------------------------------===//
 
 void GRExprEngine::VisitDeclRefExpr(DeclRefExpr* D, NodeTy* Pred, NodeSet& Dst){
@@ -708,6 +708,23 @@
   MakeNode(Dst, D, Pred, SetBlkExprRVal(St, D, Y));
 }
 
+void GRExprEngine::VisitStore(NodeSet& Dst, Expr* E, NodeTy* Pred,
+                              ValueState* St, LVal TargetLV, RVal Val) {
+  
+  assert (Builder && "GRStmtNodeBuilder must be defined.");
+  
+  unsigned size = Dst.size();  
+  SaveAndRestore<bool> OldSink(Builder->BuildSinks);
+  
+  EvalStore(Dst, E, Pred, St, TargetLV, Val);
+  
+  // Handle the case where no nodes where generated.  Auto-generate that
+  // contains the updated state if we aren't generating sinks.
+  
+  if (!Builder->BuildSinks && Dst.size() == size)
+    MakeNode(Dst, E, Pred, SetRVal(St, TargetLV, Val));    
+}
+
 //===----------------------------------------------------------------------===//
 // Transfer function: Function calls.
 //===----------------------------------------------------------------------===//
@@ -1637,7 +1654,7 @@
           // Simulate the effects of a "store":  bind the value of the RHS
           // to the L-Value represented by the LHS.
 
-          EvalStore(Dst, B, N2, SetRVal(St, B, RightV),
+          VisitStore(Dst, B, N2, SetRVal(St, B, RightV),
                     cast<LVal>(LeftV), RightV);
           
 //          St = SetRVal(SetRVal(St, B, RightV), cast<LVal>(LeftV), RightV);
@@ -1788,7 +1805,7 @@
           }
           
           //          St = SetRVal(SetRVal(St, B, Result), LeftLV, Result);          
-          EvalStore(Dst, B, N2, SetRVal(St, B, Result), LeftLV, Result);
+          VisitStore(Dst, B, N2, SetRVal(St, B, Result), LeftLV, Result);
           continue;
         }
       }





More information about the cfe-commits mailing list