summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/Basic/SourceManager.cpp16
-rw-r--r--clang/lib/Frontend/PCHReader.cpp8
2 files changed, 24 insertions, 0 deletions
diff --git a/clang/lib/Basic/SourceManager.cpp b/clang/lib/Basic/SourceManager.cpp
index 50576636db3..9ca00f5823d 100644
--- a/clang/lib/Basic/SourceManager.cpp
+++ b/clang/lib/Basic/SourceManager.cpp
@@ -318,6 +318,22 @@ void SourceManager::PreallocateSLocEntries(ExternalSLocEntrySource *Source,
SLocEntryTable.resize(SLocEntryTable.size() + NumSLocEntries);
}
+void SourceManager::ClearPreallocatedSLocEntries() {
+ unsigned I = 0;
+ for (unsigned N = SLocEntryLoaded.size(); I != N; ++I)
+ if (!SLocEntryLoaded[I])
+ break;
+
+ // We've already loaded all preallocated source location entries.
+ if (I == SLocEntryLoaded.size())
+ return;
+
+ // Remove everything from location I onward.
+ SLocEntryTable.resize(I);
+ SLocEntryLoaded.clear();
+ ExternalSLocEntries = 0;
+}
+
//===----------------------------------------------------------------------===//
// Methods to create new FileID's and instantiations.
diff --git a/clang/lib/Frontend/PCHReader.cpp b/clang/lib/Frontend/PCHReader.cpp
index d044fee4280..d36d8361fd8 100644
--- a/clang/lib/Frontend/PCHReader.cpp
+++ b/clang/lib/Frontend/PCHReader.cpp
@@ -1116,6 +1116,14 @@ PCHReader::PCHReadResult PCHReader::ReadPCH(const std::string &FileName) {
// FIXME: We could consider reading through to the end of this
// PCH block, skipping subblocks, to see if there are other
// PCH blocks elsewhere.
+
+ // Clear out any preallocated source location entries, so that
+ // the source manager does not try to resolve them later.
+ PP.getSourceManager().ClearPreallocatedSLocEntries();
+
+ // Remove the stat cache.
+ PP.getFileManager().setStatCache(0);
+
return IgnorePCH;
}
break;
OpenPOWER on IntegriCloud