[clangd] Don't print locations of anonymous tags
authorSam McCall <sam.mccall@gmail.com>
Tue, 4 Oct 2022 19:37:27 +0000 (21:37 +0200)
committerSam McCall <sam.mccall@gmail.com>
Tue, 4 Oct 2022 19:38:18 +0000 (21:38 +0200)
These are usually not interesting when clangd presents results in
context, and the file paths are noisy.

clang-tools-extra/clangd/AST.cpp

index 31db4cf..a092b93 100644 (file)
@@ -189,6 +189,9 @@ std::string printQualifiedName(const NamedDecl &ND) {
   // include them, but at query time it's hard to find all the inline
   // namespaces to query: the preamble doesn't have a dedicated list.
   Policy.SuppressUnwrittenScope = true;
+  // (unnamed struct), not (unnamed struct at /path/to/foo.cc:42:1).
+  // In clangd, context is usually available and paths are mostly noise.
+  Policy.AnonymousTagLocations = false;
   ND.printQualifiedName(OS, Policy);
   OS.flush();
   assert(!StringRef(QName).startswith("::"));