[clang] [Clang][Sema] Handle invalid variable template specialization whose type depends on itself (PR #134522)

Younan Zhang via cfe-commits cfe-commits at lists.llvm.org
Mon Apr 28 09:03:44 PDT 2025


================
@@ -4348,6 +4348,23 @@ struct PartialSpecMatchResult {
   VarTemplatePartialSpecializationDecl *Partial;
   TemplateArgumentList *Args;
 };
+
+struct TemplateArgEqualityComparator {
+  const ASTContext &Context;
+
+  bool operator()(const TemplateArgument &Canonical,
+                  const TemplateArgument &Unknown) const {
+    llvm::FoldingSetNodeID ID1, ID2;
+    Canonical.Profile(ID1, Context);
+    Context.getCanonicalTemplateArgument(Unknown).Profile(ID2, Context);
+#ifndef NDEBUG
+    llvm::FoldingSetNodeID ID3;
+    Context.getCanonicalTemplateArgument(Canonical).Profile(ID3, Context);
+    assert(ID1 == ID3);
+#endif
+    return ID1 == ID2;
+  }
+};
----------------
zyn0217 wrote:

Can we use `TemplateArgument::structurallyEquals`?
If not, we also have `isSameTemplateArg(Context, X, Y)` localized in SemaTemplateDeduction, can we reuse that?

https://github.com/llvm/llvm-project/pull/134522


More information about the cfe-commits mailing list