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