[svn r340] Rework exception handling to work with nested tryfinally and trycatch.

This commit is contained in:
Christian Kamm
2008-07-05 10:22:56 +02:00
parent 4fc93770a9
commit ce79feeb9b
6 changed files with 295 additions and 136 deletions

View File

@@ -172,10 +172,6 @@ struct IRState
llvm::BasicBlock* scopeend();
bool scopereturned();
// landing pads for try statements
typedef std::vector<llvm::BasicBlock*> BBVec;
BBVec landingPads;
// create a call or invoke, depending on the landing pad info
// the template function is defined further down in this file
template <typename InputIterator>
@@ -229,15 +225,16 @@ struct IRState
template <typename InputIterator>
CallOrInvoke* IRState::CreateCallOrInvoke(LLValue* Callee, InputIterator ArgBegin, InputIterator ArgEnd, const char* Name)
{
if(landingPads.empty())
return new CallOrInvoke_Call(ir->CreateCall(Callee, ArgBegin, ArgEnd, Name));
else
llvm::BasicBlock* pad;
if(pad = func()->landingPad.get())
{
llvm::BasicBlock* postinvoke = llvm::BasicBlock::Create("postinvoke", topfunc(), scopeend());
llvm::InvokeInst* invoke = ir->CreateInvoke(Callee, postinvoke, *landingPads.rbegin(), ArgBegin, ArgEnd, Name);
llvm::InvokeInst* invoke = ir->CreateInvoke(Callee, postinvoke, pad, ArgBegin, ArgEnd, Name);
scope() = IRScope(postinvoke, scopeend());
return new CallOrInvoke_Invoke(invoke);
}
else
return new CallOrInvoke_Call(ir->CreateCall(Callee, ArgBegin, ArgEnd, Name));
}
#endif // LLVMDC_GEN_IRSTATE_H