ExprCXX.h revision 63c00d7f35fa060c0a446c9df3a4402d9c7757fe
15f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer//===--- ExprCXX.h - Classes for representing expressions -------*- C++ -*-===//
25f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer//
35f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer//                     The LLVM Compiler Infrastructure
45f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer//
50bc735ffcfb223c0186419547abaa5c84482663eChris Lattner// This file is distributed under the University of Illinois Open Source
60bc735ffcfb223c0186419547abaa5c84482663eChris Lattner// License. See LICENSE.TXT for details.
75f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer//
85f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer//===----------------------------------------------------------------------===//
95f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer//
105f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer//  This file defines the Expr interface and subclasses for C++ expressions.
115f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer//
125f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer//===----------------------------------------------------------------------===//
135f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer
145f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer#ifndef LLVM_CLANG_AST_EXPRCXX_H
155f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer#define LLVM_CLANG_AST_EXPRCXX_H
165f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer
1764b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl#include "clang/Basic/TypeTraits.h"
185f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer#include "clang/AST/Expr.h"
19eec51cf1ba5f0e62c9cdb81b5c63babdd6e649abJohn McCall#include "clang/AST/UnresolvedSet.h"
20d5532b6cfff2977e0c59fa6ead7f7973984a620dJohn McCall#include "clang/AST/TemplateBase.h"
215f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer
225f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencernamespace clang {
235f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer
24aa165f8458b51c546bebff947343e1a36f3594cbDouglas Gregorclass CXXConstructorDecl;
25aa165f8458b51c546bebff947343e1a36f3594cbDouglas Gregorclass CXXDestructorDecl;
26aa165f8458b51c546bebff947343e1a36f3594cbDouglas Gregorclass CXXMethodDecl;
27aa165f8458b51c546bebff947343e1a36f3594cbDouglas Gregorclass CXXTemporary;
28aa165f8458b51c546bebff947343e1a36f3594cbDouglas Gregorclass TemplateArgumentListInfo;
294c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
301060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek//===--------------------------------------------------------------------===//
311060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek// C++ Expressions.
321060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek//===--------------------------------------------------------------------===//
331060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek
343fd95ce225393fe4a3623e429766a8c3f487ff9dDouglas Gregor/// \brief A call to an overloaded operator written using operator
353fd95ce225393fe4a3623e429766a8c3f487ff9dDouglas Gregor/// syntax.
363fd95ce225393fe4a3623e429766a8c3f487ff9dDouglas Gregor///
373fd95ce225393fe4a3623e429766a8c3f487ff9dDouglas Gregor/// Represents a call to an overloaded operator written using operator
383fd95ce225393fe4a3623e429766a8c3f487ff9dDouglas Gregor/// syntax, e.g., "x + y" or "*p". While semantically equivalent to a
393fd95ce225393fe4a3623e429766a8c3f487ff9dDouglas Gregor/// normal call, this AST node provides better information about the
403fd95ce225393fe4a3623e429766a8c3f487ff9dDouglas Gregor/// syntactic representation of the call.
413fd95ce225393fe4a3623e429766a8c3f487ff9dDouglas Gregor///
423fd95ce225393fe4a3623e429766a8c3f487ff9dDouglas Gregor/// In a C++ template, this expression node kind will be used whenever
433fd95ce225393fe4a3623e429766a8c3f487ff9dDouglas Gregor/// any of the arguments are type-dependent. In this case, the
443fd95ce225393fe4a3623e429766a8c3f487ff9dDouglas Gregor/// function itself will be a (possibly empty) set of functions and
453fd95ce225393fe4a3623e429766a8c3f487ff9dDouglas Gregor/// function templates that were found by name lookup at template
463fd95ce225393fe4a3623e429766a8c3f487ff9dDouglas Gregor/// definition time.
47b4609806e9232593ece09ce08b630836e825865cDouglas Gregorclass CXXOperatorCallExpr : public CallExpr {
48063daf6e196c51f162e0485478355d8e280eef5cDouglas Gregor  /// \brief The overloaded operator.
49063daf6e196c51f162e0485478355d8e280eef5cDouglas Gregor  OverloadedOperatorKind Operator;
50063daf6e196c51f162e0485478355d8e280eef5cDouglas Gregor
51b4609806e9232593ece09ce08b630836e825865cDouglas Gregorpublic:
521eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  CXXOperatorCallExpr(ASTContext& C, OverloadedOperatorKind Op, Expr *fn,
531eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump                      Expr **args, unsigned numargs, QualType t,
54f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall                      ExprValueKind VK, SourceLocation operatorloc)
55cc324ad80ab940efca006b0064f7ca70a6181816Peter Collingbourne    : CallExpr(C, CXXOperatorCallExprClass, fn, 0, args, numargs, t, VK,
56f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall               operatorloc),
57063daf6e196c51f162e0485478355d8e280eef5cDouglas Gregor      Operator(Op) {}
581eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  explicit CXXOperatorCallExpr(ASTContext& C, EmptyShell Empty) :
59ba0a9006dbc4814e1e35f82812cb5a1dad65e8b8Argyrios Kyrtzidis    CallExpr(C, CXXOperatorCallExprClass, Empty) { }
601eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
61b4609806e9232593ece09ce08b630836e825865cDouglas Gregor
62b4609806e9232593ece09ce08b630836e825865cDouglas Gregor  /// getOperator - Returns the kind of overloaded operator that this
63b4609806e9232593ece09ce08b630836e825865cDouglas Gregor  /// expression refers to.
64063daf6e196c51f162e0485478355d8e280eef5cDouglas Gregor  OverloadedOperatorKind getOperator() const { return Operator; }
65ba0a9006dbc4814e1e35f82812cb5a1dad65e8b8Argyrios Kyrtzidis  void setOperator(OverloadedOperatorKind Kind) { Operator = Kind; }
66b4609806e9232593ece09ce08b630836e825865cDouglas Gregor
67b4609806e9232593ece09ce08b630836e825865cDouglas Gregor  /// getOperatorLoc - Returns the location of the operator symbol in
68b4609806e9232593ece09ce08b630836e825865cDouglas Gregor  /// the expression. When @c getOperator()==OO_Call, this is the
69b4609806e9232593ece09ce08b630836e825865cDouglas Gregor  /// location of the right parentheses; when @c
70b4609806e9232593ece09ce08b630836e825865cDouglas Gregor  /// getOperator()==OO_Subscript, this is the location of the right
71b4609806e9232593ece09ce08b630836e825865cDouglas Gregor  /// bracket.
72b4609806e9232593ece09ce08b630836e825865cDouglas Gregor  SourceLocation getOperatorLoc() const { return getRParenLoc(); }
73b4609806e9232593ece09ce08b630836e825865cDouglas Gregor
7463c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall  SourceRange getSourceRange() const;
751eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
761eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  static bool classof(const Stmt *T) {
771eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump    return T->getStmtClass() == CXXOperatorCallExprClass;
78b4609806e9232593ece09ce08b630836e825865cDouglas Gregor  }
79b4609806e9232593ece09ce08b630836e825865cDouglas Gregor  static bool classof(const CXXOperatorCallExpr *) { return true; }
80b4609806e9232593ece09ce08b630836e825865cDouglas Gregor};
81b4609806e9232593ece09ce08b630836e825865cDouglas Gregor
8288a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor/// CXXMemberCallExpr - Represents a call to a member function that
8388a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor/// may be written either with member call syntax (e.g., "obj.func()"
8488a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor/// or "objptr->func()") or with normal function-call syntax
8588a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor/// ("func()") within a member function that ends up calling a member
8688a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor/// function. The callee in either case is a MemberExpr that contains
8788a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor/// both the object argument and the member function, while the
8888a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor/// arguments are the arguments within the parentheses (not including
8988a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor/// the object argument).
9088a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregorclass CXXMemberCallExpr : public CallExpr {
9188a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregorpublic:
921817bd483b538fd3f4530649f5cb900bad9e8a76Chris Lattner  CXXMemberCallExpr(ASTContext &C, Expr *fn, Expr **args, unsigned numargs,
93f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall                    QualType t, ExprValueKind VK, SourceLocation RP)
94cc324ad80ab940efca006b0064f7ca70a6181816Peter Collingbourne    : CallExpr(C, CXXMemberCallExprClass, fn, 0, args, numargs, t, VK, RP) {}
9588a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor
961817bd483b538fd3f4530649f5cb900bad9e8a76Chris Lattner  CXXMemberCallExpr(ASTContext &C, EmptyShell Empty)
971817bd483b538fd3f4530649f5cb900bad9e8a76Chris Lattner    : CallExpr(C, CXXMemberCallExprClass, Empty) { }
981817bd483b538fd3f4530649f5cb900bad9e8a76Chris Lattner
9988a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor  /// getImplicitObjectArgument - Retrieves the implicit object
10088a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor  /// argument for the member call. For example, in "x.f(5)", this
10188a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor  /// operation would return "x".
10288a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor  Expr *getImplicitObjectArgument();
10388a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor
104007a9b1c632bfaac20e41c60cbe07fdc6d0e647cChandler Carruth  /// getRecordDecl - Retrieves the CXXRecordDecl for the underlying type of
105007a9b1c632bfaac20e41c60cbe07fdc6d0e647cChandler Carruth  /// the implicit object argument. Note that this is may not be the same
106007a9b1c632bfaac20e41c60cbe07fdc6d0e647cChandler Carruth  /// declaration as that of the class context of the CXXMethodDecl which this
107007a9b1c632bfaac20e41c60cbe07fdc6d0e647cChandler Carruth  /// function is calling.
108007a9b1c632bfaac20e41c60cbe07fdc6d0e647cChandler Carruth  /// FIXME: Returns 0 for member pointer call exprs.
109007a9b1c632bfaac20e41c60cbe07fdc6d0e647cChandler Carruth  CXXRecordDecl *getRecordDecl();
110007a9b1c632bfaac20e41c60cbe07fdc6d0e647cChandler Carruth
11163c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall  SourceRange getSourceRange() const;
11200b98c229ef28a5e82943bb23d09fb46d24ca381Douglas Gregor
1131eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  static bool classof(const Stmt *T) {
11488a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor    return T->getStmtClass() == CXXMemberCallExprClass;
11588a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor  }
11688a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor  static bool classof(const CXXMemberCallExpr *) { return true; }
11788a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor};
11888a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor
11949badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// CXXNamedCastExpr - Abstract class common to all of the C++ "named"
12049badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// casts, @c static_cast, @c dynamic_cast, @c reinterpret_cast, or @c
12149badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// const_cast.
12249badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor///
12349badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// This abstract class is inherited by all of the classes
12449badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// representing "named" casts, e.g., CXXStaticCastExpr,
12549badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// CXXDynamicCastExpr, CXXReinterpretCastExpr, and CXXConstCastExpr.
12649badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregorclass CXXNamedCastExpr : public ExplicitCastExpr {
1271060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenekprivate:
1281060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  SourceLocation Loc; // the location of the casting op
1291d5d0b9df6d2a3df338bc3e63000536406e7666cDouglas Gregor  SourceLocation RParenLoc; // the location of the right parenthesis
1301d5d0b9df6d2a3df338bc3e63000536406e7666cDouglas Gregor
13149badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregorprotected:
132f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall  CXXNamedCastExpr(StmtClass SC, QualType ty, ExprValueKind VK,
133f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall                   CastKind kind, Expr *op, unsigned PathSize,
1341d5d0b9df6d2a3df338bc3e63000536406e7666cDouglas Gregor                   TypeSourceInfo *writtenTy, SourceLocation l,
1351d5d0b9df6d2a3df338bc3e63000536406e7666cDouglas Gregor                   SourceLocation RParenLoc)
1361d5d0b9df6d2a3df338bc3e63000536406e7666cDouglas Gregor    : ExplicitCastExpr(SC, ty, VK, kind, op, PathSize, writtenTy), Loc(l),
1371d5d0b9df6d2a3df338bc3e63000536406e7666cDouglas Gregor      RParenLoc(RParenLoc) {}
13849badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor
139f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall  explicit CXXNamedCastExpr(StmtClass SC, EmptyShell Shell, unsigned PathSize)
140f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall    : ExplicitCastExpr(SC, Shell, PathSize) { }
141ce757a7a1ee905f87551996a69da3e95e8afeeb7Sam Weinig
1421d5d0b9df6d2a3df338bc3e63000536406e7666cDouglas Gregor  friend class ASTStmtReader;
1431d5d0b9df6d2a3df338bc3e63000536406e7666cDouglas Gregor
1441060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenekpublic:
14549badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor  const char *getCastName() const;
14649badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor
147a3a7b8eea87c90a5a257f685749222b212ddaf36Douglas Gregor  /// \brief Retrieve the location of the cast operator keyword, e.g.,
148a3a7b8eea87c90a5a257f685749222b212ddaf36Douglas Gregor  /// "static_cast".
149a3a7b8eea87c90a5a257f685749222b212ddaf36Douglas Gregor  SourceLocation getOperatorLoc() const { return Loc; }
150a3a7b8eea87c90a5a257f685749222b212ddaf36Douglas Gregor
1511d5d0b9df6d2a3df338bc3e63000536406e7666cDouglas Gregor  /// \brief Retrieve the location of the closing parenthesis.
1521d5d0b9df6d2a3df338bc3e63000536406e7666cDouglas Gregor  SourceLocation getRParenLoc() const { return RParenLoc; }
1531d5d0b9df6d2a3df338bc3e63000536406e7666cDouglas Gregor
15463c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall  SourceRange getSourceRange() const {
1551d5d0b9df6d2a3df338bc3e63000536406e7666cDouglas Gregor    return SourceRange(Loc, RParenLoc);
1561060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  }
1571eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  static bool classof(const Stmt *T) {
15849badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor    switch (T->getStmtClass()) {
15949badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor    case CXXStaticCastExprClass:
16049badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor    case CXXDynamicCastExprClass:
16149badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor    case CXXReinterpretCastExprClass:
16249badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor    case CXXConstCastExprClass:
16349badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor      return true;
16449badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor    default:
16549badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor      return false;
16649badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor    }
1671060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  }
16849badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor  static bool classof(const CXXNamedCastExpr *) { return true; }
16949badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor};
17049badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor
17149badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// CXXStaticCastExpr - A C++ @c static_cast expression (C++ [expr.static.cast]).
1721eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump///
17349badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// This expression node represents a C++ static cast, e.g.,
17449badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// @c static_cast<int>(1.0).
17549badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregorclass CXXStaticCastExpr : public CXXNamedCastExpr {
176f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall  CXXStaticCastExpr(QualType ty, ExprValueKind vk, CastKind kind, Expr *op,
177f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall                    unsigned pathSize, TypeSourceInfo *writtenTy,
1781d5d0b9df6d2a3df338bc3e63000536406e7666cDouglas Gregor                    SourceLocation l, SourceLocation RParenLoc)
179f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall    : CXXNamedCastExpr(CXXStaticCastExprClass, ty, vk, kind, op, pathSize,
1801d5d0b9df6d2a3df338bc3e63000536406e7666cDouglas Gregor                       writtenTy, l, RParenLoc) {}
18149badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor
182f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall  explicit CXXStaticCastExpr(EmptyShell Empty, unsigned PathSize)
183f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall    : CXXNamedCastExpr(CXXStaticCastExprClass, Empty, PathSize) { }
184f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall
185f871d0cc377a1367b519a6cce26be74607566ebaJohn McCallpublic:
186f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall  static CXXStaticCastExpr *Create(ASTContext &Context, QualType T,
187f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall                                   ExprValueKind VK, CastKind K, Expr *Op,
188f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall                                   const CXXCastPath *Path,
1891d5d0b9df6d2a3df338bc3e63000536406e7666cDouglas Gregor                                   TypeSourceInfo *Written, SourceLocation L,
1901d5d0b9df6d2a3df338bc3e63000536406e7666cDouglas Gregor                                   SourceLocation RParenLoc);
191f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall  static CXXStaticCastExpr *CreateEmpty(ASTContext &Context,
192f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall                                        unsigned PathSize);
193ce757a7a1ee905f87551996a69da3e95e8afeeb7Sam Weinig
1941eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  static bool classof(const Stmt *T) {
19549badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor    return T->getStmtClass() == CXXStaticCastExprClass;
19649badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor  }
19749badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor  static bool classof(const CXXStaticCastExpr *) { return true; }
19849badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor};
19949badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor
20049badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// CXXDynamicCastExpr - A C++ @c dynamic_cast expression
2011eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump/// (C++ [expr.dynamic.cast]), which may perform a run-time check to
20249badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// determine how to perform the type cast.
2031eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump///
20449badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// This expression node represents a dynamic cast, e.g.,
20549badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// @c dynamic_cast<Derived*>(BasePtr).
20649badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregorclass CXXDynamicCastExpr : public CXXNamedCastExpr {
207f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall  CXXDynamicCastExpr(QualType ty, ExprValueKind VK, CastKind kind,
208f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall                     Expr *op, unsigned pathSize, TypeSourceInfo *writtenTy,
2091d5d0b9df6d2a3df338bc3e63000536406e7666cDouglas Gregor                     SourceLocation l, SourceLocation RParenLoc)
210f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall    : CXXNamedCastExpr(CXXDynamicCastExprClass, ty, VK, kind, op, pathSize,
2111d5d0b9df6d2a3df338bc3e63000536406e7666cDouglas Gregor                       writtenTy, l, RParenLoc) {}
21249badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor
213f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall  explicit CXXDynamicCastExpr(EmptyShell Empty, unsigned pathSize)
214f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall    : CXXNamedCastExpr(CXXDynamicCastExprClass, Empty, pathSize) { }
215f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall
216f871d0cc377a1367b519a6cce26be74607566ebaJohn McCallpublic:
217f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall  static CXXDynamicCastExpr *Create(ASTContext &Context, QualType T,
218f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall                                    ExprValueKind VK, CastKind Kind, Expr *Op,
219f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall                                    const CXXCastPath *Path,
2201d5d0b9df6d2a3df338bc3e63000536406e7666cDouglas Gregor                                    TypeSourceInfo *Written, SourceLocation L,
2211d5d0b9df6d2a3df338bc3e63000536406e7666cDouglas Gregor                                    SourceLocation RParenLoc);
222f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall
223f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall  static CXXDynamicCastExpr *CreateEmpty(ASTContext &Context,
224f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall                                         unsigned pathSize);
225ce757a7a1ee905f87551996a69da3e95e8afeeb7Sam Weinig
2261eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  static bool classof(const Stmt *T) {
22749badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor    return T->getStmtClass() == CXXDynamicCastExprClass;
22849badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor  }
22949badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor  static bool classof(const CXXDynamicCastExpr *) { return true; }
23049badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor};
23149badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor
23249badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// CXXReinterpretCastExpr - A C++ @c reinterpret_cast expression (C++
23349badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// [expr.reinterpret.cast]), which provides a differently-typed view
23449badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// of a value but performs no actual work at run time.
2351eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump///
23649badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// This expression node represents a reinterpret cast, e.g.,
23749badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// @c reinterpret_cast<int>(VoidPtr).
23849badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregorclass CXXReinterpretCastExpr : public CXXNamedCastExpr {
239f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall  CXXReinterpretCastExpr(QualType ty, ExprValueKind vk, CastKind kind,
240f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall                         Expr *op, unsigned pathSize,
2411d5d0b9df6d2a3df338bc3e63000536406e7666cDouglas Gregor                         TypeSourceInfo *writtenTy, SourceLocation l,
2421d5d0b9df6d2a3df338bc3e63000536406e7666cDouglas Gregor                         SourceLocation RParenLoc)
243f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall    : CXXNamedCastExpr(CXXReinterpretCastExprClass, ty, vk, kind, op,
2441d5d0b9df6d2a3df338bc3e63000536406e7666cDouglas Gregor                       pathSize, writtenTy, l, RParenLoc) {}
24549badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor
246f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall  CXXReinterpretCastExpr(EmptyShell Empty, unsigned pathSize)
247f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall    : CXXNamedCastExpr(CXXReinterpretCastExprClass, Empty, pathSize) { }
248f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall
249f871d0cc377a1367b519a6cce26be74607566ebaJohn McCallpublic:
250f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall  static CXXReinterpretCastExpr *Create(ASTContext &Context, QualType T,
251f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall                                        ExprValueKind VK, CastKind Kind,
252f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall                                        Expr *Op, const CXXCastPath *Path,
2531d5d0b9df6d2a3df338bc3e63000536406e7666cDouglas Gregor                                 TypeSourceInfo *WrittenTy, SourceLocation L,
2541d5d0b9df6d2a3df338bc3e63000536406e7666cDouglas Gregor                                        SourceLocation RParenLoc);
255f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall  static CXXReinterpretCastExpr *CreateEmpty(ASTContext &Context,
256f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall                                             unsigned pathSize);
257ce757a7a1ee905f87551996a69da3e95e8afeeb7Sam Weinig
2581eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  static bool classof(const Stmt *T) {
25949badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor    return T->getStmtClass() == CXXReinterpretCastExprClass;
26049badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor  }
26149badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor  static bool classof(const CXXReinterpretCastExpr *) { return true; }
26249badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor};
26349badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor
26449badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// CXXConstCastExpr - A C++ @c const_cast expression (C++ [expr.const.cast]),
26549badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// which can remove type qualifiers but does not change the underlying value.
2661eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump///
26749badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// This expression node represents a const cast, e.g.,
26849badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// @c const_cast<char*>(PtrToConstChar).
26949badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregorclass CXXConstCastExpr : public CXXNamedCastExpr {
270f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall  CXXConstCastExpr(QualType ty, ExprValueKind VK, Expr *op,
2711d5d0b9df6d2a3df338bc3e63000536406e7666cDouglas Gregor                   TypeSourceInfo *writtenTy, SourceLocation l,
2721d5d0b9df6d2a3df338bc3e63000536406e7666cDouglas Gregor                   SourceLocation RParenLoc)
273f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall    : CXXNamedCastExpr(CXXConstCastExprClass, ty, VK, CK_NoOp, op,
2741d5d0b9df6d2a3df338bc3e63000536406e7666cDouglas Gregor                       0, writtenTy, l, RParenLoc) {}
27549badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor
276ce757a7a1ee905f87551996a69da3e95e8afeeb7Sam Weinig  explicit CXXConstCastExpr(EmptyShell Empty)
277f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall    : CXXNamedCastExpr(CXXConstCastExprClass, Empty, 0) { }
278f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall
279f871d0cc377a1367b519a6cce26be74607566ebaJohn McCallpublic:
280f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall  static CXXConstCastExpr *Create(ASTContext &Context, QualType T,
281f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall                                  ExprValueKind VK, Expr *Op,
2821d5d0b9df6d2a3df338bc3e63000536406e7666cDouglas Gregor                                  TypeSourceInfo *WrittenTy, SourceLocation L,
2831d5d0b9df6d2a3df338bc3e63000536406e7666cDouglas Gregor                                  SourceLocation RParenLoc);
284f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall  static CXXConstCastExpr *CreateEmpty(ASTContext &Context);
285ce757a7a1ee905f87551996a69da3e95e8afeeb7Sam Weinig
2861eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  static bool classof(const Stmt *T) {
28749badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor    return T->getStmtClass() == CXXConstCastExprClass;
28849badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor  }
28949badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor  static bool classof(const CXXConstCastExpr *) { return true; }
2901060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek};
2911060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek
2921060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek/// CXXBoolLiteralExpr - [C++ 2.13.5] C++ Boolean Literal.
2931eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump///
2941060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenekclass CXXBoolLiteralExpr : public Expr {
2951060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  bool Value;
2961060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  SourceLocation Loc;
2971060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenekpublic:
2981eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  CXXBoolLiteralExpr(bool val, QualType Ty, SourceLocation l) :
299bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor    Expr(CXXBoolLiteralExprClass, Ty, VK_RValue, OK_Ordinary, false, false,
300bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor         false),
301f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall    Value(val), Loc(l) {}
3028b0b475b3464b0f70b91ba7d679d23c424677d5eSebastian Redl
303eb7f96141f754150a92433286fa385910a22f494Sam Weinig  explicit CXXBoolLiteralExpr(EmptyShell Empty)
304eb7f96141f754150a92433286fa385910a22f494Sam Weinig    : Expr(CXXBoolLiteralExprClass, Empty) { }
305eb7f96141f754150a92433286fa385910a22f494Sam Weinig
3061060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  bool getValue() const { return Value; }
307eb7f96141f754150a92433286fa385910a22f494Sam Weinig  void setValue(bool V) { Value = V; }
3085f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer
30963c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall  SourceRange getSourceRange() const { return SourceRange(Loc); }
3101eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
311eb7f96141f754150a92433286fa385910a22f494Sam Weinig  SourceLocation getLocation() const { return Loc; }
312eb7f96141f754150a92433286fa385910a22f494Sam Weinig  void setLocation(SourceLocation L) { Loc = L; }
313eb7f96141f754150a92433286fa385910a22f494Sam Weinig
3141eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  static bool classof(const Stmt *T) {
3151060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek    return T->getStmtClass() == CXXBoolLiteralExprClass;
3161060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  }
3171060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  static bool classof(const CXXBoolLiteralExpr *) { return true; }
3181eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
3191060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  // Iterators
32063c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall  child_range children() { return child_range(); }
3211060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek};
3221060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek
3236e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl/// CXXNullPtrLiteralExpr - [C++0x 2.14.7] C++ Pointer Literal
3246e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redlclass CXXNullPtrLiteralExpr : public Expr {
3256e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl  SourceLocation Loc;
3266e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redlpublic:
3276e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl  CXXNullPtrLiteralExpr(QualType Ty, SourceLocation l) :
328bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor    Expr(CXXNullPtrLiteralExprClass, Ty, VK_RValue, OK_Ordinary, false, false,
329bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor         false),
330f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall    Loc(l) {}
3316e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl
332eb7f96141f754150a92433286fa385910a22f494Sam Weinig  explicit CXXNullPtrLiteralExpr(EmptyShell Empty)
333eb7f96141f754150a92433286fa385910a22f494Sam Weinig    : Expr(CXXNullPtrLiteralExprClass, Empty) { }
334eb7f96141f754150a92433286fa385910a22f494Sam Weinig
33563c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall  SourceRange getSourceRange() const { return SourceRange(Loc); }
3366e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl
337eb7f96141f754150a92433286fa385910a22f494Sam Weinig  SourceLocation getLocation() const { return Loc; }
338eb7f96141f754150a92433286fa385910a22f494Sam Weinig  void setLocation(SourceLocation L) { Loc = L; }
339eb7f96141f754150a92433286fa385910a22f494Sam Weinig
3406e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl  static bool classof(const Stmt *T) {
3416e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl    return T->getStmtClass() == CXXNullPtrLiteralExprClass;
3426e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl  }
3436e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl  static bool classof(const CXXNullPtrLiteralExpr *) { return true; }
3446e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl
34563c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall  child_range children() { return child_range(); }
3466e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl};
3476e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl
348c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl/// CXXTypeidExpr - A C++ @c typeid expression (C++ [expr.typeid]), which gets
349c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl/// the type_info that corresponds to the supplied type, or the (possibly
350c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl/// dynamic) type of the supplied expression.
351c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl///
352c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl/// This represents code like @c typeid(int) or @c typeid(*objPtr)
353c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redlclass CXXTypeidExpr : public Expr {
354c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redlprivate:
35557fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor  llvm::PointerUnion<Stmt *, TypeSourceInfo *> Operand;
356c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl  SourceRange Range;
357c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl
358c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redlpublic:
35957fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor  CXXTypeidExpr(QualType Ty, TypeSourceInfo *Operand, SourceRange R)
360f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall    : Expr(CXXTypeidExprClass, Ty, VK_LValue, OK_Ordinary,
36157fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor           // typeid is never type-dependent (C++ [temp.dep.expr]p4)
36257fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor           false,
36357fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor           // typeid is value-dependent if the type or expression are dependent
364bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor           Operand->getType()->isDependentType(),
365bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor           Operand->getType()->containsUnexpandedParameterPack()),
36657fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor      Operand(Operand), Range(R) { }
36757fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor
36857fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor  CXXTypeidExpr(QualType Ty, Expr *Operand, SourceRange R)
369f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall    : Expr(CXXTypeidExprClass, Ty, VK_LValue, OK_Ordinary,
3702850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl        // typeid is never type-dependent (C++ [temp.dep.expr]p4)
371bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor           false,
3722850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl        // typeid is value-dependent if the type or expression are dependent
373bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor           Operand->isTypeDependent() || Operand->isValueDependent(),
374bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor           Operand->containsUnexpandedParameterPack()),
37557fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor      Operand(Operand), Range(R) { }
376c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl
37714ab24f01e36d495fce183aa67b41e45cdd54f39Chris Lattner  CXXTypeidExpr(EmptyShell Empty, bool isExpr)
37814ab24f01e36d495fce183aa67b41e45cdd54f39Chris Lattner    : Expr(CXXTypeidExprClass, Empty) {
37914ab24f01e36d495fce183aa67b41e45cdd54f39Chris Lattner    if (isExpr)
38014ab24f01e36d495fce183aa67b41e45cdd54f39Chris Lattner      Operand = (Expr*)0;
38114ab24f01e36d495fce183aa67b41e45cdd54f39Chris Lattner    else
38214ab24f01e36d495fce183aa67b41e45cdd54f39Chris Lattner      Operand = (TypeSourceInfo*)0;
38314ab24f01e36d495fce183aa67b41e45cdd54f39Chris Lattner  }
38414ab24f01e36d495fce183aa67b41e45cdd54f39Chris Lattner
38557fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor  bool isTypeOperand() const { return Operand.is<TypeSourceInfo *>(); }
38657fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor
38757fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor  /// \brief Retrieves the type operand of this typeid() expression after
38857fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor  /// various required adjustments (removing reference types, cv-qualifiers).
38957fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor  QualType getTypeOperand() const;
39057fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor
39157fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor  /// \brief Retrieve source information for the type operand.
39257fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor  TypeSourceInfo *getTypeOperandSourceInfo() const {
393c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl    assert(isTypeOperand() && "Cannot call getTypeOperand for typeid(expr)");
39457fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor    return Operand.get<TypeSourceInfo *>();
395c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl  }
39614ab24f01e36d495fce183aa67b41e45cdd54f39Chris Lattner
39714ab24f01e36d495fce183aa67b41e45cdd54f39Chris Lattner  void setTypeOperandSourceInfo(TypeSourceInfo *TSI) {
39814ab24f01e36d495fce183aa67b41e45cdd54f39Chris Lattner    assert(isTypeOperand() && "Cannot call getTypeOperand for typeid(expr)");
39914ab24f01e36d495fce183aa67b41e45cdd54f39Chris Lattner    Operand = TSI;
40014ab24f01e36d495fce183aa67b41e45cdd54f39Chris Lattner  }
40157fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor
40214ab24f01e36d495fce183aa67b41e45cdd54f39Chris Lattner  Expr *getExprOperand() const {
403c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl    assert(!isTypeOperand() && "Cannot call getExprOperand for typeid(type)");
40457fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor    return static_cast<Expr*>(Operand.get<Stmt *>());
405c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl  }
40614ab24f01e36d495fce183aa67b41e45cdd54f39Chris Lattner
407030854b95f7bfd86aaa8afd9ae1aff9768a37e9aChris Lattner  void setExprOperand(Expr *E) {
408030854b95f7bfd86aaa8afd9ae1aff9768a37e9aChris Lattner    assert(!isTypeOperand() && "Cannot call getExprOperand for typeid(type)");
409030854b95f7bfd86aaa8afd9ae1aff9768a37e9aChris Lattner    Operand = E;
410030854b95f7bfd86aaa8afd9ae1aff9768a37e9aChris Lattner  }
411030854b95f7bfd86aaa8afd9ae1aff9768a37e9aChris Lattner
41263c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall  SourceRange getSourceRange() const { return Range; }
41314ab24f01e36d495fce183aa67b41e45cdd54f39Chris Lattner  void setSourceRange(SourceRange R) { Range = R; }
41414ab24f01e36d495fce183aa67b41e45cdd54f39Chris Lattner
415c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl  static bool classof(const Stmt *T) {
416c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl    return T->getStmtClass() == CXXTypeidExprClass;
417c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl  }
418c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl  static bool classof(const CXXTypeidExpr *) { return true; }
419c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl
420c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl  // Iterators
42163c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall  child_range children() {
42263c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall    if (isTypeOperand()) return child_range();
42363c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall    Stmt **begin = reinterpret_cast<Stmt**>(&Operand);
42463c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall    return child_range(begin, begin + 1);
42563c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall  }
426c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl};
427c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl
42801b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet/// CXXUuidofExpr - A microsoft C++ @c __uuidof expression, which gets
42901b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet/// the _GUID that corresponds to the supplied type or expression.
43001b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet///
43101b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet/// This represents code like @c __uuidof(COMTYPE) or @c __uuidof(*comPtr)
43201b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichetclass CXXUuidofExpr : public Expr {
43301b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichetprivate:
43401b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet  llvm::PointerUnion<Stmt *, TypeSourceInfo *> Operand;
43501b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet  SourceRange Range;
43601b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet
43701b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichetpublic:
43801b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet  CXXUuidofExpr(QualType Ty, TypeSourceInfo *Operand, SourceRange R)
4392e219b8d253dbb901206b14e5643cc9d0edd662bFrancois Pichet    : Expr(CXXUuidofExprClass, Ty, VK_LValue, OK_Ordinary,
440bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor           false, Operand->getType()->isDependentType(),
441bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor           Operand->getType()->containsUnexpandedParameterPack()),
44201b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet      Operand(Operand), Range(R) { }
44301b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet
44401b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet  CXXUuidofExpr(QualType Ty, Expr *Operand, SourceRange R)
4452e219b8d253dbb901206b14e5643cc9d0edd662bFrancois Pichet    : Expr(CXXUuidofExprClass, Ty, VK_LValue, OK_Ordinary,
446bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor           false, Operand->isTypeDependent(),
447bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor           Operand->containsUnexpandedParameterPack()),
44801b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet      Operand(Operand), Range(R) { }
44901b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet
45001b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet  CXXUuidofExpr(EmptyShell Empty, bool isExpr)
45101b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet    : Expr(CXXUuidofExprClass, Empty) {
45201b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet    if (isExpr)
45301b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet      Operand = (Expr*)0;
45401b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet    else
45501b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet      Operand = (TypeSourceInfo*)0;
45601b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet  }
45701b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet
45801b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet  bool isTypeOperand() const { return Operand.is<TypeSourceInfo *>(); }
45901b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet
46001b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet  /// \brief Retrieves the type operand of this __uuidof() expression after
46101b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet  /// various required adjustments (removing reference types, cv-qualifiers).
46201b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet  QualType getTypeOperand() const;
46301b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet
46401b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet  /// \brief Retrieve source information for the type operand.
46501b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet  TypeSourceInfo *getTypeOperandSourceInfo() const {
46601b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet    assert(isTypeOperand() && "Cannot call getTypeOperand for __uuidof(expr)");
46701b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet    return Operand.get<TypeSourceInfo *>();
46801b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet  }
46901b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet
47001b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet  void setTypeOperandSourceInfo(TypeSourceInfo *TSI) {
47101b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet    assert(isTypeOperand() && "Cannot call getTypeOperand for __uuidof(expr)");
47201b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet    Operand = TSI;
47301b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet  }
47401b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet
47501b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet  Expr *getExprOperand() const {
47601b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet    assert(!isTypeOperand() && "Cannot call getExprOperand for __uuidof(type)");
47701b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet    return static_cast<Expr*>(Operand.get<Stmt *>());
47801b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet  }
47901b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet
48001b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet  void setExprOperand(Expr *E) {
48101b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet    assert(!isTypeOperand() && "Cannot call getExprOperand for __uuidof(type)");
48201b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet    Operand = E;
48301b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet  }
48401b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet
48563c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall  SourceRange getSourceRange() const { return Range; }
48601b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet  void setSourceRange(SourceRange R) { Range = R; }
48701b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet
48801b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet  static bool classof(const Stmt *T) {
48901b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet    return T->getStmtClass() == CXXUuidofExprClass;
49001b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet  }
49101b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet  static bool classof(const CXXUuidofExpr *) { return true; }
49201b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet
49301b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet  // Iterators
49463c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall  child_range children() {
49563c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall    if (isTypeOperand()) return child_range();
49663c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall    Stmt **begin = reinterpret_cast<Stmt**>(&Operand);
49763c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall    return child_range(begin, begin + 1);
49863c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall  }
49901b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet};
50001b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet
501796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// CXXThisExpr - Represents the "this" expression in C++, which is a
502796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// pointer to the object on which the current member function is
503796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// executing (C++ [expr.prim]p3). Example:
504796da18402f286b897782a298ae3b20c459c102eDouglas Gregor///
505796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// @code
506796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// class Foo {
507796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// public:
508796da18402f286b897782a298ae3b20c459c102eDouglas Gregor///   void bar();
509796da18402f286b897782a298ae3b20c459c102eDouglas Gregor///   void test() { this->bar(); }
510796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// };
511796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// @endcode
512796da18402f286b897782a298ae3b20c459c102eDouglas Gregorclass CXXThisExpr : public Expr {
513796da18402f286b897782a298ae3b20c459c102eDouglas Gregor  SourceLocation Loc;
514828a197317288e3333b0ce6f5cedadd036e3531fDouglas Gregor  bool Implicit : 1;
515828a197317288e3333b0ce6f5cedadd036e3531fDouglas Gregor
516796da18402f286b897782a298ae3b20c459c102eDouglas Gregorpublic:
517828a197317288e3333b0ce6f5cedadd036e3531fDouglas Gregor  CXXThisExpr(SourceLocation L, QualType Type, bool isImplicit)
518f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall    : Expr(CXXThisExprClass, Type, VK_RValue, OK_Ordinary,
5192850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl           // 'this' is type-dependent if the class type of the enclosing
5202850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl           // member function is dependent (C++ [temp.dep.expr]p2)
521bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor           Type->isDependentType(), Type->isDependentType(),
522bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor           /*ContainsUnexpandedParameterPack=*/false),
523828a197317288e3333b0ce6f5cedadd036e3531fDouglas Gregor      Loc(L), Implicit(isImplicit) { }
524796da18402f286b897782a298ae3b20c459c102eDouglas Gregor
5252fbdfcdf3bbf7b941853d38b123930755e837437Chris Lattner  CXXThisExpr(EmptyShell Empty) : Expr(CXXThisExprClass, Empty) {}
5262fbdfcdf3bbf7b941853d38b123930755e837437Chris Lattner
5272fbdfcdf3bbf7b941853d38b123930755e837437Chris Lattner  SourceLocation getLocation() const { return Loc; }
5282fbdfcdf3bbf7b941853d38b123930755e837437Chris Lattner  void setLocation(SourceLocation L) { Loc = L; }
5292fbdfcdf3bbf7b941853d38b123930755e837437Chris Lattner
53063c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall  SourceRange getSourceRange() const { return SourceRange(Loc); }
531796da18402f286b897782a298ae3b20c459c102eDouglas Gregor
532828a197317288e3333b0ce6f5cedadd036e3531fDouglas Gregor  bool isImplicit() const { return Implicit; }
533828a197317288e3333b0ce6f5cedadd036e3531fDouglas Gregor  void setImplicit(bool I) { Implicit = I; }
534828a197317288e3333b0ce6f5cedadd036e3531fDouglas Gregor
5351eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  static bool classof(const Stmt *T) {
536796da18402f286b897782a298ae3b20c459c102eDouglas Gregor    return T->getStmtClass() == CXXThisExprClass;
537796da18402f286b897782a298ae3b20c459c102eDouglas Gregor  }
538796da18402f286b897782a298ae3b20c459c102eDouglas Gregor  static bool classof(const CXXThisExpr *) { return true; }
539796da18402f286b897782a298ae3b20c459c102eDouglas Gregor
540796da18402f286b897782a298ae3b20c459c102eDouglas Gregor  // Iterators
54163c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall  child_range children() { return child_range(); }
542796da18402f286b897782a298ae3b20c459c102eDouglas Gregor};
543796da18402f286b897782a298ae3b20c459c102eDouglas Gregor
5441060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek///  CXXThrowExpr - [C++ 15] C++ Throw Expression.  This handles
5451060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek///  'throw' and 'throw' assignment-expression.  When
5461060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek///  assignment-expression isn't present, Op will be null.
5471060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek///
5481060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenekclass CXXThrowExpr : public Expr {
5491060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  Stmt *Op;
5501060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  SourceLocation ThrowLoc;
5511060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenekpublic:
5521060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  // Ty is the void type which is used as the result type of the
5531060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  // exepression.  The l is the location of the throw keyword.  expr
5541060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  // can by null, if the optional expression to throw isn't present.
5551060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  CXXThrowExpr(Expr *expr, QualType Ty, SourceLocation l) :
556bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor    Expr(CXXThrowExprClass, Ty, VK_RValue, OK_Ordinary, false, false,
557bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor         expr && expr->containsUnexpandedParameterPack()),
558f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall    Op(expr), ThrowLoc(l) {}
5592fbdfcdf3bbf7b941853d38b123930755e837437Chris Lattner  CXXThrowExpr(EmptyShell Empty) : Expr(CXXThrowExprClass, Empty) {}
5602fbdfcdf3bbf7b941853d38b123930755e837437Chris Lattner
5611060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  const Expr *getSubExpr() const { return cast_or_null<Expr>(Op); }
5621060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  Expr *getSubExpr() { return cast_or_null<Expr>(Op); }
56342e5b50f4dc897f252e0d476063a7f9846d96624Douglas Gregor  void setSubExpr(Expr *E) { Op = E; }
56442e5b50f4dc897f252e0d476063a7f9846d96624Douglas Gregor
56542e5b50f4dc897f252e0d476063a7f9846d96624Douglas Gregor  SourceLocation getThrowLoc() const { return ThrowLoc; }
56642e5b50f4dc897f252e0d476063a7f9846d96624Douglas Gregor  void setThrowLoc(SourceLocation L) { ThrowLoc = L; }
5671060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek
56863c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall  SourceRange getSourceRange() const {
5691060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek    if (getSubExpr() == 0)
5701060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek      return SourceRange(ThrowLoc, ThrowLoc);
5711060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek    return SourceRange(ThrowLoc, getSubExpr()->getSourceRange().getEnd());
5721060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  }
5731060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek
5741060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  static bool classof(const Stmt *T) {
5751060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek    return T->getStmtClass() == CXXThrowExprClass;
5761060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  }
5771060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  static bool classof(const CXXThrowExpr *) { return true; }
5781060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek
5791060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  // Iterators
58063c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall  child_range children() {
58163c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall    return child_range(&Op, Op ? &Op+1 : &Op);
58263c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall  }
5831060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek};
5841060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek
5851060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek/// CXXDefaultArgExpr - C++ [dcl.fct.default]. This wraps up a
5861060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek/// function call argument that was created from the corresponding
5871060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek/// parameter's default argument, when the call did not explicitly
5881060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek/// supply arguments for all of the parameters.
5891060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenekclass CXXDefaultArgExpr : public Expr {
59065222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor  /// \brief The parameter whose default is being used.
59165222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor  ///
59265222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor  /// When the bit is set, the subexpression is stored after the
59365222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor  /// CXXDefaultArgExpr itself. When the bit is clear, the parameter's
59465222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor  /// actual default expression is the subexpression.
59565222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor  llvm::PointerIntPair<ParmVarDecl *, 1, bool> Param;
5961eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
597036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor  /// \brief The location where the default argument expression was used.
598036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor  SourceLocation Loc;
599036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor
600036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor  CXXDefaultArgExpr(StmtClass SC, SourceLocation Loc, ParmVarDecl *param)
60165222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor    : Expr(SC,
60265222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor           param->hasUnparsedDefaultArg()
60365222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor             ? param->getType().getNonReferenceType()
6042333f7727f97018d6742e1e0938133bcfad967abEli Friedman             : param->getDefaultArg()->getType(),
605dfa1edbebeda7ec3a7a9c45e4317de9241aa9883John McCall           param->getDefaultArg()->getValueKind(),
606bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor           param->getDefaultArg()->getObjectKind(), false, false, false),
607036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor      Param(param, false), Loc(Loc) { }
60865222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor
609036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor  CXXDefaultArgExpr(StmtClass SC, SourceLocation Loc, ParmVarDecl *param,
610036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor                    Expr *SubExpr)
611dfa1edbebeda7ec3a7a9c45e4317de9241aa9883John McCall    : Expr(SC, SubExpr->getType(),
612dfa1edbebeda7ec3a7a9c45e4317de9241aa9883John McCall           SubExpr->getValueKind(), SubExpr->getObjectKind(),
613bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor           false, false, false),
614bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor      Param(param, true), Loc(Loc) {
61565222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor    *reinterpret_cast<Expr **>(this + 1) = SubExpr;
61665222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor  }
61765222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor
6181060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenekpublic:
619030854b95f7bfd86aaa8afd9ae1aff9768a37e9aChris Lattner  CXXDefaultArgExpr(EmptyShell Empty) : Expr(CXXDefaultArgExprClass, Empty) {}
620030854b95f7bfd86aaa8afd9ae1aff9768a37e9aChris Lattner
621030854b95f7bfd86aaa8afd9ae1aff9768a37e9aChris Lattner
6221060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  // Param is the parameter whose default argument is used by this
6231060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  // expression.
624036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor  static CXXDefaultArgExpr *Create(ASTContext &C, SourceLocation Loc,
625036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor                                   ParmVarDecl *Param) {
626036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor    return new (C) CXXDefaultArgExpr(CXXDefaultArgExprClass, Loc, Param);
627f1480eee38b59d15438fb7bc50865ac7c7e22403Anders Carlsson  }
6281060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek
62965222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor  // Param is the parameter whose default argument is used by this
63065222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor  // expression, and SubExpr is the expression that will actually be used.
631036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor  static CXXDefaultArgExpr *Create(ASTContext &C,
632036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor                                   SourceLocation Loc,
633036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor                                   ParmVarDecl *Param,
63465222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor                                   Expr *SubExpr);
63565222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor
6361060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  // Retrieve the parameter that the argument was created from.
63765222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor  const ParmVarDecl *getParam() const { return Param.getPointer(); }
63865222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor  ParmVarDecl *getParam() { return Param.getPointer(); }
639030854b95f7bfd86aaa8afd9ae1aff9768a37e9aChris Lattner
6401060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  // Retrieve the actual argument to the function call.
64165222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor  const Expr *getExpr() const {
64265222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor    if (Param.getInt())
64365222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor      return *reinterpret_cast<Expr const * const*> (this + 1);
64465222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor    return getParam()->getDefaultArg();
64565222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor  }
64665222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor  Expr *getExpr() {
64765222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor    if (Param.getInt())
64865222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor      return *reinterpret_cast<Expr **> (this + 1);
64965222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor    return getParam()->getDefaultArg();
65065222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor  }
6511060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek
652036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor  /// \brief Retrieve the location where this default argument was actually
653036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor  /// used.
654036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor  SourceLocation getUsedLocation() const { return Loc; }
655036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor
65663c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall  SourceRange getSourceRange() const {
6571060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek    // Default argument expressions have no representation in the
6581060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek    // source, so they have an empty source range.
6591060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek    return SourceRange();
6601060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  }
6611060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek
6621060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  static bool classof(const Stmt *T) {
6631060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek    return T->getStmtClass() == CXXDefaultArgExprClass;
6641060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  }
6651060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  static bool classof(const CXXDefaultArgExpr *) { return true; }
6661060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek
6671060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  // Iterators
66863c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall  child_range children() { return child_range(); }
6698a50733034edd6a349b34e2b9f0c8d0a874846d3Argyrios Kyrtzidis
67060adf4acf40b72227740bf966fb87eebddff3f37Sebastian Redl  friend class ASTStmtReader;
6713397c5570369f19b2d6c52e898f708d75ceede1fSebastian Redl  friend class ASTStmtWriter;
6721060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek};
673987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis
674c1ce477119fed070299668aab24084b17ff5f14bAnders Carlsson/// CXXTemporary - Represents a C++ temporary.
675c1ce477119fed070299668aab24084b17ff5f14bAnders Carlssonclass CXXTemporary {
676c1ce477119fed070299668aab24084b17ff5f14bAnders Carlsson  /// Destructor - The destructor that needs to be called.
677b859f35459ae3e1188d1e1b86df08d649695fd86Anders Carlsson  const CXXDestructorDecl *Destructor;
6781eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
679b859f35459ae3e1188d1e1b86df08d649695fd86Anders Carlsson  CXXTemporary(const CXXDestructorDecl *destructor)
680c1ce477119fed070299668aab24084b17ff5f14bAnders Carlsson    : Destructor(destructor) { }
681c1ce477119fed070299668aab24084b17ff5f14bAnders Carlsson
682c1ce477119fed070299668aab24084b17ff5f14bAnders Carlssonpublic:
6831eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  static CXXTemporary *Create(ASTContext &C,
684b859f35459ae3e1188d1e1b86df08d649695fd86Anders Carlsson                              const CXXDestructorDecl *Destructor);
6851eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
686f0721fe438d7e40c168e5d664970e7830bc138fbAnders Carlsson  const CXXDestructorDecl *getDestructor() const { return Destructor; }
687c1ce477119fed070299668aab24084b17ff5f14bAnders Carlsson};
688fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson
689ddfe960d252a93525692b547945236d361d1929fChandler Carruth/// \brief Represents binding an expression to a temporary.
690ddfe960d252a93525692b547945236d361d1929fChandler Carruth///
691ddfe960d252a93525692b547945236d361d1929fChandler Carruth/// This ensures the destructor is called for the temporary. It should only be
692ddfe960d252a93525692b547945236d361d1929fChandler Carruth/// needed for non-POD, non-trivially destructable class types. For example:
693ddfe960d252a93525692b547945236d361d1929fChandler Carruth///
694ddfe960d252a93525692b547945236d361d1929fChandler Carruth/// \code
695ddfe960d252a93525692b547945236d361d1929fChandler Carruth///   struct S {
696ddfe960d252a93525692b547945236d361d1929fChandler Carruth///     S() { }  // User defined constructor makes S non-POD.
697ddfe960d252a93525692b547945236d361d1929fChandler Carruth///     ~S() { } // User defined destructor makes it non-trivial.
698ddfe960d252a93525692b547945236d361d1929fChandler Carruth///   };
699ddfe960d252a93525692b547945236d361d1929fChandler Carruth///   void test() {
700ddfe960d252a93525692b547945236d361d1929fChandler Carruth///     const S &s_ref = S(); // Requires a CXXBindTemporaryExpr.
701ddfe960d252a93525692b547945236d361d1929fChandler Carruth///   }
702ddfe960d252a93525692b547945236d361d1929fChandler Carruth/// \endcode
703fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlssonclass CXXBindTemporaryExpr : public Expr {
704fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson  CXXTemporary *Temp;
7051eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
706fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson  Stmt *SubExpr;
707fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson
708bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor  CXXBindTemporaryExpr(CXXTemporary *temp, Expr* SubExpr)
709bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor   : Expr(CXXBindTemporaryExprClass, SubExpr->getType(),
710bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor          VK_RValue, OK_Ordinary, SubExpr->isTypeDependent(),
711bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor          SubExpr->isValueDependent(),
712bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor          SubExpr->containsUnexpandedParameterPack()),
713bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor     Temp(temp), SubExpr(SubExpr) { }
71488eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlsson
715fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlssonpublic:
716d2598368876cfe40bc8465540033bc5b5e58d8afChris Lattner  CXXBindTemporaryExpr(EmptyShell Empty)
717d2598368876cfe40bc8465540033bc5b5e58d8afChris Lattner    : Expr(CXXBindTemporaryExprClass, Empty), Temp(0), SubExpr(0) {}
718d2598368876cfe40bc8465540033bc5b5e58d8afChris Lattner
7191eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  static CXXBindTemporaryExpr *Create(ASTContext &C, CXXTemporary *Temp,
720fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson                                      Expr* SubExpr);
7211eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
72288eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlsson  CXXTemporary *getTemporary() { return Temp; }
723f0721fe438d7e40c168e5d664970e7830bc138fbAnders Carlsson  const CXXTemporary *getTemporary() const { return Temp; }
724d2598368876cfe40bc8465540033bc5b5e58d8afChris Lattner  void setTemporary(CXXTemporary *T) { Temp = T; }
725f0721fe438d7e40c168e5d664970e7830bc138fbAnders Carlsson
726fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson  const Expr *getSubExpr() const { return cast<Expr>(SubExpr); }
727fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson  Expr *getSubExpr() { return cast<Expr>(SubExpr); }
72888eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlsson  void setSubExpr(Expr *E) { SubExpr = E; }
729fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson
73063c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall  SourceRange getSourceRange() const {
73196be6917e1c4ba1f4435a14c9e7c6c139571d086Douglas Gregor    return SubExpr->getSourceRange();
73296be6917e1c4ba1f4435a14c9e7c6c139571d086Douglas Gregor  }
733fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson
734fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson  // Implement isa/cast/dyncast/etc.
735fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson  static bool classof(const Stmt *T) {
736fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson    return T->getStmtClass() == CXXBindTemporaryExprClass;
737fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson  }
738fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson  static bool classof(const CXXBindTemporaryExpr *) { return true; }
739fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson
740fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson  // Iterators
74163c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall  child_range children() { return child_range(&SubExpr, &SubExpr + 1); }
742fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson};
743fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson
74415ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson/// CXXConstructExpr - Represents a call to a C++ constructor.
74515ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlssonclass CXXConstructExpr : public Expr {
74672e96fd181b19b8d01144a685cda6e955584c7eaAnders Carlssonpublic:
74772e96fd181b19b8d01144a685cda6e955584c7eaAnders Carlsson  enum ConstructionKind {
74872e96fd181b19b8d01144a685cda6e955584c7eaAnders Carlsson    CK_Complete,
74972e96fd181b19b8d01144a685cda6e955584c7eaAnders Carlsson    CK_NonVirtualBase,
75072e96fd181b19b8d01144a685cda6e955584c7eaAnders Carlsson    CK_VirtualBase
75172e96fd181b19b8d01144a685cda6e955584c7eaAnders Carlsson  };
75272e96fd181b19b8d01144a685cda6e955584c7eaAnders Carlsson
75372e96fd181b19b8d01144a685cda6e955584c7eaAnders Carlssonprivate:
75415ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson  CXXConstructorDecl *Constructor;
75515ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson
75699a2e600f9e2e51d3ce10fb6f27191677ac65b2aDouglas Gregor  SourceLocation Loc;
757428edafa9eb80e01dd40aab31d4166a787a741e1Chandler Carruth  SourceRange ParenRange;
75816006c901315fa12a108b4e571f187f4b676e426Douglas Gregor  bool Elidable : 1;
75916006c901315fa12a108b4e571f187f4b676e426Douglas Gregor  bool ZeroInitialization : 1;
76072e96fd181b19b8d01144a685cda6e955584c7eaAnders Carlsson  unsigned ConstructKind : 2;
76115ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson  Stmt **Args;
76215ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson  unsigned NumArgs;
7631eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
764bd6734e5f6432ce0cc07171c490ffaa094796198Anders Carlssonprotected:
7651eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  CXXConstructExpr(ASTContext &C, StmtClass SC, QualType T,
76699a2e600f9e2e51d3ce10fb6f27191677ac65b2aDouglas Gregor                   SourceLocation Loc,
767bd6734e5f6432ce0cc07171c490ffaa094796198Anders Carlsson                   CXXConstructorDecl *d, bool elidable,
76816006c901315fa12a108b4e571f187f4b676e426Douglas Gregor                   Expr **args, unsigned numargs,
7699db7dbb918ca49f4ee6c181e4917e7b6ec547353Douglas Gregor                   bool ZeroInitialization = false,
770428edafa9eb80e01dd40aab31d4166a787a741e1Chandler Carruth                   ConstructionKind ConstructKind = CK_Complete,
771428edafa9eb80e01dd40aab31d4166a787a741e1Chandler Carruth                   SourceRange ParenRange = SourceRange());
772bd6734e5f6432ce0cc07171c490ffaa094796198Anders Carlsson
7736d00c1365dd3601f6d93bbda9162913c57ae788fArgyrios Kyrtzidis  /// \brief Construct an empty C++ construction expression.
7746d00c1365dd3601f6d93bbda9162913c57ae788fArgyrios Kyrtzidis  CXXConstructExpr(StmtClass SC, EmptyShell Empty)
7756d00c1365dd3601f6d93bbda9162913c57ae788fArgyrios Kyrtzidis    : Expr(SC, Empty), Constructor(0), Elidable(0), ZeroInitialization(0),
7766d00c1365dd3601f6d93bbda9162913c57ae788fArgyrios Kyrtzidis      ConstructKind(0), Args(0), NumArgs(0) { }
7776d00c1365dd3601f6d93bbda9162913c57ae788fArgyrios Kyrtzidis
77815ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlssonpublic:
7796d00c1365dd3601f6d93bbda9162913c57ae788fArgyrios Kyrtzidis  /// \brief Construct an empty C++ construction expression.
7806d00c1365dd3601f6d93bbda9162913c57ae788fArgyrios Kyrtzidis  explicit CXXConstructExpr(EmptyShell Empty)
7816d00c1365dd3601f6d93bbda9162913c57ae788fArgyrios Kyrtzidis    : Expr(CXXConstructExprClass, Empty), Constructor(0),
7826d00c1365dd3601f6d93bbda9162913c57ae788fArgyrios Kyrtzidis      Elidable(0), ZeroInitialization(0),
7836d00c1365dd3601f6d93bbda9162913c57ae788fArgyrios Kyrtzidis      ConstructKind(0), Args(0), NumArgs(0) { }
7846d00c1365dd3601f6d93bbda9162913c57ae788fArgyrios Kyrtzidis
7858e587a15da6d3457a418239d5eb4146fcbd209f3Anders Carlsson  static CXXConstructExpr *Create(ASTContext &C, QualType T,
78699a2e600f9e2e51d3ce10fb6f27191677ac65b2aDouglas Gregor                                  SourceLocation Loc,
7871eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump                                  CXXConstructorDecl *D, bool Elidable,
78816006c901315fa12a108b4e571f187f4b676e426Douglas Gregor                                  Expr **Args, unsigned NumArgs,
7899db7dbb918ca49f4ee6c181e4917e7b6ec547353Douglas Gregor                                  bool ZeroInitialization = false,
790428edafa9eb80e01dd40aab31d4166a787a741e1Chandler Carruth                                  ConstructionKind ConstructKind = CK_Complete,
791428edafa9eb80e01dd40aab31d4166a787a741e1Chandler Carruth                                  SourceRange ParenRange = SourceRange());
7921eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
7931eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
794d94546a0a1deef7286c13e49b9584621ae81cc9aDouglas Gregor  CXXConstructorDecl* getConstructor() const { return Constructor; }
79539da0b8145eaec7da7004f9b3645c5c9f4f63b1dDouglas Gregor  void setConstructor(CXXConstructorDecl *C) { Constructor = C; }
79639da0b8145eaec7da7004f9b3645c5c9f4f63b1dDouglas Gregor
79799a2e600f9e2e51d3ce10fb6f27191677ac65b2aDouglas Gregor  SourceLocation getLocation() const { return Loc; }
79899a2e600f9e2e51d3ce10fb6f27191677ac65b2aDouglas Gregor  void setLocation(SourceLocation Loc) { this->Loc = Loc; }
79999a2e600f9e2e51d3ce10fb6f27191677ac65b2aDouglas Gregor
800d94546a0a1deef7286c13e49b9584621ae81cc9aDouglas Gregor  /// \brief Whether this construction is elidable.
801d94546a0a1deef7286c13e49b9584621ae81cc9aDouglas Gregor  bool isElidable() const { return Elidable; }
80239da0b8145eaec7da7004f9b3645c5c9f4f63b1dDouglas Gregor  void setElidable(bool E) { Elidable = E; }
80339da0b8145eaec7da7004f9b3645c5c9f4f63b1dDouglas Gregor
80416006c901315fa12a108b4e571f187f4b676e426Douglas Gregor  /// \brief Whether this construction first requires
80516006c901315fa12a108b4e571f187f4b676e426Douglas Gregor  /// zero-initialization before the initializer is called.
80616006c901315fa12a108b4e571f187f4b676e426Douglas Gregor  bool requiresZeroInitialization() const { return ZeroInitialization; }
80716006c901315fa12a108b4e571f187f4b676e426Douglas Gregor  void setRequiresZeroInitialization(bool ZeroInit) {
80816006c901315fa12a108b4e571f187f4b676e426Douglas Gregor    ZeroInitialization = ZeroInit;
80916006c901315fa12a108b4e571f187f4b676e426Douglas Gregor  }
81016006c901315fa12a108b4e571f187f4b676e426Douglas Gregor
8119db7dbb918ca49f4ee6c181e4917e7b6ec547353Douglas Gregor  /// \brief Determines whether this constructor is actually constructing
8129db7dbb918ca49f4ee6c181e4917e7b6ec547353Douglas Gregor  /// a base class (rather than a complete object).
81324eb78e38aba55c507bc3c05c37035a9ab2defa7Anders Carlsson  ConstructionKind getConstructionKind() const {
81424eb78e38aba55c507bc3c05c37035a9ab2defa7Anders Carlsson    return (ConstructionKind)ConstructKind;
81572e96fd181b19b8d01144a685cda6e955584c7eaAnders Carlsson  }
81672e96fd181b19b8d01144a685cda6e955584c7eaAnders Carlsson  void setConstructionKind(ConstructionKind CK) {
81772e96fd181b19b8d01144a685cda6e955584c7eaAnders Carlsson    ConstructKind = CK;
81872e96fd181b19b8d01144a685cda6e955584c7eaAnders Carlsson  }
8199db7dbb918ca49f4ee6c181e4917e7b6ec547353Douglas Gregor
82015ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson  typedef ExprIterator arg_iterator;
82115ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson  typedef ConstExprIterator const_arg_iterator;
8221eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
82315ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson  arg_iterator arg_begin() { return Args; }
82415ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson  arg_iterator arg_end() { return Args + NumArgs; }
82515ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson  const_arg_iterator arg_begin() const { return Args; }
82615ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson  const_arg_iterator arg_end() const { return Args + NumArgs; }
82715ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson
828a88cfbfac9bbcbb9858f048d6d73a48711d8e93dDouglas Gregor  Expr **getArgs() const { return reinterpret_cast<Expr **>(Args); }
82915ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson  unsigned getNumArgs() const { return NumArgs; }
83015ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson
831bcb11d01c034f967503bd98f28bdf458c1ab8001Anders Carlsson  /// getArg - Return the specified argument.
832bcb11d01c034f967503bd98f28bdf458c1ab8001Anders Carlsson  Expr *getArg(unsigned Arg) {
833bcb11d01c034f967503bd98f28bdf458c1ab8001Anders Carlsson    assert(Arg < NumArgs && "Arg access out of range!");
834bcb11d01c034f967503bd98f28bdf458c1ab8001Anders Carlsson    return cast<Expr>(Args[Arg]);
835bcb11d01c034f967503bd98f28bdf458c1ab8001Anders Carlsson  }
836bcb11d01c034f967503bd98f28bdf458c1ab8001Anders Carlsson  const Expr *getArg(unsigned Arg) const {
837bcb11d01c034f967503bd98f28bdf458c1ab8001Anders Carlsson    assert(Arg < NumArgs && "Arg access out of range!");
838bcb11d01c034f967503bd98f28bdf458c1ab8001Anders Carlsson    return cast<Expr>(Args[Arg]);
839bcb11d01c034f967503bd98f28bdf458c1ab8001Anders Carlsson  }
8401eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
8412eeed7bc4fd457ac57ff32ab3b02674588545f65Fariborz Jahanian  /// setArg - Set the specified argument.
8422eeed7bc4fd457ac57ff32ab3b02674588545f65Fariborz Jahanian  void setArg(unsigned Arg, Expr *ArgExpr) {
8432eeed7bc4fd457ac57ff32ab3b02674588545f65Fariborz Jahanian    assert(Arg < NumArgs && "Arg access out of range!");
8442eeed7bc4fd457ac57ff32ab3b02674588545f65Fariborz Jahanian    Args[Arg] = ArgExpr;
8452eeed7bc4fd457ac57ff32ab3b02674588545f65Fariborz Jahanian  }
8462eeed7bc4fd457ac57ff32ab3b02674588545f65Fariborz Jahanian
84763c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall  SourceRange getSourceRange() const;
848428edafa9eb80e01dd40aab31d4166a787a741e1Chandler Carruth  SourceRange getParenRange() const { return ParenRange; }
84915ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson
8501eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  static bool classof(const Stmt *T) {
851524fa13fd81e88533c7a1d4b1232c0de2c97dc7cAnders Carlsson    return T->getStmtClass() == CXXConstructExprClass ||
852524fa13fd81e88533c7a1d4b1232c0de2c97dc7cAnders Carlsson      T->getStmtClass() == CXXTemporaryObjectExprClass;
85315ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson  }
85415ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson  static bool classof(const CXXConstructExpr *) { return true; }
8551eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
85615ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson  // Iterators
85763c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall  child_range children() {
85863c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall    return child_range(&Args[0], &Args[0]+NumArgs);
85963c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall  }
8606d00c1365dd3601f6d93bbda9162913c57ae788fArgyrios Kyrtzidis
86160adf4acf40b72227740bf966fb87eebddff3f37Sebastian Redl  friend class ASTStmtReader;
86215ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson};
86315ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson
86449badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// CXXFunctionalCastExpr - Represents an explicit C++ type conversion
86549badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// that uses "functional" notion (C++ [expr.type.conv]). Example: @c
86649badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// x = int(0.5);
86749badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregorclass CXXFunctionalCastExpr : public ExplicitCastExpr {
868987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  SourceLocation TyBeginLoc;
869987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  SourceLocation RParenLoc;
870f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall
871f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall  CXXFunctionalCastExpr(QualType ty, ExprValueKind VK,
872f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall                        TypeSourceInfo *writtenTy,
8731eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump                        SourceLocation tyBeginLoc, CastKind kind,
874f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall                        Expr *castExpr, unsigned pathSize,
87541b2dcd465f1e438502c420effc9d0c747f9db8fAnders Carlsson                        SourceLocation rParenLoc)
876f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall    : ExplicitCastExpr(CXXFunctionalCastExprClass, ty, VK, kind,
877f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall                       castExpr, pathSize, writtenTy),
8780aebc81e02397a5987aaa8e8c7acbdb01a31d7c3Anders Carlsson      TyBeginLoc(tyBeginLoc), RParenLoc(rParenLoc) {}
8790aebc81e02397a5987aaa8e8c7acbdb01a31d7c3Anders Carlsson
880f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall  explicit CXXFunctionalCastExpr(EmptyShell Shell, unsigned PathSize)
881f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall    : ExplicitCastExpr(CXXFunctionalCastExprClass, Shell, PathSize) { }
882f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall
883f871d0cc377a1367b519a6cce26be74607566ebaJohn McCallpublic:
884f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall  static CXXFunctionalCastExpr *Create(ASTContext &Context, QualType T,
885f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall                                       ExprValueKind VK,
886f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall                                       TypeSourceInfo *Written,
887f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall                                       SourceLocation TyBeginLoc,
888f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall                                       CastKind Kind, Expr *Op,
889f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall                                       const CXXCastPath *Path,
890f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall                                       SourceLocation RPLoc);
891f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall  static CXXFunctionalCastExpr *CreateEmpty(ASTContext &Context,
892f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall                                            unsigned PathSize);
893ce757a7a1ee905f87551996a69da3e95e8afeeb7Sam Weinig
894987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  SourceLocation getTypeBeginLoc() const { return TyBeginLoc; }
895ce757a7a1ee905f87551996a69da3e95e8afeeb7Sam Weinig  void setTypeBeginLoc(SourceLocation L) { TyBeginLoc = L; }
896987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  SourceLocation getRParenLoc() const { return RParenLoc; }
897ce757a7a1ee905f87551996a69da3e95e8afeeb7Sam Weinig  void setRParenLoc(SourceLocation L) { RParenLoc = L; }
8981eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
89963c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall  SourceRange getSourceRange() const {
900987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis    return SourceRange(TyBeginLoc, RParenLoc);
901987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  }
9021eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  static bool classof(const Stmt *T) {
9031eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump    return T->getStmtClass() == CXXFunctionalCastExprClass;
904987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  }
905987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  static bool classof(const CXXFunctionalCastExpr *) { return true; }
906987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis};
907987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis
908506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// @brief Represents a C++ functional cast expression that builds a
909506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// temporary object.
910506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor///
9111eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump/// This expression type represents a C++ "functional" cast
912506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// (C++[expr.type.conv]) with N != 1 arguments that invokes a
913ed8abf18329df67b0abcbb3a10458bd8c1d2a595Douglas Gregor/// constructor to build a temporary object. With N == 1 arguments the
914ed8abf18329df67b0abcbb3a10458bd8c1d2a595Douglas Gregor/// functional cast expression will be represented by CXXFunctionalCastExpr.
915506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// Example:
916506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// @code
917506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// struct X { X(int, float); }
918506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor///
919506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// X create_X() {
920506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor///   return X(1, 3.14f); // creates a CXXTemporaryObjectExpr
921506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// };
922506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// @endcode
923524fa13fd81e88533c7a1d4b1232c0de2c97dc7cAnders Carlssonclass CXXTemporaryObjectExpr : public CXXConstructExpr {
924ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor  TypeSourceInfo *Type;
925506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor
926506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregorpublic:
9271eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  CXXTemporaryObjectExpr(ASTContext &C, CXXConstructorDecl *Cons,
928ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor                         TypeSourceInfo *Type,
9291eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump                         Expr **Args,unsigned NumArgs,
930428edafa9eb80e01dd40aab31d4166a787a741e1Chandler Carruth                         SourceRange parenRange,
9311c63b9c15d48cb8c833a4b2d6fd6c496c0766e88Douglas Gregor                         bool ZeroInitialization = false);
9326d00c1365dd3601f6d93bbda9162913c57ae788fArgyrios Kyrtzidis  explicit CXXTemporaryObjectExpr(EmptyShell Empty)
933ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor    : CXXConstructExpr(CXXTemporaryObjectExprClass, Empty), Type() { }
934506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor
935ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor  TypeSourceInfo *getTypeSourceInfo() const { return Type; }
936ba49817c5b9f502602672861cf369fd0e53966e8Douglas Gregor
93763c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall  SourceRange getSourceRange() const;
938ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor
9391eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  static bool classof(const Stmt *T) {
940506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor    return T->getStmtClass() == CXXTemporaryObjectExprClass;
941506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor  }
942506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor  static bool classof(const CXXTemporaryObjectExpr *) { return true; }
9436d00c1365dd3601f6d93bbda9162913c57ae788fArgyrios Kyrtzidis
94460adf4acf40b72227740bf966fb87eebddff3f37Sebastian Redl  friend class ASTStmtReader;
945506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor};
946506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor
947ed8abf18329df67b0abcbb3a10458bd8c1d2a595Douglas Gregor/// CXXScalarValueInitExpr - [C++ 5.2.3p2]
948506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// Expression "T()" which creates a value-initialized rvalue of type
949ed8abf18329df67b0abcbb3a10458bd8c1d2a595Douglas Gregor/// T, which is a non-class type.
950987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis///
951ed8abf18329df67b0abcbb3a10458bd8c1d2a595Douglas Gregorclass CXXScalarValueInitExpr : public Expr {
952987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  SourceLocation RParenLoc;
953ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor  TypeSourceInfo *TypeInfo;
954987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis
955ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor  friend class ASTStmtReader;
956ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor
957987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidispublic:
958ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor  /// \brief Create an explicitly-written scalar-value initialization
959ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor  /// expression.
960ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor  CXXScalarValueInitExpr(QualType Type,
961ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor                         TypeSourceInfo *TypeInfo,
962ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor                         SourceLocation rParenLoc ) :
963f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall    Expr(CXXScalarValueInitExprClass, Type, VK_RValue, OK_Ordinary,
964bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor         false, false, false),
965ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor    RParenLoc(rParenLoc), TypeInfo(TypeInfo) {}
966ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor
967ed8abf18329df67b0abcbb3a10458bd8c1d2a595Douglas Gregor  explicit CXXScalarValueInitExpr(EmptyShell Shell)
968ed8abf18329df67b0abcbb3a10458bd8c1d2a595Douglas Gregor    : Expr(CXXScalarValueInitExprClass, Shell) { }
9691eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
970ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor  TypeSourceInfo *getTypeSourceInfo() const {
971ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor    return TypeInfo;
9724c67834407ca6ab344dcf44fc599ad4938cfa96dDouglas Gregor  }
973ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor
974ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor  SourceLocation getRParenLoc() const { return RParenLoc; }
9754c67834407ca6ab344dcf44fc599ad4938cfa96dDouglas Gregor
97663c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall  SourceRange getSourceRange() const;
9771eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
9781eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  static bool classof(const Stmt *T) {
979ed8abf18329df67b0abcbb3a10458bd8c1d2a595Douglas Gregor    return T->getStmtClass() == CXXScalarValueInitExprClass;
980987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  }
981ed8abf18329df67b0abcbb3a10458bd8c1d2a595Douglas Gregor  static bool classof(const CXXScalarValueInitExpr *) { return true; }
9821eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
983987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  // Iterators
98463c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall  child_range children() { return child_range(); }
985987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis};
986987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis
9874c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl/// CXXNewExpr - A new expression for memory allocation and constructor calls,
9884c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl/// e.g: "new CXXNewExpr(foo)".
9894c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redlclass CXXNewExpr : public Expr {
9904c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  // Was the usage ::new, i.e. is the global new to be used?
9914c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  bool GlobalNew : 1;
9924c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  // Is there an initializer? If not, built-ins are uninitialized, else they're
9934c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  // value-initialized.
9944c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  bool Initializer : 1;
995cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl  // Do we allocate an array? If so, the first SubExpr is the size expression.
996cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl  bool Array : 1;
9976ec278d1a354517e20f13a877481453ee7940c78John McCall  // If this is an array allocation, does the usual deallocation
9986ec278d1a354517e20f13a877481453ee7940c78John McCall  // function for the allocated type want to know the allocated size?
9996ec278d1a354517e20f13a877481453ee7940c78John McCall  bool UsualArrayDeleteWantsSize : 1;
10004c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  // The number of placement new arguments.
10016ec278d1a354517e20f13a877481453ee7940c78John McCall  unsigned NumPlacementArgs : 14;
10024c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  // The number of constructor arguments. This may be 1 even for non-class
10034c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  // types; use the pseudo copy constructor.
1004cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl  unsigned NumConstructorArgs : 14;
1005cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl  // Contains an optional array size expression, any number of optional
1006cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl  // placement arguments, and any number of optional constructor arguments,
1007cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl  // in that order.
10084c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  Stmt **SubExprs;
10094c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  // Points to the allocation function used.
10104c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  FunctionDecl *OperatorNew;
10114c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  // Points to the deallocation function used in case of error. May be null.
10124c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  FunctionDecl *OperatorDelete;
10134c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  // Points to the constructor used. Cannot be null if AllocType is a record;
10144c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  // it would still point at the default constructor (even an implicit one).
10154c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  // Must be null for all other types.
10164c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  CXXConstructorDecl *Constructor;
10174c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
10181bb2a93ab7b1499dda6f6b58865bd0dce1864228Douglas Gregor  /// \brief The allocated type-source information, as written in the source.
10191bb2a93ab7b1499dda6f6b58865bd0dce1864228Douglas Gregor  TypeSourceInfo *AllocatedTypeInfo;
10201bb2a93ab7b1499dda6f6b58865bd0dce1864228Douglas Gregor
10214bd40318cbea15310a37343db46de96c4fcc15e6Douglas Gregor  /// \brief If the allocated type was expressed as a parenthesized type-id,
10224bd40318cbea15310a37343db46de96c4fcc15e6Douglas Gregor  /// the source range covering the parenthesized type-id.
10234bd40318cbea15310a37343db46de96c4fcc15e6Douglas Gregor  SourceRange TypeIdParens;
10244bd40318cbea15310a37343db46de96c4fcc15e6Douglas Gregor
10254c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  SourceLocation StartLoc;
10264c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  SourceLocation EndLoc;
1027428edafa9eb80e01dd40aab31d4166a787a741e1Chandler Carruth  SourceLocation ConstructorLParen;
1028428edafa9eb80e01dd40aab31d4166a787a741e1Chandler Carruth  SourceLocation ConstructorRParen;
10294c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
103060adf4acf40b72227740bf966fb87eebddff3f37Sebastian Redl  friend class ASTStmtReader;
10314c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redlpublic:
1032ad7fe864862305c2f71e047cdf6706ef43aebdc0Ted Kremenek  CXXNewExpr(ASTContext &C, bool globalNew, FunctionDecl *operatorNew,
10334bd40318cbea15310a37343db46de96c4fcc15e6Douglas Gregor             Expr **placementArgs, unsigned numPlaceArgs,
10344bd40318cbea15310a37343db46de96c4fcc15e6Douglas Gregor             SourceRange TypeIdParens,
1035ad7fe864862305c2f71e047cdf6706ef43aebdc0Ted Kremenek             Expr *arraySize, CXXConstructorDecl *constructor, bool initializer,
10364c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl             Expr **constructorArgs, unsigned numConsArgs,
10376ec278d1a354517e20f13a877481453ee7940c78John McCall             FunctionDecl *operatorDelete, bool usualArrayDeleteWantsSize,
10386ec278d1a354517e20f13a877481453ee7940c78John McCall             QualType ty, TypeSourceInfo *AllocatedTypeInfo,
1039428edafa9eb80e01dd40aab31d4166a787a741e1Chandler Carruth             SourceLocation startLoc, SourceLocation endLoc,
1040428edafa9eb80e01dd40aab31d4166a787a741e1Chandler Carruth             SourceLocation constructorLParen,
1041428edafa9eb80e01dd40aab31d4166a787a741e1Chandler Carruth             SourceLocation constructorRParen);
10425921863d8f24084797863b5df37842113bac4352Chris Lattner  explicit CXXNewExpr(EmptyShell Shell)
10435921863d8f24084797863b5df37842113bac4352Chris Lattner    : Expr(CXXNewExprClass, Shell), SubExprs(0) { }
10445921863d8f24084797863b5df37842113bac4352Chris Lattner
10455921863d8f24084797863b5df37842113bac4352Chris Lattner  void AllocateArgsArray(ASTContext &C, bool isArray, unsigned numPlaceArgs,
10465921863d8f24084797863b5df37842113bac4352Chris Lattner                         unsigned numConsArgs);
1047ad7fe864862305c2f71e047cdf6706ef43aebdc0Ted Kremenek
1048cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl  QualType getAllocatedType() const {
1049cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl    assert(getType()->isPointerType());
10506217b80b7a1379b74cced1c076338262c3c980b3Ted Kremenek    return getType()->getAs<PointerType>()->getPointeeType();
1051cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl  }
10524c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
10531bb2a93ab7b1499dda6f6b58865bd0dce1864228Douglas Gregor  TypeSourceInfo *getAllocatedTypeSourceInfo() const {
10541bb2a93ab7b1499dda6f6b58865bd0dce1864228Douglas Gregor    return AllocatedTypeInfo;
10551bb2a93ab7b1499dda6f6b58865bd0dce1864228Douglas Gregor  }
10561bb2a93ab7b1499dda6f6b58865bd0dce1864228Douglas Gregor
10574c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  FunctionDecl *getOperatorNew() const { return OperatorNew; }
10585921863d8f24084797863b5df37842113bac4352Chris Lattner  void setOperatorNew(FunctionDecl *D) { OperatorNew = D; }
10594c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  FunctionDecl *getOperatorDelete() const { return OperatorDelete; }
10605921863d8f24084797863b5df37842113bac4352Chris Lattner  void setOperatorDelete(FunctionDecl *D) { OperatorDelete = D; }
10614c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  CXXConstructorDecl *getConstructor() const { return Constructor; }
10625921863d8f24084797863b5df37842113bac4352Chris Lattner  void setConstructor(CXXConstructorDecl *D) { Constructor = D; }
10634c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
1064cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl  bool isArray() const { return Array; }
1065cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl  Expr *getArraySize() {
1066cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl    return Array ? cast<Expr>(SubExprs[0]) : 0;
1067cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl  }
1068cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl  const Expr *getArraySize() const {
1069cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl    return Array ? cast<Expr>(SubExprs[0]) : 0;
1070cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl  }
1071cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl
10724c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  unsigned getNumPlacementArgs() const { return NumPlacementArgs; }
1073aa165f8458b51c546bebff947343e1a36f3594cbDouglas Gregor  Expr **getPlacementArgs() {
1074aa165f8458b51c546bebff947343e1a36f3594cbDouglas Gregor    return reinterpret_cast<Expr **>(SubExprs + Array);
1075aa165f8458b51c546bebff947343e1a36f3594cbDouglas Gregor  }
1076aa165f8458b51c546bebff947343e1a36f3594cbDouglas Gregor
10774c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  Expr *getPlacementArg(unsigned i) {
10784c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl    assert(i < NumPlacementArgs && "Index out of range");
1079cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl    return cast<Expr>(SubExprs[Array + i]);
10804c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  }
10814c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  const Expr *getPlacementArg(unsigned i) const {
10824c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl    assert(i < NumPlacementArgs && "Index out of range");
1083cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl    return cast<Expr>(SubExprs[Array + i]);
10844c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  }
10854c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
10864bd40318cbea15310a37343db46de96c4fcc15e6Douglas Gregor  bool isParenTypeId() const { return TypeIdParens.isValid(); }
10874bd40318cbea15310a37343db46de96c4fcc15e6Douglas Gregor  SourceRange getTypeIdParens() const { return TypeIdParens; }
10884bd40318cbea15310a37343db46de96c4fcc15e6Douglas Gregor
10894c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  bool isGlobalNew() const { return GlobalNew; }
10904c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  bool hasInitializer() const { return Initializer; }
10916ec278d1a354517e20f13a877481453ee7940c78John McCall
10926ec278d1a354517e20f13a877481453ee7940c78John McCall  /// Answers whether the usual array deallocation function for the
10936ec278d1a354517e20f13a877481453ee7940c78John McCall  /// allocated type expects the size of the allocation as a
10946ec278d1a354517e20f13a877481453ee7940c78John McCall  /// parameter.
10956ec278d1a354517e20f13a877481453ee7940c78John McCall  bool doesUsualArrayDeleteWantSize() const {
10966ec278d1a354517e20f13a877481453ee7940c78John McCall    return UsualArrayDeleteWantsSize;
10976ec278d1a354517e20f13a877481453ee7940c78John McCall  }
10984c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
10994c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  unsigned getNumConstructorArgs() const { return NumConstructorArgs; }
1100aa165f8458b51c546bebff947343e1a36f3594cbDouglas Gregor
1101aa165f8458b51c546bebff947343e1a36f3594cbDouglas Gregor  Expr **getConstructorArgs() {
1102aa165f8458b51c546bebff947343e1a36f3594cbDouglas Gregor    return reinterpret_cast<Expr **>(SubExprs + Array + NumPlacementArgs);
1103aa165f8458b51c546bebff947343e1a36f3594cbDouglas Gregor  }
1104aa165f8458b51c546bebff947343e1a36f3594cbDouglas Gregor
11054c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  Expr *getConstructorArg(unsigned i) {
11064c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl    assert(i < NumConstructorArgs && "Index out of range");
1107cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl    return cast<Expr>(SubExprs[Array + NumPlacementArgs + i]);
11084c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  }
11094c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  const Expr *getConstructorArg(unsigned i) const {
11104c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl    assert(i < NumConstructorArgs && "Index out of range");
1111cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl    return cast<Expr>(SubExprs[Array + NumPlacementArgs + i]);
11124c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  }
11134c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
11144c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  typedef ExprIterator arg_iterator;
11154c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  typedef ConstExprIterator const_arg_iterator;
11164c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
11174c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  arg_iterator placement_arg_begin() {
1118cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl    return SubExprs + Array;
11194c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  }
11204c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  arg_iterator placement_arg_end() {
1121cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl    return SubExprs + Array + getNumPlacementArgs();
11224c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  }
11234c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  const_arg_iterator placement_arg_begin() const {
1124cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl    return SubExprs + Array;
11254c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  }
11264c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  const_arg_iterator placement_arg_end() const {
1127cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl    return SubExprs + Array + getNumPlacementArgs();
11284c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  }
11294c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
11304c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  arg_iterator constructor_arg_begin() {
1131cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl    return SubExprs + Array + getNumPlacementArgs();
11324c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  }
11334c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  arg_iterator constructor_arg_end() {
1134cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl    return SubExprs + Array + getNumPlacementArgs() + getNumConstructorArgs();
11354c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  }
11364c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  const_arg_iterator constructor_arg_begin() const {
1137cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl    return SubExprs + Array + getNumPlacementArgs();
11384c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  }
11394c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  const_arg_iterator constructor_arg_end() const {
1140cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl    return SubExprs + Array + getNumPlacementArgs() + getNumConstructorArgs();
11414c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  }
11425921863d8f24084797863b5df37842113bac4352Chris Lattner
11435921863d8f24084797863b5df37842113bac4352Chris Lattner  typedef Stmt **raw_arg_iterator;
11445921863d8f24084797863b5df37842113bac4352Chris Lattner  raw_arg_iterator raw_arg_begin() { return SubExprs; }
11455921863d8f24084797863b5df37842113bac4352Chris Lattner  raw_arg_iterator raw_arg_end() {
11465921863d8f24084797863b5df37842113bac4352Chris Lattner    return SubExprs + Array + getNumPlacementArgs() + getNumConstructorArgs();
11475921863d8f24084797863b5df37842113bac4352Chris Lattner  }
11485921863d8f24084797863b5df37842113bac4352Chris Lattner  const_arg_iterator raw_arg_begin() const { return SubExprs; }
11495921863d8f24084797863b5df37842113bac4352Chris Lattner  const_arg_iterator raw_arg_end() const { return constructor_arg_end(); }
11504c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
11515921863d8f24084797863b5df37842113bac4352Chris Lattner  SourceLocation getStartLoc() const { return StartLoc; }
11525921863d8f24084797863b5df37842113bac4352Chris Lattner  SourceLocation getEndLoc() const { return EndLoc; }
1153428edafa9eb80e01dd40aab31d4166a787a741e1Chandler Carruth
1154428edafa9eb80e01dd40aab31d4166a787a741e1Chandler Carruth  SourceLocation getConstructorLParen() const { return ConstructorLParen; }
1155428edafa9eb80e01dd40aab31d4166a787a741e1Chandler Carruth  SourceLocation getConstructorRParen() const { return ConstructorRParen; }
1156428edafa9eb80e01dd40aab31d4166a787a741e1Chandler Carruth
115763c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall  SourceRange getSourceRange() const {
11584c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl    return SourceRange(StartLoc, EndLoc);
11594c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  }
11604c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
11614c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  static bool classof(const Stmt *T) {
11624c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl    return T->getStmtClass() == CXXNewExprClass;
11634c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  }
11644c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  static bool classof(const CXXNewExpr *) { return true; }
11654c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
11664c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  // Iterators
116763c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall  child_range children() {
116863c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall    return child_range(&SubExprs[0],
116963c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall                       &SubExprs[0] + Array + getNumPlacementArgs()
117063c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall                         + getNumConstructorArgs());
117163c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall  }
11724c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl};
11734c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
11744c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl/// CXXDeleteExpr - A delete expression for memory deallocation and destructor
11754c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl/// calls, e.g. "delete[] pArray".
11764c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redlclass CXXDeleteExpr : public Expr {
11774c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  // Is this a forced global delete, i.e. "::delete"?
11784c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  bool GlobalDelete : 1;
11794c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  // Is this the array form of delete, i.e. "delete[]"?
11804c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  bool ArrayForm : 1;
11814076dacf1497fb95cb298b9d964fbdbdaf9bde6cArgyrios Kyrtzidis  // ArrayFormAsWritten can be different from ArrayForm if 'delete' is applied
11824076dacf1497fb95cb298b9d964fbdbdaf9bde6cArgyrios Kyrtzidis  // to pointer-to-array type (ArrayFormAsWritten will be false while ArrayForm
11834076dacf1497fb95cb298b9d964fbdbdaf9bde6cArgyrios Kyrtzidis  // will be true).
11844076dacf1497fb95cb298b9d964fbdbdaf9bde6cArgyrios Kyrtzidis  bool ArrayFormAsWritten : 1;
11856ec278d1a354517e20f13a877481453ee7940c78John McCall  // Does the usual deallocation function for the element type require
11866ec278d1a354517e20f13a877481453ee7940c78John McCall  // a size_t argument?
11876ec278d1a354517e20f13a877481453ee7940c78John McCall  bool UsualArrayDeleteWantsSize : 1;
11884c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  // Points to the operator delete overload that is used. Could be a member.
11894c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  FunctionDecl *OperatorDelete;
11904c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  // The pointer expression to be deleted.
11914c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  Stmt *Argument;
11924c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  // Location of the expression.
11934c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  SourceLocation Loc;
11944c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redlpublic:
11954c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  CXXDeleteExpr(QualType ty, bool globalDelete, bool arrayForm,
11966ec278d1a354517e20f13a877481453ee7940c78John McCall                bool arrayFormAsWritten, bool usualArrayDeleteWantsSize,
11976ec278d1a354517e20f13a877481453ee7940c78John McCall                FunctionDecl *operatorDelete, Expr *arg, SourceLocation loc)
1198bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor    : Expr(CXXDeleteExprClass, ty, VK_RValue, OK_Ordinary, false, false,
1199bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor           arg->containsUnexpandedParameterPack()),
1200f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall      GlobalDelete(globalDelete),
12014076dacf1497fb95cb298b9d964fbdbdaf9bde6cArgyrios Kyrtzidis      ArrayForm(arrayForm), ArrayFormAsWritten(arrayFormAsWritten),
12026ec278d1a354517e20f13a877481453ee7940c78John McCall      UsualArrayDeleteWantsSize(usualArrayDeleteWantsSize),
12034076dacf1497fb95cb298b9d964fbdbdaf9bde6cArgyrios Kyrtzidis      OperatorDelete(operatorDelete), Argument(arg), Loc(loc) { }
120495fc98ce95d4faa4f1bb2783384150530404ea6fArgyrios Kyrtzidis  explicit CXXDeleteExpr(EmptyShell Shell)
120595fc98ce95d4faa4f1bb2783384150530404ea6fArgyrios Kyrtzidis    : Expr(CXXDeleteExprClass, Shell), OperatorDelete(0), Argument(0) { }
12064c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
12074c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  bool isGlobalDelete() const { return GlobalDelete; }
12084c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  bool isArrayForm() const { return ArrayForm; }
12094076dacf1497fb95cb298b9d964fbdbdaf9bde6cArgyrios Kyrtzidis  bool isArrayFormAsWritten() const { return ArrayFormAsWritten; }
12104c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
12116ec278d1a354517e20f13a877481453ee7940c78John McCall  /// Answers whether the usual array deallocation function for the
12126ec278d1a354517e20f13a877481453ee7940c78John McCall  /// allocated type expects the size of the allocation as a
12136ec278d1a354517e20f13a877481453ee7940c78John McCall  /// parameter.  This can be true even if the actual deallocation
12146ec278d1a354517e20f13a877481453ee7940c78John McCall  /// function that we're using doesn't want a size.
12156ec278d1a354517e20f13a877481453ee7940c78John McCall  bool doesUsualArrayDeleteWantSize() const {
12166ec278d1a354517e20f13a877481453ee7940c78John McCall    return UsualArrayDeleteWantsSize;
12176ec278d1a354517e20f13a877481453ee7940c78John McCall  }
12186ec278d1a354517e20f13a877481453ee7940c78John McCall
12194c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  FunctionDecl *getOperatorDelete() const { return OperatorDelete; }
12204c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
12214c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  Expr *getArgument() { return cast<Expr>(Argument); }
12224c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  const Expr *getArgument() const { return cast<Expr>(Argument); }
12234c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
1224a437ad3ec5b407ede394d74e6f9f463fa3657dbeCraig Silverstein  /// \brief Retrieve the type being destroyed.  If the type being
1225a437ad3ec5b407ede394d74e6f9f463fa3657dbeCraig Silverstein  /// destroyed is a dependent type which may or may not be a pointer,
1226a437ad3ec5b407ede394d74e6f9f463fa3657dbeCraig Silverstein  /// return an invalid type.
12275833b0b831d6afae2885e6af420e2bda639652e6Douglas Gregor  QualType getDestroyedType() const;
12285833b0b831d6afae2885e6af420e2bda639652e6Douglas Gregor
122963c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall  SourceRange getSourceRange() const {
12304c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl    return SourceRange(Loc, Argument->getLocEnd());
12314c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  }
12324c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
12334c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  static bool classof(const Stmt *T) {
12344c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl    return T->getStmtClass() == CXXDeleteExprClass;
12354c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  }
12364c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  static bool classof(const CXXDeleteExpr *) { return true; }
12374c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
12384c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  // Iterators
123963c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall  child_range children() { return child_range(&Argument, &Argument+1); }
1240f1b8911d35bb2830a13267581d3cbde4b6b85db6Argyrios Kyrtzidis
1241f1b8911d35bb2830a13267581d3cbde4b6b85db6Argyrios Kyrtzidis  friend class ASTStmtReader;
12424c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl};
12434c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
1244a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor/// \brief Structure used to store the type being destroyed by a
1245a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor/// pseudo-destructor expression.
1246a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregorclass PseudoDestructorTypeStorage {
1247a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor  /// \brief Either the type source information or the name of the type, if
1248a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor  /// it couldn't be resolved due to type-dependence.
1249a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor  llvm::PointerUnion<TypeSourceInfo *, IdentifierInfo *> Type;
1250a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor
1251a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor  /// \brief The starting source location of the pseudo-destructor type.
1252a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor  SourceLocation Location;
1253a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor
1254a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregorpublic:
1255a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor  PseudoDestructorTypeStorage() { }
1256a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor
1257a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor  PseudoDestructorTypeStorage(IdentifierInfo *II, SourceLocation Loc)
1258a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor    : Type(II), Location(Loc) { }
1259a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor
1260a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor  PseudoDestructorTypeStorage(TypeSourceInfo *Info);
1261a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor
1262a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor  TypeSourceInfo *getTypeSourceInfo() const {
1263a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor    return Type.dyn_cast<TypeSourceInfo *>();
1264a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor  }
1265a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor
1266a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor  IdentifierInfo *getIdentifier() const {
1267a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor    return Type.dyn_cast<IdentifierInfo *>();
1268a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor  }
1269a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor
1270a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor  SourceLocation getLocation() const { return Location; }
1271a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor};
1272a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor
1273a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor/// \brief Represents a C++ pseudo-destructor (C++ [expr.pseudo]).
1274a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor///
1275e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor/// A pseudo-destructor is an expression that looks like a member access to a
1276e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor/// destructor of a scalar type, except that scalar types don't have
1277e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor/// destructors. For example:
1278e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor///
1279e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor/// \code
1280e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor/// typedef int T;
1281e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor/// void f(int *p) {
1282e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor///   p->T::~T();
1283e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor/// }
1284e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor/// \endcode
1285a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor///
1286e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor/// Pseudo-destructors typically occur when instantiating templates such as:
1287e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor///
1288a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor/// \code
12891eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump/// template<typename T>
1290a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor/// void destroy(T* ptr) {
1291e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor///   ptr->T::~T();
1292a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor/// }
1293a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor/// \endcode
1294a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor///
1295e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor/// for scalar types. A pseudo-destructor expression has no run-time semantics
1296e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor/// beyond evaluating the base expression.
1297a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregorclass CXXPseudoDestructorExpr : public Expr {
1298a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  /// \brief The base expression (that is being destroyed).
1299a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  Stmt *Base;
13001eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1301a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  /// \brief Whether the operator was an arrow ('->'); otherwise, it was a
1302a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  /// period ('.').
1303a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  bool IsArrow : 1;
13041eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1305a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  /// \brief The location of the '.' or '->' operator.
1306a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  SourceLocation OperatorLoc;
13071eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1308a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  /// \brief The nested-name-specifier that follows the operator, if present.
1309a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  NestedNameSpecifier *Qualifier;
13101eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
13111eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  /// \brief The source range that covers the nested-name-specifier, if
1312a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  /// present.
1313a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  SourceRange QualifierRange;
13141eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1315e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor  /// \brief The type that precedes the '::' in a qualified pseudo-destructor
1316e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor  /// expression.
1317e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor  TypeSourceInfo *ScopeType;
1318e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor
1319e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor  /// \brief The location of the '::' in a qualified pseudo-destructor
1320e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor  /// expression.
1321e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor  SourceLocation ColonColonLoc;
1322e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor
1323fce46ee68f779e239826e69e45d01d4c8e5323caDouglas Gregor  /// \brief The location of the '~'.
1324fce46ee68f779e239826e69e45d01d4c8e5323caDouglas Gregor  SourceLocation TildeLoc;
1325fce46ee68f779e239826e69e45d01d4c8e5323caDouglas Gregor
1326a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor  /// \brief The type being destroyed, or its name if we were unable to
1327a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor  /// resolve the name.
1328a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor  PseudoDestructorTypeStorage DestroyedType;
13291eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1330a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregorpublic:
1331a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  CXXPseudoDestructorExpr(ASTContext &Context,
1332a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor                          Expr *Base, bool isArrow, SourceLocation OperatorLoc,
1333a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor                          NestedNameSpecifier *Qualifier,
1334a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor                          SourceRange QualifierRange,
1335e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor                          TypeSourceInfo *ScopeType,
1336e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor                          SourceLocation ColonColonLoc,
1337fce46ee68f779e239826e69e45d01d4c8e5323caDouglas Gregor                          SourceLocation TildeLoc,
1338e23cf437fe76b1ed02d63c3f61b456fd48a915f5John McCall                          PseudoDestructorTypeStorage DestroyedType);
13391eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1340de4bd18bb45a1db68996cfb949db3015fc25d10dArgyrios Kyrtzidis  explicit CXXPseudoDestructorExpr(EmptyShell Shell)
1341de4bd18bb45a1db68996cfb949db3015fc25d10dArgyrios Kyrtzidis    : Expr(CXXPseudoDestructorExprClass, Shell),
1342de4bd18bb45a1db68996cfb949db3015fc25d10dArgyrios Kyrtzidis      Base(0), IsArrow(false), Qualifier(0), ScopeType(0) { }
1343de4bd18bb45a1db68996cfb949db3015fc25d10dArgyrios Kyrtzidis
1344a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  void setBase(Expr *E) { Base = E; }
1345a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  Expr *getBase() const { return cast<Expr>(Base); }
13461eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
13471eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  /// \brief Determines whether this member expression actually had
1348a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  /// a C++ nested-name-specifier prior to the name of the member, e.g.,
1349a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  /// x->Base::foo.
1350a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  bool hasQualifier() const { return Qualifier != 0; }
13511eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1352a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  /// \brief If the member name was qualified, retrieves the source range of
1353a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  /// the nested-name-specifier that precedes the member name. Otherwise,
1354a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  /// returns an empty source range.
1355a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  SourceRange getQualifierRange() const { return QualifierRange; }
1356de4bd18bb45a1db68996cfb949db3015fc25d10dArgyrios Kyrtzidis  void setQualifierRange(SourceRange R) { QualifierRange = R; }
13571eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
13581eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  /// \brief If the member name was qualified, retrieves the
1359a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  /// nested-name-specifier that precedes the member name. Otherwise, returns
1360a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  /// NULL.
1361a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  NestedNameSpecifier *getQualifier() const { return Qualifier; }
1362de4bd18bb45a1db68996cfb949db3015fc25d10dArgyrios Kyrtzidis  void setQualifier(NestedNameSpecifier *NNS) { Qualifier = NNS; }
13631eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1364a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  /// \brief Determine whether this pseudo-destructor expression was written
1365a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  /// using an '->' (otherwise, it used a '.').
1366a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  bool isArrow() const { return IsArrow; }
1367a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  void setArrow(bool A) { IsArrow = A; }
1368a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor
1369a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  /// \brief Retrieve the location of the '.' or '->' operator.
1370a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  SourceLocation getOperatorLoc() const { return OperatorLoc; }
1371de4bd18bb45a1db68996cfb949db3015fc25d10dArgyrios Kyrtzidis  void setOperatorLoc(SourceLocation L) { OperatorLoc = L; }
13721eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1373e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor  /// \brief Retrieve the scope type in a qualified pseudo-destructor
1374e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor  /// expression.
1375e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor  ///
1376e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor  /// Pseudo-destructor expressions can have extra qualification within them
1377e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor  /// that is not part of the nested-name-specifier, e.g., \c p->T::~T().
1378e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor  /// Here, if the object type of the expression is (or may be) a scalar type,
1379e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor  /// \p T may also be a scalar type and, therefore, cannot be part of a
1380e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor  /// nested-name-specifier. It is stored as the "scope type" of the pseudo-
1381e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor  /// destructor expression.
138226d4ac97fb514bb60c2536eae6f203dc569159d9Douglas Gregor  TypeSourceInfo *getScopeTypeInfo() const { return ScopeType; }
1383de4bd18bb45a1db68996cfb949db3015fc25d10dArgyrios Kyrtzidis  void setScopeTypeInfo(TypeSourceInfo *Info) { ScopeType = Info; }
1384e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor
1385e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor  /// \brief Retrieve the location of the '::' in a qualified pseudo-destructor
1386e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor  /// expression.
1387e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor  SourceLocation getColonColonLoc() const { return ColonColonLoc; }
1388de4bd18bb45a1db68996cfb949db3015fc25d10dArgyrios Kyrtzidis  void setColonColonLoc(SourceLocation L) { ColonColonLoc = L; }
1389e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor
1390fce46ee68f779e239826e69e45d01d4c8e5323caDouglas Gregor  /// \brief Retrieve the location of the '~'.
1391fce46ee68f779e239826e69e45d01d4c8e5323caDouglas Gregor  SourceLocation getTildeLoc() const { return TildeLoc; }
1392de4bd18bb45a1db68996cfb949db3015fc25d10dArgyrios Kyrtzidis  void setTildeLoc(SourceLocation L) { TildeLoc = L; }
1393fce46ee68f779e239826e69e45d01d4c8e5323caDouglas Gregor
139426d4ac97fb514bb60c2536eae6f203dc569159d9Douglas Gregor  /// \brief Retrieve the source location information for the type
139526d4ac97fb514bb60c2536eae6f203dc569159d9Douglas Gregor  /// being destroyed.
1396a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor  ///
1397a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor  /// This type-source information is available for non-dependent
1398a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor  /// pseudo-destructor expressions and some dependent pseudo-destructor
1399a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor  /// expressions. Returns NULL if we only have the identifier for a
1400a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor  /// dependent pseudo-destructor expression.
1401a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor  TypeSourceInfo *getDestroyedTypeInfo() const {
1402a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor    return DestroyedType.getTypeSourceInfo();
1403a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor  }
1404a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor
1405a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor  /// \brief In a dependent pseudo-destructor expression for which we do not
1406a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor  /// have full type information on the destroyed type, provides the name
1407a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor  /// of the destroyed type.
1408a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor  IdentifierInfo *getDestroyedTypeIdentifier() const {
1409a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor    return DestroyedType.getIdentifier();
1410a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor  }
1411a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor
1412a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor  /// \brief Retrieve the type being destroyed.
1413a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor  QualType getDestroyedType() const;
1414a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor
1415a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor  /// \brief Retrieve the starting location of the type being destroyed.
1416a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor  SourceLocation getDestroyedTypeLoc() const {
1417a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor    return DestroyedType.getLocation();
1418a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor  }
14191eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1420de4bd18bb45a1db68996cfb949db3015fc25d10dArgyrios Kyrtzidis  /// \brief Set the name of destroyed type for a dependent pseudo-destructor
1421de4bd18bb45a1db68996cfb949db3015fc25d10dArgyrios Kyrtzidis  /// expression.
1422de4bd18bb45a1db68996cfb949db3015fc25d10dArgyrios Kyrtzidis  void setDestroyedType(IdentifierInfo *II, SourceLocation Loc) {
1423de4bd18bb45a1db68996cfb949db3015fc25d10dArgyrios Kyrtzidis    DestroyedType = PseudoDestructorTypeStorage(II, Loc);
1424de4bd18bb45a1db68996cfb949db3015fc25d10dArgyrios Kyrtzidis  }
1425de4bd18bb45a1db68996cfb949db3015fc25d10dArgyrios Kyrtzidis
1426de4bd18bb45a1db68996cfb949db3015fc25d10dArgyrios Kyrtzidis  /// \brief Set the destroyed type.
1427de4bd18bb45a1db68996cfb949db3015fc25d10dArgyrios Kyrtzidis  void setDestroyedType(TypeSourceInfo *Info) {
1428de4bd18bb45a1db68996cfb949db3015fc25d10dArgyrios Kyrtzidis    DestroyedType = PseudoDestructorTypeStorage(Info);
1429de4bd18bb45a1db68996cfb949db3015fc25d10dArgyrios Kyrtzidis  }
1430de4bd18bb45a1db68996cfb949db3015fc25d10dArgyrios Kyrtzidis
143163c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall  SourceRange getSourceRange() const;
14321eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
14331eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  static bool classof(const Stmt *T) {
1434a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor    return T->getStmtClass() == CXXPseudoDestructorExprClass;
1435a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  }
1436a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  static bool classof(const CXXPseudoDestructorExpr *) { return true; }
14371eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1438a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  // Iterators
143963c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall  child_range children() { return child_range(&Base, &Base + 1); }
1440a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor};
14411eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
144264b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl/// UnaryTypeTraitExpr - A GCC or MS unary type trait, as used in the
144364b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl/// implementation of TR1/C++0x type trait templates.
144464b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl/// Example:
144564b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl/// __is_pod(int) == true
144664b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl/// __is_enum(std::string) == false
144764b45f7e0d3167f040841ac2920aead7f080730dSebastian Redlclass UnaryTypeTraitExpr : public Expr {
14480dfd848fa4c9664852ba8c929a8bd3fce93ddca2Sebastian Redl  /// UTT - The trait. A UnaryTypeTrait enum in MSVC compat unsigned.
14490dfd848fa4c9664852ba8c929a8bd3fce93ddca2Sebastian Redl  unsigned UTT : 31;
14500dfd848fa4c9664852ba8c929a8bd3fce93ddca2Sebastian Redl  /// The value of the type trait. Unspecified if dependent.
14510dfd848fa4c9664852ba8c929a8bd3fce93ddca2Sebastian Redl  bool Value : 1;
145264b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl
145364b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl  /// Loc - The location of the type trait keyword.
145464b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl  SourceLocation Loc;
145564b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl
145664b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl  /// RParen - The location of the closing paren.
145764b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl  SourceLocation RParen;
145864b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl
14590dfd848fa4c9664852ba8c929a8bd3fce93ddca2Sebastian Redl  /// The type being queried.
14603d37c0ada0e46b87be0a10e8d52d990a97d3907aDouglas Gregor  TypeSourceInfo *QueriedType;
146164b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl
146264b45f7e0d3167f040841ac2920aead7f080730dSebastian Redlpublic:
14633d37c0ada0e46b87be0a10e8d52d990a97d3907aDouglas Gregor  UnaryTypeTraitExpr(SourceLocation loc, UnaryTypeTrait utt,
14640dfd848fa4c9664852ba8c929a8bd3fce93ddca2Sebastian Redl                     TypeSourceInfo *queried, bool value,
146564b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl                     SourceLocation rparen, QualType ty)
1466f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall    : Expr(UnaryTypeTraitExprClass, ty, VK_RValue, OK_Ordinary,
1467bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor           false,  queried->getType()->isDependentType(),
1468bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor           queried->getType()->containsUnexpandedParameterPack()),
14690dfd848fa4c9664852ba8c929a8bd3fce93ddca2Sebastian Redl      UTT(utt), Value(value), Loc(loc), RParen(rparen), QueriedType(queried) { }
147064b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl
14716d00c1365dd3601f6d93bbda9162913c57ae788fArgyrios Kyrtzidis  explicit UnaryTypeTraitExpr(EmptyShell Empty)
14720dfd848fa4c9664852ba8c929a8bd3fce93ddca2Sebastian Redl    : Expr(UnaryTypeTraitExprClass, Empty), UTT(0), Value(false),
14733d37c0ada0e46b87be0a10e8d52d990a97d3907aDouglas Gregor      QueriedType() { }
14746d00c1365dd3601f6d93bbda9162913c57ae788fArgyrios Kyrtzidis
147563c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall  SourceRange getSourceRange() const { return SourceRange(Loc, RParen);}
147664b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl
14770dfd848fa4c9664852ba8c929a8bd3fce93ddca2Sebastian Redl  UnaryTypeTrait getTrait() const { return static_cast<UnaryTypeTrait>(UTT); }
147864b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl
14793d37c0ada0e46b87be0a10e8d52d990a97d3907aDouglas Gregor  QualType getQueriedType() const { return QueriedType->getType(); }
148064b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl
14813d37c0ada0e46b87be0a10e8d52d990a97d3907aDouglas Gregor  TypeSourceInfo *getQueriedTypeSourceInfo() const { return QueriedType; }
14823d37c0ada0e46b87be0a10e8d52d990a97d3907aDouglas Gregor
14830dfd848fa4c9664852ba8c929a8bd3fce93ddca2Sebastian Redl  bool getValue() const { return Value; }
148464b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl
148564b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl  static bool classof(const Stmt *T) {
148664b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl    return T->getStmtClass() == UnaryTypeTraitExprClass;
148764b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl  }
148864b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl  static bool classof(const UnaryTypeTraitExpr *) { return true; }
148964b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl
149064b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl  // Iterators
149163c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall  child_range children() { return child_range(); }
14926d00c1365dd3601f6d93bbda9162913c57ae788fArgyrios Kyrtzidis
149360adf4acf40b72227740bf966fb87eebddff3f37Sebastian Redl  friend class ASTStmtReader;
149464b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl};
149564b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl
14966ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet/// BinaryTypeTraitExpr - A GCC or MS binary type trait, as used in the
14976ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet/// implementation of TR1/C++0x type trait templates.
14986ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet/// Example:
14996ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet/// __is_base_of(Base, Derived) == true
15006ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichetclass BinaryTypeTraitExpr : public Expr {
15016ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet  /// BTT - The trait. A BinaryTypeTrait enum in MSVC compat unsigned.
15026ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet  unsigned BTT : 8;
15036ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet
15046ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet  /// The value of the type trait. Unspecified if dependent.
15056ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet  bool Value : 1;
15066ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet
15076ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet  /// Loc - The location of the type trait keyword.
15086ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet  SourceLocation Loc;
15096ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet
15106ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet  /// RParen - The location of the closing paren.
15116ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet  SourceLocation RParen;
15126ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet
15136ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet  /// The lhs type being queried.
15146ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet  TypeSourceInfo *LhsType;
15156ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet
15166ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet  /// The rhs type being queried.
15176ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet  TypeSourceInfo *RhsType;
15186ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet
15196ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichetpublic:
15206ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet  BinaryTypeTraitExpr(SourceLocation loc, BinaryTypeTrait btt,
15216ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet                     TypeSourceInfo *lhsType, TypeSourceInfo *rhsType,
15226ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet                     bool value, SourceLocation rparen, QualType ty)
15236ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet    : Expr(BinaryTypeTraitExprClass, ty, VK_RValue, OK_Ordinary, false,
15246ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet           lhsType->getType()->isDependentType() ||
1525bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor           rhsType->getType()->isDependentType(),
1526bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor           (lhsType->getType()->containsUnexpandedParameterPack() ||
1527bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor            rhsType->getType()->containsUnexpandedParameterPack())),
15286ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet      BTT(btt), Value(value), Loc(loc), RParen(rparen),
15296ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet      LhsType(lhsType), RhsType(rhsType) { }
15306ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet
15316ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet
15326ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet  explicit BinaryTypeTraitExpr(EmptyShell Empty)
15336ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet    : Expr(BinaryTypeTraitExprClass, Empty), BTT(0), Value(false),
1534f187237d916afa97c491ac32fe98be7d335c5b63Francois Pichet      LhsType(), RhsType() { }
15356ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet
153663c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall  SourceRange getSourceRange() const {
15376ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet    return SourceRange(Loc, RParen);
15386ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet  }
15396ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet
15406ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet  BinaryTypeTrait getTrait() const {
15416ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet    return static_cast<BinaryTypeTrait>(BTT);
15426ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet  }
15436ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet
15446ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet  QualType getLhsType() const { return LhsType->getType(); }
15456ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet  QualType getRhsType() const { return RhsType->getType(); }
15466ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet
15476ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet  TypeSourceInfo *getLhsTypeSourceInfo() const { return LhsType; }
15486ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet  TypeSourceInfo *getRhsTypeSourceInfo() const { return RhsType; }
15496ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet
15506ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet  bool getValue() const { assert(!isTypeDependent()); return Value; }
15516ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet
15526ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet  static bool classof(const Stmt *T) {
15536ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet    return T->getStmtClass() == BinaryTypeTraitExprClass;
15546ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet  }
15556ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet  static bool classof(const BinaryTypeTraitExpr *) { return true; }
15566ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet
15576ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet  // Iterators
155863c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall  child_range children() { return child_range(); }
15596ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet
15606ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet  friend class ASTStmtReader;
15616ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet};
15626ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet
15637bb12da2b0749eeebb21854c77877736969e59f2John McCall/// \brief A reference to an overloaded function set, either an
15647bb12da2b0749eeebb21854c77877736969e59f2John McCall/// \t UnresolvedLookupExpr or an \t UnresolvedMemberExpr.
15657bb12da2b0749eeebb21854c77877736969e59f2John McCallclass OverloadExpr : public Expr {
1566ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  /// The results.  These are undesugared, which is to say, they may
15677bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// include UsingShadowDecls.  Access is relative to the naming
15687bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// class.
1569928e6fcf66fc4f342bcf7cc96bf56986c9c2a833Douglas Gregor  // FIXME: Allocate this data after the OverloadExpr subclass.
1570928e6fcf66fc4f342bcf7cc96bf56986c9c2a833Douglas Gregor  DeclAccessPair *Results;
1571928e6fcf66fc4f342bcf7cc96bf56986c9c2a833Douglas Gregor  unsigned NumResults;
1572ba13543329afac4a0d01304ec2ec4924d99306a6John McCall
15737bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// The common name of these declarations.
15742577743c5650c646fb705df01403707e94f2df04Abramo Bagnara  DeclarationNameInfo NameInfo;
1575ba13543329afac4a0d01304ec2ec4924d99306a6John McCall
15767bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// The scope specifier, if any.
1577ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  NestedNameSpecifier *Qualifier;
15787bb12da2b0749eeebb21854c77877736969e59f2John McCall
15797bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// The source range of the scope specifier.
1580ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  SourceRange QualifierRange;
1581ba13543329afac4a0d01304ec2ec4924d99306a6John McCall
1582a77eb0862507b900a10fa352af1568e639ed10b1Argyrios Kyrtzidisprotected:
15837bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// True if the name was a template-id.
15847bb12da2b0749eeebb21854c77877736969e59f2John McCall  bool HasExplicitTemplateArgs;
15857bb12da2b0749eeebb21854c77877736969e59f2John McCall
1586bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor  OverloadExpr(StmtClass K, ASTContext &C,
15877bb12da2b0749eeebb21854c77877736969e59f2John McCall               NestedNameSpecifier *Qualifier, SourceRange QRange,
15882577743c5650c646fb705df01403707e94f2df04Abramo Bagnara               const DeclarationNameInfo &NameInfo,
1589bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor               const TemplateArgumentListInfo *TemplateArgs,
1590bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor               UnresolvedSetIterator Begin, UnresolvedSetIterator End,
1591bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor               bool KnownDependent = false,
1592bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor               bool KnownContainsUnexpandedParameterPack = false);
15937bb12da2b0749eeebb21854c77877736969e59f2John McCall
1594a77eb0862507b900a10fa352af1568e639ed10b1Argyrios Kyrtzidis  OverloadExpr(StmtClass K, EmptyShell Empty)
1595a77eb0862507b900a10fa352af1568e639ed10b1Argyrios Kyrtzidis    : Expr(K, Empty), Results(0), NumResults(0),
1596a77eb0862507b900a10fa352af1568e639ed10b1Argyrios Kyrtzidis      Qualifier(0), HasExplicitTemplateArgs(false) { }
1597a77eb0862507b900a10fa352af1568e639ed10b1Argyrios Kyrtzidis
1598bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor  void initializeResults(ASTContext &C,
1599bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor                         UnresolvedSetIterator Begin,
1600bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor                         UnresolvedSetIterator End);
16017bb12da2b0749eeebb21854c77877736969e59f2John McCall
1602bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregorpublic:
16039c72c6088d591ace8503b842d39448c2040f3033John McCall  struct FindResult {
16049c72c6088d591ace8503b842d39448c2040f3033John McCall    OverloadExpr *Expression;
16059c72c6088d591ace8503b842d39448c2040f3033John McCall    bool IsAddressOfOperand;
16069c72c6088d591ace8503b842d39448c2040f3033John McCall    bool HasFormOfMemberPointer;
16079c72c6088d591ace8503b842d39448c2040f3033John McCall  };
16089c72c6088d591ace8503b842d39448c2040f3033John McCall
16097bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// Finds the overloaded expression in the given expression of
16107bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// OverloadTy.
16117bb12da2b0749eeebb21854c77877736969e59f2John McCall  ///
16129c72c6088d591ace8503b842d39448c2040f3033John McCall  /// \return the expression (which must be there) and true if it has
16139c72c6088d591ace8503b842d39448c2040f3033John McCall  /// the particular form of a member pointer expression
16149c72c6088d591ace8503b842d39448c2040f3033John McCall  static FindResult find(Expr *E) {
16157bb12da2b0749eeebb21854c77877736969e59f2John McCall    assert(E->getType()->isSpecificBuiltinType(BuiltinType::Overload));
16167bb12da2b0749eeebb21854c77877736969e59f2John McCall
16179c72c6088d591ace8503b842d39448c2040f3033John McCall    FindResult Result;
16189c72c6088d591ace8503b842d39448c2040f3033John McCall
16197bb12da2b0749eeebb21854c77877736969e59f2John McCall    E = E->IgnoreParens();
16209c72c6088d591ace8503b842d39448c2040f3033John McCall    if (isa<UnaryOperator>(E)) {
16219c72c6088d591ace8503b842d39448c2040f3033John McCall      assert(cast<UnaryOperator>(E)->getOpcode() == UO_AddrOf);
16229c72c6088d591ace8503b842d39448c2040f3033John McCall      E = cast<UnaryOperator>(E)->getSubExpr();
16239c72c6088d591ace8503b842d39448c2040f3033John McCall      OverloadExpr *Ovl = cast<OverloadExpr>(E->IgnoreParens());
16249c72c6088d591ace8503b842d39448c2040f3033John McCall
16259c72c6088d591ace8503b842d39448c2040f3033John McCall      Result.HasFormOfMemberPointer = (E == Ovl && Ovl->getQualifier());
16269c72c6088d591ace8503b842d39448c2040f3033John McCall      Result.IsAddressOfOperand = true;
16279c72c6088d591ace8503b842d39448c2040f3033John McCall      Result.Expression = Ovl;
16289c72c6088d591ace8503b842d39448c2040f3033John McCall    } else {
16299c72c6088d591ace8503b842d39448c2040f3033John McCall      Result.HasFormOfMemberPointer = false;
16309c72c6088d591ace8503b842d39448c2040f3033John McCall      Result.IsAddressOfOperand = false;
16319c72c6088d591ace8503b842d39448c2040f3033John McCall      Result.Expression = cast<OverloadExpr>(E);
16329c72c6088d591ace8503b842d39448c2040f3033John McCall    }
16339c72c6088d591ace8503b842d39448c2040f3033John McCall
16349c72c6088d591ace8503b842d39448c2040f3033John McCall    return Result;
16357bb12da2b0749eeebb21854c77877736969e59f2John McCall  }
16367bb12da2b0749eeebb21854c77877736969e59f2John McCall
1637e9ee23edd17c4bb7f271e67f8790792b4de677fcJohn McCall  /// Gets the naming class of this lookup, if any.
1638e9ee23edd17c4bb7f271e67f8790792b4de677fcJohn McCall  CXXRecordDecl *getNamingClass() const;
1639e9ee23edd17c4bb7f271e67f8790792b4de677fcJohn McCall
16407bb12da2b0749eeebb21854c77877736969e59f2John McCall  typedef UnresolvedSetImpl::iterator decls_iterator;
1641928e6fcf66fc4f342bcf7cc96bf56986c9c2a833Douglas Gregor  decls_iterator decls_begin() const { return UnresolvedSetIterator(Results); }
1642928e6fcf66fc4f342bcf7cc96bf56986c9c2a833Douglas Gregor  decls_iterator decls_end() const {
1643928e6fcf66fc4f342bcf7cc96bf56986c9c2a833Douglas Gregor    return UnresolvedSetIterator(Results + NumResults);
1644928e6fcf66fc4f342bcf7cc96bf56986c9c2a833Douglas Gregor  }
1645a77eb0862507b900a10fa352af1568e639ed10b1Argyrios Kyrtzidis
16467bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// Gets the number of declarations in the unresolved set.
1647928e6fcf66fc4f342bcf7cc96bf56986c9c2a833Douglas Gregor  unsigned getNumDecls() const { return NumResults; }
16487bb12da2b0749eeebb21854c77877736969e59f2John McCall
16492577743c5650c646fb705df01403707e94f2df04Abramo Bagnara  /// Gets the full name info.
16502577743c5650c646fb705df01403707e94f2df04Abramo Bagnara  const DeclarationNameInfo &getNameInfo() const { return NameInfo; }
16512577743c5650c646fb705df01403707e94f2df04Abramo Bagnara  void setNameInfo(const DeclarationNameInfo &N) { NameInfo = N; }
16522577743c5650c646fb705df01403707e94f2df04Abramo Bagnara
16537bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// Gets the name looked up.
16542577743c5650c646fb705df01403707e94f2df04Abramo Bagnara  DeclarationName getName() const { return NameInfo.getName(); }
16552577743c5650c646fb705df01403707e94f2df04Abramo Bagnara  void setName(DeclarationName N) { NameInfo.setName(N); }
16567bb12da2b0749eeebb21854c77877736969e59f2John McCall
16577bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// Gets the location of the name.
16582577743c5650c646fb705df01403707e94f2df04Abramo Bagnara  SourceLocation getNameLoc() const { return NameInfo.getLoc(); }
16592577743c5650c646fb705df01403707e94f2df04Abramo Bagnara  void setNameLoc(SourceLocation Loc) { NameInfo.setLoc(Loc); }
16607bb12da2b0749eeebb21854c77877736969e59f2John McCall
16617bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// Fetches the nested-name qualifier, if one was given.
16627bb12da2b0749eeebb21854c77877736969e59f2John McCall  NestedNameSpecifier *getQualifier() const { return Qualifier; }
1663a77eb0862507b900a10fa352af1568e639ed10b1Argyrios Kyrtzidis  void setQualifier(NestedNameSpecifier *NNS) { Qualifier = NNS; }
16647bb12da2b0749eeebb21854c77877736969e59f2John McCall
16657bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// Fetches the range of the nested-name qualifier.
16667bb12da2b0749eeebb21854c77877736969e59f2John McCall  SourceRange getQualifierRange() const { return QualifierRange; }
1667a77eb0862507b900a10fa352af1568e639ed10b1Argyrios Kyrtzidis  void setQualifierRange(SourceRange R) { QualifierRange = R; }
16687bb12da2b0749eeebb21854c77877736969e59f2John McCall
16697bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// \brief Determines whether this expression had an explicit
16707bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// template argument list, e.g. f<int>.
16717bb12da2b0749eeebb21854c77877736969e59f2John McCall  bool hasExplicitTemplateArgs() const { return HasExplicitTemplateArgs; }
16727bb12da2b0749eeebb21854c77877736969e59f2John McCall
16737bb12da2b0749eeebb21854c77877736969e59f2John McCall  ExplicitTemplateArgumentList &getExplicitTemplateArgs(); // defined far below
16747bb12da2b0749eeebb21854c77877736969e59f2John McCall
16757bb12da2b0749eeebb21854c77877736969e59f2John McCall  const ExplicitTemplateArgumentList &getExplicitTemplateArgs() const {
16767bb12da2b0749eeebb21854c77877736969e59f2John McCall    return const_cast<OverloadExpr*>(this)->getExplicitTemplateArgs();
16777bb12da2b0749eeebb21854c77877736969e59f2John McCall  }
16787bb12da2b0749eeebb21854c77877736969e59f2John McCall
1679096832c5ed5b9106fa177ebc148489760c3bc496John McCall  /// \brief Retrieves the optional explicit template arguments.
1680096832c5ed5b9106fa177ebc148489760c3bc496John McCall  /// This points to the same data as getExplicitTemplateArgs(), but
1681096832c5ed5b9106fa177ebc148489760c3bc496John McCall  /// returns null if there are no explicit template arguments.
1682096832c5ed5b9106fa177ebc148489760c3bc496John McCall  const ExplicitTemplateArgumentList *getOptionalExplicitTemplateArgs() {
1683096832c5ed5b9106fa177ebc148489760c3bc496John McCall    if (!hasExplicitTemplateArgs()) return 0;
1684096832c5ed5b9106fa177ebc148489760c3bc496John McCall    return &getExplicitTemplateArgs();
16857bb12da2b0749eeebb21854c77877736969e59f2John McCall  }
16867bb12da2b0749eeebb21854c77877736969e59f2John McCall
16877bb12da2b0749eeebb21854c77877736969e59f2John McCall  static bool classof(const Stmt *T) {
16887bb12da2b0749eeebb21854c77877736969e59f2John McCall    return T->getStmtClass() == UnresolvedLookupExprClass ||
16897bb12da2b0749eeebb21854c77877736969e59f2John McCall           T->getStmtClass() == UnresolvedMemberExprClass;
16907bb12da2b0749eeebb21854c77877736969e59f2John McCall  }
16917bb12da2b0749eeebb21854c77877736969e59f2John McCall  static bool classof(const OverloadExpr *) { return true; }
16924045107b7384fd68eed5e3e2f06fc2a47e7be0a6Argyrios Kyrtzidis
16934045107b7384fd68eed5e3e2f06fc2a47e7be0a6Argyrios Kyrtzidis  friend class ASTStmtReader;
16944045107b7384fd68eed5e3e2f06fc2a47e7be0a6Argyrios Kyrtzidis  friend class ASTStmtWriter;
16957bb12da2b0749eeebb21854c77877736969e59f2John McCall};
16967bb12da2b0749eeebb21854c77877736969e59f2John McCall
16977bb12da2b0749eeebb21854c77877736969e59f2John McCall/// \brief A reference to a name which we were able to look up during
16987bb12da2b0749eeebb21854c77877736969e59f2John McCall/// parsing but could not resolve to a specific declaration.  This
16997bb12da2b0749eeebb21854c77877736969e59f2John McCall/// arises in several ways:
17007bb12da2b0749eeebb21854c77877736969e59f2John McCall///   * we might be waiting for argument-dependent lookup
17017bb12da2b0749eeebb21854c77877736969e59f2John McCall///   * the name might resolve to an overloaded function
17027bb12da2b0749eeebb21854c77877736969e59f2John McCall/// and eventually:
17037bb12da2b0749eeebb21854c77877736969e59f2John McCall///   * the lookup might have included a function template
17047bb12da2b0749eeebb21854c77877736969e59f2John McCall/// These never include UnresolvedUsingValueDecls, which are always
17057bb12da2b0749eeebb21854c77877736969e59f2John McCall/// class members and therefore appear only in
17067bb12da2b0749eeebb21854c77877736969e59f2John McCall/// UnresolvedMemberLookupExprs.
17077bb12da2b0749eeebb21854c77877736969e59f2John McCallclass UnresolvedLookupExpr : public OverloadExpr {
1708ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  /// True if these lookup results should be extended by
1709ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  /// argument-dependent lookup if this is the operand of a function
1710ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  /// call.
1711ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  bool RequiresADL;
1712ba13543329afac4a0d01304ec2ec4924d99306a6John McCall
17137453ed4cb2cab113de3378df371b1c6f1243d832John McCall  /// True if these lookup results are overloaded.  This is pretty
17147453ed4cb2cab113de3378df371b1c6f1243d832John McCall  /// trivially rederivable if we urgently need to kill this field.
17157453ed4cb2cab113de3378df371b1c6f1243d832John McCall  bool Overloaded;
17167453ed4cb2cab113de3378df371b1c6f1243d832John McCall
17177bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// The naming class (C++ [class.access.base]p5) of the lookup, if
17187bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// any.  This can generally be recalculated from the context chain,
17197bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// but that can be fairly expensive for unqualified lookups.  If we
17207bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// want to improve memory use here, this could go in a union
17217bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// against the qualified-lookup bits.
17227bb12da2b0749eeebb21854c77877736969e59f2John McCall  CXXRecordDecl *NamingClass;
1723f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall
1724bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor  UnresolvedLookupExpr(ASTContext &C,
1725928e6fcf66fc4f342bcf7cc96bf56986c9c2a833Douglas Gregor                       CXXRecordDecl *NamingClass,
1726ba13543329afac4a0d01304ec2ec4924d99306a6John McCall                       NestedNameSpecifier *Qualifier, SourceRange QRange,
17272577743c5650c646fb705df01403707e94f2df04Abramo Bagnara                       const DeclarationNameInfo &NameInfo,
1728bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor                       bool RequiresADL, bool Overloaded,
1729bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor                       const TemplateArgumentListInfo *TemplateArgs,
17305a84dec38cfa9e084377a3167b474c79283c82faDouglas Gregor                       UnresolvedSetIterator Begin, UnresolvedSetIterator End)
1731bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor    : OverloadExpr(UnresolvedLookupExprClass, C, Qualifier,  QRange, NameInfo,
1732bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor                   TemplateArgs, Begin, End),
17337bb12da2b0749eeebb21854c77877736969e59f2John McCall      RequiresADL(RequiresADL), Overloaded(Overloaded), NamingClass(NamingClass)
1734ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  {}
1735ba13543329afac4a0d01304ec2ec4924d99306a6John McCall
1736bd65bb511c26549c96b829c1282e4c877588564aArgyrios Kyrtzidis  UnresolvedLookupExpr(EmptyShell Empty)
1737bd65bb511c26549c96b829c1282e4c877588564aArgyrios Kyrtzidis    : OverloadExpr(UnresolvedLookupExprClass, Empty),
1738bd65bb511c26549c96b829c1282e4c877588564aArgyrios Kyrtzidis      RequiresADL(false), Overloaded(false), NamingClass(0)
1739bd65bb511c26549c96b829c1282e4c877588564aArgyrios Kyrtzidis  {}
1740bd65bb511c26549c96b829c1282e4c877588564aArgyrios Kyrtzidis
1741ba13543329afac4a0d01304ec2ec4924d99306a6John McCallpublic:
1742ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  static UnresolvedLookupExpr *Create(ASTContext &C,
1743c373d48502ca7683ab55385f5bd624d778eb288dJohn McCall                                      CXXRecordDecl *NamingClass,
1744ba13543329afac4a0d01304ec2ec4924d99306a6John McCall                                      NestedNameSpecifier *Qualifier,
1745ba13543329afac4a0d01304ec2ec4924d99306a6John McCall                                      SourceRange QualifierRange,
17462577743c5650c646fb705df01403707e94f2df04Abramo Bagnara                                      const DeclarationNameInfo &NameInfo,
17475a84dec38cfa9e084377a3167b474c79283c82faDouglas Gregor                                      bool ADL, bool Overloaded,
17485a84dec38cfa9e084377a3167b474c79283c82faDouglas Gregor                                      UnresolvedSetIterator Begin,
17495a84dec38cfa9e084377a3167b474c79283c82faDouglas Gregor                                      UnresolvedSetIterator End) {
1750bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor    return new(C) UnresolvedLookupExpr(C, NamingClass, Qualifier,
1751bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor                                       QualifierRange, NameInfo, ADL,
1752bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor                                       Overloaded, 0, Begin, End);
1753ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  }
1754ba13543329afac4a0d01304ec2ec4924d99306a6John McCall
1755f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  static UnresolvedLookupExpr *Create(ASTContext &C,
1756c373d48502ca7683ab55385f5bd624d778eb288dJohn McCall                                      CXXRecordDecl *NamingClass,
1757f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall                                      NestedNameSpecifier *Qualifier,
1758f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall                                      SourceRange QualifierRange,
17592577743c5650c646fb705df01403707e94f2df04Abramo Bagnara                                      const DeclarationNameInfo &NameInfo,
1760f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall                                      bool ADL,
17615a84dec38cfa9e084377a3167b474c79283c82faDouglas Gregor                                      const TemplateArgumentListInfo &Args,
17625a84dec38cfa9e084377a3167b474c79283c82faDouglas Gregor                                      UnresolvedSetIterator Begin,
17635a84dec38cfa9e084377a3167b474c79283c82faDouglas Gregor                                      UnresolvedSetIterator End);
1764f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall
1765bd65bb511c26549c96b829c1282e4c877588564aArgyrios Kyrtzidis  static UnresolvedLookupExpr *CreateEmpty(ASTContext &C,
1766def0354384d9c4431f7b58b664b59896d4623028Douglas Gregor                                           bool HasExplicitTemplateArgs,
1767bd65bb511c26549c96b829c1282e4c877588564aArgyrios Kyrtzidis                                           unsigned NumTemplateArgs);
1768bd65bb511c26549c96b829c1282e4c877588564aArgyrios Kyrtzidis
1769ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  /// True if this declaration should be extended by
1770ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  /// argument-dependent lookup.
1771ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  bool requiresADL() const { return RequiresADL; }
1772bd65bb511c26549c96b829c1282e4c877588564aArgyrios Kyrtzidis  void setRequiresADL(bool V) { RequiresADL = V; }
1773ba13543329afac4a0d01304ec2ec4924d99306a6John McCall
17747453ed4cb2cab113de3378df371b1c6f1243d832John McCall  /// True if this lookup is overloaded.
17757453ed4cb2cab113de3378df371b1c6f1243d832John McCall  bool isOverloaded() const { return Overloaded; }
1776bd65bb511c26549c96b829c1282e4c877588564aArgyrios Kyrtzidis  void setOverloaded(bool V) { Overloaded = V; }
17777453ed4cb2cab113de3378df371b1c6f1243d832John McCall
1778c373d48502ca7683ab55385f5bd624d778eb288dJohn McCall  /// Gets the 'naming class' (in the sense of C++0x
1779c373d48502ca7683ab55385f5bd624d778eb288dJohn McCall  /// [class.access.base]p5) of the lookup.  This is the scope
1780c373d48502ca7683ab55385f5bd624d778eb288dJohn McCall  /// that was looked in to find these results.
1781c373d48502ca7683ab55385f5bd624d778eb288dJohn McCall  CXXRecordDecl *getNamingClass() const { return NamingClass; }
1782bd65bb511c26549c96b829c1282e4c877588564aArgyrios Kyrtzidis  void setNamingClass(CXXRecordDecl *D) { NamingClass = D; }
1783c373d48502ca7683ab55385f5bd624d778eb288dJohn McCall
1784f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  // Note that, inconsistently with the explicit-template-argument AST
1785f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  // nodes, users are *forbidden* from calling these methods on objects
1786f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  // without explicit template arguments.
1787f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall
17887bb12da2b0749eeebb21854c77877736969e59f2John McCall  ExplicitTemplateArgumentList &getExplicitTemplateArgs() {
17897bb12da2b0749eeebb21854c77877736969e59f2John McCall    assert(hasExplicitTemplateArgs());
17907bb12da2b0749eeebb21854c77877736969e59f2John McCall    return *reinterpret_cast<ExplicitTemplateArgumentList*>(this + 1);
17917bb12da2b0749eeebb21854c77877736969e59f2John McCall  }
17927bb12da2b0749eeebb21854c77877736969e59f2John McCall
1793f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  /// Gets a reference to the explicit template argument list.
1794f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  const ExplicitTemplateArgumentList &getExplicitTemplateArgs() const {
1795f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall    assert(hasExplicitTemplateArgs());
1796f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall    return *reinterpret_cast<const ExplicitTemplateArgumentList*>(this + 1);
1797f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  }
1798f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall
1799096832c5ed5b9106fa177ebc148489760c3bc496John McCall  /// \brief Retrieves the optional explicit template arguments.
1800096832c5ed5b9106fa177ebc148489760c3bc496John McCall  /// This points to the same data as getExplicitTemplateArgs(), but
1801096832c5ed5b9106fa177ebc148489760c3bc496John McCall  /// returns null if there are no explicit template arguments.
1802096832c5ed5b9106fa177ebc148489760c3bc496John McCall  const ExplicitTemplateArgumentList *getOptionalExplicitTemplateArgs() {
1803096832c5ed5b9106fa177ebc148489760c3bc496John McCall    if (!hasExplicitTemplateArgs()) return 0;
1804096832c5ed5b9106fa177ebc148489760c3bc496John McCall    return &getExplicitTemplateArgs();
1805096832c5ed5b9106fa177ebc148489760c3bc496John McCall  }
1806096832c5ed5b9106fa177ebc148489760c3bc496John McCall
1807f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  /// \brief Copies the template arguments (if present) into the given
1808f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  /// structure.
1809f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  void copyTemplateArgumentsInto(TemplateArgumentListInfo &List) const {
1810f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall    getExplicitTemplateArgs().copyInto(List);
1811f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  }
1812ba13543329afac4a0d01304ec2ec4924d99306a6John McCall
1813f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  SourceLocation getLAngleLoc() const {
1814f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall    return getExplicitTemplateArgs().LAngleLoc;
1815f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  }
1816f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall
1817f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  SourceLocation getRAngleLoc() const {
1818f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall    return getExplicitTemplateArgs().RAngleLoc;
1819f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  }
1820f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall
1821f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  TemplateArgumentLoc const *getTemplateArgs() const {
1822f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall    return getExplicitTemplateArgs().getTemplateArgs();
1823f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  }
1824f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall
1825f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  unsigned getNumTemplateArgs() const {
1826f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall    return getExplicitTemplateArgs().NumTemplateArgs;
1827f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  }
1828ba13543329afac4a0d01304ec2ec4924d99306a6John McCall
182963c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall  SourceRange getSourceRange() const {
18302577743c5650c646fb705df01403707e94f2df04Abramo Bagnara    SourceRange Range(getNameInfo().getSourceRange());
18317bb12da2b0749eeebb21854c77877736969e59f2John McCall    if (getQualifier()) Range.setBegin(getQualifierRange().getBegin());
1832f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall    if (hasExplicitTemplateArgs()) Range.setEnd(getRAngleLoc());
1833f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall    return Range;
1834ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  }
1835ba13543329afac4a0d01304ec2ec4924d99306a6John McCall
183663c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall  child_range children() { return child_range(); }
1837ba13543329afac4a0d01304ec2ec4924d99306a6John McCall
1838ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  static bool classof(const Stmt *T) {
1839ba13543329afac4a0d01304ec2ec4924d99306a6John McCall    return T->getStmtClass() == UnresolvedLookupExprClass;
1840ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  }
1841ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  static bool classof(const UnresolvedLookupExpr *) { return true; }
1842ba13543329afac4a0d01304ec2ec4924d99306a6John McCall};
1843ba13543329afac4a0d01304ec2ec4924d99306a6John McCall
18445953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor/// \brief A qualified reference to a name whose declaration cannot
18455953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor/// yet be resolved.
18465953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor///
1847ba13543329afac4a0d01304ec2ec4924d99306a6John McCall/// DependentScopeDeclRefExpr is similar to DeclRefExpr in that
1848a2813cec2605ce7878d1b13471d685f689b251afDouglas Gregor/// it expresses a reference to a declaration such as
18495953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor/// X<T>::value. The difference, however, is that an
1850865d447ac6a4721ab58e898d014a21f2eff74b06John McCall/// DependentScopeDeclRefExpr node is used only within C++ templates when
18515953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor/// the qualification (e.g., X<T>::) refers to a dependent type. In
18525953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor/// this case, X<T>::value cannot resolve to a declaration because the
18535953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor/// declaration will differ from on instantiation of X<T> to the
1854865d447ac6a4721ab58e898d014a21f2eff74b06John McCall/// next. Therefore, DependentScopeDeclRefExpr keeps track of the
1855ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor/// qualifier (X<T>::) and the name of the entity being referenced
1856a2813cec2605ce7878d1b13471d685f689b251afDouglas Gregor/// ("value"). Such expressions will instantiate to a DeclRefExpr once the
1857a2813cec2605ce7878d1b13471d685f689b251afDouglas Gregor/// declaration can be found.
1858865d447ac6a4721ab58e898d014a21f2eff74b06John McCallclass DependentScopeDeclRefExpr : public Expr {
18595953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor  /// The name of the entity we will be referencing.
18602577743c5650c646fb705df01403707e94f2df04Abramo Bagnara  DeclarationNameInfo NameInfo;
18615953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor
18625953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor  /// QualifierRange - The source range that covers the
18635953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor  /// nested-name-specifier.
18645953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor  SourceRange QualifierRange;
18655953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor
1866ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor  /// \brief The nested-name-specifier that qualifies this unresolved
1867ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor  /// declaration name.
1868f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  NestedNameSpecifier *Qualifier;
18695953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor
1870f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  /// \brief Whether the name includes explicit template arguments.
1871f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  bool HasExplicitTemplateArgs;
18721eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1873f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  DependentScopeDeclRefExpr(QualType T,
1874f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall                            NestedNameSpecifier *Qualifier,
1875f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall                            SourceRange QualifierRange,
18762577743c5650c646fb705df01403707e94f2df04Abramo Bagnara                            const DeclarationNameInfo &NameInfo,
1877bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor                            const TemplateArgumentListInfo *Args);
1878f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall
1879f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCallpublic:
1880f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  static DependentScopeDeclRefExpr *Create(ASTContext &C,
1881f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall                                           NestedNameSpecifier *Qualifier,
1882f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall                                           SourceRange QualifierRange,
18832577743c5650c646fb705df01403707e94f2df04Abramo Bagnara                                           const DeclarationNameInfo &NameInfo,
1884f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall                              const TemplateArgumentListInfo *TemplateArgs = 0);
18855953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor
188612dffcddb60380c5bed4f085a1f51534afda3b87Argyrios Kyrtzidis  static DependentScopeDeclRefExpr *CreateEmpty(ASTContext &C,
1887def0354384d9c4431f7b58b664b59896d4623028Douglas Gregor                                                bool HasExplicitTemplateArgs,
188812dffcddb60380c5bed4f085a1f51534afda3b87Argyrios Kyrtzidis                                                unsigned NumTemplateArgs);
188912dffcddb60380c5bed4f085a1f51534afda3b87Argyrios Kyrtzidis
18905953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor  /// \brief Retrieve the name that this expression refers to.
18912577743c5650c646fb705df01403707e94f2df04Abramo Bagnara  const DeclarationNameInfo &getNameInfo() const { return NameInfo; }
18922577743c5650c646fb705df01403707e94f2df04Abramo Bagnara  void setNameInfo(const DeclarationNameInfo &N) { NameInfo =  N; }
18932577743c5650c646fb705df01403707e94f2df04Abramo Bagnara
18942577743c5650c646fb705df01403707e94f2df04Abramo Bagnara  /// \brief Retrieve the name that this expression refers to.
18952577743c5650c646fb705df01403707e94f2df04Abramo Bagnara  DeclarationName getDeclName() const { return NameInfo.getName(); }
18962577743c5650c646fb705df01403707e94f2df04Abramo Bagnara  void setDeclName(DeclarationName N) { NameInfo.setName(N); }
18975953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor
18985953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor  /// \brief Retrieve the location of the name within the expression.
18992577743c5650c646fb705df01403707e94f2df04Abramo Bagnara  SourceLocation getLocation() const { return NameInfo.getLoc(); }
19002577743c5650c646fb705df01403707e94f2df04Abramo Bagnara  void setLocation(SourceLocation L) { NameInfo.setLoc(L); }
19015953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor
19025953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor  /// \brief Retrieve the source range of the nested-name-specifier.
19035953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor  SourceRange getQualifierRange() const { return QualifierRange; }
190412dffcddb60380c5bed4f085a1f51534afda3b87Argyrios Kyrtzidis  void setQualifierRange(SourceRange R) { QualifierRange = R; }
19055953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor
1906ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor  /// \brief Retrieve the nested-name-specifier that qualifies this
1907ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor  /// declaration.
1908edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor  NestedNameSpecifier *getQualifier() const { return Qualifier; }
190912dffcddb60380c5bed4f085a1f51534afda3b87Argyrios Kyrtzidis  void setQualifier(NestedNameSpecifier *NNS) { Qualifier = NNS; }
19101eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1911f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  /// Determines whether this lookup had explicit template arguments.
1912f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  bool hasExplicitTemplateArgs() const { return HasExplicitTemplateArgs; }
19131eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1914f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  // Note that, inconsistently with the explicit-template-argument AST
1915f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  // nodes, users are *forbidden* from calling these methods on objects
1916f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  // without explicit template arguments.
19171eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
191812dffcddb60380c5bed4f085a1f51534afda3b87Argyrios Kyrtzidis  ExplicitTemplateArgumentList &getExplicitTemplateArgs() {
191912dffcddb60380c5bed4f085a1f51534afda3b87Argyrios Kyrtzidis    assert(hasExplicitTemplateArgs());
192012dffcddb60380c5bed4f085a1f51534afda3b87Argyrios Kyrtzidis    return *reinterpret_cast<ExplicitTemplateArgumentList*>(this + 1);
192112dffcddb60380c5bed4f085a1f51534afda3b87Argyrios Kyrtzidis  }
192212dffcddb60380c5bed4f085a1f51534afda3b87Argyrios Kyrtzidis
1923f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  /// Gets a reference to the explicit template argument list.
1924f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  const ExplicitTemplateArgumentList &getExplicitTemplateArgs() const {
1925f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall    assert(hasExplicitTemplateArgs());
1926f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall    return *reinterpret_cast<const ExplicitTemplateArgumentList*>(this + 1);
1927f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  }
19281eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1929096832c5ed5b9106fa177ebc148489760c3bc496John McCall  /// \brief Retrieves the optional explicit template arguments.
1930096832c5ed5b9106fa177ebc148489760c3bc496John McCall  /// This points to the same data as getExplicitTemplateArgs(), but
1931096832c5ed5b9106fa177ebc148489760c3bc496John McCall  /// returns null if there are no explicit template arguments.
1932096832c5ed5b9106fa177ebc148489760c3bc496John McCall  const ExplicitTemplateArgumentList *getOptionalExplicitTemplateArgs() {
1933096832c5ed5b9106fa177ebc148489760c3bc496John McCall    if (!hasExplicitTemplateArgs()) return 0;
1934096832c5ed5b9106fa177ebc148489760c3bc496John McCall    return &getExplicitTemplateArgs();
1935096832c5ed5b9106fa177ebc148489760c3bc496John McCall  }
1936096832c5ed5b9106fa177ebc148489760c3bc496John McCall
1937f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  /// \brief Copies the template arguments (if present) into the given
1938f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  /// structure.
1939f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  void copyTemplateArgumentsInto(TemplateArgumentListInfo &List) const {
1940f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall    getExplicitTemplateArgs().copyInto(List);
1941f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  }
1942f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall
1943f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  SourceLocation getLAngleLoc() const {
1944f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall    return getExplicitTemplateArgs().LAngleLoc;
1945edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor  }
19461eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1947f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  SourceLocation getRAngleLoc() const {
1948f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall    return getExplicitTemplateArgs().RAngleLoc;
1949f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  }
19501eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1951f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  TemplateArgumentLoc const *getTemplateArgs() const {
1952f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall    return getExplicitTemplateArgs().getTemplateArgs();
1953d5532b6cfff2977e0c59fa6ead7f7973984a620dJohn McCall  }
1954d5532b6cfff2977e0c59fa6ead7f7973984a620dJohn McCall
1955f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  unsigned getNumTemplateArgs() const {
1956f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall    return getExplicitTemplateArgs().NumTemplateArgs;
1957f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  }
19581eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
195963c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall  SourceRange getSourceRange() const {
1960f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall    SourceRange Range(QualifierRange.getBegin(), getLocation());
1961f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall    if (hasExplicitTemplateArgs())
1962f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall      Range.setEnd(getRAngleLoc());
1963f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall    return Range;
1964edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor  }
19651eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
19661eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  static bool classof(const Stmt *T) {
1967f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall    return T->getStmtClass() == DependentScopeDeclRefExprClass;
1968edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor  }
1969f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  static bool classof(const DependentScopeDeclRefExpr *) { return true; }
1970f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall
197163c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall  child_range children() { return child_range(); }
19724045107b7384fd68eed5e3e2f06fc2a47e7be0a6Argyrios Kyrtzidis
19734045107b7384fd68eed5e3e2f06fc2a47e7be0a6Argyrios Kyrtzidis  friend class ASTStmtReader;
19744045107b7384fd68eed5e3e2f06fc2a47e7be0a6Argyrios Kyrtzidis  friend class ASTStmtWriter;
1975edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor};
19761eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
19774765fa05b5652fcc4356371c2f481d0ea9a1b007John McCall/// Represents an expression --- generally a full-expression --- which
19784765fa05b5652fcc4356371c2f481d0ea9a1b007John McCall/// introduces cleanups to be run at the end of the sub-expression's
19794765fa05b5652fcc4356371c2f481d0ea9a1b007John McCall/// evaluation.  The most common source of expression-introduced
19804765fa05b5652fcc4356371c2f481d0ea9a1b007John McCall/// cleanups is temporary objects in C++, but several other C++
19814765fa05b5652fcc4356371c2f481d0ea9a1b007John McCall/// expressions can create cleanups.
19824765fa05b5652fcc4356371c2f481d0ea9a1b007John McCallclass ExprWithCleanups : public Expr {
198302bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson  Stmt *SubExpr;
19841eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1985ff6b3d64c9f07155f1414411b8451d7bf8937c62Anders Carlsson  CXXTemporary **Temps;
1986ff6b3d64c9f07155f1414411b8451d7bf8937c62Anders Carlsson  unsigned NumTemps;
198702bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson
19884765fa05b5652fcc4356371c2f481d0ea9a1b007John McCall  ExprWithCleanups(ASTContext &C, Expr *SubExpr,
19894765fa05b5652fcc4356371c2f481d0ea9a1b007John McCall                   CXXTemporary **Temps, unsigned NumTemps);
19904765fa05b5652fcc4356371c2f481d0ea9a1b007John McCall
199188eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlssonpublic:
19924765fa05b5652fcc4356371c2f481d0ea9a1b007John McCall  ExprWithCleanups(EmptyShell Empty)
19934765fa05b5652fcc4356371c2f481d0ea9a1b007John McCall    : Expr(ExprWithCleanupsClass, Empty),
1994d2598368876cfe40bc8465540033bc5b5e58d8afChris Lattner      SubExpr(0), Temps(0), NumTemps(0) {}
1995d2598368876cfe40bc8465540033bc5b5e58d8afChris Lattner
19964765fa05b5652fcc4356371c2f481d0ea9a1b007John McCall  static ExprWithCleanups *Create(ASTContext &C, Expr *SubExpr,
19970ece491d8f62ce67f047491a6703fac0d3bd4ff4Anders Carlsson                                        CXXTemporary **Temps,
19980ece491d8f62ce67f047491a6703fac0d3bd4ff4Anders Carlsson                                        unsigned NumTemps);
19991eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
200088eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlsson  unsigned getNumTemporaries() const { return NumTemps; }
2001d04ed416be7c55bddddab1fa3fd38a0113a6b3daTed Kremenek  void setNumTemporaries(ASTContext &C, unsigned N);
2002d2598368876cfe40bc8465540033bc5b5e58d8afChris Lattner
200388eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlsson  CXXTemporary *getTemporary(unsigned i) {
200488eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlsson    assert(i < NumTemps && "Index out of range");
200588eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlsson    return Temps[i];
200688eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlsson  }
2007f0721fe438d7e40c168e5d664970e7830bc138fbAnders Carlsson  const CXXTemporary *getTemporary(unsigned i) const {
20084765fa05b5652fcc4356371c2f481d0ea9a1b007John McCall    return const_cast<ExprWithCleanups*>(this)->getTemporary(i);
2009f0721fe438d7e40c168e5d664970e7830bc138fbAnders Carlsson  }
2010d2598368876cfe40bc8465540033bc5b5e58d8afChris Lattner  void setTemporary(unsigned i, CXXTemporary *T) {
2011d2598368876cfe40bc8465540033bc5b5e58d8afChris Lattner    assert(i < NumTemps && "Index out of range");
2012d2598368876cfe40bc8465540033bc5b5e58d8afChris Lattner    Temps[i] = T;
2013d2598368876cfe40bc8465540033bc5b5e58d8afChris Lattner  }
20141eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
201502bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson  Expr *getSubExpr() { return cast<Expr>(SubExpr); }
2016f0721fe438d7e40c168e5d664970e7830bc138fbAnders Carlsson  const Expr *getSubExpr() const { return cast<Expr>(SubExpr); }
201788eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlsson  void setSubExpr(Expr *E) { SubExpr = E; }
201802bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson
201963c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall  SourceRange getSourceRange() const {
202096be6917e1c4ba1f4435a14c9e7c6c139571d086Douglas Gregor    return SubExpr->getSourceRange();
202196be6917e1c4ba1f4435a14c9e7c6c139571d086Douglas Gregor  }
202202bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson
202302bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson  // Implement isa/cast/dyncast/etc.
202402bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson  static bool classof(const Stmt *T) {
20254765fa05b5652fcc4356371c2f481d0ea9a1b007John McCall    return T->getStmtClass() == ExprWithCleanupsClass;
202602bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson  }
20274765fa05b5652fcc4356371c2f481d0ea9a1b007John McCall  static bool classof(const ExprWithCleanups *) { return true; }
202802bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson
202902bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson  // Iterators
203063c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall  child_range children() { return child_range(&SubExpr, &SubExpr + 1); }
203102bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson};
203202bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson
2033d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// \brief Describes an explicit type conversion that uses functional
2034d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// notion but could not be resolved because one or more arguments are
2035d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// type-dependent.
2036d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor///
2037d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// The explicit type conversions expressed by
2038d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// CXXUnresolvedConstructExpr have the form \c T(a1, a2, ..., aN),
2039d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// where \c T is some type and \c a1, a2, ..., aN are values, and
2040d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// either \C T is a dependent type or one or more of the \c a's is
2041d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// type-dependent. For example, this would occur in a template such
2042d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// as:
2043d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor///
2044d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// \code
2045d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor///   template<typename T, typename A1>
2046d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor///   inline T make_a(const A1& a1) {
2047d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor///     return T(a1);
2048d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor///   }
2049d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// \endcode
2050d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor///
2051d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// When the returned expression is instantiated, it may resolve to a
2052d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// constructor call, conversion function call, or some kind of type
2053d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// conversion.
2054d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregorclass CXXUnresolvedConstructExpr : public Expr {
2055d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  /// \brief The type being constructed.
2056ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor  TypeSourceInfo *Type;
2057ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor
2058d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  /// \brief The location of the left parentheses ('(').
2059d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  SourceLocation LParenLoc;
2060d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor
2061d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  /// \brief The location of the right parentheses (')').
2062d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  SourceLocation RParenLoc;
2063d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor
2064d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  /// \brief The number of arguments used to construct the type.
2065d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  unsigned NumArgs;
20661eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
2067ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor  CXXUnresolvedConstructExpr(TypeSourceInfo *Type,
2068d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor                             SourceLocation LParenLoc,
2069d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor                             Expr **Args,
2070d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor                             unsigned NumArgs,
2071d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor                             SourceLocation RParenLoc);
2072d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor
20738dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis  CXXUnresolvedConstructExpr(EmptyShell Empty, unsigned NumArgs)
2074ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor    : Expr(CXXUnresolvedConstructExprClass, Empty), Type(), NumArgs(NumArgs) { }
20758dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis
2076ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor  friend class ASTStmtReader;
2077ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor
2078d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregorpublic:
20791eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  static CXXUnresolvedConstructExpr *Create(ASTContext &C,
2080ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor                                            TypeSourceInfo *Type,
2081d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor                                            SourceLocation LParenLoc,
2082d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor                                            Expr **Args,
2083d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor                                            unsigned NumArgs,
2084d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor                                            SourceLocation RParenLoc);
2085d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor
20868dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis  static CXXUnresolvedConstructExpr *CreateEmpty(ASTContext &C,
20878dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis                                                 unsigned NumArgs);
20888dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis
2089d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  /// \brief Retrieve the type that is being constructed, as specified
2090d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  /// in the source code.
2091ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor  QualType getTypeAsWritten() const { return Type->getType(); }
2092d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor
2093ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor  /// \brief Retrieve the type source information for the type being
2094ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor  /// constructed.
2095ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor  TypeSourceInfo *getTypeSourceInfo() const { return Type; }
2096ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor
2097d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  /// \brief Retrieve the location of the left parentheses ('(') that
2098d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  /// precedes the argument list.
2099d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  SourceLocation getLParenLoc() const { return LParenLoc; }
2100d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  void setLParenLoc(SourceLocation L) { LParenLoc = L; }
2101d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor
2102d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  /// \brief Retrieve the location of the right parentheses (')') that
2103d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  /// follows the argument list.
2104d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  SourceLocation getRParenLoc() const { return RParenLoc; }
2105d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  void setRParenLoc(SourceLocation L) { RParenLoc = L; }
2106d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor
2107d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  /// \brief Retrieve the number of arguments.
2108d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  unsigned arg_size() const { return NumArgs; }
2109d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor
2110d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  typedef Expr** arg_iterator;
2111d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  arg_iterator arg_begin() { return reinterpret_cast<Expr**>(this + 1); }
2112d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  arg_iterator arg_end() { return arg_begin() + NumArgs; }
2113d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor
21141dd7383dc48718c452e71a625b29531dd96fbb9dJohn McCall  typedef const Expr* const * const_arg_iterator;
21151dd7383dc48718c452e71a625b29531dd96fbb9dJohn McCall  const_arg_iterator arg_begin() const {
21161dd7383dc48718c452e71a625b29531dd96fbb9dJohn McCall    return reinterpret_cast<const Expr* const *>(this + 1);
21171dd7383dc48718c452e71a625b29531dd96fbb9dJohn McCall  }
21181dd7383dc48718c452e71a625b29531dd96fbb9dJohn McCall  const_arg_iterator arg_end() const {
21191dd7383dc48718c452e71a625b29531dd96fbb9dJohn McCall    return arg_begin() + NumArgs;
21201dd7383dc48718c452e71a625b29531dd96fbb9dJohn McCall  }
21211dd7383dc48718c452e71a625b29531dd96fbb9dJohn McCall
2122d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  Expr *getArg(unsigned I) {
2123d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor    assert(I < NumArgs && "Argument index out-of-range");
2124d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor    return *(arg_begin() + I);
2125d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  }
2126d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor
21271dd7383dc48718c452e71a625b29531dd96fbb9dJohn McCall  const Expr *getArg(unsigned I) const {
21281dd7383dc48718c452e71a625b29531dd96fbb9dJohn McCall    assert(I < NumArgs && "Argument index out-of-range");
21291dd7383dc48718c452e71a625b29531dd96fbb9dJohn McCall    return *(arg_begin() + I);
21301dd7383dc48718c452e71a625b29531dd96fbb9dJohn McCall  }
21311dd7383dc48718c452e71a625b29531dd96fbb9dJohn McCall
21328dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis  void setArg(unsigned I, Expr *E) {
21338dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis    assert(I < NumArgs && "Argument index out-of-range");
21348dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis    *(arg_begin() + I) = E;
21358dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis  }
21368dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis
213763c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall  SourceRange getSourceRange() const;
2138ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor
21391eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  static bool classof(const Stmt *T) {
2140d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor    return T->getStmtClass() == CXXUnresolvedConstructExprClass;
2141d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  }
2142d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  static bool classof(const CXXUnresolvedConstructExpr *) { return true; }
2143d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor
2144d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  // Iterators
214563c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall  child_range children() {
214663c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall    Stmt **begin = reinterpret_cast<Stmt**>(this+1);
214763c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall    return child_range(begin, begin + NumArgs);
214863c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall  }
2149d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor};
2150d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor
2151ba13543329afac4a0d01304ec2ec4924d99306a6John McCall/// \brief Represents a C++ member access expression where the actual
2152ba13543329afac4a0d01304ec2ec4924d99306a6John McCall/// member referenced could not be resolved because the base
2153ba13543329afac4a0d01304ec2ec4924d99306a6John McCall/// expression or the member name was dependent.
2154aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall///
2155aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall/// Like UnresolvedMemberExprs, these can be either implicit or
2156aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall/// explicit accesses.  It is only possible to get one of these with
2157aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall/// an implicit access if a qualifier is provided.
2158865d447ac6a4721ab58e898d014a21f2eff74b06John McCallclass CXXDependentScopeMemberExpr : public Expr {
21591c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  /// \brief The expression for the base pointer or class reference,
2160aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall  /// e.g., the \c x in x.f.  Can be null in implicit accesses.
21611c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  Stmt *Base;
21621eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
2163aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall  /// \brief The type of the base expression.  Never null, even for
2164aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall  /// implicit accesses.
2165aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall  QualType BaseType;
2166aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall
21671c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  /// \brief Whether this member expression used the '->' operator or
21681c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  /// the '.' operator.
21693b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor  bool IsArrow : 1;
21701c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor
21713b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor  /// \brief Whether this member expression has explicitly-specified template
21723b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor  /// arguments.
2173aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall  bool HasExplicitTemplateArgs : 1;
21741eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
21751c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  /// \brief The location of the '->' or '.' operator.
21761c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  SourceLocation OperatorLoc;
21771c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor
2178a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor  /// \brief The nested-name-specifier that precedes the member name, if any.
2179a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor  NestedNameSpecifier *Qualifier;
21801eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
2181a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor  /// \brief The source range covering the nested name specifier.
2182a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor  SourceRange QualifierRange;
21831eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
2184c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor  /// \brief In a qualified member access expression such as t->Base::f, this
21851eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  /// member stores the resolves of name lookup in the context of the member
2186c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor  /// access expression, to be used at instantiation time.
2187c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor  ///
2188c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor  /// FIXME: This member, along with the Qualifier and QualifierRange, could
2189c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor  /// be stuck into a structure that is optionally allocated at the end of
2190865d447ac6a4721ab58e898d014a21f2eff74b06John McCall  /// the CXXDependentScopeMemberExpr, to save space in the common case.
2191c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor  NamedDecl *FirstQualifierFoundInScope;
21921eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
21931c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  /// \brief The member to which this member expression refers, which
21941c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  /// can be name, overloaded operator, or destructor.
2195a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor  /// FIXME: could also be a template-id
21962577743c5650c646fb705df01403707e94f2df04Abramo Bagnara  DeclarationNameInfo MemberNameInfo;
21971eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
2198865d447ac6a4721ab58e898d014a21f2eff74b06John McCall  CXXDependentScopeMemberExpr(ASTContext &C,
2199aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall                          Expr *Base, QualType BaseType, bool IsArrow,
22003b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor                          SourceLocation OperatorLoc,
22013b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor                          NestedNameSpecifier *Qualifier,
22023b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor                          SourceRange QualifierRange,
22033b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor                          NamedDecl *FirstQualifierFoundInScope,
22042577743c5650c646fb705df01403707e94f2df04Abramo Bagnara                          DeclarationNameInfo MemberNameInfo,
2205d5532b6cfff2977e0c59fa6ead7f7973984a620dJohn McCall                          const TemplateArgumentListInfo *TemplateArgs);
22061eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
22071c0ca59416999129d0439c2661d137ef38e86209Douglas Gregorpublic:
2208865d447ac6a4721ab58e898d014a21f2eff74b06John McCall  CXXDependentScopeMemberExpr(ASTContext &C,
2209bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor                              Expr *Base, QualType BaseType,
2210bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor                              bool IsArrow,
2211bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor                              SourceLocation OperatorLoc,
2212bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor                              NestedNameSpecifier *Qualifier,
2213bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor                              SourceRange QualifierRange,
2214bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor                              NamedDecl *FirstQualifierFoundInScope,
2215bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor                              DeclarationNameInfo MemberNameInfo);
22161eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
2217865d447ac6a4721ab58e898d014a21f2eff74b06John McCall  static CXXDependentScopeMemberExpr *
22181eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  Create(ASTContext &C,
2219aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall         Expr *Base, QualType BaseType, bool IsArrow,
22203b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor         SourceLocation OperatorLoc,
22213b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor         NestedNameSpecifier *Qualifier,
22223b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor         SourceRange QualifierRange,
22233b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor         NamedDecl *FirstQualifierFoundInScope,
22242577743c5650c646fb705df01403707e94f2df04Abramo Bagnara         DeclarationNameInfo MemberNameInfo,
2225d5532b6cfff2977e0c59fa6ead7f7973984a620dJohn McCall         const TemplateArgumentListInfo *TemplateArgs);
22261eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
22278dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis  static CXXDependentScopeMemberExpr *
2228def0354384d9c4431f7b58b664b59896d4623028Douglas Gregor  CreateEmpty(ASTContext &C, bool HasExplicitTemplateArgs,
2229def0354384d9c4431f7b58b664b59896d4623028Douglas Gregor              unsigned NumTemplateArgs);
22308dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis
2231aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall  /// \brief True if this is an implicit access, i.e. one in which the
2232aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall  /// member being accessed was not written in the source.  The source
2233aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall  /// location of the operator is invalid in this case.
2234aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall  bool isImplicitAccess() const { return Base == 0; }
2235aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall
22361c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  /// \brief Retrieve the base object of this member expressions,
22371c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  /// e.g., the \c x in \c x.m.
2238aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall  Expr *getBase() const {
2239aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall    assert(!isImplicitAccess());
2240aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall    return cast<Expr>(Base);
2241aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall  }
22421c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  void setBase(Expr *E) { Base = E; }
22431c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor
2244aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall  QualType getBaseType() const { return BaseType; }
22458dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis  void setBaseType(QualType T) { BaseType = T; }
2246aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall
22471c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  /// \brief Determine whether this member expression used the '->'
22481c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  /// operator; otherwise, it used the '.' operator.
22491c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  bool isArrow() const { return IsArrow; }
22501c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  void setArrow(bool A) { IsArrow = A; }
22511c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor
22521c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  /// \brief Retrieve the location of the '->' or '.' operator.
22531c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  SourceLocation getOperatorLoc() const { return OperatorLoc; }
22541c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  void setOperatorLoc(SourceLocation L) { OperatorLoc = L; }
22551c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor
2256a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor  /// \brief Retrieve the nested-name-specifier that qualifies the member
2257a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor  /// name.
2258a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor  NestedNameSpecifier *getQualifier() const { return Qualifier; }
22598dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis  void setQualifier(NestedNameSpecifier *NNS) { Qualifier = NNS; }
22601eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
2261a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor  /// \brief Retrieve the source range covering the nested-name-specifier
2262a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor  /// that qualifies the member name.
2263a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor  SourceRange getQualifierRange() const { return QualifierRange; }
22648dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis  void setQualifierRange(SourceRange R) { QualifierRange = R; }
22651eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
2266c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor  /// \brief Retrieve the first part of the nested-name-specifier that was
2267c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor  /// found in the scope of the member access expression when the member access
2268c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor  /// was initially parsed.
2269c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor  ///
2270c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor  /// This function only returns a useful result when member access expression
22711eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  /// uses a qualified member name, e.g., "x.Base::f". Here, the declaration
22721eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  /// returned by this function describes what was found by unqualified name
2273c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor  /// lookup for the identifier "Base" within the scope of the member access
2274c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor  /// expression itself. At template instantiation time, this information is
2275c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor  /// combined with the results of name lookup into the type of the object
2276c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor  /// expression itself (the class type of x).
22771eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  NamedDecl *getFirstQualifierFoundInScope() const {
2278c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor    return FirstQualifierFoundInScope;
2279c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor  }
22808dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis  void setFirstQualifierFoundInScope(NamedDecl *D) {
22818dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis    FirstQualifierFoundInScope = D;
22828dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis  }
22831eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
22841c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  /// \brief Retrieve the name of the member that this expression
22851c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  /// refers to.
22862577743c5650c646fb705df01403707e94f2df04Abramo Bagnara  const DeclarationNameInfo &getMemberNameInfo() const {
22872577743c5650c646fb705df01403707e94f2df04Abramo Bagnara    return MemberNameInfo;
22882577743c5650c646fb705df01403707e94f2df04Abramo Bagnara  }
22892577743c5650c646fb705df01403707e94f2df04Abramo Bagnara  void setMemberNameInfo(const DeclarationNameInfo &N) { MemberNameInfo = N; }
22902577743c5650c646fb705df01403707e94f2df04Abramo Bagnara
22912577743c5650c646fb705df01403707e94f2df04Abramo Bagnara  /// \brief Retrieve the name of the member that this expression
22922577743c5650c646fb705df01403707e94f2df04Abramo Bagnara  /// refers to.
22932577743c5650c646fb705df01403707e94f2df04Abramo Bagnara  DeclarationName getMember() const { return MemberNameInfo.getName(); }
22942577743c5650c646fb705df01403707e94f2df04Abramo Bagnara  void setMember(DeclarationName N) { MemberNameInfo.setName(N); }
22951c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor
22961c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  // \brief Retrieve the location of the name of the member that this
22971c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  // expression refers to.
22982577743c5650c646fb705df01403707e94f2df04Abramo Bagnara  SourceLocation getMemberLoc() const { return MemberNameInfo.getLoc(); }
22992577743c5650c646fb705df01403707e94f2df04Abramo Bagnara  void setMemberLoc(SourceLocation L) { MemberNameInfo.setLoc(L); }
23001c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor
23013b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor  /// \brief Determines whether this member expression actually had a C++
23023b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor  /// template argument list explicitly specified, e.g., x.f<int>.
2303aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall  bool hasExplicitTemplateArgs() const {
2304aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall    return HasExplicitTemplateArgs;
23053b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor  }
23061eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
230736c76f0bea0d3595a25a5362225c642019cc3176Argyrios Kyrtzidis  /// \brief Retrieve the explicit template argument list that followed the
230836c76f0bea0d3595a25a5362225c642019cc3176Argyrios Kyrtzidis  /// member template name, if any.
2309096832c5ed5b9106fa177ebc148489760c3bc496John McCall  ExplicitTemplateArgumentList &getExplicitTemplateArgs() {
231036c76f0bea0d3595a25a5362225c642019cc3176Argyrios Kyrtzidis    assert(HasExplicitTemplateArgs);
2311096832c5ed5b9106fa177ebc148489760c3bc496John McCall    return *reinterpret_cast<ExplicitTemplateArgumentList *>(this + 1);
231236c76f0bea0d3595a25a5362225c642019cc3176Argyrios Kyrtzidis  }
231336c76f0bea0d3595a25a5362225c642019cc3176Argyrios Kyrtzidis
231436c76f0bea0d3595a25a5362225c642019cc3176Argyrios Kyrtzidis  /// \brief Retrieve the explicit template argument list that followed the
231536c76f0bea0d3595a25a5362225c642019cc3176Argyrios Kyrtzidis  /// member template name, if any.
2316096832c5ed5b9106fa177ebc148489760c3bc496John McCall  const ExplicitTemplateArgumentList &getExplicitTemplateArgs() const {
231736c76f0bea0d3595a25a5362225c642019cc3176Argyrios Kyrtzidis    return const_cast<CXXDependentScopeMemberExpr *>(this)
2318096832c5ed5b9106fa177ebc148489760c3bc496John McCall             ->getExplicitTemplateArgs();
2319096832c5ed5b9106fa177ebc148489760c3bc496John McCall  }
2320096832c5ed5b9106fa177ebc148489760c3bc496John McCall
2321096832c5ed5b9106fa177ebc148489760c3bc496John McCall  /// \brief Retrieves the optional explicit template arguments.
2322096832c5ed5b9106fa177ebc148489760c3bc496John McCall  /// This points to the same data as getExplicitTemplateArgs(), but
2323096832c5ed5b9106fa177ebc148489760c3bc496John McCall  /// returns null if there are no explicit template arguments.
2324096832c5ed5b9106fa177ebc148489760c3bc496John McCall  const ExplicitTemplateArgumentList *getOptionalExplicitTemplateArgs() {
2325096832c5ed5b9106fa177ebc148489760c3bc496John McCall    if (!hasExplicitTemplateArgs()) return 0;
2326096832c5ed5b9106fa177ebc148489760c3bc496John McCall    return &getExplicitTemplateArgs();
232736c76f0bea0d3595a25a5362225c642019cc3176Argyrios Kyrtzidis  }
232836c76f0bea0d3595a25a5362225c642019cc3176Argyrios Kyrtzidis
2329d5532b6cfff2977e0c59fa6ead7f7973984a620dJohn McCall  /// \brief Copies the template arguments (if present) into the given
2330d5532b6cfff2977e0c59fa6ead7f7973984a620dJohn McCall  /// structure.
2331d5532b6cfff2977e0c59fa6ead7f7973984a620dJohn McCall  void copyTemplateArgumentsInto(TemplateArgumentListInfo &List) const {
2332096832c5ed5b9106fa177ebc148489760c3bc496John McCall    getExplicitTemplateArgs().copyInto(List);
2333d5532b6cfff2977e0c59fa6ead7f7973984a620dJohn McCall  }
2334d5532b6cfff2977e0c59fa6ead7f7973984a620dJohn McCall
23358dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis  /// \brief Initializes the template arguments using the given structure.
23368dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis  void initializeTemplateArgumentsFrom(const TemplateArgumentListInfo &List) {
2337096832c5ed5b9106fa177ebc148489760c3bc496John McCall    getExplicitTemplateArgs().initializeFrom(List);
23388dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis  }
23398dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis
23401eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  /// \brief Retrieve the location of the left angle bracket following the
23413b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor  /// member name ('<'), if any.
23421eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  SourceLocation getLAngleLoc() const {
2343096832c5ed5b9106fa177ebc148489760c3bc496John McCall    return getExplicitTemplateArgs().LAngleLoc;
23443b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor  }
23451eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
23463b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor  /// \brief Retrieve the template arguments provided as part of this
23473b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor  /// template-id.
2348833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall  const TemplateArgumentLoc *getTemplateArgs() const {
2349096832c5ed5b9106fa177ebc148489760c3bc496John McCall    return getExplicitTemplateArgs().getTemplateArgs();
23503b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor  }
23511eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
23523b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor  /// \brief Retrieve the number of template arguments provided as part of this
23533b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor  /// template-id.
23541eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  unsigned getNumTemplateArgs() const {
2355096832c5ed5b9106fa177ebc148489760c3bc496John McCall    return getExplicitTemplateArgs().NumTemplateArgs;
23563b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor  }
23571eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
23581eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  /// \brief Retrieve the location of the right angle bracket following the
23593b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor  /// template arguments ('>').
23601eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  SourceLocation getRAngleLoc() const {
2361096832c5ed5b9106fa177ebc148489760c3bc496John McCall    return getExplicitTemplateArgs().RAngleLoc;
23623b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor  }
23631eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
236463c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall  SourceRange getSourceRange() const {
2365aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall    SourceRange Range;
2366aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall    if (!isImplicitAccess())
2367aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall      Range.setBegin(Base->getSourceRange().getBegin());
2368aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall    else if (getQualifier())
2369aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall      Range.setBegin(getQualifierRange().getBegin());
2370aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall    else
23712577743c5650c646fb705df01403707e94f2df04Abramo Bagnara      Range.setBegin(MemberNameInfo.getBeginLoc());
23721eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
2373aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall    if (hasExplicitTemplateArgs())
2374aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall      Range.setEnd(getRAngleLoc());
2375aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall    else
23762577743c5650c646fb705df01403707e94f2df04Abramo Bagnara      Range.setEnd(MemberNameInfo.getEndLoc());
2377aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall    return Range;
23781c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  }
23791eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
23801eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  static bool classof(const Stmt *T) {
2381865d447ac6a4721ab58e898d014a21f2eff74b06John McCall    return T->getStmtClass() == CXXDependentScopeMemberExprClass;
23821c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  }
2383865d447ac6a4721ab58e898d014a21f2eff74b06John McCall  static bool classof(const CXXDependentScopeMemberExpr *) { return true; }
23841c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor
23851c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  // Iterators
238663c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall  child_range children() {
238763c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall    if (isImplicitAccess()) return child_range();
238863c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall    return child_range(&Base, &Base + 1);
238963c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall  }
23904045107b7384fd68eed5e3e2f06fc2a47e7be0a6Argyrios Kyrtzidis
23914045107b7384fd68eed5e3e2f06fc2a47e7be0a6Argyrios Kyrtzidis  friend class ASTStmtReader;
23924045107b7384fd68eed5e3e2f06fc2a47e7be0a6Argyrios Kyrtzidis  friend class ASTStmtWriter;
23931c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor};
23941c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor
2395129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall/// \brief Represents a C++ member access expression for which lookup
2396aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall/// produced a set of overloaded functions.
2397aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall///
2398aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall/// The member access may be explicit or implicit:
2399aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall///    struct A {
2400aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall///      int a, b;
2401aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall///      int explicitAccess() { return this->a + this->A::b; }
2402aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall///      int implicitAccess() { return a + A::b; }
2403aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall///    };
2404aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall///
2405aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall/// In the final AST, an explicit access always becomes a MemberExpr.
2406aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall/// An implicit access may become either a MemberExpr or a
2407aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall/// DeclRefExpr, depending on whether the member is static.
24087bb12da2b0749eeebb21854c77877736969e59f2John McCallclass UnresolvedMemberExpr : public OverloadExpr {
2409129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// \brief Whether this member expression used the '->' operator or
2410129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// the '.' operator.
2411129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  bool IsArrow : 1;
2412129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall
2413129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// \brief Whether the lookup results contain an unresolved using
2414129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// declaration.
2415129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  bool HasUnresolvedUsing : 1;
2416129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall
24177bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// \brief The expression for the base pointer or class reference,
24187bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// e.g., the \c x in x.f.  This can be null if this is an 'unbased'
24197bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// member expression
24207bb12da2b0749eeebb21854c77877736969e59f2John McCall  Stmt *Base;
24217bb12da2b0749eeebb21854c77877736969e59f2John McCall
24227bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// \brief The type of the base expression;  never null.
24237bb12da2b0749eeebb21854c77877736969e59f2John McCall  QualType BaseType;
2424129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall
2425129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// \brief The location of the '->' or '.' operator.
2426129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  SourceLocation OperatorLoc;
2427129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall
2428bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor  UnresolvedMemberExpr(ASTContext &C, bool HasUnresolvedUsing,
2429aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall                       Expr *Base, QualType BaseType, bool IsArrow,
2430129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall                       SourceLocation OperatorLoc,
2431129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall                       NestedNameSpecifier *Qualifier,
2432129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall                       SourceRange QualifierRange,
24332577743c5650c646fb705df01403707e94f2df04Abramo Bagnara                       const DeclarationNameInfo &MemberNameInfo,
24345a84dec38cfa9e084377a3167b474c79283c82faDouglas Gregor                       const TemplateArgumentListInfo *TemplateArgs,
24355a84dec38cfa9e084377a3167b474c79283c82faDouglas Gregor                       UnresolvedSetIterator Begin, UnresolvedSetIterator End);
2436a77eb0862507b900a10fa352af1568e639ed10b1Argyrios Kyrtzidis
2437a77eb0862507b900a10fa352af1568e639ed10b1Argyrios Kyrtzidis  UnresolvedMemberExpr(EmptyShell Empty)
2438a77eb0862507b900a10fa352af1568e639ed10b1Argyrios Kyrtzidis    : OverloadExpr(UnresolvedMemberExprClass, Empty), IsArrow(false),
2439a77eb0862507b900a10fa352af1568e639ed10b1Argyrios Kyrtzidis      HasUnresolvedUsing(false), Base(0) { }
2440129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall
2441129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCallpublic:
2442129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  static UnresolvedMemberExpr *
2443bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor  Create(ASTContext &C, bool HasUnresolvedUsing,
2444aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall         Expr *Base, QualType BaseType, bool IsArrow,
2445129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall         SourceLocation OperatorLoc,
2446129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall         NestedNameSpecifier *Qualifier,
2447129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall         SourceRange QualifierRange,
24482577743c5650c646fb705df01403707e94f2df04Abramo Bagnara         const DeclarationNameInfo &MemberNameInfo,
24495a84dec38cfa9e084377a3167b474c79283c82faDouglas Gregor         const TemplateArgumentListInfo *TemplateArgs,
24505a84dec38cfa9e084377a3167b474c79283c82faDouglas Gregor         UnresolvedSetIterator Begin, UnresolvedSetIterator End);
2451129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall
2452a77eb0862507b900a10fa352af1568e639ed10b1Argyrios Kyrtzidis  static UnresolvedMemberExpr *
2453def0354384d9c4431f7b58b664b59896d4623028Douglas Gregor  CreateEmpty(ASTContext &C, bool HasExplicitTemplateArgs,
2454def0354384d9c4431f7b58b664b59896d4623028Douglas Gregor              unsigned NumTemplateArgs);
2455a77eb0862507b900a10fa352af1568e639ed10b1Argyrios Kyrtzidis
2456aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall  /// \brief True if this is an implicit access, i.e. one in which the
2457aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall  /// member being accessed was not written in the source.  The source
2458aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall  /// location of the operator is invalid in this case.
2459aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall  bool isImplicitAccess() const { return Base == 0; }
2460aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall
2461129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// \brief Retrieve the base object of this member expressions,
2462129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// e.g., the \c x in \c x.m.
2463aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall  Expr *getBase() {
2464aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall    assert(!isImplicitAccess());
2465aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall    return cast<Expr>(Base);
2466aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall  }
24672f27bf854f0519810b34afd209089cc75536b757John McCall  const Expr *getBase() const {
24682f27bf854f0519810b34afd209089cc75536b757John McCall    assert(!isImplicitAccess());
24692f27bf854f0519810b34afd209089cc75536b757John McCall    return cast<Expr>(Base);
24702f27bf854f0519810b34afd209089cc75536b757John McCall  }
2471129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  void setBase(Expr *E) { Base = E; }
2472129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall
2473aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall  QualType getBaseType() const { return BaseType; }
2474a77eb0862507b900a10fa352af1568e639ed10b1Argyrios Kyrtzidis  void setBaseType(QualType T) { BaseType = T; }
2475a77eb0862507b900a10fa352af1568e639ed10b1Argyrios Kyrtzidis
2476a77eb0862507b900a10fa352af1568e639ed10b1Argyrios Kyrtzidis  /// \brief Determine whether the lookup results contain an unresolved using
2477a77eb0862507b900a10fa352af1568e639ed10b1Argyrios Kyrtzidis  /// declaration.
2478a77eb0862507b900a10fa352af1568e639ed10b1Argyrios Kyrtzidis  bool hasUnresolvedUsing() const { return HasUnresolvedUsing; }
2479a77eb0862507b900a10fa352af1568e639ed10b1Argyrios Kyrtzidis  void setHasUnresolvedUsing(bool V) { HasUnresolvedUsing = V; }
2480aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall
2481129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// \brief Determine whether this member expression used the '->'
2482129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// operator; otherwise, it used the '.' operator.
2483129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  bool isArrow() const { return IsArrow; }
2484129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  void setArrow(bool A) { IsArrow = A; }
2485129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall
2486129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// \brief Retrieve the location of the '->' or '.' operator.
2487129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  SourceLocation getOperatorLoc() const { return OperatorLoc; }
2488129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  void setOperatorLoc(SourceLocation L) { OperatorLoc = L; }
2489129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall
2490c373d48502ca7683ab55385f5bd624d778eb288dJohn McCall  /// \brief Retrieves the naming class of this lookup.
2491c373d48502ca7683ab55385f5bd624d778eb288dJohn McCall  CXXRecordDecl *getNamingClass() const;
2492c373d48502ca7683ab55385f5bd624d778eb288dJohn McCall
24932577743c5650c646fb705df01403707e94f2df04Abramo Bagnara  /// \brief Retrieve the full name info for the member that this expression
24942577743c5650c646fb705df01403707e94f2df04Abramo Bagnara  /// refers to.
24952577743c5650c646fb705df01403707e94f2df04Abramo Bagnara  const DeclarationNameInfo &getMemberNameInfo() const { return getNameInfo(); }
24962577743c5650c646fb705df01403707e94f2df04Abramo Bagnara  void setMemberNameInfo(const DeclarationNameInfo &N) { setNameInfo(N); }
24972577743c5650c646fb705df01403707e94f2df04Abramo Bagnara
2498129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// \brief Retrieve the name of the member that this expression
2499129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// refers to.
25007bb12da2b0749eeebb21854c77877736969e59f2John McCall  DeclarationName getMemberName() const { return getName(); }
25017bb12da2b0749eeebb21854c77877736969e59f2John McCall  void setMemberName(DeclarationName N) { setName(N); }
2502129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall
2503129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  // \brief Retrieve the location of the name of the member that this
2504129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  // expression refers to.
25057bb12da2b0749eeebb21854c77877736969e59f2John McCall  SourceLocation getMemberLoc() const { return getNameLoc(); }
25067bb12da2b0749eeebb21854c77877736969e59f2John McCall  void setMemberLoc(SourceLocation L) { setNameLoc(L); }
2507129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall
25087bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// \brief Retrieve the explicit template argument list that followed the
25097bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// member template name.
25107bb12da2b0749eeebb21854c77877736969e59f2John McCall  ExplicitTemplateArgumentList &getExplicitTemplateArgs() {
25117bb12da2b0749eeebb21854c77877736969e59f2John McCall    assert(hasExplicitTemplateArgs());
25127bb12da2b0749eeebb21854c77877736969e59f2John McCall    return *reinterpret_cast<ExplicitTemplateArgumentList *>(this + 1);
25137bb12da2b0749eeebb21854c77877736969e59f2John McCall  }
25147bb12da2b0749eeebb21854c77877736969e59f2John McCall
25157bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// \brief Retrieve the explicit template argument list that followed the
25167bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// member template name, if any.
25177bb12da2b0749eeebb21854c77877736969e59f2John McCall  const ExplicitTemplateArgumentList &getExplicitTemplateArgs() const {
25187bb12da2b0749eeebb21854c77877736969e59f2John McCall    assert(hasExplicitTemplateArgs());
25197bb12da2b0749eeebb21854c77877736969e59f2John McCall    return *reinterpret_cast<const ExplicitTemplateArgumentList *>(this + 1);
2520129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  }
2521129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall
2522096832c5ed5b9106fa177ebc148489760c3bc496John McCall  /// \brief Retrieves the optional explicit template arguments.
2523096832c5ed5b9106fa177ebc148489760c3bc496John McCall  /// This points to the same data as getExplicitTemplateArgs(), but
2524096832c5ed5b9106fa177ebc148489760c3bc496John McCall  /// returns null if there are no explicit template arguments.
2525096832c5ed5b9106fa177ebc148489760c3bc496John McCall  const ExplicitTemplateArgumentList *getOptionalExplicitTemplateArgs() {
2526096832c5ed5b9106fa177ebc148489760c3bc496John McCall    if (!hasExplicitTemplateArgs()) return 0;
2527096832c5ed5b9106fa177ebc148489760c3bc496John McCall    return &getExplicitTemplateArgs();
2528096832c5ed5b9106fa177ebc148489760c3bc496John McCall  }
2529096832c5ed5b9106fa177ebc148489760c3bc496John McCall
2530129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// \brief Copies the template arguments into the given structure.
2531129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  void copyTemplateArgumentsInto(TemplateArgumentListInfo &List) const {
25327bb12da2b0749eeebb21854c77877736969e59f2John McCall    getExplicitTemplateArgs().copyInto(List);
2533129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  }
2534129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall
2535129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// \brief Retrieve the location of the left angle bracket following
2536129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// the member name ('<').
2537129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  SourceLocation getLAngleLoc() const {
25387bb12da2b0749eeebb21854c77877736969e59f2John McCall    return getExplicitTemplateArgs().LAngleLoc;
2539129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  }
2540129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall
2541129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// \brief Retrieve the template arguments provided as part of this
2542129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// template-id.
2543129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  const TemplateArgumentLoc *getTemplateArgs() const {
25447bb12da2b0749eeebb21854c77877736969e59f2John McCall    return getExplicitTemplateArgs().getTemplateArgs();
2545129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  }
2546129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall
2547129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// \brief Retrieve the number of template arguments provided as
2548129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// part of this template-id.
2549129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  unsigned getNumTemplateArgs() const {
25507bb12da2b0749eeebb21854c77877736969e59f2John McCall    return getExplicitTemplateArgs().NumTemplateArgs;
2551129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  }
2552129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall
2553129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// \brief Retrieve the location of the right angle bracket
2554129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// following the template arguments ('>').
2555129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  SourceLocation getRAngleLoc() const {
25567bb12da2b0749eeebb21854c77877736969e59f2John McCall    return getExplicitTemplateArgs().RAngleLoc;
2557129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  }
2558129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall
255963c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall  SourceRange getSourceRange() const {
25602577743c5650c646fb705df01403707e94f2df04Abramo Bagnara    SourceRange Range = getMemberNameInfo().getSourceRange();
2561aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall    if (!isImplicitAccess())
2562aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall      Range.setBegin(Base->getSourceRange().getBegin());
2563aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall    else if (getQualifier())
2564aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall      Range.setBegin(getQualifierRange().getBegin());
2565aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall
2566129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall    if (hasExplicitTemplateArgs())
2567129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall      Range.setEnd(getRAngleLoc());
2568129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall    return Range;
2569129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  }
2570129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall
2571129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  static bool classof(const Stmt *T) {
2572129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall    return T->getStmtClass() == UnresolvedMemberExprClass;
2573129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  }
2574129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  static bool classof(const UnresolvedMemberExpr *) { return true; }
2575129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall
2576129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  // Iterators
257763c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall  child_range children() {
257863c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall    if (isImplicitAccess()) return child_range();
257963c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall    return child_range(&Base, &Base + 1);
258063c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall  }
2581129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall};
2582129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall
25832e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl/// \brief Represents a C++0x noexcept expression (C++ [expr.unary.noexcept]).
25842e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl///
25852e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl/// The noexcept expression tests whether a given expression might throw. Its
25862e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl/// result is a boolean constant.
25872e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redlclass CXXNoexceptExpr : public Expr {
25882e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl  bool Value : 1;
25892e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl  Stmt *Operand;
25902e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl  SourceRange Range;
25912e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl
2592c8aecc2dfb2e393d9eeaedeca22ff8cd7149af81Sebastian Redl  friend class ASTStmtReader;
2593c8aecc2dfb2e393d9eeaedeca22ff8cd7149af81Sebastian Redl
25942e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redlpublic:
25952e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl  CXXNoexceptExpr(QualType Ty, Expr *Operand, CanThrowResult Val,
25962e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl                  SourceLocation Keyword, SourceLocation RParen)
2597f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall    : Expr(CXXNoexceptExprClass, Ty, VK_RValue, OK_Ordinary,
2598f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall           /*TypeDependent*/false,
2599bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor           /*ValueDependent*/Val == CT_Dependent,
2600bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor           Operand->containsUnexpandedParameterPack()),
26016b219d082434394c1ac401390ec1d1967727815aSebastian Redl      Value(Val == CT_Cannot), Operand(Operand), Range(Keyword, RParen)
26026b219d082434394c1ac401390ec1d1967727815aSebastian Redl  { }
26036b219d082434394c1ac401390ec1d1967727815aSebastian Redl
26046b219d082434394c1ac401390ec1d1967727815aSebastian Redl  CXXNoexceptExpr(EmptyShell Empty)
26056b219d082434394c1ac401390ec1d1967727815aSebastian Redl    : Expr(CXXNoexceptExprClass, Empty)
26062e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl  { }
26072e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl
26082e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl  Expr *getOperand() const { return static_cast<Expr*>(Operand); }
26092e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl
261063c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall  SourceRange getSourceRange() const { return Range; }
26112e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl
26122e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl  bool getValue() const { return Value; }
26132e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl
26142e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl  static bool classof(const Stmt *T) {
26152e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl    return T->getStmtClass() == CXXNoexceptExprClass;
26162e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl  }
26172e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl  static bool classof(const CXXNoexceptExpr *) { return true; }
26182e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl
26192e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl  // Iterators
262063c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall  child_range children() { return child_range(&Operand, &Operand + 1); }
26212e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl};
26222e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl
2623be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor/// \brief Represents a C++0x pack expansion that produces a sequence of
2624be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor/// expressions.
2625be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor///
2626be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor/// A pack expansion expression contains a pattern (which itself is an
2627be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor/// expression) followed by an ellipsis. For example:
2628be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor///
2629be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor/// \code
2630be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor/// template<typename F, typename ...Types>
2631be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor/// void forward(F f, Types &&...args) {
2632be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor///   f(static_cast<Types&&>(args)...);
2633be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor/// }
2634be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor/// \endcode
2635be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor///
2636be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor/// Here, the argument to the function object \c f is a pack expansion whose
2637be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor/// pattern is \c static_cast<Types&&>(args). When the \c forward function
2638be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor/// template is instantiated, the pack expansion will instantiate to zero or
2639be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor/// or more function arguments to the function object \c f.
2640be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregorclass PackExpansionExpr : public Expr {
2641be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor  SourceLocation EllipsisLoc;
264267fd1251aad51bb80d050b7fa5e506fef0ec8e02Douglas Gregor
264367fd1251aad51bb80d050b7fa5e506fef0ec8e02Douglas Gregor  /// \brief The number of expansions that will be produced by this pack
264467fd1251aad51bb80d050b7fa5e506fef0ec8e02Douglas Gregor  /// expansion expression, if known.
264567fd1251aad51bb80d050b7fa5e506fef0ec8e02Douglas Gregor  ///
264667fd1251aad51bb80d050b7fa5e506fef0ec8e02Douglas Gregor  /// When zero, the number of expansions is not known. Otherwise, this value
264767fd1251aad51bb80d050b7fa5e506fef0ec8e02Douglas Gregor  /// is the number of expansions + 1.
264867fd1251aad51bb80d050b7fa5e506fef0ec8e02Douglas Gregor  unsigned NumExpansions;
264967fd1251aad51bb80d050b7fa5e506fef0ec8e02Douglas Gregor
2650be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor  Stmt *Pattern;
2651be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor
2652be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor  friend class ASTStmtReader;
265367fd1251aad51bb80d050b7fa5e506fef0ec8e02Douglas Gregor  friend class ASTStmtWriter;
2654be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor
2655be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregorpublic:
265667fd1251aad51bb80d050b7fa5e506fef0ec8e02Douglas Gregor  PackExpansionExpr(QualType T, Expr *Pattern, SourceLocation EllipsisLoc,
265767fd1251aad51bb80d050b7fa5e506fef0ec8e02Douglas Gregor                    llvm::Optional<unsigned> NumExpansions)
2658be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor    : Expr(PackExpansionExprClass, T, Pattern->getValueKind(),
2659be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor           Pattern->getObjectKind(), /*TypeDependent=*/true,
2660be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor           /*ValueDependent=*/true, /*ContainsUnexpandedParameterPack=*/false),
2661be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor      EllipsisLoc(EllipsisLoc),
266267fd1251aad51bb80d050b7fa5e506fef0ec8e02Douglas Gregor      NumExpansions(NumExpansions? *NumExpansions + 1 : 0),
2663be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor      Pattern(Pattern) { }
2664be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor
2665be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor  PackExpansionExpr(EmptyShell Empty) : Expr(PackExpansionExprClass, Empty) { }
2666be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor
2667be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor  /// \brief Retrieve the pattern of the pack expansion.
2668be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor  Expr *getPattern() { return reinterpret_cast<Expr *>(Pattern); }
2669be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor
2670be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor  /// \brief Retrieve the pattern of the pack expansion.
2671be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor  const Expr *getPattern() const { return reinterpret_cast<Expr *>(Pattern); }
2672be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor
2673be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor  /// \brief Retrieve the location of the ellipsis that describes this pack
2674be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor  /// expansion.
2675be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor  SourceLocation getEllipsisLoc() const { return EllipsisLoc; }
2676be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor
267767fd1251aad51bb80d050b7fa5e506fef0ec8e02Douglas Gregor  /// \brief Determine the number of expansions that will be produced when
267867fd1251aad51bb80d050b7fa5e506fef0ec8e02Douglas Gregor  /// this pack expansion is instantiated, if already known.
267967fd1251aad51bb80d050b7fa5e506fef0ec8e02Douglas Gregor  llvm::Optional<unsigned> getNumExpansions() const {
268067fd1251aad51bb80d050b7fa5e506fef0ec8e02Douglas Gregor    if (NumExpansions)
268167fd1251aad51bb80d050b7fa5e506fef0ec8e02Douglas Gregor      return NumExpansions - 1;
268267fd1251aad51bb80d050b7fa5e506fef0ec8e02Douglas Gregor
268367fd1251aad51bb80d050b7fa5e506fef0ec8e02Douglas Gregor    return llvm::Optional<unsigned>();
268467fd1251aad51bb80d050b7fa5e506fef0ec8e02Douglas Gregor  }
268567fd1251aad51bb80d050b7fa5e506fef0ec8e02Douglas Gregor
268663c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall  SourceRange getSourceRange() const {
268763c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall    return SourceRange(Pattern->getLocStart(), EllipsisLoc);
268863c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall  }
2689be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor
2690be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor  static bool classof(const Stmt *T) {
2691be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor    return T->getStmtClass() == PackExpansionExprClass;
2692be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor  }
2693be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor  static bool classof(const PackExpansionExpr *) { return true; }
2694be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor
2695be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor  // Iterators
269663c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall  child_range children() {
269763c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall    return child_range(&Pattern, &Pattern + 1);
269863c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall  }
2699be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor};
2700be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor
27017bb12da2b0749eeebb21854c77877736969e59f2John McCallinline ExplicitTemplateArgumentList &OverloadExpr::getExplicitTemplateArgs() {
27027bb12da2b0749eeebb21854c77877736969e59f2John McCall  if (isa<UnresolvedLookupExpr>(this))
27037bb12da2b0749eeebb21854c77877736969e59f2John McCall    return cast<UnresolvedLookupExpr>(this)->getExplicitTemplateArgs();
27047bb12da2b0749eeebb21854c77877736969e59f2John McCall  else
27057bb12da2b0749eeebb21854c77877736969e59f2John McCall    return cast<UnresolvedMemberExpr>(this)->getExplicitTemplateArgs();
27067bb12da2b0749eeebb21854c77877736969e59f2John McCall}
27077bb12da2b0749eeebb21854c77877736969e59f2John McCall
2708ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor/// \brief Represents an expression that computes the length of a parameter
2709ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor/// pack.
2710ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor///
2711ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor/// \code
2712ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor/// template<typename ...Types>
2713ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor/// struct count {
2714ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor///   static const unsigned value = sizeof...(Types);
2715ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor/// };
2716ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor/// \endcode
2717ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregorclass SizeOfPackExpr : public Expr {
2718ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor  /// \brief The location of the 'sizeof' keyword.
2719ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor  SourceLocation OperatorLoc;
2720ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor
2721ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor  /// \brief The location of the name of the parameter pack.
2722ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor  SourceLocation PackLoc;
2723ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor
2724ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor  /// \brief The location of the closing parenthesis.
2725ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor  SourceLocation RParenLoc;
2726ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor
2727ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor  /// \brief The length of the parameter pack, if known.
2728ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor  ///
2729ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor  /// When this expression is value-dependent, the length of the parameter pack
2730ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor  /// is unknown. When this expression is not value-dependent, the length is
2731ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor  /// known.
2732ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor  unsigned Length;
2733ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor
2734ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor  /// \brief The parameter pack itself.
2735ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor  NamedDecl *Pack;
2736ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor
2737ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor  friend class ASTStmtReader;
2738ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor  friend class ASTStmtWriter;
2739ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor
2740ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregorpublic:
2741ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor  /// \brief Creates a value-dependent expression that computes the length of
2742ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor  /// the given parameter pack.
2743ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor  SizeOfPackExpr(QualType SizeType, SourceLocation OperatorLoc, NamedDecl *Pack,
2744ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor                 SourceLocation PackLoc, SourceLocation RParenLoc)
2745ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor    : Expr(SizeOfPackExprClass, SizeType, VK_RValue, OK_Ordinary,
2746ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor           /*TypeDependent=*/false, /*ValueDependent=*/true,
2747ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor           /*ContainsUnexpandedParameterPack=*/false),
2748ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor      OperatorLoc(OperatorLoc), PackLoc(PackLoc), RParenLoc(RParenLoc),
2749ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor      Length(0), Pack(Pack) { }
2750ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor
2751ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor  /// \brief Creates an expression that computes the length of
2752ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor  /// the given parameter pack, which is already known.
2753ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor  SizeOfPackExpr(QualType SizeType, SourceLocation OperatorLoc, NamedDecl *Pack,
2754ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor                 SourceLocation PackLoc, SourceLocation RParenLoc,
2755ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor                 unsigned Length)
2756ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor  : Expr(SizeOfPackExprClass, SizeType, VK_RValue, OK_Ordinary,
2757ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor         /*TypeDependent=*/false, /*ValueDependent=*/false,
2758ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor         /*ContainsUnexpandedParameterPack=*/false),
2759ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor    OperatorLoc(OperatorLoc), PackLoc(PackLoc), RParenLoc(RParenLoc),
2760ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor    Length(Length), Pack(Pack) { }
2761ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor
2762ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor  /// \brief Create an empty expression.
2763ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor  SizeOfPackExpr(EmptyShell Empty) : Expr(SizeOfPackExprClass, Empty) { }
2764ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor
2765ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor  /// \brief Determine the location of the 'sizeof' keyword.
2766ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor  SourceLocation getOperatorLoc() const { return OperatorLoc; }
2767ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor
2768ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor  /// \brief Determine the location of the parameter pack.
2769ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor  SourceLocation getPackLoc() const { return PackLoc; }
2770ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor
2771ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor  /// \brief Determine the location of the right parenthesis.
2772ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor  SourceLocation getRParenLoc() const { return RParenLoc; }
2773ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor
2774ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor  /// \brief Retrieve the parameter pack.
2775ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor  NamedDecl *getPack() const { return Pack; }
2776ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor
2777ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor  /// \brief Retrieve the length of the parameter pack.
2778ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor  ///
2779c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor  /// This routine may only be invoked when the expression is not
2780c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor  /// value-dependent.
2781ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor  unsigned getPackLength() const {
2782ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor    assert(!isValueDependent() &&
2783ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor           "Cannot get the length of a value-dependent pack size expression");
2784ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor    return Length;
2785ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor  }
2786ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor
278763c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall  SourceRange getSourceRange() const {
278863c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall    return SourceRange(OperatorLoc, RParenLoc);
278963c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall  }
2790ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor
2791ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor  static bool classof(const Stmt *T) {
2792ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor    return T->getStmtClass() == SizeOfPackExprClass;
2793ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor  }
2794ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor  static bool classof(const SizeOfPackExpr *) { return true; }
2795ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor
2796ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor  // Iterators
279763c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall  child_range children() { return child_range(); }
2798ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor};
2799c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor
2800c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor/// \brief Represents a reference to a non-type template parameter pack that
2801c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor/// has been substituted with a non-template argument pack.
2802c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor///
2803c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor/// When a pack expansion in the source code contains multiple parameter packs
2804c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor/// and those parameter packs correspond to different levels of template
2805c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor/// parameter lists, this node node is used to represent a non-type template
2806c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor/// parameter pack from an outer level, which has already had its argument pack
2807c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor/// substituted but that still lives within a pack expansion that itself
2808c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor/// could not be instantiated. When actually performing a substitution into
2809c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor/// that pack expansion (e.g., when all template parameters have corresponding
2810c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor/// arguments), this type will be replaced with the appropriate underlying
2811c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor/// expression at the current pack substitution index.
2812c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregorclass SubstNonTypeTemplateParmPackExpr : public Expr {
2813c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor  /// \brief The non-type template parameter pack itself.
2814c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor  NonTypeTemplateParmDecl *Param;
2815c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor
2816c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor  /// \brief A pointer to the set of template arguments that this
2817c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor  /// parameter pack is instantiated with.
2818c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor  const TemplateArgument *Arguments;
2819c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor
2820c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor  /// \brief The number of template arguments in \c Arguments.
2821c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor  unsigned NumArguments;
2822c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor
2823c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor  /// \brief The location of the non-type template parameter pack reference.
2824c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor  SourceLocation NameLoc;
2825c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor
2826c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor  friend class ASTStmtReader;
2827c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor  friend class ASTStmtWriter;
2828c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor
2829c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregorpublic:
2830c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor  SubstNonTypeTemplateParmPackExpr(QualType T,
2831c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor                                   NonTypeTemplateParmDecl *Param,
2832c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor                                   SourceLocation NameLoc,
2833c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor                                   const TemplateArgument &ArgPack);
2834c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor
2835c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor  SubstNonTypeTemplateParmPackExpr(EmptyShell Empty)
2836c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor    : Expr(SubstNonTypeTemplateParmPackExprClass, Empty) { }
2837c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor
2838c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor  /// \brief Retrieve the non-type template parameter pack being substituted.
2839c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor  NonTypeTemplateParmDecl *getParameterPack() const { return Param; }
2840c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor
2841c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor  /// \brief Retrieve the location of the parameter pack name.
2842c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor  SourceLocation getParameterPackLocation() const { return NameLoc; }
2843c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor
2844c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor  /// \brief Retrieve the template argument pack containing the substituted
2845c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor  /// template arguments.
2846c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor  TemplateArgument getArgumentPack() const;
2847c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor
284863c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall  SourceRange getSourceRange() const { return NameLoc; }
2849c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor
2850c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor  static bool classof(const Stmt *T) {
2851c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor    return T->getStmtClass() == SubstNonTypeTemplateParmPackExprClass;
2852c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor  }
2853c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor  static bool classof(const SubstNonTypeTemplateParmPackExpr *) {
2854c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor    return true;
2855c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor  }
2856c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor
2857c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor  // Iterators
285863c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall  child_range children() { return child_range(); }
2859c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor};
2860ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor
28615f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer}  // end namespace clang
28625f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer
28635f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer#endif
2864