diff options
author | Anders Carlsson <andersca@mac.com> | 2009-02-07 23:30:41 +0000 |
---|---|---|
committer | Anders Carlsson <andersca@mac.com> | 2009-02-07 23:30:41 +0000 |
commit | 0d5c6851393d260dfb5ab0420b50adc173e1c549 (patch) | |
tree | 93023a61d11e71b5e92ac992760cde7973fa939b | |
parent | 89941c1c68d8e4eec3c8ea8ee68e34d9e3c7b083 (diff) |
Add a simple RAII object, to be used for pushing a cleanup entry and make the insertion point be the cleanup block.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64048 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/CodeGen/CodeGenFunction.h | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/lib/CodeGen/CodeGenFunction.h b/lib/CodeGen/CodeGenFunction.h index 068627139d..1f037600f5 100644 --- a/lib/CodeGen/CodeGenFunction.h +++ b/lib/CodeGen/CodeGenFunction.h @@ -132,6 +132,25 @@ public: /// and return a BasicBlock where cleanup instructions can be added llvm::BasicBlock *CreateCleanupBlock(); + /// 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. + class CleanupScope { + CodeGenFunction& CGF; + llvm::BasicBlock *CurBB; + + public: + CleanupScope(CodeGenFunction &cgf) + : CGF(cgf), CurBB(CGF.Builder.GetInsertBlock()) { + llvm::BasicBlock *FinallyBB = CGF.CreateCleanupBlock(); + CGF.Builder.SetInsertPoint(FinallyBB); + } + + ~CleanupScope() { + CGF.Builder.SetInsertPoint(CurBB); + } + }; + private: /// LabelIDs - Track arbitrary ids assigned to labels for use in /// implementing the GCC address-of-label extension and indirect |