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