xref: /llvm-project/clang/test/ExtractAPI/function_noexcepts.cpp (revision 2bcbe40f8a1c6cc9a256711261d8aa8fde50f7b3)
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 \
6 // RUN:   -x c++-header %t/input.h -o %t/output.json -verify
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 //--- input.h
14 void getFoo() noexcept;
15 
16 void getBar() noexcept(true);
17 
18 void getFooBar() noexcept(false);
19 /// expected-no-diagnostics
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": "",
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": "typeIdentifier",
53           "preciseIdentifier": "c:v",
54           "spelling": "void"
55         },
56         {
57           "kind": "text",
58           "spelling": " "
59         },
60         {
61           "kind": "identifier",
62           "spelling": "getFoo"
63         },
64         {
65           "kind": "text",
66           "spelling": "() "
67         },
68         {
69           "kind": "keyword",
70           "spelling": "noexcept"
71         },
72         {
73           "kind": "text",
74           "spelling": ";"
75         }
76       ],
77       "functionSignature": {
78         "returns": [
79           {
80             "kind": "typeIdentifier",
81             "preciseIdentifier": "c:v",
82             "spelling": "void"
83           }
84         ]
85       },
86       "identifier": {
87         "interfaceLanguage": "c++",
88         "precise": "c:@F@getFoo#"
89       },
90       "kind": {
91         "displayName": "Function",
92         "identifier": "c++.func"
93       },
94       "location": {
95         "position": {
96           "character": 5,
97           "line": 0
98         },
99         "uri": "file://INPUT_DIR/input.h"
100       },
101       "names": {
102         "navigator": [
103           {
104             "kind": "identifier",
105             "spelling": "getFoo"
106           }
107         ],
108         "subHeading": [
109           {
110             "kind": "identifier",
111             "spelling": "getFoo"
112           }
113         ],
114         "title": "getFoo"
115       },
116       "pathComponents": [
117         "getFoo"
118       ]
119     },
120     {
121       "accessLevel": "public",
122       "declarationFragments": [
123         {
124           "kind": "typeIdentifier",
125           "preciseIdentifier": "c:v",
126           "spelling": "void"
127         },
128         {
129           "kind": "text",
130           "spelling": " "
131         },
132         {
133           "kind": "identifier",
134           "spelling": "getBar"
135         },
136         {
137           "kind": "text",
138           "spelling": "() "
139         },
140         {
141           "kind": "keyword",
142           "spelling": "noexcept"
143         },
144         {
145           "kind": "text",
146           "spelling": "("
147         },
148         {
149           "kind": "keyword",
150           "spelling": "true"
151         },
152         {
153           "kind": "text",
154           "spelling": ");"
155         }
156       ],
157       "functionSignature": {
158         "returns": [
159           {
160             "kind": "typeIdentifier",
161             "preciseIdentifier": "c:v",
162             "spelling": "void"
163           }
164         ]
165       },
166       "identifier": {
167         "interfaceLanguage": "c++",
168         "precise": "c:@F@getBar#"
169       },
170       "kind": {
171         "displayName": "Function",
172         "identifier": "c++.func"
173       },
174       "location": {
175         "position": {
176           "character": 5,
177           "line": 2
178         },
179         "uri": "file://INPUT_DIR/input.h"
180       },
181       "names": {
182         "navigator": [
183           {
184             "kind": "identifier",
185             "spelling": "getBar"
186           }
187         ],
188         "subHeading": [
189           {
190             "kind": "identifier",
191             "spelling": "getBar"
192           }
193         ],
194         "title": "getBar"
195       },
196       "pathComponents": [
197         "getBar"
198       ]
199     },
200     {
201       "accessLevel": "public",
202       "declarationFragments": [
203         {
204           "kind": "typeIdentifier",
205           "preciseIdentifier": "c:v",
206           "spelling": "void"
207         },
208         {
209           "kind": "text",
210           "spelling": " "
211         },
212         {
213           "kind": "identifier",
214           "spelling": "getFooBar"
215         },
216         {
217           "kind": "text",
218           "spelling": "() "
219         },
220         {
221           "kind": "keyword",
222           "spelling": "noexcept"
223         },
224         {
225           "kind": "text",
226           "spelling": "("
227         },
228         {
229           "kind": "keyword",
230           "spelling": "false"
231         },
232         {
233           "kind": "text",
234           "spelling": ");"
235         }
236       ],
237       "functionSignature": {
238         "returns": [
239           {
240             "kind": "typeIdentifier",
241             "preciseIdentifier": "c:v",
242             "spelling": "void"
243           }
244         ]
245       },
246       "identifier": {
247         "interfaceLanguage": "c++",
248         "precise": "c:@F@getFooBar#"
249       },
250       "kind": {
251         "displayName": "Function",
252         "identifier": "c++.func"
253       },
254       "location": {
255         "position": {
256           "character": 5,
257           "line": 4
258         },
259         "uri": "file://INPUT_DIR/input.h"
260       },
261       "names": {
262         "navigator": [
263           {
264             "kind": "identifier",
265             "spelling": "getFooBar"
266           }
267         ],
268         "subHeading": [
269           {
270             "kind": "identifier",
271             "spelling": "getFooBar"
272           }
273         ],
274         "title": "getFooBar"
275       },
276       "pathComponents": [
277         "getFooBar"
278       ]
279     }
280   ]
281 }
282