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

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Jan 13 05:42:05 PST 2023


aaron.ballman added a comment.

> 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?


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