[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
================
@@ -636,23 +656,28 @@ void USRGenerator::GenExtSymbolContainer(const NamedDecl *D) {
}
bool USRGenerator::GenLoc(const Decl *D, bool IncludeOffset) {
- if (generatedLoc)
- return IgnoreResults;
- generatedLoc = true;
-
// Guard against null declarations in invalid code.
if (!D) {
IgnoreResults = true;
return true;
}
+ // Do nothing if file entry has been printed and no need to print the offset.
+ if (GeneratedFileEntry && !IncludeOffset)
----------------
steakhal wrote:
For me, it would make more sense to swap the order of these conditions.
For example, I'd read this as:
if we didn't ask for offsets, then well, we are done.
Otherwise, if we have already generated then we don't need to print again.
https://github.com/llvm/llvm-project/pull/205430
More information about the cfe-commits
mailing list