Handle new throw expressions

This commit is contained in:
Martin Kinkelin 2022-02-19 19:28:08 +01:00
parent 78681e12e1
commit 5c9f1e5fd6
4 changed files with 32 additions and 14 deletions

View file

@ -270,7 +270,7 @@ LLValue *DtoAllocaDump(LLValue *val, LLType *asType, int alignment,
}
/******************************************************************************
* ASSERT HELPER
* ASSERT HELPERS
******************************************************************************/
void DtoAssert(Module *M, const Loc &loc, DValue *msg) {
@ -339,6 +339,21 @@ void DtoCAssert(Module *M, const Loc &loc, LLValue *msg) {
gIR->ir->CreateUnreachable();
}
/******************************************************************************
* THROW HELPER
******************************************************************************/
void DtoThrow(const Loc &loc, DValue *e) {
LLFunction *fn = getRuntimeFunction(loc, gIR->module, "_d_throw_exception");
LLValue *arg = DtoBitCast(DtoRVal(e), fn->getFunctionType()->getParamType(0));
gIR->CreateCallOrInvoke(fn, arg);
gIR->ir->CreateUnreachable();
llvm::BasicBlock *bb = gIR->insertBB("afterthrow");
gIR->ir->SetInsertPoint(bb);
}
/******************************************************************************
* MODULE FILE NAME
******************************************************************************/