[clang] [clang-tools-extra] [Clang] Add builtins that deduplicate and sort types (PR #106730)

Ilya Biryukov via cfe-commits cfe-commits at lists.llvm.org
Tue May 13 08:58:08 PDT 2025


================
@@ -1666,6 +1685,21 @@ namespace {
       return inherited::TransformTemplateArgument(Input, Output, Uneval);
     }
 
+    using TreeTransform::TransformTemplateSpecializationType;
+    QualType
+    TransformTemplateSpecializationType(TypeLocBuilder &TLB,
+                                        TemplateSpecializationTypeLoc TL) {
+      auto *T = TL.getTypePtr();
+      if (!getSema().ArgPackSubstIndex || !T->isSugared() ||
+          !isPackProducingBuiltinTemplateName(T->getTemplateName()))
+        return TreeTransform::TransformTemplateSpecializationType(TLB, TL);
+      // Look through sugar to get to the SubstBuiltinTemplatePackType that we
+      // need to substitute into.
+      QualType R = TransformType(T->desugar());
----------------
ilya-biryukov wrote:

The default implementation just never looks through `TemplateSpecializationType`, it will instead substitute into template arguments and template name and rerun `CheckTemplateId`.

This looks wrong to me (at least inefficient in some cases, not sure if that's semantically correct) and I thought I was missing something, but I am almost 100% certain that's what happens after going through the exercise of implementing this PR.

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


More information about the cfe-commits mailing list