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

99

100

104

105

107}

108

112 if (const auto *DNT = ty->getAs())

116 if (const auto *TT = ty->getAs())

117 ND = TT->getDecl();

118 else if (ty->getTypeClass() == Type::Typedef)

124

125 if (ND)

127 return nullptr;

128}

129

134

139

141 if (T.isConstQualified())

142 return true;

143

145 return AT->getElementType().isConstant(Ctx);

146

148}

149

150std::optionalQualType::NonConstantStorageReason

152 bool ExcludeDtor) {

153 if (isConstant(Ctx) && !(*this)->isReferenceType())

156 return std::nullopt;

159 if (!ExcludeCtor)

161 if (Record->hasMutableFields())

163 if (Record->hasTrivialDestructor() && !ExcludeDtor)

165 }

166 return std::nullopt;

167}

168

169

170

171

172

173

176

177

178

179

180

181

182 : Type(tc, can,

187 (tc == VariableArray ? TypeDependence::VariablyModified

189 (tc == DependentSizedArray

192 ElementType(et) {

194 ArrayTypeBits.SizeModifier = llvm::to_underlying(sm);

195}

196

199 const llvm::APInt &Sz, const Expr *SzExpr,

201 bool NeedsExternalSize = SzExpr != nullptr || Sz.ugt(0x0FFFFFFFFFFFFFFF) ||

202 Sz.getBitWidth() > 0xFF;

203 if (!NeedsExternalSize)

205 ET, Can, Sz.getBitWidth(), Sz.getZExtValue(), SzMod, Qual);

206

207 auto *SzPtr = new (Ctx, alignof(ConstantArrayType::ExternalSize))

208 ConstantArrayType::ExternalSize(Sz, SzExpr);

211}

212

213unsigned

216 const llvm::APInt &NumElements) {

217 uint64_t ElementSize = Context.getTypeSizeInChars(ElementType).getQuantity();

218

219

220

221

222

223

224

225 if (llvm::isPowerOf2_64(ElementSize)) {

226 return NumElements.getActiveBits() + llvm::Log2_64(ElementSize);

227 }

228

229

230

231 if ((ElementSize >> 32) == 0 && NumElements.getBitWidth() <= 64 &&

232 (NumElements.getZExtValue() >> 32) == 0) {

233 uint64_t TotalSize = NumElements.getZExtValue() * ElementSize;

234 return llvm::bit_width(TotalSize);

235 }

236

237

238 llvm::APSInt SizeExtended(NumElements, true);

239 unsigned SizeTypeBits = Context.getTypeSize(Context.getSizeType());

240 SizeExtended = SizeExtended.extend(

241 std::max(SizeTypeBits, SizeExtended.getBitWidth()) * 2);

242

243 llvm::APSInt TotalSize(llvm::APInt(SizeExtended.getBitWidth(), ElementSize));

244 TotalSize *= SizeExtended;

245

246 return TotalSize.getActiveBits();

247}

248

249unsigned

253

255 unsigned Bits = Context.getTypeSize(Context.getSizeType());

256

257

258

259

260 if (Bits > 61)

261 Bits = 61;

262

263 return Bits;

264}

265

268 uint64_t ArraySize, const Expr *SizeExpr,

271 ID.AddInteger(ArraySize);

272 ID.AddInteger(llvm::to_underlying(SizeMod));

273 ID.AddInteger(TypeQuals);

274 ID.AddBoolean(SizeExpr != nullptr);

275 if (SizeExpr)

276 SizeExpr->Profile(ID, Context, true);

277}

278

284

285DependentSizedArrayType::DependentSizedArrayType(QualType et, QualType can,

287 unsigned tq)

288 : ArrayType(DependentSizedArray, et, can, sm, tq, e), SizeExpr((Stmt *)e) {}

289

293 unsigned TypeQuals, Expr *E) {

295 ID.AddInteger(llvm::to_underlying(SizeMod));

296 ID.AddInteger(TypeQuals);

297 if (E)

298 E->Profile(ID, Context, true);

299}

300

301DependentVectorType::DependentVectorType(QualType ElementType,

304 : Type(DependentVector, CanonType,

306 ElementType->getDependence() |

309 ElementType(ElementType), SizeExpr(SizeExpr), Loc(Loc) {

310 VectorTypeBits.VecKind = llvm::to_underlying(VecKind);

311}

312

317 ID.AddPointer(ElementType.getAsOpaquePtr());

318 ID.AddInteger(llvm::to_underlying(VecKind));

319 SizeExpr->Profile(ID, Context, true);

320}

321

322DependentSizedExtVectorType::DependentSizedExtVectorType(QualType ElementType,

324 Expr *SizeExpr,

326 : Type(DependentSizedExtVector, can,

328 ElementType->getDependence() |

331 SizeExpr(SizeExpr), ElementType(ElementType), loc(loc) {}

332

336 Expr *SizeExpr) {

337 ID.AddPointer(ElementType.getAsOpaquePtr());

338 SizeExpr->Profile(ID, Context, true);

339}

340

341DependentAddressSpaceType::DependentAddressSpaceType(QualType PointeeType,

343 Expr *AddrSpaceExpr,

345 : Type(DependentAddressSpace, can,

347 PointeeType->getDependence() |

348 (AddrSpaceExpr ? toTypeDependence(AddrSpaceExpr->getDependence())

350 AddrSpaceExpr(AddrSpaceExpr), PointeeType(PointeeType), loc(loc) {}

351

355 Expr *AddrSpaceExpr) {

356 ID.AddPointer(PointeeType.getAsOpaquePtr());

357 AddrSpaceExpr->Profile(ID, Context, true);

358}

359

361 const Expr *RowExpr, const Expr *ColumnExpr)

362 : Type(tc, canonType,

369 (RowExpr &&

371 (ColumnExpr &&

377

379 unsigned nColumns, QualType canonType)

381 canonType) {}

382

384 unsigned nRows, unsigned nColumns,

388

389DependentSizedMatrixType::DependentSizedMatrixType(QualType ElementType,

391 Expr *RowExpr,

392 Expr *ColumnExpr,

394 : MatrixType(DependentSizedMatrix, ElementType, CanonicalType, RowExpr,

395 ColumnExpr),

396 RowExpr(RowExpr), ColumnExpr(ColumnExpr), loc(loc) {}

397

401 Expr *ColumnExpr) {

402 ID.AddPointer(ElementType.getAsOpaquePtr());

403 RowExpr->Profile(ID, CTX, true);

404 ColumnExpr->Profile(ID, CTX, true);

405}

406

410

417

423

427

431 ExprAndUnsigned(NumBitsExpr, IsUnsigned) {}

432

434 return ExprAndUnsigned.getInt();

435}

436

438 return ExprAndUnsigned.getPointer();

439}

440

442 const ASTContext &Context, bool IsUnsigned,

443 Expr *NumBitsExpr) {

444 ID.AddBoolean(IsUnsigned);

445 NumBitsExpr->Profile(ID, Context, true);

446}

447

454

457 bool CountInBytes, bool OrNull) {

458 ID.AddPointer(WrappedTy.getAsOpaquePtr());

459 ID.AddBoolean(CountInBytes);

460 ID.AddBoolean(OrNull);

461

462

463

464

465 ID.AddPointer(CountExpr);

466}

467

468

469

470

472

473 if (const auto *ATy = dyn_cast(this))

474 return ATy->getElementType().getTypePtr();

475

476

478 return nullptr;

479

480

481

483 ->getElementType()

484 .getTypePtr();

485}

486

487

488

489

490

491

492

496}

497

502 return Context.getQualifiedType(desugar, split.Quals);

503}

504

505

506

507

508#define TYPE(CLASS, BASE) \

509 static_assert(!std::is_polymorphic<CLASS##Type>::value, \

510 #CLASS "Type should not be polymorphic!");

511#include "clang/AST/TypeNodes.inc"

512

513

514

515

516#define TYPE(CLASS, BASE) \

517 static_assert(std::is_trivially_destructible<CLASS##Type>::value, \

518 #CLASS "Type should be trivially destructible!");

519#include "clang/AST/TypeNodes.inc"

520

523#define ABSTRACT_TYPE(Class, Parent)

524#define TYPE(Class, Parent) \

525 case Type::Class: { \

526 const auto *ty = cast<Class##Type>(this); \

527 if (!ty->isSugared()) \

528 return QualType(ty, 0); \

529 return ty->desugar(); \

530 }

531#include "clang/AST/TypeNodes.inc"

532 }

533 llvm_unreachable("bad type kind!");

534}

535

538

540 while (true) {

541 const Type *CurTy = Qs.strip(Cur);

543#define ABSTRACT_TYPE(Class, Parent)

544#define TYPE(Class, Parent) \

545 case Type::Class: { \

546 const auto *Ty = cast<Class##Type>(CurTy); \

547 if (!Ty->isSugared()) \

548 return SplitQualType(Ty, Qs); \

549 Cur = Ty->desugar(); \

550 break; \

551 }

552#include "clang/AST/TypeNodes.inc"

553 }

554 }

555}

556

558 SplitQualType split = type.split();

559

560

561 Qualifiers quals = split.Quals;

562

563

564 const Type *lastTypeWithQuals = split.Ty;

565

566 while (true) {

568

569

570

571 switch (split.Ty->getTypeClass()) {

572#define ABSTRACT_TYPE(Class, Parent)

573#define TYPE(Class, Parent) \

574 case Type::Class: { \

575 const auto *ty = cast<Class##Type>(split.Ty); \

576 if (!ty->isSugared()) \

577 goto done; \

578 next = ty->desugar(); \

579 break; \

580 }

581#include "clang/AST/TypeNodes.inc"

582 }

583

584

585

587 if (split.Quals.empty()) {

588 lastTypeWithQuals = split.Ty;

590 }

591 }

592

593done:

594 return SplitQualType(lastTypeWithQuals, quals);

595}

596

598

599 while (const auto *PT = T->getAs())

600 T = PT->getInnerType();

601 return T;

602}

603

604

605

606

608 while (true) {

609 if (const auto *Sugar = dyn_cast(Cur))

610 return Sugar;

612#define ABSTRACT_TYPE(Class, Parent)

613#define TYPE(Class, Parent) \

614 case Type::Class: { \

615 const auto *Ty = cast<Class##Type>(Cur); \

616 if (!Ty->isSugared()) \

617 return 0; \

618 Cur = Ty->desugar().getTypePtr(); \

619 break; \

620 }

621#include "clang/AST/TypeNodes.inc"

622 }

623 }

624}

625

629

633

634template <> const TemplateSpecializationType *Type::getAs() const {

636}

637

641

645

649

650

651

652

654 const Type *Cur = this;

655

656 while (true) {

658#define ABSTRACT_TYPE(Class, Parent)

659#define TYPE(Class, Parent) \

660 case Class: { \

661 const auto *Ty = cast<Class##Type>(Cur); \

662 if (!Ty->isSugared()) \

663 return Cur; \

664 Cur = Ty->desugar().getTypePtr(); \

665 break; \

666 }

667#include "clang/AST/TypeNodes.inc"

668 }

669 }

670}

671

674 return RT->getDecl()->isClass();

675 return false;

676}

677

680 return RT->getDecl()->isStruct();

681 return false;

682}

683

686 if (!RT)

687 return false;

688 const auto *Decl = RT->getDecl();

689 if (Decl->isStruct())

690 return false;

691 return Decl->getDefinitionOrSelf()->hasFlexibleArrayMember();

692}

693

696 return RD->hasAttr();

697 return false;

698}

699

702 return RT->getDecl()->isInterface();

703 return false;

704}

705

708 return RT->getDecl()->isStructureOrClass();

709 return false;

710}

711

714 return PT->getPointeeType()->isVoidType();

715 return false;

716}

717

720 return RT->getDecl()->isUnion();

721 return false;

722}

723

726 return CT->getElementType()->isFloatingType();

727 return false;

728}

729

734

737 return ET->getDecl()->isScoped();

738 return false;

739}

740

744

747 if (Complex->getElementType()->isIntegerType())

749 return nullptr;

750}

751

767

769

770 if (const auto *RT = dyn_cast(this)) {

771 if (RT->getDecl()->isStruct())

772 return RT;

773 }

774

775

776 if (const auto *RT = dyn_cast(CanonicalType)) {

777 if (!RT->getDecl()->isStruct())

778 return nullptr;

779

780

781

783 }

784 return nullptr;

785}

786

788

789 if (const auto *RT = dyn_cast(this)) {

790 if (RT->getDecl()->isUnion())

791 return RT;

792 }

793

794

795 if (const auto *RT = dyn_cast(CanonicalType)) {

796 if (!RT->getDecl()->isUnion())

797 return nullptr;

798

799

800

802 }

803

804 return nullptr;

805}

806

809 bound = nullptr;

810

812 if (!OPT)

813 return false;

814

815

816 if (OPT->isObjCIdType())

817 return true;

818

819

820 if (!OPT->isKindOfType())

821 return false;

822

823

824 if (OPT->isObjCClassType() || OPT->isObjCQualifiedClassType())

825 return false;

826

827

828 bound = OPT->getObjectType()

829 ->stripObjCKindOfTypeAndQuals(ctx)

831 return true;

832}

833

836 if (!OPT)

837 return false;

838

839

840 if (OPT->isObjCClassType())

841 return true;

842

843

844 if (!OPT->isKindOfType())

845 return false;

846

847

848 return OPT->isObjCClassType() || OPT->isObjCQualifiedClassType();

849}

850

856}

857

861 bool isKindOf)

862 : Type(ObjCObject, Canonical, Base->getDependence()), BaseType(Base) {

864

866 assert(getTypeArgsAsWritten().size() == typeArgs.size() &&

867 "bitfield overflow in type argument count");

868 if (!typeArgs.empty())

869 memcpy(getTypeArgStorage(), typeArgs.data(),

870 typeArgs.size() * sizeof(QualType));

871

872 for (auto typeArg : typeArgs) {

873 addDependence(typeArg->getDependence() & ~TypeDependence::VariablyModified);

874 }

875

876

878}

879

880bool ObjCObjectType::isSpecialized() const {

881

882 if (ObjCObjectTypeBits.NumTypeArgs > 0)

883 return true;

884

885

886 if (const auto objcObject = getBaseType()->getAs()) {

887

889 return false;

890

891 return objcObject->isSpecialized();

892 }

893

894

895 return false;

896}

897

899

900 if (isSpecializedAsWritten())

901 return getTypeArgsAsWritten();

902

903

904 if (const auto objcObject = getBaseType()->getAs()) {

905

907 return {};

908

909 return objcObject->getTypeArgs();

910 }

911

912

913 return {};

914}

915

916bool ObjCObjectType::isKindOfType() const {

917 if (isKindOfTypeAsWritten())

918 return true;

919

920

921 if (const auto objcObject = getBaseType()->getAs()) {

922

924 return false;

925

926 return objcObject->isKindOfType();

927 }

928

929

930 return false;

931}

932

934ObjCObjectType::stripObjCKindOfTypeAndQuals(const ASTContext &ctx) const {

935 if (!isKindOfType() && qual_empty())

937

938

940 QualType baseType(splitBaseType.Ty, 0);

941 if (const auto *baseObj = splitBaseType.Ty->getAs())

942 baseType = baseObj->stripObjCKindOfTypeAndQuals(ctx);

943

946 getTypeArgsAsWritten(),

947 {},

948 false);

949}

950

954 return Def;

955 return Canon;

956}

957

961 return this;

962

965}

966

967namespace {

968

969

970

971template

972struct SimpleTransformVisitor : public TypeVisitor<Derived, QualType> {

974

976

978

979

980 QualType result = static_cast<Derived *>(this)->Visit(splitType.Ty);

982 return result;

983

984

985

987 }

988

989public:

990 explicit SimpleTransformVisitor(ASTContext &ctx) : Ctx(ctx) {}

991

992

993

994#define TYPE(Class, Base)

995#define DEPENDENT_TYPE(Class, Base) \

996 QualType Visit##Class##Type(const Class##Type *T) { return QualType(T, 0); }

997#include "clang/AST/TypeNodes.inc"

998

999#define TRIVIAL_TYPE_CLASS(Class) \

1000 QualType Visit##Class##Type(const Class##Type *T) { return QualType(T, 0); }

1001#define SUGARED_TYPE_CLASS(Class) \

1002 QualType Visit##Class##Type(const Class##Type *T) { \

1003 if (!T->isSugared()) \

1004 return QualType(T, 0); \

1005 QualType desugaredType = recurse(T->desugar()); \

1006 if (desugaredType.isNull()) \

1007 return {}; \

1008 if (desugaredType.getAsOpaquePtr() == T->desugar().getAsOpaquePtr()) \

1009 return QualType(T, 0); \

1010 return desugaredType; \

1011 }

1012

1014

1016 QualType elementType = recurse(T->getElementType());

1017 if (elementType.isNull())

1018 return {};

1019

1020 if (elementType.getAsOpaquePtr() == T->getElementType().getAsOpaquePtr())

1022

1024 }

1025

1026 QualType VisitPointerType(const PointerType *T) {

1028 if (pointeeType.isNull())

1029 return {};

1030

1032 return QualType(T, 0);

1033

1035 }

1036

1037 QualType VisitBlockPointerType(const BlockPointerType *T) {

1039 if (pointeeType.isNull())

1040 return {};

1041

1043 return QualType(T, 0);

1044

1046 }

1047

1048 QualType VisitLValueReferenceType(const LValueReferenceType *T) {

1049 QualType pointeeType = recurse(T->getPointeeTypeAsWritten());

1050 if (pointeeType.isNull())

1051 return {};

1052

1054 T->getPointeeTypeAsWritten().getAsOpaquePtr())

1055 return QualType(T, 0);

1056

1058 }

1059

1060 QualType VisitRValueReferenceType(const RValueReferenceType *T) {

1061 QualType pointeeType = recurse(T->getPointeeTypeAsWritten());

1062 if (pointeeType.isNull())

1063 return {};

1064

1066 T->getPointeeTypeAsWritten().getAsOpaquePtr())

1067 return QualType(T, 0);

1068

1070 }

1071

1072 QualType VisitMemberPointerType(const MemberPointerType *T) {

1074 if (pointeeType.isNull())

1075 return {};

1076

1078 return QualType(T, 0);

1079

1081 T->getMostRecentCXXRecordDecl());

1082 }

1083

1084 QualType VisitConstantArrayType(const ConstantArrayType *T) {

1085 QualType elementType = recurse(T->getElementType());

1086 if (elementType.isNull())

1087 return {};

1088

1089 if (elementType.getAsOpaquePtr() == T->getElementType().getAsOpaquePtr())

1090 return QualType(T, 0);

1091

1093 T->getSizeModifier(),

1094 T->getIndexTypeCVRQualifiers());

1095 }

1096

1097 QualType VisitVariableArrayType(const VariableArrayType *T) {

1098 QualType elementType = recurse(T->getElementType());

1099 if (elementType.isNull())

1100 return {};

1101

1102 if (elementType.getAsOpaquePtr() == T->getElementType().getAsOpaquePtr())

1103 return QualType(T, 0);

1104

1106 T->getSizeModifier(),

1107 T->getIndexTypeCVRQualifiers());

1108 }

1109

1110 QualType VisitIncompleteArrayType(const IncompleteArrayType *T) {

1111 QualType elementType = recurse(T->getElementType());

1112 if (elementType.isNull())

1113 return {};

1114

1115 if (elementType.getAsOpaquePtr() == T->getElementType().getAsOpaquePtr())

1116 return QualType(T, 0);

1117

1119 T->getIndexTypeCVRQualifiers());

1120 }

1121

