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 --pretty-sgf --product-name=GlobalRecord -target arm64-apple-macosx \ 6 // RUN: %t/input1.h %t/input2.h %t/input3.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 //--- input1.h 17 int num; 18 19 //--- input2.h 20 /** 21 * \brief Add two numbers. 22 * \param [in] x A number. 23 * \param [in] y Another number. 24 * \param [out] res The result of x + y. 25 */ 26 void add(const int x, const int y, int *res); 27 28 //--- input3.h 29 char unavailable __attribute__((unavailable)); 30 31 //--- reference.output.json.in 32 { 33 "metadata": { 34 "formatVersion": { 35 "major": 0, 36 "minor": 5, 37 "patch": 3 38 }, 39 "generator": "?" 40 }, 41 "module": { 42 "name": "GlobalRecord", 43 "platform": { 44 "architecture": "arm64", 45 "operatingSystem": { 46 "minimumVersion": { 47 "major": 11, 48 "minor": 0, 49 "patch": 0 50 }, 51 "name": "macosx" 52 }, 53 "vendor": "apple" 54 } 55 }, 56 "relationships": [], 57 "symbols": [ 58 { 59 "accessLevel": "public", 60 "declarationFragments": [ 61 { 62 "kind": "typeIdentifier", 63 "preciseIdentifier": "c:I", 64 "spelling": "int" 65 }, 66 { 67 "kind": "text", 68 "spelling": " " 69 }, 70 { 71 "kind": "identifier", 72 "spelling": "num" 73 }, 74 { 75 "kind": "text", 76 "spelling": ";" 77 } 78 ], 79 "identifier": { 80 "interfaceLanguage": "c", 81 "precise": "c:@num" 82 }, 83 "kind": { 84 "displayName": "Global Variable", 85 "identifier": "c.var" 86 }, 87 "location": { 88 "position": { 89 "character": 4, 90 "line": 0 91 }, 92 "uri": "file://INPUT_DIR/input1.h" 93 }, 94 "names": { 95 "navigator": [ 96 { 97 "kind": "identifier", 98 "spelling": "num" 99 } 100 ], 101 "subHeading": [ 102 { 103 "kind": "identifier", 104 "spelling": "num" 105 } 106 ], 107 "title": "num" 108 }, 109 "pathComponents": [ 110 "num" 111 ] 112 }, 113 { 114 "accessLevel": "public", 115 "declarationFragments": [ 116 { 117 "kind": "typeIdentifier", 118 "preciseIdentifier": "c:v", 119 "spelling": "void" 120 }, 121 { 122 "kind": "text", 123 "spelling": " " 124 }, 125 { 126 "kind": "identifier", 127 "spelling": "add" 128 }, 129 { 130 "kind": "text", 131 "spelling": "(" 132 }, 133 { 134 "kind": "keyword", 135 "spelling": "const" 136 }, 137 { 138 "kind": "text", 139 "spelling": " " 140 }, 141 { 142 "kind": "typeIdentifier", 143 "preciseIdentifier": "c:I", 144 "spelling": "int" 145 }, 146 { 147 "kind": "text", 148 "spelling": " " 149 }, 150 { 151 "kind": "internalParam", 152 "spelling": "x" 153 }, 154 { 155 "kind": "text", 156 "spelling": ", " 157 }, 158 { 159 "kind": "keyword", 160 "spelling": "const" 161 }, 162 { 163 "kind": "text", 164 "spelling": " " 165 }, 166 { 167 "kind": "typeIdentifier", 168 "preciseIdentifier": "c:I", 169 "spelling": "int" 170 }, 171 { 172 "kind": "text", 173 "spelling": " " 174 }, 175 { 176 "kind": "internalParam", 177 "spelling": "y" 178 }, 179 { 180 "kind": "text", 181 "spelling": ", " 182 }, 183 { 184 "kind": "typeIdentifier", 185 "preciseIdentifier": "c:I", 186 "spelling": "int" 187 }, 188 { 189 "kind": "text", 190 "spelling": " * " 191 }, 192 { 193 "kind": "internalParam", 194 "spelling": "res" 195 }, 196 { 197 "kind": "text", 198 "spelling": ");" 199 } 200 ], 201 "docComment": { 202 "lines": [ 203 { 204 "range": { 205 "end": { 206 "character": 3, 207 "line": 0 208 }, 209 "start": { 210 "character": 3, 211 "line": 0 212 } 213 }, 214 "text": "" 215 }, 216 { 217 "range": { 218 "end": { 219 "character": 26, 220 "line": 1 221 }, 222 "start": { 223 "character": 2, 224 "line": 1 225 } 226 }, 227 "text": " \\brief Add two numbers." 228 }, 229 { 230 "range": { 231 "end": { 232 "character": 29, 233 "line": 2 234 }, 235 "start": { 236 "character": 2, 237 "line": 2 238 } 239 }, 240 "text": " \\param [in] x A number." 241 }, 242 { 243 "range": { 244 "end": { 245 "character": 35, 246 "line": 3 247 }, 248 "start": { 249 "character": 2, 250 "line": 3 251 } 252 }, 253 "text": " \\param [in] y Another number." 254 }, 255 { 256 "range": { 257 "end": { 258 "character": 40, 259 "line": 4 260 }, 261 "start": { 262 "character": 2, 263 "line": 4 264 } 265 }, 266 "text": " \\param [out] res The result of x + y." 267 }, 268 { 269 "range": { 270 "end": { 271 "character": 3, 272 "line": 5 273 }, 274 "start": { 275 "character": 0, 276 "line": 5 277 } 278 }, 279 "text": " " 280 } 281 ] 282 }, 283 "functionSignature": { 284 "parameters": [ 285 { 286 "declarationFragments": [ 287 { 288 "kind": "keyword", 289 "spelling": "const" 290 }, 291 { 292 "kind": "text", 293 "spelling": " " 294 }, 295 { 296 "kind": "typeIdentifier", 297 "preciseIdentifier": "c:I", 298 "spelling": "int" 299 }, 300 { 301 "kind": "text", 302 "spelling": " " 303 }, 304 { 305 "kind": "internalParam", 306 "spelling": "x" 307 } 308 ], 309 "name": "x" 310 }, 311 { 312 "declarationFragments": [ 313 { 314 "kind": "keyword", 315 "spelling": "const" 316 }, 317 { 318 "kind": "text", 319 "spelling": " " 320 }, 321 { 322 "kind": "typeIdentifier", 323 "preciseIdentifier": "c:I", 324 "spelling": "int" 325 }, 326 { 327 "kind": "text", 328 "spelling": " " 329 }, 330 { 331 "kind": "internalParam", 332 "spelling": "y" 333 } 334 ], 335 "name": "y" 336 }, 337 { 338 "declarationFragments": [ 339 { 340 "kind": "typeIdentifier", 341 "preciseIdentifier": "c:I", 342 "spelling": "int" 343 }, 344 { 345 "kind": "text", 346 "spelling": " * " 347 }, 348 { 349 "kind": "internalParam", 350 "spelling": "res" 351 } 352 ], 353 "name": "res" 354 } 355 ], 356 "returns": [ 357 { 358 "kind": "typeIdentifier", 359 "preciseIdentifier": "c:v", 360 "spelling": "void" 361 } 362 ] 363 }, 364 "identifier": { 365 "interfaceLanguage": "c", 366 "precise": "c:@F@add" 367 }, 368 "kind": { 369 "displayName": "Function", 370 "identifier": "c.func" 371 }, 372 "location": { 373 "position": { 374 "character": 5, 375 "line": 6 376 }, 377 "uri": "file://INPUT_DIR/input2.h" 378 }, 379 "names": { 380 "navigator": [ 381 { 382 "kind": "identifier", 383 "spelling": "add" 384 } 385 ], 386 "subHeading": [ 387 { 388 "kind": "identifier", 389 "spelling": "add" 390 } 391 ], 392 "title": "add" 393 }, 394 "pathComponents": [ 395 "add" 396 ] 397 } 398 ] 399 } 400