aboutsummaryrefslogtreecommitdiff
path: root/lib/StaticAnalyzer/Core/ExprEngine.cpp
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2011-07-29 21:18:41 +0000
committerTed Kremenek <kremenek@apple.com>2011-07-29 21:18:41 +0000
commit6075f01f557ea9f0f59a8040a666e78df9bbb3df (patch)
tree0f0ee70cb2bc3c5448903b84947048e8ecabeb5a /lib/StaticAnalyzer/Core/ExprEngine.cpp
parent71f20db43bfcb6e7a377982e20615f5f62789cc2 (diff)
[analyzer] Remove recursive visitation in ExprEngine::VisitDeclStmt because it isn't needed anymore.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136522 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/StaticAnalyzer/Core/ExprEngine.cpp')
-rw-r--r--lib/StaticAnalyzer/Core/ExprEngine.cpp32
1 files changed, 14 insertions, 18 deletions
diff --git a/lib/StaticAnalyzer/Core/ExprEngine.cpp b/lib/StaticAnalyzer/Core/ExprEngine.cpp
index 82312d871d..fb7bf9e246 100644
--- a/lib/StaticAnalyzer/Core/ExprEngine.cpp
+++ b/lib/StaticAnalyzer/Core/ExprEngine.cpp
@@ -2163,35 +2163,32 @@ void ExprEngine::VisitCompoundLiteralExpr(const CompoundLiteralExpr* CL,
void ExprEngine::VisitDeclStmt(const DeclStmt *DS, ExplodedNode *Pred,
ExplodedNodeSet& Dst) {
- // The CFG has one DeclStmt per Decl.
+ // FIXME: static variables may have an initializer, but the second
+ // time a function is called those values may not be current.
+ // This may need to be reflected in the CFG.
+
+ // Assumption: The CFG has one DeclStmt per Decl.
const Decl* D = *DS->decl_begin();
if (!D || !isa<VarDecl>(D))
return;
- const VarDecl* VD = dyn_cast<VarDecl>(D);
- const Expr* InitEx = VD->getInit();
- // FIXME: static variables may have an initializer, but the second
- // time a function is called those values may not be current.
- ExplodedNodeSet Tmp;
-
- if (InitEx)
- Visit(InitEx, Pred, Tmp);
- else
- Tmp.Add(Pred);
+ ExplodedNodeSet dstPreVisit;
+ getCheckerManager().runCheckersForPreStmt(dstPreVisit, Pred, DS, *this);
- ExplodedNodeSet Tmp2;
- getCheckerManager().runCheckersForPreStmt(Tmp2, Tmp, DS, *this);
+ const VarDecl *VD = dyn_cast<VarDecl>(D);
- for (ExplodedNodeSet::iterator I=Tmp2.begin(), E=Tmp2.end(); I!=E; ++I) {
+ for (ExplodedNodeSet::iterator I = dstPreVisit.begin(), E = dstPreVisit.end();
+ I!=E; ++I)
+ {
ExplodedNode *N = *I;
const GRState *state = GetState(N);
// Decls without InitExpr are not initialized explicitly.
const LocationContext *LC = N->getLocationContext();
- if (InitEx) {
+ if (const Expr *InitEx = VD->getInit()) {
SVal InitVal = state->getSVal(InitEx);
// We bound the temp obj region to the CXXConstructExpr. Now recover
@@ -2211,12 +2208,11 @@ void ExprEngine::VisitDeclStmt(const DeclStmt *DS, ExplodedNode *Pred,
Builder->getCurrentBlockCount());
}
- evalBind(Dst, DS, *I, state,
+ evalBind(Dst, DS, N, state,
loc::MemRegionVal(state->getRegion(VD, LC)), InitVal, true);
}
else {
- state = state->bindDeclWithNoInit(state->getRegion(VD, LC));
- MakeNode(Dst, DS, *I, state);
+ MakeNode(Dst, DS, N, state->bindDeclWithNoInit(state->getRegion(VD, LC)));
}
}
}