1122 QualType VisitVectorType(const VectorType *T) {

1123 QualType elementType = recurse(T->getElementType());

1124 if (elementType.isNull())

1125 return {};

1126

1127 if (elementType.getAsOpaquePtr() == T->getElementType().getAsOpaquePtr())

1128 return QualType(T, 0);

1129

1130 return Ctx.getVectorType(elementType, T->getNumElements(),

1131 T->getVectorKind());

1132 }

1133

1134 QualType VisitExtVectorType(const ExtVectorType *T) {

1135 QualType elementType = recurse(T->getElementType());

1136 if (elementType.isNull())

1137 return {};

1138

1139 if (elementType.getAsOpaquePtr() == T->getElementType().getAsOpaquePtr())

1140 return QualType(T, 0);

1141

1143 }

1144

1145 QualType VisitConstantMatrixType(const ConstantMatrixType *T) {

1146 QualType elementType = recurse(T->getElementType());

1147 if (elementType.isNull())

1148 return {};

1149 if (elementType.getAsOpaquePtr() == T->getElementType().getAsOpaquePtr())

1150 return QualType(T, 0);

1151

1153 T->getNumColumns());

1154 }

1155

1156 QualType VisitFunctionNoProtoType(const FunctionNoProtoType *T) {

1158 if (returnType.isNull())

1159 return {};

1160

1162 return QualType(T, 0);

1163

1165 }

1166

1167 QualType VisitFunctionProtoType(const FunctionProtoType *T) {

1169 if (returnType.isNull())

1170 return {};

1171

1172

1173 SmallVector<QualType, 4> paramTypes;

1174 bool paramChanged = false;

1176 QualType newParamType = recurse(paramType);

1177 if (newParamType.isNull())

1178 return {};

1179

1180 if (newParamType.getAsOpaquePtr() != paramType.getAsOpaquePtr())

1181 paramChanged = true;

1182

1183 paramTypes.push_back(newParamType);

1184 }

1185

1186

1187 FunctionProtoType::ExtProtoInfo info = T->getExtProtoInfo();

1188 bool exceptionChanged = false;

1190 SmallVector<QualType, 4> exceptionTypes;

1192 QualType newExceptionType = recurse(exceptionType);

1193 if (newExceptionType.isNull())

1194 return {};

1195

1196 if (newExceptionType.getAsOpaquePtr() != exceptionType.getAsOpaquePtr())

1197 exceptionChanged = true;

1198

1199 exceptionTypes.push_back(newExceptionType);

1200 }

1201

1202 if (exceptionChanged) {

1204 llvm::ArrayRef(exceptionTypes).copy(Ctx);

1205 }

1206 }

1207

1209 !paramChanged && !exceptionChanged)

1210 return QualType(T, 0);

1211

1212 return Ctx.getFunctionType(returnType, paramTypes, info);

1213 }

1214

1215 QualType VisitParenType(const ParenType *T) {

1216 QualType innerType = recurse(T->getInnerType());

1217 if (innerType.isNull())

1218 return {};

1219

1220 if (innerType.getAsOpaquePtr() == T->getInnerType().getAsOpaquePtr())

1221 return QualType(T, 0);

1222

1224 }

1225

1229

1230 QualType VisitAdjustedType(const AdjustedType *T) {

1231 QualType originalType = recurse(T->getOriginalType());

1232 if (originalType.isNull())

1233 return {};

1234

1235 QualType adjustedType = recurse(T->getAdjustedType());

1236 if (adjustedType.isNull())

1237 return {};

1238

1240 T->getOriginalType().getAsOpaquePtr() &&

1241 adjustedType.getAsOpaquePtr() == T->getAdjustedType().getAsOpaquePtr())

1242 return QualType(T, 0);

1243

1245 }

1246

1247 QualType VisitDecayedType(const DecayedType *T) {

1248 QualType originalType = recurse(T->getOriginalType());

1249 if (originalType.isNull())

1250 return {};

1251

1252 if (originalType.getAsOpaquePtr() == T->getOriginalType().getAsOpaquePtr())

1253 return QualType(T, 0);

1254

1256 }

1257

1258 QualType VisitArrayParameterType(const ArrayParameterType *T) {

1259 QualType ArrTy = VisitConstantArrayType(T);

1261 return {};

1262

1264 }

1265

1272

1273 QualType VisitAttributedType(const AttributedType *T) {

1274 QualType modifiedType = recurse(T->getModifiedType());

1275 if (modifiedType.isNull())

1276 return {};

1277

1278 QualType equivalentType = recurse(T->getEquivalentType());

1279 if (equivalentType.isNull())

1280 return {};

1281

1283 T->getModifiedType().getAsOpaquePtr() &&

1285 T->getEquivalentType().getAsOpaquePtr())

1286 return QualType(T, 0);

1287

1288 return Ctx.getAttributedType(T->getAttrKind(), modifiedType, equivalentType,

1289 T->getAttr());

1290 }

1291

1292 QualType VisitSubstTemplateTypeParmType(const SubstTemplateTypeParmType *T) {

1293 QualType replacementType = recurse(T->getReplacementType());

1294 if (replacementType.isNull())

1295 return {};

1296

1298 T->getReplacementType().getAsOpaquePtr())

1299 return QualType(T, 0);

1300

1302 replacementType, T->getAssociatedDecl(), T->getIndex(),

1303 T->getPackIndex(), T->getFinal());

1304 }

1305

1306

1308

1309 QualType VisitAutoType(const AutoType *T) {

1310 if (T->isDeduced())

1311 return QualType(T, 0);

1312

1313 QualType deducedType = recurse(T->getDeducedType());

1314 if (deducedType.isNull())

1315 return {};

1316

1317 if (deducedType.getAsOpaquePtr() == T->getDeducedType().getAsOpaquePtr())

1318 return QualType(T, 0);

1319

1321 false, T->getTypeConstraintConcept(),

1322 T->getTypeConstraintArguments());

1323 }

1324

1325 QualType VisitObjCObjectType(const ObjCObjectType *T) {

1326 QualType baseType = recurse(T->getBaseType());

1327 if (baseType.isNull())

1328 return {};

1329

1330

1331 bool typeArgChanged = false;

1332 SmallVector<QualType, 4> typeArgs;

1333 for (auto typeArg : T->getTypeArgsAsWritten()) {

1334 QualType newTypeArg = recurse(typeArg);

1335 if (newTypeArg.isNull())

1336 return {};

1337

1338 if (newTypeArg.getAsOpaquePtr() != typeArg.getAsOpaquePtr())

1339 typeArgChanged = true;

1340

1341 typeArgs.push_back(newTypeArg);

1342 }

1343

1344 if (baseType.getAsOpaquePtr() == T->getBaseType().getAsOpaquePtr() &&

1345 !typeArgChanged)

1346 return QualType(T, 0);

1347

1349 baseType, typeArgs,

1350 llvm::ArrayRef(T->qual_begin(), T->getNumProtocols()),

1351 T->isKindOfTypeAsWritten());

1352 }

1353

1355

1356 QualType VisitObjCObjectPointerType(const ObjCObjectPointerType *T) {

1358 if (pointeeType.isNull())

1359 return {};

1360

1362 return QualType(T, 0);

1363

1365 }

1366

1367 QualType VisitAtomicType(const AtomicType *T) {

1368 QualType valueType = recurse(T->getValueType());

1369 if (valueType.isNull())

1370 return {};

1371

1372 if (valueType.getAsOpaquePtr() == T->getValueType().getAsOpaquePtr())

1373 return QualType(T, 0);

1374

1376 }

1377

1378#undef TRIVIAL_TYPE_CLASS

1379#undef SUGARED_TYPE_CLASS

1380};

1381

1382struct SubstObjCTypeArgsVisitor

1383 : public SimpleTransformVisitor {

1384 using BaseType = SimpleTransformVisitor;

1385

1386 ArrayRef TypeArgs;

1388

1389 SubstObjCTypeArgsVisitor(ASTContext &ctx, ArrayRef typeArgs,

1391 : BaseType(ctx), TypeArgs(typeArgs), SubstContext(context) {}

1392

1393 QualType VisitObjCTypeParamType(const ObjCTypeParamType *OTPTy) {

1394

1395

1396 ObjCTypeParamDecl *typeParam = OTPTy->getDecl();

1397

1398 if (!TypeArgs.empty()) {

1399 QualType argType = TypeArgs[typeParam->getIndex()];

1400 if (OTPTy->qual_empty())

1401 return argType;

1402

1403

1404 bool hasError;

1405 SmallVector<ObjCProtocolDecl *, 8> protocolsVec;

1406 protocolsVec.append(OTPTy->qual_begin(), OTPTy->qual_end());

1407 ArrayRef<ObjCProtocolDecl *> protocolsToApply = protocolsVec;

1409 argType, protocolsToApply, hasError, true );

1410 }

1411

1412 switch (SubstContext) {

1413 case ObjCSubstitutionContext::Ordinary:

1414 case ObjCSubstitutionContext::Parameter:

1415 case ObjCSubstitutionContext::Superclass:

1416

1418

1419 case ObjCSubstitutionContext::Result:

1420 case ObjCSubstitutionContext::Property: {

1421

1422 const auto *objPtr =

1424

1425

1426

1427 if (objPtr->isKindOfType() || objPtr->isObjCIdOrClassType())

1429

1430

1431 const auto *obj = objPtr->getObjectType();

1433 obj->getBaseType(), obj->getTypeArgsAsWritten(), obj->getProtocols(),

1434 true);

1435

1436

1438 }

1439 }

1440 llvm_unreachable("Unexpected ObjCSubstitutionContext!");

1441 }

1442

1443 QualType VisitFunctionType(const FunctionType *funcType) {

1444

1445

1446

1447

1449 Ctx, TypeArgs, ObjCSubstitutionContext::Result);

1450 if (returnType.isNull())

1451 return {};

1452

1453

1454

1456

1459 return BaseType::VisitFunctionType(funcType);

1460

1461

1463 }

1464

1466

1467

1468 SmallVector<QualType, 4> paramTypes;

1469 bool paramChanged = false;

1470 for (auto paramType : funcProtoType->getParamTypes()) {

1472 Ctx, TypeArgs, ObjCSubstitutionContext::Parameter);

1473 if (newParamType.isNull())

1474 return {};

1475

1476 if (newParamType.getAsOpaquePtr() != paramType.getAsOpaquePtr())

1477 paramChanged = true;

1478

1479 paramTypes.push_back(newParamType);

1480 }

1481

1482

1483 FunctionProtoType::ExtProtoInfo info = funcProtoType->getExtProtoInfo();

1484 bool exceptionChanged = false;

1486 SmallVector<QualType, 4> exceptionTypes;

1489 Ctx, TypeArgs, ObjCSubstitutionContext::Ordinary);

1490 if (newExceptionType.isNull())

1491 return {};

1492

1493 if (newExceptionType.getAsOpaquePtr() != exceptionType.getAsOpaquePtr())

1494 exceptionChanged = true;

1495

1496 exceptionTypes.push_back(newExceptionType);

1497 }

1498

1499 if (exceptionChanged) {

1501 llvm::ArrayRef(exceptionTypes).copy(Ctx);

1502 }

1503 }

1504

1506 funcProtoType->getReturnType().getAsOpaquePtr() &&

1507 !paramChanged && !exceptionChanged)

1508 return BaseType::VisitFunctionType(funcType);

1509

1510 return Ctx.getFunctionType(returnType, paramTypes, info);

1511 }

1512

1513 QualType VisitObjCObjectType(const ObjCObjectType *objcObjectType) {

1514

1515

1516 if (objcObjectType->isSpecializedAsWritten()) {

1517 SmallVector<QualType, 4> newTypeArgs;

1518 bool anyChanged = false;

1519 for (auto typeArg : objcObjectType->getTypeArgsAsWritten()) {

1521 Ctx, TypeArgs, ObjCSubstitutionContext::Ordinary);

1522 if (newTypeArg.isNull())

1523 return {};

1524

1525 if (newTypeArg.getAsOpaquePtr() != typeArg.getAsOpaquePtr()) {

1526

1527

1528 ArrayRef<ObjCProtocolDecl *> protocols(

1529 objcObjectType->qual_begin(), objcObjectType->getNumProtocols());

1530 if (TypeArgs.empty() &&

1531 SubstContext != ObjCSubstitutionContext::Superclass) {

1533 objcObjectType->getBaseType(), {}, protocols,

1534 objcObjectType->isKindOfTypeAsWritten());

1535 }

1536

1537 anyChanged = true;

1538 }

1539

1540 newTypeArgs.push_back(newTypeArg);

1541 }

1542

1543 if (anyChanged) {

1544 ArrayRef<ObjCProtocolDecl *> protocols(

1545 objcObjectType->qual_begin(), objcObjectType->getNumProtocols());

1546 return Ctx.getObjCObjectType(objcObjectType->getBaseType(), newTypeArgs,

1547 protocols,

1548 objcObjectType->isKindOfTypeAsWritten());

1549 }

1550 }

1551

1552 return BaseType::VisitObjCObjectType(objcObjectType);

1553 }

1554

1555 QualType VisitAttributedType(const AttributedType *attrType) {

1556 QualType newType = BaseType::VisitAttributedType(attrType);

1557 if (newType.isNull())

1558 return {};

1559

1560 const auto *newAttrType = dyn_cast(newType.getTypePtr());

1561 if (!newAttrType || newAttrType->getAttrKind() != attr::ObjCKindOf)

1562 return newType;

1563

1564

1565 QualType newEquivType = newAttrType->getEquivalentType();

1566 const ObjCObjectPointerType *ptrType =

1567 newEquivType->getAs();

1568 const ObjCObjectType *objType = ptrType

1570 : newEquivType->getAs();

1571 if (!objType)

1572 return newType;

1573

1574

1575

1577 objType->getBaseType(), objType->getTypeArgsAsWritten(),

1578 objType->getProtocols(),

1579

1580 objType->isObjCUnqualifiedId() ? false : true);

1581

1582

1583 if (ptrType)

1585

1586

1588 newAttrType->getModifiedType(), newEquivType,

1589 newAttrType->getAttr());

1590 }

1591};

1592

1593struct StripObjCKindOfTypeVisitor

1594 : public SimpleTransformVisitor {

1595 using BaseType = SimpleTransformVisitor;

1596

1597 explicit StripObjCKindOfTypeVisitor(ASTContext &ctx) : BaseType(ctx) {}

1598

1599 QualType VisitObjCObjectType(const ObjCObjectType *objType) {

1600 if (!objType->isKindOfType())

1601 return BaseType::VisitObjCObjectType(objType);

1602

1603 QualType baseType = objType->getBaseType().stripObjCKindOfType(Ctx);

1604 return Ctx.getObjCObjectType(baseType, objType->getTypeArgsAsWritten(),

1605 objType->getProtocols(),

1606 false);

1607 }

1608};

1609

1610}

1611

1614 if (!BT) {

1616 if (VT) {

1619 }

1620 } else {

1621 switch (BT->getKind()) {

1622 case BuiltinType::Kind::Float16: {

1625 Ctx.getLangOpts().getFloat16ExcessPrecision() !=

1626 Ctx.getLangOpts().ExcessPrecisionKind::FPP_None)

1627 return true;

1628 break;

1629 }

1630 case BuiltinType::Kind::BFloat16: {

1633 Ctx.getLangOpts().getBFloat16ExcessPrecision() !=

1634 Ctx.getLangOpts().ExcessPrecisionKind::FPP_None)

1635 return true;

1636 break;

1637 }

1638 default:

1639 return false;

1640 }

1641 }

1642 return false;

1643}

1644

1645

1646

1650 SubstObjCTypeArgsVisitor visitor(ctx, typeArgs, context);

1651 return visitor.recurse(*this);

1652}

1653

1659

1660 return *this;

1661}

1662

1664

1665 auto &ctx = const_cast<ASTContext &>(constCtx);

1666 StripObjCKindOfTypeVisitor visitor(ctx);

1667 return visitor.recurse(*this);

1668}

1669

1672 if (const auto AT = T.getTypePtr()->getAs<AtomicType>())

1673 T = AT->getValueType();

1674 return T.getUnqualifiedType();

1675}

1676

1677std::optional<ArrayRef>

1679

1680 if (const auto method = dyn_cast(dc))

1681 dc = method->getDeclContext();

1682

1683

1684

1685 const auto *dcClassDecl = dyn_cast(dc);

1688 if (dcClassDecl) {

1689

1690

1691 dcTypeParams = dcClassDecl->getTypeParamList();

1692 if (!dcTypeParams)

1693 return std::nullopt;

1694 } else {

1695

1696

1697 dcCategoryDecl = dyn_cast(dc);

1698 if (!dcCategoryDecl)

1699 return std::nullopt;

1700

1701

1702

1704 if (!dcTypeParams)

1705 return std::nullopt;

1706

1708 if (!dcClassDecl)

1709 return std::nullopt;

1710 }

1711 assert(dcTypeParams && "No substitutions to perform");

1712 assert(dcClassDecl && "No class context");

1713

1714

1717 objectType = objectPointerType->getObjectType();

1722 } else {

1724 }

1725

1726

1728 objectType ? objectType->getInterface() : nullptr;

1729 if (!curClassDecl) {

1730

1731

1733 }

1734

1735

1736

1737 while (curClassDecl != dcClassDecl) {

1738

1739 QualType superType = objectType->getSuperClassType();

1740 if (superType.isNull()) {

1741 objectType = nullptr;

1742 break;

1743 }

1744

1746 curClassDecl = objectType->getInterface();

1747 }

1748

1749

1750

1751 if (!objectType || objectType->isUnspecialized()) {

1753 }

1754

1755

1756 return objectType->getTypeArgs();

1757}

1758

1761 if (auto *ID = IfaceT->getInterface()) {

1762 if (ID->getTypeParamList())

1763 return true;

1764 }

1765 }

1766

1767 return false;

1768}

1769

1770void ObjCObjectType::computeSuperClassTypeSlow() const {

1771

1772

1773

1775 if (!classDecl) {

1776 CachedSuperClassType.setInt(true);

1777 return;

1778 }

1779

1780

1782 if (!superClassObjTy) {

1783 CachedSuperClassType.setInt(true);

1784 return;

1785 }

1786

1787 ObjCInterfaceDecl *superClassDecl = superClassObjTy->getInterface();

1788 if (!superClassDecl) {

1789 CachedSuperClassType.setInt(true);

1790 return;

1791 }

1792

1793

1794

1795 QualType superClassType(superClassObjTy, 0);

1797 if (!superClassTypeParams) {

1798 CachedSuperClassType.setPointerAndInt(

1799 superClassType->castAs(), true);

1800 return;

1801 }

1802

1803

1804 if (superClassObjTy->isUnspecialized()) {

1805 CachedSuperClassType.setPointerAndInt(superClassObjTy, true);

1806 return;

1807 }

1808

1809

1810

1812 if (!typeParams) {

1813 CachedSuperClassType.setPointerAndInt(

1814 superClassType->castAs(), true);

1815 return;

1816 }

1817

1818

1819

1820 if (isUnspecialized()) {

1821 QualType unspecializedSuper =

1823 superClassObjTy->getInterface());

1824 CachedSuperClassType.setPointerAndInt(

1825 unspecializedSuper->castAs(), true);

1826 return;

1827 }

1828

1829

1831 assert(typeArgs.size() == typeParams->size());

1832 CachedSuperClassType.setPointerAndInt(

1833 superClassType

1834 .substObjCTypeArgs(classDecl->getASTContext(), typeArgs,

1836 ->castAs(),

1837 true);

1838}

1839

1841 if (auto interfaceDecl = getObjectType()->getInterface()) {

1842 return interfaceDecl->getASTContext()

1843 .getObjCInterfaceType(interfaceDecl)

1845 }

