diff options
author | Douglas Gregor <dgregor@apple.com> | 2009-04-27 21:28:04 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2009-04-27 21:28:04 +0000 |
commit | 0bc1293584cc02a83f57762098a9622f541f3b84 (patch) | |
tree | 96b2fade40882164aa87ab678fd1fed80eaf288e /clang/lib | |
parent | 1f1e1c7e393fe8ff1dc12357b24d9b145af3ff04 (diff) | |
download | bcm5719-llvm-0bc1293584cc02a83f57762098a9622f541f3b84.tar.gz bcm5719-llvm-0bc1293584cc02a83f57762098a9622f541f3b84.zip |
Be more careful in our teardown of the PCHReader after deciding to
ignore a PCH file.
llvm-svn: 70251
Diffstat (limited to 'clang/lib')
-rw-r--r-- | clang/lib/Basic/SourceManager.cpp | 16 | ||||
-rw-r--r-- | clang/lib/Frontend/PCHReader.cpp | 8 |
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; |