diff options
author | Daniel Dunbar <daniel@zuster.org> | 2008-09-30 01:06:03 +0000 |
---|---|---|
committer | Daniel Dunbar <daniel@zuster.org> | 2008-09-30 01:06:03 +0000 |
commit | 898d508d4c9e9d45914952473e39196b20830a9f (patch) | |
tree | e8c7ea7bf3d2719bf17ea24a33df5159417c0747 /lib/CodeGen/CodeGenFunction.h | |
parent | 8b30c412198ed004d999f0047e48f87b95bd3205 (diff) |
Add infrastructure for proper @finally support.
- Provides a basic primitive to jump to an arbitrary basic block,
through the finally code.
- Only used for return statements and rethrow currently. Still need
to handle break, continue and goto.
- Code still needs to be shuffled around to live elsewhere.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@56827 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CodeGenFunction.h')
-rw-r--r-- | lib/CodeGen/CodeGenFunction.h | 40 |
1 files changed, 35 insertions, 5 deletions
diff --git a/lib/CodeGen/CodeGenFunction.h b/lib/CodeGen/CodeGenFunction.h index 6aa2e4e79d..8058c342e7 100644 --- a/lib/CodeGen/CodeGenFunction.h +++ b/lib/CodeGen/CodeGenFunction.h @@ -31,6 +31,7 @@ namespace llvm { class BasicBlock; class Module; + class SwitchInst; } namespace clang { @@ -88,13 +89,42 @@ public: // inside @catch blocks and which @finally block exits from an EH // scope should be chained through. struct ObjCEHEntry { - ObjCEHEntry(llvm::BasicBlock *fb) - : Exception(0), FinallyBlock(fb) {} + ObjCEHEntry(llvm::BasicBlock *fb, llvm::BasicBlock *fne, + llvm::SwitchInst *fs, llvm::Value *dc) + : FinallyBlock(fb), FinallyNoExit(fne), FinallySwitch(fs), + DestCode(dc), Exception(0) {} - llvm::Value *Exception; - llvm::BasicBlock *FinallyBlock; + /// Entry point to the finally block. + llvm::BasicBlock *FinallyBlock; + + /// Entry point to the finally block which skips execution of the + /// try_exit runtime function. + llvm::BasicBlock *FinallyNoExit; + + /// Switch instruction which runs at the end of the finally block + /// to forward jumps through the finally block. + llvm::SwitchInst *FinallySwitch; + + /// Variable holding the code for the destination of a jump + /// through the @finally block. + llvm::Value *DestCode; + + /// The exception object being handled, during IR generation for a + /// @catch block. + llvm::Value *Exception; }; - llvm::SmallVector<ObjCEHEntry, 8> ObjCEHStack; + + typedef llvm::SmallVector<ObjCEHEntry*, 8> ObjCEHStackType; + ObjCEHStackType ObjCEHStack; + + /// EmitJumpThroughFinally - Emit a branch from the current insert + /// point through the finally handling code for \arg Entry and then + /// on to \arg Dest. + /// + /// \param ExecuteTryExit - When true, the try_exit runtime function + /// should be called prior to executing the finally code. + void EmitJumpThroughFinally(ObjCEHEntry *Entry, llvm::BasicBlock *Dest, + bool ExecuteTryExit=true); private: /// LabelIDs - Track arbitrary ids assigned to labels for use in |