[cfe-commits] r136436 - in /cfe/trunk: include/clang/Serialization/ASTReader.h lib/Serialization/ASTReader.cpp
Douglas Gregor
dgregor at apple.com
Thu Jul 28 17:21:44 PDT 2011
Author: dgregor
Date: Thu Jul 28 19:21:44 2011
New Revision: 136436
URL: http://llvm.org/viewvc/llvm-project?rev=136436&view=rev
Log:
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.
Modified:
cfe/trunk/include/clang/Serialization/ASTReader.h
cfe/trunk/lib/Serialization/ASTReader.cpp
Modified: cfe/trunk/include/clang/Serialization/ASTReader.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTReader.h?rev=136436&r1=136435&r2=136436&view=diff
==============================================================================
--- cfe/trunk/include/clang/Serialization/ASTReader.h (original)
+++ cfe/trunk/include/clang/Serialization/ASTReader.h Thu Jul 28 19:21:44 2011
@@ -360,6 +360,9 @@
/// 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 @@
/// 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
Modified: cfe/trunk/lib/Serialization/ASTReader.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=136436&r1=136435&r2=136436&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTReader.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReader.cpp Thu Jul 28 19:21:44 2011
@@ -2054,12 +2054,11 @@
}
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 @@
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 @@
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);
More information about the cfe-commits
mailing list