1846

1847 return nullptr;

1848}

1849

1852 if (superObjectType.isNull())

1853 return superObjectType;

1854

1857}

1858

1860

1861

1862

1864 if (T->getNumProtocols() && T->getInterface())

1865 return T;

1866 return nullptr;

1867}

1868

1872

1874

1875

1877 if (OPT->isObjCQualifiedIdType())

1878 return OPT;

1879 }

1880 return nullptr;

1881}

1882

1884

1885

1887 if (OPT->isObjCQualifiedClassType())

1888 return OPT;

1889 }

1890 return nullptr;

1891}

1892

1895 if (OT->getInterface())

1896 return OT;

1897 }

1898 return nullptr;

1899}

1900

1903 if (OPT->getInterfaceType())

1904 return OPT;

1905 }

1906 return nullptr;

1907}

1908

1915 else

1916 return nullptr;

1918}

1919

1920const TemplateSpecializationType *

1923 while (TST && TST->isTypeAlias())

1924 TST = TST->desugar()->getAs();

1925 return TST;

1926}

1927

1930 case Type::DependentName:

1932 case Type::TemplateSpecialization:

1934 ->getTemplateName()

1935 .getQualifier();

1936 case Type::Enum:

1937 case Type::Record:

1938 case Type::InjectedClassName:

1940 case Type::Typedef:

1942 case Type::UnresolvedUsing:

1944 case Type::Using:

1946 default:

1947 return std::nullopt;

1948 }

1949}

1950

1952 const Type *Cur = this;

1953 while (const auto *AT = Cur->getAs()) {

1954 if (AT->getAttrKind() == AK)

1955 return true;

1956 Cur = AT->getEquivalentType().getTypePtr();

1957 }

1958 return false;

1959}

1960

1961namespace {

1962

1963class GetContainedDeducedTypeVisitor

1964 : public TypeVisitor<GetContainedDeducedTypeVisitor, Type *> {

1965 bool Syntactic;

1966

1967public:

1968 GetContainedDeducedTypeVisitor(bool Syntactic = false)

1969 : Syntactic(Syntactic) {}

1970

1971 using TypeVisitor<GetContainedDeducedTypeVisitor, Type *>::Visit;

1972

1974 if (T.isNull())

1975 return nullptr;

1976 return Visit(T.getTypePtr());

1977 }

1978

1979

1980 Type *VisitDeducedType(const DeducedType *AT) {

1981 return const_cast<DeducedType *>(AT);

1982 }

1983

1984

1985 Type *VisitSubstTemplateTypeParmType(const SubstTemplateTypeParmType *T) {

1986 return Visit(T->getReplacementType());

1987 }

1988

1989 Type *VisitPointerType(const PointerType *T) {

1991 }

1992

1993 Type *VisitBlockPointerType(const BlockPointerType *T) {

1995 }

1996

1997 Type *VisitReferenceType(const ReferenceType *T) {

1998 return Visit(T->getPointeeTypeAsWritten());

1999 }

2000

2001 Type *VisitMemberPointerType(const MemberPointerType *T) {

2003 }

2004

2005 Type *VisitArrayType(const ArrayType *T) {

2006 return Visit(T->getElementType());

2007 }

2008

2009 Type *VisitDependentSizedExtVectorType(const DependentSizedExtVectorType *T) {

2010 return Visit(T->getElementType());

2011 }

2012

2013 Type *VisitVectorType(const VectorType *T) {

2014 return Visit(T->getElementType());

2015 }

2016

2017 Type *VisitDependentSizedMatrixType(const DependentSizedMatrixType *T) {

2018 return Visit(T->getElementType());

2019 }

2020

2021 Type *VisitConstantMatrixType(const ConstantMatrixType *T) {

2022 return Visit(T->getElementType());

2023 }

2024

2025 Type *VisitFunctionProtoType(const FunctionProtoType *T) {

2027 return const_cast<FunctionProtoType *>(T);

2028 return VisitFunctionType(T);

2029 }

2030

2031 Type *VisitFunctionType(const FunctionType *T) {

2033 }

2034

2035 Type *VisitParenType(const ParenType *T) { return Visit(T->getInnerType()); }

2036

2037 Type *VisitAttributedType(const AttributedType *T) {

2038 return Visit(T->getModifiedType());

2039 }

2040

2041 Type *VisitMacroQualifiedType(const MacroQualifiedType *T) {

2042 return Visit(T->getUnderlyingType());

2043 }

2044

2045 Type *VisitAdjustedType(const AdjustedType *T) {

2046 return Visit(T->getOriginalType());

2047 }

2048

2049 Type *VisitPackExpansionType(const PackExpansionType *T) {

2050 return Visit(T->getPattern());

2051 }

2052};

2053

2054}

2055

2057 return cast_or_null(

2058 GetContainedDeducedTypeVisitor().Visit(this));

2059}

2060

2062 return isa_and_nonnull(

2063 GetContainedDeducedTypeVisitor(true).Visit(this));

2064}

2065

2067 if (const auto *VT = dyn_cast(CanonicalType))

2068 return VT->getElementType()->isIntegerType();

2069 if (CanonicalType->isSveVLSBuiltinType()) {

2071 return VT->getKind() == BuiltinType::SveBool ||

2072 (VT->getKind() >= BuiltinType::SveInt8 &&

2073 VT->getKind() <= BuiltinType::SveUint64);

2074 }

2075 if (CanonicalType->isRVVVLSBuiltinType()) {

2077 return (VT->getKind() >= BuiltinType::RvvInt8mf8 &&

2078 VT->getKind() <= BuiltinType::RvvUint64m8);

2079 }

2080

2082}

2083

2084

2085

2086

2087

2088

2089

2090

2091

2092

2093

2094

2095

2096

2097

2098

2099

2100

2101

2102

2104 if (const auto *BT = dyn_cast(CanonicalType))

2105 return BT->isInteger();

2106

2107

2109 if (const auto *ET = dyn_cast(CanonicalType))

2111

2113}

2114

2116 if (const auto *BT = dyn_cast(CanonicalType))

2117 return BT->isInteger();

2118

2120 return true;

2121

2123}

2124

2126 if (const auto *ET = dyn_cast(CanonicalType))

2127 return !ET->getDecl()->isScoped();

2128

2129 return false;

2130}

2131

2133 if (const auto *BT = dyn_cast(CanonicalType))

2134 return BT->getKind() == BuiltinType::Char_U ||

2135 BT->getKind() == BuiltinType::UChar ||

2136 BT->getKind() == BuiltinType::Char_S ||

2137 BT->getKind() == BuiltinType::SChar;

2138 return false;

2139}

2140

2142 if (const auto *BT = dyn_cast(CanonicalType))

2143 return BT->getKind() == BuiltinType::WChar_S ||

2144 BT->getKind() == BuiltinType::WChar_U;

2145 return false;

2146}

2147

2149 if (const BuiltinType *BT = dyn_cast(CanonicalType))

2150 return BT->getKind() == BuiltinType::Char8;

2151 return false;

2152}

2153

2155 if (const auto *BT = dyn_cast(CanonicalType))

2156 return BT->getKind() == BuiltinType::Char16;

2157 return false;

2158}

2159

2161 if (const auto *BT = dyn_cast(CanonicalType))

2162 return BT->getKind() == BuiltinType::Char32;

2163 return false;

2164}

2165

2166

2167

2169 const auto *BT = dyn_cast(CanonicalType);

2170 if (!BT)

2171 return false;

2172 switch (BT->getKind()) {

2173 default:

2174 return false;

2175 case BuiltinType::Char_U:

2176 case BuiltinType::UChar:

2177 case BuiltinType::WChar_U:

2178 case BuiltinType::Char8:

2179 case BuiltinType::Char16:

2180 case BuiltinType::Char32:

2181 case BuiltinType::Char_S:

2182 case BuiltinType::SChar:

2183 case BuiltinType::WChar_S:

2184 return true;

2185 }

2186}

2187

2189 const auto *BT = dyn_cast(CanonicalType);

2190 if (!BT)

2191 return false;

2192 switch (BT->getKind()) {

2193 default:

2194 return false;

2195 case BuiltinType::Char8:

2196 case BuiltinType::Char16:

2197 case BuiltinType::Char32:

2198 return true;

2199 }

2200}

2201

2202

2203

2204

2206 if (const auto *BT = dyn_cast(CanonicalType))

2207 return BT->isSignedInteger();

2208

2210

2211

2212 if (!ED->isComplete() || ED->isScoped())

2213 return false;

2214 return ED->getIntegerType()->isSignedIntegerType();

2215 }

2216

2217 if (const auto *IT = dyn_cast(CanonicalType))

2218 return IT->isSigned();

2219 if (const auto *IT = dyn_cast(CanonicalType))

2220 return IT->isSigned();

2221

2222 return false;

2223}

2224

2226 if (const auto *BT = dyn_cast(CanonicalType))

2227 return BT->isSignedInteger();

2228

2230 if (!ED->isComplete())

2231 return false;

2232 return ED->getIntegerType()->isSignedIntegerType();

2233 }

2234

2235 if (const auto *IT = dyn_cast(CanonicalType))

2236 return IT->isSigned();

2237 if (const auto *IT = dyn_cast(CanonicalType))

2238 return IT->isSigned();

2239

2240 return false;

2241}

2242

2244 if (const auto *VT = dyn_cast(CanonicalType))

2245 return VT->getElementType()->isSignedIntegerOrEnumerationType();

2246 else

2248}

2249

2250

2251

2252

2254 if (const auto *BT = dyn_cast(CanonicalType))

2255 return BT->isUnsignedInteger();

2256

2258

2259

2260 if (!ED->isComplete() || ED->isScoped())

2261 return false;

2262 return ED->getIntegerType()->isUnsignedIntegerType();

2263 }

2264

2265 if (const auto *IT = dyn_cast(CanonicalType))

2266 return IT->isUnsigned();

2267 if (const auto *IT = dyn_cast(CanonicalType))

2268 return IT->isUnsigned();

2269

2270 return false;

2271}

2272

2274 if (const auto *BT = dyn_cast(CanonicalType))

2275 return BT->isUnsignedInteger();

2276

2278 if (!ED->isComplete())

2279 return false;

2280 return ED->getIntegerType()->isUnsignedIntegerType();

2281 }

2282

2283 if (const auto *IT = dyn_cast(CanonicalType))

2284 return IT->isUnsigned();

2285 if (const auto *IT = dyn_cast(CanonicalType))

2286 return IT->isUnsigned();

2287

2288 return false;

2289}

2290

2292 if (const auto *VT = dyn_cast(CanonicalType))

2293 return VT->getElementType()->isUnsignedIntegerOrEnumerationType();

2294 if (const auto *VT = dyn_cast(CanonicalType))

2295 return VT->getElementType()->isUnsignedIntegerOrEnumerationType();

2296 if (CanonicalType->isSveVLSBuiltinType()) {

2298 return VT->getKind() >= BuiltinType::SveUint8 &&

2299 VT->getKind() <= BuiltinType::SveUint64;

2300 }

2302}

2303

2305 if (const auto *BT = dyn_cast(CanonicalType))

2306 return BT->isFloatingPoint();

2307 if (const auto *CT = dyn_cast(CanonicalType))

2308 return CT->getElementType()->isFloatingType();

2309 return false;

2310}

2311

2313 if (const auto *VT = dyn_cast(CanonicalType))

2314 return VT->getElementType()->isFloatingType();

2315 if (const auto *MT = dyn_cast(CanonicalType))

2316 return MT->getElementType()->isFloatingType();

2318}

2319

2321 if (const auto *BT = dyn_cast(CanonicalType))

2322 return BT->isFloatingPoint();

2323 return false;

2324}

2325

2327 if (const auto *BT = dyn_cast(CanonicalType))

2328 return BT->getKind() >= BuiltinType::Bool &&

2329 BT->getKind() <= BuiltinType::Ibm128;

2330 if (const auto *ET = dyn_cast(CanonicalType)) {

2331 const auto *ED = ET->getDecl();

2332 return !ED->isScoped() && ED->getDefinitionOrSelf()->isComplete();

2333 }

2335}

2336

2338 if (const auto *BT = dyn_cast(CanonicalType))

2339 return BT->getKind() >= BuiltinType::Bool &&

2340 BT->getKind() <= BuiltinType::Ibm128;

2341 if (const auto *ET = dyn_cast(CanonicalType)) {

2342

2343

2344

2345

2346

2347

2348 const auto *ED = ET->getDecl();

2349 return !ED->isScoped() && ED->getDefinitionOrSelf()->isComplete();

2350 }

2352}

2353

2355 if (const auto *VT = dyn_cast(CanonicalType))

2356 return VT->getElementType()->isBooleanType();

2358 return ED->isComplete() && ED->getIntegerType()->isBooleanType();

2359 if (const auto *IT = dyn_cast(CanonicalType))

2360 return IT->getNumBits() == 1;

2362}

2363

2366

2367 const Type *T = CanonicalType.getTypePtr();

2368 if (const auto *BT = dyn_cast(T)) {

2369 if (BT->getKind() == BuiltinType::Bool)

2371 if (BT->getKind() == BuiltinType::NullPtr)

2373 if (BT->isInteger())

2375 if (BT->isFloatingPoint())

2377 if (BT->isFixedPointType())

2379 llvm_unreachable("unknown scalar builtin type");

2389 assert(T->castAsEnumDecl()->isComplete());

2391 } else if (const auto *CT = dyn_cast(T)) {

2392 if (CT->getElementType()->isRealFloatingType())

2397 }

2398

2399 llvm_unreachable("unknown scalar type");

2400}

2401

2402

2403

2404

2405

2406

2407

2408

2409

2410

2412 if (const auto *Record = dyn_cast(CanonicalType)) {

2413 if (const auto *ClassDecl = dyn_cast(Record->getDecl()))

2414 return ClassDecl->isAggregate();

2415

2416 return true;

2417 }

2418

2420}

2421

2422

2423

2424

2426 assert(isIncompleteType() && "This doesn't make sense for incomplete types");

2427 assert(isDependentType() && "This doesn't make sense for dependent types");

2428

2430}

2431

2432

2433

2434

2436 if (Def)

2437 *Def = nullptr;

2438

2439 switch (CanonicalType->getTypeClass()) {

2440 default:

2441 return false;

2443

2444

2446 case Enum: {

2448 if (Def)

2449 *Def = EnumD;

2450 return !EnumD->isComplete();

2451 }

2453

2454

2456 if (Def)

2457 *Def = Rec;

2458 return !Rec->isCompleteDefinition();

2459 }

2460 case InjectedClassName: {

2462 if (!Rec->isBeingDefined())

2463 return false;

2464 if (Def)

2465 *Def = Rec;

2466 return true;

2467 }

2468 case ConstantArray:

2469 case VariableArray:

2470

2471

2472

2473

2475 ->getElementType()

2476 ->isIncompleteType(Def);

2477 case IncompleteArray:

2478

2479 return true;

2480 case MemberPointer: {

2481

2482

2483

2484

2485

2488

2490 return false;

2492

2493 if (!Context.getTargetInfo().getCXXABI().isMicrosoft())

2494 return false;

2495

2496 if (RD->hasAttr())

2497 return false;

2498 return true;

2499 }

2500 case ObjCObject:

2502 ->getBaseType()

2503 ->isIncompleteType(Def);

2504 case ObjCInterface: {

2505

2508 if (Def)

2510 return Interface->hasDefinition();

2511 }

2512 }

2513}

2514

2517 return false;

2518

2519

2520

2522 return false;

2523

2524

2525

2526

2527

2528 return true;

2529}

2530

2533 return true;

2534

2536 switch (BT->getKind()) {

2537

2538#define WASM_TYPE(Name, Id, SingletonId) case BuiltinType::Id:

2539#include "clang/Basic/WebAssemblyReferenceTypes.def"

2540

2541#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) case BuiltinType::Id:

2542#include "clang/Basic/HLSLIntangibleTypes.def"

2543 return true;

2544 default:

2545 return false;

2546 }

2547 }

2548 return false;

2549}

2550

2553 return BT->getKind() == BuiltinType::WasmExternRef;

2554 return false;

2555}

2556

2558 if (const auto *ATy = dyn_cast(this))

2559 return ATy->getElementType().isWebAssemblyReferenceType();

2560

2561 if (const auto *PTy = dyn_cast(this))

2562 return PTy->getPointeeType().isWebAssemblyReferenceType();

2563

2564 return false;

2565}

2566

2568

2572

2575 switch (BT->getKind()) {

2576

2577#define SVE_VECTOR_TYPE(Name, MangledName, Id, SingletonId) \

2578 case BuiltinType::Id: \

2579 return true;

2580#define SVE_OPAQUE_TYPE(Name, MangledName, Id, SingletonId) \

2581 case BuiltinType::Id: \

2582 return true;

2583#define SVE_PREDICATE_TYPE(Name, MangledName, Id, SingletonId) \

2584 case BuiltinType::Id: \

2585 return true;

2586#include "clang/Basic/AArch64ACLETypes.def"

2587 default:

2588 return false;

2589 }

2590 }

2591 return false;

2592}

2593

2596 switch (BT->getKind()) {

2597#define RVV_TYPE(Name, Id, SingletonId) case BuiltinType::Id:

2598#include "clang/Basic/RISCVVTypes.def"

2599 return true;

2600 default:

2601 return false;

2602 }

2603 }

2604 return false;

2605}

2606

2609 switch (BT->getKind()) {

2610 case BuiltinType::SveInt8:

2611 case BuiltinType::SveInt16:

2612 case BuiltinType::SveInt32:

2613 case BuiltinType::SveInt64:

2614 case BuiltinType::SveUint8:

2615 case BuiltinType::SveUint16:

2616 case BuiltinType::SveUint32:

2617 case BuiltinType::SveUint64:

2618 case BuiltinType::SveFloat16:

2619 case BuiltinType::SveFloat32:

2620 case BuiltinType::SveFloat64:

2621 case BuiltinType::SveBFloat16:

2622 case BuiltinType::SveBool:

2623 case BuiltinType::SveBoolx2:

2624 case BuiltinType::SveBoolx4:

2625 case BuiltinType::SveMFloat8:

2626 return true;

2627 default:

2628 return false;

2629 }

2630 }

2631 return false;

2632}

2633

2636

2639

2642

2643 llvm_unreachable("Unhandled type");

2644}

2645

2648

2650 if (BTy->getKind() == BuiltinType::SveBool)

2651

2652

2653

2655 else

2657}

2658

2661 switch (BT->getKind()) {

2662#define RVV_VECTOR_TYPE(Name, Id, SingletonId, NumEls, ElBits, NF, IsSigned, \

2663 IsFP, IsBF) \

2664 case BuiltinType::Id: \

2665 return NF == 1;

2666#define RVV_PREDICATE_TYPE(Name, Id, SingletonId, NumEls) \

2667 case BuiltinType::Id: \

2668 return true;

2669#include "clang/Basic/RISCVVTypes.def"

2670 default:

2671 return false;

2672 }

2673 }

2674 return false;

2675}

2676

2679

2681

2682 switch (BTy->getKind()) {

2683#define RVV_PREDICATE_TYPE(Name, Id, SingletonId, NumEls) \

2684 case BuiltinType::Id: \

2685 return Ctx.UnsignedCharTy;

2686 default:

2688#include "clang/Basic/RISCVVTypes.def"

2689 }

2690

2691 llvm_unreachable("Unhandled type");

2692}

2693

2695

2696 if (Context.getLangOpts().CPlusPlus11)

2698

2700}

2701

2703

2704

2705

2707 return false;

2708

