aboutsummaryrefslogtreecommitdiff
path: root/lib/Serialization
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2011-07-21 18:46:38 +0000
committerDouglas Gregor <dgregor@apple.com>2011-07-21 18:46:38 +0000
commit0cdd798dbaadd959d3e97ea16993efbdccbbe642 (patch)
tree37273f2cc6bf8b9563713f501f31a25bb399bf21 /lib/Serialization
parent9cca68dbfc42f7778f8db0bcfe8b3e575599ac0f (diff)
In the AST reader, keep track of the total number of source locations
entries incrementally, rather than iterating over the chain when loading a single AST file. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135692 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Serialization')
-rw-r--r--lib/Serialization/ASTReader.cpp23
1 files changed, 10 insertions, 13 deletions
diff --git a/lib/Serialization/ASTReader.cpp b/lib/Serialization/ASTReader.cpp
index 4465b6b801..83c894b648 100644
--- a/lib/Serialization/ASTReader.cpp
+++ b/lib/Serialization/ASTReader.cpp
@@ -1239,7 +1239,7 @@ ASTReader::ASTReadResult ASTReader::ReadSLocEntryRecord(int ID) {
if (ID == 0)
return Success;
- if (unsigned(-ID) - 2 >= TotalNumSLocEntries || ID > 0) {
+ if (unsigned(-ID) - 2 >= getTotalNumSLocs() || ID > 0) {
Error("source location entry ID out-of-range for AST file");
return Failure;
}
@@ -2110,8 +2110,10 @@ ASTReader::ReadASTBlock(PerFileData &F) {
(const unsigned char *)F.IdentifierTableData + Record[0],
(const unsigned char *)F.IdentifierTableData,
ASTIdentifierLookupTrait(*this, F));
- if (PP)
+ if (PP) {
PP->getIdentifierTable().setExternalIdentifierLookup(this);
+ PP->getHeaderSearchInfo().SetExternalLookup(this);
+ }
}
break;
@@ -2240,6 +2242,8 @@ ASTReader::ReadASTBlock(PerFileData &F) {
// This module. Base was 2 when being compiled.
F.SLocRemap.insert(std::make_pair(2U,
static_cast<int>(F.SLocEntryBaseOffset - 2)));
+
+ TotalNumSLocEntries += F.LocalNumSLocEntries;
break;
}
@@ -2578,20 +2582,14 @@ ASTReader::ASTReadResult ASTReader::ReadAST(const std::string &FileName,
}
}
- // Allocate space for loaded slocentries, identifiers, decls and types.
- for (unsigned I = 0, N = Chain.size(); I != N; ++I) {
- TotalNumSLocEntries += Chain[I]->LocalNumSLocEntries;
- }
- if (PP)
- PP->getHeaderSearchInfo().SetExternalLookup(this);
-
// 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 && CheckPredefinesBuffers())
return IgnorePCH;
@@ -2789,6 +2787,7 @@ void ASTReader::setPreprocessor(Preprocessor &pp) {
}
PP->getHeaderSearchInfo().SetExternalLookup(this);
+ PP->getHeaderSearchInfo().SetExternalSource(this);
}
void ASTReader::InitializeContext(ASTContext &Ctx) {
@@ -2797,9 +2796,7 @@ void ASTReader::InitializeContext(ASTContext &Ctx) {
assert(PP && "Forgot to set Preprocessor ?");
PP->getIdentifierTable().setExternalIdentifierLookup(this);
- PP->getHeaderSearchInfo().SetExternalLookup(this);
PP->setExternalSource(this);
- PP->getHeaderSearchInfo().SetExternalSource(this);
// If we have an update block for the TU waiting, we have to add it before
// deserializing the decl.
@@ -4234,7 +4231,7 @@ void ASTReader::PrintStats() {
std::fprintf(stderr, " %u stat cache hits\n", NumStatHits);
std::fprintf(stderr, " %u stat cache misses\n", NumStatMisses);
- if (TotalNumSLocEntries)
+ if (unsigned TotalNumSLocEntries = getTotalNumSLocs())
std::fprintf(stderr, " %u/%u source location entries read (%f%%)\n",
NumSLocEntriesRead, TotalNumSLocEntries,
((float)NumSLocEntriesRead/TotalNumSLocEntries * 100));