562 lines · c
1// RUN: rm -rf %t2// RUN: mkdir %t3// RUN: split-file %s %t4// RUN: sed -e "s@INPUT_DIR@%{/t:regex_replacement}@g" \5// RUN: %t/reference.main.json.in >> %t/reference.main.json6// RUN: sed -e "s@INPUT_DIR@%{/t:regex_replacement}@g" \7// RUN: %t/reference.test.json.in >> %t/reference.test.json8// RUN: %clang_cc1 %t/test.c %t/main.c -emit-symbol-graph --pretty-sgf \9// RUN: --symbol-graph-dir=%t/SymbolGraphs --product-name=multifile_test -triple=x86_64-apple-macosx12.0.010 11// Test main.json12// Generator version is not consistent across test runs, normalize it.13// RUN: sed -e "s@\"generator\": \".*\"@\"generator\": \"?\"@g" \14// RUN: %t/SymbolGraphs/main.c.symbols.json > %t/output-normalized.json15// RUN: diff %t/reference.main.json %t/output-normalized.json16 17// Test test.json18// Generator version is not consistent across test runs, normalize it.19// RUN: sed -e "s@\"generator\": \".*\"@\"generator\": \"?\"@g" \20// RUN: %t/SymbolGraphs/test.c.symbols.json > %t/output-normalized.json21// RUN: diff %t/reference.test.json %t/output-normalized.json22 23// CHECK-NOT: error:24// CHECK-NOT: warning:25 26//--- test.h27#ifndef TEST_H28#define TEST_H29 30int testfunc (int param1, int param2);31void testfunc2 ();32#endif /* TEST_H */33 34//--- test.c35#include "test.h"36 37int testfunc(int param1, int param2) { return param1 + param2; }38 39void testfunc2() {}40 41//--- main.c42#include "test.h"43 44int main ()45{46 testfunc2();47 return 0;48}49 50//--- reference.main.json.in51{52 "metadata": {53 "formatVersion": {54 "major": 0,55 "minor": 5,56 "patch": 357 },58 "generator": "?"59 },60 "module": {61 "name": "multifile_test",62 "platform": {63 "architecture": "x86_64",64 "operatingSystem": {65 "name": "macosx"66 },67 "vendor": "apple"68 }69 },70 "relationships": [],71 "symbols": [72 {73 "accessLevel": "public",74 "declarationFragments": [75 {76 "kind": "typeIdentifier",77 "preciseIdentifier": "c:I",78 "spelling": "int"79 },80 {81 "kind": "text",82 "spelling": " "83 },84 {85 "kind": "identifier",86 "spelling": "testfunc"87 },88 {89 "kind": "text",90 "spelling": "("91 },92 {93 "kind": "typeIdentifier",94 "preciseIdentifier": "c:I",95 "spelling": "int"96 },97 {98 "kind": "text",99 "spelling": " "100 },101 {102 "kind": "internalParam",103 "spelling": "param1"104 },105 {106 "kind": "text",107 "spelling": ", "108 },109 {110 "kind": "typeIdentifier",111 "preciseIdentifier": "c:I",112 "spelling": "int"113 },114 {115 "kind": "text",116 "spelling": " "117 },118 {119 "kind": "internalParam",120 "spelling": "param2"121 },122 {123 "kind": "text",124 "spelling": ");"125 }126 ],127 "functionSignature": {128 "parameters": [129 {130 "declarationFragments": [131 {132 "kind": "typeIdentifier",133 "preciseIdentifier": "c:I",134 "spelling": "int"135 },136 {137 "kind": "text",138 "spelling": " "139 },140 {141 "kind": "internalParam",142 "spelling": "param1"143 }144 ],145 "name": "param1"146 },147 {148 "declarationFragments": [149 {150 "kind": "typeIdentifier",151 "preciseIdentifier": "c:I",152 "spelling": "int"153 },154 {155 "kind": "text",156 "spelling": " "157 },158 {159 "kind": "internalParam",160 "spelling": "param2"161 }162 ],163 "name": "param2"164 }165 ],166 "returns": [167 {168 "kind": "typeIdentifier",169 "preciseIdentifier": "c:I",170 "spelling": "int"171 }172 ]173 },174 "identifier": {175 "interfaceLanguage": "c",176 "precise": "c:@F@testfunc"177 },178 "kind": {179 "displayName": "Function",180 "identifier": "c.func"181 },182 "location": {183 "position": {184 "character": 4,185 "line": 3186 },187 "uri": "file://INPUT_DIR/test.h"188 },189 "names": {190 "navigator": [191 {192 "kind": "identifier",193 "spelling": "testfunc"194 }195 ],196 "subHeading": [197 {198 "kind": "identifier",199 "spelling": "testfunc"200 }201 ],202 "title": "testfunc"203 },204 "pathComponents": [205 "testfunc"206 ]207 },208 {209 "accessLevel": "public",210 "declarationFragments": [211 {212 "kind": "typeIdentifier",213 "preciseIdentifier": "c:v",214 "spelling": "void"215 },216 {217 "kind": "text",218 "spelling": " "219 },220 {221 "kind": "identifier",222 "spelling": "testfunc2"223 },224 {225 "kind": "text",226 "spelling": "();"227 }228 ],229 "functionSignature": {230 "returns": [231 {232 "kind": "typeIdentifier",233 "preciseIdentifier": "c:v",234 "spelling": "void"235 }236 ]237 },238 "identifier": {239 "interfaceLanguage": "c",240 "precise": "c:@F@testfunc2"241 },242 "kind": {243 "displayName": "Function",244 "identifier": "c.func"245 },246 "location": {247 "position": {248 "character": 5,249 "line": 4250 },251 "uri": "file://INPUT_DIR/test.h"252 },253 "names": {254 "navigator": [255 {256 "kind": "identifier",257 "spelling": "testfunc2"258 }259 ],260 "subHeading": [261 {262 "kind": "identifier",263 "spelling": "testfunc2"264 }265 ],266 "title": "testfunc2"267 },268 "pathComponents": [269 "testfunc2"270 ]271 },272 {273 "accessLevel": "public",274 "declarationFragments": [275 {276 "kind": "typeIdentifier",277 "preciseIdentifier": "c:I",278 "spelling": "int"279 },280 {281 "kind": "text",282 "spelling": " "283 },284 {285 "kind": "identifier",286 "spelling": "main"287 },288 {289 "kind": "text",290 "spelling": "();"291 }292 ],293 "functionSignature": {294 "returns": [295 {296 "kind": "typeIdentifier",297 "preciseIdentifier": "c:I",298 "spelling": "int"299 }300 ]301 },302 "identifier": {303 "interfaceLanguage": "c",304 "precise": "c:@F@main"305 },306 "kind": {307 "displayName": "Function",308 "identifier": "c.func"309 },310 "location": {311 "position": {312 "character": 4,313 "line": 2314 },315 "uri": "file://INPUT_DIR/main.c"316 },317 "names": {318 "navigator": [319 {320 "kind": "identifier",321 "spelling": "main"322 }323 ],324 "subHeading": [325 {326 "kind": "identifier",327 "spelling": "main"328 }329 ],330 "title": "main"331 },332 "pathComponents": [333 "main"334 ]335 }336 ]337}338//--- reference.test.json.in339{340 "metadata": {341 "formatVersion": {342 "major": 0,343 "minor": 5,344 "patch": 3345 },346 "generator": "?"347 },348 "module": {349 "name": "multifile_test",350 "platform": {351 "architecture": "x86_64",352 "operatingSystem": {353 "name": "macosx"354 },355 "vendor": "apple"356 }357 },358 "relationships": [],359 "symbols": [360 {361 "accessLevel": "public",362 "declarationFragments": [363 {364 "kind": "typeIdentifier",365 "preciseIdentifier": "c:I",366 "spelling": "int"367 },368 {369 "kind": "text",370 "spelling": " "371 },372 {373 "kind": "identifier",374 "spelling": "testfunc"375 },376 {377 "kind": "text",378 "spelling": "("379 },380 {381 "kind": "typeIdentifier",382 "preciseIdentifier": "c:I",383 "spelling": "int"384 },385 {386 "kind": "text",387 "spelling": " "388 },389 {390 "kind": "internalParam",391 "spelling": "param1"392 },393 {394 "kind": "text",395 "spelling": ", "396 },397 {398 "kind": "typeIdentifier",399 "preciseIdentifier": "c:I",400 "spelling": "int"401 },402 {403 "kind": "text",404 "spelling": " "405 },406 {407 "kind": "internalParam",408 "spelling": "param2"409 },410 {411 "kind": "text",412 "spelling": ");"413 }414 ],415 "functionSignature": {416 "parameters": [417 {418 "declarationFragments": [419 {420 "kind": "typeIdentifier",421 "preciseIdentifier": "c:I",422 "spelling": "int"423 },424 {425 "kind": "text",426 "spelling": " "427 },428 {429 "kind": "internalParam",430 "spelling": "param1"431 }432 ],433 "name": "param1"434 },435 {436 "declarationFragments": [437 {438 "kind": "typeIdentifier",439 "preciseIdentifier": "c:I",440 "spelling": "int"441 },442 {443 "kind": "text",444 "spelling": " "445 },446 {447 "kind": "internalParam",448 "spelling": "param2"449 }450 ],451 "name": "param2"452 }453 ],454 "returns": [455 {456 "kind": "typeIdentifier",457 "preciseIdentifier": "c:I",458 "spelling": "int"459 }460 ]461 },462 "identifier": {463 "interfaceLanguage": "c",464 "precise": "c:@F@testfunc"465 },466 "kind": {467 "displayName": "Function",468 "identifier": "c.func"469 },470 "location": {471 "position": {472 "character": 4,473 "line": 3474 },475 "uri": "file://INPUT_DIR/test.h"476 },477 "names": {478 "navigator": [479 {480 "kind": "identifier",481 "spelling": "testfunc"482 }483 ],484 "subHeading": [485 {486 "kind": "identifier",487 "spelling": "testfunc"488 }489 ],490 "title": "testfunc"491 },492 "pathComponents": [493 "testfunc"494 ]495 },496 {497 "accessLevel": "public",498 "declarationFragments": [499 {500 "kind": "typeIdentifier",501 "preciseIdentifier": "c:v",502 "spelling": "void"503 },504 {505 "kind": "text",506 "spelling": " "507 },508 {509 "kind": "identifier",510 "spelling": "testfunc2"511 },512 {513 "kind": "text",514 "spelling": "();"515 }516 ],517 "functionSignature": {518 "returns": [519 {520 "kind": "typeIdentifier",521 "preciseIdentifier": "c:v",522 "spelling": "void"523 }524 ]525 },526 "identifier": {527 "interfaceLanguage": "c",528 "precise": "c:@F@testfunc2"529 },530 "kind": {531 "displayName": "Function",532 "identifier": "c.func"533 },534 "location": {535 "position": {536 "character": 5,537 "line": 4538 },539 "uri": "file://INPUT_DIR/test.h"540 },541 "names": {542 "navigator": [543 {544 "kind": "identifier",545 "spelling": "testfunc2"546 }547 ],548 "subHeading": [549 {550 "kind": "identifier",551 "spelling": "testfunc2"552 }553 ],554 "title": "testfunc2"555 },556 "pathComponents": [557 "testfunc2"558 ]559 }560 ]561}562