ExprCXX.h revision fceb0a8adba9d25db99a4d73e9655c2831a96ecd
15f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer//===--- ExprCXX.h - Classes for representing expressions -------*- C++ -*-===//
25f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer//
35f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer//                     The LLVM Compiler Infrastructure
45f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer//
50bc735ffcfb223c0186419547abaa5c84482663eChris Lattner// This file is distributed under the University of Illinois Open Source
60bc735ffcfb223c0186419547abaa5c84482663eChris Lattner// License. See LICENSE.TXT for details.
75f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer//
85f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer//===----------------------------------------------------------------------===//
95f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer//
105f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer//  This file defines the Expr interface and subclasses for C++ expressions.
115f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer//
125f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer//===----------------------------------------------------------------------===//
135f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer
145f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer#ifndef LLVM_CLANG_AST_EXPRCXX_H
155f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer#define LLVM_CLANG_AST_EXPRCXX_H
165f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer
1764b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl#include "clang/Basic/TypeTraits.h"
185f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer#include "clang/AST/Expr.h"
19c4a1dea2dc56bd1357ec91b829a0b9e68229a13eDaniel Dunbar#include "clang/AST/Decl.h"
205f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer
215f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencernamespace clang {
225f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer
234c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  class CXXConstructorDecl;
24c1ce477119fed070299668aab24084b17ff5f14bAnders Carlsson  class CXXDestructorDecl;
2502bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson  class CXXTempVarDecl;
264c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
271060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek//===--------------------------------------------------------------------===//
281060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek// C++ Expressions.
291060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek//===--------------------------------------------------------------------===//
301060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek
313fd95ce225393fe4a3623e429766a8c3f487ff9dDouglas Gregor/// \brief A call to an overloaded operator written using operator
323fd95ce225393fe4a3623e429766a8c3f487ff9dDouglas Gregor/// syntax.
333fd95ce225393fe4a3623e429766a8c3f487ff9dDouglas Gregor///
343fd95ce225393fe4a3623e429766a8c3f487ff9dDouglas Gregor/// Represents a call to an overloaded operator written using operator
353fd95ce225393fe4a3623e429766a8c3f487ff9dDouglas Gregor/// syntax, e.g., "x + y" or "*p". While semantically equivalent to a
363fd95ce225393fe4a3623e429766a8c3f487ff9dDouglas Gregor/// normal call, this AST node provides better information about the
373fd95ce225393fe4a3623e429766a8c3f487ff9dDouglas Gregor/// syntactic representation of the call.
383fd95ce225393fe4a3623e429766a8c3f487ff9dDouglas Gregor///
393fd95ce225393fe4a3623e429766a8c3f487ff9dDouglas Gregor/// In a C++ template, this expression node kind will be used whenever
403fd95ce225393fe4a3623e429766a8c3f487ff9dDouglas Gregor/// any of the arguments are type-dependent. In this case, the
413fd95ce225393fe4a3623e429766a8c3f487ff9dDouglas Gregor/// function itself will be a (possibly empty) set of functions and
423fd95ce225393fe4a3623e429766a8c3f487ff9dDouglas Gregor/// function templates that were found by name lookup at template
433fd95ce225393fe4a3623e429766a8c3f487ff9dDouglas Gregor/// definition time.
44b4609806e9232593ece09ce08b630836e825865cDouglas Gregorclass CXXOperatorCallExpr : public CallExpr {
45063daf6e196c51f162e0485478355d8e280eef5cDouglas Gregor  /// \brief The overloaded operator.
46063daf6e196c51f162e0485478355d8e280eef5cDouglas Gregor  OverloadedOperatorKind Operator;
47063daf6e196c51f162e0485478355d8e280eef5cDouglas Gregor
48b4609806e9232593ece09ce08b630836e825865cDouglas Gregorpublic:
49063daf6e196c51f162e0485478355d8e280eef5cDouglas Gregor  CXXOperatorCallExpr(ASTContext& C, OverloadedOperatorKind Op, Expr *fn,
50063daf6e196c51f162e0485478355d8e280eef5cDouglas Gregor                      Expr **args, unsigned numargs, QualType t,
51063daf6e196c51f162e0485478355d8e280eef5cDouglas Gregor                      SourceLocation operatorloc)
52063daf6e196c51f162e0485478355d8e280eef5cDouglas Gregor    : CallExpr(C, CXXOperatorCallExprClass, fn, args, numargs, t, operatorloc),
53063daf6e196c51f162e0485478355d8e280eef5cDouglas Gregor      Operator(Op) {}
54b4609806e9232593ece09ce08b630836e825865cDouglas Gregor
55b4609806e9232593ece09ce08b630836e825865cDouglas Gregor  /// getOperator - Returns the kind of overloaded operator that this
56b4609806e9232593ece09ce08b630836e825865cDouglas Gregor  /// expression refers to.
57063daf6e196c51f162e0485478355d8e280eef5cDouglas Gregor  OverloadedOperatorKind getOperator() const { return Operator; }
58b4609806e9232593ece09ce08b630836e825865cDouglas Gregor
59b4609806e9232593ece09ce08b630836e825865cDouglas Gregor  /// getOperatorLoc - Returns the location of the operator symbol in
60b4609806e9232593ece09ce08b630836e825865cDouglas Gregor  /// the expression. When @c getOperator()==OO_Call, this is the
61b4609806e9232593ece09ce08b630836e825865cDouglas Gregor  /// location of the right parentheses; when @c
62b4609806e9232593ece09ce08b630836e825865cDouglas Gregor  /// getOperator()==OO_Subscript, this is the location of the right
63b4609806e9232593ece09ce08b630836e825865cDouglas Gregor  /// bracket.
64b4609806e9232593ece09ce08b630836e825865cDouglas Gregor  SourceLocation getOperatorLoc() const { return getRParenLoc(); }
65b4609806e9232593ece09ce08b630836e825865cDouglas Gregor
66b4609806e9232593ece09ce08b630836e825865cDouglas Gregor  virtual SourceRange getSourceRange() const;
67b4609806e9232593ece09ce08b630836e825865cDouglas Gregor
68b4609806e9232593ece09ce08b630836e825865cDouglas Gregor  static bool classof(const Stmt *T) {
69b4609806e9232593ece09ce08b630836e825865cDouglas Gregor    return T->getStmtClass() == CXXOperatorCallExprClass;
70b4609806e9232593ece09ce08b630836e825865cDouglas Gregor  }
71b4609806e9232593ece09ce08b630836e825865cDouglas Gregor  static bool classof(const CXXOperatorCallExpr *) { return true; }
72b4609806e9232593ece09ce08b630836e825865cDouglas Gregor};
73b4609806e9232593ece09ce08b630836e825865cDouglas Gregor
7488a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor/// CXXMemberCallExpr - Represents a call to a member function that
7588a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor/// may be written either with member call syntax (e.g., "obj.func()"
7688a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor/// or "objptr->func()") or with normal function-call syntax
7788a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor/// ("func()") within a member function that ends up calling a member
7888a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor/// function. The callee in either case is a MemberExpr that contains
7988a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor/// both the object argument and the member function, while the
8088a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor/// arguments are the arguments within the parentheses (not including
8188a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor/// the object argument).
8288a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregorclass CXXMemberCallExpr : public CallExpr {
8388a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregorpublic:
84668bf91d31265b6ea8c3eb854ba450857701f269Ted Kremenek  CXXMemberCallExpr(ASTContext& C, Expr *fn, Expr **args, unsigned numargs,
85668bf91d31265b6ea8c3eb854ba450857701f269Ted Kremenek                    QualType t, SourceLocation rparenloc)
86668bf91d31265b6ea8c3eb854ba450857701f269Ted Kremenek    : CallExpr(C, CXXMemberCallExprClass, fn, args, numargs, t, rparenloc) {}
8788a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor
8888a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor  /// getImplicitObjectArgument - Retrieves the implicit object
8988a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor  /// argument for the member call. For example, in "x.f(5)", this
9088a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor  /// operation would return "x".
9188a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor  Expr *getImplicitObjectArgument();
9288a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor
9388a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor  static bool classof(const Stmt *T) {
9488a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor    return T->getStmtClass() == CXXMemberCallExprClass;
9588a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor  }
9688a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor  static bool classof(const CXXMemberCallExpr *) { return true; }
9788a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor};
9888a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor
9949badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// CXXNamedCastExpr - Abstract class common to all of the C++ "named"
10049badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// casts, @c static_cast, @c dynamic_cast, @c reinterpret_cast, or @c
10149badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// const_cast.
10249badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor///
10349badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// This abstract class is inherited by all of the classes
10449badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// representing "named" casts, e.g., CXXStaticCastExpr,
10549badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// CXXDynamicCastExpr, CXXReinterpretCastExpr, and CXXConstCastExpr.
10649badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregorclass CXXNamedCastExpr : public ExplicitCastExpr {
1071060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenekprivate:
1081060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  SourceLocation Loc; // the location of the casting op
10949badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor
11049badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregorprotected:
11149badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor  CXXNamedCastExpr(StmtClass SC, QualType ty, Expr *op, QualType writtenTy,
11249badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor                   SourceLocation l)
11349badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor    : ExplicitCastExpr(SC, ty, op, writtenTy), Loc(l) {}
11449badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor
1151060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenekpublic:
11649badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor  const char *getCastName() const;
11749badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor
118a3a7b8eea87c90a5a257f685749222b212ddaf36Douglas Gregor  /// \brief Retrieve the location of the cast operator keyword, e.g.,
119a3a7b8eea87c90a5a257f685749222b212ddaf36Douglas Gregor  /// "static_cast".
120a3a7b8eea87c90a5a257f685749222b212ddaf36Douglas Gregor  SourceLocation getOperatorLoc() const { return Loc; }
121a3a7b8eea87c90a5a257f685749222b212ddaf36Douglas Gregor  void setOperatorLoc(SourceLocation L) { Loc = L; }
122a3a7b8eea87c90a5a257f685749222b212ddaf36Douglas Gregor
1231060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  virtual SourceRange getSourceRange() const {
1241060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek    return SourceRange(Loc, getSubExpr()->getSourceRange().getEnd());
1251060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  }
1261060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  static bool classof(const Stmt *T) {
12749badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor    switch (T->getStmtClass()) {
12849badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor    case CXXNamedCastExprClass:
12949badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor    case CXXStaticCastExprClass:
13049badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor    case CXXDynamicCastExprClass:
13149badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor    case CXXReinterpretCastExprClass:
13249badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor    case CXXConstCastExprClass:
13349badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor      return true;
13449badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor    default:
13549badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor      return false;
13649badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor    }
1371060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  }
13849badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor  static bool classof(const CXXNamedCastExpr *) { return true; }
13949badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor};
14049badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor
14149badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// CXXStaticCastExpr - A C++ @c static_cast expression (C++ [expr.static.cast]).
14249badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor///
14349badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// This expression node represents a C++ static cast, e.g.,
14449badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// @c static_cast<int>(1.0).
14549badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregorclass CXXStaticCastExpr : public CXXNamedCastExpr {
14649badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregorpublic:
14749badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor  CXXStaticCastExpr(QualType ty, Expr *op, QualType writtenTy, SourceLocation l)
14849badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor    : CXXNamedCastExpr(CXXStaticCastExprClass, ty, op, writtenTy, l) {}
14949badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor
15049badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor  static bool classof(const Stmt *T) {
15149badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor    return T->getStmtClass() == CXXStaticCastExprClass;
15249badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor  }
15349badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor  static bool classof(const CXXStaticCastExpr *) { return true; }
15449badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor};
15549badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor
15649badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// CXXDynamicCastExpr - A C++ @c dynamic_cast expression
15749badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// (C++ [expr.dynamic.cast]), which may perform a run-time check to
15849badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// determine how to perform the type cast.
15949badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor///
16049badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// This expression node represents a dynamic cast, e.g.,
16149badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// @c dynamic_cast<Derived*>(BasePtr).
16249badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregorclass CXXDynamicCastExpr : public CXXNamedCastExpr {
16349badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregorpublic:
16449badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor  CXXDynamicCastExpr(QualType ty, Expr *op, QualType writtenTy, SourceLocation l)
16549badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor    : CXXNamedCastExpr(CXXDynamicCastExprClass, ty, op, writtenTy, l) {}
16649badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor
16749badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor  static bool classof(const Stmt *T) {
16849badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor    return T->getStmtClass() == CXXDynamicCastExprClass;
16949badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor  }
17049badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor  static bool classof(const CXXDynamicCastExpr *) { return true; }
17149badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor};
17249badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor
17349badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// CXXReinterpretCastExpr - A C++ @c reinterpret_cast expression (C++
17449badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// [expr.reinterpret.cast]), which provides a differently-typed view
17549badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// of a value but performs no actual work at run time.
17649badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor///
17749badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// This expression node represents a reinterpret cast, e.g.,
17849badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// @c reinterpret_cast<int>(VoidPtr).
17949badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregorclass CXXReinterpretCastExpr : public CXXNamedCastExpr {
18049badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregorpublic:
18149badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor  CXXReinterpretCastExpr(QualType ty, Expr *op, QualType writtenTy,
18249badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor                         SourceLocation l)
18349badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor    : CXXNamedCastExpr(CXXReinterpretCastExprClass, ty, op, writtenTy, l) {}
18449badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor
18549badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor  static bool classof(const Stmt *T) {
18649badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor    return T->getStmtClass() == CXXReinterpretCastExprClass;
18749badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor  }
18849badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor  static bool classof(const CXXReinterpretCastExpr *) { return true; }
18949badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor};
19049badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor
19149badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// CXXConstCastExpr - A C++ @c const_cast expression (C++ [expr.const.cast]),
19249badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// which can remove type qualifiers but does not change the underlying value.
19349badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor///
19449badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// This expression node represents a const cast, e.g.,
19549badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// @c const_cast<char*>(PtrToConstChar).
19649badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregorclass CXXConstCastExpr : public CXXNamedCastExpr {
19749badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregorpublic:
19849badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor  CXXConstCastExpr(QualType ty, Expr *op, QualType writtenTy,
19949badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor                   SourceLocation l)
20049badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor    : CXXNamedCastExpr(CXXConstCastExprClass, ty, op, writtenTy, l) {}
20149badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor
20249badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor  static bool classof(const Stmt *T) {
20349badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor    return T->getStmtClass() == CXXConstCastExprClass;
20449badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor  }
20549badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor  static bool classof(const CXXConstCastExpr *) { return true; }
2061060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek};
2071060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek
2081060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek/// CXXBoolLiteralExpr - [C++ 2.13.5] C++ Boolean Literal.
2091060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek///
2101060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenekclass CXXBoolLiteralExpr : public Expr {
2111060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  bool Value;
2121060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  SourceLocation Loc;
2131060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenekpublic:
2141060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  CXXBoolLiteralExpr(bool val, QualType Ty, SourceLocation l) :
2151060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek    Expr(CXXBoolLiteralExprClass, Ty), Value(val), Loc(l) {}
2168b0b475b3464b0f70b91ba7d679d23c424677d5eSebastian Redl
2178b0b475b3464b0f70b91ba7d679d23c424677d5eSebastian Redl  CXXBoolLiteralExpr* Clone(ASTContext &C) const;
2188b0b475b3464b0f70b91ba7d679d23c424677d5eSebastian Redl
2191060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  bool getValue() const { return Value; }
2205f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer
2211060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  virtual SourceRange getSourceRange() const { return SourceRange(Loc); }
2225f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer
2231060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  static bool classof(const Stmt *T) {
2241060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek    return T->getStmtClass() == CXXBoolLiteralExprClass;
2251060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  }
2261060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  static bool classof(const CXXBoolLiteralExpr *) { return true; }
2275f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer
2281060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  // Iterators
2291060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  virtual child_iterator child_begin();
2301060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  virtual child_iterator child_end();
2311060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek};
2321060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek
2336e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl/// CXXNullPtrLiteralExpr - [C++0x 2.14.7] C++ Pointer Literal
2346e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redlclass CXXNullPtrLiteralExpr : public Expr {
2356e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl  SourceLocation Loc;
2366e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redlpublic:
2376e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl  CXXNullPtrLiteralExpr(QualType Ty, SourceLocation l) :
2386e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl    Expr(CXXNullPtrLiteralExprClass, Ty), Loc(l) {}
2396e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl
2408b0b475b3464b0f70b91ba7d679d23c424677d5eSebastian Redl  CXXNullPtrLiteralExpr* Clone(ASTContext &C) const;
2418b0b475b3464b0f70b91ba7d679d23c424677d5eSebastian Redl
2426e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl  virtual SourceRange getSourceRange() const { return SourceRange(Loc); }
2436e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl
2446e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl  static bool classof(const Stmt *T) {
2456e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl    return T->getStmtClass() == CXXNullPtrLiteralExprClass;
2466e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl  }
2476e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl  static bool classof(const CXXNullPtrLiteralExpr *) { return true; }
2486e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl
2496e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl  virtual child_iterator child_begin();
2506e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl  virtual child_iterator child_end();
2516e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl};
2526e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl
253c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl/// CXXTypeidExpr - A C++ @c typeid expression (C++ [expr.typeid]), which gets
254c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl/// the type_info that corresponds to the supplied type, or the (possibly
255c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl/// dynamic) type of the supplied expression.
256c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl///
257c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl/// This represents code like @c typeid(int) or @c typeid(*objPtr)
258c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redlclass CXXTypeidExpr : public Expr {
259c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redlprivate:
260c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl  bool isTypeOp : 1;
261d457589fc69dc7a9c80cd74d317c0b81a35a27c9Sebastian Redl  union {
262d457589fc69dc7a9c80cd74d317c0b81a35a27c9Sebastian Redl    void *Ty;
263d457589fc69dc7a9c80cd74d317c0b81a35a27c9Sebastian Redl    Stmt *Ex;
264d457589fc69dc7a9c80cd74d317c0b81a35a27c9Sebastian Redl  } Operand;
265c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl  SourceRange Range;
266c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl
267c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redlpublic:
268c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl  CXXTypeidExpr(bool isTypeOp, void *op, QualType Ty, const SourceRange r) :
2692850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl      Expr(CXXTypeidExprClass, Ty,
2702850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl        // typeid is never type-dependent (C++ [temp.dep.expr]p4)
2712850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl        false,
2722850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl        // typeid is value-dependent if the type or expression are dependent
2732850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl        (isTypeOp ? QualType::getFromOpaquePtr(op)->isDependentType()
2742850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl                  : static_cast<Expr*>(op)->isValueDependent())),
2752850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl      isTypeOp(isTypeOp), Range(r) {
276d457589fc69dc7a9c80cd74d317c0b81a35a27c9Sebastian Redl    if (isTypeOp)
277d457589fc69dc7a9c80cd74d317c0b81a35a27c9Sebastian Redl      Operand.Ty = op;
278d457589fc69dc7a9c80cd74d317c0b81a35a27c9Sebastian Redl    else
279d457589fc69dc7a9c80cd74d317c0b81a35a27c9Sebastian Redl      // op was an Expr*, so cast it back to that to be safe
2802850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl      Operand.Ex = static_cast<Expr*>(op);
281d457589fc69dc7a9c80cd74d317c0b81a35a27c9Sebastian Redl  }
282c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl
283c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl  bool isTypeOperand() const { return isTypeOp; }
284c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl  QualType getTypeOperand() const {
285c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl    assert(isTypeOperand() && "Cannot call getTypeOperand for typeid(expr)");
286d457589fc69dc7a9c80cd74d317c0b81a35a27c9Sebastian Redl    return QualType::getFromOpaquePtr(Operand.Ty);
287c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl  }
288c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl  Expr* getExprOperand() const {
289c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl    assert(!isTypeOperand() && "Cannot call getExprOperand for typeid(type)");
290d457589fc69dc7a9c80cd74d317c0b81a35a27c9Sebastian Redl    return static_cast<Expr*>(Operand.Ex);
291c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl  }
292c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl
293c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl  virtual SourceRange getSourceRange() const {
294c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl    return Range;
295c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl  }
296c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl  static bool classof(const Stmt *T) {
297c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl    return T->getStmtClass() == CXXTypeidExprClass;
298c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl  }
299c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl  static bool classof(const CXXTypeidExpr *) { return true; }
300c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl
301c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl  // Iterators
302c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl  virtual child_iterator child_begin();
303c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl  virtual child_iterator child_end();
304c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl};
305c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl
306796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// CXXThisExpr - Represents the "this" expression in C++, which is a
307796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// pointer to the object on which the current member function is
308796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// executing (C++ [expr.prim]p3). Example:
309796da18402f286b897782a298ae3b20c459c102eDouglas Gregor///
310796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// @code
311796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// class Foo {
312796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// public:
313796da18402f286b897782a298ae3b20c459c102eDouglas Gregor///   void bar();
314796da18402f286b897782a298ae3b20c459c102eDouglas Gregor///   void test() { this->bar(); }
315796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// };
316796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// @endcode
317796da18402f286b897782a298ae3b20c459c102eDouglas Gregorclass CXXThisExpr : public Expr {
318796da18402f286b897782a298ae3b20c459c102eDouglas Gregor  SourceLocation Loc;
319796da18402f286b897782a298ae3b20c459c102eDouglas Gregor
320796da18402f286b897782a298ae3b20c459c102eDouglas Gregorpublic:
321796da18402f286b897782a298ae3b20c459c102eDouglas Gregor  CXXThisExpr(SourceLocation L, QualType Type)
3222850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl    : Expr(CXXThisExprClass, Type,
3232850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl           // 'this' is type-dependent if the class type of the enclosing
3242850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl           // member function is dependent (C++ [temp.dep.expr]p2)
3252850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl           Type->isDependentType(), Type->isDependentType()),
3262850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl      Loc(L) { }
327796da18402f286b897782a298ae3b20c459c102eDouglas Gregor
328796da18402f286b897782a298ae3b20c459c102eDouglas Gregor  virtual SourceRange getSourceRange() const { return SourceRange(Loc); }
329796da18402f286b897782a298ae3b20c459c102eDouglas Gregor
330796da18402f286b897782a298ae3b20c459c102eDouglas Gregor  static bool classof(const Stmt *T) {
331796da18402f286b897782a298ae3b20c459c102eDouglas Gregor    return T->getStmtClass() == CXXThisExprClass;
332796da18402f286b897782a298ae3b20c459c102eDouglas Gregor  }
333796da18402f286b897782a298ae3b20c459c102eDouglas Gregor  static bool classof(const CXXThisExpr *) { return true; }
334796da18402f286b897782a298ae3b20c459c102eDouglas Gregor
335796da18402f286b897782a298ae3b20c459c102eDouglas Gregor  // Iterators
336796da18402f286b897782a298ae3b20c459c102eDouglas Gregor  virtual child_iterator child_begin();
337796da18402f286b897782a298ae3b20c459c102eDouglas Gregor  virtual child_iterator child_end();
338796da18402f286b897782a298ae3b20c459c102eDouglas Gregor};
339796da18402f286b897782a298ae3b20c459c102eDouglas Gregor
3401060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek///  CXXThrowExpr - [C++ 15] C++ Throw Expression.  This handles
3411060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek///  'throw' and 'throw' assignment-expression.  When
3421060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek///  assignment-expression isn't present, Op will be null.
3431060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek///
3441060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenekclass CXXThrowExpr : public Expr {
3451060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  Stmt *Op;
3461060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  SourceLocation ThrowLoc;
3471060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenekpublic:
3481060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  // Ty is the void type which is used as the result type of the
3491060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  // exepression.  The l is the location of the throw keyword.  expr
3501060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  // can by null, if the optional expression to throw isn't present.
3511060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  CXXThrowExpr(Expr *expr, QualType Ty, SourceLocation l) :
3522850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl    Expr(CXXThrowExprClass, Ty, false, false), Op(expr), ThrowLoc(l) {}
3531060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  const Expr *getSubExpr() const { return cast_or_null<Expr>(Op); }
3541060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  Expr *getSubExpr() { return cast_or_null<Expr>(Op); }
35542e5b50f4dc897f252e0d476063a7f9846d96624Douglas Gregor  void setSubExpr(Expr *E) { Op = E; }
35642e5b50f4dc897f252e0d476063a7f9846d96624Douglas Gregor
35742e5b50f4dc897f252e0d476063a7f9846d96624Douglas Gregor  SourceLocation getThrowLoc() const { return ThrowLoc; }
35842e5b50f4dc897f252e0d476063a7f9846d96624Douglas Gregor  void setThrowLoc(SourceLocation L) { ThrowLoc = L; }
3591060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek
3601060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  virtual SourceRange getSourceRange() const {
3611060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek    if (getSubExpr() == 0)
3621060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek      return SourceRange(ThrowLoc, ThrowLoc);
3631060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek    return SourceRange(ThrowLoc, getSubExpr()->getSourceRange().getEnd());
3641060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  }
3651060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek
3661060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  static bool classof(const Stmt *T) {
3671060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek    return T->getStmtClass() == CXXThrowExprClass;
3681060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  }
3691060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  static bool classof(const CXXThrowExpr *) { return true; }
3701060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek
3711060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  // Iterators
3721060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  virtual child_iterator child_begin();
3731060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  virtual child_iterator child_end();
3741060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek};
3751060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek
3761060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek/// CXXDefaultArgExpr - C++ [dcl.fct.default]. This wraps up a
3771060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek/// function call argument that was created from the corresponding
3781060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek/// parameter's default argument, when the call did not explicitly
3791060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek/// supply arguments for all of the parameters.
3801060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenekclass CXXDefaultArgExpr : public Expr {
3811060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  ParmVarDecl *Param;
3821060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenekpublic:
3831060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  // Param is the parameter whose default argument is used by this
3841060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  // expression.
3851060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  explicit CXXDefaultArgExpr(ParmVarDecl *param)
38661366e9cd41a6dbde4e66416dac21269c8ac1d94Douglas Gregor    : Expr(CXXDefaultArgExprClass,
38761366e9cd41a6dbde4e66416dac21269c8ac1d94Douglas Gregor           param->hasUnparsedDefaultArg()? param->getType().getNonReferenceType()
38861366e9cd41a6dbde4e66416dac21269c8ac1d94Douglas Gregor                                         : param->getDefaultArg()->getType()),
3891060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek      Param(param) { }
3901060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek
3911060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  // Retrieve the parameter that the argument was created from.
3921060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  const ParmVarDecl *getParam() const { return Param; }
3931060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  ParmVarDecl *getParam() { return Param; }
3941060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek
3951060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  // Retrieve the actual argument to the function call.
3961060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  const Expr *getExpr() const { return Param->getDefaultArg(); }
3971060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  Expr *getExpr() { return Param->getDefaultArg(); }
3981060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek
3991060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  virtual SourceRange getSourceRange() const {
4001060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek    // Default argument expressions have no representation in the
4011060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek    // source, so they have an empty source range.
4021060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek    return SourceRange();
4031060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  }
4041060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek
4051060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  static bool classof(const Stmt *T) {
4061060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek    return T->getStmtClass() == CXXDefaultArgExprClass;
4071060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  }
4081060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  static bool classof(const CXXDefaultArgExpr *) { return true; }
4091060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek
4101060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  // Iterators
4111060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  virtual child_iterator child_begin();
4121060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  virtual child_iterator child_end();
4131060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek};
414987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis
415c1ce477119fed070299668aab24084b17ff5f14bAnders Carlsson/// CXXTemporary - Represents a C++ temporary.
416c1ce477119fed070299668aab24084b17ff5f14bAnders Carlssonclass CXXTemporary {
417c1ce477119fed070299668aab24084b17ff5f14bAnders Carlsson  /// Destructor - The destructor that needs to be called.
418c1ce477119fed070299668aab24084b17ff5f14bAnders Carlsson  CXXDestructorDecl *Destructor;
419c1ce477119fed070299668aab24084b17ff5f14bAnders Carlsson
420c1ce477119fed070299668aab24084b17ff5f14bAnders Carlsson  CXXTemporary(CXXDestructorDecl *destructor)
421c1ce477119fed070299668aab24084b17ff5f14bAnders Carlsson    : Destructor(destructor) { }
422c1ce477119fed070299668aab24084b17ff5f14bAnders Carlsson
423c1ce477119fed070299668aab24084b17ff5f14bAnders Carlssonpublic:
424c1ce477119fed070299668aab24084b17ff5f14bAnders Carlsson  static CXXTemporary *Create(ASTContext &C, CXXDestructorDecl *Destructor);
425c1ce477119fed070299668aab24084b17ff5f14bAnders Carlsson};
426fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson
427fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson/// CXXBindTemporaryExpr - Represents binding an expression to a temporary,
428fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson/// so its destructor can be called later.
429fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlssonclass CXXBindTemporaryExpr : public Expr {
430fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson  CXXTemporary *Temp;
431fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson
432fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson  Stmt *SubExpr;
433fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson
434fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson  CXXBindTemporaryExpr(CXXTemporary *temp, Expr* subexpr)
435fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson   : Expr(CXXBindTemporaryExprClass,
436fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson          subexpr->getType()), Temp(temp), SubExpr(subexpr) { }
437fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson
438fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlssonpublic:
439fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson  static CXXBindTemporaryExpr *Create(ASTContext &C, CXXTemporary *Temp,
440fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson                                      Expr* SubExpr);
441c1ce477119fed070299668aab24084b17ff5f14bAnders Carlsson
442fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson  const Expr *getSubExpr() const { return cast<Expr>(SubExpr); }
443fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson  Expr *getSubExpr() { return cast<Expr>(SubExpr); }
444fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson
445fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson  virtual SourceRange getSourceRange() const { return SourceRange(); }
446fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson
447fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson  // Implement isa/cast/dyncast/etc.
448fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson  static bool classof(const Stmt *T) {
449fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson    return T->getStmtClass() == CXXBindTemporaryExprClass;
450fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson  }
451fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson  static bool classof(const CXXBindTemporaryExpr *) { return true; }
452fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson
453fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson  // Iterators
454fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson  virtual child_iterator child_begin();
455fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson  virtual child_iterator child_end();
456fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson};
457fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson
45815ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson/// CXXConstructExpr - Represents a call to a C++ constructor.
45915ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlssonclass CXXConstructExpr : public Expr {
46015ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson  VarDecl *VD;
46115ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson  CXXConstructorDecl *Constructor;
46215ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson
46315ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson  bool Elidable;
46415ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson
46515ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson  Stmt **Args;
46615ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson  unsigned NumArgs;
46715ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson
46815ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson
469bd6734e5f6432ce0cc07171c490ffaa094796198Anders Carlssonprotected:
470bd6734e5f6432ce0cc07171c490ffaa094796198Anders Carlsson  CXXConstructExpr(ASTContext &C, StmtClass SC, VarDecl *vd, QualType T,
471bd6734e5f6432ce0cc07171c490ffaa094796198Anders Carlsson                   CXXConstructorDecl *d, bool elidable,
472bd6734e5f6432ce0cc07171c490ffaa094796198Anders Carlsson                   Expr **args, unsigned numargs);
473524fa13fd81e88533c7a1d4b1232c0de2c97dc7cAnders Carlsson  ~CXXConstructExpr() { }
474bd6734e5f6432ce0cc07171c490ffaa094796198Anders Carlsson
47515ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlssonpublic:
47615ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson  static CXXConstructExpr *Create(ASTContext &C, VarDecl *VD, QualType T,
47715ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson                                  CXXConstructorDecl *D, bool Elidable,
47815ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson                                  Expr **Args, unsigned NumArgs);
47915ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson
48015ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson  void Destroy(ASTContext &C);
48115ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson
482d94546a0a1deef7286c13e49b9584621ae81cc9aDouglas Gregor  VarDecl* getVarDecl() const { return VD; }
483d94546a0a1deef7286c13e49b9584621ae81cc9aDouglas Gregor  CXXConstructorDecl* getConstructor() const { return Constructor; }
484d94546a0a1deef7286c13e49b9584621ae81cc9aDouglas Gregor
485d94546a0a1deef7286c13e49b9584621ae81cc9aDouglas Gregor  /// \brief Whether this construction is elidable.
486d94546a0a1deef7286c13e49b9584621ae81cc9aDouglas Gregor  bool isElidable() const { return Elidable; }
48715ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson
48815ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson  typedef ExprIterator arg_iterator;
48915ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson  typedef ConstExprIterator const_arg_iterator;
49015ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson
49115ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson  arg_iterator arg_begin() { return Args; }
49215ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson  arg_iterator arg_end() { return Args + NumArgs; }
49315ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson  const_arg_iterator arg_begin() const { return Args; }
49415ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson  const_arg_iterator arg_end() const { return Args + NumArgs; }
49515ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson
49615ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson  unsigned getNumArgs() const { return NumArgs; }
49715ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson
49815ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson  virtual SourceRange getSourceRange() const { return SourceRange(); }
49915ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson
50015ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson  static bool classof(const Stmt *T) {
501524fa13fd81e88533c7a1d4b1232c0de2c97dc7cAnders Carlsson    return T->getStmtClass() == CXXConstructExprClass ||
502524fa13fd81e88533c7a1d4b1232c0de2c97dc7cAnders Carlsson      T->getStmtClass() == CXXTemporaryObjectExprClass;
50315ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson  }
50415ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson  static bool classof(const CXXConstructExpr *) { return true; }
50515ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson
50615ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson  // Iterators
50715ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson  virtual child_iterator child_begin();
50815ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson  virtual child_iterator child_end();
50915ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson};
51015ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson
51149badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// CXXFunctionalCastExpr - Represents an explicit C++ type conversion
51249badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// that uses "functional" notion (C++ [expr.type.conv]). Example: @c
51349badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// x = int(0.5);
51449badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregorclass CXXFunctionalCastExpr : public ExplicitCastExpr {
515987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  SourceLocation TyBeginLoc;
516987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  SourceLocation RParenLoc;
517987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidispublic:
51849badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor  CXXFunctionalCastExpr(QualType ty, QualType writtenTy,
51949badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor                        SourceLocation tyBeginLoc, Expr *castExpr,
520987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis                        SourceLocation rParenLoc) :
52149badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor    ExplicitCastExpr(CXXFunctionalCastExprClass, ty, castExpr, writtenTy),
522987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis    TyBeginLoc(tyBeginLoc), RParenLoc(rParenLoc) {}
523987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis
524987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  SourceLocation getTypeBeginLoc() const { return TyBeginLoc; }
525987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  SourceLocation getRParenLoc() const { return RParenLoc; }
526987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis
527987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  virtual SourceRange getSourceRange() const {
528987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis    return SourceRange(TyBeginLoc, RParenLoc);
529987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  }
530987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  static bool classof(const Stmt *T) {
531987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis    return T->getStmtClass() == CXXFunctionalCastExprClass;
532987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  }
533987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  static bool classof(const CXXFunctionalCastExpr *) { return true; }
534987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis};
535987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis
536506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// @brief Represents a C++ functional cast expression that builds a
537506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// temporary object.
538506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor///
539506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// This expression type represents a C++ "functional" cast
540506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// (C++[expr.type.conv]) with N != 1 arguments that invokes a
541506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// constructor to build a temporary object. If N == 0 but no
542506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// constructor will be called (because the functional cast is
543506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// performing a value-initialized an object whose class type has no
544506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// user-declared constructors), CXXZeroInitValueExpr will represent
545506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// the functional cast. Finally, with N == 1 arguments the functional
546506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// cast expression will be represented by CXXFunctionalCastExpr.
547506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// Example:
548506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// @code
549506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// struct X { X(int, float); }
550506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor///
551506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// X create_X() {
552506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor///   return X(1, 3.14f); // creates a CXXTemporaryObjectExpr
553506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// };
554506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// @endcode
555524fa13fd81e88533c7a1d4b1232c0de2c97dc7cAnders Carlssonclass CXXTemporaryObjectExpr : public CXXConstructExpr {
556506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor  SourceLocation TyBeginLoc;
557506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor  SourceLocation RParenLoc;
558506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor
559506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregorpublic:
56009c4abb1057f0eb53a9c2b5c2f22b1472362156eAnders Carlsson  CXXTemporaryObjectExpr(ASTContext &C, VarDecl *vd,
56126de54983e7977fad615c94012f2f67d0d1cf404Anders Carlsson                         CXXConstructorDecl *Cons, QualType writtenTy,
562506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor                         SourceLocation tyBeginLoc, Expr **Args,
563506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor                         unsigned NumArgs, SourceLocation rParenLoc);
564506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor
565524fa13fd81e88533c7a1d4b1232c0de2c97dc7cAnders Carlsson  ~CXXTemporaryObjectExpr() { }
566506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor
567506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor  SourceLocation getTypeBeginLoc() const { return TyBeginLoc; }
568506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor  SourceLocation getRParenLoc() const { return RParenLoc; }
569ba49817c5b9f502602672861cf369fd0e53966e8Douglas Gregor
570506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor  virtual SourceRange getSourceRange() const {
571506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor    return SourceRange(TyBeginLoc, RParenLoc);
572506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor  }
573506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor  static bool classof(const Stmt *T) {
574506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor    return T->getStmtClass() == CXXTemporaryObjectExprClass;
575506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor  }
576506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor  static bool classof(const CXXTemporaryObjectExpr *) { return true; }
577506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor};
578506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor
579987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis/// CXXZeroInitValueExpr - [C++ 5.2.3p2]
580506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// Expression "T()" which creates a value-initialized rvalue of type
581506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// T, which is either a non-class type or a class type without any
582506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// user-defined constructors.
583987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis///
584987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidisclass CXXZeroInitValueExpr : public Expr {
585987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  SourceLocation TyBeginLoc;
586987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  SourceLocation RParenLoc;
587987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis
588987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidispublic:
589987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  CXXZeroInitValueExpr(QualType ty, SourceLocation tyBeginLoc,
590987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis                       SourceLocation rParenLoc ) :
591d94546a0a1deef7286c13e49b9584621ae81cc9aDouglas Gregor    Expr(CXXZeroInitValueExprClass, ty, false, false),
592987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis    TyBeginLoc(tyBeginLoc), RParenLoc(rParenLoc) {}
593987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis
594987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  SourceLocation getTypeBeginLoc() const { return TyBeginLoc; }
595987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  SourceLocation getRParenLoc() const { return RParenLoc; }
596987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis
5974c67834407ca6ab344dcf44fc599ad4938cfa96dDouglas Gregor  /// @brief Whether this initialization expression was
5984c67834407ca6ab344dcf44fc599ad4938cfa96dDouglas Gregor  /// implicitly-generated.
5994c67834407ca6ab344dcf44fc599ad4938cfa96dDouglas Gregor  bool isImplicit() const {
6004c67834407ca6ab344dcf44fc599ad4938cfa96dDouglas Gregor    return TyBeginLoc.isInvalid() && RParenLoc.isInvalid();
6014c67834407ca6ab344dcf44fc599ad4938cfa96dDouglas Gregor  }
6024c67834407ca6ab344dcf44fc599ad4938cfa96dDouglas Gregor
603987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  virtual SourceRange getSourceRange() const {
604987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis    return SourceRange(TyBeginLoc, RParenLoc);
605987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  }
606987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis
607d94546a0a1deef7286c13e49b9584621ae81cc9aDouglas Gregor  CXXZeroInitValueExpr* Clone(ASTContext &C) const;
608d94546a0a1deef7286c13e49b9584621ae81cc9aDouglas Gregor
609987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  static bool classof(const Stmt *T) {
610987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis    return T->getStmtClass() == CXXZeroInitValueExprClass;
611987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  }
612987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  static bool classof(const CXXZeroInitValueExpr *) { return true; }
613987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis
614987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  // Iterators
615987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  virtual child_iterator child_begin();
616987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  virtual child_iterator child_end();
617987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis};
618987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis
6199e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis/// CXXConditionDeclExpr - Condition declaration of a if/switch/while/for
6209e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis/// statement, e.g: "if (int x = f()) {...}".
6219e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis/// The main difference with DeclRefExpr is that CXXConditionDeclExpr owns the
6229e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis/// decl that it references.
6239e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis///
6249e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidisclass CXXConditionDeclExpr : public DeclRefExpr {
6259e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidispublic:
6269e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis  CXXConditionDeclExpr(SourceLocation startLoc,
6279e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis                       SourceLocation eqLoc, VarDecl *var)
6289d293dfc0ad7c44ae0b5eb9517f1ed8c8d8b7ff7Douglas Gregor    : DeclRefExpr(CXXConditionDeclExprClass, var,
6294a2e2041edc63db687677325e113b39b9d123c40Douglas Gregor                  var->getType().getNonReferenceType(), startLoc,
6304a2e2041edc63db687677325e113b39b9d123c40Douglas Gregor                  var->getType()->isDependentType(),
6314a2e2041edc63db687677325e113b39b9d123c40Douglas Gregor                  /*FIXME:integral constant?*/
6324a2e2041edc63db687677325e113b39b9d123c40Douglas Gregor                    var->getType()->isDependentType()) {}
6339e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis
6349e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis  virtual void Destroy(ASTContext& Ctx);
6359e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis
6369e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis  SourceLocation getStartLoc() const { return getLocation(); }
6379e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis
6389e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis  VarDecl *getVarDecl() { return cast<VarDecl>(getDecl()); }
6399e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis  const VarDecl *getVarDecl() const { return cast<VarDecl>(getDecl()); }
6409e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis
6419e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis  virtual SourceRange getSourceRange() const {
6429e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis    return SourceRange(getStartLoc(), getVarDecl()->getInit()->getLocEnd());
6439e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis  }
6449e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis
6459e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis  static bool classof(const Stmt *T) {
6469e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis    return T->getStmtClass() == CXXConditionDeclExprClass;
6479e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis  }
6489e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis  static bool classof(const CXXConditionDeclExpr *) { return true; }
6499e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis
6509e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis  // Iterators
6519e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis  virtual child_iterator child_begin();
6529e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis  virtual child_iterator child_end();
6539e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis};
6549e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis
6554c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl/// CXXNewExpr - A new expression for memory allocation and constructor calls,
6564c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl/// e.g: "new CXXNewExpr(foo)".
6574c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redlclass CXXNewExpr : public Expr {
6584c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  // Was the usage ::new, i.e. is the global new to be used?
6594c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  bool GlobalNew : 1;
6604c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  // Was the form (type-id) used? Otherwise, it was new-type-id.
6614c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  bool ParenTypeId : 1;
6624c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  // Is there an initializer? If not, built-ins are uninitialized, else they're
6634c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  // value-initialized.
6644c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  bool Initializer : 1;
665cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl  // Do we allocate an array? If so, the first SubExpr is the size expression.
666cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl  bool Array : 1;
6674c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  // The number of placement new arguments.
6684c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  unsigned NumPlacementArgs : 14;
6694c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  // The number of constructor arguments. This may be 1 even for non-class
6704c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  // types; use the pseudo copy constructor.
671cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl  unsigned NumConstructorArgs : 14;
672cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl  // Contains an optional array size expression, any number of optional
673cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl  // placement arguments, and any number of optional constructor arguments,
674cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl  // in that order.
6754c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  Stmt **SubExprs;
6764c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  // Points to the allocation function used.
6774c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  FunctionDecl *OperatorNew;
6784c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  // Points to the deallocation function used in case of error. May be null.
6794c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  FunctionDecl *OperatorDelete;
6804c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  // Points to the constructor used. Cannot be null if AllocType is a record;
6814c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  // it would still point at the default constructor (even an implicit one).
6824c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  // Must be null for all other types.
6834c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  CXXConstructorDecl *Constructor;
6844c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
6854c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  SourceLocation StartLoc;
6864c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  SourceLocation EndLoc;
6874c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
6884c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redlpublic:
6894c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  CXXNewExpr(bool globalNew, FunctionDecl *operatorNew, Expr **placementArgs,
690cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl             unsigned numPlaceArgs, bool ParenTypeId, Expr *arraySize,
6914c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl             CXXConstructorDecl *constructor, bool initializer,
6924c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl             Expr **constructorArgs, unsigned numConsArgs,
6934c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl             FunctionDecl *operatorDelete, QualType ty,
6944c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl             SourceLocation startLoc, SourceLocation endLoc);
6954c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  ~CXXNewExpr() {
6964c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl    delete[] SubExprs;
6974c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  }
6984c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
699cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl  QualType getAllocatedType() const {
700cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl    assert(getType()->isPointerType());
701cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl    return getType()->getAsPointerType()->getPointeeType();
702cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl  }
7034c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
7044c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  FunctionDecl *getOperatorNew() const { return OperatorNew; }
7054c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  FunctionDecl *getOperatorDelete() const { return OperatorDelete; }
7064c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  CXXConstructorDecl *getConstructor() const { return Constructor; }
7074c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
708cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl  bool isArray() const { return Array; }
709cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl  Expr *getArraySize() {
710cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl    return Array ? cast<Expr>(SubExprs[0]) : 0;
711cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl  }
712cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl  const Expr *getArraySize() const {
713cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl    return Array ? cast<Expr>(SubExprs[0]) : 0;
714cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl  }
715cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl
7164c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  unsigned getNumPlacementArgs() const { return NumPlacementArgs; }
7174c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  Expr *getPlacementArg(unsigned i) {
7184c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl    assert(i < NumPlacementArgs && "Index out of range");
719cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl    return cast<Expr>(SubExprs[Array + i]);
7204c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  }
7214c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  const Expr *getPlacementArg(unsigned i) const {
7224c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl    assert(i < NumPlacementArgs && "Index out of range");
723cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl    return cast<Expr>(SubExprs[Array + i]);
7244c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  }
7254c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
7264c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  bool isGlobalNew() const { return GlobalNew; }
7274c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  bool isParenTypeId() const { return ParenTypeId; }
7284c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  bool hasInitializer() const { return Initializer; }
7294c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
7304c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  unsigned getNumConstructorArgs() const { return NumConstructorArgs; }
7314c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  Expr *getConstructorArg(unsigned i) {
7324c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl    assert(i < NumConstructorArgs && "Index out of range");
733cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl    return cast<Expr>(SubExprs[Array + NumPlacementArgs + i]);
7344c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  }
7354c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  const Expr *getConstructorArg(unsigned i) const {
7364c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl    assert(i < NumConstructorArgs && "Index out of range");
737cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl    return cast<Expr>(SubExprs[Array + NumPlacementArgs + i]);
7384c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  }
7394c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
7404c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  typedef ExprIterator arg_iterator;
7414c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  typedef ConstExprIterator const_arg_iterator;
7424c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
7434c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  arg_iterator placement_arg_begin() {
744cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl    return SubExprs + Array;
7454c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  }
7464c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  arg_iterator placement_arg_end() {
747cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl    return SubExprs + Array + getNumPlacementArgs();
7484c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  }
7494c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  const_arg_iterator placement_arg_begin() const {
750cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl    return SubExprs + Array;
7514c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  }
7524c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  const_arg_iterator placement_arg_end() const {
753cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl    return SubExprs + Array + getNumPlacementArgs();
7544c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  }
7554c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
7564c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  arg_iterator constructor_arg_begin() {
757cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl    return SubExprs + Array + getNumPlacementArgs();
7584c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  }
7594c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  arg_iterator constructor_arg_end() {
760cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl    return SubExprs + Array + getNumPlacementArgs() + getNumConstructorArgs();
7614c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  }
7624c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  const_arg_iterator constructor_arg_begin() const {
763cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl    return SubExprs + Array + getNumPlacementArgs();
7644c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  }
7654c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  const_arg_iterator constructor_arg_end() const {
766cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl    return SubExprs + Array + getNumPlacementArgs() + getNumConstructorArgs();
7674c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  }
7684c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
7694c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  virtual SourceRange getSourceRange() const {
7704c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl    return SourceRange(StartLoc, EndLoc);
7714c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  }
7724c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
7734c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  static bool classof(const Stmt *T) {
7744c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl    return T->getStmtClass() == CXXNewExprClass;
7754c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  }
7764c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  static bool classof(const CXXNewExpr *) { return true; }
7774c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
7784c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  // Iterators
7794c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  virtual child_iterator child_begin();
7804c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  virtual child_iterator child_end();
7814c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl};
7824c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
7834c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl/// CXXDeleteExpr - A delete expression for memory deallocation and destructor
7844c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl/// calls, e.g. "delete[] pArray".
7854c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redlclass CXXDeleteExpr : public Expr {
7864c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  // Is this a forced global delete, i.e. "::delete"?
7874c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  bool GlobalDelete : 1;
7884c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  // Is this the array form of delete, i.e. "delete[]"?
7894c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  bool ArrayForm : 1;
7904c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  // Points to the operator delete overload that is used. Could be a member.
7914c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  FunctionDecl *OperatorDelete;
7924c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  // The pointer expression to be deleted.
7934c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  Stmt *Argument;
7944c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  // Location of the expression.
7954c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  SourceLocation Loc;
7964c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redlpublic:
7974c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  CXXDeleteExpr(QualType ty, bool globalDelete, bool arrayForm,
7984c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl                FunctionDecl *operatorDelete, Expr *arg, SourceLocation loc)
7992850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl    : Expr(CXXDeleteExprClass, ty, false, false), GlobalDelete(globalDelete),
8004c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl      ArrayForm(arrayForm), OperatorDelete(operatorDelete), Argument(arg),
8014c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl      Loc(loc) { }
8024c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
8034c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  bool isGlobalDelete() const { return GlobalDelete; }
8044c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  bool isArrayForm() const { return ArrayForm; }
8054c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
8064c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  FunctionDecl *getOperatorDelete() const { return OperatorDelete; }
8074c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
8084c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  Expr *getArgument() { return cast<Expr>(Argument); }
8094c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  const Expr *getArgument() const { return cast<Expr>(Argument); }
8104c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
8114c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  virtual SourceRange getSourceRange() const {
8124c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl    return SourceRange(Loc, Argument->getLocEnd());
8134c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  }
8144c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
8154c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  static bool classof(const Stmt *T) {
8164c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl    return T->getStmtClass() == CXXDeleteExprClass;
8174c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  }
8184c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  static bool classof(const CXXDeleteExpr *) { return true; }
8194c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
8204c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  // Iterators
8214c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  virtual child_iterator child_begin();
8224c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  virtual child_iterator child_end();
8234c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl};
8244c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
82517330019f05966762bc952840ef1926b9becb145Douglas Gregor/// \brief Represents the name of a function that has not been
82617330019f05966762bc952840ef1926b9becb145Douglas Gregor/// resolved to any declaration.
82717330019f05966762bc952840ef1926b9becb145Douglas Gregor///
82817330019f05966762bc952840ef1926b9becb145Douglas Gregor/// Unresolved function names occur when a function name is
82917330019f05966762bc952840ef1926b9becb145Douglas Gregor/// encountered prior to an open parentheses ('(') in a C++ function
83017330019f05966762bc952840ef1926b9becb145Douglas Gregor/// call, and the function name itself did not resolve to a
83117330019f05966762bc952840ef1926b9becb145Douglas Gregor/// declaration. These function names can only be resolved when they
83217330019f05966762bc952840ef1926b9becb145Douglas Gregor/// form the postfix-expression of a function call, so that
83317330019f05966762bc952840ef1926b9becb145Douglas Gregor/// argument-dependent lookup finds declarations corresponding to
83417330019f05966762bc952840ef1926b9becb145Douglas Gregor/// these functions.
83517330019f05966762bc952840ef1926b9becb145Douglas Gregor
8365c37de788529cd9180f22069970737a7208bd625Douglas Gregor/// @code
8375c37de788529cd9180f22069970737a7208bd625Douglas Gregor/// template<typename T> void f(T x) {
83817330019f05966762bc952840ef1926b9becb145Douglas Gregor///   g(x); // g is an unresolved function name (that is also a dependent name)
8395c37de788529cd9180f22069970737a7208bd625Douglas Gregor/// }
8405c37de788529cd9180f22069970737a7208bd625Douglas Gregor/// @endcode
84117330019f05966762bc952840ef1926b9becb145Douglas Gregorclass UnresolvedFunctionNameExpr : public Expr {
84217330019f05966762bc952840ef1926b9becb145Douglas Gregor  /// The name that was present in the source
84317330019f05966762bc952840ef1926b9becb145Douglas Gregor  DeclarationName Name;
8445c37de788529cd9180f22069970737a7208bd625Douglas Gregor
84517330019f05966762bc952840ef1926b9becb145Douglas Gregor  /// The location of this name in the source code
8465c37de788529cd9180f22069970737a7208bd625Douglas Gregor  SourceLocation Loc;
8475c37de788529cd9180f22069970737a7208bd625Douglas Gregor
8485c37de788529cd9180f22069970737a7208bd625Douglas Gregorpublic:
84917330019f05966762bc952840ef1926b9becb145Douglas Gregor  UnresolvedFunctionNameExpr(DeclarationName N, QualType T, SourceLocation L)
85017330019f05966762bc952840ef1926b9becb145Douglas Gregor    : Expr(UnresolvedFunctionNameExprClass, T, false, false), Name(N), Loc(L) { }
8515c37de788529cd9180f22069970737a7208bd625Douglas Gregor
85217330019f05966762bc952840ef1926b9becb145Douglas Gregor  /// \brief Retrieves the name that occurred in the source code.
85317330019f05966762bc952840ef1926b9becb145Douglas Gregor  DeclarationName getName() const { return Name; }
8545c37de788529cd9180f22069970737a7208bd625Douglas Gregor
8555c37de788529cd9180f22069970737a7208bd625Douglas Gregor  /// getLocation - Retrieves the location in the source code where
8565c37de788529cd9180f22069970737a7208bd625Douglas Gregor  /// the name occurred.
8575c37de788529cd9180f22069970737a7208bd625Douglas Gregor  SourceLocation getLocation() const { return Loc; }
8585c37de788529cd9180f22069970737a7208bd625Douglas Gregor
8595c37de788529cd9180f22069970737a7208bd625Douglas Gregor  virtual SourceRange getSourceRange() const { return SourceRange(Loc); }
8605c37de788529cd9180f22069970737a7208bd625Douglas Gregor
8614a2487aeacf9f35ce553318c2eb39c20ec23845eDouglas Gregor  UnresolvedFunctionNameExpr* Clone(ASTContext &C) const;
8624a2487aeacf9f35ce553318c2eb39c20ec23845eDouglas Gregor
8635c37de788529cd9180f22069970737a7208bd625Douglas Gregor  static bool classof(const Stmt *T) {
86417330019f05966762bc952840ef1926b9becb145Douglas Gregor    return T->getStmtClass() == UnresolvedFunctionNameExprClass;
8655c37de788529cd9180f22069970737a7208bd625Douglas Gregor  }
86617330019f05966762bc952840ef1926b9becb145Douglas Gregor  static bool classof(const UnresolvedFunctionNameExpr *) { return true; }
8675c37de788529cd9180f22069970737a7208bd625Douglas Gregor
8685c37de788529cd9180f22069970737a7208bd625Douglas Gregor  // Iterators
8695c37de788529cd9180f22069970737a7208bd625Douglas Gregor  virtual child_iterator child_begin();
8705c37de788529cd9180f22069970737a7208bd625Douglas Gregor  virtual child_iterator child_end();
8715c37de788529cd9180f22069970737a7208bd625Douglas Gregor};
8725c37de788529cd9180f22069970737a7208bd625Douglas Gregor
87364b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl/// UnaryTypeTraitExpr - A GCC or MS unary type trait, as used in the
87464b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl/// implementation of TR1/C++0x type trait templates.
87564b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl/// Example:
87664b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl/// __is_pod(int) == true
87764b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl/// __is_enum(std::string) == false
87864b45f7e0d3167f040841ac2920aead7f080730dSebastian Redlclass UnaryTypeTraitExpr : public Expr {
87964b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl  /// UTT - The trait.
88064b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl  UnaryTypeTrait UTT;
88164b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl
88264b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl  /// Loc - The location of the type trait keyword.
88364b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl  SourceLocation Loc;
88464b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl
88564b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl  /// RParen - The location of the closing paren.
88664b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl  SourceLocation RParen;
88764b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl
88864b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl  /// QueriedType - The type we're testing.
88964b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl  QualType QueriedType;
89064b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl
89164b45f7e0d3167f040841ac2920aead7f080730dSebastian Redlpublic:
89264b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl  UnaryTypeTraitExpr(SourceLocation loc, UnaryTypeTrait utt, QualType queried,
89364b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl                     SourceLocation rparen, QualType ty)
89464b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl    : Expr(UnaryTypeTraitExprClass, ty, false, queried->isDependentType()),
89564b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl      UTT(utt), Loc(loc), RParen(rparen), QueriedType(queried) { }
89664b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl
89764b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl  virtual SourceRange getSourceRange() const { return SourceRange(Loc, RParen);}
89864b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl
89964b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl  UnaryTypeTrait getTrait() const { return UTT; }
90064b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl
90164b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl  QualType getQueriedType() const { return QueriedType; }
90264b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl
903c87a282e7b80c055088fc51bdbe8fc73da64d4f8Daniel Dunbar  bool EvaluateTrait() const;
90464b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl
90564b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl  static bool classof(const Stmt *T) {
90664b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl    return T->getStmtClass() == UnaryTypeTraitExprClass;
90764b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl  }
90864b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl  static bool classof(const UnaryTypeTraitExpr *) { return true; }
90964b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl
91064b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl  // Iterators
91164b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl  virtual child_iterator child_begin();
91264b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl  virtual child_iterator child_end();
91364b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl};
91464b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl
9151a49af9681c350fef58e677f85ccb9a77e8e9d0aDouglas Gregor/// QualifiedDeclRefExpr - A reference to a declared variable,
9161a49af9681c350fef58e677f85ccb9a77e8e9d0aDouglas Gregor/// function, enum, etc., that includes a qualification, e.g.,
9171a49af9681c350fef58e677f85ccb9a77e8e9d0aDouglas Gregor/// "N::foo".
9181a49af9681c350fef58e677f85ccb9a77e8e9d0aDouglas Gregorclass QualifiedDeclRefExpr : public DeclRefExpr {
919bad351822117eaf280081494e3dbe4a06c0dbfcfDouglas Gregor  /// QualifierRange - The source range that covers the
920bad351822117eaf280081494e3dbe4a06c0dbfcfDouglas Gregor  /// nested-name-specifier.
921bad351822117eaf280081494e3dbe4a06c0dbfcfDouglas Gregor  SourceRange QualifierRange;
922bad351822117eaf280081494e3dbe4a06c0dbfcfDouglas Gregor
923ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor  /// \brief The nested-name-specifier that qualifies this declaration
924ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor  /// name.
925ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor  NestedNameSpecifier *NNS;
926bad351822117eaf280081494e3dbe4a06c0dbfcfDouglas Gregor
927bad351822117eaf280081494e3dbe4a06c0dbfcfDouglas Gregorpublic:
928ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor  QualifiedDeclRefExpr(NamedDecl *d, QualType t, SourceLocation l, bool TD,
929ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor                       bool VD, SourceRange R, NestedNameSpecifier *NNS)
930ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor    : DeclRefExpr(QualifiedDeclRefExprClass, d, t, l, TD, VD),
931ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor      QualifierRange(R), NNS(NNS) { }
932bad351822117eaf280081494e3dbe4a06c0dbfcfDouglas Gregor
933bad351822117eaf280081494e3dbe4a06c0dbfcfDouglas Gregor  /// \brief Retrieve the source range of the nested-name-specifier.
934bad351822117eaf280081494e3dbe4a06c0dbfcfDouglas Gregor  SourceRange getQualifierRange() const { return QualifierRange; }
935bad351822117eaf280081494e3dbe4a06c0dbfcfDouglas Gregor
936ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor  /// \brief Retrieve the nested-name-specifier that qualifies this
937ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor  /// declaration.
938ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor  NestedNameSpecifier *getQualifier() const { return NNS; }
9391a49af9681c350fef58e677f85ccb9a77e8e9d0aDouglas Gregor
9401a49af9681c350fef58e677f85ccb9a77e8e9d0aDouglas Gregor  virtual SourceRange getSourceRange() const {
941bad351822117eaf280081494e3dbe4a06c0dbfcfDouglas Gregor    return SourceRange(QualifierRange.getBegin(), getLocation());
9421a49af9681c350fef58e677f85ccb9a77e8e9d0aDouglas Gregor  }
9431a49af9681c350fef58e677f85ccb9a77e8e9d0aDouglas Gregor
9441a49af9681c350fef58e677f85ccb9a77e8e9d0aDouglas Gregor  static bool classof(const Stmt *T) {
9451a49af9681c350fef58e677f85ccb9a77e8e9d0aDouglas Gregor    return T->getStmtClass() == QualifiedDeclRefExprClass;
9461a49af9681c350fef58e677f85ccb9a77e8e9d0aDouglas Gregor  }
9471a49af9681c350fef58e677f85ccb9a77e8e9d0aDouglas Gregor  static bool classof(const QualifiedDeclRefExpr *) { return true; }
9481a49af9681c350fef58e677f85ccb9a77e8e9d0aDouglas Gregor};
9491a49af9681c350fef58e677f85ccb9a77e8e9d0aDouglas Gregor
9505953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor/// \brief A qualified reference to a name whose declaration cannot
9515953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor/// yet be resolved.
9525953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor///
9535953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor/// UnresolvedDeclRefExpr is similar to QualifiedDeclRefExpr in that
9545953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor/// it expresses a qualified reference to a declaration such as
9555953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor/// X<T>::value. The difference, however, is that an
9565953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor/// UnresolvedDeclRefExpr node is used only within C++ templates when
9575953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor/// the qualification (e.g., X<T>::) refers to a dependent type. In
9585953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor/// this case, X<T>::value cannot resolve to a declaration because the
9595953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor/// declaration will differ from on instantiation of X<T> to the
960ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor/// next. Therefore, UnresolvedDeclRefExpr keeps track of the
961ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor/// qualifier (X<T>::) and the name of the entity being referenced
962ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor/// ("value"). Such expressions will instantiate to
963ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor/// QualifiedDeclRefExprs.
9645953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregorclass UnresolvedDeclRefExpr : public Expr {
9655953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor  /// The name of the entity we will be referencing.
9665953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor  DeclarationName Name;
9675953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor
9685953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor  /// Location of the name of the declaration we're referencing.
9695953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor  SourceLocation Loc;
9705953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor
9715953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor  /// QualifierRange - The source range that covers the
9725953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor  /// nested-name-specifier.
9735953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor  SourceRange QualifierRange;
9745953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor
975ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor  /// \brief The nested-name-specifier that qualifies this unresolved
976ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor  /// declaration name.
977ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor  NestedNameSpecifier *NNS;
9785953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor
9795953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregorpublic:
980ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor  UnresolvedDeclRefExpr(DeclarationName N, QualType T, SourceLocation L,
981ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor                        SourceRange R, NestedNameSpecifier *NNS)
982ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor    : Expr(UnresolvedDeclRefExprClass, T, true, true),
983ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor      Name(N), Loc(L), QualifierRange(R), NNS(NNS) { }
9845953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor
9855953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor  /// \brief Retrieve the name that this expression refers to.
9865953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor  DeclarationName getDeclName() const { return Name; }
9875953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor
9885953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor  /// \brief Retrieve the location of the name within the expression.
9895953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor  SourceLocation getLocation() const { return Loc; }
9905953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor
9915953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor  /// \brief Retrieve the source range of the nested-name-specifier.
9925953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor  SourceRange getQualifierRange() const { return QualifierRange; }
9935953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor
994ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor  /// \brief Retrieve the nested-name-specifier that qualifies this
995ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor  /// declaration.
996ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor  NestedNameSpecifier *getQualifier() const { return NNS; }
9975953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor
9985953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor  virtual SourceRange getSourceRange() const {
9995953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor    return SourceRange(QualifierRange.getBegin(), getLocation());
10005953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor  }
10015953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor
10025953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor  static bool classof(const Stmt *T) {
10035953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor    return T->getStmtClass() == UnresolvedDeclRefExprClass;
10045953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor  }
10055953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor  static bool classof(const UnresolvedDeclRefExpr *) { return true; }
10065953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor
10075953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor  virtual StmtIterator child_begin();
10085953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor  virtual StmtIterator child_end();
10095953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor};
10105953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor
10112d44e8a41de8a33c0f04ac198714f71dc841bab0Anders Carlssonclass CXXExprWithTemporaries : public Expr {
101202bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson  Stmt *SubExpr;
101302bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson
101402bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson  CXXTempVarDecl **Decls;
101502bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson  unsigned NumDecls;
101602bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson
101702bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlssonpublic:
10182d44e8a41de8a33c0f04ac198714f71dc841bab0Anders Carlsson  CXXExprWithTemporaries(Expr *subexpr, CXXTempVarDecl **decls,
10192d44e8a41de8a33c0f04ac198714f71dc841bab0Anders Carlsson                         unsigned numdecls);
10202d44e8a41de8a33c0f04ac198714f71dc841bab0Anders Carlsson  ~CXXExprWithTemporaries();
102102bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson
102202bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson  const Expr *getSubExpr() const { return cast<Expr>(SubExpr); }
102302bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson  Expr *getSubExpr() { return cast<Expr>(SubExpr); }
102402bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson
102502bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson  virtual SourceRange getSourceRange() const { return SourceRange(); }
102602bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson
102702bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson  // Implement isa/cast/dyncast/etc.
102802bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson  static bool classof(const Stmt *T) {
10292d44e8a41de8a33c0f04ac198714f71dc841bab0Anders Carlsson    return T->getStmtClass() == CXXExprWithTemporariesClass;
103002bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson  }
10312d44e8a41de8a33c0f04ac198714f71dc841bab0Anders Carlsson  static bool classof(const CXXExprWithTemporaries *) { return true; }
103202bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson
103302bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson  // Iterators
103402bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson  virtual child_iterator child_begin();
103502bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson  virtual child_iterator child_end();
103602bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson};
103702bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson
1038d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// \brief Describes an explicit type conversion that uses functional
1039d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// notion but could not be resolved because one or more arguments are
1040d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// type-dependent.
1041d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor///
1042d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// The explicit type conversions expressed by
1043d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// CXXUnresolvedConstructExpr have the form \c T(a1, a2, ..., aN),
1044d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// where \c T is some type and \c a1, a2, ..., aN are values, and
1045d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// either \C T is a dependent type or one or more of the \c a's is
1046d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// type-dependent. For example, this would occur in a template such
1047d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// as:
1048d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor///
1049d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// \code
1050d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor///   template<typename T, typename A1>
1051d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor///   inline T make_a(const A1& a1) {
1052d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor///     return T(a1);
1053d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor///   }
1054d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// \endcode
1055d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor///
1056d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// When the returned expression is instantiated, it may resolve to a
1057d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// constructor call, conversion function call, or some kind of type
1058d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// conversion.
1059d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregorclass CXXUnresolvedConstructExpr : public Expr {
1060d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  /// \brief The starting location of the type
1061d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  SourceLocation TyBeginLoc;
1062d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor
1063d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  /// \brief The type being constructed.
1064d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  QualType Type;
1065d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor
1066d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  /// \brief The location of the left parentheses ('(').
1067d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  SourceLocation LParenLoc;
1068d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor
1069d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  /// \brief The location of the right parentheses (')').
1070d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  SourceLocation RParenLoc;
1071d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor
1072d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  /// \brief The number of arguments used to construct the type.
1073d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  unsigned NumArgs;
1074d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor
1075d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  CXXUnresolvedConstructExpr(SourceLocation TyBegin,
1076d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor                             QualType T,
1077d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor                             SourceLocation LParenLoc,
1078d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor                             Expr **Args,
1079d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor                             unsigned NumArgs,
1080d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor                             SourceLocation RParenLoc);
1081d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor
1082d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregorpublic:
1083d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  static CXXUnresolvedConstructExpr *Create(ASTContext &C,
1084d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor                                            SourceLocation TyBegin,
1085d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor                                            QualType T,
1086d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor                                            SourceLocation LParenLoc,
1087d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor                                            Expr **Args,
1088d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor                                            unsigned NumArgs,
1089d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor                                            SourceLocation RParenLoc);
1090d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor
1091d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  /// \brief Retrieve the source location where the type begins.
1092d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  SourceLocation getTypeBeginLoc() const { return TyBeginLoc; }
1093d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  void setTypeBeginLoc(SourceLocation L) { TyBeginLoc = L; }
1094d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor
1095d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  /// \brief Retrieve the type that is being constructed, as specified
1096d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  /// in the source code.
1097d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  QualType getTypeAsWritten() const { return Type; }
1098d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  void setTypeAsWritten(QualType T) { Type = T; }
1099d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor
1100d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  /// \brief Retrieve the location of the left parentheses ('(') that
1101d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  /// precedes the argument list.
1102d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  SourceLocation getLParenLoc() const { return LParenLoc; }
1103d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  void setLParenLoc(SourceLocation L) { LParenLoc = L; }
1104d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor
1105d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  /// \brief Retrieve the location of the right parentheses (')') that
1106d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  /// follows the argument list.
1107d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  SourceLocation getRParenLoc() const { return RParenLoc; }
1108d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  void setRParenLoc(SourceLocation L) { RParenLoc = L; }
1109d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor
1110d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  /// \brief Retrieve the number of arguments.
1111d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  unsigned arg_size() const { return NumArgs; }
1112d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor
1113d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  typedef Expr** arg_iterator;
1114d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  arg_iterator arg_begin() { return reinterpret_cast<Expr**>(this + 1); }
1115d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  arg_iterator arg_end() { return arg_begin() + NumArgs; }
1116d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor
1117d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  Expr *getArg(unsigned I) {
1118d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor    assert(I < NumArgs && "Argument index out-of-range");
1119d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor    return *(arg_begin() + I);
1120d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  }
1121d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor
1122d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  virtual SourceRange getSourceRange() const {
1123d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor    return SourceRange(TyBeginLoc, RParenLoc);
1124d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  }
1125d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  static bool classof(const Stmt *T) {
1126d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor    return T->getStmtClass() == CXXUnresolvedConstructExprClass;
1127d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  }
1128d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  static bool classof(const CXXUnresolvedConstructExpr *) { return true; }
1129d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor
1130d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  // Iterators
1131d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  virtual child_iterator child_begin();
1132d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  virtual child_iterator child_end();
1133d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor};
1134d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor
11351c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor/// \brief
11361c0ca59416999129d0439c2661d137ef38e86209Douglas Gregorclass CXXUnresolvedMemberExpr : public Expr {
11371c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  /// \brief The expression for the base pointer or class reference,
11381c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  /// e.g., the \c x in x.f.
11391c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  Stmt *Base;
11401c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor
11411c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  /// \brief Whether this member expression used the '->' operator or
11421c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  /// the '.' operator.
11431c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  bool IsArrow;
11441c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor
11451c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  /// \brief The location of the '->' or '.' operator.
11461c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  SourceLocation OperatorLoc;
11471c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor
11481c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  /// \brief The member to which this member expression refers, which
11491c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  /// can be name, overloaded operator, or destructor.
11501c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  /// FIXME: could also be a template-id, and we might have a
11511c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  /// nested-name-specifier as well.
11521c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  DeclarationName Member;
11531c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor
11541c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  /// \brief The location of the member name.
11551c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  SourceLocation MemberLoc;
11561c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor
11571c0ca59416999129d0439c2661d137ef38e86209Douglas Gregorpublic:
11581c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  CXXUnresolvedMemberExpr(ASTContext &C,
11591c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor                          Expr *Base, bool IsArrow,
11601c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor                          SourceLocation OperatorLoc,
11611c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor                          DeclarationName Member,
11621c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor                          SourceLocation MemberLoc)
11631c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor    : Expr(CXXUnresolvedMemberExprClass, C.DependentTy, true, true),
11641c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor      Base(Base), IsArrow(IsArrow), OperatorLoc(OperatorLoc),
11651c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor      Member(Member), MemberLoc(MemberLoc) { }
11661c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor
11671c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  /// \brief Retrieve the base object of this member expressions,
11681c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  /// e.g., the \c x in \c x.m.
11691c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  Expr *getBase() { return cast<Expr>(Base); }
11701c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  void setBase(Expr *E) { Base = E; }
11711c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor
11721c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  /// \brief Determine whether this member expression used the '->'
11731c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  /// operator; otherwise, it used the '.' operator.
11741c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  bool isArrow() const { return IsArrow; }
11751c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  void setArrow(bool A) { IsArrow = A; }
11761c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor
11771c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  /// \brief Retrieve the location of the '->' or '.' operator.
11781c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  SourceLocation getOperatorLoc() const { return OperatorLoc; }
11791c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  void setOperatorLoc(SourceLocation L) { OperatorLoc = L; }
11801c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor
11811c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  /// \brief Retrieve the name of the member that this expression
11821c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  /// refers to.
11831c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  DeclarationName getMember() const { return Member; }
11841c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  void setMember(DeclarationName N) { Member = N; }
11851c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor
11861c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  // \brief Retrieve the location of the name of the member that this
11871c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  // expression refers to.
11881c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  SourceLocation getMemberLoc() const { return MemberLoc; }
11891c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  void setMemberLoc(SourceLocation L) { MemberLoc = L; }
11901c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor
11911c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  virtual SourceRange getSourceRange() const {
11921c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor    return SourceRange(Base->getSourceRange().getBegin(),
11931c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor                       MemberLoc);
11941c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  }
11951c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  static bool classof(const Stmt *T) {
11961c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor    return T->getStmtClass() == CXXUnresolvedMemberExprClass;
11971c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  }
11981c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  static bool classof(const CXXUnresolvedMemberExpr *) { return true; }
11991c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor
12001c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  // Iterators
12011c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  virtual child_iterator child_begin();
12021c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  virtual child_iterator child_end();
12031c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor};
12041c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor
12055f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer}  // end namespace clang
12065f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer
12075f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer#endif
1208