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