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

Matheus Izvekov via cfe-commits cfe-commits at lists.llvm.org
Wed May 14 08:44:40 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());
----------------
mizvekov wrote:

Yeah we need a representation for how the type was written, we try to avoid faking resolved types as written ones.

We model all current builtin templates as type aliases, and I still see this as a good fit here.

When unresolved (due to dependencies), they stay as canonical template specialization types, and when they  are resolved they simply become sugar by turning into aliases over whatever the builtin template specialization resolves to.

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


More information about the cfe-commits mailing list