]> granicus.if.org Git - clang/commitdiff
I failed to notice that my last patch wasn't doing as much as it could
authorJohn McCall <rjmccall@apple.com>
Wed, 21 Apr 2010 11:18:06 +0000 (11:18 +0000)
committerJohn McCall <rjmccall@apple.com>
Wed, 21 Apr 2010 11:18:06 +0000 (11:18 +0000)
because EmitBranch actually clears the insert point.  This version
actually accomplishes what I initially wanted.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@101998 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGStmt.cpp
lib/CodeGen/CodeGenFunction.h

index eb861f469063f4bf6273285a3011d5ba2b38073d..70cb1a2eca0fe172a19c0fcf16d7e4ded0647722 100644 (file)
@@ -205,6 +205,8 @@ void CodeGenFunction::SimplifyForwardingBlocks(llvm::BasicBlock *BB) {
 }
 
 void CodeGenFunction::EmitBlock(llvm::BasicBlock *BB, bool IsFinished) {
+  llvm::BasicBlock *CurBB = Builder.GetInsertBlock();
+
   // Fall out of the current block (if necessary).
   EmitBranch(BB);
 
@@ -227,8 +229,8 @@ void CodeGenFunction::EmitBlock(llvm::BasicBlock *BB, bool IsFinished) {
 
   // Place the block after the current block, if possible, or else at
   // the end of the function.
-  if (Builder.GetInsertBlock())
-    CurFn->getBasicBlockList().insertAfter(Builder.GetInsertBlock(), BB);
+  if (CurBB && CurBB->getParent())
+    CurFn->getBasicBlockList().insertAfter(CurBB, BB);
   else
     CurFn->getBasicBlockList().push_back(BB);
   Builder.SetInsertPoint(BB);
index 7072301b4bc7f39b6f55dc854ea2fa807213e08a..a913459adee4ef033c853911688ea165026771da 100644 (file)
@@ -184,7 +184,8 @@ public:
   public:
     DelayedCleanupBlock(CodeGenFunction &cgf, bool ehonly = false)
       : CGF(cgf), CurBB(CGF.Builder.GetInsertBlock()),
-        CleanupEntryBB(CGF.createBasicBlock("cleanup")), CleanupExitBB(0),
+        CleanupEntryBB(CGF.createBasicBlock("cleanup")),
+        CleanupExitBB(0),
         CurInvokeDest(CGF.getInvokeDest()),
         EHOnly(ehonly) {
       CGF.Builder.SetInsertPoint(CleanupEntryBB);