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" 54 using namespace clang;
57 return (*
this != Other) &&
72 const Type* ty = getTypePtr();
84 getElementType().getBaseTypeIdentifier();
92 const auto *ClassDecl = getTypePtr()->getPointeeCXXRecordDecl();
93 return ClassDecl && ClassDecl->mayBeDynamicClass();
97 const auto *ClassDecl = getTypePtr()->getPointeeCXXRecordDecl();
98 return !ClassDecl || ClassDecl->mayBeNonDynamicClass();
106 return AT->getElementType().isConstant(Ctx);
113 const llvm::APInt &NumElements) {
122 if (llvm::isPowerOf2_64(ElementSize)) {
123 return NumElements.getActiveBits() + llvm::Log2_64(ElementSize);
128 if ((ElementSize >> 32) == 0 && NumElements.getBitWidth() <= 64 &&
129 (NumElements.getZExtValue() >> 32) == 0) {
130 uint64_t TotalSize = NumElements.getZExtValue() * ElementSize;
131 return 64 - llvm::countLeadingZeros(TotalSize);
135 llvm::APSInt SizeExtended(NumElements,
true);
137 SizeExtended = SizeExtended.extend(
std::max(SizeTypeBits,
138 SizeExtended.getBitWidth()) * 2);
140 llvm::APSInt TotalSize(llvm::APInt(SizeExtended.getBitWidth(), ElementSize));
141 TotalSize *= SizeExtended;
143 return TotalSize.getActiveBits();
158 DependentSizedArrayType::DependentSizedArrayType(
const ASTContext &Context,
163 :
ArrayType(DependentSizedArray, et, can, sm, tq,
166 Context(Context), SizeExpr((
Stmt*) e), Brackets(brackets) {}
175 ID.AddInteger(SizeMod);
176 ID.AddInteger(TypeQuals);
180 DependentVectorType::DependentVectorType(
183 :
Type(DependentVector, CanonType,
true,
188 Context(Context), ElementType(ElementType), SizeExpr(SizeExpr), Loc(Loc) {
189 VectorTypeBits.VecKind = VecKind;
197 ID.AddInteger(VecKind);
198 SizeExpr->
Profile(ID, Context,
true);
201 DependentSizedExtVectorType::DependentSizedExtVectorType(
const 207 :
Type(DependentSizedExtVector, can,
true,
212 Context(Context), SizeExpr(SizeExpr), ElementType(ElementType),
220 SizeExpr->
Profile(ID, Context,
true);
223 DependentAddressSpaceType::DependentAddressSpaceType(
226 :
Type(DependentAddressSpace, can,
true,
232 Context(Context), AddrSpaceExpr(AddrSpaceExpr), PointeeType(PointeeType),
238 Expr *AddrSpaceExpr) {
240 AddrSpaceExpr->
Profile(ID, Context,
true);
245 :
VectorType(Vector, vecType, nElements, canonType, vecKind) {}
253 ElementType(vecType) {
263 if (
const auto *ATy = dyn_cast<ArrayType>(
this))
264 return ATy->getElementType().getTypePtr();
267 if (!isa<ArrayType>(CanonicalType))
297 #define TYPE(CLASS, BASE) \ 298 static_assert(!std::is_polymorphic<CLASS##Type>::value, \ 299 #CLASS "Type should not be polymorphic!"); 300 #include "clang/AST/TypeNodes.def" 304 #define ABSTRACT_TYPE(Class, Parent) 305 #define TYPE(Class, Parent) \ 306 case Type::Class: { \ 307 const auto *ty = cast<Class##Type>(this); \ 308 if (!ty->isSugared()) return QualType(ty, 0); \ 309 return ty->desugar(); \ 311 #include "clang/AST/TypeNodes.def" 313 llvm_unreachable(
"bad type kind!");
323 #define ABSTRACT_TYPE(Class, Parent) 324 #define TYPE(Class, Parent) \ 325 case Type::Class: { \ 326 const auto *Ty = cast<Class##Type>(CurTy); \ 327 if (!Ty->isSugared()) \ 328 return SplitQualType(Ty, Qs); \ 329 Cur = Ty->desugar(); \ 332 #include "clang/AST/TypeNodes.def" 344 const Type *lastTypeWithQuals = split.
Ty;
352 #define ABSTRACT_TYPE(Class, Parent) 353 #define TYPE(Class, Parent) \ 354 case Type::Class: { \ 355 const auto *ty = cast<Class##Type>(split.Ty); \ 356 if (!ty->isSugared()) goto done; \ 357 next = ty->desugar(); \ 360 #include "clang/AST/TypeNodes.def" 365 split = next.
split();
367 lastTypeWithQuals = split.
Ty;
379 T = PT->getInnerType();
388 if (
const auto *Sugar = dyn_cast<T>(Cur))
391 #define ABSTRACT_TYPE(Class, Parent) 392 #define TYPE(Class, Parent) \ 393 case Type::Class: { \ 394 const auto *Ty = cast<Class##Type>(Cur); \ 395 if (!Ty->isSugared()) return 0; \ 396 Cur = Ty->desugar().getTypePtr(); \ 399 #include "clang/AST/TypeNodes.def" 405 return getAsSugar<TypedefType>(
this);
409 return getAsSugar<TemplateSpecializationType>(
this);
413 return getAsSugar<AttributedType>(
this);
420 const Type *Cur =
this;
424 #define ABSTRACT_TYPE(Class, Parent) 425 #define TYPE(Class, Parent) \ 427 const auto *Ty = cast<Class##Type>(Cur); \ 428 if (!Ty->isSugared()) return Cur; \ 429 Cur = Ty->desugar().getTypePtr(); \ 432 #include "clang/AST/TypeNodes.def" 438 if (
const auto *RT = getAs<RecordType>())
439 return RT->getDecl()->isClass();
444 if (
const auto *RT = getAs<RecordType>())
445 return RT->getDecl()->isStruct();
450 if (
const auto *RT = getAs<RecordType>())
451 return RT->getDecl()->hasAttr<ObjCBoxableAttr>();
456 if (
const auto *RT = getAs<RecordType>())
457 return RT->getDecl()->isInterface();
462 if (
const auto *RT = getAs<RecordType>()) {
470 if (
const auto *PT = getAs<PointerType>())
471 return PT->getPointeeType()->isVoidType();
476 if (
const auto *RT = getAs<RecordType>())
477 return RT->getDecl()->isUnion();
482 if (
const auto *CT = dyn_cast<ComplexType>(CanonicalType))
483 return CT->getElementType()->isFloatingType();
493 if (
const auto *ET = getAs<EnumType>())
494 return ET->getDecl()->isScoped();
499 if (
const auto *
Complex = getAs<ComplexType>())
500 if (
Complex->getElementType()->isIntegerType())
506 if (
const auto *PT = getAs<PointerType>())
508 if (
const auto *OPT = getAs<ObjCObjectPointerType>())
510 if (
const auto *BPT = getAs<BlockPointerType>())
512 if (
const auto *RT = getAs<ReferenceType>())
514 if (
const auto *MPT = getAs<MemberPointerType>())
516 if (
const auto *DT = getAs<DecayedType>())
523 if (
const auto *RT = dyn_cast<RecordType>(
this)) {
524 if (RT->getDecl()->isStruct())
529 if (
const auto *RT = dyn_cast<RecordType>(CanonicalType)) {
530 if (!RT->getDecl()->isStruct())
542 if (
const auto *RT = dyn_cast<RecordType>(
this)) {
543 if (RT->getDecl()->isUnion())
548 if (
const auto *RT = dyn_cast<RecordType>(CanonicalType)) {
549 if (!RT->getDecl()->isUnion())
564 const auto *OPT = getAs<ObjCObjectPointerType>();
569 if (OPT->isObjCIdType())
573 if (!OPT->isKindOfType())
577 if (OPT->isObjCClassType() || OPT->isObjCQualifiedClassType())
587 const auto *OPT = getAs<ObjCObjectPointerType>();
592 if (OPT->isObjCClassType())
596 if (!OPT->isKindOfType())
600 return OPT->isObjCClassType() || OPT->isObjCQualifiedClassType();
610 OTPDecl(const_cast<ObjCTypeParamDecl*>(D)) {
627 "bitfield overflow in type argument count");
628 if (!typeArgs.empty())
629 memcpy(getTypeArgStorage(), typeArgs.data(),
630 typeArgs.size() *
sizeof(
QualType));
632 for (
auto typeArg : typeArgs) {
633 if (typeArg->isDependentType())
635 else if (typeArg->isInstantiationDependentType())
638 if (typeArg->containsUnexpandedParameterPack())
652 if (
const auto objcObject =
getBaseType()->getAs<ObjCObjectType>()) {
654 if (isa<ObjCInterfaceType>(objcObject))
657 return objcObject->isSpecialized();
670 if (
const auto objcObject =
getBaseType()->getAs<ObjCObjectType>()) {
672 if (isa<ObjCInterfaceType>(objcObject))
675 return objcObject->getTypeArgs();
687 if (
const auto objcObject =
getBaseType()->getAs<ObjCObjectType>()) {
689 if (isa<ObjCInterfaceType>(objcObject))
692 return objcObject->isKindOfType();
708 baseType = baseObj->stripObjCKindOfTypeAndQuals(ctx);
711 splitBaseType.
Quals),
730 template <
typename Derived>
731 struct SimpleTransformVisitor :
public TypeVisitor<Derived, QualType> {
745 return Ctx.getQualifiedType(result, splitType.
Quals);
749 explicit SimpleTransformVisitor(
ASTContext &ctx) : Ctx(ctx) {}
753 #define TYPE(Class, Base) 754 #define DEPENDENT_TYPE(Class, Base) \ 755 QualType Visit##Class##Type(const Class##Type *T) { return QualType(T, 0); } 756 #include "clang/AST/TypeNodes.def" 758 #define TRIVIAL_TYPE_CLASS(Class) \ 759 QualType Visit##Class##Type(const Class##Type *T) { return QualType(T, 0); } 760 #define SUGARED_TYPE_CLASS(Class) \ 761 QualType Visit##Class##Type(const Class##Type *T) { \ 762 if (!T->isSugared()) \ 763 return QualType(T, 0); \ 764 QualType desugaredType = recurse(T->desugar()); \ 765 if (desugaredType.isNull()) \ 767 if (desugaredType.getAsOpaquePtr() == T->desugar().getAsOpaquePtr()) \ 768 return QualType(T, 0); \ 769 return desugaredType; \ 782 return Ctx.getComplexType(elementType);
793 return Ctx.getPointerType(pointeeType);
804 return Ctx.getBlockPointerType(pointeeType);
828 return Ctx.getRValueReferenceType(pointeeType);
839 return Ctx.getMemberPointerType(pointeeType, T->
getClass());
850 return Ctx.getConstantArrayType(elementType, T->
getSize(),
863 return Ctx.getVariableArrayType(elementType, T->
getSizeExpr(),
912 return Ctx.getFunctionNoProtoType(returnType, T->
getExtInfo());
922 bool paramChanged =
false;
924 QualType newParamType = recurse(paramType);
925 if (newParamType.
isNull())
931 paramTypes.push_back(newParamType);
936 bool exceptionChanged =
false;
940 QualType newExceptionType = recurse(exceptionType);
941 if (newExceptionType.
isNull())
944 if (newExceptionType.
getAsOpaquePtr() != exceptionType.getAsOpaquePtr())
945 exceptionChanged =
true;
947 exceptionTypes.push_back(newExceptionType);
950 if (exceptionChanged) {
952 llvm::makeArrayRef(exceptionTypes).copy(Ctx);
957 !paramChanged && !exceptionChanged)
960 return Ctx.getFunctionType(returnType, paramTypes, info);
971 return Ctx.getParenType(innerType);
980 if (originalType.
isNull())
984 if (adjustedType.
isNull())
992 return Ctx.getAdjustedType(originalType, adjustedType);
997 if (originalType.
isNull())
1004 return Ctx.getDecayedType(originalType);
1019 if (modifiedType.
isNull())
1023 if (equivalentType.
isNull())
1032 return Ctx.getAttributedType(T->
getAttrKind(), modifiedType,
1038 if (replacementType.
isNull())
1057 if (deducedType.
isNull())
1064 return Ctx.getAutoType(deducedType, T->
getKeyword(),
1077 bool typeArgChanged =
false;
1080 QualType newTypeArg = recurse(typeArg);
1085 typeArgChanged =
true;
1087 typeArgs.push_back(newTypeArg);
1094 return Ctx.getObjCObjectType(baseType, typeArgs,
1104 if (pointeeType.
isNull())
1111 return Ctx.getObjCObjectPointerType(pointeeType);
1123 return Ctx.getAtomicType(valueType);
1126 #undef TRIVIAL_TYPE_CLASS 1127 #undef SUGARED_TYPE_CLASS 1130 struct SubstObjCTypeArgsVisitor
1131 :
public SimpleTransformVisitor<SubstObjCTypeArgsVisitor> {
1132 using BaseType = SimpleTransformVisitor<SubstObjCTypeArgsVisitor>;
1139 : BaseType(ctx), TypeArgs(typeArgs), SubstContext(context) {}
1146 if (!TypeArgs.empty()) {
1157 argType, protocolsToApply, hasError,
true);
1160 switch (SubstContext) {
1170 const auto *objPtr =
1175 if (objPtr->isKindOfType() || objPtr->isObjCIdOrClassType())
1179 const auto *obj = objPtr->getObjectType();
1181 obj->getBaseType(), obj->getTypeArgsAsWritten(), obj->getProtocols(),
1188 llvm_unreachable(
"Unexpected ObjCSubstitutionContext!");
1203 if (isa<FunctionNoProtoType>(funcType)) {
1207 return BaseType::VisitFunctionType(funcType);
1213 const auto *funcProtoType = cast<FunctionProtoType>(funcType);
1217 bool paramChanged =
false;
1218 for (
auto paramType : funcProtoType->getParamTypes()) {
1221 if (newParamType.
isNull())
1225 paramChanged =
true;
1227 paramTypes.push_back(newParamType);
1232 bool exceptionChanged =
false;
1238 if (newExceptionType.
isNull())
1241 if (newExceptionType.
getAsOpaquePtr() != exceptionType.getAsOpaquePtr())
1242 exceptionChanged =
true;
1244 exceptionTypes.push_back(newExceptionType);
1247 if (exceptionChanged) {
1249 llvm::makeArrayRef(exceptionTypes).copy(Ctx);
1254 funcProtoType->getReturnType().getAsOpaquePtr() &&
1255 !paramChanged && !exceptionChanged)
1256 return BaseType::VisitFunctionType(funcType);
1266 bool anyChanged =
false;
1278 if (TypeArgs.empty() &&
1288 newTypeArgs.push_back(newTypeArg);
1300 return BaseType::VisitObjCObjectType(objcObjectType);
1304 QualType newType = BaseType::VisitAttributedType(attrType);
1309 if (!newAttrType || newAttrType->getAttrKind() != attr::ObjCKindOf)
1313 QualType newEquivType = newAttrType->getEquivalentType();
1325 objType->getBaseType(), objType->getTypeArgsAsWritten(),
1326 objType->getProtocols(),
1328 objType->isObjCUnqualifiedId() ?
false :
true);
1336 newAttrType->getModifiedType(), newEquivType);
1340 struct StripObjCKindOfTypeVisitor
1341 :
public SimpleTransformVisitor<StripObjCKindOfTypeVisitor> {
1342 using BaseType = SimpleTransformVisitor<StripObjCKindOfTypeVisitor>;
1344 explicit StripObjCKindOfTypeVisitor(
ASTContext &ctx) : BaseType(ctx) {}
1348 return BaseType::VisitObjCObjectType(objType);
1364 SubstObjCTypeArgsVisitor visitor(ctx, typeArgs, context);
1365 return visitor.recurse(*
this);
1379 auto &ctx =
const_cast<ASTContext &
>(constCtx);
1380 StripObjCKindOfTypeVisitor visitor(ctx);
1381 return visitor.recurse(*
this);
1385 if (
const auto AT = getTypePtr()->getAs<AtomicType>())
1386 return AT->getValueType().getUnqualifiedType();
1387 return getUnqualifiedType();
1393 if (
const auto method = dyn_cast<ObjCMethodDecl>(dc))
1394 dc = method->getDeclContext();
1404 dcTypeParams = dcClassDecl->getTypeParamList();
1411 if (!dcCategoryDecl)
1416 dcTypeParams = dcCategoryDecl->getTypeParamList();
1420 dcClassDecl = dcCategoryDecl->getClassInterface();
1424 assert(dcTypeParams &&
"No substitutions to perform");
1425 assert(dcClassDecl &&
"No class context");
1429 if (
const auto *objectPointerType = getAs<ObjCObjectPointerType>()) {
1430 objectType = objectPointerType->getObjectType();
1431 }
else if (getAs<BlockPointerType>()) {
1436 objectType = getAs<ObjCObjectType>();
1442 if (!curClassDecl) {
1450 while (curClassDecl != dcClassDecl) {
1453 if (superType.
isNull()) {
1454 objectType =
nullptr;
1474 if (
auto *
ID = IfaceT->getInterface()) {
1475 if (
ID->getTypeParamList())
1489 CachedSuperClassType.setInt(
true);
1495 if (!superClassObjTy) {
1496 CachedSuperClassType.setInt(
true);
1501 if (!superClassDecl) {
1502 CachedSuperClassType.setInt(
true);
1508 QualType superClassType(superClassObjTy, 0);
1510 if (!superClassTypeParams) {
1511 CachedSuperClassType.setPointerAndInt(
1518 CachedSuperClassType.setPointerAndInt(superClassObjTy,
true);
1526 CachedSuperClassType.setPointerAndInt(
1537 CachedSuperClassType.setPointerAndInt(
1545 assert(typeArgs.size() == typeParams->
size());
1546 CachedSuperClassType.setPointerAndInt(
1549 ->castAs<ObjCObjectType>(),
1555 return interfaceDecl->getASTContext().getObjCInterfaceType(interfaceDecl)
1564 if (superObjectType.
isNull())
1565 return superObjectType;
1567 ASTContext &ctx = getInterfaceDecl()->getASTContext();
1575 if (
const auto *T = getAs<ObjCObjectType>())
1576 if (T->getNumProtocols() && T->getInterface())
1588 if (
const auto *OPT = getAs<ObjCObjectPointerType>()) {
1589 if (OPT->isObjCQualifiedIdType())
1598 if (
const auto *OPT = getAs<ObjCObjectPointerType>()) {
1599 if (OPT->isObjCQualifiedClassType())
1606 if (
const auto *OT = getAs<ObjCObjectType>()) {
1607 if (OT->getInterface())
1614 if (
const auto *OPT = getAs<ObjCObjectPointerType>()) {
1615 if (OPT->getInterfaceType())
1623 if (
const auto *PT = getAs<PointerType>())
1625 else if (
const auto *RT = getAs<ReferenceType>())
1637 return dyn_cast_or_null<CXXRecordDecl>(
getAsTagDecl());
1645 if (
const auto *TT = getAs<TagType>())
1646 return TT->getDecl();
1647 if (
const auto *Injected = getAs<InjectedClassNameType>())
1648 return Injected->getDecl();
1654 const Type *Cur =
this;
1656 if (AT->getAttrKind() == AK)
1658 Cur = AT->getEquivalentType().getTypePtr();
1665 class GetContainedDeducedTypeVisitor :
1666 public TypeVisitor<GetContainedDeducedTypeVisitor, Type*> {
1670 GetContainedDeducedTypeVisitor(
bool Syntactic =
false)
1671 : Syntactic(Syntactic) {}
1712 Type *VisitDependentSizedExtVectorType(
1723 return const_cast<FunctionProtoType*>(T);
1724 return VisitFunctionType(T);
1755 return cast_or_null<DeducedType>(
1756 GetContainedDeducedTypeVisitor().Visit(
this));
1760 return dyn_cast_or_null<FunctionType>(
1761 GetContainedDeducedTypeVisitor(
true).Visit(
this));
1765 if (
const auto *VT = dyn_cast<VectorType>(CanonicalType))
1766 return VT->getElementType()->isIntegerType();
1791 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
1792 return BT->getKind() >= BuiltinType::Bool &&
1793 BT->getKind() <= BuiltinType::Int128;
1797 if (
const auto *ET = dyn_cast<EnumType>(CanonicalType))
1798 return ET->getDecl()->isComplete();
1804 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
1805 return BT->getKind() >= BuiltinType::Bool &&
1806 BT->getKind() <= BuiltinType::Int128;
1812 if (
const auto *ET = dyn_cast<EnumType>(CanonicalType))
1813 return ET->getDecl()->isComplete() && !ET->getDecl()->isScoped();
1819 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
1820 return BT->getKind() == BuiltinType::Char_U ||
1821 BT->getKind() == BuiltinType::UChar ||
1822 BT->getKind() == BuiltinType::Char_S ||
1823 BT->getKind() == BuiltinType::SChar;
1828 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
1829 return BT->getKind() == BuiltinType::WChar_S ||
1830 BT->getKind() == BuiltinType::WChar_U;
1835 if (
const BuiltinType *BT = dyn_cast<BuiltinType>(CanonicalType))
1836 return BT->getKind() == BuiltinType::Char8;
1841 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
1842 return BT->getKind() == BuiltinType::Char16;
1847 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
1848 return BT->getKind() == BuiltinType::Char32;
1855 const auto *BT = dyn_cast<
BuiltinType>(CanonicalType);
1856 if (!BT)
return false;
1857 switch (BT->getKind()) {
1858 default:
return false;
1859 case BuiltinType::Char_U:
1860 case BuiltinType::UChar:
1861 case BuiltinType::WChar_U:
1862 case BuiltinType::Char8:
1863 case BuiltinType::Char16:
1864 case BuiltinType::Char32:
1865 case BuiltinType::Char_S:
1866 case BuiltinType::SChar:
1867 case BuiltinType::WChar_S:
1876 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType)) {
1877 return BT->getKind() >= BuiltinType::Char_S &&
1878 BT->getKind() <= BuiltinType::Int128;
1881 if (
const EnumType *ET = dyn_cast<EnumType>(CanonicalType)) {
1884 if (ET->getDecl()->isComplete() && !ET->getDecl()->isScoped())
1885 return ET->getDecl()->getIntegerType()->isSignedIntegerType();
1892 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType)) {
1893 return BT->getKind() >= BuiltinType::Char_S &&
1894 BT->getKind() <= BuiltinType::Int128;
1897 if (
const auto *ET = dyn_cast<EnumType>(CanonicalType)) {
1898 if (ET->getDecl()->isComplete())
1899 return ET->getDecl()->getIntegerType()->isSignedIntegerType();
1906 if (
const auto *VT = dyn_cast<VectorType>(CanonicalType))
1907 return VT->getElementType()->isSignedIntegerOrEnumerationType();
1916 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType)) {
1917 return BT->getKind() >= BuiltinType::Bool &&
1918 BT->getKind() <= BuiltinType::UInt128;
1921 if (
const auto *ET = dyn_cast<EnumType>(CanonicalType)) {
1924 if (ET->getDecl()->isComplete() && !ET->getDecl()->isScoped())
1925 return ET->getDecl()->getIntegerType()->isUnsignedIntegerType();
1932 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType)) {
1933 return BT->getKind() >= BuiltinType::Bool &&
1934 BT->getKind() <= BuiltinType::UInt128;
1937 if (
const auto *ET = dyn_cast<EnumType>(CanonicalType)) {
1938 if (ET->getDecl()->isComplete())
1939 return ET->getDecl()->getIntegerType()->isUnsignedIntegerType();
1946 if (
const auto *VT = dyn_cast<VectorType>(CanonicalType))
1947 return VT->getElementType()->isUnsignedIntegerOrEnumerationType();
1953 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
1954 return BT->getKind() >= BuiltinType::Half &&
1955 BT->getKind() <= BuiltinType::Float128;
1956 if (
const auto *CT = dyn_cast<ComplexType>(CanonicalType))
1957 return CT->getElementType()->isFloatingType();
1962 if (
const auto *VT = dyn_cast<VectorType>(CanonicalType))
1963 return VT->getElementType()->isFloatingType();
1969 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
1970 return BT->isFloatingPoint();
1975 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
1976 return BT->getKind() >= BuiltinType::Bool &&
1977 BT->getKind() <= BuiltinType::Float128;
1978 if (
const auto *ET = dyn_cast<EnumType>(CanonicalType))
1979 return ET->getDecl()->isComplete() && !ET->getDecl()->isScoped();
1984 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
1985 return BT->getKind() >= BuiltinType::Bool &&
1986 BT->getKind() <= BuiltinType::Float128;
1987 if (
const auto *ET = dyn_cast<EnumType>(CanonicalType))
1994 return !ET->getDecl()->isScoped() && ET->getDecl()->isComplete();
1995 return isa<ComplexType>(CanonicalType);
2002 if (
const auto *BT = dyn_cast<BuiltinType>(T)) {
2003 if (BT->getKind() == BuiltinType::Bool)
return STK_Bool;
2004 if (BT->getKind() == BuiltinType::NullPtr)
return STK_CPointer;
2008 llvm_unreachable(
"unknown scalar builtin type");
2009 }
else if (isa<PointerType>(T)) {
2011 }
else if (isa<BlockPointerType>(T)) {
2013 }
else if (isa<ObjCObjectPointerType>(T)) {
2015 }
else if (isa<MemberPointerType>(T)) {
2017 }
else if (isa<EnumType>(T)) {
2018 assert(cast<EnumType>(T)->getDecl()->isComplete());
2020 }
else if (
const auto *CT = dyn_cast<ComplexType>(T)) {
2021 if (CT->getElementType()->isRealFloatingType())
2026 llvm_unreachable(
"unknown scalar type");
2039 if (
const auto *Record = dyn_cast<RecordType>(CanonicalType)) {
2040 if (
const auto *ClassDecl = dyn_cast<CXXRecordDecl>(Record->getDecl()))
2041 return ClassDecl->isAggregate();
2046 return isa<ArrayType>(CanonicalType);
2053 assert(!
isIncompleteType() &&
"This doesn't make sense for incomplete types");
2054 assert(!
isDependentType() &&
"This doesn't make sense for dependent types");
2056 return !isa<VariableArrayType>(CanonicalType);
2066 switch (CanonicalType->getTypeClass()) {
2067 default:
return false;
2073 EnumDecl *EnumD = cast<EnumType>(CanonicalType)->getDecl();
2081 RecordDecl *Rec = cast<RecordType>(CanonicalType)->getDecl();
2091 return cast<ArrayType>(CanonicalType)->getElementType()
2092 ->isIncompleteType(Def);
2093 case IncompleteArray:
2096 case MemberPointer: {
2100 auto *MPTy = cast<MemberPointerType>(CanonicalType);
2101 const Type *ClassTy = MPTy->getClass();
2103 if (ClassTy->isDependentType())
2114 if (RD->
hasAttr<MSInheritanceAttr>())
2119 return cast<ObjCObjectType>(CanonicalType)->
getBaseType()
2121 case ObjCInterface: {
2124 = cast<ObjCInterfaceType>(CanonicalType)->getDecl();
2135 return isCXX11PODType(Context);
2137 return isCXX98PODType(Context);
2147 if ((*this)->isIncompleteArrayType())
2150 if ((*this)->isIncompleteType())
2153 if (hasNonTrivialObjCLifetime())
2156 QualType CanonicalType = getTypePtr()->CanonicalType;
2159 default:
return false;
2160 case Type::VariableArray:
2161 case Type::ConstantArray:
2165 case Type::ObjCObjectPointer:
2166 case Type::BlockPointer:
2170 case Type::MemberPointer:
2172 case Type::ExtVector:
2179 if (
const auto *ClassDecl =
2180 dyn_cast<CXXRecordDecl>(cast<RecordType>(CanonicalType)->getDecl()))
2181 return ClassDecl->isPOD();
2195 if ((*this)->isArrayType())
2200 if ((*this)->isIncompleteType())
2203 if (hasNonTrivialObjCLifetime())
2206 QualType CanonicalType = getTypePtr()->CanonicalType;
2219 if (
const auto *ClassDecl = dyn_cast<CXXRecordDecl>(RT->getDecl())) {
2224 return ClassDecl->hasDefaultConstructor() &&
2225 !ClassDecl->hasNonTrivialDefaultConstructor() &&
2226 ClassDecl->isTriviallyCopyable();
2237 if ((*this)->isArrayType())
2240 if (hasNonTrivialObjCLifetime())
2248 QualType CanonicalType = getCanonicalType();
2262 if (
const auto *ClassDecl = dyn_cast<CXXRecordDecl>(RT->getDecl())) {
2263 if (!ClassDecl->isTriviallyCopyable())
return false;
2293 if (
const auto *RT =
2295 if (RT->getDecl()->isNonTrivialToPrimitiveDefaultInitialize())
2298 switch (getQualifiers().getObjCLifetime()) {
2300 return PDIK_ARCStrong;
2302 return PDIK_ARCWeak;
2304 return PDIK_Trivial;
2309 if (
const auto *RT =
2311 if (RT->getDecl()->isNonTrivialToPrimitiveCopy())
2317 return PCK_ARCStrong;
2321 return Qs.
hasVolatile() ? PCK_VolatileTrivial : PCK_Trivial;
2327 return isNonTrivialToPrimitiveCopy();
2347 assert(BaseTy &&
"NULL element type");
2377 if (
const auto *ClassDecl = dyn_cast<CXXRecordDecl>(RT->getDecl()))
2378 return ClassDecl->isLiteral();
2385 return AT->getValueType()->isLiteralType(Ctx);
2404 assert(BaseTy &&
"NULL element type");
2414 if (
const auto *ClassDecl = dyn_cast<CXXRecordDecl>(RT->getDecl()))
2415 if (!ClassDecl->isStandardLayout())
2432 const Type *ty = getTypePtr();
2436 if (hasNonTrivialObjCLifetime())
2443 assert(BaseTy &&
"NULL element type");
2453 if (
const auto *ClassDecl = dyn_cast<CXXRecordDecl>(RT->getDecl())) {
2456 if (!ClassDecl->isTrivial())
return false;
2461 if (!ClassDecl->isStandardLayout())
return false;
2481 if (
const auto *ET = getAs<EnumType>()) {
2483 if (II && II->
isStr(
"align_val_t") && ET->getDecl()->isInStdNamespace())
2490 if (
const auto *ET = getAs<EnumType>()) {
2492 if (II && II->
isStr(
"byte") && ET->getDecl()->isInStdNamespace())
2499 if (
const auto *BT = getAs<BuiltinType>())
2500 switch (BT->getKind()) {
2501 case BuiltinType::Bool:
2502 case BuiltinType::Char_S:
2503 case BuiltinType::Char_U:
2504 case BuiltinType::SChar:
2505 case BuiltinType::UChar:
2506 case BuiltinType::Short:
2507 case BuiltinType::UShort:
2508 case BuiltinType::WChar_S:
2509 case BuiltinType::WChar_U:
2510 case BuiltinType::Char8:
2511 case BuiltinType::Char16:
2512 case BuiltinType::Char32:
2520 if (
const auto *ET = getAs<EnumType>()){
2521 if (this->
isDependentType() || ET->getDecl()->getPromotionType().isNull()
2522 || ET->getDecl()->isScoped())
2541 case TemplateTypeParm:
2542 case SubstTemplateTypeParm:
2543 case TemplateSpecialization:
2546 case DependentTemplateSpecialization:
2549 case ObjCObjectPointer:
2579 llvm_unreachable(
"Type specifier is not a tag type kind.");
2591 llvm_unreachable(
"Unknown tag type kind.");
2604 llvm_unreachable(
"Elaborated type keyword is not a tag type kind.");
2606 llvm_unreachable(
"Unknown elaborated type keyword.");
2622 llvm_unreachable(
"Unknown elaborated type keyword.");
2636 llvm_unreachable(
"Unknown elaborated type keyword.");
2639 DependentTemplateSpecializationType::DependentTemplateSpecializationType(
2644 :
TypeWithKeyword(Keyword, DependentTemplateSpecialization, Canon,
true,
true,
2647 NNS(NNS), Name(Name) {
2650 "DependentTemplateSpecializatonType requires dependent qualifier");
2653 if (Arg.containsUnexpandedParameterPack())
2667 ID.AddInteger(Keyword);
2668 ID.AddPointer(Qualifier);
2669 ID.AddPointer(Name);
2671 Arg.Profile(ID, Context);
2676 if (
const auto *Elab = dyn_cast<ElaboratedType>(
this))
2677 Keyword = Elab->getKeyword();
2678 else if (
const auto *DepName = dyn_cast<DependentNameType>(
this))
2679 Keyword = DepName->getKeyword();
2680 else if (
const auto *DepTST =
2681 dyn_cast<DependentTemplateSpecializationType>(
this))
2682 Keyword = DepTST->getKeyword();
2691 #define ABSTRACT_TYPE(Derived, Base) 2692 #define TYPE(Derived, Base) case Derived: return #Derived; 2693 #include "clang/AST/TypeNodes.def" 2696 llvm_unreachable(
"Invalid type class.");
2704 return Policy.
Bool ?
"bool" :
"_Bool";
2710 return "signed char";
2722 return "unsigned char";
2724 return "unsigned short";
2726 return "unsigned int";
2728 return "unsigned long";
2730 return "unsigned long long";
2732 return "unsigned __int128";
2734 return Policy.
Half ?
"half" :
"__fp16";
2740 return "long double";
2742 return "short _Accum";
2746 return "long _Accum";
2748 return "unsigned short _Accum";
2750 return "unsigned _Accum";
2752 return "unsigned long _Accum";
2753 case BuiltinType::ShortFract:
2754 return "short _Fract";
2755 case BuiltinType::Fract:
2757 case BuiltinType::LongFract:
2758 return "long _Fract";
2759 case BuiltinType::UShortFract:
2760 return "unsigned short _Fract";
2761 case BuiltinType::UFract:
2762 return "unsigned _Fract";
2763 case BuiltinType::ULongFract:
2764 return "unsigned long _Fract";
2765 case BuiltinType::SatShortAccum:
2766 return "_Sat short _Accum";
2767 case BuiltinType::SatAccum:
2768 return "_Sat _Accum";
2769 case BuiltinType::SatLongAccum:
2770 return "_Sat long _Accum";
2771 case BuiltinType::SatUShortAccum:
2772 return "_Sat unsigned short _Accum";
2773 case BuiltinType::SatUAccum:
2774 return "_Sat unsigned _Accum";
2775 case BuiltinType::SatULongAccum:
2776 return "_Sat unsigned long _Accum";
2777 case BuiltinType::SatShortFract:
2778 return "_Sat short _Fract";
2779 case BuiltinType::SatFract:
2780 return "_Sat _Fract";
2781 case BuiltinType::SatLongFract:
2782 return "_Sat long _Fract";
2783 case BuiltinType::SatUShortFract:
2784 return "_Sat unsigned short _Fract";
2785 case BuiltinType::SatUFract:
2786 return "_Sat unsigned _Fract";
2787 case BuiltinType::SatULongFract:
2788 return "_Sat unsigned long _Fract";
2792 return "__float128";
2795 return Policy.
MSWChar ?
"__wchar_t" :
"wchar_t";
2805 return "<overloaded function type>";
2807 return "<bound member function type>";
2809 return "<pseudo-object type>";
2811 return "<dependent type>";
2813 return "<unknown type>";
2814 case ARCUnbridgedCast:
2815 return "<ARC unbridged cast type>";
2817 return "<builtin fn type>";
2824 #define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \ 2826 return "__" #Access " " #ImgType "_t"; 2827 #include "clang/Basic/OpenCLImageTypes.def" 2833 return "clk_event_t";
2837 return "reserve_id_t";
2838 case OMPArraySection:
2839 return "<OpenMP array section type>";
2840 #define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \ 2843 #include "clang/Basic/OpenCLExtensionTypes.def" 2846 llvm_unreachable(
"Invalid builtin type.");
2850 if (
const auto *RefType = getTypePtr()->getAs<ReferenceType>())
2859 (!getTypePtr()->isDependentType() && !getTypePtr()->isRecordType()))
2860 return getUnqualifiedType();
2867 case CC_C:
return "cdecl";
2887 llvm_unreachable(
"Invalid calling convention.");
2892 const ExtProtoInfo &epi)
2900 assert(getNumParams() == params.size() &&
"NumParams overflow!");
2907 if (hasExtraBitfields(epi.ExceptionSpec.Type)) {
2908 auto &ExtraBits = *getTrailingObjects<FunctionTypeExtraBitfields>();
2909 ExtraBits.NumExceptionType = epi.ExceptionSpec.Exceptions.size();
2913 auto *argSlot = getTrailingObjects<QualType>();
2914 for (
unsigned i = 0;
i != getNumParams(); ++
i) {
2923 argSlot[
i] = params[
i];
2928 assert(hasExtraBitfields() &&
"missing trailing extra bitfields!");
2930 reinterpret_cast<QualType *
>(getTrailingObjects<ExceptionType>());
2942 exnSlot[I++] = ExceptionType;
2947 assert(epi.ExceptionSpec.NoexceptExpr &&
"computed noexcept with no expr");
2949 epi.ExceptionSpec.NoexceptExpr->isValueDependent());
2952 *getTrailingObjects<Expr *>() = epi.ExceptionSpec.NoexceptExpr;
2954 if (epi.ExceptionSpec.NoexceptExpr->isValueDependent() ||
2955 epi.ExceptionSpec.NoexceptExpr->isInstantiationDependent())
2958 if (epi.ExceptionSpec.NoexceptExpr->containsUnexpandedParameterPack())
2965 auto **slot = getTrailingObjects<FunctionDecl *>();
2966 slot[0] = epi.ExceptionSpec.SourceDecl;
2967 slot[1] = epi.ExceptionSpec.SourceTemplate;
2973 auto **slot = getTrailingObjects<FunctionDecl *>();
2974 slot[0] = epi.ExceptionSpec.SourceDecl;
2982 assert(hasDependentExceptionSpec() &&
"type should not be canonical");
2991 if (epi.ExtParameterInfos) {
2992 auto *extParamInfos = getTrailingObjects<ExtParameterInfo>();
2993 for (
unsigned i = 0;
i != getNumParams(); ++
i)
2994 extParamInfos[
i] = epi.ExtParameterInfos[
i];
2997 if (epi.TypeQuals.hasNonFastQualifiers()) {
2999 *getTrailingObjects<Qualifiers>() = epi.TypeQuals;
3006 if (
Expr *NE = getNoexceptExpr())
3007 return NE->isValueDependent();
3018 if (
Expr *NE = getNoexceptExpr())
3019 return NE->isInstantiationDependent();
3021 if (ET->isInstantiationDependentType())
3027 switch (getExceptionSpecType()) {
3031 llvm_unreachable(
"should not call this with unresolved exception specs");
3047 for (
unsigned I = 0; I != getNumExceptions(); ++I)
3056 llvm_unreachable(
"unexpected exception specification kind");
3060 for (
unsigned ArgIdx = getNumParams(); ArgIdx; --ArgIdx)
3068 const QualType *ArgTys,
unsigned NumParams,
3089 for (
unsigned i = 0;
i != NumParams; ++
i)
3094 assert(!(
unsigned(epi.
Variadic) & ~1) &&
3097 "Values larger than expected.");
3112 for (
unsigned i = 0;
i != NumParams; ++
i)
3121 Profile(ID, getReturnType(), param_type_begin(), getNumParams(),
3126 return getDecl()->getUnderlyingType();
3135 while (
auto *InnerMQT = dyn_cast<MacroQualifiedType>(Inner)) {
3136 if (InnerMQT->getMacroIdentifier() != getMacroIdentifier())
3138 Inner = InnerMQT->getModifiedType();
3144 :
Type(TypeOfExpr, can, E->isTypeDependent(),
3145 E->isInstantiationDependent(),
3163 E->
Profile(ID, Context,
true);
3170 :
Type(Decltype, can, E->isInstantiationDependent(),
3171 E->isInstantiationDependent(),
3174 E(E), UnderlyingType(underlyingType) {}
3186 :
DecltypeType(E, Context.DependentTy), Context(Context) {}
3190 E->
Profile(ID, Context,
true);
3201 BaseType(BaseType), UnderlyingType(UnderlyingType), UKind(UKind) {}
3216 for (
auto I : decl->
redecls()) {
3217 if (I->isCompleteDefinition() || I->isBeingDefined())
3233 std::vector<const RecordType*> RecordTypeList;
3234 RecordTypeList.push_back(
this);
3235 unsigned NextToCheckIndex = 0;
3237 while (RecordTypeList.size() > NextToCheckIndex) {
3239 RecordTypeList[NextToCheckIndex]->
getDecl()->fields()) {
3245 if (llvm::find(RecordTypeList, FieldRecTy) == RecordTypeList.end())
3246 RecordTypeList.push_back(FieldRecTy);
3256 switch (getAttrKind()) {
3261 case attr::ObjCOwnership:
3262 case attr::ObjCInertUnsafeUnretained:
3263 case attr::TypeNonNull:
3264 case attr::TypeNullable:
3265 case attr::TypeNullUnspecified:
3266 case attr::LifetimeBound:
3267 case attr::AddressSpace:
3279 switch (getAttrKind()) {
3280 default:
return false;
3287 llvm_unreachable(
"invalid attr kind");
3292 switch (getAttrKind()) {
3293 default:
return false;
3296 case attr::FastCall:
3298 case attr::ThisCall:
3300 case attr::SwiftCall:
3301 case attr::VectorCall:
3302 case attr::AArch64VectorPcs:
3306 case attr::IntelOclBicc:
3307 case attr::PreserveMost:
3308 case attr::PreserveAll:
3311 llvm_unreachable(
"invalid attr kind");
3322 SubstTemplateTypeParmPackType::
3326 :
Type(SubstTemplateTypeParmPack, Canon,
true,
true,
false,
true),
3327 Replaced(Param), Arguments(ArgPack.
pack_begin()) {
3336 Profile(ID, getReplacedParameter(), getArgumentPack());
3342 ID.AddPointer(Replaced);
3345 ID.AddPointer(
P.getAsType().getAsOpaquePtr());
3350 bool &InstantiationDependent) {
3351 return anyDependentTemplateArguments(Args.
arguments(),
3352 InstantiationDependent);
3357 bool &InstantiationDependent) {
3359 if (ArgLoc.getArgument().isDependent()) {
3360 InstantiationDependent =
true;
3364 if (ArgLoc.getArgument().isInstantiationDependent())
3365 InstantiationDependent =
true;
3370 TemplateSpecializationType::
3374 :
Type(TemplateSpecialization,
3384 "Use DependentTemplateSpecializationType for dependent template-name");
3388 "Unexpected template name for TemplateSpecializationType");
3400 if (Arg.isInstantiationDependent())
3403 Arg.getAsType()->isVariablyModifiedType())
3405 if (Arg.containsUnexpandedParameterPack())
3411 if (isTypeAlias()) {
3413 *
reinterpret_cast<QualType*
>(
Begin + getNumArgs()) = AliasedType;
3424 Arg.Profile(ID, Context);
3429 if (!hasNonFastQualifiers())
3437 if (!hasNonFastQualifiers())
3438 return QualType(T, getFastQualifiers());
3449 ID.AddInteger(typeArgs.size());
3450 for (
auto typeArg : typeArgs)
3451 ID.AddPointer(typeArg.getAsOpaquePtr());
3452 ID.AddInteger(protocols.size());
3453 for (
auto proto : protocols)
3454 ID.AddPointer(proto);
3455 ID.AddBoolean(isKindOf);
3459 Profile(ID, getBaseType(), getTypeArgsAsWritten(),
3460 llvm::makeArrayRef(qual_begin(), getNumProtocols()),
3461 isKindOfTypeAsWritten());
3467 ID.AddPointer(OTPDecl);
3468 ID.AddInteger(protocols.size());
3469 for (
auto proto : protocols)
3470 ID.AddPointer(proto);
3475 llvm::makeArrayRef(qual_begin(), getNumProtocols()));
3481 class CachedProperties {
3486 CachedProperties(
Linkage L,
bool local) : L(L), local(local) {}
3489 bool hasLocalOrUnnamedType()
const {
return local; }
3491 friend CachedProperties merge(CachedProperties L, CachedProperties R) {
3493 return CachedProperties(MergedLinkage,
3494 L.hasLocalOrUnnamedType() | R.hasLocalOrUnnamedType());
3510 return get(T.getTypePtr());
3513 static CachedProperties
get(
const Type *T) {
3515 return CachedProperties(T->
TypeBits.getLinkage(),
3516 T->
TypeBits.hasLocalOrUnnamedType());
3521 if (T->
TypeBits.isCacheValid())
return;
3537 T->
TypeBits.CachedLinkage = Result.getLinkage();
3538 T->
TypeBits.CachedLocalOrUnnamed = Result.hasLocalOrUnnamedType();
3557 #define TYPE(Class,Base) 3558 #define NON_CANONICAL_TYPE(Class,Base) case Type::Class: 3559 #include "clang/AST/TypeNodes.def" 3560 llvm_unreachable(
"didn't expect a non-canonical type here");
3562 #define TYPE(Class,Base) 3563 #define DEPENDENT_TYPE(Class,Base) case Type::Class: 3564 #define NON_CANONICAL_UNLESS_DEPENDENT_TYPE(Class,Base) case Type::Class: 3565 #include "clang/AST/TypeNodes.def" 3571 case Type::DeducedTemplateSpecialization:
3591 bool IsLocalOrUnnamed =
3594 return CachedProperties(L, IsLocalOrUnnamed);
3601 return Cache::get(cast<ComplexType>(T)->getElementType());
3604 case Type::BlockPointer:
3606 case Type::LValueReference:
3607 case Type::RValueReference:
3609 case Type::MemberPointer: {
3610 const auto *MPT = cast<MemberPointerType>(T);
3614 case Type::ConstantArray:
3615 case Type::IncompleteArray:
3616 case Type::VariableArray:
3617 return Cache::get(cast<ArrayType>(T)->getElementType());
3619 case Type::ExtVector:
3620 return Cache::get(cast<VectorType>(T)->getElementType());
3621 case Type::FunctionNoProto:
3622 return Cache::get(cast<FunctionType>(T)->getReturnType());
3623 case Type::FunctionProto: {
3624 const auto *FPT = cast<FunctionProtoType>(T);
3625 CachedProperties result =
Cache::get(FPT->getReturnType());
3626 for (
const auto &ai : FPT->param_types())
3630 case Type::ObjCInterface: {
3632 return CachedProperties(L,
false);
3634 case Type::ObjCObject:
3635 return Cache::get(cast<ObjCObjectType>(T)->getBaseType());
3636 case Type::ObjCObjectPointer:
3639 return Cache::get(cast<AtomicType>(T)->getValueType());
3641 return Cache::get(cast<PipeType>(T)->getElementType());
3644 llvm_unreachable(
"unhandled type class");
3655 return TypeBits.hasLocalOrUnnamedType();
3660 #define TYPE(Class,Base) 3661 #define NON_CANONICAL_TYPE(Class,Base) case Type::Class: 3662 #include "clang/AST/TypeNodes.def" 3663 llvm_unreachable(
"didn't expect a non-canonical type here");
3665 #define TYPE(Class,Base) 3666 #define DEPENDENT_TYPE(Class,Base) case Type::Class: 3667 #define NON_CANONICAL_UNLESS_DEPENDENT_TYPE(Class,Base) case Type::Class: 3668 #include "clang/AST/TypeNodes.def" 3677 case Type::DeducedTemplateSpecialization:
3682 return getDeclLinkageAndVisibility(cast<TagType>(T)->
getDecl());
3685 return computeTypeLinkageInfo(cast<ComplexType>(T)->getElementType());
3687 return computeTypeLinkageInfo(cast<PointerType>(T)->
getPointeeType());
3688 case Type::BlockPointer:
3689 return computeTypeLinkageInfo(cast<BlockPointerType>(T)->
getPointeeType());
3690 case Type::LValueReference:
3691 case Type::RValueReference:
3692 return computeTypeLinkageInfo(cast<ReferenceType>(T)->
getPointeeType());
3693 case Type::MemberPointer: {
3694 const auto *MPT = cast<MemberPointerType>(T);
3695 LinkageInfo LV = computeTypeLinkageInfo(MPT->getClass());
3696 LV.
merge(computeTypeLinkageInfo(MPT->getPointeeType()));
3699 case Type::ConstantArray:
3700 case Type::IncompleteArray:
3701 case Type::VariableArray:
3702 return computeTypeLinkageInfo(cast<ArrayType>(T)->getElementType());
3704 case Type::ExtVector:
3705 return computeTypeLinkageInfo(cast<VectorType>(T)->getElementType());
3706 case Type::FunctionNoProto:
3707 return computeTypeLinkageInfo(cast<FunctionType>(T)->getReturnType());
3708 case Type::FunctionProto: {
3709 const auto *FPT = cast<FunctionProtoType>(T);
3710 LinkageInfo LV = computeTypeLinkageInfo(FPT->getReturnType());
3711 for (
const auto &ai : FPT->param_types())
3712 LV.
merge(computeTypeLinkageInfo(ai));
3715 case Type::ObjCInterface:
3716 return getDeclLinkageAndVisibility(cast<ObjCInterfaceType>(T)->
getDecl());
3717 case Type::ObjCObject:
3718 return computeTypeLinkageInfo(cast<ObjCObjectType>(T)->getBaseType());
3719 case Type::ObjCObjectPointer:
3720 return computeTypeLinkageInfo(
3723 return computeTypeLinkageInfo(cast<AtomicType>(T)->getValueType());
3725 return computeTypeLinkageInfo(cast<PipeType>(T)->getElementType());
3728 llvm_unreachable(
"unhandled type class");
3760 if (
auto Nullability = AT->getImmediateNullability())
3763 Type = AT->getEquivalentType();
3773 #define NON_CANONICAL_TYPE(Class, Parent) \ 3775 llvm_unreachable("non-canonical type"); 3776 #define TYPE(Class, Parent) 3777 #include "clang/AST/TypeNodes.def" 3781 case Type::BlockPointer:
3782 case Type::MemberPointer:
3783 case Type::ObjCObjectPointer:
3787 case Type::UnresolvedUsing:
3788 case Type::TypeOfExpr:
3790 case Type::Decltype:
3791 case Type::UnaryTransform:
3792 case Type::TemplateTypeParm:
3793 case Type::SubstTemplateTypeParmPack:
3794 case Type::DependentName:
3795 case Type::DependentTemplateSpecialization:
3797 return ResultIfUnknown;
3802 case Type::TemplateSpecialization:
3804 = cast<TemplateSpecializationType>(type.
getTypePtr())
3805 ->getTemplateName().getAsTemplateDecl()) {
3806 if (isa<ClassTemplateDecl>(templateDecl))
3809 return ResultIfUnknown;
3814 #define SIGNED_TYPE(Id, SingletonId) case BuiltinType::Id: 3815 #define UNSIGNED_TYPE(Id, SingletonId) case BuiltinType::Id: 3816 #define FLOATING_TYPE(Id, SingletonId) case BuiltinType::Id: 3817 #define BUILTIN_TYPE(Id, SingletonId) 3818 #include "clang/AST/BuiltinTypes.def" 3822 case BuiltinType::Dependent:
3823 case BuiltinType::Overload:
3824 case BuiltinType::BoundMember:
3825 case BuiltinType::PseudoObject:
3826 case BuiltinType::UnknownAny:
3827 case BuiltinType::ARCUnbridgedCast:
3828 return ResultIfUnknown;
3830 case BuiltinType::Void:
3831 case BuiltinType::ObjCId:
3832 case BuiltinType::ObjCClass:
3833 case BuiltinType::ObjCSel:
3834 #define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \ 3835 case BuiltinType::Id: 3836 #include "clang/Basic/OpenCLImageTypes.def" 3837 #define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \ 3838 case BuiltinType::Id: 3839 #include "clang/Basic/OpenCLExtensionTypes.def" 3840 case BuiltinType::OCLSampler:
3841 case BuiltinType::OCLEvent:
3842 case BuiltinType::OCLClkEvent:
3843 case BuiltinType::OCLQueue:
3844 case BuiltinType::OCLReserveID:
3845 case BuiltinType::BuiltinFn:
3846 case BuiltinType::NullPtr:
3847 case BuiltinType::OMPArraySection:
3850 llvm_unreachable(
"unknown builtin type");
3854 case Type::LValueReference:
3855 case Type::RValueReference:
3856 case Type::ConstantArray:
3857 case Type::IncompleteArray:
3858 case Type::VariableArray:
3859 case Type::DependentSizedArray:
3860 case Type::DependentVector:
3861 case Type::DependentSizedExtVector:
3863 case Type::ExtVector:
3864 case Type::DependentAddressSpace:
3865 case Type::FunctionProto:
3866 case Type::FunctionNoProto:
3868 case Type::DeducedTemplateSpecialization:
3870 case Type::InjectedClassName:
3871 case Type::PackExpansion:
3872 case Type::ObjCObject:
3873 case Type::ObjCInterface:
3878 llvm_unreachable(
"bad type kind!");
3883 if (getAttrKind() == attr::TypeNonNull)
3885 if (getAttrKind() == attr::TypeNullable)
3887 if (getAttrKind() == attr::TypeNullUnspecified)
3894 if (
auto MacroTy = dyn_cast<MacroQualifiedType>(T))
3895 AttrTy = MacroTy->getUnderlyingType();
3897 if (
auto attributed = dyn_cast<AttributedType>(AttrTy)) {
3898 if (
auto nullability = attributed->getImmediateNullability()) {
3899 T = attributed->getModifiedType();
3908 const auto *objcPtr = getAs<ObjCObjectPointerType>();
3912 if (objcPtr->isObjCIdType()) {
3923 }
else if (objcPtr->isObjCQualifiedIdType()) {
3948 "cannot query implicit lifetime for non-inferrable type");
3953 while (
const auto *array = dyn_cast<ArrayType>(canon))
3954 canon = array->getElementType().getTypePtr();
3956 if (
const auto *opt = dyn_cast<ObjCObjectPointerType>(canon)) {
3958 if (opt->getObjectType()->isObjCClass())
3966 const Type *cur =
this;
3968 if (
const auto *
typedefType = dyn_cast<TypedefType>(cur))
3969 return typedefType->getDecl()->hasAttr<ObjCNSObjectAttr>();
3973 if (next.getTypePtr() == cur)
return false;
3974 cur = next.getTypePtr();
3979 if (
const auto *
typedefType = dyn_cast<TypedefType>(
this))
3980 return typedefType->getDecl()->hasAttr<ObjCIndependentClassAttr>();
3993 if (
const auto *OPT = getAs<PointerType>())
3994 return OPT->getPointeeType()->isObjCIndirectLifetimeType();
3995 if (
const auto *Ref = getAs<ReferenceType>())
3996 return Ref->getPointeeType()->isObjCIndirectLifetimeType();
3997 if (
const auto *MemPtr = getAs<MemberPointerType>())
3998 return MemPtr->getPointeeType()->isObjCIndirectLifetimeType();
4005 const Type *type =
this;
4007 type = array->getElementType().getTypePtr();
4019 const auto *
Pointer = getAs<PointerType>();
4030 if (
const auto *ptr = getAs<PointerType>())
4031 return ptr->getPointeeType()->hasSizedVLAType();
4032 if (
const auto *ref = getAs<ReferenceType>())
4033 return ref->getPointeeType()->hasSizedVLAType();
4035 if (isa<VariableArrayType>(arr) &&
4036 cast<VariableArrayType>(arr)->getSizeExpr())
4039 return arr->getElementType()->hasSizedVLAType();
4053 return DK_objc_strong_lifetime;
4055 return DK_objc_weak_lifetime;
4058 if (
const auto *RT =
4061 if (
const auto *CXXRD = dyn_cast<CXXRecordDecl>(RD)) {
4063 if (CXXRD->hasDefinition() && !CXXRD->hasTrivialDestructor())
4064 return DK_cxx_destructor;
4069 return DK_nontrivial_c_struct;
4081 llvm::APSInt Val,
unsigned Scale) {
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
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...
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
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.
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.
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...
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.
Optional< types::ID > 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 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
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.
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
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)
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.