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