[cfe-commits] r132769 - in /cfe/trunk: lib/Analysis/LiveVariables.cpp test/Analysis/misc-ps.c

Jordy Rose jediknil at belkadan.com
Wed Jun 8 22:44:05 PDT 2011


Author: jrose
Date: Thu Jun  9 00:44:04 2011
New Revision: 132769

URL: http://llvm.org/viewvc/llvm-project?rev=132769&view=rev
Log:
[analyzer] Ignore parentheses around block-level expressions when computing liveness. Fixes the other half of PR8962.

Modified:
    cfe/trunk/lib/Analysis/LiveVariables.cpp
    cfe/trunk/test/Analysis/misc-ps.c

Modified: cfe/trunk/lib/Analysis/LiveVariables.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/LiveVariables.cpp?rev=132769&r1=132768&r2=132769&view=diff
==============================================================================
--- cfe/trunk/lib/Analysis/LiveVariables.cpp (original)
+++ cfe/trunk/lib/Analysis/LiveVariables.cpp Thu Jun  9 00:44:04 2011
@@ -142,8 +142,12 @@
     if (AD.Observer)
       AD.Observer->ObserveStmt(S, currentBlock, AD, LiveState);
 
-    if (getCFG().isBlkExpr(S))
-      LiveState(S, AD) = Dead;
+    if (getCFG().isBlkExpr(S)) {
+      if (Expr *E = dyn_cast<Expr>(S)) 
+        LiveState(E->IgnoreParens(), AD) = Dead;
+      else
+        LiveState(S, AD) = Dead;
+    }
 
     StmtVisitor<TransferFuncs,void>::Visit(S);
   }
@@ -157,7 +161,10 @@
   }
   else {
     // For block-level expressions, mark that they are live.
-    LiveState(S,AD) = Alive;
+    if (Expr *E = dyn_cast<Expr>(S)) 
+      LiveState(E->IgnoreParens(), AD) = Alive;
+    else
+      LiveState(S, AD) = Alive;
   }
 }
   
@@ -174,6 +181,9 @@
     return;
 
   assert (getCFG().isBlkExpr(E));
+
+  if (const Expr *Ex = dyn_cast<Expr>(E))
+    E = Ex->IgnoreParens();
   LiveState(E, AD) = Alive;
 }
 

Modified: cfe/trunk/test/Analysis/misc-ps.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/misc-ps.c?rev=132769&r1=132768&r2=132769&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/misc-ps.c (original)
+++ cfe/trunk/test/Analysis/misc-ps.c Thu Jun  9 00:44:04 2011
@@ -50,3 +50,15 @@
   return *t; // expected-warning {{null pointer}}
 }
 
+int PR8962_c (int *t) {
+  // If the last element in a StmtExpr was a ParenExpr, it's still live
+  if (({ (t ? (_Bool)0 : (_Bool)1); })) return 0;
+  return *t; // no-warning
+}
+
+int PR8962_d (int *t) {
+  // If the last element in a StmtExpr is an __extension__, it's still live
+  if (({ __extension__(t ? (_Bool)0 : (_Bool)1); })) return 0;
+  return *t; // no-warning
+}
+





More information about the cfe-commits mailing list