diff options
| author | Ted Kremenek <kremenek@apple.com> | 2008-08-28 18:34:26 +0000 |
|---|---|---|
| committer | Ted Kremenek <kremenek@apple.com> | 2008-08-28 18:34:26 +0000 |
| commit | b45e6b91c6678890c64f33a532ed28fc17aa5ec4 (patch) | |
| tree | f00c9e5e7f559f0a275717674b9955944b2a3af2 /clang/lib/Analysis/GRExprEngine.cpp | |
| parent | 26d54b3ef35545c0c3584989a15fc2c3c5fbe99d (diff) | |
| download | bcm5719-llvm-b45e6b91c6678890c64f33a532ed28fc17aa5ec4.tar.gz bcm5719-llvm-b45e6b91c6678890c64f33a532ed28fc17aa5ec4.zip | |
Fixed analyzer caching bug in DeclStmt.
llvm-svn: 55487
Diffstat (limited to 'clang/lib/Analysis/GRExprEngine.cpp')
| -rw-r--r-- | clang/lib/Analysis/GRExprEngine.cpp | 33 |
1 files changed, 11 insertions, 22 deletions
diff --git a/clang/lib/Analysis/GRExprEngine.cpp b/clang/lib/Analysis/GRExprEngine.cpp index c92093cf003..75ba46051ff 100644 --- a/clang/lib/Analysis/GRExprEngine.cpp +++ b/clang/lib/Analysis/GRExprEngine.cpp @@ -1452,25 +1452,19 @@ void GRExprEngine::VisitCast(Expr* CastE, Expr* Ex, NodeTy* Pred, NodeSet& Dst){ } void GRExprEngine::VisitDeclStmt(DeclStmt* DS, NodeTy* Pred, NodeSet& Dst) { - VisitDeclStmtAux(DS, DS->getDecl(), Pred, Dst); -} - -void GRExprEngine::VisitDeclStmtAux(DeclStmt* DS, ScopedDecl* D, - NodeTy* Pred, NodeSet& Dst) { - if (!D) - return; + // The CFG has one DeclStmt per Decl, so we don't need to walk the + // Decl chain. + + ScopedDecl* D = DS->getDecl(); - if (!isa<VarDecl>(D)) { - VisitDeclStmtAux(DS, D->getNextDeclarator(), Pred, Dst); + if (!D || !isa<VarDecl>(D)) return; - } const VarDecl* VD = dyn_cast<VarDecl>(D); // FIXME: Add support for local arrays. if (VD->getType()->isArrayType()) { - VisitDeclStmtAux(DS, D->getNextDeclarator(), Pred, Dst); return; } @@ -1480,21 +1474,16 @@ void GRExprEngine::VisitDeclStmtAux(DeclStmt* DS, ScopedDecl* D, // time a function is called those values may not be current. NodeSet Tmp; - if (Ex) Visit(Ex, Pred, Tmp); - if (Tmp.empty()) Tmp.Add(Pred); + if (Ex) + Visit(Ex, Pred, Tmp); + + if (Tmp.empty()) + Tmp.Add(Pred); for (NodeSet::iterator I=Tmp.begin(), E=Tmp.end(); I!=E; ++I) { const GRState* St = GetState(*I); St = StateMgr.AddDecl(St, VD, Ex, Builder->getCurrentBlockCount()); - - // Create a new node. We don't really need to create a new NodeSet - // here, but it simplifies things and doesn't cost much. - NodeSet Tmp2; - MakeNode(Tmp2, DS, *I, St); - if (Tmp2.empty()) Tmp2.Add(*I); - - for (NodeSet::iterator I2=Tmp2.begin(), E2=Tmp2.end(); I2!=E2; ++I2) - VisitDeclStmtAux(DS, D->getNextDeclarator(), *I2, Dst); + MakeNode(Dst, DS, *I, St); } } |

