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 "relationhips": [], 51 "symbols": [ 52 { 53 "declarationFragments": [ 54 { 55 "kind": "typeIdentifier", 56 "preciseIdentifier": "c:v", 57 "spelling": "void" 58 }, 59 { 60 "kind": "text", 61 "spelling": " " 62 }, 63 { 64 "kind": "identifier", 65 "spelling": "foo" 66 }, 67 { 68 "kind": "text", 69 "spelling": "()" 70 } 71 ], 72 "identifier": { 73 "interfaceLanguage": "objective-c", 74 "precise": "c:@F@foo" 75 }, 76 "kind": { 77 "displayName": "Function", 78 "identifier": "objective-c.func" 79 }, 80 "location": { 81 "character": 1, 82 "line": 3, 83 "uri": "file://INPUT_DIR/input.h" 84 }, 85 "names": { 86 "subHeading": [ 87 { 88 "kind": "identifier", 89 "spelling": "foo" 90 } 91 ], 92 "title": "foo" 93 }, 94 "parameters": { 95 "returns": [ 96 { 97 "kind": "typeIdentifier", 98 "preciseIdentifier": "c:v", 99 "spelling": "void" 100 } 101 ] 102 } 103 }, 104 { 105 "declarationFragments": [ 106 { 107 "kind": "typeIdentifier", 108 "preciseIdentifier": "c:v", 109 "spelling": "void" 110 }, 111 { 112 "kind": "text", 113 "spelling": " " 114 }, 115 { 116 "kind": "identifier", 117 "spelling": "bar" 118 }, 119 { 120 "kind": "text", 121 "spelling": "(" 122 }, 123 { 124 "kind": "keyword", 125 "spelling": "const" 126 }, 127 { 128 "kind": "text", 129 "spelling": " " 130 }, 131 { 132 "kind": "typeIdentifier", 133 "preciseIdentifier": "c:I", 134 "spelling": "int" 135 }, 136 { 137 "kind": "text", 138 "spelling": " *" 139 }, 140 { 141 "kind": "internalParam", 142 "spelling": "" 143 }, 144 { 145 "kind": "text", 146 "spelling": ", " 147 }, 148 { 149 "kind": "typeIdentifier", 150 "preciseIdentifier": "c:i", 151 "spelling": "unsigned int" 152 }, 153 { 154 "kind": "text", 155 "spelling": " " 156 }, 157 { 158 "kind": "internalParam", 159 "spelling": "" 160 }, 161 { 162 "kind": "text", 163 "spelling": ")" 164 } 165 ], 166 "identifier": { 167 "interfaceLanguage": "objective-c", 168 "precise": "c:@F@bar" 169 }, 170 "kind": { 171 "displayName": "Function", 172 "identifier": "objective-c.func" 173 }, 174 "location": { 175 "character": 1, 176 "line": 4, 177 "uri": "file://INPUT_DIR/input.h" 178 }, 179 "names": { 180 "subHeading": [ 181 { 182 "kind": "identifier", 183 "spelling": "bar" 184 } 185 ], 186 "title": "bar" 187 }, 188 "parameters": { 189 "parameters": [ 190 { 191 "declarationFragments": [ 192 { 193 "kind": "keyword", 194 "spelling": "const" 195 }, 196 { 197 "kind": "text", 198 "spelling": " " 199 }, 200 { 201 "kind": "typeIdentifier", 202 "preciseIdentifier": "c:I", 203 "spelling": "int" 204 }, 205 { 206 "kind": "text", 207 "spelling": " *" 208 }, 209 { 210 "kind": "internalParam", 211 "spelling": "" 212 } 213 ], 214 "name": "" 215 }, 216 { 217 "declarationFragments": [ 218 { 219 "kind": "typeIdentifier", 220 "preciseIdentifier": "c:i", 221 "spelling": "unsigned int" 222 }, 223 { 224 "kind": "text", 225 "spelling": " " 226 }, 227 { 228 "kind": "internalParam", 229 "spelling": "" 230 } 231 ], 232 "name": "" 233 } 234 ], 235 "returns": [ 236 { 237 "kind": "typeIdentifier", 238 "preciseIdentifier": "c:v", 239 "spelling": "void" 240 } 241 ] 242 } 243 }, 244 { 245 "declarationFragments": [ 246 { 247 "kind": "keyword", 248 "spelling": "#define" 249 }, 250 { 251 "kind": "text", 252 "spelling": " " 253 }, 254 { 255 "kind": "identifier", 256 "spelling": "HELLO" 257 } 258 ], 259 "identifier": { 260 "interfaceLanguage": "objective-c", 261 "precise": "c:input.h@8@macro@HELLO" 262 }, 263 "kind": { 264 "displayName": "Macro", 265 "identifier": "objective-c.macro" 266 }, 267 "location": { 268 "character": 9, 269 "line": 1, 270 "uri": "file://INPUT_DIR/input.h" 271 }, 272 "names": { 273 "subHeading": [ 274 { 275 "kind": "identifier", 276 "spelling": "HELLO" 277 } 278 ], 279 "title": "HELLO" 280 } 281 } 282 ] 283 } 284