2709 if ((*this)->isIncompleteArrayType())

2710 return Context.getBaseElementType(*this).isCXX98PODType(Context);

2711

2712 if ((*this)->isIncompleteType())

2713 return false;

2714

2716 return false;

2717

2719

2720

2721 if (Context.containsAddressDiscriminatedPointerAuth(CanonicalType))

2722 return false;

2723

2725

2726 default:

2727 return false;

2728 case Type::VariableArray:

2729 case Type::ConstantArray:

2730

2731 return Context.getBaseElementType(*this).isCXX98PODType(Context);

2732

2733 case Type::ObjCObjectPointer:

2734 case Type::BlockPointer:

2735 case Type::Builtin:

2736 case Type::Complex:

2737 case Type::Pointer:

2738 case Type::MemberPointer:

2739 case Type::Vector:

2740 case Type::ExtVector:

2741 case Type::BitInt:

2742 return true;

2743

2744 case Type::Enum:

2745 return true;

2746

2747 case Type::Record:

2748 if (const auto *ClassDecl =

2749 dyn_cast(cast(CanonicalType)->getDecl()))

2750 return ClassDecl->isPOD();

2751

2752

2753 return true;

2754 }

2755}

2756

2758

2759

2760

2762 return false;

2763

2764 if ((*this)->isArrayType())

2765 return Context.getBaseElementType(*this).isTrivialType(Context);

2766

2767 if ((*this)->isSizelessBuiltinType())

2768 return true;

2769

2770

2771

2772 if ((*this)->isIncompleteType())

2773 return false;

2774

2776 return false;

2777

2780 return false;

2781

2782

2783

2784 if (Context.containsAddressDiscriminatedPointerAuth(CanonicalType))

2785 return false;

2786

2787

2788

2789

2790

2791

2792

2794 return true;

2795

2797

2798

2799

2800

2801

2802

2803 return ClassDecl->hasTrivialDefaultConstructor() &&

2804 !ClassDecl->hasNonTrivialDefaultConstructor() &&

2805 ClassDecl->isTriviallyCopyable();

2806 }

2807

2809 return true;

2810

2811

2812 return false;

2813}

2814

2817 bool IsCopyConstructible) {

2818 if (type->isArrayType())

2820 Context, IsCopyConstructible);

2821

2822 if (type.hasNonTrivialObjCLifetime())

2823 return false;

2824

2825

2826

2827

2828

2829

2830 QualType CanonicalType = type.getCanonicalType();

2832 return false;

2833

2835 return true;

2836

2837

2838

2840 return false;

2841

2843 return false;

2844

2845

2847 return true;

2848

2849

2850

2852 return true;

2853

2854 if (const auto *RD = CanonicalType->getAsRecordDecl()) {

2855 if (const auto *ClassDecl = dyn_cast(RD)) {

2856 if (IsCopyConstructible)

2857 return ClassDecl->isTriviallyCopyConstructible();

2858 return ClassDecl->isTriviallyCopyable();

2859 }

2860 return !RD->isNonTrivialToPrimitiveCopy();

2861 }

2862

2863 return false;

2864}

2865

2870

2871

2874 if (CanonicalType.hasNonTrivialObjCLifetime())

2875 return false;

2876 if (CanonicalType->isArrayType())

2877 return Context.getBaseElementType(CanonicalType)

2878 .isBitwiseCloneableType(Context);

2879

2880 if (CanonicalType->isIncompleteType())

2881 return false;

2882

2883

2884

2885 if (Context.containsAddressDiscriminatedPointerAuth(CanonicalType))

2886 return false;

2887

2888 const auto *RD = CanonicalType->getAsRecordDecl();

2889 if (!RD)

2890 return true;

2891

2892

2893

2894

2895 if (RD->mayInsertExtraPadding())

2896 return false;

2897

2898 for (auto *const Field : RD->fields()) {

2899 if (!Field->getType().isBitwiseCloneableType(Context))

2900 return false;

2901 }

2902

2903 if (const auto *CXXRD = dyn_cast(RD)) {

2904 for (auto Base : CXXRD->bases())

2905 if (Base.getType().isBitwiseCloneableType(Context))

2906 return false;

2907 for (auto VBase : CXXRD->vbases())

2908 if (!VBase.getType().isBitwiseCloneableType(Context))

2909 return false;

2910 }

2911 return true;

2912}

2913

2919

2921 return !Context.getLangOpts().ObjCAutoRefCount &&

2922 Context.getLangOpts().ObjCWeak &&

2924}

2925

2929}

2930

2933}

2934

2937}

2938

2942

2946

2951

2954 if (const auto *RD =

2958

2964 default:

2966 }

2967}

2968

2970 if (const auto *RD =

2974

2981 default:

2985 }

2986}

2987

2992

2995 return false;

2996

2997

2998

2999

3001 return true;

3002

3003

3004

3005

3006

3008 return false;

3010 assert(BaseTy && "NULL element type");

3011

3012

3013

3015 return false;

3016

3017

3018

3019

3020

3021

3024 return true;

3025

3027 return true;

3028

3030

3031

3032

3033

3034

3035

3036

3037

3038

3039

3040 if (const auto *ClassDecl = dyn_cast(RD))

3041 return ClassDecl->isLiteral();

3042

3043 return true;

3044 }

3045

3046

3048 return AT->getValueType()->isLiteralType(Ctx);

3049

3050

3051

3053 return true;

3054

3055 return false;

3056}

3057

3059

3060

3061

3062

3064 return true;

3065

3067 return true;

3068

3070 return RD->isStructural();

3071 return false;

3072}

3073

3076 return false;

3077

3078

3079

3080

3081

3083 assert(BaseTy && "NULL element type");

3084

3085

3086

3088 return false;

3089

3090

3092 return true;

3094 if (const auto *ClassDecl = dyn_cast(RD);

3095 ClassDecl && !ClassDecl->isStandardLayout())

3096 return false;

3097

3098

3099

3100

3101 return true;

3102 }

3103

3104

3105 return false;

3106}

3107

3108

3109

3110

3114 return false;

3115

3117 return false;

3118

3119

3120

3121

3123 assert(BaseTy && "NULL element type");

3124

3126 return true;

3127

3128

3129

3131 return false;

3132

3133

3134 if (Context.containsAddressDiscriminatedPointerAuth(*this))

3135 return false;

3136

3137

3139 return true;

3141 if (const auto *ClassDecl = dyn_cast(RD)) {

3142

3143

3144 if (!ClassDecl->isTrivial())

3145 return false;

3146

3147

3148

3149

3150 if (!ClassDecl->isStandardLayout())

3151 return false;

3152

3153

3154

3155

3156

3157

3158

3159

3160

3161 }

3162

3163 return true;

3164 }

3165

3166

3167 return false;

3168}

3169

3174 return true;

3175 }

3176 return false;

3177}

3178

3181 const auto *ED = ET->getDecl();

3183 if (II && II->isStr("align_val_t") && ED->isInStdNamespace())

3184 return true;

3185 }

3186 return false;

3187}

3188

3191 const auto *ED = ET->getDecl();

3193 if (II && II->isStr("byte") && ED->isInStdNamespace())

3194 return true;

3195 }

3196 return false;

3197}

3198

3200

3207 case TypeOfExpr:

3208 case TypeOf:

3209 case TemplateTypeParm:

3210 case SubstTemplateTypeParm:

3211 case TemplateSpecialization:

3212 case DependentName:

3213 case ObjCInterface:

3214 case ObjCObject:

3215 return true;

3216 default:

3217 return false;

3218 }

3219}

3220

3222 switch (TypeSpec) {

3223 default:

3237 }

3238}

3239

3241 switch (TypeSpec) {

3252 }

3253

3254 llvm_unreachable("Type specifier is not a tag type kind.");

3255}

3256

3259 switch (Kind) {

3270 }

3271 llvm_unreachable("Unknown tag type kind.");

3272}

3273

3289 llvm_unreachable("Elaborated type keyword is not a tag type kind.");

3290 }

3291 llvm_unreachable("Unknown elaborated type keyword.");

3292}

3293

3298 return false;

3304 return true;

3305 }

3306 llvm_unreachable("Unknown elaborated type keyword.");

3307}

3308

3312 return {};

3314 return "typename";

3316 return "class";

3318 return "struct";

3320 return "__interface";

3322 return "union";

3324 return "enum";

3325 }

3326

3327 llvm_unreachable("Unknown elaborated type keyword.");

3328}

3329

3332 if (const auto *TST = dyn_cast(this))

3333 Keyword = TST->getKeyword();

3334 else if (const auto *DepName = dyn_cast(this))

3335 Keyword = DepName->getKeyword();

3336 else if (const auto *T = dyn_cast(this))

3338 else if (const auto *T = dyn_cast(this))

3340 else if (const auto *T = dyn_cast(this))

3342 else if (const auto *T = dyn_cast(this))

3344 else

3345 return false;

3346

3348}

3349

3352#define ABSTRACT_TYPE(Derived, Base)

3353#define TYPE(Derived, Base) \

3354 case Derived: \

3355 return #Derived;

3356#include "clang/AST/TypeNodes.inc"

3357 }

3358

3359 llvm_unreachable("Invalid type class.");

3360}

3361

3365 return "void";

3367 return Policy.Bool ? "bool" : "_Bool";

3368 case Char_S:

3369 return "char";

3370 case Char_U:

3371 return "char";

3372 case SChar:

3373 return "signed char";

3375 return "short";

3376 case Int:

3377 return "int";

3379 return "long";

3381 return "long long";

3382 case Int128:

3383 return "__int128";

3384 case UChar:

3385 return "unsigned char";

3386 case UShort:

3387 return "unsigned short";

3388 case UInt:

3389 return "unsigned int";

3390 case ULong:

3391 return "unsigned long";

3392 case ULongLong:

3393 return "unsigned long long";

3394 case UInt128:

3395 return "unsigned __int128";

3397 return Policy.Half ? "half" : "__fp16";

3398 case BFloat16:

3399 return "__bf16";

3401 return "float";

3403 return "double";

3405 return "long double";

3406 case ShortAccum:

3407 return "short _Accum";

3408 case Accum:

3409 return "_Accum";

3410 case LongAccum:

3411 return "long _Accum";

3412 case UShortAccum:

3413 return "unsigned short _Accum";

3414 case UAccum:

3415 return "unsigned _Accum";

3416 case ULongAccum:

3417 return "unsigned long _Accum";

3418 case BuiltinType::ShortFract:

3419 return "short _Fract";

3420 case BuiltinType::Fract:

3421 return "_Fract";

3422 case BuiltinType::LongFract:

3423 return "long _Fract";

3424 case BuiltinType::UShortFract:

3425 return "unsigned short _Fract";

3426 case BuiltinType::UFract:

3427 return "unsigned _Fract";

3428 case BuiltinType::ULongFract:

3429 return "unsigned long _Fract";

3430 case BuiltinType::SatShortAccum:

3431 return "_Sat short _Accum";

3432 case BuiltinType::SatAccum:

3433 return "_Sat _Accum";

3434 case BuiltinType::SatLongAccum:

3435 return "_Sat long _Accum";

3436 case BuiltinType::SatUShortAccum:

3437 return "_Sat unsigned short _Accum";

3438 case BuiltinType::SatUAccum:

3439 return "_Sat unsigned _Accum";

3440 case BuiltinType::SatULongAccum:

3441 return "_Sat unsigned long _Accum";

3442 case BuiltinType::SatShortFract:

3443 return "_Sat short _Fract";

3444 case BuiltinType::SatFract:

3445 return "_Sat _Fract";

3446 case BuiltinType::SatLongFract:

3447 return "_Sat long _Fract";

3448 case BuiltinType::SatUShortFract:

3449 return "_Sat unsigned short _Fract";

3450 case BuiltinType::SatUFract:

3451 return "_Sat unsigned _Fract";

3452 case BuiltinType::SatULongFract:

3453 return "_Sat unsigned long _Fract";

3454 case Float16:

3455 return "_Float16";

3457 return "__float128";

3459 return "__ibm128";

3460 case WChar_S:

3461 case WChar_U:

3462 return Policy.MSWChar ? "__wchar_t" : "wchar_t";

3463 case Char8:

3464 return "char8_t";

3465 case Char16:

3466 return "char16_t";

3467 case Char32:

3468 return "char32_t";

3469 case NullPtr:

3472 return "";

3473 case BoundMember:

3474 return "";

3475 case UnresolvedTemplate:

3476 return "";

3477 case PseudoObject:

3478 return "";

3480 return "";

3481 case UnknownAny:

3482 return "";

3483 case ARCUnbridgedCast:

3484 return "";

3485 case BuiltinFn:

3486 return "";

3487 case ObjCId:

3488 return "id";

3489 case ObjCClass:

3490 return "Class";

3491 case ObjCSel:

3492 return "SEL";

3493#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \

3494 case Id: \

3495 return "__" #Access " " #ImgType "_t";

3496#include "clang/Basic/OpenCLImageTypes.def"

3497 case OCLSampler:

3498 return "sampler_t";

3499 case OCLEvent:

3500 return "event_t";

3501 case OCLClkEvent:

3502 return "clk_event_t";

3503 case OCLQueue:

3504 return "queue_t";

3505 case OCLReserveID:

3506 return "reserve_id_t";

3507 case IncompleteMatrixIdx:

3508 return "";

3509 case ArraySection:

3510 return "";

3511 case OMPArrayShaping:

3512 return "";

3513 case OMPIterator:

3514 return "";

3515#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \

3516 case Id: \

3517 return #ExtType;

3518#include "clang/Basic/OpenCLExtensionTypes.def"

3519#define SVE_TYPE(Name, Id, SingletonId) \

3520 case Id: \

3521 return #Name;

3522#include "clang/Basic/AArch64ACLETypes.def"

3523#define PPC_VECTOR_TYPE(Name, Id, Size) \

3524 case Id: \

3525 return #Name;

3526#include "clang/Basic/PPCTypes.def"

3527#define RVV_TYPE(Name, Id, SingletonId) \

3528 case Id: \

3529 return Name;

3530#include "clang/Basic/RISCVVTypes.def"

3531#define WASM_TYPE(Name, Id, SingletonId) \

3532 case Id: \

3533 return Name;

3534#include "clang/Basic/WebAssemblyReferenceTypes.def"

3535#define AMDGPU_TYPE(Name, Id, SingletonId, Width, Align) \

3536 case Id: \

3537 return Name;

3538#include "clang/Basic/AMDGPUTypes.def"

3539#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) \

3540 case Id: \

3541 return #Name;

3542#include "clang/Basic/HLSLIntangibleTypes.def"

3543 }

3544

3545 llvm_unreachable("Invalid builtin type.");

3546}

3547

3549

3550 if (auto *PET = dyn_cast(getTypePtr()))

3551 return PET->getPattern();

3552 return *this;

3553}

3554

3556 if (const auto *RefType = getTypePtr()->getAs())

3558

3559

3560

3561

3562

3563

3564 if (!Context.getLangOpts().CPlusPlus ||

3567

3568 return *this;

3569}

3570

3573 return FPT->hasCFIUncheckedCallee();

3574 return false;

3575}

3576

3578 switch (CC) {

3580 return "cdecl";

3582 return "stdcall";

3584 return "fastcall";

3586 return "thiscall";

3588 return "pascal";

3590 return "vectorcall";

3592 return "ms_abi";

3594 return "sysv_abi";

3596 return "regcall";

3598 return "aapcs";

3600 return "aapcs-vfp";

3602 return "aarch64_vector_pcs";

3604 return "aarch64_sve_pcs";

3606 return "intel_ocl_bicc";

3608 return "spir_function";

3610 return "device_kernel";

3612 return "swiftcall";

3614 return "swiftasynccall";

3616 return "preserve_most";

3618 return "preserve_all";

3620 return "m68k_rtd";

3622 return "preserve_none";

3623

3625#define CC_VLS_CASE(ABI_VLEN) \

3626 case CC_RISCVVLSCall_##ABI_VLEN: return "riscv_vls_cc(" #ABI_VLEN ")";

3639#undef CC_VLS_CASE

3640

3641 }

3642

3643 llvm_unreachable("Invalid calling convention.");

3644}

3645

3652

3661 assert(getNumParams() == params.size() && "NumParams overflow!");

3667

3670 auto &ExtraBits = *getTrailingObjects();

3672 } else {

3674 }

3675

3676

3678 auto &ExtraAttrInfo = *getTrailingObjects();

3680

3681

3682 auto &ExtraBits = *getTrailingObjects();

3683 ExtraBits.HasExtraAttributeInfo = true;

3684 }

3685

3687 auto &ArmTypeAttrs = *getTrailingObjects();

3688 ArmTypeAttrs = FunctionTypeArmAttributes();

3689

3690

3691 auto &ExtraBits = *getTrailingObjects();

3692 ExtraBits.HasArmTypeAttributes = true;

3693 }

3694

3695

3696 auto *argSlot = getTrailingObjects();

3697 for (unsigned i = 0; i != getNumParams(); ++i) {

3699 ~TypeDependence::VariablyModified);

3700 argSlot[i] = params[i];

3701 }

3702

3703

3705 auto &ArmTypeAttrs = *getTrailingObjects();

3707 "Not enough bits to encode SME attributes");

3709 }

3710

3711

3713 auto &ExtraBits = *getTrailingObjects();

3715 assert(NumExceptions <= 1023 && "Not enough bits to encode exceptions");

3716 ExtraBits.NumExceptionType = NumExceptions;

3717

3718 assert(hasExtraBitfields() && "missing trailing extra bitfields!");

3719 auto *exnSlot =

3720 reinterpret_cast<QualType *>(getTrailingObjects());

3721 unsigned I = 0;

3723

3724

3725

3728 (TypeDependence::Instantiation | TypeDependence::UnexpandedPack));

3729

3730 exnSlot[I++] = ExceptionType;

3731 }

3732 }

3733

3738

3739

3741

3744 (TypeDependence::Instantiation | TypeDependence::UnexpandedPack));

3745 }

3746

3748

3749

3750 auto **slot = getTrailingObjects<FunctionDecl *>();

3753

3754

3756

3757

3758 auto **slot = getTrailingObjects<FunctionDecl *>();

3760 }

3761

3762

3763

3768 addDependence(TypeDependence::DependentInstantiation);

3769 }

3771

3772 addDependence(TypeDependence::DependentInstantiation);

3773 }

3774

3775

3777 auto *extParamInfos = getTrailingObjects();

3778 for (unsigned i = 0; i != getNumParams(); ++i)

3780 }

3781

3784 *getTrailingObjects() = epi.TypeQuals;

3785 } else {

3787 }

3788

3789

3791 auto &EllipsisLoc = *getTrailingObjects();

3793 }

3794

3796 auto &ExtraBits = *getTrailingObjects();

3798 ExtraBits.NumFunctionEffects = EffectsCount;

3799 assert(ExtraBits.NumFunctionEffects == EffectsCount &&

3800 "effect bitfield overflow");

3801

3803 auto *DestFX = getTrailingObjects();

3804 llvm::uninitialized_copy(SrcFX, DestFX);

3805

3807 if (!SrcConds.empty()) {

3808 ExtraBits.EffectsHaveConditions = true;

3809 auto *DestConds = getTrailingObjects();

3810 llvm::uninitialized_copy(SrcConds, DestConds);

3811 assert(llvm::any_of(SrcConds,

3812 [](const EffectConditionExpr &EC) {

3814 return E->isTypeDependent() ||

3815 E->isValueDependent();

3816 return false;

3817 }) &&

3818 "expected a dependent expression among the conditions");

3819 addDependence(TypeDependence::DependentInstantiation);

3820 }

3821 }

3822}

3823

