41#include "llvm/ADT/APInt.h"
42#include "llvm/ADT/APSInt.h"
43#include "llvm/ADT/ArrayRef.h"
44#include "llvm/ADT/FoldingSet.h"
45#include "llvm/ADT/STLExtras.h"
46#include "llvm/ADT/SmallVector.h"
47#include "llvm/Support/ErrorHandling.h"
48#include "llvm/Support/MathExtras.h"
58 return (*
this !=
Other) &&
115 getElementType().getBaseTypeIdentifier();
133 if (
T.isConstQualified())
137 return AT->getElementType().isConstant(Ctx);
142std::optional<QualType::NonConstantStorageReason>
145 if (!
isConstant(Ctx) && !(*this)->isReferenceType())
153 if (
Record->hasMutableFields())
155 if (!
Record->hasTrivialDestructor() && !ExcludeDtor)
175 et->getDependence() |
181 (tc == DependentSizedArray
191 const llvm::APInt &Sz,
const Expr *SzExpr,
193 bool NeedsExternalSize = SzExpr !=
nullptr || Sz.ugt(0x0FFFFFFFFFFFFFFF) ||
194 Sz.getBitWidth() > 0xFF;
195 if (!NeedsExternalSize)
197 ET, Can, Sz.getBitWidth(), Sz.getZExtValue(), SzMod, Qual);
199 auto *SzPtr =
new (Ctx,
alignof(ConstantArrayType::ExternalSize))
200 ConstantArrayType::ExternalSize(Sz, SzExpr);
207 const llvm::APInt &NumElements) {
216 if (llvm::isPowerOf2_64(ElementSize)) {
217 return NumElements.getActiveBits() + llvm::Log2_64(ElementSize);
222 if ((ElementSize >> 32) == 0 && NumElements.getBitWidth() <= 64 &&
223 (NumElements.getZExtValue() >> 32) == 0) {
224 uint64_t TotalSize = NumElements.getZExtValue() * ElementSize;
225 return llvm::bit_width(TotalSize);
229 llvm::APSInt SizeExtended(NumElements,
true);
231 SizeExtended = SizeExtended.extend(std::max(SizeTypeBits,
232 SizeExtended.getBitWidth()) * 2);
234 llvm::APSInt TotalSize(llvm::APInt(SizeExtended.getBitWidth(), ElementSize));
235 TotalSize *= SizeExtended;
237 return TotalSize.getActiveBits();
259 uint64_t ArraySize,
const Expr *SizeExpr,
262 ID.AddInteger(ArraySize);
263 ID.AddInteger(llvm::to_underlying(SizeMod));
264 ID.AddInteger(TypeQuals);
265 ID.AddBoolean(SizeExpr !=
nullptr);
267 SizeExpr->
Profile(ID, Context,
true);
280 :
ArrayType(DependentSizedArray, et, can, sm, tq, e), SizeExpr((
Stmt *)e),
281 Brackets(brackets) {}
290 ID.AddInteger(llvm::to_underlying(SizeMod));
291 ID.AddInteger(TypeQuals);
296DependentVectorType::DependentVectorType(
QualType ElementType,
299 :
Type(DependentVector, CanonType,
301 ElementType->getDependence() |
304 ElementType(ElementType), SizeExpr(SizeExpr),
Loc(
Loc) {
313 ID.AddInteger(llvm::to_underlying(VecKind));
314 SizeExpr->
Profile(ID, Context,
true);
317DependentSizedExtVectorType::DependentSizedExtVectorType(
QualType ElementType,
321 :
Type(DependentSizedExtVector, can,
323 ElementType->getDependence() |
326 SizeExpr(SizeExpr), ElementType(ElementType), loc(loc) {}
333 SizeExpr->
Profile(ID, Context,
true);
336DependentAddressSpaceType::DependentAddressSpaceType(
QualType PointeeType,
340 :
Type(DependentAddressSpace, can,
342 PointeeType->getDependence() |
345 AddrSpaceExpr(AddrSpaceExpr), PointeeType(PointeeType), loc(loc) {}
350 Expr *AddrSpaceExpr) {
352 AddrSpaceExpr->
Profile(ID, Context,
true);
356 const Expr *RowExpr,
const Expr *ColumnExpr)
357 :
Type(tc, canonType,
360 (matrixType->isVariablyModifiedType()
363 (matrixType->containsUnexpandedParameterPack() ||
365 RowExpr->containsUnexpandedParameterPack()) ||
367 ColumnExpr->containsUnexpandedParameterPack())
370 : matrixType->getDependence())),
371 ElementType(matrixType) {}
374 unsigned nColumns,
QualType canonType)
379 unsigned nRows,
unsigned nColumns,
381 :
MatrixType(tc, matrixType, canonType), NumRows(nRows),
382 NumColumns(nColumns) {}
384DependentSizedMatrixType::DependentSizedMatrixType(
QualType ElementType,
389 :
MatrixType(DependentSizedMatrix, ElementType, CanonicalType, RowExpr,
391 RowExpr(RowExpr), ColumnExpr(ColumnExpr), loc(loc) {}
398 RowExpr->
Profile(ID, CTX,
true);
399 ColumnExpr->
Profile(ID, CTX,
true);
408 :
Type(tc, canonType, vecType->getDependence()), ElementType(vecType) {
420 ExprAndUnsigned(NumBitsExpr, IsUnsigned) {}
423 return ExprAndUnsigned.getInt();
427 return ExprAndUnsigned.getPointer();
433 ID.AddBoolean(IsUnsigned);
434 NumBitsExpr->
Profile(ID, Context,
true);
440 return isa<FieldDecl>(Info.
getDecl());
446 bool CountInBytes,
bool OrNull) {
448 ID.AddBoolean(CountInBytes);
449 ID.AddBoolean(OrNull);
454 ID.AddPointer(CountExpr);
462 if (
const auto *ATy = dyn_cast<ArrayType>(
this))
463 return ATy->getElementType().getTypePtr();
466 if (!isa<ArrayType>(CanonicalType))
472 ->getElementType().getTypePtr();
496#define TYPE(CLASS, BASE) \
497 static_assert(!std::is_polymorphic<CLASS##Type>::value, \
498 #CLASS "Type should not be polymorphic!");
499#include "clang/AST/TypeNodes.inc"
504#define TYPE(CLASS, BASE) \
505 static_assert(std::is_trivially_destructible<CLASS##Type>::value, \
506 #CLASS "Type should be trivially destructible!");
507#include "clang/AST/TypeNodes.inc"
511#define ABSTRACT_TYPE(Class, Parent)
512#define TYPE(Class, Parent) \
513 case Type::Class: { \
514 const auto *ty = cast<Class##Type>(this); \
515 if (!ty->isSugared()) return QualType(ty, 0); \
516 return ty->desugar(); \
518#include "clang/AST/TypeNodes.inc"
520 llvm_unreachable(
"bad type kind!");
530#define ABSTRACT_TYPE(Class, Parent)
531#define TYPE(Class, Parent) \
532 case Type::Class: { \
533 const auto *Ty = cast<Class##Type>(CurTy); \
534 if (!Ty->isSugared()) \
535 return SplitQualType(Ty, Qs); \
536 Cur = Ty->desugar(); \
539#include "clang/AST/TypeNodes.inc"
559#define ABSTRACT_TYPE(Class, Parent)
560#define TYPE(Class, Parent) \
561 case Type::Class: { \
562 const auto *ty = cast<Class##Type>(split.Ty); \
563 if (!ty->isSugared()) goto done; \
564 next = ty->desugar(); \
567#include "clang/AST/TypeNodes.inc"
586 T = PT->getInnerType();
595 if (
const auto *Sugar = dyn_cast<T>(Cur))
598#define ABSTRACT_TYPE(Class, Parent)
599#define TYPE(Class, Parent) \
600 case Type::Class: { \
601 const auto *Ty = cast<Class##Type>(Cur); \
602 if (!Ty->isSugared()) return 0; \
603 Cur = Ty->desugar().getTypePtr(); \
606#include "clang/AST/TypeNodes.inc"
612 return getAsSugar<TypedefType>(
this);
616 return getAsSugar<UsingType>(
this);
620 return getAsSugar<TemplateSpecializationType>(
this);
624 return getAsSugar<AttributedType>(
this);
628 return getAsSugar<BoundsAttributedType>(
this);
632 return getAsSugar<CountAttributedType>(
this);
639 const Type *Cur =
this;
643#define ABSTRACT_TYPE(Class, Parent)
644#define TYPE(Class, Parent) \
646 const auto *Ty = cast<Class##Type>(Cur); \
647 if (!Ty->isSugared()) return Cur; \
648 Cur = Ty->desugar().getTypePtr(); \
651#include "clang/AST/TypeNodes.inc"
657 if (
const auto *RT = getAs<RecordType>())
658 return RT->getDecl()->isClass();
663 if (
const auto *RT = getAs<RecordType>())
664 return RT->getDecl()->isStruct();
669 const auto *RT = getAs<RecordType>();
672 const auto *
Decl = RT->getDecl();
673 if (!
Decl->isStruct())
675 return Decl->hasFlexibleArrayMember();
679 if (
const auto *RT = getAs<RecordType>())
680 return RT->getDecl()->hasAttr<ObjCBoxableAttr>();
685 if (
const auto *RT = getAs<RecordType>())
686 return RT->getDecl()->isInterface();
691 if (
const auto *RT = getAs<RecordType>()) {
699 if (
const auto *PT = getAs<PointerType>())
700 return PT->getPointeeType()->isVoidType();
705 if (
const auto *RT = getAs<RecordType>())
706 return RT->getDecl()->isUnion();
711 if (
const auto *CT = dyn_cast<ComplexType>(CanonicalType))
712 return CT->getElementType()->isFloatingType();
722 if (
const auto *ET = getAs<EnumType>())
723 return ET->getDecl()->isScoped();
728 return getAs<CountAttributedType>();
732 if (
const auto *
Complex = getAs<ComplexType>())
733 if (
Complex->getElementType()->isIntegerType())
739 if (
const auto *PT = getAs<PointerType>())
741 if (
const auto *OPT = getAs<ObjCObjectPointerType>())
743 if (
const auto *BPT = getAs<BlockPointerType>())
745 if (
const auto *RT = getAs<ReferenceType>())
747 if (
const auto *MPT = getAs<MemberPointerType>())
749 if (
const auto *DT = getAs<DecayedType>())
756 if (
const auto *RT = dyn_cast<RecordType>(
this)) {
757 if (RT->getDecl()->isStruct())
762 if (
const auto *RT = dyn_cast<RecordType>(CanonicalType)) {
763 if (!RT->getDecl()->isStruct())
775 if (
const auto *RT = dyn_cast<RecordType>(
this)) {
776 if (RT->getDecl()->isUnion())
781 if (
const auto *RT = dyn_cast<RecordType>(CanonicalType)) {
782 if (!RT->getDecl()->isUnion())
797 const auto *OPT = getAs<ObjCObjectPointerType>();
802 if (OPT->isObjCIdType())
806 if (!OPT->isKindOfType())
810 if (OPT->isObjCClassType() || OPT->isObjCQualifiedClassType())
820 const auto *OPT = getAs<ObjCObjectPointerType>();
825 if (OPT->isObjCClassType())
829 if (!OPT->isKindOfType())
833 return OPT->isObjCClassType() || OPT->isObjCQualifiedClassType();
847 :
Type(ObjCObject, Canonical,
Base->getDependence()), BaseType(
Base) {
852 "bitfield overflow in type argument count");
853 if (!typeArgs.empty())
854 memcpy(getTypeArgStorage(), typeArgs.data(),
855 typeArgs.size() *
sizeof(
QualType));
857 for (
auto typeArg : typeArgs) {
858 addDependence(typeArg->getDependence() & ~TypeDependence::VariablyModified);
871 if (
const auto objcObject =
getBaseType()->getAs<ObjCObjectType>()) {
873 if (isa<ObjCInterfaceType>(objcObject))
876 return objcObject->isSpecialized();
889 if (
const auto objcObject =
getBaseType()->getAs<ObjCObjectType>()) {
891 if (isa<ObjCInterfaceType>(objcObject))
894 return objcObject->getTypeArgs();
906 if (
const auto objcObject =
getBaseType()->getAs<ObjCObjectType>()) {
908 if (isa<ObjCInterfaceType>(objcObject))
911 return objcObject->isKindOfType();
927 baseType = baseObj->stripObjCKindOfTypeAndQuals(ctx);
930 splitBaseType.
Quals),
956template <
typename Derived>
957struct SimpleTransformVisitor :
public TypeVisitor<Derived, QualType> {
965 QualType result =
static_cast<Derived *
>(
this)->Visit(splitType.
Ty);
975 explicit SimpleTransformVisitor(
ASTContext &ctx) : Ctx(ctx) {}
979#define TYPE(Class, Base)
980#define DEPENDENT_TYPE(Class, Base) \
981 QualType Visit##Class##Type(const Class##Type *T) { return QualType(T, 0); }
982#include "clang/AST/TypeNodes.inc"
984#define TRIVIAL_TYPE_CLASS(Class) \
985 QualType Visit##Class##Type(const Class##Type *T) { return QualType(T, 0); }
986#define SUGARED_TYPE_CLASS(Class) \
987 QualType Visit##Class##Type(const Class##Type *T) { \
988 if (!T->isSugared()) \
989 return QualType(T, 0); \
990 QualType desugaredType = recurse(T->desugar()); \
991 if (desugaredType.isNull()) \
993 if (desugaredType.getAsOpaquePtr() == T->desugar().getAsOpaquePtr()) \
994 return QualType(T, 0); \
995 return desugaredType; \
1001 QualType elementType = recurse(
T->getElementType());
1002 if (elementType.
isNull())
1005 if (elementType.
getAsOpaquePtr() ==
T->getElementType().getAsOpaquePtr())
1013 if (pointeeType.
isNull())
1024 if (pointeeType.
isNull())
1034 QualType pointeeType = recurse(
T->getPointeeTypeAsWritten());
1035 if (pointeeType.
isNull())
1039 ==
T->getPointeeTypeAsWritten().getAsOpaquePtr())
1046 QualType pointeeType = recurse(
T->getPointeeTypeAsWritten());
1047 if (pointeeType.
isNull())
1051 ==
T->getPointeeTypeAsWritten().getAsOpaquePtr())
1059 if (pointeeType.
isNull())
1069 QualType elementType = recurse(
T->getElementType());
1070 if (elementType.
isNull())
1073 if (elementType.
getAsOpaquePtr() ==
T->getElementType().getAsOpaquePtr())
1077 T->getSizeModifier(),
1078 T->getIndexTypeCVRQualifiers());
1082 QualType elementType = recurse(
T->getElementType());
1083 if (elementType.
isNull())
1086 if (elementType.
getAsOpaquePtr() ==
T->getElementType().getAsOpaquePtr())
1090 T->getSizeModifier(),
1091 T->getIndexTypeCVRQualifiers(),
1092 T->getBracketsRange());
1096 QualType elementType = recurse(
T->getElementType());
1097 if (elementType.
isNull())
1100 if (elementType.
getAsOpaquePtr() ==
T->getElementType().getAsOpaquePtr())
1104 T->getIndexTypeCVRQualifiers());
1108 QualType elementType = recurse(
T->getElementType());
1109 if (elementType.
isNull())
1112 if (elementType.
getAsOpaquePtr() ==
T->getElementType().getAsOpaquePtr())
1116 T->getVectorKind());
1120 QualType elementType = recurse(
T->getElementType());
1121 if (elementType.
isNull())
1124 if (elementType.
getAsOpaquePtr() ==
T->getElementType().getAsOpaquePtr())
1131 QualType elementType = recurse(
T->getElementType());
1132 if (elementType.
isNull())
1134 if (elementType.
getAsOpaquePtr() ==
T->getElementType().getAsOpaquePtr())
1138 T->getNumColumns());
1159 bool paramChanged =
false;
1161 QualType newParamType = recurse(paramType);
1162 if (newParamType.
isNull())
1166 paramChanged =
true;
1168 paramTypes.push_back(newParamType);
1173 bool exceptionChanged =
false;
1177 QualType newExceptionType = recurse(exceptionType);
1178 if (newExceptionType.
isNull())
1181 if (newExceptionType.
getAsOpaquePtr() != exceptionType.getAsOpaquePtr())
1182 exceptionChanged =
true;
1184 exceptionTypes.push_back(newExceptionType);
1187 if (exceptionChanged) {
1194 !paramChanged && !exceptionChanged)
1201 QualType innerType = recurse(
T->getInnerType());
1216 QualType originalType = recurse(
T->getOriginalType());
1217 if (originalType.
isNull())
1220 QualType adjustedType = recurse(
T->getAdjustedType());
1221 if (adjustedType.
isNull())
1225 ==
T->getOriginalType().getAsOpaquePtr() &&
1226 adjustedType.
getAsOpaquePtr() ==
T->getAdjustedType().getAsOpaquePtr())
1233 QualType originalType = recurse(
T->getOriginalType());
1234 if (originalType.
isNull())
1238 ==
T->getOriginalType().getAsOpaquePtr())
1245 QualType ArrTy = VisitConstantArrayType(
T);
1263 QualType modifiedType = recurse(
T->getModifiedType());
1264 if (modifiedType.
isNull())
1267 QualType equivalentType = recurse(
T->getEquivalentType());
1268 if (equivalentType.
isNull())
1272 ==
T->getModifiedType().getAsOpaquePtr() &&
1274 ==
T->getEquivalentType().getAsOpaquePtr())
1282 QualType replacementType = recurse(
T->getReplacementType());
1283 if (replacementType.
isNull())
1287 ==
T->getReplacementType().getAsOpaquePtr())
1291 T->getAssociatedDecl(),
1292 T->getIndex(),
T->getPackIndex());
1299 if (!
T->isDeduced())
1302 QualType deducedType = recurse(
T->getDeducedType());
1303 if (deducedType.
isNull())
1307 ==
T->getDeducedType().getAsOpaquePtr())
1312 T->getTypeConstraintConcept(),
1313 T->getTypeConstraintArguments());
1317 QualType baseType = recurse(
T->getBaseType());
1322 bool typeArgChanged =
false;
1324 for (
auto typeArg :
T->getTypeArgsAsWritten()) {
1325 QualType newTypeArg = recurse(typeArg);
1330 typeArgChanged =
true;
1332 typeArgs.push_back(newTypeArg);
1342 T->isKindOfTypeAsWritten());
1349 if (pointeeType.
isNull())
1360 QualType valueType = recurse(
T->getValueType());
1365 ==
T->getValueType().getAsOpaquePtr())
1371#undef TRIVIAL_TYPE_CLASS
1372#undef SUGARED_TYPE_CLASS
1375struct SubstObjCTypeArgsVisitor
1376 :
public SimpleTransformVisitor<SubstObjCTypeArgsVisitor> {
1377 using BaseType = SimpleTransformVisitor<SubstObjCTypeArgsVisitor>;
1384 : BaseType(ctx), TypeArgs(typeArgs), SubstContext(context) {}
1391 if (!TypeArgs.empty()) {
1402 argType, protocolsToApply, hasError,
true);
1405 switch (SubstContext) {
1406 case ObjCSubstitutionContext::Ordinary:
1407 case ObjCSubstitutionContext::Parameter:
1408 case ObjCSubstitutionContext::Superclass:
1412 case ObjCSubstitutionContext::Result:
1413 case ObjCSubstitutionContext::Property: {
1415 const auto *objPtr =
1420 if (objPtr->isKindOfType() || objPtr->isObjCIdOrClassType())
1424 const auto *obj = objPtr->getObjectType();
1426 obj->getBaseType(), obj->getTypeArgsAsWritten(), obj->getProtocols(),
1433 llvm_unreachable(
"Unexpected ObjCSubstitutionContext!");
1442 Ctx, TypeArgs, ObjCSubstitutionContext::Result);
1448 if (isa<FunctionNoProtoType>(funcType)) {
1452 return BaseType::VisitFunctionType(funcType);
1458 const auto *funcProtoType = cast<FunctionProtoType>(funcType);
1462 bool paramChanged =
false;
1463 for (
auto paramType : funcProtoType->getParamTypes()) {
1465 Ctx, TypeArgs, ObjCSubstitutionContext::Parameter);
1466 if (newParamType.
isNull())
1470 paramChanged =
true;
1472 paramTypes.push_back(newParamType);
1477 bool exceptionChanged =
false;
1482 Ctx, TypeArgs, ObjCSubstitutionContext::Ordinary);
1483 if (newExceptionType.
isNull())
1486 if (newExceptionType.
getAsOpaquePtr() != exceptionType.getAsOpaquePtr())
1487 exceptionChanged =
true;
1489 exceptionTypes.push_back(newExceptionType);
1492 if (exceptionChanged) {
1499 funcProtoType->getReturnType().getAsOpaquePtr() &&
1500 !paramChanged && !exceptionChanged)
1501 return BaseType::VisitFunctionType(funcType);
1511 bool anyChanged =
false;
1514 Ctx, TypeArgs, ObjCSubstitutionContext::Ordinary);
1523 if (TypeArgs.empty() &&
1524 SubstContext != ObjCSubstitutionContext::Superclass) {
1533 newTypeArgs.push_back(newTypeArg);
1545 return BaseType::VisitObjCObjectType(objcObjectType);
1549 QualType newType = BaseType::VisitAttributedType(attrType);
1553 const auto *newAttrType = dyn_cast<AttributedType>(newType.
getTypePtr());
1554 if (!newAttrType || newAttrType->getAttrKind() != attr::ObjCKindOf)
1558 QualType newEquivType = newAttrType->getEquivalentType();
1570 objType->getBaseType(), objType->getTypeArgsAsWritten(),
1571 objType->getProtocols(),
1573 objType->isObjCUnqualifiedId() ?
false :
true);
1581 newAttrType->getModifiedType(), newEquivType,
1582 newAttrType->getAttr());
1586struct StripObjCKindOfTypeVisitor
1587 :
public SimpleTransformVisitor<StripObjCKindOfTypeVisitor> {
1588 using BaseType = SimpleTransformVisitor<StripObjCKindOfTypeVisitor>;
1590 explicit StripObjCKindOfTypeVisitor(
ASTContext &ctx) : BaseType(ctx) {}
1594 return BaseType::VisitObjCObjectType(objType);
1615 case BuiltinType::Kind::Float16: {
1623 case BuiltinType::Kind::BFloat16: {
1643 SubstObjCTypeArgsVisitor visitor(ctx, typeArgs, context);
1644 return visitor.recurse(*
this);
1658 auto &ctx =
const_cast<ASTContext &
>(constCtx);
1659 StripObjCKindOfTypeVisitor visitor(ctx);
1660 return visitor.recurse(*
this);
1666 T = AT->getValueType();
1667 return T.getUnqualifiedType();
1670std::optional<ArrayRef<QualType>>
1673 if (
const auto method = dyn_cast<ObjCMethodDecl>(dc))
1674 dc = method->getDeclContext();
1678 const auto *dcClassDecl = dyn_cast<ObjCInterfaceDecl>(dc);
1684 dcTypeParams = dcClassDecl->getTypeParamList();
1686 return std::nullopt;
1690 dcCategoryDecl = dyn_cast<ObjCCategoryDecl>(dc);
1691 if (!dcCategoryDecl)
1692 return std::nullopt;
1698 return std::nullopt;
1702 return std::nullopt;
1704 assert(dcTypeParams &&
"No substitutions to perform");
1705 assert(dcClassDecl &&
"No class context");
1709 if (
const auto *objectPointerType = getAs<ObjCObjectPointerType>()) {
1710 objectType = objectPointerType->getObjectType();
1711 }
else if (getAs<BlockPointerType>()) {
1716 objectType = getAs<ObjCObjectType>();
1722 if (!curClassDecl) {
1730 while (curClassDecl != dcClassDecl) {
1733 if (superType.
isNull()) {
1734 objectType =
nullptr;
1754 if (
auto *ID = IfaceT->getInterface()) {
1755 if (ID->getTypeParamList())
1769 CachedSuperClassType.setInt(
true);
1775 if (!superClassObjTy) {
1776 CachedSuperClassType.setInt(
true);
1781 if (!superClassDecl) {
1782 CachedSuperClassType.setInt(
true);
1788 QualType superClassType(superClassObjTy, 0);
1790 if (!superClassTypeParams) {
1791 CachedSuperClassType.setPointerAndInt(
1798 CachedSuperClassType.setPointerAndInt(superClassObjTy,
true);
1806 CachedSuperClassType.setPointerAndInt(
1817 CachedSuperClassType.setPointerAndInt(
1825 assert(typeArgs.size() == typeParams->
size());
1826 CachedSuperClassType.setPointerAndInt(
1835 return interfaceDecl->getASTContext().getObjCInterfaceType(interfaceDecl)
1844 if (superObjectType.
isNull())
1845 return superObjectType;
1855 if (
const auto *
T = getAs<ObjCObjectType>())
1856 if (
T->getNumProtocols() &&
T->getInterface())
1868 if (
const auto *OPT = getAs<ObjCObjectPointerType>()) {
1869 if (OPT->isObjCQualifiedIdType())
1878 if (
const auto *OPT = getAs<ObjCObjectPointerType>()) {
1879 if (OPT->isObjCQualifiedClassType())
1886 if (
const auto *OT = getAs<ObjCObjectType>()) {
1887 if (OT->getInterface())
1894 if (
const auto *OPT = getAs<ObjCObjectPointerType>()) {
1895 if (OPT->getInterfaceType())
1903 if (
const auto *PT = getAs<PointerType>())
1905 else if (
const auto *RT = getAs<ReferenceType>())
1911 return dyn_cast<CXXRecordDecl>(RT->getDecl());
1917 return dyn_cast_or_null<CXXRecordDecl>(
getAsTagDecl());
1925 if (
const auto *TT = getAs<TagType>())
1926 return TT->getDecl();
1927 if (
const auto *Injected = getAs<InjectedClassNameType>())
1928 return Injected->getDecl();
1934 const Type *Cur =
this;
1936 if (AT->getAttrKind() == AK)
1938 Cur = AT->getEquivalentType().getTypePtr();
1945 class GetContainedDeducedTypeVisitor :
1946 public TypeVisitor<GetContainedDeducedTypeVisitor, Type*> {
1950 GetContainedDeducedTypeVisitor(
bool Syntactic =
false)
1951 : Syntactic(Syntactic) {}
1958 return Visit(
T.getTypePtr());
1968 return Visit(
T->getReplacementType());
1972 return Visit(
T->getNamedType());
1984 return Visit(
T->getPointeeTypeAsWritten());
1992 return Visit(
T->getElementType());
1995 Type *VisitDependentSizedExtVectorType(
1997 return Visit(
T->getElementType());
2001 return Visit(
T->getElementType());
2005 return Visit(
T->getElementType());
2009 return Visit(
T->getElementType());
2015 return VisitFunctionType(
T);
2023 return Visit(
T->getInnerType());
2027 return Visit(
T->getModifiedType());
2031 return Visit(
T->getUnderlyingType());
2035 return Visit(
T->getOriginalType());
2039 return Visit(
T->getPattern());
2046 return cast_or_null<DeducedType>(
2047 GetContainedDeducedTypeVisitor().Visit(
this));
2051 return isa_and_nonnull<FunctionType>(
2052 GetContainedDeducedTypeVisitor(
true).Visit(
this));
2056 if (
const auto *VT = dyn_cast<VectorType>(CanonicalType))
2057 return VT->getElementType()->isIntegerType();
2058 if (CanonicalType->isSveVLSBuiltinType()) {
2059 const auto *VT = cast<BuiltinType>(CanonicalType);
2060 return VT->getKind() == BuiltinType::SveBool ||
2061 (VT->getKind() >= BuiltinType::SveInt8 &&
2062 VT->getKind() <= BuiltinType::SveUint64);
2064 if (CanonicalType->isRVVVLSBuiltinType()) {
2065 const auto *VT = cast<BuiltinType>(CanonicalType);
2066 return (VT->getKind() >= BuiltinType::RvvInt8mf8 &&
2067 VT->getKind() <= BuiltinType::RvvUint64m8);
2093 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
2094 return BT->getKind() >= BuiltinType::Bool &&
2095 BT->getKind() <= BuiltinType::Int128;
2099 if (
const auto *ET = dyn_cast<EnumType>(CanonicalType))
2100 return ET->getDecl()->isComplete();
2106 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
2107 return BT->getKind() >= BuiltinType::Bool &&
2108 BT->getKind() <= BuiltinType::Int128;
2117 if (
const auto *ET = dyn_cast<EnumType>(CanonicalType))
2118 return !ET->getDecl()->isScoped();
2124 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
2125 return BT->getKind() == BuiltinType::Char_U ||
2126 BT->getKind() == BuiltinType::UChar ||
2127 BT->getKind() == BuiltinType::Char_S ||
2128 BT->getKind() == BuiltinType::SChar;
2133 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
2134 return BT->getKind() == BuiltinType::WChar_S ||
2135 BT->getKind() == BuiltinType::WChar_U;
2140 if (
const BuiltinType *BT = dyn_cast<BuiltinType>(CanonicalType))
2141 return BT->getKind() == BuiltinType::Char8;
2146 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
2147 return BT->getKind() == BuiltinType::Char16;
2152 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
2153 return BT->getKind() == BuiltinType::Char32;
2160 const auto *BT = dyn_cast<BuiltinType>(CanonicalType);
2161 if (!BT)
return false;
2162 switch (BT->getKind()) {
2163 default:
return false;
2164 case BuiltinType::Char_U:
2165 case BuiltinType::UChar:
2166 case BuiltinType::WChar_U:
2167 case BuiltinType::Char8:
2168 case BuiltinType::Char16:
2169 case BuiltinType::Char32:
2170 case BuiltinType::Char_S:
2171 case BuiltinType::SChar:
2172 case BuiltinType::WChar_S:
2181 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType)) {
2182 return BT->getKind() >= BuiltinType::Char_S &&
2183 BT->getKind() <= BuiltinType::Int128;
2186 if (
const EnumType *ET = dyn_cast<EnumType>(CanonicalType)) {
2189 if (ET->getDecl()->isComplete() && !ET->getDecl()->isScoped())
2193 if (
const auto *IT = dyn_cast<BitIntType>(CanonicalType))
2194 return IT->isSigned();
2195 if (
const auto *IT = dyn_cast<DependentBitIntType>(CanonicalType))
2196 return IT->isSigned();
2202 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType)) {
2203 return BT->getKind() >= BuiltinType::Char_S &&
2204 BT->getKind() <= BuiltinType::Int128;
2207 if (
const auto *ET = dyn_cast<EnumType>(CanonicalType)) {
2208 if (ET->getDecl()->isComplete())
2212 if (
const auto *IT = dyn_cast<BitIntType>(CanonicalType))
2213 return IT->isSigned();
2214 if (
const auto *IT = dyn_cast<DependentBitIntType>(CanonicalType))
2215 return IT->isSigned();
2221 if (
const auto *VT = dyn_cast<VectorType>(CanonicalType))
2222 return VT->getElementType()->isSignedIntegerOrEnumerationType();
2231 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType)) {
2232 return BT->getKind() >= BuiltinType::Bool &&
2233 BT->getKind() <= BuiltinType::UInt128;
2236 if (
const auto *ET = dyn_cast<EnumType>(CanonicalType)) {
2239 if (ET->getDecl()->isComplete() && !ET->getDecl()->isScoped())
2243 if (
const auto *IT = dyn_cast<BitIntType>(CanonicalType))
2244 return IT->isUnsigned();
2245 if (
const auto *IT = dyn_cast<DependentBitIntType>(CanonicalType))
2246 return IT->isUnsigned();
2252 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType)) {
2253 return BT->getKind() >= BuiltinType::Bool &&
2254 BT->getKind() <= BuiltinType::UInt128;
2257 if (
const auto *ET = dyn_cast<EnumType>(CanonicalType)) {
2258 if (ET->getDecl()->isComplete())
2262 if (
const auto *IT = dyn_cast<BitIntType>(CanonicalType))
2263 return IT->isUnsigned();
2264 if (
const auto *IT = dyn_cast<DependentBitIntType>(CanonicalType))
2265 return IT->isUnsigned();
2271 if (
const auto *VT = dyn_cast<VectorType>(CanonicalType))
2272 return VT->getElementType()->isUnsignedIntegerOrEnumerationType();
2273 if (
const auto *VT = dyn_cast<MatrixType>(CanonicalType))
2274 return VT->getElementType()->isUnsignedIntegerOrEnumerationType();
2275 if (CanonicalType->isSveVLSBuiltinType()) {
2276 const auto *VT = cast<BuiltinType>(CanonicalType);
2277 return VT->getKind() >= BuiltinType::SveUint8 &&
2278 VT->getKind() <= BuiltinType::SveUint64;
2284 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
2285 return BT->getKind() >= BuiltinType::Half &&
2286 BT->getKind() <= BuiltinType::Ibm128;
2287 if (
const auto *CT = dyn_cast<ComplexType>(CanonicalType))
2288 return CT->getElementType()->isFloatingType();
2293 if (
const auto *VT = dyn_cast<VectorType>(CanonicalType))
2294 return VT->getElementType()->isFloatingType();
2295 if (
const auto *MT = dyn_cast<MatrixType>(CanonicalType))
2296 return MT->getElementType()->isFloatingType();
2301 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
2302 return BT->isFloatingPoint();
2307 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
2308 return BT->getKind() >= BuiltinType::Bool &&
2309 BT->getKind() <= BuiltinType::Ibm128;
2310 if (
const auto *ET = dyn_cast<EnumType>(CanonicalType))
2311 return ET->getDecl()->isComplete() && !ET->getDecl()->isScoped();
2316 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
2317 return BT->getKind() >= BuiltinType::Bool &&
2318 BT->getKind() <= BuiltinType::Ibm128;
2319 if (
const auto *ET = dyn_cast<EnumType>(CanonicalType))
2326 return !ET->getDecl()->isScoped() && ET->getDecl()->isComplete();
2327 return isa<ComplexType>(CanonicalType) ||
isBitIntType();
2333 const Type *
T = CanonicalType.getTypePtr();
2334 if (
const auto *BT = dyn_cast<BuiltinType>(
T)) {
2335 if (BT->getKind() == BuiltinType::Bool)
return STK_Bool;
2336 if (BT->getKind() == BuiltinType::NullPtr)
return STK_CPointer;
2340 llvm_unreachable(
"unknown scalar builtin type");
2341 }
else if (isa<PointerType>(
T)) {
2343 }
else if (isa<BlockPointerType>(
T)) {
2345 }
else if (isa<ObjCObjectPointerType>(
T)) {
2347 }
else if (isa<MemberPointerType>(
T)) {
2349 }
else if (isa<EnumType>(
T)) {
2350 assert(cast<EnumType>(
T)->getDecl()->isComplete());
2352 }
else if (
const auto *CT = dyn_cast<ComplexType>(
T)) {
2353 if (CT->getElementType()->isRealFloatingType())
2360 llvm_unreachable(
"unknown scalar type");
2373 if (
const auto *
Record = dyn_cast<RecordType>(CanonicalType)) {
2374 if (
const auto *ClassDecl = dyn_cast<CXXRecordDecl>(
Record->getDecl()))
2375 return ClassDecl->isAggregate();
2380 return isa<ArrayType>(CanonicalType);
2387 assert(!
isIncompleteType() &&
"This doesn't make sense for incomplete types");
2388 assert(!
isDependentType() &&
"This doesn't make sense for dependent types");
2390 return !isa<VariableArrayType>(CanonicalType);
2400 switch (CanonicalType->getTypeClass()) {
2401 default:
return false;
2407 EnumDecl *EnumD = cast<EnumType>(CanonicalType)->getDecl();
2415 RecordDecl *Rec = cast<RecordType>(CanonicalType)->getDecl();
2420 case InjectedClassName: {
2421 CXXRecordDecl *Rec = cast<InjectedClassNameType>(CanonicalType)->getDecl();
2434 return cast<ArrayType>(CanonicalType)->getElementType()
2435 ->isIncompleteType(Def);
2436 case IncompleteArray:
2439 case MemberPointer: {
2443 auto *MPTy = cast<MemberPointerType>(CanonicalType);
2444 const Type *ClassTy = MPTy->getClass();
2457 if (RD->
hasAttr<MSInheritanceAttr>())
2462 return cast<ObjCObjectType>(CanonicalType)->getBaseType()
2463 ->isIncompleteType(Def);
2464 case ObjCInterface: {
2467 = cast<ObjCInterfaceType>(CanonicalType)->getDecl();
2479 if (
const BuiltinType *BT = getAs<BuiltinType>()) {
2480 switch (BT->getKind()) {
2482#define WASM_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
2483#include "clang/Basic/WebAssemblyReferenceTypes.def"
2485#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
2486#include "clang/Basic/HLSLIntangibleTypes.def"
2496 if (
const auto *BT = getAs<BuiltinType>())
2497 return BT->getKind() == BuiltinType::WasmExternRef;
2502 if (
const auto *ATy = dyn_cast<ArrayType>(
this))
2503 return ATy->getElementType().isWebAssemblyReferenceType();
2505 if (
const auto *PTy = dyn_cast<PointerType>(
this))
2506 return PTy->getPointeeType().isWebAssemblyReferenceType();
2518 if (
const BuiltinType *BT = getAs<BuiltinType>()) {
2519 switch (BT->getKind()) {
2521#define SVE_VECTOR_TYPE(Name, MangledName, Id, SingletonId) \
2522 case BuiltinType::Id: \
2524#define SVE_OPAQUE_TYPE(Name, MangledName, Id, SingletonId) \
2525 case BuiltinType::Id: \
2527#define SVE_PREDICATE_TYPE(Name, MangledName, Id, SingletonId) \
2528 case BuiltinType::Id: \
2530#define AARCH64_VECTOR_TYPE(Name, MangledName, Id, SingletonId) \
2531 case BuiltinType::Id: \
2533#include "clang/Basic/AArch64SVEACLETypes.def"
2542 if (
const BuiltinType *BT = getAs<BuiltinType>()) {
2543 switch (BT->getKind()) {
2544#define RVV_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
2545#include "clang/Basic/RISCVVTypes.def"
2555 if (
const BuiltinType *BT = getAs<BuiltinType>()) {
2556 switch (BT->getKind()) {
2557 case BuiltinType::SveInt8:
2558 case BuiltinType::SveInt16:
2559 case BuiltinType::SveInt32:
2560 case BuiltinType::SveInt64:
2561 case BuiltinType::SveUint8:
2562 case BuiltinType::SveUint16:
2563 case BuiltinType::SveUint32:
2564 case BuiltinType::SveUint64:
2565 case BuiltinType::SveFloat16:
2566 case BuiltinType::SveFloat32:
2567 case BuiltinType::SveFloat64:
2568 case BuiltinType::SveBFloat16:
2569 case BuiltinType::SveBool:
2570 case BuiltinType::SveBoolx2:
2571 case BuiltinType::SveBoolx4:
2572 case BuiltinType::SveMFloat8:
2590 llvm_unreachable(
"Unhandled type");
2597 if (BTy->
getKind() == BuiltinType::SveBool)
2607 if (
const BuiltinType *BT = getAs<BuiltinType>()) {
2608 switch (BT->getKind()) {
2609#define RVV_VECTOR_TYPE(Name, Id, SingletonId, NumEls, ElBits, NF, IsSigned, \
2611 case BuiltinType::Id: \
2613#define RVV_PREDICATE_TYPE(Name, Id, SingletonId, NumEls) \
2614 case BuiltinType::Id: \
2616#include "clang/Basic/RISCVVTypes.def"
2630#define RVV_PREDICATE_TYPE(Name, Id, SingletonId, NumEls) \
2631 case BuiltinType::Id: \
2632 return Ctx.UnsignedCharTy;
2635#include "clang/Basic/RISCVVTypes.def"
2638 llvm_unreachable(
"Unhandled type");
2656 if ((*this)->isIncompleteArrayType())
2659 if ((*this)->isIncompleteType())
2668 default:
return false;
2669 case Type::VariableArray:
2670 case Type::ConstantArray:
2674 case Type::ObjCObjectPointer:
2675 case Type::BlockPointer:
2679 case Type::MemberPointer:
2681 case Type::ExtVector:
2689 if (
const auto *ClassDecl =
2690 dyn_cast<CXXRecordDecl>(cast<RecordType>(CanonicalType)->getDecl()))
2691 return ClassDecl->isPOD();
2705 if ((*this)->isArrayType())
2708 if ((*this)->isSizelessBuiltinType())
2713 if ((*this)->isIncompleteType())
2732 if (
const auto *ClassDecl = dyn_cast<CXXRecordDecl>(RT->getDecl())) {
2739 return ClassDecl->hasTrivialDefaultConstructor() &&
2740 !ClassDecl->hasNonTrivialDefaultConstructor() &&
2741 ClassDecl->isTriviallyCopyable();
2753 bool IsCopyConstructible) {
2754 if (
type->isArrayType())
2756 Context, IsCopyConstructible);
2758 if (
type.hasNonTrivialObjCLifetime())
2783 if (
const auto *ClassDecl = dyn_cast<CXXRecordDecl>(RT->getDecl())) {
2784 if (IsCopyConstructible) {
2785 return ClassDecl->isTriviallyCopyConstructible();
2787 return ClassDecl->isTriviallyCopyable();
2804 if (CanonicalType.hasNonTrivialObjCLifetime())
2806 if (CanonicalType->isArrayType())
2810 if (CanonicalType->isIncompleteType())
2812 const auto *RD = CanonicalType->getAsRecordDecl();
2819 if (RD->mayInsertExtraPadding())
2822 for (
auto *
const Field : RD->fields()) {
2823 if (!Field->getType().isBitwiseCloneableType(Context))
2827 if (
const auto *CXXRD = dyn_cast<CXXRecordDecl>(RD)) {
2828 for (
auto Base : CXXRD->bases())
2829 if (!
Base.getType().isBitwiseCloneableType(Context))
2831 for (
auto VBase : CXXRD->vbases())
2832 if (!VBase.getType().isBitwiseCloneableType(Context))
2852 return RD->canPassInRegisters();
2900 if (
const auto *RT =
2901 getTypePtr()->getBaseElementTypeUnsafe()->getAs<RecordType>())
2902 if (RT->getDecl()->isNonTrivialToPrimitiveDefaultInitialize())
2916 if (
const auto *RT =
2917 getTypePtr()->getBaseElementTypeUnsafe()->getAs<RecordType>())
2918 if (RT->getDecl()->isNonTrivialToPrimitiveCopy())
2954 assert(BaseTy &&
"NULL element type");
2984 if (
const auto *ClassDecl = dyn_cast<CXXRecordDecl>(RT->getDecl()))
2985 return ClassDecl->isLiteral();
2992 return AT->getValueType()->isLiteralType(Ctx);
3014 return RD->isStructural();
3027 assert(BaseTy &&
"NULL element type");
3037 if (
const auto *ClassDecl = dyn_cast<CXXRecordDecl>(RT->getDecl()))
3038 if (!ClassDecl->isStandardLayout())
3066 assert(BaseTy &&
"NULL element type");
3079 if (
const auto *ClassDecl = dyn_cast<CXXRecordDecl>(RT->getDecl())) {
3082 if (!ClassDecl->isTrivial())
return false;
3087 if (!ClassDecl->isStandardLayout())
return false;
3116 if (
const auto *ET = getAs<EnumType>()) {
3118 if (II && II->
isStr(
"align_val_t") && ET->getDecl()->isInStdNamespace())
3125 if (
const auto *ET = getAs<EnumType>()) {
3127 if (II && II->
isStr(
"byte") && ET->getDecl()->isInStdNamespace())
3143 case TemplateTypeParm:
3144 case SubstTemplateTypeParm:
3145 case TemplateSpecialization:
3148 case DependentTemplateSpecialization:
3192 llvm_unreachable(
"Type specifier is not a tag type kind.");
3209 llvm_unreachable(
"Unknown tag type kind.");
3227 llvm_unreachable(
"Elaborated type keyword is not a tag type kind.");
3229 llvm_unreachable(
"Unknown elaborated type keyword.");
3245 llvm_unreachable(
"Unknown elaborated type keyword.");
3259 return "__interface";
3266 llvm_unreachable(
"Unknown elaborated type keyword.");
3269DependentTemplateSpecializationType::DependentTemplateSpecializationType(
3276 NNS(NNS), Name(Name) {
3279 "DependentTemplateSpecializatonType requires dependent qualifier");
3280 auto *ArgBuffer =
const_cast<TemplateArgument *
>(template_arguments().data());
3283 TemplateArgumentDependence::UnexpandedPack));
3296 ID.AddInteger(llvm::to_underlying(Keyword));
3297 ID.AddPointer(Qualifier);
3298 ID.AddPointer(Name);
3300 Arg.Profile(ID, Context);
3305 if (
const auto *Elab = dyn_cast<ElaboratedType>(
this))
3306 Keyword = Elab->getKeyword();
3307 else if (
const auto *DepName = dyn_cast<DependentNameType>(
this))
3308 Keyword = DepName->getKeyword();
3309 else if (
const auto *DepTST =
3310 dyn_cast<DependentTemplateSpecializationType>(
this))
3311 Keyword = DepTST->getKeyword();
3320#define ABSTRACT_TYPE(Derived, Base)
3321#define TYPE(Derived, Base) case Derived: return #Derived;
3322#include "clang/AST/TypeNodes.inc"
3325 llvm_unreachable(
"Invalid type class.");
3333 return Policy.
Bool ?
"bool" :
"_Bool";
3339 return "signed char";
3351 return "unsigned char";
3353 return "unsigned short";
3355 return "unsigned int";
3357 return "unsigned long";
3359 return "unsigned long long";
3361 return "unsigned __int128";
3363 return Policy.
Half ?
"half" :
"__fp16";
3371 return "long double";
3373 return "short _Accum";
3377 return "long _Accum";
3379 return "unsigned short _Accum";
3381 return "unsigned _Accum";
3383 return "unsigned long _Accum";
3384 case BuiltinType::ShortFract:
3385 return "short _Fract";
3386 case BuiltinType::Fract:
3388 case BuiltinType::LongFract:
3389 return "long _Fract";
3390 case BuiltinType::UShortFract:
3391 return "unsigned short _Fract";
3392 case BuiltinType::UFract:
3393 return "unsigned _Fract";
3394 case BuiltinType::ULongFract:
3395 return "unsigned long _Fract";
3396 case BuiltinType::SatShortAccum:
3397 return "_Sat short _Accum";
3398 case BuiltinType::SatAccum:
3399 return "_Sat _Accum";
3400 case BuiltinType::SatLongAccum:
3401 return "_Sat long _Accum";
3402 case BuiltinType::SatUShortAccum:
3403 return "_Sat unsigned short _Accum";
3404 case BuiltinType::SatUAccum:
3405 return "_Sat unsigned _Accum";
3406 case BuiltinType::SatULongAccum:
3407 return "_Sat unsigned long _Accum";
3408 case BuiltinType::SatShortFract:
3409 return "_Sat short _Fract";
3410 case BuiltinType::SatFract:
3411 return "_Sat _Fract";
3412 case BuiltinType::SatLongFract:
3413 return "_Sat long _Fract";
3414 case BuiltinType::SatUShortFract:
3415 return "_Sat unsigned short _Fract";
3416 case BuiltinType::SatUFract:
3417 return "_Sat unsigned _Fract";
3418 case BuiltinType::SatULongFract:
3419 return "_Sat unsigned long _Fract";
3423 return "__float128";
3428 return Policy.
MSWChar ?
"__wchar_t" :
"wchar_t";
3438 return "<overloaded function type>";
3440 return "<bound member function type>";
3441 case UnresolvedTemplate:
3442 return "<unresolved template type>";
3444 return "<pseudo-object type>";
3446 return "<dependent type>";
3448 return "<unknown type>";
3449 case ARCUnbridgedCast:
3450 return "<ARC unbridged cast type>";
3452 return "<builtin fn type>";
3459#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
3461 return "__" #Access " " #ImgType "_t";
3462#include "clang/Basic/OpenCLImageTypes.def"
3468 return "clk_event_t";
3472 return "reserve_id_t";
3473 case IncompleteMatrixIdx:
3474 return "<incomplete matrix index type>";
3476 return "<array section type>";
3477 case OMPArrayShaping:
3478 return "<OpenMP array shaping type>";
3480 return "<OpenMP iterator type>";
3481#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \
3484#include "clang/Basic/OpenCLExtensionTypes.def"
3485#define SVE_TYPE(Name, Id, SingletonId) \
3488#include "clang/Basic/AArch64SVEACLETypes.def"
3489#define PPC_VECTOR_TYPE(Name, Id, Size) \
3492#include "clang/Basic/PPCTypes.def"
3493#define RVV_TYPE(Name, Id, SingletonId) \
3496#include "clang/Basic/RISCVVTypes.def"
3497#define WASM_TYPE(Name, Id, SingletonId) \
3500#include "clang/Basic/WebAssemblyReferenceTypes.def"
3501#define AMDGPU_TYPE(Name, Id, SingletonId, Width, Align) \
3504#include "clang/Basic/AMDGPUTypes.def"
3505#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) \
3508#include "clang/Basic/HLSLIntangibleTypes.def"
3511 llvm_unreachable(
"Invalid builtin type.");
3516 if (
auto *PET = dyn_cast<PackExpansionType>(
getTypePtr()))
3517 return PET->getPattern();
3522 if (
const auto *RefType =
getTypePtr()->getAs<ReferenceType>())
3539 case CC_C:
return "cdecl";
3567 llvm_unreachable(
"Invalid calling convention.");
3585 assert(
getNumParams() == params.size() &&
"NumParams overflow!");
3593 auto &ExtraBits = *getTrailingObjects<FunctionTypeExtraBitfields>();
3600 auto &ArmTypeAttrs = *getTrailingObjects<FunctionTypeArmAttributes>();
3601 ArmTypeAttrs = FunctionTypeArmAttributes();
3604 auto &ExtraBits = *getTrailingObjects<FunctionTypeExtraBitfields>();
3605 ExtraBits.HasArmTypeAttributes =
true;
3609 auto *argSlot = getTrailingObjects<QualType>();
3612 ~TypeDependence::VariablyModified);
3613 argSlot[i] = params[i];
3618 auto &ArmTypeAttrs = *getTrailingObjects<FunctionTypeArmAttributes>();
3620 "Not enough bits to encode SME attributes");
3626 auto &ExtraBits = *getTrailingObjects<FunctionTypeExtraBitfields>();
3628 assert(NumExceptions <= 1023 &&
"Not enough bits to encode exceptions");
3629 ExtraBits.NumExceptionType = NumExceptions;
3631 assert(hasExtraBitfields() &&
"missing trailing extra bitfields!");
3633 reinterpret_cast<QualType *
>(getTrailingObjects<ExceptionType>());
3641 (TypeDependence::Instantiation | TypeDependence::UnexpandedPack));
3643 exnSlot[I++] = ExceptionType;
3657 (TypeDependence::Instantiation | TypeDependence::UnexpandedPack));
3663 auto **slot = getTrailingObjects<FunctionDecl *>();
3671 auto **slot = getTrailingObjects<FunctionDecl *>();
3690 auto *extParamInfos = getTrailingObjects<ExtParameterInfo>();
3697 *getTrailingObjects<Qualifiers>() = epi.
TypeQuals;
3704 auto &EllipsisLoc = *getTrailingObjects<SourceLocation>();
3709 auto &ExtraBits = *getTrailingObjects<FunctionTypeExtraBitfields>();
3711 ExtraBits.NumFunctionEffects = EffectsCount;
3712 assert(ExtraBits.NumFunctionEffects == EffectsCount &&
3713 "effect bitfield overflow");
3716 auto *DestFX = getTrailingObjects<FunctionEffect>();
3717 std::uninitialized_copy(SrcFX.begin(), SrcFX.end(), DestFX);
3720 if (!SrcConds.empty()) {
3721 ExtraBits.EffectsHaveConditions =
true;
3722 auto *DestConds = getTrailingObjects<EffectConditionExpr>();
3723 std::uninitialized_copy(SrcConds.begin(), SrcConds.end(), DestConds);
3724 assert(std::any_of(SrcConds.begin(), SrcConds.end(),
3726 if (const Expr *E = EC.getCondition())
3727 return E->isTypeDependent() ||
3728 E->isValueDependent();
3731 "expected a dependent expression among the conditions");
3739 return NE->isValueDependent();
3751 return NE->isInstantiationDependent();
3762 llvm_unreachable(
"should not call this with unresolved exception specs");
3788 llvm_unreachable(
"unexpected exception specification kind");
3792 for (
unsigned ArgIdx =
getNumParams(); ArgIdx; --ArgIdx)
3800 const QualType *ArgTys,
unsigned NumParams,
3801 const ExtProtoInfo &epi,
3824 ID.AddPointer(
Result.getAsOpaquePtr());
3825 for (
unsigned i = 0; i != NumParams; ++i)
3826 ID.AddPointer(ArgTys[i].getAsOpaquePtr());
3830 assert(!(
unsigned(epi.Variadic) & ~1) &&
3831 !(
unsigned(epi.RefQualifier) & ~3) &&
3832 !(
unsigned(epi.ExceptionSpec.Type) & ~15) &&
3833 "Values larger than expected.");
3834 ID.AddInteger(
unsigned(epi.Variadic) +
3835 (epi.RefQualifier << 1) +
3836 (epi.ExceptionSpec.Type << 3));
3837 ID.Add(epi.TypeQuals);
3839 for (
QualType Ex : epi.ExceptionSpec.Exceptions)
3842 epi.ExceptionSpec.NoexceptExpr->Profile(ID, Context, Canonical);
3845 ID.AddPointer(epi.ExceptionSpec.SourceDecl->getCanonicalDecl());
3847 if (epi.ExtParameterInfos) {
3848 for (
unsigned i = 0; i != NumParams; ++i)
3849 ID.AddInteger(epi.ExtParameterInfos[i].getOpaqueValue());
3852 epi.ExtInfo.Profile(ID);
3854 unsigned EffectCount = epi.FunctionEffects.size();
3855 bool HasConds = !epi.FunctionEffects.Conditions.empty();
3857 ID.AddInteger((EffectCount << 3) | (HasConds << 2) |
3858 (epi.AArch64SMEAttributes << 1) | epi.HasTrailingReturn);
3860 for (
unsigned Idx = 0; Idx != EffectCount; ++Idx) {
3861 ID.AddInteger(epi.FunctionEffects.Effects[Idx].toOpaqueInt32());
3863 ID.AddPointer(epi.FunctionEffects.Conditions[Idx].getCondition());
3874 :
Data(
D, Deref << DerefShift) {}
3877 return Data.getInt() & DerefMask;
3882 return Data.getOpaqueValue();
3889 Data.setFromOpaqueValue(
V);
3894 :
Type(TC, Canon, Wrapped->getDependence()), WrappedTy(Wrapped) {}
3896CountAttributedType::CountAttributedType(
3900 CountExpr(CountExpr) {
3904 auto *DeclSlot = getTrailingObjects<TypeCoupledDeclRefInfo>();
3906 for (
unsigned i = 0; i != CoupledDecls.size(); ++i)
3907 DeclSlot[i] = CoupledDecls[i];
3914 assert(!isa<TypedefType>(can) &&
"Invalid canonical type");
3916 if (!typeMatchesDecl())
3917 *getTrailingObjects<QualType>() = Underlying;
3922 : *getTrailingObjects<QualType>();
3931 *getTrailingObjects<QualType>() = Underlying;
3937 cast<TypeDecl>(
Found->getTargetDecl())->getTypeForDecl(), 0)
3938 : *getTrailingObjects<QualType>();
3947 while (
auto *InnerMQT = dyn_cast<MacroQualifiedType>(Inner)) {
3950 Inner = InnerMQT->getModifiedType();
3961 ? Context.getUnqualifiedArrayType(Can).getAtomicUnqualifiedType()
3964 (
E->getType()->getDependence() &
3966 TOExpr(
E), Context(Context) {
3967 TypeOfBits.Kind =
static_cast<unsigned>(Kind);
3988 ID.AddBoolean(IsUnqual);
3995 ? Context.getUnqualifiedArrayType(Can).getAtomicUnqualifiedType()
3997 T->getDependence()),
3998 TOType(
T), Context(Context) {
3999 TypeOfBits.Kind =
static_cast<unsigned>(Kind);
4013 :
Type(Decltype, can,
4017 (
E->getType()->getDependence() &
4019 E(
E), UnderlyingType(underlyingType) {}
4040 Expr *IndexExpr,
bool FullySubstituted,
4042 :
Type(PackIndexing, Canonical,
4044 Context(Context), Pattern(Pattern), IndexExpr(IndexExpr),
4045 Size(Expansions.size()), FullySubstituted(FullySubstituted) {
4047 std::uninitialized_copy(Expansions.begin(), Expansions.end(),
4048 getTrailingObjects<QualType>());
4053 return std::nullopt;
4057 return std::nullopt;
4059 assert(Index.isNonNegative() &&
"Invalid index");
4060 return static_cast<unsigned>(Index.getExtValue());
4064PackIndexingType::computeDependence(
QualType Pattern,
Expr *IndexExpr,
4069 ? TypeDependence::DependentInstantiation
4070 : TypeDependence::None);
4071 if (Expansions.empty())
4072 TD |= Pattern->
getDependence() & TypeDependence::DependentInstantiation;
4077 if (!(IndexD & TypeDependence::UnexpandedPack))
4078 TD &= ~TypeDependence::UnexpandedPack;
4083 TD |= TypeDependence::Error | TypeDependence::DependentInstantiation;
4090 Expr *
E,
bool FullySubstituted) {
4093 ID.AddBoolean(FullySubstituted);
4099 :
Type(UnaryTransform, CanonicalType, BaseType->getDependence()),
4100 BaseType(BaseType), UnderlyingType(UnderlyingType), UKind(UKind) {}
4114 for (
auto *I :
decl->redecls()) {
4115 if (I->isCompleteDefinition() || I->isBeingDefined())
4131 std::vector<const RecordType*> RecordTypeList;
4132 RecordTypeList.push_back(
this);
4133 unsigned NextToCheckIndex = 0;
4135 while (RecordTypeList.size() > NextToCheckIndex) {
4137 RecordTypeList[NextToCheckIndex]->
getDecl()->fields()) {
4143 if (!llvm::is_contained(RecordTypeList, FieldRecTy))
4144 RecordTypeList.push_back(FieldRecTy);
4152AttributedType::AttributedType(
QualType canon,
const Attr *attr,
4159 :
Type(Attributed, canon, equivalent->getDependence()), Attribute(
attr),
4160 ModifiedType(modified), EquivalentType(equivalent) {
4162 assert(!attr ||
attr->getKind() == attrKind);
4172 case attr::ObjCOwnership:
4173 case attr::ObjCInertUnsafeUnretained:
4174 case attr::TypeNonNull:
4175 case attr::TypeNullable:
4176 case attr::TypeNullableResult:
4177 case attr::TypeNullUnspecified:
4178 case attr::LifetimeBound:
4179 case attr::AddressSpace:
4192 default:
return false;
4199 llvm_unreachable(
"invalid attr kind");
4209 default:
return false;
4212 case attr::FastCall:
4214 case attr::ThisCall:
4216 case attr::SwiftCall:
4217 case attr::SwiftAsyncCall:
4218 case attr::VectorCall:
4219 case attr::AArch64VectorPcs:
4220 case attr::AArch64SVEPcs:
4221 case attr::AMDGPUKernelCall:
4225 case attr::IntelOclBicc:
4226 case attr::PreserveMost:
4227 case attr::PreserveAll:
4229 case attr::PreserveNone:
4230 case attr::RISCVVectorCC:
4233 llvm_unreachable(
"invalid attr kind");
4246 if (
const auto *TTP = dyn_cast<TemplateTypeParmDecl>(
D))
4248 return cast<TemplateTypeParmDecl>(
4252SubstTemplateTypeParmType::SubstTemplateTypeParmType(
4253 QualType Replacement,
Decl *AssociatedDecl,
unsigned Index,
4255 :
Type(SubstTemplateTypeParm, Replacement.getCanonicalType(),
4256 Replacement->getDependence()),
4257 AssociatedDecl(AssociatedDecl) {
4258 SubstTemplateTypeParmTypeBits.HasNonCanonicalUnderlyingType =
4259 Replacement != getCanonicalTypeInternal();
4260 if (SubstTemplateTypeParmTypeBits.HasNonCanonicalUnderlyingType)
4261 *getTrailingObjects<QualType>() = Replacement;
4263 SubstTemplateTypeParmTypeBits.Index = Index;
4264 SubstTemplateTypeParmTypeBits.PackIndex = PackIndex ? *PackIndex + 1 : 0;
4265 SubstTemplateTypeParmTypeBits.SubstitutionFlag = llvm::to_underlying(Flag);
4266 assert((Flag != SubstTemplateTypeParmTypeFlag::ExpandPacksInPlace ||
4268 "ExpandPacksInPlace needs a valid PackIndex");
4269 assert(AssociatedDecl !=
nullptr);
4277SubstTemplateTypeParmPackType::SubstTemplateTypeParmPackType(
4278 QualType Canon,
Decl *AssociatedDecl,
unsigned Index,
bool Final,
4280 :
Type(SubstTemplateTypeParmPack, Canon,
4283 Arguments(ArgPack.pack_begin()),
4284 AssociatedDeclAndFinal(AssociatedDecl, Final) {
4287 assert(AssociatedDecl !=
nullptr);
4291 return AssociatedDeclAndFinal.getPointer();
4295 return AssociatedDeclAndFinal.getInt();
4316 const Decl *AssociatedDecl,
4317 unsigned Index,
bool Final,
4319 ID.AddPointer(AssociatedDecl);
4320 ID.AddInteger(Index);
4321 ID.AddBoolean(Final);
4324 ID.AddPointer(
P.getAsType().getAsOpaquePtr());
4335 if (Arg.isDependent())
4343 if (ArgLoc.getArgument().isInstantiationDependent())
4349TemplateSpecializationType::TemplateSpecializationType(
4352 :
Type(TemplateSpecialization, Canon.isNull() ?
QualType(this, 0) : Canon,
4362 assert(!
T.getAsDependentTemplateName() &&
4363 "Use DependentTemplateSpecializationType for dependent template-name");
4370 "Unexpected template name for TemplateSpecializationType");
4383 ~TypeDependence::Dependent);
4386 TypeDependence::VariablyModified);
4393 *
reinterpret_cast<QualType *
>(
Begin + Args.size()) = AliasedType;
4398 assert(
isTypeAlias() &&
"not a type alias template specialization");
4416 Arg.Profile(ID, Context);
4441 ID.AddInteger(typeArgs.size());
4442 for (
auto typeArg : typeArgs)
4443 ID.AddPointer(typeArg.getAsOpaquePtr());
4444 ID.AddInteger(protocols.size());
4445 for (
auto *proto : protocols)
4446 ID.AddPointer(proto);
4447 ID.AddBoolean(isKindOf);
4460 ID.AddPointer(OTPDecl);
4462 ID.AddInteger(protocols.size());
4463 for (
auto *proto : protocols)
4464 ID.AddPointer(proto);
4475class CachedProperties {
4480 CachedProperties(
Linkage L,
bool local) : L(L), local(local) {}
4482 Linkage getLinkage()
const {
return L; }
4483 bool hasLocalOrUnnamedType()
const {
return local; }
4485 friend CachedProperties merge(CachedProperties L, CachedProperties R) {
4487 return CachedProperties(MergedLinkage, L.hasLocalOrUnnamedType() ||
4488 R.hasLocalOrUnnamedType());
4504 return get(
T.getTypePtr());
4509 return CachedProperties(
T->
TypeBits.getLinkage(),
4551#define TYPE(Class,Base)
4552#define NON_CANONICAL_TYPE(Class,Base) case Type::Class:
4553#include "clang/AST/TypeNodes.inc"
4554 llvm_unreachable(
"didn't expect a non-canonical type here");
4556#define TYPE(Class,Base)
4557#define DEPENDENT_TYPE(Class,Base) case Type::Class:
4558#define NON_CANONICAL_UNLESS_DEPENDENT_TYPE(Class,Base) case Type::Class:
4559#include "clang/AST/TypeNodes.inc"
4565 case Type::DeducedTemplateSpecialization:
4579 const TagDecl *Tag = cast<TagType>(
T)->getDecl();
4585 Linkage L = Tag->getLinkageInternal();
4586 bool IsLocalOrUnnamed =
4587 Tag->getDeclContext()->isFunctionOrMethod() ||
4588 !Tag->hasNameForLinkage();
4589 return CachedProperties(L, IsLocalOrUnnamed);
4596 return Cache::get(cast<ComplexType>(
T)->getElementType());
4599 case Type::BlockPointer:
4601 case Type::LValueReference:
4602 case Type::RValueReference:
4604 case Type::MemberPointer: {
4605 const auto *MPT = cast<MemberPointerType>(
T);
4609 case Type::ConstantArray:
4610 case Type::IncompleteArray:
4611 case Type::VariableArray:
4612 case Type::ArrayParameter:
4613 return Cache::get(cast<ArrayType>(
T)->getElementType());
4615 case Type::ExtVector:
4616 return Cache::get(cast<VectorType>(
T)->getElementType());
4617 case Type::ConstantMatrix:
4618 return Cache::get(cast<ConstantMatrixType>(
T)->getElementType());
4619 case Type::FunctionNoProto:
4620 return Cache::get(cast<FunctionType>(
T)->getReturnType());
4621 case Type::FunctionProto: {
4622 const auto *FPT = cast<FunctionProtoType>(
T);
4623 CachedProperties result =
Cache::get(FPT->getReturnType());
4624 for (
const auto &ai : FPT->param_types())
4628 case Type::ObjCInterface: {
4629 Linkage L = cast<ObjCInterfaceType>(
T)->getDecl()->getLinkageInternal();
4630 return CachedProperties(L,
false);
4632 case Type::ObjCObject:
4633 return Cache::get(cast<ObjCObjectType>(
T)->getBaseType());
4634 case Type::ObjCObjectPointer:
4637 return Cache::get(cast<AtomicType>(
T)->getValueType());
4639 return Cache::get(cast<PipeType>(
T)->getElementType());
4640 case Type::HLSLAttributedResource:
4641 return Cache::get(cast<HLSLAttributedResourceType>(
T)->getWrappedType());
4644 llvm_unreachable(
"unhandled type class");
4655 return TypeBits.hasLocalOrUnnamedType();
4660#define TYPE(Class,Base)
4661#define NON_CANONICAL_TYPE(Class,Base) case Type::Class:
4662#include "clang/AST/TypeNodes.inc"
4663 llvm_unreachable(
"didn't expect a non-canonical type here");
4665#define TYPE(Class,Base)
4666#define DEPENDENT_TYPE(Class,Base) case Type::Class:
4667#define NON_CANONICAL_UNLESS_DEPENDENT_TYPE(Class,Base) case Type::Class:
4668#include "clang/AST/TypeNodes.inc"
4678 case Type::DeducedTemplateSpecialization:
4689 case Type::BlockPointer:
4691 case Type::LValueReference:
4692 case Type::RValueReference:
4694 case Type::MemberPointer: {
4695 const auto *MPT = cast<MemberPointerType>(
T);
4700 case Type::ConstantArray:
4701 case Type::IncompleteArray:
4702 case Type::VariableArray:
4703 case Type::ArrayParameter:
4706 case Type::ExtVector:
4708 case Type::ConstantMatrix:
4710 cast<ConstantMatrixType>(
T)->getElementType());
4711 case Type::FunctionNoProto:
4713 case Type::FunctionProto: {
4714 const auto *FPT = cast<FunctionProtoType>(
T);
4716 for (
const auto &ai : FPT->param_types())
4720 case Type::ObjCInterface:
4722 case Type::ObjCObject:
4724 case Type::ObjCObjectPointer:
4731 case Type::HLSLAttributedResource:
4733 ->getContainedType()
4734 ->getCanonicalTypeInternal());
4737 llvm_unreachable(
"unhandled type class");
4768 if (
auto Nullability = AT->getImmediateNullability())
4771 Type = AT->getEquivalentType();
4773 return std::nullopt;
4779 switch (
type->getTypeClass()) {
4781#define NON_CANONICAL_TYPE(Class, Parent) \
4783 llvm_unreachable("non-canonical type");
4784#define TYPE(Class, Parent)
4785#include "clang/AST/TypeNodes.inc"
4789 case Type::BlockPointer:
4790 case Type::MemberPointer:
4791 case Type::ObjCObjectPointer:
4795 case Type::UnresolvedUsing:
4796 case Type::TypeOfExpr:
4798 case Type::Decltype:
4799 case Type::PackIndexing:
4800 case Type::UnaryTransform:
4801 case Type::TemplateTypeParm:
4802 case Type::SubstTemplateTypeParmPack:
4803 case Type::DependentName:
4804 case Type::DependentTemplateSpecialization:
4806 return ResultIfUnknown;
4809 case Type::TemplateSpecialization:
4812 cast<TemplateSpecializationType>(
type.getTypePtr())
4814 .getAsTemplateDecl())
4815 if (
auto *CTD = dyn_cast<ClassTemplateDecl>(templateDecl))
4816 return llvm::any_of(
4818 return RTD->getTemplatedDecl()->hasAttr<TypeNullableAttr>();
4820 return ResultIfUnknown;
4823 switch (cast<BuiltinType>(
type.getTypePtr())->getKind()) {
4825#define SIGNED_TYPE(Id, SingletonId) case BuiltinType::Id:
4826#define UNSIGNED_TYPE(Id, SingletonId) case BuiltinType::Id:
4827#define FLOATING_TYPE(Id, SingletonId) case BuiltinType::Id:
4828#define BUILTIN_TYPE(Id, SingletonId)
4829#include "clang/AST/BuiltinTypes.def"
4832 case BuiltinType::UnresolvedTemplate:
4834 case BuiltinType::Dependent:
4835 case BuiltinType::Overload:
4836 case BuiltinType::BoundMember:
4837 case BuiltinType::PseudoObject:
4838 case BuiltinType::UnknownAny:
4839 case BuiltinType::ARCUnbridgedCast:
4840 return ResultIfUnknown;
4842 case BuiltinType::Void:
4843 case BuiltinType::ObjCId:
4844 case BuiltinType::ObjCClass:
4845 case BuiltinType::ObjCSel:
4846#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
4847 case BuiltinType::Id:
4848#include "clang/Basic/OpenCLImageTypes.def"
4849#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \
4850 case BuiltinType::Id:
4851#include "clang/Basic/OpenCLExtensionTypes.def"
4852 case BuiltinType::OCLSampler:
4853 case BuiltinType::OCLEvent:
4854 case BuiltinType::OCLClkEvent:
4855 case BuiltinType::OCLQueue:
4856 case BuiltinType::OCLReserveID:
4857#define SVE_TYPE(Name, Id, SingletonId) \
4858 case BuiltinType::Id:
4859#include "clang/Basic/AArch64SVEACLETypes.def"
4860#define PPC_VECTOR_TYPE(Name, Id, Size) \
4861 case BuiltinType::Id:
4862#include "clang/Basic/PPCTypes.def"
4863#define RVV_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
4864#include "clang/Basic/RISCVVTypes.def"
4865#define WASM_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
4866#include "clang/Basic/WebAssemblyReferenceTypes.def"
4867#define AMDGPU_TYPE(Name, Id, SingletonId, Width, Align) case BuiltinType::Id:
4868#include "clang/Basic/AMDGPUTypes.def"
4869#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
4870#include "clang/Basic/HLSLIntangibleTypes.def"
4871 case BuiltinType::BuiltinFn:
4872 case BuiltinType::NullPtr:
4873 case BuiltinType::IncompleteMatrixIdx:
4874 case BuiltinType::ArraySection:
4875 case BuiltinType::OMPArrayShaping:
4876 case BuiltinType::OMPIterator:
4879 llvm_unreachable(
"unknown builtin type");
4881 case Type::Record: {
4885 if (
const auto *CTSD = dyn_cast<ClassTemplateSpecializationDecl>(RD))
4886 return llvm::any_of(
4887 CTSD->getSpecializedTemplate()->redecls(),
4889 return RTD->getTemplatedDecl()->hasAttr<TypeNullableAttr>();
4892 return RD->hasAttr<TypeNullableAttr>();
4898 case Type::LValueReference:
4899 case Type::RValueReference:
4900 case Type::ConstantArray:
4901 case Type::IncompleteArray:
4902 case Type::VariableArray:
4903 case Type::DependentSizedArray:
4904 case Type::DependentVector:
4905 case Type::DependentSizedExtVector:
4907 case Type::ExtVector:
4908 case Type::ConstantMatrix:
4909 case Type::DependentSizedMatrix:
4910 case Type::DependentAddressSpace:
4911 case Type::FunctionProto:
4912 case Type::FunctionNoProto:
4913 case Type::DeducedTemplateSpecialization:
4915 case Type::InjectedClassName:
4916 case Type::PackExpansion:
4917 case Type::ObjCObject:
4918 case Type::ObjCInterface:
4922 case Type::DependentBitInt:
4923 case Type::ArrayParameter:
4924 case Type::HLSLAttributedResource:
4927 llvm_unreachable(
"bad type kind!");
4939 return std::nullopt;
4942std::optional<NullabilityKind>
4945 if (
auto MacroTy = dyn_cast<MacroQualifiedType>(
T))
4946 AttrTy = MacroTy->getUnderlyingType();
4948 if (
auto attributed = dyn_cast<AttributedType>(AttrTy)) {
4949 if (
auto nullability = attributed->getImmediateNullability()) {
4950 T = attributed->getModifiedType();
4955 return std::nullopt;
4959 const auto *objcPtr = getAs<ObjCObjectPointerType>();
4963 if (objcPtr->isObjCIdType()) {
4974 }
else if (objcPtr->isObjCQualifiedIdType()) {
4999 "cannot query implicit lifetime for non-inferrable type");
5004 while (
const auto *array = dyn_cast<ArrayType>(canon))
5005 canon = array->getElementType().getTypePtr();
5007 if (
const auto *opt = dyn_cast<ObjCObjectPointerType>(canon)) {
5009 if (opt->getObjectType()->isObjCClass())
5017 if (
const auto *
typedefType = getAs<TypedefType>())
5018 return typedefType->getDecl()->hasAttr<ObjCNSObjectAttr>();
5023 if (
const auto *
typedefType = getAs<TypedefType>())
5024 return typedefType->getDecl()->hasAttr<ObjCIndependentClassAttr>();
5037 if (
const auto *OPT = getAs<PointerType>())
5038 return OPT->getPointeeType()->isObjCIndirectLifetimeType();
5039 if (
const auto *Ref = getAs<ReferenceType>())
5040 return Ref->getPointeeType()->isObjCIndirectLifetimeType();
5041 if (
const auto *MemPtr = getAs<MemberPointerType>())
5042 return MemPtr->getPointeeType()->isObjCIndirectLifetimeType();
5050 while (
const ArrayType *array =
type->getAsArrayTypeUnsafe())
5051 type = array->getElementType().getTypePtr();
5052 return type->isObjCRetainableType();
5063 const auto *
Pointer = getAs<PointerType>();