ExprCXX.h revision e0601ea1220348957dacec5f3dd0707837365290
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
244eb7f96141f754150a92433286fa385910a22f494Sam Weinig  explicit CXXBoolLiteralExpr(EmptyShell Empty)
245eb7f96141f754150a92433286fa385910a22f494Sam Weinig    : Expr(CXXBoolLiteralExprClass, Empty) { }
246eb7f96141f754150a92433286fa385910a22f494Sam Weinig
2471060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  bool getValue() const { return Value; }
248eb7f96141f754150a92433286fa385910a22f494Sam Weinig  void setValue(bool V) { Value = V; }
2495f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer
2501060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  virtual SourceRange getSourceRange() const { return SourceRange(Loc); }
2511eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
252eb7f96141f754150a92433286fa385910a22f494Sam Weinig  SourceLocation getLocation() const { return Loc; }
253eb7f96141f754150a92433286fa385910a22f494Sam Weinig  void setLocation(SourceLocation L) { Loc = L; }
254eb7f96141f754150a92433286fa385910a22f494Sam Weinig
2551eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  static bool classof(const Stmt *T) {
2561060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek    return T->getStmtClass() == CXXBoolLiteralExprClass;
2571060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  }
2581060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  static bool classof(const CXXBoolLiteralExpr *) { return true; }
2591eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
2601060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  // Iterators
2611060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  virtual child_iterator child_begin();
2621060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  virtual child_iterator child_end();
2631060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek};
2641060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek
2656e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl/// CXXNullPtrLiteralExpr - [C++0x 2.14.7] C++ Pointer Literal
2666e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redlclass CXXNullPtrLiteralExpr : public Expr {
2676e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl  SourceLocation Loc;
2686e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redlpublic:
2696e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl  CXXNullPtrLiteralExpr(QualType Ty, SourceLocation l) :
2702333f7727f97018d6742e1e0938133bcfad967abEli Friedman    Expr(CXXNullPtrLiteralExprClass, Ty, false, false), Loc(l) {}
2716e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl
272eb7f96141f754150a92433286fa385910a22f494Sam Weinig  explicit CXXNullPtrLiteralExpr(EmptyShell Empty)
273eb7f96141f754150a92433286fa385910a22f494Sam Weinig    : Expr(CXXNullPtrLiteralExprClass, Empty) { }
274eb7f96141f754150a92433286fa385910a22f494Sam Weinig
2756e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl  virtual SourceRange getSourceRange() const { return SourceRange(Loc); }
2766e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl
277eb7f96141f754150a92433286fa385910a22f494Sam Weinig  SourceLocation getLocation() const { return Loc; }
278eb7f96141f754150a92433286fa385910a22f494Sam Weinig  void setLocation(SourceLocation L) { Loc = L; }
279eb7f96141f754150a92433286fa385910a22f494Sam Weinig
2806e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl  static bool classof(const Stmt *T) {
2816e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl    return T->getStmtClass() == CXXNullPtrLiteralExprClass;
2826e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl  }
2836e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl  static bool classof(const CXXNullPtrLiteralExpr *) { return true; }
2846e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl
2856e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl  virtual child_iterator child_begin();
2866e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl  virtual child_iterator child_end();
2876e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl};
2886e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl
289c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl/// CXXTypeidExpr - A C++ @c typeid expression (C++ [expr.typeid]), which gets
290c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl/// the type_info that corresponds to the supplied type, or the (possibly
291c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl/// dynamic) type of the supplied expression.
292c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl///
293c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl/// This represents code like @c typeid(int) or @c typeid(*objPtr)
294c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redlclass CXXTypeidExpr : public Expr {
295c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redlprivate:
296c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl  bool isTypeOp : 1;
297d457589fc69dc7a9c80cd74d317c0b81a35a27c9Sebastian Redl  union {
298d457589fc69dc7a9c80cd74d317c0b81a35a27c9Sebastian Redl    void *Ty;
299d457589fc69dc7a9c80cd74d317c0b81a35a27c9Sebastian Redl    Stmt *Ex;
300d457589fc69dc7a9c80cd74d317c0b81a35a27c9Sebastian Redl  } Operand;
301c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl  SourceRange Range;
302c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl
303c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redlpublic:
304c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl  CXXTypeidExpr(bool isTypeOp, void *op, QualType Ty, const SourceRange r) :
3052850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl      Expr(CXXTypeidExprClass, Ty,
3062850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl        // typeid is never type-dependent (C++ [temp.dep.expr]p4)
3072850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl        false,
3082850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl        // typeid is value-dependent if the type or expression are dependent
3092850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl        (isTypeOp ? QualType::getFromOpaquePtr(op)->isDependentType()
3102850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl                  : static_cast<Expr*>(op)->isValueDependent())),
3112850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl      isTypeOp(isTypeOp), Range(r) {
312d457589fc69dc7a9c80cd74d317c0b81a35a27c9Sebastian Redl    if (isTypeOp)
313d457589fc69dc7a9c80cd74d317c0b81a35a27c9Sebastian Redl      Operand.Ty = op;
314d457589fc69dc7a9c80cd74d317c0b81a35a27c9Sebastian Redl    else
315d457589fc69dc7a9c80cd74d317c0b81a35a27c9Sebastian Redl      // op was an Expr*, so cast it back to that to be safe
3162850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl      Operand.Ex = static_cast<Expr*>(op);
317d457589fc69dc7a9c80cd74d317c0b81a35a27c9Sebastian Redl  }
318c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl
319c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl  bool isTypeOperand() const { return isTypeOp; }
320c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl  QualType getTypeOperand() const {
321c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl    assert(isTypeOperand() && "Cannot call getTypeOperand for typeid(expr)");
322d457589fc69dc7a9c80cd74d317c0b81a35a27c9Sebastian Redl    return QualType::getFromOpaquePtr(Operand.Ty);
323c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl  }
324c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl  Expr* getExprOperand() const {
325c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl    assert(!isTypeOperand() && "Cannot call getExprOperand for typeid(type)");
326d457589fc69dc7a9c80cd74d317c0b81a35a27c9Sebastian Redl    return static_cast<Expr*>(Operand.Ex);
327c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl  }
328c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl
329c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl  virtual SourceRange getSourceRange() const {
330c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl    return Range;
331c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl  }
332c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl  static bool classof(const Stmt *T) {
333c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl    return T->getStmtClass() == CXXTypeidExprClass;
334c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl  }
335c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl  static bool classof(const CXXTypeidExpr *) { return true; }
336c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl
337c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl  // Iterators
338c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl  virtual child_iterator child_begin();
339c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl  virtual child_iterator child_end();
340c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl};
341c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl
342796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// CXXThisExpr - Represents the "this" expression in C++, which is a
343796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// pointer to the object on which the current member function is
344796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// executing (C++ [expr.prim]p3). Example:
345796da18402f286b897782a298ae3b20c459c102eDouglas Gregor///
346796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// @code
347796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// class Foo {
348796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// public:
349796da18402f286b897782a298ae3b20c459c102eDouglas Gregor///   void bar();
350796da18402f286b897782a298ae3b20c459c102eDouglas Gregor///   void test() { this->bar(); }
351796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// };
352796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// @endcode
353796da18402f286b897782a298ae3b20c459c102eDouglas Gregorclass CXXThisExpr : public Expr {
354796da18402f286b897782a298ae3b20c459c102eDouglas Gregor  SourceLocation Loc;
355828a197317288e3333b0ce6f5cedadd036e3531fDouglas Gregor  bool Implicit : 1;
356828a197317288e3333b0ce6f5cedadd036e3531fDouglas Gregor
357796da18402f286b897782a298ae3b20c459c102eDouglas Gregorpublic:
358828a197317288e3333b0ce6f5cedadd036e3531fDouglas Gregor  CXXThisExpr(SourceLocation L, QualType Type, bool isImplicit)
3592850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl    : Expr(CXXThisExprClass, Type,
3602850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl           // 'this' is type-dependent if the class type of the enclosing
3612850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl           // member function is dependent (C++ [temp.dep.expr]p2)
3622850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl           Type->isDependentType(), Type->isDependentType()),
363828a197317288e3333b0ce6f5cedadd036e3531fDouglas Gregor      Loc(L), Implicit(isImplicit) { }
364796da18402f286b897782a298ae3b20c459c102eDouglas Gregor
365796da18402f286b897782a298ae3b20c459c102eDouglas Gregor  virtual SourceRange getSourceRange() const { return SourceRange(Loc); }
366796da18402f286b897782a298ae3b20c459c102eDouglas Gregor
367828a197317288e3333b0ce6f5cedadd036e3531fDouglas Gregor  bool isImplicit() const { return Implicit; }
368828a197317288e3333b0ce6f5cedadd036e3531fDouglas Gregor  void setImplicit(bool I) { Implicit = I; }
369828a197317288e3333b0ce6f5cedadd036e3531fDouglas Gregor
3701eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  static bool classof(const Stmt *T) {
371796da18402f286b897782a298ae3b20c459c102eDouglas Gregor    return T->getStmtClass() == CXXThisExprClass;
372796da18402f286b897782a298ae3b20c459c102eDouglas Gregor  }
373796da18402f286b897782a298ae3b20c459c102eDouglas Gregor  static bool classof(const CXXThisExpr *) { return true; }
374796da18402f286b897782a298ae3b20c459c102eDouglas Gregor
375796da18402f286b897782a298ae3b20c459c102eDouglas Gregor  // Iterators
376796da18402f286b897782a298ae3b20c459c102eDouglas Gregor  virtual child_iterator child_begin();
377796da18402f286b897782a298ae3b20c459c102eDouglas Gregor  virtual child_iterator child_end();
378796da18402f286b897782a298ae3b20c459c102eDouglas Gregor};
379796da18402f286b897782a298ae3b20c459c102eDouglas Gregor
3801060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek///  CXXThrowExpr - [C++ 15] C++ Throw Expression.  This handles
3811060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek///  'throw' and 'throw' assignment-expression.  When
3821060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek///  assignment-expression isn't present, Op will be null.
3831060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek///
3841060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenekclass CXXThrowExpr : public Expr {
3851060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  Stmt *Op;
3861060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  SourceLocation ThrowLoc;
3871060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenekpublic:
3881060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  // Ty is the void type which is used as the result type of the
3891060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  // exepression.  The l is the location of the throw keyword.  expr
3901060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  // can by null, if the optional expression to throw isn't present.
3911060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  CXXThrowExpr(Expr *expr, QualType Ty, SourceLocation l) :
3922850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl    Expr(CXXThrowExprClass, Ty, false, false), Op(expr), ThrowLoc(l) {}
3931060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  const Expr *getSubExpr() const { return cast_or_null<Expr>(Op); }
3941060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  Expr *getSubExpr() { return cast_or_null<Expr>(Op); }
39542e5b50f4dc897f252e0d476063a7f9846d96624Douglas Gregor  void setSubExpr(Expr *E) { Op = E; }
39642e5b50f4dc897f252e0d476063a7f9846d96624Douglas Gregor
39742e5b50f4dc897f252e0d476063a7f9846d96624Douglas Gregor  SourceLocation getThrowLoc() const { return ThrowLoc; }
39842e5b50f4dc897f252e0d476063a7f9846d96624Douglas Gregor  void setThrowLoc(SourceLocation L) { ThrowLoc = L; }
3991060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek
4001060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  virtual SourceRange getSourceRange() const {
4011060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek    if (getSubExpr() == 0)
4021060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek      return SourceRange(ThrowLoc, ThrowLoc);
4031060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek    return SourceRange(ThrowLoc, getSubExpr()->getSourceRange().getEnd());
4041060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  }
4051060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek
4061060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  static bool classof(const Stmt *T) {
4071060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek    return T->getStmtClass() == CXXThrowExprClass;
4081060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  }
4091060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  static bool classof(const CXXThrowExpr *) { return true; }
4101060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek
4111060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  // Iterators
4121060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  virtual child_iterator child_begin();
4131060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  virtual child_iterator child_end();
4141060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek};
4151060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek
4161060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek/// CXXDefaultArgExpr - C++ [dcl.fct.default]. This wraps up a
4171060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek/// function call argument that was created from the corresponding
4181060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek/// parameter's default argument, when the call did not explicitly
4191060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek/// supply arguments for all of the parameters.
4201060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenekclass CXXDefaultArgExpr : public Expr {
42165222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor  /// \brief The parameter whose default is being used.
42265222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor  ///
42365222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor  /// When the bit is set, the subexpression is stored after the
42465222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor  /// CXXDefaultArgExpr itself. When the bit is clear, the parameter's
42565222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor  /// actual default expression is the subexpression.
42665222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor  llvm::PointerIntPair<ParmVarDecl *, 1, bool> Param;
4271eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
428036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor  /// \brief The location where the default argument expression was used.
429036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor  SourceLocation Loc;
430036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor
431f1480eee38b59d15438fb7bc50865ac7c7e22403Anders Carlssonprotected:
432036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor  CXXDefaultArgExpr(StmtClass SC, SourceLocation Loc, ParmVarDecl *param)
43365222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor    : Expr(SC,
43465222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor           param->hasUnparsedDefaultArg()
43565222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor             ? param->getType().getNonReferenceType()
4362333f7727f97018d6742e1e0938133bcfad967abEli Friedman             : param->getDefaultArg()->getType(),
4372333f7727f97018d6742e1e0938133bcfad967abEli Friedman           false, false),
438036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor      Param(param, false), Loc(Loc) { }
43965222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor
440036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor  CXXDefaultArgExpr(StmtClass SC, SourceLocation Loc, ParmVarDecl *param,
441036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor                    Expr *SubExpr)
4422333f7727f97018d6742e1e0938133bcfad967abEli Friedman    : Expr(SC, SubExpr->getType(), false, false), Param(param, true), Loc(Loc)
44365222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor  {
44465222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor    *reinterpret_cast<Expr **>(this + 1) = SubExpr;
44565222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor  }
44665222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor
44765222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregorprotected:
44865222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor  virtual void DoDestroy(ASTContext &C);
44965222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor
4501060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenekpublic:
4511060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  // Param is the parameter whose default argument is used by this
4521060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  // expression.
453036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor  static CXXDefaultArgExpr *Create(ASTContext &C, SourceLocation Loc,
454036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor                                   ParmVarDecl *Param) {
455036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor    return new (C) CXXDefaultArgExpr(CXXDefaultArgExprClass, Loc, Param);
456f1480eee38b59d15438fb7bc50865ac7c7e22403Anders Carlsson  }
4571060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek
45865222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor  // Param is the parameter whose default argument is used by this
45965222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor  // expression, and SubExpr is the expression that will actually be used.
460036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor  static CXXDefaultArgExpr *Create(ASTContext &C,
461036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor                                   SourceLocation Loc,
462036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor                                   ParmVarDecl *Param,
46365222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor                                   Expr *SubExpr);
46465222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor
4651060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  // Retrieve the parameter that the argument was created from.
46665222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor  const ParmVarDecl *getParam() const { return Param.getPointer(); }
46765222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor  ParmVarDecl *getParam() { return Param.getPointer(); }
4681060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek
4691060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  // Retrieve the actual argument to the function call.
47065222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor  const Expr *getExpr() const {
47165222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor    if (Param.getInt())
47265222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor      return *reinterpret_cast<Expr const * const*> (this + 1);
47365222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor    return getParam()->getDefaultArg();
47465222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor  }
47565222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor  Expr *getExpr() {
47665222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor    if (Param.getInt())
47765222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor      return *reinterpret_cast<Expr **> (this + 1);
47865222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor    return getParam()->getDefaultArg();
47965222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor  }
4801060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek
481036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor  /// \brief Retrieve the location where this default argument was actually
482036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor  /// used.
483036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor  SourceLocation getUsedLocation() const { return Loc; }
484036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor
4851060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  virtual SourceRange getSourceRange() const {
4861060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek    // Default argument expressions have no representation in the
4871060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek    // source, so they have an empty source range.
4881060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek    return SourceRange();
4891060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  }
4901060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek
4911060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  static bool classof(const Stmt *T) {
4921060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek    return T->getStmtClass() == CXXDefaultArgExprClass;
4931060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  }
4941060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  static bool classof(const CXXDefaultArgExpr *) { return true; }
4951060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek
4961060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  // Iterators
4971060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  virtual child_iterator child_begin();
4981060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  virtual child_iterator child_end();
4991060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek};
500987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis
501c1ce477119fed070299668aab24084b17ff5f14bAnders Carlsson/// CXXTemporary - Represents a C++ temporary.
502c1ce477119fed070299668aab24084b17ff5f14bAnders Carlssonclass CXXTemporary {
503c1ce477119fed070299668aab24084b17ff5f14bAnders Carlsson  /// Destructor - The destructor that needs to be called.
504b859f35459ae3e1188d1e1b86df08d649695fd86Anders Carlsson  const CXXDestructorDecl *Destructor;
5051eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
506b859f35459ae3e1188d1e1b86df08d649695fd86Anders Carlsson  CXXTemporary(const CXXDestructorDecl *destructor)
507c1ce477119fed070299668aab24084b17ff5f14bAnders Carlsson    : Destructor(destructor) { }
50888eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlsson  ~CXXTemporary() { }
509c1ce477119fed070299668aab24084b17ff5f14bAnders Carlsson
510c1ce477119fed070299668aab24084b17ff5f14bAnders Carlssonpublic:
5111eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  static CXXTemporary *Create(ASTContext &C,
512b859f35459ae3e1188d1e1b86df08d649695fd86Anders Carlsson                              const CXXDestructorDecl *Destructor);
5131eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
51442602bb40aefcc2751d4078ba88aacf4d965c9bdDouglas Gregor  void Destroy(ASTContext &Ctx);
5151eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
516f0721fe438d7e40c168e5d664970e7830bc138fbAnders Carlsson  const CXXDestructorDecl *getDestructor() const { return Destructor; }
517c1ce477119fed070299668aab24084b17ff5f14bAnders Carlsson};
518fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson
5191eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump/// CXXBindTemporaryExpr - Represents binding an expression to a temporary,
520fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson/// so its destructor can be called later.
521fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlssonclass CXXBindTemporaryExpr : public Expr {
522fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson  CXXTemporary *Temp;
5231eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
524fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson  Stmt *SubExpr;
525fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson
5261eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  CXXBindTemporaryExpr(CXXTemporary *temp, Expr* subexpr)
5272333f7727f97018d6742e1e0938133bcfad967abEli Friedman   : Expr(CXXBindTemporaryExprClass, subexpr->getType(), false, false),
5282333f7727f97018d6742e1e0938133bcfad967abEli Friedman     Temp(temp), SubExpr(subexpr) { }
5291eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  ~CXXBindTemporaryExpr() { }
53088eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlsson
53142602bb40aefcc2751d4078ba88aacf4d965c9bdDouglas Gregorprotected:
53242602bb40aefcc2751d4078ba88aacf4d965c9bdDouglas Gregor  virtual void DoDestroy(ASTContext &C);
53342602bb40aefcc2751d4078ba88aacf4d965c9bdDouglas Gregor
534fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlssonpublic:
5351eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  static CXXBindTemporaryExpr *Create(ASTContext &C, CXXTemporary *Temp,
536fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson                                      Expr* SubExpr);
5371eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
53888eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlsson  CXXTemporary *getTemporary() { return Temp; }
539f0721fe438d7e40c168e5d664970e7830bc138fbAnders Carlsson  const CXXTemporary *getTemporary() const { return Temp; }
540f0721fe438d7e40c168e5d664970e7830bc138fbAnders Carlsson
541fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson  const Expr *getSubExpr() const { return cast<Expr>(SubExpr); }
542fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson  Expr *getSubExpr() { return cast<Expr>(SubExpr); }
54388eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlsson  void setSubExpr(Expr *E) { SubExpr = E; }
544fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson
54596be6917e1c4ba1f4435a14c9e7c6c139571d086Douglas Gregor  virtual SourceRange getSourceRange() const {
54696be6917e1c4ba1f4435a14c9e7c6c139571d086Douglas Gregor    return SubExpr->getSourceRange();
54796be6917e1c4ba1f4435a14c9e7c6c139571d086Douglas Gregor  }
548fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson
549fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson  // Implement isa/cast/dyncast/etc.
550fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson  static bool classof(const Stmt *T) {
551fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson    return T->getStmtClass() == CXXBindTemporaryExprClass;
552fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson  }
553fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson  static bool classof(const CXXBindTemporaryExpr *) { return true; }
554fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson
555fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson  // Iterators
556fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson  virtual child_iterator child_begin();
557fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson  virtual child_iterator child_end();
558fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson};
559fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson
560eb60edffa147e061278c436e513b0df9b4c4e7f6Anders Carlsson/// CXXBindReferenceExpr - Represents binding an expression to a reference.
561eb60edffa147e061278c436e513b0df9b4c4e7f6Anders Carlsson/// In the example:
562eb60edffa147e061278c436e513b0df9b4c4e7f6Anders Carlsson///
563eb60edffa147e061278c436e513b0df9b4c4e7f6Anders Carlsson/// const int &i = 10;
564eb60edffa147e061278c436e513b0df9b4c4e7f6Anders Carlsson///
565eb60edffa147e061278c436e513b0df9b4c4e7f6Anders Carlsson/// a bind reference expression is inserted to indicate that 10 is bound to
566eb60edffa147e061278c436e513b0df9b4c4e7f6Anders Carlsson/// a reference. (Ans also that a temporary needs to be created to hold the
567eb60edffa147e061278c436e513b0df9b4c4e7f6Anders Carlsson/// value).
568eb60edffa147e061278c436e513b0df9b4c4e7f6Anders Carlssonclass CXXBindReferenceExpr : public Expr {
569eb60edffa147e061278c436e513b0df9b4c4e7f6Anders Carlsson  // SubExpr - The expression being bound.
570eb60edffa147e061278c436e513b0df9b4c4e7f6Anders Carlsson  Stmt *SubExpr;
571eb60edffa147e061278c436e513b0df9b4c4e7f6Anders Carlsson
572eb60edffa147e061278c436e513b0df9b4c4e7f6Anders Carlsson  // ExtendsLifetime - Whether binding this reference extends the lifetime of
573eb60edffa147e061278c436e513b0df9b4c4e7f6Anders Carlsson  // the expression being bound. FIXME: Add C++ reference.
574eb60edffa147e061278c436e513b0df9b4c4e7f6Anders Carlsson  bool ExtendsLifetime;
575eb60edffa147e061278c436e513b0df9b4c4e7f6Anders Carlsson
576eb60edffa147e061278c436e513b0df9b4c4e7f6Anders Carlsson  /// RequiresTemporaryCopy - Whether binding the subexpression requires a
577eb60edffa147e061278c436e513b0df9b4c4e7f6Anders Carlsson  /// temporary copy.
578eb60edffa147e061278c436e513b0df9b4c4e7f6Anders Carlsson  bool RequiresTemporaryCopy;
579eb60edffa147e061278c436e513b0df9b4c4e7f6Anders Carlsson
580eb60edffa147e061278c436e513b0df9b4c4e7f6Anders Carlsson  CXXBindReferenceExpr(Expr *subexpr, bool ExtendsLifetime,
581eb60edffa147e061278c436e513b0df9b4c4e7f6Anders Carlsson                       bool RequiresTemporaryCopy)
582eb60edffa147e061278c436e513b0df9b4c4e7f6Anders Carlsson  : Expr(CXXBindReferenceExprClass, subexpr->getType(), false, false),
583eb60edffa147e061278c436e513b0df9b4c4e7f6Anders Carlsson    SubExpr(subexpr), ExtendsLifetime(ExtendsLifetime),
584eb60edffa147e061278c436e513b0df9b4c4e7f6Anders Carlsson    RequiresTemporaryCopy(RequiresTemporaryCopy) { }
585eb60edffa147e061278c436e513b0df9b4c4e7f6Anders Carlsson  ~CXXBindReferenceExpr() { }
586eb60edffa147e061278c436e513b0df9b4c4e7f6Anders Carlsson
587eb60edffa147e061278c436e513b0df9b4c4e7f6Anders Carlssonprotected:
588eb60edffa147e061278c436e513b0df9b4c4e7f6Anders Carlsson  virtual void DoDestroy(ASTContext &C);
589eb60edffa147e061278c436e513b0df9b4c4e7f6Anders Carlsson
590eb60edffa147e061278c436e513b0df9b4c4e7f6Anders Carlssonpublic:
591eb60edffa147e061278c436e513b0df9b4c4e7f6Anders Carlsson  static CXXBindReferenceExpr *Create(ASTContext &C, Expr *SubExpr,
592eb60edffa147e061278c436e513b0df9b4c4e7f6Anders Carlsson                                      bool ExtendsLifetime,
593eb60edffa147e061278c436e513b0df9b4c4e7f6Anders Carlsson                                      bool RequiresTemporaryCopy);
594eb60edffa147e061278c436e513b0df9b4c4e7f6Anders Carlsson
595eb60edffa147e061278c436e513b0df9b4c4e7f6Anders Carlsson  const Expr *getSubExpr() const { return cast<Expr>(SubExpr); }
596eb60edffa147e061278c436e513b0df9b4c4e7f6Anders Carlsson  Expr *getSubExpr() { return cast<Expr>(SubExpr); }
597eb60edffa147e061278c436e513b0df9b4c4e7f6Anders Carlsson  void setSubExpr(Expr *E) { SubExpr = E; }
598eb60edffa147e061278c436e513b0df9b4c4e7f6Anders Carlsson
599eb60edffa147e061278c436e513b0df9b4c4e7f6Anders Carlsson  virtual SourceRange getSourceRange() const {
600eb60edffa147e061278c436e513b0df9b4c4e7f6Anders Carlsson    return SubExpr->getSourceRange();
601eb60edffa147e061278c436e513b0df9b4c4e7f6Anders Carlsson  }
602eb60edffa147e061278c436e513b0df9b4c4e7f6Anders Carlsson
6034e1c181e2bb378dad55dd25c18611e3a0fb6c22aAnders Carlsson  /// requiresTemporaryCopy - Whether binding the subexpression requires a
6044e1c181e2bb378dad55dd25c18611e3a0fb6c22aAnders Carlsson  /// temporary copy.
6054e1c181e2bb378dad55dd25c18611e3a0fb6c22aAnders Carlsson  bool requiresTemporaryCopy() const { return RequiresTemporaryCopy; }
6064e1c181e2bb378dad55dd25c18611e3a0fb6c22aAnders Carlsson
6074e1c181e2bb378dad55dd25c18611e3a0fb6c22aAnders Carlsson  // extendsLifetime - Whether binding this reference extends the lifetime of
6084e1c181e2bb378dad55dd25c18611e3a0fb6c22aAnders Carlsson  // the expression being bound. FIXME: Add C++ reference.
6094e1c181e2bb378dad55dd25c18611e3a0fb6c22aAnders Carlsson  bool extendsLifetime() { return ExtendsLifetime; }
6104e1c181e2bb378dad55dd25c18611e3a0fb6c22aAnders Carlsson
611eb60edffa147e061278c436e513b0df9b4c4e7f6Anders Carlsson  // Implement isa/cast/dyncast/etc.
612eb60edffa147e061278c436e513b0df9b4c4e7f6Anders Carlsson  static bool classof(const Stmt *T) {
613eb60edffa147e061278c436e513b0df9b4c4e7f6Anders Carlsson    return T->getStmtClass() == CXXBindReferenceExprClass;
614eb60edffa147e061278c436e513b0df9b4c4e7f6Anders Carlsson  }
615eb60edffa147e061278c436e513b0df9b4c4e7f6Anders Carlsson  static bool classof(const CXXBindReferenceExpr *) { return true; }
616eb60edffa147e061278c436e513b0df9b4c4e7f6Anders Carlsson
617eb60edffa147e061278c436e513b0df9b4c4e7f6Anders Carlsson  // Iterators
618eb60edffa147e061278c436e513b0df9b4c4e7f6Anders Carlsson  virtual child_iterator child_begin();
619eb60edffa147e061278c436e513b0df9b4c4e7f6Anders Carlsson  virtual child_iterator child_end();
620eb60edffa147e061278c436e513b0df9b4c4e7f6Anders Carlsson};
621eb60edffa147e061278c436e513b0df9b4c4e7f6Anders Carlsson
62215ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson/// CXXConstructExpr - Represents a call to a C++ constructor.
62315ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlssonclass CXXConstructExpr : public Expr {
62415ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson  CXXConstructorDecl *Constructor;
62515ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson
62699a2e600f9e2e51d3ce10fb6f27191677ac65b2aDouglas Gregor  SourceLocation Loc;
62716006c901315fa12a108b4e571f187f4b676e426Douglas Gregor  bool Elidable : 1;
62816006c901315fa12a108b4e571f187f4b676e426Douglas Gregor  bool ZeroInitialization : 1;
6299db7dbb918ca49f4ee6c181e4917e7b6ec547353Douglas Gregor  bool BaseInitialization : 1;
63015ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson  Stmt **Args;
63115ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson  unsigned NumArgs;
6321eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
633bd6734e5f6432ce0cc07171c490ffaa094796198Anders Carlssonprotected:
6341eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  CXXConstructExpr(ASTContext &C, StmtClass SC, QualType T,
63599a2e600f9e2e51d3ce10fb6f27191677ac65b2aDouglas Gregor                   SourceLocation Loc,
636bd6734e5f6432ce0cc07171c490ffaa094796198Anders Carlsson                   CXXConstructorDecl *d, bool elidable,
63716006c901315fa12a108b4e571f187f4b676e426Douglas Gregor                   Expr **args, unsigned numargs,
6389db7dbb918ca49f4ee6c181e4917e7b6ec547353Douglas Gregor                   bool ZeroInitialization = false,
6399db7dbb918ca49f4ee6c181e4917e7b6ec547353Douglas Gregor                   bool BaseInitialization = false);
6401eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  ~CXXConstructExpr() { }
641bd6734e5f6432ce0cc07171c490ffaa094796198Anders Carlsson
64242602bb40aefcc2751d4078ba88aacf4d965c9bdDouglas Gregor  virtual void DoDestroy(ASTContext &C);
64342602bb40aefcc2751d4078ba88aacf4d965c9bdDouglas Gregor
64415ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlssonpublic:
64539da0b8145eaec7da7004f9b3645c5c9f4f63b1dDouglas Gregor  /// \brief Construct an empty C++ construction expression that will store
64639da0b8145eaec7da7004f9b3645c5c9f4f63b1dDouglas Gregor  /// \p numargs arguments.
64739da0b8145eaec7da7004f9b3645c5c9f4f63b1dDouglas Gregor  CXXConstructExpr(EmptyShell Empty, ASTContext &C, unsigned numargs);
64839da0b8145eaec7da7004f9b3645c5c9f4f63b1dDouglas Gregor
6498e587a15da6d3457a418239d5eb4146fcbd209f3Anders Carlsson  static CXXConstructExpr *Create(ASTContext &C, QualType T,
65099a2e600f9e2e51d3ce10fb6f27191677ac65b2aDouglas Gregor                                  SourceLocation Loc,
6511eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump                                  CXXConstructorDecl *D, bool Elidable,
65216006c901315fa12a108b4e571f187f4b676e426Douglas Gregor                                  Expr **Args, unsigned NumArgs,
6539db7dbb918ca49f4ee6c181e4917e7b6ec547353Douglas Gregor                                  bool ZeroInitialization = false,
6549db7dbb918ca49f4ee6c181e4917e7b6ec547353Douglas Gregor                                  bool BaseInitialization = false);
6551eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
6561eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
657d94546a0a1deef7286c13e49b9584621ae81cc9aDouglas Gregor  CXXConstructorDecl* getConstructor() const { return Constructor; }
65839da0b8145eaec7da7004f9b3645c5c9f4f63b1dDouglas Gregor  void setConstructor(CXXConstructorDecl *C) { Constructor = C; }
65939da0b8145eaec7da7004f9b3645c5c9f4f63b1dDouglas Gregor
66099a2e600f9e2e51d3ce10fb6f27191677ac65b2aDouglas Gregor  SourceLocation getLocation() const { return Loc; }
66199a2e600f9e2e51d3ce10fb6f27191677ac65b2aDouglas Gregor  void setLocation(SourceLocation Loc) { this->Loc = Loc; }
66299a2e600f9e2e51d3ce10fb6f27191677ac65b2aDouglas Gregor
663d94546a0a1deef7286c13e49b9584621ae81cc9aDouglas Gregor  /// \brief Whether this construction is elidable.
664d94546a0a1deef7286c13e49b9584621ae81cc9aDouglas Gregor  bool isElidable() const { return Elidable; }
66539da0b8145eaec7da7004f9b3645c5c9f4f63b1dDouglas Gregor  void setElidable(bool E) { Elidable = E; }
66639da0b8145eaec7da7004f9b3645c5c9f4f63b1dDouglas Gregor
66716006c901315fa12a108b4e571f187f4b676e426Douglas Gregor  /// \brief Whether this construction first requires
66816006c901315fa12a108b4e571f187f4b676e426Douglas Gregor  /// zero-initialization before the initializer is called.
66916006c901315fa12a108b4e571f187f4b676e426Douglas Gregor  bool requiresZeroInitialization() const { return ZeroInitialization; }
67016006c901315fa12a108b4e571f187f4b676e426Douglas Gregor  void setRequiresZeroInitialization(bool ZeroInit) {
67116006c901315fa12a108b4e571f187f4b676e426Douglas Gregor    ZeroInitialization = ZeroInit;
67216006c901315fa12a108b4e571f187f4b676e426Douglas Gregor  }
67316006c901315fa12a108b4e571f187f4b676e426Douglas Gregor
6749db7dbb918ca49f4ee6c181e4917e7b6ec547353Douglas Gregor  /// \brief Determines whether this constructor is actually constructing
6759db7dbb918ca49f4ee6c181e4917e7b6ec547353Douglas Gregor  /// a base class (rather than a complete object).
6769db7dbb918ca49f4ee6c181e4917e7b6ec547353Douglas Gregor  bool isBaseInitialization() const { return BaseInitialization; }
6779db7dbb918ca49f4ee6c181e4917e7b6ec547353Douglas Gregor  void setBaseInitialization(bool BI) { BaseInitialization = BI; }
6789db7dbb918ca49f4ee6c181e4917e7b6ec547353Douglas Gregor
67915ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson  typedef ExprIterator arg_iterator;
68015ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson  typedef ConstExprIterator const_arg_iterator;
6811eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
68215ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson  arg_iterator arg_begin() { return Args; }
68315ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson  arg_iterator arg_end() { return Args + NumArgs; }
68415ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson  const_arg_iterator arg_begin() const { return Args; }
68515ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson  const_arg_iterator arg_end() const { return Args + NumArgs; }
68615ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson
687a88cfbfac9bbcbb9858f048d6d73a48711d8e93dDouglas Gregor  Expr **getArgs() const { return reinterpret_cast<Expr **>(Args); }
68815ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson  unsigned getNumArgs() const { return NumArgs; }
68915ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson
690bcb11d01c034f967503bd98f28bdf458c1ab8001Anders Carlsson  /// getArg - Return the specified argument.
691bcb11d01c034f967503bd98f28bdf458c1ab8001Anders Carlsson  Expr *getArg(unsigned Arg) {
692bcb11d01c034f967503bd98f28bdf458c1ab8001Anders Carlsson    assert(Arg < NumArgs && "Arg access out of range!");
693bcb11d01c034f967503bd98f28bdf458c1ab8001Anders Carlsson    return cast<Expr>(Args[Arg]);
694bcb11d01c034f967503bd98f28bdf458c1ab8001Anders Carlsson  }
695bcb11d01c034f967503bd98f28bdf458c1ab8001Anders Carlsson  const Expr *getArg(unsigned Arg) const {
696bcb11d01c034f967503bd98f28bdf458c1ab8001Anders Carlsson    assert(Arg < NumArgs && "Arg access out of range!");
697bcb11d01c034f967503bd98f28bdf458c1ab8001Anders Carlsson    return cast<Expr>(Args[Arg]);
698bcb11d01c034f967503bd98f28bdf458c1ab8001Anders Carlsson  }
6991eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
7002eeed7bc4fd457ac57ff32ab3b02674588545f65Fariborz Jahanian  /// setArg - Set the specified argument.
7012eeed7bc4fd457ac57ff32ab3b02674588545f65Fariborz Jahanian  void setArg(unsigned Arg, Expr *ArgExpr) {
7022eeed7bc4fd457ac57ff32ab3b02674588545f65Fariborz Jahanian    assert(Arg < NumArgs && "Arg access out of range!");
7032eeed7bc4fd457ac57ff32ab3b02674588545f65Fariborz Jahanian    Args[Arg] = ArgExpr;
7042eeed7bc4fd457ac57ff32ab3b02674588545f65Fariborz Jahanian  }
7052eeed7bc4fd457ac57ff32ab3b02674588545f65Fariborz Jahanian
706e383768f7f5d45ca4af0b1c11cbf072de18bce98Ted Kremenek  virtual SourceRange getSourceRange() const;
70715ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson
7081eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  static bool classof(const Stmt *T) {
709524fa13fd81e88533c7a1d4b1232c0de2c97dc7cAnders Carlsson    return T->getStmtClass() == CXXConstructExprClass ||
710524fa13fd81e88533c7a1d4b1232c0de2c97dc7cAnders Carlsson      T->getStmtClass() == CXXTemporaryObjectExprClass;
71115ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson  }
71215ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson  static bool classof(const CXXConstructExpr *) { return true; }
7131eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
71415ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson  // Iterators
71515ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson  virtual child_iterator child_begin();
71615ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson  virtual child_iterator child_end();
71715ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson};
71815ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson
71949badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// CXXFunctionalCastExpr - Represents an explicit C++ type conversion
72049badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// that uses "functional" notion (C++ [expr.type.conv]). Example: @c
72149badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// x = int(0.5);
72249badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregorclass CXXFunctionalCastExpr : public ExplicitCastExpr {
723987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  SourceLocation TyBeginLoc;
724987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  SourceLocation RParenLoc;
725987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidispublic:
7269d125033a9853f3b572a4c9e2f9e2d4e5e346973John McCall  CXXFunctionalCastExpr(QualType ty, TypeSourceInfo *writtenTy,
7271eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump                        SourceLocation tyBeginLoc, CastKind kind,
7280aebc81e02397a5987aaa8e8c7acbdb01a31d7c3Anders Carlsson                        Expr *castExpr, SourceLocation rParenLoc)
7290aebc81e02397a5987aaa8e8c7acbdb01a31d7c3Anders Carlsson    : ExplicitCastExpr(CXXFunctionalCastExprClass, ty, kind, castExpr,
7300aebc81e02397a5987aaa8e8c7acbdb01a31d7c3Anders Carlsson                       writtenTy),
7310aebc81e02397a5987aaa8e8c7acbdb01a31d7c3Anders Carlsson      TyBeginLoc(tyBeginLoc), RParenLoc(rParenLoc) {}
7320aebc81e02397a5987aaa8e8c7acbdb01a31d7c3Anders Carlsson
733ce757a7a1ee905f87551996a69da3e95e8afeeb7Sam Weinig  explicit CXXFunctionalCastExpr(EmptyShell Shell)
734ce757a7a1ee905f87551996a69da3e95e8afeeb7Sam Weinig    : ExplicitCastExpr(CXXFunctionalCastExprClass, Shell) { }
735ce757a7a1ee905f87551996a69da3e95e8afeeb7Sam Weinig
736987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  SourceLocation getTypeBeginLoc() const { return TyBeginLoc; }
737ce757a7a1ee905f87551996a69da3e95e8afeeb7Sam Weinig  void setTypeBeginLoc(SourceLocation L) { TyBeginLoc = L; }
738987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  SourceLocation getRParenLoc() const { return RParenLoc; }
739ce757a7a1ee905f87551996a69da3e95e8afeeb7Sam Weinig  void setRParenLoc(SourceLocation L) { RParenLoc = L; }
7401eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
741987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  virtual SourceRange getSourceRange() const {
742987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis    return SourceRange(TyBeginLoc, RParenLoc);
743987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  }
7441eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  static bool classof(const Stmt *T) {
7451eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump    return T->getStmtClass() == CXXFunctionalCastExprClass;
746987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  }
747987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  static bool classof(const CXXFunctionalCastExpr *) { return true; }
748987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis};
749987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis
750506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// @brief Represents a C++ functional cast expression that builds a
751506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// temporary object.
752506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor///
7531eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump/// This expression type represents a C++ "functional" cast
754506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// (C++[expr.type.conv]) with N != 1 arguments that invokes a
755506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// constructor to build a temporary object. If N == 0 but no
756506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// constructor will be called (because the functional cast is
757506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// performing a value-initialized an object whose class type has no
758506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// user-declared constructors), CXXZeroInitValueExpr will represent
759506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// the functional cast. Finally, with N == 1 arguments the functional
760506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// cast expression will be represented by CXXFunctionalCastExpr.
761506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// Example:
762506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// @code
763506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// struct X { X(int, float); }
764506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor///
765506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// X create_X() {
766506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor///   return X(1, 3.14f); // creates a CXXTemporaryObjectExpr
767506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// };
768506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// @endcode
769524fa13fd81e88533c7a1d4b1232c0de2c97dc7cAnders Carlssonclass CXXTemporaryObjectExpr : public CXXConstructExpr {
770506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor  SourceLocation TyBeginLoc;
771506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor  SourceLocation RParenLoc;
772506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor
773506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregorpublic:
7741eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  CXXTemporaryObjectExpr(ASTContext &C, CXXConstructorDecl *Cons,
7751eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump                         QualType writtenTy, SourceLocation tyBeginLoc,
7761eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump                         Expr **Args,unsigned NumArgs,
7778e587a15da6d3457a418239d5eb4146fcbd209f3Anders Carlsson                         SourceLocation rParenLoc);
778506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor
7791eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  ~CXXTemporaryObjectExpr() { }
780506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor
781506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor  SourceLocation getTypeBeginLoc() const { return TyBeginLoc; }
782506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor  SourceLocation getRParenLoc() const { return RParenLoc; }
783ba49817c5b9f502602672861cf369fd0e53966e8Douglas Gregor
784506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor  virtual SourceRange getSourceRange() const {
785506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor    return SourceRange(TyBeginLoc, RParenLoc);
786506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor  }
7871eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  static bool classof(const Stmt *T) {
788506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor    return T->getStmtClass() == CXXTemporaryObjectExprClass;
789506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor  }
790506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor  static bool classof(const CXXTemporaryObjectExpr *) { return true; }
791506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor};
792506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor
793987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis/// CXXZeroInitValueExpr - [C++ 5.2.3p2]
794506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// Expression "T()" which creates a value-initialized rvalue of type
795506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// T, which is either a non-class type or a class type without any
796506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// user-defined constructors.
797987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis///
798987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidisclass CXXZeroInitValueExpr : public Expr {
799987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  SourceLocation TyBeginLoc;
800987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  SourceLocation RParenLoc;
801987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis
802987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidispublic:
803987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  CXXZeroInitValueExpr(QualType ty, SourceLocation tyBeginLoc,
8041eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump                       SourceLocation rParenLoc ) :
805d94546a0a1deef7286c13e49b9584621ae81cc9aDouglas Gregor    Expr(CXXZeroInitValueExprClass, ty, false, false),
806987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis    TyBeginLoc(tyBeginLoc), RParenLoc(rParenLoc) {}
8071eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
808987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  SourceLocation getTypeBeginLoc() const { return TyBeginLoc; }
809987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  SourceLocation getRParenLoc() const { return RParenLoc; }
810987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis
8114c67834407ca6ab344dcf44fc599ad4938cfa96dDouglas Gregor  /// @brief Whether this initialization expression was
8124c67834407ca6ab344dcf44fc599ad4938cfa96dDouglas Gregor  /// implicitly-generated.
8131eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  bool isImplicit() const {
8141eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump    return TyBeginLoc.isInvalid() && RParenLoc.isInvalid();
8154c67834407ca6ab344dcf44fc599ad4938cfa96dDouglas Gregor  }
8164c67834407ca6ab344dcf44fc599ad4938cfa96dDouglas Gregor
817987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  virtual SourceRange getSourceRange() const {
818987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis    return SourceRange(TyBeginLoc, RParenLoc);
819987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  }
8201eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
8211eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  static bool classof(const Stmt *T) {
822987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis    return T->getStmtClass() == CXXZeroInitValueExprClass;
823987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  }
824987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  static bool classof(const CXXZeroInitValueExpr *) { return true; }
8251eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
826987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  // Iterators
827987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  virtual child_iterator child_begin();
828987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  virtual child_iterator child_end();
829987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis};
830987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis
8314c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl/// CXXNewExpr - A new expression for memory allocation and constructor calls,
8324c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl/// e.g: "new CXXNewExpr(foo)".
8334c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redlclass CXXNewExpr : public Expr {
8344c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  // Was the usage ::new, i.e. is the global new to be used?
8354c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  bool GlobalNew : 1;
8364c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  // Was the form (type-id) used? Otherwise, it was new-type-id.
8374c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  bool ParenTypeId : 1;
8384c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  // Is there an initializer? If not, built-ins are uninitialized, else they're
8394c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  // value-initialized.
8404c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  bool Initializer : 1;
841cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl  // Do we allocate an array? If so, the first SubExpr is the size expression.
842cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl  bool Array : 1;
8434c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  // The number of placement new arguments.
8444c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  unsigned NumPlacementArgs : 14;
8454c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  // The number of constructor arguments. This may be 1 even for non-class
8464c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  // types; use the pseudo copy constructor.
847cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl  unsigned NumConstructorArgs : 14;
848cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl  // Contains an optional array size expression, any number of optional
849cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl  // placement arguments, and any number of optional constructor arguments,
850cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl  // in that order.
8514c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  Stmt **SubExprs;
8524c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  // Points to the allocation function used.
8534c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  FunctionDecl *OperatorNew;
8544c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  // Points to the deallocation function used in case of error. May be null.
8554c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  FunctionDecl *OperatorDelete;
8564c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  // Points to the constructor used. Cannot be null if AllocType is a record;
8574c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  // it would still point at the default constructor (even an implicit one).
8584c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  // Must be null for all other types.
8594c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  CXXConstructorDecl *Constructor;
8604c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
8614c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  SourceLocation StartLoc;
8624c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  SourceLocation EndLoc;
8634c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
8644c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redlpublic:
865ad7fe864862305c2f71e047cdf6706ef43aebdc0Ted Kremenek  CXXNewExpr(ASTContext &C, bool globalNew, FunctionDecl *operatorNew,
866ad7fe864862305c2f71e047cdf6706ef43aebdc0Ted Kremenek             Expr **placementArgs, unsigned numPlaceArgs, bool ParenTypeId,
867ad7fe864862305c2f71e047cdf6706ef43aebdc0Ted Kremenek             Expr *arraySize, CXXConstructorDecl *constructor, bool initializer,
8684c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl             Expr **constructorArgs, unsigned numConsArgs,
8694c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl             FunctionDecl *operatorDelete, QualType ty,
8704c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl             SourceLocation startLoc, SourceLocation endLoc);
871ad7fe864862305c2f71e047cdf6706ef43aebdc0Ted Kremenek
872ad7fe864862305c2f71e047cdf6706ef43aebdc0Ted Kremenek  virtual void DoDestroy(ASTContext &C);
8734c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
874cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl  QualType getAllocatedType() const {
875cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl    assert(getType()->isPointerType());
8766217b80b7a1379b74cced1c076338262c3c980b3Ted Kremenek    return getType()->getAs<PointerType>()->getPointeeType();
877cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl  }
8784c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
8794c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  FunctionDecl *getOperatorNew() const { return OperatorNew; }
8804c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  FunctionDecl *getOperatorDelete() const { return OperatorDelete; }
8814c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  CXXConstructorDecl *getConstructor() const { return Constructor; }
8824c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
883cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl  bool isArray() const { return Array; }
884cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl  Expr *getArraySize() {
885cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl    return Array ? cast<Expr>(SubExprs[0]) : 0;
886cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl  }
887cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl  const Expr *getArraySize() const {
888cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl    return Array ? cast<Expr>(SubExprs[0]) : 0;
889cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl  }
890cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl
8914c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  unsigned getNumPlacementArgs() const { return NumPlacementArgs; }
8924c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  Expr *getPlacementArg(unsigned i) {
8934c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl    assert(i < NumPlacementArgs && "Index out of range");
894cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl    return cast<Expr>(SubExprs[Array + i]);
8954c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  }
8964c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  const Expr *getPlacementArg(unsigned i) const {
8974c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl    assert(i < NumPlacementArgs && "Index out of range");
898cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl    return cast<Expr>(SubExprs[Array + i]);
8994c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  }
9004c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
9014c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  bool isGlobalNew() const { return GlobalNew; }
9024c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  bool isParenTypeId() const { return ParenTypeId; }
9034c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  bool hasInitializer() const { return Initializer; }
9044c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
9054c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  unsigned getNumConstructorArgs() const { return NumConstructorArgs; }
9064c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  Expr *getConstructorArg(unsigned i) {
9074c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl    assert(i < NumConstructorArgs && "Index out of range");
908cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl    return cast<Expr>(SubExprs[Array + NumPlacementArgs + i]);
9094c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  }
9104c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  const Expr *getConstructorArg(unsigned i) const {
9114c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl    assert(i < NumConstructorArgs && "Index out of range");
912cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl    return cast<Expr>(SubExprs[Array + NumPlacementArgs + i]);
9134c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  }
9144c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
9154c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  typedef ExprIterator arg_iterator;
9164c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  typedef ConstExprIterator const_arg_iterator;
9174c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
9184c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  arg_iterator placement_arg_begin() {
919cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl    return SubExprs + Array;
9204c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  }
9214c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  arg_iterator placement_arg_end() {
922cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl    return SubExprs + Array + getNumPlacementArgs();
9234c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  }
9244c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  const_arg_iterator placement_arg_begin() const {
925cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl    return SubExprs + Array;
9264c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  }
9274c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  const_arg_iterator placement_arg_end() const {
928cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl    return SubExprs + Array + getNumPlacementArgs();
9294c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  }
9304c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
9314c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  arg_iterator constructor_arg_begin() {
932cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl    return SubExprs + Array + getNumPlacementArgs();
9334c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  }
9344c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  arg_iterator constructor_arg_end() {
935cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl    return SubExprs + Array + getNumPlacementArgs() + getNumConstructorArgs();
9364c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  }
9374c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  const_arg_iterator constructor_arg_begin() const {
938cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl    return SubExprs + Array + getNumPlacementArgs();
9394c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  }
9404c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  const_arg_iterator constructor_arg_end() const {
941cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl    return SubExprs + Array + getNumPlacementArgs() + getNumConstructorArgs();
9424c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  }
9434c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
9444c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  virtual SourceRange getSourceRange() const {
9454c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl    return SourceRange(StartLoc, EndLoc);
9464c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  }
9474c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
9484c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  static bool classof(const Stmt *T) {
9494c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl    return T->getStmtClass() == CXXNewExprClass;
9504c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  }
9514c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  static bool classof(const CXXNewExpr *) { return true; }
9524c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
9534c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  // Iterators
9544c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  virtual child_iterator child_begin();
9554c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  virtual child_iterator child_end();
9564c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl};
9574c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
9584c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl/// CXXDeleteExpr - A delete expression for memory deallocation and destructor
9594c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl/// calls, e.g. "delete[] pArray".
9604c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redlclass CXXDeleteExpr : public Expr {
9614c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  // Is this a forced global delete, i.e. "::delete"?
9624c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  bool GlobalDelete : 1;
9634c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  // Is this the array form of delete, i.e. "delete[]"?
9644c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  bool ArrayForm : 1;
9654c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  // Points to the operator delete overload that is used. Could be a member.
9664c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  FunctionDecl *OperatorDelete;
9674c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  // The pointer expression to be deleted.
9684c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  Stmt *Argument;
9694c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  // Location of the expression.
9704c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  SourceLocation Loc;
9714c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redlpublic:
9724c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  CXXDeleteExpr(QualType ty, bool globalDelete, bool arrayForm,
9734c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl                FunctionDecl *operatorDelete, Expr *arg, SourceLocation loc)
9742850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl    : Expr(CXXDeleteExprClass, ty, false, false), GlobalDelete(globalDelete),
9754c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl      ArrayForm(arrayForm), OperatorDelete(operatorDelete), Argument(arg),
9764c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl      Loc(loc) { }
9774c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
9784c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  bool isGlobalDelete() const { return GlobalDelete; }
9794c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  bool isArrayForm() const { return ArrayForm; }
9804c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
9814c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  FunctionDecl *getOperatorDelete() const { return OperatorDelete; }
9824c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
9834c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  Expr *getArgument() { return cast<Expr>(Argument); }
9844c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  const Expr *getArgument() const { return cast<Expr>(Argument); }
9854c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
9864c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  virtual SourceRange getSourceRange() const {
9874c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl    return SourceRange(Loc, Argument->getLocEnd());
9884c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  }
9894c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
9904c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  static bool classof(const Stmt *T) {
9914c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl    return T->getStmtClass() == CXXDeleteExprClass;
9924c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  }
9934c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  static bool classof(const CXXDeleteExpr *) { return true; }
9944c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
9954c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  // Iterators
9964c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  virtual child_iterator child_begin();
9974c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  virtual child_iterator child_end();
9984c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl};
9994c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
1000a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor/// \brief Represents a C++ pseudo-destructor (C++ [expr.pseudo]).
1001a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor///
1002e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor/// A pseudo-destructor is an expression that looks like a member access to a
1003e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor/// destructor of a scalar type, except that scalar types don't have
1004e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor/// destructors. For example:
1005e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor///
1006e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor/// \code
1007e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor/// typedef int T;
1008e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor/// void f(int *p) {
1009e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor///   p->T::~T();
1010e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor/// }
1011e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor/// \endcode
1012a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor///
1013e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor/// Pseudo-destructors typically occur when instantiating templates such as:
1014e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor///
1015a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor/// \code
10161eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump/// template<typename T>
1017a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor/// void destroy(T* ptr) {
1018e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor///   ptr->T::~T();
1019a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor/// }
1020a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor/// \endcode
1021a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor///
1022e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor/// for scalar types. A pseudo-destructor expression has no run-time semantics
1023e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor/// beyond evaluating the base expression.
1024a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregorclass CXXPseudoDestructorExpr : public Expr {
1025a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  /// \brief The base expression (that is being destroyed).
1026a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  Stmt *Base;
10271eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1028a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  /// \brief Whether the operator was an arrow ('->'); otherwise, it was a
1029a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  /// period ('.').
1030a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  bool IsArrow : 1;
10311eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1032a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  /// \brief The location of the '.' or '->' operator.
1033a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  SourceLocation OperatorLoc;
10341eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1035a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  /// \brief The nested-name-specifier that follows the operator, if present.
1036a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  NestedNameSpecifier *Qualifier;
10371eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
10381eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  /// \brief The source range that covers the nested-name-specifier, if
1039a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  /// present.
1040a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  SourceRange QualifierRange;
10411eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1042e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor  /// \brief The type that precedes the '::' in a qualified pseudo-destructor
1043e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor  /// expression.
1044e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor  TypeSourceInfo *ScopeType;
1045e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor
1046e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor  /// \brief The location of the '::' in a qualified pseudo-destructor
1047e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor  /// expression.
1048e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor  SourceLocation ColonColonLoc;
1049e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor
1050a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  /// \brief The type being destroyed.
1051a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  QualType DestroyedType;
10521eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1053a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  /// \brief The location of the type after the '~'.
1054a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  SourceLocation DestroyedTypeLoc;
10551eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1056a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregorpublic:
1057a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  CXXPseudoDestructorExpr(ASTContext &Context,
1058a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor                          Expr *Base, bool isArrow, SourceLocation OperatorLoc,
1059a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor                          NestedNameSpecifier *Qualifier,
1060a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor                          SourceRange QualifierRange,
1061e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor                          TypeSourceInfo *ScopeType,
1062e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor                          SourceLocation ColonColonLoc,
10631eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump                          QualType DestroyedType,
1064a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor                          SourceLocation DestroyedTypeLoc)
10651eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump    : Expr(CXXPseudoDestructorExprClass,
1066a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor           Context.getPointerType(Context.getFunctionType(Context.VoidTy, 0, 0,
1067ce056bcaa1c97b89a4b2de2112c62d060863be2bDouglas Gregor                                                          false, 0, false,
1068ce056bcaa1c97b89a4b2de2112c62d060863be2bDouglas Gregor                                                          false, 0, 0, false,
1069ce056bcaa1c97b89a4b2de2112c62d060863be2bDouglas Gregor                                                          CC_Default)),
1070a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor           /*isTypeDependent=*/false,
1071a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor           /*isValueDependent=*/Base->isValueDependent()),
10721eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump      Base(static_cast<Stmt *>(Base)), IsArrow(isArrow),
1073a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor      OperatorLoc(OperatorLoc), Qualifier(Qualifier),
1074e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor      QualifierRange(QualifierRange),
1075e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor      ScopeType(ScopeType), ColonColonLoc(ColonColonLoc),
1076e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor      DestroyedType(DestroyedType), DestroyedTypeLoc(DestroyedTypeLoc) { }
10771eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1078a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  void setBase(Expr *E) { Base = E; }
1079a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  Expr *getBase() const { return cast<Expr>(Base); }
10801eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
10811eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  /// \brief Determines whether this member expression actually had
1082a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  /// a C++ nested-name-specifier prior to the name of the member, e.g.,
1083a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  /// x->Base::foo.
1084a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  bool hasQualifier() const { return Qualifier != 0; }
10851eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1086a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  /// \brief If the member name was qualified, retrieves the source range of
1087a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  /// the nested-name-specifier that precedes the member name. Otherwise,
1088a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  /// returns an empty source range.
1089a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  SourceRange getQualifierRange() const { return QualifierRange; }
10901eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
10911eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  /// \brief If the member name was qualified, retrieves the
1092a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  /// nested-name-specifier that precedes the member name. Otherwise, returns
1093a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  /// NULL.
1094a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  NestedNameSpecifier *getQualifier() const { return Qualifier; }
10951eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1096a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  /// \brief Determine whether this pseudo-destructor expression was written
1097a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  /// using an '->' (otherwise, it used a '.').
1098a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  bool isArrow() const { return IsArrow; }
1099a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  void setArrow(bool A) { IsArrow = A; }
1100a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor
1101a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  /// \brief Retrieve the location of the '.' or '->' operator.
1102a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  SourceLocation getOperatorLoc() const { return OperatorLoc; }
11031eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1104e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor  /// \brief Retrieve the scope type in a qualified pseudo-destructor
1105e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor  /// expression.
1106e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor  ///
1107e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor  /// Pseudo-destructor expressions can have extra qualification within them
1108e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor  /// that is not part of the nested-name-specifier, e.g., \c p->T::~T().
1109e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor  /// Here, if the object type of the expression is (or may be) a scalar type,
1110e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor  /// \p T may also be a scalar type and, therefore, cannot be part of a
1111e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor  /// nested-name-specifier. It is stored as the "scope type" of the pseudo-
1112e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor  /// destructor expression.
1113e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor  TypeSourceInfo *getScopeTypeLoc() const { return ScopeType; }
1114e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor
1115e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor  /// \brief Retrieve the location of the '::' in a qualified pseudo-destructor
1116e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor  /// expression.
1117e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor  SourceLocation getColonColonLoc() const { return ColonColonLoc; }
1118e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor
1119a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  /// \brief Retrieve the type that is being destroyed.
1120a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  QualType getDestroyedType() const { return DestroyedType; }
11211eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1122a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  /// \brief Retrieve the location of the type being destroyed.
1123a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  SourceLocation getDestroyedTypeLoc() const { return DestroyedTypeLoc; }
11241eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1125a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  virtual SourceRange getSourceRange() const {
1126a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor    return SourceRange(Base->getLocStart(), DestroyedTypeLoc);
1127a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  }
11281eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
11291eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  static bool classof(const Stmt *T) {
1130a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor    return T->getStmtClass() == CXXPseudoDestructorExprClass;
1131a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  }
1132a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  static bool classof(const CXXPseudoDestructorExpr *) { return true; }
11331eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1134a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  // Iterators
1135a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  virtual child_iterator child_begin();
11361eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  virtual child_iterator child_end();
1137a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor};
11381eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
113964b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl/// UnaryTypeTraitExpr - A GCC or MS unary type trait, as used in the
114064b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl/// implementation of TR1/C++0x type trait templates.
114164b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl/// Example:
114264b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl/// __is_pod(int) == true
114364b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl/// __is_enum(std::string) == false
114464b45f7e0d3167f040841ac2920aead7f080730dSebastian Redlclass UnaryTypeTraitExpr : public Expr {
114564b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl  /// UTT - The trait.
114664b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl  UnaryTypeTrait UTT;
114764b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl
114864b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl  /// Loc - The location of the type trait keyword.
114964b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl  SourceLocation Loc;
115064b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl
115164b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl  /// RParen - The location of the closing paren.
115264b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl  SourceLocation RParen;
115364b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl
115464b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl  /// QueriedType - The type we're testing.
115564b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl  QualType QueriedType;
115664b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl
115764b45f7e0d3167f040841ac2920aead7f080730dSebastian Redlpublic:
115864b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl  UnaryTypeTraitExpr(SourceLocation loc, UnaryTypeTrait utt, QualType queried,
115964b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl                     SourceLocation rparen, QualType ty)
116064b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl    : Expr(UnaryTypeTraitExprClass, ty, false, queried->isDependentType()),
116164b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl      UTT(utt), Loc(loc), RParen(rparen), QueriedType(queried) { }
116264b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl
116364b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl  virtual SourceRange getSourceRange() const { return SourceRange(Loc, RParen);}
116464b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl
116564b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl  UnaryTypeTrait getTrait() const { return UTT; }
116664b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl
116764b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl  QualType getQueriedType() const { return QueriedType; }
116864b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl
11695e03f9ea8174ae588c5e69ec6b5ef4c68f8fd766Douglas Gregor  bool EvaluateTrait(ASTContext&) const;
117064b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl
117164b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl  static bool classof(const Stmt *T) {
117264b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl    return T->getStmtClass() == UnaryTypeTraitExprClass;
117364b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl  }
117464b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl  static bool classof(const UnaryTypeTraitExpr *) { return true; }
117564b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl
117664b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl  // Iterators
117764b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl  virtual child_iterator child_begin();
117864b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl  virtual child_iterator child_end();
117964b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl};
118064b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl
11817bb12da2b0749eeebb21854c77877736969e59f2John McCall/// \brief A reference to an overloaded function set, either an
11827bb12da2b0749eeebb21854c77877736969e59f2John McCall/// \t UnresolvedLookupExpr or an \t UnresolvedMemberExpr.
11837bb12da2b0749eeebb21854c77877736969e59f2John McCallclass OverloadExpr : public Expr {
1184ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  /// The results.  These are undesugared, which is to say, they may
11857bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// include UsingShadowDecls.  Access is relative to the naming
11867bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// class.
1187eec51cf1ba5f0e62c9cdb81b5c63babdd6e649abJohn McCall  UnresolvedSet<4> Results;
1188ba13543329afac4a0d01304ec2ec4924d99306a6John McCall
11897bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// The common name of these declarations.
1190ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  DeclarationName Name;
1191ba13543329afac4a0d01304ec2ec4924d99306a6John McCall
11927bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// The scope specifier, if any.
1193ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  NestedNameSpecifier *Qualifier;
11947bb12da2b0749eeebb21854c77877736969e59f2John McCall
11957bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// The source range of the scope specifier.
1196ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  SourceRange QualifierRange;
1197ba13543329afac4a0d01304ec2ec4924d99306a6John McCall
1198ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  /// The location of the name.
1199ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  SourceLocation NameLoc;
1200ba13543329afac4a0d01304ec2ec4924d99306a6John McCall
12017bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// True if the name was a template-id.
12027bb12da2b0749eeebb21854c77877736969e59f2John McCall  bool HasExplicitTemplateArgs;
12037bb12da2b0749eeebb21854c77877736969e59f2John McCall
12047bb12da2b0749eeebb21854c77877736969e59f2John McCallprotected:
12057bb12da2b0749eeebb21854c77877736969e59f2John McCall  OverloadExpr(StmtClass K, QualType T, bool Dependent,
12067bb12da2b0749eeebb21854c77877736969e59f2John McCall               NestedNameSpecifier *Qualifier, SourceRange QRange,
12077bb12da2b0749eeebb21854c77877736969e59f2John McCall               DeclarationName Name, SourceLocation NameLoc,
12087bb12da2b0749eeebb21854c77877736969e59f2John McCall               bool HasTemplateArgs)
12097bb12da2b0749eeebb21854c77877736969e59f2John McCall    : Expr(K, T, Dependent, Dependent),
12107bb12da2b0749eeebb21854c77877736969e59f2John McCall      Name(Name), Qualifier(Qualifier), QualifierRange(QRange),
12117bb12da2b0749eeebb21854c77877736969e59f2John McCall      NameLoc(NameLoc), HasExplicitTemplateArgs(HasTemplateArgs)
12127bb12da2b0749eeebb21854c77877736969e59f2John McCall  {}
12137bb12da2b0749eeebb21854c77877736969e59f2John McCall
12147bb12da2b0749eeebb21854c77877736969e59f2John McCallpublic:
12157bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// Computes whether an unresolved lookup on the given declarations
12167bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// and optional template arguments is type- and value-dependent.
12177bb12da2b0749eeebb21854c77877736969e59f2John McCall  static bool ComputeDependence(UnresolvedSetIterator Begin,
12187bb12da2b0749eeebb21854c77877736969e59f2John McCall                                UnresolvedSetIterator End,
12197bb12da2b0749eeebb21854c77877736969e59f2John McCall                                const TemplateArgumentListInfo *Args);
12207bb12da2b0749eeebb21854c77877736969e59f2John McCall
12217bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// Finds the overloaded expression in the given expression of
12227bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// OverloadTy.
12237bb12da2b0749eeebb21854c77877736969e59f2John McCall  ///
12247bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// \return the expression (which must be there) and true if it is
12257bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// within an address-of operator.
12267bb12da2b0749eeebb21854c77877736969e59f2John McCall  static llvm::PointerIntPair<OverloadExpr*,1> find(Expr *E) {
12277bb12da2b0749eeebb21854c77877736969e59f2John McCall    assert(E->getType()->isSpecificBuiltinType(BuiltinType::Overload));
12287bb12da2b0749eeebb21854c77877736969e59f2John McCall
12297bb12da2b0749eeebb21854c77877736969e59f2John McCall    bool op = false;
12307bb12da2b0749eeebb21854c77877736969e59f2John McCall    E = E->IgnoreParens();
12317bb12da2b0749eeebb21854c77877736969e59f2John McCall    if (isa<UnaryOperator>(E))
12327bb12da2b0749eeebb21854c77877736969e59f2John McCall      op = true, E = cast<UnaryOperator>(E)->getSubExpr()->IgnoreParens();
12337bb12da2b0749eeebb21854c77877736969e59f2John McCall    return llvm::PointerIntPair<OverloadExpr*,1>(cast<OverloadExpr>(E), op);
12347bb12da2b0749eeebb21854c77877736969e59f2John McCall  }
12357bb12da2b0749eeebb21854c77877736969e59f2John McCall
12367bb12da2b0749eeebb21854c77877736969e59f2John McCall  void addDecls(UnresolvedSetIterator Begin, UnresolvedSetIterator End) {
12377bb12da2b0749eeebb21854c77877736969e59f2John McCall    Results.append(Begin, End);
12387bb12da2b0749eeebb21854c77877736969e59f2John McCall  }
12397bb12da2b0749eeebb21854c77877736969e59f2John McCall
12407bb12da2b0749eeebb21854c77877736969e59f2John McCall  typedef UnresolvedSetImpl::iterator decls_iterator;
12417bb12da2b0749eeebb21854c77877736969e59f2John McCall  decls_iterator decls_begin() const { return Results.begin(); }
12427bb12da2b0749eeebb21854c77877736969e59f2John McCall  decls_iterator decls_end() const { return Results.end(); }
12437bb12da2b0749eeebb21854c77877736969e59f2John McCall
12447bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// Gets the decls as an unresolved set.
12457bb12da2b0749eeebb21854c77877736969e59f2John McCall  const UnresolvedSetImpl &getDecls() { return Results; }
12467bb12da2b0749eeebb21854c77877736969e59f2John McCall
12477bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// Gets the number of declarations in the unresolved set.
12487bb12da2b0749eeebb21854c77877736969e59f2John McCall  unsigned getNumDecls() const { return Results.size(); }
12497bb12da2b0749eeebb21854c77877736969e59f2John McCall
12507bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// Gets the name looked up.
12517bb12da2b0749eeebb21854c77877736969e59f2John McCall  DeclarationName getName() const { return Name; }
12527bb12da2b0749eeebb21854c77877736969e59f2John McCall  void setName(DeclarationName N) { Name = N; }
12537bb12da2b0749eeebb21854c77877736969e59f2John McCall
12547bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// Gets the location of the name.
12557bb12da2b0749eeebb21854c77877736969e59f2John McCall  SourceLocation getNameLoc() const { return NameLoc; }
12567bb12da2b0749eeebb21854c77877736969e59f2John McCall  void setNameLoc(SourceLocation Loc) { NameLoc = Loc; }
12577bb12da2b0749eeebb21854c77877736969e59f2John McCall
12587bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// Fetches the nested-name qualifier, if one was given.
12597bb12da2b0749eeebb21854c77877736969e59f2John McCall  NestedNameSpecifier *getQualifier() const { return Qualifier; }
12607bb12da2b0749eeebb21854c77877736969e59f2John McCall
12617bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// Fetches the range of the nested-name qualifier.
12627bb12da2b0749eeebb21854c77877736969e59f2John McCall  SourceRange getQualifierRange() const { return QualifierRange; }
12637bb12da2b0749eeebb21854c77877736969e59f2John McCall
12647bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// \brief Determines whether this expression had an explicit
12657bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// template argument list, e.g. f<int>.
12667bb12da2b0749eeebb21854c77877736969e59f2John McCall  bool hasExplicitTemplateArgs() const { return HasExplicitTemplateArgs; }
12677bb12da2b0749eeebb21854c77877736969e59f2John McCall
12687bb12da2b0749eeebb21854c77877736969e59f2John McCall  ExplicitTemplateArgumentList &getExplicitTemplateArgs(); // defined far below
12697bb12da2b0749eeebb21854c77877736969e59f2John McCall
12707bb12da2b0749eeebb21854c77877736969e59f2John McCall  const ExplicitTemplateArgumentList &getExplicitTemplateArgs() const {
12717bb12da2b0749eeebb21854c77877736969e59f2John McCall    return const_cast<OverloadExpr*>(this)->getExplicitTemplateArgs();
12727bb12da2b0749eeebb21854c77877736969e59f2John McCall  }
12737bb12da2b0749eeebb21854c77877736969e59f2John McCall
12747bb12da2b0749eeebb21854c77877736969e59f2John McCall  ExplicitTemplateArgumentList *getOptionalExplicitTemplateArgs() {
12757bb12da2b0749eeebb21854c77877736969e59f2John McCall    if (hasExplicitTemplateArgs())
12767bb12da2b0749eeebb21854c77877736969e59f2John McCall      return &getExplicitTemplateArgs();
12777bb12da2b0749eeebb21854c77877736969e59f2John McCall    return 0;
12787bb12da2b0749eeebb21854c77877736969e59f2John McCall  }
12797bb12da2b0749eeebb21854c77877736969e59f2John McCall
12807bb12da2b0749eeebb21854c77877736969e59f2John McCall  static bool classof(const Stmt *T) {
12817bb12da2b0749eeebb21854c77877736969e59f2John McCall    return T->getStmtClass() == UnresolvedLookupExprClass ||
12827bb12da2b0749eeebb21854c77877736969e59f2John McCall           T->getStmtClass() == UnresolvedMemberExprClass;
12837bb12da2b0749eeebb21854c77877736969e59f2John McCall  }
12847bb12da2b0749eeebb21854c77877736969e59f2John McCall  static bool classof(const OverloadExpr *) { return true; }
12857bb12da2b0749eeebb21854c77877736969e59f2John McCall};
12867bb12da2b0749eeebb21854c77877736969e59f2John McCall
12877bb12da2b0749eeebb21854c77877736969e59f2John McCall/// \brief A reference to a name which we were able to look up during
12887bb12da2b0749eeebb21854c77877736969e59f2John McCall/// parsing but could not resolve to a specific declaration.  This
12897bb12da2b0749eeebb21854c77877736969e59f2John McCall/// arises in several ways:
12907bb12da2b0749eeebb21854c77877736969e59f2John McCall///   * we might be waiting for argument-dependent lookup
12917bb12da2b0749eeebb21854c77877736969e59f2John McCall///   * the name might resolve to an overloaded function
12927bb12da2b0749eeebb21854c77877736969e59f2John McCall/// and eventually:
12937bb12da2b0749eeebb21854c77877736969e59f2John McCall///   * the lookup might have included a function template
12947bb12da2b0749eeebb21854c77877736969e59f2John McCall/// These never include UnresolvedUsingValueDecls, which are always
12957bb12da2b0749eeebb21854c77877736969e59f2John McCall/// class members and therefore appear only in
12967bb12da2b0749eeebb21854c77877736969e59f2John McCall/// UnresolvedMemberLookupExprs.
12977bb12da2b0749eeebb21854c77877736969e59f2John McCallclass UnresolvedLookupExpr : public OverloadExpr {
1298ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  /// True if these lookup results should be extended by
1299ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  /// argument-dependent lookup if this is the operand of a function
1300ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  /// call.
1301ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  bool RequiresADL;
1302ba13543329afac4a0d01304ec2ec4924d99306a6John McCall
13037453ed4cb2cab113de3378df371b1c6f1243d832John McCall  /// True if these lookup results are overloaded.  This is pretty
13047453ed4cb2cab113de3378df371b1c6f1243d832John McCall  /// trivially rederivable if we urgently need to kill this field.
13057453ed4cb2cab113de3378df371b1c6f1243d832John McCall  bool Overloaded;
13067453ed4cb2cab113de3378df371b1c6f1243d832John McCall
13077bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// The naming class (C++ [class.access.base]p5) of the lookup, if
13087bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// any.  This can generally be recalculated from the context chain,
13097bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// but that can be fairly expensive for unqualified lookups.  If we
13107bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// want to improve memory use here, this could go in a union
13117bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// against the qualified-lookup bits.
13127bb12da2b0749eeebb21854c77877736969e59f2John McCall  CXXRecordDecl *NamingClass;
1313f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall
1314c373d48502ca7683ab55385f5bd624d778eb288dJohn McCall  UnresolvedLookupExpr(QualType T, bool Dependent, CXXRecordDecl *NamingClass,
1315ba13543329afac4a0d01304ec2ec4924d99306a6John McCall                       NestedNameSpecifier *Qualifier, SourceRange QRange,
1316ba13543329afac4a0d01304ec2ec4924d99306a6John McCall                       DeclarationName Name, SourceLocation NameLoc,
1317f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall                       bool RequiresADL, bool Overloaded, bool HasTemplateArgs)
13187bb12da2b0749eeebb21854c77877736969e59f2John McCall    : OverloadExpr(UnresolvedLookupExprClass, T, Dependent, Qualifier, QRange,
13197bb12da2b0749eeebb21854c77877736969e59f2John McCall                   Name, NameLoc, HasTemplateArgs),
13207bb12da2b0749eeebb21854c77877736969e59f2John McCall      RequiresADL(RequiresADL), Overloaded(Overloaded), NamingClass(NamingClass)
1321ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  {}
1322ba13543329afac4a0d01304ec2ec4924d99306a6John McCall
1323ba13543329afac4a0d01304ec2ec4924d99306a6John McCallpublic:
1324ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  static UnresolvedLookupExpr *Create(ASTContext &C,
1325f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall                                      bool Dependent,
1326c373d48502ca7683ab55385f5bd624d778eb288dJohn McCall                                      CXXRecordDecl *NamingClass,
1327ba13543329afac4a0d01304ec2ec4924d99306a6John McCall                                      NestedNameSpecifier *Qualifier,
1328ba13543329afac4a0d01304ec2ec4924d99306a6John McCall                                      SourceRange QualifierRange,
1329ba13543329afac4a0d01304ec2ec4924d99306a6John McCall                                      DeclarationName Name,
1330ba13543329afac4a0d01304ec2ec4924d99306a6John McCall                                      SourceLocation NameLoc,
13317453ed4cb2cab113de3378df371b1c6f1243d832John McCall                                      bool ADL, bool Overloaded) {
1332f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall    return new(C) UnresolvedLookupExpr(Dependent ? C.DependentTy : C.OverloadTy,
1333c373d48502ca7683ab55385f5bd624d778eb288dJohn McCall                                       Dependent, NamingClass,
1334c373d48502ca7683ab55385f5bd624d778eb288dJohn McCall                                       Qualifier, QualifierRange,
1335f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall                                       Name, NameLoc, ADL, Overloaded, false);
1336ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  }
1337ba13543329afac4a0d01304ec2ec4924d99306a6John McCall
1338f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  static UnresolvedLookupExpr *Create(ASTContext &C,
1339f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall                                      bool Dependent,
1340c373d48502ca7683ab55385f5bd624d778eb288dJohn McCall                                      CXXRecordDecl *NamingClass,
1341f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall                                      NestedNameSpecifier *Qualifier,
1342f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall                                      SourceRange QualifierRange,
1343f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall                                      DeclarationName Name,
1344f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall                                      SourceLocation NameLoc,
1345f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall                                      bool ADL,
1346f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall                                      const TemplateArgumentListInfo &Args);
1347f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall
1348ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  /// True if this declaration should be extended by
1349ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  /// argument-dependent lookup.
1350ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  bool requiresADL() const { return RequiresADL; }
1351ba13543329afac4a0d01304ec2ec4924d99306a6John McCall
13527453ed4cb2cab113de3378df371b1c6f1243d832John McCall  /// True if this lookup is overloaded.
13537453ed4cb2cab113de3378df371b1c6f1243d832John McCall  bool isOverloaded() const { return Overloaded; }
13547453ed4cb2cab113de3378df371b1c6f1243d832John McCall
1355c373d48502ca7683ab55385f5bd624d778eb288dJohn McCall  /// Gets the 'naming class' (in the sense of C++0x
1356c373d48502ca7683ab55385f5bd624d778eb288dJohn McCall  /// [class.access.base]p5) of the lookup.  This is the scope
1357c373d48502ca7683ab55385f5bd624d778eb288dJohn McCall  /// that was looked in to find these results.
1358c373d48502ca7683ab55385f5bd624d778eb288dJohn McCall  CXXRecordDecl *getNamingClass() const { return NamingClass; }
1359c373d48502ca7683ab55385f5bd624d778eb288dJohn McCall
1360f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  // Note that, inconsistently with the explicit-template-argument AST
1361f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  // nodes, users are *forbidden* from calling these methods on objects
1362f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  // without explicit template arguments.
1363f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall
13647bb12da2b0749eeebb21854c77877736969e59f2John McCall  ExplicitTemplateArgumentList &getExplicitTemplateArgs() {
13657bb12da2b0749eeebb21854c77877736969e59f2John McCall    assert(hasExplicitTemplateArgs());
13667bb12da2b0749eeebb21854c77877736969e59f2John McCall    return *reinterpret_cast<ExplicitTemplateArgumentList*>(this + 1);
13677bb12da2b0749eeebb21854c77877736969e59f2John McCall  }
13687bb12da2b0749eeebb21854c77877736969e59f2John McCall
1369f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  /// Gets a reference to the explicit template argument list.
1370f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  const ExplicitTemplateArgumentList &getExplicitTemplateArgs() const {
1371f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall    assert(hasExplicitTemplateArgs());
1372f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall    return *reinterpret_cast<const ExplicitTemplateArgumentList*>(this + 1);
1373f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  }
1374f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall
1375f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  /// \brief Copies the template arguments (if present) into the given
1376f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  /// structure.
1377f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  void copyTemplateArgumentsInto(TemplateArgumentListInfo &List) const {
1378f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall    getExplicitTemplateArgs().copyInto(List);
1379f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  }
1380ba13543329afac4a0d01304ec2ec4924d99306a6John McCall
1381f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  SourceLocation getLAngleLoc() const {
1382f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall    return getExplicitTemplateArgs().LAngleLoc;
1383f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  }
1384f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall
1385f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  SourceLocation getRAngleLoc() const {
1386f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall    return getExplicitTemplateArgs().RAngleLoc;
1387f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  }
1388f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall
1389f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  TemplateArgumentLoc const *getTemplateArgs() const {
1390f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall    return getExplicitTemplateArgs().getTemplateArgs();
1391f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  }
1392f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall
1393f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  unsigned getNumTemplateArgs() const {
1394f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall    return getExplicitTemplateArgs().NumTemplateArgs;
1395f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  }
1396ba13543329afac4a0d01304ec2ec4924d99306a6John McCall
1397ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  virtual SourceRange getSourceRange() const {
13987bb12da2b0749eeebb21854c77877736969e59f2John McCall    SourceRange Range(getNameLoc());
13997bb12da2b0749eeebb21854c77877736969e59f2John McCall    if (getQualifier()) Range.setBegin(getQualifierRange().getBegin());
1400f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall    if (hasExplicitTemplateArgs()) Range.setEnd(getRAngleLoc());
1401f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall    return Range;
1402ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  }
1403ba13543329afac4a0d01304ec2ec4924d99306a6John McCall
1404ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  virtual StmtIterator child_begin();
1405ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  virtual StmtIterator child_end();
1406ba13543329afac4a0d01304ec2ec4924d99306a6John McCall
1407ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  static bool classof(const Stmt *T) {
1408ba13543329afac4a0d01304ec2ec4924d99306a6John McCall    return T->getStmtClass() == UnresolvedLookupExprClass;
1409ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  }
1410ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  static bool classof(const UnresolvedLookupExpr *) { return true; }
1411ba13543329afac4a0d01304ec2ec4924d99306a6John McCall};
1412ba13543329afac4a0d01304ec2ec4924d99306a6John McCall
14135953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor/// \brief A qualified reference to a name whose declaration cannot
14145953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor/// yet be resolved.
14155953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor///
1416ba13543329afac4a0d01304ec2ec4924d99306a6John McCall/// DependentScopeDeclRefExpr is similar to DeclRefExpr in that
1417a2813cec2605ce7878d1b13471d685f689b251afDouglas Gregor/// it expresses a reference to a declaration such as
14185953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor/// X<T>::value. The difference, however, is that an
1419865d447ac6a4721ab58e898d014a21f2eff74b06John McCall/// DependentScopeDeclRefExpr node is used only within C++ templates when
14205953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor/// the qualification (e.g., X<T>::) refers to a dependent type. In
14215953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor/// this case, X<T>::value cannot resolve to a declaration because the
14225953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor/// declaration will differ from on instantiation of X<T> to the
1423865d447ac6a4721ab58e898d014a21f2eff74b06John McCall/// next. Therefore, DependentScopeDeclRefExpr keeps track of the
1424ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor/// qualifier (X<T>::) and the name of the entity being referenced
1425a2813cec2605ce7878d1b13471d685f689b251afDouglas Gregor/// ("value"). Such expressions will instantiate to a DeclRefExpr once the
1426a2813cec2605ce7878d1b13471d685f689b251afDouglas Gregor/// declaration can be found.
1427865d447ac6a4721ab58e898d014a21f2eff74b06John McCallclass DependentScopeDeclRefExpr : public Expr {
14285953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor  /// The name of the entity we will be referencing.
14295953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor  DeclarationName Name;
14305953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor
14315953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor  /// Location of the name of the declaration we're referencing.
14325953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor  SourceLocation Loc;
14335953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor
14345953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor  /// QualifierRange - The source range that covers the
14355953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor  /// nested-name-specifier.
14365953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor  SourceRange QualifierRange;
14375953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor
1438ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor  /// \brief The nested-name-specifier that qualifies this unresolved
1439ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor  /// declaration name.
1440f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  NestedNameSpecifier *Qualifier;
14415953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor
1442f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  /// \brief Whether the name includes explicit template arguments.
1443f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  bool HasExplicitTemplateArgs;
14441eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1445f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  DependentScopeDeclRefExpr(QualType T,
1446f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall                            NestedNameSpecifier *Qualifier,
1447f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall                            SourceRange QualifierRange,
1448f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall                            DeclarationName Name,
1449f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall                            SourceLocation NameLoc,
1450f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall                            bool HasExplicitTemplateArgs)
1451865d447ac6a4721ab58e898d014a21f2eff74b06John McCall    : Expr(DependentScopeDeclRefExprClass, T, true, true),
1452f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall      Name(Name), Loc(NameLoc),
1453f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall      QualifierRange(QualifierRange), Qualifier(Qualifier),
1454f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall      HasExplicitTemplateArgs(HasExplicitTemplateArgs)
1455f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  {}
1456f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall
1457f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCallpublic:
1458f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  static DependentScopeDeclRefExpr *Create(ASTContext &C,
1459f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall                                           NestedNameSpecifier *Qualifier,
1460f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall                                           SourceRange QualifierRange,
1461f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall                                           DeclarationName Name,
1462f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall                                           SourceLocation NameLoc,
1463f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall                              const TemplateArgumentListInfo *TemplateArgs = 0);
14645953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor
14655953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor  /// \brief Retrieve the name that this expression refers to.
14665953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor  DeclarationName getDeclName() const { return Name; }
14675953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor
14685953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor  /// \brief Retrieve the location of the name within the expression.
14695953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor  SourceLocation getLocation() const { return Loc; }
14705953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor
14715953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor  /// \brief Retrieve the source range of the nested-name-specifier.
14725953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor  SourceRange getQualifierRange() const { return QualifierRange; }
14735953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor
1474ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor  /// \brief Retrieve the nested-name-specifier that qualifies this
1475ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor  /// declaration.
1476edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor  NestedNameSpecifier *getQualifier() const { return Qualifier; }
14771eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1478f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  /// Determines whether this lookup had explicit template arguments.
1479f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  bool hasExplicitTemplateArgs() const { return HasExplicitTemplateArgs; }
14801eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1481f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  // Note that, inconsistently with the explicit-template-argument AST
1482f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  // nodes, users are *forbidden* from calling these methods on objects
1483f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  // without explicit template arguments.
14841eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1485f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  /// Gets a reference to the explicit template argument list.
1486f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  const ExplicitTemplateArgumentList &getExplicitTemplateArgs() const {
1487f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall    assert(hasExplicitTemplateArgs());
1488f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall    return *reinterpret_cast<const ExplicitTemplateArgumentList*>(this + 1);
1489f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  }
14901eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1491f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  /// \brief Copies the template arguments (if present) into the given
1492f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  /// structure.
1493f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  void copyTemplateArgumentsInto(TemplateArgumentListInfo &List) const {
1494f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall    getExplicitTemplateArgs().copyInto(List);
1495f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  }
1496f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall
1497f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  SourceLocation getLAngleLoc() const {
1498f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall    return getExplicitTemplateArgs().LAngleLoc;
1499edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor  }
15001eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1501f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  SourceLocation getRAngleLoc() const {
1502f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall    return getExplicitTemplateArgs().RAngleLoc;
1503f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  }
15041eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1505f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  TemplateArgumentLoc const *getTemplateArgs() const {
1506f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall    return getExplicitTemplateArgs().getTemplateArgs();
1507d5532b6cfff2977e0c59fa6ead7f7973984a620dJohn McCall  }
1508d5532b6cfff2977e0c59fa6ead7f7973984a620dJohn McCall
1509f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  unsigned getNumTemplateArgs() const {
1510f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall    return getExplicitTemplateArgs().NumTemplateArgs;
1511f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  }
15121eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1513edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor  virtual SourceRange getSourceRange() const {
1514f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall    SourceRange Range(QualifierRange.getBegin(), getLocation());
1515f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall    if (hasExplicitTemplateArgs())
1516f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall      Range.setEnd(getRAngleLoc());
1517f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall    return Range;
1518edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor  }
15191eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
15201eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  static bool classof(const Stmt *T) {
1521f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall    return T->getStmtClass() == DependentScopeDeclRefExprClass;
1522edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor  }
1523f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  static bool classof(const DependentScopeDeclRefExpr *) { return true; }
1524f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall
1525f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  virtual StmtIterator child_begin();
1526f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  virtual StmtIterator child_end();
1527edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor};
15281eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
15292d44e8a41de8a33c0f04ac198714f71dc841bab0Anders Carlssonclass CXXExprWithTemporaries : public Expr {
153002bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson  Stmt *SubExpr;
15311eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1532ff6b3d64c9f07155f1414411b8451d7bf8937c62Anders Carlsson  CXXTemporary **Temps;
1533ff6b3d64c9f07155f1414411b8451d7bf8937c62Anders Carlsson  unsigned NumTemps;
153402bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson
15351eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  CXXExprWithTemporaries(Expr *SubExpr, CXXTemporary **Temps,
15360ece491d8f62ce67f047491a6703fac0d3bd4ff4Anders Carlsson                         unsigned NumTemps);
15372d44e8a41de8a33c0f04ac198714f71dc841bab0Anders Carlsson  ~CXXExprWithTemporaries();
153842602bb40aefcc2751d4078ba88aacf4d965c9bdDouglas Gregor
153942602bb40aefcc2751d4078ba88aacf4d965c9bdDouglas Gregorprotected:
154042602bb40aefcc2751d4078ba88aacf4d965c9bdDouglas Gregor  virtual void DoDestroy(ASTContext &C);
154142602bb40aefcc2751d4078ba88aacf4d965c9bdDouglas Gregor
154288eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlssonpublic:
154388eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlsson  static CXXExprWithTemporaries *Create(ASTContext &C, Expr *SubExpr,
15440ece491d8f62ce67f047491a6703fac0d3bd4ff4Anders Carlsson                                        CXXTemporary **Temps,
15450ece491d8f62ce67f047491a6703fac0d3bd4ff4Anders Carlsson                                        unsigned NumTemps);
15461eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
154788eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlsson  unsigned getNumTemporaries() const { return NumTemps; }
154888eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlsson  CXXTemporary *getTemporary(unsigned i) {
154988eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlsson    assert(i < NumTemps && "Index out of range");
155088eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlsson    return Temps[i];
155188eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlsson  }
1552f0721fe438d7e40c168e5d664970e7830bc138fbAnders Carlsson  const CXXTemporary *getTemporary(unsigned i) const {
15530ece491d8f62ce67f047491a6703fac0d3bd4ff4Anders Carlsson    return const_cast<CXXExprWithTemporaries*>(this)->getTemporary(i);
1554f0721fe438d7e40c168e5d664970e7830bc138fbAnders Carlsson  }
15551eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
155602bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson  Expr *getSubExpr() { return cast<Expr>(SubExpr); }
1557f0721fe438d7e40c168e5d664970e7830bc138fbAnders Carlsson  const Expr *getSubExpr() const { return cast<Expr>(SubExpr); }
155888eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlsson  void setSubExpr(Expr *E) { SubExpr = E; }
155902bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson
156096be6917e1c4ba1f4435a14c9e7c6c139571d086Douglas Gregor  virtual SourceRange getSourceRange() const {
156196be6917e1c4ba1f4435a14c9e7c6c139571d086Douglas Gregor    return SubExpr->getSourceRange();
156296be6917e1c4ba1f4435a14c9e7c6c139571d086Douglas Gregor  }
156302bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson
156402bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson  // Implement isa/cast/dyncast/etc.
156502bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson  static bool classof(const Stmt *T) {
15662d44e8a41de8a33c0f04ac198714f71dc841bab0Anders Carlsson    return T->getStmtClass() == CXXExprWithTemporariesClass;
156702bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson  }
15682d44e8a41de8a33c0f04ac198714f71dc841bab0Anders Carlsson  static bool classof(const CXXExprWithTemporaries *) { return true; }
156902bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson
157002bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson  // Iterators
157102bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson  virtual child_iterator child_begin();
157202bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson  virtual child_iterator child_end();
157302bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson};
157402bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson
1575d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// \brief Describes an explicit type conversion that uses functional
1576d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// notion but could not be resolved because one or more arguments are
1577d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// type-dependent.
1578d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor///
1579d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// The explicit type conversions expressed by
1580d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// CXXUnresolvedConstructExpr have the form \c T(a1, a2, ..., aN),
1581d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// where \c T is some type and \c a1, a2, ..., aN are values, and
1582d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// either \C T is a dependent type or one or more of the \c a's is
1583d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// type-dependent. For example, this would occur in a template such
1584d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// as:
1585d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor///
1586d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// \code
1587d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor///   template<typename T, typename A1>
1588d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor///   inline T make_a(const A1& a1) {
1589d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor///     return T(a1);
1590d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor///   }
1591d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// \endcode
1592d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor///
1593d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// When the returned expression is instantiated, it may resolve to a
1594d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// constructor call, conversion function call, or some kind of type
1595d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// conversion.
1596d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregorclass CXXUnresolvedConstructExpr : public Expr {
1597d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  /// \brief The starting location of the type
1598d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  SourceLocation TyBeginLoc;
1599d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor
1600d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  /// \brief The type being constructed.
1601d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  QualType Type;
1602d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor
1603d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  /// \brief The location of the left parentheses ('(').
1604d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  SourceLocation LParenLoc;
1605d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor
1606d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  /// \brief The location of the right parentheses (')').
1607d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  SourceLocation RParenLoc;
1608d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor
1609d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  /// \brief The number of arguments used to construct the type.
1610d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  unsigned NumArgs;
16111eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1612d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  CXXUnresolvedConstructExpr(SourceLocation TyBegin,
1613d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor                             QualType T,
1614d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor                             SourceLocation LParenLoc,
1615d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor                             Expr **Args,
1616d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor                             unsigned NumArgs,
1617d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor                             SourceLocation RParenLoc);
1618d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor
1619d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregorpublic:
16201eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  static CXXUnresolvedConstructExpr *Create(ASTContext &C,
1621d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor                                            SourceLocation TyBegin,
1622d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor                                            QualType T,
1623d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor                                            SourceLocation LParenLoc,
1624d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor                                            Expr **Args,
1625d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor                                            unsigned NumArgs,
1626d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor                                            SourceLocation RParenLoc);
1627d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor
1628d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  /// \brief Retrieve the source location where the type begins.
1629d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  SourceLocation getTypeBeginLoc() const { return TyBeginLoc; }
1630d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  void setTypeBeginLoc(SourceLocation L) { TyBeginLoc = L; }
1631d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor
1632d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  /// \brief Retrieve the type that is being constructed, as specified
1633d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  /// in the source code.
1634d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  QualType getTypeAsWritten() const { return Type; }
1635d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  void setTypeAsWritten(QualType T) { Type = T; }
1636d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor
1637d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  /// \brief Retrieve the location of the left parentheses ('(') that
1638d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  /// precedes the argument list.
1639d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  SourceLocation getLParenLoc() const { return LParenLoc; }
1640d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  void setLParenLoc(SourceLocation L) { LParenLoc = L; }
1641d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor
1642d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  /// \brief Retrieve the location of the right parentheses (')') that
1643d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  /// follows the argument list.
1644d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  SourceLocation getRParenLoc() const { return RParenLoc; }
1645d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  void setRParenLoc(SourceLocation L) { RParenLoc = L; }
1646d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor
1647d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  /// \brief Retrieve the number of arguments.
1648d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  unsigned arg_size() const { return NumArgs; }
1649d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor
1650d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  typedef Expr** arg_iterator;
1651d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  arg_iterator arg_begin() { return reinterpret_cast<Expr**>(this + 1); }
1652d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  arg_iterator arg_end() { return arg_begin() + NumArgs; }
1653d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor
16541dd7383dc48718c452e71a625b29531dd96fbb9dJohn McCall  typedef const Expr* const * const_arg_iterator;
16551dd7383dc48718c452e71a625b29531dd96fbb9dJohn McCall  const_arg_iterator arg_begin() const {
16561dd7383dc48718c452e71a625b29531dd96fbb9dJohn McCall    return reinterpret_cast<const Expr* const *>(this + 1);
16571dd7383dc48718c452e71a625b29531dd96fbb9dJohn McCall  }
16581dd7383dc48718c452e71a625b29531dd96fbb9dJohn McCall  const_arg_iterator arg_end() const {
16591dd7383dc48718c452e71a625b29531dd96fbb9dJohn McCall    return arg_begin() + NumArgs;
16601dd7383dc48718c452e71a625b29531dd96fbb9dJohn McCall  }
16611dd7383dc48718c452e71a625b29531dd96fbb9dJohn McCall
1662d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  Expr *getArg(unsigned I) {
1663d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor    assert(I < NumArgs && "Argument index out-of-range");
1664d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor    return *(arg_begin() + I);
1665d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  }
1666d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor
16671dd7383dc48718c452e71a625b29531dd96fbb9dJohn McCall  const Expr *getArg(unsigned I) const {
16681dd7383dc48718c452e71a625b29531dd96fbb9dJohn McCall    assert(I < NumArgs && "Argument index out-of-range");
16691dd7383dc48718c452e71a625b29531dd96fbb9dJohn McCall    return *(arg_begin() + I);
16701dd7383dc48718c452e71a625b29531dd96fbb9dJohn McCall  }
16711dd7383dc48718c452e71a625b29531dd96fbb9dJohn McCall
1672d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  virtual SourceRange getSourceRange() const {
1673d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor    return SourceRange(TyBeginLoc, RParenLoc);
1674d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  }
16751eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  static bool classof(const Stmt *T) {
1676d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor    return T->getStmtClass() == CXXUnresolvedConstructExprClass;
1677d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  }
1678d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  static bool classof(const CXXUnresolvedConstructExpr *) { return true; }
1679d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor
1680d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  // Iterators
1681d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  virtual child_iterator child_begin();
1682d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  virtual child_iterator child_end();
1683d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor};
1684d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor
1685ba13543329afac4a0d01304ec2ec4924d99306a6John McCall/// \brief Represents a C++ member access expression where the actual
1686ba13543329afac4a0d01304ec2ec4924d99306a6John McCall/// member referenced could not be resolved because the base
1687ba13543329afac4a0d01304ec2ec4924d99306a6John McCall/// expression or the member name was dependent.
1688aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall///
1689aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall/// Like UnresolvedMemberExprs, these can be either implicit or
1690aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall/// explicit accesses.  It is only possible to get one of these with
1691aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall/// an implicit access if a qualifier is provided.
1692865d447ac6a4721ab58e898d014a21f2eff74b06John McCallclass CXXDependentScopeMemberExpr : public Expr {
16931c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  /// \brief The expression for the base pointer or class reference,
1694aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall  /// e.g., the \c x in x.f.  Can be null in implicit accesses.
16951c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  Stmt *Base;
16961eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1697aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall  /// \brief The type of the base expression.  Never null, even for
1698aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall  /// implicit accesses.
1699aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall  QualType BaseType;
1700aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall
17011c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  /// \brief Whether this member expression used the '->' operator or
17021c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  /// the '.' operator.
17033b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor  bool IsArrow : 1;
17041c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor
17053b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor  /// \brief Whether this member expression has explicitly-specified template
17063b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor  /// arguments.
1707aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall  bool HasExplicitTemplateArgs : 1;
17081eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
17091c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  /// \brief The location of the '->' or '.' operator.
17101c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  SourceLocation OperatorLoc;
17111c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor
1712a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor  /// \brief The nested-name-specifier that precedes the member name, if any.
1713a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor  NestedNameSpecifier *Qualifier;
17141eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1715a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor  /// \brief The source range covering the nested name specifier.
1716a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor  SourceRange QualifierRange;
17171eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1718c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor  /// \brief In a qualified member access expression such as t->Base::f, this
17191eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  /// member stores the resolves of name lookup in the context of the member
1720c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor  /// access expression, to be used at instantiation time.
1721c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor  ///
1722c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor  /// FIXME: This member, along with the Qualifier and QualifierRange, could
1723c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor  /// be stuck into a structure that is optionally allocated at the end of
1724865d447ac6a4721ab58e898d014a21f2eff74b06John McCall  /// the CXXDependentScopeMemberExpr, to save space in the common case.
1725c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor  NamedDecl *FirstQualifierFoundInScope;
17261eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
17271c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  /// \brief The member to which this member expression refers, which
17281c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  /// can be name, overloaded operator, or destructor.
1729a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor  /// FIXME: could also be a template-id
17301c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  DeclarationName Member;
17311c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor
17321c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  /// \brief The location of the member name.
17331c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  SourceLocation MemberLoc;
17341eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
17353b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor  /// \brief Retrieve the explicit template argument list that followed the
17363b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor  /// member template name, if any.
17373b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor  ExplicitTemplateArgumentList *getExplicitTemplateArgumentList() {
1738aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall    assert(HasExplicitTemplateArgs);
17393b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor    return reinterpret_cast<ExplicitTemplateArgumentList *>(this + 1);
17403b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor  }
17411eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
17423b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor  /// \brief Retrieve the explicit template argument list that followed the
17433b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor  /// member template name, if any.
17443b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor  const ExplicitTemplateArgumentList *getExplicitTemplateArgumentList() const {
1745865d447ac6a4721ab58e898d014a21f2eff74b06John McCall    return const_cast<CXXDependentScopeMemberExpr *>(this)
17463b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor             ->getExplicitTemplateArgumentList();
17473b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor  }
17481eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1749865d447ac6a4721ab58e898d014a21f2eff74b06John McCall  CXXDependentScopeMemberExpr(ASTContext &C,
1750aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall                          Expr *Base, QualType BaseType, bool IsArrow,
17513b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor                          SourceLocation OperatorLoc,
17523b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor                          NestedNameSpecifier *Qualifier,
17533b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor                          SourceRange QualifierRange,
17543b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor                          NamedDecl *FirstQualifierFoundInScope,
17553b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor                          DeclarationName Member,
17563b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor                          SourceLocation MemberLoc,
1757d5532b6cfff2977e0c59fa6ead7f7973984a620dJohn McCall                          const TemplateArgumentListInfo *TemplateArgs);
17581eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
17591c0ca59416999129d0439c2661d137ef38e86209Douglas Gregorpublic:
1760865d447ac6a4721ab58e898d014a21f2eff74b06John McCall  CXXDependentScopeMemberExpr(ASTContext &C,
1761aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall                          Expr *Base, QualType BaseType,
1762aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall                          bool IsArrow,
17631c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor                          SourceLocation OperatorLoc,
1764a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor                          NestedNameSpecifier *Qualifier,
1765a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor                          SourceRange QualifierRange,
1766c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor                          NamedDecl *FirstQualifierFoundInScope,
17671c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor                          DeclarationName Member,
17681c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor                          SourceLocation MemberLoc)
1769865d447ac6a4721ab58e898d014a21f2eff74b06John McCall  : Expr(CXXDependentScopeMemberExprClass, C.DependentTy, true, true),
1770aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall    Base(Base), BaseType(BaseType), IsArrow(IsArrow),
1771aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall    HasExplicitTemplateArgs(false), OperatorLoc(OperatorLoc),
17723b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor    Qualifier(Qualifier), QualifierRange(QualifierRange),
17733b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor    FirstQualifierFoundInScope(FirstQualifierFoundInScope),
17743b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor    Member(Member), MemberLoc(MemberLoc) { }
17751eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1776865d447ac6a4721ab58e898d014a21f2eff74b06John McCall  static CXXDependentScopeMemberExpr *
17771eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  Create(ASTContext &C,
1778aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall         Expr *Base, QualType BaseType, bool IsArrow,
17793b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor         SourceLocation OperatorLoc,
17803b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor         NestedNameSpecifier *Qualifier,
17813b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor         SourceRange QualifierRange,
17823b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor         NamedDecl *FirstQualifierFoundInScope,
17833b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor         DeclarationName Member,
17843b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor         SourceLocation MemberLoc,
1785d5532b6cfff2977e0c59fa6ead7f7973984a620dJohn McCall         const TemplateArgumentListInfo *TemplateArgs);
17861eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1787aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall  /// \brief True if this is an implicit access, i.e. one in which the
1788aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall  /// member being accessed was not written in the source.  The source
1789aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall  /// location of the operator is invalid in this case.
1790aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall  bool isImplicitAccess() const { return Base == 0; }
1791aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall
17921c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  /// \brief Retrieve the base object of this member expressions,
17931c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  /// e.g., the \c x in \c x.m.
1794aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall  Expr *getBase() const {
1795aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall    assert(!isImplicitAccess());
1796aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall    return cast<Expr>(Base);
1797aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall  }
17981c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  void setBase(Expr *E) { Base = E; }
17991c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor
1800aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall  QualType getBaseType() const { return BaseType; }
1801aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall
18021c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  /// \brief Determine whether this member expression used the '->'
18031c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  /// operator; otherwise, it used the '.' operator.
18041c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  bool isArrow() const { return IsArrow; }
18051c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  void setArrow(bool A) { IsArrow = A; }
18061c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor
18071c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  /// \brief Retrieve the location of the '->' or '.' operator.
18081c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  SourceLocation getOperatorLoc() const { return OperatorLoc; }
18091c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  void setOperatorLoc(SourceLocation L) { OperatorLoc = L; }
18101c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor
1811a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor  /// \brief Retrieve the nested-name-specifier that qualifies the member
1812a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor  /// name.
1813a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor  NestedNameSpecifier *getQualifier() const { return Qualifier; }
18141eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1815a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor  /// \brief Retrieve the source range covering the nested-name-specifier
1816a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor  /// that qualifies the member name.
1817a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor  SourceRange getQualifierRange() const { return QualifierRange; }
18181eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1819c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor  /// \brief Retrieve the first part of the nested-name-specifier that was
1820c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor  /// found in the scope of the member access expression when the member access
1821c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor  /// was initially parsed.
1822c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor  ///
1823c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor  /// This function only returns a useful result when member access expression
18241eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  /// uses a qualified member name, e.g., "x.Base::f". Here, the declaration
18251eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  /// returned by this function describes what was found by unqualified name
1826c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor  /// lookup for the identifier "Base" within the scope of the member access
1827c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor  /// expression itself. At template instantiation time, this information is
1828c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor  /// combined with the results of name lookup into the type of the object
1829c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor  /// expression itself (the class type of x).
18301eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  NamedDecl *getFirstQualifierFoundInScope() const {
1831c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor    return FirstQualifierFoundInScope;
1832c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor  }
18331eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
18341c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  /// \brief Retrieve the name of the member that this expression
18351c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  /// refers to.
18361c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  DeclarationName getMember() const { return Member; }
18371c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  void setMember(DeclarationName N) { Member = N; }
18381c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor
18391c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  // \brief Retrieve the location of the name of the member that this
18401c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  // expression refers to.
18411c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  SourceLocation getMemberLoc() const { return MemberLoc; }
18421c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  void setMemberLoc(SourceLocation L) { MemberLoc = L; }
18431c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor
18443b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor  /// \brief Determines whether this member expression actually had a C++
18453b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor  /// template argument list explicitly specified, e.g., x.f<int>.
1846aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall  bool hasExplicitTemplateArgs() const {
1847aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall    return HasExplicitTemplateArgs;
18483b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor  }
18491eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1850d5532b6cfff2977e0c59fa6ead7f7973984a620dJohn McCall  /// \brief Copies the template arguments (if present) into the given
1851d5532b6cfff2977e0c59fa6ead7f7973984a620dJohn McCall  /// structure.
1852d5532b6cfff2977e0c59fa6ead7f7973984a620dJohn McCall  void copyTemplateArgumentsInto(TemplateArgumentListInfo &List) const {
1853aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall    assert(HasExplicitTemplateArgs);
1854aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall    getExplicitTemplateArgumentList()->copyInto(List);
1855d5532b6cfff2977e0c59fa6ead7f7973984a620dJohn McCall  }
1856d5532b6cfff2977e0c59fa6ead7f7973984a620dJohn McCall
18571eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  /// \brief Retrieve the location of the left angle bracket following the
18583b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor  /// member name ('<'), if any.
18591eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  SourceLocation getLAngleLoc() const {
1860aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall    assert(HasExplicitTemplateArgs);
18613b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor    return getExplicitTemplateArgumentList()->LAngleLoc;
18623b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor  }
18631eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
18643b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor  /// \brief Retrieve the template arguments provided as part of this
18653b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor  /// template-id.
1866833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall  const TemplateArgumentLoc *getTemplateArgs() const {
1867aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall    assert(HasExplicitTemplateArgs);
18683b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor    return getExplicitTemplateArgumentList()->getTemplateArgs();
18693b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor  }
18701eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
18713b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor  /// \brief Retrieve the number of template arguments provided as part of this
18723b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor  /// template-id.
18731eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  unsigned getNumTemplateArgs() const {
1874aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall    assert(HasExplicitTemplateArgs);
18753b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor    return getExplicitTemplateArgumentList()->NumTemplateArgs;
18763b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor  }
18771eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
18781eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  /// \brief Retrieve the location of the right angle bracket following the
18793b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor  /// template arguments ('>').
18801eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  SourceLocation getRAngleLoc() const {
1881aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall    assert(HasExplicitTemplateArgs);
18823b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor    return getExplicitTemplateArgumentList()->RAngleLoc;
18833b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor  }
18841eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
18851c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  virtual SourceRange getSourceRange() const {
1886aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall    SourceRange Range;
1887aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall    if (!isImplicitAccess())
1888aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall      Range.setBegin(Base->getSourceRange().getBegin());
1889aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall    else if (getQualifier())
1890aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall      Range.setBegin(getQualifierRange().getBegin());
1891aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall    else
1892aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall      Range.setBegin(MemberLoc);
18931eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1894aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall    if (hasExplicitTemplateArgs())
1895aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall      Range.setEnd(getRAngleLoc());
1896aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall    else
1897aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall      Range.setEnd(MemberLoc);
1898aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall    return Range;
18991c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  }
19001eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
19011eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  static bool classof(const Stmt *T) {
1902865d447ac6a4721ab58e898d014a21f2eff74b06John McCall    return T->getStmtClass() == CXXDependentScopeMemberExprClass;
19031c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  }
1904865d447ac6a4721ab58e898d014a21f2eff74b06John McCall  static bool classof(const CXXDependentScopeMemberExpr *) { return true; }
19051c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor
19061c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  // Iterators
19071c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  virtual child_iterator child_begin();
19081c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  virtual child_iterator child_end();
19091c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor};
19101c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor
1911129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall/// \brief Represents a C++ member access expression for which lookup
1912aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall/// produced a set of overloaded functions.
1913aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall///
1914aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall/// The member access may be explicit or implicit:
1915aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall///    struct A {
1916aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall///      int a, b;
1917aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall///      int explicitAccess() { return this->a + this->A::b; }
1918aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall///      int implicitAccess() { return a + A::b; }
1919aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall///    };
1920aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall///
1921aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall/// In the final AST, an explicit access always becomes a MemberExpr.
1922aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall/// An implicit access may become either a MemberExpr or a
1923aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall/// DeclRefExpr, depending on whether the member is static.
19247bb12da2b0749eeebb21854c77877736969e59f2John McCallclass UnresolvedMemberExpr : public OverloadExpr {
1925129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// \brief Whether this member expression used the '->' operator or
1926129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// the '.' operator.
1927129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  bool IsArrow : 1;
1928129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall
1929129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// \brief Whether the lookup results contain an unresolved using
1930129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// declaration.
1931129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  bool HasUnresolvedUsing : 1;
1932129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall
19337bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// \brief The expression for the base pointer or class reference,
19347bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// e.g., the \c x in x.f.  This can be null if this is an 'unbased'
19357bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// member expression
19367bb12da2b0749eeebb21854c77877736969e59f2John McCall  Stmt *Base;
19377bb12da2b0749eeebb21854c77877736969e59f2John McCall
19387bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// \brief The type of the base expression;  never null.
19397bb12da2b0749eeebb21854c77877736969e59f2John McCall  QualType BaseType;
1940129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall
1941129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// \brief The location of the '->' or '.' operator.
1942129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  SourceLocation OperatorLoc;
1943129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall
1944129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  UnresolvedMemberExpr(QualType T, bool Dependent,
1945129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall                       bool HasUnresolvedUsing,
1946aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall                       Expr *Base, QualType BaseType, bool IsArrow,
1947129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall                       SourceLocation OperatorLoc,
1948129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall                       NestedNameSpecifier *Qualifier,
1949129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall                       SourceRange QualifierRange,
1950129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall                       DeclarationName Member,
1951129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall                       SourceLocation MemberLoc,
1952129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall                       const TemplateArgumentListInfo *TemplateArgs);
1953129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall
1954129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCallpublic:
1955129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  static UnresolvedMemberExpr *
1956129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  Create(ASTContext &C, bool Dependent, bool HasUnresolvedUsing,
1957aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall         Expr *Base, QualType BaseType, bool IsArrow,
1958129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall         SourceLocation OperatorLoc,
1959129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall         NestedNameSpecifier *Qualifier,
1960129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall         SourceRange QualifierRange,
1961129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall         DeclarationName Member,
1962129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall         SourceLocation MemberLoc,
1963129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall         const TemplateArgumentListInfo *TemplateArgs);
1964129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall
1965aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall  /// \brief True if this is an implicit access, i.e. one in which the
1966aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall  /// member being accessed was not written in the source.  The source
1967aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall  /// location of the operator is invalid in this case.
1968aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall  bool isImplicitAccess() const { return Base == 0; }
1969aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall
1970129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// \brief Retrieve the base object of this member expressions,
1971129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// e.g., the \c x in \c x.m.
1972aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall  Expr *getBase() {
1973aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall    assert(!isImplicitAccess());
1974aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall    return cast<Expr>(Base);
1975aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall  }
19762f27bf854f0519810b34afd209089cc75536b757John McCall  const Expr *getBase() const {
19772f27bf854f0519810b34afd209089cc75536b757John McCall    assert(!isImplicitAccess());
19782f27bf854f0519810b34afd209089cc75536b757John McCall    return cast<Expr>(Base);
19792f27bf854f0519810b34afd209089cc75536b757John McCall  }
1980129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  void setBase(Expr *E) { Base = E; }
1981129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall
1982aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall  QualType getBaseType() const { return BaseType; }
1983aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall
1984129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// \brief Determine whether this member expression used the '->'
1985129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// operator; otherwise, it used the '.' operator.
1986129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  bool isArrow() const { return IsArrow; }
1987129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  void setArrow(bool A) { IsArrow = A; }
1988129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall
1989129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// \brief Retrieve the location of the '->' or '.' operator.
1990129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  SourceLocation getOperatorLoc() const { return OperatorLoc; }
1991129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  void setOperatorLoc(SourceLocation L) { OperatorLoc = L; }
1992129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall
1993c373d48502ca7683ab55385f5bd624d778eb288dJohn McCall  /// \brief Retrieves the naming class of this lookup.
1994c373d48502ca7683ab55385f5bd624d778eb288dJohn McCall  CXXRecordDecl *getNamingClass() const;
1995c373d48502ca7683ab55385f5bd624d778eb288dJohn McCall
1996129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// \brief Retrieve the name of the member that this expression
1997129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// refers to.
19987bb12da2b0749eeebb21854c77877736969e59f2John McCall  DeclarationName getMemberName() const { return getName(); }
19997bb12da2b0749eeebb21854c77877736969e59f2John McCall  void setMemberName(DeclarationName N) { setName(N); }
2000129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall
2001129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  // \brief Retrieve the location of the name of the member that this
2002129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  // expression refers to.
20037bb12da2b0749eeebb21854c77877736969e59f2John McCall  SourceLocation getMemberLoc() const { return getNameLoc(); }
20047bb12da2b0749eeebb21854c77877736969e59f2John McCall  void setMemberLoc(SourceLocation L) { setNameLoc(L); }
2005129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall
20067bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// \brief Retrieve the explicit template argument list that followed the
20077bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// member template name.
20087bb12da2b0749eeebb21854c77877736969e59f2John McCall  ExplicitTemplateArgumentList &getExplicitTemplateArgs() {
20097bb12da2b0749eeebb21854c77877736969e59f2John McCall    assert(hasExplicitTemplateArgs());
20107bb12da2b0749eeebb21854c77877736969e59f2John McCall    return *reinterpret_cast<ExplicitTemplateArgumentList *>(this + 1);
20117bb12da2b0749eeebb21854c77877736969e59f2John McCall  }
20127bb12da2b0749eeebb21854c77877736969e59f2John McCall
20137bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// \brief Retrieve the explicit template argument list that followed the
20147bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// member template name, if any.
20157bb12da2b0749eeebb21854c77877736969e59f2John McCall  const ExplicitTemplateArgumentList &getExplicitTemplateArgs() const {
20167bb12da2b0749eeebb21854c77877736969e59f2John McCall    assert(hasExplicitTemplateArgs());
20177bb12da2b0749eeebb21854c77877736969e59f2John McCall    return *reinterpret_cast<const ExplicitTemplateArgumentList *>(this + 1);
2018129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  }
2019129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall
2020129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// \brief Copies the template arguments into the given structure.
2021129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  void copyTemplateArgumentsInto(TemplateArgumentListInfo &List) const {
20227bb12da2b0749eeebb21854c77877736969e59f2John McCall    getExplicitTemplateArgs().copyInto(List);
2023129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  }
2024129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall
2025129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// \brief Retrieve the location of the left angle bracket following
2026129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// the member name ('<').
2027129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  SourceLocation getLAngleLoc() const {
20287bb12da2b0749eeebb21854c77877736969e59f2John McCall    return getExplicitTemplateArgs().LAngleLoc;
2029129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  }
2030129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall
2031129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// \brief Retrieve the template arguments provided as part of this
2032129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// template-id.
2033129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  const TemplateArgumentLoc *getTemplateArgs() const {
20347bb12da2b0749eeebb21854c77877736969e59f2John McCall    return getExplicitTemplateArgs().getTemplateArgs();
2035129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  }
2036129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall
2037129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// \brief Retrieve the number of template arguments provided as
2038129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// part of this template-id.
2039129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  unsigned getNumTemplateArgs() const {
20407bb12da2b0749eeebb21854c77877736969e59f2John McCall    return getExplicitTemplateArgs().NumTemplateArgs;
2041129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  }
2042129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall
2043129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// \brief Retrieve the location of the right angle bracket
2044129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// following the template arguments ('>').
2045129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  SourceLocation getRAngleLoc() const {
20467bb12da2b0749eeebb21854c77877736969e59f2John McCall    return getExplicitTemplateArgs().RAngleLoc;
2047129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  }
2048129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall
2049129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  virtual SourceRange getSourceRange() const {
2050aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall    SourceRange Range;
2051aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall    if (!isImplicitAccess())
2052aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall      Range.setBegin(Base->getSourceRange().getBegin());
2053aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall    else if (getQualifier())
2054aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall      Range.setBegin(getQualifierRange().getBegin());
2055aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall    else
20567bb12da2b0749eeebb21854c77877736969e59f2John McCall      Range.setBegin(getMemberLoc());
2057aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall
2058129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall    if (hasExplicitTemplateArgs())
2059129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall      Range.setEnd(getRAngleLoc());
2060129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall    else
20617bb12da2b0749eeebb21854c77877736969e59f2John McCall      Range.setEnd(getMemberLoc());
2062129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall    return Range;
2063129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  }
2064129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall
2065129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  static bool classof(const Stmt *T) {
2066129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall    return T->getStmtClass() == UnresolvedMemberExprClass;
2067129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  }
2068129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  static bool classof(const UnresolvedMemberExpr *) { return true; }
2069129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall
2070129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  // Iterators
2071129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  virtual child_iterator child_begin();
2072129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  virtual child_iterator child_end();
2073129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall};
2074129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall
20757bb12da2b0749eeebb21854c77877736969e59f2John McCallinline ExplicitTemplateArgumentList &OverloadExpr::getExplicitTemplateArgs() {
20767bb12da2b0749eeebb21854c77877736969e59f2John McCall  if (isa<UnresolvedLookupExpr>(this))
20777bb12da2b0749eeebb21854c77877736969e59f2John McCall    return cast<UnresolvedLookupExpr>(this)->getExplicitTemplateArgs();
20787bb12da2b0749eeebb21854c77877736969e59f2John McCall  else
20797bb12da2b0749eeebb21854c77877736969e59f2John McCall    return cast<UnresolvedMemberExpr>(this)->getExplicitTemplateArgs();
20807bb12da2b0749eeebb21854c77877736969e59f2John McCall}
20817bb12da2b0749eeebb21854c77877736969e59f2John McCall
20825f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer}  // end namespace clang
20835f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer
20845f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer#endif
2085