diff options
author | Douglas Gregor <dgregor@apple.com> | 2011-08-04 18:56:47 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2011-08-04 18:56:47 +0000 |
commit | 272b6bc6a6c8fc04f951ad850df68c44d137f513 (patch) | |
tree | 84fcaff82022819fba1d81dfb01819f72e67033f /lib/Serialization/ASTReader.cpp | |
parent | 3b2257ca054aa0b7d0150a294f184e9349cda433 (diff) |
Introduce local -> global mapping for preprocessed entity IDs. This is
the last of the ID/offset/index mappings that I know
of. Unfortunately, the "gap" method of testing doesn't work here due
to the way the preprocessing record performs iteration. We'll do more
testing once multi-AST loading is possible.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136902 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Serialization/ASTReader.cpp')
-rw-r--r-- | lib/Serialization/ASTReader.cpp | 48 |
1 files changed, 35 insertions, 13 deletions
diff --git a/lib/Serialization/ASTReader.cpp b/lib/Serialization/ASTReader.cpp index 62ce2f8c8a..2606676b69 100644 --- a/lib/Serialization/ASTReader.cpp +++ b/lib/Serialization/ASTReader.cpp @@ -1643,8 +1643,12 @@ PreprocessedEntity *ASTReader::LoadPreprocessedEntity(Module &F) { PreprocessedEntityID ASTReader::getGlobalPreprocessedEntityID(Module &M, unsigned LocalID) { - // FIXME: Local-to-global mapping - return LocalID; + ContinuousRangeMap<uint32_t, int, 2>::iterator + I = M.PreprocessedEntityRemap.find(LocalID - NUM_PREDEF_PP_ENTITY_IDS); + assert(I != M.PreprocessedEntityRemap.end() + && "Invalid index into preprocessed entity index remap"); + + return LocalID + I->second; } namespace { @@ -2323,6 +2327,8 @@ ASTReader::ReadASTBlock(Module &F) { ContinuousRangeMap<uint32_t, int, 2>::Builder IdentifierRemap(F.IdentifierRemap); ContinuousRangeMap<uint32_t, int, 2>::Builder + PreprocessedEntityRemap(F.PreprocessedEntityRemap); + ContinuousRangeMap<uint32_t, int, 2>::Builder MacroDefinitionRemap(F.MacroDefinitionRemap); ContinuousRangeMap<uint32_t, int, 2>::Builder SelectorRemap(F.SelectorRemap); @@ -2350,12 +2356,12 @@ ASTReader::ReadASTBlock(Module &F) { // Source location offset is mapped to OM->SLocEntryBaseOffset. SLocRemap.insert(std::make_pair(SLocOffset, static_cast<int>(OM->SLocEntryBaseOffset - SLocOffset))); - - // FIXME: Map other locations IdentifierRemap.insert( std::make_pair(IdentifierIDOffset, OM->BaseIdentifierID - IdentifierIDOffset)); - (void)PreprocessedEntityIDOffset; + PreprocessedEntityRemap.insert( + std::make_pair(PreprocessedEntityIDOffset, + OM->BasePreprocessedEntityID - PreprocessedEntityIDOffset)); MacroDefinitionRemap.insert( std::make_pair(MacroDefinitionIDOffset, OM->BaseMacroDefinitionID - MacroDefinitionIDOffset)); @@ -2485,11 +2491,10 @@ ASTReader::ReadASTBlock(Module &F) { case MACRO_DEFINITION_OFFSETS: { F.MacroDefinitionOffsets = (const uint32_t *)BlobStart; F.NumPreallocatedPreprocessingEntities = Record[0]; - F.LocalNumMacroDefinitions = Record[1]; - unsigned LocalBaseMacroID = Record[2]; + unsigned LocalBasePreprocessedEntityID = Record[1]; + F.LocalNumMacroDefinitions = Record[2]; + unsigned LocalBaseMacroID = Record[3]; - // Introduce the global -> local mapping for preprocessed entities within - // this AST file. unsigned StartingID; if (PP) { if (!PP->getPreprocessingRecord()) @@ -2502,13 +2507,25 @@ ASTReader::ReadASTBlock(Module &F) { } else { // FIXME: We'll eventually want to kill this path, since it assumes // a particular allocation strategy in the preprocessing record. - StartingID = getTotalNumPreprocessedEntities(); + StartingID = getTotalNumPreprocessedEntities() + - F.NumPreallocatedPreprocessingEntities; } - GlobalPreprocessedEntityMap.insert(std::make_pair(StartingID, &F)); - F.BaseMacroDefinitionID = getTotalNumMacroDefinitions(); F.BasePreprocessedEntityID = StartingID; + if (F.NumPreallocatedPreprocessingEntities > 0) { + // Introduce the global -> local mapping for preprocessed entities in + // this module. + GlobalPreprocessedEntityMap.insert(std::make_pair(StartingID, &F)); + + // Introduce the local -> global mapping for preprocessed entities in + // this module. + F.PreprocessedEntityRemap.insert( + std::make_pair(LocalBasePreprocessedEntityID, + F.BasePreprocessedEntityID - LocalBasePreprocessedEntityID)); + } + + if (F.LocalNumMacroDefinitions > 0) { // Introduce the global -> local mapping for macro definitions within // this module. @@ -5606,8 +5623,13 @@ void Module::dump() { << '\n'; dumpLocalRemap("Source location offset map", SLocRemap); llvm::errs() << " Base identifier ID: " << BaseIdentifierID << '\n' - << "Number of identifiers: " << LocalNumIdentifiers << '\n'; + << " Number of identifiers: " << LocalNumIdentifiers << '\n'; dumpLocalRemap("Identifier ID map", IdentifierRemap); + llvm::errs() << " Base preprocessed entity ID: " << BasePreprocessedEntityID + << '\n' + << "Number of preprocessed entities: " + << NumPreallocatedPreprocessingEntities << '\n'; + dumpLocalRemap("Preprocessed entity ID map", PreprocessedEntityRemap); llvm::errs() << " Base type index: " << BaseTypeIndex << '\n' << " Number of types: " << LocalNumTypes << '\n'; dumpLocalRemap("Type index map", TypeRemap); |