[clang] [clang-tools-extra] [clang][TypePrinter] Unify printing of anonymous/unnamed tag types (PR #169445)

Michael Buch via cfe-commits cfe-commits at lists.llvm.org
Fri Nov 28 05:57:23 PST 2025


Michael137 wrote:

> I like the direction.
> 
> Some comments:
> 
> * This would be better declared in Decl.h, since it's about printing declarations, and not related to types.
> * This could probably get rid of the additional bool flags, and rely on PrintingPolicy entirely.
> * Instead of the `printAnonymousTagDecl` helper, we could probably implement a `print` method for TagDecls, which takes care of the named case, and for the unnamed case, takes care of the EnumDecl and RecordDecl specific behavior, including the typedef to unnamed class.

Latest commit reworks the patch to do the anonymous type-printing in `TagDecl::printName`. Getting the tag keyword to print is a bit fiddly. Not a big fan of having to introduce another bit into the `PrintingPolicy` for this though. Is this along the lines of what you had in mind?

https://github.com/llvm/llvm-project/pull/169445


More information about the cfe-commits mailing list