summaryrefslogtreecommitdiffstats
path: root/test/Parser
diff options
context:
space:
mode:
authorAlex Lorenz <arphaman@gmail.com>2017-06-19 17:53:21 +0000
committerAlex Lorenz <arphaman@gmail.com>2017-06-19 17:53:21 +0000
commit2a29f3b4c8d5c9042103398f643bf8b32a5d9974 (patch)
treeb14ce0a327d8f6333fa258fff1e0d1bc1013e571 /test/Parser
parent1b12bf4092573db0add5649e9fbe9925a141c328 (diff)
[Parser][ObjC] Use an artificial EOF token while parsing lexed ObjC methods
This change avoid a crash that occurred when skipping to EOF while parsing an ObjC interface/implementation. rdar://31963299 Differential Revision: https://reviews.llvm.org/D34185 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@305719 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Parser')
-rw-r--r--test/Parser/objc-at-implementation-eof-crash.m21
-rw-r--r--test/Parser/objc-at-interface-eof-crash.m21
2 files changed, 42 insertions, 0 deletions
diff --git a/test/Parser/objc-at-implementation-eof-crash.m b/test/Parser/objc-at-implementation-eof-crash.m
new file mode 100644
index 0000000000..01469ecb11
--- /dev/null
+++ b/test/Parser/objc-at-implementation-eof-crash.m
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -verify -Wno-objc-root-class %s
+
+@interface ClassA
+
+- (void)fileExistsAtPath:(int)x;
+
+@end
+
+@interface ClassB
+
+@end
+
+@implementation ClassB // expected-note {{implementation started here}}
+
+- (void) method:(ClassA *)mgr { // expected-note {{to match this '{'}}
+ mgr fileExistsAtPath:0
+} // expected-error {{expected ']'}}
+
+@implementation ClassC // expected-error {{missing '@end'}} // expected-error {{expected '}'}} // expected-warning {{cannot find interface declaration for 'ClassC'}}
+
+@end
diff --git a/test/Parser/objc-at-interface-eof-crash.m b/test/Parser/objc-at-interface-eof-crash.m
new file mode 100644
index 0000000000..7776838c9e
--- /dev/null
+++ b/test/Parser/objc-at-interface-eof-crash.m
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -verify -Wno-objc-root-class %s
+
+@interface ClassA
+
+- (void)fileExistsAtPath:(int)x;
+
+@end
+
+@interface ClassB
+
+@end
+
+@implementation ClassB // expected-note {{implementation started here}}
+
+- (void) method:(ClassA *)mgr { // expected-note {{to match this '{'}}
+ mgr fileExistsAtPath:0
+} // expected-error {{expected ']'}}
+
+@interface ClassC // expected-error {{missing '@end'}} // expected-error {{expected '}'}}
+
+@end