See D84656 for the background on NamedDecl::printName.
This patch overloads NamedDecl::printName for VarDecl, FieldDecl ,RecordDecl and EnumDecl to provide a more user-friendly name in diagnostics for unnamed entities. We try to only use the term "anonymous" when we have an anonymous struct or union; otherwise we use the term "unnamed".
There is one little tweak we need to make to Sema::BuildAnonymousStructOrUnion: we mark the record as being anonymous as early as possible. This is to ensure that diagnostics emitted here will use the term "anonymous".
These names a bit too generic: open/close delimiter for *what* (there's a lot of paired delimiters to consider when pretty printing). Perhaps getUnnamedIdentOpenDelimiter() or something to make it more clear that this isn't, say, an attribute delimiter?