[PATCH] D126172: [clang] Fix comparison of TemplateArgument when they are of template kind

Robert Esclapez via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sun May 22 13:52:56 PDT 2022


roberteg16 updated this revision to Diff 431264.
roberteg16 edited the summary of this revision.
roberteg16 added a comment.

Make clang-format not complain


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126172

Files:
  clang/lib/AST/TemplateBase.cpp
  clang/test/CXX/dcl/dcl.fct/p17.cpp


Index: clang/test/CXX/dcl/dcl.fct/p17.cpp
===================================================================
--- clang/test/CXX/dcl/dcl.fct/p17.cpp
+++ clang/test/CXX/dcl/dcl.fct/p17.cpp
@@ -257,4 +257,23 @@
   static_assert(is_same_v<decltype(S2(1)), S2>);
   // expected-error at -1{{no matching}}
   static_assert(is_same_v<decltype(S2('a')), S2>);
-}
+
+  // clang-format off
+  template <typename T> struct S3 {};
+  // expected-note at -1 {{'S3' declared here}}
+  // expected-note at -2 {{template is declared here}}
+  void f23(C2<::S3> auto);
+  // expected-error at -1 {{no template named 'S3' in the global namespace; did you mean simply 'S3'?}}
+  // expected-error at -2 {{use of class template '::S3' requires template arguments}}
+  // clang-format on
+} // namespace constrained
+
+template <typename T> struct S4 {};
+// expected-note at -1 {{template is declared here}}
+
+namespace constrained {
+// clang-format off
+void f24(C2<::S4> auto);
+// expected-error at -1 {{use of class template '::S4' requires template arguments}}
+// clang-format on
+} // namespace constrained
Index: clang/lib/AST/TemplateBase.cpp
===================================================================
--- clang/lib/AST/TemplateBase.cpp
+++ clang/lib/AST/TemplateBase.cpp
@@ -370,8 +370,8 @@
 
   case Template:
   case TemplateExpansion:
-    return TemplateArg.Name == Other.TemplateArg.Name &&
-           TemplateArg.NumExpansions == Other.TemplateArg.NumExpansions;
+    return getAsTemplateOrTemplatePattern().getAsTemplateDecl() ==
+           Other.getAsTemplateOrTemplatePattern().getAsTemplateDecl();
 
   case Declaration:
     return getAsDecl() == Other.getAsDecl();


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D126172.431264.patch
Type: text/x-patch
Size: 1660 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220522/c5dd3409/attachment-0001.bin>


More information about the cfe-commits mailing list