diff options
| author | Ted Kremenek <kremenek@apple.com> | 2011-07-29 21:18:41 +0000 |
|---|---|---|
| committer | Ted Kremenek <kremenek@apple.com> | 2011-07-29 21:18:41 +0000 |
| commit | 67d7136f260ff606da42fe6e8894370964df8569 (patch) | |
| tree | 4b54992f433fe167df462a3426ca01f4186c0365 /clang | |
| parent | e905c68cbdb9dde51e667d1c8c5ade868b9dde0e (diff) | |
| download | bcm5719-llvm-67d7136f260ff606da42fe6e8894370964df8569.tar.gz bcm5719-llvm-67d7136f260ff606da42fe6e8894370964df8569.zip | |
[analyzer] Remove recursive visitation in ExprEngine::VisitDeclStmt because it isn't needed anymore.
llvm-svn: 136522
Diffstat (limited to 'clang')
| -rw-r--r-- | clang/lib/StaticAnalyzer/Core/ExprEngine.cpp | 32 |
1 files changed, 14 insertions, 18 deletions
diff --git a/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp b/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp index 82312d871d9..fb7bf9e246d 100644 --- a/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp +++ b/clang/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))); } } } |

