xref: /llvm-project/clang/test/ExtractAPI/language.c (revision e05c1b46d0d3739cc48ad912dbe6e9affce05927)
115bf0e56SZixu Wang // RUN: rm -rf %t
215bf0e56SZixu Wang // RUN: split-file %s %t
3e08c4354SZixu Wang // RUN: sed -e "s@INPUT_DIR@%{/t:regex_replacement}@g" \
4e08c4354SZixu Wang // RUN: %t/c.reference.output.json.in >> %t/c.reference.output.json
5e08c4354SZixu Wang // RUN: sed -e "s@INPUT_DIR@%{/t:regex_replacement}@g" \
6e08c4354SZixu Wang // RUN: %t/objc.reference.output.json.in >> %t/objc.reference.output.json
7789a5bbbSDaniel Grumberg // RUN: sed -e "s@INPUT_DIR@%{/t:regex_replacement}@g" \
8789a5bbbSDaniel Grumberg // RUN: %t/objcpp.reference.output.json.in >> %t/objcpp.reference.output.json
915bf0e56SZixu Wang 
10*e05c1b46SDaniel Grumberg // RUN: %clang_cc1 -extract-api --pretty-sgf -x c-header -triple arm64-apple-macosx \
1115bf0e56SZixu Wang // RUN: %t/c.h -o %t/c.output.json | FileCheck -allow-empty %s
12*e05c1b46SDaniel Grumberg // RUN: %clang_cc1 -extract-api --pretty-sgf -x objective-c-header -triple arm64-apple-macosx \
1315bf0e56SZixu Wang // RUN: %t/objc.h -o %t/objc.output.json | FileCheck -allow-empty %s
14*e05c1b46SDaniel Grumberg // RUN: %clang_cc1 -extract-api --pretty-sgf -x objective-c++-header -triple arm64-apple-macosx \
15789a5bbbSDaniel Grumberg // RUN: %t/objcpp.h -o %t/objcpp.output.json | FileCheck -allow-empty %s
1615bf0e56SZixu Wang 
1715bf0e56SZixu Wang // Generator version is not consistent across test runs, normalize it.
1815bf0e56SZixu Wang // RUN: sed -e "s@\"generator\": \".*\"@\"generator\": \"?\"@g" \
1915bf0e56SZixu Wang // RUN: %t/c.output.json >> %t/c.output-normalized.json
2015bf0e56SZixu Wang // RUN: sed -e "s@\"generator\": \".*\"@\"generator\": \"?\"@g" \
2115bf0e56SZixu Wang // RUN: %t/objc.output.json >> %t/objc.output-normalized.json
22789a5bbbSDaniel Grumberg // RUN: sed -e "s@\"generator\": \".*\"@\"generator\": \"?\"@g" \
23789a5bbbSDaniel Grumberg // RUN: %t/objcpp.output.json >> %t/objcpp.output-normalized.json
2415bf0e56SZixu Wang 
2515bf0e56SZixu Wang // RUN: diff %t/c.reference.output.json %t/c.output-normalized.json
2615bf0e56SZixu Wang // RUN: diff %t/objc.reference.output.json %t/objc.output-normalized.json
27789a5bbbSDaniel Grumberg // RUN: diff %t/objcpp.reference.output.json %t/objcpp.output-normalized.json
2815bf0e56SZixu Wang 
2915bf0e56SZixu Wang // CHECK-NOT: error:
3015bf0e56SZixu Wang // CHECK-NOT: warning:
3115bf0e56SZixu Wang 
3215bf0e56SZixu Wang //--- c.h
3315bf0e56SZixu Wang char c;
34789a5bbbSDaniel Grumberg ///expected-no-diagnostics
3515bf0e56SZixu Wang 
3615bf0e56SZixu Wang //--- objc.h
3715bf0e56SZixu Wang char objc;
38789a5bbbSDaniel Grumberg ///expected-no-diagnostics
39789a5bbbSDaniel Grumberg 
40789a5bbbSDaniel Grumberg //--- objcpp.h
41789a5bbbSDaniel Grumberg char objcpp;
42789a5bbbSDaniel Grumberg ///expected-no-diagnostics
4315bf0e56SZixu Wang 
4415bf0e56SZixu Wang //--- c.reference.output.json.in
4515bf0e56SZixu Wang {
4615bf0e56SZixu Wang   "metadata": {
4715bf0e56SZixu Wang     "formatVersion": {
4815bf0e56SZixu Wang       "major": 0,
4915bf0e56SZixu Wang       "minor": 5,
5015bf0e56SZixu Wang       "patch": 3
5115bf0e56SZixu Wang     },
5215bf0e56SZixu Wang     "generator": "?"
5315bf0e56SZixu Wang   },
5415bf0e56SZixu Wang   "module": {
5515bf0e56SZixu Wang     "name": "",
5615bf0e56SZixu Wang     "platform": {
5715bf0e56SZixu Wang       "architecture": "arm64",
5815bf0e56SZixu Wang       "operatingSystem": {
5915bf0e56SZixu Wang         "minimumVersion": {
6015bf0e56SZixu Wang           "major": 11,
6115bf0e56SZixu Wang           "minor": 0,
6215bf0e56SZixu Wang           "patch": 0
6315bf0e56SZixu Wang         },
6415bf0e56SZixu Wang         "name": "macosx"
6515bf0e56SZixu Wang       },
6615bf0e56SZixu Wang       "vendor": "apple"
6715bf0e56SZixu Wang     }
6815bf0e56SZixu Wang   },
6928d79314SDaniel Grumberg   "relationships": [],
7015bf0e56SZixu Wang   "symbols": [
7115bf0e56SZixu Wang     {
7228d79314SDaniel Grumberg       "accessLevel": "public",
7315bf0e56SZixu Wang       "declarationFragments": [
7415bf0e56SZixu Wang         {
7515bf0e56SZixu Wang           "kind": "typeIdentifier",
7615bf0e56SZixu Wang           "preciseIdentifier": "c:C",
7715bf0e56SZixu Wang           "spelling": "char"
7815bf0e56SZixu Wang         },
7915bf0e56SZixu Wang         {
8015bf0e56SZixu Wang           "kind": "text",
8115bf0e56SZixu Wang           "spelling": " "
8215bf0e56SZixu Wang         },
8315bf0e56SZixu Wang         {
8415bf0e56SZixu Wang           "kind": "identifier",
8515bf0e56SZixu Wang           "spelling": "c"
86422bcd10SErick Velez         },
87422bcd10SErick Velez         {
88422bcd10SErick Velez           "kind": "text",
89422bcd10SErick Velez           "spelling": ";"
9015bf0e56SZixu Wang         }
9115bf0e56SZixu Wang       ],
9215bf0e56SZixu Wang       "identifier": {
9315bf0e56SZixu Wang         "interfaceLanguage": "c",
9415bf0e56SZixu Wang         "precise": "c:@c"
9515bf0e56SZixu Wang       },
9615bf0e56SZixu Wang       "kind": {
9715bf0e56SZixu Wang         "displayName": "Global Variable",
9815bf0e56SZixu Wang         "identifier": "c.var"
9915bf0e56SZixu Wang       },
10015bf0e56SZixu Wang       "location": {
10128d79314SDaniel Grumberg         "position": {
10263537872SQuietMisdreavus           "character": 5,
10363537872SQuietMisdreavus           "line": 0
10428d79314SDaniel Grumberg         },
10515bf0e56SZixu Wang         "uri": "file://INPUT_DIR/c.h"
10615bf0e56SZixu Wang       },
10715bf0e56SZixu Wang       "names": {
10880ae3665SDaniel Grumberg         "navigator": [
10980ae3665SDaniel Grumberg           {
11080ae3665SDaniel Grumberg             "kind": "identifier",
11180ae3665SDaniel Grumberg             "spelling": "c"
11280ae3665SDaniel Grumberg           }
11380ae3665SDaniel Grumberg         ],
11415bf0e56SZixu Wang         "subHeading": [
11515bf0e56SZixu Wang           {
11615bf0e56SZixu Wang             "kind": "identifier",
11715bf0e56SZixu Wang             "spelling": "c"
11815bf0e56SZixu Wang           }
11915bf0e56SZixu Wang         ],
12015bf0e56SZixu Wang         "title": "c"
12128d79314SDaniel Grumberg       },
12228d79314SDaniel Grumberg       "pathComponents": [
12328d79314SDaniel Grumberg         "c"
12428d79314SDaniel Grumberg       ]
12515bf0e56SZixu Wang     }
12615bf0e56SZixu Wang   ]
12715bf0e56SZixu Wang }
12815bf0e56SZixu Wang //--- objc.reference.output.json.in
12915bf0e56SZixu Wang {
13015bf0e56SZixu Wang   "metadata": {
13115bf0e56SZixu Wang     "formatVersion": {
13215bf0e56SZixu Wang       "major": 0,
13315bf0e56SZixu Wang       "minor": 5,
13415bf0e56SZixu Wang       "patch": 3
13515bf0e56SZixu Wang     },
13615bf0e56SZixu Wang     "generator": "?"
13715bf0e56SZixu Wang   },
13815bf0e56SZixu Wang   "module": {
13915bf0e56SZixu Wang     "name": "",
14015bf0e56SZixu Wang     "platform": {
14115bf0e56SZixu Wang       "architecture": "arm64",
14215bf0e56SZixu Wang       "operatingSystem": {
14315bf0e56SZixu Wang         "minimumVersion": {
14415bf0e56SZixu Wang           "major": 11,
14515bf0e56SZixu Wang           "minor": 0,
14615bf0e56SZixu Wang           "patch": 0
14715bf0e56SZixu Wang         },
14815bf0e56SZixu Wang         "name": "macosx"
14915bf0e56SZixu Wang       },
15015bf0e56SZixu Wang       "vendor": "apple"
15115bf0e56SZixu Wang     }
15215bf0e56SZixu Wang   },
15328d79314SDaniel Grumberg   "relationships": [],
15415bf0e56SZixu Wang   "symbols": [
15515bf0e56SZixu Wang     {
15628d79314SDaniel Grumberg       "accessLevel": "public",
15715bf0e56SZixu Wang       "declarationFragments": [
15815bf0e56SZixu Wang         {
15915bf0e56SZixu Wang           "kind": "typeIdentifier",
16015bf0e56SZixu Wang           "preciseIdentifier": "c:C",
16115bf0e56SZixu Wang           "spelling": "char"
16215bf0e56SZixu Wang         },
16315bf0e56SZixu Wang         {
16415bf0e56SZixu Wang           "kind": "text",
16515bf0e56SZixu Wang           "spelling": " "
16615bf0e56SZixu Wang         },
16715bf0e56SZixu Wang         {
16815bf0e56SZixu Wang           "kind": "identifier",
16915bf0e56SZixu Wang           "spelling": "objc"
170422bcd10SErick Velez         },
171422bcd10SErick Velez         {
172422bcd10SErick Velez           "kind": "text",
173422bcd10SErick Velez           "spelling": ";"
17415bf0e56SZixu Wang         }
17515bf0e56SZixu Wang       ],
17615bf0e56SZixu Wang       "identifier": {
17715bf0e56SZixu Wang         "interfaceLanguage": "objective-c",
17815bf0e56SZixu Wang         "precise": "c:@objc"
17915bf0e56SZixu Wang       },
18015bf0e56SZixu Wang       "kind": {
18115bf0e56SZixu Wang         "displayName": "Global Variable",
18215bf0e56SZixu Wang         "identifier": "objective-c.var"
18315bf0e56SZixu Wang       },
18415bf0e56SZixu Wang       "location": {
18528d79314SDaniel Grumberg         "position": {
18663537872SQuietMisdreavus           "character": 5,
18763537872SQuietMisdreavus           "line": 0
18828d79314SDaniel Grumberg         },
18915bf0e56SZixu Wang         "uri": "file://INPUT_DIR/objc.h"
19015bf0e56SZixu Wang       },
19115bf0e56SZixu Wang       "names": {
19280ae3665SDaniel Grumberg         "navigator": [
19380ae3665SDaniel Grumberg           {
19480ae3665SDaniel Grumberg             "kind": "identifier",
19580ae3665SDaniel Grumberg             "spelling": "objc"
19680ae3665SDaniel Grumberg           }
19780ae3665SDaniel Grumberg         ],
19815bf0e56SZixu Wang         "subHeading": [
19915bf0e56SZixu Wang           {
20015bf0e56SZixu Wang             "kind": "identifier",
20115bf0e56SZixu Wang             "spelling": "objc"
20215bf0e56SZixu Wang           }
20315bf0e56SZixu Wang         ],
20415bf0e56SZixu Wang         "title": "objc"
20528d79314SDaniel Grumberg       },
20628d79314SDaniel Grumberg       "pathComponents": [
20728d79314SDaniel Grumberg         "objc"
20828d79314SDaniel Grumberg       ]
20915bf0e56SZixu Wang     }
21015bf0e56SZixu Wang   ]
21115bf0e56SZixu Wang }
212789a5bbbSDaniel Grumberg //--- objcpp.reference.output.json.in
213789a5bbbSDaniel Grumberg {
214789a5bbbSDaniel Grumberg   "metadata": {
215789a5bbbSDaniel Grumberg     "formatVersion": {
216789a5bbbSDaniel Grumberg       "major": 0,
217789a5bbbSDaniel Grumberg       "minor": 5,
218789a5bbbSDaniel Grumberg       "patch": 3
219789a5bbbSDaniel Grumberg     },
220789a5bbbSDaniel Grumberg     "generator": "?"
221789a5bbbSDaniel Grumberg   },
222789a5bbbSDaniel Grumberg   "module": {
223789a5bbbSDaniel Grumberg     "name": "",
224789a5bbbSDaniel Grumberg     "platform": {
225789a5bbbSDaniel Grumberg       "architecture": "arm64",
226789a5bbbSDaniel Grumberg       "operatingSystem": {
227789a5bbbSDaniel Grumberg         "minimumVersion": {
228789a5bbbSDaniel Grumberg           "major": 11,
229789a5bbbSDaniel Grumberg           "minor": 0,
230789a5bbbSDaniel Grumberg           "patch": 0
231789a5bbbSDaniel Grumberg         },
232789a5bbbSDaniel Grumberg         "name": "macosx"
233789a5bbbSDaniel Grumberg       },
234789a5bbbSDaniel Grumberg       "vendor": "apple"
235789a5bbbSDaniel Grumberg     }
236789a5bbbSDaniel Grumberg   },
237789a5bbbSDaniel Grumberg   "relationships": [],
238789a5bbbSDaniel Grumberg   "symbols": [
239789a5bbbSDaniel Grumberg     {
240789a5bbbSDaniel Grumberg       "accessLevel": "public",
241789a5bbbSDaniel Grumberg       "declarationFragments": [
242789a5bbbSDaniel Grumberg         {
243789a5bbbSDaniel Grumberg           "kind": "typeIdentifier",
244789a5bbbSDaniel Grumberg           "preciseIdentifier": "c:C",
245789a5bbbSDaniel Grumberg           "spelling": "char"
246789a5bbbSDaniel Grumberg         },
247789a5bbbSDaniel Grumberg         {
248789a5bbbSDaniel Grumberg           "kind": "text",
249789a5bbbSDaniel Grumberg           "spelling": " "
250789a5bbbSDaniel Grumberg         },
251789a5bbbSDaniel Grumberg         {
252789a5bbbSDaniel Grumberg           "kind": "identifier",
253789a5bbbSDaniel Grumberg           "spelling": "objcpp"
254789a5bbbSDaniel Grumberg         },
255789a5bbbSDaniel Grumberg         {
256789a5bbbSDaniel Grumberg           "kind": "text",
257789a5bbbSDaniel Grumberg           "spelling": ";"
258789a5bbbSDaniel Grumberg         }
259789a5bbbSDaniel Grumberg       ],
260789a5bbbSDaniel Grumberg       "identifier": {
261789a5bbbSDaniel Grumberg         "interfaceLanguage": "objective-c++",
262789a5bbbSDaniel Grumberg         "precise": "c:@objcpp"
263789a5bbbSDaniel Grumberg       },
264789a5bbbSDaniel Grumberg       "kind": {
265789a5bbbSDaniel Grumberg         "displayName": "Global Variable",
266789a5bbbSDaniel Grumberg         "identifier": "objective-c++.var"
267789a5bbbSDaniel Grumberg       },
268789a5bbbSDaniel Grumberg       "location": {
269789a5bbbSDaniel Grumberg         "position": {
270789a5bbbSDaniel Grumberg           "character": 5,
271789a5bbbSDaniel Grumberg           "line": 0
272789a5bbbSDaniel Grumberg         },
273789a5bbbSDaniel Grumberg         "uri": "file://INPUT_DIR/objcpp.h"
274789a5bbbSDaniel Grumberg       },
275789a5bbbSDaniel Grumberg       "names": {
276789a5bbbSDaniel Grumberg         "navigator": [
277789a5bbbSDaniel Grumberg           {
278789a5bbbSDaniel Grumberg             "kind": "identifier",
279789a5bbbSDaniel Grumberg             "spelling": "objcpp"
280789a5bbbSDaniel Grumberg           }
281789a5bbbSDaniel Grumberg         ],
282789a5bbbSDaniel Grumberg         "subHeading": [
283789a5bbbSDaniel Grumberg           {
284789a5bbbSDaniel Grumberg             "kind": "identifier",
285789a5bbbSDaniel Grumberg             "spelling": "objcpp"
286789a5bbbSDaniel Grumberg           }
287789a5bbbSDaniel Grumberg         ],
288789a5bbbSDaniel Grumberg         "title": "objcpp"
289789a5bbbSDaniel Grumberg       },
290789a5bbbSDaniel Grumberg       "pathComponents": [
291789a5bbbSDaniel Grumberg         "objcpp"
292789a5bbbSDaniel Grumberg       ]
293789a5bbbSDaniel Grumberg     }
294789a5bbbSDaniel Grumberg   ]
295789a5bbbSDaniel Grumberg }
296