3826 return NE->isValueDependent();

3828

3829

3830

3832 return true;

3833 return false;

3834}

3835

3838 return NE->isInstantiationDependent();

3841 return true;

3842 return false;

3843}

3844

3849 llvm_unreachable("should not call this with unresolved exception specs");

3850

3856

3861

3863

3864

3869

3873 }

3874

3875 llvm_unreachable("unexpected exception specification kind");

3876}

3877

3879 for (unsigned ArgIdx = getNumParams(); ArgIdx; --ArgIdx)

3881 return true;

3882

3883 return false;

3884}

3885

3887 const QualType *ArgTys, unsigned NumParams,

3888 const ExtProtoInfo &epi,

3889 const ASTContext &Context, bool Canonical) {

3890

3891

3892

3893

3894

3895

3896

3897

3898

3899

3900

3901

3902

3903

3904

3905

3906

3907

3908

3909

3910

3911

3912 ID.AddPointer(Result.getAsOpaquePtr());

3913 for (unsigned i = 0; i != NumParams; ++i)

3914 ID.AddPointer(ArgTys[i].getAsOpaquePtr());

3915

3916

3917

3918 assert(!(unsigned(epi.Variadic) & ~1) && !(unsigned(epi.RefQualifier) & ~3) &&

3919 !(unsigned(epi.ExceptionSpec.Type) & ~15) &&

3920 "Values larger than expected.");

3921 ID.AddInteger(unsigned(epi.Variadic) + (epi.RefQualifier << 1) +

3922 (epi.ExceptionSpec.Type << 3));

3923 ID.Add(epi.TypeQuals);

3924 if (epi.ExceptionSpec.Type == EST_Dynamic) {

3925 for (QualType Ex : epi.ExceptionSpec.Exceptions)

3928 epi.ExceptionSpec.NoexceptExpr->Profile(ID, Context, Canonical);

3931 ID.AddPointer(epi.ExceptionSpec.SourceDecl->getCanonicalDecl());

3932 }

3933 if (epi.ExtParameterInfos) {

3934 for (unsigned i = 0; i != NumParams; ++i)

3935 ID.AddInteger(epi.ExtParameterInfos[i].getOpaqueValue());

3936 }

3937

3938 epi.ExtInfo.Profile(ID);

3939 epi.ExtraAttributeInfo.Profile(ID);

3940

3941 unsigned EffectCount = epi.FunctionEffects.size();

3942 bool HasConds = !epi.FunctionEffects.Conditions.empty();

3943

3944 ID.AddInteger((EffectCount << 3) | (HasConds << 2) |

3945 (epi.AArch64SMEAttributes << 1) | epi.HasTrailingReturn);

3946 ID.AddInteger(epi.CFIUncheckedCallee);

3947

3948 for (unsigned Idx = 0; Idx != EffectCount; ++Idx) {

3949 ID.AddInteger(epi.FunctionEffects.Effects[Idx].toOpaqueInt32());

3950 if (HasConds)

3951 ID.AddPointer(epi.FunctionEffects.Conditions[Idx].getCondition());

3952 }

3953}

3954

3960

3962 : Data(D, Deref << DerefShift) {}

3963

3965 return Data.getInt() & DerefMask;

3966}

3970 return Data.getOpaqueValue();

3971}

3977 Data.setFromOpaqueValue(V);

3978}

3979

3983

3984CountAttributedType::CountAttributedType(

3988 CountExpr(CountExpr) {

3992 auto *DeclSlot = getTrailingObjects();

3993 llvm::copy(CoupledDecls, DeclSlot);

3994 Decls = llvm::ArrayRef(DeclSlot, CoupledDecls.size());

3995}

3996

3998

3999

4000

4001

4002#define ENUMERATE_ATTRS(PREFIX) \

4003 do { \

4004 if (isCountInBytes()) { \

4005 if (isOrNull()) \

4006 return PREFIX "sized_by_or_null"; \

4007 return PREFIX "sized_by"; \

4008 } \

4009 if (isOrNull()) \

4010 return PREFIX "counted_by_or_null"; \

4011 return PREFIX "counted_by"; \

4012 } while (0)

4013

4014 if (WithMacroPrefix)

4016 else

4018

4019#undef ENUMERATE_ATTRS

4020}

4021

4025 bool HasTypeDifferentFromDecl)

4027 Keyword, TC, UnderlyingType.getCanonicalType(),

4029 (Qualifier

4031 ~NestedNameSpecifierDependence::Dependent)

4034 if ((TypedefBits.hasQualifier = !!Qualifier))

4035 *getTrailingObjects() = Qualifier;

4036 if ((TypedefBits.hasTypeDifferentFromDecl = HasTypeDifferentFromDecl))

4037 *getTrailingObjects() = UnderlyingType;

4038}

4039

4042 : *getTrailingObjects();

4043}

4044

4048 const Type *CanonicalType)

4052 (Qualifier

4054 ~NestedNameSpecifierDependence::Dependent)

4058 *getTrailingObjects() = Qualifier;

4059}

4060

4066 D(const_cast<UsingShadowDecl *>(D)), UnderlyingType(UnderlyingType) {

4067 if ((UsingBits.hasQualifier = !!Qualifier))

4068 *getTrailingObjects() = Qualifier;

4069}

4070

4072

4074

4075

4077 while (auto *InnerMQT = dyn_cast(Inner)) {

4079 break;

4080 Inner = InnerMQT->getModifiedType();

4081 }

4082 return Inner;

4083}

4084

4087 : Type(TypeOfExpr,

4088

4089

4091 ? Context.getUnqualifiedArrayType(Can).getAtomicUnqualifiedType()

4092 : Can,

4096 TOExpr(E), Context(Context) {

4097 TypeOfBits.Kind = static_cast<unsigned>(Kind);

4098}

4099

4101

4106 ? Context.getUnqualifiedArrayType(QT).getAtomicUnqualifiedType()

4107 : QT;

4108 }

4110}

4111

4114 bool IsUnqual) {

4115 E->Profile(ID, Context, true);

4116 ID.AddBoolean(IsUnqual);

4117}

4118

4121 : Type(TypeOf,

4123 ? Context.getUnqualifiedArrayType(Can).getAtomicUnqualifiedType()

4124 : Can,

4125 T->getDependence()),

4126 TOType(T), Context(Context) {

4127 TypeOfBits.Kind = static_cast<unsigned>(Kind);

4128}

4129

4130QualType TypeOfType::desugar() const {

4131 QualType QT = getUnmodifiedType();

4133 ? Context.getUnqualifiedArrayType(QT).getAtomicUnqualifiedType()

4134 : QT;

4135}

4136

4138

4139

4140

4141 : Type(Decltype, can,

4145 (E->getType()->getDependence() &

4147 E(E), UnderlyingType(underlyingType) {}

4148

4149bool DecltypeType::isSugared() const { return !E->isInstantiationDependent(); }

4150

4151QualType DecltypeType::desugar() const {

4152 if (isSugared())

4154

4156}

4157

4158DependentDecltypeType::DependentDecltypeType(Expr *E)

4159 : DecltypeType(E, QualType()) {}

4160

4161void DependentDecltypeType::Profile(llvm::FoldingSetNodeID &ID,

4163 E->Profile(ID, Context, true);

4164}

4165

4166PackIndexingType::PackIndexingType(QualType Canonical, QualType Pattern,

4167 Expr *IndexExpr, bool FullySubstituted,

4169 : Type(PackIndexing, Canonical,

4171 Pattern(Pattern), IndexExpr(IndexExpr), Size(Expansions.size()),

4172 FullySubstituted(FullySubstituted) {

4173

4174 llvm::uninitialized_copy(Expansions, getTrailingObjects());

4175}

4176

4177UnsignedOrNone PackIndexingType::getSelectedIndex() const {

4178 if (isInstantiationDependentType())

4179 return std::nullopt;

4180

4181 ConstantExpr *CE = dyn_cast(getIndexExpr());

4182 if (!CE)

4183 return std::nullopt;

4185 assert(Index.isNonNegative() && "Invalid index");

4186 return static_cast<unsigned>(Index.getExtValue());

4187}

4188

4190PackIndexingType::computeDependence(QualType Pattern, Expr *IndexExpr,

4193

4195 ? TypeDependence::DependentInstantiation

4196 : TypeDependence::None);

4197 if (Expansions.empty())

4198 TD |= Pattern->getDependence() & TypeDependence::DependentInstantiation;

4199 else

4200 for (const QualType &T : Expansions)

4201 TD |= T->getDependence();

4202

4203 if (!(IndexD & TypeDependence::UnexpandedPack))

4205

4206

4207

4209 TD |= TypeDependence::Error | TypeDependence::DependentInstantiation;

4210

4211 return TD;

4212}

4213

4214void PackIndexingType::Profile(llvm::FoldingSetNodeID &ID,

4216 Profile(ID, Context, getPattern(), getIndexExpr(), isFullySubstituted(),

4217 getExpansions());

4218}

4219

4220void PackIndexingType::Profile(llvm::FoldingSetNodeID &ID,

4222 Expr *E, bool FullySubstituted,

4224

4225 E->Profile(ID, Context, true);

4226 ID.AddBoolean(FullySubstituted);

4227 if (!Expansions.empty()) {

4228 ID.AddInteger(Expansions.size());

4230 T.getCanonicalType().Profile(ID);

4231 } else {

4233 }

4234}

4235

4236UnaryTransformType::UnaryTransformType(QualType BaseType,

4237 QualType UnderlyingType, UTTKind UKind,

4239 : Type(UnaryTransform, CanonicalType, BaseType->getDependence()),

4240 BaseType(BaseType), UnderlyingType(UnderlyingType), UKind(UKind) {}

4241

4244 bool OwnsTag, bool ISInjected, const Type *CanonicalType)

4247 (Tag->isDependentType() ? TypeDependence::DependentInstantiation

4251 ~NestedNameSpecifierDependence::Dependent)

4254 if ((TagTypeBits.HasQualifier = !!Qualifier))

4255 getTrailingQualifier() = Qualifier;

4258}

4259

4260void *TagType::getTrailingPointer() const {

4261 switch (getTypeClass()) {

4262 case Type::Enum:

4263 return const_cast<EnumType *>(cast(this) + 1);

4264 case Type::Record:

4265 return const_cast<RecordType *>(cast(this) + 1);

4266 case Type::InjectedClassName:

4267 return const_cast<InjectedClassNameType *>(

4269 default:

4270 llvm_unreachable("unexpected type class");

4271 }

4272}

4273

4275 assert(TagTypeBits.HasQualifier);

4277 getTrailingPointer(), llvm::Align::Of<NestedNameSpecifier *>()));

4278}

4279

4281 return TagTypeBits.HasQualifier ? getTrailingQualifier() : std::nullopt;

4282}

4283

4285 auto *Decl = dyn_cast(decl);

4287 return nullptr;

4288 if (auto *RD = dyn_cast(Decl))

4289 return RD->getSpecializedTemplate();

4290 return Decl->getDescribedClassTemplate();

4291}

4292

4294 auto *TD = getTemplateDecl();

4295 if (!TD)

4297 if (isCanonicalUnqualified())

4301}

4302

4304TagType::getTemplateArgs(const ASTContext &Ctx) const {

4305 auto *Decl = dyn_cast(decl);

4307 return {};

4308

4309 if (auto *RD = dyn_cast(Decl))

4310 return RD->getTemplateArgs().asArray();

4312 return TD->getTemplateParameters()->getInjectedTemplateArgs(Ctx);

4313 return {};

4314}

4315

4316bool RecordType::hasConstFields() const {

4317 std::vector<const RecordType *> RecordTypeList;

4318 RecordTypeList.push_back(this);

4319 unsigned NextToCheckIndex = 0;

4320

4321 while (RecordTypeList.size() > NextToCheckIndex) {

4322 for (FieldDecl *FD : RecordTypeList[NextToCheckIndex]

4323 ->getDecl()

4325 ->fields()) {

4326 QualType FieldTy = FD->getType();

4328 return true;

4330 if (const auto *FieldRecTy = FieldTy->getAsCanonical()) {

4331 if (!llvm::is_contained(RecordTypeList, FieldRecTy))

4332 RecordTypeList.push_back(FieldRecTy);

4333 }

4334 }

4335 ++NextToCheckIndex;

4336 }

4337 return false;

4338}

4339

4342 const TagDecl *TD, bool IsInjected,

4343 const Type *CanonicalType)

4344 : TagType(TypeClass::InjectedClassName, Keyword, Qualifier, TD,

4345 false, IsInjected, CanonicalType) {}

4346

4347AttributedType::AttributedType(QualType canon, const Attr *attr,

4350

4354 : Type(Attributed, canon, equivalent->getDependence()), Attribute(attr),

4355 ModifiedType(modified), EquivalentType(equivalent) {

4357 assert(!attr || attr->getKind() == attrKind);

4358}

4359

4360bool AttributedType::isQualifier() const {

4361

4362 switch (getAttrKind()) {

4363

4364

4365

4366 case attr::ObjCGC:

4367 case attr::ObjCOwnership:

4368 case attr::ObjCInertUnsafeUnretained:

4369 case attr::TypeNonNull:

4370 case attr::TypeNullable:

4371 case attr::TypeNullableResult:

4372 case attr::TypeNullUnspecified:

4373 case attr::LifetimeBound:

4374 case attr::AddressSpace:

4375 return true;

4376

4377

4378

4379 default:

4380 return false;

4381 }

4382}

4383

4384bool AttributedType::isMSTypeSpec() const {

4385

4386 switch (getAttrKind()) {

4387 default:

4388 return false;

4389 case attr::Ptr32:

4390 case attr::Ptr64:

4391 case attr::SPtr:

4392 case attr::UPtr:

4393 return true;

4394 }

4395 llvm_unreachable("invalid attr kind");

4396}

4397

4398bool AttributedType::isWebAssemblyFuncrefSpec() const {

4399 return getAttrKind() == attr::WebAssemblyFuncref;

4400}

4401

4402bool AttributedType::isCallingConv() const {

4403

4404 switch (getAttrKind()) {

4405 default:

4406 return false;

4407 case attr::Pcs:

4408 case attr::CDecl:

4409 case attr::FastCall:

4410 case attr::StdCall:

4411 case attr::ThisCall:

4412 case attr::RegCall:

4413 case attr::SwiftCall:

4414 case attr::SwiftAsyncCall:

4415 case attr::VectorCall:

4416 case attr::AArch64VectorPcs:

4417 case attr::AArch64SVEPcs:

4418 case attr::DeviceKernel:

4419 case attr::Pascal:

4420 case attr::MSABI:

4421 case attr::SysVABI:

4422 case attr::IntelOclBicc:

4423 case attr::PreserveMost:

4424 case attr::PreserveAll:

4425 case attr::M68kRTD:

4426 case attr::PreserveNone:

4427 case attr::RISCVVectorCC:

4428 case attr::RISCVVLSCC:

4429 return true;

4430 }

4431 llvm_unreachable("invalid attr kind");

4432}

4433

4434IdentifierInfo *TemplateTypeParmType::getIdentifier() const {

4435 return isCanonicalUnqualified() ? nullptr : getDecl()->getIdentifier();

4436}

4437

4438SubstTemplateTypeParmType::SubstTemplateTypeParmType(QualType Replacement,

4439 Decl *AssociatedDecl,

4440 unsigned Index,

4442 bool Final)

4443 : Type(SubstTemplateTypeParm, Replacement.getCanonicalType(),

4444 Replacement->getDependence()),

4445 AssociatedDecl(AssociatedDecl) {

4449 *getTrailingObjects() = Replacement;

4450

4455 assert(AssociatedDecl != nullptr);

4456}

4457

4459SubstTemplateTypeParmType::getReplacedParameter() const {

4462}

4463

4464void SubstTemplateTypeParmType::Profile(llvm::FoldingSetNodeID &ID,

4466 const Decl *AssociatedDecl,

4467 unsigned Index,

4469 Replacement.Profile(ID);

4470 ID.AddPointer(AssociatedDecl);

4471 ID.AddInteger(Index);

4473 ID.AddBoolean(Final);

4474}

4475

4476SubstPackType::SubstPackType(TypeClass Derived, QualType Canon,

4478 : Type(Derived, Canon,

4481 Arguments(ArgPack.pack_begin()) {

4482 assert(llvm::all_of(

4484 [](auto &P) { return P.getKind() == TemplateArgument::Type; }) &&

4485 "non-type argument to SubstPackType?");

4487}

4488

4491}

4492

4493void SubstPackType::Profile(llvm::FoldingSetNodeID &ID) {

4494 Profile(ID, getArgumentPack());

4495}

4496

4497void SubstPackType::Profile(llvm::FoldingSetNodeID &ID,

4501 ID.AddPointer(P.getAsType().getAsOpaquePtr());

4502}

4503

4504SubstTemplateTypeParmPackType::SubstTemplateTypeParmPackType(

4505 QualType Canon, Decl *AssociatedDecl, unsigned Index, bool Final,

4507 : SubstPackType(SubstTemplateTypeParmPack, Canon, ArgPack),

4508 AssociatedDeclAndFinal(AssociatedDecl, Final) {

4509 assert(AssociatedDecl != nullptr);

4510

4512 assert(getNumArgs() == ArgPack.pack_size() &&

4513 "Parent bitfields in SubstPackType were overwritten."

4514 "Check NumSubstPackTypeBits.");

4515}

4516

4517Decl *SubstTemplateTypeParmPackType::getAssociatedDecl() const {

4518 return AssociatedDeclAndFinal.getPointer();

4519}

4520

4521bool SubstTemplateTypeParmPackType::getFinal() const {

4522 return AssociatedDeclAndFinal.getInt();

4523}

4524

4526SubstTemplateTypeParmPackType::getReplacedParameter() const {

4529}

4530

4531IdentifierInfo *SubstTemplateTypeParmPackType::getIdentifier() const {

4532 return getReplacedParameter()->getIdentifier();

4533}

4534

4535void SubstTemplateTypeParmPackType::Profile(llvm::FoldingSetNodeID &ID) {

4536 Profile(ID, getAssociatedDecl(), getIndex(), getFinal(), getArgumentPack());

4537}

4538

4539void SubstTemplateTypeParmPackType::Profile(llvm::FoldingSetNodeID &ID,

4540 const Decl *AssociatedDecl,

4541 unsigned Index, bool Final,

4543 ID.AddPointer(AssociatedDecl);

4544 ID.AddInteger(Index);

4545 ID.AddBoolean(Final);

4546 SubstPackType::Profile(ID, ArgPack);

4547}

4548

4549SubstBuiltinTemplatePackType::SubstBuiltinTemplatePackType(

4551 : SubstPackType(SubstBuiltinTemplatePack, Canon, ArgPack) {}

4552

4553bool TemplateSpecializationType::anyDependentTemplateArguments(

4556 return anyDependentTemplateArguments(Args.arguments(), Converted);

4557}

4558

4559bool TemplateSpecializationType::anyDependentTemplateArguments(

4562 if (Arg.isDependent())

4563 return true;

4564 return false;

4565}

4566

4567bool TemplateSpecializationType::anyInstantiationDependentTemplateArguments(

4570 if (ArgLoc.getArgument().isInstantiationDependent())

4571 return true;

4572 }

4573 return false;

4574}

4575

4579 ? TypeDependence::DependentInstantiation

4581 D |= toTypeDependence(T.getDependence()) & TypeDependence::UnexpandedPack;

4583 if (Underlying.isNull())

4584 D |= TypeDependence::UnexpandedPack;

4585 else

4586 D |= (Underlying->getDependence() & TypeDependence::UnexpandedPack);

4587 }

4588 return D;

4589}

4590

4591TemplateSpecializationType::TemplateSpecializationType(

4595 Underlying.isNull() ? QualType(this, 0)

4596 : Underlying.getCanonicalType(),

4599 TemplateSpecializationTypeBits.NumArgs = Args.size();

4600 TemplateSpecializationTypeBits.TypeAlias = IsAlias;

4601

4602 auto *TemplateArgs =

4603 const_cast<TemplateArgument *>(template_arguments().data());

4605

4606

4607

4608

4609

4610

4611

4612

4614 ~TypeDependence::Dependent);

4616 addDependence(Arg.getAsType()->getDependence() &

4617 TypeDependence::VariablyModified);

4619 }

