diff options
author | Reid Kleckner <rnk@google.com> | 2016-06-29 18:29:21 +0000 |
---|---|---|
committer | Reid Kleckner <rnk@google.com> | 2016-06-29 18:29:21 +0000 |
commit | ad1e22bf335041cae1740b19a46f18932c374f27 (patch) | |
tree | c8a537770b810bac861e3134b39f9934f7cc2fef /clang/lib/CodeGen/CGVTables.cpp | |
parent | 4561e784f47cbf8491da177316cba4840b3f440f (diff) | |
download | bcm5719-llvm-ad1e22bf335041cae1740b19a46f18932c374f27.tar.gz bcm5719-llvm-ad1e22bf335041cae1740b19a46f18932c374f27.zip |
Re-land "[MS] Don't expect vftables to be provided for extern template instantiations"
Reverts r273305 and re-instates r273296.
We needed to fix a bug in Sema::MarkVTableUsed to ensure that operator
delete lookup occurs when the vtable is referenced. We already had a
special case to look up operator delete when dllimport was used, but I
think should really mark virtual destructors referenced any time the
vtable is used.
llvm-svn: 274147
Diffstat (limited to 'clang/lib/CodeGen/CGVTables.cpp')
-rw-r--r-- | clang/lib/CodeGen/CGVTables.cpp | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/clang/lib/CodeGen/CGVTables.cpp b/clang/lib/CodeGen/CGVTables.cpp index 83974e0d214..95705503389 100644 --- a/clang/lib/CodeGen/CGVTables.cpp +++ b/clang/lib/CodeGen/CGVTables.cpp @@ -794,6 +794,10 @@ CodeGenModule::getVTableLinkage(const CXXRecordDecl *RD) { return DiscardableODRLinkage; case TSK_ExplicitInstantiationDeclaration: + // Explicit instantiations in MSVC do not provide vtables, so we must emit + // our own. + if (getTarget().getCXXABI().isMicrosoft()) + return DiscardableODRLinkage; return shouldEmitAvailableExternallyVTable(*this, RD) ? llvm::GlobalVariable::AvailableExternallyLinkage : llvm::GlobalVariable::ExternalLinkage; @@ -839,9 +843,9 @@ CodeGenVTables::GenerateClassData(const CXXRecordDecl *RD) { bool CodeGenVTables::isVTableExternal(const CXXRecordDecl *RD) { assert(RD->isDynamicClass() && "Non-dynamic classes have no VTable."); - // We always synthesize vtables on the import side regardless of whether or - // not it is an explicit instantiation declaration. - if (CGM.getTarget().getCXXABI().isMicrosoft() && RD->hasAttr<DLLImportAttr>()) + // We always synthesize vtables if they are needed in the MS ABI. MSVC doesn't + // emit them even if there is an explicit template instantiation. + if (CGM.getTarget().getCXXABI().isMicrosoft()) return false; // If we have an explicit instantiation declaration (and not a |