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);
115std::optional<QualType::NonConstantStorageReason>
118 if (!
isConstant(Ctx) && !(*this)->isReferenceType())
126 if (Record->hasMutableFields())
128 if (!Record->hasTrivialDestructor() && !ExcludeDtor)
148 et->getDependence() |
154 (tc == DependentSizedArray
164 const llvm::APInt &NumElements) {
173 if (llvm::isPowerOf2_64(ElementSize)) {
174 return NumElements.getActiveBits() + llvm::Log2_64(ElementSize);
179 if ((ElementSize >> 32) == 0 && NumElements.getBitWidth() <= 64 &&
180 (NumElements.getZExtValue() >> 32) == 0) {
181 uint64_t TotalSize = NumElements.getZExtValue() * ElementSize;
182 return llvm::bit_width(TotalSize);
186 llvm::APSInt SizeExtended(NumElements,
true);
188 SizeExtended = SizeExtended.extend(std::max(SizeTypeBits,
189 SizeExtended.getBitWidth()) * 2);
191 llvm::APSInt TotalSize(llvm::APInt(SizeExtended.getBitWidth(), ElementSize));
192 TotalSize *= SizeExtended;
194 return TotalSize.getActiveBits();
216 const llvm::APInt &ArraySize,
218 unsigned TypeQuals) {
220 ID.AddInteger(ArraySize.getZExtValue());
221 ID.AddInteger(SizeMod);
222 ID.AddInteger(TypeQuals);
223 ID.AddBoolean(SizeExpr !=
nullptr);
225 SizeExpr->
Profile(ID, Context,
true);
228DependentSizedArrayType::DependentSizedArrayType(
const ASTContext &Context,
230 Expr *e, ArraySizeModifier sm,
233 :
ArrayType(DependentSizedArray, et, can, sm, tq, e),
234 Context(Context), SizeExpr((
Stmt*) e), Brackets(brackets) {}
243 ID.AddInteger(SizeMod);
244 ID.AddInteger(TypeQuals);
248DependentVectorType::DependentVectorType(
const ASTContext &Context,
253 :
Type(DependentVector, CanonType,
255 ElementType->getDependence() |
258 Context(Context), ElementType(ElementType), SizeExpr(SizeExpr), Loc(Loc) {
267 ID.AddInteger(VecKind);
268 SizeExpr->
Profile(ID, Context,
true);
271DependentSizedExtVectorType::DependentSizedExtVectorType(
274 :
Type(DependentSizedExtVector, can,
276 ElementType->getDependence() |
279 Context(Context), SizeExpr(SizeExpr), ElementType(ElementType), loc(loc) {
287 SizeExpr->
Profile(ID, Context,
true);
290DependentAddressSpaceType::DependentAddressSpaceType(
const ASTContext &Context,
295 :
Type(DependentAddressSpace, can,
297 PointeeType->getDependence() |
300 Context(Context), AddrSpaceExpr(AddrSpaceExpr), PointeeType(PointeeType),
306 Expr *AddrSpaceExpr) {
308 AddrSpaceExpr->
Profile(ID, Context,
true);
312 const Expr *RowExpr,
const Expr *ColumnExpr)
313 :
Type(tc, canonType,
314 (RowExpr ? (matrixType->getDependence() |
TypeDependence::Dependent |
316 (matrixType->isVariablyModifiedType()
319 (matrixType->containsUnexpandedParameterPack() ||
321 RowExpr->containsUnexpandedParameterPack()) ||
323 ColumnExpr->containsUnexpandedParameterPack())
326 : matrixType->getDependence())),
327 ElementType(matrixType) {}
330 unsigned nColumns,
QualType canonType)
335 unsigned nRows,
unsigned nColumns,
337 :
MatrixType(tc, matrixType, canonType), NumRows(nRows),
338 NumColumns(nColumns) {}
340DependentSizedMatrixType::DependentSizedMatrixType(
343 :
MatrixType(DependentSizedMatrix, ElementType, CanonicalType, RowExpr,
345 Context(CTX), RowExpr(RowExpr), ColumnExpr(ColumnExpr), loc(loc) {}
352 RowExpr->
Profile(ID, CTX,
true);
353 ColumnExpr->
Profile(ID, CTX,
true);
358 :
VectorType(Vector, vecType, nElements, canonType, vecKind) {}
362 :
Type(tc, canonType, vecType->getDependence()), ElementType(vecType) {
372 bool IsUnsigned,
Expr *NumBitsExpr)
375 Context(Context), ExprAndUnsigned(NumBitsExpr, IsUnsigned) {}
378 return ExprAndUnsigned.getInt();
382 return ExprAndUnsigned.getPointer();
388 ID.AddBoolean(IsUnsigned);
389 NumBitsExpr->
Profile(ID, Context,
true);
397 if (
const auto *ATy = dyn_cast<ArrayType>(
this))
398 return ATy->getElementType().getTypePtr();
401 if (!isa<ArrayType>(CanonicalType))
407 ->getElementType().getTypePtr();
431#define TYPE(CLASS, BASE) \
432 static_assert(!std::is_polymorphic<CLASS##Type>::value, \
433 #CLASS "Type should not be polymorphic!");
434#include "clang/AST/TypeNodes.inc"
442#define TYPE(CLASS, BASE) \
443 static_assert(std::is_trivially_destructible<CLASS##Type>::value || \
444 std::is_same<CLASS##Type, ConstantArrayType>::value, \
445 #CLASS "Type should be trivially destructible!");
446#include "clang/AST/TypeNodes.inc"
450#define ABSTRACT_TYPE(Class, Parent)
451#define TYPE(Class, Parent) \
452 case Type::Class: { \
453 const auto *ty = cast<Class##Type>(this); \
454 if (!ty->isSugared()) return QualType(ty, 0); \
455 return ty->desugar(); \
457#include "clang/AST/TypeNodes.inc"
459 llvm_unreachable(
"bad type kind!");
469#define ABSTRACT_TYPE(Class, Parent)
470#define TYPE(Class, Parent) \
471 case Type::Class: { \
472 const auto *Ty = cast<Class##Type>(CurTy); \
473 if (!Ty->isSugared()) \
474 return SplitQualType(Ty, Qs); \
475 Cur = Ty->desugar(); \
478#include "clang/AST/TypeNodes.inc"
498#define ABSTRACT_TYPE(Class, Parent)
499#define TYPE(Class, Parent) \
500 case Type::Class: { \
501 const auto *ty = cast<Class##Type>(split.Ty); \
502 if (!ty->isSugared()) goto done; \
503 next = ty->desugar(); \
506#include "clang/AST/TypeNodes.inc"
525 T = PT->getInnerType();
534 if (
const auto *Sugar = dyn_cast<T>(Cur))
537#define ABSTRACT_TYPE(Class, Parent)
538#define TYPE(Class, Parent) \
539 case Type::Class: { \
540 const auto *Ty = cast<Class##Type>(Cur); \
541 if (!Ty->isSugared()) return 0; \
542 Cur = Ty->desugar().getTypePtr(); \
545#include "clang/AST/TypeNodes.inc"
551 return getAsSugar<TypedefType>(
this);
555 return getAsSugar<UsingType>(
this);
559 return getAsSugar<TemplateSpecializationType>(
this);
563 return getAsSugar<AttributedType>(
this);
570 const Type *Cur =
this;
574#define ABSTRACT_TYPE(Class, Parent)
575#define TYPE(Class, Parent) \
577 const auto *Ty = cast<Class##Type>(Cur); \
578 if (!Ty->isSugared()) return Cur; \
579 Cur = Ty->desugar().getTypePtr(); \
582#include "clang/AST/TypeNodes.inc"
588 if (
const auto *RT = getAs<RecordType>())
589 return RT->getDecl()->isClass();
594 if (
const auto *RT = getAs<RecordType>())
595 return RT->getDecl()->isStruct();
600 if (
const auto *RT = getAs<RecordType>())
601 return RT->getDecl()->hasAttr<ObjCBoxableAttr>();
606 if (
const auto *RT = getAs<RecordType>())
607 return RT->getDecl()->isInterface();
612 if (
const auto *RT = getAs<RecordType>()) {
620 if (
const auto *PT = getAs<PointerType>())
621 return PT->getPointeeType()->isVoidType();
626 if (
const auto *RT = getAs<RecordType>())
627 return RT->getDecl()->isUnion();
632 if (
const auto *CT = dyn_cast<ComplexType>(CanonicalType))
633 return CT->getElementType()->isFloatingType();
643 if (
const auto *ET = getAs<EnumType>())
644 return ET->getDecl()->isScoped();
649 if (
const auto *
Complex = getAs<ComplexType>())
650 if (
Complex->getElementType()->isIntegerType())
656 if (
const auto *PT = getAs<PointerType>())
658 if (
const auto *OPT = getAs<ObjCObjectPointerType>())
660 if (
const auto *BPT = getAs<BlockPointerType>())
662 if (
const auto *RT = getAs<ReferenceType>())
664 if (
const auto *MPT = getAs<MemberPointerType>())
666 if (
const auto *DT = getAs<DecayedType>())
673 if (
const auto *RT = dyn_cast<RecordType>(
this)) {
674 if (RT->getDecl()->isStruct())
679 if (
const auto *RT = dyn_cast<RecordType>(CanonicalType)) {
680 if (!RT->getDecl()->isStruct())
692 if (
const auto *RT = dyn_cast<RecordType>(
this)) {
693 if (RT->getDecl()->isUnion())
698 if (
const auto *RT = dyn_cast<RecordType>(CanonicalType)) {
699 if (!RT->getDecl()->isUnion())
714 const auto *OPT = getAs<ObjCObjectPointerType>();
719 if (OPT->isObjCIdType())
723 if (!OPT->isKindOfType())
727 if (OPT->isObjCClassType() || OPT->isObjCQualifiedClassType())
737 const auto *OPT = getAs<ObjCObjectPointerType>();
742 if (OPT->isObjCClassType())
746 if (!OPT->isKindOfType())
750 return OPT->isObjCClassType() || OPT->isObjCQualifiedClassType();
764 :
Type(ObjCObject, Canonical,
Base->getDependence()), BaseType(
Base) {
769 "bitfield overflow in type argument count");
770 if (!typeArgs.empty())
771 memcpy(getTypeArgStorage(), typeArgs.data(),
772 typeArgs.size() *
sizeof(
QualType));
774 for (
auto typeArg : typeArgs) {
775 addDependence(typeArg->getDependence() & ~TypeDependence::VariablyModified);
788 if (
const auto objcObject =
getBaseType()->getAs<ObjCObjectType>()) {
790 if (isa<ObjCInterfaceType>(objcObject))
793 return objcObject->isSpecialized();
806 if (
const auto objcObject =
getBaseType()->getAs<ObjCObjectType>()) {
808 if (isa<ObjCInterfaceType>(objcObject))
811 return objcObject->getTypeArgs();
823 if (
const auto objcObject =
getBaseType()->getAs<ObjCObjectType>()) {
825 if (isa<ObjCInterfaceType>(objcObject))
828 return objcObject->isKindOfType();
844 baseType = baseObj->stripObjCKindOfTypeAndQuals(ctx);
847 splitBaseType.
Quals),
873template <
typename Derived>
874struct SimpleTransformVisitor :
public TypeVisitor<Derived, QualType> {
882 QualType result =
static_cast<Derived *
>(
this)->Visit(splitType.
Ty);
892 explicit SimpleTransformVisitor(
ASTContext &ctx) : Ctx(ctx) {}
896#define TYPE(Class, Base)
897#define DEPENDENT_TYPE(Class, Base) \
898 QualType Visit##Class##Type(const Class##Type *T) { return QualType(T, 0); }
899#include "clang/AST/TypeNodes.inc"
901#define TRIVIAL_TYPE_CLASS(Class) \
902 QualType Visit##Class##Type(const Class##Type *T) { return QualType(T, 0); }
903#define SUGARED_TYPE_CLASS(Class) \
904 QualType Visit##Class##Type(const Class##Type *T) { \
905 if (!T->isSugared()) \
906 return QualType(T, 0); \
907 QualType desugaredType = recurse(T->desugar()); \
908 if (desugaredType.isNull()) \
910 if (desugaredType.getAsOpaquePtr() == T->desugar().getAsOpaquePtr()) \
911 return QualType(T, 0); \
912 return desugaredType; \
1000 if (elementType.
isNull())
1014 if (elementType.
isNull())
1026 if (elementType.
isNull())
1038 if (elementType.
isNull())
1049 if (elementType.
isNull())
1076 bool paramChanged =
false;
1078 QualType newParamType = recurse(paramType);
1079 if (newParamType.
isNull())
1083 paramChanged =
true;
1085 paramTypes.push_back(newParamType);
1090 bool exceptionChanged =
false;
1094 QualType newExceptionType = recurse(exceptionType);
1095 if (newExceptionType.
isNull())
1098 if (newExceptionType.
getAsOpaquePtr() != exceptionType.getAsOpaquePtr())
1099 exceptionChanged =
true;
1101 exceptionTypes.push_back(newExceptionType);
1104 if (exceptionChanged) {
1111 !paramChanged && !exceptionChanged)
1134 if (originalType.
isNull())
1138 if (adjustedType.
isNull())
1151 if (originalType.
isNull())
1173 if (modifiedType.
isNull())
1177 if (equivalentType.
isNull())
1192 if (replacementType.
isNull())
1212 if (deducedType.
isNull())
1231 bool typeArgChanged =
false;
1234 QualType newTypeArg = recurse(typeArg);
1239 typeArgChanged =
true;
1241 typeArgs.push_back(newTypeArg);
1258 if (pointeeType.
isNull())
1280#undef TRIVIAL_TYPE_CLASS
1281#undef SUGARED_TYPE_CLASS
1284struct SubstObjCTypeArgsVisitor
1285 :
public SimpleTransformVisitor<SubstObjCTypeArgsVisitor> {
1286 using BaseType = SimpleTransformVisitor<SubstObjCTypeArgsVisitor>;
1293 : BaseType(ctx), TypeArgs(typeArgs), SubstContext(context) {}
1300 if (!TypeArgs.empty()) {
1311 argType, protocolsToApply, hasError,
true);
1314 switch (SubstContext) {
1315 case ObjCSubstitutionContext::Ordinary:
1316 case ObjCSubstitutionContext::Parameter:
1317 case ObjCSubstitutionContext::Superclass:
1321 case ObjCSubstitutionContext::Result:
1322 case ObjCSubstitutionContext::Property: {
1324 const auto *objPtr =
1329 if (objPtr->isKindOfType() || objPtr->isObjCIdOrClassType())
1333 const auto *obj = objPtr->getObjectType();
1335 obj->getBaseType(), obj->getTypeArgsAsWritten(), obj->getProtocols(),
1342 llvm_unreachable(
"Unexpected ObjCSubstitutionContext!");
1351 Ctx, TypeArgs, ObjCSubstitutionContext::Result);
1357 if (isa<FunctionNoProtoType>(funcType)) {
1361 return BaseType::VisitFunctionType(funcType);
1367 const auto *funcProtoType = cast<FunctionProtoType>(funcType);
1371 bool paramChanged =
false;
1372 for (
auto paramType : funcProtoType->getParamTypes()) {
1374 Ctx, TypeArgs, ObjCSubstitutionContext::Parameter);
1375 if (newParamType.
isNull())
1379 paramChanged =
true;
1381 paramTypes.push_back(newParamType);
1386 bool exceptionChanged =
false;
1391 Ctx, TypeArgs, ObjCSubstitutionContext::Ordinary);
1392 if (newExceptionType.
isNull())
1395 if (newExceptionType.
getAsOpaquePtr() != exceptionType.getAsOpaquePtr())
1396 exceptionChanged =
true;
1398 exceptionTypes.push_back(newExceptionType);
1401 if (exceptionChanged) {
1408 funcProtoType->getReturnType().getAsOpaquePtr() &&
1409 !paramChanged && !exceptionChanged)
1410 return BaseType::VisitFunctionType(funcType);
1420 bool anyChanged =
false;
1423 Ctx, TypeArgs, ObjCSubstitutionContext::Ordinary);
1432 if (TypeArgs.empty() &&
1433 SubstContext != ObjCSubstitutionContext::Superclass) {
1442 newTypeArgs.push_back(newTypeArg);
1454 return BaseType::VisitObjCObjectType(objcObjectType);
1458 QualType newType = BaseType::VisitAttributedType(attrType);
1462 const auto *newAttrType = dyn_cast<AttributedType>(newType.
getTypePtr());
1463 if (!newAttrType || newAttrType->getAttrKind() != attr::ObjCKindOf)
1467 QualType newEquivType = newAttrType->getEquivalentType();
1479 objType->getBaseType(), objType->getTypeArgsAsWritten(),
1480 objType->getProtocols(),
1482 objType->isObjCUnqualifiedId() ?
false :
true);
1490 newAttrType->getModifiedType(), newEquivType);
1494struct StripObjCKindOfTypeVisitor
1495 :
public SimpleTransformVisitor<StripObjCKindOfTypeVisitor> {
1496 using BaseType = SimpleTransformVisitor<StripObjCKindOfTypeVisitor>;
1498 explicit StripObjCKindOfTypeVisitor(
ASTContext &ctx) : BaseType(ctx) {}
1502 return BaseType::VisitObjCObjectType(objType);
1523 case BuiltinType::Kind::Float16: {
1531 case BuiltinType::Kind::BFloat16: {
1551 SubstObjCTypeArgsVisitor visitor(ctx, typeArgs, context);
1552 return visitor.recurse(*
this);
1566 auto &ctx =
const_cast<ASTContext &
>(constCtx);
1567 StripObjCKindOfTypeVisitor visitor(ctx);
1568 return visitor.recurse(*
this);
1572 if (
const auto AT =
getTypePtr()->getAs<AtomicType>())
1573 return AT->getValueType().getUnqualifiedType();
1577std::optional<ArrayRef<QualType>>
1580 if (
const auto method = dyn_cast<ObjCMethodDecl>(dc))
1581 dc = method->getDeclContext();
1585 const auto *dcClassDecl = dyn_cast<ObjCInterfaceDecl>(dc);
1591 dcTypeParams = dcClassDecl->getTypeParamList();
1593 return std::nullopt;
1597 dcCategoryDecl = dyn_cast<ObjCCategoryDecl>(dc);
1598 if (!dcCategoryDecl)
1599 return std::nullopt;
1605 return std::nullopt;
1609 return std::nullopt;
1611 assert(dcTypeParams &&
"No substitutions to perform");
1612 assert(dcClassDecl &&
"No class context");
1616 if (
const auto *objectPointerType = getAs<ObjCObjectPointerType>()) {
1617 objectType = objectPointerType->getObjectType();
1618 }
else if (getAs<BlockPointerType>()) {
1623 objectType = getAs<ObjCObjectType>();
1629 if (!curClassDecl) {
1637 while (curClassDecl != dcClassDecl) {
1640 if (superType.
isNull()) {
1641 objectType =
nullptr;
1661 if (
auto *ID = IfaceT->getInterface()) {
1662 if (ID->getTypeParamList())
1676 CachedSuperClassType.setInt(
true);
1682 if (!superClassObjTy) {
1683 CachedSuperClassType.setInt(
true);
1688 if (!superClassDecl) {
1689 CachedSuperClassType.setInt(
true);
1695 QualType superClassType(superClassObjTy, 0);
1697 if (!superClassTypeParams) {
1698 CachedSuperClassType.setPointerAndInt(
1705 CachedSuperClassType.setPointerAndInt(superClassObjTy,
true);
1713 CachedSuperClassType.setPointerAndInt(
1724 CachedSuperClassType.setPointerAndInt(
1732 assert(typeArgs.size() == typeParams->
size());
1733 CachedSuperClassType.setPointerAndInt(
1742 return interfaceDecl->getASTContext().getObjCInterfaceType(interfaceDecl)
1751 if (superObjectType.
isNull())
1752 return superObjectType;
1762 if (
const auto *T = getAs<ObjCObjectType>())
1763 if (T->getNumProtocols() && T->getInterface())
1775 if (
const auto *OPT = getAs<ObjCObjectPointerType>()) {
1776 if (OPT->isObjCQualifiedIdType())
1785 if (
const auto *OPT = getAs<ObjCObjectPointerType>()) {
1786 if (OPT->isObjCQualifiedClassType())
1793 if (
const auto *OT = getAs<ObjCObjectType>()) {
1794 if (OT->getInterface())
1801 if (
const auto *OPT = getAs<ObjCObjectPointerType>()) {
1802 if (OPT->getInterfaceType())
1810 if (
const auto *PT = getAs<PointerType>())
1812 else if (
const auto *RT = getAs<ReferenceType>())
1818 return dyn_cast<CXXRecordDecl>(RT->getDecl());
1824 return dyn_cast_or_null<CXXRecordDecl>(
getAsTagDecl());
1832 if (
const auto *TT = getAs<TagType>())
1833 return TT->getDecl();
1834 if (
const auto *Injected = getAs<InjectedClassNameType>())
1835 return Injected->getDecl();
1841 const Type *Cur =
this;
1843 if (AT->getAttrKind() == AK)
1845 Cur = AT->getEquivalentType().getTypePtr();
1852 class GetContainedDeducedTypeVisitor :
1853 public TypeVisitor<GetContainedDeducedTypeVisitor, Type*> {
1857 GetContainedDeducedTypeVisitor(
bool Syntactic =
false)
1858 : Syntactic(Syntactic) {}
1902 Type *VisitDependentSizedExtVectorType(
1922 return VisitFunctionType(T);
1953 return cast_or_null<DeducedType>(
1954 GetContainedDeducedTypeVisitor().Visit(
this));
1958 return isa_and_nonnull<FunctionType>(
1959 GetContainedDeducedTypeVisitor(
true).Visit(
this));
1963 if (
const auto *VT = dyn_cast<VectorType>(CanonicalType))
1964 return VT->getElementType()->isIntegerType();
1965 if (CanonicalType->isSveVLSBuiltinType()) {
1966 const auto *VT = cast<BuiltinType>(CanonicalType);
1967 return VT->getKind() == BuiltinType::SveBool ||
1968 (VT->getKind() >= BuiltinType::SveInt8 &&
1969 VT->getKind() <= BuiltinType::SveUint64);
1971 if (CanonicalType->isRVVVLSBuiltinType()) {
1972 const auto *VT = cast<BuiltinType>(CanonicalType);
1973 return (VT->getKind() >= BuiltinType::RvvInt8mf8 &&
1974 VT->getKind() <= BuiltinType::RvvUint64m8);
2000 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
2001 return BT->getKind() >= BuiltinType::Bool &&
2002 BT->getKind() <= BuiltinType::Int128;
2006 if (
const auto *ET = dyn_cast<EnumType>(CanonicalType))
2007 return ET->getDecl()->isComplete();
2013 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
2014 return BT->getKind() >= BuiltinType::Bool &&
2015 BT->getKind() <= BuiltinType::Int128;
2024 if (
const auto *ET = dyn_cast<EnumType>(CanonicalType))
2025 return !ET->getDecl()->isScoped();
2031 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
2032 return BT->getKind() == BuiltinType::Char_U ||
2033 BT->getKind() == BuiltinType::UChar ||
2034 BT->getKind() == BuiltinType::Char_S ||
2035 BT->getKind() == BuiltinType::SChar;
2040 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
2041 return BT->getKind() == BuiltinType::WChar_S ||
2042 BT->getKind() == BuiltinType::WChar_U;
2047 if (
const BuiltinType *BT = dyn_cast<BuiltinType>(CanonicalType))
2048 return BT->getKind() == BuiltinType::Char8;
2053 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
2054 return BT->getKind() == BuiltinType::Char16;
2059 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
2060 return BT->getKind() == BuiltinType::Char32;
2067 const auto *BT = dyn_cast<BuiltinType>(CanonicalType);
2068 if (!BT)
return false;
2069 switch (BT->getKind()) {
2070 default:
return false;
2071 case BuiltinType::Char_U:
2072 case BuiltinType::UChar:
2073 case BuiltinType::WChar_U:
2074 case BuiltinType::Char8:
2075 case BuiltinType::Char16:
2076 case BuiltinType::Char32:
2077 case BuiltinType::Char_S:
2078 case BuiltinType::SChar:
2079 case BuiltinType::WChar_S:
2088 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType)) {
2089 return BT->getKind() >= BuiltinType::Char_S &&
2090 BT->getKind() <= BuiltinType::Int128;
2093 if (
const EnumType *ET = dyn_cast<EnumType>(CanonicalType)) {
2096 if (ET->getDecl()->isComplete() && !ET->getDecl()->isScoped())
2097 return ET->getDecl()->getIntegerType()->isSignedIntegerType();
2100 if (
const auto *IT = dyn_cast<BitIntType>(CanonicalType))
2101 return IT->isSigned();
2102 if (
const auto *IT = dyn_cast<DependentBitIntType>(CanonicalType))
2103 return IT->isSigned();
2109 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType)) {
2110 return BT->getKind() >= BuiltinType::Char_S &&
2111 BT->getKind() <= BuiltinType::Int128;
2114 if (
const auto *ET = dyn_cast<EnumType>(CanonicalType)) {
2115 if (ET->getDecl()->isComplete())
2116 return ET->getDecl()->getIntegerType()->isSignedIntegerType();
2119 if (
const auto *IT = dyn_cast<BitIntType>(CanonicalType))
2120 return IT->isSigned();
2121 if (
const auto *IT = dyn_cast<DependentBitIntType>(CanonicalType))
2122 return IT->isSigned();
2128 if (
const auto *VT = dyn_cast<VectorType>(CanonicalType))
2129 return VT->getElementType()->isSignedIntegerOrEnumerationType();
2138 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType)) {
2139 return BT->getKind() >= BuiltinType::Bool &&
2140 BT->getKind() <= BuiltinType::UInt128;
2143 if (
const auto *ET = dyn_cast<EnumType>(CanonicalType)) {
2146 if (ET->getDecl()->isComplete() && !ET->getDecl()->isScoped())
2147 return ET->getDecl()->getIntegerType()->isUnsignedIntegerType();
2150 if (
const auto *IT = dyn_cast<BitIntType>(CanonicalType))
2151 return IT->isUnsigned();
2152 if (
const auto *IT = dyn_cast<DependentBitIntType>(CanonicalType))
2153 return IT->isUnsigned();
2159 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType)) {
2160 return BT->getKind() >= BuiltinType::Bool &&
2161 BT->getKind() <= BuiltinType::UInt128;
2164 if (
const auto *ET = dyn_cast<EnumType>(CanonicalType)) {
2165 if (ET->getDecl()->isComplete())
2166 return ET->getDecl()->getIntegerType()->isUnsignedIntegerType();
2169 if (
const auto *IT = dyn_cast<BitIntType>(CanonicalType))
2170 return IT->isUnsigned();
2171 if (
const auto *IT = dyn_cast<DependentBitIntType>(CanonicalType))
2172 return IT->isUnsigned();
2178 if (
const auto *VT = dyn_cast<VectorType>(CanonicalType))
2179 return VT->getElementType()->isUnsignedIntegerOrEnumerationType();
2180 if (
const auto *VT = dyn_cast<MatrixType>(CanonicalType))
2181 return VT->getElementType()->isUnsignedIntegerOrEnumerationType();
2182 if (CanonicalType->isSveVLSBuiltinType()) {
2183 const auto *VT = cast<BuiltinType>(CanonicalType);
2184 return VT->getKind() >= BuiltinType::SveUint8 &&
2185 VT->getKind() <= BuiltinType::SveUint64;
2191 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
2192 return BT->getKind() >= BuiltinType::Half &&
2193 BT->getKind() <= BuiltinType::Ibm128;
2194 if (
const auto *CT = dyn_cast<ComplexType>(CanonicalType))
2195 return CT->getElementType()->isFloatingType();
2200 if (
const auto *VT = dyn_cast<VectorType>(CanonicalType))
2201 return VT->getElementType()->isFloatingType();
2202 if (
const auto *MT = dyn_cast<MatrixType>(CanonicalType))
2203 return MT->getElementType()->isFloatingType();
2208 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
2209 return BT->isFloatingPoint();
2214 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
2215 return BT->getKind() >= BuiltinType::Bool &&
2216 BT->getKind() <= BuiltinType::Ibm128;
2217 if (
const auto *ET = dyn_cast<EnumType>(CanonicalType))
2218 return ET->getDecl()->isComplete() && !ET->getDecl()->isScoped();
2223 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
2224 return BT->getKind() >= BuiltinType::Bool &&
2225 BT->getKind() <= BuiltinType::Ibm128;
2226 if (
const auto *ET = dyn_cast<EnumType>(CanonicalType))
2233 return !ET->getDecl()->isScoped() && ET->getDecl()->isComplete();
2234 return isa<ComplexType>(CanonicalType) ||
isBitIntType();
2240 const Type *T = CanonicalType.getTypePtr();
2241 if (
const auto *BT = dyn_cast<BuiltinType>(T)) {
2242 if (BT->getKind() == BuiltinType::Bool)
return STK_Bool;
2243 if (BT->getKind() == BuiltinType::NullPtr)
return STK_CPointer;
2247 llvm_unreachable(
"unknown scalar builtin type");
2248 }
else if (isa<PointerType>(T)) {
2250 }
else if (isa<BlockPointerType>(T)) {
2252 }
else if (isa<ObjCObjectPointerType>(T)) {
2254 }
else if (isa<MemberPointerType>(T)) {
2256 }
else if (isa<EnumType>(T)) {
2257 assert(cast<EnumType>(T)->getDecl()->isComplete());
2259 }
else if (
const auto *CT = dyn_cast<ComplexType>(T)) {
2260 if (CT->getElementType()->isRealFloatingType())
2267 llvm_unreachable(
"unknown scalar type");
2280 if (
const auto *Record = dyn_cast<RecordType>(CanonicalType)) {
2281 if (
const auto *ClassDecl = dyn_cast<CXXRecordDecl>(Record->getDecl()))
2282 return ClassDecl->isAggregate();
2287 return isa<ArrayType>(CanonicalType);
2294 assert(!
isIncompleteType() &&
"This doesn't make sense for incomplete types");
2295 assert(!
isDependentType() &&
"This doesn't make sense for dependent types");
2297 return !isa<VariableArrayType>(CanonicalType);
2307 switch (CanonicalType->getTypeClass()) {
2308 default:
return false;
2314 EnumDecl *EnumD = cast<EnumType>(CanonicalType)->getDecl();
2322 RecordDecl *Rec = cast<RecordType>(CanonicalType)->getDecl();
2333 return cast<ArrayType>(CanonicalType)->getElementType()
2334 ->isIncompleteType(Def);
2335 case IncompleteArray:
2338 case MemberPointer: {
2342 auto *MPTy = cast<MemberPointerType>(CanonicalType);
2343 const Type *ClassTy = MPTy->getClass();
2356 if (RD->
hasAttr<MSInheritanceAttr>())
2361 return cast<ObjCObjectType>(CanonicalType)->getBaseType()
2362 ->isIncompleteType(Def);
2363 case ObjCInterface: {
2366 = cast<ObjCInterfaceType>(CanonicalType)->getDecl();
2378 if (
const BuiltinType *BT = getAs<BuiltinType>()) {
2379 switch (BT->getKind()) {
2381#define WASM_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
2382#include "clang/Basic/WebAssemblyReferenceTypes.def"
2392 if (
const auto *BT = getAs<BuiltinType>())
2393 return BT->getKind() == BuiltinType::WasmExternRef;
2398 if (
const auto *ATy = dyn_cast<ArrayType>(
this))
2399 return ATy->getElementType().isWebAssemblyReferenceType();
2401 if (
const auto *PTy = dyn_cast<PointerType>(
this))
2402 return PTy->getPointeeType().isWebAssemblyReferenceType();
2410 if (
const BuiltinType *BT = getAs<BuiltinType>()) {
2411 switch (BT->getKind()) {
2413#define SVE_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
2414#include "clang/Basic/AArch64SVEACLETypes.def"
2424 if (
const BuiltinType *BT = getAs<BuiltinType>()) {
2425 switch (BT->getKind()) {
2426#define RVV_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
2427#include "clang/Basic/RISCVVTypes.def"
2437 if (
const BuiltinType *BT = getAs<BuiltinType>()) {
2438 switch (BT->getKind()) {
2439 case BuiltinType::SveInt8:
2440 case BuiltinType::SveInt16:
2441 case BuiltinType::SveInt32:
2442 case BuiltinType::SveInt64:
2443 case BuiltinType::SveUint8:
2444 case BuiltinType::SveUint16:
2445 case BuiltinType::SveUint32:
2446 case BuiltinType::SveUint64:
2447 case BuiltinType::SveFloat16:
2448 case BuiltinType::SveFloat32:
2449 case BuiltinType::SveFloat64:
2450 case BuiltinType::SveBFloat16:
2451 case BuiltinType::SveBool:
2452 case BuiltinType::SveBoolx2:
2453 case BuiltinType::SveBoolx4:
2466 if (BTy->
getKind() == BuiltinType::SveBool)
2476 if (
const BuiltinType *BT = getAs<BuiltinType>()) {
2477 switch (BT->getKind()) {
2478#define RVV_VECTOR_TYPE(Name, Id, SingletonId, NumEls, ElBits, NF, IsSigned, IsFP) \
2479 case BuiltinType::Id: \
2481#include "clang/Basic/RISCVVTypes.def"
2511 if ((*this)->isIncompleteArrayType())
2514 if ((*this)->isIncompleteType())
2523 default:
return false;
2524 case Type::VariableArray:
2525 case Type::ConstantArray:
2529 case Type::ObjCObjectPointer:
2530 case Type::BlockPointer:
2534 case Type::MemberPointer:
2536 case Type::ExtVector:
2544 if (
const auto *ClassDecl =
2545 dyn_cast<CXXRecordDecl>(cast<RecordType>(CanonicalType)->getDecl()))
2546 return ClassDecl->isPOD();
2560 if ((*this)->isArrayType())
2563 if ((*this)->isSizelessBuiltinType())
2568 if ((*this)->isIncompleteType())
2587 if (
const auto *ClassDecl = dyn_cast<CXXRecordDecl>(RT->getDecl())) {
2594 return ClassDecl->hasTrivialDefaultConstructor() &&
2595 !ClassDecl->hasNonTrivialDefaultConstructor() &&
2596 ClassDecl->isTriviallyCopyable();
2607 if ((*this)->isArrayType())
2635 if (
const auto *ClassDecl = dyn_cast<CXXRecordDecl>(RT->getDecl())) {
2636 if (!ClassDecl->isTriviallyCopyable())
return false;
2652 return RD->canPassInRegisters();
2667 if (
Decl->isUnion())
2670 auto IsDefaultedOperatorEqualEqual = [&](
const FunctionDecl *Function) {
2671 return Function->getOverloadedOperator() ==
2672 OverloadedOperatorKind::OO_EqualEqual &&
2673 Function->isDefaulted() && Function->getNumParams() > 0 &&
2674 (Function->getParamDecl(0)->getType()->isReferenceType() ||
2675 Decl->isTriviallyCopyable());
2678 if (llvm::none_of(
Decl->methods(), IsDefaultedOperatorEqualEqual) &&
2680 if (
NamedDecl *ND = Friend->getFriendDecl()) {
2682 IsDefaultedOperatorEqualEqual(ND->getAsFunction());
2688 return llvm::all_of(
Decl->bases(),
2690 if (const auto *RD = BS.getType()->getAsCXXRecordDecl())
2691 return HasNonDeletedDefaultedEqualityComparison(RD);
2695 auto Type = FD->getType();
2696 if (Type->isArrayType())
2697 Type = Type->getBaseElementTypeUnsafe()->getCanonicalTypeUnqualified();
2699 if (Type->isReferenceType() || Type->isEnumeralType())
2701 if (const auto *RD = Type->getAsCXXRecordDecl())
2702 return HasNonDeletedDefaultedEqualityComparison(RD);
2720 CanonicalType,
false);
2756 if (
const auto *RT =
2757 getTypePtr()->getBaseElementTypeUnsafe()->getAs<RecordType>())
2758 if (RT->getDecl()->isNonTrivialToPrimitiveDefaultInitialize())
2772 if (
const auto *RT =
2773 getTypePtr()->getBaseElementTypeUnsafe()->getAs<RecordType>())
2774 if (RT->getDecl()->isNonTrivialToPrimitiveCopy())
2810 assert(BaseTy &&
"NULL element type");
2840 if (
const auto *ClassDecl = dyn_cast<CXXRecordDecl>(RT->getDecl()))
2841 return ClassDecl->isLiteral();
2848 return AT->getValueType()->isLiteralType(Ctx);
2870 return RD->isStructural();
2883 assert(BaseTy &&
"NULL element type");
2893 if (
const auto *ClassDecl = dyn_cast<CXXRecordDecl>(RT->getDecl()))
2894 if (!ClassDecl->isStandardLayout())
2922 assert(BaseTy &&
"NULL element type");
2935 if (
const auto *ClassDecl = dyn_cast<CXXRecordDecl>(RT->getDecl())) {
2938 if (!ClassDecl->isTrivial())
return false;
2943 if (!ClassDecl->isStandardLayout())
return false;
2972 if (
const auto *ET = getAs<EnumType>()) {
2974 if (II && II->
isStr(
"align_val_t") && ET->getDecl()->isInStdNamespace())
2981 if (
const auto *ET = getAs<EnumType>()) {
2983 if (II && II->
isStr(
"byte") && ET->getDecl()->isInStdNamespace())
2999 case TemplateTypeParm:
3000 case SubstTemplateTypeParm:
3001 case TemplateSpecialization:
3004 case DependentTemplateSpecialization:
3036 llvm_unreachable(
"Type specifier is not a tag type kind.");
3048 llvm_unreachable(
"Unknown tag type kind.");
3061 llvm_unreachable(
"Elaborated type keyword is not a tag type kind.");
3063 llvm_unreachable(
"Unknown elaborated type keyword.");
3079 llvm_unreachable(
"Unknown elaborated type keyword.");
3093 llvm_unreachable(
"Unknown elaborated type keyword.");
3096DependentTemplateSpecializationType::DependentTemplateSpecializationType(
3103 NNS(NNS), Name(Name) {
3106 "DependentTemplateSpecializatonType requires dependent qualifier");
3107 auto *ArgBuffer =
const_cast<TemplateArgument *
>(template_arguments().data());
3110 TemplateArgumentDependence::UnexpandedPack));
3123 ID.AddInteger(Keyword);
3124 ID.AddPointer(Qualifier);
3125 ID.AddPointer(Name);
3127 Arg.Profile(ID, Context);
3132 if (
const auto *Elab = dyn_cast<ElaboratedType>(
this))
3133 Keyword = Elab->getKeyword();
3134 else if (
const auto *DepName = dyn_cast<DependentNameType>(
this))
3135 Keyword = DepName->getKeyword();
3136 else if (
const auto *DepTST =
3137 dyn_cast<DependentTemplateSpecializationType>(
this))
3138 Keyword = DepTST->getKeyword();
3147#define ABSTRACT_TYPE(Derived, Base)
3148#define TYPE(Derived, Base) case Derived: return #Derived;
3149#include "clang/AST/TypeNodes.inc"
3152 llvm_unreachable(
"Invalid type class.");
3160 return Policy.
Bool ?
"bool" :
"_Bool";
3166 return "signed char";
3178 return "unsigned char";
3180 return "unsigned short";
3182 return "unsigned int";
3184 return "unsigned long";
3186 return "unsigned long long";
3188 return "unsigned __int128";
3190 return Policy.
Half ?
"half" :
"__fp16";
3198 return "long double";
3200 return "short _Accum";
3204 return "long _Accum";
3206 return "unsigned short _Accum";
3208 return "unsigned _Accum";
3210 return "unsigned long _Accum";
3211 case BuiltinType::ShortFract:
3212 return "short _Fract";
3213 case BuiltinType::Fract:
3215 case BuiltinType::LongFract:
3216 return "long _Fract";
3217 case BuiltinType::UShortFract:
3218 return "unsigned short _Fract";
3219 case BuiltinType::UFract:
3220 return "unsigned _Fract";
3221 case BuiltinType::ULongFract:
3222 return "unsigned long _Fract";
3223 case BuiltinType::SatShortAccum:
3224 return "_Sat short _Accum";
3225 case BuiltinType::SatAccum:
3226 return "_Sat _Accum";
3227 case BuiltinType::SatLongAccum:
3228 return "_Sat long _Accum";
3229 case BuiltinType::SatUShortAccum:
3230 return "_Sat unsigned short _Accum";
3231 case BuiltinType::SatUAccum:
3232 return "_Sat unsigned _Accum";
3233 case BuiltinType::SatULongAccum:
3234 return "_Sat unsigned long _Accum";
3235 case BuiltinType::SatShortFract:
3236 return "_Sat short _Fract";
3237 case BuiltinType::SatFract:
3238 return "_Sat _Fract";
3239 case BuiltinType::SatLongFract:
3240 return "_Sat long _Fract";
3241 case BuiltinType::SatUShortFract:
3242 return "_Sat unsigned short _Fract";
3243 case BuiltinType::SatUFract:
3244 return "_Sat unsigned _Fract";
3245 case BuiltinType::SatULongFract:
3246 return "_Sat unsigned long _Fract";
3250 return "__float128";
3255 return Policy.
MSWChar ?
"__wchar_t" :
"wchar_t";
3265 return "<overloaded function type>";
3267 return "<bound member function type>";
3269 return "<pseudo-object type>";
3271 return "<dependent type>";
3273 return "<unknown type>";
3274 case ARCUnbridgedCast:
3275 return "<ARC unbridged cast type>";
3277 return "<builtin fn type>";
3284#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
3286 return "__" #Access " " #ImgType "_t";
3287#include "clang/Basic/OpenCLImageTypes.def"
3293 return "clk_event_t";
3297 return "reserve_id_t";
3298 case IncompleteMatrixIdx:
3299 return "<incomplete matrix index type>";
3300 case OMPArraySection:
3301 return "<OpenMP array section type>";
3302 case OMPArrayShaping:
3303 return "<OpenMP array shaping type>";
3305 return "<OpenMP iterator type>";
3306#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \
3309#include "clang/Basic/OpenCLExtensionTypes.def"
3310#define SVE_TYPE(Name, Id, SingletonId) \
3313#include "clang/Basic/AArch64SVEACLETypes.def"
3314#define PPC_VECTOR_TYPE(Name, Id, Size) \
3317#include "clang/Basic/PPCTypes.def"
3318#define RVV_TYPE(Name, Id, SingletonId) \
3321#include "clang/Basic/RISCVVTypes.def"
3322#define WASM_TYPE(Name, Id, SingletonId) \
3325#include "clang/Basic/WebAssemblyReferenceTypes.def"
3328 llvm_unreachable(
"Invalid builtin type.");
3333 if (
auto *PET = dyn_cast<PackExpansionType>(
getTypePtr()))
3334 return PET->getPattern();
3339 if (
const auto *RefType =
getTypePtr()->getAs<ReferenceType>())
3356 case CC_C:
return "cdecl";
3379 llvm_unreachable(
"Invalid calling convention.");
3384 const ExtProtoInfo &epi)
3385 :
FunctionType(FunctionProto, result, canonical, result->getDependence(),
3390 assert(getNumParams() == params.size() &&
"NumParams overflow!");
3396 if (epi.requiresFunctionProtoTypeExtraBitfields()) {
3398 auto &ExtraBits = *getTrailingObjects<FunctionTypeExtraBitfields>();
3399 ExtraBits = FunctionTypeExtraBitfields();
3406 auto *argSlot = getTrailingObjects<QualType>();
3407 for (
unsigned i = 0; i != getNumParams(); ++i) {
3409 ~TypeDependence::VariablyModified);
3410 argSlot[i] = params[i];
3415 auto &ExtraBits = *getTrailingObjects<FunctionTypeExtraBitfields>();
3417 "Not enough bits to encode SME attributes");
3418 ExtraBits.AArch64SMEAttributes = epi.AArch64SMEAttributes;
3423 auto &ExtraBits = *getTrailingObjects<FunctionTypeExtraBitfields>();
3424 size_t NumExceptions = epi.ExceptionSpec.Exceptions.size();
3425 assert(NumExceptions <= 1023 &&
"Not enough bits to encode exceptions");
3426 ExtraBits.NumExceptionType = NumExceptions;
3428 assert(hasExtraBitfields() &&
"missing trailing extra bitfields!");
3430 reinterpret_cast<QualType *
>(getTrailingObjects<ExceptionType>());
3432 for (
QualType ExceptionType : epi.ExceptionSpec.Exceptions) {
3438 (TypeDependence::Instantiation | TypeDependence::UnexpandedPack));
3440 exnSlot[I++] = ExceptionType;
3445 assert(epi.ExceptionSpec.NoexceptExpr &&
"computed noexcept with no expr");
3447 epi.ExceptionSpec.NoexceptExpr->isValueDependent());
3450 *getTrailingObjects<Expr *>() = epi.ExceptionSpec.NoexceptExpr;
3454 (TypeDependence::Instantiation | TypeDependence::UnexpandedPack));
3460 auto **slot = getTrailingObjects<FunctionDecl *>();
3461 slot[0] = epi.ExceptionSpec.SourceDecl;
3462 slot[1] = epi.ExceptionSpec.SourceTemplate;
3468 auto **slot = getTrailingObjects<FunctionDecl *>();
3469 slot[0] = epi.ExceptionSpec.SourceDecl;
3477 assert(hasDependentExceptionSpec() &&
"type should not be canonical");
3486 if (epi.ExtParameterInfos) {
3487 auto *extParamInfos = getTrailingObjects<ExtParameterInfo>();
3488 for (
unsigned i = 0; i != getNumParams(); ++i)
3489 extParamInfos[i] = epi.ExtParameterInfos[i];
3492 if (epi.TypeQuals.hasNonFastQualifiers()) {
3494 *getTrailingObjects<Qualifiers>() = epi.TypeQuals;
3501 auto &EllipsisLoc = *getTrailingObjects<SourceLocation>();
3502 EllipsisLoc = epi.EllipsisLoc;
3508 return NE->isValueDependent();
3520 return NE->isInstantiationDependent();
3522 if (ET->isInstantiationDependentType())
3531 llvm_unreachable(
"should not call this with unresolved exception specs");
3557 llvm_unreachable(
"unexpected exception specification kind");
3561 for (
unsigned ArgIdx =
getNumParams(); ArgIdx; --ArgIdx)
3569 const QualType *ArgTys,
unsigned NumParams,
3570 const ExtProtoInfo &epi,
3592 ID.AddPointer(
Result.getAsOpaquePtr());
3593 for (
unsigned i = 0; i != NumParams; ++i)
3594 ID.AddPointer(ArgTys[i].getAsOpaquePtr());
3598 assert(!(
unsigned(epi.Variadic) & ~1) &&
3599 !(
unsigned(epi.RefQualifier) & ~3) &&
3600 !(
unsigned(epi.ExceptionSpec.Type) & ~15) &&
3601 "Values larger than expected.");
3602 ID.AddInteger(
unsigned(epi.Variadic) +
3603 (epi.RefQualifier << 1) +
3604 (epi.ExceptionSpec.Type << 3));
3605 ID.Add(epi.TypeQuals);
3607 for (
QualType Ex : epi.ExceptionSpec.Exceptions)
3610 epi.ExceptionSpec.NoexceptExpr->Profile(ID, Context, Canonical);
3613 ID.AddPointer(epi.ExceptionSpec.SourceDecl->getCanonicalDecl());
3615 if (epi.ExtParameterInfos) {
3616 for (
unsigned i = 0; i != NumParams; ++i)
3617 ID.AddInteger(epi.ExtParameterInfos[i].getOpaqueValue());
3620 epi.ExtInfo.Profile(ID);
3621 ID.AddInteger((epi.AArch64SMEAttributes << 1) | epi.HasTrailingReturn);
3634 assert(!isa<TypedefType>(can) &&
"Invalid canonical type");
3636 if (!typeMatchesDecl())
3637 *getTrailingObjects<QualType>() = Underlying;
3642 : *getTrailingObjects<QualType>();
3651 *getTrailingObjects<QualType>() = Underlying;
3657 cast<TypeDecl>(Found->
getTargetDecl())->getTypeForDecl(), 0)
3658 : *getTrailingObjects<QualType>();
3667 while (
auto *InnerMQT = dyn_cast<MacroQualifiedType>(Inner)) {
3670 Inner = InnerMQT->getModifiedType();
3680 ? Can.getAtomicUnqualifiedType()
3683 (E->getType()->getDependence() &
3704 E->
Profile(ID, Context,
true);
3705 ID.AddBoolean(IsUnqual);
3712 :
Type(Decltype, can,
3716 (E->getType()->getDependence() &
3718 E(E), UnderlyingType(underlyingType) {}
3730 :
DecltypeType(E, Context.DependentTy), Context(Context) {}
3734 E->
Profile(ID, Context,
true);
3740 :
Type(UnaryTransform, CanonicalType, BaseType->getDependence()),
3741 BaseType(BaseType), UnderlyingType(UnderlyingType), UKind(UKind) {}
3755 for (
auto *I :
decl->redecls()) {
3756 if (I->isCompleteDefinition() || I->isBeingDefined())
3772 std::vector<const RecordType*> RecordTypeList;
3773 RecordTypeList.push_back(
this);
3774 unsigned NextToCheckIndex = 0;
3776 while (RecordTypeList.size() > NextToCheckIndex) {
3778 RecordTypeList[NextToCheckIndex]->
getDecl()->fields()) {
3784 if (!llvm::is_contained(RecordTypeList, FieldRecTy))
3785 RecordTypeList.push_back(FieldRecTy);
3800 case attr::ObjCOwnership:
3801 case attr::ObjCInertUnsafeUnretained:
3802 case attr::TypeNonNull:
3803 case attr::TypeNullable:
3804 case attr::TypeNullableResult:
3805 case attr::TypeNullUnspecified:
3806 case attr::LifetimeBound:
3807 case attr::AddressSpace:
3820 default:
return false;
3827 llvm_unreachable(
"invalid attr kind");
3837 default:
return false;
3840 case attr::FastCall:
3842 case attr::ThisCall:
3844 case attr::SwiftCall:
3845 case attr::SwiftAsyncCall:
3846 case attr::VectorCall:
3847 case attr::AArch64VectorPcs:
3848 case attr::AArch64SVEPcs:
3849 case attr::AMDGPUKernelCall:
3853 case attr::IntelOclBicc:
3854 case attr::PreserveMost:
3855 case attr::PreserveAll:
3858 llvm_unreachable(
"invalid attr kind");
3871 if (
const auto *TTP = dyn_cast<TemplateTypeParmDecl>(D))
3873 return cast<TemplateTypeParmDecl>(
3877SubstTemplateTypeParmType::SubstTemplateTypeParmType(
3878 QualType Replacement,
Decl *AssociatedDecl,
unsigned Index,
3879 std::optional<unsigned> PackIndex)
3880 :
Type(SubstTemplateTypeParm, Replacement.getCanonicalType(),
3881 Replacement->getDependence()),
3882 AssociatedDecl(AssociatedDecl) {
3883 SubstTemplateTypeParmTypeBits.HasNonCanonicalUnderlyingType =
3884 Replacement != getCanonicalTypeInternal();
3885 if (SubstTemplateTypeParmTypeBits.HasNonCanonicalUnderlyingType)
3886 *getTrailingObjects<QualType>() = Replacement;
3888 SubstTemplateTypeParmTypeBits.Index = Index;
3889 SubstTemplateTypeParmTypeBits.PackIndex = PackIndex ? *PackIndex + 1 : 0;
3890 assert(AssociatedDecl !=
nullptr);
3898SubstTemplateTypeParmPackType::SubstTemplateTypeParmPackType(
3899 QualType Canon,
Decl *AssociatedDecl,
unsigned Index,
bool Final,
3901 :
Type(SubstTemplateTypeParmPack, Canon,
3904 Arguments(ArgPack.pack_begin()),
3905 AssociatedDeclAndFinal(AssociatedDecl, Final) {
3908 assert(AssociatedDecl !=
nullptr);
3912 return AssociatedDeclAndFinal.getPointer();
3916 return AssociatedDeclAndFinal.getInt();
3937 const Decl *AssociatedDecl,
3938 unsigned Index,
bool Final,
3940 ID.AddPointer(AssociatedDecl);
3941 ID.AddInteger(Index);
3942 ID.AddBoolean(Final);
3945 ID.AddPointer(
P.getAsType().getAsOpaquePtr());
3956 if (Arg.isDependent())
3964 if (ArgLoc.getArgument().isInstantiationDependent())
3970TemplateSpecializationType::TemplateSpecializationType(
3973 :
Type(TemplateSpecialization, Canon.isNull() ?
QualType(this, 0) : Canon,
3984 "Use DependentTemplateSpecializationType for dependent template-name");
3989 "Unexpected template name for TemplateSpecializationType");
4002 ~TypeDependence::Dependent);
4005 TypeDependence::VariablyModified);
4012 *
reinterpret_cast<QualType *
>(
Begin + Args.size()) = AliasedType;
4017 assert(
isTypeAlias() &&
"not a type alias template specialization");
4035 Arg.Profile(ID, Context);
4060 ID.AddInteger(typeArgs.size());
4061 for (
auto typeArg : typeArgs)
4062 ID.AddPointer(typeArg.getAsOpaquePtr());
4063 ID.AddInteger(protocols.size());
4064 for (
auto *proto : protocols)
4065 ID.AddPointer(proto);
4066 ID.AddBoolean(isKindOf);
4079 ID.AddPointer(OTPDecl);
4081 ID.AddInteger(protocols.size());
4082 for (
auto *proto : protocols)
4083 ID.AddPointer(proto);
4094class CachedProperties {
4099 CachedProperties(
Linkage L,
bool local) : L(L), local(local) {}
4101 Linkage getLinkage()
const {
return L; }
4102 bool hasLocalOrUnnamedType()
const {
return local; }
4104 friend CachedProperties merge(CachedProperties L, CachedProperties R) {
4106 return CachedProperties(MergedLinkage, L.hasLocalOrUnnamedType() ||
4107 R.hasLocalOrUnnamedType());
4128 return CachedProperties(T->
TypeBits.getLinkage(),
4129 T->
TypeBits.hasLocalOrUnnamedType());
4134 if (T->
TypeBits.isCacheValid())
return;
4151 T->
TypeBits.CachedLocalOrUnnamed =
Result.hasLocalOrUnnamedType();
4170#define TYPE(Class,Base)
4171#define NON_CANONICAL_TYPE(Class,Base) case Type::Class:
4172#include "clang/AST/TypeNodes.inc"
4173 llvm_unreachable(
"didn't expect a non-canonical type here");
4175#define TYPE(Class,Base)
4176#define DEPENDENT_TYPE(Class,Base) case Type::Class:
4177#define NON_CANONICAL_UNLESS_DEPENDENT_TYPE(Class,Base) case Type::Class:
4178#include "clang/AST/TypeNodes.inc"
4185 case Type::DeducedTemplateSpecialization:
4199 const TagDecl *Tag = cast<TagType>(T)->getDecl();
4206 bool IsLocalOrUnnamed =
4209 return CachedProperties(L, IsLocalOrUnnamed);
4216 return Cache::get(cast<ComplexType>(T)->getElementType());
4218 return Cache::get(cast<PointerType>(T)->getPointeeType());
4219 case Type::BlockPointer:
4220 return Cache::get(cast<BlockPointerType>(T)->getPointeeType());
4221 case Type::LValueReference:
4222 case Type::RValueReference:
4223 return Cache::get(cast<ReferenceType>(T)->getPointeeType());
4224 case Type::MemberPointer: {
4225 const auto *MPT = cast<MemberPointerType>(T);
4229 case Type::ConstantArray:
4230 case Type::IncompleteArray:
4231 case Type::VariableArray:
4232 return Cache::get(cast<ArrayType>(T)->getElementType());
4234 case Type::ExtVector:
4235 return Cache::get(cast<VectorType>(T)->getElementType());
4236 case Type::ConstantMatrix:
4237 return Cache::get(cast<ConstantMatrixType>(T)->getElementType());
4238 case Type::FunctionNoProto:
4239 return Cache::get(cast<FunctionType>(T)->getReturnType());
4240 case Type::FunctionProto: {
4241 const auto *FPT = cast<FunctionProtoType>(T);
4242 CachedProperties result =
Cache::get(FPT->getReturnType());
4243 for (
const auto &ai : FPT->param_types())
4247 case Type::ObjCInterface: {
4248 Linkage L = cast<ObjCInterfaceType>(T)->getDecl()->getLinkageInternal();
4249 return CachedProperties(L,
false);
4251 case Type::ObjCObject:
4252 return Cache::get(cast<ObjCObjectType>(T)->getBaseType());
4253 case Type::ObjCObjectPointer:
4254 return Cache::get(cast<ObjCObjectPointerType>(T)->getPointeeType());
4256 return Cache::get(cast<AtomicType>(T)->getValueType());
4258 return Cache::get(cast<PipeType>(T)->getElementType());
4261 llvm_unreachable(
"unhandled type class");
4272 return TypeBits.hasLocalOrUnnamedType();
4277#define TYPE(Class,Base)
4278#define NON_CANONICAL_TYPE(Class,Base) case Type::Class:
4279#include "clang/AST/TypeNodes.inc"
4280 llvm_unreachable(
"didn't expect a non-canonical type here");
4282#define TYPE(Class,Base)
4283#define DEPENDENT_TYPE(Class,Base) case Type::Class:
4284#define NON_CANONICAL_UNLESS_DEPENDENT_TYPE(Class,Base) case Type::Class:
4285#include "clang/AST/TypeNodes.inc"
4295 case Type::DeducedTemplateSpecialization:
4306 case Type::BlockPointer:
4308 case Type::LValueReference:
4309 case Type::RValueReference:
4311 case Type::MemberPointer: {
4312 const auto *MPT = cast<MemberPointerType>(T);
4317 case Type::ConstantArray:
4318 case Type::IncompleteArray:
4319 case Type::VariableArray:
4322 case Type::ExtVector:
4324 case Type::ConstantMatrix:
4326 cast<ConstantMatrixType>(T)->getElementType());
4327 case Type::FunctionNoProto:
4329 case Type::FunctionProto: {
4330 const auto *FPT = cast<FunctionProtoType>(T);
4332 for (
const auto &ai : FPT->param_types())
4336 case Type::ObjCInterface:
4338 case Type::ObjCObject:
4340 case Type::ObjCObjectPointer:
4342 cast<ObjCObjectPointerType>(T)->getPointeeType());
4349 llvm_unreachable(
"unhandled type class");
4380 if (
auto Nullability = AT->getImmediateNullability())
4383 Type = AT->getEquivalentType();
4385 return std::nullopt;
4391 switch (
type->getTypeClass()) {
4393#define NON_CANONICAL_TYPE(Class, Parent) \
4395 llvm_unreachable("non-canonical type");
4396#define TYPE(Class, Parent)
4397#include "clang/AST/TypeNodes.inc"
4401 case Type::BlockPointer:
4402 case Type::MemberPointer:
4403 case Type::ObjCObjectPointer:
4407 case Type::UnresolvedUsing:
4408 case Type::TypeOfExpr:
4410 case Type::Decltype:
4411 case Type::UnaryTransform:
4412 case Type::TemplateTypeParm:
4413 case Type::SubstTemplateTypeParmPack:
4414 case Type::DependentName:
4415 case Type::DependentTemplateSpecialization:
4417 return ResultIfUnknown;
4422 case Type::TemplateSpecialization:
4424 = cast<TemplateSpecializationType>(
type.getTypePtr())
4425 ->getTemplateName().getAsTemplateDecl()) {
4426 if (isa<ClassTemplateDecl>(templateDecl))
4429 return ResultIfUnknown;
4432 switch (cast<BuiltinType>(
type.getTypePtr())->getKind()) {
4434#define SIGNED_TYPE(Id, SingletonId) case BuiltinType::Id:
4435#define UNSIGNED_TYPE(Id, SingletonId) case BuiltinType::Id:
4436#define FLOATING_TYPE(Id, SingletonId) case BuiltinType::Id:
4437#define BUILTIN_TYPE(Id, SingletonId)
4438#include "clang/AST/BuiltinTypes.def"
4442 case BuiltinType::Dependent:
4443 case BuiltinType::Overload:
4444 case BuiltinType::BoundMember:
4445 case BuiltinType::PseudoObject:
4446 case BuiltinType::UnknownAny:
4447 case BuiltinType::ARCUnbridgedCast:
4448 return ResultIfUnknown;
4450 case BuiltinType::Void:
4451 case BuiltinType::ObjCId:
4452 case BuiltinType::ObjCClass:
4453 case BuiltinType::ObjCSel:
4454#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
4455 case BuiltinType::Id:
4456#include "clang/Basic/OpenCLImageTypes.def"
4457#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \
4458 case BuiltinType::Id:
4459#include "clang/Basic/OpenCLExtensionTypes.def"
4460 case BuiltinType::OCLSampler:
4461 case BuiltinType::OCLEvent:
4462 case BuiltinType::OCLClkEvent:
4463 case BuiltinType::OCLQueue:
4464 case BuiltinType::OCLReserveID:
4465#define SVE_TYPE(Name, Id, SingletonId) \
4466 case BuiltinType::Id:
4467#include "clang/Basic/AArch64SVEACLETypes.def"
4468#define PPC_VECTOR_TYPE(Name, Id, Size) \
4469 case BuiltinType::Id:
4470#include "clang/Basic/PPCTypes.def"
4471#define RVV_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
4472#include "clang/Basic/RISCVVTypes.def"
4473#define WASM_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
4474#include "clang/Basic/WebAssemblyReferenceTypes.def"
4475 case BuiltinType::BuiltinFn:
4476 case BuiltinType::NullPtr:
4477 case BuiltinType::IncompleteMatrixIdx:
4478 case BuiltinType::OMPArraySection:
4479 case BuiltinType::OMPArrayShaping:
4480 case BuiltinType::OMPIterator:
4483 llvm_unreachable(
"unknown builtin type");
4487 case Type::LValueReference:
4488 case Type::RValueReference:
4489 case Type::ConstantArray:
4490 case Type::IncompleteArray:
4491 case Type::VariableArray:
4492 case Type::DependentSizedArray:
4493 case Type::DependentVector:
4494 case Type::DependentSizedExtVector:
4496 case Type::ExtVector:
4497 case Type::ConstantMatrix:
4498 case Type::DependentSizedMatrix:
4499 case Type::DependentAddressSpace:
4500 case Type::FunctionProto:
4501 case Type::FunctionNoProto:
4503 case Type::DeducedTemplateSpecialization:
4505 case Type::InjectedClassName:
4506 case Type::PackExpansion:
4507 case Type::ObjCObject:
4508 case Type::ObjCInterface:
4512 case Type::DependentBitInt:
4515 llvm_unreachable(
"bad type kind!");
4527 return std::nullopt;
4530std::optional<NullabilityKind>
4533 if (
auto MacroTy = dyn_cast<MacroQualifiedType>(T))
4534 AttrTy = MacroTy->getUnderlyingType();
4536 if (
auto attributed = dyn_cast<AttributedType>(AttrTy)) {
4537 if (
auto nullability = attributed->getImmediateNullability()) {
4538 T = attributed->getModifiedType();
4543 return std::nullopt;
4547 const auto *objcPtr = getAs<ObjCObjectPointerType>();
4551 if (objcPtr->isObjCIdType()) {
4562 }
else if (objcPtr->isObjCQualifiedIdType()) {
4587 "cannot query implicit lifetime for non-inferrable type");
4592 while (
const auto *array = dyn_cast<ArrayType>(canon))
4593 canon = array->getElementType().getTypePtr();
4595 if (
const auto *opt = dyn_cast<ObjCObjectPointerType>(canon)) {
4597 if (opt->getObjectType()->isObjCClass())
4605 if (
const auto *
typedefType = getAs<TypedefType>())
4606 return typedefType->getDecl()->hasAttr<ObjCNSObjectAttr>();
4611 if (
const auto *
typedefType = getAs<TypedefType>())
4612 return typedefType->getDecl()->hasAttr<ObjCIndependentClassAttr>();
4625 if (
const auto *OPT = getAs<PointerType>())
4626 return OPT->getPointeeType()->isObjCIndirectLifetimeType();
4627 if (
const auto *Ref = getAs<ReferenceType>())
4628 return Ref->getPointeeType()->isObjCIndirectLifetimeType();
4629 if (
const auto *MemPtr = getAs<MemberPointerType>())
4630 return MemPtr->getPointeeType()->isObjCIndirectLifetimeType();
4638 while (
const ArrayType *array =
type->getAsArrayTypeUnsafe())
4639 type = array->getElementType().getTypePtr();
4640 return type->isObjCRetainableType();
4651 const auto *
Pointer = getAs<PointerType>();
4661 if (
const auto *RT = getAs<RecordType>())
4662 return RT->getDecl()->hasAttr<CUDADeviceBuiltinSurfaceTypeAttr>();
4668 if (
const auto *RT = getAs<RecordType>())
4669 return RT->getDecl()->hasAttr<CUDADeviceBuiltinTextureTypeAttr>();
4676 if (
const auto *ptr = getAs<PointerType>())
4677 return ptr->getPointeeType()->hasSizedVLAType();
4678 if (
const auto *ref = getAs<ReferenceType>())
4679 return ref->getPointeeType()->hasSizedVLAType();
4681 if (isa<VariableArrayType>(arr) &&
4682 cast<VariableArrayType>(arr)->getSizeExpr())
4685 return arr->getElementType()->hasSizedVLAType();
4692 switch (
type.getObjCLifetime()) {
4704 if (
const auto *RT =
4707 if (
const auto *CXXRD = dyn_cast<CXXRecordDecl>(RD)) {
4709 if (CXXRD->hasDefinition() && !CXXRD->hasTrivialDestructor())
4727 llvm::APSInt Val,
unsigned Scale) {
4728 llvm::FixedPointSemantics FXSema(Val.getBitWidth(), Scale, Val.isSigned(),
4731 llvm::APFixedPoint(Val, FXSema).toString(Str);
4739 AutoTypeBits.Keyword = (
unsigned)Keyword;
4740 AutoTypeBits.NumArgs = TypeConstraintArgs.size();
4741 this->TypeConstraintConcept = TypeConstraintConcept;
4742 assert(TypeConstraintConcept || AutoTypeBits.NumArgs == 0);
4743 if (TypeConstraintConcept) {
4762 ID.AddInteger((
unsigned)Keyword);
4763 ID.AddBoolean(IsDependent);
4766 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