diff options
author | Martin Storsjo <martin@martin.st> | 2019-04-26 19:31:46 +0000 |
---|---|---|
committer | Martin Storsjo <martin@martin.st> | 2019-04-26 19:31:46 +0000 |
commit | 9534e9dbe44c130acefb48bd87b3e7d78db72def (patch) | |
tree | 6ccd0a5974df2b80354be69b21c51850b92af23d | |
parent | da93dec330507c5f5ff20115a4d571979ed31393 (diff) | |
download | bcm5719-llvm-9534e9dbe44c130acefb48bd87b3e7d78db72def.tar.gz bcm5719-llvm-9534e9dbe44c130acefb48bd87b3e7d78db72def.zip |
[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
llvm-svn: 359343
-rw-r--r-- | clang/lib/Sema/SemaDeclCXX.cpp | 7 | ||||
-rw-r--r-- | clang/test/CodeGenCXX/mingw-template-dllexport.cpp | 4 |
2 files changed, 6 insertions, 5 deletions
diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp index c03bcb5e3a5..2e7573d11ef 100644 --- a/clang/lib/Sema/SemaDeclCXX.cpp +++ b/clang/lib/Sema/SemaDeclCXX.cpp @@ -5726,9 +5726,12 @@ void Sema::checkClassLevelDLLAttribute(CXXRecordDecl *Class) { 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 diff --git a/clang/test/CodeGenCXX/mingw-template-dllexport.cpp b/clang/test/CodeGenCXX/mingw-template-dllexport.cpp index 9e8f9b1bccf..408a3fd0a77 100644 --- a/clang/test/CodeGenCXX/mingw-template-dllexport.cpp +++ b/clang/test/CodeGenCXX/mingw-template-dllexport.cpp @@ -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 |