ExprCXX.h revision 828a197317288e3333b0ce6f5cedadd036e3531f
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"
19c4a1dea2dc56bd1357ec91b829a0b9e68229a13eDaniel Dunbar#include "clang/AST/Decl.h"
20d5532b6cfff2977e0c59fa6ead7f7973984a620dJohn McCall#include "clang/AST/TemplateBase.h"
215f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer
225f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencernamespace clang {
235f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer
244c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  class CXXConstructorDecl;
25c1ce477119fed070299668aab24084b17ff5f14bAnders Carlsson  class CXXDestructorDecl;
26e9f42087aabfdb6b2afc35c7e38ac65da063b409Fariborz Jahanian  class CXXMethodDecl;
27ff6b3d64c9f07155f1414411b8451d7bf8937c62Anders Carlsson  class CXXTemporary;
28d5532b6cfff2977e0c59fa6ead7f7973984a620dJohn McCall  class 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,
54063daf6e196c51f162e0485478355d8e280eef5cDouglas Gregor                      SourceLocation operatorloc)
55063daf6e196c51f162e0485478355d8e280eef5cDouglas Gregor    : CallExpr(C, CXXOperatorCallExprClass, fn, args, numargs, t, operatorloc),
56063daf6e196c51f162e0485478355d8e280eef5cDouglas Gregor      Operator(Op) {}
571eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  explicit CXXOperatorCallExpr(ASTContext& C, EmptyShell Empty) :
58ba0a9006dbc4814e1e35f82812cb5a1dad65e8b8Argyrios Kyrtzidis    CallExpr(C, CXXOperatorCallExprClass, Empty) { }
591eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
60b4609806e9232593ece09ce08b630836e825865cDouglas Gregor
61b4609806e9232593ece09ce08b630836e825865cDouglas Gregor  /// getOperator - Returns the kind of overloaded operator that this
62b4609806e9232593ece09ce08b630836e825865cDouglas Gregor  /// expression refers to.
63063daf6e196c51f162e0485478355d8e280eef5cDouglas Gregor  OverloadedOperatorKind getOperator() const { return Operator; }
64ba0a9006dbc4814e1e35f82812cb5a1dad65e8b8Argyrios Kyrtzidis  void setOperator(OverloadedOperatorKind Kind) { Operator = Kind; }
65b4609806e9232593ece09ce08b630836e825865cDouglas Gregor
66b4609806e9232593ece09ce08b630836e825865cDouglas Gregor  /// getOperatorLoc - Returns the location of the operator symbol in
67b4609806e9232593ece09ce08b630836e825865cDouglas Gregor  /// the expression. When @c getOperator()==OO_Call, this is the
68b4609806e9232593ece09ce08b630836e825865cDouglas Gregor  /// location of the right parentheses; when @c
69b4609806e9232593ece09ce08b630836e825865cDouglas Gregor  /// getOperator()==OO_Subscript, this is the location of the right
70b4609806e9232593ece09ce08b630836e825865cDouglas Gregor  /// bracket.
71b4609806e9232593ece09ce08b630836e825865cDouglas Gregor  SourceLocation getOperatorLoc() const { return getRParenLoc(); }
72b4609806e9232593ece09ce08b630836e825865cDouglas Gregor
73b4609806e9232593ece09ce08b630836e825865cDouglas Gregor  virtual SourceRange getSourceRange() const;
741eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
751eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  static bool classof(const Stmt *T) {
761eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump    return T->getStmtClass() == CXXOperatorCallExprClass;
77b4609806e9232593ece09ce08b630836e825865cDouglas Gregor  }
78b4609806e9232593ece09ce08b630836e825865cDouglas Gregor  static bool classof(const CXXOperatorCallExpr *) { return true; }
79b4609806e9232593ece09ce08b630836e825865cDouglas Gregor};
80b4609806e9232593ece09ce08b630836e825865cDouglas Gregor
8188a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor/// CXXMemberCallExpr - Represents a call to a member function that
8288a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor/// may be written either with member call syntax (e.g., "obj.func()"
8388a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor/// or "objptr->func()") or with normal function-call syntax
8488a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor/// ("func()") within a member function that ends up calling a member
8588a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor/// function. The callee in either case is a MemberExpr that contains
8688a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor/// both the object argument and the member function, while the
8788a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor/// arguments are the arguments within the parentheses (not including
8888a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor/// the object argument).
8988a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregorclass CXXMemberCallExpr : public CallExpr {
9088a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregorpublic:
91668bf91d31265b6ea8c3eb854ba450857701f269Ted Kremenek  CXXMemberCallExpr(ASTContext& C, Expr *fn, Expr **args, unsigned numargs,
92668bf91d31265b6ea8c3eb854ba450857701f269Ted Kremenek                    QualType t, SourceLocation rparenloc)
93668bf91d31265b6ea8c3eb854ba450857701f269Ted Kremenek    : CallExpr(C, CXXMemberCallExprClass, fn, args, numargs, t, rparenloc) {}
9488a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor
9588a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor  /// getImplicitObjectArgument - Retrieves the implicit object
9688a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor  /// argument for the member call. For example, in "x.f(5)", this
9788a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor  /// operation would return "x".
9888a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor  Expr *getImplicitObjectArgument();
9988a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor
10000b98c229ef28a5e82943bb23d09fb46d24ca381Douglas Gregor  virtual SourceRange getSourceRange() const;
10100b98c229ef28a5e82943bb23d09fb46d24ca381Douglas Gregor
1021eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  static bool classof(const Stmt *T) {
10388a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor    return T->getStmtClass() == CXXMemberCallExprClass;
10488a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor  }
10588a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor  static bool classof(const CXXMemberCallExpr *) { return true; }
10688a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor};
10788a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor
10849badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// CXXNamedCastExpr - Abstract class common to all of the C++ "named"
10949badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// casts, @c static_cast, @c dynamic_cast, @c reinterpret_cast, or @c
11049badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// const_cast.
11149badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor///
11249badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// This abstract class is inherited by all of the classes
11349badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// representing "named" casts, e.g., CXXStaticCastExpr,
11449badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// CXXDynamicCastExpr, CXXReinterpretCastExpr, and CXXConstCastExpr.
11549badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregorclass CXXNamedCastExpr : public ExplicitCastExpr {
1161060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenekprivate:
1171060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  SourceLocation Loc; // the location of the casting op
11849badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor
11949badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregorprotected:
120c0a2fd8f092722c8f78b566ac4506a21437040e9Anders Carlsson  CXXNamedCastExpr(StmtClass SC, QualType ty, CastKind kind, Expr *op,
121cdef2b75aa60cde1ca00e0aa3f89139ac89c6ae4Anders Carlsson                   QualType writtenTy, SourceLocation l)
122c0a2fd8f092722c8f78b566ac4506a21437040e9Anders Carlsson    : ExplicitCastExpr(SC, ty, kind, op, writtenTy), Loc(l) {}
12349badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor
1241060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenekpublic:
12549badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor  const char *getCastName() const;
12649badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor
127a3a7b8eea87c90a5a257f685749222b212ddaf36Douglas Gregor  /// \brief Retrieve the location of the cast operator keyword, e.g.,
128a3a7b8eea87c90a5a257f685749222b212ddaf36Douglas Gregor  /// "static_cast".
129a3a7b8eea87c90a5a257f685749222b212ddaf36Douglas Gregor  SourceLocation getOperatorLoc() const { return Loc; }
130a3a7b8eea87c90a5a257f685749222b212ddaf36Douglas Gregor  void setOperatorLoc(SourceLocation L) { Loc = L; }
131a3a7b8eea87c90a5a257f685749222b212ddaf36Douglas Gregor
1321060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  virtual SourceRange getSourceRange() const {
1331060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek    return SourceRange(Loc, getSubExpr()->getSourceRange().getEnd());
1341060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  }
1351eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  static bool classof(const Stmt *T) {
13649badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor    switch (T->getStmtClass()) {
13749badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor    case CXXNamedCastExprClass:
13849badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor    case CXXStaticCastExprClass:
13949badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor    case CXXDynamicCastExprClass:
14049badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor    case CXXReinterpretCastExprClass:
14149badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor    case CXXConstCastExprClass:
14249badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor      return true;
14349badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor    default:
14449badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor      return false;
14549badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor    }
1461060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  }
14749badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor  static bool classof(const CXXNamedCastExpr *) { return true; }
14849badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor};
14949badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor
15049badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// CXXStaticCastExpr - A C++ @c static_cast expression (C++ [expr.static.cast]).
1511eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump///
15249badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// This expression node represents a C++ static cast, e.g.,
15349badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// @c static_cast<int>(1.0).
15449badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregorclass CXXStaticCastExpr : public CXXNamedCastExpr {
15549badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregorpublic:
156c0a2fd8f092722c8f78b566ac4506a21437040e9Anders Carlsson  CXXStaticCastExpr(QualType ty, CastKind kind, Expr *op,
157bd0fb30fa2a039439d1a30a83ea896801394d780Anders Carlsson                    QualType writtenTy, SourceLocation l)
158c0a2fd8f092722c8f78b566ac4506a21437040e9Anders Carlsson    : CXXNamedCastExpr(CXXStaticCastExprClass, ty, kind, op, writtenTy, l) {}
15949badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor
1601eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  static bool classof(const Stmt *T) {
16149badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor    return T->getStmtClass() == CXXStaticCastExprClass;
16249badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor  }
16349badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor  static bool classof(const CXXStaticCastExpr *) { return true; }
16449badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor};
16549badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor
16649badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// CXXDynamicCastExpr - A C++ @c dynamic_cast expression
1671eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump/// (C++ [expr.dynamic.cast]), which may perform a run-time check to
16849badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// determine how to perform the type cast.
1691eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump///
17049badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// This expression node represents a dynamic cast, e.g.,
17149badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// @c dynamic_cast<Derived*>(BasePtr).
17249badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregorclass CXXDynamicCastExpr : public CXXNamedCastExpr {
17349badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregorpublic:
1741eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  CXXDynamicCastExpr(QualType ty, CastKind kind, Expr *op, QualType writtenTy,
175cdef2b75aa60cde1ca00e0aa3f89139ac89c6ae4Anders Carlsson                     SourceLocation l)
176cdef2b75aa60cde1ca00e0aa3f89139ac89c6ae4Anders Carlsson    : CXXNamedCastExpr(CXXDynamicCastExprClass, ty, kind, op, writtenTy, l) {}
17749badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor
1781eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  static bool classof(const Stmt *T) {
17949badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor    return T->getStmtClass() == CXXDynamicCastExprClass;
18049badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor  }
18149badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor  static bool classof(const CXXDynamicCastExpr *) { return true; }
18249badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor};
18349badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor
18449badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// CXXReinterpretCastExpr - A C++ @c reinterpret_cast expression (C++
18549badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// [expr.reinterpret.cast]), which provides a differently-typed view
18649badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// of a value but performs no actual work at run time.
1871eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump///
18849badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// This expression node represents a reinterpret cast, e.g.,
18949badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// @c reinterpret_cast<int>(VoidPtr).
19049badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregorclass CXXReinterpretCastExpr : public CXXNamedCastExpr {
19149badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregorpublic:
1927f9e646b7ed47bc8e9a60031ad0c2b55031e2077Anders Carlsson  CXXReinterpretCastExpr(QualType ty, CastKind kind, Expr *op,
1937f9e646b7ed47bc8e9a60031ad0c2b55031e2077Anders Carlsson                         QualType writtenTy, SourceLocation l)
1947f9e646b7ed47bc8e9a60031ad0c2b55031e2077Anders Carlsson    : CXXNamedCastExpr(CXXReinterpretCastExprClass, ty, kind, op,
195cdef2b75aa60cde1ca00e0aa3f89139ac89c6ae4Anders Carlsson                       writtenTy, l) {}
19649badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor
1971eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  static bool classof(const Stmt *T) {
19849badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor    return T->getStmtClass() == CXXReinterpretCastExprClass;
19949badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor  }
20049badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor  static bool classof(const CXXReinterpretCastExpr *) { return true; }
20149badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor};
20249badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor
20349badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// CXXConstCastExpr - A C++ @c const_cast expression (C++ [expr.const.cast]),
20449badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// which can remove type qualifiers but does not change the underlying value.
2051eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump///
20649badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// This expression node represents a const cast, e.g.,
20749badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// @c const_cast<char*>(PtrToConstChar).
20849badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregorclass CXXConstCastExpr : public CXXNamedCastExpr {
20949badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregorpublic:
2101eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  CXXConstCastExpr(QualType ty, Expr *op, QualType writtenTy,
21149badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor                   SourceLocation l)
212cdef2b75aa60cde1ca00e0aa3f89139ac89c6ae4Anders Carlsson    : CXXNamedCastExpr(CXXConstCastExprClass, ty, CK_NoOp, op, writtenTy, l) {}
21349badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor
2141eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  static bool classof(const Stmt *T) {
21549badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor    return T->getStmtClass() == CXXConstCastExprClass;
21649badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor  }
21749badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor  static bool classof(const CXXConstCastExpr *) { return true; }
2181060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek};
2191060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek
2201060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek/// CXXBoolLiteralExpr - [C++ 2.13.5] C++ Boolean Literal.
2211eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump///
2221060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenekclass CXXBoolLiteralExpr : public Expr {
2231060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  bool Value;
2241060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  SourceLocation Loc;
2251060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenekpublic:
2261eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  CXXBoolLiteralExpr(bool val, QualType Ty, SourceLocation l) :
2272333f7727f97018d6742e1e0938133bcfad967abEli Friedman    Expr(CXXBoolLiteralExprClass, Ty, false, false), Value(val), Loc(l) {}
2288b0b475b3464b0f70b91ba7d679d23c424677d5eSebastian Redl
2291060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  bool getValue() const { return Value; }
2305f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer
2311060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  virtual SourceRange getSourceRange() const { return SourceRange(Loc); }
2321eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
2331eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  static bool classof(const Stmt *T) {
2341060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek    return T->getStmtClass() == CXXBoolLiteralExprClass;
2351060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  }
2361060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  static bool classof(const CXXBoolLiteralExpr *) { return true; }
2371eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
2381060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  // Iterators
2391060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  virtual child_iterator child_begin();
2401060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  virtual child_iterator child_end();
2411060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek};
2421060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek
2436e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl/// CXXNullPtrLiteralExpr - [C++0x 2.14.7] C++ Pointer Literal
2446e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redlclass CXXNullPtrLiteralExpr : public Expr {
2456e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl  SourceLocation Loc;
2466e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redlpublic:
2476e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl  CXXNullPtrLiteralExpr(QualType Ty, SourceLocation l) :
2482333f7727f97018d6742e1e0938133bcfad967abEli Friedman    Expr(CXXNullPtrLiteralExprClass, Ty, false, false), Loc(l) {}
2496e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl
2506e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl  virtual SourceRange getSourceRange() const { return SourceRange(Loc); }
2516e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl
2526e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl  static bool classof(const Stmt *T) {
2536e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl    return T->getStmtClass() == CXXNullPtrLiteralExprClass;
2546e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl  }
2556e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl  static bool classof(const CXXNullPtrLiteralExpr *) { return true; }
2566e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl
2576e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl  virtual child_iterator child_begin();
2586e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl  virtual child_iterator child_end();
2596e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl};
2606e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl
261c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl/// CXXTypeidExpr - A C++ @c typeid expression (C++ [expr.typeid]), which gets
262c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl/// the type_info that corresponds to the supplied type, or the (possibly
263c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl/// dynamic) type of the supplied expression.
264c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl///
265c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl/// This represents code like @c typeid(int) or @c typeid(*objPtr)
266c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redlclass CXXTypeidExpr : public Expr {
267c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redlprivate:
268c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl  bool isTypeOp : 1;
269d457589fc69dc7a9c80cd74d317c0b81a35a27c9Sebastian Redl  union {
270d457589fc69dc7a9c80cd74d317c0b81a35a27c9Sebastian Redl    void *Ty;
271d457589fc69dc7a9c80cd74d317c0b81a35a27c9Sebastian Redl    Stmt *Ex;
272d457589fc69dc7a9c80cd74d317c0b81a35a27c9Sebastian Redl  } Operand;
273c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl  SourceRange Range;
274c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl
275c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redlpublic:
276c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl  CXXTypeidExpr(bool isTypeOp, void *op, QualType Ty, const SourceRange r) :
2772850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl      Expr(CXXTypeidExprClass, Ty,
2782850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl        // typeid is never type-dependent (C++ [temp.dep.expr]p4)
2792850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl        false,
2802850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl        // typeid is value-dependent if the type or expression are dependent
2812850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl        (isTypeOp ? QualType::getFromOpaquePtr(op)->isDependentType()
2822850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl                  : static_cast<Expr*>(op)->isValueDependent())),
2832850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl      isTypeOp(isTypeOp), Range(r) {
284d457589fc69dc7a9c80cd74d317c0b81a35a27c9Sebastian Redl    if (isTypeOp)
285d457589fc69dc7a9c80cd74d317c0b81a35a27c9Sebastian Redl      Operand.Ty = op;
286d457589fc69dc7a9c80cd74d317c0b81a35a27c9Sebastian Redl    else
287d457589fc69dc7a9c80cd74d317c0b81a35a27c9Sebastian Redl      // op was an Expr*, so cast it back to that to be safe
2882850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl      Operand.Ex = static_cast<Expr*>(op);
289d457589fc69dc7a9c80cd74d317c0b81a35a27c9Sebastian Redl  }
290c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl
291c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl  bool isTypeOperand() const { return isTypeOp; }
292c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl  QualType getTypeOperand() const {
293c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl    assert(isTypeOperand() && "Cannot call getTypeOperand for typeid(expr)");
294d457589fc69dc7a9c80cd74d317c0b81a35a27c9Sebastian Redl    return QualType::getFromOpaquePtr(Operand.Ty);
295c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl  }
296c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl  Expr* getExprOperand() const {
297c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl    assert(!isTypeOperand() && "Cannot call getExprOperand for typeid(type)");
298d457589fc69dc7a9c80cd74d317c0b81a35a27c9Sebastian Redl    return static_cast<Expr*>(Operand.Ex);
299c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl  }
300c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl
301c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl  virtual SourceRange getSourceRange() const {
302c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl    return Range;
303c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl  }
304c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl  static bool classof(const Stmt *T) {
305c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl    return T->getStmtClass() == CXXTypeidExprClass;
306c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl  }
307c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl  static bool classof(const CXXTypeidExpr *) { return true; }
308c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl
309c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl  // Iterators
310c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl  virtual child_iterator child_begin();
311c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl  virtual child_iterator child_end();
312c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl};
313c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl
314796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// CXXThisExpr - Represents the "this" expression in C++, which is a
315796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// pointer to the object on which the current member function is
316796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// executing (C++ [expr.prim]p3). Example:
317796da18402f286b897782a298ae3b20c459c102eDouglas Gregor///
318796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// @code
319796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// class Foo {
320796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// public:
321796da18402f286b897782a298ae3b20c459c102eDouglas Gregor///   void bar();
322796da18402f286b897782a298ae3b20c459c102eDouglas Gregor///   void test() { this->bar(); }
323796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// };
324796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// @endcode
325796da18402f286b897782a298ae3b20c459c102eDouglas Gregorclass CXXThisExpr : public Expr {
326796da18402f286b897782a298ae3b20c459c102eDouglas Gregor  SourceLocation Loc;
327828a197317288e3333b0ce6f5cedadd036e3531fDouglas Gregor  bool Implicit : 1;
328828a197317288e3333b0ce6f5cedadd036e3531fDouglas Gregor
329796da18402f286b897782a298ae3b20c459c102eDouglas Gregorpublic:
330828a197317288e3333b0ce6f5cedadd036e3531fDouglas Gregor  CXXThisExpr(SourceLocation L, QualType Type, bool isImplicit)
3312850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl    : Expr(CXXThisExprClass, Type,
3322850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl           // 'this' is type-dependent if the class type of the enclosing
3332850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl           // member function is dependent (C++ [temp.dep.expr]p2)
3342850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl           Type->isDependentType(), Type->isDependentType()),
335828a197317288e3333b0ce6f5cedadd036e3531fDouglas Gregor      Loc(L), Implicit(isImplicit) { }
336796da18402f286b897782a298ae3b20c459c102eDouglas Gregor
337796da18402f286b897782a298ae3b20c459c102eDouglas Gregor  virtual SourceRange getSourceRange() const { return SourceRange(Loc); }
338796da18402f286b897782a298ae3b20c459c102eDouglas Gregor
339828a197317288e3333b0ce6f5cedadd036e3531fDouglas Gregor  bool isImplicit() const { return Implicit; }
340828a197317288e3333b0ce6f5cedadd036e3531fDouglas Gregor  void setImplicit(bool I) { Implicit = I; }
341828a197317288e3333b0ce6f5cedadd036e3531fDouglas Gregor
3421eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  static bool classof(const Stmt *T) {
343796da18402f286b897782a298ae3b20c459c102eDouglas Gregor    return T->getStmtClass() == CXXThisExprClass;
344796da18402f286b897782a298ae3b20c459c102eDouglas Gregor  }
345796da18402f286b897782a298ae3b20c459c102eDouglas Gregor  static bool classof(const CXXThisExpr *) { return true; }
346796da18402f286b897782a298ae3b20c459c102eDouglas Gregor
347796da18402f286b897782a298ae3b20c459c102eDouglas Gregor  // Iterators
348796da18402f286b897782a298ae3b20c459c102eDouglas Gregor  virtual child_iterator child_begin();
349796da18402f286b897782a298ae3b20c459c102eDouglas Gregor  virtual child_iterator child_end();
350796da18402f286b897782a298ae3b20c459c102eDouglas Gregor};
351796da18402f286b897782a298ae3b20c459c102eDouglas Gregor
3521060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek///  CXXThrowExpr - [C++ 15] C++ Throw Expression.  This handles
3531060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek///  'throw' and 'throw' assignment-expression.  When
3541060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek///  assignment-expression isn't present, Op will be null.
3551060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek///
3561060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenekclass CXXThrowExpr : public Expr {
3571060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  Stmt *Op;
3581060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  SourceLocation ThrowLoc;
3591060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenekpublic:
3601060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  // Ty is the void type which is used as the result type of the
3611060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  // exepression.  The l is the location of the throw keyword.  expr
3621060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  // can by null, if the optional expression to throw isn't present.
3631060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  CXXThrowExpr(Expr *expr, QualType Ty, SourceLocation l) :
3642850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl    Expr(CXXThrowExprClass, Ty, false, false), Op(expr), ThrowLoc(l) {}
3651060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  const Expr *getSubExpr() const { return cast_or_null<Expr>(Op); }
3661060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  Expr *getSubExpr() { return cast_or_null<Expr>(Op); }
36742e5b50f4dc897f252e0d476063a7f9846d96624Douglas Gregor  void setSubExpr(Expr *E) { Op = E; }
36842e5b50f4dc897f252e0d476063a7f9846d96624Douglas Gregor
36942e5b50f4dc897f252e0d476063a7f9846d96624Douglas Gregor  SourceLocation getThrowLoc() const { return ThrowLoc; }
37042e5b50f4dc897f252e0d476063a7f9846d96624Douglas Gregor  void setThrowLoc(SourceLocation L) { ThrowLoc = L; }
3711060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek
3721060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  virtual SourceRange getSourceRange() const {
3731060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek    if (getSubExpr() == 0)
3741060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek      return SourceRange(ThrowLoc, ThrowLoc);
3751060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek    return SourceRange(ThrowLoc, getSubExpr()->getSourceRange().getEnd());
3761060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  }
3771060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek
3781060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  static bool classof(const Stmt *T) {
3791060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek    return T->getStmtClass() == CXXThrowExprClass;
3801060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  }
3811060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  static bool classof(const CXXThrowExpr *) { return true; }
3821060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek
3831060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  // Iterators
3841060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  virtual child_iterator child_begin();
3851060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  virtual child_iterator child_end();
3861060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek};
3871060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek
3881060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek/// CXXDefaultArgExpr - C++ [dcl.fct.default]. This wraps up a
3891060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek/// function call argument that was created from the corresponding
3901060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek/// parameter's default argument, when the call did not explicitly
3911060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek/// supply arguments for all of the parameters.
3921060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenekclass CXXDefaultArgExpr : public Expr {
39365222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor  /// \brief The parameter whose default is being used.
39465222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor  ///
39565222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor  /// When the bit is set, the subexpression is stored after the
39665222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor  /// CXXDefaultArgExpr itself. When the bit is clear, the parameter's
39765222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor  /// actual default expression is the subexpression.
39865222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor  llvm::PointerIntPair<ParmVarDecl *, 1, bool> Param;
3991eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
400036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor  /// \brief The location where the default argument expression was used.
401036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor  SourceLocation Loc;
402036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor
403f1480eee38b59d15438fb7bc50865ac7c7e22403Anders Carlssonprotected:
404036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor  CXXDefaultArgExpr(StmtClass SC, SourceLocation Loc, ParmVarDecl *param)
40565222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor    : Expr(SC,
40665222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor           param->hasUnparsedDefaultArg()
40765222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor             ? param->getType().getNonReferenceType()
4082333f7727f97018d6742e1e0938133bcfad967abEli Friedman             : param->getDefaultArg()->getType(),
4092333f7727f97018d6742e1e0938133bcfad967abEli Friedman           false, false),
410036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor      Param(param, false), Loc(Loc) { }
41165222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor
412036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor  CXXDefaultArgExpr(StmtClass SC, SourceLocation Loc, ParmVarDecl *param,
413036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor                    Expr *SubExpr)
4142333f7727f97018d6742e1e0938133bcfad967abEli Friedman    : Expr(SC, SubExpr->getType(), false, false), Param(param, true), Loc(Loc)
41565222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor  {
41665222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor    *reinterpret_cast<Expr **>(this + 1) = SubExpr;
41765222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor  }
41865222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor
41965222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregorprotected:
42065222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor  virtual void DoDestroy(ASTContext &C);
42165222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor
4221060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenekpublic:
4231060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  // Param is the parameter whose default argument is used by this
4241060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  // expression.
425036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor  static CXXDefaultArgExpr *Create(ASTContext &C, SourceLocation Loc,
426036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor                                   ParmVarDecl *Param) {
427036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor    return new (C) CXXDefaultArgExpr(CXXDefaultArgExprClass, Loc, Param);
428f1480eee38b59d15438fb7bc50865ac7c7e22403Anders Carlsson  }
4291060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek
43065222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor  // Param is the parameter whose default argument is used by this
43165222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor  // expression, and SubExpr is the expression that will actually be used.
432036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor  static CXXDefaultArgExpr *Create(ASTContext &C,
433036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor                                   SourceLocation Loc,
434036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor                                   ParmVarDecl *Param,
43565222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor                                   Expr *SubExpr);
43665222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor
4371060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  // Retrieve the parameter that the argument was created from.
43865222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor  const ParmVarDecl *getParam() const { return Param.getPointer(); }
43965222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor  ParmVarDecl *getParam() { return Param.getPointer(); }
4401060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek
4411060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  // Retrieve the actual argument to the function call.
44265222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor  const Expr *getExpr() const {
44365222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor    if (Param.getInt())
44465222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor      return *reinterpret_cast<Expr const * const*> (this + 1);
44565222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor    return getParam()->getDefaultArg();
44665222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor  }
44765222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor  Expr *getExpr() {
44865222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor    if (Param.getInt())
44965222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor      return *reinterpret_cast<Expr **> (this + 1);
45065222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor    return getParam()->getDefaultArg();
45165222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor  }
4521060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek
453036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor  /// \brief Retrieve the location where this default argument was actually
454036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor  /// used.
455036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor  SourceLocation getUsedLocation() const { return Loc; }
456036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor
4571060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  virtual SourceRange getSourceRange() const {
4581060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek    // Default argument expressions have no representation in the
4591060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek    // source, so they have an empty source range.
4601060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek    return SourceRange();
4611060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  }
4621060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek
4631060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  static bool classof(const Stmt *T) {
4641060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek    return T->getStmtClass() == CXXDefaultArgExprClass;
4651060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  }
4661060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  static bool classof(const CXXDefaultArgExpr *) { return true; }
4671060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek
4681060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  // Iterators
4691060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  virtual child_iterator child_begin();
4701060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  virtual child_iterator child_end();
4711060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek};
472987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis
473c1ce477119fed070299668aab24084b17ff5f14bAnders Carlsson/// CXXTemporary - Represents a C++ temporary.
474c1ce477119fed070299668aab24084b17ff5f14bAnders Carlssonclass CXXTemporary {
475c1ce477119fed070299668aab24084b17ff5f14bAnders Carlsson  /// Destructor - The destructor that needs to be called.
476b859f35459ae3e1188d1e1b86df08d649695fd86Anders Carlsson  const CXXDestructorDecl *Destructor;
4771eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
478b859f35459ae3e1188d1e1b86df08d649695fd86Anders Carlsson  CXXTemporary(const CXXDestructorDecl *destructor)
479c1ce477119fed070299668aab24084b17ff5f14bAnders Carlsson    : Destructor(destructor) { }
48088eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlsson  ~CXXTemporary() { }
481c1ce477119fed070299668aab24084b17ff5f14bAnders Carlsson
482c1ce477119fed070299668aab24084b17ff5f14bAnders Carlssonpublic:
4831eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  static CXXTemporary *Create(ASTContext &C,
484b859f35459ae3e1188d1e1b86df08d649695fd86Anders Carlsson                              const CXXDestructorDecl *Destructor);
4851eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
48642602bb40aefcc2751d4078ba88aacf4d965c9bdDouglas Gregor  void Destroy(ASTContext &Ctx);
4871eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
488f0721fe438d7e40c168e5d664970e7830bc138fbAnders Carlsson  const CXXDestructorDecl *getDestructor() const { return Destructor; }
489c1ce477119fed070299668aab24084b17ff5f14bAnders Carlsson};
490fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson
4911eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump/// CXXBindTemporaryExpr - Represents binding an expression to a temporary,
492fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson/// so its destructor can be called later.
493fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlssonclass CXXBindTemporaryExpr : public Expr {
494fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson  CXXTemporary *Temp;
4951eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
496fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson  Stmt *SubExpr;
497fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson
4981eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  CXXBindTemporaryExpr(CXXTemporary *temp, Expr* subexpr)
4992333f7727f97018d6742e1e0938133bcfad967abEli Friedman   : Expr(CXXBindTemporaryExprClass, subexpr->getType(), false, false),
5002333f7727f97018d6742e1e0938133bcfad967abEli Friedman     Temp(temp), SubExpr(subexpr) { }
5011eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  ~CXXBindTemporaryExpr() { }
50288eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlsson
50342602bb40aefcc2751d4078ba88aacf4d965c9bdDouglas Gregorprotected:
50442602bb40aefcc2751d4078ba88aacf4d965c9bdDouglas Gregor  virtual void DoDestroy(ASTContext &C);
50542602bb40aefcc2751d4078ba88aacf4d965c9bdDouglas Gregor
506fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlssonpublic:
5071eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  static CXXBindTemporaryExpr *Create(ASTContext &C, CXXTemporary *Temp,
508fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson                                      Expr* SubExpr);
5091eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
51088eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlsson  CXXTemporary *getTemporary() { return Temp; }
511f0721fe438d7e40c168e5d664970e7830bc138fbAnders Carlsson  const CXXTemporary *getTemporary() const { return Temp; }
512f0721fe438d7e40c168e5d664970e7830bc138fbAnders Carlsson
513fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson  const Expr *getSubExpr() const { return cast<Expr>(SubExpr); }
514fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson  Expr *getSubExpr() { return cast<Expr>(SubExpr); }
51588eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlsson  void setSubExpr(Expr *E) { SubExpr = E; }
516fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson
51796be6917e1c4ba1f4435a14c9e7c6c139571d086Douglas Gregor  virtual SourceRange getSourceRange() const {
51896be6917e1c4ba1f4435a14c9e7c6c139571d086Douglas Gregor    return SubExpr->getSourceRange();
51996be6917e1c4ba1f4435a14c9e7c6c139571d086Douglas Gregor  }
520fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson
521fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson  // Implement isa/cast/dyncast/etc.
522fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson  static bool classof(const Stmt *T) {
523fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson    return T->getStmtClass() == CXXBindTemporaryExprClass;
524fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson  }
525fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson  static bool classof(const CXXBindTemporaryExpr *) { return true; }
526fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson
527fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson  // Iterators
528fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson  virtual child_iterator child_begin();
529fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson  virtual child_iterator child_end();
530fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson};
531fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson
53215ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson/// CXXConstructExpr - Represents a call to a C++ constructor.
53315ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlssonclass CXXConstructExpr : public Expr {
53415ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson  CXXConstructorDecl *Constructor;
53515ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson
53699a2e600f9e2e51d3ce10fb6f27191677ac65b2aDouglas Gregor  SourceLocation Loc;
53716006c901315fa12a108b4e571f187f4b676e426Douglas Gregor  bool Elidable : 1;
53816006c901315fa12a108b4e571f187f4b676e426Douglas Gregor  bool ZeroInitialization : 1;
53915ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson  Stmt **Args;
54015ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson  unsigned NumArgs;
5411eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
542bd6734e5f6432ce0cc07171c490ffaa094796198Anders Carlssonprotected:
5431eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  CXXConstructExpr(ASTContext &C, StmtClass SC, QualType T,
54499a2e600f9e2e51d3ce10fb6f27191677ac65b2aDouglas Gregor                   SourceLocation Loc,
545bd6734e5f6432ce0cc07171c490ffaa094796198Anders Carlsson                   CXXConstructorDecl *d, bool elidable,
54616006c901315fa12a108b4e571f187f4b676e426Douglas Gregor                   Expr **args, unsigned numargs,
54716006c901315fa12a108b4e571f187f4b676e426Douglas Gregor                   bool ZeroInitialization = false);
5481eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  ~CXXConstructExpr() { }
549bd6734e5f6432ce0cc07171c490ffaa094796198Anders Carlsson
55042602bb40aefcc2751d4078ba88aacf4d965c9bdDouglas Gregor  virtual void DoDestroy(ASTContext &C);
55142602bb40aefcc2751d4078ba88aacf4d965c9bdDouglas Gregor
55215ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlssonpublic:
55339da0b8145eaec7da7004f9b3645c5c9f4f63b1dDouglas Gregor  /// \brief Construct an empty C++ construction expression that will store
55439da0b8145eaec7da7004f9b3645c5c9f4f63b1dDouglas Gregor  /// \p numargs arguments.
55539da0b8145eaec7da7004f9b3645c5c9f4f63b1dDouglas Gregor  CXXConstructExpr(EmptyShell Empty, ASTContext &C, unsigned numargs);
55639da0b8145eaec7da7004f9b3645c5c9f4f63b1dDouglas Gregor
5578e587a15da6d3457a418239d5eb4146fcbd209f3Anders Carlsson  static CXXConstructExpr *Create(ASTContext &C, QualType T,
55899a2e600f9e2e51d3ce10fb6f27191677ac65b2aDouglas Gregor                                  SourceLocation Loc,
5591eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump                                  CXXConstructorDecl *D, bool Elidable,
56016006c901315fa12a108b4e571f187f4b676e426Douglas Gregor                                  Expr **Args, unsigned NumArgs,
56116006c901315fa12a108b4e571f187f4b676e426Douglas Gregor                                  bool ZeroInitialization = false);
5621eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
5631eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
564d94546a0a1deef7286c13e49b9584621ae81cc9aDouglas Gregor  CXXConstructorDecl* getConstructor() const { return Constructor; }
56539da0b8145eaec7da7004f9b3645c5c9f4f63b1dDouglas Gregor  void setConstructor(CXXConstructorDecl *C) { Constructor = C; }
56639da0b8145eaec7da7004f9b3645c5c9f4f63b1dDouglas Gregor
56799a2e600f9e2e51d3ce10fb6f27191677ac65b2aDouglas Gregor  SourceLocation getLocation() const { return Loc; }
56899a2e600f9e2e51d3ce10fb6f27191677ac65b2aDouglas Gregor  void setLocation(SourceLocation Loc) { this->Loc = Loc; }
56999a2e600f9e2e51d3ce10fb6f27191677ac65b2aDouglas Gregor
570d94546a0a1deef7286c13e49b9584621ae81cc9aDouglas Gregor  /// \brief Whether this construction is elidable.
571d94546a0a1deef7286c13e49b9584621ae81cc9aDouglas Gregor  bool isElidable() const { return Elidable; }
57239da0b8145eaec7da7004f9b3645c5c9f4f63b1dDouglas Gregor  void setElidable(bool E) { Elidable = E; }
57339da0b8145eaec7da7004f9b3645c5c9f4f63b1dDouglas Gregor
57416006c901315fa12a108b4e571f187f4b676e426Douglas Gregor  /// \brief Whether this construction first requires
57516006c901315fa12a108b4e571f187f4b676e426Douglas Gregor  /// zero-initialization before the initializer is called.
57616006c901315fa12a108b4e571f187f4b676e426Douglas Gregor  bool requiresZeroInitialization() const { return ZeroInitialization; }
57716006c901315fa12a108b4e571f187f4b676e426Douglas Gregor  void setRequiresZeroInitialization(bool ZeroInit) {
57816006c901315fa12a108b4e571f187f4b676e426Douglas Gregor    ZeroInitialization = ZeroInit;
57916006c901315fa12a108b4e571f187f4b676e426Douglas Gregor  }
58016006c901315fa12a108b4e571f187f4b676e426Douglas Gregor
58115ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson  typedef ExprIterator arg_iterator;
58215ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson  typedef ConstExprIterator const_arg_iterator;
5831eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
58415ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson  arg_iterator arg_begin() { return Args; }
58515ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson  arg_iterator arg_end() { return Args + NumArgs; }
58615ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson  const_arg_iterator arg_begin() const { return Args; }
58715ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson  const_arg_iterator arg_end() const { return Args + NumArgs; }
58815ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson
589a88cfbfac9bbcbb9858f048d6d73a48711d8e93dDouglas Gregor  Expr **getArgs() const { return reinterpret_cast<Expr **>(Args); }
59015ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson  unsigned getNumArgs() const { return NumArgs; }
59115ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson
592bcb11d01c034f967503bd98f28bdf458c1ab8001Anders Carlsson  /// getArg - Return the specified argument.
593bcb11d01c034f967503bd98f28bdf458c1ab8001Anders Carlsson  Expr *getArg(unsigned Arg) {
594bcb11d01c034f967503bd98f28bdf458c1ab8001Anders Carlsson    assert(Arg < NumArgs && "Arg access out of range!");
595bcb11d01c034f967503bd98f28bdf458c1ab8001Anders Carlsson    return cast<Expr>(Args[Arg]);
596bcb11d01c034f967503bd98f28bdf458c1ab8001Anders Carlsson  }
597bcb11d01c034f967503bd98f28bdf458c1ab8001Anders Carlsson  const Expr *getArg(unsigned Arg) const {
598bcb11d01c034f967503bd98f28bdf458c1ab8001Anders Carlsson    assert(Arg < NumArgs && "Arg access out of range!");
599bcb11d01c034f967503bd98f28bdf458c1ab8001Anders Carlsson    return cast<Expr>(Args[Arg]);
600bcb11d01c034f967503bd98f28bdf458c1ab8001Anders Carlsson  }
6011eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
6022eeed7bc4fd457ac57ff32ab3b02674588545f65Fariborz Jahanian  /// setArg - Set the specified argument.
6032eeed7bc4fd457ac57ff32ab3b02674588545f65Fariborz Jahanian  void setArg(unsigned Arg, Expr *ArgExpr) {
6042eeed7bc4fd457ac57ff32ab3b02674588545f65Fariborz Jahanian    assert(Arg < NumArgs && "Arg access out of range!");
6052eeed7bc4fd457ac57ff32ab3b02674588545f65Fariborz Jahanian    Args[Arg] = ArgExpr;
6062eeed7bc4fd457ac57ff32ab3b02674588545f65Fariborz Jahanian  }
6072eeed7bc4fd457ac57ff32ab3b02674588545f65Fariborz Jahanian
608e383768f7f5d45ca4af0b1c11cbf072de18bce98Ted Kremenek  virtual SourceRange getSourceRange() const;
60915ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson
6101eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  static bool classof(const Stmt *T) {
611524fa13fd81e88533c7a1d4b1232c0de2c97dc7cAnders Carlsson    return T->getStmtClass() == CXXConstructExprClass ||
612524fa13fd81e88533c7a1d4b1232c0de2c97dc7cAnders Carlsson      T->getStmtClass() == CXXTemporaryObjectExprClass;
61315ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson  }
61415ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson  static bool classof(const CXXConstructExpr *) { return true; }
6151eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
61615ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson  // Iterators
61715ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson  virtual child_iterator child_begin();
61815ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson  virtual child_iterator child_end();
61915ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson};
62015ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson
62149badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// CXXFunctionalCastExpr - Represents an explicit C++ type conversion
62249badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// that uses "functional" notion (C++ [expr.type.conv]). Example: @c
62349badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// x = int(0.5);
62449badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregorclass CXXFunctionalCastExpr : public ExplicitCastExpr {
625987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  SourceLocation TyBeginLoc;
626987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  SourceLocation RParenLoc;
627987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidispublic:
6281eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  CXXFunctionalCastExpr(QualType ty, QualType writtenTy,
6291eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump                        SourceLocation tyBeginLoc, CastKind kind,
6300aebc81e02397a5987aaa8e8c7acbdb01a31d7c3Anders Carlsson                        Expr *castExpr, SourceLocation rParenLoc)
6310aebc81e02397a5987aaa8e8c7acbdb01a31d7c3Anders Carlsson    : ExplicitCastExpr(CXXFunctionalCastExprClass, ty, kind, castExpr,
6320aebc81e02397a5987aaa8e8c7acbdb01a31d7c3Anders Carlsson                       writtenTy),
6330aebc81e02397a5987aaa8e8c7acbdb01a31d7c3Anders Carlsson      TyBeginLoc(tyBeginLoc), RParenLoc(rParenLoc) {}
6340aebc81e02397a5987aaa8e8c7acbdb01a31d7c3Anders Carlsson
635987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  SourceLocation getTypeBeginLoc() const { return TyBeginLoc; }
636987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  SourceLocation getRParenLoc() const { return RParenLoc; }
6371eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
638987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  virtual SourceRange getSourceRange() const {
639987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis    return SourceRange(TyBeginLoc, RParenLoc);
640987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  }
6411eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  static bool classof(const Stmt *T) {
6421eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump    return T->getStmtClass() == CXXFunctionalCastExprClass;
643987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  }
644987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  static bool classof(const CXXFunctionalCastExpr *) { return true; }
645987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis};
646987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis
647506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// @brief Represents a C++ functional cast expression that builds a
648506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// temporary object.
649506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor///
6501eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump/// This expression type represents a C++ "functional" cast
651506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// (C++[expr.type.conv]) with N != 1 arguments that invokes a
652506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// constructor to build a temporary object. If N == 0 but no
653506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// constructor will be called (because the functional cast is
654506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// performing a value-initialized an object whose class type has no
655506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// user-declared constructors), CXXZeroInitValueExpr will represent
656506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// the functional cast. Finally, with N == 1 arguments the functional
657506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// cast expression will be represented by CXXFunctionalCastExpr.
658506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// Example:
659506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// @code
660506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// struct X { X(int, float); }
661506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor///
662506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// X create_X() {
663506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor///   return X(1, 3.14f); // creates a CXXTemporaryObjectExpr
664506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// };
665506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// @endcode
666524fa13fd81e88533c7a1d4b1232c0de2c97dc7cAnders Carlssonclass CXXTemporaryObjectExpr : public CXXConstructExpr {
667506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor  SourceLocation TyBeginLoc;
668506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor  SourceLocation RParenLoc;
669506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor
670506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregorpublic:
6711eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  CXXTemporaryObjectExpr(ASTContext &C, CXXConstructorDecl *Cons,
6721eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump                         QualType writtenTy, SourceLocation tyBeginLoc,
6731eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump                         Expr **Args,unsigned NumArgs,
6748e587a15da6d3457a418239d5eb4146fcbd209f3Anders Carlsson                         SourceLocation rParenLoc);
675506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor
6761eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  ~CXXTemporaryObjectExpr() { }
677506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor
678506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor  SourceLocation getTypeBeginLoc() const { return TyBeginLoc; }
679506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor  SourceLocation getRParenLoc() const { return RParenLoc; }
680ba49817c5b9f502602672861cf369fd0e53966e8Douglas Gregor
681506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor  virtual SourceRange getSourceRange() const {
682506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor    return SourceRange(TyBeginLoc, RParenLoc);
683506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor  }
6841eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  static bool classof(const Stmt *T) {
685506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor    return T->getStmtClass() == CXXTemporaryObjectExprClass;
686506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor  }
687506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor  static bool classof(const CXXTemporaryObjectExpr *) { return true; }
688506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor};
689506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor
690987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis/// CXXZeroInitValueExpr - [C++ 5.2.3p2]
691506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// Expression "T()" which creates a value-initialized rvalue of type
692506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// T, which is either a non-class type or a class type without any
693506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// user-defined constructors.
694987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis///
695987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidisclass CXXZeroInitValueExpr : public Expr {
696987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  SourceLocation TyBeginLoc;
697987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  SourceLocation RParenLoc;
698987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis
699987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidispublic:
700987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  CXXZeroInitValueExpr(QualType ty, SourceLocation tyBeginLoc,
7011eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump                       SourceLocation rParenLoc ) :
702d94546a0a1deef7286c13e49b9584621ae81cc9aDouglas Gregor    Expr(CXXZeroInitValueExprClass, ty, false, false),
703987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis    TyBeginLoc(tyBeginLoc), RParenLoc(rParenLoc) {}
7041eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
705987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  SourceLocation getTypeBeginLoc() const { return TyBeginLoc; }
706987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  SourceLocation getRParenLoc() const { return RParenLoc; }
707987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis
7084c67834407ca6ab344dcf44fc599ad4938cfa96dDouglas Gregor  /// @brief Whether this initialization expression was
7094c67834407ca6ab344dcf44fc599ad4938cfa96dDouglas Gregor  /// implicitly-generated.
7101eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  bool isImplicit() const {
7111eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump    return TyBeginLoc.isInvalid() && RParenLoc.isInvalid();
7124c67834407ca6ab344dcf44fc599ad4938cfa96dDouglas Gregor  }
7134c67834407ca6ab344dcf44fc599ad4938cfa96dDouglas Gregor
714987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  virtual SourceRange getSourceRange() const {
715987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis    return SourceRange(TyBeginLoc, RParenLoc);
716987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  }
7171eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
7181eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  static bool classof(const Stmt *T) {
719987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis    return T->getStmtClass() == CXXZeroInitValueExprClass;
720987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  }
721987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  static bool classof(const CXXZeroInitValueExpr *) { return true; }
7221eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
723987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  // Iterators
724987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  virtual child_iterator child_begin();
725987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  virtual child_iterator child_end();
726987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis};
727987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis
7284c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl/// CXXNewExpr - A new expression for memory allocation and constructor calls,
7294c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl/// e.g: "new CXXNewExpr(foo)".
7304c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redlclass CXXNewExpr : public Expr {
7314c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  // Was the usage ::new, i.e. is the global new to be used?
7324c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  bool GlobalNew : 1;
7334c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  // Was the form (type-id) used? Otherwise, it was new-type-id.
7344c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  bool ParenTypeId : 1;
7354c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  // Is there an initializer? If not, built-ins are uninitialized, else they're
7364c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  // value-initialized.
7374c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  bool Initializer : 1;
738cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl  // Do we allocate an array? If so, the first SubExpr is the size expression.
739cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl  bool Array : 1;
7404c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  // The number of placement new arguments.
7414c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  unsigned NumPlacementArgs : 14;
7424c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  // The number of constructor arguments. This may be 1 even for non-class
7434c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  // types; use the pseudo copy constructor.
744cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl  unsigned NumConstructorArgs : 14;
745cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl  // Contains an optional array size expression, any number of optional
746cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl  // placement arguments, and any number of optional constructor arguments,
747cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl  // in that order.
7484c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  Stmt **SubExprs;
7494c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  // Points to the allocation function used.
7504c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  FunctionDecl *OperatorNew;
7514c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  // Points to the deallocation function used in case of error. May be null.
7524c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  FunctionDecl *OperatorDelete;
7534c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  // Points to the constructor used. Cannot be null if AllocType is a record;
7544c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  // it would still point at the default constructor (even an implicit one).
7554c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  // Must be null for all other types.
7564c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  CXXConstructorDecl *Constructor;
7574c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
7584c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  SourceLocation StartLoc;
7594c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  SourceLocation EndLoc;
7604c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
7614c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redlpublic:
7624c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  CXXNewExpr(bool globalNew, FunctionDecl *operatorNew, Expr **placementArgs,
763cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl             unsigned numPlaceArgs, bool ParenTypeId, Expr *arraySize,
7644c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl             CXXConstructorDecl *constructor, bool initializer,
7654c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl             Expr **constructorArgs, unsigned numConsArgs,
7664c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl             FunctionDecl *operatorDelete, QualType ty,
7674c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl             SourceLocation startLoc, SourceLocation endLoc);
7684c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  ~CXXNewExpr() {
7694c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl    delete[] SubExprs;
7704c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  }
7714c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
772cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl  QualType getAllocatedType() const {
773cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl    assert(getType()->isPointerType());
7746217b80b7a1379b74cced1c076338262c3c980b3Ted Kremenek    return getType()->getAs<PointerType>()->getPointeeType();
775cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl  }
7764c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
7774c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  FunctionDecl *getOperatorNew() const { return OperatorNew; }
7784c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  FunctionDecl *getOperatorDelete() const { return OperatorDelete; }
7794c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  CXXConstructorDecl *getConstructor() const { return Constructor; }
7804c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
781cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl  bool isArray() const { return Array; }
782cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl  Expr *getArraySize() {
783cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl    return Array ? cast<Expr>(SubExprs[0]) : 0;
784cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl  }
785cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl  const Expr *getArraySize() const {
786cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl    return Array ? cast<Expr>(SubExprs[0]) : 0;
787cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl  }
788cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl
7894c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  unsigned getNumPlacementArgs() const { return NumPlacementArgs; }
7904c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  Expr *getPlacementArg(unsigned i) {
7914c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl    assert(i < NumPlacementArgs && "Index out of range");
792cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl    return cast<Expr>(SubExprs[Array + i]);
7934c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  }
7944c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  const Expr *getPlacementArg(unsigned i) const {
7954c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl    assert(i < NumPlacementArgs && "Index out of range");
796cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl    return cast<Expr>(SubExprs[Array + i]);
7974c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  }
7984c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
7994c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  bool isGlobalNew() const { return GlobalNew; }
8004c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  bool isParenTypeId() const { return ParenTypeId; }
8014c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  bool hasInitializer() const { return Initializer; }
8024c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
8034c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  unsigned getNumConstructorArgs() const { return NumConstructorArgs; }
8044c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  Expr *getConstructorArg(unsigned i) {
8054c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl    assert(i < NumConstructorArgs && "Index out of range");
806cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl    return cast<Expr>(SubExprs[Array + NumPlacementArgs + i]);
8074c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  }
8084c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  const Expr *getConstructorArg(unsigned i) const {
8094c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl    assert(i < NumConstructorArgs && "Index out of range");
810cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl    return cast<Expr>(SubExprs[Array + NumPlacementArgs + i]);
8114c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  }
8124c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
8134c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  typedef ExprIterator arg_iterator;
8144c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  typedef ConstExprIterator const_arg_iterator;
8154c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
8164c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  arg_iterator placement_arg_begin() {
817cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl    return SubExprs + Array;
8184c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  }
8194c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  arg_iterator placement_arg_end() {
820cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl    return SubExprs + Array + getNumPlacementArgs();
8214c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  }
8224c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  const_arg_iterator placement_arg_begin() const {
823cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl    return SubExprs + Array;
8244c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  }
8254c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  const_arg_iterator placement_arg_end() const {
826cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl    return SubExprs + Array + getNumPlacementArgs();
8274c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  }
8284c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
8294c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  arg_iterator constructor_arg_begin() {
830cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl    return SubExprs + Array + getNumPlacementArgs();
8314c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  }
8324c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  arg_iterator constructor_arg_end() {
833cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl    return SubExprs + Array + getNumPlacementArgs() + getNumConstructorArgs();
8344c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  }
8354c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  const_arg_iterator constructor_arg_begin() const {
836cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl    return SubExprs + Array + getNumPlacementArgs();
8374c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  }
8384c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  const_arg_iterator constructor_arg_end() const {
839cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl    return SubExprs + Array + getNumPlacementArgs() + getNumConstructorArgs();
8404c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  }
8414c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
8424c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  virtual SourceRange getSourceRange() const {
8434c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl    return SourceRange(StartLoc, EndLoc);
8444c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  }
8454c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
8464c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  static bool classof(const Stmt *T) {
8474c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl    return T->getStmtClass() == CXXNewExprClass;
8484c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  }
8494c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  static bool classof(const CXXNewExpr *) { return true; }
8504c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
8514c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  // Iterators
8524c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  virtual child_iterator child_begin();
8534c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  virtual child_iterator child_end();
8544c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl};
8554c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
8564c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl/// CXXDeleteExpr - A delete expression for memory deallocation and destructor
8574c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl/// calls, e.g. "delete[] pArray".
8584c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redlclass CXXDeleteExpr : public Expr {
8594c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  // Is this a forced global delete, i.e. "::delete"?
8604c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  bool GlobalDelete : 1;
8614c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  // Is this the array form of delete, i.e. "delete[]"?
8624c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  bool ArrayForm : 1;
8634c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  // Points to the operator delete overload that is used. Could be a member.
8644c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  FunctionDecl *OperatorDelete;
8654c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  // The pointer expression to be deleted.
8664c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  Stmt *Argument;
8674c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  // Location of the expression.
8684c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  SourceLocation Loc;
8694c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redlpublic:
8704c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  CXXDeleteExpr(QualType ty, bool globalDelete, bool arrayForm,
8714c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl                FunctionDecl *operatorDelete, Expr *arg, SourceLocation loc)
8722850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl    : Expr(CXXDeleteExprClass, ty, false, false), GlobalDelete(globalDelete),
8734c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl      ArrayForm(arrayForm), OperatorDelete(operatorDelete), Argument(arg),
8744c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl      Loc(loc) { }
8754c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
8764c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  bool isGlobalDelete() const { return GlobalDelete; }
8774c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  bool isArrayForm() const { return ArrayForm; }
8784c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
8794c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  FunctionDecl *getOperatorDelete() const { return OperatorDelete; }
8804c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
8814c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  Expr *getArgument() { return cast<Expr>(Argument); }
8824c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  const Expr *getArgument() const { return cast<Expr>(Argument); }
8834c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
8844c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  virtual SourceRange getSourceRange() const {
8854c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl    return SourceRange(Loc, Argument->getLocEnd());
8864c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  }
8874c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
8884c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  static bool classof(const Stmt *T) {
8894c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl    return T->getStmtClass() == CXXDeleteExprClass;
8904c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  }
8914c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  static bool classof(const CXXDeleteExpr *) { return true; }
8924c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
8934c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  // Iterators
8944c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  virtual child_iterator child_begin();
8954c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  virtual child_iterator child_end();
8964c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl};
8974c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
898a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor/// \brief Represents a C++ pseudo-destructor (C++ [expr.pseudo]).
899a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor///
900a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor/// Example:
901a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor///
902a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor/// \code
9031eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump/// template<typename T>
904a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor/// void destroy(T* ptr) {
905a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor///   ptr->~T();
906a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor/// }
907a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor/// \endcode
908a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor///
909a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor/// When the template is parsed, the expression \c ptr->~T will be stored as
910a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor/// a member reference expression. If it then instantiated with a scalar type
9111eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump/// as a template argument for T, the resulting expression will be a
912a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor/// pseudo-destructor expression.
913a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregorclass CXXPseudoDestructorExpr : public Expr {
914a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  /// \brief The base expression (that is being destroyed).
915a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  Stmt *Base;
9161eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
917a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  /// \brief Whether the operator was an arrow ('->'); otherwise, it was a
918a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  /// period ('.').
919a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  bool IsArrow : 1;
9201eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
921a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  /// \brief The location of the '.' or '->' operator.
922a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  SourceLocation OperatorLoc;
9231eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
924a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  /// \brief The nested-name-specifier that follows the operator, if present.
925a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  NestedNameSpecifier *Qualifier;
9261eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
9271eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  /// \brief The source range that covers the nested-name-specifier, if
928a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  /// present.
929a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  SourceRange QualifierRange;
9301eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
931a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  /// \brief The type being destroyed.
932a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  QualType DestroyedType;
9331eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
934a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  /// \brief The location of the type after the '~'.
935a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  SourceLocation DestroyedTypeLoc;
9361eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
937a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregorpublic:
938a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  CXXPseudoDestructorExpr(ASTContext &Context,
939a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor                          Expr *Base, bool isArrow, SourceLocation OperatorLoc,
940a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor                          NestedNameSpecifier *Qualifier,
941a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor                          SourceRange QualifierRange,
9421eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump                          QualType DestroyedType,
943a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor                          SourceLocation DestroyedTypeLoc)
9441eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump    : Expr(CXXPseudoDestructorExprClass,
945a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor           Context.getPointerType(Context.getFunctionType(Context.VoidTy, 0, 0,
946a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor                                                          false, 0)),
947a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor           /*isTypeDependent=*/false,
948a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor           /*isValueDependent=*/Base->isValueDependent()),
9491eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump      Base(static_cast<Stmt *>(Base)), IsArrow(isArrow),
950a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor      OperatorLoc(OperatorLoc), Qualifier(Qualifier),
951a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor      QualifierRange(QualifierRange), DestroyedType(DestroyedType),
952a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor      DestroyedTypeLoc(DestroyedTypeLoc) { }
9531eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
954a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  void setBase(Expr *E) { Base = E; }
955a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  Expr *getBase() const { return cast<Expr>(Base); }
9561eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
9571eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  /// \brief Determines whether this member expression actually had
958a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  /// a C++ nested-name-specifier prior to the name of the member, e.g.,
959a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  /// x->Base::foo.
960a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  bool hasQualifier() const { return Qualifier != 0; }
9611eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
962a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  /// \brief If the member name was qualified, retrieves the source range of
963a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  /// the nested-name-specifier that precedes the member name. Otherwise,
964a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  /// returns an empty source range.
965a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  SourceRange getQualifierRange() const { return QualifierRange; }
9661eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
9671eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  /// \brief If the member name was qualified, retrieves the
968a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  /// nested-name-specifier that precedes the member name. Otherwise, returns
969a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  /// NULL.
970a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  NestedNameSpecifier *getQualifier() const { return Qualifier; }
9711eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
972a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  /// \brief Determine whether this pseudo-destructor expression was written
973a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  /// using an '->' (otherwise, it used a '.').
974a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  bool isArrow() const { return IsArrow; }
975a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  void setArrow(bool A) { IsArrow = A; }
976a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor
977a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  /// \brief Retrieve the location of the '.' or '->' operator.
978a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  SourceLocation getOperatorLoc() const { return OperatorLoc; }
9791eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
980a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  /// \brief Retrieve the type that is being destroyed.
981a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  QualType getDestroyedType() const { return DestroyedType; }
9821eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
983a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  /// \brief Retrieve the location of the type being destroyed.
984a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  SourceLocation getDestroyedTypeLoc() const { return DestroyedTypeLoc; }
9851eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
986a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  virtual SourceRange getSourceRange() const {
987a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor    return SourceRange(Base->getLocStart(), DestroyedTypeLoc);
988a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  }
9891eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
9901eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  static bool classof(const Stmt *T) {
991a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor    return T->getStmtClass() == CXXPseudoDestructorExprClass;
992a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  }
993a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  static bool classof(const CXXPseudoDestructorExpr *) { return true; }
9941eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
995a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  // Iterators
996a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  virtual child_iterator child_begin();
9971eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  virtual child_iterator child_end();
998a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor};
9991eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
100064b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl/// UnaryTypeTraitExpr - A GCC or MS unary type trait, as used in the
100164b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl/// implementation of TR1/C++0x type trait templates.
100264b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl/// Example:
100364b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl/// __is_pod(int) == true
100464b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl/// __is_enum(std::string) == false
100564b45f7e0d3167f040841ac2920aead7f080730dSebastian Redlclass UnaryTypeTraitExpr : public Expr {
100664b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl  /// UTT - The trait.
100764b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl  UnaryTypeTrait UTT;
100864b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl
100964b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl  /// Loc - The location of the type trait keyword.
101064b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl  SourceLocation Loc;
101164b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl
101264b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl  /// RParen - The location of the closing paren.
101364b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl  SourceLocation RParen;
101464b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl
101564b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl  /// QueriedType - The type we're testing.
101664b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl  QualType QueriedType;
101764b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl
101864b45f7e0d3167f040841ac2920aead7f080730dSebastian Redlpublic:
101964b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl  UnaryTypeTraitExpr(SourceLocation loc, UnaryTypeTrait utt, QualType queried,
102064b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl                     SourceLocation rparen, QualType ty)
102164b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl    : Expr(UnaryTypeTraitExprClass, ty, false, queried->isDependentType()),
102264b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl      UTT(utt), Loc(loc), RParen(rparen), QueriedType(queried) { }
102364b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl
102464b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl  virtual SourceRange getSourceRange() const { return SourceRange(Loc, RParen);}
102564b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl
102664b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl  UnaryTypeTrait getTrait() const { return UTT; }
102764b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl
102864b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl  QualType getQueriedType() const { return QueriedType; }
102964b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl
10305e03f9ea8174ae588c5e69ec6b5ef4c68f8fd766Douglas Gregor  bool EvaluateTrait(ASTContext&) const;
103164b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl
103264b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl  static bool classof(const Stmt *T) {
103364b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl    return T->getStmtClass() == UnaryTypeTraitExprClass;
103464b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl  }
103564b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl  static bool classof(const UnaryTypeTraitExpr *) { return true; }
103664b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl
103764b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl  // Iterators
103864b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl  virtual child_iterator child_begin();
103964b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl  virtual child_iterator child_end();
104064b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl};
104164b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl
1042ba13543329afac4a0d01304ec2ec4924d99306a6John McCall/// \brief A reference to a name which we were able to look up during
1043ba13543329afac4a0d01304ec2ec4924d99306a6John McCall/// parsing but could not resolve to a specific declaration.  This
1044ba13543329afac4a0d01304ec2ec4924d99306a6John McCall/// arises in several ways:
1045ba13543329afac4a0d01304ec2ec4924d99306a6John McCall///   * we might be waiting for argument-dependent lookup
1046ba13543329afac4a0d01304ec2ec4924d99306a6John McCall///   * the name might resolve to an overloaded function
1047ba13543329afac4a0d01304ec2ec4924d99306a6John McCall/// and eventually:
1048ba13543329afac4a0d01304ec2ec4924d99306a6John McCall///   * the lookup might have included a function template
1049ba13543329afac4a0d01304ec2ec4924d99306a6John McCall/// These never include UnresolvedUsingValueDecls, which are always
1050ba13543329afac4a0d01304ec2ec4924d99306a6John McCall/// class members and therefore appear only in
1051ba13543329afac4a0d01304ec2ec4924d99306a6John McCall/// UnresolvedMemberLookupExprs.
1052ba13543329afac4a0d01304ec2ec4924d99306a6John McCallclass UnresolvedLookupExpr : public Expr {
1053ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  /// The results.  These are undesugared, which is to say, they may
1054ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  /// include UsingShadowDecls.
1055ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  UnresolvedSet Results;
1056ba13543329afac4a0d01304ec2ec4924d99306a6John McCall
1057ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  /// The name declared.
1058ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  DeclarationName Name;
1059ba13543329afac4a0d01304ec2ec4924d99306a6John McCall
1060ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  /// The qualifier given, if any.
1061ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  NestedNameSpecifier *Qualifier;
1062ba13543329afac4a0d01304ec2ec4924d99306a6John McCall
1063ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  /// The source range of the nested name specifier.
1064ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  SourceRange QualifierRange;
1065ba13543329afac4a0d01304ec2ec4924d99306a6John McCall
1066ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  /// The location of the name.
1067ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  SourceLocation NameLoc;
1068ba13543329afac4a0d01304ec2ec4924d99306a6John McCall
1069ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  /// True if these lookup results should be extended by
1070ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  /// argument-dependent lookup if this is the operand of a function
1071ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  /// call.
1072ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  bool RequiresADL;
1073ba13543329afac4a0d01304ec2ec4924d99306a6John McCall
10747453ed4cb2cab113de3378df371b1c6f1243d832John McCall  /// True if these lookup results are overloaded.  This is pretty
10757453ed4cb2cab113de3378df371b1c6f1243d832John McCall  /// trivially rederivable if we urgently need to kill this field.
10767453ed4cb2cab113de3378df371b1c6f1243d832John McCall  bool Overloaded;
10777453ed4cb2cab113de3378df371b1c6f1243d832John McCall
1078f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  /// True if the name looked up had explicit template arguments.
1079f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  /// This requires all the results to be function templates.
1080f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  bool HasExplicitTemplateArgs;
1081f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall
1082f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  UnresolvedLookupExpr(QualType T, bool Dependent,
1083ba13543329afac4a0d01304ec2ec4924d99306a6John McCall                       NestedNameSpecifier *Qualifier, SourceRange QRange,
1084ba13543329afac4a0d01304ec2ec4924d99306a6John McCall                       DeclarationName Name, SourceLocation NameLoc,
1085f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall                       bool RequiresADL, bool Overloaded, bool HasTemplateArgs)
1086f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall    : Expr(UnresolvedLookupExprClass, T, Dependent, Dependent),
1087ba13543329afac4a0d01304ec2ec4924d99306a6John McCall      Name(Name), Qualifier(Qualifier), QualifierRange(QRange),
1088f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall      NameLoc(NameLoc), RequiresADL(RequiresADL), Overloaded(Overloaded),
1089f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall      HasExplicitTemplateArgs(HasTemplateArgs)
1090ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  {}
1091ba13543329afac4a0d01304ec2ec4924d99306a6John McCall
1092ba13543329afac4a0d01304ec2ec4924d99306a6John McCallpublic:
1093ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  static UnresolvedLookupExpr *Create(ASTContext &C,
1094f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall                                      bool Dependent,
1095ba13543329afac4a0d01304ec2ec4924d99306a6John McCall                                      NestedNameSpecifier *Qualifier,
1096ba13543329afac4a0d01304ec2ec4924d99306a6John McCall                                      SourceRange QualifierRange,
1097ba13543329afac4a0d01304ec2ec4924d99306a6John McCall                                      DeclarationName Name,
1098ba13543329afac4a0d01304ec2ec4924d99306a6John McCall                                      SourceLocation NameLoc,
10997453ed4cb2cab113de3378df371b1c6f1243d832John McCall                                      bool ADL, bool Overloaded) {
1100f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall    return new(C) UnresolvedLookupExpr(Dependent ? C.DependentTy : C.OverloadTy,
1101f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall                                       Dependent, Qualifier, QualifierRange,
1102f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall                                       Name, NameLoc, ADL, Overloaded, false);
1103ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  }
1104ba13543329afac4a0d01304ec2ec4924d99306a6John McCall
1105f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  static UnresolvedLookupExpr *Create(ASTContext &C,
1106f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall                                      bool Dependent,
1107f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall                                      NestedNameSpecifier *Qualifier,
1108f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall                                      SourceRange QualifierRange,
1109f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall                                      DeclarationName Name,
1110f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall                                      SourceLocation NameLoc,
1111f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall                                      bool ADL,
1112f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall                                      const TemplateArgumentListInfo &Args);
1113f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall
1114f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  /// Computes whether an unresolved lookup on the given declarations
1115f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  /// and optional template arguments is type- and value-dependent.
1116f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  static bool ComputeDependence(NamedDecl * const *Begin,
1117f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall                                NamedDecl * const *End,
1118f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall                                const TemplateArgumentListInfo *Args);
1119f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall
1120ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  void addDecl(NamedDecl *Decl) {
1121ba13543329afac4a0d01304ec2ec4924d99306a6John McCall    Results.addDecl(Decl);
1122ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  }
1123ba13543329afac4a0d01304ec2ec4924d99306a6John McCall
1124ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  typedef UnresolvedSet::iterator decls_iterator;
1125ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  decls_iterator decls_begin() const { return Results.begin(); }
1126ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  decls_iterator decls_end() const { return Results.end(); }
1127ba13543329afac4a0d01304ec2ec4924d99306a6John McCall
1128ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  /// True if this declaration should be extended by
1129ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  /// argument-dependent lookup.
1130ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  bool requiresADL() const { return RequiresADL; }
1131ba13543329afac4a0d01304ec2ec4924d99306a6John McCall
11327453ed4cb2cab113de3378df371b1c6f1243d832John McCall  /// True if this lookup is overloaded.
11337453ed4cb2cab113de3378df371b1c6f1243d832John McCall  bool isOverloaded() const { return Overloaded; }
11347453ed4cb2cab113de3378df371b1c6f1243d832John McCall
1135ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  /// Fetches the name looked up.
1136ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  DeclarationName getName() const { return Name; }
1137ba13543329afac4a0d01304ec2ec4924d99306a6John McCall
1138ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  /// Gets the location of the name.
1139ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  SourceLocation getNameLoc() const { return NameLoc; }
1140ba13543329afac4a0d01304ec2ec4924d99306a6John McCall
1141ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  /// Fetches the nested-name qualifier, if one was given.
1142ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  NestedNameSpecifier *getQualifier() const { return Qualifier; }
1143ba13543329afac4a0d01304ec2ec4924d99306a6John McCall
1144ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  /// Fetches the range of the nested-name qualifier.
1145ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  SourceRange getQualifierRange() const { return QualifierRange; }
1146f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall
1147f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  /// Determines whether this lookup had explicit template arguments.
1148f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  bool hasExplicitTemplateArgs() const { return HasExplicitTemplateArgs; }
1149f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall
1150f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  // Note that, inconsistently with the explicit-template-argument AST
1151f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  // nodes, users are *forbidden* from calling these methods on objects
1152f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  // without explicit template arguments.
1153f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall
1154f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  /// Gets a reference to the explicit template argument list.
1155f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  const ExplicitTemplateArgumentList &getExplicitTemplateArgs() const {
1156f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall    assert(hasExplicitTemplateArgs());
1157f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall    return *reinterpret_cast<const ExplicitTemplateArgumentList*>(this + 1);
1158f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  }
1159f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall
1160f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  /// \brief Copies the template arguments (if present) into the given
1161f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  /// structure.
1162f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  void copyTemplateArgumentsInto(TemplateArgumentListInfo &List) const {
1163f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall    getExplicitTemplateArgs().copyInto(List);
1164f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  }
1165ba13543329afac4a0d01304ec2ec4924d99306a6John McCall
1166f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  SourceLocation getLAngleLoc() const {
1167f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall    return getExplicitTemplateArgs().LAngleLoc;
1168f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  }
1169f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall
1170f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  SourceLocation getRAngleLoc() const {
1171f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall    return getExplicitTemplateArgs().RAngleLoc;
1172f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  }
1173f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall
1174f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  TemplateArgumentLoc const *getTemplateArgs() const {
1175f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall    return getExplicitTemplateArgs().getTemplateArgs();
1176f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  }
1177f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall
1178f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  unsigned getNumTemplateArgs() const {
1179f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall    return getExplicitTemplateArgs().NumTemplateArgs;
1180f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  }
1181ba13543329afac4a0d01304ec2ec4924d99306a6John McCall
1182ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  virtual SourceRange getSourceRange() const {
1183f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall    SourceRange Range(NameLoc);
1184f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall    if (Qualifier) Range.setBegin(QualifierRange.getBegin());
1185f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall    if (hasExplicitTemplateArgs()) Range.setEnd(getRAngleLoc());
1186f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall    return Range;
1187ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  }
1188ba13543329afac4a0d01304ec2ec4924d99306a6John McCall
1189ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  virtual StmtIterator child_begin();
1190ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  virtual StmtIterator child_end();
1191ba13543329afac4a0d01304ec2ec4924d99306a6John McCall
1192ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  static bool classof(const Stmt *T) {
1193ba13543329afac4a0d01304ec2ec4924d99306a6John McCall    return T->getStmtClass() == UnresolvedLookupExprClass;
1194ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  }
1195ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  static bool classof(const UnresolvedLookupExpr *) { return true; }
1196ba13543329afac4a0d01304ec2ec4924d99306a6John McCall};
1197ba13543329afac4a0d01304ec2ec4924d99306a6John McCall
11985953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor/// \brief A qualified reference to a name whose declaration cannot
11995953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor/// yet be resolved.
12005953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor///
1201ba13543329afac4a0d01304ec2ec4924d99306a6John McCall/// DependentScopeDeclRefExpr is similar to DeclRefExpr in that
1202a2813cec2605ce7878d1b13471d685f689b251afDouglas Gregor/// it expresses a reference to a declaration such as
12035953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor/// X<T>::value. The difference, however, is that an
1204865d447ac6a4721ab58e898d014a21f2eff74b06John McCall/// DependentScopeDeclRefExpr node is used only within C++ templates when
12055953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor/// the qualification (e.g., X<T>::) refers to a dependent type. In
12065953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor/// this case, X<T>::value cannot resolve to a declaration because the
12075953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor/// declaration will differ from on instantiation of X<T> to the
1208865d447ac6a4721ab58e898d014a21f2eff74b06John McCall/// next. Therefore, DependentScopeDeclRefExpr keeps track of the
1209ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor/// qualifier (X<T>::) and the name of the entity being referenced
1210a2813cec2605ce7878d1b13471d685f689b251afDouglas Gregor/// ("value"). Such expressions will instantiate to a DeclRefExpr once the
1211a2813cec2605ce7878d1b13471d685f689b251afDouglas Gregor/// declaration can be found.
1212865d447ac6a4721ab58e898d014a21f2eff74b06John McCallclass DependentScopeDeclRefExpr : public Expr {
12135953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor  /// The name of the entity we will be referencing.
12145953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor  DeclarationName Name;
12155953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor
12165953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor  /// Location of the name of the declaration we're referencing.
12175953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor  SourceLocation Loc;
12185953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor
12195953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor  /// QualifierRange - The source range that covers the
12205953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor  /// nested-name-specifier.
12215953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor  SourceRange QualifierRange;
12225953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor
1223ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor  /// \brief The nested-name-specifier that qualifies this unresolved
1224ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor  /// declaration name.
1225f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  NestedNameSpecifier *Qualifier;
12265953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor
1227f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  /// \brief Whether the name includes explicit template arguments.
1228f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  bool HasExplicitTemplateArgs;
12291eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1230f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  DependentScopeDeclRefExpr(QualType T,
1231f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall                            NestedNameSpecifier *Qualifier,
1232f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall                            SourceRange QualifierRange,
1233f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall                            DeclarationName Name,
1234f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall                            SourceLocation NameLoc,
1235f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall                            bool HasExplicitTemplateArgs)
1236865d447ac6a4721ab58e898d014a21f2eff74b06John McCall    : Expr(DependentScopeDeclRefExprClass, T, true, true),
1237f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall      Name(Name), Loc(NameLoc),
1238f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall      QualifierRange(QualifierRange), Qualifier(Qualifier),
1239f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall      HasExplicitTemplateArgs(HasExplicitTemplateArgs)
1240f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  {}
1241f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall
1242f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCallpublic:
1243f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  static DependentScopeDeclRefExpr *Create(ASTContext &C,
1244f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall                                           NestedNameSpecifier *Qualifier,
1245f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall                                           SourceRange QualifierRange,
1246f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall                                           DeclarationName Name,
1247f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall                                           SourceLocation NameLoc,
1248f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall                              const TemplateArgumentListInfo *TemplateArgs = 0);
12495953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor
12505953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor  /// \brief Retrieve the name that this expression refers to.
12515953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor  DeclarationName getDeclName() const { return Name; }
12525953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor
12535953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor  /// \brief Retrieve the location of the name within the expression.
12545953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor  SourceLocation getLocation() const { return Loc; }
12555953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor
12565953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor  /// \brief Retrieve the source range of the nested-name-specifier.
12575953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor  SourceRange getQualifierRange() const { return QualifierRange; }
12585953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor
1259ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor  /// \brief Retrieve the nested-name-specifier that qualifies this
1260ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor  /// declaration.
1261edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor  NestedNameSpecifier *getQualifier() const { return Qualifier; }
12621eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1263f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  /// Determines whether this lookup had explicit template arguments.
1264f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  bool hasExplicitTemplateArgs() const { return HasExplicitTemplateArgs; }
12651eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1266f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  // Note that, inconsistently with the explicit-template-argument AST
1267f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  // nodes, users are *forbidden* from calling these methods on objects
1268f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  // without explicit template arguments.
12691eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1270f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  /// Gets a reference to the explicit template argument list.
1271f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  const ExplicitTemplateArgumentList &getExplicitTemplateArgs() const {
1272f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall    assert(hasExplicitTemplateArgs());
1273f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall    return *reinterpret_cast<const ExplicitTemplateArgumentList*>(this + 1);
1274f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  }
12751eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1276f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  /// \brief Copies the template arguments (if present) into the given
1277f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  /// structure.
1278f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  void copyTemplateArgumentsInto(TemplateArgumentListInfo &List) const {
1279f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall    getExplicitTemplateArgs().copyInto(List);
1280f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  }
1281f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall
1282f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  SourceLocation getLAngleLoc() const {
1283f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall    return getExplicitTemplateArgs().LAngleLoc;
1284edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor  }
12851eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1286f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  SourceLocation getRAngleLoc() const {
1287f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall    return getExplicitTemplateArgs().RAngleLoc;
1288f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  }
12891eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1290f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  TemplateArgumentLoc const *getTemplateArgs() const {
1291f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall    return getExplicitTemplateArgs().getTemplateArgs();
1292d5532b6cfff2977e0c59fa6ead7f7973984a620dJohn McCall  }
1293d5532b6cfff2977e0c59fa6ead7f7973984a620dJohn McCall
1294f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  unsigned getNumTemplateArgs() const {
1295f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall    return getExplicitTemplateArgs().NumTemplateArgs;
1296f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  }
12971eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1298edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor  virtual SourceRange getSourceRange() const {
1299f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall    SourceRange Range(QualifierRange.getBegin(), getLocation());
1300f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall    if (hasExplicitTemplateArgs())
1301f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall      Range.setEnd(getRAngleLoc());
1302f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall    return Range;
1303edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor  }
13041eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
13051eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  static bool classof(const Stmt *T) {
1306f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall    return T->getStmtClass() == DependentScopeDeclRefExprClass;
1307edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor  }
1308f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  static bool classof(const DependentScopeDeclRefExpr *) { return true; }
1309f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall
1310f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  virtual StmtIterator child_begin();
1311f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  virtual StmtIterator child_end();
1312edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor};
13131eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
13142d44e8a41de8a33c0f04ac198714f71dc841bab0Anders Carlssonclass CXXExprWithTemporaries : public Expr {
131502bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson  Stmt *SubExpr;
13161eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1317ff6b3d64c9f07155f1414411b8451d7bf8937c62Anders Carlsson  CXXTemporary **Temps;
1318ff6b3d64c9f07155f1414411b8451d7bf8937c62Anders Carlsson  unsigned NumTemps;
131902bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson
13201eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  CXXExprWithTemporaries(Expr *SubExpr, CXXTemporary **Temps,
13210ece491d8f62ce67f047491a6703fac0d3bd4ff4Anders Carlsson                         unsigned NumTemps);
13222d44e8a41de8a33c0f04ac198714f71dc841bab0Anders Carlsson  ~CXXExprWithTemporaries();
132342602bb40aefcc2751d4078ba88aacf4d965c9bdDouglas Gregor
132442602bb40aefcc2751d4078ba88aacf4d965c9bdDouglas Gregorprotected:
132542602bb40aefcc2751d4078ba88aacf4d965c9bdDouglas Gregor  virtual void DoDestroy(ASTContext &C);
132642602bb40aefcc2751d4078ba88aacf4d965c9bdDouglas Gregor
132788eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlssonpublic:
132888eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlsson  static CXXExprWithTemporaries *Create(ASTContext &C, Expr *SubExpr,
13290ece491d8f62ce67f047491a6703fac0d3bd4ff4Anders Carlsson                                        CXXTemporary **Temps,
13300ece491d8f62ce67f047491a6703fac0d3bd4ff4Anders Carlsson                                        unsigned NumTemps);
13311eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
133288eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlsson  unsigned getNumTemporaries() const { return NumTemps; }
133388eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlsson  CXXTemporary *getTemporary(unsigned i) {
133488eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlsson    assert(i < NumTemps && "Index out of range");
133588eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlsson    return Temps[i];
133688eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlsson  }
1337f0721fe438d7e40c168e5d664970e7830bc138fbAnders Carlsson  const CXXTemporary *getTemporary(unsigned i) const {
13380ece491d8f62ce67f047491a6703fac0d3bd4ff4Anders Carlsson    return const_cast<CXXExprWithTemporaries*>(this)->getTemporary(i);
1339f0721fe438d7e40c168e5d664970e7830bc138fbAnders Carlsson  }
13401eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
134102bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson  Expr *getSubExpr() { return cast<Expr>(SubExpr); }
1342f0721fe438d7e40c168e5d664970e7830bc138fbAnders Carlsson  const Expr *getSubExpr() const { return cast<Expr>(SubExpr); }
134388eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlsson  void setSubExpr(Expr *E) { SubExpr = E; }
134402bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson
134596be6917e1c4ba1f4435a14c9e7c6c139571d086Douglas Gregor  virtual SourceRange getSourceRange() const {
134696be6917e1c4ba1f4435a14c9e7c6c139571d086Douglas Gregor    return SubExpr->getSourceRange();
134796be6917e1c4ba1f4435a14c9e7c6c139571d086Douglas Gregor  }
134802bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson
134902bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson  // Implement isa/cast/dyncast/etc.
135002bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson  static bool classof(const Stmt *T) {
13512d44e8a41de8a33c0f04ac198714f71dc841bab0Anders Carlsson    return T->getStmtClass() == CXXExprWithTemporariesClass;
135202bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson  }
13532d44e8a41de8a33c0f04ac198714f71dc841bab0Anders Carlsson  static bool classof(const CXXExprWithTemporaries *) { return true; }
135402bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson
135502bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson  // Iterators
135602bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson  virtual child_iterator child_begin();
135702bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson  virtual child_iterator child_end();
135802bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson};
135902bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson
1360d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// \brief Describes an explicit type conversion that uses functional
1361d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// notion but could not be resolved because one or more arguments are
1362d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// type-dependent.
1363d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor///
1364d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// The explicit type conversions expressed by
1365d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// CXXUnresolvedConstructExpr have the form \c T(a1, a2, ..., aN),
1366d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// where \c T is some type and \c a1, a2, ..., aN are values, and
1367d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// either \C T is a dependent type or one or more of the \c a's is
1368d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// type-dependent. For example, this would occur in a template such
1369d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// as:
1370d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor///
1371d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// \code
1372d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor///   template<typename T, typename A1>
1373d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor///   inline T make_a(const A1& a1) {
1374d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor///     return T(a1);
1375d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor///   }
1376d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// \endcode
1377d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor///
1378d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// When the returned expression is instantiated, it may resolve to a
1379d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// constructor call, conversion function call, or some kind of type
1380d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// conversion.
1381d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregorclass CXXUnresolvedConstructExpr : public Expr {
1382d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  /// \brief The starting location of the type
1383d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  SourceLocation TyBeginLoc;
1384d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor
1385d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  /// \brief The type being constructed.
1386d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  QualType Type;
1387d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor
1388d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  /// \brief The location of the left parentheses ('(').
1389d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  SourceLocation LParenLoc;
1390d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor
1391d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  /// \brief The location of the right parentheses (')').
1392d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  SourceLocation RParenLoc;
1393d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor
1394d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  /// \brief The number of arguments used to construct the type.
1395d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  unsigned NumArgs;
13961eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1397d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  CXXUnresolvedConstructExpr(SourceLocation TyBegin,
1398d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor                             QualType T,
1399d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor                             SourceLocation LParenLoc,
1400d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor                             Expr **Args,
1401d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor                             unsigned NumArgs,
1402d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor                             SourceLocation RParenLoc);
1403d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor
1404d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregorpublic:
14051eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  static CXXUnresolvedConstructExpr *Create(ASTContext &C,
1406d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor                                            SourceLocation TyBegin,
1407d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor                                            QualType T,
1408d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor                                            SourceLocation LParenLoc,
1409d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor                                            Expr **Args,
1410d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor                                            unsigned NumArgs,
1411d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor                                            SourceLocation RParenLoc);
1412d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor
1413d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  /// \brief Retrieve the source location where the type begins.
1414d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  SourceLocation getTypeBeginLoc() const { return TyBeginLoc; }
1415d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  void setTypeBeginLoc(SourceLocation L) { TyBeginLoc = L; }
1416d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor
1417d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  /// \brief Retrieve the type that is being constructed, as specified
1418d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  /// in the source code.
1419d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  QualType getTypeAsWritten() const { return Type; }
1420d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  void setTypeAsWritten(QualType T) { Type = T; }
1421d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor
1422d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  /// \brief Retrieve the location of the left parentheses ('(') that
1423d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  /// precedes the argument list.
1424d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  SourceLocation getLParenLoc() const { return LParenLoc; }
1425d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  void setLParenLoc(SourceLocation L) { LParenLoc = L; }
1426d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor
1427d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  /// \brief Retrieve the location of the right parentheses (')') that
1428d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  /// follows the argument list.
1429d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  SourceLocation getRParenLoc() const { return RParenLoc; }
1430d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  void setRParenLoc(SourceLocation L) { RParenLoc = L; }
1431d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor
1432d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  /// \brief Retrieve the number of arguments.
1433d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  unsigned arg_size() const { return NumArgs; }
1434d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor
1435d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  typedef Expr** arg_iterator;
1436d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  arg_iterator arg_begin() { return reinterpret_cast<Expr**>(this + 1); }
1437d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  arg_iterator arg_end() { return arg_begin() + NumArgs; }
1438d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor
1439d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  Expr *getArg(unsigned I) {
1440d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor    assert(I < NumArgs && "Argument index out-of-range");
1441d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor    return *(arg_begin() + I);
1442d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  }
1443d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor
1444d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  virtual SourceRange getSourceRange() const {
1445d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor    return SourceRange(TyBeginLoc, RParenLoc);
1446d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  }
14471eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  static bool classof(const Stmt *T) {
1448d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor    return T->getStmtClass() == CXXUnresolvedConstructExprClass;
1449d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  }
1450d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  static bool classof(const CXXUnresolvedConstructExpr *) { return true; }
1451d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor
1452d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  // Iterators
1453d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  virtual child_iterator child_begin();
1454d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  virtual child_iterator child_end();
1455d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor};
1456d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor
1457ba13543329afac4a0d01304ec2ec4924d99306a6John McCall/// \brief Represents a C++ member access expression where the actual
1458ba13543329afac4a0d01304ec2ec4924d99306a6John McCall/// member referenced could not be resolved because the base
1459ba13543329afac4a0d01304ec2ec4924d99306a6John McCall/// expression or the member name was dependent.
1460aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall///
1461aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall/// Like UnresolvedMemberExprs, these can be either implicit or
1462aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall/// explicit accesses.  It is only possible to get one of these with
1463aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall/// an implicit access if a qualifier is provided.
1464865d447ac6a4721ab58e898d014a21f2eff74b06John McCallclass CXXDependentScopeMemberExpr : public Expr {
14651c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  /// \brief The expression for the base pointer or class reference,
1466aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall  /// e.g., the \c x in x.f.  Can be null in implicit accesses.
14671c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  Stmt *Base;
14681eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1469aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall  /// \brief The type of the base expression.  Never null, even for
1470aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall  /// implicit accesses.
1471aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall  QualType BaseType;
1472aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall
14731c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  /// \brief Whether this member expression used the '->' operator or
14741c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  /// the '.' operator.
14753b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor  bool IsArrow : 1;
14761c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor
14773b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor  /// \brief Whether this member expression has explicitly-specified template
14783b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor  /// arguments.
1479aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall  bool HasExplicitTemplateArgs : 1;
14801eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
14811c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  /// \brief The location of the '->' or '.' operator.
14821c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  SourceLocation OperatorLoc;
14831c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor
1484a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor  /// \brief The nested-name-specifier that precedes the member name, if any.
1485a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor  NestedNameSpecifier *Qualifier;
14861eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1487a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor  /// \brief The source range covering the nested name specifier.
1488a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor  SourceRange QualifierRange;
14891eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1490c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor  /// \brief In a qualified member access expression such as t->Base::f, this
14911eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  /// member stores the resolves of name lookup in the context of the member
1492c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor  /// access expression, to be used at instantiation time.
1493c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor  ///
1494c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor  /// FIXME: This member, along with the Qualifier and QualifierRange, could
1495c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor  /// be stuck into a structure that is optionally allocated at the end of
1496865d447ac6a4721ab58e898d014a21f2eff74b06John McCall  /// the CXXDependentScopeMemberExpr, to save space in the common case.
1497c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor  NamedDecl *FirstQualifierFoundInScope;
14981eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
14991c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  /// \brief The member to which this member expression refers, which
15001c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  /// can be name, overloaded operator, or destructor.
1501a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor  /// FIXME: could also be a template-id
15021c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  DeclarationName Member;
15031c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor
15041c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  /// \brief The location of the member name.
15051c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  SourceLocation MemberLoc;
15061eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
15073b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor  /// \brief Retrieve the explicit template argument list that followed the
15083b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor  /// member template name, if any.
15093b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor  ExplicitTemplateArgumentList *getExplicitTemplateArgumentList() {
1510aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall    assert(HasExplicitTemplateArgs);
15113b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor    return reinterpret_cast<ExplicitTemplateArgumentList *>(this + 1);
15123b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor  }
15131eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
15143b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor  /// \brief Retrieve the explicit template argument list that followed the
15153b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor  /// member template name, if any.
15163b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor  const ExplicitTemplateArgumentList *getExplicitTemplateArgumentList() const {
1517865d447ac6a4721ab58e898d014a21f2eff74b06John McCall    return const_cast<CXXDependentScopeMemberExpr *>(this)
15183b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor             ->getExplicitTemplateArgumentList();
15193b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor  }
15201eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1521865d447ac6a4721ab58e898d014a21f2eff74b06John McCall  CXXDependentScopeMemberExpr(ASTContext &C,
1522aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall                          Expr *Base, QualType BaseType, bool IsArrow,
15233b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor                          SourceLocation OperatorLoc,
15243b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor                          NestedNameSpecifier *Qualifier,
15253b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor                          SourceRange QualifierRange,
15263b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor                          NamedDecl *FirstQualifierFoundInScope,
15273b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor                          DeclarationName Member,
15283b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor                          SourceLocation MemberLoc,
1529d5532b6cfff2977e0c59fa6ead7f7973984a620dJohn McCall                          const TemplateArgumentListInfo *TemplateArgs);
15301eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
15311c0ca59416999129d0439c2661d137ef38e86209Douglas Gregorpublic:
1532865d447ac6a4721ab58e898d014a21f2eff74b06John McCall  CXXDependentScopeMemberExpr(ASTContext &C,
1533aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall                          Expr *Base, QualType BaseType,
1534aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall                          bool IsArrow,
15351c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor                          SourceLocation OperatorLoc,
1536a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor                          NestedNameSpecifier *Qualifier,
1537a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor                          SourceRange QualifierRange,
1538c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor                          NamedDecl *FirstQualifierFoundInScope,
15391c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor                          DeclarationName Member,
15401c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor                          SourceLocation MemberLoc)
1541865d447ac6a4721ab58e898d014a21f2eff74b06John McCall  : Expr(CXXDependentScopeMemberExprClass, C.DependentTy, true, true),
1542aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall    Base(Base), BaseType(BaseType), IsArrow(IsArrow),
1543aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall    HasExplicitTemplateArgs(false), OperatorLoc(OperatorLoc),
15443b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor    Qualifier(Qualifier), QualifierRange(QualifierRange),
15453b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor    FirstQualifierFoundInScope(FirstQualifierFoundInScope),
15463b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor    Member(Member), MemberLoc(MemberLoc) { }
15471eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1548865d447ac6a4721ab58e898d014a21f2eff74b06John McCall  static CXXDependentScopeMemberExpr *
15491eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  Create(ASTContext &C,
1550aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall         Expr *Base, QualType BaseType, bool IsArrow,
15513b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor         SourceLocation OperatorLoc,
15523b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor         NestedNameSpecifier *Qualifier,
15533b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor         SourceRange QualifierRange,
15543b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor         NamedDecl *FirstQualifierFoundInScope,
15553b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor         DeclarationName Member,
15563b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor         SourceLocation MemberLoc,
1557d5532b6cfff2977e0c59fa6ead7f7973984a620dJohn McCall         const TemplateArgumentListInfo *TemplateArgs);
15581eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1559aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall  /// \brief True if this is an implicit access, i.e. one in which the
1560aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall  /// member being accessed was not written in the source.  The source
1561aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall  /// location of the operator is invalid in this case.
1562aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall  bool isImplicitAccess() const { return Base == 0; }
1563aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall
15641c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  /// \brief Retrieve the base object of this member expressions,
15651c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  /// e.g., the \c x in \c x.m.
1566aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall  Expr *getBase() const {
1567aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall    assert(!isImplicitAccess());
1568aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall    return cast<Expr>(Base);
1569aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall  }
15701c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  void setBase(Expr *E) { Base = E; }
15711c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor
1572aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall  QualType getBaseType() const { return BaseType; }
1573aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall
15741c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  /// \brief Determine whether this member expression used the '->'
15751c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  /// operator; otherwise, it used the '.' operator.
15761c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  bool isArrow() const { return IsArrow; }
15771c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  void setArrow(bool A) { IsArrow = A; }
15781c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor
15791c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  /// \brief Retrieve the location of the '->' or '.' operator.
15801c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  SourceLocation getOperatorLoc() const { return OperatorLoc; }
15811c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  void setOperatorLoc(SourceLocation L) { OperatorLoc = L; }
15821c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor
1583a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor  /// \brief Retrieve the nested-name-specifier that qualifies the member
1584a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor  /// name.
1585a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor  NestedNameSpecifier *getQualifier() const { return Qualifier; }
15861eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1587a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor  /// \brief Retrieve the source range covering the nested-name-specifier
1588a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor  /// that qualifies the member name.
1589a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor  SourceRange getQualifierRange() const { return QualifierRange; }
15901eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1591c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor  /// \brief Retrieve the first part of the nested-name-specifier that was
1592c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor  /// found in the scope of the member access expression when the member access
1593c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor  /// was initially parsed.
1594c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor  ///
1595c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor  /// This function only returns a useful result when member access expression
15961eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  /// uses a qualified member name, e.g., "x.Base::f". Here, the declaration
15971eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  /// returned by this function describes what was found by unqualified name
1598c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor  /// lookup for the identifier "Base" within the scope of the member access
1599c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor  /// expression itself. At template instantiation time, this information is
1600c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor  /// combined with the results of name lookup into the type of the object
1601c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor  /// expression itself (the class type of x).
16021eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  NamedDecl *getFirstQualifierFoundInScope() const {
1603c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor    return FirstQualifierFoundInScope;
1604c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor  }
16051eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
16061c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  /// \brief Retrieve the name of the member that this expression
16071c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  /// refers to.
16081c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  DeclarationName getMember() const { return Member; }
16091c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  void setMember(DeclarationName N) { Member = N; }
16101c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor
16111c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  // \brief Retrieve the location of the name of the member that this
16121c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  // expression refers to.
16131c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  SourceLocation getMemberLoc() const { return MemberLoc; }
16141c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  void setMemberLoc(SourceLocation L) { MemberLoc = L; }
16151c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor
16163b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor  /// \brief Determines whether this member expression actually had a C++
16173b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor  /// template argument list explicitly specified, e.g., x.f<int>.
1618aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall  bool hasExplicitTemplateArgs() const {
1619aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall    return HasExplicitTemplateArgs;
16203b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor  }
16211eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1622d5532b6cfff2977e0c59fa6ead7f7973984a620dJohn McCall  /// \brief Copies the template arguments (if present) into the given
1623d5532b6cfff2977e0c59fa6ead7f7973984a620dJohn McCall  /// structure.
1624d5532b6cfff2977e0c59fa6ead7f7973984a620dJohn McCall  void copyTemplateArgumentsInto(TemplateArgumentListInfo &List) const {
1625aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall    assert(HasExplicitTemplateArgs);
1626aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall    getExplicitTemplateArgumentList()->copyInto(List);
1627d5532b6cfff2977e0c59fa6ead7f7973984a620dJohn McCall  }
1628d5532b6cfff2977e0c59fa6ead7f7973984a620dJohn McCall
16291eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  /// \brief Retrieve the location of the left angle bracket following the
16303b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor  /// member name ('<'), if any.
16311eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  SourceLocation getLAngleLoc() const {
1632aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall    assert(HasExplicitTemplateArgs);
16333b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor    return getExplicitTemplateArgumentList()->LAngleLoc;
16343b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor  }
16351eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
16363b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor  /// \brief Retrieve the template arguments provided as part of this
16373b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor  /// template-id.
1638833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall  const TemplateArgumentLoc *getTemplateArgs() const {
1639aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall    assert(HasExplicitTemplateArgs);
16403b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor    return getExplicitTemplateArgumentList()->getTemplateArgs();
16413b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor  }
16421eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
16433b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor  /// \brief Retrieve the number of template arguments provided as part of this
16443b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor  /// template-id.
16451eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  unsigned getNumTemplateArgs() const {
1646aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall    assert(HasExplicitTemplateArgs);
16473b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor    return getExplicitTemplateArgumentList()->NumTemplateArgs;
16483b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor  }
16491eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
16501eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  /// \brief Retrieve the location of the right angle bracket following the
16513b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor  /// template arguments ('>').
16521eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  SourceLocation getRAngleLoc() const {
1653aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall    assert(HasExplicitTemplateArgs);
16543b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor    return getExplicitTemplateArgumentList()->RAngleLoc;
16553b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor  }
16561eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
16571c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  virtual SourceRange getSourceRange() const {
1658aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall    SourceRange Range;
1659aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall    if (!isImplicitAccess())
1660aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall      Range.setBegin(Base->getSourceRange().getBegin());
1661aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall    else if (getQualifier())
1662aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall      Range.setBegin(getQualifierRange().getBegin());
1663aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall    else
1664aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall      Range.setBegin(MemberLoc);
16651eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1666aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall    if (hasExplicitTemplateArgs())
1667aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall      Range.setEnd(getRAngleLoc());
1668aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall    else
1669aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall      Range.setEnd(MemberLoc);
1670aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall    return Range;
16711c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  }
16721eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
16731eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  static bool classof(const Stmt *T) {
1674865d447ac6a4721ab58e898d014a21f2eff74b06John McCall    return T->getStmtClass() == CXXDependentScopeMemberExprClass;
16751c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  }
1676865d447ac6a4721ab58e898d014a21f2eff74b06John McCall  static bool classof(const CXXDependentScopeMemberExpr *) { return true; }
16771c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor
16781c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  // Iterators
16791c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  virtual child_iterator child_begin();
16801c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  virtual child_iterator child_end();
16811c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor};
16821c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor
1683129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall/// \brief Represents a C++ member access expression for which lookup
1684aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall/// produced a set of overloaded functions.
1685aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall///
1686aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall/// The member access may be explicit or implicit:
1687aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall///    struct A {
1688aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall///      int a, b;
1689aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall///      int explicitAccess() { return this->a + this->A::b; }
1690aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall///      int implicitAccess() { return a + A::b; }
1691aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall///    };
1692aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall///
1693aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall/// In the final AST, an explicit access always becomes a MemberExpr.
1694aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall/// An implicit access may become either a MemberExpr or a
1695aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall/// DeclRefExpr, depending on whether the member is static.
1696129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCallclass UnresolvedMemberExpr : public Expr {
1697129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// The results.  These are undesugared, which is to say, they may
1698129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// include UsingShadowDecls.
1699129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  UnresolvedSet Results;
1700129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall
1701129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// \brief The expression for the base pointer or class reference,
1702aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall  /// e.g., the \c x in x.f.  This can be null if this is an 'unbased'
1703aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall  /// member expression
1704129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  Stmt *Base;
1705129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall
1706aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall  /// \brief The type of the base expression;  never null.
1707aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall  QualType BaseType;
1708aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall
1709129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// \brief Whether this member expression used the '->' operator or
1710129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// the '.' operator.
1711129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  bool IsArrow : 1;
1712129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall
1713129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// \brief Whether the lookup results contain an unresolved using
1714129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// declaration.
1715129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  bool HasUnresolvedUsing : 1;
1716129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall
1717129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// \brief Whether this member expression has explicitly-specified template
1718129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// arguments.
1719129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  bool HasExplicitTemplateArgs : 1;
1720129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall
1721129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// \brief The location of the '->' or '.' operator.
1722129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  SourceLocation OperatorLoc;
1723129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall
1724129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// \brief The nested-name-specifier that precedes the member name, if any.
1725129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  NestedNameSpecifier *Qualifier;
1726129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall
1727129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// \brief The source range covering the nested name specifier.
1728129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  SourceRange QualifierRange;
1729129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall
1730129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// \brief The member to which this member expression refers, which
1731129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// can be a name or an overloaded operator.
1732129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  DeclarationName MemberName;
1733129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall
1734129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// \brief The location of the member name.
1735129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  SourceLocation MemberLoc;
1736129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall
1737129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// \brief Retrieve the explicit template argument list that followed the
1738129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// member template name.
1739129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  ExplicitTemplateArgumentList *getExplicitTemplateArgs() {
1740129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall    assert(HasExplicitTemplateArgs);
1741129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall    return reinterpret_cast<ExplicitTemplateArgumentList *>(this + 1);
1742129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  }
1743129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall
1744129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// \brief Retrieve the explicit template argument list that followed the
1745129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// member template name, if any.
1746129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  const ExplicitTemplateArgumentList *getExplicitTemplateArgs() const {
1747129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall    return const_cast<UnresolvedMemberExpr*>(this)->getExplicitTemplateArgs();
1748129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  }
1749129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall
1750129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  UnresolvedMemberExpr(QualType T, bool Dependent,
1751129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall                       bool HasUnresolvedUsing,
1752aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall                       Expr *Base, QualType BaseType, bool IsArrow,
1753129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall                       SourceLocation OperatorLoc,
1754129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall                       NestedNameSpecifier *Qualifier,
1755129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall                       SourceRange QualifierRange,
1756129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall                       DeclarationName Member,
1757129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall                       SourceLocation MemberLoc,
1758129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall                       const TemplateArgumentListInfo *TemplateArgs);
1759129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall
1760129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCallpublic:
1761129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  static UnresolvedMemberExpr *
1762129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  Create(ASTContext &C, bool Dependent, bool HasUnresolvedUsing,
1763aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall         Expr *Base, QualType BaseType, bool IsArrow,
1764129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall         SourceLocation OperatorLoc,
1765129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall         NestedNameSpecifier *Qualifier,
1766129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall         SourceRange QualifierRange,
1767129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall         DeclarationName Member,
1768129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall         SourceLocation MemberLoc,
1769129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall         const TemplateArgumentListInfo *TemplateArgs);
1770129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall
1771129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// Adds a declaration to the unresolved set.  By assumption, all of
1772129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// these happen at initialization time and properties like
1773129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// 'Dependent' and 'HasUnresolvedUsing' take them into account.
1774129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  void addDecl(NamedDecl *Decl) {
1775129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall    Results.addDecl(Decl);
1776129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  }
1777129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall
1778129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  typedef UnresolvedSet::iterator decls_iterator;
1779129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  decls_iterator decls_begin() const { return Results.begin(); }
1780129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  decls_iterator decls_end() const { return Results.end(); }
1781129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall
1782129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  unsigned getNumDecls() const { return Results.size(); }
1783129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall
1784aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall  /// \brief True if this is an implicit access, i.e. one in which the
1785aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall  /// member being accessed was not written in the source.  The source
1786aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall  /// location of the operator is invalid in this case.
1787aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall  bool isImplicitAccess() const { return Base == 0; }
1788aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall
1789129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// \brief Retrieve the base object of this member expressions,
1790129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// e.g., the \c x in \c x.m.
1791aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall  Expr *getBase() {
1792aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall    assert(!isImplicitAccess());
1793aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall    return cast<Expr>(Base);
1794aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall  }
1795129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  void setBase(Expr *E) { Base = E; }
1796129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall
1797aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall  QualType getBaseType() const { return BaseType; }
1798aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall
1799129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// \brief Determine whether this member expression used the '->'
1800129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// operator; otherwise, it used the '.' operator.
1801129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  bool isArrow() const { return IsArrow; }
1802129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  void setArrow(bool A) { IsArrow = A; }
1803129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall
1804129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// \brief Retrieve the location of the '->' or '.' operator.
1805129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  SourceLocation getOperatorLoc() const { return OperatorLoc; }
1806129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  void setOperatorLoc(SourceLocation L) { OperatorLoc = L; }
1807129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall
1808129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// \brief Retrieve the nested-name-specifier that qualifies the member
1809129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// name.
1810129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  NestedNameSpecifier *getQualifier() const { return Qualifier; }
1811129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall
1812129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// \brief Retrieve the source range covering the nested-name-specifier
1813129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// that qualifies the member name.
1814129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  SourceRange getQualifierRange() const { return QualifierRange; }
1815129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall
1816129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// \brief Retrieve the name of the member that this expression
1817129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// refers to.
1818129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  DeclarationName getMemberName() const { return MemberName; }
1819129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  void setMemberName(DeclarationName N) { MemberName = N; }
1820129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall
1821129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  // \brief Retrieve the location of the name of the member that this
1822129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  // expression refers to.
1823129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  SourceLocation getMemberLoc() const { return MemberLoc; }
1824129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  void setMemberLoc(SourceLocation L) { MemberLoc = L; }
1825129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall
1826129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// \brief Determines whether this member expression actually had a C++
1827129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// template argument list explicitly specified, e.g., x.f<int>.
1828129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  bool hasExplicitTemplateArgs() const {
1829129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall    return HasExplicitTemplateArgs;
1830129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  }
1831129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall
1832129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// \brief Copies the template arguments into the given structure.
1833129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  void copyTemplateArgumentsInto(TemplateArgumentListInfo &List) const {
1834129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall    getExplicitTemplateArgs()->copyInto(List);
1835129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  }
1836129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall
1837129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// \brief Retrieve the location of the left angle bracket following
1838129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// the member name ('<').
1839129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  SourceLocation getLAngleLoc() const {
1840129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall    return getExplicitTemplateArgs()->LAngleLoc;
1841129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  }
1842129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall
1843129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// \brief Retrieve the template arguments provided as part of this
1844129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// template-id.
1845129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  const TemplateArgumentLoc *getTemplateArgs() const {
1846129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall    return getExplicitTemplateArgs()->getTemplateArgs();
1847129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  }
1848129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall
1849129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// \brief Retrieve the number of template arguments provided as
1850129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// part of this template-id.
1851129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  unsigned getNumTemplateArgs() const {
1852129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall    return getExplicitTemplateArgs()->NumTemplateArgs;
1853129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  }
1854129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall
1855129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// \brief Retrieve the location of the right angle bracket
1856129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// following the template arguments ('>').
1857129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  SourceLocation getRAngleLoc() const {
1858129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall    return getExplicitTemplateArgs()->RAngleLoc;
1859129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  }
1860129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall
1861129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  virtual SourceRange getSourceRange() const {
1862aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall    SourceRange Range;
1863aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall    if (!isImplicitAccess())
1864aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall      Range.setBegin(Base->getSourceRange().getBegin());
1865aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall    else if (getQualifier())
1866aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall      Range.setBegin(getQualifierRange().getBegin());
1867aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall    else
1868aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall      Range.setBegin(MemberLoc);
1869aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall
1870129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall    if (hasExplicitTemplateArgs())
1871129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall      Range.setEnd(getRAngleLoc());
1872129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall    else
1873129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall      Range.setEnd(MemberLoc);
1874129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall    return Range;
1875129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  }
1876129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall
1877129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  static bool classof(const Stmt *T) {
1878129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall    return T->getStmtClass() == UnresolvedMemberExprClass;
1879129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  }
1880129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  static bool classof(const UnresolvedMemberExpr *) { return true; }
1881129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall
1882129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  // Iterators
1883129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  virtual child_iterator child_begin();
1884129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  virtual child_iterator child_end();
1885129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall};
1886129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall
18875f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer}  // end namespace clang
18885f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer
18895f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer#endif
1890