diff options
author | Chris Lattner <sabre@nondot.org> | 2007-12-01 05:27:33 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2007-12-01 05:27:33 +0000 |
commit | 1438b4918a1658ef6467488109ca434e775e58e5 (patch) | |
tree | 9fdfbec3fd24698df0f47f4406e3de34f2809be0 | |
parent | 68072a7f22bf73a3d75b6d1e7bf08ebc4d7a4781 (diff) |
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
-rw-r--r-- | CodeGen/CGStmt.cpp | 5 | ||||
-rw-r--r-- | clang.xcodeproj/project.pbxproj | 1 | ||||
-rw-r--r-- | test/CodeGen/switch.c | 10 |
3 files changed, 15 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; diff --git a/clang.xcodeproj/project.pbxproj b/clang.xcodeproj/project.pbxproj index db10ad3f44..1585d851d9 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 a4d77b9c19..3697ce7c02 100644 --- a/test/CodeGen/switch.c +++ b/test/CodeGen/switch.c @@ -64,3 +64,13 @@ int foo4(int i) { } return j; } + +void foo5(){ + switch(0){ + default: + if (0) { + + } + } +} + |