Don't introduce a local -> global mapping for CXXBaseSpecifiers. The

IDs will never cross module boundaries, since they're tied to the
CXXDefinitionData, so just use a local mapping throughout. Eliminate
the global -> local tables and supporting data.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136847 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Douglas Gregor 2011-08-04 00:01:48 +00:00
Родитель 8d28897e32
Коммит e92b8a1dbb
4 изменённых файлов: 20 добавлений и 44 удалений

Просмотреть файл

@ -377,9 +377,6 @@ public:
/// indexed by the C++ base specifier set ID (-1).
const uint32_t *CXXBaseSpecifiersOffsets;
/// \brief Base base specifier ID for base specifiers local to this module.
serialization::CXXBaseSpecifiersID BaseCXXBaseSpecifiersID;
// === Types ===
/// \brief The number of types in this AST file.
@ -723,14 +720,6 @@ private:
/// added to the global preprocessing entitiy ID to produce a local ID.
GlobalPreprocessedEntityMapType GlobalPreprocessedEntityMap;
typedef ContinuousRangeMap<serialization::CXXBaseSpecifiersID, Module *, 4>
GlobalCXXBaseSpecifiersMapType;
/// \brief Mapping from global CXX base specifier IDs to the module in which
/// the CXX base specifier resides along with the offset that should be added
/// to the global CXX base specifer ID to produce a local ID.
GlobalCXXBaseSpecifiersMapType GlobalCXXBaseSpecifiersMap;
/// \name CodeGen-relevant special data
/// \brief Fields containing data that is relevant to CodeGen.
//@{
@ -1034,7 +1023,9 @@ private:
void LoadedDecl(unsigned Index, Decl *D);
Decl *ReadDeclRecord(serialization::DeclID ID);
RecordLocation DeclCursorForID(serialization::DeclID ID);
RecordLocation getLocalBitOffset(uint64_t GlobalOffset);
uint64_t getGlobalBitOffset(Module &M, uint32_t LocalOffset);
void PassInterestingDeclsToConsumer();
@ -1292,9 +1283,10 @@ public:
return cast_or_null<T>(GetDecl(ReadDeclID(F, R, I)));
}
/// \brief Resolve a CXXBaseSpecifiers ID into an offset into the chain
/// of loaded AST files.
uint64_t GetCXXBaseSpecifiersOffset(serialization::CXXBaseSpecifiersID ID);
/// \brief Read a CXXBaseSpecifiers ID form the given record and
/// return its global bit offset.
uint64_t readCXXBaseSpecifiers(Module &M, const RecordData &Record,
unsigned &Idx);
virtual CXXBaseSpecifier *GetExternalCXXBaseSpecifiers(uint64_t Offset);

Просмотреть файл

