[clang] [clang][index][USR] GenLoc prints file entry at most once, allow repeated offsets (PR #205430)

Balázs Benics via cfe-commits cfe-commits at lists.llvm.org
Wed Jun 24 02:24:54 PDT 2026


================
@@ -64,7 +80,11 @@ class USRGenerator : public ConstDeclVisitor<USRGenerator> {
   ASTContext *Context;
   const LangOptions &LangOpts;
   bool IgnoreResults = false;
-  bool generatedLoc = false;
+  // The flag below ensures that, when a source location needs to be printed,
+  // the file entry is printed at most once during the recursive visit.  The
+  // offset part may be printed multiple times, since sub-decls along the
+  // path may each need a distinct location to disambiguate them.
+  bool GeneratedFileEntry = false;
----------------
steakhal wrote:

It was puzzling for me what `file entry` means in this context. How I understand it right now, it means `file path`. So maybe we should use `path` in the name?

https://github.com/llvm/llvm-project/pull/205430


More information about the cfe-commits mailing list