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 --product-name=Macros -target arm64-apple-macosx \ 6 // RUN: -x objective-c-header %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 #define HELLO 1 18 #define FUNC_GEN(NAME, ...) void NAME(__VA_ARGS__); 19 FUNC_GEN(foo) 20 FUNC_GEN(bar, const int *, unsigned); 21 #undef FUNC_GEN 22 // Undefining a not previously defined macro should not result in a crash. 23 #undef FOO 24 25 //--- reference.output.json.in 26 { 27 "metadata": { 28 "formatVersion": { 29 "major": 0, 30 "minor": 5, 31 "patch": 3 32 }, 33 "generator": "?" 34 }, 35 "module": { 36 "name": "Macros", 37 "platform": { 38 "architecture": "arm64", 39 "operatingSystem": { 40 "minimumVersion": { 41 "major": 11, 42 "minor": 0, 43 "patch": 0 44 }, 45 "name": "macosx" 46 }, 47 "vendor": "apple" 48 } 49 }, 50 "relationships": [], 51 "symbols": [ 52 { 53 "accessLevel": "public", 54 "declarationFragments": [ 55 { 56 "kind": "typeIdentifier", 57 "preciseIdentifier": "c:v", 58 "spelling": "void" 59 }, 60 { 61 "kind": "text", 62 "spelling": " " 63 }, 64 { 65 "kind": "identifier", 66 "spelling": "foo" 67 }, 68 { 69 "kind": "text", 70 "spelling": "()" 71 } 72 ], 73 "functionSignature": { 74 "returns": [ 75 { 76 "kind": "typeIdentifier", 77 "preciseIdentifier": "c:v", 78 "spelling": "void" 79 } 80 ] 81 }, 82 "identifier": { 83 "interfaceLanguage": "objective-c", 84 "precise": "c:@F@foo" 85 }, 86 "kind": { 87 "displayName": "Function", 88 "identifier": "objective-c.func" 89 }, 90 "location": { 91 "position": { 92 "character": 1, 93 "line": 3 94 }, 95 "uri": "file://INPUT_DIR/input.h" 96 }, 97 "names": { 98 "subHeading": [ 99 { 100 "kind": "identifier", 101 "spelling": "foo" 102 } 103 ], 104 "title": "foo" 105 }, 106 "pathComponents": [ 107 "foo" 108 ] 109 }, 110 { 111 "accessLevel": "public", 112 "declarationFragments": [ 113 { 114 "kind": "typeIdentifier", 115 "preciseIdentifier": "c:v", 116 "spelling": "void" 117 }, 118 { 119 "kind": "text", 120 "spelling": " " 121 }, 122 { 123 "kind": "identifier", 124 "spelling": "bar" 125 }, 126 { 127 "kind": "text", 128 "spelling": "(" 129 }, 130 { 131 "kind": "keyword", 132 "spelling": "const" 133 }, 134 { 135 "kind": "text", 136 "spelling": " " 137 }, 138 { 139 "kind": "typeIdentifier", 140 "preciseIdentifier": "c:I", 141 "spelling": "int" 142 }, 143 { 144 "kind": "text", 145 "spelling": " *" 146 }, 147 { 148 "kind": "internalParam", 149 "spelling": "" 150 }, 151 { 152 "kind": "text", 153 "spelling": ", " 154 }, 155 { 156 "kind": "typeIdentifier", 157 "preciseIdentifier": "c:i", 158 "spelling": "unsigned int" 159 }, 160 { 161 "kind": "text", 162 "spelling": " " 163 }, 164 { 165 "kind": "internalParam", 166 "spelling": "" 167 }, 168 { 169 "kind": "text", 170 "spelling": ")" 171 } 172 ], 173 "functionSignature": { 174 "parameters": [ 175 { 176 "declarationFragments": [ 177 { 178 "kind": "keyword", 179 "spelling": "const" 180 }, 181 { 182 "kind": "text", 183 "spelling": " " 184 }, 185 { 186 "kind": "typeIdentifier", 187 "preciseIdentifier": "c:I", 188 "spelling": "int" 189 }, 190 { 191 "kind": "text", 192 "spelling": " *" 193 }, 194 { 195 "kind": "internalParam", 196 "spelling": "" 197 } 198 ], 199 "name": "" 200 }, 201 { 202 "declarationFragments": [ 203 { 204 "kind": "typeIdentifier", 205 "preciseIdentifier": "c:i", 206 "spelling": "unsigned int" 207 }, 208 { 209 "kind": "text", 210 "spelling": " " 211 }, 212 { 213 "kind": "internalParam", 214 "spelling": "" 215 } 216 ], 217 "name": "" 218 } 219 ], 220 "returns": [ 221 { 222 "kind": "typeIdentifier", 223 "preciseIdentifier": "c:v", 224 "spelling": "void" 225 } 226 ] 227 }, 228 "identifier": { 229 "interfaceLanguage": "objective-c", 230 "precise": "c:@F@bar" 231 }, 232 "kind": { 233 "displayName": "Function", 234 "identifier": "objective-c.func" 235 }, 236 "location": { 237 "position": { 238 "character": 1, 239 "line": 4 240 }, 241 "uri": "file://INPUT_DIR/input.h" 242 }, 243 "names": { 244 "subHeading": [ 245 { 246 "kind": "identifier", 247 "spelling": "bar" 248 } 249 ], 250 "title": "bar" 251 }, 252 "pathComponents": [ 253 "bar" 254 ] 255 }, 256 { 257 "accessLevel": "public", 258 "declarationFragments": [ 259 { 260 "kind": "keyword", 261 "spelling": "#define" 262 }, 263 { 264 "kind": "text", 265 "spelling": " " 266 }, 267 { 268 "kind": "identifier", 269 "spelling": "HELLO" 270 } 271 ], 272 "identifier": { 273 "interfaceLanguage": "objective-c", 274 "precise": "c:input.h@8@macro@HELLO" 275 }, 276 "kind": { 277 "displayName": "Macro", 278 "identifier": "objective-c.macro" 279 }, 280 "location": { 281 "position": { 282 "character": 9, 283 "line": 1 284 }, 285 "uri": "file://INPUT_DIR/input.h" 286 }, 287 "names": { 288 "subHeading": [ 289 { 290 "kind": "identifier", 291 "spelling": "HELLO" 292 } 293 ], 294 "title": "HELLO" 295 }, 296 "pathComponents": [ 297 "HELLO" 298 ] 299 } 300 ] 301 } 302