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

Ben Langmuir via cfe-commits cfe-commits at lists.llvm.org
Wed Oct 4 10:54:01 PDT 2023


================
@@ -458,14 +458,12 @@ SourceManager::AllocateLoadedSLocEntries(unsigned NumSLocEntries,
       CurrentLoadedOffset - TotalSize < NextLocalOffset) {
     return std::make_pair(0, 0);
   }
-
-  unsigned NewTableSize = LoadedSLocEntryTable.size() + NumSLocEntries;
-  LoadedSLocEntryTableSegments.push_back(NewTableSize);
-  LoadedSLocEntryTable.resize(NewTableSize);
-  SLocEntryLoaded.resize(NewTableSize);
-
+  LoadedSLocEntryTable.resize(LoadedSLocEntryTable.size() + NumSLocEntries);
+  SLocEntryLoaded.resize(LoadedSLocEntryTable.size());
   CurrentLoadedOffset -= TotalSize;
-  return std::make_pair(-NewTableSize - 1, CurrentLoadedOffset);
+  int ID = LoadedSLocEntryTable.size();
+  LoadedSLocEntryAllocBegin.push_back(FileID::get(-ID - 2));
----------------
benlangmuir wrote:

To clarify (from `LoadedSLocEntryAllocBegin`):
> we keep the first FileID

but `AllocateLoadedSLocEntries` says
> The lowest ID ... of the entries will be returned.

So it's odd that one is -ID-2 and the other is -ID-1. Based on the comments I would have expected they'd either be the same or one would be offset from the other by the number of entries allocated.

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


More information about the cfe-commits mailing list