[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / ExtractAPI / objc_instancetype.m
blob071ebe440918aacd9f9ddc05eed518c0f1a85783
1 // RUN: rm -rf %t
2 // RUN: split-file %s %t
3 // RUN: sed -e "s@INPUT_DIR@%{/t:regex_replacement}@g" \
4 // RUN: %t/reference.output.json.in >> %t/reference.output.json
5 // RUN: %clang_cc1 -extract-api --pretty-sgf -triple arm64-apple-macosx -x objective-c-header %t/input.h -o %t/output.json -verify
7 // Generator version is not consistent across test runs, normalize it.
8 // RUN: sed -e "s@\"generator\": \".*\"@\"generator\": \"?\"@g" \
9              // RUN: %t/output.json >> %t/output-normalized.json
10 // RUN: diff %t/reference.output.json %t/output-normalized.json
13 //--- input.h
14 @interface Foo
15 - (instancetype) init;
16 - (id) reset;
17 @end
18 // expected-no-diagnostics
21 //--- reference.output.json.in
23   "metadata": {
24     "formatVersion": {
25       "major": 0,
26       "minor": 5,
27       "patch": 3
28     },
29     "generator": "?"
30   },
31   "module": {
32     "name": "",
33     "platform": {
34       "architecture": "arm64",
35       "operatingSystem": {
36         "minimumVersion": {
37           "major": 11,
38           "minor": 0,
39           "patch": 0
40         },
41         "name": "macosx"
42       },
43       "vendor": "apple"
44     }
45   },
46   "relationships": [
47     {
48       "kind": "memberOf",
49       "source": "c:objc(cs)Foo(im)init",
50       "target": "c:objc(cs)Foo",
51       "targetFallback": "Foo"
52     },
53     {
54       "kind": "memberOf",
55       "source": "c:objc(cs)Foo(im)reset",
56       "target": "c:objc(cs)Foo",
57       "targetFallback": "Foo"
58     }
59   ],
60   "symbols": [
61     {
62       "accessLevel": "public",
63       "declarationFragments": [
64         {
65           "kind": "keyword",
66           "spelling": "@interface"
67         },
68         {
69           "kind": "text",
70           "spelling": " "
71         },
72         {
73           "kind": "identifier",
74           "spelling": "Foo"
75         }
76       ],
77       "identifier": {
78         "interfaceLanguage": "objective-c",
79         "precise": "c:objc(cs)Foo"
80       },
81       "kind": {
82         "displayName": "Class",
83         "identifier": "objective-c.class"
84       },
85       "location": {
86         "position": {
87           "character": 11,
88           "line": 0
89         },
90         "uri": "file://INPUT_DIR/input.h"
91       },
92       "names": {
93         "navigator": [
94           {
95             "kind": "identifier",
96             "spelling": "Foo"
97           }
98         ],
99         "subHeading": [
100           {
101             "kind": "identifier",
102             "spelling": "Foo"
103           }
104         ],
105         "title": "Foo"
106       },
107       "pathComponents": [
108         "Foo"
109       ]
110     },
111     {
112       "accessLevel": "public",
113       "declarationFragments": [
114         {
115           "kind": "text",
116           "spelling": "- ("
117         },
118         {
119           "kind": "keyword",
120           "spelling": "instancetype"
121         },
122         {
123           "kind": "text",
124           "spelling": ") "
125         },
126         {
127           "kind": "identifier",
128           "spelling": "init"
129         },
130         {
131           "kind": "text",
132           "spelling": ";"
133         }
134       ],
135       "functionSignature": {
136         "returns": [
137           {
138             "kind": "keyword",
139             "spelling": "instancetype"
140           }
141         ]
142       },
143       "identifier": {
144         "interfaceLanguage": "objective-c",
145         "precise": "c:objc(cs)Foo(im)init"
146       },
147       "kind": {
148         "displayName": "Instance Method",
149         "identifier": "objective-c.method"
150       },
151       "location": {
152         "position": {
153           "character": 0,
154           "line": 1
155         },
156         "uri": "file://INPUT_DIR/input.h"
157       },
158       "names": {
159         "navigator": [
160           {
161             "kind": "identifier",
162             "spelling": "init"
163           }
164         ],
165         "subHeading": [
166           {
167             "kind": "text",
168             "spelling": "- "
169           },
170           {
171             "kind": "identifier",
172             "spelling": "init"
173           }
174         ],
175         "title": "init"
176       },
177       "pathComponents": [
178         "Foo",
179         "init"
180       ]
181     },
182     {
183       "accessLevel": "public",
184       "declarationFragments": [
185         {
186           "kind": "text",
187           "spelling": "- ("
188         },
189         {
190           "kind": "keyword",
191           "spelling": "id"
192         },
193         {
194           "kind": "text",
195           "spelling": ") "
196         },
197         {
198           "kind": "identifier",
199           "spelling": "reset"
200         },
201         {
202           "kind": "text",
203           "spelling": ";"
204         }
205       ],
206       "functionSignature": {
207         "returns": [
208           {
209             "kind": "keyword",
210             "spelling": "id"
211           }
212         ]
213       },
214       "identifier": {
215         "interfaceLanguage": "objective-c",
216         "precise": "c:objc(cs)Foo(im)reset"
217       },
218       "kind": {
219         "displayName": "Instance Method",
220         "identifier": "objective-c.method"
221       },
222       "location": {
223         "position": {
224           "character": 0,
225           "line": 2
226         },
227         "uri": "file://INPUT_DIR/input.h"
228       },
229       "names": {
230         "navigator": [
231           {
232             "kind": "identifier",
233             "spelling": "reset"
234           }
235         ],
236         "subHeading": [
237           {
238             "kind": "text",
239             "spelling": "- "
240           },
241           {
242             "kind": "identifier",
243             "spelling": "reset"
244           }
245         ],
246         "title": "reset"
247       },
248       "pathComponents": [
249         "Foo",
250         "reset"
251       ]
252     }
253   ]