[PATCH] D134813: Properly print unnamed TagDecl objects in diagnostics

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Sep 28 09:21:41 PDT 2022


aaron.ballman created this revision.
aaron.ballman added reviewers: erichkeane, jyknight.
Herald added subscribers: arphaman, delcypher.
Herald added a reviewer: dang.
Herald added a reviewer: ributzka.
Herald added a project: All.
aaron.ballman requested review of this revision.
Herald added projects: clang, LLVM.
Herald added a subscriber: llvm-commits.

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.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D134813

Files:
  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/Analysis/func-mapping-test.cpp
  clang/test/ExtractAPI/enum.c
  clang/test/ExtractAPI/typedef_anonymous_record.c
  clang/test/ExtractAPI/underscored.c
  clang/test/Index/Core/index-source.m
  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/cxx11-lambdas.cpp
  clang/test/Index/cxx14-lambdas.cpp
  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.cpp
  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
  llvm/utils/lit/lit/TestRunner.py

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D134813.463582.patch
Type: text/x-patch
Size: 50496 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220928/41df4320/attachment-0001.bin>


More information about the cfe-commits mailing list