4620

4621

4622

4623 if (IsAlias)

4624 *reinterpret_cast<QualType *>(TemplateArgs) = Underlying;

4625}

4626

4627QualType TemplateSpecializationType::getAliasedType() const {

4628 assert(isTypeAlias() && "not a type alias template specialization");

4629 return *reinterpret_cast<const QualType *>(template_arguments().end());

4630}

4631

4632bool clang::TemplateSpecializationType::isSugared() const {

4633 return !isDependentType() || isCurrentInstantiation() || isTypeAlias() ||

4636}

4637

4638void TemplateSpecializationType::Profile(llvm::FoldingSetNodeID &ID,

4640 Profile(ID, getKeyword(), Template, template_arguments(),

4641 isSugared() ? desugar() : QualType(), Ctx);

4642}

4643

4644void TemplateSpecializationType::Profile(llvm::FoldingSetNodeID &ID,

4650 ID.AddInteger(llvm::to_underlying(Keyword));

4651 T.Profile(ID);

4653

4654 ID.AddInteger(Args.size());

4656 Arg.Profile(ID, Context);

4657}

4658

4663

4664 return Context.getQualifiedType(QT, *this);

4665}

4666

4668 const Type *T) const {

4671

4672 return Context.getQualifiedType(T, *this);

4673}

4674

4675void ObjCObjectTypeImpl::Profile(llvm::FoldingSetNodeID &ID, QualType BaseType,

4678 bool isKindOf) {

4679 ID.AddPointer(BaseType.getAsOpaquePtr());

4680 ID.AddInteger(typeArgs.size());

4681 for (auto typeArg : typeArgs)

4682 ID.AddPointer(typeArg.getAsOpaquePtr());

4683 ID.AddInteger(protocols.size());

4684 for (auto *proto : protocols)

4685 ID.AddPointer(proto);

4686 ID.AddBoolean(isKindOf);

4687}

4688

4689void ObjCObjectTypeImpl::Profile(llvm::FoldingSetNodeID &ID) {

4690 Profile(ID, getBaseType(), getTypeArgsAsWritten(),

4692 isKindOfTypeAsWritten());

4693}

4694

4695void ObjCTypeParamType::Profile(llvm::FoldingSetNodeID &ID,

4699 ID.AddPointer(OTPDecl);

4701 ID.AddInteger(protocols.size());

4702 for (auto *proto : protocols)

4703 ID.AddPointer(proto);

4704}

4705

4706void ObjCTypeParamType::Profile(llvm::FoldingSetNodeID &ID) {

4707 Profile(ID, getDecl(), getCanonicalTypeInternal(),

4709}

4710

4711namespace {

4712

4713

4714class CachedProperties {

4716 bool local;

4717

4718public:

4719 CachedProperties(Linkage L, bool local) : L(L), local(local) {}

4720

4721 Linkage getLinkage() const { return L; }

4722 bool hasLocalOrUnnamedType() const { return local; }

4723

4724 friend CachedProperties merge(CachedProperties L, CachedProperties R) {

4726 return CachedProperties(MergedLinkage, L.hasLocalOrUnnamedType() ||

4727 R.hasLocalOrUnnamedType());

4728 }

4729};

4730

4731}

4732

4734

4735namespace clang {

4736

4737

4738

4739

4741public:

4743

4744 static CachedProperties get(const Type *T) {

4746 return CachedProperties(T->TypeBits.getLinkage(),

4747 T->TypeBits.hasLocalOrUnnamedType());

4748 }

4749

4751

4752 if (T->TypeBits.isCacheValid())

4753 return;

4754

4755

4756

4757 if (T->isCanonicalUnqualified()) {

4758 const Type *CT = T->getCanonicalTypeInternal().getTypePtr();

4760 T->TypeBits.CacheValid = true;

4761 T->TypeBits.CachedLinkage = CT->TypeBits.CachedLinkage;

4762 T->TypeBits.CachedLocalOrUnnamed = CT->TypeBits.CachedLocalOrUnnamed;

4763 return;

4764 }

4765

4766

4768 T->TypeBits.CacheValid = true;

4769 T->TypeBits.CachedLinkage = llvm::to_underlying(Result.getLinkage());

4770 T->TypeBits.CachedLocalOrUnnamed = Result.hasLocalOrUnnamedType();

4771 }

4772};

4773

4774}

4775

4776

4777

4778

4779namespace {

4780

4782

4783}

4784

4786

4788 switch (T->getTypeClass()) {

4789#define TYPE(Class, Base)

4790#define NON_CANONICAL_TYPE(Class, Base) case Type::Class:

4791#include "clang/AST/TypeNodes.inc"

4792 llvm_unreachable("didn't expect a non-canonical type here");

4793

4794#define TYPE(Class, Base)

4795#define DEPENDENT_TYPE(Class, Base) case Type::Class:

4796#define NON_CANONICAL_UNLESS_DEPENDENT_TYPE(Class, Base) case Type::Class:

4797#include "clang/AST/TypeNodes.inc"

4798

4799 assert(T->isInstantiationDependentType());

4801

4802 case Type::Auto:

4803 case Type::DeducedTemplateSpecialization:

4804

4805

4807

4808 case Type::BitInt:

4809 case Type::Builtin:

4810

4811

4812

4814

4815 case Type::Record:

4816 case Type::Enum: {

4817 const auto *Tag = cast(T)->getDecl()->getDefinitionOrSelf();

4818

4819

4820

4821

4822

4823 Linkage L = Tag->getLinkageInternal();

4824 bool IsLocalOrUnnamed = Tag->getDeclContext()->isFunctionOrMethod() ||

4825 !Tag->hasNameForLinkage();

4826 return CachedProperties(L, IsLocalOrUnnamed);

4827 }

4828

4829

4830

4831

4832 case Type::Complex:

4834 case Type::Pointer:

4836 case Type::BlockPointer:

4838 case Type::LValueReference:

4839 case Type::RValueReference:

4841 case Type::MemberPointer: {

4843 CachedProperties Cls = [&] {

4844 if (MPT->isSugared())

4846 return Cache::get(MPT->getQualifier().getAsType());

4847 }();

4848 return merge(Cls, Cache::get(MPT->getPointeeType()));

4849 }

4850 case Type::ConstantArray:

4851 case Type::IncompleteArray:

4852 case Type::VariableArray:

4853 case Type::ArrayParameter:

4855 case Type::Vector:

4856 case Type::ExtVector:

4858 case Type::ConstantMatrix:

4860 case Type::FunctionNoProto:

4862 case Type::FunctionProto: {

4864 CachedProperties result = Cache::get(FPT->getReturnType());

4865 for (const auto &ai : FPT->param_types())

4866 result = merge(result, Cache::get(ai));

4867 return result;

4868 }

4869 case Type::ObjCInterface: {

4871 return CachedProperties(L, false);

4872 }

4873 case Type::ObjCObject:

4875 case Type::ObjCObjectPointer:

4877 case Type::Atomic:

4879 case Type::Pipe:

4881 case Type::HLSLAttributedResource:

4883 case Type::HLSLInlineSpirv:

4885 }

4886

4887 llvm_unreachable("unhandled type class");

4888}

4889

4890

4893 return TypeBits.getLinkage();

4894}

4895

4898 return TypeBits.hasLocalOrUnnamedType();

4899}

4900

4902 switch (T->getTypeClass()) {

4903#define TYPE(Class, Base)

4904#define NON_CANONICAL_TYPE(Class, Base) case Type::Class:

4905#include "clang/AST/TypeNodes.inc"

4906 llvm_unreachable("didn't expect a non-canonical type here");

4907

4908#define TYPE(Class, Base)

4909#define DEPENDENT_TYPE(Class, Base) case Type::Class:

4910#define NON_CANONICAL_UNLESS_DEPENDENT_TYPE(Class, Base) case Type::Class:

4911#include "clang/AST/TypeNodes.inc"

4912

4913 assert(T->isInstantiationDependentType());

4915

4916 case Type::BitInt:

4917 case Type::Builtin:

4919

4920 case Type::Auto:

4921 case Type::DeducedTemplateSpecialization:

4923

4924 case Type::Record:

4925 case Type::Enum:

4928

4929 case Type::Complex:

4931 case Type::Pointer:

4933 case Type::BlockPointer:

4935 case Type::LValueReference:

4936 case Type::RValueReference:

4938 case Type::MemberPointer: {

4941 if (auto *D = MPT->getMostRecentCXXRecordDecl()) {

4943 } else {

4945 }

4947 return LV;

4948 }

4949 case Type::ConstantArray:

4950 case Type::IncompleteArray:

4951 case Type::VariableArray:

4952 case Type::ArrayParameter:

4954 case Type::Vector:

4955 case Type::ExtVector:

4957 case Type::ConstantMatrix:

4960 case Type::FunctionNoProto:

4962 case Type::FunctionProto: {

4965 for (const auto &ai : FPT->param_types())

4967 return LV;

4968 }

4969 case Type::ObjCInterface:

4971 case Type::ObjCObject:

4973 case Type::ObjCObjectPointer:

4976 case Type::Atomic:

4978 case Type::Pipe:

4980 case Type::HLSLAttributedResource:

4982 ->getContainedType()

4983 ->getCanonicalTypeInternal());

4984 case Type::HLSLInlineSpirv:

4986 }

4987

4988 llvm_unreachable("unhandled type class");

4989}

4990

4992 if (TypeBits.isCacheValid())

4993 return true;

4994

4998 return L == TypeBits.getLinkage();

4999}

5000

5002 if (T->isCanonicalUnqualified())

5004

5006 assert(LV.getLinkage() == T->getLinkage());

5007 return LV;

5008}

5009

5013

5016 while (const auto *AT = Type->getAs()) {

5017

5018

5019 if (auto Nullability = AT->getImmediateNullability())

5020 return Nullability;

5021

5022 Type = AT->getEquivalentType();

5023 }

5024 return std::nullopt;

5025}

5026

5029

5030 switch (type->getTypeClass()) {

5031#define NON_CANONICAL_TYPE(Class, Parent) \

5032 \

5033 case Type::Class: \

5034 llvm_unreachable("non-canonical type");

5035#define TYPE(Class, Parent)

5036#include "clang/AST/TypeNodes.inc"

5037

5038

5039 case Type::Pointer:

5040 case Type::BlockPointer:

5041 case Type::MemberPointer:

5042 case Type::ObjCObjectPointer:

5043 return true;

5044

5045

5046 case Type::UnresolvedUsing:

5047 case Type::TypeOfExpr:

5048 case Type::TypeOf:

5049 case Type::Decltype:

5050 case Type::PackIndexing:

5051 case Type::UnaryTransform:

5052 case Type::TemplateTypeParm:

5053 case Type::SubstTemplateTypeParmPack:

5054 case Type::SubstBuiltinTemplatePack:

5055 case Type::DependentName:

5056 case Type::Auto:

5057 return ResultIfUnknown;

5058

5059

5060 case Type::TemplateSpecialization:

5061

5064 ->getTemplateName()

5065 .getAsTemplateDecl())

5066 if (auto *CTD = dyn_cast(templateDecl))

5067 return llvm::any_of(

5069 return RTD->getTemplatedDecl()->hasAttr();

5070 });

5071 return ResultIfUnknown;

5072

5073 case Type::Builtin:

5075

5076#define SIGNED_TYPE(Id, SingletonId) case BuiltinType::Id:

5077#define UNSIGNED_TYPE(Id, SingletonId) case BuiltinType::Id:

5078#define FLOATING_TYPE(Id, SingletonId) case BuiltinType::Id:

5079#define BUILTIN_TYPE(Id, SingletonId)

5080#include "clang/AST/BuiltinTypes.def"

5081 return false;

5082

5083 case BuiltinType::UnresolvedTemplate:

5084

5085 case BuiltinType::Dependent:

5086 case BuiltinType::Overload:

5087 case BuiltinType::BoundMember:

5088 case BuiltinType::PseudoObject:

5089 case BuiltinType::UnknownAny:

5090 case BuiltinType::ARCUnbridgedCast:

5091 return ResultIfUnknown;

5092

5093 case BuiltinType::Void:

5094 case BuiltinType::ObjCId:

5095 case BuiltinType::ObjCClass:

5096 case BuiltinType::ObjCSel:

5097#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \

5098 case BuiltinType::Id:

5099#include "clang/Basic/OpenCLImageTypes.def"

5100#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) case BuiltinType::Id:

5101#include "clang/Basic/OpenCLExtensionTypes.def"

5102 case BuiltinType::OCLSampler:

5103 case BuiltinType::OCLEvent:

5104 case BuiltinType::OCLClkEvent:

5105 case BuiltinType::OCLQueue:

5106 case BuiltinType::OCLReserveID:

5107#define SVE_TYPE(Name, Id, SingletonId) case BuiltinType::Id:

5108#include "clang/Basic/AArch64ACLETypes.def"

5109#define PPC_VECTOR_TYPE(Name, Id, Size) case BuiltinType::Id:

5110#include "clang/Basic/PPCTypes.def"

5111#define RVV_TYPE(Name, Id, SingletonId) case BuiltinType::Id:

5112#include "clang/Basic/RISCVVTypes.def"

5113#define WASM_TYPE(Name, Id, SingletonId) case BuiltinType::Id:

5114#include "clang/Basic/WebAssemblyReferenceTypes.def"

5115#define AMDGPU_TYPE(Name, Id, SingletonId, Width, Align) case BuiltinType::Id:

5116#include "clang/Basic/AMDGPUTypes.def"

5117#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) case BuiltinType::Id:

5118#include "clang/Basic/HLSLIntangibleTypes.def"

5119 case BuiltinType::BuiltinFn:

5120 case BuiltinType::NullPtr:

5121 case BuiltinType::IncompleteMatrixIdx:

5122 case BuiltinType::ArraySection:

5123 case BuiltinType::OMPArrayShaping:

5124 case BuiltinType::OMPIterator:

5125 return false;

5126 }

5127 llvm_unreachable("unknown builtin type");

5128

5129 case Type::Record: {

5131

5132

5133 if (const auto *CTSD = dyn_cast(RD))

5134 return llvm::any_of(

5135 CTSD->getSpecializedTemplate()->redecls(),

5137 return RTD->getTemplatedDecl()->hasAttr();

5138 });

5139 return llvm::any_of(RD->redecls(), [](const TagDecl *RD) {

5140 return RD->hasAttr();

5141 });

5142 }

5143

5144

5145 case Type::Complex:

5146 case Type::LValueReference:

5147 case Type::RValueReference:

5148 case Type::ConstantArray:

5149 case Type::IncompleteArray:

5150 case Type::VariableArray:

5151 case Type::DependentSizedArray:

5152 case Type::DependentVector:

5153 case Type::DependentSizedExtVector:

5154 case Type::Vector:

5155 case Type::ExtVector:

5156 case Type::ConstantMatrix:

5157 case Type::DependentSizedMatrix:

5158 case Type::DependentAddressSpace:

5159 case Type::FunctionProto:

5160 case Type::FunctionNoProto:

5161 case Type::DeducedTemplateSpecialization:

5162 case Type::Enum:

5163 case Type::InjectedClassName:

5164 case Type::PackExpansion:

5165 case Type::ObjCObject:

5166 case Type::ObjCInterface:

5167 case Type::Atomic:

5168 case Type::Pipe:

5169 case Type::BitInt:

5170 case Type::DependentBitInt:

5171 case Type::ArrayParameter:

5172 case Type::HLSLAttributedResource:

5173 case Type::HLSLInlineSpirv:

5174 return false;

5175 }

5176 llvm_unreachable("bad type kind!");

5177}

5178

5179std::optional AttributedType::getImmediateNullability() const {

5180 if (getAttrKind() == attr::TypeNonNull)

5182 if (getAttrKind() == attr::TypeNullable)

5184 if (getAttrKind() == attr::TypeNullUnspecified)

5186 if (getAttrKind() == attr::TypeNullableResult)

5188 return std::nullopt;

5189}

5190

5191std::optional

5192AttributedType::stripOuterNullability(QualType &T) {

5194 if (auto MacroTy = dyn_cast(T))

5195 AttrTy = MacroTy->getUnderlyingType();

5196

5197 if (auto attributed = dyn_cast(AttrTy)) {

5198 if (auto nullability = attributed->getImmediateNullability()) {

5199 T = attributed->getModifiedType();

5200 return nullability;

5201 }

5202 }

5203

5204 return std::nullopt;

5205}

5206

5212

5215 if (!objcPtr)

5216 return false;

5217

5218 if (objcPtr->isObjCIdType()) {

5219

5220 return true;

5221 }

5222

5223

5226 return false;

5227

5228

5229 } else if (objcPtr->isObjCQualifiedIdType()) {

5230

5231 } else {

5232 return false;

5233 }

5234

5235

5237

5240 return false;

5241 }

5242

5243 return true;

5244}

5245

5251

5254 "cannot query implicit lifetime for non-inferrable type");

5255

5257

5258

5259 while (const auto *array = dyn_cast(canon))

5260 canon = array->getElementType().getTypePtr();

5261

5262 if (const auto *opt = dyn_cast(canon)) {

5263

5264 if (opt->getObjectType()->isObjCClass())

5265 return true;

5266 }

5267

5268 return false;

5269}

5270

5273 return typedefType->getDecl()->hasAttr();

5274 return false;

5275}

5276

5279 return typedefType->getDecl()->hasAttr();

5280 return false;

5281}

5282

5287

5290 return true;

5292 return OPT->getPointeeType()->isObjCIndirectLifetimeType();

5294 return Ref->getPointeeType()->isObjCIndirectLifetimeType();

5296 return MemPtr->getPointeeType()->isObjCIndirectLifetimeType();

5297 return false;

5298}

5299

5300

5301

5304 while (const ArrayType *array = type->getAsArrayTypeUnsafe())

5305 type = array->getElementType().getTypePtr();

5306 return type->isObjCRetainableType();

5307}

5308

5309

5310

5314

5315

5319 return false;

5320

5323}

5324

5325

5328 return RT->getDecl()

5329 ->getMostRecentDecl()

5330 ->hasAttr();

5331 return false;

5332}

5333

5334

5337 return RT->getDecl()

5338 ->getMostRecentDecl()

5339 ->hasAttr();

5340 return false;

5341}

5342

5345 return false;

5346

5348 return ptr->getPointeeType()->hasSizedVLAType();

5350 return ref->getPointeeType()->hasSizedVLAType();

5354 return true;

5355

5356 return arr->getElementType()->hasSizedVLAType();

5357 }

5358

5359 return false;

5360}

5361

5363 return HLSLAttributedResourceType::findHandleTypeOnResource(this) != nullptr;

5364}

5365

5374

5377

5378

5381

5382

5385

5386 const RecordType *RT =

5388 if (!RT)

5389 return false;

5390

5392 assert(RD != nullptr &&

5393 "all HLSL structs and classes should be CXXRecordDecl");

5396}

5397

5399 switch (type.getObjCLifetime()) {

5403 break;

5404

5409 }

5410

5411 if (const auto *RD = type->getBaseElementTypeUnsafe()->getAsRecordDecl()) {

5412 if (const auto *CXXRD = dyn_cast(RD)) {

5413

5414 if (CXXRD->hasDefinition() && !CXXRD->hasTrivialDestructor())

5416 } else {

5417

5418

5421 }

5422 }

5423

5425}

5426

5430 assert(!D1 == !D2);

5432}

5433

5438 Qualifier.Profile(ID);

5439 if (Cls)

5441}

5442

5443CXXRecordDecl *MemberPointerType::getCXXRecordDecl() const {

5447}

5448

5450 auto *RD = getCXXRecordDecl();

5451 if (!RD)

5452 return nullptr;

5454}

5455

5457 llvm::APSInt Val, unsigned Scale) {

5458 llvm::FixedPointSemantics FXSema(Val.getBitWidth(), Scale, Val.isSigned(),

5459 false,

5460 false);

5461 llvm::APFixedPoint(Val, FXSema).toString(Str);

5462}

5463

5468 : DeducedType(Auto, DeducedAsType, ExtraDependence, Canon) {

5469 AutoTypeBits.Keyword = llvm::to_underlying(Keyword);

5470 AutoTypeBits.NumArgs = TypeConstraintArgs.size();

5471 this->TypeConstraintConcept = TypeConstraintConcept;

5472 assert(TypeConstraintConcept || AutoTypeBits.NumArgs == 0);

5473 if (TypeConstraintConcept) {

5475 addDependence(TypeDependence::DependentInstantiation);

5476

5477 auto *ArgBuffer =

5478 const_cast<TemplateArgument *>(getTypeConstraintArguments().data());

5480

5481

5482 addDependence(

5484

5486 }

5487 }

5488}

5489

5490void AutoType::Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context,

5495 ID.AddInteger((unsigned)Keyword);

5496 ID.AddBoolean(IsDependent);

5497 ID.AddPointer(CD);

5499 Arg.Profile(ID, Context);

5500}

5501

5502void AutoType::Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context) {

5503 Profile(ID, Context, getDeducedType(), getKeyword(), isDependentType(),

5504 getTypeConstraintConcept(), getTypeConstraintArguments());

5505}

5506

5508 switch (kind()) {

5517 }

5518 llvm_unreachable("unknown effect kind");

5519}

5520

5522 switch (kind()) {

5524 return "nonblocking";

5526 return "nonallocating";

5528 return "blocking";

5530 return "allocating";

5531 }

5532 llvm_unreachable("unknown effect kind");

5533}

5534

5537 switch (kind()) {

5541

5543 return Effect;

5544

5546 return Effect;

5547 }

5548 return std::nullopt;

5549 }

5550

5553 assert(0 && "effectProhibitingInference with non-inferable effect kind");

5554 break;

5555 }

5556 llvm_unreachable("unknown effect kind");

5557}

5558

5561 switch (kind()) {

5564 const Kind CallerKind = kind();

5566 const Kind EK = Effect.kind();

5567

5568 if (EK == CallerKind ||

5570 return false;

5571 }

5572 }

5573 return true;

5574 }

5577 return false;

5578 }

5579 llvm_unreachable("unknown effect kind");

5580}

5581

5582

5583

5588

5589

5590

5591 unsigned InsertIdx = Effects.size();

5592 unsigned Idx = 0;

5594

5595

5596

5597 if (EC.Cond.getCondition() == nullptr && NewCondition == nullptr) {

5599

5600

5601

5602 return true;

5603 }

5604

5605 if (EC.Effect.kind() == NewOppositeKind) {

5606 Errs.push_back({EC, NewEC});

5607 return false;

5608 }

5609 }

5610

5612 InsertIdx = Idx;

5613

5614 ++Idx;

5615 }

5616

5617 if (NewCondition || !Conditions.empty()) {

5618 if (Conditions.empty() && !Effects.empty())

5619 Conditions.resize(Effects.size());

5620 Conditions.insert(Conditions.begin() + InsertIdx,

5622 }

5623 Effects.insert(Effects.begin() + InsertIdx, NewEC.Effect);

5624 return true;

5625}

5626

5628 for (const auto &Item : Set)

5630 return Errs.empty();

5631}

5632

5637

5638

5639

5640

5641 auto IterA = LHS.begin(), EndA = LHS.end();

5642 auto IterB = RHS.begin(), EndB = RHS.end();

5643

5646 return std::tuple(LHS.Effect, uintptr_t(LHS.Cond.getCondition())) <

5647 std::tuple(RHS.Effect, uintptr_t(RHS.Cond.getCondition()));

5648 };

5649

5650 while (IterA != EndA && IterB != EndB) {

5653 if (FEWCLess(A, B))

5654 ++IterA;

5655 else if (FEWCLess(B, A))

5656 ++IterB;

5657 else {

5658 Result.insert(A, Errs);

5659 ++IterA;

5660 ++IterB;

5661 }

5662 }

5663

5664

5665

5666 assert(Errs.empty() && "conflict shouldn't be possible in getIntersection");

5667

5669}

5670

5674

5675 if (LHS.empty())

5677

5679 Combined.insert(RHS, Errs);

5680 return Combined;

5681}

5682

5683namespace clang {

5684

5689 OS << '(';

5691 OS << ')';

5692 }

5693 return OS;

5694}

5695

5696}

5697

5699 OS << "Effects{";

5700 llvm::interleaveComma(*this, OS);

5701 OS << "}";

5702}

5703

5707

5709 OS << "Effects{";

5710 llvm::interleaveComma(*this, OS);

5711 OS << "}";

5712}

5713

5717 assert(llvm::is_sorted(FX) && "effects should be sorted");

5718 assert((Conds.empty() || Conds.size() == FX.size()) &&

5719 "effects size should match conditions size");

5721}

5722

5725 if (Cond.getCondition() != nullptr)

5728}

5729

5730const HLSLAttributedResourceType *

5731HLSLAttributedResourceType::findHandleTypeOnResource(const Type *RT) {

5732

5733

5736 if (!RD->fields().empty()) {

5737 const auto &FirstFD = RD->fields().begin();

5738 return dyn_cast(

5739 FirstFD->getType().getTypePtr());

5740 }

5741 }

5742 return nullptr;

5743}

5744

5745StringRef PredefinedSugarType::getName(Kind KD) {

5746 switch (KD) {

5748 return "__size_t";

5750 return "__signed_size_t";

5752 return "__ptrdiff_t";

5753 }

5754 llvm_unreachable("unexpected kind");

5755}

Defines the clang::ASTContext interface.

Provides definitions for the various language-specific address spaces.

static std::optional< NonLoc > getIndex(ProgramStateRef State, const ElementRegion *ER, CharKind CK)

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.

static DeclT * getDefinitionOrSelf(DeclT *D)

Defines the ExceptionSpecificationType enumeration and various utility functions.

TokenType getType() const

Returns the token's type, e.g.

Defines the clang::IdentifierInfo, clang::IdentifierTable, and clang::Selector interfaces.

#define CC_VLS_CASE(ABI_VLEN)

Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified.

Defines the clang::LangOptions interface.

llvm::MachO::Record Record

static QualType getUnderlyingType(const SubRegion *R)

static RecordDecl * getAsRecordDecl(QualType BaseType, HeuristicResolver &Resolver)

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 TypeDependence getTemplateSpecializationTypeDependence(QualType Underlying, TemplateName T)

Definition Type.cpp:4577

#define ENUMERATE_ATTRS(PREFIX)

#define SUGARED_TYPE_CLASS(Class)

Definition Type.cpp:1001

TypePropertyCache< Private > Cache

Definition Type.cpp:4785

static bool isTriviallyCopyableTypeImpl(const QualType &type, const ASTContext &Context, bool IsCopyConstructible)

Definition Type.cpp:2815

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...

Definition Type.cpp:607

#define TRIVIAL_TYPE_CLASS(Class)

Definition Type.cpp:999

static CachedProperties computeCachedProperties(const Type *T)

Definition Type.cpp:4787

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 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 getAttributedType(attr::Kind attrKind, QualType modifiedType, QualType equivalentType, const Attr *attr=nullptr) const

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, UnsignedOrNone PackIndex, bool Final) 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'.

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.

QualType getVariableArrayType(QualType EltTy, Expr *NumElts, ArraySizeModifier ASM, unsigned IndexTypeQuals) const

Return a non-unique reference to the type for a variable array of the specified element type.

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.

QualType getAutoType(QualType DeducedType, AutoTypeKeyword Keyword, bool IsDependent, bool IsPack=false, TemplateDecl *TypeConstraintConcept=nullptr, ArrayRef< TemplateArgument > TypeConstraintArgs={}) const

C++11 deduced auto type.

CanQualType UnsignedCharTy

TemplateName getQualifiedTemplateName(NestedNameSpecifier Qualifier, bool TemplateKeyword, TemplateName Template) const

Retrieve the template name that represents a qualified template name such as std::vector.

QualType getFunctionType(QualType ResultTy, ArrayRef< QualType > Args, const FunctionProtoType::ExtProtoInfo &EPI) const

Return a normal function type with a typed argument list.

QualType getMemberPointerType(QualType T, NestedNameSpecifier Qualifier, const CXXRecordDecl *Cls) const

Return the uniqued reference to the type for a member pointer to the specified type in the specified ...

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 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'.

QualType getConstantArrayType(const ASTContext &Ctx) const

Definition Type.cpp:279

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)

Definition Type.cpp:174

Attr - This represents one attribute.

BitIntType(bool isUnsigned, unsigned NumBits)

Definition Type.cpp:424

[BoundsSafety] Represents a parent type class for CountAttributedType and similar sugar types that wi...

BoundsAttributedType(TypeClass TC, QualType Wrapped, QualType Canon)

Definition Type.cpp:3980

decl_range dependent_decls() const

bool referencesFieldDecls() const

Definition Type.cpp:448

This class is used for builtin types like 'int'.

StringRef getName(const PrintingPolicy &Policy) const

Definition Type.cpp:3362

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

bool mayBeDynamicClass() const

CXXRecordDecl * getCanonicalDecl() override

Retrieves the "canonical" declaration of the given declaration.

Declaration of a class template.

Complex values, per C99 6.2.5p11.

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.

Definition Type.cpp:214

static unsigned getMaxSizeBits(const ASTContext &Context)

Determine the maximum number of active bits that an array's size can require, which limits the maximu...

Definition Type.cpp:254

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

ConstantMatrixType(QualType MatrixElementType, unsigned NRows, unsigned NColumns, QualType CanonElementType)

Definition Type.cpp:378

unsigned NumRows

Number of rows and columns.

Represents a sugar type with __counted_by or __sized_by annotations, including their _or_null variant...

void Profile(llvm::FoldingSetNodeID &ID)

StringRef getAttributeName(bool WithMacroPrefix) const

Definition Type.cpp:3997

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

void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context)

Expr * getNumBitsExpr() const

Definition Type.cpp:437

void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context)

DependentBitIntType(bool IsUnsigned, Expr *NumBits)

Definition Type.cpp:428

bool isUnsigned() const

Definition Type.cpp:433

void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context)

void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context)

void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context)

void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context)

void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context)

Expr * getCondition() const

This represents one expression.

bool isValueDependent() const

Determines whether the value 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

Represents a member of a struct/union/class.

A mutable set of FunctionEffect::Kind.

void dump(llvm::raw_ostream &OS) const

Definition Type.cpp:5708

FunctionEffectSet()=default

bool insert(const FunctionEffectWithCondition &NewEC, Conflicts &Errs)

Definition Type.cpp:5584

SmallVector< Conflict > Conflicts

static FunctionEffectSet getIntersection(FunctionEffectsRef LHS, FunctionEffectsRef RHS)

Definition Type.cpp:5633

void dump(llvm::raw_ostream &OS) const

Definition Type.cpp:5704

static FunctionEffectSet getUnion(FunctionEffectsRef LHS, FunctionEffectsRef RHS, Conflicts &Errs)

Definition Type.cpp:5671

Kind kind() const

The kind of the effect.

Kind

Identifies the particular effect.

bool shouldDiagnoseFunctionCall(bool Direct, FunctionEffectKindSet CalleeFX) const

Definition Type.cpp:5559

StringRef name() const

The description printed in diagnostics, e.g. 'nonblocking'.

Definition Type.cpp:5521

Kind oppositeKind() const

Return the opposite kind, for effects which have opposites.

Definition Type.cpp:5507

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 ...

Definition Type.cpp:5535

An immutable set of FunctionEffects and possibly conditions attached to them.

void dump(llvm::raw_ostream &OS) const

Definition Type.cpp:5698

ArrayRef< FunctionEffect > effects() const

ArrayRef< EffectConditionExpr > conditions() const

static FunctionEffectsRef create(ArrayRef< FunctionEffect > FX, ArrayRef< EffectConditionExpr > Conds)

Asserts invariants.

Definition Type.cpp:5715

FunctionEffectsRef()=default

bool hasDependentExceptionSpec() const

Return whether this function has a dependent exception spec.

Definition Type.cpp:3824

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.

Definition Type.cpp:3878

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)

Definition Type.cpp:3955

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.

Definition Type.cpp:3845

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.

Definition Type.cpp:3836

A class which abstracts out some details necessary for making a call.

ExtInfo getExtInfo() const

static StringRef getNameForCallConv(CallingConv CC)

Definition Type.cpp:3577

bool getCFIUncheckedCalleeAttr() const

Determine whether this is a function prototype that includes the cfi_unchecked_callee attribute.

Definition Type.cpp:3571

QualType getReturnType() const

FunctionType(TypeClass tc, QualType res, QualType Canonical, TypeDependence Dependence, ExtInfo Info)

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.

LinkageInfo computeTypeLinkageInfo(const Type *T)

Definition Type.cpp:4901

LinkageInfo getTypeLinkageAndVisibility(const Type *T)

Definition Type.cpp:5001

LinkageInfo getDeclLinkageAndVisibility(const NamedDecl *D)

static LinkageInfo external()

Linkage getLinkage() const

void merge(LinkageInfo other)

Merge both linkage and visibility.

QualType desugar() const

Definition Type.cpp:4071

QualType getModifiedType() const

Return this attributed type's modified type with no qualifiers attached to it.

Definition Type.cpp:4073

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.

NestedNameSpecifier getQualifier() const

bool isSugared() const

Definition Type.cpp:5427

void Profile(llvm::FoldingSetNodeID &ID)

CXXRecordDecl * getMostRecentCXXRecordDecl() const

Note: this can trigger extra deserialization when external AST sources are used.

Definition Type.cpp:5449

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::".

CXXRecordDecl * getAsRecordDecl() const

Retrieve the record declaration stored in this nested name specifier, or null.

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 * getCanonicalDecl() override

Retrieves the canonical declaration of this Objective-C class.

ObjCInterfaceDecl * getDefinition()

Retrieve the definition of this class, or NULL if this class has been forward-declared (with @class) ...

