2 // RUN: %clang_cc1 -extract-api --pretty-sgf --emit-sgf-symbol-labels-for-testing --product-name=Macros -triple arm64-apple-macosx \
3 // RUN: -isystem %S -x objective-c-header %s -o %t/output.symbols.json
5 // RUN: FileCheck %s --input-file %t/output.symbols.json --check-prefix HELLO
7 // HELLO-LABEL: "!testLabel": "c:@macro@HELLO"
8 // HELLO: "accessLevel": "public",
9 // HELLO-NEXT: "declarationFragments": [
11 // HELLO-NEXT: "kind": "keyword",
12 // HELLO-NEXT: "spelling": "#define"
15 // HELLO-NEXT: "kind": "text",
16 // HELLO-NEXT: "spelling": " "
19 // HELLO-NEXT: "kind": "identifier",
20 // HELLO-NEXT: "spelling": "HELLO"
24 // HELLO-NEXT: "displayName": "Macro",
25 // HELLO-NEXT: "identifier": "objective-c.macro"
27 // HELLO-NEXT: "location": {
28 // HELLO-NEXT: "position": {
29 // HELLO-NEXT: "character": 8,
30 // HELLO-NEXT: "line": [[# @LINE - 25]]
32 // HELLO-NEXT: "uri": "file://{{.*}}/macros.c"
34 // HELLO-NEXT: "names": {
35 // HELLO-NEXT: "navigator": [
37 // HELLO-NEXT: "kind": "identifier",
38 // HELLO-NEXT: "spelling": "HELLO"
41 // HELLO-NEXT: "subHeading": [
43 // HELLO-NEXT: "kind": "identifier",
44 // HELLO-NEXT: "spelling": "HELLO"
47 // HELLO-NEXT: "title": "HELLO"
49 // HELLO-NEXT: "pathComponents": [
50 // HELLO-NEXT: "HELLO"
53 // RUN: FileCheck %s --input-file %t/output.symbols.json --check-prefix WORLD
55 // WORLD-LABEL: "!testLabel": "c:@macro@WORLD"
56 // WORLD: "accessLevel": "public",
57 // WORLD-NEXT: "declarationFragments": [
59 // WORLD-NEXT: "kind": "keyword",
60 // WORLD-NEXT: "spelling": "#define"
63 // WORLD-NEXT: "kind": "text",
64 // WORLD-NEXT: "spelling": " "
67 // WORLD-NEXT: "kind": "identifier",
68 // WORLD-NEXT: "spelling": "WORLD"
72 // WORLD-NEXT: "displayName": "Macro",
73 // WORLD-NEXT: "identifier": "objective-c.macro"
75 // WORLD-NEXT: "location": {
76 // WORLD-NEXT: "position": {
77 // WORLD-NEXT: "character": 8,
78 // WORLD-NEXT: "line": [[# @LINE - 25]]
80 // WORLD-NEXT: "uri": "file://{{.*}}/macros.c"
82 // WORLD-NEXT: "names": {
83 // WORLD-NEXT: "navigator": [
85 // WORLD-NEXT: "kind": "identifier",
86 // WORLD-NEXT: "spelling": "WORLD"
89 // WORLD-NEXT: "subHeading": [
91 // WORLD-NEXT: "kind": "identifier",
92 // WORLD-NEXT: "spelling": "WORLD"
95 // WORLD-NEXT: "title": "WORLD"
97 // WORLD-NEXT: "pathComponents": [
98 // WORLD-NEXT: "WORLD"
101 // RUN: FileCheck %s --input-file %t/output.symbols.json --check-prefix MACRO_FUN
102 #define MACRO_FUN(x) x x
103 // MACRO_FUN-LABEL: "!testLabel": "c:@macro@MACRO_FUN"
104 // MACRO_FUN-NEXT: "accessLevel": "public",
105 // MACRO_FUN-NEXT: "declarationFragments": [
107 // MACRO_FUN-NEXT: "kind": "keyword",
108 // MACRO_FUN-NEXT: "spelling": "#define"
109 // MACRO_FUN-NEXT: },
111 // MACRO_FUN-NEXT: "kind": "text",
112 // MACRO_FUN-NEXT: "spelling": " "
113 // MACRO_FUN-NEXT: },
115 // MACRO_FUN-NEXT: "kind": "identifier",
116 // MACRO_FUN-NEXT: "spelling": "MACRO_FUN"
117 // MACRO_FUN-NEXT: },
119 // MACRO_FUN-NEXT: "kind": "text",
120 // MACRO_FUN-NEXT: "spelling": "("
121 // MACRO_FUN-NEXT: },
123 // MACRO_FUN-NEXT: "kind": "internalParam",
124 // MACRO_FUN-NEXT: "spelling": "x"
125 // MACRO_FUN-NEXT: },
127 // MACRO_FUN-NEXT: "kind": "text",
128 // MACRO_FUN-NEXT: "spelling": ")"
130 // MACRO_FUN-NEXT: ],
131 // MACRO_FUN: "kind": {
132 // MACRO_FUN-NEXT: "displayName": "Macro",
133 // MACRO_FUN-NEXT: "identifier": "objective-c.macro"
134 // MACRO_FUN-NEXT: },
135 // MACRO_FUN-NEXT: "location": {
136 // MACRO_FUN-NEXT: "position": {
137 // MACRO_FUN-NEXT: "character": 8,
138 // MACRO_FUN-NEXT: "line": [[# @LINE - 37]]
139 // MACRO_FUN-NEXT: },
140 // MACRO_FUN-NEXT: "uri": "file://{{.*}}/macros.c"
141 // MACRO_FUN-NEXT: },
142 // MACRO_FUN-NEXT: "names": {
143 // MACRO_FUN-NEXT: "navigator": [
145 // MACRO_FUN-NEXT: "kind": "identifier",
146 // MACRO_FUN-NEXT: "spelling": "MACRO_FUN"
148 // MACRO_FUN-NEXT: ],
149 // MACRO_FUN-NEXT: "subHeading": [
151 // MACRO_FUN-NEXT: "kind": "identifier",
152 // MACRO_FUN-NEXT: "spelling": "MACRO_FUN"
154 // MACRO_FUN-NEXT: ],
155 // MACRO_FUN-NEXT: "title": "MACRO_FUN"
156 // MACRO_FUN-NEXT: },
157 // MACRO_FUN-NEXT: "pathComponents": [
158 // MACRO_FUN-NEXT: "MACRO_FUN"
161 // RUN: FileCheck %s --input-file %t/output.symbols.json --check-prefix FUN
162 #define FUN(x, y, z) x + y + z
163 // FUN-LABEL: "!testLabel": "c:@macro@FUN"
164 // FUN-NEXT: "accessLevel": "public",
165 // FUN-NEXT: "declarationFragments": [
167 // FUN-NEXT: "kind": "keyword",
168 // FUN-NEXT: "spelling": "#define"
171 // FUN-NEXT: "kind": "text",
172 // FUN-NEXT: "spelling": " "
175 // FUN-NEXT: "kind": "identifier",
176 // FUN-NEXT: "spelling": "FUN"
179 // FUN-NEXT: "kind": "text",
180 // FUN-NEXT: "spelling": "("
183 // FUN-NEXT: "kind": "internalParam",
184 // FUN-NEXT: "spelling": "x"
187 // FUN-NEXT: "kind": "text",
188 // FUN-NEXT: "spelling": ", "
191 // FUN-NEXT: "kind": "internalParam",
192 // FUN-NEXT: "spelling": "y"
195 // FUN-NEXT: "kind": "text",
196 // FUN-NEXT: "spelling": ", "
199 // FUN-NEXT: "kind": "internalParam",
200 // FUN-NEXT: "spelling": "z"
203 // FUN-NEXT: "kind": "text",
204 // FUN-NEXT: "spelling": ")"
208 // FUN-NEXT: "displayName": "Macro",
209 // FUN-NEXT: "identifier": "objective-c.macro"
211 // FUN-NEXT: "location": {
212 // FUN-NEXT: "position": {
213 // FUN-NEXT: "character": 8,
214 // FUN-NEXT: "line": [[# @LINE - 53]]
216 // FUN-NEXT: "uri": "file://{{.*}}/macros.c"
218 // FUN-NEXT: "names": {
219 // FUN-NEXT: "navigator": [
221 // FUN-NEXT: "kind": "identifier",
222 // FUN-NEXT: "spelling": "FUN"
225 // FUN-NEXT: "subHeading": [
227 // FUN-NEXT: "kind": "identifier",
228 // FUN-NEXT: "spelling": "FUN"
231 // FUN-NEXT: "title": "FUN"
233 // FUN-NEXT: "pathComponents": [
237 // RUN: FileCheck %s --input-file %t/output.symbols.json --check-prefix FUNC99
238 #define FUNC99(x, ...)
239 // FUNC99-LABEL: "!testLabel": "c:@macro@FUNC99"
240 // FUNC99-NEXT: "accessLevel": "public",
241 // FUNC99-NEXT: "declarationFragments": [
243 // FUNC99-NEXT: "kind": "keyword",
244 // FUNC99-NEXT: "spelling": "#define"
247 // FUNC99-NEXT: "kind": "text",
248 // FUNC99-NEXT: "spelling": " "
251 // FUNC99-NEXT: "kind": "identifier",
252 // FUNC99-NEXT: "spelling": "FUNC99"
255 // FUNC99-NEXT: "kind": "text",
256 // FUNC99-NEXT: "spelling": "("
259 // FUNC99-NEXT: "kind": "internalParam",
260 // FUNC99-NEXT: "spelling": "x"
263 // FUNC99-NEXT: "kind": "text",
264 // FUNC99-NEXT: "spelling": ", ...)"
268 // FUNC99-NEXT: "displayName": "Macro",
269 // FUNC99-NEXT: "identifier": "objective-c.macro"
271 // FUNC99-NEXT: "location": {
272 // FUNC99-NEXT: "position": {
273 // FUNC99-NEXT: "character": 8,
274 // FUNC99-NEXT: "line": [[# @LINE - 37]]
276 // FUNC99-NEXT: "uri": "file://{{.*}}/macros.c"
278 // FUNC99-NEXT: "names": {
279 // FUNC99-NEXT: "navigator": [
281 // FUNC99-NEXT: "kind": "identifier",
282 // FUNC99-NEXT: "spelling": "FUNC99"
285 // FUNC99-NEXT: "subHeading": [
287 // FUNC99-NEXT: "kind": "identifier",
288 // FUNC99-NEXT: "spelling": "FUNC99"
291 // FUNC99-NEXT: "title": "FUNC99"
293 // FUNC99-NEXT: "pathComponents": [
294 // FUNC99-NEXT: "FUNC99"
297 // RUN: FileCheck %s --input-file %t/output.symbols.json --check-prefix FUNGNU
299 // FUNGNU-LABEL: "!testLabel": "c:@macro@FUNGNU"
300 // FUNGNU-NEXT: "accessLevel": "public",
301 // FUNGNU-NEXT: "declarationFragments": [
303 // FUNGNU-NEXT: "kind": "keyword",
304 // FUNGNU-NEXT: "spelling": "#define"
307 // FUNGNU-NEXT: "kind": "text",
308 // FUNGNU-NEXT: "spelling": " "
311 // FUNGNU-NEXT: "kind": "identifier",
312 // FUNGNU-NEXT: "spelling": "FUNGNU"
315 // FUNGNU-NEXT: "kind": "text",
316 // FUNGNU-NEXT: "spelling": "("
319 // FUNGNU-NEXT: "kind": "internalParam",
320 // FUNGNU-NEXT: "spelling": "x"
323 // FUNGNU-NEXT: "kind": "text",
324 // FUNGNU-NEXT: "spelling": "...)"
328 // FUNGNU-NEXT: "displayName": "Macro",
329 // FUNGNU-NEXT: "identifier": "objective-c.macro"
331 // FUNGNU-NEXT: "location": {
332 // FUNGNU-NEXT: "position": {
333 // FUNGNU-NEXT: "character": 8,
334 // FUNGNU-NEXT: "line": [[# @LINE - 37]]
336 // FUNGNU-NEXT: "uri": "file://{{.*}}/macros.c"
338 // FUNGNU-NEXT: "names": {
339 // FUNGNU-NEXT: "navigator": [
341 // FUNGNU-NEXT: "kind": "identifier",
342 // FUNGNU-NEXT: "spelling": "FUNGNU"
345 // FUNGNU-NEXT: "subHeading": [
347 // FUNGNU-NEXT: "kind": "identifier",
348 // FUNGNU-NEXT: "spelling": "FUNGNU"
351 // FUNGNU-NEXT: "title": "FUNGNU"
353 // FUNGNU-NEXT: "pathComponents": [
354 // FUNGNU-NEXT: "FUNGNU"
357 // expected-no-diagnostics