File indexing completed on 2026-05-10 08:36:37
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014 #ifndef LLVM_CLANG_AST_EXPRCXX_H
0015 #define LLVM_CLANG_AST_EXPRCXX_H
0016
0017 #include "clang/AST/ASTConcept.h"
0018 #include "clang/AST/ComputeDependence.h"
0019 #include "clang/AST/Decl.h"
0020 #include "clang/AST/DeclBase.h"
0021 #include "clang/AST/DeclCXX.h"
0022 #include "clang/AST/DeclTemplate.h"
0023 #include "clang/AST/DeclarationName.h"
0024 #include "clang/AST/DependenceFlags.h"
0025 #include "clang/AST/Expr.h"
0026 #include "clang/AST/NestedNameSpecifier.h"
0027 #include "clang/AST/OperationKinds.h"
0028 #include "clang/AST/Stmt.h"
0029 #include "clang/AST/StmtCXX.h"
0030 #include "clang/AST/TemplateBase.h"
0031 #include "clang/AST/Type.h"
0032 #include "clang/AST/UnresolvedSet.h"
0033 #include "clang/Basic/ExceptionSpecificationType.h"
0034 #include "clang/Basic/ExpressionTraits.h"
0035 #include "clang/Basic/LLVM.h"
0036 #include "clang/Basic/Lambda.h"
0037 #include "clang/Basic/LangOptions.h"
0038 #include "clang/Basic/OperatorKinds.h"
0039 #include "clang/Basic/SourceLocation.h"
0040 #include "clang/Basic/Specifiers.h"
0041 #include "clang/Basic/TypeTraits.h"
0042 #include "llvm/ADT/ArrayRef.h"
0043 #include "llvm/ADT/PointerUnion.h"
0044 #include "llvm/ADT/StringRef.h"
0045 #include "llvm/ADT/iterator_range.h"
0046 #include "llvm/Support/Casting.h"
0047 #include "llvm/Support/Compiler.h"
0048 #include "llvm/Support/TrailingObjects.h"
0049 #include <cassert>
0050 #include <cstddef>
0051 #include <cstdint>
0052 #include <memory>
0053 #include <optional>
0054
0055 namespace clang {
0056
0057 class ASTContext;
0058 class DeclAccessPair;
0059 class IdentifierInfo;
0060 class LambdaCapture;
0061 class NonTypeTemplateParmDecl;
0062 class TemplateParameterList;
0063
0064
0065
0066
0067
0068
0069
0070
0071
0072
0073
0074
0075
0076
0077
0078
0079
0080
0081 class CXXOperatorCallExpr final : public CallExpr {
0082 friend class ASTStmtReader;
0083 friend class ASTStmtWriter;
0084
0085 SourceRange Range;
0086
0087
0088
0089
0090 SourceRange getSourceRangeImpl() const LLVM_READONLY;
0091
0092 CXXOperatorCallExpr(OverloadedOperatorKind OpKind, Expr *Fn,
0093 ArrayRef<Expr *> Args, QualType Ty, ExprValueKind VK,
0094 SourceLocation OperatorLoc, FPOptionsOverride FPFeatures,
0095 ADLCallKind UsesADL);
0096
0097 CXXOperatorCallExpr(unsigned NumArgs, bool HasFPFeatures, EmptyShell Empty);
0098
0099 public:
0100 static CXXOperatorCallExpr *
0101 Create(const ASTContext &Ctx, OverloadedOperatorKind OpKind, Expr *Fn,
0102 ArrayRef<Expr *> Args, QualType Ty, ExprValueKind VK,
0103 SourceLocation OperatorLoc, FPOptionsOverride FPFeatures,
0104 ADLCallKind UsesADL = NotADL);
0105
0106 static CXXOperatorCallExpr *CreateEmpty(const ASTContext &Ctx,
0107 unsigned NumArgs, bool HasFPFeatures,
0108 EmptyShell Empty);
0109
0110
0111 OverloadedOperatorKind getOperator() const {
0112 return static_cast<OverloadedOperatorKind>(
0113 CXXOperatorCallExprBits.OperatorKind);
0114 }
0115
0116 static bool isAssignmentOp(OverloadedOperatorKind Opc) {
0117 return Opc == OO_Equal || Opc == OO_StarEqual || Opc == OO_SlashEqual ||
0118 Opc == OO_PercentEqual || Opc == OO_PlusEqual ||
0119 Opc == OO_MinusEqual || Opc == OO_LessLessEqual ||
0120 Opc == OO_GreaterGreaterEqual || Opc == OO_AmpEqual ||
0121 Opc == OO_CaretEqual || Opc == OO_PipeEqual;
0122 }
0123 bool isAssignmentOp() const { return isAssignmentOp(getOperator()); }
0124
0125 static bool isComparisonOp(OverloadedOperatorKind Opc) {
0126 switch (Opc) {
0127 case OO_EqualEqual:
0128 case OO_ExclaimEqual:
0129 case OO_Greater:
0130 case OO_GreaterEqual:
0131 case OO_Less:
0132 case OO_LessEqual:
0133 case OO_Spaceship:
0134 return true;
0135 default:
0136 return false;
0137 }
0138 }
0139 bool isComparisonOp() const { return isComparisonOp(getOperator()); }
0140
0141
0142 bool isInfixBinaryOp() const;
0143
0144
0145
0146
0147
0148
0149 SourceLocation getOperatorLoc() const { return getRParenLoc(); }
0150
0151 SourceLocation getExprLoc() const LLVM_READONLY {
0152 OverloadedOperatorKind Operator = getOperator();
0153 return (Operator < OO_Plus || Operator >= OO_Arrow ||
0154 Operator == OO_PlusPlus || Operator == OO_MinusMinus)
0155 ? getBeginLoc()
0156 : getOperatorLoc();
0157 }
0158
0159 SourceLocation getBeginLoc() const { return Range.getBegin(); }
0160 SourceLocation getEndLoc() const { return Range.getEnd(); }
0161 SourceRange getSourceRange() const { return Range; }
0162
0163 static bool classof(const Stmt *T) {
0164 return T->getStmtClass() == CXXOperatorCallExprClass;
0165 }
0166 };
0167
0168
0169
0170
0171
0172
0173
0174
0175
0176 class CXXMemberCallExpr final : public CallExpr {
0177
0178
0179
0180 CXXMemberCallExpr(Expr *Fn, ArrayRef<Expr *> Args, QualType Ty,
0181 ExprValueKind VK, SourceLocation RP,
0182 FPOptionsOverride FPOptions, unsigned MinNumArgs);
0183
0184 CXXMemberCallExpr(unsigned NumArgs, bool HasFPFeatures, EmptyShell Empty);
0185
0186 public:
0187 static CXXMemberCallExpr *Create(const ASTContext &Ctx, Expr *Fn,
0188 ArrayRef<Expr *> Args, QualType Ty,
0189 ExprValueKind VK, SourceLocation RP,
0190 FPOptionsOverride FPFeatures,
0191 unsigned MinNumArgs = 0);
0192
0193 static CXXMemberCallExpr *CreateEmpty(const ASTContext &Ctx, unsigned NumArgs,
0194 bool HasFPFeatures, EmptyShell Empty);
0195
0196
0197
0198
0199 Expr *getImplicitObjectArgument() const;
0200
0201
0202
0203
0204 QualType getObjectType() const;
0205
0206
0207 CXXMethodDecl *getMethodDecl() const;
0208
0209
0210
0211
0212
0213
0214
0215 CXXRecordDecl *getRecordDecl() const;
0216
0217 SourceLocation getExprLoc() const LLVM_READONLY {
0218 SourceLocation CLoc = getCallee()->getExprLoc();
0219 if (CLoc.isValid())
0220 return CLoc;
0221
0222 return getBeginLoc();
0223 }
0224
0225 static bool classof(const Stmt *T) {
0226 return T->getStmtClass() == CXXMemberCallExprClass;
0227 }
0228 };
0229
0230
0231 class CUDAKernelCallExpr final : public CallExpr {
0232 friend class ASTStmtReader;
0233
0234 enum { CONFIG, END_PREARG };
0235
0236
0237
0238
0239 CUDAKernelCallExpr(Expr *Fn, CallExpr *Config, ArrayRef<Expr *> Args,
0240 QualType Ty, ExprValueKind VK, SourceLocation RP,
0241 FPOptionsOverride FPFeatures, unsigned MinNumArgs);
0242
0243 CUDAKernelCallExpr(unsigned NumArgs, bool HasFPFeatures, EmptyShell Empty);
0244
0245 public:
0246 static CUDAKernelCallExpr *Create(const ASTContext &Ctx, Expr *Fn,
0247 CallExpr *Config, ArrayRef<Expr *> Args,
0248 QualType Ty, ExprValueKind VK,
0249 SourceLocation RP,
0250 FPOptionsOverride FPFeatures,
0251 unsigned MinNumArgs = 0);
0252
0253 static CUDAKernelCallExpr *CreateEmpty(const ASTContext &Ctx,
0254 unsigned NumArgs, bool HasFPFeatures,
0255 EmptyShell Empty);
0256
0257 const CallExpr *getConfig() const {
0258 return cast_or_null<CallExpr>(getPreArg(CONFIG));
0259 }
0260 CallExpr *getConfig() { return cast_or_null<CallExpr>(getPreArg(CONFIG)); }
0261
0262 static bool classof(const Stmt *T) {
0263 return T->getStmtClass() == CUDAKernelCallExprClass;
0264 }
0265 };
0266
0267
0268
0269
0270
0271
0272
0273
0274
0275
0276
0277
0278
0279
0280
0281
0282
0283 class CXXRewrittenBinaryOperator : public Expr {
0284 friend class ASTStmtReader;
0285
0286
0287 Stmt *SemanticForm;
0288
0289 public:
0290 CXXRewrittenBinaryOperator(Expr *SemanticForm, bool IsReversed)
0291 : Expr(CXXRewrittenBinaryOperatorClass, SemanticForm->getType(),
0292 SemanticForm->getValueKind(), SemanticForm->getObjectKind()),
0293 SemanticForm(SemanticForm) {
0294 CXXRewrittenBinaryOperatorBits.IsReversed = IsReversed;
0295 setDependence(computeDependence(this));
0296 }
0297 CXXRewrittenBinaryOperator(EmptyShell Empty)
0298 : Expr(CXXRewrittenBinaryOperatorClass, Empty), SemanticForm() {}
0299
0300
0301 Expr *getSemanticForm() { return cast<Expr>(SemanticForm); }
0302 const Expr *getSemanticForm() const { return cast<Expr>(SemanticForm); }
0303
0304 struct DecomposedForm {
0305
0306 BinaryOperatorKind Opcode;
0307
0308 const Expr *LHS;
0309
0310 const Expr *RHS;
0311
0312 const Expr *InnerBinOp;
0313 };
0314
0315
0316 DecomposedForm getDecomposedForm() const LLVM_READONLY;
0317
0318
0319 bool isReversed() const { return CXXRewrittenBinaryOperatorBits.IsReversed; }
0320
0321 BinaryOperatorKind getOperator() const { return getDecomposedForm().Opcode; }
0322 BinaryOperatorKind getOpcode() const { return getOperator(); }
0323 static StringRef getOpcodeStr(BinaryOperatorKind Op) {
0324 return BinaryOperator::getOpcodeStr(Op);
0325 }
0326 StringRef getOpcodeStr() const {
0327 return BinaryOperator::getOpcodeStr(getOpcode());
0328 }
0329 bool isComparisonOp() const { return true; }
0330 bool isAssignmentOp() const { return false; }
0331
0332 const Expr *getLHS() const { return getDecomposedForm().LHS; }
0333 const Expr *getRHS() const { return getDecomposedForm().RHS; }
0334
0335 SourceLocation getOperatorLoc() const LLVM_READONLY {
0336 return getDecomposedForm().InnerBinOp->getExprLoc();
0337 }
0338 SourceLocation getExprLoc() const LLVM_READONLY { return getOperatorLoc(); }
0339
0340
0341
0342
0343
0344 SourceLocation getBeginLoc() const LLVM_READONLY {
0345 return getDecomposedForm().LHS->getBeginLoc();
0346 }
0347 SourceLocation getEndLoc() const LLVM_READONLY {
0348 return getDecomposedForm().RHS->getEndLoc();
0349 }
0350 SourceRange getSourceRange() const LLVM_READONLY {
0351 DecomposedForm DF = getDecomposedForm();
0352 return SourceRange(DF.LHS->getBeginLoc(), DF.RHS->getEndLoc());
0353 }
0354
0355
0356 child_range children() {
0357 return child_range(&SemanticForm, &SemanticForm + 1);
0358 }
0359
0360 static bool classof(const Stmt *T) {
0361 return T->getStmtClass() == CXXRewrittenBinaryOperatorClass;
0362 }
0363 };
0364
0365
0366
0367
0368
0369
0370
0371
0372 class CXXNamedCastExpr : public ExplicitCastExpr {
0373 private:
0374
0375 SourceLocation Loc;
0376
0377
0378 SourceLocation RParenLoc;
0379
0380
0381 SourceRange AngleBrackets;
0382
0383 protected:
0384 friend class ASTStmtReader;
0385
0386 CXXNamedCastExpr(StmtClass SC, QualType ty, ExprValueKind VK, CastKind kind,
0387 Expr *op, unsigned PathSize, bool HasFPFeatures,
0388 TypeSourceInfo *writtenTy, SourceLocation l,
0389 SourceLocation RParenLoc, SourceRange AngleBrackets)
0390 : ExplicitCastExpr(SC, ty, VK, kind, op, PathSize, HasFPFeatures,
0391 writtenTy),
0392 Loc(l), RParenLoc(RParenLoc), AngleBrackets(AngleBrackets) {}
0393
0394 explicit CXXNamedCastExpr(StmtClass SC, EmptyShell Shell, unsigned PathSize,
0395 bool HasFPFeatures)
0396 : ExplicitCastExpr(SC, Shell, PathSize, HasFPFeatures) {}
0397
0398 public:
0399 const char *getCastName() const;
0400
0401
0402
0403 SourceLocation getOperatorLoc() const { return Loc; }
0404
0405
0406 SourceLocation getRParenLoc() const { return RParenLoc; }
0407
0408 SourceLocation getBeginLoc() const LLVM_READONLY { return Loc; }
0409 SourceLocation getEndLoc() const LLVM_READONLY { return RParenLoc; }
0410 SourceRange getAngleBrackets() const LLVM_READONLY { return AngleBrackets; }
0411
0412 static bool classof(const Stmt *T) {
0413 switch (T->getStmtClass()) {
0414 case CXXStaticCastExprClass:
0415 case CXXDynamicCastExprClass:
0416 case CXXReinterpretCastExprClass:
0417 case CXXConstCastExprClass:
0418 case CXXAddrspaceCastExprClass:
0419 return true;
0420 default:
0421 return false;
0422 }
0423 }
0424 };
0425
0426
0427
0428
0429
0430 class CXXStaticCastExpr final
0431 : public CXXNamedCastExpr,
0432 private llvm::TrailingObjects<CXXStaticCastExpr, CXXBaseSpecifier *,
0433 FPOptionsOverride> {
0434 CXXStaticCastExpr(QualType ty, ExprValueKind vk, CastKind kind, Expr *op,
0435 unsigned pathSize, TypeSourceInfo *writtenTy,
0436 FPOptionsOverride FPO, SourceLocation l,
0437 SourceLocation RParenLoc, SourceRange AngleBrackets)
0438 : CXXNamedCastExpr(CXXStaticCastExprClass, ty, vk, kind, op, pathSize,
0439 FPO.requiresTrailingStorage(), writtenTy, l, RParenLoc,
0440 AngleBrackets) {
0441 if (hasStoredFPFeatures())
0442 *getTrailingFPFeatures() = FPO;
0443 }
0444
0445 explicit CXXStaticCastExpr(EmptyShell Empty, unsigned PathSize,
0446 bool HasFPFeatures)
0447 : CXXNamedCastExpr(CXXStaticCastExprClass, Empty, PathSize,
0448 HasFPFeatures) {}
0449
0450 unsigned numTrailingObjects(OverloadToken<CXXBaseSpecifier *>) const {
0451 return path_size();
0452 }
0453
0454 public:
0455 friend class CastExpr;
0456 friend TrailingObjects;
0457
0458 static CXXStaticCastExpr *
0459 Create(const ASTContext &Context, QualType T, ExprValueKind VK, CastKind K,
0460 Expr *Op, const CXXCastPath *Path, TypeSourceInfo *Written,
0461 FPOptionsOverride FPO, SourceLocation L, SourceLocation RParenLoc,
0462 SourceRange AngleBrackets);
0463 static CXXStaticCastExpr *CreateEmpty(const ASTContext &Context,
0464 unsigned PathSize, bool hasFPFeatures);
0465
0466 static bool classof(const Stmt *T) {
0467 return T->getStmtClass() == CXXStaticCastExprClass;
0468 }
0469 };
0470
0471
0472
0473
0474
0475
0476 class CXXDynamicCastExpr final
0477 : public CXXNamedCastExpr,
0478 private llvm::TrailingObjects<CXXDynamicCastExpr, CXXBaseSpecifier *> {
0479 CXXDynamicCastExpr(QualType ty, ExprValueKind VK, CastKind kind, Expr *op,
0480 unsigned pathSize, TypeSourceInfo *writtenTy,
0481 SourceLocation l, SourceLocation RParenLoc,
0482 SourceRange AngleBrackets)
0483 : CXXNamedCastExpr(CXXDynamicCastExprClass, ty, VK, kind, op, pathSize,
0484 false, writtenTy, l, RParenLoc,
0485 AngleBrackets) {}
0486
0487 explicit CXXDynamicCastExpr(EmptyShell Empty, unsigned pathSize)
0488 : CXXNamedCastExpr(CXXDynamicCastExprClass, Empty, pathSize,
0489 false) {}
0490
0491 public:
0492 friend class CastExpr;
0493 friend TrailingObjects;
0494
0495 static CXXDynamicCastExpr *Create(const ASTContext &Context, QualType T,
0496 ExprValueKind VK, CastKind Kind, Expr *Op,
0497 const CXXCastPath *Path,
0498 TypeSourceInfo *Written, SourceLocation L,
0499 SourceLocation RParenLoc,
0500 SourceRange AngleBrackets);
0501
0502 static CXXDynamicCastExpr *CreateEmpty(const ASTContext &Context,
0503 unsigned pathSize);
0504
0505 bool isAlwaysNull() const;
0506
0507 static bool classof(const Stmt *T) {
0508 return T->getStmtClass() == CXXDynamicCastExprClass;
0509 }
0510 };
0511
0512
0513
0514
0515
0516
0517
0518
0519
0520 class CXXReinterpretCastExpr final
0521 : public CXXNamedCastExpr,
0522 private llvm::TrailingObjects<CXXReinterpretCastExpr,
0523 CXXBaseSpecifier *> {
0524 CXXReinterpretCastExpr(QualType ty, ExprValueKind vk, CastKind kind, Expr *op,
0525 unsigned pathSize, TypeSourceInfo *writtenTy,
0526 SourceLocation l, SourceLocation RParenLoc,
0527 SourceRange AngleBrackets)
0528 : CXXNamedCastExpr(CXXReinterpretCastExprClass, ty, vk, kind, op,
0529 pathSize, false, writtenTy, l,
0530 RParenLoc, AngleBrackets) {}
0531
0532 CXXReinterpretCastExpr(EmptyShell Empty, unsigned pathSize)
0533 : CXXNamedCastExpr(CXXReinterpretCastExprClass, Empty, pathSize,
0534 false) {}
0535
0536 public:
0537 friend class CastExpr;
0538 friend TrailingObjects;
0539
0540 static CXXReinterpretCastExpr *Create(const ASTContext &Context, QualType T,
0541 ExprValueKind VK, CastKind Kind,
0542 Expr *Op, const CXXCastPath *Path,
0543 TypeSourceInfo *WrittenTy, SourceLocation L,
0544 SourceLocation RParenLoc,
0545 SourceRange AngleBrackets);
0546 static CXXReinterpretCastExpr *CreateEmpty(const ASTContext &Context,
0547 unsigned pathSize);
0548
0549 static bool classof(const Stmt *T) {
0550 return T->getStmtClass() == CXXReinterpretCastExprClass;
0551 }
0552 };
0553
0554
0555
0556
0557
0558
0559
0560
0561 class CXXConstCastExpr final
0562 : public CXXNamedCastExpr,
0563 private llvm::TrailingObjects<CXXConstCastExpr, CXXBaseSpecifier *> {
0564 CXXConstCastExpr(QualType ty, ExprValueKind VK, Expr *op,
0565 TypeSourceInfo *writtenTy, SourceLocation l,
0566 SourceLocation RParenLoc, SourceRange AngleBrackets)
0567 : CXXNamedCastExpr(CXXConstCastExprClass, ty, VK, CK_NoOp, op, 0,
0568 false, writtenTy, l, RParenLoc,
0569 AngleBrackets) {}
0570
0571 explicit CXXConstCastExpr(EmptyShell Empty)
0572 : CXXNamedCastExpr(CXXConstCastExprClass, Empty, 0,
0573 false) {}
0574
0575 public:
0576 friend class CastExpr;
0577 friend TrailingObjects;
0578
0579 static CXXConstCastExpr *Create(const ASTContext &Context, QualType T,
0580 ExprValueKind VK, Expr *Op,
0581 TypeSourceInfo *WrittenTy, SourceLocation L,
0582 SourceLocation RParenLoc,
0583 SourceRange AngleBrackets);
0584 static CXXConstCastExpr *CreateEmpty(const ASTContext &Context);
0585
0586 static bool classof(const Stmt *T) {
0587 return T->getStmtClass() == CXXConstCastExprClass;
0588 }
0589 };
0590
0591
0592
0593
0594
0595
0596
0597
0598
0599 class CXXAddrspaceCastExpr final
0600 : public CXXNamedCastExpr,
0601 private llvm::TrailingObjects<CXXAddrspaceCastExpr, CXXBaseSpecifier *> {
0602 CXXAddrspaceCastExpr(QualType ty, ExprValueKind VK, CastKind Kind, Expr *op,
0603 TypeSourceInfo *writtenTy, SourceLocation l,
0604 SourceLocation RParenLoc, SourceRange AngleBrackets)
0605 : CXXNamedCastExpr(CXXAddrspaceCastExprClass, ty, VK, Kind, op, 0,
0606 false, writtenTy, l, RParenLoc,
0607 AngleBrackets) {}
0608
0609 explicit CXXAddrspaceCastExpr(EmptyShell Empty)
0610 : CXXNamedCastExpr(CXXAddrspaceCastExprClass, Empty, 0,
0611 false) {}
0612
0613 public:
0614 friend class CastExpr;
0615 friend TrailingObjects;
0616
0617 static CXXAddrspaceCastExpr *
0618 Create(const ASTContext &Context, QualType T, ExprValueKind VK, CastKind Kind,
0619 Expr *Op, TypeSourceInfo *WrittenTy, SourceLocation L,
0620 SourceLocation RParenLoc, SourceRange AngleBrackets);
0621 static CXXAddrspaceCastExpr *CreateEmpty(const ASTContext &Context);
0622
0623 static bool classof(const Stmt *T) {
0624 return T->getStmtClass() == CXXAddrspaceCastExprClass;
0625 }
0626 };
0627
0628
0629
0630
0631
0632
0633
0634
0635
0636
0637 class UserDefinedLiteral final : public CallExpr {
0638 friend class ASTStmtReader;
0639 friend class ASTStmtWriter;
0640
0641
0642 SourceLocation UDSuffixLoc;
0643
0644
0645
0646
0647 UserDefinedLiteral(Expr *Fn, ArrayRef<Expr *> Args, QualType Ty,
0648 ExprValueKind VK, SourceLocation LitEndLoc,
0649 SourceLocation SuffixLoc, FPOptionsOverride FPFeatures);
0650
0651 UserDefinedLiteral(unsigned NumArgs, bool HasFPFeatures, EmptyShell Empty);
0652
0653 public:
0654 static UserDefinedLiteral *Create(const ASTContext &Ctx, Expr *Fn,
0655 ArrayRef<Expr *> Args, QualType Ty,
0656 ExprValueKind VK, SourceLocation LitEndLoc,
0657 SourceLocation SuffixLoc,
0658 FPOptionsOverride FPFeatures);
0659
0660 static UserDefinedLiteral *CreateEmpty(const ASTContext &Ctx,
0661 unsigned NumArgs, bool HasFPOptions,
0662 EmptyShell Empty);
0663
0664
0665 enum LiteralOperatorKind {
0666
0667 LOK_Raw,
0668
0669
0670 LOK_Template,
0671
0672
0673 LOK_Integer,
0674
0675
0676 LOK_Floating,
0677
0678
0679 LOK_String,
0680
0681
0682 LOK_Character
0683 };
0684
0685
0686
0687 LiteralOperatorKind getLiteralOperatorKind() const;
0688
0689
0690
0691
0692 Expr *getCookedLiteral();
0693 const Expr *getCookedLiteral() const {
0694 return const_cast<UserDefinedLiteral*>(this)->getCookedLiteral();
0695 }
0696
0697 SourceLocation getBeginLoc() const {
0698 if (getLiteralOperatorKind() == LOK_Template)
0699 return getRParenLoc();
0700 return getArg(0)->getBeginLoc();
0701 }
0702
0703 SourceLocation getEndLoc() const { return getRParenLoc(); }
0704
0705
0706
0707
0708
0709 SourceLocation getUDSuffixLoc() const { return UDSuffixLoc; }
0710
0711
0712 const IdentifierInfo *getUDSuffix() const;
0713
0714 static bool classof(const Stmt *S) {
0715 return S->getStmtClass() == UserDefinedLiteralClass;
0716 }
0717 };
0718
0719
0720 class CXXBoolLiteralExpr : public Expr {
0721 public:
0722 CXXBoolLiteralExpr(bool Val, QualType Ty, SourceLocation Loc)
0723 : Expr(CXXBoolLiteralExprClass, Ty, VK_PRValue, OK_Ordinary) {
0724 CXXBoolLiteralExprBits.Value = Val;
0725 CXXBoolLiteralExprBits.Loc = Loc;
0726 setDependence(ExprDependence::None);
0727 }
0728
0729 explicit CXXBoolLiteralExpr(EmptyShell Empty)
0730 : Expr(CXXBoolLiteralExprClass, Empty) {}
0731
0732 static CXXBoolLiteralExpr *Create(const ASTContext &C, bool Val, QualType Ty,
0733 SourceLocation Loc) {
0734 return new (C) CXXBoolLiteralExpr(Val, Ty, Loc);
0735 }
0736
0737 bool getValue() const { return CXXBoolLiteralExprBits.Value; }
0738 void setValue(bool V) { CXXBoolLiteralExprBits.Value = V; }
0739
0740 SourceLocation getBeginLoc() const { return getLocation(); }
0741 SourceLocation getEndLoc() const { return getLocation(); }
0742
0743 SourceLocation getLocation() const { return CXXBoolLiteralExprBits.Loc; }
0744 void setLocation(SourceLocation L) { CXXBoolLiteralExprBits.Loc = L; }
0745
0746 static bool classof(const Stmt *T) {
0747 return T->getStmtClass() == CXXBoolLiteralExprClass;
0748 }
0749
0750
0751 child_range children() {
0752 return child_range(child_iterator(), child_iterator());
0753 }
0754
0755 const_child_range children() const {
0756 return const_child_range(const_child_iterator(), const_child_iterator());
0757 }
0758 };
0759
0760
0761
0762
0763
0764
0765 class CXXNullPtrLiteralExpr : public Expr {
0766 public:
0767 CXXNullPtrLiteralExpr(QualType Ty, SourceLocation Loc)
0768 : Expr(CXXNullPtrLiteralExprClass, Ty, VK_PRValue, OK_Ordinary) {
0769 CXXNullPtrLiteralExprBits.Loc = Loc;
0770 setDependence(ExprDependence::None);
0771 }
0772
0773 explicit CXXNullPtrLiteralExpr(EmptyShell Empty)
0774 : Expr(CXXNullPtrLiteralExprClass, Empty) {}
0775
0776 SourceLocation getBeginLoc() const { return getLocation(); }
0777 SourceLocation getEndLoc() const { return getLocation(); }
0778
0779 SourceLocation getLocation() const { return CXXNullPtrLiteralExprBits.Loc; }
0780 void setLocation(SourceLocation L) { CXXNullPtrLiteralExprBits.Loc = L; }
0781
0782 static bool classof(const Stmt *T) {
0783 return T->getStmtClass() == CXXNullPtrLiteralExprClass;
0784 }
0785
0786 child_range children() {
0787 return child_range(child_iterator(), child_iterator());
0788 }
0789
0790 const_child_range children() const {
0791 return const_child_range(const_child_iterator(), const_child_iterator());
0792 }
0793 };
0794
0795
0796
0797 class CXXStdInitializerListExpr : public Expr {
0798 Stmt *SubExpr = nullptr;
0799
0800 CXXStdInitializerListExpr(EmptyShell Empty)
0801 : Expr(CXXStdInitializerListExprClass, Empty) {}
0802
0803 public:
0804 friend class ASTReader;
0805 friend class ASTStmtReader;
0806
0807 CXXStdInitializerListExpr(QualType Ty, Expr *SubExpr)
0808 : Expr(CXXStdInitializerListExprClass, Ty, VK_PRValue, OK_Ordinary),
0809 SubExpr(SubExpr) {
0810 setDependence(computeDependence(this));
0811 }
0812
0813 Expr *getSubExpr() { return static_cast<Expr*>(SubExpr); }
0814 const Expr *getSubExpr() const { return static_cast<const Expr*>(SubExpr); }
0815
0816 SourceLocation getBeginLoc() const LLVM_READONLY {
0817 return SubExpr->getBeginLoc();
0818 }
0819
0820 SourceLocation getEndLoc() const LLVM_READONLY {
0821 return SubExpr->getEndLoc();
0822 }
0823
0824
0825 SourceRange getSourceRange() const LLVM_READONLY {
0826 return SubExpr->getSourceRange();
0827 }
0828
0829 static bool classof(const Stmt *S) {
0830 return S->getStmtClass() == CXXStdInitializerListExprClass;
0831 }
0832
0833 child_range children() { return child_range(&SubExpr, &SubExpr + 1); }
0834
0835 const_child_range children() const {
0836 return const_child_range(&SubExpr, &SubExpr + 1);
0837 }
0838 };
0839
0840
0841
0842
0843
0844
0845 class CXXTypeidExpr : public Expr {
0846 friend class ASTStmtReader;
0847
0848 private:
0849 llvm::PointerUnion<Stmt *, TypeSourceInfo *> Operand;
0850 SourceRange Range;
0851
0852 public:
0853 CXXTypeidExpr(QualType Ty, TypeSourceInfo *Operand, SourceRange R)
0854 : Expr(CXXTypeidExprClass, Ty, VK_LValue, OK_Ordinary), Operand(Operand),
0855 Range(R) {
0856 setDependence(computeDependence(this));
0857 }
0858
0859 CXXTypeidExpr(QualType Ty, Expr *Operand, SourceRange R)
0860 : Expr(CXXTypeidExprClass, Ty, VK_LValue, OK_Ordinary), Operand(Operand),
0861 Range(R) {
0862 setDependence(computeDependence(this));
0863 }
0864
0865 CXXTypeidExpr(EmptyShell Empty, bool isExpr)
0866 : Expr(CXXTypeidExprClass, Empty) {
0867 if (isExpr)
0868 Operand = (Expr*)nullptr;
0869 else
0870 Operand = (TypeSourceInfo*)nullptr;
0871 }
0872
0873
0874
0875 bool isPotentiallyEvaluated() const;
0876
0877
0878
0879 bool isMostDerived(const ASTContext &Context) const;
0880
0881 bool isTypeOperand() const { return isa<TypeSourceInfo *>(Operand); }
0882
0883
0884
0885 QualType getTypeOperand(const ASTContext &Context) const;
0886
0887
0888 TypeSourceInfo *getTypeOperandSourceInfo() const {
0889 assert(isTypeOperand() && "Cannot call getTypeOperand for typeid(expr)");
0890 return cast<TypeSourceInfo *>(Operand);
0891 }
0892 Expr *getExprOperand() const {
0893 assert(!isTypeOperand() && "Cannot call getExprOperand for typeid(type)");
0894 return static_cast<Expr *>(cast<Stmt *>(Operand));
0895 }
0896
0897 SourceLocation getBeginLoc() const LLVM_READONLY { return Range.getBegin(); }
0898 SourceLocation getEndLoc() const LLVM_READONLY { return Range.getEnd(); }
0899 SourceRange getSourceRange() const LLVM_READONLY { return Range; }
0900 void setSourceRange(SourceRange R) { Range = R; }
0901
0902 static bool classof(const Stmt *T) {
0903 return T->getStmtClass() == CXXTypeidExprClass;
0904 }
0905
0906
0907 child_range children() {
0908 if (isTypeOperand())
0909 return child_range(child_iterator(), child_iterator());
0910 auto **begin = reinterpret_cast<Stmt **>(&Operand);
0911 return child_range(begin, begin + 1);
0912 }
0913
0914 const_child_range children() const {
0915 if (isTypeOperand())
0916 return const_child_range(const_child_iterator(), const_child_iterator());
0917
0918 auto **begin =
0919 reinterpret_cast<Stmt **>(&const_cast<CXXTypeidExpr *>(this)->Operand);
0920 return const_child_range(begin, begin + 1);
0921 }
0922
0923
0924
0925 bool hasNullCheck() const;
0926 };
0927
0928
0929
0930
0931
0932
0933 class MSPropertyRefExpr : public Expr {
0934 Expr *BaseExpr;
0935 MSPropertyDecl *TheDecl;
0936 SourceLocation MemberLoc;
0937 bool IsArrow;
0938 NestedNameSpecifierLoc QualifierLoc;
0939
0940 public:
0941 friend class ASTStmtReader;
0942
0943 MSPropertyRefExpr(Expr *baseExpr, MSPropertyDecl *decl, bool isArrow,
0944 QualType ty, ExprValueKind VK,
0945 NestedNameSpecifierLoc qualifierLoc, SourceLocation nameLoc)
0946 : Expr(MSPropertyRefExprClass, ty, VK, OK_Ordinary), BaseExpr(baseExpr),
0947 TheDecl(decl), MemberLoc(nameLoc), IsArrow(isArrow),
0948 QualifierLoc(qualifierLoc) {
0949 setDependence(computeDependence(this));
0950 }
0951
0952 MSPropertyRefExpr(EmptyShell Empty) : Expr(MSPropertyRefExprClass, Empty) {}
0953
0954 SourceRange getSourceRange() const LLVM_READONLY {
0955 return SourceRange(getBeginLoc(), getEndLoc());
0956 }
0957
0958 bool isImplicitAccess() const {
0959 return getBaseExpr() && getBaseExpr()->isImplicitCXXThis();
0960 }
0961
0962 SourceLocation getBeginLoc() const {
0963 if (!isImplicitAccess())
0964 return BaseExpr->getBeginLoc();
0965 else if (QualifierLoc)
0966 return QualifierLoc.getBeginLoc();
0967 else
0968 return MemberLoc;
0969 }
0970
0971 SourceLocation getEndLoc() const { return getMemberLoc(); }
0972
0973 child_range children() {
0974 return child_range((Stmt**)&BaseExpr, (Stmt**)&BaseExpr + 1);
0975 }
0976
0977 const_child_range children() const {
0978 auto Children = const_cast<MSPropertyRefExpr *>(this)->children();
0979 return const_child_range(Children.begin(), Children.end());
0980 }
0981
0982 static bool classof(const Stmt *T) {
0983 return T->getStmtClass() == MSPropertyRefExprClass;
0984 }
0985
0986 Expr *getBaseExpr() const { return BaseExpr; }
0987 MSPropertyDecl *getPropertyDecl() const { return TheDecl; }
0988 bool isArrow() const { return IsArrow; }
0989 SourceLocation getMemberLoc() const { return MemberLoc; }
0990 NestedNameSpecifierLoc getQualifierLoc() const { return QualifierLoc; }
0991 };
0992
0993
0994
0995
0996
0997
0998
0999
1000
1001
1002
1003
1004 class MSPropertySubscriptExpr : public Expr {
1005 friend class ASTStmtReader;
1006
1007 enum { BASE_EXPR, IDX_EXPR, NUM_SUBEXPRS = 2 };
1008
1009 Stmt *SubExprs[NUM_SUBEXPRS];
1010 SourceLocation RBracketLoc;
1011
1012 void setBase(Expr *Base) { SubExprs[BASE_EXPR] = Base; }
1013 void setIdx(Expr *Idx) { SubExprs[IDX_EXPR] = Idx; }
1014
1015 public:
1016 MSPropertySubscriptExpr(Expr *Base, Expr *Idx, QualType Ty, ExprValueKind VK,
1017 ExprObjectKind OK, SourceLocation RBracketLoc)
1018 : Expr(MSPropertySubscriptExprClass, Ty, VK, OK),
1019 RBracketLoc(RBracketLoc) {
1020 SubExprs[BASE_EXPR] = Base;
1021 SubExprs[IDX_EXPR] = Idx;
1022 setDependence(computeDependence(this));
1023 }
1024
1025
1026 explicit MSPropertySubscriptExpr(EmptyShell Shell)
1027 : Expr(MSPropertySubscriptExprClass, Shell) {}
1028
1029 Expr *getBase() { return cast<Expr>(SubExprs[BASE_EXPR]); }
1030 const Expr *getBase() const { return cast<Expr>(SubExprs[BASE_EXPR]); }
1031
1032 Expr *getIdx() { return cast<Expr>(SubExprs[IDX_EXPR]); }
1033 const Expr *getIdx() const { return cast<Expr>(SubExprs[IDX_EXPR]); }
1034
1035 SourceLocation getBeginLoc() const LLVM_READONLY {
1036 return getBase()->getBeginLoc();
1037 }
1038
1039 SourceLocation getEndLoc() const LLVM_READONLY { return RBracketLoc; }
1040
1041 SourceLocation getRBracketLoc() const { return RBracketLoc; }
1042 void setRBracketLoc(SourceLocation L) { RBracketLoc = L; }
1043
1044 SourceLocation getExprLoc() const LLVM_READONLY {
1045 return getBase()->getExprLoc();
1046 }
1047
1048 static bool classof(const Stmt *T) {
1049 return T->getStmtClass() == MSPropertySubscriptExprClass;
1050 }
1051
1052
1053 child_range children() {
1054 return child_range(&SubExprs[0], &SubExprs[0] + NUM_SUBEXPRS);
1055 }
1056
1057 const_child_range children() const {
1058 return const_child_range(&SubExprs[0], &SubExprs[0] + NUM_SUBEXPRS);
1059 }
1060 };
1061
1062
1063
1064
1065
1066 class CXXUuidofExpr : public Expr {
1067 friend class ASTStmtReader;
1068
1069 private:
1070 llvm::PointerUnion<Stmt *, TypeSourceInfo *> Operand;
1071 MSGuidDecl *Guid;
1072 SourceRange Range;
1073
1074 public:
1075 CXXUuidofExpr(QualType Ty, TypeSourceInfo *Operand, MSGuidDecl *Guid,
1076 SourceRange R)
1077 : Expr(CXXUuidofExprClass, Ty, VK_LValue, OK_Ordinary), Operand(Operand),
1078 Guid(Guid), Range(R) {
1079 setDependence(computeDependence(this));
1080 }
1081
1082 CXXUuidofExpr(QualType Ty, Expr *Operand, MSGuidDecl *Guid, SourceRange R)
1083 : Expr(CXXUuidofExprClass, Ty, VK_LValue, OK_Ordinary), Operand(Operand),
1084 Guid(Guid), Range(R) {
1085 setDependence(computeDependence(this));
1086 }
1087
1088 CXXUuidofExpr(EmptyShell Empty, bool isExpr)
1089 : Expr(CXXUuidofExprClass, Empty) {
1090 if (isExpr)
1091 Operand = (Expr*)nullptr;
1092 else
1093 Operand = (TypeSourceInfo*)nullptr;
1094 }
1095
1096 bool isTypeOperand() const { return isa<TypeSourceInfo *>(Operand); }
1097
1098
1099
1100 QualType getTypeOperand(ASTContext &Context) const;
1101
1102
1103 TypeSourceInfo *getTypeOperandSourceInfo() const {
1104 assert(isTypeOperand() && "Cannot call getTypeOperand for __uuidof(expr)");
1105 return cast<TypeSourceInfo *>(Operand);
1106 }
1107 Expr *getExprOperand() const {
1108 assert(!isTypeOperand() && "Cannot call getExprOperand for __uuidof(type)");
1109 return static_cast<Expr *>(cast<Stmt *>(Operand));
1110 }
1111
1112 MSGuidDecl *getGuidDecl() const { return Guid; }
1113
1114 SourceLocation getBeginLoc() const LLVM_READONLY { return Range.getBegin(); }
1115 SourceLocation getEndLoc() const LLVM_READONLY { return Range.getEnd(); }
1116 SourceRange getSourceRange() const LLVM_READONLY { return Range; }
1117 void setSourceRange(SourceRange R) { Range = R; }
1118
1119 static bool classof(const Stmt *T) {
1120 return T->getStmtClass() == CXXUuidofExprClass;
1121 }
1122
1123
1124 child_range children() {
1125 if (isTypeOperand())
1126 return child_range(child_iterator(), child_iterator());
1127 auto **begin = reinterpret_cast<Stmt **>(&Operand);
1128 return child_range(begin, begin + 1);
1129 }
1130
1131 const_child_range children() const {
1132 if (isTypeOperand())
1133 return const_child_range(const_child_iterator(), const_child_iterator());
1134 auto **begin =
1135 reinterpret_cast<Stmt **>(&const_cast<CXXUuidofExpr *>(this)->Operand);
1136 return const_child_range(begin, begin + 1);
1137 }
1138 };
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152 class CXXThisExpr : public Expr {
1153 CXXThisExpr(SourceLocation L, QualType Ty, bool IsImplicit, ExprValueKind VK)
1154 : Expr(CXXThisExprClass, Ty, VK, OK_Ordinary) {
1155 CXXThisExprBits.IsImplicit = IsImplicit;
1156 CXXThisExprBits.CapturedByCopyInLambdaWithExplicitObjectParameter = false;
1157 CXXThisExprBits.Loc = L;
1158 setDependence(computeDependence(this));
1159 }
1160
1161 CXXThisExpr(EmptyShell Empty) : Expr(CXXThisExprClass, Empty) {}
1162
1163 public:
1164 static CXXThisExpr *Create(const ASTContext &Ctx, SourceLocation L,
1165 QualType Ty, bool IsImplicit);
1166
1167 static CXXThisExpr *CreateEmpty(const ASTContext &Ctx);
1168
1169 SourceLocation getLocation() const { return CXXThisExprBits.Loc; }
1170 void setLocation(SourceLocation L) { CXXThisExprBits.Loc = L; }
1171
1172 SourceLocation getBeginLoc() const { return getLocation(); }
1173 SourceLocation getEndLoc() const { return getLocation(); }
1174
1175 bool isImplicit() const { return CXXThisExprBits.IsImplicit; }
1176 void setImplicit(bool I) { CXXThisExprBits.IsImplicit = I; }
1177
1178 bool isCapturedByCopyInLambdaWithExplicitObjectParameter() const {
1179 return CXXThisExprBits.CapturedByCopyInLambdaWithExplicitObjectParameter;
1180 }
1181
1182 void setCapturedByCopyInLambdaWithExplicitObjectParameter(bool Set) {
1183 CXXThisExprBits.CapturedByCopyInLambdaWithExplicitObjectParameter = Set;
1184 setDependence(computeDependence(this));
1185 }
1186
1187 static bool classof(const Stmt *T) {
1188 return T->getStmtClass() == CXXThisExprClass;
1189 }
1190
1191
1192 child_range children() {
1193 return child_range(child_iterator(), child_iterator());
1194 }
1195
1196 const_child_range children() const {
1197 return const_child_range(const_child_iterator(), const_child_iterator());
1198 }
1199 };
1200
1201
1202
1203
1204
1205
1206 class CXXThrowExpr : public Expr {
1207 friend class ASTStmtReader;
1208
1209
1210 Stmt *Operand;
1211
1212 public:
1213
1214
1215
1216
1217 CXXThrowExpr(Expr *Operand, QualType Ty, SourceLocation Loc,
1218 bool IsThrownVariableInScope)
1219 : Expr(CXXThrowExprClass, Ty, VK_PRValue, OK_Ordinary), Operand(Operand) {
1220 CXXThrowExprBits.ThrowLoc = Loc;
1221 CXXThrowExprBits.IsThrownVariableInScope = IsThrownVariableInScope;
1222 setDependence(computeDependence(this));
1223 }
1224 CXXThrowExpr(EmptyShell Empty) : Expr(CXXThrowExprClass, Empty) {}
1225
1226 const Expr *getSubExpr() const { return cast_or_null<Expr>(Operand); }
1227 Expr *getSubExpr() { return cast_or_null<Expr>(Operand); }
1228
1229 SourceLocation getThrowLoc() const { return CXXThrowExprBits.ThrowLoc; }
1230
1231
1232
1233
1234
1235
1236 bool isThrownVariableInScope() const {
1237 return CXXThrowExprBits.IsThrownVariableInScope;
1238 }
1239
1240 SourceLocation getBeginLoc() const { return getThrowLoc(); }
1241 SourceLocation getEndLoc() const LLVM_READONLY {
1242 if (!getSubExpr())
1243 return getThrowLoc();
1244 return getSubExpr()->getEndLoc();
1245 }
1246
1247 static bool classof(const Stmt *T) {
1248 return T->getStmtClass() == CXXThrowExprClass;
1249 }
1250
1251
1252 child_range children() {
1253 return child_range(&Operand, Operand ? &Operand + 1 : &Operand);
1254 }
1255
1256 const_child_range children() const {
1257 return const_child_range(&Operand, Operand ? &Operand + 1 : &Operand);
1258 }
1259 };
1260
1261
1262
1263
1264
1265
1266 class CXXDefaultArgExpr final
1267 : public Expr,
1268 private llvm::TrailingObjects<CXXDefaultArgExpr, Expr *> {
1269 friend class ASTStmtReader;
1270 friend class ASTReader;
1271 friend TrailingObjects;
1272
1273
1274 ParmVarDecl *Param;
1275
1276
1277 DeclContext *UsedContext;
1278
1279 CXXDefaultArgExpr(StmtClass SC, SourceLocation Loc, ParmVarDecl *Param,
1280 Expr *RewrittenExpr, DeclContext *UsedContext)
1281 : Expr(SC,
1282 Param->hasUnparsedDefaultArg()
1283 ? Param->getType().getNonReferenceType()
1284 : Param->getDefaultArg()->getType(),
1285 Param->getDefaultArg()->getValueKind(),
1286 Param->getDefaultArg()->getObjectKind()),
1287 Param(Param), UsedContext(UsedContext) {
1288 CXXDefaultArgExprBits.Loc = Loc;
1289 CXXDefaultArgExprBits.HasRewrittenInit = RewrittenExpr != nullptr;
1290 if (RewrittenExpr)
1291 *getTrailingObjects<Expr *>() = RewrittenExpr;
1292 setDependence(computeDependence(this));
1293 }
1294
1295 CXXDefaultArgExpr(EmptyShell Empty, bool HasRewrittenInit)
1296 : Expr(CXXDefaultArgExprClass, Empty) {
1297 CXXDefaultArgExprBits.HasRewrittenInit = HasRewrittenInit;
1298 }
1299
1300 public:
1301 static CXXDefaultArgExpr *CreateEmpty(const ASTContext &C,
1302 bool HasRewrittenInit);
1303
1304
1305
1306 static CXXDefaultArgExpr *Create(const ASTContext &C, SourceLocation Loc,
1307 ParmVarDecl *Param, Expr *RewrittenExpr,
1308 DeclContext *UsedContext);
1309
1310 const ParmVarDecl *getParam() const { return Param; }
1311 ParmVarDecl *getParam() { return Param; }
1312
1313 bool hasRewrittenInit() const {
1314 return CXXDefaultArgExprBits.HasRewrittenInit;
1315 }
1316
1317
1318 Expr *getExpr();
1319 const Expr *getExpr() const {
1320 return const_cast<CXXDefaultArgExpr *>(this)->getExpr();
1321 }
1322
1323 Expr *getRewrittenExpr() {
1324 return hasRewrittenInit() ? *getTrailingObjects<Expr *>() : nullptr;
1325 }
1326
1327 const Expr *getRewrittenExpr() const {
1328 return const_cast<CXXDefaultArgExpr *>(this)->getRewrittenExpr();
1329 }
1330
1331
1332
1333 Expr *getAdjustedRewrittenExpr();
1334 const Expr *getAdjustedRewrittenExpr() const {
1335 return const_cast<CXXDefaultArgExpr *>(this)->getAdjustedRewrittenExpr();
1336 }
1337
1338 const DeclContext *getUsedContext() const { return UsedContext; }
1339 DeclContext *getUsedContext() { return UsedContext; }
1340
1341
1342 SourceLocation getUsedLocation() const { return CXXDefaultArgExprBits.Loc; }
1343
1344
1345
1346 SourceLocation getBeginLoc() const { return SourceLocation(); }
1347 SourceLocation getEndLoc() const { return SourceLocation(); }
1348
1349 SourceLocation getExprLoc() const { return getUsedLocation(); }
1350
1351 static bool classof(const Stmt *T) {
1352 return T->getStmtClass() == CXXDefaultArgExprClass;
1353 }
1354
1355
1356 child_range children() {
1357 return child_range(child_iterator(), child_iterator());
1358 }
1359
1360 const_child_range children() const {
1361 return const_child_range(const_child_iterator(), const_child_iterator());
1362 }
1363 };
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373 class CXXDefaultInitExpr final
1374 : public Expr,
1375 private llvm::TrailingObjects<CXXDefaultInitExpr, Expr *> {
1376
1377 friend class ASTStmtReader;
1378 friend class ASTReader;
1379 friend TrailingObjects;
1380
1381 FieldDecl *Field;
1382
1383
1384 DeclContext *UsedContext;
1385
1386 CXXDefaultInitExpr(const ASTContext &Ctx, SourceLocation Loc,
1387 FieldDecl *Field, QualType Ty, DeclContext *UsedContext,
1388 Expr *RewrittenInitExpr);
1389
1390 CXXDefaultInitExpr(EmptyShell Empty, bool HasRewrittenInit)
1391 : Expr(CXXDefaultInitExprClass, Empty) {
1392 CXXDefaultInitExprBits.HasRewrittenInit = HasRewrittenInit;
1393 }
1394
1395 public:
1396 static CXXDefaultInitExpr *CreateEmpty(const ASTContext &C,
1397 bool HasRewrittenInit);
1398
1399
1400 static CXXDefaultInitExpr *Create(const ASTContext &Ctx, SourceLocation Loc,
1401 FieldDecl *Field, DeclContext *UsedContext,
1402 Expr *RewrittenInitExpr);
1403
1404 bool hasRewrittenInit() const {
1405 return CXXDefaultInitExprBits.HasRewrittenInit;
1406 }
1407
1408
1409 FieldDecl *getField() { return Field; }
1410 const FieldDecl *getField() const { return Field; }
1411
1412
1413 Expr *getExpr();
1414 const Expr *getExpr() const {
1415 return const_cast<CXXDefaultInitExpr *>(this)->getExpr();
1416 }
1417
1418
1419
1420 const Expr *getRewrittenExpr() const {
1421 assert(hasRewrittenInit() && "expected a rewritten init expression");
1422 return *getTrailingObjects<Expr *>();
1423 }
1424
1425
1426
1427 Expr *getRewrittenExpr() {
1428 assert(hasRewrittenInit() && "expected a rewritten init expression");
1429 return *getTrailingObjects<Expr *>();
1430 }
1431
1432 const DeclContext *getUsedContext() const { return UsedContext; }
1433 DeclContext *getUsedContext() { return UsedContext; }
1434
1435
1436
1437 SourceLocation getUsedLocation() const { return getBeginLoc(); }
1438
1439 SourceLocation getBeginLoc() const { return CXXDefaultInitExprBits.Loc; }
1440 SourceLocation getEndLoc() const { return CXXDefaultInitExprBits.Loc; }
1441
1442 static bool classof(const Stmt *T) {
1443 return T->getStmtClass() == CXXDefaultInitExprClass;
1444 }
1445
1446
1447 child_range children() {
1448 return child_range(child_iterator(), child_iterator());
1449 }
1450
1451 const_child_range children() const {
1452 return const_child_range(const_child_iterator(), const_child_iterator());
1453 }
1454 };
1455
1456
1457 class CXXTemporary {
1458
1459 const CXXDestructorDecl *Destructor;
1460
1461 explicit CXXTemporary(const CXXDestructorDecl *destructor)
1462 : Destructor(destructor) {}
1463
1464 public:
1465 static CXXTemporary *Create(const ASTContext &C,
1466 const CXXDestructorDecl *Destructor);
1467
1468 const CXXDestructorDecl *getDestructor() const { return Destructor; }
1469
1470 void setDestructor(const CXXDestructorDecl *Dtor) {
1471 Destructor = Dtor;
1472 }
1473 };
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491 class CXXBindTemporaryExpr : public Expr {
1492 CXXTemporary *Temp = nullptr;
1493 Stmt *SubExpr = nullptr;
1494
1495 CXXBindTemporaryExpr(CXXTemporary *temp, Expr *SubExpr)
1496 : Expr(CXXBindTemporaryExprClass, SubExpr->getType(), VK_PRValue,
1497 OK_Ordinary),
1498 Temp(temp), SubExpr(SubExpr) {
1499 setDependence(computeDependence(this));
1500 }
1501
1502 public:
1503 CXXBindTemporaryExpr(EmptyShell Empty)
1504 : Expr(CXXBindTemporaryExprClass, Empty) {}
1505
1506 static CXXBindTemporaryExpr *Create(const ASTContext &C, CXXTemporary *Temp,
1507 Expr* SubExpr);
1508
1509 CXXTemporary *getTemporary() { return Temp; }
1510 const CXXTemporary *getTemporary() const { return Temp; }
1511 void setTemporary(CXXTemporary *T) { Temp = T; }
1512
1513 const Expr *getSubExpr() const { return cast<Expr>(SubExpr); }
1514 Expr *getSubExpr() { return cast<Expr>(SubExpr); }
1515 void setSubExpr(Expr *E) { SubExpr = E; }
1516
1517 SourceLocation getBeginLoc() const LLVM_READONLY {
1518 return SubExpr->getBeginLoc();
1519 }
1520
1521 SourceLocation getEndLoc() const LLVM_READONLY {
1522 return SubExpr->getEndLoc();
1523 }
1524
1525
1526 static bool classof(const Stmt *T) {
1527 return T->getStmtClass() == CXXBindTemporaryExprClass;
1528 }
1529
1530
1531 child_range children() { return child_range(&SubExpr, &SubExpr + 1); }
1532
1533 const_child_range children() const {
1534 return const_child_range(&SubExpr, &SubExpr + 1);
1535 }
1536 };
1537
1538 enum class CXXConstructionKind {
1539 Complete,
1540 NonVirtualBase,
1541 VirtualBase,
1542 Delegating
1543 };
1544
1545
1546 class CXXConstructExpr : public Expr {
1547 friend class ASTStmtReader;
1548
1549
1550 CXXConstructorDecl *Constructor;
1551
1552 SourceRange ParenOrBraceRange;
1553
1554
1555 unsigned NumArgs;
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573 inline Stmt **getTrailingArgs();
1574 const Stmt *const *getTrailingArgs() const {
1575 return const_cast<CXXConstructExpr *>(this)->getTrailingArgs();
1576 }
1577
1578 protected:
1579
1580 CXXConstructExpr(StmtClass SC, QualType Ty, SourceLocation Loc,
1581 CXXConstructorDecl *Ctor, bool Elidable,
1582 ArrayRef<Expr *> Args, bool HadMultipleCandidates,
1583 bool ListInitialization, bool StdInitListInitialization,
1584 bool ZeroInitialization, CXXConstructionKind ConstructKind,
1585 SourceRange ParenOrBraceRange);
1586
1587
1588 CXXConstructExpr(StmtClass SC, EmptyShell Empty, unsigned NumArgs);
1589
1590
1591
1592 static unsigned sizeOfTrailingObjects(unsigned NumArgs) {
1593 return NumArgs * sizeof(Stmt *);
1594 }
1595
1596 public:
1597
1598 static CXXConstructExpr *
1599 Create(const ASTContext &Ctx, QualType Ty, SourceLocation Loc,
1600 CXXConstructorDecl *Ctor, bool Elidable, ArrayRef<Expr *> Args,
1601 bool HadMultipleCandidates, bool ListInitialization,
1602 bool StdInitListInitialization, bool ZeroInitialization,
1603 CXXConstructionKind ConstructKind, SourceRange ParenOrBraceRange);
1604
1605
1606 static CXXConstructExpr *CreateEmpty(const ASTContext &Ctx, unsigned NumArgs);
1607
1608
1609 CXXConstructorDecl *getConstructor() const { return Constructor; }
1610
1611 SourceLocation getLocation() const { return CXXConstructExprBits.Loc; }
1612 void setLocation(SourceLocation Loc) { CXXConstructExprBits.Loc = Loc; }
1613
1614
1615 bool isElidable() const { return CXXConstructExprBits.Elidable; }
1616 void setElidable(bool E) { CXXConstructExprBits.Elidable = E; }
1617
1618
1619
1620 bool hadMultipleCandidates() const {
1621 return CXXConstructExprBits.HadMultipleCandidates;
1622 }
1623 void setHadMultipleCandidates(bool V) {
1624 CXXConstructExprBits.HadMultipleCandidates = V;
1625 }
1626
1627
1628 bool isListInitialization() const {
1629 return CXXConstructExprBits.ListInitialization;
1630 }
1631 void setListInitialization(bool V) {
1632 CXXConstructExprBits.ListInitialization = V;
1633 }
1634
1635
1636
1637
1638
1639 bool isStdInitListInitialization() const {
1640 return CXXConstructExprBits.StdInitListInitialization;
1641 }
1642 void setStdInitListInitialization(bool V) {
1643 CXXConstructExprBits.StdInitListInitialization = V;
1644 }
1645
1646
1647
1648 bool requiresZeroInitialization() const {
1649 return CXXConstructExprBits.ZeroInitialization;
1650 }
1651 void setRequiresZeroInitialization(bool ZeroInit) {
1652 CXXConstructExprBits.ZeroInitialization = ZeroInit;
1653 }
1654
1655
1656
1657 CXXConstructionKind getConstructionKind() const {
1658 return static_cast<CXXConstructionKind>(
1659 CXXConstructExprBits.ConstructionKind);
1660 }
1661 void setConstructionKind(CXXConstructionKind CK) {
1662 CXXConstructExprBits.ConstructionKind = llvm::to_underlying(CK);
1663 }
1664
1665 using arg_iterator = ExprIterator;
1666 using const_arg_iterator = ConstExprIterator;
1667 using arg_range = llvm::iterator_range<arg_iterator>;
1668 using const_arg_range = llvm::iterator_range<const_arg_iterator>;
1669
1670 arg_range arguments() { return arg_range(arg_begin(), arg_end()); }
1671 const_arg_range arguments() const {
1672 return const_arg_range(arg_begin(), arg_end());
1673 }
1674
1675 arg_iterator arg_begin() { return getTrailingArgs(); }
1676 arg_iterator arg_end() { return arg_begin() + getNumArgs(); }
1677 const_arg_iterator arg_begin() const { return getTrailingArgs(); }
1678 const_arg_iterator arg_end() const { return arg_begin() + getNumArgs(); }
1679
1680 Expr **getArgs() { return reinterpret_cast<Expr **>(getTrailingArgs()); }
1681 const Expr *const *getArgs() const {
1682 return reinterpret_cast<const Expr *const *>(getTrailingArgs());
1683 }
1684
1685
1686 unsigned getNumArgs() const { return NumArgs; }
1687
1688
1689 Expr *getArg(unsigned Arg) {
1690 assert(Arg < getNumArgs() && "Arg access out of range!");
1691 return getArgs()[Arg];
1692 }
1693 const Expr *getArg(unsigned Arg) const {
1694 assert(Arg < getNumArgs() && "Arg access out of range!");
1695 return getArgs()[Arg];
1696 }
1697
1698
1699 void setArg(unsigned Arg, Expr *ArgExpr) {
1700 assert(Arg < getNumArgs() && "Arg access out of range!");
1701 getArgs()[Arg] = ArgExpr;
1702 }
1703
1704 bool isImmediateEscalating() const {
1705 return CXXConstructExprBits.IsImmediateEscalating;
1706 }
1707
1708 void setIsImmediateEscalating(bool Set) {
1709 CXXConstructExprBits.IsImmediateEscalating = Set;
1710 }
1711
1712 SourceLocation getBeginLoc() const LLVM_READONLY;
1713 SourceLocation getEndLoc() const LLVM_READONLY;
1714 SourceRange getParenOrBraceRange() const { return ParenOrBraceRange; }
1715 void setParenOrBraceRange(SourceRange Range) { ParenOrBraceRange = Range; }
1716
1717 static bool classof(const Stmt *T) {
1718 return T->getStmtClass() == CXXConstructExprClass ||
1719 T->getStmtClass() == CXXTemporaryObjectExprClass;
1720 }
1721
1722
1723 child_range children() {
1724 return child_range(getTrailingArgs(), getTrailingArgs() + getNumArgs());
1725 }
1726
1727 const_child_range children() const {
1728 auto Children = const_cast<CXXConstructExpr *>(this)->children();
1729 return const_child_range(Children.begin(), Children.end());
1730 }
1731 };
1732
1733
1734
1735
1736
1737 class CXXInheritedCtorInitExpr : public Expr {
1738 private:
1739 CXXConstructorDecl *Constructor = nullptr;
1740
1741
1742 SourceLocation Loc;
1743
1744
1745 LLVM_PREFERRED_TYPE(bool)
1746 unsigned ConstructsVirtualBase : 1;
1747
1748
1749
1750 LLVM_PREFERRED_TYPE(bool)
1751 unsigned InheritedFromVirtualBase : 1;
1752
1753 public:
1754 friend class ASTStmtReader;
1755
1756
1757 CXXInheritedCtorInitExpr(SourceLocation Loc, QualType T,
1758 CXXConstructorDecl *Ctor, bool ConstructsVirtualBase,
1759 bool InheritedFromVirtualBase)
1760 : Expr(CXXInheritedCtorInitExprClass, T, VK_PRValue, OK_Ordinary),
1761 Constructor(Ctor), Loc(Loc),
1762 ConstructsVirtualBase(ConstructsVirtualBase),
1763 InheritedFromVirtualBase(InheritedFromVirtualBase) {
1764 assert(!T->isDependentType());
1765 setDependence(ExprDependence::None);
1766 }
1767
1768
1769 explicit CXXInheritedCtorInitExpr(EmptyShell Empty)
1770 : Expr(CXXInheritedCtorInitExprClass, Empty),
1771 ConstructsVirtualBase(false), InheritedFromVirtualBase(false) {}
1772
1773
1774 CXXConstructorDecl *getConstructor() const { return Constructor; }
1775
1776
1777
1778 bool constructsVBase() const { return ConstructsVirtualBase; }
1779 CXXConstructionKind getConstructionKind() const {
1780 return ConstructsVirtualBase ? CXXConstructionKind::VirtualBase
1781 : CXXConstructionKind::NonVirtualBase;
1782 }
1783
1784
1785
1786
1787
1788 bool inheritedFromVBase() const { return InheritedFromVirtualBase; }
1789
1790 SourceLocation getLocation() const LLVM_READONLY { return Loc; }
1791 SourceLocation getBeginLoc() const LLVM_READONLY { return Loc; }
1792 SourceLocation getEndLoc() const LLVM_READONLY { return Loc; }
1793
1794 static bool classof(const Stmt *T) {
1795 return T->getStmtClass() == CXXInheritedCtorInitExprClass;
1796 }
1797
1798 child_range children() {
1799 return child_range(child_iterator(), child_iterator());
1800 }
1801
1802 const_child_range children() const {
1803 return const_child_range(const_child_iterator(), const_child_iterator());
1804 }
1805 };
1806
1807
1808
1809
1810
1811
1812
1813
1814 class CXXFunctionalCastExpr final
1815 : public ExplicitCastExpr,
1816 private llvm::TrailingObjects<CXXFunctionalCastExpr, CXXBaseSpecifier *,
1817 FPOptionsOverride> {
1818 SourceLocation LParenLoc;
1819 SourceLocation RParenLoc;
1820
1821 CXXFunctionalCastExpr(QualType ty, ExprValueKind VK,
1822 TypeSourceInfo *writtenTy, CastKind kind,
1823 Expr *castExpr, unsigned pathSize,
1824 FPOptionsOverride FPO, SourceLocation lParenLoc,
1825 SourceLocation rParenLoc)
1826 : ExplicitCastExpr(CXXFunctionalCastExprClass, ty, VK, kind, castExpr,
1827 pathSize, FPO.requiresTrailingStorage(), writtenTy),
1828 LParenLoc(lParenLoc), RParenLoc(rParenLoc) {
1829 if (hasStoredFPFeatures())
1830 *getTrailingFPFeatures() = FPO;
1831 }
1832
1833 explicit CXXFunctionalCastExpr(EmptyShell Shell, unsigned PathSize,
1834 bool HasFPFeatures)
1835 : ExplicitCastExpr(CXXFunctionalCastExprClass, Shell, PathSize,
1836 HasFPFeatures) {}
1837
1838 unsigned numTrailingObjects(OverloadToken<CXXBaseSpecifier *>) const {
1839 return path_size();
1840 }
1841
1842 public:
1843 friend class CastExpr;
1844 friend TrailingObjects;
1845
1846 static CXXFunctionalCastExpr *
1847 Create(const ASTContext &Context, QualType T, ExprValueKind VK,
1848 TypeSourceInfo *Written, CastKind Kind, Expr *Op,
1849 const CXXCastPath *Path, FPOptionsOverride FPO, SourceLocation LPLoc,
1850 SourceLocation RPLoc);
1851 static CXXFunctionalCastExpr *
1852 CreateEmpty(const ASTContext &Context, unsigned PathSize, bool HasFPFeatures);
1853
1854 SourceLocation getLParenLoc() const { return LParenLoc; }
1855 void setLParenLoc(SourceLocation L) { LParenLoc = L; }
1856 SourceLocation getRParenLoc() const { return RParenLoc; }
1857 void setRParenLoc(SourceLocation L) { RParenLoc = L; }
1858
1859
1860 bool isListInitialization() const { return LParenLoc.isInvalid(); }
1861
1862 SourceLocation getBeginLoc() const LLVM_READONLY;
1863 SourceLocation getEndLoc() const LLVM_READONLY;
1864
1865 static bool classof(const Stmt *T) {
1866 return T->getStmtClass() == CXXFunctionalCastExprClass;
1867 }
1868 };
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885 class CXXTemporaryObjectExpr final : public CXXConstructExpr {
1886 friend class ASTStmtReader;
1887
1888
1889
1890
1891
1892 TypeSourceInfo *TSI;
1893
1894 CXXTemporaryObjectExpr(CXXConstructorDecl *Cons, QualType Ty,
1895 TypeSourceInfo *TSI, ArrayRef<Expr *> Args,
1896 SourceRange ParenOrBraceRange,
1897 bool HadMultipleCandidates, bool ListInitialization,
1898 bool StdInitListInitialization,
1899 bool ZeroInitialization);
1900
1901 CXXTemporaryObjectExpr(EmptyShell Empty, unsigned NumArgs);
1902
1903 public:
1904 static CXXTemporaryObjectExpr *
1905 Create(const ASTContext &Ctx, CXXConstructorDecl *Cons, QualType Ty,
1906 TypeSourceInfo *TSI, ArrayRef<Expr *> Args,
1907 SourceRange ParenOrBraceRange, bool HadMultipleCandidates,
1908 bool ListInitialization, bool StdInitListInitialization,
1909 bool ZeroInitialization);
1910
1911 static CXXTemporaryObjectExpr *CreateEmpty(const ASTContext &Ctx,
1912 unsigned NumArgs);
1913
1914 TypeSourceInfo *getTypeSourceInfo() const { return TSI; }
1915
1916 SourceLocation getBeginLoc() const LLVM_READONLY;
1917 SourceLocation getEndLoc() const LLVM_READONLY;
1918
1919 static bool classof(const Stmt *T) {
1920 return T->getStmtClass() == CXXTemporaryObjectExprClass;
1921 }
1922 };
1923
1924 Stmt **CXXConstructExpr::getTrailingArgs() {
1925 if (auto *E = dyn_cast<CXXTemporaryObjectExpr>(this))
1926 return reinterpret_cast<Stmt **>(E + 1);
1927 assert((getStmtClass() == CXXConstructExprClass) &&
1928 "Unexpected class deriving from CXXConstructExpr!");
1929 return reinterpret_cast<Stmt **>(this + 1);
1930 }
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953 class LambdaExpr final : public Expr,
1954 private llvm::TrailingObjects<LambdaExpr, Stmt *> {
1955
1956
1957
1958 SourceRange IntroducerRange;
1959
1960
1961 SourceLocation CaptureDefaultLoc;
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971 SourceLocation ClosingBrace;
1972
1973
1974 LambdaExpr(QualType T, SourceRange IntroducerRange,
1975 LambdaCaptureDefault CaptureDefault,
1976 SourceLocation CaptureDefaultLoc, bool ExplicitParams,
1977 bool ExplicitResultType, ArrayRef<Expr *> CaptureInits,
1978 SourceLocation ClosingBrace, bool ContainsUnexpandedParameterPack);
1979
1980
1981 LambdaExpr(EmptyShell Empty, unsigned NumCaptures);
1982
1983 Stmt **getStoredStmts() { return getTrailingObjects<Stmt *>(); }
1984 Stmt *const *getStoredStmts() const { return getTrailingObjects<Stmt *>(); }
1985
1986 void initBodyIfNeeded() const;
1987
1988 public:
1989 friend class ASTStmtReader;
1990 friend class ASTStmtWriter;
1991 friend TrailingObjects;
1992
1993
1994 static LambdaExpr *
1995 Create(const ASTContext &C, CXXRecordDecl *Class, SourceRange IntroducerRange,
1996 LambdaCaptureDefault CaptureDefault, SourceLocation CaptureDefaultLoc,
1997 bool ExplicitParams, bool ExplicitResultType,
1998 ArrayRef<Expr *> CaptureInits, SourceLocation ClosingBrace,
1999 bool ContainsUnexpandedParameterPack);
2000
2001
2002
2003 static LambdaExpr *CreateDeserialized(const ASTContext &C,
2004 unsigned NumCaptures);
2005
2006
2007 LambdaCaptureDefault getCaptureDefault() const {
2008 return static_cast<LambdaCaptureDefault>(LambdaExprBits.CaptureDefault);
2009 }
2010
2011
2012 SourceLocation getCaptureDefaultLoc() const { return CaptureDefaultLoc; }
2013
2014
2015 bool isInitCapture(const LambdaCapture *Capture) const;
2016
2017
2018
2019 using capture_iterator = const LambdaCapture *;
2020
2021
2022 using capture_range = llvm::iterator_range<capture_iterator>;
2023
2024
2025 capture_range captures() const;
2026
2027
2028 capture_iterator capture_begin() const;
2029
2030
2031
2032 capture_iterator capture_end() const;
2033
2034
2035 unsigned capture_size() const { return LambdaExprBits.NumCaptures; }
2036
2037
2038 capture_range explicit_captures() const;
2039
2040
2041
2042 capture_iterator explicit_capture_begin() const;
2043
2044
2045
2046 capture_iterator explicit_capture_end() const;
2047
2048
2049 capture_range implicit_captures() const;
2050
2051
2052
2053 capture_iterator implicit_capture_begin() const;
2054
2055
2056
2057 capture_iterator implicit_capture_end() const;
2058
2059
2060
2061 using capture_init_iterator = Expr **;
2062
2063
2064
2065
2066 using const_capture_init_iterator = Expr *const *;
2067
2068
2069 llvm::iterator_range<capture_init_iterator> capture_inits() {
2070 return llvm::make_range(capture_init_begin(), capture_init_end());
2071 }
2072
2073
2074 llvm::iterator_range<const_capture_init_iterator> capture_inits() const {
2075 return llvm::make_range(capture_init_begin(), capture_init_end());
2076 }
2077
2078
2079
2080 capture_init_iterator capture_init_begin() {
2081 return reinterpret_cast<Expr **>(getStoredStmts());
2082 }
2083
2084
2085
2086 const_capture_init_iterator capture_init_begin() const {
2087 return reinterpret_cast<Expr *const *>(getStoredStmts());
2088 }
2089
2090
2091
2092 capture_init_iterator capture_init_end() {
2093 return capture_init_begin() + capture_size();
2094 }
2095
2096
2097
2098 const_capture_init_iterator capture_init_end() const {
2099 return capture_init_begin() + capture_size();
2100 }
2101
2102
2103
2104
2105 SourceRange getIntroducerRange() const { return IntroducerRange; }
2106
2107
2108
2109
2110
2111
2112 CXXRecordDecl *getLambdaClass() const;
2113
2114
2115
2116 CXXMethodDecl *getCallOperator() const;
2117
2118
2119
2120 FunctionTemplateDecl *getDependentCallOperator() const;
2121
2122
2123
2124 TemplateParameterList *getTemplateParameterList() const;
2125
2126
2127
2128 ArrayRef<NamedDecl *> getExplicitTemplateParameters() const;
2129
2130
2131 Expr *getTrailingRequiresClause() const;
2132
2133
2134 bool isGenericLambda() const { return getTemplateParameterList(); }
2135
2136
2137
2138
2139
2140 Stmt *getBody() const;
2141
2142
2143
2144
2145 const CompoundStmt *getCompoundStmtBody() const;
2146 CompoundStmt *getCompoundStmtBody() {
2147 const auto *ConstThis = this;
2148 return const_cast<CompoundStmt *>(ConstThis->getCompoundStmtBody());
2149 }
2150
2151
2152
2153 bool isMutable() const;
2154
2155
2156
2157 bool hasExplicitParameters() const { return LambdaExprBits.ExplicitParams; }
2158
2159
2160 bool hasExplicitResultType() const {
2161 return LambdaExprBits.ExplicitResultType;
2162 }
2163
2164 static bool classof(const Stmt *T) {
2165 return T->getStmtClass() == LambdaExprClass;
2166 }
2167
2168 SourceLocation getBeginLoc() const LLVM_READONLY {
2169 return IntroducerRange.getBegin();
2170 }
2171
2172 SourceLocation getEndLoc() const LLVM_READONLY { return ClosingBrace; }
2173
2174
2175 child_range children();
2176 const_child_range children() const;
2177 };
2178
2179
2180
2181
2182 class CXXScalarValueInitExpr : public Expr {
2183 friend class ASTStmtReader;
2184
2185 TypeSourceInfo *TypeInfo;
2186
2187 public:
2188
2189
2190 CXXScalarValueInitExpr(QualType Type, TypeSourceInfo *TypeInfo,
2191 SourceLocation RParenLoc)
2192 : Expr(CXXScalarValueInitExprClass, Type, VK_PRValue, OK_Ordinary),
2193 TypeInfo(TypeInfo) {
2194 CXXScalarValueInitExprBits.RParenLoc = RParenLoc;
2195 setDependence(computeDependence(this));
2196 }
2197
2198 explicit CXXScalarValueInitExpr(EmptyShell Shell)
2199 : Expr(CXXScalarValueInitExprClass, Shell) {}
2200
2201 TypeSourceInfo *getTypeSourceInfo() const {
2202 return TypeInfo;
2203 }
2204
2205 SourceLocation getRParenLoc() const {
2206 return CXXScalarValueInitExprBits.RParenLoc;
2207 }
2208
2209 SourceLocation getBeginLoc() const LLVM_READONLY;
2210 SourceLocation getEndLoc() const { return getRParenLoc(); }
2211
2212 static bool classof(const Stmt *T) {
2213 return T->getStmtClass() == CXXScalarValueInitExprClass;
2214 }
2215
2216
2217 child_range children() {
2218 return child_range(child_iterator(), child_iterator());
2219 }
2220
2221 const_child_range children() const {
2222 return const_child_range(const_child_iterator(), const_child_iterator());
2223 }
2224 };
2225
2226 enum class CXXNewInitializationStyle {
2227
2228 None,
2229
2230
2231 Parens,
2232
2233
2234 Braces
2235 };
2236
2237
2238
2239 class CXXNewExpr final
2240 : public Expr,
2241 private llvm::TrailingObjects<CXXNewExpr, Stmt *, SourceRange> {
2242 friend class ASTStmtReader;
2243 friend class ASTStmtWriter;
2244 friend TrailingObjects;
2245
2246
2247 FunctionDecl *OperatorNew;
2248
2249
2250 FunctionDecl *OperatorDelete;
2251
2252
2253 TypeSourceInfo *AllocatedTypeInfo;
2254
2255
2256 SourceRange Range;
2257
2258
2259 SourceRange DirectInitRange;
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276 unsigned arraySizeOffset() const { return 0; }
2277 unsigned initExprOffset() const { return arraySizeOffset() + isArray(); }
2278 unsigned placementNewArgsOffset() const {
2279 return initExprOffset() + hasInitializer();
2280 }
2281
2282 unsigned numTrailingObjects(OverloadToken<Stmt *>) const {
2283 return isArray() + hasInitializer() + getNumPlacementArgs();
2284 }
2285
2286 unsigned numTrailingObjects(OverloadToken<SourceRange>) const {
2287 return isParenTypeId();
2288 }
2289
2290
2291 CXXNewExpr(bool IsGlobalNew, FunctionDecl *OperatorNew,
2292 FunctionDecl *OperatorDelete, bool ShouldPassAlignment,
2293 bool UsualArrayDeleteWantsSize, ArrayRef<Expr *> PlacementArgs,
2294 SourceRange TypeIdParens, std::optional<Expr *> ArraySize,
2295 CXXNewInitializationStyle InitializationStyle, Expr *Initializer,
2296 QualType Ty, TypeSourceInfo *AllocatedTypeInfo, SourceRange Range,
2297 SourceRange DirectInitRange);
2298
2299
2300 CXXNewExpr(EmptyShell Empty, bool IsArray, unsigned NumPlacementArgs,
2301 bool IsParenTypeId);
2302
2303 public:
2304
2305 static CXXNewExpr *
2306 Create(const ASTContext &Ctx, bool IsGlobalNew, FunctionDecl *OperatorNew,
2307 FunctionDecl *OperatorDelete, bool ShouldPassAlignment,
2308 bool UsualArrayDeleteWantsSize, ArrayRef<Expr *> PlacementArgs,
2309 SourceRange TypeIdParens, std::optional<Expr *> ArraySize,
2310 CXXNewInitializationStyle InitializationStyle, Expr *Initializer,
2311 QualType Ty, TypeSourceInfo *AllocatedTypeInfo, SourceRange Range,
2312 SourceRange DirectInitRange);
2313
2314
2315 static CXXNewExpr *CreateEmpty(const ASTContext &Ctx, bool IsArray,
2316 bool HasInit, unsigned NumPlacementArgs,
2317 bool IsParenTypeId);
2318
2319 QualType getAllocatedType() const {
2320 return getType()->castAs<PointerType>()->getPointeeType();
2321 }
2322
2323 TypeSourceInfo *getAllocatedTypeSourceInfo() const {
2324 return AllocatedTypeInfo;
2325 }
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342 bool shouldNullCheckAllocation() const;
2343
2344 FunctionDecl *getOperatorNew() const { return OperatorNew; }
2345 void setOperatorNew(FunctionDecl *D) { OperatorNew = D; }
2346 FunctionDecl *getOperatorDelete() const { return OperatorDelete; }
2347 void setOperatorDelete(FunctionDecl *D) { OperatorDelete = D; }
2348
2349 bool isArray() const { return CXXNewExprBits.IsArray; }
2350
2351
2352
2353
2354 std::optional<Expr *> getArraySize() {
2355 if (!isArray())
2356 return std::nullopt;
2357
2358 if (auto *Result =
2359 cast_or_null<Expr>(getTrailingObjects<Stmt *>()[arraySizeOffset()]))
2360 return Result;
2361
2362 return std::nullopt;
2363 }
2364
2365
2366
2367
2368 std::optional<const Expr *> getArraySize() const {
2369 if (!isArray())
2370 return std::nullopt;
2371
2372 if (auto *Result =
2373 cast_or_null<Expr>(getTrailingObjects<Stmt *>()[arraySizeOffset()]))
2374 return Result;
2375
2376 return std::nullopt;
2377 }
2378
2379 unsigned getNumPlacementArgs() const {
2380 return CXXNewExprBits.NumPlacementArgs;
2381 }
2382
2383 Expr **getPlacementArgs() {
2384 return reinterpret_cast<Expr **>(getTrailingObjects<Stmt *>() +
2385 placementNewArgsOffset());
2386 }
2387
2388 Expr *getPlacementArg(unsigned I) {
2389 assert((I < getNumPlacementArgs()) && "Index out of range!");
2390 return getPlacementArgs()[I];
2391 }
2392 const Expr *getPlacementArg(unsigned I) const {
2393 return const_cast<CXXNewExpr *>(this)->getPlacementArg(I);
2394 }
2395
2396 bool isParenTypeId() const { return CXXNewExprBits.IsParenTypeId; }
2397 SourceRange getTypeIdParens() const {
2398 return isParenTypeId() ? getTrailingObjects<SourceRange>()[0]
2399 : SourceRange();
2400 }
2401
2402 bool isGlobalNew() const { return CXXNewExprBits.IsGlobalNew; }
2403
2404
2405 bool hasInitializer() const { return CXXNewExprBits.HasInitializer; }
2406
2407
2408 CXXNewInitializationStyle getInitializationStyle() const {
2409 return static_cast<CXXNewInitializationStyle>(
2410 CXXNewExprBits.StoredInitializationStyle);
2411 }
2412
2413
2414 Expr *getInitializer() {
2415 return hasInitializer()
2416 ? cast<Expr>(getTrailingObjects<Stmt *>()[initExprOffset()])
2417 : nullptr;
2418 }
2419 const Expr *getInitializer() const {
2420 return hasInitializer()
2421 ? cast<Expr>(getTrailingObjects<Stmt *>()[initExprOffset()])
2422 : nullptr;
2423 }
2424
2425
2426 const CXXConstructExpr *getConstructExpr() const {
2427 return dyn_cast_or_null<CXXConstructExpr>(getInitializer());
2428 }
2429
2430
2431
2432 bool passAlignment() const { return CXXNewExprBits.ShouldPassAlignment; }
2433
2434
2435
2436
2437 bool doesUsualArrayDeleteWantSize() const {
2438 return CXXNewExprBits.UsualArrayDeleteWantsSize;
2439 }
2440
2441 using arg_iterator = ExprIterator;
2442 using const_arg_iterator = ConstExprIterator;
2443
2444 llvm::iterator_range<arg_iterator> placement_arguments() {
2445 return llvm::make_range(placement_arg_begin(), placement_arg_end());
2446 }
2447
2448 llvm::iterator_range<const_arg_iterator> placement_arguments() const {
2449 return llvm::make_range(placement_arg_begin(), placement_arg_end());
2450 }
2451
2452 arg_iterator placement_arg_begin() {
2453 return getTrailingObjects<Stmt *>() + placementNewArgsOffset();
2454 }
2455 arg_iterator placement_arg_end() {
2456 return placement_arg_begin() + getNumPlacementArgs();
2457 }
2458 const_arg_iterator placement_arg_begin() const {
2459 return getTrailingObjects<Stmt *>() + placementNewArgsOffset();
2460 }
2461 const_arg_iterator placement_arg_end() const {
2462 return placement_arg_begin() + getNumPlacementArgs();
2463 }
2464
2465 using raw_arg_iterator = Stmt **;
2466
2467 raw_arg_iterator raw_arg_begin() { return getTrailingObjects<Stmt *>(); }
2468 raw_arg_iterator raw_arg_end() {
2469 return raw_arg_begin() + numTrailingObjects(OverloadToken<Stmt *>());
2470 }
2471 const_arg_iterator raw_arg_begin() const {
2472 return getTrailingObjects<Stmt *>();
2473 }
2474 const_arg_iterator raw_arg_end() const {
2475 return raw_arg_begin() + numTrailingObjects(OverloadToken<Stmt *>());
2476 }
2477
2478 SourceLocation getBeginLoc() const { return Range.getBegin(); }
2479 SourceLocation getEndLoc() const { return Range.getEnd(); }
2480
2481 SourceRange getDirectInitRange() const { return DirectInitRange; }
2482 SourceRange getSourceRange() const { return Range; }
2483
2484 static bool classof(const Stmt *T) {
2485 return T->getStmtClass() == CXXNewExprClass;
2486 }
2487
2488
2489 child_range children() { return child_range(raw_arg_begin(), raw_arg_end()); }
2490
2491 const_child_range children() const {
2492 return const_child_range(const_cast<CXXNewExpr *>(this)->children());
2493 }
2494 };
2495
2496
2497
2498 class CXXDeleteExpr : public Expr {
2499 friend class ASTStmtReader;
2500
2501
2502 FunctionDecl *OperatorDelete = nullptr;
2503
2504
2505 Stmt *Argument = nullptr;
2506
2507 public:
2508 CXXDeleteExpr(QualType Ty, bool GlobalDelete, bool ArrayForm,
2509 bool ArrayFormAsWritten, bool UsualArrayDeleteWantsSize,
2510 FunctionDecl *OperatorDelete, Expr *Arg, SourceLocation Loc)
2511 : Expr(CXXDeleteExprClass, Ty, VK_PRValue, OK_Ordinary),
2512 OperatorDelete(OperatorDelete), Argument(Arg) {
2513 CXXDeleteExprBits.GlobalDelete = GlobalDelete;
2514 CXXDeleteExprBits.ArrayForm = ArrayForm;
2515 CXXDeleteExprBits.ArrayFormAsWritten = ArrayFormAsWritten;
2516 CXXDeleteExprBits.UsualArrayDeleteWantsSize = UsualArrayDeleteWantsSize;
2517 CXXDeleteExprBits.Loc = Loc;
2518 setDependence(computeDependence(this));
2519 }
2520
2521 explicit CXXDeleteExpr(EmptyShell Shell) : Expr(CXXDeleteExprClass, Shell) {}
2522
2523 bool isGlobalDelete() const { return CXXDeleteExprBits.GlobalDelete; }
2524 bool isArrayForm() const { return CXXDeleteExprBits.ArrayForm; }
2525 bool isArrayFormAsWritten() const {
2526 return CXXDeleteExprBits.ArrayFormAsWritten;
2527 }
2528
2529
2530
2531
2532
2533 bool doesUsualArrayDeleteWantSize() const {
2534 return CXXDeleteExprBits.UsualArrayDeleteWantsSize;
2535 }
2536
2537 FunctionDecl *getOperatorDelete() const { return OperatorDelete; }
2538
2539 Expr *getArgument() { return cast<Expr>(Argument); }
2540 const Expr *getArgument() const { return cast<Expr>(Argument); }
2541
2542
2543
2544
2545
2546 QualType getDestroyedType() const;
2547
2548 SourceLocation getBeginLoc() const { return CXXDeleteExprBits.Loc; }
2549 SourceLocation getEndLoc() const LLVM_READONLY {
2550 return Argument->getEndLoc();
2551 }
2552
2553 static bool classof(const Stmt *T) {
2554 return T->getStmtClass() == CXXDeleteExprClass;
2555 }
2556
2557
2558 child_range children() { return child_range(&Argument, &Argument + 1); }
2559
2560 const_child_range children() const {
2561 return const_child_range(&Argument, &Argument + 1);
2562 }
2563 };
2564
2565
2566 class PseudoDestructorTypeStorage {
2567
2568
2569 llvm::PointerUnion<TypeSourceInfo *, const IdentifierInfo *> Type;
2570
2571
2572 SourceLocation Location;
2573
2574 public:
2575 PseudoDestructorTypeStorage() = default;
2576
2577 PseudoDestructorTypeStorage(const IdentifierInfo *II, SourceLocation Loc)
2578 : Type(II), Location(Loc) {}
2579
2580 PseudoDestructorTypeStorage(TypeSourceInfo *Info);
2581
2582 TypeSourceInfo *getTypeSourceInfo() const {
2583 return Type.dyn_cast<TypeSourceInfo *>();
2584 }
2585
2586 const IdentifierInfo *getIdentifier() const {
2587 return Type.dyn_cast<const IdentifierInfo *>();
2588 }
2589
2590 SourceLocation getLocation() const { return Location; }
2591 };
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617 class CXXPseudoDestructorExpr : public Expr {
2618 friend class ASTStmtReader;
2619
2620
2621 Stmt *Base = nullptr;
2622
2623
2624
2625 LLVM_PREFERRED_TYPE(bool)
2626 bool IsArrow : 1;
2627
2628
2629 SourceLocation OperatorLoc;
2630
2631
2632 NestedNameSpecifierLoc QualifierLoc;
2633
2634
2635
2636 TypeSourceInfo *ScopeType = nullptr;
2637
2638
2639
2640 SourceLocation ColonColonLoc;
2641
2642
2643 SourceLocation TildeLoc;
2644
2645
2646
2647 PseudoDestructorTypeStorage DestroyedType;
2648
2649 public:
2650 CXXPseudoDestructorExpr(const ASTContext &Context,
2651 Expr *Base, bool isArrow, SourceLocation OperatorLoc,
2652 NestedNameSpecifierLoc QualifierLoc,
2653 TypeSourceInfo *ScopeType,
2654 SourceLocation ColonColonLoc,
2655 SourceLocation TildeLoc,
2656 PseudoDestructorTypeStorage DestroyedType);
2657
2658 explicit CXXPseudoDestructorExpr(EmptyShell Shell)
2659 : Expr(CXXPseudoDestructorExprClass, Shell), IsArrow(false) {}
2660
2661 Expr *getBase() const { return cast<Expr>(Base); }
2662
2663
2664
2665
2666 bool hasQualifier() const { return QualifierLoc.hasQualifier(); }
2667
2668
2669
2670 NestedNameSpecifierLoc getQualifierLoc() const { return QualifierLoc; }
2671
2672
2673
2674
2675 NestedNameSpecifier *getQualifier() const {
2676 return QualifierLoc.getNestedNameSpecifier();
2677 }
2678
2679
2680
2681 bool isArrow() const { return IsArrow; }
2682
2683
2684 SourceLocation getOperatorLoc() const { return OperatorLoc; }
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695 TypeSourceInfo *getScopeTypeInfo() const { return ScopeType; }
2696
2697
2698
2699 SourceLocation getColonColonLoc() const { return ColonColonLoc; }
2700
2701
2702 SourceLocation getTildeLoc() const { return TildeLoc; }
2703
2704
2705
2706
2707
2708
2709
2710
2711 TypeSourceInfo *getDestroyedTypeInfo() const {
2712 return DestroyedType.getTypeSourceInfo();
2713 }
2714
2715
2716
2717
2718 const IdentifierInfo *getDestroyedTypeIdentifier() const {
2719 return DestroyedType.getIdentifier();
2720 }
2721
2722
2723 QualType getDestroyedType() const;
2724
2725
2726 SourceLocation getDestroyedTypeLoc() const {
2727 return DestroyedType.getLocation();
2728 }
2729
2730
2731
2732 void setDestroyedType(IdentifierInfo *II, SourceLocation Loc) {
2733 DestroyedType = PseudoDestructorTypeStorage(II, Loc);
2734 }
2735
2736
2737 void setDestroyedType(TypeSourceInfo *Info) {
2738 DestroyedType = PseudoDestructorTypeStorage(Info);
2739 }
2740
2741 SourceLocation getBeginLoc() const LLVM_READONLY {
2742 return Base->getBeginLoc();
2743 }
2744 SourceLocation getEndLoc() const LLVM_READONLY;
2745
2746 static bool classof(const Stmt *T) {
2747 return T->getStmtClass() == CXXPseudoDestructorExprClass;
2748 }
2749
2750
2751 child_range children() { return child_range(&Base, &Base + 1); }
2752
2753 const_child_range children() const {
2754 return const_child_range(&Base, &Base + 1);
2755 }
2756 };
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766 class TypeTraitExpr final
2767 : public Expr,
2768 private llvm::TrailingObjects<TypeTraitExpr, TypeSourceInfo *> {
2769
2770 SourceLocation Loc;
2771
2772
2773 SourceLocation RParenLoc;
2774
2775
2776
2777
2778 TypeTraitExpr(QualType T, SourceLocation Loc, TypeTrait Kind,
2779 ArrayRef<TypeSourceInfo *> Args,
2780 SourceLocation RParenLoc,
2781 bool Value);
2782
2783 TypeTraitExpr(EmptyShell Empty) : Expr(TypeTraitExprClass, Empty) {}
2784
2785 size_t numTrailingObjects(OverloadToken<TypeSourceInfo *>) const {
2786 return getNumArgs();
2787 }
2788
2789 public:
2790 friend class ASTStmtReader;
2791 friend class ASTStmtWriter;
2792 friend TrailingObjects;
2793
2794
2795 static TypeTraitExpr *Create(const ASTContext &C, QualType T,
2796 SourceLocation Loc, TypeTrait Kind,
2797 ArrayRef<TypeSourceInfo *> Args,
2798 SourceLocation RParenLoc,
2799 bool Value);
2800
2801 static TypeTraitExpr *CreateDeserialized(const ASTContext &C,
2802 unsigned NumArgs);
2803
2804
2805 TypeTrait getTrait() const {
2806 return static_cast<TypeTrait>(TypeTraitExprBits.Kind);
2807 }
2808
2809 bool getValue() const {
2810 assert(!isValueDependent());
2811 return TypeTraitExprBits.Value;
2812 }
2813
2814
2815 unsigned getNumArgs() const { return TypeTraitExprBits.NumArgs; }
2816
2817
2818 TypeSourceInfo *getArg(unsigned I) const {
2819 assert(I < getNumArgs() && "Argument out-of-range");
2820 return getArgs()[I];
2821 }
2822
2823
2824 ArrayRef<TypeSourceInfo *> getArgs() const {
2825 return llvm::ArrayRef(getTrailingObjects<TypeSourceInfo *>(), getNumArgs());
2826 }
2827
2828 SourceLocation getBeginLoc() const LLVM_READONLY { return Loc; }
2829 SourceLocation getEndLoc() const LLVM_READONLY { return RParenLoc; }
2830
2831 static bool classof(const Stmt *T) {
2832 return T->getStmtClass() == TypeTraitExprClass;
2833 }
2834
2835
2836 child_range children() {
2837 return child_range(child_iterator(), child_iterator());
2838 }
2839
2840 const_child_range children() const {
2841 return const_child_range(const_child_iterator(), const_child_iterator());
2842 }
2843 };
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853 class ArrayTypeTraitExpr : public Expr {
2854
2855 LLVM_PREFERRED_TYPE(ArrayTypeTrait)
2856 unsigned ATT : 2;
2857
2858
2859 uint64_t Value = 0;
2860
2861
2862 Expr *Dimension;
2863
2864
2865 SourceLocation Loc;
2866
2867
2868 SourceLocation RParen;
2869
2870
2871 TypeSourceInfo *QueriedType = nullptr;
2872
2873 public:
2874 friend class ASTStmtReader;
2875
2876 ArrayTypeTraitExpr(SourceLocation loc, ArrayTypeTrait att,
2877 TypeSourceInfo *queried, uint64_t value, Expr *dimension,
2878 SourceLocation rparen, QualType ty)
2879 : Expr(ArrayTypeTraitExprClass, ty, VK_PRValue, OK_Ordinary), ATT(att),
2880 Value(value), Dimension(dimension), Loc(loc), RParen(rparen),
2881 QueriedType(queried) {
2882 assert(att <= ATT_Last && "invalid enum value!");
2883 assert(static_cast<unsigned>(att) == ATT && "ATT overflow!");
2884 setDependence(computeDependence(this));
2885 }
2886
2887 explicit ArrayTypeTraitExpr(EmptyShell Empty)
2888 : Expr(ArrayTypeTraitExprClass, Empty), ATT(0) {}
2889
2890 SourceLocation getBeginLoc() const LLVM_READONLY { return Loc; }
2891 SourceLocation getEndLoc() const LLVM_READONLY { return RParen; }
2892
2893 ArrayTypeTrait getTrait() const { return static_cast<ArrayTypeTrait>(ATT); }
2894
2895 QualType getQueriedType() const { return QueriedType->getType(); }
2896
2897 TypeSourceInfo *getQueriedTypeSourceInfo() const { return QueriedType; }
2898
2899 uint64_t getValue() const { assert(!isTypeDependent()); return Value; }
2900
2901 Expr *getDimensionExpression() const { return Dimension; }
2902
2903 static bool classof(const Stmt *T) {
2904 return T->getStmtClass() == ArrayTypeTraitExprClass;
2905 }
2906
2907
2908 child_range children() {
2909 return child_range(child_iterator(), child_iterator());
2910 }
2911
2912 const_child_range children() const {
2913 return const_child_range(const_child_iterator(), const_child_iterator());
2914 }
2915 };
2916
2917
2918
2919
2920
2921
2922
2923
2924 class ExpressionTraitExpr : public Expr {
2925
2926 LLVM_PREFERRED_TYPE(ExpressionTrait)
2927 unsigned ET : 31;
2928
2929
2930 LLVM_PREFERRED_TYPE(bool)
2931 unsigned Value : 1;
2932
2933
2934 SourceLocation Loc;
2935
2936
2937 SourceLocation RParen;
2938
2939
2940 Expr* QueriedExpression = nullptr;
2941
2942 public:
2943 friend class ASTStmtReader;
2944
2945 ExpressionTraitExpr(SourceLocation loc, ExpressionTrait et, Expr *queried,
2946 bool value, SourceLocation rparen, QualType resultType)
2947 : Expr(ExpressionTraitExprClass, resultType, VK_PRValue, OK_Ordinary),
2948 ET(et), Value(value), Loc(loc), RParen(rparen),
2949 QueriedExpression(queried) {
2950 assert(et <= ET_Last && "invalid enum value!");
2951 assert(static_cast<unsigned>(et) == ET && "ET overflow!");
2952 setDependence(computeDependence(this));
2953 }
2954
2955 explicit ExpressionTraitExpr(EmptyShell Empty)
2956 : Expr(ExpressionTraitExprClass, Empty), ET(0), Value(false) {}
2957
2958 SourceLocation getBeginLoc() const LLVM_READONLY { return Loc; }
2959 SourceLocation getEndLoc() const LLVM_READONLY { return RParen; }
2960
2961 ExpressionTrait getTrait() const { return static_cast<ExpressionTrait>(ET); }
2962
2963 Expr *getQueriedExpression() const { return QueriedExpression; }
2964
2965 bool getValue() const { return Value; }
2966
2967 static bool classof(const Stmt *T) {
2968 return T->getStmtClass() == ExpressionTraitExprClass;
2969 }
2970
2971
2972 child_range children() {
2973 return child_range(child_iterator(), child_iterator());
2974 }
2975
2976 const_child_range children() const {
2977 return const_child_range(const_child_iterator(), const_child_iterator());
2978 }
2979 };
2980
2981
2982
2983 class OverloadExpr : public Expr {
2984 friend class ASTStmtReader;
2985 friend class ASTStmtWriter;
2986
2987
2988 DeclarationNameInfo NameInfo;
2989
2990
2991 NestedNameSpecifierLoc QualifierLoc;
2992
2993 protected:
2994 OverloadExpr(StmtClass SC, const ASTContext &Context,
2995 NestedNameSpecifierLoc QualifierLoc,
2996 SourceLocation TemplateKWLoc,
2997 const DeclarationNameInfo &NameInfo,
2998 const TemplateArgumentListInfo *TemplateArgs,
2999 UnresolvedSetIterator Begin, UnresolvedSetIterator End,
3000 bool KnownDependent, bool KnownInstantiationDependent,
3001 bool KnownContainsUnexpandedParameterPack);
3002
3003 OverloadExpr(StmtClass SC, EmptyShell Empty, unsigned NumResults,
3004 bool HasTemplateKWAndArgsInfo);
3005
3006
3007 inline DeclAccessPair *getTrailingResults();
3008 const DeclAccessPair *getTrailingResults() const {
3009 return const_cast<OverloadExpr *>(this)->getTrailingResults();
3010 }
3011
3012
3013
3014 inline ASTTemplateKWAndArgsInfo *getTrailingASTTemplateKWAndArgsInfo();
3015 const ASTTemplateKWAndArgsInfo *getTrailingASTTemplateKWAndArgsInfo() const {
3016 return const_cast<OverloadExpr *>(this)
3017 ->getTrailingASTTemplateKWAndArgsInfo();
3018 }
3019
3020
3021
3022 inline TemplateArgumentLoc *getTrailingTemplateArgumentLoc();
3023 const TemplateArgumentLoc *getTrailingTemplateArgumentLoc() const {
3024 return const_cast<OverloadExpr *>(this)->getTrailingTemplateArgumentLoc();
3025 }
3026
3027 bool hasTemplateKWAndArgsInfo() const {
3028 return OverloadExprBits.HasTemplateKWAndArgsInfo;
3029 }
3030
3031 public:
3032 struct FindResult {
3033 OverloadExpr *Expression = nullptr;
3034 bool IsAddressOfOperand = false;
3035 bool IsAddressOfOperandWithParen = false;
3036 bool HasFormOfMemberPointer = false;
3037 };
3038
3039
3040
3041
3042
3043
3044 static FindResult find(Expr *E) {
3045 assert(E->getType()->isSpecificBuiltinType(BuiltinType::Overload));
3046
3047 FindResult Result;
3048 bool HasParen = isa<ParenExpr>(E);
3049
3050 E = E->IgnoreParens();
3051 if (isa<UnaryOperator>(E)) {
3052 assert(cast<UnaryOperator>(E)->getOpcode() == UO_AddrOf);
3053 E = cast<UnaryOperator>(E)->getSubExpr();
3054 auto *Ovl = cast<OverloadExpr>(E->IgnoreParens());
3055
3056 Result.HasFormOfMemberPointer = (E == Ovl && Ovl->getQualifier());
3057 Result.IsAddressOfOperand = true;
3058 Result.IsAddressOfOperandWithParen = HasParen;
3059 Result.Expression = Ovl;
3060 } else {
3061 Result.Expression = cast<OverloadExpr>(E);
3062 }
3063
3064 return Result;
3065 }
3066
3067
3068
3069 inline CXXRecordDecl *getNamingClass();
3070 const CXXRecordDecl *getNamingClass() const {
3071 return const_cast<OverloadExpr *>(this)->getNamingClass();
3072 }
3073
3074 using decls_iterator = UnresolvedSetImpl::iterator;
3075
3076 decls_iterator decls_begin() const {
3077 return UnresolvedSetIterator(getTrailingResults());
3078 }
3079 decls_iterator decls_end() const {
3080 return UnresolvedSetIterator(getTrailingResults() + getNumDecls());
3081 }
3082 llvm::iterator_range<decls_iterator> decls() const {
3083 return llvm::make_range(decls_begin(), decls_end());
3084 }
3085
3086
3087 unsigned getNumDecls() const { return OverloadExprBits.NumResults; }
3088
3089
3090 const DeclarationNameInfo &getNameInfo() const { return NameInfo; }
3091
3092
3093 DeclarationName getName() const { return NameInfo.getName(); }
3094
3095
3096 SourceLocation getNameLoc() const { return NameInfo.getLoc(); }
3097
3098
3099 NestedNameSpecifier *getQualifier() const {
3100 return QualifierLoc.getNestedNameSpecifier();
3101 }
3102
3103
3104
3105 NestedNameSpecifierLoc getQualifierLoc() const { return QualifierLoc; }
3106
3107
3108
3109 SourceLocation getTemplateKeywordLoc() const {
3110 if (!hasTemplateKWAndArgsInfo())
3111 return SourceLocation();
3112 return getTrailingASTTemplateKWAndArgsInfo()->TemplateKWLoc;
3113 }
3114
3115
3116
3117 SourceLocation getLAngleLoc() const {
3118 if (!hasTemplateKWAndArgsInfo())
3119 return SourceLocation();
3120 return getTrailingASTTemplateKWAndArgsInfo()->LAngleLoc;
3121 }
3122
3123
3124
3125 SourceLocation getRAngleLoc() const {
3126 if (!hasTemplateKWAndArgsInfo())
3127 return SourceLocation();
3128 return getTrailingASTTemplateKWAndArgsInfo()->RAngleLoc;
3129 }
3130
3131
3132 bool hasTemplateKeyword() const { return getTemplateKeywordLoc().isValid(); }
3133
3134
3135 bool hasExplicitTemplateArgs() const { return getLAngleLoc().isValid(); }
3136
3137 TemplateArgumentLoc const *getTemplateArgs() const {
3138 if (!hasExplicitTemplateArgs())
3139 return nullptr;
3140 return const_cast<OverloadExpr *>(this)->getTrailingTemplateArgumentLoc();
3141 }
3142
3143 unsigned getNumTemplateArgs() const {
3144 if (!hasExplicitTemplateArgs())
3145 return 0;
3146
3147 return getTrailingASTTemplateKWAndArgsInfo()->NumTemplateArgs;
3148 }
3149
3150 ArrayRef<TemplateArgumentLoc> template_arguments() const {
3151 return {getTemplateArgs(), getNumTemplateArgs()};
3152 }
3153
3154
3155 void copyTemplateArgumentsInto(TemplateArgumentListInfo &List) const {
3156 if (hasExplicitTemplateArgs())
3157 getTrailingASTTemplateKWAndArgsInfo()->copyInto(getTemplateArgs(), List);
3158 }
3159
3160 static bool classof(const Stmt *T) {
3161 return T->getStmtClass() == UnresolvedLookupExprClass ||
3162 T->getStmtClass() == UnresolvedMemberExprClass;
3163 }
3164 };
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199 class UnresolvedLookupExpr final
3200 : public OverloadExpr,
3201 private llvm::TrailingObjects<UnresolvedLookupExpr, DeclAccessPair,
3202 ASTTemplateKWAndArgsInfo,
3203 TemplateArgumentLoc> {
3204 friend class ASTStmtReader;
3205 friend class OverloadExpr;
3206 friend TrailingObjects;
3207
3208
3209
3210
3211 CXXRecordDecl *NamingClass;
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227 UnresolvedLookupExpr(const ASTContext &Context, CXXRecordDecl *NamingClass,
3228 NestedNameSpecifierLoc QualifierLoc,
3229 SourceLocation TemplateKWLoc,
3230 const DeclarationNameInfo &NameInfo, bool RequiresADL,
3231 const TemplateArgumentListInfo *TemplateArgs,
3232 UnresolvedSetIterator Begin, UnresolvedSetIterator End,
3233 bool KnownDependent, bool KnownInstantiationDependent);
3234
3235 UnresolvedLookupExpr(EmptyShell Empty, unsigned NumResults,
3236 bool HasTemplateKWAndArgsInfo);
3237
3238 unsigned numTrailingObjects(OverloadToken<DeclAccessPair>) const {
3239 return getNumDecls();
3240 }
3241
3242 unsigned numTrailingObjects(OverloadToken<ASTTemplateKWAndArgsInfo>) const {
3243 return hasTemplateKWAndArgsInfo();
3244 }
3245
3246 public:
3247 static UnresolvedLookupExpr *
3248 Create(const ASTContext &Context, CXXRecordDecl *NamingClass,
3249 NestedNameSpecifierLoc QualifierLoc,
3250 const DeclarationNameInfo &NameInfo, bool RequiresADL,
3251 UnresolvedSetIterator Begin, UnresolvedSetIterator End,
3252 bool KnownDependent, bool KnownInstantiationDependent);
3253
3254
3255
3256
3257 static UnresolvedLookupExpr *
3258 Create(const ASTContext &Context, CXXRecordDecl *NamingClass,
3259 NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc,
3260 const DeclarationNameInfo &NameInfo, bool RequiresADL,
3261 const TemplateArgumentListInfo *Args, UnresolvedSetIterator Begin,
3262 UnresolvedSetIterator End, bool KnownDependent,
3263 bool KnownInstantiationDependent);
3264
3265 static UnresolvedLookupExpr *CreateEmpty(const ASTContext &Context,
3266 unsigned NumResults,
3267 bool HasTemplateKWAndArgsInfo,
3268 unsigned NumTemplateArgs);
3269
3270
3271
3272 bool requiresADL() const { return UnresolvedLookupExprBits.RequiresADL; }
3273
3274
3275
3276
3277 CXXRecordDecl *getNamingClass() { return NamingClass; }
3278 const CXXRecordDecl *getNamingClass() const { return NamingClass; }
3279
3280 SourceLocation getBeginLoc() const LLVM_READONLY {
3281 if (NestedNameSpecifierLoc l = getQualifierLoc())
3282 return l.getBeginLoc();
3283 return getNameInfo().getBeginLoc();
3284 }
3285
3286 SourceLocation getEndLoc() const LLVM_READONLY {
3287 if (hasExplicitTemplateArgs())
3288 return getRAngleLoc();
3289 return getNameInfo().getEndLoc();
3290 }
3291
3292 child_range children() {
3293 return child_range(child_iterator(), child_iterator());
3294 }
3295
3296 const_child_range children() const {
3297 return const_child_range(const_child_iterator(), const_child_iterator());
3298 }
3299
3300 static bool classof(const Stmt *T) {
3301 return T->getStmtClass() == UnresolvedLookupExprClass;
3302 }
3303 };
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319 class DependentScopeDeclRefExpr final
3320 : public Expr,
3321 private llvm::TrailingObjects<DependentScopeDeclRefExpr,
3322 ASTTemplateKWAndArgsInfo,
3323 TemplateArgumentLoc> {
3324 friend class ASTStmtReader;
3325 friend class ASTStmtWriter;
3326 friend TrailingObjects;
3327
3328
3329
3330 NestedNameSpecifierLoc QualifierLoc;
3331
3332
3333 DeclarationNameInfo NameInfo;
3334
3335 DependentScopeDeclRefExpr(QualType Ty, NestedNameSpecifierLoc QualifierLoc,
3336 SourceLocation TemplateKWLoc,
3337 const DeclarationNameInfo &NameInfo,
3338 const TemplateArgumentListInfo *Args);
3339
3340 size_t numTrailingObjects(OverloadToken<ASTTemplateKWAndArgsInfo>) const {
3341 return hasTemplateKWAndArgsInfo();
3342 }
3343
3344 bool hasTemplateKWAndArgsInfo() const {
3345 return DependentScopeDeclRefExprBits.HasTemplateKWAndArgsInfo;
3346 }
3347
3348 public:
3349 static DependentScopeDeclRefExpr *
3350 Create(const ASTContext &Context, NestedNameSpecifierLoc QualifierLoc,
3351 SourceLocation TemplateKWLoc, const DeclarationNameInfo &NameInfo,
3352 const TemplateArgumentListInfo *TemplateArgs);
3353
3354 static DependentScopeDeclRefExpr *CreateEmpty(const ASTContext &Context,
3355 bool HasTemplateKWAndArgsInfo,
3356 unsigned NumTemplateArgs);
3357
3358
3359 const DeclarationNameInfo &getNameInfo() const { return NameInfo; }
3360
3361
3362 DeclarationName getDeclName() const { return NameInfo.getName(); }
3363
3364
3365
3366
3367 SourceLocation getLocation() const { return NameInfo.getLoc(); }
3368
3369
3370
3371 NestedNameSpecifierLoc getQualifierLoc() const { return QualifierLoc; }
3372
3373
3374
3375 NestedNameSpecifier *getQualifier() const {
3376 return QualifierLoc.getNestedNameSpecifier();
3377 }
3378
3379
3380
3381 SourceLocation getTemplateKeywordLoc() const {
3382 if (!hasTemplateKWAndArgsInfo())
3383 return SourceLocation();
3384 return getTrailingObjects<ASTTemplateKWAndArgsInfo>()->TemplateKWLoc;
3385 }
3386
3387
3388
3389 SourceLocation getLAngleLoc() const {
3390 if (!hasTemplateKWAndArgsInfo())
3391 return SourceLocation();
3392 return getTrailingObjects<ASTTemplateKWAndArgsInfo>()->LAngleLoc;
3393 }
3394
3395
3396
3397 SourceLocation getRAngleLoc() const {
3398 if (!hasTemplateKWAndArgsInfo())
3399 return SourceLocation();
3400 return getTrailingObjects<ASTTemplateKWAndArgsInfo>()->RAngleLoc;
3401 }
3402
3403
3404 bool hasTemplateKeyword() const { return getTemplateKeywordLoc().isValid(); }
3405
3406
3407 bool hasExplicitTemplateArgs() const { return getLAngleLoc().isValid(); }
3408
3409
3410
3411 void copyTemplateArgumentsInto(TemplateArgumentListInfo &List) const {
3412 if (hasExplicitTemplateArgs())
3413 getTrailingObjects<ASTTemplateKWAndArgsInfo>()->copyInto(
3414 getTrailingObjects<TemplateArgumentLoc>(), List);
3415 }
3416
3417 TemplateArgumentLoc const *getTemplateArgs() const {
3418 if (!hasExplicitTemplateArgs())
3419 return nullptr;
3420
3421 return getTrailingObjects<TemplateArgumentLoc>();
3422 }
3423
3424 unsigned getNumTemplateArgs() const {
3425 if (!hasExplicitTemplateArgs())
3426 return 0;
3427
3428 return getTrailingObjects<ASTTemplateKWAndArgsInfo>()->NumTemplateArgs;
3429 }
3430
3431 ArrayRef<TemplateArgumentLoc> template_arguments() const {
3432 return {getTemplateArgs(), getNumTemplateArgs()};
3433 }
3434
3435
3436
3437 SourceLocation getBeginLoc() const LLVM_READONLY {
3438 return QualifierLoc.getBeginLoc();
3439 }
3440
3441 SourceLocation getEndLoc() const LLVM_READONLY {
3442 if (hasExplicitTemplateArgs())
3443 return getRAngleLoc();
3444 return getLocation();
3445 }
3446
3447 static bool classof(const Stmt *T) {
3448 return T->getStmtClass() == DependentScopeDeclRefExprClass;
3449 }
3450
3451 child_range children() {
3452 return child_range(child_iterator(), child_iterator());
3453 }
3454
3455 const_child_range children() const {
3456 return const_child_range(const_child_iterator(), const_child_iterator());
3457 }
3458 };
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470 class ExprWithCleanups final
3471 : public FullExpr,
3472 private llvm::TrailingObjects<
3473 ExprWithCleanups,
3474 llvm::PointerUnion<BlockDecl *, CompoundLiteralExpr *>> {
3475 public:
3476
3477
3478
3479
3480 using CleanupObject = llvm::PointerUnion<BlockDecl *, CompoundLiteralExpr *>;
3481
3482 private:
3483 friend class ASTStmtReader;
3484 friend TrailingObjects;
3485
3486 ExprWithCleanups(EmptyShell, unsigned NumObjects);
3487 ExprWithCleanups(Expr *SubExpr, bool CleanupsHaveSideEffects,
3488 ArrayRef<CleanupObject> Objects);
3489
3490 public:
3491 static ExprWithCleanups *Create(const ASTContext &C, EmptyShell empty,
3492 unsigned numObjects);
3493
3494 static ExprWithCleanups *Create(const ASTContext &C, Expr *subexpr,
3495 bool CleanupsHaveSideEffects,
3496 ArrayRef<CleanupObject> objects);
3497
3498 ArrayRef<CleanupObject> getObjects() const {
3499 return llvm::ArrayRef(getTrailingObjects<CleanupObject>(), getNumObjects());
3500 }
3501
3502 unsigned getNumObjects() const { return ExprWithCleanupsBits.NumObjects; }
3503
3504 CleanupObject getObject(unsigned i) const {
3505 assert(i < getNumObjects() && "Index out of range");
3506 return getObjects()[i];
3507 }
3508
3509 bool cleanupsHaveSideEffects() const {
3510 return ExprWithCleanupsBits.CleanupsHaveSideEffects;
3511 }
3512
3513 SourceLocation getBeginLoc() const LLVM_READONLY {
3514 return SubExpr->getBeginLoc();
3515 }
3516
3517 SourceLocation getEndLoc() const LLVM_READONLY {
3518 return SubExpr->getEndLoc();
3519 }
3520
3521
3522 static bool classof(const Stmt *T) {
3523 return T->getStmtClass() == ExprWithCleanupsClass;
3524 }
3525
3526
3527 child_range children() { return child_range(&SubExpr, &SubExpr + 1); }
3528
3529 const_child_range children() const {
3530 return const_child_range(&SubExpr, &SubExpr + 1);
3531 }
3532 };
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555 class CXXUnresolvedConstructExpr final
3556 : public Expr,
3557 private llvm::TrailingObjects<CXXUnresolvedConstructExpr, Expr *> {
3558 friend class ASTStmtReader;
3559 friend TrailingObjects;
3560
3561
3562
3563 llvm::PointerIntPair<TypeSourceInfo *, 1> TypeAndInitForm;
3564
3565
3566 SourceLocation LParenLoc;
3567
3568
3569 SourceLocation RParenLoc;
3570
3571 CXXUnresolvedConstructExpr(QualType T, TypeSourceInfo *TSI,
3572 SourceLocation LParenLoc, ArrayRef<Expr *> Args,
3573 SourceLocation RParenLoc, bool IsListInit);
3574
3575 CXXUnresolvedConstructExpr(EmptyShell Empty, unsigned NumArgs)
3576 : Expr(CXXUnresolvedConstructExprClass, Empty) {
3577 CXXUnresolvedConstructExprBits.NumArgs = NumArgs;
3578 }
3579
3580 public:
3581 static CXXUnresolvedConstructExpr *
3582 Create(const ASTContext &Context, QualType T, TypeSourceInfo *TSI,
3583 SourceLocation LParenLoc, ArrayRef<Expr *> Args,
3584 SourceLocation RParenLoc, bool IsListInit);
3585
3586 static CXXUnresolvedConstructExpr *CreateEmpty(const ASTContext &Context,
3587 unsigned NumArgs);
3588
3589
3590
3591 QualType getTypeAsWritten() const { return getTypeSourceInfo()->getType(); }
3592
3593
3594
3595 TypeSourceInfo *getTypeSourceInfo() const {
3596 return TypeAndInitForm.getPointer();
3597 }
3598
3599
3600
3601 SourceLocation getLParenLoc() const { return LParenLoc; }
3602 void setLParenLoc(SourceLocation L) { LParenLoc = L; }
3603
3604
3605
3606 SourceLocation getRParenLoc() const { return RParenLoc; }
3607 void setRParenLoc(SourceLocation L) { RParenLoc = L; }
3608
3609
3610
3611
3612 bool isListInitialization() const { return TypeAndInitForm.getInt(); }
3613
3614
3615 unsigned getNumArgs() const { return CXXUnresolvedConstructExprBits.NumArgs; }
3616
3617 using arg_iterator = Expr **;
3618 using arg_range = llvm::iterator_range<arg_iterator>;
3619
3620 arg_iterator arg_begin() { return getTrailingObjects<Expr *>(); }
3621 arg_iterator arg_end() { return arg_begin() + getNumArgs(); }
3622 arg_range arguments() { return arg_range(arg_begin(), arg_end()); }
3623
3624 using const_arg_iterator = const Expr* const *;
3625 using const_arg_range = llvm::iterator_range<const_arg_iterator>;
3626
3627 const_arg_iterator arg_begin() const { return getTrailingObjects<Expr *>(); }
3628 const_arg_iterator arg_end() const { return arg_begin() + getNumArgs(); }
3629 const_arg_range arguments() const {
3630 return const_arg_range(arg_begin(), arg_end());
3631 }
3632
3633 Expr *getArg(unsigned I) {
3634 assert(I < getNumArgs() && "Argument index out-of-range");
3635 return arg_begin()[I];
3636 }
3637
3638 const Expr *getArg(unsigned I) const {
3639 assert(I < getNumArgs() && "Argument index out-of-range");
3640 return arg_begin()[I];
3641 }
3642
3643 void setArg(unsigned I, Expr *E) {
3644 assert(I < getNumArgs() && "Argument index out-of-range");
3645 arg_begin()[I] = E;
3646 }
3647
3648 SourceLocation getBeginLoc() const LLVM_READONLY;
3649 SourceLocation getEndLoc() const LLVM_READONLY {
3650 if (!RParenLoc.isValid() && getNumArgs() > 0)
3651 return getArg(getNumArgs() - 1)->getEndLoc();
3652 return RParenLoc;
3653 }
3654
3655 static bool classof(const Stmt *T) {
3656 return T->getStmtClass() == CXXUnresolvedConstructExprClass;
3657 }
3658
3659
3660 child_range children() {
3661 auto **begin = reinterpret_cast<Stmt **>(arg_begin());
3662 return child_range(begin, begin + getNumArgs());
3663 }
3664
3665 const_child_range children() const {
3666 auto **begin = reinterpret_cast<Stmt **>(
3667 const_cast<CXXUnresolvedConstructExpr *>(this)->arg_begin());
3668 return const_child_range(begin, begin + getNumArgs());
3669 }
3670 };
3671
3672
3673
3674
3675
3676
3677
3678
3679 class CXXDependentScopeMemberExpr final
3680 : public Expr,
3681 private llvm::TrailingObjects<CXXDependentScopeMemberExpr,
3682 ASTTemplateKWAndArgsInfo,
3683 TemplateArgumentLoc, NamedDecl *> {
3684 friend class ASTStmtReader;
3685 friend class ASTStmtWriter;
3686 friend TrailingObjects;
3687
3688
3689
3690 Stmt *Base;
3691
3692
3693
3694 QualType BaseType;
3695
3696
3697
3698
3699 NestedNameSpecifierLoc QualifierLoc;
3700
3701
3702
3703
3704
3705 DeclarationNameInfo MemberNameInfo;
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722 bool hasTemplateKWAndArgsInfo() const {
3723 return CXXDependentScopeMemberExprBits.HasTemplateKWAndArgsInfo;
3724 }
3725
3726 bool hasFirstQualifierFoundInScope() const {
3727 return CXXDependentScopeMemberExprBits.HasFirstQualifierFoundInScope;
3728 }
3729
3730 unsigned numTrailingObjects(OverloadToken<ASTTemplateKWAndArgsInfo>) const {
3731 return hasTemplateKWAndArgsInfo();
3732 }
3733
3734 unsigned numTrailingObjects(OverloadToken<TemplateArgumentLoc>) const {
3735 return getNumTemplateArgs();
3736 }
3737
3738 unsigned numTrailingObjects(OverloadToken<NamedDecl *>) const {
3739 return hasFirstQualifierFoundInScope();
3740 }
3741
3742 CXXDependentScopeMemberExpr(const ASTContext &Ctx, Expr *Base,
3743 QualType BaseType, bool IsArrow,
3744 SourceLocation OperatorLoc,
3745 NestedNameSpecifierLoc QualifierLoc,
3746 SourceLocation TemplateKWLoc,
3747 NamedDecl *FirstQualifierFoundInScope,
3748 DeclarationNameInfo MemberNameInfo,
3749 const TemplateArgumentListInfo *TemplateArgs);
3750
3751 CXXDependentScopeMemberExpr(EmptyShell Empty, bool HasTemplateKWAndArgsInfo,
3752 bool HasFirstQualifierFoundInScope);
3753
3754 public:
3755 static CXXDependentScopeMemberExpr *
3756 Create(const ASTContext &Ctx, Expr *Base, QualType BaseType, bool IsArrow,
3757 SourceLocation OperatorLoc, NestedNameSpecifierLoc QualifierLoc,
3758 SourceLocation TemplateKWLoc, NamedDecl *FirstQualifierFoundInScope,
3759 DeclarationNameInfo MemberNameInfo,
3760 const TemplateArgumentListInfo *TemplateArgs);
3761
3762 static CXXDependentScopeMemberExpr *
3763 CreateEmpty(const ASTContext &Ctx, bool HasTemplateKWAndArgsInfo,
3764 unsigned NumTemplateArgs, bool HasFirstQualifierFoundInScope);
3765
3766
3767
3768
3769 bool isImplicitAccess() const {
3770 if (!Base)
3771 return true;
3772 return cast<Expr>(Base)->isImplicitCXXThis();
3773 }
3774
3775
3776
3777 Expr *getBase() const {
3778 assert(!isImplicitAccess());
3779 return cast<Expr>(Base);
3780 }
3781
3782 QualType getBaseType() const { return BaseType; }
3783
3784
3785
3786 bool isArrow() const { return CXXDependentScopeMemberExprBits.IsArrow; }
3787
3788
3789 SourceLocation getOperatorLoc() const {
3790 return CXXDependentScopeMemberExprBits.OperatorLoc;
3791 }
3792
3793
3794 NestedNameSpecifier *getQualifier() const {
3795 return QualifierLoc.getNestedNameSpecifier();
3796 }
3797
3798
3799
3800 NestedNameSpecifierLoc getQualifierLoc() const { return QualifierLoc; }
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813 NamedDecl *getFirstQualifierFoundInScope() const {
3814 if (!hasFirstQualifierFoundInScope())
3815 return nullptr;
3816 return *getTrailingObjects<NamedDecl *>();
3817 }
3818
3819
3820 const DeclarationNameInfo &getMemberNameInfo() const {
3821 return MemberNameInfo;
3822 }
3823
3824
3825 DeclarationName getMember() const { return MemberNameInfo.getName(); }
3826
3827
3828
3829 SourceLocation getMemberLoc() const { return MemberNameInfo.getLoc(); }
3830
3831
3832
3833 SourceLocation getTemplateKeywordLoc() const {
3834 if (!hasTemplateKWAndArgsInfo())
3835 return SourceLocation();
3836 return getTrailingObjects<ASTTemplateKWAndArgsInfo>()->TemplateKWLoc;
3837 }
3838
3839
3840
3841 SourceLocation getLAngleLoc() const {
3842 if (!hasTemplateKWAndArgsInfo())
3843 return SourceLocation();
3844 return getTrailingObjects<ASTTemplateKWAndArgsInfo>()->LAngleLoc;
3845 }
3846
3847
3848
3849 SourceLocation getRAngleLoc() const {
3850 if (!hasTemplateKWAndArgsInfo())
3851 return SourceLocation();
3852 return getTrailingObjects<ASTTemplateKWAndArgsInfo>()->RAngleLoc;
3853 }
3854
3855
3856 bool hasTemplateKeyword() const { return getTemplateKeywordLoc().isValid(); }
3857
3858
3859
3860 bool hasExplicitTemplateArgs() const { return getLAngleLoc().isValid(); }
3861
3862
3863
3864 void copyTemplateArgumentsInto(TemplateArgumentListInfo &List) const {
3865 if (hasExplicitTemplateArgs())
3866 getTrailingObjects<ASTTemplateKWAndArgsInfo>()->copyInto(
3867 getTrailingObjects<TemplateArgumentLoc>(), List);
3868 }
3869
3870
3871
3872 const TemplateArgumentLoc *getTemplateArgs() const {
3873 if (!hasExplicitTemplateArgs())
3874 return nullptr;
3875
3876 return getTrailingObjects<TemplateArgumentLoc>();
3877 }
3878
3879
3880
3881 unsigned getNumTemplateArgs() const {
3882 if (!hasExplicitTemplateArgs())
3883 return 0;
3884
3885 return getTrailingObjects<ASTTemplateKWAndArgsInfo>()->NumTemplateArgs;
3886 }
3887
3888 ArrayRef<TemplateArgumentLoc> template_arguments() const {
3889 return {getTemplateArgs(), getNumTemplateArgs()};
3890 }
3891
3892 SourceLocation getBeginLoc() const LLVM_READONLY {
3893 if (!isImplicitAccess())
3894 return Base->getBeginLoc();
3895 if (getQualifier())
3896 return getQualifierLoc().getBeginLoc();
3897 return MemberNameInfo.getBeginLoc();
3898 }
3899
3900 SourceLocation getEndLoc() const LLVM_READONLY {
3901 if (hasExplicitTemplateArgs())
3902 return getRAngleLoc();
3903 return MemberNameInfo.getEndLoc();
3904 }
3905
3906 static bool classof(const Stmt *T) {
3907 return T->getStmtClass() == CXXDependentScopeMemberExprClass;
3908 }
3909
3910
3911 child_range children() {
3912 if (isImplicitAccess())
3913 return child_range(child_iterator(), child_iterator());
3914 return child_range(&Base, &Base + 1);
3915 }
3916
3917 const_child_range children() const {
3918 if (isImplicitAccess())
3919 return const_child_range(const_child_iterator(), const_child_iterator());
3920 return const_child_range(&Base, &Base + 1);
3921 }
3922 };
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939 class UnresolvedMemberExpr final
3940 : public OverloadExpr,
3941 private llvm::TrailingObjects<UnresolvedMemberExpr, DeclAccessPair,
3942 ASTTemplateKWAndArgsInfo,
3943 TemplateArgumentLoc> {
3944 friend class ASTStmtReader;
3945 friend class OverloadExpr;
3946 friend TrailingObjects;
3947
3948
3949
3950
3951
3952 Stmt *Base;
3953
3954
3955 QualType BaseType;
3956
3957
3958 SourceLocation OperatorLoc;
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974 UnresolvedMemberExpr(const ASTContext &Context, bool HasUnresolvedUsing,
3975 Expr *Base, QualType BaseType, bool IsArrow,
3976 SourceLocation OperatorLoc,
3977 NestedNameSpecifierLoc QualifierLoc,
3978 SourceLocation TemplateKWLoc,
3979 const DeclarationNameInfo &MemberNameInfo,
3980 const TemplateArgumentListInfo *TemplateArgs,
3981 UnresolvedSetIterator Begin, UnresolvedSetIterator End);
3982
3983 UnresolvedMemberExpr(EmptyShell Empty, unsigned NumResults,
3984 bool HasTemplateKWAndArgsInfo);
3985
3986 unsigned numTrailingObjects(OverloadToken<DeclAccessPair>) const {
3987 return getNumDecls();
3988 }
3989
3990 unsigned numTrailingObjects(OverloadToken<ASTTemplateKWAndArgsInfo>) const {
3991 return hasTemplateKWAndArgsInfo();
3992 }
3993
3994 public:
3995 static UnresolvedMemberExpr *
3996 Create(const ASTContext &Context, bool HasUnresolvedUsing, Expr *Base,
3997 QualType BaseType, bool IsArrow, SourceLocation OperatorLoc,
3998 NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc,
3999 const DeclarationNameInfo &MemberNameInfo,
4000 const TemplateArgumentListInfo *TemplateArgs,
4001 UnresolvedSetIterator Begin, UnresolvedSetIterator End);
4002
4003 static UnresolvedMemberExpr *CreateEmpty(const ASTContext &Context,
4004 unsigned NumResults,
4005 bool HasTemplateKWAndArgsInfo,
4006 unsigned NumTemplateArgs);
4007
4008
4009
4010
4011
4012 bool isImplicitAccess() const;
4013
4014
4015
4016 Expr *getBase() {
4017 assert(!isImplicitAccess());
4018 return cast<Expr>(Base);
4019 }
4020 const Expr *getBase() const {
4021 assert(!isImplicitAccess());
4022 return cast<Expr>(Base);
4023 }
4024
4025 QualType getBaseType() const { return BaseType; }
4026
4027
4028
4029 bool hasUnresolvedUsing() const {
4030 return UnresolvedMemberExprBits.HasUnresolvedUsing;
4031 }
4032
4033
4034
4035 bool isArrow() const { return UnresolvedMemberExprBits.IsArrow; }
4036
4037
4038 SourceLocation getOperatorLoc() const { return OperatorLoc; }
4039
4040
4041 CXXRecordDecl *getNamingClass();
4042 const CXXRecordDecl *getNamingClass() const {
4043 return const_cast<UnresolvedMemberExpr *>(this)->getNamingClass();
4044 }
4045
4046
4047
4048 const DeclarationNameInfo &getMemberNameInfo() const { return getNameInfo(); }
4049
4050
4051 DeclarationName getMemberName() const { return getName(); }
4052
4053
4054
4055 SourceLocation getMemberLoc() const { return getNameLoc(); }
4056
4057
4058
4059 SourceLocation getExprLoc() const LLVM_READONLY { return getMemberLoc(); }
4060
4061 SourceLocation getBeginLoc() const LLVM_READONLY {
4062 if (!isImplicitAccess())
4063 return Base->getBeginLoc();
4064 if (NestedNameSpecifierLoc l = getQualifierLoc())
4065 return l.getBeginLoc();
4066 return getMemberNameInfo().getBeginLoc();
4067 }
4068
4069 SourceLocation getEndLoc() const LLVM_READONLY {
4070 if (hasExplicitTemplateArgs())
4071 return getRAngleLoc();
4072 return getMemberNameInfo().getEndLoc();
4073 }
4074
4075 static bool classof(const Stmt *T) {
4076 return T->getStmtClass() == UnresolvedMemberExprClass;
4077 }
4078
4079
4080 child_range children() {
4081 if (isImplicitAccess())
4082 return child_range(child_iterator(), child_iterator());
4083 return child_range(&Base, &Base + 1);
4084 }
4085
4086 const_child_range children() const {
4087 if (isImplicitAccess())
4088 return const_child_range(const_child_iterator(), const_child_iterator());
4089 return const_child_range(&Base, &Base + 1);
4090 }
4091 };
4092
4093 DeclAccessPair *OverloadExpr::getTrailingResults() {
4094 if (auto *ULE = dyn_cast<UnresolvedLookupExpr>(this))
4095 return ULE->getTrailingObjects<DeclAccessPair>();
4096 return cast<UnresolvedMemberExpr>(this)->getTrailingObjects<DeclAccessPair>();
4097 }
4098
4099 ASTTemplateKWAndArgsInfo *OverloadExpr::getTrailingASTTemplateKWAndArgsInfo() {
4100 if (!hasTemplateKWAndArgsInfo())
4101 return nullptr;
4102
4103 if (auto *ULE = dyn_cast<UnresolvedLookupExpr>(this))
4104 return ULE->getTrailingObjects<ASTTemplateKWAndArgsInfo>();
4105 return cast<UnresolvedMemberExpr>(this)
4106 ->getTrailingObjects<ASTTemplateKWAndArgsInfo>();
4107 }
4108
4109 TemplateArgumentLoc *OverloadExpr::getTrailingTemplateArgumentLoc() {
4110 if (auto *ULE = dyn_cast<UnresolvedLookupExpr>(this))
4111 return ULE->getTrailingObjects<TemplateArgumentLoc>();
4112 return cast<UnresolvedMemberExpr>(this)
4113 ->getTrailingObjects<TemplateArgumentLoc>();
4114 }
4115
4116 CXXRecordDecl *OverloadExpr::getNamingClass() {
4117 if (auto *ULE = dyn_cast<UnresolvedLookupExpr>(this))
4118 return ULE->getNamingClass();
4119 return cast<UnresolvedMemberExpr>(this)->getNamingClass();
4120 }
4121
4122
4123
4124
4125
4126 class CXXNoexceptExpr : public Expr {
4127 friend class ASTStmtReader;
4128
4129 Stmt *Operand;
4130 SourceRange Range;
4131
4132 public:
4133 CXXNoexceptExpr(QualType Ty, Expr *Operand, CanThrowResult Val,
4134 SourceLocation Keyword, SourceLocation RParen)
4135 : Expr(CXXNoexceptExprClass, Ty, VK_PRValue, OK_Ordinary),
4136 Operand(Operand), Range(Keyword, RParen) {
4137 CXXNoexceptExprBits.Value = Val == CT_Cannot;
4138 setDependence(computeDependence(this, Val));
4139 }
4140
4141 CXXNoexceptExpr(EmptyShell Empty) : Expr(CXXNoexceptExprClass, Empty) {}
4142
4143 Expr *getOperand() const { return static_cast<Expr *>(Operand); }
4144
4145 SourceLocation getBeginLoc() const { return Range.getBegin(); }
4146 SourceLocation getEndLoc() const { return Range.getEnd(); }
4147 SourceRange getSourceRange() const { return Range; }
4148
4149 bool getValue() const { return CXXNoexceptExprBits.Value; }
4150
4151 static bool classof(const Stmt *T) {
4152 return T->getStmtClass() == CXXNoexceptExprClass;
4153 }
4154
4155
4156 child_range children() { return child_range(&Operand, &Operand + 1); }
4157
4158 const_child_range children() const {
4159 return const_child_range(&Operand, &Operand + 1);
4160 }
4161 };
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180 class PackExpansionExpr : public Expr {
4181 friend class ASTStmtReader;
4182 friend class ASTStmtWriter;
4183
4184 SourceLocation EllipsisLoc;
4185
4186
4187
4188
4189
4190
4191 unsigned NumExpansions;
4192
4193 Stmt *Pattern;
4194
4195 public:
4196 PackExpansionExpr(QualType T, Expr *Pattern, SourceLocation EllipsisLoc,
4197 std::optional<unsigned> NumExpansions)
4198 : Expr(PackExpansionExprClass, T, Pattern->getValueKind(),
4199 Pattern->getObjectKind()),
4200 EllipsisLoc(EllipsisLoc),
4201 NumExpansions(NumExpansions ? *NumExpansions + 1 : 0),
4202 Pattern(Pattern) {
4203 setDependence(computeDependence(this));
4204 }
4205
4206 PackExpansionExpr(EmptyShell Empty) : Expr(PackExpansionExprClass, Empty) {}
4207
4208
4209 Expr *getPattern() { return reinterpret_cast<Expr *>(Pattern); }
4210
4211
4212 const Expr *getPattern() const { return reinterpret_cast<Expr *>(Pattern); }
4213
4214
4215
4216 SourceLocation getEllipsisLoc() const { return EllipsisLoc; }
4217
4218
4219
4220 std::optional<unsigned> getNumExpansions() const {
4221 if (NumExpansions)
4222 return NumExpansions - 1;
4223
4224 return std::nullopt;
4225 }
4226
4227 SourceLocation getBeginLoc() const LLVM_READONLY {
4228 return Pattern->getBeginLoc();
4229 }
4230
4231 SourceLocation getEndLoc() const LLVM_READONLY { return EllipsisLoc; }
4232
4233 static bool classof(const Stmt *T) {
4234 return T->getStmtClass() == PackExpansionExprClass;
4235 }
4236
4237
4238 child_range children() {
4239 return child_range(&Pattern, &Pattern + 1);
4240 }
4241
4242 const_child_range children() const {
4243 return const_child_range(&Pattern, &Pattern + 1);
4244 }
4245 };
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256 class SizeOfPackExpr final
4257 : public Expr,
4258 private llvm::TrailingObjects<SizeOfPackExpr, TemplateArgument> {
4259 friend class ASTStmtReader;
4260 friend class ASTStmtWriter;
4261 friend TrailingObjects;
4262
4263
4264 SourceLocation OperatorLoc;
4265
4266
4267 SourceLocation PackLoc;
4268
4269
4270 SourceLocation RParenLoc;
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282 unsigned Length;
4283
4284
4285 NamedDecl *Pack = nullptr;
4286
4287
4288
4289 SizeOfPackExpr(QualType SizeType, SourceLocation OperatorLoc, NamedDecl *Pack,
4290 SourceLocation PackLoc, SourceLocation RParenLoc,
4291 std::optional<unsigned> Length,
4292 ArrayRef<TemplateArgument> PartialArgs)
4293 : Expr(SizeOfPackExprClass, SizeType, VK_PRValue, OK_Ordinary),
4294 OperatorLoc(OperatorLoc), PackLoc(PackLoc), RParenLoc(RParenLoc),
4295 Length(Length ? *Length : PartialArgs.size()), Pack(Pack) {
4296 assert((!Length || PartialArgs.empty()) &&
4297 "have partial args for non-dependent sizeof... expression");
4298 auto *Args = getTrailingObjects<TemplateArgument>();
4299 std::uninitialized_copy(PartialArgs.begin(), PartialArgs.end(), Args);
4300 setDependence(Length ? ExprDependence::None
4301 : ExprDependence::ValueInstantiation);
4302 }
4303
4304
4305 SizeOfPackExpr(EmptyShell Empty, unsigned NumPartialArgs)
4306 : Expr(SizeOfPackExprClass, Empty), Length(NumPartialArgs) {}
4307
4308 public:
4309 static SizeOfPackExpr *Create(ASTContext &Context, SourceLocation OperatorLoc,
4310 NamedDecl *Pack, SourceLocation PackLoc,
4311 SourceLocation RParenLoc,
4312 std::optional<unsigned> Length = std::nullopt,
4313 ArrayRef<TemplateArgument> PartialArgs = {});
4314 static SizeOfPackExpr *CreateDeserialized(ASTContext &Context,
4315 unsigned NumPartialArgs);
4316
4317
4318 SourceLocation getOperatorLoc() const { return OperatorLoc; }
4319
4320
4321 SourceLocation getPackLoc() const { return PackLoc; }
4322
4323
4324 SourceLocation getRParenLoc() const { return RParenLoc; }
4325
4326
4327 NamedDecl *getPack() const { return Pack; }
4328
4329
4330
4331
4332
4333 unsigned getPackLength() const {
4334 assert(!isValueDependent() &&
4335 "Cannot get the length of a value-dependent pack size expression");
4336 return Length;
4337 }
4338
4339
4340
4341
4342
4343
4344 bool isPartiallySubstituted() const {
4345 return isValueDependent() && Length;
4346 }
4347
4348
4349 ArrayRef<TemplateArgument> getPartialArguments() const {
4350 assert(isPartiallySubstituted());
4351 const auto *Args = getTrailingObjects<TemplateArgument>();
4352 return llvm::ArrayRef(Args, Args + Length);
4353 }
4354
4355 SourceLocation getBeginLoc() const LLVM_READONLY { return OperatorLoc; }
4356 SourceLocation getEndLoc() const LLVM_READONLY { return RParenLoc; }
4357
4358 static bool classof(const Stmt *T) {
4359 return T->getStmtClass() == SizeOfPackExprClass;
4360 }
4361
4362
4363 child_range children() {
4364 return child_range(child_iterator(), child_iterator());
4365 }
4366
4367 const_child_range children() const {
4368 return const_child_range(const_child_iterator(), const_child_iterator());
4369 }
4370 };
4371
4372 class PackIndexingExpr final
4373 : public Expr,
4374 private llvm::TrailingObjects<PackIndexingExpr, Expr *> {
4375 friend class ASTStmtReader;
4376 friend class ASTStmtWriter;
4377 friend TrailingObjects;
4378
4379 SourceLocation EllipsisLoc;
4380
4381
4382 SourceLocation RSquareLoc;
4383
4384
4385 Stmt *SubExprs[2];
4386
4387
4388 unsigned TransformedExpressions : 31;
4389
4390 LLVM_PREFERRED_TYPE(bool)
4391 unsigned FullySubstituted : 1;
4392
4393 PackIndexingExpr(QualType Type, SourceLocation EllipsisLoc,
4394 SourceLocation RSquareLoc, Expr *PackIdExpr, Expr *IndexExpr,
4395 ArrayRef<Expr *> SubstitutedExprs = {},
4396 bool FullySubstituted = false)
4397 : Expr(PackIndexingExprClass, Type, VK_LValue, OK_Ordinary),
4398 EllipsisLoc(EllipsisLoc), RSquareLoc(RSquareLoc),
4399 SubExprs{PackIdExpr, IndexExpr},
4400 TransformedExpressions(SubstitutedExprs.size()),
4401 FullySubstituted(FullySubstituted) {
4402
4403 auto *Exprs = getTrailingObjects<Expr *>();
4404 std::uninitialized_copy(SubstitutedExprs.begin(), SubstitutedExprs.end(),
4405 Exprs);
4406
4407 setDependence(computeDependence(this));
4408 if (!isInstantiationDependent())
4409 setValueKind(getSelectedExpr()->getValueKind());
4410 }
4411
4412
4413 PackIndexingExpr(EmptyShell Empty) : Expr(PackIndexingExprClass, Empty) {}
4414
4415 unsigned numTrailingObjects(OverloadToken<Expr *>) const {
4416 return TransformedExpressions;
4417 }
4418
4419 public:
4420 static PackIndexingExpr *Create(ASTContext &Context,
4421 SourceLocation EllipsisLoc,
4422 SourceLocation RSquareLoc, Expr *PackIdExpr,
4423 Expr *IndexExpr, std::optional<int64_t> Index,
4424 ArrayRef<Expr *> SubstitutedExprs = {},
4425 bool FullySubstituted = false);
4426 static PackIndexingExpr *CreateDeserialized(ASTContext &Context,
4427 unsigned NumTransformedExprs);
4428
4429 bool isFullySubstituted() const { return FullySubstituted; }
4430
4431
4432 bool expandsToEmptyPack() const {
4433 return isFullySubstituted() && TransformedExpressions == 0;
4434 }
4435
4436
4437 SourceLocation getEllipsisLoc() const { return EllipsisLoc; }
4438
4439
4440 SourceLocation getPackLoc() const { return SubExprs[0]->getBeginLoc(); }
4441
4442
4443 SourceLocation getRSquareLoc() const { return RSquareLoc; }
4444
4445 SourceLocation getBeginLoc() const LLVM_READONLY { return getPackLoc(); }
4446 SourceLocation getEndLoc() const LLVM_READONLY { return RSquareLoc; }
4447
4448 Expr *getPackIdExpression() const { return cast<Expr>(SubExprs[0]); }
4449
4450 NamedDecl *getPackDecl() const;
4451
4452 Expr *getIndexExpr() const { return cast<Expr>(SubExprs[1]); }
4453
4454 std::optional<unsigned> getSelectedIndex() const {
4455 if (isInstantiationDependent())
4456 return std::nullopt;
4457 ConstantExpr *CE = cast<ConstantExpr>(getIndexExpr());
4458 auto Index = CE->getResultAsAPSInt();
4459 assert(Index.isNonNegative() && "Invalid index");
4460 return static_cast<unsigned>(Index.getExtValue());
4461 }
4462
4463 Expr *getSelectedExpr() const {
4464 std::optional<unsigned> Index = getSelectedIndex();
4465 assert(Index && "extracting the indexed expression of a dependant pack");
4466 return getTrailingObjects<Expr *>()[*Index];
4467 }
4468
4469
4470 ArrayRef<Expr *> getExpressions() const {
4471 return {getTrailingObjects<Expr *>(), TransformedExpressions};
4472 }
4473
4474 static bool classof(const Stmt *T) {
4475 return T->getStmtClass() == PackIndexingExprClass;
4476 }
4477
4478
4479 child_range children() { return child_range(SubExprs, SubExprs + 2); }
4480
4481 const_child_range children() const {
4482 return const_child_range(SubExprs, SubExprs + 2);
4483 }
4484 };
4485
4486
4487
4488 class SubstNonTypeTemplateParmExpr : public Expr {
4489 friend class ASTReader;
4490 friend class ASTStmtReader;
4491
4492
4493 Stmt *Replacement;
4494
4495
4496
4497
4498 llvm::PointerIntPair<Decl *, 1, bool> AssociatedDeclAndRef;
4499
4500 unsigned Index : 15;
4501 unsigned PackIndex : 16;
4502
4503 explicit SubstNonTypeTemplateParmExpr(EmptyShell Empty)
4504 : Expr(SubstNonTypeTemplateParmExprClass, Empty) {}
4505
4506 public:
4507 SubstNonTypeTemplateParmExpr(QualType Ty, ExprValueKind ValueKind,
4508 SourceLocation Loc, Expr *Replacement,
4509 Decl *AssociatedDecl, unsigned Index,
4510 std::optional<unsigned> PackIndex, bool RefParam)
4511 : Expr(SubstNonTypeTemplateParmExprClass, Ty, ValueKind, OK_Ordinary),
4512 Replacement(Replacement),
4513 AssociatedDeclAndRef(AssociatedDecl, RefParam), Index(Index),
4514 PackIndex(PackIndex ? *PackIndex + 1 : 0) {
4515 assert(AssociatedDecl != nullptr);
4516 SubstNonTypeTemplateParmExprBits.NameLoc = Loc;
4517 setDependence(computeDependence(this));
4518 }
4519
4520 SourceLocation getNameLoc() const {
4521 return SubstNonTypeTemplateParmExprBits.NameLoc;
4522 }
4523 SourceLocation getBeginLoc() const { return getNameLoc(); }
4524 SourceLocation getEndLoc() const { return getNameLoc(); }
4525
4526 Expr *getReplacement() const { return cast<Expr>(Replacement); }
4527
4528
4529
4530 Decl *getAssociatedDecl() const { return AssociatedDeclAndRef.getPointer(); }
4531
4532
4533
4534 unsigned getIndex() const { return Index; }
4535
4536 std::optional<unsigned> getPackIndex() const {
4537 if (PackIndex == 0)
4538 return std::nullopt;
4539 return PackIndex - 1;
4540 }
4541
4542 NonTypeTemplateParmDecl *getParameter() const;
4543
4544 bool isReferenceParameter() const { return AssociatedDeclAndRef.getInt(); }
4545
4546
4547 QualType getParameterType(const ASTContext &Ctx) const;
4548
4549 static bool classof(const Stmt *s) {
4550 return s->getStmtClass() == SubstNonTypeTemplateParmExprClass;
4551 }
4552
4553
4554 child_range children() { return child_range(&Replacement, &Replacement + 1); }
4555
4556 const_child_range children() const {
4557 return const_child_range(&Replacement, &Replacement + 1);
4558 }
4559 };
4560
4561
4562
4563
4564
4565
4566
4567
4568
4569
4570
4571
4572
4573 class SubstNonTypeTemplateParmPackExpr : public Expr {
4574 friend class ASTReader;
4575 friend class ASTStmtReader;
4576
4577
4578 Decl *AssociatedDecl;
4579
4580
4581
4582 const TemplateArgument *Arguments;
4583
4584
4585 unsigned NumArguments : 16;
4586
4587 unsigned Index : 16;
4588
4589
4590 SourceLocation NameLoc;
4591
4592 explicit SubstNonTypeTemplateParmPackExpr(EmptyShell Empty)
4593 : Expr(SubstNonTypeTemplateParmPackExprClass, Empty) {}
4594
4595 public:
4596 SubstNonTypeTemplateParmPackExpr(QualType T, ExprValueKind ValueKind,
4597 SourceLocation NameLoc,
4598 const TemplateArgument &ArgPack,
4599 Decl *AssociatedDecl, unsigned Index);
4600
4601
4602
4603 Decl *getAssociatedDecl() const { return AssociatedDecl; }
4604
4605
4606
4607 unsigned getIndex() const { return Index; }
4608
4609
4610 NonTypeTemplateParmDecl *getParameterPack() const;
4611
4612
4613 SourceLocation getParameterPackLocation() const { return NameLoc; }
4614
4615
4616
4617 TemplateArgument getArgumentPack() const;
4618
4619 SourceLocation getBeginLoc() const LLVM_READONLY { return NameLoc; }
4620 SourceLocation getEndLoc() const LLVM_READONLY { return NameLoc; }
4621
4622 static bool classof(const Stmt *T) {
4623 return T->getStmtClass() == SubstNonTypeTemplateParmPackExprClass;
4624 }
4625
4626
4627 child_range children() {
4628 return child_range(child_iterator(), child_iterator());
4629 }
4630
4631 const_child_range children() const {
4632 return const_child_range(const_child_iterator(), const_child_iterator());
4633 }
4634 };
4635
4636
4637
4638
4639
4640
4641
4642
4643
4644
4645
4646
4647
4648
4649
4650 class FunctionParmPackExpr final
4651 : public Expr,
4652 private llvm::TrailingObjects<FunctionParmPackExpr, VarDecl *> {
4653 friend class ASTReader;
4654 friend class ASTStmtReader;
4655 friend TrailingObjects;
4656
4657
4658 VarDecl *ParamPack;
4659
4660
4661 SourceLocation NameLoc;
4662
4663
4664 unsigned NumParameters;
4665
4666 FunctionParmPackExpr(QualType T, VarDecl *ParamPack,
4667 SourceLocation NameLoc, unsigned NumParams,
4668 VarDecl *const *Params);
4669
4670 public:
4671 static FunctionParmPackExpr *Create(const ASTContext &Context, QualType T,
4672 VarDecl *ParamPack,
4673 SourceLocation NameLoc,
4674 ArrayRef<VarDecl *> Params);
4675 static FunctionParmPackExpr *CreateEmpty(const ASTContext &Context,
4676 unsigned NumParams);
4677
4678
4679 VarDecl *getParameterPack() const { return ParamPack; }
4680
4681
4682 SourceLocation getParameterPackLocation() const { return NameLoc; }
4683
4684
4685
4686 using iterator = VarDecl * const *;
4687 iterator begin() const { return getTrailingObjects<VarDecl *>(); }
4688 iterator end() const { return begin() + NumParameters; }
4689
4690
4691 unsigned getNumExpansions() const { return NumParameters; }
4692
4693
4694 VarDecl *getExpansion(unsigned I) const { return begin()[I]; }
4695
4696 SourceLocation getBeginLoc() const LLVM_READONLY { return NameLoc; }
4697 SourceLocation getEndLoc() const LLVM_READONLY { return NameLoc; }
4698
4699 static bool classof(const Stmt *T) {
4700 return T->getStmtClass() == FunctionParmPackExprClass;
4701 }
4702
4703 child_range children() {
4704 return child_range(child_iterator(), child_iterator());
4705 }
4706
4707 const_child_range children() const {
4708 return const_child_range(const_child_iterator(), const_child_iterator());
4709 }
4710 };
4711
4712
4713
4714
4715
4716
4717
4718
4719
4720
4721
4722
4723
4724
4725
4726
4727
4728
4729
4730
4731
4732 class MaterializeTemporaryExpr : public Expr {
4733 private:
4734 friend class ASTStmtReader;
4735 friend class ASTStmtWriter;
4736
4737 llvm::PointerUnion<Stmt *, LifetimeExtendedTemporaryDecl *> State;
4738
4739 public:
4740 MaterializeTemporaryExpr(QualType T, Expr *Temporary,
4741 bool BoundToLvalueReference,
4742 LifetimeExtendedTemporaryDecl *MTD = nullptr);
4743
4744 MaterializeTemporaryExpr(EmptyShell Empty)
4745 : Expr(MaterializeTemporaryExprClass, Empty) {}
4746
4747
4748
4749 Expr *getSubExpr() const {
4750 return cast<Expr>(
4751 isa<Stmt *>(State)
4752 ? cast<Stmt *>(State)
4753 : cast<LifetimeExtendedTemporaryDecl *>(State)->getTemporaryExpr());
4754 }
4755
4756
4757 StorageDuration getStorageDuration() const {
4758 return isa<Stmt *>(State) ? SD_FullExpression
4759 : cast<LifetimeExtendedTemporaryDecl *>(State)
4760 ->getStorageDuration();
4761 }
4762
4763
4764
4765 APValue *getOrCreateValue(bool MayCreate) const {
4766 assert(isa<LifetimeExtendedTemporaryDecl *>(State) &&
4767 "the temporary has not been lifetime extended");
4768 return cast<LifetimeExtendedTemporaryDecl *>(State)->getOrCreateValue(
4769 MayCreate);
4770 }
4771
4772 LifetimeExtendedTemporaryDecl *getLifetimeExtendedTemporaryDecl() {
4773 return State.dyn_cast<LifetimeExtendedTemporaryDecl *>();
4774 }
4775 const LifetimeExtendedTemporaryDecl *
4776 getLifetimeExtendedTemporaryDecl() const {
4777 return State.dyn_cast<LifetimeExtendedTemporaryDecl *>();
4778 }
4779
4780
4781
4782 ValueDecl *getExtendingDecl() {
4783 return isa<Stmt *>(State) ? nullptr
4784 : cast<LifetimeExtendedTemporaryDecl *>(State)
4785 ->getExtendingDecl();
4786 }
4787 const ValueDecl *getExtendingDecl() const {
4788 return const_cast<MaterializeTemporaryExpr *>(this)->getExtendingDecl();
4789 }
4790
4791 void setExtendingDecl(ValueDecl *ExtendedBy, unsigned ManglingNumber);
4792
4793 unsigned getManglingNumber() const {
4794 return isa<Stmt *>(State) ? 0
4795 : cast<LifetimeExtendedTemporaryDecl *>(State)
4796 ->getManglingNumber();
4797 }
4798
4799
4800
4801 bool isBoundToLvalueReference() const { return isLValue(); }
4802
4803
4804
4805 bool isUsableInConstantExpressions(const ASTContext &Context) const;
4806
4807 SourceLocation getBeginLoc() const LLVM_READONLY {
4808 return getSubExpr()->getBeginLoc();
4809 }
4810
4811 SourceLocation getEndLoc() const LLVM_READONLY {
4812 return getSubExpr()->getEndLoc();
4813 }
4814
4815 static bool classof(const Stmt *T) {
4816 return T->getStmtClass() == MaterializeTemporaryExprClass;
4817 }
4818
4819
4820 child_range children() {
4821 return isa<Stmt *>(State)
4822 ? child_range(State.getAddrOfPtr1(), State.getAddrOfPtr1() + 1)
4823 : cast<LifetimeExtendedTemporaryDecl *>(State)->childrenExpr();
4824 }
4825
4826 const_child_range children() const {
4827 return isa<Stmt *>(State)
4828 ? const_child_range(State.getAddrOfPtr1(),
4829 State.getAddrOfPtr1() + 1)
4830 : const_cast<const LifetimeExtendedTemporaryDecl *>(
4831 cast<LifetimeExtendedTemporaryDecl *>(State))
4832 ->childrenExpr();
4833 }
4834 };
4835
4836
4837
4838
4839
4840
4841
4842
4843
4844 class CXXFoldExpr : public Expr {
4845 friend class ASTStmtReader;
4846 friend class ASTStmtWriter;
4847
4848 enum SubExpr { Callee, LHS, RHS, Count };
4849
4850 SourceLocation LParenLoc;
4851 SourceLocation EllipsisLoc;
4852 SourceLocation RParenLoc;
4853
4854
4855 unsigned NumExpansions;
4856 Stmt *SubExprs[SubExpr::Count];
4857 BinaryOperatorKind Opcode;
4858
4859 public:
4860 CXXFoldExpr(QualType T, UnresolvedLookupExpr *Callee,
4861 SourceLocation LParenLoc, Expr *LHS, BinaryOperatorKind Opcode,
4862 SourceLocation EllipsisLoc, Expr *RHS, SourceLocation RParenLoc,
4863 std::optional<unsigned> NumExpansions);
4864
4865 CXXFoldExpr(EmptyShell Empty) : Expr(CXXFoldExprClass, Empty) {}
4866
4867 UnresolvedLookupExpr *getCallee() const {
4868 return static_cast<UnresolvedLookupExpr *>(SubExprs[SubExpr::Callee]);
4869 }
4870 Expr *getLHS() const { return static_cast<Expr*>(SubExprs[SubExpr::LHS]); }
4871 Expr *getRHS() const { return static_cast<Expr*>(SubExprs[SubExpr::RHS]); }
4872
4873
4874 bool isRightFold() const {
4875 return getLHS() && getLHS()->containsUnexpandedParameterPack();
4876 }
4877
4878
4879 bool isLeftFold() const { return !isRightFold(); }
4880
4881
4882 Expr *getPattern() const { return isLeftFold() ? getRHS() : getLHS(); }
4883
4884
4885 Expr *getInit() const { return isLeftFold() ? getLHS() : getRHS(); }
4886
4887 SourceLocation getLParenLoc() const { return LParenLoc; }
4888 SourceLocation getRParenLoc() const { return RParenLoc; }
4889 SourceLocation getEllipsisLoc() const { return EllipsisLoc; }
4890 BinaryOperatorKind getOperator() const { return Opcode; }
4891
4892 std::optional<unsigned> getNumExpansions() const {
4893 if (NumExpansions)
4894 return NumExpansions - 1;
4895 return std::nullopt;
4896 }
4897
4898 SourceLocation getBeginLoc() const LLVM_READONLY {
4899 if (LParenLoc.isValid())
4900 return LParenLoc;
4901 if (isLeftFold())
4902 return getEllipsisLoc();
4903 return getLHS()->getBeginLoc();
4904 }
4905
4906 SourceLocation getEndLoc() const LLVM_READONLY {
4907 if (RParenLoc.isValid())
4908 return RParenLoc;
4909 if (isRightFold())
4910 return getEllipsisLoc();
4911 return getRHS()->getEndLoc();
4912 }
4913
4914 static bool classof(const Stmt *T) {
4915 return T->getStmtClass() == CXXFoldExprClass;
4916 }
4917
4918
4919 child_range children() {
4920 return child_range(SubExprs, SubExprs + SubExpr::Count);
4921 }
4922
4923 const_child_range children() const {
4924 return const_child_range(SubExprs, SubExprs + SubExpr::Count);
4925 }
4926 };
4927
4928
4929
4930
4931
4932
4933
4934
4935
4936
4937
4938
4939
4940
4941
4942
4943
4944
4945
4946
4947
4948
4949
4950
4951
4952
4953
4954
4955
4956 class CXXParenListInitExpr final
4957 : public Expr,
4958 private llvm::TrailingObjects<CXXParenListInitExpr, Expr *> {
4959 friend class TrailingObjects;
4960 friend class ASTStmtReader;
4961 friend class ASTStmtWriter;
4962
4963 unsigned NumExprs;
4964 unsigned NumUserSpecifiedExprs;
4965 SourceLocation InitLoc, LParenLoc, RParenLoc;
4966 llvm::PointerUnion<Expr *, FieldDecl *> ArrayFillerOrUnionFieldInit;
4967
4968 CXXParenListInitExpr(ArrayRef<Expr *> Args, QualType T,
4969 unsigned NumUserSpecifiedExprs, SourceLocation InitLoc,
4970 SourceLocation LParenLoc, SourceLocation RParenLoc)
4971 : Expr(CXXParenListInitExprClass, T, getValueKindForType(T), OK_Ordinary),
4972 NumExprs(Args.size()), NumUserSpecifiedExprs(NumUserSpecifiedExprs),
4973 InitLoc(InitLoc), LParenLoc(LParenLoc), RParenLoc(RParenLoc) {
4974 std::copy(Args.begin(), Args.end(), getTrailingObjects<Expr *>());
4975 assert(NumExprs >= NumUserSpecifiedExprs &&
4976 "number of user specified inits is greater than the number of "
4977 "passed inits");
4978 setDependence(computeDependence(this));
4979 }
4980
4981 size_t numTrailingObjects(OverloadToken<Expr *>) const { return NumExprs; }
4982
4983 public:
4984 static CXXParenListInitExpr *
4985 Create(ASTContext &C, ArrayRef<Expr *> Args, QualType T,
4986 unsigned NumUserSpecifiedExprs, SourceLocation InitLoc,
4987 SourceLocation LParenLoc, SourceLocation RParenLoc);
4988
4989 static CXXParenListInitExpr *CreateEmpty(ASTContext &C, unsigned numExprs,
4990 EmptyShell Empty);
4991
4992 explicit CXXParenListInitExpr(EmptyShell Empty, unsigned NumExprs)
4993 : Expr(CXXParenListInitExprClass, Empty), NumExprs(NumExprs),
4994 NumUserSpecifiedExprs(0) {}
4995
4996 void updateDependence() { setDependence(computeDependence(this)); }
4997
4998 ArrayRef<Expr *> getInitExprs() {
4999 return ArrayRef(getTrailingObjects<Expr *>(), NumExprs);
5000 }
5001
5002 const ArrayRef<Expr *> getInitExprs() const {
5003 return ArrayRef(getTrailingObjects<Expr *>(), NumExprs);
5004 }
5005
5006 ArrayRef<Expr *> getUserSpecifiedInitExprs() {
5007 return ArrayRef(getTrailingObjects<Expr *>(), NumUserSpecifiedExprs);
5008 }
5009
5010 const ArrayRef<Expr *> getUserSpecifiedInitExprs() const {
5011 return ArrayRef(getTrailingObjects<Expr *>(), NumUserSpecifiedExprs);
5012 }
5013
5014 SourceLocation getBeginLoc() const LLVM_READONLY { return LParenLoc; }
5015
5016 SourceLocation getEndLoc() const LLVM_READONLY { return RParenLoc; }
5017
5018 SourceLocation getInitLoc() const LLVM_READONLY { return InitLoc; }
5019
5020 SourceRange getSourceRange() const LLVM_READONLY {
5021 return SourceRange(getBeginLoc(), getEndLoc());
5022 }
5023
5024 void setArrayFiller(Expr *E) { ArrayFillerOrUnionFieldInit = E; }
5025
5026 Expr *getArrayFiller() {
5027 return dyn_cast_if_present<Expr *>(ArrayFillerOrUnionFieldInit);
5028 }
5029
5030 const Expr *getArrayFiller() const {
5031 return dyn_cast_if_present<Expr *>(ArrayFillerOrUnionFieldInit);
5032 }
5033
5034 void setInitializedFieldInUnion(FieldDecl *FD) {
5035 ArrayFillerOrUnionFieldInit = FD;
5036 }
5037
5038 FieldDecl *getInitializedFieldInUnion() {
5039 return dyn_cast_if_present<FieldDecl *>(ArrayFillerOrUnionFieldInit);
5040 }
5041
5042 const FieldDecl *getInitializedFieldInUnion() const {
5043 return ArrayFillerOrUnionFieldInit.dyn_cast<FieldDecl *>();
5044 }
5045
5046 child_range children() {
5047 Stmt **Begin = reinterpret_cast<Stmt **>(getTrailingObjects<Expr *>());
5048 return child_range(Begin, Begin + NumExprs);
5049 }
5050
5051 const_child_range children() const {
5052 Stmt *const *Begin =
5053 reinterpret_cast<Stmt *const *>(getTrailingObjects<Expr *>());
5054 return const_child_range(Begin, Begin + NumExprs);
5055 }
5056
5057 static bool classof(const Stmt *T) {
5058 return T->getStmtClass() == CXXParenListInitExprClass;
5059 }
5060 };
5061
5062
5063
5064
5065
5066
5067
5068
5069
5070
5071
5072
5073
5074
5075 class CoroutineSuspendExpr : public Expr {
5076 friend class ASTStmtReader;
5077
5078 SourceLocation KeywordLoc;
5079
5080 enum SubExpr { Operand, Common, Ready, Suspend, Resume, Count };
5081
5082 Stmt *SubExprs[SubExpr::Count];
5083 OpaqueValueExpr *OpaqueValue = nullptr;
5084
5085 public:
5086
5087 enum class SuspendReturnType { SuspendVoid, SuspendBool, SuspendHandle };
5088
5089 CoroutineSuspendExpr(StmtClass SC, SourceLocation KeywordLoc, Expr *Operand,
5090 Expr *Common, Expr *Ready, Expr *Suspend, Expr *Resume,
5091 OpaqueValueExpr *OpaqueValue)
5092 : Expr(SC, Resume->getType(), Resume->getValueKind(),
5093 Resume->getObjectKind()),
5094 KeywordLoc(KeywordLoc), OpaqueValue(OpaqueValue) {
5095 SubExprs[SubExpr::Operand] = Operand;
5096 SubExprs[SubExpr::Common] = Common;
5097 SubExprs[SubExpr::Ready] = Ready;
5098 SubExprs[SubExpr::Suspend] = Suspend;
5099 SubExprs[SubExpr::Resume] = Resume;
5100 setDependence(computeDependence(this));
5101 }
5102
5103 CoroutineSuspendExpr(StmtClass SC, SourceLocation KeywordLoc, QualType Ty,
5104 Expr *Operand, Expr *Common)
5105 : Expr(SC, Ty, VK_PRValue, OK_Ordinary), KeywordLoc(KeywordLoc) {
5106 assert(Common->isTypeDependent() && Ty->isDependentType() &&
5107 "wrong constructor for non-dependent co_await/co_yield expression");
5108 SubExprs[SubExpr::Operand] = Operand;
5109 SubExprs[SubExpr::Common] = Common;
5110 SubExprs[SubExpr::Ready] = nullptr;
5111 SubExprs[SubExpr::Suspend] = nullptr;
5112 SubExprs[SubExpr::Resume] = nullptr;
5113 setDependence(computeDependence(this));
5114 }
5115
5116 CoroutineSuspendExpr(StmtClass SC, EmptyShell Empty) : Expr(SC, Empty) {
5117 SubExprs[SubExpr::Operand] = nullptr;
5118 SubExprs[SubExpr::Common] = nullptr;
5119 SubExprs[SubExpr::Ready] = nullptr;
5120 SubExprs[SubExpr::Suspend] = nullptr;
5121 SubExprs[SubExpr::Resume] = nullptr;
5122 }
5123
5124 Expr *getCommonExpr() const {
5125 return static_cast<Expr*>(SubExprs[SubExpr::Common]);
5126 }
5127
5128
5129 OpaqueValueExpr *getOpaqueValue() const { return OpaqueValue; }
5130
5131 Expr *getReadyExpr() const {
5132 return static_cast<Expr*>(SubExprs[SubExpr::Ready]);
5133 }
5134
5135 Expr *getSuspendExpr() const {
5136 return static_cast<Expr*>(SubExprs[SubExpr::Suspend]);
5137 }
5138
5139 Expr *getResumeExpr() const {
5140 return static_cast<Expr*>(SubExprs[SubExpr::Resume]);
5141 }
5142
5143
5144 Expr *getOperand() const {
5145 return static_cast<Expr *>(SubExprs[SubExpr::Operand]);
5146 }
5147
5148 SuspendReturnType getSuspendReturnType() const {
5149 auto *SuspendExpr = getSuspendExpr();
5150 assert(SuspendExpr);
5151
5152 auto SuspendType = SuspendExpr->getType();
5153
5154 if (SuspendType->isVoidType())
5155 return SuspendReturnType::SuspendVoid;
5156 if (SuspendType->isBooleanType())
5157 return SuspendReturnType::SuspendBool;
5158
5159
5160
5161
5162 assert(SuspendType->isVoidPointerType());
5163 return SuspendReturnType::SuspendHandle;
5164 }
5165
5166 SourceLocation getKeywordLoc() const { return KeywordLoc; }
5167
5168 SourceLocation getBeginLoc() const LLVM_READONLY { return KeywordLoc; }
5169
5170 SourceLocation getEndLoc() const LLVM_READONLY {
5171 return getOperand()->getEndLoc();
5172 }
5173
5174 child_range children() {
5175 return child_range(SubExprs, SubExprs + SubExpr::Count);
5176 }
5177
5178 const_child_range children() const {
5179 return const_child_range(SubExprs, SubExprs + SubExpr::Count);
5180 }
5181
5182 static bool classof(const Stmt *T) {
5183 return T->getStmtClass() == CoawaitExprClass ||
5184 T->getStmtClass() == CoyieldExprClass;
5185 }
5186 };
5187
5188
5189 class CoawaitExpr : public CoroutineSuspendExpr {
5190 friend class ASTStmtReader;
5191
5192 public:
5193 CoawaitExpr(SourceLocation CoawaitLoc, Expr *Operand, Expr *Common,
5194 Expr *Ready, Expr *Suspend, Expr *Resume,
5195 OpaqueValueExpr *OpaqueValue, bool IsImplicit = false)
5196 : CoroutineSuspendExpr(CoawaitExprClass, CoawaitLoc, Operand, Common,
5197 Ready, Suspend, Resume, OpaqueValue) {
5198 CoawaitBits.IsImplicit = IsImplicit;
5199 }
5200
5201 CoawaitExpr(SourceLocation CoawaitLoc, QualType Ty, Expr *Operand,
5202 Expr *Common, bool IsImplicit = false)
5203 : CoroutineSuspendExpr(CoawaitExprClass, CoawaitLoc, Ty, Operand,
5204 Common) {
5205 CoawaitBits.IsImplicit = IsImplicit;
5206 }
5207
5208 CoawaitExpr(EmptyShell Empty)
5209 : CoroutineSuspendExpr(CoawaitExprClass, Empty) {}
5210
5211 bool isImplicit() const { return CoawaitBits.IsImplicit; }
5212 void setIsImplicit(bool value = true) { CoawaitBits.IsImplicit = value; }
5213
5214 static bool classof(const Stmt *T) {
5215 return T->getStmtClass() == CoawaitExprClass;
5216 }
5217 };
5218
5219
5220
5221 class DependentCoawaitExpr : public Expr {
5222 friend class ASTStmtReader;
5223
5224 SourceLocation KeywordLoc;
5225 Stmt *SubExprs[2];
5226
5227 public:
5228 DependentCoawaitExpr(SourceLocation KeywordLoc, QualType Ty, Expr *Op,
5229 UnresolvedLookupExpr *OpCoawait)
5230 : Expr(DependentCoawaitExprClass, Ty, VK_PRValue, OK_Ordinary),
5231 KeywordLoc(KeywordLoc) {
5232
5233
5234 assert(Ty->isDependentType() &&
5235 "wrong constructor for non-dependent co_await/co_yield expression");
5236 SubExprs[0] = Op;
5237 SubExprs[1] = OpCoawait;
5238 setDependence(computeDependence(this));
5239 }
5240
5241 DependentCoawaitExpr(EmptyShell Empty)
5242 : Expr(DependentCoawaitExprClass, Empty) {}
5243
5244 Expr *getOperand() const { return cast<Expr>(SubExprs[0]); }
5245
5246 UnresolvedLookupExpr *getOperatorCoawaitLookup() const {
5247 return cast<UnresolvedLookupExpr>(SubExprs[1]);
5248 }
5249
5250 SourceLocation getKeywordLoc() const { return KeywordLoc; }
5251
5252 SourceLocation getBeginLoc() const LLVM_READONLY { return KeywordLoc; }
5253
5254 SourceLocation getEndLoc() const LLVM_READONLY {
5255 return getOperand()->getEndLoc();
5256 }
5257
5258 child_range children() { return child_range(SubExprs, SubExprs + 2); }
5259
5260 const_child_range children() const {
5261 return const_child_range(SubExprs, SubExprs + 2);
5262 }
5263
5264 static bool classof(const Stmt *T) {
5265 return T->getStmtClass() == DependentCoawaitExprClass;
5266 }
5267 };
5268
5269
5270 class CoyieldExpr : public CoroutineSuspendExpr {
5271 friend class ASTStmtReader;
5272
5273 public:
5274 CoyieldExpr(SourceLocation CoyieldLoc, Expr *Operand, Expr *Common,
5275 Expr *Ready, Expr *Suspend, Expr *Resume,
5276 OpaqueValueExpr *OpaqueValue)
5277 : CoroutineSuspendExpr(CoyieldExprClass, CoyieldLoc, Operand, Common,
5278 Ready, Suspend, Resume, OpaqueValue) {}
5279 CoyieldExpr(SourceLocation CoyieldLoc, QualType Ty, Expr *Operand,
5280 Expr *Common)
5281 : CoroutineSuspendExpr(CoyieldExprClass, CoyieldLoc, Ty, Operand,
5282 Common) {}
5283 CoyieldExpr(EmptyShell Empty)
5284 : CoroutineSuspendExpr(CoyieldExprClass, Empty) {}
5285
5286 static bool classof(const Stmt *T) {
5287 return T->getStmtClass() == CoyieldExprClass;
5288 }
5289 };
5290
5291
5292
5293
5294 class BuiltinBitCastExpr final
5295 : public ExplicitCastExpr,
5296 private llvm::TrailingObjects<BuiltinBitCastExpr, CXXBaseSpecifier *> {
5297 friend class ASTStmtReader;
5298 friend class CastExpr;
5299 friend TrailingObjects;
5300
5301 SourceLocation KWLoc;
5302 SourceLocation RParenLoc;
5303
5304 public:
5305 BuiltinBitCastExpr(QualType T, ExprValueKind VK, CastKind CK, Expr *SrcExpr,
5306 TypeSourceInfo *DstType, SourceLocation KWLoc,
5307 SourceLocation RParenLoc)
5308 : ExplicitCastExpr(BuiltinBitCastExprClass, T, VK, CK, SrcExpr, 0, false,
5309 DstType),
5310 KWLoc(KWLoc), RParenLoc(RParenLoc) {}
5311 BuiltinBitCastExpr(EmptyShell Empty)
5312 : ExplicitCastExpr(BuiltinBitCastExprClass, Empty, 0, false) {}
5313
5314 SourceLocation getBeginLoc() const LLVM_READONLY { return KWLoc; }
5315 SourceLocation getEndLoc() const LLVM_READONLY { return RParenLoc; }
5316
5317 static bool classof(const Stmt *T) {
5318 return T->getStmtClass() == BuiltinBitCastExprClass;
5319 }
5320 };
5321
5322 }
5323
5324 #endif