25 #include "llvm/ADT/APSInt.h"
26 #include "llvm/ADT/StringExtras.h"
27 #include "llvm/Support/raw_ostream.h"
29 using namespace clang;
32 return (*
this != Other) &&
71 return AT->getElementType().isConstant(Ctx);
78 const llvm::APInt &NumElements) {
87 if (llvm::isPowerOf2_64(ElementSize)) {
88 return NumElements.getActiveBits() + llvm::Log2_64(ElementSize);
93 if ((ElementSize >> 32) == 0 && NumElements.getBitWidth() <= 64 &&
94 (NumElements.getZExtValue() >> 32) == 0) {
95 uint64_t TotalSize = NumElements.getZExtValue() * ElementSize;
96 return 64 - llvm::countLeadingZeros(TotalSize);
100 llvm::APSInt SizeExtended(NumElements,
true);
102 SizeExtended = SizeExtended.extend(std::max(SizeTypeBits,
103 SizeExtended.getBitWidth()) * 2);
105 llvm::APSInt TotalSize(llvm::APInt(SizeExtended.getBitWidth(), ElementSize));
106 TotalSize *= SizeExtended;
108 return TotalSize.getActiveBits();
125 Expr *e, ArraySizeModifier sm,
128 :
ArrayType(DependentSizedArray, et, can, sm, tq,
129 (et->containsUnexpandedParameterPack() ||
130 (e && e->containsUnexpandedParameterPack()))),
131 Context(Context), SizeExpr((
Stmt*) e), Brackets(brackets)
142 ID.AddInteger(SizeMod);
143 ID.AddInteger(TypeQuals);
144 E->Profile(ID, Context,
true);
147 DependentSizedExtVectorType::DependentSizedExtVectorType(
const
153 :
Type(DependentSizedExtVector, can,
true,
155 ElementType->isVariablyModifiedType(),
156 (ElementType->containsUnexpandedParameterPack() ||
157 (SizeExpr && SizeExpr->containsUnexpandedParameterPack()))),
158 Context(Context), SizeExpr(SizeExpr), ElementType(ElementType),
168 SizeExpr->Profile(ID, Context,
true);
173 :
VectorType(Vector, vecType, nElements, canonType, vecKind) {}
177 :
Type(tc, canonType, vecType->isDependentType(),
178 vecType->isInstantiationDependentType(),
179 vecType->isVariablyModifiedType(),
180 vecType->containsUnexpandedParameterPack()),
192 if (
const ArrayType *ATy = dyn_cast<ArrayType>(
this))
193 return ATy->getElementType().getTypePtr();
196 if (!isa<ArrayType>(CanonicalType))
225 #define ABSTRACT_TYPE(Class, Parent)
226 #define TYPE(Class, Parent) \
227 case Type::Class: { \
228 const Class##Type *ty = cast<Class##Type>(this); \
229 if (!ty->isSugared()) return QualType(ty, 0); \
230 return ty->desugar(); \
232 #include "clang/AST/TypeNodes.def"
234 llvm_unreachable(
"bad type kind!");
244 #define ABSTRACT_TYPE(Class, Parent)
245 #define TYPE(Class, Parent) \
246 case Type::Class: { \
247 const Class##Type *Ty = cast<Class##Type>(CurTy); \
248 if (!Ty->isSugared()) \
249 return SplitQualType(Ty, Qs); \
250 Cur = Ty->desugar(); \
253 #include "clang/AST/TypeNodes.def"
265 const Type *lastTypeWithQuals = split.
Ty;
273 #define ABSTRACT_TYPE(Class, Parent)
274 #define TYPE(Class, Parent) \
275 case Type::Class: { \
276 const Class##Type *ty = cast<Class##Type>(split.Ty); \
277 if (!ty->isSugared()) goto done; \
278 next = ty->desugar(); \
281 #include "clang/AST/TypeNodes.def"
286 split = next.
split();
288 lastTypeWithQuals = split.
Ty;
300 T = PT->getInnerType();
309 if (
const T *Sugar = dyn_cast<T>(Cur))
312 #define ABSTRACT_TYPE(Class, Parent)
313 #define TYPE(Class, Parent) \
314 case Type::Class: { \
315 const Class##Type *Ty = cast<Class##Type>(Cur); \
316 if (!Ty->isSugared()) return 0; \
317 Cur = Ty->desugar().getTypePtr(); \
320 #include "clang/AST/TypeNodes.def"
326 return getAsSugar<TypedefType>(
this);
330 return getAsSugar<TemplateSpecializationType>(
this);
334 return getAsSugar<AttributedType>(
this);
341 const Type *Cur =
this;
345 #define ABSTRACT_TYPE(Class, Parent)
346 #define TYPE(Class, Parent) \
348 const Class##Type *Ty = cast<Class##Type>(Cur); \
349 if (!Ty->isSugared()) return Cur; \
350 Cur = Ty->desugar().getTypePtr(); \
353 #include "clang/AST/TypeNodes.def"
358 if (
const RecordType *RT = getAs<RecordType>())
359 return RT->getDecl()->isClass();
363 if (
const RecordType *RT = getAs<RecordType>())
364 return RT->getDecl()->isStruct();
368 if (
const RecordType *RT = getAs<RecordType>())
369 return RT->getDecl()->hasAttr<ObjCBoxableAttr>();
373 if (
const RecordType *RT = getAs<RecordType>())
374 return RT->getDecl()->isInterface();
378 if (
const RecordType *RT = getAs<RecordType>()) {
386 return PT->getPointeeType()->isVoidType();
391 if (
const RecordType *RT = getAs<RecordType>())
392 return RT->getDecl()->isUnion();
397 if (
const ComplexType *CT = dyn_cast<ComplexType>(CanonicalType))
398 return CT->getElementType()->isFloatingType();
408 if (
const ComplexType *Complex = getAs<ComplexType>())
409 if (Complex->getElementType()->isIntegerType())
432 if (
const RecordType *RT = dyn_cast<RecordType>(
this)) {
433 if (RT->getDecl()->isStruct())
438 if (
const RecordType *RT = dyn_cast<RecordType>(CanonicalType)) {
439 if (!RT->getDecl()->isStruct())
451 if (
const RecordType *RT = dyn_cast<RecordType>(
this)) {
452 if (RT->getDecl()->isUnion())
457 if (
const RecordType *RT = dyn_cast<RecordType>(CanonicalType)) {
458 if (!RT->getDecl()->isUnion())
516 :
Type(ObjCObject, Canonical, Base->isDependentType(),
517 Base->isInstantiationDependentType(),
518 Base->isVariablyModifiedType(),
519 Base->containsUnexpandedParameterPack()),
526 "bitfield overflow in type argument count");
529 "bitfield overflow in protocol count");
530 if (!typeArgs.empty())
531 memcpy(getTypeArgStorage(), typeArgs.data(),
532 typeArgs.size() *
sizeof(
QualType));
533 if (!protocols.empty())
534 memcpy(getProtocolStorage(), protocols.data(),
537 for (
auto typeArg : typeArgs) {
538 if (typeArg->isDependentType())
540 else if (typeArg->isInstantiationDependentType())
543 if (typeArg->containsUnexpandedParameterPack())
554 if (
auto objcObject =
getBaseType()->getAs<ObjCObjectType>()) {
556 if (isa<ObjCInterfaceType>(objcObject))
559 return objcObject->isSpecialized();
572 if (
auto objcObject =
getBaseType()->getAs<ObjCObjectType>()) {
574 if (isa<ObjCInterfaceType>(objcObject))
577 return objcObject->getTypeArgs();
589 if (
auto objcObject =
getBaseType()->getAs<ObjCObjectType>()) {
591 if (isa<ObjCInterfaceType>(objcObject))
594 return objcObject->isKindOfType();
611 baseType = baseObj->stripObjCKindOfTypeAndQuals(ctx);
615 splitBaseType.
Quals),
637 struct SimpleTransformVisitor
638 :
public TypeVisitor<SimpleTransformVisitor<F>, QualType> {
643 return simpleTransform(Ctx, type, std::move(TheFunc));
647 SimpleTransformVisitor(
ASTContext &ctx, F &&f) : Ctx(ctx), TheFunc(std::move(f)) { }
651 #define TYPE(Class, Base)
652 #define DEPENDENT_TYPE(Class, Base) \
653 QualType Visit##Class##Type(const Class##Type *T) { return QualType(T, 0); }
654 #include "clang/AST/TypeNodes.def"
656 #define TRIVIAL_TYPE_CLASS(Class) \
657 QualType Visit##Class##Type(const Class##Type *T) { return QualType(T, 0); }
662 QualType elementType = recurse(T->getElementType());
666 if (elementType.
getAsOpaquePtr() == T->getElementType().getAsOpaquePtr())
809 bool paramChanged =
false;
811 QualType newParamType = recurse(paramType);
812 if (newParamType.
isNull())
818 paramTypes.push_back(newParamType);
823 bool exceptionChanged =
false;
827 QualType newExceptionType = recurse(exceptionType);
828 if (newExceptionType.
isNull())
832 != exceptionType.getAsOpaquePtr())
833 exceptionChanged =
true;
835 exceptionTypes.push_back(newExceptionType);
838 if (exceptionChanged) {
839 unsigned size =
sizeof(
QualType) * exceptionTypes.size();
840 void *mem = Ctx.
Allocate(size, llvm::alignOf<QualType>());
841 memcpy(mem, exceptionTypes.data(), size);
843 = llvm::makeArrayRef((
QualType *)mem, exceptionTypes.size());
848 !paramChanged && !exceptionChanged)
868 QualType originalType = recurse(T->getOriginalType());
869 if (originalType.
isNull())
872 QualType adjustedType = recurse(T->getAdjustedType());
873 if (adjustedType.
isNull())
877 == T->getOriginalType().getAsOpaquePtr() &&
878 adjustedType.
getAsOpaquePtr() == T->getAdjustedType().getAsOpaquePtr())
886 if (originalType.
isNull())
907 QualType modifiedType = recurse(T->getModifiedType());
908 if (modifiedType.
isNull())
911 QualType equivalentType = recurse(T->getEquivalentType());
912 if (equivalentType.
isNull())
916 == T->getModifiedType().getAsOpaquePtr() &&
918 == T->getEquivalentType().getAsOpaquePtr())
927 if (replacementType.
isNull())
945 QualType deducedType = recurse(T->getDeducedType());
950 == T->getDeducedType().getAsOpaquePtr())
953 return Ctx.
getAutoType(deducedType, T->isDecltypeAuto(),
961 QualType baseType = recurse(T->getBaseType());
966 bool typeArgChanged =
false;
968 for (
auto typeArg : T->getTypeArgsAsWritten()) {
969 QualType newTypeArg = recurse(typeArg);
974 typeArgChanged =
true;
976 typeArgs.push_back(newTypeArg);
979 if (baseType.
getAsOpaquePtr() == T->getBaseType().getAsOpaquePtr() &&
984 llvm::makeArrayRef(T->qual_begin(),
985 T->getNumProtocols()),
986 T->isKindOfTypeAsWritten());
992 QualType pointeeType = recurse(T->getPointeeType());
997 == T->getPointeeType().getAsOpaquePtr())
1015 #undef TRIVIAL_TYPE_CLASS
1020 template<
typename F>
1031 SimpleTransformVisitor<F> visitor(ctx, std::move(f));
1032 QualType result = visitor.Visit(splitType.
Ty);
1049 return simpleTransform(ctx, *
this,
1055 if (
const auto *typedefTy = dyn_cast<TypedefType>(splitType.
Ty)) {
1056 if (
auto *typeParam = dyn_cast<ObjCTypeParamDecl>(typedefTy->getDecl())) {
1058 if (!typeArgs.empty()) {
1060 QualType argType = typeArgs[typeParam->getIndex()];
1075 const auto *objPtr = typeParam->getUnderlyingType()
1080 if (objPtr->isKindOfType() || objPtr->isObjCIdOrClassType())
1085 const auto *obj = objPtr->getObjectType();
1087 obj->getTypeArgsAsWritten(),
1088 obj->getProtocols(),
1100 if (
const auto *funcType = dyn_cast<FunctionType>(splitType.
Ty)) {
1102 QualType returnType = funcType->getReturnType().substObjCTypeArgs(
1111 if (isa<FunctionNoProtoType>(funcType)) {
1114 == funcType->getReturnType().getAsOpaquePtr())
1121 const auto *funcProtoType = cast<FunctionProtoType>(funcType);
1125 bool paramChanged =
false;
1126 for (
auto paramType : funcProtoType->getParamTypes()) {
1131 if (newParamType.
isNull())
1135 paramChanged =
true;
1137 paramTypes.push_back(newParamType);
1142 bool exceptionChanged =
false;
1150 if (newExceptionType.
isNull())
1154 != exceptionType.getAsOpaquePtr())
1155 exceptionChanged =
true;
1157 exceptionTypes.push_back(newExceptionType);
1160 if (exceptionChanged) {
1161 unsigned size =
sizeof(
QualType) * exceptionTypes.size();
1162 void *mem = ctx.
Allocate(size, llvm::alignOf<QualType>());
1163 memcpy(mem, exceptionTypes.data(), size);
1165 = llvm::makeArrayRef((
QualType *)mem, exceptionTypes.size());
1170 == funcProtoType->getReturnType().getAsOpaquePtr() &&
1171 !paramChanged && !exceptionChanged)
1179 if (
const auto *objcObjectType = dyn_cast<ObjCObjectType>(splitType.
Ty)) {
1180 if (objcObjectType->isSpecializedAsWritten()) {
1182 bool anyChanged =
false;
1183 for (
auto typeArg : objcObjectType->getTypeArgsAsWritten()) {
1194 objcObjectType->qual_begin(),
1195 objcObjectType->getNumProtocols());
1196 if (typeArgs.empty() &&
1199 objcObjectType->getBaseType(), { },
1201 objcObjectType->isKindOfTypeAsWritten());
1207 newTypeArgs.push_back(newTypeArg);
1212 objcObjectType->qual_begin(),
1213 objcObjectType->getNumProtocols());
1215 newTypeArgs, protocols,
1216 objcObjectType->isKindOfTypeAsWritten());
1238 auto &ctx =
const_cast<ASTContext &
>(constCtx);
1239 return simpleTransform(ctx, *
this,
1243 if (!objType->isKindOfType())
1247 = objType->getBaseType().stripObjCKindOfType(ctx);
1250 objType->getTypeArgsAsWritten(),
1251 objType->getProtocols(),
1263 if (
auto method = dyn_cast<ObjCMethodDecl>(dc))
1264 dc = method->getDeclContext();
1281 if (!dcCategoryDecl)
1286 dcTypeParams = dcCategoryDecl->getTypeParamList();
1290 dcClassDecl = dcCategoryDecl->getClassInterface();
1294 assert(dcTypeParams &&
"No substitutions to perform");
1295 assert(dcClassDecl &&
"No class context");
1299 if (
const auto *objectPointerType = getAs<ObjCObjectPointerType>()) {
1300 objectType = objectPointerType->getObjectType();
1301 }
else if (getAs<BlockPointerType>()) {
1304 ->castAs<ObjCObjectType>();;
1306 objectType = getAs<ObjCObjectType>();
1312 if (!curClassDecl) {
1320 while (curClassDecl != dcClassDecl) {
1322 QualType superType = objectType->getSuperClassType();
1323 if (superType.
isNull()) {
1324 objectType =
nullptr;
1334 if (!objectType || objectType->isUnspecialized()) {
1339 return objectType->getTypeArgs();
1342 bool Type::acceptsObjCTypeParams()
const {
1344 if (
auto *
ID = IfaceT->getInterface()) {
1345 if (
ID->getTypeParamList())
1359 CachedSuperClassType.setInt(
true);
1365 if (!superClassObjTy) {
1366 CachedSuperClassType.setInt(
true);
1371 if (!superClassDecl) {
1372 CachedSuperClassType.setInt(
true);
1378 QualType superClassType(superClassObjTy, 0);
1380 if (!superClassTypeParams) {
1381 CachedSuperClassType.setPointerAndInt(
1388 CachedSuperClassType.setPointerAndInt(superClassObjTy,
true);
1396 CachedSuperClassType.setPointerAndInt(
1407 CachedSuperClassType.setPointerAndInt(
1415 assert(typeArgs.size() == typeParams->
size());
1416 CachedSuperClassType.setPointerAndInt(
1419 ->castAs<ObjCObjectType>(),
1425 return interfaceDecl->getASTContext().getObjCInterfaceType(interfaceDecl)
1434 if (superObjectType.
isNull())
1435 return superObjectType;
1446 if (T->getNumProtocols() && T->getInterface())
1459 if (OPT->isObjCQualifiedIdType())
1469 if (OPT->isObjCQualifiedClassType())
1477 if (OT->getInterface())
1484 if (OPT->getInterfaceType())
1506 return dyn_cast_or_null<CXXRecordDecl>(
getAsTagDecl());
1510 if (
const auto *TT = getAs<TagType>())
1511 return cast<TagDecl>(TT->getDecl());
1512 if (
const auto *Injected = getAs<InjectedClassNameType>())
1513 return Injected->getDecl();
1519 class GetContainedAutoVisitor :
1520 public TypeVisitor<GetContainedAutoVisitor, AutoType*> {
1550 AutoType *VisitDependentSizedExtVectorType(
1573 return GetContainedAutoVisitor().Visit(
this);
1577 if (
const VectorType *VT = dyn_cast<VectorType>(CanonicalType))
1578 return VT->getElementType()->isIntegerType();
1603 if (
const BuiltinType *BT = dyn_cast<BuiltinType>(CanonicalType))
1604 return BT->getKind() >= BuiltinType::Bool &&
1605 BT->getKind() <= BuiltinType::Int128;
1609 if (
const EnumType *ET = dyn_cast<EnumType>(CanonicalType))
1610 return ET->getDecl()->isComplete();
1617 if (
const BuiltinType *BT = dyn_cast<BuiltinType>(CanonicalType))
1618 return BT->getKind() >= BuiltinType::Bool &&
1619 BT->getKind() <= BuiltinType::Int128;
1625 if (
const EnumType *ET = dyn_cast<EnumType>(CanonicalType))
1626 return ET->getDecl()->isComplete() && !ET->getDecl()->isScoped();
1634 if (
const BuiltinType *BT = dyn_cast<BuiltinType>(CanonicalType))
1635 return BT->getKind() == BuiltinType::Char_U ||
1636 BT->getKind() == BuiltinType::UChar ||
1637 BT->getKind() == BuiltinType::Char_S ||
1638 BT->getKind() == BuiltinType::SChar;
1643 if (
const BuiltinType *BT = dyn_cast<BuiltinType>(CanonicalType))
1644 return BT->getKind() == BuiltinType::WChar_S ||
1645 BT->getKind() == BuiltinType::WChar_U;
1650 if (
const BuiltinType *BT = dyn_cast<BuiltinType>(CanonicalType))
1651 return BT->getKind() == BuiltinType::Char16;
1656 if (
const BuiltinType *BT = dyn_cast<BuiltinType>(CanonicalType))
1657 return BT->getKind() == BuiltinType::Char32;
1665 if (!BT)
return false;
1667 default:
return false;
1668 case BuiltinType::Char_U:
1669 case BuiltinType::UChar:
1670 case BuiltinType::WChar_U:
1671 case BuiltinType::Char16:
1672 case BuiltinType::Char32:
1673 case BuiltinType::Char_S:
1674 case BuiltinType::SChar:
1675 case BuiltinType::WChar_S:
1684 if (
const BuiltinType *BT = dyn_cast<BuiltinType>(CanonicalType)) {
1685 return BT->getKind() >= BuiltinType::Char_S &&
1686 BT->getKind() <= BuiltinType::Int128;
1689 if (
const EnumType *ET = dyn_cast<EnumType>(CanonicalType)) {
1692 if (ET->getDecl()->isComplete() && !ET->getDecl()->isScoped())
1693 return ET->getDecl()->getIntegerType()->isSignedIntegerType();
1700 if (
const BuiltinType *BT = dyn_cast<BuiltinType>(CanonicalType)) {
1701 return BT->getKind() >= BuiltinType::Char_S &&
1702 BT->getKind() <= BuiltinType::Int128;
1705 if (
const EnumType *ET = dyn_cast<EnumType>(CanonicalType)) {
1706 if (ET->getDecl()->isComplete())
1707 return ET->getDecl()->getIntegerType()->isSignedIntegerType();
1714 if (
const VectorType *VT = dyn_cast<VectorType>(CanonicalType))
1715 return VT->getElementType()->isSignedIntegerOrEnumerationType();
1724 if (
const BuiltinType *BT = dyn_cast<BuiltinType>(CanonicalType)) {
1725 return BT->getKind() >= BuiltinType::Bool &&
1726 BT->getKind() <= BuiltinType::UInt128;
1729 if (
const EnumType *ET = dyn_cast<EnumType>(CanonicalType)) {
1732 if (ET->getDecl()->isComplete() && !ET->getDecl()->isScoped())
1733 return ET->getDecl()->getIntegerType()->isUnsignedIntegerType();
1740 if (
const BuiltinType *BT = dyn_cast<BuiltinType>(CanonicalType)) {
1741 return BT->getKind() >= BuiltinType::Bool &&
1742 BT->getKind() <= BuiltinType::UInt128;
1745 if (
const EnumType *ET = dyn_cast<EnumType>(CanonicalType)) {
1746 if (ET->getDecl()->isComplete())
1747 return ET->getDecl()->getIntegerType()->isUnsignedIntegerType();
1754 if (
const VectorType *VT = dyn_cast<VectorType>(CanonicalType))
1755 return VT->getElementType()->isUnsignedIntegerOrEnumerationType();
1761 if (
const BuiltinType *BT = dyn_cast<BuiltinType>(CanonicalType))
1762 return BT->getKind() >= BuiltinType::Half &&
1763 BT->getKind() <= BuiltinType::LongDouble;
1764 if (
const ComplexType *CT = dyn_cast<ComplexType>(CanonicalType))
1765 return CT->getElementType()->isFloatingType();
1770 if (
const VectorType *VT = dyn_cast<VectorType>(CanonicalType))
1771 return VT->getElementType()->isFloatingType();
1777 if (
const BuiltinType *BT = dyn_cast<BuiltinType>(CanonicalType))
1778 return BT->isFloatingPoint();
1783 if (
const BuiltinType *BT = dyn_cast<BuiltinType>(CanonicalType))
1784 return BT->getKind() >= BuiltinType::Bool &&
1785 BT->getKind() <= BuiltinType::LongDouble;
1786 if (
const EnumType *ET = dyn_cast<EnumType>(CanonicalType))
1787 return ET->getDecl()->isComplete() && !ET->getDecl()->isScoped();
1792 if (
const BuiltinType *BT = dyn_cast<BuiltinType>(CanonicalType))
1793 return BT->getKind() >= BuiltinType::Bool &&
1794 BT->getKind() <= BuiltinType::LongDouble;
1795 if (
const EnumType *ET = dyn_cast<EnumType>(CanonicalType))
1802 return !ET->getDecl()->isScoped() && ET->getDecl()->isComplete();
1803 return isa<ComplexType>(CanonicalType);
1809 const Type *T = CanonicalType.getTypePtr();
1810 if (
const BuiltinType *BT = dyn_cast<BuiltinType>(T)) {
1811 if (BT->getKind() == BuiltinType::Bool)
return STK_Bool;
1812 if (BT->getKind() == BuiltinType::NullPtr)
return STK_CPointer;
1815 llvm_unreachable(
"unknown scalar builtin type");
1816 }
else if (isa<PointerType>(T)) {
1818 }
else if (isa<BlockPointerType>(T)) {
1820 }
else if (isa<ObjCObjectPointerType>(T)) {
1822 }
else if (isa<MemberPointerType>(T)) {
1824 }
else if (isa<EnumType>(T)) {
1825 assert(cast<EnumType>(T)->getDecl()->isComplete());
1827 }
else if (
const ComplexType *CT = dyn_cast<ComplexType>(T)) {
1828 if (CT->getElementType()->isRealFloatingType())
1833 llvm_unreachable(
"unknown scalar type");
1846 if (
const RecordType *Record = dyn_cast<RecordType>(CanonicalType)) {
1847 if (
CXXRecordDecl *ClassDecl = dyn_cast<CXXRecordDecl>(Record->getDecl()))
1848 return ClassDecl->isAggregate();
1853 return isa<ArrayType>(CanonicalType);
1860 assert(!
isIncompleteType() &&
"This doesn't make sense for incomplete types");
1861 assert(!
isDependentType() &&
"This doesn't make sense for dependent types");
1863 return !isa<VariableArrayType>(CanonicalType);
1873 switch (CanonicalType->getTypeClass()) {
1874 default:
return false;
1880 EnumDecl *EnumD = cast<EnumType>(CanonicalType)->getDecl();
1893 RecordDecl *Rec = cast<RecordType>(CanonicalType)->getDecl();
1905 case IncompleteArray:
1909 return cast<ObjCObjectType>(CanonicalType)->getBaseType()
1910 ->isIncompleteType(Def);
1911 case ObjCInterface: {
1914 = cast<ObjCInterfaceType>(CanonicalType)->getDecl();
1937 if ((*this)->isIncompleteArrayType())
1940 if ((*this)->isIncompleteType())
1961 default:
return false;
1962 case Type::VariableArray:
1963 case Type::ConstantArray:
1967 case Type::ObjCObjectPointer:
1968 case Type::BlockPointer:
1972 case Type::MemberPointer:
1974 case Type::ExtVector:
1982 = dyn_cast<CXXRecordDecl>(cast<RecordType>(CanonicalType)->getDecl()))
1983 return ClassDecl->isPOD();
1997 if ((*this)->isArrayType())
2002 if ((*this)->isIncompleteType())
2016 if ((*this)->isObjCLifetimeType())
2036 dyn_cast<CXXRecordDecl>(RT->getDecl())) {
2041 return ClassDecl->hasDefaultConstructor() &&
2042 !ClassDecl->hasNonTrivialDefaultConstructor() &&
2043 ClassDecl->isTriviallyCopyable();
2054 if ((*this)->isArrayType())
2068 if ((*this)->isObjCLifetimeType())
2097 dyn_cast<CXXRecordDecl>(RT->getDecl())) {
2098 if (!ClassDecl->isTriviallyCopyable())
return false;
2127 assert(BaseTy &&
"NULL element type");
2158 dyn_cast<CXXRecordDecl>(RT->getDecl()))
2159 return ClassDecl->isLiteral();
2166 return AT->getValueType()->isLiteralType(Ctx);
2185 assert(BaseTy &&
"NULL element type");
2196 dyn_cast<CXXRecordDecl>(RT->getDecl()))
2197 if (!ClassDecl->isStandardLayout())
2237 assert(BaseTy &&
"NULL element type");
2248 dyn_cast<CXXRecordDecl>(RT->getDecl())) {
2251 if (!ClassDecl->isTrivial())
return false;
2256 if (!ClassDecl->isStandardLayout())
return false;
2277 switch (BT->getKind()) {
2278 case BuiltinType::Bool:
2279 case BuiltinType::Char_S:
2280 case BuiltinType::Char_U:
2281 case BuiltinType::SChar:
2282 case BuiltinType::UChar:
2283 case BuiltinType::Short:
2284 case BuiltinType::UShort:
2285 case BuiltinType::WChar_S:
2286 case BuiltinType::WChar_U:
2287 case BuiltinType::Char16:
2288 case BuiltinType::Char32:
2296 if (
const EnumType *ET = getAs<EnumType>()){
2297 if (this->
isDependentType() || ET->getDecl()->getPromotionType().isNull()
2298 || ET->getDecl()->isScoped())
2317 case TemplateTypeParm:
2318 case SubstTemplateTypeParm:
2319 case TemplateSpecialization:
2322 case DependentTemplateSpecialization:
2325 case ObjCObjectPointer:
2355 llvm_unreachable(
"Type specifier is not a tag type kind.");
2367 llvm_unreachable(
"Unknown tag type kind.");
2380 llvm_unreachable(
"Elaborated type keyword is not a tag type kind.");
2382 llvm_unreachable(
"Unknown elaborated type keyword.");
2398 llvm_unreachable(
"Unknown elaborated type keyword.");
2412 llvm_unreachable(
"Unknown elaborated type keyword.");
2415 DependentTemplateSpecializationType::DependentTemplateSpecializationType(
2422 NNS && NNS->containsUnexpandedParameterPack()),
2423 NNS(NNS), Name(Name), NumArgs(NumArgs) {
2425 "DependentTemplateSpecializatonType requires dependent qualifier");
2426 for (
unsigned I = 0; I != NumArgs; ++I) {
2442 ID.AddInteger(Keyword);
2443 ID.AddPointer(Qualifier);
2444 ID.AddPointer(Name);
2445 for (
unsigned Idx = 0; Idx < NumArgs; ++Idx)
2446 Args[Idx].
Profile(ID, Context);
2452 Keyword = Elab->getKeyword();
2454 Keyword = DepName->getKeyword();
2456 dyn_cast<DependentTemplateSpecializationType>(
this))
2457 Keyword = DepTST->getKeyword();
2466 #define ABSTRACT_TYPE(Derived, Base)
2467 #define TYPE(Derived, Base) case Derived: return #Derived;
2468 #include "clang/AST/TypeNodes.def"
2471 llvm_unreachable(
"Invalid type class.");
2476 case Void:
return "void";
2477 case Bool:
return Policy.
Bool ?
"bool" :
"_Bool";
2478 case Char_S:
return "char";
2479 case Char_U:
return "char";
2480 case SChar:
return "signed char";
2481 case Short:
return "short";
2482 case Int:
return "int";
2483 case Long:
return "long";
2484 case LongLong:
return "long long";
2485 case Int128:
return "__int128";
2486 case UChar:
return "unsigned char";
2487 case UShort:
return "unsigned short";
2488 case UInt:
return "unsigned int";
2489 case ULong:
return "unsigned long";
2490 case ULongLong:
return "unsigned long long";
2491 case UInt128:
return "unsigned __int128";
2492 case Half:
return Policy.
Half ?
"half" :
"__fp16";
2493 case Float:
return "float";
2494 case Double:
return "double";
2495 case LongDouble:
return "long double";
2497 case WChar_U:
return Policy.
MSWChar ?
"__wchar_t" :
"wchar_t";
2498 case Char16:
return "char16_t";
2499 case Char32:
return "char32_t";
2500 case NullPtr:
return "nullptr_t";
2501 case Overload:
return "<overloaded function type>";
2502 case BoundMember:
return "<bound member function type>";
2503 case PseudoObject:
return "<pseudo-object type>";
2504 case Dependent:
return "<dependent type>";
2505 case UnknownAny:
return "<unknown type>";
2506 case ARCUnbridgedCast:
return "<ARC unbridged cast type>";
2507 case BuiltinFn:
return "<builtin fn type>";
2508 case ObjCId:
return "id";
2509 case ObjCClass:
return "Class";
2510 case ObjCSel:
return "SEL";
2511 case OCLImage1d:
return "image1d_t";
2512 case OCLImage1dArray:
return "image1d_array_t";
2513 case OCLImage1dBuffer:
return "image1d_buffer_t";
2514 case OCLImage2d:
return "image2d_t";
2515 case OCLImage2dArray:
return "image2d_array_t";
2516 case OCLImage3d:
return "image3d_t";
2517 case OCLSampler:
return "sampler_t";
2518 case OCLEvent:
return "event_t";
2521 llvm_unreachable(
"Invalid builtin type.");
2542 case CC_C:
return "cdecl";
2557 llvm_unreachable(
"Invalid calling convention.");
2562 const ExtProtoInfo &epi)
2564 result->isDependentType(),
2565 result->isInstantiationDependentType(),
2566 result->isVariablyModifiedType(),
2567 result->containsUnexpandedParameterPack(), epi.ExtInfo),
2568 NumParams(params.size()),
2569 NumExceptions(epi.ExceptionSpec.Exceptions.size()),
2570 ExceptionSpecType(epi.ExceptionSpec.
Type),
2571 HasAnyConsumedParams(epi.ConsumedParameters != nullptr),
2572 Variadic(epi.Variadic), HasTrailingReturn(epi.HasTrailingReturn) {
2573 assert(NumParams == params.size() &&
"function has too many parameters");
2580 for (
unsigned i = 0; i != NumParams; ++i) {
2589 argSlot[i] = params[i];
2594 QualType *exnSlot = argSlot + NumParams;
2596 for (
QualType ExceptionType : epi.ExceptionSpec.Exceptions) {
2605 exnSlot[I++] = ExceptionType;
2609 Expr **noexSlot =
reinterpret_cast<Expr **
>(argSlot + NumParams);
2610 *noexSlot = epi.ExceptionSpec.NoexceptExpr;
2612 if (epi.ExceptionSpec.NoexceptExpr) {
2613 if (epi.ExceptionSpec.NoexceptExpr->isValueDependent() ||
2614 epi.ExceptionSpec.NoexceptExpr->isInstantiationDependent())
2617 if (epi.ExceptionSpec.NoexceptExpr->containsUnexpandedParameterPack())
2624 reinterpret_cast<FunctionDecl **
>(argSlot + NumParams);
2625 slot[0] = epi.ExceptionSpec.SourceDecl;
2626 slot[1] = epi.ExceptionSpec.SourceTemplate;
2633 reinterpret_cast<FunctionDecl **
>(argSlot + NumParams);
2634 slot[0] = epi.ExceptionSpec.SourceDecl;
2637 if (epi.ConsumedParameters) {
2638 bool *consumedParams =
const_cast<bool *
>(getConsumedParamsBuffer());
2639 for (
unsigned i = 0; i != NumParams; ++i)
2640 consumedParams[i] = epi.ConsumedParameters[i];
2646 return NE->isValueDependent();
2675 assert(isICE &&
"AST should not contain bad noexcept expressions.");
2681 bool ResultIfDependent)
const {
2690 for (
unsigned I = 0, N = NumExceptions; I != N; ++I)
2693 return ResultIfDependent;
2701 return ResultIfDependent;
2706 for (
unsigned ArgIdx =
getNumParams(); ArgIdx; --ArgIdx)
2714 const QualType *ArgTys,
unsigned NumParams,
2715 const ExtProtoInfo &epi,
2736 for (
unsigned i = 0; i != NumParams; ++i)
2741 assert(!(
unsigned(epi.Variadic) & ~1) &&
2742 !(
unsigned(epi.TypeQuals) & ~255) &&
2743 !(
unsigned(epi.RefQualifier) & ~3) &&
2744 !(
unsigned(epi.ExceptionSpec.Type) & ~15) &&
2745 "Values larger than expected.");
2746 ID.AddInteger(
unsigned(epi.Variadic) +
2747 (epi.TypeQuals << 1) +
2748 (epi.RefQualifier << 9) +
2749 (epi.ExceptionSpec.Type << 11));
2751 for (
QualType Ex : epi.ExceptionSpec.Exceptions)
2754 epi.ExceptionSpec.NoexceptExpr) {
2755 epi.ExceptionSpec.NoexceptExpr->Profile(ID, Context,
false);
2758 ID.AddPointer(epi.ExceptionSpec.SourceDecl->getCanonicalDecl());
2760 if (epi.ConsumedParameters) {
2761 for (
unsigned i = 0; i != NumParams; ++i)
2762 ID.AddBoolean(epi.ConsumedParameters[i]);
2764 epi.ExtInfo.Profile(ID);
2765 ID.AddBoolean(epi.HasTrailingReturn);
2779 :
Type(TypeOfExpr, can, E->isTypeDependent(),
2780 E->isInstantiationDependent(),
2781 E->getType()->isVariablyModifiedType(),
2782 E->containsUnexpandedParameterPack()),
2799 E->Profile(ID, Context,
true);
2806 :
Type(Decltype, can, E->isInstantiationDependent(),
2807 E->isInstantiationDependent(),
2808 E->getType()->isVariablyModifiedType(),
2809 E->containsUnexpandedParameterPack()),
2811 UnderlyingType(underlyingType) {
2824 :
DecltypeType(E, Context.DependentTy), Context(Context) { }
2828 E->Profile(ID, Context,
true);
2832 :
Type(TC, can, D->isDependentType(),
2833 D->isDependentType(),
2839 for (
auto I : decl->
redecls()) {
2840 if (I->isCompleteDefinition() || I->isBeingDefined())
2851 :
Type(UnaryTransform, CanonicalType, UnderlyingType->isDependentType(),
2852 UnderlyingType->isInstantiationDependentType(),
2853 UnderlyingType->isVariablyModifiedType(),
2854 BaseType->containsUnexpandedParameterPack())
2855 , BaseType(BaseType), UnderlyingType(UnderlyingType), UKind(UKind)
2868 default:
return false;
2875 llvm_unreachable(
"invalid attr kind");
2911 llvm_unreachable(
"invalid attr kind");
2922 SubstTemplateTypeParmPackType::
2928 Arguments(ArgPack.pack_begin()), NumArguments(ArgPack.pack_size())
2943 ID.AddPointer(Replaced);
2946 ID.AddPointer(
P.getAsType().getAsOpaquePtr());
2951 bool &InstantiationDependent) {
2953 InstantiationDependent);
2958 bool &InstantiationDependent) {
2959 for (
unsigned i = 0; i != N; ++i) {
2960 if (Args[i].getArgument().isDependent()) {
2961 InstantiationDependent =
true;
2965 if (Args[i].getArgument().isInstantiationDependent())
2966 InstantiationDependent =
true;
2971 TemplateSpecializationType::
2975 :
Type(TemplateSpecialization,
2976 Canon.isNull()?
QualType(this, 0) : Canon,
2977 Canon.isNull()?
true : Canon->isDependentType(),
2978 Canon.isNull()?
true : Canon->isInstantiationDependentType(),
2980 T.containsUnexpandedParameterPack()),
2981 Template(T), NumArgs(NumArgs), TypeAlias(!AliasedType.isNull()) {
2983 "Use DependentTemplateSpecializationType for dependent template-name");
2987 "Unexpected template name for TemplateSpecializationType");
2991 for (
unsigned Arg = 0; Arg < NumArgs; ++Arg) {
3000 if (Args[Arg].isInstantiationDependent())
3024 for (
unsigned Idx = 0; Idx < NumArgs; ++Idx)
3025 Args[Idx].
Profile(ID, Context);
3050 ID.AddInteger(typeArgs.size());
3051 for (
auto typeArg : typeArgs)
3052 ID.AddPointer(typeArg.getAsOpaquePtr());
3053 ID.AddInteger(protocols.size());
3054 for (
auto proto : protocols)
3055 ID.AddPointer(proto);
3056 ID.AddBoolean(isKindOf);
3068 class CachedProperties {
3073 CachedProperties(
Linkage L,
bool local) : L(L), local(local) {}
3075 Linkage getLinkage()
const {
return L; }
3076 bool hasLocalOrUnnamedType()
const {
return local; }
3078 friend CachedProperties merge(CachedProperties L, CachedProperties R) {
3080 return CachedProperties(MergedLinkage,
3081 L.hasLocalOrUnnamedType() | R.hasLocalOrUnnamedType());
3095 return get(T.getTypePtr());
3098 static CachedProperties
get(
const Type *T) {
3100 return CachedProperties(T->TypeBits.getLinkage(),
3101 T->TypeBits.hasLocalOrUnnamedType());
3106 if (T->
TypeBits.isCacheValid())
return;
3122 T->
TypeBits.CachedLinkage = Result.getLinkage();
3123 T->
TypeBits.CachedLocalOrUnnamed = Result.hasLocalOrUnnamedType();
3131 namespace {
class Private {}; }
3136 #define TYPE(Class,Base)
3137 #define NON_CANONICAL_TYPE(Class,Base) case Type::Class:
3138 #include "clang/AST/TypeNodes.def"
3139 llvm_unreachable(
"didn't expect a non-canonical type here");
3141 #define TYPE(Class,Base)
3142 #define DEPENDENT_TYPE(Class,Base) case Type::Class:
3143 #define NON_CANONICAL_UNLESS_DEPENDENT_TYPE(Class,Base) case Type::Class:
3144 #include "clang/AST/TypeNodes.def"
3162 const TagDecl *Tag = cast<TagType>(T)->getDecl();
3169 bool IsLocalOrUnnamed =
3172 return CachedProperties(L, IsLocalOrUnnamed);
3181 return Cache::get(cast<PointerType>(T)->getPointeeType());
3182 case Type::BlockPointer:
3183 return Cache::get(cast<BlockPointerType>(T)->getPointeeType());
3184 case Type::LValueReference:
3185 case Type::RValueReference:
3186 return Cache::get(cast<ReferenceType>(T)->getPointeeType());
3187 case Type::MemberPointer: {
3192 case Type::ConstantArray:
3193 case Type::IncompleteArray:
3194 case Type::VariableArray:
3197 case Type::ExtVector:
3199 case Type::FunctionNoProto:
3200 return Cache::get(cast<FunctionType>(T)->getReturnType());
3201 case Type::FunctionProto: {
3208 case Type::ObjCInterface: {
3209 Linkage L = cast<ObjCInterfaceType>(T)->getDecl()->getLinkageInternal();
3210 return CachedProperties(L,
false);
3212 case Type::ObjCObject:
3213 return Cache::get(cast<ObjCObjectType>(T)->getBaseType());
3214 case Type::ObjCObjectPointer:
3215 return Cache::get(cast<ObjCObjectPointerType>(T)->getPointeeType());
3217 return Cache::get(cast<AtomicType>(T)->getValueType());
3220 llvm_unreachable(
"unhandled type class");
3231 return TypeBits.hasLocalOrUnnamedType();
3238 #define TYPE(Class,Base)
3239 #define NON_CANONICAL_TYPE(Class,Base) case Type::Class:
3240 #include "clang/AST/TypeNodes.def"
3241 llvm_unreachable(
"didn't expect a non-canonical type here");
3243 #define TYPE(Class,Base)
3244 #define DEPENDENT_TYPE(Class,Base) case Type::Class:
3245 #define NON_CANONICAL_UNLESS_DEPENDENT_TYPE(Class,Base) case Type::Class:
3246 #include "clang/AST/TypeNodes.def"
3259 return cast<TagType>(T)->getDecl()->getLinkageAndVisibility();
3265 case Type::BlockPointer:
3267 case Type::LValueReference:
3268 case Type::RValueReference:
3270 case Type::MemberPointer: {
3276 case Type::ConstantArray:
3277 case Type::IncompleteArray:
3278 case Type::VariableArray:
3281 case Type::ExtVector:
3283 case Type::FunctionNoProto:
3285 case Type::FunctionProto: {
3292 case Type::ObjCInterface:
3293 return cast<ObjCInterfaceType>(T)->getDecl()->getLinkageAndVisibility();
3294 case Type::ObjCObject:
3296 case Type::ObjCObjectPointer:
3302 llvm_unreachable(
"unhandled type class");
3331 if (
auto attributed = dyn_cast<AttributedType>(type.
getTypePtr())) {
3332 if (
auto nullability = attributed->getImmediateNullability())
3350 #define NON_CANONICAL_TYPE(Class, Parent) \
3352 llvm_unreachable("non-canonical type");
3353 #define TYPE(Class, Parent)
3354 #include "clang/AST/TypeNodes.def"
3358 case Type::BlockPointer:
3359 case Type::MemberPointer:
3360 case Type::ObjCObjectPointer:
3364 case Type::UnresolvedUsing:
3365 case Type::TypeOfExpr:
3367 case Type::Decltype:
3368 case Type::UnaryTransform:
3369 case Type::TemplateTypeParm:
3370 case Type::SubstTemplateTypeParmPack:
3371 case Type::DependentName:
3372 case Type::DependentTemplateSpecialization:
3378 case Type::TemplateSpecialization:
3380 = cast<TemplateSpecializationType>(type.
getTypePtr())
3381 ->getTemplateName().getAsTemplateDecl()) {
3382 if (isa<ClassTemplateDecl>(templateDecl))
3389 return !cast<AutoType>(type.
getTypePtr())->isDeduced();
3394 #define SIGNED_TYPE(Id, SingletonId) case BuiltinType::Id:
3395 #define UNSIGNED_TYPE(Id, SingletonId) case BuiltinType::Id:
3396 #define FLOATING_TYPE(Id, SingletonId) case BuiltinType::Id:
3397 #define BUILTIN_TYPE(Id, SingletonId)
3398 #include "clang/AST/BuiltinTypes.def"
3402 case BuiltinType::Dependent:
3403 case BuiltinType::Overload:
3404 case BuiltinType::BoundMember:
3405 case BuiltinType::PseudoObject:
3406 case BuiltinType::UnknownAny:
3407 case BuiltinType::ARCUnbridgedCast:
3410 case BuiltinType::Void:
3411 case BuiltinType::ObjCId:
3412 case BuiltinType::ObjCClass:
3413 case BuiltinType::ObjCSel:
3414 case BuiltinType::OCLImage1d:
3415 case BuiltinType::OCLImage1dArray:
3416 case BuiltinType::OCLImage1dBuffer:
3417 case BuiltinType::OCLImage2d:
3418 case BuiltinType::OCLImage2dArray:
3419 case BuiltinType::OCLImage3d:
3420 case BuiltinType::OCLSampler:
3421 case BuiltinType::OCLEvent:
3422 case BuiltinType::BuiltinFn:
3423 case BuiltinType::NullPtr:
3429 case Type::LValueReference:
3430 case Type::RValueReference:
3431 case Type::ConstantArray:
3432 case Type::IncompleteArray:
3433 case Type::VariableArray:
3434 case Type::DependentSizedArray:
3435 case Type::DependentSizedExtVector:
3437 case Type::ExtVector:
3438 case Type::FunctionProto:
3439 case Type::FunctionNoProto:
3442 case Type::InjectedClassName:
3443 case Type::PackExpansion:
3444 case Type::ObjCObject:
3445 case Type::ObjCInterface:
3449 llvm_unreachable(
"bad type kind!");
3463 if (
auto attributed = dyn_cast<AttributedType>(T.
getTypePtr())) {
3464 if (
auto nullability = attributed->getImmediateNullability()) {
3465 T = attributed->getModifiedType();
3514 "cannot query implicit lifetime for non-inferrable type");
3519 while (
const ArrayType *array = dyn_cast<ArrayType>(canon))
3520 canon = array->getElementType().getTypePtr();
3523 = dyn_cast<ObjCObjectPointerType>(canon)) {
3525 if (opt->getObjectType()->isObjCClass())
3533 if (
const TypedefType *typedefType = dyn_cast<TypedefType>(
this))
3534 return typedefType->getDecl()->hasAttr<ObjCNSObjectAttr>();
3538 if (
const TypedefType *typedefType = dyn_cast<TypedefType>(
this))
3539 return typedefType->getDecl()->hasAttr<ObjCIndependentClassAttr>();
3550 if (
const PointerType *OPT = getAs<PointerType>())
3551 return OPT->getPointeeType()->isObjCIndirectLifetimeType();
3553 return Ref->getPointeeType()->isObjCIndirectLifetimeType();
3555 return MemPtr->getPointeeType()->isObjCIndirectLifetimeType();
3562 const Type *type =
this;
3564 type = array->getElementType().getTypePtr();
3576 const PointerType *Pointer = getAs<PointerType>();
3587 if (
const PointerType *ptr = getAs<PointerType>())
3588 return ptr->getPointeeType()->hasSizedVLAType();
3590 return ref->getPointeeType()->hasSizedVLAType();
3592 if (isa<VariableArrayType>(arr) &&
3593 cast<VariableArrayType>(arr)->getSizeExpr())
3596 return arr->getElementType()->hasSizedVLAType();
unsigned getNumElements() const
bool hasObjCGCAttr() const
unsigned getAddressSpace() const
getAddressSpace - Return the address space of this type.
const ComplexType * getAsComplexIntegerType() const
bool isUnspecialized() const
DecltypeType(Expr *E, QualType underlyingType, QualType can=QualType())
static StringRef getKeywordName(ElaboratedTypeKeyword Keyword)
bool hasDefinition() const
Determine whether this class has been defined.
Defines the clang::ASTContext interface.
QualType getExceptionType(unsigned i) const
Represents a type that was referred to using an elaborated type keyword, e.g., struct S...
QualType getUnderlyingType() const
const Type * Ty
The locally-unqualified type.
void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Ctx)
External linkage, which indicates that the entity can be referred to from other translation units...
The "enum" keyword introduces the elaborated-type-specifier.
void setDependent(bool D=true)
llvm::iterator_range< pack_iterator > pack_elements() const
Iterator range referencing all of the elements of a template argument pack.
bool isCXX98PODType(ASTContext &Context) const
SourceRange getBracketsRange() const
void computeSuperClassTypeSlow() const
bool isCanonicalUnqualified() const
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.
bool hasTrivialDestructor() const
Determine whether this class has a trivial destructor (C++ [class.dtor]p3)
QualType getAdjustedType(QualType Orig, QualType New) const
Return the uniqued reference to a type adjusted from the original type to a new type.
QualType getComplexType(QualType T) const
Return the uniqued reference to the type for a complex number with the specified element type...
IdentifierInfo * getIdentifier() const
bool isKindOfTypeAsWritten() const
Whether this is a "__kindof" type as written.
bool isInstantiationDependentType() const
Determine whether this type is an instantiation-dependent type, meaning that the type involves a temp...
unsigned getFastQualifiers() const
QualType getNonLValueExprType(const ASTContext &Context) const
Determine the type of a (typically non-lvalue) expression with the specified result type...
QualType getQualifiedType(SplitQualType split) const
Un-split a SplitQualType.
Qualifiers::ObjCLifetime getObjCARCImplicitLifetime() const
Return the implicit lifetime for this type, which must not be dependent.
void setInstantiationDependent(bool D=true)
bool isFixed() const
Returns true if this is an Objective-C, C++11, or Microsoft-style enumeration with a fixed underlying...
bool isAnyCharacterType() const
Determine whether this type is any of the built-in character types.
QualType getRValueReferenceType(QualType T) const
Return the uniqued reference to the type for an rvalue reference to the specified type...
CanQualType getSizeType() const
Return the unique type for "size_t" (C99 7.17), defined in <stddef.h>.
bool canHaveNullability() const
unsigned MSWChar
When true, print the built-in wchar_t type as __wchar_t. For use in Microsoft mode when wchar_t is no...
Represents a qualified type name for which the type name is dependent.
QuantityType getQuantity() const
getQuantity - Get the raw integer representation of this quantity.
void Profile(llvm::FoldingSetNodeID &ID)
CXXRecordDecl * getDecl() const
bool isRecordType() const
QualType getUnderlyingType() const
bool isChar16Type() const
ObjCObjectTypeBitfields ObjCObjectTypeBits
bool isLiteralType(const ASTContext &Ctx) const
AutoType * getContainedAutoType() const
Get the AutoType whose type will be deduced for a variable with an initializer of this type...
Defines the C++ template declaration subclasses.
bool isVoidPointerType() const
Represents a C++11 auto or C++1y decltype(auto) type.
QualType substObjCTypeArgs(ASTContext &ctx, ArrayRef< QualType > typeArgs, ObjCSubstitutionContext context) const
bool isEnumeralType() const
void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Ctx)
TypePropertyCache< Private > Cache
bool hasDefinition() const
QualType getLValueReferenceType(QualType T, bool SpelledAsLValue=true) const
Return the uniqued reference to the type for an lvalue reference to the specified type...
static ElaboratedTypeKeyword getKeywordForTagTypeKind(TagTypeKind Tag)
QualType getPointeeType() const
bool isElaboratedTypeSpecifier() const
Determine wither this type is a C++ elaborated-type-specifier.
const ObjCObjectType * getObjectType() const
DependentDecltypeType(const ASTContext &Context, Expr *E)
bool isBlockPointerType() const
const ObjCObjectPointerType * getAsObjCQualifiedClassType() const
bool isSpelledAsLValue() const
A template template parameter that has been substituted for some other template name.
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.
const llvm::APInt & getSize() const
void * getAsOpaquePtr() const
const TemplateArgumentLoc * getArgumentArray() const
static CachedProperties computeCachedProperties(const Type *T)
QualType getBlockPointerType(QualType T) const
Return the uniqued reference to the type for a block of the specified type.
QualType substObjCMemberType(QualType objectType, const DeclContext *dc, ObjCSubstitutionContext context) const
The noexcept specifier has a bad expression.
ObjCLifetime getObjCLifetime() const
ExtProtoInfo - Extra information about a function prototype.
The "__interface" keyword.
uint64_t getTypeSize(QualType T) const
Return the size of the specified (complete) type T, in bits.
TemplateTypeParmDecl * getDecl() const
QualType getOriginalType() const
bool isTrivialType(ASTContext &Context) const
Describes how types, statements, expressions, and declarations should be printed. ...
unsigned size() const
Determine the number of type parameters in this list.
bool isSpecialized() const
bool containsUnexpandedParameterPack() const
Whether this type is or contains an unexpanded parameter pack, used to support C++0x variadic templat...
bool isObjCRetainableType() const
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...
unsigned getNumArgs() const
Retrieve the number of template arguments.
const Type * getUnqualifiedDesugaredType() const
QualType getFunctionNoProtoType(QualType ResultTy, const FunctionType::ExtInfo &Info) const
Return a K&R style C function type like 'int()'.
void Profile(llvm::FoldingSetNodeID &ID)
bool isTemplateVariadic() const
Determines whether this function prototype contains a parameter pack at the end.
unsigned getNumParams() const
QualType getElementType() const
unsigned getIndexTypeCVRQualifiers() const
bool isScalarType() const
QualType apply(const ASTContext &Context, QualType QT) const
Apply the collected qualifiers to the given type.
TagDecl * getAsTagDecl() const
Retrieves the TagDecl that this type refers to, either because the type is a TagType or because it is...
QualType getAutoType(QualType DeducedType, bool IsDecltypeAuto, bool IsDependent) const
C++11 deduced auto type.
Expr * getSizeExpr() const
IdentifierInfo * getIdentifier() const
bool isVariablyModifiedType() const
Whether this type is a variably-modified type (C99 6.7.5).
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
ArrayRef< QualType > getParamTypes() const
bool isObjCARCImplicitlyUnretainedType() const
bool isSugared() const
Returns whether this type directly provides sugar.
bool isReferenceType() const
bool isStructureOrClassType() const
QualType getExtVectorType(QualType VectorType, unsigned NumElts) const
Return the unique reference to an extended vector type of the specified element type and size...
bool isCompleteDefinition() const
NoexceptResult
Result type of getNoexceptSpec().
const internal::VariadicAllOfMatcher< Decl > decl
Matches declarations.
bool isBeingDefined() const
Determines whether this type is in the process of being defined.
bool isChar32Type() const
const CXXRecordDecl * getPointeeCXXRecordDecl() const
const RecordType * getAsUnionType() const
NOTE: getAs*ArrayType are methods on ASTContext.
static unsigned getNumAddressingBits(ASTContext &Context, QualType ElementType, const llvm::APInt &NumElements)
Determine the number of bits required to address a member of.
Linkage getLinkage() const
bool isSugared() const
Returns whether this type directly provides sugar.
Values of this type can be null.
bool isIntegralOrUnscopedEnumerationType() const
Determine whether this type is an integral or unscoped enumeration type.
bool hasNonFastQualifiers() const
TemplateArgument getArgumentPack() const
param_type_range param_types() const
QualType getParenType(QualType NamedType) const
const LangOptions & getLangOpts() const
LinkageInfo getLinkageAndVisibility() const
Determine the linkage and visibility of this type.
QualType getBaseType() const
QualType getReturnType() const
The "struct" keyword introduces the elaborated-type-specifier.
static ElaboratedTypeKeyword getKeywordForTypeSpec(unsigned TypeSpec)
bool isObjCLifetimeType() const
const ArrayType * getAsArrayType(QualType T) const
Expr * getNoexceptExpr() const
bool isValueDependent() const
RecordDecl * getDecl() const
ObjCInterfaceDecl * getInterface() const
bool isUnsignedIntegerType() const
const ObjCObjectType * getAsObjCInterfaceType() const
Values of this type can never be null.
bool isDependent() const
Whether this nested name specifier refers to a dependent type or not.
static TagDecl * getInterestingTagDecl(TagDecl *decl)
TypeClass getTypeClass() const
unsigned Half
When true, print the half-precision floating-point type as 'half' instead of '__fp16'.
bool isStructureType() const
Represents an Objective-C protocol declaration.
bool isObjCIndependentClassType() const
bool isIncompleteType(NamedDecl **Def=nullptr) const
Def If non-NULL, and the type refers to some kind of declaration that can be completed (such as a C s...
CharUnits getTypeSizeInChars(QualType T) const
Return the size of the specified (complete) type T, in characters.
Represents an ObjC class declaration.
QualType getCanonicalTypeInternal() const
TagType(TypeClass TC, const TagDecl *D, QualType can)
const TemplateTypeParmType * getReplacedParameter() const
Gets the template parameter that was substituted for.
bool isLinkageValid() const
True if the computed linkage is valid. Used for consistency checking. Should always return true...
const ArrayType * getAsArrayTypeUnsafe() const
EnumDecl * getDecl() const
DependentTemplateName * getAsDependentTemplateName() const
Retrieve the underlying dependent template name structure, if any.
QualType getValueType() const
static void ensure(const Type *T)
ExtInfo getExtInfo() const
const ArrayType * castAsArrayTypeUnsafe() const
QualType getObjCObjectType(QualType Base, ObjCProtocolDecl *const *Protocols, unsigned NumProtocols) const
Legacy interface: cannot provide type arguments or __kindof.
CXXRecordDecl * getMostRecentDecl()
Optional< ArrayRef< QualType > > getObjCSubstitutions(const DeclContext *dc) const
QualType getParamType(unsigned i) const
ExceptionSpecificationType getExceptionSpecType() const
Get the kind of exception specification on this function.
static bool KeywordIsTagTypeKind(ElaboratedTypeKeyword Keyword)
Qualifiers::ObjCLifetime getObjCLifetime() const
getObjCLifetime - Returns lifetime attribute of this type.
param_type_iterator param_type_begin() const
bool isInstantiationDependent() const
Whether this expression is instantiation-dependent, meaning that it depends in some way on a template...
QualType getAtomicType(QualType T) const
Return the uniqued reference to the atomic type for the specified type.
ID
Defines the set of possible language-specific address spaces.
QualType desugar() const
Remove a single level of sugar.
QualType getPointeeType() const
QualType getObjCInterfaceType(const ObjCInterfaceDecl *Decl, ObjCInterfaceDecl *PrevDecl=nullptr) const
bool hasSizedVLAType() const
Whether this type involves a variable-length array type with a definite size.
bool isRealFloatingType() const
Floating point categories.
bool isKindOfType() const
Whether this is a "__kindof" type.
bool isSignedIntegerOrEnumerationType() const
SplitQualType split() const
QualType getSuperClassType() const
QualType getPointeeType() const
The "typename" keyword precedes the qualified type name, e.g., typename T::type.
static unsigned getMaxSizeBits(ASTContext &Context)
Determine the maximum number of active bits that an array's size can require, which limits the maximu...
bool isAnyComplexType() const
QualType getLocallyUnqualifiedSingleStepDesugaredType() const
ASTContext & getParentASTContext() const
ElaboratedTypeKeyword
The elaboration keyword that precedes a qualified type name or introduces an elaborated-type-specifie...
ObjCObjectType(QualType Canonical, QualType Base, ArrayRef< QualType > typeArgs, ArrayRef< ObjCProtocolDecl * > protocols, bool isKindOf)
static LinkageInfo computeLinkageInfo(QualType T)
Expr * getUnderlyingExpr() const
bool isVariableArrayType() const
ExtProtoInfo getExtProtoInfo() const
DeclContext * getDeclContext()
bool isFloatingType() const
void Profile(llvm::FoldingSetNodeID &ID)
static TagTypeKind getTagTypeKindForTypeSpec(unsigned TypeSpec)
Represents a C++ template name within the type system.
QualType getDesugaredType(const ASTContext &Context) const
There is no noexcept specifier.
bool isCXX11PODType(ASTContext &Context) const
static Optional< NullabilityKind > stripOuterNullability(QualType &T)
const ObjCObjectPointerType * stripObjCKindOfTypeAndQuals(const ASTContext &ctx) const
QualType stripObjCKindOfType(const ASTContext &ctx) const
Strip Objective-C "__kindof" types from the given type.
bool isDependentType() const
bool isFunctionOrMethod() const
Qualifiers Quals
The local qualifiers.
bool isObjCQualifiedIdType() const
#define TRIVIAL_TYPE_CLASS(Class)
QualType withFastQualifiers(unsigned TQs) const
const IdentifierInfo * getBaseTypeIdentifier() const
Retrieves a pointer to the name of the base type.
Linkage getLinkageInternal() const
Determine what kind of linkage this entity has. This is not the linkage as defined by the standard or...
QualType getElementType() const
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 result type of a method or function.
bool isComplexIntegerType() const
bool hasNameForLinkage() const
IdentifierInfo * getNSObjectName()
Retrieve the identifier 'NSObject'.
bool isUnsignedIntegerOrEnumerationType() const
QualType getReplacementType() const
CallingConv
CallingConv - Specifies the calling convention that a function uses.
static LinkageInfo external()
bool hasObjCLifetime() const
QualType stripObjCKindOfTypeAndQuals(const ASTContext &ctx) const
IdentifierInfo * getNSCopyingName()
Retrieve the identifier 'NSCopying'.
bool hasUnnamedOrLocalType() const
Whether this type is or contains a local or unnamed type.
bool isNothrow(const ASTContext &Ctx, bool ResultIfDependent=false) const
Determine whether this function type has a non-throwing exception specification. If this depends on t...
const TemplateTypeParmType * getReplacedParameter() const
Gets the template parameter that was substituted for.
unsigned Bool
Whether we can use 'bool' rather than '_Bool', even if the language doesn't actually have 'bool' (bec...
CXXRecordDecl * getMostRecentCXXRecordDecl() const
A template template parameter pack that has been substituted for a template template argument pack...
There is no lifetime qualification on this type.
redecl_range redecls() const
Returns an iterator range for all the redeclarations of the same decl. It will iterate at least once ...
ExceptionSpecificationType Type
The kind of exception specification this is.
Encodes a location in the source. The SourceManager can decode this to get at the full include stack...
bool hasIntegerRepresentation() const
Determine whether this type has an integer representation of some sort, e.g., it is an integer type o...
const Type * getTypePtr() const
bool isComplexType() const
bool isConstant(ASTContext &Ctx) const
TagDecl - Represents the declaration of a struct/union/class/enum.
bool isConstantSizeType() const
ASTContext & getASTContext() const LLVM_READONLY
VectorKind getVectorKind() const
bool isObjCClassOrClassKindOfType() const
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
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...
The noexcept specifier evaluates to true.
bool isObjCBoxableRecordType() const
const Type * getArrayElementTypeNoTypeQual() const
bool isIntegerConstantExpr(llvm::APSInt &Result, const ASTContext &Ctx, SourceLocation *Loc=nullptr, bool isEvaluated=true) const
void Profile(llvm::FoldingSetNodeID &ID)
SplitQualType getSplitDesugaredType() const
bool hasDependentExceptionSpec() const
Return whether this function has a dependent exception spec.
const Type * getBaseElementTypeUnsafe() const
bool isSpecializedAsWritten() const
Determine whether this object type was written with type arguments.
TypedefNameDecl * getDecl() const
unsigned getNumProtocols() const
bool isObjCQualifiedClassType() const
bool isTypeDependent() const
NoexceptResult getNoexceptSpec(const ASTContext &Ctx) const
Get the meaning of the noexcept spec on this function, if any.
qual_iterator qual_begin() const
QualType getAttributedType(AttributedType::Kind attrKind, QualType modifiedType, QualType equivalentType)
bool isVectorType() const
bool isPromotableIntegerType() const
More type predicates useful for type checking/promotion.
Assigning into this object requires a lifetime extension.
bool isVolatileQualified() const
Determine whether this type is volatile-qualified.
static TagTypeKind getTagTypeKindForKeyword(ElaboratedTypeKeyword Keyword)
getTagTypeKindForKeyword - Converts an elaborated type keyword into
void setVariablyModified(bool VM=true)
TypeOfExprType(Expr *E, QualType can=QualType())
Represents a pointer type decayed from an array or function type.
QualType getPointeeType() const
QualType getFunctionType(QualType ResultTy, ArrayRef< QualType > Args, const FunctionProtoType::ExtProtoInfo &EPI) const
Return a normal function type with a typed argument list.
Represents a pack expansion of types.
ArrayRef< QualType > getTypeArgsAsWritten() const
Defines various enumerations that describe declaration and type specifiers.
ArrayRef< QualType > getTypeArgs() const
Retrieve the type arguments of this object type (semantically).
const char * getTypeClassName() const
Linkage minLinkage(Linkage L1, Linkage L2)
Compute the minimum linkage given two linkages.
Represents a template argument.
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 ...
Represents a type which was implicitly adjusted by the semantic engine for arbitrary reasons...
QualType getAsType() const
Retrieve the type for a type template argument.
TagTypeKind
The kind of a tag type.
CanQualType ObjCBuiltinIdTy
static const Type * getElementType(const Expr *BaseExpr)
QualType getDecayedType(QualType T) const
Return the uniqued reference to the decayed version of the given type. Can only be called on array an...
not evaluated yet, for special member function
A qualifier set is used to build a set of qualifiers.
bool isAggregateType() const
Determines whether the type is a C++ aggregate type or C aggregate or union type. ...
void setContainsUnexpandedParameterPack(bool PP=true)
The base class of all kinds of template declarations (e.g., class, function, etc.).
static CachedProperties get(QualType T)
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
bool isKindOfType() const
Whether this ia a "__kindof" type (semantically).
QualType IgnoreParens() const
bool isCallingConv() const
const ObjCInterfaceType * getInterfaceType() const
bool isStandardLayoutType() const
Test if this type is a standard-layout type. (C++0x [basic.type]p9)
QualType getPointerType(QualType T) const
Return the uniqued reference to the type for a pointer to the specified type.
void Profile(llvm::FoldingSetNodeID &ID)
The "union" keyword introduces the elaborated-type-specifier.
const Type * strip(QualType type)
QualType getObjCObjectPointerType(QualType OIT) const
Return a ObjCObjectPointerType type for the given ObjCObjectType.
void Profile(llvm::FoldingSetNodeID &ID)
The "class" keyword introduces the elaborated-type-specifier.
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...
QualType getModifiedType() const
void addConsistentQualifiers(Qualifiers qs)
Add the qualifiers from the given set to this set, given that they don't conflict.
const RecordType * getAsStructureType() const
bool isWideCharType() const
FunctionTypeBitfields FunctionTypeBits
bool isTriviallyCopyableType(ASTContext &Context) const
llvm::Optional< NullabilityKind > getImmediateNullability() const
bool isObjCNSObjectType() const
QualType getCanonicalType() const
ObjCTypeParamList * getTypeParamList() const
bool isSpecifierType() const
ObjCInterfaceDecl * getInterfaceDecl() const
const ObjCObjectType * getAsObjCQualifiedInterfaceType() const
VectorTypeBitfields VectorTypeBits
QualType getInnerType() const
The noexcept specifier evaluates to false.
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
unsigned getAddressSpace() const
The template argument is a type.
ExceptionSpecificationType
The various types of exception specifications that exist in C++11.
bool isMSTypeSpec() const
ArrayRef< QualType > Exceptions
Explicitly-specified list of exception types.
void merge(LinkageInfo other)
Merge both linkage and visibility.
Linkage getLinkage() const
Determine the linkage of this type.
const Type * getClass() const
Reading or writing from this object requires a barrier call.
bool isPODType(ASTContext &Context) const
Determine whether this is a Plain Old Data (POD) type (C++ 3.9p10).
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate.h) and friends (in DeclFriend.h).
bool hasAddressSpace() const
bool isBlockCompatibleObjCPointerType(ASTContext &ctx) const
unsigned pack_size() const
The number of template arguments in the given template argument pack.
bool isObjCClassType() const
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 isCARCBridgableType() const
Determine whether the given type T is a "bridgeable" C type.
QualType getUnqualifiedType() const
Retrieve the unqualified variant of the given type, removing as little sugar as possible.
Represents a C++ struct/union/class.
bool isObjCObjectPointerType() const
The parameter type of a method or function.
void * Allocate(size_t Size, unsigned Align=8) const
ArraySizeModifier getSizeModifier() const
void Profile(llvm::FoldingSetNodeID &ID)
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.
QualType getPointeeTypeAsWritten() const
TagDecl * getDecl() const
bool isObjCIndirectLifetimeType() const
static Decl::Kind getKind(const Decl *D)
Represents a type template specialization; the template must be a class template, a type alias templa...
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...
QualType getElementType() const
static StringRef getNameForCallConv(CallingConv CC)
bool isObjCARCBridgableType() const
Determine whether the given type T is a "bridgable" Objective-C type, which is either an Objective-C ...
static bool anyDependentTemplateArguments(const TemplateArgumentLoc *Args, unsigned NumArgs, bool &InstantiationDependent)
Determine whether any of the given template arguments are dependent.
bool isInterfaceType() const
QualType desugar() const
Remove a single level of sugar.
A trivial tuple used to represent a source range.
VectorType(QualType vecType, unsigned nElements, QualType canonType, VectorKind vecKind)
StringRef getName(const PrintingPolicy &Policy) const
bool isObjCIdOrObjectKindOfType(const ASTContext &ctx, const ObjCObjectType *&bound) const
bool isArithmeticType() const
No keyword precedes the qualified type name.
bool isSignedIntegerType() const
bool isConstQualified() const
Determine whether this type is const-qualified.
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.
bool isNull() const
isNull - Return true if this QualType doesn't point to a type yet.
void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context)
const ObjCObjectPointerType * getAsObjCInterfacePointerType() const
QualType getSubstTemplateTypeParmType(const TemplateTypeParmType *Replaced, QualType Replacement) const
Retrieve a substitution-result type.
bool isObjCIdType() const
The noexcept specifier is dependent.
Optional< NullabilityKind > getNullability(const ASTContext &context) const
QualType getSingleStepDesugaredType(const ASTContext &Context) const
Return the specified type with one level of "sugar" removed from the type.
QualType getSuperClassType() const
The "__interface" keyword introduces the elaborated-type-specifier.
ArrayRef< QualType > exceptions() const
The superclass of a type.
bool isBeingDefined() const
isBeingDefined - Return true if this decl is currently being defined.
bool isIntegralType(ASTContext &Ctx) const
Determine whether this type is an integral type.
ExceptionSpecInfo ExceptionSpec
QualType getBaseElementType(const ArrayType *VAT) const
Return the innermost element type of an array type.
const ObjCObjectType * getSuperClassType() const
Retrieve the superclass type.
bool isObjCQualifiedInterfaceType() const
ScalarTypeKind getScalarTypeKind() const
getScalarTypeKind - Given that this is a scalar type, classify it.
A single template declaration.
bool isIntegerType() const
const ObjCObjectPointerType * getAsObjCQualifiedIdType() const
bool isPointerType() const