aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnna Zaks <ganna@apple.com>2011-10-27 00:59:28 +0000
committerAnna Zaks <ganna@apple.com>2011-10-27 00:59:28 +0000
commit4d2ae4a70336dc2aa11389b34946be152bb454c9 (patch)
tree91c63458cea275276ec29b9e425f9c88fb6aa774
parentdd7ddf2b2296f95e7591ca3f9791f0eb9a15ee42 (diff)
[analyzer] Move enqueueEndOfFunction into CoreEngine.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@143090 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/clang/StaticAnalyzer/Core/PathSensitive/CoreEngine.h9
-rw-r--r--lib/StaticAnalyzer/Core/CoreEngine.cpp29
-rw-r--r--lib/StaticAnalyzer/Core/ExprEngine.cpp31
3 files changed, 37 insertions, 32 deletions
diff --git a/include/clang/StaticAnalyzer/Core/PathSensitive/CoreEngine.h b/include/clang/StaticAnalyzer/Core/PathSensitive/CoreEngine.h
index ca98e637e0..87751d28a3 100644
--- a/include/clang/StaticAnalyzer/Core/PathSensitive/CoreEngine.h
+++ b/include/clang/StaticAnalyzer/Core/PathSensitive/CoreEngine.h
@@ -47,7 +47,6 @@ class CoreEngine {
friend class EndOfFunctionNodeBuilder;
friend class CallEnterNodeBuilder;
friend class CallExitNodeBuilder;
- friend class ExprEngine;
public:
typedef std::vector<std::pair<BlockEdge, const ExplodedNode*> >
@@ -103,6 +102,8 @@ private:
void enqueueStmtNode(ExplodedNode *N,
const CFGBlock *Block, unsigned Idx);
+ ExplodedNode *generateCallExitNode(ExplodedNode *N);
+
public:
/// Construct a CoreEngine object to analyze the provided CFG using
/// a DFS exploration of the exploded graph.
@@ -167,11 +168,15 @@ public:
}
/// \brief Enqueue the given set of nodes onto the work list.
- void enqueue(ExplodedNodeSet &NB);
+ void enqueue(ExplodedNodeSet &Set);
/// \brief Enqueue nodes that were created as a result of processing
/// a statement onto the work list.
void enqueue(ExplodedNodeSet &Set, const CFGBlock *Block, unsigned Idx);
+
+ /// \brief enqueue the nodes corresponding to the end of function onto the
+ /// end of path / work list.
+ void enqueueEndOfFunction(ExplodedNodeSet &Set);
};
// TODO: Turn into a calss.
diff --git a/lib/StaticAnalyzer/Core/CoreEngine.cpp b/lib/StaticAnalyzer/Core/CoreEngine.cpp
index e88a8f1963..5ab55b5ee3 100644
--- a/lib/StaticAnalyzer/Core/CoreEngine.cpp
+++ b/lib/StaticAnalyzer/Core/CoreEngine.cpp
@@ -491,6 +491,22 @@ void CoreEngine::enqueueStmtNode(ExplodedNode *N,
WList->enqueue(Succ, Block, Idx+1);
}
+ExplodedNode *CoreEngine::generateCallExitNode(ExplodedNode *N) {
+ // Create a CallExit node and enqueue it.
+ const StackFrameContext *LocCtx
+ = cast<StackFrameContext>(N->getLocationContext());
+ const Stmt *CE = LocCtx->getCallSite();
+
+ // Use the the callee location context.
+ CallExit Loc(CE, LocCtx);
+
+ bool isNew;
+ ExplodedNode *Node = G->getNode(Loc, N->getState(), &isNew);
+ Node->addPredecessor(N, *G);
+ return isNew ? Node : 0;
+}
+
+
void CoreEngine::enqueue(ExplodedNodeSet &Set) {
for (ExplodedNodeSet::iterator I = Set.begin(),
E = Set.end(); I != E; ++I) {
@@ -506,6 +522,19 @@ void CoreEngine::enqueue(ExplodedNodeSet &Set,
}
}
+void CoreEngine::enqueueEndOfFunction(ExplodedNodeSet &Set) {
+ for (ExplodedNodeSet::iterator I = Set.begin(), E = Set.end(); I != E; ++I) {
+ ExplodedNode *N = *I;
+ // If we are in an inlined call, generate CallExit node.
+ if (N->getLocationContext()->getParent()) {
+ N = generateCallExitNode(N);
+ if (N)
+ WList->enqueue(N);
+ } else
+ G->addEndOfPath(N);
+ }
+}
+
ExplodedNode* NodeBuilder::generateNodeImpl(const ProgramPoint &Loc,
const ProgramState *State,
diff --git a/lib/StaticAnalyzer/Core/ExprEngine.cpp b/lib/StaticAnalyzer/Core/ExprEngine.cpp
index 2c5379f66a..3924154f6f 100644
--- a/lib/StaticAnalyzer/Core/ExprEngine.cpp
+++ b/lib/StaticAnalyzer/Core/ExprEngine.cpp
@@ -1100,42 +1100,13 @@ void ExprEngine::processIndirectGoto(IndirectGotoNodeBuilder &builder) {
builder.generateNode(I, state);
}
-// TODO: The next two functions should be moved into CoreEngine.
-void ExprEngine::GenerateCallExitNode(ExplodedNode *N) {
- // Create a CallExit node and enqueue it.
- const StackFrameContext *LocCtx
- = cast<StackFrameContext>(N->getLocationContext());
- const Stmt *CE = LocCtx->getCallSite();
-
- // Use the the callee location context.
- CallExit Loc(CE, LocCtx);
-
- bool isNew;
- ExplodedNode *Node = Engine.G->getNode(Loc, N->getState(), &isNew);
- Node->addPredecessor(N, *Engine.G);
-
- if (isNew)
- Engine.WList->enqueue(Node);
-}
-
-void ExprEngine::enqueueEndOfPath(ExplodedNodeSet &S) {
- for (ExplodedNodeSet::iterator I = S.begin(), E = S.end(); I != E; ++I) {
- ExplodedNode *N = *I;
- // If we are in an inlined call, generate CallExit node.
- if (N->getLocationContext()->getParent())
- GenerateCallExitNode(N);
- else
- Engine.G->addEndOfPath(N);
- }
-}
-
/// ProcessEndPath - Called by CoreEngine. Used to generate end-of-path
/// nodes when the control reaches the end of a function.
void ExprEngine::processEndOfFunction(NodeBuilderContext& BC) {
StateMgr.EndPath(BC.Pred->getState());
ExplodedNodeSet Dst;
getCheckerManager().runCheckersForEndPath(BC, Dst, *this);
- enqueueEndOfPath(Dst);
+ Engine.enqueueEndOfFunction(Dst);
}
/// ProcessSwitch - Called by CoreEngine. Used to generate successor