summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CodeGenModule.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2010-01-06 22:00:56 +0000
committerDouglas Gregor <dgregor@apple.com>2010-01-06 22:00:56 +0000
commit2a34df32641bf80bc67cda915afbe46552cad9dc (patch)
tree4ad9b34bbd4ca10ee167ac9cb6cca8899d9974ec /clang/lib/CodeGen/CodeGenModule.cpp
parent8e356bfe288410c6ff243270aba089415435b327 (diff)
downloadbcm5719-llvm-2a34df32641bf80bc67cda915afbe46552cad9dc.tar.gz
bcm5719-llvm-2a34df32641bf80bc67cda915afbe46552cad9dc.zip
Fix linkage for RTTI names by re-using the logic for computing the
linkage of vtables. Before this, we were emitting RTTI names for template instantiations with strong external linkage rather than with weak ODR linkage. llvm-svn: 92857
Diffstat (limited to 'clang/lib/CodeGen/CodeGenModule.cpp')
-rw-r--r--clang/lib/CodeGen/CodeGenModule.cpp45
1 files changed, 21 insertions, 24 deletions
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp
index e0e8c54434e..0dbf336dccc 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -889,18 +889,17 @@ void CodeGenModule::EmitTentativeDefinition(const VarDecl *D) {
llvm::GlobalVariable::LinkageTypes
CodeGenModule::getVtableLinkage(const CXXRecordDecl *RD) {
- // Get the key function.
- const CXXMethodDecl *KeyFunction = getContext().getKeyFunction(RD);
-
- if (KeyFunction) {
+ if (RD->isInAnonymousNamespace() || !RD->hasLinkage())
+ return llvm::GlobalVariable::InternalLinkage;
+
+ if (const CXXMethodDecl *KeyFunction
+ = RD->getASTContext().getKeyFunction(RD)) {
+ // If this class has a key function, use that to determine the linkage of
+ // the vtable.
const FunctionDecl *Def = 0;
if (KeyFunction->getBody(Def))
KeyFunction = cast<CXXMethodDecl>(Def);
- }
-
- if (RD->isInAnonymousNamespace() || !RD->hasLinkage())
- return llvm::GlobalVariable::InternalLinkage;
- else if (KeyFunction) {
+
switch (KeyFunction->getTemplateSpecializationKind()) {
case TSK_Undeclared:
case TSK_ExplicitSpecialization:
@@ -919,22 +918,20 @@ CodeGenModule::getVtableLinkage(const CXXRecordDecl *RD) {
// return llvm::GlobalVariable::AvailableExternallyLinkage;
return llvm::GlobalVariable::WeakODRLinkage;
}
- } else if (KeyFunction) {
+ }
+
+ switch (RD->getTemplateSpecializationKind()) {
+ case TSK_Undeclared:
+ case TSK_ExplicitSpecialization:
+ case TSK_ImplicitInstantiation:
+ case TSK_ExplicitInstantiationDefinition:
+ return llvm::GlobalVariable::WeakODRLinkage;
+
+ case TSK_ExplicitInstantiationDeclaration:
+ // FIXME: Use available_externally linkage. However, this currently
+ // breaks LLVM's build due to undefined symbols.
+ // return llvm::GlobalVariable::AvailableExternallyLinkage;
return llvm::GlobalVariable::WeakODRLinkage;
- } else {
- switch (RD->getTemplateSpecializationKind()) {
- case TSK_Undeclared:
- case TSK_ExplicitSpecialization:
- case TSK_ImplicitInstantiation:
- case TSK_ExplicitInstantiationDefinition:
- return llvm::GlobalVariable::WeakODRLinkage;
-
- case TSK_ExplicitInstantiationDeclaration:
- // FIXME: Use available_externally linkage. However, this currently
- // breaks LLVM's build due to undefined symbols.
- // return llvm::GlobalVariable::AvailableExternallyLinkage;
- return llvm::GlobalVariable::WeakODRLinkage;
- }
}
// Silence GCC warning.
OpenPOWER on IntegriCloud