Don't seed the ASTWriter's declaration -> ID mapping with the IDs of

each deserialized declaration, since that information is already
available in each declaration.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@147619 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Douglas Gregor 2012-01-05 22:33:30 +00:00
Родитель b6b60c1521
Коммит 1c7946a9fb
3 изменённых файлов: 23 добавлений и 11 удалений

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

@ -668,7 +668,6 @@ public:
void ReaderInitialized(ASTReader *Reader);
void IdentifierRead(serialization::IdentID ID, IdentifierInfo *II);
void TypeRead(serialization::TypeIdx Idx, QualType T);
void DeclRead(serialization::DeclID ID, const Decl *D);
void SelectorRead(serialization::SelectorID ID, Selector Sel);
void MacroDefinitionRead(serialization::PreprocessedEntityID ID,
MacroDefinition *MD);

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

@ -3729,6 +3729,12 @@ DeclID ASTWriter::GetDeclRef(const Decl *D) {
if (D == 0) {
return 0;
}
// If D comes from an AST file, its declaration ID is already known and
// fixed.
if (D->isFromASTFile())
return D->getGlobalID();
assert(!(reinterpret_cast<uintptr_t>(D) & 0x01) && "Invalid decl pointer");
DeclID &ID = DeclIDs[D];
if (ID == 0) {
@ -3745,6 +3751,11 @@ DeclID ASTWriter::getDeclID(const Decl *D) {
if (D == 0)
return 0;
// If D comes from an AST file, its declaration ID is already known and
// fixed.
if (D->isFromASTFile())
return D->getGlobalID();
assert(DeclIDs.find(D) != DeclIDs.end() && "Declaration not emitted!");
return DeclIDs[D];
}
@ -4273,10 +4284,6 @@ void ASTWriter::TypeRead(TypeIdx Idx, QualType T) {
StoredIdx = Idx;
}
void ASTWriter::DeclRead(DeclID ID, const Decl *D) {
DeclIDs[D] = ID;
}
void ASTWriter::SelectorRead(SelectorID ID, Selector S) {
SelectorIDs[S] = ID;
}

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

@ -1679,12 +1679,18 @@ void ASTWriter::WriteDecl(ASTContext &Context, Decl *D) {
VisibleOffset = WriteDeclContextVisibleBlock(Context, DC);
}
// Determine the ID for this declaration
serialization::DeclID &IDR = DeclIDs[D];
if (IDR == 0)
IDR = NextDeclID++;
serialization::DeclID ID = IDR;
// Determine the ID for this declaration.
serialization::DeclID ID;
if (D->isFromASTFile())
ID = getDeclID(D);
else {
serialization::DeclID &IDR = DeclIDs[D];
if (IDR == 0)
IDR = NextDeclID++;
ID= IDR;
}
if (ID < FirstDeclID) {
// We're replacing a decl in a previous file.
ReplacedDecls.push_back(ReplacedDeclInfo(ID, Stream.GetCurrentBitNo(),