riccibruno created this revision.
riccibruno added reviewers: akyrtzi, jkorous, sammccall, hokein.
riccibruno added a project: clang.
Herald added subscribers: cfe-commits, arphaman, dexonsmith.

`NamedDecl::printName` is used as a customisation point for 
`getNameForDiagnostic`. The default implementation is just sending the 
`DeclarationName` into the output stream, but it can be overloaded to display a 
more user-friendly name for some entities.

Currently only `DecompositionDecl` and `MSGuidDecl` have an overload (and they 
were both added after this code was written) but I will be adding overloads to 
`VarDecl`, `FieldDecl`, `EnumDecl` and `RecordDecl` to better handle unnamed 
entities.

To preserve the current behaviour (that is except for `DecompositionDecl` and 
`MSGuidDecl` which I don't think are relevant here?), just send the 
`DeclarationName` into the output instead of going through 
`NamedDecl::printName`.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D84599

Files:
  clang/lib/Index/USRGeneration.cpp


Index: clang/lib/Index/USRGeneration.cpp
===================================================================
--- clang/lib/Index/USRGeneration.cpp
+++ clang/lib/Index/USRGeneration.cpp
@@ -179,7 +179,7 @@
 
 bool USRGenerator::EmitDeclName(const NamedDecl *D) {
   const unsigned startSize = Buf.size();
-  D->printName(Out);
+  Out << D->getDeclName();
   const unsigned endSize = Buf.size();
   return startSize == endSize;
 }


Index: clang/lib/Index/USRGeneration.cpp
===================================================================
--- clang/lib/Index/USRGeneration.cpp
+++ clang/lib/Index/USRGeneration.cpp
@@ -179,7 +179,7 @@
 
 bool USRGenerator::EmitDeclName(const NamedDecl *D) {
   const unsigned startSize = Buf.size();
-  D->printName(Out);
+  Out << D->getDeclName();
   const unsigned endSize = Buf.size();
   return startSize == endSize;
 }
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to