From ed84a21462ab710c0e3eb6edafd85d3062add0bd Mon Sep 17 00:00:00 2001 From: Alexey Prokhin Date: Fri, 22 Jul 2011 19:44:16 +0400 Subject: [PATCH] Fixed try/finally statements inside another finally --- ir/irlandingpad.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/ir/irlandingpad.cpp b/ir/irlandingpad.cpp index fa5078ab..9f769b07 100644 --- a/ir/irlandingpad.cpp +++ b/ir/irlandingpad.cpp @@ -153,12 +153,17 @@ void IRLandingPad::constructLandingPad(llvm::BasicBlock* inBB) // emit finallys and 'if' chain to catch the exception llvm::Function* eh_typeid_for_fn = GET_INTRINSIC_DECL(eh_typeid_for); + std::deque infos = this->infos; + std::stack nInfos = this->nInfos; std::deque::reverse_iterator rit, rend = infos.rend(); for(rit = infos.rbegin(); rit != rend; ++rit) { // if it's a finally, emit its code if(rit->finallyBody) { + size_t n = this->nInfos.top(); + this->infos.resize(n); + this->nInfos.pop(); rit->finallyBody->toIR(gIR); } // otherwise it's a catch and we'll add a if-statement @@ -173,6 +178,10 @@ void IRLandingPad::constructLandingPad(llvm::BasicBlock* inBB) } } + // restore landing pad infos + this->infos = infos; + this->nInfos = nInfos; + // no catch matched and all finallys executed - resume unwind llvm::Function* unwind_resume_fn = LLVM_D_GetRuntimeFunction(gIR->module, "_d_eh_resume_unwind"); gIR->ir->CreateCall(unwind_resume_fn, eh_ptr);