[cfe-commits] r64068 - in /cfe/trunk/lib/CodeGen: CodeGenFunction.cpp CodeGenFunction.h

Anders Carlsson andersca at mac.com
Sat Feb 7 19:22:37 PST 2009


Author: andersca
Date: Sat Feb  7 21:22:36 2009
New Revision: 64068

URL: http://llvm.org/viewvc/llvm-project?rev=64068&view=rev
Log:
CleanupScope needs to push the cleanup block in its destructor

Modified:
    cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
    cfe/trunk/lib/CodeGen/CodeGenFunction.h

Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.cpp?rev=64068&r1=64067&r2=64068&view=diff

==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenFunction.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.cpp Sat Feb  7 21:22:36 2009
@@ -517,13 +517,9 @@
   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)

Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.h?rev=64068&r1=64067&r2=64068&view=diff

==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenFunction.h (original)
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.h Sat Feb  7 21:22:36 2009
@@ -128,25 +128,27 @@
   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);
     }
   };





More information about the cfe-commits mailing list