mirror of
https://github.com/ldc-developers/ldc.git
synced 2025-04-30 15:10:59 +03:00
-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:
parent
fbbbeecaca
commit
30b858781b
10 changed files with 106 additions and 32 deletions
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue