1// RUN: rm -rf %t
2// RUN: split-file %s %t
3// RUN: sed -e "s@INPUT_DIR@%/t@g" %t/reference.output.json.in >> \
4// RUN: %t/reference.output.json
5// RUN: %clang -extract-api -x objective-c-header -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@protocol Protocol
18@end
19
20@protocol AnotherProtocol <Protocol>
21@end
22
23//--- reference.output.json.in
24{
25  "metadata": {
26    "formatVersion": {
27      "major": 0,
28      "minor": 5,
29      "patch": 3
30    },
31    "generator": "?"
32  },
33  "module": {
34    "name": "",
35    "platform": {
36      "architecture": "arm64",
37      "operatingSystem": {
38        "minimumVersion": {
39          "major": 11,
40          "minor": 0,
41          "patch": 0
42        },
43        "name": "macosx"
44      },
45      "vendor": "apple"
46    }
47  },
48  "relationships": [
49    {
50      "kind": "conformsTo",
51      "source": "c:objc(pl)AnotherProtocol",
52      "target": "c:objc(pl)Protocol"
53    }
54  ],
55  "symbols": [
56    {
57      "accessLevel": "public",
58      "declarationFragments": [
59        {
60          "kind": "keyword",
61          "spelling": "@protocol"
62        },
63        {
64          "kind": "text",
65          "spelling": " "
66        },
67        {
68          "kind": "identifier",
69          "spelling": "Protocol"
70        }
71      ],
72      "identifier": {
73        "interfaceLanguage": "objective-c",
74        "precise": "c:objc(pl)Protocol"
75      },
76      "kind": {
77        "displayName": "Protocol",
78        "identifier": "objective-c.protocol"
79      },
80      "location": {
81        "position": {
82          "character": 11,
83          "line": 1
84        },
85        "uri": "file://INPUT_DIR/input.h"
86      },
87      "names": {
88        "subHeading": [
89          {
90            "kind": "identifier",
91            "spelling": "Protocol"
92          }
93        ],
94        "title": "Protocol"
95      },
96      "pathComponents": [
97        "Protocol"
98      ]
99    },
100    {
101      "accessLevel": "public",
102      "declarationFragments": [
103        {
104          "kind": "keyword",
105          "spelling": "@protocol"
106        },
107        {
108          "kind": "text",
109          "spelling": " "
110        },
111        {
112          "kind": "identifier",
113          "spelling": "AnotherProtocol"
114        },
115        {
116          "kind": "text",
117          "spelling": " <"
118        },
119        {
120          "kind": "typeIdentifier",
121          "preciseIdentifier": "c:objc(pl)Protocol",
122          "spelling": "Protocol"
123        },
124        {
125          "kind": "text",
126          "spelling": ">"
127        }
128      ],
129      "identifier": {
130        "interfaceLanguage": "objective-c",
131        "precise": "c:objc(pl)AnotherProtocol"
132      },
133      "kind": {
134        "displayName": "Protocol",
135        "identifier": "objective-c.protocol"
136      },
137      "location": {
138        "position": {
139          "character": 11,
140          "line": 4
141        },
142        "uri": "file://INPUT_DIR/input.h"
143      },
144      "names": {
145        "subHeading": [
146          {
147            "kind": "identifier",
148            "spelling": "AnotherProtocol"
149          }
150        ],
151        "title": "AnotherProtocol"
152      },
153      "pathComponents": [
154        "AnotherProtocol"
155      ]
156    }
157  ]
158}
159