summaryrefslogtreecommitdiffstats
path: root/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
diff options
context:
space:
mode:
authorAnna Zaks <ganna@apple.com>2011-10-27 00:59:23 +0000
committerAnna Zaks <ganna@apple.com>2011-10-27 00:59:23 +0000
commitb1d3d968725baf28a00b12aad760434036cbe704 (patch)
tree1099303be3c5af1d1cc28ac1a59b8c6bca2d2648 /clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
parent67f914dc976ebdf1d880a04d728166fcc5afe61b (diff)
downloadbcm5719-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/ExprEngine.cpp')
-rw-r--r--clang/lib/StaticAnalyzer/Core/ExprEngine.cpp72
1 files changed, 11 insertions, 61 deletions
diff --git a/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp b/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
index 24fa04bd564..2c5379f66a7 100644
--- a/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
+++ b/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
@@ -220,50 +220,6 @@ void ExprEngine::processCFGElement(const CFGElement E, ExplodedNode *Pred,
currentBuilderContext = 0;
}
-const Stmt *ExprEngine::getStmt() const {
- const CFGStmt *CS = (*currentBuilderContext->getBlock())[currentStmtIdx]
- .getAs<CFGStmt>();
- return CS ? CS->getStmt() : 0;
-}
-
-// TODO: Adding nodes to the worklist shoudl be a function inside CoreEngine.
-void ExprEngine::GenerateAutoTransition(ExplodedNode *N) {
- assert (!N->isSink());
- const CFGBlock *Block = currentBuilderContext->getBlock();
- unsigned Idx = currentStmtIdx;
-
- // 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.
- Engine.WList->enqueue(N, Block, Idx);
- return;
- }
-
- // Do not create extra nodes. Move to the next CFG element.
- if (isa<PostInitializer>(N->getLocation())) {
- Engine.WList->enqueue(N, Block, Idx+1);
- return;
- }
-
- PostStmt Loc(getStmt(), N->getLocationContext());
-
- if (Loc == N->getLocation()) {
- // Note: 'N' should be a fresh node because otherwise it shouldn't be
- // a member of Deferred.
- Engine.WList->enqueue(N, Block, Idx+1);
- return;
- }
-
- bool IsNew;
- ExplodedNode *Succ = Engine.G->getNode(Loc, N->getState(), &IsNew);
- Succ->addPredecessor(N, *Engine.G);
-
- if (IsNew)
- Engine.WList->enqueue(Succ, Block, Idx+1);
-}
-
-
void ExprEngine::ProcessStmt(const CFGStmt S,
ExplodedNode *Pred) {
// TODO: Use RAII to remove the unnecessary, tagged nodes.
@@ -346,19 +302,16 @@ void ExprEngine::ProcessStmt(const CFGStmt S,
}
}
- ExplodedNodeSet AllDst;
+ ExplodedNodeSet Dst;
for (ExplodedNodeSet::iterator I=Tmp.begin(), E=Tmp.end(); I!=E; ++I) {
- ExplodedNodeSet Dst;
+ ExplodedNodeSet DstI;
// Visit the statement.
- Visit(currentStmt, *I, Dst);
- AllDst.insert(Dst);
+ Visit(currentStmt, *I, DstI);
+ Dst.insert(DstI);
}
- for (ExplodedNodeSet::iterator I = AllDst.begin(),
- E = AllDst.end(); I != E; ++I) {
- assert(!(*I)->isSink());
- GenerateAutoTransition(*I);
- }
+ // Enqueue the new nodes onto the work list.
+ Engine.enqueue(Dst, currentBuilderContext->getBlock(), currentStmtIdx);
// NULL out these variables to cleanup.
CleanedState = NULL;
@@ -418,10 +371,9 @@ void ExprEngine::ProcessInitializer(const CFGInitializer Init,
VisitCXXConstructExpr(ctorExpr, baseReg, Pred, Dst);
}
- for (ExplodedNodeSet::iterator I = Dst.begin(),
- E = Dst.end(); I != E; ++I) {
- GenerateAutoTransition(*I);
- }
+
+ // Enqueue the new nodes onto the work list.
+ Engine.enqueue(Dst, currentBuilderContext->getBlock(), currentStmtIdx);
}
void ExprEngine::ProcessImplicitDtor(const CFGImplicitDtor D,
@@ -444,10 +396,8 @@ void ExprEngine::ProcessImplicitDtor(const CFGImplicitDtor D,
llvm_unreachable("Unexpected dtor kind.");
}
- for (ExplodedNodeSet::iterator I = Dst.begin(),
- E = Dst.end(); I != E; ++I) {
- GenerateAutoTransition(*I);
- }
+ // Enqueue the new nodes onto the work list.
+ Engine.enqueue(Dst, currentBuilderContext->getBlock(), currentStmtIdx);
}
void ExprEngine::ProcessAutomaticObjDtor(const CFGAutomaticObjDtor Dtor,
OpenPOWER on IntegriCloud