Details | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 14 | pmbaty | 1 | /*===- TableGen'erated file -------------------------------------*- C++ -*-===*\ |
| 2 | |* *| |
||
| 3 | |* Helper classes for BasicReaders *| |
||
| 4 | |* *| |
||
| 5 | |* Automatically generated file, do not edit! *| |
||
| 6 | |* *| |
||
| 7 | \*===----------------------------------------------------------------------===*/ |
||
| 8 | |||
| 9 | template <class ValueType> |
||
| 10 | struct ReadDispatcher; |
||
| 11 | template <> |
||
| 12 | struct ReadDispatcher<llvm::APInt> { |
||
| 13 | template <class BasicReader, class... Args> |
||
| 14 | static llvm::APInt read(BasicReader &R, Args &&... args) { |
||
| 15 | return R.readAPInt(std::forward<Args>(args)...); |
||
| 16 | } |
||
| 17 | }; |
||
| 18 | template <> |
||
| 19 | struct ReadDispatcher<llvm::APSInt> { |
||
| 20 | template <class BasicReader, class... Args> |
||
| 21 | static llvm::APSInt read(BasicReader &R, Args &&... args) { |
||
| 22 | return R.readAPSInt(std::forward<Args>(args)...); |
||
| 23 | } |
||
| 24 | }; |
||
| 25 | template <> |
||
| 26 | struct ReadDispatcher<APValue> { |
||
| 27 | template <class BasicReader, class... Args> |
||
| 28 | static APValue read(BasicReader &R, Args &&... args) { |
||
| 29 | return R.readAPValue(std::forward<Args>(args)...); |
||
| 30 | } |
||
| 31 | }; |
||
| 32 | template <> |
||
| 33 | struct ReadDispatcher<APValue::ValueKind> { |
||
| 34 | template <class BasicReader, class... Args> |
||
| 35 | static APValue::ValueKind read(BasicReader &R, Args &&... args) { |
||
| 36 | return R.readAPValueKind(std::forward<Args>(args)...); |
||
| 37 | } |
||
| 38 | }; |
||
| 39 | template <> |
||
| 40 | struct ReadDispatcher<ArrayType::ArraySizeModifier> { |
||
| 41 | template <class BasicReader, class... Args> |
||
| 42 | static ArrayType::ArraySizeModifier read(BasicReader &R, Args &&... args) { |
||
| 43 | return R.readArraySizeModifier(std::forward<Args>(args)...); |
||
| 44 | } |
||
| 45 | }; |
||
| 46 | template <> |
||
| 47 | struct ReadDispatcher<attr::Kind> { |
||
| 48 | template <class BasicReader, class... Args> |
||
| 49 | static attr::Kind read(BasicReader &R, Args &&... args) { |
||
| 50 | return R.readAttrKind(std::forward<Args>(args)...); |
||
| 51 | } |
||
| 52 | }; |
||
| 53 | template <> |
||
| 54 | struct ReadDispatcher<AutoTypeKeyword> { |
||
| 55 | template <class BasicReader, class... Args> |
||
| 56 | static AutoTypeKeyword read(BasicReader &R, Args &&... args) { |
||
| 57 | return R.readAutoTypeKeyword(std::forward<Args>(args)...); |
||
| 58 | } |
||
| 59 | }; |
||
| 60 | template <> |
||
| 61 | struct ReadDispatcher<const BTFTypeTagAttr *> { |
||
| 62 | template <class BasicReader, class... Args> |
||
| 63 | static const BTFTypeTagAttr * read(BasicReader &R, Args &&... args) { |
||
| 64 | return R.readBTFTypeTagAttr(std::forward<Args>(args)...); |
||
| 65 | } |
||
| 66 | }; |
||
| 67 | template <> |
||
| 68 | struct ReadDispatcher<bool> { |
||
| 69 | template <class BasicReader, class... Args> |
||
| 70 | static bool read(BasicReader &R, Args &&... args) { |
||
| 71 | return R.readBool(std::forward<Args>(args)...); |
||
| 72 | } |
||
| 73 | }; |
||
| 74 | template <> |
||
| 75 | struct ReadDispatcher<BuiltinType::Kind> { |
||
| 76 | template <class BasicReader, class... Args> |
||
| 77 | static BuiltinType::Kind read(BasicReader &R, Args &&... args) { |
||
| 78 | return R.readBuiltinTypeKind(std::forward<Args>(args)...); |
||
| 79 | } |
||
| 80 | }; |
||
| 81 | template <> |
||
| 82 | struct ReadDispatcher<CXXRecordDecl*> { |
||
| 83 | template <class BasicReader, class... Args> |
||
| 84 | static CXXRecordDecl* read(BasicReader &R, Args &&... args) { |
||
| 85 | return R.readCXXRecordDeclRef(std::forward<Args>(args)...); |
||
| 86 | } |
||
| 87 | }; |
||
| 88 | template <> |
||
| 89 | struct ReadDispatcher<CallingConv> { |
||
| 90 | template <class BasicReader, class... Args> |
||
| 91 | static CallingConv read(BasicReader &R, Args &&... args) { |
||
| 92 | return R.readCallingConv(std::forward<Args>(args)...); |
||
| 93 | } |
||
| 94 | }; |
||
| 95 | template <> |
||
| 96 | struct ReadDispatcher<ConceptDecl*> { |
||
| 97 | template <class BasicReader, class... Args> |
||
| 98 | static ConceptDecl* read(BasicReader &R, Args &&... args) { |
||
| 99 | return R.readConceptDeclRef(std::forward<Args>(args)...); |
||
| 100 | } |
||
| 101 | }; |
||
| 102 | template <> |
||
| 103 | struct ReadDispatcher<Decl*> { |
||
| 104 | template <class BasicReader, class... Args> |
||
| 105 | static Decl* read(BasicReader &R, Args &&... args) { |
||
| 106 | return R.readDeclRef(std::forward<Args>(args)...); |
||
| 107 | } |
||
| 108 | }; |
||
| 109 | template <> |
||
| 110 | struct ReadDispatcher<DeclarationName> { |
||
| 111 | template <class BasicReader, class... Args> |
||
| 112 | static DeclarationName read(BasicReader &R, Args &&... args) { |
||
| 113 | return R.readDeclarationName(std::forward<Args>(args)...); |
||
| 114 | } |
||
| 115 | }; |
||
| 116 | template <> |
||
| 117 | struct ReadDispatcher<DeclarationName::NameKind> { |
||
| 118 | template <class BasicReader, class... Args> |
||
| 119 | static DeclarationName::NameKind read(BasicReader &R, Args &&... args) { |
||
| 120 | return R.readDeclarationNameKind(std::forward<Args>(args)...); |
||
| 121 | } |
||
| 122 | }; |
||
| 123 | template <> |
||
| 124 | struct ReadDispatcher<ElaboratedTypeKeyword> { |
||
| 125 | template <class BasicReader, class... Args> |
||
| 126 | static ElaboratedTypeKeyword read(BasicReader &R, Args &&... args) { |
||
| 127 | return R.readElaboratedTypeKeyword(std::forward<Args>(args)...); |
||
| 128 | } |
||
| 129 | }; |
||
| 130 | template <> |
||
| 131 | struct ReadDispatcher<FunctionProtoType::ExceptionSpecInfo> { |
||
| 132 | template <class BasicReader, class... Args> |
||
| 133 | static FunctionProtoType::ExceptionSpecInfo read(BasicReader &R, Args &&... args) { |
||
| 134 | return R.readExceptionSpecInfo(std::forward<Args>(args)...); |
||
| 135 | } |
||
| 136 | }; |
||
| 137 | template <> |
||
| 138 | struct ReadDispatcher<Expr*> { |
||
| 139 | template <class BasicReader, class... Args> |
||
| 140 | static Expr* read(BasicReader &R, Args &&... args) { |
||
| 141 | return R.readExprRef(std::forward<Args>(args)...); |
||
| 142 | } |
||
| 143 | }; |
||
| 144 | template <> |
||
| 145 | struct ReadDispatcher<FunctionProtoType::ExtParameterInfo> { |
||
| 146 | template <class BasicReader, class... Args> |
||
| 147 | static FunctionProtoType::ExtParameterInfo read(BasicReader &R, Args &&... args) { |
||
| 148 | return R.readExtParameterInfo(std::forward<Args>(args)...); |
||
| 149 | } |
||
| 150 | }; |
||
| 151 | template <> |
||
| 152 | struct ReadDispatcher<llvm::FixedPointSemantics> { |
||
| 153 | template <class BasicReader, class... Args> |
||
| 154 | static llvm::FixedPointSemantics read(BasicReader &R, Args &&... args) { |
||
| 155 | return R.readFixedPointSemantics(std::forward<Args>(args)...); |
||
| 156 | } |
||
| 157 | }; |
||
| 158 | template <> |
||
| 159 | struct ReadDispatcher<FunctionDecl*> { |
||
| 160 | template <class BasicReader, class... Args> |
||
| 161 | static FunctionDecl* read(BasicReader &R, Args &&... args) { |
||
| 162 | return R.readFunctionDeclRef(std::forward<Args>(args)...); |
||
| 163 | } |
||
| 164 | }; |
||
| 165 | template <> |
||
| 166 | struct ReadDispatcher<IdentifierInfo*> { |
||
| 167 | template <class BasicReader, class... Args> |
||
| 168 | static IdentifierInfo* read(BasicReader &R, Args &&... args) { |
||
| 169 | return R.readIdentifier(std::forward<Args>(args)...); |
||
| 170 | } |
||
| 171 | }; |
||
| 172 | template <> |
||
| 173 | struct ReadDispatcher<APValue::LValuePathEntry> { |
||
| 174 | template <class BasicReader, class... Args> |
||
| 175 | static APValue::LValuePathEntry read(BasicReader &R, Args &&... args) { |
||
| 176 | return R.readLValuePathEntry(std::forward<Args>(args)...); |
||
| 177 | } |
||
| 178 | }; |
||
| 179 | template <> |
||
| 180 | struct ReadDispatcher<APValue::LValuePathSerializationHelper> { |
||
| 181 | template <class BasicReader, class... Args> |
||
| 182 | static APValue::LValuePathSerializationHelper read(BasicReader &R, Args &&... args) { |
||
| 183 | return R.readLValuePathSerializationHelper(std::forward<Args>(args)...); |
||
| 184 | } |
||
| 185 | }; |
||
| 186 | template <> |
||
| 187 | struct ReadDispatcher<NamedDecl*> { |
||
| 188 | template <class BasicReader, class... Args> |
||
| 189 | static NamedDecl* read(BasicReader &R, Args &&... args) { |
||
| 190 | return R.readNamedDeclRef(std::forward<Args>(args)...); |
||
| 191 | } |
||
| 192 | }; |
||
| 193 | template <> |
||
| 194 | struct ReadDispatcher<NamespaceAliasDecl*> { |
||
| 195 | template <class BasicReader, class... Args> |
||
| 196 | static NamespaceAliasDecl* read(BasicReader &R, Args &&... args) { |
||
| 197 | return R.readNamespaceAliasDeclRef(std::forward<Args>(args)...); |
||
| 198 | } |
||
| 199 | }; |
||
| 200 | template <> |
||
| 201 | struct ReadDispatcher<NamespaceDecl*> { |
||
| 202 | template <class BasicReader, class... Args> |
||
| 203 | static NamespaceDecl* read(BasicReader &R, Args &&... args) { |
||
| 204 | return R.readNamespaceDeclRef(std::forward<Args>(args)...); |
||
| 205 | } |
||
| 206 | }; |
||
| 207 | template <> |
||
| 208 | struct ReadDispatcher<NestedNameSpecifier *> { |
||
| 209 | template <class BasicReader, class... Args> |
||
| 210 | static NestedNameSpecifier * read(BasicReader &R, Args &&... args) { |
||
| 211 | return R.readNestedNameSpecifier(std::forward<Args>(args)...); |
||
| 212 | } |
||
| 213 | }; |
||
| 214 | template <> |
||
| 215 | struct ReadDispatcher<NestedNameSpecifier::SpecifierKind> { |
||
| 216 | template <class BasicReader, class... Args> |
||
| 217 | static NestedNameSpecifier::SpecifierKind read(BasicReader &R, Args &&... args) { |
||
| 218 | return R.readNestedNameSpecifierKind(std::forward<Args>(args)...); |
||
| 219 | } |
||
| 220 | }; |
||
| 221 | template <> |
||
| 222 | struct ReadDispatcher<ObjCProtocolDecl*> { |
||
| 223 | template <class BasicReader, class... Args> |
||
| 224 | static ObjCProtocolDecl* read(BasicReader &R, Args &&... args) { |
||
| 225 | return R.readObjCProtocolDeclRef(std::forward<Args>(args)...); |
||
| 226 | } |
||
| 227 | }; |
||
| 228 | template <> |
||
| 229 | struct ReadDispatcher<ObjCTypeParamDecl*> { |
||
| 230 | template <class BasicReader, class... Args> |
||
| 231 | static ObjCTypeParamDecl* read(BasicReader &R, Args &&... args) { |
||
| 232 | return R.readObjCTypeParamDeclRef(std::forward<Args>(args)...); |
||
| 233 | } |
||
| 234 | }; |
||
| 235 | template <> |
||
| 236 | struct ReadDispatcher<OverloadedOperatorKind> { |
||
| 237 | template <class BasicReader, class... Args> |
||
| 238 | static OverloadedOperatorKind read(BasicReader &R, Args &&... args) { |
||
| 239 | return R.readOverloadedOperatorKind(std::forward<Args>(args)...); |
||
| 240 | } |
||
| 241 | }; |
||
| 242 | template <> |
||
| 243 | struct ReadDispatcher<QualType> { |
||
| 244 | template <class BasicReader, class... Args> |
||
| 245 | static QualType read(BasicReader &R, Args &&... args) { |
||
| 246 | return R.readQualType(std::forward<Args>(args)...); |
||
| 247 | } |
||
| 248 | }; |
||
| 249 | template <> |
||
| 250 | struct ReadDispatcher<Qualifiers> { |
||
| 251 | template <class BasicReader, class... Args> |
||
| 252 | static Qualifiers read(BasicReader &R, Args &&... args) { |
||
| 253 | return R.readQualifiers(std::forward<Args>(args)...); |
||
| 254 | } |
||
| 255 | }; |
||
| 256 | template <> |
||
| 257 | struct ReadDispatcher<RefQualifierKind> { |
||
| 258 | template <class BasicReader, class... Args> |
||
| 259 | static RefQualifierKind read(BasicReader &R, Args &&... args) { |
||
| 260 | return R.readRefQualifierKind(std::forward<Args>(args)...); |
||
| 261 | } |
||
| 262 | }; |
||
| 263 | template <> |
||
| 264 | struct ReadDispatcher<Selector> { |
||
| 265 | template <class BasicReader, class... Args> |
||
| 266 | static Selector read(BasicReader &R, Args &&... args) { |
||
| 267 | return R.readSelector(std::forward<Args>(args)...); |
||
| 268 | } |
||
| 269 | }; |
||
| 270 | template <> |
||
| 271 | struct ReadDispatcher<SourceLocation> { |
||
| 272 | template <class BasicReader, class... Args> |
||
| 273 | static SourceLocation read(BasicReader &R, Args &&... args) { |
||
| 274 | return R.readSourceLocation(std::forward<Args>(args)...); |
||
| 275 | } |
||
| 276 | }; |
||
| 277 | template <> |
||
| 278 | struct ReadDispatcher<Stmt*> { |
||
| 279 | template <class BasicReader, class... Args> |
||
| 280 | static Stmt* read(BasicReader &R, Args &&... args) { |
||
| 281 | return R.readStmtRef(std::forward<Args>(args)...); |
||
| 282 | } |
||
| 283 | }; |
||
| 284 | template <> |
||
| 285 | struct ReadDispatcher<TagDecl*> { |
||
| 286 | template <class BasicReader, class... Args> |
||
| 287 | static TagDecl* read(BasicReader &R, Args &&... args) { |
||
| 288 | return R.readTagDeclRef(std::forward<Args>(args)...); |
||
| 289 | } |
||
| 290 | }; |
||
| 291 | template <> |
||
| 292 | struct ReadDispatcher<TemplateArgument> { |
||
| 293 | template <class BasicReader, class... Args> |
||
| 294 | static TemplateArgument read(BasicReader &R, Args &&... args) { |
||
| 295 | return R.readTemplateArgument(std::forward<Args>(args)...); |
||
| 296 | } |
||
| 297 | }; |
||
| 298 | template <> |
||
| 299 | struct ReadDispatcher<TemplateArgument::ArgKind> { |
||
| 300 | template <class BasicReader, class... Args> |
||
| 301 | static TemplateArgument::ArgKind read(BasicReader &R, Args &&... args) { |
||
| 302 | return R.readTemplateArgumentKind(std::forward<Args>(args)...); |
||
| 303 | } |
||
| 304 | }; |
||
| 305 | template <> |
||
| 306 | struct ReadDispatcher<TemplateDecl*> { |
||
| 307 | template <class BasicReader, class... Args> |
||
| 308 | static TemplateDecl* read(BasicReader &R, Args &&... args) { |
||
| 309 | return R.readTemplateDeclRef(std::forward<Args>(args)...); |
||
| 310 | } |
||
| 311 | }; |
||
| 312 | template <> |
||
| 313 | struct ReadDispatcher<TemplateName> { |
||
| 314 | template <class BasicReader, class... Args> |
||
| 315 | static TemplateName read(BasicReader &R, Args &&... args) { |
||
| 316 | return R.readTemplateName(std::forward<Args>(args)...); |
||
| 317 | } |
||
| 318 | }; |
||
| 319 | template <> |
||
| 320 | struct ReadDispatcher<TemplateName::NameKind> { |
||
| 321 | template <class BasicReader, class... Args> |
||
| 322 | static TemplateName::NameKind read(BasicReader &R, Args &&... args) { |
||
| 323 | return R.readTemplateNameKind(std::forward<Args>(args)...); |
||
| 324 | } |
||
| 325 | }; |
||
| 326 | template <> |
||
| 327 | struct ReadDispatcher<TemplateTemplateParmDecl*> { |
||
| 328 | template <class BasicReader, class... Args> |
||
| 329 | static TemplateTemplateParmDecl* read(BasicReader &R, Args &&... args) { |
||
| 330 | return R.readTemplateTemplateParmDeclRef(std::forward<Args>(args)...); |
||
| 331 | } |
||
| 332 | }; |
||
| 333 | template <> |
||
| 334 | struct ReadDispatcher<TemplateTypeParmDecl*> { |
||
| 335 | template <class BasicReader, class... Args> |
||
| 336 | static TemplateTypeParmDecl* read(BasicReader &R, Args &&... args) { |
||
| 337 | return R.readTemplateTypeParmDeclRef(std::forward<Args>(args)...); |
||
| 338 | } |
||
| 339 | }; |
||
| 340 | template <> |
||
| 341 | struct ReadDispatcher<TypeOfKind> { |
||
| 342 | template <class BasicReader, class... Args> |
||
| 343 | static TypeOfKind read(BasicReader &R, Args &&... args) { |
||
| 344 | return R.readTypeOfKind(std::forward<Args>(args)...); |
||
| 345 | } |
||
| 346 | }; |
||
| 347 | template <> |
||
| 348 | struct ReadDispatcher<uint32_t> { |
||
| 349 | template <class BasicReader, class... Args> |
||
| 350 | static uint32_t read(BasicReader &R, Args &&... args) { |
||
| 351 | return R.readUInt32(std::forward<Args>(args)...); |
||
| 352 | } |
||
| 353 | }; |
||
| 354 | template <> |
||
| 355 | struct ReadDispatcher<uint64_t> { |
||
| 356 | template <class BasicReader, class... Args> |
||
| 357 | static uint64_t read(BasicReader &R, Args &&... args) { |
||
| 358 | return R.readUInt64(std::forward<Args>(args)...); |
||
| 359 | } |
||
| 360 | }; |
||
| 361 | template <> |
||
| 362 | struct ReadDispatcher<UnaryTransformType::UTTKind> { |
||
| 363 | template <class BasicReader, class... Args> |
||
| 364 | static UnaryTransformType::UTTKind read(BasicReader &R, Args &&... args) { |
||
| 365 | return R.readUnaryTypeTransformKind(std::forward<Args>(args)...); |
||
| 366 | } |
||
| 367 | }; |
||
| 368 | template <> |
||
| 369 | struct ReadDispatcher<UsingShadowDecl*> { |
||
| 370 | template <class BasicReader, class... Args> |
||
| 371 | static UsingShadowDecl* read(BasicReader &R, Args &&... args) { |
||
| 372 | return R.readUsingShadowDeclRef(std::forward<Args>(args)...); |
||
| 373 | } |
||
| 374 | }; |
||
| 375 | template <> |
||
| 376 | struct ReadDispatcher<ValueDecl*> { |
||
| 377 | template <class BasicReader, class... Args> |
||
| 378 | static ValueDecl* read(BasicReader &R, Args &&... args) { |
||
| 379 | return R.readValueDeclRef(std::forward<Args>(args)...); |
||
| 380 | } |
||
| 381 | }; |
||
| 382 | template <> |
||
| 383 | struct ReadDispatcher<VectorType::VectorKind> { |
||
| 384 | template <class BasicReader, class... Args> |
||
| 385 | static VectorType::VectorKind read(BasicReader &R, Args &&... args) { |
||
| 386 | return R.readVectorKind(std::forward<Args>(args)...); |
||
| 387 | } |
||
| 388 | }; |
||
| 389 | template <class T> |
||
| 390 | struct ReadDispatcher<llvm::ArrayRef<T>> { |
||
| 391 | template <class BasicReader, class... Args> |
||
| 392 | static llvm::ArrayRef<T> read(BasicReader &R, Args &&... args) { |
||
| 393 | return R.readArray(std::forward<Args>(args)...); |
||
| 394 | } |
||
| 395 | }; |
||
| 396 | template <class T> |
||
| 397 | struct ReadDispatcher<std::optional<T>> { |
||
| 398 | template <class BasicReader, class... Args> |
||
| 399 | static std::optional<T> read(BasicReader &R, Args &&... args) { |
||
| 400 | return R.readOptional(std::forward<Args>(args)...); |
||
| 401 | } |
||
| 402 | }; |
||
| 403 | |||
| 404 | template <class ValueType> |
||
| 405 | struct UnpackOptionalValue; |
||
| 406 | template <> |
||
| 407 | struct UnpackOptionalValue<CXXRecordDecl*> { |
||
| 408 | static std::optional<CXXRecordDecl*> unpack(CXXRecordDecl* value) { |
||
| 409 | return value ? std::optional<CXXRecordDecl*>(value) : std::nullopt; |
||
| 410 | } |
||
| 411 | }; |
||
| 412 | template <> |
||
| 413 | struct UnpackOptionalValue<ConceptDecl*> { |
||
| 414 | static std::optional<ConceptDecl*> unpack(ConceptDecl* value) { |
||
| 415 | return value ? std::optional<ConceptDecl*>(value) : std::nullopt; |
||
| 416 | } |
||
| 417 | }; |
||
| 418 | template <> |
||
| 419 | struct UnpackOptionalValue<Decl*> { |
||
| 420 | static std::optional<Decl*> unpack(Decl* value) { |
||
| 421 | return value ? std::optional<Decl*>(value) : std::nullopt; |
||
| 422 | } |
||
| 423 | }; |
||
| 424 | template <> |
||
| 425 | struct UnpackOptionalValue<Expr*> { |
||
| 426 | static std::optional<Expr*> unpack(Expr* value) { |
||
| 427 | return value ? std::optional<Expr*>(value) : std::nullopt; |
||
| 428 | } |
||
| 429 | }; |
||
| 430 | template <> |
||
| 431 | struct UnpackOptionalValue<FunctionDecl*> { |
||
| 432 | static std::optional<FunctionDecl*> unpack(FunctionDecl* value) { |
||
| 433 | return value ? std::optional<FunctionDecl*>(value) : std::nullopt; |
||
| 434 | } |
||
| 435 | }; |
||
| 436 | template <> |
||
| 437 | struct UnpackOptionalValue<IdentifierInfo*> { |
||
| 438 | static std::optional<IdentifierInfo*> unpack(IdentifierInfo* value) { |
||
| 439 | return value ? std::optional<IdentifierInfo*>(value) : std::nullopt; |
||
| 440 | } |
||
| 441 | }; |
||
| 442 | template <> |
||
| 443 | struct UnpackOptionalValue<NamedDecl*> { |
||
| 444 | static std::optional<NamedDecl*> unpack(NamedDecl* value) { |
||
| 445 | return value ? std::optional<NamedDecl*>(value) : std::nullopt; |
||
| 446 | } |
||
| 447 | }; |
||
| 448 | template <> |
||
| 449 | struct UnpackOptionalValue<NamespaceAliasDecl*> { |
||
| 450 | static std::optional<NamespaceAliasDecl*> unpack(NamespaceAliasDecl* value) { |
||
| 451 | return value ? std::optional<NamespaceAliasDecl*>(value) : std::nullopt; |
||
| 452 | } |
||
| 453 | }; |
||
| 454 | template <> |
||
| 455 | struct UnpackOptionalValue<NamespaceDecl*> { |
||
| 456 | static std::optional<NamespaceDecl*> unpack(NamespaceDecl* value) { |
||
| 457 | return value ? std::optional<NamespaceDecl*>(value) : std::nullopt; |
||
| 458 | } |
||
| 459 | }; |
||
| 460 | template <> |
||
| 461 | struct UnpackOptionalValue<ObjCProtocolDecl*> { |
||
| 462 | static std::optional<ObjCProtocolDecl*> unpack(ObjCProtocolDecl* value) { |
||
| 463 | return value ? std::optional<ObjCProtocolDecl*>(value) : std::nullopt; |
||
| 464 | } |
||
| 465 | }; |
||
| 466 | template <> |
||
| 467 | struct UnpackOptionalValue<ObjCTypeParamDecl*> { |
||
| 468 | static std::optional<ObjCTypeParamDecl*> unpack(ObjCTypeParamDecl* value) { |
||
| 469 | return value ? std::optional<ObjCTypeParamDecl*>(value) : std::nullopt; |
||
| 470 | } |
||
| 471 | }; |
||
| 472 | template <> |
||
| 473 | struct UnpackOptionalValue<QualType> { |
||
| 474 | static std::optional<QualType> unpack(QualType value) { |
||
| 475 | return value.isNull() ? std::nullopt : std::optional<QualType>(value); |
||
| 476 | } |
||
| 477 | }; |
||
| 478 | template <> |
||
| 479 | struct UnpackOptionalValue<Stmt*> { |
||
| 480 | static std::optional<Stmt*> unpack(Stmt* value) { |
||
| 481 | return value ? std::optional<Stmt*>(value) : std::nullopt; |
||
| 482 | } |
||
| 483 | }; |
||
| 484 | template <> |
||
| 485 | struct UnpackOptionalValue<TagDecl*> { |
||
| 486 | static std::optional<TagDecl*> unpack(TagDecl* value) { |
||
| 487 | return value ? std::optional<TagDecl*>(value) : std::nullopt; |
||
| 488 | } |
||
| 489 | }; |
||
| 490 | template <> |
||
| 491 | struct UnpackOptionalValue<TemplateDecl*> { |
||
| 492 | static std::optional<TemplateDecl*> unpack(TemplateDecl* value) { |
||
| 493 | return value ? std::optional<TemplateDecl*>(value) : std::nullopt; |
||
| 494 | } |
||
| 495 | }; |
||
| 496 | template <> |
||
| 497 | struct UnpackOptionalValue<TemplateName> { |
||
| 498 | static std::optional<TemplateName> unpack(TemplateName value) { |
||
| 499 | return value.isNull() ? std::nullopt : std::optional<TemplateName>(value); |
||
| 500 | } |
||
| 501 | }; |
||
| 502 | template <> |
||
| 503 | struct UnpackOptionalValue<TemplateTemplateParmDecl*> { |
||
| 504 | static std::optional<TemplateTemplateParmDecl*> unpack(TemplateTemplateParmDecl* value) { |
||
| 505 | return value ? std::optional<TemplateTemplateParmDecl*>(value) : std::nullopt; |
||
| 506 | } |
||
| 507 | }; |
||
| 508 | template <> |
||
| 509 | struct UnpackOptionalValue<TemplateTypeParmDecl*> { |
||
| 510 | static std::optional<TemplateTypeParmDecl*> unpack(TemplateTypeParmDecl* value) { |
||
| 511 | return value ? std::optional<TemplateTypeParmDecl*>(value) : std::nullopt; |
||
| 512 | } |
||
| 513 | }; |
||
| 514 | template <> |
||
| 515 | struct UnpackOptionalValue<uint32_t> { |
||
| 516 | static std::optional<uint32_t> unpack(uint32_t value) { |
||
| 517 | return value ? std::optional<uint32_t>(value - 1) : std::nullopt; |
||
| 518 | } |
||
| 519 | }; |
||
| 520 | template <> |
||
| 521 | struct UnpackOptionalValue<uint64_t> { |
||
| 522 | static std::optional<uint64_t> unpack(uint64_t value) { |
||
| 523 | return value ? std::optional<uint64_t>(value - 1) : std::nullopt; |
||
| 524 | } |
||
| 525 | }; |
||
| 526 | template <> |
||
| 527 | struct UnpackOptionalValue<UsingShadowDecl*> { |
||
| 528 | static std::optional<UsingShadowDecl*> unpack(UsingShadowDecl* value) { |
||
| 529 | return value ? std::optional<UsingShadowDecl*>(value) : std::nullopt; |
||
| 530 | } |
||
| 531 | }; |
||
| 532 | template <> |
||
| 533 | struct UnpackOptionalValue<ValueDecl*> { |
||
| 534 | static std::optional<ValueDecl*> unpack(ValueDecl* value) { |
||
| 535 | return value ? std::optional<ValueDecl*>(value) : std::nullopt; |
||
| 536 | } |
||
| 537 | }; |
||
| 538 | |||
| 539 | template <class Impl> |
||
| 540 | class BasicReaderBase { |
||
| 541 | ASTContext &C; |
||
| 542 | protected: |
||
| 543 | BasicReaderBase(ASTContext &ctx) : C(ctx) {} |
||
| 544 | public: |
||
| 545 | ASTContext &getASTContext() { return C; } |
||
| 546 | Impl &asImpl() { return static_cast<Impl&>(*this); } |
||
| 547 | APValue readAPValue() { |
||
| 548 | auto &ctx = asImpl().getASTContext(); |
||
| 549 | auto &&subR = asImpl().readObject(); |
||
| 550 | APValue::ValueKind kind = subR.find("kind").readAPValueKind(); |
||
| 551 | switch (kind) { |
||
| 552 | case APValue::None: { |
||
| 553 | return APValue(); |
||
| 554 | } |
||
| 555 | |||
| 556 | case APValue::FixedPoint: { |
||
| 557 | llvm::FixedPointSemantics semantics = subR.find("semantics").readFixedPointSemantics(); |
||
| 558 | llvm::APSInt value = subR.find("value").readAPSInt(); |
||
| 559 | |||
| 560 | return APValue(llvm::APFixedPoint(std::move(value), semantics)); |
||
| 561 | |||
| 562 | } |
||
| 563 | |||
| 564 | case APValue::ComplexInt: { |
||
| 565 | llvm::APSInt real = subR.find("real").readAPSInt(); |
||
| 566 | llvm::APSInt imag = subR.find("imag").readAPSInt(); |
||
| 567 | return APValue(real, imag); |
||
| 568 | } |
||
| 569 | |||
| 570 | case APValue::ComplexFloat: { |
||
| 571 | uint32_t semantics = subR.find("semantics").readUInt32(); |
||
| 572 | llvm::APInt real = subR.find("real").readAPInt(); |
||
| 573 | llvm::APInt imag = subR.find("imag").readAPInt(); |
||
| 574 | |||
| 575 | const llvm::fltSemantics &sema = llvm::APFloatBase::EnumToSemantics( |
||
| 576 | static_cast<llvm::APFloatBase::Semantics>(semantics)); |
||
| 577 | return APValue(llvm::APFloat(sema, real), |
||
| 578 | llvm::APFloat(sema, imag)); |
||
| 579 | |||
| 580 | } |
||
| 581 | |||
| 582 | case APValue::Vector: { |
||
| 583 | llvm::SmallVector<APValue, 8> elements_buffer_0; |
||
| 584 | llvm::ArrayRef<APValue> elements = subR.find("elements").template readArray<APValue>(elements_buffer_0); |
||
| 585 | |||
| 586 | APValue result; |
||
| 587 | result.MakeVector(); |
||
| 588 | unsigned length = elements.size(); |
||
| 589 | (void)result.setVectorUninit(length); |
||
| 590 | for (unsigned i = 0; i < length; i++) |
||
| 591 | result.getVectorElt(i) = elements[i]; |
||
| 592 | return result; |
||
| 593 | |||
| 594 | } |
||
| 595 | |||
| 596 | case APValue::Indeterminate: { |
||
| 597 | return APValue::IndeterminateValue(); |
||
| 598 | } |
||
| 599 | |||
| 600 | case APValue::Array: { |
||
| 601 | uint32_t totalLength = subR.find("totalLength").readUInt32(); |
||
| 602 | bool hasFiller = subR.find("hasFiller").readBool(); |
||
| 603 | llvm::SmallVector<APValue, 8> elements_buffer_0; |
||
| 604 | llvm::ArrayRef<APValue> elements = subR.find("elements").template readArray<APValue>(elements_buffer_0); |
||
| 605 | |||
| 606 | APValue result; |
||
| 607 | unsigned initLength = elements.size() - (hasFiller ? 1 : 0); |
||
| 608 | result.MakeArray(initLength, totalLength); |
||
| 609 | for (unsigned i = 0; i < initLength; ++i) |
||
| 610 | result.getArrayInitializedElt(i) = elements[i]; |
||
| 611 | if (hasFiller) |
||
| 612 | result.getArrayFiller() = elements.back(); |
||
| 613 | return result; |
||
| 614 | |||
| 615 | } |
||
| 616 | |||
| 617 | case APValue::Struct: { |
||
| 618 | llvm::SmallVector<APValue, 8> bases_buffer_0; |
||
| 619 | llvm::ArrayRef<APValue> bases = subR.find("bases").template readArray<APValue>(bases_buffer_0); |
||
| 620 | llvm::SmallVector<APValue, 8> fields_buffer_0; |
||
| 621 | llvm::ArrayRef<APValue> fields = subR.find("fields").template readArray<APValue>(fields_buffer_0); |
||
| 622 | |||
| 623 | APValue result; |
||
| 624 | result.MakeStruct(bases.size(), fields.size()); |
||
| 625 | for (unsigned i = 0; i < bases.size(); ++i) |
||
| 626 | result.getStructBase(i) = bases[i]; |
||
| 627 | for (unsigned i = 0; i < fields.size(); ++i) |
||
| 628 | result.getStructField(i) = fields[i]; |
||
| 629 | return result; |
||
| 630 | |||
| 631 | } |
||
| 632 | |||
| 633 | case APValue::Union: { |
||
| 634 | Decl* fieldDecl = subR.find("fieldDecl").readDeclRef(); |
||
| 635 | APValue value = subR.find("value").readAPValue(); |
||
| 636 | |||
| 637 | return APValue(cast<clang::FieldDecl>(fieldDecl), std::move(value)); |
||
| 638 | |||
| 639 | } |
||
| 640 | |||
| 641 | case APValue::AddrLabelDiff: { |
||
| 642 | Stmt* lhs = subR.find("lhs").readStmtRef(); |
||
| 643 | Stmt* rhs = subR.find("rhs").readStmtRef(); |
||
| 644 | |||
| 645 | return APValue(cast<AddrLabelExpr>(lhs), cast<AddrLabelExpr>(rhs)); |
||
| 646 | |||
| 647 | } |
||
| 648 | |||
| 649 | case APValue::Int: { |
||
| 650 | llvm::APSInt value = subR.find("value").readAPSInt(); |
||
| 651 | return APValue(value); |
||
| 652 | } |
||
| 653 | |||
| 654 | case APValue::MemberPointer: { |
||
| 655 | bool isDerived = subR.find("isDerived").readBool(); |
||
| 656 | ValueDecl* member = subR.find("member").readValueDeclRef(); |
||
| 657 | llvm::SmallVector<CXXRecordDecl*, 8> memberPath_buffer_0; |
||
| 658 | llvm::ArrayRef<CXXRecordDecl*> memberPath = subR.find("memberPath").template readArray<CXXRecordDecl*>(memberPath_buffer_0); |
||
| 659 | |||
| 660 | APValue result; |
||
| 661 | unsigned pathSize = memberPath.size(); |
||
| 662 | const CXXRecordDecl **pathArray = |
||
| 663 | result.setMemberPointerUninit(member, isDerived, pathSize).data(); |
||
| 664 | for (unsigned i = 0; i < pathSize; ++i) |
||
| 665 | pathArray[i] = memberPath[i]->getCanonicalDecl(); |
||
| 666 | return result; |
||
| 667 | |||
| 668 | } |
||
| 669 | |||
| 670 | case APValue::LValue: { |
||
| 671 | bool hasLValuePath = subR.find("hasLValuePath").readBool(); |
||
| 672 | bool isLValueOnePastTheEnd = subR.find("isLValueOnePastTheEnd").readBool(); |
||
| 673 | bool isExpr = subR.find("isExpr").readBool(); |
||
| 674 | bool isTypeInfo = subR.find("isTypeInfo").readBool(); |
||
| 675 | bool hasBase = subR.find("hasBase").readBool(); |
||
| 676 | bool isNullPtr = subR.find("isNullPtr").readBool(); |
||
| 677 | std::optional<QualType> typeInfo; |
||
| 678 | if ( hasBase && isTypeInfo ) { |
||
| 679 | typeInfo.emplace(subR.find("typeInfo").readQualType()); |
||
| 680 | } |
||
| 681 | std::optional<QualType> type; |
||
| 682 | if ( hasBase && isTypeInfo ) { |
||
| 683 | type.emplace(subR.find("type").readQualType()); |
||
| 684 | } |
||
| 685 | std::optional<uint32_t> callIndex; |
||
| 686 | if ( hasBase && !isTypeInfo ) { |
||
| 687 | callIndex.emplace(subR.find("callIndex").readUInt32()); |
||
| 688 | } |
||
| 689 | std::optional<uint32_t> version; |
||
| 690 | if ( hasBase && !isTypeInfo ) { |
||
| 691 | version.emplace(subR.find("version").readUInt32()); |
||
| 692 | } |
||
| 693 | std::optional<Stmt*> stmt; |
||
| 694 | if ( hasBase && !isTypeInfo && isExpr ) { |
||
| 695 | stmt.emplace(subR.find("stmt").readStmtRef()); |
||
| 696 | } |
||
| 697 | std::optional<Decl*> decl; |
||
| 698 | if ( hasBase && !isTypeInfo && !isExpr ) { |
||
| 699 | decl.emplace(subR.find("decl").readDeclRef()); |
||
| 700 | } |
||
| 701 | uint32_t offsetQuantity = subR.find("offsetQuantity").readUInt32(); |
||
| 702 | llvm::SmallVector<APValue::LValuePathEntry, 8> lvaluePath_buffer_0; |
||
| 703 | std::optional<APValue::LValuePathSerializationHelper> lvaluePath; |
||
| 704 | if ( hasLValuePath ) { |
||
| 705 | lvaluePath.emplace(subR.find("lvaluePath").readLValuePathSerializationHelper(lvaluePath_buffer_0)); |
||
| 706 | } |
||
| 707 | |||
| 708 | (void)ctx; |
||
| 709 | APValue::LValueBase base; |
||
| 710 | if (hasBase) { |
||
| 711 | if (isTypeInfo) { |
||
| 712 | base = APValue::LValueBase::getTypeInfo( |
||
| 713 | TypeInfoLValue(typeInfo->getTypePtr()), *type); |
||
| 714 | } else if (isExpr) { |
||
| 715 | base = APValue::LValueBase(cast<Expr>(*stmt), |
||
| 716 | *callIndex, *version); |
||
| 717 | } else { |
||
| 718 | base = APValue::LValueBase(cast<ValueDecl>(*decl), |
||
| 719 | *callIndex, *version); |
||
| 720 | } |
||
| 721 | } |
||
| 722 | CharUnits offset = CharUnits::fromQuantity(offsetQuantity); |
||
| 723 | APValue result; |
||
| 724 | result.MakeLValue(); |
||
| 725 | if (!hasLValuePath) { |
||
| 726 | result.setLValue(base, offset, APValue::NoLValuePath{}, isNullPtr); |
||
| 727 | return result; |
||
| 728 | } |
||
| 729 | auto pathLength = lvaluePath->Path.size(); |
||
| 730 | APValue::LValuePathEntry *path = result.setLValueUninit( |
||
| 731 | base, offset, pathLength, isLValueOnePastTheEnd, isNullPtr).data(); |
||
| 732 | llvm::copy(lvaluePath->Path, path); |
||
| 733 | return result; |
||
| 734 | |||
| 735 | } |
||
| 736 | |||
| 737 | case APValue::Float: { |
||
| 738 | llvm::APInt value = subR.find("value").readAPInt(); |
||
| 739 | uint32_t semantics = subR.find("semantics").readUInt32(); |
||
| 740 | |||
| 741 | const llvm::fltSemantics &floatSema = llvm::APFloatBase::EnumToSemantics( |
||
| 742 | static_cast<llvm::APFloatBase::Semantics>(semantics)); |
||
| 743 | return APValue(llvm::APFloat(floatSema, value)); |
||
| 744 | |||
| 745 | } |
||
| 746 | |||
| 747 | } |
||
| 748 | llvm_unreachable("bad APValue::ValueKind"); |
||
| 749 | } |
||
| 750 | APValue::ValueKind readAPValueKind() { |
||
| 751 | return asImpl().template readEnum<APValue::ValueKind>(); |
||
| 752 | } |
||
| 753 | ArrayType::ArraySizeModifier readArraySizeModifier() { |
||
| 754 | return asImpl().template readEnum<ArrayType::ArraySizeModifier>(); |
||
| 755 | } |
||
| 756 | attr::Kind readAttrKind() { |
||
| 757 | return asImpl().template readEnum<attr::Kind>(); |
||
| 758 | } |
||
| 759 | AutoTypeKeyword readAutoTypeKeyword() { |
||
| 760 | return asImpl().template readEnum<AutoTypeKeyword>(); |
||
| 761 | } |
||
| 762 | BuiltinType::Kind readBuiltinTypeKind() { |
||
| 763 | return asImpl().template readEnum<BuiltinType::Kind>(); |
||
| 764 | } |
||
| 765 | CXXRecordDecl* readCXXRecordDeclRef() { |
||
| 766 | return cast_or_null<CXXRecordDecl>(asImpl().readDeclRef()); |
||
| 767 | } |
||
| 768 | CallingConv readCallingConv() { |
||
| 769 | return asImpl().template readEnum<CallingConv>(); |
||
| 770 | } |
||
| 771 | ConceptDecl* readConceptDeclRef() { |
||
| 772 | return cast_or_null<ConceptDecl>(asImpl().readDeclRef()); |
||
| 773 | } |
||
| 774 | DeclarationName readDeclarationName() { |
||
| 775 | auto &ctx = asImpl().getASTContext(); |
||
| 776 | auto &&subR = asImpl().readObject(); |
||
| 777 | DeclarationName::NameKind kind = subR.find("kind").readDeclarationNameKind(); |
||
| 778 | switch (kind) { |
||
| 779 | case DeclarationName::CXXLiteralOperatorName: { |
||
| 780 | IdentifierInfo* identifier = subR.find("identifier").readIdentifier(); |
||
| 781 | |||
| 782 | return ctx.DeclarationNames.getCXXLiteralOperatorName(identifier); |
||
| 783 | |||
| 784 | } |
||
| 785 | |||
| 786 | case DeclarationName::CXXUsingDirective: { |
||
| 787 | |||
| 788 | return DeclarationName::getUsingDirectiveName(); |
||
| 789 | |||
| 790 | } |
||
| 791 | |||
| 792 | case DeclarationName::Identifier: { |
||
| 793 | IdentifierInfo* identifier = subR.find("identifier").readIdentifier(); |
||
| 794 | |||
| 795 | return DeclarationName(identifier); |
||
| 796 | |||
| 797 | } |
||
| 798 | |||
| 799 | case DeclarationName::ObjCZeroArgSelector: { |
||
| 800 | Selector selector = subR.find("selector").readSelector(); |
||
| 801 | |||
| 802 | return DeclarationName(selector); |
||
| 803 | |||
| 804 | } |
||
| 805 | |||
| 806 | case DeclarationName::ObjCOneArgSelector: { |
||
| 807 | Selector selector = subR.find("selector").readSelector(); |
||
| 808 | |||
| 809 | return DeclarationName(selector); |
||
| 810 | |||
| 811 | } |
||
| 812 | |||
| 813 | case DeclarationName::ObjCMultiArgSelector: { |
||
| 814 | Selector selector = subR.find("selector").readSelector(); |
||
| 815 | |||
| 816 | return DeclarationName(selector); |
||
| 817 | |||
| 818 | } |
||
| 819 | |||
| 820 | case DeclarationName::CXXConstructorName: { |
||
| 821 | QualType type = subR.find("type").readQualType(); |
||
| 822 | |||
| 823 | return ctx.DeclarationNames.getCXXConstructorName( |
||
| 824 | ctx.getCanonicalType(type)); |
||
| 825 | |||
| 826 | } |
||
| 827 | |||
| 828 | case DeclarationName::CXXDestructorName: { |
||
| 829 | QualType type = subR.find("type").readQualType(); |
||
| 830 | |||
| 831 | return ctx.DeclarationNames.getCXXDestructorName( |
||
| 832 | ctx.getCanonicalType(type)); |
||
| 833 | |||
| 834 | } |
||
| 835 | |||
| 836 | case DeclarationName::CXXConversionFunctionName: { |
||
| 837 | QualType type = subR.find("type").readQualType(); |
||
| 838 | |||
| 839 | return ctx.DeclarationNames.getCXXConversionFunctionName( |
||
| 840 | ctx.getCanonicalType(type)); |
||
| 841 | |||
| 842 | } |
||
| 843 | |||
| 844 | case DeclarationName::CXXDeductionGuideName: { |
||
| 845 | TemplateDecl* declaration = subR.find("declaration").readTemplateDeclRef(); |
||
| 846 | |||
| 847 | return ctx.DeclarationNames.getCXXDeductionGuideName(declaration); |
||
| 848 | |||
| 849 | } |
||
| 850 | |||
| 851 | case DeclarationName::CXXOperatorName: { |
||
| 852 | OverloadedOperatorKind operatorKind = subR.find("operatorKind").readOverloadedOperatorKind(); |
||
| 853 | |||
| 854 | return ctx.DeclarationNames.getCXXOperatorName(operatorKind); |
||
| 855 | |||
| 856 | } |
||
| 857 | |||
| 858 | } |
||
| 859 | llvm_unreachable("bad DeclarationName::NameKind"); |
||
| 860 | } |
||
| 861 | DeclarationName::NameKind readDeclarationNameKind() { |
||
| 862 | return asImpl().template readEnum<DeclarationName::NameKind>(); |
||
| 863 | } |
||
| 864 | ElaboratedTypeKeyword readElaboratedTypeKeyword() { |
||
| 865 | return asImpl().template readEnum<ElaboratedTypeKeyword>(); |
||
| 866 | } |
||
| 867 | Expr* readExprRef() { |
||
| 868 | return cast_or_null<Expr>(asImpl().readStmtRef()); |
||
| 869 | } |
||
| 870 | FunctionDecl* readFunctionDeclRef() { |
||
| 871 | return cast_or_null<FunctionDecl>(asImpl().readDeclRef()); |
||
| 872 | } |
||
| 873 | NamedDecl* readNamedDeclRef() { |
||
| 874 | return cast_or_null<NamedDecl>(asImpl().readDeclRef()); |
||
| 875 | } |
||
| 876 | NamespaceAliasDecl* readNamespaceAliasDeclRef() { |
||
| 877 | return cast_or_null<NamespaceAliasDecl>(asImpl().readDeclRef()); |
||
| 878 | } |
||
| 879 | NamespaceDecl* readNamespaceDeclRef() { |
||
| 880 | return cast_or_null<NamespaceDecl>(asImpl().readDeclRef()); |
||
| 881 | } |
||
| 882 | NestedNameSpecifier::SpecifierKind readNestedNameSpecifierKind() { |
||
| 883 | return asImpl().template readEnum<NestedNameSpecifier::SpecifierKind>(); |
||
| 884 | } |
||
| 885 | ObjCProtocolDecl* readObjCProtocolDeclRef() { |
||
| 886 | return cast_or_null<ObjCProtocolDecl>(asImpl().readDeclRef()); |
||
| 887 | } |
||
| 888 | ObjCTypeParamDecl* readObjCTypeParamDeclRef() { |
||
| 889 | return cast_or_null<ObjCTypeParamDecl>(asImpl().readDeclRef()); |
||
| 890 | } |
||
| 891 | OverloadedOperatorKind readOverloadedOperatorKind() { |
||
| 892 | return asImpl().template readEnum<OverloadedOperatorKind>(); |
||
| 893 | } |
||
| 894 | RefQualifierKind readRefQualifierKind() { |
||
| 895 | return asImpl().template readEnum<RefQualifierKind>(); |
||
| 896 | } |
||
| 897 | TagDecl* readTagDeclRef() { |
||
| 898 | return cast_or_null<TagDecl>(asImpl().readDeclRef()); |
||
| 899 | } |
||
| 900 | TemplateArgument readTemplateArgument() { |
||
| 901 | auto &ctx = asImpl().getASTContext(); |
||
| 902 | auto &&subR = asImpl().readObject(); |
||
| 903 | TemplateArgument::ArgKind kind = subR.find("kind").readTemplateArgumentKind(); |
||
| 904 | switch (kind) { |
||
| 905 | case TemplateArgument::Null: { |
||
| 906 | |||
| 907 | return TemplateArgument(); |
||
| 908 | |||
| 909 | } |
||
| 910 | |||
| 911 | case TemplateArgument::Type: { |
||
| 912 | QualType type = subR.find("type").readQualType(); |
||
| 913 | |||
| 914 | return TemplateArgument(type); |
||
| 915 | |||
| 916 | } |
||
| 917 | |||
| 918 | case TemplateArgument::Declaration: { |
||
| 919 | ValueDecl* declaration = subR.find("declaration").readValueDeclRef(); |
||
| 920 | QualType parameterType = subR.find("parameterType").readQualType(); |
||
| 921 | |||
| 922 | return TemplateArgument(declaration, parameterType); |
||
| 923 | |||
| 924 | } |
||
| 925 | |||
| 926 | case TemplateArgument::NullPtr: { |
||
| 927 | QualType type = subR.find("type").readQualType(); |
||
| 928 | |||
| 929 | return TemplateArgument(type, /*nullptr*/ true); |
||
| 930 | |||
| 931 | } |
||
| 932 | |||
| 933 | case TemplateArgument::Integral: { |
||
| 934 | llvm::APSInt value = subR.find("value").readAPSInt(); |
||
| 935 | QualType type = subR.find("type").readQualType(); |
||
| 936 | |||
| 937 | return TemplateArgument(ctx, value, type); |
||
| 938 | |||
| 939 | } |
||
| 940 | |||
| 941 | case TemplateArgument::Template: { |
||
| 942 | TemplateName name = subR.find("name").readTemplateName(); |
||
| 943 | |||
| 944 | return TemplateArgument(name); |
||
| 945 | |||
| 946 | } |
||
| 947 | |||
| 948 | case TemplateArgument::TemplateExpansion: { |
||
| 949 | TemplateName name = subR.find("name").readTemplateName(); |
||
| 950 | std::optional<uint32_t> numExpansions = subR.find("numExpansions").template readOptional<uint32_t>(); |
||
| 951 | |||
| 952 | auto numExpansionsUnsigned = llvm::transformOptional( |
||
| 953 | numExpansions, [](uint32_t i) { return unsigned(i); }); |
||
| 954 | |||
| 955 | return TemplateArgument(name, numExpansionsUnsigned); |
||
| 956 | |||
| 957 | } |
||
| 958 | |||
| 959 | case TemplateArgument::Expression: { |
||
| 960 | Expr* expression = subR.find("expression").readExprRef(); |
||
| 961 | |||
| 962 | return TemplateArgument(expression); |
||
| 963 | |||
| 964 | } |
||
| 965 | |||
| 966 | case TemplateArgument::Pack: { |
||
| 967 | llvm::SmallVector<TemplateArgument, 8> elements_buffer_0; |
||
| 968 | llvm::ArrayRef<TemplateArgument> elements = subR.find("elements").template readArray<TemplateArgument>(elements_buffer_0); |
||
| 969 | |||
| 970 | // Copy the pack into the ASTContext. |
||
| 971 | TemplateArgument *ctxElements = new (ctx) TemplateArgument[elements.size()]; |
||
| 972 | for (size_t i = 0, e = elements.size(); i != e; ++i) |
||
| 973 | ctxElements[i] = elements[i]; |
||
| 974 | return TemplateArgument(llvm::ArrayRef(ctxElements, elements.size())); |
||
| 975 | |||
| 976 | } |
||
| 977 | |||
| 978 | } |
||
| 979 | llvm_unreachable("bad TemplateArgument::ArgKind"); |
||
| 980 | } |
||
| 981 | TemplateArgument::ArgKind readTemplateArgumentKind() { |
||
| 982 | return asImpl().template readEnum<TemplateArgument::ArgKind>(); |
||
| 983 | } |
||
| 984 | TemplateDecl* readTemplateDeclRef() { |
||
| 985 | return cast_or_null<TemplateDecl>(asImpl().readDeclRef()); |
||
| 986 | } |
||
| 987 | TemplateName readTemplateName() { |
||
| 988 | auto &ctx = asImpl().getASTContext(); |
||
| 989 | auto &&subR = asImpl().readObject(); |
||
| 990 | TemplateName::NameKind kind = subR.find("kind").readTemplateNameKind(); |
||
| 991 | switch (kind) { |
||
| 992 | case TemplateName::Template: { |
||
| 993 | TemplateDecl* declaration = subR.find("declaration").readTemplateDeclRef(); |
||
| 994 | |||
| 995 | return TemplateName(declaration); |
||
| 996 | |||
| 997 | } |
||
| 998 | |||
| 999 | case TemplateName::UsingTemplate: { |
||
| 1000 | UsingShadowDecl* foundDecl = subR.find("foundDecl").readUsingShadowDeclRef(); |
||
| 1001 | |||
| 1002 | return TemplateName(foundDecl); |
||
| 1003 | |||
| 1004 | } |
||
| 1005 | |||
| 1006 | case TemplateName::OverloadedTemplate: { |
||
| 1007 | llvm::SmallVector<NamedDecl*, 8> overloads_buffer_0; |
||
| 1008 | llvm::ArrayRef<NamedDecl*> overloads = subR.find("overloads").template readArray<NamedDecl*>(overloads_buffer_0); |
||
| 1009 | |||
| 1010 | // Copy into an UnresolvedSet to satisfy the interface. |
||
| 1011 | UnresolvedSet<8> overloadSet; |
||
| 1012 | for (auto overload : overloads) { |
||
| 1013 | overloadSet.addDecl(overload); |
||
| 1014 | } |
||
| 1015 | |||
| 1016 | return ctx.getOverloadedTemplateName(overloadSet.begin(), |
||
| 1017 | overloadSet.end()); |
||
| 1018 | |||
| 1019 | } |
||
| 1020 | |||
| 1021 | case TemplateName::AssumedTemplate: { |
||
| 1022 | DeclarationName name = subR.find("name").readDeclarationName(); |
||
| 1023 | |||
| 1024 | return ctx.getAssumedTemplateName(name); |
||
| 1025 | |||
| 1026 | } |
||
| 1027 | |||
| 1028 | case TemplateName::QualifiedTemplate: { |
||
| 1029 | NestedNameSpecifier * qualifier = subR.find("qualifier").readNestedNameSpecifier(); |
||
| 1030 | bool hasTemplateKeyword = subR.find("hasTemplateKeyword").readBool(); |
||
| 1031 | TemplateName underlyingTemplateName = subR.find("underlyingTemplateName").readTemplateName(); |
||
| 1032 | |||
| 1033 | return ctx.getQualifiedTemplateName(qualifier, hasTemplateKeyword, |
||
| 1034 | underlyingTemplateName); |
||
| 1035 | |||
| 1036 | } |
||
| 1037 | |||
| 1038 | case TemplateName::DependentTemplate: { |
||
| 1039 | NestedNameSpecifier * qualifier = subR.find("qualifier").readNestedNameSpecifier(); |
||
| 1040 | std::optional<IdentifierInfo*> identifier = subR.find("identifier").template readOptional<IdentifierInfo*>(); |
||
| 1041 | std::optional<OverloadedOperatorKind> operatorKind; |
||
| 1042 | if ( !identifier ) { |
||
| 1043 | operatorKind.emplace(subR.find("operatorKind").readOverloadedOperatorKind()); |
||
| 1044 | } |
||
| 1045 | |||
| 1046 | if (identifier) { |
||
| 1047 | return ctx.getDependentTemplateName(qualifier, *identifier); |
||
| 1048 | } else { |
||
| 1049 | return ctx.getDependentTemplateName(qualifier, *operatorKind); |
||
| 1050 | } |
||
| 1051 | |||
| 1052 | } |
||
| 1053 | |||
| 1054 | case TemplateName::SubstTemplateTemplateParm: { |
||
| 1055 | TemplateName replacement = subR.find("replacement").readTemplateName(); |
||
| 1056 | Decl* associatedDecl = subR.find("associatedDecl").readDeclRef(); |
||
| 1057 | uint32_t index = subR.find("index").readUInt32(); |
||
| 1058 | std::optional<uint32_t> packIndex = subR.find("packIndex").template readOptional<uint32_t>(); |
||
| 1059 | |||
| 1060 | return ctx.getSubstTemplateTemplateParm(replacement, associatedDecl, index, packIndex); |
||
| 1061 | |||
| 1062 | } |
||
| 1063 | |||
| 1064 | case TemplateName::SubstTemplateTemplateParmPack: { |
||
| 1065 | TemplateArgument argumentPack = subR.find("argumentPack").readTemplateArgument(); |
||
| 1066 | Decl* associatedDecl = subR.find("associatedDecl").readDeclRef(); |
||
| 1067 | uint32_t index = subR.find("index").readUInt32(); |
||
| 1068 | bool final = subR.find("final").readBool(); |
||
| 1069 | |||
| 1070 | return ctx.getSubstTemplateTemplateParmPack(argumentPack, associatedDecl, index, final); |
||
| 1071 | |||
| 1072 | } |
||
| 1073 | |||
| 1074 | } |
||
| 1075 | llvm_unreachable("bad TemplateName::NameKind"); |
||
| 1076 | } |
||
| 1077 | TemplateName::NameKind readTemplateNameKind() { |
||
| 1078 | return asImpl().template readEnum<TemplateName::NameKind>(); |
||
| 1079 | } |
||
| 1080 | TemplateTemplateParmDecl* readTemplateTemplateParmDeclRef() { |
||
| 1081 | return cast_or_null<TemplateTemplateParmDecl>(asImpl().readDeclRef()); |
||
| 1082 | } |
||
| 1083 | TemplateTypeParmDecl* readTemplateTypeParmDeclRef() { |
||
| 1084 | return cast_or_null<TemplateTypeParmDecl>(asImpl().readDeclRef()); |
||
| 1085 | } |
||
| 1086 | TypeOfKind readTypeOfKind() { |
||
| 1087 | return asImpl().template readEnum<TypeOfKind>(); |
||
| 1088 | } |
||
| 1089 | UnaryTransformType::UTTKind readUnaryTypeTransformKind() { |
||
| 1090 | return asImpl().template readEnum<UnaryTransformType::UTTKind>(); |
||
| 1091 | } |
||
| 1092 | UsingShadowDecl* readUsingShadowDeclRef() { |
||
| 1093 | return cast_or_null<UsingShadowDecl>(asImpl().readDeclRef()); |
||
| 1094 | } |
||
| 1095 | ValueDecl* readValueDeclRef() { |
||
| 1096 | return cast_or_null<ValueDecl>(asImpl().readDeclRef()); |
||
| 1097 | } |
||
| 1098 | VectorType::VectorKind readVectorKind() { |
||
| 1099 | return asImpl().template readEnum<VectorType::VectorKind>(); |
||
| 1100 | } |
||
| 1101 | }; |
||
| 1102 |