diff options
author | Hans Wennborg <hans@hanshq.net> | 2019-08-05 07:31:33 +0000 |
---|---|---|
committer | Hans Wennborg <hans@hanshq.net> | 2019-08-05 07:31:33 +0000 |
commit | 9c6af4af5049977f32e9dbb53c3087a9ff76338e (patch) | |
tree | c3b7de1d54c65da1dda5ac069a12173a454dd355 | |
parent | e333eb0d63721ee2d0f8cb8c24c5434a87d72f1c (diff) |
Merging r367661:
------------------------------------------------------------------------
r367661 | hans | 2019-08-02 09:51:41 +0200 (Fri, 02 Aug 2019) | 5 lines
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
------------------------------------------------------------------------
git-svn-id: https://llvm.org/svn/llvm-project/cfe/branches/release_90@367805 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Sema/SemaDeclCXX.cpp | 8 | ||||
-rw-r--r-- | test/CodeGenCXX/dllexport.cpp | 7 |
2 files changed, 14 insertions, 1 deletions
diff --git a/lib/Sema/SemaDeclCXX.cpp b/lib/Sema/SemaDeclCXX.cpp index 3d4c7fc3e0..2ffb0b4892 100644 --- a/lib/Sema/SemaDeclCXX.cpp +++ b/lib/Sema/SemaDeclCXX.cpp @@ -11425,7 +11425,13 @@ void Sema::ActOnFinishCXXNonNestedClass(Decl *D) { std::swap(DelayedDllExportMemberFunctions, WorkList); for (CXXMethodDecl *M : WorkList) { DefineImplicitSpecialMember(*this, M, M->getLocation()); - ActOnFinishInlineFunctionDef(M); + + // 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); } } } diff --git a/test/CodeGenCXX/dllexport.cpp b/test/CodeGenCXX/dllexport.cpp index 5d4523f2ea..59ba6d8548 100644 --- a/test/CodeGenCXX/dllexport.cpp +++ b/test/CodeGenCXX/dllexport.cpp @@ -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 |