ExprCXX.h revision eb7f96141f754150a92433286fa385910a22f494
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:
8654c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  CXXNewExpr(bool globalNew, FunctionDecl *operatorNew, Expr **placementArgs,
866cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl             unsigned numPlaceArgs, bool ParenTypeId, Expr *arraySize,
8674c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl             CXXConstructorDecl *constructor, bool initializer,
8684c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl             Expr **constructorArgs, unsigned numConsArgs,
8694c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl             FunctionDecl *operatorDelete, QualType ty,
8704c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl             SourceLocation startLoc, SourceLocation endLoc);
8714c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  ~CXXNewExpr() {
8724c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl    delete[] SubExprs;
8734c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  }
8744c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
875cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl  QualType getAllocatedType() const {
876cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl    assert(getType()->isPointerType());
8776217b80b7a1379b74cced1c076338262c3c980b3Ted Kremenek    return getType()->getAs<PointerType>()->getPointeeType();
878cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl  }
8794c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
8804c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  FunctionDecl *getOperatorNew() const { return OperatorNew; }
8814c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  FunctionDecl *getOperatorDelete() const { return OperatorDelete; }
8824c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  CXXConstructorDecl *getConstructor() const { return Constructor; }
8834c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
884cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl  bool isArray() const { return Array; }
885cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl  Expr *getArraySize() {
886cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl    return Array ? cast<Expr>(SubExprs[0]) : 0;
887cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl  }
888cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl  const Expr *getArraySize() const {
889cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl    return Array ? cast<Expr>(SubExprs[0]) : 0;
890cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl  }
891cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl
8924c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  unsigned getNumPlacementArgs() const { return NumPlacementArgs; }
8934c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  Expr *getPlacementArg(unsigned i) {
8944c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl    assert(i < NumPlacementArgs && "Index out of range");
895cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl    return cast<Expr>(SubExprs[Array + i]);
8964c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  }
8974c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  const Expr *getPlacementArg(unsigned i) const {
8984c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl    assert(i < NumPlacementArgs && "Index out of range");
899cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl    return cast<Expr>(SubExprs[Array + i]);
9004c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  }
9014c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
9024c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  bool isGlobalNew() const { return GlobalNew; }
9034c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  bool isParenTypeId() const { return ParenTypeId; }
9044c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  bool hasInitializer() const { return Initializer; }
9054c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
9064c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  unsigned getNumConstructorArgs() const { return NumConstructorArgs; }
9074c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  Expr *getConstructorArg(unsigned i) {
9084c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl    assert(i < NumConstructorArgs && "Index out of range");
909cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl    return cast<Expr>(SubExprs[Array + NumPlacementArgs + i]);
9104c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  }
9114c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  const Expr *getConstructorArg(unsigned i) const {
9124c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl    assert(i < NumConstructorArgs && "Index out of range");
913cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl    return cast<Expr>(SubExprs[Array + NumPlacementArgs + i]);
9144c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  }
9154c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
9164c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  typedef ExprIterator arg_iterator;
9174c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  typedef ConstExprIterator const_arg_iterator;
9184c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
9194c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  arg_iterator placement_arg_begin() {
920cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl    return SubExprs + Array;
9214c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  }
9224c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  arg_iterator placement_arg_end() {
923cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl    return SubExprs + Array + getNumPlacementArgs();
9244c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  }
9254c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  const_arg_iterator placement_arg_begin() const {
926cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl    return SubExprs + Array;
9274c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  }
9284c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  const_arg_iterator placement_arg_end() const {
929cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl    return SubExprs + Array + getNumPlacementArgs();
9304c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  }
9314c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
9324c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  arg_iterator constructor_arg_begin() {
933cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl    return SubExprs + Array + getNumPlacementArgs();
9344c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  }
9354c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  arg_iterator constructor_arg_end() {
936cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl    return SubExprs + Array + getNumPlacementArgs() + getNumConstructorArgs();
9374c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  }
9384c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  const_arg_iterator constructor_arg_begin() const {
939cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl    return SubExprs + Array + getNumPlacementArgs();
9404c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  }
9414c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  const_arg_iterator constructor_arg_end() const {
942cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl    return SubExprs + Array + getNumPlacementArgs() + getNumConstructorArgs();
9434c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  }
9444c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
9454c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  virtual SourceRange getSourceRange() const {
9464c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl    return SourceRange(StartLoc, EndLoc);
9474c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  }
9484c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
9494c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  static bool classof(const Stmt *T) {
9504c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl    return T->getStmtClass() == CXXNewExprClass;
9514c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  }
9524c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  static bool classof(const CXXNewExpr *) { return true; }
9534c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
9544c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  // Iterators
9554c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  virtual child_iterator child_begin();
9564c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  virtual child_iterator child_end();
9574c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl};
9584c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
9594c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl/// CXXDeleteExpr - A delete expression for memory deallocation and destructor
9604c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl/// calls, e.g. "delete[] pArray".
9614c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redlclass CXXDeleteExpr : public Expr {
9624c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  // Is this a forced global delete, i.e. "::delete"?
9634c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  bool GlobalDelete : 1;
9644c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  // Is this the array form of delete, i.e. "delete[]"?
9654c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  bool ArrayForm : 1;
9664c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  // Points to the operator delete overload that is used. Could be a member.
9674c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  FunctionDecl *OperatorDelete;
9684c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  // The pointer expression to be deleted.
9694c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  Stmt *Argument;
9704c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  // Location of the expression.
9714c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  SourceLocation Loc;
9724c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redlpublic:
9734c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  CXXDeleteExpr(QualType ty, bool globalDelete, bool arrayForm,
9744c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl                FunctionDecl *operatorDelete, Expr *arg, SourceLocation loc)
9752850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl    : Expr(CXXDeleteExprClass, ty, false, false), GlobalDelete(globalDelete),
9764c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl      ArrayForm(arrayForm), OperatorDelete(operatorDelete), Argument(arg),
9774c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl      Loc(loc) { }
9784c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
9794c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  bool isGlobalDelete() const { return GlobalDelete; }
9804c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  bool isArrayForm() const { return ArrayForm; }
9814c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
9824c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  FunctionDecl *getOperatorDelete() const { return OperatorDelete; }
9834c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
9844c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  Expr *getArgument() { return cast<Expr>(Argument); }
9854c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  const Expr *getArgument() const { return cast<Expr>(Argument); }
9864c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
9874c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  virtual SourceRange getSourceRange() const {
9884c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl    return SourceRange(Loc, Argument->getLocEnd());
9894c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  }
9904c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
9914c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  static bool classof(const Stmt *T) {
9924c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl    return T->getStmtClass() == CXXDeleteExprClass;
9934c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  }
9944c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  static bool classof(const CXXDeleteExpr *) { return true; }
9954c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
9964c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  // Iterators
9974c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  virtual child_iterator child_begin();
9984c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  virtual child_iterator child_end();
9994c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl};
10004c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
1001a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor/// \brief Represents a C++ pseudo-destructor (C++ [expr.pseudo]).
1002a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor///
1003a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor/// Example:
1004a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor///
1005a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor/// \code
10061eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump/// template<typename T>
1007a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor/// void destroy(T* ptr) {
1008a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor///   ptr->~T();
1009a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor/// }
1010a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor/// \endcode
1011a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor///
1012a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor/// When the template is parsed, the expression \c ptr->~T will be stored as
1013a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor/// a member reference expression. If it then instantiated with a scalar type
10141eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump/// as a template argument for T, the resulting expression will be a
1015a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor/// pseudo-destructor expression.
1016a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregorclass CXXPseudoDestructorExpr : public Expr {
1017a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  /// \brief The base expression (that is being destroyed).
1018a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  Stmt *Base;
10191eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1020a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  /// \brief Whether the operator was an arrow ('->'); otherwise, it was a
1021a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  /// period ('.').
1022a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  bool IsArrow : 1;
10231eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1024a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  /// \brief The location of the '.' or '->' operator.
1025a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  SourceLocation OperatorLoc;
10261eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1027a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  /// \brief The nested-name-specifier that follows the operator, if present.
1028a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  NestedNameSpecifier *Qualifier;
10291eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
10301eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  /// \brief The source range that covers the nested-name-specifier, if
1031a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  /// present.
1032a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  SourceRange QualifierRange;
10331eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1034a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  /// \brief The type being destroyed.
1035a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  QualType DestroyedType;
10361eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1037a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  /// \brief The location of the type after the '~'.
1038a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  SourceLocation DestroyedTypeLoc;
10391eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1040a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregorpublic:
1041a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  CXXPseudoDestructorExpr(ASTContext &Context,
1042a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor                          Expr *Base, bool isArrow, SourceLocation OperatorLoc,
1043a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor                          NestedNameSpecifier *Qualifier,
1044a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor                          SourceRange QualifierRange,
10451eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump                          QualType DestroyedType,
1046a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor                          SourceLocation DestroyedTypeLoc)
10471eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump    : Expr(CXXPseudoDestructorExprClass,
1048a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor           Context.getPointerType(Context.getFunctionType(Context.VoidTy, 0, 0,
1049a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor                                                          false, 0)),
1050a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor           /*isTypeDependent=*/false,
1051a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor           /*isValueDependent=*/Base->isValueDependent()),
10521eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump      Base(static_cast<Stmt *>(Base)), IsArrow(isArrow),
1053a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor      OperatorLoc(OperatorLoc), Qualifier(Qualifier),
1054a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor      QualifierRange(QualifierRange), DestroyedType(DestroyedType),
1055a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor      DestroyedTypeLoc(DestroyedTypeLoc) { }
10561eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1057a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  void setBase(Expr *E) { Base = E; }
1058a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  Expr *getBase() const { return cast<Expr>(Base); }
10591eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
10601eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  /// \brief Determines whether this member expression actually had
1061a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  /// a C++ nested-name-specifier prior to the name of the member, e.g.,
1062a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  /// x->Base::foo.
1063a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  bool hasQualifier() const { return Qualifier != 0; }
10641eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1065a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  /// \brief If the member name was qualified, retrieves the source range of
1066a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  /// the nested-name-specifier that precedes the member name. Otherwise,
1067a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  /// returns an empty source range.
1068a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  SourceRange getQualifierRange() const { return QualifierRange; }
10691eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
10701eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  /// \brief If the member name was qualified, retrieves the
1071a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  /// nested-name-specifier that precedes the member name. Otherwise, returns
1072a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  /// NULL.
1073a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  NestedNameSpecifier *getQualifier() const { return Qualifier; }
10741eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1075a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  /// \brief Determine whether this pseudo-destructor expression was written
1076a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  /// using an '->' (otherwise, it used a '.').
1077a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  bool isArrow() const { return IsArrow; }
1078a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  void setArrow(bool A) { IsArrow = A; }
1079a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor
1080a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  /// \brief Retrieve the location of the '.' or '->' operator.
1081a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  SourceLocation getOperatorLoc() const { return OperatorLoc; }
10821eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1083a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  /// \brief Retrieve the type that is being destroyed.
1084a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  QualType getDestroyedType() const { return DestroyedType; }
10851eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1086a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  /// \brief Retrieve the location of the type being destroyed.
1087a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  SourceLocation getDestroyedTypeLoc() const { return DestroyedTypeLoc; }
10881eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1089a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  virtual SourceRange getSourceRange() const {
1090a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor    return SourceRange(Base->getLocStart(), DestroyedTypeLoc);
1091a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  }
10921eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
10931eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  static bool classof(const Stmt *T) {
1094a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor    return T->getStmtClass() == CXXPseudoDestructorExprClass;
1095a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  }
1096a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  static bool classof(const CXXPseudoDestructorExpr *) { return true; }
10971eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1098a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  // Iterators
1099a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  virtual child_iterator child_begin();
11001eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  virtual child_iterator child_end();
1101a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor};
11021eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
110364b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl/// UnaryTypeTraitExpr - A GCC or MS unary type trait, as used in the
110464b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl/// implementation of TR1/C++0x type trait templates.
110564b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl/// Example:
110664b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl/// __is_pod(int) == true
110764b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl/// __is_enum(std::string) == false
110864b45f7e0d3167f040841ac2920aead7f080730dSebastian Redlclass UnaryTypeTraitExpr : public Expr {
110964b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl  /// UTT - The trait.
111064b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl  UnaryTypeTrait UTT;
111164b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl
111264b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl  /// Loc - The location of the type trait keyword.
111364b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl  SourceLocation Loc;
111464b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl
111564b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl  /// RParen - The location of the closing paren.
111664b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl  SourceLocation RParen;
111764b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl
111864b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl  /// QueriedType - The type we're testing.
111964b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl  QualType QueriedType;
112064b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl
112164b45f7e0d3167f040841ac2920aead7f080730dSebastian Redlpublic:
112264b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl  UnaryTypeTraitExpr(SourceLocation loc, UnaryTypeTrait utt, QualType queried,
112364b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl                     SourceLocation rparen, QualType ty)
112464b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl    : Expr(UnaryTypeTraitExprClass, ty, false, queried->isDependentType()),
112564b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl      UTT(utt), Loc(loc), RParen(rparen), QueriedType(queried) { }
112664b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl
112764b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl  virtual SourceRange getSourceRange() const { return SourceRange(Loc, RParen);}
112864b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl
112964b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl  UnaryTypeTrait getTrait() const { return UTT; }
113064b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl
113164b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl  QualType getQueriedType() const { return QueriedType; }
113264b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl
11335e03f9ea8174ae588c5e69ec6b5ef4c68f8fd766Douglas Gregor  bool EvaluateTrait(ASTContext&) const;
113464b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl
113564b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl  static bool classof(const Stmt *T) {
113664b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl    return T->getStmtClass() == UnaryTypeTraitExprClass;
113764b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl  }
113864b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl  static bool classof(const UnaryTypeTraitExpr *) { return true; }
113964b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl
114064b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl  // Iterators
114164b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl  virtual child_iterator child_begin();
114264b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl  virtual child_iterator child_end();
114364b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl};
114464b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl
11457bb12da2b0749eeebb21854c77877736969e59f2John McCall/// \brief A reference to an overloaded function set, either an
11467bb12da2b0749eeebb21854c77877736969e59f2John McCall/// \t UnresolvedLookupExpr or an \t UnresolvedMemberExpr.
11477bb12da2b0749eeebb21854c77877736969e59f2John McCallclass OverloadExpr : public Expr {
1148ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  /// The results.  These are undesugared, which is to say, they may
11497bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// include UsingShadowDecls.  Access is relative to the naming
11507bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// class.
1151eec51cf1ba5f0e62c9cdb81b5c63babdd6e649abJohn McCall  UnresolvedSet<4> Results;
1152ba13543329afac4a0d01304ec2ec4924d99306a6John McCall
11537bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// The common name of these declarations.
1154ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  DeclarationName Name;
1155ba13543329afac4a0d01304ec2ec4924d99306a6John McCall
11567bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// The scope specifier, if any.
1157ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  NestedNameSpecifier *Qualifier;
11587bb12da2b0749eeebb21854c77877736969e59f2John McCall
11597bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// The source range of the scope specifier.
1160ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  SourceRange QualifierRange;
1161ba13543329afac4a0d01304ec2ec4924d99306a6John McCall
1162ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  /// The location of the name.
1163ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  SourceLocation NameLoc;
1164ba13543329afac4a0d01304ec2ec4924d99306a6John McCall
11657bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// True if the name was a template-id.
11667bb12da2b0749eeebb21854c77877736969e59f2John McCall  bool HasExplicitTemplateArgs;
11677bb12da2b0749eeebb21854c77877736969e59f2John McCall
11687bb12da2b0749eeebb21854c77877736969e59f2John McCallprotected:
11697bb12da2b0749eeebb21854c77877736969e59f2John McCall  OverloadExpr(StmtClass K, QualType T, bool Dependent,
11707bb12da2b0749eeebb21854c77877736969e59f2John McCall               NestedNameSpecifier *Qualifier, SourceRange QRange,
11717bb12da2b0749eeebb21854c77877736969e59f2John McCall               DeclarationName Name, SourceLocation NameLoc,
11727bb12da2b0749eeebb21854c77877736969e59f2John McCall               bool HasTemplateArgs)
11737bb12da2b0749eeebb21854c77877736969e59f2John McCall    : Expr(K, T, Dependent, Dependent),
11747bb12da2b0749eeebb21854c77877736969e59f2John McCall      Name(Name), Qualifier(Qualifier), QualifierRange(QRange),
11757bb12da2b0749eeebb21854c77877736969e59f2John McCall      NameLoc(NameLoc), HasExplicitTemplateArgs(HasTemplateArgs)
11767bb12da2b0749eeebb21854c77877736969e59f2John McCall  {}
11777bb12da2b0749eeebb21854c77877736969e59f2John McCall
11787bb12da2b0749eeebb21854c77877736969e59f2John McCallpublic:
11797bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// Computes whether an unresolved lookup on the given declarations
11807bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// and optional template arguments is type- and value-dependent.
11817bb12da2b0749eeebb21854c77877736969e59f2John McCall  static bool ComputeDependence(UnresolvedSetIterator Begin,
11827bb12da2b0749eeebb21854c77877736969e59f2John McCall                                UnresolvedSetIterator End,
11837bb12da2b0749eeebb21854c77877736969e59f2John McCall                                const TemplateArgumentListInfo *Args);
11847bb12da2b0749eeebb21854c77877736969e59f2John McCall
11857bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// Finds the overloaded expression in the given expression of
11867bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// OverloadTy.
11877bb12da2b0749eeebb21854c77877736969e59f2John McCall  ///
11887bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// \return the expression (which must be there) and true if it is
11897bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// within an address-of operator.
11907bb12da2b0749eeebb21854c77877736969e59f2John McCall  static llvm::PointerIntPair<OverloadExpr*,1> find(Expr *E) {
11917bb12da2b0749eeebb21854c77877736969e59f2John McCall    assert(E->getType()->isSpecificBuiltinType(BuiltinType::Overload));
11927bb12da2b0749eeebb21854c77877736969e59f2John McCall
11937bb12da2b0749eeebb21854c77877736969e59f2John McCall    bool op = false;
11947bb12da2b0749eeebb21854c77877736969e59f2John McCall    E = E->IgnoreParens();
11957bb12da2b0749eeebb21854c77877736969e59f2John McCall    if (isa<UnaryOperator>(E))
11967bb12da2b0749eeebb21854c77877736969e59f2John McCall      op = true, E = cast<UnaryOperator>(E)->getSubExpr()->IgnoreParens();
11977bb12da2b0749eeebb21854c77877736969e59f2John McCall    return llvm::PointerIntPair<OverloadExpr*,1>(cast<OverloadExpr>(E), op);
11987bb12da2b0749eeebb21854c77877736969e59f2John McCall  }
11997bb12da2b0749eeebb21854c77877736969e59f2John McCall
12007bb12da2b0749eeebb21854c77877736969e59f2John McCall  void addDecls(UnresolvedSetIterator Begin, UnresolvedSetIterator End) {
12017bb12da2b0749eeebb21854c77877736969e59f2John McCall    Results.append(Begin, End);
12027bb12da2b0749eeebb21854c77877736969e59f2John McCall  }
12037bb12da2b0749eeebb21854c77877736969e59f2John McCall
12047bb12da2b0749eeebb21854c77877736969e59f2John McCall  typedef UnresolvedSetImpl::iterator decls_iterator;
12057bb12da2b0749eeebb21854c77877736969e59f2John McCall  decls_iterator decls_begin() const { return Results.begin(); }
12067bb12da2b0749eeebb21854c77877736969e59f2John McCall  decls_iterator decls_end() const { return Results.end(); }
12077bb12da2b0749eeebb21854c77877736969e59f2John McCall
12087bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// Gets the decls as an unresolved set.
12097bb12da2b0749eeebb21854c77877736969e59f2John McCall  const UnresolvedSetImpl &getDecls() { return Results; }
12107bb12da2b0749eeebb21854c77877736969e59f2John McCall
12117bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// Gets the number of declarations in the unresolved set.
12127bb12da2b0749eeebb21854c77877736969e59f2John McCall  unsigned getNumDecls() const { return Results.size(); }
12137bb12da2b0749eeebb21854c77877736969e59f2John McCall
12147bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// Gets the name looked up.
12157bb12da2b0749eeebb21854c77877736969e59f2John McCall  DeclarationName getName() const { return Name; }
12167bb12da2b0749eeebb21854c77877736969e59f2John McCall  void setName(DeclarationName N) { Name = N; }
12177bb12da2b0749eeebb21854c77877736969e59f2John McCall
12187bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// Gets the location of the name.
12197bb12da2b0749eeebb21854c77877736969e59f2John McCall  SourceLocation getNameLoc() const { return NameLoc; }
12207bb12da2b0749eeebb21854c77877736969e59f2John McCall  void setNameLoc(SourceLocation Loc) { NameLoc = Loc; }
12217bb12da2b0749eeebb21854c77877736969e59f2John McCall
12227bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// Fetches the nested-name qualifier, if one was given.
12237bb12da2b0749eeebb21854c77877736969e59f2John McCall  NestedNameSpecifier *getQualifier() const { return Qualifier; }
12247bb12da2b0749eeebb21854c77877736969e59f2John McCall
12257bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// Fetches the range of the nested-name qualifier.
12267bb12da2b0749eeebb21854c77877736969e59f2John McCall  SourceRange getQualifierRange() const { return QualifierRange; }
12277bb12da2b0749eeebb21854c77877736969e59f2John McCall
12287bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// \brief Determines whether this expression had an explicit
12297bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// template argument list, e.g. f<int>.
12307bb12da2b0749eeebb21854c77877736969e59f2John McCall  bool hasExplicitTemplateArgs() const { return HasExplicitTemplateArgs; }
12317bb12da2b0749eeebb21854c77877736969e59f2John McCall
12327bb12da2b0749eeebb21854c77877736969e59f2John McCall  ExplicitTemplateArgumentList &getExplicitTemplateArgs(); // defined far below
12337bb12da2b0749eeebb21854c77877736969e59f2John McCall
12347bb12da2b0749eeebb21854c77877736969e59f2John McCall  const ExplicitTemplateArgumentList &getExplicitTemplateArgs() const {
12357bb12da2b0749eeebb21854c77877736969e59f2John McCall    return const_cast<OverloadExpr*>(this)->getExplicitTemplateArgs();
12367bb12da2b0749eeebb21854c77877736969e59f2John McCall  }
12377bb12da2b0749eeebb21854c77877736969e59f2John McCall
12387bb12da2b0749eeebb21854c77877736969e59f2John McCall  ExplicitTemplateArgumentList *getOptionalExplicitTemplateArgs() {
12397bb12da2b0749eeebb21854c77877736969e59f2John McCall    if (hasExplicitTemplateArgs())
12407bb12da2b0749eeebb21854c77877736969e59f2John McCall      return &getExplicitTemplateArgs();
12417bb12da2b0749eeebb21854c77877736969e59f2John McCall    return 0;
12427bb12da2b0749eeebb21854c77877736969e59f2John McCall  }
12437bb12da2b0749eeebb21854c77877736969e59f2John McCall
12447bb12da2b0749eeebb21854c77877736969e59f2John McCall  static bool classof(const Stmt *T) {
12457bb12da2b0749eeebb21854c77877736969e59f2John McCall    return T->getStmtClass() == UnresolvedLookupExprClass ||
12467bb12da2b0749eeebb21854c77877736969e59f2John McCall           T->getStmtClass() == UnresolvedMemberExprClass;
12477bb12da2b0749eeebb21854c77877736969e59f2John McCall  }
12487bb12da2b0749eeebb21854c77877736969e59f2John McCall  static bool classof(const OverloadExpr *) { return true; }
12497bb12da2b0749eeebb21854c77877736969e59f2John McCall};
12507bb12da2b0749eeebb21854c77877736969e59f2John McCall
12517bb12da2b0749eeebb21854c77877736969e59f2John McCall/// \brief A reference to a name which we were able to look up during
12527bb12da2b0749eeebb21854c77877736969e59f2John McCall/// parsing but could not resolve to a specific declaration.  This
12537bb12da2b0749eeebb21854c77877736969e59f2John McCall/// arises in several ways:
12547bb12da2b0749eeebb21854c77877736969e59f2John McCall///   * we might be waiting for argument-dependent lookup
12557bb12da2b0749eeebb21854c77877736969e59f2John McCall///   * the name might resolve to an overloaded function
12567bb12da2b0749eeebb21854c77877736969e59f2John McCall/// and eventually:
12577bb12da2b0749eeebb21854c77877736969e59f2John McCall///   * the lookup might have included a function template
12587bb12da2b0749eeebb21854c77877736969e59f2John McCall/// These never include UnresolvedUsingValueDecls, which are always
12597bb12da2b0749eeebb21854c77877736969e59f2John McCall/// class members and therefore appear only in
12607bb12da2b0749eeebb21854c77877736969e59f2John McCall/// UnresolvedMemberLookupExprs.
12617bb12da2b0749eeebb21854c77877736969e59f2John McCallclass UnresolvedLookupExpr : public OverloadExpr {
1262ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  /// True if these lookup results should be extended by
1263ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  /// argument-dependent lookup if this is the operand of a function
1264ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  /// call.
1265ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  bool RequiresADL;
1266ba13543329afac4a0d01304ec2ec4924d99306a6John McCall
12677453ed4cb2cab113de3378df371b1c6f1243d832John McCall  /// True if these lookup results are overloaded.  This is pretty
12687453ed4cb2cab113de3378df371b1c6f1243d832John McCall  /// trivially rederivable if we urgently need to kill this field.
12697453ed4cb2cab113de3378df371b1c6f1243d832John McCall  bool Overloaded;
12707453ed4cb2cab113de3378df371b1c6f1243d832John McCall
12717bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// The naming class (C++ [class.access.base]p5) of the lookup, if
12727bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// any.  This can generally be recalculated from the context chain,
12737bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// but that can be fairly expensive for unqualified lookups.  If we
12747bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// want to improve memory use here, this could go in a union
12757bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// against the qualified-lookup bits.
12767bb12da2b0749eeebb21854c77877736969e59f2John McCall  CXXRecordDecl *NamingClass;
1277f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall
1278c373d48502ca7683ab55385f5bd624d778eb288dJohn McCall  UnresolvedLookupExpr(QualType T, bool Dependent, CXXRecordDecl *NamingClass,
1279ba13543329afac4a0d01304ec2ec4924d99306a6John McCall                       NestedNameSpecifier *Qualifier, SourceRange QRange,
1280ba13543329afac4a0d01304ec2ec4924d99306a6John McCall                       DeclarationName Name, SourceLocation NameLoc,
1281f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall                       bool RequiresADL, bool Overloaded, bool HasTemplateArgs)
12827bb12da2b0749eeebb21854c77877736969e59f2John McCall    : OverloadExpr(UnresolvedLookupExprClass, T, Dependent, Qualifier, QRange,
12837bb12da2b0749eeebb21854c77877736969e59f2John McCall                   Name, NameLoc, HasTemplateArgs),
12847bb12da2b0749eeebb21854c77877736969e59f2John McCall      RequiresADL(RequiresADL), Overloaded(Overloaded), NamingClass(NamingClass)
1285ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  {}
1286ba13543329afac4a0d01304ec2ec4924d99306a6John McCall
1287ba13543329afac4a0d01304ec2ec4924d99306a6John McCallpublic:
1288ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  static UnresolvedLookupExpr *Create(ASTContext &C,
1289f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall                                      bool Dependent,
1290c373d48502ca7683ab55385f5bd624d778eb288dJohn McCall                                      CXXRecordDecl *NamingClass,
1291ba13543329afac4a0d01304ec2ec4924d99306a6John McCall                                      NestedNameSpecifier *Qualifier,
1292ba13543329afac4a0d01304ec2ec4924d99306a6John McCall                                      SourceRange QualifierRange,
1293ba13543329afac4a0d01304ec2ec4924d99306a6John McCall                                      DeclarationName Name,
1294ba13543329afac4a0d01304ec2ec4924d99306a6John McCall                                      SourceLocation NameLoc,
12957453ed4cb2cab113de3378df371b1c6f1243d832John McCall                                      bool ADL, bool Overloaded) {
1296f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall    return new(C) UnresolvedLookupExpr(Dependent ? C.DependentTy : C.OverloadTy,
1297c373d48502ca7683ab55385f5bd624d778eb288dJohn McCall                                       Dependent, NamingClass,
1298c373d48502ca7683ab55385f5bd624d778eb288dJohn McCall                                       Qualifier, QualifierRange,
1299f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall                                       Name, NameLoc, ADL, Overloaded, false);
1300ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  }
1301ba13543329afac4a0d01304ec2ec4924d99306a6John McCall
1302f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  static UnresolvedLookupExpr *Create(ASTContext &C,
1303f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall                                      bool Dependent,
1304c373d48502ca7683ab55385f5bd624d778eb288dJohn McCall                                      CXXRecordDecl *NamingClass,
1305f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall                                      NestedNameSpecifier *Qualifier,
1306f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall                                      SourceRange QualifierRange,
1307f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall                                      DeclarationName Name,
1308f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall                                      SourceLocation NameLoc,
1309f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall                                      bool ADL,
1310f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall                                      const TemplateArgumentListInfo &Args);
1311f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall
1312ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  /// True if this declaration should be extended by
1313ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  /// argument-dependent lookup.
1314ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  bool requiresADL() const { return RequiresADL; }
1315ba13543329afac4a0d01304ec2ec4924d99306a6John McCall
13167453ed4cb2cab113de3378df371b1c6f1243d832John McCall  /// True if this lookup is overloaded.
13177453ed4cb2cab113de3378df371b1c6f1243d832John McCall  bool isOverloaded() const { return Overloaded; }
13187453ed4cb2cab113de3378df371b1c6f1243d832John McCall
1319c373d48502ca7683ab55385f5bd624d778eb288dJohn McCall  /// Gets the 'naming class' (in the sense of C++0x
1320c373d48502ca7683ab55385f5bd624d778eb288dJohn McCall  /// [class.access.base]p5) of the lookup.  This is the scope
1321c373d48502ca7683ab55385f5bd624d778eb288dJohn McCall  /// that was looked in to find these results.
1322c373d48502ca7683ab55385f5bd624d778eb288dJohn McCall  CXXRecordDecl *getNamingClass() const { return NamingClass; }
1323c373d48502ca7683ab55385f5bd624d778eb288dJohn McCall
1324f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  // Note that, inconsistently with the explicit-template-argument AST
1325f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  // nodes, users are *forbidden* from calling these methods on objects
1326f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  // without explicit template arguments.
1327f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall
13287bb12da2b0749eeebb21854c77877736969e59f2John McCall  ExplicitTemplateArgumentList &getExplicitTemplateArgs() {
13297bb12da2b0749eeebb21854c77877736969e59f2John McCall    assert(hasExplicitTemplateArgs());
13307bb12da2b0749eeebb21854c77877736969e59f2John McCall    return *reinterpret_cast<ExplicitTemplateArgumentList*>(this + 1);
13317bb12da2b0749eeebb21854c77877736969e59f2John McCall  }
13327bb12da2b0749eeebb21854c77877736969e59f2John McCall
1333f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  /// Gets a reference to the explicit template argument list.
1334f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  const ExplicitTemplateArgumentList &getExplicitTemplateArgs() const {
1335f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall    assert(hasExplicitTemplateArgs());
1336f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall    return *reinterpret_cast<const ExplicitTemplateArgumentList*>(this + 1);
1337f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  }
1338f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall
1339f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  /// \brief Copies the template arguments (if present) into the given
1340f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  /// structure.
1341f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  void copyTemplateArgumentsInto(TemplateArgumentListInfo &List) const {
1342f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall    getExplicitTemplateArgs().copyInto(List);
1343f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  }
1344ba13543329afac4a0d01304ec2ec4924d99306a6John McCall
1345f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  SourceLocation getLAngleLoc() const {
1346f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall    return getExplicitTemplateArgs().LAngleLoc;
1347f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  }
1348f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall
1349f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  SourceLocation getRAngleLoc() const {
1350f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall    return getExplicitTemplateArgs().RAngleLoc;
1351f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  }
1352f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall
1353f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  TemplateArgumentLoc const *getTemplateArgs() const {
1354f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall    return getExplicitTemplateArgs().getTemplateArgs();
1355f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  }
1356f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall
1357f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  unsigned getNumTemplateArgs() const {
1358f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall    return getExplicitTemplateArgs().NumTemplateArgs;
1359f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  }
1360ba13543329afac4a0d01304ec2ec4924d99306a6John McCall
1361ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  virtual SourceRange getSourceRange() const {
13627bb12da2b0749eeebb21854c77877736969e59f2John McCall    SourceRange Range(getNameLoc());
13637bb12da2b0749eeebb21854c77877736969e59f2John McCall    if (getQualifier()) Range.setBegin(getQualifierRange().getBegin());
1364f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall    if (hasExplicitTemplateArgs()) Range.setEnd(getRAngleLoc());
1365f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall    return Range;
1366ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  }
1367ba13543329afac4a0d01304ec2ec4924d99306a6John McCall
1368ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  virtual StmtIterator child_begin();
1369ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  virtual StmtIterator child_end();
1370ba13543329afac4a0d01304ec2ec4924d99306a6John McCall
1371ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  static bool classof(const Stmt *T) {
1372ba13543329afac4a0d01304ec2ec4924d99306a6John McCall    return T->getStmtClass() == UnresolvedLookupExprClass;
1373ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  }
1374ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  static bool classof(const UnresolvedLookupExpr *) { return true; }
1375ba13543329afac4a0d01304ec2ec4924d99306a6John McCall};
1376ba13543329afac4a0d01304ec2ec4924d99306a6John McCall
13775953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor/// \brief A qualified reference to a name whose declaration cannot
13785953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor/// yet be resolved.
13795953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor///
1380ba13543329afac4a0d01304ec2ec4924d99306a6John McCall/// DependentScopeDeclRefExpr is similar to DeclRefExpr in that
1381a2813cec2605ce7878d1b13471d685f689b251afDouglas Gregor/// it expresses a reference to a declaration such as
13825953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor/// X<T>::value. The difference, however, is that an
1383865d447ac6a4721ab58e898d014a21f2eff74b06John McCall/// DependentScopeDeclRefExpr node is used only within C++ templates when
13845953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor/// the qualification (e.g., X<T>::) refers to a dependent type. In
13855953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor/// this case, X<T>::value cannot resolve to a declaration because the
13865953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor/// declaration will differ from on instantiation of X<T> to the
1387865d447ac6a4721ab58e898d014a21f2eff74b06John McCall/// next. Therefore, DependentScopeDeclRefExpr keeps track of the
1388ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor/// qualifier (X<T>::) and the name of the entity being referenced
1389a2813cec2605ce7878d1b13471d685f689b251afDouglas Gregor/// ("value"). Such expressions will instantiate to a DeclRefExpr once the
1390a2813cec2605ce7878d1b13471d685f689b251afDouglas Gregor/// declaration can be found.
1391865d447ac6a4721ab58e898d014a21f2eff74b06John McCallclass DependentScopeDeclRefExpr : public Expr {
13925953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor  /// The name of the entity we will be referencing.
13935953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor  DeclarationName Name;
13945953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor
13955953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor  /// Location of the name of the declaration we're referencing.
13965953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor  SourceLocation Loc;
13975953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor
13985953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor  /// QualifierRange - The source range that covers the
13995953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor  /// nested-name-specifier.
14005953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor  SourceRange QualifierRange;
14015953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor
1402ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor  /// \brief The nested-name-specifier that qualifies this unresolved
1403ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor  /// declaration name.
1404f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  NestedNameSpecifier *Qualifier;
14055953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor
1406f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  /// \brief Whether the name includes explicit template arguments.
1407f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  bool HasExplicitTemplateArgs;
14081eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1409f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  DependentScopeDeclRefExpr(QualType T,
1410f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall                            NestedNameSpecifier *Qualifier,
1411f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall                            SourceRange QualifierRange,
1412f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall                            DeclarationName Name,
1413f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall                            SourceLocation NameLoc,
1414f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall                            bool HasExplicitTemplateArgs)
1415865d447ac6a4721ab58e898d014a21f2eff74b06John McCall    : Expr(DependentScopeDeclRefExprClass, T, true, true),
1416f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall      Name(Name), Loc(NameLoc),
1417f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall      QualifierRange(QualifierRange), Qualifier(Qualifier),
1418f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall      HasExplicitTemplateArgs(HasExplicitTemplateArgs)
1419f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  {}
1420f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall
1421f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCallpublic:
1422f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  static DependentScopeDeclRefExpr *Create(ASTContext &C,
1423f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall                                           NestedNameSpecifier *Qualifier,
1424f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall                                           SourceRange QualifierRange,
1425f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall                                           DeclarationName Name,
1426f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall                                           SourceLocation NameLoc,
1427f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall                              const TemplateArgumentListInfo *TemplateArgs = 0);
14285953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor
14295953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor  /// \brief Retrieve the name that this expression refers to.
14305953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor  DeclarationName getDeclName() const { return Name; }
14315953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor
14325953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor  /// \brief Retrieve the location of the name within the expression.
14335953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor  SourceLocation getLocation() const { return Loc; }
14345953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor
14355953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor  /// \brief Retrieve the source range of the nested-name-specifier.
14365953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor  SourceRange getQualifierRange() const { return QualifierRange; }
14375953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor
1438ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor  /// \brief Retrieve the nested-name-specifier that qualifies this
1439ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor  /// declaration.
1440edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor  NestedNameSpecifier *getQualifier() const { return Qualifier; }
14411eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1442f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  /// Determines whether this lookup had explicit template arguments.
1443f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  bool hasExplicitTemplateArgs() const { return HasExplicitTemplateArgs; }
14441eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1445f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  // Note that, inconsistently with the explicit-template-argument AST
1446f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  // nodes, users are *forbidden* from calling these methods on objects
1447f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  // without explicit template arguments.
14481eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1449f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  /// Gets a reference to the explicit template argument list.
1450f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  const ExplicitTemplateArgumentList &getExplicitTemplateArgs() const {
1451f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall    assert(hasExplicitTemplateArgs());
1452f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall    return *reinterpret_cast<const ExplicitTemplateArgumentList*>(this + 1);
1453f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  }
14541eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1455f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  /// \brief Copies the template arguments (if present) into the given
1456f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  /// structure.
1457f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  void copyTemplateArgumentsInto(TemplateArgumentListInfo &List) const {
1458f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall    getExplicitTemplateArgs().copyInto(List);
1459f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  }
1460f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall
1461f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  SourceLocation getLAngleLoc() const {
1462f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall    return getExplicitTemplateArgs().LAngleLoc;
1463edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor  }
14641eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1465f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  SourceLocation getRAngleLoc() const {
1466f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall    return getExplicitTemplateArgs().RAngleLoc;
1467f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  }
14681eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1469f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  TemplateArgumentLoc const *getTemplateArgs() const {
1470f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall    return getExplicitTemplateArgs().getTemplateArgs();
1471d5532b6cfff2977e0c59fa6ead7f7973984a620dJohn McCall  }
1472d5532b6cfff2977e0c59fa6ead7f7973984a620dJohn McCall
1473f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  unsigned getNumTemplateArgs() const {
1474f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall    return getExplicitTemplateArgs().NumTemplateArgs;
1475f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  }
14761eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1477edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor  virtual SourceRange getSourceRange() const {
1478f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall    SourceRange Range(QualifierRange.getBegin(), getLocation());
1479f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall    if (hasExplicitTemplateArgs())
1480f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall      Range.setEnd(getRAngleLoc());
1481f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall    return Range;
1482edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor  }
14831eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
14841eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  static bool classof(const Stmt *T) {
1485f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall    return T->getStmtClass() == DependentScopeDeclRefExprClass;
1486edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor  }
1487f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  static bool classof(const DependentScopeDeclRefExpr *) { return true; }
1488f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall
1489f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  virtual StmtIterator child_begin();
1490f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  virtual StmtIterator child_end();
1491edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor};
14921eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
14932d44e8a41de8a33c0f04ac198714f71dc841bab0Anders Carlssonclass CXXExprWithTemporaries : public Expr {
149402bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson  Stmt *SubExpr;
14951eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1496ff6b3d64c9f07155f1414411b8451d7bf8937c62Anders Carlsson  CXXTemporary **Temps;
1497ff6b3d64c9f07155f1414411b8451d7bf8937c62Anders Carlsson  unsigned NumTemps;
149802bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson
14991eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  CXXExprWithTemporaries(Expr *SubExpr, CXXTemporary **Temps,
15000ece491d8f62ce67f047491a6703fac0d3bd4ff4Anders Carlsson                         unsigned NumTemps);
15012d44e8a41de8a33c0f04ac198714f71dc841bab0Anders Carlsson  ~CXXExprWithTemporaries();
150242602bb40aefcc2751d4078ba88aacf4d965c9bdDouglas Gregor
150342602bb40aefcc2751d4078ba88aacf4d965c9bdDouglas Gregorprotected:
150442602bb40aefcc2751d4078ba88aacf4d965c9bdDouglas Gregor  virtual void DoDestroy(ASTContext &C);
150542602bb40aefcc2751d4078ba88aacf4d965c9bdDouglas Gregor
150688eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlssonpublic:
150788eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlsson  static CXXExprWithTemporaries *Create(ASTContext &C, Expr *SubExpr,
15080ece491d8f62ce67f047491a6703fac0d3bd4ff4Anders Carlsson                                        CXXTemporary **Temps,
15090ece491d8f62ce67f047491a6703fac0d3bd4ff4Anders Carlsson                                        unsigned NumTemps);
15101eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
151188eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlsson  unsigned getNumTemporaries() const { return NumTemps; }
151288eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlsson  CXXTemporary *getTemporary(unsigned i) {
151388eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlsson    assert(i < NumTemps && "Index out of range");
151488eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlsson    return Temps[i];
151588eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlsson  }
1516f0721fe438d7e40c168e5d664970e7830bc138fbAnders Carlsson  const CXXTemporary *getTemporary(unsigned i) const {
15170ece491d8f62ce67f047491a6703fac0d3bd4ff4Anders Carlsson    return const_cast<CXXExprWithTemporaries*>(this)->getTemporary(i);
1518f0721fe438d7e40c168e5d664970e7830bc138fbAnders Carlsson  }
15191eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
152002bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson  Expr *getSubExpr() { return cast<Expr>(SubExpr); }
1521f0721fe438d7e40c168e5d664970e7830bc138fbAnders Carlsson  const Expr *getSubExpr() const { return cast<Expr>(SubExpr); }
152288eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlsson  void setSubExpr(Expr *E) { SubExpr = E; }
152302bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson
152496be6917e1c4ba1f4435a14c9e7c6c139571d086Douglas Gregor  virtual SourceRange getSourceRange() const {
152596be6917e1c4ba1f4435a14c9e7c6c139571d086Douglas Gregor    return SubExpr->getSourceRange();
152696be6917e1c4ba1f4435a14c9e7c6c139571d086Douglas Gregor  }
152702bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson
152802bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson  // Implement isa/cast/dyncast/etc.
152902bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson  static bool classof(const Stmt *T) {
15302d44e8a41de8a33c0f04ac198714f71dc841bab0Anders Carlsson    return T->getStmtClass() == CXXExprWithTemporariesClass;
153102bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson  }
15322d44e8a41de8a33c0f04ac198714f71dc841bab0Anders Carlsson  static bool classof(const CXXExprWithTemporaries *) { return true; }
153302bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson
153402bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson  // Iterators
153502bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson  virtual child_iterator child_begin();
153602bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson  virtual child_iterator child_end();
153702bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson};
153802bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson
1539d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// \brief Describes an explicit type conversion that uses functional
1540d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// notion but could not be resolved because one or more arguments are
1541d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// type-dependent.
1542d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor///
1543d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// The explicit type conversions expressed by
1544d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// CXXUnresolvedConstructExpr have the form \c T(a1, a2, ..., aN),
1545d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// where \c T is some type and \c a1, a2, ..., aN are values, and
1546d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// either \C T is a dependent type or one or more of the \c a's is
1547d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// type-dependent. For example, this would occur in a template such
1548d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// as:
1549d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor///
1550d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// \code
1551d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor///   template<typename T, typename A1>
1552d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor///   inline T make_a(const A1& a1) {
1553d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor///     return T(a1);
1554d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor///   }
1555d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// \endcode
1556d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor///
1557d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// When the returned expression is instantiated, it may resolve to a
1558d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// constructor call, conversion function call, or some kind of type
1559d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// conversion.
1560d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregorclass CXXUnresolvedConstructExpr : public Expr {
1561d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  /// \brief The starting location of the type
1562d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  SourceLocation TyBeginLoc;
1563d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor
1564d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  /// \brief The type being constructed.
1565d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  QualType Type;
1566d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor
1567d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  /// \brief The location of the left parentheses ('(').
1568d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  SourceLocation LParenLoc;
1569d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor
1570d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  /// \brief The location of the right parentheses (')').
1571d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  SourceLocation RParenLoc;
1572d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor
1573d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  /// \brief The number of arguments used to construct the type.
1574d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  unsigned NumArgs;
15751eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1576d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  CXXUnresolvedConstructExpr(SourceLocation TyBegin,
1577d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor                             QualType T,
1578d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor                             SourceLocation LParenLoc,
1579d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor                             Expr **Args,
1580d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor                             unsigned NumArgs,
1581d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor                             SourceLocation RParenLoc);
1582d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor
1583d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregorpublic:
15841eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  static CXXUnresolvedConstructExpr *Create(ASTContext &C,
1585d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor                                            SourceLocation TyBegin,
1586d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor                                            QualType T,
1587d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor                                            SourceLocation LParenLoc,
1588d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor                                            Expr **Args,
1589d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor                                            unsigned NumArgs,
1590d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor                                            SourceLocation RParenLoc);
1591d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor
1592d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  /// \brief Retrieve the source location where the type begins.
1593d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  SourceLocation getTypeBeginLoc() const { return TyBeginLoc; }
1594d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  void setTypeBeginLoc(SourceLocation L) { TyBeginLoc = L; }
1595d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor
1596d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  /// \brief Retrieve the type that is being constructed, as specified
1597d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  /// in the source code.
1598d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  QualType getTypeAsWritten() const { return Type; }
1599d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  void setTypeAsWritten(QualType T) { Type = T; }
1600d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor
1601d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  /// \brief Retrieve the location of the left parentheses ('(') that
1602d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  /// precedes the argument list.
1603d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  SourceLocation getLParenLoc() const { return LParenLoc; }
1604d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  void setLParenLoc(SourceLocation L) { LParenLoc = L; }
1605d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor
1606d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  /// \brief Retrieve the location of the right parentheses (')') that
1607d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  /// follows the argument list.
1608d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  SourceLocation getRParenLoc() const { return RParenLoc; }
1609d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  void setRParenLoc(SourceLocation L) { RParenLoc = L; }
1610d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor
1611d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  /// \brief Retrieve the number of arguments.
1612d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  unsigned arg_size() const { return NumArgs; }
1613d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor
1614d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  typedef Expr** arg_iterator;
1615d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  arg_iterator arg_begin() { return reinterpret_cast<Expr**>(this + 1); }
1616d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  arg_iterator arg_end() { return arg_begin() + NumArgs; }
1617d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor
16181dd7383dc48718c452e71a625b29531dd96fbb9dJohn McCall  typedef const Expr* const * const_arg_iterator;
16191dd7383dc48718c452e71a625b29531dd96fbb9dJohn McCall  const_arg_iterator arg_begin() const {
16201dd7383dc48718c452e71a625b29531dd96fbb9dJohn McCall    return reinterpret_cast<const Expr* const *>(this + 1);
16211dd7383dc48718c452e71a625b29531dd96fbb9dJohn McCall  }
16221dd7383dc48718c452e71a625b29531dd96fbb9dJohn McCall  const_arg_iterator arg_end() const {
16231dd7383dc48718c452e71a625b29531dd96fbb9dJohn McCall    return arg_begin() + NumArgs;
16241dd7383dc48718c452e71a625b29531dd96fbb9dJohn McCall  }
16251dd7383dc48718c452e71a625b29531dd96fbb9dJohn McCall
1626d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  Expr *getArg(unsigned I) {
1627d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor    assert(I < NumArgs && "Argument index out-of-range");
1628d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor    return *(arg_begin() + I);
1629d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  }
1630d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor
16311dd7383dc48718c452e71a625b29531dd96fbb9dJohn McCall  const Expr *getArg(unsigned I) const {
16321dd7383dc48718c452e71a625b29531dd96fbb9dJohn McCall    assert(I < NumArgs && "Argument index out-of-range");
16331dd7383dc48718c452e71a625b29531dd96fbb9dJohn McCall    return *(arg_begin() + I);
16341dd7383dc48718c452e71a625b29531dd96fbb9dJohn McCall  }
16351dd7383dc48718c452e71a625b29531dd96fbb9dJohn McCall
1636d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  virtual SourceRange getSourceRange() const {
1637d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor    return SourceRange(TyBeginLoc, RParenLoc);
1638d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  }
16391eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  static bool classof(const Stmt *T) {
1640d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor    return T->getStmtClass() == CXXUnresolvedConstructExprClass;
1641d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  }
1642d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  static bool classof(const CXXUnresolvedConstructExpr *) { return true; }
1643d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor
1644d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  // Iterators
1645d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  virtual child_iterator child_begin();
1646d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  virtual child_iterator child_end();
1647d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor};
1648d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor
1649ba13543329afac4a0d01304ec2ec4924d99306a6John McCall/// \brief Represents a C++ member access expression where the actual
1650ba13543329afac4a0d01304ec2ec4924d99306a6John McCall/// member referenced could not be resolved because the base
1651ba13543329afac4a0d01304ec2ec4924d99306a6John McCall/// expression or the member name was dependent.
1652aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall///
1653aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall/// Like UnresolvedMemberExprs, these can be either implicit or
1654aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall/// explicit accesses.  It is only possible to get one of these with
1655aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall/// an implicit access if a qualifier is provided.
1656865d447ac6a4721ab58e898d014a21f2eff74b06John McCallclass CXXDependentScopeMemberExpr : public Expr {
16571c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  /// \brief The expression for the base pointer or class reference,
1658aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall  /// e.g., the \c x in x.f.  Can be null in implicit accesses.
16591c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  Stmt *Base;
16601eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1661aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall  /// \brief The type of the base expression.  Never null, even for
1662aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall  /// implicit accesses.
1663aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall  QualType BaseType;
1664aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall
16651c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  /// \brief Whether this member expression used the '->' operator or
16661c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  /// the '.' operator.
16673b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor  bool IsArrow : 1;
16681c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor
16693b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor  /// \brief Whether this member expression has explicitly-specified template
16703b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor  /// arguments.
1671aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall  bool HasExplicitTemplateArgs : 1;
16721eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
16731c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  /// \brief The location of the '->' or '.' operator.
16741c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  SourceLocation OperatorLoc;
16751c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor
1676a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor  /// \brief The nested-name-specifier that precedes the member name, if any.
1677a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor  NestedNameSpecifier *Qualifier;
16781eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1679a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor  /// \brief The source range covering the nested name specifier.
1680a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor  SourceRange QualifierRange;
16811eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1682c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor  /// \brief In a qualified member access expression such as t->Base::f, this
16831eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  /// member stores the resolves of name lookup in the context of the member
1684c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor  /// access expression, to be used at instantiation time.
1685c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor  ///
1686c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor  /// FIXME: This member, along with the Qualifier and QualifierRange, could
1687c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor  /// be stuck into a structure that is optionally allocated at the end of
1688865d447ac6a4721ab58e898d014a21f2eff74b06John McCall  /// the CXXDependentScopeMemberExpr, to save space in the common case.
1689c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor  NamedDecl *FirstQualifierFoundInScope;
16901eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
16911c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  /// \brief The member to which this member expression refers, which
16921c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  /// can be name, overloaded operator, or destructor.
1693a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor  /// FIXME: could also be a template-id
16941c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  DeclarationName Member;
16951c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor
16961c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  /// \brief The location of the member name.
16971c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  SourceLocation MemberLoc;
16981eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
16993b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor  /// \brief Retrieve the explicit template argument list that followed the
17003b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor  /// member template name, if any.
17013b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor  ExplicitTemplateArgumentList *getExplicitTemplateArgumentList() {
1702aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall    assert(HasExplicitTemplateArgs);
17033b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor    return reinterpret_cast<ExplicitTemplateArgumentList *>(this + 1);
17043b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor  }
17051eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
17063b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor  /// \brief Retrieve the explicit template argument list that followed the
17073b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor  /// member template name, if any.
17083b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor  const ExplicitTemplateArgumentList *getExplicitTemplateArgumentList() const {
1709865d447ac6a4721ab58e898d014a21f2eff74b06John McCall    return const_cast<CXXDependentScopeMemberExpr *>(this)
17103b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor             ->getExplicitTemplateArgumentList();
17113b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor  }
17121eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1713865d447ac6a4721ab58e898d014a21f2eff74b06John McCall  CXXDependentScopeMemberExpr(ASTContext &C,
1714aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall                          Expr *Base, QualType BaseType, bool IsArrow,
17153b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor                          SourceLocation OperatorLoc,
17163b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor                          NestedNameSpecifier *Qualifier,
17173b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor                          SourceRange QualifierRange,
17183b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor                          NamedDecl *FirstQualifierFoundInScope,
17193b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor                          DeclarationName Member,
17203b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor                          SourceLocation MemberLoc,
1721d5532b6cfff2977e0c59fa6ead7f7973984a620dJohn McCall                          const TemplateArgumentListInfo *TemplateArgs);
17221eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
17231c0ca59416999129d0439c2661d137ef38e86209Douglas Gregorpublic:
1724865d447ac6a4721ab58e898d014a21f2eff74b06John McCall  CXXDependentScopeMemberExpr(ASTContext &C,
1725aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall                          Expr *Base, QualType BaseType,
1726aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall                          bool IsArrow,
17271c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor                          SourceLocation OperatorLoc,
1728a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor                          NestedNameSpecifier *Qualifier,
1729a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor                          SourceRange QualifierRange,
1730c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor                          NamedDecl *FirstQualifierFoundInScope,
17311c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor                          DeclarationName Member,
17321c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor                          SourceLocation MemberLoc)
1733865d447ac6a4721ab58e898d014a21f2eff74b06John McCall  : Expr(CXXDependentScopeMemberExprClass, C.DependentTy, true, true),
1734aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall    Base(Base), BaseType(BaseType), IsArrow(IsArrow),
1735aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall    HasExplicitTemplateArgs(false), OperatorLoc(OperatorLoc),
17363b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor    Qualifier(Qualifier), QualifierRange(QualifierRange),
17373b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor    FirstQualifierFoundInScope(FirstQualifierFoundInScope),
17383b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor    Member(Member), MemberLoc(MemberLoc) { }
17391eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1740865d447ac6a4721ab58e898d014a21f2eff74b06John McCall  static CXXDependentScopeMemberExpr *
17411eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  Create(ASTContext &C,
1742aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall         Expr *Base, QualType BaseType, bool IsArrow,
17433b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor         SourceLocation OperatorLoc,
17443b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor         NestedNameSpecifier *Qualifier,
17453b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor         SourceRange QualifierRange,
17463b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor         NamedDecl *FirstQualifierFoundInScope,
17473b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor         DeclarationName Member,
17483b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor         SourceLocation MemberLoc,
1749d5532b6cfff2977e0c59fa6ead7f7973984a620dJohn McCall         const TemplateArgumentListInfo *TemplateArgs);
17501eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1751aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall  /// \brief True if this is an implicit access, i.e. one in which the
1752aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall  /// member being accessed was not written in the source.  The source
1753aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall  /// location of the operator is invalid in this case.
1754aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall  bool isImplicitAccess() const { return Base == 0; }
1755aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall
17561c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  /// \brief Retrieve the base object of this member expressions,
17571c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  /// e.g., the \c x in \c x.m.
1758aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall  Expr *getBase() const {
1759aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall    assert(!isImplicitAccess());
1760aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall    return cast<Expr>(Base);
1761aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall  }
17621c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  void setBase(Expr *E) { Base = E; }
17631c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor
1764aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall  QualType getBaseType() const { return BaseType; }
1765aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall
17661c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  /// \brief Determine whether this member expression used the '->'
17671c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  /// operator; otherwise, it used the '.' operator.
17681c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  bool isArrow() const { return IsArrow; }
17691c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  void setArrow(bool A) { IsArrow = A; }
17701c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor
17711c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  /// \brief Retrieve the location of the '->' or '.' operator.
17721c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  SourceLocation getOperatorLoc() const { return OperatorLoc; }
17731c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  void setOperatorLoc(SourceLocation L) { OperatorLoc = L; }
17741c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor
1775a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor  /// \brief Retrieve the nested-name-specifier that qualifies the member
1776a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor  /// name.
1777a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor  NestedNameSpecifier *getQualifier() const { return Qualifier; }
17781eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1779a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor  /// \brief Retrieve the source range covering the nested-name-specifier
1780a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor  /// that qualifies the member name.
1781a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor  SourceRange getQualifierRange() const { return QualifierRange; }
17821eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1783c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor  /// \brief Retrieve the first part of the nested-name-specifier that was
1784c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor  /// found in the scope of the member access expression when the member access
1785c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor  /// was initially parsed.
1786c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor  ///
1787c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor  /// This function only returns a useful result when member access expression
17881eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  /// uses a qualified member name, e.g., "x.Base::f". Here, the declaration
17891eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  /// returned by this function describes what was found by unqualified name
1790c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor  /// lookup for the identifier "Base" within the scope of the member access
1791c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor  /// expression itself. At template instantiation time, this information is
1792c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor  /// combined with the results of name lookup into the type of the object
1793c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor  /// expression itself (the class type of x).
17941eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  NamedDecl *getFirstQualifierFoundInScope() const {
1795c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor    return FirstQualifierFoundInScope;
1796c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor  }
17971eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
17981c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  /// \brief Retrieve the name of the member that this expression
17991c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  /// refers to.
18001c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  DeclarationName getMember() const { return Member; }
18011c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  void setMember(DeclarationName N) { Member = N; }
18021c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor
18031c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  // \brief Retrieve the location of the name of the member that this
18041c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  // expression refers to.
18051c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  SourceLocation getMemberLoc() const { return MemberLoc; }
18061c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  void setMemberLoc(SourceLocation L) { MemberLoc = L; }
18071c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor
18083b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor  /// \brief Determines whether this member expression actually had a C++
18093b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor  /// template argument list explicitly specified, e.g., x.f<int>.
1810aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall  bool hasExplicitTemplateArgs() const {
1811aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall    return HasExplicitTemplateArgs;
18123b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor  }
18131eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1814d5532b6cfff2977e0c59fa6ead7f7973984a620dJohn McCall  /// \brief Copies the template arguments (if present) into the given
1815d5532b6cfff2977e0c59fa6ead7f7973984a620dJohn McCall  /// structure.
1816d5532b6cfff2977e0c59fa6ead7f7973984a620dJohn McCall  void copyTemplateArgumentsInto(TemplateArgumentListInfo &List) const {
1817aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall    assert(HasExplicitTemplateArgs);
1818aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall    getExplicitTemplateArgumentList()->copyInto(List);
1819d5532b6cfff2977e0c59fa6ead7f7973984a620dJohn McCall  }
1820d5532b6cfff2977e0c59fa6ead7f7973984a620dJohn McCall
18211eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  /// \brief Retrieve the location of the left angle bracket following the
18223b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor  /// member name ('<'), if any.
18231eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  SourceLocation getLAngleLoc() const {
1824aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall    assert(HasExplicitTemplateArgs);
18253b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor    return getExplicitTemplateArgumentList()->LAngleLoc;
18263b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor  }
18271eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
18283b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor  /// \brief Retrieve the template arguments provided as part of this
18293b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor  /// template-id.
1830833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall  const TemplateArgumentLoc *getTemplateArgs() const {
1831aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall    assert(HasExplicitTemplateArgs);
18323b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor    return getExplicitTemplateArgumentList()->getTemplateArgs();
18333b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor  }
18341eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
18353b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor  /// \brief Retrieve the number of template arguments provided as part of this
18363b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor  /// template-id.
18371eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  unsigned getNumTemplateArgs() const {
1838aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall    assert(HasExplicitTemplateArgs);
18393b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor    return getExplicitTemplateArgumentList()->NumTemplateArgs;
18403b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor  }
18411eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
18421eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  /// \brief Retrieve the location of the right angle bracket following the
18433b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor  /// template arguments ('>').
18441eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  SourceLocation getRAngleLoc() const {
1845aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall    assert(HasExplicitTemplateArgs);
18463b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor    return getExplicitTemplateArgumentList()->RAngleLoc;
18473b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor  }
18481eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
18491c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  virtual SourceRange getSourceRange() const {
1850aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall    SourceRange Range;
1851aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall    if (!isImplicitAccess())
1852aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall      Range.setBegin(Base->getSourceRange().getBegin());
1853aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall    else if (getQualifier())
1854aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall      Range.setBegin(getQualifierRange().getBegin());
1855aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall    else
1856aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall      Range.setBegin(MemberLoc);
18571eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1858aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall    if (hasExplicitTemplateArgs())
1859aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall      Range.setEnd(getRAngleLoc());
1860aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall    else
1861aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall      Range.setEnd(MemberLoc);
1862aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall    return Range;
18631c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  }
18641eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
18651eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  static bool classof(const Stmt *T) {
1866865d447ac6a4721ab58e898d014a21f2eff74b06John McCall    return T->getStmtClass() == CXXDependentScopeMemberExprClass;
18671c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  }
1868865d447ac6a4721ab58e898d014a21f2eff74b06John McCall  static bool classof(const CXXDependentScopeMemberExpr *) { return true; }
18691c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor
18701c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  // Iterators
18711c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  virtual child_iterator child_begin();
18721c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  virtual child_iterator child_end();
18731c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor};
18741c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor
1875129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall/// \brief Represents a C++ member access expression for which lookup
1876aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall/// produced a set of overloaded functions.
1877aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall///
1878aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall/// The member access may be explicit or implicit:
1879aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall///    struct A {
1880aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall///      int a, b;
1881aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall///      int explicitAccess() { return this->a + this->A::b; }
1882aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall///      int implicitAccess() { return a + A::b; }
1883aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall///    };
1884aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall///
1885aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall/// In the final AST, an explicit access always becomes a MemberExpr.
1886aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall/// An implicit access may become either a MemberExpr or a
1887aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall/// DeclRefExpr, depending on whether the member is static.
18887bb12da2b0749eeebb21854c77877736969e59f2John McCallclass UnresolvedMemberExpr : public OverloadExpr {
1889129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// \brief Whether this member expression used the '->' operator or
1890129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// the '.' operator.
1891129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  bool IsArrow : 1;
1892129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall
1893129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// \brief Whether the lookup results contain an unresolved using
1894129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// declaration.
1895129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  bool HasUnresolvedUsing : 1;
1896129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall
18977bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// \brief The expression for the base pointer or class reference,
18987bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// e.g., the \c x in x.f.  This can be null if this is an 'unbased'
18997bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// member expression
19007bb12da2b0749eeebb21854c77877736969e59f2John McCall  Stmt *Base;
19017bb12da2b0749eeebb21854c77877736969e59f2John McCall
19027bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// \brief The type of the base expression;  never null.
19037bb12da2b0749eeebb21854c77877736969e59f2John McCall  QualType BaseType;
1904129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall
1905129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// \brief The location of the '->' or '.' operator.
1906129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  SourceLocation OperatorLoc;
1907129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall
1908129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  UnresolvedMemberExpr(QualType T, bool Dependent,
1909129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall                       bool HasUnresolvedUsing,
1910aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall                       Expr *Base, QualType BaseType, bool IsArrow,
1911129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall                       SourceLocation OperatorLoc,
1912129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall                       NestedNameSpecifier *Qualifier,
1913129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall                       SourceRange QualifierRange,
1914129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall                       DeclarationName Member,
1915129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall                       SourceLocation MemberLoc,
1916129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall                       const TemplateArgumentListInfo *TemplateArgs);
1917129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall
1918129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCallpublic:
1919129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  static UnresolvedMemberExpr *
1920129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  Create(ASTContext &C, bool Dependent, bool HasUnresolvedUsing,
1921aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall         Expr *Base, QualType BaseType, bool IsArrow,
1922129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall         SourceLocation OperatorLoc,
1923129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall         NestedNameSpecifier *Qualifier,
1924129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall         SourceRange QualifierRange,
1925129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall         DeclarationName Member,
1926129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall         SourceLocation MemberLoc,
1927129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall         const TemplateArgumentListInfo *TemplateArgs);
1928129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall
1929aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall  /// \brief True if this is an implicit access, i.e. one in which the
1930aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall  /// member being accessed was not written in the source.  The source
1931aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall  /// location of the operator is invalid in this case.
1932aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall  bool isImplicitAccess() const { return Base == 0; }
1933aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall
1934129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// \brief Retrieve the base object of this member expressions,
1935129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// e.g., the \c x in \c x.m.
1936aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall  Expr *getBase() {
1937aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall    assert(!isImplicitAccess());
1938aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall    return cast<Expr>(Base);
1939aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall  }
19402f27bf854f0519810b34afd209089cc75536b757John McCall  const Expr *getBase() const {
19412f27bf854f0519810b34afd209089cc75536b757John McCall    assert(!isImplicitAccess());
19422f27bf854f0519810b34afd209089cc75536b757John McCall    return cast<Expr>(Base);
19432f27bf854f0519810b34afd209089cc75536b757John McCall  }
1944129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  void setBase(Expr *E) { Base = E; }
1945129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall
1946aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall  QualType getBaseType() const { return BaseType; }
1947aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall
1948129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// \brief Determine whether this member expression used the '->'
1949129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// operator; otherwise, it used the '.' operator.
1950129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  bool isArrow() const { return IsArrow; }
1951129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  void setArrow(bool A) { IsArrow = A; }
1952129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall
1953129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// \brief Retrieve the location of the '->' or '.' operator.
1954129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  SourceLocation getOperatorLoc() const { return OperatorLoc; }
1955129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  void setOperatorLoc(SourceLocation L) { OperatorLoc = L; }
1956129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall
1957c373d48502ca7683ab55385f5bd624d778eb288dJohn McCall  /// \brief Retrieves the naming class of this lookup.
1958c373d48502ca7683ab55385f5bd624d778eb288dJohn McCall  CXXRecordDecl *getNamingClass() const;
1959c373d48502ca7683ab55385f5bd624d778eb288dJohn McCall
1960129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// \brief Retrieve the name of the member that this expression
1961129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// refers to.
19627bb12da2b0749eeebb21854c77877736969e59f2John McCall  DeclarationName getMemberName() const { return getName(); }
19637bb12da2b0749eeebb21854c77877736969e59f2John McCall  void setMemberName(DeclarationName N) { setName(N); }
1964129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall
1965129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  // \brief Retrieve the location of the name of the member that this
1966129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  // expression refers to.
19677bb12da2b0749eeebb21854c77877736969e59f2John McCall  SourceLocation getMemberLoc() const { return getNameLoc(); }
19687bb12da2b0749eeebb21854c77877736969e59f2John McCall  void setMemberLoc(SourceLocation L) { setNameLoc(L); }
1969129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall
19707bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// \brief Retrieve the explicit template argument list that followed the
19717bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// member template name.
19727bb12da2b0749eeebb21854c77877736969e59f2John McCall  ExplicitTemplateArgumentList &getExplicitTemplateArgs() {
19737bb12da2b0749eeebb21854c77877736969e59f2John McCall    assert(hasExplicitTemplateArgs());
19747bb12da2b0749eeebb21854c77877736969e59f2John McCall    return *reinterpret_cast<ExplicitTemplateArgumentList *>(this + 1);
19757bb12da2b0749eeebb21854c77877736969e59f2John McCall  }
19767bb12da2b0749eeebb21854c77877736969e59f2John McCall
19777bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// \brief Retrieve the explicit template argument list that followed the
19787bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// member template name, if any.
19797bb12da2b0749eeebb21854c77877736969e59f2John McCall  const ExplicitTemplateArgumentList &getExplicitTemplateArgs() const {
19807bb12da2b0749eeebb21854c77877736969e59f2John McCall    assert(hasExplicitTemplateArgs());
19817bb12da2b0749eeebb21854c77877736969e59f2John McCall    return *reinterpret_cast<const ExplicitTemplateArgumentList *>(this + 1);
1982129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  }
1983129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall
1984129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// \brief Copies the template arguments into the given structure.
1985129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  void copyTemplateArgumentsInto(TemplateArgumentListInfo &List) const {
19867bb12da2b0749eeebb21854c77877736969e59f2John McCall    getExplicitTemplateArgs().copyInto(List);
1987129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  }
1988129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall
1989129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// \brief Retrieve the location of the left angle bracket following
1990129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// the member name ('<').
1991129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  SourceLocation getLAngleLoc() const {
19927bb12da2b0749eeebb21854c77877736969e59f2John McCall    return getExplicitTemplateArgs().LAngleLoc;
1993129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  }
1994129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall
1995129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// \brief Retrieve the template arguments provided as part of this
1996129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// template-id.
1997129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  const TemplateArgumentLoc *getTemplateArgs() const {
19987bb12da2b0749eeebb21854c77877736969e59f2John McCall    return getExplicitTemplateArgs().getTemplateArgs();
1999129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  }
2000129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall
2001129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// \brief Retrieve the number of template arguments provided as
2002129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// part of this template-id.
2003129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  unsigned getNumTemplateArgs() const {
20047bb12da2b0749eeebb21854c77877736969e59f2John McCall    return getExplicitTemplateArgs().NumTemplateArgs;
2005129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  }
2006129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall
2007129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// \brief Retrieve the location of the right angle bracket
2008129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// following the template arguments ('>').
2009129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  SourceLocation getRAngleLoc() const {
20107bb12da2b0749eeebb21854c77877736969e59f2John McCall    return getExplicitTemplateArgs().RAngleLoc;
2011129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  }
2012129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall
2013129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  virtual SourceRange getSourceRange() const {
2014aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall    SourceRange Range;
2015aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall    if (!isImplicitAccess())
2016aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall      Range.setBegin(Base->getSourceRange().getBegin());
2017aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall    else if (getQualifier())
2018aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall      Range.setBegin(getQualifierRange().getBegin());
2019aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall    else
20207bb12da2b0749eeebb21854c77877736969e59f2John McCall      Range.setBegin(getMemberLoc());
2021aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall
2022129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall    if (hasExplicitTemplateArgs())
2023129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall      Range.setEnd(getRAngleLoc());
2024129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall    else
20257bb12da2b0749eeebb21854c77877736969e59f2John McCall      Range.setEnd(getMemberLoc());
2026129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall    return Range;
2027129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  }
2028129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall
2029129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  static bool classof(const Stmt *T) {
2030129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall    return T->getStmtClass() == UnresolvedMemberExprClass;
2031129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  }
2032129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  static bool classof(const UnresolvedMemberExpr *) { return true; }
2033129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall
2034129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  // Iterators
2035129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  virtual child_iterator child_begin();
2036129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  virtual child_iterator child_end();
2037129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall};
2038129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall
20397bb12da2b0749eeebb21854c77877736969e59f2John McCallinline ExplicitTemplateArgumentList &OverloadExpr::getExplicitTemplateArgs() {
20407bb12da2b0749eeebb21854c77877736969e59f2John McCall  if (isa<UnresolvedLookupExpr>(this))
20417bb12da2b0749eeebb21854c77877736969e59f2John McCall    return cast<UnresolvedLookupExpr>(this)->getExplicitTemplateArgs();
20427bb12da2b0749eeebb21854c77877736969e59f2John McCall  else
20437bb12da2b0749eeebb21854c77877736969e59f2John McCall    return cast<UnresolvedMemberExpr>(this)->getExplicitTemplateArgs();
20447bb12da2b0749eeebb21854c77877736969e59f2John McCall}
20457bb12da2b0749eeebb21854c77877736969e59f2John McCall
20465f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer}  // end namespace clang
20475f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer
20485f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer#endif
2049