[cfe-commits] r117220 - in /cfe/trunk: lib/Analysis/CFG.cpp test/Sema/warn-unreachable.c

Marcin Swiderski marcin.sfider at gmail.com
Sun Oct 24 01:21:40 PDT 2010


Author: sfider
Date: Sun Oct 24 03:21:40 2010
New Revision: 117220

URL: http://llvm.org/viewvc/llvm-project?rev=117220&view=rev
Log:
- Fixed subexpressions evaluation order for binary operators to match order in code generated with the compiler,
- Fixed test cases for unreachable code warnings produced by Sema.

Modified:
    cfe/trunk/lib/Analysis/CFG.cpp
    cfe/trunk/test/Sema/warn-unreachable.c

Modified: cfe/trunk/lib/Analysis/CFG.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/CFG.cpp?rev=117220&r1=117219&r2=117220&view=diff
==============================================================================
--- cfe/trunk/lib/Analysis/CFG.cpp (original)
+++ cfe/trunk/lib/Analysis/CFG.cpp Sun Oct 24 03:21:40 2010
@@ -912,15 +912,17 @@
       AppendStmt(Block, B, asc);
     }
 
-    // If visiting RHS causes us to finish 'Block' and the LHS doesn't
-    // create a new block, then we should return RBlock.  Otherwise
-    // we'll incorrectly return NULL.
-    CFGBlock *RBlock = Visit(B->getRHS());
-    CFGBlock *LBlock = Visit(B->getLHS(), AddStmtChoice::AsLValueNotAlwaysAdd);
-    return LBlock ? LBlock : RBlock;
+    Visit(B->getLHS(), AddStmtChoice::AsLValueNotAlwaysAdd);
+    return Visit(B->getRHS());
   }
 
-  return VisitStmt(B, asc);
+  if (asc.alwaysAdd()) {
+    autoCreateBlock();
+    AppendStmt(Block, B, asc);
+  }
+
+  Visit(B->getRHS());
+  return Visit(B->getLHS());
 }
 
 CFGBlock *CFGBuilder::VisitBlockExpr(BlockExpr *E, AddStmtChoice asc) {

Modified: cfe/trunk/test/Sema/warn-unreachable.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/warn-unreachable.c?rev=117220&r1=117219&r2=117220&view=diff
==============================================================================
--- cfe/trunk/test/Sema/warn-unreachable.c (original)
+++ cfe/trunk/test/Sema/warn-unreachable.c Sun Oct 24 03:21:40 2010
@@ -35,8 +35,8 @@
       dead();   // expected-warning {{will never be executed}}
 
   case 3:
-  live()        // expected-warning {{will never be executed}}
-    +           
+  live()
+    +           // expected-warning {{will never be executed}}
     halt();
   dead();
 
@@ -75,8 +75,8 @@
     goto c6;
   case 7:
     halt()
-      +         // expected-warning {{will never be executed}}
-      dead();
+      +
+      dead();   // expected-warning {{will never be executed}}
     -           // expected-warning {{will never be executed}}
       halt();
   case 8:





More information about the cfe-commits mailing list