[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 13:07:59 PDT 2023
================
@@ -1986,13 +1984,15 @@ bool SourceManager::isInTheSameTranslationUnitImpl(
if (isLoadedFileID(LOffs.first) != isLoadedFileID(ROffs.first))
return false;
- // If both are loaded from different AST files.
if (isLoadedFileID(LOffs.first) && isLoadedFileID(ROffs.first)) {
- auto FindTableSegment = [this](FileID FID) {
- return llvm::upper_bound(LoadedSLocEntryTableSegments, -FID.ID - 2);
+ auto FindSLocEntryAlloc = [this](FileID FID) {
+ // FileIDs are negative, we store the beginning of each allocation (the
+ // lowest FileID), later allocations have lower FileIDs.
+ return llvm::upper_bound(LoadedSLocEntryAllocBegin, FID, std::greater{});
----------------
jansvoboda11 wrote:
No, that's just me not being able to visualize binary search over anything else than positive increasing integers 😅
You're right, this should be `lower_bound`. `upper_bound` would report the incorrect allocation for the first `FileID`. Fixed in the latest commit and added a unit test.
https://github.com/llvm/llvm-project/pull/66962
More information about the cfe-commits
mailing list