[PATCH] D140423: [WIP][clang] Add PrintingPolicy callback for identifying default template arguments

David Blaikie via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Jan 13 10:53:23 PST 2023


dblaikie added a comment.

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

>> Add something like a bool IsDefaulted somewhere in Clang, e.g., in TemplateArgument and consult it from the TypePrinter. This would be much simpler but requires adding a field on one of the Clang types
>
> I think this might be worth exploring as a cleaner solution to the problem. `TemplateArgument` has a union of structures for the various kinds of template arguments it represents (https://github.com/llvm/llvm-project/blob/main/clang/include/clang/AST/TemplateBase.h#L140). All of the structures in that union start with an `unsigned Kind` field to discriminate between the members. There are only 8 kinds currently (https://github.com/llvm/llvm-project/blob/main/clang/include/clang/AST/TemplateBase.h#L63), so we could turn `Kind` into a bit-field and then steal a bit for `IsDefaulted` without increasing memory overhead. Do you think that's a reasonable approach to try instead?

FWIW, I Think I discouraged @Michael137 from going down that direction since it felt weird to me to add that sort of thing to the Clang ASTs for an lldb-only use case, and a callback seemed more suitable. But this is hardly my wheelhouse - if you reckon that's the better direction, carry on, I expect @Michael137 will be on board with that.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140423



More information about the cfe-commits mailing list