42#include "llvm/ADT/APInt.h"
43#include "llvm/ADT/APSInt.h"
44#include "llvm/ADT/ArrayRef.h"
45#include "llvm/ADT/FoldingSet.h"
46#include "llvm/ADT/SmallVector.h"
47#include "llvm/Support/Casting.h"
48#include "llvm/Support/ErrorHandling.h"
49#include "llvm/Support/MathExtras.h"
50#include "llvm/TargetParser/RISCVTargetParser.h"
61 return (*
this !=
Other) &&
88 getElementType().getBaseTypeIdentifier();
110 return AT->getElementType().isConstant(Ctx);
115std::optional<QualType::NonConstantStorageReason>
118 if (!
isConstant(Ctx) && !(*this)->isReferenceType())
126 if (
Record->hasMutableFields())
128 if (!
Record->hasTrivialDestructor() && !ExcludeDtor)
148 et->getDependence() |
154 (tc == DependentSizedArray
164 const llvm::APInt &NumElements) {
173 if (llvm::isPowerOf2_64(ElementSize)) {
174 return NumElements.getActiveBits() + llvm::Log2_64(ElementSize);
179 if ((ElementSize >> 32) == 0 && NumElements.getBitWidth() <= 64 &&
180 (NumElements.getZExtValue() >> 32) == 0) {
181 uint64_t TotalSize = NumElements.getZExtValue() * ElementSize;
182 return llvm::bit_width(TotalSize);
186 llvm::APSInt SizeExtended(NumElements,
true);
188 SizeExtended = SizeExtended.extend(std::max(SizeTypeBits,
189 SizeExtended.getBitWidth()) * 2);
191 llvm::APSInt TotalSize(llvm::APInt(SizeExtended.getBitWidth(), ElementSize));
192 TotalSize *= SizeExtended;
194 return TotalSize.getActiveBits();
216 const llvm::APInt &ArraySize,
218 unsigned TypeQuals) {
220 ID.AddInteger(ArraySize.getZExtValue());
221 ID.AddInteger(llvm::to_underlying(SizeMod));
222 ID.AddInteger(TypeQuals);
223 ID.AddBoolean(SizeExpr !=
nullptr);
225 SizeExpr->
Profile(ID, Context,
true);
232 :
ArrayType(DependentSizedArray, et, can, sm, tq, e), SizeExpr((
Stmt *)e),
233 Brackets(brackets) {}
242 ID.AddInteger(llvm::to_underlying(SizeMod));
243 ID.AddInteger(TypeQuals);
247DependentVectorType::DependentVectorType(
QualType ElementType,
250 :
Type(DependentVector, CanonType,
252 ElementType->getDependence() |
255 ElementType(ElementType), SizeExpr(SizeExpr), Loc(Loc) {
264 ID.AddInteger(llvm::to_underlying(VecKind));
265 SizeExpr->
Profile(ID, Context,
true);
268DependentSizedExtVectorType::DependentSizedExtVectorType(
QualType ElementType,
272 :
Type(DependentSizedExtVector, can,
274 ElementType->getDependence() |
277 SizeExpr(SizeExpr), ElementType(ElementType), loc(loc) {}
284 SizeExpr->
Profile(ID, Context,
true);
287DependentAddressSpaceType::DependentAddressSpaceType(
QualType PointeeType,
291 :
Type(DependentAddressSpace, can,
293 PointeeType->getDependence() |
296 AddrSpaceExpr(AddrSpaceExpr), PointeeType(PointeeType), loc(loc) {}
301 Expr *AddrSpaceExpr) {
303 AddrSpaceExpr->
Profile(ID, Context,
true);
307 const Expr *RowExpr,
const Expr *ColumnExpr)
308 :
Type(tc, canonType,
309 (RowExpr ? (matrixType->getDependence() |
TypeDependence::Dependent |
311 (matrixType->isVariablyModifiedType()
314 (matrixType->containsUnexpandedParameterPack() ||
316 RowExpr->containsUnexpandedParameterPack()) ||
318 ColumnExpr->containsUnexpandedParameterPack())
321 : matrixType->getDependence())),
322 ElementType(matrixType) {}
325 unsigned nColumns,
QualType canonType)
330 unsigned nRows,
unsigned nColumns,
332 :
MatrixType(tc, matrixType, canonType), NumRows(nRows),
333 NumColumns(nColumns) {}
335DependentSizedMatrixType::DependentSizedMatrixType(
QualType ElementType,
340 :
MatrixType(DependentSizedMatrix, ElementType, CanonicalType, RowExpr,
342 RowExpr(RowExpr), ColumnExpr(ColumnExpr), loc(loc) {}
349 RowExpr->
Profile(ID, CTX,
true);
350 ColumnExpr->
Profile(ID, CTX,
true);
359 :
Type(tc, canonType, vecType->getDependence()), ElementType(vecType) {
371 ExprAndUnsigned(NumBitsExpr, IsUnsigned) {}
374 return ExprAndUnsigned.getInt();
378 return ExprAndUnsigned.getPointer();
384 ID.AddBoolean(IsUnsigned);
385 NumBitsExpr->
Profile(ID, Context,
true);
393 if (
const auto *ATy = dyn_cast<ArrayType>(
this))
394 return ATy->getElementType().getTypePtr();
397 if (!isa<ArrayType>(CanonicalType))
403 ->getElementType().getTypePtr();
427#define TYPE(CLASS, BASE) \
428 static_assert(!std::is_polymorphic<CLASS##Type>::value, \
429 #CLASS "Type should not be polymorphic!");
430#include "clang/AST/TypeNodes.inc"
438#define TYPE(CLASS, BASE) \
439 static_assert(std::is_trivially_destructible<CLASS##Type>::value || \
440 std::is_same<CLASS##Type, ConstantArrayType>::value, \
441 #CLASS "Type should be trivially destructible!");
442#include "clang/AST/TypeNodes.inc"
446#define ABSTRACT_TYPE(Class, Parent)
447#define TYPE(Class, Parent) \
448 case Type::Class: { \
449 const auto *ty = cast<Class##Type>(this); \
450 if (!ty->isSugared()) return QualType(ty, 0); \
451 return ty->desugar(); \
453#include "clang/AST/TypeNodes.inc"
455 llvm_unreachable(
"bad type kind!");
465#define ABSTRACT_TYPE(Class, Parent)
466#define TYPE(Class, Parent) \
467 case Type::Class: { \
468 const auto *Ty = cast<Class##Type>(CurTy); \
469 if (!Ty->isSugared()) \
470 return SplitQualType(Ty, Qs); \
471 Cur = Ty->desugar(); \
474#include "clang/AST/TypeNodes.inc"
494#define ABSTRACT_TYPE(Class, Parent)
495#define TYPE(Class, Parent) \
496 case Type::Class: { \
497 const auto *ty = cast<Class##Type>(split.Ty); \
498 if (!ty->isSugared()) goto done; \
499 next = ty->desugar(); \
502#include "clang/AST/TypeNodes.inc"
521 T = PT->getInnerType();
530 if (
const auto *Sugar = dyn_cast<T>(Cur))
533#define ABSTRACT_TYPE(Class, Parent)
534#define TYPE(Class, Parent) \
535 case Type::Class: { \
536 const auto *Ty = cast<Class##Type>(Cur); \
537 if (!Ty->isSugared()) return 0; \
538 Cur = Ty->desugar().getTypePtr(); \
541#include "clang/AST/TypeNodes.inc"
547 return getAsSugar<TypedefType>(
this);
551 return getAsSugar<UsingType>(
this);
555 return getAsSugar<TemplateSpecializationType>(
this);
559 return getAsSugar<AttributedType>(
this);
566 const Type *Cur =
this;
570#define ABSTRACT_TYPE(Class, Parent)
571#define TYPE(Class, Parent) \
573 const auto *Ty = cast<Class##Type>(Cur); \
574 if (!Ty->isSugared()) return Cur; \
575 Cur = Ty->desugar().getTypePtr(); \
578#include "clang/AST/TypeNodes.inc"
584 if (
const auto *RT = getAs<RecordType>())
585 return RT->getDecl()->isClass();
590 if (
const auto *RT = getAs<RecordType>())
591 return RT->getDecl()->isStruct();
596 if (
const auto *RT = getAs<RecordType>())
597 return RT->getDecl()->hasAttr<ObjCBoxableAttr>();
602 if (
const auto *RT = getAs<RecordType>())
603 return RT->getDecl()->isInterface();
608 if (
const auto *RT = getAs<RecordType>()) {
616 if (
const auto *PT = getAs<PointerType>())
617 return PT->getPointeeType()->isVoidType();
622 if (
const auto *RT = getAs<RecordType>())
623 return RT->getDecl()->isUnion();
628 if (
const auto *CT = dyn_cast<ComplexType>(CanonicalType))
629 return CT->getElementType()->isFloatingType();
639 if (
const auto *ET = getAs<EnumType>())
640 return ET->getDecl()->isScoped();
645 if (
const auto *
Complex = getAs<ComplexType>())
646 if (
Complex->getElementType()->isIntegerType())
652 if (
const auto *PT = getAs<PointerType>())
654 if (
const auto *OPT = getAs<ObjCObjectPointerType>())
656 if (
const auto *BPT = getAs<BlockPointerType>())
658 if (
const auto *RT = getAs<ReferenceType>())
660 if (
const auto *MPT = getAs<MemberPointerType>())
662 if (
const auto *DT = getAs<DecayedType>())
669 if (
const auto *RT = dyn_cast<RecordType>(
this)) {
670 if (RT->getDecl()->isStruct())
675 if (
const auto *RT = dyn_cast<RecordType>(CanonicalType)) {
676 if (!RT->getDecl()->isStruct())
688 if (
const auto *RT = dyn_cast<RecordType>(
this)) {
689 if (RT->getDecl()->isUnion())
694 if (
const auto *RT = dyn_cast<RecordType>(CanonicalType)) {
695 if (!RT->getDecl()->isUnion())
710 const auto *OPT = getAs<ObjCObjectPointerType>();
715 if (OPT->isObjCIdType())
719 if (!OPT->isKindOfType())
723 if (OPT->isObjCClassType() || OPT->isObjCQualifiedClassType())
733 const auto *OPT = getAs<ObjCObjectPointerType>();
738 if (OPT->isObjCClassType())
742 if (!OPT->isKindOfType())
746 return OPT->isObjCClassType() || OPT->isObjCQualifiedClassType();
760 :
Type(ObjCObject, Canonical,
Base->getDependence()), BaseType(
Base) {
765 "bitfield overflow in type argument count");
766 if (!typeArgs.empty())
767 memcpy(getTypeArgStorage(), typeArgs.data(),
768 typeArgs.size() *
sizeof(
QualType));
770 for (
auto typeArg : typeArgs) {
771 addDependence(typeArg->getDependence() & ~TypeDependence::VariablyModified);
784 if (
const auto objcObject =
getBaseType()->getAs<ObjCObjectType>()) {
786 if (isa<ObjCInterfaceType>(objcObject))
789 return objcObject->isSpecialized();
802 if (
const auto objcObject =
getBaseType()->getAs<ObjCObjectType>()) {
804 if (isa<ObjCInterfaceType>(objcObject))
807 return objcObject->getTypeArgs();
819 if (
const auto objcObject =
getBaseType()->getAs<ObjCObjectType>()) {
821 if (isa<ObjCInterfaceType>(objcObject))
824 return objcObject->isKindOfType();
840 baseType = baseObj->stripObjCKindOfTypeAndQuals(ctx);
843 splitBaseType.
Quals),
869template <
typename Derived>
870struct SimpleTransformVisitor :
public TypeVisitor<Derived, QualType> {
878 QualType result =
static_cast<Derived *
>(
this)->Visit(splitType.
Ty);
888 explicit SimpleTransformVisitor(
ASTContext &ctx) : Ctx(ctx) {}
892#define TYPE(Class, Base)
893#define DEPENDENT_TYPE(Class, Base) \
894 QualType Visit##Class##Type(const Class##Type *T) { return QualType(T, 0); }
895#include "clang/AST/TypeNodes.inc"
897#define TRIVIAL_TYPE_CLASS(Class) \
898 QualType Visit##Class##Type(const Class##Type *T) { return QualType(T, 0); }
899#define SUGARED_TYPE_CLASS(Class) \
900 QualType Visit##Class##Type(const Class##Type *T) { \
901 if (!T->isSugared()) \
902 return QualType(T, 0); \
903 QualType desugaredType = recurse(T->desugar()); \
904 if (desugaredType.isNull()) \
906 if (desugaredType.getAsOpaquePtr() == T->desugar().getAsOpaquePtr()) \
907 return QualType(T, 0); \
908 return desugaredType; \
1010 if (elementType.
isNull())
1022 if (elementType.
isNull())
1034 if (elementType.
isNull())
1045 if (elementType.
isNull())
1072 bool paramChanged =
false;
1074 QualType newParamType = recurse(paramType);
1075 if (newParamType.
isNull())
1079 paramChanged =
true;
1081 paramTypes.push_back(newParamType);
1086 bool exceptionChanged =
false;
1090 QualType newExceptionType = recurse(exceptionType);
1091 if (newExceptionType.
isNull())
1094 if (newExceptionType.
getAsOpaquePtr() != exceptionType.getAsOpaquePtr())
1095 exceptionChanged =
true;
1097 exceptionTypes.push_back(newExceptionType);
1100 if (exceptionChanged) {
1107 !paramChanged && !exceptionChanged)
1130 if (originalType.
isNull())
1134 if (adjustedType.
isNull())
1147 if (originalType.
isNull())
1169 if (modifiedType.
isNull())
1173 if (equivalentType.
isNull())
1188 if (replacementType.
isNull())
1208 if (deducedType.
isNull())
1227 bool typeArgChanged =
false;
1230 QualType newTypeArg = recurse(typeArg);
1235 typeArgChanged =
true;
1237 typeArgs.push_back(newTypeArg);
1254 if (pointeeType.
isNull())
1276#undef TRIVIAL_TYPE_CLASS
1277#undef SUGARED_TYPE_CLASS
1280struct SubstObjCTypeArgsVisitor
1281 :
public SimpleTransformVisitor<SubstObjCTypeArgsVisitor> {
1282 using BaseType = SimpleTransformVisitor<SubstObjCTypeArgsVisitor>;
1289 : BaseType(ctx), TypeArgs(typeArgs), SubstContext(context) {}
1296 if (!TypeArgs.empty()) {
1307 argType, protocolsToApply, hasError,
true);
1310 switch (SubstContext) {
1311 case ObjCSubstitutionContext::Ordinary:
1312 case ObjCSubstitutionContext::Parameter:
1313 case ObjCSubstitutionContext::Superclass:
1317 case ObjCSubstitutionContext::Result:
1318 case ObjCSubstitutionContext::Property: {
1320 const auto *objPtr =
1325 if (objPtr->isKindOfType() || objPtr->isObjCIdOrClassType())
1329 const auto *obj = objPtr->getObjectType();
1331 obj->getBaseType(), obj->getTypeArgsAsWritten(), obj->getProtocols(),
1338 llvm_unreachable(
"Unexpected ObjCSubstitutionContext!");
1347 Ctx, TypeArgs, ObjCSubstitutionContext::Result);
1353 if (isa<FunctionNoProtoType>(funcType)) {
1357 return BaseType::VisitFunctionType(funcType);
1363 const auto *funcProtoType = cast<FunctionProtoType>(funcType);
1367 bool paramChanged =
false;
1368 for (
auto paramType : funcProtoType->getParamTypes()) {
1370 Ctx, TypeArgs, ObjCSubstitutionContext::Parameter);
1371 if (newParamType.
isNull())
1375 paramChanged =
true;
1377 paramTypes.push_back(newParamType);
1382 bool exceptionChanged =
false;
1387 Ctx, TypeArgs, ObjCSubstitutionContext::Ordinary);
1388 if (newExceptionType.
isNull())
1391 if (newExceptionType.
getAsOpaquePtr() != exceptionType.getAsOpaquePtr())
1392 exceptionChanged =
true;
1394 exceptionTypes.push_back(newExceptionType);
1397 if (exceptionChanged) {
1404 funcProtoType->getReturnType().getAsOpaquePtr() &&
1405 !paramChanged && !exceptionChanged)
1406 return BaseType::VisitFunctionType(funcType);
1416 bool anyChanged =
false;
1419 Ctx, TypeArgs, ObjCSubstitutionContext::Ordinary);
1428 if (TypeArgs.empty() &&
1429 SubstContext != ObjCSubstitutionContext::Superclass) {
1438 newTypeArgs.push_back(newTypeArg);
1450 return BaseType::VisitObjCObjectType(objcObjectType);
1454 QualType newType = BaseType::VisitAttributedType(attrType);
1458 const auto *newAttrType = dyn_cast<AttributedType>(newType.
getTypePtr());
1459 if (!newAttrType || newAttrType->getAttrKind() != attr::ObjCKindOf)
1463 QualType newEquivType = newAttrType->getEquivalentType();
1475 objType->getBaseType(), objType->getTypeArgsAsWritten(),
1476 objType->getProtocols(),
1478 objType->isObjCUnqualifiedId() ?
false :
true);
1486 newAttrType->getModifiedType(), newEquivType);
1490struct StripObjCKindOfTypeVisitor
1491 :
public SimpleTransformVisitor<StripObjCKindOfTypeVisitor> {
1492 using BaseType = SimpleTransformVisitor<StripObjCKindOfTypeVisitor>;
1494 explicit StripObjCKindOfTypeVisitor(
ASTContext &ctx) : BaseType(ctx) {}
1498 return BaseType::VisitObjCObjectType(objType);
1519 case BuiltinType::Kind::Float16: {
1527 case BuiltinType::Kind::BFloat16: {
1547 SubstObjCTypeArgsVisitor visitor(ctx, typeArgs, context);
1548 return visitor.recurse(*
this);
1562 auto &ctx =
const_cast<ASTContext &
>(constCtx);
1563 StripObjCKindOfTypeVisitor visitor(ctx);
1564 return visitor.recurse(*
this);
1568 if (
const auto AT =
getTypePtr()->getAs<AtomicType>())
1569 return AT->getValueType().getUnqualifiedType();
1573std::optional<ArrayRef<QualType>>
1576 if (
const auto method = dyn_cast<ObjCMethodDecl>(dc))
1577 dc = method->getDeclContext();
1581 const auto *dcClassDecl = dyn_cast<ObjCInterfaceDecl>(dc);
1587 dcTypeParams = dcClassDecl->getTypeParamList();
1589 return std::nullopt;
1593 dcCategoryDecl = dyn_cast<ObjCCategoryDecl>(dc);
1594 if (!dcCategoryDecl)
1595 return std::nullopt;
1601 return std::nullopt;
1605 return std::nullopt;
1607 assert(dcTypeParams &&
"No substitutions to perform");
1608 assert(dcClassDecl &&
"No class context");
1612 if (
const auto *objectPointerType = getAs<ObjCObjectPointerType>()) {
1613 objectType = objectPointerType->getObjectType();
1614 }
else if (getAs<BlockPointerType>()) {
1619 objectType = getAs<ObjCObjectType>();
1625 if (!curClassDecl) {
1633 while (curClassDecl != dcClassDecl) {
1636 if (superType.
isNull()) {
1637 objectType =
nullptr;
1657 if (
auto *ID = IfaceT->getInterface()) {
1658 if (ID->getTypeParamList())
1672 CachedSuperClassType.setInt(
true);
1678 if (!superClassObjTy) {
1679 CachedSuperClassType.setInt(
true);
1684 if (!superClassDecl) {
1685 CachedSuperClassType.setInt(
true);
1691 QualType superClassType(superClassObjTy, 0);
1693 if (!superClassTypeParams) {
1694 CachedSuperClassType.setPointerAndInt(
1701 CachedSuperClassType.setPointerAndInt(superClassObjTy,
true);
1709 CachedSuperClassType.setPointerAndInt(
1720 CachedSuperClassType.setPointerAndInt(
1728 assert(typeArgs.size() == typeParams->
size());
1729 CachedSuperClassType.setPointerAndInt(
1738 return interfaceDecl->getASTContext().getObjCInterfaceType(interfaceDecl)
1747 if (superObjectType.
isNull())
1748 return superObjectType;
1758 if (
const auto *T = getAs<ObjCObjectType>())
1759 if (T->getNumProtocols() && T->getInterface())
1771 if (
const auto *OPT = getAs<ObjCObjectPointerType>()) {
1772 if (OPT->isObjCQualifiedIdType())
1781 if (
const auto *OPT = getAs<ObjCObjectPointerType>()) {
1782 if (OPT->isObjCQualifiedClassType())
1789 if (
const auto *OT = getAs<ObjCObjectType>()) {
1790 if (OT->getInterface())
1797 if (
const auto *OPT = getAs<ObjCObjectPointerType>()) {
1798 if (OPT->getInterfaceType())
1806 if (
const auto *PT = getAs<PointerType>())
1808 else if (
const auto *RT = getAs<ReferenceType>())
1814 return dyn_cast<CXXRecordDecl>(RT->getDecl());
1820 return dyn_cast_or_null<CXXRecordDecl>(
getAsTagDecl());
1828 if (
const auto *TT = getAs<TagType>())
1829 return TT->getDecl();
1830 if (
const auto *Injected = getAs<InjectedClassNameType>())
1831 return Injected->getDecl();
1837 const Type *Cur =
this;
1839 if (AT->getAttrKind() == AK)
1841 Cur = AT->getEquivalentType().getTypePtr();
1848 class GetContainedDeducedTypeVisitor :
1849 public TypeVisitor<GetContainedDeducedTypeVisitor, Type*> {
1853 GetContainedDeducedTypeVisitor(
bool Syntactic =
false)
1854 : Syntactic(Syntactic) {}
1898 Type *VisitDependentSizedExtVectorType(
1918 return VisitFunctionType(T);
1949 return cast_or_null<DeducedType>(
1950 GetContainedDeducedTypeVisitor().Visit(
this));
1954 return isa_and_nonnull<FunctionType>(
1955 GetContainedDeducedTypeVisitor(
true).Visit(
this));
1959 if (
const auto *VT = dyn_cast<VectorType>(CanonicalType))
1960 return VT->getElementType()->isIntegerType();
1961 if (CanonicalType->isSveVLSBuiltinType()) {
1962 const auto *VT = cast<BuiltinType>(CanonicalType);
1963 return VT->getKind() == BuiltinType::SveBool ||
1964 (VT->getKind() >= BuiltinType::SveInt8 &&
1965 VT->getKind() <= BuiltinType::SveUint64);
1967 if (CanonicalType->isRVVVLSBuiltinType()) {
1968 const auto *VT = cast<BuiltinType>(CanonicalType);
1969 return (VT->getKind() >= BuiltinType::RvvInt8mf8 &&
1970 VT->getKind() <= BuiltinType::RvvUint64m8);
1996 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
1997 return BT->getKind() >= BuiltinType::Bool &&
1998 BT->getKind() <= BuiltinType::Int128;
2002 if (
const auto *ET = dyn_cast<EnumType>(CanonicalType))
2003 return ET->getDecl()->isComplete();
2009 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
2010 return BT->getKind() >= BuiltinType::Bool &&
2011 BT->getKind() <= BuiltinType::Int128;
2020 if (
const auto *ET = dyn_cast<EnumType>(CanonicalType))
2021 return !ET->getDecl()->isScoped();
2027 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
2028 return BT->getKind() == BuiltinType::Char_U ||
2029 BT->getKind() == BuiltinType::UChar ||
2030 BT->getKind() == BuiltinType::Char_S ||
2031 BT->getKind() == BuiltinType::SChar;
2036 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
2037 return BT->getKind() == BuiltinType::WChar_S ||
2038 BT->getKind() == BuiltinType::WChar_U;
2043 if (
const BuiltinType *BT = dyn_cast<BuiltinType>(CanonicalType))
2044 return BT->getKind() == BuiltinType::Char8;
2049 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
2050 return BT->getKind() == BuiltinType::Char16;
2055 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
2056 return BT->getKind() == BuiltinType::Char32;
2063 const auto *BT = dyn_cast<BuiltinType>(CanonicalType);
2064 if (!BT)
return false;
2065 switch (BT->getKind()) {
2066 default:
return false;
2067 case BuiltinType::Char_U:
2068 case BuiltinType::UChar:
2069 case BuiltinType::WChar_U:
2070 case BuiltinType::Char8:
2071 case BuiltinType::Char16:
2072 case BuiltinType::Char32:
2073 case BuiltinType::Char_S:
2074 case BuiltinType::SChar:
2075 case BuiltinType::WChar_S:
2084 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType)) {
2085 return BT->getKind() >= BuiltinType::Char_S &&
2086 BT->getKind() <= BuiltinType::Int128;
2089 if (
const EnumType *ET = dyn_cast<EnumType>(CanonicalType)) {
2092 if (ET->getDecl()->isComplete() && !ET->getDecl()->isScoped())
2093 return ET->getDecl()->getIntegerType()->isSignedIntegerType();
2096 if (
const auto *IT = dyn_cast<BitIntType>(CanonicalType))
2097 return IT->isSigned();
2098 if (
const auto *IT = dyn_cast<DependentBitIntType>(CanonicalType))
2099 return IT->isSigned();
2105 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType)) {
2106 return BT->getKind() >= BuiltinType::Char_S &&
2107 BT->getKind() <= BuiltinType::Int128;
2110 if (
const auto *ET = dyn_cast<EnumType>(CanonicalType)) {
2111 if (ET->getDecl()->isComplete())
2112 return ET->getDecl()->getIntegerType()->isSignedIntegerType();
2115 if (
const auto *IT = dyn_cast<BitIntType>(CanonicalType))
2116 return IT->isSigned();
2117 if (
const auto *IT = dyn_cast<DependentBitIntType>(CanonicalType))
2118 return IT->isSigned();
2124 if (
const auto *VT = dyn_cast<VectorType>(CanonicalType))
2125 return VT->getElementType()->isSignedIntegerOrEnumerationType();
2134 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType)) {
2135 return BT->getKind() >= BuiltinType::Bool &&
2136 BT->getKind() <= BuiltinType::UInt128;
2139 if (
const auto *ET = dyn_cast<EnumType>(CanonicalType)) {
2142 if (ET->getDecl()->isComplete() && !ET->getDecl()->isScoped())
2143 return ET->getDecl()->getIntegerType()->isUnsignedIntegerType();
2146 if (
const auto *IT = dyn_cast<BitIntType>(CanonicalType))
2147 return IT->isUnsigned();
2148 if (
const auto *IT = dyn_cast<DependentBitIntType>(CanonicalType))
2149 return IT->isUnsigned();
2155 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType)) {
2156 return BT->getKind() >= BuiltinType::Bool &&
2157 BT->getKind() <= BuiltinType::UInt128;
2160 if (
const auto *ET = dyn_cast<EnumType>(CanonicalType)) {
2161 if (ET->getDecl()->isComplete())
2162 return ET->getDecl()->getIntegerType()->isUnsignedIntegerType();
2165 if (
const auto *IT = dyn_cast<BitIntType>(CanonicalType))
2166 return IT->isUnsigned();
2167 if (
const auto *IT = dyn_cast<DependentBitIntType>(CanonicalType))
2168 return IT->isUnsigned();
2174 if (
const auto *VT = dyn_cast<VectorType>(CanonicalType))
2175 return VT->getElementType()->isUnsignedIntegerOrEnumerationType();
2176 if (
const auto *VT = dyn_cast<MatrixType>(CanonicalType))
2177 return VT->getElementType()->isUnsignedIntegerOrEnumerationType();
2178 if (CanonicalType->isSveVLSBuiltinType()) {
2179 const auto *VT = cast<BuiltinType>(CanonicalType);
2180 return VT->getKind() >= BuiltinType::SveUint8 &&
2181 VT->getKind() <= BuiltinType::SveUint64;
2187 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
2188 return BT->getKind() >= BuiltinType::Half &&
2189 BT->getKind() <= BuiltinType::Ibm128;
2190 if (
const auto *CT = dyn_cast<ComplexType>(CanonicalType))
2191 return CT->getElementType()->isFloatingType();
2196 if (
const auto *VT = dyn_cast<VectorType>(CanonicalType))
2197 return VT->getElementType()->isFloatingType();
2198 if (
const auto *MT = dyn_cast<MatrixType>(CanonicalType))
2199 return MT->getElementType()->isFloatingType();
2204 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
2205 return BT->isFloatingPoint();
2210 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
2211 return BT->getKind() >= BuiltinType::Bool &&
2212 BT->getKind() <= BuiltinType::Ibm128;
2213 if (
const auto *ET = dyn_cast<EnumType>(CanonicalType))
2214 return ET->getDecl()->isComplete() && !ET->getDecl()->isScoped();
2219 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
2220 return BT->getKind() >= BuiltinType::Bool &&
2221 BT->getKind() <= BuiltinType::Ibm128;
2222 if (
const auto *ET = dyn_cast<EnumType>(CanonicalType))
2229 return !ET->getDecl()->isScoped() && ET->getDecl()->isComplete();
2230 return isa<ComplexType>(CanonicalType) ||
isBitIntType();
2236 const Type *T = CanonicalType.getTypePtr();
2237 if (
const auto *BT = dyn_cast<BuiltinType>(T)) {
2238 if (BT->getKind() == BuiltinType::Bool)
return STK_Bool;
2239 if (BT->getKind() == BuiltinType::NullPtr)
return STK_CPointer;
2243 llvm_unreachable(
"unknown scalar builtin type");
2244 }
else if (isa<PointerType>(T)) {
2246 }
else if (isa<BlockPointerType>(T)) {
2248 }
else if (isa<ObjCObjectPointerType>(T)) {
2250 }
else if (isa<MemberPointerType>(T)) {
2252 }
else if (isa<EnumType>(T)) {
2253 assert(cast<EnumType>(T)->getDecl()->isComplete());
2255 }
else if (
const auto *CT = dyn_cast<ComplexType>(T)) {
2256 if (CT->getElementType()->isRealFloatingType())
2263 llvm_unreachable(
"unknown scalar type");
2276 if (
const auto *
Record = dyn_cast<RecordType>(CanonicalType)) {
2277 if (
const auto *ClassDecl = dyn_cast<CXXRecordDecl>(
Record->getDecl()))
2278 return ClassDecl->isAggregate();
2283 return isa<ArrayType>(CanonicalType);
2290 assert(!
isIncompleteType() &&
"This doesn't make sense for incomplete types");
2291 assert(!
isDependentType() &&
"This doesn't make sense for dependent types");
2293 return !isa<VariableArrayType>(CanonicalType);
2303 switch (CanonicalType->getTypeClass()) {
2304 default:
return false;
2310 EnumDecl *EnumD = cast<EnumType>(CanonicalType)->getDecl();
2318 RecordDecl *Rec = cast<RecordType>(CanonicalType)->getDecl();
2329 return cast<ArrayType>(CanonicalType)->getElementType()
2330 ->isIncompleteType(Def);
2331 case IncompleteArray:
2334 case MemberPointer: {
2338 auto *MPTy = cast<MemberPointerType>(CanonicalType);
2339 const Type *ClassTy = MPTy->getClass();
2352 if (RD->
hasAttr<MSInheritanceAttr>())
2357 return cast<ObjCObjectType>(CanonicalType)->getBaseType()
2358 ->isIncompleteType(Def);
2359 case ObjCInterface: {
2362 = cast<ObjCInterfaceType>(CanonicalType)->getDecl();
2374 if (
const BuiltinType *BT = getAs<BuiltinType>()) {
2375 switch (BT->getKind()) {
2377#define WASM_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
2378#include "clang/Basic/WebAssemblyReferenceTypes.def"
2388 if (
const auto *BT = getAs<BuiltinType>())
2389 return BT->getKind() == BuiltinType::WasmExternRef;
2394 if (
const auto *ATy = dyn_cast<ArrayType>(
this))
2395 return ATy->getElementType().isWebAssemblyReferenceType();
2397 if (
const auto *PTy = dyn_cast<PointerType>(
this))
2398 return PTy->getPointeeType().isWebAssemblyReferenceType();
2410 if (
const BuiltinType *BT = getAs<BuiltinType>()) {
2411 switch (BT->getKind()) {
2413#define SVE_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
2414#include "clang/Basic/AArch64SVEACLETypes.def"
2424 if (
const BuiltinType *BT = getAs<BuiltinType>()) {
2425 switch (BT->getKind()) {
2426#define RVV_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
2427#include "clang/Basic/RISCVVTypes.def"
2437 if (
const BuiltinType *BT = getAs<BuiltinType>()) {
2438 switch (BT->getKind()) {
2439 case BuiltinType::SveInt8:
2440 case BuiltinType::SveInt16:
2441 case BuiltinType::SveInt32:
2442 case BuiltinType::SveInt64:
2443 case BuiltinType::SveUint8:
2444 case BuiltinType::SveUint16:
2445 case BuiltinType::SveUint32:
2446 case BuiltinType::SveUint64:
2447 case BuiltinType::SveFloat16:
2448 case BuiltinType::SveFloat32:
2449 case BuiltinType::SveFloat64:
2450 case BuiltinType::SveBFloat16:
2451 case BuiltinType::SveBool:
2452 case BuiltinType::SveBoolx2:
2453 case BuiltinType::SveBoolx4:
2466 if (BTy->
getKind() == BuiltinType::SveBool)
2476 if (
const BuiltinType *BT = getAs<BuiltinType>()) {
2477 switch (BT->getKind()) {
2478#define RVV_VECTOR_TYPE(Name, Id, SingletonId, NumEls, ElBits, NF, IsSigned, \
2480 case BuiltinType::Id: \
2482#define RVV_PREDICATE_TYPE(Name, Id, SingletonId, NumEls) \
2483 case BuiltinType::Id: \
2485#include "clang/Basic/RISCVVTypes.def"
2499#define RVV_PREDICATE_TYPE(Name, Id, SingletonId, NumEls) \
2500 case BuiltinType::Id: \
2501 return Ctx.UnsignedCharTy;
2504#include "clang/Basic/RISCVVTypes.def"
2507 llvm_unreachable(
"Unhandled type");
2525 if ((*this)->isIncompleteArrayType())
2528 if ((*this)->isIncompleteType())
2537 default:
return false;
2538 case Type::VariableArray:
2539 case Type::ConstantArray:
2543 case Type::ObjCObjectPointer:
2544 case Type::BlockPointer:
2548 case Type::MemberPointer:
2550 case Type::ExtVector:
2558 if (
const auto *ClassDecl =
2559 dyn_cast<CXXRecordDecl>(cast<RecordType>(CanonicalType)->getDecl()))
2560 return ClassDecl->isPOD();
2574 if ((*this)->isArrayType())
2577 if ((*this)->isSizelessBuiltinType())
2582 if ((*this)->isIncompleteType())
2601 if (
const auto *ClassDecl = dyn_cast<CXXRecordDecl>(RT->getDecl())) {
2608 return ClassDecl->hasTrivialDefaultConstructor() &&
2609 !ClassDecl->hasNonTrivialDefaultConstructor() &&
2610 ClassDecl->isTriviallyCopyable();
2622 bool IsCopyConstructible) {
2623 if (
type->isArrayType())
2625 Context, IsCopyConstructible);
2627 if (
type.hasNonTrivialObjCLifetime())
2652 if (
const auto *ClassDecl = dyn_cast<CXXRecordDecl>(RT->getDecl())) {
2653 if (IsCopyConstructible) {
2654 return ClassDecl->isTriviallyCopyConstructible();
2656 return ClassDecl->isTriviallyCopyable();
2684 return RD->canPassInRegisters();
2701 if (
Decl->isUnion())
2703 if (
Decl->isLambda())
2704 return Decl->isCapturelessLambda();
2707 return Function->getOverloadedOperator() ==
2708 OverloadedOperatorKind::OO_EqualEqual &&
2710 (
Function->getParamDecl(0)->getType()->isReferenceType() ||
2711 Decl->isTriviallyCopyable());
2714 if (llvm::none_of(
Decl->methods(), IsDefaultedOperatorEqualEqual) &&
2716 if (
NamedDecl *ND = Friend->getFriendDecl()) {
2718 IsDefaultedOperatorEqualEqual(ND->getAsFunction());
2724 return llvm::all_of(
Decl->bases(),
2726 if (const auto *RD = BS.getType()->getAsCXXRecordDecl())
2727 return HasNonDeletedDefaultedEqualityComparison(RD);
2731 auto Type = FD->getType();
2732 if (Type->isArrayType())
2733 Type = Type->getBaseElementTypeUnsafe()->getCanonicalTypeUnqualified();
2735 if (Type->isReferenceType() || Type->isEnumeralType())
2737 if (const auto *RD = Type->getAsCXXRecordDecl())
2738 return HasNonDeletedDefaultedEqualityComparison(RD);
2756 CanonicalType,
false);
2792 if (
const auto *RT =
2793 getTypePtr()->getBaseElementTypeUnsafe()->getAs<RecordType>())
2794 if (RT->getDecl()->isNonTrivialToPrimitiveDefaultInitialize())
2808 if (
const auto *RT =
2809 getTypePtr()->getBaseElementTypeUnsafe()->getAs<RecordType>())
2810 if (RT->getDecl()->isNonTrivialToPrimitiveCopy())
2846 assert(BaseTy &&
"NULL element type");
2876 if (
const auto *ClassDecl = dyn_cast<CXXRecordDecl>(RT->getDecl()))
2877 return ClassDecl->isLiteral();
2884 return AT->getValueType()->isLiteralType(Ctx);
2906 return RD->isStructural();
2919 assert(BaseTy &&
"NULL element type");
2929 if (
const auto *ClassDecl = dyn_cast<CXXRecordDecl>(RT->getDecl()))
2930 if (!ClassDecl->isStandardLayout())
2958 assert(BaseTy &&
"NULL element type");
2971 if (
const auto *ClassDecl = dyn_cast<CXXRecordDecl>(RT->getDecl())) {
2974 if (!ClassDecl->isTrivial())
return false;
2979 if (!ClassDecl->isStandardLayout())
return false;
3008 if (
const auto *ET = getAs<EnumType>()) {
3010 if (II && II->
isStr(
"align_val_t") && ET->getDecl()->isInStdNamespace())
3017 if (
const auto *ET = getAs<EnumType>()) {
3019 if (II && II->
isStr(
"byte") && ET->getDecl()->isInStdNamespace())
3035 case TemplateTypeParm:
3036 case SubstTemplateTypeParm:
3037 case TemplateSpecialization:
3040 case DependentTemplateSpecialization:
3084 llvm_unreachable(
"Type specifier is not a tag type kind.");
3101 llvm_unreachable(
"Unknown tag type kind.");
3119 llvm_unreachable(
"Elaborated type keyword is not a tag type kind.");
3121 llvm_unreachable(
"Unknown elaborated type keyword.");
3137 llvm_unreachable(
"Unknown elaborated type keyword.");
3151 return "__interface";
3158 llvm_unreachable(
"Unknown elaborated type keyword.");
3161DependentTemplateSpecializationType::DependentTemplateSpecializationType(
3168 NNS(NNS), Name(Name) {
3171 "DependentTemplateSpecializatonType requires dependent qualifier");
3172 auto *ArgBuffer =
const_cast<TemplateArgument *
>(template_arguments().data());
3175 TemplateArgumentDependence::UnexpandedPack));
3188 ID.AddInteger(llvm::to_underlying(Keyword));
3189 ID.AddPointer(Qualifier);
3190 ID.AddPointer(Name);
3192 Arg.Profile(ID, Context);
3197 if (
const auto *Elab = dyn_cast<ElaboratedType>(
this))
3198 Keyword = Elab->getKeyword();
3199 else if (
const auto *DepName = dyn_cast<DependentNameType>(
this))
3200 Keyword = DepName->getKeyword();
3201 else if (
const auto *DepTST =
3202 dyn_cast<DependentTemplateSpecializationType>(
this))
3203 Keyword = DepTST->getKeyword();
3212#define ABSTRACT_TYPE(Derived, Base)
3213#define TYPE(Derived, Base) case Derived: return #Derived;
3214#include "clang/AST/TypeNodes.inc"
3217 llvm_unreachable(
"Invalid type class.");
3225 return Policy.
Bool ?
"bool" :
"_Bool";
3231 return "signed char";
3243 return "unsigned char";
3245 return "unsigned short";
3247 return "unsigned int";
3249 return "unsigned long";
3251 return "unsigned long long";
3253 return "unsigned __int128";
3255 return Policy.
Half ?
"half" :
"__fp16";
3263 return "long double";
3265 return "short _Accum";
3269 return "long _Accum";
3271 return "unsigned short _Accum";
3273 return "unsigned _Accum";
3275 return "unsigned long _Accum";
3276 case BuiltinType::ShortFract:
3277 return "short _Fract";
3278 case BuiltinType::Fract:
3280 case BuiltinType::LongFract:
3281 return "long _Fract";
3282 case BuiltinType::UShortFract:
3283 return "unsigned short _Fract";
3284 case BuiltinType::UFract:
3285 return "unsigned _Fract";
3286 case BuiltinType::ULongFract:
3287 return "unsigned long _Fract";
3288 case BuiltinType::SatShortAccum:
3289 return "_Sat short _Accum";
3290 case BuiltinType::SatAccum:
3291 return "_Sat _Accum";
3292 case BuiltinType::SatLongAccum:
3293 return "_Sat long _Accum";
3294 case BuiltinType::SatUShortAccum:
3295 return "_Sat unsigned short _Accum";
3296 case BuiltinType::SatUAccum:
3297 return "_Sat unsigned _Accum";
3298 case BuiltinType::SatULongAccum:
3299 return "_Sat unsigned long _Accum";
3300 case BuiltinType::SatShortFract:
3301 return "_Sat short _Fract";
3302 case BuiltinType::SatFract:
3303 return "_Sat _Fract";
3304 case BuiltinType::SatLongFract:
3305 return "_Sat long _Fract";
3306 case BuiltinType::SatUShortFract:
3307 return "_Sat unsigned short _Fract";
3308 case BuiltinType::SatUFract:
3309 return "_Sat unsigned _Fract";
3310 case BuiltinType::SatULongFract:
3311 return "_Sat unsigned long _Fract";
3315 return "__float128";
3320 return Policy.
MSWChar ?
"__wchar_t" :
"wchar_t";
3330 return "<overloaded function type>";
3332 return "<bound member function type>";
3334 return "<pseudo-object type>";
3336 return "<dependent type>";
3338 return "<unknown type>";
3339 case ARCUnbridgedCast:
3340 return "<ARC unbridged cast type>";
3342 return "<builtin fn type>";
3349#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
3351 return "__" #Access " " #ImgType "_t";
3352#include "clang/Basic/OpenCLImageTypes.def"
3358 return "clk_event_t";
3362 return "reserve_id_t";
3363 case IncompleteMatrixIdx:
3364 return "<incomplete matrix index type>";
3365 case OMPArraySection:
3366 return "<OpenMP array section type>";
3367 case OMPArrayShaping:
3368 return "<OpenMP array shaping type>";
3370 return "<OpenMP iterator type>";
3371#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \
3374#include "clang/Basic/OpenCLExtensionTypes.def"
3375#define SVE_TYPE(Name, Id, SingletonId) \
3378#include "clang/Basic/AArch64SVEACLETypes.def"
3379#define PPC_VECTOR_TYPE(Name, Id, Size) \
3382#include "clang/Basic/PPCTypes.def"
3383#define RVV_TYPE(Name, Id, SingletonId) \
3386#include "clang/Basic/RISCVVTypes.def"
3387#define WASM_TYPE(Name, Id, SingletonId) \
3390#include "clang/Basic/WebAssemblyReferenceTypes.def"
3393 llvm_unreachable(
"Invalid builtin type.");
3398 if (
auto *PET = dyn_cast<PackExpansionType>(
getTypePtr()))
3399 return PET->getPattern();
3404 if (
const auto *RefType =
getTypePtr()->getAs<ReferenceType>())
3421 case CC_C:
return "cdecl";
3446 llvm_unreachable(
"Invalid calling convention.");
3464 assert(
getNumParams() == params.size() &&
"NumParams overflow!");
3472 auto &ExtraBits = *getTrailingObjects<FunctionTypeExtraBitfields>();
3479 auto &ArmTypeAttrs = *getTrailingObjects<FunctionTypeArmAttributes>();
3480 ArmTypeAttrs = FunctionTypeArmAttributes();
3483 auto &ExtraBits = *getTrailingObjects<FunctionTypeExtraBitfields>();
3484 ExtraBits.HasArmTypeAttributes =
true;
3488 auto *argSlot = getTrailingObjects<QualType>();
3491 ~TypeDependence::VariablyModified);
3492 argSlot[i] = params[i];
3497 auto &ArmTypeAttrs = *getTrailingObjects<FunctionTypeArmAttributes>();
3499 "Not enough bits to encode SME attributes");
3505 auto &ExtraBits = *getTrailingObjects<FunctionTypeExtraBitfields>();
3507 assert(NumExceptions <= 1023 &&
"Not enough bits to encode exceptions");
3508 ExtraBits.NumExceptionType = NumExceptions;
3510 assert(hasExtraBitfields() &&
"missing trailing extra bitfields!");
3512 reinterpret_cast<QualType *
>(getTrailingObjects<ExceptionType>());
3520 (TypeDependence::Instantiation | TypeDependence::UnexpandedPack));
3522 exnSlot[I++] = ExceptionType;
3536 (TypeDependence::Instantiation | TypeDependence::UnexpandedPack));
3542 auto **slot = getTrailingObjects<FunctionDecl *>();
3550 auto **slot = getTrailingObjects<FunctionDecl *>();
3569 auto *extParamInfos = getTrailingObjects<ExtParameterInfo>();
3576 *getTrailingObjects<Qualifiers>() = epi.
TypeQuals;
3583 auto &EllipsisLoc = *getTrailingObjects<SourceLocation>();
3590 return NE->isValueDependent();
3602 return NE->isInstantiationDependent();
3604 if (ET->isInstantiationDependentType())
3613 llvm_unreachable(
"should not call this with unresolved exception specs");
3639 llvm_unreachable(
"unexpected exception specification kind");
3643 for (
unsigned ArgIdx =
getNumParams(); ArgIdx; --ArgIdx)
3651 const QualType *ArgTys,
unsigned NumParams,
3652 const ExtProtoInfo &epi,
3674 ID.AddPointer(
Result.getAsOpaquePtr());
3675 for (
unsigned i = 0; i != NumParams; ++i)
3676 ID.AddPointer(ArgTys[i].getAsOpaquePtr());
3680 assert(!(
unsigned(epi.Variadic) & ~1) &&
3681 !(
unsigned(epi.RefQualifier) & ~3) &&
3682 !(
unsigned(epi.ExceptionSpec.Type) & ~15) &&
3683 "Values larger than expected.");
3684 ID.AddInteger(
unsigned(epi.Variadic) +
3685 (epi.RefQualifier << 1) +
3686 (epi.ExceptionSpec.Type << 3));
3687 ID.Add(epi.TypeQuals);
3689 for (
QualType Ex : epi.ExceptionSpec.Exceptions)
3692 epi.ExceptionSpec.NoexceptExpr->Profile(ID, Context, Canonical);
3695 ID.AddPointer(epi.ExceptionSpec.SourceDecl->getCanonicalDecl());
3697 if (epi.ExtParameterInfos) {
3698 for (
unsigned i = 0; i != NumParams; ++i)
3699 ID.AddInteger(epi.ExtParameterInfos[i].getOpaqueValue());
3702 epi.ExtInfo.Profile(ID);
3703 ID.AddInteger((epi.AArch64SMEAttributes << 1) | epi.HasTrailingReturn);
3716 assert(!isa<TypedefType>(can) &&
"Invalid canonical type");
3718 if (!typeMatchesDecl())
3719 *getTrailingObjects<QualType>() = Underlying;
3724 : *getTrailingObjects<QualType>();
3733 *getTrailingObjects<QualType>() = Underlying;
3739 cast<TypeDecl>(Found->
getTargetDecl())->getTypeForDecl(), 0)
3740 : *getTrailingObjects<QualType>();
3749 while (
auto *InnerMQT = dyn_cast<MacroQualifiedType>(Inner)) {
3752 Inner = InnerMQT->getModifiedType();
3762 ? Can.getAtomicUnqualifiedType()
3765 (E->getType()->getDependence() &
3786 E->
Profile(ID, Context,
true);
3787 ID.AddBoolean(IsUnqual);
3794 :
Type(Decltype, can,
3798 (E->getType()->getDependence() &
3800 E(E), UnderlyingType(underlyingType) {}
3816 E->
Profile(ID, Context,
true);
3823 :
Type(PackIndexing, Canonical,
3825 Context(Context), Pattern(Pattern), IndexExpr(IndexExpr),
3826 Size(Expansions.size()) {
3828 std::uninitialized_copy(Expansions.begin(), Expansions.end(),
3829 getTrailingObjects<QualType>());
3834 return std::nullopt;
3838 return std::nullopt;
3840 assert(Index.isNonNegative() &&
"Invalid index");
3841 return static_cast<unsigned>(Index.getExtValue());
3845PackIndexingType::computeDependence(
QualType Pattern,
Expr *IndexExpr,
3850 ? TypeDependence::DependentInstantiation
3851 : TypeDependence::None);
3852 if (Expansions.empty())
3853 TD |= Pattern->
getDependence() & TypeDependence::DependentInstantiation;
3855 for (
const QualType &T : Expansions)
3858 if (!(IndexD & TypeDependence::UnexpandedPack))
3859 TD &= ~TypeDependence::UnexpandedPack;
3864 TD |= TypeDependence::Error | TypeDependence::DependentInstantiation;
3873 E->
Profile(ID, Context,
true);
3879 :
Type(UnaryTransform, CanonicalType, BaseType->getDependence()),
3880 BaseType(BaseType), UnderlyingType(UnderlyingType), UKind(UKind) {}
3894 for (
auto *I :
decl->redecls()) {
3895 if (I->isCompleteDefinition() || I->isBeingDefined())
3911 std::vector<const RecordType*> RecordTypeList;
3912 RecordTypeList.push_back(
this);
3913 unsigned NextToCheckIndex = 0;
3915 while (RecordTypeList.size() > NextToCheckIndex) {
3917 RecordTypeList[NextToCheckIndex]->
getDecl()->fields()) {
3923 if (!llvm::is_contained(RecordTypeList, FieldRecTy))
3924 RecordTypeList.push_back(FieldRecTy);
3939 case attr::ObjCOwnership:
3940 case attr::ObjCInertUnsafeUnretained:
3941 case attr::TypeNonNull:
3942 case attr::TypeNullable:
3943 case attr::TypeNullableResult:
3944 case attr::TypeNullUnspecified:
3945 case attr::LifetimeBound:
3946 case attr::AddressSpace:
3959 default:
return false;
3966 llvm_unreachable(
"invalid attr kind");
3976 default:
return false;
3979 case attr::FastCall:
3981 case attr::ThisCall:
3983 case attr::SwiftCall:
3984 case attr::SwiftAsyncCall:
3985 case attr::VectorCall:
3986 case attr::AArch64VectorPcs:
3987 case attr::AArch64SVEPcs:
3988 case attr::AMDGPUKernelCall:
3992 case attr::IntelOclBicc:
3993 case attr::PreserveMost:
3994 case attr::PreserveAll:
3996 case attr::PreserveNone:
3999 llvm_unreachable(
"invalid attr kind");
4012 if (
const auto *TTP = dyn_cast<TemplateTypeParmDecl>(D))
4014 return cast<TemplateTypeParmDecl>(
4018SubstTemplateTypeParmType::SubstTemplateTypeParmType(
4019 QualType Replacement,
Decl *AssociatedDecl,
unsigned Index,
4020 std::optional<unsigned> PackIndex)
4021 :
Type(SubstTemplateTypeParm, Replacement.getCanonicalType(),
4022 Replacement->getDependence()),
4023 AssociatedDecl(AssociatedDecl) {
4024 SubstTemplateTypeParmTypeBits.HasNonCanonicalUnderlyingType =
4025 Replacement != getCanonicalTypeInternal();
4026 if (SubstTemplateTypeParmTypeBits.HasNonCanonicalUnderlyingType)
4027 *getTrailingObjects<QualType>() = Replacement;
4029 SubstTemplateTypeParmTypeBits.Index = Index;
4030 SubstTemplateTypeParmTypeBits.PackIndex = PackIndex ? *PackIndex + 1 : 0;
4031 assert(AssociatedDecl !=
nullptr);
4039SubstTemplateTypeParmPackType::SubstTemplateTypeParmPackType(
4040 QualType Canon,
Decl *AssociatedDecl,
unsigned Index,
bool Final,
4042 :
Type(SubstTemplateTypeParmPack, Canon,
4045 Arguments(ArgPack.pack_begin()),
4046 AssociatedDeclAndFinal(AssociatedDecl, Final) {
4049 assert(AssociatedDecl !=
nullptr);
4053 return AssociatedDeclAndFinal.getPointer();
4057 return AssociatedDeclAndFinal.getInt();
4078 const Decl *AssociatedDecl,
4079 unsigned Index,
bool Final,
4081 ID.AddPointer(AssociatedDecl);
4082 ID.AddInteger(Index);
4083 ID.AddBoolean(Final);
4086 ID.AddPointer(
P.getAsType().getAsOpaquePtr());
4097 if (Arg.isDependent())
4105 if (ArgLoc.getArgument().isInstantiationDependent())
4111TemplateSpecializationType::TemplateSpecializationType(
4114 :
Type(TemplateSpecialization, Canon.isNull() ?
QualType(this, 0) : Canon,
4125 "Use DependentTemplateSpecializationType for dependent template-name");
4130 "Unexpected template name for TemplateSpecializationType");
4143 ~TypeDependence::Dependent);
4146 TypeDependence::VariablyModified);
4153 *
reinterpret_cast<QualType *
>(
Begin + Args.size()) = AliasedType;
4158 assert(
isTypeAlias() &&
"not a type alias template specialization");
4176 Arg.Profile(ID, Context);
4201 ID.AddInteger(typeArgs.size());
4202 for (
auto typeArg : typeArgs)
4203 ID.AddPointer(typeArg.getAsOpaquePtr());
4204 ID.AddInteger(protocols.size());
4205 for (
auto *proto : protocols)
4206 ID.AddPointer(proto);
4207 ID.AddBoolean(isKindOf);
4220 ID.AddPointer(OTPDecl);
4222 ID.AddInteger(protocols.size());
4223 for (
auto *proto : protocols)
4224 ID.AddPointer(proto);
4235class CachedProperties {
4240 CachedProperties(
Linkage L,
bool local) : L(L), local(local) {}
4242 Linkage getLinkage()
const {
return L; }
4243 bool hasLocalOrUnnamedType()
const {
return local; }
4245 friend CachedProperties merge(CachedProperties L, CachedProperties R) {
4247 return CachedProperties(MergedLinkage, L.hasLocalOrUnnamedType() ||
4248 R.hasLocalOrUnnamedType());
4269 return CachedProperties(T->
TypeBits.getLinkage(),
4270 T->
TypeBits.hasLocalOrUnnamedType());
4275 if (T->
TypeBits.isCacheValid())
return;
4291 T->
TypeBits.CachedLinkage = llvm::to_underlying(
Result.getLinkage());
4292 T->
TypeBits.CachedLocalOrUnnamed =
Result.hasLocalOrUnnamedType();
4311#define TYPE(Class,Base)
4312#define NON_CANONICAL_TYPE(Class,Base) case Type::Class:
4313#include "clang/AST/TypeNodes.inc"
4314 llvm_unreachable(
"didn't expect a non-canonical type here");
4316#define TYPE(Class,Base)
4317#define DEPENDENT_TYPE(Class,Base) case Type::Class:
4318#define NON_CANONICAL_UNLESS_DEPENDENT_TYPE(Class,Base) case Type::Class:
4319#include "clang/AST/TypeNodes.inc"
4326 case Type::DeducedTemplateSpecialization:
4340 const TagDecl *Tag = cast<TagType>(T)->getDecl();
4347 bool IsLocalOrUnnamed =
4350 return CachedProperties(L, IsLocalOrUnnamed);
4357 return Cache::get(cast<ComplexType>(T)->getElementType());
4359 return Cache::get(cast<PointerType>(T)->getPointeeType());
4360 case Type::BlockPointer:
4361 return Cache::get(cast<BlockPointerType>(T)->getPointeeType());
4362 case Type::LValueReference:
4363 case Type::RValueReference:
4364 return Cache::get(cast<ReferenceType>(T)->getPointeeType());
4365 case Type::MemberPointer: {
4366 const auto *MPT = cast<MemberPointerType>(T);
4370 case Type::ConstantArray:
4371 case Type::IncompleteArray:
4372 case Type::VariableArray:
4373 return Cache::get(cast<ArrayType>(T)->getElementType());
4375 case Type::ExtVector:
4376 return Cache::get(cast<VectorType>(T)->getElementType());
4377 case Type::ConstantMatrix:
4378 return Cache::get(cast<ConstantMatrixType>(T)->getElementType());
4379 case Type::FunctionNoProto:
4380 return Cache::get(cast<FunctionType>(T)->getReturnType());
4381 case Type::FunctionProto: {
4382 const auto *FPT = cast<FunctionProtoType>(T);
4383 CachedProperties result =
Cache::get(FPT->getReturnType());
4384 for (
const auto &ai : FPT->param_types())
4388 case Type::ObjCInterface: {
4389 Linkage L = cast<ObjCInterfaceType>(T)->getDecl()->getLinkageInternal();
4390 return CachedProperties(L,
false);
4392 case Type::ObjCObject:
4393 return Cache::get(cast<ObjCObjectType>(T)->getBaseType());
4394 case Type::ObjCObjectPointer:
4395 return Cache::get(cast<ObjCObjectPointerType>(T)->getPointeeType());
4397 return Cache::get(cast<AtomicType>(T)->getValueType());
4399 return Cache::get(cast<PipeType>(T)->getElementType());
4402 llvm_unreachable(
"unhandled type class");
4413 return TypeBits.hasLocalOrUnnamedType();
4418#define TYPE(Class,Base)
4419#define NON_CANONICAL_TYPE(Class,Base) case Type::Class:
4420#include "clang/AST/TypeNodes.inc"
4421 llvm_unreachable(
"didn't expect a non-canonical type here");
4423#define TYPE(Class,Base)
4424#define DEPENDENT_TYPE(Class,Base) case Type::Class:
4425#define NON_CANONICAL_UNLESS_DEPENDENT_TYPE(Class,Base) case Type::Class:
4426#include "clang/AST/TypeNodes.inc"
4436 case Type::DeducedTemplateSpecialization:
4447 case Type::BlockPointer:
4449 case Type::LValueReference:
4450 case Type::RValueReference:
4452 case Type::MemberPointer: {
4453 const auto *MPT = cast<MemberPointerType>(T);
4458 case Type::ConstantArray:
4459 case Type::IncompleteArray:
4460 case Type::VariableArray:
4463 case Type::ExtVector:
4465 case Type::ConstantMatrix:
4467 cast<ConstantMatrixType>(T)->getElementType());
4468 case Type::FunctionNoProto:
4470 case Type::FunctionProto: {
4471 const auto *FPT = cast<FunctionProtoType>(T);
4473 for (
const auto &ai : FPT->param_types())
4477 case Type::ObjCInterface:
4479 case Type::ObjCObject:
4481 case Type::ObjCObjectPointer:
4483 cast<ObjCObjectPointerType>(T)->getPointeeType());
4490 llvm_unreachable(
"unhandled type class");
4521 if (
auto Nullability = AT->getImmediateNullability())
4524 Type = AT->getEquivalentType();
4526 return std::nullopt;
4532 switch (
type->getTypeClass()) {
4534#define NON_CANONICAL_TYPE(Class, Parent) \
4536 llvm_unreachable("non-canonical type");
4537#define TYPE(Class, Parent)
4538#include "clang/AST/TypeNodes.inc"
4542 case Type::BlockPointer:
4543 case Type::MemberPointer:
4544 case Type::ObjCObjectPointer:
4548 case Type::UnresolvedUsing:
4549 case Type::TypeOfExpr:
4551 case Type::Decltype:
4552 case Type::PackIndexing:
4553 case Type::UnaryTransform:
4554 case Type::TemplateTypeParm:
4555 case Type::SubstTemplateTypeParmPack:
4556 case Type::DependentName:
4557 case Type::DependentTemplateSpecialization:
4559 return ResultIfUnknown;
4564 case Type::TemplateSpecialization:
4566 = cast<TemplateSpecializationType>(
type.getTypePtr())
4567 ->getTemplateName().getAsTemplateDecl()) {
4568 if (isa<ClassTemplateDecl>(templateDecl))
4571 return ResultIfUnknown;
4574 switch (cast<BuiltinType>(
type.getTypePtr())->getKind()) {
4576#define SIGNED_TYPE(Id, SingletonId) case BuiltinType::Id:
4577#define UNSIGNED_TYPE(Id, SingletonId) case BuiltinType::Id:
4578#define FLOATING_TYPE(Id, SingletonId) case BuiltinType::Id:
4579#define BUILTIN_TYPE(Id, SingletonId)
4580#include "clang/AST/BuiltinTypes.def"
4584 case BuiltinType::Dependent:
4585 case BuiltinType::Overload:
4586 case BuiltinType::BoundMember:
4587 case BuiltinType::PseudoObject:
4588 case BuiltinType::UnknownAny:
4589 case BuiltinType::ARCUnbridgedCast:
4590 return ResultIfUnknown;
4592 case BuiltinType::Void:
4593 case BuiltinType::ObjCId:
4594 case BuiltinType::ObjCClass:
4595 case BuiltinType::ObjCSel:
4596#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
4597 case BuiltinType::Id:
4598#include "clang/Basic/OpenCLImageTypes.def"
4599#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \
4600 case BuiltinType::Id:
4601#include "clang/Basic/OpenCLExtensionTypes.def"
4602 case BuiltinType::OCLSampler:
4603 case BuiltinType::OCLEvent:
4604 case BuiltinType::OCLClkEvent:
4605 case BuiltinType::OCLQueue:
4606 case BuiltinType::OCLReserveID:
4607#define SVE_TYPE(Name, Id, SingletonId) \
4608 case BuiltinType::Id:
4609#include "clang/Basic/AArch64SVEACLETypes.def"
4610#define PPC_VECTOR_TYPE(Name, Id, Size) \
4611 case BuiltinType::Id:
4612#include "clang/Basic/PPCTypes.def"
4613#define RVV_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
4614#include "clang/Basic/RISCVVTypes.def"
4615#define WASM_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
4616#include "clang/Basic/WebAssemblyReferenceTypes.def"
4617 case BuiltinType::BuiltinFn:
4618 case BuiltinType::NullPtr:
4619 case BuiltinType::IncompleteMatrixIdx:
4620 case BuiltinType::OMPArraySection:
4621 case BuiltinType::OMPArrayShaping:
4622 case BuiltinType::OMPIterator:
4625 llvm_unreachable(
"unknown builtin type");
4629 case Type::LValueReference:
4630 case Type::RValueReference:
4631 case Type::ConstantArray:
4632 case Type::IncompleteArray:
4633 case Type::VariableArray:
4634 case Type::DependentSizedArray:
4635 case Type::DependentVector:
4636 case Type::DependentSizedExtVector:
4638 case Type::ExtVector:
4639 case Type::ConstantMatrix:
4640 case Type::DependentSizedMatrix:
4641 case Type::DependentAddressSpace:
4642 case Type::FunctionProto:
4643 case Type::FunctionNoProto:
4645 case Type::DeducedTemplateSpecialization:
4647 case Type::InjectedClassName:
4648 case Type::PackExpansion:
4649 case Type::ObjCObject:
4650 case Type::ObjCInterface:
4654 case Type::DependentBitInt:
4657 llvm_unreachable(
"bad type kind!");
4669 return std::nullopt;
4672std::optional<NullabilityKind>
4675 if (
auto MacroTy = dyn_cast<MacroQualifiedType>(T))
4676 AttrTy = MacroTy->getUnderlyingType();
4678 if (
auto attributed = dyn_cast<AttributedType>(AttrTy)) {
4679 if (
auto nullability = attributed->getImmediateNullability()) {
4680 T = attributed->getModifiedType();
4685 return std::nullopt;
4689 const auto *objcPtr = getAs<ObjCObjectPointerType>();
4693 if (objcPtr->isObjCIdType()) {
4704 }
else if (objcPtr->isObjCQualifiedIdType()) {
4729 "cannot query implicit lifetime for non-inferrable type");
4734 while (
const auto *array = dyn_cast<ArrayType>(canon))
4735 canon = array->getElementType().getTypePtr();
4737 if (
const auto *opt = dyn_cast<ObjCObjectPointerType>(canon)) {
4739 if (opt->getObjectType()->isObjCClass())
4747 if (
const auto *
typedefType = getAs<TypedefType>())
4748 return typedefType->getDecl()->hasAttr<ObjCNSObjectAttr>();
4753 if (
const auto *
typedefType = getAs<TypedefType>())
4754 return typedefType->getDecl()->hasAttr<ObjCIndependentClassAttr>();
4767 if (
const auto *OPT = getAs<PointerType>())
4768 return OPT->getPointeeType()->isObjCIndirectLifetimeType();
4769 if (
const auto *Ref = getAs<ReferenceType>())
4770 return Ref->getPointeeType()->isObjCIndirectLifetimeType();
4771 if (
const auto *MemPtr = getAs<MemberPointerType>())
4772 return MemPtr->getPointeeType()->isObjCIndirectLifetimeType();
4780 while (
const ArrayType *array =
type->getAsArrayTypeUnsafe())
4781 type = array->getElementType().getTypePtr();
4782 return type->isObjCRetainableType();
4793 const auto *
Pointer = getAs<PointerType>();
4803 if (
const auto *RT = getAs<RecordType>())
4804 return RT->getDecl()->hasAttr<CUDADeviceBuiltinSurfaceTypeAttr>();
4810 if (
const auto *RT = getAs<RecordType>())
4811 return RT->getDecl()->hasAttr<CUDADeviceBuiltinTextureTypeAttr>();
4818 if (
const auto *ptr = getAs<PointerType>())
4819 return ptr->getPointeeType()->hasSizedVLAType();
4820 if (
const auto *ref = getAs<ReferenceType>())
4821 return ref->getPointeeType()->hasSizedVLAType();
4823 if (isa<VariableArrayType>(arr) &&
4824 cast<VariableArrayType>(arr)->getSizeExpr())
4827 return arr->getElementType()->hasSizedVLAType();
4834 switch (
type.getObjCLifetime()) {
4846 if (
const auto *RT =
4849 if (
const auto *CXXRD = dyn_cast<CXXRecordDecl>(RD)) {
4851 if (CXXRD->hasDefinition() && !CXXRD->hasTrivialDestructor())
4869 llvm::APSInt Val,
unsigned Scale) {
4870 llvm::FixedPointSemantics FXSema(Val.getBitWidth(), Scale, Val.isSigned(),
4873 llvm::APFixedPoint(Val, FXSema).toString(Str);
4881 AutoTypeBits.Keyword = llvm::to_underlying(Keyword);
4882 AutoTypeBits.NumArgs = TypeConstraintArgs.size();
4883 this->TypeConstraintConcept = TypeConstraintConcept;
4884 assert(TypeConstraintConcept || AutoTypeBits.NumArgs == 0);
4885 if (TypeConstraintConcept) {
4904 ID.AddInteger((
unsigned)Keyword);
4905 ID.AddBoolean(IsDependent);
4908 Arg.Profile(ID, Context);
Defines the clang::ASTContext interface.
Provides definitions for the various language-specific address spaces.
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate....
Defines the C++ template declaration subclasses.
Defines the ExceptionSpecificationType enumeration and various utility functions.
Defines the clang::IdentifierInfo, clang::IdentifierTable, and clang::Selector interfaces.
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified.
Defines the clang::LangOptions interface.
llvm::MachO::Record Record
static bool isRecordType(QualType T)
Defines various enumerations that describe declaration and type specifiers.
Defines the TargetCXXABI class, which abstracts details of the C++ ABI that we're targeting.
static TagDecl * getInterestingTagDecl(TagDecl *decl)
#define SUGARED_TYPE_CLASS(Class)
static bool HasNonDeletedDefaultedEqualityComparison(const CXXRecordDecl *Decl)
static const TemplateTypeParmDecl * getReplacedParameter(Decl *D, unsigned Index)
static bool isTriviallyCopyableTypeImpl(const QualType &type, const ASTContext &Context, bool IsCopyConstructible)
static const T * getAsSugar(const Type *Cur)
This will check for a T (which should be a Type which can act as sugar, such as a TypedefType) by rem...
#define TRIVIAL_TYPE_CLASS(Class)
static CachedProperties computeCachedProperties(const Type *T)
C Language Family Type Representation.
Defines the clang::Visibility enumeration and various utility functions.
__DEVICE__ void * memcpy(void *__a, const void *__b, size_t __c)
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
BuiltinVectorTypeInfo getBuiltinVectorTypeInfo(const BuiltinType *VecTy) const
Returns the element type, element count and number of vectors (in case of tuple) for a builtin vector...
QualType getAtomicType(QualType T) const
Return the uniqued reference to the atomic type for the specified type.
QualType getParenType(QualType NamedType) const
QualType getRValueReferenceType(QualType T) const
Return the uniqued reference to the type for an rvalue reference to the specified type.
QualType getAttributedType(attr::Kind attrKind, QualType modifiedType, QualType equivalentType) const
QualType getAutoType(QualType DeducedType, AutoTypeKeyword Keyword, bool IsDependent, bool IsPack=false, ConceptDecl *TypeConstraintConcept=nullptr, ArrayRef< TemplateArgument > TypeConstraintArgs={}) const
C++11 deduced auto type.
QualType getObjCInterfaceType(const ObjCInterfaceDecl *Decl, ObjCInterfaceDecl *PrevDecl=nullptr) const
getObjCInterfaceType - Return the unique reference to the type for the specified ObjC interface decl.
QualType getBlockPointerType(QualType T) const
Return the uniqued reference to the type for a block of the specified type.
QualType getMemberPointerType(QualType T, const Type *Cls) const
Return the uniqued reference to the type for a member pointer to the specified type in the specified ...
QualType getVariableArrayType(QualType EltTy, Expr *NumElts, ArraySizeModifier ASM, unsigned IndexTypeQuals, SourceRange Brackets) const
Return a non-unique reference to the type for a variable array of the specified element type.
QualType getFunctionNoProtoType(QualType ResultTy, const FunctionType::ExtInfo &Info) const
Return a K&R style C function type like 'int()'.
QualType getVectorType(QualType VectorType, unsigned NumElts, VectorKind VecKind) const
Return the unique reference to a vector type of the specified element type and size.
QualType getPointerType(QualType T) const
Return the uniqued reference to the type for a pointer to the specified type.
QualType getLValueReferenceType(QualType T, bool SpelledAsLValue=true) const
Return the uniqued reference to the type for an lvalue reference to the specified type.
QualType getConstantArrayType(QualType EltTy, const llvm::APInt &ArySize, const Expr *SizeExpr, ArraySizeModifier ASM, unsigned IndexTypeQuals) const
Return the unique reference to the type for a constant array of the specified element type.
const LangOptions & getLangOpts() const
QualType applyObjCProtocolQualifiers(QualType type, ArrayRef< ObjCProtocolDecl * > protocols, bool &hasError, bool allowOnPointerType=false) const
Apply Objective-C protocol qualifiers to the given type.
QualType getDecayedType(QualType T) const
Return the uniqued reference to the decayed version of the given type.
bool hasUniqueObjectRepresentations(QualType Ty, bool CheckIfTriviallyCopyable=true) const
Return true if the specified type has unique object representations according to (C++17 [meta....
QualType getBaseElementType(const ArrayType *VAT) const
Return the innermost element type of an array type.
CanQualType ObjCBuiltinIdTy
IdentifierInfo * getNSObjectName() const
Retrieve the identifier 'NSObject'.
CanQualType getSizeType() const
Return the unique type for "size_t" (C99 7.17), defined in <stddef.h>.
QualType getAdjustedType(QualType Orig, QualType New) const
Return the uniqued reference to a type adjusted from the original type to a new type.
QualType getQualifiedType(SplitQualType split) const
Un-split a SplitQualType.
QualType getObjCObjectPointerType(QualType OIT) const
Return a ObjCObjectPointerType type for the given ObjCObjectType.
QualType getObjCObjectType(QualType Base, ObjCProtocolDecl *const *Protocols, unsigned NumProtocols) const
Legacy interface: cannot provide type arguments or __kindof.
const ArrayType * getAsArrayType(QualType T) const
Type Query functions.
uint64_t getTypeSize(QualType T) const
Return the size of the specified (complete) type T, in bits.
CharUnits getTypeSizeInChars(QualType T) const
Return the size of the specified (complete) type T, in characters.
CanQualType UnsignedCharTy
QualType getFunctionType(QualType ResultTy, ArrayRef< QualType > Args, const FunctionProtoType::ExtProtoInfo &EPI) const
Return a normal function type with a typed argument list.
QualType getComplexType(QualType T) const
Return the uniqued reference to the type for a complex number with the specified element type.
QualType getExtVectorType(QualType VectorType, unsigned NumElts) const
Return the unique reference to an extended vector type of the specified element type and size.
const TargetInfo & getTargetInfo() const
QualType getSubstTemplateTypeParmType(QualType Replacement, Decl *AssociatedDecl, unsigned Index, std::optional< unsigned > PackIndex) const
Retrieve a substitution-result type.
QualType getIncompleteArrayType(QualType EltTy, ArraySizeModifier ASM, unsigned IndexTypeQuals) const
Return a unique reference to the type for an incomplete array of the specified element type.
QualType getConstantMatrixType(QualType ElementType, unsigned NumRows, unsigned NumColumns) const
Return the unique reference to the matrix type of the specified element type and size.
IdentifierInfo * getNSCopyingName()
Retrieve the identifier 'NSCopying'.
Represents a type which was implicitly adjusted by the semantic engine for arbitrary reasons.
QualType getAdjustedType() const
QualType getOriginalType() const
Represents an array type, per C99 6.7.5.2 - Array Declarators.
ArraySizeModifier getSizeModifier() const
QualType getElementType() const
ArrayType(TypeClass tc, QualType et, QualType can, ArraySizeModifier sm, unsigned tq, const Expr *sz=nullptr)
unsigned getIndexTypeCVRQualifiers() const
QualType getValueType() const
Gets the type contained by this atomic type, i.e.
An attributed type is a type to which a type attribute has been applied.
QualType getModifiedType() const
bool isCallingConv() const
std::optional< NullabilityKind > getImmediateNullability() const
static std::optional< NullabilityKind > stripOuterNullability(QualType &T)
Strip off the top-level nullability annotation on the given type, if it's there.
bool isMSTypeSpec() const
QualType getEquivalentType() const
bool isWebAssemblyFuncrefSpec() const
bool isQualifier() const
Does this attribute behave like a type qualifier?
Represents a C++11 auto or C++14 decltype(auto) type, possibly constrained by a type-constraint.
ArrayRef< TemplateArgument > getTypeConstraintArguments() const
void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context)
ConceptDecl * getTypeConstraintConcept() const
AutoTypeKeyword getKeyword() const
BitIntType(bool isUnsigned, unsigned NumBits)
QualType getPointeeType() const
This class is used for builtin types like 'int'.
StringRef getName(const PrintingPolicy &Policy) const
Represents a base class of a C++ class.
Represents a C++ struct/union/class.
bool mayBeNonDynamicClass() const
CXXRecordDecl * getMostRecentNonInjectedDecl()
bool mayBeDynamicClass() const
QuantityType getQuantity() const
getQuantity - Get the raw integer representation of this quantity.
Complex values, per C99 6.2.5p11.
QualType getElementType() const
Declaration of a C++20 concept.
Represents the canonical version of C arrays with a specified constant size.
const llvm::APInt & getSize() const
static unsigned getNumAddressingBits(const ASTContext &Context, QualType ElementType, const llvm::APInt &NumElements)
Determine the number of bits required to address a member of.
static unsigned getMaxSizeBits(const ASTContext &Context)
Determine the maximum number of active bits that an array's size can require, which limits the maximu...
const Expr * getSizeExpr() const
void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Ctx)
ConstantExpr - An expression that occurs in a constant context and optionally the result of evaluatin...
llvm::APSInt getResultAsAPSInt() const
Represents a concrete matrix type with constant number of rows and columns.
unsigned getNumColumns() const
Returns the number of columns in the matrix.
unsigned getNumRows() const
Returns the number of rows in the matrix.
ConstantMatrixType(QualType MatrixElementType, unsigned NRows, unsigned NColumns, QualType CanonElementType)
Represents a pointer type decayed from an array or function type.
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
ASTContext & getParentASTContext() const
bool isFunctionOrMethod() const
Decl - This represents one declaration (or definition), e.g.
bool isInStdNamespace() const
bool isFunctionOrFunctionTemplate() const
Whether this declaration is a function or function template.
ASTContext & getASTContext() const LLVM_READONLY
DeclContext * getDeclContext()
virtual Decl * getCanonicalDecl()
Retrieves the "canonical" declaration of the given declaration.
Represents the type decltype(expr) (C++11).
QualType desugar() const
Remove a single level of sugar.
bool isSugared() const
Returns whether this type directly provides sugar.
DecltypeType(Expr *E, QualType underlyingType, QualType can=QualType())
QualType getUnderlyingType() const
Common base class for placeholders for types that get replaced by placeholder type deduction: C++11 a...
QualType getDeducedType() const
Get the type deduced for this placeholder type, or null if it has not been deduced.
void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context)
Expr * getNumBitsExpr() const
void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context)
DependentBitIntType(bool IsUnsigned, Expr *NumBits)
void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context)
DependentDecltypeType(Expr *E, QualType UnderlyingTpe)
void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context)
Represents an extended vector type where either the type or size is dependent.
void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context)
QualType getElementType() const
Represents a matrix type where the type and the number of rows and columns is dependent on a template...
void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context)
void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context)
void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context)
void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context)
Represents a type that was referred to using an elaborated type keyword, e.g., struct S,...
QualType getNamedType() const
Retrieve the type named by the qualified-id.
bool isComplete() const
Returns true if this can be considered a complete type.
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of enums.
This represents one expression.
bool isValueDependent() const
Determines whether the value of this expression depends on.
bool isTypeDependent() const
Determines whether the type of this expression depends on.
bool isInstantiationDependent() const
Whether this expression is instantiation-dependent, meaning that it depends in some way on.
ExprDependence getDependence() const
ExtVectorType - Extended vector type.
Represents a member of a struct/union/class.
FriendDecl - Represents the declaration of a friend entity, which can be a function,...
Represents a function declaration or definition.
Represents a K&R-style 'int foo()' function, which has no information available about its arguments.
Represents a prototype with parameter type info, e.g.
bool hasDependentExceptionSpec() const
Return whether this function has a dependent exception spec.
param_type_iterator param_type_begin() const
ExceptionSpecificationType getExceptionSpecType() const
Get the kind of exception specification on this function.
bool isTemplateVariadic() const
Determines whether this function prototype contains a parameter pack at the end.
unsigned getNumParams() const
bool hasTrailingReturn() const
Whether this function prototype has a trailing return type.
QualType getParamType(unsigned i) const
QualType getExceptionType(unsigned i) const
Return the ith exception type, where 0 <= i < getNumExceptions().
void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Ctx)
unsigned getNumExceptions() const
Return the number of types in the exception specification.
CanThrowResult canThrow() const
Determine whether this function type has a non-throwing exception specification.
ExtProtoInfo getExtProtoInfo() const
Expr * getNoexceptExpr() const
Return the expression inside noexcept(expression), or a null pointer if there is none (because the ex...
ArrayRef< QualType > getParamTypes() const
ArrayRef< QualType > exceptions() const
bool hasInstantiationDependentExceptionSpec() const
Return whether this function has an instantiation-dependent exception spec.
A class which abstracts out some details necessary for making a call.
FunctionType - C99 6.7.5.3 - Function Declarators.
ExtInfo getExtInfo() const
static StringRef getNameForCallConv(CallingConv CC)
QualType getReturnType() const
One of these records is kept for each identifier that is lexed.
bool isStr(const char(&Str)[StrLen]) const
Return true if this is the identifier for the specified string.
Represents a C array with an unspecified size.
CXXRecordDecl * getDecl() const
An lvalue reference type, per C++11 [dcl.ref].
LinkageInfo computeTypeLinkageInfo(const Type *T)
LinkageInfo getTypeLinkageAndVisibility(const Type *T)
LinkageInfo getDeclLinkageAndVisibility(const NamedDecl *D)
static LinkageInfo external()
Linkage getLinkage() const
void merge(LinkageInfo other)
Merge both linkage and visibility.
Sugar type that represents a type that was qualified by a qualifier written as a macro invocation.
QualType getModifiedType() const
Return this attributed type's modified type with no qualifiers attached to it.
QualType getUnderlyingType() const
const IdentifierInfo * getMacroIdentifier() const
Represents a matrix type, as defined in the Matrix Types clang extensions.
QualType getElementType() const
Returns type of the elements being stored in the matrix.
MatrixType(QualType ElementTy, QualType CanonElementTy)
QualType ElementType
The element type of the matrix.
A pointer to member type per C++ 8.3.3 - Pointers to members.
CXXRecordDecl * getMostRecentCXXRecordDecl() const
QualType getPointeeType() const
const Type * getClass() const
This represents a decl that may have a name.
Linkage getLinkageInternal() const
Determine what kind of linkage this entity has.
IdentifierInfo * getIdentifier() const
Get the identifier that names this declaration, if there is one.
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
bool isDependent() const
Whether this nested name specifier refers to a dependent type or not.
ObjCCategoryDecl - Represents a category declaration.
ObjCInterfaceDecl * getClassInterface()
ObjCTypeParamList * getTypeParamList() const
Retrieve the type parameter list associated with this category or extension.
Represents an ObjC class declaration.
ObjCTypeParamList * getTypeParamList() const
Retrieve the type parameters of this class.
const ObjCObjectType * getSuperClassType() const
Retrieve the superclass type.
ObjCInterfaceDecl * getDefinition()
Retrieve the definition of this class, or NULL if this class has been forward-declared (with @class) ...
Interfaces are the core concept in Objective-C for object oriented design.
ObjCInterfaceDecl * getDecl() const
Get the declaration of this interface.
Represents a pointer to an Objective C object.
const ObjCObjectPointerType * stripObjCKindOfTypeAndQuals(const ASTContext &ctx) const
Strip off the Objective-C "kindof" type and (with it) any protocol qualifiers.
const ObjCObjectType * getObjectType() const
Gets the type pointed to by this ObjC pointer.
QualType getSuperClassType() const
Retrieve the type of the superclass of this object pointer type.
QualType getPointeeType() const
Gets the type pointed to by this ObjC pointer.
ObjCInterfaceDecl * getInterfaceDecl() const
If this pointer points to an Objective @interface type, gets the declaration for that interface.
const ObjCInterfaceType * getInterfaceType() const
If this pointer points to an Objective C @interface type, gets the type for that interface.
bool isKindOfType() const
Whether this is a "__kindof" type.
void Profile(llvm::FoldingSetNodeID &ID)
Represents a class type in Objective C.
bool isKindOfTypeAsWritten() const
Whether this is a "__kindof" type as written.
bool isSpecialized() const
Determine whether this object type is "specialized", meaning that it has type arguments.
ObjCObjectType(QualType Canonical, QualType Base, ArrayRef< QualType > typeArgs, ArrayRef< ObjCProtocolDecl * > protocols, bool isKindOf)
ArrayRef< QualType > getTypeArgsAsWritten() const
Retrieve the type arguments of this object type as they were written.
QualType getBaseType() const
Gets the base type of this object type.
bool isKindOfType() const
Whether this ia a "__kindof" type (semantically).
bool isSpecializedAsWritten() const
Determine whether this object type was written with type arguments.
ArrayRef< QualType > getTypeArgs() const
Retrieve the type arguments of this object type (semantically).
bool isUnspecialized() const
Determine whether this object type is "unspecialized", meaning that it has no type arguments.
QualType stripObjCKindOfTypeAndQuals(const ASTContext &ctx) const
Strip off the Objective-C "kindof" type and (with it) any protocol qualifiers.
void computeSuperClassTypeSlow() const
ObjCInterfaceDecl * getInterface() const
Gets the interface declaration for this object type, if the base type really is an interface.
QualType getSuperClassType() const
Retrieve the type of the superclass of this object type.
Represents an Objective-C protocol declaration.
void initialize(ArrayRef< ObjCProtocolDecl * > protocols)
ArrayRef< ObjCProtocolDecl * > getProtocols() const
Retrieve all of the protocol qualifiers.
unsigned getNumProtocols() const
Return the number of qualifying protocols in this type, or 0 if there are none.
qual_iterator qual_end() const
qual_iterator qual_begin() const
Represents the declaration of an Objective-C type parameter.
unsigned getIndex() const
Retrieve the index into its type parameter list.
Stores a list of Objective-C type parameters for a parameterized class or a category/extension thereo...
unsigned size() const
Determine the number of type parameters in this list.
Represents a type parameter type in Objective C.
void Profile(llvm::FoldingSetNodeID &ID)
ObjCTypeParamDecl * getDecl() const
Represents a pack expansion of types.
QualType getPattern() const
Retrieve the pattern of this pack expansion, which is the type that will be repeatedly instantiated w...
PackIndexingType(const ASTContext &Context, QualType Canonical, QualType Pattern, Expr *IndexExpr, ArrayRef< QualType > Expansions={})
void Profile(llvm::FoldingSetNodeID &ID)
Expr * getIndexExpr() const
std::optional< unsigned > getSelectedIndex() const
Sugar for parentheses used when specifying types.
QualType getInnerType() const
PointerType - C99 6.7.5.1 - Pointer Declarators.
QualType getPointeeType() const
A (possibly-)qualified type.
bool isTriviallyCopyableType(const ASTContext &Context) const
Return true if this is a trivially copyable type (C++0x [basic.types]p9)
QualType IgnoreParens() const
Returns the specified type after dropping any outer-level parentheses.
QualType withFastQualifiers(unsigned TQs) const
bool hasNonTrivialToPrimitiveCopyCUnion() const
Check if this is or contains a C union that is non-trivial to copy, which is a union that has a membe...
bool isWebAssemblyFuncrefType() const
Returns true if it is a WebAssembly Funcref Type.
QualType getNonLValueExprType(const ASTContext &Context) const
Determine the type of a (typically non-lvalue) expression with the specified result type.
@ DK_objc_strong_lifetime
PrimitiveDefaultInitializeKind
@ PDIK_ARCWeak
The type is an Objective-C retainable pointer type that is qualified with the ARC __weak qualifier.
@ PDIK_Trivial
The type does not fall into any of the following categories.
@ PDIK_ARCStrong
The type is an Objective-C retainable pointer type that is qualified with the ARC __strong qualifier.
@ PDIK_Struct
The type is a struct containing a field whose type is not PCK_Trivial.
bool mayBeDynamicClass() const
Returns true if it is a class and it might be dynamic.
bool isNonWeakInMRRWithObjCWeak(const ASTContext &Context) const
const IdentifierInfo * getBaseTypeIdentifier() const
Retrieves a pointer to the name of the base type.
void Profile(llvm::FoldingSetNodeID &ID) const
QualType getDesugaredType(const ASTContext &Context) const
Return the specified type with any "sugar" removed from the type.
bool isTriviallyCopyConstructibleType(const ASTContext &Context) const
Return true if this is a trivially copyable type.
bool isTrivialType(const ASTContext &Context) const
Return true if this is a trivial type per (C++0x [basic.types]p9)
bool isNull() const
Return true if this QualType doesn't point to a type yet.
PrimitiveCopyKind isNonTrivialToPrimitiveCopy() const
Check if this is a non-trivial type that would cause a C struct transitively containing this type to ...
bool isTriviallyRelocatableType(const ASTContext &Context) const
Return true if this is a trivially relocatable type.
const Type * getTypePtr() const
Retrieves a pointer to the underlying (unqualified) type.
LangAS getAddressSpace() const
Return the address space of this type.
bool isConstant(const ASTContext &Ctx) const
bool hasNonTrivialToPrimitiveDestructCUnion() const
Check if this is or contains a C union that is non-trivial to destruct, which is a union that has a m...
Qualifiers getQualifiers() const
Retrieve the set of qualifiers applied to this type.
bool isCXX98PODType(const ASTContext &Context) const
Return true if this is a POD type according to the rules of the C++98 standard, regardless of the cur...
Qualifiers::ObjCLifetime getObjCLifetime() const
Returns lifetime attribute of this type.
QualType stripObjCKindOfType(const ASTContext &ctx) const
Strip Objective-C "__kindof" types from the given type.
QualType getCanonicalType() const
QualType getUnqualifiedType() const
Retrieve the unqualified variant of the given type, removing as little sugar as possible.
bool isTriviallyEqualityComparableType(const ASTContext &Context) const
Return true if this is a trivially equality comparable type.
QualType substObjCMemberType(QualType objectType, const DeclContext *dc, ObjCSubstitutionContext context) const
Substitute type arguments from an object type for the Objective-C type parameters used in the subject...
bool isWebAssemblyReferenceType() const
Returns true if it is a WebAssembly Reference Type.
SplitQualType getSplitDesugaredType() const
std::optional< NonConstantStorageReason > isNonConstantStorage(const ASTContext &Ctx, bool ExcludeCtor, bool ExcludeDtor)
Determine whether instances of this type can be placed in immutable storage.
SplitQualType split() const
Divides a QualType into its unqualified type and a set of local qualifiers.
bool UseExcessPrecision(const ASTContext &Ctx)
PrimitiveDefaultInitializeKind isNonTrivialToPrimitiveDefaultInitialize() const
Functions to query basic properties of non-trivial C struct types.
void * getAsOpaquePtr() const
bool isWebAssemblyExternrefType() const
Returns true if it is a WebAssembly Externref Type.
QualType getNonPackExpansionType() const
Remove an outer pack expansion type (if any) from this type.
bool isCXX11PODType(const ASTContext &Context) const
Return true if this is a POD type according to the more relaxed rules of the C++11 standard,...
bool mayBeNotDynamicClass() const
Returns true if it is not a class or if the class might not be dynamic.
bool isConstQualified() const
Determine whether this type is const-qualified.
QualType substObjCTypeArgs(ASTContext &ctx, ArrayRef< QualType > typeArgs, ObjCSubstitutionContext context) const
Substitute type arguments for the Objective-C type parameters used in the subject type.
QualType getAtomicUnqualifiedType() const
Remove all qualifiers including _Atomic.
DestructionKind isDestructedType() const
Returns a nonzero value if objects of this type require non-trivial work to clean up after.
bool hasNonTrivialObjCLifetime() const
bool isPODType(const ASTContext &Context) const
Determine whether this is a Plain Old Data (POD) type (C++ 3.9p10).
PrimitiveCopyKind isNonTrivialToPrimitiveDestructiveMove() const
Check if this is a non-trivial type that would cause a C struct transitively containing this type to ...
@ NonConstNonReferenceType
@ PCK_Struct
The type is a struct containing a field whose type is neither PCK_Trivial nor PCK_VolatileTrivial.
@ PCK_Trivial
The type does not fall into any of the following categories.
@ PCK_ARCStrong
The type is an Objective-C retainable pointer type that is qualified with the ARC __strong qualifier.
@ PCK_VolatileTrivial
The type would be trivial except that it is volatile-qualified.
@ PCK_ARCWeak
The type is an Objective-C retainable pointer type that is qualified with the ARC __weak qualifier.
bool hasNonTrivialToPrimitiveDefaultInitializeCUnion() const
Check if this is or contains a C union that is non-trivial to default-initialize, which is a union th...
A qualifier set is used to build a set of qualifiers.
const Type * strip(QualType type)
Collect any qualifiers on the given type and return an unqualified type.
QualType apply(const ASTContext &Context, QualType QT) const
Apply the collected qualifiers to the given type.
The collection of all-type qualifiers we support.
@ OCL_Strong
Assigning into this object requires the old value to be released and the new value to be retained.
@ OCL_ExplicitNone
This object can be modified without requiring retains or releases.
@ OCL_None
There is no lifetime qualification on this type.
@ OCL_Weak
Reading or writing from this object requires a barrier call.
@ OCL_Autoreleasing
Assigning into this object requires a lifetime extension.
bool isStrictSupersetOf(Qualifiers Other) const
Determine whether this set of qualifiers is a strict superset of another set of qualifiers,...
bool hasNonFastQualifiers() const
Return true if the set contains any qualifiers which require an ExtQuals node to be allocated.
void addConsistentQualifiers(Qualifiers qs)
Add the qualifiers from the given set to this set, given that they don't conflict.
bool hasAddressSpace() const
unsigned getFastQualifiers() const
bool hasObjCGCAttr() const
bool hasObjCLifetime() const
ObjCLifetime getObjCLifetime() const
LangAS getAddressSpace() const
An rvalue reference type, per C++11 [dcl.ref].
Represents a struct/union/class.
bool hasNonTrivialToPrimitiveDestructCUnion() const
bool hasNonTrivialToPrimitiveCopyCUnion() const
bool hasNonTrivialToPrimitiveDefaultInitializeCUnion() const
bool isNonTrivialToPrimitiveDestroy() const
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
RecordDecl * getDecl() const
bool hasConstFields() const
Recursively check all fields in the record for const-ness.
Base for LValueReferenceType and RValueReferenceType.
QualType getPointeeTypeAsWritten() const
bool isSpelledAsLValue() const
Encodes a location in the source.
A trivial tuple used to represent a source range.
Stmt - This represents one statement.
void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context, bool Canonical, bool ProfileLambdaExpr=false) const
Produce a unique representation of the given statement.
Decl * getAssociatedDecl() const
A template-like entity which owns the whole pattern being substituted.
IdentifierInfo * getIdentifier() const
TemplateArgument getArgumentPack() const
void Profile(llvm::FoldingSetNodeID &ID)
unsigned getIndex() const
Returns the index of the replaced parameter in the associated declaration.
unsigned getNumArgs() const
const TemplateTypeParmDecl * getReplacedParameter() const
Gets the template parameter declaration that was substituted for.
Represents the result of substituting a type for a template type parameter.
Decl * getAssociatedDecl() const
A template-like entity which owns the whole pattern being substituted.
std::optional< unsigned > getPackIndex() const
QualType getReplacementType() const
Gets the type that was substituted for the template parameter.
unsigned getIndex() const
Returns the index of the replaced parameter in the associated declaration.
const TemplateTypeParmDecl * getReplacedParameter() const
Gets the template parameter declaration that was substituted for.
Represents the declaration of a struct/union/class/enum.
bool isBeingDefined() const
Return true if this decl is currently being defined.
bool isCompleteDefinition() const
Return true if this decl has its body fully specified.
bool hasNameForLinkage() const
Is this tag type named, either directly or via being defined in a typedef of this type?
TagType(TypeClass TC, const TagDecl *D, QualType can)
TagDecl * getDecl() const
bool isBeingDefined() const
Determines whether this type is in the process of being defined.
bool isMicrosoft() const
Is this ABI an MSVC-compatible ABI?
Exposes information about the current target.
virtual bool hasLegalHalfType() const
Determine whether _Float16 is supported on this target.
virtual bool hasFullBFloat16Type() const
Determine whether the BFloat type is fully supported on this target, i.e arithemtic operations.
virtual bool hasFloat16Type() const
Determine whether the _Float16 type is supported on this target.
TargetCXXABI getCXXABI() const
Get the C++ ABI currently in use.
virtual bool hasBFloat16Type() const
Determine whether the _BFloat16 type is supported on this target.
A convenient class for passing around template argument information.
llvm::ArrayRef< TemplateArgumentLoc > arguments() const
Location wrapper for a TemplateArgument.
Represents a template argument.
unsigned pack_size() const
The number of template arguments in the given template argument pack.
ArrayRef< TemplateArgument > pack_elements() const
Iterator range referencing all of the elements of a template argument pack.
@ Type
The template argument is a type.
The base class of all kinds of template declarations (e.g., class, function, etc.).
Represents a C++ template name within the type system.
DependentTemplateName * getAsDependentTemplateName() const
Retrieve the underlying dependent template name structure, if any.
void Profile(llvm::FoldingSetNodeID &ID)
@ UsingTemplate
A template name that refers to a template declaration found through a specific using shadow declarati...
@ Template
A single template declaration.
@ SubstTemplateTemplateParm
A template template parameter that has been substituted for some other template name.
@ SubstTemplateTemplateParmPack
A template template parameter pack that has been substituted for a template template argument pack,...
Represents a type template specialization; the template must be a class template, a type alias templa...
QualType getAliasedType() const
Get the aliased type, if this is a specialization of a type alias template.
ArrayRef< TemplateArgument > template_arguments() const
bool isTypeAlias() const
Determine if this template specialization type is for a type alias template that has been substituted...
static bool anyInstantiationDependentTemplateArguments(ArrayRef< TemplateArgumentLoc > Args)
static bool anyDependentTemplateArguments(ArrayRef< TemplateArgumentLoc > Args, ArrayRef< TemplateArgument > Converted)
Determine whether any of the given template arguments are dependent.
void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Ctx)
Declaration of a template type parameter.
TemplateTypeParmDecl * getDecl() const
IdentifierInfo * getIdentifier() const
TypeOfExprType(Expr *E, TypeOfKind Kind, QualType Can=QualType())
bool isSugared() const
Returns whether this type directly provides sugar.
Expr * getUnderlyingExpr() const
QualType desugar() const
Remove a single level of sugar.
static void ensure(const Type *T)
static CachedProperties get(QualType T)
static CachedProperties get(const Type *T)
A helper class for Type nodes having an ElaboratedTypeKeyword.
static ElaboratedTypeKeyword getKeywordForTypeSpec(unsigned TypeSpec)
Converts a type specifier (DeclSpec::TST) into an elaborated type keyword.
static TagTypeKind getTagTypeKindForKeyword(ElaboratedTypeKeyword Keyword)
Converts an elaborated type keyword into a TagTypeKind.
static bool KeywordIsTagTypeKind(ElaboratedTypeKeyword Keyword)
static StringRef getKeywordName(ElaboratedTypeKeyword Keyword)
static ElaboratedTypeKeyword getKeywordForTagTypeKind(TagTypeKind Tag)
Converts a TagTypeKind into an elaborated type keyword.
static TagTypeKind getTagTypeKindForTypeSpec(unsigned TypeSpec)
Converts a type specifier (DeclSpec::TST) into a tag type kind.
The base class of the type hierarchy.
bool isSizelessType() const
As an extension, we classify types as one of "sized" or "sizeless"; every type is one or the other.
bool isStructureType() const
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
bool isBlockPointerType() const
const ObjCObjectPointerType * getAsObjCQualifiedClassType() const
bool isLinkageValid() const
True if the computed linkage is valid.
TypedefBitfields TypedefBits
const ObjCObjectType * getAsObjCQualifiedInterfaceType() const
const ObjCObjectPointerType * getAsObjCQualifiedIdType() const
bool isSignedIntegerOrEnumerationType() const
Determines whether this is an integer type that is signed or an enumeration types whose underlying ty...
bool hasAttr(attr::Kind AK) const
Determine whether this type had the specified attribute applied to it (looking through top-level type...
QualType getRVVEltType(const ASTContext &Ctx) const
Returns the representative type for the element of an RVV builtin type.
const RecordType * getAsUnionType() const
NOTE: getAs*ArrayType are methods on ASTContext.
bool isLiteralType(const ASTContext &Ctx) const
Return true if this is a literal type (C++11 [basic.types]p10)
bool isSignedIntegerType() const
Return true if this is an integer type that is signed, according to C99 6.2.5p4 [char,...
bool isComplexType() const
isComplexType() does not include complex integers (a GCC extension).
ArrayTypeBitfields ArrayTypeBits
const ArrayType * castAsArrayTypeUnsafe() const
A variant of castAs<> for array type which silently discards qualifiers from the outermost type.
bool isUnsignedIntegerOrEnumerationType() const
Determines whether this is an integer type that is unsigned or an enumeration types whose underlying ...
bool isIntegralOrUnscopedEnumerationType() const
Determine whether this type is an integral or unscoped enumeration type.
VectorTypeBitfields VectorTypeBits
bool hasIntegerRepresentation() const
Determine whether this type has an integer representation of some sort, e.g., it is an integer type o...
bool isVoidPointerType() const
const ComplexType * getAsComplexIntegerType() const
bool isConstantSizeType() const
Return true if this is not a variable sized type, according to the rules of C99 6....
QualType getLocallyUnqualifiedSingleStepDesugaredType() const
Pull a single level of sugar off of this locally-unqualified type.
bool isFunctionPointerType() const
bool isObjCARCBridgableType() const
Determine whether the given type T is a "bridgable" Objective-C type, which is either an Objective-C ...
bool isArithmeticType() const
bool isPointerType() const
TypeOfBitfields TypeOfBits
bool isIntegerType() const
isIntegerType() does not include complex integers (a GCC extension).
bool isSVESizelessBuiltinType() const
Returns true for SVE scalable vector types.
const T * castAs() const
Member-template castAs<specific type>.
bool isReferenceType() const
bool isEnumeralType() const
void addDependence(TypeDependence D)
bool isObjCNSObjectType() const
const ObjCObjectPointerType * getAsObjCInterfacePointerType() const
bool isScalarType() const
const CXXRecordDecl * getPointeeCXXRecordDecl() const
If this is a pointer or reference to a RecordType, return the CXXRecordDecl that the type refers to.
bool isInterfaceType() const
bool isVariableArrayType() const
bool isSizelessBuiltinType() const
bool isCUDADeviceBuiltinSurfaceType() const
Check if the type is the CUDA device builtin surface type.
bool isSveVLSBuiltinType() const
Determines if this is a sizeless type supported by the 'arm_sve_vector_bits' type attribute,...
bool isIntegralType(const ASTContext &Ctx) const
Determine whether this type is an integral type.
bool isElaboratedTypeSpecifier() const
Determine wither this type is a C++ elaborated-type-specifier.
const Type * getArrayElementTypeNoTypeQual() const
If this is an array type, return the element type of the array, potentially with type qualifiers miss...
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee.
LinkageInfo getLinkageAndVisibility() const
Determine the linkage and visibility of this type.
bool hasUnsignedIntegerRepresentation() const
Determine whether this type has an unsigned integer representation of some sort, e....
bool isAnyCharacterType() const
Determine whether this type is any of the built-in character types.
bool isWebAssemblyExternrefType() const
Check if this is a WebAssembly Externref Type.
bool canHaveNullability(bool ResultIfUnknown=true) const
Determine whether the given type can have a nullability specifier applied to it, i....
QualType getSveEltType(const ASTContext &Ctx) const
Returns the representative type for the element of an SVE builtin type.
bool isInstantiationDependentType() const
Determine whether this type is an instantiation-dependent type, meaning that the type involves a temp...
bool isLValueReferenceType() const
bool isBitIntType() const
bool isStructuralType() const
Determine if this type is a structural type, per C++20 [temp.param]p7.
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
bool isAggregateType() const
Determines whether the type is a C++ aggregate type or C aggregate or union type.
bool isCARCBridgableType() const
Determine whether the given type T is a "bridgeable" C type.
bool isChar16Type() const
bool isAnyComplexType() const
DependentTemplateSpecializationTypeBitfields DependentTemplateSpecializationTypeBits
DeducedType * getContainedDeducedType() const
Get the DeducedType whose type will be deduced for a variable with an initializer of this type.
bool containsUnexpandedParameterPack() const
Whether this type is or contains an unexpanded parameter pack, used to support C++0x variadic templat...
ScalarTypeKind getScalarTypeKind() const
Given that this is a scalar type, classify it.
bool hasSignedIntegerRepresentation() const
Determine whether this type has an signed integer representation of some sort, e.g....
QualType getCanonicalTypeInternal() const
const RecordType * getAsStructureType() const
const char * getTypeClassName() const
bool isWebAssemblyTableType() const
Returns true if this is a WebAssembly table type: either an array of reference types,...
const Type * getBaseElementTypeUnsafe() const
Get the base element type of this type, potentially discarding type qualifiers.
bool isObjCBoxableRecordType() const
bool isChar32Type() const
bool isStandardLayoutType() const
Test if this type is a standard-layout type.
bool isVariablyModifiedType() const
Whether this type is a variably-modified type (C99 6.7.5).
bool isComplexIntegerType() const
bool isUnscopedEnumerationType() const
bool isStdByteType() const
bool isCUDADeviceBuiltinTextureType() const
Check if the type is the CUDA device builtin texture type.
bool isBlockCompatibleObjCPointerType(ASTContext &ctx) const
bool isObjCClassOrClassKindOfType() const
Whether the type is Objective-C 'Class' or a __kindof type of an Class type, e.g.,...
const ArrayType * getAsArrayTypeUnsafe() const
A variant of getAs<> for array types which silently discards qualifiers from the outermost type.
bool isObjCLifetimeType() const
Returns true if objects of this type have lifetime semantics under ARC.
bool isObjectType() const
Determine whether this type is an object type.
bool isObjCIndirectLifetimeType() const
bool hasUnnamedOrLocalType() const
Whether this type is or contains a local or unnamed type.
Qualifiers::ObjCLifetime getObjCARCImplicitLifetime() const
Return the implicit lifetime for this type, which must not be dependent.
FunctionTypeBitfields FunctionTypeBits
bool isObjCQualifiedInterfaceType() const
bool isSpecifierType() const
Returns true if this type can be represented by some set of type specifiers.
bool isIncompleteType(NamedDecl **Def=nullptr) const
Types are partitioned into 3 broad categories (C99 6.2.5p1): object types, function types,...
bool isObjCObjectPointerType() const
TypeDependence getDependence() const
bool hasFloatingRepresentation() const
Determine whether this type has a floating-point representation of some sort, e.g....
bool isStructureOrClassType() const
bool isVectorType() const
bool isRVVVLSBuiltinType() const
Determines if this is a sizeless type supported by the 'riscv_rvv_vector_bits' type attribute,...
bool isRealFloatingType() const
Floating point categories.
bool isRVVSizelessBuiltinType() const
Returns true for RVV scalable vector types.
std::optional< ArrayRef< QualType > > getObjCSubstitutions(const DeclContext *dc) const
Retrieve the set of substitutions required when accessing a member of the Objective-C receiver type t...
Linkage getLinkage() const
Determine the linkage of this type.
ObjCObjectTypeBitfields ObjCObjectTypeBits
bool isFloatingType() const
const ObjCObjectType * getAsObjCInterfaceType() const
bool isWideCharType() const
bool isUnsignedIntegerType() const
Return true if this is an integer type that is unsigned, according to C99 6.2.5p6 [which returns true...
bool hasSizedVLAType() const
Whether this type involves a variable-length array type with a definite size.
TypeClass getTypeClass() const
bool isCanonicalUnqualified() const
Determines if this type would be canonical if it had no further qualification.
bool hasAutoForTrailingReturnType() const
Determine whether this type was written with a leading 'auto' corresponding to a trailing return type...
bool isObjCIdOrObjectKindOfType(const ASTContext &ctx, const ObjCObjectType *&bound) const
Whether the type is Objective-C 'id' or a __kindof type of an object type, e.g., __kindof NSView * or...
const T * getAs() const
Member-template getAs<specific type>'.
SubstTemplateTypeParmPackTypeBitfields SubstTemplateTypeParmPackTypeBits
const Type * getUnqualifiedDesugaredType() const
Return the specified type with any "sugar" removed from the type, removing any typedefs,...
bool isObjCARCImplicitlyUnretainedType() const
Determines if this type, which must satisfy isObjCLifetimeType(), is implicitly __unsafe_unretained r...
bool isRecordType() const
TemplateSpecializationTypeBitfields TemplateSpecializationTypeBits
bool isObjCRetainableType() const
std::optional< NullabilityKind > getNullability() const
Determine the nullability of the given type.
bool isObjCIndependentClassType() const
TagDecl * getAsTagDecl() const
Retrieves the TagDecl that this type refers to, either because the type is a TagType or because it is...
bool isSizelessVectorType() const
Returns true for all scalable vector types.
bool isScopedEnumeralType() const
Determine whether this type is a scoped enumeration type.
bool acceptsObjCTypeParams() const
Determines if this is an ObjC interface type that may accept type parameters.
RecordDecl * getAsRecordDecl() const
Retrieves the RecordDecl this type refers to.
Base class for declarations which introduce a typedef-name.
QualType getUnderlyingType() const
bool typeMatchesDecl() const
Represents a shadow declaration implicitly introduced into a scope by a (resolved) using-declaration ...
NamedDecl * getTargetDecl() const
Gets the underlying declaration which has been brought into the local scope.
QualType getUnderlyingType() const
bool typeMatchesDecl() const
Represents a C array with a specified size that is not an integer-constant-expression.
SourceRange getBracketsRange() const
Expr * getSizeExpr() const
Represents a GCC generic vector type.
unsigned getNumElements() const
VectorType(QualType vecType, unsigned nElements, QualType canonType, VectorKind vecKind)
VectorKind getVectorKind() const
QualType getElementType() const
Defines the Linkage enumeration and various utility functions.
Defines the clang::TargetInfo interface.
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
const AstTypeMatcher< TypedefType > typedefType
Matches typedef types.
const internal::VariadicAllOfMatcher< Decl > decl
Matches declarations.
The JSON file list parser is used to communicate input to InstallAPI.
@ Private
'private' clause, allowed on 'parallel', 'serial', 'loop', 'parallel loop', and 'serial loop' constru...
@ Vector
'vector' clause, allowed on 'loop', Combined, and 'routine' directives.
AutoTypeKeyword
Which keyword(s) were used to create an AutoType.
CanThrowResult
Possible results from evaluation of a noexcept expression.
void initialize(TemplateInstantiationCallbackPtrs &Callbacks, const Sema &TheSema)
Linkage minLinkage(Linkage L1, Linkage L2)
Compute the minimum linkage given two linkages.
@ Nullable
Values of this type can be null.
@ Unspecified
Whether values of this type can be null is (explicitly) unspecified.
@ NonNull
Values of this type can never be null.
ExprDependence computeDependence(FullExpr *E)
TypeOfKind
The kind of 'typeof' expression we're after.
TypeDependence toTypeDependence(ExprDependence D)
ExprDependence turnValueToTypeDependence(ExprDependence D)
Linkage
Describes the different kinds of linkage (C++ [basic.link], C99 6.2.2) that an entity may have.
@ External
External linkage, which indicates that the entity can be referred to from other translation units.
ObjCSubstitutionContext
The kind of type we are substituting Objective-C type arguments into.
@ Superclass
The superclass of a type.
@ Result
The result type of a method or function.
ArraySizeModifier
Capture whether this is a normal array (e.g.
bool isComputedNoexcept(ExceptionSpecificationType ESpecType)
TemplateParameterList * getReplacedTemplateParameterList(Decl *D)
Internal helper used by Subst* nodes to retrieve the parameter list for their AssociatedDecl.
TagTypeKind
The kind of a tag type.
@ Interface
The "__interface" keyword.
@ Struct
The "struct" keyword.
@ Class
The "class" keyword.
@ Union
The "union" keyword.
@ Enum
The "enum" keyword.
void FixedPointValueToString(SmallVectorImpl< char > &Str, llvm::APSInt Val, unsigned Scale)
CallingConv
CallingConv - Specifies the calling convention that a function uses.
@ None
The alignment was not explicit in code.
ElaboratedTypeKeyword
The elaboration keyword that precedes a qualified type name or introduces an elaborated-type-specifie...
@ Interface
The "__interface" keyword introduces the elaborated-type-specifier.
@ None
No keyword precedes the qualified type name.
@ Struct
The "struct" keyword introduces the elaborated-type-specifier.
@ Class
The "class" keyword introduces the elaborated-type-specifier.
@ Union
The "union" keyword introduces the elaborated-type-specifier.
@ Enum
The "enum" keyword introduces the elaborated-type-specifier.
@ Typename
The "typename" keyword precedes the qualified type name, e.g., typename T::type.
TypeDependence toSemanticDependence(TypeDependence D)
TypeDependence toSyntacticDependence(TypeDependence D)
@ Other
Other implicit parameter.
@ EST_DependentNoexcept
noexcept(expression), value-dependent
@ EST_Uninstantiated
not instantiated yet
@ EST_Unparsed
not parsed yet
@ EST_NoThrow
Microsoft __declspec(nothrow) extension.
@ EST_None
no exception specification
@ EST_MSAny
Microsoft throw(...) extension.
@ EST_BasicNoexcept
noexcept
@ EST_NoexceptFalse
noexcept(expression), evals to 'false'
@ EST_Unevaluated
not evaluated yet, for special member function
@ EST_NoexceptTrue
noexcept(expression), evals to 'true'
@ EST_Dynamic
throw(T1, T2)
FunctionDecl * SourceDecl
The function whose exception specification this is, for EST_Unevaluated and EST_Uninstantiated.
FunctionDecl * SourceTemplate
The function template whose exception specification this is instantiated from, for EST_Uninstantiated...
ExceptionSpecificationType Type
The kind of exception specification this is.
ArrayRef< QualType > Exceptions
Explicitly-specified list of exception types.
Expr * NoexceptExpr
Noexcept expression, if this is a computed noexcept specification.
Extra information about a function prototype.
ExceptionSpecInfo ExceptionSpec
bool requiresFunctionProtoTypeArmAttributes() const
unsigned AArch64SMEAttributes
SourceLocation EllipsisLoc
const ExtParameterInfo * ExtParameterInfos
RefQualifierKind RefQualifier
unsigned HasTrailingReturn
bool requiresFunctionProtoTypeExtraBitfields() const
Describes how types, statements, expressions, and declarations should be printed.
unsigned Bool
Whether we can use 'bool' rather than '_Bool' (even if the language doesn't actually have 'bool',...
unsigned NullptrTypeInNamespace
Whether 'nullptr_t' is in namespace 'std' or not.
unsigned Half
When true, print the half-precision floating-point type as 'half' instead of '__fp16'.
unsigned MSWChar
When true, print the built-in wchar_t type as __wchar_t.
A std::pair-like structure for storing a qualified type split into its local qualifiers and its local...
const Type * Ty
The locally-unqualified type.
Qualifiers Quals
The local qualifiers.