aboutsummaryrefslogtreecommitdiff
path: root/lib/Basic/SourceManager.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Basic/SourceManager.cpp')
-rw-r--r--lib/Basic/SourceManager.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/Basic/SourceManager.cpp b/lib/Basic/SourceManager.cpp
index 4a1eb3096d..0a6ce4c03e 100644
--- a/lib/Basic/SourceManager.cpp
+++ b/lib/Basic/SourceManager.cpp
@@ -424,9 +424,12 @@ void SourceManager::PreallocateSLocEntries(ExternalSLocEntrySource *Source,
unsigned NextOffset) {
ExternalSLocEntries = Source;
this->NextOffset = NextOffset;
+ unsigned CurPrealloc = SLocEntryLoaded.size();
+ // If we've ever preallocated, we must not count the dummy entry.
+ if (CurPrealloc) --CurPrealloc;
SLocEntryLoaded.resize(NumSLocEntries + 1);
SLocEntryLoaded[0] = true;
- SLocEntryTable.resize(SLocEntryTable.size() + NumSLocEntries);
+ SLocEntryTable.resize(SLocEntryTable.size() + NumSLocEntries - CurPrealloc);
}
void SourceManager::ClearPreallocatedSLocEntries() {