[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 11:56:47 PDT 2022
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 at -1{{no matching}}
static_assert(is_same_v<decltype(S2('a')), S2>);
+
+ 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}}
+}
+
+template <typename T>
+struct S4 {};
+// expected-note at -1 {{template is declared here}}
+
+namespace constrained {
+ void f24(C2<::S4> auto);
+ // expected-error at -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();
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D126172.431245.patch
Type: text/x-patch
Size: 1529 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220522/ad71a185/attachment.bin>
More information about the cfe-commits
mailing list