Skip to content

Commit e37403e

Browse files
committed
[Cygwin] Template instantiations should be exported by default
Behaves as same as both of Clang and GCC targetting MinGW. Required for compatibility for Cygwin-GCC.
1 parent 77fa7d6 commit e37403e

File tree

6 files changed

+81
-8
lines changed

6 files changed

+81
-8
lines changed

clang/lib/Sema/SemaDeclCXX.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6576,7 +6576,7 @@ void Sema::checkClassLevelDLLAttribute(CXXRecordDecl *Class) {
65766576
// declarations, except in MinGW mode.
65776577
if (ClassExported && !ClassAttr->isInherited() &&
65786578
TSK == TSK_ExplicitInstantiationDeclaration &&
6579-
!Context.getTargetInfo().getTriple().isWindowsGNUEnvironment()) {
6579+
!Context.getTargetInfo().getTriple().isOSCygMing()) {
65806580
Class->dropAttr<DLLExportAttr>();
65816581
return;
65826582
}

clang/lib/Sema/SemaTemplate.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8938,8 +8938,7 @@ Sema::CheckSpecializationInstantiationRedecl(SourceLocation NewLoc,
89388938
// The declaration itself has not actually been instantiated, so it is
89398939
// still okay to specialize it.
89408940
StripImplicitInstantiation(
8941-
PrevDecl,
8942-
Context.getTargetInfo().getTriple().isWindowsGNUEnvironment());
8941+
PrevDecl, Context.getTargetInfo().getTriple().isOSCygMing());
89438942
return false;
89448943
}
89458944
// Fall through
@@ -9806,7 +9805,7 @@ DeclResult Sema::ActOnExplicitInstantiation(
98069805
: TSK_ExplicitInstantiationDeclaration;
98079806

98089807
if (TSK == TSK_ExplicitInstantiationDeclaration &&
9809-
!Context.getTargetInfo().getTriple().isWindowsGNUEnvironment()) {
9808+
!Context.getTargetInfo().getTriple().isOSCygMing()) {
98109809
// Check for dllexport class template instantiation declarations,
98119810
// except for MinGW mode.
98129811
for (const ParsedAttr &AL : Attr) {
@@ -9871,7 +9870,7 @@ DeclResult Sema::ActOnExplicitInstantiation(
98719870
= PrevDecl ? PrevDecl->getTemplateSpecializationKind() : TSK_Undeclared;
98729871

98739872
if (TSK == TSK_ExplicitInstantiationDefinition && PrevDecl != nullptr &&
9874-
Context.getTargetInfo().getTriple().isWindowsGNUEnvironment()) {
9873+
Context.getTargetInfo().getTriple().isOSCygMing()) {
98759874
// Check for dllexport class template instantiation definitions in MinGW
98769875
// mode, if a previous declaration of the instantiation was seen.
98779876
for (const ParsedAttr &AL : Attr) {
@@ -10039,7 +10038,7 @@ DeclResult Sema::ActOnExplicitInstantiation(
1003910038
// In MinGW mode, export the template instantiation if the declaration
1004010039
// was marked dllexport.
1004110040
if (PrevDecl_TSK == TSK_ExplicitInstantiationDeclaration &&
10042-
Context.getTargetInfo().getTriple().isWindowsGNUEnvironment() &&
10041+
Context.getTargetInfo().getTriple().isOSCygMing() &&
1004310042
PrevDecl->hasAttr<DLLExportAttr>()) {
1004410043
dllExportImportClassTemplateSpecialization(*this, Def);
1004510044
}

0 commit comments

Comments
 (0)