summaryrefslogtreecommitdiffstats
path: root/clang/lib/Frontend
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2013-08-07 21:17:33 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2013-08-07 21:17:33 +0000
commitacfbbd77f80c012707c6ed5ebe1a5be35778c41d (patch)
treefb6b44fc9f6c1c7f08e92f47e9ed74832b3c836a /clang/lib/Frontend
parent7af8baf678f7e9590f80d82327676aa3b43ba7a7 (diff)
downloadbcm5719-llvm-acfbbd77f80c012707c6ed5ebe1a5be35778c41d.tar.gz
bcm5719-llvm-acfbbd77f80c012707c6ed5ebe1a5be35778c41d.zip
[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
Diffstat (limited to 'clang/lib/Frontend')
-rw-r--r--clang/lib/Frontend/ASTUnit.cpp10
1 files changed, 7 insertions, 3 deletions
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();
}
OpenPOWER on IntegriCloud