diff options
author | Anna Zaks <ganna@apple.com> | 2011-10-27 00:59:23 +0000 |
---|---|---|
committer | Anna Zaks <ganna@apple.com> | 2011-10-27 00:59:23 +0000 |
commit | b1d3d968725baf28a00b12aad760434036cbe704 (patch) | |
tree | 1099303be3c5af1d1cc28ac1a59b8c6bca2d2648 /clang/lib/StaticAnalyzer/Core/CoreEngine.cpp | |
parent | 67f914dc976ebdf1d880a04d728166fcc5afe61b (diff) | |
download | bcm5719-llvm-b1d3d968725baf28a00b12aad760434036cbe704.tar.gz bcm5719-llvm-b1d3d968725baf28a00b12aad760434036cbe704.zip |
[analyzer] Make CoreEngine responsible for enqueueing Stmt Nodes.
Enqueue the nodes generated as the result of processing a statement
inside the Core Engine. This makes sure ExpEngine does not access
CoreEngine's private members and is more concise.
llvm-svn: 143089
Diffstat (limited to 'clang/lib/StaticAnalyzer/Core/CoreEngine.cpp')
-rw-r--r-- | clang/lib/StaticAnalyzer/Core/CoreEngine.cpp | 52 |
1 files changed, 49 insertions, 3 deletions
diff --git a/clang/lib/StaticAnalyzer/Core/CoreEngine.cpp b/clang/lib/StaticAnalyzer/Core/CoreEngine.cpp index f6939172427..e88a8f1963d 100644 --- a/clang/lib/StaticAnalyzer/Core/CoreEngine.cpp +++ b/clang/lib/StaticAnalyzer/Core/CoreEngine.cpp @@ -454,13 +454,59 @@ void CoreEngine::generateNode(const ProgramPoint &Loc, if (IsNew) WList->enqueue(Node); } -void CoreEngine::enqueue(ExplodedNodeSet &S) { - for (ExplodedNodeSet::iterator I = S.begin(), - E = S.end(); I != E; ++I) { +void CoreEngine::enqueueStmtNode(ExplodedNode *N, + const CFGBlock *Block, unsigned Idx) { + assert (!N->isSink()); + + // Check if this node entered a callee. + if (isa<CallEnter>(N->getLocation())) { + // Still use the index of the CallExpr. It's needed to create the callee + // StackFrameContext. + WList->enqueue(N, Block, Idx); + return; + } + + // Do not create extra nodes. Move to the next CFG element. + if (isa<PostInitializer>(N->getLocation())) { + WList->enqueue(N, Block, Idx+1); + return; + } + + const CFGStmt *CS = (*Block)[Idx].getAs<CFGStmt>(); + const Stmt *St = CS ? CS->getStmt() : 0; + PostStmt Loc(St, N->getLocationContext()); + + if (Loc == N->getLocation()) { + // Note: 'N' should be a fresh node because otherwise it shouldn't be + // a member of Deferred. + WList->enqueue(N, Block, Idx+1); + return; + } + + bool IsNew; + ExplodedNode *Succ = G->getNode(Loc, N->getState(), &IsNew); + Succ->addPredecessor(N, *G); + + if (IsNew) + WList->enqueue(Succ, Block, Idx+1); +} + +void CoreEngine::enqueue(ExplodedNodeSet &Set) { + for (ExplodedNodeSet::iterator I = Set.begin(), + E = Set.end(); I != E; ++I) { WList->enqueue(*I); } } +void CoreEngine::enqueue(ExplodedNodeSet &Set, + const CFGBlock *Block, unsigned Idx) { + for (ExplodedNodeSet::iterator I = Set.begin(), + E = Set.end(); I != E; ++I) { + enqueueStmtNode(*I, Block, Idx); + } +} + + ExplodedNode* NodeBuilder::generateNodeImpl(const ProgramPoint &Loc, const ProgramState *State, ExplodedNode *FromN, |