ExprCXX.h revision f89e55ab1bfb3ea997f8b02997c611a02254eb2d
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)
426f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall    : Expr(CXXUuidofExprClass, Ty, /*FIXME*/ VK_LValue, 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(),
580f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall           getValueKindForType(param->getType()), OK_Ordinary, false, false),
581036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor      Param(param, false), Loc(Loc) { }
58265222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor
583036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor  CXXDefaultArgExpr(StmtClass SC, SourceLocation Loc, ParmVarDecl *param,
584036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor                    Expr *SubExpr)
585f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall    : Expr(SC, SubExpr->getType(), SubExpr->getValueKind(), OK_Ordinary,
586f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall           false, false), Param(param, true), Loc(Loc) {
58765222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor    *reinterpret_cast<Expr **>(this + 1) = SubExpr;
58865222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor  }
58965222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor
5901060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenekpublic:
591030854b95f7bfd86aaa8afd9ae1aff9768a37e9aChris Lattner  CXXDefaultArgExpr(EmptyShell Empty) : Expr(CXXDefaultArgExprClass, Empty) {}
592030854b95f7bfd86aaa8afd9ae1aff9768a37e9aChris Lattner
593030854b95f7bfd86aaa8afd9ae1aff9768a37e9aChris Lattner
5941060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  // Param is the parameter whose default argument is used by this
5951060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  // expression.
596036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor  static CXXDefaultArgExpr *Create(ASTContext &C, SourceLocation Loc,
597036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor                                   ParmVarDecl *Param) {
598036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor    return new (C) CXXDefaultArgExpr(CXXDefaultArgExprClass, Loc, Param);
599f1480eee38b59d15438fb7bc50865ac7c7e22403Anders Carlsson  }
6001060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek
60165222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor  // Param is the parameter whose default argument is used by this
60265222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor  // expression, and SubExpr is the expression that will actually be used.
603036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor  static CXXDefaultArgExpr *Create(ASTContext &C,
604036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor                                   SourceLocation Loc,
605036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor                                   ParmVarDecl *Param,
60665222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor                                   Expr *SubExpr);
60765222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor
6081060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  // Retrieve the parameter that the argument was created from.
60965222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor  const ParmVarDecl *getParam() const { return Param.getPointer(); }
61065222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor  ParmVarDecl *getParam() { return Param.getPointer(); }
611030854b95f7bfd86aaa8afd9ae1aff9768a37e9aChris Lattner
6121060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  // Retrieve the actual argument to the function call.
61365222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor  const Expr *getExpr() const {
61465222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor    if (Param.getInt())
61565222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor      return *reinterpret_cast<Expr const * const*> (this + 1);
61665222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor    return getParam()->getDefaultArg();
61765222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor  }
61865222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor  Expr *getExpr() {
61965222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor    if (Param.getInt())
62065222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor      return *reinterpret_cast<Expr **> (this + 1);
62165222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor    return getParam()->getDefaultArg();
62265222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor  }
6231060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek
624036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor  /// \brief Retrieve the location where this default argument was actually
625036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor  /// used.
626036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor  SourceLocation getUsedLocation() const { return Loc; }
627036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor
6281060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  virtual SourceRange getSourceRange() const {
6291060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek    // Default argument expressions have no representation in the
6301060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek    // source, so they have an empty source range.
6311060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek    return SourceRange();
6321060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  }
6331060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek
6341060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  static bool classof(const Stmt *T) {
6351060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek    return T->getStmtClass() == CXXDefaultArgExprClass;
6361060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  }
6371060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  static bool classof(const CXXDefaultArgExpr *) { return true; }
6381060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek
6391060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  // Iterators
6401060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  virtual child_iterator child_begin();
6411060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  virtual child_iterator child_end();
6428a50733034edd6a349b34e2b9f0c8d0a874846d3Argyrios Kyrtzidis
64360adf4acf40b72227740bf966fb87eebddff3f37Sebastian Redl  friend class ASTStmtReader;
6443397c5570369f19b2d6c52e898f708d75ceede1fSebastian Redl  friend class ASTStmtWriter;
6451060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek};
646987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis
647c1ce477119fed070299668aab24084b17ff5f14bAnders Carlsson/// CXXTemporary - Represents a C++ temporary.
648c1ce477119fed070299668aab24084b17ff5f14bAnders Carlssonclass CXXTemporary {
649c1ce477119fed070299668aab24084b17ff5f14bAnders Carlsson  /// Destructor - The destructor that needs to be called.
650b859f35459ae3e1188d1e1b86df08d649695fd86Anders Carlsson  const CXXDestructorDecl *Destructor;
6511eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
652b859f35459ae3e1188d1e1b86df08d649695fd86Anders Carlsson  CXXTemporary(const CXXDestructorDecl *destructor)
653c1ce477119fed070299668aab24084b17ff5f14bAnders Carlsson    : Destructor(destructor) { }
654c1ce477119fed070299668aab24084b17ff5f14bAnders Carlsson
655c1ce477119fed070299668aab24084b17ff5f14bAnders Carlssonpublic:
6561eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  static CXXTemporary *Create(ASTContext &C,
657b859f35459ae3e1188d1e1b86df08d649695fd86Anders Carlsson                              const CXXDestructorDecl *Destructor);
6581eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
659f0721fe438d7e40c168e5d664970e7830bc138fbAnders Carlsson  const CXXDestructorDecl *getDestructor() const { return Destructor; }
660c1ce477119fed070299668aab24084b17ff5f14bAnders Carlsson};
661fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson
662ddfe960d252a93525692b547945236d361d1929fChandler Carruth/// \brief Represents binding an expression to a temporary.
663ddfe960d252a93525692b547945236d361d1929fChandler Carruth///
664ddfe960d252a93525692b547945236d361d1929fChandler Carruth/// This ensures the destructor is called for the temporary. It should only be
665ddfe960d252a93525692b547945236d361d1929fChandler Carruth/// needed for non-POD, non-trivially destructable class types. For example:
666ddfe960d252a93525692b547945236d361d1929fChandler Carruth///
667ddfe960d252a93525692b547945236d361d1929fChandler Carruth/// \code
668ddfe960d252a93525692b547945236d361d1929fChandler Carruth///   struct S {
669ddfe960d252a93525692b547945236d361d1929fChandler Carruth///     S() { }  // User defined constructor makes S non-POD.
670ddfe960d252a93525692b547945236d361d1929fChandler Carruth///     ~S() { } // User defined destructor makes it non-trivial.
671ddfe960d252a93525692b547945236d361d1929fChandler Carruth///   };
672ddfe960d252a93525692b547945236d361d1929fChandler Carruth///   void test() {
673ddfe960d252a93525692b547945236d361d1929fChandler Carruth///     const S &s_ref = S(); // Requires a CXXBindTemporaryExpr.
674ddfe960d252a93525692b547945236d361d1929fChandler Carruth///   }
675ddfe960d252a93525692b547945236d361d1929fChandler Carruth/// \endcode
676fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlssonclass CXXBindTemporaryExpr : public Expr {
677fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson  CXXTemporary *Temp;
6781eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
679fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson  Stmt *SubExpr;
680fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson
681b8e39236f05b2f71fb2632673948499fd54e2a34Fariborz Jahanian  CXXBindTemporaryExpr(CXXTemporary *temp, Expr* subexpr,
682b8e39236f05b2f71fb2632673948499fd54e2a34Fariborz Jahanian                       bool TD=false, bool VD=false)
683f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall   : Expr(CXXBindTemporaryExprClass, subexpr->getType(),
684f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall          VK_RValue, OK_Ordinary, TD, VD),
6852333f7727f97018d6742e1e0938133bcfad967abEli Friedman     Temp(temp), SubExpr(subexpr) { }
68688eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlsson
687fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlssonpublic:
688d2598368876cfe40bc8465540033bc5b5e58d8afChris Lattner  CXXBindTemporaryExpr(EmptyShell Empty)
689d2598368876cfe40bc8465540033bc5b5e58d8afChris Lattner    : Expr(CXXBindTemporaryExprClass, Empty), Temp(0), SubExpr(0) {}
690d2598368876cfe40bc8465540033bc5b5e58d8afChris Lattner
6911eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  static CXXBindTemporaryExpr *Create(ASTContext &C, CXXTemporary *Temp,
692fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson                                      Expr* SubExpr);
6931eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
69488eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlsson  CXXTemporary *getTemporary() { return Temp; }
695f0721fe438d7e40c168e5d664970e7830bc138fbAnders Carlsson  const CXXTemporary *getTemporary() const { return Temp; }
696d2598368876cfe40bc8465540033bc5b5e58d8afChris Lattner  void setTemporary(CXXTemporary *T) { Temp = T; }
697f0721fe438d7e40c168e5d664970e7830bc138fbAnders Carlsson
698fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson  const Expr *getSubExpr() const { return cast<Expr>(SubExpr); }
699fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson  Expr *getSubExpr() { return cast<Expr>(SubExpr); }
70088eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlsson  void setSubExpr(Expr *E) { SubExpr = E; }
701fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson
70296be6917e1c4ba1f4435a14c9e7c6c139571d086Douglas Gregor  virtual SourceRange getSourceRange() const {
70396be6917e1c4ba1f4435a14c9e7c6c139571d086Douglas Gregor    return SubExpr->getSourceRange();
70496be6917e1c4ba1f4435a14c9e7c6c139571d086Douglas Gregor  }
705fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson
706fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson  // Implement isa/cast/dyncast/etc.
707fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson  static bool classof(const Stmt *T) {
708fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson    return T->getStmtClass() == CXXBindTemporaryExprClass;
709fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson  }
710fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson  static bool classof(const CXXBindTemporaryExpr *) { return true; }
711fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson
712fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson  // Iterators
713fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson  virtual child_iterator child_begin();
714fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson  virtual child_iterator child_end();
715fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson};
716fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson
71715ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson/// CXXConstructExpr - Represents a call to a C++ constructor.
71815ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlssonclass CXXConstructExpr : public Expr {
71972e96fd181b19b8d01144a685cda6e955584c7eaAnders Carlssonpublic:
72072e96fd181b19b8d01144a685cda6e955584c7eaAnders Carlsson  enum ConstructionKind {
72172e96fd181b19b8d01144a685cda6e955584c7eaAnders Carlsson    CK_Complete,
72272e96fd181b19b8d01144a685cda6e955584c7eaAnders Carlsson    CK_NonVirtualBase,
72372e96fd181b19b8d01144a685cda6e955584c7eaAnders Carlsson    CK_VirtualBase
72472e96fd181b19b8d01144a685cda6e955584c7eaAnders Carlsson  };
72572e96fd181b19b8d01144a685cda6e955584c7eaAnders Carlsson
72672e96fd181b19b8d01144a685cda6e955584c7eaAnders Carlssonprivate:
72715ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson  CXXConstructorDecl *Constructor;
72815ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson
72999a2e600f9e2e51d3ce10fb6f27191677ac65b2aDouglas Gregor  SourceLocation Loc;
730428edafa9eb80e01dd40aab31d4166a787a741e1Chandler Carruth  SourceRange ParenRange;
73116006c901315fa12a108b4e571f187f4b676e426Douglas Gregor  bool Elidable : 1;
73216006c901315fa12a108b4e571f187f4b676e426Douglas Gregor  bool ZeroInitialization : 1;
73372e96fd181b19b8d01144a685cda6e955584c7eaAnders Carlsson  unsigned ConstructKind : 2;
73415ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson  Stmt **Args;
73515ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson  unsigned NumArgs;
7361eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
737bd6734e5f6432ce0cc07171c490ffaa094796198Anders Carlssonprotected:
7381eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  CXXConstructExpr(ASTContext &C, StmtClass SC, QualType T,
73999a2e600f9e2e51d3ce10fb6f27191677ac65b2aDouglas Gregor                   SourceLocation Loc,
740bd6734e5f6432ce0cc07171c490ffaa094796198Anders Carlsson                   CXXConstructorDecl *d, bool elidable,
74116006c901315fa12a108b4e571f187f4b676e426Douglas Gregor                   Expr **args, unsigned numargs,
7429db7dbb918ca49f4ee6c181e4917e7b6ec547353Douglas Gregor                   bool ZeroInitialization = false,
743428edafa9eb80e01dd40aab31d4166a787a741e1Chandler Carruth                   ConstructionKind ConstructKind = CK_Complete,
744428edafa9eb80e01dd40aab31d4166a787a741e1Chandler Carruth                   SourceRange ParenRange = SourceRange());
745bd6734e5f6432ce0cc07171c490ffaa094796198Anders Carlsson
7466d00c1365dd3601f6d93bbda9162913c57ae788fArgyrios Kyrtzidis  /// \brief Construct an empty C++ construction expression.
7476d00c1365dd3601f6d93bbda9162913c57ae788fArgyrios Kyrtzidis  CXXConstructExpr(StmtClass SC, EmptyShell Empty)
7486d00c1365dd3601f6d93bbda9162913c57ae788fArgyrios Kyrtzidis    : Expr(SC, Empty), Constructor(0), Elidable(0), ZeroInitialization(0),
7496d00c1365dd3601f6d93bbda9162913c57ae788fArgyrios Kyrtzidis      ConstructKind(0), Args(0), NumArgs(0) { }
7506d00c1365dd3601f6d93bbda9162913c57ae788fArgyrios Kyrtzidis
75115ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlssonpublic:
7526d00c1365dd3601f6d93bbda9162913c57ae788fArgyrios Kyrtzidis  /// \brief Construct an empty C++ construction expression.
7536d00c1365dd3601f6d93bbda9162913c57ae788fArgyrios Kyrtzidis  explicit CXXConstructExpr(EmptyShell Empty)
7546d00c1365dd3601f6d93bbda9162913c57ae788fArgyrios Kyrtzidis    : Expr(CXXConstructExprClass, Empty), Constructor(0),
7556d00c1365dd3601f6d93bbda9162913c57ae788fArgyrios Kyrtzidis      Elidable(0), ZeroInitialization(0),
7566d00c1365dd3601f6d93bbda9162913c57ae788fArgyrios Kyrtzidis      ConstructKind(0), Args(0), NumArgs(0) { }
7576d00c1365dd3601f6d93bbda9162913c57ae788fArgyrios Kyrtzidis
7588e587a15da6d3457a418239d5eb4146fcbd209f3Anders Carlsson  static CXXConstructExpr *Create(ASTContext &C, QualType T,
75999a2e600f9e2e51d3ce10fb6f27191677ac65b2aDouglas Gregor                                  SourceLocation Loc,
7601eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump                                  CXXConstructorDecl *D, bool Elidable,
76116006c901315fa12a108b4e571f187f4b676e426Douglas Gregor                                  Expr **Args, unsigned NumArgs,
7629db7dbb918ca49f4ee6c181e4917e7b6ec547353Douglas Gregor                                  bool ZeroInitialization = false,
763428edafa9eb80e01dd40aab31d4166a787a741e1Chandler Carruth                                  ConstructionKind ConstructKind = CK_Complete,
764428edafa9eb80e01dd40aab31d4166a787a741e1Chandler Carruth                                  SourceRange ParenRange = SourceRange());
7651eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
7661eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
767d94546a0a1deef7286c13e49b9584621ae81cc9aDouglas Gregor  CXXConstructorDecl* getConstructor() const { return Constructor; }
76839da0b8145eaec7da7004f9b3645c5c9f4f63b1dDouglas Gregor  void setConstructor(CXXConstructorDecl *C) { Constructor = C; }
76939da0b8145eaec7da7004f9b3645c5c9f4f63b1dDouglas Gregor
77099a2e600f9e2e51d3ce10fb6f27191677ac65b2aDouglas Gregor  SourceLocation getLocation() const { return Loc; }
77199a2e600f9e2e51d3ce10fb6f27191677ac65b2aDouglas Gregor  void setLocation(SourceLocation Loc) { this->Loc = Loc; }
77299a2e600f9e2e51d3ce10fb6f27191677ac65b2aDouglas Gregor
773d94546a0a1deef7286c13e49b9584621ae81cc9aDouglas Gregor  /// \brief Whether this construction is elidable.
774d94546a0a1deef7286c13e49b9584621ae81cc9aDouglas Gregor  bool isElidable() const { return Elidable; }
77539da0b8145eaec7da7004f9b3645c5c9f4f63b1dDouglas Gregor  void setElidable(bool E) { Elidable = E; }
77639da0b8145eaec7da7004f9b3645c5c9f4f63b1dDouglas Gregor
77716006c901315fa12a108b4e571f187f4b676e426Douglas Gregor  /// \brief Whether this construction first requires
77816006c901315fa12a108b4e571f187f4b676e426Douglas Gregor  /// zero-initialization before the initializer is called.
77916006c901315fa12a108b4e571f187f4b676e426Douglas Gregor  bool requiresZeroInitialization() const { return ZeroInitialization; }
78016006c901315fa12a108b4e571f187f4b676e426Douglas Gregor  void setRequiresZeroInitialization(bool ZeroInit) {
78116006c901315fa12a108b4e571f187f4b676e426Douglas Gregor    ZeroInitialization = ZeroInit;
78216006c901315fa12a108b4e571f187f4b676e426Douglas Gregor  }
78316006c901315fa12a108b4e571f187f4b676e426Douglas Gregor
7849db7dbb918ca49f4ee6c181e4917e7b6ec547353Douglas Gregor  /// \brief Determines whether this constructor is actually constructing
7859db7dbb918ca49f4ee6c181e4917e7b6ec547353Douglas Gregor  /// a base class (rather than a complete object).
78624eb78e38aba55c507bc3c05c37035a9ab2defa7Anders Carlsson  ConstructionKind getConstructionKind() const {
78724eb78e38aba55c507bc3c05c37035a9ab2defa7Anders Carlsson    return (ConstructionKind)ConstructKind;
78872e96fd181b19b8d01144a685cda6e955584c7eaAnders Carlsson  }
78972e96fd181b19b8d01144a685cda6e955584c7eaAnders Carlsson  void setConstructionKind(ConstructionKind CK) {
79072e96fd181b19b8d01144a685cda6e955584c7eaAnders Carlsson    ConstructKind = CK;
79172e96fd181b19b8d01144a685cda6e955584c7eaAnders Carlsson  }
7929db7dbb918ca49f4ee6c181e4917e7b6ec547353Douglas Gregor
79315ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson  typedef ExprIterator arg_iterator;
79415ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson  typedef ConstExprIterator const_arg_iterator;
7951eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
79615ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson  arg_iterator arg_begin() { return Args; }
79715ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson  arg_iterator arg_end() { return Args + NumArgs; }
79815ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson  const_arg_iterator arg_begin() const { return Args; }
79915ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson  const_arg_iterator arg_end() const { return Args + NumArgs; }
80015ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson
801a88cfbfac9bbcbb9858f048d6d73a48711d8e93dDouglas Gregor  Expr **getArgs() const { return reinterpret_cast<Expr **>(Args); }
80215ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson  unsigned getNumArgs() const { return NumArgs; }
80315ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson
804bcb11d01c034f967503bd98f28bdf458c1ab8001Anders Carlsson  /// getArg - Return the specified argument.
805bcb11d01c034f967503bd98f28bdf458c1ab8001Anders Carlsson  Expr *getArg(unsigned Arg) {
806bcb11d01c034f967503bd98f28bdf458c1ab8001Anders Carlsson    assert(Arg < NumArgs && "Arg access out of range!");
807bcb11d01c034f967503bd98f28bdf458c1ab8001Anders Carlsson    return cast<Expr>(Args[Arg]);
808bcb11d01c034f967503bd98f28bdf458c1ab8001Anders Carlsson  }
809bcb11d01c034f967503bd98f28bdf458c1ab8001Anders Carlsson  const Expr *getArg(unsigned Arg) const {
810bcb11d01c034f967503bd98f28bdf458c1ab8001Anders Carlsson    assert(Arg < NumArgs && "Arg access out of range!");
811bcb11d01c034f967503bd98f28bdf458c1ab8001Anders Carlsson    return cast<Expr>(Args[Arg]);
812bcb11d01c034f967503bd98f28bdf458c1ab8001Anders Carlsson  }
8131eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
8142eeed7bc4fd457ac57ff32ab3b02674588545f65Fariborz Jahanian  /// setArg - Set the specified argument.
8152eeed7bc4fd457ac57ff32ab3b02674588545f65Fariborz Jahanian  void setArg(unsigned Arg, Expr *ArgExpr) {
8162eeed7bc4fd457ac57ff32ab3b02674588545f65Fariborz Jahanian    assert(Arg < NumArgs && "Arg access out of range!");
8172eeed7bc4fd457ac57ff32ab3b02674588545f65Fariborz Jahanian    Args[Arg] = ArgExpr;
8182eeed7bc4fd457ac57ff32ab3b02674588545f65Fariborz Jahanian  }
8192eeed7bc4fd457ac57ff32ab3b02674588545f65Fariborz Jahanian
820e383768f7f5d45ca4af0b1c11cbf072de18bce98Ted Kremenek  virtual SourceRange getSourceRange() const;
821428edafa9eb80e01dd40aab31d4166a787a741e1Chandler Carruth  SourceRange getParenRange() const { return ParenRange; }
82215ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson
8231eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  static bool classof(const Stmt *T) {
824524fa13fd81e88533c7a1d4b1232c0de2c97dc7cAnders Carlsson    return T->getStmtClass() == CXXConstructExprClass ||
825524fa13fd81e88533c7a1d4b1232c0de2c97dc7cAnders Carlsson      T->getStmtClass() == CXXTemporaryObjectExprClass;
82615ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson  }
82715ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson  static bool classof(const CXXConstructExpr *) { return true; }
8281eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
82915ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson  // Iterators
83015ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson  virtual child_iterator child_begin();
83115ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson  virtual child_iterator child_end();
8326d00c1365dd3601f6d93bbda9162913c57ae788fArgyrios Kyrtzidis
83360adf4acf40b72227740bf966fb87eebddff3f37Sebastian Redl  friend class ASTStmtReader;
83415ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson};
83515ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson
83649badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// CXXFunctionalCastExpr - Represents an explicit C++ type conversion
83749badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// that uses "functional" notion (C++ [expr.type.conv]). Example: @c
83849badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// x = int(0.5);
83949badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregorclass CXXFunctionalCastExpr : public ExplicitCastExpr {
840987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  SourceLocation TyBeginLoc;
841987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  SourceLocation RParenLoc;
842f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall
843f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall  CXXFunctionalCastExpr(QualType ty, ExprValueKind VK,
844f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall                        TypeSourceInfo *writtenTy,
8451eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump                        SourceLocation tyBeginLoc, CastKind kind,
846f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall                        Expr *castExpr, unsigned pathSize,
84741b2dcd465f1e438502c420effc9d0c747f9db8fAnders Carlsson                        SourceLocation rParenLoc)
848f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall    : ExplicitCastExpr(CXXFunctionalCastExprClass, ty, VK, kind,
849f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall                       castExpr, pathSize, writtenTy),
8500aebc81e02397a5987aaa8e8c7acbdb01a31d7c3Anders Carlsson      TyBeginLoc(tyBeginLoc), RParenLoc(rParenLoc) {}
8510aebc81e02397a5987aaa8e8c7acbdb01a31d7c3Anders Carlsson
852f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall  explicit CXXFunctionalCastExpr(EmptyShell Shell, unsigned PathSize)
853f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall    : ExplicitCastExpr(CXXFunctionalCastExprClass, Shell, PathSize) { }
854f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall
855f871d0cc377a1367b519a6cce26be74607566ebaJohn McCallpublic:
856f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall  static CXXFunctionalCastExpr *Create(ASTContext &Context, QualType T,
857f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall                                       ExprValueKind VK,
858f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall                                       TypeSourceInfo *Written,
859f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall                                       SourceLocation TyBeginLoc,
860f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall                                       CastKind Kind, Expr *Op,
861f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall                                       const CXXCastPath *Path,
862f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall                                       SourceLocation RPLoc);
863f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall  static CXXFunctionalCastExpr *CreateEmpty(ASTContext &Context,
864f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall                                            unsigned PathSize);
865ce757a7a1ee905f87551996a69da3e95e8afeeb7Sam Weinig
866987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  SourceLocation getTypeBeginLoc() const { return TyBeginLoc; }
867ce757a7a1ee905f87551996a69da3e95e8afeeb7Sam Weinig  void setTypeBeginLoc(SourceLocation L) { TyBeginLoc = L; }
868987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  SourceLocation getRParenLoc() const { return RParenLoc; }
869ce757a7a1ee905f87551996a69da3e95e8afeeb7Sam Weinig  void setRParenLoc(SourceLocation L) { RParenLoc = L; }
8701eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
871987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  virtual SourceRange getSourceRange() const {
872987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis    return SourceRange(TyBeginLoc, RParenLoc);
873987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  }
8741eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  static bool classof(const Stmt *T) {
8751eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump    return T->getStmtClass() == CXXFunctionalCastExprClass;
876987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  }
877987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  static bool classof(const CXXFunctionalCastExpr *) { return true; }
878987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis};
879987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis
880506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// @brief Represents a C++ functional cast expression that builds a
881506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// temporary object.
882506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor///
8831eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump/// This expression type represents a C++ "functional" cast
884506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// (C++[expr.type.conv]) with N != 1 arguments that invokes a
885ed8abf18329df67b0abcbb3a10458bd8c1d2a595Douglas Gregor/// constructor to build a temporary object. With N == 1 arguments the
886ed8abf18329df67b0abcbb3a10458bd8c1d2a595Douglas Gregor/// functional cast expression will be represented by CXXFunctionalCastExpr.
887506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// Example:
888506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// @code
889506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// struct X { X(int, float); }
890506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor///
891506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// X create_X() {
892506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor///   return X(1, 3.14f); // creates a CXXTemporaryObjectExpr
893506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// };
894506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// @endcode
895524fa13fd81e88533c7a1d4b1232c0de2c97dc7cAnders Carlssonclass CXXTemporaryObjectExpr : public CXXConstructExpr {
896ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor  TypeSourceInfo *Type;
897506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor
898506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregorpublic:
8991eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  CXXTemporaryObjectExpr(ASTContext &C, CXXConstructorDecl *Cons,
900ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor                         TypeSourceInfo *Type,
9011eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump                         Expr **Args,unsigned NumArgs,
902428edafa9eb80e01dd40aab31d4166a787a741e1Chandler Carruth                         SourceRange parenRange,
9031c63b9c15d48cb8c833a4b2d6fd6c496c0766e88Douglas Gregor                         bool ZeroInitialization = false);
9046d00c1365dd3601f6d93bbda9162913c57ae788fArgyrios Kyrtzidis  explicit CXXTemporaryObjectExpr(EmptyShell Empty)
905ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor    : CXXConstructExpr(CXXTemporaryObjectExprClass, Empty), Type() { }
906506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor
907ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor  TypeSourceInfo *getTypeSourceInfo() const { return Type; }
908ba49817c5b9f502602672861cf369fd0e53966e8Douglas Gregor
909ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor  virtual SourceRange getSourceRange() const;
910ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor
9111eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  static bool classof(const Stmt *T) {
912506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor    return T->getStmtClass() == CXXTemporaryObjectExprClass;
913506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor  }
914506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor  static bool classof(const CXXTemporaryObjectExpr *) { return true; }
9156d00c1365dd3601f6d93bbda9162913c57ae788fArgyrios Kyrtzidis
91660adf4acf40b72227740bf966fb87eebddff3f37Sebastian Redl  friend class ASTStmtReader;
917506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor};
918506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor
919ed8abf18329df67b0abcbb3a10458bd8c1d2a595Douglas Gregor/// CXXScalarValueInitExpr - [C++ 5.2.3p2]
920506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// Expression "T()" which creates a value-initialized rvalue of type
921ed8abf18329df67b0abcbb3a10458bd8c1d2a595Douglas Gregor/// T, which is a non-class type.
922987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis///
923ed8abf18329df67b0abcbb3a10458bd8c1d2a595Douglas Gregorclass CXXScalarValueInitExpr : public Expr {
924987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  SourceLocation RParenLoc;
925ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor  TypeSourceInfo *TypeInfo;
926987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis
927ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor  friend class ASTStmtReader;
928ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor
929987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidispublic:
930ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor  /// \brief Create an explicitly-written scalar-value initialization
931ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor  /// expression.
932ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor  CXXScalarValueInitExpr(QualType Type,
933ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor                         TypeSourceInfo *TypeInfo,
934ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor                         SourceLocation rParenLoc ) :
935f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall    Expr(CXXScalarValueInitExprClass, Type, VK_RValue, OK_Ordinary,
936f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall         false, false),
937ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor    RParenLoc(rParenLoc), TypeInfo(TypeInfo) {}
938ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor
939ed8abf18329df67b0abcbb3a10458bd8c1d2a595Douglas Gregor  explicit CXXScalarValueInitExpr(EmptyShell Shell)
940ed8abf18329df67b0abcbb3a10458bd8c1d2a595Douglas Gregor    : Expr(CXXScalarValueInitExprClass, Shell) { }
9411eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
942ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor  TypeSourceInfo *getTypeSourceInfo() const {
943ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor    return TypeInfo;
9444c67834407ca6ab344dcf44fc599ad4938cfa96dDouglas Gregor  }
945ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor
946ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor  SourceLocation getRParenLoc() const { return RParenLoc; }
9474c67834407ca6ab344dcf44fc599ad4938cfa96dDouglas Gregor
948ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor  virtual SourceRange getSourceRange() const;
9491eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
9501eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  static bool classof(const Stmt *T) {
951ed8abf18329df67b0abcbb3a10458bd8c1d2a595Douglas Gregor    return T->getStmtClass() == CXXScalarValueInitExprClass;
952987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  }
953ed8abf18329df67b0abcbb3a10458bd8c1d2a595Douglas Gregor  static bool classof(const CXXScalarValueInitExpr *) { return true; }
9541eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
955987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  // Iterators
956987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  virtual child_iterator child_begin();
957987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis  virtual child_iterator child_end();
958987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis};
959987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis
9604c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl/// CXXNewExpr - A new expression for memory allocation and constructor calls,
9614c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl/// e.g: "new CXXNewExpr(foo)".
9624c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redlclass CXXNewExpr : public Expr {
9634c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  // Was the usage ::new, i.e. is the global new to be used?
9644c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  bool GlobalNew : 1;
9654c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  // Is there an initializer? If not, built-ins are uninitialized, else they're
9664c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  // value-initialized.
9674c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  bool Initializer : 1;
968cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl  // Do we allocate an array? If so, the first SubExpr is the size expression.
969cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl  bool Array : 1;
9704c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  // The number of placement new arguments.
971e4b8f1171d699c56ba2b39aabf1d7cb4c38ce4f8Douglas Gregor  unsigned NumPlacementArgs : 15;
9724c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  // The number of constructor arguments. This may be 1 even for non-class
9734c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  // types; use the pseudo copy constructor.
974cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl  unsigned NumConstructorArgs : 14;
975cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl  // Contains an optional array size expression, any number of optional
976cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl  // placement arguments, and any number of optional constructor arguments,
977cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl  // in that order.
9784c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  Stmt **SubExprs;
9794c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  // Points to the allocation function used.
9804c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  FunctionDecl *OperatorNew;
9814c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  // Points to the deallocation function used in case of error. May be null.
9824c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  FunctionDecl *OperatorDelete;
9834c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  // Points to the constructor used. Cannot be null if AllocType is a record;
9844c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  // it would still point at the default constructor (even an implicit one).
9854c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  // Must be null for all other types.
9864c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  CXXConstructorDecl *Constructor;
9874c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
9881bb2a93ab7b1499dda6f6b58865bd0dce1864228Douglas Gregor  /// \brief The allocated type-source information, as written in the source.
9891bb2a93ab7b1499dda6f6b58865bd0dce1864228Douglas Gregor  TypeSourceInfo *AllocatedTypeInfo;
9901bb2a93ab7b1499dda6f6b58865bd0dce1864228Douglas Gregor
9914bd40318cbea15310a37343db46de96c4fcc15e6Douglas Gregor  /// \brief If the allocated type was expressed as a parenthesized type-id,
9924bd40318cbea15310a37343db46de96c4fcc15e6Douglas Gregor  /// the source range covering the parenthesized type-id.
9934bd40318cbea15310a37343db46de96c4fcc15e6Douglas Gregor  SourceRange TypeIdParens;
9944bd40318cbea15310a37343db46de96c4fcc15e6Douglas Gregor
9954c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  SourceLocation StartLoc;
9964c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  SourceLocation EndLoc;
997428edafa9eb80e01dd40aab31d4166a787a741e1Chandler Carruth  SourceLocation ConstructorLParen;
998428edafa9eb80e01dd40aab31d4166a787a741e1Chandler Carruth  SourceLocation ConstructorRParen;
9994c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
100060adf4acf40b72227740bf966fb87eebddff3f37Sebastian Redl  friend class ASTStmtReader;
10014c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redlpublic:
1002ad7fe864862305c2f71e047cdf6706ef43aebdc0Ted Kremenek  CXXNewExpr(ASTContext &C, bool globalNew, FunctionDecl *operatorNew,
10034bd40318cbea15310a37343db46de96c4fcc15e6Douglas Gregor             Expr **placementArgs, unsigned numPlaceArgs,
10044bd40318cbea15310a37343db46de96c4fcc15e6Douglas Gregor             SourceRange TypeIdParens,
1005ad7fe864862305c2f71e047cdf6706ef43aebdc0Ted Kremenek             Expr *arraySize, CXXConstructorDecl *constructor, bool initializer,
10064c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl             Expr **constructorArgs, unsigned numConsArgs,
10074c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl             FunctionDecl *operatorDelete, QualType ty,
10081bb2a93ab7b1499dda6f6b58865bd0dce1864228Douglas Gregor             TypeSourceInfo *AllocatedTypeInfo,
1009428edafa9eb80e01dd40aab31d4166a787a741e1Chandler Carruth             SourceLocation startLoc, SourceLocation endLoc,
1010428edafa9eb80e01dd40aab31d4166a787a741e1Chandler Carruth             SourceLocation constructorLParen,
1011428edafa9eb80e01dd40aab31d4166a787a741e1Chandler Carruth             SourceLocation constructorRParen);
10125921863d8f24084797863b5df37842113bac4352Chris Lattner  explicit CXXNewExpr(EmptyShell Shell)
10135921863d8f24084797863b5df37842113bac4352Chris Lattner    : Expr(CXXNewExprClass, Shell), SubExprs(0) { }
10145921863d8f24084797863b5df37842113bac4352Chris Lattner
10155921863d8f24084797863b5df37842113bac4352Chris Lattner  void AllocateArgsArray(ASTContext &C, bool isArray, unsigned numPlaceArgs,
10165921863d8f24084797863b5df37842113bac4352Chris Lattner                         unsigned numConsArgs);
1017ad7fe864862305c2f71e047cdf6706ef43aebdc0Ted Kremenek
1018cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl  QualType getAllocatedType() const {
1019cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl    assert(getType()->isPointerType());
10206217b80b7a1379b74cced1c076338262c3c980b3Ted Kremenek    return getType()->getAs<PointerType>()->getPointeeType();
1021cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl  }
10224c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
10231bb2a93ab7b1499dda6f6b58865bd0dce1864228Douglas Gregor  TypeSourceInfo *getAllocatedTypeSourceInfo() const {
10241bb2a93ab7b1499dda6f6b58865bd0dce1864228Douglas Gregor    return AllocatedTypeInfo;
10251bb2a93ab7b1499dda6f6b58865bd0dce1864228Douglas Gregor  }
10261bb2a93ab7b1499dda6f6b58865bd0dce1864228Douglas Gregor
10274c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  FunctionDecl *getOperatorNew() const { return OperatorNew; }
10285921863d8f24084797863b5df37842113bac4352Chris Lattner  void setOperatorNew(FunctionDecl *D) { OperatorNew = D; }
10294c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  FunctionDecl *getOperatorDelete() const { return OperatorDelete; }
10305921863d8f24084797863b5df37842113bac4352Chris Lattner  void setOperatorDelete(FunctionDecl *D) { OperatorDelete = D; }
10314c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  CXXConstructorDecl *getConstructor() const { return Constructor; }
10325921863d8f24084797863b5df37842113bac4352Chris Lattner  void setConstructor(CXXConstructorDecl *D) { Constructor = D; }
10334c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
1034cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl  bool isArray() const { return Array; }
1035cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl  Expr *getArraySize() {
1036cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl    return Array ? cast<Expr>(SubExprs[0]) : 0;
1037cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl  }
1038cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl  const Expr *getArraySize() const {
1039cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl    return Array ? cast<Expr>(SubExprs[0]) : 0;
1040cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl  }
1041cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl
10424c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  unsigned getNumPlacementArgs() const { return NumPlacementArgs; }
10434c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  Expr *getPlacementArg(unsigned i) {
10444c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl    assert(i < NumPlacementArgs && "Index out of range");
1045cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl    return cast<Expr>(SubExprs[Array + i]);
10464c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  }
10474c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  const Expr *getPlacementArg(unsigned i) const {
10484c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl    assert(i < NumPlacementArgs && "Index out of range");
1049cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl    return cast<Expr>(SubExprs[Array + i]);
10504c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  }
10514c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
10524bd40318cbea15310a37343db46de96c4fcc15e6Douglas Gregor  bool isParenTypeId() const { return TypeIdParens.isValid(); }
10534bd40318cbea15310a37343db46de96c4fcc15e6Douglas Gregor  SourceRange getTypeIdParens() const { return TypeIdParens; }
10544bd40318cbea15310a37343db46de96c4fcc15e6Douglas Gregor
10554c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  bool isGlobalNew() const { return GlobalNew; }
10565921863d8f24084797863b5df37842113bac4352Chris Lattner  void setGlobalNew(bool V) { GlobalNew = V; }
10574c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  bool hasInitializer() const { return Initializer; }
10585921863d8f24084797863b5df37842113bac4352Chris Lattner  void setHasInitializer(bool V) { Initializer = V; }
10594c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
10604c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  unsigned getNumConstructorArgs() const { return NumConstructorArgs; }
10614c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  Expr *getConstructorArg(unsigned i) {
10624c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl    assert(i < NumConstructorArgs && "Index out of range");
1063cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl    return cast<Expr>(SubExprs[Array + NumPlacementArgs + i]);
10644c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  }
10654c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  const Expr *getConstructorArg(unsigned i) const {
10664c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl    assert(i < NumConstructorArgs && "Index out of range");
1067cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl    return cast<Expr>(SubExprs[Array + NumPlacementArgs + i]);
10684c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  }
10694c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
10704c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  typedef ExprIterator arg_iterator;
10714c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  typedef ConstExprIterator const_arg_iterator;
10724c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
10734c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  arg_iterator placement_arg_begin() {
1074cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl    return SubExprs + Array;
10754c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  }
10764c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  arg_iterator placement_arg_end() {
1077cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl    return SubExprs + Array + getNumPlacementArgs();
10784c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  }
10794c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  const_arg_iterator placement_arg_begin() const {
1080cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl    return SubExprs + Array;
10814c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  }
10824c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  const_arg_iterator placement_arg_end() const {
1083cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl    return SubExprs + Array + getNumPlacementArgs();
10844c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  }
10854c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
10864c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  arg_iterator constructor_arg_begin() {
1087cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl    return SubExprs + Array + getNumPlacementArgs();
10884c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  }
10894c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  arg_iterator constructor_arg_end() {
1090cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl    return SubExprs + Array + getNumPlacementArgs() + getNumConstructorArgs();
10914c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  }
10924c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  const_arg_iterator constructor_arg_begin() const {
1093cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl    return SubExprs + Array + getNumPlacementArgs();
10944c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  }
10954c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  const_arg_iterator constructor_arg_end() const {
1096cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl    return SubExprs + Array + getNumPlacementArgs() + getNumConstructorArgs();
10974c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  }
10985921863d8f24084797863b5df37842113bac4352Chris Lattner
10995921863d8f24084797863b5df37842113bac4352Chris Lattner  typedef Stmt **raw_arg_iterator;
11005921863d8f24084797863b5df37842113bac4352Chris Lattner  raw_arg_iterator raw_arg_begin() { return SubExprs; }
11015921863d8f24084797863b5df37842113bac4352Chris Lattner  raw_arg_iterator raw_arg_end() {
11025921863d8f24084797863b5df37842113bac4352Chris Lattner    return SubExprs + Array + getNumPlacementArgs() + getNumConstructorArgs();
11035921863d8f24084797863b5df37842113bac4352Chris Lattner  }
11045921863d8f24084797863b5df37842113bac4352Chris Lattner  const_arg_iterator raw_arg_begin() const { return SubExprs; }
11055921863d8f24084797863b5df37842113bac4352Chris Lattner  const_arg_iterator raw_arg_end() const { return constructor_arg_end(); }
11064c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
11075921863d8f24084797863b5df37842113bac4352Chris Lattner  SourceLocation getStartLoc() const { return StartLoc; }
11085921863d8f24084797863b5df37842113bac4352Chris Lattner  SourceLocation getEndLoc() const { return EndLoc; }
1109428edafa9eb80e01dd40aab31d4166a787a741e1Chandler Carruth
1110428edafa9eb80e01dd40aab31d4166a787a741e1Chandler Carruth  SourceLocation getConstructorLParen() const { return ConstructorLParen; }
1111428edafa9eb80e01dd40aab31d4166a787a741e1Chandler Carruth  SourceLocation getConstructorRParen() const { return ConstructorRParen; }
1112428edafa9eb80e01dd40aab31d4166a787a741e1Chandler Carruth
11134c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  virtual SourceRange getSourceRange() const {
11144c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl    return SourceRange(StartLoc, EndLoc);
11154c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  }
11164c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
11174c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  static bool classof(const Stmt *T) {
11184c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl    return T->getStmtClass() == CXXNewExprClass;
11194c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  }
11204c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  static bool classof(const CXXNewExpr *) { return true; }
11214c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
11224c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  // Iterators
11234c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  virtual child_iterator child_begin();
11244c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  virtual child_iterator child_end();
11254c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl};
11264c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
11274c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl/// CXXDeleteExpr - A delete expression for memory deallocation and destructor
11284c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl/// calls, e.g. "delete[] pArray".
11294c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redlclass CXXDeleteExpr : public Expr {
11304c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  // Is this a forced global delete, i.e. "::delete"?
11314c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  bool GlobalDelete : 1;
11324c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  // Is this the array form of delete, i.e. "delete[]"?
11334c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  bool ArrayForm : 1;
11344076dacf1497fb95cb298b9d964fbdbdaf9bde6cArgyrios Kyrtzidis  // ArrayFormAsWritten can be different from ArrayForm if 'delete' is applied
11354076dacf1497fb95cb298b9d964fbdbdaf9bde6cArgyrios Kyrtzidis  // to pointer-to-array type (ArrayFormAsWritten will be false while ArrayForm
11364076dacf1497fb95cb298b9d964fbdbdaf9bde6cArgyrios Kyrtzidis  // will be true).
11374076dacf1497fb95cb298b9d964fbdbdaf9bde6cArgyrios Kyrtzidis  bool ArrayFormAsWritten : 1;
11384c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  // Points to the operator delete overload that is used. Could be a member.
11394c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  FunctionDecl *OperatorDelete;
11404c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  // The pointer expression to be deleted.
11414c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  Stmt *Argument;
11424c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  // Location of the expression.
11434c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  SourceLocation Loc;
11444c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redlpublic:
11454c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  CXXDeleteExpr(QualType ty, bool globalDelete, bool arrayForm,
11464076dacf1497fb95cb298b9d964fbdbdaf9bde6cArgyrios Kyrtzidis                bool arrayFormAsWritten, FunctionDecl *operatorDelete,
11474076dacf1497fb95cb298b9d964fbdbdaf9bde6cArgyrios Kyrtzidis                Expr *arg, SourceLocation loc)
1148f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall    : Expr(CXXDeleteExprClass, ty, VK_RValue, OK_Ordinary, false, false),
1149f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall      GlobalDelete(globalDelete),
11504076dacf1497fb95cb298b9d964fbdbdaf9bde6cArgyrios Kyrtzidis      ArrayForm(arrayForm), ArrayFormAsWritten(arrayFormAsWritten),
11514076dacf1497fb95cb298b9d964fbdbdaf9bde6cArgyrios Kyrtzidis      OperatorDelete(operatorDelete), Argument(arg), Loc(loc) { }
115295fc98ce95d4faa4f1bb2783384150530404ea6fArgyrios Kyrtzidis  explicit CXXDeleteExpr(EmptyShell Shell)
115395fc98ce95d4faa4f1bb2783384150530404ea6fArgyrios Kyrtzidis    : Expr(CXXDeleteExprClass, Shell), OperatorDelete(0), Argument(0) { }
11544c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
11554c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  bool isGlobalDelete() const { return GlobalDelete; }
11564c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  bool isArrayForm() const { return ArrayForm; }
11574076dacf1497fb95cb298b9d964fbdbdaf9bde6cArgyrios Kyrtzidis  bool isArrayFormAsWritten() const { return ArrayFormAsWritten; }
11584c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
11594c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  FunctionDecl *getOperatorDelete() const { return OperatorDelete; }
11604c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
11614c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  Expr *getArgument() { return cast<Expr>(Argument); }
11624c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  const Expr *getArgument() const { return cast<Expr>(Argument); }
11634c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
1164a437ad3ec5b407ede394d74e6f9f463fa3657dbeCraig Silverstein  /// \brief Retrieve the type being destroyed.  If the type being
1165a437ad3ec5b407ede394d74e6f9f463fa3657dbeCraig Silverstein  /// destroyed is a dependent type which may or may not be a pointer,
1166a437ad3ec5b407ede394d74e6f9f463fa3657dbeCraig Silverstein  /// return an invalid type.
11675833b0b831d6afae2885e6af420e2bda639652e6Douglas Gregor  QualType getDestroyedType() const;
11685833b0b831d6afae2885e6af420e2bda639652e6Douglas Gregor
11694c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  virtual SourceRange getSourceRange() const {
11704c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl    return SourceRange(Loc, Argument->getLocEnd());
11714c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  }
11724c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
11734c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  static bool classof(const Stmt *T) {
11744c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl    return T->getStmtClass() == CXXDeleteExprClass;
11754c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  }
11764c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  static bool classof(const CXXDeleteExpr *) { return true; }
11774c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
11784c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  // Iterators
11794c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  virtual child_iterator child_begin();
11804c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl  virtual child_iterator child_end();
1181f1b8911d35bb2830a13267581d3cbde4b6b85db6Argyrios Kyrtzidis
1182f1b8911d35bb2830a13267581d3cbde4b6b85db6Argyrios Kyrtzidis  friend class ASTStmtReader;
11834c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl};
11844c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
1185a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor/// \brief Structure used to store the type being destroyed by a
1186a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor/// pseudo-destructor expression.
1187a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregorclass PseudoDestructorTypeStorage {
1188a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor  /// \brief Either the type source information or the name of the type, if
1189a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor  /// it couldn't be resolved due to type-dependence.
1190a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor  llvm::PointerUnion<TypeSourceInfo *, IdentifierInfo *> Type;
1191a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor
1192a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor  /// \brief The starting source location of the pseudo-destructor type.
1193a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor  SourceLocation Location;
1194a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor
1195a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregorpublic:
1196a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor  PseudoDestructorTypeStorage() { }
1197a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor
1198a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor  PseudoDestructorTypeStorage(IdentifierInfo *II, SourceLocation Loc)
1199a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor    : Type(II), Location(Loc) { }
1200a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor
1201a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor  PseudoDestructorTypeStorage(TypeSourceInfo *Info);
1202a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor
1203a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor  TypeSourceInfo *getTypeSourceInfo() const {
1204a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor    return Type.dyn_cast<TypeSourceInfo *>();
1205a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor  }
1206a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor
1207a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor  IdentifierInfo *getIdentifier() const {
1208a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor    return Type.dyn_cast<IdentifierInfo *>();
1209a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor  }
1210a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor
1211a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor  SourceLocation getLocation() const { return Location; }
1212a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor};
1213a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor
1214a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor/// \brief Represents a C++ pseudo-destructor (C++ [expr.pseudo]).
1215a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor///
1216e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor/// A pseudo-destructor is an expression that looks like a member access to a
1217e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor/// destructor of a scalar type, except that scalar types don't have
1218e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor/// destructors. For example:
1219e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor///
1220e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor/// \code
1221e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor/// typedef int T;
1222e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor/// void f(int *p) {
1223e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor///   p->T::~T();
1224e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor/// }
1225e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor/// \endcode
1226a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor///
1227e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor/// Pseudo-destructors typically occur when instantiating templates such as:
1228e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor///
1229a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor/// \code
12301eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump/// template<typename T>
1231a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor/// void destroy(T* ptr) {
1232e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor///   ptr->T::~T();
1233a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor/// }
1234a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor/// \endcode
1235a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor///
1236e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor/// for scalar types. A pseudo-destructor expression has no run-time semantics
1237e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor/// beyond evaluating the base expression.
1238a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregorclass CXXPseudoDestructorExpr : public Expr {
1239a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  /// \brief The base expression (that is being destroyed).
1240a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  Stmt *Base;
12411eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1242a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  /// \brief Whether the operator was an arrow ('->'); otherwise, it was a
1243a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  /// period ('.').
1244a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  bool IsArrow : 1;
12451eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1246a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  /// \brief The location of the '.' or '->' operator.
1247a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  SourceLocation OperatorLoc;
12481eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1249a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  /// \brief The nested-name-specifier that follows the operator, if present.
1250a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  NestedNameSpecifier *Qualifier;
12511eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
12521eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  /// \brief The source range that covers the nested-name-specifier, if
1253a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  /// present.
1254a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  SourceRange QualifierRange;
12551eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1256e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor  /// \brief The type that precedes the '::' in a qualified pseudo-destructor
1257e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor  /// expression.
1258e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor  TypeSourceInfo *ScopeType;
1259e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor
1260e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor  /// \brief The location of the '::' in a qualified pseudo-destructor
1261e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor  /// expression.
1262e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor  SourceLocation ColonColonLoc;
1263e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor
1264fce46ee68f779e239826e69e45d01d4c8e5323caDouglas Gregor  /// \brief The location of the '~'.
1265fce46ee68f779e239826e69e45d01d4c8e5323caDouglas Gregor  SourceLocation TildeLoc;
1266fce46ee68f779e239826e69e45d01d4c8e5323caDouglas Gregor
1267a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor  /// \brief The type being destroyed, or its name if we were unable to
1268a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor  /// resolve the name.
1269a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor  PseudoDestructorTypeStorage DestroyedType;
12701eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1271a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregorpublic:
1272a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  CXXPseudoDestructorExpr(ASTContext &Context,
1273a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor                          Expr *Base, bool isArrow, SourceLocation OperatorLoc,
1274a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor                          NestedNameSpecifier *Qualifier,
1275a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor                          SourceRange QualifierRange,
1276e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor                          TypeSourceInfo *ScopeType,
1277e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor                          SourceLocation ColonColonLoc,
1278fce46ee68f779e239826e69e45d01d4c8e5323caDouglas Gregor                          SourceLocation TildeLoc,
1279a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor                          PseudoDestructorTypeStorage DestroyedType)
12801eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump    : Expr(CXXPseudoDestructorExprClass,
1281a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor           Context.getPointerType(Context.getFunctionType(Context.VoidTy, 0, 0,
1282ce056bcaa1c97b89a4b2de2112c62d060863be2bDouglas Gregor                                                          false, 0, false,
1283264ba48dc98f3f843935a485d5b086f7e0fdc4f1Rafael Espindola                                                          false, 0, 0,
1284264ba48dc98f3f843935a485d5b086f7e0fdc4f1Rafael Espindola                                                      FunctionType::ExtInfo())),
1285f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall           VK_RValue, OK_Ordinary,
128626d4ac97fb514bb60c2536eae6f203dc569159d9Douglas Gregor           /*isTypeDependent=*/(Base->isTypeDependent() ||
1287a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor            (DestroyedType.getTypeSourceInfo() &&
1288a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor              DestroyedType.getTypeSourceInfo()->getType()->isDependentType())),
1289a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor           /*isValueDependent=*/Base->isValueDependent()),
12901eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump      Base(static_cast<Stmt *>(Base)), IsArrow(isArrow),
1291a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor      OperatorLoc(OperatorLoc), Qualifier(Qualifier),
1292e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor      QualifierRange(QualifierRange),
1293fce46ee68f779e239826e69e45d01d4c8e5323caDouglas Gregor      ScopeType(ScopeType), ColonColonLoc(ColonColonLoc), TildeLoc(TildeLoc),
129426d4ac97fb514bb60c2536eae6f203dc569159d9Douglas Gregor      DestroyedType(DestroyedType) { }
12951eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1296de4bd18bb45a1db68996cfb949db3015fc25d10dArgyrios Kyrtzidis  explicit CXXPseudoDestructorExpr(EmptyShell Shell)
1297de4bd18bb45a1db68996cfb949db3015fc25d10dArgyrios Kyrtzidis    : Expr(CXXPseudoDestructorExprClass, Shell),
1298de4bd18bb45a1db68996cfb949db3015fc25d10dArgyrios Kyrtzidis      Base(0), IsArrow(false), Qualifier(0), ScopeType(0) { }
1299de4bd18bb45a1db68996cfb949db3015fc25d10dArgyrios Kyrtzidis
1300a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  void setBase(Expr *E) { Base = E; }
1301a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  Expr *getBase() const { return cast<Expr>(Base); }
13021eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
13031eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  /// \brief Determines whether this member expression actually had
1304a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  /// a C++ nested-name-specifier prior to the name of the member, e.g.,
1305a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  /// x->Base::foo.
1306a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  bool hasQualifier() const { return Qualifier != 0; }
13071eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1308a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  /// \brief If the member name was qualified, retrieves the source range of
1309a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  /// the nested-name-specifier that precedes the member name. Otherwise,
1310a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  /// returns an empty source range.
1311a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  SourceRange getQualifierRange() const { return QualifierRange; }
1312de4bd18bb45a1db68996cfb949db3015fc25d10dArgyrios Kyrtzidis  void setQualifierRange(SourceRange R) { QualifierRange = R; }
13131eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
13141eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  /// \brief If the member name was qualified, retrieves the
1315a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  /// nested-name-specifier that precedes the member name. Otherwise, returns
1316a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  /// NULL.
1317a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  NestedNameSpecifier *getQualifier() const { return Qualifier; }
1318de4bd18bb45a1db68996cfb949db3015fc25d10dArgyrios Kyrtzidis  void setQualifier(NestedNameSpecifier *NNS) { Qualifier = NNS; }
13191eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1320a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  /// \brief Determine whether this pseudo-destructor expression was written
1321a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  /// using an '->' (otherwise, it used a '.').
1322a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  bool isArrow() const { return IsArrow; }
1323a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  void setArrow(bool A) { IsArrow = A; }
1324a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor
1325a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  /// \brief Retrieve the location of the '.' or '->' operator.
1326a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  SourceLocation getOperatorLoc() const { return OperatorLoc; }
1327de4bd18bb45a1db68996cfb949db3015fc25d10dArgyrios Kyrtzidis  void setOperatorLoc(SourceLocation L) { OperatorLoc = L; }
13281eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1329e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor  /// \brief Retrieve the scope type in a qualified pseudo-destructor
1330e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor  /// expression.
1331e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor  ///
1332e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor  /// Pseudo-destructor expressions can have extra qualification within them
1333e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor  /// that is not part of the nested-name-specifier, e.g., \c p->T::~T().
1334e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor  /// Here, if the object type of the expression is (or may be) a scalar type,
1335e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor  /// \p T may also be a scalar type and, therefore, cannot be part of a
1336e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor  /// nested-name-specifier. It is stored as the "scope type" of the pseudo-
1337e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor  /// destructor expression.
133826d4ac97fb514bb60c2536eae6f203dc569159d9Douglas Gregor  TypeSourceInfo *getScopeTypeInfo() const { return ScopeType; }
1339de4bd18bb45a1db68996cfb949db3015fc25d10dArgyrios Kyrtzidis  void setScopeTypeInfo(TypeSourceInfo *Info) { ScopeType = Info; }
1340e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor
1341e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor  /// \brief Retrieve the location of the '::' in a qualified pseudo-destructor
1342e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor  /// expression.
1343e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor  SourceLocation getColonColonLoc() const { return ColonColonLoc; }
1344de4bd18bb45a1db68996cfb949db3015fc25d10dArgyrios Kyrtzidis  void setColonColonLoc(SourceLocation L) { ColonColonLoc = L; }
1345e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor
1346fce46ee68f779e239826e69e45d01d4c8e5323caDouglas Gregor  /// \brief Retrieve the location of the '~'.
1347fce46ee68f779e239826e69e45d01d4c8e5323caDouglas Gregor  SourceLocation getTildeLoc() const { return TildeLoc; }
1348de4bd18bb45a1db68996cfb949db3015fc25d10dArgyrios Kyrtzidis  void setTildeLoc(SourceLocation L) { TildeLoc = L; }
1349fce46ee68f779e239826e69e45d01d4c8e5323caDouglas Gregor
135026d4ac97fb514bb60c2536eae6f203dc569159d9Douglas Gregor  /// \brief Retrieve the source location information for the type
135126d4ac97fb514bb60c2536eae6f203dc569159d9Douglas Gregor  /// being destroyed.
1352a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor  ///
1353a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor  /// This type-source information is available for non-dependent
1354a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor  /// pseudo-destructor expressions and some dependent pseudo-destructor
1355a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor  /// expressions. Returns NULL if we only have the identifier for a
1356a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor  /// dependent pseudo-destructor expression.
1357a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor  TypeSourceInfo *getDestroyedTypeInfo() const {
1358a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor    return DestroyedType.getTypeSourceInfo();
1359a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor  }
1360a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor
1361a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor  /// \brief In a dependent pseudo-destructor expression for which we do not
1362a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor  /// have full type information on the destroyed type, provides the name
1363a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor  /// of the destroyed type.
1364a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor  IdentifierInfo *getDestroyedTypeIdentifier() const {
1365a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor    return DestroyedType.getIdentifier();
1366a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor  }
1367a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor
1368a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor  /// \brief Retrieve the type being destroyed.
1369a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor  QualType getDestroyedType() const;
1370a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor
1371a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor  /// \brief Retrieve the starting location of the type being destroyed.
1372a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor  SourceLocation getDestroyedTypeLoc() const {
1373a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor    return DestroyedType.getLocation();
1374a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor  }
13751eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1376de4bd18bb45a1db68996cfb949db3015fc25d10dArgyrios Kyrtzidis  /// \brief Set the name of destroyed type for a dependent pseudo-destructor
1377de4bd18bb45a1db68996cfb949db3015fc25d10dArgyrios Kyrtzidis  /// expression.
1378de4bd18bb45a1db68996cfb949db3015fc25d10dArgyrios Kyrtzidis  void setDestroyedType(IdentifierInfo *II, SourceLocation Loc) {
1379de4bd18bb45a1db68996cfb949db3015fc25d10dArgyrios Kyrtzidis    DestroyedType = PseudoDestructorTypeStorage(II, Loc);
1380de4bd18bb45a1db68996cfb949db3015fc25d10dArgyrios Kyrtzidis  }
1381de4bd18bb45a1db68996cfb949db3015fc25d10dArgyrios Kyrtzidis
1382de4bd18bb45a1db68996cfb949db3015fc25d10dArgyrios Kyrtzidis  /// \brief Set the destroyed type.
1383de4bd18bb45a1db68996cfb949db3015fc25d10dArgyrios Kyrtzidis  void setDestroyedType(TypeSourceInfo *Info) {
1384de4bd18bb45a1db68996cfb949db3015fc25d10dArgyrios Kyrtzidis    DestroyedType = PseudoDestructorTypeStorage(Info);
1385de4bd18bb45a1db68996cfb949db3015fc25d10dArgyrios Kyrtzidis  }
1386de4bd18bb45a1db68996cfb949db3015fc25d10dArgyrios Kyrtzidis
138726d4ac97fb514bb60c2536eae6f203dc569159d9Douglas Gregor  virtual SourceRange getSourceRange() const;
13881eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
13891eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  static bool classof(const Stmt *T) {
1390a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor    return T->getStmtClass() == CXXPseudoDestructorExprClass;
1391a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  }
1392a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  static bool classof(const CXXPseudoDestructorExpr *) { return true; }
13931eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1394a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  // Iterators
1395a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor  virtual child_iterator child_begin();
13961eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  virtual child_iterator child_end();
1397a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor};
13981eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
139964b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl/// UnaryTypeTraitExpr - A GCC or MS unary type trait, as used in the
140064b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl/// implementation of TR1/C++0x type trait templates.
140164b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl/// Example:
140264b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl/// __is_pod(int) == true
140364b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl/// __is_enum(std::string) == false
140464b45f7e0d3167f040841ac2920aead7f080730dSebastian Redlclass UnaryTypeTraitExpr : public Expr {
14050dfd848fa4c9664852ba8c929a8bd3fce93ddca2Sebastian Redl  /// UTT - The trait. A UnaryTypeTrait enum in MSVC compat unsigned.
14060dfd848fa4c9664852ba8c929a8bd3fce93ddca2Sebastian Redl  unsigned UTT : 31;
14070dfd848fa4c9664852ba8c929a8bd3fce93ddca2Sebastian Redl  /// The value of the type trait. Unspecified if dependent.
14080dfd848fa4c9664852ba8c929a8bd3fce93ddca2Sebastian Redl  bool Value : 1;
140964b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl
141064b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl  /// Loc - The location of the type trait keyword.
141164b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl  SourceLocation Loc;
141264b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl
141364b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl  /// RParen - The location of the closing paren.
141464b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl  SourceLocation RParen;
141564b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl
14160dfd848fa4c9664852ba8c929a8bd3fce93ddca2Sebastian Redl  /// The type being queried.
14173d37c0ada0e46b87be0a10e8d52d990a97d3907aDouglas Gregor  TypeSourceInfo *QueriedType;
141864b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl
141964b45f7e0d3167f040841ac2920aead7f080730dSebastian Redlpublic:
14203d37c0ada0e46b87be0a10e8d52d990a97d3907aDouglas Gregor  UnaryTypeTraitExpr(SourceLocation loc, UnaryTypeTrait utt,
14210dfd848fa4c9664852ba8c929a8bd3fce93ddca2Sebastian Redl                     TypeSourceInfo *queried, bool value,
142264b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl                     SourceLocation rparen, QualType ty)
1423f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall    : Expr(UnaryTypeTraitExprClass, ty, VK_RValue, OK_Ordinary,
1424f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall           false,  queried->getType()->isDependentType()),
14250dfd848fa4c9664852ba8c929a8bd3fce93ddca2Sebastian Redl      UTT(utt), Value(value), Loc(loc), RParen(rparen), QueriedType(queried) { }
142664b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl
14276d00c1365dd3601f6d93bbda9162913c57ae788fArgyrios Kyrtzidis  explicit UnaryTypeTraitExpr(EmptyShell Empty)
14280dfd848fa4c9664852ba8c929a8bd3fce93ddca2Sebastian Redl    : Expr(UnaryTypeTraitExprClass, Empty), UTT(0), Value(false),
14293d37c0ada0e46b87be0a10e8d52d990a97d3907aDouglas Gregor      QueriedType() { }
14306d00c1365dd3601f6d93bbda9162913c57ae788fArgyrios Kyrtzidis
143164b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl  virtual SourceRange getSourceRange() const { return SourceRange(Loc, RParen);}
143264b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl
14330dfd848fa4c9664852ba8c929a8bd3fce93ddca2Sebastian Redl  UnaryTypeTrait getTrait() const { return static_cast<UnaryTypeTrait>(UTT); }
143464b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl
14353d37c0ada0e46b87be0a10e8d52d990a97d3907aDouglas Gregor  QualType getQueriedType() const { return QueriedType->getType(); }
143664b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl
14373d37c0ada0e46b87be0a10e8d52d990a97d3907aDouglas Gregor  TypeSourceInfo *getQueriedTypeSourceInfo() const { return QueriedType; }
14383d37c0ada0e46b87be0a10e8d52d990a97d3907aDouglas Gregor
14390dfd848fa4c9664852ba8c929a8bd3fce93ddca2Sebastian Redl  bool getValue() const { return Value; }
144064b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl
144164b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl  static bool classof(const Stmt *T) {
144264b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl    return T->getStmtClass() == UnaryTypeTraitExprClass;
144364b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl  }
144464b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl  static bool classof(const UnaryTypeTraitExpr *) { return true; }
144564b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl
144664b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl  // Iterators
144764b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl  virtual child_iterator child_begin();
144864b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl  virtual child_iterator child_end();
14496d00c1365dd3601f6d93bbda9162913c57ae788fArgyrios Kyrtzidis
145060adf4acf40b72227740bf966fb87eebddff3f37Sebastian Redl  friend class ASTStmtReader;
145164b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl};
145264b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl
14537bb12da2b0749eeebb21854c77877736969e59f2John McCall/// \brief A reference to an overloaded function set, either an
14547bb12da2b0749eeebb21854c77877736969e59f2John McCall/// \t UnresolvedLookupExpr or an \t UnresolvedMemberExpr.
14557bb12da2b0749eeebb21854c77877736969e59f2John McCallclass OverloadExpr : public Expr {
1456ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  /// The results.  These are undesugared, which is to say, they may
14577bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// include UsingShadowDecls.  Access is relative to the naming
14587bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// class.
1459928e6fcf66fc4f342bcf7cc96bf56986c9c2a833Douglas Gregor  // FIXME: Allocate this data after the OverloadExpr subclass.
1460928e6fcf66fc4f342bcf7cc96bf56986c9c2a833Douglas Gregor  DeclAccessPair *Results;
1461928e6fcf66fc4f342bcf7cc96bf56986c9c2a833Douglas Gregor  unsigned NumResults;
1462ba13543329afac4a0d01304ec2ec4924d99306a6John McCall
14637bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// The common name of these declarations.
14642577743c5650c646fb705df01403707e94f2df04Abramo Bagnara  DeclarationNameInfo NameInfo;
1465ba13543329afac4a0d01304ec2ec4924d99306a6John McCall
14667bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// The scope specifier, if any.
1467ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  NestedNameSpecifier *Qualifier;
14687bb12da2b0749eeebb21854c77877736969e59f2John McCall
14697bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// The source range of the scope specifier.
1470ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  SourceRange QualifierRange;
1471ba13543329afac4a0d01304ec2ec4924d99306a6John McCall
1472a77eb0862507b900a10fa352af1568e639ed10b1Argyrios Kyrtzidisprotected:
14737bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// True if the name was a template-id.
14747bb12da2b0749eeebb21854c77877736969e59f2John McCall  bool HasExplicitTemplateArgs;
14757bb12da2b0749eeebb21854c77877736969e59f2John McCall
1476928e6fcf66fc4f342bcf7cc96bf56986c9c2a833Douglas Gregor  OverloadExpr(StmtClass K, ASTContext &C, QualType T, bool Dependent,
14777bb12da2b0749eeebb21854c77877736969e59f2John McCall               NestedNameSpecifier *Qualifier, SourceRange QRange,
14782577743c5650c646fb705df01403707e94f2df04Abramo Bagnara               const DeclarationNameInfo &NameInfo,
14795a84dec38cfa9e084377a3167b474c79283c82faDouglas Gregor               bool HasTemplateArgs,
1480928e6fcf66fc4f342bcf7cc96bf56986c9c2a833Douglas Gregor               UnresolvedSetIterator Begin, UnresolvedSetIterator End);
14817bb12da2b0749eeebb21854c77877736969e59f2John McCall
1482a77eb0862507b900a10fa352af1568e639ed10b1Argyrios Kyrtzidis  OverloadExpr(StmtClass K, EmptyShell Empty)
1483a77eb0862507b900a10fa352af1568e639ed10b1Argyrios Kyrtzidis    : Expr(K, Empty), Results(0), NumResults(0),
1484a77eb0862507b900a10fa352af1568e639ed10b1Argyrios Kyrtzidis      Qualifier(0), HasExplicitTemplateArgs(false) { }
1485a77eb0862507b900a10fa352af1568e639ed10b1Argyrios Kyrtzidis
14867bb12da2b0749eeebb21854c77877736969e59f2John McCallpublic:
14877bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// Computes whether an unresolved lookup on the given declarations
14887bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// and optional template arguments is type- and value-dependent.
14897bb12da2b0749eeebb21854c77877736969e59f2John McCall  static bool ComputeDependence(UnresolvedSetIterator Begin,
14907bb12da2b0749eeebb21854c77877736969e59f2John McCall                                UnresolvedSetIterator End,
14917bb12da2b0749eeebb21854c77877736969e59f2John McCall                                const TemplateArgumentListInfo *Args);
14927bb12da2b0749eeebb21854c77877736969e59f2John McCall
14939c72c6088d591ace8503b842d39448c2040f3033John McCall  struct FindResult {
14949c72c6088d591ace8503b842d39448c2040f3033John McCall    OverloadExpr *Expression;
14959c72c6088d591ace8503b842d39448c2040f3033John McCall    bool IsAddressOfOperand;
14969c72c6088d591ace8503b842d39448c2040f3033John McCall    bool HasFormOfMemberPointer;
14979c72c6088d591ace8503b842d39448c2040f3033John McCall  };
14989c72c6088d591ace8503b842d39448c2040f3033John McCall
14997bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// Finds the overloaded expression in the given expression of
15007bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// OverloadTy.
15017bb12da2b0749eeebb21854c77877736969e59f2John McCall  ///
15029c72c6088d591ace8503b842d39448c2040f3033John McCall  /// \return the expression (which must be there) and true if it has
15039c72c6088d591ace8503b842d39448c2040f3033John McCall  /// the particular form of a member pointer expression
15049c72c6088d591ace8503b842d39448c2040f3033John McCall  static FindResult find(Expr *E) {
15057bb12da2b0749eeebb21854c77877736969e59f2John McCall    assert(E->getType()->isSpecificBuiltinType(BuiltinType::Overload));
15067bb12da2b0749eeebb21854c77877736969e59f2John McCall
15079c72c6088d591ace8503b842d39448c2040f3033John McCall    FindResult Result;
15089c72c6088d591ace8503b842d39448c2040f3033John McCall
15097bb12da2b0749eeebb21854c77877736969e59f2John McCall    E = E->IgnoreParens();
15109c72c6088d591ace8503b842d39448c2040f3033John McCall    if (isa<UnaryOperator>(E)) {
15119c72c6088d591ace8503b842d39448c2040f3033John McCall      assert(cast<UnaryOperator>(E)->getOpcode() == UO_AddrOf);
15129c72c6088d591ace8503b842d39448c2040f3033John McCall      E = cast<UnaryOperator>(E)->getSubExpr();
15139c72c6088d591ace8503b842d39448c2040f3033John McCall      OverloadExpr *Ovl = cast<OverloadExpr>(E->IgnoreParens());
15149c72c6088d591ace8503b842d39448c2040f3033John McCall
15159c72c6088d591ace8503b842d39448c2040f3033John McCall      Result.HasFormOfMemberPointer = (E == Ovl && Ovl->getQualifier());
15169c72c6088d591ace8503b842d39448c2040f3033John McCall      Result.IsAddressOfOperand = true;
15179c72c6088d591ace8503b842d39448c2040f3033John McCall      Result.Expression = Ovl;
15189c72c6088d591ace8503b842d39448c2040f3033John McCall    } else {
15199c72c6088d591ace8503b842d39448c2040f3033John McCall      Result.HasFormOfMemberPointer = false;
15209c72c6088d591ace8503b842d39448c2040f3033John McCall      Result.IsAddressOfOperand = false;
15219c72c6088d591ace8503b842d39448c2040f3033John McCall      Result.Expression = cast<OverloadExpr>(E);
15229c72c6088d591ace8503b842d39448c2040f3033John McCall    }
15239c72c6088d591ace8503b842d39448c2040f3033John McCall
15249c72c6088d591ace8503b842d39448c2040f3033John McCall    return Result;
15257bb12da2b0749eeebb21854c77877736969e59f2John McCall  }
15267bb12da2b0749eeebb21854c77877736969e59f2John McCall
1527e9ee23edd17c4bb7f271e67f8790792b4de677fcJohn McCall  /// Gets the naming class of this lookup, if any.
1528e9ee23edd17c4bb7f271e67f8790792b4de677fcJohn McCall  CXXRecordDecl *getNamingClass() const;
1529e9ee23edd17c4bb7f271e67f8790792b4de677fcJohn McCall
15307bb12da2b0749eeebb21854c77877736969e59f2John McCall  typedef UnresolvedSetImpl::iterator decls_iterator;
1531928e6fcf66fc4f342bcf7cc96bf56986c9c2a833Douglas Gregor  decls_iterator decls_begin() const { return UnresolvedSetIterator(Results); }
1532928e6fcf66fc4f342bcf7cc96bf56986c9c2a833Douglas Gregor  decls_iterator decls_end() const {
1533928e6fcf66fc4f342bcf7cc96bf56986c9c2a833Douglas Gregor    return UnresolvedSetIterator(Results + NumResults);
1534928e6fcf66fc4f342bcf7cc96bf56986c9c2a833Douglas Gregor  }
1535a77eb0862507b900a10fa352af1568e639ed10b1Argyrios Kyrtzidis
1536a77eb0862507b900a10fa352af1568e639ed10b1Argyrios Kyrtzidis  void initializeResults(ASTContext &C,
1537a77eb0862507b900a10fa352af1568e639ed10b1Argyrios Kyrtzidis                         UnresolvedSetIterator Begin,UnresolvedSetIterator End);
15387bb12da2b0749eeebb21854c77877736969e59f2John McCall
15397bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// Gets the number of declarations in the unresolved set.
1540928e6fcf66fc4f342bcf7cc96bf56986c9c2a833Douglas Gregor  unsigned getNumDecls() const { return NumResults; }
15417bb12da2b0749eeebb21854c77877736969e59f2John McCall
15422577743c5650c646fb705df01403707e94f2df04Abramo Bagnara  /// Gets the full name info.
15432577743c5650c646fb705df01403707e94f2df04Abramo Bagnara  const DeclarationNameInfo &getNameInfo() const { return NameInfo; }
15442577743c5650c646fb705df01403707e94f2df04Abramo Bagnara  void setNameInfo(const DeclarationNameInfo &N) { NameInfo = N; }
15452577743c5650c646fb705df01403707e94f2df04Abramo Bagnara
15467bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// Gets the name looked up.
15472577743c5650c646fb705df01403707e94f2df04Abramo Bagnara  DeclarationName getName() const { return NameInfo.getName(); }
15482577743c5650c646fb705df01403707e94f2df04Abramo Bagnara  void setName(DeclarationName N) { NameInfo.setName(N); }
15497bb12da2b0749eeebb21854c77877736969e59f2John McCall
15507bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// Gets the location of the name.
15512577743c5650c646fb705df01403707e94f2df04Abramo Bagnara  SourceLocation getNameLoc() const { return NameInfo.getLoc(); }
15522577743c5650c646fb705df01403707e94f2df04Abramo Bagnara  void setNameLoc(SourceLocation Loc) { NameInfo.setLoc(Loc); }
15537bb12da2b0749eeebb21854c77877736969e59f2John McCall
15547bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// Fetches the nested-name qualifier, if one was given.
15557bb12da2b0749eeebb21854c77877736969e59f2John McCall  NestedNameSpecifier *getQualifier() const { return Qualifier; }
1556a77eb0862507b900a10fa352af1568e639ed10b1Argyrios Kyrtzidis  void setQualifier(NestedNameSpecifier *NNS) { Qualifier = NNS; }
15577bb12da2b0749eeebb21854c77877736969e59f2John McCall
15587bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// Fetches the range of the nested-name qualifier.
15597bb12da2b0749eeebb21854c77877736969e59f2John McCall  SourceRange getQualifierRange() const { return QualifierRange; }
1560a77eb0862507b900a10fa352af1568e639ed10b1Argyrios Kyrtzidis  void setQualifierRange(SourceRange R) { QualifierRange = R; }
15617bb12da2b0749eeebb21854c77877736969e59f2John McCall
15627bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// \brief Determines whether this expression had an explicit
15637bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// template argument list, e.g. f<int>.
15647bb12da2b0749eeebb21854c77877736969e59f2John McCall  bool hasExplicitTemplateArgs() const { return HasExplicitTemplateArgs; }
15657bb12da2b0749eeebb21854c77877736969e59f2John McCall
15667bb12da2b0749eeebb21854c77877736969e59f2John McCall  ExplicitTemplateArgumentList &getExplicitTemplateArgs(); // defined far below
15677bb12da2b0749eeebb21854c77877736969e59f2John McCall
15687bb12da2b0749eeebb21854c77877736969e59f2John McCall  const ExplicitTemplateArgumentList &getExplicitTemplateArgs() const {
15697bb12da2b0749eeebb21854c77877736969e59f2John McCall    return const_cast<OverloadExpr*>(this)->getExplicitTemplateArgs();
15707bb12da2b0749eeebb21854c77877736969e59f2John McCall  }
15717bb12da2b0749eeebb21854c77877736969e59f2John McCall
1572096832c5ed5b9106fa177ebc148489760c3bc496John McCall  /// \brief Retrieves the optional explicit template arguments.
1573096832c5ed5b9106fa177ebc148489760c3bc496John McCall  /// This points to the same data as getExplicitTemplateArgs(), but
1574096832c5ed5b9106fa177ebc148489760c3bc496John McCall  /// returns null if there are no explicit template arguments.
1575096832c5ed5b9106fa177ebc148489760c3bc496John McCall  const ExplicitTemplateArgumentList *getOptionalExplicitTemplateArgs() {
1576096832c5ed5b9106fa177ebc148489760c3bc496John McCall    if (!hasExplicitTemplateArgs()) return 0;
1577096832c5ed5b9106fa177ebc148489760c3bc496John McCall    return &getExplicitTemplateArgs();
15787bb12da2b0749eeebb21854c77877736969e59f2John McCall  }
15797bb12da2b0749eeebb21854c77877736969e59f2John McCall
15807bb12da2b0749eeebb21854c77877736969e59f2John McCall  static bool classof(const Stmt *T) {
15817bb12da2b0749eeebb21854c77877736969e59f2John McCall    return T->getStmtClass() == UnresolvedLookupExprClass ||
15827bb12da2b0749eeebb21854c77877736969e59f2John McCall           T->getStmtClass() == UnresolvedMemberExprClass;
15837bb12da2b0749eeebb21854c77877736969e59f2John McCall  }
15847bb12da2b0749eeebb21854c77877736969e59f2John McCall  static bool classof(const OverloadExpr *) { return true; }
15854045107b7384fd68eed5e3e2f06fc2a47e7be0a6Argyrios Kyrtzidis
15864045107b7384fd68eed5e3e2f06fc2a47e7be0a6Argyrios Kyrtzidis  friend class ASTStmtReader;
15874045107b7384fd68eed5e3e2f06fc2a47e7be0a6Argyrios Kyrtzidis  friend class ASTStmtWriter;
15887bb12da2b0749eeebb21854c77877736969e59f2John McCall};
15897bb12da2b0749eeebb21854c77877736969e59f2John McCall
15907bb12da2b0749eeebb21854c77877736969e59f2John McCall/// \brief A reference to a name which we were able to look up during
15917bb12da2b0749eeebb21854c77877736969e59f2John McCall/// parsing but could not resolve to a specific declaration.  This
15927bb12da2b0749eeebb21854c77877736969e59f2John McCall/// arises in several ways:
15937bb12da2b0749eeebb21854c77877736969e59f2John McCall///   * we might be waiting for argument-dependent lookup
15947bb12da2b0749eeebb21854c77877736969e59f2John McCall///   * the name might resolve to an overloaded function
15957bb12da2b0749eeebb21854c77877736969e59f2John McCall/// and eventually:
15967bb12da2b0749eeebb21854c77877736969e59f2John McCall///   * the lookup might have included a function template
15977bb12da2b0749eeebb21854c77877736969e59f2John McCall/// These never include UnresolvedUsingValueDecls, which are always
15987bb12da2b0749eeebb21854c77877736969e59f2John McCall/// class members and therefore appear only in
15997bb12da2b0749eeebb21854c77877736969e59f2John McCall/// UnresolvedMemberLookupExprs.
16007bb12da2b0749eeebb21854c77877736969e59f2John McCallclass UnresolvedLookupExpr : public OverloadExpr {
1601ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  /// True if these lookup results should be extended by
1602ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  /// argument-dependent lookup if this is the operand of a function
1603ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  /// call.
1604ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  bool RequiresADL;
1605ba13543329afac4a0d01304ec2ec4924d99306a6John McCall
16067453ed4cb2cab113de3378df371b1c6f1243d832John McCall  /// True if these lookup results are overloaded.  This is pretty
16077453ed4cb2cab113de3378df371b1c6f1243d832John McCall  /// trivially rederivable if we urgently need to kill this field.
16087453ed4cb2cab113de3378df371b1c6f1243d832John McCall  bool Overloaded;
16097453ed4cb2cab113de3378df371b1c6f1243d832John McCall
16107bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// The naming class (C++ [class.access.base]p5) of the lookup, if
16117bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// any.  This can generally be recalculated from the context chain,
16127bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// but that can be fairly expensive for unqualified lookups.  If we
16137bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// want to improve memory use here, this could go in a union
16147bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// against the qualified-lookup bits.
16157bb12da2b0749eeebb21854c77877736969e59f2John McCall  CXXRecordDecl *NamingClass;
1616f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall
1617928e6fcf66fc4f342bcf7cc96bf56986c9c2a833Douglas Gregor  UnresolvedLookupExpr(ASTContext &C, QualType T, bool Dependent,
1618928e6fcf66fc4f342bcf7cc96bf56986c9c2a833Douglas Gregor                       CXXRecordDecl *NamingClass,
1619ba13543329afac4a0d01304ec2ec4924d99306a6John McCall                       NestedNameSpecifier *Qualifier, SourceRange QRange,
16202577743c5650c646fb705df01403707e94f2df04Abramo Bagnara                       const DeclarationNameInfo &NameInfo,
16215a84dec38cfa9e084377a3167b474c79283c82faDouglas Gregor                       bool RequiresADL, bool Overloaded, bool HasTemplateArgs,
16225a84dec38cfa9e084377a3167b474c79283c82faDouglas Gregor                       UnresolvedSetIterator Begin, UnresolvedSetIterator End)
1623f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall    : OverloadExpr(UnresolvedLookupExprClass, C, T,
1624f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall                   Dependent, Qualifier,  QRange, NameInfo, HasTemplateArgs,
1625f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall                   Begin, End),
16267bb12da2b0749eeebb21854c77877736969e59f2John McCall      RequiresADL(RequiresADL), Overloaded(Overloaded), NamingClass(NamingClass)
1627ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  {}
1628ba13543329afac4a0d01304ec2ec4924d99306a6John McCall
1629bd65bb511c26549c96b829c1282e4c877588564aArgyrios Kyrtzidis  UnresolvedLookupExpr(EmptyShell Empty)
1630bd65bb511c26549c96b829c1282e4c877588564aArgyrios Kyrtzidis    : OverloadExpr(UnresolvedLookupExprClass, Empty),
1631bd65bb511c26549c96b829c1282e4c877588564aArgyrios Kyrtzidis      RequiresADL(false), Overloaded(false), NamingClass(0)
1632bd65bb511c26549c96b829c1282e4c877588564aArgyrios Kyrtzidis  {}
1633bd65bb511c26549c96b829c1282e4c877588564aArgyrios Kyrtzidis
1634ba13543329afac4a0d01304ec2ec4924d99306a6John McCallpublic:
1635ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  static UnresolvedLookupExpr *Create(ASTContext &C,
1636f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall                                      bool Dependent,
1637c373d48502ca7683ab55385f5bd624d778eb288dJohn McCall                                      CXXRecordDecl *NamingClass,
1638ba13543329afac4a0d01304ec2ec4924d99306a6John McCall                                      NestedNameSpecifier *Qualifier,
1639ba13543329afac4a0d01304ec2ec4924d99306a6John McCall                                      SourceRange QualifierRange,
16402577743c5650c646fb705df01403707e94f2df04Abramo Bagnara                                      const DeclarationNameInfo &NameInfo,
16415a84dec38cfa9e084377a3167b474c79283c82faDouglas Gregor                                      bool ADL, bool Overloaded,
16425a84dec38cfa9e084377a3167b474c79283c82faDouglas Gregor                                      UnresolvedSetIterator Begin,
16435a84dec38cfa9e084377a3167b474c79283c82faDouglas Gregor                                      UnresolvedSetIterator End) {
1644928e6fcf66fc4f342bcf7cc96bf56986c9c2a833Douglas Gregor    return new(C) UnresolvedLookupExpr(C,
1645928e6fcf66fc4f342bcf7cc96bf56986c9c2a833Douglas Gregor                                       Dependent ? C.DependentTy : C.OverloadTy,
1646c373d48502ca7683ab55385f5bd624d778eb288dJohn McCall                                       Dependent, NamingClass,
16472577743c5650c646fb705df01403707e94f2df04Abramo Bagnara                                       Qualifier, QualifierRange, NameInfo,
16482577743c5650c646fb705df01403707e94f2df04Abramo Bagnara                                       ADL, Overloaded, false,
16495a84dec38cfa9e084377a3167b474c79283c82faDouglas Gregor                                       Begin, End);
1650ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  }
1651ba13543329afac4a0d01304ec2ec4924d99306a6John McCall
1652f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  static UnresolvedLookupExpr *Create(ASTContext &C,
1653f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall                                      bool Dependent,
1654c373d48502ca7683ab55385f5bd624d778eb288dJohn McCall                                      CXXRecordDecl *NamingClass,
1655f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall                                      NestedNameSpecifier *Qualifier,
1656f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall                                      SourceRange QualifierRange,
16572577743c5650c646fb705df01403707e94f2df04Abramo Bagnara                                      const DeclarationNameInfo &NameInfo,
1658f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall                                      bool ADL,
16595a84dec38cfa9e084377a3167b474c79283c82faDouglas Gregor                                      const TemplateArgumentListInfo &Args,
16605a84dec38cfa9e084377a3167b474c79283c82faDouglas Gregor                                      UnresolvedSetIterator Begin,
16615a84dec38cfa9e084377a3167b474c79283c82faDouglas Gregor                                      UnresolvedSetIterator End);
1662f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall
1663bd65bb511c26549c96b829c1282e4c877588564aArgyrios Kyrtzidis  static UnresolvedLookupExpr *CreateEmpty(ASTContext &C,
1664bd65bb511c26549c96b829c1282e4c877588564aArgyrios Kyrtzidis                                           unsigned NumTemplateArgs);
1665bd65bb511c26549c96b829c1282e4c877588564aArgyrios Kyrtzidis
1666ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  /// True if this declaration should be extended by
1667ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  /// argument-dependent lookup.
1668ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  bool requiresADL() const { return RequiresADL; }
1669bd65bb511c26549c96b829c1282e4c877588564aArgyrios Kyrtzidis  void setRequiresADL(bool V) { RequiresADL = V; }
1670ba13543329afac4a0d01304ec2ec4924d99306a6John McCall
16717453ed4cb2cab113de3378df371b1c6f1243d832John McCall  /// True if this lookup is overloaded.
16727453ed4cb2cab113de3378df371b1c6f1243d832John McCall  bool isOverloaded() const { return Overloaded; }
1673bd65bb511c26549c96b829c1282e4c877588564aArgyrios Kyrtzidis  void setOverloaded(bool V) { Overloaded = V; }
16747453ed4cb2cab113de3378df371b1c6f1243d832John McCall
1675c373d48502ca7683ab55385f5bd624d778eb288dJohn McCall  /// Gets the 'naming class' (in the sense of C++0x
1676c373d48502ca7683ab55385f5bd624d778eb288dJohn McCall  /// [class.access.base]p5) of the lookup.  This is the scope
1677c373d48502ca7683ab55385f5bd624d778eb288dJohn McCall  /// that was looked in to find these results.
1678c373d48502ca7683ab55385f5bd624d778eb288dJohn McCall  CXXRecordDecl *getNamingClass() const { return NamingClass; }
1679bd65bb511c26549c96b829c1282e4c877588564aArgyrios Kyrtzidis  void setNamingClass(CXXRecordDecl *D) { NamingClass = D; }
1680c373d48502ca7683ab55385f5bd624d778eb288dJohn McCall
1681f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  // Note that, inconsistently with the explicit-template-argument AST
1682f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  // nodes, users are *forbidden* from calling these methods on objects
1683f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  // without explicit template arguments.
1684f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall
16857bb12da2b0749eeebb21854c77877736969e59f2John McCall  ExplicitTemplateArgumentList &getExplicitTemplateArgs() {
16867bb12da2b0749eeebb21854c77877736969e59f2John McCall    assert(hasExplicitTemplateArgs());
16877bb12da2b0749eeebb21854c77877736969e59f2John McCall    return *reinterpret_cast<ExplicitTemplateArgumentList*>(this + 1);
16887bb12da2b0749eeebb21854c77877736969e59f2John McCall  }
16897bb12da2b0749eeebb21854c77877736969e59f2John McCall
1690f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  /// Gets a reference to the explicit template argument list.
1691f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  const ExplicitTemplateArgumentList &getExplicitTemplateArgs() const {
1692f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall    assert(hasExplicitTemplateArgs());
1693f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall    return *reinterpret_cast<const ExplicitTemplateArgumentList*>(this + 1);
1694f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  }
1695f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall
1696096832c5ed5b9106fa177ebc148489760c3bc496John McCall  /// \brief Retrieves the optional explicit template arguments.
1697096832c5ed5b9106fa177ebc148489760c3bc496John McCall  /// This points to the same data as getExplicitTemplateArgs(), but
1698096832c5ed5b9106fa177ebc148489760c3bc496John McCall  /// returns null if there are no explicit template arguments.
1699096832c5ed5b9106fa177ebc148489760c3bc496John McCall  const ExplicitTemplateArgumentList *getOptionalExplicitTemplateArgs() {
1700096832c5ed5b9106fa177ebc148489760c3bc496John McCall    if (!hasExplicitTemplateArgs()) return 0;
1701096832c5ed5b9106fa177ebc148489760c3bc496John McCall    return &getExplicitTemplateArgs();
1702096832c5ed5b9106fa177ebc148489760c3bc496John McCall  }
1703096832c5ed5b9106fa177ebc148489760c3bc496John McCall
1704f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  /// \brief Copies the template arguments (if present) into the given
1705f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  /// structure.
1706f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  void copyTemplateArgumentsInto(TemplateArgumentListInfo &List) const {
1707f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall    getExplicitTemplateArgs().copyInto(List);
1708f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  }
1709ba13543329afac4a0d01304ec2ec4924d99306a6John McCall
1710f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  SourceLocation getLAngleLoc() const {
1711f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall    return getExplicitTemplateArgs().LAngleLoc;
1712f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  }
1713f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall
1714f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  SourceLocation getRAngleLoc() const {
1715f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall    return getExplicitTemplateArgs().RAngleLoc;
1716f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  }
1717f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall
1718f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  TemplateArgumentLoc const *getTemplateArgs() const {
1719f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall    return getExplicitTemplateArgs().getTemplateArgs();
1720f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  }
1721f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall
1722f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  unsigned getNumTemplateArgs() const {
1723f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall    return getExplicitTemplateArgs().NumTemplateArgs;
1724f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  }
1725ba13543329afac4a0d01304ec2ec4924d99306a6John McCall
1726ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  virtual SourceRange getSourceRange() const {
17272577743c5650c646fb705df01403707e94f2df04Abramo Bagnara    SourceRange Range(getNameInfo().getSourceRange());
17287bb12da2b0749eeebb21854c77877736969e59f2John McCall    if (getQualifier()) Range.setBegin(getQualifierRange().getBegin());
1729f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall    if (hasExplicitTemplateArgs()) Range.setEnd(getRAngleLoc());
1730f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall    return Range;
1731ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  }
1732ba13543329afac4a0d01304ec2ec4924d99306a6John McCall
1733ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  virtual StmtIterator child_begin();
1734ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  virtual StmtIterator child_end();
1735ba13543329afac4a0d01304ec2ec4924d99306a6John McCall
1736ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  static bool classof(const Stmt *T) {
1737ba13543329afac4a0d01304ec2ec4924d99306a6John McCall    return T->getStmtClass() == UnresolvedLookupExprClass;
1738ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  }
1739ba13543329afac4a0d01304ec2ec4924d99306a6John McCall  static bool classof(const UnresolvedLookupExpr *) { return true; }
1740ba13543329afac4a0d01304ec2ec4924d99306a6John McCall};
1741ba13543329afac4a0d01304ec2ec4924d99306a6John McCall
17425953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor/// \brief A qualified reference to a name whose declaration cannot
17435953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor/// yet be resolved.
17445953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor///
1745ba13543329afac4a0d01304ec2ec4924d99306a6John McCall/// DependentScopeDeclRefExpr is similar to DeclRefExpr in that
1746a2813cec2605ce7878d1b13471d685f689b251afDouglas Gregor/// it expresses a reference to a declaration such as
17475953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor/// X<T>::value. The difference, however, is that an
1748865d447ac6a4721ab58e898d014a21f2eff74b06John McCall/// DependentScopeDeclRefExpr node is used only within C++ templates when
17495953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor/// the qualification (e.g., X<T>::) refers to a dependent type. In
17505953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor/// this case, X<T>::value cannot resolve to a declaration because the
17515953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor/// declaration will differ from on instantiation of X<T> to the
1752865d447ac6a4721ab58e898d014a21f2eff74b06John McCall/// next. Therefore, DependentScopeDeclRefExpr keeps track of the
1753ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor/// qualifier (X<T>::) and the name of the entity being referenced
1754a2813cec2605ce7878d1b13471d685f689b251afDouglas Gregor/// ("value"). Such expressions will instantiate to a DeclRefExpr once the
1755a2813cec2605ce7878d1b13471d685f689b251afDouglas Gregor/// declaration can be found.
1756865d447ac6a4721ab58e898d014a21f2eff74b06John McCallclass DependentScopeDeclRefExpr : public Expr {
17575953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor  /// The name of the entity we will be referencing.
17582577743c5650c646fb705df01403707e94f2df04Abramo Bagnara  DeclarationNameInfo NameInfo;
17595953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor
17605953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor  /// QualifierRange - The source range that covers the
17615953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor  /// nested-name-specifier.
17625953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor  SourceRange QualifierRange;
17635953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor
1764ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor  /// \brief The nested-name-specifier that qualifies this unresolved
1765ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor  /// declaration name.
1766f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  NestedNameSpecifier *Qualifier;
17675953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor
1768f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  /// \brief Whether the name includes explicit template arguments.
1769f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  bool HasExplicitTemplateArgs;
17701eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1771f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  DependentScopeDeclRefExpr(QualType T,
1772f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall                            NestedNameSpecifier *Qualifier,
1773f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall                            SourceRange QualifierRange,
17742577743c5650c646fb705df01403707e94f2df04Abramo Bagnara                            const DeclarationNameInfo &NameInfo,
1775f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall                            bool HasExplicitTemplateArgs)
1776f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall    : Expr(DependentScopeDeclRefExprClass, T, VK_LValue, OK_Ordinary,
1777f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall           true, true),
17782577743c5650c646fb705df01403707e94f2df04Abramo Bagnara      NameInfo(NameInfo), QualifierRange(QualifierRange), Qualifier(Qualifier),
1779f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall      HasExplicitTemplateArgs(HasExplicitTemplateArgs)
1780f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  {}
1781f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall
1782f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCallpublic:
1783f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  static DependentScopeDeclRefExpr *Create(ASTContext &C,
1784f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall                                           NestedNameSpecifier *Qualifier,
1785f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall                                           SourceRange QualifierRange,
17862577743c5650c646fb705df01403707e94f2df04Abramo Bagnara                                           const DeclarationNameInfo &NameInfo,
1787f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall                              const TemplateArgumentListInfo *TemplateArgs = 0);
17885953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor
178912dffcddb60380c5bed4f085a1f51534afda3b87Argyrios Kyrtzidis  static DependentScopeDeclRefExpr *CreateEmpty(ASTContext &C,
179012dffcddb60380c5bed4f085a1f51534afda3b87Argyrios Kyrtzidis                                                unsigned NumTemplateArgs);
179112dffcddb60380c5bed4f085a1f51534afda3b87Argyrios Kyrtzidis
17925953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor  /// \brief Retrieve the name that this expression refers to.
17932577743c5650c646fb705df01403707e94f2df04Abramo Bagnara  const DeclarationNameInfo &getNameInfo() const { return NameInfo; }
17942577743c5650c646fb705df01403707e94f2df04Abramo Bagnara  void setNameInfo(const DeclarationNameInfo &N) { NameInfo =  N; }
17952577743c5650c646fb705df01403707e94f2df04Abramo Bagnara
17962577743c5650c646fb705df01403707e94f2df04Abramo Bagnara  /// \brief Retrieve the name that this expression refers to.
17972577743c5650c646fb705df01403707e94f2df04Abramo Bagnara  DeclarationName getDeclName() const { return NameInfo.getName(); }
17982577743c5650c646fb705df01403707e94f2df04Abramo Bagnara  void setDeclName(DeclarationName N) { NameInfo.setName(N); }
17995953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor
18005953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor  /// \brief Retrieve the location of the name within the expression.
18012577743c5650c646fb705df01403707e94f2df04Abramo Bagnara  SourceLocation getLocation() const { return NameInfo.getLoc(); }
18022577743c5650c646fb705df01403707e94f2df04Abramo Bagnara  void setLocation(SourceLocation L) { NameInfo.setLoc(L); }
18035953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor
18045953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor  /// \brief Retrieve the source range of the nested-name-specifier.
18055953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor  SourceRange getQualifierRange() const { return QualifierRange; }
180612dffcddb60380c5bed4f085a1f51534afda3b87Argyrios Kyrtzidis  void setQualifierRange(SourceRange R) { QualifierRange = R; }
18075953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor
1808ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor  /// \brief Retrieve the nested-name-specifier that qualifies this
1809ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor  /// declaration.
1810edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor  NestedNameSpecifier *getQualifier() const { return Qualifier; }
181112dffcddb60380c5bed4f085a1f51534afda3b87Argyrios Kyrtzidis  void setQualifier(NestedNameSpecifier *NNS) { Qualifier = NNS; }
18121eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1813f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  /// Determines whether this lookup had explicit template arguments.
1814f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  bool hasExplicitTemplateArgs() const { return HasExplicitTemplateArgs; }
18151eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1816f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  // Note that, inconsistently with the explicit-template-argument AST
1817f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  // nodes, users are *forbidden* from calling these methods on objects
1818f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  // without explicit template arguments.
18191eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
182012dffcddb60380c5bed4f085a1f51534afda3b87Argyrios Kyrtzidis  ExplicitTemplateArgumentList &getExplicitTemplateArgs() {
182112dffcddb60380c5bed4f085a1f51534afda3b87Argyrios Kyrtzidis    assert(hasExplicitTemplateArgs());
182212dffcddb60380c5bed4f085a1f51534afda3b87Argyrios Kyrtzidis    return *reinterpret_cast<ExplicitTemplateArgumentList*>(this + 1);
182312dffcddb60380c5bed4f085a1f51534afda3b87Argyrios Kyrtzidis  }
182412dffcddb60380c5bed4f085a1f51534afda3b87Argyrios Kyrtzidis
1825f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  /// Gets a reference to the explicit template argument list.
1826f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  const ExplicitTemplateArgumentList &getExplicitTemplateArgs() const {
1827f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall    assert(hasExplicitTemplateArgs());
1828f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall    return *reinterpret_cast<const ExplicitTemplateArgumentList*>(this + 1);
1829f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  }
18301eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1831096832c5ed5b9106fa177ebc148489760c3bc496John McCall  /// \brief Retrieves the optional explicit template arguments.
1832096832c5ed5b9106fa177ebc148489760c3bc496John McCall  /// This points to the same data as getExplicitTemplateArgs(), but
1833096832c5ed5b9106fa177ebc148489760c3bc496John McCall  /// returns null if there are no explicit template arguments.
1834096832c5ed5b9106fa177ebc148489760c3bc496John McCall  const ExplicitTemplateArgumentList *getOptionalExplicitTemplateArgs() {
1835096832c5ed5b9106fa177ebc148489760c3bc496John McCall    if (!hasExplicitTemplateArgs()) return 0;
1836096832c5ed5b9106fa177ebc148489760c3bc496John McCall    return &getExplicitTemplateArgs();
1837096832c5ed5b9106fa177ebc148489760c3bc496John McCall  }
1838096832c5ed5b9106fa177ebc148489760c3bc496John McCall
1839f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  /// \brief Copies the template arguments (if present) into the given
1840f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  /// structure.
1841f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  void copyTemplateArgumentsInto(TemplateArgumentListInfo &List) const {
1842f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall    getExplicitTemplateArgs().copyInto(List);
1843f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  }
1844f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall
1845f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  SourceLocation getLAngleLoc() const {
1846f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall    return getExplicitTemplateArgs().LAngleLoc;
1847edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor  }
18481eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1849f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  SourceLocation getRAngleLoc() const {
1850f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall    return getExplicitTemplateArgs().RAngleLoc;
1851f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  }
18521eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1853f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  TemplateArgumentLoc const *getTemplateArgs() const {
1854f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall    return getExplicitTemplateArgs().getTemplateArgs();
1855d5532b6cfff2977e0c59fa6ead7f7973984a620dJohn McCall  }
1856d5532b6cfff2977e0c59fa6ead7f7973984a620dJohn McCall
1857f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  unsigned getNumTemplateArgs() const {
1858f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall    return getExplicitTemplateArgs().NumTemplateArgs;
1859f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  }
18601eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1861edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor  virtual SourceRange getSourceRange() const {
1862f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall    SourceRange Range(QualifierRange.getBegin(), getLocation());
1863f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall    if (hasExplicitTemplateArgs())
1864f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall      Range.setEnd(getRAngleLoc());
1865f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall    return Range;
1866edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor  }
18671eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
18681eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  static bool classof(const Stmt *T) {
1869f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall    return T->getStmtClass() == DependentScopeDeclRefExprClass;
1870edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor  }
1871f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  static bool classof(const DependentScopeDeclRefExpr *) { return true; }
1872f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall
1873f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  virtual StmtIterator child_begin();
1874f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall  virtual StmtIterator child_end();
18754045107b7384fd68eed5e3e2f06fc2a47e7be0a6Argyrios Kyrtzidis
18764045107b7384fd68eed5e3e2f06fc2a47e7be0a6Argyrios Kyrtzidis  friend class ASTStmtReader;
18774045107b7384fd68eed5e3e2f06fc2a47e7be0a6Argyrios Kyrtzidis  friend class ASTStmtWriter;
1878edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor};
18791eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
18802d44e8a41de8a33c0f04ac198714f71dc841bab0Anders Carlssonclass CXXExprWithTemporaries : public Expr {
188102bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson  Stmt *SubExpr;
18821eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1883ff6b3d64c9f07155f1414411b8451d7bf8937c62Anders Carlsson  CXXTemporary **Temps;
1884ff6b3d64c9f07155f1414411b8451d7bf8937c62Anders Carlsson  unsigned NumTemps;
188502bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson
1886d04ed416be7c55bddddab1fa3fd38a0113a6b3daTed Kremenek  CXXExprWithTemporaries(ASTContext &C, Expr *SubExpr, CXXTemporary **Temps,
18870ece491d8f62ce67f047491a6703fac0d3bd4ff4Anders Carlsson                         unsigned NumTemps);
188842602bb40aefcc2751d4078ba88aacf4d965c9bdDouglas Gregor
188988eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlssonpublic:
1890d2598368876cfe40bc8465540033bc5b5e58d8afChris Lattner  CXXExprWithTemporaries(EmptyShell Empty)
1891d2598368876cfe40bc8465540033bc5b5e58d8afChris Lattner    : Expr(CXXExprWithTemporariesClass, Empty),
1892d2598368876cfe40bc8465540033bc5b5e58d8afChris Lattner      SubExpr(0), Temps(0), NumTemps(0) {}
1893d2598368876cfe40bc8465540033bc5b5e58d8afChris Lattner
189488eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlsson  static CXXExprWithTemporaries *Create(ASTContext &C, Expr *SubExpr,
18950ece491d8f62ce67f047491a6703fac0d3bd4ff4Anders Carlsson                                        CXXTemporary **Temps,
18960ece491d8f62ce67f047491a6703fac0d3bd4ff4Anders Carlsson                                        unsigned NumTemps);
18971eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
189888eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlsson  unsigned getNumTemporaries() const { return NumTemps; }
1899d04ed416be7c55bddddab1fa3fd38a0113a6b3daTed Kremenek  void setNumTemporaries(ASTContext &C, unsigned N);
1900d2598368876cfe40bc8465540033bc5b5e58d8afChris Lattner
190188eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlsson  CXXTemporary *getTemporary(unsigned i) {
190288eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlsson    assert(i < NumTemps && "Index out of range");
190388eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlsson    return Temps[i];
190488eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlsson  }
1905f0721fe438d7e40c168e5d664970e7830bc138fbAnders Carlsson  const CXXTemporary *getTemporary(unsigned i) const {
19060ece491d8f62ce67f047491a6703fac0d3bd4ff4Anders Carlsson    return const_cast<CXXExprWithTemporaries*>(this)->getTemporary(i);
1907f0721fe438d7e40c168e5d664970e7830bc138fbAnders Carlsson  }
1908d2598368876cfe40bc8465540033bc5b5e58d8afChris Lattner  void setTemporary(unsigned i, CXXTemporary *T) {
1909d2598368876cfe40bc8465540033bc5b5e58d8afChris Lattner    assert(i < NumTemps && "Index out of range");
1910d2598368876cfe40bc8465540033bc5b5e58d8afChris Lattner    Temps[i] = T;
1911d2598368876cfe40bc8465540033bc5b5e58d8afChris Lattner  }
19121eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
191302bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson  Expr *getSubExpr() { return cast<Expr>(SubExpr); }
1914f0721fe438d7e40c168e5d664970e7830bc138fbAnders Carlsson  const Expr *getSubExpr() const { return cast<Expr>(SubExpr); }
191588eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlsson  void setSubExpr(Expr *E) { SubExpr = E; }
191602bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson
191796be6917e1c4ba1f4435a14c9e7c6c139571d086Douglas Gregor  virtual SourceRange getSourceRange() const {
191896be6917e1c4ba1f4435a14c9e7c6c139571d086Douglas Gregor    return SubExpr->getSourceRange();
191996be6917e1c4ba1f4435a14c9e7c6c139571d086Douglas Gregor  }
192002bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson
192102bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson  // Implement isa/cast/dyncast/etc.
192202bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson  static bool classof(const Stmt *T) {
19232d44e8a41de8a33c0f04ac198714f71dc841bab0Anders Carlsson    return T->getStmtClass() == CXXExprWithTemporariesClass;
192402bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson  }
19252d44e8a41de8a33c0f04ac198714f71dc841bab0Anders Carlsson  static bool classof(const CXXExprWithTemporaries *) { return true; }
192602bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson
192702bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson  // Iterators
192802bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson  virtual child_iterator child_begin();
192902bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson  virtual child_iterator child_end();
193002bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson};
193102bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson
1932d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// \brief Describes an explicit type conversion that uses functional
1933d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// notion but could not be resolved because one or more arguments are
1934d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// type-dependent.
1935d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor///
1936d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// The explicit type conversions expressed by
1937d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// CXXUnresolvedConstructExpr have the form \c T(a1, a2, ..., aN),
1938d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// where \c T is some type and \c a1, a2, ..., aN are values, and
1939d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// either \C T is a dependent type or one or more of the \c a's is
1940d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// type-dependent. For example, this would occur in a template such
1941d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// as:
1942d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor///
1943d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// \code
1944d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor///   template<typename T, typename A1>
1945d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor///   inline T make_a(const A1& a1) {
1946d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor///     return T(a1);
1947d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor///   }
1948d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// \endcode
1949d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor///
1950d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// When the returned expression is instantiated, it may resolve to a
1951d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// constructor call, conversion function call, or some kind of type
1952d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// conversion.
1953d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregorclass CXXUnresolvedConstructExpr : public Expr {
1954d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  /// \brief The type being constructed.
1955ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor  TypeSourceInfo *Type;
1956ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor
1957d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  /// \brief The location of the left parentheses ('(').
1958d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  SourceLocation LParenLoc;
1959d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor
1960d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  /// \brief The location of the right parentheses (')').
1961d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  SourceLocation RParenLoc;
1962d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor
1963d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  /// \brief The number of arguments used to construct the type.
1964d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  unsigned NumArgs;
19651eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1966ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor  CXXUnresolvedConstructExpr(TypeSourceInfo *Type,
1967d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor                             SourceLocation LParenLoc,
1968d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor                             Expr **Args,
1969d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor                             unsigned NumArgs,
1970d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor                             SourceLocation RParenLoc);
1971d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor
19728dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis  CXXUnresolvedConstructExpr(EmptyShell Empty, unsigned NumArgs)
1973ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor    : Expr(CXXUnresolvedConstructExprClass, Empty), Type(), NumArgs(NumArgs) { }
19748dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis
1975ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor  friend class ASTStmtReader;
1976ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor
1977d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregorpublic:
19781eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  static CXXUnresolvedConstructExpr *Create(ASTContext &C,
1979ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor                                            TypeSourceInfo *Type,
1980d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor                                            SourceLocation LParenLoc,
1981d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor                                            Expr **Args,
1982d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor                                            unsigned NumArgs,
1983d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor                                            SourceLocation RParenLoc);
1984d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor
19858dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis  static CXXUnresolvedConstructExpr *CreateEmpty(ASTContext &C,
19868dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis                                                 unsigned NumArgs);
19878dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis
1988d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  /// \brief Retrieve the type that is being constructed, as specified
1989d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  /// in the source code.
1990ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor  QualType getTypeAsWritten() const { return Type->getType(); }
1991d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor
1992ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor  /// \brief Retrieve the type source information for the type being
1993ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor  /// constructed.
1994ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor  TypeSourceInfo *getTypeSourceInfo() const { return Type; }
1995ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor
1996d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  /// \brief Retrieve the location of the left parentheses ('(') that
1997d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  /// precedes the argument list.
1998d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  SourceLocation getLParenLoc() const { return LParenLoc; }
1999d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  void setLParenLoc(SourceLocation L) { LParenLoc = L; }
2000d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor
2001d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  /// \brief Retrieve the location of the right parentheses (')') that
2002d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  /// follows the argument list.
2003d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  SourceLocation getRParenLoc() const { return RParenLoc; }
2004d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  void setRParenLoc(SourceLocation L) { RParenLoc = L; }
2005d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor
2006d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  /// \brief Retrieve the number of arguments.
2007d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  unsigned arg_size() const { return NumArgs; }
2008d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor
2009d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  typedef Expr** arg_iterator;
2010d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  arg_iterator arg_begin() { return reinterpret_cast<Expr**>(this + 1); }
2011d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  arg_iterator arg_end() { return arg_begin() + NumArgs; }
2012d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor
20131dd7383dc48718c452e71a625b29531dd96fbb9dJohn McCall  typedef const Expr* const * const_arg_iterator;
20141dd7383dc48718c452e71a625b29531dd96fbb9dJohn McCall  const_arg_iterator arg_begin() const {
20151dd7383dc48718c452e71a625b29531dd96fbb9dJohn McCall    return reinterpret_cast<const Expr* const *>(this + 1);
20161dd7383dc48718c452e71a625b29531dd96fbb9dJohn McCall  }
20171dd7383dc48718c452e71a625b29531dd96fbb9dJohn McCall  const_arg_iterator arg_end() const {
20181dd7383dc48718c452e71a625b29531dd96fbb9dJohn McCall    return arg_begin() + NumArgs;
20191dd7383dc48718c452e71a625b29531dd96fbb9dJohn McCall  }
20201dd7383dc48718c452e71a625b29531dd96fbb9dJohn McCall
2021d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  Expr *getArg(unsigned I) {
2022d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor    assert(I < NumArgs && "Argument index out-of-range");
2023d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor    return *(arg_begin() + I);
2024d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  }
2025d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor
20261dd7383dc48718c452e71a625b29531dd96fbb9dJohn McCall  const Expr *getArg(unsigned I) const {
20271dd7383dc48718c452e71a625b29531dd96fbb9dJohn McCall    assert(I < NumArgs && "Argument index out-of-range");
20281dd7383dc48718c452e71a625b29531dd96fbb9dJohn McCall    return *(arg_begin() + I);
20291dd7383dc48718c452e71a625b29531dd96fbb9dJohn McCall  }
20301dd7383dc48718c452e71a625b29531dd96fbb9dJohn McCall
20318dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis  void setArg(unsigned I, Expr *E) {
20328dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis    assert(I < NumArgs && "Argument index out-of-range");
20338dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis    *(arg_begin() + I) = E;
20348dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis  }
20358dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis
2036ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor  virtual SourceRange getSourceRange() const;
2037ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor
20381eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  static bool classof(const Stmt *T) {
2039d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor    return T->getStmtClass() == CXXUnresolvedConstructExprClass;
2040d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  }
2041d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  static bool classof(const CXXUnresolvedConstructExpr *) { return true; }
2042d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor
2043d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  // Iterators
2044d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  virtual child_iterator child_begin();
2045d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor  virtual child_iterator child_end();
2046d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor};
2047d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor
2048ba13543329afac4a0d01304ec2ec4924d99306a6John McCall/// \brief Represents a C++ member access expression where the actual
2049ba13543329afac4a0d01304ec2ec4924d99306a6John McCall/// member referenced could not be resolved because the base
2050ba13543329afac4a0d01304ec2ec4924d99306a6John McCall/// expression or the member name was dependent.
2051aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall///
2052aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall/// Like UnresolvedMemberExprs, these can be either implicit or
2053aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall/// explicit accesses.  It is only possible to get one of these with
2054aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall/// an implicit access if a qualifier is provided.
2055865d447ac6a4721ab58e898d014a21f2eff74b06John McCallclass CXXDependentScopeMemberExpr : public Expr {
20561c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  /// \brief The expression for the base pointer or class reference,
2057aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall  /// e.g., the \c x in x.f.  Can be null in implicit accesses.
20581c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  Stmt *Base;
20591eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
2060aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall  /// \brief The type of the base expression.  Never null, even for
2061aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall  /// implicit accesses.
2062aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall  QualType BaseType;
2063aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall
20641c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  /// \brief Whether this member expression used the '->' operator or
20651c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  /// the '.' operator.
20663b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor  bool IsArrow : 1;
20671c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor
20683b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor  /// \brief Whether this member expression has explicitly-specified template
20693b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor  /// arguments.
2070aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall  bool HasExplicitTemplateArgs : 1;
20711eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
20721c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  /// \brief The location of the '->' or '.' operator.
20731c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  SourceLocation OperatorLoc;
20741c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor
2075a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor  /// \brief The nested-name-specifier that precedes the member name, if any.
2076a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor  NestedNameSpecifier *Qualifier;
20771eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
2078a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor  /// \brief The source range covering the nested name specifier.
2079a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor  SourceRange QualifierRange;
20801eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
2081c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor  /// \brief In a qualified member access expression such as t->Base::f, this
20821eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  /// member stores the resolves of name lookup in the context of the member
2083c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor  /// access expression, to be used at instantiation time.
2084c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor  ///
2085c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor  /// FIXME: This member, along with the Qualifier and QualifierRange, could
2086c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor  /// be stuck into a structure that is optionally allocated at the end of
2087865d447ac6a4721ab58e898d014a21f2eff74b06John McCall  /// the CXXDependentScopeMemberExpr, to save space in the common case.
2088c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor  NamedDecl *FirstQualifierFoundInScope;
20891eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
20901c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  /// \brief The member to which this member expression refers, which
20911c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  /// can be name, overloaded operator, or destructor.
2092a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor  /// FIXME: could also be a template-id
20932577743c5650c646fb705df01403707e94f2df04Abramo Bagnara  DeclarationNameInfo MemberNameInfo;
20941eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
2095865d447ac6a4721ab58e898d014a21f2eff74b06John McCall  CXXDependentScopeMemberExpr(ASTContext &C,
2096aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall                          Expr *Base, QualType BaseType, bool IsArrow,
20973b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor                          SourceLocation OperatorLoc,
20983b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor                          NestedNameSpecifier *Qualifier,
20993b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor                          SourceRange QualifierRange,
21003b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor                          NamedDecl *FirstQualifierFoundInScope,
21012577743c5650c646fb705df01403707e94f2df04Abramo Bagnara                          DeclarationNameInfo MemberNameInfo,
2102d5532b6cfff2977e0c59fa6ead7f7973984a620dJohn McCall                          const TemplateArgumentListInfo *TemplateArgs);
21031eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
21041c0ca59416999129d0439c2661d137ef38e86209Douglas Gregorpublic:
2105865d447ac6a4721ab58e898d014a21f2eff74b06John McCall  CXXDependentScopeMemberExpr(ASTContext &C,
2106aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall                          Expr *Base, QualType BaseType,
2107aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall                          bool IsArrow,
21081c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor                          SourceLocation OperatorLoc,
2109a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor                          NestedNameSpecifier *Qualifier,
2110a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor                          SourceRange QualifierRange,
2111c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor                          NamedDecl *FirstQualifierFoundInScope,
21122577743c5650c646fb705df01403707e94f2df04Abramo Bagnara                          DeclarationNameInfo MemberNameInfo)
2113f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall  : Expr(CXXDependentScopeMemberExprClass, C.DependentTy,
2114f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall         VK_LValue, OK_Ordinary, true, true),
2115aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall    Base(Base), BaseType(BaseType), IsArrow(IsArrow),
2116aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall    HasExplicitTemplateArgs(false), OperatorLoc(OperatorLoc),
21173b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor    Qualifier(Qualifier), QualifierRange(QualifierRange),
21183b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor    FirstQualifierFoundInScope(FirstQualifierFoundInScope),
21192577743c5650c646fb705df01403707e94f2df04Abramo Bagnara    MemberNameInfo(MemberNameInfo) { }
21201eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
2121865d447ac6a4721ab58e898d014a21f2eff74b06John McCall  static CXXDependentScopeMemberExpr *
21221eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  Create(ASTContext &C,
2123aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall         Expr *Base, QualType BaseType, bool IsArrow,
21243b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor         SourceLocation OperatorLoc,
21253b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor         NestedNameSpecifier *Qualifier,
21263b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor         SourceRange QualifierRange,
21273b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor         NamedDecl *FirstQualifierFoundInScope,
21282577743c5650c646fb705df01403707e94f2df04Abramo Bagnara         DeclarationNameInfo MemberNameInfo,
2129d5532b6cfff2977e0c59fa6ead7f7973984a620dJohn McCall         const TemplateArgumentListInfo *TemplateArgs);
21301eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
21318dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis  static CXXDependentScopeMemberExpr *
21328dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis  CreateEmpty(ASTContext &C, unsigned NumTemplateArgs);
21338dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis
2134aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall  /// \brief True if this is an implicit access, i.e. one in which the
2135aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall  /// member being accessed was not written in the source.  The source
2136aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall  /// location of the operator is invalid in this case.
2137aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall  bool isImplicitAccess() const { return Base == 0; }
2138aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall
21391c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  /// \brief Retrieve the base object of this member expressions,
21401c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  /// e.g., the \c x in \c x.m.
2141aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall  Expr *getBase() const {
2142aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall    assert(!isImplicitAccess());
2143aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall    return cast<Expr>(Base);
2144aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall  }
21451c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  void setBase(Expr *E) { Base = E; }
21461c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor
2147aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall  QualType getBaseType() const { return BaseType; }
21488dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis  void setBaseType(QualType T) { BaseType = T; }
2149aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall
21501c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  /// \brief Determine whether this member expression used the '->'
21511c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  /// operator; otherwise, it used the '.' operator.
21521c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  bool isArrow() const { return IsArrow; }
21531c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  void setArrow(bool A) { IsArrow = A; }
21541c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor
21551c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  /// \brief Retrieve the location of the '->' or '.' operator.
21561c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  SourceLocation getOperatorLoc() const { return OperatorLoc; }
21571c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  void setOperatorLoc(SourceLocation L) { OperatorLoc = L; }
21581c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor
2159a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor  /// \brief Retrieve the nested-name-specifier that qualifies the member
2160a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor  /// name.
2161a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor  NestedNameSpecifier *getQualifier() const { return Qualifier; }
21628dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis  void setQualifier(NestedNameSpecifier *NNS) { Qualifier = NNS; }
21631eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
2164a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor  /// \brief Retrieve the source range covering the nested-name-specifier
2165a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor  /// that qualifies the member name.
2166a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor  SourceRange getQualifierRange() const { return QualifierRange; }
21678dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis  void setQualifierRange(SourceRange R) { QualifierRange = R; }
21681eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
2169c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor  /// \brief Retrieve the first part of the nested-name-specifier that was
2170c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor  /// found in the scope of the member access expression when the member access
2171c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor  /// was initially parsed.
2172c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor  ///
2173c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor  /// This function only returns a useful result when member access expression
21741eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  /// uses a qualified member name, e.g., "x.Base::f". Here, the declaration
21751eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  /// returned by this function describes what was found by unqualified name
2176c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor  /// lookup for the identifier "Base" within the scope of the member access
2177c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor  /// expression itself. At template instantiation time, this information is
2178c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor  /// combined with the results of name lookup into the type of the object
2179c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor  /// expression itself (the class type of x).
21801eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  NamedDecl *getFirstQualifierFoundInScope() const {
2181c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor    return FirstQualifierFoundInScope;
2182c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor  }
21838dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis  void setFirstQualifierFoundInScope(NamedDecl *D) {
21848dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis    FirstQualifierFoundInScope = D;
21858dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis  }
21861eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
21871c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  /// \brief Retrieve the name of the member that this expression
21881c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  /// refers to.
21892577743c5650c646fb705df01403707e94f2df04Abramo Bagnara  const DeclarationNameInfo &getMemberNameInfo() const {
21902577743c5650c646fb705df01403707e94f2df04Abramo Bagnara    return MemberNameInfo;
21912577743c5650c646fb705df01403707e94f2df04Abramo Bagnara  }
21922577743c5650c646fb705df01403707e94f2df04Abramo Bagnara  void setMemberNameInfo(const DeclarationNameInfo &N) { MemberNameInfo = N; }
21932577743c5650c646fb705df01403707e94f2df04Abramo Bagnara
21942577743c5650c646fb705df01403707e94f2df04Abramo Bagnara  /// \brief Retrieve the name of the member that this expression
21952577743c5650c646fb705df01403707e94f2df04Abramo Bagnara  /// refers to.
21962577743c5650c646fb705df01403707e94f2df04Abramo Bagnara  DeclarationName getMember() const { return MemberNameInfo.getName(); }
21972577743c5650c646fb705df01403707e94f2df04Abramo Bagnara  void setMember(DeclarationName N) { MemberNameInfo.setName(N); }
21981c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor
21991c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  // \brief Retrieve the location of the name of the member that this
22001c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  // expression refers to.
22012577743c5650c646fb705df01403707e94f2df04Abramo Bagnara  SourceLocation getMemberLoc() const { return MemberNameInfo.getLoc(); }
22022577743c5650c646fb705df01403707e94f2df04Abramo Bagnara  void setMemberLoc(SourceLocation L) { MemberNameInfo.setLoc(L); }
22031c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor
22043b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor  /// \brief Determines whether this member expression actually had a C++
22053b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor  /// template argument list explicitly specified, e.g., x.f<int>.
2206aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall  bool hasExplicitTemplateArgs() const {
2207aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall    return HasExplicitTemplateArgs;
22083b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor  }
22091eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
221036c76f0bea0d3595a25a5362225c642019cc3176Argyrios Kyrtzidis  /// \brief Retrieve the explicit template argument list that followed the
221136c76f0bea0d3595a25a5362225c642019cc3176Argyrios Kyrtzidis  /// member template name, if any.
2212096832c5ed5b9106fa177ebc148489760c3bc496John McCall  ExplicitTemplateArgumentList &getExplicitTemplateArgs() {
221336c76f0bea0d3595a25a5362225c642019cc3176Argyrios Kyrtzidis    assert(HasExplicitTemplateArgs);
2214096832c5ed5b9106fa177ebc148489760c3bc496John McCall    return *reinterpret_cast<ExplicitTemplateArgumentList *>(this + 1);
221536c76f0bea0d3595a25a5362225c642019cc3176Argyrios Kyrtzidis  }
221636c76f0bea0d3595a25a5362225c642019cc3176Argyrios Kyrtzidis
221736c76f0bea0d3595a25a5362225c642019cc3176Argyrios Kyrtzidis  /// \brief Retrieve the explicit template argument list that followed the
221836c76f0bea0d3595a25a5362225c642019cc3176Argyrios Kyrtzidis  /// member template name, if any.
2219096832c5ed5b9106fa177ebc148489760c3bc496John McCall  const ExplicitTemplateArgumentList &getExplicitTemplateArgs() const {
222036c76f0bea0d3595a25a5362225c642019cc3176Argyrios Kyrtzidis    return const_cast<CXXDependentScopeMemberExpr *>(this)
2221096832c5ed5b9106fa177ebc148489760c3bc496John McCall             ->getExplicitTemplateArgs();
2222096832c5ed5b9106fa177ebc148489760c3bc496John McCall  }
2223096832c5ed5b9106fa177ebc148489760c3bc496John McCall
2224096832c5ed5b9106fa177ebc148489760c3bc496John McCall  /// \brief Retrieves the optional explicit template arguments.
2225096832c5ed5b9106fa177ebc148489760c3bc496John McCall  /// This points to the same data as getExplicitTemplateArgs(), but
2226096832c5ed5b9106fa177ebc148489760c3bc496John McCall  /// returns null if there are no explicit template arguments.
2227096832c5ed5b9106fa177ebc148489760c3bc496John McCall  const ExplicitTemplateArgumentList *getOptionalExplicitTemplateArgs() {
2228096832c5ed5b9106fa177ebc148489760c3bc496John McCall    if (!hasExplicitTemplateArgs()) return 0;
2229096832c5ed5b9106fa177ebc148489760c3bc496John McCall    return &getExplicitTemplateArgs();
223036c76f0bea0d3595a25a5362225c642019cc3176Argyrios Kyrtzidis  }
223136c76f0bea0d3595a25a5362225c642019cc3176Argyrios Kyrtzidis
2232d5532b6cfff2977e0c59fa6ead7f7973984a620dJohn McCall  /// \brief Copies the template arguments (if present) into the given
2233d5532b6cfff2977e0c59fa6ead7f7973984a620dJohn McCall  /// structure.
2234d5532b6cfff2977e0c59fa6ead7f7973984a620dJohn McCall  void copyTemplateArgumentsInto(TemplateArgumentListInfo &List) const {
2235096832c5ed5b9106fa177ebc148489760c3bc496John McCall    getExplicitTemplateArgs().copyInto(List);
2236d5532b6cfff2977e0c59fa6ead7f7973984a620dJohn McCall  }
2237d5532b6cfff2977e0c59fa6ead7f7973984a620dJohn McCall
22388dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis  /// \brief Initializes the template arguments using the given structure.
22398dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis  void initializeTemplateArgumentsFrom(const TemplateArgumentListInfo &List) {
2240096832c5ed5b9106fa177ebc148489760c3bc496John McCall    getExplicitTemplateArgs().initializeFrom(List);
22418dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis  }
22428dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis
22431eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  /// \brief Retrieve the location of the left angle bracket following the
22443b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor  /// member name ('<'), if any.
22451eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  SourceLocation getLAngleLoc() const {
2246096832c5ed5b9106fa177ebc148489760c3bc496John McCall    return getExplicitTemplateArgs().LAngleLoc;
22473b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor  }
22481eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
22493b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor  /// \brief Retrieve the template arguments provided as part of this
22503b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor  /// template-id.
2251833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall  const TemplateArgumentLoc *getTemplateArgs() const {
2252096832c5ed5b9106fa177ebc148489760c3bc496John McCall    return getExplicitTemplateArgs().getTemplateArgs();
22533b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor  }
22541eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
22553b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor  /// \brief Retrieve the number of template arguments provided as part of this
22563b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor  /// template-id.
22571eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  unsigned getNumTemplateArgs() const {
2258096832c5ed5b9106fa177ebc148489760c3bc496John McCall    return getExplicitTemplateArgs().NumTemplateArgs;
22593b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor  }
22601eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
22611eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  /// \brief Retrieve the location of the right angle bracket following the
22623b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor  /// template arguments ('>').
22631eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  SourceLocation getRAngleLoc() const {
2264096832c5ed5b9106fa177ebc148489760c3bc496John McCall    return getExplicitTemplateArgs().RAngleLoc;
22653b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor  }
22661eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
22671c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  virtual SourceRange getSourceRange() const {
2268aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall    SourceRange Range;
2269aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall    if (!isImplicitAccess())
2270aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall      Range.setBegin(Base->getSourceRange().getBegin());
2271aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall    else if (getQualifier())
2272aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall      Range.setBegin(getQualifierRange().getBegin());
2273aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall    else
22742577743c5650c646fb705df01403707e94f2df04Abramo Bagnara      Range.setBegin(MemberNameInfo.getBeginLoc());
22751eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
2276aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall    if (hasExplicitTemplateArgs())
2277aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall      Range.setEnd(getRAngleLoc());
2278aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall    else
22792577743c5650c646fb705df01403707e94f2df04Abramo Bagnara      Range.setEnd(MemberNameInfo.getEndLoc());
2280aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall    return Range;
22811c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  }
22821eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
22831eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  static bool classof(const Stmt *T) {
2284865d447ac6a4721ab58e898d014a21f2eff74b06John McCall    return T->getStmtClass() == CXXDependentScopeMemberExprClass;
22851c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  }
2286865d447ac6a4721ab58e898d014a21f2eff74b06John McCall  static bool classof(const CXXDependentScopeMemberExpr *) { return true; }
22871c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor
22881c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  // Iterators
22891c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  virtual child_iterator child_begin();
22901c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor  virtual child_iterator child_end();
22914045107b7384fd68eed5e3e2f06fc2a47e7be0a6Argyrios Kyrtzidis
22924045107b7384fd68eed5e3e2f06fc2a47e7be0a6Argyrios Kyrtzidis  friend class ASTStmtReader;
22934045107b7384fd68eed5e3e2f06fc2a47e7be0a6Argyrios Kyrtzidis  friend class ASTStmtWriter;
22941c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor};
22951c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor
2296129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall/// \brief Represents a C++ member access expression for which lookup
2297aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall/// produced a set of overloaded functions.
2298aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall///
2299aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall/// The member access may be explicit or implicit:
2300aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall///    struct A {
2301aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall///      int a, b;
2302aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall///      int explicitAccess() { return this->a + this->A::b; }
2303aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall///      int implicitAccess() { return a + A::b; }
2304aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall///    };
2305aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall///
2306aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall/// In the final AST, an explicit access always becomes a MemberExpr.
2307aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall/// An implicit access may become either a MemberExpr or a
2308aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall/// DeclRefExpr, depending on whether the member is static.
23097bb12da2b0749eeebb21854c77877736969e59f2John McCallclass UnresolvedMemberExpr : public OverloadExpr {
2310129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// \brief Whether this member expression used the '->' operator or
2311129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// the '.' operator.
2312129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  bool IsArrow : 1;
2313129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall
2314129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// \brief Whether the lookup results contain an unresolved using
2315129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// declaration.
2316129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  bool HasUnresolvedUsing : 1;
2317129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall
23187bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// \brief The expression for the base pointer or class reference,
23197bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// e.g., the \c x in x.f.  This can be null if this is an 'unbased'
23207bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// member expression
23217bb12da2b0749eeebb21854c77877736969e59f2John McCall  Stmt *Base;
23227bb12da2b0749eeebb21854c77877736969e59f2John McCall
23237bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// \brief The type of the base expression;  never null.
23247bb12da2b0749eeebb21854c77877736969e59f2John McCall  QualType BaseType;
2325129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall
2326129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// \brief The location of the '->' or '.' operator.
2327129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  SourceLocation OperatorLoc;
2328129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall
2329928e6fcf66fc4f342bcf7cc96bf56986c9c2a833Douglas Gregor  UnresolvedMemberExpr(ASTContext &C, QualType T, bool Dependent,
2330129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall                       bool HasUnresolvedUsing,
2331aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall                       Expr *Base, QualType BaseType, bool IsArrow,
2332129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall                       SourceLocation OperatorLoc,
2333129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall                       NestedNameSpecifier *Qualifier,
2334129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall                       SourceRange QualifierRange,
23352577743c5650c646fb705df01403707e94f2df04Abramo Bagnara                       const DeclarationNameInfo &MemberNameInfo,
23365a84dec38cfa9e084377a3167b474c79283c82faDouglas Gregor                       const TemplateArgumentListInfo *TemplateArgs,
23375a84dec38cfa9e084377a3167b474c79283c82faDouglas Gregor                       UnresolvedSetIterator Begin, UnresolvedSetIterator End);
2338a77eb0862507b900a10fa352af1568e639ed10b1Argyrios Kyrtzidis
2339a77eb0862507b900a10fa352af1568e639ed10b1Argyrios Kyrtzidis  UnresolvedMemberExpr(EmptyShell Empty)
2340a77eb0862507b900a10fa352af1568e639ed10b1Argyrios Kyrtzidis    : OverloadExpr(UnresolvedMemberExprClass, Empty), IsArrow(false),
2341a77eb0862507b900a10fa352af1568e639ed10b1Argyrios Kyrtzidis      HasUnresolvedUsing(false), Base(0) { }
2342129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall
2343129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCallpublic:
2344129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  static UnresolvedMemberExpr *
2345129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  Create(ASTContext &C, bool Dependent, bool HasUnresolvedUsing,
2346aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall         Expr *Base, QualType BaseType, bool IsArrow,
2347129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall         SourceLocation OperatorLoc,
2348129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall         NestedNameSpecifier *Qualifier,
2349129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall         SourceRange QualifierRange,
23502577743c5650c646fb705df01403707e94f2df04Abramo Bagnara         const DeclarationNameInfo &MemberNameInfo,
23515a84dec38cfa9e084377a3167b474c79283c82faDouglas Gregor         const TemplateArgumentListInfo *TemplateArgs,
23525a84dec38cfa9e084377a3167b474c79283c82faDouglas Gregor         UnresolvedSetIterator Begin, UnresolvedSetIterator End);
2353129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall
2354a77eb0862507b900a10fa352af1568e639ed10b1Argyrios Kyrtzidis  static UnresolvedMemberExpr *
2355a77eb0862507b900a10fa352af1568e639ed10b1Argyrios Kyrtzidis  CreateEmpty(ASTContext &C, unsigned NumTemplateArgs);
2356a77eb0862507b900a10fa352af1568e639ed10b1Argyrios Kyrtzidis
2357aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall  /// \brief True if this is an implicit access, i.e. one in which the
2358aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall  /// member being accessed was not written in the source.  The source
2359aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall  /// location of the operator is invalid in this case.
2360aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall  bool isImplicitAccess() const { return Base == 0; }
2361aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall
2362129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// \brief Retrieve the base object of this member expressions,
2363129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// e.g., the \c x in \c x.m.
2364aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall  Expr *getBase() {
2365aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall    assert(!isImplicitAccess());
2366aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall    return cast<Expr>(Base);
2367aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall  }
23682f27bf854f0519810b34afd209089cc75536b757John McCall  const Expr *getBase() const {
23692f27bf854f0519810b34afd209089cc75536b757John McCall    assert(!isImplicitAccess());
23702f27bf854f0519810b34afd209089cc75536b757John McCall    return cast<Expr>(Base);
23712f27bf854f0519810b34afd209089cc75536b757John McCall  }
2372129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  void setBase(Expr *E) { Base = E; }
2373129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall
2374aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall  QualType getBaseType() const { return BaseType; }
2375a77eb0862507b900a10fa352af1568e639ed10b1Argyrios Kyrtzidis  void setBaseType(QualType T) { BaseType = T; }
2376a77eb0862507b900a10fa352af1568e639ed10b1Argyrios Kyrtzidis
2377a77eb0862507b900a10fa352af1568e639ed10b1Argyrios Kyrtzidis  /// \brief Determine whether the lookup results contain an unresolved using
2378a77eb0862507b900a10fa352af1568e639ed10b1Argyrios Kyrtzidis  /// declaration.
2379a77eb0862507b900a10fa352af1568e639ed10b1Argyrios Kyrtzidis  bool hasUnresolvedUsing() const { return HasUnresolvedUsing; }
2380a77eb0862507b900a10fa352af1568e639ed10b1Argyrios Kyrtzidis  void setHasUnresolvedUsing(bool V) { HasUnresolvedUsing = V; }
2381aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall
2382129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// \brief Determine whether this member expression used the '->'
2383129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// operator; otherwise, it used the '.' operator.
2384129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  bool isArrow() const { return IsArrow; }
2385129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  void setArrow(bool A) { IsArrow = A; }
2386129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall
2387129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// \brief Retrieve the location of the '->' or '.' operator.
2388129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  SourceLocation getOperatorLoc() const { return OperatorLoc; }
2389129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  void setOperatorLoc(SourceLocation L) { OperatorLoc = L; }
2390129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall
2391c373d48502ca7683ab55385f5bd624d778eb288dJohn McCall  /// \brief Retrieves the naming class of this lookup.
2392c373d48502ca7683ab55385f5bd624d778eb288dJohn McCall  CXXRecordDecl *getNamingClass() const;
2393c373d48502ca7683ab55385f5bd624d778eb288dJohn McCall
23942577743c5650c646fb705df01403707e94f2df04Abramo Bagnara  /// \brief Retrieve the full name info for the member that this expression
23952577743c5650c646fb705df01403707e94f2df04Abramo Bagnara  /// refers to.
23962577743c5650c646fb705df01403707e94f2df04Abramo Bagnara  const DeclarationNameInfo &getMemberNameInfo() const { return getNameInfo(); }
23972577743c5650c646fb705df01403707e94f2df04Abramo Bagnara  void setMemberNameInfo(const DeclarationNameInfo &N) { setNameInfo(N); }
23982577743c5650c646fb705df01403707e94f2df04Abramo Bagnara
2399129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// \brief Retrieve the name of the member that this expression
2400129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// refers to.
24017bb12da2b0749eeebb21854c77877736969e59f2John McCall  DeclarationName getMemberName() const { return getName(); }
24027bb12da2b0749eeebb21854c77877736969e59f2John McCall  void setMemberName(DeclarationName N) { setName(N); }
2403129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall
2404129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  // \brief Retrieve the location of the name of the member that this
2405129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  // expression refers to.
24067bb12da2b0749eeebb21854c77877736969e59f2John McCall  SourceLocation getMemberLoc() const { return getNameLoc(); }
24077bb12da2b0749eeebb21854c77877736969e59f2John McCall  void setMemberLoc(SourceLocation L) { setNameLoc(L); }
2408129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall
24097bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// \brief Retrieve the explicit template argument list that followed the
24107bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// member template name.
24117bb12da2b0749eeebb21854c77877736969e59f2John McCall  ExplicitTemplateArgumentList &getExplicitTemplateArgs() {
24127bb12da2b0749eeebb21854c77877736969e59f2John McCall    assert(hasExplicitTemplateArgs());
24137bb12da2b0749eeebb21854c77877736969e59f2John McCall    return *reinterpret_cast<ExplicitTemplateArgumentList *>(this + 1);
24147bb12da2b0749eeebb21854c77877736969e59f2John McCall  }
24157bb12da2b0749eeebb21854c77877736969e59f2John McCall
24167bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// \brief Retrieve the explicit template argument list that followed the
24177bb12da2b0749eeebb21854c77877736969e59f2John McCall  /// member template name, if any.
24187bb12da2b0749eeebb21854c77877736969e59f2John McCall  const ExplicitTemplateArgumentList &getExplicitTemplateArgs() const {
24197bb12da2b0749eeebb21854c77877736969e59f2John McCall    assert(hasExplicitTemplateArgs());
24207bb12da2b0749eeebb21854c77877736969e59f2John McCall    return *reinterpret_cast<const ExplicitTemplateArgumentList *>(this + 1);
2421129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  }
2422129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall
2423096832c5ed5b9106fa177ebc148489760c3bc496John McCall  /// \brief Retrieves the optional explicit template arguments.
2424096832c5ed5b9106fa177ebc148489760c3bc496John McCall  /// This points to the same data as getExplicitTemplateArgs(), but
2425096832c5ed5b9106fa177ebc148489760c3bc496John McCall  /// returns null if there are no explicit template arguments.
2426096832c5ed5b9106fa177ebc148489760c3bc496John McCall  const ExplicitTemplateArgumentList *getOptionalExplicitTemplateArgs() {
2427096832c5ed5b9106fa177ebc148489760c3bc496John McCall    if (!hasExplicitTemplateArgs()) return 0;
2428096832c5ed5b9106fa177ebc148489760c3bc496John McCall    return &getExplicitTemplateArgs();
2429096832c5ed5b9106fa177ebc148489760c3bc496John McCall  }
2430096832c5ed5b9106fa177ebc148489760c3bc496John McCall
2431129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// \brief Copies the template arguments into the given structure.
2432129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  void copyTemplateArgumentsInto(TemplateArgumentListInfo &List) const {
24337bb12da2b0749eeebb21854c77877736969e59f2John McCall    getExplicitTemplateArgs().copyInto(List);
2434129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  }
2435129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall
2436129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// \brief Retrieve the location of the left angle bracket following
2437129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// the member name ('<').
2438129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  SourceLocation getLAngleLoc() const {
24397bb12da2b0749eeebb21854c77877736969e59f2John McCall    return getExplicitTemplateArgs().LAngleLoc;
2440129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  }
2441129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall
2442129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// \brief Retrieve the template arguments provided as part of this
2443129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// template-id.
2444129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  const TemplateArgumentLoc *getTemplateArgs() const {
24457bb12da2b0749eeebb21854c77877736969e59f2John McCall    return getExplicitTemplateArgs().getTemplateArgs();
2446129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  }
2447129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall
2448129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// \brief Retrieve the number of template arguments provided as
2449129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// part of this template-id.
2450129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  unsigned getNumTemplateArgs() const {
24517bb12da2b0749eeebb21854c77877736969e59f2John McCall    return getExplicitTemplateArgs().NumTemplateArgs;
2452129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  }
2453129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall
2454129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// \brief Retrieve the location of the right angle bracket
2455129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  /// following the template arguments ('>').
2456129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  SourceLocation getRAngleLoc() const {
24577bb12da2b0749eeebb21854c77877736969e59f2John McCall    return getExplicitTemplateArgs().RAngleLoc;
2458129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  }
2459129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall
2460129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  virtual SourceRange getSourceRange() const {
24612577743c5650c646fb705df01403707e94f2df04Abramo Bagnara    SourceRange Range = getMemberNameInfo().getSourceRange();
2462aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall    if (!isImplicitAccess())
2463aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall      Range.setBegin(Base->getSourceRange().getBegin());
2464aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall    else if (getQualifier())
2465aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall      Range.setBegin(getQualifierRange().getBegin());
2466aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall
2467129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall    if (hasExplicitTemplateArgs())
2468129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall      Range.setEnd(getRAngleLoc());
2469129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall    return Range;
2470129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  }
2471129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall
2472129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  static bool classof(const Stmt *T) {
2473129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall    return T->getStmtClass() == UnresolvedMemberExprClass;
2474129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  }
2475129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  static bool classof(const UnresolvedMemberExpr *) { return true; }
2476129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall
2477129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  // Iterators
2478129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  virtual child_iterator child_begin();
2479129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall  virtual child_iterator child_end();
2480129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall};
2481129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall
24822e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl/// \brief Represents a C++0x noexcept expression (C++ [expr.unary.noexcept]).
24832e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl///
24842e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl/// The noexcept expression tests whether a given expression might throw. Its
24852e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl/// result is a boolean constant.
24862e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redlclass CXXNoexceptExpr : public Expr {
24872e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl  bool Value : 1;
24882e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl  Stmt *Operand;
24892e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl  SourceRange Range;
24902e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl
2491c8aecc2dfb2e393d9eeaedeca22ff8cd7149af81Sebastian Redl  friend class ASTStmtReader;
2492c8aecc2dfb2e393d9eeaedeca22ff8cd7149af81Sebastian Redl
24932e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redlpublic:
24942e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl  CXXNoexceptExpr(QualType Ty, Expr *Operand, CanThrowResult Val,
24952e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl                  SourceLocation Keyword, SourceLocation RParen)
2496f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall    : Expr(CXXNoexceptExprClass, Ty, VK_RValue, OK_Ordinary,
2497f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall           /*TypeDependent*/false,
24986b219d082434394c1ac401390ec1d1967727815aSebastian Redl           /*ValueDependent*/Val == CT_Dependent),
24996b219d082434394c1ac401390ec1d1967727815aSebastian Redl      Value(Val == CT_Cannot), Operand(Operand), Range(Keyword, RParen)
25006b219d082434394c1ac401390ec1d1967727815aSebastian Redl  { }
25016b219d082434394c1ac401390ec1d1967727815aSebastian Redl
25026b219d082434394c1ac401390ec1d1967727815aSebastian Redl  CXXNoexceptExpr(EmptyShell Empty)
25036b219d082434394c1ac401390ec1d1967727815aSebastian Redl    : Expr(CXXNoexceptExprClass, Empty)
25042e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl  { }
25052e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl
25062e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl  Expr *getOperand() const { return static_cast<Expr*>(Operand); }
25072e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl
25082e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl  virtual SourceRange getSourceRange() const { return Range; }
25092e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl
25102e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl  bool getValue() const { return Value; }
25112e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl
25122e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl  static bool classof(const Stmt *T) {
25132e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl    return T->getStmtClass() == CXXNoexceptExprClass;
25142e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl  }
25152e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl  static bool classof(const CXXNoexceptExpr *) { return true; }
25162e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl
25172e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl  // Iterators
25182e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl  virtual child_iterator child_begin();
25192e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl  virtual child_iterator child_end();
25202e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl};
25212e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl
25227bb12da2b0749eeebb21854c77877736969e59f2John McCallinline ExplicitTemplateArgumentList &OverloadExpr::getExplicitTemplateArgs() {
25237bb12da2b0749eeebb21854c77877736969e59f2John McCall  if (isa<UnresolvedLookupExpr>(this))
25247bb12da2b0749eeebb21854c77877736969e59f2John McCall    return cast<UnresolvedLookupExpr>(this)->getExplicitTemplateArgs();
25257bb12da2b0749eeebb21854c77877736969e59f2John McCall  else
25267bb12da2b0749eeebb21854c77877736969e59f2John McCall    return cast<UnresolvedMemberExpr>(this)->getExplicitTemplateArgs();
25277bb12da2b0749eeebb21854c77877736969e59f2John McCall}
25287bb12da2b0749eeebb21854c77877736969e59f2John McCall
25295f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer}  // end namespace clang
25305f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer
25315f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer#endif
2532