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