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