diff options
author | Anders Carlsson <andersca@mac.com> | 2009-12-06 00:23:49 +0000 |
---|---|---|
committer | Anders Carlsson <andersca@mac.com> | 2009-12-06 00:23:49 +0000 |
commit | 3527225899adf04e7b966e533da72e4550f9c7e5 (patch) | |
tree | 75e2268d3982e13e2aad98992afffd1b19ab5662 /lib/CodeGen/CGVtable.cpp | |
parent | 8c2d36ffc82c6c616c02f4a231a39f0fe5ab4e54 (diff) |
Pass the desired vtable linkage to GenerateVtable directly. Only call MaybeMarkVirtualImplicitMembersReferenced for non-inline functions.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@90686 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGVtable.cpp')
-rw-r--r-- | lib/CodeGen/CGVtable.cpp | 26 |
1 files changed, 7 insertions, 19 deletions
diff --git a/lib/CodeGen/CGVtable.cpp b/lib/CodeGen/CGVtable.cpp index b52e5739d5..6f8f9ebd83 100644 --- a/lib/CodeGen/CGVtable.cpp +++ b/lib/CodeGen/CGVtable.cpp @@ -1112,7 +1112,8 @@ createGlobalVariable(CodeGenModule &CGM, const CXXRecordDecl *RD, } llvm::GlobalVariable * -CGVtableInfo::GenerateVtable(const CXXRecordDecl *LayoutClass, +CGVtableInfo::GenerateVtable(llvm::GlobalVariable::LinkageTypes Linkage, + const CXXRecordDecl *LayoutClass, const CXXRecordDecl *RD, uint64_t Offset) { llvm::SmallString<256> OutName; if (LayoutClass != RD) @@ -1133,21 +1134,7 @@ CGVtableInfo::GenerateVtable(const CXXRecordDecl *LayoutClass, if (AddressPoint == 0) AddressPoint = 1; } else { - bool CreateDefinition = true; - if (LayoutClass != RD) - CreateDefinition = true; - else { - const ASTRecordLayout &Layout = - CGM.getContext().getASTRecordLayout(LayoutClass); - - if (const CXXMethodDecl *KeyFunction = Layout.getKeyFunction()) { - if (!KeyFunction->getBody()) { - // If there is a KeyFunction, and it isn't defined, just build a - // reference to the vtable. - CreateDefinition = false; - } - } - } + bool CreateDefinition = Linkage != llvm::GlobalVariable::ExternalLinkage; VtableBuilder b(RD, LayoutClass, Offset, CGM, CreateDefinition); @@ -1383,7 +1370,7 @@ llvm::Constant *CodeGenModule::GenerateVTT(const CXXRecordDecl *RD) { } void CGVtableInfo::GenerateClassData(const CXXRecordDecl *RD) { - Vtables[RD] = GenerateVtable(RD, RD, 0); + Vtables[RD] = GenerateVtable(llvm::GlobalValue::WeakODRLinkage, RD, RD, 0); CGM.GenerateRTTI(RD); CGM.GenerateVTT(RD); } @@ -1392,7 +1379,7 @@ llvm::GlobalVariable *CGVtableInfo::getVtable(const CXXRecordDecl *RD) { llvm::GlobalVariable *Vtable = Vtables[RD]; if (!Vtable) - Vtable = GenerateVtable(RD, RD, 0); + Vtable = GenerateVtable(llvm::GlobalValue::ExternalLinkage, RD, RD, 0); return Vtable; } @@ -1400,7 +1387,8 @@ llvm::GlobalVariable *CGVtableInfo::getVtable(const CXXRecordDecl *RD) { llvm::GlobalVariable * CGVtableInfo::getCtorVtable(const CXXRecordDecl *LayoutClass, const CXXRecordDecl *RD, uint64_t Offset) { - return GenerateVtable(LayoutClass, RD, Offset); + return GenerateVtable(llvm::GlobalValue::InternalLinkage, + LayoutClass, RD, Offset); } void CGVtableInfo::MaybeEmitVtable(GlobalDecl GD) { |