15bb5704cSZixu Wang // RUN: rm -rf %t
25bb5704cSZixu Wang // RUN: split-file %s %t
35bb5704cSZixu Wang // RUN: sed -e "s@INPUT_DIR@%/t@g" %t/reference.output.json.in >> \
45bb5704cSZixu Wang // RUN: %t/reference.output.json
55bb5704cSZixu Wang // RUN: %clang -extract-api -target arm64-apple-macosx \
65bb5704cSZixu Wang // RUN: %t/input.h -o %t/output.json | FileCheck -allow-empty %s
75bb5704cSZixu Wang 
85bb5704cSZixu Wang // Generator version is not consistent across test runs, normalize it.
95bb5704cSZixu Wang // RUN: sed -e "s@\"generator\": \".*\"@\"generator\": \"?\"@g" \
105bb5704cSZixu Wang // RUN: %t/output.json >> %t/output-normalized.json
115bb5704cSZixu Wang // RUN: diff %t/reference.output.json %t/output-normalized.json
125bb5704cSZixu Wang 
135bb5704cSZixu Wang // CHECK-NOT: error:
145bb5704cSZixu Wang // CHECK-NOT: warning:
155bb5704cSZixu Wang 
165bb5704cSZixu Wang //--- input.h
175bb5704cSZixu Wang /// Color in RGBA
185bb5704cSZixu Wang struct Color {
195bb5704cSZixu Wang   unsigned Red;
205bb5704cSZixu Wang   unsigned Green;
215bb5704cSZixu Wang   unsigned Blue;
225bb5704cSZixu Wang   /// Alpha channel for transparency
235bb5704cSZixu Wang   unsigned Alpha;
245bb5704cSZixu Wang };
255bb5704cSZixu Wang 
265bb5704cSZixu Wang //--- reference.output.json.in
275bb5704cSZixu Wang {
285bb5704cSZixu Wang   "metadata": {
295bb5704cSZixu Wang     "formatVersion": {
305bb5704cSZixu Wang       "major": 0,
315bb5704cSZixu Wang       "minor": 5,
325bb5704cSZixu Wang       "patch": 3
335bb5704cSZixu Wang     },
345bb5704cSZixu Wang     "generator": "?"
355bb5704cSZixu Wang   },
365bb5704cSZixu Wang   "module": {
375bb5704cSZixu Wang     "name": "",
385bb5704cSZixu Wang     "platform": {
395bb5704cSZixu Wang       "architecture": "arm64",
405bb5704cSZixu Wang       "operatingSystem": {
415bb5704cSZixu Wang         "minimumVersion": {
425bb5704cSZixu Wang           "major": 11,
435bb5704cSZixu Wang           "minor": 0,
445bb5704cSZixu Wang           "patch": 0
455bb5704cSZixu Wang         },
465bb5704cSZixu Wang         "name": "macosx"
475bb5704cSZixu Wang       },
485bb5704cSZixu Wang       "vendor": "apple"
495bb5704cSZixu Wang     }
505bb5704cSZixu Wang   },
5128d79314SDaniel Grumberg   "relationships": [
525bb5704cSZixu Wang     {
535bb5704cSZixu Wang       "kind": "memberOf",
545bb5704cSZixu Wang       "source": "c:@S@Color@FI@Red",
555bb5704cSZixu Wang       "target": "c:@S@Color"
565bb5704cSZixu Wang     },
575bb5704cSZixu Wang     {
585bb5704cSZixu Wang       "kind": "memberOf",
595bb5704cSZixu Wang       "source": "c:@S@Color@FI@Green",
605bb5704cSZixu Wang       "target": "c:@S@Color"
615bb5704cSZixu Wang     },
625bb5704cSZixu Wang     {
635bb5704cSZixu Wang       "kind": "memberOf",
645bb5704cSZixu Wang       "source": "c:@S@Color@FI@Blue",
655bb5704cSZixu Wang       "target": "c:@S@Color"
665bb5704cSZixu Wang     },
675bb5704cSZixu Wang     {
685bb5704cSZixu Wang       "kind": "memberOf",
695bb5704cSZixu Wang       "source": "c:@S@Color@FI@Alpha",
705bb5704cSZixu Wang       "target": "c:@S@Color"
715bb5704cSZixu Wang     }
725bb5704cSZixu Wang   ],
735bb5704cSZixu Wang   "symbols": [
745bb5704cSZixu Wang     {
7528d79314SDaniel Grumberg       "accessLevel": "public",
765bb5704cSZixu Wang       "declarationFragments": [
775bb5704cSZixu Wang         {
785bb5704cSZixu Wang           "kind": "keyword",
795bb5704cSZixu Wang           "spelling": "struct"
805bb5704cSZixu Wang         },
815bb5704cSZixu Wang         {
825bb5704cSZixu Wang           "kind": "text",
835bb5704cSZixu Wang           "spelling": " "
845bb5704cSZixu Wang         },
855bb5704cSZixu Wang         {
865bb5704cSZixu Wang           "kind": "identifier",
875bb5704cSZixu Wang           "spelling": "Color"
885bb5704cSZixu Wang         }
895bb5704cSZixu Wang       ],
905bb5704cSZixu Wang       "docComment": {
915bb5704cSZixu Wang         "lines": [
925bb5704cSZixu Wang           {
935bb5704cSZixu Wang             "range": {
945bb5704cSZixu Wang               "end": {
955bb5704cSZixu Wang                 "character": 18,
965bb5704cSZixu Wang                 "line": 1
975bb5704cSZixu Wang               },
985bb5704cSZixu Wang               "start": {
995bb5704cSZixu Wang                 "character": 5,
1005bb5704cSZixu Wang                 "line": 1
1015bb5704cSZixu Wang               }
1025bb5704cSZixu Wang             },
1035bb5704cSZixu Wang             "text": "Color in RGBA"
1045bb5704cSZixu Wang           }
1055bb5704cSZixu Wang         ]
1065bb5704cSZixu Wang       },
1075bb5704cSZixu Wang       "identifier": {
1085bb5704cSZixu Wang         "interfaceLanguage": "c",
1095bb5704cSZixu Wang         "precise": "c:@S@Color"
1105bb5704cSZixu Wang       },
1115bb5704cSZixu Wang       "kind": {
1125bb5704cSZixu Wang         "displayName": "Structure",
1135bb5704cSZixu Wang         "identifier": "c.struct"
1145bb5704cSZixu Wang       },
1155bb5704cSZixu Wang       "location": {
11628d79314SDaniel Grumberg         "position": {
1175bb5704cSZixu Wang           "character": 8,
11828d79314SDaniel Grumberg           "line": 2
11928d79314SDaniel Grumberg         },
1205bb5704cSZixu Wang         "uri": "file://INPUT_DIR/input.h"
1215bb5704cSZixu Wang       },
1225bb5704cSZixu Wang       "names": {
123*80ae3665SDaniel Grumberg         "navigator": [
124*80ae3665SDaniel Grumberg           {
125*80ae3665SDaniel Grumberg             "kind": "identifier",
126*80ae3665SDaniel Grumberg             "spelling": "Color"
127*80ae3665SDaniel Grumberg           }
128*80ae3665SDaniel Grumberg         ],
1295bb5704cSZixu Wang         "subHeading": [
1305bb5704cSZixu Wang           {
1315bb5704cSZixu Wang             "kind": "identifier",
1325bb5704cSZixu Wang             "spelling": "Color"
1335bb5704cSZixu Wang           }
1345bb5704cSZixu Wang         ],
1355bb5704cSZixu Wang         "title": "Color"
13628d79314SDaniel Grumberg       },
13728d79314SDaniel Grumberg       "pathComponents": [
13828d79314SDaniel Grumberg         "Color"
13928d79314SDaniel Grumberg       ]
1405bb5704cSZixu Wang     },
1415bb5704cSZixu Wang     {
14228d79314SDaniel Grumberg       "accessLevel": "public",
1435bb5704cSZixu Wang       "declarationFragments": [
1445bb5704cSZixu Wang         {
1455bb5704cSZixu Wang           "kind": "typeIdentifier",
1465bb5704cSZixu Wang           "preciseIdentifier": "c:i",
1475bb5704cSZixu Wang           "spelling": "unsigned int"
1485bb5704cSZixu Wang         },
1495bb5704cSZixu Wang         {
1505bb5704cSZixu Wang           "kind": "text",
1515bb5704cSZixu Wang           "spelling": " "
1525bb5704cSZixu Wang         },
1535bb5704cSZixu Wang         {
1545bb5704cSZixu Wang           "kind": "identifier",
1555bb5704cSZixu Wang           "spelling": "Red"
1565bb5704cSZixu Wang         }
1575bb5704cSZixu Wang       ],
1585bb5704cSZixu Wang       "identifier": {
1595bb5704cSZixu Wang         "interfaceLanguage": "c",
1605bb5704cSZixu Wang         "precise": "c:@S@Color@FI@Red"
1615bb5704cSZixu Wang       },
1625bb5704cSZixu Wang       "kind": {
1635bb5704cSZixu Wang         "displayName": "Instance Property",
1645bb5704cSZixu Wang         "identifier": "c.property"
1655bb5704cSZixu Wang       },
1665bb5704cSZixu Wang       "location": {
16728d79314SDaniel Grumberg         "position": {
1685bb5704cSZixu Wang           "character": 12,
16928d79314SDaniel Grumberg           "line": 3
17028d79314SDaniel Grumberg         },
1715bb5704cSZixu Wang         "uri": "file://INPUT_DIR/input.h"
1725bb5704cSZixu Wang       },
1735bb5704cSZixu Wang       "names": {
174*80ae3665SDaniel Grumberg         "navigator": [
175*80ae3665SDaniel Grumberg           {
176*80ae3665SDaniel Grumberg             "kind": "identifier",
177*80ae3665SDaniel Grumberg             "spelling": "Red"
178*80ae3665SDaniel Grumberg           }
179*80ae3665SDaniel Grumberg         ],
1805bb5704cSZixu Wang         "subHeading": [
1815bb5704cSZixu Wang           {
1825bb5704cSZixu Wang             "kind": "identifier",
1835bb5704cSZixu Wang             "spelling": "Red"
1845bb5704cSZixu Wang           }
1855bb5704cSZixu Wang         ],
1865bb5704cSZixu Wang         "title": "Red"
18728d79314SDaniel Grumberg       },
18828d79314SDaniel Grumberg       "pathComponents": [
18928d79314SDaniel Grumberg         "Color",
19028d79314SDaniel Grumberg         "Red"
19128d79314SDaniel Grumberg       ]
1925bb5704cSZixu Wang     },
1935bb5704cSZixu Wang     {
19428d79314SDaniel Grumberg       "accessLevel": "public",
1955bb5704cSZixu Wang       "declarationFragments": [
1965bb5704cSZixu Wang         {
1975bb5704cSZixu Wang           "kind": "typeIdentifier",
1985bb5704cSZixu Wang           "preciseIdentifier": "c:i",
1995bb5704cSZixu Wang           "spelling": "unsigned int"
2005bb5704cSZixu Wang         },
2015bb5704cSZixu Wang         {
2025bb5704cSZixu Wang           "kind": "text",
2035bb5704cSZixu Wang           "spelling": " "
2045bb5704cSZixu Wang         },
2055bb5704cSZixu Wang         {
2065bb5704cSZixu Wang           "kind": "identifier",
2075bb5704cSZixu Wang           "spelling": "Green"
2085bb5704cSZixu Wang         }
2095bb5704cSZixu Wang       ],
2105bb5704cSZixu Wang       "identifier": {
2115bb5704cSZixu Wang         "interfaceLanguage": "c",
2125bb5704cSZixu Wang         "precise": "c:@S@Color@FI@Green"
2135bb5704cSZixu Wang       },
2145bb5704cSZixu Wang       "kind": {
2155bb5704cSZixu Wang         "displayName": "Instance Property",
2165bb5704cSZixu Wang         "identifier": "c.property"
2175bb5704cSZixu Wang       },
2185bb5704cSZixu Wang       "location": {
21928d79314SDaniel Grumberg         "position": {
2205bb5704cSZixu Wang           "character": 12,
22128d79314SDaniel Grumberg           "line": 4
22228d79314SDaniel Grumberg         },
2235bb5704cSZixu Wang         "uri": "file://INPUT_DIR/input.h"
2245bb5704cSZixu Wang       },
2255bb5704cSZixu Wang       "names": {
226*80ae3665SDaniel Grumberg         "navigator": [
227*80ae3665SDaniel Grumberg           {
228*80ae3665SDaniel Grumberg             "kind": "identifier",
229*80ae3665SDaniel Grumberg             "spelling": "Green"
230*80ae3665SDaniel Grumberg           }
231*80ae3665SDaniel Grumberg         ],
2325bb5704cSZixu Wang         "subHeading": [
2335bb5704cSZixu Wang           {
2345bb5704cSZixu Wang             "kind": "identifier",
2355bb5704cSZixu Wang             "spelling": "Green"
2365bb5704cSZixu Wang           }
2375bb5704cSZixu Wang         ],
2385bb5704cSZixu Wang         "title": "Green"
23928d79314SDaniel Grumberg       },
24028d79314SDaniel Grumberg       "pathComponents": [
24128d79314SDaniel Grumberg         "Color",
24228d79314SDaniel Grumberg         "Green"
24328d79314SDaniel Grumberg       ]
2445bb5704cSZixu Wang     },
2455bb5704cSZixu Wang     {
24628d79314SDaniel Grumberg       "accessLevel": "public",
2475bb5704cSZixu Wang       "declarationFragments": [
2485bb5704cSZixu Wang         {
2495bb5704cSZixu Wang           "kind": "typeIdentifier",
2505bb5704cSZixu Wang           "preciseIdentifier": "c:i",
2515bb5704cSZixu Wang           "spelling": "unsigned int"
2525bb5704cSZixu Wang         },
2535bb5704cSZixu Wang         {
2545bb5704cSZixu Wang           "kind": "text",
2555bb5704cSZixu Wang           "spelling": " "
2565bb5704cSZixu Wang         },
2575bb5704cSZixu Wang         {
2585bb5704cSZixu Wang           "kind": "identifier",
2595bb5704cSZixu Wang           "spelling": "Blue"
2605bb5704cSZixu Wang         }
2615bb5704cSZixu Wang       ],
2625bb5704cSZixu Wang       "identifier": {
2635bb5704cSZixu Wang         "interfaceLanguage": "c",
2645bb5704cSZixu Wang         "precise": "c:@S@Color@FI@Blue"
2655bb5704cSZixu Wang       },
2665bb5704cSZixu Wang       "kind": {
2675bb5704cSZixu Wang         "displayName": "Instance Property",
2685bb5704cSZixu Wang         "identifier": "c.property"
2695bb5704cSZixu Wang       },
2705bb5704cSZixu Wang       "location": {
27128d79314SDaniel Grumberg         "position": {
2725bb5704cSZixu Wang           "character": 12,
27328d79314SDaniel Grumberg           "line": 5
27428d79314SDaniel Grumberg         },
2755bb5704cSZixu Wang         "uri": "file://INPUT_DIR/input.h"
2765bb5704cSZixu Wang       },
2775bb5704cSZixu Wang       "names": {
278*80ae3665SDaniel Grumberg         "navigator": [
279*80ae3665SDaniel Grumberg           {
280*80ae3665SDaniel Grumberg             "kind": "identifier",
281*80ae3665SDaniel Grumberg             "spelling": "Blue"
282*80ae3665SDaniel Grumberg           }
283*80ae3665SDaniel Grumberg         ],
2845bb5704cSZixu Wang         "subHeading": [
2855bb5704cSZixu Wang           {
2865bb5704cSZixu Wang             "kind": "identifier",
2875bb5704cSZixu Wang             "spelling": "Blue"
2885bb5704cSZixu Wang           }
2895bb5704cSZixu Wang         ],
2905bb5704cSZixu Wang         "title": "Blue"
29128d79314SDaniel Grumberg       },
29228d79314SDaniel Grumberg       "pathComponents": [
29328d79314SDaniel Grumberg         "Color",
29428d79314SDaniel Grumberg         "Blue"
29528d79314SDaniel Grumberg       ]
2965bb5704cSZixu Wang     },
2975bb5704cSZixu Wang     {
29828d79314SDaniel Grumberg       "accessLevel": "public",
2995bb5704cSZixu Wang       "declarationFragments": [
3005bb5704cSZixu Wang         {
3015bb5704cSZixu Wang           "kind": "typeIdentifier",
3025bb5704cSZixu Wang           "preciseIdentifier": "c:i",
3035bb5704cSZixu Wang           "spelling": "unsigned int"
3045bb5704cSZixu Wang         },
3055bb5704cSZixu Wang         {
3065bb5704cSZixu Wang           "kind": "text",
3075bb5704cSZixu Wang           "spelling": " "
3085bb5704cSZixu Wang         },
3095bb5704cSZixu Wang         {
3105bb5704cSZixu Wang           "kind": "identifier",
3115bb5704cSZixu Wang           "spelling": "Alpha"
3125bb5704cSZixu Wang         }
3135bb5704cSZixu Wang       ],
3145bb5704cSZixu Wang       "docComment": {
3155bb5704cSZixu Wang         "lines": [
3165bb5704cSZixu Wang           {
3175bb5704cSZixu Wang             "range": {
3185bb5704cSZixu Wang               "end": {
3195bb5704cSZixu Wang                 "character": 37,
3205bb5704cSZixu Wang                 "line": 6
3215bb5704cSZixu Wang               },
3225bb5704cSZixu Wang               "start": {
3235bb5704cSZixu Wang                 "character": 7,
3245bb5704cSZixu Wang                 "line": 6
3255bb5704cSZixu Wang               }
3265bb5704cSZixu Wang             },
3275bb5704cSZixu Wang             "text": "Alpha channel for transparency"
3285bb5704cSZixu Wang           }
3295bb5704cSZixu Wang         ]
3305bb5704cSZixu Wang       },
3315bb5704cSZixu Wang       "identifier": {
3325bb5704cSZixu Wang         "interfaceLanguage": "c",
3335bb5704cSZixu Wang         "precise": "c:@S@Color@FI@Alpha"
3345bb5704cSZixu Wang       },
3355bb5704cSZixu Wang       "kind": {
3365bb5704cSZixu Wang         "displayName": "Instance Property",
3375bb5704cSZixu Wang         "identifier": "c.property"
3385bb5704cSZixu Wang       },
3395bb5704cSZixu Wang       "location": {
34028d79314SDaniel Grumberg         "position": {
3415bb5704cSZixu Wang           "character": 12,
34228d79314SDaniel Grumberg           "line": 7
34328d79314SDaniel Grumberg         },
3445bb5704cSZixu Wang         "uri": "file://INPUT_DIR/input.h"
3455bb5704cSZixu Wang       },
3465bb5704cSZixu Wang       "names": {
347*80ae3665SDaniel Grumberg         "navigator": [
348*80ae3665SDaniel Grumberg           {
349*80ae3665SDaniel Grumberg             "kind": "identifier",
350*80ae3665SDaniel Grumberg             "spelling": "Alpha"
351*80ae3665SDaniel Grumberg           }
352*80ae3665SDaniel Grumberg         ],
3535bb5704cSZixu Wang         "subHeading": [
3545bb5704cSZixu Wang           {
3555bb5704cSZixu Wang             "kind": "identifier",
3565bb5704cSZixu Wang             "spelling": "Alpha"
3575bb5704cSZixu Wang           }
3585bb5704cSZixu Wang         ],
3595bb5704cSZixu Wang         "title": "Alpha"
36028d79314SDaniel Grumberg       },
36128d79314SDaniel Grumberg       "pathComponents": [
36228d79314SDaniel Grumberg         "Color",
36328d79314SDaniel Grumberg         "Alpha"
36428d79314SDaniel Grumberg       ]
3655bb5704cSZixu Wang     }
3665bb5704cSZixu Wang   ]
3675bb5704cSZixu Wang }
368