Mercurial > projects > ldc
comparison ir/irlandingpad.cpp @ 320:d772927ca496 trunk
[svn r341] Fix all regressions between [332] and [340]:
- fixed assert on empty catch body
- fixed(?) typedefed classes in catch specification
- fixed assert with catchall
Added some documentation.
author | ChristianK |
---|---|
date | Sat, 05 Jul 2008 13:05:29 +0200 |
parents | e9c93739bc4c |
children | d7e6ace5cca4 |
comparison
equal
deleted
inserted
replaced
319:e9c93739bc4c | 320:d772927ca496 |
---|---|
19 catchstmt->var->ir.irLocal = new IrLocal(catchstmt->var); | 19 catchstmt->var->ir.irLocal = new IrLocal(catchstmt->var); |
20 LLValue* catch_var = gIR->func()->landingPad.getExceptionStorage(); | 20 LLValue* catch_var = gIR->func()->landingPad.getExceptionStorage(); |
21 catchstmt->var->ir.irLocal->value = gIR->ir->CreateBitCast(catch_var, getPtrToType(DtoType(catchstmt->var->type))); | 21 catchstmt->var->ir.irLocal->value = gIR->ir->CreateBitCast(catch_var, getPtrToType(DtoType(catchstmt->var->type))); |
22 } | 22 } |
23 | 23 |
24 // emit handler | 24 // emit handler, if there is one |
25 assert(catchstmt->handler); | 25 // handler is zero for instance for 'catch { debug foo(); }' |
26 catchstmt->handler->toIR(gIR); | 26 if(catchstmt->handler); |
27 catchstmt->handler->toIR(gIR); | |
27 | 28 |
28 if (!gIR->scopereturned()) | 29 if (!gIR->scopereturned()) |
29 gIR->ir->CreateBr(end); | 30 gIR->ir->CreateBr(end); |
30 | 31 |
31 assert(catchstmt->type); | 32 assert(catchstmt->type); |
32 catchType = catchstmt->type->isClassHandle(); | 33 //TODO: Is toBasetype correct here? Should catch handlers with typedefed |
34 // classes behave differently? | |
35 catchType = catchstmt->type->toBasetype()->isClassHandle(); | |
36 assert(catchType); | |
33 DtoForceDeclareDsymbol(catchType); | 37 DtoForceDeclareDsymbol(catchType); |
34 assert(catchType); | |
35 } | 38 } |
36 | 39 |
37 IRLandingPadInfo::IRLandingPadInfo(Statement* finallystmt) | 40 IRLandingPadInfo::IRLandingPadInfo(Statement* finallystmt) |
38 : target(NULL), finallyBody(finallystmt), catchType(NULL) | 41 : target(NULL), finallyBody(finallystmt), catchType(NULL) |
39 { | 42 { |
120 } | 123 } |
121 } | 124 } |
122 // if there's a finally, the eh table has to have a 0 action | 125 // if there's a finally, the eh table has to have a 0 action |
123 if(hasFinally) | 126 if(hasFinally) |
124 selectorargs.push_back(llvm::ConstantInt::get(LLType::Int32Ty, 0)); | 127 selectorargs.push_back(llvm::ConstantInt::get(LLType::Int32Ty, 0)); |
125 // if there is a catch, store exception object | 128 // if there is a catch and some catch allocated storage, store exception object |
126 if(catchToInt.size()) | 129 if(catchToInt.size() && catch_var) |
127 { | 130 { |
128 const LLType* objectTy = DtoType(ClassDeclaration::object->type); | 131 const LLType* objectTy = DtoType(ClassDeclaration::object->type); |
129 assert(catch_var); | |
130 gIR->ir->CreateStore(gIR->ir->CreateBitCast(eh_ptr, objectTy), catch_var); | 132 gIR->ir->CreateStore(gIR->ir->CreateBitCast(eh_ptr, objectTy), catch_var); |
131 } | 133 } |
132 | 134 |
133 // eh_sel = llvm.eh.selector(eh_ptr, cast(byte*)&_d_eh_personality, <selectorargs>); | 135 // eh_sel = llvm.eh.selector(eh_ptr, cast(byte*)&_d_eh_personality, <selectorargs>); |
134 llvm::Function* eh_selector_fn; | 136 llvm::Function* eh_selector_fn; |