summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
authorReid Kleckner <rnk@google.com>2016-06-21 19:51:52 +0000
committerReid Kleckner <rnk@google.com>2016-06-21 19:51:52 +0000
commitf981bcb3a05af0c69ea1c17dea553937688674a8 (patch)
tree15380dd8f9e1236a621436b9fe4b45815f25f058 /clang/lib
parent47bd46395ad8496bd067d4e50f2ac5b196c09977 (diff)
downloadbcm5719-llvm-f981bcb3a05af0c69ea1c17dea553937688674a8.tar.gz
bcm5719-llvm-f981bcb3a05af0c69ea1c17dea553937688674a8.zip
Revert "[MS] Don't expect vftables to be provided for extern template instantiations"
This reverts commit r273296, it broke the Windows self-host. llvm-svn: 273305
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/AST/VTableBuilder.cpp13
-rw-r--r--clang/lib/CodeGen/CGVTables.cpp10
2 files changed, 10 insertions, 13 deletions
diff --git a/clang/lib/AST/VTableBuilder.cpp b/clang/lib/AST/VTableBuilder.cpp
index 640fbf47aea..e43acc4de78 100644
--- a/clang/lib/AST/VTableBuilder.cpp
+++ b/clang/lib/AST/VTableBuilder.cpp
@@ -2545,13 +2545,14 @@ public:
MostDerivedClassLayout(Context.getASTRecordLayout(MostDerivedClass)),
WhichVFPtr(*Which),
Overriders(MostDerivedClass, CharUnits(), MostDerivedClass) {
- // Provide the RTTI component if RTTIData is enabled. If the vftable would
- // be available externally, we should not provide the RTTI componenent. It
- // is currently impossible to get available externally vftables with either
- // dllimport or extern template instantiations, but eventually we may add a
- // flag to support additional devirtualization that needs this.
+ // Only include the RTTI component if we know that we will provide a
+ // definition of the vftable. We always provide the definition of
+ // dllimported classes.
if (Context.getLangOpts().RTTIData)
- HasRTTIComponent = true;
+ if (MostDerivedClass->hasAttr<DLLImportAttr>() ||
+ MostDerivedClass->getTemplateSpecializationKind() !=
+ TSK_ExplicitInstantiationDeclaration)
+ HasRTTIComponent = true;
LayoutVFTable();
diff --git a/clang/lib/CodeGen/CGVTables.cpp b/clang/lib/CodeGen/CGVTables.cpp
index da9b7421879..38461446de5 100644
--- a/clang/lib/CodeGen/CGVTables.cpp
+++ b/clang/lib/CodeGen/CGVTables.cpp
@@ -794,10 +794,6 @@ 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;
@@ -843,9 +839,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 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())
+ // 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>())
return false;
// If we have an explicit instantiation declaration (and not a
OpenPOWER on IntegriCloud