mirror of
https://github.com/xomboverlord/ldc.git
synced 2026-07-19 13:45:21 +02:00
Fixed problems with nested 'this'. Fixes #39 .
Fixed problem with debug info order of intrinsic calls (func.start after declare).
This commit is contained in:
14
gen/toir.cpp
14
gen/toir.cpp
@@ -969,6 +969,7 @@ DValue* ThisExp::toElem(IRState* p)
|
||||
|
||||
// this seems to happen for dmd generated assert statements like:
|
||||
// assert(this, "null this");
|
||||
// FIXME: check for TOKthis in AssertExp instead
|
||||
if (!var)
|
||||
{
|
||||
LLValue* v = p->func()->thisVar;
|
||||
@@ -978,9 +979,16 @@ DValue* ThisExp::toElem(IRState* p)
|
||||
// regular this expr
|
||||
else if (VarDeclaration* vd = var->isVarDeclaration()) {
|
||||
LLValue* v;
|
||||
v = p->func()->decl->ir.irFunc->thisVar;
|
||||
if (llvm::isa<llvm::AllocaInst>(v))
|
||||
v = DtoLoad(v);
|
||||
if (vd->toParent2() != p->func()->decl) {
|
||||
Logger::println("nested this exp");
|
||||
v = DtoLoad(DtoNestedVariable(vd));
|
||||
}
|
||||
else {
|
||||
Logger::println("normal this exp");
|
||||
v = p->func()->decl->ir.irFunc->thisVar;
|
||||
if (llvm::isa<llvm::AllocaInst>(v))
|
||||
v = DtoLoad(v);
|
||||
}
|
||||
const LLType* t = DtoType(type);
|
||||
if (v->getType() != t)
|
||||
v = DtoBitCast(v, t);
|
||||
|
||||
Reference in New Issue
Block a user