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