aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2011-07-29 00:21:44 +0000
committerDouglas Gregor <dgregor@apple.com>2011-07-29 00:21:44 +0000
commit1e849b6f43a6aded51466978d826e938859130db (patch)
tree62da8e2a4dcb9631c4ac83af3feedc805e6dc4e5
parente3b075b816195e22e3eb0679b0f93c2598aa3663 (diff)
Move the base type ID from the ASTReader's global type map into the
Module itself, which makes more sense. This pattern to be repeated several more times. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136436 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/clang/Serialization/ASTReader.h6
-rw-r--r--lib/Serialization/ASTReader.cpp13
2 files changed, 10 insertions, 9 deletions
diff --git a/include/clang/Serialization/ASTReader.h b/include/clang/Serialization/ASTReader.h
index 41cf09ad64..a42d97eba6 100644
--- a/include/clang/Serialization/ASTReader.h
+++ b/include/clang/Serialization/ASTReader.h
@@ -360,6 +360,9 @@ public:
/// type ID, or the representation of a Type*.
const uint32_t *TypeOffsets;
+ /// \brief Base type ID for types local to this module.
+ serialization::TypeID BaseTypeID;
+
// === Miscellaneous ===
/// \brief Diagnostic IDs and their mappings that the user changed.
@@ -537,8 +540,7 @@ private:
/// ID = (I + 1) << FastQual::Width has already been loaded
std::vector<QualType> TypesLoaded;
- typedef ContinuousRangeMap<serialization::TypeID,
- std::pair<Module *, int32_t>, 4>
+ typedef ContinuousRangeMap<serialization::TypeID, Module *, 4>
GlobalTypeMapType;
/// \brief Mapping from global type IDs to the module in which the
diff --git a/lib/Serialization/ASTReader.cpp b/lib/Serialization/ASTReader.cpp
index 34af0b70db..77286b7898 100644
--- a/lib/Serialization/ASTReader.cpp
+++ b/lib/Serialization/ASTReader.cpp
@@ -2054,12 +2054,11 @@ ASTReader::ReadASTBlock(Module &F) {
}
F.TypeOffsets = (const uint32_t *)BlobStart;
F.LocalNumTypes = Record[0];
-
+ F.BaseTypeID = getTotalNumTypes();
+
// Introduce the global -> local mapping for types within this
// AST file.
- GlobalTypeMap.insert(std::make_pair(getTotalNumTypes() + 1,
- std::make_pair(&F,
- -getTotalNumTypes())));
+ GlobalTypeMap.insert(std::make_pair(getTotalNumTypes() + 1, &F));
TypesLoaded.resize(TypesLoaded.size() + F.LocalNumTypes);
break;
@@ -3218,8 +3217,8 @@ void ASTReader::ReadPragmaDiagnosticMappings(Diagnostic &Diag) {
ASTReader::RecordLocation ASTReader::TypeCursorForIndex(unsigned Index) {
GlobalTypeMapType::iterator I = GlobalTypeMap.find(Index+1);
assert(I != GlobalTypeMap.end() && "Corrupted global type map");
- return RecordLocation(I->second.first,
- I->second.first->TypeOffsets[Index + I->second.second]);
+ Module *M = I->second;
+ return RecordLocation(M, M->TypeOffsets[Index - M->BaseTypeID]);
}
/// \brief Read and return the type with the given index..
@@ -4374,7 +4373,7 @@ void ASTReader::dump() {
llvm::errs() << "*** AST File Remapping:\n";
dumpModuleIDMap("Global bit offset map", GlobalBitOffsetsMap);
dumpModuleIDMap("Global source location entry map", GlobalSLocEntryMap);
- dumpModuleIDOffsetMap("Global type map", GlobalTypeMap);
+ dumpModuleIDMap("Global type map", GlobalTypeMap);
dumpModuleIDOffsetMap("Global declaration map", GlobalDeclMap);
dumpModuleIDOffsetMap("Global identifier map", GlobalIdentifierMap);
dumpModuleIDOffsetMap("Global selector map", GlobalSelectorMap);