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