ExprCXX.h revision dfa1edbebeda7ec3a7a9c45e4317de9241aa9883
15f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer//===--- ExprCXX.h - Classes for representing expressions -------*- C++ -*-===//
25f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer//
35f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer//                     The LLVM Compiler Infrastructure
45f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer//
50bc735ffcfb223c0186419547abaa5c84482663eChris Lattner// This file is distributed under the University of Illinois Open Source
60bc735ffcfb223c0186419547abaa5c84482663eChris Lattner// License. See LICENSE.TXT for details.
75f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer//
85f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer//===----------------------------------------------------------------------===//
95f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer//
105f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer//  This file defines the Expr interface and subclasses for C++ expressions.
115f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer//
125f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer//===----------------------------------------------------------------------===//
135f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer
145f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer#ifndef LLVM_CLANG_AST_EXPRCXX_H
155f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer#define LLVM_CLANG_AST_EXPRCXX_H
165f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer
1764b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl#include "clang/Basic/TypeTraits.h"
185f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer#include "clang/AST/Expr.h"
19eec51cf1ba5f0e62c9cdb81b5c63babdd6e649abJohn McCall#include "clang/AST/UnresolvedSet.h"
20d5532b6cfff2977e0c59fa6ead7f7973984a620dJohn McCall#include "clang/AST/TemplateBase.h"
215f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer
225f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencernamespace clang {
235f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer
244c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  class CXXConstructorDecl;
25c1ce477119fed070299668aab24084b17ff5f14bAnders Carlsson  class CXXDestructorDecl;
26e9f42087aabfdb6b2afc35c7e38ac65da063b409Fariborz Jahanian  class CXXMethodDecl;
27ff6b3d64c9f07155f1414411b8451d7bf8937c62Anders Carlsson  class CXXTemporary;
28d5532b6cfff2977e0c59fa6ead7f7973984a620dJohn McCall  class TemplateArgumentListInfo;
294c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
301060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek//===--------------------------------------------------------------------===//
311060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek// C++ Expressions.
321060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek//===--------------------------------------------------------------------===//
331060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek
343fd95ce225393fe4a3623e429766a8c3f487ff9dDouglas Gregor/// \brief A call to an overloaded operator written using operator
353fd95ce225393fe4a3623e429766a8c3f487ff9dDouglas Gregor/// syntax.
363fd95ce225393fe4a3623e429766a8c3f487ff9dDouglas Gregor///
373fd95ce225393fe4a3623e429766a8c3f487ff9dDouglas Gregor/// Represents a call to an overloaded operator written using operator
383fd95ce225393fe4a3623e429766a8c3f487ff9dDouglas Gregor/// syntax, e.g., "x + y" or "*p". While semantically equivalent to a
393fd95ce225393fe4a3623e429766a8c3f487ff9dDouglas Gregor/// normal call, this AST node provides better information about the
403fd95ce225393fe4a3623e429766a8c3f487ff9dDouglas Gregor/// syntactic representation of the call.
413fd95ce225393fe4a3623e429766a8c3f487ff9dDouglas Gregor///
423fd95ce225393fe4a3623e429766a8c3f487ff9dDouglas Gregor/// In a C++ template, this expression node kind will be used whenever
433fd95ce225393fe4a3623e429766a8c3f487ff9dDouglas Gregor/// any of the arguments are type-dependent. In this case, the
443fd95ce225393fe4a3623e429766a8c3f487ff9dDouglas Gregor/// function itself will be a (possibly empty) set of functions and
453fd95ce225393fe4a3623e429766a8c3f487ff9dDouglas Gregor/// function templates that were found by name lookup at template
463fd95ce225393fe4a3623e429766a8c3f487ff9dDouglas Gregor/// definition time.
47b4609806e9232593ece09ce08b630836e825865cDouglas Gregorclass CXXOperatorCallExpr : public CallExpr {
48063daf6e196c51f162e0485478355d8e280eef5cDouglas Gregor  /// \brief The overloaded operator.
49063daf6e196c51f162e0485478355d8e280eef5cDouglas Gregor  OverloadedOperatorKind Operator;
50063daf6e196c51f162e0485478355d8e280eef5cDouglas Gregor
51b4609806e9232593ece09ce08b630836e825865cDouglas Gregorpublic:
521eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  CXXOperatorCallExpr(ASTContext& C, OverloadedOperatorKind Op, Expr *fn,
531eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump                      Expr **args, unsigned numargs, QualType t,
54f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall                      ExprValueKind VK, SourceLocation operatorloc)
55f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall    : CallExpr(C, CXXOperatorCallExprClass, fn, args, numargs, t, VK,
56f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall               operatorloc),
57063daf6e196c51f162e0485478355d8e280eef5cDouglas Gregor      Operator(Op) {}
581eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  explicit CXXOperatorCallExpr(ASTContext& C, EmptyShell Empty) :
59ba0a9006dbc4814e1e35f82812cb5a1dad65e8b8Argyrios Kyrtzidis    CallExpr(C, CXXOperatorCallExprClass, Empty) { }
601eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
61b4609806e9232593ece09ce08b630836e825865cDouglas Gregor
62b4609806e9232593ece09ce08b630836e825865cDouglas Gregor  /// getOperator - Returns the kind of overloaded operator that this
63b4609806e9232593ece09ce08b630836e825865cDouglas Gregor  /// expression refers to.
64063daf6e196c51f162e0485478355d8e280eef5cDouglas Gregor  OverloadedOperatorKind getOperator() const { return Operator; }
65ba0a9006dbc4814e1e35f82812cb5a1dad65e8b8Argyrios Kyrtzidis  void setOperator(OverloadedOperatorKind Kind) { Operator = Kind; }
66b4609806e9232593ece09ce08b630836e825865cDouglas Gregor
67b4609806e9232593ece09ce08b630836e825865cDouglas Gregor  /// getOperatorLoc - Returns the location of the operator symbol in
68b4609806e9232593ece09ce08b630836e825865cDouglas Gregor  /// the expression. When @c getOperator()==OO_Call, this is the
69b4609806e9232593ece09ce08b630836e825865cDouglas Gregor  /// location of the right parentheses; when @c
70b4609806e9232593ece09ce08b630836e825865cDouglas Gregor  /// getOperator()==OO_Subscript, this is the location of the right
71b4609806e9232593ece09ce08b630836e825865cDouglas Gregor  /// bracket.
72b4609806e9232593ece09ce08b630836e825865cDouglas Gregor  SourceLocation getOperatorLoc() const { return getRParenLoc(); }
73b4609806e9232593ece09ce08b630836e825865cDouglas Gregor
74b4609806e9232593ece09ce08b630836e825865cDouglas Gregor  virtual SourceRange getSourceRange() const;
751eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
761eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  static bool classof(const Stmt *T) {
771eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump    return T->getStmtClass() == CXXOperatorCallExprClass;
78b4609806e9232593ece09ce08b630836e825865cDouglas Gregor  }
79b4609806e9232593ece09ce08b630836e825865cDouglas Gregor  static bool classof(const CXXOperatorCallExpr *) { return true; }
80b4609806e9232593ece09ce08b630836e825865cDouglas Gregor};
81b4609806e9232593ece09ce08b630836e825865cDouglas Gregor
8288a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor/// CXXMemberCallExpr - Represents a call to a member function that
8388a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor/// may be written either with member call syntax (e.g., "obj.func()"
8488a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor/// or "objptr->func()") or with normal function-call syntax
8588a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor/// ("func()") within a member function that ends up calling a member
8688a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor/// function. The callee in either case is a MemberExpr that contains
8788a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor/// both the object argument and the member function, while the
8888a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor/// arguments are the arguments within the parentheses (not including
8988a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor/// the object argument).
9088a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregorclass CXXMemberCallExpr : public CallExpr {
9188a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregorpublic:
921817bd483b538fd3f4530649f5cb900bad9e8a76Chris Lattner  CXXMemberCallExpr(ASTContext &C, Expr *fn, Expr **args, unsigned numargs,
93f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall                    QualType t, ExprValueKind VK, SourceLocation RP)
94f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall    : CallExpr(C, CXXMemberCallExprClass, fn, args, numargs, t, VK, RP) {}
9588a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor
961817bd483b538fd3f4530649f5cb900bad9e8a76Chris Lattner  CXXMemberCallExpr(ASTContext &C, EmptyShell Empty)
971817bd483b538fd3f4530649f5cb900bad9e8a76Chris Lattner    : CallExpr(C, CXXMemberCallExprClass, Empty) { }
981817bd483b538fd3f4530649f5cb900bad9e8a76Chris Lattner
9988a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor  /// getImplicitObjectArgument - Retrieves the implicit object
10088a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor  /// argument for the member call. For example, in "x.f(5)", this
10188a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor  /// operation would return "x".
10288a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor  Expr *getImplicitObjectArgument();
10388a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor
104007a9b1c632bfaac20e41c60cbe07fdc6d0e647cChandler Carruth  /// getRecordDecl - Retrieves the CXXRecordDecl for the underlying type of
105007a9b1c632bfaac20e41c60cbe07fdc6d0e647cChandler Carruth  /// the implicit object argument. Note that this is may not be the same
106007a9b1c632bfaac20e41c60cbe07fdc6d0e647cChandler Carruth  /// declaration as that of the class context of the CXXMethodDecl which this
107007a9b1c632bfaac20e41c60cbe07fdc6d0e647cChandler Carruth  /// function is calling.
108007a9b1c632bfaac20e41c60cbe07fdc6d0e647cChandler Carruth  /// FIXME: Returns 0 for member pointer call exprs.
109007a9b1c632bfaac20e41c60cbe07fdc6d0e647cChandler Carruth  CXXRecordDecl *getRecordDecl();
110007a9b1c632bfaac20e41c60cbe07fdc6d0e647cChandler Carruth
11100b98c229ef28a5e82943bb23d09fb46d24ca381Douglas Gregor  virtual SourceRange getSourceRange() const;
11200b98c229ef28a5e82943bb23d09fb46d24ca381Douglas Gregor
1131eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  static bool classof(const Stmt *T) {
11488a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor    return T->getStmtClass() == CXXMemberCallExprClass;
11588a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor  }
11688a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor  static bool classof(const CXXMemberCallExpr *) { return true; }
11788a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor};
11888a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor
11949badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// CXXNamedCastExpr - Abstract class common to all of the C++ "named"
12049badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// casts, @c static_cast, @c dynamic_cast, @c reinterpret_cast, or @c
12149badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// const_cast.
12249badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor///
12349badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// This abstract class is inherited by all of the classes
12449badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// representing "named" casts, e.g., CXXStaticCastExpr,
12549badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// CXXDynamicCastExpr, CXXReinterpretCastExpr, and CXXConstCastExpr.
12649badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregorclass CXXNamedCastExpr : public ExplicitCastExpr {
1271060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenekprivate:
1281060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  SourceLocation Loc; // the location of the casting op
12949badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor
13049badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregorprotected:
131f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall  CXXNamedCastExpr(StmtClass SC, QualType ty, ExprValueKind VK,
132f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall                   CastKind kind, Expr *op, unsigned PathSize,
133f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall                   TypeSourceInfo *writtenTy, SourceLocation l)
134f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall    : ExplicitCastExpr(SC, ty, VK, kind, op, PathSize, writtenTy), Loc(l) {}
13549badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor
136f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall  explicit CXXNamedCastExpr(StmtClass SC, EmptyShell Shell, unsigned PathSize)
137f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall    : ExplicitCastExpr(SC, Shell, PathSize) { }
138ce757a7a1ee905f87551996a69da3e95e8afeeb7Sam Weinig
1391060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenekpublic:
14049badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor  const char *getCastName() const;
14149badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor
142a3a7b8eea87c90a5a257f685749222b212ddaf36Douglas Gregor  /// \brief Retrieve the location of the cast operator keyword, e.g.,
143a3a7b8eea87c90a5a257f685749222b212ddaf36Douglas Gregor  /// "static_cast".
144a3a7b8eea87c90a5a257f685749222b212ddaf36Douglas Gregor  SourceLocation getOperatorLoc() const { return Loc; }
145a3a7b8eea87c90a5a257f685749222b212ddaf36Douglas Gregor  void setOperatorLoc(SourceLocation L) { Loc = L; }
146a3a7b8eea87c90a5a257f685749222b212ddaf36Douglas Gregor
1471060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  virtual SourceRange getSourceRange() const {
1481060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek    return SourceRange(Loc, getSubExpr()->getSourceRange().getEnd());
1491060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  }
1501eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  static bool classof(const Stmt *T) {
15149badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor    switch (T->getStmtClass()) {
15249badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor    case CXXStaticCastExprClass:
15349badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor    case CXXDynamicCastExprClass:
15449badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor    case CXXReinterpretCastExprClass:
15549badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor    case CXXConstCastExprClass:
15649badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor      return true;
15749badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor    default:
15849badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor      return false;
15949badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor    }
1601060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  }
16149badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor  static bool classof(const CXXNamedCastExpr *) { return true; }
16249badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor};
16349badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor
16449badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// CXXStaticCastExpr - A C++ @c static_cast expression (C++ [expr.static.cast]).
1651eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump///
16649badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// This expression node represents a C++ static cast, e.g.,
16749badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// @c static_cast<int>(1.0).
16849badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregorclass CXXStaticCastExpr : public CXXNamedCastExpr {
169f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall  CXXStaticCastExpr(QualType ty, ExprValueKind vk, CastKind kind, Expr *op,
170f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall                    unsigned pathSize, TypeSourceInfo *writtenTy,
17141b2dcd465f1e438502c420effc9d0c747f9db8fAnders Carlsson                    SourceLocation l)
172f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall    : CXXNamedCastExpr(CXXStaticCastExprClass, ty, vk, kind, op, pathSize,
173f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall                       writtenTy, l) {}
17449badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor
175f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall  explicit CXXStaticCastExpr(EmptyShell Empty, unsigned PathSize)
176f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall    : CXXNamedCastExpr(CXXStaticCastExprClass, Empty, PathSize) { }
177f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall
178f871d0cc377a1367b519a6cce26be74607566ebaJohn McCallpublic:
179f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall  static CXXStaticCastExpr *Create(ASTContext &Context, QualType T,
180f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall                                   ExprValueKind VK, CastKind K, Expr *Op,
181f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall                                   const CXXCastPath *Path,
182f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall                                   TypeSourceInfo *Written, SourceLocation L);
183f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall  static CXXStaticCastExpr *CreateEmpty(ASTContext &Context,
184f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall                                        unsigned PathSize);
185ce757a7a1ee905f87551996a69da3e95e8afeeb7Sam Weinig
1861eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  static bool classof(const Stmt *T) {
18749badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor    return T->getStmtClass() == CXXStaticCastExprClass;
18849badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor  }
18949badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor  static bool classof(const CXXStaticCastExpr *) { return true; }
19049badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor};
19149badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor
19249badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// CXXDynamicCastExpr - A C++ @c dynamic_cast expression
1931eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump/// (C++ [expr.dynamic.cast]), which may perform a run-time check to
19449badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// determine how to perform the type cast.
1951eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump///
19649badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// This expression node represents a dynamic cast, e.g.,
19749badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// @c dynamic_cast<Derived*>(BasePtr).
19849badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregorclass CXXDynamicCastExpr : public CXXNamedCastExpr {
199f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall  CXXDynamicCastExpr(QualType ty, ExprValueKind VK, CastKind kind,
200f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall                     Expr *op, unsigned pathSize, TypeSourceInfo *writtenTy,
20141b2dcd465f1e438502c420effc9d0c747f9db8fAnders Carlsson                     SourceLocation l)
202f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall    : CXXNamedCastExpr(CXXDynamicCastExprClass, ty, VK, kind, op, pathSize,
20341b2dcd465f1e438502c420effc9d0c747f9db8fAnders Carlsson                       writtenTy, l) {}
20449badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor
205f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall  explicit CXXDynamicCastExpr(EmptyShell Empty, unsigned pathSize)
206f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall    : CXXNamedCastExpr(CXXDynamicCastExprClass, Empty, pathSize) { }
207f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall
208f871d0cc377a1367b519a6cce26be74607566ebaJohn McCallpublic:
209f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall  static CXXDynamicCastExpr *Create(ASTContext &Context, QualType T,
210f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall                                    ExprValueKind VK, CastKind Kind, Expr *Op,
211f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall                                    const CXXCastPath *Path,
212f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall                                    TypeSourceInfo *Written, SourceLocation L);
213f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall
214f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall  static CXXDynamicCastExpr *CreateEmpty(ASTContext &Context,
215f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall                                         unsigned pathSize);
216ce757a7a1ee905f87551996a69da3e95e8afeeb7Sam Weinig
2171eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  static bool classof(const Stmt *T) {
21849badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor    return T->getStmtClass() == CXXDynamicCastExprClass;
21949badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor  }
22049badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor  static bool classof(const CXXDynamicCastExpr *) { return true; }
22149badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor};
22249badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor
22349badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// CXXReinterpretCastExpr - A C++ @c reinterpret_cast expression (C++
22449badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// [expr.reinterpret.cast]), which provides a differently-typed view
22549badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// of a value but performs no actual work at run time.
2261eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump///
22749badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// This expression node represents a reinterpret cast, e.g.,
22849badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// @c reinterpret_cast<int>(VoidPtr).
22949badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregorclass CXXReinterpretCastExpr : public CXXNamedCastExpr {
230f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall  CXXReinterpretCastExpr(QualType ty, ExprValueKind vk, CastKind kind,
231f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall                         Expr *op, unsigned pathSize,
2329d125033a9853f3b572a4c9e2f9e2d4e5e346973John McCall                         TypeSourceInfo *writtenTy, SourceLocation l)
233f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall    : CXXNamedCastExpr(CXXReinterpretCastExprClass, ty, vk, kind, op,
234f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall                       pathSize, writtenTy, l) {}
23549badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor
236f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall  CXXReinterpretCastExpr(EmptyShell Empty, unsigned pathSize)
237f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall    : CXXNamedCastExpr(CXXReinterpretCastExprClass, Empty, pathSize) { }
238f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall
239f871d0cc377a1367b519a6cce26be74607566ebaJohn McCallpublic:
240f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall  static CXXReinterpretCastExpr *Create(ASTContext &Context, QualType T,
241f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall                                        ExprValueKind VK, CastKind Kind,
242f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall                                        Expr *Op, const CXXCastPath *Path,
243f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall                                 TypeSourceInfo *WrittenTy, SourceLocation L);
244f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall  static CXXReinterpretCastExpr *CreateEmpty(ASTContext &Context,
245f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall                                             unsigned pathSize);
246ce757a7a1ee905f87551996a69da3e95e8afeeb7Sam Weinig
2471eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  static bool classof(const Stmt *T) {
24849badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor    return T->getStmtClass() == CXXReinterpretCastExprClass;
24949badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor  }
25049badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor  static bool classof(const CXXReinterpretCastExpr *) { return true; }
25149badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor};
25249badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor
25349badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// CXXConstCastExpr - A C++ @c const_cast expression (C++ [expr.const.cast]),
25449badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// which can remove type qualifiers but does not change the underlying value.
2551eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump///
25649badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// This expression node represents a const cast, e.g.,
25749badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// @c const_cast<char*>(PtrToConstChar).
25849badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregorclass CXXConstCastExpr : public CXXNamedCastExpr {
259f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall  CXXConstCastExpr(QualType ty, ExprValueKind VK, Expr *op,
260f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall                   TypeSourceInfo *writtenTy, SourceLocation l)
261f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall    : CXXNamedCastExpr(CXXConstCastExprClass, ty, VK, CK_NoOp, op,
262f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall                       0, writtenTy, l) {}
26349badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor
264ce757a7a1ee905f87551996a69da3e95e8afeeb7Sam Weinig  explicit CXXConstCastExpr(EmptyShell Empty)
265f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall    : CXXNamedCastExpr(CXXConstCastExprClass, Empty, 0) { }
266f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall
267f871d0cc377a1367b519a6cce26be74607566ebaJohn McCallpublic:
268f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall  static CXXConstCastExpr *Create(ASTContext &Context, QualType T,
269f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall                                  ExprValueKind VK, Expr *Op,
270f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall                                  TypeSourceInfo *WrittenTy, SourceLocation L);
271f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall  static CXXConstCastExpr *CreateEmpty(ASTContext &Context);
272ce757a7a1ee905f87551996a69da3e95e8afeeb7Sam Weinig
2731eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  static bool classof(const Stmt *T) {
27449badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor    return T->getStmtClass() == CXXConstCastExprClass;
27549badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor  }
27649badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor  static bool classof(const CXXConstCastExpr *) { return true; }
2771060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek};
2781060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek
2791060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek/// CXXBoolLiteralExpr - [C++ 2.13.5] C++ Boolean Literal.
2801eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump///
2811060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenekclass CXXBoolLiteralExpr : public Expr {
2821060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  bool Value;
2831060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  SourceLocation Loc;
2841060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenekpublic:
2851eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  CXXBoolLiteralExpr(bool val, QualType Ty, SourceLocation l) :
286f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall    Expr(CXXBoolLiteralExprClass, Ty, VK_RValue, OK_Ordinary, false, false),
287f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall    Value(val), Loc(l) {}
2888b0b475b3464b0f70b91ba7d679d23c424677d5eSebastian Redl
289eb7f96141f754150a92433286fa385910a22f494Sam Weinig  explicit CXXBoolLiteralExpr(EmptyShell Empty)
290eb7f96141f754150a92433286fa385910a22f494Sam Weinig    : Expr(CXXBoolLiteralExprClass, Empty) { }
291eb7f96141f754150a92433286fa385910a22f494Sam Weinig
2921060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  bool getValue() const { return Value; }
293eb7f96141f754150a92433286fa385910a22f494Sam Weinig  void setValue(bool V) { Value = V; }
2945f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer
2951060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  virtual SourceRange getSourceRange() const { return SourceRange(Loc); }
2961eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
297eb7f96141f754150a92433286fa385910a22f494Sam Weinig  SourceLocation getLocation() const { return Loc; }
298eb7f96141f754150a92433286fa385910a22f494Sam Weinig  void setLocation(SourceLocation L) { Loc = L; }
299eb7f96141f754150a92433286fa385910a22f494Sam Weinig
3001eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  static bool classof(const Stmt *T) {
3011060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek    return T->getStmtClass() == CXXBoolLiteralExprClass;
3021060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  }
3031060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  static bool classof(const CXXBoolLiteralExpr *) { return true; }
3041eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
3051060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  // Iterators
3061060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  virtual child_iterator child_begin();
3071060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  virtual child_iterator child_end();
3081060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek};
3091060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek
3106e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl/// CXXNullPtrLiteralExpr - [C++0x 2.14.7] C++ Pointer Literal
3116e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redlclass CXXNullPtrLiteralExpr : public Expr {
3126e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl  SourceLocation Loc;
3136e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redlpublic:
3146e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl  CXXNullPtrLiteralExpr(QualType Ty, SourceLocation l) :
315f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall    Expr(CXXNullPtrLiteralExprClass, Ty, VK_RValue, OK_Ordinary, false, false),
316f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall    Loc(l) {}
3176e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl
318eb7f96141f754150a92433286fa385910a22f494Sam Weinig  explicit CXXNullPtrLiteralExpr(EmptyShell Empty)
319eb7f96141f754150a92433286fa385910a22f494Sam Weinig    : Expr(CXXNullPtrLiteralExprClass, Empty) { }
320eb7f96141f754150a92433286fa385910a22f494Sam Weinig
3216e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl  virtual SourceRange getSourceRange() const { return SourceRange(Loc); }
3226e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl
323eb7f96141f754150a92433286fa385910a22f494Sam Weinig  SourceLocation getLocation() const { return Loc; }
324eb7f96141f754150a92433286fa385910a22f494Sam Weinig  void setLocation(SourceLocation L) { Loc = L; }
325eb7f96141f754150a92433286fa385910a22f494Sam Weinig
3266e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl  static bool classof(const Stmt *T) {
3276e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl    return T->getStmtClass() == CXXNullPtrLiteralExprClass;
3286e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl  }
3296e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl  static bool classof(const CXXNullPtrLiteralExpr *) { return true; }
3306e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl
3316e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl  virtual child_iterator child_begin();
3326e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl  virtual child_iterator child_end();
3336e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl};
3346e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl
335c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl/// CXXTypeidExpr - A C++ @c typeid expression (C++ [expr.typeid]), which gets
336c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl/// the type_info that corresponds to the supplied type, or the (possibly
337c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl/// dynamic) type of the supplied expression.
338c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl///
339c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl/// This represents code like @c typeid(int) or @c typeid(*objPtr)
340c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redlclass CXXTypeidExpr : public Expr {
341c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redlprivate:
34257fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor  llvm::PointerUnion<Stmt *, TypeSourceInfo *> Operand;
343c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl  SourceRange Range;
344c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl
345c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redlpublic:
34657fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor  CXXTypeidExpr(QualType Ty, TypeSourceInfo *Operand, SourceRange R)
347f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall    : Expr(CXXTypeidExprClass, Ty, VK_LValue, OK_Ordinary,
34857fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor           // typeid is never type-dependent (C++ [temp.dep.expr]p4)
34957fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor           false,
35057fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor           // typeid is value-dependent if the type or expression are dependent
35157fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor           Operand->getType()->isDependentType()),
35257fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor      Operand(Operand), Range(R) { }
35357fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor
35457fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor  CXXTypeidExpr(QualType Ty, Expr *Operand, SourceRange R)
355f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall    : Expr(CXXTypeidExprClass, Ty, VK_LValue, OK_Ordinary,
3562850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl        // typeid is never type-dependent (C++ [temp.dep.expr]p4)
3572850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl        false,
3582850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl        // typeid is value-dependent if the type or expression are dependent
35957fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor        Operand->isTypeDependent() || Operand->isValueDependent()),
36057fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor      Operand(Operand), Range(R) { }
361c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl
36214ab24f01e36d495fce183aa67b41e45cdd54f39Chris Lattner  CXXTypeidExpr(EmptyShell Empty, bool isExpr)
36314ab24f01e36d495fce183aa67b41e45cdd54f39Chris Lattner    : Expr(CXXTypeidExprClass, Empty) {
36414ab24f01e36d495fce183aa67b41e45cdd54f39Chris Lattner    if (isExpr)
36514ab24f01e36d495fce183aa67b41e45cdd54f39Chris Lattner      Operand = (Expr*)0;
36614ab24f01e36d495fce183aa67b41e45cdd54f39Chris Lattner    else
36714ab24f01e36d495fce183aa67b41e45cdd54f39Chris Lattner      Operand = (TypeSourceInfo*)0;
36814ab24f01e36d495fce183aa67b41e45cdd54f39Chris Lattner  }
36914ab24f01e36d495fce183aa67b41e45cdd54f39Chris Lattner
37057fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor  bool isTypeOperand() const { return Operand.is<TypeSourceInfo *>(); }
37157fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor
37257fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor  /// \brief Retrieves the type operand of this typeid() expression after
37357fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor  /// various required adjustments (removing reference types, cv-qualifiers).
37457fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor  QualType getTypeOperand() const;
37557fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor
37657fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor  /// \brief Retrieve source information for the type operand.
37757fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor  TypeSourceInfo *getTypeOperandSourceInfo() const {
378c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl    assert(isTypeOperand() && "Cannot call getTypeOperand for typeid(expr)");
37957fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor    return Operand.get<TypeSourceInfo *>();
380c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl  }
38114ab24f01e36d495fce183aa67b41e45cdd54f39Chris Lattner
38214ab24f01e36d495fce183aa67b41e45cdd54f39Chris Lattner  void setTypeOperandSourceInfo(TypeSourceInfo *TSI) {
38314ab24f01e36d495fce183aa67b41e45cdd54f39Chris Lattner    assert(isTypeOperand() && "Cannot call getTypeOperand for typeid(expr)");
38414ab24f01e36d495fce183aa67b41e45cdd54f39Chris Lattner    Operand = TSI;
38514ab24f01e36d495fce183aa67b41e45cdd54f39Chris Lattner  }
38657fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor
38714ab24f01e36d495fce183aa67b41e45cdd54f39Chris Lattner  Expr *getExprOperand() const {
388c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl    assert(!isTypeOperand() && "Cannot call getExprOperand for typeid(type)");
38957fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor    return static_cast<Expr*>(Operand.get<Stmt *>());
390c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl  }
39114ab24f01e36d495fce183aa67b41e45cdd54f39Chris Lattner
392030854b95f7bfd86aaa8afd9ae1aff9768a37e9aChris Lattner  void setExprOperand(Expr *E) {
393030854b95f7bfd86aaa8afd9ae1aff9768a37e9aChris Lattner    assert(!isTypeOperand() && "Cannot call getExprOperand for typeid(type)");
394030854b95f7bfd86aaa8afd9ae1aff9768a37e9aChris Lattner    Operand = E;
395030854b95f7bfd86aaa8afd9ae1aff9768a37e9aChris Lattner  }
396030854b95f7bfd86aaa8afd9ae1aff9768a37e9aChris Lattner
39714ab24f01e36d495fce183aa67b41e45cdd54f39Chris Lattner  virtual SourceRange getSourceRange() const { return Range; }
39814ab24f01e36d495fce183aa67b41e45cdd54f39Chris Lattner  void setSourceRange(SourceRange R) { Range = R; }
39914ab24f01e36d495fce183aa67b41e45cdd54f39Chris Lattner
400c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl  static bool classof(const Stmt *T) {
401c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl    return T->getStmtClass() == CXXTypeidExprClass;
402c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl  }
403c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl  static bool classof(const CXXTypeidExpr *) { return true; }
404c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl
405c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl  // Iterators
406c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl  virtual child_iterator child_begin();
407c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl  virtual child_iterator child_end();
408c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl};
409c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl
41001b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet/// CXXUuidofExpr - A microsoft C++ @c __uuidof expression, which gets
41101b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet/// the _GUID that corresponds to the supplied type or expression.
41201b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet///
41301b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet/// This represents code like @c __uuidof(COMTYPE) or @c __uuidof(*comPtr)
41401b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichetclass CXXUuidofExpr : public Expr {
41501b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichetprivate:
41601b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet  llvm::PointerUnion<Stmt *, TypeSourceInfo *> Operand;
41701b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet  SourceRange Range;
41801b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet
41901b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichetpublic:
42001b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet  CXXUuidofExpr(QualType Ty, TypeSourceInfo *Operand, SourceRange R)
421f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall    : Expr(CXXUuidofExprClass, Ty, VK_RValue, OK_Ordinary,
42201b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet        false, Operand->getType()->isDependentType()),
42301b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet      Operand(Operand), Range(R) { }
42401b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet
42501b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet  CXXUuidofExpr(QualType Ty, Expr *Operand, SourceRange R)
4260943168ac126b8047f30f6bd215fbe7db14d61baJohn McCall    : Expr(CXXUuidofExprClass, Ty, VK_RValue, OK_Ordinary,
42701b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet        false, Operand->isTypeDependent()),
42801b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet      Operand(Operand), Range(R) { }
42901b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet
43001b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet  CXXUuidofExpr(EmptyShell Empty, bool isExpr)
43101b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet    : Expr(CXXUuidofExprClass, Empty) {
43201b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet    if (isExpr)
43301b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet      Operand = (Expr*)0;
43401b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet    else
43501b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet      Operand = (TypeSourceInfo*)0;
43601b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet  }
43701b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet
43801b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet  bool isTypeOperand() const { return Operand.is<TypeSourceInfo *>(); }
43901b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet
44001b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet  /// \brief Retrieves the type operand of this __uuidof() expression after
44101b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet  /// various required adjustments (removing reference types, cv-qualifiers).
44201b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet  QualType getTypeOperand() const;
44301b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet
44401b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet  /// \brief Retrieve source information for the type operand.
44501b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet  TypeSourceInfo *getTypeOperandSourceInfo() const {
44601b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet    assert(isTypeOperand() && "Cannot call getTypeOperand for __uuidof(expr)");
44701b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet    return Operand.get<TypeSourceInfo *>();
44801b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet  }
44901b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet
45001b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet  void setTypeOperandSourceInfo(TypeSourceInfo *TSI) {
45101b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet    assert(isTypeOperand() && "Cannot call getTypeOperand for __uuidof(expr)");
45201b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet    Operand = TSI;
45301b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet  }
45401b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet
45501b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet  Expr *getExprOperand() const {
45601b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet    assert(!isTypeOperand() && "Cannot call getExprOperand for __uuidof(type)");
45701b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet    return static_cast<Expr*>(Operand.get<Stmt *>());
45801b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet  }
45901b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet
46001b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet  void setExprOperand(Expr *E) {
46101b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet    assert(!isTypeOperand() && "Cannot call getExprOperand for __uuidof(type)");
46201b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet    Operand = E;
46301b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet  }
46401b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet
46501b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet  virtual SourceRange getSourceRange() const { return Range; }
46601b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet  void setSourceRange(SourceRange R) { Range = R; }
46701b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet
46801b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet  static bool classof(const Stmt *T) {
46901b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet    return T->getStmtClass() == CXXUuidofExprClass;
47001b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet  }
47101b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet  static bool classof(const CXXUuidofExpr *) { return true; }
47201b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet
47301b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet  // Iterators
47401b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet  virtual child_iterator child_begin();
47501b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet  virtual child_iterator child_end();
47601b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet};
47701b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet
478796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// CXXThisExpr - Represents the "this" expression in C++, which is a
479796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// pointer to the object on which the current member function is
480796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// executing (C++ [expr.prim]p3). Example:
481796da18402f286b897782a298ae3b20c459c102eDouglas Gregor///
482796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// @code
483796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// class Foo {
484796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// public:
485796da18402f286b897782a298ae3b20c459c102eDouglas Gregor///   void bar();
486796da18402f286b897782a298ae3b20c459c102eDouglas Gregor///   void test() { this->bar(); }
487796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// };
488796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// @endcode
489796da18402f286b897782a298ae3b20c459c102eDouglas Gregorclass CXXThisExpr : public Expr {
490796da18402f286b897782a298ae3b20c459c102eDouglas Gregor  SourceLocation Loc;
491828a197317288e3333b0ce6f5cedadd036e3531fDouglas Gregor  bool Implicit : 1;
492828a197317288e3333b0ce6f5cedadd036e3531fDouglas Gregor
493796da18402f286b897782a298ae3b20c459c102eDouglas Gregorpublic:
494828a197317288e3333b0ce6f5cedadd036e3531fDouglas Gregor  CXXThisExpr(SourceLocation L, QualType Type, bool isImplicit)
495f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall    : Expr(CXXThisExprClass, Type, VK_RValue, OK_Ordinary,
4962850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl           // 'this' is type-dependent if the class type of the enclosing
4972850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl           // member function is dependent (C++ [temp.dep.expr]p2)
4982850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl           Type->isDependentType(), Type->isDependentType()),
499828a197317288e3333b0ce6f5cedadd036e3531fDouglas Gregor      Loc(L), Implicit(isImplicit) { }
500796da18402f286b897782a298ae3b20c459c102eDouglas Gregor
5012fbdfcdf3bbf7b941853d38b123930755e837437Chris Lattner  CXXThisExpr(EmptyShell Empty) : Expr(CXXThisExprClass, Empty) {}
5022fbdfcdf3bbf7b941853d38b123930755e837437Chris Lattner
5032fbdfcdf3bbf7b941853d38b123930755e837437Chris Lattner  SourceLocation getLocation() const { return Loc; }
5042fbdfcdf3bbf7b941853d38b123930755e837437Chris Lattner  void setLocation(SourceLocation L) { Loc = L; }
5052fbdfcdf3bbf7b941853d38b123930755e837437Chris Lattner
506796da18402f286b897782a298ae3b20c459c102eDouglas Gregor  virtual SourceRange getSourceRange() const { return SourceRange(Loc); }
507796da18402f286b897782a298ae3b20c459c102eDouglas Gregor
508828a197317288e3333b0ce6f5cedadd036e3531fDouglas Gregor  bool isImplicit() const { return Implicit; }
509828a197317288e3333b0ce6f5cedadd036e3531fDouglas Gregor  void setImplicit(bool I) { Implicit = I; }
510828a197317288e3333b0ce6f5cedadd036e3531fDouglas Gregor
5111eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  static bool classof(const Stmt *T) {
512796da18402f286b897782a298ae3b20c459c102eDouglas Gregor    return T->getStmtClass() == CXXThisExprClass;
513796da18402f286b897782a298ae3b20c459c102eDouglas Gregor  }
514796da18402f286b897782a298ae3b20c459c102eDouglas Gregor  static bool classof(const CXXThisExpr *) { return true; }
515796da18402f286b897782a298ae3b20c459c102eDouglas Gregor
516796da18402f286b897782a298ae3b20c459c102eDouglas Gregor  // Iterators
517796da18402f286b897782a298ae3b20c459c102eDouglas Gregor  virtual child_iterator child_begin();
518796da18402f286b897782a298ae3b20c459c102eDouglas Gregor  virtual child_iterator child_end();
519796da18402f286b897782a298ae3b20c459c102eDouglas Gregor};
520796da18402f286b897782a298ae3b20c459c102eDouglas Gregor
5211060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek///  CXXThrowExpr - [C++ 15] C++ Throw Expression.  This handles
5221060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek///  'throw' and 'throw' assignment-expression.  When
5231060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek///  assignment-expression isn't present, Op will be null.
5241060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek///
5251060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenekclass CXXThrowExpr : public Expr {
5261060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  Stmt *Op;
5271060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  SourceLocation ThrowLoc;
5281060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenekpublic:
5291060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  // Ty is the void type which is used as the result type of the
5301060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  // exepression.  The l is the location of the throw keyword.  expr
5311060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  // can by null, if the optional expression to throw isn't present.
5321060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  CXXThrowExpr(Expr *expr, QualType Ty, SourceLocation l) :
533f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall    Expr(CXXThrowExprClass, Ty, VK_RValue, OK_Ordinary, false, false),
534f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall    Op(expr), ThrowLoc(l) {}
5352fbdfcdf3bbf7b941853d38b123930755e837437Chris Lattner  CXXThrowExpr(EmptyShell Empty) : Expr(CXXThrowExprClass, Empty) {}
5362fbdfcdf3bbf7b941853d38b123930755e837437Chris Lattner
5371060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  const Expr *getSubExpr() const { return cast_or_null<Expr>(Op); }
5381060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  Expr *getSubExpr() { return cast_or_null<Expr>(Op); }
53942e5b50f4dc897f252e0d476063a7f9846d96624Douglas Gregor  void setSubExpr(Expr *E) { Op = E; }
54042e5b50f4dc897f252e0d476063a7f9846d96624Douglas Gregor
54142e5b50f4dc897f252e0d476063a7f9846d96624Douglas Gregor  SourceLocation getThrowLoc() const { return ThrowLoc; }
54242e5b50f4dc897f252e0d476063a7f9846d96624Douglas Gregor  void setThrowLoc(SourceLocation L) { ThrowLoc = L; }
5431060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek
5441060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  virtual SourceRange getSourceRange() const {
5451060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek    if (getSubExpr() == 0)
5461060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek      return SourceRange(ThrowLoc, ThrowLoc);
5471060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek    return SourceRange(ThrowLoc, getSubExpr()->getSourceRange().getEnd());
5481060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  }
5491060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek
5501060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  static bool classof(const Stmt *T) {
5511060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek    return T->getStmtClass() == CXXThrowExprClass;
5521060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  }
5531060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  static bool classof(const CXXThrowExpr *) { return true; }
5541060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek
5551060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  // Iterators
5561060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  virtual child_iterator child_begin();
5571060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  virtual child_iterator child_end();
5581060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek};
5591060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek
5601060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek/// CXXDefaultArgExpr - C++ [dcl.fct.default]. This wraps up a
5611060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek/// function call argument that was created from the corresponding
5621060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek/// parameter's default argument, when the call did not explicitly
5631060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek/// supply arguments for all of the parameters.
5641060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenekclass CXXDefaultArgExpr : public Expr {
56565222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor  /// \brief The parameter whose default is being used.
56665222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor  ///
56765222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor  /// When the bit is set, the subexpression is stored after the
56865222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor  /// CXXDefaultArgExpr itself. When the bit is clear, the parameter's
56965222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor  /// actual default expression is the subexpression.
57065222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor  llvm::PointerIntPair<ParmVarDecl *, 1, bool> Param;
5711eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
572036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor  /// \brief The location where the default argument expression was used.
573036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor  SourceLocation Loc;
574036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor
575036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor  CXXDefaultArgExpr(StmtClass SC, SourceLocation Loc, ParmVarDecl *param)
57665222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor    : Expr(SC,
57765222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor           param->hasUnparsedDefaultArg()
57865222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor             ? param->getType().getNonReferenceType()
5792333f7727f97018d6742e1e0938133bcfad967abEli Friedman             : param->getDefaultArg()->getType(),
580dfa1edbebeda7ec3a7a9c45e4317de9241aa9883John McCall           param->getDefaultArg()->getValueKind(),
581dfa1edbebeda7ec3a7a9c45e4317de9241aa9883John McCall           param->getDefaultArg()->getObjectKind(), false, false),
582036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor      Param(param, false), Loc(Loc) { }
58365222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor
584036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor  CXXDefaultArgExpr(StmtClass SC, SourceLocation Loc, ParmVarDecl *param,
585036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor                    Expr *SubExpr)
586dfa1edbebeda7ec3a7a9c45e4317de9241aa9883John McCall    : Expr(SC, SubExpr->getType(),
587dfa1edbebeda7ec3a7a9c45e4317de9241aa9883John McCall           SubExpr->getValueKind(), SubExpr->getObjectKind(),
588f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall           false, false), Param(param, true), Loc(Loc) {
58965222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor    *reinterpret_cast<Expr **>(this + 1) = SubExpr;
59065222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor  }
59165222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor
5921060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenekpublic:
593030854b95f7bfd86aaa8afd9ae1aff9768a37e9aChris Lattner  CXXDefaultArgExpr(EmptyShell Empty) : Expr(CXXDefaultArgExprClass, Empty) {}
594030854b95f7bfd86aaa8afd9ae1aff9768a37e9aChris Lattner
595030854b95f7bfd86aaa8afd9ae1aff9768a37e9aChris Lattner
5961060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  // Param is the parameter whose default argument is used by this
5971060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  // expression.
598036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor  static CXXDefaultArgExpr *Create(ASTContext &C, SourceLocation Loc,
599036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor                                   ParmVarDecl *Param) {
600036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor    return new (C) CXXDefaultArgExpr(CXXDefaultArgExprClass, Loc, Param);
601f1480eee38b59d15438fb7bc50865ac7c7e22403Anders Carlsson  }
6021060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek
60365222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor  // Param is the parameter whose default argument is used by this
60465222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor  // expression, and SubExpr is the expression that will actually be used.
605036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor  static CXXDefaultArgExpr *Create(ASTContext &C,
606036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor                                   SourceLocation Loc,
607036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor                                   ParmVarDecl *Param,
60865222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor                                   Expr *SubExpr);
60965222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor
6101060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  // Retrieve the parameter that the argument was created from.
61165222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor  const ParmVarDecl *getParam() const { return Param.getPointer(); }
61265222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor  ParmVarDecl *getParam() { return Param.getPointer(); }
613030854b95f7bfd86aaa8afd9ae1aff9768a37e9aChris Lattner
6141060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  // Retrieve the actual argument to the function call.
61565222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor  const Expr *getExpr() const {
61665222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor    if (Param.getInt())
61765222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor      return *reinterpret_cast<Expr const * const*> (this + 1);
61865222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor    return getParam()->getDefaultArg();
61965222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor  }
62065222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor  Expr *getExpr() {
62165222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor    if (Param.getInt())
62265222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor      return *reinterpret_cast<Expr **> (this + 1);
62365222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor    return getParam()->getDefaultArg();
62465222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor  }
6251060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek
626036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor  /// \brief Retrieve the location where this default argument was actually
627036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor  /// used.
628036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor  SourceLocation getUsedLocation() const { return Loc; }
629036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor
6301060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  virtual SourceRange getSourceRange() const {
6311060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek    // Default argument expressions have no representation in the
6321060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek    // source, so they have an empty source range.
6331060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek    return SourceRange();
6341060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  }
6351060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek
6361060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  static bool classof(const Stmt *T) {
6371060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek    return T->getStmtClass() == CXXDefaultArgExprClass;
6381060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  }
6391060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  static bool classof(const CXXDefaultArgExpr *) { return true; }
6401060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek
6411060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  // Iterators
6421060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  virtual child_iterator child_begin();
6431060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  virtual child_iterator child_end();
6448a50733034edd6a349b34e2b9f0c8d0a874846d3Argyrios Kyrtzidis
64560adf4acf40b72227740bf966fb87eebddff3f37Sebastian Redl  friend class ASTStmtReader;
6463397c5570369f19b2d6c52e898f708d75ceede1fSebastian Redl  friend class ASTStmtWriter;
6471060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek};
648987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis
649c1ce477119fed070299668aab24084b17ff5f14bAnders Carlsson/// CXXTemporary - Represents a C++ temporary.
650c1ce477119fed070299668aab24084b17ff5f14bAnders Carlssonclass CXXTemporary {
651c1ce477119fed070299668aab24084b17ff5f14bAnders Carlsson  /// Destructor - The destructor that needs to be called.
652b859f35459ae3e1188d1e1b86df08d649695fd86Anders Carlsson  const CXXDestructorDecl *Destructor;
6531eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
654b859f35459ae3e1188d1e1b86df08d649695fd86Anders Carlsson  CXXTemporary(const CXXDestructorDecl *destructor)
655c1ce477119fed070299668aab24084b17ff5f14bAnders Carlsson    : Destructor(destructor) { }
656c1ce477119fed070299668aab24084b17ff5f14bAnders Carlsson
657c1ce477119fed070299668aab24084b17ff5f14bAnders Carlssonpublic:
6581eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  static CXXTemporary *Create(ASTContext &C,
659b859f35459ae3e1188d1e1b86df08d649695fd86Anders Carlsson                              const CXXDestructorDecl *Destructor);
6601eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
661f0721fe438d7e40c168e5d664970e7830bc138fbAnders Carlsson  const CXXDestructorDecl *getDestructor() const { return Destructor; }
662c1ce477119fed070299668aab24084b17ff5f14bAnders Carlsson};
663fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson
664ddfe960d252a93525692b547945236d361d1929fChandler Carruth/// \brief Represents binding an expression to a temporary.
665ddfe960d252a93525692b547945236d361d1929fChandler Carruth///
666ddfe960d252a93525692b547945236d361d1929fChandler Carruth/// This ensures the destructor is called for the temporary. It should only be
667ddfe960d252a93525692b547945236d361d1929fChandler Carruth/// needed for non-POD, non-trivially destructable class types. For example:
668ddfe960d252a93525692b547945236d361d1929fChandler Carruth///
669ddfe960d252a93525692b547945236d361d1929fChandler Carruth/// \code
670ddfe960d252a93525692b547945236d361d1929fChandler Carruth///   struct S {
671ddfe960d252a93525692b547945236d361d1929fChandler Carruth///     S() { }  // User defined constructor makes S non-POD.
672ddfe960d252a93525692b547945236d361d1929fChandler Carruth///     ~S() { } // User defined destructor makes it non-trivial.
673ddfe960d252a93525692b547945236d361d1929fChandler Carruth///   };
674ddfe960d252a93525692b547945236d361d1929fChandler Carruth///   void test() {
675ddfe960d252a93525692b547945236d361d1929fChandler Carruth///     const S &s_ref = S(); // Requires a CXXBindTemporaryExpr.
676ddfe960d252a93525692b547945236d361d1929fChandler Carruth///   }
677ddfe960d252a93525692b547945236d361d1929fChandler Carruth/// \endcode
678fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlssonclass CXXBindTemporaryExpr : public Expr {
679fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson  CXXTemporary *Temp;
6801eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
681fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson  Stmt *SubExpr;
682fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson
683b8e39236f05b2f71fb2632673948499fd54e2a34Fariborz Jahanian  CXXBindTemporaryExpr(CXXTemporary *temp, Expr* subexpr,
684b8e39236f05b2f71fb2632673948499fd54e2a34Fariborz Jahanian                       bool TD=false, bool VD=false)
685f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall   : Expr(CXXBindTemporaryExprClass, subexpr->getType(),
686f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall          VK_RValue, OK_Ordinary, TD, VD),
6872333f7727f97018d6742e1e0938133bcfad967abEli Friedman     Temp(temp), SubExpr(subexpr) { }
68888eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlsson
689fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlssonpublic:
690d2598368876cfe40bc8465540033bc5b5e58d8afChris Lattner  CXXBindTemporaryExpr(EmptyShell Empty)
691d2598368876cfe40bc8465540033bc5b5e58d8afChris Lattner    : Expr(CXXBindTemporaryExprClass, Empty), Temp(0), SubExpr(0) {}
692d2598368876cfe40bc8465540033bc5b5e58d8afChris Lattner
6931eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  static CXXBindTemporaryExpr *Create(ASTContext &C, CXXTemporary *Temp,
694fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson                                      Expr* SubExpr);
6951eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
69688eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlsson  CXXTemporary *getTemporary() { return Temp; }
697f0721fe438d7e40c168e5d664970e7830bc138fbAnders Carlsson  const CXXTemporary *getTemporary() const { return Temp; }
698d2598368876cfe40bc8465540033bc5b5e58d8afChris Lattner  void setTemporary(CXXTemporary *T) { Temp = T; }
699f0721fe438d7e40c168e5d664970e7830bc138fbAnders Carlsson
700fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson  const Expr *getSubExpr() const { return cast<Expr>(SubExpr); }
701fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson  Expr *getSubExpr() { return cast<Expr>(SubExpr); }
70288eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlsson  void setSubExpr(Expr *E) { SubExpr = E; }
703fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson
70496be6917e1c4ba1f4435a14c9e7c6c139571d086Douglas Gregor  virtual SourceRange getSourceRange() const {
70596be6917e1c4ba1f4435a14c9e7c6c139571d086Douglas Gregor    return SubExpr->getSourceRange();
70696be6917e1c4ba1f4435a14c9e7c6c139571d086Douglas Gregor  }
707fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson
708fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson  // Implement isa/cast/dyncast/etc.
709fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson  static bool classof(const Stmt *T) {
710fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson    return T->getStmtClass() == CXXBindTemporaryExprClass;
711fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson  }
712fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson  static bool classof(const CXXBindTemporaryExpr *) { return true; }
713fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson
714fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson  // Iterators
715fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson  virtual child_iterator child_begin();
716fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson  virtual child_iterator child_end();
717fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson};
718fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson
71915ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson/// CXXConstructExpr - Represents a call to a C++ constructor.
72015ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlssonclass CXXConstructExpr : public Expr {
72172e96fd181b19b8d01144a685cda6e955584c7eaAnders Carlssonpublic:
72272e96fd181b19b8d01144a685cda6e955584c7eaAnders Carlsson  enum ConstructionKind {
72372e96fd181b19b8d01144a685cda6e955584c7eaAnders Carlsson    CK_Complete,
72472e96fd181b19b8d01144a685cda6e955584c7eaAnders Carlsson    CK_NonVirtualBase,
72572e96fd181b19b8d01144a685cda6e955584c7eaAnders Carlsson    CK_VirtualBase
72672e96fd181b19b8d01144a685cda6e955584c7eaAnders Carlsson  };
72772e96fd181b19b8d01144a685cda6e955584c7eaAnders Carlsson
72872e96fd181b19b8d01144a685cda6e955584c7eaAnders Carlssonprivate:
72915ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson  CXXConstructorDecl *Constructor;
73015ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson
73199a2e600f9e2e51d3ce10fb6f27191677ac65b2aDouglas Gregor  SourceLocation Loc;
732428edafa9eb80e01dd40aab31d4166a787a741e1Chandler Carruth  SourceRange ParenRange;
73316006c901315fa12a108b4e571f187f4b676e426Douglas Gregor  bool Elidable : 1;
73416006c901315fa12a108b4e571f187f4b676e426Douglas Gregor  bool ZeroInitialization : 1;
73572e96fd181b19b8d01144a685cda6e955584c7eaAnders Carlsson  unsigned ConstructKind : 2;
73615ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson  Stmt **Args;
73715ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson  unsigned NumArgs;
7381eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
739bd6734e5f6432ce0cc07171c490ffaa094796198Anders Carlssonprotected:
7401eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  CXXConstructExpr(ASTContext &C, StmtClass SC, QualType T,
74199a2e600f9e2e51d3ce10fb6f27191677ac65b2aDouglas Gregor                   SourceLocation Loc,
742bd6734e5f6432ce0cc07171c490ffaa094796198Anders Carlsson                   CXXConstructorDecl *d, bool elidable,
74316006c901315fa12a108b4e571f187f4b676e426Douglas Gregor                   Expr **args, unsigned numargs,
7449db7dbb918ca49f4ee6c181e4917e7b6ec547353Douglas Gregor                   bool ZeroInitialization = false,
745428edafa9eb80e01dd40aab31d4166a787a741e1Chandler Carruth                   ConstructionKind ConstructKind = CK_Complete,
746428edafa9eb80e01dd40aab31d4166a787a741e1Chandler Carruth                   SourceRange ParenRange = SourceRange());
747bd6734e5f6432ce0cc07171c490ffaa094796198Anders Carlsson
7486d00c1365dd3601f6d93bbda9162913c57ae788fArgyrios Kyrtzidis  /// \brief Construct an empty C++ construction expression.
7496d00c1365dd3601f6d93bbda9162913c57ae788fArgyrios Kyrtzidis  CXXConstructExpr(StmtClass SC, EmptyShell Empty)
7506d00c1365dd3601f6d93bbda9162913c57ae788fArgyrios Kyrtzidis    : Expr(SC, Empty), Constructor(0), Elidable(0), ZeroInitialization(0),
7516d00c1365dd3601f6d93bbda9162913c57ae788fArgyrios Kyrtzidis      ConstructKind(0), Args(0), NumArgs(0) { }
7526d00c1365dd3601f6d93bbda9162913c57ae788fArgyrios Kyrtzidis
75315ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlssonpublic:
7546d00c1365dd3601f6d93bbda9162913c57ae788fArgyrios Kyrtzidis  /// \brief Construct an empty C++ construction expression.
7556d00c1365dd3601f6d93bbda9162913c57ae788fArgyrios Kyrtzidis  explicit CXXConstructExpr(EmptyShell Empty)
7566d00c1365dd3601f6d93bbda9162913c57ae788fArgyrios Kyrtzidis    : Expr(CXXConstructExprClass, Empty), Constructor(0),
7576d00c1365dd3601f6d93bbda9162913c57ae788fArgyrios Kyrtzidis      Elidable(0), ZeroInitialization(0),
7586d00c1365dd3601f6d93bbda9162913c57ae788fArgyrios Kyrtzidis      ConstructKind(0), Args(0), NumArgs(0) { }
7596d00c1365dd3601f6d93bbda9162913c57ae788fArgyrios Kyrtzidis
7608e587a15da6d3457a418239d5eb4146fcbd209f3Anders Carlsson  static CXXConstructExpr *Create(ASTContext &C, QualType T,
76199a2e600f9e2e51d3ce10fb6f27191677ac65b2aDouglas Gregor                                  SourceLocation Loc,
7621eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump                                  CXXConstructorDecl *D, bool Elidable,
76316006c901315fa12a108b4e571f187f4b676e426Douglas Gregor                                  Expr **Args, unsigned NumArgs,
7649db7dbb918ca49f4ee6c181e4917e7b6ec547353Douglas Gregor                                  bool ZeroInitialization = false,
765428edafa9eb80e01dd40aab31d4166a787a741e1Chandler Carruth                                  ConstructionKind ConstructKind = CK_Complete,
766428edafa9eb80e01dd40aab31d4166a787a741e1Chandler Carruth                                  SourceRange ParenRange = SourceRange());
7671eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
7681eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
769d94546a0a1deef7286c13e49b9584621ae81cc9aDouglas Gregor  CXXConstructorDecl* getConstructor() const { return Constructor; }
77039da0b8145eaec7da7004f9b3645c5c9f4f63b1dDouglas Gregor  void setConstructor(CXXConstructorDecl *C) { Constructor = C; }
77139da0b8145eaec7da7004f9b3645c5c9f4f63b1dDouglas Gregor
77299a2e600f9e2e51d3ce10fb6f27191677ac65b2aDouglas Gregor  SourceLocation getLocation() const { return Loc; }
77399a2e600f9e2e51d3ce10fb6f27191677ac65b2aDouglas Gregor  void setLocation(SourceLocation Loc) { this->Loc = Loc; }
77499a2e600f9e2e51d3ce10fb6f27191677ac65b2aDouglas Gregor
775d94546a0a1deef7286c13e49b9584621ae81cc9aDouglas Gregor  /// \brief Whether this construction is elidable.
776d94546a0a1deef7286c13e49b9584621ae81cc9aDouglas Gregor  bool isElidable() const { return Elidable; }
77739da0b8145eaec7da7004f9b3645c5c9f4f63b1dDouglas Gregor  void setElidable(bool E) { Elidable = E; }
77839da0b8145eaec7da7004f9b3645c5c9f4f63b1dDouglas Gregor
77916006c901315fa12a108b4e571f187f4b676e426Douglas Gregor  /// \brief Whether this construction first requires
78016006c901315fa12a108b4e571f187f4b676e426Douglas Gregor  /// zero-initialization before the initializer is called.
78116006c901315fa12a108b4e571f187f4b676e426Douglas Gregor  bool requiresZeroInitialization() const { return ZeroInitialization; }
78216006c901315fa12a108b4e571f187f4b676e426Douglas Gregor  void setRequiresZeroInitialization(bool ZeroInit) {
78316006c901315fa12a108b4e571f187f4b676e426Douglas Gregor    ZeroInitialization = ZeroInit;
78416006c901315fa12a108b4e571f187f4b676e426Douglas Gregor  }
78516006c901315fa12a108b4e571f187f4b676e426Douglas Gregor
7869db7dbb918ca49f4ee6c181e4917e7b6ec547353Douglas Gregor  /// \brief Determines whether this constructor is actually constructing
7879db7dbb918ca49f4ee6c181e4917e7b6ec547353Douglas Gregor  /// a base class (rather than a complete object).
78824eb78e38aba55c507bc3c05c37035a9ab2defa7Anders Carlsson  ConstructionKind getConstructionKind() const {
78924eb78e38aba55c507bc3c05c37035a9ab2defa7Anders Carlsson    return (ConstructionKind)ConstructKind;
79072e96fd181b19b8d01144a685cda6e955584c7eaAnders Carlsson  }
79172e96fd181b19b8d01144a685cda6e955584c7eaAnders Carlsson  void setConstructionKind(ConstructionKind CK) {
79272e96fd181b19b8d01144a685cda6e955584c7eaAnders Carlsson    ConstructKind = CK;
79372e96fd181b19b8d01144a685cda6e955584c7eaAnders Carlsson  }
7949db7dbb918ca49f4ee6c181e4917e7b6ec547353Douglas Gregor
79515ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson  typedef ExprIterator arg_iterator;
79615ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson  typedef ConstExprIterator const_arg_iterator;
7971eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
79815ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson  arg_iterator arg_begin() { return Args; }
79915ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson  arg_iterator arg_end() { return Args + NumArgs; }
80015ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson  const_arg_iterator arg_begin() const { return Args; }
80115ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson  const_arg_iterator arg_end() const { return Args + NumArgs; }
80215ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson
803a88cfbfac9bbcbb9858f048d6d73a48711d8e93dDouglas Gregor  Expr **getArgs() const { return reinterpret_cast<Expr **>(Args); }
80415ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson  unsigned getNumArgs() const { return NumArgs; }
80515ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson
806bcb11d01c034f967503bd98f28bdf458c1ab8001Anders Carlsson  /// getArg - Return the specified argument.
807bcb11d01c034f967503bd98f28bdf458c1ab8001Anders Carlsson  Expr *getArg(unsigned Arg) {
808bcb11d01c034f967503bd98f28bdf458c1ab8001Anders Carlsson    assert(Arg < NumArgs && "Arg access out of range!");
809bcb11d01c034f967503bd98f28bdf458c1ab8001Anders Carlsson    return cast<Expr>(Args[Arg]);
810bcb11d01c034f967503bd98f28bdf458c1ab8001Anders Carlsson  }
811bcb11d01c034f967503bd98f28bdf458c1ab8001Anders Carlsson  const Expr *getArg(unsigned Arg) const {
812bcb11d01c034f967503bd98f28bdf458c1ab8001Anders Carlsson    assert(Arg < NumArgs && "Arg access out of range!");
813bcb11d01c034f967503bd98f28bdf458c1ab8001Anders Carlsson    return cast<Expr>(Args[Arg]);
814bcb11d01c034f967503bd98f28bdf458c1ab8001Anders Carlsson  }
8151eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
8162eeed7bc4fd457ac57ff32ab3b02674588545f65Fariborz Jahanian  /// setArg - Set the specified argument.
8172eeed7bc4fd457ac57ff32ab3b02674588545f65Fariborz Jahanian  void setArg(unsigned Arg, Expr *ArgExpr) {
8182eeed7bc4fd457ac57ff32ab3b02674588545f65Fariborz Jahanian    assert(Arg < NumArgs && "Arg access out of range!");
8192eeed7bc4fd457ac57ff32ab3b02674588545f65Fariborz Jahanian    Args[Arg] = ArgExpr;
8202eeed7bc4fd457ac57ff32ab3b02674588545f65Fariborz Jahanian  }
8212eeed7bc4fd457ac57ff32ab3b02674588545f65Fariborz Jahanian
822e383768f7f5d45ca4af0b1c11cbf072de18bce98Ted Kremenek  virtual SourceRange getSourceRange() const;
823428edafa9eb80e01dd40aab31d4166a787a741e1Chandler Carruth  SourceRange getParenRange() const { return ParenRange; }
82415ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson
8251eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  static bool classof(const Stmt *T) {
826524fa13fd81e88533c7a1d4b1232c0de2c97dc7cAnders Carlsson    return T->getStmtClass() == CXXConstructExprClass ||
827524fa13fd81e88533c7a1d4b1232c0de2c97dc7cAnders Carlsson      T->getStmtClass() == CXXTemporaryObjectExprClass;
82815ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson  }
82915ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson  static bool classof(const CXXConstructExpr *) { return true; }
8301eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
83115ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson  // Iterators
83215ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson  virtual child_iterator child_begin();
83315ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson  virtual child_iterator child_end();
8346d00c1365dd3601f6d93bbda9162913c57ae788fArgyrios Kyrtzidis
83560adf4acf40b72227740bf966fb87eebddff3f37Sebastian Redl  friend class ASTStmtReader;
83615ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson};
83715ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson
83849badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// CXXFunctionalCastExpr - Represents an explicit C++ type conversion
83949badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// that uses "functional" notion (C++ [expr.type.conv]). Example: @c
84049badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// x = int(0.5);
84149badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregorclass CXXFunctionalCastExpr : public ExplicitCastExpr {
842987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  SourceLocation TyBeginLoc;
843987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  SourceLocation RParenLoc;
844f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall
845f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall  CXXFunctionalCastExpr(QualType ty, ExprValueKind VK,
846f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall                        TypeSourceInfo *writtenTy,
8471eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump                        SourceLocation tyBeginLoc, CastKind kind,
848f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall                        Expr *castExpr, unsigned pathSize,
84941b2dcd465f1e438502c420effc9d0c747f9db8fAnders Carlsson                        SourceLocation rParenLoc)
850f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall    : ExplicitCastExpr(CXXFunctionalCastExprClass, ty, VK, kind,
851f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall                       castExpr, pathSize, writtenTy),
8520aebc81e02397a5987aaa8e8c7acbdb01a31d7c3Anders Carlsson      TyBeginLoc(tyBeginLoc), RParenLoc(rParenLoc) {}
8530aebc81e02397a5987aaa8e8c7acbdb01a31d7c3Anders Carlsson
854f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall  explicit CXXFunctionalCastExpr(EmptyShell Shell, unsigned PathSize)
855f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall    : ExplicitCastExpr(CXXFunctionalCastExprClass, Shell, PathSize) { }
856f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall
857f871d0cc377a1367b519a6cce26be74607566ebaJohn McCallpublic:
858f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall  static CXXFunctionalCastExpr *Create(ASTContext &Context, QualType T,
859f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall                                       ExprValueKind VK,
860f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall                                       TypeSourceInfo *Written,
861f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall                                       SourceLocation TyBeginLoc,
862f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall                                       CastKind Kind, Expr *Op,
863f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall                                       const CXXCastPath *Path,
864f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall                                       SourceLocation RPLoc);
865f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall  static CXXFunctionalCastExpr *CreateEmpty(ASTContext &Context,
866f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall                                            unsigned PathSize);
867ce757a7a1ee905f87551996a69da3e95e8afeeb7Sam Weinig
868987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  SourceLocation getTypeBeginLoc() const { return TyBeginLoc; }
869ce757a7a1ee905f87551996a69da3e95e8afeeb7Sam Weinig  void setTypeBeginLoc(SourceLocation L) { TyBeginLoc = L; }
870987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  SourceLocation getRParenLoc() const { return RParenLoc; }
871ce757a7a1ee905f87551996a69da3e95e8afeeb7Sam Weinig  void setRParenLoc(SourceLocation L) { RParenLoc = L; }
8721eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
873987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  virtual SourceRange getSourceRange() const {
874987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis    return SourceRange(TyBeginLoc, RParenLoc);
875987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  }
8761eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  static bool classof(const Stmt *T) {
8771eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump    return T->getStmtClass() == CXXFunctionalCastExprClass;
878987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  }
879987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  static bool classof(const CXXFunctionalCastExpr *) { return true; }
880987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis};
881987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis
882506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// @brief Represents a C++ functional cast expression that builds a
883506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// temporary object.
884506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor///
8851eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump/// This expression type represents a C++ "functional" cast
886506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// (C++[expr.type.conv]) with N != 1 arguments that invokes a
887ed8abf18329df67b0abcbb3a10458bd8c1d2a595Douglas Gregor/// constructor to build a temporary object. With N == 1 arguments the
888ed8abf18329df67b0abcbb3a10458bd8c1d2a595Douglas Gregor/// functional cast expression will be represented by CXXFunctionalCastExpr.
889506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// Example:
890506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// @code
891506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// struct X { X(int, float); }
892506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor///
893506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// X create_X() {
894506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor///   return X(1, 3.14f); // creates a CXXTemporaryObjectExpr
895506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// };
896506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// @endcode
897524fa13fd81e88533c7a1d4b1232c0de2c97dc7cAnders Carlssonclass CXXTemporaryObjectExpr : public CXXConstructExpr {
898ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor  TypeSourceInfo *Type;
899506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor
900506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregorpublic:
9011eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  CXXTemporaryObjectExpr(ASTContext &C, CXXConstructorDecl *Cons,
902ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor                         TypeSourceInfo *Type,
9031eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump                         Expr **Args,unsigned NumArgs,
904428edafa9eb80e01dd40aab31d4166a787a741e1Chandler Carruth                         SourceRange parenRange,
9051c63b9c15d48cb8c833a4b2d6fd6c496c0766e88Douglas Gregor                         bool ZeroInitialization = false);
9066d00c1365dd3601f6d93bbda9162913c57ae788fArgyrios Kyrtzidis  explicit CXXTemporaryObjectExpr(EmptyShell Empty)
907ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor    : CXXConstructExpr(CXXTemporaryObjectExprClass, Empty), Type() { }
908506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor
909ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor  TypeSourceInfo *getTypeSourceInfo() const { return Type; }
910ba49817c5b9f502602672861cf369fd0e53966e8Douglas Gregor
911ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor  virtual SourceRange getSourceRange() const;
912ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor
9131eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  static bool classof(const Stmt *T) {
914506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor    return T->getStmtClass() == CXXTemporaryObjectExprClass;
915506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor  }
916506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor  static bool classof(const CXXTemporaryObjectExpr *) { return true; }
9176d00c1365dd3601f6d93bbda9162913c57ae788fArgyrios Kyrtzidis
91860adf4acf40b72227740bf966fb87eebddff3f37Sebastian Redl  friend class ASTStmtReader;
919506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor};
920506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor
921ed8abf18329df67b0abcbb3a10458bd8c1d2a595Douglas Gregor/// CXXScalarValueInitExpr - [C++ 5.2.3p2]
922506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// Expression "T()" which creates a value-initialized rvalue of type
923ed8abf18329df67b0abcbb3a10458bd8c1d2a595Douglas Gregor/// T, which is a non-class type.
924987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis///
925ed8abf18329df67b0abcbb3a10458bd8c1d2a595Douglas Gregorclass CXXScalarValueInitExpr : public Expr {
926987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  SourceLocation RParenLoc;
927ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor  TypeSourceInfo *TypeInfo;
928987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis
929ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor  friend class ASTStmtReader;
930ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor
931987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidispublic:
932ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor  /// \brief Create an explicitly-written scalar-value initialization
933ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor  /// expression.
934ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor  CXXScalarValueInitExpr(QualType Type,
935ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor                         TypeSourceInfo *TypeInfo,
936ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor                         SourceLocation rParenLoc ) :
937f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall    Expr(CXXScalarValueInitExprClass, Type, VK_RValue, OK_Ordinary,
938f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall         false, false),
939ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor    RParenLoc(rParenLoc), TypeInfo(TypeInfo) {}
940ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor
941ed8abf18329df67b0abcbb3a10458bd8c1d2a595Douglas Gregor  explicit CXXScalarValueInitExpr(EmptyShell Shell)
942ed8abf18329df67b0abcbb3a10458bd8c1d2a595Douglas Gregor    : Expr(CXXScalarValueInitExprClass, Shell) { }
9431eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
944ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor  TypeSourceInfo *getTypeSourceInfo() const {
945ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor    return TypeInfo;
9464c67834407ca6ab344dcf44fc599ad4938cfa96dDouglas Gregor  }
947ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor
948ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor  SourceLocation getRParenLoc() const { return RParenLoc; }
9494c67834407ca6ab344dcf44fc599ad4938cfa96dDouglas Gregor
950ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor  virtual SourceRange getSourceRange() const;
9511eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
9521eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  static bool classof(const Stmt *T) {
953ed8abf18329df67b0abcbb3a10458bd8c1d2a595Douglas Gregor    return T->getStmtClass() == CXXScalarValueInitExprClass;
954987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  }
955ed8abf18329df67b0abcbb3a10458bd8c1d2a595Douglas Gregor  static bool classof(const CXXScalarValueInitExpr *) { return true; }
9561eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
957987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  // Iterators
958987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  virtual child_iterator child_begin();
959987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  virtual child_iterator child_end();
960987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis};
961987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis
9624c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl/// CXXNewExpr - A new expression for memory allocation and constructor calls,
9634c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl/// e.g: "new CXXNewExpr(foo)".
9644c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redlclass CXXNewExpr : public Expr {
9654c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  // Was the usage ::new, i.e. is the global new to be used?
9664c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  bool GlobalNew : 1;
9674c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  // Is there an initializer? If not, built-ins are uninitialized, else they're
9684c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  // value-initialized.
9694c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  bool Initializer : 1;
970cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl  // Do we allocate an array? If so, the first SubExpr is the size expression.
971cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl  bool Array : 1;
9724c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  // The number of placement new arguments.
973e4b8f1171d699c56ba2b39aabf1d7cb4c38ce4f8Douglas Gregor  unsigned NumPlacementArgs : 15;
9744c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  // The number of constructor arguments. This may be 1 even for non-class
9754c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  // types; use the pseudo copy constructor.
976cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl  unsigned NumConstructorArgs : 14;
977cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl  // Contains an optional array size expression, any number of optional
978cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl  // placement arguments, and any number of optional constructor arguments,
979cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl  // in that order.
9804c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  Stmt **SubExprs;
9814c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  // Points to the allocation function used.
9824c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  FunctionDecl *OperatorNew;
9834c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  // Points to the deallocation function used in case of error. May be null.
9844c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  FunctionDecl *OperatorDelete;
9854c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  // Points to the constructor used. Cannot be null if AllocType is a record;
9864c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  // it would still point at the default constructor (even an implicit one).
9874c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  // Must be null for all other types.
9884c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  CXXConstructorDecl *Constructor;
9894c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
9901bb2a93ab7b1499dda6f6b58865bd0dce1864228Douglas Gregor  /// \brief The allocated type-source information, as written in the source.
9911bb2a93ab7b1499dda6f6b58865bd0dce1864228Douglas Gregor  TypeSourceInfo *AllocatedTypeInfo;
9921bb2a93ab7b1499dda6f6b58865bd0dce1864228Douglas Gregor
9934bd40318cbea15310a37343db46de96c4fcc15e6Douglas Gregor  /// \brief If the allocated type was expressed as a parenthesized type-id,
9944bd40318cbea15310a37343db46de96c4fcc15e6Douglas Gregor  /// the source range covering the parenthesized type-id.
9954bd40318cbea15310a37343db46de96c4fcc15e6Douglas Gregor  SourceRange TypeIdParens;
9964bd40318cbea15310a37343db46de96c4fcc15e6Douglas Gregor
9974c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  SourceLocation StartLoc;
9984c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  SourceLocation EndLoc;
999428edafa9eb80e01dd40aab31d4166a787a741e1Chandler Carruth  SourceLocation ConstructorLParen;
1000428edafa9eb80e01dd40aab31d4166a787a741e1Chandler Carruth  SourceLocation ConstructorRParen;
10014c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
100260adf4acf40b72227740bf966fb87eebddff3f37Sebastian Redl  friend class ASTStmtReader;
10034c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redlpublic:
1004ad7fe864862305c2f71e047cdf6706ef43aebdc0Ted Kremenek  CXXNewExpr(ASTContext &C, bool globalNew, FunctionDecl *operatorNew,
10054bd40318cbea15310a37343db46de96c4fcc15e6Douglas Gregor             Expr **placementArgs, unsigned numPlaceArgs,
10064bd40318cbea15310a37343db46de96c4fcc15e6Douglas Gregor             SourceRange TypeIdParens,
1007ad7fe864862305c2f71e047cdf6706ef43aebdc0Ted Kremenek             Expr *arraySize, CXXConstructorDecl *constructor, bool initializer,
10084c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl             Expr **constructorArgs, unsigned numConsArgs,
10094c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl             FunctionDecl *operatorDelete, QualType ty,
10101bb2a93ab7b1499dda6f6b58865bd0dce1864228Douglas Gregor             TypeSourceInfo *AllocatedTypeInfo,
1011428edafa9eb80e01dd40aab31d4166a787a741e1Chandler Carruth             SourceLocation startLoc, SourceLocation endLoc,
1012428edafa9eb80e01dd40aab31d4166a787a741e1Chandler Carruth             SourceLocation constructorLParen,
1013428edafa9eb80e01dd40aab31d4166a787a741e1Chandler Carruth             SourceLocation constructorRParen);
10145921863d8f24084797863b5df37842113bac4352Chris Lattner  explicit CXXNewExpr(EmptyShell Shell)
10155921863d8f24084797863b5df37842113bac4352Chris Lattner    : Expr(CXXNewExprClass, Shell), SubExprs(0) { }
10165921863d8f24084797863b5df37842113bac4352Chris Lattner
10175921863d8f24084797863b5df37842113bac4352Chris Lattner  void AllocateArgsArray(ASTContext &C, bool isArray, unsigned numPlaceArgs,
10185921863d8f24084797863b5df37842113bac4352Chris Lattner                         unsigned numConsArgs);
1019ad7fe864862305c2f71e047cdf6706ef43aebdc0Ted Kremenek
1020cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl  QualType getAllocatedType() const {
1021cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl    assert(getType()->isPointerType());
10226217b80b7a1379b74cced1c076338262c3c980b3Ted Kremenek    return getType()->getAs<PointerType>()->getPointeeType();
1023cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl  }
10244c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
10251bb2a93ab7b1499dda6f6b58865bd0dce1864228Douglas Gregor  TypeSourceInfo *getAllocatedTypeSourceInfo() const {
10261bb2a93ab7b1499dda6f6b58865bd0dce1864228Douglas Gregor    return AllocatedTypeInfo;
10271bb2a93ab7b1499dda6f6b58865bd0dce1864228Douglas Gregor  }
10281bb2a93ab7b1499dda6f6b58865bd0dce1864228Douglas Gregor
10294c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  FunctionDecl *getOperatorNew() const { return OperatorNew; }
10305921863d8f24084797863b5df37842113bac4352Chris Lattner  void setOperatorNew(FunctionDecl *D) { OperatorNew = D; }
10314c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  FunctionDecl *getOperatorDelete() const { return OperatorDelete; }
10325921863d8f24084797863b5df37842113bac4352Chris Lattner  void setOperatorDelete(FunctionDecl *D) { OperatorDelete = D; }
10334c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  CXXConstructorDecl *getConstructor() const { return Constructor; }
10345921863d8f24084797863b5df37842113bac4352Chris Lattner  void setConstructor(CXXConstructorDecl *D) { Constructor = D; }
10354c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
1036cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl  bool isArray() const { return Array; }
1037cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl  Expr *getArraySize() {
1038cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl    return Array ? cast<Expr>(SubExprs[0]) : 0;
1039cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl  }
1040cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl  const Expr *getArraySize() const {
1041cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl    return Array ? cast<Expr>(SubExprs[0]) : 0;
1042cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl  }
1043cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl
10444c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  unsigned getNumPlacementArgs() const { return NumPlacementArgs; }
10454c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  Expr *getPlacementArg(unsigned i) {
10464c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl    assert(i < NumPlacementArgs && "Index out of range");
1047cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl    return cast<Expr>(SubExprs[Array + i]);
10484c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  }
10494c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  const Expr *getPlacementArg(unsigned i) const {
10504c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl    assert(i < NumPlacementArgs && "Index out of range");
1051cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl    return cast<Expr>(SubExprs[Array + i]);
10524c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  }
10534c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
10544bd40318cbea15310a37343db46de96c4fcc15e6Douglas Gregor  bool isParenTypeId() const { return TypeIdParens.isValid(); }
10554bd40318cbea15310a37343db46de96c4fcc15e6Douglas Gregor  SourceRange getTypeIdParens() const { return TypeIdParens; }
10564bd40318cbea15310a37343db46de96c4fcc15e6Douglas Gregor
10574c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  bool isGlobalNew() const { return GlobalNew; }
10585921863d8f24084797863b5df37842113bac4352Chris Lattner  void setGlobalNew(bool V) { GlobalNew = V; }
10594c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  bool hasInitializer() const { return Initializer; }
10605921863d8f24084797863b5df37842113bac4352Chris Lattner  void setHasInitializer(bool V) { Initializer = V; }
10614c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
10624c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  unsigned getNumConstructorArgs() const { return NumConstructorArgs; }
10634c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  Expr *getConstructorArg(unsigned i) {
10644c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl    assert(i < NumConstructorArgs && "Index out of range");
1065cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl    return cast<Expr>(SubExprs[Array + NumPlacementArgs + i]);
10664c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  }
10674c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  const Expr *getConstructorArg(unsigned i) const {
10684c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl    assert(i < NumConstructorArgs && "Index out of range");
1069cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl    return cast<Expr>(SubExprs[Array + NumPlacementArgs + i]);
10704c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  }
10714c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
10724c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  typedef ExprIterator arg_iterator;
10734c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  typedef ConstExprIterator const_arg_iterator;
10744c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
10754c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  arg_iterator placement_arg_begin() {
1076cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl    return SubExprs + Array;
10774c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  }
10784c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  arg_iterator placement_arg_end() {
1079cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl    return SubExprs + Array + getNumPlacementArgs();
10804c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  }
10814c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  const_arg_iterator placement_arg_begin() const {
1082cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl    return SubExprs + Array;
10834c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  }
10844c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  const_arg_iterator placement_arg_end() const {
1085cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl    return SubExprs + Array + getNumPlacementArgs();
10864c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  }
10874c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
10884c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  arg_iterator constructor_arg_begin() {
1089cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl    return SubExprs + Array + getNumPlacementArgs();
10904c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  }
10914c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  arg_iterator constructor_arg_end() {
1092cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl    return SubExprs + Array + getNumPlacementArgs() + getNumConstructorArgs();
10934c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  }
10944c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  const_arg_iterator constructor_arg_begin() const {
1095cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl    return SubExprs + Array + getNumPlacementArgs();
10964c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  }
10974c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  const_arg_iterator constructor_arg_end() const {
1098cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl    return SubExprs + Array + getNumPlacementArgs() + getNumConstructorArgs();
10994c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  }
11005921863d8f24084797863b5df37842113bac4352Chris Lattner
11015921863d8f24084797863b5df37842113bac4352Chris Lattner  typedef Stmt **raw_arg_iterator;
11025921863d8f24084797863b5df37842113bac4352Chris Lattner  raw_arg_iterator raw_arg_begin() { return SubExprs; }
11035921863d8f24084797863b5df37842113bac4352Chris Lattner  raw_arg_iterator raw_arg_end() {
11045921863d8f24084797863b5df37842113bac4352Chris Lattner    return SubExprs + Array + getNumPlacementArgs() + getNumConstructorArgs();
11055921863d8f24084797863b5df37842113bac4352Chris Lattner  }
11065921863d8f24084797863b5df37842113bac4352Chris Lattner  const_arg_iterator raw_arg_begin() const { return SubExprs; }
11075921863d8f24084797863b5df37842113bac4352Chris Lattner  const_arg_iterator raw_arg_end() const { return constructor_arg_end(); }
11084c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
11095921863d8f24084797863b5df37842113bac4352Chris Lattner  SourceLocation getStartLoc() const { return StartLoc; }
11105921863d8f24084797863b5df37842113bac4352Chris Lattner  SourceLocation getEndLoc() const { return EndLoc; }
1111428edafa9eb80e01dd40aab31d4166a787a741e1Chandler Carruth
1112428edafa9eb80e01dd40aab31d4166a787a741e1Chandler Carruth  SourceLocation getConstructorLParen() const { return ConstructorLParen; }
1113428edafa9eb80e01dd40aab31d4166a787a741e1Chandler Carruth  SourceLocation getConstructorRParen() const { return ConstructorRParen; }
1114428edafa9eb80e01dd40aab31d4166a787a741e1Chandler Carruth
11154c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  virtual SourceRange getSourceRange() const {
11164c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl    return SourceRange(StartLoc, EndLoc);
11174c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  }
11184c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
11194c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  static bool classof(const Stmt *T) {
11204c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl    return T->getStmtClass() == CXXNewExprClass;
11214c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  }
11224c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  static bool classof(const CXXNewExpr *) { return true; }
11234c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
11244c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  // Iterators
11254c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  virtual child_iterator child_begin();
11264c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  virtual child_iterator child_end();
11274c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl};
11284c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
11294c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl/// CXXDeleteExpr - A delete expression for memory deallocation and destructor
11304c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl/// calls, e.g. "delete[] pArray".
11314c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redlclass CXXDeleteExpr : public Expr {
11324c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  // Is this a forced global delete, i.e. "::delete"?
11334c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  bool GlobalDelete : 1;
11344c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  // Is this the array form of delete, i.e. "delete[]"?
11354c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  bool ArrayForm : 1;
11364076dacf1497fb95cb298b9d964fbdbdaf9bde6cArgyrios Kyrtzidis  // ArrayFormAsWritten can be different from ArrayForm if 'delete' is applied
11374076dacf1497fb95cb298b9d964fbdbdaf9bde6cArgyrios Kyrtzidis  // to pointer-to-array type (ArrayFormAsWritten will be false while ArrayForm
11384076dacf1497fb95cb298b9d964fbdbdaf9bde6cArgyrios Kyrtzidis  // will be true).
11394076dacf1497fb95cb298b9d964fbdbdaf9bde6cArgyrios Kyrtzidis  bool ArrayFormAsWritten : 1;
11404c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  // Points to the operator delete overload that is used. Could be a member.
11414c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  FunctionDecl *OperatorDelete;
11424c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  // The pointer expression to be deleted.
11434c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  Stmt *Argument;
11444c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  // Location of the expression.
11454c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  SourceLocation Loc;
11464c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redlpublic:
11474c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  CXXDeleteExpr(QualType ty, bool globalDelete, bool arrayForm,
11484076dacf1497fb95cb298b9d964fbdbdaf9bde6cArgyrios Kyrtzidis                bool arrayFormAsWritten, FunctionDecl *operatorDelete,
11494076dacf1497fb95cb298b9d964fbdbdaf9bde6cArgyrios Kyrtzidis                Expr *arg, SourceLocation loc)
1150f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall    : Expr(CXXDeleteExprClass, ty, VK_RValue, OK_Ordinary, false, false),
1151f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall      GlobalDelete(globalDelete),
11524076dacf1497fb95cb298b9d964fbdbdaf9bde6cArgyrios Kyrtzidis      ArrayForm(arrayForm), ArrayFormAsWritten(arrayFormAsWritten),
11534076dacf1497fb95cb298b9d964fbdbdaf9bde6cArgyrios Kyrtzidis      OperatorDelete(operatorDelete), Argument(arg), Loc(loc) { }
115495fc98ce95d4faa4f1bb2783384150530404ea6fArgyrios Kyrtzidis  explicit CXXDeleteExpr(EmptyShell Shell)
115595fc98ce95d4faa4f1bb2783384150530404ea6fArgyrios Kyrtzidis    : Expr(CXXDeleteExprClass, Shell), OperatorDelete(0), Argument(0) { }
11564c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
11574c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  bool isGlobalDelete() const { return GlobalDelete; }
11584c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  bool isArrayForm() const { return ArrayForm; }
11594076dacf1497fb95cb298b9d964fbdbdaf9bde6cArgyrios Kyrtzidis  bool isArrayFormAsWritten() const { return ArrayFormAsWritten; }
11604c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
11614c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  FunctionDecl *getOperatorDelete() const { return OperatorDelete; }
11624c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
11634c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  Expr *getArgument() { return cast<Expr>(Argument); }
11644c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  const Expr *getArgument() const { return cast<Expr>(Argument); }
11654c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
1166a437ad3ec5b407ede394d74e6f9f463fa3657dbeCraig Silverstein  /// \brief Retrieve the type being destroyed.  If the type being
1167a437ad3ec5b407ede394d74e6f9f463fa3657dbeCraig Silverstein  /// destroyed is a dependent type which may or may not be a pointer,
1168a437ad3ec5b407ede394d74e6f9f463fa3657dbeCraig Silverstein  /// return an invalid type.
11695833b0b831d6afae2885e6af420e2bda639652e6Douglas Gregor  QualType getDestroyedType() const;
11705833b0b831d6afae2885e6af420e2bda639652e6Douglas Gregor
11714c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  virtual SourceRange getSourceRange() const {
11724c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl    return SourceRange(Loc, Argument->getLocEnd());
11734c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  }
11744c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
11754c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  static bool classof(const Stmt *T) {
11764c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl    return T->getStmtClass() == CXXDeleteExprClass;
11774c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  }
11784c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  static bool classof(const CXXDeleteExpr *) { return true; }
11794c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
11804c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  // Iterators
11814c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  virtual child_iterator child_begin();
11824c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  virtual child_iterator child_end();
1183f1b8911d35bb2830a13267581d3cbde4b6b85db6Argyrios Kyrtzidis
1184f1b8911d35bb2830a13267581d3cbde4b6b85db6Argyrios Kyrtzidis  friend class ASTStmtReader;
11854c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl};
11864c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
1187a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor/// \brief Structure used to store the type being destroyed by a
1188a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor/// pseudo-destructor expression.
1189a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregorclass PseudoDestructorTypeStorage {
1190a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor  /// \brief Either the type source information or the name of the type, if
1191a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor  /// it couldn't be resolved due to type-dependence.
1192a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor  llvm::PointerUnion<TypeSourceInfo *, IdentifierInfo *> Type;
1193a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor
1194a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor  /// \brief The starting source location of the pseudo-destructor type.
1195a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor  SourceLocation Location;
1196a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor
1197a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregorpublic:
1198a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor  PseudoDestructorTypeStorage() { }
1199a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor
1200a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor  PseudoDestructorTypeStorage(IdentifierInfo *II, SourceLocation Loc)
1201a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor    : Type(II), Location(Loc) { }
1202a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor
1203a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor  PseudoDestructorTypeStorage(TypeSourceInfo *Info);
1204a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor
1205a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor  TypeSourceInfo *getTypeSourceInfo() const {
1206a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor    return Type.dyn_cast<TypeSourceInfo *>();
1207a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor  }
1208a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor
1209a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor  IdentifierInfo *getIdentifier() const {
1210a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor    return Type.dyn_cast<IdentifierInfo *>();
1211a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor  }
1212a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor
1213a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor  SourceLocation getLocation() const { return Location; }
1214a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor};
1215a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor
1216a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor/// \brief Represents a C++ pseudo-destructor (C++ [expr.pseudo]).
1217a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor///
1218e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor/// A pseudo-destructor is an expression that looks like a member access to a
1219e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor/// destructor of a scalar type, except that scalar types don't have
1220e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor/// destructors. For example:
1221e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor///
1222e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor/// \code
1223e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor/// typedef int T;
1224e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor/// void f(int *p) {
1225e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor///   p->T::~T();
1226e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor/// }
1227e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor/// \endcode
1228a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor///
1229e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor/// Pseudo-destructors typically occur when instantiating templates such as:
1230e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor///
1231a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor/// \code
12321eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump/// template<typename T>
1233a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor/// void destroy(T* ptr) {
1234e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor///   ptr->T::~T();
1235a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor/// }
1236a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor/// \endcode
1237a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor///
1238e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor/// for scalar types. A pseudo-destructor expression has no run-time semantics
1239e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor/// beyond evaluating the base expression.
1240a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregorclass CXXPseudoDestructorExpr : public Expr {
1241a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  /// \brief The base expression (that is being destroyed).
1242a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  Stmt *Base;
12431eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1244a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  /// \brief Whether the operator was an arrow ('->'); otherwise, it was a
1245a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  /// period ('.').
1246a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  bool IsArrow : 1;
12471eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1248a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  /// \brief The location of the '.' or '->' operator.
1249a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  SourceLocation OperatorLoc;
12501eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1251a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  /// \brief The nested-name-specifier that follows the operator, if present.
1252a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  NestedNameSpecifier *Qualifier;
12531eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
12541eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  /// \brief The source range that covers the nested-name-specifier, if
1255a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  /// present.
1256a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  SourceRange QualifierRange;
12571eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1258e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor  /// \brief The type that precedes the '::' in a qualified pseudo-destructor
1259e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor  /// expression.
1260e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor  TypeSourceInfo *ScopeType;
1261e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor
1262e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor  /// \brief The location of the '::' in a qualified pseudo-destructor
1263e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor  /// expression.
1264e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor  SourceLocation ColonColonLoc;
1265e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor
1266fce46ee68f779e239826e69e45d01d4c8e5323caDouglas Gregor  /// \brief The location of the '~'.
1267fce46ee68f779e239826e69e45d01d4c8e5323caDouglas Gregor  SourceLocation TildeLoc;
1268fce46ee68f779e239826e69e45d01d4c8e5323caDouglas Gregor
1269a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor  /// \brief The type being destroyed, or its name if we were unable to
1270a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor  /// resolve the name.
1271a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor  PseudoDestructorTypeStorage DestroyedType;
12721eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1273a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregorpublic:
1274a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  CXXPseudoDestructorExpr(ASTContext &Context,
1275a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor                          Expr *Base, bool isArrow, SourceLocation OperatorLoc,
1276a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor                          NestedNameSpecifier *Qualifier,
1277a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor                          SourceRange QualifierRange,
1278e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor                          TypeSourceInfo *ScopeType,
1279e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor                          SourceLocation ColonColonLoc,
1280fce46ee68f779e239826e69e45d01d4c8e5323caDouglas Gregor                          SourceLocation TildeLoc,
1281a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor                          PseudoDestructorTypeStorage DestroyedType)
12821eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump    : Expr(CXXPseudoDestructorExprClass,
1283a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor           Context.getPointerType(Context.getFunctionType(Context.VoidTy, 0, 0,
1284ce056bcaa1c97b89a4b2de2112c62d060863be2bDouglas Gregor                                                          false, 0, false,
1285264ba48dc98f3f843935a485d5b086f7e0fdc4f1Rafael Espindola                                                          false, 0, 0,
1286264ba48dc98f3f843935a485d5b086f7e0fdc4f1Rafael Espindola                                                      FunctionType::ExtInfo())),
1287f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall           VK_RValue, OK_Ordinary,
128826d4ac97fb514bb60c2536eae6f203dc569159d9Douglas Gregor           /*isTypeDependent=*/(Base->isTypeDependent() ||
1289a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor            (DestroyedType.getTypeSourceInfo() &&
1290a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor              DestroyedType.getTypeSourceInfo()->getType()->isDependentType())),
1291a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor           /*isValueDependent=*/Base->isValueDependent()),
12921eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump      Base(static_cast<Stmt *>(Base)), IsArrow(isArrow),
1293a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor      OperatorLoc(OperatorLoc), Qualifier(Qualifier),
1294e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor      QualifierRange(QualifierRange),
1295fce46ee68f779e239826e69e45d01d4c8e5323caDouglas Gregor      ScopeType(ScopeType), ColonColonLoc(ColonColonLoc), TildeLoc(TildeLoc),
129626d4ac97fb514bb60c2536eae6f203dc569159d9Douglas Gregor      DestroyedType(DestroyedType) { }
12971eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1298de4bd18bb45a1db68996cfb949db3015fc25d10dArgyrios Kyrtzidis  explicit CXXPseudoDestructorExpr(EmptyShell Shell)
1299de4bd18bb45a1db68996cfb949db3015fc25d10dArgyrios Kyrtzidis    : Expr(CXXPseudoDestructorExprClass, Shell),
1300de4bd18bb45a1db68996cfb949db3015fc25d10dArgyrios Kyrtzidis      Base(0), IsArrow(false), Qualifier(0), ScopeType(0) { }
1301de4bd18bb45a1db68996cfb949db3015fc25d10dArgyrios Kyrtzidis
1302a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  void setBase(Expr *E) { Base = E; }
1303a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  Expr *getBase() const { return cast<Expr>(Base); }
13041eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
13051eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  /// \brief Determines whether this member expression actually had
1306a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  /// a C++ nested-name-specifier prior to the name of the member, e.g.,
1307a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  /// x->Base::foo.
1308a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  bool hasQualifier() const { return Qualifier != 0; }
13091eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1310a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  /// \brief If the member name was qualified, retrieves the source range of
1311a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  /// the nested-name-specifier that precedes the member name. Otherwise,
1312a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  /// returns an empty source range.
1313a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  SourceRange getQualifierRange() const { return QualifierRange; }
1314de4bd18bb45a1db68996cfb949db3015fc25d10dArgyrios Kyrtzidis  void setQualifierRange(SourceRange R) { QualifierRange = R; }
13151eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
13161eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  /// \brief If the member name was qualified, retrieves the
1317a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  /// nested-name-specifier that precedes the member name. Otherwise, returns
1318a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  /// NULL.
1319a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  NestedNameSpecifier *getQualifier() const { return Qualifier; }
1320de4bd18bb45a1db68996cfb949db3015fc25d10dArgyrios Kyrtzidis  void setQualifier(NestedNameSpecifier *NNS) { Qualifier = NNS; }
13211eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1322a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  /// \brief Determine whether this pseudo-destructor expression was written
1323a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  /// using an '->' (otherwise, it used a '.').
1324a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  bool isArrow() const { return IsArrow; }
1325a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  void setArrow(bool A) { IsArrow = A; }
1326a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor
1327a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  /// \brief Retrieve the location of the '.' or '->' operator.
1328a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  SourceLocation getOperatorLoc() const { return OperatorLoc; }
1329de4bd18bb45a1db68996cfb949db3015fc25d10dArgyrios Kyrtzidis  void setOperatorLoc(SourceLocation L) { OperatorLoc = L; }
13301eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1331e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor  /// \brief Retrieve the scope type in a qualified pseudo-destructor
1332e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor  /// expression.
1333e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor  ///
1334e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor  /// Pseudo-destructor expressions can have extra qualification within them
1335e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor  /// that is not part of the nested-name-specifier, e.g., \c p->T::~T().
1336e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor  /// Here, if the object type of the expression is (or may be) a scalar type,
1337e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor  /// \p T may also be a scalar type and, therefore, cannot be part of a
1338e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor  /// nested-name-specifier. It is stored as the "scope type" of the pseudo-
1339e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor  /// destructor expression.
134026d4ac97fb514bb60c2536eae6f203dc569159d9Douglas Gregor  TypeSourceInfo *getScopeTypeInfo() const { return ScopeType; }
1341de4bd18bb45a1db68996cfb949db3015fc25d10dArgyrios Kyrtzidis  void setScopeTypeInfo(TypeSourceInfo *Info) { ScopeType = Info; }
1342e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor
1343e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor  /// \brief Retrieve the location of the '::' in a qualified pseudo-destructor
1344e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor  /// expression.
1345e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor  SourceLocation getColonColonLoc() const { return ColonColonLoc; }
1346de4bd18bb45a1db68996cfb949db3015fc25d10dArgyrios Kyrtzidis  void setColonColonLoc(SourceLocation L) { ColonColonLoc = L; }
1347e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor
1348fce46ee68f779e239826e69e45d01d4c8e5323caDouglas Gregor  /// \brief Retrieve the location of the '~'.
1349fce46ee68f779e239826e69e45d01d4c8e5323caDouglas Gregor  SourceLocation getTildeLoc() const { return TildeLoc; }
1350de4bd18bb45a1db68996cfb949db3015fc25d10dArgyrios Kyrtzidis  void setTildeLoc(SourceLocation L) { TildeLoc = L; }
1351fce46ee68f779e239826e69e45d01d4c8e5323caDouglas Gregor
135226d4ac97fb514bb60c2536eae6f203dc569159d9Douglas Gregor  /// \brief Retrieve the source location information for the type
135326d4ac97fb514bb60c2536eae6f203dc569159d9Douglas Gregor  /// being destroyed.
1354a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor  ///
1355a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor  /// This type-source information is available for non-dependent
1356a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor  /// pseudo-destructor expressions and some dependent pseudo-destructor
1357a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor  /// expressions. Returns NULL if we only have the identifier for a
1358a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor  /// dependent pseudo-destructor expression.
1359a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor  TypeSourceInfo *getDestroyedTypeInfo() const {
1360a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor    return DestroyedType.getTypeSourceInfo();
1361a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor  }
1362a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor
1363a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor  /// \brief In a dependent pseudo-destructor expression for which we do not
1364a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor  /// have full type information on the destroyed type, provides the name
1365a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor  /// of the destroyed type.
1366a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor  IdentifierInfo *getDestroyedTypeIdentifier() const {
1367a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor    return DestroyedType.getIdentifier();
1368a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor  }
1369a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor
1370a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor  /// \brief Retrieve the type being destroyed.
1371a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor  QualType getDestroyedType() const;
1372a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor
1373a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor  /// \brief Retrieve the starting location of the type being destroyed.
1374a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor  SourceLocation getDestroyedTypeLoc() const {
1375a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor    return DestroyedType.getLocation();
1376a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor  }
13771eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1378de4bd18bb45a1db68996cfb949db3015fc25d10dArgyrios Kyrtzidis  /// \brief Set the name of destroyed type for a dependent pseudo-destructor
1379de4bd18bb45a1db68996cfb949db3015fc25d10dArgyrios Kyrtzidis  /// expression.
1380de4bd18bb45a1db68996cfb949db3015fc25d10dArgyrios Kyrtzidis  void setDestroyedType(IdentifierInfo *II, SourceLocation Loc) {
1381de4bd18bb45a1db68996cfb949db3015fc25d10dArgyrios Kyrtzidis    DestroyedType = PseudoDestructorTypeStorage(II, Loc);
1382de4bd18bb45a1db68996cfb949db3015fc25d10dArgyrios Kyrtzidis  }
1383de4bd18bb45a1db68996cfb949db3015fc25d10dArgyrios Kyrtzidis
1384de4bd18bb45a1db68996cfb949db3015fc25d10dArgyrios Kyrtzidis  /// \brief Set the destroyed type.
1385de4bd18bb45a1db68996cfb949db3015fc25d10dArgyrios Kyrtzidis  void setDestroyedType(TypeSourceInfo *Info) {
1386de4bd18bb45a1db68996cfb949db3015fc25d10dArgyrios Kyrtzidis    DestroyedType = PseudoDestructorTypeStorage(Info);
1387de4bd18bb45a1db68996cfb949db3015fc25d10dArgyrios Kyrtzidis  }
1388de4bd18bb45a1db68996cfb949db3015fc25d10dArgyrios Kyrtzidis
138926d4ac97fb514bb60c2536eae6f203dc569159d9Douglas Gregor  virtual SourceRange getSourceRange() const;
13901eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
13911eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  static bool classof(const Stmt *T) {
1392a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor    return T->getStmtClass() == CXXPseudoDestructorExprClass;
1393a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  }
1394a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  static bool classof(const CXXPseudoDestructorExpr *) { return true; }
13951eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1396a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  // Iterators
1397a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  virtual child_iterator child_begin();
13981eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  virtual child_iterator child_end();
1399a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor};
14001eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
140164b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl/// UnaryTypeTraitExpr - A GCC or MS unary type trait, as used in the
140264b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl/// implementation of TR1/C++0x type trait templates.
140364b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl/// Example:
140464b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl/// __is_pod(int) == true
140564b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl/// __is_enum(std::string) == false
140664b45f7e0d3167f040841ac2920aead7f080730dSebastian Redlclass UnaryTypeTraitExpr : public Expr {
14070dfd848fa4c9664852ba8c929a8bd3fce93ddca2Sebastian Redl  /// UTT - The trait. A UnaryTypeTrait enum in MSVC compat unsigned.
14080dfd848fa4c9664852ba8c929a8bd3fce93ddca2Sebastian Redl  unsigned UTT : 31;
14090dfd848fa4c9664852ba8c929a8bd3fce93ddca2Sebastian Redl  /// The value of the type trait. Unspecified if dependent.
14100dfd848fa4c9664852ba8c929a8bd3fce93ddca2Sebastian Redl  bool Value : 1;
141164b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl
141264b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl  /// Loc - The location of the type trait keyword.
141364b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl  SourceLocation Loc;
141464b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl
141564b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl  /// RParen - The location of the closing paren.
141664b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl  SourceLocation RParen;
141764b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl
14180dfd848fa4c9664852ba8c929a8bd3fce93ddca2Sebastian Redl  /// The type being queried.
14193d37c0ada0e46b87be0a10e8d52d990a97d3907aDouglas Gregor  TypeSourceInfo *QueriedType;
142064b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl
142164b45f7e0d3167f040841ac2920aead7f080730dSebastian Redlpublic:
14223d37c0ada0e46b87be0a10e8d52d990a97d3907aDouglas Gregor  UnaryTypeTraitExpr(SourceLocation loc, UnaryTypeTrait utt,
14230dfd848fa4c9664852ba8c929a8bd3fce93ddca2Sebastian Redl                     TypeSourceInfo *queried, bool value,
142464b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl                     SourceLocation rparen, QualType ty)
1425f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall    : Expr(UnaryTypeTraitExprClass, ty, VK_RValue, OK_Ordinary,
1426f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall           false,  queried->getType()->isDependentType()),
14270dfd848fa4c9664852ba8c929a8bd3fce93ddca2Sebastian Redl      UTT(utt), Value(value), Loc(loc), RParen(rparen), QueriedType(queried) { }
142864b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl
14296d00c1365dd3601f6d93bbda9162913c57ae788fArgyrios Kyrtzidis  explicit UnaryTypeTraitExpr(EmptyShell Empty)
14300dfd848fa4c9664852ba8c929a8bd3fce93ddca2Sebastian Redl    : Expr(UnaryTypeTraitExprClass, Empty), UTT(0), Value(false),
14313d37c0ada0e46b87be0a10e8d52d990a97d3907aDouglas Gregor      QueriedType() { }
14326d00c1365dd3601f6d93bbda9162913c57ae788fArgyrios Kyrtzidis
143364b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl  virtual SourceRange getSourceRange() const { return SourceRange(Loc, RParen);}
143464b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl
14350dfd848fa4c9664852ba8c929a8bd3fce93ddca2Sebastian Redl  UnaryTypeTrait getTrait() const { return static_cast<UnaryTypeTrait>(UTT); }
143664b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl
14373d37c0ada0e46b87be0a10e8d52d990a97d3907aDouglas Gregor  QualType getQueriedType() const { return QueriedType->getType(); }
143864b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl
14393d37c0ada0e46b87be0a10e8d52d990a97d3907aDouglas Gregor  TypeSourceInfo *getQueriedTypeSourceInfo() const { return QueriedType; }
14403d37c0ada0e46b87be0a10e8d52d990a97d3907aDouglas Gregor
14410dfd848fa4c9664852ba8c929a8bd3fce93ddca2Sebastian Redl  bool getValue() const { return Value; }
144264b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl
144364b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl  static bool classof(const Stmt *T) {
144464b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl    return T->getStmtClass() == UnaryTypeTraitExprClass;
144564b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl  }
144664b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl  static bool classof(const UnaryTypeTraitExpr *) { return true; }
144764b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl
144864b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl  // Iterators
144964b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl  virtual child_iterator child_begin();
145064b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl  virtual child_iterator child_end();
14516d00c1365dd3601f6d93bbda9162913c57ae788fArgyrios Kyrtzidis
145260adf4acf40b72227740bf966fb87eebddff3f37Sebastian Redl  friend class ASTStmtReader;
145364b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl};
145464b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl
14557bb12da2b0749eeebb21854c77877736969e59f2John McCall/// \brief A reference to an overloaded function set, either an
14567bb12da2b0749eeebb21854c77877736969e59f2John McCall/// \t UnresolvedLookupExpr or an \t UnresolvedMemberExpr.
14577bb12da2b0749eeebb21854c77877736969e59f2John McCallclass OverloadExpr : public Expr {
1458ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  /// The results.  These are undesugared, which is to say, they may
14597bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// include UsingShadowDecls.  Access is relative to the naming
14607bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// class.
1461928e6fcf66fc4f342bcf7cc96bf56986c9c2a833Douglas Gregor  // FIXME: Allocate this data after the OverloadExpr subclass.
1462928e6fcf66fc4f342bcf7cc96bf56986c9c2a833Douglas Gregor  DeclAccessPair *Results;
1463928e6fcf66fc4f342bcf7cc96bf56986c9c2a833Douglas Gregor  unsigned NumResults;
1464ba13543329afac4a0d01304ec2ec4924d99306a6John McCall
14657bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// The common name of these declarations.
14662577743c5650c646fb705df01403707e94f2df04Abramo Bagnara  DeclarationNameInfo NameInfo;
1467ba13543329afac4a0d01304ec2ec4924d99306a6John McCall
14687bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// The scope specifier, if any.
1469ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  NestedNameSpecifier *Qualifier;
14707bb12da2b0749eeebb21854c77877736969e59f2John McCall
14717bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// The source range of the scope specifier.
1472ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  SourceRange QualifierRange;
1473ba13543329afac4a0d01304ec2ec4924d99306a6John McCall
1474a77eb0862507b900a10fa352af1568e639ed10b1Argyrios Kyrtzidisprotected:
14757bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// True if the name was a template-id.
14767bb12da2b0749eeebb21854c77877736969e59f2John McCall  bool HasExplicitTemplateArgs;
14777bb12da2b0749eeebb21854c77877736969e59f2John McCall
1478928e6fcf66fc4f342bcf7cc96bf56986c9c2a833Douglas Gregor  OverloadExpr(StmtClass K, ASTContext &C, QualType T, bool Dependent,
14797bb12da2b0749eeebb21854c77877736969e59f2John McCall               NestedNameSpecifier *Qualifier, SourceRange QRange,
14802577743c5650c646fb705df01403707e94f2df04Abramo Bagnara               const DeclarationNameInfo &NameInfo,
14815a84dec38cfa9e084377a3167b474c79283c82faDouglas Gregor               bool HasTemplateArgs,
1482928e6fcf66fc4f342bcf7cc96bf56986c9c2a833Douglas Gregor               UnresolvedSetIterator Begin, UnresolvedSetIterator End);
14837bb12da2b0749eeebb21854c77877736969e59f2John McCall
1484a77eb0862507b900a10fa352af1568e639ed10b1Argyrios Kyrtzidis  OverloadExpr(StmtClass K, EmptyShell Empty)
1485a77eb0862507b900a10fa352af1568e639ed10b1Argyrios Kyrtzidis    : Expr(K, Empty), Results(0), NumResults(0),
1486a77eb0862507b900a10fa352af1568e639ed10b1Argyrios Kyrtzidis      Qualifier(0), HasExplicitTemplateArgs(false) { }
1487a77eb0862507b900a10fa352af1568e639ed10b1Argyrios Kyrtzidis
14887bb12da2b0749eeebb21854c77877736969e59f2John McCallpublic:
14897bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// Computes whether an unresolved lookup on the given declarations
14907bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// and optional template arguments is type- and value-dependent.
14917bb12da2b0749eeebb21854c77877736969e59f2John McCall  static bool ComputeDependence(UnresolvedSetIterator Begin,
14927bb12da2b0749eeebb21854c77877736969e59f2John McCall                                UnresolvedSetIterator End,
14937bb12da2b0749eeebb21854c77877736969e59f2John McCall                                const TemplateArgumentListInfo *Args);
14947bb12da2b0749eeebb21854c77877736969e59f2John McCall
14959c72c6088d591ace8503b842d39448c2040f3033John McCall  struct FindResult {
14969c72c6088d591ace8503b842d39448c2040f3033John McCall    OverloadExpr *Expression;
14979c72c6088d591ace8503b842d39448c2040f3033John McCall    bool IsAddressOfOperand;
14989c72c6088d591ace8503b842d39448c2040f3033John McCall    bool HasFormOfMemberPointer;
14999c72c6088d591ace8503b842d39448c2040f3033John McCall  };
15009c72c6088d591ace8503b842d39448c2040f3033John McCall
15017bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// Finds the overloaded expression in the given expression of
15027bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// OverloadTy.
15037bb12da2b0749eeebb21854c77877736969e59f2John McCall  ///
15049c72c6088d591ace8503b842d39448c2040f3033John McCall  /// \return the expression (which must be there) and true if it has
15059c72c6088d591ace8503b842d39448c2040f3033John McCall  /// the particular form of a member pointer expression
15069c72c6088d591ace8503b842d39448c2040f3033John McCall  static FindResult find(Expr *E) {
15077bb12da2b0749eeebb21854c77877736969e59f2John McCall    assert(E->getType()->isSpecificBuiltinType(BuiltinType::Overload));
15087bb12da2b0749eeebb21854c77877736969e59f2John McCall
15099c72c6088d591ace8503b842d39448c2040f3033John McCall    FindResult Result;
15109c72c6088d591ace8503b842d39448c2040f3033John McCall
15117bb12da2b0749eeebb21854c77877736969e59f2John McCall    E = E->IgnoreParens();
15129c72c6088d591ace8503b842d39448c2040f3033John McCall    if (isa<UnaryOperator>(E)) {
15139c72c6088d591ace8503b842d39448c2040f3033John McCall      assert(cast<UnaryOperator>(E)->getOpcode() == UO_AddrOf);
15149c72c6088d591ace8503b842d39448c2040f3033John McCall      E = cast<UnaryOperator>(E)->getSubExpr();
15159c72c6088d591ace8503b842d39448c2040f3033John McCall      OverloadExpr *Ovl = cast<OverloadExpr>(E->IgnoreParens());
15169c72c6088d591ace8503b842d39448c2040f3033John McCall
15179c72c6088d591ace8503b842d39448c2040f3033John McCall      Result.HasFormOfMemberPointer = (E == Ovl && Ovl->getQualifier());
15189c72c6088d591ace8503b842d39448c2040f3033John McCall      Result.IsAddressOfOperand = true;
15199c72c6088d591ace8503b842d39448c2040f3033John McCall      Result.Expression = Ovl;
15209c72c6088d591ace8503b842d39448c2040f3033John McCall    } else {
15219c72c6088d591ace8503b842d39448c2040f3033John McCall      Result.HasFormOfMemberPointer = false;
15229c72c6088d591ace8503b842d39448c2040f3033John McCall      Result.IsAddressOfOperand = false;
15239c72c6088d591ace8503b842d39448c2040f3033John McCall      Result.Expression = cast<OverloadExpr>(E);
15249c72c6088d591ace8503b842d39448c2040f3033John McCall    }
15259c72c6088d591ace8503b842d39448c2040f3033John McCall
15269c72c6088d591ace8503b842d39448c2040f3033John McCall    return Result;
15277bb12da2b0749eeebb21854c77877736969e59f2John McCall  }
15287bb12da2b0749eeebb21854c77877736969e59f2John McCall
1529e9ee23edd17c4bb7f271e67f8790792b4de677fcJohn McCall  /// Gets the naming class of this lookup, if any.
1530e9ee23edd17c4bb7f271e67f8790792b4de677fcJohn McCall  CXXRecordDecl *getNamingClass() const;
1531e9ee23edd17c4bb7f271e67f8790792b4de677fcJohn McCall
15327bb12da2b0749eeebb21854c77877736969e59f2John McCall  typedef UnresolvedSetImpl::iterator decls_iterator;
1533928e6fcf66fc4f342bcf7cc96bf56986c9c2a833Douglas Gregor  decls_iterator decls_begin() const { return UnresolvedSetIterator(Results); }
1534928e6fcf66fc4f342bcf7cc96bf56986c9c2a833Douglas Gregor  decls_iterator decls_end() const {
1535928e6fcf66fc4f342bcf7cc96bf56986c9c2a833Douglas Gregor    return UnresolvedSetIterator(Results + NumResults);
1536928e6fcf66fc4f342bcf7cc96bf56986c9c2a833Douglas Gregor  }
1537a77eb0862507b900a10fa352af1568e639ed10b1Argyrios Kyrtzidis
1538a77eb0862507b900a10fa352af1568e639ed10b1Argyrios Kyrtzidis  void initializeResults(ASTContext &C,
1539a77eb0862507b900a10fa352af1568e639ed10b1Argyrios Kyrtzidis                         UnresolvedSetIterator Begin,UnresolvedSetIterator End);
15407bb12da2b0749eeebb21854c77877736969e59f2John McCall
15417bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// Gets the number of declarations in the unresolved set.
1542928e6fcf66fc4f342bcf7cc96bf56986c9c2a833Douglas Gregor  unsigned getNumDecls() const { return NumResults; }
15437bb12da2b0749eeebb21854c77877736969e59f2John McCall
15442577743c5650c646fb705df01403707e94f2df04Abramo Bagnara  /// Gets the full name info.
15452577743c5650c646fb705df01403707e94f2df04Abramo Bagnara  const DeclarationNameInfo &getNameInfo() const { return NameInfo; }
15462577743c5650c646fb705df01403707e94f2df04Abramo Bagnara  void setNameInfo(const DeclarationNameInfo &N) { NameInfo = N; }
15472577743c5650c646fb705df01403707e94f2df04Abramo Bagnara
15487bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// Gets the name looked up.
15492577743c5650c646fb705df01403707e94f2df04Abramo Bagnara  DeclarationName getName() const { return NameInfo.getName(); }
15502577743c5650c646fb705df01403707e94f2df04Abramo Bagnara  void setName(DeclarationName N) { NameInfo.setName(N); }
15517bb12da2b0749eeebb21854c77877736969e59f2John McCall
15527bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// Gets the location of the name.
15532577743c5650c646fb705df01403707e94f2df04Abramo Bagnara  SourceLocation getNameLoc() const { return NameInfo.getLoc(); }
15542577743c5650c646fb705df01403707e94f2df04Abramo Bagnara  void setNameLoc(SourceLocation Loc) { NameInfo.setLoc(Loc); }
15557bb12da2b0749eeebb21854c77877736969e59f2John McCall
15567bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// Fetches the nested-name qualifier, if one was given.
15577bb12da2b0749eeebb21854c77877736969e59f2John McCall  NestedNameSpecifier *getQualifier() const { return Qualifier; }
1558a77eb0862507b900a10fa352af1568e639ed10b1Argyrios Kyrtzidis  void setQualifier(NestedNameSpecifier *NNS) { Qualifier = NNS; }
15597bb12da2b0749eeebb21854c77877736969e59f2John McCall
15607bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// Fetches the range of the nested-name qualifier.
15617bb12da2b0749eeebb21854c77877736969e59f2John McCall  SourceRange getQualifierRange() const { return QualifierRange; }
1562a77eb0862507b900a10fa352af1568e639ed10b1Argyrios Kyrtzidis  void setQualifierRange(SourceRange R) { QualifierRange = R; }
15637bb12da2b0749eeebb21854c77877736969e59f2John McCall
15647bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// \brief Determines whether this expression had an explicit
15657bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// template argument list, e.g. f<int>.
15667bb12da2b0749eeebb21854c77877736969e59f2John McCall  bool hasExplicitTemplateArgs() const { return HasExplicitTemplateArgs; }
15677bb12da2b0749eeebb21854c77877736969e59f2John McCall
15687bb12da2b0749eeebb21854c77877736969e59f2John McCall  ExplicitTemplateArgumentList &getExplicitTemplateArgs(); // defined far below
15697bb12da2b0749eeebb21854c77877736969e59f2John McCall
15707bb12da2b0749eeebb21854c77877736969e59f2John McCall  const ExplicitTemplateArgumentList &getExplicitTemplateArgs() const {
15717bb12da2b0749eeebb21854c77877736969e59f2John McCall    return const_cast<OverloadExpr*>(this)->getExplicitTemplateArgs();
15727bb12da2b0749eeebb21854c77877736969e59f2John McCall  }
15737bb12da2b0749eeebb21854c77877736969e59f2John McCall
1574096832c5ed5b9106fa177ebc148489760c3bc496John McCall  /// \brief Retrieves the optional explicit template arguments.
1575096832c5ed5b9106fa177ebc148489760c3bc496John McCall  /// This points to the same data as getExplicitTemplateArgs(), but
1576096832c5ed5b9106fa177ebc148489760c3bc496John McCall  /// returns null if there are no explicit template arguments.
1577096832c5ed5b9106fa177ebc148489760c3bc496John McCall  const ExplicitTemplateArgumentList *getOptionalExplicitTemplateArgs() {
1578096832c5ed5b9106fa177ebc148489760c3bc496John McCall    if (!hasExplicitTemplateArgs()) return 0;
1579096832c5ed5b9106fa177ebc148489760c3bc496John McCall    return &getExplicitTemplateArgs();
15807bb12da2b0749eeebb21854c77877736969e59f2John McCall  }
15817bb12da2b0749eeebb21854c77877736969e59f2John McCall
15827bb12da2b0749eeebb21854c77877736969e59f2John McCall  static bool classof(const Stmt *T) {
15837bb12da2b0749eeebb21854c77877736969e59f2John McCall    return T->getStmtClass() == UnresolvedLookupExprClass ||
15847bb12da2b0749eeebb21854c77877736969e59f2John McCall           T->getStmtClass() == UnresolvedMemberExprClass;
15857bb12da2b0749eeebb21854c77877736969e59f2John McCall  }
15867bb12da2b0749eeebb21854c77877736969e59f2John McCall  static bool classof(const OverloadExpr *) { return true; }
15874045107b7384fd68eed5e3e2f06fc2a47e7be0a6Argyrios Kyrtzidis
15884045107b7384fd68eed5e3e2f06fc2a47e7be0a6Argyrios Kyrtzidis  friend class ASTStmtReader;
15894045107b7384fd68eed5e3e2f06fc2a47e7be0a6Argyrios Kyrtzidis  friend class ASTStmtWriter;
15907bb12da2b0749eeebb21854c77877736969e59f2John McCall};
15917bb12da2b0749eeebb21854c77877736969e59f2John McCall
15927bb12da2b0749eeebb21854c77877736969e59f2John McCall/// \brief A reference to a name which we were able to look up during
15937bb12da2b0749eeebb21854c77877736969e59f2John McCall/// parsing but could not resolve to a specific declaration.  This
15947bb12da2b0749eeebb21854c77877736969e59f2John McCall/// arises in several ways:
15957bb12da2b0749eeebb21854c77877736969e59f2John McCall///   * we might be waiting for argument-dependent lookup
15967bb12da2b0749eeebb21854c77877736969e59f2John McCall///   * the name might resolve to an overloaded function
15977bb12da2b0749eeebb21854c77877736969e59f2John McCall/// and eventually:
15987bb12da2b0749eeebb21854c77877736969e59f2John McCall///   * the lookup might have included a function template
15997bb12da2b0749eeebb21854c77877736969e59f2John McCall/// These never include UnresolvedUsingValueDecls, which are always
16007bb12da2b0749eeebb21854c77877736969e59f2John McCall/// class members and therefore appear only in
16017bb12da2b0749eeebb21854c77877736969e59f2John McCall/// UnresolvedMemberLookupExprs.
16027bb12da2b0749eeebb21854c77877736969e59f2John McCallclass UnresolvedLookupExpr : public OverloadExpr {
1603ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  /// True if these lookup results should be extended by
1604ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  /// argument-dependent lookup if this is the operand of a function
1605ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  /// call.
1606ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  bool RequiresADL;
1607ba13543329afac4a0d01304ec2ec4924d99306a6John McCall
16087453ed4cb2cab113de3378df371b1c6f1243d832John McCall  /// True if these lookup results are overloaded.  This is pretty
16097453ed4cb2cab113de3378df371b1c6f1243d832John McCall  /// trivially rederivable if we urgently need to kill this field.
16107453ed4cb2cab113de3378df371b1c6f1243d832John McCall  bool Overloaded;
16117453ed4cb2cab113de3378df371b1c6f1243d832John McCall
16127bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// The naming class (C++ [class.access.base]p5) of the lookup, if
16137bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// any.  This can generally be recalculated from the context chain,
16147bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// but that can be fairly expensive for unqualified lookups.  If we
16157bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// want to improve memory use here, this could go in a union
16167bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// against the qualified-lookup bits.
16177bb12da2b0749eeebb21854c77877736969e59f2John McCall  CXXRecordDecl *NamingClass;
1618f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall
1619928e6fcf66fc4f342bcf7cc96bf56986c9c2a833Douglas Gregor  UnresolvedLookupExpr(ASTContext &C, QualType T, bool Dependent,
1620928e6fcf66fc4f342bcf7cc96bf56986c9c2a833Douglas Gregor                       CXXRecordDecl *NamingClass,
1621ba13543329afac4a0d01304ec2ec4924d99306a6John McCall                       NestedNameSpecifier *Qualifier, SourceRange QRange,
16222577743c5650c646fb705df01403707e94f2df04Abramo Bagnara                       const DeclarationNameInfo &NameInfo,
16235a84dec38cfa9e084377a3167b474c79283c82faDouglas Gregor                       bool RequiresADL, bool Overloaded, bool HasTemplateArgs,
16245a84dec38cfa9e084377a3167b474c79283c82faDouglas Gregor                       UnresolvedSetIterator Begin, UnresolvedSetIterator End)
1625f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall    : OverloadExpr(UnresolvedLookupExprClass, C, T,
1626f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall                   Dependent, Qualifier,  QRange, NameInfo, HasTemplateArgs,
1627f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall                   Begin, End),
16287bb12da2b0749eeebb21854c77877736969e59f2John McCall      RequiresADL(RequiresADL), Overloaded(Overloaded), NamingClass(NamingClass)
1629ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  {}
1630ba13543329afac4a0d01304ec2ec4924d99306a6John McCall
1631bd65bb511c26549c96b829c1282e4c877588564aArgyrios Kyrtzidis  UnresolvedLookupExpr(EmptyShell Empty)
1632bd65bb511c26549c96b829c1282e4c877588564aArgyrios Kyrtzidis    : OverloadExpr(UnresolvedLookupExprClass, Empty),
1633bd65bb511c26549c96b829c1282e4c877588564aArgyrios Kyrtzidis      RequiresADL(false), Overloaded(false), NamingClass(0)
1634bd65bb511c26549c96b829c1282e4c877588564aArgyrios Kyrtzidis  {}
1635bd65bb511c26549c96b829c1282e4c877588564aArgyrios Kyrtzidis
1636ba13543329afac4a0d01304ec2ec4924d99306a6John McCallpublic:
1637ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  static UnresolvedLookupExpr *Create(ASTContext &C,
1638f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall                                      bool Dependent,
1639c373d48502ca7683ab55385f5bd624d778eb288dJohn McCall                                      CXXRecordDecl *NamingClass,
1640ba13543329afac4a0d01304ec2ec4924d99306a6John McCall                                      NestedNameSpecifier *Qualifier,
1641ba13543329afac4a0d01304ec2ec4924d99306a6John McCall                                      SourceRange QualifierRange,
16422577743c5650c646fb705df01403707e94f2df04Abramo Bagnara                                      const DeclarationNameInfo &NameInfo,
16435a84dec38cfa9e084377a3167b474c79283c82faDouglas Gregor                                      bool ADL, bool Overloaded,
16445a84dec38cfa9e084377a3167b474c79283c82faDouglas Gregor                                      UnresolvedSetIterator Begin,
16455a84dec38cfa9e084377a3167b474c79283c82faDouglas Gregor                                      UnresolvedSetIterator End) {
1646928e6fcf66fc4f342bcf7cc96bf56986c9c2a833Douglas Gregor    return new(C) UnresolvedLookupExpr(C,
1647928e6fcf66fc4f342bcf7cc96bf56986c9c2a833Douglas Gregor                                       Dependent ? C.DependentTy : C.OverloadTy,
1648c373d48502ca7683ab55385f5bd624d778eb288dJohn McCall                                       Dependent, NamingClass,
16492577743c5650c646fb705df01403707e94f2df04Abramo Bagnara                                       Qualifier, QualifierRange, NameInfo,
16502577743c5650c646fb705df01403707e94f2df04Abramo Bagnara                                       ADL, Overloaded, false,
16515a84dec38cfa9e084377a3167b474c79283c82faDouglas Gregor                                       Begin, End);
1652ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  }
1653ba13543329afac4a0d01304ec2ec4924d99306a6John McCall
1654f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  static UnresolvedLookupExpr *Create(ASTContext &C,
1655f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall                                      bool Dependent,
1656c373d48502ca7683ab55385f5bd624d778eb288dJohn McCall                                      CXXRecordDecl *NamingClass,
1657f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall                                      NestedNameSpecifier *Qualifier,
1658f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall                                      SourceRange QualifierRange,
16592577743c5650c646fb705df01403707e94f2df04Abramo Bagnara                                      const DeclarationNameInfo &NameInfo,
1660f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall                                      bool ADL,
16615a84dec38cfa9e084377a3167b474c79283c82faDouglas Gregor                                      const TemplateArgumentListInfo &Args,
16625a84dec38cfa9e084377a3167b474c79283c82faDouglas Gregor                                      UnresolvedSetIterator Begin,
16635a84dec38cfa9e084377a3167b474c79283c82faDouglas Gregor                                      UnresolvedSetIterator End);
1664f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall
1665bd65bb511c26549c96b829c1282e4c877588564aArgyrios Kyrtzidis  static UnresolvedLookupExpr *CreateEmpty(ASTContext &C,
1666bd65bb511c26549c96b829c1282e4c877588564aArgyrios Kyrtzidis                                           unsigned NumTemplateArgs);
1667bd65bb511c26549c96b829c1282e4c877588564aArgyrios Kyrtzidis
1668ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  /// True if this declaration should be extended by
1669ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  /// argument-dependent lookup.
1670ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  bool requiresADL() const { return RequiresADL; }
1671bd65bb511c26549c96b829c1282e4c877588564aArgyrios Kyrtzidis  void setRequiresADL(bool V) { RequiresADL = V; }
1672ba13543329afac4a0d01304ec2ec4924d99306a6John McCall
16737453ed4cb2cab113de3378df371b1c6f1243d832John McCall  /// True if this lookup is overloaded.
16747453ed4cb2cab113de3378df371b1c6f1243d832John McCall  bool isOverloaded() const { return Overloaded; }
1675bd65bb511c26549c96b829c1282e4c877588564aArgyrios Kyrtzidis  void setOverloaded(bool V) { Overloaded = V; }
16767453ed4cb2cab113de3378df371b1c6f1243d832John McCall
1677c373d48502ca7683ab55385f5bd624d778eb288dJohn McCall  /// Gets the 'naming class' (in the sense of C++0x
1678c373d48502ca7683ab55385f5bd624d778eb288dJohn McCall  /// [class.access.base]p5) of the lookup.  This is the scope
1679c373d48502ca7683ab55385f5bd624d778eb288dJohn McCall  /// that was looked in to find these results.
1680c373d48502ca7683ab55385f5bd624d778eb288dJohn McCall  CXXRecordDecl *getNamingClass() const { return NamingClass; }
1681bd65bb511c26549c96b829c1282e4c877588564aArgyrios Kyrtzidis  void setNamingClass(CXXRecordDecl *D) { NamingClass = D; }
1682c373d48502ca7683ab55385f5bd624d778eb288dJohn McCall
1683f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  // Note that, inconsistently with the explicit-template-argument AST
1684f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  // nodes, users are *forbidden* from calling these methods on objects
1685f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  // without explicit template arguments.
1686f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall
16877bb12da2b0749eeebb21854c77877736969e59f2John McCall  ExplicitTemplateArgumentList &getExplicitTemplateArgs() {
16887bb12da2b0749eeebb21854c77877736969e59f2John McCall    assert(hasExplicitTemplateArgs());
16897bb12da2b0749eeebb21854c77877736969e59f2John McCall    return *reinterpret_cast<ExplicitTemplateArgumentList*>(this + 1);
16907bb12da2b0749eeebb21854c77877736969e59f2John McCall  }
16917bb12da2b0749eeebb21854c77877736969e59f2John McCall
1692f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  /// Gets a reference to the explicit template argument list.
1693f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  const ExplicitTemplateArgumentList &getExplicitTemplateArgs() const {
1694f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall    assert(hasExplicitTemplateArgs());
1695f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall    return *reinterpret_cast<const ExplicitTemplateArgumentList*>(this + 1);
1696f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  }
1697f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall
1698096832c5ed5b9106fa177ebc148489760c3bc496John McCall  /// \brief Retrieves the optional explicit template arguments.
1699096832c5ed5b9106fa177ebc148489760c3bc496John McCall  /// This points to the same data as getExplicitTemplateArgs(), but
1700096832c5ed5b9106fa177ebc148489760c3bc496John McCall  /// returns null if there are no explicit template arguments.
1701096832c5ed5b9106fa177ebc148489760c3bc496John McCall  const ExplicitTemplateArgumentList *getOptionalExplicitTemplateArgs() {
1702096832c5ed5b9106fa177ebc148489760c3bc496John McCall    if (!hasExplicitTemplateArgs()) return 0;
1703096832c5ed5b9106fa177ebc148489760c3bc496John McCall    return &getExplicitTemplateArgs();
1704096832c5ed5b9106fa177ebc148489760c3bc496John McCall  }
1705096832c5ed5b9106fa177ebc148489760c3bc496John McCall
1706f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  /// \brief Copies the template arguments (if present) into the given
1707f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  /// structure.
1708f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  void copyTemplateArgumentsInto(TemplateArgumentListInfo &List) const {
1709f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall    getExplicitTemplateArgs().copyInto(List);
1710f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  }
1711ba13543329afac4a0d01304ec2ec4924d99306a6John McCall
1712f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  SourceLocation getLAngleLoc() const {
1713f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall    return getExplicitTemplateArgs().LAngleLoc;
1714f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  }
1715f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall
1716f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  SourceLocation getRAngleLoc() const {
1717f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall    return getExplicitTemplateArgs().RAngleLoc;
1718f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  }
1719f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall
1720f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  TemplateArgumentLoc const *getTemplateArgs() const {
1721f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall    return getExplicitTemplateArgs().getTemplateArgs();
1722f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  }
1723f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall
1724f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  unsigned getNumTemplateArgs() const {
1725f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall    return getExplicitTemplateArgs().NumTemplateArgs;
1726f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  }
1727ba13543329afac4a0d01304ec2ec4924d99306a6John McCall
1728ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  virtual SourceRange getSourceRange() const {
17292577743c5650c646fb705df01403707e94f2df04Abramo Bagnara    SourceRange Range(getNameInfo().getSourceRange());
17307bb12da2b0749eeebb21854c77877736969e59f2John McCall    if (getQualifier()) Range.setBegin(getQualifierRange().getBegin());
1731f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall    if (hasExplicitTemplateArgs()) Range.setEnd(getRAngleLoc());
1732f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall    return Range;
1733ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  }
1734ba13543329afac4a0d01304ec2ec4924d99306a6John McCall
1735ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  virtual StmtIterator child_begin();
1736ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  virtual StmtIterator child_end();
1737ba13543329afac4a0d01304ec2ec4924d99306a6John McCall
1738ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  static bool classof(const Stmt *T) {
1739ba13543329afac4a0d01304ec2ec4924d99306a6John McCall    return T->getStmtClass() == UnresolvedLookupExprClass;
1740ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  }
1741ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  static bool classof(const UnresolvedLookupExpr *) { return true; }
1742ba13543329afac4a0d01304ec2ec4924d99306a6John McCall};
1743ba13543329afac4a0d01304ec2ec4924d99306a6John McCall
17445953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor/// \brief A qualified reference to a name whose declaration cannot
17455953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor/// yet be resolved.
17465953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor///
1747ba13543329afac4a0d01304ec2ec4924d99306a6John McCall/// DependentScopeDeclRefExpr is similar to DeclRefExpr in that
1748a2813cec2605ce7878d1b13471d685f689b251afDouglas Gregor/// it expresses a reference to a declaration such as
17495953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor/// X<T>::value. The difference, however, is that an
1750865d447ac6a4721ab58e898d014a21f2eff74b06John McCall/// DependentScopeDeclRefExpr node is used only within C++ templates when
17515953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor/// the qualification (e.g., X<T>::) refers to a dependent type. In
17525953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor/// this case, X<T>::value cannot resolve to a declaration because the
17535953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor/// declaration will differ from on instantiation of X<T> to the
1754865d447ac6a4721ab58e898d014a21f2eff74b06John McCall/// next. Therefore, DependentScopeDeclRefExpr keeps track of the
1755ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor/// qualifier (X<T>::) and the name of the entity being referenced
1756a2813cec2605ce7878d1b13471d685f689b251afDouglas Gregor/// ("value"). Such expressions will instantiate to a DeclRefExpr once the
1757a2813cec2605ce7878d1b13471d685f689b251afDouglas Gregor/// declaration can be found.
1758865d447ac6a4721ab58e898d014a21f2eff74b06John McCallclass DependentScopeDeclRefExpr : public Expr {
17595953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor  /// The name of the entity we will be referencing.
17602577743c5650c646fb705df01403707e94f2df04Abramo Bagnara  DeclarationNameInfo NameInfo;
17615953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor
17625953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor  /// QualifierRange - The source range that covers the
17635953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor  /// nested-name-specifier.
17645953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor  SourceRange QualifierRange;
17655953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor
1766ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor  /// \brief The nested-name-specifier that qualifies this unresolved
1767ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor  /// declaration name.
1768f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  NestedNameSpecifier *Qualifier;
17695953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor
1770f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  /// \brief Whether the name includes explicit template arguments.
1771f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  bool HasExplicitTemplateArgs;
17721eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1773f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  DependentScopeDeclRefExpr(QualType T,
1774f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall                            NestedNameSpecifier *Qualifier,
1775f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall                            SourceRange QualifierRange,
17762577743c5650c646fb705df01403707e94f2df04Abramo Bagnara                            const DeclarationNameInfo &NameInfo,
1777f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall                            bool HasExplicitTemplateArgs)
1778f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall    : Expr(DependentScopeDeclRefExprClass, T, VK_LValue, OK_Ordinary,
1779f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall           true, true),
17802577743c5650c646fb705df01403707e94f2df04Abramo Bagnara      NameInfo(NameInfo), QualifierRange(QualifierRange), Qualifier(Qualifier),
1781f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall      HasExplicitTemplateArgs(HasExplicitTemplateArgs)
1782f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  {}
1783f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall
1784f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCallpublic:
1785f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  static DependentScopeDeclRefExpr *Create(ASTContext &C,
1786f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall                                           NestedNameSpecifier *Qualifier,
1787f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall                                           SourceRange QualifierRange,
17882577743c5650c646fb705df01403707e94f2df04Abramo Bagnara                                           const DeclarationNameInfo &NameInfo,
1789f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall                              const TemplateArgumentListInfo *TemplateArgs = 0);
17905953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor
179112dffcddb60380c5bed4f085a1f51534afda3b87Argyrios Kyrtzidis  static DependentScopeDeclRefExpr *CreateEmpty(ASTContext &C,
179212dffcddb60380c5bed4f085a1f51534afda3b87Argyrios Kyrtzidis                                                unsigned NumTemplateArgs);
179312dffcddb60380c5bed4f085a1f51534afda3b87Argyrios Kyrtzidis
17945953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor  /// \brief Retrieve the name that this expression refers to.
17952577743c5650c646fb705df01403707e94f2df04Abramo Bagnara  const DeclarationNameInfo &getNameInfo() const { return NameInfo; }
17962577743c5650c646fb705df01403707e94f2df04Abramo Bagnara  void setNameInfo(const DeclarationNameInfo &N) { NameInfo =  N; }
17972577743c5650c646fb705df01403707e94f2df04Abramo Bagnara
17982577743c5650c646fb705df01403707e94f2df04Abramo Bagnara  /// \brief Retrieve the name that this expression refers to.
17992577743c5650c646fb705df01403707e94f2df04Abramo Bagnara  DeclarationName getDeclName() const { return NameInfo.getName(); }
18002577743c5650c646fb705df01403707e94f2df04Abramo Bagnara  void setDeclName(DeclarationName N) { NameInfo.setName(N); }
18015953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor
18025953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor  /// \brief Retrieve the location of the name within the expression.
18032577743c5650c646fb705df01403707e94f2df04Abramo Bagnara  SourceLocation getLocation() const { return NameInfo.getLoc(); }
18042577743c5650c646fb705df01403707e94f2df04Abramo Bagnara  void setLocation(SourceLocation L) { NameInfo.setLoc(L); }
18055953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor
18065953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor  /// \brief Retrieve the source range of the nested-name-specifier.
18075953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor  SourceRange getQualifierRange() const { return QualifierRange; }
180812dffcddb60380c5bed4f085a1f51534afda3b87Argyrios Kyrtzidis  void setQualifierRange(SourceRange R) { QualifierRange = R; }
18095953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor
1810ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor  /// \brief Retrieve the nested-name-specifier that qualifies this
1811ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor  /// declaration.
1812edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor  NestedNameSpecifier *getQualifier() const { return Qualifier; }
181312dffcddb60380c5bed4f085a1f51534afda3b87Argyrios Kyrtzidis  void setQualifier(NestedNameSpecifier *NNS) { Qualifier = NNS; }
18141eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1815f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  /// Determines whether this lookup had explicit template arguments.
1816f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  bool hasExplicitTemplateArgs() const { return HasExplicitTemplateArgs; }
18171eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1818f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  // Note that, inconsistently with the explicit-template-argument AST
1819f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  // nodes, users are *forbidden* from calling these methods on objects
1820f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  // without explicit template arguments.
18211eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
182212dffcddb60380c5bed4f085a1f51534afda3b87Argyrios Kyrtzidis  ExplicitTemplateArgumentList &getExplicitTemplateArgs() {
182312dffcddb60380c5bed4f085a1f51534afda3b87Argyrios Kyrtzidis    assert(hasExplicitTemplateArgs());
182412dffcddb60380c5bed4f085a1f51534afda3b87Argyrios Kyrtzidis    return *reinterpret_cast<ExplicitTemplateArgumentList*>(this + 1);
182512dffcddb60380c5bed4f085a1f51534afda3b87Argyrios Kyrtzidis  }
182612dffcddb60380c5bed4f085a1f51534afda3b87Argyrios Kyrtzidis
1827f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  /// Gets a reference to the explicit template argument list.
1828f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  const ExplicitTemplateArgumentList &getExplicitTemplateArgs() const {
1829f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall    assert(hasExplicitTemplateArgs());
1830f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall    return *reinterpret_cast<const ExplicitTemplateArgumentList*>(this + 1);
1831f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  }
18321eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1833096832c5ed5b9106fa177ebc148489760c3bc496John McCall  /// \brief Retrieves the optional explicit template arguments.
1834096832c5ed5b9106fa177ebc148489760c3bc496John McCall  /// This points to the same data as getExplicitTemplateArgs(), but
1835096832c5ed5b9106fa177ebc148489760c3bc496John McCall  /// returns null if there are no explicit template arguments.
1836096832c5ed5b9106fa177ebc148489760c3bc496John McCall  const ExplicitTemplateArgumentList *getOptionalExplicitTemplateArgs() {
1837096832c5ed5b9106fa177ebc148489760c3bc496John McCall    if (!hasExplicitTemplateArgs()) return 0;
1838096832c5ed5b9106fa177ebc148489760c3bc496John McCall    return &getExplicitTemplateArgs();
1839096832c5ed5b9106fa177ebc148489760c3bc496John McCall  }
1840096832c5ed5b9106fa177ebc148489760c3bc496John McCall
1841f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  /// \brief Copies the template arguments (if present) into the given
1842f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  /// structure.
1843f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  void copyTemplateArgumentsInto(TemplateArgumentListInfo &List) const {
1844f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall    getExplicitTemplateArgs().copyInto(List);
1845f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  }
1846f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall
1847f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  SourceLocation getLAngleLoc() const {
1848f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall    return getExplicitTemplateArgs().LAngleLoc;
1849edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor  }
18501eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1851f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  SourceLocation getRAngleLoc() const {
1852f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall    return getExplicitTemplateArgs().RAngleLoc;
1853f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  }
18541eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1855f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  TemplateArgumentLoc const *getTemplateArgs() const {
1856f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall    return getExplicitTemplateArgs().getTemplateArgs();
1857d5532b6cfff2977e0c59fa6ead7f7973984a620dJohn McCall  }
1858d5532b6cfff2977e0c59fa6ead7f7973984a620dJohn McCall
1859f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  unsigned getNumTemplateArgs() const {
1860f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall    return getExplicitTemplateArgs().NumTemplateArgs;
1861f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  }
18621eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1863edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor  virtual SourceRange getSourceRange() const {
1864f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall    SourceRange Range(QualifierRange.getBegin(), getLocation());
1865f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall    if (hasExplicitTemplateArgs())
1866f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall      Range.setEnd(getRAngleLoc());
1867f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall    return Range;
1868edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor  }
18691eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
18701eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  static bool classof(const Stmt *T) {
1871f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall    return T->getStmtClass() == DependentScopeDeclRefExprClass;
1872edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor  }
1873f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  static bool classof(const DependentScopeDeclRefExpr *) { return true; }
1874f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall
1875f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  virtual StmtIterator child_begin();
1876f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  virtual StmtIterator child_end();
18774045107b7384fd68eed5e3e2f06fc2a47e7be0a6Argyrios Kyrtzidis
18784045107b7384fd68eed5e3e2f06fc2a47e7be0a6Argyrios Kyrtzidis  friend class ASTStmtReader;
18794045107b7384fd68eed5e3e2f06fc2a47e7be0a6Argyrios Kyrtzidis  friend class ASTStmtWriter;
1880edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor};
18811eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
18822d44e8a41de8a33c0f04ac198714f71dc841bab0Anders Carlssonclass CXXExprWithTemporaries : public Expr {
188302bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson  Stmt *SubExpr;
18841eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1885ff6b3d64c9f07155f1414411b8451d7bf8937c62Anders Carlsson  CXXTemporary **Temps;
1886ff6b3d64c9f07155f1414411b8451d7bf8937c62Anders Carlsson  unsigned NumTemps;
188702bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson
1888d04ed416be7c55bddddab1fa3fd38a0113a6b3daTed Kremenek  CXXExprWithTemporaries(ASTContext &C, Expr *SubExpr, CXXTemporary **Temps,
18890ece491d8f62ce67f047491a6703fac0d3bd4ff4Anders Carlsson                         unsigned NumTemps);
189042602bb40aefcc2751d4078ba88aacf4d965c9bdDouglas Gregor
189188eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlssonpublic:
1892d2598368876cfe40bc8465540033bc5b5e58d8afChris Lattner  CXXExprWithTemporaries(EmptyShell Empty)
1893d2598368876cfe40bc8465540033bc5b5e58d8afChris Lattner    : Expr(CXXExprWithTemporariesClass, Empty),
1894d2598368876cfe40bc8465540033bc5b5e58d8afChris Lattner      SubExpr(0), Temps(0), NumTemps(0) {}
1895d2598368876cfe40bc8465540033bc5b5e58d8afChris Lattner
189688eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlsson  static CXXExprWithTemporaries *Create(ASTContext &C, Expr *SubExpr,
18970ece491d8f62ce67f047491a6703fac0d3bd4ff4Anders Carlsson                                        CXXTemporary **Temps,
18980ece491d8f62ce67f047491a6703fac0d3bd4ff4Anders Carlsson                                        unsigned NumTemps);
18991eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
190088eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlsson  unsigned getNumTemporaries() const { return NumTemps; }
1901d04ed416be7c55bddddab1fa3fd38a0113a6b3daTed Kremenek  void setNumTemporaries(ASTContext &C, unsigned N);
1902d2598368876cfe40bc8465540033bc5b5e58d8afChris Lattner
190388eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlsson  CXXTemporary *getTemporary(unsigned i) {
190488eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlsson    assert(i < NumTemps && "Index out of range");
190588eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlsson    return Temps[i];
190688eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlsson  }
1907f0721fe438d7e40c168e5d664970e7830bc138fbAnders Carlsson  const CXXTemporary *getTemporary(unsigned i) const {
19080ece491d8f62ce67f047491a6703fac0d3bd4ff4Anders Carlsson    return const_cast<CXXExprWithTemporaries*>(this)->getTemporary(i);
1909f0721fe438d7e40c168e5d664970e7830bc138fbAnders Carlsson  }
1910d2598368876cfe40bc8465540033bc5b5e58d8afChris Lattner  void setTemporary(unsigned i, CXXTemporary *T) {
1911d2598368876cfe40bc8465540033bc5b5e58d8afChris Lattner    assert(i < NumTemps && "Index out of range");
1912d2598368876cfe40bc8465540033bc5b5e58d8afChris Lattner    Temps[i] = T;
1913d2598368876cfe40bc8465540033bc5b5e58d8afChris Lattner  }
19141eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
191502bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson  Expr *getSubExpr() { return cast<Expr>(SubExpr); }
1916f0721fe438d7e40c168e5d664970e7830bc138fbAnders Carlsson  const Expr *getSubExpr() const { return cast<Expr>(SubExpr); }
191788eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlsson  void setSubExpr(Expr *E) { SubExpr = E; }
191802bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson
191996be6917e1c4ba1f4435a14c9e7c6c139571d086Douglas Gregor  virtual SourceRange getSourceRange() const {
192096be6917e1c4ba1f4435a14c9e7c6c139571d086Douglas Gregor    return SubExpr->getSourceRange();
192196be6917e1c4ba1f4435a14c9e7c6c139571d086Douglas Gregor  }
192202bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson
192302bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson  // Implement isa/cast/dyncast/etc.
192402bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson  static bool classof(const Stmt *T) {
19252d44e8a41de8a33c0f04ac198714f71dc841bab0Anders Carlsson    return T->getStmtClass() == CXXExprWithTemporariesClass;
192602bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson  }
19272d44e8a41de8a33c0f04ac198714f71dc841bab0Anders Carlsson  static bool classof(const CXXExprWithTemporaries *) { return true; }
192802bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson
192902bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson  // Iterators
193002bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson  virtual child_iterator child_begin();
193102bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson  virtual child_iterator child_end();
193202bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson};
193302bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson
1934d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// \brief Describes an explicit type conversion that uses functional
1935d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// notion but could not be resolved because one or more arguments are
1936d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// type-dependent.
1937d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor///
1938d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// The explicit type conversions expressed by
1939d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// CXXUnresolvedConstructExpr have the form \c T(a1, a2, ..., aN),
1940d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// where \c T is some type and \c a1, a2, ..., aN are values, and
1941d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// either \C T is a dependent type or one or more of the \c a's is
1942d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// type-dependent. For example, this would occur in a template such
1943d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// as:
1944d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor///
1945d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// \code
1946d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor///   template<typename T, typename A1>
1947d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor///   inline T make_a(const A1& a1) {
1948d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor///     return T(a1);
1949d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor///   }
1950d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// \endcode
1951d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor///
1952d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// When the returned expression is instantiated, it may resolve to a
1953d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// constructor call, conversion function call, or some kind of type
1954d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// conversion.
1955d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregorclass CXXUnresolvedConstructExpr : public Expr {
1956d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  /// \brief The type being constructed.
1957ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor  TypeSourceInfo *Type;
1958ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor
1959d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  /// \brief The location of the left parentheses ('(').
1960d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  SourceLocation LParenLoc;
1961d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor
1962d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  /// \brief The location of the right parentheses (')').
1963d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  SourceLocation RParenLoc;
1964d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor
1965d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  /// \brief The number of arguments used to construct the type.
1966d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  unsigned NumArgs;
19671eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1968ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor  CXXUnresolvedConstructExpr(TypeSourceInfo *Type,
1969d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor                             SourceLocation LParenLoc,
1970d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor                             Expr **Args,
1971d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor                             unsigned NumArgs,
1972d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor                             SourceLocation RParenLoc);
1973d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor
19748dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis  CXXUnresolvedConstructExpr(EmptyShell Empty, unsigned NumArgs)
1975ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor    : Expr(CXXUnresolvedConstructExprClass, Empty), Type(), NumArgs(NumArgs) { }
19768dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis
1977ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor  friend class ASTStmtReader;
1978ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor
1979d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregorpublic:
19801eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  static CXXUnresolvedConstructExpr *Create(ASTContext &C,
1981ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor                                            TypeSourceInfo *Type,
1982d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor                                            SourceLocation LParenLoc,
1983d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor                                            Expr **Args,
1984d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor                                            unsigned NumArgs,
1985d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor                                            SourceLocation RParenLoc);
1986d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor
19878dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis  static CXXUnresolvedConstructExpr *CreateEmpty(ASTContext &C,
19888dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis                                                 unsigned NumArgs);
19898dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis
1990d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  /// \brief Retrieve the type that is being constructed, as specified
1991d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  /// in the source code.
1992ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor  QualType getTypeAsWritten() const { return Type->getType(); }
1993d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor
1994ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor  /// \brief Retrieve the type source information for the type being
1995ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor  /// constructed.
1996ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor  TypeSourceInfo *getTypeSourceInfo() const { return Type; }
1997ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor
1998d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  /// \brief Retrieve the location of the left parentheses ('(') that
1999d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  /// precedes the argument list.
2000d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  SourceLocation getLParenLoc() const { return LParenLoc; }
2001d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  void setLParenLoc(SourceLocation L) { LParenLoc = L; }
2002d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor
2003d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  /// \brief Retrieve the location of the right parentheses (')') that
2004d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  /// follows the argument list.
2005d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  SourceLocation getRParenLoc() const { return RParenLoc; }
2006d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  void setRParenLoc(SourceLocation L) { RParenLoc = L; }
2007d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor
2008d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  /// \brief Retrieve the number of arguments.
2009d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  unsigned arg_size() const { return NumArgs; }
2010d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor
2011d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  typedef Expr** arg_iterator;
2012d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  arg_iterator arg_begin() { return reinterpret_cast<Expr**>(this + 1); }
2013d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  arg_iterator arg_end() { return arg_begin() + NumArgs; }
2014d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor
20151dd7383dc48718c452e71a625b29531dd96fbb9dJohn McCall  typedef const Expr* const * const_arg_iterator;
20161dd7383dc48718c452e71a625b29531dd96fbb9dJohn McCall  const_arg_iterator arg_begin() const {
20171dd7383dc48718c452e71a625b29531dd96fbb9dJohn McCall    return reinterpret_cast<const Expr* const *>(this + 1);
20181dd7383dc48718c452e71a625b29531dd96fbb9dJohn McCall  }
20191dd7383dc48718c452e71a625b29531dd96fbb9dJohn McCall  const_arg_iterator arg_end() const {
20201dd7383dc48718c452e71a625b29531dd96fbb9dJohn McCall    return arg_begin() + NumArgs;
20211dd7383dc48718c452e71a625b29531dd96fbb9dJohn McCall  }
20221dd7383dc48718c452e71a625b29531dd96fbb9dJohn McCall
2023d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  Expr *getArg(unsigned I) {
2024d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor    assert(I < NumArgs && "Argument index out-of-range");
2025d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor    return *(arg_begin() + I);
2026d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  }
2027d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor
20281dd7383dc48718c452e71a625b29531dd96fbb9dJohn McCall  const Expr *getArg(unsigned I) const {
20291dd7383dc48718c452e71a625b29531dd96fbb9dJohn McCall    assert(I < NumArgs && "Argument index out-of-range");
20301dd7383dc48718c452e71a625b29531dd96fbb9dJohn McCall    return *(arg_begin() + I);
20311dd7383dc48718c452e71a625b29531dd96fbb9dJohn McCall  }
20321dd7383dc48718c452e71a625b29531dd96fbb9dJohn McCall
20338dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis  void setArg(unsigned I, Expr *E) {
20348dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis    assert(I < NumArgs && "Argument index out-of-range");
20358dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis    *(arg_begin() + I) = E;
20368dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis  }
20378dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis
2038ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor  virtual SourceRange getSourceRange() const;
2039ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor
20401eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  static bool classof(const Stmt *T) {
2041d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor    return T->getStmtClass() == CXXUnresolvedConstructExprClass;
2042d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  }
2043d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  static bool classof(const CXXUnresolvedConstructExpr *) { return true; }
2044d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor
2045d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  // Iterators
2046d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  virtual child_iterator child_begin();
2047d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  virtual child_iterator child_end();
2048d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor};
2049d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor
2050ba13543329afac4a0d01304ec2ec4924d99306a6John McCall/// \brief Represents a C++ member access expression where the actual
2051ba13543329afac4a0d01304ec2ec4924d99306a6John McCall/// member referenced could not be resolved because the base
2052ba13543329afac4a0d01304ec2ec4924d99306a6John McCall/// expression or the member name was dependent.
2053aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall///
2054aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall/// Like UnresolvedMemberExprs, these can be either implicit or
2055aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall/// explicit accesses.  It is only possible to get one of these with
2056aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall/// an implicit access if a qualifier is provided.
2057865d447ac6a4721ab58e898d014a21f2eff74b06John McCallclass CXXDependentScopeMemberExpr : public Expr {
20581c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  /// \brief The expression for the base pointer or class reference,
2059aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall  /// e.g., the \c x in x.f.  Can be null in implicit accesses.
20601c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  Stmt *Base;
20611eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
2062aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall  /// \brief The type of the base expression.  Never null, even for
2063aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall  /// implicit accesses.
2064aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall  QualType BaseType;
2065aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall
20661c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  /// \brief Whether this member expression used the '->' operator or
20671c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  /// the '.' operator.
20683b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor  bool IsArrow : 1;
20691c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor
20703b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor  /// \brief Whether this member expression has explicitly-specified template
20713b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor  /// arguments.
2072aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall  bool HasExplicitTemplateArgs : 1;
20731eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
20741c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  /// \brief The location of the '->' or '.' operator.
20751c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  SourceLocation OperatorLoc;
20761c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor
2077a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor  /// \brief The nested-name-specifier that precedes the member name, if any.
2078a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor  NestedNameSpecifier *Qualifier;
20791eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
2080a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor  /// \brief The source range covering the nested name specifier.
2081a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor  SourceRange QualifierRange;
20821eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
2083c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor  /// \brief In a qualified member access expression such as t->Base::f, this
20841eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  /// member stores the resolves of name lookup in the context of the member
2085c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor  /// access expression, to be used at instantiation time.
2086c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor  ///
2087c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor  /// FIXME: This member, along with the Qualifier and QualifierRange, could
2088c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor  /// be stuck into a structure that is optionally allocated at the end of
2089865d447ac6a4721ab58e898d014a21f2eff74b06John McCall  /// the CXXDependentScopeMemberExpr, to save space in the common case.
2090c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor  NamedDecl *FirstQualifierFoundInScope;
20911eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
20921c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  /// \brief The member to which this member expression refers, which
20931c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  /// can be name, overloaded operator, or destructor.
2094a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor  /// FIXME: could also be a template-id
20952577743c5650c646fb705df01403707e94f2df04Abramo Bagnara  DeclarationNameInfo MemberNameInfo;
20961eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
2097865d447ac6a4721ab58e898d014a21f2eff74b06John McCall  CXXDependentScopeMemberExpr(ASTContext &C,
2098aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall                          Expr *Base, QualType BaseType, bool IsArrow,
20993b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor                          SourceLocation OperatorLoc,
21003b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor                          NestedNameSpecifier *Qualifier,
21013b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor                          SourceRange QualifierRange,
21023b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor                          NamedDecl *FirstQualifierFoundInScope,
21032577743c5650c646fb705df01403707e94f2df04Abramo Bagnara                          DeclarationNameInfo MemberNameInfo,
2104d5532b6cfff2977e0c59fa6ead7f7973984a620dJohn McCall                          const TemplateArgumentListInfo *TemplateArgs);
21051eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
21061c0ca59416999129d0439c2661d137ef38e86209Douglas Gregorpublic:
2107865d447ac6a4721ab58e898d014a21f2eff74b06John McCall  CXXDependentScopeMemberExpr(ASTContext &C,
2108aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall                          Expr *Base, QualType BaseType,
2109aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall                          bool IsArrow,
21101c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor                          SourceLocation OperatorLoc,
2111a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor                          NestedNameSpecifier *Qualifier,
2112a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor                          SourceRange QualifierRange,
2113c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor                          NamedDecl *FirstQualifierFoundInScope,
21142577743c5650c646fb705df01403707e94f2df04Abramo Bagnara                          DeclarationNameInfo MemberNameInfo)
2115f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall  : Expr(CXXDependentScopeMemberExprClass, C.DependentTy,
2116f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall         VK_LValue, OK_Ordinary, true, true),
2117aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall    Base(Base), BaseType(BaseType), IsArrow(IsArrow),
2118aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall    HasExplicitTemplateArgs(false), OperatorLoc(OperatorLoc),
21193b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor    Qualifier(Qualifier), QualifierRange(QualifierRange),
21203b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor    FirstQualifierFoundInScope(FirstQualifierFoundInScope),
21212577743c5650c646fb705df01403707e94f2df04Abramo Bagnara    MemberNameInfo(MemberNameInfo) { }
21221eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
2123865d447ac6a4721ab58e898d014a21f2eff74b06John McCall  static CXXDependentScopeMemberExpr *
21241eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  Create(ASTContext &C,
2125aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall         Expr *Base, QualType BaseType, bool IsArrow,
21263b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor         SourceLocation OperatorLoc,
21273b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor         NestedNameSpecifier *Qualifier,
21283b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor         SourceRange QualifierRange,
21293b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor         NamedDecl *FirstQualifierFoundInScope,
21302577743c5650c646fb705df01403707e94f2df04Abramo Bagnara         DeclarationNameInfo MemberNameInfo,
2131d5532b6cfff2977e0c59fa6ead7f7973984a620dJohn McCall         const TemplateArgumentListInfo *TemplateArgs);
21321eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
21338dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis  static CXXDependentScopeMemberExpr *
21348dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis  CreateEmpty(ASTContext &C, unsigned NumTemplateArgs);
21358dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis
2136aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall  /// \brief True if this is an implicit access, i.e. one in which the
2137aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall  /// member being accessed was not written in the source.  The source
2138aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall  /// location of the operator is invalid in this case.
2139aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall  bool isImplicitAccess() const { return Base == 0; }
2140aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall
21411c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  /// \brief Retrieve the base object of this member expressions,
21421c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  /// e.g., the \c x in \c x.m.
2143aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall  Expr *getBase() const {
2144aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall    assert(!isImplicitAccess());
2145aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall    return cast<Expr>(Base);
2146aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall  }
21471c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  void setBase(Expr *E) { Base = E; }
21481c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor
2149aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall  QualType getBaseType() const { return BaseType; }
21508dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis  void setBaseType(QualType T) { BaseType = T; }
2151aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall
21521c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  /// \brief Determine whether this member expression used the '->'
21531c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  /// operator; otherwise, it used the '.' operator.
21541c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  bool isArrow() const { return IsArrow; }
21551c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  void setArrow(bool A) { IsArrow = A; }
21561c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor
21571c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  /// \brief Retrieve the location of the '->' or '.' operator.
21581c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  SourceLocation getOperatorLoc() const { return OperatorLoc; }
21591c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  void setOperatorLoc(SourceLocation L) { OperatorLoc = L; }
21601c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor
2161a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor  /// \brief Retrieve the nested-name-specifier that qualifies the member
2162a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor  /// name.
2163a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor  NestedNameSpecifier *getQualifier() const { return Qualifier; }
21648dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis  void setQualifier(NestedNameSpecifier *NNS) { Qualifier = NNS; }
21651eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
2166a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor  /// \brief Retrieve the source range covering the nested-name-specifier
2167a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor  /// that qualifies the member name.
2168a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor  SourceRange getQualifierRange() const { return QualifierRange; }
21698dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis  void setQualifierRange(SourceRange R) { QualifierRange = R; }
21701eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
2171c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor  /// \brief Retrieve the first part of the nested-name-specifier that was
2172c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor  /// found in the scope of the member access expression when the member access
2173c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor  /// was initially parsed.
2174c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor  ///
2175c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor  /// This function only returns a useful result when member access expression
21761eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  /// uses a qualified member name, e.g., "x.Base::f". Here, the declaration
21771eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  /// returned by this function describes what was found by unqualified name
2178c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor  /// lookup for the identifier "Base" within the scope of the member access
2179c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor  /// expression itself. At template instantiation time, this information is
2180c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor  /// combined with the results of name lookup into the type of the object
2181c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor  /// expression itself (the class type of x).
21821eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  NamedDecl *getFirstQualifierFoundInScope() const {
2183c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor    return FirstQualifierFoundInScope;
2184c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor  }
21858dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis  void setFirstQualifierFoundInScope(NamedDecl *D) {
21868dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis    FirstQualifierFoundInScope = D;
21878dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis  }
21881eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
21891c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  /// \brief Retrieve the name of the member that this expression
21901c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  /// refers to.
21912577743c5650c646fb705df01403707e94f2df04Abramo Bagnara  const DeclarationNameInfo &getMemberNameInfo() const {
21922577743c5650c646fb705df01403707e94f2df04Abramo Bagnara    return MemberNameInfo;
21932577743c5650c646fb705df01403707e94f2df04Abramo Bagnara  }
21942577743c5650c646fb705df01403707e94f2df04Abramo Bagnara  void setMemberNameInfo(const DeclarationNameInfo &N) { MemberNameInfo = N; }
21952577743c5650c646fb705df01403707e94f2df04Abramo Bagnara
21962577743c5650c646fb705df01403707e94f2df04Abramo Bagnara  /// \brief Retrieve the name of the member that this expression
21972577743c5650c646fb705df01403707e94f2df04Abramo Bagnara  /// refers to.
21982577743c5650c646fb705df01403707e94f2df04Abramo Bagnara  DeclarationName getMember() const { return MemberNameInfo.getName(); }
21992577743c5650c646fb705df01403707e94f2df04Abramo Bagnara  void setMember(DeclarationName N) { MemberNameInfo.setName(N); }
22001c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor
22011c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  // \brief Retrieve the location of the name of the member that this
22021c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  // expression refers to.
22032577743c5650c646fb705df01403707e94f2df04Abramo Bagnara  SourceLocation getMemberLoc() const { return MemberNameInfo.getLoc(); }
22042577743c5650c646fb705df01403707e94f2df04Abramo Bagnara  void setMemberLoc(SourceLocation L) { MemberNameInfo.setLoc(L); }
22051c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor
22063b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor  /// \brief Determines whether this member expression actually had a C++
22073b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor  /// template argument list explicitly specified, e.g., x.f<int>.
2208aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall  bool hasExplicitTemplateArgs() const {
2209aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall    return HasExplicitTemplateArgs;
22103b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor  }
22111eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
221236c76f0bea0d3595a25a5362225c642019cc3176Argyrios Kyrtzidis  /// \brief Retrieve the explicit template argument list that followed the
221336c76f0bea0d3595a25a5362225c642019cc3176Argyrios Kyrtzidis  /// member template name, if any.
2214096832c5ed5b9106fa177ebc148489760c3bc496John McCall  ExplicitTemplateArgumentList &getExplicitTemplateArgs() {
221536c76f0bea0d3595a25a5362225c642019cc3176Argyrios Kyrtzidis    assert(HasExplicitTemplateArgs);
2216096832c5ed5b9106fa177ebc148489760c3bc496John McCall    return *reinterpret_cast<ExplicitTemplateArgumentList *>(this + 1);
221736c76f0bea0d3595a25a5362225c642019cc3176Argyrios Kyrtzidis  }
221836c76f0bea0d3595a25a5362225c642019cc3176Argyrios Kyrtzidis
221936c76f0bea0d3595a25a5362225c642019cc3176Argyrios Kyrtzidis  /// \brief Retrieve the explicit template argument list that followed the
222036c76f0bea0d3595a25a5362225c642019cc3176Argyrios Kyrtzidis  /// member template name, if any.
2221096832c5ed5b9106fa177ebc148489760c3bc496John McCall  const ExplicitTemplateArgumentList &getExplicitTemplateArgs() const {
222236c76f0bea0d3595a25a5362225c642019cc3176Argyrios Kyrtzidis    return const_cast<CXXDependentScopeMemberExpr *>(this)
2223096832c5ed5b9106fa177ebc148489760c3bc496John McCall             ->getExplicitTemplateArgs();
2224096832c5ed5b9106fa177ebc148489760c3bc496John McCall  }
2225096832c5ed5b9106fa177ebc148489760c3bc496John McCall
2226096832c5ed5b9106fa177ebc148489760c3bc496John McCall  /// \brief Retrieves the optional explicit template arguments.
2227096832c5ed5b9106fa177ebc148489760c3bc496John McCall  /// This points to the same data as getExplicitTemplateArgs(), but
2228096832c5ed5b9106fa177ebc148489760c3bc496John McCall  /// returns null if there are no explicit template arguments.
2229096832c5ed5b9106fa177ebc148489760c3bc496John McCall  const ExplicitTemplateArgumentList *getOptionalExplicitTemplateArgs() {
2230096832c5ed5b9106fa177ebc148489760c3bc496John McCall    if (!hasExplicitTemplateArgs()) return 0;
2231096832c5ed5b9106fa177ebc148489760c3bc496John McCall    return &getExplicitTemplateArgs();
223236c76f0bea0d3595a25a5362225c642019cc3176Argyrios Kyrtzidis  }
223336c76f0bea0d3595a25a5362225c642019cc3176Argyrios Kyrtzidis
2234d5532b6cfff2977e0c59fa6ead7f7973984a620dJohn McCall  /// \brief Copies the template arguments (if present) into the given
2235d5532b6cfff2977e0c59fa6ead7f7973984a620dJohn McCall  /// structure.
2236d5532b6cfff2977e0c59fa6ead7f7973984a620dJohn McCall  void copyTemplateArgumentsInto(TemplateArgumentListInfo &List) const {
2237096832c5ed5b9106fa177ebc148489760c3bc496John McCall    getExplicitTemplateArgs().copyInto(List);
2238d5532b6cfff2977e0c59fa6ead7f7973984a620dJohn McCall  }
2239d5532b6cfff2977e0c59fa6ead7f7973984a620dJohn McCall
22408dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis  /// \brief Initializes the template arguments using the given structure.
22418dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis  void initializeTemplateArgumentsFrom(const TemplateArgumentListInfo &List) {
2242096832c5ed5b9106fa177ebc148489760c3bc496John McCall    getExplicitTemplateArgs().initializeFrom(List);
22438dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis  }
22448dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis
22451eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  /// \brief Retrieve the location of the left angle bracket following the
22463b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor  /// member name ('<'), if any.
22471eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  SourceLocation getLAngleLoc() const {
2248096832c5ed5b9106fa177ebc148489760c3bc496John McCall    return getExplicitTemplateArgs().LAngleLoc;
22493b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor  }
22501eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
22513b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor  /// \brief Retrieve the template arguments provided as part of this
22523b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor  /// template-id.
2253833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall  const TemplateArgumentLoc *getTemplateArgs() const {
2254096832c5ed5b9106fa177ebc148489760c3bc496John McCall    return getExplicitTemplateArgs().getTemplateArgs();
22553b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor  }
22561eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
22573b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor  /// \brief Retrieve the number of template arguments provided as part of this
22583b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor  /// template-id.
22591eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  unsigned getNumTemplateArgs() const {
2260096832c5ed5b9106fa177ebc148489760c3bc496John McCall    return getExplicitTemplateArgs().NumTemplateArgs;
22613b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor  }
22621eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
22631eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  /// \brief Retrieve the location of the right angle bracket following the
22643b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor  /// template arguments ('>').
22651eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  SourceLocation getRAngleLoc() const {
2266096832c5ed5b9106fa177ebc148489760c3bc496John McCall    return getExplicitTemplateArgs().RAngleLoc;
22673b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor  }
22681eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
22691c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  virtual SourceRange getSourceRange() const {
2270aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall    SourceRange Range;
2271aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall    if (!isImplicitAccess())
2272aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall      Range.setBegin(Base->getSourceRange().getBegin());
2273aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall    else if (getQualifier())
2274aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall      Range.setBegin(getQualifierRange().getBegin());
2275aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall    else
22762577743c5650c646fb705df01403707e94f2df04Abramo Bagnara      Range.setBegin(MemberNameInfo.getBeginLoc());
22771eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
2278aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall    if (hasExplicitTemplateArgs())
2279aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall      Range.setEnd(getRAngleLoc());
2280aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall    else
22812577743c5650c646fb705df01403707e94f2df04Abramo Bagnara      Range.setEnd(MemberNameInfo.getEndLoc());
2282aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall    return Range;
22831c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  }
22841eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
22851eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  static bool classof(const Stmt *T) {
2286865d447ac6a4721ab58e898d014a21f2eff74b06John McCall    return T->getStmtClass() == CXXDependentScopeMemberExprClass;
22871c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  }
2288865d447ac6a4721ab58e898d014a21f2eff74b06John McCall  static bool classof(const CXXDependentScopeMemberExpr *) { return true; }
22891c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor
22901c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  // Iterators
22911c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  virtual child_iterator child_begin();
22921c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  virtual child_iterator child_end();
22934045107b7384fd68eed5e3e2f06fc2a47e7be0a6Argyrios Kyrtzidis
22944045107b7384fd68eed5e3e2f06fc2a47e7be0a6Argyrios Kyrtzidis  friend class ASTStmtReader;
22954045107b7384fd68eed5e3e2f06fc2a47e7be0a6Argyrios Kyrtzidis  friend class ASTStmtWriter;
22961c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor};
22971c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor
2298129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall/// \brief Represents a C++ member access expression for which lookup
2299aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall/// produced a set of overloaded functions.
2300aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall///
2301aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall/// The member access may be explicit or implicit:
2302aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall///    struct A {
2303aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall///      int a, b;
2304aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall///      int explicitAccess() { return this->a + this->A::b; }
2305aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall///      int implicitAccess() { return a + A::b; }
2306aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall///    };
2307aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall///
2308aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall/// In the final AST, an explicit access always becomes a MemberExpr.
2309aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall/// An implicit access may become either a MemberExpr or a
2310aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall/// DeclRefExpr, depending on whether the member is static.
23117bb12da2b0749eeebb21854c77877736969e59f2John McCallclass UnresolvedMemberExpr : public OverloadExpr {
2312129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// \brief Whether this member expression used the '->' operator or
2313129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// the '.' operator.
2314129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  bool IsArrow : 1;
2315129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall
2316129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// \brief Whether the lookup results contain an unresolved using
2317129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// declaration.
2318129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  bool HasUnresolvedUsing : 1;
2319129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall
23207bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// \brief The expression for the base pointer or class reference,
23217bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// e.g., the \c x in x.f.  This can be null if this is an 'unbased'
23227bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// member expression
23237bb12da2b0749eeebb21854c77877736969e59f2John McCall  Stmt *Base;
23247bb12da2b0749eeebb21854c77877736969e59f2John McCall
23257bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// \brief The type of the base expression;  never null.
23267bb12da2b0749eeebb21854c77877736969e59f2John McCall  QualType BaseType;
2327129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall
2328129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// \brief The location of the '->' or '.' operator.
2329129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  SourceLocation OperatorLoc;
2330129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall
2331928e6fcf66fc4f342bcf7cc96bf56986c9c2a833Douglas Gregor  UnresolvedMemberExpr(ASTContext &C, QualType T, bool Dependent,
2332129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall                       bool HasUnresolvedUsing,
2333aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall                       Expr *Base, QualType BaseType, bool IsArrow,
2334129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall                       SourceLocation OperatorLoc,
2335129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall                       NestedNameSpecifier *Qualifier,
2336129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall                       SourceRange QualifierRange,
23372577743c5650c646fb705df01403707e94f2df04Abramo Bagnara                       const DeclarationNameInfo &MemberNameInfo,
23385a84dec38cfa9e084377a3167b474c79283c82faDouglas Gregor                       const TemplateArgumentListInfo *TemplateArgs,
23395a84dec38cfa9e084377a3167b474c79283c82faDouglas Gregor                       UnresolvedSetIterator Begin, UnresolvedSetIterator End);
2340a77eb0862507b900a10fa352af1568e639ed10b1Argyrios Kyrtzidis
2341a77eb0862507b900a10fa352af1568e639ed10b1Argyrios Kyrtzidis  UnresolvedMemberExpr(EmptyShell Empty)
2342a77eb0862507b900a10fa352af1568e639ed10b1Argyrios Kyrtzidis    : OverloadExpr(UnresolvedMemberExprClass, Empty), IsArrow(false),
2343a77eb0862507b900a10fa352af1568e639ed10b1Argyrios Kyrtzidis      HasUnresolvedUsing(false), Base(0) { }
2344129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall
2345129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCallpublic:
2346129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  static UnresolvedMemberExpr *
2347129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  Create(ASTContext &C, bool Dependent, bool HasUnresolvedUsing,
2348aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall         Expr *Base, QualType BaseType, bool IsArrow,
2349129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall         SourceLocation OperatorLoc,
2350129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall         NestedNameSpecifier *Qualifier,
2351129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall         SourceRange QualifierRange,
23522577743c5650c646fb705df01403707e94f2df04Abramo Bagnara         const DeclarationNameInfo &MemberNameInfo,
23535a84dec38cfa9e084377a3167b474c79283c82faDouglas Gregor         const TemplateArgumentListInfo *TemplateArgs,
23545a84dec38cfa9e084377a3167b474c79283c82faDouglas Gregor         UnresolvedSetIterator Begin, UnresolvedSetIterator End);
2355129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall
2356a77eb0862507b900a10fa352af1568e639ed10b1Argyrios Kyrtzidis  static UnresolvedMemberExpr *
2357a77eb0862507b900a10fa352af1568e639ed10b1Argyrios Kyrtzidis  CreateEmpty(ASTContext &C, unsigned NumTemplateArgs);
2358a77eb0862507b900a10fa352af1568e639ed10b1Argyrios Kyrtzidis
2359aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall  /// \brief True if this is an implicit access, i.e. one in which the
2360aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall  /// member being accessed was not written in the source.  The source
2361aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall  /// location of the operator is invalid in this case.
2362aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall  bool isImplicitAccess() const { return Base == 0; }
2363aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall
2364129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// \brief Retrieve the base object of this member expressions,
2365129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// e.g., the \c x in \c x.m.
2366aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall  Expr *getBase() {
2367aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall    assert(!isImplicitAccess());
2368aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall    return cast<Expr>(Base);
2369aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall  }
23702f27bf854f0519810b34afd209089cc75536b757John McCall  const Expr *getBase() const {
23712f27bf854f0519810b34afd209089cc75536b757John McCall    assert(!isImplicitAccess());
23722f27bf854f0519810b34afd209089cc75536b757John McCall    return cast<Expr>(Base);
23732f27bf854f0519810b34afd209089cc75536b757John McCall  }
2374129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  void setBase(Expr *E) { Base = E; }
2375129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall
2376aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall  QualType getBaseType() const { return BaseType; }
2377a77eb0862507b900a10fa352af1568e639ed10b1Argyrios Kyrtzidis  void setBaseType(QualType T) { BaseType = T; }
2378a77eb0862507b900a10fa352af1568e639ed10b1Argyrios Kyrtzidis
2379a77eb0862507b900a10fa352af1568e639ed10b1Argyrios Kyrtzidis  /// \brief Determine whether the lookup results contain an unresolved using
2380a77eb0862507b900a10fa352af1568e639ed10b1Argyrios Kyrtzidis  /// declaration.
2381a77eb0862507b900a10fa352af1568e639ed10b1Argyrios Kyrtzidis  bool hasUnresolvedUsing() const { return HasUnresolvedUsing; }
2382a77eb0862507b900a10fa352af1568e639ed10b1Argyrios Kyrtzidis  void setHasUnresolvedUsing(bool V) { HasUnresolvedUsing = V; }
2383aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall
2384129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// \brief Determine whether this member expression used the '->'
2385129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// operator; otherwise, it used the '.' operator.
2386129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  bool isArrow() const { return IsArrow; }
2387129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  void setArrow(bool A) { IsArrow = A; }
2388129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall
2389129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// \brief Retrieve the location of the '->' or '.' operator.
2390129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  SourceLocation getOperatorLoc() const { return OperatorLoc; }
2391129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  void setOperatorLoc(SourceLocation L) { OperatorLoc = L; }
2392129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall
2393c373d48502ca7683ab55385f5bd624d778eb288dJohn McCall  /// \brief Retrieves the naming class of this lookup.
2394c373d48502ca7683ab55385f5bd624d778eb288dJohn McCall  CXXRecordDecl *getNamingClass() const;
2395c373d48502ca7683ab55385f5bd624d778eb288dJohn McCall
23962577743c5650c646fb705df01403707e94f2df04Abramo Bagnara  /// \brief Retrieve the full name info for the member that this expression
23972577743c5650c646fb705df01403707e94f2df04Abramo Bagnara  /// refers to.
23982577743c5650c646fb705df01403707e94f2df04Abramo Bagnara  const DeclarationNameInfo &getMemberNameInfo() const { return getNameInfo(); }
23992577743c5650c646fb705df01403707e94f2df04Abramo Bagnara  void setMemberNameInfo(const DeclarationNameInfo &N) { setNameInfo(N); }
24002577743c5650c646fb705df01403707e94f2df04Abramo Bagnara
2401129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// \brief Retrieve the name of the member that this expression
2402129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// refers to.
24037bb12da2b0749eeebb21854c77877736969e59f2John McCall  DeclarationName getMemberName() const { return getName(); }
24047bb12da2b0749eeebb21854c77877736969e59f2John McCall  void setMemberName(DeclarationName N) { setName(N); }
2405129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall
2406129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  // \brief Retrieve the location of the name of the member that this
2407129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  // expression refers to.
24087bb12da2b0749eeebb21854c77877736969e59f2John McCall  SourceLocation getMemberLoc() const { return getNameLoc(); }
24097bb12da2b0749eeebb21854c77877736969e59f2John McCall  void setMemberLoc(SourceLocation L) { setNameLoc(L); }
2410129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall
24117bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// \brief Retrieve the explicit template argument list that followed the
24127bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// member template name.
24137bb12da2b0749eeebb21854c77877736969e59f2John McCall  ExplicitTemplateArgumentList &getExplicitTemplateArgs() {
24147bb12da2b0749eeebb21854c77877736969e59f2John McCall    assert(hasExplicitTemplateArgs());
24157bb12da2b0749eeebb21854c77877736969e59f2John McCall    return *reinterpret_cast<ExplicitTemplateArgumentList *>(this + 1);
24167bb12da2b0749eeebb21854c77877736969e59f2John McCall  }
24177bb12da2b0749eeebb21854c77877736969e59f2John McCall
24187bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// \brief Retrieve the explicit template argument list that followed the
24197bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// member template name, if any.
24207bb12da2b0749eeebb21854c77877736969e59f2John McCall  const ExplicitTemplateArgumentList &getExplicitTemplateArgs() const {
24217bb12da2b0749eeebb21854c77877736969e59f2John McCall    assert(hasExplicitTemplateArgs());
24227bb12da2b0749eeebb21854c77877736969e59f2John McCall    return *reinterpret_cast<const ExplicitTemplateArgumentList *>(this + 1);
2423129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  }
2424129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall
2425096832c5ed5b9106fa177ebc148489760c3bc496John McCall  /// \brief Retrieves the optional explicit template arguments.
2426096832c5ed5b9106fa177ebc148489760c3bc496John McCall  /// This points to the same data as getExplicitTemplateArgs(), but
2427096832c5ed5b9106fa177ebc148489760c3bc496John McCall  /// returns null if there are no explicit template arguments.
2428096832c5ed5b9106fa177ebc148489760c3bc496John McCall  const ExplicitTemplateArgumentList *getOptionalExplicitTemplateArgs() {
2429096832c5ed5b9106fa177ebc148489760c3bc496John McCall    if (!hasExplicitTemplateArgs()) return 0;
2430096832c5ed5b9106fa177ebc148489760c3bc496John McCall    return &getExplicitTemplateArgs();
2431096832c5ed5b9106fa177ebc148489760c3bc496John McCall  }
2432096832c5ed5b9106fa177ebc148489760c3bc496John McCall
2433129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// \brief Copies the template arguments into the given structure.
2434129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  void copyTemplateArgumentsInto(TemplateArgumentListInfo &List) const {
24357bb12da2b0749eeebb21854c77877736969e59f2John McCall    getExplicitTemplateArgs().copyInto(List);
2436129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  }
2437129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall
2438129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// \brief Retrieve the location of the left angle bracket following
2439129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// the member name ('<').
2440129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  SourceLocation getLAngleLoc() const {
24417bb12da2b0749eeebb21854c77877736969e59f2John McCall    return getExplicitTemplateArgs().LAngleLoc;
2442129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  }
2443129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall
2444129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// \brief Retrieve the template arguments provided as part of this
2445129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// template-id.
2446129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  const TemplateArgumentLoc *getTemplateArgs() const {
24477bb12da2b0749eeebb21854c77877736969e59f2John McCall    return getExplicitTemplateArgs().getTemplateArgs();
2448129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  }
2449129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall
2450129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// \brief Retrieve the number of template arguments provided as
2451129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// part of this template-id.
2452129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  unsigned getNumTemplateArgs() const {
24537bb12da2b0749eeebb21854c77877736969e59f2John McCall    return getExplicitTemplateArgs().NumTemplateArgs;
2454129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  }
2455129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall
2456129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// \brief Retrieve the location of the right angle bracket
2457129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// following the template arguments ('>').
2458129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  SourceLocation getRAngleLoc() const {
24597bb12da2b0749eeebb21854c77877736969e59f2John McCall    return getExplicitTemplateArgs().RAngleLoc;
2460129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  }
2461129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall
2462129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  virtual SourceRange getSourceRange() const {
24632577743c5650c646fb705df01403707e94f2df04Abramo Bagnara    SourceRange Range = getMemberNameInfo().getSourceRange();
2464aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall    if (!isImplicitAccess())
2465aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall      Range.setBegin(Base->getSourceRange().getBegin());
2466aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall    else if (getQualifier())
2467aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall      Range.setBegin(getQualifierRange().getBegin());
2468aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall
2469129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall    if (hasExplicitTemplateArgs())
2470129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall      Range.setEnd(getRAngleLoc());
2471129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall    return Range;
2472129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  }
2473129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall
2474129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  static bool classof(const Stmt *T) {
2475129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall    return T->getStmtClass() == UnresolvedMemberExprClass;
2476129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  }
2477129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  static bool classof(const UnresolvedMemberExpr *) { return true; }
2478129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall
2479129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  // Iterators
2480129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  virtual child_iterator child_begin();
2481129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  virtual child_iterator child_end();
2482129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall};
2483129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall
24842e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl/// \brief Represents a C++0x noexcept expression (C++ [expr.unary.noexcept]).
24852e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl///
24862e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl/// The noexcept expression tests whether a given expression might throw. Its
24872e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl/// result is a boolean constant.
24882e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redlclass CXXNoexceptExpr : public Expr {
24892e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl  bool Value : 1;
24902e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl  Stmt *Operand;
24912e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl  SourceRange Range;
24922e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl
2493c8aecc2dfb2e393d9eeaedeca22ff8cd7149af81Sebastian Redl  friend class ASTStmtReader;
2494c8aecc2dfb2e393d9eeaedeca22ff8cd7149af81Sebastian Redl
24952e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redlpublic:
24962e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl  CXXNoexceptExpr(QualType Ty, Expr *Operand, CanThrowResult Val,
24972e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl                  SourceLocation Keyword, SourceLocation RParen)
2498f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall    : Expr(CXXNoexceptExprClass, Ty, VK_RValue, OK_Ordinary,
2499f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall           /*TypeDependent*/false,
25006b219d082434394c1ac401390ec1d1967727815aSebastian Redl           /*ValueDependent*/Val == CT_Dependent),
25016b219d082434394c1ac401390ec1d1967727815aSebastian Redl      Value(Val == CT_Cannot), Operand(Operand), Range(Keyword, RParen)
25026b219d082434394c1ac401390ec1d1967727815aSebastian Redl  { }
25036b219d082434394c1ac401390ec1d1967727815aSebastian Redl
25046b219d082434394c1ac401390ec1d1967727815aSebastian Redl  CXXNoexceptExpr(EmptyShell Empty)
25056b219d082434394c1ac401390ec1d1967727815aSebastian Redl    : Expr(CXXNoexceptExprClass, Empty)
25062e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl  { }
25072e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl
25082e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl  Expr *getOperand() const { return static_cast<Expr*>(Operand); }
25092e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl
25102e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl  virtual SourceRange getSourceRange() const { return Range; }
25112e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl
25122e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl  bool getValue() const { return Value; }
25132e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl
25142e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl  static bool classof(const Stmt *T) {
25152e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl    return T->getStmtClass() == CXXNoexceptExprClass;
25162e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl  }
25172e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl  static bool classof(const CXXNoexceptExpr *) { return true; }
25182e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl
25192e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl  // Iterators
25202e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl  virtual child_iterator child_begin();
25212e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl  virtual child_iterator child_end();
25222e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl};
25232e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl
25247bb12da2b0749eeebb21854c77877736969e59f2John McCallinline ExplicitTemplateArgumentList &OverloadExpr::getExplicitTemplateArgs() {
25257bb12da2b0749eeebb21854c77877736969e59f2John McCall  if (isa<UnresolvedLookupExpr>(this))
25267bb12da2b0749eeebb21854c77877736969e59f2John McCall    return cast<UnresolvedLookupExpr>(this)->getExplicitTemplateArgs();
25277bb12da2b0749eeebb21854c77877736969e59f2John McCall  else
25287bb12da2b0749eeebb21854c77877736969e59f2John McCall    return cast<UnresolvedMemberExpr>(this)->getExplicitTemplateArgs();
25297bb12da2b0749eeebb21854c77877736969e59f2John McCall}
25307bb12da2b0749eeebb21854c77877736969e59f2John McCall
25315f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer}  // end namespace clang
25325f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer
25335f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer#endif
2534