Properly print unnamed TagDecl objects in diagnostics
authorAaron Ballman <aaron@aaronballman.com>
Fri, 14 Oct 2022 12:17:16 +0000 (08:17 -0400)
committerAaron Ballman <aaron@aaronballman.com>
Fri, 14 Oct 2022 12:18:28 +0000 (08:18 -0400)
commit19e984ef8f49bc3ccced15621989fa9703b2cd5b
treed130cb8421bab54d6627aeca1b468d74f0d66944
parentce4d5ae9dcf64deade70f305b8d7ab8d0dc80102
Properly print unnamed TagDecl objects in diagnostics

The diagnostics engine is very smart about being passed a NamedDecl to
print as part of a diagnostic; it gets the "right" form of the name,
quotes it properly, etc. However, the result of using an unnamed tag
declaration was to print '' instead of anything useful.

This patch causes us to print the same information we'd have gotten if
we had printed the type of the declaration rather than the name of it,
as that's the most relevant information we can display.

Differential Revision: https://reviews.llvm.org/D134813
32 files changed:
clang-tools-extra/clangd/unittests/FindTargetTests.cpp
clang/include/clang/AST/Decl.h
clang/include/clang/AST/DeclCXX.h
clang/include/clang/AST/DeclTemplate.h
clang/lib/AST/ASTDiagnostic.cpp
clang/lib/AST/Decl.cpp
clang/lib/AST/DeclCXX.cpp
clang/lib/AST/DeclPrinter.cpp
clang/lib/AST/DeclTemplate.cpp
clang/lib/AST/NestedNameSpecifier.cpp
clang/lib/AST/TemplateName.cpp
clang/lib/CodeGen/CodeGenTypes.cpp
clang/lib/Sema/SemaTemplateInstantiate.cpp
clang/test/AST/ast-dump-record-definition-data-json.cpp
clang/test/ExtractAPI/enum.c
clang/test/Index/annotate-comments-typedef.m
clang/test/Index/c-index-api-loadTU-test.m
clang/test/Index/c-index-getCursor-test.m
clang/test/Index/print-type.c
clang/test/Index/print-type.cpp
clang/test/Index/targeted-annotation.c
clang/test/Index/targeted-cursor.c
clang/test/Index/usrs.m
clang/test/Sema/address-packed.c
clang/test/Sema/attr-flag-enum.c
clang/test/SemaCXX/attr-unused.cpp
clang/test/SemaCXX/lambda-expressions.cpp
clang/test/SemaCXX/ms-interface.cpp
clang/test/SemaObjCXX/arc-0x.mm
clang/test/Templight/templight-empty-entries-fix.cpp
clang/unittests/AST/ASTTraverserTest.cpp
llvm/utils/lit/lit/TestRunner.py