aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnna Zaks <ganna@apple.com>2011-10-24 18:26:12 +0000
committerAnna Zaks <ganna@apple.com>2011-10-24 18:26:12 +0000
commitd231d0130a95336610ab9a42eaeb2cdac19992f3 (patch)
treef50edd86c3b1d8c4c8f44281c0e636104140abbd
parent6b6152ba96c164a292cc0b8d8b1d4cecbec27a60 (diff)
[analyzer] Convert VisitDeclStmt to use local node builder.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@142830 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/clang/StaticAnalyzer/Core/PathSensitive/CoreEngine.h35
-rw-r--r--lib/StaticAnalyzer/Core/ExprEngine.cpp2
-rw-r--r--lib/StaticAnalyzer/Core/ExprEngineC.cpp17
3 files changed, 31 insertions, 23 deletions
diff --git a/include/clang/StaticAnalyzer/Core/PathSensitive/CoreEngine.h b/include/clang/StaticAnalyzer/Core/PathSensitive/CoreEngine.h
index 7321b8bd84..47682a2ac5 100644
--- a/include/clang/StaticAnalyzer/Core/PathSensitive/CoreEngine.h
+++ b/include/clang/StaticAnalyzer/Core/PathSensitive/CoreEngine.h
@@ -283,6 +283,24 @@ public:
C.ContextPred->getLocationContext()->getCurrentStackFrame(),
C.Block->getBlockID());
}
+
+ void takeNodes(const ExplodedNodeSet &S) {
+ for (ExplodedNodeSet::iterator I = S.begin(), E = S.end(); I != E; ++I )
+ Frontier.erase(*I);
+ }
+
+ void takeNodes(ExplodedNode *N) {
+ Frontier.erase(N);
+ }
+
+ void addNodes(const ExplodedNodeSet &S) {
+ Frontier.insert(S);
+ }
+
+ void addNodes(ExplodedNode *N) {
+ Frontier.Add(N);
+ }
+
};
class CommonNodeBuilder {
@@ -403,23 +421,6 @@ public:
BuildSinks = Tmp;
return N;
}
-
- void takeNodes(const ExplodedNodeSet &S) {
- for (ExplodedNodeSet::iterator I = S.begin(), E = S.end(); I != E; ++I )
- Frontier.erase(*I);
- }
-
- void takeNodes(ExplodedNode *N) {
- Frontier.erase(N);
- }
-
- void addNodes(const ExplodedNodeSet &S) {
- Frontier.insert(S);
- }
-
- void addNodes(ExplodedNode *N) {
- Frontier.Add(N);
- }
};
class BranchNodeBuilder: public NodeBuilder {
diff --git a/lib/StaticAnalyzer/Core/ExprEngine.cpp b/lib/StaticAnalyzer/Core/ExprEngine.cpp
index 781106c30b..5999dc6bb1 100644
--- a/lib/StaticAnalyzer/Core/ExprEngine.cpp
+++ b/lib/StaticAnalyzer/Core/ExprEngine.cpp
@@ -1297,7 +1297,7 @@ void ExprEngine::evalBind(ExplodedNodeSet &Dst, const Stmt *StoreE,
getCheckerManager().runCheckersForBind(CheckedSet, Pred, location, Val,
StoreE, *this);
- // TODO: Remove TmpDst after NB refactoring is done.
+ // TODO:AZ Remove TmpDst after NB refactoring is done.
ExplodedNodeSet TmpDst;
Builder->takeNodes(CheckedSet);
PureStmtNodeBuilder Bldr(CheckedSet, TmpDst, *currentBuilderContext);
diff --git a/lib/StaticAnalyzer/Core/ExprEngineC.cpp b/lib/StaticAnalyzer/Core/ExprEngineC.cpp
index dc6bbc69f7..b70a5f1e14 100644
--- a/lib/StaticAnalyzer/Core/ExprEngineC.cpp
+++ b/lib/StaticAnalyzer/Core/ExprEngineC.cpp
@@ -302,6 +302,9 @@ void ExprEngine::VisitCast(const CastExpr *CastE, const Expr *Ex,
void ExprEngine::VisitCompoundLiteralExpr(const CompoundLiteralExpr *CL,
ExplodedNode *Pred,
ExplodedNodeSet &Dst) {
+ PureStmtNodeBuilder B(Pred, Dst, *currentBuilderContext);
+ Builder->takeNodes(Pred);
+
const InitListExpr *ILE
= cast<InitListExpr>(CL->getInitializer()->IgnoreParens());
@@ -311,9 +314,10 @@ void ExprEngine::VisitCompoundLiteralExpr(const CompoundLiteralExpr *CL,
state = state->bindCompoundLiteral(CL, LC, ILV);
if (CL->isLValue())
- MakeNode(Dst, CL, Pred, state->BindExpr(CL, state->getLValue(CL, LC)));
+ B.generateNode(CL, Pred, state->BindExpr(CL, state->getLValue(CL, LC)));
else
- MakeNode(Dst, CL, Pred, state->BindExpr(CL, ILV));
+ B.generateNode(CL, Pred, state->BindExpr(CL, ILV));
+ Builder->addNodes(Dst);
}
void ExprEngine::VisitDeclStmt(const DeclStmt *DS, ExplodedNode *Pred,
@@ -333,8 +337,9 @@ void ExprEngine::VisitDeclStmt(const DeclStmt *DS, ExplodedNode *Pred,
ExplodedNodeSet dstPreVisit;
getCheckerManager().runCheckersForPreStmt(dstPreVisit, Pred, DS, *this);
+ PureStmtNodeBuilder B(dstPreVisit, Dst, *currentBuilderContext);
+ Builder->takeNodes(dstPreVisit);
const VarDecl *VD = dyn_cast<VarDecl>(D);
-
for (ExplodedNodeSet::iterator I = dstPreVisit.begin(), E = dstPreVisit.end();
I!=E; ++I) {
ExplodedNode *N = *I;
@@ -362,13 +367,15 @@ void ExprEngine::VisitDeclStmt(const DeclStmt *DS, ExplodedNode *Pred,
InitVal = svalBuilder.getConjuredSymbolVal(NULL, InitEx,
Builder->getCurrentBlockCount());
}
-
+ B.takeNodes(N);
evalBind(Dst, DS, N, state->getLValue(VD, LC), InitVal, true);
+ B.addNodes(Dst);
}
else {
- MakeNode(Dst, DS, N, state->bindDeclWithNoInit(state->getRegion(VD, LC)));
+ B.generateNode(DS, N,state->bindDeclWithNoInit(state->getRegion(VD, LC)));
}
}
+ Builder->addNodes(Dst);
}
void ExprEngine::VisitLogicalExpr(const BinaryOperator* B, ExplodedNode *Pred,