[PATCH] D142268: [clang][DebugInfo] Don't canonicalize names in template argument list for alias templates

David Blaikie via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sun Jan 22 21:42:44 PST 2023


dblaikie added a comment.

So @Michael137 and I talked about this offline, and a few extra details:

- Generally it's important that types have identical names. Templates try to do this, but get it wrong in a bunch of ways (& certainly between GCC and Clang we get it different in a bunch of ways too) which are all problematic/could cause a debugger to not correctly identify two types in distinct CUs as being actually the same type.
  - That's why we usually use the full name of a template, to ensure it's identical between instantiations in different CUs
- Because compilers don't all produce character-for-character identical names, debuggers mostly have to throw away the "<.*>" and recanonicalize from the `DW_TAG_template_*_parameter`s anyway..
- But none of that matters, because alias templates aren't strong aliases - they aren't part of the type system, they're just a name that code can use
- As mentioned, GCC currently only uses the base name, no template parameters - which isn't super helpful (since you'd then end up with a bunch of different alias template instantiations all with the same name).
- Clang produces the alias template with the template parameters in the `DW_AT_name`, but without any `DW_TAG_template_*_parameter` DIEs, which means we can't apply Simple Template Names here, currently - though might be a nice thing to do at somepoint.

But for now, since the name doesn't actually have to be deconstruct/canonicalize the template parameters - we can just pick whatever name is nice for the user, really.

So, I think this is an OK change to make for now - though probably the nicer thing, long-term, would be to add the template parameter DIEs, and under `-gsimple-template-names` remove the template parameters from the `DW_AT_name` (& maybe eventually turn that on by default/migrate to `-gsimple-template-names`) but for now/when using non`-gsimple-template-names`, this seems OK, if a bit weird/inconsistent, but for good reasons because the alias template isn't part of the type system. (thanks for including the FIXME there)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142268



More information about the cfe-commits mailing list