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