aboutsummaryrefslogtreecommitdiff
path: root/lib/StaticAnalyzer/Core/CoreEngine.cpp
diff options
context:
space:
mode:
authorAnna Zaks <ganna@apple.com>2011-10-18 23:06:33 +0000
committerAnna Zaks <ganna@apple.com>2011-10-18 23:06:33 +0000
commit319a9184d5ca9f77622b45ae15c08f6b9ce01621 (patch)
treeff094c6aca3c74345bab7d76ce27221b681e8f3b /lib/StaticAnalyzer/Core/CoreEngine.cpp
parent67d9fbac82922ef5b6c9ba5ac4a07e80f9960292 (diff)
[analyzer] Subclassing StmtBuilder from the NodeBuilder
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@142451 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/StaticAnalyzer/Core/CoreEngine.cpp')
-rw-r--r--lib/StaticAnalyzer/Core/CoreEngine.cpp71
1 files changed, 18 insertions, 53 deletions
diff --git a/lib/StaticAnalyzer/Core/CoreEngine.cpp b/lib/StaticAnalyzer/Core/CoreEngine.cpp
index 91aa9a567c..fda7bbdf4c 100644
--- a/lib/StaticAnalyzer/Core/CoreEngine.cpp
+++ b/lib/StaticAnalyzer/Core/CoreEngine.cpp
@@ -314,7 +314,8 @@ void CoreEngine::HandleBlockEntrance(const BlockEntrance &L,
// Process the entrance of the block.
if (CFGElement E = L.getFirstElement()) {
- StmtNodeBuilder Builder(L.getBlock(), 0, Pred, this);
+ NodeBuilderContext Ctx(*this, L.getBlock());
+ StmtNodeBuilder Builder(Pred, 0, Ctx);
SubEng.processCFGElement(E, Builder);
}
else
@@ -430,7 +431,8 @@ void CoreEngine::HandlePostStmt(const CFGBlock *B, unsigned StmtIdx,
if (StmtIdx == B->size())
HandleBlockExit(B, Pred);
else {
- StmtNodeBuilder Builder(B, StmtIdx, Pred, this);
+ NodeBuilderContext Ctx(*this, B);
+ StmtNodeBuilder Builder(Pred, StmtIdx, Ctx);
SubEng.processCFGElement((*B)[StmtIdx], Builder);
}
}
@@ -484,9 +486,9 @@ GenericNodeBuilderImpl::generateNodeImpl(const ProgramState *state,
}
ExplodedNode* NodeBuilder::generateNodeImpl(const ProgramPoint &Loc,
- const ProgramState *State,
- ExplodedNode *FromN,
- bool MarkAsSink) {
+ const ProgramState *State,
+ ExplodedNode *FromN,
+ bool MarkAsSink) {
assert(Finalized == false &&
"We cannot create new nodes after the results have been finalized.");
@@ -505,11 +507,9 @@ ExplodedNode* NodeBuilder::generateNodeImpl(const ProgramPoint &Loc,
}
-StmtNodeBuilder::StmtNodeBuilder(const CFGBlock *b,
- unsigned idx,
- ExplodedNode *N,
- CoreEngine* e)
- : CommonNodeBuilder(e, N), B(*b), Idx(idx),
+StmtNodeBuilder::StmtNodeBuilder(ExplodedNode *N, unsigned idx,
+ NodeBuilderContext &Ctx)
+ : NodeBuilder(N, Ctx), Idx(idx),
PurgingDeadSymbols(false), BuildSinks(false), hasGeneratedNode(false),
PointKind(ProgramPoint::PostStmtKind), Tag(0) {
Deferred.insert(N);
@@ -528,13 +528,13 @@ void StmtNodeBuilder::GenerateAutoTransition(ExplodedNode *N) {
if (isa<CallEnter>(N->getLocation())) {
// Still use the index of the CallExpr. It's needed to create the callee
// StackFrameContext.
- Eng.WList->enqueue(N, &B, Idx);
+ C.Eng.WList->enqueue(N, C.Block, Idx);
return;
}
// Do not create extra nodes. Move to the next CFG element.
if (isa<PostInitializer>(N->getLocation())) {
- Eng.WList->enqueue(N, &B, Idx+1);
+ C.Eng.WList->enqueue(N, C.Block, Idx+1);
return;
}
@@ -543,16 +543,16 @@ void StmtNodeBuilder::GenerateAutoTransition(ExplodedNode *N) {
if (Loc == N->getLocation()) {
// Note: 'N' should be a fresh node because otherwise it shouldn't be
// a member of Deferred.
- Eng.WList->enqueue(N, &B, Idx+1);
+ C.Eng.WList->enqueue(N, C.Block, Idx+1);
return;
}
bool IsNew;
- ExplodedNode *Succ = Eng.G->getNode(Loc, N->State, &IsNew);
- Succ->addPredecessor(N, *Eng.G);
+ ExplodedNode *Succ = C.Eng.G->getNode(Loc, N->State, &IsNew);
+ Succ->addPredecessor(N, *C.Eng.G);
if (IsNew)
- Eng.WList->enqueue(Succ, &B, Idx+1);
+ C.Eng.WList->enqueue(Succ, C.Block, Idx+1);
}
ExplodedNode *StmtNodeBuilder::MakeNode(ExplodedNodeSet &Dst,
@@ -560,48 +560,13 @@ ExplodedNode *StmtNodeBuilder::MakeNode(ExplodedNodeSet &Dst,
ExplodedNode *Pred,
const ProgramState *St,
ProgramPoint::Kind K) {
-
- ExplodedNode *N = generateNode(S, St, Pred, K);
-
- if (N) {
- if (BuildSinks)
- N->markAsSink();
- else
+ ExplodedNode *N = generateNode(S, St, Pred, K, 0, BuildSinks);
+ if (N && !BuildSinks){
Dst.Add(N);
}
-
return N;
}
-ExplodedNode*
-StmtNodeBuilder::generateNodeInternal(const Stmt *S,
- const ProgramState *state,
- ExplodedNode *Pred,
- ProgramPoint::Kind K,
- const ProgramPointTag *tag) {
-
- const ProgramPoint &L = ProgramPoint::getProgramPoint(S, K,
- Pred->getLocationContext(), tag);
- return generateNodeInternal(L, state, Pred);
-}
-
-ExplodedNode*
-StmtNodeBuilder::generateNodeInternal(const ProgramPoint &Loc,
- const ProgramState *State,
- ExplodedNode *Pred) {
- bool IsNew;
- ExplodedNode *N = Eng.G->getNode(Loc, State, &IsNew);
- N->addPredecessor(Pred, *Eng.G);
- Deferred.erase(Pred);
-
- if (IsNew) {
- Deferred.insert(N);
- return N;
- }
-
- return NULL;
-}
-
ExplodedNode *BranchNodeBuilder::generateNode(const ProgramState *State,
bool branch,
ExplodedNode *NodePred) {