Skip to content

Commit cb53ece

Browse files
authored
[Cygwin] Template instantiations should be exported by default (#139799)
Behaves as same as both of Clang and GCC targetting MinGW. Required for compatibility for Cygwin-GCC. Divided from #138773
1 parent a3d52ea commit cb53ece

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
@@ -9021,8 +9021,7 @@ Sema::CheckSpecializationInstantiationRedecl(SourceLocation NewLoc,
90219021
// The declaration itself has not actually been instantiated, so it is
90229022
// still okay to specialize it.
90239023
StripImplicitInstantiation(
9024-
PrevDecl,
9025-
Context.getTargetInfo().getTriple().isWindowsGNUEnvironment());
9024+
PrevDecl, Context.getTargetInfo().getTriple().isOSCygMing());
90269025
return false;
90279026
}
90289027
// Fall through
@@ -9892,7 +9891,7 @@ DeclResult Sema::ActOnExplicitInstantiation(
98929891
: TSK_ExplicitInstantiationDeclaration;
98939892

98949893
if (TSK == TSK_ExplicitInstantiationDeclaration &&
9895-
!Context.getTargetInfo().getTriple().isWindowsGNUEnvironment()) {
9894+
!Context.getTargetInfo().getTriple().isOSCygMing()) {
98969895
// Check for dllexport class template instantiation declarations,
98979896
// except for MinGW mode.
98989897
for (const ParsedAttr &AL : Attr) {
@@ -9957,7 +9956,7 @@ DeclResult Sema::ActOnExplicitInstantiation(
99579956
= PrevDecl ? PrevDecl->getTemplateSpecializationKind() : TSK_Undeclared;
99589957

99599958
if (TSK == TSK_ExplicitInstantiationDefinition && PrevDecl != nullptr &&
9960-
Context.getTargetInfo().getTriple().isWindowsGNUEnvironment()) {
9959+
Context.getTargetInfo().getTriple().isOSCygMing()) {
99619960
// Check for dllexport class template instantiation definitions in MinGW
99629961
// mode, if a previous declaration of the instantiation was seen.
99639962
for (const ParsedAttr &AL : Attr) {
@@ -10125,7 +10124,7 @@ DeclResult Sema::ActOnExplicitInstantiation(
1012510124
// In MinGW mode, export the template instantiation if the declaration
1012610125
// was marked dllexport.
1012710126
if (PrevDecl_TSK == TSK_ExplicitInstantiationDeclaration &&
10128-
Context.getTargetInfo().getTriple().isWindowsGNUEnvironment() &&
10127+
Context.getTargetInfo().getTriple().isOSCygMing() &&
1012910128
PrevDecl->hasAttr<DLLExportAttr>()) {
1013010129
dllExportImportClassTemplateSpecialization(*this, Def);
1013110130
}

0 commit comments

Comments
 (0)