diff options
author | Ted Kremenek <kremenek@apple.com> | 2008-03-05 00:33:14 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2008-03-05 00:33:14 +0000 |
commit | 330dddd19406f9cc227e59e0bb0a36ecdc52915e (patch) | |
tree | 11332ef1e208029741dd139b34e596d5b074bddb | |
parent | e5f4dcb6bd73a10df6eb6c3cfe057c88cb2362cc (diff) |
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
-rw-r--r-- | Analysis/GRExprEngine.cpp | 8 | ||||
-rw-r--r-- | Analysis/GRSimpleVals.cpp | 15 | ||||
-rw-r--r-- | Analysis/GRSimpleVals.h | 10 | ||||
-rw-r--r-- | include/clang/Analysis/PathSensitive/ExplodedGraph.h | 3 | ||||
-rw-r--r-- | include/clang/Analysis/PathSensitive/GRCoreEngine.h | 2 | ||||
-rw-r--r-- | include/clang/Analysis/PathSensitive/GRExprEngine.h | 7 | ||||
-rw-r--r-- | include/clang/Analysis/PathSensitive/GRTransferFuncs.h | 8 |
7 files changed, 35 insertions, 18 deletions
diff --git a/Analysis/GRExprEngine.cpp b/Analysis/GRExprEngine.cpp index 61d10a4ecc..2481f56838 100644 --- a/Analysis/GRExprEngine.cpp +++ b/Analysis/GRExprEngine.cpp @@ -549,7 +549,13 @@ void GRExprEngine::VisitCall(CallExpr* CE, NodeTy* Pred, 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 fbaccba94f..d8a3112b1a 100644 --- a/Analysis/GRSimpleVals.cpp +++ b/Analysis/GRSimpleVals.cpp @@ -397,9 +397,14 @@ RVal GRSimpleVals::EvalNE(ValueManager& ValMgr, LVal L, LVal R) { // 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 @@ GRSimpleVals::EvalCall(ValueStateManager& StateMgr, ValueManager& ValMgr, 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 43fed85fdd..c947afdb57 100644 --- a/Analysis/GRSimpleVals.h +++ b/Analysis/GRSimpleVals.h @@ -52,10 +52,12 @@ public: // 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 423f4f065c..ca76c48387 100644 --- a/include/clang/Analysis/PathSensitive/ExplodedGraph.h +++ b/include/clang/Analysis/PathSensitive/ExplodedGraph.h @@ -365,9 +365,10 @@ public: }; -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 53986a326f..151f202dee 100644 --- a/include/clang/Analysis/PathSensitive/GRCoreEngine.h +++ b/include/clang/Analysis/PathSensitive/GRCoreEngine.h @@ -176,7 +176,7 @@ public: 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 ffbd064c30..c753249779 100644 --- a/include/clang/Analysis/PathSensitive/GRExprEngine.h +++ b/include/clang/Analysis/PathSensitive/GRExprEngine.h @@ -31,7 +31,7 @@ public: 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 @@ protected: 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 a91a97b91a..ea8a793471 100644 --- a/include/clang/Analysis/PathSensitive/GRTransferFuncs.h +++ b/include/clang/Analysis/PathSensitive/GRTransferFuncs.h @@ -54,9 +54,11 @@ public: // 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 |