Fix #308 by giving finally code emitted by EnclosingTryFinally a different landing pad.

This commit is contained in:
Christian Kamm
2009-05-23 00:23:39 +02:00
parent adfc5b3ee9
commit 5b799deeb4
7 changed files with 29 additions and 15 deletions

View File

@@ -117,6 +117,8 @@ IrFunction::IrFunction(FuncDeclaration* fd)
_arguments = NULL;
_argptr = NULL;
landingPad = NULL;
nextUnique.push(0);
}

View File

@@ -70,7 +70,8 @@ struct IrFunction : IrBase
LabelToBBMap labelToBB;
// landing pads for try statements
IRLandingPad landingPad;
IRLandingPad landingPadInfo;
llvm::BasicBlock* landingPad;
// loop blocks
typedef std::vector<IRTargetScope> TargetScopeVec;

View File

@@ -24,7 +24,7 @@ IRLandingPadInfo::IRLandingPadInfo(Catch* catchstmt, llvm::BasicBlock* end)
#endif
assert(!catchstmt->var->ir.irLocal);
catchstmt->var->ir.irLocal = new IrLocal(catchstmt->var);
LLValue* catch_var = gIR->func()->landingPad.getExceptionStorage();
LLValue* catch_var = gIR->func()->landingPadInfo.getExceptionStorage();
catchstmt->var->ir.irLocal->value = gIR->ir->CreateBitCast(catch_var, getPtrToType(DtoType(catchstmt->var->type)));
}
@@ -32,8 +32,8 @@ IRLandingPadInfo::IRLandingPadInfo(Catch* catchstmt, llvm::BasicBlock* end)
DtoDeclarationExp(catchstmt->var);
// the exception will only be stored in catch_var. copy it over if necessary
if(catchstmt->var->ir.irLocal->value != gIR->func()->landingPad.getExceptionStorage()) {
LLValue* exc = gIR->ir->CreateBitCast(DtoLoad(gIR->func()->landingPad.getExceptionStorage()), DtoType(catchstmt->var->type));
if(catchstmt->var->ir.irLocal->value != gIR->func()->landingPadInfo.getExceptionStorage()) {
LLValue* exc = gIR->ir->CreateBitCast(DtoLoad(gIR->func()->landingPadInfo.getExceptionStorage()), DtoType(catchstmt->var->type));
DtoStore(exc, catchstmt->var->ir.irLocal->value);
}
}