ExprCXX.h revision 2f27bf854f0519810b34afd209089cc75536b757
15f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer//===--- ExprCXX.h - Classes for representing expressions -------*- C++ -*-===//
25f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer//
35f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer//                     The LLVM Compiler Infrastructure
45f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer//
50bc735ffcfb223c0186419547abaa5c84482663eChris Lattner// This file is distributed under the University of Illinois Open Source
60bc735ffcfb223c0186419547abaa5c84482663eChris Lattner// License. See LICENSE.TXT for details.
75f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer//
85f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer//===----------------------------------------------------------------------===//
95f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer//
105f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer//  This file defines the Expr interface and subclasses for C++ expressions.
115f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer//
125f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer//===----------------------------------------------------------------------===//
135f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer
145f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer#ifndef LLVM_CLANG_AST_EXPRCXX_H
155f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer#define LLVM_CLANG_AST_EXPRCXX_H
165f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer
1764b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl#include "clang/Basic/TypeTraits.h"
185f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer#include "clang/AST/Expr.h"
19eec51cf1ba5f0e62c9cdb81b5c63babdd6e649abJohn McCall#include "clang/AST/UnresolvedSet.h"
20d5532b6cfff2977e0c59fa6ead7f7973984a620dJohn McCall#include "clang/AST/TemplateBase.h"
215f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer
225f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencernamespace clang {
235f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer
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,
1219d125033a9853f3b572a4c9e2f9e2d4e5e346973John McCall                   TypeSourceInfo *writtenTy, SourceLocation l)
122c0a2fd8f092722c8f78b566ac4506a21437040e9Anders Carlsson    : ExplicitCastExpr(SC, ty, kind, op, writtenTy), Loc(l) {}
12349badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor
124ce757a7a1ee905f87551996a69da3e95e8afeeb7Sam Weinig  explicit CXXNamedCastExpr(StmtClass SC, EmptyShell Shell)
125ce757a7a1ee905f87551996a69da3e95e8afeeb7Sam Weinig    : ExplicitCastExpr(SC, Shell) { }
126ce757a7a1ee905f87551996a69da3e95e8afeeb7Sam Weinig
1271060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenekpublic:
12849badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor  const char *getCastName() const;
12949badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor
130a3a7b8eea87c90a5a257f685749222b212ddaf36Douglas Gregor  /// \brief Retrieve the location of the cast operator keyword, e.g.,
131a3a7b8eea87c90a5a257f685749222b212ddaf36Douglas Gregor  /// "static_cast".
132a3a7b8eea87c90a5a257f685749222b212ddaf36Douglas Gregor  SourceLocation getOperatorLoc() const { return Loc; }
133a3a7b8eea87c90a5a257f685749222b212ddaf36Douglas Gregor  void setOperatorLoc(SourceLocation L) { Loc = L; }
134a3a7b8eea87c90a5a257f685749222b212ddaf36Douglas Gregor
1351060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  virtual SourceRange getSourceRange() const {
1361060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek    return SourceRange(Loc, getSubExpr()->getSourceRange().getEnd());
1371060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  }
1381eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  static bool classof(const Stmt *T) {
13949badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor    switch (T->getStmtClass()) {
14049badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor    case CXXNamedCastExprClass:
14149badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor    case CXXStaticCastExprClass:
14249badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor    case CXXDynamicCastExprClass:
14349badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor    case CXXReinterpretCastExprClass:
14449badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor    case CXXConstCastExprClass:
14549badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor      return true;
14649badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor    default:
14749badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor      return false;
14849badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor    }
1491060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  }
15049badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor  static bool classof(const CXXNamedCastExpr *) { return true; }
15149badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor};
15249badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor
15349badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// CXXStaticCastExpr - A C++ @c static_cast expression (C++ [expr.static.cast]).
1541eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump///
15549badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// This expression node represents a C++ static cast, e.g.,
15649badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// @c static_cast<int>(1.0).
15749badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregorclass CXXStaticCastExpr : public CXXNamedCastExpr {
15849badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregorpublic:
159c0a2fd8f092722c8f78b566ac4506a21437040e9Anders Carlsson  CXXStaticCastExpr(QualType ty, CastKind kind, Expr *op,
1609d125033a9853f3b572a4c9e2f9e2d4e5e346973John McCall                    TypeSourceInfo *writtenTy, SourceLocation l)
161c0a2fd8f092722c8f78b566ac4506a21437040e9Anders Carlsson    : CXXNamedCastExpr(CXXStaticCastExprClass, ty, kind, op, writtenTy, l) {}
16249badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor
163ce757a7a1ee905f87551996a69da3e95e8afeeb7Sam Weinig  explicit CXXStaticCastExpr(EmptyShell Empty)
164ce757a7a1ee905f87551996a69da3e95e8afeeb7Sam Weinig    : CXXNamedCastExpr(CXXStaticCastExprClass, Empty) { }
165ce757a7a1ee905f87551996a69da3e95e8afeeb7Sam Weinig
1661eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  static bool classof(const Stmt *T) {
16749badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor    return T->getStmtClass() == CXXStaticCastExprClass;
16849badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor  }
16949badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor  static bool classof(const CXXStaticCastExpr *) { return true; }
17049badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor};
17149badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor
17249badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// CXXDynamicCastExpr - A C++ @c dynamic_cast expression
1731eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump/// (C++ [expr.dynamic.cast]), which may perform a run-time check to
17449badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// determine how to perform the type cast.
1751eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump///
17649badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// This expression node represents a dynamic cast, e.g.,
17749badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// @c dynamic_cast<Derived*>(BasePtr).
17849badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregorclass CXXDynamicCastExpr : public CXXNamedCastExpr {
17949badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregorpublic:
1809d125033a9853f3b572a4c9e2f9e2d4e5e346973John McCall  CXXDynamicCastExpr(QualType ty, CastKind kind, Expr *op,
1819d125033a9853f3b572a4c9e2f9e2d4e5e346973John McCall                     TypeSourceInfo *writtenTy, SourceLocation l)
182cdef2b75aa60cde1ca00e0aa3f89139ac89c6ae4Anders Carlsson    : CXXNamedCastExpr(CXXDynamicCastExprClass, ty, kind, op, writtenTy, l) {}
18349badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor
184ce757a7a1ee905f87551996a69da3e95e8afeeb7Sam Weinig  explicit CXXDynamicCastExpr(EmptyShell Empty)
185ce757a7a1ee905f87551996a69da3e95e8afeeb7Sam Weinig    : CXXNamedCastExpr(CXXDynamicCastExprClass, Empty) { }
186ce757a7a1ee905f87551996a69da3e95e8afeeb7Sam Weinig
1871eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  static bool classof(const Stmt *T) {
18849badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor    return T->getStmtClass() == CXXDynamicCastExprClass;
18949badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor  }
19049badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor  static bool classof(const CXXDynamicCastExpr *) { return true; }
19149badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor};
19249badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor
19349badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// CXXReinterpretCastExpr - A C++ @c reinterpret_cast expression (C++
19449badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// [expr.reinterpret.cast]), which provides a differently-typed view
19549badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// of a value but performs no actual work at run time.
1961eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump///
19749badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// This expression node represents a reinterpret cast, e.g.,
19849badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// @c reinterpret_cast<int>(VoidPtr).
19949badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregorclass CXXReinterpretCastExpr : public CXXNamedCastExpr {
20049badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregorpublic:
2017f9e646b7ed47bc8e9a60031ad0c2b55031e2077Anders Carlsson  CXXReinterpretCastExpr(QualType ty, CastKind kind, Expr *op,
2029d125033a9853f3b572a4c9e2f9e2d4e5e346973John McCall                         TypeSourceInfo *writtenTy, SourceLocation l)
2037f9e646b7ed47bc8e9a60031ad0c2b55031e2077Anders Carlsson    : CXXNamedCastExpr(CXXReinterpretCastExprClass, ty, kind, op,
204cdef2b75aa60cde1ca00e0aa3f89139ac89c6ae4Anders Carlsson                       writtenTy, l) {}
20549badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor
206ce757a7a1ee905f87551996a69da3e95e8afeeb7Sam Weinig  explicit CXXReinterpretCastExpr(EmptyShell Empty)
207ce757a7a1ee905f87551996a69da3e95e8afeeb7Sam Weinig    : CXXNamedCastExpr(CXXReinterpretCastExprClass, Empty) { }
208ce757a7a1ee905f87551996a69da3e95e8afeeb7Sam Weinig
2091eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  static bool classof(const Stmt *T) {
21049badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor    return T->getStmtClass() == CXXReinterpretCastExprClass;
21149badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor  }
21249badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor  static bool classof(const CXXReinterpretCastExpr *) { return true; }
21349badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor};
21449badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor
21549badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// CXXConstCastExpr - A C++ @c const_cast expression (C++ [expr.const.cast]),
21649badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// which can remove type qualifiers but does not change the underlying value.
2171eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump///
21849badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// This expression node represents a const cast, e.g.,
21949badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// @c const_cast<char*>(PtrToConstChar).
22049badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregorclass CXXConstCastExpr : public CXXNamedCastExpr {
22149badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregorpublic:
2229d125033a9853f3b572a4c9e2f9e2d4e5e346973John McCall  CXXConstCastExpr(QualType ty, Expr *op, TypeSourceInfo *writtenTy,
22349badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor                   SourceLocation l)
224cdef2b75aa60cde1ca00e0aa3f89139ac89c6ae4Anders Carlsson    : CXXNamedCastExpr(CXXConstCastExprClass, ty, CK_NoOp, op, writtenTy, l) {}
22549badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor
226ce757a7a1ee905f87551996a69da3e95e8afeeb7Sam Weinig  explicit CXXConstCastExpr(EmptyShell Empty)
227ce757a7a1ee905f87551996a69da3e95e8afeeb7Sam Weinig    : CXXNamedCastExpr(CXXConstCastExprClass, Empty) { }
228ce757a7a1ee905f87551996a69da3e95e8afeeb7Sam Weinig
2291eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  static bool classof(const Stmt *T) {
23049badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor    return T->getStmtClass() == CXXConstCastExprClass;
23149badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor  }
23249badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor  static bool classof(const CXXConstCastExpr *) { return true; }
2331060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek};
2341060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek
2351060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek/// CXXBoolLiteralExpr - [C++ 2.13.5] C++ Boolean Literal.
2361eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump///
2371060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenekclass CXXBoolLiteralExpr : public Expr {
2381060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  bool Value;
2391060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  SourceLocation Loc;
2401060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenekpublic:
2411eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  CXXBoolLiteralExpr(bool val, QualType Ty, SourceLocation l) :
2422333f7727f97018d6742e1e0938133bcfad967abEli Friedman    Expr(CXXBoolLiteralExprClass, Ty, false, false), Value(val), Loc(l) {}
2438b0b475b3464b0f70b91ba7d679d23c424677d5eSebastian Redl
2441060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  bool getValue() const { return Value; }
2455f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer
2461060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  virtual SourceRange getSourceRange() const { return SourceRange(Loc); }
2471eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
2481eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  static bool classof(const Stmt *T) {
2491060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek    return T->getStmtClass() == CXXBoolLiteralExprClass;
2501060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  }
2511060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  static bool classof(const CXXBoolLiteralExpr *) { return true; }
2521eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
2531060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  // Iterators
2541060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  virtual child_iterator child_begin();
2551060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  virtual child_iterator child_end();
2561060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek};
2571060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek
2586e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl/// CXXNullPtrLiteralExpr - [C++0x 2.14.7] C++ Pointer Literal
2596e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redlclass CXXNullPtrLiteralExpr : public Expr {
2606e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl  SourceLocation Loc;
2616e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redlpublic:
2626e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl  CXXNullPtrLiteralExpr(QualType Ty, SourceLocation l) :
2632333f7727f97018d6742e1e0938133bcfad967abEli Friedman    Expr(CXXNullPtrLiteralExprClass, Ty, false, false), Loc(l) {}
2646e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl
2656e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl  virtual SourceRange getSourceRange() const { return SourceRange(Loc); }
2666e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl
2676e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl  static bool classof(const Stmt *T) {
2686e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl    return T->getStmtClass() == CXXNullPtrLiteralExprClass;
2696e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl  }
2706e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl  static bool classof(const CXXNullPtrLiteralExpr *) { return true; }
2716e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl
2726e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl  virtual child_iterator child_begin();
2736e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl  virtual child_iterator child_end();
2746e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl};
2756e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl
276c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl/// CXXTypeidExpr - A C++ @c typeid expression (C++ [expr.typeid]), which gets
277c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl/// the type_info that corresponds to the supplied type, or the (possibly
278c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl/// dynamic) type of the supplied expression.
279c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl///
280c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl/// This represents code like @c typeid(int) or @c typeid(*objPtr)
281c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redlclass CXXTypeidExpr : public Expr {
282c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redlprivate:
283c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl  bool isTypeOp : 1;
284d457589fc69dc7a9c80cd74d317c0b81a35a27c9Sebastian Redl  union {
285d457589fc69dc7a9c80cd74d317c0b81a35a27c9Sebastian Redl    void *Ty;
286d457589fc69dc7a9c80cd74d317c0b81a35a27c9Sebastian Redl    Stmt *Ex;
287d457589fc69dc7a9c80cd74d317c0b81a35a27c9Sebastian Redl  } Operand;
288c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl  SourceRange Range;
289c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl
290c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redlpublic:
291c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl  CXXTypeidExpr(bool isTypeOp, void *op, QualType Ty, const SourceRange r) :
2922850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl      Expr(CXXTypeidExprClass, Ty,
2932850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl        // typeid is never type-dependent (C++ [temp.dep.expr]p4)
2942850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl        false,
2952850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl        // typeid is value-dependent if the type or expression are dependent
2962850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl        (isTypeOp ? QualType::getFromOpaquePtr(op)->isDependentType()
2972850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl                  : static_cast<Expr*>(op)->isValueDependent())),
2982850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl      isTypeOp(isTypeOp), Range(r) {
299d457589fc69dc7a9c80cd74d317c0b81a35a27c9Sebastian Redl    if (isTypeOp)
300d457589fc69dc7a9c80cd74d317c0b81a35a27c9Sebastian Redl      Operand.Ty = op;
301d457589fc69dc7a9c80cd74d317c0b81a35a27c9Sebastian Redl    else
302d457589fc69dc7a9c80cd74d317c0b81a35a27c9Sebastian Redl      // op was an Expr*, so cast it back to that to be safe
3032850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl      Operand.Ex = static_cast<Expr*>(op);
304d457589fc69dc7a9c80cd74d317c0b81a35a27c9Sebastian Redl  }
305c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl
306c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl  bool isTypeOperand() const { return isTypeOp; }
307c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl  QualType getTypeOperand() const {
308c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl    assert(isTypeOperand() && "Cannot call getTypeOperand for typeid(expr)");
309d457589fc69dc7a9c80cd74d317c0b81a35a27c9Sebastian Redl    return QualType::getFromOpaquePtr(Operand.Ty);
310c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl  }
311c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl  Expr* getExprOperand() const {
312c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl    assert(!isTypeOperand() && "Cannot call getExprOperand for typeid(type)");
313d457589fc69dc7a9c80cd74d317c0b81a35a27c9Sebastian Redl    return static_cast<Expr*>(Operand.Ex);
314c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl  }
315c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl
316c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl  virtual SourceRange getSourceRange() const {
317c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl    return Range;
318c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl  }
319c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl  static bool classof(const Stmt *T) {
320c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl    return T->getStmtClass() == CXXTypeidExprClass;
321c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl  }
322c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl  static bool classof(const CXXTypeidExpr *) { return true; }
323c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl
324c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl  // Iterators
325c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl  virtual child_iterator child_begin();
326c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl  virtual child_iterator child_end();
327c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl};
328c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl
329796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// CXXThisExpr - Represents the "this" expression in C++, which is a
330796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// pointer to the object on which the current member function is
331796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// executing (C++ [expr.prim]p3). Example:
332796da18402f286b897782a298ae3b20c459c102eDouglas Gregor///
333796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// @code
334796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// class Foo {
335796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// public:
336796da18402f286b897782a298ae3b20c459c102eDouglas Gregor///   void bar();
337796da18402f286b897782a298ae3b20c459c102eDouglas Gregor///   void test() { this->bar(); }
338796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// };
339796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// @endcode
340796da18402f286b897782a298ae3b20c459c102eDouglas Gregorclass CXXThisExpr : public Expr {
341796da18402f286b897782a298ae3b20c459c102eDouglas Gregor  SourceLocation Loc;
342828a197317288e3333b0ce6f5cedadd036e3531fDouglas Gregor  bool Implicit : 1;
343828a197317288e3333b0ce6f5cedadd036e3531fDouglas Gregor
344796da18402f286b897782a298ae3b20c459c102eDouglas Gregorpublic:
345828a197317288e3333b0ce6f5cedadd036e3531fDouglas Gregor  CXXThisExpr(SourceLocation L, QualType Type, bool isImplicit)
3462850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl    : Expr(CXXThisExprClass, Type,
3472850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl           // 'this' is type-dependent if the class type of the enclosing
3482850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl           // member function is dependent (C++ [temp.dep.expr]p2)
3492850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl           Type->isDependentType(), Type->isDependentType()),
350828a197317288e3333b0ce6f5cedadd036e3531fDouglas Gregor      Loc(L), Implicit(isImplicit) { }
351796da18402f286b897782a298ae3b20c459c102eDouglas Gregor
352796da18402f286b897782a298ae3b20c459c102eDouglas Gregor  virtual SourceRange getSourceRange() const { return SourceRange(Loc); }
353796da18402f286b897782a298ae3b20c459c102eDouglas Gregor
354828a197317288e3333b0ce6f5cedadd036e3531fDouglas Gregor  bool isImplicit() const { return Implicit; }
355828a197317288e3333b0ce6f5cedadd036e3531fDouglas Gregor  void setImplicit(bool I) { Implicit = I; }
356828a197317288e3333b0ce6f5cedadd036e3531fDouglas Gregor
3571eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  static bool classof(const Stmt *T) {
358796da18402f286b897782a298ae3b20c459c102eDouglas Gregor    return T->getStmtClass() == CXXThisExprClass;
359796da18402f286b897782a298ae3b20c459c102eDouglas Gregor  }
360796da18402f286b897782a298ae3b20c459c102eDouglas Gregor  static bool classof(const CXXThisExpr *) { return true; }
361796da18402f286b897782a298ae3b20c459c102eDouglas Gregor
362796da18402f286b897782a298ae3b20c459c102eDouglas Gregor  // Iterators
363796da18402f286b897782a298ae3b20c459c102eDouglas Gregor  virtual child_iterator child_begin();
364796da18402f286b897782a298ae3b20c459c102eDouglas Gregor  virtual child_iterator child_end();
365796da18402f286b897782a298ae3b20c459c102eDouglas Gregor};
366796da18402f286b897782a298ae3b20c459c102eDouglas Gregor
3671060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek///  CXXThrowExpr - [C++ 15] C++ Throw Expression.  This handles
3681060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek///  'throw' and 'throw' assignment-expression.  When
3691060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek///  assignment-expression isn't present, Op will be null.
3701060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek///
3711060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenekclass CXXThrowExpr : public Expr {
3721060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  Stmt *Op;
3731060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  SourceLocation ThrowLoc;
3741060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenekpublic:
3751060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  // Ty is the void type which is used as the result type of the
3761060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  // exepression.  The l is the location of the throw keyword.  expr
3771060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  // can by null, if the optional expression to throw isn't present.
3781060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  CXXThrowExpr(Expr *expr, QualType Ty, SourceLocation l) :
3792850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl    Expr(CXXThrowExprClass, Ty, false, false), Op(expr), ThrowLoc(l) {}
3801060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  const Expr *getSubExpr() const { return cast_or_null<Expr>(Op); }
3811060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  Expr *getSubExpr() { return cast_or_null<Expr>(Op); }
38242e5b50f4dc897f252e0d476063a7f9846d96624Douglas Gregor  void setSubExpr(Expr *E) { Op = E; }
38342e5b50f4dc897f252e0d476063a7f9846d96624Douglas Gregor
38442e5b50f4dc897f252e0d476063a7f9846d96624Douglas Gregor  SourceLocation getThrowLoc() const { return ThrowLoc; }
38542e5b50f4dc897f252e0d476063a7f9846d96624Douglas Gregor  void setThrowLoc(SourceLocation L) { ThrowLoc = L; }
3861060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek
3871060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  virtual SourceRange getSourceRange() const {
3881060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek    if (getSubExpr() == 0)
3891060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek      return SourceRange(ThrowLoc, ThrowLoc);
3901060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek    return SourceRange(ThrowLoc, getSubExpr()->getSourceRange().getEnd());
3911060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  }
3921060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek
3931060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  static bool classof(const Stmt *T) {
3941060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek    return T->getStmtClass() == CXXThrowExprClass;
3951060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  }
3961060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  static bool classof(const CXXThrowExpr *) { return true; }
3971060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek
3981060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  // Iterators
3991060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  virtual child_iterator child_begin();
4001060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  virtual child_iterator child_end();
4011060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek};
4021060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek
4031060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek/// CXXDefaultArgExpr - C++ [dcl.fct.default]. This wraps up a
4041060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek/// function call argument that was created from the corresponding
4051060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek/// parameter's default argument, when the call did not explicitly
4061060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek/// supply arguments for all of the parameters.
4071060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenekclass CXXDefaultArgExpr : public Expr {
40865222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor  /// \brief The parameter whose default is being used.
40965222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor  ///
41065222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor  /// When the bit is set, the subexpression is stored after the
41165222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor  /// CXXDefaultArgExpr itself. When the bit is clear, the parameter's
41265222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor  /// actual default expression is the subexpression.
41365222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor  llvm::PointerIntPair<ParmVarDecl *, 1, bool> Param;
4141eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
415036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor  /// \brief The location where the default argument expression was used.
416036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor  SourceLocation Loc;
417036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor
418f1480eee38b59d15438fb7bc50865ac7c7e22403Anders Carlssonprotected:
419036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor  CXXDefaultArgExpr(StmtClass SC, SourceLocation Loc, ParmVarDecl *param)
42065222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor    : Expr(SC,
42165222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor           param->hasUnparsedDefaultArg()
42265222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor             ? param->getType().getNonReferenceType()
4232333f7727f97018d6742e1e0938133bcfad967abEli Friedman             : param->getDefaultArg()->getType(),
4242333f7727f97018d6742e1e0938133bcfad967abEli Friedman           false, false),
425036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor      Param(param, false), Loc(Loc) { }
42665222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor
427036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor  CXXDefaultArgExpr(StmtClass SC, SourceLocation Loc, ParmVarDecl *param,
428036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor                    Expr *SubExpr)
4292333f7727f97018d6742e1e0938133bcfad967abEli Friedman    : Expr(SC, SubExpr->getType(), false, false), Param(param, true), Loc(Loc)
43065222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor  {
43165222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor    *reinterpret_cast<Expr **>(this + 1) = SubExpr;
43265222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor  }
43365222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor
43465222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregorprotected:
43565222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor  virtual void DoDestroy(ASTContext &C);
43665222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor
4371060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenekpublic:
4381060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  // Param is the parameter whose default argument is used by this
4391060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  // expression.
440036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor  static CXXDefaultArgExpr *Create(ASTContext &C, SourceLocation Loc,
441036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor                                   ParmVarDecl *Param) {
442036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor    return new (C) CXXDefaultArgExpr(CXXDefaultArgExprClass, Loc, Param);
443f1480eee38b59d15438fb7bc50865ac7c7e22403Anders Carlsson  }
4441060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek
44565222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor  // Param is the parameter whose default argument is used by this
44665222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor  // expression, and SubExpr is the expression that will actually be used.
447036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor  static CXXDefaultArgExpr *Create(ASTContext &C,
448036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor                                   SourceLocation Loc,
449036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor                                   ParmVarDecl *Param,
45065222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor                                   Expr *SubExpr);
45165222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor
4521060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  // Retrieve the parameter that the argument was created from.
45365222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor  const ParmVarDecl *getParam() const { return Param.getPointer(); }
45465222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor  ParmVarDecl *getParam() { return Param.getPointer(); }
4551060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek
4561060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  // Retrieve the actual argument to the function call.
45765222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor  const Expr *getExpr() const {
45865222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor    if (Param.getInt())
45965222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor      return *reinterpret_cast<Expr const * const*> (this + 1);
46065222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor    return getParam()->getDefaultArg();
46165222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor  }
46265222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor  Expr *getExpr() {
46365222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor    if (Param.getInt())
46465222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor      return *reinterpret_cast<Expr **> (this + 1);
46565222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor    return getParam()->getDefaultArg();
46665222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor  }
4671060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek
468036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor  /// \brief Retrieve the location where this default argument was actually
469036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor  /// used.
470036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor  SourceLocation getUsedLocation() const { return Loc; }
471036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor
4721060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  virtual SourceRange getSourceRange() const {
4731060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek    // Default argument expressions have no representation in the
4741060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek    // source, so they have an empty source range.
4751060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek    return SourceRange();
4761060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  }
4771060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek
4781060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  static bool classof(const Stmt *T) {
4791060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek    return T->getStmtClass() == CXXDefaultArgExprClass;
4801060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  }
4811060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  static bool classof(const CXXDefaultArgExpr *) { return true; }
4821060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek
4831060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  // Iterators
4841060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  virtual child_iterator child_begin();
4851060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  virtual child_iterator child_end();
4861060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek};
487987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis
488c1ce477119fed070299668aab24084b17ff5f14bAnders Carlsson/// CXXTemporary - Represents a C++ temporary.
489c1ce477119fed070299668aab24084b17ff5f14bAnders Carlssonclass CXXTemporary {
490c1ce477119fed070299668aab24084b17ff5f14bAnders Carlsson  /// Destructor - The destructor that needs to be called.
491b859f35459ae3e1188d1e1b86df08d649695fd86Anders Carlsson  const CXXDestructorDecl *Destructor;
4921eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
493b859f35459ae3e1188d1e1b86df08d649695fd86Anders Carlsson  CXXTemporary(const CXXDestructorDecl *destructor)
494c1ce477119fed070299668aab24084b17ff5f14bAnders Carlsson    : Destructor(destructor) { }
49588eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlsson  ~CXXTemporary() { }
496c1ce477119fed070299668aab24084b17ff5f14bAnders Carlsson
497c1ce477119fed070299668aab24084b17ff5f14bAnders Carlssonpublic:
4981eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  static CXXTemporary *Create(ASTContext &C,
499b859f35459ae3e1188d1e1b86df08d649695fd86Anders Carlsson                              const CXXDestructorDecl *Destructor);
5001eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
50142602bb40aefcc2751d4078ba88aacf4d965c9bdDouglas Gregor  void Destroy(ASTContext &Ctx);
5021eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
503f0721fe438d7e40c168e5d664970e7830bc138fbAnders Carlsson  const CXXDestructorDecl *getDestructor() const { return Destructor; }
504c1ce477119fed070299668aab24084b17ff5f14bAnders Carlsson};
505fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson
5061eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump/// CXXBindTemporaryExpr - Represents binding an expression to a temporary,
507fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson/// so its destructor can be called later.
508fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlssonclass CXXBindTemporaryExpr : public Expr {
509fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson  CXXTemporary *Temp;
5101eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
511fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson  Stmt *SubExpr;
512fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson
5131eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  CXXBindTemporaryExpr(CXXTemporary *temp, Expr* subexpr)
5142333f7727f97018d6742e1e0938133bcfad967abEli Friedman   : Expr(CXXBindTemporaryExprClass, subexpr->getType(), false, false),
5152333f7727f97018d6742e1e0938133bcfad967abEli Friedman     Temp(temp), SubExpr(subexpr) { }
5161eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  ~CXXBindTemporaryExpr() { }
51788eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlsson
51842602bb40aefcc2751d4078ba88aacf4d965c9bdDouglas Gregorprotected:
51942602bb40aefcc2751d4078ba88aacf4d965c9bdDouglas Gregor  virtual void DoDestroy(ASTContext &C);
52042602bb40aefcc2751d4078ba88aacf4d965c9bdDouglas Gregor
521fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlssonpublic:
5221eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  static CXXBindTemporaryExpr *Create(ASTContext &C, CXXTemporary *Temp,
523fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson                                      Expr* SubExpr);
5241eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
52588eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlsson  CXXTemporary *getTemporary() { return Temp; }
526f0721fe438d7e40c168e5d664970e7830bc138fbAnders Carlsson  const CXXTemporary *getTemporary() const { return Temp; }
527f0721fe438d7e40c168e5d664970e7830bc138fbAnders Carlsson
528fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson  const Expr *getSubExpr() const { return cast<Expr>(SubExpr); }
529fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson  Expr *getSubExpr() { return cast<Expr>(SubExpr); }
53088eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlsson  void setSubExpr(Expr *E) { SubExpr = E; }
531fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson
53296be6917e1c4ba1f4435a14c9e7c6c139571d086Douglas Gregor  virtual SourceRange getSourceRange() const {
53396be6917e1c4ba1f4435a14c9e7c6c139571d086Douglas Gregor    return SubExpr->getSourceRange();
53496be6917e1c4ba1f4435a14c9e7c6c139571d086Douglas Gregor  }
535fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson
536fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson  // Implement isa/cast/dyncast/etc.
537fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson  static bool classof(const Stmt *T) {
538fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson    return T->getStmtClass() == CXXBindTemporaryExprClass;
539fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson  }
540fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson  static bool classof(const CXXBindTemporaryExpr *) { return true; }
541fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson
542fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson  // Iterators
543fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson  virtual child_iterator child_begin();
544fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson  virtual child_iterator child_end();
545fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson};
546fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson
547eb60edffa147e061278c436e513b0df9b4c4e7f6Anders Carlsson/// CXXBindReferenceExpr - Represents binding an expression to a reference.
548eb60edffa147e061278c436e513b0df9b4c4e7f6Anders Carlsson/// In the example:
549eb60edffa147e061278c436e513b0df9b4c4e7f6Anders Carlsson///
550eb60edffa147e061278c436e513b0df9b4c4e7f6Anders Carlsson/// const int &i = 10;
551eb60edffa147e061278c436e513b0df9b4c4e7f6Anders Carlsson///
552eb60edffa147e061278c436e513b0df9b4c4e7f6Anders Carlsson/// a bind reference expression is inserted to indicate that 10 is bound to
553eb60edffa147e061278c436e513b0df9b4c4e7f6Anders Carlsson/// a reference. (Ans also that a temporary needs to be created to hold the
554eb60edffa147e061278c436e513b0df9b4c4e7f6Anders Carlsson/// value).
555eb60edffa147e061278c436e513b0df9b4c4e7f6Anders Carlssonclass CXXBindReferenceExpr : public Expr {
556eb60edffa147e061278c436e513b0df9b4c4e7f6Anders Carlsson  // SubExpr - The expression being bound.
557eb60edffa147e061278c436e513b0df9b4c4e7f6Anders Carlsson  Stmt *SubExpr;
558eb60edffa147e061278c436e513b0df9b4c4e7f6Anders Carlsson
559eb60edffa147e061278c436e513b0df9b4c4e7f6Anders Carlsson  // ExtendsLifetime - Whether binding this reference extends the lifetime of
560eb60edffa147e061278c436e513b0df9b4c4e7f6Anders Carlsson  // the expression being bound. FIXME: Add C++ reference.
561eb60edffa147e061278c436e513b0df9b4c4e7f6Anders Carlsson  bool ExtendsLifetime;
562eb60edffa147e061278c436e513b0df9b4c4e7f6Anders Carlsson
563eb60edffa147e061278c436e513b0df9b4c4e7f6Anders Carlsson  /// RequiresTemporaryCopy - Whether binding the subexpression requires a
564eb60edffa147e061278c436e513b0df9b4c4e7f6Anders Carlsson  /// temporary copy.
565eb60edffa147e061278c436e513b0df9b4c4e7f6Anders Carlsson  bool RequiresTemporaryCopy;
566eb60edffa147e061278c436e513b0df9b4c4e7f6Anders Carlsson
567eb60edffa147e061278c436e513b0df9b4c4e7f6Anders Carlsson  CXXBindReferenceExpr(Expr *subexpr, bool ExtendsLifetime,
568eb60edffa147e061278c436e513b0df9b4c4e7f6Anders Carlsson                       bool RequiresTemporaryCopy)
569eb60edffa147e061278c436e513b0df9b4c4e7f6Anders Carlsson  : Expr(CXXBindReferenceExprClass, subexpr->getType(), false, false),
570eb60edffa147e061278c436e513b0df9b4c4e7f6Anders Carlsson    SubExpr(subexpr), ExtendsLifetime(ExtendsLifetime),
571eb60edffa147e061278c436e513b0df9b4c4e7f6Anders Carlsson    RequiresTemporaryCopy(RequiresTemporaryCopy) { }
572eb60edffa147e061278c436e513b0df9b4c4e7f6Anders Carlsson  ~CXXBindReferenceExpr() { }
573eb60edffa147e061278c436e513b0df9b4c4e7f6Anders Carlsson
574eb60edffa147e061278c436e513b0df9b4c4e7f6Anders Carlssonprotected:
575eb60edffa147e061278c436e513b0df9b4c4e7f6Anders Carlsson  virtual void DoDestroy(ASTContext &C);
576eb60edffa147e061278c436e513b0df9b4c4e7f6Anders Carlsson
577eb60edffa147e061278c436e513b0df9b4c4e7f6Anders Carlssonpublic:
578eb60edffa147e061278c436e513b0df9b4c4e7f6Anders Carlsson  static CXXBindReferenceExpr *Create(ASTContext &C, Expr *SubExpr,
579eb60edffa147e061278c436e513b0df9b4c4e7f6Anders Carlsson                                      bool ExtendsLifetime,
580eb60edffa147e061278c436e513b0df9b4c4e7f6Anders Carlsson                                      bool RequiresTemporaryCopy);
581eb60edffa147e061278c436e513b0df9b4c4e7f6Anders Carlsson
582eb60edffa147e061278c436e513b0df9b4c4e7f6Anders Carlsson  const Expr *getSubExpr() const { return cast<Expr>(SubExpr); }
583eb60edffa147e061278c436e513b0df9b4c4e7f6Anders Carlsson  Expr *getSubExpr() { return cast<Expr>(SubExpr); }
584eb60edffa147e061278c436e513b0df9b4c4e7f6Anders Carlsson  void setSubExpr(Expr *E) { SubExpr = E; }
585eb60edffa147e061278c436e513b0df9b4c4e7f6Anders Carlsson
586eb60edffa147e061278c436e513b0df9b4c4e7f6Anders Carlsson  virtual SourceRange getSourceRange() const {
587eb60edffa147e061278c436e513b0df9b4c4e7f6Anders Carlsson    return SubExpr->getSourceRange();
588eb60edffa147e061278c436e513b0df9b4c4e7f6Anders Carlsson  }
589eb60edffa147e061278c436e513b0df9b4c4e7f6Anders Carlsson
5904e1c181e2bb378dad55dd25c18611e3a0fb6c22aAnders Carlsson  /// requiresTemporaryCopy - Whether binding the subexpression requires a
5914e1c181e2bb378dad55dd25c18611e3a0fb6c22aAnders Carlsson  /// temporary copy.
5924e1c181e2bb378dad55dd25c18611e3a0fb6c22aAnders Carlsson  bool requiresTemporaryCopy() const { return RequiresTemporaryCopy; }
5934e1c181e2bb378dad55dd25c18611e3a0fb6c22aAnders Carlsson
5944e1c181e2bb378dad55dd25c18611e3a0fb6c22aAnders Carlsson  // extendsLifetime - Whether binding this reference extends the lifetime of
5954e1c181e2bb378dad55dd25c18611e3a0fb6c22aAnders Carlsson  // the expression being bound. FIXME: Add C++ reference.
5964e1c181e2bb378dad55dd25c18611e3a0fb6c22aAnders Carlsson  bool extendsLifetime() { return ExtendsLifetime; }
5974e1c181e2bb378dad55dd25c18611e3a0fb6c22aAnders Carlsson
598eb60edffa147e061278c436e513b0df9b4c4e7f6Anders Carlsson  // Implement isa/cast/dyncast/etc.
599eb60edffa147e061278c436e513b0df9b4c4e7f6Anders Carlsson  static bool classof(const Stmt *T) {
600eb60edffa147e061278c436e513b0df9b4c4e7f6Anders Carlsson    return T->getStmtClass() == CXXBindReferenceExprClass;
601eb60edffa147e061278c436e513b0df9b4c4e7f6Anders Carlsson  }
602eb60edffa147e061278c436e513b0df9b4c4e7f6Anders Carlsson  static bool classof(const CXXBindReferenceExpr *) { return true; }
603eb60edffa147e061278c436e513b0df9b4c4e7f6Anders Carlsson
604eb60edffa147e061278c436e513b0df9b4c4e7f6Anders Carlsson  // Iterators
605eb60edffa147e061278c436e513b0df9b4c4e7f6Anders Carlsson  virtual child_iterator child_begin();
606eb60edffa147e061278c436e513b0df9b4c4e7f6Anders Carlsson  virtual child_iterator child_end();
607eb60edffa147e061278c436e513b0df9b4c4e7f6Anders Carlsson};
608eb60edffa147e061278c436e513b0df9b4c4e7f6Anders Carlsson
60915ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson/// CXXConstructExpr - Represents a call to a C++ constructor.
61015ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlssonclass CXXConstructExpr : public Expr {
61115ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson  CXXConstructorDecl *Constructor;
61215ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson
61399a2e600f9e2e51d3ce10fb6f27191677ac65b2aDouglas Gregor  SourceLocation Loc;
61416006c901315fa12a108b4e571f187f4b676e426Douglas Gregor  bool Elidable : 1;
61516006c901315fa12a108b4e571f187f4b676e426Douglas Gregor  bool ZeroInitialization : 1;
6169db7dbb918ca49f4ee6c181e4917e7b6ec547353Douglas Gregor  bool BaseInitialization : 1;
61715ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson  Stmt **Args;
61815ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson  unsigned NumArgs;
6191eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
620bd6734e5f6432ce0cc07171c490ffaa094796198Anders Carlssonprotected:
6211eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  CXXConstructExpr(ASTContext &C, StmtClass SC, QualType T,
62299a2e600f9e2e51d3ce10fb6f27191677ac65b2aDouglas Gregor                   SourceLocation Loc,
623bd6734e5f6432ce0cc07171c490ffaa094796198Anders Carlsson                   CXXConstructorDecl *d, bool elidable,
62416006c901315fa12a108b4e571f187f4b676e426Douglas Gregor                   Expr **args, unsigned numargs,
6259db7dbb918ca49f4ee6c181e4917e7b6ec547353Douglas Gregor                   bool ZeroInitialization = false,
6269db7dbb918ca49f4ee6c181e4917e7b6ec547353Douglas Gregor                   bool BaseInitialization = false);
6271eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  ~CXXConstructExpr() { }
628bd6734e5f6432ce0cc07171c490ffaa094796198Anders Carlsson
62942602bb40aefcc2751d4078ba88aacf4d965c9bdDouglas Gregor  virtual void DoDestroy(ASTContext &C);
63042602bb40aefcc2751d4078ba88aacf4d965c9bdDouglas Gregor
63115ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlssonpublic:
63239da0b8145eaec7da7004f9b3645c5c9f4f63b1dDouglas Gregor  /// \brief Construct an empty C++ construction expression that will store
63339da0b8145eaec7da7004f9b3645c5c9f4f63b1dDouglas Gregor  /// \p numargs arguments.
63439da0b8145eaec7da7004f9b3645c5c9f4f63b1dDouglas Gregor  CXXConstructExpr(EmptyShell Empty, ASTContext &C, unsigned numargs);
63539da0b8145eaec7da7004f9b3645c5c9f4f63b1dDouglas Gregor
6368e587a15da6d3457a418239d5eb4146fcbd209f3Anders Carlsson  static CXXConstructExpr *Create(ASTContext &C, QualType T,
63799a2e600f9e2e51d3ce10fb6f27191677ac65b2aDouglas Gregor                                  SourceLocation Loc,
6381eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump                                  CXXConstructorDecl *D, bool Elidable,
63916006c901315fa12a108b4e571f187f4b676e426Douglas Gregor                                  Expr **Args, unsigned NumArgs,
6409db7dbb918ca49f4ee6c181e4917e7b6ec547353Douglas Gregor                                  bool ZeroInitialization = false,
6419db7dbb918ca49f4ee6c181e4917e7b6ec547353Douglas Gregor                                  bool BaseInitialization = false);
6421eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
6431eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
644d94546a0a1deef7286c13e49b9584621ae81cc9aDouglas Gregor  CXXConstructorDecl* getConstructor() const { return Constructor; }
64539da0b8145eaec7da7004f9b3645c5c9f4f63b1dDouglas Gregor  void setConstructor(CXXConstructorDecl *C) { Constructor = C; }
64639da0b8145eaec7da7004f9b3645c5c9f4f63b1dDouglas Gregor
64799a2e600f9e2e51d3ce10fb6f27191677ac65b2aDouglas Gregor  SourceLocation getLocation() const { return Loc; }
64899a2e600f9e2e51d3ce10fb6f27191677ac65b2aDouglas Gregor  void setLocation(SourceLocation Loc) { this->Loc = Loc; }
64999a2e600f9e2e51d3ce10fb6f27191677ac65b2aDouglas Gregor
650d94546a0a1deef7286c13e49b9584621ae81cc9aDouglas Gregor  /// \brief Whether this construction is elidable.
651d94546a0a1deef7286c13e49b9584621ae81cc9aDouglas Gregor  bool isElidable() const { return Elidable; }
65239da0b8145eaec7da7004f9b3645c5c9f4f63b1dDouglas Gregor  void setElidable(bool E) { Elidable = E; }
65339da0b8145eaec7da7004f9b3645c5c9f4f63b1dDouglas Gregor
65416006c901315fa12a108b4e571f187f4b676e426Douglas Gregor  /// \brief Whether this construction first requires
65516006c901315fa12a108b4e571f187f4b676e426Douglas Gregor  /// zero-initialization before the initializer is called.
65616006c901315fa12a108b4e571f187f4b676e426Douglas Gregor  bool requiresZeroInitialization() const { return ZeroInitialization; }
65716006c901315fa12a108b4e571f187f4b676e426Douglas Gregor  void setRequiresZeroInitialization(bool ZeroInit) {
65816006c901315fa12a108b4e571f187f4b676e426Douglas Gregor    ZeroInitialization = ZeroInit;
65916006c901315fa12a108b4e571f187f4b676e426Douglas Gregor  }
66016006c901315fa12a108b4e571f187f4b676e426Douglas Gregor
6619db7dbb918ca49f4ee6c181e4917e7b6ec547353Douglas Gregor  /// \brief Determines whether this constructor is actually constructing
6629db7dbb918ca49f4ee6c181e4917e7b6ec547353Douglas Gregor  /// a base class (rather than a complete object).
6639db7dbb918ca49f4ee6c181e4917e7b6ec547353Douglas Gregor  bool isBaseInitialization() const { return BaseInitialization; }
6649db7dbb918ca49f4ee6c181e4917e7b6ec547353Douglas Gregor  void setBaseInitialization(bool BI) { BaseInitialization = BI; }
6659db7dbb918ca49f4ee6c181e4917e7b6ec547353Douglas Gregor
66615ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson  typedef ExprIterator arg_iterator;
66715ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson  typedef ConstExprIterator const_arg_iterator;
6681eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
66915ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson  arg_iterator arg_begin() { return Args; }
67015ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson  arg_iterator arg_end() { return Args + NumArgs; }
67115ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson  const_arg_iterator arg_begin() const { return Args; }
67215ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson  const_arg_iterator arg_end() const { return Args + NumArgs; }
67315ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson
674a88cfbfac9bbcbb9858f048d6d73a48711d8e93dDouglas Gregor  Expr **getArgs() const { return reinterpret_cast<Expr **>(Args); }
67515ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson  unsigned getNumArgs() const { return NumArgs; }
67615ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson
677bcb11d01c034f967503bd98f28bdf458c1ab8001Anders Carlsson  /// getArg - Return the specified argument.
678bcb11d01c034f967503bd98f28bdf458c1ab8001Anders Carlsson  Expr *getArg(unsigned Arg) {
679bcb11d01c034f967503bd98f28bdf458c1ab8001Anders Carlsson    assert(Arg < NumArgs && "Arg access out of range!");
680bcb11d01c034f967503bd98f28bdf458c1ab8001Anders Carlsson    return cast<Expr>(Args[Arg]);
681bcb11d01c034f967503bd98f28bdf458c1ab8001Anders Carlsson  }
682bcb11d01c034f967503bd98f28bdf458c1ab8001Anders Carlsson  const Expr *getArg(unsigned Arg) const {
683bcb11d01c034f967503bd98f28bdf458c1ab8001Anders Carlsson    assert(Arg < NumArgs && "Arg access out of range!");
684bcb11d01c034f967503bd98f28bdf458c1ab8001Anders Carlsson    return cast<Expr>(Args[Arg]);
685bcb11d01c034f967503bd98f28bdf458c1ab8001Anders Carlsson  }
6861eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
6872eeed7bc4fd457ac57ff32ab3b02674588545f65Fariborz Jahanian  /// setArg - Set the specified argument.
6882eeed7bc4fd457ac57ff32ab3b02674588545f65Fariborz Jahanian  void setArg(unsigned Arg, Expr *ArgExpr) {
6892eeed7bc4fd457ac57ff32ab3b02674588545f65Fariborz Jahanian    assert(Arg < NumArgs && "Arg access out of range!");
6902eeed7bc4fd457ac57ff32ab3b02674588545f65Fariborz Jahanian    Args[Arg] = ArgExpr;
6912eeed7bc4fd457ac57ff32ab3b02674588545f65Fariborz Jahanian  }
6922eeed7bc4fd457ac57ff32ab3b02674588545f65Fariborz Jahanian
693e383768f7f5d45ca4af0b1c11cbf072de18bce98Ted Kremenek  virtual SourceRange getSourceRange() const;
69415ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson
6951eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  static bool classof(const Stmt *T) {
696524fa13fd81e88533c7a1d4b1232c0de2c97dc7cAnders Carlsson    return T->getStmtClass() == CXXConstructExprClass ||
697524fa13fd81e88533c7a1d4b1232c0de2c97dc7cAnders Carlsson      T->getStmtClass() == CXXTemporaryObjectExprClass;
69815ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson  }
69915ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson  static bool classof(const CXXConstructExpr *) { return true; }
7001eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
70115ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson  // Iterators
70215ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson  virtual child_iterator child_begin();
70315ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson  virtual child_iterator child_end();
70415ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson};
70515ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson
70649badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// CXXFunctionalCastExpr - Represents an explicit C++ type conversion
70749badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// that uses "functional" notion (C++ [expr.type.conv]). Example: @c
70849badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// x = int(0.5);
70949badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregorclass CXXFunctionalCastExpr : public ExplicitCastExpr {
710987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  SourceLocation TyBeginLoc;
711987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  SourceLocation RParenLoc;
712987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidispublic:
7139d125033a9853f3b572a4c9e2f9e2d4e5e346973John McCall  CXXFunctionalCastExpr(QualType ty, TypeSourceInfo *writtenTy,
7141eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump                        SourceLocation tyBeginLoc, CastKind kind,
7150aebc81e02397a5987aaa8e8c7acbdb01a31d7c3Anders Carlsson                        Expr *castExpr, SourceLocation rParenLoc)
7160aebc81e02397a5987aaa8e8c7acbdb01a31d7c3Anders Carlsson    : ExplicitCastExpr(CXXFunctionalCastExprClass, ty, kind, castExpr,
7170aebc81e02397a5987aaa8e8c7acbdb01a31d7c3Anders Carlsson                       writtenTy),
7180aebc81e02397a5987aaa8e8c7acbdb01a31d7c3Anders Carlsson      TyBeginLoc(tyBeginLoc), RParenLoc(rParenLoc) {}
7190aebc81e02397a5987aaa8e8c7acbdb01a31d7c3Anders Carlsson
720ce757a7a1ee905f87551996a69da3e95e8afeeb7Sam Weinig  explicit CXXFunctionalCastExpr(EmptyShell Shell)
721ce757a7a1ee905f87551996a69da3e95e8afeeb7Sam Weinig    : ExplicitCastExpr(CXXFunctionalCastExprClass, Shell) { }
722ce757a7a1ee905f87551996a69da3e95e8afeeb7Sam Weinig
723987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  SourceLocation getTypeBeginLoc() const { return TyBeginLoc; }
724ce757a7a1ee905f87551996a69da3e95e8afeeb7Sam Weinig  void setTypeBeginLoc(SourceLocation L) { TyBeginLoc = L; }
725987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  SourceLocation getRParenLoc() const { return RParenLoc; }
726ce757a7a1ee905f87551996a69da3e95e8afeeb7Sam Weinig  void setRParenLoc(SourceLocation L) { RParenLoc = L; }
7271eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
728987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  virtual SourceRange getSourceRange() const {
729987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis    return SourceRange(TyBeginLoc, RParenLoc);
730987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  }
7311eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  static bool classof(const Stmt *T) {
7321eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump    return T->getStmtClass() == CXXFunctionalCastExprClass;
733987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  }
734987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  static bool classof(const CXXFunctionalCastExpr *) { return true; }
735987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis};
736987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis
737506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// @brief Represents a C++ functional cast expression that builds a
738506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// temporary object.
739506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor///
7401eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump/// This expression type represents a C++ "functional" cast
741506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// (C++[expr.type.conv]) with N != 1 arguments that invokes a
742506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// constructor to build a temporary object. If N == 0 but no
743506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// constructor will be called (because the functional cast is
744506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// performing a value-initialized an object whose class type has no
745506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// user-declared constructors), CXXZeroInitValueExpr will represent
746506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// the functional cast. Finally, with N == 1 arguments the functional
747506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// cast expression will be represented by CXXFunctionalCastExpr.
748506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// Example:
749506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// @code
750506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// struct X { X(int, float); }
751506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor///
752506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// X create_X() {
753506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor///   return X(1, 3.14f); // creates a CXXTemporaryObjectExpr
754506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// };
755506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// @endcode
756524fa13fd81e88533c7a1d4b1232c0de2c97dc7cAnders Carlssonclass CXXTemporaryObjectExpr : public CXXConstructExpr {
757506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor  SourceLocation TyBeginLoc;
758506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor  SourceLocation RParenLoc;
759506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor
760506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregorpublic:
7611eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  CXXTemporaryObjectExpr(ASTContext &C, CXXConstructorDecl *Cons,
7621eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump                         QualType writtenTy, SourceLocation tyBeginLoc,
7631eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump                         Expr **Args,unsigned NumArgs,
7648e587a15da6d3457a418239d5eb4146fcbd209f3Anders Carlsson                         SourceLocation rParenLoc);
765506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor
7661eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  ~CXXTemporaryObjectExpr() { }
767506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor
768506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor  SourceLocation getTypeBeginLoc() const { return TyBeginLoc; }
769506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor  SourceLocation getRParenLoc() const { return RParenLoc; }
770ba49817c5b9f502602672861cf369fd0e53966e8Douglas Gregor
771506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor  virtual SourceRange getSourceRange() const {
772506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor    return SourceRange(TyBeginLoc, RParenLoc);
773506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor  }
7741eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  static bool classof(const Stmt *T) {
775506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor    return T->getStmtClass() == CXXTemporaryObjectExprClass;
776506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor  }
777506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor  static bool classof(const CXXTemporaryObjectExpr *) { return true; }
778506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor};
779506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor
780987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis/// CXXZeroInitValueExpr - [C++ 5.2.3p2]
781506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// Expression "T()" which creates a value-initialized rvalue of type
782506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// T, which is either a non-class type or a class type without any
783506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// user-defined constructors.
784987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis///
785987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidisclass CXXZeroInitValueExpr : public Expr {
786987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  SourceLocation TyBeginLoc;
787987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  SourceLocation RParenLoc;
788987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis
789987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidispublic:
790987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  CXXZeroInitValueExpr(QualType ty, SourceLocation tyBeginLoc,
7911eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump                       SourceLocation rParenLoc ) :
792d94546a0a1deef7286c13e49b9584621ae81cc9aDouglas Gregor    Expr(CXXZeroInitValueExprClass, ty, false, false),
793987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis    TyBeginLoc(tyBeginLoc), RParenLoc(rParenLoc) {}
7941eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
795987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  SourceLocation getTypeBeginLoc() const { return TyBeginLoc; }
796987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  SourceLocation getRParenLoc() const { return RParenLoc; }
797987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis
7984c67834407ca6ab344dcf44fc599ad4938cfa96dDouglas Gregor  /// @brief Whether this initialization expression was
7994c67834407ca6ab344dcf44fc599ad4938cfa96dDouglas Gregor  /// implicitly-generated.
8001eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  bool isImplicit() const {
8011eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump    return TyBeginLoc.isInvalid() && RParenLoc.isInvalid();
8024c67834407ca6ab344dcf44fc599ad4938cfa96dDouglas Gregor  }
8034c67834407ca6ab344dcf44fc599ad4938cfa96dDouglas Gregor
804987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  virtual SourceRange getSourceRange() const {
805987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis    return SourceRange(TyBeginLoc, RParenLoc);
806987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  }
8071eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
8081eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  static bool classof(const Stmt *T) {
809987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis    return T->getStmtClass() == CXXZeroInitValueExprClass;
810987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  }
811987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  static bool classof(const CXXZeroInitValueExpr *) { return true; }
8121eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
813987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  // Iterators
814987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  virtual child_iterator child_begin();
815987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  virtual child_iterator child_end();
816987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis};
817987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis
8184c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl/// CXXNewExpr - A new expression for memory allocation and constructor calls,
8194c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl/// e.g: "new CXXNewExpr(foo)".
8204c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redlclass CXXNewExpr : public Expr {
8214c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  // Was the usage ::new, i.e. is the global new to be used?
8224c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  bool GlobalNew : 1;
8234c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  // Was the form (type-id) used? Otherwise, it was new-type-id.
8244c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  bool ParenTypeId : 1;
8254c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  // Is there an initializer? If not, built-ins are uninitialized, else they're
8264c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  // value-initialized.
8274c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  bool Initializer : 1;
828cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl  // Do we allocate an array? If so, the first SubExpr is the size expression.
829cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl  bool Array : 1;
8304c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  // The number of placement new arguments.
8314c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  unsigned NumPlacementArgs : 14;
8324c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  // The number of constructor arguments. This may be 1 even for non-class
8334c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  // types; use the pseudo copy constructor.
834cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl  unsigned NumConstructorArgs : 14;
835cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl  // Contains an optional array size expression, any number of optional
836cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl  // placement arguments, and any number of optional constructor arguments,
837cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl  // in that order.
8384c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  Stmt **SubExprs;
8394c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  // Points to the allocation function used.
8404c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  FunctionDecl *OperatorNew;
8414c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  // Points to the deallocation function used in case of error. May be null.
8424c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  FunctionDecl *OperatorDelete;
8434c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  // Points to the constructor used. Cannot be null if AllocType is a record;
8444c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  // it would still point at the default constructor (even an implicit one).
8454c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  // Must be null for all other types.
8464c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  CXXConstructorDecl *Constructor;
8474c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
8484c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  SourceLocation StartLoc;
8494c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  SourceLocation EndLoc;
8504c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
8514c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redlpublic:
8524c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  CXXNewExpr(bool globalNew, FunctionDecl *operatorNew, Expr **placementArgs,
853cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl             unsigned numPlaceArgs, bool ParenTypeId, Expr *arraySize,
8544c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl             CXXConstructorDecl *constructor, bool initializer,
8554c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl             Expr **constructorArgs, unsigned numConsArgs,
8564c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl             FunctionDecl *operatorDelete, QualType ty,
8574c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl             SourceLocation startLoc, SourceLocation endLoc);
8584c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  ~CXXNewExpr() {
8594c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl    delete[] SubExprs;
8604c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  }
8614c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
862cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl  QualType getAllocatedType() const {
863cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl    assert(getType()->isPointerType());
8646217b80b7a1379b74cced1c076338262c3c980b3Ted Kremenek    return getType()->getAs<PointerType>()->getPointeeType();
865cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl  }
8664c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
8674c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  FunctionDecl *getOperatorNew() const { return OperatorNew; }
8684c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  FunctionDecl *getOperatorDelete() const { return OperatorDelete; }
8694c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  CXXConstructorDecl *getConstructor() const { return Constructor; }
8704c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
871cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl  bool isArray() const { return Array; }
872cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl  Expr *getArraySize() {
873cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl    return Array ? cast<Expr>(SubExprs[0]) : 0;
874cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl  }
875cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl  const Expr *getArraySize() const {
876cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl    return Array ? cast<Expr>(SubExprs[0]) : 0;
877cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl  }
878cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl
8794c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  unsigned getNumPlacementArgs() const { return NumPlacementArgs; }
8804c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  Expr *getPlacementArg(unsigned i) {
8814c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl    assert(i < NumPlacementArgs && "Index out of range");
882cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl    return cast<Expr>(SubExprs[Array + i]);
8834c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  }
8844c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  const Expr *getPlacementArg(unsigned i) const {
8854c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl    assert(i < NumPlacementArgs && "Index out of range");
886cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl    return cast<Expr>(SubExprs[Array + i]);
8874c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  }
8884c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
8894c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  bool isGlobalNew() const { return GlobalNew; }
8904c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  bool isParenTypeId() const { return ParenTypeId; }
8914c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  bool hasInitializer() const { return Initializer; }
8924c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
8934c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  unsigned getNumConstructorArgs() const { return NumConstructorArgs; }
8944c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  Expr *getConstructorArg(unsigned i) {
8954c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl    assert(i < NumConstructorArgs && "Index out of range");
896cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl    return cast<Expr>(SubExprs[Array + NumPlacementArgs + i]);
8974c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  }
8984c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  const Expr *getConstructorArg(unsigned i) const {
8994c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl    assert(i < NumConstructorArgs && "Index out of range");
900cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl    return cast<Expr>(SubExprs[Array + NumPlacementArgs + i]);
9014c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  }
9024c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
9034c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  typedef ExprIterator arg_iterator;
9044c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  typedef ConstExprIterator const_arg_iterator;
9054c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
9064c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  arg_iterator placement_arg_begin() {
907cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl    return SubExprs + Array;
9084c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  }
9094c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  arg_iterator placement_arg_end() {
910cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl    return SubExprs + Array + getNumPlacementArgs();
9114c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  }
9124c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  const_arg_iterator placement_arg_begin() const {
913cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl    return SubExprs + Array;
9144c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  }
9154c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  const_arg_iterator placement_arg_end() const {
916cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl    return SubExprs + Array + getNumPlacementArgs();
9174c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  }
9184c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
9194c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  arg_iterator constructor_arg_begin() {
920cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl    return SubExprs + Array + getNumPlacementArgs();
9214c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  }
9224c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  arg_iterator constructor_arg_end() {
923cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl    return SubExprs + Array + getNumPlacementArgs() + getNumConstructorArgs();
9244c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  }
9254c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  const_arg_iterator constructor_arg_begin() const {
926cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl    return SubExprs + Array + getNumPlacementArgs();
9274c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  }
9284c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  const_arg_iterator constructor_arg_end() const {
929cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl    return SubExprs + Array + getNumPlacementArgs() + getNumConstructorArgs();
9304c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  }
9314c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
9324c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  virtual SourceRange getSourceRange() const {
9334c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl    return SourceRange(StartLoc, EndLoc);
9344c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  }
9354c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
9364c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  static bool classof(const Stmt *T) {
9374c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl    return T->getStmtClass() == CXXNewExprClass;
9384c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  }
9394c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  static bool classof(const CXXNewExpr *) { return true; }
9404c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
9414c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  // Iterators
9424c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  virtual child_iterator child_begin();
9434c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  virtual child_iterator child_end();
9444c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl};
9454c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
9464c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl/// CXXDeleteExpr - A delete expression for memory deallocation and destructor
9474c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl/// calls, e.g. "delete[] pArray".
9484c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redlclass CXXDeleteExpr : public Expr {
9494c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  // Is this a forced global delete, i.e. "::delete"?
9504c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  bool GlobalDelete : 1;
9514c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  // Is this the array form of delete, i.e. "delete[]"?
9524c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  bool ArrayForm : 1;
9534c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  // Points to the operator delete overload that is used. Could be a member.
9544c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  FunctionDecl *OperatorDelete;
9554c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  // The pointer expression to be deleted.
9564c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  Stmt *Argument;
9574c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  // Location of the expression.
9584c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  SourceLocation Loc;
9594c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redlpublic:
9604c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  CXXDeleteExpr(QualType ty, bool globalDelete, bool arrayForm,
9614c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl                FunctionDecl *operatorDelete, Expr *arg, SourceLocation loc)
9622850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl    : Expr(CXXDeleteExprClass, ty, false, false), GlobalDelete(globalDelete),
9634c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl      ArrayForm(arrayForm), OperatorDelete(operatorDelete), Argument(arg),
9644c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl      Loc(loc) { }
9654c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
9664c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  bool isGlobalDelete() const { return GlobalDelete; }
9674c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  bool isArrayForm() const { return ArrayForm; }
9684c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
9694c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  FunctionDecl *getOperatorDelete() const { return OperatorDelete; }
9704c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
9714c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  Expr *getArgument() { return cast<Expr>(Argument); }
9724c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  const Expr *getArgument() const { return cast<Expr>(Argument); }
9734c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
9744c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  virtual SourceRange getSourceRange() const {
9754c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl    return SourceRange(Loc, Argument->getLocEnd());
9764c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  }
9774c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
9784c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  static bool classof(const Stmt *T) {
9794c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl    return T->getStmtClass() == CXXDeleteExprClass;
9804c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  }
9814c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  static bool classof(const CXXDeleteExpr *) { return true; }
9824c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
9834c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  // Iterators
9844c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  virtual child_iterator child_begin();
9854c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  virtual child_iterator child_end();
9864c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl};
9874c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
988a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor/// \brief Represents a C++ pseudo-destructor (C++ [expr.pseudo]).
989a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor///
990a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor/// Example:
991a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor///
992a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor/// \code
9931eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump/// template<typename T>
994a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor/// void destroy(T* ptr) {
995a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor///   ptr->~T();
996a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor/// }
997a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor/// \endcode
998a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor///
999a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor/// When the template is parsed, the expression \c ptr->~T will be stored as
1000a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor/// a member reference expression. If it then instantiated with a scalar type
10011eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump/// as a template argument for T, the resulting expression will be a
1002a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor/// pseudo-destructor expression.
1003a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregorclass CXXPseudoDestructorExpr : public Expr {
1004a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  /// \brief The base expression (that is being destroyed).
1005a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  Stmt *Base;
10061eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1007a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  /// \brief Whether the operator was an arrow ('->'); otherwise, it was a
1008a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  /// period ('.').
1009a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  bool IsArrow : 1;
10101eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1011a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  /// \brief The location of the '.' or '->' operator.
1012a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  SourceLocation OperatorLoc;
10131eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1014a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  /// \brief The nested-name-specifier that follows the operator, if present.
1015a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  NestedNameSpecifier *Qualifier;
10161eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
10171eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  /// \brief The source range that covers the nested-name-specifier, if
1018a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  /// present.
1019a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  SourceRange QualifierRange;
10201eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1021a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  /// \brief The type being destroyed.
1022a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  QualType DestroyedType;
10231eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1024a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  /// \brief The location of the type after the '~'.
1025a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  SourceLocation DestroyedTypeLoc;
10261eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1027a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregorpublic:
1028a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  CXXPseudoDestructorExpr(ASTContext &Context,
1029a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor                          Expr *Base, bool isArrow, SourceLocation OperatorLoc,
1030a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor                          NestedNameSpecifier *Qualifier,
1031a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor                          SourceRange QualifierRange,
10321eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump                          QualType DestroyedType,
1033a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor                          SourceLocation DestroyedTypeLoc)
10341eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump    : Expr(CXXPseudoDestructorExprClass,
1035a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor           Context.getPointerType(Context.getFunctionType(Context.VoidTy, 0, 0,
1036a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor                                                          false, 0)),
1037a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor           /*isTypeDependent=*/false,
1038a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor           /*isValueDependent=*/Base->isValueDependent()),
10391eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump      Base(static_cast<Stmt *>(Base)), IsArrow(isArrow),
1040a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor      OperatorLoc(OperatorLoc), Qualifier(Qualifier),
1041a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor      QualifierRange(QualifierRange), DestroyedType(DestroyedType),
1042a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor      DestroyedTypeLoc(DestroyedTypeLoc) { }
10431eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1044a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  void setBase(Expr *E) { Base = E; }
1045a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  Expr *getBase() const { return cast<Expr>(Base); }
10461eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
10471eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  /// \brief Determines whether this member expression actually had
1048a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  /// a C++ nested-name-specifier prior to the name of the member, e.g.,
1049a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  /// x->Base::foo.
1050a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  bool hasQualifier() const { return Qualifier != 0; }
10511eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1052a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  /// \brief If the member name was qualified, retrieves the source range of
1053a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  /// the nested-name-specifier that precedes the member name. Otherwise,
1054a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  /// returns an empty source range.
1055a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  SourceRange getQualifierRange() const { return QualifierRange; }
10561eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
10571eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  /// \brief If the member name was qualified, retrieves the
1058a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  /// nested-name-specifier that precedes the member name. Otherwise, returns
1059a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  /// NULL.
1060a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  NestedNameSpecifier *getQualifier() const { return Qualifier; }
10611eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1062a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  /// \brief Determine whether this pseudo-destructor expression was written
1063a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  /// using an '->' (otherwise, it used a '.').
1064a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  bool isArrow() const { return IsArrow; }
1065a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  void setArrow(bool A) { IsArrow = A; }
1066a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor
1067a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  /// \brief Retrieve the location of the '.' or '->' operator.
1068a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  SourceLocation getOperatorLoc() const { return OperatorLoc; }
10691eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1070a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  /// \brief Retrieve the type that is being destroyed.
1071a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  QualType getDestroyedType() const { return DestroyedType; }
10721eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1073a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  /// \brief Retrieve the location of the type being destroyed.
1074a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  SourceLocation getDestroyedTypeLoc() const { return DestroyedTypeLoc; }
10751eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1076a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  virtual SourceRange getSourceRange() const {
1077a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor    return SourceRange(Base->getLocStart(), DestroyedTypeLoc);
1078a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  }
10791eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
10801eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  static bool classof(const Stmt *T) {
1081a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor    return T->getStmtClass() == CXXPseudoDestructorExprClass;
1082a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  }
1083a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  static bool classof(const CXXPseudoDestructorExpr *) { return true; }
10841eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1085a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  // Iterators
1086a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  virtual child_iterator child_begin();
10871eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  virtual child_iterator child_end();
1088a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor};
10891eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
109064b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl/// UnaryTypeTraitExpr - A GCC or MS unary type trait, as used in the
109164b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl/// implementation of TR1/C++0x type trait templates.
109264b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl/// Example:
109364b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl/// __is_pod(int) == true
109464b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl/// __is_enum(std::string) == false
109564b45f7e0d3167f040841ac2920aead7f080730dSebastian Redlclass UnaryTypeTraitExpr : public Expr {
109664b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl  /// UTT - The trait.
109764b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl  UnaryTypeTrait UTT;
109864b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl
109964b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl  /// Loc - The location of the type trait keyword.
110064b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl  SourceLocation Loc;
110164b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl
110264b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl  /// RParen - The location of the closing paren.
110364b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl  SourceLocation RParen;
110464b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl
110564b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl  /// QueriedType - The type we're testing.
110664b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl  QualType QueriedType;
110764b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl
110864b45f7e0d3167f040841ac2920aead7f080730dSebastian Redlpublic:
110964b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl  UnaryTypeTraitExpr(SourceLocation loc, UnaryTypeTrait utt, QualType queried,
111064b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl                     SourceLocation rparen, QualType ty)
111164b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl    : Expr(UnaryTypeTraitExprClass, ty, false, queried->isDependentType()),
111264b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl      UTT(utt), Loc(loc), RParen(rparen), QueriedType(queried) { }
111364b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl
111464b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl  virtual SourceRange getSourceRange() const { return SourceRange(Loc, RParen);}
111564b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl
111664b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl  UnaryTypeTrait getTrait() const { return UTT; }
111764b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl
111864b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl  QualType getQueriedType() const { return QueriedType; }
111964b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl
11205e03f9ea8174ae588c5e69ec6b5ef4c68f8fd766Douglas Gregor  bool EvaluateTrait(ASTContext&) const;
112164b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl
112264b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl  static bool classof(const Stmt *T) {
112364b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl    return T->getStmtClass() == UnaryTypeTraitExprClass;
112464b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl  }
112564b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl  static bool classof(const UnaryTypeTraitExpr *) { return true; }
112664b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl
112764b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl  // Iterators
112864b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl  virtual child_iterator child_begin();
112964b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl  virtual child_iterator child_end();
113064b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl};
113164b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl
11327bb12da2b0749eeebb21854c77877736969e59f2John McCall/// \brief A reference to an overloaded function set, either an
11337bb12da2b0749eeebb21854c77877736969e59f2John McCall/// \t UnresolvedLookupExpr or an \t UnresolvedMemberExpr.
11347bb12da2b0749eeebb21854c77877736969e59f2John McCallclass OverloadExpr : public Expr {
1135ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  /// The results.  These are undesugared, which is to say, they may
11367bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// include UsingShadowDecls.  Access is relative to the naming
11377bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// class.
1138eec51cf1ba5f0e62c9cdb81b5c63babdd6e649abJohn McCall  UnresolvedSet<4> Results;
1139ba13543329afac4a0d01304ec2ec4924d99306a6John McCall
11407bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// The common name of these declarations.
1141ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  DeclarationName Name;
1142ba13543329afac4a0d01304ec2ec4924d99306a6John McCall
11437bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// The scope specifier, if any.
1144ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  NestedNameSpecifier *Qualifier;
11457bb12da2b0749eeebb21854c77877736969e59f2John McCall
11467bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// The source range of the scope specifier.
1147ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  SourceRange QualifierRange;
1148ba13543329afac4a0d01304ec2ec4924d99306a6John McCall
1149ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  /// The location of the name.
1150ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  SourceLocation NameLoc;
1151ba13543329afac4a0d01304ec2ec4924d99306a6John McCall
11527bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// True if the name was a template-id.
11537bb12da2b0749eeebb21854c77877736969e59f2John McCall  bool HasExplicitTemplateArgs;
11547bb12da2b0749eeebb21854c77877736969e59f2John McCall
11557bb12da2b0749eeebb21854c77877736969e59f2John McCallprotected:
11567bb12da2b0749eeebb21854c77877736969e59f2John McCall  OverloadExpr(StmtClass K, QualType T, bool Dependent,
11577bb12da2b0749eeebb21854c77877736969e59f2John McCall               NestedNameSpecifier *Qualifier, SourceRange QRange,
11587bb12da2b0749eeebb21854c77877736969e59f2John McCall               DeclarationName Name, SourceLocation NameLoc,
11597bb12da2b0749eeebb21854c77877736969e59f2John McCall               bool HasTemplateArgs)
11607bb12da2b0749eeebb21854c77877736969e59f2John McCall    : Expr(K, T, Dependent, Dependent),
11617bb12da2b0749eeebb21854c77877736969e59f2John McCall      Name(Name), Qualifier(Qualifier), QualifierRange(QRange),
11627bb12da2b0749eeebb21854c77877736969e59f2John McCall      NameLoc(NameLoc), HasExplicitTemplateArgs(HasTemplateArgs)
11637bb12da2b0749eeebb21854c77877736969e59f2John McCall  {}
11647bb12da2b0749eeebb21854c77877736969e59f2John McCall
11657bb12da2b0749eeebb21854c77877736969e59f2John McCallpublic:
11667bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// Computes whether an unresolved lookup on the given declarations
11677bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// and optional template arguments is type- and value-dependent.
11687bb12da2b0749eeebb21854c77877736969e59f2John McCall  static bool ComputeDependence(UnresolvedSetIterator Begin,
11697bb12da2b0749eeebb21854c77877736969e59f2John McCall                                UnresolvedSetIterator End,
11707bb12da2b0749eeebb21854c77877736969e59f2John McCall                                const TemplateArgumentListInfo *Args);
11717bb12da2b0749eeebb21854c77877736969e59f2John McCall
11727bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// Finds the overloaded expression in the given expression of
11737bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// OverloadTy.
11747bb12da2b0749eeebb21854c77877736969e59f2John McCall  ///
11757bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// \return the expression (which must be there) and true if it is
11767bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// within an address-of operator.
11777bb12da2b0749eeebb21854c77877736969e59f2John McCall  static llvm::PointerIntPair<OverloadExpr*,1> find(Expr *E) {
11787bb12da2b0749eeebb21854c77877736969e59f2John McCall    assert(E->getType()->isSpecificBuiltinType(BuiltinType::Overload));
11797bb12da2b0749eeebb21854c77877736969e59f2John McCall
11807bb12da2b0749eeebb21854c77877736969e59f2John McCall    bool op = false;
11817bb12da2b0749eeebb21854c77877736969e59f2John McCall    E = E->IgnoreParens();
11827bb12da2b0749eeebb21854c77877736969e59f2John McCall    if (isa<UnaryOperator>(E))
11837bb12da2b0749eeebb21854c77877736969e59f2John McCall      op = true, E = cast<UnaryOperator>(E)->getSubExpr()->IgnoreParens();
11847bb12da2b0749eeebb21854c77877736969e59f2John McCall    return llvm::PointerIntPair<OverloadExpr*,1>(cast<OverloadExpr>(E), op);
11857bb12da2b0749eeebb21854c77877736969e59f2John McCall  }
11867bb12da2b0749eeebb21854c77877736969e59f2John McCall
11877bb12da2b0749eeebb21854c77877736969e59f2John McCall  void addDecls(UnresolvedSetIterator Begin, UnresolvedSetIterator End) {
11887bb12da2b0749eeebb21854c77877736969e59f2John McCall    Results.append(Begin, End);
11897bb12da2b0749eeebb21854c77877736969e59f2John McCall  }
11907bb12da2b0749eeebb21854c77877736969e59f2John McCall
11917bb12da2b0749eeebb21854c77877736969e59f2John McCall  typedef UnresolvedSetImpl::iterator decls_iterator;
11927bb12da2b0749eeebb21854c77877736969e59f2John McCall  decls_iterator decls_begin() const { return Results.begin(); }
11937bb12da2b0749eeebb21854c77877736969e59f2John McCall  decls_iterator decls_end() const { return Results.end(); }
11947bb12da2b0749eeebb21854c77877736969e59f2John McCall
11957bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// Gets the decls as an unresolved set.
11967bb12da2b0749eeebb21854c77877736969e59f2John McCall  const UnresolvedSetImpl &getDecls() { return Results; }
11977bb12da2b0749eeebb21854c77877736969e59f2John McCall
11987bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// Gets the number of declarations in the unresolved set.
11997bb12da2b0749eeebb21854c77877736969e59f2John McCall  unsigned getNumDecls() const { return Results.size(); }
12007bb12da2b0749eeebb21854c77877736969e59f2John McCall
12017bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// Gets the name looked up.
12027bb12da2b0749eeebb21854c77877736969e59f2John McCall  DeclarationName getName() const { return Name; }
12037bb12da2b0749eeebb21854c77877736969e59f2John McCall  void setName(DeclarationName N) { Name = N; }
12047bb12da2b0749eeebb21854c77877736969e59f2John McCall
12057bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// Gets the location of the name.
12067bb12da2b0749eeebb21854c77877736969e59f2John McCall  SourceLocation getNameLoc() const { return NameLoc; }
12077bb12da2b0749eeebb21854c77877736969e59f2John McCall  void setNameLoc(SourceLocation Loc) { NameLoc = Loc; }
12087bb12da2b0749eeebb21854c77877736969e59f2John McCall
12097bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// Fetches the nested-name qualifier, if one was given.
12107bb12da2b0749eeebb21854c77877736969e59f2John McCall  NestedNameSpecifier *getQualifier() const { return Qualifier; }
12117bb12da2b0749eeebb21854c77877736969e59f2John McCall
12127bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// Fetches the range of the nested-name qualifier.
12137bb12da2b0749eeebb21854c77877736969e59f2John McCall  SourceRange getQualifierRange() const { return QualifierRange; }
12147bb12da2b0749eeebb21854c77877736969e59f2John McCall
12157bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// \brief Determines whether this expression had an explicit
12167bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// template argument list, e.g. f<int>.
12177bb12da2b0749eeebb21854c77877736969e59f2John McCall  bool hasExplicitTemplateArgs() const { return HasExplicitTemplateArgs; }
12187bb12da2b0749eeebb21854c77877736969e59f2John McCall
12197bb12da2b0749eeebb21854c77877736969e59f2John McCall  ExplicitTemplateArgumentList &getExplicitTemplateArgs(); // defined far below
12207bb12da2b0749eeebb21854c77877736969e59f2John McCall
12217bb12da2b0749eeebb21854c77877736969e59f2John McCall  const ExplicitTemplateArgumentList &getExplicitTemplateArgs() const {
12227bb12da2b0749eeebb21854c77877736969e59f2John McCall    return const_cast<OverloadExpr*>(this)->getExplicitTemplateArgs();
12237bb12da2b0749eeebb21854c77877736969e59f2John McCall  }
12247bb12da2b0749eeebb21854c77877736969e59f2John McCall
12257bb12da2b0749eeebb21854c77877736969e59f2John McCall  ExplicitTemplateArgumentList *getOptionalExplicitTemplateArgs() {
12267bb12da2b0749eeebb21854c77877736969e59f2John McCall    if (hasExplicitTemplateArgs())
12277bb12da2b0749eeebb21854c77877736969e59f2John McCall      return &getExplicitTemplateArgs();
12287bb12da2b0749eeebb21854c77877736969e59f2John McCall    return 0;
12297bb12da2b0749eeebb21854c77877736969e59f2John McCall  }
12307bb12da2b0749eeebb21854c77877736969e59f2John McCall
12317bb12da2b0749eeebb21854c77877736969e59f2John McCall  static bool classof(const Stmt *T) {
12327bb12da2b0749eeebb21854c77877736969e59f2John McCall    return T->getStmtClass() == UnresolvedLookupExprClass ||
12337bb12da2b0749eeebb21854c77877736969e59f2John McCall           T->getStmtClass() == UnresolvedMemberExprClass;
12347bb12da2b0749eeebb21854c77877736969e59f2John McCall  }
12357bb12da2b0749eeebb21854c77877736969e59f2John McCall  static bool classof(const OverloadExpr *) { return true; }
12367bb12da2b0749eeebb21854c77877736969e59f2John McCall};
12377bb12da2b0749eeebb21854c77877736969e59f2John McCall
12387bb12da2b0749eeebb21854c77877736969e59f2John McCall/// \brief A reference to a name which we were able to look up during
12397bb12da2b0749eeebb21854c77877736969e59f2John McCall/// parsing but could not resolve to a specific declaration.  This
12407bb12da2b0749eeebb21854c77877736969e59f2John McCall/// arises in several ways:
12417bb12da2b0749eeebb21854c77877736969e59f2John McCall///   * we might be waiting for argument-dependent lookup
12427bb12da2b0749eeebb21854c77877736969e59f2John McCall///   * the name might resolve to an overloaded function
12437bb12da2b0749eeebb21854c77877736969e59f2John McCall/// and eventually:
12447bb12da2b0749eeebb21854c77877736969e59f2John McCall///   * the lookup might have included a function template
12457bb12da2b0749eeebb21854c77877736969e59f2John McCall/// These never include UnresolvedUsingValueDecls, which are always
12467bb12da2b0749eeebb21854c77877736969e59f2John McCall/// class members and therefore appear only in
12477bb12da2b0749eeebb21854c77877736969e59f2John McCall/// UnresolvedMemberLookupExprs.
12487bb12da2b0749eeebb21854c77877736969e59f2John McCallclass UnresolvedLookupExpr : public OverloadExpr {
1249ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  /// True if these lookup results should be extended by
1250ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  /// argument-dependent lookup if this is the operand of a function
1251ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  /// call.
1252ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  bool RequiresADL;
1253ba13543329afac4a0d01304ec2ec4924d99306a6John McCall
12547453ed4cb2cab113de3378df371b1c6f1243d832John McCall  /// True if these lookup results are overloaded.  This is pretty
12557453ed4cb2cab113de3378df371b1c6f1243d832John McCall  /// trivially rederivable if we urgently need to kill this field.
12567453ed4cb2cab113de3378df371b1c6f1243d832John McCall  bool Overloaded;
12577453ed4cb2cab113de3378df371b1c6f1243d832John McCall
12587bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// The naming class (C++ [class.access.base]p5) of the lookup, if
12597bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// any.  This can generally be recalculated from the context chain,
12607bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// but that can be fairly expensive for unqualified lookups.  If we
12617bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// want to improve memory use here, this could go in a union
12627bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// against the qualified-lookup bits.
12637bb12da2b0749eeebb21854c77877736969e59f2John McCall  CXXRecordDecl *NamingClass;
1264f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall
1265c373d48502ca7683ab55385f5bd624d778eb288dJohn McCall  UnresolvedLookupExpr(QualType T, bool Dependent, CXXRecordDecl *NamingClass,
1266ba13543329afac4a0d01304ec2ec4924d99306a6John McCall                       NestedNameSpecifier *Qualifier, SourceRange QRange,
1267ba13543329afac4a0d01304ec2ec4924d99306a6John McCall                       DeclarationName Name, SourceLocation NameLoc,
1268f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall                       bool RequiresADL, bool Overloaded, bool HasTemplateArgs)
12697bb12da2b0749eeebb21854c77877736969e59f2John McCall    : OverloadExpr(UnresolvedLookupExprClass, T, Dependent, Qualifier, QRange,
12707bb12da2b0749eeebb21854c77877736969e59f2John McCall                   Name, NameLoc, HasTemplateArgs),
12717bb12da2b0749eeebb21854c77877736969e59f2John McCall      RequiresADL(RequiresADL), Overloaded(Overloaded), NamingClass(NamingClass)
1272ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  {}
1273ba13543329afac4a0d01304ec2ec4924d99306a6John McCall
1274ba13543329afac4a0d01304ec2ec4924d99306a6John McCallpublic:
1275ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  static UnresolvedLookupExpr *Create(ASTContext &C,
1276f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall                                      bool Dependent,
1277c373d48502ca7683ab55385f5bd624d778eb288dJohn McCall                                      CXXRecordDecl *NamingClass,
1278ba13543329afac4a0d01304ec2ec4924d99306a6John McCall                                      NestedNameSpecifier *Qualifier,
1279ba13543329afac4a0d01304ec2ec4924d99306a6John McCall                                      SourceRange QualifierRange,
1280ba13543329afac4a0d01304ec2ec4924d99306a6John McCall                                      DeclarationName Name,
1281ba13543329afac4a0d01304ec2ec4924d99306a6John McCall                                      SourceLocation NameLoc,
12827453ed4cb2cab113de3378df371b1c6f1243d832John McCall                                      bool ADL, bool Overloaded) {
1283f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall    return new(C) UnresolvedLookupExpr(Dependent ? C.DependentTy : C.OverloadTy,
1284c373d48502ca7683ab55385f5bd624d778eb288dJohn McCall                                       Dependent, NamingClass,
1285c373d48502ca7683ab55385f5bd624d778eb288dJohn McCall                                       Qualifier, QualifierRange,
1286f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall                                       Name, NameLoc, ADL, Overloaded, false);
1287ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  }
1288ba13543329afac4a0d01304ec2ec4924d99306a6John McCall
1289f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  static UnresolvedLookupExpr *Create(ASTContext &C,
1290f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall                                      bool Dependent,
1291c373d48502ca7683ab55385f5bd624d778eb288dJohn McCall                                      CXXRecordDecl *NamingClass,
1292f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall                                      NestedNameSpecifier *Qualifier,
1293f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall                                      SourceRange QualifierRange,
1294f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall                                      DeclarationName Name,
1295f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall                                      SourceLocation NameLoc,
1296f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall                                      bool ADL,
1297f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall                                      const TemplateArgumentListInfo &Args);
1298f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall
1299ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  /// True if this declaration should be extended by
1300ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  /// argument-dependent lookup.
1301ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  bool requiresADL() const { return RequiresADL; }
1302ba13543329afac4a0d01304ec2ec4924d99306a6John McCall
13037453ed4cb2cab113de3378df371b1c6f1243d832John McCall  /// True if this lookup is overloaded.
13047453ed4cb2cab113de3378df371b1c6f1243d832John McCall  bool isOverloaded() const { return Overloaded; }
13057453ed4cb2cab113de3378df371b1c6f1243d832John McCall
1306c373d48502ca7683ab55385f5bd624d778eb288dJohn McCall  /// Gets the 'naming class' (in the sense of C++0x
1307c373d48502ca7683ab55385f5bd624d778eb288dJohn McCall  /// [class.access.base]p5) of the lookup.  This is the scope
1308c373d48502ca7683ab55385f5bd624d778eb288dJohn McCall  /// that was looked in to find these results.
1309c373d48502ca7683ab55385f5bd624d778eb288dJohn McCall  CXXRecordDecl *getNamingClass() const { return NamingClass; }
1310c373d48502ca7683ab55385f5bd624d778eb288dJohn McCall
1311f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  // Note that, inconsistently with the explicit-template-argument AST
1312f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  // nodes, users are *forbidden* from calling these methods on objects
1313f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  // without explicit template arguments.
1314f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall
13157bb12da2b0749eeebb21854c77877736969e59f2John McCall  ExplicitTemplateArgumentList &getExplicitTemplateArgs() {
13167bb12da2b0749eeebb21854c77877736969e59f2John McCall    assert(hasExplicitTemplateArgs());
13177bb12da2b0749eeebb21854c77877736969e59f2John McCall    return *reinterpret_cast<ExplicitTemplateArgumentList*>(this + 1);
13187bb12da2b0749eeebb21854c77877736969e59f2John McCall  }
13197bb12da2b0749eeebb21854c77877736969e59f2John McCall
1320f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  /// Gets a reference to the explicit template argument list.
1321f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  const ExplicitTemplateArgumentList &getExplicitTemplateArgs() const {
1322f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall    assert(hasExplicitTemplateArgs());
1323f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall    return *reinterpret_cast<const ExplicitTemplateArgumentList*>(this + 1);
1324f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  }
1325f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall
1326f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  /// \brief Copies the template arguments (if present) into the given
1327f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  /// structure.
1328f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  void copyTemplateArgumentsInto(TemplateArgumentListInfo &List) const {
1329f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall    getExplicitTemplateArgs().copyInto(List);
1330f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  }
1331ba13543329afac4a0d01304ec2ec4924d99306a6John McCall
1332f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  SourceLocation getLAngleLoc() const {
1333f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall    return getExplicitTemplateArgs().LAngleLoc;
1334f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  }
1335f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall
1336f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  SourceLocation getRAngleLoc() const {
1337f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall    return getExplicitTemplateArgs().RAngleLoc;
1338f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  }
1339f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall
1340f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  TemplateArgumentLoc const *getTemplateArgs() const {
1341f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall    return getExplicitTemplateArgs().getTemplateArgs();
1342f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  }
1343f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall
1344f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  unsigned getNumTemplateArgs() const {
1345f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall    return getExplicitTemplateArgs().NumTemplateArgs;
1346f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  }
1347ba13543329afac4a0d01304ec2ec4924d99306a6John McCall
1348ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  virtual SourceRange getSourceRange() const {
13497bb12da2b0749eeebb21854c77877736969e59f2John McCall    SourceRange Range(getNameLoc());
13507bb12da2b0749eeebb21854c77877736969e59f2John McCall    if (getQualifier()) Range.setBegin(getQualifierRange().getBegin());
1351f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall    if (hasExplicitTemplateArgs()) Range.setEnd(getRAngleLoc());
1352f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall    return Range;
1353ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  }
1354ba13543329afac4a0d01304ec2ec4924d99306a6John McCall
1355ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  virtual StmtIterator child_begin();
1356ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  virtual StmtIterator child_end();
1357ba13543329afac4a0d01304ec2ec4924d99306a6John McCall
1358ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  static bool classof(const Stmt *T) {
1359ba13543329afac4a0d01304ec2ec4924d99306a6John McCall    return T->getStmtClass() == UnresolvedLookupExprClass;
1360ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  }
1361ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  static bool classof(const UnresolvedLookupExpr *) { return true; }
1362ba13543329afac4a0d01304ec2ec4924d99306a6John McCall};
1363ba13543329afac4a0d01304ec2ec4924d99306a6John McCall
13645953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor/// \brief A qualified reference to a name whose declaration cannot
13655953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor/// yet be resolved.
13665953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor///
1367ba13543329afac4a0d01304ec2ec4924d99306a6John McCall/// DependentScopeDeclRefExpr is similar to DeclRefExpr in that
1368a2813cec2605ce7878d1b13471d685f689b251afDouglas Gregor/// it expresses a reference to a declaration such as
13695953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor/// X<T>::value. The difference, however, is that an
1370865d447ac6a4721ab58e898d014a21f2eff74b06John McCall/// DependentScopeDeclRefExpr node is used only within C++ templates when
13715953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor/// the qualification (e.g., X<T>::) refers to a dependent type. In
13725953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor/// this case, X<T>::value cannot resolve to a declaration because the
13735953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor/// declaration will differ from on instantiation of X<T> to the
1374865d447ac6a4721ab58e898d014a21f2eff74b06John McCall/// next. Therefore, DependentScopeDeclRefExpr keeps track of the
1375ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor/// qualifier (X<T>::) and the name of the entity being referenced
1376a2813cec2605ce7878d1b13471d685f689b251afDouglas Gregor/// ("value"). Such expressions will instantiate to a DeclRefExpr once the
1377a2813cec2605ce7878d1b13471d685f689b251afDouglas Gregor/// declaration can be found.
1378865d447ac6a4721ab58e898d014a21f2eff74b06John McCallclass DependentScopeDeclRefExpr : public Expr {
13795953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor  /// The name of the entity we will be referencing.
13805953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor  DeclarationName Name;
13815953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor
13825953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor  /// Location of the name of the declaration we're referencing.
13835953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor  SourceLocation Loc;
13845953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor
13855953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor  /// QualifierRange - The source range that covers the
13865953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor  /// nested-name-specifier.
13875953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor  SourceRange QualifierRange;
13885953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor
1389ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor  /// \brief The nested-name-specifier that qualifies this unresolved
1390ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor  /// declaration name.
1391f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  NestedNameSpecifier *Qualifier;
13925953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor
1393f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  /// \brief Whether the name includes explicit template arguments.
1394f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  bool HasExplicitTemplateArgs;
13951eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1396f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  DependentScopeDeclRefExpr(QualType T,
1397f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall                            NestedNameSpecifier *Qualifier,
1398f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall                            SourceRange QualifierRange,
1399f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall                            DeclarationName Name,
1400f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall                            SourceLocation NameLoc,
1401f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall                            bool HasExplicitTemplateArgs)
1402865d447ac6a4721ab58e898d014a21f2eff74b06John McCall    : Expr(DependentScopeDeclRefExprClass, T, true, true),
1403f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall      Name(Name), Loc(NameLoc),
1404f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall      QualifierRange(QualifierRange), Qualifier(Qualifier),
1405f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall      HasExplicitTemplateArgs(HasExplicitTemplateArgs)
1406f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  {}
1407f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall
1408f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCallpublic:
1409f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  static DependentScopeDeclRefExpr *Create(ASTContext &C,
1410f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall                                           NestedNameSpecifier *Qualifier,
1411f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall                                           SourceRange QualifierRange,
1412f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall                                           DeclarationName Name,
1413f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall                                           SourceLocation NameLoc,
1414f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall                              const TemplateArgumentListInfo *TemplateArgs = 0);
14155953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor
14165953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor  /// \brief Retrieve the name that this expression refers to.
14175953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor  DeclarationName getDeclName() const { return Name; }
14185953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor
14195953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor  /// \brief Retrieve the location of the name within the expression.
14205953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor  SourceLocation getLocation() const { return Loc; }
14215953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor
14225953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor  /// \brief Retrieve the source range of the nested-name-specifier.
14235953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor  SourceRange getQualifierRange() const { return QualifierRange; }
14245953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor
1425ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor  /// \brief Retrieve the nested-name-specifier that qualifies this
1426ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor  /// declaration.
1427edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor  NestedNameSpecifier *getQualifier() const { return Qualifier; }
14281eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1429f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  /// Determines whether this lookup had explicit template arguments.
1430f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  bool hasExplicitTemplateArgs() const { return HasExplicitTemplateArgs; }
14311eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1432f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  // Note that, inconsistently with the explicit-template-argument AST
1433f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  // nodes, users are *forbidden* from calling these methods on objects
1434f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  // without explicit template arguments.
14351eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1436f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  /// Gets a reference to the explicit template argument list.
1437f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  const ExplicitTemplateArgumentList &getExplicitTemplateArgs() const {
1438f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall    assert(hasExplicitTemplateArgs());
1439f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall    return *reinterpret_cast<const ExplicitTemplateArgumentList*>(this + 1);
1440f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  }
14411eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1442f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  /// \brief Copies the template arguments (if present) into the given
1443f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  /// structure.
1444f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  void copyTemplateArgumentsInto(TemplateArgumentListInfo &List) const {
1445f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall    getExplicitTemplateArgs().copyInto(List);
1446f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  }
1447f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall
1448f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  SourceLocation getLAngleLoc() const {
1449f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall    return getExplicitTemplateArgs().LAngleLoc;
1450edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor  }
14511eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1452f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  SourceLocation getRAngleLoc() const {
1453f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall    return getExplicitTemplateArgs().RAngleLoc;
1454f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  }
14551eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1456f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  TemplateArgumentLoc const *getTemplateArgs() const {
1457f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall    return getExplicitTemplateArgs().getTemplateArgs();
1458d5532b6cfff2977e0c59fa6ead7f7973984a620dJohn McCall  }
1459d5532b6cfff2977e0c59fa6ead7f7973984a620dJohn McCall
1460f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  unsigned getNumTemplateArgs() const {
1461f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall    return getExplicitTemplateArgs().NumTemplateArgs;
1462f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  }
14631eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1464edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor  virtual SourceRange getSourceRange() const {
1465f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall    SourceRange Range(QualifierRange.getBegin(), getLocation());
1466f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall    if (hasExplicitTemplateArgs())
1467f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall      Range.setEnd(getRAngleLoc());
1468f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall    return Range;
1469edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor  }
14701eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
14711eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  static bool classof(const Stmt *T) {
1472f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall    return T->getStmtClass() == DependentScopeDeclRefExprClass;
1473edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor  }
1474f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  static bool classof(const DependentScopeDeclRefExpr *) { return true; }
1475f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall
1476f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  virtual StmtIterator child_begin();
1477f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  virtual StmtIterator child_end();
1478edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor};
14791eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
14802d44e8a41de8a33c0f04ac198714f71dc841bab0Anders Carlssonclass CXXExprWithTemporaries : public Expr {
148102bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson  Stmt *SubExpr;
14821eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1483ff6b3d64c9f07155f1414411b8451d7bf8937c62Anders Carlsson  CXXTemporary **Temps;
1484ff6b3d64c9f07155f1414411b8451d7bf8937c62Anders Carlsson  unsigned NumTemps;
148502bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson
14861eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  CXXExprWithTemporaries(Expr *SubExpr, CXXTemporary **Temps,
14870ece491d8f62ce67f047491a6703fac0d3bd4ff4Anders Carlsson                         unsigned NumTemps);
14882d44e8a41de8a33c0f04ac198714f71dc841bab0Anders Carlsson  ~CXXExprWithTemporaries();
148942602bb40aefcc2751d4078ba88aacf4d965c9bdDouglas Gregor
149042602bb40aefcc2751d4078ba88aacf4d965c9bdDouglas Gregorprotected:
149142602bb40aefcc2751d4078ba88aacf4d965c9bdDouglas Gregor  virtual void DoDestroy(ASTContext &C);
149242602bb40aefcc2751d4078ba88aacf4d965c9bdDouglas Gregor
149388eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlssonpublic:
149488eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlsson  static CXXExprWithTemporaries *Create(ASTContext &C, Expr *SubExpr,
14950ece491d8f62ce67f047491a6703fac0d3bd4ff4Anders Carlsson                                        CXXTemporary **Temps,
14960ece491d8f62ce67f047491a6703fac0d3bd4ff4Anders Carlsson                                        unsigned NumTemps);
14971eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
149888eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlsson  unsigned getNumTemporaries() const { return NumTemps; }
149988eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlsson  CXXTemporary *getTemporary(unsigned i) {
150088eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlsson    assert(i < NumTemps && "Index out of range");
150188eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlsson    return Temps[i];
150288eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlsson  }
1503f0721fe438d7e40c168e5d664970e7830bc138fbAnders Carlsson  const CXXTemporary *getTemporary(unsigned i) const {
15040ece491d8f62ce67f047491a6703fac0d3bd4ff4Anders Carlsson    return const_cast<CXXExprWithTemporaries*>(this)->getTemporary(i);
1505f0721fe438d7e40c168e5d664970e7830bc138fbAnders Carlsson  }
15061eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
150702bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson  Expr *getSubExpr() { return cast<Expr>(SubExpr); }
1508f0721fe438d7e40c168e5d664970e7830bc138fbAnders Carlsson  const Expr *getSubExpr() const { return cast<Expr>(SubExpr); }
150988eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlsson  void setSubExpr(Expr *E) { SubExpr = E; }
151002bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson
151196be6917e1c4ba1f4435a14c9e7c6c139571d086Douglas Gregor  virtual SourceRange getSourceRange() const {
151296be6917e1c4ba1f4435a14c9e7c6c139571d086Douglas Gregor    return SubExpr->getSourceRange();
151396be6917e1c4ba1f4435a14c9e7c6c139571d086Douglas Gregor  }
151402bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson
151502bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson  // Implement isa/cast/dyncast/etc.
151602bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson  static bool classof(const Stmt *T) {
15172d44e8a41de8a33c0f04ac198714f71dc841bab0Anders Carlsson    return T->getStmtClass() == CXXExprWithTemporariesClass;
151802bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson  }
15192d44e8a41de8a33c0f04ac198714f71dc841bab0Anders Carlsson  static bool classof(const CXXExprWithTemporaries *) { return true; }
152002bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson
152102bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson  // Iterators
152202bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson  virtual child_iterator child_begin();
152302bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson  virtual child_iterator child_end();
152402bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson};
152502bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson
1526d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// \brief Describes an explicit type conversion that uses functional
1527d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// notion but could not be resolved because one or more arguments are
1528d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// type-dependent.
1529d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor///
1530d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// The explicit type conversions expressed by
1531d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// CXXUnresolvedConstructExpr have the form \c T(a1, a2, ..., aN),
1532d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// where \c T is some type and \c a1, a2, ..., aN are values, and
1533d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// either \C T is a dependent type or one or more of the \c a's is
1534d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// type-dependent. For example, this would occur in a template such
1535d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// as:
1536d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor///
1537d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// \code
1538d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor///   template<typename T, typename A1>
1539d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor///   inline T make_a(const A1& a1) {
1540d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor///     return T(a1);
1541d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor///   }
1542d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// \endcode
1543d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor///
1544d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// When the returned expression is instantiated, it may resolve to a
1545d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// constructor call, conversion function call, or some kind of type
1546d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// conversion.
1547d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregorclass CXXUnresolvedConstructExpr : public Expr {
1548d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  /// \brief The starting location of the type
1549d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  SourceLocation TyBeginLoc;
1550d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor
1551d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  /// \brief The type being constructed.
1552d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  QualType Type;
1553d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor
1554d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  /// \brief The location of the left parentheses ('(').
1555d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  SourceLocation LParenLoc;
1556d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor
1557d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  /// \brief The location of the right parentheses (')').
1558d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  SourceLocation RParenLoc;
1559d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor
1560d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  /// \brief The number of arguments used to construct the type.
1561d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  unsigned NumArgs;
15621eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1563d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  CXXUnresolvedConstructExpr(SourceLocation TyBegin,
1564d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor                             QualType T,
1565d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor                             SourceLocation LParenLoc,
1566d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor                             Expr **Args,
1567d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor                             unsigned NumArgs,
1568d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor                             SourceLocation RParenLoc);
1569d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor
1570d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregorpublic:
15711eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  static CXXUnresolvedConstructExpr *Create(ASTContext &C,
1572d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor                                            SourceLocation TyBegin,
1573d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor                                            QualType T,
1574d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor                                            SourceLocation LParenLoc,
1575d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor                                            Expr **Args,
1576d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor                                            unsigned NumArgs,
1577d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor                                            SourceLocation RParenLoc);
1578d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor
1579d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  /// \brief Retrieve the source location where the type begins.
1580d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  SourceLocation getTypeBeginLoc() const { return TyBeginLoc; }
1581d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  void setTypeBeginLoc(SourceLocation L) { TyBeginLoc = L; }
1582d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor
1583d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  /// \brief Retrieve the type that is being constructed, as specified
1584d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  /// in the source code.
1585d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  QualType getTypeAsWritten() const { return Type; }
1586d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  void setTypeAsWritten(QualType T) { Type = T; }
1587d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor
1588d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  /// \brief Retrieve the location of the left parentheses ('(') that
1589d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  /// precedes the argument list.
1590d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  SourceLocation getLParenLoc() const { return LParenLoc; }
1591d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  void setLParenLoc(SourceLocation L) { LParenLoc = L; }
1592d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor
1593d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  /// \brief Retrieve the location of the right parentheses (')') that
1594d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  /// follows the argument list.
1595d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  SourceLocation getRParenLoc() const { return RParenLoc; }
1596d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  void setRParenLoc(SourceLocation L) { RParenLoc = L; }
1597d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor
1598d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  /// \brief Retrieve the number of arguments.
1599d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  unsigned arg_size() const { return NumArgs; }
1600d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor
1601d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  typedef Expr** arg_iterator;
1602d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  arg_iterator arg_begin() { return reinterpret_cast<Expr**>(this + 1); }
1603d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  arg_iterator arg_end() { return arg_begin() + NumArgs; }
1604d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor
16051dd7383dc48718c452e71a625b29531dd96fbb9dJohn McCall  typedef const Expr* const * const_arg_iterator;
16061dd7383dc48718c452e71a625b29531dd96fbb9dJohn McCall  const_arg_iterator arg_begin() const {
16071dd7383dc48718c452e71a625b29531dd96fbb9dJohn McCall    return reinterpret_cast<const Expr* const *>(this + 1);
16081dd7383dc48718c452e71a625b29531dd96fbb9dJohn McCall  }
16091dd7383dc48718c452e71a625b29531dd96fbb9dJohn McCall  const_arg_iterator arg_end() const {
16101dd7383dc48718c452e71a625b29531dd96fbb9dJohn McCall    return arg_begin() + NumArgs;
16111dd7383dc48718c452e71a625b29531dd96fbb9dJohn McCall  }
16121dd7383dc48718c452e71a625b29531dd96fbb9dJohn McCall
1613d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  Expr *getArg(unsigned I) {
1614d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor    assert(I < NumArgs && "Argument index out-of-range");
1615d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor    return *(arg_begin() + I);
1616d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  }
1617d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor
16181dd7383dc48718c452e71a625b29531dd96fbb9dJohn McCall  const Expr *getArg(unsigned I) const {
16191dd7383dc48718c452e71a625b29531dd96fbb9dJohn McCall    assert(I < NumArgs && "Argument index out-of-range");
16201dd7383dc48718c452e71a625b29531dd96fbb9dJohn McCall    return *(arg_begin() + I);
16211dd7383dc48718c452e71a625b29531dd96fbb9dJohn McCall  }
16221dd7383dc48718c452e71a625b29531dd96fbb9dJohn McCall
1623d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  virtual SourceRange getSourceRange() const {
1624d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor    return SourceRange(TyBeginLoc, RParenLoc);
1625d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  }
16261eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  static bool classof(const Stmt *T) {
1627d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor    return T->getStmtClass() == CXXUnresolvedConstructExprClass;
1628d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  }
1629d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  static bool classof(const CXXUnresolvedConstructExpr *) { return true; }
1630d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor
1631d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  // Iterators
1632d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  virtual child_iterator child_begin();
1633d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  virtual child_iterator child_end();
1634d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor};
1635d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor
1636ba13543329afac4a0d01304ec2ec4924d99306a6John McCall/// \brief Represents a C++ member access expression where the actual
1637ba13543329afac4a0d01304ec2ec4924d99306a6John McCall/// member referenced could not be resolved because the base
1638ba13543329afac4a0d01304ec2ec4924d99306a6John McCall/// expression or the member name was dependent.
1639aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall///
1640aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall/// Like UnresolvedMemberExprs, these can be either implicit or
1641aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall/// explicit accesses.  It is only possible to get one of these with
1642aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall/// an implicit access if a qualifier is provided.
1643865d447ac6a4721ab58e898d014a21f2eff74b06John McCallclass CXXDependentScopeMemberExpr : public Expr {
16441c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  /// \brief The expression for the base pointer or class reference,
1645aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall  /// e.g., the \c x in x.f.  Can be null in implicit accesses.
16461c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  Stmt *Base;
16471eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1648aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall  /// \brief The type of the base expression.  Never null, even for
1649aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall  /// implicit accesses.
1650aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall  QualType BaseType;
1651aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall
16521c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  /// \brief Whether this member expression used the '->' operator or
16531c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  /// the '.' operator.
16543b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor  bool IsArrow : 1;
16551c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor
16563b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor  /// \brief Whether this member expression has explicitly-specified template
16573b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor  /// arguments.
1658aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall  bool HasExplicitTemplateArgs : 1;
16591eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
16601c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  /// \brief The location of the '->' or '.' operator.
16611c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  SourceLocation OperatorLoc;
16621c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor
1663a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor  /// \brief The nested-name-specifier that precedes the member name, if any.
1664a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor  NestedNameSpecifier *Qualifier;
16651eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1666a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor  /// \brief The source range covering the nested name specifier.
1667a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor  SourceRange QualifierRange;
16681eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1669c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor  /// \brief In a qualified member access expression such as t->Base::f, this
16701eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  /// member stores the resolves of name lookup in the context of the member
1671c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor  /// access expression, to be used at instantiation time.
1672c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor  ///
1673c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor  /// FIXME: This member, along with the Qualifier and QualifierRange, could
1674c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor  /// be stuck into a structure that is optionally allocated at the end of
1675865d447ac6a4721ab58e898d014a21f2eff74b06John McCall  /// the CXXDependentScopeMemberExpr, to save space in the common case.
1676c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor  NamedDecl *FirstQualifierFoundInScope;
16771eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
16781c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  /// \brief The member to which this member expression refers, which
16791c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  /// can be name, overloaded operator, or destructor.
1680a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor  /// FIXME: could also be a template-id
16811c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  DeclarationName Member;
16821c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor
16831c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  /// \brief The location of the member name.
16841c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  SourceLocation MemberLoc;
16851eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
16863b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor  /// \brief Retrieve the explicit template argument list that followed the
16873b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor  /// member template name, if any.
16883b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor  ExplicitTemplateArgumentList *getExplicitTemplateArgumentList() {
1689aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall    assert(HasExplicitTemplateArgs);
16903b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor    return reinterpret_cast<ExplicitTemplateArgumentList *>(this + 1);
16913b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor  }
16921eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
16933b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor  /// \brief Retrieve the explicit template argument list that followed the
16943b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor  /// member template name, if any.
16953b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor  const ExplicitTemplateArgumentList *getExplicitTemplateArgumentList() const {
1696865d447ac6a4721ab58e898d014a21f2eff74b06John McCall    return const_cast<CXXDependentScopeMemberExpr *>(this)
16973b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor             ->getExplicitTemplateArgumentList();
16983b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor  }
16991eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1700865d447ac6a4721ab58e898d014a21f2eff74b06John McCall  CXXDependentScopeMemberExpr(ASTContext &C,
1701aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall                          Expr *Base, QualType BaseType, bool IsArrow,
17023b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor                          SourceLocation OperatorLoc,
17033b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor                          NestedNameSpecifier *Qualifier,
17043b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor                          SourceRange QualifierRange,
17053b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor                          NamedDecl *FirstQualifierFoundInScope,
17063b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor                          DeclarationName Member,
17073b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor                          SourceLocation MemberLoc,
1708d5532b6cfff2977e0c59fa6ead7f7973984a620dJohn McCall                          const TemplateArgumentListInfo *TemplateArgs);
17091eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
17101c0ca59416999129d0439c2661d137ef38e86209Douglas Gregorpublic:
1711865d447ac6a4721ab58e898d014a21f2eff74b06John McCall  CXXDependentScopeMemberExpr(ASTContext &C,
1712aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall                          Expr *Base, QualType BaseType,
1713aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall                          bool IsArrow,
17141c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor                          SourceLocation OperatorLoc,
1715a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor                          NestedNameSpecifier *Qualifier,
1716a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor                          SourceRange QualifierRange,
1717c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor                          NamedDecl *FirstQualifierFoundInScope,
17181c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor                          DeclarationName Member,
17191c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor                          SourceLocation MemberLoc)
1720865d447ac6a4721ab58e898d014a21f2eff74b06John McCall  : Expr(CXXDependentScopeMemberExprClass, C.DependentTy, true, true),
1721aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall    Base(Base), BaseType(BaseType), IsArrow(IsArrow),
1722aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall    HasExplicitTemplateArgs(false), OperatorLoc(OperatorLoc),
17233b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor    Qualifier(Qualifier), QualifierRange(QualifierRange),
17243b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor    FirstQualifierFoundInScope(FirstQualifierFoundInScope),
17253b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor    Member(Member), MemberLoc(MemberLoc) { }
17261eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1727865d447ac6a4721ab58e898d014a21f2eff74b06John McCall  static CXXDependentScopeMemberExpr *
17281eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  Create(ASTContext &C,
1729aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall         Expr *Base, QualType BaseType, bool IsArrow,
17303b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor         SourceLocation OperatorLoc,
17313b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor         NestedNameSpecifier *Qualifier,
17323b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor         SourceRange QualifierRange,
17333b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor         NamedDecl *FirstQualifierFoundInScope,
17343b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor         DeclarationName Member,
17353b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor         SourceLocation MemberLoc,
1736d5532b6cfff2977e0c59fa6ead7f7973984a620dJohn McCall         const TemplateArgumentListInfo *TemplateArgs);
17371eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1738aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall  /// \brief True if this is an implicit access, i.e. one in which the
1739aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall  /// member being accessed was not written in the source.  The source
1740aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall  /// location of the operator is invalid in this case.
1741aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall  bool isImplicitAccess() const { return Base == 0; }
1742aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall
17431c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  /// \brief Retrieve the base object of this member expressions,
17441c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  /// e.g., the \c x in \c x.m.
1745aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall  Expr *getBase() const {
1746aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall    assert(!isImplicitAccess());
1747aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall    return cast<Expr>(Base);
1748aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall  }
17491c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  void setBase(Expr *E) { Base = E; }
17501c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor
1751aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall  QualType getBaseType() const { return BaseType; }
1752aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall
17531c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  /// \brief Determine whether this member expression used the '->'
17541c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  /// operator; otherwise, it used the '.' operator.
17551c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  bool isArrow() const { return IsArrow; }
17561c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  void setArrow(bool A) { IsArrow = A; }
17571c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor
17581c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  /// \brief Retrieve the location of the '->' or '.' operator.
17591c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  SourceLocation getOperatorLoc() const { return OperatorLoc; }
17601c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  void setOperatorLoc(SourceLocation L) { OperatorLoc = L; }
17611c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor
1762a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor  /// \brief Retrieve the nested-name-specifier that qualifies the member
1763a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor  /// name.
1764a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor  NestedNameSpecifier *getQualifier() const { return Qualifier; }
17651eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1766a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor  /// \brief Retrieve the source range covering the nested-name-specifier
1767a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor  /// that qualifies the member name.
1768a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor  SourceRange getQualifierRange() const { return QualifierRange; }
17691eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1770c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor  /// \brief Retrieve the first part of the nested-name-specifier that was
1771c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor  /// found in the scope of the member access expression when the member access
1772c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor  /// was initially parsed.
1773c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor  ///
1774c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor  /// This function only returns a useful result when member access expression
17751eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  /// uses a qualified member name, e.g., "x.Base::f". Here, the declaration
17761eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  /// returned by this function describes what was found by unqualified name
1777c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor  /// lookup for the identifier "Base" within the scope of the member access
1778c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor  /// expression itself. At template instantiation time, this information is
1779c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor  /// combined with the results of name lookup into the type of the object
1780c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor  /// expression itself (the class type of x).
17811eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  NamedDecl *getFirstQualifierFoundInScope() const {
1782c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor    return FirstQualifierFoundInScope;
1783c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor  }
17841eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
17851c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  /// \brief Retrieve the name of the member that this expression
17861c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  /// refers to.
17871c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  DeclarationName getMember() const { return Member; }
17881c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  void setMember(DeclarationName N) { Member = N; }
17891c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor
17901c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  // \brief Retrieve the location of the name of the member that this
17911c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  // expression refers to.
17921c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  SourceLocation getMemberLoc() const { return MemberLoc; }
17931c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  void setMemberLoc(SourceLocation L) { MemberLoc = L; }
17941c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor
17953b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor  /// \brief Determines whether this member expression actually had a C++
17963b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor  /// template argument list explicitly specified, e.g., x.f<int>.
1797aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall  bool hasExplicitTemplateArgs() const {
1798aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall    return HasExplicitTemplateArgs;
17993b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor  }
18001eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1801d5532b6cfff2977e0c59fa6ead7f7973984a620dJohn McCall  /// \brief Copies the template arguments (if present) into the given
1802d5532b6cfff2977e0c59fa6ead7f7973984a620dJohn McCall  /// structure.
1803d5532b6cfff2977e0c59fa6ead7f7973984a620dJohn McCall  void copyTemplateArgumentsInto(TemplateArgumentListInfo &List) const {
1804aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall    assert(HasExplicitTemplateArgs);
1805aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall    getExplicitTemplateArgumentList()->copyInto(List);
1806d5532b6cfff2977e0c59fa6ead7f7973984a620dJohn McCall  }
1807d5532b6cfff2977e0c59fa6ead7f7973984a620dJohn McCall
18081eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  /// \brief Retrieve the location of the left angle bracket following the
18093b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor  /// member name ('<'), if any.
18101eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  SourceLocation getLAngleLoc() const {
1811aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall    assert(HasExplicitTemplateArgs);
18123b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor    return getExplicitTemplateArgumentList()->LAngleLoc;
18133b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor  }
18141eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
18153b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor  /// \brief Retrieve the template arguments provided as part of this
18163b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor  /// template-id.
1817833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall  const TemplateArgumentLoc *getTemplateArgs() const {
1818aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall    assert(HasExplicitTemplateArgs);
18193b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor    return getExplicitTemplateArgumentList()->getTemplateArgs();
18203b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor  }
18211eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
18223b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor  /// \brief Retrieve the number of template arguments provided as part of this
18233b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor  /// template-id.
18241eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  unsigned getNumTemplateArgs() const {
1825aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall    assert(HasExplicitTemplateArgs);
18263b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor    return getExplicitTemplateArgumentList()->NumTemplateArgs;
18273b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor  }
18281eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
18291eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  /// \brief Retrieve the location of the right angle bracket following the
18303b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor  /// template arguments ('>').
18311eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  SourceLocation getRAngleLoc() const {
1832aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall    assert(HasExplicitTemplateArgs);
18333b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor    return getExplicitTemplateArgumentList()->RAngleLoc;
18343b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor  }
18351eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
18361c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  virtual SourceRange getSourceRange() const {
1837aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall    SourceRange Range;
1838aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall    if (!isImplicitAccess())
1839aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall      Range.setBegin(Base->getSourceRange().getBegin());
1840aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall    else if (getQualifier())
1841aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall      Range.setBegin(getQualifierRange().getBegin());
1842aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall    else
1843aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall      Range.setBegin(MemberLoc);
18441eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1845aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall    if (hasExplicitTemplateArgs())
1846aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall      Range.setEnd(getRAngleLoc());
1847aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall    else
1848aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall      Range.setEnd(MemberLoc);
1849aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall    return Range;
18501c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  }
18511eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
18521eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  static bool classof(const Stmt *T) {
1853865d447ac6a4721ab58e898d014a21f2eff74b06John McCall    return T->getStmtClass() == CXXDependentScopeMemberExprClass;
18541c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  }
1855865d447ac6a4721ab58e898d014a21f2eff74b06John McCall  static bool classof(const CXXDependentScopeMemberExpr *) { return true; }
18561c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor
18571c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  // Iterators
18581c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  virtual child_iterator child_begin();
18591c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  virtual child_iterator child_end();
18601c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor};
18611c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor
1862129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall/// \brief Represents a C++ member access expression for which lookup
1863aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall/// produced a set of overloaded functions.
1864aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall///
1865aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall/// The member access may be explicit or implicit:
1866aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall///    struct A {
1867aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall///      int a, b;
1868aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall///      int explicitAccess() { return this->a + this->A::b; }
1869aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall///      int implicitAccess() { return a + A::b; }
1870aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall///    };
1871aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall///
1872aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall/// In the final AST, an explicit access always becomes a MemberExpr.
1873aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall/// An implicit access may become either a MemberExpr or a
1874aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall/// DeclRefExpr, depending on whether the member is static.
18757bb12da2b0749eeebb21854c77877736969e59f2John McCallclass UnresolvedMemberExpr : public OverloadExpr {
1876129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// \brief Whether this member expression used the '->' operator or
1877129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// the '.' operator.
1878129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  bool IsArrow : 1;
1879129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall
1880129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// \brief Whether the lookup results contain an unresolved using
1881129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// declaration.
1882129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  bool HasUnresolvedUsing : 1;
1883129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall
18847bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// \brief The expression for the base pointer or class reference,
18857bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// e.g., the \c x in x.f.  This can be null if this is an 'unbased'
18867bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// member expression
18877bb12da2b0749eeebb21854c77877736969e59f2John McCall  Stmt *Base;
18887bb12da2b0749eeebb21854c77877736969e59f2John McCall
18897bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// \brief The type of the base expression;  never null.
18907bb12da2b0749eeebb21854c77877736969e59f2John McCall  QualType BaseType;
1891129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall
1892129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// \brief The location of the '->' or '.' operator.
1893129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  SourceLocation OperatorLoc;
1894129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall
1895129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  UnresolvedMemberExpr(QualType T, bool Dependent,
1896129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall                       bool HasUnresolvedUsing,
1897aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall                       Expr *Base, QualType BaseType, bool IsArrow,
1898129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall                       SourceLocation OperatorLoc,
1899129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall                       NestedNameSpecifier *Qualifier,
1900129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall                       SourceRange QualifierRange,
1901129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall                       DeclarationName Member,
1902129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall                       SourceLocation MemberLoc,
1903129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall                       const TemplateArgumentListInfo *TemplateArgs);
1904129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall
1905129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCallpublic:
1906129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  static UnresolvedMemberExpr *
1907129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  Create(ASTContext &C, bool Dependent, bool HasUnresolvedUsing,
1908aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall         Expr *Base, QualType BaseType, bool IsArrow,
1909129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall         SourceLocation OperatorLoc,
1910129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall         NestedNameSpecifier *Qualifier,
1911129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall         SourceRange QualifierRange,
1912129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall         DeclarationName Member,
1913129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall         SourceLocation MemberLoc,
1914129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall         const TemplateArgumentListInfo *TemplateArgs);
1915129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall
1916aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall  /// \brief True if this is an implicit access, i.e. one in which the
1917aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall  /// member being accessed was not written in the source.  The source
1918aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall  /// location of the operator is invalid in this case.
1919aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall  bool isImplicitAccess() const { return Base == 0; }
1920aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall
1921129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// \brief Retrieve the base object of this member expressions,
1922129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// e.g., the \c x in \c x.m.
1923aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall  Expr *getBase() {
1924aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall    assert(!isImplicitAccess());
1925aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall    return cast<Expr>(Base);
1926aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall  }
19272f27bf854f0519810b34afd209089cc75536b757John McCall  const Expr *getBase() const {
19282f27bf854f0519810b34afd209089cc75536b757John McCall    assert(!isImplicitAccess());
19292f27bf854f0519810b34afd209089cc75536b757John McCall    return cast<Expr>(Base);
19302f27bf854f0519810b34afd209089cc75536b757John McCall  }
1931129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  void setBase(Expr *E) { Base = E; }
1932129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall
1933aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall  QualType getBaseType() const { return BaseType; }
1934aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall
1935129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// \brief Determine whether this member expression used the '->'
1936129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// operator; otherwise, it used the '.' operator.
1937129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  bool isArrow() const { return IsArrow; }
1938129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  void setArrow(bool A) { IsArrow = A; }
1939129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall
1940129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// \brief Retrieve the location of the '->' or '.' operator.
1941129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  SourceLocation getOperatorLoc() const { return OperatorLoc; }
1942129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  void setOperatorLoc(SourceLocation L) { OperatorLoc = L; }
1943129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall
1944c373d48502ca7683ab55385f5bd624d778eb288dJohn McCall  /// \brief Retrieves the naming class of this lookup.
1945c373d48502ca7683ab55385f5bd624d778eb288dJohn McCall  CXXRecordDecl *getNamingClass() const;
1946c373d48502ca7683ab55385f5bd624d778eb288dJohn McCall
1947129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// \brief Retrieve the name of the member that this expression
1948129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// refers to.
19497bb12da2b0749eeebb21854c77877736969e59f2John McCall  DeclarationName getMemberName() const { return getName(); }
19507bb12da2b0749eeebb21854c77877736969e59f2John McCall  void setMemberName(DeclarationName N) { setName(N); }
1951129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall
1952129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  // \brief Retrieve the location of the name of the member that this
1953129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  // expression refers to.
19547bb12da2b0749eeebb21854c77877736969e59f2John McCall  SourceLocation getMemberLoc() const { return getNameLoc(); }
19557bb12da2b0749eeebb21854c77877736969e59f2John McCall  void setMemberLoc(SourceLocation L) { setNameLoc(L); }
1956129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall
19577bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// \brief Retrieve the explicit template argument list that followed the
19587bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// member template name.
19597bb12da2b0749eeebb21854c77877736969e59f2John McCall  ExplicitTemplateArgumentList &getExplicitTemplateArgs() {
19607bb12da2b0749eeebb21854c77877736969e59f2John McCall    assert(hasExplicitTemplateArgs());
19617bb12da2b0749eeebb21854c77877736969e59f2John McCall    return *reinterpret_cast<ExplicitTemplateArgumentList *>(this + 1);
19627bb12da2b0749eeebb21854c77877736969e59f2John McCall  }
19637bb12da2b0749eeebb21854c77877736969e59f2John McCall
19647bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// \brief Retrieve the explicit template argument list that followed the
19657bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// member template name, if any.
19667bb12da2b0749eeebb21854c77877736969e59f2John McCall  const ExplicitTemplateArgumentList &getExplicitTemplateArgs() const {
19677bb12da2b0749eeebb21854c77877736969e59f2John McCall    assert(hasExplicitTemplateArgs());
19687bb12da2b0749eeebb21854c77877736969e59f2John McCall    return *reinterpret_cast<const ExplicitTemplateArgumentList *>(this + 1);
1969129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  }
1970129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall
1971129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// \brief Copies the template arguments into the given structure.
1972129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  void copyTemplateArgumentsInto(TemplateArgumentListInfo &List) const {
19737bb12da2b0749eeebb21854c77877736969e59f2John McCall    getExplicitTemplateArgs().copyInto(List);
1974129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  }
1975129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall
1976129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// \brief Retrieve the location of the left angle bracket following
1977129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// the member name ('<').
1978129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  SourceLocation getLAngleLoc() const {
19797bb12da2b0749eeebb21854c77877736969e59f2John McCall    return getExplicitTemplateArgs().LAngleLoc;
1980129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  }
1981129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall
1982129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// \brief Retrieve the template arguments provided as part of this
1983129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// template-id.
1984129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  const TemplateArgumentLoc *getTemplateArgs() const {
19857bb12da2b0749eeebb21854c77877736969e59f2John McCall    return getExplicitTemplateArgs().getTemplateArgs();
1986129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  }
1987129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall
1988129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// \brief Retrieve the number of template arguments provided as
1989129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// part of this template-id.
1990129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  unsigned getNumTemplateArgs() const {
19917bb12da2b0749eeebb21854c77877736969e59f2John McCall    return getExplicitTemplateArgs().NumTemplateArgs;
1992129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  }
1993129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall
1994129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// \brief Retrieve the location of the right angle bracket
1995129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// following the template arguments ('>').
1996129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  SourceLocation getRAngleLoc() const {
19977bb12da2b0749eeebb21854c77877736969e59f2John McCall    return getExplicitTemplateArgs().RAngleLoc;
1998129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  }
1999129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall
2000129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  virtual SourceRange getSourceRange() const {
2001aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall    SourceRange Range;
2002aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall    if (!isImplicitAccess())
2003aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall      Range.setBegin(Base->getSourceRange().getBegin());
2004aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall    else if (getQualifier())
2005aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall      Range.setBegin(getQualifierRange().getBegin());
2006aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall    else
20077bb12da2b0749eeebb21854c77877736969e59f2John McCall      Range.setBegin(getMemberLoc());
2008aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall
2009129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall    if (hasExplicitTemplateArgs())
2010129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall      Range.setEnd(getRAngleLoc());
2011129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall    else
20127bb12da2b0749eeebb21854c77877736969e59f2John McCall      Range.setEnd(getMemberLoc());
2013129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall    return Range;
2014129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  }
2015129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall
2016129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  static bool classof(const Stmt *T) {
2017129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall    return T->getStmtClass() == UnresolvedMemberExprClass;
2018129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  }
2019129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  static bool classof(const UnresolvedMemberExpr *) { return true; }
2020129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall
2021129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  // Iterators
2022129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  virtual child_iterator child_begin();
2023129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  virtual child_iterator child_end();
2024129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall};
2025129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall
20267bb12da2b0749eeebb21854c77877736969e59f2John McCallinline ExplicitTemplateArgumentList &OverloadExpr::getExplicitTemplateArgs() {
20277bb12da2b0749eeebb21854c77877736969e59f2John McCall  if (isa<UnresolvedLookupExpr>(this))
20287bb12da2b0749eeebb21854c77877736969e59f2John McCall    return cast<UnresolvedLookupExpr>(this)->getExplicitTemplateArgs();
20297bb12da2b0749eeebb21854c77877736969e59f2John McCall  else
20307bb12da2b0749eeebb21854c77877736969e59f2John McCall    return cast<UnresolvedMemberExpr>(this)->getExplicitTemplateArgs();
20317bb12da2b0749eeebb21854c77877736969e59f2John McCall}
20327bb12da2b0749eeebb21854c77877736969e59f2John McCall
20335f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer}  // end namespace clang
20345f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer
20355f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer#endif
2036