From: Ted Kremenek Date: Tue, 29 Jan 2008 05:25:31 +0000 (+0000) Subject: Fixed bug where not all dead subexpressions were being pruned from the analysis X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=65cac139a00758b74a96a693f28f5e63aedfa4e7;p=clang Fixed bug where not all dead subexpressions were being pruned from the analysis state. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@46491 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/Analysis/GRConstants.cpp b/Analysis/GRConstants.cpp index 103e6a0d74..46f828bac2 100644 --- a/Analysis/GRConstants.cpp +++ b/Analysis/GRConstants.cpp @@ -88,7 +88,9 @@ public: bool isSymbol() const { return getKind() == IsSymbol; } bool isSubExpr() const { return getKind() == IsSubExpr; } + bool isBlkExpr() const { return getKind() == IsBlkExpr; } bool isDecl() const { return getKind() == IsDecl; } + bool isStmt() const { return getKind() <= IsBlkExpr; } inline void Profile(llvm::FoldingSetNodeID& ID) const { ID.AddInteger(isSymbol() ? 1 : 0); @@ -838,18 +840,21 @@ GRConstants::StateTy GRConstants::RemoveDeadBindings(Stmt* Loc, StateTy M) { // iterators are iterating over the tree of the *original* map. StateTy::iterator I = M.begin(), E = M.end(); - // Remove old bindings for subexpressions and "dead" block-level expressions. - for (; I!=E && !I.getKey().isDecl(); ++I) { - if (I.getKey().isSubExpr() || !Liveness.isLive(Loc,cast(I.getKey()))) + + for (; I!=E && !I.getKey().isSymbol(); ++I) { + // Remove old bindings for subexpressions and "dead" + // block-level expressions. + if (I.getKey().isSubExpr() || + I.getKey().isBlkExpr() && !Liveness.isLive(Loc,cast(I.getKey()))){ M = StateMgr.Remove(M, I.getKey()); + } + else if (I.getKey().isDecl()) { // Remove bindings for "dead" decls. + if (VarDecl* V = dyn_cast(cast(I.getKey()))) + if (!Liveness.isLive(Loc, V)) + M = StateMgr.Remove(M, I.getKey()); + } } - // Remove bindings for "dead" decls. - for (; I!=E && I.getKey().isDecl(); ++I) - if (VarDecl* V = dyn_cast(cast(I.getKey()))) - if (!Liveness.isLive(Loc, V)) - M = StateMgr.Remove(M, I.getKey()); - return M; }