diff options
| author | Douglas Gregor <dgregor@apple.com> | 2011-08-25 21:09:44 +0000 |
|---|---|---|
| committer | Douglas Gregor <dgregor@apple.com> | 2011-08-25 21:09:44 +0000 |
| commit | a918babff436d67023a484815c0b3bba945cd04f (patch) | |
| tree | ce55cb128e6eb3541f0843ba0aa239a67f50b4b1 | |
| parent | d8114f7560617df42c502408362e25aad1b81e12 (diff) | |
| download | bcm5719-llvm-a918babff436d67023a484815c0b3bba945cd04f.tar.gz bcm5719-llvm-a918babff436d67023a484815c0b3bba945cd04f.zip | |
Preload source location entries as soon as we've loaded a particular
AST file, rather than waiting until we finish loading the top-level
AST file.
llvm-svn: 138585
| -rw-r--r-- | clang/include/clang/Serialization/ASTReader.h | 3 | ||||
| -rw-r--r-- | clang/include/clang/Serialization/Module.h | 3 | ||||
| -rw-r--r-- | clang/lib/Serialization/ASTReader.cpp | 26 |
3 files changed, 18 insertions, 14 deletions
diff --git a/clang/include/clang/Serialization/ASTReader.h b/clang/include/clang/Serialization/ASTReader.h index b145710a133..7eb512a51a7 100644 --- a/clang/include/clang/Serialization/ASTReader.h +++ b/clang/include/clang/Serialization/ASTReader.h @@ -244,9 +244,6 @@ private: /// at those bit offsets. ContinuousRangeMap<uint64_t, Module*, 4> GlobalBitOffsetsMap; - /// \brief SLocEntries that we're going to preload. - SmallVector<int, 64> PreloadSLocEntries; - /// \brief A map of negated SLocEntryIDs to the modules containing them. ContinuousRangeMap<unsigned, Module*, 64> GlobalSLocEntryMap; diff --git a/clang/include/clang/Serialization/Module.h b/clang/include/clang/Serialization/Module.h index a6a7da4fbdb..b3c3bc3271c 100644 --- a/clang/include/clang/Serialization/Module.h +++ b/clang/include/clang/Serialization/Module.h @@ -111,6 +111,9 @@ public: /// AST file. const uint32_t *SLocEntryOffsets; + /// \brief SLocEntries that we're going to preload. + SmallVector<uint64_t, 4> PreloadSLocEntries; + /// \brief The number of source location file entries in this AST file. unsigned LocalNumSLocFileEntries; diff --git a/clang/lib/Serialization/ASTReader.cpp b/clang/lib/Serialization/ASTReader.cpp index c9a8380ff68..86625b7bdf1 100644 --- a/clang/lib/Serialization/ASTReader.cpp +++ b/clang/lib/Serialization/ASTReader.cpp @@ -2216,9 +2216,12 @@ ASTReader::ReadASTBlock(Module &F) { case SOURCE_LOCATION_PRELOADS: { // Need to transform from the local view (1-based IDs) to the global view, // which is based off F.SLocEntryBaseID. - PreloadSLocEntries.reserve(PreloadSLocEntries.size() + Record.size()); - for (unsigned I = 0, N = Record.size(); I != N; ++I) - PreloadSLocEntries.push_back(int(Record[I] - 1) + F.SLocEntryBaseID); + if (!F.PreloadSLocEntries.empty()) { + Error("Multiple SOURCE_LOCATION_PRELOADS records in AST file"); + return Failure; + } + + F.PreloadSLocEntries.swap(Record); break; } @@ -2546,14 +2549,6 @@ ASTReader::ASTReadResult ASTReader::ReadAST(const std::string &FileName, } // Here comes stuff that we only do once the entire chain is loaded. - - // Preload SLocEntries. - for (unsigned I = 0, N = PreloadSLocEntries.size(); I != N; ++I) { - ASTReadResult Result = ReadSLocEntryRecord(PreloadSLocEntries[I]); - if (Result != Success) - return Failure; - } - PreloadSLocEntries.clear(); // Check the predefines buffers. if (!DisableValidation && Type != MK_Module && CheckPredefinesBuffers()) @@ -2742,6 +2737,15 @@ ASTReader::ASTReadResult ASTReader::ReadASTCore(StringRef FileName, case Success: break; } } + + // Preload SLocEntries. + for (unsigned I = 0, N = M->PreloadSLocEntries.size(); I != N; ++I) { + int Index = int(M->PreloadSLocEntries[I] - 1) + F.SLocEntryBaseID; + ASTReadResult Result = ReadSLocEntryRecord(Index); + if (Result != Success) + return Failure; + } + return Success; } |

