[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
Wed May 14 08:21:02 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 issue I see in this case here is that you are just dropping the TemplateSpecializationType, why can't you just build a new one here to wrap over the transformed underlying type?
`TemplateSpecializationType` looks like the right sugar for the whole pack, but after we pick a single element from it I don't think it models what we want correctly. I.e. `dedup<int, double> == argpack{int, double}`, but **not equal** to the individual `int` or `double` after we've picked them.
So I decided to stick with the lack of sugar rather than pick the incorrect one (from that perspective).
Or do you feel `TemplateSpecializationType` is a good fit here?
https://github.com/llvm/llvm-project/pull/106730
More information about the cfe-commits
mailing list