[llvm-branch-commits] [cfe-branch] r127613 - in /cfe/branches/release_29: ./ lib/Analysis/CFG.cpp test/Analysis/misc-ps.m test/SemaCXX/warn-unreachable.cpp
Bill Wendling
isanbard at gmail.com
Mon Mar 14 13:22:59 PDT 2011
Author: void
Date: Mon Mar 14 15:22:59 2011
New Revision: 127613
URL: http://llvm.org/viewvc/llvm-project?rev=127613&view=rev
Log:
--- Merging r127563 into '.':
U test/Analysis/misc-ps.m
U lib/Analysis/CFG.cpp
Modified:
cfe/branches/release_29/ (props changed)
cfe/branches/release_29/lib/Analysis/CFG.cpp
cfe/branches/release_29/test/Analysis/misc-ps.m
cfe/branches/release_29/test/SemaCXX/warn-unreachable.cpp (props changed)
Propchange: cfe/branches/release_29/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Mar 14 15:22:59 2011
@@ -1,2 +1,2 @@
-/cfe/trunk:127460
+/cfe/trunk:127460,127563
/cfe/trunk/test/SemaTemplate:126920
Modified: cfe/branches/release_29/lib/Analysis/CFG.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_29/lib/Analysis/CFG.cpp?rev=127613&r1=127612&r2=127613&view=diff
==============================================================================
--- cfe/branches/release_29/lib/Analysis/CFG.cpp (original)
+++ cfe/branches/release_29/lib/Analysis/CFG.cpp Mon Mar 14 15:22:59 2011
@@ -2201,8 +2201,9 @@
// Determine if the switch condition can be explicitly evaluated.
assert(Terminator->getCond() && "switch condition must be non-NULL");
Expr::EvalResult result;
- tryEvaluate(Terminator->getCond(), result);
- SaveAndRestore<Expr::EvalResult*> save_switchCond(switchCond, &result);
+ bool b = tryEvaluate(Terminator->getCond(), result);
+ SaveAndRestore<Expr::EvalResult*> save_switchCond(switchCond,
+ b ? &result : 0);
// If body is not a compound statement create implicit scope
// and add destructors.
@@ -2239,18 +2240,21 @@
}
static bool shouldAddCase(bool &switchExclusivelyCovered,
- const Expr::EvalResult &switchCond,
+ const Expr::EvalResult *switchCond,
const CaseStmt *CS,
ASTContext &Ctx) {
+ if (!switchCond)
+ return true;
+
bool addCase = false;
if (!switchExclusivelyCovered) {
- if (switchCond.Val.isInt()) {
+ if (switchCond->Val.isInt()) {
// Evaluate the LHS of the case value.
Expr::EvalResult V1;
CS->getLHS()->Evaluate(V1, Ctx);
assert(V1.Val.isInt());
- const llvm::APSInt &condInt = switchCond.Val.getInt();
+ const llvm::APSInt &condInt = switchCond->Val.getInt();
const llvm::APSInt &lhsInt = V1.Val.getInt();
if (condInt == lhsInt) {
@@ -2280,7 +2284,6 @@
// CaseStmts are essentially labels, so they are the first statement in a
// block.
CFGBlock *TopBlock = 0, *LastBlock = 0;
- assert(switchCond);
if (Stmt *Sub = CS->getSubStmt()) {
// For deeply nested chains of CaseStmts, instead of doing a recursion
@@ -2296,7 +2299,7 @@
TopBlock = currentBlock;
addSuccessor(SwitchTerminatedBlock,
- shouldAddCase(switchExclusivelyCovered, *switchCond,
+ shouldAddCase(switchExclusivelyCovered, switchCond,
CS, *Context)
? currentBlock : 0);
@@ -2323,7 +2326,7 @@
// statement.
assert(SwitchTerminatedBlock);
addSuccessor(SwitchTerminatedBlock,
- shouldAddCase(switchExclusivelyCovered, *switchCond,
+ shouldAddCase(switchExclusivelyCovered, switchCond,
CS, *Context)
? CaseBlock : 0);
Modified: cfe/branches/release_29/test/Analysis/misc-ps.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_29/test/Analysis/misc-ps.m?rev=127613&r1=127612&r2=127613&view=diff
==============================================================================
--- cfe/branches/release_29/test/Analysis/misc-ps.m (original)
+++ cfe/branches/release_29/test/Analysis/misc-ps.m Mon Mar 14 15:22:59 2011
@@ -1287,4 +1287,17 @@
break;
}
}
-}
\ No newline at end of file
+}
+
+// PR 9467. Tests various CFG optimizations. This previously crashed.
+static void test(unsigned int bit_mask)
+{
+ unsigned int bit_index;
+ for (bit_index = 0;
+ bit_index < 24;
+ bit_index++) {
+ switch ((0x01 << bit_index) & bit_mask) {
+ case 0x100000: ;
+ }
+ }
+}
Propchange: cfe/branches/release_29/test/SemaCXX/warn-unreachable.cpp
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Mar 14 15:22:59 2011
@@ -1 +1 @@
-/cfe/trunk/test/SemaCXX/warn-unreachable.cpp:121961,127460
+/cfe/trunk/test/SemaCXX/warn-unreachable.cpp:121961,127460,127563
More information about the llvm-branch-commits
mailing list