]> granicus.if.org Git - clang/commitdiff
Fixed bug where not all dead subexpressions were being pruned from the analysis
authorTed Kremenek <kremenek@apple.com>
Tue, 29 Jan 2008 05:25:31 +0000 (05:25 +0000)
committerTed Kremenek <kremenek@apple.com>
Tue, 29 Jan 2008 05:25:31 +0000 (05:25 +0000)
state.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@46491 91177308-0d34-0410-b5e6-96231b3b80d8

Analysis/GRConstants.cpp

index 103e6a0d74bb6336fe042d2f5cda1d5ba4821275..46f828bac29563ac8bc37ca75b9d188cf13b859d 100644 (file)
@@ -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;
 }