mirror of
https://github.com/ldc-developers/ldc.git
synced 2025-05-01 23:50:43 +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
|
@ -278,11 +278,37 @@ void DtoAssert(Module *M, Loc &loc, DValue *msg) {
|
|||
gIR->ir->CreateUnreachable();
|
||||
}
|
||||
|
||||
void DtoCAssert(Module *M, Loc &loc, LLValue *msg) {
|
||||
const auto file = DtoConstCString(loc.filename ? loc.filename
|
||||
: M->srcfile->name->toChars());
|
||||
const auto line = DtoConstUint(loc.linnum);
|
||||
const auto fn = getCAssertFunction(loc, gIR->module);
|
||||
|
||||
llvm::SmallVector<LLValue *, 4> args;
|
||||
if (global.params.targetTriple->isOSDarwin()) {
|
||||
const auto irFunc = gIR->func();
|
||||
const auto funcName =
|
||||
irFunc && irFunc->decl ? irFunc->decl->toPrettyChars() : "";
|
||||
args.push_back(DtoConstCString(funcName));
|
||||
args.push_back(file);
|
||||
args.push_back(line);
|
||||
args.push_back(msg);
|
||||
} else {
|
||||
args.push_back(msg);
|
||||
args.push_back(file);
|
||||
args.push_back(line);
|
||||
}
|
||||
|
||||
gIR->funcGen().callOrInvoke(fn, args);
|
||||
|
||||
gIR->ir->CreateUnreachable();
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* MODULE FILE NAME
|
||||
******************************************************************************/
|
||||
|
||||
LLValue *DtoModuleFileName(Module *M, const Loc &loc) {
|
||||
LLConstant *DtoModuleFileName(Module *M, const Loc &loc) {
|
||||
return DtoConstString(loc.filename ? loc.filename
|
||||
: M->srcfile->name->toChars());
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue