@@ -329,6 +329,7 @@ SourceManager::~SourceManager() {
329
329
void SourceManager::clearIDTables () {
330
330
MainFileID = FileID ();
331
331
LocalSLocEntryTable.clear ();
332
+ LocalLocOffsetTable.clear ();
332
333
LoadedSLocEntryTable.clear ();
333
334
SLocEntryLoaded.clear ();
334
335
SLocEntryOffsetLoaded.clear ();
@@ -628,9 +629,11 @@ FileID SourceManager::createFileIDImpl(ContentCache &File, StringRef Filename,
628
629
noteSLocAddressSpaceUsage (Diag);
629
630
return FileID ();
630
631
}
632
+ assert (LocalSLocEntryTable.size () == LocalLocOffsetTable.size ());
631
633
LocalSLocEntryTable.push_back (
632
634
SLocEntry::get (NextLocalOffset,
633
635
FileInfo::get (IncludePos, File, FileCharacter, Filename)));
636
+ LocalLocOffsetTable.push_back (NextLocalOffset);
634
637
LastLookupStartOffset = NextLocalOffset;
635
638
// We do a +1 here because we want a SourceLocation that means "the end of the
636
639
// file", e.g. for the "no newline at the end of the file" diagnostic.
@@ -684,7 +687,9 @@ SourceManager::createExpansionLocImpl(const ExpansionInfo &Info,
684
687
SLocEntryLoaded[Index] = SLocEntryOffsetLoaded[Index] = true ;
685
688
return SourceLocation::getMacroLoc (LoadedOffset);
686
689
}
690
+ assert (LocalSLocEntryTable.size () == LocalLocOffsetTable.size ());
687
691
LocalSLocEntryTable.push_back (SLocEntry::get (NextLocalOffset, Info));
692
+ LocalLocOffsetTable.push_back (NextLocalOffset);
688
693
if (NextLocalOffset + Length + 1 <= NextLocalOffset ||
689
694
NextLocalOffset + Length + 1 > CurrentLoadedOffset) {
690
695
Diag.Report (diag::err_sloc_space_too_large);
@@ -807,6 +812,7 @@ FileID SourceManager::getFileIDLocal(SourceLocation::UIntTy SLocOffset) const {
807
812
assert (SLocOffset < NextLocalOffset && " Bad function choice" );
808
813
assert (SLocOffset >= LocalSLocEntryTable[0 ].getOffset () && SLocOffset > 0 &&
809
814
" Invalid SLocOffset" );
815
+ assert (LocalSLocEntryTable.size () == LocalLocOffsetTable.size ());
810
816
assert (LastFileIDLookup.ID >= 0 && " Only cache local file sloc entry" );
811
817
812
818
// After the first and second level caches, I see two common sorts of
@@ -837,8 +843,8 @@ FileID SourceManager::getFileIDLocal(SourceLocation::UIntTy SLocOffset) const {
837
843
unsigned NumProbes = 0 ;
838
844
while (true ) {
839
845
--GreaterIndex;
840
- assert (GreaterIndex < LocalSLocEntryTable .size ());
841
- if (LocalSLocEntryTable [GreaterIndex]. getOffset () <= SLocOffset) {
846
+ assert (GreaterIndex < LocalLocOffsetTable .size ());
847
+ if (LocalLocOffsetTable [GreaterIndex] <= SLocOffset) {
842
848
FileID Res = FileID::get (int (GreaterIndex));
843
849
// Remember it. We have good locality across FileID lookups.
844
850
LastFileIDLookup = Res;
@@ -858,11 +864,7 @@ FileID SourceManager::getFileIDLocal(SourceLocation::UIntTy SLocOffset) const {
858
864
++NumBinaryProbes;
859
865
860
866
unsigned MiddleIndex = LessIndex + (GreaterIndex - LessIndex) / 2 ;
861
-
862
- SourceLocation::UIntTy MidOffset =
863
- LocalSLocEntryTable[MiddleIndex].getOffset ();
864
-
865
- if (MidOffset <= SLocOffset)
867
+ if (LocalLocOffsetTable[MiddleIndex] <= SLocOffset)
866
868
LessIndex = MiddleIndex + 1 ;
867
869
else
868
870
GreaterIndex = MiddleIndex;
0 commit comments