diff options
author | Chris Lattner <sabre@nondot.org> | 2011-02-28 07:16:14 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2011-02-28 07:16:14 +0000 |
commit | 9467110fcef8a3e4caf9e5d022cff0322afe6e8b (patch) | |
tree | ac3471512cb5195eb9a546438603aa18d2d5e80a /lib/CodeGen/CGStmt.cpp | |
parent | c480ac8b5034cfb57caf86247549d10fd01a17ed (diff) |
make switch constant folding a bit stronger, handling a missed case.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@126638 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGStmt.cpp')
-rw-r--r-- | lib/CodeGen/CGStmt.cpp | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/lib/CodeGen/CGStmt.cpp b/lib/CodeGen/CGStmt.cpp index c67d1d1b0d..21fb36a72d 100644 --- a/lib/CodeGen/CGStmt.cpp +++ b/lib/CodeGen/CGStmt.cpp @@ -895,9 +895,14 @@ static CSFC_Result CollectStatementsForCase(const Stmt *S, case CSFC_Success: // A successful result means that either 1) that the statement doesn't // have the case and is skippable, or 2) does contain the case value - // and also contains the break to exit the switch. In either case, - // we continue scanning the body of the compound statement to see if - // the rest are skippable or have the case. + // and also contains the break to exit the switch. In the later case, + // we just verify the rest of the statements are elidable. + if (FoundCase) { + for (++I; I != E; ++I) + if (CodeGenFunction::ContainsLabel(*I, true)) + return CSFC_Failure; + return CSFC_Success; + } break; case CSFC_FallThrough: // If we have a fallthrough condition, then we must have found the |