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) &&
117 ND = TT->getOriginalDecl();
141 if (
T.isConstQualified())
145 return AT->getElementType().isConstant(Ctx);
150std::optional<QualType::NonConstantStorageReason>
153 if (!
isConstant(Ctx) && !(*this)->isReferenceType())
161 if (
Record->hasMutableFields())
163 if (!
Record->hasTrivialDestructor() && !ExcludeDtor)
183 et->getDependence() |
189 (tc == DependentSizedArray
199 const llvm::APInt &Sz,
const Expr *SzExpr,
201 bool NeedsExternalSize = SzExpr !=
nullptr || Sz.ugt(0x0FFFFFFFFFFFFFFF) ||
202 Sz.getBitWidth() > 0xFF;
203 if (!NeedsExternalSize)
205 ET, Can, Sz.getBitWidth(), Sz.getZExtValue(), SzMod, Qual);
207 auto *SzPtr =
new (Ctx,
alignof(ConstantArrayType::ExternalSize))
208 ConstantArrayType::ExternalSize(Sz, SzExpr);
216 const llvm::APInt &NumElements) {
225 if (llvm::isPowerOf2_64(ElementSize)) {
226 return NumElements.getActiveBits() + llvm::Log2_64(ElementSize);
231 if ((ElementSize >> 32) == 0 && NumElements.getBitWidth() <= 64 &&
232 (NumElements.getZExtValue() >> 32) == 0) {
233 uint64_t TotalSize = NumElements.getZExtValue() * ElementSize;
234 return llvm::bit_width(TotalSize);
238 llvm::APSInt SizeExtended(NumElements,
true);
240 SizeExtended = SizeExtended.extend(
241 std::max(SizeTypeBits, SizeExtended.getBitWidth()) * 2);
243 llvm::APSInt TotalSize(llvm::APInt(SizeExtended.getBitWidth(), ElementSize));
244 TotalSize *= SizeExtended;
246 return TotalSize.getActiveBits();
268 uint64_t ArraySize,
const Expr *SizeExpr,
271 ID.AddInteger(ArraySize);
272 ID.AddInteger(llvm::to_underlying(SizeMod));
273 ID.AddInteger(TypeQuals);
274 ID.AddBoolean(SizeExpr !=
nullptr);
276 SizeExpr->
Profile(ID, Context,
true);
288 :
ArrayType(DependentSizedArray, et, can, sm, tq, e), SizeExpr((
Stmt *)e) {}
293 unsigned TypeQuals,
Expr *
E) {
295 ID.AddInteger(llvm::to_underlying(SizeMod));
296 ID.AddInteger(TypeQuals);
301DependentVectorType::DependentVectorType(
QualType ElementType,
304 :
Type(DependentVector, CanonType,
306 ElementType->getDependence() |
309 ElementType(ElementType), SizeExpr(SizeExpr),
Loc(
Loc) {
318 ID.AddInteger(llvm::to_underlying(VecKind));
319 SizeExpr->
Profile(ID, Context,
true);
322DependentSizedExtVectorType::DependentSizedExtVectorType(
QualType ElementType,
326 :
Type(DependentSizedExtVector, can,
328 ElementType->getDependence() |
331 SizeExpr(SizeExpr), ElementType(ElementType), loc(loc) {}
338 SizeExpr->
Profile(ID, Context,
true);
341DependentAddressSpaceType::DependentAddressSpaceType(
QualType PointeeType,
345 :
Type(DependentAddressSpace, can,
347 PointeeType->getDependence() |
350 AddrSpaceExpr(AddrSpaceExpr), PointeeType(PointeeType), loc(loc) {}
355 Expr *AddrSpaceExpr) {
357 AddrSpaceExpr->
Profile(ID, Context,
true);
361 const Expr *RowExpr,
const Expr *ColumnExpr)
362 :
Type(tc, canonType,
365 (matrixType->isVariablyModifiedType()
368 (matrixType->containsUnexpandedParameterPack() ||
370 RowExpr->containsUnexpandedParameterPack()) ||
372 ColumnExpr->containsUnexpandedParameterPack())
375 : matrixType->getDependence())),
376 ElementType(matrixType) {}
379 unsigned nColumns,
QualType canonType)
384 unsigned nRows,
unsigned nColumns,
386 :
MatrixType(tc, matrixType, canonType), NumRows(nRows),
387 NumColumns(nColumns) {}
389DependentSizedMatrixType::DependentSizedMatrixType(
QualType ElementType,
394 :
MatrixType(DependentSizedMatrix, ElementType, CanonicalType, RowExpr,
396 RowExpr(RowExpr), ColumnExpr(ColumnExpr), loc(loc) {}
403 RowExpr->
Profile(ID, CTX,
true);
404 ColumnExpr->
Profile(ID, CTX,
true);
413 :
Type(tc, canonType, vecType->getDependence()), ElementType(vecType) {
431 ExprAndUnsigned(NumBitsExpr, IsUnsigned) {}
434 return ExprAndUnsigned.getInt();
438 return ExprAndUnsigned.getPointer();
444 ID.AddBoolean(IsUnsigned);
445 NumBitsExpr->
Profile(ID, Context,
true);
451 return isa<FieldDecl>(Info.
getDecl());
457 bool CountInBytes,
bool OrNull) {
459 ID.AddBoolean(CountInBytes);
460 ID.AddBoolean(OrNull);
465 ID.AddPointer(CountExpr);
473 if (
const auto *ATy = dyn_cast<ArrayType>(
this))
474 return ATy->getElementType().getTypePtr();
477 if (!isa<ArrayType>(CanonicalType))
508#define TYPE(CLASS, BASE) \
509 static_assert(!std::is_polymorphic<CLASS##Type>::value, \
510 #CLASS "Type should not be polymorphic!");
511#include "clang/AST/TypeNodes.inc"
516#define TYPE(CLASS, BASE) \
517 static_assert(std::is_trivially_destructible<CLASS##Type>::value, \
518 #CLASS "Type should be trivially destructible!");
519#include "clang/AST/TypeNodes.inc"
523#define ABSTRACT_TYPE(Class, Parent)
524#define TYPE(Class, Parent) \
525 case Type::Class: { \
526 const auto *ty = cast<Class##Type>(this); \
527 if (!ty->isSugared()) \
528 return QualType(ty, 0); \
529 return ty->desugar(); \
531#include "clang/AST/TypeNodes.inc"
533 llvm_unreachable(
"bad type kind!");
543#define ABSTRACT_TYPE(Class, Parent)
544#define TYPE(Class, Parent) \
545 case Type::Class: { \
546 const auto *Ty = cast<Class##Type>(CurTy); \
547 if (!Ty->isSugared()) \
548 return SplitQualType(Ty, Qs); \
549 Cur = Ty->desugar(); \
552#include "clang/AST/TypeNodes.inc"
572#define ABSTRACT_TYPE(Class, Parent)
573#define TYPE(Class, Parent) \
574 case Type::Class: { \
575 const auto *ty = cast<Class##Type>(split.Ty); \
576 if (!ty->isSugared()) \
578 next = ty->desugar(); \
581#include "clang/AST/TypeNodes.inc"
600 T = PT->getInnerType();
609 if (
const auto *Sugar = dyn_cast<T>(Cur))
612#define ABSTRACT_TYPE(Class, Parent)
613#define TYPE(Class, Parent) \
614 case Type::Class: { \
615 const auto *Ty = cast<Class##Type>(Cur); \
616 if (!Ty->isSugared()) \
618 Cur = Ty->desugar().getTypePtr(); \
621#include "clang/AST/TypeNodes.inc"
627 return getAsSugar<TypedefType>(
this);
631 return getAsSugar<UsingType>(
this);
635 return getAsSugar<TemplateSpecializationType>(
this);
639 return getAsSugar<AttributedType>(
this);
643 return getAsSugar<BoundsAttributedType>(
this);
647 return getAsSugar<CountAttributedType>(
this);
654 const Type *Cur =
this;
658#define ABSTRACT_TYPE(Class, Parent)
659#define TYPE(Class, Parent) \
661 const auto *Ty = cast<Class##Type>(Cur); \
662 if (!Ty->isSugared()) \
664 Cur = Ty->desugar().getTypePtr(); \
667#include "clang/AST/TypeNodes.inc"
673 if (
const auto *RT = getAsCanonical<RecordType>())
674 return RT->getOriginalDecl()->isClass();
679 if (
const auto *RT = getAsCanonical<RecordType>())
680 return RT->getOriginalDecl()->isStruct();
685 const auto *RT = getAsCanonical<RecordType>();
688 const auto *
Decl = RT->getOriginalDecl();
689 if (!
Decl->isStruct())
691 return Decl->getDefinitionOrSelf()->hasFlexibleArrayMember();
696 return RD->hasAttr<ObjCBoxableAttr>();
701 if (
const auto *RT = getAsCanonical<RecordType>())
702 return RT->getOriginalDecl()->isInterface();
707 if (
const auto *RT = getAsCanonical<RecordType>())
708 return RT->getOriginalDecl()->isStructureOrClass();
713 if (
const auto *PT = getAsCanonical<PointerType>())
714 return PT->getPointeeType()->isVoidType();
719 if (
const auto *RT = getAsCanonical<RecordType>())
720 return RT->getOriginalDecl()->isUnion();
725 if (
const auto *CT = getAsCanonical<ComplexType>())
726 return CT->getElementType()->isFloatingType();
736 if (
const auto *ET = getAsCanonical<EnumType>())
737 return ET->getOriginalDecl()->isScoped();
742 return getAs<CountAttributedType>();
746 if (
const auto *
Complex = getAs<ComplexType>())
747 if (
Complex->getElementType()->isIntegerType())
753 if (
const auto *PT = getAs<PointerType>())
755 if (
const auto *OPT = getAs<ObjCObjectPointerType>())
757 if (
const auto *BPT = getAs<BlockPointerType>())
759 if (
const auto *RT = getAs<ReferenceType>())
761 if (
const auto *MPT = getAs<MemberPointerType>())
763 if (
const auto *DT = getAs<DecayedType>())
770 if (
const auto *RT = dyn_cast<RecordType>(
this)) {
771 if (RT->getOriginalDecl()->isStruct())
776 if (
const auto *RT = dyn_cast<RecordType>(CanonicalType)) {
777 if (!RT->getOriginalDecl()->isStruct())
789 if (
const auto *RT = dyn_cast<RecordType>(
this)) {
790 if (RT->getOriginalDecl()->isUnion())
795 if (
const auto *RT = dyn_cast<RecordType>(CanonicalType)) {
796 if (!RT->getOriginalDecl()->isUnion())
811 const auto *OPT = getAs<ObjCObjectPointerType>();
816 if (OPT->isObjCIdType())
820 if (!OPT->isKindOfType())
824 if (OPT->isObjCClassType() || OPT->isObjCQualifiedClassType())
828 bound = OPT->getObjectType()
835 const auto *OPT = getAs<ObjCObjectPointerType>();
840 if (OPT->isObjCClassType())
844 if (!OPT->isKindOfType())
848 return OPT->isObjCClassType() || OPT->isObjCQualifiedClassType();
862 :
Type(ObjCObject, Canonical,
Base->getDependence()), BaseType(
Base) {
867 "bitfield overflow in type argument count");
868 if (!typeArgs.empty())
869 memcpy(getTypeArgStorage(), typeArgs.data(),
870 typeArgs.size() *
sizeof(
QualType));
872 for (
auto typeArg : typeArgs) {
873 addDependence(typeArg->getDependence() & ~TypeDependence::VariablyModified);
886 if (
const auto objcObject =
getBaseType()->getAs<ObjCObjectType>()) {
888 if (isa<ObjCInterfaceType>(objcObject))
891 return objcObject->isSpecialized();
904 if (
const auto objcObject =
getBaseType()->getAs<ObjCObjectType>()) {
906 if (isa<ObjCInterfaceType>(objcObject))
909 return objcObject->getTypeArgs();
921 if (
const auto objcObject =
getBaseType()->getAs<ObjCObjectType>()) {
923 if (isa<ObjCInterfaceType>(objcObject))
926 return objcObject->isKindOfType();
942 baseType = baseObj->stripObjCKindOfTypeAndQuals(ctx);
971template <
typename Derived>
972struct SimpleTransformVisitor :
public TypeVisitor<Derived, QualType> {
980 QualType result =
static_cast<Derived *
>(
this)->Visit(splitType.
Ty);
990 explicit SimpleTransformVisitor(
ASTContext &ctx) : Ctx(ctx) {}
994#define TYPE(Class, Base)
995#define DEPENDENT_TYPE(Class, Base) \
996 QualType Visit##Class##Type(const Class##Type *T) { return QualType(T, 0); }
997#include "clang/AST/TypeNodes.inc"
999#define TRIVIAL_TYPE_CLASS(Class) \
1000 QualType Visit##Class##Type(const Class##Type *T) { return QualType(T, 0); }
1001#define SUGARED_TYPE_CLASS(Class) \
1002 QualType Visit##Class##Type(const Class##Type *T) { \
1003 if (!T->isSugared()) \
1004 return QualType(T, 0); \
1005 QualType desugaredType = recurse(T->desugar()); \
1006 if (desugaredType.isNull()) \
1008 if (desugaredType.getAsOpaquePtr() == T->desugar().getAsOpaquePtr()) \
1009 return QualType(T, 0); \
1010 return desugaredType; \
1016 QualType elementType = recurse(
T->getElementType());
1017 if (elementType.
isNull())
1020 if (elementType.
getAsOpaquePtr() ==
T->getElementType().getAsOpaquePtr())
1028 if (pointeeType.
isNull())
1039 if (pointeeType.
isNull())
1049 QualType pointeeType = recurse(
T->getPointeeTypeAsWritten());
1050 if (pointeeType.
isNull())
1054 T->getPointeeTypeAsWritten().getAsOpaquePtr())
1061 QualType pointeeType = recurse(
T->getPointeeTypeAsWritten());
1062 if (pointeeType.
isNull())
1066 T->getPointeeTypeAsWritten().getAsOpaquePtr())
1074 if (pointeeType.
isNull())
1081 T->getMostRecentCXXRecordDecl());
1085 QualType elementType = recurse(
T->getElementType());
1086 if (elementType.
isNull())
1089 if (elementType.
getAsOpaquePtr() ==
T->getElementType().getAsOpaquePtr())
1093 T->getSizeModifier(),
1094 T->getIndexTypeCVRQualifiers());
1098 QualType elementType = recurse(
T->getElementType());
1099 if (elementType.
isNull())
1102 if (elementType.
getAsOpaquePtr() ==
T->getElementType().getAsOpaquePtr())
1106 T->getSizeModifier(),
1107 T->getIndexTypeCVRQualifiers());
1111 QualType elementType = recurse(
T->getElementType());
1112 if (elementType.
isNull())
1115 if (elementType.
getAsOpaquePtr() ==
T->getElementType().getAsOpaquePtr())
1119 T->getIndexTypeCVRQualifiers());
1123 QualType elementType = recurse(
T->getElementType());
1124 if (elementType.
isNull())
1127 if (elementType.
getAsOpaquePtr() ==
T->getElementType().getAsOpaquePtr())
1131 T->getVectorKind());
1135 QualType elementType = recurse(
T->getElementType());
1136 if (elementType.
isNull())
1139 if (elementType.
getAsOpaquePtr() ==
T->getElementType().getAsOpaquePtr())
1146 QualType elementType = recurse(
T->getElementType());
1147 if (elementType.
isNull())
1149 if (elementType.
getAsOpaquePtr() ==
T->getElementType().getAsOpaquePtr())
1153 T->getNumColumns());
1174 bool paramChanged =
false;
1176 QualType newParamType = recurse(paramType);
1177 if (newParamType.
isNull())
1181 paramChanged =
true;
1183 paramTypes.push_back(newParamType);
1188 bool exceptionChanged =
false;
1192 QualType newExceptionType = recurse(exceptionType);
1193 if (newExceptionType.
isNull())
1196 if (newExceptionType.
getAsOpaquePtr() != exceptionType.getAsOpaquePtr())
1197 exceptionChanged =
true;
1199 exceptionTypes.push_back(newExceptionType);
1202 if (exceptionChanged) {
1209 !paramChanged && !exceptionChanged)
1216 QualType innerType = recurse(
T->getInnerType());
1231 QualType originalType = recurse(
T->getOriginalType());
1232 if (originalType.
isNull())
1235 QualType adjustedType = recurse(
T->getAdjustedType());
1236 if (adjustedType.
isNull())
1240 T->getOriginalType().getAsOpaquePtr() &&
1241 adjustedType.
getAsOpaquePtr() ==
T->getAdjustedType().getAsOpaquePtr())
1248 QualType originalType = recurse(
T->getOriginalType());
1249 if (originalType.
isNull())
1252 if (originalType.
getAsOpaquePtr() ==
T->getOriginalType().getAsOpaquePtr())
1259 QualType ArrTy = VisitConstantArrayType(
T);
1274 QualType modifiedType = recurse(
T->getModifiedType());
1275 if (modifiedType.
isNull())
1278 QualType equivalentType = recurse(
T->getEquivalentType());
1279 if (equivalentType.
isNull())
1283 T->getModifiedType().getAsOpaquePtr() &&
1285 T->getEquivalentType().getAsOpaquePtr())
1293 QualType replacementType = recurse(
T->getReplacementType());
1294 if (replacementType.
isNull())
1298 T->getReplacementType().getAsOpaquePtr())
1302 replacementType,
T->getAssociatedDecl(),
T->getIndex(),
1303 T->getPackIndex(),
T->getFinal());
1310 if (!
T->isDeduced())
1313 QualType deducedType = recurse(
T->getDeducedType());
1314 if (deducedType.
isNull())
1317 if (deducedType.
getAsOpaquePtr() ==
T->getDeducedType().getAsOpaquePtr())
1321 false,
T->getTypeConstraintConcept(),
1322 T->getTypeConstraintArguments());
1326 QualType baseType = recurse(
T->getBaseType());
1331 bool typeArgChanged =
false;
1333 for (
auto typeArg :
T->getTypeArgsAsWritten()) {
1334 QualType newTypeArg = recurse(typeArg);
1339 typeArgChanged =
true;
1341 typeArgs.push_back(newTypeArg);
1351 T->isKindOfTypeAsWritten());
1358 if (pointeeType.
isNull())
1368 QualType valueType = recurse(
T->getValueType());
1378#undef TRIVIAL_TYPE_CLASS
1379#undef SUGARED_TYPE_CLASS
1382struct SubstObjCTypeArgsVisitor
1383 :
public SimpleTransformVisitor<SubstObjCTypeArgsVisitor> {
1384 using BaseType = SimpleTransformVisitor<SubstObjCTypeArgsVisitor>;
1391 : BaseType(ctx), TypeArgs(typeArgs), SubstContext(context) {}
1398 if (!TypeArgs.empty()) {
1409 argType, protocolsToApply, hasError,
true );
1412 switch (SubstContext) {
1413 case ObjCSubstitutionContext::Ordinary:
1414 case ObjCSubstitutionContext::Parameter:
1415 case ObjCSubstitutionContext::Superclass:
1419 case ObjCSubstitutionContext::Result:
1420 case ObjCSubstitutionContext::Property: {
1422 const auto *objPtr =
1427 if (objPtr->isKindOfType() || objPtr->isObjCIdOrClassType())
1431 const auto *obj = objPtr->getObjectType();
1433 obj->getBaseType(), obj->getTypeArgsAsWritten(), obj->getProtocols(),
1440 llvm_unreachable(
"Unexpected ObjCSubstitutionContext!");
1449 Ctx, TypeArgs, ObjCSubstitutionContext::Result);
1455 if (isa<FunctionNoProtoType>(funcType)) {
1459 return BaseType::VisitFunctionType(funcType);
1465 const auto *funcProtoType = cast<FunctionProtoType>(funcType);
1469 bool paramChanged =
false;
1470 for (
auto paramType : funcProtoType->getParamTypes()) {
1472 Ctx, TypeArgs, ObjCSubstitutionContext::Parameter);
1473 if (newParamType.
isNull())
1477 paramChanged =
true;
1479 paramTypes.push_back(newParamType);
1484 bool exceptionChanged =
false;
1489 Ctx, TypeArgs, ObjCSubstitutionContext::Ordinary);
1490 if (newExceptionType.
isNull())
1493 if (newExceptionType.
getAsOpaquePtr() != exceptionType.getAsOpaquePtr())
1494 exceptionChanged =
true;
1496 exceptionTypes.push_back(newExceptionType);
1499 if (exceptionChanged) {
1506 funcProtoType->getReturnType().getAsOpaquePtr() &&
1507 !paramChanged && !exceptionChanged)
1508 return BaseType::VisitFunctionType(funcType);
1518 bool anyChanged =
false;
1521 Ctx, TypeArgs, ObjCSubstitutionContext::Ordinary);
1530 if (TypeArgs.empty() &&
1531 SubstContext != ObjCSubstitutionContext::Superclass) {
1540 newTypeArgs.push_back(newTypeArg);
1552 return BaseType::VisitObjCObjectType(objcObjectType);
1556 QualType newType = BaseType::VisitAttributedType(attrType);
1560 const auto *newAttrType = dyn_cast<AttributedType>(newType.
getTypePtr());
1561 if (!newAttrType || newAttrType->getAttrKind() != attr::ObjCKindOf)
1565 QualType newEquivType = newAttrType->getEquivalentType();
1577 objType->getBaseType(), objType->getTypeArgsAsWritten(),
1578 objType->getProtocols(),
1580 objType->isObjCUnqualifiedId() ?
false :
true);
1588 newAttrType->getModifiedType(), newEquivType,
1589 newAttrType->getAttr());
1593struct StripObjCKindOfTypeVisitor
1594 :
public SimpleTransformVisitor<StripObjCKindOfTypeVisitor> {
1595 using BaseType = SimpleTransformVisitor<StripObjCKindOfTypeVisitor>;
1597 explicit StripObjCKindOfTypeVisitor(
ASTContext &ctx) : BaseType(ctx) {}
1601 return BaseType::VisitObjCObjectType(objType);
1622 case BuiltinType::Kind::Float16: {
1630 case BuiltinType::Kind::BFloat16: {
1650 SubstObjCTypeArgsVisitor visitor(ctx, typeArgs, context);
1651 return visitor.recurse(*
this);
1665 auto &ctx =
const_cast<ASTContext &
>(constCtx);
1666 StripObjCKindOfTypeVisitor visitor(ctx);
1667 return visitor.recurse(*
this);
1673 T = AT->getValueType();
1674 return T.getUnqualifiedType();
1677std::optional<ArrayRef<QualType>>
1680 if (
const auto method = dyn_cast<ObjCMethodDecl>(dc))
1681 dc = method->getDeclContext();
1685 const auto *dcClassDecl = dyn_cast<ObjCInterfaceDecl>(dc);
1691 dcTypeParams = dcClassDecl->getTypeParamList();
1693 return std::nullopt;
1697 dcCategoryDecl = dyn_cast<ObjCCategoryDecl>(dc);
1698 if (!dcCategoryDecl)
1699 return std::nullopt;
1705 return std::nullopt;
1709 return std::nullopt;
1711 assert(dcTypeParams &&
"No substitutions to perform");
1712 assert(dcClassDecl &&
"No class context");
1716 if (
const auto *objectPointerType = getAs<ObjCObjectPointerType>()) {
1717 objectType = objectPointerType->getObjectType();
1718 }
else if (getAs<BlockPointerType>()) {
1723 objectType = getAs<ObjCObjectType>();
1729 if (!curClassDecl) {
1737 while (curClassDecl != dcClassDecl) {
1740 if (superType.
isNull()) {
1741 objectType =
nullptr;
1761 if (
auto *ID = IfaceT->getInterface()) {
1762 if (ID->getTypeParamList())
1776 CachedSuperClassType.setInt(
true);
1782 if (!superClassObjTy) {
1783 CachedSuperClassType.setInt(
true);
1788 if (!superClassDecl) {
1789 CachedSuperClassType.setInt(
true);
1795 QualType superClassType(superClassObjTy, 0);
1797 if (!superClassTypeParams) {
1798 CachedSuperClassType.setPointerAndInt(
1805 CachedSuperClassType.setPointerAndInt(superClassObjTy,
true);
1813 CachedSuperClassType.setPointerAndInt(
1824 CachedSuperClassType.setPointerAndInt(
1831 assert(typeArgs.size() == typeParams->
size());
1832 CachedSuperClassType.setPointerAndInt(
1842 return interfaceDecl->getASTContext()
1843 .getObjCInterfaceType(interfaceDecl)
1852 if (superObjectType.
isNull())
1853 return superObjectType;
1863 if (
const auto *
T = getAs<ObjCObjectType>())
1864 if (
T->getNumProtocols() &&
T->getInterface())
1876 if (
const auto *OPT = getAs<ObjCObjectPointerType>()) {
1877 if (OPT->isObjCQualifiedIdType())
1886 if (
const auto *OPT = getAs<ObjCObjectPointerType>()) {
1887 if (OPT->isObjCQualifiedClassType())
1894 if (
const auto *OT = getAs<ObjCObjectType>()) {
1895 if (OT->getInterface())
1902 if (
const auto *OPT = getAs<ObjCObjectPointerType>()) {
1903 if (OPT->getInterfaceType())
1911 if (
const auto *PT = getAsCanonical<PointerType>())
1913 else if (
const auto *RT = getAsCanonical<ReferenceType>())
1922 const auto *TST = getAs<TemplateSpecializationType>();
1923 while (TST && TST->isTypeAlias())
1930 case Type::DependentName:
1931 return cast<DependentNameType>(
this)->getQualifier();
1932 case Type::TemplateSpecialization:
1933 return cast<TemplateSpecializationType>(
this)
1936 case Type::DependentTemplateSpecialization:
1937 return cast<DependentTemplateSpecializationType>(
this)
1938 ->getDependentTemplateName()
1942 case Type::InjectedClassName:
1943 return cast<TagType>(
this)->getQualifier();
1945 return cast<TypedefType>(
this)->getQualifier();
1946 case Type::UnresolvedUsing:
1947 return cast<UnresolvedUsingType>(
this)->getQualifier();
1949 return cast<UsingType>(
this)->getQualifier();
1951 return std::nullopt;
1956 const Type *Cur =
this;
1958 if (AT->getAttrKind() == AK)
1960 Cur = AT->getEquivalentType().getTypePtr();
1967class GetContainedDeducedTypeVisitor
1968 :
public TypeVisitor<GetContainedDeducedTypeVisitor, Type *> {
1972 GetContainedDeducedTypeVisitor(
bool Syntactic =
false)
1973 : Syntactic(Syntactic) {}
1980 return Visit(
T.getTypePtr());
1990 return Visit(
T->getReplacementType());
2002 return Visit(
T->getPointeeTypeAsWritten());
2010 return Visit(
T->getElementType());
2014 return Visit(
T->getElementType());
2018 return Visit(
T->getElementType());
2022 return Visit(
T->getElementType());
2026 return Visit(
T->getElementType());
2032 return VisitFunctionType(
T);
2039 Type *VisitParenType(
const ParenType *
T) {
return Visit(
T->getInnerType()); }
2042 return Visit(
T->getModifiedType());
2046 return Visit(
T->getUnderlyingType());
2050 return Visit(
T->getOriginalType());
2054 return Visit(
T->getPattern());
2061 return cast_or_null<DeducedType>(
2062 GetContainedDeducedTypeVisitor().Visit(
this));
2066 return isa_and_nonnull<FunctionType>(
2067 GetContainedDeducedTypeVisitor(
true).Visit(
this));
2071 if (
const auto *VT = dyn_cast<VectorType>(CanonicalType))
2072 return VT->getElementType()->isIntegerType();
2073 if (CanonicalType->isSveVLSBuiltinType()) {
2074 const auto *VT = cast<BuiltinType>(CanonicalType);
2075 return VT->getKind() == BuiltinType::SveBool ||
2076 (VT->getKind() >= BuiltinType::SveInt8 &&
2077 VT->getKind() <= BuiltinType::SveUint64);
2079 if (CanonicalType->isRVVVLSBuiltinType()) {
2080 const auto *VT = cast<BuiltinType>(CanonicalType);
2081 return (VT->getKind() >= BuiltinType::RvvInt8mf8 &&
2082 VT->getKind() <= BuiltinType::RvvUint64m8);
2108 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
2109 return BT->isInteger();
2113 if (
const auto *ET = dyn_cast<EnumType>(CanonicalType))
2120 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
2121 return BT->isInteger();
2130 if (
const auto *ET = dyn_cast<EnumType>(CanonicalType))
2131 return !ET->getOriginalDecl()->isScoped();
2137 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
2138 return BT->getKind() == BuiltinType::Char_U ||
2139 BT->getKind() == BuiltinType::UChar ||
2140 BT->getKind() == BuiltinType::Char_S ||
2141 BT->getKind() == BuiltinType::SChar;
2146 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
2147 return BT->getKind() == BuiltinType::WChar_S ||
2148 BT->getKind() == BuiltinType::WChar_U;
2153 if (
const BuiltinType *BT = dyn_cast<BuiltinType>(CanonicalType))
2154 return BT->getKind() == BuiltinType::Char8;
2159 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
2160 return BT->getKind() == BuiltinType::Char16;
2165 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
2166 return BT->getKind() == BuiltinType::Char32;
2173 const auto *BT = dyn_cast<BuiltinType>(CanonicalType);
2176 switch (BT->getKind()) {
2179 case BuiltinType::Char_U:
2180 case BuiltinType::UChar:
2181 case BuiltinType::WChar_U:
2182 case BuiltinType::Char8:
2183 case BuiltinType::Char16:
2184 case BuiltinType::Char32:
2185 case BuiltinType::Char_S:
2186 case BuiltinType::SChar:
2187 case BuiltinType::WChar_S:
2193 const auto *BT = dyn_cast<BuiltinType>(CanonicalType);
2196 switch (BT->getKind()) {
2199 case BuiltinType::Char8:
2200 case BuiltinType::Char16:
2201 case BuiltinType::Char32:
2210 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
2211 return BT->isSignedInteger();
2216 if (!ED->isComplete() || ED->isScoped())
2218 return ED->getIntegerType()->isSignedIntegerType();
2221 if (
const auto *IT = dyn_cast<BitIntType>(CanonicalType))
2222 return IT->isSigned();
2223 if (
const auto *IT = dyn_cast<DependentBitIntType>(CanonicalType))
2224 return IT->isSigned();
2230 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
2231 return BT->isSignedInteger();
2234 if (!ED->isComplete())
2236 return ED->getIntegerType()->isSignedIntegerType();
2239 if (
const auto *IT = dyn_cast<BitIntType>(CanonicalType))
2240 return IT->isSigned();
2241 if (
const auto *IT = dyn_cast<DependentBitIntType>(CanonicalType))
2242 return IT->isSigned();
2248 if (
const auto *VT = dyn_cast<VectorType>(CanonicalType))
2249 return VT->getElementType()->isSignedIntegerOrEnumerationType();
2258 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
2259 return BT->isUnsignedInteger();
2264 if (!ED->isComplete() || ED->isScoped())
2266 return ED->getIntegerType()->isUnsignedIntegerType();
2269 if (
const auto *IT = dyn_cast<BitIntType>(CanonicalType))
2270 return IT->isUnsigned();
2271 if (
const auto *IT = dyn_cast<DependentBitIntType>(CanonicalType))
2272 return IT->isUnsigned();
2278 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
2279 return BT->isUnsignedInteger();
2282 if (!ED->isComplete())
2284 return ED->getIntegerType()->isUnsignedIntegerType();
2287 if (
const auto *IT = dyn_cast<BitIntType>(CanonicalType))
2288 return IT->isUnsigned();
2289 if (
const auto *IT = dyn_cast<DependentBitIntType>(CanonicalType))
2290 return IT->isUnsigned();
2296 if (
const auto *VT = dyn_cast<VectorType>(CanonicalType))
2297 return VT->getElementType()->isUnsignedIntegerOrEnumerationType();
2298 if (
const auto *VT = dyn_cast<MatrixType>(CanonicalType))
2299 return VT->getElementType()->isUnsignedIntegerOrEnumerationType();
2300 if (CanonicalType->isSveVLSBuiltinType()) {
2301 const auto *VT = cast<BuiltinType>(CanonicalType);
2302 return VT->getKind() >= BuiltinType::SveUint8 &&
2303 VT->getKind() <= BuiltinType::SveUint64;
2309 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
2310 return BT->isFloatingPoint();
2311 if (
const auto *CT = dyn_cast<ComplexType>(CanonicalType))
2312 return CT->getElementType()->isFloatingType();
2317 if (
const auto *VT = dyn_cast<VectorType>(CanonicalType))
2318 return VT->getElementType()->isFloatingType();
2319 if (
const auto *MT = dyn_cast<MatrixType>(CanonicalType))
2320 return MT->getElementType()->isFloatingType();
2325 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
2326 return BT->isFloatingPoint();
2331 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
2332 return BT->getKind() >= BuiltinType::Bool &&
2333 BT->getKind() <= BuiltinType::Ibm128;
2334 if (
const auto *ET = dyn_cast<EnumType>(CanonicalType)) {
2335 const auto *ED = ET->getOriginalDecl();
2336 return !ED->isScoped() && ED->getDefinitionOrSelf()->isComplete();
2342 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
2343 return BT->getKind() >= BuiltinType::Bool &&
2344 BT->getKind() <= BuiltinType::Ibm128;
2345 if (
const auto *ET = dyn_cast<EnumType>(CanonicalType)) {
2352 const auto *ED = ET->getOriginalDecl();
2353 return !ED->isScoped() && ED->getDefinitionOrSelf()->isComplete();
2355 return isa<ComplexType>(CanonicalType) ||
isBitIntType();
2359 if (
const auto *VT = dyn_cast<VectorType>(CanonicalType))
2360 return VT->getElementType()->isBooleanType();
2362 return ED->isComplete() && ED->getIntegerType()->isBooleanType();
2363 if (
const auto *IT = dyn_cast<BitIntType>(CanonicalType))
2364 return IT->getNumBits() == 1;
2371 const Type *
T = CanonicalType.getTypePtr();
2372 if (
const auto *BT = dyn_cast<BuiltinType>(
T)) {
2373 if (BT->getKind() == BuiltinType::Bool)
2375 if (BT->getKind() == BuiltinType::NullPtr)
2377 if (BT->isInteger())
2379 if (BT->isFloatingPoint())
2381 if (BT->isFixedPointType())
2383 llvm_unreachable(
"unknown scalar builtin type");
2384 }
else if (isa<PointerType>(
T)) {
2386 }
else if (isa<BlockPointerType>(
T)) {
2388 }
else if (isa<ObjCObjectPointerType>(
T)) {
2390 }
else if (isa<MemberPointerType>(
T)) {
2392 }
else if (isa<EnumType>(
T)) {
2395 }
else if (
const auto *CT = dyn_cast<ComplexType>(
T)) {
2396 if (CT->getElementType()->isRealFloatingType())
2403 llvm_unreachable(
"unknown scalar type");
2416 if (
const auto *
Record = dyn_cast<RecordType>(CanonicalType)) {
2417 if (
const auto *ClassDecl =
2418 dyn_cast<CXXRecordDecl>(
Record->getOriginalDecl()))
2419 return ClassDecl->isAggregate();
2424 return isa<ArrayType>(CanonicalType);
2431 assert(!
isIncompleteType() &&
"This doesn't make sense for incomplete types");
2432 assert(!
isDependentType() &&
"This doesn't make sense for dependent types");
2434 return !isa<VariableArrayType>(CanonicalType);
2444 switch (CanonicalType->getTypeClass()) {
2455 return !EnumD->isComplete();
2463 return !Rec->isCompleteDefinition();
2465 case InjectedClassName: {
2467 if (!Rec->isBeingDefined())
2479 return cast<ArrayType>(CanonicalType)
2481 ->isIncompleteType(Def);
2482 case IncompleteArray:
2485 case MemberPointer: {
2492 cast<MemberPointerType>(CanonicalType)->getMostRecentCXXRecordDecl();
2501 if (RD->
hasAttr<MSInheritanceAttr>())
2506 return cast<ObjCObjectType>(CanonicalType)
2508 ->isIncompleteType(Def);
2509 case ObjCInterface: {
2512 cast<ObjCInterfaceType>(CanonicalType)->getDecl();
2526 if (isa<TagType>(CanonicalType))
2540 if (
const BuiltinType *BT = getAs<BuiltinType>()) {
2541 switch (BT->getKind()) {
2543#define WASM_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
2544#include "clang/Basic/WebAssemblyReferenceTypes.def"
2546#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
2547#include "clang/Basic/HLSLIntangibleTypes.def"
2557 if (
const auto *BT = getAs<BuiltinType>())
2558 return BT->getKind() == BuiltinType::WasmExternRef;
2563 if (
const auto *ATy = dyn_cast<ArrayType>(
this))
2564 return ATy->getElementType().isWebAssemblyReferenceType();
2566 if (
const auto *PTy = dyn_cast<PointerType>(
this))
2567 return PTy->getPointeeType().isWebAssemblyReferenceType();
2579 if (
const BuiltinType *BT = getAs<BuiltinType>()) {
2580 switch (BT->getKind()) {
2582#define SVE_VECTOR_TYPE(Name, MangledName, Id, SingletonId) \
2583 case BuiltinType::Id: \
2585#define SVE_OPAQUE_TYPE(Name, MangledName, Id, SingletonId) \
2586 case BuiltinType::Id: \
2588#define SVE_PREDICATE_TYPE(Name, MangledName, Id, SingletonId) \
2589 case BuiltinType::Id: \
2591#include "clang/Basic/AArch64ACLETypes.def"
2600 if (
const BuiltinType *BT = getAs<BuiltinType>()) {
2601 switch (BT->getKind()) {
2602#define RVV_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
2603#include "clang/Basic/RISCVVTypes.def"
2613 if (
const BuiltinType *BT = getAs<BuiltinType>()) {
2614 switch (BT->getKind()) {
2615 case BuiltinType::SveInt8:
2616 case BuiltinType::SveInt16:
2617 case BuiltinType::SveInt32:
2618 case BuiltinType::SveInt64:
2619 case BuiltinType::SveUint8:
2620 case BuiltinType::SveUint16:
2621 case BuiltinType::SveUint32:
2622 case BuiltinType::SveUint64:
2623 case BuiltinType::SveFloat16:
2624 case BuiltinType::SveFloat32:
2625 case BuiltinType::SveFloat64:
2626 case BuiltinType::SveBFloat16:
2627 case BuiltinType::SveBool:
2628 case BuiltinType::SveBoolx2:
2629 case BuiltinType::SveBoolx4:
2630 case BuiltinType::SveMFloat8:
2648 llvm_unreachable(
"Unhandled type");
2655 if (BTy->
getKind() == BuiltinType::SveBool)
2665 if (
const BuiltinType *BT = getAs<BuiltinType>()) {
2666 switch (BT->getKind()) {
2667#define RVV_VECTOR_TYPE(Name, Id, SingletonId, NumEls, ElBits, NF, IsSigned, \
2669 case BuiltinType::Id: \
2671#define RVV_PREDICATE_TYPE(Name, Id, SingletonId, NumEls) \
2672 case BuiltinType::Id: \
2674#include "clang/Basic/RISCVVTypes.def"
2688#define RVV_PREDICATE_TYPE(Name, Id, SingletonId, NumEls) \
2689 case BuiltinType::Id: \
2690 return Ctx.UnsignedCharTy;
2693#include "clang/Basic/RISCVVTypes.def"
2696 llvm_unreachable(
"Unhandled type");
2714 if ((*this)->isIncompleteArrayType())
2717 if ((*this)->isIncompleteType())
2733 case Type::VariableArray:
2734 case Type::ConstantArray:
2738 case Type::ObjCObjectPointer:
2739 case Type::BlockPointer:
2743 case Type::MemberPointer:
2745 case Type::ExtVector:
2753 if (
const auto *ClassDecl = dyn_cast<CXXRecordDecl>(
2754 cast<RecordType>(CanonicalType)->getOriginalDecl()))
2755 return ClassDecl->isPOD();
2769 if ((*this)->isArrayType())
2772 if ((*this)->isSizelessBuiltinType())
2777 if ((*this)->isIncompleteType())
2808 return ClassDecl->hasTrivialDefaultConstructor() &&
2809 !ClassDecl->hasNonTrivialDefaultConstructor() &&
2810 ClassDecl->isTriviallyCopyable();
2813 if (isa<RecordType>(CanonicalType))
2822 bool IsCopyConstructible) {
2823 if (
type->isArrayType())
2825 Context, IsCopyConstructible);
2827 if (
type.hasNonTrivialObjCLifetime())
2860 if (
const auto *ClassDecl = dyn_cast<CXXRecordDecl>(RD)) {
2861 if (IsCopyConstructible)
2862 return ClassDecl->isTriviallyCopyConstructible();
2863 return ClassDecl->isTriviallyCopyable();
2865 return !RD->isNonTrivialToPrimitiveCopy();
2879 if (CanonicalType.hasNonTrivialObjCLifetime())
2881 if (CanonicalType->isArrayType())
2885 if (CanonicalType->isIncompleteType())
2893 const auto *RD = CanonicalType->getAsRecordDecl();
2900 if (RD->mayInsertExtraPadding())
2903 for (
auto *
const Field : RD->fields()) {
2904 if (!Field->getType().isBitwiseCloneableType(Context))
2908 if (
const auto *CXXRD = dyn_cast<CXXRecordDecl>(RD)) {
2909 for (
auto Base : CXXRD->bases())
2910 if (!
Base.getType().isBitwiseCloneableType(Context))
2912 for (
auto VBase : CXXRD->vbases())
2913 if (!VBase.getType().isBitwiseCloneableType(Context))
2959 if (
const auto *RD =
2975 if (
const auto *RD =
3015 assert(BaseTy &&
"NULL element type");
3045 if (
const auto *ClassDecl = dyn_cast<CXXRecordDecl>(RD))
3046 return ClassDecl->isLiteral();
3053 return AT->getValueType()->isLiteralType(Ctx);
3075 return RD->isStructural();
3088 assert(BaseTy &&
"NULL element type");
3099 if (
const auto *ClassDecl = dyn_cast<CXXRecordDecl>(RD);
3100 ClassDecl && !ClassDecl->isStandardLayout())
3128 assert(BaseTy &&
"NULL element type");
3146 if (
const auto *ClassDecl = dyn_cast<CXXRecordDecl>(RD)) {
3149 if (!ClassDecl->isTrivial())
3155 if (!ClassDecl->isStandardLayout())
3185 if (
const auto *ET = getAsCanonical<EnumType>()) {
3186 const auto *ED = ET->getOriginalDecl();
3188 if (II && II->
isStr(
"align_val_t") && ED->isInStdNamespace())
3195 if (
const auto *ET = getAsCanonical<EnumType>()) {
3196 const auto *ED = ET->getOriginalDecl();
3198 if (II && II->
isStr(
"byte") && ED->isInStdNamespace())
3214 case TemplateTypeParm:
3215 case SubstTemplateTypeParm:
3216 case TemplateSpecialization:
3218 case DependentTemplateSpecialization:
3260 llvm_unreachable(
"Type specifier is not a tag type kind.");
3277 llvm_unreachable(
"Unknown tag type kind.");
3295 llvm_unreachable(
"Elaborated type keyword is not a tag type kind.");
3297 llvm_unreachable(
"Unknown elaborated type keyword.");
3312 llvm_unreachable(
"Unknown elaborated type keyword.");
3326 return "__interface";
3333 llvm_unreachable(
"Unknown elaborated type keyword.");
3336DependentTemplateSpecializationType::DependentTemplateSpecializationType(
3343 DependentTemplateSpecializationTypeBits.NumArgs = Args.size();
3344 auto *ArgBuffer =
const_cast<TemplateArgument *
>(template_arguments().data());
3347 TemplateArgumentDependence::UnexpandedPack));
3354 llvm::FoldingSetNodeID &ID,
const ASTContext &Context,
3357 ID.AddInteger(llvm::to_underlying(
Keyword));
3360 Arg.Profile(ID, Context);
3365 if (
const auto *TST = dyn_cast<TemplateSpecializationType>(
this))
3367 else if (
const auto *DepName = dyn_cast<DependentNameType>(
this))
3368 Keyword = DepName->getKeyword();
3369 else if (
const auto *DepTST =
3370 dyn_cast<DependentTemplateSpecializationType>(
this))
3371 Keyword = DepTST->getKeyword();
3372 else if (
const auto *
T = dyn_cast<TagType>(
this))
3374 else if (
const auto *
T = dyn_cast<TypedefType>(
this))
3376 else if (
const auto *
T = dyn_cast<UnresolvedUsingType>(
this))
3378 else if (
const auto *
T = dyn_cast<UsingType>(
this))
3388#define ABSTRACT_TYPE(Derived, Base)
3389#define TYPE(Derived, Base) \
3392#include "clang/AST/TypeNodes.inc"
3395 llvm_unreachable(
"Invalid type class.");
3403 return Policy.
Bool ?
"bool" :
"_Bool";
3409 return "signed char";
3421 return "unsigned char";
3423 return "unsigned short";
3425 return "unsigned int";
3427 return "unsigned long";
3429 return "unsigned long long";
3431 return "unsigned __int128";
3433 return Policy.
Half ?
"half" :
"__fp16";
3441 return "long double";
3443 return "short _Accum";
3447 return "long _Accum";
3449 return "unsigned short _Accum";
3451 return "unsigned _Accum";
3453 return "unsigned long _Accum";
3454 case BuiltinType::ShortFract:
3455 return "short _Fract";
3456 case BuiltinType::Fract:
3458 case BuiltinType::LongFract:
3459 return "long _Fract";
3460 case BuiltinType::UShortFract:
3461 return "unsigned short _Fract";
3462 case BuiltinType::UFract:
3463 return "unsigned _Fract";
3464 case BuiltinType::ULongFract:
3465 return "unsigned long _Fract";
3466 case BuiltinType::SatShortAccum:
3467 return "_Sat short _Accum";
3468 case BuiltinType::SatAccum:
3469 return "_Sat _Accum";
3470 case BuiltinType::SatLongAccum:
3471 return "_Sat long _Accum";
3472 case BuiltinType::SatUShortAccum:
3473 return "_Sat unsigned short _Accum";
3474 case BuiltinType::SatUAccum:
3475 return "_Sat unsigned _Accum";
3476 case BuiltinType::SatULongAccum:
3477 return "_Sat unsigned long _Accum";
3478 case BuiltinType::SatShortFract:
3479 return "_Sat short _Fract";
3480 case BuiltinType::SatFract:
3481 return "_Sat _Fract";
3482 case BuiltinType::SatLongFract:
3483 return "_Sat long _Fract";
3484 case BuiltinType::SatUShortFract:
3485 return "_Sat unsigned short _Fract";
3486 case BuiltinType::SatUFract:
3487 return "_Sat unsigned _Fract";
3488 case BuiltinType::SatULongFract:
3489 return "_Sat unsigned long _Fract";
3493 return "__float128";
3498 return Policy.
MSWChar ?
"__wchar_t" :
"wchar_t";
3508 return "<overloaded function type>";
3510 return "<bound member function type>";
3511 case UnresolvedTemplate:
3512 return "<unresolved template type>";
3514 return "<pseudo-object type>";
3516 return "<dependent type>";
3518 return "<unknown type>";
3519 case ARCUnbridgedCast:
3520 return "<ARC unbridged cast type>";
3522 return "<builtin fn type>";
3529#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
3531 return "__" #Access " " #ImgType "_t";
3532#include "clang/Basic/OpenCLImageTypes.def"
3538 return "clk_event_t";
3542 return "reserve_id_t";
3543 case IncompleteMatrixIdx:
3544 return "<incomplete matrix index type>";
3546 return "<array section type>";
3547 case OMPArrayShaping:
3548 return "<OpenMP array shaping type>";
3550 return "<OpenMP iterator type>";
3551#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \
3554#include "clang/Basic/OpenCLExtensionTypes.def"
3555#define SVE_TYPE(Name, Id, SingletonId) \
3558#include "clang/Basic/AArch64ACLETypes.def"
3559#define PPC_VECTOR_TYPE(Name, Id, Size) \
3562#include "clang/Basic/PPCTypes.def"
3563#define RVV_TYPE(Name, Id, SingletonId) \
3566#include "clang/Basic/RISCVVTypes.def"
3567#define WASM_TYPE(Name, Id, SingletonId) \
3570#include "clang/Basic/WebAssemblyReferenceTypes.def"
3571#define AMDGPU_TYPE(Name, Id, SingletonId, Width, Align) \
3574#include "clang/Basic/AMDGPUTypes.def"
3575#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) \
3578#include "clang/Basic/HLSLIntangibleTypes.def"
3581 llvm_unreachable(
"Invalid builtin type.");
3586 if (
auto *PET = dyn_cast<PackExpansionType>(
getTypePtr()))
3587 return PET->getPattern();
3592 if (
const auto *RefType =
getTypePtr()->getAs<ReferenceType>())
3608 if (
const auto *FPT = getAs<FunctionProtoType>())
3609 return FPT->hasCFIUncheckedCallee();
3626 return "vectorcall";
3638 return "aarch64_vector_pcs";
3640 return "aarch64_sve_pcs";
3642 return "intel_ocl_bicc";
3644 return "spir_function";
3646 return "device_kernel";
3650 return "swiftasynccall";
3652 return "preserve_most";
3654 return "preserve_all";
3658 return "preserve_none";
3661#define CC_VLS_CASE(ABI_VLEN) \
3662 case CC_RISCVVLSCall_##ABI_VLEN: return "riscv_vls_cc(" #ABI_VLEN ")";
3679 llvm_unreachable(
"Invalid calling convention.");
3697 assert(
getNumParams() == params.size() &&
"NumParams overflow!");
3706 auto &ExtraBits = *getTrailingObjects<FunctionTypeExtraBitfields>();
3714 auto &ExtraAttrInfo = *getTrailingObjects<FunctionTypeExtraAttributeInfo>();
3718 auto &ExtraBits = *getTrailingObjects<FunctionTypeExtraBitfields>();
3719 ExtraBits.HasExtraAttributeInfo =
true;
3723 auto &ArmTypeAttrs = *getTrailingObjects<FunctionTypeArmAttributes>();
3724 ArmTypeAttrs = FunctionTypeArmAttributes();
3727 auto &ExtraBits = *getTrailingObjects<FunctionTypeExtraBitfields>();
3728 ExtraBits.HasArmTypeAttributes =
true;
3732 auto *argSlot = getTrailingObjects<QualType>();
3735 ~TypeDependence::VariablyModified);
3736 argSlot[i] = params[i];
3741 auto &ArmTypeAttrs = *getTrailingObjects<FunctionTypeArmAttributes>();
3743 "Not enough bits to encode SME attributes");
3749 auto &ExtraBits = *getTrailingObjects<FunctionTypeExtraBitfields>();
3751 assert(NumExceptions <= 1023 &&
"Not enough bits to encode exceptions");
3752 ExtraBits.NumExceptionType = NumExceptions;
3754 assert(hasExtraBitfields() &&
"missing trailing extra bitfields!");
3756 reinterpret_cast<QualType *
>(getTrailingObjects<ExceptionType>());
3764 (TypeDependence::Instantiation | TypeDependence::UnexpandedPack));
3766 exnSlot[I++] = ExceptionType;
3780 (TypeDependence::Instantiation | TypeDependence::UnexpandedPack));
3786 auto **slot = getTrailingObjects<FunctionDecl *>();
3794 auto **slot = getTrailingObjects<FunctionDecl *>();
3813 auto *extParamInfos = getTrailingObjects<ExtParameterInfo>();
3820 *getTrailingObjects<Qualifiers>() = epi.
TypeQuals;
3827 auto &EllipsisLoc = *getTrailingObjects<SourceLocation>();
3832 auto &ExtraBits = *getTrailingObjects<FunctionTypeExtraBitfields>();
3834 ExtraBits.NumFunctionEffects = EffectsCount;
3835 assert(ExtraBits.NumFunctionEffects == EffectsCount &&
3836 "effect bitfield overflow");
3839 auto *DestFX = getTrailingObjects<FunctionEffect>();
3840 llvm::uninitialized_copy(SrcFX, DestFX);
3843 if (!SrcConds.empty()) {
3844 ExtraBits.EffectsHaveConditions =
true;
3845 auto *DestConds = getTrailingObjects<EffectConditionExpr>();
3846 llvm::uninitialized_copy(SrcConds, DestConds);
3847 assert(llvm::any_of(SrcConds,
3854 "expected a dependent expression among the conditions");
3862 return NE->isValueDependent();
3874 return NE->isInstantiationDependent();
3885 llvm_unreachable(
"should not call this with unresolved exception specs");
3911 llvm_unreachable(
"unexpected exception specification kind");
3915 for (
unsigned ArgIdx =
getNumParams(); ArgIdx; --ArgIdx)
3923 const QualType *ArgTys,
unsigned NumParams,
3924 const ExtProtoInfo &epi,
3948 ID.AddPointer(
Result.getAsOpaquePtr());
3949 for (
unsigned i = 0; i != NumParams; ++i)
3950 ID.AddPointer(ArgTys[i].getAsOpaquePtr());
3954 assert(!(
unsigned(epi.Variadic) & ~1) && !(
unsigned(epi.RefQualifier) & ~3) &&
3955 !(
unsigned(epi.ExceptionSpec.Type) & ~15) &&
3956 "Values larger than expected.");
3957 ID.AddInteger(
unsigned(epi.Variadic) + (epi.RefQualifier << 1) +
3958 (epi.ExceptionSpec.Type << 3));
3959 ID.Add(epi.TypeQuals);
3961 for (
QualType Ex : epi.ExceptionSpec.Exceptions)
3964 epi.ExceptionSpec.NoexceptExpr->Profile(ID, Context, Canonical);
3967 ID.AddPointer(epi.ExceptionSpec.SourceDecl->getCanonicalDecl());
3969 if (epi.ExtParameterInfos) {
3970 for (
unsigned i = 0; i != NumParams; ++i)
3971 ID.AddInteger(epi.ExtParameterInfos[i].getOpaqueValue());
3974 epi.ExtInfo.Profile(ID);
3975 epi.ExtraAttributeInfo.Profile(ID);
3977 unsigned EffectCount = epi.FunctionEffects.size();
3978 bool HasConds = !epi.FunctionEffects.Conditions.empty();
3980 ID.AddInteger((EffectCount << 3) | (HasConds << 2) |
3981 (epi.AArch64SMEAttributes << 1) | epi.HasTrailingReturn);
3982 ID.AddInteger(epi.CFIUncheckedCallee);
3984 for (
unsigned Idx = 0; Idx != EffectCount; ++Idx) {
3985 ID.AddInteger(epi.FunctionEffects.Effects[Idx].toOpaqueInt32());
3987 ID.AddPointer(epi.FunctionEffects.Conditions[Idx].getCondition());
3998 :
Data(
D, Deref << DerefShift) {}
4001 return Data.getInt() & DerefMask;
4006 return Data.getOpaqueValue();
4013 Data.setFromOpaqueValue(
V);
4018 :
Type(TC, Canon, Wrapped->getDependence()), WrappedTy(Wrapped) {}
4020CountAttributedType::CountAttributedType(
4024 CountExpr(CountExpr) {
4028 auto *DeclSlot = getTrailingObjects();
4029 llvm::copy(CoupledDecls, DeclSlot);
4038#define ENUMERATE_ATTRS(PREFIX) \
4040 if (isCountInBytes()) { \
4042 return PREFIX "sized_by_or_null"; \
4043 return PREFIX "sized_by"; \
4046 return PREFIX "counted_by_or_null"; \
4047 return PREFIX "counted_by"; \
4050 if (WithMacroPrefix)
4055#undef ENUMERATE_ATTRS
4061 bool HasTypeDifferentFromDecl)
4063 Keyword, TC, UnderlyingType.getCanonicalType(),
4067 ~NestedNameSpecifierDependence::
Dependent)
4071 *getTrailingObjects<NestedNameSpecifier>() = Qualifier;
4072 if ((
TypedefBits.hasTypeDifferentFromDecl = HasTypeDifferentFromDecl))
4073 *getTrailingObjects<QualType>() = UnderlyingType;
4078 : *getTrailingObjects<QualType>();
4084 const Type *CanonicalType)
4090 ~NestedNameSpecifierDependence::
Dependent)
4094 *getTrailingObjects<NestedNameSpecifier>() = Qualifier;
4103 if ((
UsingBits.hasQualifier = !!Qualifier))
4104 *getTrailingObjects() = Qualifier;
4113 while (
auto *InnerMQT = dyn_cast<MacroQualifiedType>(Inner)) {
4116 Inner = InnerMQT->getModifiedType();
4127 ? Context.getUnqualifiedArrayType(Can).getAtomicUnqualifiedType()
4130 (
E->getType()->getDependence() &
4132 TOExpr(
E), Context(Context) {
4133 TypeOfBits.Kind =
static_cast<unsigned>(Kind);
4152 ID.AddBoolean(IsUnqual);
4159 ? Context.getUnqualifiedArrayType(Can).getAtomicUnqualifiedType()
4161 T->getDependence()),
4162 TOType(
T), Context(Context) {
4163 TypeOfBits.Kind =
static_cast<unsigned>(Kind);
4177 :
Type(Decltype, can,
4181 (
E->getType()->getDependence() &
4183 E(
E), UnderlyingType(underlyingType) {}
4203 Expr *IndexExpr,
bool FullySubstituted,
4205 :
Type(PackIndexing, Canonical,
4207 Pattern(Pattern), IndexExpr(IndexExpr), Size(Expansions.size()),
4208 FullySubstituted(FullySubstituted) {
4210 llvm::uninitialized_copy(Expansions, getTrailingObjects());
4215 return std::nullopt;
4219 return std::nullopt;
4221 assert(Index.isNonNegative() &&
"Invalid index");
4222 return static_cast<unsigned>(Index.getExtValue());
4226PackIndexingType::computeDependence(
QualType Pattern,
Expr *IndexExpr,
4231 ? TypeDependence::DependentInstantiation
4232 : TypeDependence::None);
4233 if (Expansions.empty())
4234 TD |= Pattern->
getDependence() & TypeDependence::DependentInstantiation;
4239 if (!(IndexD & TypeDependence::UnexpandedPack))
4240 TD &= ~TypeDependence::UnexpandedPack;
4245 TD |= TypeDependence::Error | TypeDependence::DependentInstantiation;
4258 Expr *
E,
bool FullySubstituted,
4262 ID.AddBoolean(FullySubstituted);
4263 if (!Expansions.empty()) {
4264 ID.AddInteger(Expansions.size());
4275 :
Type(UnaryTransform, CanonicalType, BaseType->getDependence()),
4276 BaseType(BaseType), UnderlyingType(UnderlyingType), UKind(UKind) {}
4280 bool OwnsTag,
bool ISInjected,
const Type *CanonicalType)
4287 ~NestedNameSpecifierDependence::
Dependent)
4291 getTrailingQualifier() = Qualifier;
4296void *TagType::getTrailingPointer()
const {
4299 return const_cast<EnumType *
>(cast<EnumType>(
this) + 1);
4301 return const_cast<RecordType *
>(cast<RecordType>(
this) + 1);
4302 case Type::InjectedClassName:
4304 cast<InjectedClassNameType>(
this) + 1);
4306 llvm_unreachable(
"unexpected type class");
4313 getTrailingPointer(), llvm::Align::Of<NestedNameSpecifier *>()));
4317 return TagTypeBits.HasQualifier ? getTrailingQualifier() : std::nullopt;
4321 auto *
Decl = dyn_cast<CXXRecordDecl>(decl);
4324 if (
auto *RD = dyn_cast<ClassTemplateSpecializationDecl>(
Decl))
4325 return RD->getSpecializedTemplate();
4326 return Decl->getDescribedClassTemplate();
4341 auto *
Decl = dyn_cast<CXXRecordDecl>(decl);
4345 if (
auto *RD = dyn_cast<ClassTemplateSpecializationDecl>(
Decl))
4346 return RD->getTemplateArgs().asArray();
4348 return TD->getTemplateParameters()->getInjectedTemplateArgs(Ctx);
4353 std::vector<const RecordType *> RecordTypeList;
4354 RecordTypeList.push_back(
this);
4355 unsigned NextToCheckIndex = 0;
4357 while (RecordTypeList.size() > NextToCheckIndex) {
4358 for (
FieldDecl *FD : RecordTypeList[NextToCheckIndex]
4367 if (!llvm::is_contained(RecordTypeList, FieldRecTy))
4368 RecordTypeList.push_back(FieldRecTy);
4378 const TagDecl *TD,
bool IsInjected,
4379 const Type *CanonicalType)
4381 false, IsInjected, CanonicalType) {}
4383AttributedType::AttributedType(
QualType canon,
const Attr *attr,
4390 :
Type(Attributed, canon, equivalent->getDependence()), Attribute(
attr),
4391 ModifiedType(modified), EquivalentType(equivalent) {
4393 assert(!attr ||
attr->getKind() == attrKind);
4403 case attr::ObjCOwnership:
4404 case attr::ObjCInertUnsafeUnretained:
4405 case attr::TypeNonNull:
4406 case attr::TypeNullable:
4407 case attr::TypeNullableResult:
4408 case attr::TypeNullUnspecified:
4409 case attr::LifetimeBound:
4410 case attr::AddressSpace:
4431 llvm_unreachable(
"invalid attr kind");
4445 case attr::FastCall:
4447 case attr::ThisCall:
4449 case attr::SwiftCall:
4450 case attr::SwiftAsyncCall:
4451 case attr::VectorCall:
4452 case attr::AArch64VectorPcs:
4453 case attr::AArch64SVEPcs:
4454 case attr::DeviceKernel:
4458 case attr::IntelOclBicc:
4459 case attr::PreserveMost:
4460 case attr::PreserveAll:
4462 case attr::PreserveNone:
4463 case attr::RISCVVectorCC:
4464 case attr::RISCVVLSCC:
4467 llvm_unreachable(
"invalid attr kind");
4476 if (
const auto *TTP = dyn_cast<TemplateTypeParmDecl>(
D))
4478 return cast<TemplateTypeParmDecl>(
4482SubstTemplateTypeParmType::SubstTemplateTypeParmType(
QualType Replacement,
4483 Decl *AssociatedDecl,
4487 :
Type(SubstTemplateTypeParm, Replacement.getCanonicalType(),
4488 Replacement->getDependence()),
4489 AssociatedDecl(AssociatedDecl) {
4490 SubstTemplateTypeParmTypeBits.HasNonCanonicalUnderlyingType =
4491 Replacement != getCanonicalTypeInternal();
4492 if (SubstTemplateTypeParmTypeBits.HasNonCanonicalUnderlyingType)
4493 *getTrailingObjects() = Replacement;
4495 SubstTemplateTypeParmTypeBits.Index = Index;
4496 SubstTemplateTypeParmTypeBits.Final = Final;
4497 SubstTemplateTypeParmTypeBits.PackIndex =
4499 assert(AssociatedDecl !=
nullptr);
4509 const Decl *AssociatedDecl,
4512 Replacement.Profile(ID);
4513 ID.AddPointer(AssociatedDecl);
4514 ID.AddInteger(Index);
4516 ID.AddBoolean(Final);
4521 :
Type(Derived, Canon,
4524 Arguments(ArgPack.pack_begin()) {
4525 assert(llvm::all_of(
4527 [](
auto &
P) { return P.getKind() == TemplateArgument::Type; }) &&
4528 "non-type argument to SubstPackType?");
4544 ID.AddPointer(
P.getAsType().getAsOpaquePtr());
4547SubstTemplateTypeParmPackType::SubstTemplateTypeParmPackType(
4548 QualType Canon,
Decl *AssociatedDecl,
unsigned Index,
bool Final,
4551 AssociatedDeclAndFinal(AssociatedDecl, Final) {
4552 assert(AssociatedDecl !=
nullptr);
4556 "Parent bitfields in SubstPackType were overwritten."
4557 "Check NumSubstPackTypeBits.");
4561 return AssociatedDeclAndFinal.getPointer();
4565 return AssociatedDeclAndFinal.getInt();
4582 const Decl *AssociatedDecl,
4583 unsigned Index,
bool Final,
4585 ID.AddPointer(AssociatedDecl);
4586 ID.AddInteger(Index);
4587 ID.AddBoolean(Final);
4591SubstBuiltinTemplatePackType::SubstBuiltinTemplatePackType(
4593 :
SubstPackType(SubstBuiltinTemplatePack, Canon, ArgPack) {}
4604 if (Arg.isDependent())
4612 if (ArgLoc.getArgument().isInstantiationDependent())
4621 ? TypeDependence::DependentInstantiation
4626 D |= TypeDependence::UnexpandedPack;
4628 D |= (Underlying->
getDependence() & TypeDependence::UnexpandedPack);
4633TemplateSpecializationType::TemplateSpecializationType(
4637 Underlying.isNull() ?
QualType(this, 0)
4638 : Underlying.getCanonicalType(),
4641 TemplateSpecializationTypeBits.NumArgs = Args.size();
4642 TemplateSpecializationTypeBits.TypeAlias = IsAlias;
4644 assert(!
T.getAsDependentTemplateName() &&
4645 "Use DependentTemplateSpecializationType for dependent template-name");
4653 "Unexpected template name for TemplateSpecializationType");
4655 auto *TemplateArgs =
4667 ~TypeDependence::Dependent);
4669 addDependence(Arg.getAsType()->getDependence() &
4670 TypeDependence::VariablyModified);
4677 *
reinterpret_cast<QualType *
>(TemplateArgs) = Underlying;
4681 assert(
isTypeAlias() &&
"not a type alias template specialization");
4686 return !isDependentType() || isCurrentInstantiation() || isTypeAlias() ||
4688 isa<SubstBuiltinTemplatePackType>(*getCanonicalTypeInternal()));
4705 ID.AddInteger(Args.size());
4707 Arg.Profile(ID, Context);
4719 const Type *
T)
const {
4731 ID.AddInteger(typeArgs.size());
4732 for (
auto typeArg : typeArgs)
4733 ID.AddPointer(typeArg.getAsOpaquePtr());
4734 ID.AddInteger(protocols.size());
4735 for (
auto *proto : protocols)
4736 ID.AddPointer(proto);
4737 ID.AddBoolean(isKindOf);
4750 ID.AddPointer(OTPDecl);
4752 ID.AddInteger(protocols.size());
4753 for (
auto *proto : protocols)
4754 ID.AddPointer(proto);
4765class CachedProperties {
4770 CachedProperties(
Linkage L,
bool local) : L(L), local(local) {}
4772 Linkage getLinkage()
const {
return L; }
4773 bool hasLocalOrUnnamedType()
const {
return local; }
4775 friend CachedProperties merge(CachedProperties L, CachedProperties R) {
4777 return CachedProperties(MergedLinkage, L.hasLocalOrUnnamedType() ||
4778 R.hasLocalOrUnnamedType());
4797 return CachedProperties(
T->
TypeBits.getLinkage(),
4840#define TYPE(Class, Base)
4841#define NON_CANONICAL_TYPE(Class, Base) case Type::Class:
4842#include "clang/AST/TypeNodes.inc"
4843 llvm_unreachable(
"didn't expect a non-canonical type here");
4845#define TYPE(Class, Base)
4846#define DEPENDENT_TYPE(Class, Base) case Type::Class:
4847#define NON_CANONICAL_UNLESS_DEPENDENT_TYPE(Class, Base) case Type::Class:
4848#include "clang/AST/TypeNodes.inc"
4854 case Type::DeducedTemplateSpecialization:
4869 cast<TagType>(
T)->getOriginalDecl()->getDefinitionOrSelf();
4875 Linkage L = Tag->getLinkageInternal();
4876 bool IsLocalOrUnnamed = Tag->getDeclContext()->isFunctionOrMethod() ||
4877 !Tag->hasNameForLinkage();
4878 return CachedProperties(L, IsLocalOrUnnamed);
4885 return Cache::get(cast<ComplexType>(
T)->getElementType());
4888 case Type::BlockPointer:
4890 case Type::LValueReference:
4891 case Type::RValueReference:
4893 case Type::MemberPointer: {
4894 const auto *MPT = cast<MemberPointerType>(
T);
4895 CachedProperties Cls = [&] {
4896 if (MPT->isSugared())
4897 MPT = cast<MemberPointerType>(MPT->getCanonicalTypeInternal());
4898 return Cache::get(MPT->getQualifier().getAsType());
4900 return merge(Cls,
Cache::get(MPT->getPointeeType()));
4902 case Type::ConstantArray:
4903 case Type::IncompleteArray:
4904 case Type::VariableArray:
4905 case Type::ArrayParameter:
4906 return Cache::get(cast<ArrayType>(
T)->getElementType());
4908 case Type::ExtVector:
4909 return Cache::get(cast<VectorType>(
T)->getElementType());
4910 case Type::ConstantMatrix:
4911 return Cache::get(cast<ConstantMatrixType>(
T)->getElementType());
4912 case Type::FunctionNoProto:
4913 return Cache::get(cast<FunctionType>(
T)->getReturnType());
4914 case Type::FunctionProto: {
4915 const auto *FPT = cast<FunctionProtoType>(
T);
4916 CachedProperties result =
Cache::get(FPT->getReturnType());
4917 for (
const auto &ai : FPT->param_types())
4921 case Type::ObjCInterface: {
4922 Linkage L = cast<ObjCInterfaceType>(
T)->getDecl()->getLinkageInternal();
4923 return CachedProperties(L,
false);
4925 case Type::ObjCObject:
4926 return Cache::get(cast<ObjCObjectType>(
T)->getBaseType());
4927 case Type::ObjCObjectPointer:
4930 return Cache::get(cast<AtomicType>(
T)->getValueType());
4932 return Cache::get(cast<PipeType>(
T)->getElementType());
4933 case Type::HLSLAttributedResource:
4934 return Cache::get(cast<HLSLAttributedResourceType>(
T)->getWrappedType());
4935 case Type::HLSLInlineSpirv:
4939 llvm_unreachable(
"unhandled type class");
4950 return TypeBits.hasLocalOrUnnamedType();
4955#define TYPE(Class, Base)
4956#define NON_CANONICAL_TYPE(Class, Base) case Type::Class:
4957#include "clang/AST/TypeNodes.inc"
4958 llvm_unreachable(
"didn't expect a non-canonical type here");
4960#define TYPE(Class, Base)
4961#define DEPENDENT_TYPE(Class, Base) case Type::Class:
4962#define NON_CANONICAL_UNLESS_DEPENDENT_TYPE(Class, Base) case Type::Class:
4963#include "clang/AST/TypeNodes.inc"
4973 case Type::DeducedTemplateSpecialization:
4985 case Type::BlockPointer:
4987 case Type::LValueReference:
4988 case Type::RValueReference:
4990 case Type::MemberPointer: {
4991 const auto *MPT = cast<MemberPointerType>(
T);
4993 if (
auto *
D = MPT->getMostRecentCXXRecordDecl()) {
5001 case Type::ConstantArray:
5002 case Type::IncompleteArray:
5003 case Type::VariableArray:
5004 case Type::ArrayParameter:
5007 case Type::ExtVector:
5009 case Type::ConstantMatrix:
5011 cast<ConstantMatrixType>(
T)->getElementType());
5012 case Type::FunctionNoProto:
5014 case Type::FunctionProto: {
5015 const auto *FPT = cast<FunctionProtoType>(
T);
5017 for (
const auto &ai : FPT->param_types())
5021 case Type::ObjCInterface:
5023 case Type::ObjCObject:
5025 case Type::ObjCObjectPointer:
5032 case Type::HLSLAttributedResource:
5034 ->getContainedType()
5035 ->getCanonicalTypeInternal());
5036 case Type::HLSLInlineSpirv:
5040 llvm_unreachable(
"unhandled type class");
5071 if (
auto Nullability = AT->getImmediateNullability())
5074 Type = AT->getEquivalentType();
5076 return std::nullopt;
5082 switch (
type->getTypeClass()) {
5083#define NON_CANONICAL_TYPE(Class, Parent) \
5086 llvm_unreachable("non-canonical type");
5087#define TYPE(Class, Parent)
5088#include "clang/AST/TypeNodes.inc"
5092 case Type::BlockPointer:
5093 case Type::MemberPointer:
5094 case Type::ObjCObjectPointer:
5098 case Type::UnresolvedUsing:
5099 case Type::TypeOfExpr:
5101 case Type::Decltype:
5102 case Type::PackIndexing:
5103 case Type::UnaryTransform:
5104 case Type::TemplateTypeParm:
5105 case Type::SubstTemplateTypeParmPack:
5106 case Type::SubstBuiltinTemplatePack:
5107 case Type::DependentName:
5108 case Type::DependentTemplateSpecialization:
5110 return ResultIfUnknown;
5113 case Type::TemplateSpecialization:
5116 cast<TemplateSpecializationType>(
type.getTypePtr())
5118 .getAsTemplateDecl())
5119 if (
auto *CTD = dyn_cast<ClassTemplateDecl>(templateDecl))
5120 return llvm::any_of(
5122 return RTD->getTemplatedDecl()->hasAttr<TypeNullableAttr>();
5124 return ResultIfUnknown;
5127 switch (cast<BuiltinType>(
type.getTypePtr())->getKind()) {
5129#define SIGNED_TYPE(Id, SingletonId) case BuiltinType::Id:
5130#define UNSIGNED_TYPE(Id, SingletonId) case BuiltinType::Id:
5131#define FLOATING_TYPE(Id, SingletonId) case BuiltinType::Id:
5132#define BUILTIN_TYPE(Id, SingletonId)
5133#include "clang/AST/BuiltinTypes.def"
5136 case BuiltinType::UnresolvedTemplate:
5138 case BuiltinType::Dependent:
5139 case BuiltinType::Overload:
5140 case BuiltinType::BoundMember:
5141 case BuiltinType::PseudoObject:
5142 case BuiltinType::UnknownAny:
5143 case BuiltinType::ARCUnbridgedCast:
5144 return ResultIfUnknown;
5146 case BuiltinType::Void:
5147 case BuiltinType::ObjCId:
5148 case BuiltinType::ObjCClass:
5149 case BuiltinType::ObjCSel:
5150#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
5151 case BuiltinType::Id:
5152#include "clang/Basic/OpenCLImageTypes.def"
5153#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) case BuiltinType::Id:
5154#include "clang/Basic/OpenCLExtensionTypes.def"
5155 case BuiltinType::OCLSampler:
5156 case BuiltinType::OCLEvent:
5157 case BuiltinType::OCLClkEvent:
5158 case BuiltinType::OCLQueue:
5159 case BuiltinType::OCLReserveID:
5160#define SVE_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
5161#include "clang/Basic/AArch64ACLETypes.def"
5162#define PPC_VECTOR_TYPE(Name, Id, Size) case BuiltinType::Id:
5163#include "clang/Basic/PPCTypes.def"
5164#define RVV_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
5165#include "clang/Basic/RISCVVTypes.def"
5166#define WASM_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
5167#include "clang/Basic/WebAssemblyReferenceTypes.def"
5168#define AMDGPU_TYPE(Name, Id, SingletonId, Width, Align) case BuiltinType::Id:
5169#include "clang/Basic/AMDGPUTypes.def"
5170#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
5171#include "clang/Basic/HLSLIntangibleTypes.def"
5172 case BuiltinType::BuiltinFn:
5173 case BuiltinType::NullPtr:
5174 case BuiltinType::IncompleteMatrixIdx:
5175 case BuiltinType::ArraySection:
5176 case BuiltinType::OMPArrayShaping:
5177 case BuiltinType::OMPIterator:
5180 llvm_unreachable(
"unknown builtin type");
5182 case Type::Record: {
5183 const RecordDecl *RD = cast<RecordType>(
type)->getOriginalDecl();
5186 if (
const auto *CTSD = dyn_cast<ClassTemplateSpecializationDecl>(RD))
5187 return llvm::any_of(
5188 CTSD->getSpecializedTemplate()->redecls(),
5190 return RTD->getTemplatedDecl()->hasAttr<TypeNullableAttr>();
5193 return RD->hasAttr<TypeNullableAttr>();
5199 case Type::LValueReference:
5200 case Type::RValueReference:
5201 case Type::ConstantArray:
5202 case Type::IncompleteArray:
5203 case Type::VariableArray:
5204 case Type::DependentSizedArray:
5205 case Type::DependentVector:
5206 case Type::DependentSizedExtVector:
5208 case Type::ExtVector:
5209 case Type::ConstantMatrix:
5210 case Type::DependentSizedMatrix:
5211 case Type::DependentAddressSpace:
5212 case Type::FunctionProto:
5213 case Type::FunctionNoProto:
5214 case Type::DeducedTemplateSpecialization:
5216 case Type::InjectedClassName:
5217 case Type::PackExpansion:
5218 case Type::ObjCObject:
5219 case Type::ObjCInterface:
5223 case Type::DependentBitInt:
5224 case Type::ArrayParameter:
5225 case Type::HLSLAttributedResource:
5226 case Type::HLSLInlineSpirv:
5229 llvm_unreachable(
"bad type kind!");
5241 return std::nullopt;
5244std::optional<NullabilityKind>
5247 if (
auto MacroTy = dyn_cast<MacroQualifiedType>(
T))
5248 AttrTy = MacroTy->getUnderlyingType();
5250 if (
auto attributed = dyn_cast<AttributedType>(AttrTy)) {
5251 if (
auto nullability = attributed->getImmediateNullability()) {
5252 T = attributed->getModifiedType();
5257 return std::nullopt;
5267 const auto *objcPtr = getAs<ObjCObjectPointerType>();
5271 if (objcPtr->isObjCIdType()) {
5282 }
else if (objcPtr->isObjCQualifiedIdType()) {
5307 "cannot query implicit lifetime for non-inferrable type");
5312 while (
const auto *array = dyn_cast<ArrayType>(canon))
5313 canon = array->getElementType().getTypePtr();
5315 if (
const auto *opt = dyn_cast<ObjCObjectPointerType>(canon)) {
5317 if (opt->getObjectType()->isObjCClass())
5325 if (
const auto *
typedefType = getAs<TypedefType>())
5326 return typedefType->getDecl()->hasAttr<ObjCNSObjectAttr>();
5331 if (
const auto *
typedefType = getAs<TypedefType>())
5332 return typedefType->getDecl()->hasAttr<ObjCIndependentClassAttr>();
5344 if (
const auto *OPT = getAs<PointerType>())
5345 return OPT->getPointeeType()->isObjCIndirectLifetimeType();
5346 if (
const auto *Ref = getAs<ReferenceType>())
5347 return Ref->getPointeeType()->isObjCIndirectLifetimeType();
5348 if (
const auto *MemPtr = getAs<MemberPointerType>())
5349 return MemPtr->getPointeeType()->isObjCIndirectLifetimeType();
5357 while (
const ArrayType *array =
type->getAsArrayTypeUnsafe())
5358 type = array->getElementType().getTypePtr();
5359 return type->isObjCRetainableType();
5370 const auto *
Pointer = getAsCanonical<PointerType>();
5380 if (
const auto *RT = getAsCanonical<RecordType>())
5381 return RT->getOriginalDecl()
5382 ->getMostRecentDecl()
5383 ->hasAttr<CUDADeviceBuiltinSurfaceTypeAttr>();
5389 if (
const auto *RT = getAsCanonical<RecordType>())
5390 return RT->getOriginalDecl()
5391 ->getMostRecentDecl()
5392 ->hasAttr<CUDADeviceBuiltinTextureTypeAttr>();
5400 if (
const auto *ptr = getAs<PointerType>())
5401 return ptr->getPointeeType()->hasSizedVLAType();
5402 if (
const auto *ref = getAs<ReferenceType>())
5403 return ref->getPointeeType()->hasSizedVLAType();
5405 if (isa<VariableArrayType>(arr) &&
5406 cast<VariableArrayType>(arr)->getSizeExpr())
5409 return arr->getElementType()->hasSizedVLAType();
5423 while (isa<ConstantArrayType>(Ty))
5436 while (isa<ConstantArrayType>(Ty))
5445 assert(RD !=
nullptr &&
5446 "all HLSL structs and classes should be CXXRecordDecl");
5452 switch (
type.getObjCLifetime()) {
5464 if (
const auto *RD =
type->getBaseElementTypeUnsafe()->getAsRecordDecl()) {
5465 if (
const auto *CXXRD = dyn_cast<CXXRecordDecl>(RD)) {
5467 if (CXXRD->hasDefinition() && !CXXRD->hasTrivialDestructor())
5491 Qualifier.Profile(ID);
5503 auto *RD = getCXXRecordDecl();
5510 llvm::APSInt Val,
unsigned Scale) {
5511 llvm::FixedPointSemantics FXSema(Val.getBitWidth(), Scale, Val.isSigned(),
5514 llvm::APFixedPoint(Val, FXSema).toString(Str);
5522 AutoTypeBits.Keyword = llvm::to_underlying(
Keyword);
5523 AutoTypeBits.NumArgs = TypeConstraintArgs.size();
5524 this->TypeConstraintConcept = TypeConstraintConcept;
5525 assert(TypeConstraintConcept || AutoTypeBits.NumArgs == 0);
5526 if (TypeConstraintConcept) {
5527 if (isa<TemplateTemplateParmDecl>(TypeConstraintConcept))
5528 addDependence(TypeDependence::DependentInstantiation);
5548 ID.AddInteger((
unsigned)
Keyword);
5549 ID.AddBoolean(IsDependent);
5552 Arg.Profile(ID, Context);
5571 llvm_unreachable(
"unknown effect kind");
5577 return "nonblocking";
5579 return "nonallocating";
5583 return "allocating";
5585 llvm_unreachable(
"unknown effect kind");
5601 return std::nullopt;
5606 assert(0 &&
"effectProhibitingInference with non-inferable effect kind");
5609 llvm_unreachable(
"unknown effect kind");
5619 const Kind EK = Effect.kind();
5621 if (EK == CallerKind ||
5632 llvm_unreachable(
"unknown effect kind");
5644 unsigned InsertIdx = Effects.size();
5659 Errs.push_back({EC, NewEC});
5670 if (NewCondition || !Conditions.empty()) {
5671 if (Conditions.empty() && !Effects.empty())
5672 Conditions.resize(Effects.size());
5673 Conditions.insert(Conditions.begin() + InsertIdx,
5676 Effects.insert(Effects.begin() + InsertIdx, NewEC.
Effect);
5681 for (
const auto &Item :
Set)
5683 return Errs.empty();
5694 auto IterA = LHS.
begin(), EndA = LHS.
end();
5695 auto IterB = RHS.
begin(), EndB = RHS.
end();
5699 return std::tuple(LHS.Effect,
uintptr_t(LHS.Cond.getCondition())) <
5700 std::tuple(RHS.Effect,
uintptr_t(RHS.Cond.getCondition()));
5703 while (IterA != EndA && IterB != EndB) {
5708 else if (FEWCLess(B, A))
5719 assert(Errs.empty() &&
"conflict shouldn't be possible in getIntersection");
5732 Combined.
insert(RHS, Errs);
5753 llvm::interleaveComma(*
this, OS);
5763 llvm::interleaveComma(*
this, OS);
5770 assert(llvm::is_sorted(FX) &&
"effects should be sorted");
5771 assert((Conds.empty() || Conds.size() == FX.size()) &&
5772 "effects size should match conditions size");
5789 if (!RD->
fields().empty()) {
5790 const auto &FirstFD = RD->
fields().begin();
5791 return dyn_cast<HLSLAttributedResourceType>(
5792 FirstFD->getType().getTypePtr());
5798StringRef PredefinedSugarType::getName(Kind KD) {
5803 return "__signed_size_t";
5805 return "__ptrdiff_t";
5807 llvm_unreachable(
"unexpected kind");
Defines the clang::ASTContext interface.
Provides definitions for the various language-specific address spaces.
static Decl::Kind getKind(const Decl *D)
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate....
Defines the C++ template declaration subclasses.
static DeclT * getDefinitionOrSelf(DeclT *D)
Defines the ExceptionSpecificationType enumeration and various utility functions.
Defines the clang::IdentifierInfo, clang::IdentifierTable, and clang::Selector interfaces.
#define CC_VLS_CASE(ABI_VLEN)
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified.
Defines the clang::LangOptions interface.
llvm::MachO::Record Record
static RecordDecl * getAsRecordDecl(QualType BaseType, HeuristicResolver &Resolver)
static bool isRecordType(QualType T)
Defines various enumerations that describe declaration and type specifiers.
static QualType getPointeeType(const MemRegion *R)
Defines the TargetCXXABI class, which abstracts details of the C++ ABI that we're targeting.
static TypeDependence getTemplateSpecializationTypeDependence(QualType Underlying, TemplateName T)
#define ENUMERATE_ATTRS(PREFIX)
#define SUGARED_TYPE_CLASS(Class)
static const TemplateTypeParmDecl * getReplacedParameter(Decl *D, unsigned Index)
static bool isTriviallyCopyableTypeImpl(const QualType &type, const ASTContext &Context, bool IsCopyConstructible)
static const T * getAsSugar(const Type *Cur)
This will check for a T (which should be a Type which can act as sugar, such as a TypedefType) by rem...
#define TRIVIAL_TYPE_CLASS(Class)
static CachedProperties computeCachedProperties(const Type *T)
C Language Family Type Representation.
Defines the clang::Visibility enumeration and various utility functions.
__DEVICE__ void * memcpy(void *__a, const void *__b, size_t __c)
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
BuiltinVectorTypeInfo getBuiltinVectorTypeInfo(const BuiltinType *VecTy) const
Returns the element type, element count and number of vectors (in case of tuple) for a builtin vector...
QualType getAtomicType(QualType T) const
Return the uniqued reference to the atomic type for the specified type.
QualType getParenType(QualType NamedType) const
QualType getRValueReferenceType(QualType T) const
Return the uniqued reference to the type for an rvalue reference to the specified type.
QualType getObjCInterfaceType(const ObjCInterfaceDecl *Decl, ObjCInterfaceDecl *PrevDecl=nullptr) const
getObjCInterfaceType - Return the unique reference to the type for the specified ObjC interface decl.
QualType getBlockPointerType(QualType T) const
Return the uniqued reference to the type for a block of the specified type.
QualType getAttributedType(attr::Kind attrKind, QualType modifiedType, QualType equivalentType, const Attr *attr=nullptr) const
QualType getFunctionNoProtoType(QualType ResultTy, const FunctionType::ExtInfo &Info) const
Return a K&R style C function type like 'int()'.
QualType getArrayParameterType(QualType Ty) const
Return the uniqued reference to a specified array parameter type from the original array type.
QualType getVectorType(QualType VectorType, unsigned NumElts, VectorKind VecKind) const
Return the unique reference to a vector type of the specified element type and size.
QualType getSubstTemplateTypeParmType(QualType Replacement, Decl *AssociatedDecl, unsigned Index, UnsignedOrNone PackIndex, bool Final) const
Retrieve a substitution-result type.
QualType getPointerType(QualType T) const
Return the uniqued reference to the type for a pointer to the specified type.
QualType getLValueReferenceType(QualType T, bool SpelledAsLValue=true) const
Return the uniqued reference to the type for an lvalue reference to the specified type.
QualType getConstantArrayType(QualType EltTy, const llvm::APInt &ArySize, const Expr *SizeExpr, ArraySizeModifier ASM, unsigned IndexTypeQuals) const
Return the unique reference to the type for a constant array of the specified element type.
const LangOptions & getLangOpts() const
bool containsAddressDiscriminatedPointerAuth(QualType T) const
Examines a given type, and returns whether the type itself is address discriminated,...
QualType applyObjCProtocolQualifiers(QualType type, ArrayRef< ObjCProtocolDecl * > protocols, bool &hasError, bool allowOnPointerType=false) const
Apply Objective-C protocol qualifiers to the given type.
QualType getDecayedType(QualType T) const
Return the uniqued reference to the decayed version of the given type.
QualType getBaseElementType(const ArrayType *VAT) const
Return the innermost element type of an array type.
CanQualType ObjCBuiltinIdTy
IdentifierInfo * getNSObjectName() const
Retrieve the identifier 'NSObject'.
QualType getAdjustedType(QualType Orig, QualType New) const
Return the uniqued reference to a type adjusted from the original type to a new type.
QualType getQualifiedType(SplitQualType split) const
Un-split a SplitQualType.
QualType getObjCObjectPointerType(QualType OIT) const
Return a ObjCObjectPointerType type for the given ObjCObjectType.
QualType getObjCObjectType(QualType Base, ObjCProtocolDecl *const *Protocols, unsigned NumProtocols) const
Legacy interface: cannot provide type arguments or __kindof.
QualType getVariableArrayType(QualType EltTy, Expr *NumElts, ArraySizeModifier ASM, unsigned IndexTypeQuals) const
Return a non-unique reference to the type for a variable array of the specified element type.
const ArrayType * getAsArrayType(QualType T) const
Type Query functions.
uint64_t getTypeSize(QualType T) const
Return the size of the specified (complete) type T, in bits.
CharUnits getTypeSizeInChars(QualType T) const
Return the size of the specified (complete) type T, in characters.
QualType getAutoType(QualType DeducedType, AutoTypeKeyword Keyword, bool IsDependent, bool IsPack=false, TemplateDecl *TypeConstraintConcept=nullptr, ArrayRef< TemplateArgument > TypeConstraintArgs={}) const
C++11 deduced auto type.
CanQualType UnsignedCharTy
TemplateName getQualifiedTemplateName(NestedNameSpecifier Qualifier, bool TemplateKeyword, TemplateName Template) const
Retrieve the template name that represents a qualified template name such as std::vector.
QualType getFunctionType(QualType ResultTy, ArrayRef< QualType > Args, const FunctionProtoType::ExtProtoInfo &EPI) const
Return a normal function type with a typed argument list.
QualType getMemberPointerType(QualType T, NestedNameSpecifier Qualifier, const CXXRecordDecl *Cls) const
Return the uniqued reference to the type for a member pointer to the specified type in the specified ...
QualType getComplexType(QualType T) const
Return the uniqued reference to the type for a complex number with the specified element type.
QualType getSizeType() const
Return the unique type for "size_t" (C99 7.17), defined in <stddef.h>.
QualType getExtVectorType(QualType VectorType, unsigned NumElts) const
Return the unique reference to an extended vector type of the specified element type and size.
const TargetInfo & getTargetInfo() const
QualType getIncompleteArrayType(QualType EltTy, ArraySizeModifier ASM, unsigned IndexTypeQuals) const
Return a unique reference to the type for an incomplete array of the specified element type.
QualType getUnqualifiedArrayType(QualType T, Qualifiers &Quals) const
Return this type as a completely-unqualified array type, capturing the qualifiers in Quals.
QualType getConstantMatrixType(QualType ElementType, unsigned NumRows, unsigned NumColumns) const
Return the unique reference to the matrix type of the specified element type and size.
IdentifierInfo * getNSCopyingName()
Retrieve the identifier 'NSCopying'.
Represents a type which was implicitly adjusted by the semantic engine for arbitrary reasons.
Represents a constant array type that does not decay to a pointer when used as a function parameter.
QualType getConstantArrayType(const ASTContext &Ctx) const
Represents an array type, per C99 6.7.5.2 - Array Declarators.
ArraySizeModifier getSizeModifier() const
Qualifiers getIndexTypeQualifiers() const
QualType getElementType() const
ArrayType(TypeClass tc, QualType et, QualType can, ArraySizeModifier sm, unsigned tq, const Expr *sz=nullptr)
Attr - This represents one attribute.
An attributed type is a type to which a type attribute has been applied.
bool isCallingConv() const
std::optional< NullabilityKind > getImmediateNullability() const
static std::optional< NullabilityKind > stripOuterNullability(QualType &T)
Strip off the top-level nullability annotation on the given type, if it's there.
bool isMSTypeSpec() const
bool isWebAssemblyFuncrefSpec() const
bool isQualifier() const
Does this attribute behave like a type qualifier?
Represents a C++11 auto or C++14 decltype(auto) type, possibly constrained by a type-constraint.
ArrayRef< TemplateArgument > getTypeConstraintArguments() const
void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context)
AutoTypeKeyword getKeyword() const
TemplateDecl * getTypeConstraintConcept() const
BitIntType(bool isUnsigned, unsigned NumBits)
[BoundsSafety] Represents a parent type class for CountAttributedType and similar sugar types that wi...
BoundsAttributedType(TypeClass TC, QualType Wrapped, QualType Canon)
decl_range dependent_decls() const
bool referencesFieldDecls() const
ArrayRef< TypeCoupledDeclRefInfo > Decls
This class is used for builtin types like 'int'.
StringRef getName(const PrintingPolicy &Policy) const
Represents a C++ struct/union/class.
bool isHLSLIntangible() const
Returns true if the class contains HLSL intangible type, either as a field or in base class.
bool mayBeNonDynamicClass() const
bool mayBeDynamicClass() const
CXXRecordDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
QuantityType getQuantity() const
getQuantity - Get the raw integer representation of this quantity.
Declaration of a class template.
Complex values, per C99 6.2.5p11.
Represents the canonical version of C arrays with a specified constant size.
static unsigned getNumAddressingBits(const ASTContext &Context, QualType ElementType, const llvm::APInt &NumElements)
Determine the number of bits required to address a member of.
static unsigned getMaxSizeBits(const ASTContext &Context)
Determine the maximum number of active bits that an array's size can require, which limits the maximu...
const Expr * getSizeExpr() const
Return a pointer to the size expression.
llvm::APInt getSize() const
Return the constant array size as an APInt.
void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Ctx)
ConstantExpr - An expression that occurs in a constant context and optionally the result of evaluatin...
llvm::APSInt getResultAsAPSInt() const
Represents a concrete matrix type with constant number of rows and columns.
ConstantMatrixType(QualType MatrixElementType, unsigned NRows, unsigned NColumns, QualType CanonElementType)
Represents a sugar type with __counted_by or __sized_by annotations, including their _or_null variant...
void Profile(llvm::FoldingSetNodeID &ID)
StringRef getAttributeName(bool WithMacroPrefix) const
Represents a pointer type decayed from an array or function type.
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
ASTContext & getParentASTContext() const
Decl - This represents one declaration (or definition), e.g.
bool isInStdNamespace() const
ASTContext & getASTContext() const LLVM_READONLY
virtual Decl * getCanonicalDecl()
Retrieves the "canonical" declaration of the given declaration.
Represents the type decltype(expr) (C++11).
QualType desugar() const
Remove a single level of sugar.
bool isSugared() const
Returns whether this type directly provides sugar.
DecltypeType(Expr *E, QualType underlyingType, QualType can=QualType())
QualType getUnderlyingType() const
Common base class for placeholders for types that get replaced by placeholder type deduction: C++11 a...
QualType getDeducedType() const
Get the type deduced for this placeholder type, or null if it has not been deduced.
void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context)
Expr * getNumBitsExpr() const
void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context)
DependentBitIntType(bool IsUnsigned, Expr *NumBits)
void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context)
DependentDecltypeType(Expr *E)
Represents a qualified type name for which the type name is dependent.
void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context)
Represents an extended vector type where either the type or size is dependent.
void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context)
Represents a matrix type where the type and the number of rows and columns is dependent on a template...
void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context)
void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context)
Represents a dependent template name that cannot be resolved prior to template instantiation.
void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context)
void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context)
Wrap a function effect's condition expression in another struct so that FunctionProtoType's TrailingO...
Expr * getCondition() const
bool isComplete() const
Returns true if this can be considered a complete type.
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of enums.
This represents one expression.
bool isValueDependent() const
Determines whether the value of this expression depends on.
bool isTypeDependent() const
Determines whether the type of this expression depends on.
bool isInstantiationDependent() const
Whether this expression is instantiation-dependent, meaning that it depends in some way on.
ExprDependence getDependence() const
ExtVectorType - Extended vector type.
Represents a member of a struct/union/class.
A mutable set of FunctionEffect::Kind.
void dump(llvm::raw_ostream &OS) const
A mutable set of FunctionEffects and possibly conditions attached to them.
FunctionEffectSet()=default
bool insert(const FunctionEffectWithCondition &NewEC, Conflicts &Errs)
static FunctionEffectSet getIntersection(FunctionEffectsRef LHS, FunctionEffectsRef RHS)
void dump(llvm::raw_ostream &OS) const
static FunctionEffectSet getUnion(FunctionEffectsRef LHS, FunctionEffectsRef RHS, Conflicts &Errs)
Represents an abstract function effect, using just an enumeration describing its kind.
Kind kind() const
The kind of the effect.
Kind
Identifies the particular effect.
bool shouldDiagnoseFunctionCall(bool Direct, FunctionEffectKindSet CalleeFX) const
StringRef name() const
The description printed in diagnostics, e.g. 'nonblocking'.
Kind oppositeKind() const
Return the opposite kind, for effects which have opposites.
std::optional< FunctionEffect > effectProhibitingInference(const Decl &Callee, FunctionEffectKindSet CalleeFX) const
Determine whether the effect is allowed to be inferred on the callee, which is either a FunctionDecl ...
An immutable set of FunctionEffects and possibly conditions attached to them.
void dump(llvm::raw_ostream &OS) const
ArrayRef< FunctionEffect > effects() const
ArrayRef< EffectConditionExpr > conditions() const
static FunctionEffectsRef create(ArrayRef< FunctionEffect > FX, ArrayRef< EffectConditionExpr > Conds)
Asserts invariants.
FunctionEffectsRef()=default
Represents a K&R-style 'int foo()' function, which has no information available about its arguments.
Represents a prototype with parameter type info, e.g.
bool hasDependentExceptionSpec() const
Return whether this function has a dependent exception spec.
param_type_iterator param_type_begin() const
ExceptionSpecificationType getExceptionSpecType() const
Get the kind of exception specification on this function.
bool isTemplateVariadic() const
Determines whether this function prototype contains a parameter pack at the end.
unsigned getNumParams() const
bool hasTrailingReturn() const
Whether this function prototype has a trailing return type.
QualType getParamType(unsigned i) const
QualType getExceptionType(unsigned i) const
Return the ith exception type, where 0 <= i < getNumExceptions().
void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Ctx)
unsigned getNumExceptions() const
Return the number of types in the exception specification.
CanThrowResult canThrow() const
Determine whether this function type has a non-throwing exception specification.
ExtProtoInfo getExtProtoInfo() const
Expr * getNoexceptExpr() const
Return the expression inside noexcept(expression), or a null pointer if there is none (because the ex...
ArrayRef< QualType > getParamTypes() const
ArrayRef< QualType > exceptions() const
bool hasInstantiationDependentExceptionSpec() const
Return whether this function has an instantiation-dependent exception spec.
A class which abstracts out some details necessary for making a call.
FunctionType - C99 6.7.5.3 - Function Declarators.
ExtInfo getExtInfo() const
static StringRef getNameForCallConv(CallingConv CC)
bool getCFIUncheckedCalleeAttr() const
Determine whether this is a function prototype that includes the cfi_unchecked_callee attribute.
QualType getReturnType() const
static const HLSLAttributedResourceType * findHandleTypeOnResource(const Type *RT)
One of these records is kept for each identifier that is lexed.
bool isStr(const char(&Str)[StrLen]) const
Return true if this is the identifier for the specified string.
Represents a C array with an unspecified size.
The injected class name of a C++ class template or class template partial specialization.
An lvalue reference type, per C++11 [dcl.ref].
LinkageInfo computeTypeLinkageInfo(const Type *T)
LinkageInfo getTypeLinkageAndVisibility(const Type *T)
LinkageInfo getDeclLinkageAndVisibility(const NamedDecl *D)
static LinkageInfo external()
Linkage getLinkage() const
void merge(LinkageInfo other)
Merge both linkage and visibility.
Sugar type that represents a type that was qualified by a qualifier written as a macro invocation.
QualType getModifiedType() const
Return this attributed type's modified type with no qualifiers attached to it.
QualType getUnderlyingType() const
const IdentifierInfo * getMacroIdentifier() const
Represents a matrix type, as defined in the Matrix Types clang extensions.
MatrixType(QualType ElementTy, QualType CanonElementTy)
QualType ElementType
The element type of the matrix.
A pointer to member type per C++ 8.3.3 - Pointers to members.
NestedNameSpecifier getQualifier() const
void Profile(llvm::FoldingSetNodeID &ID)
CXXRecordDecl * getMostRecentCXXRecordDecl() const
Note: this can trigger extra deserialization when external AST sources are used.
This represents a decl that may have a name.
IdentifierInfo * getIdentifier() const
Get the identifier that names this declaration, if there is one.
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
CXXRecordDecl * getAsRecordDecl() const
Retrieve the record declaration stored in this nested name specifier, or null.
ObjCCategoryDecl - Represents a category declaration.
ObjCInterfaceDecl * getClassInterface()
ObjCTypeParamList * getTypeParamList() const
Retrieve the type parameter list associated with this category or extension.
Represents an ObjC class declaration.
ObjCTypeParamList * getTypeParamList() const
Retrieve the type parameters of this class.
const ObjCObjectType * getSuperClassType() const
Retrieve the superclass type.
ObjCInterfaceDecl * getDefinition()
Retrieve the definition of this class, or NULL if this class has been forward-declared (with @class) ...
Interfaces are the core concept in Objective-C for object oriented design.
ObjCInterfaceDecl * getDecl() const
Get the declaration of this interface.
Represents a pointer to an Objective C object.
const ObjCObjectPointerType * stripObjCKindOfTypeAndQuals(const ASTContext &ctx) const
Strip off the Objective-C "kindof" type and (with it) any protocol qualifiers.
const ObjCObjectType * getObjectType() const
Gets the type pointed to by this ObjC pointer.
QualType getSuperClassType() const
Retrieve the type of the superclass of this object pointer type.
ObjCInterfaceDecl * getInterfaceDecl() const
If this pointer points to an Objective @interface type, gets the declaration for that interface.
const ObjCInterfaceType * getInterfaceType() const
If this pointer points to an Objective C @interface type, gets the type for that interface.
bool isKindOfType() const
Whether this is a "__kindof" type.
void Profile(llvm::FoldingSetNodeID &ID)
Represents a class type in Objective C.
bool isKindOfTypeAsWritten() const
Whether this is a "__kindof" type as written.
bool isSpecialized() const
Determine whether this object type is "specialized", meaning that it has type arguments.
ObjCObjectType(QualType Canonical, QualType Base, ArrayRef< QualType > typeArgs, ArrayRef< ObjCProtocolDecl * > protocols, bool isKindOf)
ArrayRef< QualType > getTypeArgsAsWritten() const
Retrieve the type arguments of this object type as they were written.
QualType getBaseType() const
Gets the base type of this object type.
bool isKindOfType() const
Whether this ia a "__kindof" type (semantically).
bool isSpecializedAsWritten() const
Determine whether this object type was written with type arguments.
ArrayRef< QualType > getTypeArgs() const
Retrieve the type arguments of this object type (semantically).
bool isUnspecialized() const
Determine whether this object type is "unspecialized", meaning that it has no type arguments.
QualType stripObjCKindOfTypeAndQuals(const ASTContext &ctx) const
Strip off the Objective-C "kindof" type and (with it) any protocol qualifiers.
void computeSuperClassTypeSlow() const
ObjCInterfaceDecl * getInterface() const
Gets the interface declaration for this object type, if the base type really is an interface.
QualType getSuperClassType() const
Retrieve the type of the superclass of this object type.
Represents an Objective-C protocol declaration.
void initialize(ArrayRef< ObjCProtocolDecl * > protocols)
ArrayRef< ObjCProtocolDecl * > getProtocols() const
Retrieve all of the protocol qualifiers.
unsigned getNumProtocols() const
Return the number of qualifying protocols in this type, or 0 if there are none.
qual_iterator qual_end() const
qual_iterator qual_begin() const
Represents the declaration of an Objective-C type parameter.
unsigned getIndex() const
Retrieve the index into its type parameter list.
Stores a list of Objective-C type parameters for a parameterized class or a category/extension thereo...
unsigned size() const
Determine the number of type parameters in this list.
Represents a type parameter type in Objective C.
void Profile(llvm::FoldingSetNodeID &ID)
ObjCTypeParamDecl * getDecl() const
Represents a pack expansion of types.
QualType getPattern() const
UnsignedOrNone getSelectedIndex() const
bool isFullySubstituted() const
ArrayRef< QualType > getExpansions() const
PackIndexingType(QualType Canonical, QualType Pattern, Expr *IndexExpr, bool FullySubstituted, ArrayRef< QualType > Expansions={})
Expr * getIndexExpr() const
void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context)
Sugar for parentheses used when specifying types.
PointerType - C99 6.7.5.1 - Pointer Declarators.
A (possibly-)qualified type.
bool hasAddressDiscriminatedPointerAuth() const
bool isTriviallyCopyableType(const ASTContext &Context) const
Return true if this is a trivially copyable type (C++0x [basic.types]p9)
QualType IgnoreParens() const
Returns the specified type after dropping any outer-level parentheses.
QualType withFastQualifiers(unsigned TQs) const
bool hasNonTrivialToPrimitiveCopyCUnion() const
Check if this is or contains a C union that is non-trivial to copy, which is a union that has a membe...
bool isWebAssemblyFuncrefType() const
Returns true if it is a WebAssembly Funcref Type.
QualType getNonLValueExprType(const ASTContext &Context) const
Determine the type of a (typically non-lvalue) expression with the specified result type.
@ DK_objc_strong_lifetime
PrimitiveDefaultInitializeKind
@ PDIK_ARCWeak
The type is an Objective-C retainable pointer type that is qualified with the ARC __weak qualifier.
@ PDIK_Trivial
The type does not fall into any of the following categories.
@ PDIK_ARCStrong
The type is an Objective-C retainable pointer type that is qualified with the ARC __strong qualifier.
@ PDIK_Struct
The type is a struct containing a field whose type is not PCK_Trivial.
bool mayBeDynamicClass() const
Returns true if it is a class and it might be dynamic.
bool isNonWeakInMRRWithObjCWeak(const ASTContext &Context) const
const IdentifierInfo * getBaseTypeIdentifier() const
Retrieves a pointer to the name of the base type.
bool isBitwiseCloneableType(const ASTContext &Context) const
Return true if the type is safe to bitwise copy using memcpy/memmove.
void Profile(llvm::FoldingSetNodeID &ID) const
QualType getDesugaredType(const ASTContext &Context) const
Return the specified type with any "sugar" removed from the type.
bool isTriviallyCopyConstructibleType(const ASTContext &Context) const
Return true if this is a trivially copyable type.
bool isTrivialType(const ASTContext &Context) const
Return true if this is a trivial type per (C++0x [basic.types]p9)
bool isNull() const
Return true if this QualType doesn't point to a type yet.
PrimitiveCopyKind isNonTrivialToPrimitiveCopy() const
Check if this is a non-trivial type that would cause a C struct transitively containing this type to ...
const Type * getTypePtr() const
Retrieves a pointer to the underlying (unqualified) type.
LangAS getAddressSpace() const
Return the address space of this type.
bool isConstant(const ASTContext &Ctx) const
bool hasNonTrivialToPrimitiveDestructCUnion() const
Check if this is or contains a C union that is non-trivial to destruct, which is a union that has a m...
Qualifiers getQualifiers() const
Retrieve the set of qualifiers applied to this type.
bool isCXX98PODType(const ASTContext &Context) const
Return true if this is a POD type according to the rules of the C++98 standard, regardless of the cur...
Qualifiers::ObjCLifetime getObjCLifetime() const
Returns lifetime attribute of this type.
QualType stripObjCKindOfType(const ASTContext &ctx) const
Strip Objective-C "__kindof" types from the given type.
QualType getCanonicalType() const
QualType getUnqualifiedType() const
Retrieve the unqualified variant of the given type, removing as little sugar as possible.
QualType substObjCMemberType(QualType objectType, const DeclContext *dc, ObjCSubstitutionContext context) const
Substitute type arguments from an object type for the Objective-C type parameters used in the subject...
bool isWebAssemblyReferenceType() const
Returns true if it is a WebAssembly Reference Type.
SplitQualType getSplitDesugaredType() const
std::optional< NonConstantStorageReason > isNonConstantStorage(const ASTContext &Ctx, bool ExcludeCtor, bool ExcludeDtor)
Determine whether instances of this type can be placed in immutable storage.
SplitQualType split() const
Divides a QualType into its unqualified type and a set of local qualifiers.
bool UseExcessPrecision(const ASTContext &Ctx)
PrimitiveDefaultInitializeKind isNonTrivialToPrimitiveDefaultInitialize() const
Functions to query basic properties of non-trivial C struct types.
void * getAsOpaquePtr() const
bool isWebAssemblyExternrefType() const
Returns true if it is a WebAssembly Externref Type.
QualType getNonPackExpansionType() const
Remove an outer pack expansion type (if any) from this type.
bool isCXX11PODType(const ASTContext &Context) const
Return true if this is a POD type according to the more relaxed rules of the C++11 standard,...
bool mayBeNotDynamicClass() const
Returns true if it is not a class or if the class might not be dynamic.
bool isConstQualified() const
Determine whether this type is const-qualified.
QualType substObjCTypeArgs(ASTContext &ctx, ArrayRef< QualType > typeArgs, ObjCSubstitutionContext context) const
Substitute type arguments for the Objective-C type parameters used in the subject type.
QualType getAtomicUnqualifiedType() const
Remove all qualifiers including _Atomic.
bool hasNonTrivialObjCLifetime() const
bool isPODType(const ASTContext &Context) const
Determine whether this is a Plain Old Data (POD) type (C++ 3.9p10).
PrimitiveCopyKind isNonTrivialToPrimitiveDestructiveMove() const
Check if this is a non-trivial type that would cause a C struct transitively containing this type to ...
@ NonConstNonReferenceType
@ PCK_Struct
The type is a struct containing a field whose type is neither PCK_Trivial nor PCK_VolatileTrivial.
@ PCK_Trivial
The type does not fall into any of the following categories.
@ PCK_ARCStrong
The type is an Objective-C retainable pointer type that is qualified with the ARC __strong qualifier.
@ PCK_VolatileTrivial
The type would be trivial except that it is volatile-qualified.
@ PCK_PtrAuth
The type is an address-discriminated signed pointer type.
@ PCK_ARCWeak
The type is an Objective-C retainable pointer type that is qualified with the ARC __weak qualifier.
bool hasNonTrivialToPrimitiveDefaultInitializeCUnion() const
Check if this is or contains a C union that is non-trivial to default-initialize, which is a union th...
A qualifier set is used to build a set of qualifiers.
const Type * strip(QualType type)
Collect any qualifiers on the given type and return an unqualified type.
QualType apply(const ASTContext &Context, QualType QT) const
Apply the collected qualifiers to the given type.
The collection of all-type qualifiers we support.
@ OCL_Strong
Assigning into this object requires the old value to be released and the new value to be retained.
@ OCL_ExplicitNone
This object can be modified without requiring retains or releases.
@ OCL_None
There is no lifetime qualification on this type.
@ OCL_Weak
Reading or writing from this object requires a barrier call.
@ OCL_Autoreleasing
Assigning into this object requires a lifetime extension.
bool isStrictSupersetOf(Qualifiers Other) const
Determine whether this set of qualifiers is a strict superset of another set of qualifiers,...
bool hasNonFastQualifiers() const
Return true if the set contains any qualifiers which require an ExtQuals node to be allocated.
void addConsistentQualifiers(Qualifiers qs)
Add the qualifiers from the given set to this set, given that they don't conflict.
static bool isTargetAddressSpaceSupersetOf(LangAS A, LangAS B, const ASTContext &Ctx)
bool hasAddressSpace() const
unsigned getFastQualifiers() const
bool hasObjCGCAttr() const
bool hasObjCLifetime() const
ObjCLifetime getObjCLifetime() const
LangAS getAddressSpace() const
An rvalue reference type, per C++11 [dcl.ref].
Represents a struct/union/class.
bool hasNonTrivialToPrimitiveDestructCUnion() const
bool hasNonTrivialToPrimitiveCopyCUnion() const
bool hasNonTrivialToPrimitiveDefaultInitializeCUnion() const
bool isNonTrivialToPrimitiveDestroy() const
bool isNonTrivialToPrimitiveCopy() const
field_range fields() const
RecordDecl * getMostRecentDecl()
bool isNonTrivialToPrimitiveDefaultInitialize() const
Functions to query basic properties of non-trivial C structs.
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
RecordDecl * getOriginalDecl() const
bool hasConstFields() const
Recursively check all fields in the record for const-ness.
Declaration of a redeclarable template.
redecl_range redecls() const
Returns an iterator range for all the redeclarations of the same decl.
Base for LValueReferenceType and RValueReferenceType.
Encodes a location in the source.
Stmt - This represents one statement.
void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context, bool Canonical, bool ProfileLambdaExpr=false) const
Produce a unique representation of the given statement.
void dump() const
Dumps the specified AST fragment and all subtrees to llvm::errs().
Represents the result of substituting a set of types as a template argument that needs to be expanded...
TemplateArgument getArgumentPack() const
unsigned getNumArgs() const
void Profile(llvm::FoldingSetNodeID &ID)
SubstPackType(TypeClass Derived, QualType Canon, const TemplateArgument &ArgPack)
Decl * getAssociatedDecl() const
A template-like entity which owns the whole pattern being substituted.
IdentifierInfo * getIdentifier() const
void Profile(llvm::FoldingSetNodeID &ID)
unsigned getIndex() const
Returns the index of the replaced parameter in the associated declaration.
const TemplateTypeParmDecl * getReplacedParameter() const
Gets the template parameter declaration that was substituted for.
Represents the result of substituting a type for a template type parameter.
void Profile(llvm::FoldingSetNodeID &ID)
Decl * getAssociatedDecl() const
A template-like entity which owns the whole pattern being substituted.
unsigned getIndex() const
Returns the index of the replaced parameter in the associated declaration.
const TemplateTypeParmDecl * getReplacedParameter() const
Gets the template parameter declaration that was substituted for.
Represents the declaration of a struct/union/class/enum.
bool isCompleteDefinition() const
Return true if this decl has its body fully specified.
NestedNameSpecifier getQualifier() const
Retrieve the nested-name-specifier that qualifies the name of this declaration, if it was present in ...
bool isDependentType() const
Whether this declaration declares a type that is dependent, i.e., a type that somehow depends on temp...
ArrayRef< TemplateArgument > getTemplateArgs(const ASTContext &Ctx) const
NestedNameSpecifier getQualifier() const
ClassTemplateDecl * getTemplateDecl() const
TemplateName getTemplateName(const ASTContext &Ctx) const
TagType(TypeClass TC, ElaboratedTypeKeyword Keyword, NestedNameSpecifier Qualifier, const TagDecl *TD, bool OwnsTag, bool IsInjected, const Type *CanonicalType)
bool isMicrosoft() const
Is this ABI an MSVC-compatible ABI?
Exposes information about the current target.
virtual bool hasFullBFloat16Type() const
Determine whether the BFloat type is fully supported on this target, i.e arithemtic operations.
virtual bool hasFastHalfType() const
Determine whether the target has fast native support for operations on half types.
virtual bool hasFloat16Type() const
Determine whether the _Float16 type is supported on this target.
TargetCXXABI getCXXABI() const
Get the C++ ABI currently in use.
virtual bool hasBFloat16Type() const
Determine whether the _BFloat16 type is supported on this target.
virtual bool isAddressSpaceSupersetOf(LangAS A, LangAS B) const
Returns true if an address space can be safely converted to another.
A convenient class for passing around template argument information.
ArrayRef< TemplateArgumentLoc > arguments() const
Location wrapper for a TemplateArgument.
Represents a template argument.
unsigned pack_size() const
The number of template arguments in the given template argument pack.
ArrayRef< TemplateArgument > pack_elements() const
Iterator range referencing all of the elements of a template argument pack.
@ Type
The template argument is a type.
The base class of all kinds of template declarations (e.g., class, function, etc.).
Represents a C++ template name within the type system.
@ UsingTemplate
A template name that refers to a template declaration found through a specific using shadow declarati...
@ Template
A single template declaration.
@ SubstTemplateTemplateParm
A template template parameter that has been substituted for some other template name.
@ SubstTemplateTemplateParmPack
A template template parameter pack that has been substituted for a template template argument pack,...
@ DeducedTemplate
A template name that refers to another TemplateName with deduced default arguments.
@ QualifiedTemplate
A qualified template name, where the qualification is kept to describe the source code as written.
@ AssumedTemplate
An unqualified-id that has been assumed to name a function template that will be found by ADL.
Represents a type template specialization; the template must be a class template, a type alias templa...
QualType getAliasedType() const
Get the aliased type, if this is a specialization of a type alias template.
ArrayRef< TemplateArgument > template_arguments() const
bool isTypeAlias() const
Determine if this template specialization type is for a type alias template that has been substituted...
static bool anyInstantiationDependentTemplateArguments(ArrayRef< TemplateArgumentLoc > Args)
static bool anyDependentTemplateArguments(ArrayRef< TemplateArgumentLoc > Args, ArrayRef< TemplateArgument > Converted)
Determine whether any of the given template arguments are dependent.
void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Ctx)
Declaration of a template type parameter.
TemplateTypeParmDecl * getDecl() const
IdentifierInfo * getIdentifier() const
[BoundsSafety] Represents information of declarations referenced by the arguments of the counted_by a...
ValueDecl * getDecl() const
bool operator==(const TypeCoupledDeclRefInfo &Other) const
void * getOpaqueValue() const
TypeCoupledDeclRefInfo(ValueDecl *D=nullptr, bool Deref=false)
D is to a declaration referenced by the argument of attribute.
void setFromOpaqueValue(void *V)
bool isSugared() const
Returns whether this type directly provides sugar.
TypeOfKind getKind() const
Returns the kind of 'typeof' type this is.
TypeOfExprType(const ASTContext &Context, Expr *E, TypeOfKind Kind, QualType Can=QualType())
Expr * getUnderlyingExpr() const
QualType desugar() const
Remove a single level of sugar.
TypeOfKind getKind() const
Returns the kind of 'typeof' type this is.
QualType desugar() const
Remove a single level of sugar.
QualType getUnmodifiedType() const
static void ensure(const Type *T)
static CachedProperties get(QualType T)
static CachedProperties get(const Type *T)
A helper class for Type nodes having an ElaboratedTypeKeyword.
The base class of the type hierarchy.
bool isSizelessType() const
As an extension, we classify types as one of "sized" or "sizeless"; every type is one or the other.
bool isStructureType() const
bool isBlockPointerType() const
const ObjCObjectPointerType * getAsObjCQualifiedClassType() const
bool isLinkageValid() const
True if the computed linkage is valid.
TypedefBitfields TypedefBits
bool isBooleanType() const
const ObjCObjectType * getAsObjCQualifiedInterfaceType() const
const ObjCObjectPointerType * getAsObjCQualifiedIdType() const
const TemplateSpecializationType * getAsNonAliasTemplateSpecializationType() const
Look through sugar for an instance of TemplateSpecializationType which is not a type alias,...
bool isMFloat8Type() const
bool isSignedIntegerOrEnumerationType() const
Determines whether this is an integer type that is signed or an enumeration types whose underlying ty...
bool isPackedVectorBoolType(const ASTContext &ctx) const
bool hasAttr(attr::Kind AK) const
Determine whether this type had the specified attribute applied to it (looking through top-level type...
bool isAlwaysIncompleteType() const
QualType getRVVEltType(const ASTContext &Ctx) const
Returns the representative type for the element of an RVV builtin type.
const RecordType * getAsUnionType() const
NOTE: getAs*ArrayType are methods on ASTContext.
bool isLiteralType(const ASTContext &Ctx) const
Return true if this is a literal type (C++11 [basic.types]p10)
bool isSignedIntegerType() const
Return true if this is an integer type that is signed, according to C99 6.2.5p4 [char,...
bool isComplexType() const
isComplexType() does not include complex integers (a GCC extension).
ArrayTypeBitfields ArrayTypeBits
const ArrayType * castAsArrayTypeUnsafe() const
A variant of castAs<> for array type which silently discards qualifiers from the outermost type.
bool isUnsignedIntegerOrEnumerationType() const
Determines whether this is an integer type that is unsigned or an enumeration types whose underlying ...
bool isIntegralOrUnscopedEnumerationType() const
Determine whether this type is an integral or unscoped enumeration type.
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
VectorTypeBitfields VectorTypeBits
SubstPackTypeBitfields SubstPackTypeBits
RecordDecl * getAsRecordDecl() const
Retrieves the RecordDecl this type refers to.
bool hasIntegerRepresentation() const
Determine whether this type has an integer representation of some sort, e.g., it is an integer type o...
bool isVoidPointerType() const
const ComplexType * getAsComplexIntegerType() const
bool isConstantSizeType() const
Return true if this is not a variable sized type, according to the rules of C99 6....
QualType getLocallyUnqualifiedSingleStepDesugaredType() const
Pull a single level of sugar off of this locally-unqualified type.
bool isFunctionPointerType() const
bool isCountAttributedType() const
bool isObjCARCBridgableType() const
Determine whether the given type T is a "bridgable" Objective-C type, which is either an Objective-C ...
CXXRecordDecl * castAsCXXRecordDecl() const
bool isArithmeticType() const
bool isHLSLBuiltinIntangibleType() const
TypeOfBitfields TypeOfBits
bool isIntegerType() const
isIntegerType() does not include complex integers (a GCC extension).
bool isSVESizelessBuiltinType() const
Returns true for SVE scalable vector types.
const T * castAs() const
Member-template castAs<specific type>.
bool isReferenceType() const
bool isHLSLIntangibleType() const
bool isEnumeralType() const
void addDependence(TypeDependence D)
bool isObjCNSObjectType() const
const ObjCObjectPointerType * getAsObjCInterfacePointerType() const
NestedNameSpecifier getPrefix() const
If this type represents a qualified-id, this returns its nested name specifier.
bool isScalarType() const
const CXXRecordDecl * getPointeeCXXRecordDecl() const
If this is a pointer or reference to a RecordType, return the CXXRecordDecl that the type refers to.
bool isInterfaceType() const
bool isVariableArrayType() const
bool isSizelessBuiltinType() const
bool isCUDADeviceBuiltinSurfaceType() const
Check if the type is the CUDA device builtin surface type.
bool isSveVLSBuiltinType() const
Determines if this is a sizeless type supported by the 'arm_sve_vector_bits' type attribute,...
bool isIntegralType(const ASTContext &Ctx) const
Determine whether this type is an integral type.
bool isElaboratedTypeSpecifier() const
Determine wither this type is a C++ elaborated-type-specifier.
CountAttributedTypeBitfields CountAttributedTypeBits
const Type * getArrayElementTypeNoTypeQual() const
If this is an array type, return the element type of the array, potentially with type qualifiers miss...
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee.
LinkageInfo getLinkageAndVisibility() const
Determine the linkage and visibility of this type.
bool hasUnsignedIntegerRepresentation() const
Determine whether this type has an unsigned integer representation of some sort, e....
bool isAnyCharacterType() const
Determine whether this type is any of the built-in character types.
bool isExtVectorBoolType() const
bool isWebAssemblyExternrefType() const
Check if this is a WebAssembly Externref Type.
bool canHaveNullability(bool ResultIfUnknown=true) const
Determine whether the given type can have a nullability specifier applied to it, i....
QualType getSveEltType(const ASTContext &Ctx) const
Returns the representative type for the element of an SVE builtin type.
bool isInstantiationDependentType() const
Determine whether this type is an instantiation-dependent type, meaning that the type involves a temp...
bool isLValueReferenceType() const
bool isBitIntType() const
bool isBuiltinType() const
Helper methods to distinguish type categories.
bool isStructuralType() const
Determine if this type is a structural type, per C++20 [temp.param]p7.
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
bool isAggregateType() const
Determines whether the type is a C++ aggregate type or C aggregate or union type.
bool isCARCBridgableType() const
Determine whether the given type T is a "bridgeable" C type.
bool isSignableIntegerType(const ASTContext &Ctx) const
RecordDecl * castAsRecordDecl() const
bool isChar16Type() const
bool isAnyComplexType() const
DeducedType * getContainedDeducedType() const
Get the DeducedType whose type will be deduced for a variable with an initializer of this type.
bool containsUnexpandedParameterPack() const
Whether this type is or contains an unexpanded parameter pack, used to support C++0x variadic templat...
ScalarTypeKind getScalarTypeKind() const
Given that this is a scalar type, classify it.
bool hasSignedIntegerRepresentation() const
Determine whether this type has an signed integer representation of some sort, e.g....
QualType getCanonicalTypeInternal() const
const RecordType * getAsStructureType() const
const char * getTypeClassName() const
bool isWebAssemblyTableType() const
Returns true if this is a WebAssembly table type: either an array of reference types,...
@ PtrdiffT
The "ptrdiff_t" type.
@ SizeT
The "size_t" type.
@ SignedSizeT
The signed integer type corresponding to "size_t".
const Type * getBaseElementTypeUnsafe() const
Get the base element type of this type, potentially discarding type qualifiers.
AttributedTypeBitfields AttributedTypeBits
bool isObjCBoxableRecordType() const
bool isChar32Type() const
bool isStandardLayoutType() const
Test if this type is a standard-layout type.
TagTypeBitfields TagTypeBits
EnumDecl * castAsEnumDecl() const
bool isVariablyModifiedType() const
Whether this type is a variably-modified type (C99 6.7.5).
bool isComplexIntegerType() const
bool isUnscopedEnumerationType() const
bool isStdByteType() const
UnresolvedUsingBitfields UnresolvedUsingBits
bool isCUDADeviceBuiltinTextureType() const
Check if the type is the CUDA device builtin texture type.
bool isBlockCompatibleObjCPointerType(ASTContext &ctx) const
bool isObjCClassOrClassKindOfType() const
Whether the type is Objective-C 'Class' or a __kindof type of an Class type, e.g.,...
const ArrayType * getAsArrayTypeUnsafe() const
A variant of getAs<> for array types which silently discards qualifiers from the outermost type.
bool isObjCLifetimeType() const
Returns true if objects of this type have lifetime semantics under ARC.
bool isHLSLResourceRecord() const
EnumDecl * getAsEnumDecl() const
Retrieves the EnumDecl this type refers to.
bool isObjCIndirectLifetimeType() const
bool hasUnnamedOrLocalType() const
Whether this type is or contains a local or unnamed type.
bool isPointerOrReferenceType() const
Qualifiers::ObjCLifetime getObjCARCImplicitLifetime() const
Return the implicit lifetime for this type, which must not be dependent.
FunctionTypeBitfields FunctionTypeBits
bool isObjCQualifiedInterfaceType() const
bool isSpecifierType() const
Returns true if this type can be represented by some set of type specifiers.
bool isIncompleteType(NamedDecl **Def=nullptr) const
Types are partitioned into 3 broad categories (C99 6.2.5p1): object types, function types,...
bool isObjCObjectPointerType() const
bool isStructureTypeWithFlexibleArrayMember() const
TypeDependence getDependence() const
bool hasFloatingRepresentation() const
Determine whether this type has a floating-point representation of some sort, e.g....
bool isStructureOrClassType() const
bool isVectorType() const
bool isRVVVLSBuiltinType() const
Determines if this is a sizeless type supported by the 'riscv_rvv_vector_bits' type attribute,...
bool isRealFloatingType() const
Floating point categories.
bool isRVVSizelessBuiltinType() const
Returns true for RVV scalable vector types.
std::optional< ArrayRef< QualType > > getObjCSubstitutions(const DeclContext *dc) const
Retrieve the set of substitutions required when accessing a member of the Objective-C receiver type t...
const T * getAsCanonical() const
If this type is canonically the specified type, return its canonical type cast to that specified type...
Linkage getLinkage() const
Determine the linkage of this type.
ObjCObjectTypeBitfields ObjCObjectTypeBits
bool isFloatingType() const
const ObjCObjectType * getAsObjCInterfaceType() const
bool isWideCharType() const
bool isUnsignedIntegerType() const
Return true if this is an integer type that is unsigned, according to C99 6.2.5p6 [which returns true...
bool hasSizedVLAType() const
Whether this type involves a variable-length array type with a definite size.
TypeClass getTypeClass() const
bool isCanonicalUnqualified() const
Determines if this type would be canonical if it had no further qualification.
bool hasAutoForTrailingReturnType() const
Determine whether this type was written with a leading 'auto' corresponding to a trailing return type...
bool isObjCIdOrObjectKindOfType(const ASTContext &ctx, const ObjCObjectType *&bound) const
Whether the type is Objective-C 'id' or a __kindof type of an object type, e.g., __kindof NSView * or...
const T * getAs() const
Member-template getAs<specific type>'.
const Type * getUnqualifiedDesugaredType() const
Return the specified type with any "sugar" removed from the type, removing any typedefs,...
bool isObjCARCImplicitlyUnretainedType() const
Determines if this type, which must satisfy isObjCLifetimeType(), is implicitly __unsafe_unretained r...
bool isRecordType() const
bool isHLSLResourceRecordArray() const
bool isObjCRetainableType() const
std::optional< NullabilityKind > getNullability() const
Determine the nullability of the given type.
bool isObjCIndependentClassType() const
bool isSizelessVectorType() const
Returns true for all scalable vector types.
bool isScopedEnumeralType() const
Determine whether this type is a scoped enumeration type.
bool acceptsObjCTypeParams() const
Determines if this is an ObjC interface type that may accept type parameters.
QualType getSizelessVectorEltType(const ASTContext &Ctx) const
Returns the representative type for the element of a sizeless vector builtin type.
bool isUnicodeCharacterType() const
bool hasBooleanRepresentation() const
Determine whether this type has a boolean representation – i.e., it is a boolean type,...
Base class for declarations which introduce a typedef-name.
QualType getUnderlyingType() const
bool typeMatchesDecl() const
Represents a dependent using declaration which was marked with typename.
Represents a shadow declaration implicitly introduced into a scope by a (resolved) using-declaration ...
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
Represents a C array with a specified size that is not an integer-constant-expression.
Represents a GCC generic vector type.
VectorType(QualType vecType, unsigned nElements, QualType canonType, VectorKind vecKind)
QualType getElementType() const
Defines the Linkage enumeration and various utility functions.
Defines the clang::TargetInfo interface.
const internal::VariadicAllOfMatcher< Attr > attr
Matches attributes.
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
const AstTypeMatcher< TypedefType > typedefType
Matches typedef types.
const internal::VariadicAllOfMatcher< Decl > decl
Matches declarations.
The JSON file list parser is used to communicate input to InstallAPI.
@ Overload
This is a legitimate overload: the existing declarations are functions or function templates with dif...
AutoTypeKeyword
Which keyword(s) were used to create an AutoType.
CanThrowResult
Possible results from evaluation of a noexcept expression.
void initialize(TemplateInstantiationCallbackPtrs &Callbacks, const Sema &TheSema)
Linkage minLinkage(Linkage L1, Linkage L2)
Compute the minimum linkage given two linkages.
@ Nullable
Values of this type can be null.
@ Unspecified
Whether values of this type can be null is (explicitly) unspecified.
@ NonNull
Values of this type can never be null.
bool IsEnumDeclComplete(EnumDecl *ED)
Check if the given decl is complete.
bool isPackProducingBuiltinTemplateName(TemplateName N)
ExprDependence computeDependence(FullExpr *E)
@ Private
'private' clause, allowed on 'parallel', 'serial', 'loop', 'parallel loop', and 'serial loop' constru...
@ Vector
'vector' clause, allowed on 'loop', Combined, and 'routine' directives.
TypeOfKind
The kind of 'typeof' expression we're after.
TypeDependence toTypeDependence(ExprDependence D)
ExprDependence turnValueToTypeDependence(ExprDependence D)
@ Dependent
Parse the block as a dependent block, which may be used in some template instantiations but not other...
const StreamingDiagnostic & operator<<(const StreamingDiagnostic &DB, const ASTContext::SectionInfo &Section)
Insertion operator for diagnostics.
Linkage
Describes the different kinds of linkage (C++ [basic.link], C99 6.2.2) that an entity may have.
@ External
External linkage, which indicates that the entity can be referred to from other translation units.
ObjCSubstitutionContext
The kind of type we are substituting Objective-C type arguments into.
@ Superclass
The superclass of a type.
@ Result
The result type of a method or function.
ArraySizeModifier
Capture whether this is a normal array (e.g.
bool isComputedNoexcept(ExceptionSpecificationType ESpecType)
@ Template
We are parsing a template declaration.
TagTypeKind
The kind of a tag type.
@ Interface
The "__interface" keyword.
@ Struct
The "struct" keyword.
@ Class
The "class" keyword.
@ Union
The "union" keyword.
@ Enum
The "enum" keyword.
@ Keyword
The name has been typo-corrected to a keyword.
LangAS
Defines the address space values used by the address space qualifier of QualType.
void FixedPointValueToString(SmallVectorImpl< char > &Str, llvm::APSInt Val, unsigned Scale)
bool isPtrSizeAddressSpace(LangAS AS)
TemplateParameterList * getReplacedTemplateParameterList(const Decl *D)
Internal helper used by Subst* nodes to retrieve the parameter list for their AssociatedDecl.
const FunctionProtoType * T
CallingConv
CallingConv - Specifies the calling convention that a function uses.
@ None
The alignment was not explicit in code.
ElaboratedTypeKeyword
The elaboration keyword that precedes a qualified type name or introduces an elaborated-type-specifie...
@ Interface
The "__interface" keyword introduces the elaborated-type-specifier.
@ None
No keyword precedes the qualified type name.
@ Struct
The "struct" keyword introduces the elaborated-type-specifier.
@ Class
The "class" keyword introduces the elaborated-type-specifier.
@ Union
The "union" keyword introduces the elaborated-type-specifier.
@ Enum
The "enum" keyword introduces the elaborated-type-specifier.
@ Typename
The "typename" keyword precedes the qualified type name, e.g., typename T::type.
TypeDependence toSemanticDependence(TypeDependence D)
TypeDependence toSyntacticDependence(TypeDependence D)
@ Other
Other implicit parameter.
@ EST_DependentNoexcept
noexcept(expression), value-dependent
@ EST_Uninstantiated
not instantiated yet
@ EST_Unparsed
not parsed yet
@ EST_NoThrow
Microsoft __declspec(nothrow) extension.
@ EST_None
no exception specification
@ EST_MSAny
Microsoft throw(...) extension.
@ EST_BasicNoexcept
noexcept
@ EST_NoexceptFalse
noexcept(expression), evals to 'false'
@ EST_Unevaluated
not evaluated yet, for special member function
@ EST_NoexceptTrue
noexcept(expression), evals to 'true'
@ EST_Dynamic
throw(T1, T2)
__UINTPTR_TYPE__ uintptr_t
An unsigned integer type with the property that any valid pointer to void can be converted to this ty...
A FunctionEffect plus a potential boolean expression determining whether the effect is declared (e....
std::string description() const
Return a textual description of the effect, and its condition, if any.
FunctionDecl * SourceDecl
The function whose exception specification this is, for EST_Unevaluated and EST_Uninstantiated.
FunctionDecl * SourceTemplate
The function template whose exception specification this is instantiated from, for EST_Uninstantiated...
ExceptionSpecificationType Type
The kind of exception specification this is.
ArrayRef< QualType > Exceptions
Explicitly-specified list of exception types.
Expr * NoexceptExpr
Noexcept expression, if this is a computed noexcept specification.
Extra information about a function prototype.
ExceptionSpecInfo ExceptionSpec
FunctionTypeExtraAttributeInfo ExtraAttributeInfo
bool requiresFunctionProtoTypeArmAttributes() const
unsigned AArch64SMEAttributes
SourceLocation EllipsisLoc
FunctionEffectsRef FunctionEffects
unsigned CFIUncheckedCallee
const ExtParameterInfo * ExtParameterInfos
RefQualifierKind RefQualifier
bool requiresFunctionProtoTypeExtraAttributeInfo() const
unsigned HasTrailingReturn
bool requiresFunctionProtoTypeExtraBitfields() const
static StringRef getKeywordName(ElaboratedTypeKeyword Keyword)
static ElaboratedTypeKeyword getKeywordForTagTypeKind(TagTypeKind Tag)
Converts a TagTypeKind into an elaborated type keyword.
static TagTypeKind getTagTypeKindForKeyword(ElaboratedTypeKeyword Keyword)
Converts an elaborated type keyword into a TagTypeKind.
static TagTypeKind getTagTypeKindForTypeSpec(unsigned TypeSpec)
Converts a type specifier (DeclSpec::TST) into a tag type kind.
static bool KeywordIsTagTypeKind(ElaboratedTypeKeyword Keyword)
static ElaboratedTypeKeyword getKeywordForTypeSpec(unsigned TypeSpec)
Converts a type specifier (DeclSpec::TST) into an elaborated type keyword.
Describes how types, statements, expressions, and declarations should be printed.
unsigned Bool
Whether we can use 'bool' rather than '_Bool' (even if the language doesn't actually have 'bool',...
unsigned NullptrTypeInNamespace
Whether 'nullptr_t' is in namespace 'std' or not.
unsigned Half
When true, print the half-precision floating-point type as 'half' instead of '__fp16'.
unsigned MSWChar
When true, print the built-in wchar_t type as __wchar_t.
A std::pair-like structure for storing a qualified type split into its local qualifiers and its local...
const Type * Ty
The locally-unqualified type.
Qualifiers Quals
The local qualifiers.
constexpr unsigned toInternalRepresentation() const