diff options
Diffstat (limited to 'lib/Serialization/ASTWriter.cpp')
-rw-r--r-- | lib/Serialization/ASTWriter.cpp | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/lib/Serialization/ASTWriter.cpp b/lib/Serialization/ASTWriter.cpp index 52578599ea..2afdc32db0 100644 --- a/lib/Serialization/ASTWriter.cpp +++ b/lib/Serialization/ASTWriter.cpp @@ -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; } |