[PATCH] D134453: Disambiguate type names when printing NTTP types

David Blaikie via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Oct 20 08:29:12 PDT 2022


dblaikie added a comment.

In D134453#3871414 <https://reviews.llvm.org/D134453#3871414>, @aaron.ballman wrote:

> In D134453#3871386 <https://reviews.llvm.org/D134453#3871386>, @dblaikie wrote:
>
>>> In terms of next steps, I think we should try to see if there's a "clear" path forward in terms of printing the types vs not printing the types. If we find one, then great, we go that way. But if we don't seem to have a clear path forward (relatively quickly; I don't think we want to drag this discussion on for months trying to find the perfect answer), then I think I'm fine with the patch as-is. It fixes the issue of `t<{}>` (with empty braces specifically) while retaining the status quo in other areas, but still exposes useful functionality through the additional printing policy. Does that sound reasonable?
>>
>> If you reckon (1) is better overall anyway - happy enough to defer to your opinion there and go with that, skip/omit the printing policy.
>
> Okay, thanks for that! I'm still happy to consider alternatives if we can think of any, FWIW.
>
>> I think the policy is like adding off-by-default warnings, and supporting a use case (using the string name for reflection when we'd recommend the AST) I don't think we want to encourage/support.
>
> That's a fair point. So if we find no better approach, drop the policy and just always print types.

Yeah - I don't think I have any better ideas that are reasonably within reach for a newer contributor nor worth holding up fixing the `t1<{}>` bug for.

Yeah, for type comparisons/fancy template type diffing we could trim things down if we aren't already(we probably aren't), but that doesn't address the cases where the name appears alone and not as part of a comparison. And when there's no particular context, I can't think of any cues we could use to decide which nested names "matter".

(rabbit hole/tangent: Arguably what might be more useful to the user might be a name that's not even usable in C++ - using the member variable names, as well as the type names, though that'd be even more verbose... like `t1<t2{.length=3, .width=7}>` - which, I guess, if you had user defined types for some kind of extra type safety, would get as verbose as `t1<Shape{Length{.length = 3}, Width{.width = 5}}>` though I would expect that would be the minority)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134453



More information about the cfe-commits mailing list