Douglas Gregor | e90dd00 | 2010-08-24 16:15:59 +0000 | [diff] [blame] | 1 | // The line and column layout of this test is significant. Run lines |
| 2 | // are at the end. |
| 3 | typedef void (^block_t)(float f, double d); |
| 4 | void f(int (^block)(int x, int y)); |
| 5 | void g(block_t b); |
| 6 | |
| 7 | void test_f() { |
| 8 | |
| 9 | } |
| 10 | |
| 11 | @interface A |
| 12 | - method:(int (^)(int x, int y))b; |
| 13 | - method2:(block_t)b; |
| 14 | @end |
| 15 | |
| 16 | void test_A(A *a) { |
| 17 | [a method:0]; |
| 18 | } |
Douglas Gregor | 67da50e | 2010-09-08 22:47:51 +0000 | [diff] [blame] | 19 | |
| 20 | @interface B |
| 21 | - method3:(int (^)(void))b; |
| 22 | @end |
| 23 | |
| 24 | void test_B(B *b) { |
| 25 | [b method3:^int(void){ return 0; }]; |
| 26 | } |
| 27 | |
Douglas Gregor | af25cfa | 2010-10-02 23:49:58 +0000 | [diff] [blame] | 28 | @interface C |
Douglas Gregor | d793e7c | 2011-10-18 04:23:19 +0000 | [diff] [blame] | 29 | - method4:(void(^)(void))arg; |
| 30 | - method5:(void(^)())arg5; |
Douglas Gregor | af25cfa | 2010-10-02 23:49:58 +0000 | [diff] [blame] | 31 | @end |
| 32 | |
| 33 | void test_C(C *c) { |
| 34 | [c method4:^{}]; |
| 35 | } |
| 36 | |
Douglas Gregor | d793e7c | 2011-10-18 04:23:19 +0000 | [diff] [blame] | 37 | @interface D |
| 38 | - method6:(void(^)(block_t block))arg; |
| 39 | @end |
| 40 | |
| 41 | void test_D(D *d) { |
| 42 | [d method6:0]; |
| 43 | } |
| 44 | |
Douglas Gregor | 4c850f3 | 2015-07-07 06:20:22 +0000 | [diff] [blame] | 45 | @interface I1 |
| 46 | - method7:(int (^_Nullable)(int x, int y))b; |
| 47 | @end |
| 48 | void f2(int (^_Nullable block)(int x, int y)); |
| 49 | void test_f2(I1 *o) { |
| 50 | [o method7:0]; |
| 51 | } |
| 52 | |
Sam McCall | bc7ff89 | 2019-04-04 11:34:18 +0000 | [diff] [blame] | 53 | // Crash regression test. Param info for broken function types isn't available. |
| 54 | typedef UnresolvedType *(^XXX)(float); |
| 55 | @interface Foo |
| 56 | -(void) foo:(XXX)arg; |
| 57 | @end |
| 58 | void testUnresolved(Foo* f) { |
| 59 | [f foo:0]; |
| 60 | } |
| 61 | |
Douglas Gregor | e90dd00 | 2010-08-24 16:15:59 +0000 | [diff] [blame] | 62 | // RUN: c-index-test -code-completion-at=%s:8:1 %s | FileCheck -check-prefix=CHECK-CC1 %s |
Douglas Gregor | af25cfa | 2010-10-02 23:49:58 +0000 | [diff] [blame] | 63 | // CHECK-CC1: FunctionDecl:{ResultType void}{TypedText f}{LeftParen (}{Placeholder ^int(int x, int y)block}{RightParen )} (50) |
| 64 | // CHECK-CC1: FunctionDecl:{ResultType void}{TypedText g}{LeftParen (}{Placeholder ^(float f, double d)b}{RightParen )} (50) |
Douglas Gregor | e90dd00 | 2010-08-24 16:15:59 +0000 | [diff] [blame] | 65 | // RUN: c-index-test -code-completion-at=%s:17:6 %s | FileCheck -check-prefix=CHECK-CC2 %s |
Douglas Gregor | 0787b32 | 2010-10-19 00:03:23 +0000 | [diff] [blame] | 66 | // CHECK-CC2: ObjCInstanceMethodDecl:{ResultType id}{TypedText method2:}{Placeholder ^(float f, double d)b} (35) |
| 67 | // CHECK-CC2: ObjCInstanceMethodDecl:{ResultType id}{TypedText method:}{Placeholder ^int(int x, int y)b} (35) |
Douglas Gregor | 67da50e | 2010-09-08 22:47:51 +0000 | [diff] [blame] | 68 | // RUN: c-index-test -code-completion-at=%s:25:6 %s | FileCheck -check-prefix=CHECK-CC3 %s |
Douglas Gregor | 0787b32 | 2010-10-19 00:03:23 +0000 | [diff] [blame] | 69 | // CHECK-CC3: ObjCInstanceMethodDecl:{ResultType id}{TypedText method3:}{Placeholder ^int(void)b} (35) |
Douglas Gregor | 24bbc46 | 2011-02-15 22:37:09 +0000 | [diff] [blame] | 70 | // RUN: c-index-test -code-completion-at=%s:34:6 %s | FileCheck -check-prefix=CHECK-CC4 %s |
Douglas Gregor | 0787b32 | 2010-10-19 00:03:23 +0000 | [diff] [blame] | 71 | // CHECK-CC4: ObjCInstanceMethodDecl:{ResultType id}{TypedText method4:}{Placeholder ^(void)arg} (35) |
Douglas Gregor | 24bbc46 | 2011-02-15 22:37:09 +0000 | [diff] [blame] | 72 | // CHECK-CC4: ObjCInstanceMethodDecl:{ResultType id}{TypedText method5:}{Placeholder ^(void)arg5} (35) |
Douglas Gregor | 643c330 | 2010-10-18 21:34:55 +0000 | [diff] [blame] | 73 | // RUN: c-index-test -code-completion-at=%s:25:15 %s | FileCheck -check-prefix=CHECK-CC5 %s |
| 74 | // CHECK-CC5: TypedefDecl:{TypedText block_t} (50) |
| 75 | // CHECK-CC5: TypedefDecl:{TypedText Class} (50) |
| 76 | // CHECK-CC5-NOT: test_A |
| 77 | // CHECK-CC5: {TypedText union} (50) |
| 78 | |
Douglas Gregor | d793e7c | 2011-10-18 04:23:19 +0000 | [diff] [blame] | 79 | // RUN: c-index-test -code-completion-at=%s:42:6 %s | FileCheck -check-prefix=CHECK-CC6 %s |
| 80 | // CHECK-CC6: ObjCInstanceMethodDecl:{ResultType id}{TypedText method6:}{Placeholder ^(block_t block)arg} (35) |
| 81 | |
Douglas Gregor | 4c850f3 | 2015-07-07 06:20:22 +0000 | [diff] [blame] | 82 | // RUN: c-index-test -code-completion-at=%s:50:1 %s | FileCheck -check-prefix=CHECK-CC7 %s |
| 83 | // CHECK-CC7: FunctionDecl:{ResultType void}{TypedText f2}{LeftParen (}{Placeholder ^int(int x, int y)block}{RightParen )} (50) |
| 84 | // RUN: c-index-test -code-completion-at=%s:50:6 %s | FileCheck -check-prefix=CHECK-CC8 %s |
| 85 | // CHECK-CC8: ObjCInstanceMethodDecl:{ResultType id}{TypedText method7:}{Placeholder ^int(int x, int y)b} (35) |
Sam McCall | bc7ff89 | 2019-04-04 11:34:18 +0000 | [diff] [blame] | 86 | |
| 87 | // RUN: c-index-test -code-completion-at=%s:59:6 %s | FileCheck -check-prefix=CHECK-CC9 %s |
| 88 | // CHECK-CC9: ObjCInstanceMethodDecl:{ResultType void}{TypedText foo:}{Placeholder ^int *(int)arg} (35) |