[PATCH] D26471: [Sema] Use MS ABI behavior for dllexport in Itanium

Shoaib Meenai via cfe-commits cfe-commits at lists.llvm.org
Wed Nov 9 14:00:10 PST 2016


smeenai created this revision.
smeenai added a reviewer: compnerd.
smeenai added a subscriber: cfe-commits.

Similar to r284288, make the Itanium ABI follow MS ABI dllexport
semantics in the case of an explicit instantiation declaration followed
by a dllexport explicit instantiation definition.


https://reviews.llvm.org/D26471

Files:
  lib/Sema/SemaTemplate.cpp
  test/CodeGenCXX/windows-itanium-dllexport.cpp


Index: test/CodeGenCXX/windows-itanium-dllexport.cpp
===================================================================
--- test/CodeGenCXX/windows-itanium-dllexport.cpp
+++ test/CodeGenCXX/windows-itanium-dllexport.cpp
@@ -7,3 +7,19 @@
 // CHECK: define {{.*}} dllexport {{.*}} @_ZN1saSERKS_
 // CHECK: define {{.*}} dllexport {{.*}} @_ZN1s1fEv
 
+template <class T>
+class c {
+  void f() {}
+};
+
+template class __declspec(dllexport) c<int>;
+
+// CHECK: define {{.*}} dllexport {{.*}} @_ZN1cIiEaSERKS0_
+// CHECK: define {{.*}} dllexport {{.*}} @_ZN1cIiE1fEv
+
+extern template class c<char>;
+template class __declspec(dllexport) c<char>;
+
+// CHECK: define {{.*}} dllexport {{.*}} @_ZN1cIcEaSERKS0_
+// CHECK: define {{.*}} dllexport {{.*}} @_ZN1cIcE1fEv
+
Index: lib/Sema/SemaTemplate.cpp
===================================================================
--- lib/Sema/SemaTemplate.cpp
+++ lib/Sema/SemaTemplate.cpp
@@ -7674,7 +7674,8 @@
       Def->setTemplateSpecializationKind(TSK);
 
       if (!getDLLAttr(Def) && getDLLAttr(Specialization) &&
-          Context.getTargetInfo().getCXXABI().isMicrosoft()) {
+          (Context.getTargetInfo().getCXXABI().isMicrosoft() ||
+           Context.getTargetInfo().getTriple().isWindowsItaniumEnvironment())) {
         // In the MS ABI, an explicit instantiation definition can add a dll
         // attribute to a template with a previous instantiation declaration.
         // MinGW doesn't allow this.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D26471.77392.patch
Type: text/x-patch
Size: 1466 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20161109/399bf204/attachment.bin>


More information about the cfe-commits mailing list