@ -2336,7 +2336,6 @@ ASTReader::ReadASTBlock(Module &F) {
uint32_t MacroDefinitionIDOffset = io::ReadUnalignedLE32(Data);
uint32_t SelectorIDOffset = io::ReadUnalignedLE32(Data);
uint32_t DeclIDOffset = io::ReadUnalignedLE32(Data);
uint32_t CXXBaseSpecifiersIDOffset = io::ReadUnalignedLE32(Data);
uint32_t TypeIndexOffset = io::ReadUnalignedLE32(Data);
// Source location offset is mapped to OM->SLocEntryBaseOffset.
@ -2354,8 +2353,6 @@ ASTReader::ReadASTBlock(Module &F) {
DeclRemap.insert(std::make_pair(DeclIDOffset,
OM->BaseDeclID - DeclIDOffset));
(void)CXXBaseSpecifiersIDOffset;
TypeRemap.insert(std::make_pair(TypeIndexOffset,
OM->BaseTypeIndex - TypeIndexOffset));
}
@ -2539,10 +2536,6 @@ ASTReader::ReadASTBlock(Module &F) {
F.LocalNumCXXBaseSpecifiers = Record[0];
F.CXXBaseSpecifiersOffsets = (const uint32_t *)BlobStart;
F.BaseCXXBaseSpecifiersID = getTotalNumCXXBaseSpecifiers();
GlobalCXXBaseSpecifiersMap.insert(
std::make_pair(getTotalNumCXXBaseSpecifiers() + 1, &F));
NumCXXBaseSpecifiersLoaded += F.LocalNumCXXBaseSpecifiers;
break;
}
@ -4091,20 +4084,13 @@ Decl *ASTReader::GetExternalDecl(uint32_t ID) {
return GetDecl(ID);
}
uint64_t
ASTReader::GetCXXBaseSpecifiersOffset(serialization::CXXBaseSpecifiersID ID) {
if (ID == 0)
uint64_t ASTReader::readCXXBaseSpecifiers(Module &M, const RecordData &Record,
unsigned &Idx){
if (Idx >= Record.size())
return 0;
GlobalCXXBaseSpecifiersMapType::iterator I =
GlobalCXXBaseSpecifiersMap.find(ID);
assert (I != GlobalCXXBaseSpecifiersMap.end() &&
"Corrupted global CXX base specifiers map");
Module *M = I->second;
return M->CXXBaseSpecifiersOffsets[ID - 1 - M->BaseCXXBaseSpecifiersID] +
M->GlobalBitOffset;
unsigned LocalID = Record[Idx++];
return getGlobalBitOffset(M, M.CXXBaseSpecifiersOffsets[LocalID - 1]);
}
CXXBaseSpecifier *ASTReader::GetExternalCXXBaseSpecifiers(uint64_t Offset) {
@ -4438,7 +4424,6 @@ void ASTReader::dump() {
dumpModuleIDMap("Global source location entry map", GlobalSLocEntryMap);
dumpModuleIDMap("Global type map", GlobalTypeMap);
dumpModuleIDMap("Global declaration map", GlobalDeclMap);
dumpModuleIDMap("Global C++ base specifiers map", GlobalCXXBaseSpecifiersMap);
dumpModuleIDMap("Global identifier map", GlobalIdentifierMap);
dumpModuleIDMap("Global selector map", GlobalSelectorMap);
dumpModuleIDMap("Global macro definition map", GlobalMacroDefinitionMap);
@ -5555,7 +5540,6 @@ Module::Module(ModuleKind Kind)
SelectorLookupTableData(0), SelectorLookupTable(0), LocalNumDecls(0),
DeclOffsets(0), BaseDeclID(0),
LocalNumCXXBaseSpecifiers(0), CXXBaseSpecifiersOffsets(0),
BaseCXXBaseSpecifiersID(0),
LocalNumTypes(0), TypeOffsets(0), BaseTypeIndex(0), StatCache(0),
NumPreallocatedPreprocessingEntities(0)
{}

Просмотреть файл

@ -889,10 +889,10 @@ void ASTDeclReader::ReadCXXDefinitionData(
Data.NumBases = Record[Idx++];
if (Data.NumBases)
Data.Bases = Reader.GetCXXBaseSpecifiersOffset(Record[Idx++]);
Data.Bases = Reader.readCXXBaseSpecifiers(F, Record, Idx);
Data.NumVBases = Record[Idx++];
if (Data.NumVBases)
Data.VBases = Reader.GetCXXBaseSpecifiersOffset(Record[Idx++]);
Data.VBases = Reader.readCXXBaseSpecifiers(F, Record, Idx);
Reader.ReadUnresolvedSet(F, Data.Conversions, Record, Idx);
Reader.ReadUnresolvedSet(F, Data.VisibleConversions, Record, Idx);
@ -1419,6 +1419,10 @@ ASTReader::RecordLocation ASTReader::getLocalBitOffset(uint64_t GlobalOffset) {
return RecordLocation(I->second, GlobalOffset - I->second->GlobalBitOffset);
}
uint64_t ASTReader::getGlobalBitOffset(Module &M, uint32_t LocalOffset) {
return LocalOffset + M.GlobalBitOffset;
}
void ASTDeclReader::attachPreviousDecl(Decl *D, Decl *previous) {
assert(D && previous);
if (TagDecl *TD = dyn_cast<TagDecl>(D)) {

Просмотреть файл

@ -1928,7 +1928,7 @@ void ASTWriter::WriteCXXBaseSpecifiersOffsets() {
Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
unsigned BaseSpecifierOffsetAbbrev = Stream.EmitAbbrev(Abbrev);
// Write the selector offsets table.
// Write the base specifier offsets table.
Record.clear();
Record.push_back(CXX_BASE_SPECIFIER_OFFSETS);
Record.push_back(CXXBaseSpecifiersOffsets.size());
@ -2752,7 +2752,7 @@ ASTWriter::ASTWriter(llvm::BitstreamWriter &Stream)
CollectedStmts(&StmtsToEmit),
NumStatements(0), NumMacros(0), NumLexicalDeclContexts(0),
NumVisibleDeclContexts(0),
FirstCXXBaseSpecifiersID(1), NextCXXBaseSpecifiersID(1),
NextCXXBaseSpecifiersID(1),
DeclParmVarAbbrev(0), DeclContextLexicalAbbrev(0),
DeclContextVisibleLookupAbbrev(0), UpdateVisibleAbbrev(0),
DeclRefExprAbbrev(0), CharacterLiteralAbbrev(0),
@ -3077,7 +3077,6 @@ void ASTWriter::WriteASTChain(Sema &SemaRef, MemorizeStatCalls *StatCalls,
io::Emit32(Out, (*M)->BaseMacroDefinitionID);
io::Emit32(Out, (*M)->BaseSelectorID);
io::Emit32(Out, (*M)->BaseDeclID);
io::Emit32(Out, (*M)->BaseCXXBaseSpecifiersID);
io::Emit32(Out, (*M)->BaseTypeIndex);
}
}
@ -3879,7 +3878,7 @@ void ASTWriter::FlushCXXBaseSpecifiers() {
Record.clear();
// Record the offset of this base-specifier set.
unsigned Index = CXXBaseSpecifiersToWrite[I].ID - FirstCXXBaseSpecifiersID;
unsigned Index = CXXBaseSpecifiersToWrite[I].ID - 1;
if (Index == CXXBaseSpecifiersOffsets.size())
CXXBaseSpecifiersOffsets.push_back(Stream.GetCurrentBitNo());
else {
@ -3998,7 +3997,6 @@ void ASTWriter::ReaderInitialized(ASTReader *Reader) {
FirstIdentID == NextIdentID &&
FirstSelectorID == NextSelectorID &&
FirstMacroID == NextMacroID &&
FirstCXXBaseSpecifiersID == NextCXXBaseSpecifiersID &&
"Setting chain after writing has started.");
Chain = Reader;
@ -4008,13 +4006,11 @@ void ASTWriter::ReaderInitialized(ASTReader *Reader) {
FirstIdentID += Chain->getTotalNumIdentifiers();
FirstSelectorID += Chain->getTotalNumSelectors();
FirstMacroID += Chain->getTotalNumMacroDefinitions();
FirstCXXBaseSpecifiersID += Chain->getTotalNumCXXBaseSpecifiers();
NextDeclID = FirstDeclID;
NextTypeID = FirstTypeID;
NextIdentID = FirstIdentID;
NextSelectorID = FirstSelectorID;
NextMacroID = FirstMacroID;
NextCXXBaseSpecifiersID = FirstCXXBaseSpecifiersID;
}
void ASTWriter::IdentifierRead(IdentID ID, IdentifierInfo *II) {