aboutsummaryrefslogtreecommitdiff
path: root/CodeGen
diff options
context:
space:
mode:
Diffstat (limited to 'CodeGen')
-rw-r--r--CodeGen/CGStmt.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/CodeGen/CGStmt.cpp b/CodeGen/CGStmt.cpp
index 9665e7dc63..9059a83119 100644
--- a/CodeGen/CGStmt.cpp
+++ b/CodeGen/CGStmt.cpp
@@ -468,7 +468,7 @@ void CodeGenFunction::EmitSwitchStmt(const SwitchStmt &S) {
// Create basic block to hold stuff that comes after switch statement.
// Initially use it to hold DefaultStmt.
- llvm::BasicBlock *NextBlock = new llvm::BasicBlock("after.sw", CurFn);
+ llvm::BasicBlock *NextBlock = new llvm::BasicBlock("after.sw");
SwitchInsn = Builder.CreateSwitch(CondV, NextBlock);
// All break statements jump to NextBlock. If BreakContinueStack is non empty
@@ -492,8 +492,11 @@ void CodeGenFunction::EmitSwitchStmt(const SwitchStmt &S) {
llvm::BasicBlock *BB = Builder.GetInsertBlock();
if (isDummyBlock(BB))
BB->eraseFromParent();
+ else // Otherwise, branch to continuation.
+ Builder.CreateBr(NextBlock);
// Place NextBlock as the new insert point.
+ CurFn->getBasicBlockList().push_back(NextBlock);
Builder.SetInsertPoint(NextBlock);
SwitchInsn = SavedSwitchInsn;
CaseRangeBlock = SavedCRBlock;