41#include "llvm/ADT/APInt.h"
42#include "llvm/ADT/APSInt.h"
43#include "llvm/ADT/ArrayRef.h"
44#include "llvm/ADT/FoldingSet.h"
45#include "llvm/ADT/STLExtras.h"
46#include "llvm/ADT/SmallVector.h"
47#include "llvm/Support/ErrorHandling.h"
48#include "llvm/Support/MathExtras.h"
58 return (*
this !=
Other) &&
114 if (
const auto *DNT = ty->
getAs<DependentNameType>())
118 if (
const auto *TT = ty->
getAs<TagType>())
143 if (T.isConstQualified())
147 return AT->getElementType().isConstant(Ctx);
152std::optional<QualType::NonConstantStorageReason>
155 if (!
isConstant(Ctx) && !(*this)->isReferenceType())
163 if (
Record->hasMutableFields())
165 if (!
Record->hasTrivialDestructor() && !ExcludeDtor)
191 (tc == DependentSizedArray
201 const llvm::APInt &Sz,
const Expr *SzExpr,
203 bool NeedsExternalSize = SzExpr !=
nullptr || Sz.ugt(0x0FFFFFFFFFFFFFFF) ||
204 Sz.getBitWidth() > 0xFF;
205 if (!NeedsExternalSize)
207 ET, Can, Sz.getBitWidth(), Sz.getZExtValue(), SzMod, Qual);
209 auto *SzPtr =
new (Ctx,
alignof(ConstantArrayType::ExternalSize))
210 ConstantArrayType::ExternalSize(Sz, SzExpr);
218 const llvm::APInt &NumElements) {
219 uint64_t ElementSize = Context.getTypeSizeInChars(ElementType).getQuantity();
227 if (llvm::isPowerOf2_64(ElementSize)) {
228 return NumElements.getActiveBits() + llvm::Log2_64(ElementSize);
233 if ((ElementSize >> 32) == 0 && NumElements.getBitWidth() <= 64 &&
234 (NumElements.getZExtValue() >> 32) == 0) {
235 uint64_t TotalSize = NumElements.getZExtValue() * ElementSize;
236 return llvm::bit_width(TotalSize);
240 llvm::APSInt SizeExtended(NumElements,
true);
241 unsigned SizeTypeBits = Context.getTypeSize(Context.getSizeType());
242 SizeExtended = SizeExtended.extend(
243 std::max(SizeTypeBits, SizeExtended.getBitWidth()) * 2);
245 llvm::APSInt TotalSize(llvm::APInt(SizeExtended.getBitWidth(), ElementSize));
246 TotalSize *= SizeExtended;
248 return TotalSize.getActiveBits();
257 unsigned Bits = Context.getTypeSize(Context.getSizeType());
270 uint64_t ArraySize,
const Expr *SizeExpr,
273 ID.AddInteger(ArraySize);
274 ID.AddInteger(llvm::to_underlying(SizeMod));
275 ID.AddInteger(TypeQuals);
276 ID.AddBoolean(SizeExpr !=
nullptr);
278 SizeExpr->
Profile(ID, Context,
true);
290 :
ArrayType(DependentSizedArray, et, can, sm, tq, e), SizeExpr((
Stmt *)e) {}
295 unsigned TypeQuals,
Expr *E) {
297 ID.AddInteger(llvm::to_underlying(SizeMod));
298 ID.AddInteger(TypeQuals);
303DependentVectorType::DependentVectorType(
QualType ElementType,
306 :
Type(DependentVector, CanonType,
308 ElementType->getDependence() |
311 ElementType(ElementType), SizeExpr(SizeExpr), Loc(Loc) {
319 ID.AddPointer(ElementType.getAsOpaquePtr());
320 ID.AddInteger(llvm::to_underlying(VecKind));
321 SizeExpr->Profile(ID, Context,
true);
324DependentSizedExtVectorType::DependentSizedExtVectorType(
QualType ElementType,
328 :
Type(DependentSizedExtVector, can,
330 ElementType->getDependence() |
333 SizeExpr(SizeExpr), ElementType(ElementType), loc(loc) {}
339 ID.AddPointer(ElementType.getAsOpaquePtr());
340 SizeExpr->Profile(ID, Context,
true);
343DependentAddressSpaceType::DependentAddressSpaceType(
QualType PointeeType,
347 :
Type(DependentAddressSpace, can,
349 PointeeType->getDependence() |
352 AddrSpaceExpr(AddrSpaceExpr), PointeeType(PointeeType), loc(loc) {}
357 Expr *AddrSpaceExpr) {
358 ID.AddPointer(PointeeType.getAsOpaquePtr());
359 AddrSpaceExpr->Profile(ID, Context,
true);
363 const Expr *RowExpr,
const Expr *ColumnExpr)
364 :
Type(tc, canonType,
381 unsigned nColumns,
QualType canonType)
386 unsigned nRows,
unsigned nColumns,
391DependentSizedMatrixType::DependentSizedMatrixType(
QualType ElementType,
396 :
MatrixType(DependentSizedMatrix, ElementType, CanonicalType, RowExpr,
398 RowExpr(RowExpr), ColumnExpr(ColumnExpr), loc(loc) {}
405 RowExpr->Profile(ID, CTX,
true);
406 ColumnExpr->Profile(ID, CTX,
true);
433 ExprAndUnsigned(NumBitsExpr, IsUnsigned) {}
436 return ExprAndUnsigned.getInt();
440 return ExprAndUnsigned.getPointer();
446 ID.AddBoolean(IsUnsigned);
447 NumBitsExpr->
Profile(ID, Context,
true);
459 bool CountInBytes,
bool OrNull) {
460 ID.AddPointer(WrappedTy.getAsOpaquePtr());
461 ID.AddBoolean(CountInBytes);
462 ID.AddBoolean(OrNull);
467 ID.AddPointer(CountExpr);
475 if (
const auto *ATy = dyn_cast<ArrayType>(
this))
476 return ATy->getElementType().getTypePtr();
504 return Context.getQualifiedType(desugar,
split.
Quals);
510#define TYPE(CLASS, BASE) \
511 static_assert(!std::is_polymorphic<CLASS##Type>::value, \
512 #CLASS "Type should not be polymorphic!");
513#include "clang/AST/TypeNodes.inc"
518#define TYPE(CLASS, BASE) \
519 static_assert(std::is_trivially_destructible<CLASS##Type>::value, \
520 #CLASS "Type should be trivially destructible!");
521#include "clang/AST/TypeNodes.inc"
525#define ABSTRACT_TYPE(Class, Parent)
526#define TYPE(Class, Parent) \
527 case Type::Class: { \
528 const auto *ty = cast<Class##Type>(this); \
529 if (!ty->isSugared()) \
530 return QualType(ty, 0); \
531 return ty->desugar(); \
533#include "clang/AST/TypeNodes.inc"
535 llvm_unreachable(
"bad type kind!");
545#define ABSTRACT_TYPE(Class, Parent)
546#define TYPE(Class, Parent) \
547 case Type::Class: { \
548 const auto *Ty = cast<Class##Type>(CurTy); \
549 if (!Ty->isSugared()) \
550 return SplitQualType(Ty, Qs); \
551 Cur = Ty->desugar(); \
554#include "clang/AST/TypeNodes.inc"
563 Qualifiers quals =
split.Quals;
566 const Type *lastTypeWithQuals =
split.Ty;
573 switch (
split.Ty->getTypeClass()) {
574#define ABSTRACT_TYPE(Class, Parent)
575#define TYPE(Class, Parent) \
576 case Type::Class: { \
577 const auto *ty = cast<Class##Type>(split.Ty); \
578 if (!ty->isSugared()) \
580 next = ty->desugar(); \
583#include "clang/AST/TypeNodes.inc"
589 if (!
split.Quals.empty()) {
590 lastTypeWithQuals =
split.Ty;
596 return SplitQualType(lastTypeWithQuals, quals);
601 while (
const auto *PT = T->
getAs<ParenType>())
602 T = PT->getInnerType();
611 if (
const auto *Sugar = dyn_cast<T>(Cur))
614#define ABSTRACT_TYPE(Class, Parent)
615#define TYPE(Class, Parent) \
616 case Type::Class: { \
617 const auto *Ty = cast<Class##Type>(Cur); \
618 if (!Ty->isSugared()) \
620 Cur = Ty->desugar().getTypePtr(); \
623#include "clang/AST/TypeNodes.inc"
636template <>
const TemplateSpecializationType *
Type::getAs()
const {
656 const Type *Cur =
this;
660#define ABSTRACT_TYPE(Class, Parent)
661#define TYPE(Class, Parent) \
663 const auto *Ty = cast<Class##Type>(Cur); \
664 if (!Ty->isSugared()) \
666 Cur = Ty->desugar().getTypePtr(); \
669#include "clang/AST/TypeNodes.inc"
676 return RT->getDecl()->isClass();
682 return RT->getDecl()->isStruct();
690 const auto *
Decl = RT->getDecl();
691 if (!
Decl->isStruct())
693 return Decl->getDefinitionOrSelf()->hasFlexibleArrayMember();
698 return RD->hasAttr<ObjCBoxableAttr>();
704 return RT->getDecl()->isInterface();
710 return RT->getDecl()->isStructureOrClass();
716 return PT->getPointeeType()->isVoidType();
722 return RT->getDecl()->isUnion();
728 return CT->getElementType()->isFloatingType();
739 return ET->getDecl()->isScoped();
749 if (
Complex->getElementType()->isIntegerType())
772 if (
const auto *RT = dyn_cast<RecordType>(
this)) {
773 if (RT->getDecl()->isStruct())
778 if (
const auto *RT = dyn_cast<RecordType>(CanonicalType)) {
779 if (!RT->getDecl()->isStruct())
791 if (
const auto *RT = dyn_cast<RecordType>(
this)) {
792 if (RT->getDecl()->isUnion())
797 if (
const auto *RT = dyn_cast<RecordType>(CanonicalType)) {
798 if (!RT->getDecl()->isUnion())
818 if (OPT->isObjCIdType())
822 if (!OPT->isKindOfType())
826 if (OPT->isObjCClassType() || OPT->isObjCQualifiedClassType())
830 bound = OPT->getObjectType()
831 ->stripObjCKindOfTypeAndQuals(ctx)
842 if (OPT->isObjCClassType())
846 if (!OPT->isKindOfType())
850 return OPT->isObjCClassType() || OPT->isObjCQualifiedClassType();
864 :
Type(ObjCObject, Canonical,
Base->getDependence()), BaseType(
Base) {
868 assert(getTypeArgsAsWritten().size() == typeArgs.size() &&
869 "bitfield overflow in type argument count");
870 if (!typeArgs.empty())
871 memcpy(getTypeArgStorage(), typeArgs.data(),
872 typeArgs.size() *
sizeof(
QualType));
874 for (
auto typeArg : typeArgs) {
875 addDependence(typeArg->getDependence() & ~TypeDependence::VariablyModified);
882bool ObjCObjectType::isSpecialized()
const {
884 if (ObjCObjectTypeBits.NumTypeArgs > 0)
888 if (
const auto objcObject =
getBaseType()->getAs<ObjCObjectType>()) {
893 return objcObject->isSpecialized();
902 if (isSpecializedAsWritten())
903 return getTypeArgsAsWritten();
906 if (
const auto objcObject =
getBaseType()->getAs<ObjCObjectType>()) {
911 return objcObject->getTypeArgs();
918bool ObjCObjectType::isKindOfType()
const {
919 if (isKindOfTypeAsWritten())
923 if (
const auto objcObject =
getBaseType()->getAs<ObjCObjectType>()) {
928 return objcObject->isKindOfType();
936ObjCObjectType::stripObjCKindOfTypeAndQuals(
const ASTContext &ctx)
const {
937 if (!isKindOfType() && qual_empty())
943 if (
const auto *baseObj = splitBaseType.
Ty->
getAs<ObjCObjectType>())
944 baseType = baseObj->stripObjCKindOfTypeAndQuals(ctx);
948 getTypeArgsAsWritten(),
973template <
typename Derived>
974struct SimpleTransformVisitor :
public TypeVisitor<Derived, QualType> {
982 QualType result =
static_cast<Derived *
>(
this)->Visit(splitType.
Ty);
992 explicit SimpleTransformVisitor(
ASTContext &ctx) : Ctx(ctx) {}
996#define TYPE(Class, Base)
997#define DEPENDENT_TYPE(Class, Base) \
998 QualType Visit##Class##Type(const Class##Type *T) { return QualType(T, 0); }
999#include "clang/AST/TypeNodes.inc"
1001#define TRIVIAL_TYPE_CLASS(Class) \
1002 QualType Visit##Class##Type(const Class##Type *T) { return QualType(T, 0); }
1003#define SUGARED_TYPE_CLASS(Class) \
1004 QualType Visit##Class##Type(const Class##Type *T) { \
1005 if (!T->isSugared()) \
1006 return QualType(T, 0); \
1007 QualType desugaredType = recurse(T->desugar()); \
1008 if (desugaredType.isNull()) \
1010 if (desugaredType.getAsOpaquePtr() == T->desugar().getAsOpaquePtr()) \
1011 return QualType(T, 0); \
1012 return desugaredType; \
1018 QualType elementType = recurse(T->getElementType());
1019 if (elementType.
isNull())
1022 if (elementType.
getAsOpaquePtr() == T->getElementType().getAsOpaquePtr())
1028 QualType VisitPointerType(
const PointerType *T) {
1030 if (pointeeType.
isNull())
1034 return QualType(T, 0);
1039 QualType VisitBlockPointerType(
const BlockPointerType *T) {
1041 if (pointeeType.
isNull())
1045 return QualType(T, 0);
1050 QualType VisitLValueReferenceType(
const LValueReferenceType *T) {
1052 if (pointeeType.
isNull())
1057 return QualType(T, 0);
1062 QualType VisitRValueReferenceType(
const RValueReferenceType *T) {
1064 if (pointeeType.
isNull())
1069 return QualType(T, 0);
1074 QualType VisitMemberPointerType(
const MemberPointerType *T) {
1076 if (pointeeType.
isNull())
1080 return QualType(T, 0);
1086 QualType VisitConstantArrayType(
const ConstantArrayType *T) {
1088 if (elementType.
isNull())
1092 return QualType(T, 0);
1099 QualType VisitVariableArrayType(
const VariableArrayType *T) {
1101 if (elementType.
isNull())
1105 return QualType(T, 0);
1112 QualType VisitIncompleteArrayType(
const IncompleteArrayType *T) {
1114 if (elementType.
isNull())
1118 return QualType(T, 0);
1124 QualType VisitVectorType(
const VectorType *T) {
1126 if (elementType.
isNull())
1130 return QualType(T, 0);
1136 QualType VisitExtVectorType(
const ExtVectorType *T) {
1138 if (elementType.
isNull())
1142 return QualType(T, 0);
1147 QualType VisitConstantMatrixType(
const ConstantMatrixType *T) {
1149 if (elementType.
isNull())
1152 return QualType(T, 0);
1158 QualType VisitOverflowBehaviorType(
const OverflowBehaviorType *T) {
1159 QualType UnderlyingType = recurse(T->getUnderlyingType());
1160 if (UnderlyingType.
isNull())
1164 T->getUnderlyingType().getAsOpaquePtr())
1165 return QualType(T, 0);
1170 QualType VisitFunctionNoProtoType(
const FunctionNoProtoType *T) {
1176 return QualType(T, 0);
1181 QualType VisitFunctionProtoType(
const FunctionProtoType *T) {
1187 SmallVector<QualType, 4> paramTypes;
1188 bool paramChanged =
false;
1190 QualType newParamType = recurse(paramType);
1191 if (newParamType.
isNull())
1195 paramChanged =
true;
1197 paramTypes.push_back(newParamType);
1202 bool exceptionChanged =
false;
1204 SmallVector<QualType, 4> exceptionTypes;
1206 QualType newExceptionType = recurse(exceptionType);
1207 if (newExceptionType.
isNull())
1210 if (newExceptionType.
getAsOpaquePtr() != exceptionType.getAsOpaquePtr())
1211 exceptionChanged =
true;
1213 exceptionTypes.push_back(newExceptionType);
1216 if (exceptionChanged) {
1218 llvm::ArrayRef(exceptionTypes).copy(Ctx);
1223 !paramChanged && !exceptionChanged)
1224 return QualType(T, 0);
1229 QualType VisitParenType(
const ParenType *T) {
1235 return QualType(T, 0);
1244 QualType VisitAdjustedType(
const AdjustedType *T) {
1246 if (originalType.
isNull())
1250 if (adjustedType.
isNull())
1256 return QualType(T, 0);
1261 QualType VisitDecayedType(
const DecayedType *T) {
1263 if (originalType.
isNull())
1267 return QualType(T, 0);
1272 QualType VisitArrayParameterType(
const ArrayParameterType *T) {
1273 QualType ArrTy = VisitConstantArrayType(T);
1287 QualType VisitAttributedType(
const AttributedType *T) {
1288 QualType modifiedType = recurse(T->getModifiedType());
1289 if (modifiedType.
isNull())
1292 QualType equivalentType = recurse(T->getEquivalentType());
1293 if (equivalentType.
isNull())
1297 T->getModifiedType().getAsOpaquePtr() &&
1299 T->getEquivalentType().getAsOpaquePtr())
1300 return QualType(T, 0);
1306 QualType VisitSubstTemplateTypeParmType(
const SubstTemplateTypeParmType *T) {
1307 QualType replacementType = recurse(T->getReplacementType());
1308 if (replacementType.
isNull())
1312 T->getReplacementType().getAsOpaquePtr())
1313 return QualType(T, 0);
1316 replacementType, T->getAssociatedDecl(), T->getIndex(),
1317 T->getPackIndex(), T->getFinal());
1323 QualType VisitAutoType(
const AutoType *T) {
1324 if (!T->isDeduced())
1325 return QualType(T, 0);
1327 QualType deducedType = recurse(T->getDeducedType());
1328 if (deducedType.
isNull())
1331 if (deducedType == T->getDeducedType())
1332 return QualType(T, 0);
1334 return Ctx.
getAutoType(T->getDeducedKind(), deducedType, T->getKeyword(),
1335 T->getTypeConstraintConcept(),
1336 T->getTypeConstraintArguments());
1339 QualType VisitObjCObjectType(
const ObjCObjectType *T) {
1340 QualType baseType = recurse(T->getBaseType());
1345 bool typeArgChanged =
false;
1346 SmallVector<QualType, 4> typeArgs;
1347 for (
auto typeArg : T->getTypeArgsAsWritten()) {
1348 QualType newTypeArg = recurse(typeArg);
1353 typeArgChanged =
true;
1355 typeArgs.push_back(newTypeArg);
1358 if (baseType.
getAsOpaquePtr() == T->getBaseType().getAsOpaquePtr() &&
1360 return QualType(T, 0);
1364 llvm::ArrayRef(T->qual_begin(), T->getNumProtocols()),
1365 T->isKindOfTypeAsWritten());
1370 QualType VisitObjCObjectPointerType(
const ObjCObjectPointerType *T) {
1372 if (pointeeType.
isNull())
1376 return QualType(T, 0);
1381 QualType VisitAtomicType(
const AtomicType *T) {
1387 return QualType(T, 0);
1392#undef TRIVIAL_TYPE_CLASS
1393#undef SUGARED_TYPE_CLASS
1396struct SubstObjCTypeArgsVisitor
1397 :
public SimpleTransformVisitor<SubstObjCTypeArgsVisitor> {
1398 using BaseType = SimpleTransformVisitor<SubstObjCTypeArgsVisitor>;
1400 ArrayRef<QualType> TypeArgs;
1403 SubstObjCTypeArgsVisitor(ASTContext &ctx, ArrayRef<QualType> typeArgs,
1405 : BaseType(ctx), TypeArgs(typeArgs), SubstContext(context) {}
1407 QualType VisitObjCTypeParamType(
const ObjCTypeParamType *OTPTy) {
1410 ObjCTypeParamDecl *typeParam = OTPTy->getDecl();
1412 if (!TypeArgs.empty()) {
1413 QualType argType = TypeArgs[typeParam->
getIndex()];
1414 if (OTPTy->qual_empty())
1419 SmallVector<ObjCProtocolDecl *, 8> protocolsVec;
1420 protocolsVec.append(OTPTy->qual_begin(), OTPTy->qual_end());
1421 ArrayRef<ObjCProtocolDecl *> protocolsToApply = protocolsVec;
1423 argType, protocolsToApply, hasError,
true );
1426 switch (SubstContext) {
1427 case ObjCSubstitutionContext::Ordinary:
1428 case ObjCSubstitutionContext::Parameter:
1429 case ObjCSubstitutionContext::Superclass:
1433 case ObjCSubstitutionContext::Result:
1434 case ObjCSubstitutionContext::Property: {
1436 const auto *objPtr =
1441 if (objPtr->isKindOfType() || objPtr->isObjCIdOrClassType())
1445 const auto *obj = objPtr->getObjectType();
1447 obj->getBaseType(), obj->getTypeArgsAsWritten(), obj->getProtocols(),
1454 llvm_unreachable(
"Unexpected ObjCSubstitutionContext!");
1457 QualType VisitFunctionType(
const FunctionType *funcType) {
1463 Ctx, TypeArgs, ObjCSubstitutionContext::Result);
1473 return BaseType::VisitFunctionType(funcType);
1482 SmallVector<QualType, 4> paramTypes;
1483 bool paramChanged =
false;
1484 for (
auto paramType : funcProtoType->getParamTypes()) {
1486 Ctx, TypeArgs, ObjCSubstitutionContext::Parameter);
1487 if (newParamType.
isNull())
1491 paramChanged =
true;
1493 paramTypes.push_back(newParamType);
1497 FunctionProtoType::ExtProtoInfo info = funcProtoType->getExtProtoInfo();
1498 bool exceptionChanged =
false;
1500 SmallVector<QualType, 4> exceptionTypes;
1503 Ctx, TypeArgs, ObjCSubstitutionContext::Ordinary);
1504 if (newExceptionType.
isNull())
1507 if (newExceptionType.
getAsOpaquePtr() != exceptionType.getAsOpaquePtr())
1508 exceptionChanged =
true;
1510 exceptionTypes.push_back(newExceptionType);
1513 if (exceptionChanged) {
1515 llvm::ArrayRef(exceptionTypes).copy(Ctx);
1520 funcProtoType->getReturnType().getAsOpaquePtr() &&
1521 !paramChanged && !exceptionChanged)
1522 return BaseType::VisitFunctionType(funcType);
1527 QualType VisitObjCObjectType(
const ObjCObjectType *objcObjectType) {
1530 if (objcObjectType->isSpecializedAsWritten()) {
1531 SmallVector<QualType, 4> newTypeArgs;
1532 bool anyChanged =
false;
1533 for (
auto typeArg : objcObjectType->getTypeArgsAsWritten()) {
1535 Ctx, TypeArgs, ObjCSubstitutionContext::Ordinary);
1542 ArrayRef<ObjCProtocolDecl *> protocols(
1543 objcObjectType->qual_begin(), objcObjectType->getNumProtocols());
1544 if (TypeArgs.empty() &&
1545 SubstContext != ObjCSubstitutionContext::Superclass) {
1547 objcObjectType->getBaseType(), {}, protocols,
1548 objcObjectType->isKindOfTypeAsWritten());
1554 newTypeArgs.push_back(newTypeArg);
1558 ArrayRef<ObjCProtocolDecl *> protocols(
1559 objcObjectType->qual_begin(), objcObjectType->getNumProtocols());
1562 objcObjectType->isKindOfTypeAsWritten());
1566 return BaseType::VisitObjCObjectType(objcObjectType);
1569 QualType VisitAttributedType(
const AttributedType *attrType) {
1570 QualType newType = BaseType::VisitAttributedType(attrType);
1574 const auto *newAttrType = dyn_cast<AttributedType>(newType.
getTypePtr());
1575 if (!newAttrType || newAttrType->getAttrKind() != attr::ObjCKindOf)
1579 QualType newEquivType = newAttrType->getEquivalentType();
1580 const ObjCObjectPointerType *ptrType =
1581 newEquivType->
getAs<ObjCObjectPointerType>();
1582 const ObjCObjectType *objType = ptrType
1584 : newEquivType->
getAs<ObjCObjectType>();
1591 objType->getBaseType(), objType->getTypeArgsAsWritten(),
1592 objType->getProtocols(),
1594 objType->isObjCUnqualifiedId() ?
false :
true);
1602 newAttrType->getModifiedType(), newEquivType,
1603 newAttrType->getAttr());
1607struct StripObjCKindOfTypeVisitor
1608 :
public SimpleTransformVisitor<StripObjCKindOfTypeVisitor> {
1609 using BaseType = SimpleTransformVisitor<StripObjCKindOfTypeVisitor>;
1611 explicit StripObjCKindOfTypeVisitor(ASTContext &ctx) : BaseType(ctx) {}
1613 QualType VisitObjCObjectType(
const ObjCObjectType *objType) {
1614 if (!objType->isKindOfType())
1615 return BaseType::VisitObjCObjectType(objType);
1617 QualType baseType = objType->getBaseType().stripObjCKindOfType(Ctx);
1619 objType->getProtocols(),
1636 case BuiltinType::Kind::Float16: {
1644 case BuiltinType::Kind::BFloat16: {
1664 SubstObjCTypeArgsVisitor visitor(ctx, typeArgs, context);
1665 return visitor.recurse(*
this);
1679 auto &ctx =
const_cast<ASTContext &
>(constCtx);
1680 StripObjCKindOfTypeVisitor visitor(ctx);
1681 return visitor.recurse(*
this);
1686 if (
const auto AT = T.getTypePtr()->getAs<
AtomicType>())
1687 T = AT->getValueType();
1688 return T.getUnqualifiedType();
1691std::optional<ArrayRef<QualType>>
1694 if (
const auto method = dyn_cast<ObjCMethodDecl>(dc))
1695 dc = method->getDeclContext();
1699 const auto *dcClassDecl = dyn_cast<ObjCInterfaceDecl>(dc);
1705 dcTypeParams = dcClassDecl->getTypeParamList();
1707 return std::nullopt;
1711 dcCategoryDecl = dyn_cast<ObjCCategoryDecl>(dc);
1712 if (!dcCategoryDecl)
1713 return std::nullopt;
1719 return std::nullopt;
1723 return std::nullopt;
1725 assert(dcTypeParams &&
"No substitutions to perform");
1726 assert(dcClassDecl &&
"No class context");
1731 objectType = objectPointerType->getObjectType();
1742 objectType ? objectType->getInterface() :
nullptr;
1743 if (!curClassDecl) {
1751 while (curClassDecl != dcClassDecl) {
1753 QualType superType = objectType->getSuperClassType();
1754 if (superType.
isNull()) {
1755 objectType =
nullptr;
1760 curClassDecl = objectType->getInterface();
1765 if (!objectType || objectType->isUnspecialized()) {
1770 return objectType->getTypeArgs();
1775 if (
auto *ID = IfaceT->getInterface()) {
1776 if (ID->getTypeParamList())
1784void ObjCObjectType::computeSuperClassTypeSlow()
const {
1790 CachedSuperClassType.setInt(
true);
1796 if (!superClassObjTy) {
1797 CachedSuperClassType.setInt(
true);
1802 if (!superClassDecl) {
1803 CachedSuperClassType.setInt(
true);
1809 QualType superClassType(superClassObjTy, 0);
1811 if (!superClassTypeParams) {
1812 CachedSuperClassType.setPointerAndInt(
1813 superClassType->castAs<ObjCObjectType>(),
true);
1818 if (superClassObjTy->isUnspecialized()) {
1819 CachedSuperClassType.setPointerAndInt(superClassObjTy,
true);
1827 CachedSuperClassType.setPointerAndInt(
1828 superClassType->castAs<ObjCObjectType>(),
true);
1834 if (isUnspecialized()) {
1837 superClassObjTy->getInterface());
1838 CachedSuperClassType.setPointerAndInt(
1839 unspecializedSuper->
castAs<ObjCObjectType>(),
true);
1845 assert(typeArgs.size() == typeParams->
size());
1846 CachedSuperClassType.setPointerAndInt(
1850 ->castAs<ObjCObjectType>(),
1856 return interfaceDecl->getASTContext()
1857 .getObjCInterfaceType(interfaceDecl)
1866 if (superObjectType.
isNull())
1867 return superObjectType;
1878 if (T->getNumProtocols() && T->getInterface())
1891 if (OPT->isObjCQualifiedIdType())
1901 if (OPT->isObjCQualifiedClassType())
1909 if (OT->getInterface())
1917 if (OPT->getInterfaceType())
1934const TemplateSpecializationType *
1937 while (TST && TST->isTypeAlias())
1938 TST = TST->desugar()->getAs<TemplateSpecializationType>();
1944 case Type::DependentName:
1946 case Type::TemplateSpecialization:
1952 case Type::InjectedClassName:
1956 case Type::UnresolvedUsing:
1961 return std::nullopt;
1966 const Type *Cur =
this;
1967 while (
const auto *AT = Cur->
getAs<AttributedType>()) {
1968 if (AT->getAttrKind() == AK)
1970 Cur = AT->getEquivalentType().getTypePtr();
1977class GetContainedDeducedTypeVisitor
1978 :
public TypeVisitor<GetContainedDeducedTypeVisitor, Type *> {
1982 GetContainedDeducedTypeVisitor(
bool Syntactic =
false)
1983 : Syntactic(Syntactic) {}
1990 return Visit(T.getTypePtr());
1994 Type *VisitDeducedType(
const DeducedType *AT) {
1995 return const_cast<DeducedType *
>(AT);
1999 Type *VisitSubstTemplateTypeParmType(
const SubstTemplateTypeParmType *T) {
2000 return Visit(T->getReplacementType());
2003 Type *VisitPointerType(
const PointerType *T) {
2007 Type *VisitBlockPointerType(
const BlockPointerType *T) {
2011 Type *VisitReferenceType(
const ReferenceType *T) {
2015 Type *VisitMemberPointerType(
const MemberPointerType *T) {
2019 Type *VisitArrayType(
const ArrayType *T) {
2023 Type *VisitDependentSizedExtVectorType(
const DependentSizedExtVectorType *T) {
2027 Type *VisitVectorType(
const VectorType *T) {
2031 Type *VisitDependentSizedMatrixType(
const DependentSizedMatrixType *T) {
2035 Type *VisitConstantMatrixType(
const ConstantMatrixType *T) {
2039 Type *VisitFunctionProtoType(
const FunctionProtoType *T) {
2041 return const_cast<FunctionProtoType *
>(T);
2042 return VisitFunctionType(T);
2045 Type *VisitFunctionType(
const FunctionType *T) {
2049 Type *VisitParenType(
const ParenType *T) {
return Visit(T->
getInnerType()); }
2051 Type *VisitAttributedType(
const AttributedType *T) {
2052 return Visit(T->getModifiedType());
2055 Type *VisitMacroQualifiedType(
const MacroQualifiedType *T) {
2059 Type *VisitOverflowBehaviorType(
const OverflowBehaviorType *T) {
2060 return Visit(T->getUnderlyingType());
2063 Type *VisitAdjustedType(
const AdjustedType *T) {
2067 Type *VisitPackExpansionType(
const PackExpansionType *T) {
2068 return Visit(T->getPattern());
2075 return cast_or_null<DeducedType>(
2076 GetContainedDeducedTypeVisitor().Visit(
this));
2080 return isa_and_nonnull<FunctionType>(
2081 GetContainedDeducedTypeVisitor(
true).Visit(
this));
2085 if (
const auto *VT = dyn_cast<VectorType>(CanonicalType))
2086 return VT->getElementType()->isIntegerType();
2087 if (CanonicalType->isSveVLSBuiltinType()) {
2089 return VT->getKind() == BuiltinType::SveBool ||
2090 (VT->getKind() >= BuiltinType::SveInt8 &&
2091 VT->getKind() <= BuiltinType::SveUint64);
2093 if (CanonicalType->isRVVVLSBuiltinType()) {
2095 return (VT->getKind() >= BuiltinType::RvvInt8mf8 &&
2096 VT->getKind() <= BuiltinType::RvvUint64m8);
2122 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
2123 return BT->isInteger();
2127 if (
const auto *ET = dyn_cast<EnumType>(CanonicalType))
2130 if (
const OverflowBehaviorType *OBT =
2131 dyn_cast<OverflowBehaviorType>(CanonicalType))
2132 return OBT->getUnderlyingType()->isIntegralOrEnumerationType();
2139 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
2140 return BT->isInteger();
2142 if (
const auto *OBT = dyn_cast<OverflowBehaviorType>(CanonicalType))
2143 return OBT->getUnderlyingType()->isIntegerType();
2152 if (
const auto *ET = dyn_cast<EnumType>(CanonicalType))
2153 return !ET->getDecl()->isScoped();
2159 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
2160 return BT->getKind() == BuiltinType::Char_U ||
2161 BT->getKind() == BuiltinType::UChar ||
2162 BT->getKind() == BuiltinType::Char_S ||
2163 BT->getKind() == BuiltinType::SChar;
2168 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
2169 return BT->getKind() == BuiltinType::WChar_S ||
2170 BT->getKind() == BuiltinType::WChar_U;
2175 if (
const BuiltinType *BT = dyn_cast<BuiltinType>(CanonicalType))
2176 return BT->getKind() == BuiltinType::Char8;
2181 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
2182 return BT->getKind() == BuiltinType::Char16;
2187 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
2188 return BT->getKind() == BuiltinType::Char32;
2195 const auto *BT = dyn_cast<BuiltinType>(CanonicalType);
2198 switch (BT->getKind()) {
2201 case BuiltinType::Char_U:
2202 case BuiltinType::UChar:
2203 case BuiltinType::WChar_U:
2204 case BuiltinType::Char8:
2205 case BuiltinType::Char16:
2206 case BuiltinType::Char32:
2207 case BuiltinType::Char_S:
2208 case BuiltinType::SChar:
2209 case BuiltinType::WChar_S:
2215 const auto *BT = dyn_cast<BuiltinType>(CanonicalType);
2218 switch (BT->getKind()) {
2221 case BuiltinType::Char8:
2222 case BuiltinType::Char16:
2223 case BuiltinType::Char32:
2232 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
2233 return BT->isSignedInteger();
2238 if (!ED->isComplete() || ED->isScoped())
2240 return ED->getIntegerType()->isSignedIntegerType();
2243 if (
const auto *IT = dyn_cast<BitIntType>(CanonicalType))
2244 return IT->isSigned();
2245 if (
const auto *IT = dyn_cast<DependentBitIntType>(CanonicalType))
2246 return IT->isSigned();
2248 if (
const auto *OBT = dyn_cast<OverflowBehaviorType>(CanonicalType))
2249 return OBT->getUnderlyingType()->isSignedIntegerType();
2255 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
2256 return BT->isSignedInteger();
2259 if (!ED->isComplete())
2261 return ED->getIntegerType()->isSignedIntegerType();
2264 if (
const auto *IT = dyn_cast<BitIntType>(CanonicalType))
2265 return IT->isSigned();
2266 if (
const auto *IT = dyn_cast<DependentBitIntType>(CanonicalType))
2267 return IT->isSigned();
2269 if (
const auto *OBT = dyn_cast<OverflowBehaviorType>(CanonicalType))
2270 return OBT->getUnderlyingType()->isSignedIntegerOrEnumerationType();
2276 if (
const auto *VT = dyn_cast<VectorType>(CanonicalType))
2277 return VT->getElementType()->isSignedIntegerOrEnumerationType();
2286 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
2287 return BT->isUnsignedInteger();
2292 if (!ED->isComplete() || ED->isScoped())
2294 return ED->getIntegerType()->isUnsignedIntegerType();
2297 if (
const auto *IT = dyn_cast<BitIntType>(CanonicalType))
2298 return IT->isUnsigned();
2299 if (
const auto *IT = dyn_cast<DependentBitIntType>(CanonicalType))
2300 return IT->isUnsigned();
2302 if (
const auto *OBT = dyn_cast<OverflowBehaviorType>(CanonicalType))
2303 return OBT->getUnderlyingType()->isUnsignedIntegerType();
2309 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
2310 return BT->isUnsignedInteger();
2313 if (!ED->isComplete())
2315 return ED->getIntegerType()->isUnsignedIntegerType();
2318 if (
const auto *IT = dyn_cast<BitIntType>(CanonicalType))
2319 return IT->isUnsigned();
2320 if (
const auto *IT = dyn_cast<DependentBitIntType>(CanonicalType))
2321 return IT->isUnsigned();
2323 if (
const auto *OBT = dyn_cast<OverflowBehaviorType>(CanonicalType))
2324 return OBT->getUnderlyingType()->isUnsignedIntegerOrEnumerationType();
2330 if (
const auto *VT = dyn_cast<VectorType>(CanonicalType))
2331 return VT->getElementType()->isUnsignedIntegerOrEnumerationType();
2332 if (
const auto *VT = dyn_cast<MatrixType>(CanonicalType))
2333 return VT->getElementType()->isUnsignedIntegerOrEnumerationType();
2334 if (CanonicalType->isSveVLSBuiltinType()) {
2336 return VT->getKind() >= BuiltinType::SveUint8 &&
2337 VT->getKind() <= BuiltinType::SveUint64;
2343 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
2344 return BT->isFloatingPoint();
2345 if (
const auto *CT = dyn_cast<ComplexType>(CanonicalType))
2346 return CT->getElementType()->isFloatingType();
2351 if (
const auto *VT = dyn_cast<VectorType>(CanonicalType))
2352 return VT->getElementType()->isFloatingType();
2353 if (
const auto *MT = dyn_cast<MatrixType>(CanonicalType))
2354 return MT->getElementType()->isFloatingType();
2359 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
2360 return BT->isFloatingPoint();
2365 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
2366 return BT->getKind() >= BuiltinType::Bool &&
2367 BT->getKind() <= BuiltinType::Ibm128;
2368 if (
const auto *ET = dyn_cast<EnumType>(CanonicalType)) {
2369 const auto *ED = ET->getDecl();
2370 return !ED->isScoped() && ED->getDefinitionOrSelf()->isComplete();
2376 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
2377 return BT->getKind() >= BuiltinType::Bool &&
2378 BT->getKind() <= BuiltinType::Ibm128;
2379 if (
const auto *ET = dyn_cast<EnumType>(CanonicalType)) {
2386 const auto *ED = ET->getDecl();
2387 return !ED->isScoped() && ED->getDefinitionOrSelf()->isComplete();
2398 if (
const auto *VT = dyn_cast<VectorType>(CanonicalType))
2399 return VT->getElementType()->isBooleanType();
2401 return ED->isComplete() && ED->getIntegerType()->isBooleanType();
2402 if (
const auto *IT = dyn_cast<BitIntType>(CanonicalType))
2403 return IT->getNumBits() == 1;
2410 const Type *T = CanonicalType.getTypePtr();
2411 if (
const auto *BT = dyn_cast<BuiltinType>(T)) {
2412 if (BT->getKind() == BuiltinType::Bool)
2414 if (BT->getKind() == BuiltinType::NullPtr)
2416 if (BT->isInteger())
2418 if (BT->isFloatingPoint())
2420 if (BT->isFixedPointType())
2422 llvm_unreachable(
"unknown scalar builtin type");
2432 assert(T->castAsEnumDecl()->isComplete());
2434 }
else if (
const auto *CT = dyn_cast<ComplexType>(T)) {
2435 if (CT->getElementType()->isRealFloatingType())
2444 llvm_unreachable(
"unknown scalar type");
2457 if (
const auto *
Record = dyn_cast<RecordType>(CanonicalType)) {
2458 if (
const auto *ClassDecl = dyn_cast<CXXRecordDecl>(
Record->getDecl()))
2459 return ClassDecl->isAggregate();
2471 assert(!
isIncompleteType() &&
"This doesn't make sense for incomplete types");
2472 assert(!
isDependentType() &&
"This doesn't make sense for dependent types");
2484 switch (CanonicalType->getTypeClass()) {
2495 return !EnumD->isComplete();
2503 return !Rec->isCompleteDefinition();
2505 case InjectedClassName: {
2507 if (!Rec->isBeingDefined())
2521 ->isIncompleteType(Def);
2522 case IncompleteArray:
2525 case MemberPointer: {
2538 if (!Context.getTargetInfo().getCXXABI().isMicrosoft())
2541 if (RD->
hasAttr<MSInheritanceAttr>())
2548 ->isIncompleteType(Def);
2549 case ObjCInterface: {
2581 switch (BT->getKind()) {
2583#define WASM_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
2584#include "clang/Basic/WebAssemblyReferenceTypes.def"
2586#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
2587#include "clang/Basic/HLSLIntangibleTypes.def"
2589 case BuiltinType::AMDGPUFeaturePredicate:
2600 return BT->getKind() == BuiltinType::WasmExternRef;
2605 if (
const auto *ATy = dyn_cast<ArrayType>(
this))
2606 return ATy->getElementType().isWebAssemblyReferenceType();
2608 if (
const auto *PTy = dyn_cast<PointerType>(
this))
2609 return PTy->getPointeeType().isWebAssemblyReferenceType();
2622 switch (BT->getKind()) {
2624#define SVE_VECTOR_TYPE(Name, MangledName, Id, SingletonId) \
2625 case BuiltinType::Id: \
2627#define SVE_OPAQUE_TYPE(Name, MangledName, Id, SingletonId) \
2628 case BuiltinType::Id: \
2630#define SVE_PREDICATE_TYPE(Name, MangledName, Id, SingletonId) \
2631 case BuiltinType::Id: \
2633#include "clang/Basic/AArch64ACLETypes.def"
2643 switch (BT->getKind()) {
2644#define RVV_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
2645#include "clang/Basic/RISCVVTypes.def"
2656 switch (BT->getKind()) {
2657 case BuiltinType::SveInt8:
2658 case BuiltinType::SveInt16:
2659 case BuiltinType::SveInt32:
2660 case BuiltinType::SveInt64:
2661 case BuiltinType::SveUint8:
2662 case BuiltinType::SveUint16:
2663 case BuiltinType::SveUint32:
2664 case BuiltinType::SveUint64:
2665 case BuiltinType::SveFloat16:
2666 case BuiltinType::SveFloat32:
2667 case BuiltinType::SveFloat64:
2668 case BuiltinType::SveBFloat16:
2669 case BuiltinType::SveBool:
2670 case BuiltinType::SveBoolx2:
2671 case BuiltinType::SveBoolx4:
2672 case BuiltinType::SveMFloat8:
2690 llvm_unreachable(
"Unhandled type");
2697 if (BTy->
getKind() == BuiltinType::SveBool)
2708 switch (BT->getKind()) {
2709#define RVV_VECTOR_TYPE(Name, Id, SingletonId, NumEls, ElBits, NF, IsSigned, \
2711 case BuiltinType::Id: \
2713#define RVV_PREDICATE_TYPE(Name, Id, SingletonId, NumEls) \
2714 case BuiltinType::Id: \
2716#include "clang/Basic/RISCVVTypes.def"
2730#define RVV_PREDICATE_TYPE(Name, Id, SingletonId, NumEls) \
2731 case BuiltinType::Id: \
2732 return Ctx.UnsignedCharTy;
2735#include "clang/Basic/RISCVVTypes.def"
2738 llvm_unreachable(
"Unhandled type");
2743 if (Context.getLangOpts().CPlusPlus11)
2756 if ((*this)->isIncompleteArrayType())
2757 return Context.getBaseElementType(*this).isCXX98PODType(Context);
2759 if ((*this)->isIncompleteType())
2768 if (Context.containsAddressDiscriminatedPointerAuth(CanonicalType))
2775 case Type::VariableArray:
2776 case Type::ConstantArray:
2778 return Context.getBaseElementType(*this).isCXX98PODType(Context);
2780 case Type::ObjCObjectPointer:
2781 case Type::BlockPointer:
2785 case Type::MemberPointer:
2787 case Type::ExtVector:
2789 case Type::OverflowBehavior:
2796 if (
const auto *ClassDecl =
2798 return ClassDecl->isPOD();
2812 if ((*this)->isArrayType())
2813 return Context.getBaseElementType(*this).isTrivialType(Context);
2815 if ((*this)->isSizelessBuiltinType())
2820 if ((*this)->isIncompleteType())
2832 if (Context.containsAddressDiscriminatedPointerAuth(CanonicalType))
2851 return ClassDecl->hasTrivialDefaultConstructor() &&
2852 !ClassDecl->hasNonTrivialDefaultConstructor() &&
2853 ClassDecl->isTriviallyCopyable();
2865 bool IsCopyConstructible) {
2866 if (
type->isArrayType())
2868 Context, IsCopyConstructible);
2870 if (
type.hasNonTrivialObjCLifetime())
2903 if (
const auto *ClassDecl = dyn_cast<CXXRecordDecl>(RD)) {
2904 if (IsCopyConstructible)
2905 return ClassDecl->isTriviallyCopyConstructible();
2906 return ClassDecl->isTriviallyCopyable();
2908 return !RD->isNonTrivialToPrimitiveCopy();
2922 if (CanonicalType.hasNonTrivialObjCLifetime())
2924 if (CanonicalType->isArrayType())
2925 return Context.getBaseElementType(CanonicalType)
2926 .isBitwiseCloneableType(Context);
2928 if (CanonicalType->isIncompleteType())
2933 if (Context.containsAddressDiscriminatedPointerAuth(CanonicalType))
2936 const auto *RD = CanonicalType->getAsRecordDecl();
2940 if (RD->isInvalidDecl())
2946 if (RD->mayInsertExtraPadding())
2949 for (
auto *
const Field : RD->fields()) {
2950 if (!Field->getType().isBitwiseCloneableType(Context))
2954 if (
const auto *CXXRD = dyn_cast<CXXRecordDecl>(RD)) {
2955 for (
auto Base : CXXRD->bases())
2956 if (!
Base.getType().isBitwiseCloneableType(Context))
2958 for (
auto VBase : CXXRD->vbases())
2959 if (!VBase.getType().isBitwiseCloneableType(Context))
2972 return !Context.getLangOpts().ObjCAutoRefCount &&
2973 Context.getLangOpts().ObjCWeak &&
3006 return OBT->getBehaviorKind() ==
3007 OverflowBehaviorType::OverflowBehaviorKind::Wrap;
3014 return OBT->getBehaviorKind() ==
3015 OverflowBehaviorType::OverflowBehaviorKind::Trap;
3022 if (
const auto *RD =
3038 if (
const auto *RD =
3078 assert(BaseTy &&
"NULL element type");
3112 if (
const auto *ClassDecl = dyn_cast<CXXRecordDecl>(RD))
3113 return ClassDecl->isLiteral();
3120 return AT->getValueType()->isLiteralType(Ctx);
3122 if (
const auto *OBT = BaseTy->
getAs<OverflowBehaviorType>())
3123 return OBT->getUnderlyingType()->isLiteralType(Ctx);
3145 return RD->isStructural();
3158 assert(BaseTy &&
"NULL element type");
3169 if (
const auto *ClassDecl = dyn_cast<CXXRecordDecl>(RD);
3170 ClassDecl && !ClassDecl->isStandardLayout())
3198 assert(BaseTy &&
"NULL element type");
3209 if (Context.containsAddressDiscriminatedPointerAuth(*
this))
3216 if (
const auto *ClassDecl = dyn_cast<CXXRecordDecl>(RD)) {
3219 if (!ClassDecl->isTrivial())
3225 if (!ClassDecl->isStandardLayout())
3256 const auto *ED = ET->getDecl();
3258 if (II && II->
isStr(
"align_val_t") && ED->isInStdNamespace())
3266 const auto *ED = ET->getDecl();
3268 if (II && II->
isStr(
"byte") && ED->isInStdNamespace())
3284 case TemplateTypeParm:
3285 case SubstTemplateTypeParm:
3286 case TemplateSpecialization:
3329 llvm_unreachable(
"Type specifier is not a tag type kind.");
3346 llvm_unreachable(
"Unknown tag type kind.");
3364 llvm_unreachable(
"Elaborated type keyword is not a tag type kind.");
3366 llvm_unreachable(
"Unknown elaborated type keyword.");
3381 llvm_unreachable(
"Unknown elaborated type keyword.");
3395 return "__interface";
3402 llvm_unreachable(
"Unknown elaborated type keyword.");
3407 if (
const auto *TST = dyn_cast<TemplateSpecializationType>(
this))
3409 else if (
const auto *DepName = dyn_cast<DependentNameType>(
this))
3410 Keyword = DepName->getKeyword();
3411 else if (
const auto *T = dyn_cast<TagType>(
this))
3413 else if (
const auto *T = dyn_cast<TypedefType>(
this))
3415 else if (
const auto *T = dyn_cast<UnresolvedUsingType>(
this))
3417 else if (
const auto *T = dyn_cast<UsingType>(
this))
3427#define ABSTRACT_TYPE(Derived, Base)
3428#define TYPE(Derived, Base) \
3431#include "clang/AST/TypeNodes.inc"
3434 llvm_unreachable(
"Invalid type class.");
3442 return Policy.
Bool ?
"bool" :
"_Bool";
3448 return "signed char";
3460 return "unsigned char";
3462 return "unsigned short";
3464 return "unsigned int";
3466 return "unsigned long";
3468 return "unsigned long long";
3470 return "unsigned __int128";
3472 return Policy.
Half ?
"half" :
"__fp16";
3480 return "long double";
3482 return "short _Accum";
3486 return "long _Accum";
3488 return "unsigned short _Accum";
3490 return "unsigned _Accum";
3492 return "unsigned long _Accum";
3493 case BuiltinType::ShortFract:
3494 return "short _Fract";
3495 case BuiltinType::Fract:
3497 case BuiltinType::LongFract:
3498 return "long _Fract";
3499 case BuiltinType::UShortFract:
3500 return "unsigned short _Fract";
3501 case BuiltinType::UFract:
3502 return "unsigned _Fract";
3503 case BuiltinType::ULongFract:
3504 return "unsigned long _Fract";
3505 case BuiltinType::SatShortAccum:
3506 return "_Sat short _Accum";
3507 case BuiltinType::SatAccum:
3508 return "_Sat _Accum";
3509 case BuiltinType::SatLongAccum:
3510 return "_Sat long _Accum";
3511 case BuiltinType::SatUShortAccum:
3512 return "_Sat unsigned short _Accum";
3513 case BuiltinType::SatUAccum:
3514 return "_Sat unsigned _Accum";
3515 case BuiltinType::SatULongAccum:
3516 return "_Sat unsigned long _Accum";
3517 case BuiltinType::SatShortFract:
3518 return "_Sat short _Fract";
3519 case BuiltinType::SatFract:
3520 return "_Sat _Fract";
3521 case BuiltinType::SatLongFract:
3522 return "_Sat long _Fract";
3523 case BuiltinType::SatUShortFract:
3524 return "_Sat unsigned short _Fract";
3525 case BuiltinType::SatUFract:
3526 return "_Sat unsigned _Fract";
3527 case BuiltinType::SatULongFract:
3528 return "_Sat unsigned long _Fract";
3532 return "__float128";
3537 return Policy.
MSWChar ?
"__wchar_t" :
"wchar_t";
3547 return "<overloaded function type>";
3549 return "<bound member function type>";
3550 case UnresolvedTemplate:
3551 return "<unresolved template type>";
3553 return "<pseudo-object type>";
3555 return "<dependent type>";
3557 return "<unknown type>";
3558 case ARCUnbridgedCast:
3559 return "<ARC unbridged cast type>";
3561 return "<builtin fn type>";
3568#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
3570 return "__" #Access " " #ImgType "_t";
3571#include "clang/Basic/OpenCLImageTypes.def"
3577 return "clk_event_t";
3581 return "reserve_id_t";
3582 case IncompleteMatrixIdx:
3583 return "<incomplete matrix index type>";
3585 return "<array section type>";
3586 case OMPArrayShaping:
3587 return "<OpenMP array shaping type>";
3589 return "<OpenMP iterator type>";
3590#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \
3593#include "clang/Basic/OpenCLExtensionTypes.def"
3594#define SVE_TYPE(Name, Id, SingletonId) \
3597#include "clang/Basic/AArch64ACLETypes.def"
3598#define PPC_VECTOR_TYPE(Name, Id, Size) \
3601#include "clang/Basic/PPCTypes.def"
3602#define RVV_TYPE(Name, Id, SingletonId) \
3605#include "clang/Basic/RISCVVTypes.def"
3606#define WASM_TYPE(Name, Id, SingletonId) \
3609#include "clang/Basic/WebAssemblyReferenceTypes.def"
3610#define AMDGPU_TYPE(Name, Id, SingletonId, Width, Align) \
3613#include "clang/Basic/AMDGPUTypes.def"
3614#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) \
3617#include "clang/Basic/HLSLIntangibleTypes.def"
3620 llvm_unreachable(
"Invalid builtin type.");
3625 if (
auto *PET = dyn_cast<PackExpansionType>(
getTypePtr()))
3626 return PET->getPattern();
3631 if (
const auto *RefType =
getTypePtr()->getAs<ReferenceType>())
3639 if (!Context.getLangOpts().CPlusPlus ||
3648 return FPT->hasCFIUncheckedCallee();
3665 return "vectorcall";
3677 return "aarch64_vector_pcs";
3679 return "aarch64_sve_pcs";
3681 return "intel_ocl_bicc";
3683 return "spir_function";
3685 return "device_kernel";
3689 return "swiftasynccall";
3691 return "preserve_most";
3693 return "preserve_all";
3697 return "preserve_none";
3700#define CC_VLS_CASE(ABI_VLEN) \
3701 case CC_RISCVVLSCall_##ABI_VLEN: return "riscv_vls_cc(" #ABI_VLEN ")";
3718 llvm_unreachable(
"Invalid calling convention.");
3736 assert(
getNumParams() == params.size() &&
"NumParams overflow!");
3745 auto &ExtraBits = *getTrailingObjects<FunctionTypeExtraBitfields>();
3753 auto &ExtraAttrInfo = *getTrailingObjects<FunctionTypeExtraAttributeInfo>();
3757 auto &ExtraBits = *getTrailingObjects<FunctionTypeExtraBitfields>();
3758 ExtraBits.HasExtraAttributeInfo =
true;
3762 auto &ArmTypeAttrs = *getTrailingObjects<FunctionTypeArmAttributes>();
3763 ArmTypeAttrs = FunctionTypeArmAttributes();
3766 auto &ExtraBits = *getTrailingObjects<FunctionTypeExtraBitfields>();
3767 ExtraBits.HasArmTypeAttributes =
true;
3771 auto *argSlot = getTrailingObjects<QualType>();
3774 ~TypeDependence::VariablyModified);
3775 argSlot[i] = params[i];
3780 auto &ArmTypeAttrs = *getTrailingObjects<FunctionTypeArmAttributes>();
3782 "Not enough bits to encode SME attributes");
3788 auto &ExtraBits = *getTrailingObjects<FunctionTypeExtraBitfields>();
3790 assert(NumExceptions <= 1023 &&
"Not enough bits to encode exceptions");
3791 ExtraBits.NumExceptionType = NumExceptions;
3793 assert(hasExtraBitfields() &&
"missing trailing extra bitfields!");
3795 reinterpret_cast<QualType *
>(getTrailingObjects<ExceptionType>());
3803 (TypeDependence::Instantiation | TypeDependence::UnexpandedPack));
3805 exnSlot[I++] = ExceptionType;
3819 (TypeDependence::Instantiation | TypeDependence::UnexpandedPack));
3825 auto **slot = getTrailingObjects<FunctionDecl *>();
3833 auto **slot = getTrailingObjects<FunctionDecl *>();
3852 auto *extParamInfos = getTrailingObjects<ExtParameterInfo>();
3859 *getTrailingObjects<Qualifiers>() = epi.
TypeQuals;
3866 auto &EllipsisLoc = *getTrailingObjects<SourceLocation>();
3871 auto &ExtraBits = *getTrailingObjects<FunctionTypeExtraBitfields>();
3873 ExtraBits.NumFunctionEffects = EffectsCount;
3874 assert(ExtraBits.NumFunctionEffects == EffectsCount &&
3875 "effect bitfield overflow");
3878 auto *DestFX = getTrailingObjects<FunctionEffect>();
3879 llvm::uninitialized_copy(SrcFX, DestFX);
3882 if (!SrcConds.empty()) {
3883 ExtraBits.EffectsHaveConditions =
true;
3884 auto *DestConds = getTrailingObjects<EffectConditionExpr>();
3885 llvm::uninitialized_copy(SrcConds, DestConds);
3886 assert(llvm::any_of(SrcConds,
3887 [](
const EffectConditionExpr &EC) {
3889 return E->isTypeDependent() ||
3890 E->isValueDependent();
3893 "expected a dependent expression among the conditions");
3901 return NE->isValueDependent();
3913 return NE->isInstantiationDependent();
3924 llvm_unreachable(
"should not call this with unresolved exception specs");
3950 llvm_unreachable(
"unexpected exception specification kind");
3954 for (
unsigned ArgIdx =
getNumParams(); ArgIdx; --ArgIdx)
3962 const QualType *ArgTys,
unsigned NumParams,
3963 const ExtProtoInfo &epi,
3987 ID.AddPointer(
Result.getAsOpaquePtr());
3988 for (
unsigned i = 0; i != NumParams; ++i)
3989 ID.AddPointer(ArgTys[i].getAsOpaquePtr());
3993 assert(!(
unsigned(epi.Variadic) & ~1) && !(
unsigned(epi.RefQualifier) & ~3) &&
3994 !(
unsigned(epi.ExceptionSpec.Type) & ~15) &&
3995 "Values larger than expected.");
3996 ID.AddInteger(
unsigned(epi.Variadic) + (epi.RefQualifier << 1) +
3997 (epi.ExceptionSpec.Type << 3));
3998 ID.Add(epi.TypeQuals);
4000 for (
QualType Ex : epi.ExceptionSpec.Exceptions)
4003 epi.ExceptionSpec.NoexceptExpr->Profile(ID, Context, Canonical);
4006 ID.AddPointer(epi.ExceptionSpec.SourceDecl->getCanonicalDecl());
4008 if (epi.ExtParameterInfos) {
4009 for (
unsigned i = 0; i != NumParams; ++i)
4010 ID.AddInteger(epi.ExtParameterInfos[i].getOpaqueValue());
4013 epi.ExtInfo.Profile(ID);
4014 epi.ExtraAttributeInfo.Profile(ID);
4016 unsigned EffectCount = epi.FunctionEffects.size();
4017 bool HasConds = !epi.FunctionEffects.Conditions.empty();
4019 ID.AddInteger((EffectCount << 3) | (HasConds << 2) |
4020 (epi.AArch64SMEAttributes << 1) | epi.HasTrailingReturn);
4021 ID.AddInteger(epi.CFIUncheckedCallee);
4023 for (
unsigned Idx = 0; Idx != EffectCount; ++Idx) {
4024 ID.AddInteger(epi.FunctionEffects.Effects[Idx].toOpaqueInt32());
4026 ID.AddPointer(epi.FunctionEffects.Conditions[Idx].getCondition());
4037 : Data(D, Deref << DerefShift) {}
4040 return Data.getInt() & DerefMask;
4045 return Data.getOpaqueValue();
4052 Data.setFromOpaqueValue(
V);
4055OverflowBehaviorType::OverflowBehaviorType(
4057 OverflowBehaviorType::OverflowBehaviorKind Kind)
4058 :
Type(OverflowBehavior, Canon, Underlying->getDependence()),
4059 UnderlyingType(Underlying), BehaviorKind(Kind) {}
4065CountAttributedType::CountAttributedType(
4069 CountExpr(CountExpr) {
4073 auto *DeclSlot = getTrailingObjects();
4074 llvm::copy(CoupledDecls, DeclSlot);
4083#define ENUMERATE_ATTRS(PREFIX) \
4085 if (isCountInBytes()) { \
4087 return PREFIX "sized_by_or_null"; \
4088 return PREFIX "sized_by"; \
4091 return PREFIX "counted_by_or_null"; \
4092 return PREFIX "counted_by"; \
4095 if (WithMacroPrefix)
4100#undef ENUMERATE_ATTRS
4106 bool HasTypeDifferentFromDecl)
4108 Keyword, TC, UnderlyingType.getCanonicalType(),
4112 ~NestedNameSpecifierDependence::
Dependent)
4116 *getTrailingObjects<NestedNameSpecifier>() = Qualifier;
4117 if ((
TypedefBits.hasTypeDifferentFromDecl = HasTypeDifferentFromDecl))
4118 *getTrailingObjects<QualType>() = UnderlyingType;
4123 : *getTrailingObjects<QualType>();
4129 const Type *CanonicalType)
4135 ~NestedNameSpecifierDependence::
Dependent)
4139 *getTrailingObjects<NestedNameSpecifier>() = Qualifier;
4148 if ((
UsingBits.hasQualifier = !!Qualifier))
4149 *getTrailingObjects() = Qualifier;
4158 while (
auto *InnerMQT = dyn_cast<MacroQualifiedType>(Inner)) {
4161 Inner = InnerMQT->getModifiedType();
4172 ? Context.getUnqualifiedArrayType(Can).getAtomicUnqualifiedType()
4177 TOExpr(E), Context(Context) {
4178 TypeOfBits.Kind =
static_cast<unsigned>(Kind);
4187 ? Context.getUnqualifiedArrayType(QT).getAtomicUnqualifiedType()
4196 E->
Profile(ID, Context,
true);
4197 ID.AddBoolean(IsUnqual);
4204 ? Context.getUnqualifiedArrayType(Can).getAtomicUnqualifiedType()
4206 T->getDependence()),
4207 TOType(T), Context(Context) {
4208 TypeOfBits.Kind =
static_cast<unsigned>(Kind);
4211QualType TypeOfType::desugar()
const {
4214 ? Context.getUnqualifiedArrayType(QT).getAtomicUnqualifiedType()
4222 :
Type(Decltype, can,
4226 (E->
getType()->getDependence() &
4228 E(E), UnderlyingType(underlyingType) {}
4230bool DecltypeType::isSugared()
const {
return !E->isInstantiationDependent(); }
4232QualType DecltypeType::desugar()
const {
4239DependentDecltypeType::DependentDecltypeType(
Expr *E)
4242void DependentDecltypeType::Profile(llvm::FoldingSetNodeID &ID,
4244 E->
Profile(ID, Context,
true);
4248 Expr *IndexExpr,
bool FullySubstituted,
4250 :
Type(PackIndexing, Canonical,
4252 Pattern(Pattern), IndexExpr(IndexExpr),
Size(Expansions.size()),
4253 FullySubstituted(FullySubstituted) {
4255 llvm::uninitialized_copy(Expansions, getTrailingObjects());
4259 if (isInstantiationDependentType())
4260 return std::nullopt;
4262 ConstantExpr *CE = dyn_cast<ConstantExpr>(getIndexExpr());
4264 return std::nullopt;
4266 assert(Index.isNonNegative() &&
"Invalid index");
4267 return static_cast<unsigned>(Index.getExtValue());
4271PackIndexingType::computeDependence(
QualType Pattern,
Expr *IndexExpr,
4276 ? TypeDependence::DependentInstantiation
4277 : TypeDependence::None);
4278 if (Expansions.empty())
4279 TD |= Pattern->
getDependence() & TypeDependence::DependentInstantiation;
4281 for (
const QualType &T : Expansions)
4284 if (!(IndexD & TypeDependence::UnexpandedPack))
4290 TD |= TypeDependence::Error | TypeDependence::DependentInstantiation;
4295void PackIndexingType::Profile(llvm::FoldingSetNodeID &ID,
4297 Profile(ID, Context, getPattern(), getIndexExpr(), isFullySubstituted(),
4301void PackIndexingType::Profile(llvm::FoldingSetNodeID &ID,
4303 Expr *E,
bool FullySubstituted,
4306 E->
Profile(ID, Context,
true);
4307 ID.AddBoolean(FullySubstituted);
4308 if (!Expansions.empty()) {
4309 ID.AddInteger(Expansions.size());
4311 T.getCanonicalType().
Profile(ID);
4317UnaryTransformType::UnaryTransformType(
QualType BaseType,
4318 QualType UnderlyingType, UTTKind UKind,
4320 :
Type(UnaryTransform, CanonicalType, BaseType->getDependence()),
4321 BaseType(BaseType), UnderlyingType(UnderlyingType), UKind(UKind) {}
4325 bool OwnsTag,
bool ISInjected,
const Type *CanonicalType)
4332 ~NestedNameSpecifierDependence::
Dependent)
4336 getTrailingQualifier() = Qualifier;
4341void *TagType::getTrailingPointer()
const {
4342 switch (getTypeClass()) {
4347 case Type::InjectedClassName:
4348 return const_cast<InjectedClassNameType *
>(
4351 llvm_unreachable(
"unexpected type class");
4356 assert(TagTypeBits.HasQualifier);
4358 getTrailingPointer(), llvm::Align::Of<NestedNameSpecifier *>()));
4362 return TagTypeBits.HasQualifier ? getTrailingQualifier() : std::nullopt;
4366 auto *
Decl = dyn_cast<CXXRecordDecl>(
decl);
4369 if (
auto *RD = dyn_cast<ClassTemplateSpecializationDecl>(
Decl))
4370 return RD->getSpecializedTemplate();
4371 return Decl->getDescribedClassTemplate();
4375 auto *TD = getTemplateDecl();
4378 if (isCanonicalUnqualified())
4385TagType::getTemplateArgs(
const ASTContext &Ctx)
const {
4386 auto *
Decl = dyn_cast<CXXRecordDecl>(
decl);
4390 if (
auto *RD = dyn_cast<ClassTemplateSpecializationDecl>(
Decl))
4391 return RD->getTemplateArgs().asArray();
4393 return TD->getTemplateParameters()->getInjectedTemplateArgs(Ctx);
4397bool RecordType::hasConstFields()
const {
4398 std::vector<const RecordType *> RecordTypeList;
4399 RecordTypeList.push_back(
this);
4400 unsigned NextToCheckIndex = 0;
4402 while (RecordTypeList.size() > NextToCheckIndex) {
4403 for (
FieldDecl *FD : RecordTypeList[NextToCheckIndex]
4411 if (
const auto *FieldRecTy = FieldTy->
getAsCanonical<RecordType>()) {
4412 if (!llvm::is_contained(RecordTypeList, FieldRecTy))
4413 RecordTypeList.push_back(FieldRecTy);
4423 const TagDecl *TD,
bool IsInjected,
4424 const Type *CanonicalType)
4426 false, IsInjected, CanonicalType) {}
4435 :
Type(Attributed, canon, equivalent->getDependence()), Attribute(
attr),
4436 ModifiedType(modified), EquivalentType(equivalent) {
4438 assert(!attr ||
attr->getKind() == attrKind);
4441bool AttributedType::isQualifier()
const {
4443 switch (getAttrKind()) {
4448 case attr::ObjCOwnership:
4449 case attr::ObjCInertUnsafeUnretained:
4450 case attr::TypeNonNull:
4451 case attr::TypeNullable:
4452 case attr::TypeNullableResult:
4453 case attr::TypeNullUnspecified:
4454 case attr::LifetimeBound:
4455 case attr::AddressSpace:
4465bool AttributedType::isMSTypeSpec()
const {
4467 switch (getAttrKind()) {
4476 llvm_unreachable(
"invalid attr kind");
4479bool AttributedType::isWebAssemblyFuncrefSpec()
const {
4480 return getAttrKind() == attr::WebAssemblyFuncref;
4483bool AttributedType::isCallingConv()
const {
4485 switch (getAttrKind()) {
4490 case attr::FastCall:
4492 case attr::ThisCall:
4494 case attr::SwiftCall:
4495 case attr::SwiftAsyncCall:
4496 case attr::VectorCall:
4497 case attr::AArch64VectorPcs:
4498 case attr::AArch64SVEPcs:
4499 case attr::DeviceKernel:
4503 case attr::IntelOclBicc:
4504 case attr::PreserveMost:
4505 case attr::PreserveAll:
4507 case attr::PreserveNone:
4508 case attr::RISCVVectorCC:
4509 case attr::RISCVVLSCC:
4512 llvm_unreachable(
"invalid attr kind");
4516 return isCanonicalUnqualified() ?
nullptr : getDecl()->getIdentifier();
4519SubstTemplateTypeParmType::SubstTemplateTypeParmType(
QualType Replacement,
4520 Decl *AssociatedDecl,
4524 :
Type(SubstTemplateTypeParm, Replacement.getCanonicalType(),
4525 Replacement->getDependence()),
4526 AssociatedDecl(AssociatedDecl) {
4530 *getTrailingObjects() = Replacement;
4536 assert(AssociatedDecl !=
nullptr);
4540SubstTemplateTypeParmType::getReplacedParameter()
const {
4545void SubstTemplateTypeParmType::Profile(llvm::FoldingSetNodeID &ID,
4547 const Decl *AssociatedDecl,
4550 Replacement.Profile(ID);
4551 ID.AddPointer(AssociatedDecl);
4552 ID.AddInteger(Index);
4554 ID.AddBoolean(Final);
4557SubstPackType::SubstPackType(TypeClass Derived,
QualType Canon,
4559 :
Type(Derived, Canon,
4563 assert(llvm::all_of(
4565 [](
auto &P) { return P.getKind() == TemplateArgument::Type; }) &&
4566 "non-type argument to SubstPackType?");
4574void SubstPackType::Profile(llvm::FoldingSetNodeID &ID) {
4575 Profile(ID, getArgumentPack());
4578void SubstPackType::Profile(llvm::FoldingSetNodeID &ID,
4582 ID.AddPointer(P.getAsType().getAsOpaquePtr());
4585SubstTemplateTypeParmPackType::SubstTemplateTypeParmPackType(
4586 QualType Canon,
Decl *AssociatedDecl,
unsigned Index,
bool Final,
4588 : SubstPackType(SubstTemplateTypeParmPack, Canon, ArgPack),
4589 AssociatedDeclAndFinal(AssociatedDecl, Final) {
4590 assert(AssociatedDecl !=
nullptr);
4593 assert(getNumArgs() == ArgPack.
pack_size() &&
4594 "Parent bitfields in SubstPackType were overwritten."
4595 "Check NumSubstPackTypeBits.");
4598Decl *SubstTemplateTypeParmPackType::getAssociatedDecl()
const {
4599 return AssociatedDeclAndFinal.getPointer();
4602bool SubstTemplateTypeParmPackType::getFinal()
const {
4603 return AssociatedDeclAndFinal.getInt();
4607SubstTemplateTypeParmPackType::getReplacedParameter()
const {
4612IdentifierInfo *SubstTemplateTypeParmPackType::getIdentifier()
const {
4613 return getReplacedParameter()->getIdentifier();
4616void SubstTemplateTypeParmPackType::Profile(llvm::FoldingSetNodeID &ID) {
4617 Profile(ID, getAssociatedDecl(),
getIndex(), getFinal(), getArgumentPack());
4620void SubstTemplateTypeParmPackType::Profile(llvm::FoldingSetNodeID &ID,
4621 const Decl *AssociatedDecl,
4622 unsigned Index,
bool Final,
4624 ID.AddPointer(AssociatedDecl);
4625 ID.AddInteger(Index);
4626 ID.AddBoolean(Final);
4627 SubstPackType::Profile(ID, ArgPack);
4630SubstBuiltinTemplatePackType::SubstBuiltinTemplatePackType(
4632 : SubstPackType(SubstBuiltinTemplatePack, Canon, ArgPack) {}
4634bool TemplateSpecializationType::anyDependentTemplateArguments(
4637 return anyDependentTemplateArguments(Args.
arguments(), Converted);
4640bool TemplateSpecializationType::anyDependentTemplateArguments(
4643 if (Arg.isDependent())
4648bool TemplateSpecializationType::anyInstantiationDependentTemplateArguments(
4651 if (ArgLoc.getArgument().isInstantiationDependent())
4660 ? TypeDependence::DependentInstantiation
4665 D |= TypeDependence::UnexpandedPack;
4667 D |= (Underlying->
getDependence() & TypeDependence::UnexpandedPack);
4672TemplateSpecializationType::TemplateSpecializationType(
4676 Underlying.isNull() ?
QualType(this, 0)
4677 : Underlying.getCanonicalType(),
4680 TemplateSpecializationTypeBits.NumArgs = Args.size();
4681 TemplateSpecializationTypeBits.TypeAlias = IsAlias;
4683 auto *TemplateArgs =
4695 ~TypeDependence::Dependent);
4697 addDependence(Arg.getAsType()->getDependence() &
4698 TypeDependence::VariablyModified);
4705 *
reinterpret_cast<QualType *
>(TemplateArgs) = Underlying;
4708QualType TemplateSpecializationType::getAliasedType()
const {
4709 assert(isTypeAlias() &&
"not a type alias template specialization");
4710 return *
reinterpret_cast<const QualType *
>(template_arguments().end());
4713bool clang::TemplateSpecializationType::isSugared()
const {
4714 return !isDependentType() || isCurrentInstantiation() || isTypeAlias() ||
4719void TemplateSpecializationType::Profile(llvm::FoldingSetNodeID &ID,
4721 Profile(ID, getKeyword(),
Template, template_arguments(),
4722 isSugared() ? desugar() :
QualType(), Ctx);
4725void TemplateSpecializationType::Profile(llvm::FoldingSetNodeID &ID,
4731 ID.AddInteger(llvm::to_underlying(
Keyword));
4735 ID.AddInteger(Args.size());
4737 Arg.Profile(ID, Context);
4745 return Context.getQualifiedType(QT, *
this);
4749 const Type *T)
const {
4753 return Context.getQualifiedType(T, *
this);
4756void ObjCObjectTypeImpl::Profile(llvm::FoldingSetNodeID &ID,
QualType BaseType,
4760 ID.AddPointer(BaseType.getAsOpaquePtr());
4761 ID.AddInteger(typeArgs.size());
4762 for (
auto typeArg : typeArgs)
4763 ID.AddPointer(typeArg.getAsOpaquePtr());
4764 ID.AddInteger(protocols.size());
4765 for (
auto *proto : protocols)
4766 ID.AddPointer(proto);
4767 ID.AddBoolean(isKindOf);
4770void ObjCObjectTypeImpl::Profile(llvm::FoldingSetNodeID &ID) {
4771 Profile(ID, getBaseType(), getTypeArgsAsWritten(),
4773 isKindOfTypeAsWritten());
4776void ObjCTypeParamType::Profile(llvm::FoldingSetNodeID &ID,
4780 ID.AddPointer(OTPDecl);
4782 ID.AddInteger(protocols.size());
4783 for (
auto *proto : protocols)
4784 ID.AddPointer(proto);
4787void ObjCTypeParamType::Profile(llvm::FoldingSetNodeID &ID) {
4788 Profile(ID, getDecl(), getCanonicalTypeInternal(),
4795class CachedProperties {
4800 CachedProperties(
Linkage L,
bool local) : L(L), local(local) {}
4802 Linkage getLinkage()
const {
return L; }
4803 bool hasLocalOrUnnamedType()
const {
return local; }
4805 friend CachedProperties
merge(CachedProperties L, CachedProperties R) {
4807 return CachedProperties(MergedLinkage, L.hasLocalOrUnnamedType() ||
4808 R.hasLocalOrUnnamedType());
4827 return CachedProperties(T->TypeBits.getLinkage(),
4828 T->TypeBits.hasLocalOrUnnamedType());
4833 if (T->TypeBits.isCacheValid())
4838 if (!T->isCanonicalUnqualified()) {
4841 T->TypeBits.CacheValid =
true;
4842 T->TypeBits.CachedLinkage = CT->
TypeBits.CachedLinkage;
4843 T->TypeBits.CachedLocalOrUnnamed = CT->
TypeBits.CachedLocalOrUnnamed;
4849 T->TypeBits.CacheValid =
true;
4850 T->TypeBits.CachedLinkage = llvm::to_underlying(
Result.getLinkage());
4851 T->TypeBits.CachedLocalOrUnnamed =
Result.hasLocalOrUnnamedType();
4869 switch (T->getTypeClass()) {
4870#define TYPE(Class, Base)
4871#define NON_CANONICAL_TYPE(Class, Base) case Type::Class:
4872#include "clang/AST/TypeNodes.inc"
4873 llvm_unreachable(
"didn't expect a non-canonical type here");
4875#define TYPE(Class, Base)
4876#define DEPENDENT_TYPE(Class, Base) case Type::Class:
4877#define NON_CANONICAL_UNLESS_DEPENDENT_TYPE(Class, Base) case Type::Class:
4878#include "clang/AST/TypeNodes.inc"
4880 assert(T->isInstantiationDependentType());
4884 case Type::DeducedTemplateSpecialization:
4898 const auto *Tag =
cast<TagType>(T)->getDecl()->getDefinitionOrSelf();
4904 Linkage L = Tag->getLinkageInternal();
4905 bool IsLocalOrUnnamed = Tag->getDeclContext()->isFunctionOrMethod() ||
4906 !Tag->hasNameForLinkage();
4907 return CachedProperties(L, IsLocalOrUnnamed);
4917 case Type::BlockPointer:
4919 case Type::LValueReference:
4920 case Type::RValueReference:
4922 case Type::MemberPointer: {
4924 CachedProperties Cls = [&] {
4925 if (MPT->isSugared())
4927 return Cache::get(MPT->getQualifier().getAsType());
4929 return merge(Cls,
Cache::get(MPT->getPointeeType()));
4931 case Type::ConstantArray:
4932 case Type::IncompleteArray:
4933 case Type::VariableArray:
4934 case Type::ArrayParameter:
4937 case Type::ExtVector:
4939 case Type::ConstantMatrix:
4941 case Type::FunctionNoProto:
4943 case Type::FunctionProto: {
4945 CachedProperties result =
Cache::get(FPT->getReturnType());
4946 for (
const auto &ai : FPT->param_types())
4950 case Type::ObjCInterface: {
4952 return CachedProperties(L,
false);
4954 case Type::ObjCObject:
4956 case Type::ObjCObjectPointer:
4962 case Type::HLSLAttributedResource:
4964 case Type::HLSLInlineSpirv:
4966 case Type::OverflowBehavior:
4970 llvm_unreachable(
"unhandled type class");
4981 return TypeBits.hasLocalOrUnnamedType();
4985 switch (T->getTypeClass()) {
4986#define TYPE(Class, Base)
4987#define NON_CANONICAL_TYPE(Class, Base) case Type::Class:
4988#include "clang/AST/TypeNodes.inc"
4989 llvm_unreachable(
"didn't expect a non-canonical type here");
4991#define TYPE(Class, Base)
4992#define DEPENDENT_TYPE(Class, Base) case Type::Class:
4993#define NON_CANONICAL_UNLESS_DEPENDENT_TYPE(Class, Base) case Type::Class:
4994#include "clang/AST/TypeNodes.inc"
4996 assert(T->isInstantiationDependentType());
5004 case Type::DeducedTemplateSpecialization:
5016 case Type::BlockPointer:
5018 case Type::LValueReference:
5019 case Type::RValueReference:
5021 case Type::MemberPointer: {
5024 if (
auto *D = MPT->getMostRecentCXXRecordDecl()) {
5032 case Type::ConstantArray:
5033 case Type::IncompleteArray:
5034 case Type::VariableArray:
5035 case Type::ArrayParameter:
5038 case Type::ExtVector:
5040 case Type::ConstantMatrix:
5043 case Type::FunctionNoProto:
5045 case Type::FunctionProto: {
5048 for (
const auto &ai : FPT->param_types())
5052 case Type::ObjCInterface:
5054 case Type::ObjCObject:
5056 case Type::ObjCObjectPointer:
5063 case Type::OverflowBehavior:
5066 case Type::HLSLAttributedResource:
5068 ->getContainedType()
5069 ->getCanonicalTypeInternal());
5070 case Type::HLSLInlineSpirv:
5074 llvm_unreachable(
"unhandled type class");
5088 if (!T->isCanonicalUnqualified())
5102 while (
const auto *AT =
Type->getAs<AttributedType>()) {
5105 if (
auto Nullability = AT->getImmediateNullability())
5108 Type = AT->getEquivalentType();
5110 return std::nullopt;
5116 switch (
type->getTypeClass()) {
5117#define NON_CANONICAL_TYPE(Class, Parent) \
5120 llvm_unreachable("non-canonical type");
5121#define TYPE(Class, Parent)
5122#include "clang/AST/TypeNodes.inc"
5126 case Type::BlockPointer:
5127 case Type::MemberPointer:
5128 case Type::ObjCObjectPointer:
5132 case Type::UnresolvedUsing:
5133 case Type::TypeOfExpr:
5135 case Type::Decltype:
5136 case Type::PackIndexing:
5137 case Type::UnaryTransform:
5138 case Type::TemplateTypeParm:
5139 case Type::SubstTemplateTypeParmPack:
5140 case Type::SubstBuiltinTemplatePack:
5141 case Type::DependentName:
5143 return ResultIfUnknown;
5146 case Type::TemplateSpecialization:
5151 .getAsTemplateDecl())
5152 if (
auto *CTD = dyn_cast<ClassTemplateDecl>(templateDecl))
5153 return llvm::any_of(
5155 return RTD->getTemplatedDecl()->hasAttr<TypeNullableAttr>();
5157 return ResultIfUnknown;
5162#define SIGNED_TYPE(Id, SingletonId) case BuiltinType::Id:
5163#define UNSIGNED_TYPE(Id, SingletonId) case BuiltinType::Id:
5164#define FLOATING_TYPE(Id, SingletonId) case BuiltinType::Id:
5165#define BUILTIN_TYPE(Id, SingletonId)
5166#include "clang/AST/BuiltinTypes.def"
5169 case BuiltinType::UnresolvedTemplate:
5171 case BuiltinType::Dependent:
5172 case BuiltinType::Overload:
5173 case BuiltinType::BoundMember:
5174 case BuiltinType::PseudoObject:
5175 case BuiltinType::UnknownAny:
5176 case BuiltinType::ARCUnbridgedCast:
5177 return ResultIfUnknown;
5179 case BuiltinType::Void:
5180 case BuiltinType::ObjCId:
5181 case BuiltinType::ObjCClass:
5182 case BuiltinType::ObjCSel:
5183#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
5184 case BuiltinType::Id:
5185#include "clang/Basic/OpenCLImageTypes.def"
5186#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) case BuiltinType::Id:
5187#include "clang/Basic/OpenCLExtensionTypes.def"
5188 case BuiltinType::OCLSampler:
5189 case BuiltinType::OCLEvent:
5190 case BuiltinType::OCLClkEvent:
5191 case BuiltinType::OCLQueue:
5192 case BuiltinType::OCLReserveID:
5193#define SVE_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
5194#include "clang/Basic/AArch64ACLETypes.def"
5195#define PPC_VECTOR_TYPE(Name, Id, Size) case BuiltinType::Id:
5196#include "clang/Basic/PPCTypes.def"
5197#define RVV_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
5198#include "clang/Basic/RISCVVTypes.def"
5199#define WASM_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
5200#include "clang/Basic/WebAssemblyReferenceTypes.def"
5201#define AMDGPU_TYPE(Name, Id, SingletonId, Width, Align) case BuiltinType::Id:
5202#include "clang/Basic/AMDGPUTypes.def"
5203#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
5204#include "clang/Basic/HLSLIntangibleTypes.def"
5205 case BuiltinType::BuiltinFn:
5206 case BuiltinType::NullPtr:
5207 case BuiltinType::IncompleteMatrixIdx:
5208 case BuiltinType::ArraySection:
5209 case BuiltinType::OMPArrayShaping:
5210 case BuiltinType::OMPIterator:
5213 llvm_unreachable(
"unknown builtin type");
5215 case Type::Record: {
5219 if (
const auto *CTSD = dyn_cast<ClassTemplateSpecializationDecl>(RD))
5220 return llvm::any_of(
5221 CTSD->getSpecializedTemplate()->redecls(),
5223 return RTD->getTemplatedDecl()->hasAttr<TypeNullableAttr>();
5226 return RD->hasAttr<TypeNullableAttr>();
5232 case Type::LValueReference:
5233 case Type::RValueReference:
5234 case Type::ConstantArray:
5235 case Type::IncompleteArray:
5236 case Type::VariableArray:
5237 case Type::DependentSizedArray:
5238 case Type::DependentVector:
5239 case Type::DependentSizedExtVector:
5241 case Type::ExtVector:
5242 case Type::ConstantMatrix:
5243 case Type::DependentSizedMatrix:
5244 case Type::DependentAddressSpace:
5245 case Type::FunctionProto:
5246 case Type::FunctionNoProto:
5247 case Type::DeducedTemplateSpecialization:
5249 case Type::InjectedClassName:
5250 case Type::PackExpansion:
5251 case Type::ObjCObject:
5252 case Type::ObjCInterface:
5256 case Type::DependentBitInt:
5257 case Type::ArrayParameter:
5258 case Type::HLSLAttributedResource:
5259 case Type::HLSLInlineSpirv:
5260 case Type::OverflowBehavior:
5263 llvm_unreachable(
"bad type kind!");
5266std::optional<NullabilityKind> AttributedType::getImmediateNullability()
const {
5267 if (getAttrKind() == attr::TypeNonNull)
5269 if (getAttrKind() == attr::TypeNullable)
5271 if (getAttrKind() == attr::TypeNullUnspecified)
5273 if (getAttrKind() == attr::TypeNullableResult)
5275 return std::nullopt;
5278std::optional<NullabilityKind>
5279AttributedType::stripOuterNullability(
QualType &T) {
5281 if (
auto MacroTy = dyn_cast<MacroQualifiedType>(T))
5282 AttrTy = MacroTy->getUnderlyingType();
5284 if (
auto attributed = dyn_cast<AttributedType>(AttrTy)) {
5285 if (
auto nullability = attributed->getImmediateNullability()) {
5286 T = attributed->getModifiedType();
5291 return std::nullopt;
5305 if (objcPtr->isObjCIdType()) {
5316 }
else if (objcPtr->isObjCQualifiedIdType()) {
5341 "cannot query implicit lifetime for non-inferrable type");
5346 while (
const auto *array = dyn_cast<ArrayType>(canon))
5347 canon = array->getElementType().getTypePtr();
5349 if (
const auto *
opt = dyn_cast<ObjCObjectPointerType>(canon)) {
5351 if (
opt->getObjectType()->isObjCClass())
5360 return typedefType->getDecl()->hasAttr<ObjCNSObjectAttr>();
5366 return typedefType->getDecl()->hasAttr<ObjCIndependentClassAttr>();
5379 return OPT->getPointeeType()->isObjCIndirectLifetimeType();
5381 return Ref->getPointeeType()->isObjCIndirectLifetimeType();
5383 return MemPtr->getPointeeType()->isObjCIndirectLifetimeType();
5391 while (
const ArrayType *array =
type->getAsArrayTypeUnsafe())
5392 type = array->getElementType().getTypePtr();
5393 return type->isObjCRetainableType();
5415 return RT->getDecl()
5416 ->getMostRecentDecl()
5417 ->hasAttr<CUDADeviceBuiltinSurfaceTypeAttr>();
5424 return RT->getDecl()
5425 ->getMostRecentDecl()
5426 ->hasAttr<CUDADeviceBuiltinTextureTypeAttr>();
5435 return ptr->getPointeeType()->hasSizedVLAType();
5437 return ref->getPointeeType()->hasSizedVLAType();
5443 return arr->getElementType()->hasSizedVLAType();
5450 return HLSLAttributedResourceType::findHandleTypeOnResource(
this) !=
nullptr;
5473 const RecordType *RT =
5479 assert(RD !=
nullptr &&
5480 "all HLSL structs and classes should be CXXRecordDecl");
5486 switch (
type.getObjCLifetime()) {
5498 if (
const auto *RD =
type->getBaseElementTypeUnsafe()->getAsRecordDecl()) {
5499 if (
const auto *CXXRD = dyn_cast<CXXRecordDecl>(RD)) {
5501 if (CXXRD->hasDefinition() && !CXXRD->hasTrivialDestructor())
5525 Qualifier.Profile(ID);
5537 auto *RD = getCXXRecordDecl();
5544 llvm::APSInt Val,
unsigned Scale) {
5545 llvm::FixedPointSemantics FXSema(Val.getBitWidth(), Scale, Val.isSigned(),
5548 llvm::APFixedPoint(Val, FXSema).toString(Str);
5551DeducedType::DeducedType(TypeClass TC,
DeducedKind DK,
5554 ? DeducedAsTypeOrCanon.getCanonicalType()
5555 : DeducedAsTypeOrCanon,
5557 DeducedTypeBits.Kind = llvm::to_underlying(DK);
5562 assert(!DeducedAsTypeOrCanon.
isNull() &&
"Deduced type cannot be null");
5564 ~TypeDependence::VariablyModified);
5565 DeducedAsType = DeducedAsTypeOrCanon;
5568 addDependence(TypeDependence::UnexpandedPack);
5571 addDependence(TypeDependence::DependentInstantiation);
5574 assert(getDeducedKind() == DK &&
"DeducedKind does not match the type state");
5580 : DeducedType(
Auto, DK, DeducedAsTypeOrCanon) {
5581 AutoTypeBits.Keyword = llvm::to_underlying(
Keyword);
5582 AutoTypeBits.NumArgs = TypeConstraintArgs.size();
5583 this->TypeConstraintConcept = TypeConstraintConcept;
5584 assert(TypeConstraintConcept || AutoTypeBits.NumArgs == 0);
5585 if (TypeConstraintConcept) {
5586 auto Dep = TypeDependence::None;
5587 if (
const auto *TTP =
5588 dyn_cast<TemplateTemplateParmDecl>(TypeConstraintConcept))
5589 Dep = TypeDependence::DependentInstantiation |
5590 (TTP->isParameterPack() ? TypeDependence::UnexpandedPack
5591 : TypeDependence::None);
5606void AutoType::Profile(llvm::FoldingSetNodeID &ID,
const ASTContext &Context,
5610 DeducedType::Profile(ID, DK,
Deduced);
5611 ID.AddInteger(llvm::to_underlying(
Keyword));
5614 Arg.Profile(ID, Context);
5617void AutoType::Profile(llvm::FoldingSetNodeID &ID,
const ASTContext &Context) {
5618 Profile(ID, Context, getDeducedKind(), getDeducedType(), getKeyword(),
5619 getTypeConstraintConcept(), getTypeConstraintArguments());
5633 llvm_unreachable(
"unknown effect kind");
5639 return "nonblocking";
5641 return "nonallocating";
5645 return "allocating";
5647 llvm_unreachable(
"unknown effect kind");
5663 return std::nullopt;
5668 assert(0 &&
"effectProhibitingInference with non-inferable effect kind");
5671 llvm_unreachable(
"unknown effect kind");
5681 const Kind EK = Effect.kind();
5683 if (EK == CallerKind ||
5694 llvm_unreachable(
"unknown effect kind");
5706 unsigned InsertIdx = Effects.size();
5721 Errs.push_back({EC, NewEC});
5732 if (NewCondition || !Conditions.empty()) {
5733 if (Conditions.empty() && !Effects.empty())
5734 Conditions.resize(Effects.size());
5735 Conditions.insert(Conditions.begin() + InsertIdx,
5738 Effects.insert(Effects.begin() + InsertIdx, NewEC.
Effect);
5743 for (
const auto &Item :
Set)
5745 return Errs.empty();
5756 auto IterA = LHS.
begin(), EndA = LHS.
end();
5757 auto IterB = RHS.
begin(), EndB = RHS.
end();
5761 return std::tuple(LHS.Effect,
uintptr_t(LHS.Cond.getCondition())) <
5762 std::tuple(RHS.Effect,
uintptr_t(RHS.Cond.getCondition()));
5765 while (IterA != EndA && IterB != EndB) {
5770 else if (FEWCLess(B, A))
5781 assert(Errs.empty() &&
"conflict shouldn't be possible in getIntersection");
5794 Combined.
insert(RHS, Errs);
5815 llvm::interleaveComma(*
this, OS);
5825 llvm::interleaveComma(*
this, OS);
5832 assert(llvm::is_sorted(FX) &&
"effects should be sorted");
5833 assert((Conds.empty() || Conds.size() == FX.size()) &&
5834 "effects size should match conditions size");
5840 if (
Cond.getCondition() !=
nullptr)
5845const HLSLAttributedResourceType *
5846HLSLAttributedResourceType::findHandleTypeOnResource(
const Type *RT) {
5851 if (!RD->
fields().empty()) {
5852 const auto &FirstFD = RD->
fields().begin();
5853 return dyn_cast<HLSLAttributedResourceType>(
5854 FirstFD->getType().getTypePtr());
5860StringRef PredefinedSugarType::getName(Kind KD) {
5865 return "__signed_size_t";
5867 return "__ptrdiff_t";
5869 llvm_unreachable(
"unexpected kind");
Defines the clang::ASTContext interface.
Provides definitions for the various language-specific address spaces.
static std::optional< NonLoc > getIndex(ProgramStateRef State, const ElementRegion *ER, CharKind CK)
static Decl::Kind getKind(const Decl *D)
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate....
Defines the C++ template declaration subclasses.
static DeclT * getDefinitionOrSelf(DeclT *D)
Defines the ExceptionSpecificationType enumeration and various utility functions.
Defines the clang::IdentifierInfo, clang::IdentifierTable, and clang::Selector interfaces.
#define CC_VLS_CASE(ABI_VLEN)
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified.
Defines the clang::LangOptions interface.
llvm::MachO::Record Record
static QualType getUnderlyingType(const SubRegion *R)
static RecordDecl * getAsRecordDecl(QualType BaseType, HeuristicResolver &Resolver)
static bool isRecordType(QualType T)
Defines various enumerations that describe declaration and type specifiers.
static QualType getPointeeType(const MemRegion *R)
Defines the TargetCXXABI class, which abstracts details of the C++ ABI that we're targeting.
static TypeDependence getTemplateSpecializationTypeDependence(QualType Underlying, TemplateName T)
#define ENUMERATE_ATTRS(PREFIX)
#define SUGARED_TYPE_CLASS(Class)
TypePropertyCache< Private > Cache
static bool isTriviallyCopyableTypeImpl(const QualType &type, const ASTContext &Context, bool IsCopyConstructible)
static const T * getAsSugar(const Type *Cur)
This will check for a T (which should be a Type which can act as sugar, such as a TypedefType) by rem...
#define TRIVIAL_TYPE_CLASS(Class)
static CachedProperties computeCachedProperties(const Type *T)
C Language Family Type Representation.
Defines the clang::Visibility enumeration and various utility functions.
__DEVICE__ void * memcpy(void *__a, const void *__b, size_t __c)
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
BuiltinVectorTypeInfo getBuiltinVectorTypeInfo(const BuiltinType *VecTy) const
Returns the element type, element count and number of vectors (in case of tuple) for a builtin vector...
QualType getAtomicType(QualType T) const
Return the uniqued reference to the atomic type for the specified type.
QualType getParenType(QualType NamedType) const
QualType getRValueReferenceType(QualType T) const
Return the uniqued reference to the type for an rvalue reference to the specified type.
QualType getObjCInterfaceType(const ObjCInterfaceDecl *Decl, ObjCInterfaceDecl *PrevDecl=nullptr) const
getObjCInterfaceType - Return the unique reference to the type for the specified ObjC interface decl.
QualType getBlockPointerType(QualType T) const
Return the uniqued reference to the type for a block of the specified type.
QualType getAttributedType(attr::Kind attrKind, QualType modifiedType, QualType equivalentType, const Attr *attr=nullptr) const
QualType getFunctionNoProtoType(QualType ResultTy, const FunctionType::ExtInfo &Info) const
Return a K&R style C function type like 'int()'.
QualType getArrayParameterType(QualType Ty) const
Return the uniqued reference to a specified array parameter type from the original array type.
QualType getVectorType(QualType VectorType, unsigned NumElts, VectorKind VecKind) const
Return the unique reference to a vector type of the specified element type and size.
QualType getSubstTemplateTypeParmType(QualType Replacement, Decl *AssociatedDecl, unsigned Index, UnsignedOrNone PackIndex, bool Final) const
Retrieve a substitution-result type.
QualType getPointerType(QualType T) const
Return the uniqued reference to the type for a pointer to the specified type.
QualType getLValueReferenceType(QualType T, bool SpelledAsLValue=true) const
Return the uniqued reference to the type for an lvalue reference to the specified type.
QualType getConstantArrayType(QualType EltTy, const llvm::APInt &ArySize, const Expr *SizeExpr, ArraySizeModifier ASM, unsigned IndexTypeQuals) const
Return the unique reference to the type for a constant array of the specified element type.
const LangOptions & getLangOpts() const
QualType applyObjCProtocolQualifiers(QualType type, ArrayRef< ObjCProtocolDecl * > protocols, bool &hasError, bool allowOnPointerType=false) const
Apply Objective-C protocol qualifiers to the given type.
QualType getDecayedType(QualType T) const
Return the uniqued reference to the decayed version of the given type.
QualType getAutoType(DeducedKind DK, QualType DeducedAsType, AutoTypeKeyword Keyword, TemplateDecl *TypeConstraintConcept=nullptr, ArrayRef< TemplateArgument > TypeConstraintArgs={}) const
C++11 deduced auto type.
QualType getBaseElementType(const ArrayType *VAT) const
Return the innermost element type of an array type.
CanQualType ObjCBuiltinIdTy
IdentifierInfo * getNSObjectName() const
Retrieve the identifier 'NSObject'.
QualType getAdjustedType(QualType Orig, QualType New) const
Return the uniqued reference to a type adjusted from the original type to a new type.
QualType getQualifiedType(SplitQualType split) const
Un-split a SplitQualType.
QualType getObjCObjectPointerType(QualType OIT) const
Return a ObjCObjectPointerType type for the given ObjCObjectType.
QualType getObjCObjectType(QualType Base, ObjCProtocolDecl *const *Protocols, unsigned NumProtocols) const
Legacy interface: cannot provide type arguments or __kindof.
QualType getVariableArrayType(QualType EltTy, Expr *NumElts, ArraySizeModifier ASM, unsigned IndexTypeQuals) const
Return a non-unique reference to the type for a variable array of the specified element type.
const ArrayType * getAsArrayType(QualType T) const
Type Query functions.
uint64_t getTypeSize(QualType T) const
Return the size of the specified (complete) type T, in bits.
CanQualType UnsignedCharTy
TemplateName getQualifiedTemplateName(NestedNameSpecifier Qualifier, bool TemplateKeyword, TemplateName Template) const
Retrieve the template name that represents a qualified template name such as std::vector.
QualType getFunctionType(QualType ResultTy, ArrayRef< QualType > Args, const FunctionProtoType::ExtProtoInfo &EPI) const
Return a normal function type with a typed argument list.
QualType getMemberPointerType(QualType T, NestedNameSpecifier Qualifier, const CXXRecordDecl *Cls) const
Return the uniqued reference to the type for a member pointer to the specified type in the specified ...
QualType getComplexType(QualType T) const
Return the uniqued reference to the type for a complex number with the specified element type.
QualType 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 getOverflowBehaviorType(const OverflowBehaviorAttr *Attr, QualType Wrapped) const
QualType getIncompleteArrayType(QualType EltTy, ArraySizeModifier ASM, unsigned IndexTypeQuals) const
Return a unique reference to the type for an incomplete array of the specified element type.
QualType 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'.
QualType getAdjustedType() const
QualType getOriginalType() const
QualType getConstantArrayType(const ASTContext &Ctx) const
Represents an array type, per C99 6.7.5.2 - Array Declarators.
ArraySizeModifier getSizeModifier() const
Qualifiers getIndexTypeQualifiers() const
QualType getElementType() const
ArrayType(TypeClass tc, QualType et, QualType can, ArraySizeModifier sm, unsigned tq, const Expr *sz=nullptr)
unsigned getIndexTypeCVRQualifiers() const
QualType getValueType() const
Gets the type contained by this atomic type, i.e.
void Profile(llvm::FoldingSetNodeID &ID)
Attr - This represents one attribute.
BitIntType(bool isUnsigned, unsigned NumBits)
QualType getPointeeType() const
[BoundsSafety] Represents a parent type class for CountAttributedType and similar sugar types that wi...
BoundsAttributedType(TypeClass TC, QualType Wrapped, QualType Canon)
decl_range dependent_decls() const
bool referencesFieldDecls() const
This class is used for builtin types like 'int'.
StringRef getName(const PrintingPolicy &Policy) const
Represents a C++ struct/union/class.
bool isHLSLIntangible() const
Returns true if the class contains HLSL intangible type, either as a field or in base class.
bool mayBeNonDynamicClass() const
bool mayBeDynamicClass() const
CXXRecordDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
Declaration of a class template.
Complex values, per C99 6.2.5p11.
Represents the canonical version of C arrays with a specified constant size.
static unsigned getNumAddressingBits(const ASTContext &Context, QualType ElementType, const llvm::APInt &NumElements)
Determine the number of bits required to address a member of.
static unsigned getMaxSizeBits(const ASTContext &Context)
Determine the maximum number of active bits that an array's size can require, which limits the maximu...
const Expr * getSizeExpr() const
Return a pointer to the size expression.
llvm::APInt getSize() const
Return the constant array size as an APInt.
void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Ctx)
ConstantExpr - An expression that occurs in a constant context and optionally the result of evaluatin...
llvm::APSInt getResultAsAPSInt() const
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)
unsigned NumRows
Number of rows and columns.
Represents a sugar type with __counted_by or __sized_by annotations, including their _or_null variant...
void Profile(llvm::FoldingSetNodeID &ID)
StringRef getAttributeName(bool WithMacroPrefix) const
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
ASTContext & getParentASTContext() const
Decl - This represents one declaration (or definition), e.g.
bool isInStdNamespace() const
ASTContext & getASTContext() const LLVM_READONLY
void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context)
Expr * getNumBitsExpr() const
void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context)
DependentBitIntType(bool IsUnsigned, Expr *NumBits)
void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context)
void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context)
QualType getElementType() const
void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context)
void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context)
void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context)
Expr * getCondition() const
This represents one expression.
bool isValueDependent() const
Determines whether the value of this expression depends on.
bool isInstantiationDependent() const
Whether this expression is instantiation-dependent, meaning that it depends in some way on.
ExprDependence getDependence() const
Represents a member of a struct/union/class.
A mutable set of FunctionEffect::Kind.
void dump(llvm::raw_ostream &OS) const
FunctionEffectSet()=default
bool insert(const FunctionEffectWithCondition &NewEC, Conflicts &Errs)
SmallVector< Conflict > Conflicts
static FunctionEffectSet getIntersection(FunctionEffectsRef LHS, FunctionEffectsRef RHS)
void dump(llvm::raw_ostream &OS) const
static FunctionEffectSet getUnion(FunctionEffectsRef LHS, FunctionEffectsRef RHS, Conflicts &Errs)
Kind kind() const
The kind of the effect.
Kind
Identifies the particular effect.
bool shouldDiagnoseFunctionCall(bool Direct, FunctionEffectKindSet CalleeFX) const
StringRef name() const
The description printed in diagnostics, e.g. 'nonblocking'.
Kind oppositeKind() const
Return the opposite kind, for effects which have opposites.
std::optional< FunctionEffect > effectProhibitingInference(const Decl &Callee, FunctionEffectKindSet CalleeFX) const
Determine whether the effect is allowed to be inferred on the callee, which is either a FunctionDecl ...
An immutable set of FunctionEffects and possibly conditions attached to them.
void dump(llvm::raw_ostream &OS) const
ArrayRef< FunctionEffect > effects() const
ArrayRef< EffectConditionExpr > conditions() const
static FunctionEffectsRef create(ArrayRef< FunctionEffect > FX, ArrayRef< EffectConditionExpr > Conds)
Asserts invariants.
FunctionEffectsRef()=default
bool hasDependentExceptionSpec() const
Return whether this function has a dependent exception spec.
param_type_iterator param_type_begin() const
ExceptionSpecificationType getExceptionSpecType() const
Get the kind of exception specification on this function.
bool isTemplateVariadic() const
Determines whether this function prototype contains a parameter pack at the end.
unsigned getNumParams() const
bool hasTrailingReturn() const
Whether this function prototype has a trailing return type.
QualType getParamType(unsigned i) const
QualType getExceptionType(unsigned i) const
Return the ith exception type, where 0 <= i < getNumExceptions().
void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Ctx)
unsigned getNumExceptions() const
Return the number of types in the exception specification.
CanThrowResult canThrow() const
Determine whether this function type has a non-throwing exception specification.
ExtProtoInfo getExtProtoInfo() const
Expr * getNoexceptExpr() const
Return the expression inside noexcept(expression), or a null pointer if there is none (because the ex...
ArrayRef< QualType > getParamTypes() const
ArrayRef< QualType > exceptions() const
bool hasInstantiationDependentExceptionSpec() const
Return whether this function has an instantiation-dependent exception spec.
A class which abstracts out some details necessary for making a call.
ExtInfo getExtInfo() const
static StringRef getNameForCallConv(CallingConv CC)
bool getCFIUncheckedCalleeAttr() const
Determine whether this is a function prototype that includes the cfi_unchecked_callee attribute.
QualType getReturnType() const
FunctionType(TypeClass tc, QualType res, QualType Canonical, TypeDependence Dependence, ExtInfo Info)
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.
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.
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.
NestedNameSpecifier getQualifier() const
void Profile(llvm::FoldingSetNodeID &ID)
CXXRecordDecl * getMostRecentCXXRecordDecl() const
Note: this can trigger extra deserialization when external AST sources are used.
QualType getPointeeType() const
This represents a decl that may have a name.
IdentifierInfo * getIdentifier() const
Get the identifier that names this declaration, if there is one.
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
CXXRecordDecl * getAsRecordDecl() const
Retrieve the record declaration stored in this nested name specifier, or null.
ObjCCategoryDecl - Represents a category declaration.
ObjCInterfaceDecl * getClassInterface()
ObjCTypeParamList * getTypeParamList() const
Retrieve the type parameter list associated with this category or extension.
Represents an ObjC class declaration.
ObjCTypeParamList * getTypeParamList() const
Retrieve the type parameters of this class.
const ObjCObjectType * getSuperClassType() const
Retrieve the superclass type.
ObjCInterfaceDecl * getCanonicalDecl() override
Retrieves the canonical declaration of this Objective-C class.
ObjCInterfaceDecl * getDefinition()
Retrieve the definition of this class, or NULL if this class has been forward-declared (with @class) ...
Represents typeof(type), a C23 feature and GCC extension, or `typeof_unqual(type),...
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.
QualType getPointeeType() const
Gets the type pointed to by this ObjC pointer.
ObjCInterfaceDecl * getInterfaceDecl() const
If this pointer points to an Objective @interface type, gets the declaration for that interface.
const ObjCInterfaceType * getInterfaceType() const
If this pointer points to an Objective C @interface type, gets the type for that interface.
bool isKindOfType() const
Whether this is a "__kindof" type.
Represents an Objective-C protocol declaration.
Represents the declaration of an Objective-C type parameter.
unsigned getIndex() const
Retrieve the index into its type parameter list.
Stores a list of Objective-C type parameters for a parameterized class or a category/extension thereo...
unsigned size() const
Determine the number of type parameters in this list.
QualType getInnerType() const
QualType getPointeeType() const
A (possibly-)qualified type.
bool hasAddressDiscriminatedPointerAuth() const
bool isTriviallyCopyableType(const ASTContext &Context) const
Return true if this is a trivially copyable type (C++0x [basic.types]p9)
QualType IgnoreParens() const
Returns the specified type after dropping any outer-level parentheses.
QualType withFastQualifiers(unsigned TQs) const
bool hasNonTrivialToPrimitiveCopyCUnion() const
Check if this is or contains a C union that is non-trivial to copy, which is a union that has a membe...
bool isWebAssemblyFuncrefType() const
Returns true if it is a WebAssembly Funcref Type.
QualType getNonLValueExprType(const ASTContext &Context) const
Determine the type of a (typically non-lvalue) expression with the specified result type.
@ DK_objc_strong_lifetime
PrimitiveDefaultInitializeKind
@ PDIK_ARCWeak
The type is an Objective-C retainable pointer type that is qualified with the ARC __weak qualifier.
@ PDIK_Trivial
The type does not fall into any of the following categories.
@ PDIK_ARCStrong
The type is an Objective-C retainable pointer type that is qualified with the ARC __strong qualifier.
@ PDIK_Struct
The type is a struct containing a field whose type is not PCK_Trivial.
bool mayBeDynamicClass() const
Returns true if it is a class and it might be dynamic.
bool isNonWeakInMRRWithObjCWeak(const ASTContext &Context) const
const IdentifierInfo * getBaseTypeIdentifier() const
Retrieves a pointer to the name of the base type.
bool isBitwiseCloneableType(const ASTContext &Context) const
Return true if the type is safe to bitwise copy using memcpy/memmove.
void Profile(llvm::FoldingSetNodeID &ID) const
QualType getDesugaredType(const ASTContext &Context) const
Return the specified type with any "sugar" removed from the type.
bool isTriviallyCopyConstructibleType(const ASTContext &Context) const
Return true if this is a trivially copyable type.
bool isTrivialType(const ASTContext &Context) const
Return true if this is a trivial type per (C++0x [basic.types]p9)
bool isNull() const
Return true if this QualType doesn't point to a type yet.
PrimitiveCopyKind isNonTrivialToPrimitiveCopy() const
Check if this is a non-trivial type that would cause a C struct transitively containing this type to ...
const Type * getTypePtr() const
Retrieves a pointer to the underlying (unqualified) type.
LangAS getAddressSpace() const
Return the address space of this type.
bool isConstant(const ASTContext &Ctx) const
bool hasNonTrivialToPrimitiveDestructCUnion() const
Check if this is or contains a C union that is non-trivial to destruct, which is a union that has a m...
Qualifiers getQualifiers() const
Retrieve the set of qualifiers applied to this type.
bool isCXX98PODType(const ASTContext &Context) const
Return true if this is a POD type according to the rules of the C++98 standard, regardless of the cur...
Qualifiers::ObjCLifetime getObjCLifetime() const
Returns lifetime attribute of this type.
QualType stripObjCKindOfType(const ASTContext &ctx) const
Strip Objective-C "__kindof" types from the given type.
QualType getCanonicalType() const
QualType getUnqualifiedType() const
Retrieve the unqualified variant of the given type, removing as little sugar as possible.
QualType substObjCMemberType(QualType objectType, const DeclContext *dc, ObjCSubstitutionContext context) const
Substitute type arguments from an object type for the Objective-C type parameters used in the subject...
bool isWebAssemblyReferenceType() const
Returns true if it is a WebAssembly Reference Type.
SplitQualType getSplitDesugaredType() const
std::optional< NonConstantStorageReason > isNonConstantStorage(const ASTContext &Ctx, bool ExcludeCtor, bool ExcludeDtor)
Determine whether instances of this type can be placed in immutable storage.
bool isTrapType() const
Returns true if it is a OverflowBehaviorType of Trap kind.
SplitQualType split() const
Divides a QualType into its unqualified type and a set of local qualifiers.
bool UseExcessPrecision(const ASTContext &Ctx)
PrimitiveDefaultInitializeKind isNonTrivialToPrimitiveDefaultInitialize() const
Functions to query basic properties of non-trivial C struct types.
void * getAsOpaquePtr() const
bool isWebAssemblyExternrefType() const
Returns true if it is a WebAssembly Externref Type.
QualType getNonPackExpansionType() const
Remove an outer pack expansion type (if any) from this type.
bool isCXX11PODType(const ASTContext &Context) const
Return true if this is a POD type according to the more relaxed rules of the C++11 standard,...
bool mayBeNotDynamicClass() const
Returns true if it is not a class or if the class might not be dynamic.
bool isConstQualified() const
Determine whether this type is const-qualified.
QualType substObjCTypeArgs(ASTContext &ctx, ArrayRef< QualType > typeArgs, ObjCSubstitutionContext context) const
Substitute type arguments for the Objective-C type parameters used in the subject type.
QualType getAtomicUnqualifiedType() const
Remove all qualifiers including _Atomic.
bool isWrapType() const
Returns true if it is a OverflowBehaviorType of Wrap kind.
bool hasNonTrivialObjCLifetime() const
bool isPODType(const ASTContext &Context) const
Determine whether this is a Plain Old Data (POD) type (C++ 3.9p10).
PrimitiveCopyKind isNonTrivialToPrimitiveDestructiveMove() const
Check if this is a non-trivial type that would cause a C struct transitively containing this type to ...
@ NonConstNonReferenceType
@ PCK_Struct
The type is a struct containing a field whose type is neither PCK_Trivial nor PCK_VolatileTrivial.
@ PCK_Trivial
The type does not fall into any of the following categories.
@ PCK_ARCStrong
The type is an Objective-C retainable pointer type that is qualified with the ARC __strong qualifier.
@ PCK_VolatileTrivial
The type would be trivial except that it is volatile-qualified.
@ PCK_PtrAuth
The type is an address-discriminated signed pointer type.
@ PCK_ARCWeak
The type is an Objective-C retainable pointer type that is qualified with the ARC __weak qualifier.
bool hasNonTrivialToPrimitiveDefaultInitializeCUnion() const
Check if this is or contains a C union that is non-trivial to default-initialize, which is a union th...
A qualifier set is used to build a set of qualifiers.
const Type * strip(QualType type)
Collect any qualifiers on the given type and return an unqualified type.
QualType apply(const ASTContext &Context, QualType QT) const
Apply the collected qualifiers to the given type.
The collection of all-type qualifiers we support.
@ OCL_Strong
Assigning into this object requires the old value to be released and the new value to be retained.
@ OCL_ExplicitNone
This object can be modified without requiring retains or releases.
@ OCL_None
There is no lifetime qualification on this type.
@ OCL_Weak
Reading or writing from this object requires a barrier call.
@ OCL_Autoreleasing
Assigning into this object requires a lifetime extension.
bool isStrictSupersetOf(Qualifiers Other) const
Determine whether this set of qualifiers is a strict superset of another set of qualifiers,...
bool hasNonFastQualifiers() const
Return true if the set contains any qualifiers which require an ExtQuals node to be allocated.
void addConsistentQualifiers(Qualifiers qs)
Add the qualifiers from the given set to this set, given that they don't conflict.
static bool isTargetAddressSpaceSupersetOf(LangAS A, LangAS B, const ASTContext &Ctx)
bool hasAddressSpace() const
unsigned getFastQualifiers() const
bool hasObjCGCAttr() const
bool hasObjCLifetime() const
ObjCLifetime getObjCLifetime() const
LangAS getAddressSpace() const
Represents a struct/union/class.
bool hasNonTrivialToPrimitiveDestructCUnion() const
bool hasNonTrivialToPrimitiveCopyCUnion() const
bool hasNonTrivialToPrimitiveDefaultInitializeCUnion() const
bool isNonTrivialToPrimitiveDestroy() const
bool isNonTrivialToPrimitiveCopy() const
field_range fields() const
RecordDecl * getMostRecentDecl()
bool isNonTrivialToPrimitiveDefaultInitialize() const
Functions to query basic properties of non-trivial C structs.
Declaration of a redeclarable template.
QualType getPointeeTypeAsWritten() const
bool isSpelledAsLValue() const
Encodes a location in the source.
Stmt - This represents one statement.
void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context, bool Canonical, bool ProfileLambdaExpr=false) const
Produce a unique representation of the given statement.
void dump() const
Dumps the specified AST fragment and all subtrees to llvm::errs().
Represents the declaration of a struct/union/class/enum.
redecl_range redecls() const
Returns an iterator range for all the redeclarations of the same decl.
bool isCompleteDefinition() const
Return true if this decl has its body fully specified.
NestedNameSpecifier getQualifier() const
Retrieve the nested-name-specifier that qualifies the name of this declaration, if it was present in ...
bool isDependentType() const
Whether this declaration declares a type that is dependent, i.e., a type that somehow depends on temp...
Exposes information about the current target.
virtual bool hasFullBFloat16Type() const
Determine whether the BFloat type is fully supported on this target, i.e arithemtic operations.
virtual bool hasFastHalfType() const
Determine whether the target has fast native support for operations on half types.
virtual bool hasFloat16Type() const
Determine whether the _Float16 type is supported on this target.
virtual bool hasBFloat16Type() const
Determine whether the _BFloat16 type is supported on this target.
virtual bool isAddressSpaceSupersetOf(LangAS A, LangAS B) const
Returns true if an address space can be safely converted to another.
A convenient class for passing around template argument information.
ArrayRef< TemplateArgumentLoc > arguments() const
Location wrapper for a TemplateArgument.
Represents a template argument.
unsigned pack_size() const
The number of template arguments in the given template argument pack.
ArrayRef< TemplateArgument > pack_elements() const
Iterator range referencing all of the elements of a template argument pack.
@ Type
The template argument is a type.
The base class of all kinds of template declarations (e.g., class, function, etc.).
Represents a C++ template name within the type system.
Declaration of a template type parameter.
[BoundsSafety] Represents information of declarations referenced by the arguments of the counted_by a...
ValueDecl * getDecl() const
bool operator==(const TypeCoupledDeclRefInfo &Other) const
void * getOpaqueValue() const
TypeCoupledDeclRefInfo(ValueDecl *D=nullptr, bool Deref=false)
D is to a declaration referenced by the argument of attribute.
void setFromOpaqueValue(void *V)
bool isSugared() const
Returns whether this type directly provides sugar.
TypeOfKind getKind() const
Returns the kind of 'typeof' type this is.
TypeOfExprType(const ASTContext &Context, Expr *E, TypeOfKind Kind, QualType Can=QualType())
Expr * getUnderlyingExpr() const
QualType desugar() const
Remove a single level of sugar.
static void ensure(const Type *T)
static CachedProperties get(QualType T)
static CachedProperties get(const Type *T)
A helper class for Type nodes having an ElaboratedTypeKeyword.
The base class of the type hierarchy.
bool isSizelessType() const
As an extension, we classify types as one of "sized" or "sizeless"; every type is one or the other.
bool isStructureType() const
bool isBlockPointerType() const
const ObjCObjectPointerType * getAsObjCQualifiedClassType() const
bool isLinkageValid() const
True if the computed linkage is valid.
TypedefBitfields TypedefBits
bool isBooleanType() const
const ObjCObjectType * getAsObjCQualifiedInterfaceType() const
const ObjCObjectPointerType * getAsObjCQualifiedIdType() const
const TemplateSpecializationType * getAsNonAliasTemplateSpecializationType() const
Look through sugar for an instance of TemplateSpecializationType which is not a type alias,...
bool isMFloat8Type() const
bool isSignedIntegerOrEnumerationType() const
Determines whether this is an integer type that is signed or an enumeration types whose underlying ty...
bool isPackedVectorBoolType(const ASTContext &ctx) const
bool hasAttr(attr::Kind AK) const
Determine whether this type had the specified attribute applied to it (looking through top-level type...
bool isAlwaysIncompleteType() const
QualType getRVVEltType(const ASTContext &Ctx) const
Returns the representative type for the element of an RVV builtin type.
const RecordType * getAsUnionType() const
NOTE: getAs*ArrayType are methods on ASTContext.
bool isLiteralType(const ASTContext &Ctx) const
Return true if this is a literal type (C++11 [basic.types]p10)
bool isSignedIntegerType() const
Return true if this is an integer type that is signed, according to C99 6.2.5p4 [char,...
bool isComplexType() const
isComplexType() does not include complex integers (a GCC extension).
ArrayTypeBitfields ArrayTypeBits
const ArrayType * castAsArrayTypeUnsafe() const
A variant of castAs<> for array type which silently discards qualifiers from the outermost type.
bool isUnsignedIntegerOrEnumerationType() const
Determines whether this is an integer type that is unsigned or an enumeration types whose underlying ...
bool isIntegralOrUnscopedEnumerationType() const
Determine whether this type is an integral or unscoped enumeration type.
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
VectorTypeBitfields VectorTypeBits
SubstPackTypeBitfields SubstPackTypeBits
RecordDecl * getAsRecordDecl() const
Retrieves the RecordDecl this type refers to.
bool hasIntegerRepresentation() const
Determine whether this type has an integer representation of some sort, e.g., it is an integer type o...
bool isVoidPointerType() const
const ComplexType * getAsComplexIntegerType() const
bool isConstantSizeType() const
Return true if this is not a variable sized type, according to the rules of C99 6....
QualType getLocallyUnqualifiedSingleStepDesugaredType() const
Pull a single level of sugar off of this locally-unqualified type.
bool isFunctionPointerType() const
bool isCountAttributedType() const
bool isObjCARCBridgableType() const
Determine whether the given type T is a "bridgable" Objective-C type, which is either an Objective-C ...
CXXRecordDecl * castAsCXXRecordDecl() const
bool isArithmeticType() const
bool isConstantMatrixType() const
bool isHLSLBuiltinIntangibleType() const
TypeOfBitfields TypeOfBits
bool isIntegerType() const
isIntegerType() does not include complex integers (a GCC extension).
bool isSVESizelessBuiltinType() const
Returns true for SVE scalable vector types.
const T * castAs() const
Member-template castAs<specific type>.
bool isReferenceType() const
bool isHLSLIntangibleType() const
bool isEnumeralType() const
void addDependence(TypeDependence D)
bool isObjCNSObjectType() const
Type(TypeClass tc, QualType canon, TypeDependence Dependence)
const ObjCObjectPointerType * getAsObjCInterfacePointerType() const
NestedNameSpecifier getPrefix() const
If this type represents a qualified-id, this returns its nested name specifier.
bool isScalarType() const
const CXXRecordDecl * getPointeeCXXRecordDecl() const
If this is a pointer or reference to a RecordType, return the CXXRecordDecl that the type refers to.
bool isInterfaceType() const
bool isVariableArrayType() const
bool isSizelessBuiltinType() const
bool isCUDADeviceBuiltinSurfaceType() const
Check if the type is the CUDA device builtin surface type.
bool isSveVLSBuiltinType() const
Determines if this is a sizeless type supported by the 'arm_sve_vector_bits' type attribute,...
bool isIntegralType(const ASTContext &Ctx) const
Determine whether this type is an integral type.
bool isElaboratedTypeSpecifier() const
Determine wither this type is a C++ elaborated-type-specifier.
CountAttributedTypeBitfields CountAttributedTypeBits
const Type * getArrayElementTypeNoTypeQual() const
If this is an array type, return the element type of the array, potentially with type qualifiers miss...
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee.
LinkageInfo getLinkageAndVisibility() const
Determine the linkage and visibility of this type.
bool hasUnsignedIntegerRepresentation() const
Determine whether this type has an unsigned integer representation of some sort, e....
bool isAnyCharacterType() const
Determine whether this type is any of the built-in character types.
bool isExtVectorBoolType() const
bool isWebAssemblyExternrefType() const
Check if this is a WebAssembly Externref Type.
bool canHaveNullability(bool ResultIfUnknown=true) const
Determine whether the given type can have a nullability specifier applied to it, i....
QualType getSveEltType(const ASTContext &Ctx) const
Returns the representative type for the element of an SVE builtin type.
bool isInstantiationDependentType() const
Determine whether this type is an instantiation-dependent type, meaning that the type involves a temp...
bool isLValueReferenceType() const
bool isBitIntType() const
bool isBuiltinType() const
Helper methods to distinguish type categories.
bool isStructuralType() const
Determine if this type is a structural type, per C++20 [temp.param]p7.
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
bool isAggregateType() const
Determines whether the type is a C++ aggregate type or C aggregate or union type.
bool isCARCBridgableType() const
Determine whether the given type T is a "bridgeable" C type.
bool isSignableIntegerType(const ASTContext &Ctx) const
RecordDecl * castAsRecordDecl() const
bool isChar16Type() const
bool isAnyComplexType() const
DeducedType * getContainedDeducedType() const
Get the DeducedType whose type will be deduced for a variable with an initializer of this type.
bool containsUnexpandedParameterPack() const
Whether this type is or contains an unexpanded parameter pack, used to support C++0x variadic templat...
ScalarTypeKind getScalarTypeKind() const
Given that this is a scalar type, classify it.
bool hasSignedIntegerRepresentation() const
Determine whether this type has an signed integer representation of some sort, e.g....
QualType getCanonicalTypeInternal() const
const RecordType * getAsStructureType() const
const char * getTypeClassName() const
bool isWebAssemblyTableType() const
Returns true if this is a WebAssembly table type: either an array of reference types,...
@ PtrdiffT
The "ptrdiff_t" type.
@ SizeT
The "size_t" type.
@ SignedSizeT
The signed integer type corresponding to "size_t".
const Type * getBaseElementTypeUnsafe() const
Get the base element type of this type, potentially discarding type qualifiers.
AttributedTypeBitfields AttributedTypeBits
bool isObjCBoxableRecordType() const
bool isChar32Type() const
bool isStandardLayoutType() const
Test if this type is a standard-layout type.
TagTypeBitfields TagTypeBits
bool isOverflowBehaviorType() const
EnumDecl * castAsEnumDecl() const
bool isVariablyModifiedType() const
Whether this type is a variably-modified type (C99 6.7.5).
bool isComplexIntegerType() const
bool isUnscopedEnumerationType() const
bool isStdByteType() const
UnresolvedUsingBitfields UnresolvedUsingBits
bool isCUDADeviceBuiltinTextureType() const
Check if the type is the CUDA device builtin texture type.
bool isBlockCompatibleObjCPointerType(ASTContext &ctx) const
bool isObjCClassOrClassKindOfType() const
Whether the type is Objective-C 'Class' or a __kindof type of an Class type, e.g.,...
const ArrayType * getAsArrayTypeUnsafe() const
A variant of getAs<> for array types which silently discards qualifiers from the outermost type.
bool isObjCLifetimeType() const
Returns true if objects of this type have lifetime semantics under ARC.
bool isHLSLResourceRecord() const
EnumDecl * getAsEnumDecl() const
Retrieves the EnumDecl this type refers to.
bool isObjCIndirectLifetimeType() const
bool hasUnnamedOrLocalType() const
Whether this type is or contains a local or unnamed type.
bool isPointerOrReferenceType() const
Qualifiers::ObjCLifetime getObjCARCImplicitLifetime() const
Return the implicit lifetime for this type, which must not be dependent.
FunctionTypeBitfields FunctionTypeBits
bool isObjCQualifiedInterfaceType() const
bool isSpecifierType() const
Returns true if this type can be represented by some set of type specifiers.
bool isIncompleteType(NamedDecl **Def=nullptr) const
Types are partitioned into 3 broad categories (C99 6.2.5p1): object types, function types,...
bool isObjCObjectPointerType() const
SubstTemplateTypeParmTypeBitfields SubstTemplateTypeParmTypeBits
bool isStructureTypeWithFlexibleArrayMember() const
TypeDependence getDependence() const
bool hasFloatingRepresentation() const
Determine whether this type has a floating-point representation of some sort, e.g....
bool isStructureOrClassType() const
bool isVectorType() const
bool isRVVVLSBuiltinType() const
Determines if this is a sizeless type supported by the 'riscv_rvv_vector_bits' type attribute,...
bool isRealFloatingType() const
Floating point categories.
bool isRVVSizelessBuiltinType() const
Returns true for RVV scalable vector types.
std::optional< ArrayRef< QualType > > getObjCSubstitutions(const DeclContext *dc) const
Retrieve the set of substitutions required when accessing a member of the Objective-C receiver type t...
const T * getAsCanonical() const
If this type is canonically the specified type, return its canonical type cast to that specified type...
Linkage getLinkage() const
Determine the linkage of this type.
ObjCObjectTypeBitfields ObjCObjectTypeBits
bool isFloatingType() const
const ObjCObjectType * getAsObjCInterfaceType() const
bool isWideCharType() const
bool isUnsignedIntegerType() const
Return true if this is an integer type that is unsigned, according to C99 6.2.5p6 [which returns true...
bool hasSizedVLAType() const
Whether this type involves a variable-length array type with a definite size.
TypeClass getTypeClass() const
bool isCanonicalUnqualified() const
Determines if this type would be canonical if it had no further qualification.
bool hasAutoForTrailingReturnType() const
Determine whether this type was written with a leading 'auto' corresponding to a trailing return type...
bool isObjCIdOrObjectKindOfType(const ASTContext &ctx, const ObjCObjectType *&bound) const
Whether the type is Objective-C 'id' or a __kindof type of an object type, e.g., __kindof NSView * or...
const T * getAs() const
Member-template getAs<specific type>'.
const Type * getUnqualifiedDesugaredType() const
Return the specified type with any "sugar" removed from the type, removing any typedefs,...
bool isObjCARCImplicitlyUnretainedType() const
Determines if this type, which must satisfy isObjCLifetimeType(), is implicitly __unsafe_unretained r...
bool isRecordType() const
bool isHLSLResourceRecordArray() const
bool isObjCRetainableType() const
std::optional< NullabilityKind > getNullability() const
Determine the nullability of the given type.
bool isObjCIndependentClassType() const
bool isSizelessVectorType() const
Returns true for all scalable vector types.
bool isScopedEnumeralType() const
Determine whether this type is a scoped enumeration type.
bool acceptsObjCTypeParams() const
Determines if this is an ObjC interface type that may accept type parameters.
QualType getSizelessVectorEltType(const ASTContext &Ctx) const
Returns the representative type for the element of a sizeless vector builtin type.
bool isUnicodeCharacterType() const
bool hasBooleanRepresentation() const
Determine whether this type has a boolean representation – i.e., it is a boolean type,...
Base class for declarations which introduce a typedef-name.
QualType getUnderlyingType() const
bool typeMatchesDecl() const
Represents a dependent using declaration which was marked with typename.
Represents a shadow declaration implicitly introduced into a scope by a (resolved) using-declaration ...
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
Expr * getSizeExpr() const
Represents a GCC generic vector type.
unsigned getNumElements() const
VectorType(QualType vecType, unsigned nElements, QualType canonType, VectorKind vecKind)
VectorKind getVectorKind() const
QualType ElementType
The element type of the vector.
QualType getElementType() const
Defines the Linkage enumeration and various utility functions.
Defines the clang::TargetInfo interface.
mlir::Type getBaseType(mlir::Value varPtr)
@ AttributedType
The l-value was considered opaque, so the alignment was determined from a type, but that type was an ...
const internal::VariadicAllOfMatcher< Attr > attr
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
const internal::VariadicAllOfMatcher< Decl > decl
Matches declarations.
const AstTypeMatcher< TypedefType > typedefType
The JSON file list parser is used to communicate input to InstallAPI.
@ Overload
This is a legitimate overload: the existing declarations are functions or function templates with dif...
bool isa(CodeGen::Address addr)
if(T->getSizeExpr()) TRY_TO(TraverseStmt(const_cast< Expr * >(T -> getSizeExpr())))
AutoTypeKeyword
Which keyword(s) were used to create an AutoType.
CanThrowResult
Possible results from evaluation of a noexcept expression.
TypeDependenceScope::TypeDependence TypeDependence
void initialize(TemplateInstantiationCallbackPtrs &Callbacks, const Sema &TheSema)
Linkage minLinkage(Linkage L1, Linkage L2)
Compute the minimum linkage given two linkages.
@ Nullable
Values of this type can be null.
@ Unspecified
Whether values of this type can be null is (explicitly) unspecified.
@ NonNull
Values of this type can never be null.
@ TemplateName
The identifier is a template name. FIXME: Add an annotation for that.
bool IsEnumDeclComplete(EnumDecl *ED)
Check if the given decl is complete.
bool isPackProducingBuiltinTemplateName(TemplateName N)
ExprDependence computeDependence(FullExpr *E)
@ Private
'private' clause, allowed on 'parallel', 'serial', 'loop', 'parallel loop', and 'serial loop' constru...
@ Vector
'vector' clause, allowed on 'loop', Combined, and 'routine' directives.
TypeOfKind
The kind of 'typeof' expression we're after.
nullptr
This class represents a compute construct, representing a 'Kind' of ‘parallel’, 'serial',...
TypeDependence toTypeDependence(ExprDependence D)
ExprDependence turnValueToTypeDependence(ExprDependence D)
@ Dependent
Parse the block as a dependent block, which may be used in some template instantiations but not other...
Linkage
Describes the different kinds of linkage (C++ [basic.link], C99 6.2.2) that an entity may have.
@ External
External linkage, which indicates that the entity can be referred to from other translation units.
ObjCSubstitutionContext
The kind of type we are substituting Objective-C type arguments into.
@ Superclass
The superclass of a type.
@ Result
The result type of a method or function.
ArraySizeModifier
Capture whether this is a normal array (e.g.
bool isComputedNoexcept(ExceptionSpecificationType ESpecType)
@ Template
We are parsing a template declaration.
TagTypeKind
The kind of a tag type.
@ Interface
The "__interface" keyword.
@ Struct
The "struct" keyword.
@ Class
The "class" keyword.
@ Union
The "union" keyword.
@ Enum
The "enum" keyword.
@ Keyword
The name has been typo-corrected to a keyword.
@ Type
The name was classified as a type.
LangAS
Defines the address space values used by the address space qualifier of QualType.
void FixedPointValueToString(SmallVectorImpl< char > &Str, llvm::APSInt Val, unsigned Scale)
@ Deduced
The normal deduced case.
@ Undeduced
Not deduced yet. This is for example an 'auto' which was just parsed.
@ DeducedAsPack
Same as above, but additionally this represents a case where the deduced entity itself is a pack.
@ DeducedAsDependent
This is a special case where the initializer is dependent, so we can't deduce a type yet.
std::tuple< NamedDecl *, TemplateArgument > getReplacedTemplateParameter(Decl *D, unsigned Index)
Internal helper used by Subst* nodes to retrieve a parameter from the AssociatedDecl,...
bool isPtrSizeAddressSpace(LangAS AS)
const StreamingDiagnostic & operator<<(const StreamingDiagnostic &DB, const ConceptReference *C)
Insertion operator for diagnostics.
CallingConv
CallingConv - Specifies the calling convention that a function uses.
U cast(CodeGen::Address addr)
@ None
The alignment was not explicit in code.
ElaboratedTypeKeyword
The elaboration keyword that precedes a qualified type name or introduces an elaborated-type-specifie...
@ Interface
The "__interface" keyword introduces the elaborated-type-specifier.
@ None
No keyword precedes the qualified type name.
@ Struct
The "struct" keyword introduces the elaborated-type-specifier.
@ Class
The "class" keyword introduces the elaborated-type-specifier.
@ Union
The "union" keyword introduces the elaborated-type-specifier.
@ Enum
The "enum" keyword introduces the elaborated-type-specifier.
@ Typename
The "typename" keyword precedes the qualified type name, e.g., typename T::type.
TypeDependence toSemanticDependence(TypeDependence D)
TypeDependence toSyntacticDependence(TypeDependence D)
@ Other
Other implicit parameter.
@ EST_DependentNoexcept
noexcept(expression), value-dependent
@ EST_Uninstantiated
not instantiated yet
@ EST_Unparsed
not parsed yet
@ EST_NoThrow
Microsoft __declspec(nothrow) extension.
@ EST_None
no exception specification
@ EST_MSAny
Microsoft throw(...) extension.
@ EST_BasicNoexcept
noexcept
@ EST_NoexceptFalse
noexcept(expression), evals to 'false'
@ EST_Unevaluated
not evaluated yet, for special member function
@ EST_NoexceptTrue
noexcept(expression), evals to 'true'
@ EST_Dynamic
throw(T1, T2)
__UINTPTR_TYPE__ uintptr_t
An unsigned integer type with the property that any valid pointer to void can be converted to this ty...
A FunctionEffect plus a potential boolean expression determining whether the effect is declared (e....
FunctionEffectWithCondition(FunctionEffect E, const EffectConditionExpr &C)
std::string description() const
Return a textual description of the effect, and its condition, if any.
FunctionDecl * SourceDecl
The function whose exception specification this is, for EST_Unevaluated and EST_Uninstantiated.
FunctionDecl * SourceTemplate
The function template whose exception specification this is instantiated from, for EST_Uninstantiated...
ExceptionSpecificationType Type
The kind of exception specification this is.
ArrayRef< QualType > Exceptions
Explicitly-specified list of exception types.
Expr * NoexceptExpr
Noexcept expression, if this is a computed noexcept specification.
Extra information about a function prototype.
ExceptionSpecInfo ExceptionSpec
FunctionTypeExtraAttributeInfo ExtraAttributeInfo
bool requiresFunctionProtoTypeArmAttributes() const
unsigned AArch64SMEAttributes
SourceLocation EllipsisLoc
FunctionEffectsRef FunctionEffects
unsigned CFIUncheckedCallee
const ExtParameterInfo * ExtParameterInfos
RefQualifierKind RefQualifier
bool requiresFunctionProtoTypeExtraAttributeInfo() const
unsigned HasTrailingReturn
bool requiresFunctionProtoTypeExtraBitfields() const
static StringRef getKeywordName(ElaboratedTypeKeyword Keyword)
static ElaboratedTypeKeyword getKeywordForTagTypeKind(TagTypeKind Tag)
Converts a TagTypeKind into an elaborated type keyword.
static TagTypeKind getTagTypeKindForKeyword(ElaboratedTypeKeyword Keyword)
Converts an elaborated type keyword into a TagTypeKind.
static TagTypeKind getTagTypeKindForTypeSpec(unsigned TypeSpec)
Converts a type specifier (DeclSpec::TST) into a tag type kind.
static bool KeywordIsTagTypeKind(ElaboratedTypeKeyword Keyword)
static ElaboratedTypeKeyword getKeywordForTypeSpec(unsigned TypeSpec)
Converts a type specifier (DeclSpec::TST) into an elaborated type keyword.
Describes how types, statements, expressions, and declarations should be printed.
unsigned Bool
Whether we can use 'bool' rather than '_Bool' (even if the language doesn't actually have 'bool',...
unsigned NullptrTypeInNamespace
Whether 'nullptr_t' is in namespace 'std' or not.
unsigned Half
When true, print the half-precision floating-point type as 'half' instead of '__fp16'.
unsigned MSWChar
When true, print the built-in wchar_t type as __wchar_t.
A std::pair-like structure for storing a qualified type split into its local qualifiers and its local...
const Type * Ty
The locally-unqualified type.
Qualifiers Quals
The local qualifiers.
constexpr unsigned toInternalRepresentation() const