diff options
author | Ted Kremenek <kremenek@apple.com> | 2008-01-29 05:25:31 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2008-01-29 05:25:31 +0000 |
commit | 65cac139a00758b74a96a693f28f5e63aedfa4e7 (patch) | |
tree | c96ca8cdbf17cb3b62cfd4a1adf380efcc1faee3 /Analysis/GRConstants.cpp | |
parent | bffaa831478baf584e74dfb7917861e865d99640 (diff) |
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
Diffstat (limited to 'Analysis/GRConstants.cpp')
-rw-r--r-- | Analysis/GRConstants.cpp | 23 |
1 files changed, 14 insertions, 9 deletions
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<Stmt>(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<Stmt>(I.getKey()))){ M = StateMgr.Remove(M, I.getKey()); + } + else if (I.getKey().isDecl()) { // Remove bindings for "dead" decls. + if (VarDecl* V = dyn_cast<VarDecl>(cast<ValueDecl>(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<VarDecl>(cast<ValueDecl>(I.getKey()))) - if (!Liveness.isLive(Loc, V)) - M = StateMgr.Remove(M, I.getKey()); - return M; } |