]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - test/Index/complete-block-property-assignment.m
Vendor import of clang trunk r351319 (just before the release_80 branch
[FreeBSD/FreeBSD.git] / test / Index / complete-block-property-assignment.m
1 // Note: the run lines follow their respective tests, since line/column
2 // matter in this test.
3
4 // rdar://28481726
5
6 void func(int x);
7 typedef int Foo;
8 typedef void (^FooBlock)(Foo *someParameter);
9
10 @interface Obj
11 @property (readwrite, nonatomic, copy) void (^onAction)(Obj *object);
12 @property (readwrite, nonatomic) int foo;
13 @end
14
15 @interface Test : Obj
16 @property (readwrite, nonatomic, copy) FooBlock onEventHandler;
17 @property (readonly, nonatomic, copy) void (^onReadonly)(int *someParameter);
18 @property (readwrite, nonatomic, copy) int (^processEvent)(int eventCode);
19 @property (readonly, nonatomic, strong) Obj *obj;
20 @end
21
22 @implementation Test
23
24 #define SELFY self
25
26 - (void)test {
27   self.foo = 2;
28   [self takeInt: 2]; self.foo = 2;
29   /* Comment */ self.foo = 2;
30   SELFY.foo = 2
31 }
32
33 // RUN: c-index-test -code-completion-at=%s:27:8 %s | FileCheck -check-prefix=CHECK-CC1 %s
34 // RUN: c-index-test -code-completion-at=%s:28:27 %s | FileCheck -check-prefix=CHECK-CC1 %s
35 // RUN: c-index-test -code-completion-at=%s:29:22 %s | FileCheck -check-prefix=CHECK-CC1 %s
36 // RUN: c-index-test -code-completion-at=%s:30:9 %s | FileCheck -check-prefix=CHECK-CC1 %s
37 // CHECK-CC1: ObjCPropertyDecl:{ResultType int}{TypedText foo} (37)
38 // CHECK-CC1-NEXT: ObjCPropertyDecl:{ResultType Obj *}{TypedText obj} (35)
39 // CHECK-CC1-NEXT: ObjCPropertyDecl:{ResultType void}{TypedText onAction}{LeftParen (}{Placeholder Obj *object}{RightParen )} (37)
40 // CHECK-CC1-NEXT: ObjCPropertyDecl:{ResultType void (^)(Obj *)}{TypedText onAction}{Equal  = }{Placeholder ^(Obj *object)} (40)
41 // CHECK-CC1-NEXT: ObjCPropertyDecl:{ResultType void}{TypedText onEventHandler}{LeftParen (}{Placeholder Foo *someParameter}{RightParen )} (35)
42 // CHECK-CC1-NEXT: ObjCPropertyDecl:{ResultType FooBlock}{TypedText onEventHandler}{Equal  = }{Placeholder ^(Foo *someParameter)} (38)
43 // CHECK-CC1-NEXT: ObjCPropertyDecl:{ResultType void}{TypedText onReadonly}{LeftParen (}{Placeholder int *someParameter}{RightParen )} (35)
44 // CHECK-CC1-NEXT: ObjCPropertyDecl:{ResultType int}{TypedText processEvent}{LeftParen (}{Placeholder int eventCode}{RightParen )} (35)
45 // CHECK-CC1-NEXT: ObjCPropertyDecl:{ResultType int (^)(int)}{TypedText processEvent}{Equal  = }{Placeholder ^int(int eventCode)} (32)
46
47 - (void) takeInt:(int)x { }
48
49 - (int) testFailures {
50   (self.foo);
51   int x = self.foo;
52   [self takeInt: self.foo];
53   if (self.foo) {
54     func(self.foo);
55   }
56   return self.foo;
57 }
58
59 // RUN: c-index-test -code-completion-at=%s:50:9 %s | FileCheck -check-prefix=CHECK-NO %s
60 // RUN: c-index-test -code-completion-at=%s:51:16 %s | FileCheck -check-prefix=CHECK-NO %s
61 // RUN: c-index-test -code-completion-at=%s:52:23 %s | FileCheck -check-prefix=CHECK-NO %s
62 // RUN: c-index-test -code-completion-at=%s:53:12 %s | FileCheck -check-prefix=CHECK-NO %s
63 // RUN: c-index-test -code-completion-at=%s:56:15 %s | FileCheck -check-prefix=CHECK-NO %s
64 // CHECK-NO: ObjCPropertyDecl:{ResultType int}{TypedText foo} (37)
65 // CHECK-NO-NEXT: ObjCPropertyDecl:{ResultType Obj *}{TypedText obj} (35)
66 // CHECK-NO-NEXT: ObjCPropertyDecl:{ResultType void (^)(Obj *)}{TypedText onAction} (37)
67 // CHECK-NO-NEXT: ObjCPropertyDecl:{ResultType FooBlock}{TypedText onEventHandler} (35)
68 // CHECK-NO-NEXT: ObjCPropertyDecl:{ResultType void (^)(int *)}{TypedText onReadonly} (35)
69 // CHECK-NO-NEXT: ObjCPropertyDecl:{ResultType int (^)(int)}{TypedText processEvent} (35)
70
71 // RUN: c-index-test -code-completion-at=%s:54:15 %s | FileCheck -check-prefix=CHECK-NO1 %s
72 // CHECK-NO1: ObjCPropertyDecl:{ResultType int}{TypedText foo} (37)
73 // CHECK-NO1-NEXT: ObjCPropertyDecl:{ResultType Obj *}{TypedText obj} (35)
74 // CHECK-NO1-NEXT: ObjCPropertyDecl:{ResultType void (^)(Obj *)}{TypedText onAction} (37)
75 // CHECK-NO1-NEXT: ObjCPropertyDecl:{ResultType FooBlock}{TypedText onEventHandler} (35)
76 // CHECK-NO1-NEXT: ObjCPropertyDecl:{ResultType void (^)(int *)}{TypedText onReadonly} (35)
77 // CHECK-NO1-NEXT: ObjCPropertyDecl:{ResultType int (^)(int)}{TypedText processEvent} (35)
78 // CHECK-NO1-NEXT: OverloadCandidate:{ResultType void}{Text func}{LeftParen (}{CurrentParameter int x}{RightParen )} (1)
79 @end