[PATCH] D135191: [Index] USRGeneration doesn't depend on unnamed.printName() => ''. NFC

Sam McCall via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Oct 4 13:05:26 PDT 2022


sammccall created this revision.
sammccall added a reviewer: aaron.ballman.
Herald added a subscriber: arphaman.
Herald added a project: All.
sammccall requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This prepares for printName() to print `(anonymous struct)` etc in D134813 <https://reviews.llvm.org/D134813>.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D135191

Files:
  clang/lib/Index/USRGeneration.cpp


Index: clang/lib/Index/USRGeneration.cpp
===================================================================
--- clang/lib/Index/USRGeneration.cpp
+++ clang/lib/Index/USRGeneration.cpp
@@ -179,10 +179,11 @@
 //===----------------------------------------------------------------------===//
 
 bool USRGenerator::EmitDeclName(const NamedDecl *D) {
-  const unsigned startSize = Buf.size();
-  D->printName(Out);
-  const unsigned endSize = Buf.size();
-  return startSize == endSize;
+  DeclarationName N = D->getDeclName();
+  if (N.isEmpty())
+    return true;
+  Out << N;
+  return false;
 }
 
 bool USRGenerator::ShouldGenerateLocation(const NamedDecl *D) {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D135191.465132.patch
Type: text/x-patch
Size: 661 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20221004/313174c5/attachment-0001.bin>


More information about the cfe-commits mailing list