Don't try emitting dllexported explicitly defaulted non-trivial ctors twice during explicit template instantiation definition (PR42857)

Trying to emit the definition twice triggers an assert.

Differential revision: https://reviews.llvm.org/D65579

llvm-svn: 367661
This commit is contained in:
Hans Wennborg 2019-08-02 07:51:41 +00:00
parent 14c6dfdfe2
commit 044d8c486b
2 changed files with 14 additions and 1 deletions

View File

@ -11543,6 +11543,12 @@ void Sema::ActOnFinishCXXNonNestedClass(Decl *D) {
std::swap(DelayedDllExportMemberFunctions, WorkList);
for (CXXMethodDecl *M : WorkList) {
DefineImplicitSpecialMember(*this, M, M->getLocation());
// Pass the method to the consumer to get emitted. This is not necessary
// for explicit instantiation definitions, as they will get emitted
// anyway.
if (M->getParent()->getTemplateSpecializationKind() !=
TSK_ExplicitInstantiationDefinition)
ActOnFinishInlineFunctionDef(M);
}
}

View File

@ -860,6 +860,13 @@ struct PR40006 {
};
// M32-DAG: define weak_odr dso_local dllexport x86_thiscallcc %"struct.InClassInits::PR40006"* @"??0PR40006@InClassInits@@QAE@XZ"
// PR42857: Clang would try to emit the non-trivial explicitly defaulted
// dllexport ctor twice when doing an explicit instantiation definition.
struct Qux { Qux(); };
template <typename T> struct PR42857 { __declspec(dllexport) PR42857() = default; Qux q; };
template struct PR42857<int>;
// M32-DAG: define weak_odr dso_local dllexport x86_thiscallcc %"struct.InClassInits::PR42857"* @"??0?$PR42857@H@InClassInits@@QAE@XZ"
}
// We had an issue where instantiating A would force emission of B's delayed