-betterC: Use C assert function

Instead of druntime's _d_assert[_msg], _d_arraybounds and
_d_switch_error.

Tested by dmd-testsuite's runnable/cassert and compilable/betterCarray.
This commit is contained in:
Martin 2017-10-13 19:49:24 +02:00
parent fbbbeecaca
commit 30b858781b
10 changed files with 106 additions and 32 deletions

View file

@ -1377,12 +1377,17 @@ void DtoIndexBoundsCheck(Loc &loc, DValue *arr, DValue *index) {
}
void DtoBoundsCheckFailCall(IRState *irs, Loc &loc) {
llvm::Function *errorfn =
getRuntimeFunction(loc, irs->module, "_d_arraybounds");
irs->CreateCallOrInvoke(
errorfn, DtoModuleFileName(irs->func()->decl->getModule(), loc),
DtoConstUint(loc.linnum));
Module *const module = irs->func()->decl->getModule();
// the function does not return
irs->ir->CreateUnreachable();
if (global.params.betterC) {
DtoCAssert(module, loc, DtoConstCString("array overflow"));
} else {
llvm::Function *errorfn =
getRuntimeFunction(loc, irs->module, "_d_arraybounds");
irs->CreateCallOrInvoke(errorfn, DtoModuleFileName(module, loc),
DtoConstUint(loc.linnum));
// the function does not return
irs->ir->CreateUnreachable();
}
}