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 103e6a0..46f828b 100644
--- a/Analysis/GRConstants.cpp
+++ b/Analysis/GRConstants.cpp
@@ -88,7 +88,9 @@
   
   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,17 +840,20 @@
   //  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())))
-      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());
+  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());
+    }
+  }
 
   return M;
 }