[PATCH] D94646: [clang][MSVC] Fix missing MSInheritanceAttr in template specialization.

Zequan Wu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Jan 14 09:56:41 PST 2021


zequanwu updated this revision to Diff 316694.
zequanwu added a comment.

Update test case.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D94646/new/

https://reviews.llvm.org/D94646

Files:
  clang/lib/Sema/SemaTemplate.cpp
  clang/test/CodeGenCXX/microsoft-abi-member-pointers.cpp


Index: clang/test/CodeGenCXX/microsoft-abi-member-pointers.cpp
===================================================================
--- clang/test/CodeGenCXX/microsoft-abi-member-pointers.cpp
+++ clang/test/CodeGenCXX/microsoft-abi-member-pointers.cpp
@@ -148,6 +148,16 @@
 // CHECK-SAME:  %"struct.pr43803::C" { { i32, i32, i32 } { i32 8, i32 0, i32 0 }, [4 x i8] undef }]
 }
 
+namespace pr48687 {
+template <typename T> struct A {
+  T value;
+  static constexpr auto address = &A<T>::value;
+};
+extern template class A<float>;
+template class A<float>;
+// CHECK: @"?address@?$A at M@pr48687@@2QQ12 at MQ12@" = weak_odr dso_local constant i32 0, comdat, align 4
+}
+
 struct PR26313_Y;
 typedef void (PR26313_Y::*PR26313_FUNC)();
 struct PR26313_X {
Index: clang/lib/Sema/SemaTemplate.cpp
===================================================================
--- clang/lib/Sema/SemaTemplate.cpp
+++ clang/lib/Sema/SemaTemplate.cpp
@@ -9764,6 +9764,12 @@
       dllExportImportClassTemplateSpecialization(*this, Def);
     }
 
+    if (Context.getTargetInfo().getCXXABI().isMicrosoft() &&
+        Def->hasAttr<MSInheritanceAttr>()) {
+      Specialization->addAttr(Def->getAttr<MSInheritanceAttr>());
+      Consumer.AssignInheritanceModel(Specialization);
+    }
+
     // Set the template specialization kind. Make sure it is set before
     // instantiating the members which will trigger ASTConsumer callbacks.
     Specialization->setTemplateSpecializationKind(TSK);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D94646.316694.patch
Type: text/x-patch
Size: 1468 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210114/386243ae/attachment.bin>


More information about the cfe-commits mailing list