================ @@ -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 guess I could store `FileID(ModuleFile::SLocEntryBaseID - 1)` instead > (which is the module's `FileID(1)` translated into the importer address space > for loaded entries) and do `lower_bound` over that: > > ```c++ > SmallVector<FileID, 0> LoadedSLocEntryTableSegments{ > FileID(-10), // represents FileIDs from -10 to -2 > FileID(-50), // represents FileIDs from -50 to -11 > FileID(-90)}; // represents FileIDs from -90 to -51 > > llvm::lower_bound(LoadedSLocEntryTableSegments, FID, [](FileID Element, > FileID Value) { > return Element.ID > Value.ID; > }); > ``` > > The lambda is still confusing... Any better ideas? This is roughly what I had in mind, though I would just do `std::greater` for that comparison function (FileID has comparison operators) and leave a comment that loaded FileID is negative. I find this much clearer than searching for `-ID - 2`. https://github.com/llvm/llvm-project/pull/66962 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits