clang: lib/AST/Type.cpp Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
41#include "llvm/ADT/APInt.h"
42#include "llvm/ADT/APSInt.h"
43#include "llvm/ADT/ArrayRef.h"
44#include "llvm/ADT/FoldingSet.h"
45#include "llvm/ADT/STLExtras.h"
46#include "llvm/ADT/SmallVector.h"
47#include "llvm/Support/ErrorHandling.h"
48#include "llvm/Support/MathExtras.h"
49#include
50#include
51#include
52#include
53#include
54
55using namespace clang;
56
58 return (*this != Other) &&
59
61
64
67
70}
71
74
75
77
78
79
84
87
92
93
97
98
100}
101
111 else if (ty->getTypeClass() == Type::Typedef)
115 getElementType().getBaseTypeIdentifier();
116
117 if (ND)
119 return nullptr;
120}
121
125}
126
130}
131
133 if (T.isConstQualified())
134 return true;
135
137 return AT->getElementType().isConstant(Ctx);
138
140}
141
142std::optionalQualType::NonConstantStorageReason
144 bool ExcludeDtor) {
145 if ((Ctx) && !(*this)->isReferenceType())
148 return std::nullopt;
151 if (!ExcludeCtor)
153 if (Record->hasMutableFields())
155 if (->hasTrivialDestructor() && !ExcludeDtor)
157 }
158 return std::nullopt;
159}
160
161
162
163
164
165
168
169
170
171
172
173
174 : Type(tc, can,
175 et->getDependence() |
179 (tc == VariableArray ? TypeDependence::VariablyModified
181 (tc == DependentSizedArray
184 ElementType(et) {
186 ArrayTypeBits.SizeModifier = llvm::to_underlying(sm);
187}
188
191 const llvm::APInt &Sz, const Expr *SzExpr,
193 bool NeedsExternalSize = SzExpr != nullptr || Sz.ugt(0x0FFFFFFFFFFFFFFF) ||
194 Sz.getBitWidth() > 0xFF;
195 if (!NeedsExternalSize)
197 ET, Can, Sz.getBitWidth(), Sz.getZExtValue(), SzMod, Qual);
198
199 auto *SzPtr = new (Ctx, alignof(ConstantArrayType::ExternalSize))
200 ConstantArrayType::ExternalSize(Sz, SzExpr);
203}
204
207 const llvm::APInt &NumElements) {
209
210
211
212
213
214
215
216 if (llvm::isPowerOf2_64(ElementSize)) {
217 return NumElements.getActiveBits() + llvm::Log2_64(ElementSize);
218 }
219
220
221
222 if ((ElementSize >> 32) == 0 && NumElements.getBitWidth() <= 64 &&
223 (NumElements.getZExtValue() >> 32) == 0) {
224 uint64_t TotalSize = NumElements.getZExtValue() * ElementSize;
225 return llvm::bit_width(TotalSize);
226 }
227
228
229 llvm::APSInt SizeExtended(NumElements, true);
231 SizeExtended = SizeExtended.extend(std::max(SizeTypeBits,
232 SizeExtended.getBitWidth()) * 2);
233
234 llvm::APSInt TotalSize(llvm::APInt(SizeExtended.getBitWidth(), ElementSize));
235 TotalSize *= SizeExtended;
236
237 return TotalSize.getActiveBits();
238}
239
240unsigned
243}
244
247
248
249
250
251 if (Bits > 61)
252 Bits = 61;
253
254 return Bits;
255}
256
259 uint64_t ArraySize, const Expr *SizeExpr,
262 ID.AddInteger(ArraySize);
263 ID.AddInteger(llvm::to_underlying(SizeMod));
264 ID.AddInteger(TypeQuals);
265 ID.AddBoolean(SizeExpr != nullptr);
266 if (SizeExpr)
267 SizeExpr->Profile(ID, Context, true);
268}
269
274}
275
276DependentSizedArrayType::DependentSizedArrayType(QualType et, QualType can,
278 unsigned tq,
280 : ArrayType(DependentSizedArray, et, can, sm, tq, e), SizeExpr((Stmt *)e),
281 Brackets(brackets) {}
282
287 unsigned TypeQuals,
290 ID.AddInteger(llvm::to_underlying(SizeMod));
291 ID.AddInteger(TypeQuals);
292 if (E)
293 E->Profile(ID, Context, true);
294}
295
296DependentVectorType::DependentVectorType(QualType ElementType,
299 : Type(DependentVector, CanonType,
301 ElementType->getDependence() |
304 ElementType(ElementType), SizeExpr(SizeExpr), Loc(Loc) {
305 VectorTypeBits.VecKind = llvm::to_underlying(VecKind);
306}
307
313 ID.AddInteger(llvm::to_underlying(VecKind));
314 SizeExpr->Profile(ID, Context, true);
315}
316
317DependentSizedExtVectorType::DependentSizedExtVectorType(QualType ElementType,
319 Expr *SizeExpr,
321 : Type(DependentSizedExtVector, can,
323 ElementType->getDependence() |
326 SizeExpr(SizeExpr), ElementType(ElementType), loc(loc) {}
327
328void
333 SizeExpr->Profile(ID, Context, true);
334}
335
336DependentAddressSpaceType::DependentAddressSpaceType(QualType PointeeType,
338 Expr *AddrSpaceExpr,
340 : Type(DependentAddressSpace, can,
342 PointeeType->getDependence() |
343 (AddrSpaceExpr ? toTypeDependence(AddrSpaceExpr->getDependence())
345 AddrSpaceExpr(AddrSpaceExpr), PointeeType(PointeeType), loc(loc) {}
346
350 Expr *AddrSpaceExpr) {
352 AddrSpaceExpr->Profile(ID, Context, true);
353}
354
356 const Expr *RowExpr, const Expr *ColumnExpr)
357 : Type(tc, canonType,
360 (matrixType->isVariablyModifiedType()
363 (matrixType->containsUnexpandedParameterPack() ||
364 (RowExpr &&
365 RowExpr->containsUnexpandedParameterPack()) ||
366 (ColumnExpr &&
367 ColumnExpr->containsUnexpandedParameterPack())
370 : matrixType->getDependence())),
371 ElementType(matrixType) {}
372
374 unsigned nColumns, QualType canonType)
376 canonType) {}
377
379 unsigned nRows, unsigned nColumns,
381 : MatrixType(tc, matrixType, canonType), NumRows(nRows),
382 NumColumns(nColumns) {}
383
384DependentSizedMatrixType::DependentSizedMatrixType(QualType ElementType,
386 Expr *RowExpr,
387 Expr *ColumnExpr,
389 : MatrixType(DependentSizedMatrix, ElementType, CanonicalType, RowExpr,
390 ColumnExpr),
391 RowExpr(RowExpr), ColumnExpr(ColumnExpr), loc(loc) {}
392
396 Expr *ColumnExpr) {
398 RowExpr->Profile(ID, CTX, true);
399 ColumnExpr->Profile(ID, CTX, true);
400}
401
404 : VectorType(Vector, vecType, nElements, canonType, vecKind) {}
405
408 : Type(tc, canonType, vecType->getDependence()), ElementType(vecType) {
409 VectorTypeBits.VecKind = llvm::to_underlying(vecKind);
411}
412
415 NumBits(NumBits) {}
416
420 ExprAndUnsigned(NumBitsExpr, IsUnsigned) {}
421
423 return ExprAndUnsigned.getInt();
424}
425
427 return ExprAndUnsigned.getPointer();
428}
429
431 const ASTContext &Context, bool IsUnsigned,
432 Expr *NumBitsExpr) {
433 ID.AddBoolean(IsUnsigned);
434 NumBitsExpr->Profile(ID, Context, true);
435}
436
440 return isa(Info.getDecl());
441 });
442}
443
446 bool CountInBytes, bool OrNull) {
448 ID.AddBoolean(CountInBytes);
449 ID.AddBoolean(OrNull);
450
451
452
453
454 ID.AddPointer(CountExpr);
455}
456
457
458
459
461
462 if (const auto *ATy = dyn_cast(this))
463 return ATy->getElementType().getTypePtr();
464
465
466 if (!isa(CanonicalType))
467 return nullptr;
468
469
470
472 ->getElementType().getTypePtr();
473}
474
475
476
477
478
479
480
484}
485
491}
492
493
494
495
496#define TYPE(CLASS, BASE) \
497 static_assert(!std::is_polymorphic<CLASS##Type>::value, \
498 #CLASS "Type should not be polymorphic!");
499#include "clang/AST/TypeNodes.inc"
500
501
502
503
504#define TYPE(CLASS, BASE) \
505 static_assert(std::is_trivially_destructible<CLASS##Type>::value, \
506 #CLASS "Type should be trivially destructible!");
507#include "clang/AST/TypeNodes.inc"
508
511#define ABSTRACT_TYPE(Class, Parent)
512#define TYPE(Class, Parent) \
513 case Type::Class: { \
514 const auto *ty = cast<Class##Type>(this); \
515 if (!ty->isSugared()) return QualType(ty, 0); \
516 return ty->desugar(); \
517 }
518#include "clang/AST/TypeNodes.inc"
519 }
520 llvm_unreachable("bad type kind!");
521}
522
525
527 while (true) {
528 const Type *CurTy = Qs.strip(Cur);
530#define ABSTRACT_TYPE(Class, Parent)
531#define TYPE(Class, Parent) \
532 case Type::Class: { \
533 const auto *Ty = cast<Class##Type>(CurTy); \
534 if (!Ty->isSugared()) \
535 return SplitQualType(Ty, Qs); \
536 Cur = Ty->desugar(); \
537 break; \
538 }
539#include "clang/AST/TypeNodes.inc"
540 }
541 }
542}
543
546
547
549
550
551 const Type *lastTypeWithQuals = split.Ty;
552
553 while (true) {
555
556
557
559#define ABSTRACT_TYPE(Class, Parent)
560#define TYPE(Class, Parent) \
561 case Type::Class: { \
562 const auto *ty = cast<Class##Type>(split.Ty); \
563 if (!ty->isSugared()) goto done; \
564 next = ty->desugar(); \
565 break; \
566 }
567#include "clang/AST/TypeNodes.inc"
568 }
569
570
571
574 lastTypeWithQuals = split.Ty;
576 }
577 }
578
579 done:
581}
582
584
586 T = PT->getInnerType();
587 return T;
588}
589
590
591
592
594 while (true) {
595 if (const auto *Sugar = dyn_cast(Cur))
596 return Sugar;
598#define ABSTRACT_TYPE(Class, Parent)
599#define TYPE(Class, Parent) \
600 case Type::Class: { \
601 const auto *Ty = cast<Class##Type>(Cur); \
602 if (!Ty->isSugared()) return 0; \
603 Cur = Ty->desugar().getTypePtr(); \
604 break; \
605 }
606#include "clang/AST/TypeNodes.inc"
607 }
608 }
609}
610
612 return getAsSugar(this);
613}
614
616 return getAsSugar(this);
617}
618
620 return getAsSugar(this);
621}
622
624 return getAsSugar(this);
625}
626
628 return getAsSugar(this);
629}
630
632 return getAsSugar(this);
633}
634
635
636
637
639 const Type *Cur = this;
640
641 while (true) {
643#define ABSTRACT_TYPE(Class, Parent)
644#define TYPE(Class, Parent) \
645 case Class: { \
646 const auto *Ty = cast<Class##Type>(Cur); \
647 if (!Ty->isSugared()) return Cur; \
648 Cur = Ty->desugar().getTypePtr(); \
649 break; \
650 }
651#include "clang/AST/TypeNodes.inc"
652 }
653 }
654}
655
657 if (const auto *RT = getAs())
658 return RT->getDecl()->isClass();
659 return false;
660}
661
663 if (const auto *RT = getAs())
664 return RT->getDecl()->isStruct();
665 return false;
666}
667
669 const auto *RT = getAs();
670 if (!RT)
671 return false;
672 const auto *Decl = RT->getDecl();
673 if (->isStruct())
674 return false;
675 return Decl->hasFlexibleArrayMember();
676}
677
679 if (const auto *RT = getAs())
680 return RT->getDecl()->hasAttr();
681 return false;
682}
683
685 if (const auto *RT = getAs())
686 return RT->getDecl()->isInterface();
687 return false;
688}
689
691 if (const auto *RT = getAs()) {
694 }
695 return false;
696}
697
699 if (const auto *PT = getAs())
700 return PT->getPointeeType()->isVoidType();
701 return false;
702}
703
705 if (const auto *RT = getAs())
706 return RT->getDecl()->isUnion();
707 return false;
708}
709
711 if (const auto *CT = dyn_cast(CanonicalType))
712 return CT->getElementType()->isFloatingType();
713 return false;
714}
715
717
719}
720
722 if (const auto *ET = getAs())
723 return ET->getDecl()->isScoped();
724 return false;
725}
726
728 return getAs();
729}
730
732 if (const auto *Complex = getAs())
733 if (Complex->getElementType()->isIntegerType())
735 return nullptr;
736}
737
739 if (const auto *PT = getAs())
741 if (const auto *OPT = getAs())
743 if (const auto *BPT = getAs())
745 if (const auto *RT = getAs())
747 if (const auto *MPT = getAs())
749 if (const auto *DT = getAs())
751 return {};
752}
753
755
756 if (const auto *RT = dyn_cast(this)) {
757 if (RT->getDecl()->isStruct())
758 return RT;
759 }
760
761
762 if (const auto *RT = dyn_cast(CanonicalType)) {
763 if (!RT->getDecl()->isStruct())
764 return nullptr;
765
766
767
769 }
770 return nullptr;
771}
772
774
775 if (const auto *RT = dyn_cast(this)) {
776 if (RT->getDecl()->isUnion())
777 return RT;
778 }
779
780
781 if (const auto *RT = dyn_cast(CanonicalType)) {
782 if (!RT->getDecl()->isUnion())
783 return nullptr;
784
785
786
788 }
789
790 return nullptr;
791}
792
795 bound = nullptr;
796
797 const auto *OPT = getAs();
798 if (!OPT)
799 return false;
800
801
802 if (OPT->isObjCIdType())
803 return true;
804
805
806 if (!OPT->isKindOfType())
807 return false;
808
809
810 if (OPT->isObjCClassType() || OPT->isObjCQualifiedClassType())
811 return false;
812
813
816 return true;
817}
818
820 const auto *OPT = getAs();
821 if (!OPT)
822 return false;
823
824
825 if (OPT->isObjCClassType())
826 return true;
827
828
829 if (!OPT->isKindOfType())
830 return false;
831
832
833 return OPT->isObjCClassType() || OPT->isObjCQualifiedClassType();
834}
835
841}
842
846 bool isKindOf)
847 : Type(ObjCObject, Canonical, Base->getDependence()), BaseType(Base) {
849
852 "bitfield overflow in type argument count");
853 if (!typeArgs.empty())
854 memcpy(getTypeArgStorage(), typeArgs.data(),
855 typeArgs.size() * sizeof(QualType));
856
857 for (auto typeArg : typeArgs) {
858 addDependence(typeArg->getDependence() & ~TypeDependence::VariablyModified);
859 }
860
861
863}
864
866
868 return true;
869
870
871 if (const auto objcObject = getBaseType()->getAs()) {
872
873 if (isa(objcObject))
874 return false;
875
876 return objcObject->isSpecialized();
877 }
878
879
880 return false;
881}
882
884
887
888
889 if (const auto objcObject = getBaseType()->getAs()) {
890
891 if (isa(objcObject))
892 return {};
893
894 return objcObject->getTypeArgs();
895 }
896
897
898 return {};
899}
900
903 return true;
904
905
906 if (const auto objcObject = getBaseType()->getAs()) {
907
908 if (isa(objcObject))
909 return false;
910
911 return objcObject->isKindOfType();
912 }
913
914
915 return false;
916}
917
922
923
925 QualType baseType(splitBaseType.Ty, 0);
927 baseType = baseObj->stripObjCKindOfTypeAndQuals(ctx);
928
930 splitBaseType.Quals),
932 {},
933 false);
934}
935
939 return Def;
940 return Canon;
941}
942
946 return this;
947
950}
951
952namespace {
953
954
955
956template
957struct SimpleTransformVisitor : public TypeVisitor<Derived, QualType> {
959
961
963
964
965 QualType result = static_cast<Derived *>(this)->Visit(splitType.Ty);
967 return result;
968
969
970
972 }
973
974public:
975 explicit SimpleTransformVisitor(ASTContext &ctx) : Ctx(ctx) {}
976
977
978
979#define TYPE(Class, Base)
980#define DEPENDENT_TYPE(Class, Base) \
981 QualType Visit##Class##Type(const Class##Type *T) { return QualType(T, 0); }
982#include "clang/AST/TypeNodes.inc"
983
984#define TRIVIAL_TYPE_CLASS(Class) \
985 QualType Visit##Class##Type(const Class##Type *T) { return QualType(T, 0); }
986#define SUGARED_TYPE_CLASS(Class) \
987 QualType Visit##Class##Type(const Class##Type *T) { \
988 if (!T->isSugared()) \
989 return QualType(T, 0); \
990 QualType desugaredType = recurse(T->desugar()); \
991 if (desugaredType.isNull()) \
992 return {}; \
993 if (desugaredType.getAsOpaquePtr() == T->desugar().getAsOpaquePtr()) \
994 return QualType(T, 0); \
995 return desugaredType; \
996 }
997
999
1001 QualType elementType = recurse(T->getElementType());
1002 if (elementType.isNull())
1003 return {};
1004
1005 if (elementType.getAsOpaquePtr() == T->getElementType().getAsOpaquePtr())
1007
1009 }
1010
1013 if (pointeeType.isNull())
1014 return {};
1015
1018
1020 }
1021
1024 if (pointeeType.isNull())
1025 return {};
1026
1029
1031 }
1032
1034 QualType pointeeType = recurse(T->getPointeeTypeAsWritten());
1035 if (pointeeType.isNull())
1036 return {};
1037
1039 == T->getPointeeTypeAsWritten().getAsOpaquePtr())
1041
1043 }
1044
1046 QualType pointeeType = recurse(T->getPointeeTypeAsWritten());
1047 if (pointeeType.isNull())
1048 return {};
1049
1051 == T->getPointeeTypeAsWritten().getAsOpaquePtr())
1053
1055 }
1056
1059 if (pointeeType.isNull())
1060 return {};
1061
1064
1066 }
1067
1069 QualType elementType = recurse(T->getElementType());
1070 if (elementType.isNull())
1071 return {};
1072
1073 if (elementType.getAsOpaquePtr() == T->getElementType().getAsOpaquePtr())
1075
1077 T->getSizeModifier(),
1078 T->getIndexTypeCVRQualifiers());
1079 }
1080
1082 QualType elementType = recurse(T->getElementType());
1083 if (elementType.isNull())
1084 return {};
1085
1086 if (elementType.getAsOpaquePtr() == T->getElementType().getAsOpaquePtr())
1088
1090 T->getSizeModifier(),
1091 T->getIndexTypeCVRQualifiers(),
1092 T->getBracketsRange());
1093 }
1094
1096 QualType elementType = recurse(T->getElementType());
1097 if (elementType.isNull())
1098 return {};
1099
1100 if (elementType.getAsOpaquePtr() == T->getElementType().getAsOpaquePtr())
1102
1104 T->getIndexTypeCVRQualifiers());
1105 }
1106
1108 QualType elementType = recurse(T->getElementType());
1109 if (elementType.isNull())
1110 return {};
1111
1112 if (elementType.getAsOpaquePtr() == T->getElementType().getAsOpaquePtr())
1114
1115 return Ctx.getVectorType(elementType, T->getNumElements(),
1116 T->getVectorKind());
1117 }
1118
1120 QualType elementType = recurse(T->getElementType());
1121 if (elementType.isNull())
1122 return {};
1123
1124 if (elementType.getAsOpaquePtr() == T->getElementType().getAsOpaquePtr())
1126
1128 }
1129
1131 QualType elementType = recurse(T->getElementType());
1132 if (elementType.isNull())
1133 return {};
1134 if (elementType.getAsOpaquePtr() == T->getElementType().getAsOpaquePtr())
1136
1138 T->getNumColumns());
1139 }
1140
1143 if (returnType.isNull())
1144 return {};
1145
1148
1150 }
1151
1154 if (returnType.isNull())
1155 return {};
1156
1157
1159 bool paramChanged = false;
1161 QualType newParamType = recurse(paramType);
1162 if (newParamType.isNull())
1163 return {};
1164
1165 if (newParamType.getAsOpaquePtr() != paramType.getAsOpaquePtr())
1166 paramChanged = true;
1167
1168 paramTypes.push_back(newParamType);
1169 }
1170
1171
1173 bool exceptionChanged = false;
1177 QualType newExceptionType = recurse(exceptionType);
1178 if (newExceptionType.isNull())
1179 return {};
1180
1181 if (newExceptionType.getAsOpaquePtr() != exceptionType.getAsOpaquePtr())
1182 exceptionChanged = true;
1183
1184 exceptionTypes.push_back(newExceptionType);
1185 }
1186
1187 if (exceptionChanged) {
1190 }
1191 }
1192
1194 !paramChanged && !exceptionChanged)
1196
1197 return Ctx.getFunctionType(returnType, paramTypes, info);
1198 }
1199
1201 QualType innerType = recurse(T->getInnerType());
1202 if (innerType.isNull())
1203 return {};
1204
1205 if (innerType.getAsOpaquePtr() == T->getInnerType().getAsOpaquePtr())
1207
1209 }
1210
1214
1216 QualType originalType = recurse(T->getOriginalType());
1217 if (originalType.isNull())
1218 return {};
1219
1220 QualType adjustedType = recurse(T->getAdjustedType());
1221 if (adjustedType.isNull())
1222 return {};
1223
1225 == T->getOriginalType().getAsOpaquePtr() &&
1226 adjustedType.getAsOpaquePtr() == T->getAdjustedType().getAsOpaquePtr())
1228
1230 }
1231
1233 QualType originalType = recurse(T->getOriginalType());
1234 if (originalType.isNull())
1235 return {};
1236
1238 == T->getOriginalType().getAsOpaquePtr())
1240
1242 }
1243
1245 QualType ArrTy = VisitConstantArrayType(T);
1247 return {};
1248
1250 }
1251
1258
1259
1261
1263 QualType modifiedType = recurse(T->getModifiedType());
1264 if (modifiedType.isNull())
1265 return {};
1266
1267 QualType equivalentType = recurse(T->getEquivalentType());
1268 if (equivalentType.isNull())
1269 return {};
1270
1272 == T->getModifiedType().getAsOpaquePtr() &&
1274 == T->getEquivalentType().getAsOpaquePtr())
1276
1277 return Ctx.getAttributedType(T->getAttrKind(), modifiedType, equivalentType,
1278 T->getAttr());
1279 }
1280
1282 QualType replacementType = recurse(T->getReplacementType());
1283 if (replacementType.isNull())
1284 return {};
1285
1287 == T->getReplacementType().getAsOpaquePtr())
1289
1291 T->getAssociatedDecl(),
1292 T->getIndex(), T->getPackIndex());
1293 }
1294
1295
1297
1299 if (->isDeduced())
1301
1302 QualType deducedType = recurse(T->getDeducedType());
1303 if (deducedType.isNull())
1304 return {};
1305
1307 == T->getDeducedType().getAsOpaquePtr())
1309
1310 return Ctx.getAutoType(deducedType, T->getKeyword(),
1312 T->getTypeConstraintConcept(),
1313 T->getTypeConstraintArguments());
1314 }
1315
1317 QualType baseType = recurse(T->getBaseType());
1318 if (baseType.isNull())
1319 return {};
1320
1321
1322 bool typeArgChanged = false;
1324 for (auto typeArg : T->getTypeArgsAsWritten()) {
1325 QualType newTypeArg = recurse(typeArg);
1326 if (newTypeArg.isNull())
1327 return {};
1328
1329 if (newTypeArg.getAsOpaquePtr() != typeArg.getAsOpaquePtr())
1330 typeArgChanged = true;
1331
1332 typeArgs.push_back(newTypeArg);
1333 }
1334
1335 if (baseType.getAsOpaquePtr() == T->getBaseType().getAsOpaquePtr() &&
1336 !typeArgChanged)
1338
1340 baseType, typeArgs,
1342 T->isKindOfTypeAsWritten());
1343 }
1344
1346
1349 if (pointeeType.isNull())
1350 return {};
1351
1355
1357 }
1358
1360 QualType valueType = recurse(T->getValueType());
1361 if (valueType.isNull())
1362 return {};
1363
1365 == T->getValueType().getAsOpaquePtr())
1367
1369 }
1370
1371#undef TRIVIAL_TYPE_CLASS
1372#undef SUGARED_TYPE_CLASS
1373};
1374
1375struct SubstObjCTypeArgsVisitor
1376 : public SimpleTransformVisitor {
1377 using BaseType = SimpleTransformVisitor;
1378
1381
1384 : BaseType(ctx), TypeArgs(typeArgs), SubstContext(context) {}
1385
1387
1388
1390
1391 if (!TypeArgs.empty()) {
1394 return argType;
1395
1396
1397 bool hasError;
1402 argType, protocolsToApply, hasError, true);
1403 }
1404
1405 switch (SubstContext) {
1406 case ObjCSubstitutionContext::Ordinary:
1407 case ObjCSubstitutionContext::Parameter:
1408 case ObjCSubstitutionContext::Superclass:
1409
1411
1412 case ObjCSubstitutionContext::Result:
1413 case ObjCSubstitutionContext::Property: {
1414
1415 const auto *objPtr =
1417
1418
1419
1420 if (objPtr->isKindOfType() || objPtr->isObjCIdOrClassType())
1422
1423
1424 const auto *obj = objPtr->getObjectType();
1426 obj->getBaseType(), obj->getTypeArgsAsWritten(), obj->getProtocols(),
1427 true);
1428
1429
1431 }
1432 }
1433 llvm_unreachable("Unexpected ObjCSubstitutionContext!");
1434 }
1435
1437
1438
1439
1440
1442 Ctx, TypeArgs, ObjCSubstitutionContext::Result);
1443 if (returnType.isNull())
1444 return {};
1445
1446
1447
1448 if (isa(funcType)) {
1449
1452 return BaseType::VisitFunctionType(funcType);
1453
1454
1456 }
1457
1458 const auto *funcProtoType = cast(funcType);
1459
1460
1462 bool paramChanged = false;
1463 for (auto paramType : funcProtoType->getParamTypes()) {
1465 Ctx, TypeArgs, ObjCSubstitutionContext::Parameter);
1466 if (newParamType.isNull())
1467 return {};
1468
1469 if (newParamType.getAsOpaquePtr() != paramType.getAsOpaquePtr())
1470 paramChanged = true;
1471
1472 paramTypes.push_back(newParamType);
1473 }
1474
1475
1477 bool exceptionChanged = false;
1482 Ctx, TypeArgs, ObjCSubstitutionContext::Ordinary);
1483 if (newExceptionType.isNull())
1484 return {};
1485
1486 if (newExceptionType.getAsOpaquePtr() != exceptionType.getAsOpaquePtr())
1487 exceptionChanged = true;
1488
1489 exceptionTypes.push_back(newExceptionType);
1490 }
1491
1492 if (exceptionChanged) {
1495 }
1496 }
1497
1499 funcProtoType->getReturnType().getAsOpaquePtr() &&
1500 !paramChanged && !exceptionChanged)
1501 return BaseType::VisitFunctionType(funcType);
1502
1503 return Ctx.getFunctionType(returnType, paramTypes, info);
1504 }
1505
1507
1508
1511 bool anyChanged = false;
1514 Ctx, TypeArgs, ObjCSubstitutionContext::Ordinary);
1515 if (newTypeArg.isNull())
1516 return {};
1517
1518 if (newTypeArg.getAsOpaquePtr() != typeArg.getAsOpaquePtr()) {
1519
1520
1523 if (TypeArgs.empty() &&
1524 SubstContext != ObjCSubstitutionContext::Superclass) {
1526 objcObjectType->getBaseType(), {}, protocols,
1528 }
1529
1530 anyChanged = true;
1531 }
1532
1533 newTypeArgs.push_back(newTypeArg);
1534 }
1535
1536 if (anyChanged) {
1540 protocols,
1542 }
1543 }
1544
1545 return BaseType::VisitObjCObjectType(objcObjectType);
1546 }
1547
1549 QualType newType = BaseType::VisitAttributedType(attrType);
1550 if (newType.isNull())
1551 return {};
1552
1553 const auto *newAttrType = dyn_cast(newType.getTypePtr());
1554 if (!newAttrType || newAttrType->getAttrKind() != attr::ObjCKindOf)
1555 return newType;
1556
1557
1558 QualType newEquivType = newAttrType->getEquivalentType();
1564 if (!objType)
1565 return newType;
1566
1567
1568
1570 objType->getBaseType(), objType->getTypeArgsAsWritten(),
1571 objType->getProtocols(),
1572
1573 objType->isObjCUnqualifiedId() ? false : true);
1574
1575
1576 if (ptrType)
1578
1579
1581 newAttrType->getModifiedType(), newEquivType,
1582 newAttrType->getAttr());
1583 }
1584};
1585
1586struct StripObjCKindOfTypeVisitor
1587 : public SimpleTransformVisitor {
1588 using BaseType = SimpleTransformVisitor;
1589
1590 explicit StripObjCKindOfTypeVisitor(ASTContext &ctx) : BaseType(ctx) {}
1591
1594 return BaseType::VisitObjCObjectType(objType);
1595
1599 false);
1600 }
1601};
1602
1603}
1604
1607 if (!BT) {
1609 if (VT) {
1612 }
1613 } else {
1614 switch (BT->getKind()) {
1615 case BuiltinType::Kind::Float16: {
1618 Ctx.getLangOpts().getFloat16ExcessPrecision() !=
1619 Ctx.getLangOpts().ExcessPrecisionKind::FPP_None)
1620 return true;
1621 break;
1622 }
1623 case BuiltinType::Kind::BFloat16: {
1626 Ctx.getLangOpts().getBFloat16ExcessPrecision() !=
1627 Ctx.getLangOpts().ExcessPrecisionKind::FPP_None)
1628 return true;
1629 break;
1630 }
1631 default:
1632 return false;
1633 }
1634 }
1635 return false;
1636}
1637
1638
1639
1643 SubstObjCTypeArgsVisitor visitor(ctx, typeArgs, context);
1644 return visitor.recurse(*this);
1645}
1646
1652
1653 return *this;
1654}
1655
1657
1658 auto &ctx = const_cast<ASTContext &>(constCtx);
1659 StripObjCKindOfTypeVisitor visitor(ctx);
1660 return visitor.recurse(*this);
1661}
1662
1666 T = AT->getValueType();
1667 return T.getUnqualifiedType();
1668}
1669
1670std::optional<ArrayRef>
1672
1673 if (const auto method = dyn_cast(dc))
1674 dc = method->getDeclContext();
1675
1676
1677
1678 const auto *dcClassDecl = dyn_cast(dc);
1681 if (dcClassDecl) {
1682
1683
1684 dcTypeParams = dcClassDecl->getTypeParamList();
1685 if (!dcTypeParams)
1686 return std::nullopt;
1687 } else {
1688
1689
1690 dcCategoryDecl = dyn_cast(dc);
1691 if (!dcCategoryDecl)
1692 return std::nullopt;
1693
1694
1695
1697 if (!dcTypeParams)
1698 return std::nullopt;
1699
1701 if (!dcClassDecl)
1702 return std::nullopt;
1703 }
1704 assert(dcTypeParams && "No substitutions to perform");
1705 assert(dcClassDecl && "No class context");
1706
1707
1709 if (const auto *objectPointerType = getAs()) {
1710 objectType = objectPointerType->getObjectType();
1711 } else if (getAs()) {
1715 } else {
1716 objectType = getAs();
1717 }
1718
1719
1721 : nullptr;
1722 if (!curClassDecl) {
1723
1724
1726 }
1727
1728
1729
1730 while (curClassDecl != dcClassDecl) {
1731
1733 if (superType.isNull()) {
1734 objectType = nullptr;
1735 break;
1736 }
1737
1740 }
1741
1742
1743
1746 }
1747
1748
1750}
1751
1754 if (auto *ID = IfaceT->getInterface()) {
1755 if (ID->getTypeParamList())
1756 return true;
1757 }
1758 }
1759
1760 return false;
1761}
1762
1764
1765
1766
1768 if (!classDecl) {
1769 CachedSuperClassType.setInt(true);
1770 return;
1771 }
1772
1773
1775 if (!superClassObjTy) {
1776 CachedSuperClassType.setInt(true);
1777 return;
1778 }
1779
1781 if (!superClassDecl) {
1782 CachedSuperClassType.setInt(true);
1783 return;
1784 }
1785
1786
1787
1788 QualType superClassType(superClassObjTy, 0);
1790 if (!superClassTypeParams) {
1791 CachedSuperClassType.setPointerAndInt(
1793 return;
1794 }
1795
1796
1798 CachedSuperClassType.setPointerAndInt(superClassObjTy, true);
1799 return;
1800 }
1801
1802
1803
1805 if (!typeParams) {
1806 CachedSuperClassType.setPointerAndInt(
1808 return;
1809 }
1810
1811
1812
1817 CachedSuperClassType.setPointerAndInt(
1819 true);
1820 return;
1821 }
1822
1823
1825 assert(typeArgs.size() == typeParams->size());
1826 CachedSuperClassType.setPointerAndInt(
1830 true);
1831}
1832
1834 if (auto interfaceDecl = getObjectType()->getInterface()) {
1835 return interfaceDecl->getASTContext().getObjCInterfaceType(interfaceDecl)
1837 }
1838
1839 return nullptr;
1840}
1841
1844 if (superObjectType.isNull())
1845 return superObjectType;
1846
1849}
1850
1852
1853
1854
1855 if (const auto *T = getAs())
1856 if (T->getNumProtocols() && T->getInterface())
1857 return T;
1858 return nullptr;
1859}
1860
1863}
1864
1866
1867
1868 if (const auto *OPT = getAs()) {
1869 if (OPT->isObjCQualifiedIdType())
1870 return OPT;
1871 }
1872 return nullptr;
1873}
1874
1876
1877
1878 if (const auto *OPT = getAs()) {
1879 if (OPT->isObjCQualifiedClassType())
1880 return OPT;
1881 }
1882 return nullptr;
1883}
1884
1886 if (const auto *OT = getAs()) {
1887 if (OT->getInterface())
1888 return OT;
1889 }
1890 return nullptr;
1891}
1892
1894 if (const auto *OPT = getAs()) {
1895 if (OPT->getInterfaceType())
1896 return OPT;
1897 }
1898 return nullptr;
1899}
1900
1903 if (const auto *PT = getAs())
1905 else if (const auto *RT = getAs())
1907 else
1908 return nullptr;
1909
1911 return dyn_cast(RT->getDecl());
1912
1913 return nullptr;
1914}
1915
1917 return dyn_cast_or_null(getAsTagDecl());
1918}
1919
1921 return dyn_cast_or_null(getAsTagDecl());
1922}
1923
1925 if (const auto *TT = getAs())
1926 return TT->getDecl();
1927 if (const auto *Injected = getAs())
1928 return Injected->getDecl();
1929
1930 return nullptr;
1931}
1932
1934 const Type *Cur = this;
1936 if (AT->getAttrKind() == AK)
1937 return true;
1938 Cur = AT->getEquivalentType().getTypePtr();
1939 }
1940 return false;
1941}
1942
1943namespace {
1944
1945 class GetContainedDeducedTypeVisitor :
1946 public TypeVisitor<GetContainedDeducedTypeVisitor, Type*> {
1947 bool Syntactic;
1948
1949 public:
1950 GetContainedDeducedTypeVisitor(bool Syntactic = false)
1951 : Syntactic(Syntactic) {}
1952
1953 using TypeVisitor<GetContainedDeducedTypeVisitor, Type*>::Visit;
1954
1956 if (T.isNull())
1957 return nullptr;
1958 return Visit(T.getTypePtr());
1959 }
1960
1961
1964 }
1965
1966
1968 return Visit(T->getReplacementType());
1969 }
1970
1972 return Visit(T->getNamedType());
1973 }
1974
1977 }
1978
1981 }
1982
1984 return Visit(T->getPointeeTypeAsWritten());
1985 }
1986
1989 }
1990
1992 return Visit(T->getElementType());
1993 }
1994
1995 Type *VisitDependentSizedExtVectorType(
1997 return Visit(T->getElementType());
1998 }
1999
2001 return Visit(T->getElementType());
2002 }
2003
2005 return Visit(T->getElementType());
2006 }
2007
2009 return Visit(T->getElementType());
2010 }
2011
2015 return VisitFunctionType(T);
2016 }
2017
2020 }
2021
2023 return Visit(T->getInnerType());
2024 }
2025
2027 return Visit(T->getModifiedType());
2028 }
2029
2031 return Visit(T->getUnderlyingType());
2032 }
2033
2035 return Visit(T->getOriginalType());
2036 }
2037
2039 return Visit(T->getPattern());
2040 }
2041 };
2042
2043}
2044
2046 return cast_or_null(
2047 GetContainedDeducedTypeVisitor().Visit(this));
2048}
2049
2051 return isa_and_nonnull(
2052 GetContainedDeducedTypeVisitor(true).Visit(this));
2053}
2054
2056 if (const auto *VT = dyn_cast(CanonicalType))
2057 return VT->getElementType()->isIntegerType();
2058 if (CanonicalType->isSveVLSBuiltinType()) {
2059 const auto *VT = cast(CanonicalType);
2060 return VT->getKind() == BuiltinType::SveBool ||
2061 (VT->getKind() >= BuiltinType::SveInt8 &&
2062 VT->getKind() <= BuiltinType::SveUint64);
2063 }
2064 if (CanonicalType->isRVVVLSBuiltinType()) {
2065 const auto *VT = cast(CanonicalType);
2066 return (VT->getKind() >= BuiltinType::RvvInt8mf8 &&
2067 VT->getKind() <= BuiltinType::RvvUint64m8);
2068 }
2069
2071}
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2093 if (const auto *BT = dyn_cast(CanonicalType))
2094 return BT->getKind() >= BuiltinType::Bool &&
2095 BT->getKind() <= BuiltinType::Int128;
2096
2097
2099 if (const auto *ET = dyn_cast(CanonicalType))
2100 return ET->getDecl()->isComplete();
2101
2103}
2104
2106 if (const auto *BT = dyn_cast(CanonicalType))
2107 return BT->getKind() >= BuiltinType::Bool &&
2108 BT->getKind() <= BuiltinType::Int128;
2109
2111 return true;
2112
2114}
2115
2117 if (const auto *ET = dyn_cast(CanonicalType))
2118 return !ET->getDecl()->isScoped();
2119
2120 return false;
2121}
2122
2124 if (const auto *BT = dyn_cast(CanonicalType))
2125 return BT->getKind() == BuiltinType::Char_U ||
2126 BT->getKind() == BuiltinType::UChar ||
2127 BT->getKind() == BuiltinType::Char_S ||
2128 BT->getKind() == BuiltinType::SChar;
2129 return false;
2130}
2131
2133 if (const auto *BT = dyn_cast(CanonicalType))
2134 return BT->getKind() == BuiltinType::WChar_S ||
2135 BT->getKind() == BuiltinType::WChar_U;
2136 return false;
2137}
2138
2140 if (const BuiltinType *BT = dyn_cast(CanonicalType))
2141 return BT->getKind() == BuiltinType::Char8;
2142 return false;
2143}
2144
2146 if (const auto *BT = dyn_cast(CanonicalType))
2147 return BT->getKind() == BuiltinType::Char16;
2148 return false;
2149}
2150
2152 if (const auto *BT = dyn_cast(CanonicalType))
2153 return BT->getKind() == BuiltinType::Char32;
2154 return false;
2155}
2156
2157
2158
2160 const auto *BT = dyn_cast(CanonicalType);
2161 if (!BT) return false;
2162 switch (BT->getKind()) {
2163 default: return false;
2164 case BuiltinType::Char_U:
2165 case BuiltinType::UChar:
2166 case BuiltinType::WChar_U:
2167 case BuiltinType::Char8:
2168 case BuiltinType::Char16:
2169 case BuiltinType::Char32:
2170 case BuiltinType::Char_S:
2171 case BuiltinType::SChar:
2172 case BuiltinType::WChar_S:
2173 return true;
2174 }
2175}
2176
2177
2178
2179
2181 if (const auto *BT = dyn_cast(CanonicalType)) {
2182 return BT->getKind() >= BuiltinType::Char_S &&
2183 BT->getKind() <= BuiltinType::Int128;
2184 }
2185
2186 if (const EnumType *ET = dyn_cast(CanonicalType)) {
2187
2188
2189 if (ET->getDecl()->isComplete() && !ET->getDecl()->isScoped())
2191 }
2192
2193 if (const auto *IT = dyn_cast(CanonicalType))
2194 return IT->isSigned();
2195 if (const auto *IT = dyn_cast(CanonicalType))
2196 return IT->isSigned();
2197
2198 return false;
2199}
2200
2202 if (const auto *BT = dyn_cast(CanonicalType)) {
2203 return BT->getKind() >= BuiltinType::Char_S &&
2204 BT->getKind() <= BuiltinType::Int128;
2205 }
2206
2207 if (const auto *ET = dyn_cast(CanonicalType)) {
2208 if (ET->getDecl()->isComplete())
2210 }
2211
2212 if (const auto *IT = dyn_cast(CanonicalType))
2213 return IT->isSigned();
2214 if (const auto *IT = dyn_cast(CanonicalType))
2215 return IT->isSigned();
2216
2217 return false;
2218}
2219
2221 if (const auto *VT = dyn_cast(CanonicalType))
2222 return VT->getElementType()->isSignedIntegerOrEnumerationType();
2223 else
2225}
2226
2227
2228
2229
2231 if (const auto *BT = dyn_cast(CanonicalType)) {
2232 return BT->getKind() >= BuiltinType::Bool &&
2233 BT->getKind() <= BuiltinType::UInt128;
2234 }
2235
2236 if (const auto *ET = dyn_cast(CanonicalType)) {
2237
2238
2239 if (ET->getDecl()->isComplete() && !ET->getDecl()->isScoped())
2241 }
2242
2243 if (const auto *IT = dyn_cast(CanonicalType))
2244 return IT->isUnsigned();
2245 if (const auto *IT = dyn_cast(CanonicalType))
2246 return IT->isUnsigned();
2247
2248 return false;
2249}
2250
2252 if (const auto *BT = dyn_cast(CanonicalType)) {
2253 return BT->getKind() >= BuiltinType::Bool &&
2254 BT->getKind() <= BuiltinType::UInt128;
2255 }
2256
2257 if (const auto *ET = dyn_cast(CanonicalType)) {
2258 if (ET->getDecl()->isComplete())
2260 }
2261
2262 if (const auto *IT = dyn_cast(CanonicalType))
2263 return IT->isUnsigned();
2264 if (const auto *IT = dyn_cast(CanonicalType))
2265 return IT->isUnsigned();
2266
2267 return false;
2268}
2269
2271 if (const auto *VT = dyn_cast(CanonicalType))
2272 return VT->getElementType()->isUnsignedIntegerOrEnumerationType();
2273 if (const auto *VT = dyn_cast(CanonicalType))
2274 return VT->getElementType()->isUnsignedIntegerOrEnumerationType();
2275 if (CanonicalType->isSveVLSBuiltinType()) {
2276 const auto *VT = cast(CanonicalType);
2277 return VT->getKind() >= BuiltinType::SveUint8 &&
2278 VT->getKind() <= BuiltinType::SveUint64;
2279 }
2281}
2282
2284 if (const auto *BT = dyn_cast(CanonicalType))
2285 return BT->getKind() >= BuiltinType::Half &&
2286 BT->getKind() <= BuiltinType::Ibm128;
2287 if (const auto *CT = dyn_cast(CanonicalType))
2288 return CT->getElementType()->isFloatingType();
2289 return false;
2290}
2291
2293 if (const auto *VT = dyn_cast(CanonicalType))
2294 return VT->getElementType()->isFloatingType();
2295 if (const auto *MT = dyn_cast(CanonicalType))
2296 return MT->getElementType()->isFloatingType();
2298}
2299
2301 if (const auto *BT = dyn_cast(CanonicalType))
2302 return BT->isFloatingPoint();
2303 return false;
2304}
2305
2307 if (const auto *BT = dyn_cast(CanonicalType))
2308 return BT->getKind() >= BuiltinType::Bool &&
2309 BT->getKind() <= BuiltinType::Ibm128;
2310 if (const auto *ET = dyn_cast(CanonicalType))
2311 return ET->getDecl()->isComplete() && !ET->getDecl()->isScoped();
2313}
2314
2316 if (const auto *BT = dyn_cast(CanonicalType))
2317 return BT->getKind() >= BuiltinType::Bool &&
2318 BT->getKind() <= BuiltinType::Ibm128;
2319 if (const auto *ET = dyn_cast(CanonicalType))
2320
2321
2322
2323
2324
2325
2326 return !ET->getDecl()->isScoped() && ET->getDecl()->isComplete();
2327 return isa(CanonicalType) || isBitIntType();
2328}
2329
2332
2333 const Type *T = CanonicalType.getTypePtr();
2334 if (const auto *BT = dyn_cast(T)) {
2335 if (BT->getKind() == BuiltinType::Bool) return STK_Bool;
2336 if (BT->getKind() == BuiltinType::NullPtr) return STK_CPointer;
2338 if (BT->isFloatingPoint()) return STK_Floating;
2340 llvm_unreachable("unknown scalar builtin type");
2341 } else if (isa(T)) {
2343 } else if (isa(T)) {
2345 } else if (isa(T)) {
2347 } else if (isa(T)) {
2349 } else if (isa(T)) {
2350 assert(cast(T)->getDecl()->isComplete());
2352 } else if (const auto *CT = dyn_cast(T)) {
2353 if (CT->getElementType()->isRealFloatingType())
2358 }
2359
2360 llvm_unreachable("unknown scalar type");
2361}
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2373 if (const auto *Record = dyn_cast(CanonicalType)) {
2374 if (const auto *ClassDecl = dyn_cast(Record->getDecl()))
2375 return ClassDecl->isAggregate();
2376
2377 return true;
2378 }
2379
2380 return isa(CanonicalType);
2381}
2382
2383
2384
2385
2387 assert(() && "This doesn't make sense for incomplete types");
2388 assert(() && "This doesn't make sense for dependent types");
2389
2390 return !isa(CanonicalType);
2391}
2392
2393
2394
2395
2397 if (Def)
2398 *Def = nullptr;
2399
2400 switch (CanonicalType->getTypeClass()) {
2401 default: return false;
2402 case Builtin:
2403
2404
2406 case Enum: {
2407 EnumDecl *EnumD = cast(CanonicalType)->getDecl();
2408 if (Def)
2409 *Def = EnumD;
2411 }
2413
2414
2415 RecordDecl *Rec = cast(CanonicalType)->getDecl();
2416 if (Def)
2417 *Def = Rec;
2419 }
2420 case InjectedClassName: {
2421 CXXRecordDecl *Rec = cast(CanonicalType)->getDecl();
2423 return false;
2424 if (Def)
2425 *Def = Rec;
2426 return true;
2427 }
2428 case ConstantArray:
2429 case VariableArray:
2430
2431
2432
2433
2434 return cast(CanonicalType)->getElementType()
2435 ->isIncompleteType(Def);
2436 case IncompleteArray:
2437
2438 return true;
2439 case MemberPointer: {
2440
2441
2442
2443 auto *MPTy = cast(CanonicalType);
2444 const Type *ClassTy = MPTy->getClass();
2445
2447 return false;
2450
2452 return false;
2453
2454
2456
2457 if (RD->hasAttr())
2458 return false;
2459 return true;
2460 }
2461 case ObjCObject:
2462 return cast(CanonicalType)->getBaseType()
2463 ->isIncompleteType(Def);
2464 case ObjCInterface: {
2465
2467 = cast(CanonicalType)->getDecl();
2468 if (Def)
2470 return ->hasDefinition();
2471 }
2472 }
2473}
2474
2477 return true;
2478
2479 if (const BuiltinType *BT = getAs()) {
2480 switch (BT->getKind()) {
2481
2482#define WASM_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
2483#include "clang/Basic/WebAssemblyReferenceTypes.def"
2484
2485#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
2486#include "clang/Basic/HLSLIntangibleTypes.def"
2487 return true;
2488 default:
2489 return false;
2490 }
2491 }
2492 return false;
2493}
2494
2496 if (const auto *BT = getAs())
2497 return BT->getKind() == BuiltinType::WasmExternRef;
2498 return false;
2499}
2500
2502 if (const auto *ATy = dyn_cast(this))
2503 return ATy->getElementType().isWebAssemblyReferenceType();
2504
2505 if (const auto *PTy = dyn_cast(this))
2506 return PTy->getPointeeType().isWebAssemblyReferenceType();
2507
2508 return false;
2509}
2510
2512
2515}
2516
2518 if (const BuiltinType *BT = getAs()) {
2519 switch (BT->getKind()) {
2520
2521#define SVE_VECTOR_TYPE(Name, MangledName, Id, SingletonId) \
2522 case BuiltinType::Id: \
2523 return true;
2524#define SVE_OPAQUE_TYPE(Name, MangledName, Id, SingletonId) \
2525 case BuiltinType::Id: \
2526 return true;
2527#define SVE_PREDICATE_TYPE(Name, MangledName, Id, SingletonId) \
2528 case BuiltinType::Id: \
2529 return true;
2530#define AARCH64_VECTOR_TYPE(Name, MangledName, Id, SingletonId) \
2531 case BuiltinType::Id: \
2532 return false;
2533#include "clang/Basic/AArch64SVEACLETypes.def"
2534 default:
2535 return false;
2536 }
2537 }
2538 return false;
2539}
2540
2542 if (const BuiltinType *BT = getAs()) {
2543 switch (BT->getKind()) {
2544#define RVV_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
2545#include "clang/Basic/RISCVVTypes.def"
2546 return true;
2547 default:
2548 return false;
2549 }
2550 }
2551 return false;
2552}
2553
2555 if (const BuiltinType *BT = getAs()) {
2556 switch (BT->getKind()) {
2557 case BuiltinType::SveInt8:
2558 case BuiltinType::SveInt16:
2559 case BuiltinType::SveInt32:
2560 case BuiltinType::SveInt64:
2561 case BuiltinType::SveUint8:
2562 case BuiltinType::SveUint16:
2563 case BuiltinType::SveUint32:
2564 case BuiltinType::SveUint64:
2565 case BuiltinType::SveFloat16:
2566 case BuiltinType::SveFloat32:
2567 case BuiltinType::SveFloat64:
2568 case BuiltinType::SveBFloat16:
2569 case BuiltinType::SveBool:
2570 case BuiltinType::SveBoolx2:
2571 case BuiltinType::SveBoolx4:
2572 case BuiltinType::SveMFloat8:
2573 return true;
2574 default:
2575 return false;
2576 }
2577 }
2578 return false;
2579}
2580
2583
2586
2589
2590 llvm_unreachable("Unhandled type");
2591}
2592
2595
2596 const BuiltinType *BTy = castAs();
2597 if (BTy->getKind() == BuiltinType::SveBool)
2598
2599
2600
2602 else
2604}
2605
2607 if (const BuiltinType *BT = getAs()) {
2608 switch (BT->getKind()) {
2609#define RVV_VECTOR_TYPE(Name, Id, SingletonId, NumEls, ElBits, NF, IsSigned, \
2610 IsFP, IsBF) \
2611 case BuiltinType::Id: \
2612 return NF == 1;
2613#define RVV_PREDICATE_TYPE(Name, Id, SingletonId, NumEls) \
2614 case BuiltinType::Id: \
2615 return true;
2616#include "clang/Basic/RISCVVTypes.def"
2617 default:
2618 return false;
2619 }
2620 }
2621 return false;
2622}
2623
2626
2627 const BuiltinType *BTy = castAs();
2628
2629 switch (BTy->getKind()) {
2630#define RVV_PREDICATE_TYPE(Name, Id, SingletonId, NumEls) \
2631 case BuiltinType::Id: \
2632 return Ctx.UnsignedCharTy;
2633 default:
2635#include "clang/Basic/RISCVVTypes.def"
2636 }
2637
2638 llvm_unreachable("Unhandled type");
2639}
2640
2642
2645
2647}
2648
2650
2651
2652
2654 return false;
2655
2656 if ((*this)->isIncompleteArrayType())
2658
2659 if ((*this)->isIncompleteType())
2660 return false;
2661
2663 return false;
2664
2667
2668 default: return false;
2669 case Type::VariableArray:
2670 case Type::ConstantArray:
2671
2673
2674 case Type::ObjCObjectPointer:
2675 case Type::BlockPointer:
2676 case Type::Builtin:
2677 case Type::Complex:
2678 case Type::Pointer:
2679 case Type::MemberPointer:
2680 case Type::Vector:
2681 case Type::ExtVector:
2682 case Type::BitInt:
2683 return true;
2684
2685 case Type::Enum:
2686 return true;
2687
2688 case Type::Record:
2689 if (const auto *ClassDecl =
2690 dyn_cast(cast(CanonicalType)->getDecl()))
2691 return ClassDecl->isPOD();
2692
2693
2694 return true;
2695 }
2696}
2697
2699
2700
2701
2703 return false;
2704
2705 if ((*this)->isArrayType())
2707
2708 if ((*this)->isSizelessBuiltinType())
2709 return true;
2710
2711
2712
2713 if ((*this)->isIncompleteType())
2714 return false;
2715
2717 return false;
2718
2721 return false;
2722
2723
2724
2725
2726
2727
2728
2730 return true;
2731 if (const auto *RT = CanonicalType->getAs<RecordType>()) {
2732 if (const auto *ClassDecl = dyn_cast(RT->getDecl())) {
2733
2734
2735
2736
2737
2738
2739 return ClassDecl->hasTrivialDefaultConstructor() &&
2740 !ClassDecl->hasNonTrivialDefaultConstructor() &&
2741 ClassDecl->isTriviallyCopyable();
2742 }
2743
2744 return true;
2745 }
2746
2747
2748 return false;
2749}
2750
2753 bool IsCopyConstructible) {
2754 if (type->isArrayType())
2756 Context, IsCopyConstructible);
2757
2758 if (type.hasNonTrivialObjCLifetime())
2759 return false;
2760
2761
2762
2763
2764
2765
2766 QualType CanonicalType = type.getCanonicalType();
2768 return false;
2769
2771 return true;
2772
2773
2774
2776 return false;
2777
2778
2780 return true;
2781
2782 if (const auto *RT = CanonicalType->getAs<RecordType>()) {
2783 if (const auto *ClassDecl = dyn_cast(RT->getDecl())) {
2784 if (IsCopyConstructible) {
2785 return ClassDecl->isTriviallyCopyConstructible();
2786 } else {
2787 return ClassDecl->isTriviallyCopyable();
2788 }
2789 }
2790 return true;
2791 }
2792
2793 return false;
2794}
2795
2798 false);
2799}
2800
2801
2804 if (CanonicalType.hasNonTrivialObjCLifetime())
2805 return false;
2806 if (CanonicalType->isArrayType())
2809
2810 if (CanonicalType->isIncompleteType())
2811 return false;
2812 const auto *RD = CanonicalType->getAsRecordDecl();
2813 if (!RD)
2814 return true;
2815
2816
2817
2818
2819 if (RD->mayInsertExtraPadding())
2820 return false;
2821
2822 for (auto *const Field : RD->fields()) {
2823 if (!Field->getType().isBitwiseCloneableType(Context))
2824 return false;
2825 }
2826
2827 if (const auto *CXXRD = dyn_cast(RD)) {
2828 for (auto Base : CXXRD->bases())
2829 if (.getType().isBitwiseCloneableType(Context))
2830 return false;
2831 for (auto VBase : CXXRD->vbases())
2832 if (!VBase.getType().isBitwiseCloneableType(Context))
2833 return false;
2834 }
2835 return true;
2836}
2837
2841 true);
2842}
2843
2846
2848 return false;
2849 } else if (!BaseElementType->isObjectType()) {
2850 return false;
2851 } else if (const auto *RD = BaseElementType->getAsRecordDecl()) {
2852 return RD->canPassInRegisters();
2854 return true;
2855 } else {
2860 return true;
2861 default:
2862 return false;
2863 }
2864 }
2865}
2866
2868 return !Context.getLangOpts().ObjCAutoRefCount &&
2871}
2872
2875}
2876
2879}
2880
2883}
2884
2887}
2888
2891}
2892
2896}
2897
2900 if (const auto *RT =
2901 getTypePtr()->getBaseElementTypeUnsafe()->getAs())
2902 if (RT->getDecl()->isNonTrivialToPrimitiveDefaultInitialize())
2904
2910 default:
2912 }
2913}
2914
2916 if (const auto *RT =
2917 getTypePtr()->getBaseElementTypeUnsafe()->getAs())
2918 if (RT->getDecl()->isNonTrivialToPrimitiveCopy())
2920
2927 default:
2929 }
2930}
2931
2935}
2936
2939 return false;
2940
2941
2942
2943
2945 return true;
2946
2947
2948
2949
2950
2952 return false;
2954 assert(BaseTy && "NULL element type");
2955
2956
2957
2959 return false;
2960
2961
2962
2963
2964
2965
2968 return true;
2969
2971 return true;
2972
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984 if (const auto *ClassDecl = dyn_cast(RT->getDecl()))
2985 return ClassDecl->isLiteral();
2986
2987 return true;
2988 }
2989
2990
2992 return AT->getValueType()->isLiteralType(Ctx);
2993
2994
2995
2997 return true;
2998
2999 return false;
3000}
3001
3003
3004
3005
3006
3008 return true;
3009
3011 return true;
3012
3014 return RD->isStructural();
3015 return false;
3016}
3017
3020 return false;
3021
3022
3023
3024
3025
3027 assert(BaseTy && "NULL element type");
3028
3029
3030
3032 return false;
3033
3034
3037 if (const auto *ClassDecl = dyn_cast(RT->getDecl()))
3038 if (!ClassDecl->isStandardLayout())
3039 return false;
3040
3041
3042
3043
3044 return true;
3045 }
3046
3047
3048 return false;
3049}
3050
3051
3052
3053
3057 return false;
3058
3060 return false;
3061
3062
3063
3064
3066 assert(BaseTy && "NULL element type");
3067
3069 return true;
3070
3071
3072
3074 return false;
3075
3076
3079 if (const auto *ClassDecl = dyn_cast(RT->getDecl())) {
3080
3081
3082 if (!ClassDecl->isTrivial()) return false;
3083
3084
3085
3086
3087 if (!ClassDecl->isStandardLayout()) return false;
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097 }
3098
3099 return true;
3100 }
3101
3102
3103 return false;
3104}
3105
3110 return true;
3111 }
3112 return false;
3113}
3114
3116 if (const auto *ET = getAs()) {
3117 IdentifierInfo *II = ET->getDecl()->getIdentifier();
3118 if (II && II->isStr("align_val_t") && ET->getDecl()->isInStdNamespace())
3119 return true;
3120 }
3121 return false;
3122}
3123
3125 if (const auto *ET = getAs()) {
3126 IdentifierInfo *II = ET->getDecl()->getIdentifier();
3127 if (II && II->isStr("byte") && ET->getDecl()->isInStdNamespace())
3128 return true;
3129 }
3130 return false;
3131}
3132
3134
3136 case Builtin:
3139 case Typedef:
3141 case TypeOfExpr:
3142 case TypeOf:
3143 case TemplateTypeParm:
3144 case SubstTemplateTypeParm:
3145 case TemplateSpecialization:
3146 case Elaborated:
3147 case DependentName:
3148 case DependentTemplateSpecialization:
3149 case ObjCInterface:
3150 case ObjCObject:
3151 return true;
3152 default:
3153 return false;
3154 }
3155}
3156
3159 switch (TypeSpec) {
3160 default:
3174 }
3175}
3176
3179 switch(TypeSpec) {
3190 }
3191
3192 llvm_unreachable("Type specifier is not a tag type kind.");
3193}
3194
3197 switch (Kind) {
3208 }
3209 llvm_unreachable("Unknown tag type kind.");
3210}
3211
3214 switch (Keyword) {
3227 llvm_unreachable("Elaborated type keyword is not a tag type kind.");
3228 }
3229 llvm_unreachable("Unknown elaborated type keyword.");
3230}
3231
3232bool
3234 switch (Keyword) {
3237 return false;
3243 return true;
3244 }
3245 llvm_unreachable("Unknown elaborated type keyword.");
3246}
3247
3249 switch (Keyword) {
3251 return {};
3253 return "typename";
3255 return "class";
3257 return "struct";
3259 return "__interface";
3261 return "union";
3263 return "enum";
3264 }
3265
3266 llvm_unreachable("Unknown elaborated type keyword.");
3267}
3268
3269DependentTemplateSpecializationType::DependentTemplateSpecializationType(
3272 : TypeWithKeyword(Keyword, DependentTemplateSpecialization, Canon,
3276 NNS(NNS), Name(Name) {
3279 "DependentTemplateSpecializatonType requires dependent qualifier");
3280 auto *ArgBuffer = const_cast<TemplateArgument *>(template_arguments().data());
3283 TemplateArgumentDependence::UnexpandedPack));
3284
3286 }
3287}
3288
3289void
3296 ID.AddInteger(llvm::to_underlying(Keyword));
3297 ID.AddPointer(Qualifier);
3298 ID.AddPointer(Name);
3300 Arg.Profile(ID, Context);
3301}
3302
3305 if (const auto *Elab = dyn_cast(this))
3306 Keyword = Elab->getKeyword();
3307 else if (const auto *DepName = dyn_cast(this))
3308 Keyword = DepName->getKeyword();
3309 else if (const auto *DepTST =
3310 dyn_cast(this))
3311 Keyword = DepTST->getKeyword();
3312 else
3313 return false;
3314
3316}
3317
3320#define ABSTRACT_TYPE(Derived, Base)
3321#define TYPE(Derived, Base) case Derived: return #Derived;
3322#include "clang/AST/TypeNodes.inc"
3323 }
3324
3325 llvm_unreachable("Invalid type class.");
3326}
3327
3331 return "void";
3333 return Policy.Bool ? "bool" : "_Bool";
3334 case Char_S:
3335 return "char";
3336 case Char_U:
3337 return "char";
3338 case SChar:
3339 return "signed char";
3341 return "short";
3342 case Int:
3343 return "int";
3345 return "long";
3347 return "long long";
3348 case Int128:
3349 return "__int128";
3350 case UChar:
3351 return "unsigned char";
3352 case UShort:
3353 return "unsigned short";
3354 case UInt:
3355 return "unsigned int";
3356 case ULong:
3357 return "unsigned long";
3358 case ULongLong:
3359 return "unsigned long long";
3360 case UInt128:
3361 return "unsigned __int128";
3363 return Policy.Half ? "half" : "__fp16";
3364 case BFloat16:
3365 return "__bf16";
3367 return "float";
3369 return "double";
3371 return "long double";
3372 case ShortAccum:
3373 return "short _Accum";
3374 case Accum:
3375 return "_Accum";
3376 case LongAccum:
3377 return "long _Accum";
3378 case UShortAccum:
3379 return "unsigned short _Accum";
3380 case UAccum:
3381 return "unsigned _Accum";
3382 case ULongAccum:
3383 return "unsigned long _Accum";
3384 case BuiltinType::ShortFract:
3385 return "short _Fract";
3386 case BuiltinType::Fract:
3387 return "_Fract";
3388 case BuiltinType::LongFract:
3389 return "long _Fract";
3390 case BuiltinType::UShortFract:
3391 return "unsigned short _Fract";
3392 case BuiltinType::UFract:
3393 return "unsigned _Fract";
3394 case BuiltinType::ULongFract:
3395 return "unsigned long _Fract";
3396 case BuiltinType::SatShortAccum:
3397 return "_Sat short _Accum";
3398 case BuiltinType::SatAccum:
3399 return "_Sat _Accum";
3400 case BuiltinType::SatLongAccum:
3401 return "_Sat long _Accum";
3402 case BuiltinType::SatUShortAccum:
3403 return "_Sat unsigned short _Accum";
3404 case BuiltinType::SatUAccum:
3405 return "_Sat unsigned _Accum";
3406 case BuiltinType::SatULongAccum:
3407 return "_Sat unsigned long _Accum";
3408 case BuiltinType::SatShortFract:
3409 return "_Sat short _Fract";
3410 case BuiltinType::SatFract:
3411 return "_Sat _Fract";
3412 case BuiltinType::SatLongFract:
3413 return "_Sat long _Fract";
3414 case BuiltinType::SatUShortFract:
3415 return "_Sat unsigned short _Fract";
3416 case BuiltinType::SatUFract:
3417 return "_Sat unsigned _Fract";
3418 case BuiltinType::SatULongFract:
3419 return "_Sat unsigned long _Fract";
3420 case Float16:
3421 return "_Float16";
3423 return "__float128";
3425 return "__ibm128";
3426 case WChar_S:
3427 case WChar_U:
3428 return Policy.MSWChar ? "__wchar_t" : "wchar_t";
3429 case Char8:
3430 return "char8_t";
3431 case Char16:
3432 return "char16_t";
3433 case Char32:
3434 return "char32_t";
3435 case NullPtr:
3437 case Overload:
3438 return "";
3439 case BoundMember:
3440 return "";
3441 case UnresolvedTemplate:
3442 return "";
3443 case PseudoObject:
3444 return "";
3446 return "";
3447 case UnknownAny:
3448 return "";
3449 case ARCUnbridgedCast:
3450 return "";
3451 case BuiltinFn:
3452 return "";
3453 case ObjCId:
3454 return "id";
3455 case ObjCClass:
3456 return "Class";
3457 case ObjCSel:
3458 return "SEL";
3459#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
3460 case Id: \
3461 return "__" #Access " " #ImgType "_t";
3462#include "clang/Basic/OpenCLImageTypes.def"
3463 case OCLSampler:
3464 return "sampler_t";
3465 case OCLEvent:
3466 return "event_t";
3467 case OCLClkEvent:
3468 return "clk_event_t";
3469 case OCLQueue:
3470 return "queue_t";
3471 case OCLReserveID:
3472 return "reserve_id_t";
3473 case IncompleteMatrixIdx:
3474 return "";
3475 case ArraySection:
3476 return "";
3477 case OMPArrayShaping:
3478 return "";
3479 case OMPIterator:
3480 return "";
3481#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \
3482 case Id: \
3483 return #ExtType;
3484#include "clang/Basic/OpenCLExtensionTypes.def"
3485#define SVE_TYPE(Name, Id, SingletonId) \
3486 case Id: \
3487 return Name;
3488#include "clang/Basic/AArch64SVEACLETypes.def"
3489#define PPC_VECTOR_TYPE(Name, Id, Size) \
3490 case Id: \
3491 return #Name;
3492#include "clang/Basic/PPCTypes.def"
3493#define RVV_TYPE(Name, Id, SingletonId) \
3494 case Id: \
3495 return Name;
3496#include "clang/Basic/RISCVVTypes.def"
3497#define WASM_TYPE(Name, Id, SingletonId) \
3498 case Id: \
3499 return Name;
3500#include "clang/Basic/WebAssemblyReferenceTypes.def"
3501#define AMDGPU_TYPE(Name, Id, SingletonId, Width, Align) \
3502 case Id: \
3503 return Name;
3504#include "clang/Basic/AMDGPUTypes.def"
3505#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) \
3506 case Id: \
3507 return #Name;
3508#include "clang/Basic/HLSLIntangibleTypes.def"
3509 }
3510
3511 llvm_unreachable("Invalid builtin type.");
3512}
3513
3515
3516 if (auto *PET = dyn_cast(getTypePtr()))
3517 return PET->getPattern();
3518 return *this;
3519}
3520
3522 if (const auto *RefType = getTypePtr()->getAs())
3524
3525
3526
3527
3528
3529
3533
3534 return *this;
3535}
3536
3538 switch (CC) {
3539 case CC_C: return "cdecl";
3545 case CC_Win64: return "ms_abi";
3548 case CC_AAPCS: return "aapcs";
3556 case CC_Swift: return "swiftcall";
3562
3564
3565 }
3566
3567 llvm_unreachable("Invalid calling convention.");
3568}
3569
3575}
3576
3585 assert(getNumParams() == params.size() && "NumParams overflow!");
3590
3593 auto &ExtraBits = *getTrailingObjects();
3595 } else {
3597 }
3598
3600 auto &ArmTypeAttrs = *getTrailingObjects();
3601 ArmTypeAttrs = FunctionTypeArmAttributes();
3602
3603
3604 auto &ExtraBits = *getTrailingObjects();
3605 ExtraBits.HasArmTypeAttributes = true;
3606 }
3607
3608
3609 auto *argSlot = getTrailingObjects();
3610 for (unsigned i = 0; i != getNumParams(); ++i) {
3612 ~TypeDependence::VariablyModified);
3613 argSlot[i] = params[i];
3614 }
3615
3616
3618 auto &ArmTypeAttrs = *getTrailingObjects();
3620 "Not enough bits to encode SME attributes");
3622 }
3623
3624
3626 auto &ExtraBits = *getTrailingObjects();
3628 assert(NumExceptions <= 1023 && "Not enough bits to encode exceptions");
3629 ExtraBits.NumExceptionType = NumExceptions;
3630
3631 assert(hasExtraBitfields() && "missing trailing extra bitfields!");
3632 auto *exnSlot =
3633 reinterpret_cast<QualType *>(getTrailingObjects());
3634 unsigned I = 0;
3636
3637
3638
3641 (TypeDependence::Instantiation | TypeDependence::UnexpandedPack));
3642
3643 exnSlot[I++] = ExceptionType;
3644 }
3645 }
3646
3651
3652
3654
3657 (TypeDependence::Instantiation | TypeDependence::UnexpandedPack));
3658 }
3659
3661
3662
3663 auto **slot = getTrailingObjects<FunctionDecl *>();
3666
3667
3669
3670
3671 auto **slot = getTrailingObjects<FunctionDecl *>();
3673 }
3674
3675
3676
3681 addDependence(TypeDependence::DependentInstantiation);
3682 }
3684
3685 addDependence(TypeDependence::DependentInstantiation);
3686 }
3687
3688
3690 auto *extParamInfos = getTrailingObjects();
3691 for (unsigned i = 0; i != getNumParams(); ++i)
3693 }
3694
3697 *getTrailingObjects() = epi.TypeQuals;
3698 } else {
3700 }
3701
3702
3704 auto &EllipsisLoc = *getTrailingObjects();
3706 }
3707
3709 auto &ExtraBits = *getTrailingObjects();
3711 ExtraBits.NumFunctionEffects = EffectsCount;
3712 assert(ExtraBits.NumFunctionEffects == EffectsCount &&
3713 "effect bitfield overflow");
3714
3716 auto *DestFX = getTrailingObjects();
3717 std::uninitialized_copy(SrcFX.begin(), SrcFX.end(), DestFX);
3718
3720 if (!SrcConds.empty()) {
3721 ExtraBits.EffectsHaveConditions = true;
3722 auto *DestConds = getTrailingObjects();
3723 std::uninitialized_copy(SrcConds.begin(), SrcConds.end(), DestConds);
3724 assert(std::any_of(SrcConds.begin(), SrcConds.end(),
3726 if (const Expr *E = EC.getCondition())
3727 return E->isTypeDependent() ||
3728 E->isValueDependent();
3729 return false;
3730 }) &&
3731 "expected a dependent expression among the conditions");
3732 addDependence(TypeDependence::DependentInstantiation);
3733 }
3734 }
3735}
3736
3739 return NE->isValueDependent();
3741
3742
3743
3745 return true;
3746 return false;
3747}
3748
3751 return NE->isInstantiationDependent();
3754 return true;
3755 return false;
3756}
3757
3762 llvm_unreachable("should not call this with unresolved exception specs");
3763
3769
3774
3776
3777
3782
3786 }
3787
3788 llvm_unreachable("unexpected exception specification kind");
3789}
3790
3792 for (unsigned ArgIdx = getNumParams(); ArgIdx; --ArgIdx)
3793 if (isa(getParamType(ArgIdx - 1)))
3794 return true;
3795
3796 return false;
3797}
3798
3800 const QualType *ArgTys, unsigned NumParams,
3801 const ExtProtoInfo &epi,
3802 const ASTContext &Context, bool Canonical) {
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824 ID.AddPointer(Result.getAsOpaquePtr());
3825 for (unsigned i = 0; i != NumParams; ++i)
3826 ID.AddPointer(ArgTys[i].getAsOpaquePtr());
3827
3828
3829
3830 assert(!(unsigned(epi.Variadic) & ~1) &&
3831 !(unsigned(epi.RefQualifier) & ~3) &&
3832 !(unsigned(epi.ExceptionSpec.Type) & ~15) &&
3833 "Values larger than expected.");
3834 ID.AddInteger(unsigned(epi.Variadic) +
3835 (epi.RefQualifier << 1) +
3836 (epi.ExceptionSpec.Type << 3));
3837 ID.Add(epi.TypeQuals);
3838 if (epi.ExceptionSpec.Type == EST_Dynamic) {
3839 for (QualType Ex : epi.ExceptionSpec.Exceptions)
3842 epi.ExceptionSpec.NoexceptExpr->Profile(ID, Context, Canonical);
3845 ID.AddPointer(epi.ExceptionSpec.SourceDecl->getCanonicalDecl());
3846 }
3847 if (epi.ExtParameterInfos) {
3848 for (unsigned i = 0; i != NumParams; ++i)
3849 ID.AddInteger(epi.ExtParameterInfos[i].getOpaqueValue());
3850 }
3851
3852 epi.ExtInfo.Profile(ID);
3853
3854 unsigned EffectCount = epi.FunctionEffects.size();
3855 bool HasConds = !epi.FunctionEffects.Conditions.empty();
3856
3857 ID.AddInteger((EffectCount << 3) | (HasConds << 2) |
3858 (epi.AArch64SMEAttributes << 1) | epi.HasTrailingReturn);
3859
3860 for (unsigned Idx = 0; Idx != EffectCount; ++Idx) {
3861 ID.AddInteger(epi.FunctionEffects.Effects[Idx].toOpaqueInt32());
3862 if (HasConds)
3863 ID.AddPointer(epi.FunctionEffects.Conditions[Idx].getCondition());
3864 }
3865}
3866
3871}
3872
3874 : Data(D, Deref << DerefShift) {}
3875
3877 return Data.getInt() & DerefMask;
3878}
3882 return Data.getOpaqueValue();
3883}
3887}
3889 Data.setFromOpaqueValue(V);
3890}
3891
3894 : Type(TC, Canon, Wrapped->getDependence()), WrappedTy(Wrapped) {}
3895
3896CountAttributedType::CountAttributedType(
3900 CountExpr(CountExpr) {
3904 auto *DeclSlot = getTrailingObjects();
3906 for (unsigned i = 0; i != CoupledDecls.size(); ++i)
3907 DeclSlot[i] = CoupledDecls[i];
3908}
3909
3910TypedefType::TypedefType(TypeClass tc, const TypedefNameDecl *D,
3914 assert(!isa(can) && "Invalid canonical type");
3916 if (!typeMatchesDecl())
3917 *getTrailingObjects() = Underlying;
3918}
3919
3922 : *getTrailingObjects();
3923}
3924
3929 UsingBits.hasTypeDifferentFromDecl = !Underlying.isNull();
3931 *getTrailingObjects() = Underlying;
3932}
3933
3937 cast(Found->getTargetDecl())->getTypeForDecl(), 0)
3938 : *getTrailingObjects();
3939}
3940
3942
3944
3945
3947 while (auto *InnerMQT = dyn_cast(Inner)) {
3949 break;
3950 Inner = InnerMQT->getModifiedType();
3951 }
3952 return Inner;
3953}
3954
3957 : Type(TypeOfExpr,
3958
3959
3961 ? Context.getUnqualifiedArrayType(Can).getAtomicUnqualifiedType()
3962 : Can,
3964 (E->getType()->getDependence() &
3966 TOExpr(E), Context(Context) {
3967 TypeOfBits.Kind = static_cast<unsigned>(Kind);
3968}
3969
3972}
3973
3979 : QT;
3980 }
3982}
3983
3986 bool IsUnqual) {
3987 E->Profile(ID, Context, true);
3988 ID.AddBoolean(IsUnqual);
3989}
3990
3993 : Type(TypeOf,
3995 ? Context.getUnqualifiedArrayType(Can).getAtomicUnqualifiedType()
3996 : Can,
3997 T->getDependence()),
3998 TOType(T), Context(Context) {
3999 TypeOfBits.Kind = static_cast<unsigned>(Kind);
4000}
4001
4006 : QT;
4007}
4008
4010
4011
4012
4013 : Type(Decltype, can,
4017 (E->getType()->getDependence() &
4019 E(E), UnderlyingType(underlyingType) {}
4020
4022
4026
4028}
4029
4032
4035 E->Profile(ID, Context, true);
4036}
4037
4040 Expr *IndexExpr, bool FullySubstituted,
4042 : Type(PackIndexing, Canonical,
4044 Context(Context), Pattern(Pattern), IndexExpr(IndexExpr),
4045 Size(Expansions.size()), FullySubstituted(FullySubstituted) {
4046
4047 std::uninitialized_copy(Expansions.begin(), Expansions.end(),
4048 getTrailingObjects());
4049}
4050
4053 return std::nullopt;
4054
4056 if (!CE)
4057 return std::nullopt;
4059 assert(Index.isNonNegative() && "Invalid index");
4060 return static_cast<unsigned>(Index.getExtValue());
4061}
4062
4064PackIndexingType::computeDependence(QualType Pattern, Expr *IndexExpr,
4067
4069 ? TypeDependence::DependentInstantiation
4070 : TypeDependence::None);
4071 if (Expansions.empty())
4072 TD |= Pattern->getDependence() & TypeDependence::DependentInstantiation;
4073 else
4074 for (const QualType &T : Expansions)
4076
4077 if (!(IndexD & TypeDependence::UnexpandedPack))
4078 TD &= ~TypeDependence::UnexpandedPack;
4079
4080
4081
4083 TD |= TypeDependence::Error | TypeDependence::DependentInstantiation;
4084
4085 return TD;
4086}
4087
4090 Expr *E, bool FullySubstituted) {
4092 E->Profile(ID, Context, true);
4093 ID.AddBoolean(FullySubstituted);
4094}
4095
4099 : Type(UnaryTransform, CanonicalType, BaseType->getDependence()),
4100 BaseType(BaseType), UnderlyingType(UnderlyingType), UKind(UKind) {}
4101
4106
4108 : Type(TC, can,
4109 D->isDependentType() ? TypeDependence::DependentInstantiation
4112
4114 for (auto *I : decl->redecls()) {
4115 if (I->isCompleteDefinition() || I->isBeingDefined())
4116 return I;
4117 }
4118
4119 return decl;
4120}
4121
4124}
4125
4128}
4129
4131 std::vector<const RecordType*> RecordTypeList;
4132 RecordTypeList.push_back(this);
4133 unsigned NextToCheckIndex = 0;
4134
4135 while (RecordTypeList.size() > NextToCheckIndex) {
4137 RecordTypeList[NextToCheckIndex]->getDecl()->fields()) {
4138 QualType FieldTy = FD->getType();
4140 return true;
4142 if (const auto *FieldRecTy = FieldTy->getAs<RecordType>()) {
4143 if (!llvm::is_contained(RecordTypeList, FieldRecTy))
4144 RecordTypeList.push_back(FieldRecTy);
4145 }
4146 }
4147 ++NextToCheckIndex;
4148 }
4149 return false;
4150}
4151
4152AttributedType::AttributedType(QualType canon, const Attr *attr,
4155
4159 : Type(Attributed, canon, equivalent->getDependence()), Attribute(attr),
4160 ModifiedType(modified), EquivalentType(equivalent) {
4162 assert(!attr || attr->getKind() == attrKind);
4163}
4164
4166
4168
4169
4170
4171 case attr::ObjCGC:
4172 case attr::ObjCOwnership:
4173 case attr::ObjCInertUnsafeUnretained:
4174 case attr::TypeNonNull:
4175 case attr::TypeNullable:
4176 case attr::TypeNullableResult:
4177 case attr::TypeNullUnspecified:
4178 case attr::LifetimeBound:
4179 case attr::AddressSpace:
4180 return true;
4181
4182
4183
4184 default:
4185 return false;
4186 }
4187}
4188
4190
4192 default: return false;
4193 case attr::Ptr32:
4194 case attr::Ptr64:
4195 case attr::SPtr:
4196 case attr::UPtr:
4197 return true;
4198 }
4199 llvm_unreachable("invalid attr kind");
4200}
4201
4203 return getAttrKind() == attr::WebAssemblyFuncref;
4204}
4205
4207
4209 default: return false;
4210 case attr::Pcs:
4211 case attr::CDecl:
4212 case attr::FastCall:
4213 case attr::StdCall:
4214 case attr::ThisCall:
4215 case attr::RegCall:
4216 case attr::SwiftCall:
4217 case attr::SwiftAsyncCall:
4218 case attr::VectorCall:
4219 case attr::AArch64VectorPcs:
4220 case attr::AArch64SVEPcs:
4221 case attr::AMDGPUKernelCall:
4222 case attr::Pascal:
4223 case attr::MSABI:
4224 case attr::SysVABI:
4225 case attr::IntelOclBicc:
4226 case attr::PreserveMost:
4227 case attr::PreserveAll:
4228 case attr::M68kRTD:
4229 case attr::PreserveNone:
4230 case attr::RISCVVectorCC:
4231 return true;
4232 }
4233 llvm_unreachable("invalid attr kind");
4234}
4235
4238}
4239
4242}
4243
4245 unsigned Index) {
4246 if (const auto *TTP = dyn_cast(D))
4247 return TTP;
4248 return cast(
4250}
4251
4252SubstTemplateTypeParmType::SubstTemplateTypeParmType(
4253 QualType Replacement, Decl *AssociatedDecl, unsigned Index,
4255 : Type(SubstTemplateTypeParm, Replacement.getCanonicalType(),
4256 Replacement->getDependence()),
4257 AssociatedDecl(AssociatedDecl) {
4258 SubstTemplateTypeParmTypeBits.HasNonCanonicalUnderlyingType =
4259 Replacement != getCanonicalTypeInternal();
4260 if (SubstTemplateTypeParmTypeBits.HasNonCanonicalUnderlyingType)
4261 *getTrailingObjects() = Replacement;
4262
4263 SubstTemplateTypeParmTypeBits.Index = Index;
4264 SubstTemplateTypeParmTypeBits.PackIndex = PackIndex ? *PackIndex + 1 : 0;
4265 SubstTemplateTypeParmTypeBits.SubstitutionFlag = llvm::to_underlying(Flag);
4266 assert((Flag != SubstTemplateTypeParmTypeFlag::ExpandPacksInPlace ||
4267 PackIndex) &&
4268 "ExpandPacksInPlace needs a valid PackIndex");
4269 assert(AssociatedDecl != nullptr);
4270}
4271
4275}
4276
4277SubstTemplateTypeParmPackType::SubstTemplateTypeParmPackType(
4278 QualType Canon, Decl *AssociatedDecl, unsigned Index, bool Final,
4280 : Type(SubstTemplateTypeParmPack, Canon,
4283 Arguments(ArgPack.pack_begin()),
4284 AssociatedDeclAndFinal(AssociatedDecl, Final) {
4287 assert(AssociatedDecl != nullptr);
4288}
4289
4291 return AssociatedDeclAndFinal.getPointer();
4292}
4293
4295 return AssociatedDeclAndFinal.getInt();
4296}
4297
4301}
4302
4305}
4306
4309}
4310
4313}
4314
4316 const Decl *AssociatedDecl,
4317 unsigned Index, bool Final,
4319 ID.AddPointer(AssociatedDecl);
4320 ID.AddInteger(Index);
4321 ID.AddBoolean(Final);
4322 ID.AddInteger(ArgPack.pack_size());
4324 ID.AddPointer(P.getAsType().getAsOpaquePtr());
4325}
4326
4330}
4331
4335 if (Arg.isDependent())
4336 return true;
4337 return false;
4338}
4339
4343 if (ArgLoc.getArgument().isInstantiationDependent())
4344 return true;
4345 }
4346 return false;
4347}
4348
4349TemplateSpecializationType::TemplateSpecializationType(
4352 : Type(TemplateSpecialization, Canon.isNull() ? QualType(this, 0) : Canon,
4353 (Canon.isNull()
4358 Template(T) {
4361
4362 assert(.getAsDependentTemplateName() &&
4363 "Use DependentTemplateSpecializationType for dependent template-name");
4370 "Unexpected template name for TemplateSpecializationType");
4371
4372 auto *TemplateArgs = reinterpret_cast<TemplateArgument *>(this + 1);
4374
4375
4376
4377
4378
4379
4380
4381
4383 ~TypeDependence::Dependent);
4385 addDependence(Arg.getAsType()->getDependence() &
4386 TypeDependence::VariablyModified);
4388 }
4389
4390
4393 *reinterpret_cast<QualType *>(Begin + Args.size()) = AliasedType;
4394 }
4395}
4396
4398 assert(isTypeAlias() && "not a type alias template specialization");
4400}
4401
4407}
4408
4409void
4416 Arg.Profile(ID, Context);
4417}
4418
4423
4425}
4426
4431
4433}
4434
4439 bool isKindOf) {
4441 ID.AddInteger(typeArgs.size());
4442 for (auto typeArg : typeArgs)
4443 ID.AddPointer(typeArg.getAsOpaquePtr());
4444 ID.AddInteger(protocols.size());
4445 for (auto *proto : protocols)
4446 ID.AddPointer(proto);
4447 ID.AddBoolean(isKindOf);
4448}
4449
4454}
4455
4460 ID.AddPointer(OTPDecl);
4462 ID.AddInteger(protocols.size());
4463 for (auto *proto : protocols)
4464 ID.AddPointer(proto);
4465}
4466
4470}
4471
4472namespace {
4473
4474
4475class CachedProperties {
4477 bool local;
4478
4479public:
4480 CachedProperties(Linkage L, bool local) : L(L), local(local) {}
4481
4482 Linkage getLinkage() const { return L; }
4483 bool hasLocalOrUnnamedType() const { return local; }
4484
4485 friend CachedProperties merge(CachedProperties L, CachedProperties R) {
4487 return CachedProperties(MergedLinkage, L.hasLocalOrUnnamedType() ||
4488 R.hasLocalOrUnnamedType());
4489 }
4490};
4491
4492}
4493
4495
4496namespace clang {
4497
4498
4499
4500
4502public:
4504 return get(T.getTypePtr());
4505 }
4506
4507 static CachedProperties get(const Type *T) {
4509 return CachedProperties(T->TypeBits.getLinkage(),
4510 T->TypeBits.hasLocalOrUnnamedType());
4511 }
4512
4514
4515 if (T->TypeBits.isCacheValid()) return;
4516
4517
4518
4524 T->TypeBits.CachedLocalOrUnnamed = CT->TypeBits.CachedLocalOrUnnamed;
4525 return;
4526 }
4527
4528
4531 T->TypeBits.CachedLinkage = llvm::to_underlying(Result.getLinkage());
4532 T->TypeBits.CachedLocalOrUnnamed = Result.hasLocalOrUnnamedType();
4533 }
4534};
4535
4536}
4537
4538
4539
4540
4541namespace {
4542
4544
4545}
4546
4548
4551#define TYPE(Class,Base)
4552#define NON_CANONICAL_TYPE(Class,Base) case Type::Class:
4553#include "clang/AST/TypeNodes.inc"
4554 llvm_unreachable("didn't expect a non-canonical type here");
4555
4556#define TYPE(Class,Base)
4557#define DEPENDENT_TYPE(Class,Base) case Type::Class:
4558#define NON_CANONICAL_UNLESS_DEPENDENT_TYPE(Class,Base) case Type::Class:
4559#include "clang/AST/TypeNodes.inc"
4560
4563
4564 case Type::Auto:
4565 case Type::DeducedTemplateSpecialization:
4566
4567
4569
4570 case Type::BitInt:
4571 case Type::Builtin:
4572
4573
4574
4576
4577 case Type::Record:
4578 case Type::Enum: {
4579 const TagDecl *Tag = cast(T)->getDecl();
4580
4581
4582
4583
4584
4585 Linkage L = Tag->getLinkageInternal();
4586 bool IsLocalOrUnnamed =
4587 Tag->getDeclContext()->isFunctionOrMethod() ||
4588 !Tag->hasNameForLinkage();
4589 return CachedProperties(L, IsLocalOrUnnamed);
4590 }
4591
4592
4593
4594
4595 case Type::Complex:
4596 return Cache::get(cast(T)->getElementType());
4597 case Type::Pointer:
4599 case Type::BlockPointer:
4601 case Type::LValueReference:
4602 case Type::RValueReference:
4604 case Type::MemberPointer: {
4605 const auto *MPT = cast(T);
4606 return merge(Cache::get(MPT->getClass()),
4608 }
4609 case Type::ConstantArray:
4610 case Type::IncompleteArray:
4611 case Type::VariableArray:
4612 case Type::ArrayParameter:
4613 return Cache::get(cast(T)->getElementType());
4614 case Type::Vector:
4615 case Type::ExtVector:
4616 return Cache::get(cast(T)->getElementType());
4617 case Type::ConstantMatrix:
4618 return Cache::get(cast(T)->getElementType());
4619 case Type::FunctionNoProto:
4620 return Cache::get(cast(T)->getReturnType());
4621 case Type::FunctionProto: {
4622 const auto *FPT = cast(T);
4623 CachedProperties result = Cache::get(FPT->getReturnType());
4624 for (const auto &ai : FPT->param_types())
4625 result = merge(result, Cache::get(ai));
4626 return result;
4627 }
4628 case Type::ObjCInterface: {
4629 Linkage L = cast(T)->getDecl()->getLinkageInternal();
4630 return CachedProperties(L, false);
4631 }
4632 case Type::ObjCObject:
4633 return Cache::get(cast(T)->getBaseType());
4634 case Type::ObjCObjectPointer:
4636 case Type::Atomic:
4637 return Cache::get(cast(T)->getValueType());
4638 case Type::Pipe:
4639 return Cache::get(cast(T)->getElementType());
4640 case Type::HLSLAttributedResource:
4641 return Cache::get(cast(T)->getWrappedType());
4642 }
4643
4644 llvm_unreachable("unhandled type class");
4645}
4646
4647
4650 return TypeBits.getLinkage();
4651}
4652
4655 return TypeBits.hasLocalOrUnnamedType();
4656}
4657
4660#define TYPE(Class,Base)
4661#define NON_CANONICAL_TYPE(Class,Base) case Type::Class:
4662#include "clang/AST/TypeNodes.inc"
4663 llvm_unreachable("didn't expect a non-canonical type here");
4664
4665#define TYPE(Class,Base)
4666#define DEPENDENT_TYPE(Class,Base) case Type::Class:
4667#define NON_CANONICAL_UNLESS_DEPENDENT_TYPE(Class,Base) case Type::Class:
4668#include "clang/AST/TypeNodes.inc"
4669
4672
4673 case Type::BitInt:
4674 case Type::Builtin:
4676
4677 case Type::Auto:
4678 case Type::DeducedTemplateSpecialization:
4680
4681 case Type::Record:
4682 case Type::Enum:
4684
4685 case Type::Complex:
4687 case Type::Pointer:
4689 case Type::BlockPointer:
4691 case Type::LValueReference:
4692 case Type::RValueReference:
4694 case Type::MemberPointer: {
4695 const auto *MPT = cast(T);
4698 return LV;
4699 }
4700 case Type::ConstantArray:
4701 case Type::IncompleteArray:
4702 case Type::VariableArray:
4703 case Type::ArrayParameter:
4705 case Type::Vector:
4706 case Type::ExtVector:
4708 case Type::ConstantMatrix:
4710 cast(T)->getElementType());
4711 case Type::FunctionNoProto:
4713 case Type::FunctionProto: {
4714 const auto *FPT = cast(T);
4716 for (const auto &ai : FPT->param_types())
4718 return LV;
4719 }
4720 case Type::ObjCInterface:
4722 case Type::ObjCObject:
4724 case Type::ObjCObjectPointer:
4727 case Type::Atomic:
4729 case Type::Pipe:
4731 case Type::HLSLAttributedResource:
4733 ->getContainedType()
4734 ->getCanonicalTypeInternal());
4735 }
4736
4737 llvm_unreachable("unhandled type class");
4738}
4739
4741 if (.isCacheValid())
4742 return true;
4743
4747 return L == TypeBits.getLinkage();
4748}
4749
4753
4756 return LV;
4757}
4758
4761}
4762
4766
4767
4768 if (auto Nullability = AT->getImmediateNullability())
4769 return Nullability;
4770
4771 Type = AT->getEquivalentType();
4772 }
4773 return std::nullopt;
4774}
4775
4778
4779 switch (type->getTypeClass()) {
4780
4781#define NON_CANONICAL_TYPE(Class, Parent) \
4782 case Type::Class: \
4783 llvm_unreachable("non-canonical type");
4784#define TYPE(Class, Parent)
4785#include "clang/AST/TypeNodes.inc"
4786
4787
4788 case Type::Pointer:
4789 case Type::BlockPointer:
4790 case Type::MemberPointer:
4791 case Type::ObjCObjectPointer:
4792 return true;
4793
4794
4795 case Type::UnresolvedUsing:
4796 case Type::TypeOfExpr:
4797 case Type::TypeOf:
4798 case Type::Decltype:
4799 case Type::PackIndexing:
4800 case Type::UnaryTransform:
4801 case Type::TemplateTypeParm:
4802 case Type::SubstTemplateTypeParmPack:
4803 case Type::DependentName:
4804 case Type::DependentTemplateSpecialization:
4805 case Type::Auto:
4806 return ResultIfUnknown;
4807
4808
4809 case Type::TemplateSpecialization:
4810
4812 cast(type.getTypePtr())
4813 ->getTemplateName()
4814 .getAsTemplateDecl())
4815 if (auto *CTD = dyn_cast(templateDecl))
4816 return llvm::any_of(
4818 return RTD->getTemplatedDecl()->hasAttr();
4819 });
4820 return ResultIfUnknown;
4821
4822 case Type::Builtin:
4823 switch (cast(type.getTypePtr())->getKind()) {
4824
4825#define SIGNED_TYPE(Id, SingletonId) case BuiltinType::Id:
4826#define UNSIGNED_TYPE(Id, SingletonId) case BuiltinType::Id:
4827#define FLOATING_TYPE(Id, SingletonId) case BuiltinType::Id:
4828#define BUILTIN_TYPE(Id, SingletonId)
4829#include "clang/AST/BuiltinTypes.def"
4830 return false;
4831
4832 case BuiltinType::UnresolvedTemplate:
4833
4834 case BuiltinType::Dependent:
4835 case BuiltinType::Overload:
4836 case BuiltinType::BoundMember:
4837 case BuiltinType::PseudoObject:
4838 case BuiltinType::UnknownAny:
4839 case BuiltinType::ARCUnbridgedCast:
4840 return ResultIfUnknown;
4841
4842 case BuiltinType::Void:
4843 case BuiltinType::ObjCId:
4844 case BuiltinType::ObjCClass:
4845 case BuiltinType::ObjCSel:
4846#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
4847 case BuiltinType::Id:
4848#include "clang/Basic/OpenCLImageTypes.def"
4849#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \
4850 case BuiltinType::Id:
4851#include "clang/Basic/OpenCLExtensionTypes.def"
4852 case BuiltinType::OCLSampler:
4853 case BuiltinType::OCLEvent:
4854 case BuiltinType::OCLClkEvent:
4855 case BuiltinType::OCLQueue:
4856 case BuiltinType::OCLReserveID:
4857#define SVE_TYPE(Name, Id, SingletonId) \
4858 case BuiltinType::Id:
4859#include "clang/Basic/AArch64SVEACLETypes.def"
4860#define PPC_VECTOR_TYPE(Name, Id, Size) \
4861 case BuiltinType::Id:
4862#include "clang/Basic/PPCTypes.def"
4863#define RVV_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
4864#include "clang/Basic/RISCVVTypes.def"
4865#define WASM_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
4866#include "clang/Basic/WebAssemblyReferenceTypes.def"
4867#define AMDGPU_TYPE(Name, Id, SingletonId, Width, Align) case BuiltinType::Id:
4868#include "clang/Basic/AMDGPUTypes.def"
4869#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
4870#include "clang/Basic/HLSLIntangibleTypes.def"
4871 case BuiltinType::BuiltinFn:
4872 case BuiltinType::NullPtr:
4873 case BuiltinType::IncompleteMatrixIdx:
4874 case BuiltinType::ArraySection:
4875 case BuiltinType::OMPArrayShaping:
4876 case BuiltinType::OMPIterator:
4877 return false;
4878 }
4879 llvm_unreachable("unknown builtin type");
4880
4881 case Type::Record: {
4882 const RecordDecl *RD = cast(type)->getDecl();
4883
4884
4885 if (const auto *CTSD = dyn_cast(RD))
4886 return llvm::any_of(
4887 CTSD->getSpecializedTemplate()->redecls(),
4889 return RTD->getTemplatedDecl()->hasAttr();
4890 });
4891 return llvm::any_of(RD->redecls(), [](const TagDecl *RD) {
4892 return RD->hasAttr();
4893 });
4894 }
4895
4896
4897 case Type::Complex:
4898 case Type::LValueReference:
4899 case Type::RValueReference:
4900 case Type::ConstantArray:
4901 case Type::IncompleteArray:
4902 case Type::VariableArray:
4903 case Type::DependentSizedArray:
4904 case Type::DependentVector:
4905 case Type::DependentSizedExtVector:
4906 case Type::Vector:
4907 case Type::ExtVector:
4908 case Type::ConstantMatrix:
4909 case Type::DependentSizedMatrix:
4910 case Type::DependentAddressSpace:
4911 case Type::FunctionProto:
4912 case Type::FunctionNoProto:
4913 case Type::DeducedTemplateSpecialization:
4914 case Type::Enum:
4915 case Type::InjectedClassName:
4916 case Type::PackExpansion:
4917 case Type::ObjCObject:
4918 case Type::ObjCInterface:
4919 case Type::Atomic:
4920 case Type::Pipe:
4921 case Type::BitInt:
4922 case Type::DependentBitInt:
4923 case Type::ArrayParameter:
4924 case Type::HLSLAttributedResource:
4925 return false;
4926 }
4927 llvm_unreachable("bad type kind!");
4928}
4929
4933 if (getAttrKind() == attr::TypeNullable)
4935 if (getAttrKind() == attr::TypeNullUnspecified)
4937 if (getAttrKind() == attr::TypeNullableResult)
4939 return std::nullopt;
4940}
4941
4942std::optional
4945 if (auto MacroTy = dyn_cast(T))
4946 AttrTy = MacroTy->getUnderlyingType();
4947
4948 if (auto attributed = dyn_cast(AttrTy)) {
4949 if (auto nullability = attributed->getImmediateNullability()) {
4950 T = attributed->getModifiedType();
4951 return nullability;
4952 }
4953 }
4954
4955 return std::nullopt;
4956}
4957
4959 const auto *objcPtr = getAs();
4960 if (!objcPtr)
4961 return false;
4962
4963 if (objcPtr->isObjCIdType()) {
4964
4965 return true;
4966 }
4967
4968
4971 return false;
4972
4973
4974 } else if (objcPtr->isObjCQualifiedIdType()) {
4975
4976 } else {
4977 return false;
4978 }
4979
4980
4982
4985 return false;
4986 }
4987
4988 return true;
4989}
4990
4995}
4996
4999 "cannot query implicit lifetime for non-inferrable type");
5000
5002
5003
5004 while (const auto *array = dyn_cast(canon))
5005 canon = array->getElementType().getTypePtr();
5006
5007 if (const auto *opt = dyn_cast(canon)) {
5008
5009 if (opt->getObjectType()->isObjCClass())
5010 return true;
5011 }
5012
5013 return false;
5014}
5015
5017 if (const auto *typedefType = getAs())
5018 return typedefType->getDecl()->hasAttr();
5019 return false;
5020}
5021
5023 if (const auto *typedefType = getAs())
5024 return typedefType->getDecl()->hasAttr();
5025 return false;
5026}
5027
5032}
5033
5036 return true;
5037 if (const auto *OPT = getAs())
5038 return OPT->getPointeeType()->isObjCIndirectLifetimeType();
5039 if (const auto *Ref = getAs())
5040 return Ref->getPointeeType()->isObjCIndirectLifetimeType();
5041 if (const auto *MemPtr = getAs())
5042 return MemPtr->getPointeeType()->isObjCIndirectLifetimeType();
5043 return false;
5044}
5045
5046
5047
5050 while (const ArrayType *array = type->getAsArrayTypeUnsafe())
5051 type = array->getElementType().getTypePtr();
5052 return type->isObjCRetainableType();
5053}
5054
5055
5056
5059}
5060
5061
5063 const auto *Pointer = getAs();
5065 return false;
5066
5069}
5070
5071
5073 if (const auto *RT = getAs())
5074 return RT->getDecl()->hasAttr();
5075 return false;
5076}
5077
5078
5080 if (const auto *RT = getAs())
5081 return RT->getDecl()->hasAttr();
5082 return false;
5083}
5084
5087
5088 if (const auto *ptr = getAs())
5089 return ptr->getPointeeType()->hasSizedVLAType();
5090 if (const auto *ref = getAs())
5091 return ref->getPointeeType()->hasSizedVLAType();
5093 if (isa(arr) &&
5094 cast(arr)->getSizeExpr())
5095 return true;
5096
5097 return arr->getElementType()->hasSizedVLAType();
5098 }
5099
5100 return false;
5101}
5102
5105
5106
5109
5110
5111 while (isa(Ty))
5113
5116 if (!RT)
5117 return false;
5118
5120 assert(RD != nullptr &&
5121 "all HLSL structs and classes should be CXXRecordDecl");
5124}
5125
5127 switch (type.getObjCLifetime()) {
5131 break;
5132
5137 }
5138
5139 if (const auto *RT =
5140 type->getBaseElementTypeUnsafe()->getAs<RecordType>()) {
5141 const RecordDecl *RD = RT->getDecl();
5142 if (const auto *CXXRD = dyn_cast(RD)) {
5143
5144 if (CXXRD->hasDefinition() && !CXXRD->hasTrivialDestructor())
5146 } else {
5147
5148
5151 }
5152 }
5153
5155}
5156
5159}
5160
5162 llvm::APSInt Val, unsigned Scale) {
5163 llvm::FixedPointSemantics FXSema(Val.getBitWidth(), Scale, Val.isSigned(),
5164 false,
5165 false);
5166 llvm::APFixedPoint(Val, FXSema).toString(Str);
5167}
5168
5173 : DeducedType(Auto, DeducedAsType, ExtraDependence, Canon) {
5174 AutoTypeBits.Keyword = llvm::to_underlying(Keyword);
5175 AutoTypeBits.NumArgs = TypeConstraintArgs.size();
5176 this->TypeConstraintConcept = TypeConstraintConcept;
5177 assert(TypeConstraintConcept || AutoTypeBits.NumArgs == 0);
5178 if (TypeConstraintConcept) {
5179 auto *ArgBuffer =
5180 const_cast<TemplateArgument *>(getTypeConstraintArguments().data());
5182
5183
5184 addDependence(
5186
5188 }
5189 }
5190}
5191
5197 ID.AddInteger((unsigned)Keyword);
5198 ID.AddBoolean(IsDependent);
5199 ID.AddPointer(CD);
5201 Arg.Profile(ID, Context);
5202}
5203
5207}
5208
5210 switch (kind()) {
5219 }
5220 llvm_unreachable("unknown effect kind");
5221}
5222
5224 switch (kind()) {
5226 return "nonblocking";
5228 return "nonallocating";
5230 return "blocking";
5232 return "allocating";
5233 }
5234 llvm_unreachable("unknown effect kind");
5235}
5236
5239 switch (kind()) {
5243
5245 return Effect;
5246
5248 return Effect;
5249 }
5250 return std::nullopt;
5251 }
5252
5255 assert(0 && "effectProhibitingInference with non-inferable effect kind");
5256 break;
5257 }
5258 llvm_unreachable("unknown effect kind");
5259}
5260
5263 switch (kind()) {
5266 const Kind CallerKind = kind();
5268 const Kind EK = Effect.kind();
5269
5270 if (EK == CallerKind ||
5272 return false;
5273 }
5274 }
5275 return true;
5276 }
5279 return false;
5280 }
5281 llvm_unreachable("unknown effect kind");
5282}
5283
5284
5285
5290
5291
5292
5293 unsigned InsertIdx = Effects.size();
5294 unsigned Idx = 0;
5296
5297
5298
5299 if (EC.Cond.getCondition() == nullptr && NewCondition == nullptr) {
5301
5302
5303
5304 return true;
5305 }
5306
5307 if (EC.Effect.kind() == NewOppositeKind) {
5308 Errs.push_back({EC, NewEC});
5309 return false;
5310 }
5311 }
5312
5314 InsertIdx = Idx;
5315
5316 ++Idx;
5317 }
5318
5319 if (NewCondition || !Conditions.empty()) {
5320 if (Conditions.empty() && !Effects.empty())
5321 Conditions.resize(Effects.size());
5322 Conditions.insert(Conditions.begin() + InsertIdx,
5324 }
5325 Effects.insert(Effects.begin() + InsertIdx, NewEC.Effect);
5326 return true;
5327}
5328
5330 for (const auto &Item : Set)
5332 return Errs.empty();
5333}
5334
5339
5340
5341
5342
5343 auto IterA = LHS.begin(), EndA = LHS.end();
5344 auto IterB = RHS.begin(), EndB = RHS.end();
5345
5348 return std::tuple(LHS.Effect, uintptr_t(LHS.Cond.getCondition())) <
5349 std::tuple(RHS.Effect, uintptr_t(RHS.Cond.getCondition()));
5350 };
5351
5352 while (IterA != EndA && IterB != EndB) {
5355 if (FEWCLess(A, B))
5356 ++IterA;
5357 else if (FEWCLess(B, A))
5358 ++IterB;
5359 else {
5360 Result.insert(A, Errs);
5361 ++IterA;
5362 ++IterB;
5363 }
5364 }
5365
5366
5367
5368 assert(Errs.empty() && "conflict shouldn't be possible in getIntersection");
5369
5371}
5372
5376
5377 if (LHS.empty())
5379
5381 Combined.insert(RHS, Errs);
5382 return Combined;
5383}
5384
5385namespace clang {
5386
5391 OS << '(';
5393 OS << ')';
5394 }
5395 return OS;
5396}
5397
5398}
5399
5401 OS << "Effects{";
5402 llvm::interleaveComma(*this, OS);
5403 OS << "}";
5404}
5405
5408}
5409
5411 OS << "Effects{";
5412 llvm::interleaveComma(*this, OS);
5413 OS << "}";
5414}
5415
5419 assert(std::is_sorted(FX.begin(), FX.end()) && "effects should be sorted");
5420 assert((Conds.empty() || Conds.size() == FX.size()) &&
5421 "effects size should match conditions size");
5423}
5424
5430}
5431
5434
5435
5438 if (!RD->fields().empty()) {
5439 const auto &FirstFD = RD->fields().begin();
5440 return dyn_cast(
5441 FirstFD->getType().getTypePtr());
5442 }
5443 }
5444 return nullptr;
5445}
Defines the clang::ASTContext interface.
Provides definitions for the various language-specific address spaces.
static Decl::Kind getKind(const Decl *D)
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate....
Defines the C++ template declaration subclasses.
Defines the ExceptionSpecificationType enumeration and various utility functions.
Defines the clang::IdentifierInfo, clang::IdentifierTable, and clang::Selector interfaces.
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified.
Defines the clang::LangOptions interface.
llvm::MachO::Record Record
static bool isRecordType(QualType T)
Defines various enumerations that describe declaration and type specifiers.
static QualType getPointeeType(const MemRegion *R)
Defines the TargetCXXABI class, which abstracts details of the C++ ABI that we're targeting.
static TagDecl * getInterestingTagDecl(TagDecl *decl)
#define SUGARED_TYPE_CLASS(Class)
static const TemplateTypeParmDecl * getReplacedParameter(Decl *D, unsigned Index)
static bool isTriviallyCopyableTypeImpl(const QualType &type, const ASTContext &Context, bool IsCopyConstructible)
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...
#define TRIVIAL_TYPE_CLASS(Class)
static CachedProperties computeCachedProperties(const Type *T)
C Language Family Type Representation.
Defines the clang::Visibility enumeration and various utility functions.
__DEVICE__ void * memcpy(void *__a, const void *__b, size_t __c)
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
BuiltinVectorTypeInfo getBuiltinVectorTypeInfo(const BuiltinType *VecTy) const
Returns the element type, element count and number of vectors (in case of tuple) for a builtin vector...
QualType getAtomicType(QualType T) const
Return the uniqued reference to the atomic type for the specified type.
QualType getParenType(QualType NamedType) const
QualType getRValueReferenceType(QualType T) const
Return the uniqued reference to the type for an rvalue reference to the specified type.
QualType getAutoType(QualType DeducedType, AutoTypeKeyword Keyword, bool IsDependent, bool IsPack=false, ConceptDecl *TypeConstraintConcept=nullptr, ArrayRef< TemplateArgument > TypeConstraintArgs={}) const
C++11 deduced auto type.
QualType getObjCInterfaceType(const ObjCInterfaceDecl *Decl, ObjCInterfaceDecl *PrevDecl=nullptr) const
getObjCInterfaceType - Return the unique reference to the type for the specified ObjC interface decl.
QualType getBlockPointerType(QualType T) const
Return the uniqued reference to the type for a block of the specified type.
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 ...
QualType getAttributedType(attr::Kind attrKind, QualType modifiedType, QualType equivalentType, const Attr *attr=nullptr) const
QualType getVariableArrayType(QualType EltTy, Expr *NumElts, ArraySizeModifier ASM, unsigned IndexTypeQuals, SourceRange Brackets) const
Return a non-unique reference to the type for a variable array of the specified element type.
QualType getFunctionNoProtoType(QualType ResultTy, const FunctionType::ExtInfo &Info) const
Return a K&R style C function type like 'int()'.
QualType getArrayParameterType(QualType Ty) const
Return the uniqued reference to a specified array parameter type from the original array type.
QualType getVectorType(QualType VectorType, unsigned NumElts, VectorKind VecKind) const
Return the unique reference to a vector type of the specified element type and size.
QualType getSubstTemplateTypeParmType(QualType Replacement, Decl *AssociatedDecl, unsigned Index, std::optional< unsigned > PackIndex, SubstTemplateTypeParmTypeFlag Flag=SubstTemplateTypeParmTypeFlag::None) const
Retrieve a substitution-result type.
QualType getPointerType(QualType T) const
Return the uniqued reference to the type for a pointer to the specified type.
QualType getLValueReferenceType(QualType T, bool SpelledAsLValue=true) const
Return the uniqued reference to the type for an lvalue reference to the specified type.
QualType getConstantArrayType(QualType EltTy, const llvm::APInt &ArySize, const Expr *SizeExpr, ArraySizeModifier ASM, unsigned IndexTypeQuals) const
Return the unique reference to the type for a constant array of the specified element type.
const LangOptions & getLangOpts() const
QualType applyObjCProtocolQualifiers(QualType type, ArrayRef< ObjCProtocolDecl * > protocols, bool &hasError, bool allowOnPointerType=false) const
Apply Objective-C protocol qualifiers to the given type.
QualType getDecayedType(QualType T) const
Return the uniqued reference to the decayed version of the given type.
QualType getBaseElementType(const ArrayType *VAT) const
Return the innermost element type of an array type.
CanQualType ObjCBuiltinIdTy
IdentifierInfo * getNSObjectName() const
Retrieve the identifier 'NSObject'.
CanQualType getSizeType() const
Return the unique type for "size_t" (C99 7.17), defined in <stddef.h>.
QualType getAdjustedType(QualType Orig, QualType New) const
Return the uniqued reference to a type adjusted from the original type to a new type.
QualType getQualifiedType(SplitQualType split) const
Un-split a SplitQualType.
QualType getObjCObjectPointerType(QualType OIT) const
Return a ObjCObjectPointerType type for the given ObjCObjectType.
QualType getObjCObjectType(QualType Base, ObjCProtocolDecl *const *Protocols, unsigned NumProtocols) const
Legacy interface: cannot provide type arguments or __kindof.
const ArrayType * getAsArrayType(QualType T) const
Type Query functions.
uint64_t getTypeSize(QualType T) const
Return the size of the specified (complete) type T, in bits.
CharUnits getTypeSizeInChars(QualType T) const
Return the size of the specified (complete) type T, in characters.
CanQualType UnsignedCharTy
QualType getFunctionType(QualType ResultTy, ArrayRef< QualType > Args, const FunctionProtoType::ExtProtoInfo &EPI) const
Return a normal function type with a typed argument list.
QualType getComplexType(QualType T) const
Return the uniqued reference to the type for a complex number with the specified element type.
QualType getExtVectorType(QualType VectorType, unsigned NumElts) const
Return the unique reference to an extended vector type of the specified element type and size.
const TargetInfo & getTargetInfo() const
QualType getIncompleteArrayType(QualType EltTy, ArraySizeModifier ASM, unsigned IndexTypeQuals) const
Return a unique reference to the type for an incomplete array of the specified element type.
QualType getUnqualifiedArrayType(QualType T, Qualifiers &Quals) const
Return this type as a completely-unqualified array type, capturing the qualifiers in Quals.
QualType getConstantMatrixType(QualType ElementType, unsigned NumRows, unsigned NumColumns) const
Return the unique reference to the matrix type of the specified element type and size.
IdentifierInfo * getNSCopyingName()
Retrieve the identifier 'NSCopying'.
Represents a type which was implicitly adjusted by the semantic engine for arbitrary reasons.
Represents a constant array type that does not decay to a pointer when used as a function parameter.
QualType getConstantArrayType(const ASTContext &Ctx) const
Represents an array type, per C99 6.7.5.2 - Array Declarators.
ArraySizeModifier getSizeModifier() const
Qualifiers getIndexTypeQualifiers() const
QualType getElementType() const
ArrayType(TypeClass tc, QualType et, QualType can, ArraySizeModifier sm, unsigned tq, const Expr *sz=nullptr)
Attr - This represents one attribute.
An attributed type is a type to which a type attribute has been applied.
bool isCallingConv() const
std::optional< NullabilityKind > getImmediateNullability() const
static std::optional< NullabilityKind > stripOuterNullability(QualType &T)
Strip off the top-level nullability annotation on the given type, if it's there.
bool isMSTypeSpec() const
bool isWebAssemblyFuncrefSpec() const
bool isQualifier() const
Does this attribute behave like a type qualifier?
Represents a C++11 auto or C++14 decltype(auto) type, possibly constrained by a type-constraint.
ArrayRef< TemplateArgument > getTypeConstraintArguments() const
void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context)
ConceptDecl * getTypeConstraintConcept() const
AutoTypeKeyword getKeyword() const
BitIntType(bool isUnsigned, unsigned NumBits)
[BoundsSafety] Represents a parent type class for CountAttributedType and similar sugar types that wi...
BoundsAttributedType(TypeClass TC, QualType Wrapped, QualType Canon)
decl_range dependent_decls() const
bool referencesFieldDecls() const
ArrayRef< TypeCoupledDeclRefInfo > Decls
This class is used for builtin types like 'int'.
StringRef getName(const PrintingPolicy &Policy) const
Represents a C++ struct/union/class.
bool isHLSLIntangible() const
Returns true if the class contains HLSL intangible type, either as a field or in base class.
bool mayBeNonDynamicClass() const
CXXRecordDecl * getMostRecentNonInjectedDecl()
bool mayBeDynamicClass() const
QuantityType getQuantity() const
getQuantity - Get the raw integer representation of this quantity.
Complex values, per C99 6.2.5p11.
Declaration of a C++20 concept.
Represents the canonical version of C arrays with a specified constant size.
static unsigned getNumAddressingBits(const ASTContext &Context, QualType ElementType, const llvm::APInt &NumElements)
Determine the number of bits required to address a member of.
static unsigned getMaxSizeBits(const ASTContext &Context)
Determine the maximum number of active bits that an array's size can require, which limits the maximu...
const Expr * getSizeExpr() const
Return a pointer to the size expression.
llvm::APInt getSize() const
Return the constant array size as an APInt.
void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Ctx)
ConstantExpr - An expression that occurs in a constant context and optionally the result of evaluatin...
llvm::APSInt getResultAsAPSInt() const
Represents a concrete matrix type with constant number of rows and columns.
ConstantMatrixType(QualType MatrixElementType, unsigned NRows, unsigned NColumns, QualType CanonElementType)
Represents a sugar type with __counted_by or __sized_by annotations, including their _or_null variant...
void Profile(llvm::FoldingSetNodeID &ID)
Represents a pointer type decayed from an array or function type.
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
ASTContext & getParentASTContext() const
Decl - This represents one declaration (or definition), e.g.
bool isInStdNamespace() const
ASTContext & getASTContext() const LLVM_READONLY
virtual Decl * getCanonicalDecl()
Retrieves the "canonical" declaration of the given declaration.
Represents the type decltype(expr) (C++11).
QualType desugar() const
Remove a single level of sugar.
bool isSugared() const
Returns whether this type directly provides sugar.
DecltypeType(Expr *E, QualType underlyingType, QualType can=QualType())
QualType getUnderlyingType() const
Common base class for placeholders for types that get replaced by placeholder type deduction: C++11 a...
QualType getDeducedType() const
Get the type deduced for this placeholder type, or null if it has not been deduced.
void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context)
Expr * getNumBitsExpr() const
void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context)
DependentBitIntType(bool IsUnsigned, Expr *NumBits)
void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context)
DependentDecltypeType(Expr *E, QualType UnderlyingTpe)
void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context)
Represents an extended vector type where either the type or size is dependent.
void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context)
Represents a matrix type where the type and the number of rows and columns is dependent on a template...
void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context)
void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context)
void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context)
DependentUnaryTransformType(const ASTContext &C, QualType BaseType, UTTKind UKind)
void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context)
Wrap a function effect's condition expression in another struct so that FunctionProtoType's TrailingO...
Expr * getCondition() const
Represents a type that was referred to using an elaborated type keyword, e.g., struct S,...
bool isComplete() const
Returns true if this can be considered a complete type.
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of enums.
This represents one expression.
bool isValueDependent() const
Determines whether the value of this expression depends on.
bool isTypeDependent() const
Determines whether the type of this expression depends on.
bool isInstantiationDependent() const
Whether this expression is instantiation-dependent, meaning that it depends in some way on.
ExprDependence getDependence() const
ExtVectorType - Extended vector type.
Represents a member of a struct/union/class.
A mutable set of FunctionEffect::Kind.
void dump(llvm::raw_ostream &OS) const
A mutable set of FunctionEffects and possibly conditions attached to them.
FunctionEffectSet()=default
bool insert(const FunctionEffectWithCondition &NewEC, Conflicts &Errs)
static FunctionEffectSet getIntersection(FunctionEffectsRef LHS, FunctionEffectsRef RHS)
void dump(llvm::raw_ostream &OS) const
static FunctionEffectSet getUnion(FunctionEffectsRef LHS, FunctionEffectsRef RHS, Conflicts &Errs)
Represents an abstract function effect, using just an enumeration describing its kind.
Kind kind() const
The kind of the effect.
Kind
Identifies the particular effect.
bool shouldDiagnoseFunctionCall(bool Direct, FunctionEffectKindSet CalleeFX) const
StringRef name() const
The description printed in diagnostics, e.g. 'nonblocking'.
Kind oppositeKind() const
Return the opposite kind, for effects which have opposites.
std::optional< FunctionEffect > effectProhibitingInference(const Decl &Callee, FunctionEffectKindSet CalleeFX) const
Determine whether the effect is allowed to be inferred on the callee, which is either a FunctionDecl ...
An immutable set of FunctionEffects and possibly conditions attached to them.
void dump(llvm::raw_ostream &OS) const
ArrayRef< FunctionEffect > effects() const
ArrayRef< EffectConditionExpr > conditions() const
static FunctionEffectsRef create(ArrayRef< FunctionEffect > FX, ArrayRef< EffectConditionExpr > Conds)
Asserts invariants.
FunctionEffectsRef()=default
Represents a K&R-style 'int foo()' function, which has no information available about its arguments.
Represents a prototype with parameter type info, e.g.
bool hasDependentExceptionSpec() const
Return whether this function has a dependent exception spec.
param_type_iterator param_type_begin() const
ExceptionSpecificationType getExceptionSpecType() const
Get the kind of exception specification on this function.
bool isTemplateVariadic() const
Determines whether this function prototype contains a parameter pack at the end.
unsigned getNumParams() const
bool hasTrailingReturn() const
Whether this function prototype has a trailing return type.
QualType getParamType(unsigned i) const
QualType getExceptionType(unsigned i) const
Return the ith exception type, where 0 <= i < getNumExceptions().
void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Ctx)
unsigned getNumExceptions() const
Return the number of types in the exception specification.
CanThrowResult canThrow() const
Determine whether this function type has a non-throwing exception specification.
ExtProtoInfo getExtProtoInfo() const
Expr * getNoexceptExpr() const
Return the expression inside noexcept(expression), or a null pointer if there is none (because the ex...
ArrayRef< QualType > getParamTypes() const
ArrayRef< QualType > exceptions() const
bool hasInstantiationDependentExceptionSpec() const
Return whether this function has an instantiation-dependent exception spec.
A class which abstracts out some details necessary for making a call.
FunctionType - C99 6.7.5.3 - Function Declarators.
ExtInfo getExtInfo() const
static StringRef getNameForCallConv(CallingConv CC)
QualType getReturnType() const
static const HLSLAttributedResourceType * findHandleTypeOnResource(const Type *RT)
One of these records is kept for each identifier that is lexed.
bool isStr(const char(&Str)[StrLen]) const
Return true if this is the identifier for the specified string.
Represents a C array with an unspecified size.
CXXRecordDecl * getDecl() const
An lvalue reference type, per C++11 [dcl.ref].
LinkageInfo computeTypeLinkageInfo(const Type *T)
LinkageInfo getTypeLinkageAndVisibility(const Type *T)
LinkageInfo getDeclLinkageAndVisibility(const NamedDecl *D)
static LinkageInfo external()
Linkage getLinkage() const
void merge(LinkageInfo other)
Merge both linkage and visibility.
Sugar type that represents a type that was qualified by a qualifier written as a macro invocation.
QualType getModifiedType() const
Return this attributed type's modified type with no qualifiers attached to it.
QualType getUnderlyingType() const
const IdentifierInfo * getMacroIdentifier() const
Represents a matrix type, as defined in the Matrix Types clang extensions.
MatrixType(QualType ElementTy, QualType CanonElementTy)
QualType ElementType
The element type of the matrix.
A pointer to member type per C++ 8.3.3 - Pointers to members.
CXXRecordDecl * getMostRecentCXXRecordDecl() const
const Type * getClass() const
This represents a decl that may have a name.
IdentifierInfo * getIdentifier() const
Get the identifier that names this declaration, if there is one.
Represents a C++ nested name specifier, such as "\::std::vector::".
bool isDependent() const
Whether this nested name specifier refers to a dependent type or not.
ObjCCategoryDecl - Represents a category declaration.
ObjCInterfaceDecl * getClassInterface()
ObjCTypeParamList * getTypeParamList() const
Retrieve the type parameter list associated with this category or extension.
Represents an ObjC class declaration.
ObjCTypeParamList * getTypeParamList() const
Retrieve the type parameters of this class.
const ObjCObjectType * getSuperClassType() const
Retrieve the superclass type.
ObjCInterfaceDecl * getDefinition()
Retrieve the definition of this class, or NULL if this class has been forward-declared (with @class) ...
Interfaces are the core concept in Objective-C for object oriented design.
ObjCInterfaceDecl * getDecl() const
Get the declaration of this interface.
Represents a pointer to an Objective C object.
const ObjCObjectPointerType * stripObjCKindOfTypeAndQuals(const ASTContext &ctx) const
Strip off the Objective-C "kindof" type and (with it) any protocol qualifiers.
const ObjCObjectType * getObjectType() const
Gets the type pointed to by this ObjC pointer.
QualType getSuperClassType() const
Retrieve the type of the superclass of this object pointer type.
ObjCInterfaceDecl * getInterfaceDecl() const
If this pointer points to an Objective @interface type, gets the declaration for that interface.
const ObjCInterfaceType * getInterfaceType() const
If this pointer points to an Objective C @interface type, gets the type for that interface.
bool isKindOfType() const
Whether this is a "__kindof" type.
void Profile(llvm::FoldingSetNodeID &ID)
Represents a class type in Objective C.
bool isKindOfTypeAsWritten() const
Whether this is a "__kindof" type as written.
bool isSpecialized() const
Determine whether this object type is "specialized", meaning that it has type arguments.
ObjCObjectType(QualType Canonical, QualType Base, ArrayRef< QualType > typeArgs, ArrayRef< ObjCProtocolDecl * > protocols, bool isKindOf)
ArrayRef< QualType > getTypeArgsAsWritten() const
Retrieve the type arguments of this object type as they were written.
QualType getBaseType() const
Gets the base type of this object type.
bool isKindOfType() const
Whether this ia a "__kindof" type (semantically).
bool isSpecializedAsWritten() const
Determine whether this object type was written with type arguments.
ArrayRef< QualType > getTypeArgs() const
Retrieve the type arguments of this object type (semantically).
bool isUnspecialized() const
Determine whether this object type is "unspecialized", meaning that it has no type arguments.
QualType stripObjCKindOfTypeAndQuals(const ASTContext &ctx) const
Strip off the Objective-C "kindof" type and (with it) any protocol qualifiers.
void computeSuperClassTypeSlow() const
ObjCInterfaceDecl * getInterface() const
Gets the interface declaration for this object type, if the base type really is an interface.
QualType getSuperClassType() const
Retrieve the type of the superclass of this object type.
Represents an Objective-C protocol declaration.
void initialize(ArrayRef< ObjCProtocolDecl * > protocols)
ArrayRef< ObjCProtocolDecl * > getProtocols() const
Retrieve all of the protocol qualifiers.
unsigned getNumProtocols() const
Return the number of qualifying protocols in this type, or 0 if there are none.
qual_iterator qual_end() const
qual_iterator qual_begin() const
Represents the declaration of an Objective-C type parameter.
unsigned getIndex() const
Retrieve the index into its type parameter list.
Stores a list of Objective-C type parameters for a parameterized class or a category/extension thereo...
unsigned size() const
Determine the number of type parameters in this list.
Represents a type parameter type in Objective C.
void Profile(llvm::FoldingSetNodeID &ID)
ObjCTypeParamDecl * getDecl() const
Represents a pack expansion of types.
void Profile(llvm::FoldingSetNodeID &ID)
Expr * getIndexExpr() const
PackIndexingType(const ASTContext &Context, QualType Canonical, QualType Pattern, Expr *IndexExpr, bool FullySubstituted, ArrayRef< QualType > Expansions={})
std::optional< unsigned > getSelectedIndex() const
Sugar for parentheses used when specifying types.
PointerType - C99 6.7.5.1 - Pointer Declarators.
A (possibly-)qualified type.
bool isTriviallyCopyableType(const ASTContext &Context) const
Return true if this is a trivially copyable type (C++0x [basic.types]p9)
QualType IgnoreParens() const
Returns the specified type after dropping any outer-level parentheses.
QualType withFastQualifiers(unsigned TQs) const
bool hasNonTrivialToPrimitiveCopyCUnion() const
Check if this is or contains a C union that is non-trivial to copy, which is a union that has a membe...
bool isWebAssemblyFuncrefType() const
Returns true if it is a WebAssembly Funcref Type.
QualType getNonLValueExprType(const ASTContext &Context) const
Determine the type of a (typically non-lvalue) expression with the specified result type.
@ DK_objc_strong_lifetime
PrimitiveDefaultInitializeKind
@ PDIK_ARCWeak
The type is an Objective-C retainable pointer type that is qualified with the ARC __weak qualifier.
@ PDIK_Trivial
The type does not fall into any of the following categories.
@ PDIK_ARCStrong
The type is an Objective-C retainable pointer type that is qualified with the ARC __strong qualifier.
@ PDIK_Struct
The type is a struct containing a field whose type is not PCK_Trivial.
bool mayBeDynamicClass() const
Returns true if it is a class and it might be dynamic.
bool isNonWeakInMRRWithObjCWeak(const ASTContext &Context) const
const IdentifierInfo * getBaseTypeIdentifier() const
Retrieves a pointer to the name of the base type.
bool isBitwiseCloneableType(const ASTContext &Context) const
Return true if the type is safe to bitwise copy using memcpy/memmove.
void Profile(llvm::FoldingSetNodeID &ID) const
QualType getDesugaredType(const ASTContext &Context) const
Return the specified type with any "sugar" removed from the type.
bool isTriviallyCopyConstructibleType(const ASTContext &Context) const
Return true if this is a trivially copyable type.
bool isTrivialType(const ASTContext &Context) const
Return true if this is a trivial type per (C++0x [basic.types]p9)
bool isNull() const
Return true if this QualType doesn't point to a type yet.
PrimitiveCopyKind isNonTrivialToPrimitiveCopy() const
Check if this is a non-trivial type that would cause a C struct transitively containing this type to ...
bool isTriviallyRelocatableType(const ASTContext &Context) const
Return true if this is a trivially relocatable type.
const Type * getTypePtr() const
Retrieves a pointer to the underlying (unqualified) type.
LangAS getAddressSpace() const
Return the address space of this type.
bool isConstant(const ASTContext &Ctx) const
bool hasNonTrivialToPrimitiveDestructCUnion() const
Check if this is or contains a C union that is non-trivial to destruct, which is a union that has a m...
Qualifiers getQualifiers() const
Retrieve the set of qualifiers applied to this type.
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...
Qualifiers::ObjCLifetime getObjCLifetime() const
Returns lifetime attribute of this type.
QualType stripObjCKindOfType(const ASTContext &ctx) const
Strip Objective-C "__kindof" types from the given type.
QualType getCanonicalType() const
QualType getUnqualifiedType() const
Retrieve the unqualified variant of the given type, removing as little sugar as possible.
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...
bool isWebAssemblyReferenceType() const
Returns true if it is a WebAssembly Reference Type.
SplitQualType getSplitDesugaredType() const
std::optional< NonConstantStorageReason > isNonConstantStorage(const ASTContext &Ctx, bool ExcludeCtor, bool ExcludeDtor)
Determine whether instances of this type can be placed in immutable storage.
SplitQualType split() const
Divides a QualType into its unqualified type and a set of local qualifiers.
bool UseExcessPrecision(const ASTContext &Ctx)
PrimitiveDefaultInitializeKind isNonTrivialToPrimitiveDefaultInitialize() const
Functions to query basic properties of non-trivial C struct types.
void * getAsOpaquePtr() const
bool isWebAssemblyExternrefType() const
Returns true if it is a WebAssembly Externref Type.
QualType getNonPackExpansionType() const
Remove an outer pack expansion type (if any) from this type.
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,...
bool mayBeNotDynamicClass() const
Returns true if it is not a class or if the class might not be dynamic.
bool isConstQualified() const
Determine whether this type is const-qualified.
QualType substObjCTypeArgs(ASTContext &ctx, ArrayRef< QualType > typeArgs, ObjCSubstitutionContext context) const
Substitute type arguments for the Objective-C type parameters used in the subject type.
QualType getAtomicUnqualifiedType() const
Remove all qualifiers including _Atomic.
DestructionKind isDestructedType() const
Returns a nonzero value if objects of this type require non-trivial work to clean up after.
bool hasNonTrivialObjCLifetime() const
bool isPODType(const ASTContext &Context) const
Determine whether this is a Plain Old Data (POD) type (C++ 3.9p10).
PrimitiveCopyKind isNonTrivialToPrimitiveDestructiveMove() const
Check if this is a non-trivial type that would cause a C struct transitively containing this type to ...
@ NonConstNonReferenceType
@ PCK_Struct
The type is a struct containing a field whose type is neither PCK_Trivial nor PCK_VolatileTrivial.
@ PCK_Trivial
The type does not fall into any of the following categories.
@ PCK_ARCStrong
The type is an Objective-C retainable pointer type that is qualified with the ARC __strong qualifier.
@ PCK_VolatileTrivial
The type would be trivial except that it is volatile-qualified.
@ PCK_ARCWeak
The type is an Objective-C retainable pointer type that is qualified with the ARC __weak qualifier.
bool hasNonTrivialToPrimitiveDefaultInitializeCUnion() const
Check if this is or contains a C union that is non-trivial to default-initialize, which is a union th...
A qualifier set is used to build a set of qualifiers.
const Type * strip(QualType type)
Collect any qualifiers on the given type and return an unqualified type.
QualType apply(const ASTContext &Context, QualType QT) const
Apply the collected qualifiers to the given type.
The collection of all-type qualifiers we support.
@ OCL_Strong
Assigning into this object requires the old value to be released and the new value to be retained.
@ OCL_ExplicitNone
This object can be modified without requiring retains or releases.
@ OCL_None
There is no lifetime qualification on this type.
@ OCL_Weak
Reading or writing from this object requires a barrier call.
@ OCL_Autoreleasing
Assigning into this object requires a lifetime extension.
bool isStrictSupersetOf(Qualifiers Other) const
Determine whether this set of qualifiers is a strict superset of another set of qualifiers,...
bool hasNonFastQualifiers() const
Return true if the set contains any qualifiers which require an ExtQuals node to be allocated.
void addConsistentQualifiers(Qualifiers qs)
Add the qualifiers from the given set to this set, given that they don't conflict.
static bool isTargetAddressSpaceSupersetOf(LangAS A, LangAS B, const ASTContext &Ctx)
bool hasAddressSpace() const
unsigned getFastQualifiers() const
bool hasObjCGCAttr() const
bool hasObjCLifetime() const
ObjCLifetime getObjCLifetime() const
LangAS getAddressSpace() const
An rvalue reference type, per C++11 [dcl.ref].
Represents a struct/union/class.
bool hasNonTrivialToPrimitiveDestructCUnion() const
bool hasNonTrivialToPrimitiveCopyCUnion() const
bool hasNonTrivialToPrimitiveDefaultInitializeCUnion() const
bool isNonTrivialToPrimitiveDestroy() const
field_range fields() const
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
RecordDecl * getDecl() const
bool hasConstFields() const
Recursively check all fields in the record for const-ness.
Declaration of a redeclarable template.
redecl_range redecls() const
Returns an iterator range for all the redeclarations of the same decl.
Base for LValueReferenceType and RValueReferenceType.
Encodes a location in the source.
A trivial tuple used to represent a source range.
Stmt - This represents one statement.
void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context, bool Canonical, bool ProfileLambdaExpr=false) const
Produce a unique representation of the given statement.
void dump() const
Dumps the specified AST fragment and all subtrees to llvm::errs().
Decl * getAssociatedDecl() const
A template-like entity which owns the whole pattern being substituted.
IdentifierInfo * getIdentifier() const
TemplateArgument getArgumentPack() const
void Profile(llvm::FoldingSetNodeID &ID)
unsigned getIndex() const
Returns the index of the replaced parameter in the associated declaration.
unsigned getNumArgs() const
const TemplateTypeParmDecl * getReplacedParameter() const
Gets the template parameter declaration that was substituted for.
Represents the result of substituting a type for a template type parameter.
Decl * getAssociatedDecl() const
A template-like entity which owns the whole pattern being substituted.
unsigned getIndex() const
Returns the index of the replaced parameter in the associated declaration.
const TemplateTypeParmDecl * getReplacedParameter() const
Gets the template parameter declaration that was substituted for.
Represents the declaration of a struct/union/class/enum.
bool isBeingDefined() const
Return true if this decl is currently being defined.
bool isCompleteDefinition() const
Return true if this decl has its body fully specified.
TagType(TypeClass TC, const TagDecl *D, QualType can)
TagDecl * getDecl() const
bool isBeingDefined() const
Determines whether this type is in the process of being defined.
bool isMicrosoft() const
Is this ABI an MSVC-compatible ABI?
Exposes information about the current target.
virtual bool hasLegalHalfType() const
Determine whether _Float16 is supported on this target.
virtual bool hasFullBFloat16Type() const
Determine whether the BFloat type is fully supported on this target, i.e arithemtic operations.
virtual bool hasFloat16Type() const
Determine whether the _Float16 type is supported on this target.
TargetCXXABI getCXXABI() const
Get the C++ ABI currently in use.
virtual bool hasBFloat16Type() const
Determine whether the _BFloat16 type is supported on this target.
virtual bool isAddressSpaceSupersetOf(LangAS A, LangAS B) const
Returns true if an address space can be safely converted to another.
A convenient class for passing around template argument information.
llvm::ArrayRef< TemplateArgumentLoc > arguments() const
Location wrapper for a TemplateArgument.
Represents a template argument.
unsigned pack_size() const
The number of template arguments in the given template argument pack.
ArrayRef< TemplateArgument > pack_elements() const
Iterator range referencing all of the elements of a template argument pack.
@ Type
The template argument is a type.
The base class of all kinds of template declarations (e.g., class, function, etc.).
Represents a C++ template name within the type system.
@ UsingTemplate
A template name that refers to a template declaration found through a specific using shadow declarati...
@ Template
A single template declaration.
@ SubstTemplateTemplateParm
A template template parameter that has been substituted for some other template name.
@ SubstTemplateTemplateParmPack
A template template parameter pack that has been substituted for a template template argument pack,...
@ DeducedTemplate
A template name that refers to another TemplateName with deduced default arguments.
@ QualifiedTemplate
A qualified template name, where the qualification is kept to describe the source code as written.
Represents a type template specialization; the template must be a class template, a type alias templa...
QualType getAliasedType() const
Get the aliased type, if this is a specialization of a type alias template.
ArrayRef< TemplateArgument > template_arguments() const
bool isTypeAlias() const
Determine if this template specialization type is for a type alias template that has been substituted...
static bool anyInstantiationDependentTemplateArguments(ArrayRef< TemplateArgumentLoc > Args)
static bool anyDependentTemplateArguments(ArrayRef< TemplateArgumentLoc > Args, ArrayRef< TemplateArgument > Converted)
Determine whether any of the given template arguments are dependent.
void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Ctx)
Declaration of a template type parameter.
TemplateTypeParmDecl * getDecl() const
IdentifierInfo * getIdentifier() const
[BoundsSafety] Represents information of declarations referenced by the arguments of the counted_by a...
ValueDecl * getDecl() const
bool operator==(const TypeCoupledDeclRefInfo &Other) const
void * getOpaqueValue() const
TypeCoupledDeclRefInfo(ValueDecl *D=nullptr, bool Deref=false)
D is to a declaration referenced by the argument of attribute.
void setFromOpaqueValue(void *V)
bool isSugared() const
Returns whether this type directly provides sugar.
TypeOfKind getKind() const
Returns the kind of 'typeof' type this is.
TypeOfExprType(const ASTContext &Context, Expr *E, TypeOfKind Kind, QualType Can=QualType())
Expr * getUnderlyingExpr() const
QualType desugar() const
Remove a single level of sugar.
TypeOfKind getKind() const
Returns the kind of 'typeof' type this is.
QualType desugar() const
Remove a single level of sugar.
QualType getUnmodifiedType() const
static void ensure(const Type *T)
static CachedProperties get(QualType T)
static CachedProperties get(const Type *T)
A helper class for Type nodes having an ElaboratedTypeKeyword.
static ElaboratedTypeKeyword getKeywordForTypeSpec(unsigned TypeSpec)
Converts a type specifier (DeclSpec::TST) into an elaborated type keyword.
static TagTypeKind getTagTypeKindForKeyword(ElaboratedTypeKeyword Keyword)
Converts an elaborated type keyword into a TagTypeKind.
static bool KeywordIsTagTypeKind(ElaboratedTypeKeyword Keyword)
static StringRef getKeywordName(ElaboratedTypeKeyword Keyword)
static ElaboratedTypeKeyword getKeywordForTagTypeKind(TagTypeKind Tag)
Converts a TagTypeKind into an elaborated type keyword.
static TagTypeKind getTagTypeKindForTypeSpec(unsigned TypeSpec)
Converts a type specifier (DeclSpec::TST) into a tag type kind.
The base class of the type hierarchy.
bool isSizelessType() const
As an extension, we classify types as one of "sized" or "sizeless"; every type is one or the other.
bool isStructureType() const
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
bool isBlockPointerType() const
const ObjCObjectPointerType * getAsObjCQualifiedClassType() const
bool isLinkageValid() const
True if the computed linkage is valid.
TypedefBitfields TypedefBits
const ObjCObjectType * getAsObjCQualifiedInterfaceType() const
const ObjCObjectPointerType * getAsObjCQualifiedIdType() const
bool isSignedIntegerOrEnumerationType() const
Determines whether this is an integer type that is signed or an enumeration types whose underlying ty...
bool hasAttr(attr::Kind AK) const
Determine whether this type had the specified attribute applied to it (looking through top-level type...
QualType getRVVEltType(const ASTContext &Ctx) const
Returns the representative type for the element of an RVV builtin type.
const RecordType * getAsUnionType() const
NOTE: getAs*ArrayType are methods on ASTContext.
bool isLiteralType(const ASTContext &Ctx) const
Return true if this is a literal type (C++11 [basic.types]p10)
bool isSignedIntegerType() const
Return true if this is an integer type that is signed, according to C99 6.2.5p4 [char,...
bool isComplexType() const
isComplexType() does not include complex integers (a GCC extension).
ArrayTypeBitfields ArrayTypeBits
const ArrayType * castAsArrayTypeUnsafe() const
A variant of castAs<> for array type which silently discards qualifiers from the outermost type.
bool isUnsignedIntegerOrEnumerationType() const
Determines whether this is an integer type that is unsigned or an enumeration types whose underlying ...
bool isIntegralOrUnscopedEnumerationType() const
Determine whether this type is an integral or unscoped enumeration type.
VectorTypeBitfields VectorTypeBits
bool hasIntegerRepresentation() const
Determine whether this type has an integer representation of some sort, e.g., it is an integer type o...
bool isVoidPointerType() const
const ComplexType * getAsComplexIntegerType() const
bool isConstantSizeType() const
Return true if this is not a variable sized type, according to the rules of C99 6....
QualType getLocallyUnqualifiedSingleStepDesugaredType() const
Pull a single level of sugar off of this locally-unqualified type.
bool isFunctionPointerType() const
bool isCountAttributedType() const
bool isObjCARCBridgableType() const
Determine whether the given type T is a "bridgable" Objective-C type, which is either an Objective-C ...
bool isArithmeticType() const
bool isHLSLBuiltinIntangibleType() const
TypeOfBitfields TypeOfBits
bool isIntegerType() const
isIntegerType() does not include complex integers (a GCC extension).
bool isSVESizelessBuiltinType() const
Returns true for SVE scalable vector types.
const T * castAs() const
Member-template castAs.
bool isReferenceType() const
bool isHLSLIntangibleType() const
bool isEnumeralType() const
void addDependence(TypeDependence D)
bool isObjCNSObjectType() const
const ObjCObjectPointerType * getAsObjCInterfacePointerType() const
bool isScalarType() const
const CXXRecordDecl * getPointeeCXXRecordDecl() const
If this is a pointer or reference to a RecordType, return the CXXRecordDecl that the type refers to.
bool isInterfaceType() const
bool isVariableArrayType() const
bool isSizelessBuiltinType() const
bool isCUDADeviceBuiltinSurfaceType() const
Check if the type is the CUDA device builtin surface type.
bool isSveVLSBuiltinType() const
Determines if this is a sizeless type supported by the 'arm_sve_vector_bits' type attribute,...
bool isIntegralType(const ASTContext &Ctx) const
Determine whether this type is an integral type.
bool isElaboratedTypeSpecifier() const
Determine wither this type is a C++ elaborated-type-specifier.
CountAttributedTypeBitfields CountAttributedTypeBits
const Type * getArrayElementTypeNoTypeQual() const
If this is an array type, return the element type of the array, potentially with type qualifiers miss...
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee.
LinkageInfo getLinkageAndVisibility() const
Determine the linkage and visibility of this type.
bool hasUnsignedIntegerRepresentation() const
Determine whether this type has an unsigned integer representation of some sort, e....
bool isAnyCharacterType() const
Determine whether this type is any of the built-in character types.
bool isWebAssemblyExternrefType() const
Check if this is a WebAssembly Externref Type.
bool canHaveNullability(bool ResultIfUnknown=true) const
Determine whether the given type can have a nullability specifier applied to it, i....
QualType getSveEltType(const ASTContext &Ctx) const
Returns the representative type for the element of an SVE builtin type.
bool isInstantiationDependentType() const
Determine whether this type is an instantiation-dependent type, meaning that the type involves a temp...
bool isLValueReferenceType() const
bool isBitIntType() const
bool isBuiltinType() const
Helper methods to distinguish type categories.
bool isStructuralType() const
Determine if this type is a structural type, per C++20 [temp.param]p7.
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
bool isAggregateType() const
Determines whether the type is a C++ aggregate type or C aggregate or union type.
bool isCARCBridgableType() const
Determine whether the given type T is a "bridgeable" C type.
bool isChar16Type() const
bool isAnyComplexType() const
DependentTemplateSpecializationTypeBitfields DependentTemplateSpecializationTypeBits
DeducedType * getContainedDeducedType() const
Get the DeducedType whose type will be deduced for a variable with an initializer of this type.
bool containsUnexpandedParameterPack() const
Whether this type is or contains an unexpanded parameter pack, used to support C++0x variadic templat...
ScalarTypeKind getScalarTypeKind() const
Given that this is a scalar type, classify it.
bool hasSignedIntegerRepresentation() const
Determine whether this type has an signed integer representation of some sort, e.g....
QualType getCanonicalTypeInternal() const
const RecordType * getAsStructureType() const
const char * getTypeClassName() const
bool isWebAssemblyTableType() const
Returns true if this is a WebAssembly table type: either an array of reference types,...
const Type * getBaseElementTypeUnsafe() const
Get the base element type of this type, potentially discarding type qualifiers.
AttributedTypeBitfields AttributedTypeBits
bool isObjCBoxableRecordType() const
bool isChar32Type() const
bool isStandardLayoutType() const
Test if this type is a standard-layout type.
bool isVariablyModifiedType() const
Whether this type is a variably-modified type (C99 6.7.5).
bool isComplexIntegerType() const
bool isUnscopedEnumerationType() const
bool isStdByteType() const
bool isCUDADeviceBuiltinTextureType() const
Check if the type is the CUDA device builtin texture type.
bool isBlockCompatibleObjCPointerType(ASTContext &ctx) const
bool isObjCClassOrClassKindOfType() const
Whether the type is Objective-C 'Class' or a __kindof type of an Class type, e.g.,...
const ArrayType * getAsArrayTypeUnsafe() const
A variant of getAs<> for array types which silently discards qualifiers from the outermost type.
bool isObjCLifetimeType() const
Returns true if objects of this type have lifetime semantics under ARC.
bool isObjectType() const
Determine whether this type is an object type.
bool isObjCIndirectLifetimeType() const
bool hasUnnamedOrLocalType() const
Whether this type is or contains a local or unnamed type.
bool isPointerOrReferenceType() const
Qualifiers::ObjCLifetime getObjCARCImplicitLifetime() const
Return the implicit lifetime for this type, which must not be dependent.
FunctionTypeBitfields FunctionTypeBits
bool isObjCQualifiedInterfaceType() const
bool isSpecifierType() const
Returns true if this type can be represented by some set of type specifiers.
bool isIncompleteType(NamedDecl **Def=nullptr) const
Types are partitioned into 3 broad categories (C99 6.2.5p1): object types, function types,...
bool isObjCObjectPointerType() const
bool isStructureTypeWithFlexibleArrayMember() const
TypeDependence getDependence() const
bool hasFloatingRepresentation() const
Determine whether this type has a floating-point representation of some sort, e.g....
bool isStructureOrClassType() const
bool isVectorType() const
bool isRVVVLSBuiltinType() const
Determines if this is a sizeless type supported by the 'riscv_rvv_vector_bits' type attribute,...
bool isRealFloatingType() const
Floating point categories.
bool isRVVSizelessBuiltinType() const
Returns true for RVV scalable vector types.
std::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...
Linkage getLinkage() const
Determine the linkage of this type.
ObjCObjectTypeBitfields ObjCObjectTypeBits
bool isFloatingType() const
const ObjCObjectType * getAsObjCInterfaceType() const
bool isWideCharType() const
bool isUnsignedIntegerType() const
Return true if this is an integer type that is unsigned, according to C99 6.2.5p6 [which returns true...
bool hasSizedVLAType() const
Whether this type involves a variable-length array type with a definite size.
TypeClass getTypeClass() const
bool isCanonicalUnqualified() const
Determines if this type would be canonical if it had no further qualification.
bool hasAutoForTrailingReturnType() const
Determine whether this type was written with a leading 'auto' corresponding to a trailing return type...
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...
const T * getAs() const
Member-template getAs'.
SubstTemplateTypeParmPackTypeBitfields SubstTemplateTypeParmPackTypeBits
const Type * getUnqualifiedDesugaredType() const
Return the specified type with any "sugar" removed from the type, removing any typedefs,...
bool isObjCARCImplicitlyUnretainedType() const
Determines if this type, which must satisfy isObjCLifetimeType(), is implicitly __unsafe_unretained r...
bool isRecordType() const
TemplateSpecializationTypeBitfields TemplateSpecializationTypeBits
bool isObjCRetainableType() const
std::optional< NullabilityKind > getNullability() const
Determine the nullability of the given type.
bool isObjCIndependentClassType() const
TagDecl * getAsTagDecl() const
Retrieves the TagDecl that this type refers to, either because the type is a TagType or because it is...
bool isSizelessVectorType() const
Returns true for all scalable vector types.
bool isScopedEnumeralType() const
Determine whether this type is a scoped enumeration type.
bool acceptsObjCTypeParams() const
Determines if this is an ObjC interface type that may accept type parameters.
QualType getSizelessVectorEltType(const ASTContext &Ctx) const
Returns the representative type for the element of a sizeless vector builtin type.
RecordDecl * getAsRecordDecl() const
Retrieves the RecordDecl this type refers to.
Base class for declarations which introduce a typedef-name.
QualType getUnderlyingType() const
bool typeMatchesDecl() const
A unary type transform, which is a type constructed from another.
UnaryTransformType(QualType BaseTy, QualType UnderlyingTy, UTTKind UKind, QualType CanonicalTy)
Represents a shadow declaration implicitly introduced into a scope by a (resolved) using-declaration ...
QualType getUnderlyingType() const
bool typeMatchesDecl() const
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
Represents a C array with a specified size that is not an integer-constant-expression.
Represents a GCC generic vector type.
VectorType(QualType vecType, unsigned nElements, QualType canonType, VectorKind vecKind)
QualType getElementType() const
Defines the Linkage enumeration and various utility functions.
Defines the clang::TargetInfo interface.
const internal::VariadicAllOfMatcher< Attr > attr
Matches attributes.
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
const AstTypeMatcher< TypedefType > typedefType
Matches typedef types.
const internal::VariadicAllOfMatcher< Decl > decl
Matches declarations.
The JSON file list parser is used to communicate input to InstallAPI.
AutoTypeKeyword
Which keyword(s) were used to create an AutoType.
CanThrowResult
Possible results from evaluation of a noexcept expression.
void initialize(TemplateInstantiationCallbackPtrs &Callbacks, const Sema &TheSema)
Linkage minLinkage(Linkage L1, Linkage L2)
Compute the minimum linkage given two linkages.
@ Nullable
Values of this type can be null.
@ Unspecified
Whether values of this type can be null is (explicitly) unspecified.
@ NonNull
Values of this type can never be null.
ExprDependence computeDependence(FullExpr *E)
@ Private
'private' clause, allowed on 'parallel', 'serial', 'loop', 'parallel loop', and 'serial loop' constru...
@ Vector
'vector' clause, allowed on 'loop', Combined, and 'routine' directives.
TypeOfKind
The kind of 'typeof' expression we're after.
TypeDependence toTypeDependence(ExprDependence D)
ExprDependence turnValueToTypeDependence(ExprDependence D)
const StreamingDiagnostic & operator<<(const StreamingDiagnostic &DB, const ASTContext::SectionInfo &Section)
Insertion operator for diagnostics.
Linkage
Describes the different kinds of linkage (C++ [basic.link], C99 6.2.2) that an entity may have.
@ External
External linkage, which indicates that the entity can be referred to from other translation units.
ObjCSubstitutionContext
The kind of type we are substituting Objective-C type arguments into.
@ Superclass
The superclass of a type.
@ Result
The result type of a method or function.
ArraySizeModifier
Capture whether this is a normal array (e.g.
bool isComputedNoexcept(ExceptionSpecificationType ESpecType)
SubstTemplateTypeParmTypeFlag
TemplateParameterList * getReplacedTemplateParameterList(Decl *D)
Internal helper used by Subst* nodes to retrieve the parameter list for their AssociatedDecl.
TagTypeKind
The kind of a tag type.
@ Interface
The "__interface" keyword.
@ Struct
The "struct" keyword.
@ Class
The "class" keyword.
@ Union
The "union" keyword.
@ Enum
The "enum" keyword.
LangAS
Defines the address space values used by the address space qualifier of QualType.
void FixedPointValueToString(SmallVectorImpl< char > &Str, llvm::APSInt Val, unsigned Scale)
bool isPtrSizeAddressSpace(LangAS AS)
const FunctionProtoType * T
CallingConv
CallingConv - Specifies the calling convention that a function uses.
@ None
The alignment was not explicit in code.
ElaboratedTypeKeyword
The elaboration keyword that precedes a qualified type name or introduces an elaborated-type-specifie...
@ Interface
The "__interface" keyword introduces the elaborated-type-specifier.
@ None
No keyword precedes the qualified type name.
@ Struct
The "struct" keyword introduces the elaborated-type-specifier.
@ Class
The "class" keyword introduces the elaborated-type-specifier.
@ Union
The "union" keyword introduces the elaborated-type-specifier.
@ Enum
The "enum" keyword introduces the elaborated-type-specifier.
@ Typename
The "typename" keyword precedes the qualified type name, e.g., typename T::type.
TypeDependence toSemanticDependence(TypeDependence D)
TypeDependence toSyntacticDependence(TypeDependence D)
@ Other
Other implicit parameter.
@ EST_DependentNoexcept
noexcept(expression), value-dependent
@ EST_Uninstantiated
not instantiated yet
@ EST_Unparsed
not parsed yet
@ EST_NoThrow
Microsoft __declspec(nothrow) extension.
@ EST_None
no exception specification
@ EST_MSAny
Microsoft throw(...) extension.
@ EST_BasicNoexcept
noexcept
@ EST_NoexceptFalse
noexcept(expression), evals to 'false'
@ EST_Unevaluated
not evaluated yet, for special member function
@ EST_NoexceptTrue
noexcept(expression), evals to 'true'
@ EST_Dynamic
throw(T1, T2)
__UINTPTR_TYPE__ uintptr_t
An unsigned integer type with the property that any valid pointer to void can be converted to this ty...
A FunctionEffect plus a potential boolean expression determining whether the effect is declared (e....
std::string description() const
Return a textual description of the effect, and its condition, if any.
FunctionDecl * SourceDecl
The function whose exception specification this is, for EST_Unevaluated and EST_Uninstantiated.
FunctionDecl * SourceTemplate
The function template whose exception specification this is instantiated from, for EST_Uninstantiated...
ExceptionSpecificationType Type
The kind of exception specification this is.
ArrayRef< QualType > Exceptions
Explicitly-specified list of exception types.
Expr * NoexceptExpr
Noexcept expression, if this is a computed noexcept specification.
Extra information about a function prototype.
ExceptionSpecInfo ExceptionSpec
bool requiresFunctionProtoTypeArmAttributes() const
unsigned AArch64SMEAttributes
SourceLocation EllipsisLoc
FunctionEffectsRef FunctionEffects
const ExtParameterInfo * ExtParameterInfos
RefQualifierKind RefQualifier
unsigned HasTrailingReturn
bool requiresFunctionProtoTypeExtraBitfields() const
Describes how types, statements, expressions, and declarations should be printed.
unsigned Bool
Whether we can use 'bool' rather than '_Bool' (even if the language doesn't actually have 'bool',...
unsigned NullptrTypeInNamespace
Whether 'nullptr_t' is in namespace 'std' or not.
unsigned Half
When true, print the half-precision floating-point type as 'half' instead of '__fp16'.
unsigned MSWChar
When true, print the built-in wchar_t type as __wchar_t.
A std::pair-like structure for storing a qualified type split into its local qualifiers and its local...
const Type * Ty
The locally-unqualified type.
Qualifiers Quals
The local qualifiers.