Handle new special vtbl symbol

There's a new need to access a class' vtable symbol, see dlang/dmd#8362.

Use it as alias to the actual vtable symbol with different type (dummy:
`i8*`, actual: `[N x i8*]`) and mangled name.

I tried matching the special symbol's mangled name and using an
appropriate static array front-end type for it, but then casting the
symbol address for the assignment leads to issues if the ctor is @safe.
So I decided to handle it in DtoSymbolAddress().

Unfortunately, this seems not to solve the extern(C++) issues exposed by
LDC self-compilation yet.
This commit is contained in:
Martin Kinkelin 2018-06-23 15:35:41 +02:00
parent 7548b2b89b
commit ef1e655767

View file

@ -1574,6 +1574,14 @@ DValue *DtoSymbolAddress(Loc &loc, Type *type, Declaration *decl) {
}
return new DImValue(type, m);
}
// special vtbl symbol, used by LDC as alias to the actual vtbl (with
// different type and mangled name)
if (vd->isClassMember() && vd == vd->isClassMember()->vtblsym) {
Logger::println("vtbl symbol");
auto cd = vd->isClassMember();
return new DLValue(
type, DtoBitCast(getIrAggr(cd)->getVtblSymbol(), DtoPtrToType(type)));
}
// nested variable
if (vd->nestedrefs.dim) {
Logger::println("nested variable");