NamedDecl::printName is used as a customisation point for getNameForDiagnostic. The default implementation is just sending the DeclarationName into the output stream, but it can be overloaded to display a more user-friendly name for some entities.
Currently only DecompositionDecl and MSGuidDecl have an overload (and they were both added after this code was written) but I will be adding overloads to VarDecl, FieldDecl, EnumDecl and RecordDecl to better handle unnamed entities.
To preserve the current behaviour (that is except for DecompositionDecl and MSGuidDecl which I don't think are relevant here?), just send the DeclarationName into the output instead of going through NamedDecl::printName.