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);
263DependentVectorType::DependentVectorType(
QualType ElementType,
266 :
Type(DependentVector, CanonType,
268 ElementType->getDependence() |
271 ElementType(ElementType), SizeExpr(SizeExpr),
Loc(
Loc) {
280 ID.AddInteger(llvm::to_underlying(VecKind));
281 SizeExpr->
Profile(ID, Context,
true);
284DependentSizedExtVectorType::DependentSizedExtVectorType(
QualType ElementType,
288 :
Type(DependentSizedExtVector, can,
290 ElementType->getDependence() |
293 SizeExpr(SizeExpr), ElementType(ElementType), loc(loc) {}
300 SizeExpr->
Profile(ID, Context,
true);
303DependentAddressSpaceType::DependentAddressSpaceType(
QualType PointeeType,
307 :
Type(DependentAddressSpace, can,
309 PointeeType->getDependence() |
312 AddrSpaceExpr(AddrSpaceExpr), PointeeType(PointeeType), loc(loc) {}
317 Expr *AddrSpaceExpr) {
319 AddrSpaceExpr->
Profile(ID, Context,
true);
323 const Expr *RowExpr,
const Expr *ColumnExpr)
324 :
Type(tc, canonType,
327 (matrixType->isVariablyModifiedType()
330 (matrixType->containsUnexpandedParameterPack() ||
332 RowExpr->containsUnexpandedParameterPack()) ||
334 ColumnExpr->containsUnexpandedParameterPack())
337 : matrixType->getDependence())),
338 ElementType(matrixType) {}
341 unsigned nColumns,
QualType canonType)
346 unsigned nRows,
unsigned nColumns,
348 :
MatrixType(tc, matrixType, canonType), NumRows(nRows),
349 NumColumns(nColumns) {}
351DependentSizedMatrixType::DependentSizedMatrixType(
QualType ElementType,
356 :
MatrixType(DependentSizedMatrix, ElementType, CanonicalType, RowExpr,
358 RowExpr(RowExpr), ColumnExpr(ColumnExpr), loc(loc) {}
365 RowExpr->
Profile(ID, CTX,
true);
366 ColumnExpr->
Profile(ID, CTX,
true);
375 :
Type(tc, canonType, vecType->getDependence()), ElementType(vecType) {
387 ExprAndUnsigned(NumBitsExpr, IsUnsigned) {}
390 return ExprAndUnsigned.getInt();
394 return ExprAndUnsigned.getPointer();
400 ID.AddBoolean(IsUnsigned);
401 NumBitsExpr->
Profile(ID, Context,
true);
407 return isa<FieldDecl>(Info.
getDecl());
413 bool CountInBytes,
bool OrNull) {
415 ID.AddBoolean(CountInBytes);
416 ID.AddBoolean(OrNull);
421 ID.AddPointer(CountExpr);
429 if (
const auto *ATy = dyn_cast<ArrayType>(
this))
430 return ATy->getElementType().getTypePtr();
433 if (!isa<ArrayType>(CanonicalType))
439 ->getElementType().getTypePtr();
463#define TYPE(CLASS, BASE) \
464 static_assert(!std::is_polymorphic<CLASS##Type>::value, \
465 #CLASS "Type should not be polymorphic!");
466#include "clang/AST/TypeNodes.inc"
471#define TYPE(CLASS, BASE) \
472 static_assert(std::is_trivially_destructible<CLASS##Type>::value, \
473 #CLASS "Type should be trivially destructible!");
474#include "clang/AST/TypeNodes.inc"
478#define ABSTRACT_TYPE(Class, Parent)
479#define TYPE(Class, Parent) \
480 case Type::Class: { \
481 const auto *ty = cast<Class##Type>(this); \
482 if (!ty->isSugared()) return QualType(ty, 0); \
483 return ty->desugar(); \
485#include "clang/AST/TypeNodes.inc"
487 llvm_unreachable(
"bad type kind!");
497#define ABSTRACT_TYPE(Class, Parent)
498#define TYPE(Class, Parent) \
499 case Type::Class: { \
500 const auto *Ty = cast<Class##Type>(CurTy); \
501 if (!Ty->isSugared()) \
502 return SplitQualType(Ty, Qs); \
503 Cur = Ty->desugar(); \
506#include "clang/AST/TypeNodes.inc"
526#define ABSTRACT_TYPE(Class, Parent)
527#define TYPE(Class, Parent) \
528 case Type::Class: { \
529 const auto *ty = cast<Class##Type>(split.Ty); \
530 if (!ty->isSugared()) goto done; \
531 next = ty->desugar(); \
534#include "clang/AST/TypeNodes.inc"
553 T = PT->getInnerType();
562 if (
const auto *Sugar = dyn_cast<T>(Cur))
565#define ABSTRACT_TYPE(Class, Parent)
566#define TYPE(Class, Parent) \
567 case Type::Class: { \
568 const auto *Ty = cast<Class##Type>(Cur); \
569 if (!Ty->isSugared()) return 0; \
570 Cur = Ty->desugar().getTypePtr(); \
573#include "clang/AST/TypeNodes.inc"
579 return getAsSugar<TypedefType>(
this);
583 return getAsSugar<UsingType>(
this);
587 return getAsSugar<TemplateSpecializationType>(
this);
591 return getAsSugar<AttributedType>(
this);
595 return getAsSugar<BoundsAttributedType>(
this);
599 return getAsSugar<CountAttributedType>(
this);
606 const Type *Cur =
this;
610#define ABSTRACT_TYPE(Class, Parent)
611#define TYPE(Class, Parent) \
613 const auto *Ty = cast<Class##Type>(Cur); \
614 if (!Ty->isSugared()) return Cur; \
615 Cur = Ty->desugar().getTypePtr(); \
618#include "clang/AST/TypeNodes.inc"
624 if (
const auto *RT = getAs<RecordType>())
625 return RT->getDecl()->isClass();
630 if (
const auto *RT = getAs<RecordType>())
631 return RT->getDecl()->isStruct();
636 const auto *RT = getAs<RecordType>();
639 const auto *
Decl = RT->getDecl();
640 if (!
Decl->isStruct())
642 return Decl->hasFlexibleArrayMember();
646 if (
const auto *RT = getAs<RecordType>())
647 return RT->getDecl()->hasAttr<ObjCBoxableAttr>();
652 if (
const auto *RT = getAs<RecordType>())
653 return RT->getDecl()->isInterface();
658 if (
const auto *RT = getAs<RecordType>()) {
666 if (
const auto *PT = getAs<PointerType>())
667 return PT->getPointeeType()->isVoidType();
672 if (
const auto *RT = getAs<RecordType>())
673 return RT->getDecl()->isUnion();
678 if (
const auto *CT = dyn_cast<ComplexType>(CanonicalType))
679 return CT->getElementType()->isFloatingType();
689 if (
const auto *ET = getAs<EnumType>())
690 return ET->getDecl()->isScoped();
695 return getAs<CountAttributedType>();
699 if (
const auto *
Complex = getAs<ComplexType>())
700 if (
Complex->getElementType()->isIntegerType())
706 if (
const auto *PT = getAs<PointerType>())
708 if (
const auto *OPT = getAs<ObjCObjectPointerType>())
710 if (
const auto *BPT = getAs<BlockPointerType>())
712 if (
const auto *RT = getAs<ReferenceType>())
714 if (
const auto *MPT = getAs<MemberPointerType>())
716 if (
const auto *DT = getAs<DecayedType>())
723 if (
const auto *RT = dyn_cast<RecordType>(
this)) {
724 if (RT->getDecl()->isStruct())
729 if (
const auto *RT = dyn_cast<RecordType>(CanonicalType)) {
730 if (!RT->getDecl()->isStruct())
742 if (
const auto *RT = dyn_cast<RecordType>(
this)) {
743 if (RT->getDecl()->isUnion())
748 if (
const auto *RT = dyn_cast<RecordType>(CanonicalType)) {
749 if (!RT->getDecl()->isUnion())
764 const auto *OPT = getAs<ObjCObjectPointerType>();
769 if (OPT->isObjCIdType())
773 if (!OPT->isKindOfType())
777 if (OPT->isObjCClassType() || OPT->isObjCQualifiedClassType())
787 const auto *OPT = getAs<ObjCObjectPointerType>();
792 if (OPT->isObjCClassType())
796 if (!OPT->isKindOfType())
800 return OPT->isObjCClassType() || OPT->isObjCQualifiedClassType();
814 :
Type(ObjCObject, Canonical,
Base->getDependence()), BaseType(
Base) {
819 "bitfield overflow in type argument count");
820 if (!typeArgs.empty())
821 memcpy(getTypeArgStorage(), typeArgs.data(),
822 typeArgs.size() *
sizeof(
QualType));
824 for (
auto typeArg : typeArgs) {
825 addDependence(typeArg->getDependence() & ~TypeDependence::VariablyModified);
838 if (
const auto objcObject =
getBaseType()->getAs<ObjCObjectType>()) {
840 if (isa<ObjCInterfaceType>(objcObject))
843 return objcObject->isSpecialized();
856 if (
const auto objcObject =
getBaseType()->getAs<ObjCObjectType>()) {
858 if (isa<ObjCInterfaceType>(objcObject))
861 return objcObject->getTypeArgs();
873 if (
const auto objcObject =
getBaseType()->getAs<ObjCObjectType>()) {
875 if (isa<ObjCInterfaceType>(objcObject))
878 return objcObject->isKindOfType();
894 baseType = baseObj->stripObjCKindOfTypeAndQuals(ctx);
897 splitBaseType.
Quals),
923template <
typename Derived>
924struct SimpleTransformVisitor :
public TypeVisitor<Derived, QualType> {
932 QualType result =
static_cast<Derived *
>(
this)->Visit(splitType.
Ty);
942 explicit SimpleTransformVisitor(
ASTContext &ctx) : Ctx(ctx) {}
946#define TYPE(Class, Base)
947#define DEPENDENT_TYPE(Class, Base) \
948 QualType Visit##Class##Type(const Class##Type *T) { return QualType(T, 0); }
949#include "clang/AST/TypeNodes.inc"
951#define TRIVIAL_TYPE_CLASS(Class) \
952 QualType Visit##Class##Type(const Class##Type *T) { return QualType(T, 0); }
953#define SUGARED_TYPE_CLASS(Class) \
954 QualType Visit##Class##Type(const Class##Type *T) { \
955 if (!T->isSugared()) \
956 return QualType(T, 0); \
957 QualType desugaredType = recurse(T->desugar()); \
958 if (desugaredType.isNull()) \
960 if (desugaredType.getAsOpaquePtr() == T->desugar().getAsOpaquePtr()) \
961 return QualType(T, 0); \
962 return desugaredType; \
968 QualType elementType = recurse(
T->getElementType());
972 if (elementType.
getAsOpaquePtr() ==
T->getElementType().getAsOpaquePtr())
1001 QualType pointeeType = recurse(
T->getPointeeTypeAsWritten());
1002 if (pointeeType.
isNull())
1006 ==
T->getPointeeTypeAsWritten().getAsOpaquePtr())
1013 QualType pointeeType = recurse(
T->getPointeeTypeAsWritten());
1014 if (pointeeType.
isNull())
1018 ==
T->getPointeeTypeAsWritten().getAsOpaquePtr())
1026 if (pointeeType.
isNull())
1036 QualType elementType = recurse(
T->getElementType());
1037 if (elementType.
isNull())
1040 if (elementType.
getAsOpaquePtr() ==
T->getElementType().getAsOpaquePtr())
1044 T->getSizeModifier(),
1045 T->getIndexTypeCVRQualifiers());
1049 QualType elementType = recurse(
T->getElementType());
1050 if (elementType.
isNull())
1053 if (elementType.
getAsOpaquePtr() ==
T->getElementType().getAsOpaquePtr())
1057 T->getSizeModifier(),
1058 T->getIndexTypeCVRQualifiers(),
1059 T->getBracketsRange());
1063 QualType elementType = recurse(
T->getElementType());
1064 if (elementType.
isNull())
1067 if (elementType.
getAsOpaquePtr() ==
T->getElementType().getAsOpaquePtr())
1071 T->getIndexTypeCVRQualifiers());
1075 QualType elementType = recurse(
T->getElementType());
1076 if (elementType.
isNull())
1079 if (elementType.
getAsOpaquePtr() ==
T->getElementType().getAsOpaquePtr())
1083 T->getVectorKind());
1087 QualType elementType = recurse(
T->getElementType());
1088 if (elementType.
isNull())
1091 if (elementType.
getAsOpaquePtr() ==
T->getElementType().getAsOpaquePtr())
1098 QualType elementType = recurse(
T->getElementType());
1099 if (elementType.
isNull())
1101 if (elementType.
getAsOpaquePtr() ==
T->getElementType().getAsOpaquePtr())
1105 T->getNumColumns());
1126 bool paramChanged =
false;
1128 QualType newParamType = recurse(paramType);
1129 if (newParamType.
isNull())
1133 paramChanged =
true;
1135 paramTypes.push_back(newParamType);
1140 bool exceptionChanged =
false;
1144 QualType newExceptionType = recurse(exceptionType);
1145 if (newExceptionType.
isNull())
1148 if (newExceptionType.
getAsOpaquePtr() != exceptionType.getAsOpaquePtr())
1149 exceptionChanged =
true;
1151 exceptionTypes.push_back(newExceptionType);
1154 if (exceptionChanged) {
1161 !paramChanged && !exceptionChanged)
1168 QualType innerType = recurse(
T->getInnerType());
1183 QualType originalType = recurse(
T->getOriginalType());
1184 if (originalType.
isNull())
1187 QualType adjustedType = recurse(
T->getAdjustedType());
1188 if (adjustedType.
isNull())
1192 ==
T->getOriginalType().getAsOpaquePtr() &&
1193 adjustedType.
getAsOpaquePtr() ==
T->getAdjustedType().getAsOpaquePtr())
1200 QualType originalType = recurse(
T->getOriginalType());
1201 if (originalType.
isNull())
1205 ==
T->getOriginalType().getAsOpaquePtr())
1212 QualType ArrTy = VisitConstantArrayType(
T);
1230 QualType modifiedType = recurse(
T->getModifiedType());
1231 if (modifiedType.
isNull())
1234 QualType equivalentType = recurse(
T->getEquivalentType());
1235 if (equivalentType.
isNull())
1239 ==
T->getModifiedType().getAsOpaquePtr() &&
1241 ==
T->getEquivalentType().getAsOpaquePtr())
1249 QualType replacementType = recurse(
T->getReplacementType());
1250 if (replacementType.
isNull())
1254 ==
T->getReplacementType().getAsOpaquePtr())
1258 T->getAssociatedDecl(),
1259 T->getIndex(),
T->getPackIndex());
1266 if (!
T->isDeduced())
1269 QualType deducedType = recurse(
T->getDeducedType());
1270 if (deducedType.
isNull())
1274 ==
T->getDeducedType().getAsOpaquePtr())
1279 T->getTypeConstraintConcept(),
1280 T->getTypeConstraintArguments());
1284 QualType baseType = recurse(
T->getBaseType());
1289 bool typeArgChanged =
false;
1291 for (
auto typeArg :
T->getTypeArgsAsWritten()) {
1292 QualType newTypeArg = recurse(typeArg);
1297 typeArgChanged =
true;
1299 typeArgs.push_back(newTypeArg);
1309 T->isKindOfTypeAsWritten());
1316 if (pointeeType.
isNull())
1327 QualType valueType = recurse(
T->getValueType());
1332 ==
T->getValueType().getAsOpaquePtr())
1338#undef TRIVIAL_TYPE_CLASS
1339#undef SUGARED_TYPE_CLASS
1342struct SubstObjCTypeArgsVisitor
1343 :
public SimpleTransformVisitor<SubstObjCTypeArgsVisitor> {
1344 using BaseType = SimpleTransformVisitor<SubstObjCTypeArgsVisitor>;
1351 : BaseType(ctx), TypeArgs(typeArgs), SubstContext(context) {}
1358 if (!TypeArgs.empty()) {
1369 argType, protocolsToApply, hasError,
true);
1372 switch (SubstContext) {
1373 case ObjCSubstitutionContext::Ordinary:
1374 case ObjCSubstitutionContext::Parameter:
1375 case ObjCSubstitutionContext::Superclass:
1379 case ObjCSubstitutionContext::Result:
1380 case ObjCSubstitutionContext::Property: {
1382 const auto *objPtr =
1387 if (objPtr->isKindOfType() || objPtr->isObjCIdOrClassType())
1391 const auto *obj = objPtr->getObjectType();
1393 obj->getBaseType(), obj->getTypeArgsAsWritten(), obj->getProtocols(),
1400 llvm_unreachable(
"Unexpected ObjCSubstitutionContext!");
1409 Ctx, TypeArgs, ObjCSubstitutionContext::Result);
1415 if (isa<FunctionNoProtoType>(funcType)) {
1419 return BaseType::VisitFunctionType(funcType);
1425 const auto *funcProtoType = cast<FunctionProtoType>(funcType);
1429 bool paramChanged =
false;
1430 for (
auto paramType : funcProtoType->getParamTypes()) {
1432 Ctx, TypeArgs, ObjCSubstitutionContext::Parameter);
1433 if (newParamType.
isNull())
1437 paramChanged =
true;
1439 paramTypes.push_back(newParamType);
1444 bool exceptionChanged =
false;
1449 Ctx, TypeArgs, ObjCSubstitutionContext::Ordinary);
1450 if (newExceptionType.
isNull())
1453 if (newExceptionType.
getAsOpaquePtr() != exceptionType.getAsOpaquePtr())
1454 exceptionChanged =
true;
1456 exceptionTypes.push_back(newExceptionType);
1459 if (exceptionChanged) {
1466 funcProtoType->getReturnType().getAsOpaquePtr() &&
1467 !paramChanged && !exceptionChanged)
1468 return BaseType::VisitFunctionType(funcType);
1478 bool anyChanged =
false;
1481 Ctx, TypeArgs, ObjCSubstitutionContext::Ordinary);
1490 if (TypeArgs.empty() &&
1491 SubstContext != ObjCSubstitutionContext::Superclass) {
1500 newTypeArgs.push_back(newTypeArg);
1512 return BaseType::VisitObjCObjectType(objcObjectType);
1516 QualType newType = BaseType::VisitAttributedType(attrType);
1520 const auto *newAttrType = dyn_cast<AttributedType>(newType.
getTypePtr());
1521 if (!newAttrType || newAttrType->getAttrKind() != attr::ObjCKindOf)
1525 QualType newEquivType = newAttrType->getEquivalentType();
1537 objType->getBaseType(), objType->getTypeArgsAsWritten(),
1538 objType->getProtocols(),
1540 objType->isObjCUnqualifiedId() ?
false :
true);
1548 newAttrType->getModifiedType(), newEquivType);
1552struct StripObjCKindOfTypeVisitor
1553 :
public SimpleTransformVisitor<StripObjCKindOfTypeVisitor> {
1554 using BaseType = SimpleTransformVisitor<StripObjCKindOfTypeVisitor>;
1556 explicit StripObjCKindOfTypeVisitor(
ASTContext &ctx) : BaseType(ctx) {}
1560 return BaseType::VisitObjCObjectType(objType);
1581 case BuiltinType::Kind::Float16: {
1589 case BuiltinType::Kind::BFloat16: {
1609 SubstObjCTypeArgsVisitor visitor(ctx, typeArgs, context);
1610 return visitor.recurse(*
this);
1624 auto &ctx =
const_cast<ASTContext &
>(constCtx);
1625 StripObjCKindOfTypeVisitor visitor(ctx);
1626 return visitor.recurse(*
this);
1632 T = AT->getValueType();
1633 return T.getUnqualifiedType();
1636std::optional<ArrayRef<QualType>>
1639 if (
const auto method = dyn_cast<ObjCMethodDecl>(dc))
1640 dc = method->getDeclContext();
1644 const auto *dcClassDecl = dyn_cast<ObjCInterfaceDecl>(dc);
1650 dcTypeParams = dcClassDecl->getTypeParamList();
1652 return std::nullopt;
1656 dcCategoryDecl = dyn_cast<ObjCCategoryDecl>(dc);
1657 if (!dcCategoryDecl)
1658 return std::nullopt;
1664 return std::nullopt;
1668 return std::nullopt;
1670 assert(dcTypeParams &&
"No substitutions to perform");
1671 assert(dcClassDecl &&
"No class context");
1675 if (
const auto *objectPointerType = getAs<ObjCObjectPointerType>()) {
1676 objectType = objectPointerType->getObjectType();
1677 }
else if (getAs<BlockPointerType>()) {
1682 objectType = getAs<ObjCObjectType>();
1688 if (!curClassDecl) {
1696 while (curClassDecl != dcClassDecl) {
1699 if (superType.
isNull()) {
1700 objectType =
nullptr;
1720 if (
auto *ID = IfaceT->getInterface()) {
1721 if (ID->getTypeParamList())
1735 CachedSuperClassType.setInt(
true);
1741 if (!superClassObjTy) {
1742 CachedSuperClassType.setInt(
true);
1747 if (!superClassDecl) {
1748 CachedSuperClassType.setInt(
true);
1754 QualType superClassType(superClassObjTy, 0);
1756 if (!superClassTypeParams) {
1757 CachedSuperClassType.setPointerAndInt(
1764 CachedSuperClassType.setPointerAndInt(superClassObjTy,
true);
1772 CachedSuperClassType.setPointerAndInt(
1783 CachedSuperClassType.setPointerAndInt(
1791 assert(typeArgs.size() == typeParams->
size());
1792 CachedSuperClassType.setPointerAndInt(
1801 return interfaceDecl->getASTContext().getObjCInterfaceType(interfaceDecl)
1810 if (superObjectType.
isNull())
1811 return superObjectType;
1821 if (
const auto *
T = getAs<ObjCObjectType>())
1822 if (
T->getNumProtocols() &&
T->getInterface())
1834 if (
const auto *OPT = getAs<ObjCObjectPointerType>()) {
1835 if (OPT->isObjCQualifiedIdType())
1844 if (
const auto *OPT = getAs<ObjCObjectPointerType>()) {
1845 if (OPT->isObjCQualifiedClassType())
1852 if (
const auto *OT = getAs<ObjCObjectType>()) {
1853 if (OT->getInterface())
1860 if (
const auto *OPT = getAs<ObjCObjectPointerType>()) {
1861 if (OPT->getInterfaceType())
1869 if (
const auto *PT = getAs<PointerType>())
1871 else if (
const auto *RT = getAs<ReferenceType>())
1877 return dyn_cast<CXXRecordDecl>(RT->getDecl());
1883 return dyn_cast_or_null<CXXRecordDecl>(
getAsTagDecl());
1891 if (
const auto *TT = getAs<TagType>())
1892 return TT->getDecl();
1893 if (
const auto *Injected = getAs<InjectedClassNameType>())
1894 return Injected->getDecl();
1900 const Type *Cur =
this;
1902 if (AT->getAttrKind() == AK)
1904 Cur = AT->getEquivalentType().getTypePtr();
1911 class GetContainedDeducedTypeVisitor :
1912 public TypeVisitor<GetContainedDeducedTypeVisitor, Type*> {
1916 GetContainedDeducedTypeVisitor(
bool Syntactic =
false)
1917 : Syntactic(Syntactic) {}
1924 return Visit(
T.getTypePtr());
1934 return Visit(
T->getReplacementType());
1938 return Visit(
T->getNamedType());
1950 return Visit(
T->getPointeeTypeAsWritten());
1958 return Visit(
T->getElementType());
1961 Type *VisitDependentSizedExtVectorType(
1963 return Visit(
T->getElementType());
1967 return Visit(
T->getElementType());
1971 return Visit(
T->getElementType());
1975 return Visit(
T->getElementType());
1981 return VisitFunctionType(
T);
1989 return Visit(
T->getInnerType());
1993 return Visit(
T->getModifiedType());
1997 return Visit(
T->getUnderlyingType());
2001 return Visit(
T->getOriginalType());
2005 return Visit(
T->getPattern());
2012 return cast_or_null<DeducedType>(
2013 GetContainedDeducedTypeVisitor().Visit(
this));
2017 return isa_and_nonnull<FunctionType>(
2018 GetContainedDeducedTypeVisitor(
true).Visit(
this));
2022 if (
const auto *VT = dyn_cast<VectorType>(CanonicalType))
2023 return VT->getElementType()->isIntegerType();
2024 if (CanonicalType->isSveVLSBuiltinType()) {
2025 const auto *VT = cast<BuiltinType>(CanonicalType);
2026 return VT->getKind() == BuiltinType::SveBool ||
2027 (VT->getKind() >= BuiltinType::SveInt8 &&
2028 VT->getKind() <= BuiltinType::SveUint64);
2030 if (CanonicalType->isRVVVLSBuiltinType()) {
2031 const auto *VT = cast<BuiltinType>(CanonicalType);
2032 return (VT->getKind() >= BuiltinType::RvvInt8mf8 &&
2033 VT->getKind() <= BuiltinType::RvvUint64m8);
2059 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
2060 return BT->getKind() >= BuiltinType::Bool &&
2061 BT->getKind() <= BuiltinType::Int128;
2065 if (
const auto *ET = dyn_cast<EnumType>(CanonicalType))
2066 return ET->getDecl()->isComplete();
2072 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
2073 return BT->getKind() >= BuiltinType::Bool &&
2074 BT->getKind() <= BuiltinType::Int128;
2083 if (
const auto *ET = dyn_cast<EnumType>(CanonicalType))
2084 return !ET->getDecl()->isScoped();
2090 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
2091 return BT->getKind() == BuiltinType::Char_U ||
2092 BT->getKind() == BuiltinType::UChar ||
2093 BT->getKind() == BuiltinType::Char_S ||
2094 BT->getKind() == BuiltinType::SChar;
2099 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
2100 return BT->getKind() == BuiltinType::WChar_S ||
2101 BT->getKind() == BuiltinType::WChar_U;
2106 if (
const BuiltinType *BT = dyn_cast<BuiltinType>(CanonicalType))
2107 return BT->getKind() == BuiltinType::Char8;
2112 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
2113 return BT->getKind() == BuiltinType::Char16;
2118 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
2119 return BT->getKind() == BuiltinType::Char32;
2126 const auto *BT = dyn_cast<BuiltinType>(CanonicalType);
2127 if (!BT)
return false;
2128 switch (BT->getKind()) {
2129 default:
return false;
2130 case BuiltinType::Char_U:
2131 case BuiltinType::UChar:
2132 case BuiltinType::WChar_U:
2133 case BuiltinType::Char8:
2134 case BuiltinType::Char16:
2135 case BuiltinType::Char32:
2136 case BuiltinType::Char_S:
2137 case BuiltinType::SChar:
2138 case BuiltinType::WChar_S:
2147 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType)) {
2148 return BT->getKind() >= BuiltinType::Char_S &&
2149 BT->getKind() <= BuiltinType::Int128;
2152 if (
const EnumType *ET = dyn_cast<EnumType>(CanonicalType)) {
2155 if (ET->getDecl()->isComplete() && !ET->getDecl()->isScoped())
2159 if (
const auto *IT = dyn_cast<BitIntType>(CanonicalType))
2160 return IT->isSigned();
2161 if (
const auto *IT = dyn_cast<DependentBitIntType>(CanonicalType))
2162 return IT->isSigned();
2168 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType)) {
2169 return BT->getKind() >= BuiltinType::Char_S &&
2170 BT->getKind() <= BuiltinType::Int128;
2173 if (
const auto *ET = dyn_cast<EnumType>(CanonicalType)) {
2174 if (ET->getDecl()->isComplete())
2178 if (
const auto *IT = dyn_cast<BitIntType>(CanonicalType))
2179 return IT->isSigned();
2180 if (
const auto *IT = dyn_cast<DependentBitIntType>(CanonicalType))
2181 return IT->isSigned();
2187 if (
const auto *VT = dyn_cast<VectorType>(CanonicalType))
2188 return VT->getElementType()->isSignedIntegerOrEnumerationType();
2197 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType)) {
2198 return BT->getKind() >= BuiltinType::Bool &&
2199 BT->getKind() <= BuiltinType::UInt128;
2202 if (
const auto *ET = dyn_cast<EnumType>(CanonicalType)) {
2205 if (ET->getDecl()->isComplete() && !ET->getDecl()->isScoped())
2209 if (
const auto *IT = dyn_cast<BitIntType>(CanonicalType))
2210 return IT->isUnsigned();
2211 if (
const auto *IT = dyn_cast<DependentBitIntType>(CanonicalType))
2212 return IT->isUnsigned();
2218 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType)) {
2219 return BT->getKind() >= BuiltinType::Bool &&
2220 BT->getKind() <= BuiltinType::UInt128;
2223 if (
const auto *ET = dyn_cast<EnumType>(CanonicalType)) {
2224 if (ET->getDecl()->isComplete())
2228 if (
const auto *IT = dyn_cast<BitIntType>(CanonicalType))
2229 return IT->isUnsigned();
2230 if (
const auto *IT = dyn_cast<DependentBitIntType>(CanonicalType))
2231 return IT->isUnsigned();
2237 if (
const auto *VT = dyn_cast<VectorType>(CanonicalType))
2238 return VT->getElementType()->isUnsignedIntegerOrEnumerationType();
2239 if (
const auto *VT = dyn_cast<MatrixType>(CanonicalType))
2240 return VT->getElementType()->isUnsignedIntegerOrEnumerationType();
2241 if (CanonicalType->isSveVLSBuiltinType()) {
2242 const auto *VT = cast<BuiltinType>(CanonicalType);
2243 return VT->getKind() >= BuiltinType::SveUint8 &&
2244 VT->getKind() <= BuiltinType::SveUint64;
2250 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
2251 return BT->getKind() >= BuiltinType::Half &&
2252 BT->getKind() <= BuiltinType::Ibm128;
2253 if (
const auto *CT = dyn_cast<ComplexType>(CanonicalType))
2254 return CT->getElementType()->isFloatingType();
2259 if (
const auto *VT = dyn_cast<VectorType>(CanonicalType))
2260 return VT->getElementType()->isFloatingType();
2261 if (
const auto *MT = dyn_cast<MatrixType>(CanonicalType))
2262 return MT->getElementType()->isFloatingType();
2267 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
2268 return BT->isFloatingPoint();
2273 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
2274 return BT->getKind() >= BuiltinType::Bool &&
2275 BT->getKind() <= BuiltinType::Ibm128;
2276 if (
const auto *ET = dyn_cast<EnumType>(CanonicalType))
2277 return ET->getDecl()->isComplete() && !ET->getDecl()->isScoped();
2282 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
2283 return BT->getKind() >= BuiltinType::Bool &&
2284 BT->getKind() <= BuiltinType::Ibm128;
2285 if (
const auto *ET = dyn_cast<EnumType>(CanonicalType))
2292 return !ET->getDecl()->isScoped() && ET->getDecl()->isComplete();
2293 return isa<ComplexType>(CanonicalType) ||
isBitIntType();
2299 const Type *
T = CanonicalType.getTypePtr();
2300 if (
const auto *BT = dyn_cast<BuiltinType>(
T)) {
2301 if (BT->getKind() == BuiltinType::Bool)
return STK_Bool;
2302 if (BT->getKind() == BuiltinType::NullPtr)
return STK_CPointer;
2306 llvm_unreachable(
"unknown scalar builtin type");
2307 }
else if (isa<PointerType>(
T)) {
2309 }
else if (isa<BlockPointerType>(
T)) {
2311 }
else if (isa<ObjCObjectPointerType>(
T)) {
2313 }
else if (isa<MemberPointerType>(
T)) {
2315 }
else if (isa<EnumType>(
T)) {
2316 assert(cast<EnumType>(
T)->getDecl()->isComplete());
2318 }
else if (
const auto *CT = dyn_cast<ComplexType>(
T)) {
2319 if (CT->getElementType()->isRealFloatingType())
2326 llvm_unreachable(
"unknown scalar type");
2339 if (
const auto *
Record = dyn_cast<RecordType>(CanonicalType)) {
2340 if (
const auto *ClassDecl = dyn_cast<CXXRecordDecl>(
Record->getDecl()))
2341 return ClassDecl->isAggregate();
2346 return isa<ArrayType>(CanonicalType);
2353 assert(!
isIncompleteType() &&
"This doesn't make sense for incomplete types");
2354 assert(!
isDependentType() &&
"This doesn't make sense for dependent types");
2356 return !isa<VariableArrayType>(CanonicalType);
2366 switch (CanonicalType->getTypeClass()) {
2367 default:
return false;
2373 EnumDecl *EnumD = cast<EnumType>(CanonicalType)->getDecl();
2381 RecordDecl *Rec = cast<RecordType>(CanonicalType)->getDecl();
2386 case InjectedClassName: {
2387 CXXRecordDecl *Rec = cast<InjectedClassNameType>(CanonicalType)->getDecl();
2400 return cast<ArrayType>(CanonicalType)->getElementType()
2401 ->isIncompleteType(Def);
2402 case IncompleteArray:
2405 case MemberPointer: {
2409 auto *MPTy = cast<MemberPointerType>(CanonicalType);
2410 const Type *ClassTy = MPTy->getClass();
2423 if (RD->
hasAttr<MSInheritanceAttr>())
2428 return cast<ObjCObjectType>(CanonicalType)->getBaseType()
2429 ->isIncompleteType(Def);
2430 case ObjCInterface: {
2433 = cast<ObjCInterfaceType>(CanonicalType)->getDecl();
2445 if (
const BuiltinType *BT = getAs<BuiltinType>()) {
2446 switch (BT->getKind()) {
2448#define WASM_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
2449#include "clang/Basic/WebAssemblyReferenceTypes.def"
2451#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
2452#include "clang/Basic/HLSLIntangibleTypes.def"
2462 if (
const auto *BT = getAs<BuiltinType>())
2463 return BT->getKind() == BuiltinType::WasmExternRef;
2468 if (
const auto *ATy = dyn_cast<ArrayType>(
this))
2469 return ATy->getElementType().isWebAssemblyReferenceType();
2471 if (
const auto *PTy = dyn_cast<PointerType>(
this))
2472 return PTy->getPointeeType().isWebAssemblyReferenceType();
2484 if (
const BuiltinType *BT = getAs<BuiltinType>()) {
2485 switch (BT->getKind()) {
2487#define SVE_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
2488#include "clang/Basic/AArch64SVEACLETypes.def"
2498 if (
const BuiltinType *BT = getAs<BuiltinType>()) {
2499 switch (BT->getKind()) {
2500#define RVV_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
2501#include "clang/Basic/RISCVVTypes.def"
2511 if (
const BuiltinType *BT = getAs<BuiltinType>()) {
2512 switch (BT->getKind()) {
2513 case BuiltinType::SveInt8:
2514 case BuiltinType::SveInt16:
2515 case BuiltinType::SveInt32:
2516 case BuiltinType::SveInt64:
2517 case BuiltinType::SveUint8:
2518 case BuiltinType::SveUint16:
2519 case BuiltinType::SveUint32:
2520 case BuiltinType::SveUint64:
2521 case BuiltinType::SveFloat16:
2522 case BuiltinType::SveFloat32:
2523 case BuiltinType::SveFloat64:
2524 case BuiltinType::SveBFloat16:
2525 case BuiltinType::SveBool:
2526 case BuiltinType::SveBoolx2:
2527 case BuiltinType::SveBoolx4:
2545 llvm_unreachable(
"Unhandled type");
2552 if (BTy->
getKind() == BuiltinType::SveBool)
2562 if (
const BuiltinType *BT = getAs<BuiltinType>()) {
2563 switch (BT->getKind()) {
2564#define RVV_VECTOR_TYPE(Name, Id, SingletonId, NumEls, ElBits, NF, IsSigned, \
2566 case BuiltinType::Id: \
2568#define RVV_PREDICATE_TYPE(Name, Id, SingletonId, NumEls) \
2569 case BuiltinType::Id: \
2571#include "clang/Basic/RISCVVTypes.def"
2585#define RVV_PREDICATE_TYPE(Name, Id, SingletonId, NumEls) \
2586 case BuiltinType::Id: \
2587 return Ctx.UnsignedCharTy;
2590#include "clang/Basic/RISCVVTypes.def"
2593 llvm_unreachable(
"Unhandled type");
2611 if ((*this)->isIncompleteArrayType())
2614 if ((*this)->isIncompleteType())
2623 default:
return false;
2624 case Type::VariableArray:
2625 case Type::ConstantArray:
2629 case Type::ObjCObjectPointer:
2630 case Type::BlockPointer:
2634 case Type::MemberPointer:
2636 case Type::ExtVector:
2644 if (
const auto *ClassDecl =
2645 dyn_cast<CXXRecordDecl>(cast<RecordType>(CanonicalType)->getDecl()))
2646 return ClassDecl->isPOD();
2660 if ((*this)->isArrayType())
2663 if ((*this)->isSizelessBuiltinType())
2668 if ((*this)->isIncompleteType())
2687 if (
const auto *ClassDecl = dyn_cast<CXXRecordDecl>(RT->getDecl())) {
2694 return ClassDecl->hasTrivialDefaultConstructor() &&
2695 !ClassDecl->hasNonTrivialDefaultConstructor() &&
2696 ClassDecl->isTriviallyCopyable();
2708 bool IsCopyConstructible) {
2709 if (
type->isArrayType())
2711 Context, IsCopyConstructible);
2713 if (
type.hasNonTrivialObjCLifetime())
2738 if (
const auto *ClassDecl = dyn_cast<CXXRecordDecl>(RT->getDecl())) {
2739 if (IsCopyConstructible) {
2740 return ClassDecl->isTriviallyCopyConstructible();
2742 return ClassDecl->isTriviallyCopyable();
2759 if (CanonicalType.hasNonTrivialObjCLifetime())
2761 if (CanonicalType->isArrayType())
2765 if (CanonicalType->isIncompleteType())
2767 const auto *RD = CanonicalType->getAsRecordDecl();
2774 if (RD->mayInsertExtraPadding())
2777 for (
auto *
const Field : RD->fields()) {
2778 if (!Field->getType().isBitwiseCloneableType(Context))
2782 if (
const auto *CXXRD = dyn_cast<CXXRecordDecl>(RD)) {
2783 for (
auto Base : CXXRD->bases())
2784 if (!
Base.getType().isBitwiseCloneableType(Context))
2786 for (
auto VBase : CXXRD->vbases())
2787 if (!VBase.getType().isBitwiseCloneableType(Context))
2807 return RD->canPassInRegisters();
2855 if (
const auto *RT =
2856 getTypePtr()->getBaseElementTypeUnsafe()->getAs<RecordType>())
2857 if (RT->getDecl()->isNonTrivialToPrimitiveDefaultInitialize())
2871 if (
const auto *RT =
2872 getTypePtr()->getBaseElementTypeUnsafe()->getAs<RecordType>())
2873 if (RT->getDecl()->isNonTrivialToPrimitiveCopy())
2909 assert(BaseTy &&
"NULL element type");
2939 if (
const auto *ClassDecl = dyn_cast<CXXRecordDecl>(RT->getDecl()))
2940 return ClassDecl->isLiteral();
2947 return AT->getValueType()->isLiteralType(Ctx);
2969 return RD->isStructural();
2982 assert(BaseTy &&
"NULL element type");
2992 if (
const auto *ClassDecl = dyn_cast<CXXRecordDecl>(RT->getDecl()))
2993 if (!ClassDecl->isStandardLayout())
3021 assert(BaseTy &&
"NULL element type");
3034 if (
const auto *ClassDecl = dyn_cast<CXXRecordDecl>(RT->getDecl())) {
3037 if (!ClassDecl->isTrivial())
return false;
3042 if (!ClassDecl->isStandardLayout())
return false;
3071 if (
const auto *ET = getAs<EnumType>()) {
3073 if (II && II->
isStr(
"align_val_t") && ET->getDecl()->isInStdNamespace())
3080 if (
const auto *ET = getAs<EnumType>()) {
3082 if (II && II->
isStr(
"byte") && ET->getDecl()->isInStdNamespace())
3098 case TemplateTypeParm:
3099 case SubstTemplateTypeParm:
3100 case TemplateSpecialization:
3103 case DependentTemplateSpecialization:
3147 llvm_unreachable(
"Type specifier is not a tag type kind.");
3164 llvm_unreachable(
"Unknown tag type kind.");
3182 llvm_unreachable(
"Elaborated type keyword is not a tag type kind.");
3184 llvm_unreachable(
"Unknown elaborated type keyword.");
3200 llvm_unreachable(
"Unknown elaborated type keyword.");
3214 return "__interface";
3221 llvm_unreachable(
"Unknown elaborated type keyword.");
3224DependentTemplateSpecializationType::DependentTemplateSpecializationType(
3231 NNS(NNS), Name(Name) {
3234 "DependentTemplateSpecializatonType requires dependent qualifier");
3235 auto *ArgBuffer =
const_cast<TemplateArgument *
>(template_arguments().data());
3238 TemplateArgumentDependence::UnexpandedPack));
3251 ID.AddInteger(llvm::to_underlying(Keyword));
3252 ID.AddPointer(Qualifier);
3253 ID.AddPointer(Name);
3255 Arg.Profile(ID, Context);
3260 if (
const auto *Elab = dyn_cast<ElaboratedType>(
this))
3261 Keyword = Elab->getKeyword();
3262 else if (
const auto *DepName = dyn_cast<DependentNameType>(
this))
3263 Keyword = DepName->getKeyword();
3264 else if (
const auto *DepTST =
3265 dyn_cast<DependentTemplateSpecializationType>(
this))
3266 Keyword = DepTST->getKeyword();
3275#define ABSTRACT_TYPE(Derived, Base)
3276#define TYPE(Derived, Base) case Derived: return #Derived;
3277#include "clang/AST/TypeNodes.inc"
3280 llvm_unreachable(
"Invalid type class.");
3288 return Policy.
Bool ?
"bool" :
"_Bool";
3294 return "signed char";
3306 return "unsigned char";
3308 return "unsigned short";
3310 return "unsigned int";
3312 return "unsigned long";
3314 return "unsigned long long";
3316 return "unsigned __int128";
3318 return Policy.
Half ?
"half" :
"__fp16";
3326 return "long double";
3328 return "short _Accum";
3332 return "long _Accum";
3334 return "unsigned short _Accum";
3336 return "unsigned _Accum";
3338 return "unsigned long _Accum";
3339 case BuiltinType::ShortFract:
3340 return "short _Fract";
3341 case BuiltinType::Fract:
3343 case BuiltinType::LongFract:
3344 return "long _Fract";
3345 case BuiltinType::UShortFract:
3346 return "unsigned short _Fract";
3347 case BuiltinType::UFract:
3348 return "unsigned _Fract";
3349 case BuiltinType::ULongFract:
3350 return "unsigned long _Fract";
3351 case BuiltinType::SatShortAccum:
3352 return "_Sat short _Accum";
3353 case BuiltinType::SatAccum:
3354 return "_Sat _Accum";
3355 case BuiltinType::SatLongAccum:
3356 return "_Sat long _Accum";
3357 case BuiltinType::SatUShortAccum:
3358 return "_Sat unsigned short _Accum";
3359 case BuiltinType::SatUAccum:
3360 return "_Sat unsigned _Accum";
3361 case BuiltinType::SatULongAccum:
3362 return "_Sat unsigned long _Accum";
3363 case BuiltinType::SatShortFract:
3364 return "_Sat short _Fract";
3365 case BuiltinType::SatFract:
3366 return "_Sat _Fract";
3367 case BuiltinType::SatLongFract:
3368 return "_Sat long _Fract";
3369 case BuiltinType::SatUShortFract:
3370 return "_Sat unsigned short _Fract";
3371 case BuiltinType::SatUFract:
3372 return "_Sat unsigned _Fract";
3373 case BuiltinType::SatULongFract:
3374 return "_Sat unsigned long _Fract";
3378 return "__float128";
3383 return Policy.
MSWChar ?
"__wchar_t" :
"wchar_t";
3393 return "<overloaded function type>";
3395 return "<bound member function type>";
3396 case UnresolvedTemplate:
3397 return "<unresolved template type>";
3399 return "<pseudo-object type>";
3401 return "<dependent type>";
3403 return "<unknown type>";
3404 case ARCUnbridgedCast:
3405 return "<ARC unbridged cast type>";
3407 return "<builtin fn type>";
3414#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
3416 return "__" #Access " " #ImgType "_t";
3417#include "clang/Basic/OpenCLImageTypes.def"
3423 return "clk_event_t";
3427 return "reserve_id_t";
3428 case IncompleteMatrixIdx:
3429 return "<incomplete matrix index type>";
3431 return "<array section type>";
3432 case OMPArrayShaping:
3433 return "<OpenMP array shaping type>";
3435 return "<OpenMP iterator type>";
3436#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \
3439#include "clang/Basic/OpenCLExtensionTypes.def"
3440#define SVE_TYPE(Name, Id, SingletonId) \
3443#include "clang/Basic/AArch64SVEACLETypes.def"
3444#define PPC_VECTOR_TYPE(Name, Id, Size) \
3447#include "clang/Basic/PPCTypes.def"
3448#define RVV_TYPE(Name, Id, SingletonId) \
3451#include "clang/Basic/RISCVVTypes.def"
3452#define WASM_TYPE(Name, Id, SingletonId) \
3455#include "clang/Basic/WebAssemblyReferenceTypes.def"
3456#define AMDGPU_TYPE(Name, Id, SingletonId) \
3459#include "clang/Basic/AMDGPUTypes.def"
3460#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) \
3463#include "clang/Basic/HLSLIntangibleTypes.def"
3466 llvm_unreachable(
"Invalid builtin type.");
3471 if (
auto *PET = dyn_cast<PackExpansionType>(
getTypePtr()))
3472 return PET->getPattern();
3477 if (
const auto *RefType =
getTypePtr()->getAs<ReferenceType>())
3494 case CC_C:
return "cdecl";
3522 llvm_unreachable(
"Invalid calling convention.");
3540 assert(
getNumParams() == params.size() &&
"NumParams overflow!");
3548 auto &ExtraBits = *getTrailingObjects<FunctionTypeExtraBitfields>();
3555 auto &ArmTypeAttrs = *getTrailingObjects<FunctionTypeArmAttributes>();
3556 ArmTypeAttrs = FunctionTypeArmAttributes();
3559 auto &ExtraBits = *getTrailingObjects<FunctionTypeExtraBitfields>();
3560 ExtraBits.HasArmTypeAttributes =
true;
3564 auto *argSlot = getTrailingObjects<QualType>();
3567 ~TypeDependence::VariablyModified);
3568 argSlot[i] = params[i];
3573 auto &ArmTypeAttrs = *getTrailingObjects<FunctionTypeArmAttributes>();
3575 "Not enough bits to encode SME attributes");
3581 auto &ExtraBits = *getTrailingObjects<FunctionTypeExtraBitfields>();
3583 assert(NumExceptions <= 1023 &&
"Not enough bits to encode exceptions");
3584 ExtraBits.NumExceptionType = NumExceptions;
3586 assert(hasExtraBitfields() &&
"missing trailing extra bitfields!");
3588 reinterpret_cast<QualType *
>(getTrailingObjects<ExceptionType>());
3596 (TypeDependence::Instantiation | TypeDependence::UnexpandedPack));
3598 exnSlot[I++] = ExceptionType;
3612 (TypeDependence::Instantiation | TypeDependence::UnexpandedPack));
3618 auto **slot = getTrailingObjects<FunctionDecl *>();
3626 auto **slot = getTrailingObjects<FunctionDecl *>();
3645 auto *extParamInfos = getTrailingObjects<ExtParameterInfo>();
3652 *getTrailingObjects<Qualifiers>() = epi.
TypeQuals;
3659 auto &EllipsisLoc = *getTrailingObjects<SourceLocation>();
3664 auto &ExtraBits = *getTrailingObjects<FunctionTypeExtraBitfields>();
3666 ExtraBits.NumFunctionEffects = EffectsCount;
3667 assert(ExtraBits.NumFunctionEffects == EffectsCount &&
3668 "effect bitfield overflow");
3671 auto *DestFX = getTrailingObjects<FunctionEffect>();
3672 std::uninitialized_copy(SrcFX.begin(), SrcFX.end(), DestFX);
3675 if (!SrcConds.empty()) {
3676 ExtraBits.EffectsHaveConditions =
true;
3677 auto *DestConds = getTrailingObjects<EffectConditionExpr>();
3678 std::uninitialized_copy(SrcConds.begin(), SrcConds.end(), DestConds);
3679 assert(std::any_of(SrcConds.begin(), SrcConds.end(),
3681 if (const Expr *E = EC.getCondition())
3682 return E->isTypeDependent() ||
3683 E->isValueDependent();
3686 "expected a dependent expression among the conditions");
3694 return NE->isValueDependent();
3706 return NE->isInstantiationDependent();
3717 llvm_unreachable(
"should not call this with unresolved exception specs");
3743 llvm_unreachable(
"unexpected exception specification kind");
3747 for (
unsigned ArgIdx =
getNumParams(); ArgIdx; --ArgIdx)
3755 const QualType *ArgTys,
unsigned NumParams,
3756 const ExtProtoInfo &epi,
3779 ID.AddPointer(
Result.getAsOpaquePtr());
3780 for (
unsigned i = 0; i != NumParams; ++i)
3781 ID.AddPointer(ArgTys[i].getAsOpaquePtr());
3785 assert(!(
unsigned(epi.Variadic) & ~1) &&
3786 !(
unsigned(epi.RefQualifier) & ~3) &&
3787 !(
unsigned(epi.ExceptionSpec.Type) & ~15) &&
3788 "Values larger than expected.");
3789 ID.AddInteger(
unsigned(epi.Variadic) +
3790 (epi.RefQualifier << 1) +
3791 (epi.ExceptionSpec.Type << 3));
3792 ID.Add(epi.TypeQuals);
3794 for (
QualType Ex : epi.ExceptionSpec.Exceptions)
3797 epi.ExceptionSpec.NoexceptExpr->Profile(ID, Context, Canonical);
3800 ID.AddPointer(epi.ExceptionSpec.SourceDecl->getCanonicalDecl());
3802 if (epi.ExtParameterInfos) {
3803 for (
unsigned i = 0; i != NumParams; ++i)
3804 ID.AddInteger(epi.ExtParameterInfos[i].getOpaqueValue());
3807 epi.ExtInfo.Profile(ID);
3809 unsigned EffectCount = epi.FunctionEffects.size();
3810 bool HasConds = !epi.FunctionEffects.Conditions.empty();
3812 ID.AddInteger((EffectCount << 3) | (HasConds << 2) |
3813 (epi.AArch64SMEAttributes << 1) | epi.HasTrailingReturn);
3815 for (
unsigned Idx = 0; Idx != EffectCount; ++Idx) {
3816 ID.AddInteger(epi.FunctionEffects.Effects[Idx].toOpaqueInt32());
3818 ID.AddPointer(epi.FunctionEffects.Conditions[Idx].getCondition());
3829 :
Data(
D, Deref << DerefShift) {}
3832 return Data.getInt() & DerefMask;
3837 return Data.getOpaqueValue();
3844 Data.setFromOpaqueValue(
V);
3849 :
Type(TC, Canon, Wrapped->getDependence()), WrappedTy(Wrapped) {}
3851CountAttributedType::CountAttributedType(
3855 CountExpr(CountExpr) {
3859 auto *DeclSlot = getTrailingObjects<TypeCoupledDeclRefInfo>();
3861 for (
unsigned i = 0; i != CoupledDecls.size(); ++i)
3862 DeclSlot[i] = CoupledDecls[i];
3869 assert(!isa<TypedefType>(can) &&
"Invalid canonical type");
3871 if (!typeMatchesDecl())
3872 *getTrailingObjects<QualType>() = Underlying;
3877 : *getTrailingObjects<QualType>();
3886 *getTrailingObjects<QualType>() = Underlying;
3892 cast<TypeDecl>(
Found->getTargetDecl())->getTypeForDecl(), 0)
3893 : *getTrailingObjects<QualType>();
3902 while (
auto *InnerMQT = dyn_cast<MacroQualifiedType>(Inner)) {
3905 Inner = InnerMQT->getModifiedType();
3916 ? Context.getUnqualifiedArrayType(Can).getAtomicUnqualifiedType()
3919 (
E->getType()->getDependence() &
3921 TOExpr(
E), Context(Context) {
3922 TypeOfBits.Kind =
static_cast<unsigned>(Kind);
3943 ID.AddBoolean(IsUnqual);
3950 ? Context.getUnqualifiedArrayType(Can).getAtomicUnqualifiedType()
3952 T->getDependence()),
3953 TOType(
T), Context(Context) {
3954 TypeOfBits.Kind =
static_cast<unsigned>(Kind);
3968 :
Type(Decltype, can,
3972 (
E->getType()->getDependence() &
3974 E(
E), UnderlyingType(underlyingType) {}
3997 :
Type(PackIndexing, Canonical,
3999 Context(Context), Pattern(Pattern), IndexExpr(IndexExpr),
4000 Size(Expansions.size()) {
4002 std::uninitialized_copy(Expansions.begin(), Expansions.end(),
4003 getTrailingObjects<QualType>());
4008 return std::nullopt;
4012 return std::nullopt;
4014 assert(Index.isNonNegative() &&
"Invalid index");
4015 return static_cast<unsigned>(Index.getExtValue());
4019PackIndexingType::computeDependence(
QualType Pattern,
Expr *IndexExpr,
4024 ? TypeDependence::DependentInstantiation
4025 : TypeDependence::None);
4026 if (Expansions.empty())
4027 TD |= Pattern->
getDependence() & TypeDependence::DependentInstantiation;
4032 if (!(IndexD & TypeDependence::UnexpandedPack))
4033 TD &= ~TypeDependence::UnexpandedPack;
4038 TD |= TypeDependence::Error | TypeDependence::DependentInstantiation;
4053 :
Type(UnaryTransform, CanonicalType, BaseType->getDependence()),
4054 BaseType(BaseType), UnderlyingType(UnderlyingType), UKind(UKind) {}
4068 for (
auto *I :
decl->redecls()) {
4069 if (I->isCompleteDefinition() || I->isBeingDefined())
4085 std::vector<const RecordType*> RecordTypeList;
4086 RecordTypeList.push_back(
this);
4087 unsigned NextToCheckIndex = 0;
4089 while (RecordTypeList.size() > NextToCheckIndex) {
4091 RecordTypeList[NextToCheckIndex]->
getDecl()->fields()) {
4097 if (!llvm::is_contained(RecordTypeList, FieldRecTy))
4098 RecordTypeList.push_back(FieldRecTy);
4113 case attr::ObjCOwnership:
4114 case attr::ObjCInertUnsafeUnretained:
4115 case attr::TypeNonNull:
4116 case attr::TypeNullable:
4117 case attr::TypeNullableResult:
4118 case attr::TypeNullUnspecified:
4119 case attr::LifetimeBound:
4120 case attr::AddressSpace:
4133 default:
return false;
4140 llvm_unreachable(
"invalid attr kind");
4150 default:
return false;
4153 case attr::FastCall:
4155 case attr::ThisCall:
4157 case attr::SwiftCall:
4158 case attr::SwiftAsyncCall:
4159 case attr::VectorCall:
4160 case attr::AArch64VectorPcs:
4161 case attr::AArch64SVEPcs:
4162 case attr::AMDGPUKernelCall:
4166 case attr::IntelOclBicc:
4167 case attr::PreserveMost:
4168 case attr::PreserveAll:
4170 case attr::PreserveNone:
4171 case attr::RISCVVectorCC:
4174 llvm_unreachable(
"invalid attr kind");
4187 if (
const auto *TTP = dyn_cast<TemplateTypeParmDecl>(
D))
4189 return cast<TemplateTypeParmDecl>(
4193SubstTemplateTypeParmType::SubstTemplateTypeParmType(
4194 QualType Replacement,
Decl *AssociatedDecl,
unsigned Index,
4195 std::optional<unsigned> PackIndex)
4196 :
Type(SubstTemplateTypeParm, Replacement.getCanonicalType(),
4197 Replacement->getDependence()),
4198 AssociatedDecl(AssociatedDecl) {
4199 SubstTemplateTypeParmTypeBits.HasNonCanonicalUnderlyingType =
4200 Replacement != getCanonicalTypeInternal();
4201 if (SubstTemplateTypeParmTypeBits.HasNonCanonicalUnderlyingType)
4202 *getTrailingObjects<QualType>() = Replacement;
4204 SubstTemplateTypeParmTypeBits.Index = Index;
4205 SubstTemplateTypeParmTypeBits.PackIndex = PackIndex ? *PackIndex + 1 : 0;
4206 assert(AssociatedDecl !=
nullptr);
4214SubstTemplateTypeParmPackType::SubstTemplateTypeParmPackType(
4215 QualType Canon,
Decl *AssociatedDecl,
unsigned Index,
bool Final,
4217 :
Type(SubstTemplateTypeParmPack, Canon,
4220 Arguments(ArgPack.pack_begin()),
4221 AssociatedDeclAndFinal(AssociatedDecl, Final) {
4224 assert(AssociatedDecl !=
nullptr);
4228 return AssociatedDeclAndFinal.getPointer();
4232 return AssociatedDeclAndFinal.getInt();
4253 const Decl *AssociatedDecl,
4254 unsigned Index,
bool Final,
4256 ID.AddPointer(AssociatedDecl);
4257 ID.AddInteger(Index);
4258 ID.AddBoolean(Final);
4261 ID.AddPointer(
P.getAsType().getAsOpaquePtr());
4272 if (Arg.isDependent())
4280 if (ArgLoc.getArgument().isInstantiationDependent())
4286TemplateSpecializationType::TemplateSpecializationType(
4289 :
Type(TemplateSpecialization, Canon.isNull() ?
QualType(this, 0) : Canon,
4299 assert(!
T.getAsDependentTemplateName() &&
4300 "Use DependentTemplateSpecializationType for dependent template-name");
4306 "Unexpected template name for TemplateSpecializationType");
4319 ~TypeDependence::Dependent);
4322 TypeDependence::VariablyModified);
4329 *
reinterpret_cast<QualType *
>(
Begin + Args.size()) = AliasedType;
4334 assert(
isTypeAlias() &&
"not a type alias template specialization");
4352 Arg.Profile(ID, Context);
4377 ID.AddInteger(typeArgs.size());
4378 for (
auto typeArg : typeArgs)
4379 ID.AddPointer(typeArg.getAsOpaquePtr());
4380 ID.AddInteger(protocols.size());
4381 for (
auto *proto : protocols)
4382 ID.AddPointer(proto);
4383 ID.AddBoolean(isKindOf);
4396 ID.AddPointer(OTPDecl);
4398 ID.AddInteger(protocols.size());
4399 for (
auto *proto : protocols)
4400 ID.AddPointer(proto);
4411class CachedProperties {
4416 CachedProperties(
Linkage L,
bool local) : L(L), local(local) {}
4418 Linkage getLinkage()
const {
return L; }
4419 bool hasLocalOrUnnamedType()
const {
return local; }
4421 friend CachedProperties merge(CachedProperties L, CachedProperties R) {
4423 return CachedProperties(MergedLinkage, L.hasLocalOrUnnamedType() ||
4424 R.hasLocalOrUnnamedType());
4440 return get(
T.getTypePtr());
4445 return CachedProperties(
T->
TypeBits.getLinkage(),
4487#define TYPE(Class,Base)
4488#define NON_CANONICAL_TYPE(Class,Base) case Type::Class:
4489#include "clang/AST/TypeNodes.inc"
4490 llvm_unreachable(
"didn't expect a non-canonical type here");
4492#define TYPE(Class,Base)
4493#define DEPENDENT_TYPE(Class,Base) case Type::Class:
4494#define NON_CANONICAL_UNLESS_DEPENDENT_TYPE(Class,Base) case Type::Class:
4495#include "clang/AST/TypeNodes.inc"
4501 case Type::DeducedTemplateSpecialization:
4515 const TagDecl *Tag = cast<TagType>(
T)->getDecl();
4521 Linkage L = Tag->getLinkageInternal();
4522 bool IsLocalOrUnnamed =
4523 Tag->getDeclContext()->isFunctionOrMethod() ||
4524 !Tag->hasNameForLinkage();
4525 return CachedProperties(L, IsLocalOrUnnamed);
4532 return Cache::get(cast<ComplexType>(
T)->getElementType());
4535 case Type::BlockPointer:
4537 case Type::LValueReference:
4538 case Type::RValueReference:
4540 case Type::MemberPointer: {
4541 const auto *MPT = cast<MemberPointerType>(
T);
4545 case Type::ConstantArray:
4546 case Type::IncompleteArray:
4547 case Type::VariableArray:
4548 case Type::ArrayParameter:
4549 return Cache::get(cast<ArrayType>(
T)->getElementType());
4551 case Type::ExtVector:
4552 return Cache::get(cast<VectorType>(
T)->getElementType());
4553 case Type::ConstantMatrix:
4554 return Cache::get(cast<ConstantMatrixType>(
T)->getElementType());
4555 case Type::FunctionNoProto:
4556 return Cache::get(cast<FunctionType>(
T)->getReturnType());
4557 case Type::FunctionProto: {
4558 const auto *FPT = cast<FunctionProtoType>(
T);
4559 CachedProperties result =
Cache::get(FPT->getReturnType());
4560 for (
const auto &ai : FPT->param_types())
4564 case Type::ObjCInterface: {
4565 Linkage L = cast<ObjCInterfaceType>(
T)->getDecl()->getLinkageInternal();
4566 return CachedProperties(L,
false);
4568 case Type::ObjCObject:
4569 return Cache::get(cast<ObjCObjectType>(
T)->getBaseType());
4570 case Type::ObjCObjectPointer:
4573 return Cache::get(cast<AtomicType>(
T)->getValueType());
4575 return Cache::get(cast<PipeType>(
T)->getElementType());
4578 llvm_unreachable(
"unhandled type class");
4589 return TypeBits.hasLocalOrUnnamedType();
4594#define TYPE(Class,Base)
4595#define NON_CANONICAL_TYPE(Class,Base) case Type::Class:
4596#include "clang/AST/TypeNodes.inc"
4597 llvm_unreachable(
"didn't expect a non-canonical type here");
4599#define TYPE(Class,Base)
4600#define DEPENDENT_TYPE(Class,Base) case Type::Class:
4601#define NON_CANONICAL_UNLESS_DEPENDENT_TYPE(Class,Base) case Type::Class:
4602#include "clang/AST/TypeNodes.inc"
4612 case Type::DeducedTemplateSpecialization:
4623 case Type::BlockPointer:
4625 case Type::LValueReference:
4626 case Type::RValueReference:
4628 case Type::MemberPointer: {
4629 const auto *MPT = cast<MemberPointerType>(
T);
4634 case Type::ConstantArray:
4635 case Type::IncompleteArray:
4636 case Type::VariableArray:
4637 case Type::ArrayParameter:
4640 case Type::ExtVector:
4642 case Type::ConstantMatrix:
4644 cast<ConstantMatrixType>(
T)->getElementType());
4645 case Type::FunctionNoProto:
4647 case Type::FunctionProto: {
4648 const auto *FPT = cast<FunctionProtoType>(
T);
4650 for (
const auto &ai : FPT->param_types())
4654 case Type::ObjCInterface:
4656 case Type::ObjCObject:
4658 case Type::ObjCObjectPointer:
4667 llvm_unreachable(
"unhandled type class");
4698 if (
auto Nullability = AT->getImmediateNullability())
4701 Type = AT->getEquivalentType();
4703 return std::nullopt;
4709 switch (
type->getTypeClass()) {
4711#define NON_CANONICAL_TYPE(Class, Parent) \
4713 llvm_unreachable("non-canonical type");
4714#define TYPE(Class, Parent)
4715#include "clang/AST/TypeNodes.inc"
4719 case Type::BlockPointer:
4720 case Type::MemberPointer:
4721 case Type::ObjCObjectPointer:
4725 case Type::UnresolvedUsing:
4726 case Type::TypeOfExpr:
4728 case Type::Decltype:
4729 case Type::PackIndexing:
4730 case Type::UnaryTransform:
4731 case Type::TemplateTypeParm:
4732 case Type::SubstTemplateTypeParmPack:
4733 case Type::DependentName:
4734 case Type::DependentTemplateSpecialization:
4736 return ResultIfUnknown;
4739 case Type::TemplateSpecialization:
4742 cast<TemplateSpecializationType>(
type.getTypePtr())
4744 .getAsTemplateDecl())
4745 if (
auto *CTD = dyn_cast<ClassTemplateDecl>(templateDecl))
4746 return CTD->getTemplatedDecl()->hasAttr<TypeNullableAttr>();
4747 return ResultIfUnknown;
4750 switch (cast<BuiltinType>(
type.getTypePtr())->getKind()) {
4752#define SIGNED_TYPE(Id, SingletonId) case BuiltinType::Id:
4753#define UNSIGNED_TYPE(Id, SingletonId) case BuiltinType::Id:
4754#define FLOATING_TYPE(Id, SingletonId) case BuiltinType::Id:
4755#define BUILTIN_TYPE(Id, SingletonId)
4756#include "clang/AST/BuiltinTypes.def"
4759 case BuiltinType::UnresolvedTemplate:
4761 case BuiltinType::Dependent:
4762 case BuiltinType::Overload:
4763 case BuiltinType::BoundMember:
4764 case BuiltinType::PseudoObject:
4765 case BuiltinType::UnknownAny:
4766 case BuiltinType::ARCUnbridgedCast:
4767 return ResultIfUnknown;
4769 case BuiltinType::Void:
4770 case BuiltinType::ObjCId:
4771 case BuiltinType::ObjCClass:
4772 case BuiltinType::ObjCSel:
4773#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
4774 case BuiltinType::Id:
4775#include "clang/Basic/OpenCLImageTypes.def"
4776#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \
4777 case BuiltinType::Id:
4778#include "clang/Basic/OpenCLExtensionTypes.def"
4779 case BuiltinType::OCLSampler:
4780 case BuiltinType::OCLEvent:
4781 case BuiltinType::OCLClkEvent:
4782 case BuiltinType::OCLQueue:
4783 case BuiltinType::OCLReserveID:
4784#define SVE_TYPE(Name, Id, SingletonId) \
4785 case BuiltinType::Id:
4786#include "clang/Basic/AArch64SVEACLETypes.def"
4787#define PPC_VECTOR_TYPE(Name, Id, Size) \
4788 case BuiltinType::Id:
4789#include "clang/Basic/PPCTypes.def"
4790#define RVV_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
4791#include "clang/Basic/RISCVVTypes.def"
4792#define WASM_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
4793#include "clang/Basic/WebAssemblyReferenceTypes.def"
4794#define AMDGPU_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
4795#include "clang/Basic/AMDGPUTypes.def"
4796#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
4797#include "clang/Basic/HLSLIntangibleTypes.def"
4798 case BuiltinType::BuiltinFn:
4799 case BuiltinType::NullPtr:
4800 case BuiltinType::IncompleteMatrixIdx:
4801 case BuiltinType::ArraySection:
4802 case BuiltinType::OMPArrayShaping:
4803 case BuiltinType::OMPIterator:
4806 llvm_unreachable(
"unknown builtin type");
4808 case Type::Record: {
4812 if (
const auto *CTSD = dyn_cast<ClassTemplateSpecializationDecl>(RD))
4813 return CTSD->getSpecializedTemplate()
4814 ->getTemplatedDecl()
4815 ->
hasAttr<TypeNullableAttr>();
4816 return RD->
hasAttr<TypeNullableAttr>();
4821 case Type::LValueReference:
4822 case Type::RValueReference:
4823 case Type::ConstantArray:
4824 case Type::IncompleteArray:
4825 case Type::VariableArray:
4826 case Type::DependentSizedArray:
4827 case Type::DependentVector:
4828 case Type::DependentSizedExtVector:
4830 case Type::ExtVector:
4831 case Type::ConstantMatrix:
4832 case Type::DependentSizedMatrix:
4833 case Type::DependentAddressSpace:
4834 case Type::FunctionProto:
4835 case Type::FunctionNoProto:
4836 case Type::DeducedTemplateSpecialization:
4838 case Type::InjectedClassName:
4839 case Type::PackExpansion:
4840 case Type::ObjCObject:
4841 case Type::ObjCInterface:
4845 case Type::DependentBitInt:
4846 case Type::ArrayParameter:
4849 llvm_unreachable(
"bad type kind!");
4861 return std::nullopt;
4864std::optional<NullabilityKind>
4867 if (
auto MacroTy = dyn_cast<MacroQualifiedType>(
T))
4868 AttrTy = MacroTy->getUnderlyingType();
4870 if (
auto attributed = dyn_cast<AttributedType>(AttrTy)) {
4871 if (
auto nullability = attributed->getImmediateNullability()) {
4872 T = attributed->getModifiedType();
4877 return std::nullopt;
4881 const auto *objcPtr = getAs<ObjCObjectPointerType>();
4885 if (objcPtr->isObjCIdType()) {
4896 }
else if (objcPtr->isObjCQualifiedIdType()) {
4921 "cannot query implicit lifetime for non-inferrable type");
4926 while (
const auto *array = dyn_cast<ArrayType>(canon))
4927 canon = array->getElementType().getTypePtr();
4929 if (
const auto *opt = dyn_cast<ObjCObjectPointerType>(canon)) {
4931 if (opt->getObjectType()->isObjCClass())
4939 if (
const auto *
typedefType = getAs<TypedefType>())
4940 return typedefType->getDecl()->hasAttr<ObjCNSObjectAttr>();
4945 if (
const auto *
typedefType = getAs<TypedefType>())
4946 return typedefType->getDecl()->hasAttr<ObjCIndependentClassAttr>();
4959 if (
const auto *OPT = getAs<PointerType>())
4960 return OPT->getPointeeType()->isObjCIndirectLifetimeType();
4961 if (
const auto *Ref = getAs<ReferenceType>())
4962 return Ref->getPointeeType()->isObjCIndirectLifetimeType();
4963 if (
const auto *MemPtr = getAs<MemberPointerType>())
4964 return MemPtr->getPointeeType()->isObjCIndirectLifetimeType();
4972 while (
const ArrayType *array =
type->getAsArrayTypeUnsafe())
4973 type = array->getElementType().getTypePtr();
4974 return type->isObjCRetainableType();
4985 const auto *
Pointer = getAs<PointerType>();
4995 if (
const auto *RT = getAs<RecordType>())
4996 return RT->getDecl()->hasAttr<CUDADeviceBuiltinSurfaceTypeAttr>();
5002 if (
const auto *RT = getAs<RecordType>())
5003 return RT->getDecl()->hasAttr<CUDADeviceBuiltinTextureTypeAttr>();
5010 if (
const auto *ptr = getAs<PointerType>())
5011 return ptr->getPointeeType()->hasSizedVLAType();
5012 if (
const auto *ref = getAs<ReferenceType>())
5013 return ref->getPointeeType()->hasSizedVLAType();
5015 if (isa<VariableArrayType>(arr) &&
5016 cast<VariableArrayType>(arr)->getSizeExpr())
5019 return arr->getElementType()->hasSizedVLAType();
5026 switch (
type.getObjCLifetime()) {
5038 if (
const auto *RT =
5041 if (
const auto *CXXRD = dyn_cast<CXXRecordDecl>(RD)) {
5043 if (CXXRD->hasDefinition() && !CXXRD->hasTrivialDestructor())
5061 llvm::APSInt Val,
unsigned Scale) {
5062 llvm::FixedPointSemantics FXSema(Val.getBitWidth(), Scale, Val.isSigned(),
5065 llvm::APFixedPoint(Val, FXSema).toString(Str);
5073 AutoTypeBits.Keyword = llvm::to_underlying(Keyword);
5074 AutoTypeBits.NumArgs = TypeConstraintArgs.size();
5075 this->TypeConstraintConcept = TypeConstraintConcept;
5076 assert(TypeConstraintConcept || AutoTypeBits.NumArgs == 0);
5077 if (TypeConstraintConcept) {