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/Frontend/ASTUnit.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'clang/lib/Frontend') diff --git a/clang/lib/Frontend/ASTUnit.cpp b/clang/lib/Frontend/ASTUnit.cpp index 72f5d4c18e0..9080349c956 100644 --- a/clang/lib/Frontend/ASTUnit.cpp +++ b/clang/lib/Frontend/ASTUnit.cpp @@ -1030,9 +1030,13 @@ public: // parsing into declaration IDs in the precompiled // preamble. This will allow us to deserialize those top-level // declarations when requested. - for (unsigned I = 0, N = TopLevelDecls.size(); I != N; ++I) - Unit.addTopLevelDeclFromPreamble( - getWriter().getDeclID(TopLevelDecls[I])); + for (unsigned I = 0, N = TopLevelDecls.size(); I != N; ++I) { + Decl *D = TopLevelDecls[I]; + // Invalid top-level decls may not have been serialized. + if (D->isInvalidDecl()) + continue; + Unit.addTopLevelDeclFromPreamble(getWriter().getDeclID(D)); + } Action->setHasEmittedPreamblePCH(); } -- cgit v1.2.3