From: Ted Kremenek Date: Fri, 29 Jul 2011 21:18:41 +0000 (+0000) Subject: [analyzer] Remove recursive visitation in ExprEngine::VisitDeclStmt because it isn... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=6075f01f557ea9f0f59a8040a666e78df9bbb3df;p=clang [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 --- 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(D)) return; - const VarDecl* VD = dyn_cast(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(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))); } } }