roberteg16 created this revision.
roberteg16 added reviewers: Richard, smith.
Herald added a project: All.
roberteg16 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This diff path takes care of comparing Template{Expansion} by template decl
instead of by comparing the ptr attr Name and the number of expansions.


Repository:
  rG LLVM Github Monorepo

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,21 @@
   static_assert(is_same_v<decltype(S2(1)), S2>);
   // expected-error@-1{{no matching}}
   static_assert(is_same_v<decltype(S2('a')), S2>);
+
+  template <typename T>
+  struct S3 {};
+  // expected-note@-1 {{'S3' declared here}}
+  // expected-note@-2 {{template is declared here}}
+  void f23(C2<::S3> auto);
+  // expected-error@-1 {{no template named 'S3' in the global namespace; did 
you mean simply 'S3'?}}
+  // expected-error@-2 {{use of class template '::S3' requires template 
arguments}}
+}
+
+template <typename T>
+struct S4 {};
+// expected-note@-1 {{template is declared here}}
+
+namespace constrained {
+  void f24(C2<::S4> auto);
+  // expected-error@-1 {{use of class template '::S4' requires template 
arguments}}
 }
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();


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,21 @@
   static_assert(is_same_v<decltype(S2(1)), S2>);
   // expected-error@-1{{no matching}}
   static_assert(is_same_v<decltype(S2('a')), S2>);
+
+  template <typename T>
+  struct S3 {};
+  // expected-note@-1 {{'S3' declared here}}
+  // expected-note@-2 {{template is declared here}}
+  void f23(C2<::S3> auto);
+  // expected-error@-1 {{no template named 'S3' in the global namespace; did you mean simply 'S3'?}}
+  // expected-error@-2 {{use of class template '::S3' requires template arguments}}
+}
+
+template <typename T>
+struct S4 {};
+// expected-note@-1 {{template is declared here}}
+
+namespace constrained {
+  void f24(C2<::S4> auto);
+  // expected-error@-1 {{use of class template '::S4' requires template arguments}}
 }
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();
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to