From 4b0f21c0f8bed0e2a7dc62d73be64e7e277d6c9a Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Wed, 6 Jan 2010 20:27:16 +0000 Subject: Fix marking of virtual members for nested classes whose first non-pure virtual function has a body inlined in the class git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@92855 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/CodeGenModule.cpp | 54 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) (limited to 'lib/CodeGen/CodeGenModule.cpp') diff --git a/lib/CodeGen/CodeGenModule.cpp b/lib/CodeGen/CodeGenModule.cpp index 85d57e7cbe..e0e8c54434 100644 --- a/lib/CodeGen/CodeGenModule.cpp +++ b/lib/CodeGen/CodeGenModule.cpp @@ -887,6 +887,60 @@ void CodeGenModule::EmitTentativeDefinition(const VarDecl *D) { EmitGlobalVarDefinition(D); } +llvm::GlobalVariable::LinkageTypes +CodeGenModule::getVtableLinkage(const CXXRecordDecl *RD) { + // Get the key function. + const CXXMethodDecl *KeyFunction = getContext().getKeyFunction(RD); + + if (KeyFunction) { + const FunctionDecl *Def = 0; + if (KeyFunction->getBody(Def)) + KeyFunction = cast(Def); + } + + if (RD->isInAnonymousNamespace() || !RD->hasLinkage()) + return llvm::GlobalVariable::InternalLinkage; + else if (KeyFunction) { + switch (KeyFunction->getTemplateSpecializationKind()) { + case TSK_Undeclared: + case TSK_ExplicitSpecialization: + if (KeyFunction->isInlined()) + return llvm::GlobalVariable::WeakODRLinkage; + + return llvm::GlobalVariable::ExternalLinkage; + + 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 if (KeyFunction) { + 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. + return llvm::GlobalVariable::WeakODRLinkage; +} + static CodeGenModule::GVALinkage GetLinkageForVariable(ASTContext &Context, const VarDecl *VD) { // Everything located semantically within an anonymous namespace is -- cgit v1.2.3-18-g5258