1 // RUN: rm -rf %t
2 // RUN: split-file %s %t
3 // RUN: sed -e "s@INPUT_DIR@%/t@g" %t/c.reference.output.json.in >> \
4 // RUN: %t/c.reference.output.json
5 // RUN: sed -e "s@INPUT_DIR@%/t@g" %t/objc.reference.output.json.in >> \
6 // RUN: %t/objc.reference.output.json
7 
8 // RUN: %clang -extract-api -x c-header -target arm64-apple-macosx \
9 // RUN: %t/c.h -o %t/c.output.json | FileCheck -allow-empty %s
10 // RUN: %clang -extract-api -x objective-c-header -target arm64-apple-macosx \
11 // RUN: %t/objc.h -o %t/objc.output.json | FileCheck -allow-empty %s
12 
13 // Generator version is not consistent across test runs, normalize it.
14 // RUN: sed -e "s@\"generator\": \".*\"@\"generator\": \"?\"@g" \
15 // RUN: %t/c.output.json >> %t/c.output-normalized.json
16 // RUN: sed -e "s@\"generator\": \".*\"@\"generator\": \"?\"@g" \
17 // RUN: %t/objc.output.json >> %t/objc.output-normalized.json
18 
19 // RUN: diff %t/c.reference.output.json %t/c.output-normalized.json
20 // RUN: diff %t/objc.reference.output.json %t/objc.output-normalized.json
21 
22 // CHECK-NOT: error:
23 // CHECK-NOT: warning:
24 
25 //--- c.h
26 char c;
27 
28 //--- objc.h
29 char objc;
30 
31 //--- c.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": "",
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   "relationhips": [],
57   "symbols": [
58     {
59       "declarationFragments": [
60         {
61           "kind": "typeIdentifier",
62           "preciseIdentifier": "c:C",
63           "spelling": "char"
64         },
65         {
66           "kind": "text",
67           "spelling": " "
68         },
69         {
70           "kind": "identifier",
71           "spelling": "c"
72         }
73       ],
74       "identifier": {
75         "interfaceLanguage": "c",
76         "precise": "c:@c"
77       },
78       "kind": {
79         "displayName": "Global Variable",
80         "identifier": "c.var"
81       },
82       "location": {
83         "character": 6,
84         "line": 1,
85         "uri": "file://INPUT_DIR/c.h"
86       },
87       "names": {
88         "subHeading": [
89           {
90             "kind": "identifier",
91             "spelling": "c"
92           }
93         ],
94         "title": "c"
95       }
96     }
97   ]
98 }
99 //--- objc.reference.output.json.in
100 {
101   "metadata": {
102     "formatVersion": {
103       "major": 0,
104       "minor": 5,
105       "patch": 3
106     },
107     "generator": "?"
108   },
109   "module": {
110     "name": "",
111     "platform": {
112       "architecture": "arm64",
113       "operatingSystem": {
114         "minimumVersion": {
115           "major": 11,
116           "minor": 0,
117           "patch": 0
118         },
119         "name": "macosx"
120       },
121       "vendor": "apple"
122     }
123   },
124   "relationhips": [],
125   "symbols": [
126     {
127       "declarationFragments": [
128         {
129           "kind": "typeIdentifier",
130           "preciseIdentifier": "c:C",
131           "spelling": "char"
132         },
133         {
134           "kind": "text",
135           "spelling": " "
136         },
137         {
138           "kind": "identifier",
139           "spelling": "objc"
140         }
141       ],
142       "identifier": {
143         "interfaceLanguage": "objective-c",
144         "precise": "c:@objc"
145       },
146       "kind": {
147         "displayName": "Global Variable",
148         "identifier": "objective-c.var"
149       },
150       "location": {
151         "character": 6,
152         "line": 1,
153         "uri": "file://INPUT_DIR/objc.h"
154       },
155       "names": {
156         "subHeading": [
157           {
158             "kind": "identifier",
159             "spelling": "objc"
160           }
161         ],
162         "title": "objc"
163       }
164     }
165   ]
166 }
167