41#include "llvm/ADT/APInt.h"
42#include "llvm/ADT/APSInt.h"
43#include "llvm/ADT/ArrayRef.h"
44#include "llvm/ADT/FoldingSet.h"
45#include "llvm/ADT/STLExtras.h"
46#include "llvm/ADT/SmallVector.h"
47#include "llvm/Support/ErrorHandling.h"
48#include "llvm/Support/MathExtras.h"
58 return (*
this !=
Other) &&
113 if (
const auto *DNT = ty->
getAs<DependentNameType>())
117 if (
const auto *TT = ty->
getAs<TagType>())
142 if (
T.isConstQualified())
146 return AT->getElementType().isConstant(Ctx);
151std::optional<QualType::NonConstantStorageReason>
154 if (!
isConstant(Ctx) && !(*this)->isReferenceType())
162 if (
Record->hasMutableFields())
164 if (!
Record->hasTrivialDestructor() && !ExcludeDtor)
190 (tc == DependentSizedArray
200 const llvm::APInt &Sz,
const Expr *SzExpr,
202 bool NeedsExternalSize = SzExpr !=
nullptr || Sz.ugt(0x0FFFFFFFFFFFFFFF) ||
203 Sz.getBitWidth() > 0xFF;
204 if (!NeedsExternalSize)
206 ET, Can, Sz.getBitWidth(), Sz.getZExtValue(), SzMod, Qual);
208 auto *SzPtr =
new (Ctx,
alignof(ConstantArrayType::ExternalSize))
209 ConstantArrayType::ExternalSize(Sz, SzExpr);
217 const llvm::APInt &NumElements) {
218 uint64_t ElementSize = Context.getTypeSizeInChars(ElementType).getQuantity();
226 if (llvm::isPowerOf2_64(ElementSize)) {
227 return NumElements.getActiveBits() + llvm::Log2_64(ElementSize);
232 if ((ElementSize >> 32) == 0 && NumElements.getBitWidth() <= 64 &&
233 (NumElements.getZExtValue() >> 32) == 0) {
234 uint64_t TotalSize = NumElements.getZExtValue() * ElementSize;
235 return llvm::bit_width(TotalSize);
239 llvm::APSInt SizeExtended(NumElements,
true);
240 unsigned SizeTypeBits = Context.getTypeSize(Context.getSizeType());
241 SizeExtended = SizeExtended.extend(
242 std::max(SizeTypeBits, SizeExtended.getBitWidth()) * 2);
244 llvm::APSInt TotalSize(llvm::APInt(SizeExtended.getBitWidth(), ElementSize));
245 TotalSize *= SizeExtended;
247 return TotalSize.getActiveBits();
256 unsigned Bits = Context.getTypeSize(Context.getSizeType());
269 uint64_t ArraySize,
const Expr *SizeExpr,
272 ID.AddInteger(ArraySize);
273 ID.AddInteger(llvm::to_underlying(SizeMod));
274 ID.AddInteger(TypeQuals);
275 ID.AddBoolean(SizeExpr !=
nullptr);
277 SizeExpr->
Profile(ID, Context,
true);
289 :
ArrayType(DependentSizedArray, et, can, sm, tq, e), SizeExpr((
Stmt *)e) {}
294 unsigned TypeQuals,
Expr *E) {
296 ID.AddInteger(llvm::to_underlying(SizeMod));
297 ID.AddInteger(TypeQuals);
302DependentVectorType::DependentVectorType(
QualType ElementType,
305 :
Type(DependentVector, CanonType,
307 ElementType->getDependence() |
310 ElementType(ElementType), SizeExpr(SizeExpr), Loc(Loc) {
318 ID.AddPointer(ElementType.getAsOpaquePtr());
319 ID.AddInteger(llvm::to_underlying(VecKind));
320 SizeExpr->Profile(ID, Context,
true);
323DependentSizedExtVectorType::DependentSizedExtVectorType(
QualType ElementType,
327 :
Type(DependentSizedExtVector, can,
329 ElementType->getDependence() |
332 SizeExpr(SizeExpr), ElementType(ElementType), loc(loc) {}
338 ID.AddPointer(ElementType.getAsOpaquePtr());
339 SizeExpr->Profile(ID, Context,
true);
342DependentAddressSpaceType::DependentAddressSpaceType(
QualType PointeeType,
346 :
Type(DependentAddressSpace, can,
348 PointeeType->getDependence() |
351 AddrSpaceExpr(AddrSpaceExpr), PointeeType(PointeeType), loc(loc) {}
356 Expr *AddrSpaceExpr) {
357 ID.AddPointer(PointeeType.getAsOpaquePtr());
358 AddrSpaceExpr->Profile(ID, Context,
true);
362 const Expr *RowExpr,
const Expr *ColumnExpr)
363 :
Type(tc, canonType,
380 unsigned nColumns,
QualType canonType)
385 unsigned nRows,
unsigned nColumns,
390DependentSizedMatrixType::DependentSizedMatrixType(
QualType ElementType,
395 :
MatrixType(DependentSizedMatrix, ElementType, CanonicalType, RowExpr,
397 RowExpr(RowExpr), ColumnExpr(ColumnExpr), loc(loc) {}
404 RowExpr->Profile(ID, CTX,
true);
405 ColumnExpr->Profile(ID, CTX,
true);
432 ExprAndUnsigned(NumBitsExpr, IsUnsigned) {}
435 return ExprAndUnsigned.getInt();
439 return ExprAndUnsigned.getPointer();
445 ID.AddBoolean(IsUnsigned);
446 NumBitsExpr->
Profile(ID, Context,
true);
458 bool CountInBytes,
bool OrNull) {
459 ID.AddPointer(WrappedTy.getAsOpaquePtr());
460 ID.AddBoolean(CountInBytes);
461 ID.AddBoolean(OrNull);
466 ID.AddPointer(CountExpr);
474 if (
const auto *ATy = dyn_cast<ArrayType>(
this))
475 return ATy->getElementType().getTypePtr();
503 return Context.getQualifiedType(desugar,
split.
Quals);
509#define TYPE(CLASS, BASE) \
510 static_assert(!std::is_polymorphic<CLASS##Type>::value, \
511 #CLASS "Type should not be polymorphic!");
512#include "clang/AST/TypeNodes.inc"
517#define TYPE(CLASS, BASE) \
518 static_assert(std::is_trivially_destructible<CLASS##Type>::value, \
519 #CLASS "Type should be trivially destructible!");
520#include "clang/AST/TypeNodes.inc"
524#define ABSTRACT_TYPE(Class, Parent)
525#define TYPE(Class, Parent) \
526 case Type::Class: { \
527 const auto *ty = cast<Class##Type>(this); \
528 if (!ty->isSugared()) \
529 return QualType(ty, 0); \
530 return ty->desugar(); \
532#include "clang/AST/TypeNodes.inc"
534 llvm_unreachable(
"bad type kind!");
544#define ABSTRACT_TYPE(Class, Parent)
545#define TYPE(Class, Parent) \
546 case Type::Class: { \
547 const auto *Ty = cast<Class##Type>(CurTy); \
548 if (!Ty->isSugared()) \
549 return SplitQualType(Ty, Qs); \
550 Cur = Ty->desugar(); \
553#include "clang/AST/TypeNodes.inc"
562 Qualifiers quals =
split.Quals;
565 const Type *lastTypeWithQuals =
split.Ty;
572 switch (
split.Ty->getTypeClass()) {
573#define ABSTRACT_TYPE(Class, Parent)
574#define TYPE(Class, Parent) \
575 case Type::Class: { \
576 const auto *ty = cast<Class##Type>(split.Ty); \
577 if (!ty->isSugared()) \
579 next = ty->desugar(); \
582#include "clang/AST/TypeNodes.inc"
588 if (!
split.Quals.empty()) {
589 lastTypeWithQuals =
split.Ty;
595 return SplitQualType(lastTypeWithQuals, quals);
600 while (
const auto *PT =
T->
getAs<ParenType>())
601 T = PT->getInnerType();
610 if (
const auto *Sugar = dyn_cast<T>(Cur))
613#define ABSTRACT_TYPE(Class, Parent)
614#define TYPE(Class, Parent) \
615 case Type::Class: { \
616 const auto *Ty = cast<Class##Type>(Cur); \
617 if (!Ty->isSugared()) \
619 Cur = Ty->desugar().getTypePtr(); \
622#include "clang/AST/TypeNodes.inc"
635template <>
const TemplateSpecializationType *
Type::getAs()
const {
655 const Type *Cur =
this;
659#define ABSTRACT_TYPE(Class, Parent)
660#define TYPE(Class, Parent) \
662 const auto *Ty = cast<Class##Type>(Cur); \
663 if (!Ty->isSugared()) \
665 Cur = Ty->desugar().getTypePtr(); \
668#include "clang/AST/TypeNodes.inc"
675 return RT->getDecl()->isClass();
681 return RT->getDecl()->isStruct();
689 const auto *
Decl = RT->getDecl();
690 if (!
Decl->isStruct())
692 return Decl->getDefinitionOrSelf()->hasFlexibleArrayMember();
697 return RD->hasAttr<ObjCBoxableAttr>();
703 return RT->getDecl()->isInterface();
709 return RT->getDecl()->isStructureOrClass();
715 return PT->getPointeeType()->isVoidType();
721 return RT->getDecl()->isUnion();
727 return CT->getElementType()->isFloatingType();
738 return ET->getDecl()->isScoped();
748 if (
Complex->getElementType()->isIntegerType())
771 if (
const auto *RT = dyn_cast<RecordType>(
this)) {
772 if (RT->getDecl()->isStruct())
777 if (
const auto *RT = dyn_cast<RecordType>(CanonicalType)) {
778 if (!RT->getDecl()->isStruct())
790 if (
const auto *RT = dyn_cast<RecordType>(
this)) {
791 if (RT->getDecl()->isUnion())
796 if (
const auto *RT = dyn_cast<RecordType>(CanonicalType)) {
797 if (!RT->getDecl()->isUnion())
817 if (OPT->isObjCIdType())
821 if (!OPT->isKindOfType())
825 if (OPT->isObjCClassType() || OPT->isObjCQualifiedClassType())
829 bound = OPT->getObjectType()
830 ->stripObjCKindOfTypeAndQuals(ctx)
841 if (OPT->isObjCClassType())
845 if (!OPT->isKindOfType())
849 return OPT->isObjCClassType() || OPT->isObjCQualifiedClassType();
863 :
Type(ObjCObject, Canonical,
Base->getDependence()), BaseType(
Base) {
867 assert(getTypeArgsAsWritten().size() == typeArgs.size() &&
868 "bitfield overflow in type argument count");
869 if (!typeArgs.empty())
870 memcpy(getTypeArgStorage(), typeArgs.data(),
871 typeArgs.size() *
sizeof(
QualType));
873 for (
auto typeArg : typeArgs) {
874 addDependence(typeArg->getDependence() & ~TypeDependence::VariablyModified);
881bool ObjCObjectType::isSpecialized()
const {
883 if (ObjCObjectTypeBits.NumTypeArgs > 0)
887 if (
const auto objcObject =
getBaseType()->getAs<ObjCObjectType>()) {
892 return objcObject->isSpecialized();
901 if (isSpecializedAsWritten())
902 return getTypeArgsAsWritten();
905 if (
const auto objcObject =
getBaseType()->getAs<ObjCObjectType>()) {
910 return objcObject->getTypeArgs();
917bool ObjCObjectType::isKindOfType()
const {
918 if (isKindOfTypeAsWritten())
922 if (
const auto objcObject =
getBaseType()->getAs<ObjCObjectType>()) {
927 return objcObject->isKindOfType();
935ObjCObjectType::stripObjCKindOfTypeAndQuals(
const ASTContext &ctx)
const {
936 if (!isKindOfType() && qual_empty())
942 if (
const auto *baseObj = splitBaseType.
Ty->
getAs<ObjCObjectType>())
943 baseType = baseObj->stripObjCKindOfTypeAndQuals(ctx);
947 getTypeArgsAsWritten(),
972template <
typename Derived>
973struct SimpleTransformVisitor :
public TypeVisitor<Derived, QualType> {
981 QualType result =
static_cast<Derived *
>(
this)->Visit(splitType.
Ty);
991 explicit SimpleTransformVisitor(
ASTContext &ctx) : Ctx(ctx) {}
995#define TYPE(Class, Base)
996#define DEPENDENT_TYPE(Class, Base) \
997 QualType Visit##Class##Type(const Class##Type *T) { return QualType(T, 0); }
998#include "clang/AST/TypeNodes.inc"
1000#define TRIVIAL_TYPE_CLASS(Class) \
1001 QualType Visit##Class##Type(const Class##Type *T) { return QualType(T, 0); }
1002#define SUGARED_TYPE_CLASS(Class) \
1003 QualType Visit##Class##Type(const Class##Type *T) { \
1004 if (!T->isSugared()) \
1005 return QualType(T, 0); \
1006 QualType desugaredType = recurse(T->desugar()); \
1007 if (desugaredType.isNull()) \
1009 if (desugaredType.getAsOpaquePtr() == T->desugar().getAsOpaquePtr()) \
1010 return QualType(T, 0); \
1011 return desugaredType; \
1017 QualType elementType = recurse(
T->getElementType());
1018 if (elementType.
isNull())
1021 if (elementType.
getAsOpaquePtr() ==
T->getElementType().getAsOpaquePtr())
1027 QualType VisitPointerType(
const PointerType *
T) {
1029 if (pointeeType.
isNull())
1033 return QualType(
T, 0);
1038 QualType VisitBlockPointerType(
const BlockPointerType *
T) {
1040 if (pointeeType.
isNull())
1044 return QualType(
T, 0);
1049 QualType VisitLValueReferenceType(
const LValueReferenceType *
T) {
1050 QualType pointeeType = recurse(
T->getPointeeTypeAsWritten());
1051 if (pointeeType.
isNull())
1055 T->getPointeeTypeAsWritten().getAsOpaquePtr())
1056 return QualType(
T, 0);
1061 QualType VisitRValueReferenceType(
const RValueReferenceType *
T) {
1062 QualType pointeeType = recurse(
T->getPointeeTypeAsWritten());
1063 if (pointeeType.
isNull())
1067 T->getPointeeTypeAsWritten().getAsOpaquePtr())
1068 return QualType(
T, 0);
1073 QualType VisitMemberPointerType(
const MemberPointerType *
T) {
1075 if (pointeeType.
isNull())
1079 return QualType(
T, 0);
1082 T->getMostRecentCXXRecordDecl());
1085 QualType VisitConstantArrayType(
const ConstantArrayType *
T) {
1086 QualType elementType = recurse(
T->getElementType());
1087 if (elementType.
isNull())
1090 if (elementType.
getAsOpaquePtr() ==
T->getElementType().getAsOpaquePtr())
1091 return QualType(
T, 0);
1094 T->getSizeModifier(),
1095 T->getIndexTypeCVRQualifiers());
1098 QualType VisitVariableArrayType(
const VariableArrayType *
T) {
1099 QualType elementType = recurse(
T->getElementType());
1100 if (elementType.
isNull())
1103 if (elementType.
getAsOpaquePtr() ==
T->getElementType().getAsOpaquePtr())
1104 return QualType(
T, 0);
1107 T->getSizeModifier(),
1108 T->getIndexTypeCVRQualifiers());
1111 QualType VisitIncompleteArrayType(
const IncompleteArrayType *
T) {
1112 QualType elementType = recurse(
T->getElementType());
1113 if (elementType.
isNull())
1116 if (elementType.
getAsOpaquePtr() ==
T->getElementType().getAsOpaquePtr())
1117 return QualType(
T, 0);
1120 T->getIndexTypeCVRQualifiers());
1123 QualType VisitVectorType(
const VectorType *
T) {
1124 QualType elementType = recurse(
T->getElementType());
1125 if (elementType.
isNull())
1128 if (elementType.
getAsOpaquePtr() ==
T->getElementType().getAsOpaquePtr())
1129 return QualType(
T, 0);
1132 T->getVectorKind());
1135 QualType VisitExtVectorType(
const ExtVectorType *
T) {
1136 QualType elementType = recurse(
T->getElementType());
1137 if (elementType.
isNull())
1140 if (elementType.
getAsOpaquePtr() ==
T->getElementType().getAsOpaquePtr())
1141 return QualType(
T, 0);
1146 QualType VisitConstantMatrixType(
const ConstantMatrixType *
T) {
1147 QualType elementType = recurse(
T->getElementType());
1148 if (elementType.
isNull())
1150 if (elementType.
getAsOpaquePtr() ==
T->getElementType().getAsOpaquePtr())
1151 return QualType(
T, 0);
1154 T->getNumColumns());
1157 QualType VisitFunctionNoProtoType(
const FunctionNoProtoType *
T) {
1163 return QualType(
T, 0);
1168 QualType VisitFunctionProtoType(
const FunctionProtoType *
T) {
1174 SmallVector<QualType, 4> paramTypes;
1175 bool paramChanged =
false;
1177 QualType newParamType = recurse(paramType);
1178 if (newParamType.
isNull())
1182 paramChanged =
true;
1184 paramTypes.push_back(newParamType);
1189 bool exceptionChanged =
false;
1191 SmallVector<QualType, 4> exceptionTypes;
1193 QualType newExceptionType = recurse(exceptionType);
1194 if (newExceptionType.
isNull())
1197 if (newExceptionType.
getAsOpaquePtr() != exceptionType.getAsOpaquePtr())
1198 exceptionChanged =
true;
1200 exceptionTypes.push_back(newExceptionType);
1203 if (exceptionChanged) {
1205 llvm::ArrayRef(exceptionTypes).copy(Ctx);
1210 !paramChanged && !exceptionChanged)
1211 return QualType(
T, 0);
1216 QualType VisitParenType(
const ParenType *
T) {
1217 QualType innerType = recurse(
T->getInnerType());
1222 return QualType(
T, 0);
1231 QualType VisitAdjustedType(
const AdjustedType *
T) {
1232 QualType originalType = recurse(
T->getOriginalType());
1233 if (originalType.
isNull())
1236 QualType adjustedType = recurse(
T->getAdjustedType());
1237 if (adjustedType.
isNull())
1241 T->getOriginalType().getAsOpaquePtr() &&
1242 adjustedType.
getAsOpaquePtr() ==
T->getAdjustedType().getAsOpaquePtr())
1243 return QualType(
T, 0);
1248 QualType VisitDecayedType(
const DecayedType *
T) {
1249 QualType originalType = recurse(
T->getOriginalType());
1250 if (originalType.
isNull())
1253 if (originalType.
getAsOpaquePtr() ==
T->getOriginalType().getAsOpaquePtr())
1254 return QualType(
T, 0);
1259 QualType VisitArrayParameterType(
const ArrayParameterType *
T) {
1260 QualType ArrTy = VisitConstantArrayType(
T);
1274 QualType VisitAttributedType(
const AttributedType *
T) {
1275 QualType modifiedType = recurse(
T->getModifiedType());
1276 if (modifiedType.
isNull())
1279 QualType equivalentType = recurse(
T->getEquivalentType());
1280 if (equivalentType.
isNull())
1284 T->getModifiedType().getAsOpaquePtr() &&
1286 T->getEquivalentType().getAsOpaquePtr())
1287 return QualType(
T, 0);
1293 QualType VisitSubstTemplateTypeParmType(
const SubstTemplateTypeParmType *
T) {
1294 QualType replacementType = recurse(
T->getReplacementType());
1295 if (replacementType.
isNull())
1299 T->getReplacementType().getAsOpaquePtr())
1300 return QualType(
T, 0);
1303 replacementType,
T->getAssociatedDecl(),
T->getIndex(),
1304 T->getPackIndex(),
T->getFinal());
1310 QualType VisitAutoType(
const AutoType *
T) {
1311 if (!
T->isDeduced())
1312 return QualType(
T, 0);
1314 QualType deducedType = recurse(
T->getDeducedType());
1315 if (deducedType.
isNull())
1318 if (deducedType.
getAsOpaquePtr() ==
T->getDeducedType().getAsOpaquePtr())
1319 return QualType(
T, 0);
1322 false,
T->getTypeConstraintConcept(),
1323 T->getTypeConstraintArguments());
1326 QualType VisitObjCObjectType(
const ObjCObjectType *
T) {
1327 QualType baseType = recurse(
T->getBaseType());
1332 bool typeArgChanged =
false;
1333 SmallVector<QualType, 4> typeArgs;
1334 for (
auto typeArg :
T->getTypeArgsAsWritten()) {
1335 QualType newTypeArg = recurse(typeArg);
1340 typeArgChanged =
true;
1342 typeArgs.push_back(newTypeArg);
1347 return QualType(
T, 0);
1351 llvm::ArrayRef(
T->qual_begin(),
T->getNumProtocols()),
1352 T->isKindOfTypeAsWritten());
1357 QualType VisitObjCObjectPointerType(
const ObjCObjectPointerType *
T) {
1359 if (pointeeType.
isNull())
1363 return QualType(
T, 0);
1368 QualType VisitAtomicType(
const AtomicType *
T) {
1369 QualType valueType = recurse(
T->getValueType());
1374 return QualType(
T, 0);
1379#undef TRIVIAL_TYPE_CLASS
1380#undef SUGARED_TYPE_CLASS
1383struct SubstObjCTypeArgsVisitor
1384 :
public SimpleTransformVisitor<SubstObjCTypeArgsVisitor> {
1385 using BaseType = SimpleTransformVisitor<SubstObjCTypeArgsVisitor>;
1387 ArrayRef<QualType> TypeArgs;
1390 SubstObjCTypeArgsVisitor(ASTContext &ctx, ArrayRef<QualType> typeArgs,
1392 : BaseType(ctx), TypeArgs(typeArgs), SubstContext(context) {}
1394 QualType VisitObjCTypeParamType(
const ObjCTypeParamType *OTPTy) {
1397 ObjCTypeParamDecl *typeParam = OTPTy->getDecl();
1399 if (!TypeArgs.empty()) {
1400 QualType argType = TypeArgs[typeParam->
getIndex()];
1401 if (OTPTy->qual_empty())
1406 SmallVector<ObjCProtocolDecl *, 8> protocolsVec;
1407 protocolsVec.append(OTPTy->qual_begin(), OTPTy->qual_end());
1408 ArrayRef<ObjCProtocolDecl *> protocolsToApply = protocolsVec;
1410 argType, protocolsToApply, hasError,
true );
1413 switch (SubstContext) {
1414 case ObjCSubstitutionContext::Ordinary:
1415 case ObjCSubstitutionContext::Parameter:
1416 case ObjCSubstitutionContext::Superclass:
1420 case ObjCSubstitutionContext::Result:
1421 case ObjCSubstitutionContext::Property: {
1423 const auto *objPtr =
1428 if (objPtr->isKindOfType() || objPtr->isObjCIdOrClassType())
1432 const auto *obj = objPtr->getObjectType();
1434 obj->getBaseType(), obj->getTypeArgsAsWritten(), obj->getProtocols(),
1441 llvm_unreachable(
"Unexpected ObjCSubstitutionContext!");
1444 QualType VisitFunctionType(
const FunctionType *funcType) {
1450 Ctx, TypeArgs, ObjCSubstitutionContext::Result);
1460 return BaseType::VisitFunctionType(funcType);
1469 SmallVector<QualType, 4> paramTypes;
1470 bool paramChanged =
false;
1471 for (
auto paramType : funcProtoType->getParamTypes()) {
1473 Ctx, TypeArgs, ObjCSubstitutionContext::Parameter);
1474 if (newParamType.
isNull())
1478 paramChanged =
true;
1480 paramTypes.push_back(newParamType);
1484 FunctionProtoType::ExtProtoInfo info = funcProtoType->getExtProtoInfo();
1485 bool exceptionChanged =
false;
1487 SmallVector<QualType, 4> exceptionTypes;
1490 Ctx, TypeArgs, ObjCSubstitutionContext::Ordinary);
1491 if (newExceptionType.
isNull())
1494 if (newExceptionType.
getAsOpaquePtr() != exceptionType.getAsOpaquePtr())
1495 exceptionChanged =
true;
1497 exceptionTypes.push_back(newExceptionType);
1500 if (exceptionChanged) {
1502 llvm::ArrayRef(exceptionTypes).copy(Ctx);
1507 funcProtoType->getReturnType().getAsOpaquePtr() &&
1508 !paramChanged && !exceptionChanged)
1509 return BaseType::VisitFunctionType(funcType);
1514 QualType VisitObjCObjectType(
const ObjCObjectType *objcObjectType) {
1517 if (objcObjectType->isSpecializedAsWritten()) {
1518 SmallVector<QualType, 4> newTypeArgs;
1519 bool anyChanged =
false;
1520 for (
auto typeArg : objcObjectType->getTypeArgsAsWritten()) {
1522 Ctx, TypeArgs, ObjCSubstitutionContext::Ordinary);
1529 ArrayRef<ObjCProtocolDecl *> protocols(
1530 objcObjectType->qual_begin(), objcObjectType->getNumProtocols());
1531 if (TypeArgs.empty() &&
1532 SubstContext != ObjCSubstitutionContext::Superclass) {
1534 objcObjectType->getBaseType(), {}, protocols,
1535 objcObjectType->isKindOfTypeAsWritten());
1541 newTypeArgs.push_back(newTypeArg);
1545 ArrayRef<ObjCProtocolDecl *> protocols(
1546 objcObjectType->qual_begin(), objcObjectType->getNumProtocols());
1549 objcObjectType->isKindOfTypeAsWritten());
1553 return BaseType::VisitObjCObjectType(objcObjectType);
1556 QualType VisitAttributedType(
const AttributedType *attrType) {
1557 QualType newType = BaseType::VisitAttributedType(attrType);
1561 const auto *newAttrType = dyn_cast<AttributedType>(newType.
getTypePtr());
1562 if (!newAttrType || newAttrType->getAttrKind() != attr::ObjCKindOf)
1566 QualType newEquivType = newAttrType->getEquivalentType();
1567 const ObjCObjectPointerType *ptrType =
1568 newEquivType->
getAs<ObjCObjectPointerType>();
1569 const ObjCObjectType *objType = ptrType
1571 : newEquivType->
getAs<ObjCObjectType>();
1578 objType->getBaseType(), objType->getTypeArgsAsWritten(),
1579 objType->getProtocols(),
1581 objType->isObjCUnqualifiedId() ?
false :
true);
1589 newAttrType->getModifiedType(), newEquivType,
1590 newAttrType->getAttr());
1594struct StripObjCKindOfTypeVisitor
1595 :
public SimpleTransformVisitor<StripObjCKindOfTypeVisitor> {
1596 using BaseType = SimpleTransformVisitor<StripObjCKindOfTypeVisitor>;
1598 explicit StripObjCKindOfTypeVisitor(ASTContext &ctx) : BaseType(ctx) {}
1600 QualType VisitObjCObjectType(
const ObjCObjectType *objType) {
1601 if (!objType->isKindOfType())
1602 return BaseType::VisitObjCObjectType(objType);
1604 QualType baseType = objType->getBaseType().stripObjCKindOfType(Ctx);
1606 objType->getProtocols(),
1623 case BuiltinType::Kind::Float16: {
1631 case BuiltinType::Kind::BFloat16: {
1651 SubstObjCTypeArgsVisitor visitor(ctx, typeArgs, context);
1652 return visitor.recurse(*
this);
1666 auto &ctx =
const_cast<ASTContext &
>(constCtx);
1667 StripObjCKindOfTypeVisitor visitor(ctx);
1668 return visitor.recurse(*
this);
1673 if (
const auto AT =
T.getTypePtr()->getAs<
AtomicType>())
1674 T = AT->getValueType();
1675 return T.getUnqualifiedType();
1678std::optional<ArrayRef<QualType>>
1681 if (
const auto method = dyn_cast<ObjCMethodDecl>(dc))
1682 dc = method->getDeclContext();
1686 const auto *dcClassDecl = dyn_cast<ObjCInterfaceDecl>(dc);
1692 dcTypeParams = dcClassDecl->getTypeParamList();
1694 return std::nullopt;
1698 dcCategoryDecl = dyn_cast<ObjCCategoryDecl>(dc);
1699 if (!dcCategoryDecl)
1700 return std::nullopt;
1706 return std::nullopt;
1710 return std::nullopt;
1712 assert(dcTypeParams &&
"No substitutions to perform");
1713 assert(dcClassDecl &&
"No class context");
1718 objectType = objectPointerType->getObjectType();
1729 objectType ? objectType->getInterface() :
nullptr;
1730 if (!curClassDecl) {
1738 while (curClassDecl != dcClassDecl) {
1740 QualType superType = objectType->getSuperClassType();
1741 if (superType.
isNull()) {
1742 objectType =
nullptr;
1747 curClassDecl = objectType->getInterface();
1752 if (!objectType || objectType->isUnspecialized()) {
1757 return objectType->getTypeArgs();
1762 if (
auto *ID = IfaceT->getInterface()) {
1763 if (ID->getTypeParamList())
1771void ObjCObjectType::computeSuperClassTypeSlow()
const {
1777 CachedSuperClassType.setInt(
true);
1783 if (!superClassObjTy) {
1784 CachedSuperClassType.setInt(
true);
1789 if (!superClassDecl) {
1790 CachedSuperClassType.setInt(
true);
1796 QualType superClassType(superClassObjTy, 0);
1798 if (!superClassTypeParams) {
1799 CachedSuperClassType.setPointerAndInt(
1800 superClassType->castAs<ObjCObjectType>(),
true);
1805 if (superClassObjTy->isUnspecialized()) {
1806 CachedSuperClassType.setPointerAndInt(superClassObjTy,
true);
1814 CachedSuperClassType.setPointerAndInt(
1815 superClassType->castAs<ObjCObjectType>(),
true);
1821 if (isUnspecialized()) {
1824 superClassObjTy->getInterface());
1825 CachedSuperClassType.setPointerAndInt(
1826 unspecializedSuper->
castAs<ObjCObjectType>(),
true);
1832 assert(typeArgs.size() == typeParams->
size());
1833 CachedSuperClassType.setPointerAndInt(
1837 ->castAs<ObjCObjectType>(),
1843 return interfaceDecl->getASTContext()
1844 .getObjCInterfaceType(interfaceDecl)
1853 if (superObjectType.
isNull())
1854 return superObjectType;
1865 if (
T->getNumProtocols() &&
T->getInterface())
1878 if (OPT->isObjCQualifiedIdType())
1888 if (OPT->isObjCQualifiedClassType())
1896 if (OT->getInterface())
1904 if (OPT->getInterfaceType())
1921const TemplateSpecializationType *
1924 while (TST && TST->isTypeAlias())
1925 TST = TST->desugar()->getAs<TemplateSpecializationType>();
1931 case Type::DependentName:
1933 case Type::TemplateSpecialization:
1939 case Type::InjectedClassName:
1943 case Type::UnresolvedUsing:
1948 return std::nullopt;
1953 const Type *Cur =
this;
1954 while (
const auto *AT = Cur->
getAs<AttributedType>()) {
1955 if (AT->getAttrKind() == AK)
1957 Cur = AT->getEquivalentType().getTypePtr();
1964class GetContainedDeducedTypeVisitor
1965 :
public TypeVisitor<GetContainedDeducedTypeVisitor, Type *> {
1969 GetContainedDeducedTypeVisitor(
bool Syntactic =
false)
1970 : Syntactic(Syntactic) {}
1977 return Visit(
T.getTypePtr());
1981 Type *VisitDeducedType(
const DeducedType *AT) {
1982 return const_cast<DeducedType *
>(AT);
1986 Type *VisitSubstTemplateTypeParmType(
const SubstTemplateTypeParmType *
T) {
1987 return Visit(
T->getReplacementType());
1990 Type *VisitPointerType(
const PointerType *
T) {
1994 Type *VisitBlockPointerType(
const BlockPointerType *
T) {
1998 Type *VisitReferenceType(
const ReferenceType *
T) {
1999 return Visit(
T->getPointeeTypeAsWritten());
2002 Type *VisitMemberPointerType(
const MemberPointerType *
T) {
2006 Type *VisitArrayType(
const ArrayType *
T) {
2007 return Visit(
T->getElementType());
2010 Type *VisitDependentSizedExtVectorType(
const DependentSizedExtVectorType *
T) {
2011 return Visit(
T->getElementType());
2014 Type *VisitVectorType(
const VectorType *
T) {
2015 return Visit(
T->getElementType());
2018 Type *VisitDependentSizedMatrixType(
const DependentSizedMatrixType *
T) {
2019 return Visit(
T->getElementType());
2022 Type *VisitConstantMatrixType(
const ConstantMatrixType *
T) {
2023 return Visit(
T->getElementType());
2026 Type *VisitFunctionProtoType(
const FunctionProtoType *
T) {
2028 return const_cast<FunctionProtoType *
>(
T);
2029 return VisitFunctionType(
T);
2032 Type *VisitFunctionType(
const FunctionType *
T) {
2036 Type *VisitParenType(
const ParenType *
T) {
return Visit(
T->getInnerType()); }
2038 Type *VisitAttributedType(
const AttributedType *
T) {
2039 return Visit(
T->getModifiedType());
2042 Type *VisitMacroQualifiedType(
const MacroQualifiedType *
T) {
2043 return Visit(
T->getUnderlyingType());
2046 Type *VisitAdjustedType(
const AdjustedType *
T) {
2047 return Visit(
T->getOriginalType());
2050 Type *VisitPackExpansionType(
const PackExpansionType *
T) {
2051 return Visit(
T->getPattern());
2058 return cast_or_null<DeducedType>(
2059 GetContainedDeducedTypeVisitor().Visit(
this));
2063 return isa_and_nonnull<FunctionType>(
2064 GetContainedDeducedTypeVisitor(
true).Visit(
this));
2068 if (
const auto *VT = dyn_cast<VectorType>(CanonicalType))
2069 return VT->getElementType()->isIntegerType();
2070 if (CanonicalType->isSveVLSBuiltinType()) {
2072 return VT->getKind() == BuiltinType::SveBool ||
2073 (VT->getKind() >= BuiltinType::SveInt8 &&
2074 VT->getKind() <= BuiltinType::SveUint64);
2076 if (CanonicalType->isRVVVLSBuiltinType()) {
2078 return (VT->getKind() >= BuiltinType::RvvInt8mf8 &&
2079 VT->getKind() <= BuiltinType::RvvUint64m8);
2105 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
2106 return BT->isInteger();
2110 if (
const auto *ET = dyn_cast<EnumType>(CanonicalType))
2117 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
2118 return BT->isInteger();
2127 if (
const auto *ET = dyn_cast<EnumType>(CanonicalType))
2128 return !ET->getDecl()->isScoped();
2134 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
2135 return BT->getKind() == BuiltinType::Char_U ||
2136 BT->getKind() == BuiltinType::UChar ||
2137 BT->getKind() == BuiltinType::Char_S ||
2138 BT->getKind() == BuiltinType::SChar;
2143 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
2144 return BT->getKind() == BuiltinType::WChar_S ||
2145 BT->getKind() == BuiltinType::WChar_U;
2150 if (
const BuiltinType *BT = dyn_cast<BuiltinType>(CanonicalType))
2151 return BT->getKind() == BuiltinType::Char8;
2156 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
2157 return BT->getKind() == BuiltinType::Char16;
2162 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
2163 return BT->getKind() == BuiltinType::Char32;
2170 const auto *BT = dyn_cast<BuiltinType>(CanonicalType);
2173 switch (BT->getKind()) {
2176 case BuiltinType::Char_U:
2177 case BuiltinType::UChar:
2178 case BuiltinType::WChar_U:
2179 case BuiltinType::Char8:
2180 case BuiltinType::Char16:
2181 case BuiltinType::Char32:
2182 case BuiltinType::Char_S:
2183 case BuiltinType::SChar:
2184 case BuiltinType::WChar_S:
2190 const auto *BT = dyn_cast<BuiltinType>(CanonicalType);
2193 switch (BT->getKind()) {
2196 case BuiltinType::Char8:
2197 case BuiltinType::Char16:
2198 case BuiltinType::Char32:
2207 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
2208 return BT->isSignedInteger();
2213 if (!ED->isComplete() || ED->isScoped())
2215 return ED->getIntegerType()->isSignedIntegerType();
2218 if (
const auto *IT = dyn_cast<BitIntType>(CanonicalType))
2219 return IT->isSigned();
2220 if (
const auto *IT = dyn_cast<DependentBitIntType>(CanonicalType))
2221 return IT->isSigned();
2227 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
2228 return BT->isSignedInteger();
2231 if (!ED->isComplete())
2233 return ED->getIntegerType()->isSignedIntegerType();
2236 if (
const auto *IT = dyn_cast<BitIntType>(CanonicalType))
2237 return IT->isSigned();
2238 if (
const auto *IT = dyn_cast<DependentBitIntType>(CanonicalType))
2239 return IT->isSigned();
2245 if (
const auto *VT = dyn_cast<VectorType>(CanonicalType))
2246 return VT->getElementType()->isSignedIntegerOrEnumerationType();
2255 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
2256 return BT->isUnsignedInteger();
2261 if (!ED->isComplete() || ED->isScoped())
2263 return ED->getIntegerType()->isUnsignedIntegerType();
2266 if (
const auto *IT = dyn_cast<BitIntType>(CanonicalType))
2267 return IT->isUnsigned();
2268 if (
const auto *IT = dyn_cast<DependentBitIntType>(CanonicalType))
2269 return IT->isUnsigned();
2275 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
2276 return BT->isUnsignedInteger();
2279 if (!ED->isComplete())
2281 return ED->getIntegerType()->isUnsignedIntegerType();
2284 if (
const auto *IT = dyn_cast<BitIntType>(CanonicalType))
2285 return IT->isUnsigned();
2286 if (
const auto *IT = dyn_cast<DependentBitIntType>(CanonicalType))
2287 return IT->isUnsigned();
2293 if (
const auto *VT = dyn_cast<VectorType>(CanonicalType))
2294 return VT->getElementType()->isUnsignedIntegerOrEnumerationType();
2295 if (
const auto *VT = dyn_cast<MatrixType>(CanonicalType))
2296 return VT->getElementType()->isUnsignedIntegerOrEnumerationType();
2297 if (CanonicalType->isSveVLSBuiltinType()) {
2299 return VT->getKind() >= BuiltinType::SveUint8 &&
2300 VT->getKind() <= BuiltinType::SveUint64;
2306 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
2307 return BT->isFloatingPoint();
2308 if (
const auto *CT = dyn_cast<ComplexType>(CanonicalType))
2309 return CT->getElementType()->isFloatingType();
2314 if (
const auto *VT = dyn_cast<VectorType>(CanonicalType))
2315 return VT->getElementType()->isFloatingType();
2316 if (
const auto *MT = dyn_cast<MatrixType>(CanonicalType))
2317 return MT->getElementType()->isFloatingType();
2322 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
2323 return BT->isFloatingPoint();
2328 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
2329 return BT->getKind() >= BuiltinType::Bool &&
2330 BT->getKind() <= BuiltinType::Ibm128;
2331 if (
const auto *ET = dyn_cast<EnumType>(CanonicalType)) {
2332 const auto *ED = ET->getDecl();
2333 return !ED->isScoped() && ED->getDefinitionOrSelf()->isComplete();
2339 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
2340 return BT->getKind() >= BuiltinType::Bool &&
2341 BT->getKind() <= BuiltinType::Ibm128;
2342 if (
const auto *ET = dyn_cast<EnumType>(CanonicalType)) {
2349 const auto *ED = ET->getDecl();
2350 return !ED->isScoped() && ED->getDefinitionOrSelf()->isComplete();
2356 if (
const auto *VT = dyn_cast<VectorType>(CanonicalType))
2357 return VT->getElementType()->isBooleanType();
2359 return ED->isComplete() && ED->getIntegerType()->isBooleanType();
2360 if (
const auto *IT = dyn_cast<BitIntType>(CanonicalType))
2361 return IT->getNumBits() == 1;
2368 const Type *
T = CanonicalType.getTypePtr();
2369 if (
const auto *BT = dyn_cast<BuiltinType>(
T)) {
2370 if (BT->getKind() == BuiltinType::Bool)
2372 if (BT->getKind() == BuiltinType::NullPtr)
2374 if (BT->isInteger())
2376 if (BT->isFloatingPoint())
2378 if (BT->isFixedPointType())
2380 llvm_unreachable(
"unknown scalar builtin type");
2390 assert(
T->castAsEnumDecl()->isComplete());
2392 }
else if (
const auto *CT = dyn_cast<ComplexType>(
T)) {
2393 if (CT->getElementType()->isRealFloatingType())
2400 llvm_unreachable(
"unknown scalar type");
2413 if (
const auto *
Record = dyn_cast<RecordType>(CanonicalType)) {
2414 if (
const auto *ClassDecl = dyn_cast<CXXRecordDecl>(
Record->getDecl()))
2415 return ClassDecl->isAggregate();
2427 assert(!
isIncompleteType() &&
"This doesn't make sense for incomplete types");
2428 assert(!
isDependentType() &&
"This doesn't make sense for dependent types");
2440 switch (CanonicalType->getTypeClass()) {
2451 return !EnumD->isComplete();
2459 return !Rec->isCompleteDefinition();
2461 case InjectedClassName: {
2463 if (!Rec->isBeingDefined())
2477 ->isIncompleteType(Def);
2478 case IncompleteArray:
2481 case MemberPointer: {
2494 if (!Context.getTargetInfo().getCXXABI().isMicrosoft())
2497 if (RD->
hasAttr<MSInheritanceAttr>())
2504 ->isIncompleteType(Def);
2505 case ObjCInterface: {
2537 switch (BT->getKind()) {
2539#define WASM_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
2540#include "clang/Basic/WebAssemblyReferenceTypes.def"
2542#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
2543#include "clang/Basic/HLSLIntangibleTypes.def"
2554 return BT->getKind() == BuiltinType::WasmExternRef;
2559 if (
const auto *ATy = dyn_cast<ArrayType>(
this))
2560 return ATy->getElementType().isWebAssemblyReferenceType();
2562 if (
const auto *PTy = dyn_cast<PointerType>(
this))
2563 return PTy->getPointeeType().isWebAssemblyReferenceType();
2576 switch (BT->getKind()) {
2578#define SVE_VECTOR_TYPE(Name, MangledName, Id, SingletonId) \
2579 case BuiltinType::Id: \
2581#define SVE_OPAQUE_TYPE(Name, MangledName, Id, SingletonId) \
2582 case BuiltinType::Id: \
2584#define SVE_PREDICATE_TYPE(Name, MangledName, Id, SingletonId) \
2585 case BuiltinType::Id: \
2587#include "clang/Basic/AArch64ACLETypes.def"
2597 switch (BT->getKind()) {
2598#define RVV_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
2599#include "clang/Basic/RISCVVTypes.def"
2610 switch (BT->getKind()) {
2611 case BuiltinType::SveInt8:
2612 case BuiltinType::SveInt16:
2613 case BuiltinType::SveInt32:
2614 case BuiltinType::SveInt64:
2615 case BuiltinType::SveUint8:
2616 case BuiltinType::SveUint16:
2617 case BuiltinType::SveUint32:
2618 case BuiltinType::SveUint64:
2619 case BuiltinType::SveFloat16:
2620 case BuiltinType::SveFloat32:
2621 case BuiltinType::SveFloat64:
2622 case BuiltinType::SveBFloat16:
2623 case BuiltinType::SveBool:
2624 case BuiltinType::SveBoolx2:
2625 case BuiltinType::SveBoolx4:
2626 case BuiltinType::SveMFloat8:
2644 llvm_unreachable(
"Unhandled type");
2651 if (BTy->
getKind() == BuiltinType::SveBool)
2662 switch (BT->getKind()) {
2663#define RVV_VECTOR_TYPE(Name, Id, SingletonId, NumEls, ElBits, NF, IsSigned, \
2665 case BuiltinType::Id: \
2667#define RVV_PREDICATE_TYPE(Name, Id, SingletonId, NumEls) \
2668 case BuiltinType::Id: \
2670#include "clang/Basic/RISCVVTypes.def"
2684#define RVV_PREDICATE_TYPE(Name, Id, SingletonId, NumEls) \
2685 case BuiltinType::Id: \
2686 return Ctx.UnsignedCharTy;
2689#include "clang/Basic/RISCVVTypes.def"
2692 llvm_unreachable(
"Unhandled type");
2697 if (Context.getLangOpts().CPlusPlus11)
2710 if ((*this)->isIncompleteArrayType())
2711 return Context.getBaseElementType(*this).isCXX98PODType(Context);
2713 if ((*this)->isIncompleteType())
2722 if (Context.containsAddressDiscriminatedPointerAuth(CanonicalType))
2729 case Type::VariableArray:
2730 case Type::ConstantArray:
2732 return Context.getBaseElementType(*this).isCXX98PODType(Context);
2734 case Type::ObjCObjectPointer:
2735 case Type::BlockPointer:
2739 case Type::MemberPointer:
2741 case Type::ExtVector:
2749 if (
const auto *ClassDecl =
2751 return ClassDecl->isPOD();
2765 if ((*this)->isArrayType())
2766 return Context.getBaseElementType(*this).isTrivialType(Context);
2768 if ((*this)->isSizelessBuiltinType())
2773 if ((*this)->isIncompleteType())
2785 if (Context.containsAddressDiscriminatedPointerAuth(CanonicalType))
2804 return ClassDecl->hasTrivialDefaultConstructor() &&
2805 !ClassDecl->hasNonTrivialDefaultConstructor() &&
2806 ClassDecl->isTriviallyCopyable();
2818 bool IsCopyConstructible) {
2819 if (
type->isArrayType())
2821 Context, IsCopyConstructible);
2823 if (
type.hasNonTrivialObjCLifetime())
2856 if (
const auto *ClassDecl = dyn_cast<CXXRecordDecl>(RD)) {
2857 if (IsCopyConstructible)
2858 return ClassDecl->isTriviallyCopyConstructible();
2859 return ClassDecl->isTriviallyCopyable();
2861 return !RD->isNonTrivialToPrimitiveCopy();
2875 if (CanonicalType.hasNonTrivialObjCLifetime())
2877 if (CanonicalType->isArrayType())
2878 return Context.getBaseElementType(CanonicalType)
2879 .isBitwiseCloneableType(Context);
2881 if (CanonicalType->isIncompleteType())
2886 if (Context.containsAddressDiscriminatedPointerAuth(CanonicalType))
2889 const auto *RD = CanonicalType->getAsRecordDecl();
2896 if (RD->mayInsertExtraPadding())
2899 for (
auto *
const Field : RD->fields()) {
2900 if (!Field->getType().isBitwiseCloneableType(Context))
2904 if (
const auto *CXXRD = dyn_cast<CXXRecordDecl>(RD)) {
2905 for (
auto Base : CXXRD->bases())
2906 if (!
Base.getType().isBitwiseCloneableType(Context))
2908 for (
auto VBase : CXXRD->vbases())
2909 if (!VBase.getType().isBitwiseCloneableType(Context))
2922 return !Context.getLangOpts().ObjCAutoRefCount &&
2923 Context.getLangOpts().ObjCWeak &&
2955 if (
const auto *RD =
2971 if (
const auto *RD =
3011 assert(BaseTy &&
"NULL element type");
3041 if (
const auto *ClassDecl = dyn_cast<CXXRecordDecl>(RD))
3042 return ClassDecl->isLiteral();
3049 return AT->getValueType()->isLiteralType(Ctx);
3071 return RD->isStructural();
3084 assert(BaseTy &&
"NULL element type");
3095 if (
const auto *ClassDecl = dyn_cast<CXXRecordDecl>(RD);
3096 ClassDecl && !ClassDecl->isStandardLayout())
3124 assert(BaseTy &&
"NULL element type");
3135 if (Context.containsAddressDiscriminatedPointerAuth(*
this))
3142 if (
const auto *ClassDecl = dyn_cast<CXXRecordDecl>(RD)) {
3145 if (!ClassDecl->isTrivial())
3151 if (!ClassDecl->isStandardLayout())
3182 const auto *ED = ET->getDecl();
3184 if (II && II->
isStr(
"align_val_t") && ED->isInStdNamespace())
3192 const auto *ED = ET->getDecl();
3194 if (II && II->
isStr(
"byte") && ED->isInStdNamespace())
3210 case TemplateTypeParm:
3211 case SubstTemplateTypeParm:
3212 case TemplateSpecialization:
3255 llvm_unreachable(
"Type specifier is not a tag type kind.");
3272 llvm_unreachable(
"Unknown tag type kind.");
3290 llvm_unreachable(
"Elaborated type keyword is not a tag type kind.");
3292 llvm_unreachable(
"Unknown elaborated type keyword.");
3307 llvm_unreachable(
"Unknown elaborated type keyword.");
3321 return "__interface";
3328 llvm_unreachable(
"Unknown elaborated type keyword.");
3333 if (
const auto *TST = dyn_cast<TemplateSpecializationType>(
this))
3335 else if (
const auto *DepName = dyn_cast<DependentNameType>(
this))
3336 Keyword = DepName->getKeyword();
3337 else if (
const auto *
T = dyn_cast<TagType>(
this))
3339 else if (
const auto *
T = dyn_cast<TypedefType>(
this))
3341 else if (
const auto *
T = dyn_cast<UnresolvedUsingType>(
this))
3343 else if (
const auto *
T = dyn_cast<UsingType>(
this))
3353#define ABSTRACT_TYPE(Derived, Base)
3354#define TYPE(Derived, Base) \
3357#include "clang/AST/TypeNodes.inc"
3360 llvm_unreachable(
"Invalid type class.");
3368 return Policy.
Bool ?
"bool" :
"_Bool";
3374 return "signed char";
3386 return "unsigned char";
3388 return "unsigned short";
3390 return "unsigned int";
3392 return "unsigned long";
3394 return "unsigned long long";
3396 return "unsigned __int128";
3398 return Policy.
Half ?
"half" :
"__fp16";
3406 return "long double";
3408 return "short _Accum";
3412 return "long _Accum";
3414 return "unsigned short _Accum";
3416 return "unsigned _Accum";
3418 return "unsigned long _Accum";
3419 case BuiltinType::ShortFract:
3420 return "short _Fract";
3421 case BuiltinType::Fract:
3423 case BuiltinType::LongFract:
3424 return "long _Fract";
3425 case BuiltinType::UShortFract:
3426 return "unsigned short _Fract";
3427 case BuiltinType::UFract:
3428 return "unsigned _Fract";
3429 case BuiltinType::ULongFract:
3430 return "unsigned long _Fract";
3431 case BuiltinType::SatShortAccum:
3432 return "_Sat short _Accum";
3433 case BuiltinType::SatAccum:
3434 return "_Sat _Accum";
3435 case BuiltinType::SatLongAccum:
3436 return "_Sat long _Accum";
3437 case BuiltinType::SatUShortAccum:
3438 return "_Sat unsigned short _Accum";
3439 case BuiltinType::SatUAccum:
3440 return "_Sat unsigned _Accum";
3441 case BuiltinType::SatULongAccum:
3442 return "_Sat unsigned long _Accum";
3443 case BuiltinType::SatShortFract:
3444 return "_Sat short _Fract";
3445 case BuiltinType::SatFract:
3446 return "_Sat _Fract";
3447 case BuiltinType::SatLongFract:
3448 return "_Sat long _Fract";
3449 case BuiltinType::SatUShortFract:
3450 return "_Sat unsigned short _Fract";
3451 case BuiltinType::SatUFract:
3452 return "_Sat unsigned _Fract";
3453 case BuiltinType::SatULongFract:
3454 return "_Sat unsigned long _Fract";
3458 return "__float128";
3463 return Policy.
MSWChar ?
"__wchar_t" :
"wchar_t";
3473 return "<overloaded function type>";
3475 return "<bound member function type>";
3476 case UnresolvedTemplate:
3477 return "<unresolved template type>";
3479 return "<pseudo-object type>";
3481 return "<dependent type>";
3483 return "<unknown type>";
3484 case ARCUnbridgedCast:
3485 return "<ARC unbridged cast type>";
3487 return "<builtin fn type>";
3494#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
3496 return "__" #Access " " #ImgType "_t";
3497#include "clang/Basic/OpenCLImageTypes.def"
3503 return "clk_event_t";
3507 return "reserve_id_t";
3508 case IncompleteMatrixIdx:
3509 return "<incomplete matrix index type>";
3511 return "<array section type>";
3512 case OMPArrayShaping:
3513 return "<OpenMP array shaping type>";
3515 return "<OpenMP iterator type>";
3516#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \
3519#include "clang/Basic/OpenCLExtensionTypes.def"
3520#define SVE_TYPE(Name, Id, SingletonId) \
3523#include "clang/Basic/AArch64ACLETypes.def"
3524#define PPC_VECTOR_TYPE(Name, Id, Size) \
3527#include "clang/Basic/PPCTypes.def"
3528#define RVV_TYPE(Name, Id, SingletonId) \
3531#include "clang/Basic/RISCVVTypes.def"
3532#define WASM_TYPE(Name, Id, SingletonId) \
3535#include "clang/Basic/WebAssemblyReferenceTypes.def"
3536#define AMDGPU_TYPE(Name, Id, SingletonId, Width, Align) \
3539#include "clang/Basic/AMDGPUTypes.def"
3540#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) \
3543#include "clang/Basic/HLSLIntangibleTypes.def"
3546 llvm_unreachable(
"Invalid builtin type.");
3551 if (
auto *PET = dyn_cast<PackExpansionType>(
getTypePtr()))
3552 return PET->getPattern();
3557 if (
const auto *RefType =
getTypePtr()->getAs<ReferenceType>())
3565 if (!Context.getLangOpts().CPlusPlus ||
3574 return FPT->hasCFIUncheckedCallee();
3591 return "vectorcall";
3603 return "aarch64_vector_pcs";
3605 return "aarch64_sve_pcs";
3607 return "intel_ocl_bicc";
3609 return "spir_function";
3611 return "device_kernel";
3615 return "swiftasynccall";
3617 return "preserve_most";
3619 return "preserve_all";
3623 return "preserve_none";
3626#define CC_VLS_CASE(ABI_VLEN) \
3627 case CC_RISCVVLSCall_##ABI_VLEN: return "riscv_vls_cc(" #ABI_VLEN ")";
3644 llvm_unreachable(
"Invalid calling convention.");
3662 assert(
getNumParams() == params.size() &&
"NumParams overflow!");
3671 auto &ExtraBits = *getTrailingObjects<FunctionTypeExtraBitfields>();
3679 auto &ExtraAttrInfo = *getTrailingObjects<FunctionTypeExtraAttributeInfo>();
3683 auto &ExtraBits = *getTrailingObjects<FunctionTypeExtraBitfields>();
3684 ExtraBits.HasExtraAttributeInfo =
true;
3688 auto &ArmTypeAttrs = *getTrailingObjects<FunctionTypeArmAttributes>();
3689 ArmTypeAttrs = FunctionTypeArmAttributes();
3692 auto &ExtraBits = *getTrailingObjects<FunctionTypeExtraBitfields>();
3693 ExtraBits.HasArmTypeAttributes =
true;
3697 auto *argSlot = getTrailingObjects<QualType>();
3700 ~TypeDependence::VariablyModified);
3701 argSlot[i] = params[i];
3706 auto &ArmTypeAttrs = *getTrailingObjects<FunctionTypeArmAttributes>();
3708 "Not enough bits to encode SME attributes");
3714 auto &ExtraBits = *getTrailingObjects<FunctionTypeExtraBitfields>();
3716 assert(NumExceptions <= 1023 &&
"Not enough bits to encode exceptions");
3717 ExtraBits.NumExceptionType = NumExceptions;
3719 assert(hasExtraBitfields() &&
"missing trailing extra bitfields!");
3721 reinterpret_cast<QualType *
>(getTrailingObjects<ExceptionType>());
3729 (TypeDependence::Instantiation | TypeDependence::UnexpandedPack));
3731 exnSlot[I++] = ExceptionType;
3745 (TypeDependence::Instantiation | TypeDependence::UnexpandedPack));
3751 auto **slot = getTrailingObjects<FunctionDecl *>();
3759 auto **slot = getTrailingObjects<FunctionDecl *>();
3778 auto *extParamInfos = getTrailingObjects<ExtParameterInfo>();
3785 *getTrailingObjects<Qualifiers>() = epi.
TypeQuals;
3792 auto &EllipsisLoc = *getTrailingObjects<SourceLocation>();
3797 auto &ExtraBits = *getTrailingObjects<FunctionTypeExtraBitfields>();
3799 ExtraBits.NumFunctionEffects = EffectsCount;
3800 assert(ExtraBits.NumFunctionEffects == EffectsCount &&
3801 "effect bitfield overflow");
3804 auto *DestFX = getTrailingObjects<FunctionEffect>();
3805 llvm::uninitialized_copy(SrcFX, DestFX);
3808 if (!SrcConds.empty()) {
3809 ExtraBits.EffectsHaveConditions =
true;
3810 auto *DestConds = getTrailingObjects<EffectConditionExpr>();
3811 llvm::uninitialized_copy(SrcConds, DestConds);
3812 assert(llvm::any_of(SrcConds,
3813 [](
const EffectConditionExpr &EC) {
3815 return E->isTypeDependent() ||
3816 E->isValueDependent();
3819 "expected a dependent expression among the conditions");
3827 return NE->isValueDependent();
3839 return NE->isInstantiationDependent();
3850 llvm_unreachable(
"should not call this with unresolved exception specs");
3876 llvm_unreachable(
"unexpected exception specification kind");
3880 for (
unsigned ArgIdx =
getNumParams(); ArgIdx; --ArgIdx)
3888 const QualType *ArgTys,
unsigned NumParams,
3889 const ExtProtoInfo &epi,
3913 ID.AddPointer(
Result.getAsOpaquePtr());
3914 for (
unsigned i = 0; i != NumParams; ++i)
3915 ID.AddPointer(ArgTys[i].getAsOpaquePtr());
3919 assert(!(
unsigned(epi.Variadic) & ~1) && !(
unsigned(epi.RefQualifier) & ~3) &&
3920 !(
unsigned(epi.ExceptionSpec.Type) & ~15) &&
3921 "Values larger than expected.");
3922 ID.AddInteger(
unsigned(epi.Variadic) + (epi.RefQualifier << 1) +
3923 (epi.ExceptionSpec.Type << 3));
3924 ID.Add(epi.TypeQuals);
3926 for (
QualType Ex : epi.ExceptionSpec.Exceptions)
3929 epi.ExceptionSpec.NoexceptExpr->Profile(ID, Context, Canonical);
3932 ID.AddPointer(epi.ExceptionSpec.SourceDecl->getCanonicalDecl());
3934 if (epi.ExtParameterInfos) {
3935 for (
unsigned i = 0; i != NumParams; ++i)
3936 ID.AddInteger(epi.ExtParameterInfos[i].getOpaqueValue());
3939 epi.ExtInfo.Profile(ID);
3940 epi.ExtraAttributeInfo.Profile(ID);
3942 unsigned EffectCount = epi.FunctionEffects.size();
3943 bool HasConds = !epi.FunctionEffects.Conditions.empty();
3945 ID.AddInteger((EffectCount << 3) | (HasConds << 2) |
3946 (epi.AArch64SMEAttributes << 1) | epi.HasTrailingReturn);
3947 ID.AddInteger(epi.CFIUncheckedCallee);
3949 for (
unsigned Idx = 0; Idx != EffectCount; ++Idx) {
3950 ID.AddInteger(epi.FunctionEffects.Effects[Idx].toOpaqueInt32());
3952 ID.AddPointer(epi.FunctionEffects.Conditions[Idx].getCondition());
3963 : Data(D, Deref << DerefShift) {}
3966 return Data.getInt() & DerefMask;
3971 return Data.getOpaqueValue();
3978 Data.setFromOpaqueValue(
V);
3985CountAttributedType::CountAttributedType(
3989 CountExpr(CountExpr) {
3993 auto *DeclSlot = getTrailingObjects();
3994 llvm::copy(CoupledDecls, DeclSlot);
4003#define ENUMERATE_ATTRS(PREFIX) \
4005 if (isCountInBytes()) { \
4007 return PREFIX "sized_by_or_null"; \
4008 return PREFIX "sized_by"; \
4011 return PREFIX "counted_by_or_null"; \
4012 return PREFIX "counted_by"; \
4015 if (WithMacroPrefix)
4020#undef ENUMERATE_ATTRS
4026 bool HasTypeDifferentFromDecl)
4028 Keyword, TC, UnderlyingType.getCanonicalType(),
4032 ~NestedNameSpecifierDependence::
Dependent)
4036 *getTrailingObjects<NestedNameSpecifier>() = Qualifier;
4037 if ((
TypedefBits.hasTypeDifferentFromDecl = HasTypeDifferentFromDecl))
4038 *getTrailingObjects<QualType>() = UnderlyingType;
4043 : *getTrailingObjects<QualType>();
4049 const Type *CanonicalType)
4055 ~NestedNameSpecifierDependence::
Dependent)
4059 *getTrailingObjects<NestedNameSpecifier>() = Qualifier;
4068 if ((
UsingBits.hasQualifier = !!Qualifier))
4069 *getTrailingObjects() = Qualifier;
4078 while (
auto *InnerMQT = dyn_cast<MacroQualifiedType>(Inner)) {
4081 Inner = InnerMQT->getModifiedType();
4092 ? Context.getUnqualifiedArrayType(Can).getAtomicUnqualifiedType()
4097 TOExpr(E), Context(Context) {
4098 TypeOfBits.Kind =
static_cast<unsigned>(Kind);
4107 ? Context.getUnqualifiedArrayType(QT).getAtomicUnqualifiedType()
4116 E->
Profile(ID, Context,
true);
4117 ID.AddBoolean(IsUnqual);
4124 ? Context.getUnqualifiedArrayType(Can).getAtomicUnqualifiedType()
4126 T->getDependence()),
4127 TOType(
T), Context(Context) {
4128 TypeOfBits.Kind =
static_cast<unsigned>(Kind);
4131QualType TypeOfType::desugar()
const {
4134 ? Context.getUnqualifiedArrayType(QT).getAtomicUnqualifiedType()
4142 :
Type(Decltype, can,
4146 (E->
getType()->getDependence() &
4148 E(E), UnderlyingType(underlyingType) {}
4150bool DecltypeType::isSugared()
const {
return !E->isInstantiationDependent(); }
4152QualType DecltypeType::desugar()
const {
4159DependentDecltypeType::DependentDecltypeType(
Expr *E)
4162void DependentDecltypeType::Profile(llvm::FoldingSetNodeID &ID,
4164 E->
Profile(ID, Context,
true);
4168 Expr *IndexExpr,
bool FullySubstituted,
4170 :
Type(PackIndexing, Canonical,
4172 Pattern(Pattern), IndexExpr(IndexExpr),
Size(Expansions.size()),
4173 FullySubstituted(FullySubstituted) {
4175 llvm::uninitialized_copy(Expansions, getTrailingObjects());
4179 if (isInstantiationDependentType())
4180 return std::nullopt;
4182 ConstantExpr *CE = dyn_cast<ConstantExpr>(getIndexExpr());
4184 return std::nullopt;
4186 assert(Index.isNonNegative() &&
"Invalid index");
4187 return static_cast<unsigned>(Index.getExtValue());
4191PackIndexingType::computeDependence(
QualType Pattern,
Expr *IndexExpr,
4196 ? TypeDependence::DependentInstantiation
4197 : TypeDependence::None);
4198 if (Expansions.empty())
4199 TD |= Pattern->
getDependence() & TypeDependence::DependentInstantiation;
4202 TD |=
T->getDependence();
4204 if (!(IndexD & TypeDependence::UnexpandedPack))
4210 TD |= TypeDependence::Error | TypeDependence::DependentInstantiation;
4215void PackIndexingType::Profile(llvm::FoldingSetNodeID &ID,
4217 Profile(ID, Context, getPattern(), getIndexExpr(), isFullySubstituted(),
4221void PackIndexingType::Profile(llvm::FoldingSetNodeID &ID,
4223 Expr *E,
bool FullySubstituted,
4226 E->
Profile(ID, Context,
true);
4227 ID.AddBoolean(FullySubstituted);
4228 if (!Expansions.empty()) {
4229 ID.AddInteger(Expansions.size());
4231 T.getCanonicalType().Profile(ID);
4237UnaryTransformType::UnaryTransformType(
QualType BaseType,
4238 QualType UnderlyingType, UTTKind UKind,
4240 :
Type(UnaryTransform, CanonicalType, BaseType->getDependence()),
4241 BaseType(BaseType), UnderlyingType(UnderlyingType), UKind(UKind) {}
4245 bool OwnsTag,
bool ISInjected,
const Type *CanonicalType)
4252 ~NestedNameSpecifierDependence::
Dependent)
4256 getTrailingQualifier() = Qualifier;
4261void *TagType::getTrailingPointer()
const {
4262 switch (getTypeClass()) {
4267 case Type::InjectedClassName:
4268 return const_cast<InjectedClassNameType *
>(
4271 llvm_unreachable(
"unexpected type class");
4276 assert(TagTypeBits.HasQualifier);
4278 getTrailingPointer(), llvm::Align::Of<NestedNameSpecifier *>()));
4282 return TagTypeBits.HasQualifier ? getTrailingQualifier() : std::nullopt;
4286 auto *
Decl = dyn_cast<CXXRecordDecl>(
decl);
4289 if (
auto *RD = dyn_cast<ClassTemplateSpecializationDecl>(
Decl))
4290 return RD->getSpecializedTemplate();
4291 return Decl->getDescribedClassTemplate();
4295 auto *TD = getTemplateDecl();
4298 if (isCanonicalUnqualified())
4305TagType::getTemplateArgs(
const ASTContext &Ctx)
const {
4306 auto *
Decl = dyn_cast<CXXRecordDecl>(
decl);
4310 if (
auto *RD = dyn_cast<ClassTemplateSpecializationDecl>(
Decl))
4311 return RD->getTemplateArgs().asArray();
4313 return TD->getTemplateParameters()->getInjectedTemplateArgs(Ctx);
4317bool RecordType::hasConstFields()
const {
4318 std::vector<const RecordType *> RecordTypeList;
4319 RecordTypeList.push_back(
this);
4320 unsigned NextToCheckIndex = 0;
4322 while (RecordTypeList.size() > NextToCheckIndex) {
4323 for (
FieldDecl *FD : RecordTypeList[NextToCheckIndex]
4331 if (
const auto *FieldRecTy = FieldTy->
getAsCanonical<RecordType>()) {
4332 if (!llvm::is_contained(RecordTypeList, FieldRecTy))
4333 RecordTypeList.push_back(FieldRecTy);
4343 const TagDecl *TD,
bool IsInjected,
4344 const Type *CanonicalType)
4346 false, IsInjected, CanonicalType) {}
4355 :
Type(Attributed, canon, equivalent->getDependence()), Attribute(
attr),
4356 ModifiedType(modified), EquivalentType(equivalent) {
4358 assert(!attr ||
attr->getKind() == attrKind);
4361bool AttributedType::isQualifier()
const {
4363 switch (getAttrKind()) {
4368 case attr::ObjCOwnership:
4369 case attr::ObjCInertUnsafeUnretained:
4370 case attr::TypeNonNull:
4371 case attr::TypeNullable:
4372 case attr::TypeNullableResult:
4373 case attr::TypeNullUnspecified:
4374 case attr::LifetimeBound:
4375 case attr::AddressSpace:
4385bool AttributedType::isMSTypeSpec()
const {
4387 switch (getAttrKind()) {
4396 llvm_unreachable(
"invalid attr kind");
4399bool AttributedType::isWebAssemblyFuncrefSpec()
const {
4400 return getAttrKind() == attr::WebAssemblyFuncref;
4403bool AttributedType::isCallingConv()
const {
4405 switch (getAttrKind()) {
4410 case attr::FastCall:
4412 case attr::ThisCall:
4414 case attr::SwiftCall:
4415 case attr::SwiftAsyncCall:
4416 case attr::VectorCall:
4417 case attr::AArch64VectorPcs:
4418 case attr::AArch64SVEPcs:
4419 case attr::DeviceKernel:
4423 case attr::IntelOclBicc:
4424 case attr::PreserveMost:
4425 case attr::PreserveAll:
4427 case attr::PreserveNone:
4428 case attr::RISCVVectorCC:
4429 case attr::RISCVVLSCC:
4432 llvm_unreachable(
"invalid attr kind");
4436 return isCanonicalUnqualified() ?
nullptr : getDecl()->getIdentifier();
4439SubstTemplateTypeParmType::SubstTemplateTypeParmType(
QualType Replacement,
4440 Decl *AssociatedDecl,
4444 :
Type(SubstTemplateTypeParm, Replacement.getCanonicalType(),
4445 Replacement->getDependence()),
4446 AssociatedDecl(AssociatedDecl) {
4450 *getTrailingObjects() = Replacement;
4456 assert(AssociatedDecl !=
nullptr);
4460SubstTemplateTypeParmType::getReplacedParameter()
const {
4465void SubstTemplateTypeParmType::Profile(llvm::FoldingSetNodeID &ID,
4467 const Decl *AssociatedDecl,
4470 Replacement.Profile(ID);
4471 ID.AddPointer(AssociatedDecl);
4472 ID.AddInteger(Index);
4474 ID.AddBoolean(Final);
4477SubstPackType::SubstPackType(TypeClass Derived,
QualType Canon,
4479 :
Type(Derived, Canon,
4483 assert(llvm::all_of(
4485 [](
auto &P) { return P.getKind() == TemplateArgument::Type; }) &&
4486 "non-type argument to SubstPackType?");
4494void SubstPackType::Profile(llvm::FoldingSetNodeID &ID) {
4495 Profile(ID, getArgumentPack());
4498void SubstPackType::Profile(llvm::FoldingSetNodeID &ID,
4502 ID.AddPointer(P.getAsType().getAsOpaquePtr());
4505SubstTemplateTypeParmPackType::SubstTemplateTypeParmPackType(
4506 QualType Canon,
Decl *AssociatedDecl,
unsigned Index,
bool Final,
4508 : SubstPackType(SubstTemplateTypeParmPack, Canon, ArgPack),
4509 AssociatedDeclAndFinal(AssociatedDecl, Final) {
4510 assert(AssociatedDecl !=
nullptr);
4513 assert(getNumArgs() == ArgPack.
pack_size() &&
4514 "Parent bitfields in SubstPackType were overwritten."
4515 "Check NumSubstPackTypeBits.");
4518Decl *SubstTemplateTypeParmPackType::getAssociatedDecl()
const {
4519 return AssociatedDeclAndFinal.getPointer();
4522bool SubstTemplateTypeParmPackType::getFinal()
const {
4523 return AssociatedDeclAndFinal.getInt();
4527SubstTemplateTypeParmPackType::getReplacedParameter()
const {
4532IdentifierInfo *SubstTemplateTypeParmPackType::getIdentifier()
const {
4533 return getReplacedParameter()->getIdentifier();
4536void SubstTemplateTypeParmPackType::Profile(llvm::FoldingSetNodeID &ID) {
4537 Profile(ID, getAssociatedDecl(),
getIndex(), getFinal(), getArgumentPack());
4540void SubstTemplateTypeParmPackType::Profile(llvm::FoldingSetNodeID &ID,
4541 const Decl *AssociatedDecl,
4542 unsigned Index,
bool Final,
4544 ID.AddPointer(AssociatedDecl);
4545 ID.AddInteger(Index);
4546 ID.AddBoolean(Final);
4547 SubstPackType::Profile(ID, ArgPack);
4550SubstBuiltinTemplatePackType::SubstBuiltinTemplatePackType(
4552 : SubstPackType(SubstBuiltinTemplatePack, Canon, ArgPack) {}
4554bool TemplateSpecializationType::anyDependentTemplateArguments(
4557 return anyDependentTemplateArguments(Args.
arguments(), Converted);
4560bool TemplateSpecializationType::anyDependentTemplateArguments(
4563 if (Arg.isDependent())
4568bool TemplateSpecializationType::anyInstantiationDependentTemplateArguments(
4571 if (ArgLoc.getArgument().isInstantiationDependent())
4580 ? TypeDependence::DependentInstantiation
4585 D |= TypeDependence::UnexpandedPack;
4587 D |= (Underlying->
getDependence() & TypeDependence::UnexpandedPack);
4592TemplateSpecializationType::TemplateSpecializationType(
4596 Underlying.isNull() ?
QualType(this, 0)
4597 : Underlying.getCanonicalType(),
4600 TemplateSpecializationTypeBits.NumArgs = Args.size();
4601 TemplateSpecializationTypeBits.TypeAlias = IsAlias;
4603 auto *TemplateArgs =
4615 ~TypeDependence::Dependent);
4617 addDependence(Arg.getAsType()->getDependence() &
4618 TypeDependence::VariablyModified);
4625 *
reinterpret_cast<QualType *
>(TemplateArgs) = Underlying;
4628QualType TemplateSpecializationType::getAliasedType()
const {
4629 assert(isTypeAlias() &&
"not a type alias template specialization");
4630 return *
reinterpret_cast<const QualType *
>(template_arguments().end());
4633bool clang::TemplateSpecializationType::isSugared()
const {
4634 return !isDependentType() || isCurrentInstantiation() || isTypeAlias() ||
4639void TemplateSpecializationType::Profile(llvm::FoldingSetNodeID &ID,
4641 Profile(ID, getKeyword(),
Template, template_arguments(),
4642 isSugared() ? desugar() :
QualType(), Ctx);
4645void TemplateSpecializationType::Profile(llvm::FoldingSetNodeID &ID,
4651 ID.AddInteger(llvm::to_underlying(
Keyword));
4655 ID.AddInteger(Args.size());
4657 Arg.Profile(ID, Context);
4665 return Context.getQualifiedType(QT, *
this);
4669 const Type *
T)
const {
4673 return Context.getQualifiedType(
T, *
this);
4676void ObjCObjectTypeImpl::Profile(llvm::FoldingSetNodeID &ID,
QualType BaseType,
4680 ID.AddPointer(BaseType.getAsOpaquePtr());
4681 ID.AddInteger(typeArgs.size());
4682 for (
auto typeArg : typeArgs)
4683 ID.AddPointer(typeArg.getAsOpaquePtr());
4684 ID.AddInteger(protocols.size());
4685 for (
auto *proto : protocols)
4686 ID.AddPointer(proto);
4687 ID.AddBoolean(isKindOf);
4690void ObjCObjectTypeImpl::Profile(llvm::FoldingSetNodeID &ID) {
4691 Profile(ID, getBaseType(), getTypeArgsAsWritten(),
4693 isKindOfTypeAsWritten());
4696void ObjCTypeParamType::Profile(llvm::FoldingSetNodeID &ID,
4700 ID.AddPointer(OTPDecl);
4702 ID.AddInteger(protocols.size());
4703 for (
auto *proto : protocols)
4704 ID.AddPointer(proto);
4707void ObjCTypeParamType::Profile(llvm::FoldingSetNodeID &ID) {
4708 Profile(ID, getDecl(), getCanonicalTypeInternal(),
4715class CachedProperties {
4720 CachedProperties(
Linkage L,
bool local) : L(L), local(local) {}
4722 Linkage getLinkage()
const {
return L; }
4723 bool hasLocalOrUnnamedType()
const {
return local; }
4725 friend CachedProperties
merge(CachedProperties L, CachedProperties R) {
4727 return CachedProperties(MergedLinkage, L.hasLocalOrUnnamedType() ||
4728 R.hasLocalOrUnnamedType());
4747 return CachedProperties(
T->TypeBits.getLinkage(),
4748 T->TypeBits.hasLocalOrUnnamedType());
4753 if (
T->TypeBits.isCacheValid())
4758 if (!
T->isCanonicalUnqualified()) {
4759 const Type *CT =
T->getCanonicalTypeInternal().getTypePtr();
4761 T->TypeBits.CacheValid =
true;
4762 T->TypeBits.CachedLinkage = CT->
TypeBits.CachedLinkage;
4763 T->TypeBits.CachedLocalOrUnnamed = CT->
TypeBits.CachedLocalOrUnnamed;
4769 T->TypeBits.CacheValid =
true;
4770 T->TypeBits.CachedLinkage = llvm::to_underlying(
Result.getLinkage());
4771 T->TypeBits.CachedLocalOrUnnamed =
Result.hasLocalOrUnnamedType();
4789 switch (
T->getTypeClass()) {
4790#define TYPE(Class, Base)
4791#define NON_CANONICAL_TYPE(Class, Base) case Type::Class:
4792#include "clang/AST/TypeNodes.inc"
4793 llvm_unreachable(
"didn't expect a non-canonical type here");
4795#define TYPE(Class, Base)
4796#define DEPENDENT_TYPE(Class, Base) case Type::Class:
4797#define NON_CANONICAL_UNLESS_DEPENDENT_TYPE(Class, Base) case Type::Class:
4798#include "clang/AST/TypeNodes.inc"
4800 assert(
T->isInstantiationDependentType());
4804 case Type::DeducedTemplateSpecialization:
4818 const auto *Tag =
cast<TagType>(
T)->getDecl()->getDefinitionOrSelf();
4824 Linkage L = Tag->getLinkageInternal();
4825 bool IsLocalOrUnnamed = Tag->getDeclContext()->isFunctionOrMethod() ||
4826 !Tag->hasNameForLinkage();
4827 return CachedProperties(L, IsLocalOrUnnamed);
4837 case Type::BlockPointer:
4839 case Type::LValueReference:
4840 case Type::RValueReference:
4842 case Type::MemberPointer: {
4844 CachedProperties Cls = [&] {
4845 if (MPT->isSugared())
4847 return Cache::get(MPT->getQualifier().getAsType());
4849 return merge(Cls,
Cache::get(MPT->getPointeeType()));
4851 case Type::ConstantArray:
4852 case Type::IncompleteArray:
4853 case Type::VariableArray:
4854 case Type::ArrayParameter:
4857 case Type::ExtVector:
4859 case Type::ConstantMatrix:
4861 case Type::FunctionNoProto:
4863 case Type::FunctionProto: {
4865 CachedProperties result =
Cache::get(FPT->getReturnType());
4866 for (
const auto &ai : FPT->param_types())
4870 case Type::ObjCInterface: {
4872 return CachedProperties(L,
false);
4874 case Type::ObjCObject:
4876 case Type::ObjCObjectPointer:
4882 case Type::HLSLAttributedResource:
4884 case Type::HLSLInlineSpirv:
4888 llvm_unreachable(
"unhandled type class");
4899 return TypeBits.hasLocalOrUnnamedType();
4903 switch (
T->getTypeClass()) {
4904#define TYPE(Class, Base)
4905#define NON_CANONICAL_TYPE(Class, Base) case Type::Class:
4906#include "clang/AST/TypeNodes.inc"
4907 llvm_unreachable(
"didn't expect a non-canonical type here");
4909#define TYPE(Class, Base)
4910#define DEPENDENT_TYPE(Class, Base) case Type::Class:
4911#define NON_CANONICAL_UNLESS_DEPENDENT_TYPE(Class, Base) case Type::Class:
4912#include "clang/AST/TypeNodes.inc"
4914 assert(
T->isInstantiationDependentType());
4922 case Type::DeducedTemplateSpecialization:
4934 case Type::BlockPointer:
4936 case Type::LValueReference:
4937 case Type::RValueReference:
4939 case Type::MemberPointer: {
4942 if (
auto *D = MPT->getMostRecentCXXRecordDecl()) {
4950 case Type::ConstantArray:
4951 case Type::IncompleteArray:
4952 case Type::VariableArray:
4953 case Type::ArrayParameter:
4956 case Type::ExtVector:
4958 case Type::ConstantMatrix:
4961 case Type::FunctionNoProto:
4963 case Type::FunctionProto: {
4966 for (
const auto &ai : FPT->param_types())
4970 case Type::ObjCInterface:
4972 case Type::ObjCObject:
4974 case Type::ObjCObjectPointer:
4981 case Type::HLSLAttributedResource:
4983 ->getContainedType()
4984 ->getCanonicalTypeInternal());
4985 case Type::HLSLInlineSpirv:
4989 llvm_unreachable(
"unhandled type class");
5003 if (!
T->isCanonicalUnqualified())
5017 while (
const auto *AT =
Type->getAs<AttributedType>()) {
5020 if (
auto Nullability = AT->getImmediateNullability())
5023 Type = AT->getEquivalentType();
5025 return std::nullopt;
5031 switch (
type->getTypeClass()) {
5032#define NON_CANONICAL_TYPE(Class, Parent) \
5035 llvm_unreachable("non-canonical type");
5036#define TYPE(Class, Parent)
5037#include "clang/AST/TypeNodes.inc"
5041 case Type::BlockPointer:
5042 case Type::MemberPointer:
5043 case Type::ObjCObjectPointer:
5047 case Type::UnresolvedUsing:
5048 case Type::TypeOfExpr:
5050 case Type::Decltype:
5051 case Type::PackIndexing:
5052 case Type::UnaryTransform:
5053 case Type::TemplateTypeParm:
5054 case Type::SubstTemplateTypeParmPack:
5055 case Type::SubstBuiltinTemplatePack:
5056 case Type::DependentName:
5058 return ResultIfUnknown;
5061 case Type::TemplateSpecialization:
5066 .getAsTemplateDecl())
5067 if (
auto *CTD = dyn_cast<ClassTemplateDecl>(templateDecl))
5068 return llvm::any_of(
5070 return RTD->getTemplatedDecl()->hasAttr<TypeNullableAttr>();
5072 return ResultIfUnknown;
5077#define SIGNED_TYPE(Id, SingletonId) case BuiltinType::Id:
5078#define UNSIGNED_TYPE(Id, SingletonId) case BuiltinType::Id:
5079#define FLOATING_TYPE(Id, SingletonId) case BuiltinType::Id:
5080#define BUILTIN_TYPE(Id, SingletonId)
5081#include "clang/AST/BuiltinTypes.def"
5084 case BuiltinType::UnresolvedTemplate:
5086 case BuiltinType::Dependent:
5087 case BuiltinType::Overload:
5088 case BuiltinType::BoundMember:
5089 case BuiltinType::PseudoObject:
5090 case BuiltinType::UnknownAny:
5091 case BuiltinType::ARCUnbridgedCast:
5092 return ResultIfUnknown;
5094 case BuiltinType::Void:
5095 case BuiltinType::ObjCId:
5096 case BuiltinType::ObjCClass:
5097 case BuiltinType::ObjCSel:
5098#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
5099 case BuiltinType::Id:
5100#include "clang/Basic/OpenCLImageTypes.def"
5101#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) case BuiltinType::Id:
5102#include "clang/Basic/OpenCLExtensionTypes.def"
5103 case BuiltinType::OCLSampler:
5104 case BuiltinType::OCLEvent:
5105 case BuiltinType::OCLClkEvent:
5106 case BuiltinType::OCLQueue:
5107 case BuiltinType::OCLReserveID:
5108#define SVE_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
5109#include "clang/Basic/AArch64ACLETypes.def"
5110#define PPC_VECTOR_TYPE(Name, Id, Size) case BuiltinType::Id:
5111#include "clang/Basic/PPCTypes.def"
5112#define RVV_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
5113#include "clang/Basic/RISCVVTypes.def"
5114#define WASM_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
5115#include "clang/Basic/WebAssemblyReferenceTypes.def"
5116#define AMDGPU_TYPE(Name, Id, SingletonId, Width, Align) case BuiltinType::Id:
5117#include "clang/Basic/AMDGPUTypes.def"
5118#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
5119#include "clang/Basic/HLSLIntangibleTypes.def"
5120 case BuiltinType::BuiltinFn:
5121 case BuiltinType::NullPtr:
5122 case BuiltinType::IncompleteMatrixIdx:
5123 case BuiltinType::ArraySection:
5124 case BuiltinType::OMPArrayShaping:
5125 case BuiltinType::OMPIterator:
5128 llvm_unreachable(
"unknown builtin type");
5130 case Type::Record: {
5134 if (
const auto *CTSD = dyn_cast<ClassTemplateSpecializationDecl>(RD))
5135 return llvm::any_of(
5136 CTSD->getSpecializedTemplate()->redecls(),
5138 return RTD->getTemplatedDecl()->hasAttr<TypeNullableAttr>();
5141 return RD->hasAttr<TypeNullableAttr>();
5147 case Type::LValueReference:
5148 case Type::RValueReference:
5149 case Type::ConstantArray:
5150 case Type::IncompleteArray:
5151 case Type::VariableArray:
5152 case Type::DependentSizedArray:
5153 case Type::DependentVector:
5154 case Type::DependentSizedExtVector:
5156 case Type::ExtVector:
5157 case Type::ConstantMatrix:
5158 case Type::DependentSizedMatrix:
5159 case Type::DependentAddressSpace:
5160 case Type::FunctionProto:
5161 case Type::FunctionNoProto:
5162 case Type::DeducedTemplateSpecialization:
5164 case Type::InjectedClassName:
5165 case Type::PackExpansion:
5166 case Type::ObjCObject:
5167 case Type::ObjCInterface:
5171 case Type::DependentBitInt:
5172 case Type::ArrayParameter:
5173 case Type::HLSLAttributedResource:
5174 case Type::HLSLInlineSpirv:
5177 llvm_unreachable(
"bad type kind!");
5180std::optional<NullabilityKind> AttributedType::getImmediateNullability()
const {
5181 if (getAttrKind() == attr::TypeNonNull)
5183 if (getAttrKind() == attr::TypeNullable)
5185 if (getAttrKind() == attr::TypeNullUnspecified)
5187 if (getAttrKind() == attr::TypeNullableResult)
5189 return std::nullopt;
5192std::optional<NullabilityKind>
5193AttributedType::stripOuterNullability(
QualType &
T) {
5195 if (
auto MacroTy = dyn_cast<MacroQualifiedType>(
T))
5196 AttrTy = MacroTy->getUnderlyingType();
5198 if (
auto attributed = dyn_cast<AttributedType>(AttrTy)) {
5199 if (
auto nullability = attributed->getImmediateNullability()) {
5200 T = attributed->getModifiedType();
5205 return std::nullopt;
5219 if (objcPtr->isObjCIdType()) {
5230 }
else if (objcPtr->isObjCQualifiedIdType()) {
5255 "cannot query implicit lifetime for non-inferrable type");
5260 while (
const auto *array = dyn_cast<ArrayType>(canon))
5261 canon = array->getElementType().getTypePtr();
5263 if (
const auto *
opt = dyn_cast<ObjCObjectPointerType>(canon)) {
5265 if (
opt->getObjectType()->isObjCClass())
5274 return typedefType->getDecl()->hasAttr<ObjCNSObjectAttr>();
5280 return typedefType->getDecl()->hasAttr<ObjCIndependentClassAttr>();
5293 return OPT->getPointeeType()->isObjCIndirectLifetimeType();
5295 return Ref->getPointeeType()->isObjCIndirectLifetimeType();
5297 return MemPtr->getPointeeType()->isObjCIndirectLifetimeType();
5305 while (
const ArrayType *array =
type->getAsArrayTypeUnsafe())
5306 type = array->getElementType().getTypePtr();
5307 return type->isObjCRetainableType();
5329 return RT->getDecl()
5330 ->getMostRecentDecl()
5331 ->hasAttr<CUDADeviceBuiltinSurfaceTypeAttr>();
5338 return RT->getDecl()
5339 ->getMostRecentDecl()
5340 ->hasAttr<CUDADeviceBuiltinTextureTypeAttr>();
5349 return ptr->getPointeeType()->hasSizedVLAType();
5351 return ref->getPointeeType()->hasSizedVLAType();
5357 return arr->getElementType()->hasSizedVLAType();
5364 return HLSLAttributedResourceType::findHandleTypeOnResource(
this) !=
nullptr;
5387 const RecordType *RT =
5393 assert(RD !=
nullptr &&
5394 "all HLSL structs and classes should be CXXRecordDecl");
5400 switch (
type.getObjCLifetime()) {
5412 if (
const auto *RD =
type->getBaseElementTypeUnsafe()->getAsRecordDecl()) {
5413 if (
const auto *CXXRD = dyn_cast<CXXRecordDecl>(RD)) {
5415 if (CXXRD->hasDefinition() && !CXXRD->hasTrivialDestructor())
5439 Qualifier.Profile(ID);
5451 auto *RD = getCXXRecordDecl();
5458 llvm::APSInt Val,
unsigned Scale) {
5459 llvm::FixedPointSemantics FXSema(Val.getBitWidth(), Scale, Val.isSigned(),
5462 llvm::APFixedPoint(Val, FXSema).toString(Str);
5469 : DeducedType(
Auto, DeducedAsType, ExtraDependence, Canon) {
5470 AutoTypeBits.Keyword = llvm::to_underlying(
Keyword);
5471 AutoTypeBits.NumArgs = TypeConstraintArgs.size();
5472 this->TypeConstraintConcept = TypeConstraintConcept;
5473 assert(TypeConstraintConcept || AutoTypeBits.NumArgs == 0);
5474 if (TypeConstraintConcept) {
5476 addDependence(TypeDependence::DependentInstantiation);
5491void AutoType::Profile(llvm::FoldingSetNodeID &ID,
const ASTContext &Context,
5496 ID.AddInteger((
unsigned)
Keyword);
5497 ID.AddBoolean(IsDependent);
5500 Arg.Profile(ID, Context);
5503void AutoType::Profile(llvm::FoldingSetNodeID &ID,
const ASTContext &Context) {
5504 Profile(ID, Context, getDeducedType(), getKeyword(), isDependentType(),
5505 getTypeConstraintConcept(), getTypeConstraintArguments());
5519 llvm_unreachable(
"unknown effect kind");
5525 return "nonblocking";
5527 return "nonallocating";
5531 return "allocating";
5533 llvm_unreachable(
"unknown effect kind");
5549 return std::nullopt;
5554 assert(0 &&
"effectProhibitingInference with non-inferable effect kind");
5557 llvm_unreachable(
"unknown effect kind");
5567 const Kind EK = Effect.kind();
5569 if (EK == CallerKind ||
5580 llvm_unreachable(
"unknown effect kind");
5592 unsigned InsertIdx = Effects.size();
5607 Errs.push_back({EC, NewEC});
5618 if (NewCondition || !Conditions.empty()) {
5619 if (Conditions.empty() && !Effects.empty())
5620 Conditions.resize(Effects.size());
5621 Conditions.insert(Conditions.begin() + InsertIdx,
5624 Effects.insert(Effects.begin() + InsertIdx, NewEC.
Effect);
5629 for (
const auto &Item :
Set)
5631 return Errs.empty();
5642 auto IterA = LHS.
begin(), EndA = LHS.
end();
5643 auto IterB = RHS.
begin(), EndB = RHS.
end();
5647 return std::tuple(LHS.Effect,
uintptr_t(LHS.Cond.getCondition())) <
5648 std::tuple(RHS.Effect,
uintptr_t(RHS.Cond.getCondition()));
5651 while (IterA != EndA && IterB != EndB) {
5656 else if (FEWCLess(B, A))
5667 assert(Errs.empty() &&
"conflict shouldn't be possible in getIntersection");
5680 Combined.
insert(RHS, Errs);
5701 llvm::interleaveComma(*
this, OS);
5711 llvm::interleaveComma(*
this, OS);
5718 assert(llvm::is_sorted(FX) &&
"effects should be sorted");
5719 assert((Conds.empty() || Conds.size() == FX.size()) &&
5720 "effects size should match conditions size");
5726 if (
Cond.getCondition() !=
nullptr)
5731const HLSLAttributedResourceType *
5732HLSLAttributedResourceType::findHandleTypeOnResource(
const Type *RT) {
5737 if (!RD->
fields().empty()) {
5738 const auto &FirstFD = RD->
fields().begin();
5739 return dyn_cast<HLSLAttributedResourceType>(
5740 FirstFD->getType().getTypePtr());
5746StringRef PredefinedSugarType::getName(Kind KD) {
5751 return "__signed_size_t";
5753 return "__ptrdiff_t";
5755 llvm_unreachable(
"unexpected kind");
Defines the clang::ASTContext interface.
Provides definitions for the various language-specific address spaces.
static std::optional< NonLoc > getIndex(ProgramStateRef State, const ElementRegion *ER, CharKind CK)
static Decl::Kind getKind(const Decl *D)
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate....
Defines the C++ template declaration subclasses.
static DeclT * getDefinitionOrSelf(DeclT *D)
Defines the ExceptionSpecificationType enumeration and various utility functions.
Defines the clang::IdentifierInfo, clang::IdentifierTable, and clang::Selector interfaces.
#define CC_VLS_CASE(ABI_VLEN)
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified.
Defines the clang::LangOptions interface.
llvm::MachO::Record Record
static QualType getUnderlyingType(const SubRegion *R)
static RecordDecl * getAsRecordDecl(QualType BaseType, HeuristicResolver &Resolver)
static bool isRecordType(QualType T)
Defines various enumerations that describe declaration and type specifiers.
static QualType getPointeeType(const MemRegion *R)
Defines the TargetCXXABI class, which abstracts details of the C++ ABI that we're targeting.
static TypeDependence getTemplateSpecializationTypeDependence(QualType Underlying, TemplateName T)
#define ENUMERATE_ATTRS(PREFIX)
#define SUGARED_TYPE_CLASS(Class)
TypePropertyCache< Private > Cache
static bool isTriviallyCopyableTypeImpl(const QualType &type, const ASTContext &Context, bool IsCopyConstructible)
static const T * getAsSugar(const Type *Cur)
This will check for a T (which should be a Type which can act as sugar, such as a TypedefType) by rem...
#define TRIVIAL_TYPE_CLASS(Class)
static CachedProperties computeCachedProperties(const Type *T)
C Language Family Type Representation.
Defines the clang::Visibility enumeration and various utility functions.
__DEVICE__ void * memcpy(void *__a, const void *__b, size_t __c)
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
BuiltinVectorTypeInfo getBuiltinVectorTypeInfo(const BuiltinType *VecTy) const
Returns the element type, element count and number of vectors (in case of tuple) for a builtin vector...
QualType getAtomicType(QualType T) const
Return the uniqued reference to the atomic type for the specified type.
QualType getParenType(QualType NamedType) const
QualType getRValueReferenceType(QualType T) const
Return the uniqued reference to the type for an rvalue reference to the specified type.
QualType getObjCInterfaceType(const ObjCInterfaceDecl *Decl, ObjCInterfaceDecl *PrevDecl=nullptr) const
getObjCInterfaceType - Return the unique reference to the type for the specified ObjC interface decl.
QualType getBlockPointerType(QualType T) const
Return the uniqued reference to the type for a block of the specified type.
QualType getAttributedType(attr::Kind attrKind, QualType modifiedType, QualType equivalentType, const Attr *attr=nullptr) const
QualType getFunctionNoProtoType(QualType ResultTy, const FunctionType::ExtInfo &Info) const
Return a K&R style C function type like 'int()'.
QualType getArrayParameterType(QualType Ty) const
Return the uniqued reference to a specified array parameter type from the original array type.
QualType getVectorType(QualType VectorType, unsigned NumElts, VectorKind VecKind) const
Return the unique reference to a vector type of the specified element type and size.
QualType getSubstTemplateTypeParmType(QualType Replacement, Decl *AssociatedDecl, unsigned Index, UnsignedOrNone PackIndex, bool Final) const
Retrieve a substitution-result type.
QualType getPointerType(QualType T) const
Return the uniqued reference to the type for a pointer to the specified type.
QualType getLValueReferenceType(QualType T, bool SpelledAsLValue=true) const
Return the uniqued reference to the type for an lvalue reference to the specified type.
QualType getConstantArrayType(QualType EltTy, const llvm::APInt &ArySize, const Expr *SizeExpr, ArraySizeModifier ASM, unsigned IndexTypeQuals) const
Return the unique reference to the type for a constant array of the specified element type.
const LangOptions & getLangOpts() const
QualType applyObjCProtocolQualifiers(QualType type, ArrayRef< ObjCProtocolDecl * > protocols, bool &hasError, bool allowOnPointerType=false) const
Apply Objective-C protocol qualifiers to the given type.
QualType getDecayedType(QualType T) const
Return the uniqued reference to the decayed version of the given type.
QualType 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.
QualType getAutoType(QualType DeducedType, AutoTypeKeyword Keyword, bool IsDependent, bool IsPack=false, TemplateDecl *TypeConstraintConcept=nullptr, ArrayRef< TemplateArgument > TypeConstraintArgs={}) const
C++11 deduced auto type.
CanQualType UnsignedCharTy
TemplateName getQualifiedTemplateName(NestedNameSpecifier Qualifier, bool TemplateKeyword, TemplateName Template) const
Retrieve the template name that represents a qualified template name such as std::vector.
QualType getFunctionType(QualType ResultTy, ArrayRef< QualType > Args, const FunctionProtoType::ExtProtoInfo &EPI) const
Return a normal function type with a typed argument list.
QualType getMemberPointerType(QualType T, NestedNameSpecifier Qualifier, const CXXRecordDecl *Cls) const
Return the uniqued reference to the type for a member pointer to the specified type in the specified ...
QualType getComplexType(QualType T) const
Return the uniqued reference to the type for a complex number with the specified element type.
QualType getExtVectorType(QualType VectorType, unsigned NumElts) const
Return the unique reference to an extended vector type of the specified element type and size.
const TargetInfo & getTargetInfo() const
QualType getIncompleteArrayType(QualType EltTy, ArraySizeModifier ASM, unsigned IndexTypeQuals) const
Return a unique reference to the type for an incomplete array of the specified element type.
QualType 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 getConstantArrayType(const ASTContext &Ctx) const
Represents an array type, per C99 6.7.5.2 - Array Declarators.
ArraySizeModifier getSizeModifier() const
Qualifiers getIndexTypeQualifiers() const
QualType getElementType() const
ArrayType(TypeClass tc, QualType et, QualType can, ArraySizeModifier sm, unsigned tq, const Expr *sz=nullptr)
Attr - This represents one attribute.
BitIntType(bool isUnsigned, unsigned NumBits)
[BoundsSafety] Represents a parent type class for CountAttributedType and similar sugar types that wi...
BoundsAttributedType(TypeClass TC, QualType Wrapped, QualType Canon)
decl_range dependent_decls() const
bool referencesFieldDecls() const
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
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)
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.
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.
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.
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.
A (possibly-)qualified type.
bool hasAddressDiscriminatedPointerAuth() const
bool isTriviallyCopyableType(const ASTContext &Context) const
Return true if this is a trivially copyable type (C++0x [basic.types]p9)
QualType IgnoreParens() const
Returns the specified type after dropping any outer-level parentheses.
QualType withFastQualifiers(unsigned TQs) const
bool hasNonTrivialToPrimitiveCopyCUnion() const
Check if this is or contains a C union that is non-trivial to copy, which is a union that has a membe...
bool isWebAssemblyFuncrefType() const
Returns true if it is a WebAssembly Funcref Type.
QualType getNonLValueExprType(const ASTContext &Context) const
Determine the type of a (typically non-lvalue) expression with the specified result type.
@ DK_objc_strong_lifetime
PrimitiveDefaultInitializeKind
@ PDIK_ARCWeak
The type is an Objective-C retainable pointer type that is qualified with the ARC __weak qualifier.
@ PDIK_Trivial
The type does not fall into any of the following categories.
@ PDIK_ARCStrong
The type is an Objective-C retainable pointer type that is qualified with the ARC __strong qualifier.
@ PDIK_Struct
The type is a struct containing a field whose type is not PCK_Trivial.
bool mayBeDynamicClass() const
Returns true if it is a class and it might be dynamic.
bool isNonWeakInMRRWithObjCWeak(const ASTContext &Context) const
const IdentifierInfo * getBaseTypeIdentifier() const
Retrieves a pointer to the name of the base type.
bool isBitwiseCloneableType(const ASTContext &Context) const
Return true if the type is safe to bitwise copy using memcpy/memmove.
void Profile(llvm::FoldingSetNodeID &ID) const
QualType getDesugaredType(const ASTContext &Context) const
Return the specified type with any "sugar" removed from the type.
bool isTriviallyCopyConstructibleType(const ASTContext &Context) const
Return true if this is a trivially copyable type.
bool isTrivialType(const ASTContext &Context) const
Return true if this is a trivial type per (C++0x [basic.types]p9)
bool isNull() const
Return true if this QualType doesn't point to a type yet.
PrimitiveCopyKind isNonTrivialToPrimitiveCopy() const
Check if this is a non-trivial type that would cause a C struct transitively containing this type to ...
const Type * getTypePtr() const
Retrieves a pointer to the underlying (unqualified) type.
LangAS getAddressSpace() const
Return the address space of this type.
bool isConstant(const ASTContext &Ctx) const
bool hasNonTrivialToPrimitiveDestructCUnion() const
Check if this is or contains a C union that is non-trivial to destruct, which is a union that has a m...
Qualifiers getQualifiers() const
Retrieve the set of qualifiers applied to this type.
bool isCXX98PODType(const ASTContext &Context) const
Return true if this is a POD type according to the rules of the C++98 standard, regardless of the cur...
Qualifiers::ObjCLifetime getObjCLifetime() const
Returns lifetime attribute of this type.
QualType stripObjCKindOfType(const ASTContext &ctx) const
Strip Objective-C "__kindof" types from the given type.
QualType getCanonicalType() const
QualType getUnqualifiedType() const
Retrieve the unqualified variant of the given type, removing as little sugar as possible.
QualType substObjCMemberType(QualType objectType, const DeclContext *dc, ObjCSubstitutionContext context) const
Substitute type arguments from an object type for the Objective-C type parameters used in the subject...
bool isWebAssemblyReferenceType() const
Returns true if it is a WebAssembly Reference Type.
SplitQualType getSplitDesugaredType() const
std::optional< NonConstantStorageReason > isNonConstantStorage(const ASTContext &Ctx, bool ExcludeCtor, bool ExcludeDtor)
Determine whether instances of this type can be placed in immutable storage.
SplitQualType split() const
Divides a QualType into its unqualified type and a set of local qualifiers.
bool UseExcessPrecision(const ASTContext &Ctx)
PrimitiveDefaultInitializeKind isNonTrivialToPrimitiveDefaultInitialize() const
Functions to query basic properties of non-trivial C struct types.
void * getAsOpaquePtr() const
bool isWebAssemblyExternrefType() const
Returns true if it is a WebAssembly Externref Type.
QualType getNonPackExpansionType() const
Remove an outer pack expansion type (if any) from this type.
bool isCXX11PODType(const ASTContext &Context) const
Return true if this is a POD type according to the more relaxed rules of the C++11 standard,...
bool mayBeNotDynamicClass() const
Returns true if it is not a class or if the class might not be dynamic.
bool isConstQualified() const
Determine whether this type is const-qualified.
QualType substObjCTypeArgs(ASTContext &ctx, ArrayRef< QualType > typeArgs, ObjCSubstitutionContext context) const
Substitute type arguments for the Objective-C type parameters used in the subject type.
QualType getAtomicUnqualifiedType() const
Remove all qualifiers including _Atomic.
bool hasNonTrivialObjCLifetime() const
bool isPODType(const ASTContext &Context) const
Determine whether this is a Plain Old Data (POD) type (C++ 3.9p10).
PrimitiveCopyKind isNonTrivialToPrimitiveDestructiveMove() const
Check if this is a non-trivial type that would cause a C struct transitively containing this type to ...
@ NonConstNonReferenceType
@ PCK_Struct
The type is a struct containing a field whose type is neither PCK_Trivial nor PCK_VolatileTrivial.
@ PCK_Trivial
The type does not fall into any of the following categories.
@ PCK_ARCStrong
The type is an Objective-C retainable pointer type that is qualified with the ARC __strong qualifier.
@ PCK_VolatileTrivial
The type would be trivial except that it is volatile-qualified.
@ PCK_PtrAuth
The type is an address-discriminated signed pointer type.
@ PCK_ARCWeak
The type is an Objective-C retainable pointer type that is qualified with the ARC __weak qualifier.
bool hasNonTrivialToPrimitiveDefaultInitializeCUnion() const
Check if this is or contains a C union that is non-trivial to default-initialize, which is a union th...
A qualifier set is used to build a set of qualifiers.
const Type * strip(QualType type)
Collect any qualifiers on the given type and return an unqualified type.
QualType apply(const ASTContext &Context, QualType QT) const
Apply the collected qualifiers to the given type.
The collection of all-type qualifiers we support.
@ OCL_Strong
Assigning into this object requires the old value to be released and the new value to be retained.
@ OCL_ExplicitNone
This object can be modified without requiring retains or releases.
@ OCL_None
There is no lifetime qualification on this type.
@ OCL_Weak
Reading or writing from this object requires a barrier call.
@ OCL_Autoreleasing
Assigning into this object requires a lifetime extension.
bool isStrictSupersetOf(Qualifiers Other) const
Determine whether this set of qualifiers is a strict superset of another set of qualifiers,...
bool hasNonFastQualifiers() const
Return true if the set contains any qualifiers which require an ExtQuals node to be allocated.
void addConsistentQualifiers(Qualifiers qs)
Add the qualifiers from the given set to this set, given that they don't conflict.
static bool isTargetAddressSpaceSupersetOf(LangAS A, LangAS B, const ASTContext &Ctx)
bool hasAddressSpace() const
unsigned getFastQualifiers() const
bool hasObjCGCAttr() const
bool hasObjCLifetime() const
ObjCLifetime getObjCLifetime() const
LangAS getAddressSpace() const
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.
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 isHLSLBuiltinIntangibleType() const
TypeOfBitfields TypeOfBits
bool isIntegerType() const
isIntegerType() does not include complex integers (a GCC extension).
bool isSVESizelessBuiltinType() const
Returns true for SVE scalable vector types.
const T * castAs() const
Member-template castAs<specific type>.
bool isReferenceType() const
bool isHLSLIntangibleType() const
bool isEnumeralType() const
void addDependence(TypeDependence D)
bool isObjCNSObjectType() const
Type(TypeClass tc, QualType canon, TypeDependence Dependence)
const ObjCObjectPointerType * getAsObjCInterfacePointerType() const
NestedNameSpecifier getPrefix() const
If this type represents a qualified-id, this returns its nested name specifier.
bool isScalarType() const
const CXXRecordDecl * getPointeeCXXRecordDecl() const
If this is a pointer or reference to a RecordType, return the CXXRecordDecl that the type refers to.
bool isInterfaceType() const
bool isVariableArrayType() const
bool isSizelessBuiltinType() const
bool isCUDADeviceBuiltinSurfaceType() const
Check if the type is the CUDA device builtin surface type.
bool isSveVLSBuiltinType() const
Determines if this is a sizeless type supported by the 'arm_sve_vector_bits' type attribute,...
bool isIntegralType(const ASTContext &Ctx) const
Determine whether this type is an integral type.
bool isElaboratedTypeSpecifier() const
Determine wither this type is a C++ elaborated-type-specifier.
CountAttributedTypeBitfields CountAttributedTypeBits
const Type * getArrayElementTypeNoTypeQual() const
If this is an array type, return the element type of the array, potentially with type qualifiers miss...
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee.
LinkageInfo getLinkageAndVisibility() const
Determine the linkage and visibility of this type.
bool hasUnsignedIntegerRepresentation() const
Determine whether this type has an unsigned integer representation of some sort, e....
bool isAnyCharacterType() const
Determine whether this type is any of the built-in character types.
bool isExtVectorBoolType() const
bool isWebAssemblyExternrefType() const
Check if this is a WebAssembly Externref Type.
bool canHaveNullability(bool ResultIfUnknown=true) const
Determine whether the given type can have a nullability specifier applied to it, i....
QualType getSveEltType(const ASTContext &Ctx) const
Returns the representative type for the element of an SVE builtin type.
bool isInstantiationDependentType() const
Determine whether this type is an instantiation-dependent type, meaning that the type involves a temp...
bool isLValueReferenceType() const
bool isBitIntType() const
bool isBuiltinType() const
Helper methods to distinguish type categories.
bool isStructuralType() const
Determine if this type is a structural type, per C++20 [temp.param]p7.
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
bool isAggregateType() const
Determines whether the type is a C++ aggregate type or C aggregate or union type.
bool isCARCBridgableType() const
Determine whether the given type T is a "bridgeable" C type.
bool isSignableIntegerType(const ASTContext &Ctx) const
RecordDecl * castAsRecordDecl() const
bool isChar16Type() const
bool isAnyComplexType() const
DeducedType * getContainedDeducedType() const
Get the DeducedType whose type will be deduced for a variable with an initializer of this type.
bool containsUnexpandedParameterPack() const
Whether this type is or contains an unexpanded parameter pack, used to support C++0x variadic templat...
ScalarTypeKind getScalarTypeKind() const
Given that this is a scalar type, classify it.
bool hasSignedIntegerRepresentation() const
Determine whether this type has an signed integer representation of some sort, e.g....
QualType getCanonicalTypeInternal() const
const RecordType * getAsStructureType() const
const char * getTypeClassName() const
bool isWebAssemblyTableType() const
Returns true if this is a WebAssembly table type: either an array of reference types,...
@ PtrdiffT
The "ptrdiff_t" type.
@ SizeT
The "size_t" type.
@ SignedSizeT
The signed integer type corresponding to "size_t".
const Type * getBaseElementTypeUnsafe() const
Get the base element type of this type, potentially discarding type qualifiers.
AttributedTypeBitfields AttributedTypeBits
bool isObjCBoxableRecordType() const
bool isChar32Type() const
bool isStandardLayoutType() const
Test if this type is a standard-layout type.
TagTypeBitfields TagTypeBits
EnumDecl * castAsEnumDecl() const
bool isVariablyModifiedType() const
Whether this type is a variably-modified type (C99 6.7.5).
bool isComplexIntegerType() const
bool isUnscopedEnumerationType() const
bool isStdByteType() const
UnresolvedUsingBitfields UnresolvedUsingBits
bool isCUDADeviceBuiltinTextureType() const
Check if the type is the CUDA device builtin texture type.
bool isBlockCompatibleObjCPointerType(ASTContext &ctx) const
bool isObjCClassOrClassKindOfType() const
Whether the type is Objective-C 'Class' or a __kindof type of an Class type, e.g.,...
const ArrayType * getAsArrayTypeUnsafe() const
A variant of getAs<> for array types which silently discards qualifiers from the outermost type.
bool isObjCLifetimeType() const
Returns true if objects of this type have lifetime semantics under ARC.
bool isHLSLResourceRecord() const
EnumDecl * getAsEnumDecl() const
Retrieves the EnumDecl this type refers to.
bool isObjCIndirectLifetimeType() const
bool hasUnnamedOrLocalType() const
Whether this type is or contains a local or unnamed type.
bool isPointerOrReferenceType() const
Qualifiers::ObjCLifetime getObjCARCImplicitLifetime() const
Return the implicit lifetime for this type, which must not be dependent.
FunctionTypeBitfields FunctionTypeBits
bool isObjCQualifiedInterfaceType() const
bool isSpecifierType() const
Returns true if this type can be represented by some set of type specifiers.
bool isIncompleteType(NamedDecl **Def=nullptr) const
Types are partitioned into 3 broad categories (C99 6.2.5p1): object types, function types,...
bool isObjCObjectPointerType() const
SubstTemplateTypeParmTypeBitfields SubstTemplateTypeParmTypeBits
bool isStructureTypeWithFlexibleArrayMember() const
TypeDependence getDependence() const
bool hasFloatingRepresentation() const
Determine whether this type has a floating-point representation of some sort, e.g....
bool isStructureOrClassType() const
bool isVectorType() const
bool isRVVVLSBuiltinType() const
Determines if this is a sizeless type supported by the 'riscv_rvv_vector_bits' type attribute,...
bool isRealFloatingType() const
Floating point categories.
bool isRVVSizelessBuiltinType() const
Returns true for RVV scalable vector types.
std::optional< ArrayRef< QualType > > getObjCSubstitutions(const DeclContext *dc) const
Retrieve the set of substitutions required when accessing a member of the Objective-C receiver type t...
const T * getAsCanonical() const
If this type is canonically the specified type, return its canonical type cast to that specified type...
Linkage getLinkage() const
Determine the linkage of this type.
ObjCObjectTypeBitfields ObjCObjectTypeBits
bool isFloatingType() const
const ObjCObjectType * getAsObjCInterfaceType() const
bool isWideCharType() const
bool isUnsignedIntegerType() const
Return true if this is an integer type that is unsigned, according to C99 6.2.5p6 [which returns true...
bool hasSizedVLAType() const
Whether this type involves a variable-length array type with a definite size.
TypeClass getTypeClass() const
bool isCanonicalUnqualified() const
Determines if this type would be canonical if it had no further qualification.
bool hasAutoForTrailingReturnType() const
Determine whether this type was written with a leading 'auto' corresponding to a trailing return type...
bool isObjCIdOrObjectKindOfType(const ASTContext &ctx, const ObjCObjectType *&bound) const
Whether the type is Objective-C 'id' or a __kindof type of an object type, e.g., __kindof NSView * or...
const T * getAs() const
Member-template getAs<specific type>'.
const Type * getUnqualifiedDesugaredType() const
Return the specified type with any "sugar" removed from the type, removing any typedefs,...
bool isObjCARCImplicitlyUnretainedType() const
Determines if this type, which must satisfy isObjCLifetimeType(), is implicitly __unsafe_unretained r...
bool isRecordType() const
bool isHLSLResourceRecordArray() const
bool isObjCRetainableType() const
std::optional< NullabilityKind > getNullability() const
Determine the nullability of the given type.
bool isObjCIndependentClassType() const
bool isSizelessVectorType() const
Returns true for all scalable vector types.
bool isScopedEnumeralType() const
Determine whether this type is a scoped enumeration type.
bool acceptsObjCTypeParams() const
Determines if this is an ObjC interface type that may accept type parameters.
QualType getSizelessVectorEltType(const ASTContext &Ctx) const
Returns the representative type for the element of a sizeless vector builtin type.
bool isUnicodeCharacterType() const
bool hasBooleanRepresentation() const
Determine whether this type has a boolean representation – i.e., it is a boolean type,...
Base class for declarations which introduce a typedef-name.
QualType getUnderlyingType() const
bool typeMatchesDecl() const
Represents a dependent using declaration which was marked with typename.
Represents a shadow declaration implicitly introduced into a scope by a (resolved) using-declaration ...
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
Represents a GCC generic vector type.
VectorType(QualType vecType, unsigned nElements, QualType canonType, VectorKind vecKind)
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.
const FunctionProtoType * T
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)
std::tuple< NamedDecl *, TemplateArgument > getReplacedTemplateParameter(Decl *D, unsigned Index)
Internal helper used by Subst* nodes to retrieve a parameter from the AssociatedDecl,...
bool isPtrSizeAddressSpace(LangAS AS)
const StreamingDiagnostic & operator<<(const StreamingDiagnostic &DB, const ConceptReference *C)
Insertion operator for diagnostics.
CallingConv
CallingConv - Specifies the calling convention that a function uses.
U cast(CodeGen::Address addr)
@ None
The alignment was not explicit in code.
ElaboratedTypeKeyword
The elaboration keyword that precedes a qualified type name or introduces an elaborated-type-specifie...
@ Interface
The "__interface" keyword introduces the elaborated-type-specifier.
@ None
No keyword precedes the qualified type name.
@ Struct
The "struct" keyword introduces the elaborated-type-specifier.
@ Class
The "class" keyword introduces the elaborated-type-specifier.
@ Union
The "union" keyword introduces the elaborated-type-specifier.
@ Enum
The "enum" keyword introduces the elaborated-type-specifier.
@ Typename
The "typename" keyword precedes the qualified type name, e.g., typename T::type.
TypeDependence toSemanticDependence(TypeDependence D)
TypeDependence toSyntacticDependence(TypeDependence D)
@ Other
Other implicit parameter.
@ EST_DependentNoexcept
noexcept(expression), value-dependent
@ EST_Uninstantiated
not instantiated yet
@ EST_Unparsed
not parsed yet
@ EST_NoThrow
Microsoft __declspec(nothrow) extension.
@ EST_None
no exception specification
@ EST_MSAny
Microsoft throw(...) extension.
@ EST_BasicNoexcept
noexcept
@ EST_NoexceptFalse
noexcept(expression), evals to 'false'
@ EST_Unevaluated
not evaluated yet, for special member function
@ EST_NoexceptTrue
noexcept(expression), evals to 'true'
@ EST_Dynamic
throw(T1, T2)
__UINTPTR_TYPE__ uintptr_t
An unsigned integer type with the property that any valid pointer to void can be converted to this ty...
A FunctionEffect plus a potential boolean expression determining whether the effect is declared (e....
FunctionEffectWithCondition(FunctionEffect E, const EffectConditionExpr &C)
std::string description() const
Return a textual description of the effect, and its condition, if any.
FunctionDecl * SourceDecl
The function whose exception specification this is, for EST_Unevaluated and EST_Uninstantiated.
FunctionDecl * SourceTemplate
The function template whose exception specification this is instantiated from, for EST_Uninstantiated...
ExceptionSpecificationType Type
The kind of exception specification this is.
ArrayRef< QualType > Exceptions
Explicitly-specified list of exception types.
Expr * NoexceptExpr
Noexcept expression, if this is a computed noexcept specification.
Extra information about a function prototype.
ExceptionSpecInfo ExceptionSpec
FunctionTypeExtraAttributeInfo ExtraAttributeInfo
bool requiresFunctionProtoTypeArmAttributes() const
unsigned AArch64SMEAttributes
SourceLocation EllipsisLoc
FunctionEffectsRef FunctionEffects
unsigned CFIUncheckedCallee
const ExtParameterInfo * ExtParameterInfos
RefQualifierKind RefQualifier
bool requiresFunctionProtoTypeExtraAttributeInfo() const
unsigned HasTrailingReturn
bool requiresFunctionProtoTypeExtraBitfields() const
static StringRef getKeywordName(ElaboratedTypeKeyword Keyword)
static ElaboratedTypeKeyword getKeywordForTagTypeKind(TagTypeKind Tag)
Converts a TagTypeKind into an elaborated type keyword.
static TagTypeKind getTagTypeKindForKeyword(ElaboratedTypeKeyword Keyword)
Converts an elaborated type keyword into a TagTypeKind.
static TagTypeKind getTagTypeKindForTypeSpec(unsigned TypeSpec)
Converts a type specifier (DeclSpec::TST) into a tag type kind.
static bool KeywordIsTagTypeKind(ElaboratedTypeKeyword Keyword)
static ElaboratedTypeKeyword getKeywordForTypeSpec(unsigned TypeSpec)
Converts a type specifier (DeclSpec::TST) into an elaborated type keyword.
Describes how types, statements, expressions, and declarations should be printed.
unsigned Bool
Whether we can use 'bool' rather than '_Bool' (even if the language doesn't actually have 'bool',...
unsigned NullptrTypeInNamespace
Whether 'nullptr_t' is in namespace 'std' or not.
unsigned Half
When true, print the half-precision floating-point type as 'half' instead of '__fp16'.
unsigned MSWChar
When true, print the built-in wchar_t type as __wchar_t.
A std::pair-like structure for storing a qualified type split into its local qualifiers and its local...
const Type * Ty
The locally-unqualified type.
Qualifiers Quals
The local qualifiers.
constexpr unsigned toInternalRepresentation() const