[cfe-commits] r46491 - /cfe/trunk/Analysis/GRConstants.cpp

Ted Kremenek kremenek at apple.com
Mon Jan 28 21:25:31 PST 2008


Author: kremenek
Date: Mon Jan 28 23:25:31 2008
New Revision: 46491

URL: http://llvm.org/viewvc/llvm-project?rev=46491&view=rev
Log:
Fixed bug where not all dead subexpressions were being pruned from the analysis
state.

Modified:
    cfe/trunk/Analysis/GRConstants.cpp

Modified: cfe/trunk/Analysis/GRConstants.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Analysis/GRConstants.cpp?rev=46491&r1=46490&r2=46491&view=diff

==============================================================================
--- cfe/trunk/Analysis/GRConstants.cpp (original)
+++ cfe/trunk/Analysis/GRConstants.cpp Mon Jan 28 23:25:31 2008
@@ -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,18 +840,21 @@
   //  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;
 }
 





More information about the cfe-commits mailing list