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

Jan Svoboda via cfe-commits cfe-commits at lists.llvm.org
Wed Oct 4 11:05:40 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));
----------------
jansvoboda11 wrote:

Yeah, I think the ID `AllocateLoadedSLocEntries()` returns is incorrect. It's stored in `ModuleFile::SLocEntryBaseID` and used in `ASTReader::TranslateFileID()` where we actually do `- 1` again (to get the correct `ID - 2`). I do want to fix this, but there are places in `ASTWriter` that rely on this being wrong, so it's a bit more involved to make it into this PR.

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


More information about the cfe-commits mailing list