mirror of
https://github.com/ldc-developers/ldc.git
synced 2025-05-04 00:55:49 +03:00
Fix DIP1008
Invoke _d_newThrowable for exception allocation & initialization, and increase the reference count in LDC-specific _d_throw_exception for MSVC targets. Fixes runnable/test19317.d.
This commit is contained in:
parent
89d72b646e
commit
ef2bbfa09b
3 changed files with 18 additions and 7 deletions
|
@ -82,6 +82,7 @@ DValue *DtoNewClass(Loc &loc, TypeClass *tc, NewExp *newexp) {
|
|||
|
||||
// allocate
|
||||
LLValue *mem;
|
||||
bool doInit = true;
|
||||
if (newexp->onstack) {
|
||||
unsigned alignment = tc->sym->alignsize;
|
||||
if (alignment == STRUCTALIGN_DEFAULT)
|
||||
|
@ -98,17 +99,23 @@ DValue *DtoNewClass(Loc &loc, TypeClass *tc, NewExp *newexp) {
|
|||
}
|
||||
// default allocator
|
||||
else {
|
||||
llvm::Function *fn =
|
||||
getRuntimeFunction(loc, gIR->module, "_d_allocclass");
|
||||
const bool useEHAlloc = global.params.ehnogc && newexp->thrownew;
|
||||
llvm::Function *fn = getRuntimeFunction(
|
||||
loc, gIR->module, useEHAlloc ? "_d_newThrowable" : "_d_allocclass");
|
||||
LLConstant *ci = DtoBitCast(getIrAggr(tc->sym)->getClassInfoSymbol(),
|
||||
DtoType(getClassInfoType()));
|
||||
mem =
|
||||
gIR->CreateCallOrInvoke(fn, ci, ".newclass_gc_alloc").getInstruction();
|
||||
mem = DtoBitCast(mem, DtoType(tc), ".newclass_gc");
|
||||
mem = gIR->CreateCallOrInvoke(fn, ci,
|
||||
useEHAlloc ? ".newthrowable_alloc"
|
||||
: ".newclass_gc_alloc")
|
||||
.getInstruction();
|
||||
mem = DtoBitCast(mem, DtoType(tc),
|
||||
useEHAlloc ? ".newthrowable" : ".newclass_gc");
|
||||
doInit = !useEHAlloc;
|
||||
}
|
||||
|
||||
// init
|
||||
DtoInitClass(tc, mem);
|
||||
if (doInit)
|
||||
DtoInitClass(tc, mem);
|
||||
|
||||
// init inner-class outer reference
|
||||
if (newexp->thisexp) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue