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))
296 #define ABSTRACT_TYPE(Class, Parent) 297 #define TYPE(Class, Parent) \ 298 case Type::Class: { \ 299 const auto *ty = cast<Class##Type>(this); \ 300 if (!ty->isSugared()) return QualType(ty, 0); \ 301 return ty->desugar(); \ 303 #include "clang/AST/TypeNodes.def" 305 llvm_unreachable(
"bad type kind!");
315 #define ABSTRACT_TYPE(Class, Parent) 316 #define TYPE(Class, Parent) \ 317 case Type::Class: { \ 318 const auto *Ty = cast<Class##Type>(CurTy); \ 319 if (!Ty->isSugared()) \ 320 return SplitQualType(Ty, Qs); \ 321 Cur = Ty->desugar(); \ 324 #include "clang/AST/TypeNodes.def" 336 const Type *lastTypeWithQuals = split.
Ty;
344 #define ABSTRACT_TYPE(Class, Parent) 345 #define TYPE(Class, Parent) \ 346 case Type::Class: { \ 347 const auto *ty = cast<Class##Type>(split.Ty); \ 348 if (!ty->isSugared()) goto done; \ 349 next = ty->desugar(); \ 352 #include "clang/AST/TypeNodes.def" 357 split = next.
split();
359 lastTypeWithQuals = split.
Ty;
371 T = PT->getInnerType();
380 if (
const auto *Sugar = dyn_cast<T>(Cur))
383 #define ABSTRACT_TYPE(Class, Parent) 384 #define TYPE(Class, Parent) \ 385 case Type::Class: { \ 386 const auto *Ty = cast<Class##Type>(Cur); \ 387 if (!Ty->isSugared()) return 0; \ 388 Cur = Ty->desugar().getTypePtr(); \ 391 #include "clang/AST/TypeNodes.def" 397 return getAsSugar<TypedefType>(
this);
401 return getAsSugar<TemplateSpecializationType>(
this);
405 return getAsSugar<AttributedType>(
this);
412 const Type *Cur =
this;
416 #define ABSTRACT_TYPE(Class, Parent) 417 #define TYPE(Class, Parent) \ 419 const auto *Ty = cast<Class##Type>(Cur); \ 420 if (!Ty->isSugared()) return Cur; \ 421 Cur = Ty->desugar().getTypePtr(); \ 424 #include "clang/AST/TypeNodes.def" 430 if (
const auto *RT = getAs<RecordType>())
431 return RT->getDecl()->isClass();
436 if (
const auto *RT = getAs<RecordType>())
437 return RT->getDecl()->isStruct();
442 if (
const auto *RT = getAs<RecordType>())
443 return RT->getDecl()->hasAttr<ObjCBoxableAttr>();
448 if (
const auto *RT = getAs<RecordType>())
449 return RT->getDecl()->isInterface();
454 if (
const auto *RT = getAs<RecordType>()) {
462 if (
const auto *PT = getAs<PointerType>())
463 return PT->getPointeeType()->isVoidType();
468 if (
const auto *RT = getAs<RecordType>())
469 return RT->getDecl()->isUnion();
474 if (
const auto *CT = dyn_cast<ComplexType>(CanonicalType))
475 return CT->getElementType()->isFloatingType();
485 if (
const auto *ET = getAs<EnumType>())
486 return ET->getDecl()->isScoped();
491 if (
const auto *
Complex = getAs<ComplexType>())
492 if (
Complex->getElementType()->isIntegerType())
498 if (
const auto *PT = getAs<PointerType>())
500 if (
const auto *OPT = getAs<ObjCObjectPointerType>())
502 if (
const auto *BPT = getAs<BlockPointerType>())
504 if (
const auto *RT = getAs<ReferenceType>())
506 if (
const auto *MPT = getAs<MemberPointerType>())
508 if (
const auto *DT = getAs<DecayedType>())
515 if (
const auto *RT = dyn_cast<RecordType>(
this)) {
516 if (RT->getDecl()->isStruct())
521 if (
const auto *RT = dyn_cast<RecordType>(CanonicalType)) {
522 if (!RT->getDecl()->isStruct())
534 if (
const auto *RT = dyn_cast<RecordType>(
this)) {
535 if (RT->getDecl()->isUnion())
540 if (
const auto *RT = dyn_cast<RecordType>(CanonicalType)) {
541 if (!RT->getDecl()->isUnion())
556 const auto *OPT = getAs<ObjCObjectPointerType>();
561 if (OPT->isObjCIdType())
565 if (!OPT->isKindOfType())
569 if (OPT->isObjCClassType() || OPT->isObjCQualifiedClassType())
579 const auto *OPT = getAs<ObjCObjectPointerType>();
584 if (OPT->isObjCClassType())
588 if (!OPT->isKindOfType())
592 return OPT->isObjCClassType() || OPT->isObjCQualifiedClassType();
602 const Type *cur =
this;
604 if (
const auto attributed = dyn_cast<AttributedType>(cur)) {
605 if (attributed->getAttrKind() ==
624 OTPDecl(const_cast<ObjCTypeParamDecl*>(D)) {
641 "bitfield overflow in type argument count");
642 if (!typeArgs.empty())
643 memcpy(getTypeArgStorage(), typeArgs.data(),
644 typeArgs.size() *
sizeof(
QualType));
646 for (
auto typeArg : typeArgs) {
647 if (typeArg->isDependentType())
649 else if (typeArg->isInstantiationDependentType())
652 if (typeArg->containsUnexpandedParameterPack())
666 if (
const auto objcObject =
getBaseType()->getAs<ObjCObjectType>()) {
668 if (isa<ObjCInterfaceType>(objcObject))
671 return objcObject->isSpecialized();
684 if (
const auto objcObject =
getBaseType()->getAs<ObjCObjectType>()) {
686 if (isa<ObjCInterfaceType>(objcObject))
689 return objcObject->getTypeArgs();
701 if (
const auto objcObject =
getBaseType()->getAs<ObjCObjectType>()) {
703 if (isa<ObjCInterfaceType>(objcObject))
706 return objcObject->isKindOfType();
722 baseType = baseObj->stripObjCKindOfTypeAndQuals(ctx);
725 splitBaseType.
Quals),
747 struct SimpleTransformVisitor
748 :
public TypeVisitor<SimpleTransformVisitor<F>, QualType> {
757 SimpleTransformVisitor(
ASTContext &ctx, F &&f)
758 : Ctx(ctx), TheFunc(std::move(f)) {}
762 #define TYPE(Class, Base) 763 #define DEPENDENT_TYPE(Class, Base) \ 764 QualType Visit##Class##Type(const Class##Type *T) { return QualType(T, 0); } 765 #include "clang/AST/TypeNodes.def" 767 #define TRIVIAL_TYPE_CLASS(Class) \ 768 QualType Visit##Class##Type(const Class##Type *T) { return QualType(T, 0); } 920 bool paramChanged =
false;
922 QualType newParamType = recurse(paramType);
923 if (newParamType.
isNull())
929 paramTypes.push_back(newParamType);
934 bool exceptionChanged =
false;
938 QualType newExceptionType = recurse(exceptionType);
939 if (newExceptionType.
isNull())
942 if (newExceptionType.
getAsOpaquePtr() != exceptionType.getAsOpaquePtr())
943 exceptionChanged =
true;
945 exceptionTypes.push_back(newExceptionType);
948 if (exceptionChanged) {
950 llvm::makeArrayRef(exceptionTypes).copy(Ctx);
955 !paramChanged && !exceptionChanged)
977 if (originalType.
isNull())
981 if (adjustedType.
isNull())
994 if (originalType.
isNull())
1016 if (modifiedType.
isNull())
1020 if (equivalentType.
isNull())
1035 if (replacementType.
isNull())
1054 if (deducedType.
isNull())
1074 bool typeArgChanged =
false;
1077 QualType newTypeArg = recurse(typeArg);
1082 typeArgChanged =
true;
1084 typeArgs.push_back(newTypeArg);
1101 if (pointeeType.
isNull())
1123 #undef TRIVIAL_TYPE_CLASS 1130 template<
typename F>
1141 SimpleTransformVisitor<F> visitor(ctx, std::forward<F>(f));
1142 QualType result = visitor.Visit(splitType.
Ty);
1163 if (
const auto *OTPTy = dyn_cast<ObjCTypeParamType>(splitType.
Ty)) {
1166 if (!typeArgs.empty()) {
1168 if (OTPTy->qual_empty())
1174 protocolsVec.append(OTPTy->qual_begin(),
1178 protocolsToApply, hasError,
true);
1199 if (objPtr->isKindOfType() || objPtr->isObjCIdOrClassType())
1204 const auto *obj = objPtr->getObjectType();
1206 obj->getTypeArgsAsWritten(),
1207 obj->getProtocols(),
1218 if (
const auto *funcType = dyn_cast<FunctionType>(splitType.
Ty)) {
1220 QualType returnType = funcType->getReturnType().substObjCTypeArgs(
1229 if (isa<FunctionNoProtoType>(funcType)) {
1232 == funcType->getReturnType().getAsOpaquePtr())
1239 const auto *funcProtoType = cast<FunctionProtoType>(funcType);
1243 bool paramChanged =
false;
1244 for (
auto paramType : funcProtoType->getParamTypes()) {
1249 if (newParamType.
isNull())
1253 paramChanged =
true;
1255 paramTypes.push_back(newParamType);
1260 bool exceptionChanged =
false;
1268 if (newExceptionType.
isNull())
1272 != exceptionType.getAsOpaquePtr())
1273 exceptionChanged =
true;
1275 exceptionTypes.push_back(newExceptionType);
1278 if (exceptionChanged) {
1280 llvm::makeArrayRef(exceptionTypes).copy(ctx);
1285 == funcProtoType->getReturnType().getAsOpaquePtr() &&
1286 !paramChanged && !exceptionChanged)
1294 if (
const auto *objcObjectType = dyn_cast<ObjCObjectType>(splitType.
Ty)) {
1295 if (objcObjectType->isSpecializedAsWritten()) {
1297 bool anyChanged =
false;
1298 for (
auto typeArg : objcObjectType->getTypeArgsAsWritten()) {
1309 objcObjectType->qual_begin(),
1310 objcObjectType->getNumProtocols());
1311 if (typeArgs.empty() &&
1314 objcObjectType->getBaseType(), {},
1316 objcObjectType->isKindOfTypeAsWritten());
1322 newTypeArgs.push_back(newTypeArg);
1327 objcObjectType->qual_begin(),
1328 objcObjectType->getNumProtocols());
1330 newTypeArgs, protocols,
1331 objcObjectType->isKindOfTypeAsWritten());
1353 auto &ctx =
const_cast<ASTContext &
>(constCtx);
1358 if (!objType->isKindOfType())
1362 = objType->getBaseType().stripObjCKindOfType(ctx);
1365 objType->getTypeArgsAsWritten(),
1366 objType->getProtocols(),
1376 if (
const auto AT = getTypePtr()->getAs<AtomicType>())
1377 return AT->getValueType().getUnqualifiedType();
1378 return getUnqualifiedType();
1384 if (
const auto method = dyn_cast<ObjCMethodDecl>(dc))
1385 dc = method->getDeclContext();
1395 dcTypeParams = dcClassDecl->getTypeParamList();
1402 if (!dcCategoryDecl)
1407 dcTypeParams = dcCategoryDecl->getTypeParamList();
1411 dcClassDecl = dcCategoryDecl->getClassInterface();
1415 assert(dcTypeParams &&
"No substitutions to perform");
1416 assert(dcClassDecl &&
"No class context");
1420 if (
const auto *objectPointerType = getAs<ObjCObjectPointerType>()) {
1421 objectType = objectPointerType->getObjectType();
1422 }
else if (getAs<BlockPointerType>()) {
1427 objectType = getAs<ObjCObjectType>();
1433 if (!curClassDecl) {
1441 while (curClassDecl != dcClassDecl) {
1444 if (superType.
isNull()) {
1445 objectType =
nullptr;
1465 if (
auto *
ID = IfaceT->getInterface()) {
1466 if (
ID->getTypeParamList())
1480 CachedSuperClassType.setInt(
true);
1486 if (!superClassObjTy) {
1487 CachedSuperClassType.setInt(
true);
1492 if (!superClassDecl) {
1493 CachedSuperClassType.setInt(
true);
1499 QualType superClassType(superClassObjTy, 0);
1501 if (!superClassTypeParams) {
1502 CachedSuperClassType.setPointerAndInt(
1509 CachedSuperClassType.setPointerAndInt(superClassObjTy,
true);
1517 CachedSuperClassType.setPointerAndInt(
1528 CachedSuperClassType.setPointerAndInt(
1536 assert(typeArgs.size() == typeParams->
size());
1537 CachedSuperClassType.setPointerAndInt(
1540 ->castAs<ObjCObjectType>(),
1546 return interfaceDecl->getASTContext().getObjCInterfaceType(interfaceDecl)
1555 if (superObjectType.
isNull())
1556 return superObjectType;
1558 ASTContext &ctx = getInterfaceDecl()->getASTContext();
1566 if (
const auto *T = getAs<ObjCObjectType>())
1567 if (T->getNumProtocols() && T->getInterface())
1579 if (
const auto *OPT = getAs<ObjCObjectPointerType>()) {
1580 if (OPT->isObjCQualifiedIdType())
1589 if (
const auto *OPT = getAs<ObjCObjectPointerType>()) {
1590 if (OPT->isObjCQualifiedClassType())
1597 if (
const auto *OT = getAs<ObjCObjectType>()) {
1598 if (OT->getInterface())
1605 if (
const auto *OPT = getAs<ObjCObjectPointerType>()) {
1606 if (OPT->getInterfaceType())
1614 if (
const auto *PT = getAs<PointerType>())
1616 else if (
const auto *RT = getAs<ReferenceType>())
1628 return dyn_cast_or_null<CXXRecordDecl>(
getAsTagDecl());
1636 if (
const auto *TT = getAs<TagType>())
1637 return TT->getDecl();
1638 if (
const auto *Injected = getAs<InjectedClassNameType>())
1639 return Injected->getDecl();
1646 class GetContainedDeducedTypeVisitor :
1647 public TypeVisitor<GetContainedDeducedTypeVisitor, Type*> {
1651 GetContainedDeducedTypeVisitor(
bool Syntactic =
false)
1652 : Syntactic(Syntactic) {}
1693 Type *VisitDependentSizedExtVectorType(
1704 return const_cast<FunctionProtoType*>(T);
1705 return VisitFunctionType(T);
1728 return cast_or_null<DeducedType>(
1729 GetContainedDeducedTypeVisitor().Visit(
this));
1733 return dyn_cast_or_null<FunctionType>(
1734 GetContainedDeducedTypeVisitor(
true).Visit(
this));
1738 if (
const auto *VT = dyn_cast<VectorType>(CanonicalType))
1739 return VT->getElementType()->isIntegerType();
1764 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
1765 return BT->getKind() >= BuiltinType::Bool &&
1766 BT->getKind() <= BuiltinType::Int128;
1770 if (
const auto *ET = dyn_cast<EnumType>(CanonicalType))
1771 return ET->getDecl()->isComplete();
1777 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
1778 return BT->getKind() >= BuiltinType::Bool &&
1779 BT->getKind() <= BuiltinType::Int128;
1785 if (
const auto *ET = dyn_cast<EnumType>(CanonicalType))
1786 return ET->getDecl()->isComplete() && !ET->getDecl()->isScoped();
1792 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
1793 return BT->getKind() == BuiltinType::Char_U ||
1794 BT->getKind() == BuiltinType::UChar ||
1795 BT->getKind() == BuiltinType::Char_S ||
1796 BT->getKind() == BuiltinType::SChar;
1801 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
1802 return BT->getKind() == BuiltinType::WChar_S ||
1803 BT->getKind() == BuiltinType::WChar_U;
1808 if (
const BuiltinType *BT = dyn_cast<BuiltinType>(CanonicalType))
1809 return BT->getKind() == BuiltinType::Char8;
1814 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
1815 return BT->getKind() == BuiltinType::Char16;
1820 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
1821 return BT->getKind() == BuiltinType::Char32;
1828 const auto *BT = dyn_cast<
BuiltinType>(CanonicalType);
1829 if (!BT)
return false;
1830 switch (BT->getKind()) {
1831 default:
return false;
1832 case BuiltinType::Char_U:
1833 case BuiltinType::UChar:
1834 case BuiltinType::WChar_U:
1835 case BuiltinType::Char8:
1836 case BuiltinType::Char16:
1837 case BuiltinType::Char32:
1838 case BuiltinType::Char_S:
1839 case BuiltinType::SChar:
1840 case BuiltinType::WChar_S:
1849 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType)) {
1850 return BT->getKind() >= BuiltinType::Char_S &&
1851 BT->getKind() <= BuiltinType::Int128;
1854 if (
const EnumType *ET = dyn_cast<EnumType>(CanonicalType)) {
1857 if (ET->getDecl()->isComplete() && !ET->getDecl()->isScoped())
1858 return ET->getDecl()->getIntegerType()->isSignedIntegerType();
1865 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType)) {
1866 return BT->getKind() >= BuiltinType::Char_S &&
1867 BT->getKind() <= BuiltinType::Int128;
1870 if (
const auto *ET = dyn_cast<EnumType>(CanonicalType)) {
1871 if (ET->getDecl()->isComplete())
1872 return ET->getDecl()->getIntegerType()->isSignedIntegerType();
1879 if (
const auto *VT = dyn_cast<VectorType>(CanonicalType))
1880 return VT->getElementType()->isSignedIntegerOrEnumerationType();
1889 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType)) {
1890 return BT->getKind() >= BuiltinType::Bool &&
1891 BT->getKind() <= BuiltinType::UInt128;
1894 if (
const auto *ET = dyn_cast<EnumType>(CanonicalType)) {
1897 if (ET->getDecl()->isComplete() && !ET->getDecl()->isScoped())
1898 return ET->getDecl()->getIntegerType()->isUnsignedIntegerType();
1905 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType)) {
1906 return BT->getKind() >= BuiltinType::Bool &&
1907 BT->getKind() <= BuiltinType::UInt128;
1910 if (
const auto *ET = dyn_cast<EnumType>(CanonicalType)) {
1911 if (ET->getDecl()->isComplete())
1912 return ET->getDecl()->getIntegerType()->isUnsignedIntegerType();
1919 if (
const auto *VT = dyn_cast<VectorType>(CanonicalType))
1920 return VT->getElementType()->isUnsignedIntegerOrEnumerationType();
1926 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
1927 return BT->getKind() >= BuiltinType::Half &&
1928 BT->getKind() <= BuiltinType::Float128;
1929 if (
const auto *CT = dyn_cast<ComplexType>(CanonicalType))
1930 return CT->getElementType()->isFloatingType();
1935 if (
const auto *VT = dyn_cast<VectorType>(CanonicalType))
1936 return VT->getElementType()->isFloatingType();
1942 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
1943 return BT->isFloatingPoint();
1948 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
1949 return BT->getKind() >= BuiltinType::Bool &&
1950 BT->getKind() <= BuiltinType::Float128;
1951 if (
const auto *ET = dyn_cast<EnumType>(CanonicalType))
1952 return ET->getDecl()->isComplete() && !ET->getDecl()->isScoped();
1957 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
1958 return BT->getKind() >= BuiltinType::Bool &&
1959 BT->getKind() <= BuiltinType::Float128;
1960 if (
const auto *ET = dyn_cast<EnumType>(CanonicalType))
1967 return !ET->getDecl()->isScoped() && ET->getDecl()->isComplete();
1968 return isa<ComplexType>(CanonicalType);
1975 if (
const auto *BT = dyn_cast<BuiltinType>(T)) {
1976 if (BT->getKind() == BuiltinType::Bool)
return STK_Bool;
1977 if (BT->getKind() == BuiltinType::NullPtr)
return STK_CPointer;
1980 llvm_unreachable(
"unknown scalar builtin type");
1981 }
else if (isa<PointerType>(T)) {
1983 }
else if (isa<BlockPointerType>(T)) {
1985 }
else if (isa<ObjCObjectPointerType>(T)) {
1987 }
else if (isa<MemberPointerType>(T)) {
1989 }
else if (isa<EnumType>(T)) {
1990 assert(cast<EnumType>(T)->getDecl()->isComplete());
1992 }
else if (
const auto *CT = dyn_cast<ComplexType>(T)) {
1993 if (CT->getElementType()->isRealFloatingType())
1998 llvm_unreachable(
"unknown scalar type");
2011 if (
const auto *Record = dyn_cast<RecordType>(CanonicalType)) {
2012 if (
const auto *ClassDecl = dyn_cast<CXXRecordDecl>(Record->getDecl()))
2013 return ClassDecl->isAggregate();
2018 return isa<ArrayType>(CanonicalType);
2025 assert(!
isIncompleteType() &&
"This doesn't make sense for incomplete types");
2026 assert(!
isDependentType() &&
"This doesn't make sense for dependent types");
2028 return !isa<VariableArrayType>(CanonicalType);
2038 switch (CanonicalType->getTypeClass()) {
2039 default:
return false;
2045 EnumDecl *EnumD = cast<EnumType>(CanonicalType)->getDecl();
2053 RecordDecl *Rec = cast<RecordType>(CanonicalType)->getDecl();
2063 return cast<ArrayType>(CanonicalType)->getElementType()
2064 ->isIncompleteType(Def);
2065 case IncompleteArray:
2068 case MemberPointer: {
2072 auto *MPTy = cast<MemberPointerType>(CanonicalType);
2073 const Type *ClassTy = MPTy->getClass();
2075 if (ClassTy->isDependentType())
2086 if (RD->
hasAttr<MSInheritanceAttr>())
2091 return cast<ObjCObjectType>(CanonicalType)->
getBaseType()
2093 case ObjCInterface: {
2096 = cast<ObjCInterfaceType>(CanonicalType)->getDecl();
2107 return isCXX11PODType(Context);
2109 return isCXX98PODType(Context);
2119 if ((*this)->isIncompleteArrayType())
2122 if ((*this)->isIncompleteType())
2125 if (hasNonTrivialObjCLifetime())
2128 QualType CanonicalType = getTypePtr()->CanonicalType;
2131 default:
return false;
2132 case Type::VariableArray:
2133 case Type::ConstantArray:
2137 case Type::ObjCObjectPointer:
2138 case Type::BlockPointer:
2142 case Type::MemberPointer:
2144 case Type::ExtVector:
2151 if (
const auto *ClassDecl =
2152 dyn_cast<CXXRecordDecl>(cast<RecordType>(CanonicalType)->getDecl()))
2153 return ClassDecl->isPOD();
2167 if ((*this)->isArrayType())
2172 if ((*this)->isIncompleteType())
2175 if (hasNonTrivialObjCLifetime())
2178 QualType CanonicalType = getTypePtr()->CanonicalType;
2191 if (
const auto *ClassDecl = dyn_cast<CXXRecordDecl>(RT->getDecl())) {
2196 return ClassDecl->hasDefaultConstructor() &&
2197 !ClassDecl->hasNonTrivialDefaultConstructor() &&
2198 ClassDecl->isTriviallyCopyable();
2209 if ((*this)->isArrayType())
2212 if (hasNonTrivialObjCLifetime())
2220 QualType CanonicalType = getCanonicalType();
2234 if (
const auto *ClassDecl = dyn_cast<CXXRecordDecl>(RT->getDecl())) {
2235 if (!ClassDecl->isTriviallyCopyable())
return false;
2253 if (
const auto *RT =
2255 if (RT->getDecl()->isNonTrivialToPrimitiveDefaultInitialize())
2258 switch (getQualifiers().getObjCLifetime()) {
2260 return PDIK_ARCStrong;
2262 return PDIK_ARCWeak;
2264 return PDIK_Trivial;
2269 if (
const auto *RT =
2271 if (RT->getDecl()->isNonTrivialToPrimitiveCopy())
2277 return PCK_ARCStrong;
2281 return Qs.
hasVolatile() ? PCK_VolatileTrivial : PCK_Trivial;
2287 return isNonTrivialToPrimitiveCopy();
2307 assert(BaseTy &&
"NULL element type");
2337 if (
const auto *ClassDecl = dyn_cast<CXXRecordDecl>(RT->getDecl()))
2338 return ClassDecl->isLiteral();
2345 return AT->getValueType()->isLiteralType(Ctx);
2364 assert(BaseTy &&
"NULL element type");
2374 if (
const auto *ClassDecl = dyn_cast<CXXRecordDecl>(RT->getDecl()))
2375 if (!ClassDecl->isStandardLayout())
2392 const Type *ty = getTypePtr();
2396 if (hasNonTrivialObjCLifetime())
2403 assert(BaseTy &&
"NULL element type");
2413 if (
const auto *ClassDecl = dyn_cast<CXXRecordDecl>(RT->getDecl())) {
2416 if (!ClassDecl->isTrivial())
return false;
2421 if (!ClassDecl->isStandardLayout())
return false;
2441 if (
const auto *ET = getAs<EnumType>()) {
2443 if (II && II->
isStr(
"align_val_t") && ET->getDecl()->isInStdNamespace())
2450 if (
const auto *ET = getAs<EnumType>()) {
2452 if (II && II->
isStr(
"byte") && ET->getDecl()->isInStdNamespace())
2459 if (
const auto *BT = getAs<BuiltinType>())
2460 switch (BT->getKind()) {
2461 case BuiltinType::Bool:
2462 case BuiltinType::Char_S:
2463 case BuiltinType::Char_U:
2464 case BuiltinType::SChar:
2465 case BuiltinType::UChar:
2466 case BuiltinType::Short:
2467 case BuiltinType::UShort:
2468 case BuiltinType::WChar_S:
2469 case BuiltinType::WChar_U:
2470 case BuiltinType::Char8:
2471 case BuiltinType::Char16:
2472 case BuiltinType::Char32:
2480 if (
const auto *ET = getAs<EnumType>()){
2481 if (this->
isDependentType() || ET->getDecl()->getPromotionType().isNull()
2482 || ET->getDecl()->isScoped())
2501 case TemplateTypeParm:
2502 case SubstTemplateTypeParm:
2503 case TemplateSpecialization:
2506 case DependentTemplateSpecialization:
2509 case ObjCObjectPointer:
2539 llvm_unreachable(
"Type specifier is not a tag type kind.");
2551 llvm_unreachable(
"Unknown tag type kind.");
2564 llvm_unreachable(
"Elaborated type keyword is not a tag type kind.");
2566 llvm_unreachable(
"Unknown elaborated type keyword.");
2582 llvm_unreachable(
"Unknown elaborated type keyword.");
2596 llvm_unreachable(
"Unknown elaborated type keyword.");
2599 DependentTemplateSpecializationType::DependentTemplateSpecializationType(
2604 :
TypeWithKeyword(Keyword, DependentTemplateSpecialization, Canon,
true,
true,
2607 NNS(NNS), Name(Name), NumArgs(Args.size()) {
2609 "DependentTemplateSpecializatonType requires dependent qualifier");
2612 if (Arg.containsUnexpandedParameterPack())
2626 ID.AddInteger(Keyword);
2627 ID.AddPointer(Qualifier);
2628 ID.AddPointer(Name);
2630 Arg.Profile(ID, Context);
2635 if (
const auto *Elab = dyn_cast<ElaboratedType>(
this))
2636 Keyword = Elab->getKeyword();
2637 else if (
const auto *DepName = dyn_cast<DependentNameType>(
this))
2638 Keyword = DepName->getKeyword();
2639 else if (
const auto *DepTST =
2640 dyn_cast<DependentTemplateSpecializationType>(
this))
2641 Keyword = DepTST->getKeyword();
2650 #define ABSTRACT_TYPE(Derived, Base) 2651 #define TYPE(Derived, Base) case Derived: return #Derived; 2652 #include "clang/AST/TypeNodes.def" 2655 llvm_unreachable(
"Invalid type class.");
2663 return Policy.
Bool ?
"bool" :
"_Bool";
2669 return "signed char";
2681 return "unsigned char";
2683 return "unsigned short";
2685 return "unsigned int";
2687 return "unsigned long";
2689 return "unsigned long long";
2691 return "unsigned __int128";
2693 return Policy.
Half ?
"half" :
"__fp16";
2699 return "long double";
2701 return "short _Accum";
2705 return "long _Accum";
2707 return "unsigned short _Accum";
2709 return "unsigned _Accum";
2711 return "unsigned long _Accum";
2712 case BuiltinType::ShortFract:
2713 return "short _Fract";
2714 case BuiltinType::Fract:
2716 case BuiltinType::LongFract:
2717 return "long _Fract";
2718 case BuiltinType::UShortFract:
2719 return "unsigned short _Fract";
2720 case BuiltinType::UFract:
2721 return "unsigned _Fract";
2722 case BuiltinType::ULongFract:
2723 return "unsigned long _Fract";
2724 case BuiltinType::SatShortAccum:
2725 return "_Sat short _Accum";
2726 case BuiltinType::SatAccum:
2727 return "_Sat _Accum";
2728 case BuiltinType::SatLongAccum:
2729 return "_Sat long _Accum";
2730 case BuiltinType::SatUShortAccum:
2731 return "_Sat unsigned short _Accum";
2732 case BuiltinType::SatUAccum:
2733 return "_Sat unsigned _Accum";
2734 case BuiltinType::SatULongAccum:
2735 return "_Sat unsigned long _Accum";
2736 case BuiltinType::SatShortFract:
2737 return "_Sat short _Fract";
2738 case BuiltinType::SatFract:
2739 return "_Sat _Fract";
2740 case BuiltinType::SatLongFract:
2741 return "_Sat long _Fract";
2742 case BuiltinType::SatUShortFract:
2743 return "_Sat unsigned short _Fract";
2744 case BuiltinType::SatUFract:
2745 return "_Sat unsigned _Fract";
2746 case BuiltinType::SatULongFract:
2747 return "_Sat unsigned long _Fract";
2751 return "__float128";
2754 return Policy.
MSWChar ?
"__wchar_t" :
"wchar_t";
2764 return "<overloaded function type>";
2766 return "<bound member function type>";
2768 return "<pseudo-object type>";
2770 return "<dependent type>";
2772 return "<unknown type>";
2773 case ARCUnbridgedCast:
2774 return "<ARC unbridged cast type>";
2776 return "<builtin fn type>";
2783 #define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \ 2785 return "__" #Access " " #ImgType "_t"; 2786 #include "clang/Basic/OpenCLImageTypes.def" 2792 return "clk_event_t";
2796 return "reserve_id_t";
2797 case OMPArraySection:
2798 return "<OpenMP array section type>";
2801 llvm_unreachable(
"Invalid builtin type.");
2805 if (
const auto *RefType = getTypePtr()->getAs<ReferenceType>())
2814 (!getTypePtr()->isDependentType() && !getTypePtr()->isRecordType()))
2815 return getUnqualifiedType();
2822 case CC_C:
return "cdecl";
2841 llvm_unreachable(
"Invalid calling convention.");
2846 const ExtProtoInfo &epi)
2852 NumParams(params.size()),
2853 NumExceptions(epi.ExceptionSpec.Exceptions.size()),
2854 ExceptionSpecType(epi.ExceptionSpec.Type),
2855 HasExtParameterInfos(epi.ExtParameterInfos !=
nullptr),
2856 Variadic(epi.Variadic), HasTrailingReturn(epi.HasTrailingReturn) {
2857 assert(NumParams == params.size() &&
"function has too many parameters");
2863 auto *argSlot =
reinterpret_cast<QualType *
>(
this+1);
2864 for (
unsigned i = 0; i != NumParams; ++i) {
2873 argSlot[i] = params[i];
2878 QualType *exnSlot = argSlot + NumParams;
2880 for (
QualType ExceptionType : epi.ExceptionSpec.Exceptions) {
2890 exnSlot[I++] = ExceptionType;
2893 assert(epi.ExceptionSpec.NoexceptExpr &&
"computed noexcept with no expr");
2895 epi.ExceptionSpec.NoexceptExpr->isValueDependent());
2898 auto **noexSlot =
reinterpret_cast<Expr **
>(argSlot + NumParams);
2899 *noexSlot = epi.ExceptionSpec.NoexceptExpr;
2901 if (epi.ExceptionSpec.NoexceptExpr->isValueDependent() ||
2902 epi.ExceptionSpec.NoexceptExpr->isInstantiationDependent())
2905 if (epi.ExceptionSpec.NoexceptExpr->containsUnexpandedParameterPack())
2910 auto **slot =
reinterpret_cast<FunctionDecl **
>(argSlot + NumParams);
2911 slot[0] = epi.ExceptionSpec.SourceDecl;
2912 slot[1] = epi.ExceptionSpec.SourceTemplate;
2918 auto **slot =
reinterpret_cast<FunctionDecl **
>(argSlot + NumParams);
2919 slot[0] = epi.ExceptionSpec.SourceDecl;
2927 assert(hasDependentExceptionSpec() &&
"type should not be canonical");
2935 if (epi.ExtParameterInfos) {
2936 auto *extParamInfos =
2937 const_cast<ExtParameterInfo *
>(getExtParameterInfosBuffer());
2938 for (
unsigned i = 0; i != NumParams; ++i)
2939 extParamInfos[i] = epi.ExtParameterInfos[i];
2944 if (
Expr *NE = getNoexceptExpr())
2945 return NE->isValueDependent();
2956 if (
Expr *NE = getNoexceptExpr())
2957 return NE->isInstantiationDependent();
2959 if (ET->isInstantiationDependentType())
2965 switch (getExceptionSpecType()) {
2969 llvm_unreachable(
"should not call this with unresolved exception specs");
2984 for (
unsigned I = 0, N = NumExceptions; I != N; ++I)
2985 if (!getExceptionType(I)->getAs<PackExpansionType>())
2993 llvm_unreachable(
"unexpected exception specification kind");
2997 for (
unsigned ArgIdx = getNumParams(); ArgIdx; --ArgIdx)
3005 const QualType *ArgTys,
unsigned NumParams,
3026 for (
unsigned i = 0; i != NumParams; ++i)
3031 assert(!(
unsigned(epi.
Variadic) & ~1) &&
3035 "Values larger than expected.");
3050 for (
unsigned i = 0; i != NumParams; ++i)
3059 Profile(ID, getReturnType(), param_type_begin(), NumParams, getExtProtoInfo(),
3064 return getDecl()->getUnderlyingType();
3068 :
Type(TypeOfExpr, can, E->isTypeDependent(),
3069 E->isInstantiationDependent(),
3087 E->
Profile(ID, Context,
true);
3094 :
Type(Decltype, can, E->isInstantiationDependent(),
3095 E->isInstantiationDependent(),
3098 E(E), UnderlyingType(underlyingType) {}
3110 :
DecltypeType(E, Context.DependentTy), Context(Context) {}
3114 E->
Profile(ID, Context,
true);
3125 BaseType(BaseType), UnderlyingType(UnderlyingType), UKind(UKind) {}
3140 for (
auto I : decl->
redecls()) {
3141 if (I->isCompleteDefinition() || I->isBeingDefined())
3163 if (FieldRecTy->hasConstFields())
3170 switch (getAttrKind()) {
3215 llvm_unreachable(
"bad attributed type kind");
3219 switch (getAttrKind()) {
3220 default:
return false;
3227 llvm_unreachable(
"invalid attr kind");
3231 switch (getAttrKind()) {
3236 case attr_address_space:
3238 case attr_vector_size:
3239 case attr_neon_vector_type:
3240 case attr_neon_polyvector_type:
3242 case attr_objc_ownership:
3243 case attr_objc_inert_unsafe_unretained:
3246 case attr_ns_returns_retained:
3248 case attr_null_unspecified:
3249 case attr_objc_kindof:
3250 case attr_nocf_check:
3251 case attr_lifetimebound:
3261 case attr_swiftcall:
3262 case attr_vectorcall:
3266 case attr_inteloclbicc:
3267 case attr_preserve_most:
3268 case attr_preserve_all:
3271 llvm_unreachable(
"invalid attr kind");
3282 SubstTemplateTypeParmPackType::
3286 :
Type(SubstTemplateTypeParmPack, Canon,
true,
true,
false,
true),
3295 Profile(ID, getReplacedParameter(), getArgumentPack());
3301 ID.AddPointer(Replaced);
3304 ID.AddPointer(
P.getAsType().getAsOpaquePtr());
3309 bool &InstantiationDependent) {
3310 return anyDependentTemplateArguments(Args.
arguments(),
3311 InstantiationDependent);
3316 bool &InstantiationDependent) {
3318 if (ArgLoc.getArgument().isDependent()) {
3319 InstantiationDependent =
true;
3323 if (ArgLoc.getArgument().isInstantiationDependent())
3324 InstantiationDependent =
true;
3329 TemplateSpecializationType::
3333 :
Type(TemplateSpecialization,
3339 Template(T), NumArgs(Args.size()), TypeAlias(!AliasedType.
isNull()) {
3341 "Use DependentTemplateSpecializationType for dependent template-name");
3345 "Unexpected template name for TemplateSpecializationType");
3357 if (Arg.isInstantiationDependent())
3360 Arg.getAsType()->isVariablyModifiedType())
3362 if (Arg.containsUnexpandedParameterPack())
3370 *
reinterpret_cast<QualType*
>(
Begin + getNumArgs()) = AliasedType;
3381 Arg.Profile(ID, Context);
3386 if (!hasNonFastQualifiers())
3394 if (!hasNonFastQualifiers())
3395 return QualType(T, getFastQualifiers());
3406 ID.AddInteger(typeArgs.size());
3407 for (
auto typeArg : typeArgs)
3408 ID.AddPointer(typeArg.getAsOpaquePtr());
3409 ID.AddInteger(protocols.size());
3410 for (
auto proto : protocols)
3411 ID.AddPointer(proto);
3412 ID.AddBoolean(isKindOf);
3416 Profile(ID, getBaseType(), getTypeArgsAsWritten(),
3417 llvm::makeArrayRef(qual_begin(), getNumProtocols()),
3418 isKindOfTypeAsWritten());
3424 ID.AddPointer(OTPDecl);
3425 ID.AddInteger(protocols.size());
3426 for (
auto proto : protocols)
3427 ID.AddPointer(proto);
3432 llvm::makeArrayRef(qual_begin(), getNumProtocols()));
3438 class CachedProperties {
3443 CachedProperties(
Linkage L,
bool local) : L(L), local(local) {}
3446 bool hasLocalOrUnnamedType()
const {
return local; }
3448 friend CachedProperties merge(CachedProperties L, CachedProperties R) {
3450 return CachedProperties(MergedLinkage,
3451 L.hasLocalOrUnnamedType() | R.hasLocalOrUnnamedType());
3467 return get(T.getTypePtr());
3470 static CachedProperties
get(
const Type *T) {
3472 return CachedProperties(T->
TypeBits.getLinkage(),
3473 T->
TypeBits.hasLocalOrUnnamedType());
3478 if (T->
TypeBits.isCacheValid())
return;
3494 T->
TypeBits.CachedLinkage = Result.getLinkage();
3495 T->
TypeBits.CachedLocalOrUnnamed = Result.hasLocalOrUnnamedType();
3514 #define TYPE(Class,Base) 3515 #define NON_CANONICAL_TYPE(Class,Base) case Type::Class: 3516 #include "clang/AST/TypeNodes.def" 3517 llvm_unreachable(
"didn't expect a non-canonical type here");
3519 #define TYPE(Class,Base) 3520 #define DEPENDENT_TYPE(Class,Base) case Type::Class: 3521 #define NON_CANONICAL_UNLESS_DEPENDENT_TYPE(Class,Base) case Type::Class: 3522 #include "clang/AST/TypeNodes.def" 3528 case Type::DeducedTemplateSpecialization:
3548 bool IsLocalOrUnnamed =
3551 return CachedProperties(L, IsLocalOrUnnamed);
3558 return Cache::get(cast<ComplexType>(T)->getElementType());
3561 case Type::BlockPointer:
3563 case Type::LValueReference:
3564 case Type::RValueReference:
3566 case Type::MemberPointer: {
3567 const auto *MPT = cast<MemberPointerType>(T);
3571 case Type::ConstantArray:
3572 case Type::IncompleteArray:
3573 case Type::VariableArray:
3574 return Cache::get(cast<ArrayType>(T)->getElementType());
3576 case Type::ExtVector:
3577 return Cache::get(cast<VectorType>(T)->getElementType());
3578 case Type::FunctionNoProto:
3579 return Cache::get(cast<FunctionType>(T)->getReturnType());
3580 case Type::FunctionProto: {
3581 const auto *FPT = cast<FunctionProtoType>(T);
3582 CachedProperties result =
Cache::get(FPT->getReturnType());
3583 for (
const auto &ai : FPT->param_types())
3587 case Type::ObjCInterface: {
3589 return CachedProperties(L,
false);
3591 case Type::ObjCObject:
3592 return Cache::get(cast<ObjCObjectType>(T)->getBaseType());
3593 case Type::ObjCObjectPointer:
3596 return Cache::get(cast<AtomicType>(T)->getValueType());
3598 return Cache::get(cast<PipeType>(T)->getElementType());
3601 llvm_unreachable(
"unhandled type class");
3612 return TypeBits.hasLocalOrUnnamedType();
3617 #define TYPE(Class,Base) 3618 #define NON_CANONICAL_TYPE(Class,Base) case Type::Class: 3619 #include "clang/AST/TypeNodes.def" 3620 llvm_unreachable(
"didn't expect a non-canonical type here");
3622 #define TYPE(Class,Base) 3623 #define DEPENDENT_TYPE(Class,Base) case Type::Class: 3624 #define NON_CANONICAL_UNLESS_DEPENDENT_TYPE(Class,Base) case Type::Class: 3625 #include "clang/AST/TypeNodes.def" 3634 case Type::DeducedTemplateSpecialization:
3639 return getDeclLinkageAndVisibility(cast<TagType>(T)->
getDecl());
3642 return computeTypeLinkageInfo(cast<ComplexType>(T)->getElementType());
3644 return computeTypeLinkageInfo(cast<PointerType>(T)->
getPointeeType());
3645 case Type::BlockPointer:
3646 return computeTypeLinkageInfo(cast<BlockPointerType>(T)->
getPointeeType());
3647 case Type::LValueReference:
3648 case Type::RValueReference:
3649 return computeTypeLinkageInfo(cast<ReferenceType>(T)->
getPointeeType());
3650 case Type::MemberPointer: {
3651 const auto *MPT = cast<MemberPointerType>(T);
3652 LinkageInfo LV = computeTypeLinkageInfo(MPT->getClass());
3653 LV.
merge(computeTypeLinkageInfo(MPT->getPointeeType()));
3656 case Type::ConstantArray:
3657 case Type::IncompleteArray:
3658 case Type::VariableArray:
3659 return computeTypeLinkageInfo(cast<ArrayType>(T)->getElementType());
3661 case Type::ExtVector:
3662 return computeTypeLinkageInfo(cast<VectorType>(T)->getElementType());
3663 case Type::FunctionNoProto:
3664 return computeTypeLinkageInfo(cast<FunctionType>(T)->getReturnType());
3665 case Type::FunctionProto: {
3666 const auto *FPT = cast<FunctionProtoType>(T);
3667 LinkageInfo LV = computeTypeLinkageInfo(FPT->getReturnType());
3668 for (
const auto &ai : FPT->param_types())
3669 LV.
merge(computeTypeLinkageInfo(ai));
3672 case Type::ObjCInterface:
3673 return getDeclLinkageAndVisibility(cast<ObjCInterfaceType>(T)->
getDecl());
3674 case Type::ObjCObject:
3675 return computeTypeLinkageInfo(cast<ObjCObjectType>(T)->getBaseType());
3676 case Type::ObjCObjectPointer:
3677 return computeTypeLinkageInfo(
3680 return computeTypeLinkageInfo(cast<AtomicType>(T)->getValueType());
3682 return computeTypeLinkageInfo(cast<PipeType>(T)->getElementType());
3685 llvm_unreachable(
"unhandled type class");
3716 if (
auto attributed = dyn_cast<AttributedType>(type.
getTypePtr())) {
3717 if (
auto nullability = attributed->getImmediateNullability())
3735 #define NON_CANONICAL_TYPE(Class, Parent) \ 3737 llvm_unreachable("non-canonical type"); 3738 #define TYPE(Class, Parent) 3739 #include "clang/AST/TypeNodes.def" 3743 case Type::BlockPointer:
3744 case Type::MemberPointer:
3745 case Type::ObjCObjectPointer:
3749 case Type::UnresolvedUsing:
3750 case Type::TypeOfExpr:
3752 case Type::Decltype:
3753 case Type::UnaryTransform:
3754 case Type::TemplateTypeParm:
3755 case Type::SubstTemplateTypeParmPack:
3756 case Type::DependentName:
3757 case Type::DependentTemplateSpecialization:
3759 return ResultIfUnknown;
3764 case Type::TemplateSpecialization:
3766 = cast<TemplateSpecializationType>(type.
getTypePtr())
3767 ->getTemplateName().getAsTemplateDecl()) {
3768 if (isa<ClassTemplateDecl>(templateDecl))
3771 return ResultIfUnknown;
3776 #define SIGNED_TYPE(Id, SingletonId) case BuiltinType::Id: 3777 #define UNSIGNED_TYPE(Id, SingletonId) case BuiltinType::Id: 3778 #define FLOATING_TYPE(Id, SingletonId) case BuiltinType::Id: 3779 #define BUILTIN_TYPE(Id, SingletonId) 3780 #include "clang/AST/BuiltinTypes.def" 3784 case BuiltinType::Dependent:
3785 case BuiltinType::Overload:
3786 case BuiltinType::BoundMember:
3787 case BuiltinType::PseudoObject:
3788 case BuiltinType::UnknownAny:
3789 case BuiltinType::ARCUnbridgedCast:
3790 return ResultIfUnknown;
3792 case BuiltinType::Void:
3793 case BuiltinType::ObjCId:
3794 case BuiltinType::ObjCClass:
3795 case BuiltinType::ObjCSel:
3796 #define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \ 3797 case BuiltinType::Id: 3798 #include "clang/Basic/OpenCLImageTypes.def" 3799 case BuiltinType::OCLSampler:
3800 case BuiltinType::OCLEvent:
3801 case BuiltinType::OCLClkEvent:
3802 case BuiltinType::OCLQueue:
3803 case BuiltinType::OCLReserveID:
3804 case BuiltinType::BuiltinFn:
3805 case BuiltinType::NullPtr:
3806 case BuiltinType::OMPArraySection:
3809 llvm_unreachable(
"unknown builtin type");
3813 case Type::LValueReference:
3814 case Type::RValueReference:
3815 case Type::ConstantArray:
3816 case Type::IncompleteArray:
3817 case Type::VariableArray:
3818 case Type::DependentSizedArray:
3819 case Type::DependentVector:
3820 case Type::DependentSizedExtVector:
3822 case Type::ExtVector:
3823 case Type::DependentAddressSpace:
3824 case Type::FunctionProto:
3825 case Type::FunctionNoProto:
3827 case Type::DeducedTemplateSpecialization:
3829 case Type::InjectedClassName:
3830 case Type::PackExpansion:
3831 case Type::ObjCObject:
3832 case Type::ObjCInterface:
3837 llvm_unreachable(
"bad type kind!");
3851 if (
auto attributed = dyn_cast<AttributedType>(T.
getTypePtr())) {
3852 if (
auto nullability = attributed->getImmediateNullability()) {
3853 T = attributed->getModifiedType();
3862 const auto *objcPtr = getAs<ObjCObjectPointerType>();
3866 if (objcPtr->isObjCIdType()) {
3877 }
else if (objcPtr->isObjCQualifiedIdType()) {
3902 "cannot query implicit lifetime for non-inferrable type");
3907 while (
const auto *array = dyn_cast<ArrayType>(canon))
3908 canon = array->getElementType().getTypePtr();
3910 if (
const auto *opt = dyn_cast<ObjCObjectPointerType>(canon)) {
3912 if (opt->getObjectType()->isObjCClass())
3920 const Type *cur =
this;
3922 if (
const auto *
typedefType = dyn_cast<TypedefType>(cur))
3923 return typedefType->getDecl()->hasAttr<ObjCNSObjectAttr>();
3927 if (next.getTypePtr() == cur)
return false;
3928 cur = next.getTypePtr();
3933 if (
const auto *
typedefType = dyn_cast<TypedefType>(
this))
3934 return typedefType->getDecl()->hasAttr<ObjCIndependentClassAttr>();
3947 if (
const auto *OPT = getAs<PointerType>())
3948 return OPT->getPointeeType()->isObjCIndirectLifetimeType();
3949 if (
const auto *Ref = getAs<ReferenceType>())
3950 return Ref->getPointeeType()->isObjCIndirectLifetimeType();
3951 if (
const auto *MemPtr = getAs<MemberPointerType>())
3952 return MemPtr->getPointeeType()->isObjCIndirectLifetimeType();
3959 const Type *type =
this;
3961 type = array->getElementType().getTypePtr();
3973 const auto *
Pointer = getAs<PointerType>();
3984 if (
const auto *ptr = getAs<PointerType>())
3985 return ptr->getPointeeType()->hasSizedVLAType();
3986 if (
const auto *ref = getAs<ReferenceType>())
3987 return ref->getPointeeType()->hasSizedVLAType();
3989 if (isa<VariableArrayType>(arr) &&
3990 cast<VariableArrayType>(arr)->getSizeExpr())
3993 return arr->getElementType()->hasSizedVLAType();
4007 return DK_objc_strong_lifetime;
4009 return DK_objc_weak_lifetime;
4012 if (
const auto *RT =
4015 if (
const auto *CXXRD = dyn_cast<CXXRecordDecl>(RD)) {
4017 if (CXXRD->hasDefinition() && !CXXRD->hasTrivialDestructor())
4018 return DK_cxx_destructor;
4023 return DK_nontrivial_c_struct;
4035 const llvm::APSInt &Val,
unsigned Scale,
4037 llvm::APSInt ScaleVal = llvm::APSInt::getUnsigned(1ULL << Scale);
4038 llvm::APSInt IntPart = Val / ScaleVal;
4039 llvm::APSInt FractPart = Val % ScaleVal;
4040 llvm::APSInt RadixInt = llvm::APSInt::getUnsigned(Radix);
4042 IntPart.toString(Str, Radix);
4045 (FractPart * RadixInt / ScaleVal).
toString(Str, Radix);
4046 FractPart = (FractPart * RadixInt) % ScaleVal;
4047 }
while (FractPart.getExtValue());
unsigned char getOpaqueValue() const
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.
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
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)
Represents a function declaration or definition.
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
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 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.
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
void FixedPointValueToString(SmallVectorImpl< char > &Str, const llvm::APSInt &Val, unsigned Scale, unsigned Radix)
QualType getQualifiedType(SplitQualType split) const
Un-split a SplitQualType.
const ObjCObjectType * getAsObjCInterfaceType() const
QualType getLValueReferenceType(QualType T, bool SpelledAsLValue=true) const
Return the uniqued reference to the type for an lvalue reference to the specified type...
Decl - This represents one declaration (or definition), e.g.
TagDecl * getDecl() const
ObjCObjectTypeBitfields ObjCObjectTypeBits
const RecordType * getAsStructureType() const
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.
QualType getBlockPointerType(QualType T) const
Return the uniqued reference to the type for a block of the specified type.
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.
QualType getAtomicType(QualType T) const
Return the uniqued reference to the atomic type for the specified 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
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.
QualType getMemberPointerType(QualType T, const Type *Cls) const
Return the uniqued reference to the type for a member pointer to the specified type in the specified ...
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 getSubstTemplateTypeParmType(const TemplateTypeParmType *Replaced, QualType Replacement) const
Retrieve a substitution-result type.
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
const AstTypeMatcher< TypedefType > typedefType
Matches typedef types.
unsigned getIndex() const
Retrieve the index into its type parameter list.
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)
An rvalue reference type, per C++11 [dcl.ref].
bool isMSTypeSpec() const
const ObjCObjectType * getAsObjCQualifiedInterfaceType() 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.
const ObjCObjectPointerType * getAsObjCQualifiedClassType() const
bool containsUnexpandedParameterPack() const
Whether this type is or contains an unexpanded parameter pack, used to support C++0x variadic templat...
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 QualType simpleTransform(ASTContext &ctx, QualType type, F &&f)
Perform a simple type transformation that does not change the semantics of the type.
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.
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).
ArraySizeModifier
Capture whether this is a normal array (e.g.
QuantityType getQuantity() const
getQuantity - Get the raw integer representation of this quantity.
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
QualType getVectorType(QualType VectorType, unsigned NumElts, VectorType::VectorKind VecKind) const
Return the unique reference to a vector type of the specified element type and size.
Expr - 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.
QualType getParenType(QualType NamedType) const
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...
QualType getConstantArrayType(QualType EltTy, const llvm::APInt &ArySize, ArrayType::ArraySizeModifier ASM, unsigned IndexTypeQuals) const
Return the unique reference to the type for a constant array of the specified element type...
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 isObjCInertUnsafeUnretainedType() const
Was this type written with the special inert-in-MRC __unsafe_unretained qualifier?
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.
IdentifierInfo * getNSObjectName()
Retrieve the identifier 'NSObject'.
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
bool isVoidPointerType() const
bool isConstQualified() const
Determine whether this type is const-qualified.
IdentifierInfo * getNSCopyingName()
Retrieve the identifier 'NSCopying'.
QualType getAutoType(QualType DeducedType, AutoTypeKeyword Keyword, bool IsDependent) const
C++11 deduced auto type.
bool hasTrailingReturn() const
SplitQualType split() const
Divides a QualType into its unqualified type and a set of local qualifiers.
RecordDecl * getDecl() const
noexcept(expression), evals to 'false'
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.
QualType getSingleStepDesugaredType(const ASTContext &Context) const
Return the specified type with one level of "sugar" removed from the 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
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)
QualType getExtVectorType(QualType VectorType, unsigned NumElts) const
Return the unique reference to an extended vector type of the specified element type and size...
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
QualType getAttributedType(AttributedType::Kind attrKind, QualType modifiedType, QualType equivalentType)
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 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.
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.
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.
QualType getDecayedType(QualType T) const
Return the uniqued reference to the decayed version of the given 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
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.
std::string toString(const til::SExpr *E)
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).
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.
QualType getRValueReferenceType(QualType T) const
Return the uniqued reference to the type for an rvalue reference to the specified type...
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...
QualType getPointerType(QualType T) const
Return the uniqued reference to the type for a pointer to the specified type.
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?
__DEVICE__ int max(int __a, int __b)
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)
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.
Represents a C array with a specified size that is not an integer-constant-expression.
No keyword precedes the qualified type name.
QualType getVariableArrayType(QualType EltTy, Expr *NumElts, ArrayType::ArraySizeModifier ASM, unsigned IndexTypeQuals, SourceRange Brackets) const
Return a non-unique reference to the type for a variable array of the specified element type...
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
QualType getAdjustedType(QualType Orig, QualType New) const
Return the uniqued reference to a type adjusted from the original type to a new type.
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'
QualType getComplexType(QualType T) const
Return the uniqued reference to the type for a complex number with the specified element type...
QualType getIncompleteArrayType(QualType EltTy, ArrayType::ArraySizeModifier ASM, unsigned IndexTypeQuals) const
Return a unique reference to the type for an incomplete array of the specified element type...
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.