[PATCH] D84658: [clang] Overload NamedDecl::printName to provide a user-friendly name for unnamed entities

Erich Keane via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Jul 27 07:39:13 PDT 2020


erichkeane added a comment.

This seems like a strict improvement as well.  That said, there are two opportunities to clean up the code that I suggest evaluating.



================
Comment at: clang/lib/AST/Decl.cpp:2032
+  // additional complexity needed to prevent this is not worthwhile.
+  OS << (Policy.MSVCFormatting ? '`' : '(')
+     << (IsAnonymousStructOrUnion ? "anonymous" : "unnamed") << ' '
----------------
This pattern is happening a bunch too....  Does it deserve some function?  Perhaps a function that either takes Policy, or a member of Policy to get the formatting open-tick or close-tick?


================
Comment at: clang/lib/AST/Decl.cpp:2074
+  if (Policy.AnonymousTagLocations && !SuppressLocation) {
+    PresumedLoc PLoc = Ctx.getSourceManager().getPresumedLoc(DD->getLocation());
+    if (PLoc.isValid()) {
----------------
It seems this entire block can be pulled out of these two functions.  This is probably worth while?

It seems that in this function, it would be:

if (!SuppressLocation)
    printLocation(....);

And in the other, just a call to PrintLocation(....).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84658





More information about the cfe-commits mailing list