/*===- TableGen'erated file -------------------------------------*- C++ -*-===*\ |* *| |* Helper classes for BasicReaders *| |* *| |* Automatically generated file, do not edit! *| |* From: PropertiesBase.td *| |* *| \*===----------------------------------------------------------------------===*/ template struct ReadDispatcher; template <> struct ReadDispatcher { template static llvm::APInt read(BasicReader &R, Args &&... args) { return R.readAPInt(std::forward(args)...); } }; template <> struct ReadDispatcher { template static llvm::APSInt read(BasicReader &R, Args &&... args) { return R.readAPSInt(std::forward(args)...); } }; template <> struct ReadDispatcher { template static APValue read(BasicReader &R, Args &&... args) { return R.readAPValue(std::forward(args)...); } }; template <> struct ReadDispatcher { template static APValue::ValueKind read(BasicReader &R, Args &&... args) { return R.readAPValueKind(std::forward(args)...); } }; template <> struct ReadDispatcher { template static ArraySizeModifier read(BasicReader &R, Args &&... args) { return R.readArraySizeModifier(std::forward(args)...); } }; template <> struct ReadDispatcher { template static attr::Kind read(BasicReader &R, Args &&... args) { return R.readAttrKind(std::forward(args)...); } }; template <> struct ReadDispatcher { template static AutoTypeKeyword read(BasicReader &R, Args &&... args) { return R.readAutoTypeKeyword(std::forward(args)...); } }; template <> struct ReadDispatcher { template static const BTFTypeTagAttr * read(BasicReader &R, Args &&... args) { return R.readBTFTypeTagAttr(std::forward(args)...); } }; template <> struct ReadDispatcher { template static bool read(BasicReader &R, Args &&... args) { return R.readBool(std::forward(args)...); } }; template <> struct ReadDispatcher { template static BuiltinType::Kind read(BasicReader &R, Args &&... args) { return R.readBuiltinTypeKind(std::forward(args)...); } }; template <> struct ReadDispatcher { template static CXXRecordDecl* read(BasicReader &R, Args &&... args) { return R.readCXXRecordDeclRef(std::forward(args)...); } }; template <> struct ReadDispatcher { template static CallingConv read(BasicReader &R, Args &&... args) { return R.readCallingConv(std::forward(args)...); } }; template <> struct ReadDispatcher { template static ConceptDecl* read(BasicReader &R, Args &&... args) { return R.readConceptDeclRef(std::forward(args)...); } }; template <> struct ReadDispatcher { template static Decl* read(BasicReader &R, Args &&... args) { return R.readDeclRef(std::forward(args)...); } }; template <> struct ReadDispatcher { template static DeclarationName read(BasicReader &R, Args &&... args) { return R.readDeclarationName(std::forward(args)...); } }; template <> struct ReadDispatcher { template static DeclarationName::NameKind read(BasicReader &R, Args &&... args) { return R.readDeclarationNameKind(std::forward(args)...); } }; template <> struct ReadDispatcher { template static EffectConditionExpr read(BasicReader &R, Args &&... args) { return R.readEffectConditionExpr(std::forward(args)...); } }; template <> struct ReadDispatcher { template static ElaboratedTypeKeyword read(BasicReader &R, Args &&... args) { return R.readElaboratedTypeKeyword(std::forward(args)...); } }; template <> struct ReadDispatcher { template static FunctionProtoType::ExceptionSpecInfo read(BasicReader &R, Args &&... args) { return R.readExceptionSpecInfo(std::forward(args)...); } }; template <> struct ReadDispatcher { template static Expr* read(BasicReader &R, Args &&... args) { return R.readExprRef(std::forward(args)...); } }; template <> struct ReadDispatcher { template static FunctionProtoType::ExtParameterInfo read(BasicReader &R, Args &&... args) { return R.readExtParameterInfo(std::forward(args)...); } }; template <> struct ReadDispatcher { template static llvm::FixedPointSemantics read(BasicReader &R, Args &&... args) { return R.readFixedPointSemantics(std::forward(args)...); } }; template <> struct ReadDispatcher { template static FunctionDecl* read(BasicReader &R, Args &&... args) { return R.readFunctionDeclRef(std::forward(args)...); } }; template <> struct ReadDispatcher { template static FunctionEffect read(BasicReader &R, Args &&... args) { return R.readFunctionEffect(std::forward(args)...); } }; template <> struct ReadDispatcher { template static IdentifierInfo* read(BasicReader &R, Args &&... args) { return R.readIdentifier(std::forward(args)...); } }; template <> struct ReadDispatcher { template static APValue::LValuePathEntry read(BasicReader &R, Args &&... args) { return R.readLValuePathEntry(std::forward(args)...); } }; template <> struct ReadDispatcher { template static APValue::LValuePathSerializationHelper read(BasicReader &R, Args &&... args) { return R.readLValuePathSerializationHelper(std::forward(args)...); } }; template <> struct ReadDispatcher { template static NamedDecl* read(BasicReader &R, Args &&... args) { return R.readNamedDeclRef(std::forward(args)...); } }; template <> struct ReadDispatcher { template static NamespaceAliasDecl* read(BasicReader &R, Args &&... args) { return R.readNamespaceAliasDeclRef(std::forward(args)...); } }; template <> struct ReadDispatcher { template static NamespaceDecl* read(BasicReader &R, Args &&... args) { return R.readNamespaceDeclRef(std::forward(args)...); } }; template <> struct ReadDispatcher { template static NestedNameSpecifier * read(BasicReader &R, Args &&... args) { return R.readNestedNameSpecifier(std::forward(args)...); } }; template <> struct ReadDispatcher { template static NestedNameSpecifier::SpecifierKind read(BasicReader &R, Args &&... args) { return R.readNestedNameSpecifierKind(std::forward(args)...); } }; template <> struct ReadDispatcher { template static ObjCProtocolDecl* read(BasicReader &R, Args &&... args) { return R.readObjCProtocolDeclRef(std::forward(args)...); } }; template <> struct ReadDispatcher { template static ObjCTypeParamDecl* read(BasicReader &R, Args &&... args) { return R.readObjCTypeParamDeclRef(std::forward(args)...); } }; template <> struct ReadDispatcher { template static OverloadedOperatorKind read(BasicReader &R, Args &&... args) { return R.readOverloadedOperatorKind(std::forward(args)...); } }; template <> struct ReadDispatcher { template static QualType read(BasicReader &R, Args &&... args) { return R.readQualType(std::forward(args)...); } }; template <> struct ReadDispatcher { template static Qualifiers read(BasicReader &R, Args &&... args) { return R.readQualifiers(std::forward(args)...); } }; template <> struct ReadDispatcher { template static RefQualifierKind read(BasicReader &R, Args &&... args) { return R.readRefQualifierKind(std::forward(args)...); } }; template <> struct ReadDispatcher { template static Selector read(BasicReader &R, Args &&... args) { return R.readSelector(std::forward(args)...); } }; template <> struct ReadDispatcher { template static SourceLocation read(BasicReader &R, Args &&... args) { return R.readSourceLocation(std::forward(args)...); } }; template <> struct ReadDispatcher { template static Stmt* read(BasicReader &R, Args &&... args) { return R.readStmtRef(std::forward(args)...); } }; template <> struct ReadDispatcher { template static TagDecl* read(BasicReader &R, Args &&... args) { return R.readTagDeclRef(std::forward(args)...); } }; template <> struct ReadDispatcher { template static TemplateArgument read(BasicReader &R, Args &&... args) { return R.readTemplateArgument(std::forward(args)...); } }; template <> struct ReadDispatcher { template static TemplateArgument::ArgKind read(BasicReader &R, Args &&... args) { return R.readTemplateArgumentKind(std::forward(args)...); } }; template <> struct ReadDispatcher { template static TemplateDecl* read(BasicReader &R, Args &&... args) { return R.readTemplateDeclRef(std::forward(args)...); } }; template <> struct ReadDispatcher { template static TemplateName read(BasicReader &R, Args &&... args) { return R.readTemplateName(std::forward(args)...); } }; template <> struct ReadDispatcher { template static TemplateName::NameKind read(BasicReader &R, Args &&... args) { return R.readTemplateNameKind(std::forward(args)...); } }; template <> struct ReadDispatcher { template static TemplateTemplateParmDecl* read(BasicReader &R, Args &&... args) { return R.readTemplateTemplateParmDeclRef(std::forward(args)...); } }; template <> struct ReadDispatcher { template static TemplateTypeParmDecl* read(BasicReader &R, Args &&... args) { return R.readTemplateTypeParmDeclRef(std::forward(args)...); } }; template <> struct ReadDispatcher { template static TypeCoupledDeclRefInfo read(BasicReader &R, Args &&... args) { return R.readTypeCoupledDeclRefInfo(std::forward(args)...); } }; template <> struct ReadDispatcher { template static TypeOfKind read(BasicReader &R, Args &&... args) { return R.readTypeOfKind(std::forward(args)...); } }; template <> struct ReadDispatcher { template static uint32_t read(BasicReader &R, Args &&... args) { return R.readUInt32(std::forward(args)...); } }; template <> struct ReadDispatcher { template static uint64_t read(BasicReader &R, Args &&... args) { return R.readUInt64(std::forward(args)...); } }; template <> struct ReadDispatcher { template static UnaryTransformType::UTTKind read(BasicReader &R, Args &&... args) { return R.readUnaryTypeTransformKind(std::forward(args)...); } }; template <> struct ReadDispatcher { template static UsingShadowDecl* read(BasicReader &R, Args &&... args) { return R.readUsingShadowDeclRef(std::forward(args)...); } }; template <> struct ReadDispatcher { template static ValueDecl* read(BasicReader &R, Args &&... args) { return R.readValueDeclRef(std::forward(args)...); } }; template <> struct ReadDispatcher { template static VectorKind read(BasicReader &R, Args &&... args) { return R.readVectorKind(std::forward(args)...); } }; template struct ReadDispatcher> { template static llvm::ArrayRef read(BasicReader &R, Args &&... args) { return R.readArray(std::forward(args)...); } }; template struct ReadDispatcher> { template static std::optional read(BasicReader &R, Args &&... args) { return R.readOptional(std::forward(args)...); } }; template struct UnpackOptionalValue; template <> struct UnpackOptionalValue { static std::optional unpack(CXXRecordDecl* value) { return value ? std::optional(value) : std::nullopt; } }; template <> struct UnpackOptionalValue { static std::optional unpack(ConceptDecl* value) { return value ? std::optional(value) : std::nullopt; } }; template <> struct UnpackOptionalValue { static std::optional unpack(Decl* value) { return value ? std::optional(value) : std::nullopt; } }; template <> struct UnpackOptionalValue { static std::optional unpack(Expr* value) { return value ? std::optional(value) : std::nullopt; } }; template <> struct UnpackOptionalValue { static std::optional unpack(FunctionDecl* value) { return value ? std::optional(value) : std::nullopt; } }; template <> struct UnpackOptionalValue { static std::optional unpack(IdentifierInfo* value) { return value ? std::optional(value) : std::nullopt; } }; template <> struct UnpackOptionalValue { static std::optional unpack(NamedDecl* value) { return value ? std::optional(value) : std::nullopt; } }; template <> struct UnpackOptionalValue { static std::optional unpack(NamespaceAliasDecl* value) { return value ? std::optional(value) : std::nullopt; } }; template <> struct UnpackOptionalValue { static std::optional unpack(NamespaceDecl* value) { return value ? std::optional(value) : std::nullopt; } }; template <> struct UnpackOptionalValue { static std::optional unpack(ObjCProtocolDecl* value) { return value ? std::optional(value) : std::nullopt; } }; template <> struct UnpackOptionalValue { static std::optional unpack(ObjCTypeParamDecl* value) { return value ? std::optional(value) : std::nullopt; } }; template <> struct UnpackOptionalValue { static std::optional unpack(QualType value) { return value.isNull() ? std::nullopt : std::optional(value); } }; template <> struct UnpackOptionalValue { static std::optional unpack(Stmt* value) { return value ? std::optional(value) : std::nullopt; } }; template <> struct UnpackOptionalValue { static std::optional unpack(TagDecl* value) { return value ? std::optional(value) : std::nullopt; } }; template <> struct UnpackOptionalValue { static std::optional unpack(TemplateDecl* value) { return value ? std::optional(value) : std::nullopt; } }; template <> struct UnpackOptionalValue { static std::optional unpack(TemplateName value) { return value.isNull() ? std::nullopt : std::optional(value); } }; template <> struct UnpackOptionalValue { static std::optional unpack(TemplateTemplateParmDecl* value) { return value ? std::optional(value) : std::nullopt; } }; template <> struct UnpackOptionalValue { static std::optional unpack(TemplateTypeParmDecl* value) { return value ? std::optional(value) : std::nullopt; } }; template <> struct UnpackOptionalValue { static std::optional unpack(uint32_t value) { return value ? std::optional(value - 1) : std::nullopt; } }; template <> struct UnpackOptionalValue { static std::optional unpack(uint64_t value) { return value ? std::optional(value - 1) : std::nullopt; } }; template <> struct UnpackOptionalValue { static std::optional unpack(UsingShadowDecl* value) { return value ? std::optional(value) : std::nullopt; } }; template <> struct UnpackOptionalValue { static std::optional unpack(ValueDecl* value) { return value ? std::optional(value) : std::nullopt; } }; template class BasicReaderBase { ASTContext &C; protected: BasicReaderBase(ASTContext &ctx) : C(ctx) {} public: ASTContext &getASTContext() { return C; } Impl &asImpl() { return static_cast(*this); } APValue readAPValue() { auto &ctx = asImpl().getASTContext(); auto &&subR = asImpl().readObject(); APValue::ValueKind kind = subR.find("kind").readAPValueKind(); switch (kind) { case APValue::None: { return APValue(); } case APValue::Indeterminate: { return APValue::IndeterminateValue(); } case APValue::Int: { llvm::APSInt value = subR.find("value").readAPSInt(); return APValue(value); } case APValue::Float: { uint32_t semantics = subR.find("semantics").readUInt32(); llvm::APInt value = subR.find("value").readAPInt(); const llvm::fltSemantics &floatSema = llvm::APFloatBase::EnumToSemantics( static_cast(semantics)); return APValue(llvm::APFloat(floatSema, value)); } case APValue::FixedPoint: { llvm::FixedPointSemantics semantics = subR.find("semantics").readFixedPointSemantics(); llvm::APSInt value = subR.find("value").readAPSInt(); return APValue(llvm::APFixedPoint(std::move(value), semantics)); } case APValue::ComplexInt: { llvm::APSInt real = subR.find("real").readAPSInt(); llvm::APSInt imag = subR.find("imag").readAPSInt(); return APValue(real, imag); } case APValue::ComplexFloat: { uint32_t semantics = subR.find("semantics").readUInt32(); llvm::APInt real = subR.find("real").readAPInt(); llvm::APInt imag = subR.find("imag").readAPInt(); const llvm::fltSemantics &sema = llvm::APFloatBase::EnumToSemantics( static_cast(semantics)); return APValue(llvm::APFloat(sema, real), llvm::APFloat(sema, imag)); } case APValue::Vector: { llvm::SmallVector elements_buffer_0; llvm::ArrayRef elements = subR.find("elements").template readArray(elements_buffer_0); APValue result; result.MakeVector(); unsigned length = elements.size(); (void)result.setVectorUninit(length); for (unsigned i = 0; i < length; i++) result.getVectorElt(i) = elements[i]; return result; } case APValue::Array: { uint32_t totalLength = subR.find("totalLength").readUInt32(); bool hasFiller = subR.find("hasFiller").readBool(); llvm::SmallVector elements_buffer_0; llvm::ArrayRef elements = subR.find("elements").template readArray(elements_buffer_0); APValue result; unsigned initLength = elements.size() - (hasFiller ? 1 : 0); result.MakeArray(initLength, totalLength); for (unsigned i = 0; i < initLength; ++i) result.getArrayInitializedElt(i) = elements[i]; if (hasFiller) result.getArrayFiller() = elements.back(); return result; } case APValue::Struct: { llvm::SmallVector bases_buffer_0; llvm::ArrayRef bases = subR.find("bases").template readArray(bases_buffer_0); llvm::SmallVector fields_buffer_0; llvm::ArrayRef fields = subR.find("fields").template readArray(fields_buffer_0); APValue result; result.MakeStruct(bases.size(), fields.size()); for (unsigned i = 0; i < bases.size(); ++i) result.getStructBase(i) = bases[i]; for (unsigned i = 0; i < fields.size(); ++i) result.getStructField(i) = fields[i]; return result; } case APValue::Union: { Decl* fieldDecl = subR.find("fieldDecl").readDeclRef(); APValue value = subR.find("value").readAPValue(); return APValue(cast(fieldDecl), std::move(value)); } case APValue::AddrLabelDiff: { Stmt* lhs = subR.find("lhs").readStmtRef(); Stmt* rhs = subR.find("rhs").readStmtRef(); return APValue(cast(lhs), cast(rhs)); } case APValue::MemberPointer: { bool isDerived = subR.find("isDerived").readBool(); ValueDecl* member = subR.find("member").readValueDeclRef(); llvm::SmallVector memberPath_buffer_0; llvm::ArrayRef memberPath = subR.find("memberPath").template readArray(memberPath_buffer_0); APValue result; unsigned pathSize = memberPath.size(); const CXXRecordDecl **pathArray = result.setMemberPointerUninit(member, isDerived, pathSize).data(); for (unsigned i = 0; i < pathSize; ++i) pathArray[i] = memberPath[i]->getCanonicalDecl(); return result; } case APValue::LValue: { bool hasLValuePath = subR.find("hasLValuePath").readBool(); bool isLValueOnePastTheEnd = subR.find("isLValueOnePastTheEnd").readBool(); bool isExpr = subR.find("isExpr").readBool(); bool isTypeInfo = subR.find("isTypeInfo").readBool(); bool isDynamicAlloc = subR.find("isDynamicAlloc").readBool(); bool hasBase = subR.find("hasBase").readBool(); bool isNullPtr = subR.find("isNullPtr").readBool(); std::optional typeInfo; if ( hasBase && isTypeInfo ) { typeInfo.emplace(subR.find("typeInfo").readQualType()); } std::optional dynamicAlloc; if ( hasBase && isDynamicAlloc ) { dynamicAlloc.emplace(subR.find("dynamicAlloc").readUInt32()); } std::optional type; if ( hasBase && (isTypeInfo || isDynamicAlloc) ) { type.emplace(subR.find("type").readQualType()); } std::optional callIndex; if ( hasBase && !isTypeInfo ) { callIndex.emplace(subR.find("callIndex").readUInt32()); } std::optional version; if ( hasBase && !isTypeInfo ) { version.emplace(subR.find("version").readUInt32()); } std::optional stmt; if ( hasBase && !isTypeInfo && isExpr ) { stmt.emplace(subR.find("stmt").readStmtRef()); } std::optional decl; if ( hasBase && !isTypeInfo && !isDynamicAlloc && !isExpr ) { decl.emplace(subR.find("decl").readDeclRef()); } uint32_t offsetQuantity = subR.find("offsetQuantity").readUInt32(); llvm::SmallVector lvaluePath_buffer_0; std::optional lvaluePath; if ( hasLValuePath ) { lvaluePath.emplace(subR.find("lvaluePath").readLValuePathSerializationHelper(lvaluePath_buffer_0)); } (void)ctx; APValue::LValueBase base; if (hasBase) { if (isTypeInfo) { base = APValue::LValueBase::getTypeInfo( TypeInfoLValue(typeInfo->getTypePtr()), *type); } else if (isDynamicAlloc) { base = APValue::LValueBase::getDynamicAlloc( DynamicAllocLValue(*dynamicAlloc), *type); } else if (isExpr) { base = APValue::LValueBase(cast(*stmt), *callIndex, *version); } else { base = APValue::LValueBase(cast(*decl), *callIndex, *version); } } CharUnits offset = CharUnits::fromQuantity(offsetQuantity); APValue result; result.MakeLValue(); if (!hasLValuePath) { result.setLValue(base, offset, APValue::NoLValuePath{}, isNullPtr); return result; } auto pathLength = lvaluePath->Path.size(); APValue::LValuePathEntry *path = result.setLValueUninit( base, offset, pathLength, isLValueOnePastTheEnd, isNullPtr).data(); llvm::copy(lvaluePath->Path, path); return result; } } llvm_unreachable("bad APValue::ValueKind"); } APValue::ValueKind readAPValueKind() { return asImpl().template readEnum(); } ArraySizeModifier readArraySizeModifier() { return asImpl().template readEnum(); } attr::Kind readAttrKind() { return asImpl().template readEnum(); } AutoTypeKeyword readAutoTypeKeyword() { return asImpl().template readEnum(); } BuiltinType::Kind readBuiltinTypeKind() { return asImpl().template readEnum(); } CXXRecordDecl* readCXXRecordDeclRef() { return cast_or_null(asImpl().readDeclRef()); } CallingConv readCallingConv() { return asImpl().template readEnum(); } ConceptDecl* readConceptDeclRef() { return cast_or_null(asImpl().readDeclRef()); } DeclarationName readDeclarationName() { auto &ctx = asImpl().getASTContext(); auto &&subR = asImpl().readObject(); DeclarationName::NameKind kind = subR.find("kind").readDeclarationNameKind(); switch (kind) { case DeclarationName::Identifier: { IdentifierInfo* identifier = subR.find("identifier").readIdentifier(); return DeclarationName(identifier); } case DeclarationName::ObjCZeroArgSelector: { Selector selector = subR.find("selector").readSelector(); return DeclarationName(selector); } case DeclarationName::ObjCOneArgSelector: { Selector selector = subR.find("selector").readSelector(); return DeclarationName(selector); } case DeclarationName::ObjCMultiArgSelector: { Selector selector = subR.find("selector").readSelector(); return DeclarationName(selector); } case DeclarationName::CXXConstructorName: { QualType type = subR.find("type").readQualType(); return ctx.DeclarationNames.getCXXConstructorName( ctx.getCanonicalType(type)); } case DeclarationName::CXXDestructorName: { QualType type = subR.find("type").readQualType(); return ctx.DeclarationNames.getCXXDestructorName( ctx.getCanonicalType(type)); } case DeclarationName::CXXConversionFunctionName: { QualType type = subR.find("type").readQualType(); return ctx.DeclarationNames.getCXXConversionFunctionName( ctx.getCanonicalType(type)); } case DeclarationName::CXXDeductionGuideName: { TemplateDecl* declaration = subR.find("declaration").readTemplateDeclRef(); return ctx.DeclarationNames.getCXXDeductionGuideName(declaration); } case DeclarationName::CXXOperatorName: { OverloadedOperatorKind operatorKind = subR.find("operatorKind").readOverloadedOperatorKind(); return ctx.DeclarationNames.getCXXOperatorName(operatorKind); } case DeclarationName::CXXLiteralOperatorName: { IdentifierInfo* identifier = subR.find("identifier").readIdentifier(); return ctx.DeclarationNames.getCXXLiteralOperatorName(identifier); } case DeclarationName::CXXUsingDirective: { return DeclarationName::getUsingDirectiveName(); } } llvm_unreachable("bad DeclarationName::NameKind"); } DeclarationName::NameKind readDeclarationNameKind() { return asImpl().template readEnum(); } ElaboratedTypeKeyword readElaboratedTypeKeyword() { return asImpl().template readEnum(); } Expr* readExprRef() { return cast_or_null(asImpl().readStmtRef()); } FunctionDecl* readFunctionDeclRef() { return cast_or_null(asImpl().readDeclRef()); } NamedDecl* readNamedDeclRef() { return cast_or_null(asImpl().readDeclRef()); } NamespaceAliasDecl* readNamespaceAliasDeclRef() { return cast_or_null(asImpl().readDeclRef()); } NamespaceDecl* readNamespaceDeclRef() { return cast_or_null(asImpl().readDeclRef()); } NestedNameSpecifier::SpecifierKind readNestedNameSpecifierKind() { return asImpl().template readEnum(); } ObjCProtocolDecl* readObjCProtocolDeclRef() { return cast_or_null(asImpl().readDeclRef()); } ObjCTypeParamDecl* readObjCTypeParamDeclRef() { return cast_or_null(asImpl().readDeclRef()); } OverloadedOperatorKind readOverloadedOperatorKind() { return asImpl().template readEnum(); } RefQualifierKind readRefQualifierKind() { return asImpl().template readEnum(); } TagDecl* readTagDeclRef() { return cast_or_null(asImpl().readDeclRef()); } TemplateArgument readTemplateArgument() { auto &ctx = asImpl().getASTContext(); auto &&subR = asImpl().readObject(); TemplateArgument::ArgKind kind = subR.find("kind").readTemplateArgumentKind(); switch (kind) { case TemplateArgument::Null: { return TemplateArgument(); } case TemplateArgument::Type: { QualType type = subR.find("type").readQualType(); bool isDefaulted = subR.find("isDefaulted").readBool(); return TemplateArgument(type, /* isNullPtr */ false, isDefaulted); } case TemplateArgument::Declaration: { ValueDecl* declaration = subR.find("declaration").readValueDeclRef(); QualType parameterType = subR.find("parameterType").readQualType(); bool isDefaulted = subR.find("isDefaulted").readBool(); return TemplateArgument(declaration, parameterType, isDefaulted); } case TemplateArgument::NullPtr: { QualType type = subR.find("type").readQualType(); bool isDefaulted = subR.find("isDefaulted").readBool(); return TemplateArgument(type, /*nullptr*/ true, isDefaulted); } case TemplateArgument::Integral: { llvm::APSInt value = subR.find("value").readAPSInt(); QualType type = subR.find("type").readQualType(); bool isDefaulted = subR.find("isDefaulted").readBool(); return TemplateArgument(ctx, value, type, isDefaulted); } case TemplateArgument::StructuralValue: { APValue value = subR.find("value").readAPValue(); QualType type = subR.find("type").readQualType(); bool isDefaulted = subR.find("isDefaulted").readBool(); return TemplateArgument(ctx, type, value, isDefaulted); } case TemplateArgument::Template: { TemplateName name = subR.find("name").readTemplateName(); bool isDefaulted = subR.find("isDefaulted").readBool(); return TemplateArgument(name, isDefaulted); } case TemplateArgument::TemplateExpansion: { TemplateName name = subR.find("name").readTemplateName(); std::optional numExpansions = subR.find("numExpansions").template readOptional(); bool isDefaulted = subR.find("isDefaulted").readBool(); auto numExpansionsUnsigned = llvm::transformOptional( numExpansions, [](uint32_t i) { return unsigned(i); }); return TemplateArgument(name, numExpansionsUnsigned, isDefaulted); } case TemplateArgument::Expression: { Expr* expression = subR.find("expression").readExprRef(); bool isDefaulted = subR.find("isDefaulted").readBool(); return TemplateArgument(expression, isDefaulted); } case TemplateArgument::Pack: { llvm::SmallVector elements_buffer_0; llvm::ArrayRef elements = subR.find("elements").template readArray(elements_buffer_0); // Copy the pack into the ASTContext. TemplateArgument *ctxElements = new (ctx) TemplateArgument[elements.size()]; for (size_t i = 0, e = elements.size(); i != e; ++i) ctxElements[i] = elements[i]; return TemplateArgument(llvm::ArrayRef(ctxElements, elements.size())); } } llvm_unreachable("bad TemplateArgument::ArgKind"); } TemplateArgument::ArgKind readTemplateArgumentKind() { return asImpl().template readEnum(); } TemplateDecl* readTemplateDeclRef() { return cast_or_null(asImpl().readDeclRef()); } TemplateName readTemplateName() { auto &ctx = asImpl().getASTContext(); auto &&subR = asImpl().readObject(); TemplateName::NameKind kind = subR.find("kind").readTemplateNameKind(); switch (kind) { case TemplateName::Template: { TemplateDecl* declaration = subR.find("declaration").readTemplateDeclRef(); return TemplateName(declaration); } case TemplateName::UsingTemplate: { UsingShadowDecl* foundDecl = subR.find("foundDecl").readUsingShadowDeclRef(); return TemplateName(foundDecl); } case TemplateName::OverloadedTemplate: { llvm::SmallVector overloads_buffer_0; llvm::ArrayRef overloads = subR.find("overloads").template readArray(overloads_buffer_0); // Copy into an UnresolvedSet to satisfy the interface. UnresolvedSet<8> overloadSet; for (auto overload : overloads) { overloadSet.addDecl(overload); } return ctx.getOverloadedTemplateName(overloadSet.begin(), overloadSet.end()); } case TemplateName::AssumedTemplate: { DeclarationName name = subR.find("name").readDeclarationName(); return ctx.getAssumedTemplateName(name); } case TemplateName::QualifiedTemplate: { NestedNameSpecifier * qualifier = subR.find("qualifier").readNestedNameSpecifier(); bool hasTemplateKeyword = subR.find("hasTemplateKeyword").readBool(); TemplateName underlyingTemplateName = subR.find("underlyingTemplateName").readTemplateName(); return ctx.getQualifiedTemplateName(qualifier, hasTemplateKeyword, underlyingTemplateName); } case TemplateName::DependentTemplate: { NestedNameSpecifier * qualifier = subR.find("qualifier").readNestedNameSpecifier(); std::optional identifier = subR.find("identifier").template readOptional(); std::optional operatorKind; if ( !identifier ) { operatorKind.emplace(subR.find("operatorKind").readOverloadedOperatorKind()); } if (identifier) { return ctx.getDependentTemplateName(qualifier, *identifier); } else { return ctx.getDependentTemplateName(qualifier, *operatorKind); } } case TemplateName::SubstTemplateTemplateParm: { TemplateName replacement = subR.find("replacement").readTemplateName(); Decl* associatedDecl = subR.find("associatedDecl").readDeclRef(); uint32_t index = subR.find("index").readUInt32(); std::optional packIndex = subR.find("packIndex").template readOptional(); return ctx.getSubstTemplateTemplateParm(replacement, associatedDecl, index, packIndex); } case TemplateName::SubstTemplateTemplateParmPack: { TemplateArgument argumentPack = subR.find("argumentPack").readTemplateArgument(); Decl* associatedDecl = subR.find("associatedDecl").readDeclRef(); uint32_t index = subR.find("index").readUInt32(); bool final = subR.find("final").readBool(); return ctx.getSubstTemplateTemplateParmPack(argumentPack, associatedDecl, index, final); } } llvm_unreachable("bad TemplateName::NameKind"); } TemplateName::NameKind readTemplateNameKind() { return asImpl().template readEnum(); } TemplateTemplateParmDecl* readTemplateTemplateParmDeclRef() { return cast_or_null(asImpl().readDeclRef()); } TemplateTypeParmDecl* readTemplateTypeParmDeclRef() { return cast_or_null(asImpl().readDeclRef()); } TypeOfKind readTypeOfKind() { return asImpl().template readEnum(); } UnaryTransformType::UTTKind readUnaryTypeTransformKind() { return asImpl().template readEnum(); } UsingShadowDecl* readUsingShadowDeclRef() { return cast_or_null(asImpl().readDeclRef()); } ValueDecl* readValueDeclRef() { return cast_or_null(asImpl().readDeclRef()); } VectorKind readVectorKind() { return asImpl().template readEnum(); } };