[clang] [llvm] [clang][Modules][Serialization] Avoid serializing duplicate source location entries for shared input files (PR #209795)

Chuanqi Xu via cfe-commits cfe-commits at lists.llvm.org
Thu Sep 17 01:36:39 PDT 2026


================
@@ -1448,6 +1448,38 @@ class ASTReader : public ExternalPreprocessorSource,
     const StringRef &operator*() && = delete;
   };
 
+public:
+  /// Returns where a loaded module keeps the input file with path \p Path and
+  /// size \p Size, or an invalid \c FID if no loaded module has the file.
+  serialization::InputFileLoc getLoadedFileLoc(StringRef Path, off_t Size);
+
+private:
+  struct LoadedInputFile {
+    off_t Size;
+    ModuleFile *F;
+    unsigned InputID;
+  };
+
+  /// Input files of loaded modules, keyed by resolved path. Built on first use.
+  llvm::StringMap<SmallVector<LoadedInputFile, 1>> LoadedInputFiles;
+  bool LoadedInputFilesBuilt = false;
----------------
ChuanqiXu9 wrote:

How can an input files not being built? This is ambiguous. Can't we use `LoadedInputFiles.empty()`?

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


More information about the cfe-commits mailing list