17#include "clang/AST/Attrs.inc"
42#include "llvm/ADT/APInt.h"
43#include "llvm/ADT/APSInt.h"
44#include "llvm/ADT/ArrayRef.h"
45#include "llvm/ADT/FoldingSet.h"
46#include "llvm/ADT/STLExtras.h"
47#include "llvm/ADT/SmallVector.h"
48#include "llvm/Support/ErrorHandling.h"
49#include "llvm/Support/MathExtras.h"
59 return (*
this !=
Other) &&
115 if (
const auto *DNT = ty->
getAs<DependentNameType>())
119 if (
const auto *TT = ty->
getAs<TagType>())
137 switch (T->getTypeClass()) {
143 case Type::BlockPointer:
146 case Type::MemberPointer:
149 case Type::LValueReference:
150 case Type::RValueReference:
153 case Type::PackExpansion:
157 case Type::ConstantArray:
158 case Type::DependentSizedArray:
159 case Type::IncompleteArray:
160 case Type::VariableArray:
161 case Type::FunctionProto:
162 case Type::FunctionNoProto:
179 if (T.isConstQualified())
183 return AT->getElementType().isConstant(Ctx);
188std::optional<QualType::NonConstantStorageReason>
191 if (!
isConstant(Ctx) && !(*this)->isReferenceType())
199 if (
Record->hasMutableFields())
201 if (!
Record->hasTrivialDestructor() && !ExcludeDtor)
227 (tc == DependentSizedArray
237 const llvm::APInt &Sz,
const Expr *SzExpr,
239 bool NeedsExternalSize = SzExpr !=
nullptr || Sz.ugt(0x0FFFFFFFFFFFFFFF) ||
240 Sz.getBitWidth() > 0xFF;
241 if (!NeedsExternalSize)
243 ET, Can, Sz.getBitWidth(), Sz.getZExtValue(), SzMod, Qual);
245 auto *SzPtr =
new (Ctx,
alignof(ConstantArrayType::ExternalSize))
246 ConstantArrayType::ExternalSize(Sz, SzExpr);
254 const llvm::APInt &NumElements) {
255 uint64_t ElementSize = Context.getTypeSizeInChars(ElementType).getQuantity();
263 if (llvm::isPowerOf2_64(ElementSize)) {
264 return NumElements.getActiveBits() + llvm::Log2_64(ElementSize);
269 if ((ElementSize >> 32) == 0 && NumElements.getBitWidth() <= 64 &&
270 (NumElements.getZExtValue() >> 32) == 0) {
271 uint64_t TotalSize = NumElements.getZExtValue() * ElementSize;
272 return llvm::bit_width(TotalSize);
276 llvm::APSInt SizeExtended(NumElements,
true);
277 unsigned SizeTypeBits = Context.getTypeSize(Context.getSizeType());
278 SizeExtended = SizeExtended.extend(
279 std::max(SizeTypeBits, SizeExtended.getBitWidth()) * 2);
281 llvm::APSInt TotalSize(llvm::APInt(SizeExtended.getBitWidth(), ElementSize));
282 TotalSize *= SizeExtended;
284 return TotalSize.getActiveBits();
293 unsigned Bits = Context.getTypeSize(Context.getSizeType());
306 uint64_t ArraySize,
const Expr *SizeExpr,
309 ID.AddInteger(ArraySize);
310 ID.AddInteger(llvm::to_underlying(SizeMod));
311 ID.AddInteger(TypeQuals);
312 ID.AddBoolean(SizeExpr !=
nullptr);
314 SizeExpr->
Profile(ID, Context,
true);
326 :
ArrayType(DependentSizedArray, et, can, sm, tq, e), SizeExpr((
Stmt *)e) {}
331 unsigned TypeQuals,
Expr *E) {
333 ID.AddInteger(llvm::to_underlying(SizeMod));
334 ID.AddInteger(TypeQuals);
339DependentVectorType::DependentVectorType(
QualType ElementType,
342 :
Type(DependentVector, CanonType,
344 ElementType->getDependence() |
347 ElementType(ElementType), SizeExpr(SizeExpr), Loc(Loc) {
355 ID.AddPointer(ElementType.getAsOpaquePtr());
356 ID.AddInteger(llvm::to_underlying(VecKind));
357 SizeExpr->Profile(ID, Context,
true);
360DependentSizedExtVectorType::DependentSizedExtVectorType(
QualType ElementType,
364 :
Type(DependentSizedExtVector, can,
366 ElementType->getDependence() |
369 SizeExpr(SizeExpr), ElementType(ElementType), loc(loc) {}
375 ID.AddPointer(ElementType.getAsOpaquePtr());
376 SizeExpr->Profile(ID, Context,
true);
379DependentAddressSpaceType::DependentAddressSpaceType(
QualType PointeeType,
383 :
Type(DependentAddressSpace, can,
385 PointeeType->getDependence() |
388 AddrSpaceExpr(AddrSpaceExpr), PointeeType(PointeeType), loc(loc) {}
393 Expr *AddrSpaceExpr) {
394 ID.AddPointer(PointeeType.getAsOpaquePtr());
395 AddrSpaceExpr->Profile(ID, Context,
true);
399 const Expr *RowExpr,
const Expr *ColumnExpr)
400 :
Type(tc, canonType,
417 unsigned nColumns,
QualType canonType)
422 unsigned nRows,
unsigned nColumns,
427DependentSizedMatrixType::DependentSizedMatrixType(
QualType ElementType,
432 :
MatrixType(DependentSizedMatrix, ElementType, CanonicalType, RowExpr,
434 RowExpr(RowExpr), ColumnExpr(ColumnExpr), loc(loc) {}
441 RowExpr->Profile(ID, CTX,
true);
442 ColumnExpr->Profile(ID, CTX,
true);
469 ExprAndUnsigned(NumBitsExpr, IsUnsigned) {}
472 return ExprAndUnsigned.getInt();
476 return ExprAndUnsigned.getPointer();
482 ID.AddBoolean(IsUnsigned);
483 NumBitsExpr->
Profile(ID, Context,
true);
495 bool CountInBytes,
bool OrNull) {
496 ID.AddPointer(WrappedTy.getAsOpaquePtr());
497 ID.AddBoolean(CountInBytes);
498 ID.AddBoolean(OrNull);
503 ID.AddPointer(CountExpr);
511 if (
const auto *ATy = dyn_cast<ArrayType>(
this))
512 return ATy->getElementType().getTypePtr();
540 return Context.getQualifiedType(desugar,
split.
Quals);
546#define TYPE(CLASS, BASE) \
547 static_assert(!std::is_polymorphic<CLASS##Type>::value, \
548 #CLASS "Type should not be polymorphic!");
549#include "clang/AST/TypeNodes.inc"
554#define TYPE(CLASS, BASE) \
555 static_assert(std::is_trivially_destructible<CLASS##Type>::value, \
556 #CLASS "Type should be trivially destructible!");
557#include "clang/AST/TypeNodes.inc"
561#define ABSTRACT_TYPE(Class, Parent)
562#define TYPE(Class, Parent) \
563 case Type::Class: { \
564 const auto *ty = cast<Class##Type>(this); \
565 if (!ty->isSugared()) \
566 return QualType(ty, 0); \
567 return ty->desugar(); \
569#include "clang/AST/TypeNodes.inc"
571 llvm_unreachable(
"bad type kind!");
581#define ABSTRACT_TYPE(Class, Parent)
582#define TYPE(Class, Parent) \
583 case Type::Class: { \
584 const auto *Ty = cast<Class##Type>(CurTy); \
585 if (!Ty->isSugared()) \
586 return SplitQualType(Ty, Qs); \
587 Cur = Ty->desugar(); \
590#include "clang/AST/TypeNodes.inc"
599 Qualifiers quals =
split.Quals;
602 const Type *lastTypeWithQuals =
split.Ty;
609 switch (
split.Ty->getTypeClass()) {
610#define ABSTRACT_TYPE(Class, Parent)
611#define TYPE(Class, Parent) \
612 case Type::Class: { \
613 const auto *ty = cast<Class##Type>(split.Ty); \
614 if (!ty->isSugared()) \
616 next = ty->desugar(); \
619#include "clang/AST/TypeNodes.inc"
625 if (!
split.Quals.empty()) {
626 lastTypeWithQuals =
split.Ty;
632 return SplitQualType(lastTypeWithQuals, quals);
637 while (
const auto *PT = T->
getAs<ParenType>())
638 T = PT->getInnerType();
647 if (
const auto *Sugar = dyn_cast<T>(Cur))
650#define ABSTRACT_TYPE(Class, Parent)
651#define TYPE(Class, Parent) \
652 case Type::Class: { \
653 const auto *Ty = cast<Class##Type>(Cur); \
654 if (!Ty->isSugared()) \
656 Cur = Ty->desugar().getTypePtr(); \
659#include "clang/AST/TypeNodes.inc"
672template <>
const TemplateSpecializationType *
Type::getAs()
const {
692 const Type *Cur =
this;
696#define ABSTRACT_TYPE(Class, Parent)
697#define TYPE(Class, Parent) \
699 const auto *Ty = cast<Class##Type>(Cur); \
700 if (!Ty->isSugared()) \
702 Cur = Ty->desugar().getTypePtr(); \
705#include "clang/AST/TypeNodes.inc"
712 return RT->getDecl()->isClass();
718 return RT->getDecl()->isStruct();
726 const auto *
Decl = RT->getDecl();
727 if (!
Decl->isStruct())
729 return Decl->getDefinitionOrSelf()->hasFlexibleArrayMember();
734 return RD->hasAttr<ObjCBoxableAttr>();
740 return RT->getDecl()->isInterface();
746 return RT->getDecl()->isStructureOrClass();
752 return PT->getPointeeType()->isVoidType();
758 return RT->getDecl()->isUnion();
764 return CT->getElementType()->isFloatingType();
775 return ET->getDecl()->isScoped();
785 if (
Complex->getElementType()->isIntegerType())
808 if (
const auto *RT = dyn_cast<RecordType>(
this)) {
809 if (RT->getDecl()->isStruct())
814 if (
const auto *RT = dyn_cast<RecordType>(CanonicalType)) {
815 if (!RT->getDecl()->isStruct())
827 if (
const auto *RT = dyn_cast<RecordType>(
this)) {
828 if (RT->getDecl()->isUnion())
833 if (
const auto *RT = dyn_cast<RecordType>(CanonicalType)) {
834 if (!RT->getDecl()->isUnion())
854 if (OPT->isObjCIdType())
858 if (!OPT->isKindOfType())
862 if (OPT->isObjCClassType() || OPT->isObjCQualifiedClassType())
866 bound = OPT->getObjectType()
867 ->stripObjCKindOfTypeAndQuals(ctx)
878 if (OPT->isObjCClassType())
882 if (!OPT->isKindOfType())
886 return OPT->isObjCClassType() || OPT->isObjCQualifiedClassType();
900 :
Type(ObjCObject, Canonical,
Base->getDependence()), BaseType(
Base) {
904 assert(getTypeArgsAsWritten().size() == typeArgs.size() &&
905 "bitfield overflow in type argument count");
906 if (!typeArgs.empty())
907 memcpy(getTypeArgStorage(), typeArgs.data(),
908 typeArgs.size() *
sizeof(
QualType));
910 for (
auto typeArg : typeArgs) {
911 addDependence(typeArg->getDependence() & ~TypeDependence::VariablyModified);
918bool ObjCObjectType::isSpecialized()
const {
920 if (ObjCObjectTypeBits.NumTypeArgs > 0)
924 if (
const auto objcObject =
getBaseType()->getAs<ObjCObjectType>()) {
929 return objcObject->isSpecialized();
938 if (isSpecializedAsWritten())
939 return getTypeArgsAsWritten();
942 if (
const auto objcObject =
getBaseType()->getAs<ObjCObjectType>()) {
947 return objcObject->getTypeArgs();
954bool ObjCObjectType::isKindOfType()
const {
955 if (isKindOfTypeAsWritten())
959 if (
const auto objcObject =
getBaseType()->getAs<ObjCObjectType>()) {
964 return objcObject->isKindOfType();
972ObjCObjectType::stripObjCKindOfTypeAndQuals(
const ASTContext &ctx)
const {
973 if (!isKindOfType() && qual_empty())
979 if (
const auto *baseObj = splitBaseType.
Ty->
getAs<ObjCObjectType>())
980 baseType = baseObj->stripObjCKindOfTypeAndQuals(ctx);
984 getTypeArgsAsWritten(),
1009template <
typename Derived>
1010struct SimpleTransformVisitor :
public TypeVisitor<Derived, QualType> {
1018 QualType result =
static_cast<Derived *
>(
this)->Visit(splitType.
Ty);
1028 explicit SimpleTransformVisitor(
ASTContext &ctx) : Ctx(ctx) {}
1032#define TYPE(Class, Base)
1033#define DEPENDENT_TYPE(Class, Base) \
1034 QualType Visit##Class##Type(const Class##Type *T) { return QualType(T, 0); }
1035#include "clang/AST/TypeNodes.inc"
1037#define TRIVIAL_TYPE_CLASS(Class) \
1038 QualType Visit##Class##Type(const Class##Type *T) { return QualType(T, 0); }
1039#define SUGARED_TYPE_CLASS(Class) \
1040 QualType Visit##Class##Type(const Class##Type *T) { \
1041 if (!T->isSugared()) \
1042 return QualType(T, 0); \
1043 QualType desugaredType = recurse(T->desugar()); \
1044 if (desugaredType.isNull()) \
1046 if (desugaredType.getAsOpaquePtr() == T->desugar().getAsOpaquePtr()) \
1047 return QualType(T, 0); \
1048 return desugaredType; \
1054 QualType elementType = recurse(T->getElementType());
1055 if (elementType.
isNull())
1058 if (elementType.
getAsOpaquePtr() == T->getElementType().getAsOpaquePtr())
1064 QualType VisitPointerType(
const PointerType *T) {
1066 if (pointeeType.
isNull())
1070 return QualType(T, 0);
1075 QualType VisitBlockPointerType(
const BlockPointerType *T) {
1077 if (pointeeType.
isNull())
1081 return QualType(T, 0);
1086 QualType VisitLValueReferenceType(
const LValueReferenceType *T) {
1088 if (pointeeType.
isNull())
1093 return QualType(T, 0);
1098 QualType VisitRValueReferenceType(
const RValueReferenceType *T) {
1100 if (pointeeType.
isNull())
1105 return QualType(T, 0);
1110 QualType VisitMemberPointerType(
const MemberPointerType *T) {
1112 if (pointeeType.
isNull())
1116 return QualType(T, 0);
1122 QualType VisitConstantArrayType(
const ConstantArrayType *T) {
1124 if (elementType.
isNull())
1128 return QualType(T, 0);
1135 QualType VisitVariableArrayType(
const VariableArrayType *T) {
1137 if (elementType.
isNull())
1141 return QualType(T, 0);
1148 QualType VisitIncompleteArrayType(
const IncompleteArrayType *T) {
1150 if (elementType.
isNull())
1154 return QualType(T, 0);
1160 QualType VisitVectorType(
const VectorType *T) {
1162 if (elementType.
isNull())
1166 return QualType(T, 0);
1172 QualType VisitExtVectorType(
const ExtVectorType *T) {
1174 if (elementType.
isNull())
1178 return QualType(T, 0);
1183 QualType VisitConstantMatrixType(
const ConstantMatrixType *T) {
1185 if (elementType.
isNull())
1188 return QualType(T, 0);
1194 QualType VisitOverflowBehaviorType(
const OverflowBehaviorType *T) {
1195 QualType UnderlyingType = recurse(T->getUnderlyingType());
1196 if (UnderlyingType.
isNull())
1200 T->getUnderlyingType().getAsOpaquePtr())
1201 return QualType(T, 0);
1206 QualType VisitFunctionNoProtoType(
const FunctionNoProtoType *T) {
1212 return QualType(T, 0);
1217 QualType VisitFunctionProtoType(
const FunctionProtoType *T) {
1223 SmallVector<QualType, 4> paramTypes;
1224 bool paramChanged =
false;
1226 QualType newParamType = recurse(paramType);
1227 if (newParamType.
isNull())
1231 paramChanged =
true;
1233 paramTypes.push_back(newParamType);
1238 bool exceptionChanged =
false;
1240 SmallVector<QualType, 4> exceptionTypes;
1242 QualType newExceptionType = recurse(exceptionType);
1243 if (newExceptionType.
isNull())
1246 if (newExceptionType.
getAsOpaquePtr() != exceptionType.getAsOpaquePtr())
1247 exceptionChanged =
true;
1249 exceptionTypes.push_back(newExceptionType);
1252 if (exceptionChanged) {
1254 llvm::ArrayRef(exceptionTypes).copy(Ctx);
1259 !paramChanged && !exceptionChanged)
1260 return QualType(T, 0);
1265 QualType VisitParenType(
const ParenType *T) {
1271 return QualType(T, 0);
1280 QualType VisitAdjustedType(
const AdjustedType *T) {
1282 if (originalType.
isNull())
1286 if (adjustedType.
isNull())
1292 return QualType(T, 0);
1297 QualType VisitDecayedType(
const DecayedType *T) {
1299 if (originalType.
isNull())
1303 return QualType(T, 0);
1308 QualType VisitArrayParameterType(
const ArrayParameterType *T) {
1309 QualType ArrTy = VisitConstantArrayType(T);
1323 QualType VisitAttributedType(
const AttributedType *T) {
1324 QualType modifiedType = recurse(T->getModifiedType());
1325 if (modifiedType.
isNull())
1328 QualType equivalentType = recurse(T->getEquivalentType());
1329 if (equivalentType.
isNull())
1333 T->getModifiedType().getAsOpaquePtr() &&
1335 T->getEquivalentType().getAsOpaquePtr())
1336 return QualType(T, 0);
1342 QualType VisitSubstTemplateTypeParmType(
const SubstTemplateTypeParmType *T) {
1343 QualType replacementType = recurse(T->getReplacementType());
1344 if (replacementType.
isNull())
1348 T->getReplacementType().getAsOpaquePtr())
1349 return QualType(T, 0);
1352 replacementType, T->getAssociatedDecl(), T->getIndex(),
1353 T->getPackIndex(), T->getFinal());
1359 QualType VisitAutoType(
const AutoType *T) {
1360 if (!T->isDeduced())
1361 return QualType(T, 0);
1363 QualType deducedType = recurse(T->getDeducedType());
1364 if (deducedType.
isNull())
1367 if (deducedType == T->getDeducedType())
1368 return QualType(T, 0);
1370 return Ctx.
getAutoType(T->getDeducedKind(), deducedType, T->getKeyword(),
1371 T->getTypeConstraintConcept(),
1372 T->getTypeConstraintArguments());
1375 QualType VisitObjCObjectType(
const ObjCObjectType *T) {
1376 QualType baseType = recurse(T->getBaseType());
1381 bool typeArgChanged =
false;
1382 SmallVector<QualType, 4> typeArgs;
1383 for (
auto typeArg : T->getTypeArgsAsWritten()) {
1384 QualType newTypeArg = recurse(typeArg);
1389 typeArgChanged =
true;
1391 typeArgs.push_back(newTypeArg);
1394 if (baseType.
getAsOpaquePtr() == T->getBaseType().getAsOpaquePtr() &&
1396 return QualType(T, 0);
1400 llvm::ArrayRef(T->qual_begin(), T->getNumProtocols()),
1401 T->isKindOfTypeAsWritten());
1406 QualType VisitObjCObjectPointerType(
const ObjCObjectPointerType *T) {
1408 if (pointeeType.
isNull())
1412 return QualType(T, 0);
1417 QualType VisitAtomicType(
const AtomicType *T) {
1423 return QualType(T, 0);
1428#undef TRIVIAL_TYPE_CLASS
1429#undef SUGARED_TYPE_CLASS
1432struct SubstObjCTypeArgsVisitor
1433 :
public SimpleTransformVisitor<SubstObjCTypeArgsVisitor> {
1434 using BaseType = SimpleTransformVisitor<SubstObjCTypeArgsVisitor>;
1436 ArrayRef<QualType> TypeArgs;
1439 SubstObjCTypeArgsVisitor(ASTContext &ctx, ArrayRef<QualType> typeArgs,
1441 : BaseType(ctx), TypeArgs(typeArgs), SubstContext(context) {}
1443 QualType VisitObjCTypeParamType(
const ObjCTypeParamType *OTPTy) {
1446 ObjCTypeParamDecl *typeParam = OTPTy->getDecl();
1448 if (!TypeArgs.empty()) {
1449 QualType argType = TypeArgs[typeParam->
getIndex()];
1450 if (OTPTy->qual_empty())
1455 SmallVector<ObjCProtocolDecl *, 8> protocolsVec;
1456 protocolsVec.append(OTPTy->qual_begin(), OTPTy->qual_end());
1457 ArrayRef<ObjCProtocolDecl *> protocolsToApply = protocolsVec;
1459 argType, protocolsToApply, hasError,
true );
1462 switch (SubstContext) {
1463 case ObjCSubstitutionContext::Ordinary:
1464 case ObjCSubstitutionContext::Parameter:
1465 case ObjCSubstitutionContext::Superclass:
1469 case ObjCSubstitutionContext::Result:
1470 case ObjCSubstitutionContext::Property: {
1472 const auto *objPtr =
1477 if (objPtr->isKindOfType() || objPtr->isObjCIdOrClassType())
1481 const auto *obj = objPtr->getObjectType();
1483 obj->getBaseType(), obj->getTypeArgsAsWritten(), obj->getProtocols(),
1490 llvm_unreachable(
"Unexpected ObjCSubstitutionContext!");
1493 QualType VisitFunctionType(
const FunctionType *funcType) {
1499 Ctx, TypeArgs, ObjCSubstitutionContext::Result);
1509 return BaseType::VisitFunctionType(funcType);
1518 SmallVector<QualType, 4> paramTypes;
1519 bool paramChanged =
false;
1520 for (
auto paramType : funcProtoType->getParamTypes()) {
1522 Ctx, TypeArgs, ObjCSubstitutionContext::Parameter);
1523 if (newParamType.
isNull())
1527 paramChanged =
true;
1529 paramTypes.push_back(newParamType);
1533 FunctionProtoType::ExtProtoInfo info = funcProtoType->getExtProtoInfo();
1534 bool exceptionChanged =
false;
1536 SmallVector<QualType, 4> exceptionTypes;
1539 Ctx, TypeArgs, ObjCSubstitutionContext::Ordinary);
1540 if (newExceptionType.
isNull())
1543 if (newExceptionType.
getAsOpaquePtr() != exceptionType.getAsOpaquePtr())
1544 exceptionChanged =
true;
1546 exceptionTypes.push_back(newExceptionType);
1549 if (exceptionChanged) {
1551 llvm::ArrayRef(exceptionTypes).copy(Ctx);
1556 funcProtoType->getReturnType().getAsOpaquePtr() &&
1557 !paramChanged && !exceptionChanged)
1558 return BaseType::VisitFunctionType(funcType);
1563 QualType VisitObjCObjectType(
const ObjCObjectType *objcObjectType) {
1566 if (objcObjectType->isSpecializedAsWritten()) {
1567 SmallVector<QualType, 4> newTypeArgs;
1568 bool anyChanged =
false;
1569 for (
auto typeArg : objcObjectType->getTypeArgsAsWritten()) {
1571 Ctx, TypeArgs, ObjCSubstitutionContext::Ordinary);
1578 ArrayRef<ObjCProtocolDecl *> protocols(
1579 objcObjectType->qual_begin(), objcObjectType->getNumProtocols());
1580 if (TypeArgs.empty() &&
1581 SubstContext != ObjCSubstitutionContext::Superclass) {
1583 objcObjectType->getBaseType(), {}, protocols,
1584 objcObjectType->isKindOfTypeAsWritten());
1590 newTypeArgs.push_back(newTypeArg);
1594 ArrayRef<ObjCProtocolDecl *> protocols(
1595 objcObjectType->qual_begin(), objcObjectType->getNumProtocols());
1598 objcObjectType->isKindOfTypeAsWritten());
1602 return BaseType::VisitObjCObjectType(objcObjectType);
1605 QualType VisitAttributedType(
const AttributedType *attrType) {
1606 QualType newType = BaseType::VisitAttributedType(attrType);
1610 const auto *newAttrType = dyn_cast<AttributedType>(newType.
getTypePtr());
1611 if (!newAttrType || newAttrType->getAttrKind() != attr::ObjCKindOf)
1615 QualType newEquivType = newAttrType->getEquivalentType();
1616 const ObjCObjectPointerType *ptrType =
1617 newEquivType->
getAs<ObjCObjectPointerType>();
1618 const ObjCObjectType *objType = ptrType
1620 : newEquivType->
getAs<ObjCObjectType>();
1627 objType->getBaseType(), objType->getTypeArgsAsWritten(),
1628 objType->getProtocols(),
1630 objType->isObjCUnqualifiedId() ?
false :
true);
1638 newAttrType->getModifiedType(), newEquivType,
1639 newAttrType->getAttr());
1643struct StripObjCKindOfTypeVisitor
1644 :
public SimpleTransformVisitor<StripObjCKindOfTypeVisitor> {
1645 using BaseType = SimpleTransformVisitor<StripObjCKindOfTypeVisitor>;
1647 explicit StripObjCKindOfTypeVisitor(ASTContext &ctx) : BaseType(ctx) {}
1649 QualType VisitObjCObjectType(
const ObjCObjectType *objType) {
1650 if (!objType->isKindOfType())
1651 return BaseType::VisitObjCObjectType(objType);
1653 QualType baseType = objType->getBaseType().stripObjCKindOfType(Ctx);
1655 objType->getProtocols(),
1672 case BuiltinType::Kind::Float16: {
1680 case BuiltinType::Kind::BFloat16: {
1700 SubstObjCTypeArgsVisitor visitor(ctx, typeArgs, context);
1701 return visitor.recurse(*
this);
1715 auto &ctx =
const_cast<ASTContext &
>(constCtx);
1716 StripObjCKindOfTypeVisitor visitor(ctx);
1717 return visitor.recurse(*
this);
1722 if (
const auto AT = T.getTypePtr()->getAs<
AtomicType>())
1723 T = AT->getValueType();
1724 return T.getUnqualifiedType();
1727std::optional<ArrayRef<QualType>>
1730 if (
const auto method = dyn_cast<ObjCMethodDecl>(dc))
1731 dc = method->getDeclContext();
1735 const auto *dcClassDecl = dyn_cast<ObjCInterfaceDecl>(dc);
1741 dcTypeParams = dcClassDecl->getTypeParamList();
1743 return std::nullopt;
1747 dcCategoryDecl = dyn_cast<ObjCCategoryDecl>(dc);
1748 if (!dcCategoryDecl)
1749 return std::nullopt;
1755 return std::nullopt;
1759 return std::nullopt;
1761 assert(dcTypeParams &&
"No substitutions to perform");
1762 assert(dcClassDecl &&
"No class context");
1767 objectType = objectPointerType->getObjectType();
1778 objectType ? objectType->getInterface() :
nullptr;
1779 if (!curClassDecl) {
1787 while (curClassDecl != dcClassDecl) {
1789 QualType superType = objectType->getSuperClassType();
1790 if (superType.
isNull()) {
1791 objectType =
nullptr;
1796 curClassDecl = objectType->getInterface();
1801 if (!objectType || objectType->isUnspecialized()) {
1806 return objectType->getTypeArgs();
1811 if (
auto *ID = IfaceT->getInterface()) {
1812 if (ID->getTypeParamList())
1820void ObjCObjectType::computeSuperClassTypeSlow()
const {
1826 CachedSuperClassType.setInt(
true);
1832 if (!superClassObjTy) {
1833 CachedSuperClassType.setInt(
true);
1838 if (!superClassDecl) {
1839 CachedSuperClassType.setInt(
true);
1845 QualType superClassType(superClassObjTy, 0);
1847 if (!superClassTypeParams) {
1848 CachedSuperClassType.setPointerAndInt(
1849 superClassType->castAs<ObjCObjectType>(),
true);
1854 if (superClassObjTy->isUnspecialized()) {
1855 CachedSuperClassType.setPointerAndInt(superClassObjTy,
true);
1863 CachedSuperClassType.setPointerAndInt(
1864 superClassType->castAs<ObjCObjectType>(),
true);
1870 if (isUnspecialized()) {
1873 superClassObjTy->getInterface());
1874 CachedSuperClassType.setPointerAndInt(
1875 unspecializedSuper->
castAs<ObjCObjectType>(),
true);
1881 assert(typeArgs.size() == typeParams->
size());
1882 CachedSuperClassType.setPointerAndInt(
1886 ->castAs<ObjCObjectType>(),
1892 return interfaceDecl->getASTContext()
1893 .getObjCInterfaceType(interfaceDecl)
1902 if (superObjectType.
isNull())
1903 return superObjectType;
1914 if (T->getNumProtocols() && T->getInterface())
1927 if (OPT->isObjCQualifiedIdType())
1937 if (OPT->isObjCQualifiedClassType())
1945 if (OT->getInterface())
1953 if (OPT->getInterfaceType())
1970const TemplateSpecializationType *
1973 while (TST && TST->isTypeAlias())
1974 TST = TST->desugar()->getAs<TemplateSpecializationType>();
1980 case Type::DependentName:
1982 case Type::TemplateSpecialization:
1988 case Type::InjectedClassName:
1992 case Type::UnresolvedUsing:
1997 return std::nullopt;
2002 const Type *Cur =
this;
2003 while (
const auto *AT = Cur->
getAs<AttributedType>()) {
2004 if (AT->getAttrKind() == AK)
2006 Cur = AT->getEquivalentType().getTypePtr();
2013class GetContainedDeducedTypeVisitor
2014 :
public TypeVisitor<GetContainedDeducedTypeVisitor, Type *> {
2018 GetContainedDeducedTypeVisitor(
bool Syntactic =
false)
2019 : Syntactic(Syntactic) {}
2026 return Visit(T.getTypePtr());
2030 Type *VisitDeducedType(
const DeducedType *AT) {
2031 return const_cast<DeducedType *
>(AT);
2035 Type *VisitSubstTemplateTypeParmType(
const SubstTemplateTypeParmType *T) {
2036 return Visit(T->getReplacementType());
2039 Type *VisitPointerType(
const PointerType *T) {
2043 Type *VisitBlockPointerType(
const BlockPointerType *T) {
2047 Type *VisitReferenceType(
const ReferenceType *T) {
2051 Type *VisitMemberPointerType(
const MemberPointerType *T) {
2055 Type *VisitArrayType(
const ArrayType *T) {
2059 Type *VisitDependentSizedExtVectorType(
const DependentSizedExtVectorType *T) {
2063 Type *VisitVectorType(
const VectorType *T) {
2067 Type *VisitDependentSizedMatrixType(
const DependentSizedMatrixType *T) {
2071 Type *VisitConstantMatrixType(
const ConstantMatrixType *T) {
2075 Type *VisitFunctionProtoType(
const FunctionProtoType *T) {
2077 return const_cast<FunctionProtoType *
>(T);
2078 return VisitFunctionType(T);
2081 Type *VisitFunctionType(
const FunctionType *T) {
2085 Type *VisitParenType(
const ParenType *T) {
return Visit(T->
getInnerType()); }
2087 Type *VisitAttributedType(
const AttributedType *T) {
2088 return Visit(T->getModifiedType());
2091 Type *VisitMacroQualifiedType(
const MacroQualifiedType *T) {
2095 Type *VisitOverflowBehaviorType(
const OverflowBehaviorType *T) {
2096 return Visit(T->getUnderlyingType());
2099 Type *VisitAdjustedType(
const AdjustedType *T) {
2103 Type *VisitPackExpansionType(
const PackExpansionType *T) {
2104 return Visit(T->getPattern());
2111 return cast_or_null<DeducedType>(
2112 GetContainedDeducedTypeVisitor().Visit(
this));
2116 return isa_and_nonnull<FunctionType>(
2117 GetContainedDeducedTypeVisitor(
true).Visit(
this));
2121 if (
const auto *VT = dyn_cast<VectorType>(CanonicalType))
2122 return VT->getElementType()->isIntegerType();
2123 if (CanonicalType->isSveVLSBuiltinType()) {
2125 return VT->getKind() == BuiltinType::SveBool ||
2126 (VT->getKind() >= BuiltinType::SveInt8 &&
2127 VT->getKind() <= BuiltinType::SveUint64);
2129 if (CanonicalType->isRVVVLSBuiltinType()) {
2131 return (VT->getKind() >= BuiltinType::RvvInt8mf8 &&
2132 VT->getKind() <= BuiltinType::RvvUint64m8);
2158 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
2159 return BT->isInteger();
2163 if (
const auto *ET = dyn_cast<EnumType>(CanonicalType))
2166 if (
const OverflowBehaviorType *OBT =
2167 dyn_cast<OverflowBehaviorType>(CanonicalType))
2168 return OBT->getUnderlyingType()->isIntegralOrEnumerationType();
2175 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
2176 return BT->isInteger();
2178 if (
const auto *OBT = dyn_cast<OverflowBehaviorType>(CanonicalType))
2179 return OBT->getUnderlyingType()->isIntegerType();
2188 if (
const auto *ET = dyn_cast<EnumType>(CanonicalType))
2189 return !ET->getDecl()->isScoped();
2195 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
2196 return BT->getKind() == BuiltinType::Char_U ||
2197 BT->getKind() == BuiltinType::UChar ||
2198 BT->getKind() == BuiltinType::Char_S ||
2199 BT->getKind() == BuiltinType::SChar;
2204 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
2205 return BT->getKind() == BuiltinType::WChar_S ||
2206 BT->getKind() == BuiltinType::WChar_U;
2211 if (
const BuiltinType *BT = dyn_cast<BuiltinType>(CanonicalType))
2212 return BT->getKind() == BuiltinType::Char8;
2217 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
2218 return BT->getKind() == BuiltinType::Char16;
2223 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
2224 return BT->getKind() == BuiltinType::Char32;
2231 const auto *BT = dyn_cast<BuiltinType>(CanonicalType);
2234 switch (BT->getKind()) {
2237 case BuiltinType::Char_U:
2238 case BuiltinType::UChar:
2239 case BuiltinType::WChar_U:
2240 case BuiltinType::Char8:
2241 case BuiltinType::Char16:
2242 case BuiltinType::Char32:
2243 case BuiltinType::Char_S:
2244 case BuiltinType::SChar:
2245 case BuiltinType::WChar_S:
2251 const auto *BT = dyn_cast<BuiltinType>(CanonicalType);
2254 switch (BT->getKind()) {
2257 case BuiltinType::Char8:
2258 case BuiltinType::Char16:
2259 case BuiltinType::Char32:
2268 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
2269 return BT->isSignedInteger();
2274 if (!ED->isComplete() || ED->isScoped())
2276 return ED->getIntegerType()->isSignedIntegerType();
2279 if (
const auto *IT = dyn_cast<BitIntType>(CanonicalType))
2280 return IT->isSigned();
2281 if (
const auto *IT = dyn_cast<DependentBitIntType>(CanonicalType))
2282 return IT->isSigned();
2284 if (
const auto *OBT = dyn_cast<OverflowBehaviorType>(CanonicalType))
2285 return OBT->getUnderlyingType()->isSignedIntegerType();
2291 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
2292 return BT->isSignedInteger();
2295 if (!ED->isComplete())
2297 return ED->getIntegerType()->isSignedIntegerType();
2300 if (
const auto *IT = dyn_cast<BitIntType>(CanonicalType))
2301 return IT->isSigned();
2302 if (
const auto *IT = dyn_cast<DependentBitIntType>(CanonicalType))
2303 return IT->isSigned();
2305 if (
const auto *OBT = dyn_cast<OverflowBehaviorType>(CanonicalType))
2306 return OBT->getUnderlyingType()->isSignedIntegerOrEnumerationType();
2312 if (
const auto *VT = dyn_cast<VectorType>(CanonicalType))
2313 return VT->getElementType()->isSignedIntegerOrEnumerationType();
2315 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType)) {
2316 switch (BT->getKind()) {
2317#define SVE_VECTOR_TYPE_INT(Name, MangledName, Id, SingletonId, NumEls, \
2318 ElBits, NF, IsSigned) \
2319 case BuiltinType::Id: \
2321#include "clang/Basic/AArch64ACLETypes.def"
2334 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
2335 return BT->isUnsignedInteger();
2340 if (!ED->isComplete() || ED->isScoped())
2342 return ED->getIntegerType()->isUnsignedIntegerType();
2345 if (
const auto *IT = dyn_cast<BitIntType>(CanonicalType))
2346 return IT->isUnsigned();
2347 if (
const auto *IT = dyn_cast<DependentBitIntType>(CanonicalType))
2348 return IT->isUnsigned();
2350 if (
const auto *OBT = dyn_cast<OverflowBehaviorType>(CanonicalType))
2351 return OBT->getUnderlyingType()->isUnsignedIntegerType();
2357 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
2358 return BT->isUnsignedInteger();
2361 if (!ED->isComplete())
2363 return ED->getIntegerType()->isUnsignedIntegerType();
2366 if (
const auto *IT = dyn_cast<BitIntType>(CanonicalType))
2367 return IT->isUnsigned();
2368 if (
const auto *IT = dyn_cast<DependentBitIntType>(CanonicalType))
2369 return IT->isUnsigned();
2371 if (
const auto *OBT = dyn_cast<OverflowBehaviorType>(CanonicalType))
2372 return OBT->getUnderlyingType()->isUnsignedIntegerOrEnumerationType();
2378 if (
const auto *VT = dyn_cast<VectorType>(CanonicalType))
2379 return VT->getElementType()->isUnsignedIntegerOrEnumerationType();
2380 if (
const auto *VT = dyn_cast<MatrixType>(CanonicalType))
2381 return VT->getElementType()->isUnsignedIntegerOrEnumerationType();
2382 if (CanonicalType->isSveVLSBuiltinType()) {
2384 return VT->getKind() >= BuiltinType::SveUint8 &&
2385 VT->getKind() <= BuiltinType::SveUint64;
2391 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
2392 return BT->isFloatingPoint();
2393 if (
const auto *CT = dyn_cast<ComplexType>(CanonicalType))
2394 return CT->getElementType()->isFloatingType();
2399 if (
const auto *VT = dyn_cast<VectorType>(CanonicalType))
2400 return VT->getElementType()->isFloatingType();
2401 if (
const auto *MT = dyn_cast<MatrixType>(CanonicalType))
2402 return MT->getElementType()->isFloatingType();
2407 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
2408 return BT->isFloatingPoint();
2413 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
2414 return BT->getKind() >= BuiltinType::Bool &&
2415 BT->getKind() <= BuiltinType::Ibm128;
2416 if (
const auto *ET = dyn_cast<EnumType>(CanonicalType)) {
2417 const auto *ED = ET->getDecl();
2418 return !ED->isScoped() && ED->getDefinitionOrSelf()->isComplete();
2424 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
2425 return BT->getKind() >= BuiltinType::Bool &&
2426 BT->getKind() <= BuiltinType::Ibm128;
2427 if (
const auto *ET = dyn_cast<EnumType>(CanonicalType)) {
2434 const auto *ED = ET->getDecl();
2435 return !ED->isScoped() && ED->getDefinitionOrSelf()->isComplete();
2446 if (
const auto *VT = dyn_cast<VectorType>(CanonicalType))
2447 return VT->getElementType()->isBooleanType();
2449 return ED->isComplete() && ED->getIntegerType()->isBooleanType();
2450 if (
const auto *IT = dyn_cast<BitIntType>(CanonicalType))
2451 return IT->getNumBits() == 1;
2458 const Type *T = CanonicalType.getTypePtr();
2459 if (
const auto *BT = dyn_cast<BuiltinType>(T)) {
2460 if (BT->getKind() == BuiltinType::Bool)
2462 if (BT->getKind() == BuiltinType::NullPtr)
2464 if (BT->isInteger())
2466 if (BT->isFloatingPoint())
2468 if (BT->isFixedPointType())
2470 llvm_unreachable(
"unknown scalar builtin type");
2480 assert(T->castAsEnumDecl()->isComplete());
2482 }
else if (
const auto *CT = dyn_cast<ComplexType>(T)) {
2483 if (CT->getElementType()->isRealFloatingType())
2492 llvm_unreachable(
"unknown scalar type");
2505 if (
const auto *
Record = dyn_cast<RecordType>(CanonicalType)) {
2506 if (
const auto *ClassDecl = dyn_cast<CXXRecordDecl>(
Record->getDecl()))
2507 return ClassDecl->isAggregate();
2519 assert(!
isIncompleteType() &&
"This doesn't make sense for incomplete types");
2520 assert(!
isDependentType() &&
"This doesn't make sense for dependent types");
2532 switch (CanonicalType->getTypeClass()) {
2543 return !EnumD->isComplete();
2551 return !Rec->isCompleteDefinition();
2553 case InjectedClassName: {
2555 if (!Rec->isBeingDefined())
2569 ->isIncompleteType(Def);
2570 case IncompleteArray:
2573 case MemberPointer: {
2586 if (!Context.getTargetInfo().getCXXABI().isMicrosoft())
2589 if (RD->
hasAttr<MSInheritanceAttr>())
2596 ->isIncompleteType(Def);
2597 case ObjCInterface: {
2629 switch (BT->getKind()) {
2631#define WASM_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
2632#include "clang/Basic/WebAssemblyReferenceTypes.def"
2634#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
2635#include "clang/Basic/HLSLIntangibleTypes.def"
2637 case BuiltinType::AMDGPUFeaturePredicate:
2648 return BT->getKind() == BuiltinType::WasmExternRef;
2653 if (
const auto *ATy = dyn_cast<ArrayType>(
this))
2654 return ATy->getElementType().isWebAssemblyReferenceType();
2656 if (
const auto *PTy = dyn_cast<PointerType>(
this))
2657 return PTy->getPointeeType().isWebAssemblyReferenceType();
2670 switch (BT->getKind()) {
2672#define SVE_VECTOR_TYPE(Name, MangledName, Id, SingletonId) \
2673 case BuiltinType::Id: \
2675#define SVE_OPAQUE_TYPE(Name, MangledName, Id, SingletonId) \
2676 case BuiltinType::Id: \
2678#define SVE_PREDICATE_TYPE(Name, MangledName, Id, SingletonId) \
2679 case BuiltinType::Id: \
2681#include "clang/Basic/AArch64ACLETypes.def"
2691 switch (BT->getKind()) {
2692#define RVV_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
2693#include "clang/Basic/RISCVVTypes.def"
2704 switch (BT->getKind()) {
2705 case BuiltinType::SveInt8:
2706 case BuiltinType::SveInt16:
2707 case BuiltinType::SveInt32:
2708 case BuiltinType::SveInt64:
2709 case BuiltinType::SveUint8:
2710 case BuiltinType::SveUint16:
2711 case BuiltinType::SveUint32:
2712 case BuiltinType::SveUint64:
2713 case BuiltinType::SveFloat16:
2714 case BuiltinType::SveFloat32:
2715 case BuiltinType::SveFloat64:
2716 case BuiltinType::SveBFloat16:
2717 case BuiltinType::SveBool:
2718 case BuiltinType::SveBoolx2:
2719 case BuiltinType::SveBoolx4:
2720 case BuiltinType::SveMFloat8:
2738 llvm_unreachable(
"Unhandled type");
2745 if (BTy->
getKind() == BuiltinType::SveBool)
2756 switch (BT->getKind()) {
2757#define RVV_VECTOR_TYPE(Name, Id, SingletonId, NumEls, ElBits, NF, IsSigned, \
2759 case BuiltinType::Id: \
2761#define RVV_PREDICATE_TYPE(Name, Id, SingletonId, NumEls) \
2762 case BuiltinType::Id: \
2764#include "clang/Basic/RISCVVTypes.def"
2778#define RVV_PREDICATE_TYPE(Name, Id, SingletonId, NumEls) \
2779 case BuiltinType::Id: \
2780 return Ctx.UnsignedCharTy;
2783#include "clang/Basic/RISCVVTypes.def"
2786 llvm_unreachable(
"Unhandled type");
2791 if (Context.getLangOpts().CPlusPlus11)
2804 if ((*this)->isIncompleteArrayType())
2805 return Context.getBaseElementType(*this).isCXX98PODType(Context);
2807 if ((*this)->isIncompleteType())
2816 if (Context.containsAddressDiscriminatedPointerAuth(CanonicalType))
2823 case Type::VariableArray:
2824 case Type::ConstantArray:
2826 return Context.getBaseElementType(*this).isCXX98PODType(Context);
2828 case Type::ObjCObjectPointer:
2829 case Type::BlockPointer:
2833 case Type::MemberPointer:
2835 case Type::ExtVector:
2837 case Type::OverflowBehavior:
2844 if (
const auto *ClassDecl =
2846 return ClassDecl->isPOD();
2860 if ((*this)->isArrayType())
2861 return Context.getBaseElementType(*this).isTrivialType(Context);
2863 if ((*this)->isSizelessBuiltinType())
2868 if ((*this)->isIncompleteType())
2880 if (Context.containsAddressDiscriminatedPointerAuth(CanonicalType))
2899 return ClassDecl->hasTrivialDefaultConstructor() &&
2900 !ClassDecl->hasNonTrivialDefaultConstructor() &&
2901 ClassDecl->isTriviallyCopyable();
2913 bool IsCopyConstructible) {
2914 if (
type->isArrayType())
2916 Context, IsCopyConstructible);
2918 if (
type.hasNonTrivialObjCLifetime())
2952 if (
const auto *ClassDecl = dyn_cast<CXXRecordDecl>(RD)) {
2953 if (IsCopyConstructible)
2954 return ClassDecl->isTriviallyCopyConstructible();
2955 return ClassDecl->isTriviallyCopyable();
2957 return !RD->isNonTrivialToPrimitiveCopy();
2971 if (CanonicalType.hasNonTrivialObjCLifetime())
2973 if (CanonicalType->isArrayType())
2974 return Context.getBaseElementType(CanonicalType)
2975 .isBitwiseCloneableType(Context);
2977 if (CanonicalType->isIncompleteType())
2982 if (Context.containsAddressDiscriminatedPointerAuth(CanonicalType))
2985 const auto *RD = CanonicalType->getAsRecordDecl();
2989 if (RD->isInvalidDecl())
2995 if (RD->mayInsertExtraPadding())
2998 for (
auto *
const Field : RD->fields()) {
2999 if (!Field->getType().isBitwiseCloneableType(Context))
3003 if (
const auto *CXXRD = dyn_cast<CXXRecordDecl>(RD)) {
3004 for (
auto Base : CXXRD->bases())
3005 if (!
Base.getType().isBitwiseCloneableType(Context))
3007 for (
auto VBase : CXXRD->vbases())
3008 if (!VBase.getType().isBitwiseCloneableType(Context))
3021 return !Context.getLangOpts().ObjCAutoRefCount &&
3022 Context.getLangOpts().ObjCWeak &&
3055 return OBT->getBehaviorKind() ==
3056 OverflowBehaviorType::OverflowBehaviorKind::Wrap;
3063 return OBT->getBehaviorKind() ==
3064 OverflowBehaviorType::OverflowBehaviorKind::Trap;
3071 if (
const auto *RD =
3087 if (
const auto *RD =
3127 assert(BaseTy &&
"NULL element type");
3161 if (
const auto *ClassDecl = dyn_cast<CXXRecordDecl>(RD))
3162 return ClassDecl->isLiteral();
3169 return AT->getValueType()->isLiteralType(Ctx);
3171 if (
const auto *OBT = BaseTy->
getAs<OverflowBehaviorType>())
3172 return OBT->getUnderlyingType()->isLiteralType(Ctx);
3194 return RD->isStructural();
3207 assert(BaseTy &&
"NULL element type");
3218 if (
const auto *ClassDecl = dyn_cast<CXXRecordDecl>(RD);
3219 ClassDecl && !ClassDecl->isStandardLayout())
3247 assert(BaseTy &&
"NULL element type");
3258 if (Context.containsAddressDiscriminatedPointerAuth(*
this))
3265 if (
const auto *ClassDecl = dyn_cast<CXXRecordDecl>(RD)) {
3268 if (!ClassDecl->isTrivial())
3274 if (!ClassDecl->isStandardLayout())
3305 const auto *ED = ET->getDecl();
3307 if (II && II->
isStr(
"align_val_t") && ED->isInStdNamespace())
3315 const auto *ED = ET->getDecl();
3317 if (II && II->
isStr(
"byte") && ED->isInStdNamespace())
3333 case TemplateTypeParm:
3334 case SubstTemplateTypeParm:
3335 case TemplateSpecialization:
3378 llvm_unreachable(
"Type specifier is not a tag type kind.");
3395 llvm_unreachable(
"Unknown tag type kind.");
3413 llvm_unreachable(
"Elaborated type keyword is not a tag type kind.");
3415 llvm_unreachable(
"Unknown elaborated type keyword.");
3430 llvm_unreachable(
"Unknown elaborated type keyword.");
3444 return "__interface";
3451 llvm_unreachable(
"Unknown elaborated type keyword.");
3456 if (
const auto *TST = dyn_cast<TemplateSpecializationType>(
this))
3458 else if (
const auto *DepName = dyn_cast<DependentNameType>(
this))
3459 Keyword = DepName->getKeyword();
3460 else if (
const auto *T = dyn_cast<TagType>(
this))
3462 else if (
const auto *T = dyn_cast<TypedefType>(
this))
3464 else if (
const auto *T = dyn_cast<UnresolvedUsingType>(
this))
3466 else if (
const auto *T = dyn_cast<UsingType>(
this))
3476#define ABSTRACT_TYPE(Derived, Base)
3477#define TYPE(Derived, Base) \
3480#include "clang/AST/TypeNodes.inc"
3483 llvm_unreachable(
"Invalid type class.");
3491 return Policy.
Bool ?
"bool" :
"_Bool";
3497 return "signed char";
3509 return "unsigned char";
3511 return "unsigned short";
3513 return "unsigned int";
3515 return "unsigned long";
3517 return "unsigned long long";
3519 return "unsigned __int128";
3521 return Policy.
Half ?
"half" :
"__fp16";
3529 return "long double";
3531 return "short _Accum";
3535 return "long _Accum";
3537 return "unsigned short _Accum";
3539 return "unsigned _Accum";
3541 return "unsigned long _Accum";
3542 case BuiltinType::ShortFract:
3543 return "short _Fract";
3544 case BuiltinType::Fract:
3546 case BuiltinType::LongFract:
3547 return "long _Fract";
3548 case BuiltinType::UShortFract:
3549 return "unsigned short _Fract";
3550 case BuiltinType::UFract:
3551 return "unsigned _Fract";
3552 case BuiltinType::ULongFract:
3553 return "unsigned long _Fract";
3554 case BuiltinType::SatShortAccum:
3555 return "_Sat short _Accum";
3556 case BuiltinType::SatAccum:
3557 return "_Sat _Accum";
3558 case BuiltinType::SatLongAccum:
3559 return "_Sat long _Accum";
3560 case BuiltinType::SatUShortAccum:
3561 return "_Sat unsigned short _Accum";
3562 case BuiltinType::SatUAccum:
3563 return "_Sat unsigned _Accum";
3564 case BuiltinType::SatULongAccum:
3565 return "_Sat unsigned long _Accum";
3566 case BuiltinType::SatShortFract:
3567 return "_Sat short _Fract";
3568 case BuiltinType::SatFract:
3569 return "_Sat _Fract";
3570 case BuiltinType::SatLongFract:
3571 return "_Sat long _Fract";
3572 case BuiltinType::SatUShortFract:
3573 return "_Sat unsigned short _Fract";
3574 case BuiltinType::SatUFract:
3575 return "_Sat unsigned _Fract";
3576 case BuiltinType::SatULongFract:
3577 return "_Sat unsigned long _Fract";
3581 return "__float128";
3586 return Policy.
MSWChar ?
"__wchar_t" :
"wchar_t";
3596 return "<overloaded function type>";
3598 return "<bound member function type>";
3599 case UnresolvedTemplate:
3600 return "<unresolved template type>";
3602 return "<pseudo-object type>";
3604 return "<dependent type>";
3606 return "<unknown type>";
3607 case ARCUnbridgedCast:
3608 return "<ARC unbridged cast type>";
3610 return "<builtin fn type>";
3617#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
3619 return "__" #Access " " #ImgType "_t";
3620#include "clang/Basic/OpenCLImageTypes.def"
3626 return "clk_event_t";
3630 return "reserve_id_t";
3631 case IncompleteMatrixIdx:
3632 return "<incomplete matrix index type>";
3634 return "<array section type>";
3635 case OMPArrayShaping:
3636 return "<OpenMP array shaping type>";
3638 return "<OpenMP iterator type>";
3639#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \
3642#include "clang/Basic/OpenCLExtensionTypes.def"
3643#define SVE_TYPE(Name, Id, SingletonId) \
3646#include "clang/Basic/AArch64ACLETypes.def"
3647#define PPC_VECTOR_TYPE(Name, Id, Size) \
3650#include "clang/Basic/PPCTypes.def"
3651#define RVV_TYPE(Name, Id, SingletonId) \
3654#include "clang/Basic/RISCVVTypes.def"
3655#define WASM_TYPE(Name, Id, SingletonId) \
3658#include "clang/Basic/WebAssemblyReferenceTypes.def"
3659#define AMDGPU_TYPE(Name, Id, SingletonId, Width, Align) \
3662#include "clang/Basic/AMDGPUTypes.def"
3663#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) \
3666#include "clang/Basic/HLSLIntangibleTypes.def"
3669 llvm_unreachable(
"Invalid builtin type.");
3674 if (
auto *PET = dyn_cast<PackExpansionType>(
getTypePtr()))
3675 return PET->getPattern();
3680 if (
const auto *RefType =
getTypePtr()->getAs<ReferenceType>())
3688 if (!Context.getLangOpts().CPlusPlus ||
3697 return FPT->hasCFIUncheckedCallee();
3714 return "vectorcall";
3726 return "aarch64_vector_pcs";
3728 return "aarch64_sve_pcs";
3730 return "intel_ocl_bicc";
3732 return "spir_function";
3734 return "device_kernel";
3738 return "swiftasynccall";
3740 return "preserve_most";
3742 return "preserve_all";
3746 return "preserve_none";
3749#define CC_VLS_CASE(ABI_VLEN) \
3750 case CC_RISCVVLSCall_##ABI_VLEN: return "riscv_vls_cc(" #ABI_VLEN ")";
3767 llvm_unreachable(
"Invalid calling convention.");
3785 assert(
getNumParams() == params.size() &&
"NumParams overflow!");
3794 auto &ExtraBits = *getTrailingObjects<FunctionTypeExtraBitfields>();
3802 auto &ExtraAttrInfo = *getTrailingObjects<FunctionTypeExtraAttributeInfo>();
3806 auto &ExtraBits = *getTrailingObjects<FunctionTypeExtraBitfields>();
3807 ExtraBits.HasExtraAttributeInfo =
true;
3811 auto &ArmTypeAttrs = *getTrailingObjects<FunctionTypeArmAttributes>();
3812 ArmTypeAttrs = FunctionTypeArmAttributes();
3815 auto &ExtraBits = *getTrailingObjects<FunctionTypeExtraBitfields>();
3816 ExtraBits.HasArmTypeAttributes =
true;
3820 auto *argSlot = getTrailingObjects<QualType>();
3823 ~TypeDependence::VariablyModified);
3824 argSlot[i] = params[i];
3829 auto &ArmTypeAttrs = *getTrailingObjects<FunctionTypeArmAttributes>();
3831 "Not enough bits to encode SME attributes");
3837 auto &ExtraBits = *getTrailingObjects<FunctionTypeExtraBitfields>();
3839 assert(NumExceptions <= 1023 &&
"Not enough bits to encode exceptions");
3840 ExtraBits.NumExceptionType = NumExceptions;
3842 assert(hasExtraBitfields() &&
"missing trailing extra bitfields!");
3844 reinterpret_cast<QualType *
>(getTrailingObjects<ExceptionType>());
3852 (TypeDependence::Instantiation | TypeDependence::UnexpandedPack));
3854 exnSlot[I++] = ExceptionType;
3868 (TypeDependence::Instantiation | TypeDependence::UnexpandedPack));
3874 auto **slot = getTrailingObjects<FunctionDecl *>();
3882 auto **slot = getTrailingObjects<FunctionDecl *>();
3901 auto *extParamInfos = getTrailingObjects<ExtParameterInfo>();
3908 *getTrailingObjects<Qualifiers>() = epi.
TypeQuals;
3915 auto &EllipsisLoc = *getTrailingObjects<SourceLocation>();
3920 auto &ExtraBits = *getTrailingObjects<FunctionTypeExtraBitfields>();
3922 ExtraBits.NumFunctionEffects = EffectsCount;
3923 assert(ExtraBits.NumFunctionEffects == EffectsCount &&
3924 "effect bitfield overflow");
3927 auto *DestFX = getTrailingObjects<FunctionEffect>();
3928 llvm::uninitialized_copy(SrcFX, DestFX);
3931 if (!SrcConds.empty()) {
3932 ExtraBits.EffectsHaveConditions =
true;
3933 auto *DestConds = getTrailingObjects<EffectConditionExpr>();
3934 llvm::uninitialized_copy(SrcConds, DestConds);
3935 assert(llvm::any_of(SrcConds,
3936 [](
const EffectConditionExpr &EC) {
3938 return E->isTypeDependent() ||
3939 E->isValueDependent();
3942 "expected a dependent expression among the conditions");
3950 return NE->isValueDependent();
3962 return NE->isInstantiationDependent();
3973 llvm_unreachable(
"should not call this with unresolved exception specs");
3999 llvm_unreachable(
"unexpected exception specification kind");
4003 for (
unsigned ArgIdx =
getNumParams(); ArgIdx; --ArgIdx)
4011 const QualType *ArgTys,
unsigned NumParams,
4012 const ExtProtoInfo &epi,
4036 ID.AddPointer(
Result.getAsOpaquePtr());
4037 for (
unsigned i = 0; i != NumParams; ++i)
4038 ID.AddPointer(ArgTys[i].getAsOpaquePtr());
4042 assert(!(
unsigned(epi.Variadic) & ~1) && !(
unsigned(epi.RefQualifier) & ~3) &&
4043 !(
unsigned(epi.ExceptionSpec.Type) & ~15) &&
4044 "Values larger than expected.");
4045 ID.AddInteger(
unsigned(epi.Variadic) + (epi.RefQualifier << 1) +
4046 (epi.ExceptionSpec.Type << 3));
4047 ID.Add(epi.TypeQuals);
4049 for (
QualType Ex : epi.ExceptionSpec.Exceptions)
4052 epi.ExceptionSpec.NoexceptExpr->Profile(ID, Context, Canonical);
4055 ID.AddPointer(epi.ExceptionSpec.SourceDecl->getCanonicalDecl());
4057 if (epi.ExtParameterInfos) {
4058 for (
unsigned i = 0; i != NumParams; ++i)
4059 ID.AddInteger(epi.ExtParameterInfos[i].getOpaqueValue());
4062 epi.ExtInfo.Profile(ID);
4063 epi.ExtraAttributeInfo.Profile(ID);
4065 unsigned EffectCount = epi.FunctionEffects.size();
4066 bool HasConds = !epi.FunctionEffects.Conditions.empty();
4068 ID.AddInteger((EffectCount << 3) | (HasConds << 2) |
4069 (epi.AArch64SMEAttributes << 1) | epi.HasTrailingReturn);
4070 ID.AddInteger(epi.CFIUncheckedCallee);
4072 for (
unsigned Idx = 0; Idx != EffectCount; ++Idx) {
4073 ID.AddInteger(epi.FunctionEffects.Effects[Idx].toOpaqueInt32());
4075 ID.AddPointer(epi.FunctionEffects.Conditions[Idx].getCondition());
4086 : Data(D, Deref << DerefShift) {}
4089 return Data.getInt() & DerefMask;
4094 return Data.getOpaqueValue();
4101 Data.setFromOpaqueValue(
V);
4104OverflowBehaviorType::OverflowBehaviorType(
4106 OverflowBehaviorType::OverflowBehaviorKind Kind)
4107 :
Type(OverflowBehavior, Canon, Underlying->getDependence()),
4108 UnderlyingType(Underlying), BehaviorKind(Kind) {}
4114CountAttributedType::CountAttributedType(
4118 CountExpr(CountExpr) {
4122 auto *DeclSlot = getTrailingObjects();
4123 llvm::copy(CoupledDecls, DeclSlot);
4132#define ENUMERATE_ATTRS(PREFIX) \
4134 if (isCountInBytes()) { \
4136 return PREFIX "sized_by_or_null"; \
4137 return PREFIX "sized_by"; \
4140 return PREFIX "counted_by_or_null"; \
4141 return PREFIX "counted_by"; \
4144 if (WithMacroPrefix)
4149#undef ENUMERATE_ATTRS
4155 bool HasTypeDifferentFromDecl)
4157 Keyword, TC, UnderlyingType.getCanonicalType(),
4161 ~NestedNameSpecifierDependence::
Dependent)
4165 *getTrailingObjects<NestedNameSpecifier>() = Qualifier;
4166 if ((
TypedefBits.hasTypeDifferentFromDecl = HasTypeDifferentFromDecl))
4167 *getTrailingObjects<QualType>() = UnderlyingType;
4172 : *getTrailingObjects<QualType>();
4178 const Type *CanonicalType)
4184 ~NestedNameSpecifierDependence::
Dependent)
4188 *getTrailingObjects<NestedNameSpecifier>() = Qualifier;
4197 if ((
UsingBits.hasQualifier = !!Qualifier))
4198 *getTrailingObjects() = Qualifier;
4207 while (
auto *InnerMQT = dyn_cast<MacroQualifiedType>(Inner)) {
4210 Inner = InnerMQT->getModifiedType();
4221 ? Context.getUnqualifiedArrayType(Can).getAtomicUnqualifiedType()
4226 TOExpr(E), Context(Context) {
4227 TypeOfBits.Kind =
static_cast<unsigned>(Kind);
4236 ? Context.getUnqualifiedArrayType(QT).getAtomicUnqualifiedType()
4245 E->
Profile(ID, Context,
true);
4246 ID.AddBoolean(IsUnqual);
4253 ? Context.getUnqualifiedArrayType(Can).getAtomicUnqualifiedType()
4255 T->getDependence()),
4256 TOType(T), Context(Context) {
4257 TypeOfBits.Kind =
static_cast<unsigned>(Kind);
4260QualType TypeOfType::desugar()
const {
4263 ? Context.getUnqualifiedArrayType(QT).getAtomicUnqualifiedType()
4271 :
Type(Decltype, can,
4275 (E->
getType()->getDependence() &
4277 E(E), UnderlyingType(underlyingType) {}
4279bool DecltypeType::isSugared()
const {
return !E->isInstantiationDependent(); }
4281QualType DecltypeType::desugar()
const {
4288DependentDecltypeType::DependentDecltypeType(
Expr *E)
4291void DependentDecltypeType::Profile(llvm::FoldingSetNodeID &ID,
4293 E->
Profile(ID, Context,
true);
4297 Expr *IndexExpr,
bool FullySubstituted,
4299 :
Type(PackIndexing, Canonical,
4301 Pattern(Pattern), IndexExpr(IndexExpr),
Size(Expansions.size()),
4302 FullySubstituted(FullySubstituted) {
4304 llvm::uninitialized_copy(Expansions, getTrailingObjects());
4308 if (isInstantiationDependentType())
4309 return std::nullopt;
4311 ConstantExpr *CE = dyn_cast<ConstantExpr>(getIndexExpr());
4313 return std::nullopt;
4315 assert(Index.isNonNegative() &&
"Invalid index");
4316 return static_cast<unsigned>(Index.getExtValue());
4320PackIndexingType::computeDependence(
QualType Pattern,
Expr *IndexExpr,
4325 ? TypeDependence::DependentInstantiation
4326 : TypeDependence::None);
4327 if (Expansions.empty())
4328 TD |= Pattern->
getDependence() & TypeDependence::DependentInstantiation;
4330 for (
const QualType &T : Expansions)
4333 if (!(IndexD & TypeDependence::UnexpandedPack))
4339 TD |= TypeDependence::Error | TypeDependence::DependentInstantiation;
4344void PackIndexingType::Profile(llvm::FoldingSetNodeID &ID,
4346 Profile(ID, Context, getPattern(), getIndexExpr(), isFullySubstituted(),
4350void PackIndexingType::Profile(llvm::FoldingSetNodeID &ID,
4352 Expr *E,
bool FullySubstituted,
4355 E->
Profile(ID, Context,
true);
4356 ID.AddBoolean(FullySubstituted);
4357 if (!Expansions.empty()) {
4358 ID.AddInteger(Expansions.size());
4360 T.getCanonicalType().
Profile(ID);
4366UnaryTransformType::UnaryTransformType(
QualType BaseType,
4367 QualType UnderlyingType, UTTKind UKind,
4369 :
Type(UnaryTransform, CanonicalType, BaseType->getDependence()),
4370 BaseType(BaseType), UnderlyingType(UnderlyingType), UKind(UKind) {}
4374 bool OwnsTag,
bool ISInjected,
const Type *CanonicalType)
4381 ~NestedNameSpecifierDependence::
Dependent)
4385 getTrailingQualifier() = Qualifier;
4390void *TagType::getTrailingPointer()
const {
4391 switch (getTypeClass()) {
4396 case Type::InjectedClassName:
4397 return const_cast<InjectedClassNameType *
>(
4400 llvm_unreachable(
"unexpected type class");
4405 assert(TagTypeBits.HasQualifier);
4407 getTrailingPointer(), llvm::Align::Of<NestedNameSpecifier *>()));
4411 return TagTypeBits.HasQualifier ? getTrailingQualifier() : std::nullopt;
4415 auto *
Decl = dyn_cast<CXXRecordDecl>(
decl);
4418 if (
auto *RD = dyn_cast<ClassTemplateSpecializationDecl>(
Decl))
4419 return RD->getSpecializedTemplate();
4420 return Decl->getDescribedClassTemplate();
4424 auto *TD = getTemplateDecl();
4427 if (isCanonicalUnqualified())
4434TagType::getTemplateArgs(
const ASTContext &Ctx)
const {
4435 auto *
Decl = dyn_cast<CXXRecordDecl>(
decl);
4439 if (
auto *RD = dyn_cast<ClassTemplateSpecializationDecl>(
Decl))
4440 return RD->getTemplateArgs().asArray();
4442 return TD->getTemplateParameters()->getInjectedTemplateArgs(Ctx);
4446bool RecordType::hasConstFields()
const {
4447 std::vector<const RecordType *> RecordTypeList;
4448 RecordTypeList.push_back(
this);
4449 unsigned NextToCheckIndex = 0;
4451 while (RecordTypeList.size() > NextToCheckIndex) {
4452 for (
FieldDecl *FD : RecordTypeList[NextToCheckIndex]
4454 ->getDefinitionOrSelf()
4460 if (
const auto *FieldRecTy = FieldTy->
getAsCanonical<RecordType>()) {
4461 if (!llvm::is_contained(RecordTypeList, FieldRecTy))
4462 RecordTypeList.push_back(FieldRecTy);
4472 const TagDecl *TD,
bool IsInjected,
4473 const Type *CanonicalType)
4475 false, IsInjected, CanonicalType) {}
4484 :
Type(Attributed, canon, equivalent->getDependence()), Attribute(
attr),
4485 ModifiedType(modified), EquivalentType(equivalent) {
4487 assert(!attr ||
attr->getKind() == attrKind);
4490bool AttributedType::isQualifier()
const {
4492 switch (getAttrKind()) {
4497 case attr::ObjCOwnership:
4498 case attr::ObjCInertUnsafeUnretained:
4499 case attr::TypeNonNull:
4500 case attr::TypeNullable:
4501 case attr::TypeNullableResult:
4502 case attr::TypeNullUnspecified:
4503 case attr::LifetimeBound:
4504 case attr::AddressSpace:
4514bool AttributedType::isMSTypeSpec()
const {
4516 switch (getAttrKind()) {
4525 llvm_unreachable(
"invalid attr kind");
4528bool AttributedType::isWebAssemblyFuncrefSpec()
const {
4529 return getAttrKind() == attr::WebAssemblyFuncref;
4532bool AttributedType::isCallingConv()
const {
4534 switch (getAttrKind()) {
4539 case attr::FastCall:
4541 case attr::ThisCall:
4543 case attr::SwiftCall:
4544 case attr::SwiftAsyncCall:
4545 case attr::VectorCall:
4546 case attr::AArch64VectorPcs:
4547 case attr::AArch64SVEPcs:
4548 case attr::DeviceKernel:
4552 case attr::IntelOclBicc:
4553 case attr::PreserveMost:
4554 case attr::PreserveAll:
4556 case attr::PreserveNone:
4557 case attr::RISCVVectorCC:
4558 case attr::RISCVVLSCC:
4561 llvm_unreachable(
"invalid attr kind");
4565 return isCanonicalUnqualified() ?
nullptr : getDecl()->getIdentifier();
4568SubstTemplateTypeParmType::SubstTemplateTypeParmType(
QualType Replacement,
4569 Decl *AssociatedDecl,
4573 :
Type(SubstTemplateTypeParm, Replacement.getCanonicalType(),
4574 Replacement->getDependence()),
4575 AssociatedDecl(AssociatedDecl) {
4579 *getTrailingObjects() = Replacement;
4585 assert(AssociatedDecl !=
nullptr);
4589SubstTemplateTypeParmType::getReplacedParameter()
const {
4594void SubstTemplateTypeParmType::Profile(llvm::FoldingSetNodeID &ID,
4596 const Decl *AssociatedDecl,
4599 Replacement.Profile(ID);
4600 ID.AddPointer(AssociatedDecl);
4601 ID.AddInteger(Index);
4603 ID.AddBoolean(Final);
4606SubstPackType::SubstPackType(TypeClass Derived,
QualType Canon,
4608 :
Type(Derived, Canon,
4612 assert(llvm::all_of(
4614 [](
auto &P) { return P.getKind() == TemplateArgument::Type; }) &&
4615 "non-type argument to SubstPackType?");
4623void SubstPackType::Profile(llvm::FoldingSetNodeID &ID) {
4624 Profile(ID, getArgumentPack());
4627void SubstPackType::Profile(llvm::FoldingSetNodeID &ID,
4631 ID.AddPointer(P.getAsType().getAsOpaquePtr());
4634SubstTemplateTypeParmPackType::SubstTemplateTypeParmPackType(
4635 QualType Canon,
Decl *AssociatedDecl,
unsigned Index,
bool Final,
4637 : SubstPackType(SubstTemplateTypeParmPack, Canon, ArgPack),
4638 AssociatedDeclAndFinal(AssociatedDecl, Final) {
4639 assert(AssociatedDecl !=
nullptr);
4642 assert(getNumArgs() == ArgPack.
pack_size() &&
4643 "Parent bitfields in SubstPackType were overwritten."
4644 "Check NumSubstPackTypeBits.");
4647Decl *SubstTemplateTypeParmPackType::getAssociatedDecl()
const {
4648 return AssociatedDeclAndFinal.getPointer();
4651bool SubstTemplateTypeParmPackType::getFinal()
const {
4652 return AssociatedDeclAndFinal.getInt();
4656SubstTemplateTypeParmPackType::getReplacedParameter()
const {
4661IdentifierInfo *SubstTemplateTypeParmPackType::getIdentifier()
const {
4662 return getReplacedParameter()->getIdentifier();
4665void SubstTemplateTypeParmPackType::Profile(llvm::FoldingSetNodeID &ID) {
4666 Profile(ID, getAssociatedDecl(),
getIndex(), getFinal(), getArgumentPack());
4669void SubstTemplateTypeParmPackType::Profile(llvm::FoldingSetNodeID &ID,
4670 const Decl *AssociatedDecl,
4671 unsigned Index,
bool Final,
4673 ID.AddPointer(AssociatedDecl);
4674 ID.AddInteger(Index);
4675 ID.AddBoolean(Final);
4676 SubstPackType::Profile(ID, ArgPack);
4679SubstBuiltinTemplatePackType::SubstBuiltinTemplatePackType(
4681 : SubstPackType(SubstBuiltinTemplatePack, Canon, ArgPack) {}
4683bool TemplateSpecializationType::anyDependentTemplateArguments(
4686 return anyDependentTemplateArguments(Args.
arguments(), Converted);
4689bool TemplateSpecializationType::anyDependentTemplateArguments(
4692 if (Arg.isDependent())
4697bool TemplateSpecializationType::anyInstantiationDependentTemplateArguments(
4700 if (ArgLoc.getArgument().isInstantiationDependent())
4709 ? TypeDependence::DependentInstantiation
4714 D |= TypeDependence::UnexpandedPack;
4716 D |= (Underlying->
getDependence() & TypeDependence::UnexpandedPack);
4721TemplateSpecializationType::TemplateSpecializationType(
4725 Underlying.isNull() ?
QualType(this, 0)
4726 : Underlying.getCanonicalType(),
4729 TemplateSpecializationTypeBits.NumArgs = Args.size();
4730 TemplateSpecializationTypeBits.TypeAlias = IsAlias;
4732 auto *TemplateArgs =
4744 ~TypeDependence::Dependent);
4746 addDependence(Arg.getAsType()->getDependence() &
4747 TypeDependence::VariablyModified);
4754 *
reinterpret_cast<QualType *
>(TemplateArgs) = Underlying;
4757QualType TemplateSpecializationType::getAliasedType()
const {
4758 assert(isTypeAlias() &&
"not a type alias template specialization");
4759 return *
reinterpret_cast<const QualType *
>(template_arguments().end());
4762bool clang::TemplateSpecializationType::isSugared()
const {
4763 return !isDependentType() || isCurrentInstantiation() || isTypeAlias() ||
4768void TemplateSpecializationType::Profile(llvm::FoldingSetNodeID &ID,
4770 Profile(ID, getKeyword(),
Template, template_arguments(),
4771 isSugared() ? desugar() :
QualType(), Ctx);
4774void TemplateSpecializationType::Profile(llvm::FoldingSetNodeID &ID,
4780 ID.AddInteger(llvm::to_underlying(
Keyword));
4784 ID.AddInteger(Args.size());
4786 Arg.Profile(ID, Context);
4794 return Context.getQualifiedType(QT, *
this);
4798 const Type *T)
const {
4802 return Context.getQualifiedType(T, *
this);
4805void ObjCObjectTypeImpl::Profile(llvm::FoldingSetNodeID &ID,
QualType BaseType,
4809 ID.AddPointer(BaseType.getAsOpaquePtr());
4810 ID.AddInteger(typeArgs.size());
4811 for (
auto typeArg : typeArgs)
4812 ID.AddPointer(typeArg.getAsOpaquePtr());
4813 ID.AddInteger(protocols.size());
4814 for (
auto *proto : protocols)
4815 ID.AddPointer(proto);
4816 ID.AddBoolean(isKindOf);
4819void ObjCObjectTypeImpl::Profile(llvm::FoldingSetNodeID &ID) {
4820 Profile(ID, getBaseType(), getTypeArgsAsWritten(),
4822 isKindOfTypeAsWritten());
4825void ObjCTypeParamType::Profile(llvm::FoldingSetNodeID &ID,
4829 ID.AddPointer(OTPDecl);
4831 ID.AddInteger(protocols.size());
4832 for (
auto *proto : protocols)
4833 ID.AddPointer(proto);
4836void ObjCTypeParamType::Profile(llvm::FoldingSetNodeID &ID) {
4837 Profile(ID, getDecl(), getCanonicalTypeInternal(),
4844class CachedProperties {
4849 CachedProperties(
Linkage L,
bool local) : L(L), local(local) {}
4851 Linkage getLinkage()
const {
return L; }
4852 bool hasLocalOrUnnamedType()
const {
return local; }
4854 friend CachedProperties
merge(CachedProperties L, CachedProperties R) {
4856 return CachedProperties(MergedLinkage, L.hasLocalOrUnnamedType() ||
4857 R.hasLocalOrUnnamedType());
4876 return CachedProperties(T->TypeBits.getLinkage(),
4877 T->TypeBits.hasLocalOrUnnamedType());
4882 if (T->TypeBits.isCacheValid())
4887 if (!T->isCanonicalUnqualified()) {
4890 T->TypeBits.CacheValid =
true;
4891 T->TypeBits.CachedLinkage = CT->
TypeBits.CachedLinkage;
4892 T->TypeBits.CachedLocalOrUnnamed = CT->
TypeBits.CachedLocalOrUnnamed;
4898 T->TypeBits.CacheValid =
true;
4899 T->TypeBits.CachedLinkage = llvm::to_underlying(
Result.getLinkage());
4900 T->TypeBits.CachedLocalOrUnnamed =
Result.hasLocalOrUnnamedType();
4918 switch (T->getTypeClass()) {
4919#define TYPE(Class, Base)
4920#define NON_CANONICAL_TYPE(Class, Base) case Type::Class:
4921#include "clang/AST/TypeNodes.inc"
4922 llvm_unreachable(
"didn't expect a non-canonical type here");
4924#define TYPE(Class, Base)
4925#define DEPENDENT_TYPE(Class, Base) case Type::Class:
4926#define NON_CANONICAL_UNLESS_DEPENDENT_TYPE(Class, Base) case Type::Class:
4927#include "clang/AST/TypeNodes.inc"
4929 assert(T->isInstantiationDependentType());
4933 case Type::DeducedTemplateSpecialization:
4947 const auto *Tag =
cast<TagType>(T)->getDecl()->getDefinitionOrSelf();
4953 Linkage L = Tag->getLinkageInternal();
4954 bool IsLocalOrUnnamed = Tag->getDeclContext()->isFunctionOrMethod() ||
4955 !Tag->hasNameForLinkage();
4956 return CachedProperties(L, IsLocalOrUnnamed);
4966 case Type::BlockPointer:
4968 case Type::LValueReference:
4969 case Type::RValueReference:
4971 case Type::MemberPointer: {
4973 CachedProperties Cls = [&] {
4974 if (MPT->isSugared())
4976 return Cache::get(MPT->getQualifier().getAsType());
4978 return merge(Cls,
Cache::get(MPT->getPointeeType()));
4980 case Type::ConstantArray:
4981 case Type::IncompleteArray:
4982 case Type::VariableArray:
4983 case Type::ArrayParameter:
4986 case Type::ExtVector:
4988 case Type::ConstantMatrix:
4990 case Type::FunctionNoProto:
4992 case Type::FunctionProto: {
4994 CachedProperties result =
Cache::get(FPT->getReturnType());
4995 for (
const auto &ai : FPT->param_types())
4999 case Type::ObjCInterface: {
5001 return CachedProperties(L,
false);
5003 case Type::ObjCObject:
5005 case Type::ObjCObjectPointer:
5011 case Type::HLSLAttributedResource:
5013 case Type::HLSLInlineSpirv:
5015 case Type::OverflowBehavior:
5019 llvm_unreachable(
"unhandled type class");
5030 return TypeBits.hasLocalOrUnnamedType();
5034 switch (T->getTypeClass()) {
5035#define TYPE(Class, Base)
5036#define NON_CANONICAL_TYPE(Class, Base) case Type::Class:
5037#include "clang/AST/TypeNodes.inc"
5038 llvm_unreachable(
"didn't expect a non-canonical type here");
5040#define TYPE(Class, Base)
5041#define DEPENDENT_TYPE(Class, Base) case Type::Class:
5042#define NON_CANONICAL_UNLESS_DEPENDENT_TYPE(Class, Base) case Type::Class:
5043#include "clang/AST/TypeNodes.inc"
5045 assert(T->isInstantiationDependentType());
5053 case Type::DeducedTemplateSpecialization:
5065 case Type::BlockPointer:
5067 case Type::LValueReference:
5068 case Type::RValueReference:
5070 case Type::MemberPointer: {
5073 if (
auto *D = MPT->getMostRecentCXXRecordDecl()) {
5081 case Type::ConstantArray:
5082 case Type::IncompleteArray:
5083 case Type::VariableArray:
5084 case Type::ArrayParameter:
5087 case Type::ExtVector:
5089 case Type::ConstantMatrix:
5092 case Type::FunctionNoProto:
5094 case Type::FunctionProto: {
5097 for (
const auto &ai : FPT->param_types())
5101 case Type::ObjCInterface:
5103 case Type::ObjCObject:
5105 case Type::ObjCObjectPointer:
5112 case Type::OverflowBehavior:
5115 case Type::HLSLAttributedResource:
5117 ->getContainedType()
5118 ->getCanonicalTypeInternal());
5119 case Type::HLSLInlineSpirv:
5123 llvm_unreachable(
"unhandled type class");
5137 if (!T->isCanonicalUnqualified())
5151 while (
const auto *AT =
Type->getAs<AttributedType>()) {
5154 if (
auto Nullability = AT->getImmediateNullability())
5157 Type = AT->getEquivalentType();
5159 return std::nullopt;
5165 switch (
type->getTypeClass()) {
5166#define NON_CANONICAL_TYPE(Class, Parent) \
5169 llvm_unreachable("non-canonical type");
5170#define TYPE(Class, Parent)
5171#include "clang/AST/TypeNodes.inc"
5175 case Type::BlockPointer:
5176 case Type::MemberPointer:
5177 case Type::ObjCObjectPointer:
5181 case Type::UnresolvedUsing:
5182 case Type::TypeOfExpr:
5184 case Type::Decltype:
5185 case Type::PackIndexing:
5186 case Type::UnaryTransform:
5187 case Type::TemplateTypeParm:
5188 case Type::SubstTemplateTypeParmPack:
5189 case Type::SubstBuiltinTemplatePack:
5190 case Type::DependentName:
5192 return ResultIfUnknown;
5195 case Type::TemplateSpecialization:
5200 .getAsTemplateDecl())
5201 if (
auto *CTD = dyn_cast<ClassTemplateDecl>(templateDecl))
5202 return llvm::any_of(
5204 return RTD->getTemplatedDecl()->hasAttr<TypeNullableAttr>();
5206 return ResultIfUnknown;
5211#define SIGNED_TYPE(Id, SingletonId) case BuiltinType::Id:
5212#define UNSIGNED_TYPE(Id, SingletonId) case BuiltinType::Id:
5213#define FLOATING_TYPE(Id, SingletonId) case BuiltinType::Id:
5214#define BUILTIN_TYPE(Id, SingletonId)
5215#include "clang/AST/BuiltinTypes.def"
5218 case BuiltinType::UnresolvedTemplate:
5220 case BuiltinType::Dependent:
5221 case BuiltinType::Overload:
5222 case BuiltinType::BoundMember:
5223 case BuiltinType::PseudoObject:
5224 case BuiltinType::UnknownAny:
5225 case BuiltinType::ARCUnbridgedCast:
5226 return ResultIfUnknown;
5228 case BuiltinType::Void:
5229 case BuiltinType::ObjCId:
5230 case BuiltinType::ObjCClass:
5231 case BuiltinType::ObjCSel:
5232#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
5233 case BuiltinType::Id:
5234#include "clang/Basic/OpenCLImageTypes.def"
5235#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) case BuiltinType::Id:
5236#include "clang/Basic/OpenCLExtensionTypes.def"
5237 case BuiltinType::OCLSampler:
5238 case BuiltinType::OCLEvent:
5239 case BuiltinType::OCLClkEvent:
5240 case BuiltinType::OCLQueue:
5241 case BuiltinType::OCLReserveID:
5242#define SVE_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
5243#include "clang/Basic/AArch64ACLETypes.def"
5244#define PPC_VECTOR_TYPE(Name, Id, Size) case BuiltinType::Id:
5245#include "clang/Basic/PPCTypes.def"
5246#define RVV_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
5247#include "clang/Basic/RISCVVTypes.def"
5248#define WASM_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
5249#include "clang/Basic/WebAssemblyReferenceTypes.def"
5250#define AMDGPU_TYPE(Name, Id, SingletonId, Width, Align) case BuiltinType::Id:
5251#include "clang/Basic/AMDGPUTypes.def"
5252#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
5253#include "clang/Basic/HLSLIntangibleTypes.def"
5254 case BuiltinType::BuiltinFn:
5255 case BuiltinType::NullPtr:
5256 case BuiltinType::IncompleteMatrixIdx:
5257 case BuiltinType::ArraySection:
5258 case BuiltinType::OMPArrayShaping:
5259 case BuiltinType::OMPIterator:
5262 llvm_unreachable(
"unknown builtin type");
5264 case Type::Record: {
5268 if (
const auto *CTSD = dyn_cast<ClassTemplateSpecializationDecl>(RD))
5269 return llvm::any_of(
5270 CTSD->getSpecializedTemplate()->redecls(),
5272 return RTD->getTemplatedDecl()->hasAttr<TypeNullableAttr>();
5275 return RD->hasAttr<TypeNullableAttr>();
5281 case Type::LValueReference:
5282 case Type::RValueReference:
5283 case Type::ConstantArray:
5284 case Type::IncompleteArray:
5285 case Type::VariableArray:
5286 case Type::DependentSizedArray:
5287 case Type::DependentVector:
5288 case Type::DependentSizedExtVector:
5290 case Type::ExtVector:
5291 case Type::ConstantMatrix:
5292 case Type::DependentSizedMatrix:
5293 case Type::DependentAddressSpace:
5294 case Type::FunctionProto:
5295 case Type::FunctionNoProto:
5296 case Type::DeducedTemplateSpecialization:
5298 case Type::InjectedClassName:
5299 case Type::PackExpansion:
5300 case Type::ObjCObject:
5301 case Type::ObjCInterface:
5305 case Type::DependentBitInt:
5306 case Type::ArrayParameter:
5307 case Type::HLSLAttributedResource:
5308 case Type::HLSLInlineSpirv:
5309 case Type::OverflowBehavior:
5312 llvm_unreachable(
"bad type kind!");
5316 if (getAttrKind() == attr::TypeNonNull)
5318 if (getAttrKind() == attr::TypeNullable)
5320 if (getAttrKind() == attr::TypeNullUnspecified)
5322 if (getAttrKind() == attr::TypeNullableResult)
5324 return std::nullopt;
5329 if (
auto MacroTy = dyn_cast<MacroQualifiedType>(T))
5330 AttrTy = MacroTy->getUnderlyingType();
5332 if (
auto attributed = dyn_cast<AttributedType>(AttrTy)) {
5333 if (
auto nullability = attributed->getImmediateNullability()) {
5334 T = attributed->getModifiedType();
5339 return std::nullopt;
5342void AttributedType::Profile(llvm::FoldingSetNodeID &ID,
const ASTContext &Ctx,
5345 ID.AddInteger(attrKind);
5349 attr->Profile(ID, Ctx);
5363 if (objcPtr->isObjCIdType()) {
5374 }
else if (objcPtr->isObjCQualifiedIdType()) {
5399 "cannot query implicit lifetime for non-inferrable type");
5404 while (
const auto *array = dyn_cast<ArrayType>(canon))
5405 canon = array->getElementType().getTypePtr();
5407 if (
const auto *
opt = dyn_cast<ObjCObjectPointerType>(canon)) {
5409 if (
opt->getObjectType()->isObjCClass())
5418 return typedefType->getDecl()->hasAttr<ObjCNSObjectAttr>();
5424 return typedefType->getDecl()->hasAttr<ObjCIndependentClassAttr>();
5437 return OPT->getPointeeType()->isObjCIndirectLifetimeType();
5439 return Ref->getPointeeType()->isObjCIndirectLifetimeType();
5441 return MemPtr->getPointeeType()->isObjCIndirectLifetimeType();
5449 while (
const ArrayType *array =
type->getAsArrayTypeUnsafe())
5450 type = array->getElementType().getTypePtr();
5451 return type->isObjCRetainableType();
5473 return RT->getDecl()
5474 ->getMostRecentDecl()
5475 ->hasAttr<CUDADeviceBuiltinSurfaceTypeAttr>();
5482 return RT->getDecl()
5483 ->getMostRecentDecl()
5484 ->hasAttr<CUDADeviceBuiltinTextureTypeAttr>();
5493 return ptr->getPointeeType()->hasSizedVLAType();
5495 return ref->getPointeeType()->hasSizedVLAType();
5501 return arr->getElementType()->hasSizedVLAType();
5508 return HLSLAttributedResourceType::findHandleTypeOnResource(
this) !=
nullptr;
5531 const RecordType *RT =
5537 assert(RD !=
nullptr &&
5538 "all HLSL structs and classes should be CXXRecordDecl");
5544 switch (
type.getObjCLifetime()) {
5556 if (
const auto *RD =
type->getBaseElementTypeUnsafe()->getAsRecordDecl()) {
5557 if (
const auto *CXXRD = dyn_cast<CXXRecordDecl>(RD)) {
5559 if (CXXRD->hasDefinition() && !CXXRD->hasTrivialDestructor())
5574 llvm::SmallPtrSetImpl<const Decl *> &Seen) {
5575 if (
const auto *Arr = Context.getAsArrayType(Ty))
5576 Ty = Context.getBaseElementType(Arr);
5578 if (
const auto *AttrTy = Ty->
getAs<AttributedType>())
5579 Ty = AttrTy->getModifiedType();
5582 "Incomplete types cannot be evaluated for laundering");
5589 if (!Seen.insert(
Record).second)
5592 if (
Record->isDynamicClass())
5618 Qualifier.Profile(ID);
5630 auto *RD = getCXXRecordDecl();
5637 llvm::APSInt Val,
unsigned Scale) {
5638 llvm::FixedPointSemantics FXSema(Val.getBitWidth(), Scale, Val.isSigned(),
5641 llvm::APFixedPoint(Val, FXSema).toString(Str);
5644DeducedType::DeducedType(TypeClass TC,
DeducedKind DK,
5647 ? DeducedAsTypeOrCanon.getCanonicalType()
5648 : DeducedAsTypeOrCanon,
5650 DeducedTypeBits.Kind = llvm::to_underlying(DK);
5655 assert(!DeducedAsTypeOrCanon.
isNull() &&
"Deduced type cannot be null");
5657 ~TypeDependence::VariablyModified);
5658 DeducedAsType = DeducedAsTypeOrCanon;
5661 addDependence(TypeDependence::UnexpandedPack);
5664 addDependence(TypeDependence::DependentInstantiation);
5667 assert(getDeducedKind() == DK &&
"DeducedKind does not match the type state");
5673 : DeducedType(
Auto, DK, DeducedAsTypeOrCanon) {
5674 AutoTypeBits.Keyword = llvm::to_underlying(
Keyword);
5675 AutoTypeBits.NumArgs = TypeConstraintArgs.size();
5676 this->TypeConstraintConcept = TypeConstraintConcept;
5677 assert(TypeConstraintConcept || AutoTypeBits.NumArgs == 0);
5678 if (TypeConstraintConcept) {
5679 auto Dep = TypeDependence::None;
5680 if (
const auto *TTP =
5681 dyn_cast<TemplateTemplateParmDecl>(TypeConstraintConcept))
5682 Dep = TypeDependence::DependentInstantiation |
5683 (TTP->isParameterPack() ? TypeDependence::UnexpandedPack
5684 : TypeDependence::None);
5699void AutoType::Profile(llvm::FoldingSetNodeID &ID,
const ASTContext &Context,
5703 DeducedType::Profile(ID, DK,
Deduced);
5704 ID.AddInteger(llvm::to_underlying(
Keyword));
5707 Arg.Profile(ID, Context);
5710void AutoType::Profile(llvm::FoldingSetNodeID &ID,
const ASTContext &Context) {
5711 Profile(ID, Context, getDeducedKind(), getDeducedType(), getKeyword(),
5712 getTypeConstraintConcept(), getTypeConstraintArguments());
5726 llvm_unreachable(
"unknown effect kind");
5732 return "nonblocking";
5734 return "nonallocating";
5738 return "allocating";
5740 llvm_unreachable(
"unknown effect kind");
5756 return std::nullopt;
5761 assert(0 &&
"effectProhibitingInference with non-inferable effect kind");
5764 llvm_unreachable(
"unknown effect kind");
5774 const Kind EK = Effect.kind();
5776 if (EK == CallerKind ||
5787 llvm_unreachable(
"unknown effect kind");
5799 unsigned InsertIdx = Effects.size();
5814 Errs.push_back({EC, NewEC});
5825 if (NewCondition || !Conditions.empty()) {
5826 if (Conditions.empty() && !Effects.empty())
5827 Conditions.resize(Effects.size());
5828 Conditions.insert(Conditions.begin() + InsertIdx,
5831 Effects.insert(Effects.begin() + InsertIdx, NewEC.
Effect);
5836 for (
const auto &Item :
Set)
5838 return Errs.empty();
5849 auto IterA = LHS.
begin(), EndA = LHS.
end();
5850 auto IterB = RHS.
begin(), EndB = RHS.
end();
5854 return std::tuple(LHS.Effect,
uintptr_t(LHS.Cond.getCondition())) <
5855 std::tuple(RHS.Effect,
uintptr_t(RHS.Cond.getCondition()));
5858 while (IterA != EndA && IterB != EndB) {
5863 else if (FEWCLess(B, A))
5874 assert(Errs.empty() &&
"conflict shouldn't be possible in getIntersection");
5887 Combined.
insert(RHS, Errs);
5908 llvm::interleaveComma(*
this, OS);
5918 llvm::interleaveComma(*
this, OS);
5925 assert(llvm::is_sorted(FX) &&
"effects should be sorted");
5926 assert((Conds.empty() || Conds.size() == FX.size()) &&
5927 "effects size should match conditions size");
5933 if (
Cond.getCondition() !=
nullptr)
5938const HLSLAttributedResourceType *
5939HLSLAttributedResourceType::findHandleTypeOnResource(
const Type *RT) {
5944 if (!RD->
fields().empty()) {
5945 const auto &FirstFD = RD->
fields().begin();
5946 return dyn_cast<HLSLAttributedResourceType>(
5947 FirstFD->getType().getTypePtr());
5953StringRef PredefinedSugarType::getName(Kind KD) {
5958 return "__signed_size_t";
5960 return "__ptrdiff_t";
5962 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.
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)
static bool requiresBuiltinLaunderImpl(const ASTContext &Context, QualType Ty, llvm::SmallPtrSetImpl< const Decl * > &Seen)
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...
bool hasPostfixDeclaratorSyntax() const
Returns true if the type uses postfix declarator syntax, i.e.
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 requiresBuiltinLaunder(const ASTContext &Context) const
Returns true if this type requires laundering by checking if it is a dynamic class type,...
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 isMatrixType() 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
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.
NullabilityKindOrNone getNullability() const
Determine the nullability of the given 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.
OptionalUnsigned< unsigned > UnsignedOrNone
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)
OptionalUnsigned< NullabilityKind > NullabilityKindOrNone
__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.
constexpr underlying_type toInternalRepresentation() const
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.