Warning, /include/clang/AST/AbstractBasicWriter.inc is written in an unsupported language. File is not indexed.
0001 /*===- TableGen'erated file -------------------------------------*- C++ -*-===*\
0002 |* *|
0003 |* Helper classes for BasicWriters *|
0004 |* *|
0005 |* Automatically generated file, do not edit! *|
0006 |* From: PropertiesBase.td *|
0007 |* *|
0008 \*===----------------------------------------------------------------------===*/
0009
0010 template <class ValueType>
0011 struct WriteDispatcher;
0012 template <>
0013 struct WriteDispatcher<llvm::APInt> {
0014 template <class BasicWriter, class... Args>
0015 static void write(BasicWriter &W, Args &&... args) {
0016 return W.writeAPInt(std::forward<Args>(args)...);
0017 }
0018 };
0019 template <>
0020 struct WriteDispatcher<llvm::APSInt> {
0021 template <class BasicWriter, class... Args>
0022 static void write(BasicWriter &W, Args &&... args) {
0023 return W.writeAPSInt(std::forward<Args>(args)...);
0024 }
0025 };
0026 template <>
0027 struct WriteDispatcher<APValue> {
0028 template <class BasicWriter, class... Args>
0029 static void write(BasicWriter &W, Args &&... args) {
0030 return W.writeAPValue(std::forward<Args>(args)...);
0031 }
0032 };
0033 template <>
0034 struct WriteDispatcher<APValue::ValueKind> {
0035 template <class BasicWriter, class... Args>
0036 static void write(BasicWriter &W, Args &&... args) {
0037 return W.writeAPValueKind(std::forward<Args>(args)...);
0038 }
0039 };
0040 template <>
0041 struct WriteDispatcher<ArraySizeModifier> {
0042 template <class BasicWriter, class... Args>
0043 static void write(BasicWriter &W, Args &&... args) {
0044 return W.writeArraySizeModifier(std::forward<Args>(args)...);
0045 }
0046 };
0047 template <>
0048 struct WriteDispatcher<const Attr *> {
0049 template <class BasicWriter, class... Args>
0050 static void write(BasicWriter &W, Args &&... args) {
0051 return W.writeAttr(std::forward<Args>(args)...);
0052 }
0053 };
0054 template <>
0055 struct WriteDispatcher<attr::Kind> {
0056 template <class BasicWriter, class... Args>
0057 static void write(BasicWriter &W, Args &&... args) {
0058 return W.writeAttrKind(std::forward<Args>(args)...);
0059 }
0060 };
0061 template <>
0062 struct WriteDispatcher<AutoTypeKeyword> {
0063 template <class BasicWriter, class... Args>
0064 static void write(BasicWriter &W, Args &&... args) {
0065 return W.writeAutoTypeKeyword(std::forward<Args>(args)...);
0066 }
0067 };
0068 template <>
0069 struct WriteDispatcher<const BTFTypeTagAttr *> {
0070 template <class BasicWriter, class... Args>
0071 static void write(BasicWriter &W, Args &&... args) {
0072 return W.writeBTFTypeTagAttr(std::forward<Args>(args)...);
0073 }
0074 };
0075 template <>
0076 struct WriteDispatcher<bool> {
0077 template <class BasicWriter, class... Args>
0078 static void write(BasicWriter &W, Args &&... args) {
0079 return W.writeBool(std::forward<Args>(args)...);
0080 }
0081 };
0082 template <>
0083 struct WriteDispatcher<BuiltinType::Kind> {
0084 template <class BasicWriter, class... Args>
0085 static void write(BasicWriter &W, Args &&... args) {
0086 return W.writeBuiltinTypeKind(std::forward<Args>(args)...);
0087 }
0088 };
0089 template <>
0090 struct WriteDispatcher<CXXRecordDecl*> {
0091 template <class BasicWriter, class... Args>
0092 static void write(BasicWriter &W, Args &&... args) {
0093 return W.writeCXXRecordDeclRef(std::forward<Args>(args)...);
0094 }
0095 };
0096 template <>
0097 struct WriteDispatcher<const CXXRecordDecl*> {
0098 template <class BasicWriter, class... Args>
0099 static void write(BasicWriter &W, Args &&... args) {
0100 return W.writeCXXRecordDeclRef(std::forward<Args>(args)...);
0101 }
0102 };
0103 template <>
0104 struct WriteDispatcher<CallingConv> {
0105 template <class BasicWriter, class... Args>
0106 static void write(BasicWriter &W, Args &&... args) {
0107 return W.writeCallingConv(std::forward<Args>(args)...);
0108 }
0109 };
0110 template <>
0111 struct WriteDispatcher<ConceptDecl*> {
0112 template <class BasicWriter, class... Args>
0113 static void write(BasicWriter &W, Args &&... args) {
0114 return W.writeConceptDeclRef(std::forward<Args>(args)...);
0115 }
0116 };
0117 template <>
0118 struct WriteDispatcher<const ConceptDecl*> {
0119 template <class BasicWriter, class... Args>
0120 static void write(BasicWriter &W, Args &&... args) {
0121 return W.writeConceptDeclRef(std::forward<Args>(args)...);
0122 }
0123 };
0124 template <>
0125 struct WriteDispatcher<Decl*> {
0126 template <class BasicWriter, class... Args>
0127 static void write(BasicWriter &W, Args &&... args) {
0128 return W.writeDeclRef(std::forward<Args>(args)...);
0129 }
0130 };
0131 template <>
0132 struct WriteDispatcher<const Decl*> {
0133 template <class BasicWriter, class... Args>
0134 static void write(BasicWriter &W, Args &&... args) {
0135 return W.writeDeclRef(std::forward<Args>(args)...);
0136 }
0137 };
0138 template <>
0139 struct WriteDispatcher<DeclarationName> {
0140 template <class BasicWriter, class... Args>
0141 static void write(BasicWriter &W, Args &&... args) {
0142 return W.writeDeclarationName(std::forward<Args>(args)...);
0143 }
0144 };
0145 template <>
0146 struct WriteDispatcher<DeclarationName::NameKind> {
0147 template <class BasicWriter, class... Args>
0148 static void write(BasicWriter &W, Args &&... args) {
0149 return W.writeDeclarationNameKind(std::forward<Args>(args)...);
0150 }
0151 };
0152 template <>
0153 struct WriteDispatcher<EffectConditionExpr> {
0154 template <class BasicWriter, class... Args>
0155 static void write(BasicWriter &W, Args &&... args) {
0156 return W.writeEffectConditionExpr(std::forward<Args>(args)...);
0157 }
0158 };
0159 template <>
0160 struct WriteDispatcher<ElaboratedTypeKeyword> {
0161 template <class BasicWriter, class... Args>
0162 static void write(BasicWriter &W, Args &&... args) {
0163 return W.writeElaboratedTypeKeyword(std::forward<Args>(args)...);
0164 }
0165 };
0166 template <>
0167 struct WriteDispatcher<FunctionProtoType::ExceptionSpecInfo> {
0168 template <class BasicWriter, class... Args>
0169 static void write(BasicWriter &W, Args &&... args) {
0170 return W.writeExceptionSpecInfo(std::forward<Args>(args)...);
0171 }
0172 };
0173 template <>
0174 struct WriteDispatcher<Expr*> {
0175 template <class BasicWriter, class... Args>
0176 static void write(BasicWriter &W, Args &&... args) {
0177 return W.writeExprRef(std::forward<Args>(args)...);
0178 }
0179 };
0180 template <>
0181 struct WriteDispatcher<const Expr*> {
0182 template <class BasicWriter, class... Args>
0183 static void write(BasicWriter &W, Args &&... args) {
0184 return W.writeExprRef(std::forward<Args>(args)...);
0185 }
0186 };
0187 template <>
0188 struct WriteDispatcher<FunctionProtoType::ExtParameterInfo> {
0189 template <class BasicWriter, class... Args>
0190 static void write(BasicWriter &W, Args &&... args) {
0191 return W.writeExtParameterInfo(std::forward<Args>(args)...);
0192 }
0193 };
0194 template <>
0195 struct WriteDispatcher<llvm::FixedPointSemantics> {
0196 template <class BasicWriter, class... Args>
0197 static void write(BasicWriter &W, Args &&... args) {
0198 return W.writeFixedPointSemantics(std::forward<Args>(args)...);
0199 }
0200 };
0201 template <>
0202 struct WriteDispatcher<FunctionDecl*> {
0203 template <class BasicWriter, class... Args>
0204 static void write(BasicWriter &W, Args &&... args) {
0205 return W.writeFunctionDeclRef(std::forward<Args>(args)...);
0206 }
0207 };
0208 template <>
0209 struct WriteDispatcher<const FunctionDecl*> {
0210 template <class BasicWriter, class... Args>
0211 static void write(BasicWriter &W, Args &&... args) {
0212 return W.writeFunctionDeclRef(std::forward<Args>(args)...);
0213 }
0214 };
0215 template <>
0216 struct WriteDispatcher<FunctionEffect> {
0217 template <class BasicWriter, class... Args>
0218 static void write(BasicWriter &W, Args &&... args) {
0219 return W.writeFunctionEffect(std::forward<Args>(args)...);
0220 }
0221 };
0222 template <>
0223 struct WriteDispatcher<IdentifierInfo*> {
0224 template <class BasicWriter, class... Args>
0225 static void write(BasicWriter &W, Args &&... args) {
0226 return W.writeIdentifier(std::forward<Args>(args)...);
0227 }
0228 };
0229 template <>
0230 struct WriteDispatcher<const IdentifierInfo*> {
0231 template <class BasicWriter, class... Args>
0232 static void write(BasicWriter &W, Args &&... args) {
0233 return W.writeIdentifier(std::forward<Args>(args)...);
0234 }
0235 };
0236 template <>
0237 struct WriteDispatcher<APValue::LValuePathEntry> {
0238 template <class BasicWriter, class... Args>
0239 static void write(BasicWriter &W, Args &&... args) {
0240 return W.writeLValuePathEntry(std::forward<Args>(args)...);
0241 }
0242 };
0243 template <>
0244 struct WriteDispatcher<APValue::LValuePathSerializationHelper> {
0245 template <class BasicWriter, class... Args>
0246 static void write(BasicWriter &W, Args &&... args) {
0247 return W.writeLValuePathSerializationHelper(std::forward<Args>(args)...);
0248 }
0249 };
0250 template <>
0251 struct WriteDispatcher<NamedDecl*> {
0252 template <class BasicWriter, class... Args>
0253 static void write(BasicWriter &W, Args &&... args) {
0254 return W.writeNamedDeclRef(std::forward<Args>(args)...);
0255 }
0256 };
0257 template <>
0258 struct WriteDispatcher<const NamedDecl*> {
0259 template <class BasicWriter, class... Args>
0260 static void write(BasicWriter &W, Args &&... args) {
0261 return W.writeNamedDeclRef(std::forward<Args>(args)...);
0262 }
0263 };
0264 template <>
0265 struct WriteDispatcher<NamespaceAliasDecl*> {
0266 template <class BasicWriter, class... Args>
0267 static void write(BasicWriter &W, Args &&... args) {
0268 return W.writeNamespaceAliasDeclRef(std::forward<Args>(args)...);
0269 }
0270 };
0271 template <>
0272 struct WriteDispatcher<const NamespaceAliasDecl*> {
0273 template <class BasicWriter, class... Args>
0274 static void write(BasicWriter &W, Args &&... args) {
0275 return W.writeNamespaceAliasDeclRef(std::forward<Args>(args)...);
0276 }
0277 };
0278 template <>
0279 struct WriteDispatcher<NamespaceDecl*> {
0280 template <class BasicWriter, class... Args>
0281 static void write(BasicWriter &W, Args &&... args) {
0282 return W.writeNamespaceDeclRef(std::forward<Args>(args)...);
0283 }
0284 };
0285 template <>
0286 struct WriteDispatcher<const NamespaceDecl*> {
0287 template <class BasicWriter, class... Args>
0288 static void write(BasicWriter &W, Args &&... args) {
0289 return W.writeNamespaceDeclRef(std::forward<Args>(args)...);
0290 }
0291 };
0292 template <>
0293 struct WriteDispatcher<NestedNameSpecifier *> {
0294 template <class BasicWriter, class... Args>
0295 static void write(BasicWriter &W, Args &&... args) {
0296 return W.writeNestedNameSpecifier(std::forward<Args>(args)...);
0297 }
0298 };
0299 template <>
0300 struct WriteDispatcher<NestedNameSpecifier::SpecifierKind> {
0301 template <class BasicWriter, class... Args>
0302 static void write(BasicWriter &W, Args &&... args) {
0303 return W.writeNestedNameSpecifierKind(std::forward<Args>(args)...);
0304 }
0305 };
0306 template <>
0307 struct WriteDispatcher<ObjCProtocolDecl*> {
0308 template <class BasicWriter, class... Args>
0309 static void write(BasicWriter &W, Args &&... args) {
0310 return W.writeObjCProtocolDeclRef(std::forward<Args>(args)...);
0311 }
0312 };
0313 template <>
0314 struct WriteDispatcher<const ObjCProtocolDecl*> {
0315 template <class BasicWriter, class... Args>
0316 static void write(BasicWriter &W, Args &&... args) {
0317 return W.writeObjCProtocolDeclRef(std::forward<Args>(args)...);
0318 }
0319 };
0320 template <>
0321 struct WriteDispatcher<ObjCTypeParamDecl*> {
0322 template <class BasicWriter, class... Args>
0323 static void write(BasicWriter &W, Args &&... args) {
0324 return W.writeObjCTypeParamDeclRef(std::forward<Args>(args)...);
0325 }
0326 };
0327 template <>
0328 struct WriteDispatcher<const ObjCTypeParamDecl*> {
0329 template <class BasicWriter, class... Args>
0330 static void write(BasicWriter &W, Args &&... args) {
0331 return W.writeObjCTypeParamDeclRef(std::forward<Args>(args)...);
0332 }
0333 };
0334 template <>
0335 struct WriteDispatcher<OverloadedOperatorKind> {
0336 template <class BasicWriter, class... Args>
0337 static void write(BasicWriter &W, Args &&... args) {
0338 return W.writeOverloadedOperatorKind(std::forward<Args>(args)...);
0339 }
0340 };
0341 template <>
0342 struct WriteDispatcher<QualType> {
0343 template <class BasicWriter, class... Args>
0344 static void write(BasicWriter &W, Args &&... args) {
0345 return W.writeQualType(std::forward<Args>(args)...);
0346 }
0347 };
0348 template <>
0349 struct WriteDispatcher<Qualifiers> {
0350 template <class BasicWriter, class... Args>
0351 static void write(BasicWriter &W, Args &&... args) {
0352 return W.writeQualifiers(std::forward<Args>(args)...);
0353 }
0354 };
0355 template <>
0356 struct WriteDispatcher<RefQualifierKind> {
0357 template <class BasicWriter, class... Args>
0358 static void write(BasicWriter &W, Args &&... args) {
0359 return W.writeRefQualifierKind(std::forward<Args>(args)...);
0360 }
0361 };
0362 template <>
0363 struct WriteDispatcher<Selector> {
0364 template <class BasicWriter, class... Args>
0365 static void write(BasicWriter &W, Args &&... args) {
0366 return W.writeSelector(std::forward<Args>(args)...);
0367 }
0368 };
0369 template <>
0370 struct WriteDispatcher<SourceLocation> {
0371 template <class BasicWriter, class... Args>
0372 static void write(BasicWriter &W, Args &&... args) {
0373 return W.writeSourceLocation(std::forward<Args>(args)...);
0374 }
0375 };
0376 template <>
0377 struct WriteDispatcher<Stmt*> {
0378 template <class BasicWriter, class... Args>
0379 static void write(BasicWriter &W, Args &&... args) {
0380 return W.writeStmtRef(std::forward<Args>(args)...);
0381 }
0382 };
0383 template <>
0384 struct WriteDispatcher<const Stmt*> {
0385 template <class BasicWriter, class... Args>
0386 static void write(BasicWriter &W, Args &&... args) {
0387 return W.writeStmtRef(std::forward<Args>(args)...);
0388 }
0389 };
0390 template <>
0391 struct WriteDispatcher<SubstTemplateTypeParmTypeFlag> {
0392 template <class BasicWriter, class... Args>
0393 static void write(BasicWriter &W, Args &&... args) {
0394 return W.writeSubstTemplateTypeParmTypeFlag(std::forward<Args>(args)...);
0395 }
0396 };
0397 template <>
0398 struct WriteDispatcher<TagDecl*> {
0399 template <class BasicWriter, class... Args>
0400 static void write(BasicWriter &W, Args &&... args) {
0401 return W.writeTagDeclRef(std::forward<Args>(args)...);
0402 }
0403 };
0404 template <>
0405 struct WriteDispatcher<const TagDecl*> {
0406 template <class BasicWriter, class... Args>
0407 static void write(BasicWriter &W, Args &&... args) {
0408 return W.writeTagDeclRef(std::forward<Args>(args)...);
0409 }
0410 };
0411 template <>
0412 struct WriteDispatcher<TemplateArgument> {
0413 template <class BasicWriter, class... Args>
0414 static void write(BasicWriter &W, Args &&... args) {
0415 return W.writeTemplateArgument(std::forward<Args>(args)...);
0416 }
0417 };
0418 template <>
0419 struct WriteDispatcher<TemplateArgument::ArgKind> {
0420 template <class BasicWriter, class... Args>
0421 static void write(BasicWriter &W, Args &&... args) {
0422 return W.writeTemplateArgumentKind(std::forward<Args>(args)...);
0423 }
0424 };
0425 template <>
0426 struct WriteDispatcher<TemplateDecl*> {
0427 template <class BasicWriter, class... Args>
0428 static void write(BasicWriter &W, Args &&... args) {
0429 return W.writeTemplateDeclRef(std::forward<Args>(args)...);
0430 }
0431 };
0432 template <>
0433 struct WriteDispatcher<const TemplateDecl*> {
0434 template <class BasicWriter, class... Args>
0435 static void write(BasicWriter &W, Args &&... args) {
0436 return W.writeTemplateDeclRef(std::forward<Args>(args)...);
0437 }
0438 };
0439 template <>
0440 struct WriteDispatcher<TemplateName> {
0441 template <class BasicWriter, class... Args>
0442 static void write(BasicWriter &W, Args &&... args) {
0443 return W.writeTemplateName(std::forward<Args>(args)...);
0444 }
0445 };
0446 template <>
0447 struct WriteDispatcher<TemplateName::NameKind> {
0448 template <class BasicWriter, class... Args>
0449 static void write(BasicWriter &W, Args &&... args) {
0450 return W.writeTemplateNameKind(std::forward<Args>(args)...);
0451 }
0452 };
0453 template <>
0454 struct WriteDispatcher<TemplateTemplateParmDecl*> {
0455 template <class BasicWriter, class... Args>
0456 static void write(BasicWriter &W, Args &&... args) {
0457 return W.writeTemplateTemplateParmDeclRef(std::forward<Args>(args)...);
0458 }
0459 };
0460 template <>
0461 struct WriteDispatcher<const TemplateTemplateParmDecl*> {
0462 template <class BasicWriter, class... Args>
0463 static void write(BasicWriter &W, Args &&... args) {
0464 return W.writeTemplateTemplateParmDeclRef(std::forward<Args>(args)...);
0465 }
0466 };
0467 template <>
0468 struct WriteDispatcher<TemplateTypeParmDecl*> {
0469 template <class BasicWriter, class... Args>
0470 static void write(BasicWriter &W, Args &&... args) {
0471 return W.writeTemplateTypeParmDeclRef(std::forward<Args>(args)...);
0472 }
0473 };
0474 template <>
0475 struct WriteDispatcher<const TemplateTypeParmDecl*> {
0476 template <class BasicWriter, class... Args>
0477 static void write(BasicWriter &W, Args &&... args) {
0478 return W.writeTemplateTypeParmDeclRef(std::forward<Args>(args)...);
0479 }
0480 };
0481 template <>
0482 struct WriteDispatcher<TypeCoupledDeclRefInfo> {
0483 template <class BasicWriter, class... Args>
0484 static void write(BasicWriter &W, Args &&... args) {
0485 return W.writeTypeCoupledDeclRefInfo(std::forward<Args>(args)...);
0486 }
0487 };
0488 template <>
0489 struct WriteDispatcher<TypeOfKind> {
0490 template <class BasicWriter, class... Args>
0491 static void write(BasicWriter &W, Args &&... args) {
0492 return W.writeTypeOfKind(std::forward<Args>(args)...);
0493 }
0494 };
0495 template <>
0496 struct WriteDispatcher<uint32_t> {
0497 template <class BasicWriter, class... Args>
0498 static void write(BasicWriter &W, Args &&... args) {
0499 return W.writeUInt32(std::forward<Args>(args)...);
0500 }
0501 };
0502 template <>
0503 struct WriteDispatcher<uint64_t> {
0504 template <class BasicWriter, class... Args>
0505 static void write(BasicWriter &W, Args &&... args) {
0506 return W.writeUInt64(std::forward<Args>(args)...);
0507 }
0508 };
0509 template <>
0510 struct WriteDispatcher<UnaryTransformType::UTTKind> {
0511 template <class BasicWriter, class... Args>
0512 static void write(BasicWriter &W, Args &&... args) {
0513 return W.writeUnaryTypeTransformKind(std::forward<Args>(args)...);
0514 }
0515 };
0516 template <>
0517 struct WriteDispatcher<UsingShadowDecl*> {
0518 template <class BasicWriter, class... Args>
0519 static void write(BasicWriter &W, Args &&... args) {
0520 return W.writeUsingShadowDeclRef(std::forward<Args>(args)...);
0521 }
0522 };
0523 template <>
0524 struct WriteDispatcher<const UsingShadowDecl*> {
0525 template <class BasicWriter, class... Args>
0526 static void write(BasicWriter &W, Args &&... args) {
0527 return W.writeUsingShadowDeclRef(std::forward<Args>(args)...);
0528 }
0529 };
0530 template <>
0531 struct WriteDispatcher<ValueDecl*> {
0532 template <class BasicWriter, class... Args>
0533 static void write(BasicWriter &W, Args &&... args) {
0534 return W.writeValueDeclRef(std::forward<Args>(args)...);
0535 }
0536 };
0537 template <>
0538 struct WriteDispatcher<const ValueDecl*> {
0539 template <class BasicWriter, class... Args>
0540 static void write(BasicWriter &W, Args &&... args) {
0541 return W.writeValueDeclRef(std::forward<Args>(args)...);
0542 }
0543 };
0544 template <>
0545 struct WriteDispatcher<VectorKind> {
0546 template <class BasicWriter, class... Args>
0547 static void write(BasicWriter &W, Args &&... args) {
0548 return W.writeVectorKind(std::forward<Args>(args)...);
0549 }
0550 };
0551 template <class T>
0552 struct WriteDispatcher<llvm::ArrayRef<T>> {
0553 template <class BasicWriter, class... Args>
0554 static void write(BasicWriter &W, Args &&... args) {
0555 return W.writeArray(std::forward<Args>(args)...);
0556 }
0557 };
0558 template <class T>
0559 struct WriteDispatcher<std::optional<T>> {
0560 template <class BasicWriter, class... Args>
0561 static void write(BasicWriter &W, Args &&... args) {
0562 return W.writeOptional(std::forward<Args>(args)...);
0563 }
0564 };
0565
0566 template <class ValueType>
0567 struct PackOptionalValue;
0568 template <>
0569 struct PackOptionalValue<CXXRecordDecl*> {
0570 static CXXRecordDecl* pack(std::optional<CXXRecordDecl*> value) {
0571 return value.value_or(nullptr);
0572 }
0573 };
0574 template <>
0575 struct PackOptionalValue<const CXXRecordDecl*> {
0576 static const CXXRecordDecl* pack(std::optional<const CXXRecordDecl*> value) {
0577 return value.value_or(nullptr);
0578 }
0579 };
0580 template <>
0581 struct PackOptionalValue<ConceptDecl*> {
0582 static ConceptDecl* pack(std::optional<ConceptDecl*> value) {
0583 return value.value_or(nullptr);
0584 }
0585 };
0586 template <>
0587 struct PackOptionalValue<const ConceptDecl*> {
0588 static const ConceptDecl* pack(std::optional<const ConceptDecl*> value) {
0589 return value.value_or(nullptr);
0590 }
0591 };
0592 template <>
0593 struct PackOptionalValue<Decl*> {
0594 static Decl* pack(std::optional<Decl*> value) {
0595 return value.value_or(nullptr);
0596 }
0597 };
0598 template <>
0599 struct PackOptionalValue<const Decl*> {
0600 static const Decl* pack(std::optional<const Decl*> value) {
0601 return value.value_or(nullptr);
0602 }
0603 };
0604 template <>
0605 struct PackOptionalValue<Expr*> {
0606 static Expr* pack(std::optional<Expr*> value) {
0607 return value.value_or(nullptr);
0608 }
0609 };
0610 template <>
0611 struct PackOptionalValue<const Expr*> {
0612 static const Expr* pack(std::optional<const Expr*> value) {
0613 return value.value_or(nullptr);
0614 }
0615 };
0616 template <>
0617 struct PackOptionalValue<FunctionDecl*> {
0618 static FunctionDecl* pack(std::optional<FunctionDecl*> value) {
0619 return value.value_or(nullptr);
0620 }
0621 };
0622 template <>
0623 struct PackOptionalValue<const FunctionDecl*> {
0624 static const FunctionDecl* pack(std::optional<const FunctionDecl*> value) {
0625 return value.value_or(nullptr);
0626 }
0627 };
0628 template <>
0629 struct PackOptionalValue<IdentifierInfo*> {
0630 static IdentifierInfo* pack(std::optional<IdentifierInfo*> value) {
0631 return value.value_or(nullptr);
0632 }
0633 };
0634 template <>
0635 struct PackOptionalValue<const IdentifierInfo*> {
0636 static const IdentifierInfo* pack(std::optional<const IdentifierInfo*> value) {
0637 return value.value_or(nullptr);
0638 }
0639 };
0640 template <>
0641 struct PackOptionalValue<NamedDecl*> {
0642 static NamedDecl* pack(std::optional<NamedDecl*> value) {
0643 return value.value_or(nullptr);
0644 }
0645 };
0646 template <>
0647 struct PackOptionalValue<const NamedDecl*> {
0648 static const NamedDecl* pack(std::optional<const NamedDecl*> value) {
0649 return value.value_or(nullptr);
0650 }
0651 };
0652 template <>
0653 struct PackOptionalValue<NamespaceAliasDecl*> {
0654 static NamespaceAliasDecl* pack(std::optional<NamespaceAliasDecl*> value) {
0655 return value.value_or(nullptr);
0656 }
0657 };
0658 template <>
0659 struct PackOptionalValue<const NamespaceAliasDecl*> {
0660 static const NamespaceAliasDecl* pack(std::optional<const NamespaceAliasDecl*> value) {
0661 return value.value_or(nullptr);
0662 }
0663 };
0664 template <>
0665 struct PackOptionalValue<NamespaceDecl*> {
0666 static NamespaceDecl* pack(std::optional<NamespaceDecl*> value) {
0667 return value.value_or(nullptr);
0668 }
0669 };
0670 template <>
0671 struct PackOptionalValue<const NamespaceDecl*> {
0672 static const NamespaceDecl* pack(std::optional<const NamespaceDecl*> value) {
0673 return value.value_or(nullptr);
0674 }
0675 };
0676 template <>
0677 struct PackOptionalValue<ObjCProtocolDecl*> {
0678 static ObjCProtocolDecl* pack(std::optional<ObjCProtocolDecl*> value) {
0679 return value.value_or(nullptr);
0680 }
0681 };
0682 template <>
0683 struct PackOptionalValue<const ObjCProtocolDecl*> {
0684 static const ObjCProtocolDecl* pack(std::optional<const ObjCProtocolDecl*> value) {
0685 return value.value_or(nullptr);
0686 }
0687 };
0688 template <>
0689 struct PackOptionalValue<ObjCTypeParamDecl*> {
0690 static ObjCTypeParamDecl* pack(std::optional<ObjCTypeParamDecl*> value) {
0691 return value.value_or(nullptr);
0692 }
0693 };
0694 template <>
0695 struct PackOptionalValue<const ObjCTypeParamDecl*> {
0696 static const ObjCTypeParamDecl* pack(std::optional<const ObjCTypeParamDecl*> value) {
0697 return value.value_or(nullptr);
0698 }
0699 };
0700 template <>
0701 struct PackOptionalValue<QualType> {
0702 static QualType pack(std::optional<QualType> value) {
0703 return value ? *value : QualType();
0704 }
0705 };
0706 template <>
0707 struct PackOptionalValue<Stmt*> {
0708 static Stmt* pack(std::optional<Stmt*> value) {
0709 return value.value_or(nullptr);
0710 }
0711 };
0712 template <>
0713 struct PackOptionalValue<const Stmt*> {
0714 static const Stmt* pack(std::optional<const Stmt*> value) {
0715 return value.value_or(nullptr);
0716 }
0717 };
0718 template <>
0719 struct PackOptionalValue<TagDecl*> {
0720 static TagDecl* pack(std::optional<TagDecl*> value) {
0721 return value.value_or(nullptr);
0722 }
0723 };
0724 template <>
0725 struct PackOptionalValue<const TagDecl*> {
0726 static const TagDecl* pack(std::optional<const TagDecl*> value) {
0727 return value.value_or(nullptr);
0728 }
0729 };
0730 template <>
0731 struct PackOptionalValue<TemplateDecl*> {
0732 static TemplateDecl* pack(std::optional<TemplateDecl*> value) {
0733 return value.value_or(nullptr);
0734 }
0735 };
0736 template <>
0737 struct PackOptionalValue<const TemplateDecl*> {
0738 static const TemplateDecl* pack(std::optional<const TemplateDecl*> value) {
0739 return value.value_or(nullptr);
0740 }
0741 };
0742 template <>
0743 struct PackOptionalValue<TemplateName> {
0744 static TemplateName pack(std::optional<TemplateName> value) {
0745 return value ? *value : TemplateName();
0746 }
0747 };
0748 template <>
0749 struct PackOptionalValue<TemplateTemplateParmDecl*> {
0750 static TemplateTemplateParmDecl* pack(std::optional<TemplateTemplateParmDecl*> value) {
0751 return value.value_or(nullptr);
0752 }
0753 };
0754 template <>
0755 struct PackOptionalValue<const TemplateTemplateParmDecl*> {
0756 static const TemplateTemplateParmDecl* pack(std::optional<const TemplateTemplateParmDecl*> value) {
0757 return value.value_or(nullptr);
0758 }
0759 };
0760 template <>
0761 struct PackOptionalValue<TemplateTypeParmDecl*> {
0762 static TemplateTypeParmDecl* pack(std::optional<TemplateTypeParmDecl*> value) {
0763 return value.value_or(nullptr);
0764 }
0765 };
0766 template <>
0767 struct PackOptionalValue<const TemplateTypeParmDecl*> {
0768 static const TemplateTypeParmDecl* pack(std::optional<const TemplateTypeParmDecl*> value) {
0769 return value.value_or(nullptr);
0770 }
0771 };
0772 template <>
0773 struct PackOptionalValue<uint32_t> {
0774 static uint32_t pack(std::optional<uint32_t> value) {
0775 return value ? *value + 1 : 0;
0776 }
0777 };
0778 template <>
0779 struct PackOptionalValue<uint64_t> {
0780 static uint64_t pack(std::optional<uint64_t> value) {
0781 return value ? *value + 1 : 0;
0782 }
0783 };
0784 template <>
0785 struct PackOptionalValue<UsingShadowDecl*> {
0786 static UsingShadowDecl* pack(std::optional<UsingShadowDecl*> value) {
0787 return value.value_or(nullptr);
0788 }
0789 };
0790 template <>
0791 struct PackOptionalValue<const UsingShadowDecl*> {
0792 static const UsingShadowDecl* pack(std::optional<const UsingShadowDecl*> value) {
0793 return value.value_or(nullptr);
0794 }
0795 };
0796 template <>
0797 struct PackOptionalValue<ValueDecl*> {
0798 static ValueDecl* pack(std::optional<ValueDecl*> value) {
0799 return value.value_or(nullptr);
0800 }
0801 };
0802 template <>
0803 struct PackOptionalValue<const ValueDecl*> {
0804 static const ValueDecl* pack(std::optional<const ValueDecl*> value) {
0805 return value.value_or(nullptr);
0806 }
0807 };
0808
0809 template <class Impl>
0810 class BasicWriterBase {
0811 ASTContext &C;
0812 protected:
0813 BasicWriterBase(ASTContext &ctx) : C(ctx) {}
0814 public:
0815 ASTContext &getASTContext() { return C; }
0816 Impl &asImpl() { return static_cast<Impl&>(*this); }
0817 void writeAPValue(const APValue & node) {
0818 auto &&subW = asImpl().writeObject();
0819 APValue::ValueKind kind = (node.getKind());
0820 subW.find("kind").writeAPValueKind(kind);
0821 switch (kind) {
0822 case APValue::None: {
0823 return;
0824 }
0825
0826 case APValue::Indeterminate: {
0827 return;
0828 }
0829
0830 case APValue::Int: {
0831 llvm::APSInt value = ( node.getInt() );
0832 subW.find("value").writeAPSInt(value);
0833 return;
0834 }
0835
0836 case APValue::Float: {
0837 uint32_t semantics = (
0838 static_cast<uint32_t>(
0839 llvm::APFloatBase::SemanticsToEnum(node.getFloat().getSemantics()))
0840 );
0841 subW.find("semantics").writeUInt32(semantics);
0842 llvm::APInt value = ( node.getFloat().bitcastToAPInt() );
0843 subW.find("value").writeAPInt(value);
0844 return;
0845 }
0846
0847 case APValue::FixedPoint: {
0848 llvm::FixedPointSemantics semantics = ( node.getFixedPoint().getSemantics() );
0849 subW.find("semantics").writeFixedPointSemantics(semantics);
0850 llvm::APSInt value = ( node.getFixedPoint().getValue() );
0851 subW.find("value").writeAPSInt(value);
0852 return;
0853 }
0854
0855 case APValue::ComplexInt: {
0856 llvm::APSInt real = ( node.getComplexIntReal() );
0857 subW.find("real").writeAPSInt(real);
0858 llvm::APSInt imag = ( node.getComplexIntImag() );
0859 subW.find("imag").writeAPSInt(imag);
0860 return;
0861 }
0862
0863 case APValue::ComplexFloat: {
0864
0865 auto sema = llvm::APFloatBase::SemanticsToEnum(
0866 node.getComplexFloatReal().getSemantics());
0867 assert(sema == llvm::APFloatBase::SemanticsToEnum(
0868 node.getComplexFloatImag().getSemantics()));
0869
0870 uint32_t semantics = ( static_cast<uint32_t>(sema) );
0871 subW.find("semantics").writeUInt32(semantics);
0872 llvm::APInt real = ( node.getComplexFloatReal().bitcastToAPInt() );
0873 subW.find("real").writeAPInt(real);
0874 llvm::APInt imag = ( node.getComplexFloatImag().bitcastToAPInt() );
0875 subW.find("imag").writeAPInt(imag);
0876 return;
0877 }
0878
0879 case APValue::Vector: {
0880
0881 SmallVector<APValue, 4> buffer;
0882 unsigned len = node.getVectorLength();
0883 for (unsigned i = 0; i < len; ++i)
0884 buffer.push_back(node.getVectorElt(i));
0885
0886 llvm::ArrayRef<APValue> elements = ( buffer );
0887 subW.find("elements").writeArray(elements);
0888 return;
0889 }
0890
0891 case APValue::Array: {
0892
0893 SmallVector<APValue, 4> buffer{};
0894 unsigned initLength = node.getArrayInitializedElts();
0895 for (unsigned i = 0; i < initLength; ++i)
0896 buffer.push_back(node.getArrayInitializedElt(i));
0897 if (node.hasArrayFiller())
0898 buffer.push_back(node.getArrayFiller());
0899
0900 uint32_t totalLength = ( node.getArraySize() );
0901 subW.find("totalLength").writeUInt32(totalLength);
0902 bool hasFiller = ( node.hasArrayFiller() );
0903 subW.find("hasFiller").writeBool(hasFiller);
0904 llvm::ArrayRef<APValue> elements = ( buffer );
0905 subW.find("elements").writeArray(elements);
0906 return;
0907 }
0908
0909 case APValue::Struct: {
0910
0911 SmallVector<APValue, 4> structBases;
0912 unsigned numBases = node.getStructNumBases();
0913 for (unsigned i = 0; i < numBases; ++i)
0914 structBases.push_back(node.getStructBase(i));
0915 SmallVector<APValue, 4> structFields;
0916 unsigned numFields = node.getStructNumFields();
0917 for (unsigned i = 0; i < numFields; ++i)
0918 structFields.push_back(node.getStructField(i));
0919
0920 llvm::ArrayRef<APValue> bases = ( structBases );
0921 subW.find("bases").writeArray(bases);
0922 llvm::ArrayRef<APValue> fields = ( structFields );
0923 subW.find("fields").writeArray(fields);
0924 return;
0925 }
0926
0927 case APValue::Union: {
0928 const Decl* fieldDecl = ( node.getUnionField() );
0929 subW.find("fieldDecl").writeDeclRef(fieldDecl);
0930 APValue value = ( node.getUnionValue() );
0931 subW.find("value").writeAPValue(value);
0932 return;
0933 }
0934
0935 case APValue::AddrLabelDiff: {
0936 const Stmt* lhs = ( const_cast<AddrLabelExpr *>(node.getAddrLabelDiffLHS()) );
0937 subW.find("lhs").writeStmtRef(lhs);
0938 const Stmt* rhs = ( const_cast<AddrLabelExpr *>(node.getAddrLabelDiffRHS()) );
0939 subW.find("rhs").writeStmtRef(rhs);
0940 return;
0941 }
0942
0943 case APValue::MemberPointer: {
0944 bool isDerived = ( node.isMemberPointerToDerivedMember() );
0945 subW.find("isDerived").writeBool(isDerived);
0946 const ValueDecl* member = ( node.getMemberPointerDecl() );
0947 subW.find("member").writeValueDeclRef(member);
0948 llvm::ArrayRef<const CXXRecordDecl*> memberPath = ( node.getMemberPointerPath() );
0949 subW.find("memberPath").writeArray(memberPath);
0950 return;
0951 }
0952
0953 case APValue::LValue: {
0954
0955 auto lvalueBase = node.getLValueBase();
0956 const Expr *expr =
0957 lvalueBase ? lvalueBase.dyn_cast<const Expr *>() : nullptr;
0958 bool lvalueBaseIsExpr = (bool) expr;
0959 bool lvalueBaseIsTypeInfo = lvalueBase.is<TypeInfoLValue>();
0960 bool lvalueBaseIsDynamicAlloc = lvalueBase.is<DynamicAllocLValue>();
0961 QualType elemTy;
0962 if (lvalueBase) {
0963 if (lvalueBaseIsTypeInfo) {
0964 elemTy = lvalueBase.getTypeInfoType();
0965 } else if (lvalueBaseIsDynamicAlloc) {
0966 elemTy = lvalueBase.getDynamicAllocType();
0967 } else if (lvalueBaseIsExpr) {
0968 elemTy = expr->getType();
0969 } else {
0970 elemTy = lvalueBase.get<const ValueDecl *>()->getType();
0971 }
0972 }
0973
0974 bool hasLValuePath = ( node.hasLValuePath() );
0975 subW.find("hasLValuePath").writeBool(hasLValuePath);
0976 bool isLValueOnePastTheEnd = ( node.isLValueOnePastTheEnd() );
0977 subW.find("isLValueOnePastTheEnd").writeBool(isLValueOnePastTheEnd);
0978 bool isExpr = ( lvalueBaseIsExpr );
0979 subW.find("isExpr").writeBool(isExpr);
0980 bool isTypeInfo = ( lvalueBaseIsTypeInfo );
0981 subW.find("isTypeInfo").writeBool(isTypeInfo);
0982 bool isDynamicAlloc = ( lvalueBaseIsDynamicAlloc );
0983 subW.find("isDynamicAlloc").writeBool(isDynamicAlloc);
0984 bool hasBase = ( static_cast<bool>(lvalueBase) );
0985 subW.find("hasBase").writeBool(hasBase);
0986 bool isNullPtr = ( node.isNullPointer() );
0987 subW.find("isNullPtr").writeBool(isNullPtr);
0988 if ( hasBase && isTypeInfo ) {
0989 QualType typeInfo = (
0990 QualType(node.getLValueBase().get<TypeInfoLValue>().getType(), 0)
0991 );
0992 subW.find("typeInfo").writeQualType(typeInfo);
0993 }
0994 if ( hasBase && isDynamicAlloc ) {
0995 uint32_t dynamicAlloc = ( node.getLValueBase().get<DynamicAllocLValue>().getIndex() );
0996 subW.find("dynamicAlloc").writeUInt32(dynamicAlloc);
0997 }
0998 if ( hasBase && (isTypeInfo || isDynamicAlloc) ) {
0999 QualType type = (
1000 isTypeInfo
1001 ? node.getLValueBase().getTypeInfoType()
1002 : node.getLValueBase().getDynamicAllocType()
1003 );
1004 subW.find("type").writeQualType(type);
1005 }
1006 if ( hasBase && !isTypeInfo ) {
1007 uint32_t callIndex = ( node.getLValueBase().getCallIndex() );
1008 subW.find("callIndex").writeUInt32(callIndex);
1009 }
1010 if ( hasBase && !isTypeInfo ) {
1011 uint32_t version = ( node.getLValueBase().getVersion() );
1012 subW.find("version").writeUInt32(version);
1013 }
1014 if ( hasBase && !isTypeInfo && isExpr ) {
1015 const Stmt* stmt = ( const_cast<Expr *>(expr) );
1016 subW.find("stmt").writeStmtRef(stmt);
1017 }
1018 if ( hasBase && !isTypeInfo && !isDynamicAlloc && !isExpr ) {
1019 const Decl* decl = ( lvalueBase.get<const ValueDecl *>() );
1020 subW.find("decl").writeDeclRef(decl);
1021 }
1022 uint32_t offsetQuantity = ( node.getLValueOffset().getQuantity() );
1023 subW.find("offsetQuantity").writeUInt32(offsetQuantity);
1024 if ( hasLValuePath ) {
1025 APValue::LValuePathSerializationHelper lvaluePath = (
1026 APValue::LValuePathSerializationHelper(node.getLValuePath(), elemTy)
1027 );
1028 subW.find("lvaluePath").writeLValuePathSerializationHelper(lvaluePath);
1029 }
1030 return;
1031 }
1032
1033 }
1034 llvm_unreachable("bad APValue::ValueKind");
1035 }
1036 void writeAPValueKind(APValue::ValueKind value) {
1037 asImpl().writeEnum(value);
1038 }
1039 void writeArraySizeModifier(ArraySizeModifier value) {
1040 asImpl().writeEnum(value);
1041 }
1042 void writeAttrKind(attr::Kind value) {
1043 asImpl().writeEnum(value);
1044 }
1045 void writeAutoTypeKeyword(AutoTypeKeyword value) {
1046 asImpl().writeEnum(value);
1047 }
1048 void writeBuiltinTypeKind(BuiltinType::Kind value) {
1049 asImpl().writeEnum(value);
1050 }
1051 void writeCXXRecordDeclRef(const CXXRecordDecl* value) {
1052 asImpl().writeDeclRef(value);
1053 }
1054 void writeCallingConv(CallingConv value) {
1055 asImpl().writeEnum(value);
1056 }
1057 void writeConceptDeclRef(const ConceptDecl* value) {
1058 asImpl().writeDeclRef(value);
1059 }
1060 void writeDeclarationName(DeclarationName node) {
1061 auto &&subW = asImpl().writeObject();
1062 DeclarationName::NameKind kind = (node.getNameKind());
1063 subW.find("kind").writeDeclarationNameKind(kind);
1064 switch (kind) {
1065 case DeclarationName::Identifier: {
1066 const IdentifierInfo* identifier = ( node.getAsIdentifierInfo() );
1067 subW.find("identifier").writeIdentifier(identifier);
1068 return;
1069 }
1070
1071 case DeclarationName::ObjCZeroArgSelector: {
1072 Selector selector = ( node.getObjCSelector() );
1073 subW.find("selector").writeSelector(selector);
1074 return;
1075 }
1076
1077 case DeclarationName::ObjCOneArgSelector: {
1078 Selector selector = ( node.getObjCSelector() );
1079 subW.find("selector").writeSelector(selector);
1080 return;
1081 }
1082
1083 case DeclarationName::ObjCMultiArgSelector: {
1084 Selector selector = ( node.getObjCSelector() );
1085 subW.find("selector").writeSelector(selector);
1086 return;
1087 }
1088
1089 case DeclarationName::CXXConstructorName: {
1090 QualType type = ( node.getCXXNameType() );
1091 subW.find("type").writeQualType(type);
1092 return;
1093 }
1094
1095 case DeclarationName::CXXDestructorName: {
1096 QualType type = ( node.getCXXNameType() );
1097 subW.find("type").writeQualType(type);
1098 return;
1099 }
1100
1101 case DeclarationName::CXXConversionFunctionName: {
1102 QualType type = ( node.getCXXNameType() );
1103 subW.find("type").writeQualType(type);
1104 return;
1105 }
1106
1107 case DeclarationName::CXXDeductionGuideName: {
1108 const TemplateDecl* declaration = ( node.getCXXDeductionGuideTemplate() );
1109 subW.find("declaration").writeTemplateDeclRef(declaration);
1110 return;
1111 }
1112
1113 case DeclarationName::CXXOperatorName: {
1114 OverloadedOperatorKind operatorKind = ( node.getCXXOverloadedOperator() );
1115 subW.find("operatorKind").writeOverloadedOperatorKind(operatorKind);
1116 return;
1117 }
1118
1119 case DeclarationName::CXXLiteralOperatorName: {
1120 const IdentifierInfo* identifier = ( node.getCXXLiteralIdentifier() );
1121 subW.find("identifier").writeIdentifier(identifier);
1122 return;
1123 }
1124
1125 case DeclarationName::CXXUsingDirective: {
1126 return;
1127 }
1128
1129 }
1130 llvm_unreachable("bad DeclarationName::NameKind");
1131 }
1132 void writeDeclarationNameKind(DeclarationName::NameKind value) {
1133 asImpl().writeEnum(value);
1134 }
1135 void writeElaboratedTypeKeyword(ElaboratedTypeKeyword value) {
1136 asImpl().writeEnum(value);
1137 }
1138 void writeExprRef(const Expr* value) {
1139 asImpl().writeStmtRef(value);
1140 }
1141 void writeFunctionDeclRef(const FunctionDecl* value) {
1142 asImpl().writeDeclRef(value);
1143 }
1144 void writeNamedDeclRef(const NamedDecl* value) {
1145 asImpl().writeDeclRef(value);
1146 }
1147 void writeNamespaceAliasDeclRef(const NamespaceAliasDecl* value) {
1148 asImpl().writeDeclRef(value);
1149 }
1150 void writeNamespaceDeclRef(const NamespaceDecl* value) {
1151 asImpl().writeDeclRef(value);
1152 }
1153 void writeNestedNameSpecifierKind(NestedNameSpecifier::SpecifierKind value) {
1154 asImpl().writeEnum(value);
1155 }
1156 void writeObjCProtocolDeclRef(const ObjCProtocolDecl* value) {
1157 asImpl().writeDeclRef(value);
1158 }
1159 void writeObjCTypeParamDeclRef(const ObjCTypeParamDecl* value) {
1160 asImpl().writeDeclRef(value);
1161 }
1162 void writeOverloadedOperatorKind(OverloadedOperatorKind value) {
1163 asImpl().writeEnum(value);
1164 }
1165 void writeRefQualifierKind(RefQualifierKind value) {
1166 asImpl().writeEnum(value);
1167 }
1168 void writeSubstTemplateTypeParmTypeFlag(SubstTemplateTypeParmTypeFlag value) {
1169 asImpl().writeEnum(value);
1170 }
1171 void writeTagDeclRef(const TagDecl* value) {
1172 asImpl().writeDeclRef(value);
1173 }
1174 void writeTemplateArgument(TemplateArgument node) {
1175 auto &&subW = asImpl().writeObject();
1176 TemplateArgument::ArgKind kind = (node.getKind());
1177 subW.find("kind").writeTemplateArgumentKind(kind);
1178 switch (kind) {
1179 case TemplateArgument::Null: {
1180 return;
1181 }
1182
1183 case TemplateArgument::Type: {
1184 QualType type = ( node.getAsType() );
1185 subW.find("type").writeQualType(type);
1186 bool isDefaulted = ( node.getIsDefaulted() );
1187 subW.find("isDefaulted").writeBool(isDefaulted);
1188 return;
1189 }
1190
1191 case TemplateArgument::Declaration: {
1192 const ValueDecl* declaration = ( node.getAsDecl() );
1193 subW.find("declaration").writeValueDeclRef(declaration);
1194 QualType parameterType = ( node.getParamTypeForDecl() );
1195 subW.find("parameterType").writeQualType(parameterType);
1196 bool isDefaulted = ( node.getIsDefaulted() );
1197 subW.find("isDefaulted").writeBool(isDefaulted);
1198 return;
1199 }
1200
1201 case TemplateArgument::NullPtr: {
1202 QualType type = ( node.getNullPtrType() );
1203 subW.find("type").writeQualType(type);
1204 bool isDefaulted = ( node.getIsDefaulted() );
1205 subW.find("isDefaulted").writeBool(isDefaulted);
1206 return;
1207 }
1208
1209 case TemplateArgument::Integral: {
1210 llvm::APSInt value = ( node.getAsIntegral() );
1211 subW.find("value").writeAPSInt(value);
1212 QualType type = ( node.getIntegralType() );
1213 subW.find("type").writeQualType(type);
1214 bool isDefaulted = ( node.getIsDefaulted() );
1215 subW.find("isDefaulted").writeBool(isDefaulted);
1216 return;
1217 }
1218
1219 case TemplateArgument::StructuralValue: {
1220 APValue value = ( node.getAsStructuralValue() );
1221 subW.find("value").writeAPValue(value);
1222 QualType type = ( node.getStructuralValueType() );
1223 subW.find("type").writeQualType(type);
1224 bool isDefaulted = ( node.getIsDefaulted() );
1225 subW.find("isDefaulted").writeBool(isDefaulted);
1226 return;
1227 }
1228
1229 case TemplateArgument::Template: {
1230 TemplateName name = ( node.getAsTemplateOrTemplatePattern() );
1231 subW.find("name").writeTemplateName(name);
1232 bool isDefaulted = ( node.getIsDefaulted() );
1233 subW.find("isDefaulted").writeBool(isDefaulted);
1234 return;
1235 }
1236
1237 case TemplateArgument::TemplateExpansion: {
1238 TemplateName name = ( node.getAsTemplateOrTemplatePattern() );
1239 subW.find("name").writeTemplateName(name);
1240 std::optional<uint32_t> numExpansions = (
1241 // Translate unsigned -> uint32_t just in case.
1242 llvm::transformOptional(node.getNumTemplateExpansions(),
1243 [](unsigned i) { return uint32_t(i); })
1244 );
1245 subW.find("numExpansions").writeOptional(numExpansions);
1246 bool isDefaulted = ( node.getIsDefaulted() );
1247 subW.find("isDefaulted").writeBool(isDefaulted);
1248 return;
1249 }
1250
1251 case TemplateArgument::Expression: {
1252 const Expr* expression = ( node.getAsExpr() );
1253 subW.find("expression").writeExprRef(expression);
1254 bool isDefaulted = ( node.getIsDefaulted() );
1255 subW.find("isDefaulted").writeBool(isDefaulted);
1256 return;
1257 }
1258
1259 case TemplateArgument::Pack: {
1260 llvm::ArrayRef<TemplateArgument> elements = ( node.pack_elements() );
1261 subW.find("elements").writeArray(elements);
1262 return;
1263 }
1264
1265 }
1266 llvm_unreachable("bad TemplateArgument::ArgKind");
1267 }
1268 void writeTemplateArgumentKind(TemplateArgument::ArgKind value) {
1269 asImpl().writeEnum(value);
1270 }
1271 void writeTemplateDeclRef(const TemplateDecl* value) {
1272 asImpl().writeDeclRef(value);
1273 }
1274 void writeTemplateName(TemplateName node) {
1275 auto &&subW = asImpl().writeObject();
1276 TemplateName::NameKind kind = (node.getKind());
1277 subW.find("kind").writeTemplateNameKind(kind);
1278 switch (kind) {
1279 case TemplateName::Template: {
1280 const TemplateDecl* declaration = ( node.getAsTemplateDecl() );
1281 subW.find("declaration").writeTemplateDeclRef(declaration);
1282 return;
1283 }
1284
1285 case TemplateName::UsingTemplate: {
1286 const UsingShadowDecl* foundDecl = ( node.getAsUsingShadowDecl() );
1287 subW.find("foundDecl").writeUsingShadowDeclRef(foundDecl);
1288 return;
1289 }
1290
1291 case TemplateName::OverloadedTemplate: {
1292 llvm::ArrayRef<const NamedDecl*> overloads = ( node.getAsOverloadedTemplate()->decls() );
1293 subW.find("overloads").writeArray(overloads);
1294 return;
1295 }
1296
1297 case TemplateName::AssumedTemplate: {
1298 DeclarationName name = ( node.getAsAssumedTemplateName()->getDeclName() );
1299 subW.find("name").writeDeclarationName(name);
1300 return;
1301 }
1302
1303 case TemplateName::QualifiedTemplate: {
1304
1305 auto qtn = node.getAsQualifiedTemplateName();
1306
1307 NestedNameSpecifier * qualifier = ( qtn->getQualifier() );
1308 subW.find("qualifier").writeNestedNameSpecifier(qualifier);
1309 bool hasTemplateKeyword = ( qtn->hasTemplateKeyword() );
1310 subW.find("hasTemplateKeyword").writeBool(hasTemplateKeyword);
1311 TemplateName underlyingTemplateName = ( qtn->getUnderlyingTemplate() );
1312 subW.find("underlyingTemplateName").writeTemplateName(underlyingTemplateName);
1313 return;
1314 }
1315
1316 case TemplateName::DependentTemplate: {
1317
1318 auto dtn = node.getAsDependentTemplateName();
1319
1320 NestedNameSpecifier * qualifier = ( dtn->getQualifier() );
1321 subW.find("qualifier").writeNestedNameSpecifier(qualifier);
1322 std::optional<const IdentifierInfo*> identifier = ( makeOptionalFromPointer(
1323 dtn->isIdentifier()
1324 ? dtn->getIdentifier()
1325 : nullptr) );
1326 subW.find("identifier").writeOptional(identifier);
1327 if ( !identifier ) {
1328 OverloadedOperatorKind operatorKind = ( dtn->getOperator() );
1329 subW.find("operatorKind").writeOverloadedOperatorKind(operatorKind);
1330 }
1331 return;
1332 }
1333
1334 case TemplateName::SubstTemplateTemplateParm: {
1335
1336 auto parm = node.getAsSubstTemplateTemplateParm();
1337
1338 TemplateName replacement = ( parm->getReplacement() );
1339 subW.find("replacement").writeTemplateName(replacement);
1340 const Decl* associatedDecl = ( parm->getAssociatedDecl() );
1341 subW.find("associatedDecl").writeDeclRef(associatedDecl);
1342 uint32_t index = ( parm->getIndex() );
1343 subW.find("index").writeUInt32(index);
1344 std::optional<uint32_t> packIndex = ( parm->getPackIndex() );
1345 subW.find("packIndex").writeOptional(packIndex);
1346 return;
1347 }
1348
1349 case TemplateName::SubstTemplateTemplateParmPack: {
1350
1351 auto parm = node.getAsSubstTemplateTemplateParmPack();
1352
1353 TemplateArgument argumentPack = ( parm->getArgumentPack() );
1354 subW.find("argumentPack").writeTemplateArgument(argumentPack);
1355 const Decl* associatedDecl = ( parm->getAssociatedDecl() );
1356 subW.find("associatedDecl").writeDeclRef(associatedDecl);
1357 uint32_t index = ( parm->getIndex() );
1358 subW.find("index").writeUInt32(index);
1359 bool final = ( parm->getFinal() );
1360 subW.find("final").writeBool(final);
1361 return;
1362 }
1363
1364 case TemplateName::DeducedTemplate: {
1365
1366 auto DTS = node.getAsDeducedTemplateName();
1367
1368 TemplateName underlying = ( DTS->getUnderlying() );
1369 subW.find("underlying").writeTemplateName(underlying);
1370 uint32_t startPos = ( DTS->getDefaultArguments().StartPos );
1371 subW.find("startPos").writeUInt32(startPos);
1372 llvm::ArrayRef<TemplateArgument> defaultArgs = ( DTS->getDefaultArguments().Args );
1373 subW.find("defaultArgs").writeArray(defaultArgs);
1374 return;
1375 }
1376
1377 }
1378 llvm_unreachable("bad TemplateName::NameKind");
1379 }
1380 void writeTemplateNameKind(TemplateName::NameKind value) {
1381 asImpl().writeEnum(value);
1382 }
1383 void writeTemplateTemplateParmDeclRef(const TemplateTemplateParmDecl* value) {
1384 asImpl().writeDeclRef(value);
1385 }
1386 void writeTemplateTypeParmDeclRef(const TemplateTypeParmDecl* value) {
1387 asImpl().writeDeclRef(value);
1388 }
1389 void writeTypeOfKind(TypeOfKind value) {
1390 asImpl().writeEnum(value);
1391 }
1392 void writeUnaryTypeTransformKind(UnaryTransformType::UTTKind value) {
1393 asImpl().writeEnum(value);
1394 }
1395 void writeUsingShadowDeclRef(const UsingShadowDecl* value) {
1396 asImpl().writeDeclRef(value);
1397 }
1398 void writeValueDeclRef(const ValueDecl* value) {
1399 asImpl().writeDeclRef(value);
1400 }
1401 void writeVectorKind(VectorKind value) {
1402 asImpl().writeEnum(value);
1403 }
1404 };
1405