Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / ExtractAPI / enum.c
bloba6c749028bd17b33aec451a60c6627d1fe0480f1
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 -triple arm64-apple-macosx \
6 // RUN: -x c-header %t/input.h -o %t/output.json -verify
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
13 //--- input.h
14 /// Kinds of vehicles
15 enum Vehicle {
16 Bicycle,
17 Car,
18 Train, ///< Move this to the top! -Sheldon
19 Ship,
20 Airplane,
23 enum Direction : unsigned char {
24 North = 0,
25 East,
26 South,
27 West
30 enum {
31 Constant = 1
34 enum {
35 OtherConstant = 2
37 // expected-no-diagnostics
39 //--- reference.output.json.in
41 "metadata": {
42 "formatVersion": {
43 "major": 0,
44 "minor": 5,
45 "patch": 3
47 "generator": "?"
49 "module": {
50 "name": "",
51 "platform": {
52 "architecture": "arm64",
53 "operatingSystem": {
54 "minimumVersion": {
55 "major": 11,
56 "minor": 0,
57 "patch": 0
59 "name": "macosx"
61 "vendor": "apple"
64 "relationships": [
66 "kind": "memberOf",
67 "source": "c:@E@Vehicle@Bicycle",
68 "target": "c:@E@Vehicle",
69 "targetFallback": "Vehicle"
72 "kind": "memberOf",
73 "source": "c:@E@Vehicle@Car",
74 "target": "c:@E@Vehicle",
75 "targetFallback": "Vehicle"
78 "kind": "memberOf",
79 "source": "c:@E@Vehicle@Train",
80 "target": "c:@E@Vehicle",
81 "targetFallback": "Vehicle"
84 "kind": "memberOf",
85 "source": "c:@E@Vehicle@Ship",
86 "target": "c:@E@Vehicle",
87 "targetFallback": "Vehicle"
90 "kind": "memberOf",
91 "source": "c:@E@Vehicle@Airplane",
92 "target": "c:@E@Vehicle",
93 "targetFallback": "Vehicle"
96 "kind": "memberOf",
97 "source": "c:@E@Direction@North",
98 "target": "c:@E@Direction",
99 "targetFallback": "Direction"
102 "kind": "memberOf",
103 "source": "c:@E@Direction@East",
104 "target": "c:@E@Direction",
105 "targetFallback": "Direction"
108 "kind": "memberOf",
109 "source": "c:@E@Direction@South",
110 "target": "c:@E@Direction",
111 "targetFallback": "Direction"
114 "kind": "memberOf",
115 "source": "c:@E@Direction@West",
116 "target": "c:@E@Direction",
117 "targetFallback": "Direction"
120 "kind": "memberOf",
121 "source": "c:@Ea@Constant@Constant",
122 "target": "c:@Ea@Constant",
123 "targetFallback": "enum (unnamed)"
126 "kind": "memberOf",
127 "source": "c:@Ea@OtherConstant@OtherConstant",
128 "target": "c:@Ea@OtherConstant",
129 "targetFallback": "enum (unnamed)"
132 "symbols": [
134 "accessLevel": "public",
135 "declarationFragments": [
137 "kind": "keyword",
138 "spelling": "enum"
141 "kind": "text",
142 "spelling": " "
145 "kind": "identifier",
146 "spelling": "Vehicle"
149 "kind": "text",
150 "spelling": ": "
153 "kind": "typeIdentifier",
154 "preciseIdentifier": "c:i",
155 "spelling": "unsigned int"
158 "kind": "text",
159 "spelling": ";"
162 "docComment": {
163 "lines": [
165 "range": {
166 "end": {
167 "character": 22,
168 "line": 1
170 "start": {
171 "character": 5,
172 "line": 1
175 "text": "Kinds of vehicles"
179 "identifier": {
180 "interfaceLanguage": "c",
181 "precise": "c:@E@Vehicle"
183 "kind": {
184 "displayName": "Enumeration",
185 "identifier": "c.enum"
187 "location": {
188 "position": {
189 "character": 6,
190 "line": 2
192 "uri": "file://INPUT_DIR/input.h"
194 "names": {
195 "navigator": [
197 "kind": "identifier",
198 "spelling": "Vehicle"
201 "subHeading": [
203 "kind": "identifier",
204 "spelling": "Vehicle"
207 "title": "Vehicle"
209 "pathComponents": [
210 "Vehicle"
214 "accessLevel": "public",
215 "declarationFragments": [
217 "kind": "identifier",
218 "spelling": "Bicycle"
221 "identifier": {
222 "interfaceLanguage": "c",
223 "precise": "c:@E@Vehicle@Bicycle"
225 "kind": {
226 "displayName": "Enumeration Case",
227 "identifier": "c.enum.case"
229 "location": {
230 "position": {
231 "character": 3,
232 "line": 3
234 "uri": "file://INPUT_DIR/input.h"
236 "names": {
237 "navigator": [
239 "kind": "identifier",
240 "spelling": "Bicycle"
243 "subHeading": [
245 "kind": "identifier",
246 "spelling": "Bicycle"
249 "title": "Bicycle"
251 "pathComponents": [
252 "Vehicle",
253 "Bicycle"
257 "accessLevel": "public",
258 "declarationFragments": [
260 "kind": "identifier",
261 "spelling": "Car"
264 "identifier": {
265 "interfaceLanguage": "c",
266 "precise": "c:@E@Vehicle@Car"
268 "kind": {
269 "displayName": "Enumeration Case",
270 "identifier": "c.enum.case"
272 "location": {
273 "position": {
274 "character": 3,
275 "line": 4
277 "uri": "file://INPUT_DIR/input.h"
279 "names": {
280 "navigator": [
282 "kind": "identifier",
283 "spelling": "Car"
286 "subHeading": [
288 "kind": "identifier",
289 "spelling": "Car"
292 "title": "Car"
294 "pathComponents": [
295 "Vehicle",
296 "Car"
300 "accessLevel": "public",
301 "declarationFragments": [
303 "kind": "identifier",
304 "spelling": "Train"
307 "docComment": {
308 "lines": [
310 "range": {
311 "end": {
312 "character": 45,
313 "line": 5
315 "start": {
316 "character": 15,
317 "line": 5
320 "text": "Move this to the top! -Sheldon"
324 "identifier": {
325 "interfaceLanguage": "c",
326 "precise": "c:@E@Vehicle@Train"
328 "kind": {
329 "displayName": "Enumeration Case",
330 "identifier": "c.enum.case"
332 "location": {
333 "position": {
334 "character": 3,
335 "line": 5
337 "uri": "file://INPUT_DIR/input.h"
339 "names": {
340 "navigator": [
342 "kind": "identifier",
343 "spelling": "Train"
346 "subHeading": [
348 "kind": "identifier",
349 "spelling": "Train"
352 "title": "Train"
354 "pathComponents": [
355 "Vehicle",
356 "Train"
360 "accessLevel": "public",
361 "declarationFragments": [
363 "kind": "identifier",
364 "spelling": "Ship"
367 "identifier": {
368 "interfaceLanguage": "c",
369 "precise": "c:@E@Vehicle@Ship"
371 "kind": {
372 "displayName": "Enumeration Case",
373 "identifier": "c.enum.case"
375 "location": {
376 "position": {
377 "character": 3,
378 "line": 6
380 "uri": "file://INPUT_DIR/input.h"
382 "names": {
383 "navigator": [
385 "kind": "identifier",
386 "spelling": "Ship"
389 "subHeading": [
391 "kind": "identifier",
392 "spelling": "Ship"
395 "title": "Ship"
397 "pathComponents": [
398 "Vehicle",
399 "Ship"
403 "accessLevel": "public",
404 "declarationFragments": [
406 "kind": "identifier",
407 "spelling": "Airplane"
410 "identifier": {
411 "interfaceLanguage": "c",
412 "precise": "c:@E@Vehicle@Airplane"
414 "kind": {
415 "displayName": "Enumeration Case",
416 "identifier": "c.enum.case"
418 "location": {
419 "position": {
420 "character": 3,
421 "line": 7
423 "uri": "file://INPUT_DIR/input.h"
425 "names": {
426 "navigator": [
428 "kind": "identifier",
429 "spelling": "Airplane"
432 "subHeading": [
434 "kind": "identifier",
435 "spelling": "Airplane"
438 "title": "Airplane"
440 "pathComponents": [
441 "Vehicle",
442 "Airplane"
446 "accessLevel": "public",
447 "declarationFragments": [
449 "kind": "keyword",
450 "spelling": "enum"
453 "kind": "text",
454 "spelling": " "
457 "kind": "identifier",
458 "spelling": "Direction"
461 "kind": "text",
462 "spelling": ": "
465 "kind": "typeIdentifier",
466 "preciseIdentifier": "c:c",
467 "spelling": "unsigned char"
470 "kind": "text",
471 "spelling": ";"
474 "identifier": {
475 "interfaceLanguage": "c",
476 "precise": "c:@E@Direction"
478 "kind": {
479 "displayName": "Enumeration",
480 "identifier": "c.enum"
482 "location": {
483 "position": {
484 "character": 6,
485 "line": 10
487 "uri": "file://INPUT_DIR/input.h"
489 "names": {
490 "navigator": [
492 "kind": "identifier",
493 "spelling": "Direction"
496 "subHeading": [
498 "kind": "identifier",
499 "spelling": "Direction"
502 "title": "Direction"
504 "pathComponents": [
505 "Direction"
509 "accessLevel": "public",
510 "declarationFragments": [
512 "kind": "identifier",
513 "spelling": "North"
516 "identifier": {
517 "interfaceLanguage": "c",
518 "precise": "c:@E@Direction@North"
520 "kind": {
521 "displayName": "Enumeration Case",
522 "identifier": "c.enum.case"
524 "location": {
525 "position": {
526 "character": 3,
527 "line": 11
529 "uri": "file://INPUT_DIR/input.h"
531 "names": {
532 "navigator": [
534 "kind": "identifier",
535 "spelling": "North"
538 "subHeading": [
540 "kind": "identifier",
541 "spelling": "North"
544 "title": "North"
546 "pathComponents": [
547 "Direction",
548 "North"
552 "accessLevel": "public",
553 "declarationFragments": [
555 "kind": "identifier",
556 "spelling": "East"
559 "identifier": {
560 "interfaceLanguage": "c",
561 "precise": "c:@E@Direction@East"
563 "kind": {
564 "displayName": "Enumeration Case",
565 "identifier": "c.enum.case"
567 "location": {
568 "position": {
569 "character": 3,
570 "line": 12
572 "uri": "file://INPUT_DIR/input.h"
574 "names": {
575 "navigator": [
577 "kind": "identifier",
578 "spelling": "East"
581 "subHeading": [
583 "kind": "identifier",
584 "spelling": "East"
587 "title": "East"
589 "pathComponents": [
590 "Direction",
591 "East"
595 "accessLevel": "public",
596 "declarationFragments": [
598 "kind": "identifier",
599 "spelling": "South"
602 "identifier": {
603 "interfaceLanguage": "c",
604 "precise": "c:@E@Direction@South"
606 "kind": {
607 "displayName": "Enumeration Case",
608 "identifier": "c.enum.case"
610 "location": {
611 "position": {
612 "character": 3,
613 "line": 13
615 "uri": "file://INPUT_DIR/input.h"
617 "names": {
618 "navigator": [
620 "kind": "identifier",
621 "spelling": "South"
624 "subHeading": [
626 "kind": "identifier",
627 "spelling": "South"
630 "title": "South"
632 "pathComponents": [
633 "Direction",
634 "South"
638 "accessLevel": "public",
639 "declarationFragments": [
641 "kind": "identifier",
642 "spelling": "West"
645 "identifier": {
646 "interfaceLanguage": "c",
647 "precise": "c:@E@Direction@West"
649 "kind": {
650 "displayName": "Enumeration Case",
651 "identifier": "c.enum.case"
653 "location": {
654 "position": {
655 "character": 3,
656 "line": 14
658 "uri": "file://INPUT_DIR/input.h"
660 "names": {
661 "navigator": [
663 "kind": "identifier",
664 "spelling": "West"
667 "subHeading": [
669 "kind": "identifier",
670 "spelling": "West"
673 "title": "West"
675 "pathComponents": [
676 "Direction",
677 "West"
681 "accessLevel": "public",
682 "declarationFragments": [
684 "kind": "keyword",
685 "spelling": "enum"
688 "kind": "text",
689 "spelling": ": "
692 "kind": "typeIdentifier",
693 "preciseIdentifier": "c:i",
694 "spelling": "unsigned int"
697 "kind": "text",
698 "spelling": ";"
701 "identifier": {
702 "interfaceLanguage": "c",
703 "precise": "c:@Ea@Constant"
705 "kind": {
706 "displayName": "Enumeration",
707 "identifier": "c.enum"
709 "location": {
710 "position": {
711 "character": 1,
712 "line": 17
714 "uri": "file://INPUT_DIR/input.h"
716 "names": {
717 "navigator": [
719 "kind": "identifier",
720 "spelling": "enum (unnamed)"
723 "title": "enum (unnamed)"
725 "pathComponents": [
726 "enum (unnamed)"
730 "accessLevel": "public",
731 "declarationFragments": [
733 "kind": "identifier",
734 "spelling": "Constant"
737 "identifier": {
738 "interfaceLanguage": "c",
739 "precise": "c:@Ea@Constant@Constant"
741 "kind": {
742 "displayName": "Enumeration Case",
743 "identifier": "c.enum.case"
745 "location": {
746 "position": {
747 "character": 3,
748 "line": 18
750 "uri": "file://INPUT_DIR/input.h"
752 "names": {
753 "navigator": [
755 "kind": "identifier",
756 "spelling": "Constant"
759 "subHeading": [
761 "kind": "identifier",
762 "spelling": "Constant"
765 "title": "Constant"
767 "pathComponents": [
768 "enum (unnamed)",
769 "Constant"
773 "accessLevel": "public",
774 "declarationFragments": [
776 "kind": "keyword",
777 "spelling": "enum"
780 "kind": "text",
781 "spelling": ": "
784 "kind": "typeIdentifier",
785 "preciseIdentifier": "c:i",
786 "spelling": "unsigned int"
789 "kind": "text",
790 "spelling": ";"
793 "identifier": {
794 "interfaceLanguage": "c",
795 "precise": "c:@Ea@OtherConstant"
797 "kind": {
798 "displayName": "Enumeration",
799 "identifier": "c.enum"
801 "location": {
802 "position": {
803 "character": 1,
804 "line": 21
806 "uri": "file://INPUT_DIR/input.h"
808 "names": {
809 "navigator": [
811 "kind": "identifier",
812 "spelling": "enum (unnamed)"
815 "title": "enum (unnamed)"
817 "pathComponents": [
818 "enum (unnamed)"
822 "accessLevel": "public",
823 "declarationFragments": [
825 "kind": "identifier",
826 "spelling": "OtherConstant"
829 "identifier": {
830 "interfaceLanguage": "c",
831 "precise": "c:@Ea@OtherConstant@OtherConstant"
833 "kind": {
834 "displayName": "Enumeration Case",
835 "identifier": "c.enum.case"
837 "location": {
838 "position": {
839 "character": 3,
840 "line": 22
842 "uri": "file://INPUT_DIR/input.h"
844 "names": {
845 "navigator": [
847 "kind": "identifier",
848 "spelling": "OtherConstant"
851 "subHeading": [
853 "kind": "identifier",
854 "spelling": "OtherConstant"
857 "title": "OtherConstant"
859 "pathComponents": [
860 "enum (unnamed)",
861 "OtherConstant"