aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/Frontend/ASTUnit.cpp3
-rw-r--r--lib/Parse/ParseObjc.cpp3
-rw-r--r--test/Index/invalid-code-rdar10451854.m15
3 files changed, 20 insertions, 1 deletions
diff --git a/lib/Frontend/ASTUnit.cpp b/lib/Frontend/ASTUnit.cpp
index 0b9c37a223..64b931f5a8 100644
--- a/lib/Frontend/ASTUnit.cpp
+++ b/lib/Frontend/ASTUnit.cpp
@@ -853,6 +853,9 @@ public:
}
void handleTopLevelDecl(Decl *D) {
+ if (!D)
+ return;
+
// FIXME: Currently ObjC method declarations are incorrectly being
// reported as top-level declarations, even though their DeclContext
// is the containing ObjC @interface/@implementation. This is a
diff --git a/lib/Parse/ParseObjc.cpp b/lib/Parse/ParseObjc.cpp
index 88044d1bc9..3cb2aaaec3 100644
--- a/lib/Parse/ParseObjc.cpp
+++ b/lib/Parse/ParseObjc.cpp
@@ -1487,7 +1487,8 @@ Parser::ParseObjCAtEndDeclaration(SourceRange atEnd) {
Actions.DefaultSynthesizeProperties(getCurScope(), ObjCImpDecl);
for (size_t i = 0; i < LateParsedObjCMethods.size(); ++i) {
Decl *D = ParseLexedObjCMethodDefs(*LateParsedObjCMethods[i]);
- DeclsInGroup.push_back(D);
+ if (D)
+ DeclsInGroup.push_back(D);
}
DeclsInGroup.push_back(ObjCImpDecl);
diff --git a/test/Index/invalid-code-rdar10451854.m b/test/Index/invalid-code-rdar10451854.m
new file mode 100644
index 0000000000..156267199b
--- /dev/null
+++ b/test/Index/invalid-code-rdar10451854.m
@@ -0,0 +1,15 @@
+struct {
+
+@implementation Foo
+
+- (void)finalize {
+ NSLog(@"bar");
+}
+
+- (NSArray *)graphics {
+}
+
+@end
+
+// Test that we don't crash
+// RUN: c-index-test -test-load-source-reparse 3 local %s