Mercurial > projects > ldc
comparison gen/classes.cpp @ 149:4c577c2b7229 trunk
[svn r155] Fixed a bunch of linkage problems (especially with templates)
author | lindquist |
---|---|
date | Mon, 24 Mar 2008 19:43:02 +0100 |
parents | 0636f6269dfd |
children | 7f92f477ff53 |
comparison
equal
deleted
inserted
replaced
148:86d3bb8ca33e | 149:4c577c2b7229 |
---|---|
348 bool needs_definition = false; | 348 bool needs_definition = false; |
349 if (cd->getModule() == gIR->dmodule || DtoIsTemplateInstance(cd)) { | 349 if (cd->getModule() == gIR->dmodule || DtoIsTemplateInstance(cd)) { |
350 needs_definition = true; | 350 needs_definition = true; |
351 } | 351 } |
352 | 352 |
353 llvm::GlobalValue::LinkageTypes _linkage = llvm::GlobalValue::ExternalLinkage; | 353 llvm::GlobalValue::LinkageTypes _linkage = DtoLinkage(cd); |
354 | 354 |
355 // interfaces have no static initializer | 355 // interfaces have no static initializer |
356 // same goes for abstract classes | 356 // same goes for abstract classes |
357 if (!cd->isInterfaceDeclaration() && !cd->isAbstract()) { | 357 if (!cd->isInterfaceDeclaration() && !cd->isAbstract()) { |
358 // vtable | 358 // vtable |
1199 else | 1199 else |
1200 gname.append("11__InterfaceZ"); | 1200 gname.append("11__InterfaceZ"); |
1201 | 1201 |
1202 const llvm::Type* st = cinfo->type->llvmType->get(); | 1202 const llvm::Type* st = cinfo->type->llvmType->get(); |
1203 | 1203 |
1204 cd->irStruct->classInfo = new llvm::GlobalVariable(st, true, llvm::GlobalValue::ExternalLinkage, NULL, gname, gIR->module); | 1204 cd->irStruct->classInfo = new llvm::GlobalVariable(st, true, DtoLinkage(cd), NULL, gname, gIR->module); |
1205 } | 1205 } |
1206 | 1206 |
1207 static llvm::Constant* build_offti_entry(VarDeclaration* vd) | 1207 static llvm::Constant* build_offti_entry(VarDeclaration* vd) |
1208 { | 1208 { |
1209 std::vector<const llvm::Type*> types; | 1209 std::vector<const llvm::Type*> types; |
1273 const llvm::ArrayType* arrTy = llvm::ArrayType::get(sTy, ninits); | 1273 const llvm::ArrayType* arrTy = llvm::ArrayType::get(sTy, ninits); |
1274 llvm::Constant* arrInit = llvm::ConstantArray::get(arrTy, arrayInits); | 1274 llvm::Constant* arrInit = llvm::ConstantArray::get(arrTy, arrayInits); |
1275 | 1275 |
1276 std::string name(cd->type->vtinfo->toChars()); | 1276 std::string name(cd->type->vtinfo->toChars()); |
1277 name.append("__OffsetTypeInfos"); | 1277 name.append("__OffsetTypeInfos"); |
1278 llvm::GlobalVariable* gvar = new llvm::GlobalVariable(arrTy,true,llvm::GlobalValue::InternalLinkage,arrInit,name,gIR->module); | 1278 |
1279 llvm::GlobalVariable* gvar = new llvm::GlobalVariable(arrTy,true,DtoInternalLinkage(cd),arrInit,name,gIR->module); | |
1279 ptr = llvm::ConstantExpr::getBitCast(gvar, getPtrToType(sTy)); | 1280 ptr = llvm::ConstantExpr::getBitCast(gvar, getPtrToType(sTy)); |
1280 } | 1281 } |
1281 else { | 1282 else { |
1282 ptr = llvm::ConstantPointerNull::get(isaPointer(initTy->getElementType(1))); | 1283 ptr = llvm::ConstantPointerNull::get(isaPointer(initTy->getElementType(1))); |
1283 } | 1284 } |
1305 | 1306 |
1306 std::string gname("_D"); | 1307 std::string gname("_D"); |
1307 gname.append(cd->mangle()); | 1308 gname.append(cd->mangle()); |
1308 gname.append("12__destructorMFZv"); | 1309 gname.append("12__destructorMFZv"); |
1309 | 1310 |
1310 llvm::Function* func = new llvm::Function(fnTy, llvm::GlobalValue::InternalLinkage, gname, gIR->module); | 1311 llvm::Function* func = new llvm::Function(fnTy, DtoInternalLinkage(cd), gname, gIR->module); |
1311 llvm::Value* thisptr = func->arg_begin(); | 1312 llvm::Value* thisptr = func->arg_begin(); |
1312 thisptr->setName("this"); | 1313 thisptr->setName("this"); |
1313 | 1314 |
1314 llvm::BasicBlock* bb = new llvm::BasicBlock("entry", func); | 1315 llvm::BasicBlock* bb = new llvm::BasicBlock("entry", func); |
1315 LLVMBuilder builder(bb); | 1316 LLVMBuilder builder(bb); |