comparison ir/irlandingpad.cpp @ 745:5761d7e6f628

Tried using DtoDeclarationExp for VarDecls in Statements to fix nesting issues (see bug #104), but a separate helper that doesn't initialize would be nicer.
author Christian Kamm <kamm incasoftware de>
date Sat, 01 Nov 2008 16:48:17 +0100
parents d97b017a8aef
children f04dde6e882c
comparison
equal deleted inserted replaced
744:ef5f75ae6895 745:5761d7e6f628
13 target = llvm::BasicBlock::Create("catch", gIR->topfunc(), end); 13 target = llvm::BasicBlock::Create("catch", gIR->topfunc(), end);
14 gIR->scope() = IRScope(target,end); 14 gIR->scope() = IRScope(target,end);
15 15
16 // assign storage to catch var 16 // assign storage to catch var
17 if(catchstmt->var) { 17 if(catchstmt->var) {
18 assert(!catchstmt->var->ir.irLocal); 18 // use the same storage for all exceptions that are not accessed in
19 catchstmt->var->ir.irLocal = new IrLocal(catchstmt->var); 19 // nested functions
20 LLValue* catch_var = gIR->func()->landingPad.getExceptionStorage(); 20 if(!catchstmt->var->nestedref) {
21 catchstmt->var->ir.irLocal->value = gIR->ir->CreateBitCast(catch_var, getPtrToType(DtoType(catchstmt->var->type))); 21 assert(!catchstmt->var->ir.irLocal);
22 catchstmt->var->ir.irLocal = new IrLocal(catchstmt->var);
23 LLValue* catch_var = gIR->func()->landingPad.getExceptionStorage();
24 catchstmt->var->ir.irLocal->value = gIR->ir->CreateBitCast(catch_var, getPtrToType(DtoType(catchstmt->var->type)));
25 }
26
27 // this will alloca if we haven't already and take care of nested refs
28 DtoDeclarationExp(catchstmt->var);
29
30 // the exception will only be stored in catch_var. copy it over if necessary
31 if(catchstmt->var->ir.irLocal->value != gIR->func()->landingPad.getExceptionStorage()) {
32 LLValue* exc = gIR->ir->CreateBitCast(DtoLoad(gIR->func()->landingPad.getExceptionStorage()), DtoType(catchstmt->var->type));
33 DtoStore(exc, catchstmt->var->ir.irLocal->value);
34 }
22 } 35 }
23 36
24 // emit handler, if there is one 37 // emit handler, if there is one
25 // handler is zero for instance for 'catch { debug foo(); }' 38 // handler is zero for instance for 'catch { debug foo(); }'
26 if(catchstmt->handler) 39 if(catchstmt->handler)