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();
106 if (
T.isConstQualified())
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 &Sz,
const Expr *SzExpr,
166 bool NeedsExternalSize = SzExpr !=
nullptr || Sz.ugt(0x0FFFFFFFFFFFFFFF) ||
167 Sz.getBitWidth() > 0xFF;
168 if (!NeedsExternalSize)
170 ET, Can, Sz.getBitWidth(), Sz.getZExtValue(), SzMod, Qual);
172 auto *SzPtr =
new (Ctx,
alignof(ConstantArrayType::ExternalSize))
173 ConstantArrayType::ExternalSize(Sz, SzExpr);
180 const llvm::APInt &NumElements) {
189 if (llvm::isPowerOf2_64(ElementSize)) {
190 return NumElements.getActiveBits() + llvm::Log2_64(ElementSize);
195 if ((ElementSize >> 32) == 0 && NumElements.getBitWidth() <= 64 &&
196 (NumElements.getZExtValue() >> 32) == 0) {
197 uint64_t TotalSize = NumElements.getZExtValue() * ElementSize;
198 return llvm::bit_width(TotalSize);
202 llvm::APSInt SizeExtended(NumElements,
true);
204 SizeExtended = SizeExtended.extend(std::max(SizeTypeBits,
205 SizeExtended.getBitWidth()) * 2);
207 llvm::APSInt TotalSize(llvm::APInt(SizeExtended.getBitWidth(), ElementSize));
208 TotalSize *= SizeExtended;
210 return TotalSize.getActiveBits();
232 uint64_t ArraySize,
const Expr *SizeExpr,
235 ID.AddInteger(ArraySize);
236 ID.AddInteger(llvm::to_underlying(SizeMod));
237 ID.AddInteger(TypeQuals);
238 ID.AddBoolean(SizeExpr !=
nullptr);
240 SizeExpr->
Profile(ID, Context,
true);
247 :
ArrayType(DependentSizedArray, et, can, sm, tq, e), SizeExpr((
Stmt *)e),
248 Brackets(brackets) {}
257 ID.AddInteger(llvm::to_underlying(SizeMod));
258 ID.AddInteger(TypeQuals);
262DependentVectorType::DependentVectorType(
QualType ElementType,
265 :
Type(DependentVector, CanonType,
267 ElementType->getDependence() |
270 ElementType(ElementType), SizeExpr(SizeExpr), Loc(Loc) {
279 ID.AddInteger(llvm::to_underlying(VecKind));
280 SizeExpr->
Profile(ID, Context,
true);
283DependentSizedExtVectorType::DependentSizedExtVectorType(
QualType ElementType,
287 :
Type(DependentSizedExtVector, can,
289 ElementType->getDependence() |
292 SizeExpr(SizeExpr), ElementType(ElementType), loc(loc) {}
299 SizeExpr->
Profile(ID, Context,
true);
302DependentAddressSpaceType::DependentAddressSpaceType(
QualType PointeeType,
306 :
Type(DependentAddressSpace, can,
308 PointeeType->getDependence() |
311 AddrSpaceExpr(AddrSpaceExpr), PointeeType(PointeeType), loc(loc) {}
316 Expr *AddrSpaceExpr) {
318 AddrSpaceExpr->
Profile(ID, Context,
true);
322 const Expr *RowExpr,
const Expr *ColumnExpr)
323 :
Type(tc, canonType,
324 (RowExpr ? (matrixType->getDependence() |
TypeDependence::Dependent |
326 (matrixType->isVariablyModifiedType()
329 (matrixType->containsUnexpandedParameterPack() ||
331 RowExpr->containsUnexpandedParameterPack()) ||
333 ColumnExpr->containsUnexpandedParameterPack())
336 : matrixType->getDependence())),
337 ElementType(matrixType) {}
340 unsigned nColumns,
QualType canonType)
345 unsigned nRows,
unsigned nColumns,
347 :
MatrixType(tc, matrixType, canonType), NumRows(nRows),
348 NumColumns(nColumns) {}
350DependentSizedMatrixType::DependentSizedMatrixType(
QualType ElementType,
355 :
MatrixType(DependentSizedMatrix, ElementType, CanonicalType, RowExpr,
357 RowExpr(RowExpr), ColumnExpr(ColumnExpr), loc(loc) {}
364 RowExpr->
Profile(ID, CTX,
true);
365 ColumnExpr->
Profile(ID, CTX,
true);
374 :
Type(tc, canonType, vecType->getDependence()), ElementType(vecType) {
386 ExprAndUnsigned(NumBitsExpr, IsUnsigned) {}
389 return ExprAndUnsigned.getInt();
393 return ExprAndUnsigned.getPointer();
399 ID.AddBoolean(IsUnsigned);
400 NumBitsExpr->
Profile(ID, Context,
true);
406 return isa<FieldDecl>(Info.
getDecl());
412 bool CountInBytes,
bool OrNull) {
414 ID.AddBoolean(CountInBytes);
415 ID.AddBoolean(OrNull);
420 ID.AddPointer(CountExpr);
428 if (
const auto *ATy = dyn_cast<ArrayType>(
this))
429 return ATy->getElementType().getTypePtr();
432 if (!isa<ArrayType>(CanonicalType))
438 ->getElementType().getTypePtr();
462#define TYPE(CLASS, BASE) \
463 static_assert(!std::is_polymorphic<CLASS##Type>::value, \
464 #CLASS "Type should not be polymorphic!");
465#include "clang/AST/TypeNodes.inc"
470#define TYPE(CLASS, BASE) \
471 static_assert(std::is_trivially_destructible<CLASS##Type>::value, \
472 #CLASS "Type should be trivially destructible!");
473#include "clang/AST/TypeNodes.inc"
477#define ABSTRACT_TYPE(Class, Parent)
478#define TYPE(Class, Parent) \
479 case Type::Class: { \
480 const auto *ty = cast<Class##Type>(this); \
481 if (!ty->isSugared()) return QualType(ty, 0); \
482 return ty->desugar(); \
484#include "clang/AST/TypeNodes.inc"
486 llvm_unreachable(
"bad type kind!");
496#define ABSTRACT_TYPE(Class, Parent)
497#define TYPE(Class, Parent) \
498 case Type::Class: { \
499 const auto *Ty = cast<Class##Type>(CurTy); \
500 if (!Ty->isSugared()) \
501 return SplitQualType(Ty, Qs); \
502 Cur = Ty->desugar(); \
505#include "clang/AST/TypeNodes.inc"
525#define ABSTRACT_TYPE(Class, Parent)
526#define TYPE(Class, Parent) \
527 case Type::Class: { \
528 const auto *ty = cast<Class##Type>(split.Ty); \
529 if (!ty->isSugared()) goto done; \
530 next = ty->desugar(); \
533#include "clang/AST/TypeNodes.inc"
552 T = PT->getInnerType();
561 if (
const auto *Sugar = dyn_cast<T>(Cur))
564#define ABSTRACT_TYPE(Class, Parent)
565#define TYPE(Class, Parent) \
566 case Type::Class: { \
567 const auto *Ty = cast<Class##Type>(Cur); \
568 if (!Ty->isSugared()) return 0; \
569 Cur = Ty->desugar().getTypePtr(); \
572#include "clang/AST/TypeNodes.inc"
578 return getAsSugar<TypedefType>(
this);
582 return getAsSugar<UsingType>(
this);
586 return getAsSugar<TemplateSpecializationType>(
this);
590 return getAsSugar<AttributedType>(
this);
594 return getAsSugar<BoundsAttributedType>(
this);
598 return getAsSugar<CountAttributedType>(
this);
605 const Type *Cur =
this;
609#define ABSTRACT_TYPE(Class, Parent)
610#define TYPE(Class, Parent) \
612 const auto *Ty = cast<Class##Type>(Cur); \
613 if (!Ty->isSugared()) return Cur; \
614 Cur = Ty->desugar().getTypePtr(); \
617#include "clang/AST/TypeNodes.inc"
623 if (
const auto *RT = getAs<RecordType>())
624 return RT->getDecl()->isClass();
629 if (
const auto *RT = getAs<RecordType>())
630 return RT->getDecl()->isStruct();
635 if (
const auto *RT = getAs<RecordType>())
636 return RT->getDecl()->hasAttr<ObjCBoxableAttr>();
641 if (
const auto *RT = getAs<RecordType>())
642 return RT->getDecl()->isInterface();
647 if (
const auto *RT = getAs<RecordType>()) {
655 if (
const auto *PT = getAs<PointerType>())
656 return PT->getPointeeType()->isVoidType();
661 if (
const auto *RT = getAs<RecordType>())
662 return RT->getDecl()->isUnion();
667 if (
const auto *CT = dyn_cast<ComplexType>(CanonicalType))
668 return CT->getElementType()->isFloatingType();
678 if (
const auto *ET = getAs<EnumType>())
679 return ET->getDecl()->isScoped();
684 return getAs<CountAttributedType>();
688 if (
const auto *
Complex = getAs<ComplexType>())
689 if (
Complex->getElementType()->isIntegerType())
695 if (
const auto *PT = getAs<PointerType>())
697 if (
const auto *OPT = getAs<ObjCObjectPointerType>())
699 if (
const auto *BPT = getAs<BlockPointerType>())
701 if (
const auto *RT = getAs<ReferenceType>())
703 if (
const auto *MPT = getAs<MemberPointerType>())
705 if (
const auto *DT = getAs<DecayedType>())
712 if (
const auto *RT = dyn_cast<RecordType>(
this)) {
713 if (RT->getDecl()->isStruct())
718 if (
const auto *RT = dyn_cast<RecordType>(CanonicalType)) {
719 if (!RT->getDecl()->isStruct())
731 if (
const auto *RT = dyn_cast<RecordType>(
this)) {
732 if (RT->getDecl()->isUnion())
737 if (
const auto *RT = dyn_cast<RecordType>(CanonicalType)) {
738 if (!RT->getDecl()->isUnion())
753 const auto *OPT = getAs<ObjCObjectPointerType>();
758 if (OPT->isObjCIdType())
762 if (!OPT->isKindOfType())
766 if (OPT->isObjCClassType() || OPT->isObjCQualifiedClassType())
776 const auto *OPT = getAs<ObjCObjectPointerType>();
781 if (OPT->isObjCClassType())
785 if (!OPT->isKindOfType())
789 return OPT->isObjCClassType() || OPT->isObjCQualifiedClassType();
803 :
Type(ObjCObject, Canonical,
Base->getDependence()), BaseType(
Base) {
808 "bitfield overflow in type argument count");
809 if (!typeArgs.empty())
810 memcpy(getTypeArgStorage(), typeArgs.data(),
811 typeArgs.size() *
sizeof(
QualType));
813 for (
auto typeArg : typeArgs) {
814 addDependence(typeArg->getDependence() & ~TypeDependence::VariablyModified);
827 if (
const auto objcObject =
getBaseType()->getAs<ObjCObjectType>()) {
829 if (isa<ObjCInterfaceType>(objcObject))
832 return objcObject->isSpecialized();
845 if (
const auto objcObject =
getBaseType()->getAs<ObjCObjectType>()) {
847 if (isa<ObjCInterfaceType>(objcObject))
850 return objcObject->getTypeArgs();
862 if (
const auto objcObject =
getBaseType()->getAs<ObjCObjectType>()) {
864 if (isa<ObjCInterfaceType>(objcObject))
867 return objcObject->isKindOfType();
883 baseType = baseObj->stripObjCKindOfTypeAndQuals(ctx);
886 splitBaseType.
Quals),
912template <
typename Derived>
913struct SimpleTransformVisitor :
public TypeVisitor<Derived, QualType> {
921 QualType result =
static_cast<Derived *
>(
this)->Visit(splitType.
Ty);
931 explicit SimpleTransformVisitor(
ASTContext &ctx) : Ctx(ctx) {}
935#define TYPE(Class, Base)
936#define DEPENDENT_TYPE(Class, Base) \
937 QualType Visit##Class##Type(const Class##Type *T) { return QualType(T, 0); }
938#include "clang/AST/TypeNodes.inc"
940#define TRIVIAL_TYPE_CLASS(Class) \
941 QualType Visit##Class##Type(const Class##Type *T) { return QualType(T, 0); }
942#define SUGARED_TYPE_CLASS(Class) \
943 QualType Visit##Class##Type(const Class##Type *T) { \
944 if (!T->isSugared()) \
945 return QualType(T, 0); \
946 QualType desugaredType = recurse(T->desugar()); \
947 if (desugaredType.isNull()) \
949 if (desugaredType.getAsOpaquePtr() == T->desugar().getAsOpaquePtr()) \
950 return QualType(T, 0); \
951 return desugaredType; \
957 QualType elementType = recurse(
T->getElementType());
961 if (elementType.
getAsOpaquePtr() ==
T->getElementType().getAsOpaquePtr())
990 QualType pointeeType = recurse(
T->getPointeeTypeAsWritten());
995 ==
T->getPointeeTypeAsWritten().getAsOpaquePtr())
1002 QualType pointeeType = recurse(
T->getPointeeTypeAsWritten());
1003 if (pointeeType.
isNull())
1007 ==
T->getPointeeTypeAsWritten().getAsOpaquePtr())
1015 if (pointeeType.
isNull())
1025 QualType elementType = recurse(
T->getElementType());
1026 if (elementType.
isNull())
1029 if (elementType.
getAsOpaquePtr() ==
T->getElementType().getAsOpaquePtr())
1033 T->getSizeModifier(),
1034 T->getIndexTypeCVRQualifiers());
1038 QualType elementType = recurse(
T->getElementType());
1039 if (elementType.
isNull())
1042 if (elementType.
getAsOpaquePtr() ==
T->getElementType().getAsOpaquePtr())
1046 T->getSizeModifier(),
1047 T->getIndexTypeCVRQualifiers(),
1048 T->getBracketsRange());
1052 QualType elementType = recurse(
T->getElementType());
1053 if (elementType.
isNull())
1056 if (elementType.
getAsOpaquePtr() ==
T->getElementType().getAsOpaquePtr())
1060 T->getIndexTypeCVRQualifiers());
1064 QualType elementType = recurse(
T->getElementType());
1065 if (elementType.
isNull())
1068 if (elementType.
getAsOpaquePtr() ==
T->getElementType().getAsOpaquePtr())
1072 T->getVectorKind());
1076 QualType elementType = recurse(
T->getElementType());
1077 if (elementType.
isNull())
1080 if (elementType.
getAsOpaquePtr() ==
T->getElementType().getAsOpaquePtr())
1087 QualType elementType = recurse(
T->getElementType());
1088 if (elementType.
isNull())
1090 if (elementType.
getAsOpaquePtr() ==
T->getElementType().getAsOpaquePtr())
1094 T->getNumColumns());
1115 bool paramChanged =
false;
1117 QualType newParamType = recurse(paramType);
1118 if (newParamType.
isNull())
1122 paramChanged =
true;
1124 paramTypes.push_back(newParamType);
1129 bool exceptionChanged =
false;
1133 QualType newExceptionType = recurse(exceptionType);
1134 if (newExceptionType.
isNull())
1137 if (newExceptionType.
getAsOpaquePtr() != exceptionType.getAsOpaquePtr())
1138 exceptionChanged =
true;
1140 exceptionTypes.push_back(newExceptionType);
1143 if (exceptionChanged) {
1150 !paramChanged && !exceptionChanged)
1157 QualType innerType = recurse(
T->getInnerType());
1172 QualType originalType = recurse(
T->getOriginalType());
1173 if (originalType.
isNull())
1176 QualType adjustedType = recurse(
T->getAdjustedType());
1177 if (adjustedType.
isNull())
1181 ==
T->getOriginalType().getAsOpaquePtr() &&
1182 adjustedType.
getAsOpaquePtr() ==
T->getAdjustedType().getAsOpaquePtr())
1189 QualType originalType = recurse(
T->getOriginalType());
1190 if (originalType.
isNull())
1194 ==
T->getOriginalType().getAsOpaquePtr())
1201 QualType ArrTy = VisitConstantArrayType(
T);
1219 QualType modifiedType = recurse(
T->getModifiedType());
1220 if (modifiedType.
isNull())
1223 QualType equivalentType = recurse(
T->getEquivalentType());
1224 if (equivalentType.
isNull())
1228 ==
T->getModifiedType().getAsOpaquePtr() &&
1230 ==
T->getEquivalentType().getAsOpaquePtr())
1238 QualType replacementType = recurse(
T->getReplacementType());
1239 if (replacementType.
isNull())
1243 ==
T->getReplacementType().getAsOpaquePtr())
1247 T->getAssociatedDecl(),
1248 T->getIndex(),
T->getPackIndex());
1255 if (!
T->isDeduced())
1258 QualType deducedType = recurse(
T->getDeducedType());
1259 if (deducedType.
isNull())
1263 ==
T->getDeducedType().getAsOpaquePtr())
1268 T->getTypeConstraintConcept(),
1269 T->getTypeConstraintArguments());
1273 QualType baseType = recurse(
T->getBaseType());
1278 bool typeArgChanged =
false;
1280 for (
auto typeArg :
T->getTypeArgsAsWritten()) {
1281 QualType newTypeArg = recurse(typeArg);
1286 typeArgChanged =
true;
1288 typeArgs.push_back(newTypeArg);
1298 T->isKindOfTypeAsWritten());
1305 if (pointeeType.
isNull())
1316 QualType valueType = recurse(
T->getValueType());
1321 ==
T->getValueType().getAsOpaquePtr())
1327#undef TRIVIAL_TYPE_CLASS
1328#undef SUGARED_TYPE_CLASS
1331struct SubstObjCTypeArgsVisitor
1332 :
public SimpleTransformVisitor<SubstObjCTypeArgsVisitor> {
1333 using BaseType = SimpleTransformVisitor<SubstObjCTypeArgsVisitor>;
1340 : BaseType(ctx), TypeArgs(typeArgs), SubstContext(context) {}
1347 if (!TypeArgs.empty()) {
1358 argType, protocolsToApply, hasError,
true);
1361 switch (SubstContext) {
1362 case ObjCSubstitutionContext::Ordinary:
1363 case ObjCSubstitutionContext::Parameter:
1364 case ObjCSubstitutionContext::Superclass:
1368 case ObjCSubstitutionContext::Result:
1369 case ObjCSubstitutionContext::Property: {
1371 const auto *objPtr =
1376 if (objPtr->isKindOfType() || objPtr->isObjCIdOrClassType())
1380 const auto *obj = objPtr->getObjectType();
1382 obj->getBaseType(), obj->getTypeArgsAsWritten(), obj->getProtocols(),
1389 llvm_unreachable(
"Unexpected ObjCSubstitutionContext!");
1398 Ctx, TypeArgs, ObjCSubstitutionContext::Result);
1404 if (isa<FunctionNoProtoType>(funcType)) {
1408 return BaseType::VisitFunctionType(funcType);
1414 const auto *funcProtoType = cast<FunctionProtoType>(funcType);
1418 bool paramChanged =
false;
1419 for (
auto paramType : funcProtoType->getParamTypes()) {
1421 Ctx, TypeArgs, ObjCSubstitutionContext::Parameter);
1422 if (newParamType.
isNull())
1426 paramChanged =
true;
1428 paramTypes.push_back(newParamType);
1433 bool exceptionChanged =
false;
1438 Ctx, TypeArgs, ObjCSubstitutionContext::Ordinary);
1439 if (newExceptionType.
isNull())
1442 if (newExceptionType.
getAsOpaquePtr() != exceptionType.getAsOpaquePtr())
1443 exceptionChanged =
true;
1445 exceptionTypes.push_back(newExceptionType);
1448 if (exceptionChanged) {
1455 funcProtoType->getReturnType().getAsOpaquePtr() &&
1456 !paramChanged && !exceptionChanged)
1457 return BaseType::VisitFunctionType(funcType);
1467 bool anyChanged =
false;
1470 Ctx, TypeArgs, ObjCSubstitutionContext::Ordinary);
1479 if (TypeArgs.empty() &&
1480 SubstContext != ObjCSubstitutionContext::Superclass) {
1489 newTypeArgs.push_back(newTypeArg);
1501 return BaseType::VisitObjCObjectType(objcObjectType);
1505 QualType newType = BaseType::VisitAttributedType(attrType);
1509 const auto *newAttrType = dyn_cast<AttributedType>(newType.
getTypePtr());
1510 if (!newAttrType || newAttrType->getAttrKind() != attr::ObjCKindOf)
1514 QualType newEquivType = newAttrType->getEquivalentType();
1526 objType->getBaseType(), objType->getTypeArgsAsWritten(),
1527 objType->getProtocols(),
1529 objType->isObjCUnqualifiedId() ?
false :
true);
1537 newAttrType->getModifiedType(), newEquivType);
1541struct StripObjCKindOfTypeVisitor
1542 :
public SimpleTransformVisitor<StripObjCKindOfTypeVisitor> {
1543 using BaseType = SimpleTransformVisitor<StripObjCKindOfTypeVisitor>;
1545 explicit StripObjCKindOfTypeVisitor(
ASTContext &ctx) : BaseType(ctx) {}
1549 return BaseType::VisitObjCObjectType(objType);
1570 case BuiltinType::Kind::Float16: {
1578 case BuiltinType::Kind::BFloat16: {
1598 SubstObjCTypeArgsVisitor visitor(ctx, typeArgs, context);
1599 return visitor.recurse(*
this);
1613 auto &ctx =
const_cast<ASTContext &
>(constCtx);
1614 StripObjCKindOfTypeVisitor visitor(ctx);
1615 return visitor.recurse(*
this);
1619 if (
const auto AT =
getTypePtr()->getAs<AtomicType>())
1620 return AT->getValueType().getUnqualifiedType();
1624std::optional<ArrayRef<QualType>>
1627 if (
const auto method = dyn_cast<ObjCMethodDecl>(dc))
1628 dc = method->getDeclContext();
1632 const auto *dcClassDecl = dyn_cast<ObjCInterfaceDecl>(dc);
1638 dcTypeParams = dcClassDecl->getTypeParamList();
1640 return std::nullopt;
1644 dcCategoryDecl = dyn_cast<ObjCCategoryDecl>(dc);
1645 if (!dcCategoryDecl)
1646 return std::nullopt;
1652 return std::nullopt;
1656 return std::nullopt;
1658 assert(dcTypeParams &&
"No substitutions to perform");
1659 assert(dcClassDecl &&
"No class context");
1663 if (
const auto *objectPointerType = getAs<ObjCObjectPointerType>()) {
1664 objectType = objectPointerType->getObjectType();
1665 }
else if (getAs<BlockPointerType>()) {
1670 objectType = getAs<ObjCObjectType>();
1676 if (!curClassDecl) {
1684 while (curClassDecl != dcClassDecl) {
1687 if (superType.
isNull()) {
1688 objectType =
nullptr;
1708 if (
auto *ID = IfaceT->getInterface()) {
1709 if (ID->getTypeParamList())
1723 CachedSuperClassType.setInt(
true);
1729 if (!superClassObjTy) {
1730 CachedSuperClassType.setInt(
true);
1735 if (!superClassDecl) {
1736 CachedSuperClassType.setInt(
true);
1742 QualType superClassType(superClassObjTy, 0);
1744 if (!superClassTypeParams) {
1745 CachedSuperClassType.setPointerAndInt(
1752 CachedSuperClassType.setPointerAndInt(superClassObjTy,
true);
1760 CachedSuperClassType.setPointerAndInt(
1771 CachedSuperClassType.setPointerAndInt(
1779 assert(typeArgs.size() == typeParams->
size());
1780 CachedSuperClassType.setPointerAndInt(
1789 return interfaceDecl->getASTContext().getObjCInterfaceType(interfaceDecl)
1798 if (superObjectType.
isNull())
1799 return superObjectType;
1809 if (
const auto *
T = getAs<ObjCObjectType>())
1810 if (
T->getNumProtocols() &&
T->getInterface())
1822 if (
const auto *OPT = getAs<ObjCObjectPointerType>()) {
1823 if (OPT->isObjCQualifiedIdType())
1832 if (
const auto *OPT = getAs<ObjCObjectPointerType>()) {
1833 if (OPT->isObjCQualifiedClassType())
1840 if (
const auto *OT = getAs<ObjCObjectType>()) {
1841 if (OT->getInterface())
1848 if (
const auto *OPT = getAs<ObjCObjectPointerType>()) {
1849 if (OPT->getInterfaceType())
1857 if (
const auto *PT = getAs<PointerType>())
1859 else if (
const auto *RT = getAs<ReferenceType>())
1865 return dyn_cast<CXXRecordDecl>(RT->getDecl());
1871 return dyn_cast_or_null<CXXRecordDecl>(
getAsTagDecl());
1879 if (
const auto *TT = getAs<TagType>())
1880 return TT->getDecl();
1881 if (
const auto *Injected = getAs<InjectedClassNameType>())
1882 return Injected->getDecl();
1888 const Type *Cur =
this;
1890 if (AT->getAttrKind() == AK)
1892 Cur = AT->getEquivalentType().getTypePtr();
1899 class GetContainedDeducedTypeVisitor :
1900 public TypeVisitor<GetContainedDeducedTypeVisitor, Type*> {
1904 GetContainedDeducedTypeVisitor(
bool Syntactic =
false)
1905 : Syntactic(Syntactic) {}
1912 return Visit(
T.getTypePtr());
1922 return Visit(
T->getReplacementType());
1926 return Visit(
T->getNamedType());
1938 return Visit(
T->getPointeeTypeAsWritten());
1946 return Visit(
T->getElementType());
1949 Type *VisitDependentSizedExtVectorType(
1951 return Visit(
T->getElementType());
1955 return Visit(
T->getElementType());
1959 return Visit(
T->getElementType());
1963 return Visit(
T->getElementType());
1969 return VisitFunctionType(
T);
1977 return Visit(
T->getInnerType());
1981 return Visit(
T->getModifiedType());
1985 return Visit(
T->getUnderlyingType());
1989 return Visit(
T->getOriginalType());
1993 return Visit(
T->getPattern());
2000 return cast_or_null<DeducedType>(
2001 GetContainedDeducedTypeVisitor().Visit(
this));
2005 return isa_and_nonnull<FunctionType>(
2006 GetContainedDeducedTypeVisitor(
true).Visit(
this));
2010 if (
const auto *VT = dyn_cast<VectorType>(CanonicalType))
2011 return VT->getElementType()->isIntegerType();
2012 if (CanonicalType->isSveVLSBuiltinType()) {
2013 const auto *VT = cast<BuiltinType>(CanonicalType);
2014 return VT->getKind() == BuiltinType::SveBool ||
2015 (VT->getKind() >= BuiltinType::SveInt8 &&
2016 VT->getKind() <= BuiltinType::SveUint64);
2018 if (CanonicalType->isRVVVLSBuiltinType()) {
2019 const auto *VT = cast<BuiltinType>(CanonicalType);
2020 return (VT->getKind() >= BuiltinType::RvvInt8mf8 &&
2021 VT->getKind() <= BuiltinType::RvvUint64m8);
2047 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
2048 return BT->getKind() >= BuiltinType::Bool &&
2049 BT->getKind() <= BuiltinType::Int128;
2053 if (
const auto *ET = dyn_cast<EnumType>(CanonicalType))
2054 return ET->getDecl()->isComplete();
2060 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
2061 return BT->getKind() >= BuiltinType::Bool &&
2062 BT->getKind() <= BuiltinType::Int128;
2071 if (
const auto *ET = dyn_cast<EnumType>(CanonicalType))
2072 return !ET->getDecl()->isScoped();
2078 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
2079 return BT->getKind() == BuiltinType::Char_U ||
2080 BT->getKind() == BuiltinType::UChar ||
2081 BT->getKind() == BuiltinType::Char_S ||
2082 BT->getKind() == BuiltinType::SChar;
2087 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
2088 return BT->getKind() == BuiltinType::WChar_S ||
2089 BT->getKind() == BuiltinType::WChar_U;
2094 if (
const BuiltinType *BT = dyn_cast<BuiltinType>(CanonicalType))
2095 return BT->getKind() == BuiltinType::Char8;
2100 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
2101 return BT->getKind() == BuiltinType::Char16;
2106 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
2107 return BT->getKind() == BuiltinType::Char32;
2114 const auto *BT = dyn_cast<BuiltinType>(CanonicalType);
2115 if (!BT)
return false;
2116 switch (BT->getKind()) {
2117 default:
return false;
2118 case BuiltinType::Char_U:
2119 case BuiltinType::UChar:
2120 case BuiltinType::WChar_U:
2121 case BuiltinType::Char8:
2122 case BuiltinType::Char16:
2123 case BuiltinType::Char32:
2124 case BuiltinType::Char_S:
2125 case BuiltinType::SChar:
2126 case BuiltinType::WChar_S:
2135 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType)) {
2136 return BT->getKind() >= BuiltinType::Char_S &&
2137 BT->getKind() <= BuiltinType::Int128;
2140 if (
const EnumType *ET = dyn_cast<EnumType>(CanonicalType)) {
2143 if (ET->getDecl()->isComplete() && !ET->getDecl()->isScoped())
2147 if (
const auto *IT = dyn_cast<BitIntType>(CanonicalType))
2148 return IT->isSigned();
2149 if (
const auto *IT = dyn_cast<DependentBitIntType>(CanonicalType))
2150 return IT->isSigned();
2156 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType)) {
2157 return BT->getKind() >= BuiltinType::Char_S &&
2158 BT->getKind() <= BuiltinType::Int128;
2161 if (
const auto *ET = dyn_cast<EnumType>(CanonicalType)) {
2162 if (ET->getDecl()->isComplete())
2166 if (
const auto *IT = dyn_cast<BitIntType>(CanonicalType))
2167 return IT->isSigned();
2168 if (
const auto *IT = dyn_cast<DependentBitIntType>(CanonicalType))
2169 return IT->isSigned();
2175 if (
const auto *VT = dyn_cast<VectorType>(CanonicalType))
2176 return VT->getElementType()->isSignedIntegerOrEnumerationType();
2185 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType)) {
2186 return BT->getKind() >= BuiltinType::Bool &&
2187 BT->getKind() <= BuiltinType::UInt128;
2190 if (
const auto *ET = dyn_cast<EnumType>(CanonicalType)) {
2193 if (ET->getDecl()->isComplete() && !ET->getDecl()->isScoped())
2197 if (
const auto *IT = dyn_cast<BitIntType>(CanonicalType))
2198 return IT->isUnsigned();
2199 if (
const auto *IT = dyn_cast<DependentBitIntType>(CanonicalType))
2200 return IT->isUnsigned();
2206 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType)) {
2207 return BT->getKind() >= BuiltinType::Bool &&
2208 BT->getKind() <= BuiltinType::UInt128;
2211 if (
const auto *ET = dyn_cast<EnumType>(CanonicalType)) {
2212 if (ET->getDecl()->isComplete())
2216 if (
const auto *IT = dyn_cast<BitIntType>(CanonicalType))
2217 return IT->isUnsigned();
2218 if (
const auto *IT = dyn_cast<DependentBitIntType>(CanonicalType))
2219 return IT->isUnsigned();
2225 if (
const auto *VT = dyn_cast<VectorType>(CanonicalType))
2226 return VT->getElementType()->isUnsignedIntegerOrEnumerationType();
2227 if (
const auto *VT = dyn_cast<MatrixType>(CanonicalType))
2228 return VT->getElementType()->isUnsignedIntegerOrEnumerationType();
2229 if (CanonicalType->isSveVLSBuiltinType()) {
2230 const auto *VT = cast<BuiltinType>(CanonicalType);
2231 return VT->getKind() >= BuiltinType::SveUint8 &&
2232 VT->getKind() <= BuiltinType::SveUint64;
2238 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
2239 return BT->getKind() >= BuiltinType::Half &&
2240 BT->getKind() <= BuiltinType::Ibm128;
2241 if (
const auto *CT = dyn_cast<ComplexType>(CanonicalType))
2242 return CT->getElementType()->isFloatingType();
2247 if (
const auto *VT = dyn_cast<VectorType>(CanonicalType))
2248 return VT->getElementType()->isFloatingType();
2249 if (
const auto *MT = dyn_cast<MatrixType>(CanonicalType))
2250 return MT->getElementType()->isFloatingType();
2255 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
2256 return BT->isFloatingPoint();
2261 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
2262 return BT->getKind() >= BuiltinType::Bool &&
2263 BT->getKind() <= BuiltinType::Ibm128;
2264 if (
const auto *ET = dyn_cast<EnumType>(CanonicalType))
2265 return ET->getDecl()->isComplete() && !ET->getDecl()->isScoped();
2270 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
2271 return BT->getKind() >= BuiltinType::Bool &&
2272 BT->getKind() <= BuiltinType::Ibm128;
2273 if (
const auto *ET = dyn_cast<EnumType>(CanonicalType))
2280 return !ET->getDecl()->isScoped() && ET->getDecl()->isComplete();
2281 return isa<ComplexType>(CanonicalType) ||
isBitIntType();
2287 const Type *
T = CanonicalType.getTypePtr();
2288 if (
const auto *BT = dyn_cast<BuiltinType>(
T)) {
2289 if (BT->getKind() == BuiltinType::Bool)
return STK_Bool;
2290 if (BT->getKind() == BuiltinType::NullPtr)
return STK_CPointer;
2294 llvm_unreachable(
"unknown scalar builtin type");
2295 }
else if (isa<PointerType>(
T)) {
2297 }
else if (isa<BlockPointerType>(
T)) {
2299 }
else if (isa<ObjCObjectPointerType>(
T)) {
2301 }
else if (isa<MemberPointerType>(
T)) {
2303 }
else if (isa<EnumType>(
T)) {
2304 assert(cast<EnumType>(
T)->getDecl()->isComplete());
2306 }
else if (
const auto *CT = dyn_cast<ComplexType>(
T)) {
2307 if (CT->getElementType()->isRealFloatingType())
2314 llvm_unreachable(
"unknown scalar type");
2327 if (
const auto *
Record = dyn_cast<RecordType>(CanonicalType)) {
2328 if (
const auto *ClassDecl = dyn_cast<CXXRecordDecl>(
Record->getDecl()))
2329 return ClassDecl->isAggregate();
2334 return isa<ArrayType>(CanonicalType);
2341 assert(!
isIncompleteType() &&
"This doesn't make sense for incomplete types");
2342 assert(!
isDependentType() &&
"This doesn't make sense for dependent types");
2344 return !isa<VariableArrayType>(CanonicalType);
2354 switch (CanonicalType->getTypeClass()) {
2355 default:
return false;
2361 EnumDecl *EnumD = cast<EnumType>(CanonicalType)->getDecl();
2369 RecordDecl *Rec = cast<RecordType>(CanonicalType)->getDecl();
2380 return cast<ArrayType>(CanonicalType)->getElementType()
2381 ->isIncompleteType(Def);
2382 case IncompleteArray:
2385 case MemberPointer: {
2389 auto *MPTy = cast<MemberPointerType>(CanonicalType);
2390 const Type *ClassTy = MPTy->getClass();
2403 if (RD->
hasAttr<MSInheritanceAttr>())
2408 return cast<ObjCObjectType>(CanonicalType)->getBaseType()
2409 ->isIncompleteType(Def);
2410 case ObjCInterface: {
2413 = cast<ObjCInterfaceType>(CanonicalType)->getDecl();
2425 if (
const BuiltinType *BT = getAs<BuiltinType>()) {
2426 switch (BT->getKind()) {
2428#define WASM_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
2429#include "clang/Basic/WebAssemblyReferenceTypes.def"
2439 if (
const auto *BT = getAs<BuiltinType>())
2440 return BT->getKind() == BuiltinType::WasmExternRef;
2445 if (
const auto *ATy = dyn_cast<ArrayType>(
this))
2446 return ATy->getElementType().isWebAssemblyReferenceType();
2448 if (
const auto *PTy = dyn_cast<PointerType>(
this))
2449 return PTy->getPointeeType().isWebAssemblyReferenceType();
2461 if (
const BuiltinType *BT = getAs<BuiltinType>()) {
2462 switch (BT->getKind()) {
2464#define SVE_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
2465#include "clang/Basic/AArch64SVEACLETypes.def"
2475 if (
const BuiltinType *BT = getAs<BuiltinType>()) {
2476 switch (BT->getKind()) {
2477#define RVV_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
2478#include "clang/Basic/RISCVVTypes.def"
2488 if (
const BuiltinType *BT = getAs<BuiltinType>()) {
2489 switch (BT->getKind()) {
2490 case BuiltinType::SveInt8:
2491 case BuiltinType::SveInt16:
2492 case BuiltinType::SveInt32:
2493 case BuiltinType::SveInt64:
2494 case BuiltinType::SveUint8:
2495 case BuiltinType::SveUint16:
2496 case BuiltinType::SveUint32:
2497 case BuiltinType::SveUint64:
2498 case BuiltinType::SveFloat16:
2499 case BuiltinType::SveFloat32:
2500 case BuiltinType::SveFloat64:
2501 case BuiltinType::SveBFloat16:
2502 case BuiltinType::SveBool:
2503 case BuiltinType::SveBoolx2:
2504 case BuiltinType::SveBoolx4:
2517 if (BTy->
getKind() == BuiltinType::SveBool)
2527 if (
const BuiltinType *BT = getAs<BuiltinType>()) {
2528 switch (BT->getKind()) {
2529#define RVV_VECTOR_TYPE(Name, Id, SingletonId, NumEls, ElBits, NF, IsSigned, \
2531 case BuiltinType::Id: \
2533#define RVV_PREDICATE_TYPE(Name, Id, SingletonId, NumEls) \
2534 case BuiltinType::Id: \
2536#include "clang/Basic/RISCVVTypes.def"
2550#define RVV_PREDICATE_TYPE(Name, Id, SingletonId, NumEls) \
2551 case BuiltinType::Id: \
2552 return Ctx.UnsignedCharTy;
2555#include "clang/Basic/RISCVVTypes.def"
2558 llvm_unreachable(
"Unhandled type");
2576 if ((*this)->isIncompleteArrayType())
2579 if ((*this)->isIncompleteType())
2588 default:
return false;
2589 case Type::VariableArray:
2590 case Type::ConstantArray:
2594 case Type::ObjCObjectPointer:
2595 case Type::BlockPointer:
2599 case Type::MemberPointer:
2601 case Type::ExtVector:
2609 if (
const auto *ClassDecl =
2610 dyn_cast<CXXRecordDecl>(cast<RecordType>(CanonicalType)->getDecl()))
2611 return ClassDecl->isPOD();
2625 if ((*this)->isArrayType())
2628 if ((*this)->isSizelessBuiltinType())
2633 if ((*this)->isIncompleteType())
2652 if (
const auto *ClassDecl = dyn_cast<CXXRecordDecl>(RT->getDecl())) {
2659 return ClassDecl->hasTrivialDefaultConstructor() &&
2660 !ClassDecl->hasNonTrivialDefaultConstructor() &&
2661 ClassDecl->isTriviallyCopyable();
2673 bool IsCopyConstructible) {
2674 if (
type->isArrayType())
2676 Context, IsCopyConstructible);
2678 if (
type.hasNonTrivialObjCLifetime())
2703 if (
const auto *ClassDecl = dyn_cast<CXXRecordDecl>(RT->getDecl())) {
2704 if (IsCopyConstructible) {
2705 return ClassDecl->isTriviallyCopyConstructible();
2707 return ClassDecl->isTriviallyCopyable();
2735 return RD->canPassInRegisters();
2752 if (
Decl->isUnion())
2754 if (
Decl->isLambda())
2755 return Decl->isCapturelessLambda();
2758 return Function->getOverloadedOperator() ==
2759 OverloadedOperatorKind::OO_EqualEqual &&
2761 (
Function->getParamDecl(0)->getType()->isReferenceType() ||
2762 Decl->isTriviallyCopyable());
2765 if (llvm::none_of(
Decl->methods(), IsDefaultedOperatorEqualEqual) &&
2767 if (
NamedDecl *ND = Friend->getFriendDecl()) {
2769 IsDefaultedOperatorEqualEqual(ND->getAsFunction());
2775 return llvm::all_of(
Decl->bases(),
2777 if (const auto *RD = BS.getType()->getAsCXXRecordDecl())
2778 return HasNonDeletedDefaultedEqualityComparison(RD);
2782 auto Type = FD->getType();
2783 if (Type->isArrayType())
2784 Type = Type->getBaseElementTypeUnsafe()->getCanonicalTypeUnqualified();
2786 if (Type->isReferenceType() || Type->isEnumeralType())
2788 if (const auto *RD = Type->getAsCXXRecordDecl())
2789 return HasNonDeletedDefaultedEqualityComparison(RD);
2807 CanonicalType,
false);
2843 if (
const auto *RT =
2844 getTypePtr()->getBaseElementTypeUnsafe()->getAs<RecordType>())
2845 if (RT->getDecl()->isNonTrivialToPrimitiveDefaultInitialize())
2859 if (
const auto *RT =
2860 getTypePtr()->getBaseElementTypeUnsafe()->getAs<RecordType>())
2861 if (RT->getDecl()->isNonTrivialToPrimitiveCopy())
2897 assert(BaseTy &&
"NULL element type");
2927 if (
const auto *ClassDecl = dyn_cast<CXXRecordDecl>(RT->getDecl()))
2928 return ClassDecl->isLiteral();
2935 return AT->getValueType()->isLiteralType(Ctx);
2957 return RD->isStructural();
2970 assert(BaseTy &&
"NULL element type");
2980 if (
const auto *ClassDecl = dyn_cast<CXXRecordDecl>(RT->getDecl()))
2981 if (!ClassDecl->isStandardLayout())
3009 assert(BaseTy &&
"NULL element type");
3022 if (
const auto *ClassDecl = dyn_cast<CXXRecordDecl>(RT->getDecl())) {
3025 if (!ClassDecl->isTrivial())
return false;
3030 if (!ClassDecl->isStandardLayout())
return false;
3059 if (
const auto *ET = getAs<EnumType>()) {
3061 if (II && II->
isStr(
"align_val_t") && ET->getDecl()->isInStdNamespace())
3068 if (
const auto *ET = getAs<EnumType>()) {
3070 if (II && II->
isStr(
"byte") && ET->getDecl()->isInStdNamespace())
3086 case TemplateTypeParm:
3087 case SubstTemplateTypeParm:
3088 case TemplateSpecialization:
3091 case DependentTemplateSpecialization:
3135 llvm_unreachable(
"Type specifier is not a tag type kind.");
3152 llvm_unreachable(
"Unknown tag type kind.");
3170 llvm_unreachable(
"Elaborated type keyword is not a tag type kind.");
3172 llvm_unreachable(
"Unknown elaborated type keyword.");
3188 llvm_unreachable(
"Unknown elaborated type keyword.");
3202 return "__interface";
3209 llvm_unreachable(
"Unknown elaborated type keyword.");
3212DependentTemplateSpecializationType::DependentTemplateSpecializationType(
3219 NNS(NNS), Name(Name) {
3222 "DependentTemplateSpecializatonType requires dependent qualifier");
3223 auto *ArgBuffer =
const_cast<TemplateArgument *
>(template_arguments().data());
3226 TemplateArgumentDependence::UnexpandedPack));
3239 ID.AddInteger(llvm::to_underlying(Keyword));
3240 ID.AddPointer(Qualifier);
3241 ID.AddPointer(Name);
3243 Arg.Profile(ID, Context);
3248 if (
const auto *Elab = dyn_cast<ElaboratedType>(
this))
3249 Keyword = Elab->getKeyword();
3250 else if (
const auto *DepName = dyn_cast<DependentNameType>(
this))
3251 Keyword = DepName->getKeyword();
3252 else if (
const auto *DepTST =
3253 dyn_cast<DependentTemplateSpecializationType>(
this))
3254 Keyword = DepTST->getKeyword();
3263#define ABSTRACT_TYPE(Derived, Base)
3264#define TYPE(Derived, Base) case Derived: return #Derived;
3265#include "clang/AST/TypeNodes.inc"
3268 llvm_unreachable(
"Invalid type class.");
3276 return Policy.
Bool ?
"bool" :
"_Bool";
3282 return "signed char";
3294 return "unsigned char";
3296 return "unsigned short";
3298 return "unsigned int";
3300 return "unsigned long";
3302 return "unsigned long long";
3304 return "unsigned __int128";
3306 return Policy.
Half ?
"half" :
"__fp16";
3314 return "long double";
3316 return "short _Accum";
3320 return "long _Accum";
3322 return "unsigned short _Accum";
3324 return "unsigned _Accum";
3326 return "unsigned long _Accum";
3327 case BuiltinType::ShortFract:
3328 return "short _Fract";
3329 case BuiltinType::Fract:
3331 case BuiltinType::LongFract:
3332 return "long _Fract";
3333 case BuiltinType::UShortFract:
3334 return "unsigned short _Fract";
3335 case BuiltinType::UFract:
3336 return "unsigned _Fract";
3337 case BuiltinType::ULongFract:
3338 return "unsigned long _Fract";
3339 case BuiltinType::SatShortAccum:
3340 return "_Sat short _Accum";
3341 case BuiltinType::SatAccum:
3342 return "_Sat _Accum";
3343 case BuiltinType::SatLongAccum:
3344 return "_Sat long _Accum";
3345 case BuiltinType::SatUShortAccum:
3346 return "_Sat unsigned short _Accum";
3347 case BuiltinType::SatUAccum:
3348 return "_Sat unsigned _Accum";
3349 case BuiltinType::SatULongAccum:
3350 return "_Sat unsigned long _Accum";
3351 case BuiltinType::SatShortFract:
3352 return "_Sat short _Fract";
3353 case BuiltinType::SatFract:
3354 return "_Sat _Fract";
3355 case BuiltinType::SatLongFract:
3356 return "_Sat long _Fract";
3357 case BuiltinType::SatUShortFract:
3358 return "_Sat unsigned short _Fract";
3359 case BuiltinType::SatUFract:
3360 return "_Sat unsigned _Fract";
3361 case BuiltinType::SatULongFract:
3362 return "_Sat unsigned long _Fract";
3366 return "__float128";
3371 return Policy.
MSWChar ?
"__wchar_t" :
"wchar_t";
3381 return "<overloaded function type>";
3383 return "<bound member function type>";
3385 return "<pseudo-object type>";
3387 return "<dependent type>";
3389 return "<unknown type>";
3390 case ARCUnbridgedCast:
3391 return "<ARC unbridged cast type>";
3393 return "<builtin fn type>";
3400#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
3402 return "__" #Access " " #ImgType "_t";
3403#include "clang/Basic/OpenCLImageTypes.def"
3409 return "clk_event_t";
3413 return "reserve_id_t";
3414 case IncompleteMatrixIdx:
3415 return "<incomplete matrix index type>";
3417 return "<array section type>";
3418 case OMPArrayShaping:
3419 return "<OpenMP array shaping type>";
3421 return "<OpenMP iterator type>";
3422#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \
3425#include "clang/Basic/OpenCLExtensionTypes.def"
3426#define SVE_TYPE(Name, Id, SingletonId) \
3429#include "clang/Basic/AArch64SVEACLETypes.def"
3430#define PPC_VECTOR_TYPE(Name, Id, Size) \
3433#include "clang/Basic/PPCTypes.def"
3434#define RVV_TYPE(Name, Id, SingletonId) \
3437#include "clang/Basic/RISCVVTypes.def"
3438#define WASM_TYPE(Name, Id, SingletonId) \
3441#include "clang/Basic/WebAssemblyReferenceTypes.def"
3444 llvm_unreachable(
"Invalid builtin type.");
3449 if (
auto *PET = dyn_cast<PackExpansionType>(
getTypePtr()))
3450 return PET->getPattern();
3455 if (
const auto *RefType =
getTypePtr()->getAs<ReferenceType>())
3472 case CC_C:
return "cdecl";
3500 llvm_unreachable(
"Invalid calling convention.");
3518 assert(
getNumParams() == params.size() &&
"NumParams overflow!");
3526 auto &ExtraBits = *getTrailingObjects<FunctionTypeExtraBitfields>();
3533 auto &ArmTypeAttrs = *getTrailingObjects<FunctionTypeArmAttributes>();
3534 ArmTypeAttrs = FunctionTypeArmAttributes();
3537 auto &ExtraBits = *getTrailingObjects<FunctionTypeExtraBitfields>();
3538 ExtraBits.HasArmTypeAttributes =
true;
3542 auto *argSlot = getTrailingObjects<QualType>();
3545 ~TypeDependence::VariablyModified);
3546 argSlot[i] = params[i];
3551 auto &ArmTypeAttrs = *getTrailingObjects<FunctionTypeArmAttributes>();
3553 "Not enough bits to encode SME attributes");
3559 auto &ExtraBits = *getTrailingObjects<FunctionTypeExtraBitfields>();
3561 assert(NumExceptions <= 1023 &&
"Not enough bits to encode exceptions");
3562 ExtraBits.NumExceptionType = NumExceptions;
3564 assert(hasExtraBitfields() &&
"missing trailing extra bitfields!");
3566 reinterpret_cast<QualType *
>(getTrailingObjects<ExceptionType>());
3574 (TypeDependence::Instantiation | TypeDependence::UnexpandedPack));
3576 exnSlot[I++] = ExceptionType;
3590 (TypeDependence::Instantiation | TypeDependence::UnexpandedPack));
3596 auto **slot = getTrailingObjects<FunctionDecl *>();
3604 auto **slot = getTrailingObjects<FunctionDecl *>();
3623 auto *extParamInfos = getTrailingObjects<ExtParameterInfo>();
3630 *getTrailingObjects<Qualifiers>() = epi.
TypeQuals;
3637 auto &EllipsisLoc = *getTrailingObjects<SourceLocation>();
3644 return NE->isValueDependent();
3656 return NE->isInstantiationDependent();
3667 llvm_unreachable(
"should not call this with unresolved exception specs");
3693 llvm_unreachable(
"unexpected exception specification kind");
3697 for (
unsigned ArgIdx =
getNumParams(); ArgIdx; --ArgIdx)
3705 const QualType *ArgTys,
unsigned NumParams,
3706 const ExtProtoInfo &epi,
3728 ID.AddPointer(
Result.getAsOpaquePtr());
3729 for (
unsigned i = 0; i != NumParams; ++i)
3730 ID.AddPointer(ArgTys[i].getAsOpaquePtr());
3734 assert(!(
unsigned(epi.Variadic) & ~1) &&
3735 !(
unsigned(epi.RefQualifier) & ~3) &&
3736 !(
unsigned(epi.ExceptionSpec.Type) & ~15) &&
3737 "Values larger than expected.");
3738 ID.AddInteger(
unsigned(epi.Variadic) +
3739 (epi.RefQualifier << 1) +
3740 (epi.ExceptionSpec.Type << 3));
3741 ID.Add(epi.TypeQuals);
3743 for (
QualType Ex : epi.ExceptionSpec.Exceptions)
3746 epi.ExceptionSpec.NoexceptExpr->Profile(ID, Context, Canonical);
3749 ID.AddPointer(epi.ExceptionSpec.SourceDecl->getCanonicalDecl());
3751 if (epi.ExtParameterInfos) {
3752 for (
unsigned i = 0; i != NumParams; ++i)
3753 ID.AddInteger(epi.ExtParameterInfos[i].getOpaqueValue());
3756 epi.ExtInfo.Profile(ID);
3757 ID.AddInteger((epi.AArch64SMEAttributes << 1) | epi.HasTrailingReturn);
3767 :
Data(D, Deref << DerefShift) {}
3770 return Data.getInt() & DerefMask;
3775 return Data.getOpaqueValue();
3782 Data.setFromOpaqueValue(
V);
3787 :
Type(TC, Canon, Wrapped->getDependence()), WrappedTy(Wrapped) {}
3789CountAttributedType::CountAttributedType(
3793 CountExpr(CountExpr) {
3797 auto *DeclSlot = getTrailingObjects<TypeCoupledDeclRefInfo>();
3799 for (
unsigned i = 0; i != CoupledDecls.size(); ++i)
3800 DeclSlot[i] = CoupledDecls[i];
3807 assert(!isa<TypedefType>(can) &&
"Invalid canonical type");
3809 if (!typeMatchesDecl())
3810 *getTrailingObjects<QualType>() = Underlying;
3815 : *getTrailingObjects<QualType>();
3824 *getTrailingObjects<QualType>() = Underlying;
3830 cast<TypeDecl>(Found->
getTargetDecl())->getTypeForDecl(), 0)
3831 : *getTrailingObjects<QualType>();
3840 while (
auto *InnerMQT = dyn_cast<MacroQualifiedType>(Inner)) {
3843 Inner = InnerMQT->getModifiedType();
3853 ? Can.getAtomicUnqualifiedType()
3856 (E->getType()->getDependence() &
3877 E->
Profile(ID, Context,
true);
3878 ID.AddBoolean(IsUnqual);
3885 :
Type(Decltype, can,
3889 (E->getType()->getDependence() &
3891 E(E), UnderlyingType(underlyingType) {}
3907 E->
Profile(ID, Context,
true);
3914 :
Type(PackIndexing, Canonical,
3916 Context(Context), Pattern(Pattern), IndexExpr(IndexExpr),
3917 Size(Expansions.size()) {
3919 std::uninitialized_copy(Expansions.begin(), Expansions.end(),
3920 getTrailingObjects<QualType>());
3925 return std::nullopt;
3929 return std::nullopt;
3931 assert(Index.isNonNegative() &&
"Invalid index");
3932 return static_cast<unsigned>(Index.getExtValue());
3936PackIndexingType::computeDependence(
QualType Pattern,
Expr *IndexExpr,
3941 ? TypeDependence::DependentInstantiation
3942 : TypeDependence::None);
3943 if (Expansions.empty())
3944 TD |= Pattern->
getDependence() & TypeDependence::DependentInstantiation;
3949 if (!(IndexD & TypeDependence::UnexpandedPack))
3950 TD &= ~TypeDependence::UnexpandedPack;
3955 TD |= TypeDependence::Error | TypeDependence::DependentInstantiation;
3964 E->
Profile(ID, Context,
true);
3970 :
Type(UnaryTransform, CanonicalType, BaseType->getDependence()),
3971 BaseType(BaseType), UnderlyingType(UnderlyingType), UKind(UKind) {}
3985 for (
auto *I :
decl->redecls()) {
3986 if (I->isCompleteDefinition() || I->isBeingDefined())
4002 std::vector<const RecordType*> RecordTypeList;
4003 RecordTypeList.push_back(
this);
4004 unsigned NextToCheckIndex = 0;
4006 while (RecordTypeList.size() > NextToCheckIndex) {
4008 RecordTypeList[NextToCheckIndex]->
getDecl()->fields()) {
4014 if (!llvm::is_contained(RecordTypeList, FieldRecTy))
4015 RecordTypeList.push_back(FieldRecTy);
4030 case attr::ObjCOwnership:
4031 case attr::ObjCInertUnsafeUnretained:
4032 case attr::TypeNonNull:
4033 case attr::TypeNullable:
4034 case attr::TypeNullableResult:
4035 case attr::TypeNullUnspecified:
4036 case attr::LifetimeBound:
4037 case attr::AddressSpace:
4050 default:
return false;
4057 llvm_unreachable(
"invalid attr kind");
4067 default:
return false;
4070 case attr::FastCall:
4072 case attr::ThisCall:
4074 case attr::SwiftCall:
4075 case attr::SwiftAsyncCall:
4076 case attr::VectorCall:
4077 case attr::AArch64VectorPcs:
4078 case attr::AArch64SVEPcs:
4079 case attr::AMDGPUKernelCall:
4083 case attr::IntelOclBicc:
4084 case attr::PreserveMost:
4085 case attr::PreserveAll:
4087 case attr::PreserveNone:
4088 case attr::RISCVVectorCC:
4091 llvm_unreachable(
"invalid attr kind");
4104 if (
const auto *TTP = dyn_cast<TemplateTypeParmDecl>(D))
4106 return cast<TemplateTypeParmDecl>(
4110SubstTemplateTypeParmType::SubstTemplateTypeParmType(
4111 QualType Replacement,
Decl *AssociatedDecl,
unsigned Index,
4112 std::optional<unsigned> PackIndex)
4113 :
Type(SubstTemplateTypeParm, Replacement.getCanonicalType(),
4114 Replacement->getDependence()),
4115 AssociatedDecl(AssociatedDecl) {
4116 SubstTemplateTypeParmTypeBits.HasNonCanonicalUnderlyingType =
4117 Replacement != getCanonicalTypeInternal();
4118 if (SubstTemplateTypeParmTypeBits.HasNonCanonicalUnderlyingType)
4119 *getTrailingObjects<QualType>() = Replacement;
4121 SubstTemplateTypeParmTypeBits.Index = Index;
4122 SubstTemplateTypeParmTypeBits.PackIndex = PackIndex ? *PackIndex + 1 : 0;
4123 assert(AssociatedDecl !=
nullptr);
4131SubstTemplateTypeParmPackType::SubstTemplateTypeParmPackType(
4132 QualType Canon,
Decl *AssociatedDecl,
unsigned Index,
bool Final,
4134 :
Type(SubstTemplateTypeParmPack, Canon,
4137 Arguments(ArgPack.pack_begin()),
4138 AssociatedDeclAndFinal(AssociatedDecl, Final) {
4141 assert(AssociatedDecl !=
nullptr);
4145 return AssociatedDeclAndFinal.getPointer();
4149 return AssociatedDeclAndFinal.getInt();
4170 const Decl *AssociatedDecl,
4171 unsigned Index,
bool Final,
4173 ID.AddPointer(AssociatedDecl);
4174 ID.AddInteger(Index);
4175 ID.AddBoolean(Final);
4178 ID.AddPointer(
P.getAsType().getAsOpaquePtr());
4189 if (Arg.isDependent())
4197 if (ArgLoc.getArgument().isInstantiationDependent())
4203TemplateSpecializationType::TemplateSpecializationType(
4206 :
Type(TemplateSpecialization, Canon.isNull() ?
QualType(this, 0) : Canon,
4216 assert(!
T.getAsDependentTemplateName() &&
4217 "Use DependentTemplateSpecializationType for dependent template-name");
4222 "Unexpected template name for TemplateSpecializationType");
4235 ~TypeDependence::Dependent);
4238 TypeDependence::VariablyModified);
4245 *
reinterpret_cast<QualType *
>(
Begin + Args.size()) = AliasedType;
4250 assert(
isTypeAlias() &&
"not a type alias template specialization");
4268 Arg.Profile(ID, Context);
4293 ID.AddInteger(typeArgs.size());
4294 for (
auto typeArg : typeArgs)
4295 ID.AddPointer(typeArg.getAsOpaquePtr());
4296 ID.AddInteger(protocols.size());
4297 for (
auto *proto : protocols)
4298 ID.AddPointer(proto);
4299 ID.AddBoolean(isKindOf);
4312 ID.AddPointer(OTPDecl);
4314 ID.AddInteger(protocols.size());
4315 for (
auto *proto : protocols)
4316 ID.AddPointer(proto);
4327class CachedProperties {
4332 CachedProperties(
Linkage L,
bool local) : L(L), local(local) {}
4334 Linkage getLinkage()
const {
return L; }
4335 bool hasLocalOrUnnamedType()
const {
return local; }
4337 friend CachedProperties merge(CachedProperties L, CachedProperties R) {
4339 return CachedProperties(MergedLinkage, L.hasLocalOrUnnamedType() ||
4340 R.hasLocalOrUnnamedType());
4356 return get(
T.getTypePtr());
4361 return CachedProperties(
T->
TypeBits.getLinkage(),
4403#define TYPE(Class,Base)
4404#define NON_CANONICAL_TYPE(Class,Base) case Type::Class:
4405#include "clang/AST/TypeNodes.inc"
4406 llvm_unreachable(
"didn't expect a non-canonical type here");
4408#define TYPE(Class,Base)
4409#define DEPENDENT_TYPE(Class,Base) case Type::Class:
4410#define NON_CANONICAL_UNLESS_DEPENDENT_TYPE(Class,Base) case Type::Class:
4411#include "clang/AST/TypeNodes.inc"
4418 case Type::DeducedTemplateSpecialization:
4432 const TagDecl *Tag = cast<TagType>(
T)->getDecl();
4439 bool IsLocalOrUnnamed =
4442 return CachedProperties(L, IsLocalOrUnnamed);
4449 return Cache::get(cast<ComplexType>(
T)->getElementType());
4451 return Cache::get(cast<PointerType>(
T)->getPointeeType());
4452 case Type::BlockPointer:
4453 return Cache::get(cast<BlockPointerType>(
T)->getPointeeType());
4454 case Type::LValueReference:
4455 case Type::RValueReference:
4456 return Cache::get(cast<ReferenceType>(
T)->getPointeeType());
4457 case Type::MemberPointer: {
4458 const auto *MPT = cast<MemberPointerType>(
T);
4462 case Type::ConstantArray:
4463 case Type::IncompleteArray:
4464 case Type::VariableArray:
4465 case Type::ArrayParameter:
4466 return Cache::get(cast<ArrayType>(
T)->getElementType());
4468 case Type::ExtVector:
4469 return Cache::get(cast<VectorType>(
T)->getElementType());
4470 case Type::ConstantMatrix:
4471 return Cache::get(cast<ConstantMatrixType>(
T)->getElementType());
4472 case Type::FunctionNoProto:
4473 return Cache::get(cast<FunctionType>(
T)->getReturnType());
4474 case Type::FunctionProto: {
4475 const auto *FPT = cast<FunctionProtoType>(
T);
4476 CachedProperties result =
Cache::get(FPT->getReturnType());
4477 for (
const auto &ai : FPT->param_types())
4481 case Type::ObjCInterface: {
4482 Linkage L = cast<ObjCInterfaceType>(
T)->getDecl()->getLinkageInternal();
4483 return CachedProperties(L,
false);
4485 case Type::ObjCObject:
4486 return Cache::get(cast<ObjCObjectType>(
T)->getBaseType());
4487 case Type::ObjCObjectPointer:
4488 return Cache::get(cast<ObjCObjectPointerType>(
T)->getPointeeType());
4490 return Cache::get(cast<AtomicType>(
T)->getValueType());
4492 return Cache::get(cast<PipeType>(
T)->getElementType());
4495 llvm_unreachable(
"unhandled type class");
4506 return TypeBits.hasLocalOrUnnamedType();
4511#define TYPE(Class,Base)
4512#define NON_CANONICAL_TYPE(Class,Base) case Type::Class:
4513#include "clang/AST/TypeNodes.inc"
4514 llvm_unreachable(
"didn't expect a non-canonical type here");
4516#define TYPE(Class,Base)
4517#define DEPENDENT_TYPE(Class,Base) case Type::Class:
4518#define NON_CANONICAL_UNLESS_DEPENDENT_TYPE(Class,Base) case Type::Class:
4519#include "clang/AST/TypeNodes.inc"
4529 case Type::DeducedTemplateSpecialization:
4540 case Type::BlockPointer:
4542 case Type::LValueReference:
4543 case Type::RValueReference:
4545 case Type::MemberPointer: {
4546 const auto *MPT = cast<MemberPointerType>(
T);
4551 case Type::ConstantArray:
4552 case Type::IncompleteArray:
4553 case Type::VariableArray:
4554 case Type::ArrayParameter:
4557 case Type::ExtVector:
4559 case Type::ConstantMatrix:
4561 cast<ConstantMatrixType>(
T)->getElementType());
4562 case Type::FunctionNoProto:
4564 case Type::FunctionProto: {
4565 const auto *FPT = cast<FunctionProtoType>(
T);
4567 for (
const auto &ai : FPT->param_types())
4571 case Type::ObjCInterface:
4573 case Type::ObjCObject:
4575 case Type::ObjCObjectPointer:
4577 cast<ObjCObjectPointerType>(
T)->getPointeeType());
4584 llvm_unreachable(
"unhandled type class");
4615 if (
auto Nullability = AT->getImmediateNullability())
4618 Type = AT->getEquivalentType();
4620 return std::nullopt;
4626 switch (
type->getTypeClass()) {
4628#define NON_CANONICAL_TYPE(Class, Parent) \
4630 llvm_unreachable("non-canonical type");
4631#define TYPE(Class, Parent)
4632#include "clang/AST/TypeNodes.inc"
4636 case Type::BlockPointer:
4637 case Type::MemberPointer:
4638 case Type::ObjCObjectPointer:
4642 case Type::UnresolvedUsing:
4643 case Type::TypeOfExpr:
4645 case Type::Decltype:
4646 case Type::PackIndexing:
4647 case Type::UnaryTransform:
4648 case Type::TemplateTypeParm:
4649 case Type::SubstTemplateTypeParmPack:
4650 case Type::DependentName:
4651 case Type::DependentTemplateSpecialization:
4653 return ResultIfUnknown;
4656 case Type::TemplateSpecialization:
4659 cast<TemplateSpecializationType>(
type.getTypePtr())
4661 .getAsTemplateDecl())
4662 if (
auto *CTD = dyn_cast<ClassTemplateDecl>(templateDecl))
4663 return CTD->getTemplatedDecl()->hasAttr<TypeNullableAttr>();
4664 return ResultIfUnknown;
4667 switch (cast<BuiltinType>(
type.getTypePtr())->getKind()) {
4669#define SIGNED_TYPE(Id, SingletonId) case BuiltinType::Id:
4670#define UNSIGNED_TYPE(Id, SingletonId) case BuiltinType::Id:
4671#define FLOATING_TYPE(Id, SingletonId) case BuiltinType::Id:
4672#define BUILTIN_TYPE(Id, SingletonId)
4673#include "clang/AST/BuiltinTypes.def"
4677 case BuiltinType::Dependent:
4678 case BuiltinType::Overload:
4679 case BuiltinType::BoundMember:
4680 case BuiltinType::PseudoObject:
4681 case BuiltinType::UnknownAny:
4682 case BuiltinType::ARCUnbridgedCast:
4683 return ResultIfUnknown;
4685 case BuiltinType::Void:
4686 case BuiltinType::ObjCId:
4687 case BuiltinType::ObjCClass:
4688 case BuiltinType::ObjCSel:
4689#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
4690 case BuiltinType::Id:
4691#include "clang/Basic/OpenCLImageTypes.def"
4692#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \
4693 case BuiltinType::Id:
4694#include "clang/Basic/OpenCLExtensionTypes.def"
4695 case BuiltinType::OCLSampler:
4696 case BuiltinType::OCLEvent:
4697 case BuiltinType::OCLClkEvent:
4698 case BuiltinType::OCLQueue:
4699 case BuiltinType::OCLReserveID:
4700#define SVE_TYPE(Name, Id, SingletonId) \
4701 case BuiltinType::Id:
4702#include "clang/Basic/AArch64SVEACLETypes.def"
4703#define PPC_VECTOR_TYPE(Name, Id, Size) \
4704 case BuiltinType::Id:
4705#include "clang/Basic/PPCTypes.def"
4706#define RVV_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
4707#include "clang/Basic/RISCVVTypes.def"
4708#define WASM_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
4709#include "clang/Basic/WebAssemblyReferenceTypes.def"
4710 case BuiltinType::BuiltinFn:
4711 case BuiltinType::NullPtr:
4712 case BuiltinType::IncompleteMatrixIdx:
4713 case BuiltinType::ArraySection:
4714 case BuiltinType::OMPArrayShaping:
4715 case BuiltinType::OMPIterator:
4718 llvm_unreachable(
"unknown builtin type");
4720 case Type::Record: {
4724 if (
const auto *CTSD = dyn_cast<ClassTemplateSpecializationDecl>(RD))
4725 return CTSD->getSpecializedTemplate()
4726 ->getTemplatedDecl()
4727 ->
hasAttr<TypeNullableAttr>();
4728 return RD->
hasAttr<TypeNullableAttr>();
4733 case Type::LValueReference:
4734 case Type::RValueReference:
4735 case Type::ConstantArray:
4736 case Type::IncompleteArray:
4737 case Type::VariableArray:
4738 case Type::DependentSizedArray:
4739 case Type::DependentVector:
4740 case Type::DependentSizedExtVector:
4742 case Type::ExtVector:
4743 case Type::ConstantMatrix:
4744 case Type::DependentSizedMatrix:
4745 case Type::DependentAddressSpace:
4746 case Type::FunctionProto:
4747 case Type::FunctionNoProto:
4748 case Type::DeducedTemplateSpecialization:
4750 case Type::InjectedClassName:
4751 case Type::PackExpansion:
4752 case Type::ObjCObject:
4753 case Type::ObjCInterface:
4757 case Type::DependentBitInt:
4758 case Type::ArrayParameter:
4761 llvm_unreachable(
"bad type kind!");
4773 return std::nullopt;
4776std::optional<NullabilityKind>
4779 if (
auto MacroTy = dyn_cast<MacroQualifiedType>(
T))
4780 AttrTy = MacroTy->getUnderlyingType();
4782 if (
auto attributed = dyn_cast<AttributedType>(AttrTy)) {
4783 if (
auto nullability = attributed->getImmediateNullability()) {
4784 T = attributed->getModifiedType();
4789 return std::nullopt;
4793 const auto *objcPtr = getAs<ObjCObjectPointerType>();
4797 if (objcPtr->isObjCIdType()) {
4808 }
else if (objcPtr->isObjCQualifiedIdType()) {
4833 "cannot query implicit lifetime for non-inferrable type");
4838 while (
const auto *array = dyn_cast<ArrayType>(canon))
4839 canon = array->getElementType().getTypePtr();
4841 if (
const auto *opt = dyn_cast<ObjCObjectPointerType>(canon)) {
4843 if (opt->getObjectType()->isObjCClass())
4851 if (
const auto *
typedefType = getAs<TypedefType>())
4852 return typedefType->getDecl()->hasAttr<ObjCNSObjectAttr>();
4857 if (
const auto *
typedefType = getAs<TypedefType>())
4858 return typedefType->getDecl()->hasAttr<ObjCIndependentClassAttr>();
4871 if (
const auto *OPT = getAs<PointerType>())
4872 return OPT->getPointeeType()->isObjCIndirectLifetimeType();
4873 if (
const auto *Ref = getAs<ReferenceType>())
4874 return Ref->getPointeeType()->isObjCIndirectLifetimeType();
4875 if (
const auto *MemPtr = getAs<MemberPointerType>())
4876 return MemPtr->getPointeeType()->isObjCIndirectLifetimeType();
4884 while (
const ArrayType *array =
type->getAsArrayTypeUnsafe())
4885 type = array->getElementType().getTypePtr();
4886 return type->isObjCRetainableType();
4897 const auto *
Pointer = getAs<PointerType>();
4907 if (
const auto *RT = getAs<RecordType>())
4908 return RT->getDecl()->hasAttr<CUDADeviceBuiltinSurfaceTypeAttr>();
4914 if (
const auto *RT = getAs<RecordType>())
4915 return RT->getDecl()->hasAttr<CUDADeviceBuiltinTextureTypeAttr>();
4922 if (
const auto *ptr = getAs<PointerType>())
4923 return ptr->getPointeeType()->hasSizedVLAType();
4924 if (
const auto *ref = getAs<ReferenceType>())
4925 return ref->getPointeeType()->hasSizedVLAType();
4927 if (isa<VariableArrayType>(arr) &&
4928 cast<VariableArrayType>(arr)->getSizeExpr())
4931 return arr->getElementType()->hasSizedVLAType();
4938 switch (
type.getObjCLifetime()) {
4950 if (
const auto *RT =
4953 if (
const auto *CXXRD = dyn_cast<CXXRecordDecl>(RD)) {
4955 if (CXXRD->hasDefinition() && !CXXRD->hasTrivialDestructor())
4973 llvm::APSInt Val,
unsigned Scale) {
4974 llvm::FixedPointSemantics FXSema(Val.getBitWidth(), Scale, Val.isSigned(),
4977 llvm::APFixedPoint(Val, FXSema).toString(Str);
4985 AutoTypeBits.Keyword = llvm::to_underlying(Keyword);
4986 AutoTypeBits.NumArgs = TypeConstraintArgs.size();
4987 this->TypeConstraintConcept = TypeConstraintConcept;
4988 assert(TypeConstraintConcept || AutoTypeBits.NumArgs == 0);
4989 if (TypeConstraintConcept) {
5008 ID.AddInteger((
unsigned)Keyword);
5009 ID.AddBoolean(IsDependent);
5012 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 getArrayParameterType(QualType Ty) const
Return the uniqued reference to a specified array parameter type from the original array type.
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.
Represents a constant array type that does not decay to a pointer when used as a function parameter.
Represents an array type, per C99 6.7.5.2 - Array Declarators.
QualType getElementType() const
ArrayType(TypeClass tc, QualType et, QualType can, ArraySizeModifier sm, unsigned tq, const Expr *sz=nullptr)
An attributed type is a type to which a type attribute has been applied.
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
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)
[BoundsSafety] Represents a parent type class for CountAttributedType and similar sugar types that wi...
BoundsAttributedType(TypeClass TC, QualType Wrapped, QualType Canon)
decl_range dependent_decls() const
bool referencesFieldDecls() const
ArrayRef< TypeCoupledDeclRefInfo > Decls
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.
Declaration of a C++20 concept.
Represents the canonical version of C arrays with a specified constant size.
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...
llvm::APInt getSize() const
Return the constant array size as an APInt.
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.
ConstantMatrixType(QualType MatrixElementType, unsigned NRows, unsigned NColumns, QualType CanonElementType)
Represents a sugar type with __counted_by or __sized_by annotations, including their _or_null variant...
void Profile(llvm::FoldingSetNodeID &ID)
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)
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,...
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.
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
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.
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.
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.
PointerType - C99 6.7.5.1 - Pointer Declarators.
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.
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.
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.
@ 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
[BoundsSafety] Represents information of declarations referenced by the arguments of the counted_by a...
ValueDecl * getDecl() const
bool operator==(const TypeCoupledDeclRefInfo &Other) const
void * getOpaqueValue() const
TypeCoupledDeclRefInfo(ValueDecl *D=nullptr, bool Deref=false)
D is to a declaration referenced by the argument of attribute.
void setFromOpaqueValue(void *V)
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 isCountAttributedType() 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.
CountAttributedTypeBitfields CountAttributedTypeBits
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
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
Represents a C array with a specified size that is not an integer-constant-expression.
Represents a GCC generic vector type.
VectorType(QualType vecType, unsigned nElements, QualType canonType, VectorKind vecKind)
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)
const FunctionProtoType * T
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.