This revision was automatically updated to reflect the committed changes. Closed by commit rC359342: [MinGW] Don't let template instantiation declarations cover nested classes (authored by mstorsjo, committed by ).
Repository: rC Clang CHANGES SINCE LAST ACTION https://reviews.llvm.org/D61175/new/ https://reviews.llvm.org/D61175 Files: lib/Sema/SemaTemplateInstantiate.cpp test/CodeGenCXX/mingw-template-dllexport.cpp Index: lib/Sema/SemaTemplateInstantiate.cpp =================================================================== --- lib/Sema/SemaTemplateInstantiate.cpp +++ lib/Sema/SemaTemplateInstantiate.cpp @@ -2685,10 +2685,14 @@ continue; if ((Context.getTargetInfo().getCXXABI().isMicrosoft() || - Context.getTargetInfo().getTriple().isWindowsItaniumEnvironment()) && + Context.getTargetInfo().getTriple().isWindowsItaniumEnvironment() || + Context.getTargetInfo().getTriple().isWindowsGNUEnvironment()) && TSK == TSK_ExplicitInstantiationDeclaration) { // In MSVC and Windows Itanium mode, explicit instantiation decl of the // outer class doesn't affect the inner class. + // In GNU mode, inner classes aren't dllexported. Don't let the + // instantiation cover the inner class, to avoid undefined references + // to inner classes that weren't exported. continue; } Index: test/CodeGenCXX/mingw-template-dllexport.cpp =================================================================== --- test/CodeGenCXX/mingw-template-dllexport.cpp +++ test/CodeGenCXX/mingw-template-dllexport.cpp @@ -1,5 +1,10 @@ // RUN: %clang_cc1 -emit-llvm -triple i686-mingw32 %s -o - | FileCheck %s +#define JOIN2(x, y) x##y +#define JOIN(x, y) JOIN2(x, y) +#define UNIQ(name) JOIN(name, __LINE__) +#define USEMEMFUNC(class, func) void (class::*UNIQ(use)())() { return &class::func; } + template <class T> class c { void f(); @@ -36,3 +41,10 @@ // CHECK: define {{.*}} dllexport {{.*}} @_ZN5outerIiE1fEv // CHECK-NOT: define {{.*}} dllexport {{.*}} @_ZN5outerIiE5inner1fEv + +extern template class __declspec(dllimport) outer<char>; +USEMEMFUNC(outer<char>, f) +USEMEMFUNC(outer<char>::inner, f) + +// CHECK: declare dllimport {{.*}} @_ZN5outerIcE1fEv +// CHECK: define {{.*}} @_ZN5outerIcE5inner1fEv
Index: lib/Sema/SemaTemplateInstantiate.cpp =================================================================== --- lib/Sema/SemaTemplateInstantiate.cpp +++ lib/Sema/SemaTemplateInstantiate.cpp @@ -2685,10 +2685,14 @@ continue; if ((Context.getTargetInfo().getCXXABI().isMicrosoft() || - Context.getTargetInfo().getTriple().isWindowsItaniumEnvironment()) && + Context.getTargetInfo().getTriple().isWindowsItaniumEnvironment() || + Context.getTargetInfo().getTriple().isWindowsGNUEnvironment()) && TSK == TSK_ExplicitInstantiationDeclaration) { // In MSVC and Windows Itanium mode, explicit instantiation decl of the // outer class doesn't affect the inner class. + // In GNU mode, inner classes aren't dllexported. Don't let the + // instantiation cover the inner class, to avoid undefined references + // to inner classes that weren't exported. continue; } Index: test/CodeGenCXX/mingw-template-dllexport.cpp =================================================================== --- test/CodeGenCXX/mingw-template-dllexport.cpp +++ test/CodeGenCXX/mingw-template-dllexport.cpp @@ -1,5 +1,10 @@ // RUN: %clang_cc1 -emit-llvm -triple i686-mingw32 %s -o - | FileCheck %s +#define JOIN2(x, y) x##y +#define JOIN(x, y) JOIN2(x, y) +#define UNIQ(name) JOIN(name, __LINE__) +#define USEMEMFUNC(class, func) void (class::*UNIQ(use)())() { return &class::func; } + template <class T> class c { void f(); @@ -36,3 +41,10 @@ // CHECK: define {{.*}} dllexport {{.*}} @_ZN5outerIiE1fEv // CHECK-NOT: define {{.*}} dllexport {{.*}} @_ZN5outerIiE5inner1fEv + +extern template class __declspec(dllimport) outer<char>; +USEMEMFUNC(outer<char>, f) +USEMEMFUNC(outer<char>::inner, f) + +// CHECK: declare dllimport {{.*}} @_ZN5outerIcE1fEv +// CHECK: define {{.*}} @_ZN5outerIcE5inner1fEv
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits