summaryrefslogtreecommitdiffstats
path: root/clang/lib/Serialization/ASTReader.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2011-07-20 00:27:43 +0000
committerDouglas Gregor <dgregor@apple.com>2011-07-20 00:27:43 +0000
commit047d2effea46b1ca886c64d174487aeddf3f13c7 (patch)
tree8c09c70f5cef5707da3b4906d278cea0b793a80a /clang/lib/Serialization/ASTReader.cpp
parent8957729268c201cf56f9c7a59913b8985b7ecf33 (diff)
downloadbcm5719-llvm-047d2effea46b1ca886c64d174487aeddf3f13c7.tar.gz
bcm5719-llvm-047d2effea46b1ca886c64d174487aeddf3f13c7.zip
Use a ContinuousRangeMap to map from the global declaration ID in the
AST reader down to the AST file + local ID within that file, rather than lamely walking the PCH chain. There's no actual functionality change now, but this is cleaner and more general. llvm-svn: 135548
Diffstat (limited to 'clang/lib/Serialization/ASTReader.cpp')
-rw-r--r--clang/lib/Serialization/ASTReader.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/clang/lib/Serialization/ASTReader.cpp b/clang/lib/Serialization/ASTReader.cpp
index 61c3a5c2ff4..9f3d7504c7f 100644
--- a/clang/lib/Serialization/ASTReader.cpp
+++ b/clang/lib/Serialization/ASTReader.cpp
@@ -2046,6 +2046,13 @@ ASTReader::ReadASTBlock(PerFileData &F) {
}
F.DeclOffsets = (const uint32_t *)BlobStart;
F.LocalNumDecls = Record[0];
+
+ // Introduce the global -> local mapping for declarations within this
+ GlobalDeclMap.insert(std::make_pair(getTotalNumDecls() + 1,
+ std::make_pair(&F,
+ -getTotalNumDecls())));
+ DeclsLoaded.resize(DeclsLoaded.size() + F.LocalNumDecls);
+
break;
case TU_UPDATE_LEXICAL: {
@@ -2522,14 +2529,13 @@ ASTReader::ASTReadResult ASTReader::ReadAST(const std::string &FileName,
}
// Allocate space for loaded slocentries, identifiers, decls and types.
- unsigned TotalNumIdentifiers = 0, TotalNumTypes = 0, TotalNumDecls = 0,
+ unsigned TotalNumIdentifiers = 0, TotalNumTypes = 0,
TotalNumPreallocatedPreprocessingEntities = 0, TotalNumMacroDefs = 0,
TotalNumSelectors = 0;
for (unsigned I = 0, N = Chain.size(); I != N; ++I) {
TotalNumSLocEntries += Chain[I]->LocalNumSLocEntries;
TotalNumIdentifiers += Chain[I]->LocalNumIdentifiers;
TotalNumTypes += Chain[I]->LocalNumTypes;
- TotalNumDecls += Chain[I]->LocalNumDecls;
TotalNumPreallocatedPreprocessingEntities +=
Chain[I]->NumPreallocatedPreprocessingEntities;
TotalNumMacroDefs += Chain[I]->LocalNumMacroDefinitions;
@@ -2537,7 +2543,6 @@ ASTReader::ASTReadResult ASTReader::ReadAST(const std::string &FileName,
}
IdentifiersLoaded.resize(TotalNumIdentifiers);
TypesLoaded.resize(TotalNumTypes);
- DeclsLoaded.resize(TotalNumDecls);
MacroDefinitionsLoaded.resize(TotalNumMacroDefs);
if (PP) {
if (TotalNumIdentifiers > 0)
OpenPOWER on IntegriCloud