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

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Oct 6 12:19:32 PDT 2022


aaron.ballman added a comment.

Thank you *so much* to @sammccall @zixuw and @dang for the help with indexing and API extraction, I really appreciate it!



================
Comment at: clang/include/clang/AST/Decl.h:3647
 
+  void printName(raw_ostream &OS, const PrintingPolicy &Policy) const;
+
----------------
zixuw wrote:
> nit: missing an `override` here. (`warning: 'printName' overrides a member function but is not marked 'override' [-Winconsistent-missing-override]`)
Good catch, thank you!


================
Comment at: clang/lib/AST/Decl.cpp:4480
+  // the tag is anonymous and we should print it differently.
+  if (Name.isIdentifier() && !Name.getAsIdentifierInfo()) {
+    // If the caller wanted to print a qualified name, they've already printed
----------------
erichkeane wrote:
> Do we want to assert that this is either an EnumDecl, or a RecordDecl AND RD.isAnonymousStructOrUnion?
It's a reasonable suggestion, but I'd rather not because printing is used by the dump methods and dumping is often used from a debugger where things might be in a slightly weird state.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D134813/new/

https://reviews.llvm.org/D134813



More information about the cfe-commits mailing list