diff options
author | Douglas Gregor <dgregor@apple.com> | 2010-01-06 20:27:16 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2010-01-06 20:27:16 +0000 |
commit | ccecc1bb43d26aa8fa8f396bc8537e223e60048e (patch) | |
tree | f205818190e2b73627abf935bc943eab01251ca3 /clang/lib/CodeGen/CodeGenModule.cpp | |
parent | 2cdb806fd88bccd7d4bf22fa358cc79609492f55 (diff) | |
download | bcm5719-llvm-ccecc1bb43d26aa8fa8f396bc8537e223e60048e.tar.gz bcm5719-llvm-ccecc1bb43d26aa8fa8f396bc8537e223e60048e.zip |
Fix marking of virtual members for nested classes whose first non-pure virtual function has a body inlined in the class
llvm-svn: 92855
Diffstat (limited to 'clang/lib/CodeGen/CodeGenModule.cpp')
-rw-r--r-- | clang/lib/CodeGen/CodeGenModule.cpp | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index 85d57e7cbec..e0e8c54434e 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/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<CXXMethodDecl>(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 |