]> granicus.if.org Git - clang/commitdiff
CleanupScope needs to push the cleanup block in its destructor
authorAnders Carlsson <andersca@mac.com>
Sun, 8 Feb 2009 03:22:36 +0000 (03:22 +0000)
committerAnders Carlsson <andersca@mac.com>
Sun, 8 Feb 2009 03:22:36 +0000 (03:22 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64068 91177308-0d34-0410-b5e6-96231b3b80d8

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

index 4b3ab2de194e92ff7eb62d69e3c3a67faf15de3b..e9bcfb51dc22c4f0174213bf8860d5c98ee7044e 100644 (file)
@@ -517,13 +517,9 @@ llvm::Value* CodeGenFunction::EmitVAListRef(const Expr* E) {
   return EmitLValue(E).getAddress();
 }
 
-llvm::BasicBlock *CodeGenFunction::CreateCleanupBlock()
+void CodeGenFunction::PushCleanupBlock(llvm::BasicBlock *CleanupBlock)
 {
-  llvm::BasicBlock *CleanupBlock = createBasicBlock("cleanup");
-  
   CleanupEntries.push_back(CleanupEntry(CleanupBlock));
-  
-  return CleanupBlock;  
 }
 
 void CodeGenFunction::EmitCleanupBlocks(size_t OldCleanupStackSize)
index b37cf7b919d76fd0495cce6159c925c71412270a..9eae28ca2af4fb67325874518b8cb46f4a9f0be6 100644 (file)
@@ -128,25 +128,27 @@ public:
   void EmitJumpThroughFinally(ObjCEHEntry *Entry, llvm::BasicBlock *Dest,
                               bool ExecuteTryExit=true);
   
-  /// CreateCleanupBlock - Will push a new cleanup entry on the stack
-  /// and return a BasicBlock where cleanup instructions can be added
-  llvm::BasicBlock *CreateCleanupBlock();
+  /// PushCleanupBlock - Push a new cleanup entry on the stack and set the
+  /// passed in block as the cleanup block.
+  void PushCleanupBlock(llvm::BasicBlock *CleanupBlock);
   
   /// CleanupScope - RAII object that will create a cleanup block and
   /// set the insert point to that block. When destructed, it sets the insert
-  /// point to the previous block.
+  /// point to the previous block and pushes a new cleanup entry on the stack.
   class CleanupScope {
     CodeGenFunction& CGF;
     llvm::BasicBlock *CurBB;
+    llvm::BasicBlock *CleanupBB;
     
   public:
     CleanupScope(CodeGenFunction &cgf)
       : CGF(cgf), CurBB(CGF.Builder.GetInsertBlock()) {
-      llvm::BasicBlock *FinallyBB = CGF.CreateCleanupBlock();
-      CGF.Builder.SetInsertPoint(FinallyBB);
+      CleanupBB = CGF.createBasicBlock("cleanup");
+      CGF.Builder.SetInsertPoint(CleanupBB);
     }
     
     ~CleanupScope() {
+      CGF.PushCleanupBlock(CleanupBB);
       CGF.Builder.SetInsertPoint(CurBB);
     }
   };