[clang] [clang][modules] Remove preloaded SLocEntries from PCM files (PR #66962)

Ben Langmuir via cfe-commits cfe-commits at lists.llvm.org
Tue Oct 3 13:53:00 PDT 2023


================
@@ -701,6 +701,10 @@ class SourceManager : public RefCountedBase<SourceManager> {
   /// use (-ID - 2).
   SmallVector<SrcMgr::SLocEntry, 0> LoadedSLocEntryTable;
 
+  /// For each allocation in LoadedSLocEntryTable, we keep the new size. This
+  /// can be used to determine whether two FileIDs come from the same AST file.
+  SmallVector<size_t, 0> LoadedSLocEntryTableSegments;
----------------
benlangmuir wrote:

I feel like this could use more explanation. IIUC what you're ultimately checking is whether two FileIDs were allocated in the same call to `AllocateLoadedSLocEntries`, and relying on ASTReader to make a single call to that function for each AST file.  Is there a reason you're storing the size (ie translating to 0-based) instead of storing the actual boundary FileID and doing the search based on that? I feel like searching for -ID - 2 is pretty non-obvious.

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


More information about the cfe-commits mailing list