Represents typeof(type), a C23 feature and GCC extension, or `typeof_unqual(type),...

ObjCInterfaceDecl * getDecl() const

Get the declaration of this interface.

Definition Type.cpp:951

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.

Definition Type.cpp:958

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.

Definition Type.cpp:1850

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.

Definition Type.cpp:1840

bool isKindOfType() const

Whether this is a "__kindof" type.

Represents an Objective-C protocol declaration.

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.

A (possibly-)qualified type.

bool hasAddressDiscriminatedPointerAuth() const

bool isTriviallyCopyableType(const ASTContext &Context) const

Return true if this is a trivially copyable type (C++0x [basic.types]p9)

Definition Type.cpp:2866

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.

Definition Type.cpp:2947

QualType getNonLValueExprType(const ASTContext &Context) const

Determine the type of a (typically non-lvalue) expression with the specified result type.

Definition Type.cpp:3555

@ 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.

Definition Type.cpp:130

bool isNonWeakInMRRWithObjCWeak(const ASTContext &Context) const

Definition Type.cpp:2920

const IdentifierInfo * getBaseTypeIdentifier() const

Retrieves a pointer to the name of the base type.

Definition Type.cpp:109

bool isBitwiseCloneableType(const ASTContext &Context) const

Return true if the type is safe to bitwise copy using memcpy/memmove.

Definition Type.cpp:2872

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.

Definition Type.cpp:2914

bool isTrivialType(const ASTContext &Context) const

Return true if this is a trivial type per (C++0x [basic.types]p9)

Definition Type.cpp:2757

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 ...

Definition Type.cpp:2969

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...

Definition Type.cpp:2702

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.

Definition Type.cpp:1663

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...

Definition Type.cpp:1654

bool isWebAssemblyReferenceType() const

Returns true if it is a WebAssembly Reference Type.

Definition Type.cpp:2939

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.

Definition Type.cpp:151

SplitQualType split() const

Divides a QualType into its unqualified type and a set of local qualifiers.

bool UseExcessPrecision(const ASTContext &Ctx)

Definition Type.cpp:1612

PrimitiveDefaultInitializeKind isNonTrivialToPrimitiveDefaultInitialize() const

Functions to query basic properties of non-trivial C struct types.

Definition Type.cpp:2953

void * getAsOpaquePtr() const

bool isWebAssemblyExternrefType() const

Returns true if it is a WebAssembly Externref Type.

Definition Type.cpp:2943

QualType getNonPackExpansionType() const

Remove an outer pack expansion type (if any) from this type.

Definition Type.cpp:3548

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,...

Definition Type.cpp:3111

bool mayBeNotDynamicClass() const

Returns true if it is not a class or if the class might not be dynamic.

Definition Type.cpp:135

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.

Definition Type.cpp:1647

QualType getAtomicUnqualifiedType() const

Remove all qualifiers including _Atomic.

Definition Type.cpp:1670

bool hasNonTrivialObjCLifetime() const

bool isPODType(const ASTContext &Context) const

Determine whether this is a Plain Old Data (POD) type (C++ 3.9p10).

Definition Type.cpp:2694

PrimitiveCopyKind isNonTrivialToPrimitiveDestructiveMove() const

Check if this is a non-trivial type that would cause a C struct transitively containing this type to ...

Definition Type.cpp:2989

@ 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_PtrAuth

The type is an address-discriminated signed pointer type.

@ 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.

Definition Type.cpp:4659

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,...

Definition Type.cpp:57

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)

Definition Type.cpp:72

bool hasAddressSpace() const

unsigned getFastQualifiers() const

bool hasObjCGCAttr() const

bool hasObjCLifetime() const

ObjCLifetime getObjCLifetime() const

LangAS getAddressSpace() const

Represents a struct/union/class.

bool hasNonTrivialToPrimitiveDestructCUnion() const

bool hasNonTrivialToPrimitiveCopyCUnion() const

bool hasNonTrivialToPrimitiveDefaultInitializeCUnion() const

bool isNonTrivialToPrimitiveDestroy() const

bool isNonTrivialToPrimitiveCopy() const

field_range fields() const

RecordDecl * getMostRecentDecl()

bool isNonTrivialToPrimitiveDefaultInitialize() const

Functions to query basic properties of non-trivial C structs.

Declaration of a redeclarable template.

Encodes a location in the source.

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().

Represents the declaration of a struct/union/class/enum.

redecl_range redecls() const

Returns an iterator range for all the redeclarations of the same decl.

bool isCompleteDefinition() const

Return true if this decl has its body fully specified.

NestedNameSpecifier getQualifier() const

Retrieve the nested-name-specifier that qualifies the name of this declaration, if it was present in ...

bool isDependentType() const

Whether this declaration declares a type that is dependent, i.e., a type that somehow depends on temp...

Exposes information about the current target.

virtual bool hasFullBFloat16Type() const

Determine whether the BFloat type is fully supported on this target, i.e arithemtic operations.

virtual bool hasFastHalfType() const

Determine whether the target has fast native support for operations on half types.

virtual bool hasFloat16Type() const

Determine whether the _Float16 type is supported on this target.

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.

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.

Declaration of a template type parameter.

[BoundsSafety] Represents information of declarations referenced by the arguments of the counted_by a...

ValueDecl * getDecl() const

Definition Type.cpp:3967

bool isDeref() const

Definition Type.cpp:3964

bool operator==(const TypeCoupledDeclRefInfo &Other) const

Definition Type.cpp:3972

void * getOpaqueValue() const

Definition Type.cpp:3969

TypeCoupledDeclRefInfo(ValueDecl *D=nullptr, bool Deref=false)

D is to a declaration referenced by the argument of attribute.

Definition Type.cpp:3961

unsigned getInt() const

Definition Type.cpp:3968

void setFromOpaqueValue(void *V)

Definition Type.cpp:3976

bool isSugared() const

Returns whether this type directly provides sugar.

Definition Type.cpp:4100

TypeOfKind getKind() const

Returns the kind of 'typeof' type this is.

TypeOfExprType(const ASTContext &Context, Expr *E, TypeOfKind Kind, QualType Can=QualType())

Definition Type.cpp:4085

Expr * getUnderlyingExpr() const

QualType desugar() const

Remove a single level of sugar.

Definition Type.cpp:4102

The type-property cache.

Definition Type.cpp:4740

static void ensure(const Type *T)

Definition Type.cpp:4750

static CachedProperties get(QualType T)

Definition Type.cpp:4742

static CachedProperties get(const Type *T)

Definition Type.cpp:4744

A helper class for Type nodes having an ElaboratedTypeKeyword.

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.

Definition Type.cpp:2567

bool isStructureType() const

Definition Type.cpp:678

bool isBlockPointerType() const

const ObjCObjectPointerType * getAsObjCQualifiedClassType() const

Definition Type.cpp:1883

bool isLinkageValid() const

True if the computed linkage is valid.

Definition Type.cpp:4991

TypedefBitfields TypedefBits

bool isBooleanType() const

const ObjCObjectType * getAsObjCQualifiedInterfaceType() const

Definition Type.cpp:1859

const ObjCObjectPointerType * getAsObjCQualifiedIdType() const

Definition Type.cpp:1873

const TemplateSpecializationType * getAsNonAliasTemplateSpecializationType() const

Look through sugar for an instance of TemplateSpecializationType which is not a type alias,...

Definition Type.cpp:1921

bool isMFloat8Type() const

bool isSignedIntegerOrEnumerationType() const

Determines whether this is an integer type that is signed or an enumeration types whose underlying ty...

Definition Type.cpp:2225

bool isPackedVectorBoolType(const ASTContext &ctx) const

Definition Type.cpp:418

bool hasAttr(attr::Kind AK) const

Determine whether this type had the specified attribute applied to it (looking through top-level type...

Definition Type.cpp:1951

bool isAlwaysIncompleteType() const

Definition Type.cpp:2515

QualType getRVVEltType(const ASTContext &Ctx) const

Returns the representative type for the element of an RVV builtin type.

Definition Type.cpp:2677

const RecordType * getAsUnionType() const

NOTE: getAs*ArrayType are methods on ASTContext.

Definition Type.cpp:787

bool isLiteralType(const ASTContext &Ctx) const

Return true if this is a literal type (C++11 [basic.types]p10)

Definition Type.cpp:2993

bool isSignedIntegerType() const

Return true if this is an integer type that is signed, according to C99 6.2.5p4 [char,...

Definition Type.cpp:2205

bool isComplexType() const

isComplexType() does not include complex integers (a GCC extension).

Definition Type.cpp:724

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 ...

Definition Type.cpp:2273

bool isIntegralOrUnscopedEnumerationType() const

Determine whether this type is an integral or unscoped enumeration type.

Definition Type.cpp:2115

CXXRecordDecl * getAsCXXRecordDecl() const

Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...

VectorTypeBitfields VectorTypeBits

SubstPackTypeBitfields SubstPackTypeBits

bool isNothrowT() const

Definition Type.cpp:3170

RecordDecl * getAsRecordDecl() const

Retrieves the RecordDecl this type refers to.

bool hasIntegerRepresentation() const

Determine whether this type has an integer representation of some sort, e.g., it is an integer type o...

Definition Type.cpp:2066

bool isVoidPointerType() const

Definition Type.cpp:712

const ComplexType * getAsComplexIntegerType() const

Definition Type.cpp:745

bool isConstantSizeType() const

Return true if this is not a variable sized type, according to the rules of C99 6....

Definition Type.cpp:2425

bool isCharType() const

Definition Type.cpp:2132

QualType getLocallyUnqualifiedSingleStepDesugaredType() const

Pull a single level of sugar off of this locally-unqualified type.

Definition Type.cpp:521

bool isFunctionPointerType() const

bool isCountAttributedType() const

Definition Type.cpp:741

bool isObjCARCBridgableType() const

Determine whether the given type T is a "bridgable" Objective-C type, which is either an Objective-C ...

Definition Type.cpp:5311

CXXRecordDecl * castAsCXXRecordDecl() const

bool isArithmeticType() const

Definition Type.cpp:2337

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.

Definition Type.cpp:2573

const T * castAs() const

Member-template castAs.

bool isReferenceType() const

bool isHLSLIntangibleType() const

Definition Type.cpp:5375

bool isEnumeralType() const

void addDependence(TypeDependence D)

bool isObjCNSObjectType() const

Definition Type.cpp:5271

Type(TypeClass tc, QualType canon, TypeDependence Dependence)

const ObjCObjectPointerType * getAsObjCInterfacePointerType() const

Definition Type.cpp:1901

NestedNameSpecifier getPrefix() const

If this type represents a qualified-id, this returns its nested name specifier.

Definition Type.cpp:1928

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.

Definition Type.cpp:1909

bool isInterfaceType() const

Definition Type.cpp:700

bool isVariableArrayType() const

bool isChar8Type() const

Definition Type.cpp:2148

bool isSizelessBuiltinType() const

Definition Type.cpp:2531

bool isCUDADeviceBuiltinSurfaceType() const

Check if the type is the CUDA device builtin surface type.

Definition Type.cpp:5326

bool isSveVLSBuiltinType() const

Determines if this is a sizeless type supported by the 'arm_sve_vector_bits' type attribute,...

Definition Type.cpp:2607

bool isIntegralType(const ASTContext &Ctx) const

Determine whether this type is an integral type.

Definition Type.cpp:2103

bool isElaboratedTypeSpecifier() const

Determine wither this type is a C++ elaborated-type-specifier.

Definition Type.cpp:3330

CountAttributedTypeBitfields CountAttributedTypeBits

const Type * getArrayElementTypeNoTypeQual() const

If this is an array type, return the element type of the array, potentially with type qualifiers miss...

Definition Type.cpp:471

bool isAlignValT() const

Definition Type.cpp:3179

QualType getPointeeType() const

If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee.

Definition Type.cpp:752

LinkageInfo getLinkageAndVisibility() const

Determine the linkage and visibility of this type.

Definition Type.cpp:5010

bool hasUnsignedIntegerRepresentation() const

Determine whether this type has an unsigned integer representation of some sort, e....

Definition Type.cpp:2291

bool isAnyCharacterType() const

Determine whether this type is any of the built-in character types.

Definition Type.cpp:2168

bool isExtVectorBoolType() const

bool isWebAssemblyExternrefType() const

Check if this is a WebAssembly Externref Type.

Definition Type.cpp:2551

bool canHaveNullability(bool ResultIfUnknown=true) const

Determine whether the given type can have a nullability specifier applied to it, i....

Definition Type.cpp:5027

QualType getSveEltType(const ASTContext &Ctx) const

Returns the representative type for the element of an SVE builtin type.

Definition Type.cpp:2646

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.

Definition Type.cpp:3058

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.

Definition Type.cpp:2411

bool isCARCBridgableType() const

Determine whether the given type T is a "bridgeable" C type.

Definition Type.cpp:5316

bool isSignableIntegerType(const ASTContext &Ctx) const

Definition Type.cpp:5207

RecordDecl * castAsRecordDecl() const

bool isChar16Type() const

Definition Type.cpp:2154

bool isAnyComplexType() const

DeducedType * getContainedDeducedType() const

Get the DeducedType whose type will be deduced for a variable with an initializer of this type.

Definition Type.cpp:2056

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.

Definition Type.cpp:2364

bool hasSignedIntegerRepresentation() const

Determine whether this type has an signed integer representation of some sort, e.g....

Definition Type.cpp:2243

QualType getCanonicalTypeInternal() const

const RecordType * getAsStructureType() const

Definition Type.cpp:768

const char * getTypeClassName() const

Definition Type.cpp:3350

bool isWebAssemblyTableType() const

Returns true if this is a WebAssembly table type: either an array of reference types,...

Definition Type.cpp:2557

@ PtrdiffT

The "ptrdiff_t" type.

@ SizeT

The "size_t" type.

@ SignedSizeT

The signed integer type corresponding to "size_t".

const Type * getBaseElementTypeUnsafe() const

Get the base element type of this type, potentially discarding type qualifiers.

AttributedTypeBitfields AttributedTypeBits

bool isObjCBoxableRecordType() const

Definition Type.cpp:694

bool isChar32Type() const

Definition Type.cpp:2160

bool isStandardLayoutType() const

Test if this type is a standard-layout type.

Definition Type.cpp:3074

TagTypeBitfields TagTypeBits

EnumDecl * castAsEnumDecl() const

bool isVariablyModifiedType() const

Whether this type is a variably-modified type (C99 6.7.5).

bool isComplexIntegerType() const

Definition Type.cpp:730

bool isUnscopedEnumerationType() const

Definition Type.cpp:2125

bool isStdByteType() const

Definition Type.cpp:3189

UnresolvedUsingBitfields UnresolvedUsingBits

bool isCUDADeviceBuiltinTextureType() const

Check if the type is the CUDA device builtin texture type.

Definition Type.cpp:5335

bool isBlockCompatibleObjCPointerType(ASTContext &ctx) const

Definition Type.cpp:5213

bool isObjCClassOrClassKindOfType() const

Whether the type is Objective-C 'Class' or a __kindof type of an Class type, e.g.,...

Definition Type.cpp:834

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.

Definition Type.cpp:5302

bool isHLSLResourceRecord() const

Definition Type.cpp:5362

EnumDecl * getAsEnumDecl() const

Retrieves the EnumDecl this type refers to.

bool isObjCIndirectLifetimeType() const

Definition Type.cpp:5288

bool hasUnnamedOrLocalType() const

Whether this type is or contains a local or unnamed type.

Definition Type.cpp:4896

bool isPointerOrReferenceType() const

Qualifiers::ObjCLifetime getObjCARCImplicitLifetime() const

Return the implicit lifetime for this type, which must not be dependent.

Definition Type.cpp:5246

FunctionTypeBitfields FunctionTypeBits

bool isObjCQualifiedInterfaceType() const

Definition Type.cpp:1869

bool isSpecifierType() const

Returns true if this type can be represented by some set of type specifiers.

Definition Type.cpp:3199

bool isIncompleteType(NamedDecl **Def=nullptr) const

Types are partitioned into 3 broad categories (C99 6.2.5p1): object types, function types,...

Definition Type.cpp:2435

bool isObjCObjectPointerType() const

SubstTemplateTypeParmTypeBitfields SubstTemplateTypeParmTypeBits

bool isStructureTypeWithFlexibleArrayMember() const

Definition Type.cpp:684

TypeDependence getDependence() const

bool hasFloatingRepresentation() const

Determine whether this type has a floating-point representation of some sort, e.g....

Definition Type.cpp:2312

bool isStructureOrClassType() const

Definition Type.cpp:706

bool isVectorType() const

bool isRVVVLSBuiltinType() const

Determines if this is a sizeless type supported by the 'riscv_rvv_vector_bits' type attribute,...

Definition Type.cpp:2659

bool isRealFloatingType() const

Floating point categories.

Definition Type.cpp:2320

bool isRVVSizelessBuiltinType() const

Returns true for RVV scalable vector types.

Definition Type.cpp:2594

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...

Definition Type.cpp:1678

const T * getAsCanonical() const

If this type is canonically the specified type, return its canonical type cast to that specified type...

Linkage getLinkage() const

Determine the linkage of this type.

Definition Type.cpp:4891

ObjCObjectTypeBitfields ObjCObjectTypeBits

bool isFloatingType() const

Definition Type.cpp:2304

const ObjCObjectType * getAsObjCInterfaceType() const

Definition Type.cpp:1893

bool isWideCharType() const

Definition Type.cpp:2141

bool isUnsignedIntegerType() const

Return true if this is an integer type that is unsigned, according to C99 6.2.5p6 [which returns true...

Definition Type.cpp:2253

bool isRealType() const

Definition Type.cpp:2326

bool isClassType() const

Definition Type.cpp:672

bool hasSizedVLAType() const

Whether this type involves a variable-length array type with a definite size.

Definition Type.cpp:5343

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...

Definition Type.cpp:2061

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...

Definition Type.cpp:807

const T * getAs() const

Member-template getAs'.

const Type * getUnqualifiedDesugaredType() const

Return the specified type with any "sugar" removed from the type, removing any typedefs,...

Definition Type.cpp:653

bool isObjCARCImplicitlyUnretainedType() const

Determines if this type, which must satisfy isObjCLifetimeType(), is implicitly __unsafe_unretained r...

Definition Type.cpp:5252

bool isRecordType() const

bool isHLSLResourceRecordArray() const

Definition Type.cpp:5366

bool isObjCRetainableType() const

Definition Type.cpp:5283

std::optional< NullabilityKind > getNullability() const

Determine the nullability of the given type.

Definition Type.cpp:5014

bool isObjCIndependentClassType() const

Definition Type.cpp:5277

bool isUnionType() const

Definition Type.cpp:718

bool isSizelessVectorType() const

Returns true for all scalable vector types.

Definition Type.cpp:2569

bool isScopedEnumeralType() const

Determine whether this type is a scoped enumeration type.

Definition Type.cpp:735

bool acceptsObjCTypeParams() const

Determines if this is an ObjC interface type that may accept type parameters.

Definition Type.cpp:1759

QualType getSizelessVectorEltType(const ASTContext &Ctx) const

Returns the representative type for the element of a sizeless vector builtin type.

Definition Type.cpp:2634

bool isUnicodeCharacterType() const

Definition Type.cpp:2188

bool hasBooleanRepresentation() const

Determine whether this type has a boolean representation – i.e., it is a boolean type,...

Definition Type.cpp:2354

Base class for declarations which introduce a typedef-name.

QualType getUnderlyingType() const

QualType desugar() const

Definition Type.cpp:4040

bool typeMatchesDecl() const

Represents a dependent using declaration which was marked with typename.

Represents a shadow declaration implicitly introduced into a scope by a (resolved) using-declaration ...

Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...

Represents a GCC generic vector type.

VectorType(QualType vecType, unsigned nElements, QualType canonType, VectorKind vecKind)

Definition Type.cpp:407

QualType ElementType

The element type of the vector.

QualType getElementType() const

Defines the Linkage enumeration and various utility functions.

Defines the clang::TargetInfo interface.

mlir::Type getBaseType(mlir::Value varPtr)

@ AttributedType

The l-value was considered opaque, so the alignment was determined from a type, but that type was an ...

const internal::VariadicAllOfMatcher< Attr > attr

const internal::VariadicAllOfMatcher< Type > type

Matches Types in the clang AST.

const internal::VariadicAllOfMatcher< Decl > decl

Matches declarations.

const AstTypeMatcher< TypedefType > typedefType

RangeSelector merge(RangeSelector First, RangeSelector Second)

Selects the merge of the two ranges, i.e.

The JSON file list parser is used to communicate input to InstallAPI.

@ Overload

This is a legitimate overload: the existing declarations are functions or function templates with dif...

bool isa(CodeGen::Address addr)

if(T->getSizeExpr()) TRY_TO(TraverseStmt(const_cast< Expr * >(T -> getSizeExpr())))

AutoTypeKeyword

Which keyword(s) were used to create an AutoType.

CanThrowResult

Possible results from evaluation of a noexcept expression.

TypeDependenceScope::TypeDependence TypeDependence

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.

@ TemplateName

The identifier is a template name. FIXME: Add an annotation for that.

bool IsEnumDeclComplete(EnumDecl *ED)

Check if the given decl is complete.

bool isPackProducingBuiltinTemplateName(TemplateName N)

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.

nullptr

This class represents a compute construct, representing a 'Kind' of ‘parallel’, 'serial',...

TypeDependence toTypeDependence(ExprDependence D)

ExprDependence turnValueToTypeDependence(ExprDependence D)

@ Dependent

Parse the block as a dependent block, which may be used in some template instantiations but not other...

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.

const FunctionProtoType * T

bool isComputedNoexcept(ExceptionSpecificationType ESpecType)

@ Template

We are parsing a template declaration.

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.

@ Keyword

The name has been typo-corrected to a keyword.

@ Type

The name was classified as a type.

LangAS

Defines the address space values used by the address space qualifier of QualType.

void FixedPointValueToString(SmallVectorImpl< char > &Str, llvm::APSInt Val, unsigned Scale)

Definition Type.cpp:5456

std::tuple< NamedDecl *, TemplateArgument > getReplacedTemplateParameter(Decl *D, unsigned Index)

Internal helper used by Subst* nodes to retrieve a parameter from the AssociatedDecl,...

bool isPtrSizeAddressSpace(LangAS AS)

const StreamingDiagnostic & operator<<(const StreamingDiagnostic &DB, const ConceptReference *C)

Insertion operator for diagnostics.

CallingConv

CallingConv - Specifies the calling convention that a function uses.

U cast(CodeGen::Address addr)

@ 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....

FunctionEffectWithCondition(FunctionEffect E, const EffectConditionExpr &C)

std::string description() const

Return a textual description of the effect, and its condition, if any.

Definition Type.cpp:5723

void instantiate()

Definition Type.cpp:3646

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

FunctionTypeExtraAttributeInfo ExtraAttributeInfo

bool requiresFunctionProtoTypeArmAttributes() const

unsigned AArch64SMEAttributes

SourceLocation EllipsisLoc

FunctionEffectsRef FunctionEffects

unsigned CFIUncheckedCallee

const ExtParameterInfo * ExtParameterInfos

RefQualifierKind RefQualifier

bool requiresFunctionProtoTypeExtraAttributeInfo() const

unsigned HasTrailingReturn

bool requiresFunctionProtoTypeExtraBitfields() const

static StringRef getKeywordName(ElaboratedTypeKeyword Keyword)

Definition Type.cpp:3309

static ElaboratedTypeKeyword getKeywordForTagTypeKind(TagTypeKind Tag)

Converts a TagTypeKind into an elaborated type keyword.

Definition Type.cpp:3258

static TagTypeKind getTagTypeKindForKeyword(ElaboratedTypeKeyword Keyword)

Converts an elaborated type keyword into a TagTypeKind.

Definition Type.cpp:3275

static TagTypeKind getTagTypeKindForTypeSpec(unsigned TypeSpec)

Converts a type specifier (DeclSpec::TST) into a tag type kind.

Definition Type.cpp:3240

static bool KeywordIsTagTypeKind(ElaboratedTypeKeyword Keyword)

Definition Type.cpp:3294

static ElaboratedTypeKeyword getKeywordForTypeSpec(unsigned TypeSpec)

Converts a type specifier (DeclSpec::TST) into an elaborated type keyword.

Definition Type.cpp:3221

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.

constexpr unsigned toInternalRepresentation() const