40 #include "llvm/ADT/APInt.h" 41 #include "llvm/ADT/APSInt.h" 42 #include "llvm/ADT/ArrayRef.h" 43 #include "llvm/ADT/FoldingSet.h" 44 #include "llvm/ADT/None.h" 45 #include "llvm/ADT/SmallVector.h" 46 #include "llvm/Support/Casting.h" 47 #include "llvm/Support/ErrorHandling.h" 48 #include "llvm/Support/MathExtras.h" 53 #include <type_traits> 55 using namespace clang;
58 return (*
this != Other) &&
73 const Type* ty = getTypePtr();
85 getElementType().getBaseTypeIdentifier();
93 const auto *ClassDecl = getTypePtr()->getPointeeCXXRecordDecl();
94 return ClassDecl && ClassDecl->mayBeDynamicClass();
98 const auto *ClassDecl = getTypePtr()->getPointeeCXXRecordDecl();
99 return !ClassDecl || ClassDecl->mayBeNonDynamicClass();
107 return AT->getElementType().isConstant(Ctx);
126 et->isDependentType() || (sz && sz->isValueDependent()) ||
127 tc == DependentSizedArray,
128 et->isInstantiationDependentType() ||
129 (sz && sz->isInstantiationDependent()) ||
130 tc == DependentSizedArray,
131 (tc == VariableArray || et->isVariablyModifiedType()),
132 et->containsUnexpandedParameterPack() ||
133 (sz && sz->containsUnexpandedParameterPack())),
150 if (llvm::isPowerOf2_64(ElementSize)) {
151 return NumElements.getActiveBits() + llvm::Log2_64(ElementSize);
156 if ((ElementSize >> 32) == 0 && NumElements.getBitWidth() <= 64 &&
157 (NumElements.getZExtValue() >> 32) == 0) {
158 uint64_t TotalSize = NumElements.getZExtValue() * ElementSize;
159 return 64 - llvm::countLeadingZeros(TotalSize);
165 SizeExtended = SizeExtended.extend(
std::max(SizeTypeBits,
166 SizeExtended.getBitWidth()) * 2);
169 TotalSize *= SizeExtended;
171 return TotalSize.getActiveBits();
190 unsigned TypeQuals) {
192 ID.AddInteger(ArraySize.getZExtValue());
193 ID.AddInteger(SizeMod);
194 ID.AddInteger(TypeQuals);
195 ID.AddBoolean(SizeExpr != 0);
197 SizeExpr->
Profile(ID, Context,
true);
200 DependentSizedArrayType::DependentSizedArrayType(
const ASTContext &Context,
205 :
ArrayType(DependentSizedArray, et, can, sm, tq, e),
206 Context(Context), SizeExpr((
Stmt*) e), Brackets(brackets) {}
215 ID.AddInteger(SizeMod);
216 ID.AddInteger(TypeQuals);
220 DependentVectorType::DependentVectorType(
223 :
Type(DependentVector, CanonType,
true,
228 Context(Context), ElementType(ElementType), SizeExpr(SizeExpr), Loc(Loc) {
237 ID.AddInteger(VecKind);
238 SizeExpr->
Profile(ID, Context,
true);
241 DependentSizedExtVectorType::DependentSizedExtVectorType(
const 247 :
Type(DependentSizedExtVector, can,
true,
252 Context(Context), SizeExpr(SizeExpr), ElementType(ElementType),
260 SizeExpr->
Profile(ID, Context,
true);
263 DependentAddressSpaceType::DependentAddressSpaceType(
266 :
Type(DependentAddressSpace, can,
true,
272 Context(Context), AddrSpaceExpr(AddrSpaceExpr), PointeeType(PointeeType),
278 Expr *AddrSpaceExpr) {
280 AddrSpaceExpr->
Profile(ID, Context,
true);
285 :
VectorType(Vector, vecType, nElements, canonType, vecKind) {}
293 ElementType(vecType) {
303 if (
const auto *ATy = dyn_cast<ArrayType>(
this))
304 return ATy->getElementType().getTypePtr();
307 if (!isa<ArrayType>(CanonicalType))
337 #define TYPE(CLASS, BASE) \ 338 static_assert(!std::is_polymorphic<CLASS##Type>::value, \ 339 #CLASS "Type should not be polymorphic!"); 340 #include "clang/AST/TypeNodes.inc" 348 #define TYPE(CLASS, BASE) \ 349 static_assert(std::is_trivially_destructible<CLASS##Type>::value || \ 350 std::is_same<CLASS##Type, ConstantArrayType>::value, \ 351 #CLASS "Type should be trivially destructible!"); 352 #include "clang/AST/TypeNodes.inc" 356 #define ABSTRACT_TYPE(Class, Parent) 357 #define TYPE(Class, Parent) \ 358 case Type::Class: { \ 359 const auto *ty = cast<Class##Type>(this); \ 360 if (!ty->isSugared()) return QualType(ty, 0); \ 361 return ty->desugar(); \ 363 #include "clang/AST/TypeNodes.inc" 365 llvm_unreachable(
"bad type kind!");
375 #define ABSTRACT_TYPE(Class, Parent) 376 #define TYPE(Class, Parent) \ 377 case Type::Class: { \ 378 const auto *Ty = cast<Class##Type>(CurTy); \ 379 if (!Ty->isSugared()) \ 380 return SplitQualType(Ty, Qs); \ 381 Cur = Ty->desugar(); \ 384 #include "clang/AST/TypeNodes.inc" 396 const Type *lastTypeWithQuals = split.
Ty;
404 #define ABSTRACT_TYPE(Class, Parent) 405 #define TYPE(Class, Parent) \ 406 case Type::Class: { \ 407 const auto *ty = cast<Class##Type>(split.Ty); \ 408 if (!ty->isSugared()) goto done; \ 409 next = ty->desugar(); \ 412 #include "clang/AST/TypeNodes.inc" 417 split = next.
split();
419 lastTypeWithQuals = split.
Ty;
431 T = PT->getInnerType();
440 if (
const auto *Sugar = dyn_cast<T>(Cur))
443 #define ABSTRACT_TYPE(Class, Parent) 444 #define TYPE(Class, Parent) \ 445 case Type::Class: { \ 446 const auto *Ty = cast<Class##Type>(Cur); \ 447 if (!Ty->isSugared()) return 0; \ 448 Cur = Ty->desugar().getTypePtr(); \ 451 #include "clang/AST/TypeNodes.inc" 457 return getAsSugar<TypedefType>(
this);
461 return getAsSugar<TemplateSpecializationType>(
this);
465 return getAsSugar<AttributedType>(
this);
472 const Type *Cur =
this;
476 #define ABSTRACT_TYPE(Class, Parent) 477 #define TYPE(Class, Parent) \ 479 const auto *Ty = cast<Class##Type>(Cur); \ 480 if (!Ty->isSugared()) return Cur; \ 481 Cur = Ty->desugar().getTypePtr(); \ 484 #include "clang/AST/TypeNodes.inc" 490 if (
const auto *RT = getAs<RecordType>())
491 return RT->getDecl()->isClass();
496 if (
const auto *RT = getAs<RecordType>())
497 return RT->getDecl()->isStruct();
502 if (
const auto *RT = getAs<RecordType>())
503 return RT->getDecl()->hasAttr<ObjCBoxableAttr>();
508 if (
const auto *RT = getAs<RecordType>())
509 return RT->getDecl()->isInterface();
514 if (
const auto *RT = getAs<RecordType>()) {
522 if (
const auto *PT = getAs<PointerType>())
523 return PT->getPointeeType()->isVoidType();
528 if (
const auto *RT = getAs<RecordType>())
529 return RT->getDecl()->isUnion();
534 if (
const auto *CT = dyn_cast<ComplexType>(CanonicalType))
535 return CT->getElementType()->isFloatingType();
545 if (
const auto *ET = getAs<EnumType>())
546 return ET->getDecl()->isScoped();
551 if (
const auto *
Complex = getAs<ComplexType>())
552 if (
Complex->getElementType()->isIntegerType())
558 if (
const auto *PT = getAs<PointerType>())
560 if (
const auto *OPT = getAs<ObjCObjectPointerType>())
562 if (
const auto *BPT = getAs<BlockPointerType>())
564 if (
const auto *RT = getAs<ReferenceType>())
566 if (
const auto *MPT = getAs<MemberPointerType>())
568 if (
const auto *DT = getAs<DecayedType>())
575 if (
const auto *RT = dyn_cast<RecordType>(
this)) {
576 if (RT->getDecl()->isStruct())
581 if (
const auto *RT = dyn_cast<RecordType>(CanonicalType)) {
582 if (!RT->getDecl()->isStruct())
594 if (
const auto *RT = dyn_cast<RecordType>(
this)) {
595 if (RT->getDecl()->isUnion())
600 if (
const auto *RT = dyn_cast<RecordType>(CanonicalType)) {
601 if (!RT->getDecl()->isUnion())
616 const auto *OPT = getAs<ObjCObjectPointerType>();
621 if (OPT->isObjCIdType())
625 if (!OPT->isKindOfType())
629 if (OPT->isObjCClassType() || OPT->isObjCQualifiedClassType())
639 const auto *OPT = getAs<ObjCObjectPointerType>();
644 if (OPT->isObjCClassType())
648 if (!OPT->isKindOfType())
652 return OPT->isObjCClassType() || OPT->isObjCQualifiedClassType();
662 OTPDecl(const_cast<ObjCTypeParamDecl*>(D)) {
679 "bitfield overflow in type argument count");
680 if (!typeArgs.empty())
681 memcpy(getTypeArgStorage(), typeArgs.data(),
682 typeArgs.size() *
sizeof(
QualType));
684 for (
auto typeArg : typeArgs) {
685 if (typeArg->isDependentType())
687 else if (typeArg->isInstantiationDependentType())
690 if (typeArg->containsUnexpandedParameterPack())
704 if (
const auto objcObject =
getBaseType()->getAs<ObjCObjectType>()) {
706 if (isa<ObjCInterfaceType>(objcObject))
709 return objcObject->isSpecialized();
722 if (
const auto objcObject =
getBaseType()->getAs<ObjCObjectType>()) {
724 if (isa<ObjCInterfaceType>(objcObject))
727 return objcObject->getTypeArgs();
739 if (
const auto objcObject =
getBaseType()->getAs<ObjCObjectType>()) {
741 if (isa<ObjCInterfaceType>(objcObject))
744 return objcObject->isKindOfType();
760 baseType = baseObj->stripObjCKindOfTypeAndQuals(ctx);
763 splitBaseType.
Quals),
782 template <
typename Derived>
783 struct SimpleTransformVisitor :
public TypeVisitor<Derived, QualType> {
791 QualType result =
static_cast<Derived *
>(
this)->Visit(splitType.
Ty);
797 return Ctx.getQualifiedType(result, splitType.
Quals);
801 explicit SimpleTransformVisitor(
ASTContext &ctx) : Ctx(ctx) {}
805 #define TYPE(Class, Base) 806 #define DEPENDENT_TYPE(Class, Base) \ 807 QualType Visit##Class##Type(const Class##Type *T) { return QualType(T, 0); } 808 #include "clang/AST/TypeNodes.inc" 810 #define TRIVIAL_TYPE_CLASS(Class) \ 811 QualType Visit##Class##Type(const Class##Type *T) { return QualType(T, 0); } 812 #define SUGARED_TYPE_CLASS(Class) \ 813 QualType Visit##Class##Type(const Class##Type *T) { \ 814 if (!T->isSugared()) \ 815 return QualType(T, 0); \ 816 QualType desugaredType = recurse(T->desugar()); \ 817 if (desugaredType.isNull()) \ 819 if (desugaredType.getAsOpaquePtr() == T->desugar().getAsOpaquePtr()) \ 820 return QualType(T, 0); \ 821 return desugaredType; \ 834 return Ctx.getComplexType(elementType);
845 return Ctx.getPointerType(pointeeType);
856 return Ctx.getBlockPointerType(pointeeType);
880 return Ctx.getRValueReferenceType(pointeeType);
891 return Ctx.getMemberPointerType(pointeeType, T->
getClass());
915 return Ctx.getVariableArrayType(elementType, T->
getSizeExpr(),
964 return Ctx.getFunctionNoProtoType(returnType, T->
getExtInfo());
974 bool paramChanged =
false;
976 QualType newParamType = recurse(paramType);
977 if (newParamType.
isNull())
983 paramTypes.push_back(newParamType);
988 bool exceptionChanged =
false;
992 QualType newExceptionType = recurse(exceptionType);
993 if (newExceptionType.
isNull())
996 if (newExceptionType.
getAsOpaquePtr() != exceptionType.getAsOpaquePtr())
997 exceptionChanged =
true;
999 exceptionTypes.push_back(newExceptionType);
1002 if (exceptionChanged) {
1004 llvm::makeArrayRef(exceptionTypes).copy(Ctx);
1009 !paramChanged && !exceptionChanged)
1012 return Ctx.getFunctionType(returnType, paramTypes, info);
1023 return Ctx.getParenType(innerType);
1032 if (originalType.
isNull())
1036 if (adjustedType.
isNull())
1044 return Ctx.getAdjustedType(originalType, adjustedType);
1049 if (originalType.
isNull())
1056 return Ctx.getDecayedType(originalType);
1071 if (modifiedType.
isNull())
1075 if (equivalentType.
isNull())
1084 return Ctx.getAttributedType(T->
getAttrKind(), modifiedType,
1090 if (replacementType.
isNull())
1109 if (deducedType.
isNull())
1116 return Ctx.getAutoType(deducedType, T->
getKeyword(),
1131 bool typeArgChanged =
false;
1134 QualType newTypeArg = recurse(typeArg);
1139 typeArgChanged =
true;
1141 typeArgs.push_back(newTypeArg);
1148 return Ctx.getObjCObjectType(baseType, typeArgs,
1158 if (pointeeType.
isNull())
1165 return Ctx.getObjCObjectPointerType(pointeeType);
1177 return Ctx.getAtomicType(valueType);
1180 #undef TRIVIAL_TYPE_CLASS 1181 #undef SUGARED_TYPE_CLASS 1184 struct SubstObjCTypeArgsVisitor
1185 :
public SimpleTransformVisitor<SubstObjCTypeArgsVisitor> {
1186 using BaseType = SimpleTransformVisitor<SubstObjCTypeArgsVisitor>;
1193 : BaseType(ctx), TypeArgs(typeArgs), SubstContext(context) {}
1200 if (!TypeArgs.empty()) {
1211 argType, protocolsToApply, hasError,
true);
1214 switch (SubstContext) {
1224 const auto *objPtr =
1229 if (objPtr->isKindOfType() || objPtr->isObjCIdOrClassType())
1233 const auto *obj = objPtr->getObjectType();
1235 obj->getBaseType(), obj->getTypeArgsAsWritten(), obj->getProtocols(),
1242 llvm_unreachable(
"Unexpected ObjCSubstitutionContext!");
1257 if (isa<FunctionNoProtoType>(funcType)) {
1261 return BaseType::VisitFunctionType(funcType);
1267 const auto *funcProtoType = cast<FunctionProtoType>(funcType);
1271 bool paramChanged =
false;
1272 for (
auto paramType : funcProtoType->getParamTypes()) {
1275 if (newParamType.
isNull())
1279 paramChanged =
true;
1281 paramTypes.push_back(newParamType);
1286 bool exceptionChanged =
false;
1292 if (newExceptionType.
isNull())
1295 if (newExceptionType.
getAsOpaquePtr() != exceptionType.getAsOpaquePtr())
1296 exceptionChanged =
true;
1298 exceptionTypes.push_back(newExceptionType);
1301 if (exceptionChanged) {
1303 llvm::makeArrayRef(exceptionTypes).copy(Ctx);
1308 funcProtoType->getReturnType().getAsOpaquePtr() &&
1309 !paramChanged && !exceptionChanged)
1310 return BaseType::VisitFunctionType(funcType);
1320 bool anyChanged =
false;
1332 if (TypeArgs.empty() &&
1342 newTypeArgs.push_back(newTypeArg);
1354 return BaseType::VisitObjCObjectType(objcObjectType);
1358 QualType newType = BaseType::VisitAttributedType(attrType);
1363 if (!newAttrType || newAttrType->getAttrKind() != attr::ObjCKindOf)
1367 QualType newEquivType = newAttrType->getEquivalentType();
1379 objType->getBaseType(), objType->getTypeArgsAsWritten(),
1380 objType->getProtocols(),
1382 objType->isObjCUnqualifiedId() ?
false :
true);
1390 newAttrType->getModifiedType(), newEquivType);
1394 struct StripObjCKindOfTypeVisitor
1395 :
public SimpleTransformVisitor<StripObjCKindOfTypeVisitor> {
1396 using BaseType = SimpleTransformVisitor<StripObjCKindOfTypeVisitor>;
1398 explicit StripObjCKindOfTypeVisitor(
ASTContext &ctx) : BaseType(ctx) {}
1402 return BaseType::VisitObjCObjectType(objType);
1418 SubstObjCTypeArgsVisitor visitor(ctx, typeArgs, context);
1419 return visitor.recurse(*
this);
1433 auto &ctx =
const_cast<ASTContext &
>(constCtx);
1434 StripObjCKindOfTypeVisitor visitor(ctx);
1435 return visitor.recurse(*
this);
1439 if (
const auto AT = getTypePtr()->getAs<AtomicType>())
1440 return AT->getValueType().getUnqualifiedType();
1441 return getUnqualifiedType();
1447 if (
const auto method = dyn_cast<ObjCMethodDecl>(dc))
1448 dc = method->getDeclContext();
1458 dcTypeParams = dcClassDecl->getTypeParamList();
1465 if (!dcCategoryDecl)
1470 dcTypeParams = dcCategoryDecl->getTypeParamList();
1474 dcClassDecl = dcCategoryDecl->getClassInterface();
1478 assert(dcTypeParams &&
"No substitutions to perform");
1479 assert(dcClassDecl &&
"No class context");
1483 if (
const auto *objectPointerType = getAs<ObjCObjectPointerType>()) {
1484 objectType = objectPointerType->getObjectType();
1485 }
else if (getAs<BlockPointerType>()) {
1490 objectType = getAs<ObjCObjectType>();
1496 if (!curClassDecl) {
1504 while (curClassDecl != dcClassDecl) {
1507 if (superType.
isNull()) {
1508 objectType =
nullptr;
1528 if (
auto *
ID = IfaceT->getInterface()) {
1529 if (
ID->getTypeParamList())
1543 CachedSuperClassType.setInt(
true);
1549 if (!superClassObjTy) {
1550 CachedSuperClassType.setInt(
true);
1555 if (!superClassDecl) {
1556 CachedSuperClassType.setInt(
true);
1562 QualType superClassType(superClassObjTy, 0);
1564 if (!superClassTypeParams) {
1565 CachedSuperClassType.setPointerAndInt(
1572 CachedSuperClassType.setPointerAndInt(superClassObjTy,
true);
1580 CachedSuperClassType.setPointerAndInt(
1591 CachedSuperClassType.setPointerAndInt(
1599 assert(typeArgs.size() == typeParams->
size());
1600 CachedSuperClassType.setPointerAndInt(
1603 ->castAs<ObjCObjectType>(),
1609 return interfaceDecl->getASTContext().getObjCInterfaceType(interfaceDecl)
1618 if (superObjectType.
isNull())
1619 return superObjectType;
1621 ASTContext &ctx = getInterfaceDecl()->getASTContext();
1629 if (
const auto *T = getAs<ObjCObjectType>())
1630 if (T->getNumProtocols() && T->getInterface())
1642 if (
const auto *OPT = getAs<ObjCObjectPointerType>()) {
1643 if (OPT->isObjCQualifiedIdType())
1652 if (
const auto *OPT = getAs<ObjCObjectPointerType>()) {
1653 if (OPT->isObjCQualifiedClassType())
1660 if (
const auto *OT = getAs<ObjCObjectType>()) {
1661 if (OT->getInterface())
1668 if (
const auto *OPT = getAs<ObjCObjectPointerType>()) {
1669 if (OPT->getInterfaceType())
1677 if (
const auto *PT = getAs<PointerType>())
1679 else if (
const auto *RT = getAs<ReferenceType>())
1691 return dyn_cast_or_null<CXXRecordDecl>(
getAsTagDecl());
1699 if (
const auto *TT = getAs<TagType>())
1700 return TT->getDecl();
1701 if (
const auto *Injected = getAs<InjectedClassNameType>())
1702 return Injected->getDecl();
1708 const Type *Cur =
this;
1710 if (AT->getAttrKind() == AK)
1712 Cur = AT->getEquivalentType().getTypePtr();
1719 class GetContainedDeducedTypeVisitor :
1720 public TypeVisitor<GetContainedDeducedTypeVisitor, Type*> {
1724 GetContainedDeducedTypeVisitor(
bool Syntactic =
false)
1725 : Syntactic(Syntactic) {}
1766 Type *VisitDependentSizedExtVectorType(
1777 return const_cast<FunctionProtoType*>(T);
1778 return VisitFunctionType(T);
1809 return cast_or_null<DeducedType>(
1810 GetContainedDeducedTypeVisitor().Visit(
this));
1814 return dyn_cast_or_null<FunctionType>(
1815 GetContainedDeducedTypeVisitor(
true).Visit(
this));
1819 if (
const auto *VT = dyn_cast<VectorType>(CanonicalType))
1820 return VT->getElementType()->isIntegerType();
1845 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
1846 return BT->getKind() >= BuiltinType::Bool &&
1847 BT->getKind() <= BuiltinType::Int128;
1851 if (
const auto *ET = dyn_cast<EnumType>(CanonicalType))
1852 return ET->getDecl()->isComplete();
1858 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
1859 return BT->getKind() >= BuiltinType::Bool &&
1860 BT->getKind() <= BuiltinType::Int128;
1865 if (
const auto *ET = dyn_cast<EnumType>(CanonicalType))
1866 return !ET->getDecl()->isScoped();
1872 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
1873 return BT->getKind() == BuiltinType::Char_U ||
1874 BT->getKind() == BuiltinType::UChar ||
1875 BT->getKind() == BuiltinType::Char_S ||
1876 BT->getKind() == BuiltinType::SChar;
1881 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
1882 return BT->getKind() == BuiltinType::WChar_S ||
1883 BT->getKind() == BuiltinType::WChar_U;
1888 if (
const BuiltinType *BT = dyn_cast<BuiltinType>(CanonicalType))
1889 return BT->getKind() == BuiltinType::Char8;
1894 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
1895 return BT->getKind() == BuiltinType::Char16;
1900 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
1901 return BT->getKind() == BuiltinType::Char32;
1908 const auto *BT = dyn_cast<
BuiltinType>(CanonicalType);
1909 if (!BT)
return false;
1910 switch (BT->getKind()) {
1911 default:
return false;
1912 case BuiltinType::Char_U:
1913 case BuiltinType::UChar:
1914 case BuiltinType::WChar_U:
1915 case BuiltinType::Char8:
1916 case BuiltinType::Char16:
1917 case BuiltinType::Char32:
1918 case BuiltinType::Char_S:
1919 case BuiltinType::SChar:
1920 case BuiltinType::WChar_S:
1929 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType)) {
1930 return BT->getKind() >= BuiltinType::Char_S &&
1931 BT->getKind() <= BuiltinType::Int128;
1934 if (
const EnumType *ET = dyn_cast<EnumType>(CanonicalType)) {
1937 if (ET->getDecl()->isComplete() && !ET->getDecl()->isScoped())
1938 return ET->getDecl()->getIntegerType()->isSignedIntegerType();
1945 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType)) {
1946 return BT->getKind() >= BuiltinType::Char_S &&
1947 BT->getKind() <= BuiltinType::Int128;
1950 if (
const auto *ET = dyn_cast<EnumType>(CanonicalType)) {
1951 if (ET->getDecl()->isComplete())
1952 return ET->getDecl()->getIntegerType()->isSignedIntegerType();
1959 if (
const auto *VT = dyn_cast<VectorType>(CanonicalType))
1960 return VT->getElementType()->isSignedIntegerOrEnumerationType();
1969 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType)) {
1970 return BT->getKind() >= BuiltinType::Bool &&
1971 BT->getKind() <= BuiltinType::UInt128;
1974 if (
const auto *ET = dyn_cast<EnumType>(CanonicalType)) {
1977 if (ET->getDecl()->isComplete() && !ET->getDecl()->isScoped())
1978 return ET->getDecl()->getIntegerType()->isUnsignedIntegerType();
1985 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType)) {
1986 return BT->getKind() >= BuiltinType::Bool &&
1987 BT->getKind() <= BuiltinType::UInt128;
1990 if (
const auto *ET = dyn_cast<EnumType>(CanonicalType)) {
1991 if (ET->getDecl()->isComplete())
1992 return ET->getDecl()->getIntegerType()->isUnsignedIntegerType();
1999 if (
const auto *VT = dyn_cast<VectorType>(CanonicalType))
2000 return VT->getElementType()->isUnsignedIntegerOrEnumerationType();
2006 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
2007 return BT->getKind() >= BuiltinType::Half &&
2008 BT->getKind() <= BuiltinType::Float128;
2009 if (
const auto *CT = dyn_cast<ComplexType>(CanonicalType))
2010 return CT->getElementType()->isFloatingType();
2015 if (
const auto *VT = dyn_cast<VectorType>(CanonicalType))
2016 return VT->getElementType()->isFloatingType();
2022 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
2023 return BT->isFloatingPoint();
2028 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
2029 return BT->getKind() >= BuiltinType::Bool &&
2030 BT->getKind() <= BuiltinType::Float128;
2031 if (
const auto *ET = dyn_cast<EnumType>(CanonicalType))
2032 return ET->getDecl()->isComplete() && !ET->getDecl()->isScoped();
2037 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
2038 return BT->getKind() >= BuiltinType::Bool &&
2039 BT->getKind() <= BuiltinType::Float128;
2040 if (
const auto *ET = dyn_cast<EnumType>(CanonicalType))
2047 return !ET->getDecl()->isScoped() && ET->getDecl()->isComplete();
2048 return isa<ComplexType>(CanonicalType);
2055 if (
const auto *BT = dyn_cast<BuiltinType>(T)) {
2056 if (BT->getKind() == BuiltinType::Bool)
return STK_Bool;
2057 if (BT->getKind() == BuiltinType::NullPtr)
return STK_CPointer;
2061 llvm_unreachable(
"unknown scalar builtin type");
2062 }
else if (isa<PointerType>(T)) {
2064 }
else if (isa<BlockPointerType>(T)) {
2066 }
else if (isa<ObjCObjectPointerType>(T)) {
2068 }
else if (isa<MemberPointerType>(T)) {
2070 }
else if (isa<EnumType>(T)) {
2071 assert(cast<EnumType>(T)->getDecl()->isComplete());
2073 }
else if (
const auto *CT = dyn_cast<ComplexType>(T)) {
2074 if (CT->getElementType()->isRealFloatingType())
2079 llvm_unreachable(
"unknown scalar type");
2092 if (
const auto *Record = dyn_cast<RecordType>(CanonicalType)) {
2093 if (
const auto *ClassDecl = dyn_cast<CXXRecordDecl>(Record->getDecl()))
2094 return ClassDecl->isAggregate();
2099 return isa<ArrayType>(CanonicalType);
2106 assert(!
isIncompleteType() &&
"This doesn't make sense for incomplete types");
2107 assert(!
isDependentType() &&
"This doesn't make sense for dependent types");
2109 return !isa<VariableArrayType>(CanonicalType);
2119 switch (CanonicalType->getTypeClass()) {
2120 default:
return false;
2126 EnumDecl *EnumD = cast<EnumType>(CanonicalType)->getDecl();
2134 RecordDecl *Rec = cast<RecordType>(CanonicalType)->getDecl();
2144 return cast<ArrayType>(CanonicalType)->getElementType()
2145 ->isIncompleteType(Def);
2146 case IncompleteArray:
2149 case MemberPointer: {
2153 auto *MPTy = cast<MemberPointerType>(CanonicalType);
2154 const Type *ClassTy = MPTy->getClass();
2156 if (ClassTy->isDependentType())
2167 if (RD->
hasAttr<MSInheritanceAttr>())
2172 return cast<ObjCObjectType>(CanonicalType)->
getBaseType()
2174 case ObjCInterface: {
2177 = cast<ObjCInterfaceType>(CanonicalType)->getDecl();
2188 return isCXX11PODType(Context);
2190 return isCXX98PODType(Context);
2200 if ((*this)->isIncompleteArrayType())
2203 if ((*this)->isIncompleteType())
2206 if (hasNonTrivialObjCLifetime())
2209 QualType CanonicalType = getTypePtr()->CanonicalType;
2212 default:
return false;
2213 case Type::VariableArray:
2214 case Type::ConstantArray:
2218 case Type::ObjCObjectPointer:
2219 case Type::BlockPointer:
2223 case Type::MemberPointer:
2225 case Type::ExtVector:
2232 if (
const auto *ClassDecl =
2233 dyn_cast<CXXRecordDecl>(cast<RecordType>(CanonicalType)->getDecl()))
2234 return ClassDecl->isPOD();
2248 if ((*this)->isArrayType())
2253 if ((*this)->isIncompleteType())
2256 if (hasNonTrivialObjCLifetime())
2259 QualType CanonicalType = getTypePtr()->CanonicalType;
2272 if (
const auto *ClassDecl = dyn_cast<CXXRecordDecl>(RT->getDecl())) {
2277 return ClassDecl->hasDefaultConstructor() &&
2278 !ClassDecl->hasNonTrivialDefaultConstructor() &&
2279 ClassDecl->isTriviallyCopyable();
2290 if ((*this)->isArrayType())
2293 if (hasNonTrivialObjCLifetime())
2301 QualType CanonicalType = getCanonicalType();
2315 if (
const auto *ClassDecl = dyn_cast<CXXRecordDecl>(RT->getDecl())) {
2316 if (!ClassDecl->isTriviallyCopyable())
return false;
2346 if (
const auto *RT =
2348 if (RT->getDecl()->isNonTrivialToPrimitiveDefaultInitialize())
2351 switch (getQualifiers().getObjCLifetime()) {
2353 return PDIK_ARCStrong;
2355 return PDIK_ARCWeak;
2357 return PDIK_Trivial;
2362 if (
const auto *RT =
2364 if (RT->getDecl()->isNonTrivialToPrimitiveCopy())
2370 return PCK_ARCStrong;
2374 return Qs.
hasVolatile() ? PCK_VolatileTrivial : PCK_Trivial;
2380 return isNonTrivialToPrimitiveCopy();
2400 assert(BaseTy &&
"NULL element type");
2430 if (
const auto *ClassDecl = dyn_cast<CXXRecordDecl>(RT->getDecl()))
2431 return ClassDecl->isLiteral();
2438 return AT->getValueType()->isLiteralType(Ctx);
2457 assert(BaseTy &&
"NULL element type");
2467 if (
const auto *ClassDecl = dyn_cast<CXXRecordDecl>(RT->getDecl()))
2468 if (!ClassDecl->isStandardLayout())
2485 const Type *ty = getTypePtr();
2489 if (hasNonTrivialObjCLifetime())
2496 assert(BaseTy &&
"NULL element type");
2506 if (
const auto *ClassDecl = dyn_cast<CXXRecordDecl>(RT->getDecl())) {
2509 if (!ClassDecl->isTrivial())
return false;
2514 if (!ClassDecl->isStandardLayout())
return false;
2543 if (
const auto *ET = getAs<EnumType>()) {
2545 if (II && II->
isStr(
"align_val_t") && ET->getDecl()->isInStdNamespace())
2552 if (
const auto *ET = getAs<EnumType>()) {
2554 if (II && II->
isStr(
"byte") && ET->getDecl()->isInStdNamespace())
2561 if (
const auto *BT = getAs<BuiltinType>())
2562 switch (BT->getKind()) {
2563 case BuiltinType::Bool:
2564 case BuiltinType::Char_S:
2565 case BuiltinType::Char_U:
2566 case BuiltinType::SChar:
2567 case BuiltinType::UChar:
2568 case BuiltinType::Short:
2569 case BuiltinType::UShort:
2570 case BuiltinType::WChar_S:
2571 case BuiltinType::WChar_U:
2572 case BuiltinType::Char8:
2573 case BuiltinType::Char16:
2574 case BuiltinType::Char32:
2582 if (
const auto *ET = getAs<EnumType>()){
2583 if (this->
isDependentType() || ET->getDecl()->getPromotionType().isNull()
2584 || ET->getDecl()->isScoped())
2603 case TemplateTypeParm:
2604 case SubstTemplateTypeParm:
2605 case TemplateSpecialization:
2608 case DependentTemplateSpecialization:
2611 case ObjCObjectPointer:
2641 llvm_unreachable(
"Type specifier is not a tag type kind.");
2653 llvm_unreachable(
"Unknown tag type kind.");
2666 llvm_unreachable(
"Elaborated type keyword is not a tag type kind.");
2668 llvm_unreachable(
"Unknown elaborated type keyword.");
2684 llvm_unreachable(
"Unknown elaborated type keyword.");
2698 llvm_unreachable(
"Unknown elaborated type keyword.");
2701 DependentTemplateSpecializationType::DependentTemplateSpecializationType(
2706 :
TypeWithKeyword(Keyword, DependentTemplateSpecialization, Canon,
true,
true,
2709 NNS(NNS), Name(Name) {
2712 "DependentTemplateSpecializatonType requires dependent qualifier");
2715 if (Arg.containsUnexpandedParameterPack())
2729 ID.AddInteger(Keyword);
2730 ID.AddPointer(Qualifier);
2731 ID.AddPointer(Name);
2733 Arg.Profile(ID, Context);
2738 if (
const auto *Elab = dyn_cast<ElaboratedType>(
this))
2739 Keyword = Elab->getKeyword();
2740 else if (
const auto *DepName = dyn_cast<DependentNameType>(
this))
2741 Keyword = DepName->getKeyword();
2742 else if (
const auto *DepTST =
2743 dyn_cast<DependentTemplateSpecializationType>(
this))
2744 Keyword = DepTST->getKeyword();
2753 #define ABSTRACT_TYPE(Derived, Base) 2754 #define TYPE(Derived, Base) case Derived: return #Derived; 2755 #include "clang/AST/TypeNodes.inc" 2758 llvm_unreachable(
"Invalid type class.");
2766 return Policy.
Bool ?
"bool" :
"_Bool";
2772 return "signed char";
2784 return "unsigned char";
2786 return "unsigned short";
2788 return "unsigned int";
2790 return "unsigned long";
2792 return "unsigned long long";
2794 return "unsigned __int128";
2796 return Policy.
Half ?
"half" :
"__fp16";
2802 return "long double";
2804 return "short _Accum";
2808 return "long _Accum";
2810 return "unsigned short _Accum";
2812 return "unsigned _Accum";
2814 return "unsigned long _Accum";
2815 case BuiltinType::ShortFract:
2816 return "short _Fract";
2817 case BuiltinType::Fract:
2819 case BuiltinType::LongFract:
2820 return "long _Fract";
2821 case BuiltinType::UShortFract:
2822 return "unsigned short _Fract";
2823 case BuiltinType::UFract:
2824 return "unsigned _Fract";
2825 case BuiltinType::ULongFract:
2826 return "unsigned long _Fract";
2827 case BuiltinType::SatShortAccum:
2828 return "_Sat short _Accum";
2829 case BuiltinType::SatAccum:
2830 return "_Sat _Accum";
2831 case BuiltinType::SatLongAccum:
2832 return "_Sat long _Accum";
2833 case BuiltinType::SatUShortAccum:
2834 return "_Sat unsigned short _Accum";
2835 case BuiltinType::SatUAccum:
2836 return "_Sat unsigned _Accum";
2837 case BuiltinType::SatULongAccum:
2838 return "_Sat unsigned long _Accum";
2839 case BuiltinType::SatShortFract:
2840 return "_Sat short _Fract";
2841 case BuiltinType::SatFract:
2842 return "_Sat _Fract";
2843 case BuiltinType::SatLongFract:
2844 return "_Sat long _Fract";
2845 case BuiltinType::SatUShortFract:
2846 return "_Sat unsigned short _Fract";
2847 case BuiltinType::SatUFract:
2848 return "_Sat unsigned _Fract";
2849 case BuiltinType::SatULongFract:
2850 return "_Sat unsigned long _Fract";
2854 return "__float128";
2857 return Policy.
MSWChar ?
"__wchar_t" :
"wchar_t";
2867 return "<overloaded function type>";
2869 return "<bound member function type>";
2871 return "<pseudo-object type>";
2873 return "<dependent type>";
2875 return "<unknown type>";
2876 case ARCUnbridgedCast:
2877 return "<ARC unbridged cast type>";
2879 return "<builtin fn type>";
2886 #define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \ 2888 return "__" #Access " " #ImgType "_t"; 2889 #include "clang/Basic/OpenCLImageTypes.def" 2895 return "clk_event_t";
2899 return "reserve_id_t";
2900 case OMPArraySection:
2901 return "<OpenMP array section type>";
2902 #define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \ 2905 #include "clang/Basic/OpenCLExtensionTypes.def" 2906 #define SVE_TYPE(Name, Id, SingletonId) \ 2909 #include "clang/Basic/AArch64SVEACLETypes.def" 2912 llvm_unreachable(
"Invalid builtin type.");
2916 if (
const auto *RefType = getTypePtr()->getAs<ReferenceType>())
2925 (!getTypePtr()->isDependentType() && !getTypePtr()->isRecordType()))
2926 return getUnqualifiedType();
2933 case CC_C:
return "cdecl";
2953 llvm_unreachable(
"Invalid calling convention.");
2958 const ExtProtoInfo &epi)
2966 assert(getNumParams() == params.size() &&
"NumParams overflow!");
2973 if (hasExtraBitfields(epi.ExceptionSpec.Type)) {
2974 auto &ExtraBits = *getTrailingObjects<FunctionTypeExtraBitfields>();
2975 ExtraBits.NumExceptionType = epi.ExceptionSpec.Exceptions.size();
2979 auto *argSlot = getTrailingObjects<QualType>();
2980 for (
unsigned i = 0; i != getNumParams(); ++i) {
2989 argSlot[i] = params[i];
2994 assert(hasExtraBitfields() &&
"missing trailing extra bitfields!");
2996 reinterpret_cast<QualType *
>(getTrailingObjects<ExceptionType>());
3008 exnSlot[I++] = ExceptionType;
3013 assert(epi.ExceptionSpec.NoexceptExpr &&
"computed noexcept with no expr");
3015 epi.ExceptionSpec.NoexceptExpr->isValueDependent());
3018 *getTrailingObjects<Expr *>() = epi.ExceptionSpec.NoexceptExpr;
3020 if (epi.ExceptionSpec.NoexceptExpr->isValueDependent() ||
3021 epi.ExceptionSpec.NoexceptExpr->isInstantiationDependent())
3024 if (epi.ExceptionSpec.NoexceptExpr->containsUnexpandedParameterPack())
3031 auto **slot = getTrailingObjects<FunctionDecl *>();
3032 slot[0] = epi.ExceptionSpec.SourceDecl;
3033 slot[1] = epi.ExceptionSpec.SourceTemplate;
3039 auto **slot = getTrailingObjects<FunctionDecl *>();
3040 slot[0] = epi.ExceptionSpec.SourceDecl;
3048 assert(hasDependentExceptionSpec() &&
"type should not be canonical");
3057 if (epi.ExtParameterInfos) {
3058 auto *extParamInfos = getTrailingObjects<ExtParameterInfo>();
3059 for (
unsigned i = 0; i != getNumParams(); ++i)
3060 extParamInfos[i] = epi.ExtParameterInfos[i];
3063 if (epi.TypeQuals.hasNonFastQualifiers()) {
3065 *getTrailingObjects<Qualifiers>() = epi.TypeQuals;
3072 auto &EllipsisLoc = *getTrailingObjects<SourceLocation>();
3073 EllipsisLoc = epi.EllipsisLoc;
3078 if (
Expr *
NE = getNoexceptExpr())
3079 return NE->isValueDependent();
3090 if (
Expr *
NE = getNoexceptExpr())
3091 return NE->isInstantiationDependent();
3093 if (ET->isInstantiationDependentType())
3099 switch (getExceptionSpecType()) {
3103 llvm_unreachable(
"should not call this with unresolved exception specs");
3119 for (
unsigned I = 0; I != getNumExceptions(); ++I)
3128 llvm_unreachable(
"unexpected exception specification kind");
3132 for (
unsigned ArgIdx = getNumParams(); ArgIdx; --ArgIdx)
3140 const QualType *ArgTys,
unsigned NumParams,
3161 for (
unsigned i = 0; i != NumParams; ++i)
3166 assert(!(
unsigned(epi.
Variadic) & ~1) &&
3169 "Values larger than expected.");
3184 for (
unsigned i = 0; i != NumParams; ++i)
3193 Profile(ID, getReturnType(), param_type_begin(), getNumParams(),
3198 return getDecl()->getUnderlyingType();
3207 while (
auto *InnerMQT = dyn_cast<MacroQualifiedType>(Inner)) {
3208 if (InnerMQT->getMacroIdentifier() != getMacroIdentifier())
3210 Inner = InnerMQT->getModifiedType();
3216 :
Type(TypeOfExpr, can, E->isTypeDependent(),
3217 E->isInstantiationDependent(),
3235 E->
Profile(ID, Context,
true);
3242 :
Type(Decltype, can, E->isInstantiationDependent(),
3243 E->isInstantiationDependent(),
3246 E(E), UnderlyingType(underlyingType) {}
3258 :
DecltypeType(E, Context.DependentTy), Context(Context) {}
3262 E->
Profile(ID, Context,
true);
3273 BaseType(BaseType), UnderlyingType(UnderlyingType), UKind(UKind) {}
3288 for (
auto I : decl->
redecls()) {
3289 if (I->isCompleteDefinition() || I->isBeingDefined())
3305 std::vector<const RecordType*> RecordTypeList;
3306 RecordTypeList.push_back(
this);
3307 unsigned NextToCheckIndex = 0;
3309 while (RecordTypeList.size() > NextToCheckIndex) {
3311 RecordTypeList[NextToCheckIndex]->
getDecl()->fields()) {
3317 if (llvm::find(RecordTypeList, FieldRecTy) == RecordTypeList.end())
3318 RecordTypeList.push_back(FieldRecTy);
3328 switch (getAttrKind()) {
3333 case attr::ObjCOwnership:
3334 case attr::ObjCInertUnsafeUnretained:
3335 case attr::TypeNonNull:
3336 case attr::TypeNullable:
3337 case attr::TypeNullUnspecified:
3338 case attr::LifetimeBound:
3339 case attr::AddressSpace:
3351 switch (getAttrKind()) {
3352 default:
return false;
3359 llvm_unreachable(
"invalid attr kind");
3364 switch (getAttrKind()) {
3365 default:
return false;
3368 case attr::FastCall:
3370 case attr::ThisCall:
3372 case attr::SwiftCall:
3373 case attr::VectorCall:
3374 case attr::AArch64VectorPcs:
3378 case attr::IntelOclBicc:
3379 case attr::PreserveMost:
3380 case attr::PreserveAll:
3383 llvm_unreachable(
"invalid attr kind");
3394 SubstTemplateTypeParmPackType::
3398 :
Type(SubstTemplateTypeParmPack, Canon,
true,
true,
false,
true),
3399 Replaced(Param), Arguments(ArgPack.
pack_begin()) {
3408 Profile(ID, getReplacedParameter(), getArgumentPack());
3414 ID.AddPointer(Replaced);
3417 ID.AddPointer(
P.getAsType().getAsOpaquePtr());
3422 bool &InstantiationDependent) {
3423 return anyDependentTemplateArguments(Args.
arguments(),
3424 InstantiationDependent);
3429 bool &InstantiationDependent) {
3431 if (ArgLoc.getArgument().isDependent()) {
3432 InstantiationDependent =
true;
3436 if (ArgLoc.getArgument().isInstantiationDependent())
3437 InstantiationDependent =
true;
3442 TemplateSpecializationType::
3446 :
Type(TemplateSpecialization,
3456 "Use DependentTemplateSpecializationType for dependent template-name");
3460 "Unexpected template name for TemplateSpecializationType");
3472 if (Arg.isInstantiationDependent())
3475 Arg.getAsType()->isVariablyModifiedType())
3477 if (Arg.containsUnexpandedParameterPack())
3483 if (isTypeAlias()) {
3485 *
reinterpret_cast<QualType*
>(
Begin + getNumArgs()) = AliasedType;
3496 Arg.Profile(ID, Context);
3501 if (!hasNonFastQualifiers())
3509 if (!hasNonFastQualifiers())
3510 return QualType(T, getFastQualifiers());
3521 ID.AddInteger(typeArgs.size());
3522 for (
auto typeArg : typeArgs)
3523 ID.AddPointer(typeArg.getAsOpaquePtr());
3524 ID.AddInteger(protocols.size());
3525 for (
auto proto : protocols)
3526 ID.AddPointer(proto);
3527 ID.AddBoolean(isKindOf);
3531 Profile(ID, getBaseType(), getTypeArgsAsWritten(),
3532 llvm::makeArrayRef(qual_begin(), getNumProtocols()),
3533 isKindOfTypeAsWritten());
3539 ID.AddPointer(OTPDecl);
3540 ID.AddInteger(protocols.size());
3541 for (
auto proto : protocols)
3542 ID.AddPointer(proto);
3547 llvm::makeArrayRef(qual_begin(), getNumProtocols()));
3553 class CachedProperties {
3558 CachedProperties(
Linkage L,
bool local) : L(L), local(local) {}
3561 bool hasLocalOrUnnamedType()
const {
return local; }
3563 friend CachedProperties merge(CachedProperties L, CachedProperties R) {
3565 return CachedProperties(MergedLinkage,
3566 L.hasLocalOrUnnamedType() | R.hasLocalOrUnnamedType());
3582 return get(T.getTypePtr());
3585 static CachedProperties
get(
const Type *T) {
3587 return CachedProperties(T->
TypeBits.getLinkage(),
3588 T->
TypeBits.hasLocalOrUnnamedType());
3593 if (T->
TypeBits.isCacheValid())
return;
3609 T->
TypeBits.CachedLinkage = Result.getLinkage();
3610 T->
TypeBits.CachedLocalOrUnnamed = Result.hasLocalOrUnnamedType();
3629 #define TYPE(Class,Base) 3630 #define NON_CANONICAL_TYPE(Class,Base) case Type::Class: 3631 #include "clang/AST/TypeNodes.inc" 3632 llvm_unreachable(
"didn't expect a non-canonical type here");
3634 #define TYPE(Class,Base) 3635 #define DEPENDENT_TYPE(Class,Base) case Type::Class: 3636 #define NON_CANONICAL_UNLESS_DEPENDENT_TYPE(Class,Base) case Type::Class: 3637 #include "clang/AST/TypeNodes.inc" 3644 case Type::DeducedTemplateSpecialization:
3664 bool IsLocalOrUnnamed =
3667 return CachedProperties(L, IsLocalOrUnnamed);
3674 return Cache::get(cast<ComplexType>(T)->getElementType());
3677 case Type::BlockPointer:
3679 case Type::LValueReference:
3680 case Type::RValueReference:
3682 case Type::MemberPointer: {
3683 const auto *MPT = cast<MemberPointerType>(T);
3687 case Type::ConstantArray:
3688 case Type::IncompleteArray:
3689 case Type::VariableArray:
3690 return Cache::get(cast<ArrayType>(T)->getElementType());
3692 case Type::ExtVector:
3693 return Cache::get(cast<VectorType>(T)->getElementType());
3694 case Type::FunctionNoProto:
3695 return Cache::get(cast<FunctionType>(T)->getReturnType());
3696 case Type::FunctionProto: {
3697 const auto *FPT = cast<FunctionProtoType>(T);
3698 CachedProperties result =
Cache::get(FPT->getReturnType());
3699 for (
const auto &ai : FPT->param_types())
3703 case Type::ObjCInterface: {
3705 return CachedProperties(L,
false);
3707 case Type::ObjCObject:
3708 return Cache::get(cast<ObjCObjectType>(T)->getBaseType());
3709 case Type::ObjCObjectPointer:
3712 return Cache::get(cast<AtomicType>(T)->getValueType());
3714 return Cache::get(cast<PipeType>(T)->getElementType());
3717 llvm_unreachable(
"unhandled type class");
3728 return TypeBits.hasLocalOrUnnamedType();
3733 #define TYPE(Class,Base) 3734 #define NON_CANONICAL_TYPE(Class,Base) case Type::Class: 3735 #include "clang/AST/TypeNodes.inc" 3736 llvm_unreachable(
"didn't expect a non-canonical type here");
3738 #define TYPE(Class,Base) 3739 #define DEPENDENT_TYPE(Class,Base) case Type::Class: 3740 #define NON_CANONICAL_UNLESS_DEPENDENT_TYPE(Class,Base) case Type::Class: 3741 #include "clang/AST/TypeNodes.inc" 3750 case Type::DeducedTemplateSpecialization:
3755 return getDeclLinkageAndVisibility(cast<TagType>(T)->
getDecl());
3758 return computeTypeLinkageInfo(cast<ComplexType>(T)->getElementType());
3760 return computeTypeLinkageInfo(cast<PointerType>(T)->
getPointeeType());
3761 case Type::BlockPointer:
3762 return computeTypeLinkageInfo(cast<BlockPointerType>(T)->
getPointeeType());
3763 case Type::LValueReference:
3764 case Type::RValueReference:
3765 return computeTypeLinkageInfo(cast<ReferenceType>(T)->
getPointeeType());
3766 case Type::MemberPointer: {
3767 const auto *MPT = cast<MemberPointerType>(T);
3768 LinkageInfo LV = computeTypeLinkageInfo(MPT->getClass());
3769 LV.
merge(computeTypeLinkageInfo(MPT->getPointeeType()));
3772 case Type::ConstantArray:
3773 case Type::IncompleteArray:
3774 case Type::VariableArray:
3775 return computeTypeLinkageInfo(cast<ArrayType>(T)->getElementType());
3777 case Type::ExtVector:
3778 return computeTypeLinkageInfo(cast<VectorType>(T)->getElementType());
3779 case Type::FunctionNoProto:
3780 return computeTypeLinkageInfo(cast<FunctionType>(T)->getReturnType());
3781 case Type::FunctionProto: {
3782 const auto *FPT = cast<FunctionProtoType>(T);
3783 LinkageInfo LV = computeTypeLinkageInfo(FPT->getReturnType());
3784 for (
const auto &ai : FPT->param_types())
3785 LV.
merge(computeTypeLinkageInfo(ai));
3788 case Type::ObjCInterface:
3789 return getDeclLinkageAndVisibility(cast<ObjCInterfaceType>(T)->
getDecl());
3790 case Type::ObjCObject:
3791 return computeTypeLinkageInfo(cast<ObjCObjectType>(T)->getBaseType());
3792 case Type::ObjCObjectPointer:
3793 return computeTypeLinkageInfo(
3796 return computeTypeLinkageInfo(cast<AtomicType>(T)->getValueType());
3798 return computeTypeLinkageInfo(cast<PipeType>(T)->getElementType());
3801 llvm_unreachable(
"unhandled type class");
3833 if (
auto Nullability = AT->getImmediateNullability())
3836 Type = AT->getEquivalentType();
3846 #define NON_CANONICAL_TYPE(Class, Parent) \ 3848 llvm_unreachable("non-canonical type"); 3849 #define TYPE(Class, Parent) 3850 #include "clang/AST/TypeNodes.inc" 3854 case Type::BlockPointer:
3855 case Type::MemberPointer:
3856 case Type::ObjCObjectPointer:
3860 case Type::UnresolvedUsing:
3861 case Type::TypeOfExpr:
3863 case Type::Decltype:
3864 case Type::UnaryTransform:
3865 case Type::TemplateTypeParm:
3866 case Type::SubstTemplateTypeParmPack:
3867 case Type::DependentName:
3868 case Type::DependentTemplateSpecialization:
3870 return ResultIfUnknown;
3875 case Type::TemplateSpecialization:
3877 = cast<TemplateSpecializationType>(type.
getTypePtr())
3878 ->getTemplateName().getAsTemplateDecl()) {
3879 if (isa<ClassTemplateDecl>(templateDecl))
3882 return ResultIfUnknown;
3887 #define SIGNED_TYPE(Id, SingletonId) case BuiltinType::Id: 3888 #define UNSIGNED_TYPE(Id, SingletonId) case BuiltinType::Id: 3889 #define FLOATING_TYPE(Id, SingletonId) case BuiltinType::Id: 3890 #define BUILTIN_TYPE(Id, SingletonId) 3891 #include "clang/AST/BuiltinTypes.def" 3895 case BuiltinType::Dependent:
3896 case BuiltinType::Overload:
3897 case BuiltinType::BoundMember:
3898 case BuiltinType::PseudoObject:
3899 case BuiltinType::UnknownAny:
3900 case BuiltinType::ARCUnbridgedCast:
3901 return ResultIfUnknown;
3903 case BuiltinType::Void:
3904 case BuiltinType::ObjCId:
3905 case BuiltinType::ObjCClass:
3906 case BuiltinType::ObjCSel:
3907 #define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \ 3908 case BuiltinType::Id: 3909 #include "clang/Basic/OpenCLImageTypes.def" 3910 #define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \ 3911 case BuiltinType::Id: 3912 #include "clang/Basic/OpenCLExtensionTypes.def" 3913 case BuiltinType::OCLSampler:
3914 case BuiltinType::OCLEvent:
3915 case BuiltinType::OCLClkEvent:
3916 case BuiltinType::OCLQueue:
3917 case BuiltinType::OCLReserveID:
3918 #define SVE_TYPE(Name, Id, SingletonId) \ 3919 case BuiltinType::Id: 3920 #include "clang/Basic/AArch64SVEACLETypes.def" 3921 case BuiltinType::BuiltinFn:
3922 case BuiltinType::NullPtr:
3923 case BuiltinType::OMPArraySection:
3926 llvm_unreachable(
"unknown builtin type");
3930 case Type::LValueReference:
3931 case Type::RValueReference:
3932 case Type::ConstantArray:
3933 case Type::IncompleteArray:
3934 case Type::VariableArray:
3935 case Type::DependentSizedArray:
3936 case Type::DependentVector:
3937 case Type::DependentSizedExtVector:
3939 case Type::ExtVector:
3940 case Type::DependentAddressSpace:
3941 case Type::FunctionProto:
3942 case Type::FunctionNoProto:
3944 case Type::DeducedTemplateSpecialization:
3946 case Type::InjectedClassName:
3947 case Type::PackExpansion:
3948 case Type::ObjCObject:
3949 case Type::ObjCInterface:
3954 llvm_unreachable(
"bad type kind!");
3959 if (getAttrKind() == attr::TypeNonNull)
3961 if (getAttrKind() == attr::TypeNullable)
3963 if (getAttrKind() == attr::TypeNullUnspecified)
3970 if (
auto MacroTy = dyn_cast<MacroQualifiedType>(T))
3971 AttrTy = MacroTy->getUnderlyingType();
3973 if (
auto attributed = dyn_cast<AttributedType>(AttrTy)) {
3974 if (
auto nullability = attributed->getImmediateNullability()) {
3975 T = attributed->getModifiedType();
3984 const auto *objcPtr = getAs<ObjCObjectPointerType>();
3988 if (objcPtr->isObjCIdType()) {
3999 }
else if (objcPtr->isObjCQualifiedIdType()) {
4024 "cannot query implicit lifetime for non-inferrable type");
4029 while (
const auto *array = dyn_cast<ArrayType>(canon))
4030 canon = array->getElementType().getTypePtr();
4032 if (
const auto *opt = dyn_cast<ObjCObjectPointerType>(canon)) {
4034 if (opt->getObjectType()->isObjCClass())
4042 const Type *cur =
this;
4044 if (
const auto *
typedefType = dyn_cast<TypedefType>(cur))
4045 return typedefType->getDecl()->hasAttr<ObjCNSObjectAttr>();
4049 if (next.getTypePtr() == cur)
return false;
4050 cur = next.getTypePtr();
4055 if (
const auto *
typedefType = dyn_cast<TypedefType>(
this))
4056 return typedefType->getDecl()->hasAttr<ObjCIndependentClassAttr>();
4069 if (
const auto *OPT = getAs<PointerType>())
4070 return OPT->getPointeeType()->isObjCIndirectLifetimeType();
4071 if (
const auto *Ref = getAs<ReferenceType>())
4072 return Ref->getPointeeType()->isObjCIndirectLifetimeType();
4073 if (
const auto *MemPtr = getAs<MemberPointerType>())
4074 return MemPtr->getPointeeType()->isObjCIndirectLifetimeType();
4081 const Type *type =
this;
4083 type = array->getElementType().getTypePtr();
4095 const auto *
Pointer = getAs<PointerType>();
4106 if (
const auto *ptr = getAs<PointerType>())
4107 return ptr->getPointeeType()->hasSizedVLAType();
4108 if (
const auto *ref = getAs<ReferenceType>())
4109 return ref->getPointeeType()->hasSizedVLAType();
4111 if (isa<VariableArrayType>(arr) &&
4112 cast<VariableArrayType>(arr)->getSizeExpr())
4115 return arr->getElementType()->hasSizedVLAType();
4129 return DK_objc_strong_lifetime;
4131 return DK_objc_weak_lifetime;
4134 if (
const auto *RT =
4137 if (
const auto *CXXRD = dyn_cast<CXXRecordDecl>(RD)) {
4139 if (CXXRD->hasDefinition() && !CXXRD->hasTrivialDestructor())
4140 return DK_cxx_destructor;
4145 return DK_nontrivial_c_struct;
4165 bool IsDeducedAsDependent,
bool IsDeducedAsPack,
4169 IsDeducedAsDependent, IsDeducedAsPack) {
4172 this->TypeConstraintConcept = TypeConstraintConcept;
4173 if (TypeConstraintConcept) {
4176 if (Arg.containsUnexpandedParameterPack())
4189 ID.AddInteger((
unsigned)Keyword);
4190 ID.AddBoolean(IsDependent);
4193 Arg.Profile(ID, Context);
DecltypeType(Expr *E, QualType underlyingType, QualType can=QualType())
static StringRef getKeywordName(ElaboratedTypeKeyword Keyword)
const ObjCInterfaceType * getInterfaceType() const
If this pointer points to an Objective C @interface type, gets the type for that interface.
QualType getPattern() const
Retrieve the pattern of this pack expansion, which is the type that will be repeatedly instantiated w...
Defines the clang::ASTContext interface.
bool hasDefinition() const
Determine whether this class has been defined.
bool isNonWeakInMRRWithObjCWeak(const ASTContext &Context) const
QualType getDeducedType() const
Get the type deduced for this placeholder type, or null if it's either not been deduced or was deduce...
Represents a type that was referred to using an elaborated type keyword, e.g., struct S...
const Type * Ty
The locally-unqualified type.
QualType getObjCObjectType(QualType Base, ObjCProtocolDecl *const *Protocols, unsigned NumProtocols) const
Legacy interface: cannot provide type arguments or __kindof.
void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Ctx)
bool hasAttr(attr::Kind AK) const
Determine whether this type had the specified attribute applied to it (looking through top-level type...
bool isKindOfTypeAsWritten() const
Whether this is a "__kindof" type as written.
External linkage, which indicates that the entity can be referred to from other translation units...
bool isStrictSupersetOf(Qualifiers Other) const
Determine whether this set of qualifiers is a strict superset of another set of qualifiers, not considering qualifier compatibility.
The "enum" keyword introduces the elaborated-type-specifier.
void setDependent(bool D=true)
no exception specification
bool isTemplateVariadic() const
Determines whether this function prototype contains a parameter pack at the end.
StringRef getName(const PrintingPolicy &Policy) const
if(T->getSizeExpr()) TRY_TO(TraverseStmt(T -> getSizeExpr()))
PointerType - C99 6.7.5.1 - Pointer Declarators.
ArrayRef< QualType > getTypeArgsAsWritten() const
Retrieve the type arguments of this object type as they were written.
QualType getPointeeType() const
void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Ctx)
A (possibly-)qualified type.
bool isBlockPointerType() const
QualType substObjCTypeArgs(ASTContext &ctx, ArrayRef< QualType > typeArgs, ObjCSubstitutionContext context) const
Substitute type arguments for the Objective-C type parameters used in the subject type...
ArrayType(TypeClass tc, QualType et, QualType can, ArraySizeModifier sm, unsigned tq, const Expr *sz=nullptr)
bool isPODType(const ASTContext &Context) const
Determine whether this is a Plain Old Data (POD) type (C++ 3.9p10).
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 isUnsignedIntegerOrEnumerationType() const
Determines whether this is an integer type that is unsigned or an enumeration types whose underlying ...
static QualType getObjectType(APValue::LValueBase B)
Retrieves the "underlying object type" of the given expression, as used by __builtin_object_size.
QualType getDesugaredType(const ASTContext &Context) const
Return the specified type with any "sugar" removed from the type.
PrimitiveDefaultInitializeKind isNonTrivialToPrimitiveDefaultInitialize() const
Functions to query basic properties of non-trivial C struct types.
void Profile(llvm::FoldingSetNodeID &ID) const
ArrayRef< TemplateArgument > getTypeConstraintArguments() const
AutoTypeKeyword
Which keyword(s) were used to create an AutoType.
bool isArithmeticType() const
void setInstantiationDependent(bool D=true)
Stmt - This represents one statement.
FunctionType - C99 6.7.5.3 - Function Declarators.
bool isObjCClassOrClassKindOfType() const
Whether the type is Objective-C 'Class' or a __kindof type of an Class type, e.g., __kindof Class <NSCopying>.
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee...
bool isElaboratedTypeSpecifier() const
Determine wither this type is a C++ elaborated-type-specifier.
unsigned MSWChar
When true, print the built-in wchar_t type as __wchar_t.
bool isRealFloatingType() const
Floating point categories.
The fixed point semantics work similarly to llvm::fltSemantics.
C Language Family Type Representation.
bool isObjCARCBridgableType() const
Determine whether the given type T is a "bridgable" Objective-C type, which is either an Objective-C ...
void Profile(llvm::FoldingSetNodeID &ID)
bool isRecordType() const
QualType getUnderlyingType() const
QualType getQualifiedType(SplitQualType split) const
Un-split a SplitQualType.
const ObjCObjectType * getAsObjCInterfaceType() const
Decl - This represents one declaration (or definition), e.g.
TagDecl * getDecl() const
ObjCObjectTypeBitfields ObjCObjectTypeBits
const RecordType * getAsStructureType() const
SubstTemplateTypeParmPackTypeBitfields SubstTemplateTypeParmPackTypeBits
Defines the C++ template declaration subclasses.
Represents a C++11 auto or C++14 decltype(auto) type, possibly constrained by a type-constraint.
QualType desugar() const
Remove a single level of sugar.
void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Ctx)
ObjCTypeParamList * getTypeParamList() const
Retrieve the type parameters of this class.
static ElaboratedTypeKeyword getKeywordForTagTypeKind(TagTypeKind Tag)
Converts a TagTypeKind into an elaborated type keyword.
The base class of the type hierarchy.
void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context)
Represents an array type, per C99 6.7.5.2 - Array Declarators.
bool isObjCBoxableRecordType() const
const ObjCObjectPointerType * getAsObjCInterfacePointerType() const
DependentDecltypeType(const ASTContext &Context, Expr *E)
const TargetInfo & getTargetInfo() const
RefQualifierKind RefQualifier
QualType getValueType() const
Gets the type contained by this atomic type, i.e.
bool isCARCBridgableType() const
Determine whether the given type T is a "bridgeable" C type.
bool isUnspecialized() const
Determine whether this object type is "unspecialized", meaning that it has no type arguments...
Linkage getLinkage() const
Determine the linkage of this type.
A template template parameter that has been substituted for some other template name.
QualType getElementType() const
bool isCompleteDefinition() const
Return true if this decl has its body fully specified.
const RecordType * getAsUnionType() const
NOTE: getAs*ArrayType are methods on ASTContext.
QualType withFastQualifiers(unsigned TQs) const
static CachedProperties computeCachedProperties(const Type *T)
bool isTrivialType(const ASTContext &Context) const
Return true if this is a trivial type per (C++0x [basic.types]p9)
bool isUnsignedIntegerType() const
Return true if this is an integer type that is unsigned, according to C99 6.2.5p6 [which returns true...
bool isStructureType() const
ArrayRef< ObjCProtocolDecl * > getProtocols() const
Retrieve all of the protocol qualifiers.
bool isEnumeralType() const
const T * getAs() const
Member-template getAs<specific type>'.
Extra information about a function prototype.
const ArrayType * castAsArrayTypeUnsafe() const
A variant of castAs<> for array type which silently discards qualifiers from the outermost type...
ArrayTypeBitfields ArrayTypeBits
void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context, bool Canonical) const
Produce a unique representation of the given statement.
The "__interface" keyword.
bool isChar32Type() const
bool isCallingConv() const
Describes how types, statements, expressions, and declarations should be printed. ...
LinkageInfo computeTypeLinkageInfo(const Type *T)
Represents the result of substituting a type for a template type parameter.
Linkage
Describes the different kinds of linkage (C++ [basic.link], C99 6.2.2) that an entity may have...
noexcept(expression), value-dependent
bool isStandardLayoutType() const
Test if this type is a standard-layout type.
The collection of all-type qualifiers we support.
bool isVariableArrayType() const
bool isSugared() const
Returns whether this type directly provides sugar.
bool hasFloatingRepresentation() const
Determine whether this type has a floating-point representation of some sort, e.g., it is a floating-point type or a vector thereof.
void Profile(llvm::FoldingSetNodeID &ID)
bool canHaveNullability(bool ResultIfUnknown=true) const
Determine whether the given type can have a nullability specifier applied to it, i.e., if it is any kind of pointer type.
IdentifierInfo * getIdentifier() const
Get the identifier that names this declaration, if there is one.
Represents a struct/union/class.
QualType getOriginalType() const
bool isWideCharType() const
FunctionType::ExtInfo ExtInfo
bool isComplete() const
Returns true if this can be considered a complete type.
One of these records is kept for each identifier that is lexed.
TargetCXXABI getCXXABI() const
Get the C++ ABI currently in use.
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...
bool isStr(const char(&Str)[StrLen]) const
Return true if this is the identifier for the specified string.
QualType IgnoreParens() const
Returns the specified type after dropping any outer-level parentheses.
Represents a class type in Objective C.
bool isObjCIndependentClassType() const
QualType getPointeeType() const
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
bool isStdByteType() const
ArrayRef< QualType > getParamTypes() const
bool isObjCLifetimeType() const
Returns true if objects of this type have lifetime semantics under ARC.
static bool anyDependentTemplateArguments(ArrayRef< TemplateArgumentLoc > Args, bool &InstantiationDependent)
Determine whether any of the given template arguments are dependent.
bool isSpelledAsLValue() const
Represents a member of a struct/union/class.
bool isCanonicalUnqualified() const
Determines if this type would be canonical if it had no further qualification.
Defines the ExceptionSpecificationType enumeration and various utility functions. ...
const ObjCObjectPointerType * getAsObjCQualifiedIdType() const
bool isReferenceType() const
qual_iterator qual_begin() const
__DEVICE__ int max(int __a, int __b)
unsigned char getOpaqueValue() const
const AstTypeMatcher< TypedefType > typedefType
Matches typedef types.
unsigned getIndex() const
Retrieve the index into its type parameter list.
QualType getModifiedType() const
Return this attributed type's modified type with no qualifiers attached to it.
const ObjCObjectPointerType * stripObjCKindOfTypeAndQuals(const ASTContext &ctx) const
Strip off the Objective-C "kindof" type and (with it) any protocol qualifiers.
Values of this type can be null.
void Profile(llvm::FoldingSetNodeID &ID)
Type(TypeClass tc, QualType canon, bool Dependent, bool InstantiationDependent, bool VariablyModified, bool ContainsUnexpandedParameterPack)
bool hasNonTrivialToPrimitiveCopyCUnion() const
An rvalue reference type, per C++11 [dcl.ref].
bool isMSTypeSpec() const
const ObjCObjectType * getAsObjCQualifiedInterfaceType() const
qual_iterator qual_end() const
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...
Microsoft throw(...) extension.
A convenient class for passing around template argument information.
ArrayRef< QualType > getTypeArgs() const
Retrieve the type arguments of this object type (semantically).
bool isTriviallyCopyableType(const ASTContext &Context) const
Return true if this is a trivially copyable type (C++0x [basic.types]p9)
bool hasAddressSpace() const
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified...
const ArrayType * getAsArrayTypeUnsafe() const
A variant of getAs<> for array types which silently discards qualifiers from the outermost type...
The "struct" keyword introduces the elaborated-type-specifier.
static ElaboratedTypeKeyword getKeywordForTypeSpec(unsigned TypeSpec)
Converts a type specifier (DeclSpec::TST) into an elaborated type keyword.
Whether values of this type can be null is (explicitly) unspecified.
Sugar type that represents a type that was qualified by a qualifier written as a macro invocation...
const ObjCObjectPointerType * getAsObjCQualifiedClassType() const
bool containsUnexpandedParameterPack() const
Whether this type is or contains an unexpanded parameter pack, used to support C++0x variadic templat...
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...
LangAS getAddressSpace() const
const Type * getClass() const
CXXRecordDecl * getDecl() const
Values of this type can never be null.
Expr * getSizeExpr() const
const Type * getTypePtr() const
Retrieves a pointer to the underlying (unqualified) type.
LinkageInfo getTypeLinkageAndVisibility(const Type *T)
static unsigned getNumAddressingBits(const ASTContext &Context, QualType ElementType, const llvm::APInt &NumElements)
Determine the number of bits required to address a member of.
Defines the Linkage enumeration and various utility functions.
static TagDecl * getInterestingTagDecl(TagDecl *decl)
bool hasNameForLinkage() const
Is this tag type named, either directly or via being defined in a typedef of this type...
unsigned Half
When true, print the half-precision floating-point type as 'half' instead of '__fp16'.
Represents an Objective-C protocol declaration.
bool isBlockCompatibleObjCPointerType(ASTContext &ctx) const
bool isTypeDependent() const
isTypeDependent - Determines whether this expression is type-dependent (C++ [temp.dep.expr]), which means that its type could change from one template instantiation to the next.
bool isScalarType() const
void * getAsOpaquePtr() const
Represents an ObjC class declaration.
const Type * getUnqualifiedDesugaredType() const
Return the specified type with any "sugar" removed from the type, removing any typedefs, typeofs, etc., as well as any qualifiers.
ObjCInterfaceDecl * getInterface() const
Gets the interface declaration for this object type, if the base type really is an interface...
PrimitiveDefaultInitializeKind
FunctionDecl * SourceDecl
The function whose exception specification this is, for EST_Unevaluated and EST_Uninstantiated.
SplitQualType getSplitDesugaredType() const
QualType getPointeeTypeAsWritten() const
TagType(TypeClass TC, const TagDecl *D, QualType can)
unsigned getNumProtocols() const
Return the number of qualifying protocols in this type, or 0 if there are none.
QualType getElementType() const
bool hasUnsignedIntegerRepresentation() const
Determine whether this type has an unsigned integer representation of some sort, e.g., it is an unsigned integer type or a vector.
Represents an extended vector type where either the type or size is dependent.
This object can be modified without requiring retains or releases.
CXXRecordDecl * getMostRecentNonInjectedDecl()
Defines the clang::Visibility enumeration and various utility functions.
The APFixedPoint class works similarly to APInt/APSInt in that it is a functional replacement for a s...
bool isIntegralOrUnscopedEnumerationType() const
Determine whether this type is an integral or unscoped enumeration type.
Represents a K&R-style 'int foo()' function, which has no information available about its arguments...
Provides definitions for the various language-specific address spaces.
bool isSpecializedAsWritten() const
Determine whether this object type was written with type arguments.
QualType getBaseType() const
Gets the base type of this object type.
RecordDecl * getAsRecordDecl() const
Retrieves the RecordDecl this type refers to.
static void ensure(const Type *T)
bool acceptsObjCTypeParams() const
Determines if this is an ObjC interface type that may accept type parameters.
bool containsUnexpandedParameterPack() const
Determines whether this template name contains an unexpanded parameter pack (for C++0x variadic templ...
bool isPromotableIntegerType() const
More type predicates useful for type checking/promotion.
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
Represents a prototype with parameter type info, e.g.
const ObjCObjectType * getSuperClassType() const
Retrieve the superclass type.
static bool KeywordIsTagTypeKind(ElaboratedTypeKeyword Keyword)
QualType applyObjCProtocolQualifiers(QualType type, ArrayRef< ObjCProtocolDecl *> protocols, bool &hasError, bool allowOnPointerType=false) const
Apply Objective-C protocol qualifiers to the given type.
bool isComplexType() const
isComplexType() does not include complex integers (a GCC extension).
IdentifierInfo * getNSObjectName() const
Retrieve the identifier 'NSObject'.
ArraySizeModifier
Capture whether this is a normal array (e.g.
QuantityType getQuantity() const
getQuantity - Get the raw integer representation of this quantity.
ObjCTypeParamDecl * getDecl() const
DependentTemplateSpecializationTypeBitfields DependentTemplateSpecializationTypeBits
Defines the TargetCXXABI class, which abstracts details of the C++ ABI that we're targeting...
PrimitiveCopyKind isNonTrivialToPrimitiveDestructiveMove() const
Check if this is a non-trivial type that would cause a C struct transitively containing this type to ...
QualType getElementType() const
IdentifierInfo * getIdentifier() const
This represents one expression.
Defines the clang::LangOptions interface.
The "typename" keyword precedes the qualified type name, e.g., typename T::type.
bool isObjCARCImplicitlyUnretainedType() const
Determines if this type, which must satisfy isObjCLifetimeType(), is implicitly __unsafe_unretained r...
const CXXRecordDecl * getPointeeCXXRecordDecl() const
If this is a pointer or reference to a RecordType, return the CXXRecordDecl that the type refers to...
const IdentifierInfo * getBaseTypeIdentifier() const
Retrieves a pointer to the name of the base type.
const T * castAs() const
Member-template castAs<specific type>.
ElaboratedTypeKeyword
The elaboration keyword that precedes a qualified type name or introduces an elaborated-type-specifie...
bool isObjCRetainableType() const
const internal::VariadicAllOfMatcher< Decl > decl
Matches declarations.
ObjCSubstitutionContext
The kind of type we are substituting Objective-C type arguments into.
bool isChar16Type() const
const char * getTypeClassName() const
Linkage getLinkage() const
ObjCLifetime getObjCLifetime() const
DeclContext * getDeclContext()
bool isAnyComplexType() const
void Profile(llvm::FoldingSetNodeID &ID)
static TagTypeKind getTagTypeKindForTypeSpec(unsigned TypeSpec)
Converts a type specifier (DeclSpec::TST) into a tag type kind.
ObjCObjectType(QualType Canonical, QualType Base, ArrayRef< QualType > typeArgs, ArrayRef< ObjCProtocolDecl *> protocols, bool isKindOf)
ScalarTypeKind getScalarTypeKind() const
Given that this is a scalar type, classify it.
Represents a C++ template name within the type system.
Represents the type decltype(expr) (C++11).
A std::pair-like structure for storing a qualified type split into its local qualifiers and its local...
bool isSignedIntegerType() const
Return true if this is an integer type that is signed, according to C99 6.2.5p4 [char, signed char, short, int, long..], or an enum decl which has a signed representation.
void Profile(llvm::FoldingSetNodeID &ID)
QualType desugar() const
Remove a single level of sugar.
Defines the clang::IdentifierInfo, clang::IdentifierTable, and clang::Selector interfaces.
bool isFunctionOrMethod() const
static Optional< NullabilityKind > stripOuterNullability(QualType &T)
Strip off the top-level nullability annotation on the given type, if it's there.
TagDecl * getAsTagDecl() const
Retrieves the TagDecl that this type refers to, either because the type is a TagType or because it is...
Qualifiers Quals
The local qualifiers.
bool isSpecifierType() const
Returns true if this type can be represented by some set of type specifiers.
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...
#define TRIVIAL_TYPE_CLASS(Class)
bool hasInstantiationDependentExceptionSpec() const
Return whether this function has an instantiation-dependent exception spec.
A helper class for Type nodes having an ElaboratedTypeKeyword.
QualType getObjCInterfaceType(const ObjCInterfaceDecl *Decl, ObjCInterfaceDecl *PrevDecl=nullptr) const
getObjCInterfaceType - Return the unique reference to the type for the specified ObjC interface decl...
QualType getFunctionType(QualType ResultTy, ArrayRef< QualType > Args, const FunctionProtoType::ExtProtoInfo &EPI) const
Return a normal function type with a typed argument list.
Represents a GCC generic vector type.
ArraySizeModifier getSizeModifier() const
An lvalue reference type, per C++11 [dcl.ref].
Common base class for placeholders for types that get replaced by placeholder type deduction: C++11 a...
const Type * getBaseElementTypeUnsafe() const
Get the base element type of this type, potentially discarding type qualifiers.
The result type of a method or function.
bool hasNonTrivialToPrimitiveDefaultInitializeCUnion() const
Check if this is or contains a C union that is non-trivial to default-initialize, which is a union th...
bool isNull() const
Return true if this QualType doesn't point to a type yet.
bool hasAutoForTrailingReturnType() const
Determine whether this type was written with a leading 'auto' corresponding to a trailing return type...
CallingConv
CallingConv - Specifies the calling convention that a function uses.
static LinkageInfo external()
Expr * getUnderlyingExpr() const
bool isNonTrivialToPrimitiveDestroy() const
QualType getAttributedType(attr::Kind attrKind, QualType modifiedType, QualType equivalentType)
bool isVoidPointerType() const
bool isConstQualified() const
Determine whether this type is const-qualified.
IdentifierInfo * getNSCopyingName()
Retrieve the identifier 'NSCopying'.
bool hasTrailingReturn() const
Whether this function prototype has a trailing return type.
SplitQualType split() const
Divides a QualType into its unqualified type and a set of local qualifiers.
RecordDecl * getDecl() const
void toString(llvm::SmallVectorImpl< char > &Str) const
noexcept(expression), evals to 'false'
bool hasNonTrivialToPrimitiveDefaultInitializeCUnion() const
LinkageInfo getLinkageAndVisibility() const
Determine the linkage and visibility of this type.
unsigned Bool
Whether we can use 'bool' rather than '_Bool' (even if the language doesn't actually have 'bool'...
bool isStructureOrClassType() const
A template template parameter pack that has been substituted for a template template argument pack...
CanThrowResult
Possible results from evaluation of a noexcept expression.
bool isComputedNoexcept(ExceptionSpecificationType ESpecType)
There is no lifetime qualification on this type.
bool containsUnexpandedParameterPack() const
Whether this nested-name-specifier contains an unexpanded parameter pack (for C++11 variadic template...
Assigning into this object requires the old value to be released and the new value to be retained...
QualType getCanonicalType() const
ExceptionSpecificationType Type
The kind of exception specification this is.
bool isInstantiationDependent() const
Whether this expression is instantiation-dependent, meaning that it depends in some way on a template...
bool isSpecialized() const
Determine whether this object type is "specialized", meaning that it has type arguments.
ExtProtoInfo getExtProtoInfo() const
redecl_range redecls() const
Returns an iterator range for all the redeclarations of the same decl.
const ExtParameterInfo * ExtParameterInfos
Encodes a location in the source.
Sugar for parentheses used when specifying types.
QualType getAdjustedType() const
QualType getReturnType() const
bool isLinkageValid() const
True if the computed linkage is valid.
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of enums...
bool mayBeNotDynamicClass() const
Returns true if it is not a class or if the class might not be dynamic.
LangAS getAddressSpace() const
Return the address space of this type.
Interfaces are the core concept in Objective-C for object oriented design.
bool isVariablyModifiedType() const
Whether this type is a variably-modified type (C99 6.7.5).
const ComplexType * getAsComplexIntegerType() const
bool isLiteralType(const ASTContext &Ctx) const
Return true if this is a literal type (C++11 [basic.types]p10)
Represents the declaration of a struct/union/class/enum.
TemplateArgument getArgumentPack() const
ASTContext & getASTContext() const LLVM_READONLY
QualType getElementType() const
static QualType getUnderlyingType(const SubRegion *R)
void FixedPointValueToString(SmallVectorImpl< char > &Str, llvm::APSInt Val, unsigned Scale)
QualType getBaseElementType(const ArrayType *VAT) const
Return the innermost element type of an array type.
bool isIntegralType(const ASTContext &Ctx) const
Determine whether this type is an integral type.
QualType getLocallyUnqualifiedSingleStepDesugaredType() const
Pull a single level of sugar off of this locally-unqualified type.
void initialize(ArrayRef< ObjCProtocolDecl * > protocols)
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
const ArrayType * getAsArrayType(QualType T) const
Type Query functions.
ObjCCategoryDecl - Represents a category declaration.
unsigned pack_size() const
The number of template arguments in the given template argument pack.
bool isSignedIntegerOrEnumerationType() const
Determines whether this is an integer type that is signed or an enumeration types whose underlying ty...
QualType getEquivalentType() const
void Profile(llvm::FoldingSetNodeID &ID)
QualType getInnerType() const
bool isObjCObjectPointerType() const
AutoTypeKeyword getKeyword() const
TypeClass getTypeClass() const
bool isAnyCharacterType() const
Determine whether this type is any of the built-in character types.
PrimitiveCopyKind isNonTrivialToPrimitiveCopy() const
Check if this is a non-trivial type that would cause a C struct transitively containing this type to ...
QualType getSuperClassType() const
Retrieve the type of the superclass of this object type.
EnumDecl * getDecl() const
bool hasNonTrivialToPrimitiveDestructCUnion() const
bool isVectorType() const
__DEVICE__ void * memcpy(void *__a, const void *__b, size_t __c)
bool hasConstFields() const
Recursively check all fields in the record for const-ness.
Assigning into this object requires a lifetime extension.
TemplateSpecializationTypeBitfields TemplateSpecializationTypeBits
static TagTypeKind getTagTypeKindForKeyword(ElaboratedTypeKeyword Keyword)
Converts an elaborated type keyword into a TagTypeKind.
void setVariablyModified(bool VM=true)
DependentTemplateName * getAsDependentTemplateName() const
Retrieve the underlying dependent template name structure, if any.
TypeOfExprType(Expr *E, QualType can=QualType())
bool isInstantiationDependentType() const
Determine whether this type is an instantiation-dependent type, meaning that the type involves a temp...
Linkage getLinkageInternal() const
Determine what kind of linkage this entity has.
Represents a pointer type decayed from an array or function type.
Represents a pack expansion of types.
ArrayRef< TemplateArgument > pack_elements() const
Iterator range referencing all of the elements of a template argument pack.
#define SUGARED_TYPE_CLASS(Class)
Defines various enumerations that describe declaration and type specifiers.
static unsigned getMaxSizeBits(const ASTContext &Context)
Determine the maximum number of active bits that an array's size can require, which limits the maximu...
Linkage minLinkage(Linkage L1, Linkage L2)
Compute the minimum linkage given two linkages.
CXXRecordDecl * getMostRecentCXXRecordDecl() const
Represents a template argument.
bool isScopedEnumeralType() const
Determine whether this type is a scoped enumeration type.
Represents a type which was implicitly adjusted by the semantic engine for arbitrary reasons...
TagTypeKind
The kind of a tag type.
CanQualType ObjCBuiltinIdTy
Dataflow Directional Tag Classes.
bool isObjCQualifiedInterfaceType() const
DeducedType * getContainedDeducedType() const
Get the DeducedType whose type will be deduced for a variable with an initializer of this type...
ExtInfo getExtInfo() const
not evaluated yet, for special member function
A qualifier set is used to build a set of qualifiers.
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
void setContainsUnexpandedParameterPack(bool PP=true)
The base class of all kinds of template declarations (e.g., class, function, etc.).
bool hasUnnamedOrLocalType() const
Whether this type is or contains a local or unnamed type.
static CachedProperties get(QualType T)
bool hasDependentExceptionSpec() const
Return whether this function has a dependent exception spec.
bool NE(InterpState &S, CodePtr OpPC)
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...
QualType getUnderlyingType() const
bool isDependent() const
Whether this nested name specifier refers to a dependent type or not.
QualType stripObjCKindOfType(const ASTContext &ctx) const
Strip Objective-C "__kindof" types from the given type.
QualType getUnderlyingType() const
const Type * getArrayElementTypeNoTypeQual() const
If this is an array type, return the element type of the array, potentially with type qualifiers miss...
void Profile(llvm::FoldingSetNodeID &ID)
VectorKind getVectorKind() const
Represents the declaration of an Objective-C type parameter.
The "union" keyword introduces the elaborated-type-specifier.
const Type * strip(QualType type)
Collect any qualifiers on the given type and return an unqualified type.
QualType getFunctionNoProtoType(QualType ResultTy, const FunctionType::ExtInfo &Info) const
Return a K&R style C function type like 'int()'.
void Profile(llvm::FoldingSetNodeID &ID)
void Profile(llvm::FoldingSetNodeID &ID)
bool isObjCIndirectLifetimeType() const
const ObjCObjectType * getObjectType() const
Gets the type pointed to by this ObjC pointer.
The "class" keyword introduces the elaborated-type-specifier.
bool isKindOfType() const
Whether this ia a "__kindof" type (semantically).
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...
A pointer to member type per C++ 8.3.3 - Pointers to members.
bool hasObjCLifetime() const
bool isAggregateType() const
Determines whether the type is a C++ aggregate type or C aggregate or union type. ...
bool isQualifier() const
Does this attribute behave like a type qualifier?
llvm::ArrayRef< TemplateArgumentLoc > arguments() const
QualType apply(const ASTContext &Context, QualType QT) const
Apply the collected qualifiers to the given type.
pack_iterator pack_begin() const
Iterator referencing the first argument of a template argument pack.
const TemplateTypeParmType * getReplacedParameter() const
Gets the template parameter that was substituted for.
void addConsistentQualifiers(Qualifiers qs)
Add the qualifiers from the given set to this set, given that they don't conflict.
QualType getModifiedType() const
Represents a pointer to an Objective C object.
bool isSugared() const
Returns whether this type directly provides sugar.
FunctionTypeBitfields FunctionTypeBits
bool isUnscopedEnumerationType() const
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
Complex values, per C99 6.2.5p11.
Location wrapper for a TemplateArgument.
unsigned getIndexTypeCVRQualifiers() const
bool isConstantSizeType() const
Return true if this is not a variable sized type, according to the rules of C99 6.7.5p3.
AutoTypeBitfields AutoTypeBits
QualType getCanonicalTypeInternal() const
QualType getAtomicUnqualifiedType() const
Remove all qualifiers including _Atomic.
bool isIntegerType() const
isIntegerType() does not include complex integers (a GCC extension).
CanThrowResult canThrow() const
Determine whether this function type has a non-throwing exception specification.
const llvm::APInt & getSize() const
VectorTypeBitfields VectorTypeBits
ExtVectorType - Extended vector type.
Base for LValueReferenceType and RValueReferenceType.
SourceRange getBracketsRange() const
const Expr * getSizeExpr() const
The template argument is a type.
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...
Optional< NullabilityKind > getNullability(const ASTContext &context) const
Determine the nullability of the given type.
QualType getNonLValueExprType(const ASTContext &Context) const
Determine the type of a (typically non-lvalue) expression with the specified result type...
bool isBeingDefined() const
Determines whether this type is in the process of being defined.
uint64_t getTypeSize(QualType T) const
Return the size of the specified (complete) type T, in bits.
ArrayRef< QualType > Exceptions
Explicitly-specified list of exception types.
void merge(LinkageInfo other)
Merge both linkage and visibility.
bool isIncompleteType(NamedDecl **Def=nullptr) const
Types are partitioned into 3 broad categories (C99 6.2.5p1): object types, function types...
bool hasObjCGCAttr() const
TypedefNameDecl * getDecl() const
Reading or writing from this object requires a barrier call.
Expr * NoexceptExpr
Noexcept expression, if this is a computed noexcept specification.
An attributed type is a type to which a type attribute has been applied.
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate.h) and friends (in DeclFriend.h).
Represents a type parameter type in Objective C.
bool hasSignedIntegerRepresentation() const
Determine whether this type has an signed integer representation of some sort, e.g., it is an signed integer type or a vector.
Represents a C++ struct/union/class.
Represents a C array with an unspecified size.
QualType stripObjCKindOfTypeAndQuals(const ASTContext &ctx) const
Strip off the Objective-C "kindof" type and (with it) any protocol qualifiers.
bool hasIntegerRepresentation() const
Determine whether this type has an integer representation of some sort, e.g., it is an integer type o...
The parameter type of a method or function.
QualType getNamedType() const
Retrieve the type named by the qualified-id.
QualType getReplacementType() const
Gets the type that was substituted for the template parameter.
bool containsUnexpandedParameterPack() const
Whether this expression contains an unexpanded parameter pack (for C++11 variadic templates)...
void Profile(llvm::FoldingSetNodeID &ID)
Qualifiers::ObjCLifetime getObjCARCImplicitLifetime() const
Return the implicit lifetime for this type, which must not be dependent.
Stores a list of Objective-C type parameters for a parameterized class or a category/extension thereo...
This class is used for builtin types like 'int'.
Defines the clang::TargetInfo interface.
bool isComplexIntegerType() const
ASTContext & getParentASTContext() const
bool isMicrosoft() const
Is this ABI an MSVC-compatible ABI?
static Decl::Kind getKind(const Decl *D)
unsigned getNumElements() const
QualType getSuperClassType() const
Retrieve the type of the superclass of this object pointer type.
void initialize(TemplateInstantiationCallbackPtrs &Callbacks, const Sema &TheSema)
Microsoft __declspec(nothrow) extension.
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
bool mayBeDynamicClass() const
Returns true if it is a class and it might be dynamic.
Represents a type template specialization; the template must be a class template, a type alias templa...
bool isPointerType() const
CharUnits getTypeSizeInChars(QualType T) const
Return the size of the specified (complete) type T, in characters.
static StringRef getNameForCallConv(CallingConv CC)
bool isFloatingType() const
A trivial tuple used to represent a source range.
VectorType(QualType vecType, unsigned nElements, QualType canonType, VectorKind vecKind)
FunctionDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
void computeSuperClassTypeSlow() const
This represents a decl that may have a name.
QualType getObjCObjectPointerType(QualType OIT) const
Return a ObjCObjectPointerType type for the given ObjCObjectType.
A simple holder for a QualType representing a type in an exception specification. ...
Represents a C array with a specified size that is not an integer-constant-expression.
No keyword precedes the qualified type name.
bool isConstant(const ASTContext &Ctx) const
bool isInterfaceType() const
void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context)
ConceptDecl * getTypeConstraintConcept() const
bool isInStdNamespace() const
const LangOptions & getLangOpts() const
unsigned size() const
Determine the number of type parameters in this list.
llvm::Optional< NullabilityKind > getImmediateNullability() const
The "__interface" keyword introduces the elaborated-type-specifier.
The superclass of a type.
Represents the canonical version of C arrays with a specified constant size.
ExceptionSpecInfo ExceptionSpec
bool isObjCNSObjectType() const
bool hasSizedVLAType() const
Whether this type involves a variable-length array type with a definite size.
QualType getPointeeType() const
A single template declaration.
bool isBeingDefined() const
Return true if this decl is currently being defined.
static QualType getParamType(Sema &SemaRef, ArrayRef< ResultCandidate > Candidates, unsigned N)
Get the type of the Nth parameter from a given set of overload candidates.
noexcept(expression), evals to 'true'
CanQualType getSizeType() const
Return the unique type for "size_t" (C99 7.17), defined in <stddef.h>.
Qualifiers::ObjCLifetime getObjCLifetime() const
Returns lifetime attribute of this type.
QualType getPointeeType() const
Gets the type pointed to by this ObjC pointer.