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;
diff --git a/clang.xcodeproj/project.pbxproj b/clang.xcodeproj/project.pbxproj
index db10ad3..1585d85 100644
--- a/clang.xcodeproj/project.pbxproj
+++ b/clang.xcodeproj/project.pbxproj
@@ -766,6 +766,7 @@
 		08FB7793FE84155DC02AAC07 /* Project object */ = {
 			isa = PBXProject;
 			buildConfigurationList = 1DEB923508733DC60010E9CD /* Build configuration list for PBXProject "clang" */;
+			compatibilityVersion = "Xcode 2.4";
 			hasScannedForEncodings = 1;
 			mainGroup = 08FB7794FE84155DC02AAC07 /* clang */;
 			projectDirPath = "";
diff --git a/test/CodeGen/switch.c b/test/CodeGen/switch.c
index a4d77b9..3697ce7 100644
--- a/test/CodeGen/switch.c
+++ b/test/CodeGen/switch.c
@@ -64,3 +64,13 @@
   }
   return j;
 }
+
+void foo5(){
+    switch(0){
+    default:
+        if (0) {
+
+        }
+    }
+}
+