[clang] [llvm] [clang][Modules][serialization] Deduplicate source location entries across loaded modules (PR #209795)
Jan Svoboda via cfe-commits
cfe-commits at lists.llvm.org
Fri Jul 17 10:47:43 PDT 2026
================
@@ -1815,6 +1815,97 @@ llvm::Error ASTReader::ReadSourceManagerBlock(ModuleFile &F) {
}
}
+const ASTReader::PrimaryLoadedFileLoc *
+ASTReader::getPrimaryLoadedFile(const SLocFileIdentity &Id) const {
+ assert(!Id.Name.empty() && "querying a non-file entry");
+ auto It = PrimaryLoadedFiles.find(Id.Name);
+ if (It == PrimaryLoadedFiles.end())
+ return nullptr;
+ const PrimaryLoadedFileLoc &Primary = It->second;
+ // A matching name but different size or time is a different file, e.g. two
+ // modules built against different versions of the same path. Don't merge.
+ if (Primary.Size != Id.Size || Primary.Time != Id.Time)
----------------
jansvoboda11 wrote:
The size+mtime of input files is already baked into Clang's PCMs by default, but can be (mostly?) disabled through command-line options I believe.
What I'd like to know is if we're okay with not deduplicating the input files due the names not matching exactly (i.e. capitalization, path separators, absolute/relative mismatch, benign path components differences, etc.).
https://github.com/llvm/llvm-project/pull/209795
More information about the cfe-commits
mailing list