summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CGStmt.cpp
diff options
context:
space:
mode:
authorFariborz Jahanian <fjahanian@apple.com>2012-01-16 17:35:57 +0000
committerFariborz Jahanian <fjahanian@apple.com>2012-01-16 17:35:57 +0000
commit9c882f98cc7eb4b1bf27e1af4111701867c36832 (patch)
tree6280e892511324f0bec24cf012b382e7406b4153 /clang/lib/CodeGen/CGStmt.cpp
parentfa35df628a4ab331347dc448ccde573d6a7fa81d (diff)
downloadbcm5719-llvm-9c882f98cc7eb4b1bf27e1af4111701867c36832.tar.gz
bcm5719-llvm-9c882f98cc7eb4b1bf27e1af4111701867c36832.zip
Fixes a crash during constant folding of a switch and case
statement which has an unscoped case inside it. Patch by Aaron Ballman llvm-svn: 148243
Diffstat (limited to 'clang/lib/CodeGen/CGStmt.cpp')
-rw-r--r--clang/lib/CodeGen/CGStmt.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/clang/lib/CodeGen/CGStmt.cpp b/clang/lib/CodeGen/CGStmt.cpp
index 594281d15e8..ee4a272ea88 100644
--- a/clang/lib/CodeGen/CGStmt.cpp
+++ b/clang/lib/CodeGen/CGStmt.cpp
@@ -878,6 +878,16 @@ void CodeGenFunction::EmitCaseStmtRange(const CaseStmt &S) {
}
void CodeGenFunction::EmitCaseStmt(const CaseStmt &S) {
+ // If there is no enclosing switch instance that we're aware of, then this
+ // case statement and its block can be elided. This situation only happens
+ // when we've constant-folded the switch, are emitting the constant case,
+ // and part of the constant case includes another case statement. For
+ // instance: switch (4) { case 4: do { case 5: } while (1); }
+ if (!SwitchInsn) {
+ EmitStmt(S.getSubStmt());
+ return;
+ }
+
// Handle case ranges.
if (S.getRHS()) {
EmitCaseStmtRange(S);
OpenPOWER on IntegriCloud