From acfbbd77f80c012707c6ed5ebe1a5be35778c41d Mon Sep 17 00:00:00 2001 From: Argyrios Kyrtzidis Date: Wed, 7 Aug 2013 21:17:33 +0000 Subject: [PCH] Fix a PCH serialization crash, with invalid code related to forward enum references. The problem was that an enum without closing semicolon could be associated as a forward enum in an erroneous declaration, leading to the identifier being associated with the enum decl but without a declaration actually referencing it. This resulted in not having it serialized before serializing the identifier that is associated with. Also prevent the ASTUnit from querying the serialized DeclID for an invalid top-level decl; it may not have been serialized. rdar://14539667 llvm-svn: 187914 --- clang/lib/Serialization/ASTWriter.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'clang/lib/Serialization') diff --git a/clang/lib/Serialization/ASTWriter.cpp b/clang/lib/Serialization/ASTWriter.cpp index 142e7b12671..ad3e42bce77 100644 --- a/clang/lib/Serialization/ASTWriter.cpp +++ b/clang/lib/Serialization/ASTWriter.cpp @@ -4047,6 +4047,21 @@ void ASTWriter::WriteASTCore(Sema &SemaRef, GetDeclRef(*I); } + // Make sure all decls associated with an identifier are registered for + // serialization. + for (IdentifierTable::iterator ID = PP.getIdentifierTable().begin(), + IDEnd = PP.getIdentifierTable().end(); + ID != IDEnd; ++ID) { + const IdentifierInfo *II = ID->second; + if (!Chain || !II->isFromAST() || II->hasChangedSinceDeserialization()) { + for (IdentifierResolver::iterator D = SemaRef.IdResolver.begin(II), + DEnd = SemaRef.IdResolver.end(); + D != DEnd; ++D) { + GetDeclRef(*D); + } + } + } + // Resolve any declaration pointers within the declaration updates block. ResolveDeclUpdatesBlocks(); -- cgit v1.2.3