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),
733 struct SimpleTransformVisitor
734 :
public TypeVisitor<SimpleTransformVisitor<F>, QualType> {
743 SimpleTransformVisitor(
ASTContext &ctx, F &&f)
744 : Ctx(ctx), TheFunc(std::move(f)) {}
748 #define TYPE(Class, Base) 749 #define DEPENDENT_TYPE(Class, Base) \ 750 QualType Visit##Class##Type(const Class##Type *T) { return QualType(T, 0); } 751 #include "clang/AST/TypeNodes.def" 753 #define TRIVIAL_TYPE_CLASS(Class) \ 754 QualType Visit##Class##Type(const Class##Type *T) { return QualType(T, 0); } 906 bool paramChanged =
false;
908 QualType newParamType = recurse(paramType);
909 if (newParamType.
isNull())
915 paramTypes.push_back(newParamType);
920 bool exceptionChanged =
false;
924 QualType newExceptionType = recurse(exceptionType);
925 if (newExceptionType.
isNull())
928 if (newExceptionType.
getAsOpaquePtr() != exceptionType.getAsOpaquePtr())
929 exceptionChanged =
true;
931 exceptionTypes.push_back(newExceptionType);
934 if (exceptionChanged) {
936 llvm::makeArrayRef(exceptionTypes).copy(Ctx);
941 !paramChanged && !exceptionChanged)
963 if (originalType.
isNull())
967 if (adjustedType.
isNull())
980 if (originalType.
isNull())
1002 if (modifiedType.
isNull())
1006 if (equivalentType.
isNull())
1021 if (replacementType.
isNull())
1040 if (deducedType.
isNull())
1060 bool typeArgChanged =
false;
1063 QualType newTypeArg = recurse(typeArg);
1068 typeArgChanged =
true;
1070 typeArgs.push_back(newTypeArg);
1087 if (pointeeType.
isNull())
1109 #undef TRIVIAL_TYPE_CLASS 1116 template<
typename F>
1127 SimpleTransformVisitor<F> visitor(ctx, std::forward<F>(f));
1128 QualType result = visitor.Visit(splitType.
Ty);
1149 if (
const auto *OTPTy = dyn_cast<ObjCTypeParamType>(splitType.
Ty)) {
1152 if (!typeArgs.empty()) {
1154 if (OTPTy->qual_empty())
1160 protocolsVec.append(OTPTy->qual_begin(),
1164 protocolsToApply, hasError,
true);
1185 if (objPtr->isKindOfType() || objPtr->isObjCIdOrClassType())
1190 const auto *obj = objPtr->getObjectType();
1192 obj->getTypeArgsAsWritten(),
1193 obj->getProtocols(),
1204 if (
const auto *funcType = dyn_cast<FunctionType>(splitType.
Ty)) {
1206 QualType returnType = funcType->getReturnType().substObjCTypeArgs(
1215 if (isa<FunctionNoProtoType>(funcType)) {
1218 == funcType->getReturnType().getAsOpaquePtr())
1225 const auto *funcProtoType = cast<FunctionProtoType>(funcType);
1229 bool paramChanged =
false;
1230 for (
auto paramType : funcProtoType->getParamTypes()) {
1235 if (newParamType.
isNull())
1239 paramChanged =
true;
1241 paramTypes.push_back(newParamType);
1246 bool exceptionChanged =
false;
1254 if (newExceptionType.
isNull())
1258 != exceptionType.getAsOpaquePtr())
1259 exceptionChanged =
true;
1261 exceptionTypes.push_back(newExceptionType);
1264 if (exceptionChanged) {
1266 llvm::makeArrayRef(exceptionTypes).copy(ctx);
1271 == funcProtoType->getReturnType().getAsOpaquePtr() &&
1272 !paramChanged && !exceptionChanged)
1280 if (
const auto *objcObjectType = dyn_cast<ObjCObjectType>(splitType.
Ty)) {
1281 if (objcObjectType->isSpecializedAsWritten()) {
1283 bool anyChanged =
false;
1284 for (
auto typeArg : objcObjectType->getTypeArgsAsWritten()) {
1295 objcObjectType->qual_begin(),
1296 objcObjectType->getNumProtocols());
1297 if (typeArgs.empty() &&
1300 objcObjectType->getBaseType(), {},
1302 objcObjectType->isKindOfTypeAsWritten());
1308 newTypeArgs.push_back(newTypeArg);
1313 objcObjectType->qual_begin(),
1314 objcObjectType->getNumProtocols());
1316 newTypeArgs, protocols,
1317 objcObjectType->isKindOfTypeAsWritten());
1339 auto &ctx =
const_cast<ASTContext &
>(constCtx);
1344 if (!objType->isKindOfType())
1348 = objType->getBaseType().stripObjCKindOfType(ctx);
1351 objType->getTypeArgsAsWritten(),
1352 objType->getProtocols(),
1362 if (
const auto AT = getTypePtr()->getAs<AtomicType>())
1363 return AT->getValueType().getUnqualifiedType();
1364 return getUnqualifiedType();
1370 if (
const auto method = dyn_cast<ObjCMethodDecl>(dc))
1371 dc = method->getDeclContext();
1381 dcTypeParams = dcClassDecl->getTypeParamList();
1388 if (!dcCategoryDecl)
1393 dcTypeParams = dcCategoryDecl->getTypeParamList();
1397 dcClassDecl = dcCategoryDecl->getClassInterface();
1401 assert(dcTypeParams &&
"No substitutions to perform");
1402 assert(dcClassDecl &&
"No class context");
1406 if (
const auto *objectPointerType = getAs<ObjCObjectPointerType>()) {
1407 objectType = objectPointerType->getObjectType();
1408 }
else if (getAs<BlockPointerType>()) {
1413 objectType = getAs<ObjCObjectType>();
1419 if (!curClassDecl) {
1427 while (curClassDecl != dcClassDecl) {
1430 if (superType.
isNull()) {
1431 objectType =
nullptr;
1451 if (
auto *
ID = IfaceT->getInterface()) {
1452 if (
ID->getTypeParamList())
1466 CachedSuperClassType.setInt(
true);
1472 if (!superClassObjTy) {
1473 CachedSuperClassType.setInt(
true);
1478 if (!superClassDecl) {
1479 CachedSuperClassType.setInt(
true);
1485 QualType superClassType(superClassObjTy, 0);
1487 if (!superClassTypeParams) {
1488 CachedSuperClassType.setPointerAndInt(
1495 CachedSuperClassType.setPointerAndInt(superClassObjTy,
true);
1503 CachedSuperClassType.setPointerAndInt(
1514 CachedSuperClassType.setPointerAndInt(
1522 assert(typeArgs.size() == typeParams->
size());
1523 CachedSuperClassType.setPointerAndInt(
1526 ->castAs<ObjCObjectType>(),
1532 return interfaceDecl->getASTContext().getObjCInterfaceType(interfaceDecl)
1541 if (superObjectType.
isNull())
1542 return superObjectType;
1544 ASTContext &ctx = getInterfaceDecl()->getASTContext();
1552 if (
const auto *T = getAs<ObjCObjectType>())
1553 if (T->getNumProtocols() && T->getInterface())
1565 if (
const auto *OPT = getAs<ObjCObjectPointerType>()) {
1566 if (OPT->isObjCQualifiedIdType())
1575 if (
const auto *OPT = getAs<ObjCObjectPointerType>()) {
1576 if (OPT->isObjCQualifiedClassType())
1583 if (
const auto *OT = getAs<ObjCObjectType>()) {
1584 if (OT->getInterface())
1591 if (
const auto *OPT = getAs<ObjCObjectPointerType>()) {
1592 if (OPT->getInterfaceType())
1600 if (
const auto *PT = getAs<PointerType>())
1602 else if (
const auto *RT = getAs<ReferenceType>())
1614 return dyn_cast_or_null<CXXRecordDecl>(
getAsTagDecl());
1622 if (
const auto *TT = getAs<TagType>())
1623 return TT->getDecl();
1624 if (
const auto *Injected = getAs<InjectedClassNameType>())
1625 return Injected->getDecl();
1631 const Type *Cur =
this;
1633 if (AT->getAttrKind() == AK)
1635 Cur = AT->getEquivalentType().getTypePtr();
1642 class GetContainedDeducedTypeVisitor :
1643 public TypeVisitor<GetContainedDeducedTypeVisitor, Type*> {
1647 GetContainedDeducedTypeVisitor(
bool Syntactic =
false)
1648 : Syntactic(Syntactic) {}
1689 Type *VisitDependentSizedExtVectorType(
1700 return const_cast<FunctionProtoType*>(T);
1701 return VisitFunctionType(T);
1724 return cast_or_null<DeducedType>(
1725 GetContainedDeducedTypeVisitor().Visit(
this));
1729 return dyn_cast_or_null<FunctionType>(
1730 GetContainedDeducedTypeVisitor(
true).Visit(
this));
1734 if (
const auto *VT = dyn_cast<VectorType>(CanonicalType))
1735 return VT->getElementType()->isIntegerType();
1760 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
1761 return BT->getKind() >= BuiltinType::Bool &&
1762 BT->getKind() <= BuiltinType::Int128;
1766 if (
const auto *ET = dyn_cast<EnumType>(CanonicalType))
1767 return ET->getDecl()->isComplete();
1773 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
1774 return BT->getKind() >= BuiltinType::Bool &&
1775 BT->getKind() <= BuiltinType::Int128;
1781 if (
const auto *ET = dyn_cast<EnumType>(CanonicalType))
1782 return ET->getDecl()->isComplete() && !ET->getDecl()->isScoped();
1788 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
1789 return BT->getKind() == BuiltinType::Char_U ||
1790 BT->getKind() == BuiltinType::UChar ||
1791 BT->getKind() == BuiltinType::Char_S ||
1792 BT->getKind() == BuiltinType::SChar;
1797 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
1798 return BT->getKind() == BuiltinType::WChar_S ||
1799 BT->getKind() == BuiltinType::WChar_U;
1804 if (
const BuiltinType *BT = dyn_cast<BuiltinType>(CanonicalType))
1805 return BT->getKind() == BuiltinType::Char8;
1810 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
1811 return BT->getKind() == BuiltinType::Char16;
1816 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
1817 return BT->getKind() == BuiltinType::Char32;
1824 const auto *BT = dyn_cast<
BuiltinType>(CanonicalType);
1825 if (!BT)
return false;
1826 switch (BT->getKind()) {
1827 default:
return false;
1828 case BuiltinType::Char_U:
1829 case BuiltinType::UChar:
1830 case BuiltinType::WChar_U:
1831 case BuiltinType::Char8:
1832 case BuiltinType::Char16:
1833 case BuiltinType::Char32:
1834 case BuiltinType::Char_S:
1835 case BuiltinType::SChar:
1836 case BuiltinType::WChar_S:
1845 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType)) {
1846 return BT->getKind() >= BuiltinType::Char_S &&
1847 BT->getKind() <= BuiltinType::Int128;
1850 if (
const EnumType *ET = dyn_cast<EnumType>(CanonicalType)) {
1853 if (ET->getDecl()->isComplete() && !ET->getDecl()->isScoped())
1854 return ET->getDecl()->getIntegerType()->isSignedIntegerType();
1861 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType)) {
1862 return BT->getKind() >= BuiltinType::Char_S &&
1863 BT->getKind() <= BuiltinType::Int128;
1866 if (
const auto *ET = dyn_cast<EnumType>(CanonicalType)) {
1867 if (ET->getDecl()->isComplete())
1868 return ET->getDecl()->getIntegerType()->isSignedIntegerType();
1875 if (
const auto *VT = dyn_cast<VectorType>(CanonicalType))
1876 return VT->getElementType()->isSignedIntegerOrEnumerationType();
1885 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType)) {
1886 return BT->getKind() >= BuiltinType::Bool &&
1887 BT->getKind() <= BuiltinType::UInt128;
1890 if (
const auto *ET = dyn_cast<EnumType>(CanonicalType)) {
1893 if (ET->getDecl()->isComplete() && !ET->getDecl()->isScoped())
1894 return ET->getDecl()->getIntegerType()->isUnsignedIntegerType();
1901 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType)) {
1902 return BT->getKind() >= BuiltinType::Bool &&
1903 BT->getKind() <= BuiltinType::UInt128;
1906 if (
const auto *ET = dyn_cast<EnumType>(CanonicalType)) {
1907 if (ET->getDecl()->isComplete())
1908 return ET->getDecl()->getIntegerType()->isUnsignedIntegerType();
1915 if (
const auto *VT = dyn_cast<VectorType>(CanonicalType))
1916 return VT->getElementType()->isUnsignedIntegerOrEnumerationType();
1922 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
1923 return BT->getKind() >= BuiltinType::Half &&
1924 BT->getKind() <= BuiltinType::Float128;
1925 if (
const auto *CT = dyn_cast<ComplexType>(CanonicalType))
1926 return CT->getElementType()->isFloatingType();
1931 if (
const auto *VT = dyn_cast<VectorType>(CanonicalType))
1932 return VT->getElementType()->isFloatingType();
1938 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
1939 return BT->isFloatingPoint();
1944 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
1945 return BT->getKind() >= BuiltinType::Bool &&
1946 BT->getKind() <= BuiltinType::Float128;
1947 if (
const auto *ET = dyn_cast<EnumType>(CanonicalType))
1948 return ET->getDecl()->isComplete() && !ET->getDecl()->isScoped();
1953 if (
const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
1954 return BT->getKind() >= BuiltinType::Bool &&
1955 BT->getKind() <= BuiltinType::Float128;
1956 if (
const auto *ET = dyn_cast<EnumType>(CanonicalType))
1963 return !ET->getDecl()->isScoped() && ET->getDecl()->isComplete();
1964 return isa<ComplexType>(CanonicalType);
1971 if (
const auto *BT = dyn_cast<BuiltinType>(T)) {
1972 if (BT->getKind() == BuiltinType::Bool)
return STK_Bool;
1973 if (BT->getKind() == BuiltinType::NullPtr)
return STK_CPointer;
1977 llvm_unreachable(
"unknown scalar builtin type");
1978 }
else if (isa<PointerType>(T)) {
1980 }
else if (isa<BlockPointerType>(T)) {
1982 }
else if (isa<ObjCObjectPointerType>(T)) {
1984 }
else if (isa<MemberPointerType>(T)) {
1986 }
else if (isa<EnumType>(T)) {
1987 assert(cast<EnumType>(T)->getDecl()->isComplete());
1989 }
else if (
const auto *CT = dyn_cast<ComplexType>(T)) {
1990 if (CT->getElementType()->isRealFloatingType())
1995 llvm_unreachable(
"unknown scalar type");
2008 if (
const auto *Record = dyn_cast<RecordType>(CanonicalType)) {
2009 if (
const auto *ClassDecl = dyn_cast<CXXRecordDecl>(Record->getDecl()))
2010 return ClassDecl->isAggregate();
2015 return isa<ArrayType>(CanonicalType);
2022 assert(!
isIncompleteType() &&
"This doesn't make sense for incomplete types");
2023 assert(!
isDependentType() &&
"This doesn't make sense for dependent types");
2025 return !isa<VariableArrayType>(CanonicalType);
2035 switch (CanonicalType->getTypeClass()) {
2036 default:
return false;
2042 EnumDecl *EnumD = cast<EnumType>(CanonicalType)->getDecl();
2050 RecordDecl *Rec = cast<RecordType>(CanonicalType)->getDecl();
2060 return cast<ArrayType>(CanonicalType)->getElementType()
2061 ->isIncompleteType(Def);
2062 case IncompleteArray:
2065 case MemberPointer: {
2069 auto *MPTy = cast<MemberPointerType>(CanonicalType);
2070 const Type *ClassTy = MPTy->getClass();
2072 if (ClassTy->isDependentType())
2083 if (RD->
hasAttr<MSInheritanceAttr>())
2088 return cast<ObjCObjectType>(CanonicalType)->
getBaseType()
2090 case ObjCInterface: {
2093 = cast<ObjCInterfaceType>(CanonicalType)->getDecl();
2104 return isCXX11PODType(Context);
2106 return isCXX98PODType(Context);
2116 if ((*this)->isIncompleteArrayType())
2119 if ((*this)->isIncompleteType())
2122 if (hasNonTrivialObjCLifetime())
2125 QualType CanonicalType = getTypePtr()->CanonicalType;
2128 default:
return false;
2129 case Type::VariableArray:
2130 case Type::ConstantArray:
2134 case Type::ObjCObjectPointer:
2135 case Type::BlockPointer:
2139 case Type::MemberPointer:
2141 case Type::ExtVector:
2148 if (
const auto *ClassDecl =
2149 dyn_cast<CXXRecordDecl>(cast<RecordType>(CanonicalType)->getDecl()))
2150 return ClassDecl->isPOD();
2164 if ((*this)->isArrayType())
2169 if ((*this)->isIncompleteType())
2172 if (hasNonTrivialObjCLifetime())
2175 QualType CanonicalType = getTypePtr()->CanonicalType;
2188 if (
const auto *ClassDecl = dyn_cast<CXXRecordDecl>(RT->getDecl())) {
2193 return ClassDecl->hasDefaultConstructor() &&
2194 !ClassDecl->hasNonTrivialDefaultConstructor() &&
2195 ClassDecl->isTriviallyCopyable();
2206 if ((*this)->isArrayType())
2209 if (hasNonTrivialObjCLifetime())
2217 QualType CanonicalType = getCanonicalType();
2231 if (
const auto *ClassDecl = dyn_cast<CXXRecordDecl>(RT->getDecl())) {
2232 if (!ClassDecl->isTriviallyCopyable())
return false;
2250 if (
const auto *RT =
2252 if (RT->getDecl()->isNonTrivialToPrimitiveDefaultInitialize())
2255 switch (getQualifiers().getObjCLifetime()) {
2257 return PDIK_ARCStrong;
2259 return PDIK_ARCWeak;
2261 return PDIK_Trivial;
2266 if (
const auto *RT =
2268 if (RT->getDecl()->isNonTrivialToPrimitiveCopy())
2274 return PCK_ARCStrong;
2278 return Qs.
hasVolatile() ? PCK_VolatileTrivial : PCK_Trivial;
2284 return isNonTrivialToPrimitiveCopy();
2304 assert(BaseTy &&
"NULL element type");
2334 if (
const auto *ClassDecl = dyn_cast<CXXRecordDecl>(RT->getDecl()))
2335 return ClassDecl->isLiteral();
2342 return AT->getValueType()->isLiteralType(Ctx);
2361 assert(BaseTy &&
"NULL element type");
2371 if (
const auto *ClassDecl = dyn_cast<CXXRecordDecl>(RT->getDecl()))
2372 if (!ClassDecl->isStandardLayout())
2389 const Type *ty = getTypePtr();
2393 if (hasNonTrivialObjCLifetime())
2400 assert(BaseTy &&
"NULL element type");
2410 if (
const auto *ClassDecl = dyn_cast<CXXRecordDecl>(RT->getDecl())) {
2413 if (!ClassDecl->isTrivial())
return false;
2418 if (!ClassDecl->isStandardLayout())
return false;
2438 if (
const auto *ET = getAs<EnumType>()) {
2440 if (II && II->
isStr(
"align_val_t") && ET->getDecl()->isInStdNamespace())
2447 if (
const auto *ET = getAs<EnumType>()) {
2449 if (II && II->
isStr(
"byte") && ET->getDecl()->isInStdNamespace())
2456 if (
const auto *BT = getAs<BuiltinType>())
2457 switch (BT->getKind()) {
2458 case BuiltinType::Bool:
2459 case BuiltinType::Char_S:
2460 case BuiltinType::Char_U:
2461 case BuiltinType::SChar:
2462 case BuiltinType::UChar:
2463 case BuiltinType::Short:
2464 case BuiltinType::UShort:
2465 case BuiltinType::WChar_S:
2466 case BuiltinType::WChar_U:
2467 case BuiltinType::Char8:
2468 case BuiltinType::Char16:
2469 case BuiltinType::Char32:
2477 if (
const auto *ET = getAs<EnumType>()){
2478 if (this->
isDependentType() || ET->getDecl()->getPromotionType().isNull()
2479 || ET->getDecl()->isScoped())
2498 case TemplateTypeParm:
2499 case SubstTemplateTypeParm:
2500 case TemplateSpecialization:
2503 case DependentTemplateSpecialization:
2506 case ObjCObjectPointer:
2536 llvm_unreachable(
"Type specifier is not a tag type kind.");
2548 llvm_unreachable(
"Unknown tag type kind.");
2561 llvm_unreachable(
"Elaborated type keyword is not a tag type kind.");
2563 llvm_unreachable(
"Unknown elaborated type keyword.");
2579 llvm_unreachable(
"Unknown elaborated type keyword.");
2593 llvm_unreachable(
"Unknown elaborated type keyword.");
2596 DependentTemplateSpecializationType::DependentTemplateSpecializationType(
2601 :
TypeWithKeyword(Keyword, DependentTemplateSpecialization, Canon,
true,
true,
2604 NNS(NNS), Name(Name) {
2607 "DependentTemplateSpecializatonType requires dependent qualifier");
2610 if (Arg.containsUnexpandedParameterPack())
2624 ID.AddInteger(Keyword);
2625 ID.AddPointer(Qualifier);
2626 ID.AddPointer(Name);
2628 Arg.Profile(ID, Context);
2633 if (
const auto *Elab = dyn_cast<ElaboratedType>(
this))
2634 Keyword = Elab->getKeyword();
2635 else if (
const auto *DepName = dyn_cast<DependentNameType>(
this))
2636 Keyword = DepName->getKeyword();
2637 else if (
const auto *DepTST =
2638 dyn_cast<DependentTemplateSpecializationType>(
this))
2639 Keyword = DepTST->getKeyword();
2648 #define ABSTRACT_TYPE(Derived, Base) 2649 #define TYPE(Derived, Base) case Derived: return #Derived; 2650 #include "clang/AST/TypeNodes.def" 2653 llvm_unreachable(
"Invalid type class.");
2661 return Policy.
Bool ?
"bool" :
"_Bool";
2667 return "signed char";
2679 return "unsigned char";
2681 return "unsigned short";
2683 return "unsigned int";
2685 return "unsigned long";
2687 return "unsigned long long";
2689 return "unsigned __int128";
2691 return Policy.
Half ?
"half" :
"__fp16";
2697 return "long double";
2699 return "short _Accum";
2703 return "long _Accum";
2705 return "unsigned short _Accum";
2707 return "unsigned _Accum";
2709 return "unsigned long _Accum";
2710 case BuiltinType::ShortFract:
2711 return "short _Fract";
2712 case BuiltinType::Fract:
2714 case BuiltinType::LongFract:
2715 return "long _Fract";
2716 case BuiltinType::UShortFract:
2717 return "unsigned short _Fract";
2718 case BuiltinType::UFract:
2719 return "unsigned _Fract";
2720 case BuiltinType::ULongFract:
2721 return "unsigned long _Fract";
2722 case BuiltinType::SatShortAccum:
2723 return "_Sat short _Accum";
2724 case BuiltinType::SatAccum:
2725 return "_Sat _Accum";
2726 case BuiltinType::SatLongAccum:
2727 return "_Sat long _Accum";
2728 case BuiltinType::SatUShortAccum:
2729 return "_Sat unsigned short _Accum";
2730 case BuiltinType::SatUAccum:
2731 return "_Sat unsigned _Accum";
2732 case BuiltinType::SatULongAccum:
2733 return "_Sat unsigned long _Accum";
2734 case BuiltinType::SatShortFract:
2735 return "_Sat short _Fract";
2736 case BuiltinType::SatFract:
2737 return "_Sat _Fract";
2738 case BuiltinType::SatLongFract:
2739 return "_Sat long _Fract";
2740 case BuiltinType::SatUShortFract:
2741 return "_Sat unsigned short _Fract";
2742 case BuiltinType::SatUFract:
2743 return "_Sat unsigned _Fract";
2744 case BuiltinType::SatULongFract:
2745 return "_Sat unsigned long _Fract";
2749 return "__float128";
2752 return Policy.
MSWChar ?
"__wchar_t" :
"wchar_t";
2762 return "<overloaded function type>";
2764 return "<bound member function type>";
2766 return "<pseudo-object type>";
2768 return "<dependent type>";
2770 return "<unknown type>";
2771 case ARCUnbridgedCast:
2772 return "<ARC unbridged cast type>";
2774 return "<builtin fn type>";
2781 #define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \ 2783 return "__" #Access " " #ImgType "_t"; 2784 #include "clang/Basic/OpenCLImageTypes.def" 2790 return "clk_event_t";
2794 return "reserve_id_t";
2795 case OMPArraySection:
2796 return "<OpenMP array section type>";
2797 #define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \ 2800 #include "clang/Basic/OpenCLExtensionTypes.def" 2803 llvm_unreachable(
"Invalid builtin type.");
2807 if (
const auto *RefType = getTypePtr()->getAs<ReferenceType>())
2816 (!getTypePtr()->isDependentType() && !getTypePtr()->isRecordType()))
2817 return getUnqualifiedType();
2824 case CC_C:
return "cdecl";
2844 llvm_unreachable(
"Invalid calling convention.");
2849 const ExtProtoInfo &epi)
2857 assert(getNumParams() == params.size() &&
"NumParams overflow!");
2864 if (hasExtraBitfields(epi.ExceptionSpec.Type)) {
2865 auto &ExtraBits = *getTrailingObjects<FunctionTypeExtraBitfields>();
2866 ExtraBits.NumExceptionType = epi.ExceptionSpec.Exceptions.size();
2870 auto *argSlot = getTrailingObjects<QualType>();
2871 for (
unsigned i = 0; i != getNumParams(); ++i) {
2880 argSlot[i] = params[i];
2885 assert(hasExtraBitfields() &&
"missing trailing extra bitfields!");
2887 reinterpret_cast<QualType *
>(getTrailingObjects<ExceptionType>());
2899 exnSlot[I++] = ExceptionType;
2904 assert(epi.ExceptionSpec.NoexceptExpr &&
"computed noexcept with no expr");
2906 epi.ExceptionSpec.NoexceptExpr->isValueDependent());
2909 *getTrailingObjects<Expr *>() = epi.ExceptionSpec.NoexceptExpr;
2911 if (epi.ExceptionSpec.NoexceptExpr->isValueDependent() ||
2912 epi.ExceptionSpec.NoexceptExpr->isInstantiationDependent())
2915 if (epi.ExceptionSpec.NoexceptExpr->containsUnexpandedParameterPack())
2922 auto **slot = getTrailingObjects<FunctionDecl *>();
2923 slot[0] = epi.ExceptionSpec.SourceDecl;
2924 slot[1] = epi.ExceptionSpec.SourceTemplate;
2930 auto **slot = getTrailingObjects<FunctionDecl *>();
2931 slot[0] = epi.ExceptionSpec.SourceDecl;
2939 assert(hasDependentExceptionSpec() &&
"type should not be canonical");
2948 if (epi.ExtParameterInfos) {
2949 auto *extParamInfos = getTrailingObjects<ExtParameterInfo>();
2950 for (
unsigned i = 0; i != getNumParams(); ++i)
2951 extParamInfos[i] = epi.ExtParameterInfos[i];
2954 if (epi.TypeQuals.hasNonFastQualifiers()) {
2956 *getTrailingObjects<Qualifiers>() = epi.TypeQuals;
2963 if (
Expr *NE = getNoexceptExpr())
2964 return NE->isValueDependent();
2975 if (
Expr *NE = getNoexceptExpr())
2976 return NE->isInstantiationDependent();
2978 if (ET->isInstantiationDependentType())
2984 switch (getExceptionSpecType()) {
2988 llvm_unreachable(
"should not call this with unresolved exception specs");
3003 for (
unsigned I = 0; I != getNumExceptions(); ++I)
3012 llvm_unreachable(
"unexpected exception specification kind");
3016 for (
unsigned ArgIdx = getNumParams(); ArgIdx; --ArgIdx)
3024 const QualType *ArgTys,
unsigned NumParams,
3045 for (
unsigned i = 0; i != NumParams; ++i)
3050 assert(!(
unsigned(epi.
Variadic) & ~1) &&
3053 "Values larger than expected.");
3068 for (
unsigned i = 0; i != NumParams; ++i)
3077 Profile(ID, getReturnType(), param_type_begin(), getNumParams(),
3082 return getDecl()->getUnderlyingType();
3086 :
Type(TypeOfExpr, can, E->isTypeDependent(),
3087 E->isInstantiationDependent(),
3105 E->
Profile(ID, Context,
true);
3112 :
Type(Decltype, can, E->isInstantiationDependent(),
3113 E->isInstantiationDependent(),
3116 E(E), UnderlyingType(underlyingType) {}
3128 :
DecltypeType(E, Context.DependentTy), Context(Context) {}
3132 E->
Profile(ID, Context,
true);
3143 BaseType(BaseType), UnderlyingType(UnderlyingType), UKind(UKind) {}
3158 for (
auto I : decl->
redecls()) {
3159 if (I->isCompleteDefinition() || I->isBeingDefined())
3175 std::vector<const RecordType*> RecordTypeList;
3176 RecordTypeList.push_back(
this);
3177 unsigned NextToCheckIndex = 0;
3179 while (RecordTypeList.size() > NextToCheckIndex) {
3181 RecordTypeList[NextToCheckIndex]->
getDecl()->fields()) {
3187 if (llvm::find(RecordTypeList, FieldRecTy) == RecordTypeList.end())
3188 RecordTypeList.push_back(FieldRecTy);
3198 switch (getAttrKind()) {
3203 case attr::ObjCOwnership:
3204 case attr::ObjCInertUnsafeUnretained:
3205 case attr::TypeNonNull:
3206 case attr::TypeNullable:
3207 case attr::TypeNullUnspecified:
3208 case attr::LifetimeBound:
3220 switch (getAttrKind()) {
3221 default:
return false;
3228 llvm_unreachable(
"invalid attr kind");
3233 switch (getAttrKind()) {
3234 default:
return false;
3237 case attr::FastCall:
3239 case attr::ThisCall:
3241 case attr::SwiftCall:
3242 case attr::VectorCall:
3243 case attr::AArch64VectorPcs:
3247 case attr::IntelOclBicc:
3248 case attr::PreserveMost:
3249 case attr::PreserveAll:
3252 llvm_unreachable(
"invalid attr kind");
3263 SubstTemplateTypeParmPackType::
3267 :
Type(SubstTemplateTypeParmPack, Canon,
true,
true,
false,
true),
3268 Replaced(Param), Arguments(ArgPack.
pack_begin()) {
3277 Profile(ID, getReplacedParameter(), getArgumentPack());
3283 ID.AddPointer(Replaced);
3286 ID.AddPointer(
P.getAsType().getAsOpaquePtr());
3291 bool &InstantiationDependent) {
3292 return anyDependentTemplateArguments(Args.
arguments(),
3293 InstantiationDependent);
3298 bool &InstantiationDependent) {
3300 if (ArgLoc.getArgument().isDependent()) {
3301 InstantiationDependent =
true;
3305 if (ArgLoc.getArgument().isInstantiationDependent())
3306 InstantiationDependent =
true;
3311 TemplateSpecializationType::
3315 :
Type(TemplateSpecialization,
3325 "Use DependentTemplateSpecializationType for dependent template-name");
3329 "Unexpected template name for TemplateSpecializationType");
3341 if (Arg.isInstantiationDependent())
3344 Arg.getAsType()->isVariablyModifiedType())
3346 if (Arg.containsUnexpandedParameterPack())
3352 if (isTypeAlias()) {
3354 *
reinterpret_cast<QualType*
>(
Begin + getNumArgs()) = AliasedType;
3365 Arg.Profile(ID, Context);
3370 if (!hasNonFastQualifiers())
3378 if (!hasNonFastQualifiers())
3379 return QualType(T, getFastQualifiers());
3390 ID.AddInteger(typeArgs.size());
3391 for (
auto typeArg : typeArgs)
3392 ID.AddPointer(typeArg.getAsOpaquePtr());
3393 ID.AddInteger(protocols.size());
3394 for (
auto proto : protocols)
3395 ID.AddPointer(proto);
3396 ID.AddBoolean(isKindOf);
3400 Profile(ID, getBaseType(), getTypeArgsAsWritten(),
3401 llvm::makeArrayRef(qual_begin(), getNumProtocols()),
3402 isKindOfTypeAsWritten());
3408 ID.AddPointer(OTPDecl);
3409 ID.AddInteger(protocols.size());
3410 for (
auto proto : protocols)
3411 ID.AddPointer(proto);
3416 llvm::makeArrayRef(qual_begin(), getNumProtocols()));
3422 class CachedProperties {
3427 CachedProperties(
Linkage L,
bool local) : L(L), local(local) {}
3430 bool hasLocalOrUnnamedType()
const {
return local; }
3432 friend CachedProperties merge(CachedProperties L, CachedProperties R) {
3434 return CachedProperties(MergedLinkage,
3435 L.hasLocalOrUnnamedType() | R.hasLocalOrUnnamedType());
3451 return get(T.getTypePtr());
3454 static CachedProperties
get(
const Type *T) {
3456 return CachedProperties(T->
TypeBits.getLinkage(),
3457 T->
TypeBits.hasLocalOrUnnamedType());
3462 if (T->
TypeBits.isCacheValid())
return;
3478 T->
TypeBits.CachedLinkage = Result.getLinkage();
3479 T->
TypeBits.CachedLocalOrUnnamed = Result.hasLocalOrUnnamedType();
3498 #define TYPE(Class,Base) 3499 #define NON_CANONICAL_TYPE(Class,Base) case Type::Class: 3500 #include "clang/AST/TypeNodes.def" 3501 llvm_unreachable(
"didn't expect a non-canonical type here");
3503 #define TYPE(Class,Base) 3504 #define DEPENDENT_TYPE(Class,Base) case Type::Class: 3505 #define NON_CANONICAL_UNLESS_DEPENDENT_TYPE(Class,Base) case Type::Class: 3506 #include "clang/AST/TypeNodes.def" 3512 case Type::DeducedTemplateSpecialization:
3532 bool IsLocalOrUnnamed =
3535 return CachedProperties(L, IsLocalOrUnnamed);
3542 return Cache::get(cast<ComplexType>(T)->getElementType());
3545 case Type::BlockPointer:
3547 case Type::LValueReference:
3548 case Type::RValueReference:
3550 case Type::MemberPointer: {
3551 const auto *MPT = cast<MemberPointerType>(T);
3555 case Type::ConstantArray:
3556 case Type::IncompleteArray:
3557 case Type::VariableArray:
3558 return Cache::get(cast<ArrayType>(T)->getElementType());
3560 case Type::ExtVector:
3561 return Cache::get(cast<VectorType>(T)->getElementType());
3562 case Type::FunctionNoProto:
3563 return Cache::get(cast<FunctionType>(T)->getReturnType());
3564 case Type::FunctionProto: {
3565 const auto *FPT = cast<FunctionProtoType>(T);
3566 CachedProperties result =
Cache::get(FPT->getReturnType());
3567 for (
const auto &ai : FPT->param_types())
3571 case Type::ObjCInterface: {
3573 return CachedProperties(L,
false);
3575 case Type::ObjCObject:
3576 return Cache::get(cast<ObjCObjectType>(T)->getBaseType());
3577 case Type::ObjCObjectPointer:
3580 return Cache::get(cast<AtomicType>(T)->getValueType());
3582 return Cache::get(cast<PipeType>(T)->getElementType());
3585 llvm_unreachable(
"unhandled type class");
3596 return TypeBits.hasLocalOrUnnamedType();
3601 #define TYPE(Class,Base) 3602 #define NON_CANONICAL_TYPE(Class,Base) case Type::Class: 3603 #include "clang/AST/TypeNodes.def" 3604 llvm_unreachable(
"didn't expect a non-canonical type here");
3606 #define TYPE(Class,Base) 3607 #define DEPENDENT_TYPE(Class,Base) case Type::Class: 3608 #define NON_CANONICAL_UNLESS_DEPENDENT_TYPE(Class,Base) case Type::Class: 3609 #include "clang/AST/TypeNodes.def" 3618 case Type::DeducedTemplateSpecialization:
3623 return getDeclLinkageAndVisibility(cast<TagType>(T)->
getDecl());
3626 return computeTypeLinkageInfo(cast<ComplexType>(T)->getElementType());
3628 return computeTypeLinkageInfo(cast<PointerType>(T)->
getPointeeType());
3629 case Type::BlockPointer:
3630 return computeTypeLinkageInfo(cast<BlockPointerType>(T)->
getPointeeType());
3631 case Type::LValueReference:
3632 case Type::RValueReference:
3633 return computeTypeLinkageInfo(cast<ReferenceType>(T)->
getPointeeType());
3634 case Type::MemberPointer: {
3635 const auto *MPT = cast<MemberPointerType>(T);
3636 LinkageInfo LV = computeTypeLinkageInfo(MPT->getClass());
3637 LV.
merge(computeTypeLinkageInfo(MPT->getPointeeType()));
3640 case Type::ConstantArray:
3641 case Type::IncompleteArray:
3642 case Type::VariableArray:
3643 return computeTypeLinkageInfo(cast<ArrayType>(T)->getElementType());
3645 case Type::ExtVector:
3646 return computeTypeLinkageInfo(cast<VectorType>(T)->getElementType());
3647 case Type::FunctionNoProto:
3648 return computeTypeLinkageInfo(cast<FunctionType>(T)->getReturnType());
3649 case Type::FunctionProto: {
3650 const auto *FPT = cast<FunctionProtoType>(T);
3651 LinkageInfo LV = computeTypeLinkageInfo(FPT->getReturnType());
3652 for (
const auto &ai : FPT->param_types())
3653 LV.
merge(computeTypeLinkageInfo(ai));
3656 case Type::ObjCInterface:
3657 return getDeclLinkageAndVisibility(cast<ObjCInterfaceType>(T)->
getDecl());
3658 case Type::ObjCObject:
3659 return computeTypeLinkageInfo(cast<ObjCObjectType>(T)->getBaseType());
3660 case Type::ObjCObjectPointer:
3661 return computeTypeLinkageInfo(
3664 return computeTypeLinkageInfo(cast<AtomicType>(T)->getValueType());
3666 return computeTypeLinkageInfo(cast<PipeType>(T)->getElementType());
3669 llvm_unreachable(
"unhandled type class");
3701 if (
auto Nullability = AT->getImmediateNullability())
3704 Type = AT->getEquivalentType();
3714 #define NON_CANONICAL_TYPE(Class, Parent) \ 3716 llvm_unreachable("non-canonical type"); 3717 #define TYPE(Class, Parent) 3718 #include "clang/AST/TypeNodes.def" 3722 case Type::BlockPointer:
3723 case Type::MemberPointer:
3724 case Type::ObjCObjectPointer:
3728 case Type::UnresolvedUsing:
3729 case Type::TypeOfExpr:
3731 case Type::Decltype:
3732 case Type::UnaryTransform:
3733 case Type::TemplateTypeParm:
3734 case Type::SubstTemplateTypeParmPack:
3735 case Type::DependentName:
3736 case Type::DependentTemplateSpecialization:
3738 return ResultIfUnknown;
3743 case Type::TemplateSpecialization:
3745 = cast<TemplateSpecializationType>(type.
getTypePtr())
3746 ->getTemplateName().getAsTemplateDecl()) {
3747 if (isa<ClassTemplateDecl>(templateDecl))
3750 return ResultIfUnknown;
3755 #define SIGNED_TYPE(Id, SingletonId) case BuiltinType::Id: 3756 #define UNSIGNED_TYPE(Id, SingletonId) case BuiltinType::Id: 3757 #define FLOATING_TYPE(Id, SingletonId) case BuiltinType::Id: 3758 #define BUILTIN_TYPE(Id, SingletonId) 3759 #include "clang/AST/BuiltinTypes.def" 3763 case BuiltinType::Dependent:
3764 case BuiltinType::Overload:
3765 case BuiltinType::BoundMember:
3766 case BuiltinType::PseudoObject:
3767 case BuiltinType::UnknownAny:
3768 case BuiltinType::ARCUnbridgedCast:
3769 return ResultIfUnknown;
3771 case BuiltinType::Void:
3772 case BuiltinType::ObjCId:
3773 case BuiltinType::ObjCClass:
3774 case BuiltinType::ObjCSel:
3775 #define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \ 3776 case BuiltinType::Id: 3777 #include "clang/Basic/OpenCLImageTypes.def" 3778 #define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \ 3779 case BuiltinType::Id: 3780 #include "clang/Basic/OpenCLExtensionTypes.def" 3781 case BuiltinType::OCLSampler:
3782 case BuiltinType::OCLEvent:
3783 case BuiltinType::OCLClkEvent:
3784 case BuiltinType::OCLQueue:
3785 case BuiltinType::OCLReserveID:
3786 case BuiltinType::BuiltinFn:
3787 case BuiltinType::NullPtr:
3788 case BuiltinType::OMPArraySection:
3791 llvm_unreachable(
"unknown builtin type");
3795 case Type::LValueReference:
3796 case Type::RValueReference:
3797 case Type::ConstantArray:
3798 case Type::IncompleteArray:
3799 case Type::VariableArray:
3800 case Type::DependentSizedArray:
3801 case Type::DependentVector:
3802 case Type::DependentSizedExtVector:
3804 case Type::ExtVector:
3805 case Type::DependentAddressSpace:
3806 case Type::FunctionProto:
3807 case Type::FunctionNoProto:
3809 case Type::DeducedTemplateSpecialization:
3811 case Type::InjectedClassName:
3812 case Type::PackExpansion:
3813 case Type::ObjCObject:
3814 case Type::ObjCInterface:
3819 llvm_unreachable(
"bad type kind!");
3824 if (getAttrKind() == attr::TypeNonNull)
3826 if (getAttrKind() == attr::TypeNullable)
3828 if (getAttrKind() == attr::TypeNullUnspecified)
3834 if (
auto attributed = dyn_cast<AttributedType>(T.
getTypePtr())) {
3835 if (
auto nullability = attributed->getImmediateNullability()) {
3836 T = attributed->getModifiedType();
3845 const auto *objcPtr = getAs<ObjCObjectPointerType>();
3849 if (objcPtr->isObjCIdType()) {
3860 }
else if (objcPtr->isObjCQualifiedIdType()) {
3885 "cannot query implicit lifetime for non-inferrable type");
3890 while (
const auto *array = dyn_cast<ArrayType>(canon))
3891 canon = array->getElementType().getTypePtr();
3893 if (
const auto *opt = dyn_cast<ObjCObjectPointerType>(canon)) {
3895 if (opt->getObjectType()->isObjCClass())
3903 const Type *cur =
this;
3905 if (
const auto *
typedefType = dyn_cast<TypedefType>(cur))
3906 return typedefType->getDecl()->hasAttr<ObjCNSObjectAttr>();
3910 if (next.getTypePtr() == cur)
return false;
3911 cur = next.getTypePtr();
3916 if (
const auto *
typedefType = dyn_cast<TypedefType>(
this))
3917 return typedefType->getDecl()->hasAttr<ObjCIndependentClassAttr>();
3930 if (
const auto *OPT = getAs<PointerType>())
3931 return OPT->getPointeeType()->isObjCIndirectLifetimeType();
3932 if (
const auto *Ref = getAs<ReferenceType>())
3933 return Ref->getPointeeType()->isObjCIndirectLifetimeType();
3934 if (
const auto *MemPtr = getAs<MemberPointerType>())
3935 return MemPtr->getPointeeType()->isObjCIndirectLifetimeType();
3942 const Type *type =
this;
3944 type = array->getElementType().getTypePtr();
3956 const auto *
Pointer = getAs<PointerType>();
3967 if (
const auto *ptr = getAs<PointerType>())
3968 return ptr->getPointeeType()->hasSizedVLAType();
3969 if (
const auto *ref = getAs<ReferenceType>())
3970 return ref->getPointeeType()->hasSizedVLAType();
3972 if (isa<VariableArrayType>(arr) &&
3973 cast<VariableArrayType>(arr)->getSizeExpr())
3976 return arr->getElementType()->hasSizedVLAType();
3990 return DK_objc_strong_lifetime;
3992 return DK_objc_weak_lifetime;
3995 if (
const auto *RT =
3998 if (
const auto *CXXRD = dyn_cast<CXXRecordDecl>(RD)) {
4000 if (CXXRD->hasDefinition() && !CXXRD->hasTrivialDestructor())
4001 return DK_cxx_destructor;
4006 return DK_nontrivial_c_struct;
4018 llvm::APSInt Val,
unsigned Scale) {
4019 if (Val.isSigned() && Val.isNegative() && Val != -Val) {
4024 llvm::APSInt IntPart = Val >> Scale;
4027 unsigned Width = Val.getBitWidth() + 4;
4028 llvm::APInt FractPart = Val.zextOrTrunc(Scale).zext(Width);
4029 llvm::APInt FractPartMask = llvm::APInt::getAllOnesValue(Scale).zext(Width);
4030 llvm::APInt RadixInt = llvm::APInt(Width, 10);
4032 IntPart.toString(Str, 10);
4035 (FractPart * RadixInt)
4037 .toString(Str, 10, Val.isSigned());
4038 FractPart = (FractPart * RadixInt) & FractPartMask;
4039 }
while (FractPart != 0);
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)
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 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
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
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.
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
unsigned char getOpaqueValue() 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).
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.
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
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.
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 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 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'.
QualType getAutoType(QualType DeducedType, AutoTypeKeyword Keyword, bool IsDependent) const
C++11 deduced auto type.
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
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.
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
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)
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
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.
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.
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
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.
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.
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.
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.