[PATCH] D128113: Clang: fix AST representation of expanded template arguments.

David Rector via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sat Aug 27 10:29:24 PDT 2022


davrec added a comment.

In D128113#3753640 <https://reviews.llvm.org/D128113#3753640>, @mizvekov wrote:

> In D128113#3753624 <https://reviews.llvm.org/D128113#3753624>, @davrec wrote:
>
>> Or just `SubstTemplateTypeParmType` could store this number in addition to its `TemplateTypeParmType`?  (E.g. the first Ts in an expansion is 0, the second Ts in the same expansion is 1, etc. - but it resets for the next expansion.)
>
> Well that number is just the pack_index, as implemented in this current patch :)

I meant that, in an of expansion `(Ts, Ts, Us)`, either the two `Ts` would be two unique `TemplateTypeParmType`s by adding an instanceIndex or whatever to refer to the two different syntactic instances (this would of course naturally result in two unique STTPTs), or for a bit more savings the TTPTs for the two `Ts` could continue to be the same but their STTPTs would include the instanceIndex, so there is only one unique TTPT but two unique STTPTs referring to `Ts`.

I.e. if there are 100 types in in `Ts` there would still only be two unique `SubstTemplateTypeParmTypes` created, as opposed to only 1 as there currently is, or 100 as this patch creates.

Any way it is done, the goal would be to make the STTPTs just as unique as necessary so the Resugarer can keep map from the unique STTPTs to its current pack index, and iterate the relevant index with each call to `TransformSubstTemplateTypeParmType`.

If I'm missing something and it is substantially more complex than that, then you're right that storing the pack index might end up the best solution - we don't want to e.g. have to do considerable Sema logic in the Resugarer just to infer the pack index.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D128113/new/

https://reviews.llvm.org/D128113



More information about the cfe-commits mailing list