r359343 - [MinGW] Do dllexport inline methods in template instantiation
Martin Storsjo via cfe-commits
cfe-commits at lists.llvm.org
Fri Apr 26 12:31:46 PDT 2019
Author: mstorsjo
Date: Fri Apr 26 12:31:46 2019
New Revision: 359343
URL: http://llvm.org/viewvc/llvm-project?rev=359343&view=rev
Log:
[MinGW] Do dllexport inline methods in template instantiation
Normally, in MinGW mode, inline methods aren't dllexported.
However, in the case of a dllimported template instantiation,
the inline methods aren't instantiated locally, but referenced
from the instantiation. Therefore, those methods also need to
be dllexported, in the case of an instantiation.
GCC suffers from the same issue, reported at [1], but the issue
is still unresolved there.
[1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89088
Differential Revision: https://reviews.llvm.org/D61176
Modified:
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
cfe/trunk/test/CodeGenCXX/mingw-template-dllexport.cpp
Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=359343&r1=359342&r2=359343&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Fri Apr 26 12:31:46 2019
@@ -5726,9 +5726,12 @@ void Sema::checkClassLevelDLLAttribute(C
continue;
if (MD->isInlined()) {
- // MinGW does not import or export inline methods.
+ // MinGW does not import or export inline methods. But do it for
+ // template instantiations.
if (!Context.getTargetInfo().getCXXABI().isMicrosoft() &&
- !Context.getTargetInfo().getTriple().isWindowsItaniumEnvironment())
+ !Context.getTargetInfo().getTriple().isWindowsItaniumEnvironment() &&
+ TSK != TSK_ExplicitInstantiationDeclaration &&
+ TSK != TSK_ExplicitInstantiationDefinition)
continue;
// MSVC versions before 2015 don't export the move assignment operators
Modified: cfe/trunk/test/CodeGenCXX/mingw-template-dllexport.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/mingw-template-dllexport.cpp?rev=359343&r1=359342&r2=359343&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/mingw-template-dllexport.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/mingw-template-dllexport.cpp Fri Apr 26 12:31:46 2019
@@ -7,11 +7,9 @@
template <class T>
class c {
- void f();
+ void f() {}
};
-template <class T> void c<T>::f() {}
-
template class __declspec(dllexport) c<int>;
// CHECK: define {{.*}} dllexport {{.*}} @_ZN1cIiE1fEv
More information about the cfe-commits
mailing list