mirror of
https://github.com/ldc-developers/ldc.git
synced 2025-05-04 09:00:33 +03:00
[svn r311] Fixed: structs no longer output two static typeinfos.
Updated the DtoTypeInfoOf helper a bit after figuring out how it worked.
This commit is contained in:
parent
5f247bb394
commit
f3ea671ed6
2 changed files with 5 additions and 7 deletions
|
@ -1085,17 +1085,16 @@ void DtoAnnotation(const char* str)
|
||||||
|
|
||||||
LLConstant* DtoTypeInfoOf(Type* type, bool base)
|
LLConstant* DtoTypeInfoOf(Type* type, bool base)
|
||||||
{
|
{
|
||||||
type = type->merge(); // seems like this is needed in some cases with templates.
|
type = type->merge(); // needed.. getTypeInfo does the same
|
||||||
const LLType* typeinfotype = DtoType(Type::typeinfo->type);
|
type->getTypeInfo(NULL);
|
||||||
if (!type->vtinfo)
|
|
||||||
type->getTypeInfo(NULL);
|
|
||||||
TypeInfoDeclaration* tidecl = type->vtinfo;
|
TypeInfoDeclaration* tidecl = type->vtinfo;
|
||||||
|
assert(tidecl);
|
||||||
DtoForceDeclareDsymbol(tidecl);
|
DtoForceDeclareDsymbol(tidecl);
|
||||||
assert(tidecl->ir.irGlobal != NULL);
|
assert(tidecl->ir.irGlobal != NULL);
|
||||||
LLConstant* c = isaConstant(tidecl->ir.irGlobal->value);
|
LLConstant* c = isaConstant(tidecl->ir.irGlobal->value);
|
||||||
assert(c != NULL);
|
assert(c != NULL);
|
||||||
if (base)
|
if (base)
|
||||||
return llvm::ConstantExpr::getBitCast(c, typeinfotype);
|
return llvm::ConstantExpr::getBitCast(c, DtoType(Type::typeinfo->type));
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -383,6 +383,7 @@ void TypeInfoTypedefDeclaration::llvmDefine()
|
||||||
TypedefDeclaration *sd = tc->sym;
|
TypedefDeclaration *sd = tc->sym;
|
||||||
|
|
||||||
// TypeInfo base
|
// TypeInfo base
|
||||||
|
sd->basetype = sd->basetype->merge(); // DMD does this!
|
||||||
LLConstant* castbase = DtoTypeInfoOf(sd->basetype, true);
|
LLConstant* castbase = DtoTypeInfoOf(sd->basetype, true);
|
||||||
assert(castbase->getType() == stype->getElementType(2));
|
assert(castbase->getType() == stype->getElementType(2));
|
||||||
sinits.push_back(castbase);
|
sinits.push_back(castbase);
|
||||||
|
@ -962,8 +963,6 @@ void TypeInfoStructDeclaration::llvmDefine()
|
||||||
|
|
||||||
// create the symbol
|
// create the symbol
|
||||||
LLConstant* tiInit = llvm::ConstantStruct::get(stype, sinits);
|
LLConstant* tiInit = llvm::ConstantStruct::get(stype, sinits);
|
||||||
llvm::GlobalVariable* gvar = new llvm::GlobalVariable(stype,true,llvm::GlobalValue::WeakLinkage,tiInit,toChars(),gIR->module);
|
|
||||||
|
|
||||||
isaGlobalVar(this->ir.irGlobal->value)->setInitializer(tiInit);
|
isaGlobalVar(this->ir.irGlobal->value)->setInitializer(tiInit);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue