]> granicus.if.org Git - clang/commitdiff
fix a couple switch codegen problems Oliver reported.
authorChris Lattner <sabre@nondot.org>
Sat, 1 Dec 2007 05:27:33 +0000 (05:27 +0000)
committerChris Lattner <sabre@nondot.org>
Sat, 1 Dec 2007 05:27:33 +0000 (05:27 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@44484 91177308-0d34-0410-b5e6-96231b3b80d8

CodeGen/CGStmt.cpp
clang.xcodeproj/project.pbxproj
test/CodeGen/switch.c

index 9665e7dc634fcae78c6c838e640e0866e19cd118..9059a83119e7f143b3cbad3759e362091578e047 100644 (file)
@@ -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;
index db10ad3f4485e2c426c967ccbb81ca21eff00545..1585d851d9ab75d8c3735019ca05102a2daa5db4 100644 (file)
                08FB7793FE84155DC02AAC07 /* Project object */ = {
                        isa = PBXProject;
                        buildConfigurationList = 1DEB923508733DC60010E9CD /* Build configuration list for PBXProject "clang" */;
+                       compatibilityVersion = "Xcode 2.4";
                        hasScannedForEncodings = 1;
                        mainGroup = 08FB7794FE84155DC02AAC07 /* clang */;
                        projectDirPath = "";
index a4d77b9c199daad043dc8f8d0b944a8bf322b1bc..3697ce7c02889d97b89c468990983412d2456cfa 100644 (file)
@@ -64,3 +64,13 @@ int foo4(int i) {
   }
   return j;
 }
+
+void foo5(){
+    switch(0){
+    default:
+        if (0) {
+
+        }
+    }
+}
+