42#include "llvm/ADT/APInt.h"
43#include "llvm/ADT/APSInt.h"
44#include "llvm/ADT/ArrayRef.h"
45#include "llvm/ADT/FoldingSet.h"
46#include "llvm/ADT/SmallVector.h"
47#include "llvm/Support/Casting.h"
48#include "llvm/Support/ErrorHandling.h"
49#include "llvm/Support/MathExtras.h"
50#include "llvm/TargetParser/RISCVTargetParser.h"
61 return (*
this != Other) &&
88 getElementType().getBaseTypeIdentifier();
110 return AT->getElementType().isConstant(Ctx);
129 et->getDependence() |
135 (tc == DependentSizedArray
145 const llvm::APInt &NumElements) {
154 if (llvm::isPowerOf2_64(ElementSize)) {
155 return NumElements.getActiveBits() + llvm::Log2_64(ElementSize);
160 if ((ElementSize >> 32) == 0 && NumElements.getBitWidth() <= 64 &&
161 (NumElements.getZExtValue() >> 32) == 0) {
162 uint64_t TotalSize = NumElements.getZExtValue() * ElementSize;
163 return llvm::bit_width(TotalSize);
167 llvm::APSInt SizeExtended(NumElements,
true);
169 SizeExtended = SizeExtended.extend(std::max(SizeTypeBits,
170 SizeExtended.getBitWidth()) * 2);
172 llvm::APSInt TotalSize(llvm::APInt(SizeExtended.getBitWidth(), ElementSize));
173 TotalSize *= SizeExtended;
175 return TotalSize.getActiveBits();
192 const llvm::APInt &ArraySize,
194 unsigned TypeQuals) {
196 ID.AddInteger(ArraySize.getZExtValue());
197 ID.AddInteger(SizeMod);
198 ID.AddInteger(TypeQuals);
199 ID.AddBoolean(SizeExpr !=
nullptr);
201 SizeExpr->
Profile(ID, Context,
true);
204DependentSizedArrayType::DependentSizedArrayType(
const ASTContext &Context,
206 Expr *e, ArraySizeModifier sm,
209 :
ArrayType(DependentSizedArray, et, can, sm, tq, e),
210 Context(Context), SizeExpr((
Stmt*) e), Brackets(brackets) {}
219 ID.AddInteger(SizeMod);
220 ID.AddInteger(TypeQuals);
224DependentVectorType::DependentVectorType(
const ASTContext &Context,
229 :
Type(DependentVector, CanonType,
231 ElementType->getDependence() |
234 Context(Context), ElementType(ElementType), SizeExpr(SizeExpr), Loc(Loc) {
243 ID.AddInteger(VecKind);
244 SizeExpr->
Profile(ID, Context,
true);
247DependentSizedExtVectorType::DependentSizedExtVectorType(
250 :
Type(DependentSizedExtVector, can,
252 ElementType->getDependence() |
255 Context(Context), SizeExpr(SizeExpr), ElementType(ElementType), loc(loc) {
263 SizeExpr->
Profile(ID, Context,
true);
266DependentAddressSpaceType::DependentAddressSpaceType(
const ASTContext &Context,
271 :
Type(DependentAddressSpace, can,
273 PointeeType->getDependence() |
276 Context(Context), AddrSpaceExpr(AddrSpaceExpr), PointeeType(PointeeType),
282 Expr *AddrSpaceExpr) {
284 AddrSpaceExpr->
Profile(ID, Context,
true);
288 const Expr *RowExpr,
const Expr *ColumnExpr)
289 :
Type(tc, canonType,
290 (RowExpr ? (matrixType->getDependence() |
TypeDependence::Dependent |
292 (matrixType->isVariablyModifiedType()
295 (matrixType->containsUnexpandedParameterPack() ||
297 RowExpr->containsUnexpandedParameterPack()) ||
299 ColumnExpr->containsUnexpandedParameterPack())
302 : matrixType->getDependence())),
303 ElementType(matrixType) {}
306 unsigned nColumns,
QualType canonType)
311 unsigned nRows,
unsigned nColumns,
313 :
MatrixType(tc, matrixType, canonType), NumRows(nRows),
314 NumColumns(nColumns) {}
316DependentSizedMatrixType::DependentSizedMatrixType(
319 :
MatrixType(DependentSizedMatrix, ElementType, CanonicalType, RowExpr,
321 Context(CTX), RowExpr(RowExpr), ColumnExpr(ColumnExpr), loc(loc) {}
328 RowExpr->
Profile(ID, CTX,
true);
329 ColumnExpr->
Profile(ID, CTX,
true);
334 :
VectorType(Vector, vecType, nElements, canonType, vecKind) {}
338 :
Type(tc, canonType, vecType->getDependence()), ElementType(vecType) {
348 bool IsUnsigned,
Expr *NumBitsExpr)
351 Context(Context), ExprAndUnsigned(NumBitsExpr, IsUnsigned) {}
354 return ExprAndUnsigned.getInt();
358 return ExprAndUnsigned.getPointer();
364 ID.AddBoolean(IsUnsigned);
365 NumBitsExpr->
Profile(ID, Context,
true);
373 if (
const auto *ATy = dyn_cast<ArrayType>(
this))
374 return ATy->getElementType().getTypePtr();
377 if (!isa<ArrayType>(CanonicalType))
383 ->getElementType().getTypePtr();
407#define TYPE(CLASS, BASE) \
408 static_assert(!std::is_polymorphic<CLASS##Type>::value, \
409 #CLASS "Type should not be polymorphic!");
410#include "clang/AST/TypeNodes.inc"
418#define TYPE(CLASS, BASE) \
419 static_assert(std::is_trivially_destructible<CLASS##Type>::value || \
420 std::is_same<CLASS##Type, ConstantArrayType>::value, \
421 #CLASS "Type should be trivially destructible!");
422#include "clang/AST/TypeNodes.inc"
426#define ABSTRACT_TYPE(Class, Parent)
427#define TYPE(Class, Parent) \
428 case Type::Class: { \
429 const auto *ty = cast<Class##Type>(this); \
430 if (!ty->isSugared()) return QualType(ty, 0); \
431 return ty->desugar(); \
433#include "clang/AST/TypeNodes.inc"
435 llvm_unreachable(
"bad type kind!");
445#define ABSTRACT_TYPE(Class, Parent)
446#define TYPE(Class, Parent) \
447 case Type::Class: { \
448 const auto *Ty = cast<Class##Type>(CurTy); \
449 if (!Ty->isSugared()) \
450 return SplitQualType(Ty, Qs); \
451 Cur = Ty->desugar(); \
454#include "clang/AST/TypeNodes.inc"
474#define ABSTRACT_TYPE(Class, Parent)
475#define TYPE(Class, Parent) \
476 case Type::Class: { \
477 const auto *ty = cast<Class##Type>(split.Ty); \
478 if (!ty->isSugared()) goto done; \
479 next = ty->desugar(); \
482#include "clang/AST/TypeNodes.inc"
501 T = PT->getInnerType();
510 if (
const auto *Sugar = dyn_cast<T>(Cur))
513#define ABSTRACT_TYPE(Class, Parent)
514#define TYPE(Class, Parent) \
515 case Type::Class: { \
516 const auto *Ty = cast<Class##Type>(Cur); \
517 if (!Ty->isSugared()) return 0; \
518 Cur = Ty->desugar().getTypePtr(); \
521#include "clang/AST/TypeNodes.inc"
527 return getAsSugar<TypedefType>(
this);
531 return getAsSugar<UsingType>(
this);
535 return getAsSugar<TemplateSpecializationType>(
this);
539 return getAsSugar<AttributedType>(
this);
546 const Type *Cur =
this;
550#define ABSTRACT_TYPE(Class, Parent)
551#define TYPE(Class, Parent) \
553 const auto *Ty = cast<Class##Type>(Cur); \
554 if (!Ty->isSugared()) return Cur; \
555 Cur = Ty->desugar().getTypePtr(); \
558#include "clang/AST/TypeNodes.inc"
564 if (
const auto *RT = getAs<RecordType>())
565 return RT->getDecl()->isClass();
570 if (
const auto *RT = getAs<RecordType>())
571 return RT->getDecl()->isStruct();
576 if (
const auto *RT = getAs<RecordType>())
577 return RT->getDecl()->hasAttr<ObjCBoxableAttr>();
582 if (
const auto *RT = getAs<RecordType>())
583 return RT->getDecl()->isInterface();
588 if (
const auto *RT = getAs<RecordType>()) {
596 if (
const auto *PT = getAs<PointerType>())
597 return PT->getPointeeType()->isVoidType();
602 if (
const auto *RT = getAs<RecordType>())
603 return RT->getDecl()->isUnion();
608 if (
const auto *CT = dyn_cast<ComplexType>(CanonicalType))
609 return CT->getElementType()->isFloatingType();
619 if (
const auto *ET = getAs<EnumType>())
620 return ET->getDecl()->isScoped();
625 if (
const auto *
Complex = getAs<ComplexType>())
626 if (
Complex->getElementType()->isIntegerType())
632 if (
const auto *PT = getAs<PointerType>())
634 if (
const auto *OPT = getAs<ObjCObjectPointerType>())
636 if (
const auto *BPT = getAs<BlockPointerType>())
638 if (
const auto *RT = getAs<ReferenceType>())
640 if (
const auto *MPT = getAs<MemberPointerType>())
642 if (
const auto *DT = getAs<DecayedType>())
649 if (
const auto *RT = dyn_cast<RecordType>(
this)) {
650 if (RT->getDecl()->isStruct())
655 if (
const auto *RT = dyn_cast<RecordType>(CanonicalType)) {
656 if (!RT->getDecl()->isStruct())
668 if (
const auto *RT = dyn_cast<RecordType>(
this)) {
669 if (RT->getDecl()->isUnion())
674 if (
const auto *RT = dyn_cast<RecordType>(CanonicalType)) {
675 if (!RT->getDecl()->isUnion())
690 const auto *OPT = getAs<ObjCObjectPointerType>();
695 if (OPT->isObjCIdType())
699 if (!OPT->isKindOfType())
703 if (OPT->isObjCClassType() || OPT->isObjCQualifiedClassType())
713 const auto *OPT = getAs<ObjCObjectPointerType>();
718 if (OPT->isObjCClassType())
722 if (!OPT->isKindOfType())
726 return OPT->isObjCClassType() || OPT->isObjCQualifiedClassType();
740 :
Type(ObjCObject, Canonical,
Base->getDependence()), BaseType(
Base) {
745 "bitfield overflow in type argument count");
746 if (!typeArgs.empty())
747 memcpy(getTypeArgStorage(), typeArgs.data(),
748 typeArgs.size() *
sizeof(
QualType));
750 for (
auto typeArg : typeArgs) {
751 addDependence(typeArg->getDependence() & ~TypeDependence::VariablyModified);
764 if (
const auto objcObject =
getBaseType()->getAs<ObjCObjectType>()) {
766 if (isa<ObjCInterfaceType>(objcObject))
769 return objcObject->isSpecialized();
782 if (
const auto objcObject =
getBaseType()->getAs<ObjCObjectType>()) {
784 if (isa<ObjCInterfaceType>(objcObject))
787 return objcObject->getTypeArgs();
799 if (
const auto objcObject =
getBaseType()->getAs<ObjCObjectType>()) {
801 if (isa<ObjCInterfaceType>(objcObject))
804 return objcObject->isKindOfType();
820 baseType = baseObj->stripObjCKindOfTypeAndQuals(ctx);
823 splitBaseType.
Quals),
849template <
typename Derived>
850struct SimpleTransformVisitor :
public TypeVisitor<Derived, QualType> {
858 QualType result =
static_cast<Derived *
>(
this)->Visit(splitType.
Ty);
868 explicit SimpleTransformVisitor(
ASTContext &ctx) : Ctx(ctx) {}
872#define TYPE(Class, Base)
873#define DEPENDENT_TYPE(Class, Base) \
874 QualType Visit##Class##Type(const Class##Type *T) { return QualType(T, 0); }
875#include "clang/AST/TypeNodes.inc"
877#define TRIVIAL_TYPE_CLASS(Class) \
878 QualType Visit##Class##Type(const Class##Type *T) { return QualType(T, 0); }
879#define SUGARED_TYPE_CLASS(Class) \
880 QualType Visit##Class##Type(const Class##Type *T) { \
881 if (!T->isSugared()) \
882 return QualType(T, 0); \
883 QualType desugaredType = recurse(T->desugar()); \
884 if (desugaredType.isNull()) \
886 if (desugaredType.getAsOpaquePtr() == T->desugar().getAsOpaquePtr()) \
887 return QualType(T, 0); \
888 return desugaredType; \
1002 if (elementType.
isNull())
1014 if (elementType.
isNull())
1025 if (elementType.
isNull())
1052 bool paramChanged =
false;
1054 QualType newParamType = recurse(paramType);
1055 if (newParamType.
isNull())
1059 paramChanged =
true;
1061 paramTypes.push_back(newParamType);
1066 bool exceptionChanged =
false;
1070 QualType newExceptionType = recurse(exceptionType);
1071 if (newExceptionType.
isNull())
1074 if (newExceptionType.
getAsOpaquePtr() != exceptionType.getAsOpaquePtr())
1075 exceptionChanged =
true;
1077 exceptionTypes.push_back(newExceptionType);
1080 if (exceptionChanged) {
1087 !paramChanged && !exceptionChanged)
1110 if (originalType.
isNull())
1114 if (adjustedType.
isNull())
1127 if (originalType.
isNull())
1149 if (modifiedType.
isNull())
1153 if (equivalentType.
isNull())
1168 if (replacementType.
isNull())
1188 if (deducedType.
isNull())
1207 bool typeArgChanged =
false;
1210 QualType newTypeArg = recurse(typeArg);
1215 typeArgChanged =
true;
1217 typeArgs.push_back(newTypeArg);
1234 if (pointeeType.
isNull())
1256#undef TRIVIAL_TYPE_CLASS
1257#undef SUGARED_TYPE_CLASS
1260struct SubstObjCTypeArgsVisitor
1261 :
public SimpleTransformVisitor<SubstObjCTypeArgsVisitor> {
1262 using BaseType = SimpleTransformVisitor<SubstObjCTypeArgsVisitor>;
1269 : BaseType(ctx), TypeArgs(typeArgs), SubstContext(context) {}
1276 if (!TypeArgs.empty()) {
1287 argType, protocolsToApply, hasError,
true);
1290 switch (SubstContext) {
1291 case ObjCSubstitutionContext::Ordinary:
1292 case ObjCSubstitutionContext::Parameter:
1293 case ObjCSubstitutionContext::Superclass:
1297 case ObjCSubstitutionContext::Result:
1298 case ObjCSubstitutionContext::Property: {
1300 const auto *objPtr =
1305 if (objPtr->isKindOfType() || objPtr->isObjCIdOrClassType())
1309 const auto *obj = objPtr->getObjectType();
1311 obj->getBaseType(), obj->getTypeArgsAsWritten(), obj->getProtocols(),
1318 llvm_unreachable(
"Unexpected ObjCSubstitutionContext!");
1327 Ctx, TypeArgs, ObjCSubstitutionContext::Result);
1333 if (isa<FunctionNoProtoType>(funcType)) {
1337 return BaseType::VisitFunctionType(funcType);
1343 const auto *funcProtoType = cast<FunctionProtoType>(funcType);
1347 bool paramChanged =
false;
1348 for (
auto paramType : funcProtoType->getParamTypes()) {
1350 Ctx, TypeArgs, ObjCSubstitutionContext::Parameter);
1351 if (newParamType.
isNull())
1355 paramChanged =
true;
1357 paramTypes.push_back(newParamType);
1362 bool exceptionChanged =
false;
1367 Ctx, TypeArgs, ObjCSubstitutionContext::Ordinary);
1368 if (newExceptionType.
isNull())
1371 if (newExceptionType.
getAsOpaquePtr() != exceptionType.getAsOpaquePtr())
1372 exceptionChanged =
true;
1374 exceptionTypes.push_back(newExceptionType);
1377 if (exceptionChanged) {
1384 funcProtoType->getReturnType().getAsOpaquePtr() &&
1385 !paramChanged && !exceptionChanged)
1386 return BaseType::VisitFunctionType(funcType);
1396 bool anyChanged =
false;
1399 Ctx, TypeArgs, ObjCSubstitutionContext::Ordinary);
1408 if (TypeArgs.empty() &&
1409 SubstContext != ObjCSubstitutionContext::Superclass) {
1418 newTypeArgs.push_back(newTypeArg);
1430 return BaseType::VisitObjCObjectType(objcObjectType);
1434 QualType newType = BaseType::VisitAttributedType(attrType);
1438 const auto *newAttrType = dyn_cast<AttributedType>(newType.
getTypePtr());
1439 if (!newAttrType || newAttrType->getAttrKind() != attr::ObjCKindOf)
1443 QualType newEquivType = newAttrType->getEquivalentType();
1455 objType->getBaseType(), objType->getTypeArgsAsWritten(),
1456 objType->getProtocols(),
1458 objType->isObjCUnqualifiedId() ?
false :
true);
1466 newAttrType->getModifiedType(), newEquivType);
1470struct StripObjCKindOfTypeVisitor
1471 :
public SimpleTransformVisitor<StripObjCKindOfTypeVisitor> {
1472 using BaseType = SimpleTransformVisitor<StripObjCKindOfTypeVisitor>;
1474 explicit StripObjCKindOfTypeVisitor(
ASTContext &ctx) : BaseType(ctx) {}
1478 return BaseType::VisitObjCObjectType(objType);
1499 case BuiltinType::Kind::Float16: {
1507 case BuiltinType::Kind::BFloat16: {
1527 SubstObjCTypeArgsVisitor visitor(ctx, typeArgs, context);
1528 return visitor.recurse(*
this);
1542 auto &ctx =
const_cast<ASTContext &
>(constCtx);
1543 StripObjCKindOfTypeVisitor visitor(ctx);
1544 return visitor.recurse(*
this);
1548 if (
const auto AT =
getTypePtr()->getAs<AtomicType>())
1549 return AT->getValueType().getUnqualifiedType();
1553std::optional<ArrayRef<QualType>>
1556 if (
const auto method = dyn_cast<ObjCMethodDecl>(dc))
1557 dc = method->getDeclContext();
1561 const auto *dcClassDecl = dyn_cast<ObjCInterfaceDecl>(dc);
1567 dcTypeParams = dcClassDecl->getTypeParamList();
1569 return std::nullopt;
1573 dcCategoryDecl = dyn_cast<ObjCCategoryDecl>(dc);
1574 if (!dcCategoryDecl)
1575 return std::nullopt;
1581 return std::nullopt;
1585 return std::nullopt;
1587 assert(dcTypeParams &&
"No substitutions to perform");
1588 assert(dcClassDecl &&
"No class context");
1592 if (
const auto *objectPointerType = getAs<ObjCObjectPointerType>()) {
1593 objectType = objectPointerType->getObjectType();
1594 }
else if (getAs<BlockPointerType>()) {
1599 objectType = getAs<ObjCObjectType>();
1605 if (!curClassDecl) {
1613 while (curClassDecl != dcClassDecl) {
1616 if (superType.
isNull()) {
1617 objectType =
nullptr;
1637 if (
auto *ID = IfaceT->getInterface()) {
1638 if (ID->getTypeParamList())
1652 CachedSuperClassType.setInt(
true);
1658 if (!superClassObjTy) {
1659 CachedSuperClassType.setInt(
true);
1664 if (!superClassDecl) {
1665 CachedSuperClassType.setInt(
true);
1671 QualType superClassType(superClassObjTy, 0);
1673 if (!superClassTypeParams) {
1674 CachedSuperClassType.setPointerAndInt(
1681 CachedSuperClassType.setPointerAndInt(superClassObjTy,
true);
1689 CachedSuperClassType.setPointerAndInt(
1700 CachedSuperClassType.setPointerAndInt(
1708 assert(typeArgs.size() == typeParams->
size());
1709 CachedSuperClassType.setPointerAndInt(
1718 return interfaceDecl->getASTContext().getObjCInterfaceType(interfaceDecl)
1727 if (superObjectType.
isNull())
1728 return superObjectType;
1738 if (
const auto *T = getAs<ObjCObjectType>())
1739 if (T->getNumProtocols() && T->getInterface())
1751 if (
const auto *OPT = getAs<ObjCObjectPointerType>()) {
1752 if (OPT->isObjCQualifiedIdType())
1761 if (
const auto *OPT = getAs<ObjCObjectPointerType>()) {
1762 if (OPT->isObjCQualifiedClassType())
1769 if (
const auto *OT = getAs<ObjCObjectType>()) {
1770 if (OT->getInterface())
1777 if (
const auto *OPT = getAs<ObjCObjectPointerType>()) {
1778 if (OPT->getInterfaceType())
1786 if (
const auto *PT = getAs<PointerType>())
1788 else if (
const auto *RT = getAs<ReferenceType>())
1794 return dyn_cast<CXXRecordDecl>(RT->getDecl());
1800 return dyn_cast_or_null<CXXRecordDecl>(
getAsTagDecl());
1808 if (
const auto *TT = getAs<TagType>())
1809 return TT->getDecl();
1810 if (
const auto *Injected = getAs<InjectedClassNameType>())
1811 return Injected->getDecl();
1817 const Type *Cur =
this;
1819 if (AT->getAttrKind() == AK)
1821 Cur = AT->getEquivalentType().getTypePtr();
1828 class GetContainedDeducedTypeVisitor :
1829 public TypeVisitor<GetContainedDeducedTypeVisitor, Type*> {
1833 GetContainedDeducedTypeVisitor(
bool Syntactic =
false)
1834 : Syntactic(Syntactic) {}
1878 Type *VisitDependentSizedExtVectorType(
1898 return VisitFunctionType(T);
1929 return cast_or_null<DeducedType>(
1930 GetContainedDeducedTypeVisitor().Visit(
this));
1934 return isa_and_nonnull<FunctionType>(
1935 GetContainedDeducedTypeVisitor(
true).Visit(
this));
1939 if (
const auto *VT = dyn_cast<VectorType>(CanonicalType))
1940 return VT->getElementType()->isIntegerType();
1941 if (CanonicalType->isVLSTBuiltinType()) {
1942 const auto *VT = cast<BuiltinType>(CanonicalType);
1943 return VT->getKind() == BuiltinType::SveBool ||
1944 (VT->getKind() >= BuiltinType::SveInt8 &&
1945 VT->getKind() <= BuiltinType::SveUint64);
1947 if (CanonicalType->isRVVVLSBuiltinType()) {
1948 const auto *VT = cast<BuiltinType>(CanonicalType);
1949 return (VT->getKind() >= BuiltinType::RvvInt8mf8 &&
1950 VT->getKind() <= BuiltinType::RvvUint64m8);
1976 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
1977 return BT->getKind() >= BuiltinType::Bool &&
1978 BT->getKind() <= BuiltinType::Int128;
1982 if (
const auto *ET = dyn_cast<EnumType>(CanonicalType))
1983 return ET->getDecl()->isComplete();
1989 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
1990 return BT->getKind() >= BuiltinType::Bool &&
1991 BT->getKind() <= BuiltinType::Int128;
2000 if (
const auto *ET = dyn_cast<EnumType>(CanonicalType))
2001 return !ET->getDecl()->isScoped();
2007 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
2008 return BT->getKind() == BuiltinType::Char_U ||
2009 BT->getKind() == BuiltinType::UChar ||
2010 BT->getKind() == BuiltinType::Char_S ||
2011 BT->getKind() == BuiltinType::SChar;
2016 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
2017 return BT->getKind() == BuiltinType::WChar_S ||
2018 BT->getKind() == BuiltinType::WChar_U;
2023 if (
const BuiltinType *BT = dyn_cast<BuiltinType>(CanonicalType))
2024 return BT->getKind() == BuiltinType::Char8;
2029 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
2030 return BT->getKind() == BuiltinType::Char16;
2035 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
2036 return BT->getKind() == BuiltinType::Char32;
2043 const auto *BT = dyn_cast<BuiltinType>(CanonicalType);
2044 if (!BT)
return false;
2045 switch (BT->getKind()) {
2046 default:
return false;
2047 case BuiltinType::Char_U:
2048 case BuiltinType::UChar:
2049 case BuiltinType::WChar_U:
2050 case BuiltinType::Char8:
2051 case BuiltinType::Char16:
2052 case BuiltinType::Char32:
2053 case BuiltinType::Char_S:
2054 case BuiltinType::SChar:
2055 case BuiltinType::WChar_S:
2064 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType)) {
2065 return BT->getKind() >= BuiltinType::Char_S &&
2066 BT->getKind() <= BuiltinType::Int128;
2069 if (
const EnumType *ET = dyn_cast<EnumType>(CanonicalType)) {
2072 if (ET->getDecl()->isComplete() && !ET->getDecl()->isScoped())
2073 return ET->getDecl()->getIntegerType()->isSignedIntegerType();
2076 if (
const auto *IT = dyn_cast<BitIntType>(CanonicalType))
2077 return IT->isSigned();
2078 if (
const auto *IT = dyn_cast<DependentBitIntType>(CanonicalType))
2079 return IT->isSigned();
2085 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType)) {
2086 return BT->getKind() >= BuiltinType::Char_S &&
2087 BT->getKind() <= BuiltinType::Int128;
2090 if (
const auto *ET = dyn_cast<EnumType>(CanonicalType)) {
2091 if (ET->getDecl()->isComplete())
2092 return ET->getDecl()->getIntegerType()->isSignedIntegerType();
2095 if (
const auto *IT = dyn_cast<BitIntType>(CanonicalType))
2096 return IT->isSigned();
2097 if (
const auto *IT = dyn_cast<DependentBitIntType>(CanonicalType))
2098 return IT->isSigned();
2104 if (
const auto *VT = dyn_cast<VectorType>(CanonicalType))
2105 return VT->getElementType()->isSignedIntegerOrEnumerationType();
2114 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType)) {
2115 return BT->getKind() >= BuiltinType::Bool &&
2116 BT->getKind() <= BuiltinType::UInt128;
2119 if (
const auto *ET = dyn_cast<EnumType>(CanonicalType)) {
2122 if (ET->getDecl()->isComplete() && !ET->getDecl()->isScoped())
2123 return ET->getDecl()->getIntegerType()->isUnsignedIntegerType();
2126 if (
const auto *IT = dyn_cast<BitIntType>(CanonicalType))
2127 return IT->isUnsigned();
2128 if (
const auto *IT = dyn_cast<DependentBitIntType>(CanonicalType))
2129 return IT->isUnsigned();
2135 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType)) {
2136 return BT->getKind() >= BuiltinType::Bool &&
2137 BT->getKind() <= BuiltinType::UInt128;
2140 if (
const auto *ET = dyn_cast<EnumType>(CanonicalType)) {
2141 if (ET->getDecl()->isComplete())
2142 return ET->getDecl()->getIntegerType()->isUnsignedIntegerType();
2145 if (
const auto *IT = dyn_cast<BitIntType>(CanonicalType))
2146 return IT->isUnsigned();
2147 if (
const auto *IT = dyn_cast<DependentBitIntType>(CanonicalType))
2148 return IT->isUnsigned();
2154 if (
const auto *VT = dyn_cast<VectorType>(CanonicalType))
2155 return VT->getElementType()->isUnsignedIntegerOrEnumerationType();
2156 if (
const auto *VT = dyn_cast<MatrixType>(CanonicalType))
2157 return VT->getElementType()->isUnsignedIntegerOrEnumerationType();
2158 if (CanonicalType->isVLSTBuiltinType()) {
2159 const auto *VT = cast<BuiltinType>(CanonicalType);
2160 return VT->getKind() >= BuiltinType::SveUint8 &&
2161 VT->getKind() <= BuiltinType::SveUint64;
2167 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
2168 return BT->getKind() >= BuiltinType::Half &&
2169 BT->getKind() <= BuiltinType::Ibm128;
2170 if (
const auto *CT = dyn_cast<ComplexType>(CanonicalType))
2171 return CT->getElementType()->isFloatingType();
2176 if (
const auto *VT = dyn_cast<VectorType>(CanonicalType))
2177 return VT->getElementType()->isFloatingType();
2178 if (
const auto *MT = dyn_cast<MatrixType>(CanonicalType))
2179 return MT->getElementType()->isFloatingType();
2184 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
2185 return BT->isFloatingPoint();
2190 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
2191 return BT->getKind() >= BuiltinType::Bool &&
2192 BT->getKind() <= BuiltinType::Ibm128;
2193 if (
const auto *ET = dyn_cast<EnumType>(CanonicalType))
2194 return ET->getDecl()->isComplete() && !ET->getDecl()->isScoped();
2199 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
2200 return BT->getKind() >= BuiltinType::Bool &&
2201 BT->getKind() <= BuiltinType::Ibm128;
2202 if (
const auto *ET = dyn_cast<EnumType>(CanonicalType))
2209 return !ET->getDecl()->isScoped() && ET->getDecl()->isComplete();
2210 return isa<ComplexType>(CanonicalType) ||
isBitIntType();
2216 const Type *T = CanonicalType.getTypePtr();
2217 if (
const auto *BT = dyn_cast<BuiltinType>(T)) {
2218 if (BT->getKind() == BuiltinType::Bool)
return STK_Bool;
2219 if (BT->getKind() == BuiltinType::NullPtr)
return STK_CPointer;
2223 llvm_unreachable(
"unknown scalar builtin type");
2224 }
else if (isa<PointerType>(T)) {
2226 }
else if (isa<BlockPointerType>(T)) {
2228 }
else if (isa<ObjCObjectPointerType>(T)) {
2230 }
else if (isa<MemberPointerType>(T)) {
2232 }
else if (isa<EnumType>(T)) {
2233 assert(cast<EnumType>(T)->getDecl()->isComplete());
2235 }
else if (
const auto *CT = dyn_cast<ComplexType>(T)) {
2236 if (CT->getElementType()->isRealFloatingType())
2243 llvm_unreachable(
"unknown scalar type");
2256 if (
const auto *Record = dyn_cast<RecordType>(CanonicalType)) {
2257 if (
const auto *ClassDecl = dyn_cast<CXXRecordDecl>(Record->getDecl()))
2258 return ClassDecl->isAggregate();
2263 return isa<ArrayType>(CanonicalType);
2270 assert(!
isIncompleteType() &&
"This doesn't make sense for incomplete types");
2271 assert(!
isDependentType() &&
"This doesn't make sense for dependent types");
2273 return !isa<VariableArrayType>(CanonicalType);
2283 switch (CanonicalType->getTypeClass()) {
2284 default:
return false;
2290 EnumDecl *EnumD = cast<EnumType>(CanonicalType)->getDecl();
2298 RecordDecl *Rec = cast<RecordType>(CanonicalType)->getDecl();
2309 return cast<ArrayType>(CanonicalType)->getElementType()
2310 ->isIncompleteType(Def);
2311 case IncompleteArray:
2314 case MemberPointer: {
2318 auto *MPTy = cast<MemberPointerType>(CanonicalType);
2319 const Type *ClassTy = MPTy->getClass();
2332 if (RD->
hasAttr<MSInheritanceAttr>())
2337 return cast<ObjCObjectType>(CanonicalType)->getBaseType()
2338 ->isIncompleteType(Def);
2339 case ObjCInterface: {
2342 = cast<ObjCInterfaceType>(CanonicalType)->getDecl();
2351 if (
const BuiltinType *BT = getAs<BuiltinType>()) {
2352 switch (BT->getKind()) {
2354#define SVE_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
2355#include "clang/Basic/AArch64SVEACLETypes.def"
2356#define RVV_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
2357#include "clang/Basic/RISCVVTypes.def"
2360#define WASM_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
2361#include "clang/Basic/WebAssemblyReferenceTypes.def"
2375 if (
const auto *BT = getAs<BuiltinType>())
2376 return BT->getKind() == BuiltinType::WasmExternRef;
2383 if (
const BuiltinType *BT = getAs<BuiltinType>()) {
2384 switch (BT->getKind()) {
2386#define SVE_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
2387#include "clang/Basic/AArch64SVEACLETypes.def"
2397 if (
const BuiltinType *BT = getAs<BuiltinType>()) {
2398 switch (BT->getKind()) {
2399#define RVV_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
2400#include "clang/Basic/RISCVVTypes.def"
2410 if (
const BuiltinType *BT = getAs<BuiltinType>()) {
2411 switch (BT->getKind()) {
2412 case BuiltinType::SveInt8:
2413 case BuiltinType::SveInt16:
2414 case BuiltinType::SveInt32:
2415 case BuiltinType::SveInt64:
2416 case BuiltinType::SveUint8:
2417 case BuiltinType::SveUint16:
2418 case BuiltinType::SveUint32:
2419 case BuiltinType::SveUint64:
2420 case BuiltinType::SveFloat16:
2421 case BuiltinType::SveFloat32:
2422 case BuiltinType::SveFloat64:
2423 case BuiltinType::SveBFloat16:
2424 case BuiltinType::SveBool:
2425 case BuiltinType::SveBoolx2:
2426 case BuiltinType::SveBoolx4:
2439 if (BTy->
getKind() == BuiltinType::SveBool)
2449 if (
const BuiltinType *BT = getAs<BuiltinType>()) {
2450 switch (BT->getKind()) {
2452#define RVV_VECTOR_TYPE(Name, Id, SingletonId, NumEls, ElBits, NF, IsSigned, IsFP) \
2453 case BuiltinType::Id: \
2454 return NF == 1 && (NumEls * ElBits) == llvm::RISCV::RVVBitsPerBlock;
2455#include "clang/Basic/RISCVVTypes.def"
2485 if ((*this)->isIncompleteArrayType())
2488 if ((*this)->isIncompleteType())
2497 default:
return false;
2498 case Type::VariableArray:
2499 case Type::ConstantArray:
2503 case Type::ObjCObjectPointer:
2504 case Type::BlockPointer:
2508 case Type::MemberPointer:
2510 case Type::ExtVector:
2518 if (
const auto *ClassDecl =
2519 dyn_cast<CXXRecordDecl>(cast<RecordType>(CanonicalType)->getDecl()))
2520 return ClassDecl->isPOD();
2534 if ((*this)->isArrayType())
2537 if ((*this)->isSizelessBuiltinType())
2542 if ((*this)->isIncompleteType())
2561 if (
const auto *ClassDecl = dyn_cast<CXXRecordDecl>(RT->getDecl())) {
2568 return ClassDecl->hasTrivialDefaultConstructor() &&
2569 !ClassDecl->hasNonTrivialDefaultConstructor() &&
2570 ClassDecl->isTriviallyCopyable();
2581 if ((*this)->isArrayType())
2609 if (
const auto *ClassDecl = dyn_cast<CXXRecordDecl>(RT->getDecl())) {
2610 if (!ClassDecl->isTriviallyCopyable())
return false;
2626 return RD->canPassInRegisters();
2641 if (
Decl->isUnion())
2644 auto IsDefaultedOperatorEqualEqual = [&](
const FunctionDecl *Function) {
2645 return Function->getOverloadedOperator() ==
2646 OverloadedOperatorKind::OO_EqualEqual &&
2647 Function->isDefaulted() && Function->getNumParams() > 0 &&
2648 (Function->getParamDecl(0)->getType()->isReferenceType() ||
2649 Decl->isTriviallyCopyable());
2652 if (llvm::none_of(
Decl->methods(), IsDefaultedOperatorEqualEqual) &&
2654 if (
NamedDecl *ND = Friend->getFriendDecl()) {
2656 IsDefaultedOperatorEqualEqual(ND->getAsFunction());
2662 return llvm::all_of(
Decl->bases(),
2664 if (const auto *RD = BS.getType()->getAsCXXRecordDecl())
2665 HasNonDeletedDefaultedEqualityComparison(RD);
2669 auto Type = FD->getType();
2670 if (Type->isReferenceType() || Type->isEnumeralType())
2672 if (const auto *RD = Type->getAsCXXRecordDecl())
2673 return HasNonDeletedDefaultedEqualityComparison(RD);
2691 CanonicalType,
false);
2714 if (
const auto *RT =
2715 getTypePtr()->getBaseElementTypeUnsafe()->getAs<RecordType>())
2716 if (RT->getDecl()->isNonTrivialToPrimitiveDefaultInitialize())
2730 if (
const auto *RT =
2731 getTypePtr()->getBaseElementTypeUnsafe()->getAs<RecordType>())
2732 if (RT->getDecl()->isNonTrivialToPrimitiveCopy())
2768 assert(BaseTy &&
"NULL element type");
2798 if (
const auto *ClassDecl = dyn_cast<CXXRecordDecl>(RT->getDecl()))
2799 return ClassDecl->isLiteral();
2806 return AT->getValueType()->isLiteralType(Ctx);
2828 return RD->isStructural();
2841 assert(BaseTy &&
"NULL element type");
2851 if (
const auto *ClassDecl = dyn_cast<CXXRecordDecl>(RT->getDecl()))
2852 if (!ClassDecl->isStandardLayout())
2880 assert(BaseTy &&
"NULL element type");
2893 if (
const auto *ClassDecl = dyn_cast<CXXRecordDecl>(RT->getDecl())) {
2896 if (!ClassDecl->isTrivial())
return false;
2901 if (!ClassDecl->isStandardLayout())
return false;
2930 if (
const auto *ET = getAs<EnumType>()) {
2932 if (II && II->
isStr(
"align_val_t") && ET->getDecl()->isInStdNamespace())
2939 if (
const auto *ET = getAs<EnumType>()) {
2941 if (II && II->
isStr(
"byte") && ET->getDecl()->isInStdNamespace())
2957 case TemplateTypeParm:
2958 case SubstTemplateTypeParm:
2959 case TemplateSpecialization:
2962 case DependentTemplateSpecialization:
2994 llvm_unreachable(
"Type specifier is not a tag type kind.");
3006 llvm_unreachable(
"Unknown tag type kind.");
3019 llvm_unreachable(
"Elaborated type keyword is not a tag type kind.");
3021 llvm_unreachable(
"Unknown elaborated type keyword.");
3037 llvm_unreachable(
"Unknown elaborated type keyword.");
3051 llvm_unreachable(
"Unknown elaborated type keyword.");
3054DependentTemplateSpecializationType::DependentTemplateSpecializationType(
3061 NNS(NNS), Name(Name) {
3064 "DependentTemplateSpecializatonType requires dependent qualifier");
3065 auto *ArgBuffer =
const_cast<TemplateArgument *
>(template_arguments().data());
3068 TemplateArgumentDependence::UnexpandedPack));
3081 ID.AddInteger(Keyword);
3082 ID.AddPointer(Qualifier);
3083 ID.AddPointer(Name);
3085 Arg.Profile(ID, Context);
3090 if (
const auto *Elab = dyn_cast<ElaboratedType>(
this))
3091 Keyword = Elab->getKeyword();
3092 else if (
const auto *DepName = dyn_cast<DependentNameType>(
this))
3093 Keyword = DepName->getKeyword();
3094 else if (
const auto *DepTST =
3095 dyn_cast<DependentTemplateSpecializationType>(
this))
3096 Keyword = DepTST->getKeyword();
3105#define ABSTRACT_TYPE(Derived, Base)
3106#define TYPE(Derived, Base) case Derived: return #Derived;
3107#include "clang/AST/TypeNodes.inc"
3110 llvm_unreachable(
"Invalid type class.");
3118 return Policy.
Bool ?
"bool" :
"_Bool";
3124 return "signed char";
3136 return "unsigned char";
3138 return "unsigned short";
3140 return "unsigned int";
3142 return "unsigned long";
3144 return "unsigned long long";
3146 return "unsigned __int128";
3148 return Policy.
Half ?
"half" :
"__fp16";
3156 return "long double";
3158 return "short _Accum";
3162 return "long _Accum";
3164 return "unsigned short _Accum";
3166 return "unsigned _Accum";
3168 return "unsigned long _Accum";
3169 case BuiltinType::ShortFract:
3170 return "short _Fract";
3171 case BuiltinType::Fract:
3173 case BuiltinType::LongFract:
3174 return "long _Fract";
3175 case BuiltinType::UShortFract:
3176 return "unsigned short _Fract";
3177 case BuiltinType::UFract:
3178 return "unsigned _Fract";
3179 case BuiltinType::ULongFract:
3180 return "unsigned long _Fract";
3181 case BuiltinType::SatShortAccum:
3182 return "_Sat short _Accum";
3183 case BuiltinType::SatAccum:
3184 return "_Sat _Accum";
3185 case BuiltinType::SatLongAccum:
3186 return "_Sat long _Accum";
3187 case BuiltinType::SatUShortAccum:
3188 return "_Sat unsigned short _Accum";
3189 case BuiltinType::SatUAccum:
3190 return "_Sat unsigned _Accum";
3191 case BuiltinType::SatULongAccum:
3192 return "_Sat unsigned long _Accum";
3193 case BuiltinType::SatShortFract:
3194 return "_Sat short _Fract";
3195 case BuiltinType::SatFract:
3196 return "_Sat _Fract";
3197 case BuiltinType::SatLongFract:
3198 return "_Sat long _Fract";
3199 case BuiltinType::SatUShortFract:
3200 return "_Sat unsigned short _Fract";
3201 case BuiltinType::SatUFract:
3202 return "_Sat unsigned _Fract";
3203 case BuiltinType::SatULongFract:
3204 return "_Sat unsigned long _Fract";
3208 return "__float128";
3213 return Policy.
MSWChar ?
"__wchar_t" :
"wchar_t";
3223 return "<overloaded function type>";
3225 return "<bound member function type>";
3227 return "<pseudo-object type>";
3229 return "<dependent type>";
3231 return "<unknown type>";
3232 case ARCUnbridgedCast:
3233 return "<ARC unbridged cast type>";
3235 return "<builtin fn type>";
3242#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
3244 return "__" #Access " " #ImgType "_t";
3245#include "clang/Basic/OpenCLImageTypes.def"
3251 return "clk_event_t";
3255 return "reserve_id_t";
3256 case IncompleteMatrixIdx:
3257 return "<incomplete matrix index type>";
3258 case OMPArraySection:
3259 return "<OpenMP array section type>";
3260 case OMPArrayShaping:
3261 return "<OpenMP array shaping type>";
3263 return "<OpenMP iterator type>";
3264#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \
3267#include "clang/Basic/OpenCLExtensionTypes.def"
3268#define SVE_TYPE(Name, Id, SingletonId) \
3271#include "clang/Basic/AArch64SVEACLETypes.def"
3272#define PPC_VECTOR_TYPE(Name, Id, Size) \
3275#include "clang/Basic/PPCTypes.def"
3276#define RVV_TYPE(Name, Id, SingletonId) \
3279#include "clang/Basic/RISCVVTypes.def"
3280#define WASM_TYPE(Name, Id, SingletonId) \
3283#include "clang/Basic/WebAssemblyReferenceTypes.def"
3286 llvm_unreachable(
"Invalid builtin type.");
3291 if (
auto *PET = dyn_cast<PackExpansionType>(
getTypePtr()))
3292 return PET->getPattern();
3297 if (
const auto *RefType =
getTypePtr()->getAs<ReferenceType>())
3314 case CC_C:
return "cdecl";
3337 llvm_unreachable(
"Invalid calling convention.");
3342 const ExtProtoInfo &epi)
3343 :
FunctionType(FunctionProto, result, canonical, result->getDependence(),
3348 assert(getNumParams() == params.size() &&
"NumParams overflow!");
3354 if (epi.requiresFunctionProtoTypeExtraBitfields()) {
3356 auto &ExtraBits = *getTrailingObjects<FunctionTypeExtraBitfields>();
3357 ExtraBits = FunctionTypeExtraBitfields();
3364 auto *argSlot = getTrailingObjects<QualType>();
3365 for (
unsigned i = 0; i != getNumParams(); ++i) {
3367 ~TypeDependence::VariablyModified);
3368 argSlot[i] = params[i];
3373 auto &ExtraBits = *getTrailingObjects<FunctionTypeExtraBitfields>();
3374 size_t NumExceptions = epi.ExceptionSpec.Exceptions.size();
3375 assert(NumExceptions <= UINT16_MAX &&
3376 "Not enough bits to encode exceptions");
3377 ExtraBits.NumExceptionType = NumExceptions;
3379 assert(hasExtraBitfields() &&
"missing trailing extra bitfields!");
3381 reinterpret_cast<QualType *
>(getTrailingObjects<ExceptionType>());
3383 for (
QualType ExceptionType : epi.ExceptionSpec.Exceptions) {
3389 (TypeDependence::Instantiation | TypeDependence::UnexpandedPack));
3391 exnSlot[I++] = ExceptionType;
3396 assert(epi.ExceptionSpec.NoexceptExpr &&
"computed noexcept with no expr");
3398 epi.ExceptionSpec.NoexceptExpr->isValueDependent());
3401 *getTrailingObjects<Expr *>() = epi.ExceptionSpec.NoexceptExpr;
3405 (TypeDependence::Instantiation | TypeDependence::UnexpandedPack));
3411 auto **slot = getTrailingObjects<FunctionDecl *>();
3412 slot[0] = epi.ExceptionSpec.SourceDecl;
3413 slot[1] = epi.ExceptionSpec.SourceTemplate;
3419 auto **slot = getTrailingObjects<FunctionDecl *>();
3420 slot[0] = epi.ExceptionSpec.SourceDecl;
3428 assert(hasDependentExceptionSpec() &&
"type should not be canonical");
3437 if (epi.ExtParameterInfos) {
3438 auto *extParamInfos = getTrailingObjects<ExtParameterInfo>();
3439 for (
unsigned i = 0; i != getNumParams(); ++i)
3440 extParamInfos[i] = epi.ExtParameterInfos[i];
3443 if (epi.TypeQuals.hasNonFastQualifiers()) {
3445 *getTrailingObjects<Qualifiers>() = epi.TypeQuals;
3452 auto &EllipsisLoc = *getTrailingObjects<SourceLocation>();
3453 EllipsisLoc = epi.EllipsisLoc;
3459 return NE->isValueDependent();
3471 return NE->isInstantiationDependent();
3473 if (ET->isInstantiationDependentType())
3482 llvm_unreachable(
"should not call this with unresolved exception specs");
3508 llvm_unreachable(
"unexpected exception specification kind");
3512 for (
unsigned ArgIdx =
getNumParams(); ArgIdx; --ArgIdx)
3520 const QualType *ArgTys,
unsigned NumParams,
3521 const ExtProtoInfo &epi,
3540 ID.AddPointer(
Result.getAsOpaquePtr());
3541 for (
unsigned i = 0; i != NumParams; ++i)
3542 ID.AddPointer(ArgTys[i].getAsOpaquePtr());
3546 assert(!(
unsigned(epi.Variadic) & ~1) &&
3547 !(
unsigned(epi.RefQualifier) & ~3) &&
3548 !(
unsigned(epi.ExceptionSpec.Type) & ~15) &&
3549 "Values larger than expected.");
3550 ID.AddInteger(
unsigned(epi.Variadic) +
3551 (epi.RefQualifier << 1) +
3552 (epi.ExceptionSpec.Type << 3));
3553 ID.Add(epi.TypeQuals);
3555 for (
QualType Ex : epi.ExceptionSpec.Exceptions)
3558 epi.ExceptionSpec.NoexceptExpr->Profile(ID, Context, Canonical);
3561 ID.AddPointer(epi.ExceptionSpec.SourceDecl->getCanonicalDecl());
3563 if (epi.ExtParameterInfos) {
3564 for (
unsigned i = 0; i != NumParams; ++i)
3565 ID.AddInteger(epi.ExtParameterInfos[i].getOpaqueValue());
3567 epi.ExtInfo.Profile(ID);
3568 ID.AddBoolean(epi.HasTrailingReturn);
3581 assert(!isa<TypedefType>(can) &&
"Invalid canonical type");
3583 if (!typeMatchesDecl())
3584 *getTrailingObjects<QualType>() = Underlying;
3589 : *getTrailingObjects<QualType>();
3598 *getTrailingObjects<QualType>() = Underlying;
3604 cast<TypeDecl>(Found->
getTargetDecl())->getTypeForDecl(), 0)
3605 : *getTrailingObjects<QualType>();
3614 while (
auto *InnerMQT = dyn_cast<MacroQualifiedType>(Inner)) {
3617 Inner = InnerMQT->getModifiedType();
3627 ? Can.getAtomicUnqualifiedType()
3630 (E->getType()->getDependence() &
3651 E->
Profile(ID, Context,
true);
3652 ID.AddBoolean(IsUnqual);
3659 :
Type(Decltype, can,
3663 (E->getType()->getDependence() &
3665 E(E), UnderlyingType(underlyingType) {}
3677 :
DecltypeType(E, Context.DependentTy), Context(Context) {}
3681 E->
Profile(ID, Context,
true);
3687 :
Type(UnaryTransform, CanonicalType, BaseType->getDependence()),
3688 BaseType(BaseType), UnderlyingType(UnderlyingType), UKind(UKind) {}
3702 for (
auto *I :
decl->redecls()) {
3703 if (I->isCompleteDefinition() || I->isBeingDefined())
3719 std::vector<const RecordType*> RecordTypeList;
3720 RecordTypeList.push_back(
this);
3721 unsigned NextToCheckIndex = 0;
3723 while (RecordTypeList.size() > NextToCheckIndex) {
3725 RecordTypeList[NextToCheckIndex]->
getDecl()->fields()) {
3731 if (!llvm::is_contained(RecordTypeList, FieldRecTy))
3732 RecordTypeList.push_back(FieldRecTy);
3747 case attr::ObjCOwnership:
3748 case attr::ObjCInertUnsafeUnretained:
3749 case attr::TypeNonNull:
3750 case attr::TypeNullable:
3751 case attr::TypeNullableResult:
3752 case attr::TypeNullUnspecified:
3753 case attr::LifetimeBound:
3754 case attr::AddressSpace:
3767 default:
return false;
3774 llvm_unreachable(
"invalid attr kind");
3784 default:
return false;
3787 case attr::FastCall:
3789 case attr::ThisCall:
3791 case attr::SwiftCall:
3792 case attr::SwiftAsyncCall:
3793 case attr::VectorCall:
3794 case attr::AArch64VectorPcs:
3795 case attr::AArch64SVEPcs:
3796 case attr::AMDGPUKernelCall:
3800 case attr::IntelOclBicc:
3801 case attr::PreserveMost:
3802 case attr::PreserveAll:
3805 llvm_unreachable(
"invalid attr kind");
3818 if (
const auto *TTP = dyn_cast<TemplateTypeParmDecl>(D))
3820 return cast<TemplateTypeParmDecl>(
3824SubstTemplateTypeParmType::SubstTemplateTypeParmType(
3825 QualType Replacement,
Decl *AssociatedDecl,
unsigned Index,
3826 std::optional<unsigned> PackIndex)
3827 :
Type(SubstTemplateTypeParm, Replacement.getCanonicalType(),
3828 Replacement->getDependence()),
3829 AssociatedDecl(AssociatedDecl) {
3830 SubstTemplateTypeParmTypeBits.HasNonCanonicalUnderlyingType =
3831 Replacement != getCanonicalTypeInternal();
3832 if (SubstTemplateTypeParmTypeBits.HasNonCanonicalUnderlyingType)
3833 *getTrailingObjects<QualType>() = Replacement;
3835 SubstTemplateTypeParmTypeBits.Index = Index;
3836 SubstTemplateTypeParmTypeBits.PackIndex = PackIndex ? *PackIndex + 1 : 0;
3837 assert(AssociatedDecl !=
nullptr);
3845SubstTemplateTypeParmPackType::SubstTemplateTypeParmPackType(
3846 QualType Canon,
Decl *AssociatedDecl,
unsigned Index,
bool Final,
3848 :
Type(SubstTemplateTypeParmPack, Canon,
3851 Arguments(ArgPack.pack_begin()),
3852 AssociatedDeclAndFinal(AssociatedDecl, Final) {
3855 assert(AssociatedDecl !=
nullptr);
3859 return AssociatedDeclAndFinal.getPointer();
3863 return AssociatedDeclAndFinal.getInt();
3884 const Decl *AssociatedDecl,
3885 unsigned Index,
bool Final,
3887 ID.AddPointer(AssociatedDecl);
3888 ID.AddInteger(Index);
3889 ID.AddBoolean(Final);
3892 ID.AddPointer(
P.getAsType().getAsOpaquePtr());
3903 if (Arg.isDependent())
3911 if (ArgLoc.getArgument().isInstantiationDependent())
3917TemplateSpecializationType::TemplateSpecializationType(
3920 :
Type(TemplateSpecialization, Canon.isNull() ?
QualType(this, 0) : Canon,
3931 "Use DependentTemplateSpecializationType for dependent template-name");
3936 "Unexpected template name for TemplateSpecializationType");
3949 ~TypeDependence::Dependent);
3952 TypeDependence::VariablyModified);
3959 *
reinterpret_cast<QualType *
>(
Begin + Args.size()) = AliasedType;
3964 assert(
isTypeAlias() &&
"not a type alias template specialization");
3982 Arg.Profile(ID, Context);
4007 ID.AddInteger(typeArgs.size());
4008 for (
auto typeArg : typeArgs)
4009 ID.AddPointer(typeArg.getAsOpaquePtr());
4010 ID.AddInteger(protocols.size());
4011 for (
auto *proto : protocols)
4012 ID.AddPointer(proto);
4013 ID.AddBoolean(isKindOf);
4026 ID.AddPointer(OTPDecl);
4028 ID.AddInteger(protocols.size());
4029 for (
auto *proto : protocols)
4030 ID.AddPointer(proto);
4041class CachedProperties {
4046 CachedProperties(
Linkage L,
bool local) : L(L), local(local) {}
4048 Linkage getLinkage()
const {
return L; }
4049 bool hasLocalOrUnnamedType()
const {
return local; }
4051 friend CachedProperties merge(CachedProperties L, CachedProperties R) {
4053 return CachedProperties(MergedLinkage, L.hasLocalOrUnnamedType() ||
4054 R.hasLocalOrUnnamedType());
4075 return CachedProperties(T->
TypeBits.getLinkage(),
4076 T->
TypeBits.hasLocalOrUnnamedType());
4081 if (T->
TypeBits.isCacheValid())
return;
4098 T->
TypeBits.CachedLocalOrUnnamed =
Result.hasLocalOrUnnamedType();
4117#define TYPE(Class,Base)
4118#define NON_CANONICAL_TYPE(Class,Base) case Type::Class:
4119#include "clang/AST/TypeNodes.inc"
4120 llvm_unreachable(
"didn't expect a non-canonical type here");
4122#define TYPE(Class,Base)
4123#define DEPENDENT_TYPE(Class,Base) case Type::Class:
4124#define NON_CANONICAL_UNLESS_DEPENDENT_TYPE(Class,Base) case Type::Class:
4125#include "clang/AST/TypeNodes.inc"
4132 case Type::DeducedTemplateSpecialization:
4146 const TagDecl *Tag = cast<TagType>(T)->getDecl();
4153 bool IsLocalOrUnnamed =
4156 return CachedProperties(L, IsLocalOrUnnamed);
4163 return Cache::get(cast<ComplexType>(T)->getElementType());
4165 return Cache::get(cast<PointerType>(T)->getPointeeType());
4166 case Type::BlockPointer:
4167 return Cache::get(cast<BlockPointerType>(T)->getPointeeType());
4168 case Type::LValueReference:
4169 case Type::RValueReference:
4170 return Cache::get(cast<ReferenceType>(T)->getPointeeType());
4171 case Type::MemberPointer: {
4172 const auto *MPT = cast<MemberPointerType>(T);
4176 case Type::ConstantArray:
4177 case Type::IncompleteArray:
4178 case Type::VariableArray:
4179 return Cache::get(cast<ArrayType>(T)->getElementType());
4181 case Type::ExtVector:
4182 return Cache::get(cast<VectorType>(T)->getElementType());
4183 case Type::ConstantMatrix:
4184 return Cache::get(cast<ConstantMatrixType>(T)->getElementType());
4185 case Type::FunctionNoProto:
4186 return Cache::get(cast<FunctionType>(T)->getReturnType());
4187 case Type::FunctionProto: {
4188 const auto *FPT = cast<FunctionProtoType>(T);
4189 CachedProperties result =
Cache::get(FPT->getReturnType());
4190 for (
const auto &ai : FPT->param_types())
4194 case Type::ObjCInterface: {
4195 Linkage L = cast<ObjCInterfaceType>(T)->getDecl()->getLinkageInternal();
4196 return CachedProperties(L,
false);
4198 case Type::ObjCObject:
4199 return Cache::get(cast<ObjCObjectType>(T)->getBaseType());
4200 case Type::ObjCObjectPointer:
4201 return Cache::get(cast<ObjCObjectPointerType>(T)->getPointeeType());
4203 return Cache::get(cast<AtomicType>(T)->getValueType());
4205 return Cache::get(cast<PipeType>(T)->getElementType());
4208 llvm_unreachable(
"unhandled type class");
4219 return TypeBits.hasLocalOrUnnamedType();
4224#define TYPE(Class,Base)
4225#define NON_CANONICAL_TYPE(Class,Base) case Type::Class:
4226#include "clang/AST/TypeNodes.inc"
4227 llvm_unreachable(
"didn't expect a non-canonical type here");
4229#define TYPE(Class,Base)
4230#define DEPENDENT_TYPE(Class,Base) case Type::Class:
4231#define NON_CANONICAL_UNLESS_DEPENDENT_TYPE(Class,Base) case Type::Class:
4232#include "clang/AST/TypeNodes.inc"
4242 case Type::DeducedTemplateSpecialization:
4253 case Type::BlockPointer:
4255 case Type::LValueReference:
4256 case Type::RValueReference:
4258 case Type::MemberPointer: {
4259 const auto *MPT = cast<MemberPointerType>(T);
4264 case Type::ConstantArray:
4265 case Type::IncompleteArray:
4266 case Type::VariableArray:
4269 case Type::ExtVector:
4271 case Type::ConstantMatrix:
4273 cast<ConstantMatrixType>(T)->getElementType());
4274 case Type::FunctionNoProto:
4276 case Type::FunctionProto: {
4277 const auto *FPT = cast<FunctionProtoType>(T);
4279 for (
const auto &ai : FPT->param_types())
4283 case Type::ObjCInterface:
4285 case Type::ObjCObject:
4287 case Type::ObjCObjectPointer:
4289 cast<ObjCObjectPointerType>(T)->getPointeeType());
4296 llvm_unreachable(
"unhandled type class");
4327 if (
auto Nullability = AT->getImmediateNullability())
4330 Type = AT->getEquivalentType();
4332 return std::nullopt;
4338 switch (
type->getTypeClass()) {
4340#define NON_CANONICAL_TYPE(Class, Parent) \
4342 llvm_unreachable("non-canonical type");
4343#define TYPE(Class, Parent)
4344#include "clang/AST/TypeNodes.inc"
4348 case Type::BlockPointer:
4349 case Type::MemberPointer:
4350 case Type::ObjCObjectPointer:
4354 case Type::UnresolvedUsing:
4355 case Type::TypeOfExpr:
4357 case Type::Decltype:
4358 case Type::UnaryTransform:
4359 case Type::TemplateTypeParm:
4360 case Type::SubstTemplateTypeParmPack:
4361 case Type::DependentName:
4362 case Type::DependentTemplateSpecialization:
4364 return ResultIfUnknown;
4369 case Type::TemplateSpecialization:
4371 = cast<TemplateSpecializationType>(
type.getTypePtr())
4372 ->getTemplateName().getAsTemplateDecl()) {
4373 if (isa<ClassTemplateDecl>(templateDecl))
4376 return ResultIfUnknown;
4379 switch (cast<BuiltinType>(
type.getTypePtr())->getKind()) {
4381#define SIGNED_TYPE(Id, SingletonId) case BuiltinType::Id:
4382#define UNSIGNED_TYPE(Id, SingletonId) case BuiltinType::Id:
4383#define FLOATING_TYPE(Id, SingletonId) case BuiltinType::Id:
4384#define BUILTIN_TYPE(Id, SingletonId)
4385#include "clang/AST/BuiltinTypes.def"
4389 case BuiltinType::Dependent:
4390 case BuiltinType::Overload:
4391 case BuiltinType::BoundMember:
4392 case BuiltinType::PseudoObject:
4393 case BuiltinType::UnknownAny:
4394 case BuiltinType::ARCUnbridgedCast:
4395 return ResultIfUnknown;
4397 case BuiltinType::Void:
4398 case BuiltinType::ObjCId:
4399 case BuiltinType::ObjCClass:
4400 case BuiltinType::ObjCSel:
4401#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
4402 case BuiltinType::Id:
4403#include "clang/Basic/OpenCLImageTypes.def"
4404#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \
4405 case BuiltinType::Id:
4406#include "clang/Basic/OpenCLExtensionTypes.def"
4407 case BuiltinType::OCLSampler:
4408 case BuiltinType::OCLEvent:
4409 case BuiltinType::OCLClkEvent:
4410 case BuiltinType::OCLQueue:
4411 case BuiltinType::OCLReserveID:
4412#define SVE_TYPE(Name, Id, SingletonId) \
4413 case BuiltinType::Id:
4414#include "clang/Basic/AArch64SVEACLETypes.def"
4415#define PPC_VECTOR_TYPE(Name, Id, Size) \
4416 case BuiltinType::Id:
4417#include "clang/Basic/PPCTypes.def"
4418#define RVV_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
4419#include "clang/Basic/RISCVVTypes.def"
4420#define WASM_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
4421#include "clang/Basic/WebAssemblyReferenceTypes.def"
4422 case BuiltinType::BuiltinFn:
4423 case BuiltinType::NullPtr:
4424 case BuiltinType::IncompleteMatrixIdx:
4425 case BuiltinType::OMPArraySection:
4426 case BuiltinType::OMPArrayShaping:
4427 case BuiltinType::OMPIterator:
4430 llvm_unreachable(
"unknown builtin type");
4434 case Type::LValueReference:
4435 case Type::RValueReference:
4436 case Type::ConstantArray:
4437 case Type::IncompleteArray:
4438 case Type::VariableArray:
4439 case Type::DependentSizedArray:
4440 case Type::DependentVector:
4441 case Type::DependentSizedExtVector:
4443 case Type::ExtVector:
4444 case Type::ConstantMatrix:
4445 case Type::DependentSizedMatrix:
4446 case Type::DependentAddressSpace:
4447 case Type::FunctionProto:
4448 case Type::FunctionNoProto:
4450 case Type::DeducedTemplateSpecialization:
4452 case Type::InjectedClassName:
4453 case Type::PackExpansion:
4454 case Type::ObjCObject:
4455 case Type::ObjCInterface:
4459 case Type::DependentBitInt:
4462 llvm_unreachable(
"bad type kind!");
4474 return std::nullopt;
4477std::optional<NullabilityKind>
4480 if (
auto MacroTy = dyn_cast<MacroQualifiedType>(T))
4481 AttrTy = MacroTy->getUnderlyingType();
4483 if (
auto attributed = dyn_cast<AttributedType>(AttrTy)) {
4484 if (
auto nullability = attributed->getImmediateNullability()) {
4485 T = attributed->getModifiedType();
4490 return std::nullopt;
4494 const auto *objcPtr = getAs<ObjCObjectPointerType>();
4498 if (objcPtr->isObjCIdType()) {
4509 }
else if (objcPtr->isObjCQualifiedIdType()) {
4534 "cannot query implicit lifetime for non-inferrable type");
4539 while (
const auto *array = dyn_cast<ArrayType>(canon))
4540 canon = array->getElementType().getTypePtr();
4542 if (
const auto *opt = dyn_cast<ObjCObjectPointerType>(canon)) {
4544 if (opt->getObjectType()->isObjCClass())
4552 if (
const auto *
typedefType = getAs<TypedefType>())
4553 return typedefType->getDecl()->hasAttr<ObjCNSObjectAttr>();
4558 if (
const auto *
typedefType = getAs<TypedefType>())
4559 return typedefType->getDecl()->hasAttr<ObjCIndependentClassAttr>();
4572 if (
const auto *OPT = getAs<PointerType>())
4573 return OPT->getPointeeType()->isObjCIndirectLifetimeType();
4574 if (
const auto *Ref = getAs<ReferenceType>())
4575 return Ref->getPointeeType()->isObjCIndirectLifetimeType();
4576 if (
const auto *MemPtr = getAs<MemberPointerType>())
4577 return MemPtr->getPointeeType()->isObjCIndirectLifetimeType();
4585 while (
const ArrayType *array =
type->getAsArrayTypeUnsafe())
4586 type = array->getElementType().getTypePtr();
4587 return type->isObjCRetainableType();
4598 const auto *
Pointer = getAs<PointerType>();
4608 if (
const auto *RT = getAs<RecordType>())
4609 return RT->getDecl()->hasAttr<CUDADeviceBuiltinSurfaceTypeAttr>();
4615 if (
const auto *RT = getAs<RecordType>())
4616 return RT->getDecl()->hasAttr<CUDADeviceBuiltinTextureTypeAttr>();
4623 if (
const auto *ptr = getAs<PointerType>())
4624 return ptr->getPointeeType()->hasSizedVLAType();
4625 if (
const auto *ref = getAs<ReferenceType>())
4626 return ref->getPointeeType()->hasSizedVLAType();
4628 if (isa<VariableArrayType>(arr) &&
4629 cast<VariableArrayType>(arr)->getSizeExpr())
4632 return arr->getElementType()->hasSizedVLAType();
4639 switch (
type.getObjCLifetime()) {
4651 if (
const auto *RT =
4654 if (
const auto *CXXRD = dyn_cast<CXXRecordDecl>(RD)) {
4656 if (CXXRD->hasDefinition() && !CXXRD->hasTrivialDestructor())
4674 llvm::APSInt Val,
unsigned Scale) {
4675 llvm::FixedPointSemantics FXSema(Val.getBitWidth(), Scale, Val.isSigned(),
4678 llvm::APFixedPoint(Val, FXSema).toString(Str);
4686 AutoTypeBits.Keyword = (
unsigned)Keyword;
4687 AutoTypeBits.NumArgs = TypeConstraintArgs.size();
4688 this->TypeConstraintConcept = TypeConstraintConcept;
4689 assert(TypeConstraintConcept || AutoTypeBits.NumArgs == 0);
4690 if (TypeConstraintConcept) {
4699 if (!DeducedAsType.
isNull())
4701 addDependence(ArgDependence);
4713 ID.AddInteger((
unsigned)Keyword);
4714 ID.AddBoolean(IsDependent);
4717 Arg.Profile(ID, Context);
Defines the clang::ASTContext interface.
Provides definitions for the various language-specific address spaces.
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate....
Defines the C++ template declaration subclasses.
Defines the ExceptionSpecificationType enumeration and various utility functions.
Defines the clang::IdentifierInfo, clang::IdentifierTable, and clang::Selector interfaces.
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified.
Defines the clang::LangOptions interface.
static bool isRecordType(QualType T)
Defines various enumerations that describe declaration and type specifiers.
Defines the TargetCXXABI class, which abstracts details of the C++ ABI that we're targeting.
static TagDecl * getInterestingTagDecl(TagDecl *decl)
#define SUGARED_TYPE_CLASS(Class)
static bool HasNonDeletedDefaultedEqualityComparison(const CXXRecordDecl *Decl)
static const TemplateTypeParmDecl * getReplacedParameter(Decl *D, unsigned Index)
static const T * getAsSugar(const Type *Cur)
This will check for a T (which should be a Type which can act as sugar, such as a TypedefType) by rem...
#define TRIVIAL_TYPE_CLASS(Class)
static CachedProperties computeCachedProperties(const Type *T)
C Language Family Type Representation.
Defines the clang::Visibility enumeration and various utility functions.
__DEVICE__ void * memcpy(void *__a, const void *__b, size_t __c)
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
BuiltinVectorTypeInfo getBuiltinVectorTypeInfo(const BuiltinType *VecTy) const
Returns the element type, element count and number of vectors (in case of tuple) for a builtin vector...
QualType getAtomicType(QualType T) const
Return the uniqued reference to the atomic type for the specified type.
QualType getParenType(QualType NamedType) const
QualType getRValueReferenceType(QualType T) const
Return the uniqued reference to the type for an rvalue reference to the specified type.
QualType getAttributedType(attr::Kind attrKind, QualType modifiedType, QualType equivalentType) const
QualType getIncompleteArrayType(QualType EltTy, ArrayType::ArraySizeModifier ASM, unsigned IndexTypeQuals) const
Return a unique reference to the type for an incomplete array of the specified element type.
QualType getAutoType(QualType DeducedType, AutoTypeKeyword Keyword, bool IsDependent, bool IsPack=false, ConceptDecl *TypeConstraintConcept=nullptr, ArrayRef< TemplateArgument > TypeConstraintArgs={}) const
C++11 deduced auto type.
QualType getObjCInterfaceType(const ObjCInterfaceDecl *Decl, ObjCInterfaceDecl *PrevDecl=nullptr) const
getObjCInterfaceType - Return the unique reference to the type for the specified ObjC interface decl.
QualType getBlockPointerType(QualType T) const
Return the uniqued reference to the type for a block of the specified type.
QualType getMemberPointerType(QualType T, const Type *Cls) const
Return the uniqued reference to the type for a member pointer to the specified type in the specified ...
QualType getFunctionNoProtoType(QualType ResultTy, const FunctionType::ExtInfo &Info) const
Return a K&R style C function type like 'int()'.
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.
const LangOptions & getLangOpts() const
QualType applyObjCProtocolQualifiers(QualType type, ArrayRef< ObjCProtocolDecl * > protocols, bool &hasError, bool allowOnPointerType=false) const
Apply Objective-C protocol qualifiers to the given type.
QualType getDecayedType(QualType T) const
Return the uniqued reference to the decayed version of the given type.
bool hasUniqueObjectRepresentations(QualType Ty, bool CheckIfTriviallyCopyable=true) const
Return true if the specified type has unique object representations according to (C++17 [meta....
QualType getBaseElementType(const ArrayType *VAT) const
Return the innermost element type of an array type.
CanQualType ObjCBuiltinIdTy
IdentifierInfo * getNSObjectName() const
Retrieve the identifier 'NSObject'.
CanQualType getSizeType() const
Return the unique type for "size_t" (C99 7.17), defined in <stddef.h>.
QualType getVariableArrayType(QualType EltTy, Expr *NumElts, ArrayType::ArraySizeModifier ASM, unsigned IndexTypeQuals, SourceRange Brackets) const
Return a non-unique reference to the type for a variable array of the specified element type.
QualType getAdjustedType(QualType Orig, QualType New) const
Return the uniqued reference to a type adjusted from the original type to a new type.
QualType getVectorType(QualType VectorType, unsigned NumElts, VectorType::VectorKind VecKind) const
Return the unique reference to a vector type of the specified element type and size.
QualType getQualifiedType(SplitQualType split) const
Un-split a SplitQualType.
QualType getConstantArrayType(QualType EltTy, const llvm::APInt &ArySize, const Expr *SizeExpr, ArrayType::ArraySizeModifier ASM, unsigned IndexTypeQuals) const
Return the unique reference to the type for a constant array of the specified element type.
QualType getObjCObjectPointerType(QualType OIT) const
Return a ObjCObjectPointerType type for the given ObjCObjectType.
QualType getObjCObjectType(QualType Base, ObjCProtocolDecl *const *Protocols, unsigned NumProtocols) const
Legacy interface: cannot provide type arguments or __kindof.
const ArrayType * getAsArrayType(QualType T) const
Type Query functions.
uint64_t getTypeSize(QualType T) const
Return the size of the specified (complete) type T, in bits.
CharUnits getTypeSizeInChars(QualType T) const
Return the size of the specified (complete) type T, in characters.
CanQualType UnsignedCharTy
QualType getFunctionType(QualType ResultTy, ArrayRef< QualType > Args, const FunctionProtoType::ExtProtoInfo &EPI) const
Return a normal function type with a typed argument list.
QualType getComplexType(QualType T) const
Return the uniqued reference to the type for a complex number with the specified element type.
QualType getExtVectorType(QualType VectorType, unsigned NumElts) const
Return the unique reference to an extended vector type of the specified element type and size.
const TargetInfo & getTargetInfo() const
QualType getSubstTemplateTypeParmType(QualType Replacement, Decl *AssociatedDecl, unsigned Index, std::optional< unsigned > PackIndex) const
Retrieve a substitution-result type.
QualType getConstantMatrixType(QualType ElementType, unsigned NumRows, unsigned NumColumns) const
Return the unique reference to the matrix type of the specified element type and size.
IdentifierInfo * getNSCopyingName()
Retrieve the identifier 'NSCopying'.
Represents a type which was implicitly adjusted by the semantic engine for arbitrary reasons.
QualType getAdjustedType() const
QualType getOriginalType() const
Represents an array type, per C99 6.7.5.2 - Array Declarators.
ArraySizeModifier
Capture whether this is a normal array (e.g.
ArraySizeModifier getSizeModifier() const
QualType getElementType() const
ArrayType(TypeClass tc, QualType et, QualType can, ArraySizeModifier sm, unsigned tq, const Expr *sz=nullptr)
unsigned getIndexTypeCVRQualifiers() const
QualType getValueType() const
Gets the type contained by this atomic type, i.e.
An attributed type is a type to which a type attribute has been applied.
QualType getModifiedType() const
bool isCallingConv() const
std::optional< NullabilityKind > getImmediateNullability() const
static std::optional< NullabilityKind > stripOuterNullability(QualType &T)
Strip off the top-level nullability annotation on the given type, if it's there.
bool isMSTypeSpec() const
QualType getEquivalentType() const
bool isWebAssemblyFuncrefSpec() const
bool isQualifier() const
Does this attribute behave like a type qualifier?
Represents a C++11 auto or C++14 decltype(auto) type, possibly constrained by a type-constraint.
ArrayRef< TemplateArgument > getTypeConstraintArguments() const
void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context)
ConceptDecl * getTypeConstraintConcept() const
AutoTypeKeyword getKeyword() const
BitIntType(bool isUnsigned, unsigned NumBits)
QualType getPointeeType() const
This class is used for builtin types like 'int'.
StringRef getName(const PrintingPolicy &Policy) const
Represents a base class of a C++ class.
Represents a C++ struct/union/class.
bool mayBeNonDynamicClass() const
CXXRecordDecl * getMostRecentNonInjectedDecl()
bool mayBeDynamicClass() const
QuantityType getQuantity() const
getQuantity - Get the raw integer representation of this quantity.
Complex values, per C99 6.2.5p11.
QualType getElementType() const
Declaration of a C++20 concept.
Represents the canonical version of C arrays with a specified constant size.
const llvm::APInt & getSize() const
static unsigned getNumAddressingBits(const ASTContext &Context, QualType ElementType, const llvm::APInt &NumElements)
Determine the number of bits required to address a member of.
static unsigned getMaxSizeBits(const ASTContext &Context)
Determine the maximum number of active bits that an array's size can require, which limits the maximu...
const Expr * getSizeExpr() const
void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Ctx)
Represents a concrete matrix type with constant number of rows and columns.
unsigned getNumColumns() const
Returns the number of columns in the matrix.
unsigned getNumRows() const
Returns the number of rows in the matrix.
ConstantMatrixType(QualType MatrixElementType, unsigned NRows, unsigned NColumns, QualType CanonElementType)
Represents a pointer type decayed from an array or function type.
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
ASTContext & getParentASTContext() const
bool isFunctionOrMethod() const
Decl - This represents one declaration (or definition), e.g.
bool isInStdNamespace() const
bool isFunctionOrFunctionTemplate() const
Whether this declaration is a function or function template.
ASTContext & getASTContext() const LLVM_READONLY
DeclContext * getDeclContext()
virtual Decl * getCanonicalDecl()
Retrieves the "canonical" declaration of the given declaration.
Represents the type decltype(expr) (C++11).
QualType desugar() const
Remove a single level of sugar.
bool isSugared() const
Returns whether this type directly provides sugar.
DecltypeType(Expr *E, QualType underlyingType, QualType can=QualType())
QualType getUnderlyingType() const
Common base class for placeholders for types that get replaced by placeholder type deduction: C++11 a...
QualType getDeducedType() const
Get the type deduced for this placeholder type, or null if it has not been deduced.
void Profile(llvm::FoldingSetNodeID &ID)
void Profile(llvm::FoldingSetNodeID &ID)
Expr * getNumBitsExpr() const
DependentBitIntType(const ASTContext &Context, bool IsUnsigned, Expr *NumBits)
DependentDecltypeType(const ASTContext &Context, Expr *E)
void Profile(llvm::FoldingSetNodeID &ID)
void Profile(llvm::FoldingSetNodeID &ID)
Represents an extended vector type where either the type or size is dependent.
QualType getElementType() const
void Profile(llvm::FoldingSetNodeID &ID)
Represents a matrix type where the type and the number of rows and columns is dependent on a template...
void Profile(llvm::FoldingSetNodeID &ID)
void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context)
void Profile(llvm::FoldingSetNodeID &ID)
void Profile(llvm::FoldingSetNodeID &ID)
Represents a type that was referred to using an elaborated type keyword, e.g., struct S,...
QualType getNamedType() const
Retrieve the type named by the qualified-id.
bool isComplete() const
Returns true if this can be considered a complete type.
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of enums.
This represents one expression.
bool 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.
ExtVectorType - Extended vector type.
Represents a member of a struct/union/class.
FriendDecl - Represents the declaration of a friend entity, which can be a function,...
Represents a function declaration or definition.
Represents a K&R-style 'int foo()' function, which has no information available about its arguments.
Represents a prototype with parameter type info, e.g.
bool hasDependentExceptionSpec() const
Return whether this function has a dependent exception spec.
param_type_iterator param_type_begin() const
ExceptionSpecificationType getExceptionSpecType() const
Get the kind of exception specification on this function.
bool isTemplateVariadic() const
Determines whether this function prototype contains a parameter pack at the end.
unsigned getNumParams() const
bool hasTrailingReturn() const
Whether this function prototype has a trailing return type.
QualType getParamType(unsigned i) const
QualType getExceptionType(unsigned i) const
Return the ith exception type, where 0 <= i < getNumExceptions().
void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Ctx)
unsigned getNumExceptions() const
Return the number of types in the exception specification.
CanThrowResult canThrow() const
Determine whether this function type has a non-throwing exception specification.
ExtProtoInfo getExtProtoInfo() const
Expr * getNoexceptExpr() const
Return the expression inside noexcept(expression), or a null pointer if there is none (because the ex...
ArrayRef< QualType > getParamTypes() const
ArrayRef< QualType > exceptions() const
bool hasInstantiationDependentExceptionSpec() const
Return whether this function has an instantiation-dependent exception spec.
FunctionType - C99 6.7.5.3 - Function Declarators.
ExtInfo getExtInfo() const
static StringRef getNameForCallConv(CallingConv CC)
QualType getReturnType() const
One of these records is kept for each identifier that is lexed.
bool isStr(const char(&Str)[StrLen]) const
Return true if this is the identifier for the specified string.
Represents a C array with an unspecified size.
CXXRecordDecl * getDecl() const
An lvalue reference type, per C++11 [dcl.ref].
LinkageInfo computeTypeLinkageInfo(const Type *T)
LinkageInfo getTypeLinkageAndVisibility(const Type *T)
LinkageInfo getDeclLinkageAndVisibility(const NamedDecl *D)
static LinkageInfo external()
Linkage getLinkage() const
void merge(LinkageInfo other)
Merge both linkage and visibility.
Sugar type that represents a type that was qualified by a qualifier written as a macro invocation.
QualType getModifiedType() const
Return this attributed type's modified type with no qualifiers attached to it.
QualType getUnderlyingType() const
const IdentifierInfo * getMacroIdentifier() const
Represents a matrix type, as defined in the Matrix Types clang extensions.
QualType getElementType() const
Returns type of the elements being stored in the matrix.
MatrixType(QualType ElementTy, QualType CanonElementTy)
QualType ElementType
The element type of the matrix.
A pointer to member type per C++ 8.3.3 - Pointers to members.
CXXRecordDecl * getMostRecentCXXRecordDecl() const
QualType getPointeeType() const
const Type * getClass() const
This represents a decl that may have a name.
Linkage getLinkageInternal() const
Determine what kind of linkage this entity has.
IdentifierInfo * getIdentifier() const
Get the identifier that names this declaration, if there is one.
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
bool isDependent() const
Whether this nested name specifier refers to a dependent type or not.
ObjCCategoryDecl - Represents a category declaration.
ObjCInterfaceDecl * getClassInterface()
ObjCTypeParamList * getTypeParamList() const
Retrieve the type parameter list associated with this category or extension.
Represents an ObjC class declaration.
ObjCTypeParamList * getTypeParamList() const
Retrieve the type parameters of this class.
bool hasDefinition() const
Determine whether this class has been defined.
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.