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 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 /// Kinds of vehicles 15 enum Vehicle { 16 Bicycle, 17 Car, 18 Train, ///< Move this to the top! -Sheldon 19 Ship, 20 Airplane, 21 }; 22 23 enum Direction : unsigned char { 24 North = 0, 25 East, 26 South, 27 West 28 }; 29 30 enum { 31 Constant = 1 32 }; 33 34 enum { 35 OtherConstant = 2 36 }; 37 // expected-no-diagnostics 38 39 //--- reference.output.json.in 40 { 41 "metadata": { 42 "formatVersion": { 43 "major": 0, 44 "minor": 5, 45 "patch": 3 46 }, 47 "generator": "?" 48 }, 49 "module": { 50 "name": "", 51 "platform": { 52 "architecture": "arm64", 53 "operatingSystem": { 54 "minimumVersion": { 55 "major": 11, 56 "minor": 0, 57 "patch": 0 58 }, 59 "name": "macosx" 60 }, 61 "vendor": "apple" 62 } 63 }, 64 "relationships": [ 65 { 66 "kind": "memberOf", 67 "source": "c:@E@Vehicle@Bicycle", 68 "target": "c:@E@Vehicle", 69 "targetFallback": "Vehicle" 70 }, 71 { 72 "kind": "memberOf", 73 "source": "c:@E@Vehicle@Car", 74 "target": "c:@E@Vehicle", 75 "targetFallback": "Vehicle" 76 }, 77 { 78 "kind": "memberOf", 79 "source": "c:@E@Vehicle@Train", 80 "target": "c:@E@Vehicle", 81 "targetFallback": "Vehicle" 82 }, 83 { 84 "kind": "memberOf", 85 "source": "c:@E@Vehicle@Ship", 86 "target": "c:@E@Vehicle", 87 "targetFallback": "Vehicle" 88 }, 89 { 90 "kind": "memberOf", 91 "source": "c:@E@Vehicle@Airplane", 92 "target": "c:@E@Vehicle", 93 "targetFallback": "Vehicle" 94 }, 95 { 96 "kind": "memberOf", 97 "source": "c:@E@Direction@North", 98 "target": "c:@E@Direction", 99 "targetFallback": "Direction" 100 }, 101 { 102 "kind": "memberOf", 103 "source": "c:@E@Direction@East", 104 "target": "c:@E@Direction", 105 "targetFallback": "Direction" 106 }, 107 { 108 "kind": "memberOf", 109 "source": "c:@E@Direction@South", 110 "target": "c:@E@Direction", 111 "targetFallback": "Direction" 112 }, 113 { 114 "kind": "memberOf", 115 "source": "c:@E@Direction@West", 116 "target": "c:@E@Direction", 117 "targetFallback": "Direction" 118 }, 119 { 120 "kind": "memberOf", 121 "source": "c:@Ea@Constant@Constant", 122 "target": "c:@Ea@Constant", 123 "targetFallback": "enum (unnamed)" 124 }, 125 { 126 "kind": "memberOf", 127 "source": "c:@Ea@OtherConstant@OtherConstant", 128 "target": "c:@Ea@OtherConstant", 129 "targetFallback": "enum (unnamed)" 130 } 131 ], 132 "symbols": [ 133 { 134 "accessLevel": "public", 135 "declarationFragments": [ 136 { 137 "kind": "keyword", 138 "spelling": "enum" 139 }, 140 { 141 "kind": "text", 142 "spelling": " " 143 }, 144 { 145 "kind": "identifier", 146 "spelling": "Vehicle" 147 }, 148 { 149 "kind": "text", 150 "spelling": ": " 151 }, 152 { 153 "kind": "typeIdentifier", 154 "preciseIdentifier": "c:i", 155 "spelling": "unsigned int" 156 }, 157 { 158 "kind": "text", 159 "spelling": ";" 160 } 161 ], 162 "docComment": { 163 "lines": [ 164 { 165 "range": { 166 "end": { 167 "character": 21, 168 "line": 0 169 }, 170 "start": { 171 "character": 4, 172 "line": 0 173 } 174 }, 175 "text": "Kinds of vehicles" 176 } 177 ] 178 }, 179 "identifier": { 180 "interfaceLanguage": "c", 181 "precise": "c:@E@Vehicle" 182 }, 183 "kind": { 184 "displayName": "Enumeration", 185 "identifier": "c.enum" 186 }, 187 "location": { 188 "position": { 189 "character": 5, 190 "line": 1 191 }, 192 "uri": "file://INPUT_DIR/input.h" 193 }, 194 "names": { 195 "navigator": [ 196 { 197 "kind": "identifier", 198 "spelling": "Vehicle" 199 } 200 ], 201 "subHeading": [ 202 { 203 "kind": "identifier", 204 "spelling": "Vehicle" 205 } 206 ], 207 "title": "Vehicle" 208 }, 209 "pathComponents": [ 210 "Vehicle" 211 ] 212 }, 213 { 214 "accessLevel": "public", 215 "declarationFragments": [ 216 { 217 "kind": "identifier", 218 "spelling": "Bicycle" 219 } 220 ], 221 "identifier": { 222 "interfaceLanguage": "c", 223 "precise": "c:@E@Vehicle@Bicycle" 224 }, 225 "kind": { 226 "displayName": "Enumeration Case", 227 "identifier": "c.enum.case" 228 }, 229 "location": { 230 "position": { 231 "character": 2, 232 "line": 2 233 }, 234 "uri": "file://INPUT_DIR/input.h" 235 }, 236 "names": { 237 "navigator": [ 238 { 239 "kind": "identifier", 240 "spelling": "Bicycle" 241 } 242 ], 243 "subHeading": [ 244 { 245 "kind": "identifier", 246 "spelling": "Bicycle" 247 } 248 ], 249 "title": "Bicycle" 250 }, 251 "pathComponents": [ 252 "Vehicle", 253 "Bicycle" 254 ] 255 }, 256 { 257 "accessLevel": "public", 258 "declarationFragments": [ 259 { 260 "kind": "identifier", 261 "spelling": "Car" 262 } 263 ], 264 "identifier": { 265 "interfaceLanguage": "c", 266 "precise": "c:@E@Vehicle@Car" 267 }, 268 "kind": { 269 "displayName": "Enumeration Case", 270 "identifier": "c.enum.case" 271 }, 272 "location": { 273 "position": { 274 "character": 2, 275 "line": 3 276 }, 277 "uri": "file://INPUT_DIR/input.h" 278 }, 279 "names": { 280 "navigator": [ 281 { 282 "kind": "identifier", 283 "spelling": "Car" 284 } 285 ], 286 "subHeading": [ 287 { 288 "kind": "identifier", 289 "spelling": "Car" 290 } 291 ], 292 "title": "Car" 293 }, 294 "pathComponents": [ 295 "Vehicle", 296 "Car" 297 ] 298 }, 299 { 300 "accessLevel": "public", 301 "declarationFragments": [ 302 { 303 "kind": "identifier", 304 "spelling": "Train" 305 } 306 ], 307 "docComment": { 308 "lines": [ 309 { 310 "range": { 311 "end": { 312 "character": 44, 313 "line": 4 314 }, 315 "start": { 316 "character": 14, 317 "line": 4 318 } 319 }, 320 "text": "Move this to the top! -Sheldon" 321 } 322 ] 323 }, 324 "identifier": { 325 "interfaceLanguage": "c", 326 "precise": "c:@E@Vehicle@Train" 327 }, 328 "kind": { 329 "displayName": "Enumeration Case", 330 "identifier": "c.enum.case" 331 }, 332 "location": { 333 "position": { 334 "character": 2, 335 "line": 4 336 }, 337 "uri": "file://INPUT_DIR/input.h" 338 }, 339 "names": { 340 "navigator": [ 341 { 342 "kind": "identifier", 343 "spelling": "Train" 344 } 345 ], 346 "subHeading": [ 347 { 348 "kind": "identifier", 349 "spelling": "Train" 350 } 351 ], 352 "title": "Train" 353 }, 354 "pathComponents": [ 355 "Vehicle", 356 "Train" 357 ] 358 }, 359 { 360 "accessLevel": "public", 361 "declarationFragments": [ 362 { 363 "kind": "identifier", 364 "spelling": "Ship" 365 } 366 ], 367 "identifier": { 368 "interfaceLanguage": "c", 369 "precise": "c:@E@Vehicle@Ship" 370 }, 371 "kind": { 372 "displayName": "Enumeration Case", 373 "identifier": "c.enum.case" 374 }, 375 "location": { 376 "position": { 377 "character": 2, 378 "line": 5 379 }, 380 "uri": "file://INPUT_DIR/input.h" 381 }, 382 "names": { 383 "navigator": [ 384 { 385 "kind": "identifier", 386 "spelling": "Ship" 387 } 388 ], 389 "subHeading": [ 390 { 391 "kind": "identifier", 392 "spelling": "Ship" 393 } 394 ], 395 "title": "Ship" 396 }, 397 "pathComponents": [ 398 "Vehicle", 399 "Ship" 400 ] 401 }, 402 { 403 "accessLevel": "public", 404 "declarationFragments": [ 405 { 406 "kind": "identifier", 407 "spelling": "Airplane" 408 } 409 ], 410 "identifier": { 411 "interfaceLanguage": "c", 412 "precise": "c:@E@Vehicle@Airplane" 413 }, 414 "kind": { 415 "displayName": "Enumeration Case", 416 "identifier": "c.enum.case" 417 }, 418 "location": { 419 "position": { 420 "character": 2, 421 "line": 6 422 }, 423 "uri": "file://INPUT_DIR/input.h" 424 }, 425 "names": { 426 "navigator": [ 427 { 428 "kind": "identifier", 429 "spelling": "Airplane" 430 } 431 ], 432 "subHeading": [ 433 { 434 "kind": "identifier", 435 "spelling": "Airplane" 436 } 437 ], 438 "title": "Airplane" 439 }, 440 "pathComponents": [ 441 "Vehicle", 442 "Airplane" 443 ] 444 }, 445 { 446 "accessLevel": "public", 447 "declarationFragments": [ 448 { 449 "kind": "keyword", 450 "spelling": "enum" 451 }, 452 { 453 "kind": "text", 454 "spelling": " " 455 }, 456 { 457 "kind": "identifier", 458 "spelling": "Direction" 459 }, 460 { 461 "kind": "text", 462 "spelling": ": " 463 }, 464 { 465 "kind": "typeIdentifier", 466 "preciseIdentifier": "c:c", 467 "spelling": "unsigned char" 468 }, 469 { 470 "kind": "text", 471 "spelling": ";" 472 } 473 ], 474 "identifier": { 475 "interfaceLanguage": "c", 476 "precise": "c:@E@Direction" 477 }, 478 "kind": { 479 "displayName": "Enumeration", 480 "identifier": "c.enum" 481 }, 482 "location": { 483 "position": { 484 "character": 5, 485 "line": 9 486 }, 487 "uri": "file://INPUT_DIR/input.h" 488 }, 489 "names": { 490 "navigator": [ 491 { 492 "kind": "identifier", 493 "spelling": "Direction" 494 } 495 ], 496 "subHeading": [ 497 { 498 "kind": "identifier", 499 "spelling": "Direction" 500 } 501 ], 502 "title": "Direction" 503 }, 504 "pathComponents": [ 505 "Direction" 506 ] 507 }, 508 { 509 "accessLevel": "public", 510 "declarationFragments": [ 511 { 512 "kind": "identifier", 513 "spelling": "North" 514 } 515 ], 516 "identifier": { 517 "interfaceLanguage": "c", 518 "precise": "c:@E@Direction@North" 519 }, 520 "kind": { 521 "displayName": "Enumeration Case", 522 "identifier": "c.enum.case" 523 }, 524 "location": { 525 "position": { 526 "character": 2, 527 "line": 10 528 }, 529 "uri": "file://INPUT_DIR/input.h" 530 }, 531 "names": { 532 "navigator": [ 533 { 534 "kind": "identifier", 535 "spelling": "North" 536 } 537 ], 538 "subHeading": [ 539 { 540 "kind": "identifier", 541 "spelling": "North" 542 } 543 ], 544 "title": "North" 545 }, 546 "pathComponents": [ 547 "Direction", 548 "North" 549 ] 550 }, 551 { 552 "accessLevel": "public", 553 "declarationFragments": [ 554 { 555 "kind": "identifier", 556 "spelling": "East" 557 } 558 ], 559 "identifier": { 560 "interfaceLanguage": "c", 561 "precise": "c:@E@Direction@East" 562 }, 563 "kind": { 564 "displayName": "Enumeration Case", 565 "identifier": "c.enum.case" 566 }, 567 "location": { 568 "position": { 569 "character": 2, 570 "line": 11 571 }, 572 "uri": "file://INPUT_DIR/input.h" 573 }, 574 "names": { 575 "navigator": [ 576 { 577 "kind": "identifier", 578 "spelling": "East" 579 } 580 ], 581 "subHeading": [ 582 { 583 "kind": "identifier", 584 "spelling": "East" 585 } 586 ], 587 "title": "East" 588 }, 589 "pathComponents": [ 590 "Direction", 591 "East" 592 ] 593 }, 594 { 595 "accessLevel": "public", 596 "declarationFragments": [ 597 { 598 "kind": "identifier", 599 "spelling": "South" 600 } 601 ], 602 "identifier": { 603 "interfaceLanguage": "c", 604 "precise": "c:@E@Direction@South" 605 }, 606 "kind": { 607 "displayName": "Enumeration Case", 608 "identifier": "c.enum.case" 609 }, 610 "location": { 611 "position": { 612 "character": 2, 613 "line": 12 614 }, 615 "uri": "file://INPUT_DIR/input.h" 616 }, 617 "names": { 618 "navigator": [ 619 { 620 "kind": "identifier", 621 "spelling": "South" 622 } 623 ], 624 "subHeading": [ 625 { 626 "kind": "identifier", 627 "spelling": "South" 628 } 629 ], 630 "title": "South" 631 }, 632 "pathComponents": [ 633 "Direction", 634 "South" 635 ] 636 }, 637 { 638 "accessLevel": "public", 639 "declarationFragments": [ 640 { 641 "kind": "identifier", 642 "spelling": "West" 643 } 644 ], 645 "identifier": { 646 "interfaceLanguage": "c", 647 "precise": "c:@E@Direction@West" 648 }, 649 "kind": { 650 "displayName": "Enumeration Case", 651 "identifier": "c.enum.case" 652 }, 653 "location": { 654 "position": { 655 "character": 2, 656 "line": 13 657 }, 658 "uri": "file://INPUT_DIR/input.h" 659 }, 660 "names": { 661 "navigator": [ 662 { 663 "kind": "identifier", 664 "spelling": "West" 665 } 666 ], 667 "subHeading": [ 668 { 669 "kind": "identifier", 670 "spelling": "West" 671 } 672 ], 673 "title": "West" 674 }, 675 "pathComponents": [ 676 "Direction", 677 "West" 678 ] 679 }, 680 { 681 "accessLevel": "public", 682 "declarationFragments": [ 683 { 684 "kind": "keyword", 685 "spelling": "enum" 686 }, 687 { 688 "kind": "text", 689 "spelling": ": " 690 }, 691 { 692 "kind": "typeIdentifier", 693 "preciseIdentifier": "c:i", 694 "spelling": "unsigned int" 695 }, 696 { 697 "kind": "text", 698 "spelling": ";" 699 } 700 ], 701 "identifier": { 702 "interfaceLanguage": "c", 703 "precise": "c:@Ea@Constant" 704 }, 705 "kind": { 706 "displayName": "Enumeration", 707 "identifier": "c.enum" 708 }, 709 "location": { 710 "position": { 711 "character": 0, 712 "line": 16 713 }, 714 "uri": "file://INPUT_DIR/input.h" 715 }, 716 "names": { 717 "navigator": [ 718 { 719 "kind": "identifier", 720 "spelling": "enum (unnamed)" 721 } 722 ], 723 "title": "enum (unnamed)" 724 }, 725 "pathComponents": [ 726 "enum (unnamed)" 727 ] 728 }, 729 { 730 "accessLevel": "public", 731 "declarationFragments": [ 732 { 733 "kind": "identifier", 734 "spelling": "Constant" 735 } 736 ], 737 "identifier": { 738 "interfaceLanguage": "c", 739 "precise": "c:@Ea@Constant@Constant" 740 }, 741 "kind": { 742 "displayName": "Enumeration Case", 743 "identifier": "c.enum.case" 744 }, 745 "location": { 746 "position": { 747 "character": 2, 748 "line": 17 749 }, 750 "uri": "file://INPUT_DIR/input.h" 751 }, 752 "names": { 753 "navigator": [ 754 { 755 "kind": "identifier", 756 "spelling": "Constant" 757 } 758 ], 759 "subHeading": [ 760 { 761 "kind": "identifier", 762 "spelling": "Constant" 763 } 764 ], 765 "title": "Constant" 766 }, 767 "pathComponents": [ 768 "enum (unnamed)", 769 "Constant" 770 ] 771 }, 772 { 773 "accessLevel": "public", 774 "declarationFragments": [ 775 { 776 "kind": "keyword", 777 "spelling": "enum" 778 }, 779 { 780 "kind": "text", 781 "spelling": ": " 782 }, 783 { 784 "kind": "typeIdentifier", 785 "preciseIdentifier": "c:i", 786 "spelling": "unsigned int" 787 }, 788 { 789 "kind": "text", 790 "spelling": ";" 791 } 792 ], 793 "identifier": { 794 "interfaceLanguage": "c", 795 "precise": "c:@Ea@OtherConstant" 796 }, 797 "kind": { 798 "displayName": "Enumeration", 799 "identifier": "c.enum" 800 }, 801 "location": { 802 "position": { 803 "character": 0, 804 "line": 20 805 }, 806 "uri": "file://INPUT_DIR/input.h" 807 }, 808 "names": { 809 "navigator": [ 810 { 811 "kind": "identifier", 812 "spelling": "enum (unnamed)" 813 } 814 ], 815 "title": "enum (unnamed)" 816 }, 817 "pathComponents": [ 818 "enum (unnamed)" 819 ] 820 }, 821 { 822 "accessLevel": "public", 823 "declarationFragments": [ 824 { 825 "kind": "identifier", 826 "spelling": "OtherConstant" 827 } 828 ], 829 "identifier": { 830 "interfaceLanguage": "c", 831 "precise": "c:@Ea@OtherConstant@OtherConstant" 832 }, 833 "kind": { 834 "displayName": "Enumeration Case", 835 "identifier": "c.enum.case" 836 }, 837 "location": { 838 "position": { 839 "character": 2, 840 "line": 21 841 }, 842 "uri": "file://INPUT_DIR/input.h" 843 }, 844 "names": { 845 "navigator": [ 846 { 847 "kind": "identifier", 848 "spelling": "OtherConstant" 849 } 850 ], 851 "subHeading": [ 852 { 853 "kind": "identifier", 854 "spelling": "OtherConstant" 855 } 856 ], 857 "title": "OtherConstant" 858 }, 859 "pathComponents": [ 860 "enum (unnamed)", 861 "OtherConstant" 862 ] 863 } 864 ] 865 } 866