ExprCXX.h revision 2e156225a29407a50dd19041aa5750171ad44ea3
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:
911817bd483b538fd3f4530649f5cb900bad9e8a76Chris Lattner  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
951817bd483b538fd3f4530649f5cb900bad9e8a76Chris Lattner  CXXMemberCallExpr(ASTContext &C, EmptyShell Empty)
961817bd483b538fd3f4530649f5cb900bad9e8a76Chris Lattner    : CallExpr(C, CXXMemberCallExprClass, Empty) { }
971817bd483b538fd3f4530649f5cb900bad9e8a76Chris Lattner
9888a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor  /// getImplicitObjectArgument - Retrieves the implicit object
9988a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor  /// argument for the member call. For example, in "x.f(5)", this
10088a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor  /// operation would return "x".
10188a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor  Expr *getImplicitObjectArgument();
10288a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor
10300b98c229ef28a5e82943bb23d09fb46d24ca381Douglas Gregor  virtual SourceRange getSourceRange() const;
10400b98c229ef28a5e82943bb23d09fb46d24ca381Douglas Gregor
1051eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  static bool classof(const Stmt *T) {
10688a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor    return T->getStmtClass() == CXXMemberCallExprClass;
10788a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor  }
10888a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor  static bool classof(const CXXMemberCallExpr *) { return true; }
10988a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor};
11088a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor
11149badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// CXXNamedCastExpr - Abstract class common to all of the C++ "named"
11249badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// casts, @c static_cast, @c dynamic_cast, @c reinterpret_cast, or @c
11349badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// const_cast.
11449badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor///
11549badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// This abstract class is inherited by all of the classes
11649badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// representing "named" casts, e.g., CXXStaticCastExpr,
11749badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// CXXDynamicCastExpr, CXXReinterpretCastExpr, and CXXConstCastExpr.
11849badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregorclass CXXNamedCastExpr : public ExplicitCastExpr {
1191060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenekprivate:
1201060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  SourceLocation Loc; // the location of the casting op
12149badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor
12249badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregorprotected:
123c0a2fd8f092722c8f78b566ac4506a21437040e9Anders Carlsson  CXXNamedCastExpr(StmtClass SC, QualType ty, CastKind kind, Expr *op,
124f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall                   unsigned PathSize, TypeSourceInfo *writtenTy,
12541b2dcd465f1e438502c420effc9d0c747f9db8fAnders Carlsson                   SourceLocation l)
126f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall    : ExplicitCastExpr(SC, ty, kind, op, PathSize, writtenTy), Loc(l) {}
12749badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor
128f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall  explicit CXXNamedCastExpr(StmtClass SC, EmptyShell Shell, unsigned PathSize)
129f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall    : ExplicitCastExpr(SC, Shell, PathSize) { }
130ce757a7a1ee905f87551996a69da3e95e8afeeb7Sam Weinig
1311060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenekpublic:
13249badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor  const char *getCastName() const;
13349badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor
134a3a7b8eea87c90a5a257f685749222b212ddaf36Douglas Gregor  /// \brief Retrieve the location of the cast operator keyword, e.g.,
135a3a7b8eea87c90a5a257f685749222b212ddaf36Douglas Gregor  /// "static_cast".
136a3a7b8eea87c90a5a257f685749222b212ddaf36Douglas Gregor  SourceLocation getOperatorLoc() const { return Loc; }
137a3a7b8eea87c90a5a257f685749222b212ddaf36Douglas Gregor  void setOperatorLoc(SourceLocation L) { Loc = L; }
138a3a7b8eea87c90a5a257f685749222b212ddaf36Douglas Gregor
1391060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  virtual SourceRange getSourceRange() const {
1401060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek    return SourceRange(Loc, getSubExpr()->getSourceRange().getEnd());
1411060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  }
1421eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  static bool classof(const Stmt *T) {
14349badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor    switch (T->getStmtClass()) {
14449badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor    case CXXStaticCastExprClass:
14549badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor    case CXXDynamicCastExprClass:
14649badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor    case CXXReinterpretCastExprClass:
14749badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor    case CXXConstCastExprClass:
14849badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor      return true;
14949badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor    default:
15049badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor      return false;
15149badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor    }
1521060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  }
15349badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor  static bool classof(const CXXNamedCastExpr *) { return true; }
15449badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor};
15549badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor
15649badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// CXXStaticCastExpr - A C++ @c static_cast expression (C++ [expr.static.cast]).
1571eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump///
15849badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// This expression node represents a C++ static cast, e.g.,
15949badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// @c static_cast<int>(1.0).
16049badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregorclass CXXStaticCastExpr : public CXXNamedCastExpr {
16141b2dcd465f1e438502c420effc9d0c747f9db8fAnders Carlsson  CXXStaticCastExpr(QualType ty, CastKind kind, Expr *op,
162f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall                    unsigned pathSize, TypeSourceInfo *writtenTy,
16341b2dcd465f1e438502c420effc9d0c747f9db8fAnders Carlsson                    SourceLocation l)
164f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall    : CXXNamedCastExpr(CXXStaticCastExprClass, ty, kind, op, pathSize,
165f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall                       writtenTy, l) {}
16649badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor
167f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall  explicit CXXStaticCastExpr(EmptyShell Empty, unsigned PathSize)
168f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall    : CXXNamedCastExpr(CXXStaticCastExprClass, Empty, PathSize) { }
169f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall
170f871d0cc377a1367b519a6cce26be74607566ebaJohn McCallpublic:
171f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall  static CXXStaticCastExpr *Create(ASTContext &Context, QualType T,
172f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall                                   CastKind K, Expr *Op,
173f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall                                   const CXXCastPath *Path,
174f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall                                   TypeSourceInfo *Written, SourceLocation L);
175f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall  static CXXStaticCastExpr *CreateEmpty(ASTContext &Context,
176f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall                                        unsigned PathSize);
177ce757a7a1ee905f87551996a69da3e95e8afeeb7Sam Weinig
1781eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  static bool classof(const Stmt *T) {
17949badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor    return T->getStmtClass() == CXXStaticCastExprClass;
18049badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor  }
18149badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor  static bool classof(const CXXStaticCastExpr *) { return true; }
18249badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor};
18349badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor
18449badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// CXXDynamicCastExpr - A C++ @c dynamic_cast expression
1851eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump/// (C++ [expr.dynamic.cast]), which may perform a run-time check to
18649badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// determine how to perform the type cast.
1871eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump///
18849badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// This expression node represents a dynamic cast, e.g.,
18949badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// @c dynamic_cast<Derived*>(BasePtr).
19049badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregorclass CXXDynamicCastExpr : public CXXNamedCastExpr {
19141b2dcd465f1e438502c420effc9d0c747f9db8fAnders Carlsson  CXXDynamicCastExpr(QualType ty, CastKind kind, Expr *op,
192f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall                     unsigned pathSize, TypeSourceInfo *writtenTy,
19341b2dcd465f1e438502c420effc9d0c747f9db8fAnders Carlsson                     SourceLocation l)
194f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall    : CXXNamedCastExpr(CXXDynamicCastExprClass, ty, kind, op, pathSize,
19541b2dcd465f1e438502c420effc9d0c747f9db8fAnders Carlsson                       writtenTy, l) {}
19649badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor
197f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall  explicit CXXDynamicCastExpr(EmptyShell Empty, unsigned pathSize)
198f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall    : CXXNamedCastExpr(CXXDynamicCastExprClass, Empty, pathSize) { }
199f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall
200f871d0cc377a1367b519a6cce26be74607566ebaJohn McCallpublic:
201f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall  static CXXDynamicCastExpr *Create(ASTContext &Context, QualType T,
202f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall                                    CastKind Kind, Expr *Op,
203f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall                                    const CXXCastPath *Path,
204f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall                                    TypeSourceInfo *Written, SourceLocation L);
205f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall
206f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall  static CXXDynamicCastExpr *CreateEmpty(ASTContext &Context,
207f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall                                         unsigned pathSize);
208ce757a7a1ee905f87551996a69da3e95e8afeeb7Sam Weinig
2091eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  static bool classof(const Stmt *T) {
21049badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor    return T->getStmtClass() == CXXDynamicCastExprClass;
21149badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor  }
21249badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor  static bool classof(const CXXDynamicCastExpr *) { return true; }
21349badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor};
21449badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor
21549badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// CXXReinterpretCastExpr - A C++ @c reinterpret_cast expression (C++
21649badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// [expr.reinterpret.cast]), which provides a differently-typed view
21749badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// of a value but performs no actual work at run time.
2181eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump///
21949badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// This expression node represents a reinterpret cast, e.g.,
22049badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// @c reinterpret_cast<int>(VoidPtr).
22149badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregorclass CXXReinterpretCastExpr : public CXXNamedCastExpr {
2227f9e646b7ed47bc8e9a60031ad0c2b55031e2077Anders Carlsson  CXXReinterpretCastExpr(QualType ty, CastKind kind, Expr *op,
223f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall                         unsigned pathSize,
2249d125033a9853f3b572a4c9e2f9e2d4e5e346973John McCall                         TypeSourceInfo *writtenTy, SourceLocation l)
225f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall    : CXXNamedCastExpr(CXXReinterpretCastExprClass, ty, kind, op, pathSize,
226cdef2b75aa60cde1ca00e0aa3f89139ac89c6ae4Anders Carlsson                       writtenTy, l) {}
22749badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor
228f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall  CXXReinterpretCastExpr(EmptyShell Empty, unsigned pathSize)
229f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall    : CXXNamedCastExpr(CXXReinterpretCastExprClass, Empty, pathSize) { }
230f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall
231f871d0cc377a1367b519a6cce26be74607566ebaJohn McCallpublic:
232f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall  static CXXReinterpretCastExpr *Create(ASTContext &Context, QualType T,
233f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall                                        CastKind Kind, Expr *Op,
234f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall                                        const CXXCastPath *Path,
235f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall                                 TypeSourceInfo *WrittenTy, SourceLocation L);
236f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall  static CXXReinterpretCastExpr *CreateEmpty(ASTContext &Context,
237f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall                                             unsigned pathSize);
238ce757a7a1ee905f87551996a69da3e95e8afeeb7Sam Weinig
2391eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  static bool classof(const Stmt *T) {
24049badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor    return T->getStmtClass() == CXXReinterpretCastExprClass;
24149badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor  }
24249badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor  static bool classof(const CXXReinterpretCastExpr *) { return true; }
24349badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor};
24449badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor
24549badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// CXXConstCastExpr - A C++ @c const_cast expression (C++ [expr.const.cast]),
24649badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// which can remove type qualifiers but does not change the underlying value.
2471eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump///
24849badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// This expression node represents a const cast, e.g.,
24949badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// @c const_cast<char*>(PtrToConstChar).
25049badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregorclass CXXConstCastExpr : public CXXNamedCastExpr {
2519d125033a9853f3b572a4c9e2f9e2d4e5e346973John McCall  CXXConstCastExpr(QualType ty, Expr *op, TypeSourceInfo *writtenTy,
25249badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor                   SourceLocation l)
25341b2dcd465f1e438502c420effc9d0c747f9db8fAnders Carlsson    : CXXNamedCastExpr(CXXConstCastExprClass, ty, CK_NoOp, op,
254f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall                       0, writtenTy, l) {}
25549badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor
256ce757a7a1ee905f87551996a69da3e95e8afeeb7Sam Weinig  explicit CXXConstCastExpr(EmptyShell Empty)
257f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall    : CXXNamedCastExpr(CXXConstCastExprClass, Empty, 0) { }
258f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall
259f871d0cc377a1367b519a6cce26be74607566ebaJohn McCallpublic:
260f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall  static CXXConstCastExpr *Create(ASTContext &Context, QualType T, Expr *Op,
261f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall                                  TypeSourceInfo *WrittenTy, SourceLocation L);
262f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall  static CXXConstCastExpr *CreateEmpty(ASTContext &Context);
263ce757a7a1ee905f87551996a69da3e95e8afeeb7Sam Weinig
2641eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  static bool classof(const Stmt *T) {
26549badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor    return T->getStmtClass() == CXXConstCastExprClass;
26649badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor  }
26749badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor  static bool classof(const CXXConstCastExpr *) { return true; }
2681060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek};
2691060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek
2701060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek/// CXXBoolLiteralExpr - [C++ 2.13.5] C++ Boolean Literal.
2711eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump///
2721060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenekclass CXXBoolLiteralExpr : public Expr {
2731060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  bool Value;
2741060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  SourceLocation Loc;
2751060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenekpublic:
2761eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  CXXBoolLiteralExpr(bool val, QualType Ty, SourceLocation l) :
2772333f7727f97018d6742e1e0938133bcfad967abEli Friedman    Expr(CXXBoolLiteralExprClass, Ty, false, false), Value(val), Loc(l) {}
2788b0b475b3464b0f70b91ba7d679d23c424677d5eSebastian Redl
279eb7f96141f754150a92433286fa385910a22f494Sam Weinig  explicit CXXBoolLiteralExpr(EmptyShell Empty)
280eb7f96141f754150a92433286fa385910a22f494Sam Weinig    : Expr(CXXBoolLiteralExprClass, Empty) { }
281eb7f96141f754150a92433286fa385910a22f494Sam Weinig
2821060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  bool getValue() const { return Value; }
283eb7f96141f754150a92433286fa385910a22f494Sam Weinig  void setValue(bool V) { Value = V; }
2845f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer
2851060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  virtual SourceRange getSourceRange() const { return SourceRange(Loc); }
2861eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
287eb7f96141f754150a92433286fa385910a22f494Sam Weinig  SourceLocation getLocation() const { return Loc; }
288eb7f96141f754150a92433286fa385910a22f494Sam Weinig  void setLocation(SourceLocation L) { Loc = L; }
289eb7f96141f754150a92433286fa385910a22f494Sam Weinig
2901eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  static bool classof(const Stmt *T) {
2911060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek    return T->getStmtClass() == CXXBoolLiteralExprClass;
2921060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  }
2931060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  static bool classof(const CXXBoolLiteralExpr *) { return true; }
2941eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
2951060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  // Iterators
2961060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  virtual child_iterator child_begin();
2971060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  virtual child_iterator child_end();
2981060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek};
2991060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek
3006e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl/// CXXNullPtrLiteralExpr - [C++0x 2.14.7] C++ Pointer Literal
3016e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redlclass CXXNullPtrLiteralExpr : public Expr {
3026e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl  SourceLocation Loc;
3036e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redlpublic:
3046e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl  CXXNullPtrLiteralExpr(QualType Ty, SourceLocation l) :
3052333f7727f97018d6742e1e0938133bcfad967abEli Friedman    Expr(CXXNullPtrLiteralExprClass, Ty, false, false), Loc(l) {}
3066e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl
307eb7f96141f754150a92433286fa385910a22f494Sam Weinig  explicit CXXNullPtrLiteralExpr(EmptyShell Empty)
308eb7f96141f754150a92433286fa385910a22f494Sam Weinig    : Expr(CXXNullPtrLiteralExprClass, Empty) { }
309eb7f96141f754150a92433286fa385910a22f494Sam Weinig
3106e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl  virtual SourceRange getSourceRange() const { return SourceRange(Loc); }
3116e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl
312eb7f96141f754150a92433286fa385910a22f494Sam Weinig  SourceLocation getLocation() const { return Loc; }
313eb7f96141f754150a92433286fa385910a22f494Sam Weinig  void setLocation(SourceLocation L) { Loc = L; }
314eb7f96141f754150a92433286fa385910a22f494Sam Weinig
3156e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl  static bool classof(const Stmt *T) {
3166e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl    return T->getStmtClass() == CXXNullPtrLiteralExprClass;
3176e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl  }
3186e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl  static bool classof(const CXXNullPtrLiteralExpr *) { return true; }
3196e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl
3206e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl  virtual child_iterator child_begin();
3216e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl  virtual child_iterator child_end();
3226e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl};
3236e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl
324c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl/// CXXTypeidExpr - A C++ @c typeid expression (C++ [expr.typeid]), which gets
325c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl/// the type_info that corresponds to the supplied type, or the (possibly
326c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl/// dynamic) type of the supplied expression.
327c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl///
328c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl/// This represents code like @c typeid(int) or @c typeid(*objPtr)
329c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redlclass CXXTypeidExpr : public Expr {
330c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redlprivate:
33157fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor  llvm::PointerUnion<Stmt *, TypeSourceInfo *> Operand;
332c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl  SourceRange Range;
333c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl
334c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redlpublic:
33557fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor  CXXTypeidExpr(QualType Ty, TypeSourceInfo *Operand, SourceRange R)
33657fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor    : Expr(CXXTypeidExprClass, Ty,
33757fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor           // typeid is never type-dependent (C++ [temp.dep.expr]p4)
33857fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor           false,
33957fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor           // typeid is value-dependent if the type or expression are dependent
34057fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor           Operand->getType()->isDependentType()),
34157fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor      Operand(Operand), Range(R) { }
34257fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor
34357fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor  CXXTypeidExpr(QualType Ty, Expr *Operand, SourceRange R)
34457fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor    : Expr(CXXTypeidExprClass, Ty,
3452850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl        // typeid is never type-dependent (C++ [temp.dep.expr]p4)
3462850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl        false,
3472850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl        // typeid is value-dependent if the type or expression are dependent
34857fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor        Operand->isTypeDependent() || Operand->isValueDependent()),
34957fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor      Operand(Operand), Range(R) { }
350c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl
35114ab24f01e36d495fce183aa67b41e45cdd54f39Chris Lattner  CXXTypeidExpr(EmptyShell Empty, bool isExpr)
35214ab24f01e36d495fce183aa67b41e45cdd54f39Chris Lattner    : Expr(CXXTypeidExprClass, Empty) {
35314ab24f01e36d495fce183aa67b41e45cdd54f39Chris Lattner    if (isExpr)
35414ab24f01e36d495fce183aa67b41e45cdd54f39Chris Lattner      Operand = (Expr*)0;
35514ab24f01e36d495fce183aa67b41e45cdd54f39Chris Lattner    else
35614ab24f01e36d495fce183aa67b41e45cdd54f39Chris Lattner      Operand = (TypeSourceInfo*)0;
35714ab24f01e36d495fce183aa67b41e45cdd54f39Chris Lattner  }
35814ab24f01e36d495fce183aa67b41e45cdd54f39Chris Lattner
35957fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor  bool isTypeOperand() const { return Operand.is<TypeSourceInfo *>(); }
36057fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor
36157fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor  /// \brief Retrieves the type operand of this typeid() expression after
36257fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor  /// various required adjustments (removing reference types, cv-qualifiers).
36357fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor  QualType getTypeOperand() const;
36457fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor
36557fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor  /// \brief Retrieve source information for the type operand.
36657fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor  TypeSourceInfo *getTypeOperandSourceInfo() const {
367c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl    assert(isTypeOperand() && "Cannot call getTypeOperand for typeid(expr)");
36857fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor    return Operand.get<TypeSourceInfo *>();
369c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl  }
37014ab24f01e36d495fce183aa67b41e45cdd54f39Chris Lattner
37114ab24f01e36d495fce183aa67b41e45cdd54f39Chris Lattner  void setTypeOperandSourceInfo(TypeSourceInfo *TSI) {
37214ab24f01e36d495fce183aa67b41e45cdd54f39Chris Lattner    assert(isTypeOperand() && "Cannot call getTypeOperand for typeid(expr)");
37314ab24f01e36d495fce183aa67b41e45cdd54f39Chris Lattner    Operand = TSI;
37414ab24f01e36d495fce183aa67b41e45cdd54f39Chris Lattner  }
37557fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor
37614ab24f01e36d495fce183aa67b41e45cdd54f39Chris Lattner  Expr *getExprOperand() const {
377c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl    assert(!isTypeOperand() && "Cannot call getExprOperand for typeid(type)");
37857fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor    return static_cast<Expr*>(Operand.get<Stmt *>());
379c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl  }
38014ab24f01e36d495fce183aa67b41e45cdd54f39Chris Lattner
381030854b95f7bfd86aaa8afd9ae1aff9768a37e9aChris Lattner  void setExprOperand(Expr *E) {
382030854b95f7bfd86aaa8afd9ae1aff9768a37e9aChris Lattner    assert(!isTypeOperand() && "Cannot call getExprOperand for typeid(type)");
383030854b95f7bfd86aaa8afd9ae1aff9768a37e9aChris Lattner    Operand = E;
384030854b95f7bfd86aaa8afd9ae1aff9768a37e9aChris Lattner  }
385030854b95f7bfd86aaa8afd9ae1aff9768a37e9aChris Lattner
38614ab24f01e36d495fce183aa67b41e45cdd54f39Chris Lattner  virtual SourceRange getSourceRange() const { return Range; }
38714ab24f01e36d495fce183aa67b41e45cdd54f39Chris Lattner  void setSourceRange(SourceRange R) { Range = R; }
38814ab24f01e36d495fce183aa67b41e45cdd54f39Chris Lattner
389c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl  static bool classof(const Stmt *T) {
390c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl    return T->getStmtClass() == CXXTypeidExprClass;
391c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl  }
392c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl  static bool classof(const CXXTypeidExpr *) { return true; }
393c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl
394c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl  // Iterators
395c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl  virtual child_iterator child_begin();
396c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl  virtual child_iterator child_end();
397c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl};
398c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl
39901b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet/// CXXUuidofExpr - A microsoft C++ @c __uuidof expression, which gets
40001b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet/// the _GUID that corresponds to the supplied type or expression.
40101b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet///
40201b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet/// This represents code like @c __uuidof(COMTYPE) or @c __uuidof(*comPtr)
40301b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichetclass CXXUuidofExpr : public Expr {
40401b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichetprivate:
40501b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet  llvm::PointerUnion<Stmt *, TypeSourceInfo *> Operand;
40601b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet  SourceRange Range;
40701b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet
40801b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichetpublic:
40901b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet  CXXUuidofExpr(QualType Ty, TypeSourceInfo *Operand, SourceRange R)
41001b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet    : Expr(CXXUuidofExprClass, Ty,
41101b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet        false, Operand->getType()->isDependentType()),
41201b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet      Operand(Operand), Range(R) { }
41301b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet
41401b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet  CXXUuidofExpr(QualType Ty, Expr *Operand, SourceRange R)
41501b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet    : Expr(CXXUuidofExprClass, Ty,
41601b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet        false, Operand->isTypeDependent()),
41701b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet      Operand(Operand), Range(R) { }
41801b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet
41901b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet  CXXUuidofExpr(EmptyShell Empty, bool isExpr)
42001b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet    : Expr(CXXUuidofExprClass, Empty) {
42101b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet    if (isExpr)
42201b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet      Operand = (Expr*)0;
42301b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet    else
42401b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet      Operand = (TypeSourceInfo*)0;
42501b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet  }
42601b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet
42701b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet  bool isTypeOperand() const { return Operand.is<TypeSourceInfo *>(); }
42801b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet
42901b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet  /// \brief Retrieves the type operand of this __uuidof() expression after
43001b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet  /// various required adjustments (removing reference types, cv-qualifiers).
43101b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet  QualType getTypeOperand() const;
43201b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet
43301b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet  /// \brief Retrieve source information for the type operand.
43401b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet  TypeSourceInfo *getTypeOperandSourceInfo() const {
43501b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet    assert(isTypeOperand() && "Cannot call getTypeOperand for __uuidof(expr)");
43601b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet    return Operand.get<TypeSourceInfo *>();
43701b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet  }
43801b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet
43901b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet  void setTypeOperandSourceInfo(TypeSourceInfo *TSI) {
44001b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet    assert(isTypeOperand() && "Cannot call getTypeOperand for __uuidof(expr)");
44101b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet    Operand = TSI;
44201b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet  }
44301b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet
44401b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet  Expr *getExprOperand() const {
44501b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet    assert(!isTypeOperand() && "Cannot call getExprOperand for __uuidof(type)");
44601b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet    return static_cast<Expr*>(Operand.get<Stmt *>());
44701b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet  }
44801b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet
44901b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet  void setExprOperand(Expr *E) {
45001b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet    assert(!isTypeOperand() && "Cannot call getExprOperand for __uuidof(type)");
45101b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet    Operand = E;
45201b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet  }
45301b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet
45401b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet  virtual SourceRange getSourceRange() const { return Range; }
45501b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet  void setSourceRange(SourceRange R) { Range = R; }
45601b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet
45701b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet  static bool classof(const Stmt *T) {
45801b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet    return T->getStmtClass() == CXXUuidofExprClass;
45901b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet  }
46001b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet  static bool classof(const CXXUuidofExpr *) { return true; }
46101b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet
46201b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet  // Iterators
46301b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet  virtual child_iterator child_begin();
46401b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet  virtual child_iterator child_end();
46501b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet};
46601b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet
467796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// CXXThisExpr - Represents the "this" expression in C++, which is a
468796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// pointer to the object on which the current member function is
469796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// executing (C++ [expr.prim]p3). Example:
470796da18402f286b897782a298ae3b20c459c102eDouglas Gregor///
471796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// @code
472796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// class Foo {
473796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// public:
474796da18402f286b897782a298ae3b20c459c102eDouglas Gregor///   void bar();
475796da18402f286b897782a298ae3b20c459c102eDouglas Gregor///   void test() { this->bar(); }
476796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// };
477796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// @endcode
478796da18402f286b897782a298ae3b20c459c102eDouglas Gregorclass CXXThisExpr : public Expr {
479796da18402f286b897782a298ae3b20c459c102eDouglas Gregor  SourceLocation Loc;
480828a197317288e3333b0ce6f5cedadd036e3531fDouglas Gregor  bool Implicit : 1;
481828a197317288e3333b0ce6f5cedadd036e3531fDouglas Gregor
482796da18402f286b897782a298ae3b20c459c102eDouglas Gregorpublic:
483828a197317288e3333b0ce6f5cedadd036e3531fDouglas Gregor  CXXThisExpr(SourceLocation L, QualType Type, bool isImplicit)
4842850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl    : Expr(CXXThisExprClass, Type,
4852850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl           // 'this' is type-dependent if the class type of the enclosing
4862850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl           // member function is dependent (C++ [temp.dep.expr]p2)
4872850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl           Type->isDependentType(), Type->isDependentType()),
488828a197317288e3333b0ce6f5cedadd036e3531fDouglas Gregor      Loc(L), Implicit(isImplicit) { }
489796da18402f286b897782a298ae3b20c459c102eDouglas Gregor
4902fbdfcdf3bbf7b941853d38b123930755e837437Chris Lattner  CXXThisExpr(EmptyShell Empty) : Expr(CXXThisExprClass, Empty) {}
4912fbdfcdf3bbf7b941853d38b123930755e837437Chris Lattner
4922fbdfcdf3bbf7b941853d38b123930755e837437Chris Lattner  SourceLocation getLocation() const { return Loc; }
4932fbdfcdf3bbf7b941853d38b123930755e837437Chris Lattner  void setLocation(SourceLocation L) { Loc = L; }
4942fbdfcdf3bbf7b941853d38b123930755e837437Chris Lattner
495796da18402f286b897782a298ae3b20c459c102eDouglas Gregor  virtual SourceRange getSourceRange() const { return SourceRange(Loc); }
496796da18402f286b897782a298ae3b20c459c102eDouglas Gregor
497828a197317288e3333b0ce6f5cedadd036e3531fDouglas Gregor  bool isImplicit() const { return Implicit; }
498828a197317288e3333b0ce6f5cedadd036e3531fDouglas Gregor  void setImplicit(bool I) { Implicit = I; }
499828a197317288e3333b0ce6f5cedadd036e3531fDouglas Gregor
5001eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  static bool classof(const Stmt *T) {
501796da18402f286b897782a298ae3b20c459c102eDouglas Gregor    return T->getStmtClass() == CXXThisExprClass;
502796da18402f286b897782a298ae3b20c459c102eDouglas Gregor  }
503796da18402f286b897782a298ae3b20c459c102eDouglas Gregor  static bool classof(const CXXThisExpr *) { return true; }
504796da18402f286b897782a298ae3b20c459c102eDouglas Gregor
505796da18402f286b897782a298ae3b20c459c102eDouglas Gregor  // Iterators
506796da18402f286b897782a298ae3b20c459c102eDouglas Gregor  virtual child_iterator child_begin();
507796da18402f286b897782a298ae3b20c459c102eDouglas Gregor  virtual child_iterator child_end();
508796da18402f286b897782a298ae3b20c459c102eDouglas Gregor};
509796da18402f286b897782a298ae3b20c459c102eDouglas Gregor
5101060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek///  CXXThrowExpr - [C++ 15] C++ Throw Expression.  This handles
5111060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek///  'throw' and 'throw' assignment-expression.  When
5121060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek///  assignment-expression isn't present, Op will be null.
5131060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek///
5141060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenekclass CXXThrowExpr : public Expr {
5151060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  Stmt *Op;
5161060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  SourceLocation ThrowLoc;
5171060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenekpublic:
5181060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  // Ty is the void type which is used as the result type of the
5191060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  // exepression.  The l is the location of the throw keyword.  expr
5201060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  // can by null, if the optional expression to throw isn't present.
5211060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  CXXThrowExpr(Expr *expr, QualType Ty, SourceLocation l) :
5222850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl    Expr(CXXThrowExprClass, Ty, false, false), Op(expr), ThrowLoc(l) {}
5232fbdfcdf3bbf7b941853d38b123930755e837437Chris Lattner  CXXThrowExpr(EmptyShell Empty) : Expr(CXXThrowExprClass, Empty) {}
5242fbdfcdf3bbf7b941853d38b123930755e837437Chris Lattner
5251060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  const Expr *getSubExpr() const { return cast_or_null<Expr>(Op); }
5261060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  Expr *getSubExpr() { return cast_or_null<Expr>(Op); }
52742e5b50f4dc897f252e0d476063a7f9846d96624Douglas Gregor  void setSubExpr(Expr *E) { Op = E; }
52842e5b50f4dc897f252e0d476063a7f9846d96624Douglas Gregor
52942e5b50f4dc897f252e0d476063a7f9846d96624Douglas Gregor  SourceLocation getThrowLoc() const { return ThrowLoc; }
53042e5b50f4dc897f252e0d476063a7f9846d96624Douglas Gregor  void setThrowLoc(SourceLocation L) { ThrowLoc = L; }
5311060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek
5321060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  virtual SourceRange getSourceRange() const {
5331060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek    if (getSubExpr() == 0)
5341060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek      return SourceRange(ThrowLoc, ThrowLoc);
5351060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek    return SourceRange(ThrowLoc, getSubExpr()->getSourceRange().getEnd());
5361060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  }
5371060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek
5381060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  static bool classof(const Stmt *T) {
5391060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek    return T->getStmtClass() == CXXThrowExprClass;
5401060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  }
5411060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  static bool classof(const CXXThrowExpr *) { return true; }
5421060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek
5431060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  // Iterators
5441060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  virtual child_iterator child_begin();
5451060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  virtual child_iterator child_end();
5461060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek};
5471060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek
5481060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek/// CXXDefaultArgExpr - C++ [dcl.fct.default]. This wraps up a
5491060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek/// function call argument that was created from the corresponding
5501060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek/// parameter's default argument, when the call did not explicitly
5511060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek/// supply arguments for all of the parameters.
5521060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenekclass CXXDefaultArgExpr : public Expr {
55365222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor  /// \brief The parameter whose default is being used.
55465222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor  ///
55565222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor  /// When the bit is set, the subexpression is stored after the
55665222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor  /// CXXDefaultArgExpr itself. When the bit is clear, the parameter's
55765222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor  /// actual default expression is the subexpression.
55865222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor  llvm::PointerIntPair<ParmVarDecl *, 1, bool> Param;
5591eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
560036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor  /// \brief The location where the default argument expression was used.
561036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor  SourceLocation Loc;
562036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor
563036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor  CXXDefaultArgExpr(StmtClass SC, SourceLocation Loc, ParmVarDecl *param)
56465222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor    : Expr(SC,
56565222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor           param->hasUnparsedDefaultArg()
56665222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor             ? param->getType().getNonReferenceType()
5672333f7727f97018d6742e1e0938133bcfad967abEli Friedman             : param->getDefaultArg()->getType(),
5682333f7727f97018d6742e1e0938133bcfad967abEli Friedman           false, false),
569036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor      Param(param, false), Loc(Loc) { }
57065222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor
571036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor  CXXDefaultArgExpr(StmtClass SC, SourceLocation Loc, ParmVarDecl *param,
572036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor                    Expr *SubExpr)
573030854b95f7bfd86aaa8afd9ae1aff9768a37e9aChris Lattner    : Expr(SC, SubExpr->getType(), false, false), Param(param, true), Loc(Loc) {
57465222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor    *reinterpret_cast<Expr **>(this + 1) = SubExpr;
57565222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor  }
57665222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor
5771060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenekpublic:
578030854b95f7bfd86aaa8afd9ae1aff9768a37e9aChris Lattner  CXXDefaultArgExpr(EmptyShell Empty) : Expr(CXXDefaultArgExprClass, Empty) {}
579030854b95f7bfd86aaa8afd9ae1aff9768a37e9aChris Lattner
580030854b95f7bfd86aaa8afd9ae1aff9768a37e9aChris Lattner
5811060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  // Param is the parameter whose default argument is used by this
5821060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  // expression.
583036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor  static CXXDefaultArgExpr *Create(ASTContext &C, SourceLocation Loc,
584036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor                                   ParmVarDecl *Param) {
585036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor    return new (C) CXXDefaultArgExpr(CXXDefaultArgExprClass, Loc, Param);
586f1480eee38b59d15438fb7bc50865ac7c7e22403Anders Carlsson  }
5871060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek
58865222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor  // Param is the parameter whose default argument is used by this
58965222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor  // expression, and SubExpr is the expression that will actually be used.
590036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor  static CXXDefaultArgExpr *Create(ASTContext &C,
591036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor                                   SourceLocation Loc,
592036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor                                   ParmVarDecl *Param,
59365222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor                                   Expr *SubExpr);
59465222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor
5951060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  // Retrieve the parameter that the argument was created from.
59665222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor  const ParmVarDecl *getParam() const { return Param.getPointer(); }
59765222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor  ParmVarDecl *getParam() { return Param.getPointer(); }
598030854b95f7bfd86aaa8afd9ae1aff9768a37e9aChris Lattner
5991060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  // Retrieve the actual argument to the function call.
60065222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor  const Expr *getExpr() const {
60165222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor    if (Param.getInt())
60265222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor      return *reinterpret_cast<Expr const * const*> (this + 1);
60365222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor    return getParam()->getDefaultArg();
60465222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor  }
60565222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor  Expr *getExpr() {
60665222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor    if (Param.getInt())
60765222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor      return *reinterpret_cast<Expr **> (this + 1);
60865222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor    return getParam()->getDefaultArg();
60965222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor  }
6101060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek
611036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor  /// \brief Retrieve the location where this default argument was actually
612036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor  /// used.
613036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor  SourceLocation getUsedLocation() const { return Loc; }
614036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor
6151060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  virtual SourceRange getSourceRange() const {
6161060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek    // Default argument expressions have no representation in the
6171060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek    // source, so they have an empty source range.
6181060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek    return SourceRange();
6191060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  }
6201060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek
6211060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  static bool classof(const Stmt *T) {
6221060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek    return T->getStmtClass() == CXXDefaultArgExprClass;
6231060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  }
6241060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  static bool classof(const CXXDefaultArgExpr *) { return true; }
6251060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek
6261060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  // Iterators
6271060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  virtual child_iterator child_begin();
6281060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  virtual child_iterator child_end();
6298a50733034edd6a349b34e2b9f0c8d0a874846d3Argyrios Kyrtzidis
63060adf4acf40b72227740bf966fb87eebddff3f37Sebastian Redl  friend class ASTStmtReader;
6313397c5570369f19b2d6c52e898f708d75ceede1fSebastian Redl  friend class ASTStmtWriter;
6321060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek};
633987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis
634c1ce477119fed070299668aab24084b17ff5f14bAnders Carlsson/// CXXTemporary - Represents a C++ temporary.
635c1ce477119fed070299668aab24084b17ff5f14bAnders Carlssonclass CXXTemporary {
636c1ce477119fed070299668aab24084b17ff5f14bAnders Carlsson  /// Destructor - The destructor that needs to be called.
637b859f35459ae3e1188d1e1b86df08d649695fd86Anders Carlsson  const CXXDestructorDecl *Destructor;
6381eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
639b859f35459ae3e1188d1e1b86df08d649695fd86Anders Carlsson  CXXTemporary(const CXXDestructorDecl *destructor)
640c1ce477119fed070299668aab24084b17ff5f14bAnders Carlsson    : Destructor(destructor) { }
641c1ce477119fed070299668aab24084b17ff5f14bAnders Carlsson
642c1ce477119fed070299668aab24084b17ff5f14bAnders Carlssonpublic:
6431eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  static CXXTemporary *Create(ASTContext &C,
644b859f35459ae3e1188d1e1b86df08d649695fd86Anders Carlsson                              const CXXDestructorDecl *Destructor);
6451eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
646f0721fe438d7e40c168e5d664970e7830bc138fbAnders Carlsson  const CXXDestructorDecl *getDestructor() const { return Destructor; }
647c1ce477119fed070299668aab24084b17ff5f14bAnders Carlsson};
648fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson
649ddfe960d252a93525692b547945236d361d1929fChandler Carruth/// \brief Represents binding an expression to a temporary.
650ddfe960d252a93525692b547945236d361d1929fChandler Carruth///
651ddfe960d252a93525692b547945236d361d1929fChandler Carruth/// This ensures the destructor is called for the temporary. It should only be
652ddfe960d252a93525692b547945236d361d1929fChandler Carruth/// needed for non-POD, non-trivially destructable class types. For example:
653ddfe960d252a93525692b547945236d361d1929fChandler Carruth///
654ddfe960d252a93525692b547945236d361d1929fChandler Carruth/// \code
655ddfe960d252a93525692b547945236d361d1929fChandler Carruth///   struct S {
656ddfe960d252a93525692b547945236d361d1929fChandler Carruth///     S() { }  // User defined constructor makes S non-POD.
657ddfe960d252a93525692b547945236d361d1929fChandler Carruth///     ~S() { } // User defined destructor makes it non-trivial.
658ddfe960d252a93525692b547945236d361d1929fChandler Carruth///   };
659ddfe960d252a93525692b547945236d361d1929fChandler Carruth///   void test() {
660ddfe960d252a93525692b547945236d361d1929fChandler Carruth///     const S &s_ref = S(); // Requires a CXXBindTemporaryExpr.
661ddfe960d252a93525692b547945236d361d1929fChandler Carruth///   }
662ddfe960d252a93525692b547945236d361d1929fChandler Carruth/// \endcode
663fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlssonclass CXXBindTemporaryExpr : public Expr {
664fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson  CXXTemporary *Temp;
6651eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
666fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson  Stmt *SubExpr;
667fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson
6681eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  CXXBindTemporaryExpr(CXXTemporary *temp, Expr* subexpr)
6692333f7727f97018d6742e1e0938133bcfad967abEli Friedman   : Expr(CXXBindTemporaryExprClass, subexpr->getType(), false, false),
6702333f7727f97018d6742e1e0938133bcfad967abEli Friedman     Temp(temp), SubExpr(subexpr) { }
67188eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlsson
672fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlssonpublic:
673d2598368876cfe40bc8465540033bc5b5e58d8afChris Lattner  CXXBindTemporaryExpr(EmptyShell Empty)
674d2598368876cfe40bc8465540033bc5b5e58d8afChris Lattner    : Expr(CXXBindTemporaryExprClass, Empty), Temp(0), SubExpr(0) {}
675d2598368876cfe40bc8465540033bc5b5e58d8afChris Lattner
6761eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  static CXXBindTemporaryExpr *Create(ASTContext &C, CXXTemporary *Temp,
677fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson                                      Expr* SubExpr);
6781eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
67988eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlsson  CXXTemporary *getTemporary() { return Temp; }
680f0721fe438d7e40c168e5d664970e7830bc138fbAnders Carlsson  const CXXTemporary *getTemporary() const { return Temp; }
681d2598368876cfe40bc8465540033bc5b5e58d8afChris Lattner  void setTemporary(CXXTemporary *T) { Temp = T; }
682f0721fe438d7e40c168e5d664970e7830bc138fbAnders Carlsson
683fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson  const Expr *getSubExpr() const { return cast<Expr>(SubExpr); }
684fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson  Expr *getSubExpr() { return cast<Expr>(SubExpr); }
68588eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlsson  void setSubExpr(Expr *E) { SubExpr = E; }
686fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson
68796be6917e1c4ba1f4435a14c9e7c6c139571d086Douglas Gregor  virtual SourceRange getSourceRange() const {
68896be6917e1c4ba1f4435a14c9e7c6c139571d086Douglas Gregor    return SubExpr->getSourceRange();
68996be6917e1c4ba1f4435a14c9e7c6c139571d086Douglas Gregor  }
690fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson
691fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson  // Implement isa/cast/dyncast/etc.
692fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson  static bool classof(const Stmt *T) {
693fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson    return T->getStmtClass() == CXXBindTemporaryExprClass;
694fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson  }
695fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson  static bool classof(const CXXBindTemporaryExpr *) { return true; }
696fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson
697fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson  // Iterators
698fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson  virtual child_iterator child_begin();
699fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson  virtual child_iterator child_end();
700fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson};
701fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson
70215ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson/// CXXConstructExpr - Represents a call to a C++ constructor.
70315ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlssonclass CXXConstructExpr : public Expr {
70472e96fd181b19b8d01144a685cda6e955584c7eaAnders Carlssonpublic:
70572e96fd181b19b8d01144a685cda6e955584c7eaAnders Carlsson  enum ConstructionKind {
70672e96fd181b19b8d01144a685cda6e955584c7eaAnders Carlsson    CK_Complete,
70772e96fd181b19b8d01144a685cda6e955584c7eaAnders Carlsson    CK_NonVirtualBase,
70872e96fd181b19b8d01144a685cda6e955584c7eaAnders Carlsson    CK_VirtualBase
70972e96fd181b19b8d01144a685cda6e955584c7eaAnders Carlsson  };
71072e96fd181b19b8d01144a685cda6e955584c7eaAnders Carlsson
71172e96fd181b19b8d01144a685cda6e955584c7eaAnders Carlssonprivate:
71215ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson  CXXConstructorDecl *Constructor;
71315ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson
71499a2e600f9e2e51d3ce10fb6f27191677ac65b2aDouglas Gregor  SourceLocation Loc;
71516006c901315fa12a108b4e571f187f4b676e426Douglas Gregor  bool Elidable : 1;
71616006c901315fa12a108b4e571f187f4b676e426Douglas Gregor  bool ZeroInitialization : 1;
71772e96fd181b19b8d01144a685cda6e955584c7eaAnders Carlsson  unsigned ConstructKind : 2;
71815ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson  Stmt **Args;
71915ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson  unsigned NumArgs;
7201eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
721bd6734e5f6432ce0cc07171c490ffaa094796198Anders Carlssonprotected:
7221eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  CXXConstructExpr(ASTContext &C, StmtClass SC, QualType T,
72399a2e600f9e2e51d3ce10fb6f27191677ac65b2aDouglas Gregor                   SourceLocation Loc,
724bd6734e5f6432ce0cc07171c490ffaa094796198Anders Carlsson                   CXXConstructorDecl *d, bool elidable,
72516006c901315fa12a108b4e571f187f4b676e426Douglas Gregor                   Expr **args, unsigned numargs,
7269db7dbb918ca49f4ee6c181e4917e7b6ec547353Douglas Gregor                   bool ZeroInitialization = false,
72772e96fd181b19b8d01144a685cda6e955584c7eaAnders Carlsson                   ConstructionKind ConstructKind = CK_Complete);
728bd6734e5f6432ce0cc07171c490ffaa094796198Anders Carlsson
7296d00c1365dd3601f6d93bbda9162913c57ae788fArgyrios Kyrtzidis  /// \brief Construct an empty C++ construction expression.
7306d00c1365dd3601f6d93bbda9162913c57ae788fArgyrios Kyrtzidis  CXXConstructExpr(StmtClass SC, EmptyShell Empty)
7316d00c1365dd3601f6d93bbda9162913c57ae788fArgyrios Kyrtzidis    : Expr(SC, Empty), Constructor(0), Elidable(0), ZeroInitialization(0),
7326d00c1365dd3601f6d93bbda9162913c57ae788fArgyrios Kyrtzidis      ConstructKind(0), Args(0), NumArgs(0) { }
7336d00c1365dd3601f6d93bbda9162913c57ae788fArgyrios Kyrtzidis
73415ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlssonpublic:
7356d00c1365dd3601f6d93bbda9162913c57ae788fArgyrios Kyrtzidis  /// \brief Construct an empty C++ construction expression.
7366d00c1365dd3601f6d93bbda9162913c57ae788fArgyrios Kyrtzidis  explicit CXXConstructExpr(EmptyShell Empty)
7376d00c1365dd3601f6d93bbda9162913c57ae788fArgyrios Kyrtzidis    : Expr(CXXConstructExprClass, Empty), Constructor(0),
7386d00c1365dd3601f6d93bbda9162913c57ae788fArgyrios Kyrtzidis      Elidable(0), ZeroInitialization(0),
7396d00c1365dd3601f6d93bbda9162913c57ae788fArgyrios Kyrtzidis      ConstructKind(0), Args(0), NumArgs(0) { }
7406d00c1365dd3601f6d93bbda9162913c57ae788fArgyrios Kyrtzidis
7418e587a15da6d3457a418239d5eb4146fcbd209f3Anders Carlsson  static CXXConstructExpr *Create(ASTContext &C, QualType T,
74299a2e600f9e2e51d3ce10fb6f27191677ac65b2aDouglas Gregor                                  SourceLocation Loc,
7431eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump                                  CXXConstructorDecl *D, bool Elidable,
74416006c901315fa12a108b4e571f187f4b676e426Douglas Gregor                                  Expr **Args, unsigned NumArgs,
7459db7dbb918ca49f4ee6c181e4917e7b6ec547353Douglas Gregor                                  bool ZeroInitialization = false,
746fcaeef2ae00ec643eb024e0aca2c98701cf5627cAnders Carlsson                                  ConstructionKind ConstructKind = CK_Complete);
7471eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
7481eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
749d94546a0a1deef7286c13e49b9584621ae81cc9aDouglas Gregor  CXXConstructorDecl* getConstructor() const { return Constructor; }
75039da0b8145eaec7da7004f9b3645c5c9f4f63b1dDouglas Gregor  void setConstructor(CXXConstructorDecl *C) { Constructor = C; }
75139da0b8145eaec7da7004f9b3645c5c9f4f63b1dDouglas Gregor
75299a2e600f9e2e51d3ce10fb6f27191677ac65b2aDouglas Gregor  SourceLocation getLocation() const { return Loc; }
75399a2e600f9e2e51d3ce10fb6f27191677ac65b2aDouglas Gregor  void setLocation(SourceLocation Loc) { this->Loc = Loc; }
75499a2e600f9e2e51d3ce10fb6f27191677ac65b2aDouglas Gregor
755d94546a0a1deef7286c13e49b9584621ae81cc9aDouglas Gregor  /// \brief Whether this construction is elidable.
756d94546a0a1deef7286c13e49b9584621ae81cc9aDouglas Gregor  bool isElidable() const { return Elidable; }
75739da0b8145eaec7da7004f9b3645c5c9f4f63b1dDouglas Gregor  void setElidable(bool E) { Elidable = E; }
75839da0b8145eaec7da7004f9b3645c5c9f4f63b1dDouglas Gregor
75916006c901315fa12a108b4e571f187f4b676e426Douglas Gregor  /// \brief Whether this construction first requires
76016006c901315fa12a108b4e571f187f4b676e426Douglas Gregor  /// zero-initialization before the initializer is called.
76116006c901315fa12a108b4e571f187f4b676e426Douglas Gregor  bool requiresZeroInitialization() const { return ZeroInitialization; }
76216006c901315fa12a108b4e571f187f4b676e426Douglas Gregor  void setRequiresZeroInitialization(bool ZeroInit) {
76316006c901315fa12a108b4e571f187f4b676e426Douglas Gregor    ZeroInitialization = ZeroInit;
76416006c901315fa12a108b4e571f187f4b676e426Douglas Gregor  }
76516006c901315fa12a108b4e571f187f4b676e426Douglas Gregor
7669db7dbb918ca49f4ee6c181e4917e7b6ec547353Douglas Gregor  /// \brief Determines whether this constructor is actually constructing
7679db7dbb918ca49f4ee6c181e4917e7b6ec547353Douglas Gregor  /// a base class (rather than a complete object).
76824eb78e38aba55c507bc3c05c37035a9ab2defa7Anders Carlsson  ConstructionKind getConstructionKind() const {
76924eb78e38aba55c507bc3c05c37035a9ab2defa7Anders Carlsson    return (ConstructionKind)ConstructKind;
77072e96fd181b19b8d01144a685cda6e955584c7eaAnders Carlsson  }
77172e96fd181b19b8d01144a685cda6e955584c7eaAnders Carlsson  void setConstructionKind(ConstructionKind CK) {
77272e96fd181b19b8d01144a685cda6e955584c7eaAnders Carlsson    ConstructKind = CK;
77372e96fd181b19b8d01144a685cda6e955584c7eaAnders Carlsson  }
7749db7dbb918ca49f4ee6c181e4917e7b6ec547353Douglas Gregor
77515ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson  typedef ExprIterator arg_iterator;
77615ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson  typedef ConstExprIterator const_arg_iterator;
7771eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
77815ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson  arg_iterator arg_begin() { return Args; }
77915ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson  arg_iterator arg_end() { return Args + NumArgs; }
78015ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson  const_arg_iterator arg_begin() const { return Args; }
78115ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson  const_arg_iterator arg_end() const { return Args + NumArgs; }
78215ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson
783a88cfbfac9bbcbb9858f048d6d73a48711d8e93dDouglas Gregor  Expr **getArgs() const { return reinterpret_cast<Expr **>(Args); }
78415ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson  unsigned getNumArgs() const { return NumArgs; }
78515ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson
786bcb11d01c034f967503bd98f28bdf458c1ab8001Anders Carlsson  /// getArg - Return the specified argument.
787bcb11d01c034f967503bd98f28bdf458c1ab8001Anders Carlsson  Expr *getArg(unsigned Arg) {
788bcb11d01c034f967503bd98f28bdf458c1ab8001Anders Carlsson    assert(Arg < NumArgs && "Arg access out of range!");
789bcb11d01c034f967503bd98f28bdf458c1ab8001Anders Carlsson    return cast<Expr>(Args[Arg]);
790bcb11d01c034f967503bd98f28bdf458c1ab8001Anders Carlsson  }
791bcb11d01c034f967503bd98f28bdf458c1ab8001Anders Carlsson  const Expr *getArg(unsigned Arg) const {
792bcb11d01c034f967503bd98f28bdf458c1ab8001Anders Carlsson    assert(Arg < NumArgs && "Arg access out of range!");
793bcb11d01c034f967503bd98f28bdf458c1ab8001Anders Carlsson    return cast<Expr>(Args[Arg]);
794bcb11d01c034f967503bd98f28bdf458c1ab8001Anders Carlsson  }
7951eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
7962eeed7bc4fd457ac57ff32ab3b02674588545f65Fariborz Jahanian  /// setArg - Set the specified argument.
7972eeed7bc4fd457ac57ff32ab3b02674588545f65Fariborz Jahanian  void setArg(unsigned Arg, Expr *ArgExpr) {
7982eeed7bc4fd457ac57ff32ab3b02674588545f65Fariborz Jahanian    assert(Arg < NumArgs && "Arg access out of range!");
7992eeed7bc4fd457ac57ff32ab3b02674588545f65Fariborz Jahanian    Args[Arg] = ArgExpr;
8002eeed7bc4fd457ac57ff32ab3b02674588545f65Fariborz Jahanian  }
8012eeed7bc4fd457ac57ff32ab3b02674588545f65Fariborz Jahanian
802e383768f7f5d45ca4af0b1c11cbf072de18bce98Ted Kremenek  virtual SourceRange getSourceRange() const;
80315ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson
8041eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  static bool classof(const Stmt *T) {
805524fa13fd81e88533c7a1d4b1232c0de2c97dc7cAnders Carlsson    return T->getStmtClass() == CXXConstructExprClass ||
806524fa13fd81e88533c7a1d4b1232c0de2c97dc7cAnders Carlsson      T->getStmtClass() == CXXTemporaryObjectExprClass;
80715ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson  }
80815ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson  static bool classof(const CXXConstructExpr *) { return true; }
8091eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
81015ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson  // Iterators
81115ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson  virtual child_iterator child_begin();
81215ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson  virtual child_iterator child_end();
8136d00c1365dd3601f6d93bbda9162913c57ae788fArgyrios Kyrtzidis
81460adf4acf40b72227740bf966fb87eebddff3f37Sebastian Redl  friend class ASTStmtReader;
81515ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson};
81615ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson
81749badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// CXXFunctionalCastExpr - Represents an explicit C++ type conversion
81849badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// that uses "functional" notion (C++ [expr.type.conv]). Example: @c
81949badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// x = int(0.5);
82049badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregorclass CXXFunctionalCastExpr : public ExplicitCastExpr {
821987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  SourceLocation TyBeginLoc;
822987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  SourceLocation RParenLoc;
823f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall
8249d125033a9853f3b572a4c9e2f9e2d4e5e346973John McCall  CXXFunctionalCastExpr(QualType ty, TypeSourceInfo *writtenTy,
8251eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump                        SourceLocation tyBeginLoc, CastKind kind,
826f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall                        Expr *castExpr, unsigned pathSize,
82741b2dcd465f1e438502c420effc9d0c747f9db8fAnders Carlsson                        SourceLocation rParenLoc)
8280aebc81e02397a5987aaa8e8c7acbdb01a31d7c3Anders Carlsson    : ExplicitCastExpr(CXXFunctionalCastExprClass, ty, kind, castExpr,
829f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall                       pathSize, writtenTy),
8300aebc81e02397a5987aaa8e8c7acbdb01a31d7c3Anders Carlsson      TyBeginLoc(tyBeginLoc), RParenLoc(rParenLoc) {}
8310aebc81e02397a5987aaa8e8c7acbdb01a31d7c3Anders Carlsson
832f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall  explicit CXXFunctionalCastExpr(EmptyShell Shell, unsigned PathSize)
833f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall    : ExplicitCastExpr(CXXFunctionalCastExprClass, Shell, PathSize) { }
834f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall
835f871d0cc377a1367b519a6cce26be74607566ebaJohn McCallpublic:
836f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall  static CXXFunctionalCastExpr *Create(ASTContext &Context, QualType T,
837f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall                                       TypeSourceInfo *Written,
838f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall                                       SourceLocation TyBeginLoc,
839f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall                                       CastKind Kind, Expr *Op,
840f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall                                       const CXXCastPath *Path,
841f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall                                       SourceLocation RPLoc);
842f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall  static CXXFunctionalCastExpr *CreateEmpty(ASTContext &Context,
843f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall                                            unsigned PathSize);
844ce757a7a1ee905f87551996a69da3e95e8afeeb7Sam Weinig
845987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  SourceLocation getTypeBeginLoc() const { return TyBeginLoc; }
846ce757a7a1ee905f87551996a69da3e95e8afeeb7Sam Weinig  void setTypeBeginLoc(SourceLocation L) { TyBeginLoc = L; }
847987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  SourceLocation getRParenLoc() const { return RParenLoc; }
848ce757a7a1ee905f87551996a69da3e95e8afeeb7Sam Weinig  void setRParenLoc(SourceLocation L) { RParenLoc = L; }
8491eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
850987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  virtual SourceRange getSourceRange() const {
851987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis    return SourceRange(TyBeginLoc, RParenLoc);
852987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  }
8531eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  static bool classof(const Stmt *T) {
8541eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump    return T->getStmtClass() == CXXFunctionalCastExprClass;
855987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  }
856987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  static bool classof(const CXXFunctionalCastExpr *) { return true; }
857987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis};
858987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis
859506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// @brief Represents a C++ functional cast expression that builds a
860506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// temporary object.
861506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor///
8621eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump/// This expression type represents a C++ "functional" cast
863506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// (C++[expr.type.conv]) with N != 1 arguments that invokes a
864ed8abf18329df67b0abcbb3a10458bd8c1d2a595Douglas Gregor/// constructor to build a temporary object. With N == 1 arguments the
865ed8abf18329df67b0abcbb3a10458bd8c1d2a595Douglas Gregor/// functional cast expression will be represented by CXXFunctionalCastExpr.
866506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// Example:
867506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// @code
868506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// struct X { X(int, float); }
869506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor///
870506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// X create_X() {
871506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor///   return X(1, 3.14f); // creates a CXXTemporaryObjectExpr
872506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// };
873506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// @endcode
874524fa13fd81e88533c7a1d4b1232c0de2c97dc7cAnders Carlssonclass CXXTemporaryObjectExpr : public CXXConstructExpr {
875506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor  SourceLocation RParenLoc;
876ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor  TypeSourceInfo *Type;
877506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor
878506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregorpublic:
8791eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  CXXTemporaryObjectExpr(ASTContext &C, CXXConstructorDecl *Cons,
880ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor                         TypeSourceInfo *Type,
8811eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump                         Expr **Args,unsigned NumArgs,
8821c63b9c15d48cb8c833a4b2d6fd6c496c0766e88Douglas Gregor                         SourceLocation rParenLoc,
8831c63b9c15d48cb8c833a4b2d6fd6c496c0766e88Douglas Gregor                         bool ZeroInitialization = false);
8846d00c1365dd3601f6d93bbda9162913c57ae788fArgyrios Kyrtzidis  explicit CXXTemporaryObjectExpr(EmptyShell Empty)
885ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor    : CXXConstructExpr(CXXTemporaryObjectExprClass, Empty), Type() { }
886506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor
887ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor  TypeSourceInfo *getTypeSourceInfo() const { return Type; }
888506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor  SourceLocation getRParenLoc() const { return RParenLoc; }
889ba49817c5b9f502602672861cf369fd0e53966e8Douglas Gregor
890ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor  virtual SourceRange getSourceRange() const;
891ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor
8921eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  static bool classof(const Stmt *T) {
893506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor    return T->getStmtClass() == CXXTemporaryObjectExprClass;
894506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor  }
895506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor  static bool classof(const CXXTemporaryObjectExpr *) { return true; }
8966d00c1365dd3601f6d93bbda9162913c57ae788fArgyrios Kyrtzidis
89760adf4acf40b72227740bf966fb87eebddff3f37Sebastian Redl  friend class ASTStmtReader;
898506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor};
899506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor
900ed8abf18329df67b0abcbb3a10458bd8c1d2a595Douglas Gregor/// CXXScalarValueInitExpr - [C++ 5.2.3p2]
901506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// Expression "T()" which creates a value-initialized rvalue of type
902ed8abf18329df67b0abcbb3a10458bd8c1d2a595Douglas Gregor/// T, which is a non-class type.
903987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis///
904ed8abf18329df67b0abcbb3a10458bd8c1d2a595Douglas Gregorclass CXXScalarValueInitExpr : public Expr {
905987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  SourceLocation RParenLoc;
906ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor  TypeSourceInfo *TypeInfo;
907987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis
908ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor  friend class ASTStmtReader;
909ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor
910987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidispublic:
911ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor  /// \brief Create an explicitly-written scalar-value initialization
912ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor  /// expression.
913ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor  CXXScalarValueInitExpr(QualType Type,
914ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor                         TypeSourceInfo *TypeInfo,
915ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor                         SourceLocation rParenLoc ) :
916ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor    Expr(CXXScalarValueInitExprClass, Type, false, false),
917ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor    RParenLoc(rParenLoc), TypeInfo(TypeInfo) {}
918ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor
919ed8abf18329df67b0abcbb3a10458bd8c1d2a595Douglas Gregor  explicit CXXScalarValueInitExpr(EmptyShell Shell)
920ed8abf18329df67b0abcbb3a10458bd8c1d2a595Douglas Gregor    : Expr(CXXScalarValueInitExprClass, Shell) { }
9211eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
922ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor  TypeSourceInfo *getTypeSourceInfo() const {
923ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor    return TypeInfo;
9244c67834407ca6ab344dcf44fc599ad4938cfa96dDouglas Gregor  }
925ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor
926ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor  SourceLocation getRParenLoc() const { return RParenLoc; }
9274c67834407ca6ab344dcf44fc599ad4938cfa96dDouglas Gregor
928ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor  virtual SourceRange getSourceRange() const;
9291eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
9301eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  static bool classof(const Stmt *T) {
931ed8abf18329df67b0abcbb3a10458bd8c1d2a595Douglas Gregor    return T->getStmtClass() == CXXScalarValueInitExprClass;
932987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  }
933ed8abf18329df67b0abcbb3a10458bd8c1d2a595Douglas Gregor  static bool classof(const CXXScalarValueInitExpr *) { return true; }
9341eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
935987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  // Iterators
936987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  virtual child_iterator child_begin();
937987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  virtual child_iterator child_end();
938987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis};
939987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis
9404c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl/// CXXNewExpr - A new expression for memory allocation and constructor calls,
9414c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl/// e.g: "new CXXNewExpr(foo)".
9424c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redlclass CXXNewExpr : public Expr {
9434c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  // Was the usage ::new, i.e. is the global new to be used?
9444c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  bool GlobalNew : 1;
9454c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  // Is there an initializer? If not, built-ins are uninitialized, else they're
9464c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  // value-initialized.
9474c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  bool Initializer : 1;
948cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl  // Do we allocate an array? If so, the first SubExpr is the size expression.
949cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl  bool Array : 1;
9504c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  // The number of placement new arguments.
951e4b8f1171d699c56ba2b39aabf1d7cb4c38ce4f8Douglas Gregor  unsigned NumPlacementArgs : 15;
9524c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  // The number of constructor arguments. This may be 1 even for non-class
9534c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  // types; use the pseudo copy constructor.
954cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl  unsigned NumConstructorArgs : 14;
955cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl  // Contains an optional array size expression, any number of optional
956cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl  // placement arguments, and any number of optional constructor arguments,
957cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl  // in that order.
9584c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  Stmt **SubExprs;
9594c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  // Points to the allocation function used.
9604c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  FunctionDecl *OperatorNew;
9614c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  // Points to the deallocation function used in case of error. May be null.
9624c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  FunctionDecl *OperatorDelete;
9634c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  // Points to the constructor used. Cannot be null if AllocType is a record;
9644c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  // it would still point at the default constructor (even an implicit one).
9654c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  // Must be null for all other types.
9664c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  CXXConstructorDecl *Constructor;
9674c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
9681bb2a93ab7b1499dda6f6b58865bd0dce1864228Douglas Gregor  /// \brief The allocated type-source information, as written in the source.
9691bb2a93ab7b1499dda6f6b58865bd0dce1864228Douglas Gregor  TypeSourceInfo *AllocatedTypeInfo;
9701bb2a93ab7b1499dda6f6b58865bd0dce1864228Douglas Gregor
9714bd40318cbea15310a37343db46de96c4fcc15e6Douglas Gregor  /// \brief If the allocated type was expressed as a parenthesized type-id,
9724bd40318cbea15310a37343db46de96c4fcc15e6Douglas Gregor  /// the source range covering the parenthesized type-id.
9734bd40318cbea15310a37343db46de96c4fcc15e6Douglas Gregor  SourceRange TypeIdParens;
9744bd40318cbea15310a37343db46de96c4fcc15e6Douglas Gregor
9754c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  SourceLocation StartLoc;
9764c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  SourceLocation EndLoc;
9774c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
97860adf4acf40b72227740bf966fb87eebddff3f37Sebastian Redl  friend class ASTStmtReader;
9794c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redlpublic:
980ad7fe864862305c2f71e047cdf6706ef43aebdc0Ted Kremenek  CXXNewExpr(ASTContext &C, bool globalNew, FunctionDecl *operatorNew,
9814bd40318cbea15310a37343db46de96c4fcc15e6Douglas Gregor             Expr **placementArgs, unsigned numPlaceArgs,
9824bd40318cbea15310a37343db46de96c4fcc15e6Douglas Gregor             SourceRange TypeIdParens,
983ad7fe864862305c2f71e047cdf6706ef43aebdc0Ted Kremenek             Expr *arraySize, CXXConstructorDecl *constructor, bool initializer,
9844c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl             Expr **constructorArgs, unsigned numConsArgs,
9854c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl             FunctionDecl *operatorDelete, QualType ty,
9861bb2a93ab7b1499dda6f6b58865bd0dce1864228Douglas Gregor             TypeSourceInfo *AllocatedTypeInfo,
9874c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl             SourceLocation startLoc, SourceLocation endLoc);
9885921863d8f24084797863b5df37842113bac4352Chris Lattner  explicit CXXNewExpr(EmptyShell Shell)
9895921863d8f24084797863b5df37842113bac4352Chris Lattner    : Expr(CXXNewExprClass, Shell), SubExprs(0) { }
9905921863d8f24084797863b5df37842113bac4352Chris Lattner
9915921863d8f24084797863b5df37842113bac4352Chris Lattner  void AllocateArgsArray(ASTContext &C, bool isArray, unsigned numPlaceArgs,
9925921863d8f24084797863b5df37842113bac4352Chris Lattner                         unsigned numConsArgs);
993ad7fe864862305c2f71e047cdf6706ef43aebdc0Ted Kremenek
994cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl  QualType getAllocatedType() const {
995cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl    assert(getType()->isPointerType());
9966217b80b7a1379b74cced1c076338262c3c980b3Ted Kremenek    return getType()->getAs<PointerType>()->getPointeeType();
997cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl  }
9984c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
9991bb2a93ab7b1499dda6f6b58865bd0dce1864228Douglas Gregor  TypeSourceInfo *getAllocatedTypeSourceInfo() const {
10001bb2a93ab7b1499dda6f6b58865bd0dce1864228Douglas Gregor    return AllocatedTypeInfo;
10011bb2a93ab7b1499dda6f6b58865bd0dce1864228Douglas Gregor  }
10021bb2a93ab7b1499dda6f6b58865bd0dce1864228Douglas Gregor
10034c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  FunctionDecl *getOperatorNew() const { return OperatorNew; }
10045921863d8f24084797863b5df37842113bac4352Chris Lattner  void setOperatorNew(FunctionDecl *D) { OperatorNew = D; }
10054c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  FunctionDecl *getOperatorDelete() const { return OperatorDelete; }
10065921863d8f24084797863b5df37842113bac4352Chris Lattner  void setOperatorDelete(FunctionDecl *D) { OperatorDelete = D; }
10074c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  CXXConstructorDecl *getConstructor() const { return Constructor; }
10085921863d8f24084797863b5df37842113bac4352Chris Lattner  void setConstructor(CXXConstructorDecl *D) { Constructor = D; }
10094c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
1010cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl  bool isArray() const { return Array; }
1011cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl  Expr *getArraySize() {
1012cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl    return Array ? cast<Expr>(SubExprs[0]) : 0;
1013cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl  }
1014cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl  const Expr *getArraySize() const {
1015cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl    return Array ? cast<Expr>(SubExprs[0]) : 0;
1016cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl  }
1017cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl
10184c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  unsigned getNumPlacementArgs() const { return NumPlacementArgs; }
10194c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  Expr *getPlacementArg(unsigned i) {
10204c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl    assert(i < NumPlacementArgs && "Index out of range");
1021cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl    return cast<Expr>(SubExprs[Array + i]);
10224c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  }
10234c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  const Expr *getPlacementArg(unsigned i) const {
10244c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl    assert(i < NumPlacementArgs && "Index out of range");
1025cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl    return cast<Expr>(SubExprs[Array + i]);
10264c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  }
10274c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
10284bd40318cbea15310a37343db46de96c4fcc15e6Douglas Gregor  bool isParenTypeId() const { return TypeIdParens.isValid(); }
10294bd40318cbea15310a37343db46de96c4fcc15e6Douglas Gregor  SourceRange getTypeIdParens() const { return TypeIdParens; }
10304bd40318cbea15310a37343db46de96c4fcc15e6Douglas Gregor
10314c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  bool isGlobalNew() const { return GlobalNew; }
10325921863d8f24084797863b5df37842113bac4352Chris Lattner  void setGlobalNew(bool V) { GlobalNew = V; }
10334c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  bool hasInitializer() const { return Initializer; }
10345921863d8f24084797863b5df37842113bac4352Chris Lattner  void setHasInitializer(bool V) { Initializer = V; }
10354c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
10364c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  unsigned getNumConstructorArgs() const { return NumConstructorArgs; }
10374c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  Expr *getConstructorArg(unsigned i) {
10384c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl    assert(i < NumConstructorArgs && "Index out of range");
1039cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl    return cast<Expr>(SubExprs[Array + NumPlacementArgs + i]);
10404c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  }
10414c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  const Expr *getConstructorArg(unsigned i) const {
10424c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl    assert(i < NumConstructorArgs && "Index out of range");
1043cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl    return cast<Expr>(SubExprs[Array + NumPlacementArgs + i]);
10444c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  }
10454c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
10464c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  typedef ExprIterator arg_iterator;
10474c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  typedef ConstExprIterator const_arg_iterator;
10484c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
10494c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  arg_iterator placement_arg_begin() {
1050cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl    return SubExprs + Array;
10514c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  }
10524c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  arg_iterator placement_arg_end() {
1053cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl    return SubExprs + Array + getNumPlacementArgs();
10544c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  }
10554c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  const_arg_iterator placement_arg_begin() const {
1056cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl    return SubExprs + Array;
10574c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  }
10584c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  const_arg_iterator placement_arg_end() const {
1059cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl    return SubExprs + Array + getNumPlacementArgs();
10604c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  }
10614c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
10624c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  arg_iterator constructor_arg_begin() {
1063cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl    return SubExprs + Array + getNumPlacementArgs();
10644c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  }
10654c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  arg_iterator constructor_arg_end() {
1066cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl    return SubExprs + Array + getNumPlacementArgs() + getNumConstructorArgs();
10674c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  }
10684c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  const_arg_iterator constructor_arg_begin() const {
1069cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl    return SubExprs + Array + getNumPlacementArgs();
10704c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  }
10714c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  const_arg_iterator constructor_arg_end() const {
1072cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl    return SubExprs + Array + getNumPlacementArgs() + getNumConstructorArgs();
10734c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  }
10745921863d8f24084797863b5df37842113bac4352Chris Lattner
10755921863d8f24084797863b5df37842113bac4352Chris Lattner  typedef Stmt **raw_arg_iterator;
10765921863d8f24084797863b5df37842113bac4352Chris Lattner  raw_arg_iterator raw_arg_begin() { return SubExprs; }
10775921863d8f24084797863b5df37842113bac4352Chris Lattner  raw_arg_iterator raw_arg_end() {
10785921863d8f24084797863b5df37842113bac4352Chris Lattner    return SubExprs + Array + getNumPlacementArgs() + getNumConstructorArgs();
10795921863d8f24084797863b5df37842113bac4352Chris Lattner  }
10805921863d8f24084797863b5df37842113bac4352Chris Lattner  const_arg_iterator raw_arg_begin() const { return SubExprs; }
10815921863d8f24084797863b5df37842113bac4352Chris Lattner  const_arg_iterator raw_arg_end() const { return constructor_arg_end(); }
10824c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
10835921863d8f24084797863b5df37842113bac4352Chris Lattner
10845921863d8f24084797863b5df37842113bac4352Chris Lattner  SourceLocation getStartLoc() const { return StartLoc; }
10855921863d8f24084797863b5df37842113bac4352Chris Lattner  void setStartLoc(SourceLocation L) { StartLoc = L; }
10865921863d8f24084797863b5df37842113bac4352Chris Lattner  SourceLocation getEndLoc() const { return EndLoc; }
10875921863d8f24084797863b5df37842113bac4352Chris Lattner  void setEndLoc(SourceLocation L) { EndLoc = L; }
10885921863d8f24084797863b5df37842113bac4352Chris Lattner
10894c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  virtual SourceRange getSourceRange() const {
10904c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl    return SourceRange(StartLoc, EndLoc);
10914c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  }
10924c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
10934c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  static bool classof(const Stmt *T) {
10944c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl    return T->getStmtClass() == CXXNewExprClass;
10954c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  }
10964c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  static bool classof(const CXXNewExpr *) { return true; }
10974c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
10984c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  // Iterators
10994c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  virtual child_iterator child_begin();
11004c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  virtual child_iterator child_end();
11014c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl};
11024c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
11034c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl/// CXXDeleteExpr - A delete expression for memory deallocation and destructor
11044c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl/// calls, e.g. "delete[] pArray".
11054c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redlclass CXXDeleteExpr : public Expr {
11064c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  // Is this a forced global delete, i.e. "::delete"?
11074c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  bool GlobalDelete : 1;
11084c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  // Is this the array form of delete, i.e. "delete[]"?
11094c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  bool ArrayForm : 1;
11104c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  // Points to the operator delete overload that is used. Could be a member.
11114c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  FunctionDecl *OperatorDelete;
11124c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  // The pointer expression to be deleted.
11134c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  Stmt *Argument;
11144c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  // Location of the expression.
11154c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  SourceLocation Loc;
11164c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redlpublic:
11174c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  CXXDeleteExpr(QualType ty, bool globalDelete, bool arrayForm,
11184c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl                FunctionDecl *operatorDelete, Expr *arg, SourceLocation loc)
11192850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl    : Expr(CXXDeleteExprClass, ty, false, false), GlobalDelete(globalDelete),
11204c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl      ArrayForm(arrayForm), OperatorDelete(operatorDelete), Argument(arg),
11214c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl      Loc(loc) { }
112295fc98ce95d4faa4f1bb2783384150530404ea6fArgyrios Kyrtzidis  explicit CXXDeleteExpr(EmptyShell Shell)
112395fc98ce95d4faa4f1bb2783384150530404ea6fArgyrios Kyrtzidis    : Expr(CXXDeleteExprClass, Shell), OperatorDelete(0), Argument(0) { }
11244c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
11254c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  bool isGlobalDelete() const { return GlobalDelete; }
11264c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  bool isArrayForm() const { return ArrayForm; }
112795fc98ce95d4faa4f1bb2783384150530404ea6fArgyrios Kyrtzidis
112895fc98ce95d4faa4f1bb2783384150530404ea6fArgyrios Kyrtzidis  void setGlobalDelete(bool V) { GlobalDelete = V; }
112995fc98ce95d4faa4f1bb2783384150530404ea6fArgyrios Kyrtzidis  void setArrayForm(bool V) { ArrayForm = V; }
11304c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
11314c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  FunctionDecl *getOperatorDelete() const { return OperatorDelete; }
113295fc98ce95d4faa4f1bb2783384150530404ea6fArgyrios Kyrtzidis  void setOperatorDelete(FunctionDecl *D) { OperatorDelete = D; }
11334c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
11344c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  Expr *getArgument() { return cast<Expr>(Argument); }
11354c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  const Expr *getArgument() const { return cast<Expr>(Argument); }
113695fc98ce95d4faa4f1bb2783384150530404ea6fArgyrios Kyrtzidis  void setArgument(Expr *E) { Argument = E; }
11374c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
11384c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  virtual SourceRange getSourceRange() const {
11394c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl    return SourceRange(Loc, Argument->getLocEnd());
11404c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  }
114195fc98ce95d4faa4f1bb2783384150530404ea6fArgyrios Kyrtzidis  void setStartLoc(SourceLocation L) { Loc = L; }
11424c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
11434c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  static bool classof(const Stmt *T) {
11444c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl    return T->getStmtClass() == CXXDeleteExprClass;
11454c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  }
11464c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  static bool classof(const CXXDeleteExpr *) { return true; }
11474c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
11484c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  // Iterators
11494c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  virtual child_iterator child_begin();
11504c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  virtual child_iterator child_end();
11514c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl};
11524c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
1153a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor/// \brief Structure used to store the type being destroyed by a
1154a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor/// pseudo-destructor expression.
1155a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregorclass PseudoDestructorTypeStorage {
1156a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor  /// \brief Either the type source information or the name of the type, if
1157a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor  /// it couldn't be resolved due to type-dependence.
1158a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor  llvm::PointerUnion<TypeSourceInfo *, IdentifierInfo *> Type;
1159a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor
1160a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor  /// \brief The starting source location of the pseudo-destructor type.
1161a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor  SourceLocation Location;
1162a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor
1163a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregorpublic:
1164a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor  PseudoDestructorTypeStorage() { }
1165a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor
1166a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor  PseudoDestructorTypeStorage(IdentifierInfo *II, SourceLocation Loc)
1167a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor    : Type(II), Location(Loc) { }
1168a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor
1169a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor  PseudoDestructorTypeStorage(TypeSourceInfo *Info);
1170a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor
1171a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor  TypeSourceInfo *getTypeSourceInfo() const {
1172a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor    return Type.dyn_cast<TypeSourceInfo *>();
1173a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor  }
1174a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor
1175a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor  IdentifierInfo *getIdentifier() const {
1176a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor    return Type.dyn_cast<IdentifierInfo *>();
1177a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor  }
1178a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor
1179a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor  SourceLocation getLocation() const { return Location; }
1180a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor};
1181a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor
1182a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor/// \brief Represents a C++ pseudo-destructor (C++ [expr.pseudo]).
1183a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor///
1184e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor/// A pseudo-destructor is an expression that looks like a member access to a
1185e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor/// destructor of a scalar type, except that scalar types don't have
1186e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor/// destructors. For example:
1187e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor///
1188e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor/// \code
1189e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor/// typedef int T;
1190e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor/// void f(int *p) {
1191e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor///   p->T::~T();
1192e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor/// }
1193e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor/// \endcode
1194a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor///
1195e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor/// Pseudo-destructors typically occur when instantiating templates such as:
1196e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor///
1197a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor/// \code
11981eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump/// template<typename T>
1199a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor/// void destroy(T* ptr) {
1200e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor///   ptr->T::~T();
1201a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor/// }
1202a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor/// \endcode
1203a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor///
1204e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor/// for scalar types. A pseudo-destructor expression has no run-time semantics
1205e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor/// beyond evaluating the base expression.
1206a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregorclass CXXPseudoDestructorExpr : public Expr {
1207a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  /// \brief The base expression (that is being destroyed).
1208a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  Stmt *Base;
12091eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1210a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  /// \brief Whether the operator was an arrow ('->'); otherwise, it was a
1211a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  /// period ('.').
1212a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  bool IsArrow : 1;
12131eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1214a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  /// \brief The location of the '.' or '->' operator.
1215a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  SourceLocation OperatorLoc;
12161eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1217a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  /// \brief The nested-name-specifier that follows the operator, if present.
1218a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  NestedNameSpecifier *Qualifier;
12191eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
12201eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  /// \brief The source range that covers the nested-name-specifier, if
1221a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  /// present.
1222a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  SourceRange QualifierRange;
12231eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1224e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor  /// \brief The type that precedes the '::' in a qualified pseudo-destructor
1225e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor  /// expression.
1226e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor  TypeSourceInfo *ScopeType;
1227e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor
1228e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor  /// \brief The location of the '::' in a qualified pseudo-destructor
1229e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor  /// expression.
1230e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor  SourceLocation ColonColonLoc;
1231e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor
1232fce46ee68f779e239826e69e45d01d4c8e5323caDouglas Gregor  /// \brief The location of the '~'.
1233fce46ee68f779e239826e69e45d01d4c8e5323caDouglas Gregor  SourceLocation TildeLoc;
1234fce46ee68f779e239826e69e45d01d4c8e5323caDouglas Gregor
1235a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor  /// \brief The type being destroyed, or its name if we were unable to
1236a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor  /// resolve the name.
1237a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor  PseudoDestructorTypeStorage DestroyedType;
12381eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1239a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregorpublic:
1240a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  CXXPseudoDestructorExpr(ASTContext &Context,
1241a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor                          Expr *Base, bool isArrow, SourceLocation OperatorLoc,
1242a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor                          NestedNameSpecifier *Qualifier,
1243a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor                          SourceRange QualifierRange,
1244e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor                          TypeSourceInfo *ScopeType,
1245e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor                          SourceLocation ColonColonLoc,
1246fce46ee68f779e239826e69e45d01d4c8e5323caDouglas Gregor                          SourceLocation TildeLoc,
1247a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor                          PseudoDestructorTypeStorage DestroyedType)
12481eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump    : Expr(CXXPseudoDestructorExprClass,
1249a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor           Context.getPointerType(Context.getFunctionType(Context.VoidTy, 0, 0,
1250ce056bcaa1c97b89a4b2de2112c62d060863be2bDouglas Gregor                                                          false, 0, false,
1251264ba48dc98f3f843935a485d5b086f7e0fdc4f1Rafael Espindola                                                          false, 0, 0,
1252264ba48dc98f3f843935a485d5b086f7e0fdc4f1Rafael Espindola                                                      FunctionType::ExtInfo())),
125326d4ac97fb514bb60c2536eae6f203dc569159d9Douglas Gregor           /*isTypeDependent=*/(Base->isTypeDependent() ||
1254a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor            (DestroyedType.getTypeSourceInfo() &&
1255a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor              DestroyedType.getTypeSourceInfo()->getType()->isDependentType())),
1256a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor           /*isValueDependent=*/Base->isValueDependent()),
12571eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump      Base(static_cast<Stmt *>(Base)), IsArrow(isArrow),
1258a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor      OperatorLoc(OperatorLoc), Qualifier(Qualifier),
1259e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor      QualifierRange(QualifierRange),
1260fce46ee68f779e239826e69e45d01d4c8e5323caDouglas Gregor      ScopeType(ScopeType), ColonColonLoc(ColonColonLoc), TildeLoc(TildeLoc),
126126d4ac97fb514bb60c2536eae6f203dc569159d9Douglas Gregor      DestroyedType(DestroyedType) { }
12621eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1263de4bd18bb45a1db68996cfb949db3015fc25d10dArgyrios Kyrtzidis  explicit CXXPseudoDestructorExpr(EmptyShell Shell)
1264de4bd18bb45a1db68996cfb949db3015fc25d10dArgyrios Kyrtzidis    : Expr(CXXPseudoDestructorExprClass, Shell),
1265de4bd18bb45a1db68996cfb949db3015fc25d10dArgyrios Kyrtzidis      Base(0), IsArrow(false), Qualifier(0), ScopeType(0) { }
1266de4bd18bb45a1db68996cfb949db3015fc25d10dArgyrios Kyrtzidis
1267a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  void setBase(Expr *E) { Base = E; }
1268a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  Expr *getBase() const { return cast<Expr>(Base); }
12691eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
12701eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  /// \brief Determines whether this member expression actually had
1271a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  /// a C++ nested-name-specifier prior to the name of the member, e.g.,
1272a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  /// x->Base::foo.
1273a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  bool hasQualifier() const { return Qualifier != 0; }
12741eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1275a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  /// \brief If the member name was qualified, retrieves the source range of
1276a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  /// the nested-name-specifier that precedes the member name. Otherwise,
1277a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  /// returns an empty source range.
1278a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  SourceRange getQualifierRange() const { return QualifierRange; }
1279de4bd18bb45a1db68996cfb949db3015fc25d10dArgyrios Kyrtzidis  void setQualifierRange(SourceRange R) { QualifierRange = R; }
12801eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
12811eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  /// \brief If the member name was qualified, retrieves the
1282a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  /// nested-name-specifier that precedes the member name. Otherwise, returns
1283a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  /// NULL.
1284a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  NestedNameSpecifier *getQualifier() const { return Qualifier; }
1285de4bd18bb45a1db68996cfb949db3015fc25d10dArgyrios Kyrtzidis  void setQualifier(NestedNameSpecifier *NNS) { Qualifier = NNS; }
12861eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1287a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  /// \brief Determine whether this pseudo-destructor expression was written
1288a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  /// using an '->' (otherwise, it used a '.').
1289a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  bool isArrow() const { return IsArrow; }
1290a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  void setArrow(bool A) { IsArrow = A; }
1291a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor
1292a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  /// \brief Retrieve the location of the '.' or '->' operator.
1293a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  SourceLocation getOperatorLoc() const { return OperatorLoc; }
1294de4bd18bb45a1db68996cfb949db3015fc25d10dArgyrios Kyrtzidis  void setOperatorLoc(SourceLocation L) { OperatorLoc = L; }
12951eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1296e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor  /// \brief Retrieve the scope type in a qualified pseudo-destructor
1297e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor  /// expression.
1298e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor  ///
1299e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor  /// Pseudo-destructor expressions can have extra qualification within them
1300e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor  /// that is not part of the nested-name-specifier, e.g., \c p->T::~T().
1301e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor  /// Here, if the object type of the expression is (or may be) a scalar type,
1302e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor  /// \p T may also be a scalar type and, therefore, cannot be part of a
1303e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor  /// nested-name-specifier. It is stored as the "scope type" of the pseudo-
1304e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor  /// destructor expression.
130526d4ac97fb514bb60c2536eae6f203dc569159d9Douglas Gregor  TypeSourceInfo *getScopeTypeInfo() const { return ScopeType; }
1306de4bd18bb45a1db68996cfb949db3015fc25d10dArgyrios Kyrtzidis  void setScopeTypeInfo(TypeSourceInfo *Info) { ScopeType = Info; }
1307e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor
1308e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor  /// \brief Retrieve the location of the '::' in a qualified pseudo-destructor
1309e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor  /// expression.
1310e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor  SourceLocation getColonColonLoc() const { return ColonColonLoc; }
1311de4bd18bb45a1db68996cfb949db3015fc25d10dArgyrios Kyrtzidis  void setColonColonLoc(SourceLocation L) { ColonColonLoc = L; }
1312e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor
1313fce46ee68f779e239826e69e45d01d4c8e5323caDouglas Gregor  /// \brief Retrieve the location of the '~'.
1314fce46ee68f779e239826e69e45d01d4c8e5323caDouglas Gregor  SourceLocation getTildeLoc() const { return TildeLoc; }
1315de4bd18bb45a1db68996cfb949db3015fc25d10dArgyrios Kyrtzidis  void setTildeLoc(SourceLocation L) { TildeLoc = L; }
1316fce46ee68f779e239826e69e45d01d4c8e5323caDouglas Gregor
131726d4ac97fb514bb60c2536eae6f203dc569159d9Douglas Gregor  /// \brief Retrieve the source location information for the type
131826d4ac97fb514bb60c2536eae6f203dc569159d9Douglas Gregor  /// being destroyed.
1319a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor  ///
1320a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor  /// This type-source information is available for non-dependent
1321a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor  /// pseudo-destructor expressions and some dependent pseudo-destructor
1322a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor  /// expressions. Returns NULL if we only have the identifier for a
1323a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor  /// dependent pseudo-destructor expression.
1324a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor  TypeSourceInfo *getDestroyedTypeInfo() const {
1325a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor    return DestroyedType.getTypeSourceInfo();
1326a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor  }
1327a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor
1328a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor  /// \brief In a dependent pseudo-destructor expression for which we do not
1329a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor  /// have full type information on the destroyed type, provides the name
1330a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor  /// of the destroyed type.
1331a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor  IdentifierInfo *getDestroyedTypeIdentifier() const {
1332a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor    return DestroyedType.getIdentifier();
1333a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor  }
1334a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor
1335a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor  /// \brief Retrieve the type being destroyed.
1336a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor  QualType getDestroyedType() const;
1337a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor
1338a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor  /// \brief Retrieve the starting location of the type being destroyed.
1339a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor  SourceLocation getDestroyedTypeLoc() const {
1340a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor    return DestroyedType.getLocation();
1341a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor  }
13421eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1343de4bd18bb45a1db68996cfb949db3015fc25d10dArgyrios Kyrtzidis  /// \brief Set the name of destroyed type for a dependent pseudo-destructor
1344de4bd18bb45a1db68996cfb949db3015fc25d10dArgyrios Kyrtzidis  /// expression.
1345de4bd18bb45a1db68996cfb949db3015fc25d10dArgyrios Kyrtzidis  void setDestroyedType(IdentifierInfo *II, SourceLocation Loc) {
1346de4bd18bb45a1db68996cfb949db3015fc25d10dArgyrios Kyrtzidis    DestroyedType = PseudoDestructorTypeStorage(II, Loc);
1347de4bd18bb45a1db68996cfb949db3015fc25d10dArgyrios Kyrtzidis  }
1348de4bd18bb45a1db68996cfb949db3015fc25d10dArgyrios Kyrtzidis
1349de4bd18bb45a1db68996cfb949db3015fc25d10dArgyrios Kyrtzidis  /// \brief Set the destroyed type.
1350de4bd18bb45a1db68996cfb949db3015fc25d10dArgyrios Kyrtzidis  void setDestroyedType(TypeSourceInfo *Info) {
1351de4bd18bb45a1db68996cfb949db3015fc25d10dArgyrios Kyrtzidis    DestroyedType = PseudoDestructorTypeStorage(Info);
1352de4bd18bb45a1db68996cfb949db3015fc25d10dArgyrios Kyrtzidis  }
1353de4bd18bb45a1db68996cfb949db3015fc25d10dArgyrios Kyrtzidis
135426d4ac97fb514bb60c2536eae6f203dc569159d9Douglas Gregor  virtual SourceRange getSourceRange() const;
13551eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
13561eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  static bool classof(const Stmt *T) {
1357a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor    return T->getStmtClass() == CXXPseudoDestructorExprClass;
1358a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  }
1359a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  static bool classof(const CXXPseudoDestructorExpr *) { return true; }
13601eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1361a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  // Iterators
1362a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  virtual child_iterator child_begin();
13631eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  virtual child_iterator child_end();
1364a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor};
13651eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
136664b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl/// UnaryTypeTraitExpr - A GCC or MS unary type trait, as used in the
136764b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl/// implementation of TR1/C++0x type trait templates.
136864b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl/// Example:
136964b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl/// __is_pod(int) == true
137064b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl/// __is_enum(std::string) == false
137164b45f7e0d3167f040841ac2920aead7f080730dSebastian Redlclass UnaryTypeTraitExpr : public Expr {
137264b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl  /// UTT - The trait.
137364b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl  UnaryTypeTrait UTT;
137464b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl
137564b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl  /// Loc - The location of the type trait keyword.
137664b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl  SourceLocation Loc;
137764b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl
137864b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl  /// RParen - The location of the closing paren.
137964b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl  SourceLocation RParen;
138064b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl
13813d37c0ada0e46b87be0a10e8d52d990a97d3907aDouglas Gregor  TypeSourceInfo *QueriedType;
138264b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl
138364b45f7e0d3167f040841ac2920aead7f080730dSebastian Redlpublic:
13843d37c0ada0e46b87be0a10e8d52d990a97d3907aDouglas Gregor  UnaryTypeTraitExpr(SourceLocation loc, UnaryTypeTrait utt,
13853d37c0ada0e46b87be0a10e8d52d990a97d3907aDouglas Gregor                     TypeSourceInfo *queried,
138664b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl                     SourceLocation rparen, QualType ty)
13873d37c0ada0e46b87be0a10e8d52d990a97d3907aDouglas Gregor    : Expr(UnaryTypeTraitExprClass, ty, false,
13883d37c0ada0e46b87be0a10e8d52d990a97d3907aDouglas Gregor           queried->getType()->isDependentType()),
138964b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl      UTT(utt), Loc(loc), RParen(rparen), QueriedType(queried) { }
139064b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl
13916d00c1365dd3601f6d93bbda9162913c57ae788fArgyrios Kyrtzidis  explicit UnaryTypeTraitExpr(EmptyShell Empty)
13923d37c0ada0e46b87be0a10e8d52d990a97d3907aDouglas Gregor    : Expr(UnaryTypeTraitExprClass, Empty), UTT((UnaryTypeTrait)0),
13933d37c0ada0e46b87be0a10e8d52d990a97d3907aDouglas Gregor      QueriedType() { }
13946d00c1365dd3601f6d93bbda9162913c57ae788fArgyrios Kyrtzidis
139564b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl  virtual SourceRange getSourceRange() const { return SourceRange(Loc, RParen);}
139664b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl
139764b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl  UnaryTypeTrait getTrait() const { return UTT; }
139864b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl
13993d37c0ada0e46b87be0a10e8d52d990a97d3907aDouglas Gregor  QualType getQueriedType() const { return QueriedType->getType(); }
140064b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl
14013d37c0ada0e46b87be0a10e8d52d990a97d3907aDouglas Gregor  TypeSourceInfo *getQueriedTypeSourceInfo() const { return QueriedType; }
14023d37c0ada0e46b87be0a10e8d52d990a97d3907aDouglas Gregor
14035e03f9ea8174ae588c5e69ec6b5ef4c68f8fd766Douglas Gregor  bool EvaluateTrait(ASTContext&) const;
140464b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl
140564b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl  static bool classof(const Stmt *T) {
140664b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl    return T->getStmtClass() == UnaryTypeTraitExprClass;
140764b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl  }
140864b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl  static bool classof(const UnaryTypeTraitExpr *) { return true; }
140964b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl
141064b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl  // Iterators
141164b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl  virtual child_iterator child_begin();
141264b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl  virtual child_iterator child_end();
14136d00c1365dd3601f6d93bbda9162913c57ae788fArgyrios Kyrtzidis
141460adf4acf40b72227740bf966fb87eebddff3f37Sebastian Redl  friend class ASTStmtReader;
141564b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl};
141664b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl
14177bb12da2b0749eeebb21854c77877736969e59f2John McCall/// \brief A reference to an overloaded function set, either an
14187bb12da2b0749eeebb21854c77877736969e59f2John McCall/// \t UnresolvedLookupExpr or an \t UnresolvedMemberExpr.
14197bb12da2b0749eeebb21854c77877736969e59f2John McCallclass OverloadExpr : public Expr {
1420ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  /// The results.  These are undesugared, which is to say, they may
14217bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// include UsingShadowDecls.  Access is relative to the naming
14227bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// class.
1423928e6fcf66fc4f342bcf7cc96bf56986c9c2a833Douglas Gregor  // FIXME: Allocate this data after the OverloadExpr subclass.
1424928e6fcf66fc4f342bcf7cc96bf56986c9c2a833Douglas Gregor  DeclAccessPair *Results;
1425928e6fcf66fc4f342bcf7cc96bf56986c9c2a833Douglas Gregor  unsigned NumResults;
1426ba13543329afac4a0d01304ec2ec4924d99306a6John McCall
14277bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// The common name of these declarations.
14282577743c5650c646fb705df01403707e94f2df04Abramo Bagnara  DeclarationNameInfo NameInfo;
1429ba13543329afac4a0d01304ec2ec4924d99306a6John McCall
14307bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// The scope specifier, if any.
1431ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  NestedNameSpecifier *Qualifier;
14327bb12da2b0749eeebb21854c77877736969e59f2John McCall
14337bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// The source range of the scope specifier.
1434ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  SourceRange QualifierRange;
1435ba13543329afac4a0d01304ec2ec4924d99306a6John McCall
1436a77eb0862507b900a10fa352af1568e639ed10b1Argyrios Kyrtzidisprotected:
14377bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// True if the name was a template-id.
14387bb12da2b0749eeebb21854c77877736969e59f2John McCall  bool HasExplicitTemplateArgs;
14397bb12da2b0749eeebb21854c77877736969e59f2John McCall
1440928e6fcf66fc4f342bcf7cc96bf56986c9c2a833Douglas Gregor  OverloadExpr(StmtClass K, ASTContext &C, QualType T, bool Dependent,
14417bb12da2b0749eeebb21854c77877736969e59f2John McCall               NestedNameSpecifier *Qualifier, SourceRange QRange,
14422577743c5650c646fb705df01403707e94f2df04Abramo Bagnara               const DeclarationNameInfo &NameInfo,
14435a84dec38cfa9e084377a3167b474c79283c82faDouglas Gregor               bool HasTemplateArgs,
1444928e6fcf66fc4f342bcf7cc96bf56986c9c2a833Douglas Gregor               UnresolvedSetIterator Begin, UnresolvedSetIterator End);
14457bb12da2b0749eeebb21854c77877736969e59f2John McCall
1446a77eb0862507b900a10fa352af1568e639ed10b1Argyrios Kyrtzidis  OverloadExpr(StmtClass K, EmptyShell Empty)
1447a77eb0862507b900a10fa352af1568e639ed10b1Argyrios Kyrtzidis    : Expr(K, Empty), Results(0), NumResults(0),
1448a77eb0862507b900a10fa352af1568e639ed10b1Argyrios Kyrtzidis      Qualifier(0), HasExplicitTemplateArgs(false) { }
1449a77eb0862507b900a10fa352af1568e639ed10b1Argyrios Kyrtzidis
14507bb12da2b0749eeebb21854c77877736969e59f2John McCallpublic:
14517bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// Computes whether an unresolved lookup on the given declarations
14527bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// and optional template arguments is type- and value-dependent.
14537bb12da2b0749eeebb21854c77877736969e59f2John McCall  static bool ComputeDependence(UnresolvedSetIterator Begin,
14547bb12da2b0749eeebb21854c77877736969e59f2John McCall                                UnresolvedSetIterator End,
14557bb12da2b0749eeebb21854c77877736969e59f2John McCall                                const TemplateArgumentListInfo *Args);
14567bb12da2b0749eeebb21854c77877736969e59f2John McCall
14579c72c6088d591ace8503b842d39448c2040f3033John McCall  struct FindResult {
14589c72c6088d591ace8503b842d39448c2040f3033John McCall    OverloadExpr *Expression;
14599c72c6088d591ace8503b842d39448c2040f3033John McCall    bool IsAddressOfOperand;
14609c72c6088d591ace8503b842d39448c2040f3033John McCall    bool HasFormOfMemberPointer;
14619c72c6088d591ace8503b842d39448c2040f3033John McCall  };
14629c72c6088d591ace8503b842d39448c2040f3033John McCall
14637bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// Finds the overloaded expression in the given expression of
14647bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// OverloadTy.
14657bb12da2b0749eeebb21854c77877736969e59f2John McCall  ///
14669c72c6088d591ace8503b842d39448c2040f3033John McCall  /// \return the expression (which must be there) and true if it has
14679c72c6088d591ace8503b842d39448c2040f3033John McCall  /// the particular form of a member pointer expression
14689c72c6088d591ace8503b842d39448c2040f3033John McCall  static FindResult find(Expr *E) {
14697bb12da2b0749eeebb21854c77877736969e59f2John McCall    assert(E->getType()->isSpecificBuiltinType(BuiltinType::Overload));
14707bb12da2b0749eeebb21854c77877736969e59f2John McCall
14719c72c6088d591ace8503b842d39448c2040f3033John McCall    FindResult Result;
14729c72c6088d591ace8503b842d39448c2040f3033John McCall
14737bb12da2b0749eeebb21854c77877736969e59f2John McCall    E = E->IgnoreParens();
14749c72c6088d591ace8503b842d39448c2040f3033John McCall    if (isa<UnaryOperator>(E)) {
14759c72c6088d591ace8503b842d39448c2040f3033John McCall      assert(cast<UnaryOperator>(E)->getOpcode() == UO_AddrOf);
14769c72c6088d591ace8503b842d39448c2040f3033John McCall      E = cast<UnaryOperator>(E)->getSubExpr();
14779c72c6088d591ace8503b842d39448c2040f3033John McCall      OverloadExpr *Ovl = cast<OverloadExpr>(E->IgnoreParens());
14789c72c6088d591ace8503b842d39448c2040f3033John McCall
14799c72c6088d591ace8503b842d39448c2040f3033John McCall      Result.HasFormOfMemberPointer = (E == Ovl && Ovl->getQualifier());
14809c72c6088d591ace8503b842d39448c2040f3033John McCall      Result.IsAddressOfOperand = true;
14819c72c6088d591ace8503b842d39448c2040f3033John McCall      Result.Expression = Ovl;
14829c72c6088d591ace8503b842d39448c2040f3033John McCall    } else {
14839c72c6088d591ace8503b842d39448c2040f3033John McCall      Result.HasFormOfMemberPointer = false;
14849c72c6088d591ace8503b842d39448c2040f3033John McCall      Result.IsAddressOfOperand = false;
14859c72c6088d591ace8503b842d39448c2040f3033John McCall      Result.Expression = cast<OverloadExpr>(E);
14869c72c6088d591ace8503b842d39448c2040f3033John McCall    }
14879c72c6088d591ace8503b842d39448c2040f3033John McCall
14889c72c6088d591ace8503b842d39448c2040f3033John McCall    return Result;
14897bb12da2b0749eeebb21854c77877736969e59f2John McCall  }
14907bb12da2b0749eeebb21854c77877736969e59f2John McCall
1491e9ee23edd17c4bb7f271e67f8790792b4de677fcJohn McCall  /// Gets the naming class of this lookup, if any.
1492e9ee23edd17c4bb7f271e67f8790792b4de677fcJohn McCall  CXXRecordDecl *getNamingClass() const;
1493e9ee23edd17c4bb7f271e67f8790792b4de677fcJohn McCall
14947bb12da2b0749eeebb21854c77877736969e59f2John McCall  typedef UnresolvedSetImpl::iterator decls_iterator;
1495928e6fcf66fc4f342bcf7cc96bf56986c9c2a833Douglas Gregor  decls_iterator decls_begin() const { return UnresolvedSetIterator(Results); }
1496928e6fcf66fc4f342bcf7cc96bf56986c9c2a833Douglas Gregor  decls_iterator decls_end() const {
1497928e6fcf66fc4f342bcf7cc96bf56986c9c2a833Douglas Gregor    return UnresolvedSetIterator(Results + NumResults);
1498928e6fcf66fc4f342bcf7cc96bf56986c9c2a833Douglas Gregor  }
1499a77eb0862507b900a10fa352af1568e639ed10b1Argyrios Kyrtzidis
1500a77eb0862507b900a10fa352af1568e639ed10b1Argyrios Kyrtzidis  void initializeResults(ASTContext &C,
1501a77eb0862507b900a10fa352af1568e639ed10b1Argyrios Kyrtzidis                         UnresolvedSetIterator Begin,UnresolvedSetIterator End);
15027bb12da2b0749eeebb21854c77877736969e59f2John McCall
15037bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// Gets the number of declarations in the unresolved set.
1504928e6fcf66fc4f342bcf7cc96bf56986c9c2a833Douglas Gregor  unsigned getNumDecls() const { return NumResults; }
15057bb12da2b0749eeebb21854c77877736969e59f2John McCall
15062577743c5650c646fb705df01403707e94f2df04Abramo Bagnara  /// Gets the full name info.
15072577743c5650c646fb705df01403707e94f2df04Abramo Bagnara  const DeclarationNameInfo &getNameInfo() const { return NameInfo; }
15082577743c5650c646fb705df01403707e94f2df04Abramo Bagnara  void setNameInfo(const DeclarationNameInfo &N) { NameInfo = N; }
15092577743c5650c646fb705df01403707e94f2df04Abramo Bagnara
15107bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// Gets the name looked up.
15112577743c5650c646fb705df01403707e94f2df04Abramo Bagnara  DeclarationName getName() const { return NameInfo.getName(); }
15122577743c5650c646fb705df01403707e94f2df04Abramo Bagnara  void setName(DeclarationName N) { NameInfo.setName(N); }
15137bb12da2b0749eeebb21854c77877736969e59f2John McCall
15147bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// Gets the location of the name.
15152577743c5650c646fb705df01403707e94f2df04Abramo Bagnara  SourceLocation getNameLoc() const { return NameInfo.getLoc(); }
15162577743c5650c646fb705df01403707e94f2df04Abramo Bagnara  void setNameLoc(SourceLocation Loc) { NameInfo.setLoc(Loc); }
15177bb12da2b0749eeebb21854c77877736969e59f2John McCall
15187bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// Fetches the nested-name qualifier, if one was given.
15197bb12da2b0749eeebb21854c77877736969e59f2John McCall  NestedNameSpecifier *getQualifier() const { return Qualifier; }
1520a77eb0862507b900a10fa352af1568e639ed10b1Argyrios Kyrtzidis  void setQualifier(NestedNameSpecifier *NNS) { Qualifier = NNS; }
15217bb12da2b0749eeebb21854c77877736969e59f2John McCall
15227bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// Fetches the range of the nested-name qualifier.
15237bb12da2b0749eeebb21854c77877736969e59f2John McCall  SourceRange getQualifierRange() const { return QualifierRange; }
1524a77eb0862507b900a10fa352af1568e639ed10b1Argyrios Kyrtzidis  void setQualifierRange(SourceRange R) { QualifierRange = R; }
15257bb12da2b0749eeebb21854c77877736969e59f2John McCall
15267bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// \brief Determines whether this expression had an explicit
15277bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// template argument list, e.g. f<int>.
15287bb12da2b0749eeebb21854c77877736969e59f2John McCall  bool hasExplicitTemplateArgs() const { return HasExplicitTemplateArgs; }
15297bb12da2b0749eeebb21854c77877736969e59f2John McCall
15307bb12da2b0749eeebb21854c77877736969e59f2John McCall  ExplicitTemplateArgumentList &getExplicitTemplateArgs(); // defined far below
15317bb12da2b0749eeebb21854c77877736969e59f2John McCall
15327bb12da2b0749eeebb21854c77877736969e59f2John McCall  const ExplicitTemplateArgumentList &getExplicitTemplateArgs() const {
15337bb12da2b0749eeebb21854c77877736969e59f2John McCall    return const_cast<OverloadExpr*>(this)->getExplicitTemplateArgs();
15347bb12da2b0749eeebb21854c77877736969e59f2John McCall  }
15357bb12da2b0749eeebb21854c77877736969e59f2John McCall
1536096832c5ed5b9106fa177ebc148489760c3bc496John McCall  /// \brief Retrieves the optional explicit template arguments.
1537096832c5ed5b9106fa177ebc148489760c3bc496John McCall  /// This points to the same data as getExplicitTemplateArgs(), but
1538096832c5ed5b9106fa177ebc148489760c3bc496John McCall  /// returns null if there are no explicit template arguments.
1539096832c5ed5b9106fa177ebc148489760c3bc496John McCall  const ExplicitTemplateArgumentList *getOptionalExplicitTemplateArgs() {
1540096832c5ed5b9106fa177ebc148489760c3bc496John McCall    if (!hasExplicitTemplateArgs()) return 0;
1541096832c5ed5b9106fa177ebc148489760c3bc496John McCall    return &getExplicitTemplateArgs();
15427bb12da2b0749eeebb21854c77877736969e59f2John McCall  }
15437bb12da2b0749eeebb21854c77877736969e59f2John McCall
15447bb12da2b0749eeebb21854c77877736969e59f2John McCall  static bool classof(const Stmt *T) {
15457bb12da2b0749eeebb21854c77877736969e59f2John McCall    return T->getStmtClass() == UnresolvedLookupExprClass ||
15467bb12da2b0749eeebb21854c77877736969e59f2John McCall           T->getStmtClass() == UnresolvedMemberExprClass;
15477bb12da2b0749eeebb21854c77877736969e59f2John McCall  }
15487bb12da2b0749eeebb21854c77877736969e59f2John McCall  static bool classof(const OverloadExpr *) { return true; }
15497bb12da2b0749eeebb21854c77877736969e59f2John McCall};
15507bb12da2b0749eeebb21854c77877736969e59f2John McCall
15517bb12da2b0749eeebb21854c77877736969e59f2John McCall/// \brief A reference to a name which we were able to look up during
15527bb12da2b0749eeebb21854c77877736969e59f2John McCall/// parsing but could not resolve to a specific declaration.  This
15537bb12da2b0749eeebb21854c77877736969e59f2John McCall/// arises in several ways:
15547bb12da2b0749eeebb21854c77877736969e59f2John McCall///   * we might be waiting for argument-dependent lookup
15557bb12da2b0749eeebb21854c77877736969e59f2John McCall///   * the name might resolve to an overloaded function
15567bb12da2b0749eeebb21854c77877736969e59f2John McCall/// and eventually:
15577bb12da2b0749eeebb21854c77877736969e59f2John McCall///   * the lookup might have included a function template
15587bb12da2b0749eeebb21854c77877736969e59f2John McCall/// These never include UnresolvedUsingValueDecls, which are always
15597bb12da2b0749eeebb21854c77877736969e59f2John McCall/// class members and therefore appear only in
15607bb12da2b0749eeebb21854c77877736969e59f2John McCall/// UnresolvedMemberLookupExprs.
15617bb12da2b0749eeebb21854c77877736969e59f2John McCallclass UnresolvedLookupExpr : public OverloadExpr {
1562ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  /// True if these lookup results should be extended by
1563ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  /// argument-dependent lookup if this is the operand of a function
1564ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  /// call.
1565ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  bool RequiresADL;
1566ba13543329afac4a0d01304ec2ec4924d99306a6John McCall
15677453ed4cb2cab113de3378df371b1c6f1243d832John McCall  /// True if these lookup results are overloaded.  This is pretty
15687453ed4cb2cab113de3378df371b1c6f1243d832John McCall  /// trivially rederivable if we urgently need to kill this field.
15697453ed4cb2cab113de3378df371b1c6f1243d832John McCall  bool Overloaded;
15707453ed4cb2cab113de3378df371b1c6f1243d832John McCall
15717bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// The naming class (C++ [class.access.base]p5) of the lookup, if
15727bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// any.  This can generally be recalculated from the context chain,
15737bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// but that can be fairly expensive for unqualified lookups.  If we
15747bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// want to improve memory use here, this could go in a union
15757bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// against the qualified-lookup bits.
15767bb12da2b0749eeebb21854c77877736969e59f2John McCall  CXXRecordDecl *NamingClass;
1577f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall
1578928e6fcf66fc4f342bcf7cc96bf56986c9c2a833Douglas Gregor  UnresolvedLookupExpr(ASTContext &C, QualType T, bool Dependent,
1579928e6fcf66fc4f342bcf7cc96bf56986c9c2a833Douglas Gregor                       CXXRecordDecl *NamingClass,
1580ba13543329afac4a0d01304ec2ec4924d99306a6John McCall                       NestedNameSpecifier *Qualifier, SourceRange QRange,
15812577743c5650c646fb705df01403707e94f2df04Abramo Bagnara                       const DeclarationNameInfo &NameInfo,
15825a84dec38cfa9e084377a3167b474c79283c82faDouglas Gregor                       bool RequiresADL, bool Overloaded, bool HasTemplateArgs,
15835a84dec38cfa9e084377a3167b474c79283c82faDouglas Gregor                       UnresolvedSetIterator Begin, UnresolvedSetIterator End)
1584928e6fcf66fc4f342bcf7cc96bf56986c9c2a833Douglas Gregor    : OverloadExpr(UnresolvedLookupExprClass, C, T, Dependent, Qualifier,
15852577743c5650c646fb705df01403707e94f2df04Abramo Bagnara                   QRange, NameInfo, HasTemplateArgs, Begin, End),
15867bb12da2b0749eeebb21854c77877736969e59f2John McCall      RequiresADL(RequiresADL), Overloaded(Overloaded), NamingClass(NamingClass)
1587ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  {}
1588ba13543329afac4a0d01304ec2ec4924d99306a6John McCall
1589bd65bb511c26549c96b829c1282e4c877588564aArgyrios Kyrtzidis  UnresolvedLookupExpr(EmptyShell Empty)
1590bd65bb511c26549c96b829c1282e4c877588564aArgyrios Kyrtzidis    : OverloadExpr(UnresolvedLookupExprClass, Empty),
1591bd65bb511c26549c96b829c1282e4c877588564aArgyrios Kyrtzidis      RequiresADL(false), Overloaded(false), NamingClass(0)
1592bd65bb511c26549c96b829c1282e4c877588564aArgyrios Kyrtzidis  {}
1593bd65bb511c26549c96b829c1282e4c877588564aArgyrios Kyrtzidis
1594ba13543329afac4a0d01304ec2ec4924d99306a6John McCallpublic:
1595ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  static UnresolvedLookupExpr *Create(ASTContext &C,
1596f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall                                      bool Dependent,
1597c373d48502ca7683ab55385f5bd624d778eb288dJohn McCall                                      CXXRecordDecl *NamingClass,
1598ba13543329afac4a0d01304ec2ec4924d99306a6John McCall                                      NestedNameSpecifier *Qualifier,
1599ba13543329afac4a0d01304ec2ec4924d99306a6John McCall                                      SourceRange QualifierRange,
16002577743c5650c646fb705df01403707e94f2df04Abramo Bagnara                                      const DeclarationNameInfo &NameInfo,
16015a84dec38cfa9e084377a3167b474c79283c82faDouglas Gregor                                      bool ADL, bool Overloaded,
16025a84dec38cfa9e084377a3167b474c79283c82faDouglas Gregor                                      UnresolvedSetIterator Begin,
16035a84dec38cfa9e084377a3167b474c79283c82faDouglas Gregor                                      UnresolvedSetIterator End) {
1604928e6fcf66fc4f342bcf7cc96bf56986c9c2a833Douglas Gregor    return new(C) UnresolvedLookupExpr(C,
1605928e6fcf66fc4f342bcf7cc96bf56986c9c2a833Douglas Gregor                                       Dependent ? C.DependentTy : C.OverloadTy,
1606c373d48502ca7683ab55385f5bd624d778eb288dJohn McCall                                       Dependent, NamingClass,
16072577743c5650c646fb705df01403707e94f2df04Abramo Bagnara                                       Qualifier, QualifierRange, NameInfo,
16082577743c5650c646fb705df01403707e94f2df04Abramo Bagnara                                       ADL, Overloaded, false,
16095a84dec38cfa9e084377a3167b474c79283c82faDouglas Gregor                                       Begin, End);
1610ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  }
1611ba13543329afac4a0d01304ec2ec4924d99306a6John McCall
1612f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  static UnresolvedLookupExpr *Create(ASTContext &C,
1613f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall                                      bool Dependent,
1614c373d48502ca7683ab55385f5bd624d778eb288dJohn McCall                                      CXXRecordDecl *NamingClass,
1615f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall                                      NestedNameSpecifier *Qualifier,
1616f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall                                      SourceRange QualifierRange,
16172577743c5650c646fb705df01403707e94f2df04Abramo Bagnara                                      const DeclarationNameInfo &NameInfo,
1618f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall                                      bool ADL,
16195a84dec38cfa9e084377a3167b474c79283c82faDouglas Gregor                                      const TemplateArgumentListInfo &Args,
16205a84dec38cfa9e084377a3167b474c79283c82faDouglas Gregor                                      UnresolvedSetIterator Begin,
16215a84dec38cfa9e084377a3167b474c79283c82faDouglas Gregor                                      UnresolvedSetIterator End);
1622f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall
1623bd65bb511c26549c96b829c1282e4c877588564aArgyrios Kyrtzidis  static UnresolvedLookupExpr *CreateEmpty(ASTContext &C,
1624bd65bb511c26549c96b829c1282e4c877588564aArgyrios Kyrtzidis                                           unsigned NumTemplateArgs);
1625bd65bb511c26549c96b829c1282e4c877588564aArgyrios Kyrtzidis
1626ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  /// True if this declaration should be extended by
1627ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  /// argument-dependent lookup.
1628ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  bool requiresADL() const { return RequiresADL; }
1629bd65bb511c26549c96b829c1282e4c877588564aArgyrios Kyrtzidis  void setRequiresADL(bool V) { RequiresADL = V; }
1630ba13543329afac4a0d01304ec2ec4924d99306a6John McCall
16317453ed4cb2cab113de3378df371b1c6f1243d832John McCall  /// True if this lookup is overloaded.
16327453ed4cb2cab113de3378df371b1c6f1243d832John McCall  bool isOverloaded() const { return Overloaded; }
1633bd65bb511c26549c96b829c1282e4c877588564aArgyrios Kyrtzidis  void setOverloaded(bool V) { Overloaded = V; }
16347453ed4cb2cab113de3378df371b1c6f1243d832John McCall
1635c373d48502ca7683ab55385f5bd624d778eb288dJohn McCall  /// Gets the 'naming class' (in the sense of C++0x
1636c373d48502ca7683ab55385f5bd624d778eb288dJohn McCall  /// [class.access.base]p5) of the lookup.  This is the scope
1637c373d48502ca7683ab55385f5bd624d778eb288dJohn McCall  /// that was looked in to find these results.
1638c373d48502ca7683ab55385f5bd624d778eb288dJohn McCall  CXXRecordDecl *getNamingClass() const { return NamingClass; }
1639bd65bb511c26549c96b829c1282e4c877588564aArgyrios Kyrtzidis  void setNamingClass(CXXRecordDecl *D) { NamingClass = D; }
1640c373d48502ca7683ab55385f5bd624d778eb288dJohn McCall
1641f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  // Note that, inconsistently with the explicit-template-argument AST
1642f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  // nodes, users are *forbidden* from calling these methods on objects
1643f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  // without explicit template arguments.
1644f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall
16457bb12da2b0749eeebb21854c77877736969e59f2John McCall  ExplicitTemplateArgumentList &getExplicitTemplateArgs() {
16467bb12da2b0749eeebb21854c77877736969e59f2John McCall    assert(hasExplicitTemplateArgs());
16477bb12da2b0749eeebb21854c77877736969e59f2John McCall    return *reinterpret_cast<ExplicitTemplateArgumentList*>(this + 1);
16487bb12da2b0749eeebb21854c77877736969e59f2John McCall  }
16497bb12da2b0749eeebb21854c77877736969e59f2John McCall
1650f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  /// Gets a reference to the explicit template argument list.
1651f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  const ExplicitTemplateArgumentList &getExplicitTemplateArgs() const {
1652f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall    assert(hasExplicitTemplateArgs());
1653f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall    return *reinterpret_cast<const ExplicitTemplateArgumentList*>(this + 1);
1654f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  }
1655f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall
1656096832c5ed5b9106fa177ebc148489760c3bc496John McCall  /// \brief Retrieves the optional explicit template arguments.
1657096832c5ed5b9106fa177ebc148489760c3bc496John McCall  /// This points to the same data as getExplicitTemplateArgs(), but
1658096832c5ed5b9106fa177ebc148489760c3bc496John McCall  /// returns null if there are no explicit template arguments.
1659096832c5ed5b9106fa177ebc148489760c3bc496John McCall  const ExplicitTemplateArgumentList *getOptionalExplicitTemplateArgs() {
1660096832c5ed5b9106fa177ebc148489760c3bc496John McCall    if (!hasExplicitTemplateArgs()) return 0;
1661096832c5ed5b9106fa177ebc148489760c3bc496John McCall    return &getExplicitTemplateArgs();
1662096832c5ed5b9106fa177ebc148489760c3bc496John McCall  }
1663096832c5ed5b9106fa177ebc148489760c3bc496John McCall
1664f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  /// \brief Copies the template arguments (if present) into the given
1665f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  /// structure.
1666f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  void copyTemplateArgumentsInto(TemplateArgumentListInfo &List) const {
1667f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall    getExplicitTemplateArgs().copyInto(List);
1668f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  }
1669ba13543329afac4a0d01304ec2ec4924d99306a6John McCall
1670f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  SourceLocation getLAngleLoc() const {
1671f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall    return getExplicitTemplateArgs().LAngleLoc;
1672f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  }
1673f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall
1674f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  SourceLocation getRAngleLoc() const {
1675f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall    return getExplicitTemplateArgs().RAngleLoc;
1676f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  }
1677f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall
1678f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  TemplateArgumentLoc const *getTemplateArgs() const {
1679f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall    return getExplicitTemplateArgs().getTemplateArgs();
1680f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  }
1681f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall
1682f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  unsigned getNumTemplateArgs() const {
1683f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall    return getExplicitTemplateArgs().NumTemplateArgs;
1684f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  }
1685ba13543329afac4a0d01304ec2ec4924d99306a6John McCall
1686ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  virtual SourceRange getSourceRange() const {
16872577743c5650c646fb705df01403707e94f2df04Abramo Bagnara    SourceRange Range(getNameInfo().getSourceRange());
16887bb12da2b0749eeebb21854c77877736969e59f2John McCall    if (getQualifier()) Range.setBegin(getQualifierRange().getBegin());
1689f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall    if (hasExplicitTemplateArgs()) Range.setEnd(getRAngleLoc());
1690f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall    return Range;
1691ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  }
1692ba13543329afac4a0d01304ec2ec4924d99306a6John McCall
1693ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  virtual StmtIterator child_begin();
1694ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  virtual StmtIterator child_end();
1695ba13543329afac4a0d01304ec2ec4924d99306a6John McCall
1696ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  static bool classof(const Stmt *T) {
1697ba13543329afac4a0d01304ec2ec4924d99306a6John McCall    return T->getStmtClass() == UnresolvedLookupExprClass;
1698ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  }
1699ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  static bool classof(const UnresolvedLookupExpr *) { return true; }
1700ba13543329afac4a0d01304ec2ec4924d99306a6John McCall};
1701ba13543329afac4a0d01304ec2ec4924d99306a6John McCall
17025953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor/// \brief A qualified reference to a name whose declaration cannot
17035953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor/// yet be resolved.
17045953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor///
1705ba13543329afac4a0d01304ec2ec4924d99306a6John McCall/// DependentScopeDeclRefExpr is similar to DeclRefExpr in that
1706a2813cec2605ce7878d1b13471d685f689b251afDouglas Gregor/// it expresses a reference to a declaration such as
17075953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor/// X<T>::value. The difference, however, is that an
1708865d447ac6a4721ab58e898d014a21f2eff74b06John McCall/// DependentScopeDeclRefExpr node is used only within C++ templates when
17095953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor/// the qualification (e.g., X<T>::) refers to a dependent type. In
17105953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor/// this case, X<T>::value cannot resolve to a declaration because the
17115953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor/// declaration will differ from on instantiation of X<T> to the
1712865d447ac6a4721ab58e898d014a21f2eff74b06John McCall/// next. Therefore, DependentScopeDeclRefExpr keeps track of the
1713ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor/// qualifier (X<T>::) and the name of the entity being referenced
1714a2813cec2605ce7878d1b13471d685f689b251afDouglas Gregor/// ("value"). Such expressions will instantiate to a DeclRefExpr once the
1715a2813cec2605ce7878d1b13471d685f689b251afDouglas Gregor/// declaration can be found.
1716865d447ac6a4721ab58e898d014a21f2eff74b06John McCallclass DependentScopeDeclRefExpr : public Expr {
17175953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor  /// The name of the entity we will be referencing.
17182577743c5650c646fb705df01403707e94f2df04Abramo Bagnara  DeclarationNameInfo NameInfo;
17195953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor
17205953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor  /// QualifierRange - The source range that covers the
17215953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor  /// nested-name-specifier.
17225953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor  SourceRange QualifierRange;
17235953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor
1724ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor  /// \brief The nested-name-specifier that qualifies this unresolved
1725ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor  /// declaration name.
1726f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  NestedNameSpecifier *Qualifier;
17275953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor
1728f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  /// \brief Whether the name includes explicit template arguments.
1729f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  bool HasExplicitTemplateArgs;
17301eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1731f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  DependentScopeDeclRefExpr(QualType T,
1732f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall                            NestedNameSpecifier *Qualifier,
1733f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall                            SourceRange QualifierRange,
17342577743c5650c646fb705df01403707e94f2df04Abramo Bagnara                            const DeclarationNameInfo &NameInfo,
1735f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall                            bool HasExplicitTemplateArgs)
1736865d447ac6a4721ab58e898d014a21f2eff74b06John McCall    : Expr(DependentScopeDeclRefExprClass, T, true, true),
17372577743c5650c646fb705df01403707e94f2df04Abramo Bagnara      NameInfo(NameInfo), QualifierRange(QualifierRange), Qualifier(Qualifier),
1738f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall      HasExplicitTemplateArgs(HasExplicitTemplateArgs)
1739f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  {}
1740f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall
1741f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCallpublic:
1742f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  static DependentScopeDeclRefExpr *Create(ASTContext &C,
1743f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall                                           NestedNameSpecifier *Qualifier,
1744f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall                                           SourceRange QualifierRange,
17452577743c5650c646fb705df01403707e94f2df04Abramo Bagnara                                           const DeclarationNameInfo &NameInfo,
1746f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall                              const TemplateArgumentListInfo *TemplateArgs = 0);
17475953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor
174812dffcddb60380c5bed4f085a1f51534afda3b87Argyrios Kyrtzidis  static DependentScopeDeclRefExpr *CreateEmpty(ASTContext &C,
174912dffcddb60380c5bed4f085a1f51534afda3b87Argyrios Kyrtzidis                                                unsigned NumTemplateArgs);
175012dffcddb60380c5bed4f085a1f51534afda3b87Argyrios Kyrtzidis
17515953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor  /// \brief Retrieve the name that this expression refers to.
17522577743c5650c646fb705df01403707e94f2df04Abramo Bagnara  const DeclarationNameInfo &getNameInfo() const { return NameInfo; }
17532577743c5650c646fb705df01403707e94f2df04Abramo Bagnara  void setNameInfo(const DeclarationNameInfo &N) { NameInfo =  N; }
17542577743c5650c646fb705df01403707e94f2df04Abramo Bagnara
17552577743c5650c646fb705df01403707e94f2df04Abramo Bagnara  /// \brief Retrieve the name that this expression refers to.
17562577743c5650c646fb705df01403707e94f2df04Abramo Bagnara  DeclarationName getDeclName() const { return NameInfo.getName(); }
17572577743c5650c646fb705df01403707e94f2df04Abramo Bagnara  void setDeclName(DeclarationName N) { NameInfo.setName(N); }
17585953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor
17595953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor  /// \brief Retrieve the location of the name within the expression.
17602577743c5650c646fb705df01403707e94f2df04Abramo Bagnara  SourceLocation getLocation() const { return NameInfo.getLoc(); }
17612577743c5650c646fb705df01403707e94f2df04Abramo Bagnara  void setLocation(SourceLocation L) { NameInfo.setLoc(L); }
17625953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor
17635953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor  /// \brief Retrieve the source range of the nested-name-specifier.
17645953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor  SourceRange getQualifierRange() const { return QualifierRange; }
176512dffcddb60380c5bed4f085a1f51534afda3b87Argyrios Kyrtzidis  void setQualifierRange(SourceRange R) { QualifierRange = R; }
17665953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor
1767ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor  /// \brief Retrieve the nested-name-specifier that qualifies this
1768ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor  /// declaration.
1769edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor  NestedNameSpecifier *getQualifier() const { return Qualifier; }
177012dffcddb60380c5bed4f085a1f51534afda3b87Argyrios Kyrtzidis  void setQualifier(NestedNameSpecifier *NNS) { Qualifier = NNS; }
17711eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1772f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  /// Determines whether this lookup had explicit template arguments.
1773f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  bool hasExplicitTemplateArgs() const { return HasExplicitTemplateArgs; }
17741eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1775f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  // Note that, inconsistently with the explicit-template-argument AST
1776f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  // nodes, users are *forbidden* from calling these methods on objects
1777f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  // without explicit template arguments.
17781eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
177912dffcddb60380c5bed4f085a1f51534afda3b87Argyrios Kyrtzidis  ExplicitTemplateArgumentList &getExplicitTemplateArgs() {
178012dffcddb60380c5bed4f085a1f51534afda3b87Argyrios Kyrtzidis    assert(hasExplicitTemplateArgs());
178112dffcddb60380c5bed4f085a1f51534afda3b87Argyrios Kyrtzidis    return *reinterpret_cast<ExplicitTemplateArgumentList*>(this + 1);
178212dffcddb60380c5bed4f085a1f51534afda3b87Argyrios Kyrtzidis  }
178312dffcddb60380c5bed4f085a1f51534afda3b87Argyrios Kyrtzidis
1784f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  /// Gets a reference to the explicit template argument list.
1785f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  const ExplicitTemplateArgumentList &getExplicitTemplateArgs() const {
1786f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall    assert(hasExplicitTemplateArgs());
1787f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall    return *reinterpret_cast<const ExplicitTemplateArgumentList*>(this + 1);
1788f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  }
17891eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1790096832c5ed5b9106fa177ebc148489760c3bc496John McCall  /// \brief Retrieves the optional explicit template arguments.
1791096832c5ed5b9106fa177ebc148489760c3bc496John McCall  /// This points to the same data as getExplicitTemplateArgs(), but
1792096832c5ed5b9106fa177ebc148489760c3bc496John McCall  /// returns null if there are no explicit template arguments.
1793096832c5ed5b9106fa177ebc148489760c3bc496John McCall  const ExplicitTemplateArgumentList *getOptionalExplicitTemplateArgs() {
1794096832c5ed5b9106fa177ebc148489760c3bc496John McCall    if (!hasExplicitTemplateArgs()) return 0;
1795096832c5ed5b9106fa177ebc148489760c3bc496John McCall    return &getExplicitTemplateArgs();
1796096832c5ed5b9106fa177ebc148489760c3bc496John McCall  }
1797096832c5ed5b9106fa177ebc148489760c3bc496John McCall
1798f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  /// \brief Copies the template arguments (if present) into the given
1799f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  /// structure.
1800f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  void copyTemplateArgumentsInto(TemplateArgumentListInfo &List) const {
1801f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall    getExplicitTemplateArgs().copyInto(List);
1802f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  }
1803f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall
1804f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  SourceLocation getLAngleLoc() const {
1805f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall    return getExplicitTemplateArgs().LAngleLoc;
1806edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor  }
18071eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1808f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  SourceLocation getRAngleLoc() const {
1809f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall    return getExplicitTemplateArgs().RAngleLoc;
1810f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  }
18111eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1812f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  TemplateArgumentLoc const *getTemplateArgs() const {
1813f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall    return getExplicitTemplateArgs().getTemplateArgs();
1814d5532b6cfff2977e0c59fa6ead7f7973984a620dJohn McCall  }
1815d5532b6cfff2977e0c59fa6ead7f7973984a620dJohn McCall
1816f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  unsigned getNumTemplateArgs() const {
1817f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall    return getExplicitTemplateArgs().NumTemplateArgs;
1818f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  }
18191eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1820edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor  virtual SourceRange getSourceRange() const {
1821f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall    SourceRange Range(QualifierRange.getBegin(), getLocation());
1822f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall    if (hasExplicitTemplateArgs())
1823f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall      Range.setEnd(getRAngleLoc());
1824f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall    return Range;
1825edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor  }
18261eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
18271eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  static bool classof(const Stmt *T) {
1828f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall    return T->getStmtClass() == DependentScopeDeclRefExprClass;
1829edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor  }
1830f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  static bool classof(const DependentScopeDeclRefExpr *) { return true; }
1831f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall
1832f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  virtual StmtIterator child_begin();
1833f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  virtual StmtIterator child_end();
1834edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor};
18351eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
18362d44e8a41de8a33c0f04ac198714f71dc841bab0Anders Carlssonclass CXXExprWithTemporaries : public Expr {
183702bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson  Stmt *SubExpr;
18381eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1839ff6b3d64c9f07155f1414411b8451d7bf8937c62Anders Carlsson  CXXTemporary **Temps;
1840ff6b3d64c9f07155f1414411b8451d7bf8937c62Anders Carlsson  unsigned NumTemps;
184102bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson
1842d04ed416be7c55bddddab1fa3fd38a0113a6b3daTed Kremenek  CXXExprWithTemporaries(ASTContext &C, Expr *SubExpr, CXXTemporary **Temps,
18430ece491d8f62ce67f047491a6703fac0d3bd4ff4Anders Carlsson                         unsigned NumTemps);
184442602bb40aefcc2751d4078ba88aacf4d965c9bdDouglas Gregor
184588eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlssonpublic:
1846d2598368876cfe40bc8465540033bc5b5e58d8afChris Lattner  CXXExprWithTemporaries(EmptyShell Empty)
1847d2598368876cfe40bc8465540033bc5b5e58d8afChris Lattner    : Expr(CXXExprWithTemporariesClass, Empty),
1848d2598368876cfe40bc8465540033bc5b5e58d8afChris Lattner      SubExpr(0), Temps(0), NumTemps(0) {}
1849d2598368876cfe40bc8465540033bc5b5e58d8afChris Lattner
185088eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlsson  static CXXExprWithTemporaries *Create(ASTContext &C, Expr *SubExpr,
18510ece491d8f62ce67f047491a6703fac0d3bd4ff4Anders Carlsson                                        CXXTemporary **Temps,
18520ece491d8f62ce67f047491a6703fac0d3bd4ff4Anders Carlsson                                        unsigned NumTemps);
18531eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
185488eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlsson  unsigned getNumTemporaries() const { return NumTemps; }
1855d04ed416be7c55bddddab1fa3fd38a0113a6b3daTed Kremenek  void setNumTemporaries(ASTContext &C, unsigned N);
1856d2598368876cfe40bc8465540033bc5b5e58d8afChris Lattner
185788eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlsson  CXXTemporary *getTemporary(unsigned i) {
185888eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlsson    assert(i < NumTemps && "Index out of range");
185988eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlsson    return Temps[i];
186088eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlsson  }
1861f0721fe438d7e40c168e5d664970e7830bc138fbAnders Carlsson  const CXXTemporary *getTemporary(unsigned i) const {
18620ece491d8f62ce67f047491a6703fac0d3bd4ff4Anders Carlsson    return const_cast<CXXExprWithTemporaries*>(this)->getTemporary(i);
1863f0721fe438d7e40c168e5d664970e7830bc138fbAnders Carlsson  }
1864d2598368876cfe40bc8465540033bc5b5e58d8afChris Lattner  void setTemporary(unsigned i, CXXTemporary *T) {
1865d2598368876cfe40bc8465540033bc5b5e58d8afChris Lattner    assert(i < NumTemps && "Index out of range");
1866d2598368876cfe40bc8465540033bc5b5e58d8afChris Lattner    Temps[i] = T;
1867d2598368876cfe40bc8465540033bc5b5e58d8afChris Lattner  }
18681eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
186902bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson  Expr *getSubExpr() { return cast<Expr>(SubExpr); }
1870f0721fe438d7e40c168e5d664970e7830bc138fbAnders Carlsson  const Expr *getSubExpr() const { return cast<Expr>(SubExpr); }
187188eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlsson  void setSubExpr(Expr *E) { SubExpr = E; }
187202bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson
187396be6917e1c4ba1f4435a14c9e7c6c139571d086Douglas Gregor  virtual SourceRange getSourceRange() const {
187496be6917e1c4ba1f4435a14c9e7c6c139571d086Douglas Gregor    return SubExpr->getSourceRange();
187596be6917e1c4ba1f4435a14c9e7c6c139571d086Douglas Gregor  }
187602bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson
187702bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson  // Implement isa/cast/dyncast/etc.
187802bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson  static bool classof(const Stmt *T) {
18792d44e8a41de8a33c0f04ac198714f71dc841bab0Anders Carlsson    return T->getStmtClass() == CXXExprWithTemporariesClass;
188002bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson  }
18812d44e8a41de8a33c0f04ac198714f71dc841bab0Anders Carlsson  static bool classof(const CXXExprWithTemporaries *) { return true; }
188202bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson
188302bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson  // Iterators
188402bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson  virtual child_iterator child_begin();
188502bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson  virtual child_iterator child_end();
188602bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson};
188702bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson
1888d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// \brief Describes an explicit type conversion that uses functional
1889d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// notion but could not be resolved because one or more arguments are
1890d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// type-dependent.
1891d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor///
1892d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// The explicit type conversions expressed by
1893d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// CXXUnresolvedConstructExpr have the form \c T(a1, a2, ..., aN),
1894d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// where \c T is some type and \c a1, a2, ..., aN are values, and
1895d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// either \C T is a dependent type or one or more of the \c a's is
1896d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// type-dependent. For example, this would occur in a template such
1897d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// as:
1898d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor///
1899d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// \code
1900d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor///   template<typename T, typename A1>
1901d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor///   inline T make_a(const A1& a1) {
1902d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor///     return T(a1);
1903d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor///   }
1904d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// \endcode
1905d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor///
1906d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// When the returned expression is instantiated, it may resolve to a
1907d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// constructor call, conversion function call, or some kind of type
1908d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// conversion.
1909d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregorclass CXXUnresolvedConstructExpr : public Expr {
1910d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  /// \brief The type being constructed.
1911ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor  TypeSourceInfo *Type;
1912ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor
1913d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  /// \brief The location of the left parentheses ('(').
1914d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  SourceLocation LParenLoc;
1915d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor
1916d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  /// \brief The location of the right parentheses (')').
1917d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  SourceLocation RParenLoc;
1918d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor
1919d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  /// \brief The number of arguments used to construct the type.
1920d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  unsigned NumArgs;
19211eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1922ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor  CXXUnresolvedConstructExpr(TypeSourceInfo *Type,
1923d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor                             SourceLocation LParenLoc,
1924d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor                             Expr **Args,
1925d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor                             unsigned NumArgs,
1926d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor                             SourceLocation RParenLoc);
1927d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor
19288dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis  CXXUnresolvedConstructExpr(EmptyShell Empty, unsigned NumArgs)
1929ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor    : Expr(CXXUnresolvedConstructExprClass, Empty), Type(), NumArgs(NumArgs) { }
19308dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis
1931ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor  friend class ASTStmtReader;
1932ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor
1933d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregorpublic:
19341eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  static CXXUnresolvedConstructExpr *Create(ASTContext &C,
1935ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor                                            TypeSourceInfo *Type,
1936d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor                                            SourceLocation LParenLoc,
1937d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor                                            Expr **Args,
1938d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor                                            unsigned NumArgs,
1939d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor                                            SourceLocation RParenLoc);
1940d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor
19418dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis  static CXXUnresolvedConstructExpr *CreateEmpty(ASTContext &C,
19428dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis                                                 unsigned NumArgs);
19438dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis
1944d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  /// \brief Retrieve the type that is being constructed, as specified
1945d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  /// in the source code.
1946ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor  QualType getTypeAsWritten() const { return Type->getType(); }
1947d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor
1948ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor  /// \brief Retrieve the type source information for the type being
1949ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor  /// constructed.
1950ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor  TypeSourceInfo *getTypeSourceInfo() const { return Type; }
1951ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor
1952d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  /// \brief Retrieve the location of the left parentheses ('(') that
1953d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  /// precedes the argument list.
1954d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  SourceLocation getLParenLoc() const { return LParenLoc; }
1955d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  void setLParenLoc(SourceLocation L) { LParenLoc = L; }
1956d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor
1957d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  /// \brief Retrieve the location of the right parentheses (')') that
1958d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  /// follows the argument list.
1959d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  SourceLocation getRParenLoc() const { return RParenLoc; }
1960d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  void setRParenLoc(SourceLocation L) { RParenLoc = L; }
1961d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor
1962d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  /// \brief Retrieve the number of arguments.
1963d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  unsigned arg_size() const { return NumArgs; }
1964d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor
1965d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  typedef Expr** arg_iterator;
1966d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  arg_iterator arg_begin() { return reinterpret_cast<Expr**>(this + 1); }
1967d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  arg_iterator arg_end() { return arg_begin() + NumArgs; }
1968d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor
19691dd7383dc48718c452e71a625b29531dd96fbb9dJohn McCall  typedef const Expr* const * const_arg_iterator;
19701dd7383dc48718c452e71a625b29531dd96fbb9dJohn McCall  const_arg_iterator arg_begin() const {
19711dd7383dc48718c452e71a625b29531dd96fbb9dJohn McCall    return reinterpret_cast<const Expr* const *>(this + 1);
19721dd7383dc48718c452e71a625b29531dd96fbb9dJohn McCall  }
19731dd7383dc48718c452e71a625b29531dd96fbb9dJohn McCall  const_arg_iterator arg_end() const {
19741dd7383dc48718c452e71a625b29531dd96fbb9dJohn McCall    return arg_begin() + NumArgs;
19751dd7383dc48718c452e71a625b29531dd96fbb9dJohn McCall  }
19761dd7383dc48718c452e71a625b29531dd96fbb9dJohn McCall
1977d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  Expr *getArg(unsigned I) {
1978d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor    assert(I < NumArgs && "Argument index out-of-range");
1979d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor    return *(arg_begin() + I);
1980d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  }
1981d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor
19821dd7383dc48718c452e71a625b29531dd96fbb9dJohn McCall  const Expr *getArg(unsigned I) const {
19831dd7383dc48718c452e71a625b29531dd96fbb9dJohn McCall    assert(I < NumArgs && "Argument index out-of-range");
19841dd7383dc48718c452e71a625b29531dd96fbb9dJohn McCall    return *(arg_begin() + I);
19851dd7383dc48718c452e71a625b29531dd96fbb9dJohn McCall  }
19861dd7383dc48718c452e71a625b29531dd96fbb9dJohn McCall
19878dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis  void setArg(unsigned I, Expr *E) {
19888dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis    assert(I < NumArgs && "Argument index out-of-range");
19898dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis    *(arg_begin() + I) = E;
19908dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis  }
19918dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis
1992ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor  virtual SourceRange getSourceRange() const;
1993ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor
19941eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  static bool classof(const Stmt *T) {
1995d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor    return T->getStmtClass() == CXXUnresolvedConstructExprClass;
1996d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  }
1997d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  static bool classof(const CXXUnresolvedConstructExpr *) { return true; }
1998d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor
1999d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  // Iterators
2000d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  virtual child_iterator child_begin();
2001d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  virtual child_iterator child_end();
2002d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor};
2003d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor
2004ba13543329afac4a0d01304ec2ec4924d99306a6John McCall/// \brief Represents a C++ member access expression where the actual
2005ba13543329afac4a0d01304ec2ec4924d99306a6John McCall/// member referenced could not be resolved because the base
2006ba13543329afac4a0d01304ec2ec4924d99306a6John McCall/// expression or the member name was dependent.
2007aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall///
2008aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall/// Like UnresolvedMemberExprs, these can be either implicit or
2009aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall/// explicit accesses.  It is only possible to get one of these with
2010aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall/// an implicit access if a qualifier is provided.
2011865d447ac6a4721ab58e898d014a21f2eff74b06John McCallclass CXXDependentScopeMemberExpr : public Expr {
20121c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  /// \brief The expression for the base pointer or class reference,
2013aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall  /// e.g., the \c x in x.f.  Can be null in implicit accesses.
20141c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  Stmt *Base;
20151eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
2016aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall  /// \brief The type of the base expression.  Never null, even for
2017aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall  /// implicit accesses.
2018aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall  QualType BaseType;
2019aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall
20201c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  /// \brief Whether this member expression used the '->' operator or
20211c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  /// the '.' operator.
20223b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor  bool IsArrow : 1;
20231c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor
20243b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor  /// \brief Whether this member expression has explicitly-specified template
20253b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor  /// arguments.
2026aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall  bool HasExplicitTemplateArgs : 1;
20271eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
20281c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  /// \brief The location of the '->' or '.' operator.
20291c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  SourceLocation OperatorLoc;
20301c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor
2031a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor  /// \brief The nested-name-specifier that precedes the member name, if any.
2032a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor  NestedNameSpecifier *Qualifier;
20331eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
2034a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor  /// \brief The source range covering the nested name specifier.
2035a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor  SourceRange QualifierRange;
20361eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
2037c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor  /// \brief In a qualified member access expression such as t->Base::f, this
20381eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  /// member stores the resolves of name lookup in the context of the member
2039c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor  /// access expression, to be used at instantiation time.
2040c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor  ///
2041c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor  /// FIXME: This member, along with the Qualifier and QualifierRange, could
2042c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor  /// be stuck into a structure that is optionally allocated at the end of
2043865d447ac6a4721ab58e898d014a21f2eff74b06John McCall  /// the CXXDependentScopeMemberExpr, to save space in the common case.
2044c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor  NamedDecl *FirstQualifierFoundInScope;
20451eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
20461c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  /// \brief The member to which this member expression refers, which
20471c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  /// can be name, overloaded operator, or destructor.
2048a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor  /// FIXME: could also be a template-id
20492577743c5650c646fb705df01403707e94f2df04Abramo Bagnara  DeclarationNameInfo MemberNameInfo;
20501eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
2051865d447ac6a4721ab58e898d014a21f2eff74b06John McCall  CXXDependentScopeMemberExpr(ASTContext &C,
2052aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall                          Expr *Base, QualType BaseType, bool IsArrow,
20533b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor                          SourceLocation OperatorLoc,
20543b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor                          NestedNameSpecifier *Qualifier,
20553b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor                          SourceRange QualifierRange,
20563b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor                          NamedDecl *FirstQualifierFoundInScope,
20572577743c5650c646fb705df01403707e94f2df04Abramo Bagnara                          DeclarationNameInfo MemberNameInfo,
2058d5532b6cfff2977e0c59fa6ead7f7973984a620dJohn McCall                          const TemplateArgumentListInfo *TemplateArgs);
20591eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
20601c0ca59416999129d0439c2661d137ef38e86209Douglas Gregorpublic:
2061865d447ac6a4721ab58e898d014a21f2eff74b06John McCall  CXXDependentScopeMemberExpr(ASTContext &C,
2062aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall                          Expr *Base, QualType BaseType,
2063aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall                          bool IsArrow,
20641c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor                          SourceLocation OperatorLoc,
2065a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor                          NestedNameSpecifier *Qualifier,
2066a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor                          SourceRange QualifierRange,
2067c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor                          NamedDecl *FirstQualifierFoundInScope,
20682577743c5650c646fb705df01403707e94f2df04Abramo Bagnara                          DeclarationNameInfo MemberNameInfo)
2069865d447ac6a4721ab58e898d014a21f2eff74b06John McCall  : Expr(CXXDependentScopeMemberExprClass, C.DependentTy, true, true),
2070aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall    Base(Base), BaseType(BaseType), IsArrow(IsArrow),
2071aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall    HasExplicitTemplateArgs(false), OperatorLoc(OperatorLoc),
20723b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor    Qualifier(Qualifier), QualifierRange(QualifierRange),
20733b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor    FirstQualifierFoundInScope(FirstQualifierFoundInScope),
20742577743c5650c646fb705df01403707e94f2df04Abramo Bagnara    MemberNameInfo(MemberNameInfo) { }
20751eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
2076865d447ac6a4721ab58e898d014a21f2eff74b06John McCall  static CXXDependentScopeMemberExpr *
20771eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  Create(ASTContext &C,
2078aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall         Expr *Base, QualType BaseType, bool IsArrow,
20793b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor         SourceLocation OperatorLoc,
20803b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor         NestedNameSpecifier *Qualifier,
20813b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor         SourceRange QualifierRange,
20823b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor         NamedDecl *FirstQualifierFoundInScope,
20832577743c5650c646fb705df01403707e94f2df04Abramo Bagnara         DeclarationNameInfo MemberNameInfo,
2084d5532b6cfff2977e0c59fa6ead7f7973984a620dJohn McCall         const TemplateArgumentListInfo *TemplateArgs);
20851eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
20868dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis  static CXXDependentScopeMemberExpr *
20878dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis  CreateEmpty(ASTContext &C, unsigned NumTemplateArgs);
20888dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis
2089aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall  /// \brief True if this is an implicit access, i.e. one in which the
2090aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall  /// member being accessed was not written in the source.  The source
2091aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall  /// location of the operator is invalid in this case.
2092aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall  bool isImplicitAccess() const { return Base == 0; }
2093aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall
20941c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  /// \brief Retrieve the base object of this member expressions,
20951c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  /// e.g., the \c x in \c x.m.
2096aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall  Expr *getBase() const {
2097aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall    assert(!isImplicitAccess());
2098aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall    return cast<Expr>(Base);
2099aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall  }
21001c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  void setBase(Expr *E) { Base = E; }
21011c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor
2102aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall  QualType getBaseType() const { return BaseType; }
21038dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis  void setBaseType(QualType T) { BaseType = T; }
2104aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall
21051c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  /// \brief Determine whether this member expression used the '->'
21061c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  /// operator; otherwise, it used the '.' operator.
21071c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  bool isArrow() const { return IsArrow; }
21081c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  void setArrow(bool A) { IsArrow = A; }
21091c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor
21101c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  /// \brief Retrieve the location of the '->' or '.' operator.
21111c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  SourceLocation getOperatorLoc() const { return OperatorLoc; }
21121c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  void setOperatorLoc(SourceLocation L) { OperatorLoc = L; }
21131c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor
2114a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor  /// \brief Retrieve the nested-name-specifier that qualifies the member
2115a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor  /// name.
2116a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor  NestedNameSpecifier *getQualifier() const { return Qualifier; }
21178dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis  void setQualifier(NestedNameSpecifier *NNS) { Qualifier = NNS; }
21181eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
2119a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor  /// \brief Retrieve the source range covering the nested-name-specifier
2120a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor  /// that qualifies the member name.
2121a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor  SourceRange getQualifierRange() const { return QualifierRange; }
21228dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis  void setQualifierRange(SourceRange R) { QualifierRange = R; }
21231eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
2124c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor  /// \brief Retrieve the first part of the nested-name-specifier that was
2125c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor  /// found in the scope of the member access expression when the member access
2126c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor  /// was initially parsed.
2127c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor  ///
2128c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor  /// This function only returns a useful result when member access expression
21291eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  /// uses a qualified member name, e.g., "x.Base::f". Here, the declaration
21301eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  /// returned by this function describes what was found by unqualified name
2131c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor  /// lookup for the identifier "Base" within the scope of the member access
2132c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor  /// expression itself. At template instantiation time, this information is
2133c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor  /// combined with the results of name lookup into the type of the object
2134c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor  /// expression itself (the class type of x).
21351eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  NamedDecl *getFirstQualifierFoundInScope() const {
2136c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor    return FirstQualifierFoundInScope;
2137c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor  }
21388dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis  void setFirstQualifierFoundInScope(NamedDecl *D) {
21398dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis    FirstQualifierFoundInScope = D;
21408dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis  }
21411eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
21421c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  /// \brief Retrieve the name of the member that this expression
21431c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  /// refers to.
21442577743c5650c646fb705df01403707e94f2df04Abramo Bagnara  const DeclarationNameInfo &getMemberNameInfo() const {
21452577743c5650c646fb705df01403707e94f2df04Abramo Bagnara    return MemberNameInfo;
21462577743c5650c646fb705df01403707e94f2df04Abramo Bagnara  }
21472577743c5650c646fb705df01403707e94f2df04Abramo Bagnara  void setMemberNameInfo(const DeclarationNameInfo &N) { MemberNameInfo = N; }
21482577743c5650c646fb705df01403707e94f2df04Abramo Bagnara
21492577743c5650c646fb705df01403707e94f2df04Abramo Bagnara  /// \brief Retrieve the name of the member that this expression
21502577743c5650c646fb705df01403707e94f2df04Abramo Bagnara  /// refers to.
21512577743c5650c646fb705df01403707e94f2df04Abramo Bagnara  DeclarationName getMember() const { return MemberNameInfo.getName(); }
21522577743c5650c646fb705df01403707e94f2df04Abramo Bagnara  void setMember(DeclarationName N) { MemberNameInfo.setName(N); }
21531c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor
21541c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  // \brief Retrieve the location of the name of the member that this
21551c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  // expression refers to.
21562577743c5650c646fb705df01403707e94f2df04Abramo Bagnara  SourceLocation getMemberLoc() const { return MemberNameInfo.getLoc(); }
21572577743c5650c646fb705df01403707e94f2df04Abramo Bagnara  void setMemberLoc(SourceLocation L) { MemberNameInfo.setLoc(L); }
21581c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor
21593b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor  /// \brief Determines whether this member expression actually had a C++
21603b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor  /// template argument list explicitly specified, e.g., x.f<int>.
2161aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall  bool hasExplicitTemplateArgs() const {
2162aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall    return HasExplicitTemplateArgs;
21633b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor  }
21641eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
216536c76f0bea0d3595a25a5362225c642019cc3176Argyrios Kyrtzidis  /// \brief Retrieve the explicit template argument list that followed the
216636c76f0bea0d3595a25a5362225c642019cc3176Argyrios Kyrtzidis  /// member template name, if any.
2167096832c5ed5b9106fa177ebc148489760c3bc496John McCall  ExplicitTemplateArgumentList &getExplicitTemplateArgs() {
216836c76f0bea0d3595a25a5362225c642019cc3176Argyrios Kyrtzidis    assert(HasExplicitTemplateArgs);
2169096832c5ed5b9106fa177ebc148489760c3bc496John McCall    return *reinterpret_cast<ExplicitTemplateArgumentList *>(this + 1);
217036c76f0bea0d3595a25a5362225c642019cc3176Argyrios Kyrtzidis  }
217136c76f0bea0d3595a25a5362225c642019cc3176Argyrios Kyrtzidis
217236c76f0bea0d3595a25a5362225c642019cc3176Argyrios Kyrtzidis  /// \brief Retrieve the explicit template argument list that followed the
217336c76f0bea0d3595a25a5362225c642019cc3176Argyrios Kyrtzidis  /// member template name, if any.
2174096832c5ed5b9106fa177ebc148489760c3bc496John McCall  const ExplicitTemplateArgumentList &getExplicitTemplateArgs() const {
217536c76f0bea0d3595a25a5362225c642019cc3176Argyrios Kyrtzidis    return const_cast<CXXDependentScopeMemberExpr *>(this)
2176096832c5ed5b9106fa177ebc148489760c3bc496John McCall             ->getExplicitTemplateArgs();
2177096832c5ed5b9106fa177ebc148489760c3bc496John McCall  }
2178096832c5ed5b9106fa177ebc148489760c3bc496John McCall
2179096832c5ed5b9106fa177ebc148489760c3bc496John McCall  /// \brief Retrieves the optional explicit template arguments.
2180096832c5ed5b9106fa177ebc148489760c3bc496John McCall  /// This points to the same data as getExplicitTemplateArgs(), but
2181096832c5ed5b9106fa177ebc148489760c3bc496John McCall  /// returns null if there are no explicit template arguments.
2182096832c5ed5b9106fa177ebc148489760c3bc496John McCall  const ExplicitTemplateArgumentList *getOptionalExplicitTemplateArgs() {
2183096832c5ed5b9106fa177ebc148489760c3bc496John McCall    if (!hasExplicitTemplateArgs()) return 0;
2184096832c5ed5b9106fa177ebc148489760c3bc496John McCall    return &getExplicitTemplateArgs();
218536c76f0bea0d3595a25a5362225c642019cc3176Argyrios Kyrtzidis  }
218636c76f0bea0d3595a25a5362225c642019cc3176Argyrios Kyrtzidis
2187d5532b6cfff2977e0c59fa6ead7f7973984a620dJohn McCall  /// \brief Copies the template arguments (if present) into the given
2188d5532b6cfff2977e0c59fa6ead7f7973984a620dJohn McCall  /// structure.
2189d5532b6cfff2977e0c59fa6ead7f7973984a620dJohn McCall  void copyTemplateArgumentsInto(TemplateArgumentListInfo &List) const {
2190096832c5ed5b9106fa177ebc148489760c3bc496John McCall    getExplicitTemplateArgs().copyInto(List);
2191d5532b6cfff2977e0c59fa6ead7f7973984a620dJohn McCall  }
2192d5532b6cfff2977e0c59fa6ead7f7973984a620dJohn McCall
21938dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis  /// \brief Initializes the template arguments using the given structure.
21948dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis  void initializeTemplateArgumentsFrom(const TemplateArgumentListInfo &List) {
2195096832c5ed5b9106fa177ebc148489760c3bc496John McCall    getExplicitTemplateArgs().initializeFrom(List);
21968dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis  }
21978dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis
21981eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  /// \brief Retrieve the location of the left angle bracket following the
21993b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor  /// member name ('<'), if any.
22001eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  SourceLocation getLAngleLoc() const {
2201096832c5ed5b9106fa177ebc148489760c3bc496John McCall    return getExplicitTemplateArgs().LAngleLoc;
22023b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor  }
22031eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
22043b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor  /// \brief Retrieve the template arguments provided as part of this
22053b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor  /// template-id.
2206833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall  const TemplateArgumentLoc *getTemplateArgs() const {
2207096832c5ed5b9106fa177ebc148489760c3bc496John McCall    return getExplicitTemplateArgs().getTemplateArgs();
22083b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor  }
22091eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
22103b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor  /// \brief Retrieve the number of template arguments provided as part of this
22113b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor  /// template-id.
22121eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  unsigned getNumTemplateArgs() const {
2213096832c5ed5b9106fa177ebc148489760c3bc496John McCall    return getExplicitTemplateArgs().NumTemplateArgs;
22143b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor  }
22151eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
22161eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  /// \brief Retrieve the location of the right angle bracket following the
22173b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor  /// template arguments ('>').
22181eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  SourceLocation getRAngleLoc() const {
2219096832c5ed5b9106fa177ebc148489760c3bc496John McCall    return getExplicitTemplateArgs().RAngleLoc;
22203b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor  }
22211eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
22221c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  virtual SourceRange getSourceRange() const {
2223aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall    SourceRange Range;
2224aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall    if (!isImplicitAccess())
2225aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall      Range.setBegin(Base->getSourceRange().getBegin());
2226aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall    else if (getQualifier())
2227aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall      Range.setBegin(getQualifierRange().getBegin());
2228aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall    else
22292577743c5650c646fb705df01403707e94f2df04Abramo Bagnara      Range.setBegin(MemberNameInfo.getBeginLoc());
22301eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
2231aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall    if (hasExplicitTemplateArgs())
2232aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall      Range.setEnd(getRAngleLoc());
2233aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall    else
22342577743c5650c646fb705df01403707e94f2df04Abramo Bagnara      Range.setEnd(MemberNameInfo.getEndLoc());
2235aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall    return Range;
22361c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  }
22371eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
22381eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  static bool classof(const Stmt *T) {
2239865d447ac6a4721ab58e898d014a21f2eff74b06John McCall    return T->getStmtClass() == CXXDependentScopeMemberExprClass;
22401c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  }
2241865d447ac6a4721ab58e898d014a21f2eff74b06John McCall  static bool classof(const CXXDependentScopeMemberExpr *) { return true; }
22421c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor
22431c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  // Iterators
22441c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  virtual child_iterator child_begin();
22451c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  virtual child_iterator child_end();
22461c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor};
22471c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor
2248129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall/// \brief Represents a C++ member access expression for which lookup
2249aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall/// produced a set of overloaded functions.
2250aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall///
2251aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall/// The member access may be explicit or implicit:
2252aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall///    struct A {
2253aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall///      int a, b;
2254aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall///      int explicitAccess() { return this->a + this->A::b; }
2255aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall///      int implicitAccess() { return a + A::b; }
2256aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall///    };
2257aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall///
2258aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall/// In the final AST, an explicit access always becomes a MemberExpr.
2259aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall/// An implicit access may become either a MemberExpr or a
2260aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall/// DeclRefExpr, depending on whether the member is static.
22617bb12da2b0749eeebb21854c77877736969e59f2John McCallclass UnresolvedMemberExpr : public OverloadExpr {
2262129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// \brief Whether this member expression used the '->' operator or
2263129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// the '.' operator.
2264129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  bool IsArrow : 1;
2265129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall
2266129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// \brief Whether the lookup results contain an unresolved using
2267129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// declaration.
2268129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  bool HasUnresolvedUsing : 1;
2269129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall
22707bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// \brief The expression for the base pointer or class reference,
22717bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// e.g., the \c x in x.f.  This can be null if this is an 'unbased'
22727bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// member expression
22737bb12da2b0749eeebb21854c77877736969e59f2John McCall  Stmt *Base;
22747bb12da2b0749eeebb21854c77877736969e59f2John McCall
22757bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// \brief The type of the base expression;  never null.
22767bb12da2b0749eeebb21854c77877736969e59f2John McCall  QualType BaseType;
2277129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall
2278129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// \brief The location of the '->' or '.' operator.
2279129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  SourceLocation OperatorLoc;
2280129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall
2281928e6fcf66fc4f342bcf7cc96bf56986c9c2a833Douglas Gregor  UnresolvedMemberExpr(ASTContext &C, QualType T, bool Dependent,
2282129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall                       bool HasUnresolvedUsing,
2283aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall                       Expr *Base, QualType BaseType, bool IsArrow,
2284129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall                       SourceLocation OperatorLoc,
2285129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall                       NestedNameSpecifier *Qualifier,
2286129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall                       SourceRange QualifierRange,
22872577743c5650c646fb705df01403707e94f2df04Abramo Bagnara                       const DeclarationNameInfo &MemberNameInfo,
22885a84dec38cfa9e084377a3167b474c79283c82faDouglas Gregor                       const TemplateArgumentListInfo *TemplateArgs,
22895a84dec38cfa9e084377a3167b474c79283c82faDouglas Gregor                       UnresolvedSetIterator Begin, UnresolvedSetIterator End);
2290a77eb0862507b900a10fa352af1568e639ed10b1Argyrios Kyrtzidis
2291a77eb0862507b900a10fa352af1568e639ed10b1Argyrios Kyrtzidis  UnresolvedMemberExpr(EmptyShell Empty)
2292a77eb0862507b900a10fa352af1568e639ed10b1Argyrios Kyrtzidis    : OverloadExpr(UnresolvedMemberExprClass, Empty), IsArrow(false),
2293a77eb0862507b900a10fa352af1568e639ed10b1Argyrios Kyrtzidis      HasUnresolvedUsing(false), Base(0) { }
2294129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall
2295129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCallpublic:
2296129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  static UnresolvedMemberExpr *
2297129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  Create(ASTContext &C, bool Dependent, bool HasUnresolvedUsing,
2298aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall         Expr *Base, QualType BaseType, bool IsArrow,
2299129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall         SourceLocation OperatorLoc,
2300129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall         NestedNameSpecifier *Qualifier,
2301129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall         SourceRange QualifierRange,
23022577743c5650c646fb705df01403707e94f2df04Abramo Bagnara         const DeclarationNameInfo &MemberNameInfo,
23035a84dec38cfa9e084377a3167b474c79283c82faDouglas Gregor         const TemplateArgumentListInfo *TemplateArgs,
23045a84dec38cfa9e084377a3167b474c79283c82faDouglas Gregor         UnresolvedSetIterator Begin, UnresolvedSetIterator End);
2305129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall
2306a77eb0862507b900a10fa352af1568e639ed10b1Argyrios Kyrtzidis  static UnresolvedMemberExpr *
2307a77eb0862507b900a10fa352af1568e639ed10b1Argyrios Kyrtzidis  CreateEmpty(ASTContext &C, unsigned NumTemplateArgs);
2308a77eb0862507b900a10fa352af1568e639ed10b1Argyrios Kyrtzidis
2309aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall  /// \brief True if this is an implicit access, i.e. one in which the
2310aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall  /// member being accessed was not written in the source.  The source
2311aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall  /// location of the operator is invalid in this case.
2312aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall  bool isImplicitAccess() const { return Base == 0; }
2313aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall
2314129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// \brief Retrieve the base object of this member expressions,
2315129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// e.g., the \c x in \c x.m.
2316aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall  Expr *getBase() {
2317aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall    assert(!isImplicitAccess());
2318aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall    return cast<Expr>(Base);
2319aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall  }
23202f27bf854f0519810b34afd209089cc75536b757John McCall  const Expr *getBase() const {
23212f27bf854f0519810b34afd209089cc75536b757John McCall    assert(!isImplicitAccess());
23222f27bf854f0519810b34afd209089cc75536b757John McCall    return cast<Expr>(Base);
23232f27bf854f0519810b34afd209089cc75536b757John McCall  }
2324129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  void setBase(Expr *E) { Base = E; }
2325129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall
2326aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall  QualType getBaseType() const { return BaseType; }
2327a77eb0862507b900a10fa352af1568e639ed10b1Argyrios Kyrtzidis  void setBaseType(QualType T) { BaseType = T; }
2328a77eb0862507b900a10fa352af1568e639ed10b1Argyrios Kyrtzidis
2329a77eb0862507b900a10fa352af1568e639ed10b1Argyrios Kyrtzidis  /// \brief Determine whether the lookup results contain an unresolved using
2330a77eb0862507b900a10fa352af1568e639ed10b1Argyrios Kyrtzidis  /// declaration.
2331a77eb0862507b900a10fa352af1568e639ed10b1Argyrios Kyrtzidis  bool hasUnresolvedUsing() const { return HasUnresolvedUsing; }
2332a77eb0862507b900a10fa352af1568e639ed10b1Argyrios Kyrtzidis  void setHasUnresolvedUsing(bool V) { HasUnresolvedUsing = V; }
2333aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall
2334129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// \brief Determine whether this member expression used the '->'
2335129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// operator; otherwise, it used the '.' operator.
2336129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  bool isArrow() const { return IsArrow; }
2337129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  void setArrow(bool A) { IsArrow = A; }
2338129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall
2339129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// \brief Retrieve the location of the '->' or '.' operator.
2340129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  SourceLocation getOperatorLoc() const { return OperatorLoc; }
2341129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  void setOperatorLoc(SourceLocation L) { OperatorLoc = L; }
2342129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall
2343c373d48502ca7683ab55385f5bd624d778eb288dJohn McCall  /// \brief Retrieves the naming class of this lookup.
2344c373d48502ca7683ab55385f5bd624d778eb288dJohn McCall  CXXRecordDecl *getNamingClass() const;
2345c373d48502ca7683ab55385f5bd624d778eb288dJohn McCall
23462577743c5650c646fb705df01403707e94f2df04Abramo Bagnara  /// \brief Retrieve the full name info for the member that this expression
23472577743c5650c646fb705df01403707e94f2df04Abramo Bagnara  /// refers to.
23482577743c5650c646fb705df01403707e94f2df04Abramo Bagnara  const DeclarationNameInfo &getMemberNameInfo() const { return getNameInfo(); }
23492577743c5650c646fb705df01403707e94f2df04Abramo Bagnara  void setMemberNameInfo(const DeclarationNameInfo &N) { setNameInfo(N); }
23502577743c5650c646fb705df01403707e94f2df04Abramo Bagnara
2351129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// \brief Retrieve the name of the member that this expression
2352129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// refers to.
23537bb12da2b0749eeebb21854c77877736969e59f2John McCall  DeclarationName getMemberName() const { return getName(); }
23547bb12da2b0749eeebb21854c77877736969e59f2John McCall  void setMemberName(DeclarationName N) { setName(N); }
2355129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall
2356129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  // \brief Retrieve the location of the name of the member that this
2357129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  // expression refers to.
23587bb12da2b0749eeebb21854c77877736969e59f2John McCall  SourceLocation getMemberLoc() const { return getNameLoc(); }
23597bb12da2b0749eeebb21854c77877736969e59f2John McCall  void setMemberLoc(SourceLocation L) { setNameLoc(L); }
2360129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall
23617bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// \brief Retrieve the explicit template argument list that followed the
23627bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// member template name.
23637bb12da2b0749eeebb21854c77877736969e59f2John McCall  ExplicitTemplateArgumentList &getExplicitTemplateArgs() {
23647bb12da2b0749eeebb21854c77877736969e59f2John McCall    assert(hasExplicitTemplateArgs());
23657bb12da2b0749eeebb21854c77877736969e59f2John McCall    return *reinterpret_cast<ExplicitTemplateArgumentList *>(this + 1);
23667bb12da2b0749eeebb21854c77877736969e59f2John McCall  }
23677bb12da2b0749eeebb21854c77877736969e59f2John McCall
23687bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// \brief Retrieve the explicit template argument list that followed the
23697bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// member template name, if any.
23707bb12da2b0749eeebb21854c77877736969e59f2John McCall  const ExplicitTemplateArgumentList &getExplicitTemplateArgs() const {
23717bb12da2b0749eeebb21854c77877736969e59f2John McCall    assert(hasExplicitTemplateArgs());
23727bb12da2b0749eeebb21854c77877736969e59f2John McCall    return *reinterpret_cast<const ExplicitTemplateArgumentList *>(this + 1);
2373129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  }
2374129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall
2375096832c5ed5b9106fa177ebc148489760c3bc496John McCall  /// \brief Retrieves the optional explicit template arguments.
2376096832c5ed5b9106fa177ebc148489760c3bc496John McCall  /// This points to the same data as getExplicitTemplateArgs(), but
2377096832c5ed5b9106fa177ebc148489760c3bc496John McCall  /// returns null if there are no explicit template arguments.
2378096832c5ed5b9106fa177ebc148489760c3bc496John McCall  const ExplicitTemplateArgumentList *getOptionalExplicitTemplateArgs() {
2379096832c5ed5b9106fa177ebc148489760c3bc496John McCall    if (!hasExplicitTemplateArgs()) return 0;
2380096832c5ed5b9106fa177ebc148489760c3bc496John McCall    return &getExplicitTemplateArgs();
2381096832c5ed5b9106fa177ebc148489760c3bc496John McCall  }
2382096832c5ed5b9106fa177ebc148489760c3bc496John McCall
2383129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// \brief Copies the template arguments into the given structure.
2384129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  void copyTemplateArgumentsInto(TemplateArgumentListInfo &List) const {
23857bb12da2b0749eeebb21854c77877736969e59f2John McCall    getExplicitTemplateArgs().copyInto(List);
2386129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  }
2387129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall
2388129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// \brief Retrieve the location of the left angle bracket following
2389129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// the member name ('<').
2390129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  SourceLocation getLAngleLoc() const {
23917bb12da2b0749eeebb21854c77877736969e59f2John McCall    return getExplicitTemplateArgs().LAngleLoc;
2392129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  }
2393129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall
2394129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// \brief Retrieve the template arguments provided as part of this
2395129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// template-id.
2396129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  const TemplateArgumentLoc *getTemplateArgs() const {
23977bb12da2b0749eeebb21854c77877736969e59f2John McCall    return getExplicitTemplateArgs().getTemplateArgs();
2398129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  }
2399129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall
2400129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// \brief Retrieve the number of template arguments provided as
2401129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// part of this template-id.
2402129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  unsigned getNumTemplateArgs() const {
24037bb12da2b0749eeebb21854c77877736969e59f2John McCall    return getExplicitTemplateArgs().NumTemplateArgs;
2404129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  }
2405129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall
2406129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// \brief Retrieve the location of the right angle bracket
2407129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// following the template arguments ('>').
2408129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  SourceLocation getRAngleLoc() const {
24097bb12da2b0749eeebb21854c77877736969e59f2John McCall    return getExplicitTemplateArgs().RAngleLoc;
2410129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  }
2411129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall
2412129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  virtual SourceRange getSourceRange() const {
24132577743c5650c646fb705df01403707e94f2df04Abramo Bagnara    SourceRange Range = getMemberNameInfo().getSourceRange();
2414aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall    if (!isImplicitAccess())
2415aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall      Range.setBegin(Base->getSourceRange().getBegin());
2416aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall    else if (getQualifier())
2417aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall      Range.setBegin(getQualifierRange().getBegin());
2418aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall
2419129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall    if (hasExplicitTemplateArgs())
2420129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall      Range.setEnd(getRAngleLoc());
2421129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall    return Range;
2422129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  }
2423129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall
2424129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  static bool classof(const Stmt *T) {
2425129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall    return T->getStmtClass() == UnresolvedMemberExprClass;
2426129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  }
2427129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  static bool classof(const UnresolvedMemberExpr *) { return true; }
2428129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall
2429129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  // Iterators
2430129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  virtual child_iterator child_begin();
2431129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  virtual child_iterator child_end();
2432129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall};
2433129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall
24342e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl/// \brief Represents a C++0x noexcept expression (C++ [expr.unary.noexcept]).
24352e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl///
24362e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl/// The noexcept expression tests whether a given expression might throw. Its
24372e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl/// result is a boolean constant.
24382e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redlclass CXXNoexceptExpr : public Expr {
24392e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl  bool Value : 1;
24402e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl  Stmt *Operand;
24412e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl  SourceRange Range;
24422e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl
24432e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redlpublic:
24442e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl  CXXNoexceptExpr(QualType Ty, Expr *Operand, CanThrowResult Val,
24452e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl                  SourceLocation Keyword, SourceLocation RParen)
24462e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl  : Expr(CXXNoexceptExprClass, Ty, /*TypeDependent*/false,
24472e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl         /*ValueDependent*/Val == CT_Dependent),
24482e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl    Value(Val == CT_Cannot), Operand(Operand), Range(Keyword, RParen)
24492e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl  { }
24502e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl
24512e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl  Expr *getOperand() const { return static_cast<Expr*>(Operand); }
24522e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl
24532e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl  virtual SourceRange getSourceRange() const { return Range; }
24542e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl
24552e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl  bool getValue() const { return Value; }
24562e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl
24572e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl  static bool classof(const Stmt *T) {
24582e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl    return T->getStmtClass() == CXXNoexceptExprClass;
24592e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl  }
24602e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl  static bool classof(const CXXNoexceptExpr *) { return true; }
24612e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl
24622e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl  // Iterators
24632e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl  virtual child_iterator child_begin();
24642e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl  virtual child_iterator child_end();
24652e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl};
24662e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl
24677bb12da2b0749eeebb21854c77877736969e59f2John McCallinline ExplicitTemplateArgumentList &OverloadExpr::getExplicitTemplateArgs() {
24687bb12da2b0749eeebb21854c77877736969e59f2John McCall  if (isa<UnresolvedLookupExpr>(this))
24697bb12da2b0749eeebb21854c77877736969e59f2John McCall    return cast<UnresolvedLookupExpr>(this)->getExplicitTemplateArgs();
24707bb12da2b0749eeebb21854c77877736969e59f2John McCall  else
24717bb12da2b0749eeebb21854c77877736969e59f2John McCall    return cast<UnresolvedMemberExpr>(this)->getExplicitTemplateArgs();
24727bb12da2b0749eeebb21854c77877736969e59f2John McCall}
24737bb12da2b0749eeebb21854c77877736969e59f2John McCall
24745f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer}  // end namespace clang
24755f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer
24765f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer#endif
2477