Plug-in transfer function "EvalCall" now takes as an argument the current
GRStmtNodeBuilder and is now responsible for adding its own nodes to the graph.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@47923 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/Analysis/GRExprEngine.cpp b/Analysis/GRExprEngine.cpp
index 61d10a4..2481f56 100644
--- a/Analysis/GRExprEngine.cpp
+++ b/Analysis/GRExprEngine.cpp
@@ -549,7 +549,13 @@
         continue;        
       
       // Dispatch to the plug-in transfer function.      
-      St = EvalCall(CE, cast<LVal>(L), (*DI)->getState());
+      
+      unsigned size = Dst.size();
+      
+      EvalCall(Dst, CE, cast<LVal>(L), *DI);
+      
+      if (Dst.size() == size)
+        Nodify(Dst, CE, *DI, St);
     }
     
     // Check for the "noreturn" attribute.
diff --git a/Analysis/GRSimpleVals.cpp b/Analysis/GRSimpleVals.cpp
index fbaccba..d8a3112 100644
--- a/Analysis/GRSimpleVals.cpp
+++ b/Analysis/GRSimpleVals.cpp
@@ -397,9 +397,14 @@
 // Transfer function for Function Calls.
 //===----------------------------------------------------------------------===//
 
-ValueState*
-GRSimpleVals::EvalCall(ValueStateManager& StateMgr, ValueManager& ValMgr,
-                       CallExpr* CE, LVal L, ValueState* St) {
+void GRSimpleVals::EvalCall(ExplodedNodeSet<ValueState>& Dst,
+                            ValueStateManager& StateMgr,
+                            GRStmtNodeBuilder<ValueState>& Builder,
+                            ValueManager& ValMgr,
+                            CallExpr* CE, LVal L,
+                            ExplodedNode<ValueState>* Pred) {
+  
+  ValueState* St = Pred->getState();
   
   // Invalidate all arguments passed in by reference (LVals).
 
@@ -411,6 +416,6 @@
     if (isa<LVal>(V))
       St = StateMgr.SetRVal(St, cast<LVal>(V), UnknownVal());
   }
-  
-  return St;
+    
+  Builder.Nodify(Dst, CE, Pred, St);
 }
diff --git a/Analysis/GRSimpleVals.h b/Analysis/GRSimpleVals.h
index 43fed85..c947afd 100644
--- a/Analysis/GRSimpleVals.h
+++ b/Analysis/GRSimpleVals.h
@@ -52,10 +52,12 @@
   
   // Calls.
   
-  virtual ValueState* EvalCall(ValueStateManager& StateMgr,
-                               ValueManager& ValMgr,
-                               CallExpr* CE, LVal L,
-                               ValueState* St);
+  virtual void EvalCall(ExplodedNodeSet<ValueState>& Dst,
+                        ValueStateManager& StateMgr,
+                        GRStmtNodeBuilder<ValueState>& Builder,
+                        ValueManager& ValMgr,
+                        CallExpr* CE, LVal L,
+                        ExplodedNode<ValueState>* Pred);
   
 protected:
   
diff --git a/include/clang/Analysis/PathSensitive/ExplodedGraph.h b/include/clang/Analysis/PathSensitive/ExplodedGraph.h
index 423f4f0..ca76c48 100644
--- a/include/clang/Analysis/PathSensitive/ExplodedGraph.h
+++ b/include/clang/Analysis/PathSensitive/ExplodedGraph.h
@@ -365,9 +365,10 @@
 };
   
   
-template <typename NodeTy>
+template <typename StateTy>
 class ExplodedNodeSet {
   
+  typedef ExplodedNode<StateTy>        NodeTy;
   typedef llvm::SmallPtrSet<NodeTy*,5> ImplTy;
   ImplTy Impl;
   
diff --git a/include/clang/Analysis/PathSensitive/GRCoreEngine.h b/include/clang/Analysis/PathSensitive/GRCoreEngine.h
index 53986a3..151f202 100644
--- a/include/clang/Analysis/PathSensitive/GRCoreEngine.h
+++ b/include/clang/Analysis/PathSensitive/GRCoreEngine.h
@@ -176,7 +176,7 @@
     return static_cast<NodeTy*>(NB.generateNodeImpl(S, St));    
   }
   
-  NodeTy* Nodify(ExplodedNodeSet<NodeTy>& Dst, Stmt* S,
+  NodeTy* Nodify(ExplodedNodeSet<StateTy>& Dst, Stmt* S,
                  NodeTy* Pred, StateTy* St) {
     
     // If the state hasn't changed, don't generate a new node.
diff --git a/include/clang/Analysis/PathSensitive/GRExprEngine.h b/include/clang/Analysis/PathSensitive/GRExprEngine.h
index ffbd064..c753249 100644
--- a/include/clang/Analysis/PathSensitive/GRExprEngine.h
+++ b/include/clang/Analysis/PathSensitive/GRExprEngine.h
@@ -31,7 +31,7 @@
   typedef GRBranchNodeBuilder<GRExprEngine>        BranchNodeBuilder;
   typedef GRIndirectGotoNodeBuilder<GRExprEngine>  IndirectGotoNodeBuilder;
   typedef GRSwitchNodeBuilder<GRExprEngine>        SwitchNodeBuilder;
-  typedef ExplodedNodeSet<NodeTy>                  NodeSet;
+  typedef ExplodedNodeSet<StateTy>                 NodeSet;
     
 protected:
   /// G - the simulation graph.
@@ -414,8 +414,9 @@
     return TF->EvalBinOp(ValMgr, Op, cast<NonLVal>(L), cast<NonLVal>(R));
   }
   
-  ValueState* EvalCall(CallExpr* CE, LVal L, ValueState* St) {
-    return TF->EvalCall(StateMgr, ValMgr, CE, L, St);
+  void EvalCall(NodeSet& Dst, CallExpr* CE, LVal L, NodeTy* Pred) {
+    assert (Builder && "GRStmtNodeBuilder must be defined.");    
+    return TF->EvalCall(Dst, StateMgr, *Builder, ValMgr, CE, L, Pred);
   }
   
   ValueState* MarkBranch(ValueState* St, Stmt* Terminator, bool branchTaken);
diff --git a/include/clang/Analysis/PathSensitive/GRTransferFuncs.h b/include/clang/Analysis/PathSensitive/GRTransferFuncs.h
index a91a97b..ea8a793 100644
--- a/include/clang/Analysis/PathSensitive/GRTransferFuncs.h
+++ b/include/clang/Analysis/PathSensitive/GRTransferFuncs.h
@@ -54,9 +54,11 @@
   
   // Calls.
   
-  virtual ValueState* EvalCall(ValueStateManager& StateMgr,
-                               ValueManager& ValMgr, CallExpr* CE, LVal L,
-                               ValueState* St) = 0;
+  virtual void EvalCall(ExplodedNodeSet<ValueState>& Dst,
+                        ValueStateManager& StateMgr,
+                        GRStmtNodeBuilder<ValueState>& Builder,
+                        ValueManager& ValMgr, CallExpr* CE, LVal L,
+                        ExplodedNode<ValueState>* Pred) = 0;
 };
   
 } // end clang namespace