Home | History | Annotate | Download | only in AST
      1 //===--- ExprCXX.h - Classes for representing expressions -------*- C++ -*-===//
      2 //
      3 //                     The LLVM Compiler Infrastructure
      4 //
      5 // This file is distributed under the University of Illinois Open Source
      6 // License. See LICENSE.TXT for details.
      7 //
      8 //===----------------------------------------------------------------------===//
      9 ///
     10 /// \file
     11 /// \brief Defines the clang::Expr interface and subclasses for C++ expressions.
     12 ///
     13 //===----------------------------------------------------------------------===//
     14 
     15 #ifndef LLVM_CLANG_AST_EXPRCXX_H
     16 #define LLVM_CLANG_AST_EXPRCXX_H
     17 
     18 #include "clang/AST/Decl.h"
     19 #include "clang/AST/DeclCXX.h"
     20 #include "clang/AST/Expr.h"
     21 #include "clang/AST/LambdaCapture.h"
     22 #include "clang/AST/TemplateBase.h"
     23 #include "clang/AST/UnresolvedSet.h"
     24 #include "clang/Basic/ExpressionTraits.h"
     25 #include "clang/Basic/TypeTraits.h"
     26 #include "llvm/Support/Compiler.h"
     27 
     28 namespace clang {
     29 
     30 class CXXTemporary;
     31 class MSPropertyDecl;
     32 class TemplateArgumentListInfo;
     33 class UuidAttr;
     34 
     35 //===--------------------------------------------------------------------===//
     36 // C++ Expressions.
     37 //===--------------------------------------------------------------------===//
     38 
     39 /// \brief A call to an overloaded operator written using operator
     40 /// syntax.
     41 ///
     42 /// Represents a call to an overloaded operator written using operator
     43 /// syntax, e.g., "x + y" or "*p". While semantically equivalent to a
     44 /// normal call, this AST node provides better information about the
     45 /// syntactic representation of the call.
     46 ///
     47 /// In a C++ template, this expression node kind will be used whenever
     48 /// any of the arguments are type-dependent. In this case, the
     49 /// function itself will be a (possibly empty) set of functions and
     50 /// function templates that were found by name lookup at template
     51 /// definition time.
     52 class CXXOperatorCallExpr : public CallExpr {
     53   /// \brief The overloaded operator.
     54   OverloadedOperatorKind Operator;
     55   SourceRange Range;
     56 
     57   // Only meaningful for floating point types.
     58   FPOptions FPFeatures;
     59 
     60   SourceRange getSourceRangeImpl() const LLVM_READONLY;
     61 public:
     62   CXXOperatorCallExpr(ASTContext& C, OverloadedOperatorKind Op, Expr *fn,
     63                       ArrayRef<Expr*> args, QualType t, ExprValueKind VK,
     64                       SourceLocation operatorloc, FPOptions FPFeatures)
     65     : CallExpr(C, CXXOperatorCallExprClass, fn, args, t, VK, operatorloc),
     66       Operator(Op), FPFeatures(FPFeatures) {
     67     Range = getSourceRangeImpl();
     68   }
     69   explicit CXXOperatorCallExpr(ASTContext& C, EmptyShell Empty) :
     70     CallExpr(C, CXXOperatorCallExprClass, Empty) { }
     71 
     72 
     73   /// \brief Returns the kind of overloaded operator that this
     74   /// expression refers to.
     75   OverloadedOperatorKind getOperator() const { return Operator; }
     76 
     77   static bool isAssignmentOp(OverloadedOperatorKind Opc) {
     78     return Opc == OO_Equal || Opc == OO_StarEqual ||
     79            Opc == OO_SlashEqual || Opc == OO_PercentEqual ||
     80            Opc == OO_PlusEqual || Opc == OO_MinusEqual ||
     81            Opc == OO_LessLessEqual || Opc == OO_GreaterGreaterEqual ||
     82            Opc == OO_AmpEqual || Opc == OO_CaretEqual ||
     83            Opc == OO_PipeEqual;
     84   }
     85   bool isAssignmentOp() const { return isAssignmentOp(getOperator()); }
     86 
     87   /// \brief Is this written as an infix binary operator?
     88   bool isInfixBinaryOp() const;
     89 
     90   /// \brief Returns the location of the operator symbol in the expression.
     91   ///
     92   /// When \c getOperator()==OO_Call, this is the location of the right
     93   /// parentheses; when \c getOperator()==OO_Subscript, this is the location
     94   /// of the right bracket.
     95   SourceLocation getOperatorLoc() const { return getRParenLoc(); }
     96 
     97   SourceLocation getExprLoc() const LLVM_READONLY {
     98     return (Operator < OO_Plus || Operator >= OO_Arrow ||
     99             Operator == OO_PlusPlus || Operator == OO_MinusMinus)
    100                ? getLocStart()
    101                : getOperatorLoc();
    102   }
    103 
    104   SourceLocation getLocStart() const LLVM_READONLY { return Range.getBegin(); }
    105   SourceLocation getLocEnd() const LLVM_READONLY { return Range.getEnd(); }
    106   SourceRange getSourceRange() const { return Range; }
    107 
    108   static bool classof(const Stmt *T) {
    109     return T->getStmtClass() == CXXOperatorCallExprClass;
    110   }
    111 
    112   // Set the FP contractability status of this operator. Only meaningful for
    113   // operations on floating point types.
    114   void setFPFeatures(FPOptions F) { FPFeatures = F; }
    115 
    116   FPOptions getFPFeatures() const { return FPFeatures; }
    117 
    118   // Get the FP contractability status of this operator. Only meaningful for
    119   // operations on floating point types.
    120   bool isFPContractableWithinStatement() const {
    121     return FPFeatures.allowFPContractWithinStatement();
    122   }
    123 
    124   friend class ASTStmtReader;
    125   friend class ASTStmtWriter;
    126 };
    127 
    128 /// Represents a call to a member function that
    129 /// may be written either with member call syntax (e.g., "obj.func()"
    130 /// or "objptr->func()") or with normal function-call syntax
    131 /// ("func()") within a member function that ends up calling a member
    132 /// function. The callee in either case is a MemberExpr that contains
    133 /// both the object argument and the member function, while the
    134 /// arguments are the arguments within the parentheses (not including
    135 /// the object argument).
    136 class CXXMemberCallExpr : public CallExpr {
    137 public:
    138   CXXMemberCallExpr(ASTContext &C, Expr *fn, ArrayRef<Expr*> args,
    139                     QualType t, ExprValueKind VK, SourceLocation RP)
    140     : CallExpr(C, CXXMemberCallExprClass, fn, args, t, VK, RP) {}
    141 
    142   CXXMemberCallExpr(ASTContext &C, EmptyShell Empty)
    143     : CallExpr(C, CXXMemberCallExprClass, Empty) { }
    144 
    145   /// \brief Retrieves the implicit object argument for the member call.
    146   ///
    147   /// For example, in "x.f(5)", this returns the sub-expression "x".
    148   Expr *getImplicitObjectArgument() const;
    149 
    150   /// \brief Retrieves the declaration of the called method.
    151   CXXMethodDecl *getMethodDecl() const;
    152 
    153   /// \brief Retrieves the CXXRecordDecl for the underlying type of
    154   /// the implicit object argument.
    155   ///
    156   /// Note that this is may not be the same declaration as that of the class
    157   /// context of the CXXMethodDecl which this function is calling.
    158   /// FIXME: Returns 0 for member pointer call exprs.
    159   CXXRecordDecl *getRecordDecl() const;
    160 
    161   SourceLocation getExprLoc() const LLVM_READONLY {
    162     SourceLocation CLoc = getCallee()->getExprLoc();
    163     if (CLoc.isValid())
    164       return CLoc;
    165 
    166     return getLocStart();
    167   }
    168 
    169   static bool classof(const Stmt *T) {
    170     return T->getStmtClass() == CXXMemberCallExprClass;
    171   }
    172 };
    173 
    174 /// \brief Represents a call to a CUDA kernel function.
    175 class CUDAKernelCallExpr : public CallExpr {
    176 private:
    177   enum { CONFIG, END_PREARG };
    178 
    179 public:
    180   CUDAKernelCallExpr(ASTContext &C, Expr *fn, CallExpr *Config,
    181                      ArrayRef<Expr*> args, QualType t, ExprValueKind VK,
    182                      SourceLocation RP)
    183       : CallExpr(C, CUDAKernelCallExprClass, fn, Config, args, t, VK, RP) {}
    184 
    185   CUDAKernelCallExpr(ASTContext &C, EmptyShell Empty)
    186     : CallExpr(C, CUDAKernelCallExprClass, END_PREARG, Empty) { }
    187 
    188   const CallExpr *getConfig() const {
    189     return cast_or_null<CallExpr>(getPreArg(CONFIG));
    190   }
    191   CallExpr *getConfig() { return cast_or_null<CallExpr>(getPreArg(CONFIG)); }
    192 
    193   /// \brief Sets the kernel configuration expression.
    194   ///
    195   /// Note that this method cannot be called if config has already been set to a
    196   /// non-null value.
    197   void setConfig(CallExpr *E) {
    198     assert(!getConfig() &&
    199            "Cannot call setConfig if config is not null");
    200     setPreArg(CONFIG, E);
    201     setInstantiationDependent(isInstantiationDependent() ||
    202                               E->isInstantiationDependent());
    203     setContainsUnexpandedParameterPack(containsUnexpandedParameterPack() ||
    204                                        E->containsUnexpandedParameterPack());
    205   }
    206 
    207   static bool classof(const Stmt *T) {
    208     return T->getStmtClass() == CUDAKernelCallExprClass;
    209   }
    210 };
    211 
    212 /// \brief Abstract class common to all of the C++ "named"/"keyword" casts.
    213 ///
    214 /// This abstract class is inherited by all of the classes
    215 /// representing "named" casts: CXXStaticCastExpr for \c static_cast,
    216 /// CXXDynamicCastExpr for \c dynamic_cast, CXXReinterpretCastExpr for
    217 /// reinterpret_cast, and CXXConstCastExpr for \c const_cast.
    218 class CXXNamedCastExpr : public ExplicitCastExpr {
    219 private:
    220   SourceLocation Loc; // the location of the casting op
    221   SourceLocation RParenLoc; // the location of the right parenthesis
    222   SourceRange AngleBrackets; // range for '<' '>'
    223 
    224 protected:
    225   CXXNamedCastExpr(StmtClass SC, QualType ty, ExprValueKind VK,
    226                    CastKind kind, Expr *op, unsigned PathSize,
    227                    TypeSourceInfo *writtenTy, SourceLocation l,
    228                    SourceLocation RParenLoc,
    229                    SourceRange AngleBrackets)
    230     : ExplicitCastExpr(SC, ty, VK, kind, op, PathSize, writtenTy), Loc(l),
    231       RParenLoc(RParenLoc), AngleBrackets(AngleBrackets) {}
    232 
    233   explicit CXXNamedCastExpr(StmtClass SC, EmptyShell Shell, unsigned PathSize)
    234     : ExplicitCastExpr(SC, Shell, PathSize) { }
    235 
    236   friend class ASTStmtReader;
    237 
    238 public:
    239   const char *getCastName() const;
    240 
    241   /// \brief Retrieve the location of the cast operator keyword, e.g.,
    242   /// \c static_cast.
    243   SourceLocation getOperatorLoc() const { return Loc; }
    244 
    245   /// \brief Retrieve the location of the closing parenthesis.
    246   SourceLocation getRParenLoc() const { return RParenLoc; }
    247 
    248   SourceLocation getLocStart() const LLVM_READONLY { return Loc; }
    249   SourceLocation getLocEnd() const LLVM_READONLY { return RParenLoc; }
    250   SourceRange getAngleBrackets() const LLVM_READONLY { return AngleBrackets; }
    251 
    252   static bool classof(const Stmt *T) {
    253     switch (T->getStmtClass()) {
    254     case CXXStaticCastExprClass:
    255     case CXXDynamicCastExprClass:
    256     case CXXReinterpretCastExprClass:
    257     case CXXConstCastExprClass:
    258       return true;
    259     default:
    260       return false;
    261     }
    262   }
    263 };
    264 
    265 /// \brief A C++ \c static_cast expression (C++ [expr.static.cast]).
    266 ///
    267 /// This expression node represents a C++ static cast, e.g.,
    268 /// \c static_cast<int>(1.0).
    269 class CXXStaticCastExpr final
    270     : public CXXNamedCastExpr,
    271       private llvm::TrailingObjects<CXXStaticCastExpr, CXXBaseSpecifier *> {
    272   CXXStaticCastExpr(QualType ty, ExprValueKind vk, CastKind kind, Expr *op,
    273                     unsigned pathSize, TypeSourceInfo *writtenTy,
    274                     SourceLocation l, SourceLocation RParenLoc,
    275                     SourceRange AngleBrackets)
    276     : CXXNamedCastExpr(CXXStaticCastExprClass, ty, vk, kind, op, pathSize,
    277                        writtenTy, l, RParenLoc, AngleBrackets) {}
    278 
    279   explicit CXXStaticCastExpr(EmptyShell Empty, unsigned PathSize)
    280     : CXXNamedCastExpr(CXXStaticCastExprClass, Empty, PathSize) { }
    281 
    282 public:
    283   static CXXStaticCastExpr *Create(const ASTContext &Context, QualType T,
    284                                    ExprValueKind VK, CastKind K, Expr *Op,
    285                                    const CXXCastPath *Path,
    286                                    TypeSourceInfo *Written, SourceLocation L,
    287                                    SourceLocation RParenLoc,
    288                                    SourceRange AngleBrackets);
    289   static CXXStaticCastExpr *CreateEmpty(const ASTContext &Context,
    290                                         unsigned PathSize);
    291 
    292   static bool classof(const Stmt *T) {
    293     return T->getStmtClass() == CXXStaticCastExprClass;
    294   }
    295 
    296   friend TrailingObjects;
    297   friend class CastExpr;
    298 };
    299 
    300 /// \brief A C++ @c dynamic_cast expression (C++ [expr.dynamic.cast]).
    301 ///
    302 /// This expression node represents a dynamic cast, e.g.,
    303 /// \c dynamic_cast<Derived*>(BasePtr). Such a cast may perform a run-time
    304 /// check to determine how to perform the type conversion.
    305 class CXXDynamicCastExpr final
    306     : public CXXNamedCastExpr,
    307       private llvm::TrailingObjects<CXXDynamicCastExpr, CXXBaseSpecifier *> {
    308   CXXDynamicCastExpr(QualType ty, ExprValueKind VK, CastKind kind,
    309                      Expr *op, unsigned pathSize, TypeSourceInfo *writtenTy,
    310                      SourceLocation l, SourceLocation RParenLoc,
    311                      SourceRange AngleBrackets)
    312     : CXXNamedCastExpr(CXXDynamicCastExprClass, ty, VK, kind, op, pathSize,
    313                        writtenTy, l, RParenLoc, AngleBrackets) {}
    314 
    315   explicit CXXDynamicCastExpr(EmptyShell Empty, unsigned pathSize)
    316     : CXXNamedCastExpr(CXXDynamicCastExprClass, Empty, pathSize) { }
    317 
    318 public:
    319   static CXXDynamicCastExpr *Create(const ASTContext &Context, QualType T,
    320                                     ExprValueKind VK, CastKind Kind, Expr *Op,
    321                                     const CXXCastPath *Path,
    322                                     TypeSourceInfo *Written, SourceLocation L,
    323                                     SourceLocation RParenLoc,
    324                                     SourceRange AngleBrackets);
    325 
    326   static CXXDynamicCastExpr *CreateEmpty(const ASTContext &Context,
    327                                          unsigned pathSize);
    328 
    329   bool isAlwaysNull() const;
    330 
    331   static bool classof(const Stmt *T) {
    332     return T->getStmtClass() == CXXDynamicCastExprClass;
    333   }
    334 
    335   friend TrailingObjects;
    336   friend class CastExpr;
    337 };
    338 
    339 /// \brief A C++ @c reinterpret_cast expression (C++ [expr.reinterpret.cast]).
    340 ///
    341 /// This expression node represents a reinterpret cast, e.g.,
    342 /// @c reinterpret_cast<int>(VoidPtr).
    343 ///
    344 /// A reinterpret_cast provides a differently-typed view of a value but
    345 /// (in Clang, as in most C++ implementations) performs no actual work at
    346 /// run time.
    347 class CXXReinterpretCastExpr final
    348     : public CXXNamedCastExpr,
    349       private llvm::TrailingObjects<CXXReinterpretCastExpr,
    350                                     CXXBaseSpecifier *> {
    351   CXXReinterpretCastExpr(QualType ty, ExprValueKind vk, CastKind kind,
    352                          Expr *op, unsigned pathSize,
    353                          TypeSourceInfo *writtenTy, SourceLocation l,
    354                          SourceLocation RParenLoc,
    355                          SourceRange AngleBrackets)
    356     : CXXNamedCastExpr(CXXReinterpretCastExprClass, ty, vk, kind, op,
    357                        pathSize, writtenTy, l, RParenLoc, AngleBrackets) {}
    358 
    359   CXXReinterpretCastExpr(EmptyShell Empty, unsigned pathSize)
    360     : CXXNamedCastExpr(CXXReinterpretCastExprClass, Empty, pathSize) { }
    361 
    362 public:
    363   static CXXReinterpretCastExpr *Create(const ASTContext &Context, QualType T,
    364                                         ExprValueKind VK, CastKind Kind,
    365                                         Expr *Op, const CXXCastPath *Path,
    366                                  TypeSourceInfo *WrittenTy, SourceLocation L,
    367                                         SourceLocation RParenLoc,
    368                                         SourceRange AngleBrackets);
    369   static CXXReinterpretCastExpr *CreateEmpty(const ASTContext &Context,
    370                                              unsigned pathSize);
    371 
    372   static bool classof(const Stmt *T) {
    373     return T->getStmtClass() == CXXReinterpretCastExprClass;
    374   }
    375 
    376   friend TrailingObjects;
    377   friend class CastExpr;
    378 };
    379 
    380 /// \brief A C++ \c const_cast expression (C++ [expr.const.cast]).
    381 ///
    382 /// This expression node represents a const cast, e.g.,
    383 /// \c const_cast<char*>(PtrToConstChar).
    384 ///
    385 /// A const_cast can remove type qualifiers but does not change the underlying
    386 /// value.
    387 class CXXConstCastExpr final
    388     : public CXXNamedCastExpr,
    389       private llvm::TrailingObjects<CXXConstCastExpr, CXXBaseSpecifier *> {
    390   CXXConstCastExpr(QualType ty, ExprValueKind VK, Expr *op,
    391                    TypeSourceInfo *writtenTy, SourceLocation l,
    392                    SourceLocation RParenLoc, SourceRange AngleBrackets)
    393     : CXXNamedCastExpr(CXXConstCastExprClass, ty, VK, CK_NoOp, op,
    394                        0, writtenTy, l, RParenLoc, AngleBrackets) {}
    395 
    396   explicit CXXConstCastExpr(EmptyShell Empty)
    397     : CXXNamedCastExpr(CXXConstCastExprClass, Empty, 0) { }
    398 
    399 public:
    400   static CXXConstCastExpr *Create(const ASTContext &Context, QualType T,
    401                                   ExprValueKind VK, Expr *Op,
    402                                   TypeSourceInfo *WrittenTy, SourceLocation L,
    403                                   SourceLocation RParenLoc,
    404                                   SourceRange AngleBrackets);
    405   static CXXConstCastExpr *CreateEmpty(const ASTContext &Context);
    406 
    407   static bool classof(const Stmt *T) {
    408     return T->getStmtClass() == CXXConstCastExprClass;
    409   }
    410 
    411   friend TrailingObjects;
    412   friend class CastExpr;
    413 };
    414 
    415 /// \brief A call to a literal operator (C++11 [over.literal])
    416 /// written as a user-defined literal (C++11 [lit.ext]).
    417 ///
    418 /// Represents a user-defined literal, e.g. "foo"_bar or 1.23_xyz. While this
    419 /// is semantically equivalent to a normal call, this AST node provides better
    420 /// information about the syntactic representation of the literal.
    421 ///
    422 /// Since literal operators are never found by ADL and can only be declared at
    423 /// namespace scope, a user-defined literal is never dependent.
    424 class UserDefinedLiteral : public CallExpr {
    425   /// \brief The location of a ud-suffix within the literal.
    426   SourceLocation UDSuffixLoc;
    427 
    428 public:
    429   UserDefinedLiteral(const ASTContext &C, Expr *Fn, ArrayRef<Expr*> Args,
    430                      QualType T, ExprValueKind VK, SourceLocation LitEndLoc,
    431                      SourceLocation SuffixLoc)
    432     : CallExpr(C, UserDefinedLiteralClass, Fn, Args, T, VK, LitEndLoc),
    433       UDSuffixLoc(SuffixLoc) {}
    434   explicit UserDefinedLiteral(const ASTContext &C, EmptyShell Empty)
    435     : CallExpr(C, UserDefinedLiteralClass, Empty) {}
    436 
    437   /// The kind of literal operator which is invoked.
    438   enum LiteralOperatorKind {
    439     LOK_Raw,      ///< Raw form: operator "" X (const char *)
    440     LOK_Template, ///< Raw form: operator "" X<cs...> ()
    441     LOK_Integer,  ///< operator "" X (unsigned long long)
    442     LOK_Floating, ///< operator "" X (long double)
    443     LOK_String,   ///< operator "" X (const CharT *, size_t)
    444     LOK_Character ///< operator "" X (CharT)
    445   };
    446 
    447   /// \brief Returns the kind of literal operator invocation
    448   /// which this expression represents.
    449   LiteralOperatorKind getLiteralOperatorKind() const;
    450 
    451   /// \brief If this is not a raw user-defined literal, get the
    452   /// underlying cooked literal (representing the literal with the suffix
    453   /// removed).
    454   Expr *getCookedLiteral();
    455   const Expr *getCookedLiteral() const {
    456     return const_cast<UserDefinedLiteral*>(this)->getCookedLiteral();
    457   }
    458 
    459   SourceLocation getLocStart() const {
    460     if (getLiteralOperatorKind() == LOK_Template)
    461       return getRParenLoc();
    462     return getArg(0)->getLocStart();
    463   }
    464   SourceLocation getLocEnd() const { return getRParenLoc(); }
    465 
    466 
    467   /// \brief Returns the location of a ud-suffix in the expression.
    468   ///
    469   /// For a string literal, there may be multiple identical suffixes. This
    470   /// returns the first.
    471   SourceLocation getUDSuffixLoc() const { return UDSuffixLoc; }
    472 
    473   /// \brief Returns the ud-suffix specified for this literal.
    474   const IdentifierInfo *getUDSuffix() const;
    475 
    476   static bool classof(const Stmt *S) {
    477     return S->getStmtClass() == UserDefinedLiteralClass;
    478   }
    479 
    480   friend class ASTStmtReader;
    481   friend class ASTStmtWriter;
    482 };
    483 
    484 /// \brief A boolean literal, per ([C++ lex.bool] Boolean literals).
    485 ///
    486 class CXXBoolLiteralExpr : public Expr {
    487   bool Value;
    488   SourceLocation Loc;
    489 public:
    490   CXXBoolLiteralExpr(bool val, QualType Ty, SourceLocation l) :
    491     Expr(CXXBoolLiteralExprClass, Ty, VK_RValue, OK_Ordinary, false, false,
    492          false, false),
    493     Value(val), Loc(l) {}
    494 
    495   explicit CXXBoolLiteralExpr(EmptyShell Empty)
    496     : Expr(CXXBoolLiteralExprClass, Empty) { }
    497 
    498   bool getValue() const { return Value; }
    499   void setValue(bool V) { Value = V; }
    500 
    501   SourceLocation getLocStart() const LLVM_READONLY { return Loc; }
    502   SourceLocation getLocEnd() const LLVM_READONLY { return Loc; }
    503 
    504   SourceLocation getLocation() const { return Loc; }
    505   void setLocation(SourceLocation L) { Loc = L; }
    506 
    507   static bool classof(const Stmt *T) {
    508     return T->getStmtClass() == CXXBoolLiteralExprClass;
    509   }
    510 
    511   // Iterators
    512   child_range children() {
    513     return child_range(child_iterator(), child_iterator());
    514   }
    515 };
    516 
    517 /// \brief The null pointer literal (C++11 [lex.nullptr])
    518 ///
    519 /// Introduced in C++11, the only literal of type \c nullptr_t is \c nullptr.
    520 class CXXNullPtrLiteralExpr : public Expr {
    521   SourceLocation Loc;
    522 public:
    523   CXXNullPtrLiteralExpr(QualType Ty, SourceLocation l) :
    524     Expr(CXXNullPtrLiteralExprClass, Ty, VK_RValue, OK_Ordinary, false, false,
    525          false, false),
    526     Loc(l) {}
    527 
    528   explicit CXXNullPtrLiteralExpr(EmptyShell Empty)
    529     : Expr(CXXNullPtrLiteralExprClass, Empty) { }
    530 
    531   SourceLocation getLocStart() const LLVM_READONLY { return Loc; }
    532   SourceLocation getLocEnd() const LLVM_READONLY { return Loc; }
    533 
    534   SourceLocation getLocation() const { return Loc; }
    535   void setLocation(SourceLocation L) { Loc = L; }
    536 
    537   static bool classof(const Stmt *T) {
    538     return T->getStmtClass() == CXXNullPtrLiteralExprClass;
    539   }
    540 
    541   child_range children() {
    542     return child_range(child_iterator(), child_iterator());
    543   }
    544 };
    545 
    546 /// \brief Implicit construction of a std::initializer_list<T> object from an
    547 /// array temporary within list-initialization (C++11 [dcl.init.list]p5).
    548 class CXXStdInitializerListExpr : public Expr {
    549   Stmt *SubExpr;
    550 
    551   CXXStdInitializerListExpr(EmptyShell Empty)
    552     : Expr(CXXStdInitializerListExprClass, Empty), SubExpr(nullptr) {}
    553 
    554 public:
    555   CXXStdInitializerListExpr(QualType Ty, Expr *SubExpr)
    556     : Expr(CXXStdInitializerListExprClass, Ty, VK_RValue, OK_Ordinary,
    557            Ty->isDependentType(), SubExpr->isValueDependent(),
    558            SubExpr->isInstantiationDependent(),
    559            SubExpr->containsUnexpandedParameterPack()),
    560       SubExpr(SubExpr) {}
    561 
    562   Expr *getSubExpr() { return static_cast<Expr*>(SubExpr); }
    563   const Expr *getSubExpr() const { return static_cast<const Expr*>(SubExpr); }
    564 
    565   SourceLocation getLocStart() const LLVM_READONLY {
    566     return SubExpr->getLocStart();
    567   }
    568   SourceLocation getLocEnd() const LLVM_READONLY {
    569     return SubExpr->getLocEnd();
    570   }
    571   SourceRange getSourceRange() const LLVM_READONLY {
    572     return SubExpr->getSourceRange();
    573   }
    574 
    575   static bool classof(const Stmt *S) {
    576     return S->getStmtClass() == CXXStdInitializerListExprClass;
    577   }
    578 
    579   child_range children() { return child_range(&SubExpr, &SubExpr + 1); }
    580 
    581   friend class ASTReader;
    582   friend class ASTStmtReader;
    583 };
    584 
    585 /// A C++ \c typeid expression (C++ [expr.typeid]), which gets
    586 /// the \c type_info that corresponds to the supplied type, or the (possibly
    587 /// dynamic) type of the supplied expression.
    588 ///
    589 /// This represents code like \c typeid(int) or \c typeid(*objPtr)
    590 class CXXTypeidExpr : public Expr {
    591 private:
    592   llvm::PointerUnion<Stmt *, TypeSourceInfo *> Operand;
    593   SourceRange Range;
    594 
    595 public:
    596   CXXTypeidExpr(QualType Ty, TypeSourceInfo *Operand, SourceRange R)
    597     : Expr(CXXTypeidExprClass, Ty, VK_LValue, OK_Ordinary,
    598            // typeid is never type-dependent (C++ [temp.dep.expr]p4)
    599            false,
    600            // typeid is value-dependent if the type or expression are dependent
    601            Operand->getType()->isDependentType(),
    602            Operand->getType()->isInstantiationDependentType(),
    603            Operand->getType()->containsUnexpandedParameterPack()),
    604       Operand(Operand), Range(R) { }
    605 
    606   CXXTypeidExpr(QualType Ty, Expr *Operand, SourceRange R)
    607     : Expr(CXXTypeidExprClass, Ty, VK_LValue, OK_Ordinary,
    608         // typeid is never type-dependent (C++ [temp.dep.expr]p4)
    609            false,
    610         // typeid is value-dependent if the type or expression are dependent
    611            Operand->isTypeDependent() || Operand->isValueDependent(),
    612            Operand->isInstantiationDependent(),
    613            Operand->containsUnexpandedParameterPack()),
    614       Operand(Operand), Range(R) { }
    615 
    616   CXXTypeidExpr(EmptyShell Empty, bool isExpr)
    617     : Expr(CXXTypeidExprClass, Empty) {
    618     if (isExpr)
    619       Operand = (Expr*)nullptr;
    620     else
    621       Operand = (TypeSourceInfo*)nullptr;
    622   }
    623 
    624   /// Determine whether this typeid has a type operand which is potentially
    625   /// evaluated, per C++11 [expr.typeid]p3.
    626   bool isPotentiallyEvaluated() const;
    627 
    628   bool isTypeOperand() const { return Operand.is<TypeSourceInfo *>(); }
    629 
    630   /// \brief Retrieves the type operand of this typeid() expression after
    631   /// various required adjustments (removing reference types, cv-qualifiers).
    632   QualType getTypeOperand(ASTContext &Context) const;
    633 
    634   /// \brief Retrieve source information for the type operand.
    635   TypeSourceInfo *getTypeOperandSourceInfo() const {
    636     assert(isTypeOperand() && "Cannot call getTypeOperand for typeid(expr)");
    637     return Operand.get<TypeSourceInfo *>();
    638   }
    639 
    640   void setTypeOperandSourceInfo(TypeSourceInfo *TSI) {
    641     assert(isTypeOperand() && "Cannot call getTypeOperand for typeid(expr)");
    642     Operand = TSI;
    643   }
    644 
    645   Expr *getExprOperand() const {
    646     assert(!isTypeOperand() && "Cannot call getExprOperand for typeid(type)");
    647     return static_cast<Expr*>(Operand.get<Stmt *>());
    648   }
    649 
    650   void setExprOperand(Expr *E) {
    651     assert(!isTypeOperand() && "Cannot call getExprOperand for typeid(type)");
    652     Operand = E;
    653   }
    654 
    655   SourceLocation getLocStart() const LLVM_READONLY { return Range.getBegin(); }
    656   SourceLocation getLocEnd() const LLVM_READONLY { return Range.getEnd(); }
    657   SourceRange getSourceRange() const LLVM_READONLY { return Range; }
    658   void setSourceRange(SourceRange R) { Range = R; }
    659 
    660   static bool classof(const Stmt *T) {
    661     return T->getStmtClass() == CXXTypeidExprClass;
    662   }
    663 
    664   // Iterators
    665   child_range children() {
    666     if (isTypeOperand())
    667       return child_range(child_iterator(), child_iterator());
    668     Stmt **begin = reinterpret_cast<Stmt**>(&Operand);
    669     return child_range(begin, begin + 1);
    670   }
    671 };
    672 
    673 /// \brief A member reference to an MSPropertyDecl.
    674 ///
    675 /// This expression always has pseudo-object type, and therefore it is
    676 /// typically not encountered in a fully-typechecked expression except
    677 /// within the syntactic form of a PseudoObjectExpr.
    678 class MSPropertyRefExpr : public Expr {
    679   Expr *BaseExpr;
    680   MSPropertyDecl *TheDecl;
    681   SourceLocation MemberLoc;
    682   bool IsArrow;
    683   NestedNameSpecifierLoc QualifierLoc;
    684 
    685 public:
    686   MSPropertyRefExpr(Expr *baseExpr, MSPropertyDecl *decl, bool isArrow,
    687                     QualType ty, ExprValueKind VK,
    688                     NestedNameSpecifierLoc qualifierLoc,
    689                     SourceLocation nameLoc)
    690   : Expr(MSPropertyRefExprClass, ty, VK, OK_Ordinary,
    691          /*type-dependent*/ false, baseExpr->isValueDependent(),
    692          baseExpr->isInstantiationDependent(),
    693          baseExpr->containsUnexpandedParameterPack()),
    694     BaseExpr(baseExpr), TheDecl(decl),
    695     MemberLoc(nameLoc), IsArrow(isArrow),
    696     QualifierLoc(qualifierLoc) {}
    697 
    698   MSPropertyRefExpr(EmptyShell Empty) : Expr(MSPropertyRefExprClass, Empty) {}
    699 
    700   SourceRange getSourceRange() const LLVM_READONLY {
    701     return SourceRange(getLocStart(), getLocEnd());
    702   }
    703   bool isImplicitAccess() const {
    704     return getBaseExpr() && getBaseExpr()->isImplicitCXXThis();
    705   }
    706   SourceLocation getLocStart() const {
    707     if (!isImplicitAccess())
    708       return BaseExpr->getLocStart();
    709     else if (QualifierLoc)
    710       return QualifierLoc.getBeginLoc();
    711     else
    712         return MemberLoc;
    713   }
    714   SourceLocation getLocEnd() const { return getMemberLoc(); }
    715 
    716   child_range children() {
    717     return child_range((Stmt**)&BaseExpr, (Stmt**)&BaseExpr + 1);
    718   }
    719   static bool classof(const Stmt *T) {
    720     return T->getStmtClass() == MSPropertyRefExprClass;
    721   }
    722 
    723   Expr *getBaseExpr() const { return BaseExpr; }
    724   MSPropertyDecl *getPropertyDecl() const { return TheDecl; }
    725   bool isArrow() const { return IsArrow; }
    726   SourceLocation getMemberLoc() const { return MemberLoc; }
    727   NestedNameSpecifierLoc getQualifierLoc() const { return QualifierLoc; }
    728 
    729   friend class ASTStmtReader;
    730 };
    731 
    732 /// MS property subscript expression.
    733 /// MSVC supports 'property' attribute and allows to apply it to the
    734 /// declaration of an empty array in a class or structure definition.
    735 /// For example:
    736 /// \code
    737 /// __declspec(property(get=GetX, put=PutX)) int x[];
    738 /// \endcode
    739 /// The above statement indicates that x[] can be used with one or more array
    740 /// indices. In this case, i=p->x[a][b] will be turned into i=p->GetX(a, b), and
    741 /// p->x[a][b] = i will be turned into p->PutX(a, b, i).
    742 /// This is a syntactic pseudo-object expression.
    743 class MSPropertySubscriptExpr : public Expr {
    744   friend class ASTStmtReader;
    745   enum { BASE_EXPR, IDX_EXPR, NUM_SUBEXPRS = 2 };
    746   Stmt *SubExprs[NUM_SUBEXPRS];
    747   SourceLocation RBracketLoc;
    748 
    749   void setBase(Expr *Base) { SubExprs[BASE_EXPR] = Base; }
    750   void setIdx(Expr *Idx) { SubExprs[IDX_EXPR] = Idx; }
    751 
    752 public:
    753   MSPropertySubscriptExpr(Expr *Base, Expr *Idx, QualType Ty, ExprValueKind VK,
    754                           ExprObjectKind OK, SourceLocation RBracketLoc)
    755       : Expr(MSPropertySubscriptExprClass, Ty, VK, OK, Idx->isTypeDependent(),
    756              Idx->isValueDependent(), Idx->isInstantiationDependent(),
    757              Idx->containsUnexpandedParameterPack()),
    758         RBracketLoc(RBracketLoc) {
    759     SubExprs[BASE_EXPR] = Base;
    760     SubExprs[IDX_EXPR] = Idx;
    761   }
    762 
    763   /// \brief Create an empty array subscript expression.
    764   explicit MSPropertySubscriptExpr(EmptyShell Shell)
    765       : Expr(MSPropertySubscriptExprClass, Shell) {}
    766 
    767   Expr *getBase() { return cast<Expr>(SubExprs[BASE_EXPR]); }
    768   const Expr *getBase() const { return cast<Expr>(SubExprs[BASE_EXPR]); }
    769 
    770   Expr *getIdx() { return cast<Expr>(SubExprs[IDX_EXPR]); }
    771   const Expr *getIdx() const { return cast<Expr>(SubExprs[IDX_EXPR]); }
    772 
    773   SourceLocation getLocStart() const LLVM_READONLY {
    774     return getBase()->getLocStart();
    775   }
    776   SourceLocation getLocEnd() const LLVM_READONLY { return RBracketLoc; }
    777 
    778   SourceLocation getRBracketLoc() const { return RBracketLoc; }
    779   void setRBracketLoc(SourceLocation L) { RBracketLoc = L; }
    780 
    781   SourceLocation getExprLoc() const LLVM_READONLY {
    782     return getBase()->getExprLoc();
    783   }
    784 
    785   static bool classof(const Stmt *T) {
    786     return T->getStmtClass() == MSPropertySubscriptExprClass;
    787   }
    788 
    789   // Iterators
    790   child_range children() {
    791     return child_range(&SubExprs[0], &SubExprs[0] + NUM_SUBEXPRS);
    792   }
    793 };
    794 
    795 /// A Microsoft C++ @c __uuidof expression, which gets
    796 /// the _GUID that corresponds to the supplied type or expression.
    797 ///
    798 /// This represents code like @c __uuidof(COMTYPE) or @c __uuidof(*comPtr)
    799 class CXXUuidofExpr : public Expr {
    800 private:
    801   llvm::PointerUnion<Stmt *, TypeSourceInfo *> Operand;
    802   StringRef UuidStr;
    803   SourceRange Range;
    804 
    805 public:
    806   CXXUuidofExpr(QualType Ty, TypeSourceInfo *Operand, StringRef UuidStr,
    807                 SourceRange R)
    808       : Expr(CXXUuidofExprClass, Ty, VK_LValue, OK_Ordinary, false,
    809              Operand->getType()->isDependentType(),
    810              Operand->getType()->isInstantiationDependentType(),
    811              Operand->getType()->containsUnexpandedParameterPack()),
    812         Operand(Operand), UuidStr(UuidStr), Range(R) {}
    813 
    814   CXXUuidofExpr(QualType Ty, Expr *Operand, StringRef UuidStr, SourceRange R)
    815       : Expr(CXXUuidofExprClass, Ty, VK_LValue, OK_Ordinary, false,
    816              Operand->isTypeDependent(), Operand->isInstantiationDependent(),
    817              Operand->containsUnexpandedParameterPack()),
    818         Operand(Operand), UuidStr(UuidStr), Range(R) {}
    819 
    820   CXXUuidofExpr(EmptyShell Empty, bool isExpr)
    821     : Expr(CXXUuidofExprClass, Empty) {
    822     if (isExpr)
    823       Operand = (Expr*)nullptr;
    824     else
    825       Operand = (TypeSourceInfo*)nullptr;
    826   }
    827 
    828   bool isTypeOperand() const { return Operand.is<TypeSourceInfo *>(); }
    829 
    830   /// \brief Retrieves the type operand of this __uuidof() expression after
    831   /// various required adjustments (removing reference types, cv-qualifiers).
    832   QualType getTypeOperand(ASTContext &Context) const;
    833 
    834   /// \brief Retrieve source information for the type operand.
    835   TypeSourceInfo *getTypeOperandSourceInfo() const {
    836     assert(isTypeOperand() && "Cannot call getTypeOperand for __uuidof(expr)");
    837     return Operand.get<TypeSourceInfo *>();
    838   }
    839 
    840   void setTypeOperandSourceInfo(TypeSourceInfo *TSI) {
    841     assert(isTypeOperand() && "Cannot call getTypeOperand for __uuidof(expr)");
    842     Operand = TSI;
    843   }
    844 
    845   Expr *getExprOperand() const {
    846     assert(!isTypeOperand() && "Cannot call getExprOperand for __uuidof(type)");
    847     return static_cast<Expr*>(Operand.get<Stmt *>());
    848   }
    849 
    850   void setExprOperand(Expr *E) {
    851     assert(!isTypeOperand() && "Cannot call getExprOperand for __uuidof(type)");
    852     Operand = E;
    853   }
    854 
    855   void setUuidStr(StringRef US) { UuidStr = US; }
    856   StringRef getUuidStr() const { return UuidStr; }
    857 
    858   SourceLocation getLocStart() const LLVM_READONLY { return Range.getBegin(); }
    859   SourceLocation getLocEnd() const LLVM_READONLY { return Range.getEnd(); }
    860   SourceRange getSourceRange() const LLVM_READONLY { return Range; }
    861   void setSourceRange(SourceRange R) { Range = R; }
    862 
    863   static bool classof(const Stmt *T) {
    864     return T->getStmtClass() == CXXUuidofExprClass;
    865   }
    866 
    867   // Iterators
    868   child_range children() {
    869     if (isTypeOperand())
    870       return child_range(child_iterator(), child_iterator());
    871     Stmt **begin = reinterpret_cast<Stmt**>(&Operand);
    872     return child_range(begin, begin + 1);
    873   }
    874 };
    875 
    876 /// \brief Represents the \c this expression in C++.
    877 ///
    878 /// This is a pointer to the object on which the current member function is
    879 /// executing (C++ [expr.prim]p3). Example:
    880 ///
    881 /// \code
    882 /// class Foo {
    883 /// public:
    884 ///   void bar();
    885 ///   void test() { this->bar(); }
    886 /// };
    887 /// \endcode
    888 class CXXThisExpr : public Expr {
    889   SourceLocation Loc;
    890   bool Implicit : 1;
    891 
    892 public:
    893   CXXThisExpr(SourceLocation L, QualType Type, bool isImplicit)
    894     : Expr(CXXThisExprClass, Type, VK_RValue, OK_Ordinary,
    895            // 'this' is type-dependent if the class type of the enclosing
    896            // member function is dependent (C++ [temp.dep.expr]p2)
    897            Type->isDependentType(), Type->isDependentType(),
    898            Type->isInstantiationDependentType(),
    899            /*ContainsUnexpandedParameterPack=*/false),
    900       Loc(L), Implicit(isImplicit) { }
    901 
    902   CXXThisExpr(EmptyShell Empty) : Expr(CXXThisExprClass, Empty) {}
    903 
    904   SourceLocation getLocation() const { return Loc; }
    905   void setLocation(SourceLocation L) { Loc = L; }
    906 
    907   SourceLocation getLocStart() const LLVM_READONLY { return Loc; }
    908   SourceLocation getLocEnd() const LLVM_READONLY { return Loc; }
    909 
    910   bool isImplicit() const { return Implicit; }
    911   void setImplicit(bool I) { Implicit = I; }
    912 
    913   static bool classof(const Stmt *T) {
    914     return T->getStmtClass() == CXXThisExprClass;
    915   }
    916 
    917   // Iterators
    918   child_range children() {
    919     return child_range(child_iterator(), child_iterator());
    920   }
    921 };
    922 
    923 /// \brief A C++ throw-expression (C++ [except.throw]).
    924 ///
    925 /// This handles 'throw' (for re-throwing the current exception) and
    926 /// 'throw' assignment-expression.  When assignment-expression isn't
    927 /// present, Op will be null.
    928 class CXXThrowExpr : public Expr {
    929   Stmt *Op;
    930   SourceLocation ThrowLoc;
    931   /// \brief Whether the thrown variable (if any) is in scope.
    932   unsigned IsThrownVariableInScope : 1;
    933 
    934   friend class ASTStmtReader;
    935 
    936 public:
    937   // \p Ty is the void type which is used as the result type of the
    938   // expression.  The \p l is the location of the throw keyword.  \p expr
    939   // can by null, if the optional expression to throw isn't present.
    940   CXXThrowExpr(Expr *expr, QualType Ty, SourceLocation l,
    941                bool IsThrownVariableInScope) :
    942     Expr(CXXThrowExprClass, Ty, VK_RValue, OK_Ordinary, false, false,
    943          expr && expr->isInstantiationDependent(),
    944          expr && expr->containsUnexpandedParameterPack()),
    945     Op(expr), ThrowLoc(l), IsThrownVariableInScope(IsThrownVariableInScope) {}
    946   CXXThrowExpr(EmptyShell Empty) : Expr(CXXThrowExprClass, Empty) {}
    947 
    948   const Expr *getSubExpr() const { return cast_or_null<Expr>(Op); }
    949   Expr *getSubExpr() { return cast_or_null<Expr>(Op); }
    950 
    951   SourceLocation getThrowLoc() const { return ThrowLoc; }
    952 
    953   /// \brief Determines whether the variable thrown by this expression (if any!)
    954   /// is within the innermost try block.
    955   ///
    956   /// This information is required to determine whether the NRVO can apply to
    957   /// this variable.
    958   bool isThrownVariableInScope() const { return IsThrownVariableInScope; }
    959 
    960   SourceLocation getLocStart() const LLVM_READONLY { return ThrowLoc; }
    961   SourceLocation getLocEnd() const LLVM_READONLY {
    962     if (!getSubExpr())
    963       return ThrowLoc;
    964     return getSubExpr()->getLocEnd();
    965   }
    966 
    967   static bool classof(const Stmt *T) {
    968     return T->getStmtClass() == CXXThrowExprClass;
    969   }
    970 
    971   // Iterators
    972   child_range children() {
    973     return child_range(&Op, Op ? &Op+1 : &Op);
    974   }
    975 };
    976 
    977 /// \brief A default argument (C++ [dcl.fct.default]).
    978 ///
    979 /// This wraps up a function call argument that was created from the
    980 /// corresponding parameter's default argument, when the call did not
    981 /// explicitly supply arguments for all of the parameters.
    982 class CXXDefaultArgExpr final : public Expr {
    983   /// \brief The parameter whose default is being used.
    984   ParmVarDecl *Param;
    985 
    986   /// \brief The location where the default argument expression was used.
    987   SourceLocation Loc;
    988 
    989   CXXDefaultArgExpr(StmtClass SC, SourceLocation Loc, ParmVarDecl *param)
    990     : Expr(SC,
    991            param->hasUnparsedDefaultArg()
    992              ? param->getType().getNonReferenceType()
    993              : param->getDefaultArg()->getType(),
    994            param->getDefaultArg()->getValueKind(),
    995            param->getDefaultArg()->getObjectKind(), false, false, false, false),
    996       Param(param), Loc(Loc) { }
    997 
    998 public:
    999   CXXDefaultArgExpr(EmptyShell Empty) : Expr(CXXDefaultArgExprClass, Empty) {}
   1000 
   1001   // \p Param is the parameter whose default argument is used by this
   1002   // expression.
   1003   static CXXDefaultArgExpr *Create(const ASTContext &C, SourceLocation Loc,
   1004                                    ParmVarDecl *Param) {
   1005     return new (C) CXXDefaultArgExpr(CXXDefaultArgExprClass, Loc, Param);
   1006   }
   1007 
   1008   // Retrieve the parameter that the argument was created from.
   1009   const ParmVarDecl *getParam() const { return Param; }
   1010   ParmVarDecl *getParam() { return Param; }
   1011 
   1012   // Retrieve the actual argument to the function call.
   1013   const Expr *getExpr() const {
   1014     return getParam()->getDefaultArg();
   1015   }
   1016   Expr *getExpr() {
   1017     return getParam()->getDefaultArg();
   1018   }
   1019 
   1020   /// \brief Retrieve the location where this default argument was actually
   1021   /// used.
   1022   SourceLocation getUsedLocation() const { return Loc; }
   1023 
   1024   /// Default argument expressions have no representation in the
   1025   /// source, so they have an empty source range.
   1026   SourceLocation getLocStart() const LLVM_READONLY { return SourceLocation(); }
   1027   SourceLocation getLocEnd() const LLVM_READONLY { return SourceLocation(); }
   1028 
   1029   SourceLocation getExprLoc() const LLVM_READONLY { return Loc; }
   1030 
   1031   static bool classof(const Stmt *T) {
   1032     return T->getStmtClass() == CXXDefaultArgExprClass;
   1033   }
   1034 
   1035   // Iterators
   1036   child_range children() {
   1037     return child_range(child_iterator(), child_iterator());
   1038   }
   1039 
   1040   friend class ASTStmtReader;
   1041   friend class ASTStmtWriter;
   1042 };
   1043 
   1044 /// \brief A use of a default initializer in a constructor or in aggregate
   1045 /// initialization.
   1046 ///
   1047 /// This wraps a use of a C++ default initializer (technically,
   1048 /// a brace-or-equal-initializer for a non-static data member) when it
   1049 /// is implicitly used in a mem-initializer-list in a constructor
   1050 /// (C++11 [class.base.init]p8) or in aggregate initialization
   1051 /// (C++1y [dcl.init.aggr]p7).
   1052 class CXXDefaultInitExpr : public Expr {
   1053   /// \brief The field whose default is being used.
   1054   FieldDecl *Field;
   1055 
   1056   /// \brief The location where the default initializer expression was used.
   1057   SourceLocation Loc;
   1058 
   1059   CXXDefaultInitExpr(const ASTContext &C, SourceLocation Loc, FieldDecl *Field,
   1060                      QualType T);
   1061 
   1062   CXXDefaultInitExpr(EmptyShell Empty) : Expr(CXXDefaultInitExprClass, Empty) {}
   1063 
   1064 public:
   1065   /// \p Field is the non-static data member whose default initializer is used
   1066   /// by this expression.
   1067   static CXXDefaultInitExpr *Create(const ASTContext &C, SourceLocation Loc,
   1068                                     FieldDecl *Field) {
   1069     return new (C) CXXDefaultInitExpr(C, Loc, Field, Field->getType());
   1070   }
   1071 
   1072   /// \brief Get the field whose initializer will be used.
   1073   FieldDecl *getField() { return Field; }
   1074   const FieldDecl *getField() const { return Field; }
   1075 
   1076   /// \brief Get the initialization expression that will be used.
   1077   const Expr *getExpr() const {
   1078     assert(Field->getInClassInitializer() && "initializer hasn't been parsed");
   1079     return Field->getInClassInitializer();
   1080   }
   1081   Expr *getExpr() {
   1082     assert(Field->getInClassInitializer() && "initializer hasn't been parsed");
   1083     return Field->getInClassInitializer();
   1084   }
   1085 
   1086   SourceLocation getLocStart() const LLVM_READONLY { return Loc; }
   1087   SourceLocation getLocEnd() const LLVM_READONLY { return Loc; }
   1088 
   1089   static bool classof(const Stmt *T) {
   1090     return T->getStmtClass() == CXXDefaultInitExprClass;
   1091   }
   1092 
   1093   // Iterators
   1094   child_range children() {
   1095     return child_range(child_iterator(), child_iterator());
   1096   }
   1097 
   1098   friend class ASTReader;
   1099   friend class ASTStmtReader;
   1100 };
   1101 
   1102 /// \brief Represents a C++ temporary.
   1103 class CXXTemporary {
   1104   /// \brief The destructor that needs to be called.
   1105   const CXXDestructorDecl *Destructor;
   1106 
   1107   explicit CXXTemporary(const CXXDestructorDecl *destructor)
   1108     : Destructor(destructor) { }
   1109 
   1110 public:
   1111   static CXXTemporary *Create(const ASTContext &C,
   1112                               const CXXDestructorDecl *Destructor);
   1113 
   1114   const CXXDestructorDecl *getDestructor() const { return Destructor; }
   1115   void setDestructor(const CXXDestructorDecl *Dtor) {
   1116     Destructor = Dtor;
   1117   }
   1118 };
   1119 
   1120 /// \brief Represents binding an expression to a temporary.
   1121 ///
   1122 /// This ensures the destructor is called for the temporary. It should only be
   1123 /// needed for non-POD, non-trivially destructable class types. For example:
   1124 ///
   1125 /// \code
   1126 ///   struct S {
   1127 ///     S() { }  // User defined constructor makes S non-POD.
   1128 ///     ~S() { } // User defined destructor makes it non-trivial.
   1129 ///   };
   1130 ///   void test() {
   1131 ///     const S &s_ref = S(); // Requires a CXXBindTemporaryExpr.
   1132 ///   }
   1133 /// \endcode
   1134 class CXXBindTemporaryExpr : public Expr {
   1135   CXXTemporary *Temp;
   1136 
   1137   Stmt *SubExpr;
   1138 
   1139   CXXBindTemporaryExpr(CXXTemporary *temp, Expr* SubExpr)
   1140    : Expr(CXXBindTemporaryExprClass, SubExpr->getType(),
   1141           VK_RValue, OK_Ordinary, SubExpr->isTypeDependent(),
   1142           SubExpr->isValueDependent(),
   1143           SubExpr->isInstantiationDependent(),
   1144           SubExpr->containsUnexpandedParameterPack()),
   1145      Temp(temp), SubExpr(SubExpr) { }
   1146 
   1147 public:
   1148   CXXBindTemporaryExpr(EmptyShell Empty)
   1149     : Expr(CXXBindTemporaryExprClass, Empty), Temp(nullptr), SubExpr(nullptr) {}
   1150 
   1151   static CXXBindTemporaryExpr *Create(const ASTContext &C, CXXTemporary *Temp,
   1152                                       Expr* SubExpr);
   1153 
   1154   CXXTemporary *getTemporary() { return Temp; }
   1155   const CXXTemporary *getTemporary() const { return Temp; }
   1156   void setTemporary(CXXTemporary *T) { Temp = T; }
   1157 
   1158   const Expr *getSubExpr() const { return cast<Expr>(SubExpr); }
   1159   Expr *getSubExpr() { return cast<Expr>(SubExpr); }
   1160   void setSubExpr(Expr *E) { SubExpr = E; }
   1161 
   1162   SourceLocation getLocStart() const LLVM_READONLY {
   1163     return SubExpr->getLocStart();
   1164   }
   1165   SourceLocation getLocEnd() const LLVM_READONLY { return SubExpr->getLocEnd();}
   1166 
   1167   // Implement isa/cast/dyncast/etc.
   1168   static bool classof(const Stmt *T) {
   1169     return T->getStmtClass() == CXXBindTemporaryExprClass;
   1170   }
   1171 
   1172   // Iterators
   1173   child_range children() { return child_range(&SubExpr, &SubExpr + 1); }
   1174 };
   1175 
   1176 /// \brief Represents a call to a C++ constructor.
   1177 class CXXConstructExpr : public Expr {
   1178 public:
   1179   enum ConstructionKind {
   1180     CK_Complete,
   1181     CK_NonVirtualBase,
   1182     CK_VirtualBase,
   1183     CK_Delegating
   1184   };
   1185 
   1186 private:
   1187   CXXConstructorDecl *Constructor;
   1188 
   1189   SourceLocation Loc;
   1190   SourceRange ParenOrBraceRange;
   1191   unsigned NumArgs : 16;
   1192   unsigned Elidable : 1;
   1193   unsigned HadMultipleCandidates : 1;
   1194   unsigned ListInitialization : 1;
   1195   unsigned StdInitListInitialization : 1;
   1196   unsigned ZeroInitialization : 1;
   1197   unsigned ConstructKind : 2;
   1198   Stmt **Args;
   1199 
   1200   void setConstructor(CXXConstructorDecl *C) { Constructor = C; }
   1201 
   1202 protected:
   1203   CXXConstructExpr(const ASTContext &C, StmtClass SC, QualType T,
   1204                    SourceLocation Loc,
   1205                    CXXConstructorDecl *Ctor,
   1206                    bool Elidable,
   1207                    ArrayRef<Expr *> Args,
   1208                    bool HadMultipleCandidates,
   1209                    bool ListInitialization,
   1210                    bool StdInitListInitialization,
   1211                    bool ZeroInitialization,
   1212                    ConstructionKind ConstructKind,
   1213                    SourceRange ParenOrBraceRange);
   1214 
   1215   /// \brief Construct an empty C++ construction expression.
   1216   CXXConstructExpr(StmtClass SC, EmptyShell Empty)
   1217     : Expr(SC, Empty), Constructor(nullptr), NumArgs(0), Elidable(false),
   1218       HadMultipleCandidates(false), ListInitialization(false),
   1219       ZeroInitialization(false), ConstructKind(0), Args(nullptr)
   1220   { }
   1221 
   1222 public:
   1223   /// \brief Construct an empty C++ construction expression.
   1224   explicit CXXConstructExpr(EmptyShell Empty)
   1225     : CXXConstructExpr(CXXConstructExprClass, Empty) {}
   1226 
   1227   static CXXConstructExpr *Create(const ASTContext &C, QualType T,
   1228                                   SourceLocation Loc,
   1229                                   CXXConstructorDecl *Ctor,
   1230                                   bool Elidable,
   1231                                   ArrayRef<Expr *> Args,
   1232                                   bool HadMultipleCandidates,
   1233                                   bool ListInitialization,
   1234                                   bool StdInitListInitialization,
   1235                                   bool ZeroInitialization,
   1236                                   ConstructionKind ConstructKind,
   1237                                   SourceRange ParenOrBraceRange);
   1238 
   1239   /// \brief Get the constructor that this expression will (ultimately) call.
   1240   CXXConstructorDecl *getConstructor() const { return Constructor; }
   1241 
   1242   SourceLocation getLocation() const { return Loc; }
   1243   void setLocation(SourceLocation Loc) { this->Loc = Loc; }
   1244 
   1245   /// \brief Whether this construction is elidable.
   1246   bool isElidable() const { return Elidable; }
   1247   void setElidable(bool E) { Elidable = E; }
   1248 
   1249   /// \brief Whether the referred constructor was resolved from
   1250   /// an overloaded set having size greater than 1.
   1251   bool hadMultipleCandidates() const { return HadMultipleCandidates; }
   1252   void setHadMultipleCandidates(bool V) { HadMultipleCandidates = V; }
   1253 
   1254   /// \brief Whether this constructor call was written as list-initialization.
   1255   bool isListInitialization() const { return ListInitialization; }
   1256   void setListInitialization(bool V) { ListInitialization = V; }
   1257 
   1258   /// \brief Whether this constructor call was written as list-initialization,
   1259   /// but was interpreted as forming a std::initializer_list<T> from the list
   1260   /// and passing that as a single constructor argument.
   1261   /// See C++11 [over.match.list]p1 bullet 1.
   1262   bool isStdInitListInitialization() const { return StdInitListInitialization; }
   1263   void setStdInitListInitialization(bool V) { StdInitListInitialization = V; }
   1264 
   1265   /// \brief Whether this construction first requires
   1266   /// zero-initialization before the initializer is called.
   1267   bool requiresZeroInitialization() const { return ZeroInitialization; }
   1268   void setRequiresZeroInitialization(bool ZeroInit) {
   1269     ZeroInitialization = ZeroInit;
   1270   }
   1271 
   1272   /// \brief Determine whether this constructor is actually constructing
   1273   /// a base class (rather than a complete object).
   1274   ConstructionKind getConstructionKind() const {
   1275     return (ConstructionKind)ConstructKind;
   1276   }
   1277   void setConstructionKind(ConstructionKind CK) {
   1278     ConstructKind = CK;
   1279   }
   1280 
   1281   typedef ExprIterator arg_iterator;
   1282   typedef ConstExprIterator const_arg_iterator;
   1283   typedef llvm::iterator_range<arg_iterator> arg_range;
   1284   typedef llvm::iterator_range<const_arg_iterator> arg_const_range;
   1285 
   1286   arg_range arguments() { return arg_range(arg_begin(), arg_end()); }
   1287   arg_const_range arguments() const {
   1288     return arg_const_range(arg_begin(), arg_end());
   1289   }
   1290 
   1291   arg_iterator arg_begin() { return Args; }
   1292   arg_iterator arg_end() { return Args + NumArgs; }
   1293   const_arg_iterator arg_begin() const { return Args; }
   1294   const_arg_iterator arg_end() const { return Args + NumArgs; }
   1295 
   1296   Expr **getArgs() { return reinterpret_cast<Expr **>(Args); }
   1297   const Expr *const *getArgs() const {
   1298     return const_cast<CXXConstructExpr *>(this)->getArgs();
   1299   }
   1300   unsigned getNumArgs() const { return NumArgs; }
   1301 
   1302   /// \brief Return the specified argument.
   1303   Expr *getArg(unsigned Arg) {
   1304     assert(Arg < NumArgs && "Arg access out of range!");
   1305     return cast<Expr>(Args[Arg]);
   1306   }
   1307   const Expr *getArg(unsigned Arg) const {
   1308     assert(Arg < NumArgs && "Arg access out of range!");
   1309     return cast<Expr>(Args[Arg]);
   1310   }
   1311 
   1312   /// \brief Set the specified argument.
   1313   void setArg(unsigned Arg, Expr *ArgExpr) {
   1314     assert(Arg < NumArgs && "Arg access out of range!");
   1315     Args[Arg] = ArgExpr;
   1316   }
   1317 
   1318   SourceLocation getLocStart() const LLVM_READONLY;
   1319   SourceLocation getLocEnd() const LLVM_READONLY;
   1320   SourceRange getParenOrBraceRange() const { return ParenOrBraceRange; }
   1321   void setParenOrBraceRange(SourceRange Range) { ParenOrBraceRange = Range; }
   1322 
   1323   static bool classof(const Stmt *T) {
   1324     return T->getStmtClass() == CXXConstructExprClass ||
   1325       T->getStmtClass() == CXXTemporaryObjectExprClass;
   1326   }
   1327 
   1328   // Iterators
   1329   child_range children() {
   1330     return child_range(&Args[0], &Args[0]+NumArgs);
   1331   }
   1332 
   1333   friend class ASTStmtReader;
   1334 };
   1335 
   1336 /// \brief Represents a call to an inherited base class constructor from an
   1337 /// inheriting constructor. This call implicitly forwards the arguments from
   1338 /// the enclosing context (an inheriting constructor) to the specified inherited
   1339 /// base class constructor.
   1340 class CXXInheritedCtorInitExpr : public Expr {
   1341 private:
   1342   CXXConstructorDecl *Constructor;
   1343 
   1344   /// The location of the using declaration.
   1345   SourceLocation Loc;
   1346 
   1347   /// Whether this is the construction of a virtual base.
   1348   unsigned ConstructsVirtualBase : 1;
   1349 
   1350   /// Whether the constructor is inherited from a virtual base class of the
   1351   /// class that we construct.
   1352   unsigned InheritedFromVirtualBase : 1;
   1353 
   1354 public:
   1355   /// \brief Construct a C++ inheriting construction expression.
   1356   CXXInheritedCtorInitExpr(SourceLocation Loc, QualType T,
   1357                            CXXConstructorDecl *Ctor, bool ConstructsVirtualBase,
   1358                            bool InheritedFromVirtualBase)
   1359       : Expr(CXXInheritedCtorInitExprClass, T, VK_RValue, OK_Ordinary, false,
   1360              false, false, false),
   1361         Constructor(Ctor), Loc(Loc),
   1362         ConstructsVirtualBase(ConstructsVirtualBase),
   1363         InheritedFromVirtualBase(InheritedFromVirtualBase) {
   1364     assert(!T->isDependentType());
   1365   }
   1366 
   1367   /// \brief Construct an empty C++ inheriting construction expression.
   1368   explicit CXXInheritedCtorInitExpr(EmptyShell Empty)
   1369       : Expr(CXXInheritedCtorInitExprClass, Empty), Constructor(nullptr),
   1370         ConstructsVirtualBase(false), InheritedFromVirtualBase(false) {}
   1371 
   1372   /// \brief Get the constructor that this expression will call.
   1373   CXXConstructorDecl *getConstructor() const { return Constructor; }
   1374 
   1375   /// \brief Determine whether this constructor is actually constructing
   1376   /// a base class (rather than a complete object).
   1377   bool constructsVBase() const { return ConstructsVirtualBase; }
   1378   CXXConstructExpr::ConstructionKind getConstructionKind() const {
   1379     return ConstructsVirtualBase ? CXXConstructExpr::CK_VirtualBase
   1380                                  : CXXConstructExpr::CK_NonVirtualBase;
   1381   }
   1382 
   1383   /// \brief Determine whether the inherited constructor is inherited from a
   1384   /// virtual base of the object we construct. If so, we are not responsible
   1385   /// for calling the inherited constructor (the complete object constructor
   1386   /// does that), and so we don't need to pass any arguments.
   1387   bool inheritedFromVBase() const { return InheritedFromVirtualBase; }
   1388 
   1389   SourceLocation getLocation() const LLVM_READONLY { return Loc; }
   1390   SourceLocation getLocStart() const LLVM_READONLY { return Loc; }
   1391   SourceLocation getLocEnd() const LLVM_READONLY { return Loc; }
   1392 
   1393   static bool classof(const Stmt *T) {
   1394     return T->getStmtClass() == CXXInheritedCtorInitExprClass;
   1395   }
   1396   child_range children() {
   1397     return child_range(child_iterator(), child_iterator());
   1398   }
   1399 
   1400   friend class ASTStmtReader;
   1401 };
   1402 
   1403 /// \brief Represents an explicit C++ type conversion that uses "functional"
   1404 /// notation (C++ [expr.type.conv]).
   1405 ///
   1406 /// Example:
   1407 /// \code
   1408 ///   x = int(0.5);
   1409 /// \endcode
   1410 class CXXFunctionalCastExpr final
   1411     : public ExplicitCastExpr,
   1412       private llvm::TrailingObjects<CXXFunctionalCastExpr, CXXBaseSpecifier *> {
   1413   SourceLocation LParenLoc;
   1414   SourceLocation RParenLoc;
   1415 
   1416   CXXFunctionalCastExpr(QualType ty, ExprValueKind VK,
   1417                         TypeSourceInfo *writtenTy,
   1418                         CastKind kind, Expr *castExpr, unsigned pathSize,
   1419                         SourceLocation lParenLoc, SourceLocation rParenLoc)
   1420     : ExplicitCastExpr(CXXFunctionalCastExprClass, ty, VK, kind,
   1421                        castExpr, pathSize, writtenTy),
   1422       LParenLoc(lParenLoc), RParenLoc(rParenLoc) {}
   1423 
   1424   explicit CXXFunctionalCastExpr(EmptyShell Shell, unsigned PathSize)
   1425     : ExplicitCastExpr(CXXFunctionalCastExprClass, Shell, PathSize) { }
   1426 
   1427 public:
   1428   static CXXFunctionalCastExpr *Create(const ASTContext &Context, QualType T,
   1429                                        ExprValueKind VK,
   1430                                        TypeSourceInfo *Written,
   1431                                        CastKind Kind, Expr *Op,
   1432                                        const CXXCastPath *Path,
   1433                                        SourceLocation LPLoc,
   1434                                        SourceLocation RPLoc);
   1435   static CXXFunctionalCastExpr *CreateEmpty(const ASTContext &Context,
   1436                                             unsigned PathSize);
   1437 
   1438   SourceLocation getLParenLoc() const { return LParenLoc; }
   1439   void setLParenLoc(SourceLocation L) { LParenLoc = L; }
   1440   SourceLocation getRParenLoc() const { return RParenLoc; }
   1441   void setRParenLoc(SourceLocation L) { RParenLoc = L; }
   1442 
   1443   SourceLocation getLocStart() const LLVM_READONLY;
   1444   SourceLocation getLocEnd() const LLVM_READONLY;
   1445 
   1446   static bool classof(const Stmt *T) {
   1447     return T->getStmtClass() == CXXFunctionalCastExprClass;
   1448   }
   1449 
   1450   friend TrailingObjects;
   1451   friend class CastExpr;
   1452 };
   1453 
   1454 /// @brief Represents a C++ functional cast expression that builds a
   1455 /// temporary object.
   1456 ///
   1457 /// This expression type represents a C++ "functional" cast
   1458 /// (C++[expr.type.conv]) with N != 1 arguments that invokes a
   1459 /// constructor to build a temporary object. With N == 1 arguments the
   1460 /// functional cast expression will be represented by CXXFunctionalCastExpr.
   1461 /// Example:
   1462 /// \code
   1463 /// struct X { X(int, float); }
   1464 ///
   1465 /// X create_X() {
   1466 ///   return X(1, 3.14f); // creates a CXXTemporaryObjectExpr
   1467 /// };
   1468 /// \endcode
   1469 class CXXTemporaryObjectExpr : public CXXConstructExpr {
   1470   TypeSourceInfo *Type;
   1471 
   1472 public:
   1473   CXXTemporaryObjectExpr(const ASTContext &C,
   1474                          CXXConstructorDecl *Cons,
   1475                          QualType Type,
   1476                          TypeSourceInfo *TSI,
   1477                          ArrayRef<Expr *> Args,
   1478                          SourceRange ParenOrBraceRange,
   1479                          bool HadMultipleCandidates,
   1480                          bool ListInitialization,
   1481                          bool StdInitListInitialization,
   1482                          bool ZeroInitialization);
   1483   explicit CXXTemporaryObjectExpr(EmptyShell Empty)
   1484     : CXXConstructExpr(CXXTemporaryObjectExprClass, Empty), Type() { }
   1485 
   1486   TypeSourceInfo *getTypeSourceInfo() const { return Type; }
   1487 
   1488   SourceLocation getLocStart() const LLVM_READONLY;
   1489   SourceLocation getLocEnd() const LLVM_READONLY;
   1490 
   1491   static bool classof(const Stmt *T) {
   1492     return T->getStmtClass() == CXXTemporaryObjectExprClass;
   1493   }
   1494 
   1495   friend class ASTStmtReader;
   1496 };
   1497 
   1498 /// \brief A C++ lambda expression, which produces a function object
   1499 /// (of unspecified type) that can be invoked later.
   1500 ///
   1501 /// Example:
   1502 /// \code
   1503 /// void low_pass_filter(std::vector<double> &values, double cutoff) {
   1504 ///   values.erase(std::remove_if(values.begin(), values.end(),
   1505 ///                               [=](double value) { return value > cutoff; });
   1506 /// }
   1507 /// \endcode
   1508 ///
   1509 /// C++11 lambda expressions can capture local variables, either by copying
   1510 /// the values of those local variables at the time the function
   1511 /// object is constructed (not when it is called!) or by holding a
   1512 /// reference to the local variable. These captures can occur either
   1513 /// implicitly or can be written explicitly between the square
   1514 /// brackets ([...]) that start the lambda expression.
   1515 ///
   1516 /// C++1y introduces a new form of "capture" called an init-capture that
   1517 /// includes an initializing expression (rather than capturing a variable),
   1518 /// and which can never occur implicitly.
   1519 class LambdaExpr final : public Expr,
   1520                          private llvm::TrailingObjects<LambdaExpr, Stmt *> {
   1521   /// \brief The source range that covers the lambda introducer ([...]).
   1522   SourceRange IntroducerRange;
   1523 
   1524   /// \brief The source location of this lambda's capture-default ('=' or '&').
   1525   SourceLocation CaptureDefaultLoc;
   1526 
   1527   /// \brief The number of captures.
   1528   unsigned NumCaptures : 16;
   1529 
   1530   /// \brief The default capture kind, which is a value of type
   1531   /// LambdaCaptureDefault.
   1532   unsigned CaptureDefault : 2;
   1533 
   1534   /// \brief Whether this lambda had an explicit parameter list vs. an
   1535   /// implicit (and empty) parameter list.
   1536   unsigned ExplicitParams : 1;
   1537 
   1538   /// \brief Whether this lambda had the result type explicitly specified.
   1539   unsigned ExplicitResultType : 1;
   1540 
   1541   /// \brief The location of the closing brace ('}') that completes
   1542   /// the lambda.
   1543   ///
   1544   /// The location of the brace is also available by looking up the
   1545   /// function call operator in the lambda class. However, it is
   1546   /// stored here to improve the performance of getSourceRange(), and
   1547   /// to avoid having to deserialize the function call operator from a
   1548   /// module file just to determine the source range.
   1549   SourceLocation ClosingBrace;
   1550 
   1551   /// \brief Construct a lambda expression.
   1552   LambdaExpr(QualType T, SourceRange IntroducerRange,
   1553              LambdaCaptureDefault CaptureDefault,
   1554              SourceLocation CaptureDefaultLoc, ArrayRef<LambdaCapture> Captures,
   1555              bool ExplicitParams, bool ExplicitResultType,
   1556              ArrayRef<Expr *> CaptureInits, SourceLocation ClosingBrace,
   1557              bool ContainsUnexpandedParameterPack);
   1558 
   1559   /// \brief Construct an empty lambda expression.
   1560   LambdaExpr(EmptyShell Empty, unsigned NumCaptures)
   1561     : Expr(LambdaExprClass, Empty),
   1562       NumCaptures(NumCaptures), CaptureDefault(LCD_None), ExplicitParams(false),
   1563       ExplicitResultType(false) {
   1564     getStoredStmts()[NumCaptures] = nullptr;
   1565   }
   1566 
   1567   Stmt **getStoredStmts() { return getTrailingObjects<Stmt *>(); }
   1568 
   1569   Stmt *const *getStoredStmts() const { return getTrailingObjects<Stmt *>(); }
   1570 
   1571 public:
   1572   /// \brief Construct a new lambda expression.
   1573   static LambdaExpr *
   1574   Create(const ASTContext &C, CXXRecordDecl *Class, SourceRange IntroducerRange,
   1575          LambdaCaptureDefault CaptureDefault, SourceLocation CaptureDefaultLoc,
   1576          ArrayRef<LambdaCapture> Captures, bool ExplicitParams,
   1577          bool ExplicitResultType, ArrayRef<Expr *> CaptureInits,
   1578          SourceLocation ClosingBrace, bool ContainsUnexpandedParameterPack);
   1579 
   1580   /// \brief Construct a new lambda expression that will be deserialized from
   1581   /// an external source.
   1582   static LambdaExpr *CreateDeserialized(const ASTContext &C,
   1583                                         unsigned NumCaptures);
   1584 
   1585   /// \brief Determine the default capture kind for this lambda.
   1586   LambdaCaptureDefault getCaptureDefault() const {
   1587     return static_cast<LambdaCaptureDefault>(CaptureDefault);
   1588   }
   1589 
   1590   /// \brief Retrieve the location of this lambda's capture-default, if any.
   1591   SourceLocation getCaptureDefaultLoc() const {
   1592     return CaptureDefaultLoc;
   1593   }
   1594 
   1595   /// \brief Determine whether one of this lambda's captures is an init-capture.
   1596   bool isInitCapture(const LambdaCapture *Capture) const;
   1597 
   1598   /// \brief An iterator that walks over the captures of the lambda,
   1599   /// both implicit and explicit.
   1600   typedef const LambdaCapture *capture_iterator;
   1601 
   1602   /// \brief An iterator over a range of lambda captures.
   1603   typedef llvm::iterator_range<capture_iterator> capture_range;
   1604 
   1605   /// \brief Retrieve this lambda's captures.
   1606   capture_range captures() const;
   1607 
   1608   /// \brief Retrieve an iterator pointing to the first lambda capture.
   1609   capture_iterator capture_begin() const;
   1610 
   1611   /// \brief Retrieve an iterator pointing past the end of the
   1612   /// sequence of lambda captures.
   1613   capture_iterator capture_end() const;
   1614 
   1615   /// \brief Determine the number of captures in this lambda.
   1616   unsigned capture_size() const { return NumCaptures; }
   1617 
   1618   /// \brief Retrieve this lambda's explicit captures.
   1619   capture_range explicit_captures() const;
   1620 
   1621   /// \brief Retrieve an iterator pointing to the first explicit
   1622   /// lambda capture.
   1623   capture_iterator explicit_capture_begin() const;
   1624 
   1625   /// \brief Retrieve an iterator pointing past the end of the sequence of
   1626   /// explicit lambda captures.
   1627   capture_iterator explicit_capture_end() const;
   1628 
   1629   /// \brief Retrieve this lambda's implicit captures.
   1630   capture_range implicit_captures() const;
   1631 
   1632   /// \brief Retrieve an iterator pointing to the first implicit
   1633   /// lambda capture.
   1634   capture_iterator implicit_capture_begin() const;
   1635 
   1636   /// \brief Retrieve an iterator pointing past the end of the sequence of
   1637   /// implicit lambda captures.
   1638   capture_iterator implicit_capture_end() const;
   1639 
   1640   /// \brief Iterator that walks over the capture initialization
   1641   /// arguments.
   1642   typedef Expr **capture_init_iterator;
   1643 
   1644   /// \brief Const iterator that walks over the capture initialization
   1645   /// arguments.
   1646   typedef Expr *const *const_capture_init_iterator;
   1647 
   1648   /// \brief Retrieve the initialization expressions for this lambda's captures.
   1649   llvm::iterator_range<capture_init_iterator> capture_inits() {
   1650     return llvm::make_range(capture_init_begin(), capture_init_end());
   1651   }
   1652 
   1653   /// \brief Retrieve the initialization expressions for this lambda's captures.
   1654   llvm::iterator_range<const_capture_init_iterator> capture_inits() const {
   1655     return llvm::make_range(capture_init_begin(), capture_init_end());
   1656   }
   1657 
   1658   /// \brief Retrieve the first initialization argument for this
   1659   /// lambda expression (which initializes the first capture field).
   1660   capture_init_iterator capture_init_begin() {
   1661     return reinterpret_cast<Expr **>(getStoredStmts());
   1662   }
   1663 
   1664   /// \brief Retrieve the first initialization argument for this
   1665   /// lambda expression (which initializes the first capture field).
   1666   const_capture_init_iterator capture_init_begin() const {
   1667     return reinterpret_cast<Expr *const *>(getStoredStmts());
   1668   }
   1669 
   1670   /// \brief Retrieve the iterator pointing one past the last
   1671   /// initialization argument for this lambda expression.
   1672   capture_init_iterator capture_init_end() {
   1673     return capture_init_begin() + NumCaptures;
   1674   }
   1675 
   1676   /// \brief Retrieve the iterator pointing one past the last
   1677   /// initialization argument for this lambda expression.
   1678   const_capture_init_iterator capture_init_end() const {
   1679     return capture_init_begin() + NumCaptures;
   1680   }
   1681 
   1682   /// \brief Retrieve the source range covering the lambda introducer,
   1683   /// which contains the explicit capture list surrounded by square
   1684   /// brackets ([...]).
   1685   SourceRange getIntroducerRange() const { return IntroducerRange; }
   1686 
   1687   /// \brief Retrieve the class that corresponds to the lambda.
   1688   ///
   1689   /// This is the "closure type" (C++1y [expr.prim.lambda]), and stores the
   1690   /// captures in its fields and provides the various operations permitted
   1691   /// on a lambda (copying, calling).
   1692   CXXRecordDecl *getLambdaClass() const;
   1693 
   1694   /// \brief Retrieve the function call operator associated with this
   1695   /// lambda expression.
   1696   CXXMethodDecl *getCallOperator() const;
   1697 
   1698   /// \brief If this is a generic lambda expression, retrieve the template
   1699   /// parameter list associated with it, or else return null.
   1700   TemplateParameterList *getTemplateParameterList() const;
   1701 
   1702   /// \brief Whether this is a generic lambda.
   1703   bool isGenericLambda() const { return getTemplateParameterList(); }
   1704 
   1705   /// \brief Retrieve the body of the lambda.
   1706   CompoundStmt *getBody() const;
   1707 
   1708   /// \brief Determine whether the lambda is mutable, meaning that any
   1709   /// captures values can be modified.
   1710   bool isMutable() const;
   1711 
   1712   /// \brief Determine whether this lambda has an explicit parameter
   1713   /// list vs. an implicit (empty) parameter list.
   1714   bool hasExplicitParameters() const { return ExplicitParams; }
   1715 
   1716   /// \brief Whether this lambda had its result type explicitly specified.
   1717   bool hasExplicitResultType() const { return ExplicitResultType; }
   1718 
   1719   static bool classof(const Stmt *T) {
   1720     return T->getStmtClass() == LambdaExprClass;
   1721   }
   1722 
   1723   SourceLocation getLocStart() const LLVM_READONLY {
   1724     return IntroducerRange.getBegin();
   1725   }
   1726   SourceLocation getLocEnd() const LLVM_READONLY { return ClosingBrace; }
   1727 
   1728   child_range children() {
   1729     // Includes initialization exprs plus body stmt
   1730     return child_range(getStoredStmts(), getStoredStmts() + NumCaptures + 1);
   1731   }
   1732 
   1733   friend TrailingObjects;
   1734   friend class ASTStmtReader;
   1735   friend class ASTStmtWriter;
   1736 };
   1737 
   1738 /// An expression "T()" which creates a value-initialized rvalue of type
   1739 /// T, which is a non-class type.  See (C++98 [5.2.3p2]).
   1740 class CXXScalarValueInitExpr : public Expr {
   1741   SourceLocation RParenLoc;
   1742   TypeSourceInfo *TypeInfo;
   1743 
   1744   friend class ASTStmtReader;
   1745 
   1746 public:
   1747   /// \brief Create an explicitly-written scalar-value initialization
   1748   /// expression.
   1749   CXXScalarValueInitExpr(QualType Type, TypeSourceInfo *TypeInfo,
   1750                          SourceLocation rParenLoc)
   1751       : Expr(CXXScalarValueInitExprClass, Type, VK_RValue, OK_Ordinary,
   1752              false, false, Type->isInstantiationDependentType(),
   1753              Type->containsUnexpandedParameterPack()),
   1754         RParenLoc(rParenLoc), TypeInfo(TypeInfo) {}
   1755 
   1756   explicit CXXScalarValueInitExpr(EmptyShell Shell)
   1757     : Expr(CXXScalarValueInitExprClass, Shell) { }
   1758 
   1759   TypeSourceInfo *getTypeSourceInfo() const {
   1760     return TypeInfo;
   1761   }
   1762 
   1763   SourceLocation getRParenLoc() const { return RParenLoc; }
   1764 
   1765   SourceLocation getLocStart() const LLVM_READONLY;
   1766   SourceLocation getLocEnd() const LLVM_READONLY { return RParenLoc; }
   1767 
   1768   static bool classof(const Stmt *T) {
   1769     return T->getStmtClass() == CXXScalarValueInitExprClass;
   1770   }
   1771 
   1772   // Iterators
   1773   child_range children() {
   1774     return child_range(child_iterator(), child_iterator());
   1775   }
   1776 };
   1777 
   1778 /// \brief Represents a new-expression for memory allocation and constructor
   1779 /// calls, e.g: "new CXXNewExpr(foo)".
   1780 class CXXNewExpr : public Expr {
   1781   /// Contains an optional array size expression, an optional initialization
   1782   /// expression, and any number of optional placement arguments, in that order.
   1783   Stmt **SubExprs;
   1784   /// \brief Points to the allocation function used.
   1785   FunctionDecl *OperatorNew;
   1786   /// \brief Points to the deallocation function used in case of error. May be
   1787   /// null.
   1788   FunctionDecl *OperatorDelete;
   1789 
   1790   /// \brief The allocated type-source information, as written in the source.
   1791   TypeSourceInfo *AllocatedTypeInfo;
   1792 
   1793   /// \brief If the allocated type was expressed as a parenthesized type-id,
   1794   /// the source range covering the parenthesized type-id.
   1795   SourceRange TypeIdParens;
   1796 
   1797   /// \brief Range of the entire new expression.
   1798   SourceRange Range;
   1799 
   1800   /// \brief Source-range of a paren-delimited initializer.
   1801   SourceRange DirectInitRange;
   1802 
   1803   /// Was the usage ::new, i.e. is the global new to be used?
   1804   unsigned GlobalNew : 1;
   1805   /// Do we allocate an array? If so, the first SubExpr is the size expression.
   1806   unsigned Array : 1;
   1807   /// Should the alignment be passed to the allocation function?
   1808   unsigned PassAlignment : 1;
   1809   /// If this is an array allocation, does the usual deallocation
   1810   /// function for the allocated type want to know the allocated size?
   1811   unsigned UsualArrayDeleteWantsSize : 1;
   1812   /// The number of placement new arguments.
   1813   unsigned NumPlacementArgs : 26;
   1814   /// What kind of initializer do we have? Could be none, parens, or braces.
   1815   /// In storage, we distinguish between "none, and no initializer expr", and
   1816   /// "none, but an implicit initializer expr".
   1817   unsigned StoredInitializationStyle : 2;
   1818 
   1819   friend class ASTStmtReader;
   1820   friend class ASTStmtWriter;
   1821 public:
   1822   enum InitializationStyle {
   1823     NoInit,   ///< New-expression has no initializer as written.
   1824     CallInit, ///< New-expression has a C++98 paren-delimited initializer.
   1825     ListInit  ///< New-expression has a C++11 list-initializer.
   1826   };
   1827 
   1828   CXXNewExpr(const ASTContext &C, bool globalNew, FunctionDecl *operatorNew,
   1829              FunctionDecl *operatorDelete, bool PassAlignment,
   1830              bool usualArrayDeleteWantsSize, ArrayRef<Expr*> placementArgs,
   1831              SourceRange typeIdParens, Expr *arraySize,
   1832              InitializationStyle initializationStyle, Expr *initializer,
   1833              QualType ty, TypeSourceInfo *AllocatedTypeInfo,
   1834              SourceRange Range, SourceRange directInitRange);
   1835   explicit CXXNewExpr(EmptyShell Shell)
   1836     : Expr(CXXNewExprClass, Shell), SubExprs(nullptr) { }
   1837 
   1838   void AllocateArgsArray(const ASTContext &C, bool isArray,
   1839                          unsigned numPlaceArgs, bool hasInitializer);
   1840 
   1841   QualType getAllocatedType() const {
   1842     assert(getType()->isPointerType());
   1843     return getType()->getAs<PointerType>()->getPointeeType();
   1844   }
   1845 
   1846   TypeSourceInfo *getAllocatedTypeSourceInfo() const {
   1847     return AllocatedTypeInfo;
   1848   }
   1849 
   1850   /// \brief True if the allocation result needs to be null-checked.
   1851   ///
   1852   /// C++11 [expr.new]p13:
   1853   ///   If the allocation function returns null, initialization shall
   1854   ///   not be done, the deallocation function shall not be called,
   1855   ///   and the value of the new-expression shall be null.
   1856   ///
   1857   /// C++ DR1748:
   1858   ///   If the allocation function is a reserved placement allocation
   1859   ///   function that returns null, the behavior is undefined.
   1860   ///
   1861   /// An allocation function is not allowed to return null unless it
   1862   /// has a non-throwing exception-specification.  The '03 rule is
   1863   /// identical except that the definition of a non-throwing
   1864   /// exception specification is just "is it throw()?".
   1865   bool shouldNullCheckAllocation(const ASTContext &Ctx) const;
   1866 
   1867   FunctionDecl *getOperatorNew() const { return OperatorNew; }
   1868   void setOperatorNew(FunctionDecl *D) { OperatorNew = D; }
   1869   FunctionDecl *getOperatorDelete() const { return OperatorDelete; }
   1870   void setOperatorDelete(FunctionDecl *D) { OperatorDelete = D; }
   1871 
   1872   bool isArray() const { return Array; }
   1873   Expr *getArraySize() {
   1874     return Array ? cast<Expr>(SubExprs[0]) : nullptr;
   1875   }
   1876   const Expr *getArraySize() const {
   1877     return Array ? cast<Expr>(SubExprs[0]) : nullptr;
   1878   }
   1879 
   1880   unsigned getNumPlacementArgs() const { return NumPlacementArgs; }
   1881   Expr **getPlacementArgs() {
   1882     return reinterpret_cast<Expr **>(SubExprs + Array + hasInitializer());
   1883   }
   1884 
   1885   Expr *getPlacementArg(unsigned i) {
   1886     assert(i < NumPlacementArgs && "Index out of range");
   1887     return getPlacementArgs()[i];
   1888   }
   1889   const Expr *getPlacementArg(unsigned i) const {
   1890     assert(i < NumPlacementArgs && "Index out of range");
   1891     return const_cast<CXXNewExpr*>(this)->getPlacementArg(i);
   1892   }
   1893 
   1894   bool isParenTypeId() const { return TypeIdParens.isValid(); }
   1895   SourceRange getTypeIdParens() const { return TypeIdParens; }
   1896 
   1897   bool isGlobalNew() const { return GlobalNew; }
   1898 
   1899   /// \brief Whether this new-expression has any initializer at all.
   1900   bool hasInitializer() const { return StoredInitializationStyle > 0; }
   1901 
   1902   /// \brief The kind of initializer this new-expression has.
   1903   InitializationStyle getInitializationStyle() const {
   1904     if (StoredInitializationStyle == 0)
   1905       return NoInit;
   1906     return static_cast<InitializationStyle>(StoredInitializationStyle-1);
   1907   }
   1908 
   1909   /// \brief The initializer of this new-expression.
   1910   Expr *getInitializer() {
   1911     return hasInitializer() ? cast<Expr>(SubExprs[Array]) : nullptr;
   1912   }
   1913   const Expr *getInitializer() const {
   1914     return hasInitializer() ? cast<Expr>(SubExprs[Array]) : nullptr;
   1915   }
   1916 
   1917   /// \brief Returns the CXXConstructExpr from this new-expression, or null.
   1918   const CXXConstructExpr *getConstructExpr() const {
   1919     return dyn_cast_or_null<CXXConstructExpr>(getInitializer());
   1920   }
   1921 
   1922   /// Indicates whether the required alignment should be implicitly passed to
   1923   /// the allocation function.
   1924   bool passAlignment() const {
   1925     return PassAlignment;
   1926   }
   1927 
   1928   /// Answers whether the usual array deallocation function for the
   1929   /// allocated type expects the size of the allocation as a
   1930   /// parameter.
   1931   bool doesUsualArrayDeleteWantSize() const {
   1932     return UsualArrayDeleteWantsSize;
   1933   }
   1934 
   1935   typedef ExprIterator arg_iterator;
   1936   typedef ConstExprIterator const_arg_iterator;
   1937 
   1938   llvm::iterator_range<arg_iterator> placement_arguments() {
   1939     return llvm::make_range(placement_arg_begin(), placement_arg_end());
   1940   }
   1941 
   1942   llvm::iterator_range<const_arg_iterator> placement_arguments() const {
   1943     return llvm::make_range(placement_arg_begin(), placement_arg_end());
   1944   }
   1945 
   1946   arg_iterator placement_arg_begin() {
   1947     return SubExprs + Array + hasInitializer();
   1948   }
   1949   arg_iterator placement_arg_end() {
   1950     return SubExprs + Array + hasInitializer() + getNumPlacementArgs();
   1951   }
   1952   const_arg_iterator placement_arg_begin() const {
   1953     return SubExprs + Array + hasInitializer();
   1954   }
   1955   const_arg_iterator placement_arg_end() const {
   1956     return SubExprs + Array + hasInitializer() + getNumPlacementArgs();
   1957   }
   1958 
   1959   typedef Stmt **raw_arg_iterator;
   1960   raw_arg_iterator raw_arg_begin() { return SubExprs; }
   1961   raw_arg_iterator raw_arg_end() {
   1962     return SubExprs + Array + hasInitializer() + getNumPlacementArgs();
   1963   }
   1964   const_arg_iterator raw_arg_begin() const { return SubExprs; }
   1965   const_arg_iterator raw_arg_end() const {
   1966     return SubExprs + Array + hasInitializer() + getNumPlacementArgs();
   1967   }
   1968 
   1969   SourceLocation getStartLoc() const { return Range.getBegin(); }
   1970   SourceLocation getEndLoc() const { return Range.getEnd(); }
   1971 
   1972   SourceRange getDirectInitRange() const { return DirectInitRange; }
   1973 
   1974   SourceRange getSourceRange() const LLVM_READONLY {
   1975     return Range;
   1976   }
   1977   SourceLocation getLocStart() const LLVM_READONLY { return getStartLoc(); }
   1978   SourceLocation getLocEnd() const LLVM_READONLY { return getEndLoc(); }
   1979 
   1980   static bool classof(const Stmt *T) {
   1981     return T->getStmtClass() == CXXNewExprClass;
   1982   }
   1983 
   1984   // Iterators
   1985   child_range children() {
   1986     return child_range(raw_arg_begin(), raw_arg_end());
   1987   }
   1988 };
   1989 
   1990 /// \brief Represents a \c delete expression for memory deallocation and
   1991 /// destructor calls, e.g. "delete[] pArray".
   1992 class CXXDeleteExpr : public Expr {
   1993   /// Points to the operator delete overload that is used. Could be a member.
   1994   FunctionDecl *OperatorDelete;
   1995   /// The pointer expression to be deleted.
   1996   Stmt *Argument;
   1997   /// Location of the expression.
   1998   SourceLocation Loc;
   1999   /// Is this a forced global delete, i.e. "::delete"?
   2000   bool GlobalDelete : 1;
   2001   /// Is this the array form of delete, i.e. "delete[]"?
   2002   bool ArrayForm : 1;
   2003   /// ArrayFormAsWritten can be different from ArrayForm if 'delete' is applied
   2004   /// to pointer-to-array type (ArrayFormAsWritten will be false while ArrayForm
   2005   /// will be true).
   2006   bool ArrayFormAsWritten : 1;
   2007   /// Does the usual deallocation function for the element type require
   2008   /// a size_t argument?
   2009   bool UsualArrayDeleteWantsSize : 1;
   2010 public:
   2011   CXXDeleteExpr(QualType ty, bool globalDelete, bool arrayForm,
   2012                 bool arrayFormAsWritten, bool usualArrayDeleteWantsSize,
   2013                 FunctionDecl *operatorDelete, Expr *arg, SourceLocation loc)
   2014     : Expr(CXXDeleteExprClass, ty, VK_RValue, OK_Ordinary, false, false,
   2015            arg->isInstantiationDependent(),
   2016            arg->containsUnexpandedParameterPack()),
   2017       OperatorDelete(operatorDelete), Argument(arg), Loc(loc),
   2018       GlobalDelete(globalDelete),
   2019       ArrayForm(arrayForm), ArrayFormAsWritten(arrayFormAsWritten),
   2020       UsualArrayDeleteWantsSize(usualArrayDeleteWantsSize) { }
   2021   explicit CXXDeleteExpr(EmptyShell Shell)
   2022     : Expr(CXXDeleteExprClass, Shell), OperatorDelete(nullptr),
   2023       Argument(nullptr) {}
   2024 
   2025   bool isGlobalDelete() const { return GlobalDelete; }
   2026   bool isArrayForm() const { return ArrayForm; }
   2027   bool isArrayFormAsWritten() const { return ArrayFormAsWritten; }
   2028 
   2029   /// Answers whether the usual array deallocation function for the
   2030   /// allocated type expects the size of the allocation as a
   2031   /// parameter.  This can be true even if the actual deallocation
   2032   /// function that we're using doesn't want a size.
   2033   bool doesUsualArrayDeleteWantSize() const {
   2034     return UsualArrayDeleteWantsSize;
   2035   }
   2036 
   2037   FunctionDecl *getOperatorDelete() const { return OperatorDelete; }
   2038 
   2039   Expr *getArgument() { return cast<Expr>(Argument); }
   2040   const Expr *getArgument() const { return cast<Expr>(Argument); }
   2041 
   2042   /// \brief Retrieve the type being destroyed.
   2043   ///
   2044   /// If the type being destroyed is a dependent type which may or may not
   2045   /// be a pointer, return an invalid type.
   2046   QualType getDestroyedType() const;
   2047 
   2048   SourceLocation getLocStart() const LLVM_READONLY { return Loc; }
   2049   SourceLocation getLocEnd() const LLVM_READONLY {return Argument->getLocEnd();}
   2050 
   2051   static bool classof(const Stmt *T) {
   2052     return T->getStmtClass() == CXXDeleteExprClass;
   2053   }
   2054 
   2055   // Iterators
   2056   child_range children() { return child_range(&Argument, &Argument+1); }
   2057 
   2058   friend class ASTStmtReader;
   2059 };
   2060 
   2061 /// \brief Stores the type being destroyed by a pseudo-destructor expression.
   2062 class PseudoDestructorTypeStorage {
   2063   /// \brief Either the type source information or the name of the type, if
   2064   /// it couldn't be resolved due to type-dependence.
   2065   llvm::PointerUnion<TypeSourceInfo *, IdentifierInfo *> Type;
   2066 
   2067   /// \brief The starting source location of the pseudo-destructor type.
   2068   SourceLocation Location;
   2069 
   2070 public:
   2071   PseudoDestructorTypeStorage() { }
   2072 
   2073   PseudoDestructorTypeStorage(IdentifierInfo *II, SourceLocation Loc)
   2074     : Type(II), Location(Loc) { }
   2075 
   2076   PseudoDestructorTypeStorage(TypeSourceInfo *Info);
   2077 
   2078   TypeSourceInfo *getTypeSourceInfo() const {
   2079     return Type.dyn_cast<TypeSourceInfo *>();
   2080   }
   2081 
   2082   IdentifierInfo *getIdentifier() const {
   2083     return Type.dyn_cast<IdentifierInfo *>();
   2084   }
   2085 
   2086   SourceLocation getLocation() const { return Location; }
   2087 };
   2088 
   2089 /// \brief Represents a C++ pseudo-destructor (C++ [expr.pseudo]).
   2090 ///
   2091 /// A pseudo-destructor is an expression that looks like a member access to a
   2092 /// destructor of a scalar type, except that scalar types don't have
   2093 /// destructors. For example:
   2094 ///
   2095 /// \code
   2096 /// typedef int T;
   2097 /// void f(int *p) {
   2098 ///   p->T::~T();
   2099 /// }
   2100 /// \endcode
   2101 ///
   2102 /// Pseudo-destructors typically occur when instantiating templates such as:
   2103 ///
   2104 /// \code
   2105 /// template<typename T>
   2106 /// void destroy(T* ptr) {
   2107 ///   ptr->T::~T();
   2108 /// }
   2109 /// \endcode
   2110 ///
   2111 /// for scalar types. A pseudo-destructor expression has no run-time semantics
   2112 /// beyond evaluating the base expression.
   2113 class CXXPseudoDestructorExpr : public Expr {
   2114   /// \brief The base expression (that is being destroyed).
   2115   Stmt *Base;
   2116 
   2117   /// \brief Whether the operator was an arrow ('->'); otherwise, it was a
   2118   /// period ('.').
   2119   bool IsArrow : 1;
   2120 
   2121   /// \brief The location of the '.' or '->' operator.
   2122   SourceLocation OperatorLoc;
   2123 
   2124   /// \brief The nested-name-specifier that follows the operator, if present.
   2125   NestedNameSpecifierLoc QualifierLoc;
   2126 
   2127   /// \brief The type that precedes the '::' in a qualified pseudo-destructor
   2128   /// expression.
   2129   TypeSourceInfo *ScopeType;
   2130 
   2131   /// \brief The location of the '::' in a qualified pseudo-destructor
   2132   /// expression.
   2133   SourceLocation ColonColonLoc;
   2134 
   2135   /// \brief The location of the '~'.
   2136   SourceLocation TildeLoc;
   2137 
   2138   /// \brief The type being destroyed, or its name if we were unable to
   2139   /// resolve the name.
   2140   PseudoDestructorTypeStorage DestroyedType;
   2141 
   2142   friend class ASTStmtReader;
   2143 
   2144 public:
   2145   CXXPseudoDestructorExpr(const ASTContext &Context,
   2146                           Expr *Base, bool isArrow, SourceLocation OperatorLoc,
   2147                           NestedNameSpecifierLoc QualifierLoc,
   2148                           TypeSourceInfo *ScopeType,
   2149                           SourceLocation ColonColonLoc,
   2150                           SourceLocation TildeLoc,
   2151                           PseudoDestructorTypeStorage DestroyedType);
   2152 
   2153   explicit CXXPseudoDestructorExpr(EmptyShell Shell)
   2154     : Expr(CXXPseudoDestructorExprClass, Shell),
   2155       Base(nullptr), IsArrow(false), QualifierLoc(), ScopeType(nullptr) { }
   2156 
   2157   Expr *getBase() const { return cast<Expr>(Base); }
   2158 
   2159   /// \brief Determines whether this member expression actually had
   2160   /// a C++ nested-name-specifier prior to the name of the member, e.g.,
   2161   /// x->Base::foo.
   2162   bool hasQualifier() const { return QualifierLoc.hasQualifier(); }
   2163 
   2164   /// \brief Retrieves the nested-name-specifier that qualifies the type name,
   2165   /// with source-location information.
   2166   NestedNameSpecifierLoc getQualifierLoc() const { return QualifierLoc; }
   2167 
   2168   /// \brief If the member name was qualified, retrieves the
   2169   /// nested-name-specifier that precedes the member name. Otherwise, returns
   2170   /// null.
   2171   NestedNameSpecifier *getQualifier() const {
   2172     return QualifierLoc.getNestedNameSpecifier();
   2173   }
   2174 
   2175   /// \brief Determine whether this pseudo-destructor expression was written
   2176   /// using an '->' (otherwise, it used a '.').
   2177   bool isArrow() const { return IsArrow; }
   2178 
   2179   /// \brief Retrieve the location of the '.' or '->' operator.
   2180   SourceLocation getOperatorLoc() const { return OperatorLoc; }
   2181 
   2182   /// \brief Retrieve the scope type in a qualified pseudo-destructor
   2183   /// expression.
   2184   ///
   2185   /// Pseudo-destructor expressions can have extra qualification within them
   2186   /// that is not part of the nested-name-specifier, e.g., \c p->T::~T().
   2187   /// Here, if the object type of the expression is (or may be) a scalar type,
   2188   /// \p T may also be a scalar type and, therefore, cannot be part of a
   2189   /// nested-name-specifier. It is stored as the "scope type" of the pseudo-
   2190   /// destructor expression.
   2191   TypeSourceInfo *getScopeTypeInfo() const { return ScopeType; }
   2192 
   2193   /// \brief Retrieve the location of the '::' in a qualified pseudo-destructor
   2194   /// expression.
   2195   SourceLocation getColonColonLoc() const { return ColonColonLoc; }
   2196 
   2197   /// \brief Retrieve the location of the '~'.
   2198   SourceLocation getTildeLoc() const { return TildeLoc; }
   2199 
   2200   /// \brief Retrieve the source location information for the type
   2201   /// being destroyed.
   2202   ///
   2203   /// This type-source information is available for non-dependent
   2204   /// pseudo-destructor expressions and some dependent pseudo-destructor
   2205   /// expressions. Returns null if we only have the identifier for a
   2206   /// dependent pseudo-destructor expression.
   2207   TypeSourceInfo *getDestroyedTypeInfo() const {
   2208     return DestroyedType.getTypeSourceInfo();
   2209   }
   2210 
   2211   /// \brief In a dependent pseudo-destructor expression for which we do not
   2212   /// have full type information on the destroyed type, provides the name
   2213   /// of the destroyed type.
   2214   IdentifierInfo *getDestroyedTypeIdentifier() const {
   2215     return DestroyedType.getIdentifier();
   2216   }
   2217 
   2218   /// \brief Retrieve the type being destroyed.
   2219   QualType getDestroyedType() const;
   2220 
   2221   /// \brief Retrieve the starting location of the type being destroyed.
   2222   SourceLocation getDestroyedTypeLoc() const {
   2223     return DestroyedType.getLocation();
   2224   }
   2225 
   2226   /// \brief Set the name of destroyed type for a dependent pseudo-destructor
   2227   /// expression.
   2228   void setDestroyedType(IdentifierInfo *II, SourceLocation Loc) {
   2229     DestroyedType = PseudoDestructorTypeStorage(II, Loc);
   2230   }
   2231 
   2232   /// \brief Set the destroyed type.
   2233   void setDestroyedType(TypeSourceInfo *Info) {
   2234     DestroyedType = PseudoDestructorTypeStorage(Info);
   2235   }
   2236 
   2237   SourceLocation getLocStart() const LLVM_READONLY {return Base->getLocStart();}
   2238   SourceLocation getLocEnd() const LLVM_READONLY;
   2239 
   2240   static bool classof(const Stmt *T) {
   2241     return T->getStmtClass() == CXXPseudoDestructorExprClass;
   2242   }
   2243 
   2244   // Iterators
   2245   child_range children() { return child_range(&Base, &Base + 1); }
   2246 };
   2247 
   2248 /// \brief A type trait used in the implementation of various C++11 and
   2249 /// Library TR1 trait templates.
   2250 ///
   2251 /// \code
   2252 ///   __is_pod(int) == true
   2253 ///   __is_enum(std::string) == false
   2254 ///   __is_trivially_constructible(vector<int>, int*, int*)
   2255 /// \endcode
   2256 class TypeTraitExpr final
   2257     : public Expr,
   2258       private llvm::TrailingObjects<TypeTraitExpr, TypeSourceInfo *> {
   2259   /// \brief The location of the type trait keyword.
   2260   SourceLocation Loc;
   2261 
   2262   /// \brief  The location of the closing parenthesis.
   2263   SourceLocation RParenLoc;
   2264 
   2265   // Note: The TypeSourceInfos for the arguments are allocated after the
   2266   // TypeTraitExpr.
   2267 
   2268   TypeTraitExpr(QualType T, SourceLocation Loc, TypeTrait Kind,
   2269                 ArrayRef<TypeSourceInfo *> Args,
   2270                 SourceLocation RParenLoc,
   2271                 bool Value);
   2272 
   2273   TypeTraitExpr(EmptyShell Empty) : Expr(TypeTraitExprClass, Empty) { }
   2274 
   2275   size_t numTrailingObjects(OverloadToken<TypeSourceInfo *>) const {
   2276     return getNumArgs();
   2277   }
   2278 
   2279 public:
   2280   /// \brief Create a new type trait expression.
   2281   static TypeTraitExpr *Create(const ASTContext &C, QualType T,
   2282                                SourceLocation Loc, TypeTrait Kind,
   2283                                ArrayRef<TypeSourceInfo *> Args,
   2284                                SourceLocation RParenLoc,
   2285                                bool Value);
   2286 
   2287   static TypeTraitExpr *CreateDeserialized(const ASTContext &C,
   2288                                            unsigned NumArgs);
   2289 
   2290   /// \brief Determine which type trait this expression uses.
   2291   TypeTrait getTrait() const {
   2292     return static_cast<TypeTrait>(TypeTraitExprBits.Kind);
   2293   }
   2294 
   2295   bool getValue() const {
   2296     assert(!isValueDependent());
   2297     return TypeTraitExprBits.Value;
   2298   }
   2299 
   2300   /// \brief Determine the number of arguments to this type trait.
   2301   unsigned getNumArgs() const { return TypeTraitExprBits.NumArgs; }
   2302 
   2303   /// \brief Retrieve the Ith argument.
   2304   TypeSourceInfo *getArg(unsigned I) const {
   2305     assert(I < getNumArgs() && "Argument out-of-range");
   2306     return getArgs()[I];
   2307   }
   2308 
   2309   /// \brief Retrieve the argument types.
   2310   ArrayRef<TypeSourceInfo *> getArgs() const {
   2311     return llvm::makeArrayRef(getTrailingObjects<TypeSourceInfo *>(),
   2312                               getNumArgs());
   2313   }
   2314 
   2315   SourceLocation getLocStart() const LLVM_READONLY { return Loc; }
   2316   SourceLocation getLocEnd() const LLVM_READONLY { return RParenLoc; }
   2317 
   2318   static bool classof(const Stmt *T) {
   2319     return T->getStmtClass() == TypeTraitExprClass;
   2320   }
   2321 
   2322   // Iterators
   2323   child_range children() {
   2324     return child_range(child_iterator(), child_iterator());
   2325   }
   2326 
   2327   friend TrailingObjects;
   2328   friend class ASTStmtReader;
   2329   friend class ASTStmtWriter;
   2330 };
   2331 
   2332 /// \brief An Embarcadero array type trait, as used in the implementation of
   2333 /// __array_rank and __array_extent.
   2334 ///
   2335 /// Example:
   2336 /// \code
   2337 ///   __array_rank(int[10][20]) == 2
   2338 ///   __array_extent(int, 1)    == 20
   2339 /// \endcode
   2340 class ArrayTypeTraitExpr : public Expr {
   2341   virtual void anchor();
   2342 
   2343   /// \brief The trait. An ArrayTypeTrait enum in MSVC compat unsigned.
   2344   unsigned ATT : 2;
   2345 
   2346   /// \brief The value of the type trait. Unspecified if dependent.
   2347   uint64_t Value;
   2348 
   2349   /// \brief The array dimension being queried, or -1 if not used.
   2350   Expr *Dimension;
   2351 
   2352   /// \brief The location of the type trait keyword.
   2353   SourceLocation Loc;
   2354 
   2355   /// \brief The location of the closing paren.
   2356   SourceLocation RParen;
   2357 
   2358   /// \brief The type being queried.
   2359   TypeSourceInfo *QueriedType;
   2360 
   2361 public:
   2362   ArrayTypeTraitExpr(SourceLocation loc, ArrayTypeTrait att,
   2363                      TypeSourceInfo *queried, uint64_t value,
   2364                      Expr *dimension, SourceLocation rparen, QualType ty)
   2365     : Expr(ArrayTypeTraitExprClass, ty, VK_RValue, OK_Ordinary,
   2366            false, queried->getType()->isDependentType(),
   2367            (queried->getType()->isInstantiationDependentType() ||
   2368             (dimension && dimension->isInstantiationDependent())),
   2369            queried->getType()->containsUnexpandedParameterPack()),
   2370       ATT(att), Value(value), Dimension(dimension),
   2371       Loc(loc), RParen(rparen), QueriedType(queried) { }
   2372 
   2373 
   2374   explicit ArrayTypeTraitExpr(EmptyShell Empty)
   2375     : Expr(ArrayTypeTraitExprClass, Empty), ATT(0), Value(false),
   2376       QueriedType() { }
   2377 
   2378   virtual ~ArrayTypeTraitExpr() { }
   2379 
   2380   SourceLocation getLocStart() const LLVM_READONLY { return Loc; }
   2381   SourceLocation getLocEnd() const LLVM_READONLY { return RParen; }
   2382 
   2383   ArrayTypeTrait getTrait() const { return static_cast<ArrayTypeTrait>(ATT); }
   2384 
   2385   QualType getQueriedType() const { return QueriedType->getType(); }
   2386 
   2387   TypeSourceInfo *getQueriedTypeSourceInfo() const { return QueriedType; }
   2388 
   2389   uint64_t getValue() const { assert(!isTypeDependent()); return Value; }
   2390 
   2391   Expr *getDimensionExpression() const { return Dimension; }
   2392 
   2393   static bool classof(const Stmt *T) {
   2394     return T->getStmtClass() == ArrayTypeTraitExprClass;
   2395   }
   2396 
   2397   // Iterators
   2398   child_range children() {
   2399     return child_range(child_iterator(), child_iterator());
   2400   }
   2401 
   2402   friend class ASTStmtReader;
   2403 };
   2404 
   2405 /// \brief An expression trait intrinsic.
   2406 ///
   2407 /// Example:
   2408 /// \code
   2409 ///   __is_lvalue_expr(std::cout) == true
   2410 ///   __is_lvalue_expr(1) == false
   2411 /// \endcode
   2412 class ExpressionTraitExpr : public Expr {
   2413   /// \brief The trait. A ExpressionTrait enum in MSVC compatible unsigned.
   2414   unsigned ET : 31;
   2415   /// \brief The value of the type trait. Unspecified if dependent.
   2416   unsigned Value : 1;
   2417 
   2418   /// \brief The location of the type trait keyword.
   2419   SourceLocation Loc;
   2420 
   2421   /// \brief The location of the closing paren.
   2422   SourceLocation RParen;
   2423 
   2424   /// \brief The expression being queried.
   2425   Expr* QueriedExpression;
   2426 public:
   2427   ExpressionTraitExpr(SourceLocation loc, ExpressionTrait et,
   2428                      Expr *queried, bool value,
   2429                      SourceLocation rparen, QualType resultType)
   2430     : Expr(ExpressionTraitExprClass, resultType, VK_RValue, OK_Ordinary,
   2431            false, // Not type-dependent
   2432            // Value-dependent if the argument is type-dependent.
   2433            queried->isTypeDependent(),
   2434            queried->isInstantiationDependent(),
   2435            queried->containsUnexpandedParameterPack()),
   2436       ET(et), Value(value), Loc(loc), RParen(rparen),
   2437       QueriedExpression(queried) { }
   2438 
   2439   explicit ExpressionTraitExpr(EmptyShell Empty)
   2440     : Expr(ExpressionTraitExprClass, Empty), ET(0), Value(false),
   2441       QueriedExpression() { }
   2442 
   2443   SourceLocation getLocStart() const LLVM_READONLY { return Loc; }
   2444   SourceLocation getLocEnd() const LLVM_READONLY { return RParen; }
   2445 
   2446   ExpressionTrait getTrait() const { return static_cast<ExpressionTrait>(ET); }
   2447 
   2448   Expr *getQueriedExpression() const { return QueriedExpression; }
   2449 
   2450   bool getValue() const { return Value; }
   2451 
   2452   static bool classof(const Stmt *T) {
   2453     return T->getStmtClass() == ExpressionTraitExprClass;
   2454   }
   2455 
   2456   // Iterators
   2457   child_range children() {
   2458     return child_range(child_iterator(), child_iterator());
   2459   }
   2460 
   2461   friend class ASTStmtReader;
   2462 };
   2463 
   2464 
   2465 /// \brief A reference to an overloaded function set, either an
   2466 /// \c UnresolvedLookupExpr or an \c UnresolvedMemberExpr.
   2467 class OverloadExpr : public Expr {
   2468   /// \brief The common name of these declarations.
   2469   DeclarationNameInfo NameInfo;
   2470 
   2471   /// \brief The nested-name-specifier that qualifies the name, if any.
   2472   NestedNameSpecifierLoc QualifierLoc;
   2473 
   2474   /// The results.  These are undesugared, which is to say, they may
   2475   /// include UsingShadowDecls.  Access is relative to the naming
   2476   /// class.
   2477   // FIXME: Allocate this data after the OverloadExpr subclass.
   2478   DeclAccessPair *Results;
   2479   unsigned NumResults;
   2480 
   2481 protected:
   2482   /// \brief Whether the name includes info for explicit template
   2483   /// keyword and arguments.
   2484   bool HasTemplateKWAndArgsInfo;
   2485 
   2486   /// \brief Return the optional template keyword and arguments info.
   2487   ASTTemplateKWAndArgsInfo *
   2488   getTrailingASTTemplateKWAndArgsInfo(); // defined far below.
   2489 
   2490   /// \brief Return the optional template keyword and arguments info.
   2491   const ASTTemplateKWAndArgsInfo *getTrailingASTTemplateKWAndArgsInfo() const {
   2492     return const_cast<OverloadExpr *>(this)
   2493         ->getTrailingASTTemplateKWAndArgsInfo();
   2494   }
   2495 
   2496   /// Return the optional template arguments.
   2497   TemplateArgumentLoc *getTrailingTemplateArgumentLoc(); // defined far below
   2498 
   2499   OverloadExpr(StmtClass K, const ASTContext &C,
   2500                NestedNameSpecifierLoc QualifierLoc,
   2501                SourceLocation TemplateKWLoc,
   2502                const DeclarationNameInfo &NameInfo,
   2503                const TemplateArgumentListInfo *TemplateArgs,
   2504                UnresolvedSetIterator Begin, UnresolvedSetIterator End,
   2505                bool KnownDependent,
   2506                bool KnownInstantiationDependent,
   2507                bool KnownContainsUnexpandedParameterPack);
   2508 
   2509   OverloadExpr(StmtClass K, EmptyShell Empty)
   2510     : Expr(K, Empty), QualifierLoc(), Results(nullptr), NumResults(0),
   2511       HasTemplateKWAndArgsInfo(false) { }
   2512 
   2513   void initializeResults(const ASTContext &C,
   2514                          UnresolvedSetIterator Begin,
   2515                          UnresolvedSetIterator End);
   2516 
   2517 public:
   2518   struct FindResult {
   2519     OverloadExpr *Expression;
   2520     bool IsAddressOfOperand;
   2521     bool HasFormOfMemberPointer;
   2522   };
   2523 
   2524   /// \brief Finds the overloaded expression in the given expression \p E of
   2525   /// OverloadTy.
   2526   ///
   2527   /// \return the expression (which must be there) and true if it has
   2528   /// the particular form of a member pointer expression
   2529   static FindResult find(Expr *E) {
   2530     assert(E->getType()->isSpecificBuiltinType(BuiltinType::Overload));
   2531 
   2532     FindResult Result;
   2533 
   2534     E = E->IgnoreParens();
   2535     if (isa<UnaryOperator>(E)) {
   2536       assert(cast<UnaryOperator>(E)->getOpcode() == UO_AddrOf);
   2537       E = cast<UnaryOperator>(E)->getSubExpr();
   2538       OverloadExpr *Ovl = cast<OverloadExpr>(E->IgnoreParens());
   2539 
   2540       Result.HasFormOfMemberPointer = (E == Ovl && Ovl->getQualifier());
   2541       Result.IsAddressOfOperand = true;
   2542       Result.Expression = Ovl;
   2543     } else {
   2544       Result.HasFormOfMemberPointer = false;
   2545       Result.IsAddressOfOperand = false;
   2546       Result.Expression = cast<OverloadExpr>(E);
   2547     }
   2548 
   2549     return Result;
   2550   }
   2551 
   2552   /// \brief Gets the naming class of this lookup, if any.
   2553   CXXRecordDecl *getNamingClass() const;
   2554 
   2555   typedef UnresolvedSetImpl::iterator decls_iterator;
   2556   decls_iterator decls_begin() const { return UnresolvedSetIterator(Results); }
   2557   decls_iterator decls_end() const {
   2558     return UnresolvedSetIterator(Results + NumResults);
   2559   }
   2560   llvm::iterator_range<decls_iterator> decls() const {
   2561     return llvm::make_range(decls_begin(), decls_end());
   2562   }
   2563 
   2564   /// \brief Gets the number of declarations in the unresolved set.
   2565   unsigned getNumDecls() const { return NumResults; }
   2566 
   2567   /// \brief Gets the full name info.
   2568   const DeclarationNameInfo &getNameInfo() const { return NameInfo; }
   2569 
   2570   /// \brief Gets the name looked up.
   2571   DeclarationName getName() const { return NameInfo.getName(); }
   2572 
   2573   /// \brief Gets the location of the name.
   2574   SourceLocation getNameLoc() const { return NameInfo.getLoc(); }
   2575 
   2576   /// \brief Fetches the nested-name qualifier, if one was given.
   2577   NestedNameSpecifier *getQualifier() const {
   2578     return QualifierLoc.getNestedNameSpecifier();
   2579   }
   2580 
   2581   /// \brief Fetches the nested-name qualifier with source-location
   2582   /// information, if one was given.
   2583   NestedNameSpecifierLoc getQualifierLoc() const { return QualifierLoc; }
   2584 
   2585   /// \brief Retrieve the location of the template keyword preceding
   2586   /// this name, if any.
   2587   SourceLocation getTemplateKeywordLoc() const {
   2588     if (!HasTemplateKWAndArgsInfo) return SourceLocation();
   2589     return getTrailingASTTemplateKWAndArgsInfo()->TemplateKWLoc;
   2590   }
   2591 
   2592   /// \brief Retrieve the location of the left angle bracket starting the
   2593   /// explicit template argument list following the name, if any.
   2594   SourceLocation getLAngleLoc() const {
   2595     if (!HasTemplateKWAndArgsInfo) return SourceLocation();
   2596     return getTrailingASTTemplateKWAndArgsInfo()->LAngleLoc;
   2597   }
   2598 
   2599   /// \brief Retrieve the location of the right angle bracket ending the
   2600   /// explicit template argument list following the name, if any.
   2601   SourceLocation getRAngleLoc() const {
   2602     if (!HasTemplateKWAndArgsInfo) return SourceLocation();
   2603     return getTrailingASTTemplateKWAndArgsInfo()->RAngleLoc;
   2604   }
   2605 
   2606   /// \brief Determines whether the name was preceded by the template keyword.
   2607   bool hasTemplateKeyword() const { return getTemplateKeywordLoc().isValid(); }
   2608 
   2609   /// \brief Determines whether this expression had explicit template arguments.
   2610   bool hasExplicitTemplateArgs() const { return getLAngleLoc().isValid(); }
   2611 
   2612   TemplateArgumentLoc const *getTemplateArgs() const {
   2613     if (!hasExplicitTemplateArgs())
   2614       return nullptr;
   2615     return const_cast<OverloadExpr *>(this)->getTrailingTemplateArgumentLoc();
   2616   }
   2617 
   2618   unsigned getNumTemplateArgs() const {
   2619     if (!hasExplicitTemplateArgs())
   2620       return 0;
   2621 
   2622     return getTrailingASTTemplateKWAndArgsInfo()->NumTemplateArgs;
   2623   }
   2624 
   2625   ArrayRef<TemplateArgumentLoc> template_arguments() const {
   2626     return {getTemplateArgs(), getNumTemplateArgs()};
   2627   }
   2628 
   2629   /// \brief Copies the template arguments into the given structure.
   2630   void copyTemplateArgumentsInto(TemplateArgumentListInfo &List) const {
   2631     if (hasExplicitTemplateArgs())
   2632       getTrailingASTTemplateKWAndArgsInfo()->copyInto(getTemplateArgs(), List);
   2633   }
   2634 
   2635   static bool classof(const Stmt *T) {
   2636     return T->getStmtClass() == UnresolvedLookupExprClass ||
   2637            T->getStmtClass() == UnresolvedMemberExprClass;
   2638   }
   2639 
   2640   friend class ASTStmtReader;
   2641   friend class ASTStmtWriter;
   2642 };
   2643 
   2644 /// \brief A reference to a name which we were able to look up during
   2645 /// parsing but could not resolve to a specific declaration.
   2646 ///
   2647 /// This arises in several ways:
   2648 ///   * we might be waiting for argument-dependent lookup;
   2649 ///   * the name might resolve to an overloaded function;
   2650 /// and eventually:
   2651 ///   * the lookup might have included a function template.
   2652 ///
   2653 /// These never include UnresolvedUsingValueDecls, which are always class
   2654 /// members and therefore appear only in UnresolvedMemberLookupExprs.
   2655 class UnresolvedLookupExpr final
   2656     : public OverloadExpr,
   2657       private llvm::TrailingObjects<
   2658           UnresolvedLookupExpr, ASTTemplateKWAndArgsInfo, TemplateArgumentLoc> {
   2659   /// True if these lookup results should be extended by
   2660   /// argument-dependent lookup if this is the operand of a function
   2661   /// call.
   2662   bool RequiresADL;
   2663 
   2664   /// True if these lookup results are overloaded.  This is pretty
   2665   /// trivially rederivable if we urgently need to kill this field.
   2666   bool Overloaded;
   2667 
   2668   /// The naming class (C++ [class.access.base]p5) of the lookup, if
   2669   /// any.  This can generally be recalculated from the context chain,
   2670   /// but that can be fairly expensive for unqualified lookups.  If we
   2671   /// want to improve memory use here, this could go in a union
   2672   /// against the qualified-lookup bits.
   2673   CXXRecordDecl *NamingClass;
   2674 
   2675   size_t numTrailingObjects(OverloadToken<ASTTemplateKWAndArgsInfo>) const {
   2676     return HasTemplateKWAndArgsInfo ? 1 : 0;
   2677   }
   2678 
   2679   UnresolvedLookupExpr(const ASTContext &C,
   2680                        CXXRecordDecl *NamingClass,
   2681                        NestedNameSpecifierLoc QualifierLoc,
   2682                        SourceLocation TemplateKWLoc,
   2683                        const DeclarationNameInfo &NameInfo,
   2684                        bool RequiresADL, bool Overloaded,
   2685                        const TemplateArgumentListInfo *TemplateArgs,
   2686                        UnresolvedSetIterator Begin, UnresolvedSetIterator End)
   2687     : OverloadExpr(UnresolvedLookupExprClass, C, QualifierLoc, TemplateKWLoc,
   2688                    NameInfo, TemplateArgs, Begin, End, false, false, false),
   2689       RequiresADL(RequiresADL),
   2690       Overloaded(Overloaded), NamingClass(NamingClass)
   2691   {}
   2692 
   2693   UnresolvedLookupExpr(EmptyShell Empty)
   2694     : OverloadExpr(UnresolvedLookupExprClass, Empty),
   2695       RequiresADL(false), Overloaded(false), NamingClass(nullptr)
   2696   {}
   2697 
   2698   friend TrailingObjects;
   2699   friend class OverloadExpr;
   2700   friend class ASTStmtReader;
   2701 
   2702 public:
   2703   static UnresolvedLookupExpr *Create(const ASTContext &C,
   2704                                       CXXRecordDecl *NamingClass,
   2705                                       NestedNameSpecifierLoc QualifierLoc,
   2706                                       const DeclarationNameInfo &NameInfo,
   2707                                       bool ADL, bool Overloaded,
   2708                                       UnresolvedSetIterator Begin,
   2709                                       UnresolvedSetIterator End) {
   2710     return new(C) UnresolvedLookupExpr(C, NamingClass, QualifierLoc,
   2711                                        SourceLocation(), NameInfo,
   2712                                        ADL, Overloaded, nullptr, Begin, End);
   2713   }
   2714 
   2715   static UnresolvedLookupExpr *Create(const ASTContext &C,
   2716                                       CXXRecordDecl *NamingClass,
   2717                                       NestedNameSpecifierLoc QualifierLoc,
   2718                                       SourceLocation TemplateKWLoc,
   2719                                       const DeclarationNameInfo &NameInfo,
   2720                                       bool ADL,
   2721                                       const TemplateArgumentListInfo *Args,
   2722                                       UnresolvedSetIterator Begin,
   2723                                       UnresolvedSetIterator End);
   2724 
   2725   static UnresolvedLookupExpr *CreateEmpty(const ASTContext &C,
   2726                                            bool HasTemplateKWAndArgsInfo,
   2727                                            unsigned NumTemplateArgs);
   2728 
   2729   /// True if this declaration should be extended by
   2730   /// argument-dependent lookup.
   2731   bool requiresADL() const { return RequiresADL; }
   2732 
   2733   /// True if this lookup is overloaded.
   2734   bool isOverloaded() const { return Overloaded; }
   2735 
   2736   /// Gets the 'naming class' (in the sense of C++0x
   2737   /// [class.access.base]p5) of the lookup.  This is the scope
   2738   /// that was looked in to find these results.
   2739   CXXRecordDecl *getNamingClass() const { return NamingClass; }
   2740 
   2741   SourceLocation getLocStart() const LLVM_READONLY {
   2742     if (NestedNameSpecifierLoc l = getQualifierLoc())
   2743       return l.getBeginLoc();
   2744     return getNameInfo().getLocStart();
   2745   }
   2746   SourceLocation getLocEnd() const LLVM_READONLY {
   2747     if (hasExplicitTemplateArgs())
   2748       return getRAngleLoc();
   2749     return getNameInfo().getLocEnd();
   2750   }
   2751 
   2752   child_range children() {
   2753     return child_range(child_iterator(), child_iterator());
   2754   }
   2755 
   2756   static bool classof(const Stmt *T) {
   2757     return T->getStmtClass() == UnresolvedLookupExprClass;
   2758   }
   2759 };
   2760 
   2761 /// \brief A qualified reference to a name whose declaration cannot
   2762 /// yet be resolved.
   2763 ///
   2764 /// DependentScopeDeclRefExpr is similar to DeclRefExpr in that
   2765 /// it expresses a reference to a declaration such as
   2766 /// X<T>::value. The difference, however, is that an
   2767 /// DependentScopeDeclRefExpr node is used only within C++ templates when
   2768 /// the qualification (e.g., X<T>::) refers to a dependent type. In
   2769 /// this case, X<T>::value cannot resolve to a declaration because the
   2770 /// declaration will differ from one instantiation of X<T> to the
   2771 /// next. Therefore, DependentScopeDeclRefExpr keeps track of the
   2772 /// qualifier (X<T>::) and the name of the entity being referenced
   2773 /// ("value"). Such expressions will instantiate to a DeclRefExpr once the
   2774 /// declaration can be found.
   2775 class DependentScopeDeclRefExpr final
   2776     : public Expr,
   2777       private llvm::TrailingObjects<DependentScopeDeclRefExpr,
   2778                                     ASTTemplateKWAndArgsInfo,
   2779                                     TemplateArgumentLoc> {
   2780   /// \brief The nested-name-specifier that qualifies this unresolved
   2781   /// declaration name.
   2782   NestedNameSpecifierLoc QualifierLoc;
   2783 
   2784   /// \brief The name of the entity we will be referencing.
   2785   DeclarationNameInfo NameInfo;
   2786 
   2787   /// \brief Whether the name includes info for explicit template
   2788   /// keyword and arguments.
   2789   bool HasTemplateKWAndArgsInfo;
   2790 
   2791   size_t numTrailingObjects(OverloadToken<ASTTemplateKWAndArgsInfo>) const {
   2792     return HasTemplateKWAndArgsInfo ? 1 : 0;
   2793   }
   2794 
   2795   DependentScopeDeclRefExpr(QualType T,
   2796                             NestedNameSpecifierLoc QualifierLoc,
   2797                             SourceLocation TemplateKWLoc,
   2798                             const DeclarationNameInfo &NameInfo,
   2799                             const TemplateArgumentListInfo *Args);
   2800 
   2801 public:
   2802   static DependentScopeDeclRefExpr *Create(const ASTContext &C,
   2803                                            NestedNameSpecifierLoc QualifierLoc,
   2804                                            SourceLocation TemplateKWLoc,
   2805                                            const DeclarationNameInfo &NameInfo,
   2806                               const TemplateArgumentListInfo *TemplateArgs);
   2807 
   2808   static DependentScopeDeclRefExpr *CreateEmpty(const ASTContext &C,
   2809                                                 bool HasTemplateKWAndArgsInfo,
   2810                                                 unsigned NumTemplateArgs);
   2811 
   2812   /// \brief Retrieve the name that this expression refers to.
   2813   const DeclarationNameInfo &getNameInfo() const { return NameInfo; }
   2814 
   2815   /// \brief Retrieve the name that this expression refers to.
   2816   DeclarationName getDeclName() const { return NameInfo.getName(); }
   2817 
   2818   /// \brief Retrieve the location of the name within the expression.
   2819   ///
   2820   /// For example, in "X<T>::value" this is the location of "value".
   2821   SourceLocation getLocation() const { return NameInfo.getLoc(); }
   2822 
   2823   /// \brief Retrieve the nested-name-specifier that qualifies the
   2824   /// name, with source location information.
   2825   NestedNameSpecifierLoc getQualifierLoc() const { return QualifierLoc; }
   2826 
   2827   /// \brief Retrieve the nested-name-specifier that qualifies this
   2828   /// declaration.
   2829   NestedNameSpecifier *getQualifier() const {
   2830     return QualifierLoc.getNestedNameSpecifier();
   2831   }
   2832 
   2833   /// \brief Retrieve the location of the template keyword preceding
   2834   /// this name, if any.
   2835   SourceLocation getTemplateKeywordLoc() const {
   2836     if (!HasTemplateKWAndArgsInfo) return SourceLocation();
   2837     return getTrailingObjects<ASTTemplateKWAndArgsInfo>()->TemplateKWLoc;
   2838   }
   2839 
   2840   /// \brief Retrieve the location of the left angle bracket starting the
   2841   /// explicit template argument list following the name, if any.
   2842   SourceLocation getLAngleLoc() const {
   2843     if (!HasTemplateKWAndArgsInfo) return SourceLocation();
   2844     return getTrailingObjects<ASTTemplateKWAndArgsInfo>()->LAngleLoc;
   2845   }
   2846 
   2847   /// \brief Retrieve the location of the right angle bracket ending the
   2848   /// explicit template argument list following the name, if any.
   2849   SourceLocation getRAngleLoc() const {
   2850     if (!HasTemplateKWAndArgsInfo) return SourceLocation();
   2851     return getTrailingObjects<ASTTemplateKWAndArgsInfo>()->RAngleLoc;
   2852   }
   2853 
   2854   /// Determines whether the name was preceded by the template keyword.
   2855   bool hasTemplateKeyword() const { return getTemplateKeywordLoc().isValid(); }
   2856 
   2857   /// Determines whether this lookup had explicit template arguments.
   2858   bool hasExplicitTemplateArgs() const { return getLAngleLoc().isValid(); }
   2859 
   2860   /// \brief Copies the template arguments (if present) into the given
   2861   /// structure.
   2862   void copyTemplateArgumentsInto(TemplateArgumentListInfo &List) const {
   2863     if (hasExplicitTemplateArgs())
   2864       getTrailingObjects<ASTTemplateKWAndArgsInfo>()->copyInto(
   2865           getTrailingObjects<TemplateArgumentLoc>(), List);
   2866   }
   2867 
   2868   TemplateArgumentLoc const *getTemplateArgs() const {
   2869     if (!hasExplicitTemplateArgs())
   2870       return nullptr;
   2871 
   2872     return getTrailingObjects<TemplateArgumentLoc>();
   2873   }
   2874 
   2875   unsigned getNumTemplateArgs() const {
   2876     if (!hasExplicitTemplateArgs())
   2877       return 0;
   2878 
   2879     return getTrailingObjects<ASTTemplateKWAndArgsInfo>()->NumTemplateArgs;
   2880   }
   2881 
   2882   ArrayRef<TemplateArgumentLoc> template_arguments() const {
   2883     return {getTemplateArgs(), getNumTemplateArgs()};
   2884   }
   2885 
   2886   /// Note: getLocStart() is the start of the whole DependentScopeDeclRefExpr,
   2887   /// and differs from getLocation().getStart().
   2888   SourceLocation getLocStart() const LLVM_READONLY {
   2889     return QualifierLoc.getBeginLoc();
   2890   }
   2891   SourceLocation getLocEnd() const LLVM_READONLY {
   2892     if (hasExplicitTemplateArgs())
   2893       return getRAngleLoc();
   2894     return getLocation();
   2895   }
   2896 
   2897   static bool classof(const Stmt *T) {
   2898     return T->getStmtClass() == DependentScopeDeclRefExprClass;
   2899   }
   2900 
   2901   child_range children() {
   2902     return child_range(child_iterator(), child_iterator());
   2903   }
   2904 
   2905   friend TrailingObjects;
   2906   friend class ASTStmtReader;
   2907   friend class ASTStmtWriter;
   2908 };
   2909 
   2910 /// Represents an expression -- generally a full-expression -- that
   2911 /// introduces cleanups to be run at the end of the sub-expression's
   2912 /// evaluation.  The most common source of expression-introduced
   2913 /// cleanups is temporary objects in C++, but several other kinds of
   2914 /// expressions can create cleanups, including basically every
   2915 /// call in ARC that returns an Objective-C pointer.
   2916 ///
   2917 /// This expression also tracks whether the sub-expression contains a
   2918 /// potentially-evaluated block literal.  The lifetime of a block
   2919 /// literal is the extent of the enclosing scope.
   2920 class ExprWithCleanups final
   2921     : public Expr,
   2922       private llvm::TrailingObjects<ExprWithCleanups, BlockDecl *> {
   2923 public:
   2924   /// The type of objects that are kept in the cleanup.
   2925   /// It's useful to remember the set of blocks;  we could also
   2926   /// remember the set of temporaries, but there's currently
   2927   /// no need.
   2928   typedef BlockDecl *CleanupObject;
   2929 
   2930 private:
   2931   Stmt *SubExpr;
   2932 
   2933   ExprWithCleanups(EmptyShell, unsigned NumObjects);
   2934   ExprWithCleanups(Expr *SubExpr, bool CleanupsHaveSideEffects,
   2935                    ArrayRef<CleanupObject> Objects);
   2936 
   2937   friend TrailingObjects;
   2938   friend class ASTStmtReader;
   2939 
   2940 public:
   2941   static ExprWithCleanups *Create(const ASTContext &C, EmptyShell empty,
   2942                                   unsigned numObjects);
   2943 
   2944   static ExprWithCleanups *Create(const ASTContext &C, Expr *subexpr,
   2945                                   bool CleanupsHaveSideEffects,
   2946                                   ArrayRef<CleanupObject> objects);
   2947 
   2948   ArrayRef<CleanupObject> getObjects() const {
   2949     return llvm::makeArrayRef(getTrailingObjects<CleanupObject>(),
   2950                               getNumObjects());
   2951   }
   2952 
   2953   unsigned getNumObjects() const { return ExprWithCleanupsBits.NumObjects; }
   2954 
   2955   CleanupObject getObject(unsigned i) const {
   2956     assert(i < getNumObjects() && "Index out of range");
   2957     return getObjects()[i];
   2958   }
   2959 
   2960   Expr *getSubExpr() { return cast<Expr>(SubExpr); }
   2961   const Expr *getSubExpr() const { return cast<Expr>(SubExpr); }
   2962   bool cleanupsHaveSideEffects() const {
   2963     return ExprWithCleanupsBits.CleanupsHaveSideEffects;
   2964   }
   2965 
   2966   /// As with any mutator of the AST, be very careful
   2967   /// when modifying an existing AST to preserve its invariants.
   2968   void setSubExpr(Expr *E) { SubExpr = E; }
   2969 
   2970   SourceLocation getLocStart() const LLVM_READONLY {
   2971     return SubExpr->getLocStart();
   2972   }
   2973   SourceLocation getLocEnd() const LLVM_READONLY { return SubExpr->getLocEnd();}
   2974 
   2975   // Implement isa/cast/dyncast/etc.
   2976   static bool classof(const Stmt *T) {
   2977     return T->getStmtClass() == ExprWithCleanupsClass;
   2978   }
   2979 
   2980   // Iterators
   2981   child_range children() { return child_range(&SubExpr, &SubExpr + 1); }
   2982 };
   2983 
   2984 /// \brief Describes an explicit type conversion that uses functional
   2985 /// notion but could not be resolved because one or more arguments are
   2986 /// type-dependent.
   2987 ///
   2988 /// The explicit type conversions expressed by
   2989 /// CXXUnresolvedConstructExpr have the form <tt>T(a1, a2, ..., aN)</tt>,
   2990 /// where \c T is some type and \c a1, \c a2, ..., \c aN are values, and
   2991 /// either \c T is a dependent type or one or more of the <tt>a</tt>'s is
   2992 /// type-dependent. For example, this would occur in a template such
   2993 /// as:
   2994 ///
   2995 /// \code
   2996 ///   template<typename T, typename A1>
   2997 ///   inline T make_a(const A1& a1) {
   2998 ///     return T(a1);
   2999 ///   }
   3000 /// \endcode
   3001 ///
   3002 /// When the returned expression is instantiated, it may resolve to a
   3003 /// constructor call, conversion function call, or some kind of type
   3004 /// conversion.
   3005 class CXXUnresolvedConstructExpr final
   3006     : public Expr,
   3007       private llvm::TrailingObjects<CXXUnresolvedConstructExpr, Expr *> {
   3008   /// \brief The type being constructed.
   3009   TypeSourceInfo *Type;
   3010 
   3011   /// \brief The location of the left parentheses ('(').
   3012   SourceLocation LParenLoc;
   3013 
   3014   /// \brief The location of the right parentheses (')').
   3015   SourceLocation RParenLoc;
   3016 
   3017   /// \brief The number of arguments used to construct the type.
   3018   unsigned NumArgs;
   3019 
   3020   CXXUnresolvedConstructExpr(TypeSourceInfo *Type,
   3021                              SourceLocation LParenLoc,
   3022                              ArrayRef<Expr*> Args,
   3023                              SourceLocation RParenLoc);
   3024 
   3025   CXXUnresolvedConstructExpr(EmptyShell Empty, unsigned NumArgs)
   3026     : Expr(CXXUnresolvedConstructExprClass, Empty), Type(), NumArgs(NumArgs) { }
   3027 
   3028   friend TrailingObjects;
   3029   friend class ASTStmtReader;
   3030 
   3031 public:
   3032   static CXXUnresolvedConstructExpr *Create(const ASTContext &C,
   3033                                             TypeSourceInfo *Type,
   3034                                             SourceLocation LParenLoc,
   3035                                             ArrayRef<Expr*> Args,
   3036                                             SourceLocation RParenLoc);
   3037 
   3038   static CXXUnresolvedConstructExpr *CreateEmpty(const ASTContext &C,
   3039                                                  unsigned NumArgs);
   3040 
   3041   /// \brief Retrieve the type that is being constructed, as specified
   3042   /// in the source code.
   3043   QualType getTypeAsWritten() const { return Type->getType(); }
   3044 
   3045   /// \brief Retrieve the type source information for the type being
   3046   /// constructed.
   3047   TypeSourceInfo *getTypeSourceInfo() const { return Type; }
   3048 
   3049   /// \brief Retrieve the location of the left parentheses ('(') that
   3050   /// precedes the argument list.
   3051   SourceLocation getLParenLoc() const { return LParenLoc; }
   3052   void setLParenLoc(SourceLocation L) { LParenLoc = L; }
   3053 
   3054   /// \brief Retrieve the location of the right parentheses (')') that
   3055   /// follows the argument list.
   3056   SourceLocation getRParenLoc() const { return RParenLoc; }
   3057   void setRParenLoc(SourceLocation L) { RParenLoc = L; }
   3058 
   3059   /// Determine whether this expression models list-initialization.
   3060   /// If so, there will be exactly one subexpression, which will be
   3061   /// an InitListExpr.
   3062   bool isListInitialization() const { return LParenLoc.isInvalid(); }
   3063 
   3064   /// \brief Retrieve the number of arguments.
   3065   unsigned arg_size() const { return NumArgs; }
   3066 
   3067   typedef Expr** arg_iterator;
   3068   arg_iterator arg_begin() { return getTrailingObjects<Expr *>(); }
   3069   arg_iterator arg_end() { return arg_begin() + NumArgs; }
   3070 
   3071   typedef const Expr* const * const_arg_iterator;
   3072   const_arg_iterator arg_begin() const { return getTrailingObjects<Expr *>(); }
   3073   const_arg_iterator arg_end() const {
   3074     return arg_begin() + NumArgs;
   3075   }
   3076 
   3077   Expr *getArg(unsigned I) {
   3078     assert(I < NumArgs && "Argument index out-of-range");
   3079     return *(arg_begin() + I);
   3080   }
   3081 
   3082   const Expr *getArg(unsigned I) const {
   3083     assert(I < NumArgs && "Argument index out-of-range");
   3084     return *(arg_begin() + I);
   3085   }
   3086 
   3087   void setArg(unsigned I, Expr *E) {
   3088     assert(I < NumArgs && "Argument index out-of-range");
   3089     *(arg_begin() + I) = E;
   3090   }
   3091 
   3092   SourceLocation getLocStart() const LLVM_READONLY;
   3093   SourceLocation getLocEnd() const LLVM_READONLY {
   3094     if (!RParenLoc.isValid() && NumArgs > 0)
   3095       return getArg(NumArgs - 1)->getLocEnd();
   3096     return RParenLoc;
   3097   }
   3098 
   3099   static bool classof(const Stmt *T) {
   3100     return T->getStmtClass() == CXXUnresolvedConstructExprClass;
   3101   }
   3102 
   3103   // Iterators
   3104   child_range children() {
   3105     Stmt **begin = reinterpret_cast<Stmt **>(arg_begin());
   3106     return child_range(begin, begin + NumArgs);
   3107   }
   3108 };
   3109 
   3110 /// \brief Represents a C++ member access expression where the actual
   3111 /// member referenced could not be resolved because the base
   3112 /// expression or the member name was dependent.
   3113 ///
   3114 /// Like UnresolvedMemberExprs, these can be either implicit or
   3115 /// explicit accesses.  It is only possible to get one of these with
   3116 /// an implicit access if a qualifier is provided.
   3117 class CXXDependentScopeMemberExpr final
   3118     : public Expr,
   3119       private llvm::TrailingObjects<CXXDependentScopeMemberExpr,
   3120                                     ASTTemplateKWAndArgsInfo,
   3121                                     TemplateArgumentLoc> {
   3122   /// \brief The expression for the base pointer or class reference,
   3123   /// e.g., the \c x in x.f.  Can be null in implicit accesses.
   3124   Stmt *Base;
   3125 
   3126   /// \brief The type of the base expression.  Never null, even for
   3127   /// implicit accesses.
   3128   QualType BaseType;
   3129 
   3130   /// \brief Whether this member expression used the '->' operator or
   3131   /// the '.' operator.
   3132   bool IsArrow : 1;
   3133 
   3134   /// \brief Whether this member expression has info for explicit template
   3135   /// keyword and arguments.
   3136   bool HasTemplateKWAndArgsInfo : 1;
   3137 
   3138   /// \brief The location of the '->' or '.' operator.
   3139   SourceLocation OperatorLoc;
   3140 
   3141   /// \brief The nested-name-specifier that precedes the member name, if any.
   3142   NestedNameSpecifierLoc QualifierLoc;
   3143 
   3144   /// \brief In a qualified member access expression such as t->Base::f, this
   3145   /// member stores the resolves of name lookup in the context of the member
   3146   /// access expression, to be used at instantiation time.
   3147   ///
   3148   /// FIXME: This member, along with the QualifierLoc, could
   3149   /// be stuck into a structure that is optionally allocated at the end of
   3150   /// the CXXDependentScopeMemberExpr, to save space in the common case.
   3151   NamedDecl *FirstQualifierFoundInScope;
   3152 
   3153   /// \brief The member to which this member expression refers, which
   3154   /// can be name, overloaded operator, or destructor.
   3155   ///
   3156   /// FIXME: could also be a template-id
   3157   DeclarationNameInfo MemberNameInfo;
   3158 
   3159   size_t numTrailingObjects(OverloadToken<ASTTemplateKWAndArgsInfo>) const {
   3160     return HasTemplateKWAndArgsInfo ? 1 : 0;
   3161   }
   3162 
   3163   CXXDependentScopeMemberExpr(const ASTContext &C, Expr *Base,
   3164                               QualType BaseType, bool IsArrow,
   3165                               SourceLocation OperatorLoc,
   3166                               NestedNameSpecifierLoc QualifierLoc,
   3167                               SourceLocation TemplateKWLoc,
   3168                               NamedDecl *FirstQualifierFoundInScope,
   3169                               DeclarationNameInfo MemberNameInfo,
   3170                               const TemplateArgumentListInfo *TemplateArgs);
   3171 
   3172 public:
   3173   CXXDependentScopeMemberExpr(const ASTContext &C, Expr *Base,
   3174                               QualType BaseType, bool IsArrow,
   3175                               SourceLocation OperatorLoc,
   3176                               NestedNameSpecifierLoc QualifierLoc,
   3177                               NamedDecl *FirstQualifierFoundInScope,
   3178                               DeclarationNameInfo MemberNameInfo);
   3179 
   3180   static CXXDependentScopeMemberExpr *
   3181   Create(const ASTContext &C, Expr *Base, QualType BaseType, bool IsArrow,
   3182          SourceLocation OperatorLoc, NestedNameSpecifierLoc QualifierLoc,
   3183          SourceLocation TemplateKWLoc, NamedDecl *FirstQualifierFoundInScope,
   3184          DeclarationNameInfo MemberNameInfo,
   3185          const TemplateArgumentListInfo *TemplateArgs);
   3186 
   3187   static CXXDependentScopeMemberExpr *
   3188   CreateEmpty(const ASTContext &C, bool HasTemplateKWAndArgsInfo,
   3189               unsigned NumTemplateArgs);
   3190 
   3191   /// \brief True if this is an implicit access, i.e. one in which the
   3192   /// member being accessed was not written in the source.  The source
   3193   /// location of the operator is invalid in this case.
   3194   bool isImplicitAccess() const;
   3195 
   3196   /// \brief Retrieve the base object of this member expressions,
   3197   /// e.g., the \c x in \c x.m.
   3198   Expr *getBase() const {
   3199     assert(!isImplicitAccess());
   3200     return cast<Expr>(Base);
   3201   }
   3202 
   3203   QualType getBaseType() const { return BaseType; }
   3204 
   3205   /// \brief Determine whether this member expression used the '->'
   3206   /// operator; otherwise, it used the '.' operator.
   3207   bool isArrow() const { return IsArrow; }
   3208 
   3209   /// \brief Retrieve the location of the '->' or '.' operator.
   3210   SourceLocation getOperatorLoc() const { return OperatorLoc; }
   3211 
   3212   /// \brief Retrieve the nested-name-specifier that qualifies the member
   3213   /// name.
   3214   NestedNameSpecifier *getQualifier() const {
   3215     return QualifierLoc.getNestedNameSpecifier();
   3216   }
   3217 
   3218   /// \brief Retrieve the nested-name-specifier that qualifies the member
   3219   /// name, with source location information.
   3220   NestedNameSpecifierLoc getQualifierLoc() const { return QualifierLoc; }
   3221 
   3222 
   3223   /// \brief Retrieve the first part of the nested-name-specifier that was
   3224   /// found in the scope of the member access expression when the member access
   3225   /// was initially parsed.
   3226   ///
   3227   /// This function only returns a useful result when member access expression
   3228   /// uses a qualified member name, e.g., "x.Base::f". Here, the declaration
   3229   /// returned by this function describes what was found by unqualified name
   3230   /// lookup for the identifier "Base" within the scope of the member access
   3231   /// expression itself. At template instantiation time, this information is
   3232   /// combined with the results of name lookup into the type of the object
   3233   /// expression itself (the class type of x).
   3234   NamedDecl *getFirstQualifierFoundInScope() const {
   3235     return FirstQualifierFoundInScope;
   3236   }
   3237 
   3238   /// \brief Retrieve the name of the member that this expression
   3239   /// refers to.
   3240   const DeclarationNameInfo &getMemberNameInfo() const {
   3241     return MemberNameInfo;
   3242   }
   3243 
   3244   /// \brief Retrieve the name of the member that this expression
   3245   /// refers to.
   3246   DeclarationName getMember() const { return MemberNameInfo.getName(); }
   3247 
   3248   // \brief Retrieve the location of the name of the member that this
   3249   // expression refers to.
   3250   SourceLocation getMemberLoc() const { return MemberNameInfo.getLoc(); }
   3251 
   3252   /// \brief Retrieve the location of the template keyword preceding the
   3253   /// member name, if any.
   3254   SourceLocation getTemplateKeywordLoc() const {
   3255     if (!HasTemplateKWAndArgsInfo) return SourceLocation();
   3256     return getTrailingObjects<ASTTemplateKWAndArgsInfo>()->TemplateKWLoc;
   3257   }
   3258 
   3259   /// \brief Retrieve the location of the left angle bracket starting the
   3260   /// explicit template argument list following the member name, if any.
   3261   SourceLocation getLAngleLoc() const {
   3262     if (!HasTemplateKWAndArgsInfo) return SourceLocation();
   3263     return getTrailingObjects<ASTTemplateKWAndArgsInfo>()->LAngleLoc;
   3264   }
   3265 
   3266   /// \brief Retrieve the location of the right angle bracket ending the
   3267   /// explicit template argument list following the member name, if any.
   3268   SourceLocation getRAngleLoc() const {
   3269     if (!HasTemplateKWAndArgsInfo) return SourceLocation();
   3270     return getTrailingObjects<ASTTemplateKWAndArgsInfo>()->RAngleLoc;
   3271   }
   3272 
   3273   /// Determines whether the member name was preceded by the template keyword.
   3274   bool hasTemplateKeyword() const { return getTemplateKeywordLoc().isValid(); }
   3275 
   3276   /// \brief Determines whether this member expression actually had a C++
   3277   /// template argument list explicitly specified, e.g., x.f<int>.
   3278   bool hasExplicitTemplateArgs() const { return getLAngleLoc().isValid(); }
   3279 
   3280   /// \brief Copies the template arguments (if present) into the given
   3281   /// structure.
   3282   void copyTemplateArgumentsInto(TemplateArgumentListInfo &List) const {
   3283     if (hasExplicitTemplateArgs())
   3284       getTrailingObjects<ASTTemplateKWAndArgsInfo>()->copyInto(
   3285           getTrailingObjects<TemplateArgumentLoc>(), List);
   3286   }
   3287 
   3288   /// \brief Retrieve the template arguments provided as part of this
   3289   /// template-id.
   3290   const TemplateArgumentLoc *getTemplateArgs() const {
   3291     if (!hasExplicitTemplateArgs())
   3292       return nullptr;
   3293 
   3294     return getTrailingObjects<TemplateArgumentLoc>();
   3295   }
   3296 
   3297   /// \brief Retrieve the number of template arguments provided as part of this
   3298   /// template-id.
   3299   unsigned getNumTemplateArgs() const {
   3300     if (!hasExplicitTemplateArgs())
   3301       return 0;
   3302 
   3303     return getTrailingObjects<ASTTemplateKWAndArgsInfo>()->NumTemplateArgs;
   3304   }
   3305 
   3306   ArrayRef<TemplateArgumentLoc> template_arguments() const {
   3307     return {getTemplateArgs(), getNumTemplateArgs()};
   3308   }
   3309 
   3310   SourceLocation getLocStart() const LLVM_READONLY {
   3311     if (!isImplicitAccess())
   3312       return Base->getLocStart();
   3313     if (getQualifier())
   3314       return getQualifierLoc().getBeginLoc();
   3315     return MemberNameInfo.getBeginLoc();
   3316   }
   3317 
   3318   SourceLocation getLocEnd() const LLVM_READONLY {
   3319     if (hasExplicitTemplateArgs())
   3320       return getRAngleLoc();
   3321     return MemberNameInfo.getEndLoc();
   3322   }
   3323 
   3324   static bool classof(const Stmt *T) {
   3325     return T->getStmtClass() == CXXDependentScopeMemberExprClass;
   3326   }
   3327 
   3328   // Iterators
   3329   child_range children() {
   3330     if (isImplicitAccess())
   3331       return child_range(child_iterator(), child_iterator());
   3332     return child_range(&Base, &Base + 1);
   3333   }
   3334 
   3335   friend TrailingObjects;
   3336   friend class ASTStmtReader;
   3337   friend class ASTStmtWriter;
   3338 };
   3339 
   3340 /// \brief Represents a C++ member access expression for which lookup
   3341 /// produced a set of overloaded functions.
   3342 ///
   3343 /// The member access may be explicit or implicit:
   3344 /// \code
   3345 ///    struct A {
   3346 ///      int a, b;
   3347 ///      int explicitAccess() { return this->a + this->A::b; }
   3348 ///      int implicitAccess() { return a + A::b; }
   3349 ///    };
   3350 /// \endcode
   3351 ///
   3352 /// In the final AST, an explicit access always becomes a MemberExpr.
   3353 /// An implicit access may become either a MemberExpr or a
   3354 /// DeclRefExpr, depending on whether the member is static.
   3355 class UnresolvedMemberExpr final
   3356     : public OverloadExpr,
   3357       private llvm::TrailingObjects<
   3358           UnresolvedMemberExpr, ASTTemplateKWAndArgsInfo, TemplateArgumentLoc> {
   3359   /// \brief Whether this member expression used the '->' operator or
   3360   /// the '.' operator.
   3361   bool IsArrow : 1;
   3362 
   3363   /// \brief Whether the lookup results contain an unresolved using
   3364   /// declaration.
   3365   bool HasUnresolvedUsing : 1;
   3366 
   3367   /// \brief The expression for the base pointer or class reference,
   3368   /// e.g., the \c x in x.f.
   3369   ///
   3370   /// This can be null if this is an 'unbased' member expression.
   3371   Stmt *Base;
   3372 
   3373   /// \brief The type of the base expression; never null.
   3374   QualType BaseType;
   3375 
   3376   /// \brief The location of the '->' or '.' operator.
   3377   SourceLocation OperatorLoc;
   3378 
   3379   size_t numTrailingObjects(OverloadToken<ASTTemplateKWAndArgsInfo>) const {
   3380     return HasTemplateKWAndArgsInfo ? 1 : 0;
   3381   }
   3382 
   3383   UnresolvedMemberExpr(const ASTContext &C, bool HasUnresolvedUsing,
   3384                        Expr *Base, QualType BaseType, bool IsArrow,
   3385                        SourceLocation OperatorLoc,
   3386                        NestedNameSpecifierLoc QualifierLoc,
   3387                        SourceLocation TemplateKWLoc,
   3388                        const DeclarationNameInfo &MemberNameInfo,
   3389                        const TemplateArgumentListInfo *TemplateArgs,
   3390                        UnresolvedSetIterator Begin, UnresolvedSetIterator End);
   3391 
   3392   UnresolvedMemberExpr(EmptyShell Empty)
   3393     : OverloadExpr(UnresolvedMemberExprClass, Empty), IsArrow(false),
   3394       HasUnresolvedUsing(false), Base(nullptr) { }
   3395 
   3396   friend TrailingObjects;
   3397   friend class OverloadExpr;
   3398   friend class ASTStmtReader;
   3399 
   3400 public:
   3401   static UnresolvedMemberExpr *
   3402   Create(const ASTContext &C, bool HasUnresolvedUsing,
   3403          Expr *Base, QualType BaseType, bool IsArrow,
   3404          SourceLocation OperatorLoc,
   3405          NestedNameSpecifierLoc QualifierLoc,
   3406          SourceLocation TemplateKWLoc,
   3407          const DeclarationNameInfo &MemberNameInfo,
   3408          const TemplateArgumentListInfo *TemplateArgs,
   3409          UnresolvedSetIterator Begin, UnresolvedSetIterator End);
   3410 
   3411   static UnresolvedMemberExpr *
   3412   CreateEmpty(const ASTContext &C, bool HasTemplateKWAndArgsInfo,
   3413               unsigned NumTemplateArgs);
   3414 
   3415   /// \brief True if this is an implicit access, i.e., one in which the
   3416   /// member being accessed was not written in the source.
   3417   ///
   3418   /// The source location of the operator is invalid in this case.
   3419   bool isImplicitAccess() const;
   3420 
   3421   /// \brief Retrieve the base object of this member expressions,
   3422   /// e.g., the \c x in \c x.m.
   3423   Expr *getBase() {
   3424     assert(!isImplicitAccess());
   3425     return cast<Expr>(Base);
   3426   }
   3427   const Expr *getBase() const {
   3428     assert(!isImplicitAccess());
   3429     return cast<Expr>(Base);
   3430   }
   3431 
   3432   QualType getBaseType() const { return BaseType; }
   3433 
   3434   /// \brief Determine whether the lookup results contain an unresolved using
   3435   /// declaration.
   3436   bool hasUnresolvedUsing() const { return HasUnresolvedUsing; }
   3437 
   3438   /// \brief Determine whether this member expression used the '->'
   3439   /// operator; otherwise, it used the '.' operator.
   3440   bool isArrow() const { return IsArrow; }
   3441 
   3442   /// \brief Retrieve the location of the '->' or '.' operator.
   3443   SourceLocation getOperatorLoc() const { return OperatorLoc; }
   3444 
   3445   /// \brief Retrieve the naming class of this lookup.
   3446   CXXRecordDecl *getNamingClass() const;
   3447 
   3448   /// \brief Retrieve the full name info for the member that this expression
   3449   /// refers to.
   3450   const DeclarationNameInfo &getMemberNameInfo() const { return getNameInfo(); }
   3451 
   3452   /// \brief Retrieve the name of the member that this expression
   3453   /// refers to.
   3454   DeclarationName getMemberName() const { return getName(); }
   3455 
   3456   // \brief Retrieve the location of the name of the member that this
   3457   // expression refers to.
   3458   SourceLocation getMemberLoc() const { return getNameLoc(); }
   3459 
   3460   // \brief Return the preferred location (the member name) for the arrow when
   3461   // diagnosing a problem with this expression.
   3462   SourceLocation getExprLoc() const LLVM_READONLY { return getMemberLoc(); }
   3463 
   3464   SourceLocation getLocStart() const LLVM_READONLY {
   3465     if (!isImplicitAccess())
   3466       return Base->getLocStart();
   3467     if (NestedNameSpecifierLoc l = getQualifierLoc())
   3468       return l.getBeginLoc();
   3469     return getMemberNameInfo().getLocStart();
   3470   }
   3471   SourceLocation getLocEnd() const LLVM_READONLY {
   3472     if (hasExplicitTemplateArgs())
   3473       return getRAngleLoc();
   3474     return getMemberNameInfo().getLocEnd();
   3475   }
   3476 
   3477   static bool classof(const Stmt *T) {
   3478     return T->getStmtClass() == UnresolvedMemberExprClass;
   3479   }
   3480 
   3481   // Iterators
   3482   child_range children() {
   3483     if (isImplicitAccess())
   3484       return child_range(child_iterator(), child_iterator());
   3485     return child_range(&Base, &Base + 1);
   3486   }
   3487 };
   3488 
   3489 inline ASTTemplateKWAndArgsInfo *
   3490 OverloadExpr::getTrailingASTTemplateKWAndArgsInfo() {
   3491   if (!HasTemplateKWAndArgsInfo)
   3492     return nullptr;
   3493 
   3494   if (isa<UnresolvedLookupExpr>(this))
   3495     return cast<UnresolvedLookupExpr>(this)
   3496         ->getTrailingObjects<ASTTemplateKWAndArgsInfo>();
   3497   else
   3498     return cast<UnresolvedMemberExpr>(this)
   3499         ->getTrailingObjects<ASTTemplateKWAndArgsInfo>();
   3500 }
   3501 
   3502 inline TemplateArgumentLoc *OverloadExpr::getTrailingTemplateArgumentLoc() {
   3503   if (isa<UnresolvedLookupExpr>(this))
   3504     return cast<UnresolvedLookupExpr>(this)
   3505         ->getTrailingObjects<TemplateArgumentLoc>();
   3506   else
   3507     return cast<UnresolvedMemberExpr>(this)
   3508         ->getTrailingObjects<TemplateArgumentLoc>();
   3509 }
   3510 
   3511 /// \brief Represents a C++11 noexcept expression (C++ [expr.unary.noexcept]).
   3512 ///
   3513 /// The noexcept expression tests whether a given expression might throw. Its
   3514 /// result is a boolean constant.
   3515 class CXXNoexceptExpr : public Expr {
   3516   bool Value : 1;
   3517   Stmt *Operand;
   3518   SourceRange Range;
   3519 
   3520   friend class ASTStmtReader;
   3521 
   3522 public:
   3523   CXXNoexceptExpr(QualType Ty, Expr *Operand, CanThrowResult Val,
   3524                   SourceLocation Keyword, SourceLocation RParen)
   3525     : Expr(CXXNoexceptExprClass, Ty, VK_RValue, OK_Ordinary,
   3526            /*TypeDependent*/false,
   3527            /*ValueDependent*/Val == CT_Dependent,
   3528            Val == CT_Dependent || Operand->isInstantiationDependent(),
   3529            Operand->containsUnexpandedParameterPack()),
   3530       Value(Val == CT_Cannot), Operand(Operand), Range(Keyword, RParen)
   3531   { }
   3532 
   3533   CXXNoexceptExpr(EmptyShell Empty)
   3534     : Expr(CXXNoexceptExprClass, Empty)
   3535   { }
   3536 
   3537   Expr *getOperand() const { return static_cast<Expr*>(Operand); }
   3538 
   3539   SourceLocation getLocStart() const LLVM_READONLY { return Range.getBegin(); }
   3540   SourceLocation getLocEnd() const LLVM_READONLY { return Range.getEnd(); }
   3541   SourceRange getSourceRange() const LLVM_READONLY { return Range; }
   3542 
   3543   bool getValue() const { return Value; }
   3544 
   3545   static bool classof(const Stmt *T) {
   3546     return T->getStmtClass() == CXXNoexceptExprClass;
   3547   }
   3548 
   3549   // Iterators
   3550   child_range children() { return child_range(&Operand, &Operand + 1); }
   3551 };
   3552 
   3553 /// \brief Represents a C++11 pack expansion that produces a sequence of
   3554 /// expressions.
   3555 ///
   3556 /// A pack expansion expression contains a pattern (which itself is an
   3557 /// expression) followed by an ellipsis. For example:
   3558 ///
   3559 /// \code
   3560 /// template<typename F, typename ...Types>
   3561 /// void forward(F f, Types &&...args) {
   3562 ///   f(static_cast<Types&&>(args)...);
   3563 /// }
   3564 /// \endcode
   3565 ///
   3566 /// Here, the argument to the function object \c f is a pack expansion whose
   3567 /// pattern is \c static_cast<Types&&>(args). When the \c forward function
   3568 /// template is instantiated, the pack expansion will instantiate to zero or
   3569 /// or more function arguments to the function object \c f.
   3570 class PackExpansionExpr : public Expr {
   3571   SourceLocation EllipsisLoc;
   3572 
   3573   /// \brief The number of expansions that will be produced by this pack
   3574   /// expansion expression, if known.
   3575   ///
   3576   /// When zero, the number of expansions is not known. Otherwise, this value
   3577   /// is the number of expansions + 1.
   3578   unsigned NumExpansions;
   3579 
   3580   Stmt *Pattern;
   3581 
   3582   friend class ASTStmtReader;
   3583   friend class ASTStmtWriter;
   3584 
   3585 public:
   3586   PackExpansionExpr(QualType T, Expr *Pattern, SourceLocation EllipsisLoc,
   3587                     Optional<unsigned> NumExpansions)
   3588     : Expr(PackExpansionExprClass, T, Pattern->getValueKind(),
   3589            Pattern->getObjectKind(), /*TypeDependent=*/true,
   3590            /*ValueDependent=*/true, /*InstantiationDependent=*/true,
   3591            /*ContainsUnexpandedParameterPack=*/false),
   3592       EllipsisLoc(EllipsisLoc),
   3593       NumExpansions(NumExpansions? *NumExpansions + 1 : 0),
   3594       Pattern(Pattern) { }
   3595 
   3596   PackExpansionExpr(EmptyShell Empty) : Expr(PackExpansionExprClass, Empty) { }
   3597 
   3598   /// \brief Retrieve the pattern of the pack expansion.
   3599   Expr *getPattern() { return reinterpret_cast<Expr *>(Pattern); }
   3600 
   3601   /// \brief Retrieve the pattern of the pack expansion.
   3602   const Expr *getPattern() const { return reinterpret_cast<Expr *>(Pattern); }
   3603 
   3604   /// \brief Retrieve the location of the ellipsis that describes this pack
   3605   /// expansion.
   3606   SourceLocation getEllipsisLoc() const { return EllipsisLoc; }
   3607 
   3608   /// \brief Determine the number of expansions that will be produced when
   3609   /// this pack expansion is instantiated, if already known.
   3610   Optional<unsigned> getNumExpansions() const {
   3611     if (NumExpansions)
   3612       return NumExpansions - 1;
   3613 
   3614     return None;
   3615   }
   3616 
   3617   SourceLocation getLocStart() const LLVM_READONLY {
   3618     return Pattern->getLocStart();
   3619   }
   3620   SourceLocation getLocEnd() const LLVM_READONLY { return EllipsisLoc; }
   3621 
   3622   static bool classof(const Stmt *T) {
   3623     return T->getStmtClass() == PackExpansionExprClass;
   3624   }
   3625 
   3626   // Iterators
   3627   child_range children() {
   3628     return child_range(&Pattern, &Pattern + 1);
   3629   }
   3630 };
   3631 
   3632 
   3633 /// \brief Represents an expression that computes the length of a parameter
   3634 /// pack.
   3635 ///
   3636 /// \code
   3637 /// template<typename ...Types>
   3638 /// struct count {
   3639 ///   static const unsigned value = sizeof...(Types);
   3640 /// };
   3641 /// \endcode
   3642 class SizeOfPackExpr final
   3643     : public Expr,
   3644       private llvm::TrailingObjects<SizeOfPackExpr, TemplateArgument> {
   3645   /// \brief The location of the \c sizeof keyword.
   3646   SourceLocation OperatorLoc;
   3647 
   3648   /// \brief The location of the name of the parameter pack.
   3649   SourceLocation PackLoc;
   3650 
   3651   /// \brief The location of the closing parenthesis.
   3652   SourceLocation RParenLoc;
   3653 
   3654   /// \brief The length of the parameter pack, if known.
   3655   ///
   3656   /// When this expression is not value-dependent, this is the length of
   3657   /// the pack. When the expression was parsed rather than instantiated
   3658   /// (and thus is value-dependent), this is zero.
   3659   ///
   3660   /// After partial substitution into a sizeof...(X) expression (for instance,
   3661   /// within an alias template or during function template argument deduction),
   3662   /// we store a trailing array of partially-substituted TemplateArguments,
   3663   /// and this is the length of that array.
   3664   unsigned Length;
   3665 
   3666   /// \brief The parameter pack.
   3667   NamedDecl *Pack;
   3668 
   3669   friend TrailingObjects;
   3670   friend class ASTStmtReader;
   3671   friend class ASTStmtWriter;
   3672 
   3673   /// \brief Create an expression that computes the length of
   3674   /// the given parameter pack.
   3675   SizeOfPackExpr(QualType SizeType, SourceLocation OperatorLoc, NamedDecl *Pack,
   3676                  SourceLocation PackLoc, SourceLocation RParenLoc,
   3677                  Optional<unsigned> Length, ArrayRef<TemplateArgument> PartialArgs)
   3678       : Expr(SizeOfPackExprClass, SizeType, VK_RValue, OK_Ordinary,
   3679              /*TypeDependent=*/false, /*ValueDependent=*/!Length,
   3680              /*InstantiationDependent=*/!Length,
   3681              /*ContainsUnexpandedParameterPack=*/false),
   3682         OperatorLoc(OperatorLoc), PackLoc(PackLoc), RParenLoc(RParenLoc),
   3683         Length(Length ? *Length : PartialArgs.size()), Pack(Pack) {
   3684     assert((!Length || PartialArgs.empty()) &&
   3685            "have partial args for non-dependent sizeof... expression");
   3686     TemplateArgument *Args = getTrailingObjects<TemplateArgument>();
   3687     std::uninitialized_copy(PartialArgs.begin(), PartialArgs.end(), Args);
   3688   }
   3689 
   3690   /// \brief Create an empty expression.
   3691   SizeOfPackExpr(EmptyShell Empty, unsigned NumPartialArgs)
   3692       : Expr(SizeOfPackExprClass, Empty), Length(NumPartialArgs), Pack() {}
   3693 
   3694 public:
   3695   static SizeOfPackExpr *Create(ASTContext &Context, SourceLocation OperatorLoc,
   3696                                 NamedDecl *Pack, SourceLocation PackLoc,
   3697                                 SourceLocation RParenLoc,
   3698                                 Optional<unsigned> Length = None,
   3699                                 ArrayRef<TemplateArgument> PartialArgs = None);
   3700   static SizeOfPackExpr *CreateDeserialized(ASTContext &Context,
   3701                                             unsigned NumPartialArgs);
   3702 
   3703   /// \brief Determine the location of the 'sizeof' keyword.
   3704   SourceLocation getOperatorLoc() const { return OperatorLoc; }
   3705 
   3706   /// \brief Determine the location of the parameter pack.
   3707   SourceLocation getPackLoc() const { return PackLoc; }
   3708 
   3709   /// \brief Determine the location of the right parenthesis.
   3710   SourceLocation getRParenLoc() const { return RParenLoc; }
   3711 
   3712   /// \brief Retrieve the parameter pack.
   3713   NamedDecl *getPack() const { return Pack; }
   3714 
   3715   /// \brief Retrieve the length of the parameter pack.
   3716   ///
   3717   /// This routine may only be invoked when the expression is not
   3718   /// value-dependent.
   3719   unsigned getPackLength() const {
   3720     assert(!isValueDependent() &&
   3721            "Cannot get the length of a value-dependent pack size expression");
   3722     return Length;
   3723   }
   3724 
   3725   /// \brief Determine whether this represents a partially-substituted sizeof...
   3726   /// expression, such as is produced for:
   3727   ///
   3728   ///   template<typename ...Ts> using X = int[sizeof...(Ts)];
   3729   ///   template<typename ...Us> void f(X<Us..., 1, 2, 3, Us...>);
   3730   bool isPartiallySubstituted() const {
   3731     return isValueDependent() && Length;
   3732   }
   3733 
   3734   /// \brief Get
   3735   ArrayRef<TemplateArgument> getPartialArguments() const {
   3736     assert(isPartiallySubstituted());
   3737     const TemplateArgument *Args = getTrailingObjects<TemplateArgument>();
   3738     return llvm::makeArrayRef(Args, Args + Length);
   3739   }
   3740 
   3741   SourceLocation getLocStart() const LLVM_READONLY { return OperatorLoc; }
   3742   SourceLocation getLocEnd() const LLVM_READONLY { return RParenLoc; }
   3743 
   3744   static bool classof(const Stmt *T) {
   3745     return T->getStmtClass() == SizeOfPackExprClass;
   3746   }
   3747 
   3748   // Iterators
   3749   child_range children() {
   3750     return child_range(child_iterator(), child_iterator());
   3751   }
   3752 };
   3753 
   3754 /// \brief Represents a reference to a non-type template parameter
   3755 /// that has been substituted with a template argument.
   3756 class SubstNonTypeTemplateParmExpr : public Expr {
   3757   /// \brief The replaced parameter.
   3758   NonTypeTemplateParmDecl *Param;
   3759 
   3760   /// \brief The replacement expression.
   3761   Stmt *Replacement;
   3762 
   3763   /// \brief The location of the non-type template parameter reference.
   3764   SourceLocation NameLoc;
   3765 
   3766   friend class ASTReader;
   3767   friend class ASTStmtReader;
   3768   explicit SubstNonTypeTemplateParmExpr(EmptyShell Empty)
   3769     : Expr(SubstNonTypeTemplateParmExprClass, Empty) { }
   3770 
   3771 public:
   3772   SubstNonTypeTemplateParmExpr(QualType type,
   3773                                ExprValueKind valueKind,
   3774                                SourceLocation loc,
   3775                                NonTypeTemplateParmDecl *param,
   3776                                Expr *replacement)
   3777     : Expr(SubstNonTypeTemplateParmExprClass, type, valueKind, OK_Ordinary,
   3778            replacement->isTypeDependent(), replacement->isValueDependent(),
   3779            replacement->isInstantiationDependent(),
   3780            replacement->containsUnexpandedParameterPack()),
   3781       Param(param), Replacement(replacement), NameLoc(loc) {}
   3782 
   3783   SourceLocation getNameLoc() const { return NameLoc; }
   3784   SourceLocation getLocStart() const LLVM_READONLY { return NameLoc; }
   3785   SourceLocation getLocEnd() const LLVM_READONLY { return NameLoc; }
   3786 
   3787   Expr *getReplacement() const { return cast<Expr>(Replacement); }
   3788 
   3789   NonTypeTemplateParmDecl *getParameter() const { return Param; }
   3790 
   3791   static bool classof(const Stmt *s) {
   3792     return s->getStmtClass() == SubstNonTypeTemplateParmExprClass;
   3793   }
   3794 
   3795   // Iterators
   3796   child_range children() { return child_range(&Replacement, &Replacement+1); }
   3797 };
   3798 
   3799 /// \brief Represents a reference to a non-type template parameter pack that
   3800 /// has been substituted with a non-template argument pack.
   3801 ///
   3802 /// When a pack expansion in the source code contains multiple parameter packs
   3803 /// and those parameter packs correspond to different levels of template
   3804 /// parameter lists, this node is used to represent a non-type template
   3805 /// parameter pack from an outer level, which has already had its argument pack
   3806 /// substituted but that still lives within a pack expansion that itself
   3807 /// could not be instantiated. When actually performing a substitution into
   3808 /// that pack expansion (e.g., when all template parameters have corresponding
   3809 /// arguments), this type will be replaced with the appropriate underlying
   3810 /// expression at the current pack substitution index.
   3811 class SubstNonTypeTemplateParmPackExpr : public Expr {
   3812   /// \brief The non-type template parameter pack itself.
   3813   NonTypeTemplateParmDecl *Param;
   3814 
   3815   /// \brief A pointer to the set of template arguments that this
   3816   /// parameter pack is instantiated with.
   3817   const TemplateArgument *Arguments;
   3818 
   3819   /// \brief The number of template arguments in \c Arguments.
   3820   unsigned NumArguments;
   3821 
   3822   /// \brief The location of the non-type template parameter pack reference.
   3823   SourceLocation NameLoc;
   3824 
   3825   friend class ASTReader;
   3826   friend class ASTStmtReader;
   3827   explicit SubstNonTypeTemplateParmPackExpr(EmptyShell Empty)
   3828     : Expr(SubstNonTypeTemplateParmPackExprClass, Empty) { }
   3829 
   3830 public:
   3831   SubstNonTypeTemplateParmPackExpr(QualType T,
   3832                                    NonTypeTemplateParmDecl *Param,
   3833                                    SourceLocation NameLoc,
   3834                                    const TemplateArgument &ArgPack);
   3835 
   3836   /// \brief Retrieve the non-type template parameter pack being substituted.
   3837   NonTypeTemplateParmDecl *getParameterPack() const { return Param; }
   3838 
   3839   /// \brief Retrieve the location of the parameter pack name.
   3840   SourceLocation getParameterPackLocation() const { return NameLoc; }
   3841 
   3842   /// \brief Retrieve the template argument pack containing the substituted
   3843   /// template arguments.
   3844   TemplateArgument getArgumentPack() const;
   3845 
   3846   SourceLocation getLocStart() const LLVM_READONLY { return NameLoc; }
   3847   SourceLocation getLocEnd() const LLVM_READONLY { return NameLoc; }
   3848 
   3849   static bool classof(const Stmt *T) {
   3850     return T->getStmtClass() == SubstNonTypeTemplateParmPackExprClass;
   3851   }
   3852 
   3853   // Iterators
   3854   child_range children() {
   3855     return child_range(child_iterator(), child_iterator());
   3856   }
   3857 };
   3858 
   3859 /// \brief Represents a reference to a function parameter pack that has been
   3860 /// substituted but not yet expanded.
   3861 ///
   3862 /// When a pack expansion contains multiple parameter packs at different levels,
   3863 /// this node is used to represent a function parameter pack at an outer level
   3864 /// which we have already substituted to refer to expanded parameters, but where
   3865 /// the containing pack expansion cannot yet be expanded.
   3866 ///
   3867 /// \code
   3868 /// template<typename...Ts> struct S {
   3869 ///   template<typename...Us> auto f(Ts ...ts) -> decltype(g(Us(ts)...));
   3870 /// };
   3871 /// template struct S<int, int>;
   3872 /// \endcode
   3873 class FunctionParmPackExpr final
   3874     : public Expr,
   3875       private llvm::TrailingObjects<FunctionParmPackExpr, ParmVarDecl *> {
   3876   /// \brief The function parameter pack which was referenced.
   3877   ParmVarDecl *ParamPack;
   3878 
   3879   /// \brief The location of the function parameter pack reference.
   3880   SourceLocation NameLoc;
   3881 
   3882   /// \brief The number of expansions of this pack.
   3883   unsigned NumParameters;
   3884 
   3885   FunctionParmPackExpr(QualType T, ParmVarDecl *ParamPack,
   3886                        SourceLocation NameLoc, unsigned NumParams,
   3887                        ParmVarDecl *const *Params);
   3888 
   3889   friend TrailingObjects;
   3890   friend class ASTReader;
   3891   friend class ASTStmtReader;
   3892 
   3893 public:
   3894   static FunctionParmPackExpr *Create(const ASTContext &Context, QualType T,
   3895                                       ParmVarDecl *ParamPack,
   3896                                       SourceLocation NameLoc,
   3897                                       ArrayRef<ParmVarDecl *> Params);
   3898   static FunctionParmPackExpr *CreateEmpty(const ASTContext &Context,
   3899                                            unsigned NumParams);
   3900 
   3901   /// \brief Get the parameter pack which this expression refers to.
   3902   ParmVarDecl *getParameterPack() const { return ParamPack; }
   3903 
   3904   /// \brief Get the location of the parameter pack.
   3905   SourceLocation getParameterPackLocation() const { return NameLoc; }
   3906 
   3907   /// \brief Iterators over the parameters which the parameter pack expanded
   3908   /// into.
   3909   typedef ParmVarDecl * const *iterator;
   3910   iterator begin() const { return getTrailingObjects<ParmVarDecl *>(); }
   3911   iterator end() const { return begin() + NumParameters; }
   3912 
   3913   /// \brief Get the number of parameters in this parameter pack.
   3914   unsigned getNumExpansions() const { return NumParameters; }
   3915 
   3916   /// \brief Get an expansion of the parameter pack by index.
   3917   ParmVarDecl *getExpansion(unsigned I) const { return begin()[I]; }
   3918 
   3919   SourceLocation getLocStart() const LLVM_READONLY { return NameLoc; }
   3920   SourceLocation getLocEnd() const LLVM_READONLY { return NameLoc; }
   3921 
   3922   static bool classof(const Stmt *T) {
   3923     return T->getStmtClass() == FunctionParmPackExprClass;
   3924   }
   3925 
   3926   child_range children() {
   3927     return child_range(child_iterator(), child_iterator());
   3928   }
   3929 };
   3930 
   3931 /// \brief Represents a prvalue temporary that is written into memory so that
   3932 /// a reference can bind to it.
   3933 ///
   3934 /// Prvalue expressions are materialized when they need to have an address
   3935 /// in memory for a reference to bind to. This happens when binding a
   3936 /// reference to the result of a conversion, e.g.,
   3937 ///
   3938 /// \code
   3939 /// const int &r = 1.0;
   3940 /// \endcode
   3941 ///
   3942 /// Here, 1.0 is implicitly converted to an \c int. That resulting \c int is
   3943 /// then materialized via a \c MaterializeTemporaryExpr, and the reference
   3944 /// binds to the temporary. \c MaterializeTemporaryExprs are always glvalues
   3945 /// (either an lvalue or an xvalue, depending on the kind of reference binding
   3946 /// to it), maintaining the invariant that references always bind to glvalues.
   3947 ///
   3948 /// Reference binding and copy-elision can both extend the lifetime of a
   3949 /// temporary. When either happens, the expression will also track the
   3950 /// declaration which is responsible for the lifetime extension.
   3951 class MaterializeTemporaryExpr : public Expr {
   3952 private:
   3953   struct ExtraState {
   3954     /// \brief The temporary-generating expression whose value will be
   3955     /// materialized.
   3956     Stmt *Temporary;
   3957 
   3958     /// \brief The declaration which lifetime-extended this reference, if any.
   3959     /// Either a VarDecl, or (for a ctor-initializer) a FieldDecl.
   3960     const ValueDecl *ExtendingDecl;
   3961 
   3962     unsigned ManglingNumber;
   3963   };
   3964   llvm::PointerUnion<Stmt *, ExtraState *> State;
   3965 
   3966   friend class ASTStmtReader;
   3967   friend class ASTStmtWriter;
   3968 
   3969   void initializeExtraState(const ValueDecl *ExtendedBy,
   3970                             unsigned ManglingNumber);
   3971 
   3972 public:
   3973   MaterializeTemporaryExpr(QualType T, Expr *Temporary,
   3974                            bool BoundToLvalueReference)
   3975     : Expr(MaterializeTemporaryExprClass, T,
   3976            BoundToLvalueReference? VK_LValue : VK_XValue, OK_Ordinary,
   3977            Temporary->isTypeDependent(), Temporary->isValueDependent(),
   3978            Temporary->isInstantiationDependent(),
   3979            Temporary->containsUnexpandedParameterPack()),
   3980         State(Temporary) {}
   3981 
   3982   MaterializeTemporaryExpr(EmptyShell Empty)
   3983     : Expr(MaterializeTemporaryExprClass, Empty) { }
   3984 
   3985   Stmt *getTemporary() const {
   3986     return State.is<Stmt *>() ? State.get<Stmt *>()
   3987                               : State.get<ExtraState *>()->Temporary;
   3988   }
   3989 
   3990   /// \brief Retrieve the temporary-generating subexpression whose value will
   3991   /// be materialized into a glvalue.
   3992   Expr *GetTemporaryExpr() const { return static_cast<Expr *>(getTemporary()); }
   3993 
   3994   /// \brief Retrieve the storage duration for the materialized temporary.
   3995   StorageDuration getStorageDuration() const {
   3996     const ValueDecl *ExtendingDecl = getExtendingDecl();
   3997     if (!ExtendingDecl)
   3998       return SD_FullExpression;
   3999     // FIXME: This is not necessarily correct for a temporary materialized
   4000     // within a default initializer.
   4001     if (isa<FieldDecl>(ExtendingDecl))
   4002       return SD_Automatic;
   4003     // FIXME: This only works because storage class specifiers are not allowed
   4004     // on decomposition declarations.
   4005     if (isa<BindingDecl>(ExtendingDecl))
   4006       return ExtendingDecl->getDeclContext()->isFunctionOrMethod()
   4007                  ? SD_Automatic
   4008                  : SD_Static;
   4009     return cast<VarDecl>(ExtendingDecl)->getStorageDuration();
   4010   }
   4011 
   4012   /// \brief Get the declaration which triggered the lifetime-extension of this
   4013   /// temporary, if any.
   4014   const ValueDecl *getExtendingDecl() const {
   4015     return State.is<Stmt *>() ? nullptr
   4016                               : State.get<ExtraState *>()->ExtendingDecl;
   4017   }
   4018 
   4019   void setExtendingDecl(const ValueDecl *ExtendedBy, unsigned ManglingNumber);
   4020 
   4021   unsigned getManglingNumber() const {
   4022     return State.is<Stmt *>() ? 0 : State.get<ExtraState *>()->ManglingNumber;
   4023   }
   4024 
   4025   /// \brief Determine whether this materialized temporary is bound to an
   4026   /// lvalue reference; otherwise, it's bound to an rvalue reference.
   4027   bool isBoundToLvalueReference() const {
   4028     return getValueKind() == VK_LValue;
   4029   }
   4030 
   4031   SourceLocation getLocStart() const LLVM_READONLY {
   4032     return getTemporary()->getLocStart();
   4033   }
   4034   SourceLocation getLocEnd() const LLVM_READONLY {
   4035     return getTemporary()->getLocEnd();
   4036   }
   4037 
   4038   static bool classof(const Stmt *T) {
   4039     return T->getStmtClass() == MaterializeTemporaryExprClass;
   4040   }
   4041 
   4042   // Iterators
   4043   child_range children() {
   4044     if (State.is<Stmt *>())
   4045       return child_range(State.getAddrOfPtr1(), State.getAddrOfPtr1() + 1);
   4046 
   4047     auto ES = State.get<ExtraState *>();
   4048     return child_range(&ES->Temporary, &ES->Temporary + 1);
   4049   }
   4050 };
   4051 
   4052 /// \brief Represents a folding of a pack over an operator.
   4053 ///
   4054 /// This expression is always dependent and represents a pack expansion of the
   4055 /// forms:
   4056 ///
   4057 ///    ( expr op ... )
   4058 ///    ( ... op expr )
   4059 ///    ( expr op ... op expr )
   4060 class CXXFoldExpr : public Expr {
   4061   SourceLocation LParenLoc;
   4062   SourceLocation EllipsisLoc;
   4063   SourceLocation RParenLoc;
   4064   Stmt *SubExprs[2];
   4065   BinaryOperatorKind Opcode;
   4066 
   4067   friend class ASTStmtReader;
   4068   friend class ASTStmtWriter;
   4069 public:
   4070   CXXFoldExpr(QualType T, SourceLocation LParenLoc, Expr *LHS,
   4071               BinaryOperatorKind Opcode, SourceLocation EllipsisLoc, Expr *RHS,
   4072               SourceLocation RParenLoc)
   4073       : Expr(CXXFoldExprClass, T, VK_RValue, OK_Ordinary,
   4074              /*Dependent*/ true, true, true,
   4075              /*ContainsUnexpandedParameterPack*/ false),
   4076         LParenLoc(LParenLoc), EllipsisLoc(EllipsisLoc), RParenLoc(RParenLoc),
   4077         Opcode(Opcode) {
   4078     SubExprs[0] = LHS;
   4079     SubExprs[1] = RHS;
   4080   }
   4081   CXXFoldExpr(EmptyShell Empty) : Expr(CXXFoldExprClass, Empty) {}
   4082 
   4083   Expr *getLHS() const { return static_cast<Expr*>(SubExprs[0]); }
   4084   Expr *getRHS() const { return static_cast<Expr*>(SubExprs[1]); }
   4085 
   4086   /// Does this produce a right-associated sequence of operators?
   4087   bool isRightFold() const {
   4088     return getLHS() && getLHS()->containsUnexpandedParameterPack();
   4089   }
   4090   /// Does this produce a left-associated sequence of operators?
   4091   bool isLeftFold() const { return !isRightFold(); }
   4092   /// Get the pattern, that is, the operand that contains an unexpanded pack.
   4093   Expr *getPattern() const { return isLeftFold() ? getRHS() : getLHS(); }
   4094   /// Get the operand that doesn't contain a pack, for a binary fold.
   4095   Expr *getInit() const { return isLeftFold() ? getLHS() : getRHS(); }
   4096 
   4097   SourceLocation getEllipsisLoc() const { return EllipsisLoc; }
   4098   BinaryOperatorKind getOperator() const { return Opcode; }
   4099 
   4100   SourceLocation getLocStart() const LLVM_READONLY {
   4101     return LParenLoc;
   4102   }
   4103   SourceLocation getLocEnd() const LLVM_READONLY {
   4104     return RParenLoc;
   4105   }
   4106 
   4107   static bool classof(const Stmt *T) {
   4108     return T->getStmtClass() == CXXFoldExprClass;
   4109   }
   4110 
   4111   // Iterators
   4112   child_range children() { return child_range(SubExprs, SubExprs + 2); }
   4113 };
   4114 
   4115 /// \brief Represents an expression that might suspend coroutine execution;
   4116 /// either a co_await or co_yield expression.
   4117 ///
   4118 /// Evaluation of this expression first evaluates its 'ready' expression. If
   4119 /// that returns 'false':
   4120 ///  -- execution of the coroutine is suspended
   4121 ///  -- the 'suspend' expression is evaluated
   4122 ///     -- if the 'suspend' expression returns 'false', the coroutine is
   4123 ///        resumed
   4124 ///     -- otherwise, control passes back to the resumer.
   4125 /// If the coroutine is not suspended, or when it is resumed, the 'resume'
   4126 /// expression is evaluated, and its result is the result of the overall
   4127 /// expression.
   4128 class CoroutineSuspendExpr : public Expr {
   4129   SourceLocation KeywordLoc;
   4130 
   4131   enum SubExpr { Common, Ready, Suspend, Resume, Count };
   4132   Stmt *SubExprs[SubExpr::Count];
   4133   OpaqueValueExpr *OpaqueValue = nullptr;
   4134 
   4135   friend class ASTStmtReader;
   4136 public:
   4137   CoroutineSuspendExpr(StmtClass SC, SourceLocation KeywordLoc, Expr *Common,
   4138                        Expr *Ready, Expr *Suspend, Expr *Resume,
   4139                        OpaqueValueExpr *OpaqueValue)
   4140       : Expr(SC, Resume->getType(), Resume->getValueKind(),
   4141              Resume->getObjectKind(), Resume->isTypeDependent(),
   4142              Resume->isValueDependent(), Common->isInstantiationDependent(),
   4143              Common->containsUnexpandedParameterPack()),
   4144         KeywordLoc(KeywordLoc), OpaqueValue(OpaqueValue) {
   4145     SubExprs[SubExpr::Common] = Common;
   4146     SubExprs[SubExpr::Ready] = Ready;
   4147     SubExprs[SubExpr::Suspend] = Suspend;
   4148     SubExprs[SubExpr::Resume] = Resume;
   4149   }
   4150   CoroutineSuspendExpr(StmtClass SC, SourceLocation KeywordLoc, QualType Ty,
   4151                        Expr *Common)
   4152       : Expr(SC, Ty, VK_RValue, OK_Ordinary, true, true, true,
   4153              Common->containsUnexpandedParameterPack()),
   4154         KeywordLoc(KeywordLoc) {
   4155     assert(Common->isTypeDependent() && Ty->isDependentType() &&
   4156            "wrong constructor for non-dependent co_await/co_yield expression");
   4157     SubExprs[SubExpr::Common] = Common;
   4158     SubExprs[SubExpr::Ready] = nullptr;
   4159     SubExprs[SubExpr::Suspend] = nullptr;
   4160     SubExprs[SubExpr::Resume] = nullptr;
   4161   }
   4162   CoroutineSuspendExpr(StmtClass SC, EmptyShell Empty) : Expr(SC, Empty) {
   4163     SubExprs[SubExpr::Common] = nullptr;
   4164     SubExprs[SubExpr::Ready] = nullptr;
   4165     SubExprs[SubExpr::Suspend] = nullptr;
   4166     SubExprs[SubExpr::Resume] = nullptr;
   4167   }
   4168 
   4169   SourceLocation getKeywordLoc() const { return KeywordLoc; }
   4170   Expr *getCommonExpr() const {
   4171     return static_cast<Expr*>(SubExprs[SubExpr::Common]);
   4172   }
   4173   /// \brief getOpaqueValue - Return the opaque value placeholder.
   4174   OpaqueValueExpr *getOpaqueValue() const { return OpaqueValue; }
   4175 
   4176   Expr *getReadyExpr() const {
   4177     return static_cast<Expr*>(SubExprs[SubExpr::Ready]);
   4178   }
   4179   Expr *getSuspendExpr() const {
   4180     return static_cast<Expr*>(SubExprs[SubExpr::Suspend]);
   4181   }
   4182   Expr *getResumeExpr() const {
   4183     return static_cast<Expr*>(SubExprs[SubExpr::Resume]);
   4184   }
   4185 
   4186   SourceLocation getLocStart() const LLVM_READONLY {
   4187     return KeywordLoc;
   4188   }
   4189   SourceLocation getLocEnd() const LLVM_READONLY {
   4190     return getCommonExpr()->getLocEnd();
   4191   }
   4192 
   4193   child_range children() {
   4194     return child_range(SubExprs, SubExprs + SubExpr::Count);
   4195   }
   4196 
   4197   static bool classof(const Stmt *T) {
   4198     return T->getStmtClass() == CoawaitExprClass ||
   4199            T->getStmtClass() == CoyieldExprClass;
   4200   }
   4201 };
   4202 
   4203 /// \brief Represents a 'co_await' expression.
   4204 class CoawaitExpr : public CoroutineSuspendExpr {
   4205   friend class ASTStmtReader;
   4206 public:
   4207   CoawaitExpr(SourceLocation CoawaitLoc, Expr *Operand, Expr *Ready,
   4208               Expr *Suspend, Expr *Resume, OpaqueValueExpr *OpaqueValue,
   4209               bool IsImplicit = false)
   4210       : CoroutineSuspendExpr(CoawaitExprClass, CoawaitLoc, Operand, Ready,
   4211                              Suspend, Resume, OpaqueValue) {
   4212     CoawaitBits.IsImplicit = IsImplicit;
   4213   }
   4214   CoawaitExpr(SourceLocation CoawaitLoc, QualType Ty, Expr *Operand,
   4215               bool IsImplicit = false)
   4216       : CoroutineSuspendExpr(CoawaitExprClass, CoawaitLoc, Ty, Operand) {
   4217     CoawaitBits.IsImplicit = IsImplicit;
   4218   }
   4219   CoawaitExpr(EmptyShell Empty)
   4220       : CoroutineSuspendExpr(CoawaitExprClass, Empty) {}
   4221 
   4222   Expr *getOperand() const {
   4223     // FIXME: Dig out the actual operand or store it.
   4224     return getCommonExpr();
   4225   }
   4226 
   4227   bool isImplicit() const { return CoawaitBits.IsImplicit; }
   4228   void setIsImplicit(bool value = true) { CoawaitBits.IsImplicit = value; }
   4229 
   4230   static bool classof(const Stmt *T) {
   4231     return T->getStmtClass() == CoawaitExprClass;
   4232   }
   4233 };
   4234 
   4235 /// \brief Represents a 'co_await' expression while the type of the promise
   4236 /// is dependent.
   4237 class DependentCoawaitExpr : public Expr {
   4238   SourceLocation KeywordLoc;
   4239   Stmt *SubExprs[2];
   4240 
   4241   friend class ASTStmtReader;
   4242 
   4243 public:
   4244   DependentCoawaitExpr(SourceLocation KeywordLoc, QualType Ty, Expr *Op,
   4245                        UnresolvedLookupExpr *OpCoawait)
   4246       : Expr(DependentCoawaitExprClass, Ty, VK_RValue, OK_Ordinary,
   4247              /*TypeDependent*/ true, /*ValueDependent*/ true,
   4248              /*InstantiationDependent*/ true,
   4249              Op->containsUnexpandedParameterPack()),
   4250         KeywordLoc(KeywordLoc) {
   4251     // NOTE: A co_await expression is dependent on the coroutines promise
   4252     // type and may be dependent even when the `Op` expression is not.
   4253     assert(Ty->isDependentType() &&
   4254            "wrong constructor for non-dependent co_await/co_yield expression");
   4255     SubExprs[0] = Op;
   4256     SubExprs[1] = OpCoawait;
   4257   }
   4258 
   4259   DependentCoawaitExpr(EmptyShell Empty)
   4260       : Expr(DependentCoawaitExprClass, Empty) {}
   4261 
   4262   Expr *getOperand() const { return cast<Expr>(SubExprs[0]); }
   4263   UnresolvedLookupExpr *getOperatorCoawaitLookup() const {
   4264     return cast<UnresolvedLookupExpr>(SubExprs[1]);
   4265   }
   4266   SourceLocation getKeywordLoc() const { return KeywordLoc; }
   4267 
   4268   SourceLocation getLocStart() const LLVM_READONLY { return KeywordLoc; }
   4269   SourceLocation getLocEnd() const LLVM_READONLY {
   4270     return getOperand()->getLocEnd();
   4271   }
   4272 
   4273   child_range children() { return child_range(SubExprs, SubExprs + 2); }
   4274 
   4275   static bool classof(const Stmt *T) {
   4276     return T->getStmtClass() == DependentCoawaitExprClass;
   4277   }
   4278 };
   4279 
   4280 /// \brief Represents a 'co_yield' expression.
   4281 class CoyieldExpr : public CoroutineSuspendExpr {
   4282   friend class ASTStmtReader;
   4283 public:
   4284   CoyieldExpr(SourceLocation CoyieldLoc, Expr *Operand, Expr *Ready,
   4285               Expr *Suspend, Expr *Resume, OpaqueValueExpr *OpaqueValue)
   4286       : CoroutineSuspendExpr(CoyieldExprClass, CoyieldLoc, Operand, Ready,
   4287                              Suspend, Resume, OpaqueValue) {}
   4288   CoyieldExpr(SourceLocation CoyieldLoc, QualType Ty, Expr *Operand)
   4289       : CoroutineSuspendExpr(CoyieldExprClass, CoyieldLoc, Ty, Operand) {}
   4290   CoyieldExpr(EmptyShell Empty)
   4291       : CoroutineSuspendExpr(CoyieldExprClass, Empty) {}
   4292 
   4293   Expr *getOperand() const {
   4294     // FIXME: Dig out the actual operand or store it.
   4295     return getCommonExpr();
   4296   }
   4297 
   4298   static bool classof(const Stmt *T) {
   4299     return T->getStmtClass() == CoyieldExprClass;
   4300   }
   4301 };
   4302 
   4303 }  // end namespace clang
   4304 
   4305 #endif
   4306