aboutsummaryrefslogtreecommitdiff
path: root/Analysis/GRConstants.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Analysis/GRConstants.cpp')
-rw-r--r--Analysis/GRConstants.cpp23
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;
}