xref: /llvm-project/clang/test/ExtractAPI/typedef_chain.c (revision e05c1b46d0d3739cc48ad912dbe6e9affce05927)
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 -extract-api --pretty-sgf --product-name=TypedefChain -target arm64-apple-macosx \
6 // RUN: -x objective-c-header %t/input.h -o %t/output.json | FileCheck -allow-empty %s
7 
8 // Generator version is not consistent across test runs, normalize it.
9 // RUN: sed -e "s@\"generator\": \".*\"@\"generator\": \"?\"@g" \
10 // RUN: %t/output.json >> %t/output-normalized.json
11 // RUN: diff %t/reference.output.json %t/output-normalized.json
12 
13 // CHECK-NOT: error:
14 // CHECK-NOT: warning:
15 
16 //--- input.h
17 typedef int MyInt;
18 typedef MyInt MyIntInt;
19 typedef MyIntInt MyIntIntInt;
20 
21 //--- reference.output.json.in
22 {
23   "metadata": {
24     "formatVersion": {
25       "major": 0,
26       "minor": 5,
27       "patch": 3
28     },
29     "generator": "?"
30   },
31   "module": {
32     "name": "TypedefChain",
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   "symbols": [
48     {
49       "accessLevel": "public",
50       "declarationFragments": [
51         {
52           "kind": "keyword",
53           "spelling": "typedef"
54         },
55         {
56           "kind": "text",
57           "spelling": " "
58         },
59         {
60           "kind": "typeIdentifier",
61           "preciseIdentifier": "c:I",
62           "spelling": "int"
63         },
64         {
65           "kind": "text",
66           "spelling": " "
67         },
68         {
69           "kind": "identifier",
70           "spelling": "MyInt"
71         },
72         {
73           "kind": "text",
74           "spelling": ";"
75         }
76       ],
77       "identifier": {
78         "interfaceLanguage": "objective-c",
79         "precise": "c:input.h@T@MyInt"
80       },
81       "kind": {
82         "displayName": "Type Alias",
83         "identifier": "objective-c.typealias"
84       },
85       "location": {
86         "position": {
87           "character": 12,
88           "line": 0
89         },
90         "uri": "file://INPUT_DIR/input.h"
91       },
92       "names": {
93         "navigator": [
94           {
95             "kind": "identifier",
96             "spelling": "MyInt"
97           }
98         ],
99         "subHeading": [
100           {
101             "kind": "identifier",
102             "spelling": "MyInt"
103           }
104         ],
105         "title": "MyInt"
106       },
107       "pathComponents": [
108         "MyInt"
109       ],
110       "type": "c:I"
111     },
112     {
113       "accessLevel": "public",
114       "declarationFragments": [
115         {
116           "kind": "keyword",
117           "spelling": "typedef"
118         },
119         {
120           "kind": "text",
121           "spelling": " "
122         },
123         {
124           "kind": "typeIdentifier",
125           "preciseIdentifier": "c:input.h@T@MyInt",
126           "spelling": "MyInt"
127         },
128         {
129           "kind": "text",
130           "spelling": " "
131         },
132         {
133           "kind": "identifier",
134           "spelling": "MyIntInt"
135         },
136         {
137           "kind": "text",
138           "spelling": ";"
139         }
140       ],
141       "identifier": {
142         "interfaceLanguage": "objective-c",
143         "precise": "c:input.h@T@MyIntInt"
144       },
145       "kind": {
146         "displayName": "Type Alias",
147         "identifier": "objective-c.typealias"
148       },
149       "location": {
150         "position": {
151           "character": 14,
152           "line": 1
153         },
154         "uri": "file://INPUT_DIR/input.h"
155       },
156       "names": {
157         "navigator": [
158           {
159             "kind": "identifier",
160             "spelling": "MyIntInt"
161           }
162         ],
163         "subHeading": [
164           {
165             "kind": "identifier",
166             "spelling": "MyIntInt"
167           }
168         ],
169         "title": "MyIntInt"
170       },
171       "pathComponents": [
172         "MyIntInt"
173       ],
174       "type": "c:input.h@T@MyInt"
175     },
176     {
177       "accessLevel": "public",
178       "declarationFragments": [
179         {
180           "kind": "keyword",
181           "spelling": "typedef"
182         },
183         {
184           "kind": "text",
185           "spelling": " "
186         },
187         {
188           "kind": "typeIdentifier",
189           "preciseIdentifier": "c:input.h@T@MyIntInt",
190           "spelling": "MyIntInt"
191         },
192         {
193           "kind": "text",
194           "spelling": " "
195         },
196         {
197           "kind": "identifier",
198           "spelling": "MyIntIntInt"
199         },
200         {
201           "kind": "text",
202           "spelling": ";"
203         }
204       ],
205       "identifier": {
206         "interfaceLanguage": "objective-c",
207         "precise": "c:input.h@T@MyIntIntInt"
208       },
209       "kind": {
210         "displayName": "Type Alias",
211         "identifier": "objective-c.typealias"
212       },
213       "location": {
214         "position": {
215           "character": 17,
216           "line": 2
217         },
218         "uri": "file://INPUT_DIR/input.h"
219       },
220       "names": {
221         "navigator": [
222           {
223             "kind": "identifier",
224             "spelling": "MyIntIntInt"
225           }
226         ],
227         "subHeading": [
228           {
229             "kind": "identifier",
230             "spelling": "MyIntIntInt"
231           }
232         ],
233         "title": "MyIntIntInt"
234       },
235       "pathComponents": [
236         "MyIntIntInt"
237       ],
238       "type": "c:input.h@T@MyIntInt"
239     }
240   ]
241 }
242