fix a couple switch codegen problems Oliver reported.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@44484 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/CodeGen/CGStmt.cpp b/CodeGen/CGStmt.cpp
index 9665e7d..9059a83 100644
--- a/CodeGen/CGStmt.cpp
+++ b/CodeGen/CGStmt.cpp
@@ -468,7 +468,7 @@
 
   // 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 @@
   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;