ExprCXX.h revision 1bb2a93ab7b1499dda6f6b58865bd0dce1864228
15f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer//===--- ExprCXX.h - Classes for representing expressions -------*- C++ -*-===// 25f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer// 35f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer// The LLVM Compiler Infrastructure 45f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer// 50bc735ffcfb223c0186419547abaa5c84482663eChris Lattner// This file is distributed under the University of Illinois Open Source 60bc735ffcfb223c0186419547abaa5c84482663eChris Lattner// License. See LICENSE.TXT for details. 75f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer// 85f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer//===----------------------------------------------------------------------===// 95f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer// 105f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer// This file defines the Expr interface and subclasses for C++ expressions. 115f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer// 125f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer//===----------------------------------------------------------------------===// 135f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 145f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer#ifndef LLVM_CLANG_AST_EXPRCXX_H 155f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer#define LLVM_CLANG_AST_EXPRCXX_H 165f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 1764b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl#include "clang/Basic/TypeTraits.h" 185f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer#include "clang/AST/Expr.h" 19eec51cf1ba5f0e62c9cdb81b5c63babdd6e649abJohn McCall#include "clang/AST/UnresolvedSet.h" 20d5532b6cfff2977e0c59fa6ead7f7973984a620dJohn McCall#include "clang/AST/TemplateBase.h" 215f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 225f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencernamespace clang { 235f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 244c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl class CXXConstructorDecl; 25c1ce477119fed070299668aab24084b17ff5f14bAnders Carlsson class CXXDestructorDecl; 26e9f42087aabfdb6b2afc35c7e38ac65da063b409Fariborz Jahanian class CXXMethodDecl; 27ff6b3d64c9f07155f1414411b8451d7bf8937c62Anders Carlsson class CXXTemporary; 28d5532b6cfff2977e0c59fa6ead7f7973984a620dJohn McCall class TemplateArgumentListInfo; 294c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 301060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek//===--------------------------------------------------------------------===// 311060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek// C++ Expressions. 321060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek//===--------------------------------------------------------------------===// 331060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek 343fd95ce225393fe4a3623e429766a8c3f487ff9dDouglas Gregor/// \brief A call to an overloaded operator written using operator 353fd95ce225393fe4a3623e429766a8c3f487ff9dDouglas Gregor/// syntax. 363fd95ce225393fe4a3623e429766a8c3f487ff9dDouglas Gregor/// 373fd95ce225393fe4a3623e429766a8c3f487ff9dDouglas Gregor/// Represents a call to an overloaded operator written using operator 383fd95ce225393fe4a3623e429766a8c3f487ff9dDouglas Gregor/// syntax, e.g., "x + y" or "*p". While semantically equivalent to a 393fd95ce225393fe4a3623e429766a8c3f487ff9dDouglas Gregor/// normal call, this AST node provides better information about the 403fd95ce225393fe4a3623e429766a8c3f487ff9dDouglas Gregor/// syntactic representation of the call. 413fd95ce225393fe4a3623e429766a8c3f487ff9dDouglas Gregor/// 423fd95ce225393fe4a3623e429766a8c3f487ff9dDouglas Gregor/// In a C++ template, this expression node kind will be used whenever 433fd95ce225393fe4a3623e429766a8c3f487ff9dDouglas Gregor/// any of the arguments are type-dependent. In this case, the 443fd95ce225393fe4a3623e429766a8c3f487ff9dDouglas Gregor/// function itself will be a (possibly empty) set of functions and 453fd95ce225393fe4a3623e429766a8c3f487ff9dDouglas Gregor/// function templates that were found by name lookup at template 463fd95ce225393fe4a3623e429766a8c3f487ff9dDouglas Gregor/// definition time. 47b4609806e9232593ece09ce08b630836e825865cDouglas Gregorclass CXXOperatorCallExpr : public CallExpr { 48063daf6e196c51f162e0485478355d8e280eef5cDouglas Gregor /// \brief The overloaded operator. 49063daf6e196c51f162e0485478355d8e280eef5cDouglas Gregor OverloadedOperatorKind Operator; 50063daf6e196c51f162e0485478355d8e280eef5cDouglas Gregor 51b4609806e9232593ece09ce08b630836e825865cDouglas Gregorpublic: 521eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump CXXOperatorCallExpr(ASTContext& C, OverloadedOperatorKind Op, Expr *fn, 531eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump Expr **args, unsigned numargs, QualType t, 54063daf6e196c51f162e0485478355d8e280eef5cDouglas Gregor SourceLocation operatorloc) 55063daf6e196c51f162e0485478355d8e280eef5cDouglas Gregor : CallExpr(C, CXXOperatorCallExprClass, fn, args, numargs, t, operatorloc), 56063daf6e196c51f162e0485478355d8e280eef5cDouglas Gregor Operator(Op) {} 571eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump explicit CXXOperatorCallExpr(ASTContext& C, EmptyShell Empty) : 58ba0a9006dbc4814e1e35f82812cb5a1dad65e8b8Argyrios Kyrtzidis CallExpr(C, CXXOperatorCallExprClass, Empty) { } 591eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 60b4609806e9232593ece09ce08b630836e825865cDouglas Gregor 61b4609806e9232593ece09ce08b630836e825865cDouglas Gregor /// getOperator - Returns the kind of overloaded operator that this 62b4609806e9232593ece09ce08b630836e825865cDouglas Gregor /// expression refers to. 63063daf6e196c51f162e0485478355d8e280eef5cDouglas Gregor OverloadedOperatorKind getOperator() const { return Operator; } 64ba0a9006dbc4814e1e35f82812cb5a1dad65e8b8Argyrios Kyrtzidis void setOperator(OverloadedOperatorKind Kind) { Operator = Kind; } 65b4609806e9232593ece09ce08b630836e825865cDouglas Gregor 66b4609806e9232593ece09ce08b630836e825865cDouglas Gregor /// getOperatorLoc - Returns the location of the operator symbol in 67b4609806e9232593ece09ce08b630836e825865cDouglas Gregor /// the expression. When @c getOperator()==OO_Call, this is the 68b4609806e9232593ece09ce08b630836e825865cDouglas Gregor /// location of the right parentheses; when @c 69b4609806e9232593ece09ce08b630836e825865cDouglas Gregor /// getOperator()==OO_Subscript, this is the location of the right 70b4609806e9232593ece09ce08b630836e825865cDouglas Gregor /// bracket. 71b4609806e9232593ece09ce08b630836e825865cDouglas Gregor SourceLocation getOperatorLoc() const { return getRParenLoc(); } 72b4609806e9232593ece09ce08b630836e825865cDouglas Gregor 73b4609806e9232593ece09ce08b630836e825865cDouglas Gregor virtual SourceRange getSourceRange() const; 741eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 751eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump static bool classof(const Stmt *T) { 761eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump return T->getStmtClass() == CXXOperatorCallExprClass; 77b4609806e9232593ece09ce08b630836e825865cDouglas Gregor } 78b4609806e9232593ece09ce08b630836e825865cDouglas Gregor static bool classof(const CXXOperatorCallExpr *) { return true; } 79b4609806e9232593ece09ce08b630836e825865cDouglas Gregor}; 80b4609806e9232593ece09ce08b630836e825865cDouglas Gregor 8188a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor/// CXXMemberCallExpr - Represents a call to a member function that 8288a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor/// may be written either with member call syntax (e.g., "obj.func()" 8388a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor/// or "objptr->func()") or with normal function-call syntax 8488a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor/// ("func()") within a member function that ends up calling a member 8588a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor/// function. The callee in either case is a MemberExpr that contains 8688a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor/// both the object argument and the member function, while the 8788a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor/// arguments are the arguments within the parentheses (not including 8888a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor/// the object argument). 8988a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregorclass CXXMemberCallExpr : public CallExpr { 9088a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregorpublic: 911817bd483b538fd3f4530649f5cb900bad9e8a76Chris Lattner CXXMemberCallExpr(ASTContext &C, Expr *fn, Expr **args, unsigned numargs, 92668bf91d31265b6ea8c3eb854ba450857701f269Ted Kremenek QualType t, SourceLocation rparenloc) 93668bf91d31265b6ea8c3eb854ba450857701f269Ted Kremenek : CallExpr(C, CXXMemberCallExprClass, fn, args, numargs, t, rparenloc) {} 9488a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor 951817bd483b538fd3f4530649f5cb900bad9e8a76Chris Lattner CXXMemberCallExpr(ASTContext &C, EmptyShell Empty) 961817bd483b538fd3f4530649f5cb900bad9e8a76Chris Lattner : CallExpr(C, CXXMemberCallExprClass, Empty) { } 971817bd483b538fd3f4530649f5cb900bad9e8a76Chris Lattner 9888a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor /// getImplicitObjectArgument - Retrieves the implicit object 9988a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor /// argument for the member call. For example, in "x.f(5)", this 10088a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor /// operation would return "x". 10188a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor Expr *getImplicitObjectArgument(); 10288a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor 10300b98c229ef28a5e82943bb23d09fb46d24ca381Douglas Gregor virtual SourceRange getSourceRange() const; 10400b98c229ef28a5e82943bb23d09fb46d24ca381Douglas Gregor 1051eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump static bool classof(const Stmt *T) { 10688a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor return T->getStmtClass() == CXXMemberCallExprClass; 10788a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor } 10888a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor static bool classof(const CXXMemberCallExpr *) { return true; } 10988a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor}; 11088a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor 11149badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// CXXNamedCastExpr - Abstract class common to all of the C++ "named" 11249badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// casts, @c static_cast, @c dynamic_cast, @c reinterpret_cast, or @c 11349badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// const_cast. 11449badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// 11549badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// This abstract class is inherited by all of the classes 11649badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// representing "named" casts, e.g., CXXStaticCastExpr, 11749badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// CXXDynamicCastExpr, CXXReinterpretCastExpr, and CXXConstCastExpr. 11849badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregorclass CXXNamedCastExpr : public ExplicitCastExpr { 1191060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenekprivate: 1201060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek SourceLocation Loc; // the location of the casting op 12149badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor 12249badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregorprotected: 123c0a2fd8f092722c8f78b566ac4506a21437040e9Anders Carlsson CXXNamedCastExpr(StmtClass SC, QualType ty, CastKind kind, Expr *op, 124f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall unsigned PathSize, TypeSourceInfo *writtenTy, 12541b2dcd465f1e438502c420effc9d0c747f9db8fAnders Carlsson SourceLocation l) 126f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall : ExplicitCastExpr(SC, ty, kind, op, PathSize, writtenTy), Loc(l) {} 12749badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor 128f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall explicit CXXNamedCastExpr(StmtClass SC, EmptyShell Shell, unsigned PathSize) 129f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall : ExplicitCastExpr(SC, Shell, PathSize) { } 130ce757a7a1ee905f87551996a69da3e95e8afeeb7Sam Weinig 1311060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenekpublic: 13249badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor const char *getCastName() const; 13349badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor 134a3a7b8eea87c90a5a257f685749222b212ddaf36Douglas Gregor /// \brief Retrieve the location of the cast operator keyword, e.g., 135a3a7b8eea87c90a5a257f685749222b212ddaf36Douglas Gregor /// "static_cast". 136a3a7b8eea87c90a5a257f685749222b212ddaf36Douglas Gregor SourceLocation getOperatorLoc() const { return Loc; } 137a3a7b8eea87c90a5a257f685749222b212ddaf36Douglas Gregor void setOperatorLoc(SourceLocation L) { Loc = L; } 138a3a7b8eea87c90a5a257f685749222b212ddaf36Douglas Gregor 1391060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek virtual SourceRange getSourceRange() const { 1401060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek return SourceRange(Loc, getSubExpr()->getSourceRange().getEnd()); 1411060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek } 1421eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump static bool classof(const Stmt *T) { 14349badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor switch (T->getStmtClass()) { 14449badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor case CXXStaticCastExprClass: 14549badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor case CXXDynamicCastExprClass: 14649badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor case CXXReinterpretCastExprClass: 14749badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor case CXXConstCastExprClass: 14849badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor return true; 14949badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor default: 15049badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor return false; 15149badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor } 1521060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek } 15349badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor static bool classof(const CXXNamedCastExpr *) { return true; } 15449badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor}; 15549badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor 15649badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// CXXStaticCastExpr - A C++ @c static_cast expression (C++ [expr.static.cast]). 1571eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump/// 15849badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// This expression node represents a C++ static cast, e.g., 15949badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// @c static_cast<int>(1.0). 16049badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregorclass CXXStaticCastExpr : public CXXNamedCastExpr { 16141b2dcd465f1e438502c420effc9d0c747f9db8fAnders Carlsson CXXStaticCastExpr(QualType ty, CastKind kind, Expr *op, 162f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall unsigned pathSize, TypeSourceInfo *writtenTy, 16341b2dcd465f1e438502c420effc9d0c747f9db8fAnders Carlsson SourceLocation l) 164f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall : CXXNamedCastExpr(CXXStaticCastExprClass, ty, kind, op, pathSize, 165f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall writtenTy, l) {} 16649badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor 167f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall explicit CXXStaticCastExpr(EmptyShell Empty, unsigned PathSize) 168f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall : CXXNamedCastExpr(CXXStaticCastExprClass, Empty, PathSize) { } 169f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall 170f871d0cc377a1367b519a6cce26be74607566ebaJohn McCallpublic: 171f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall static CXXStaticCastExpr *Create(ASTContext &Context, QualType T, 172f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall CastKind K, Expr *Op, 173f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall const CXXCastPath *Path, 174f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall TypeSourceInfo *Written, SourceLocation L); 175f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall static CXXStaticCastExpr *CreateEmpty(ASTContext &Context, 176f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall unsigned PathSize); 177ce757a7a1ee905f87551996a69da3e95e8afeeb7Sam Weinig 1781eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump static bool classof(const Stmt *T) { 17949badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor return T->getStmtClass() == CXXStaticCastExprClass; 18049badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor } 18149badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor static bool classof(const CXXStaticCastExpr *) { return true; } 18249badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor}; 18349badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor 18449badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// CXXDynamicCastExpr - A C++ @c dynamic_cast expression 1851eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump/// (C++ [expr.dynamic.cast]), which may perform a run-time check to 18649badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// determine how to perform the type cast. 1871eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump/// 18849badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// This expression node represents a dynamic cast, e.g., 18949badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// @c dynamic_cast<Derived*>(BasePtr). 19049badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregorclass CXXDynamicCastExpr : public CXXNamedCastExpr { 19141b2dcd465f1e438502c420effc9d0c747f9db8fAnders Carlsson CXXDynamicCastExpr(QualType ty, CastKind kind, Expr *op, 192f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall unsigned pathSize, TypeSourceInfo *writtenTy, 19341b2dcd465f1e438502c420effc9d0c747f9db8fAnders Carlsson SourceLocation l) 194f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall : CXXNamedCastExpr(CXXDynamicCastExprClass, ty, kind, op, pathSize, 19541b2dcd465f1e438502c420effc9d0c747f9db8fAnders Carlsson writtenTy, l) {} 19649badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor 197f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall explicit CXXDynamicCastExpr(EmptyShell Empty, unsigned pathSize) 198f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall : CXXNamedCastExpr(CXXDynamicCastExprClass, Empty, pathSize) { } 199f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall 200f871d0cc377a1367b519a6cce26be74607566ebaJohn McCallpublic: 201f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall static CXXDynamicCastExpr *Create(ASTContext &Context, QualType T, 202f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall CastKind Kind, Expr *Op, 203f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall const CXXCastPath *Path, 204f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall TypeSourceInfo *Written, SourceLocation L); 205f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall 206f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall static CXXDynamicCastExpr *CreateEmpty(ASTContext &Context, 207f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall unsigned pathSize); 208ce757a7a1ee905f87551996a69da3e95e8afeeb7Sam Weinig 2091eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump static bool classof(const Stmt *T) { 21049badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor return T->getStmtClass() == CXXDynamicCastExprClass; 21149badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor } 21249badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor static bool classof(const CXXDynamicCastExpr *) { return true; } 21349badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor}; 21449badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor 21549badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// CXXReinterpretCastExpr - A C++ @c reinterpret_cast expression (C++ 21649badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// [expr.reinterpret.cast]), which provides a differently-typed view 21749badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// of a value but performs no actual work at run time. 2181eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump/// 21949badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// This expression node represents a reinterpret cast, e.g., 22049badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// @c reinterpret_cast<int>(VoidPtr). 22149badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregorclass CXXReinterpretCastExpr : public CXXNamedCastExpr { 2227f9e646b7ed47bc8e9a60031ad0c2b55031e2077Anders Carlsson CXXReinterpretCastExpr(QualType ty, CastKind kind, Expr *op, 223f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall unsigned pathSize, 2249d125033a9853f3b572a4c9e2f9e2d4e5e346973John McCall TypeSourceInfo *writtenTy, SourceLocation l) 225f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall : CXXNamedCastExpr(CXXReinterpretCastExprClass, ty, kind, op, pathSize, 226cdef2b75aa60cde1ca00e0aa3f89139ac89c6ae4Anders Carlsson writtenTy, l) {} 22749badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor 228f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall CXXReinterpretCastExpr(EmptyShell Empty, unsigned pathSize) 229f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall : CXXNamedCastExpr(CXXReinterpretCastExprClass, Empty, pathSize) { } 230f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall 231f871d0cc377a1367b519a6cce26be74607566ebaJohn McCallpublic: 232f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall static CXXReinterpretCastExpr *Create(ASTContext &Context, QualType T, 233f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall CastKind Kind, Expr *Op, 234f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall const CXXCastPath *Path, 235f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall TypeSourceInfo *WrittenTy, SourceLocation L); 236f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall static CXXReinterpretCastExpr *CreateEmpty(ASTContext &Context, 237f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall unsigned pathSize); 238ce757a7a1ee905f87551996a69da3e95e8afeeb7Sam Weinig 2391eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump static bool classof(const Stmt *T) { 24049badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor return T->getStmtClass() == CXXReinterpretCastExprClass; 24149badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor } 24249badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor static bool classof(const CXXReinterpretCastExpr *) { return true; } 24349badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor}; 24449badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor 24549badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// CXXConstCastExpr - A C++ @c const_cast expression (C++ [expr.const.cast]), 24649badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// which can remove type qualifiers but does not change the underlying value. 2471eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump/// 24849badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// This expression node represents a const cast, e.g., 24949badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// @c const_cast<char*>(PtrToConstChar). 25049badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregorclass CXXConstCastExpr : public CXXNamedCastExpr { 2519d125033a9853f3b572a4c9e2f9e2d4e5e346973John McCall CXXConstCastExpr(QualType ty, Expr *op, TypeSourceInfo *writtenTy, 25249badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor SourceLocation l) 25341b2dcd465f1e438502c420effc9d0c747f9db8fAnders Carlsson : CXXNamedCastExpr(CXXConstCastExprClass, ty, CK_NoOp, op, 254f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall 0, writtenTy, l) {} 25549badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor 256ce757a7a1ee905f87551996a69da3e95e8afeeb7Sam Weinig explicit CXXConstCastExpr(EmptyShell Empty) 257f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall : CXXNamedCastExpr(CXXConstCastExprClass, Empty, 0) { } 258f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall 259f871d0cc377a1367b519a6cce26be74607566ebaJohn McCallpublic: 260f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall static CXXConstCastExpr *Create(ASTContext &Context, QualType T, Expr *Op, 261f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall TypeSourceInfo *WrittenTy, SourceLocation L); 262f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall static CXXConstCastExpr *CreateEmpty(ASTContext &Context); 263ce757a7a1ee905f87551996a69da3e95e8afeeb7Sam Weinig 2641eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump static bool classof(const Stmt *T) { 26549badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor return T->getStmtClass() == CXXConstCastExprClass; 26649badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor } 26749badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor static bool classof(const CXXConstCastExpr *) { return true; } 2681060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek}; 2691060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek 2701060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek/// CXXBoolLiteralExpr - [C++ 2.13.5] C++ Boolean Literal. 2711eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump/// 2721060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenekclass CXXBoolLiteralExpr : public Expr { 2731060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek bool Value; 2741060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek SourceLocation Loc; 2751060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenekpublic: 2761eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump CXXBoolLiteralExpr(bool val, QualType Ty, SourceLocation l) : 2772333f7727f97018d6742e1e0938133bcfad967abEli Friedman Expr(CXXBoolLiteralExprClass, Ty, false, false), Value(val), Loc(l) {} 2788b0b475b3464b0f70b91ba7d679d23c424677d5eSebastian Redl 279eb7f96141f754150a92433286fa385910a22f494Sam Weinig explicit CXXBoolLiteralExpr(EmptyShell Empty) 280eb7f96141f754150a92433286fa385910a22f494Sam Weinig : Expr(CXXBoolLiteralExprClass, Empty) { } 281eb7f96141f754150a92433286fa385910a22f494Sam Weinig 2821060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek bool getValue() const { return Value; } 283eb7f96141f754150a92433286fa385910a22f494Sam Weinig void setValue(bool V) { Value = V; } 2845f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 2851060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek virtual SourceRange getSourceRange() const { return SourceRange(Loc); } 2861eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 287eb7f96141f754150a92433286fa385910a22f494Sam Weinig SourceLocation getLocation() const { return Loc; } 288eb7f96141f754150a92433286fa385910a22f494Sam Weinig void setLocation(SourceLocation L) { Loc = L; } 289eb7f96141f754150a92433286fa385910a22f494Sam Weinig 2901eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump static bool classof(const Stmt *T) { 2911060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek return T->getStmtClass() == CXXBoolLiteralExprClass; 2921060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek } 2931060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek static bool classof(const CXXBoolLiteralExpr *) { return true; } 2941eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 2951060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek // Iterators 2961060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek virtual child_iterator child_begin(); 2971060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek virtual child_iterator child_end(); 2981060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek}; 2991060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek 3006e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl/// CXXNullPtrLiteralExpr - [C++0x 2.14.7] C++ Pointer Literal 3016e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redlclass CXXNullPtrLiteralExpr : public Expr { 3026e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl SourceLocation Loc; 3036e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redlpublic: 3046e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl CXXNullPtrLiteralExpr(QualType Ty, SourceLocation l) : 3052333f7727f97018d6742e1e0938133bcfad967abEli Friedman Expr(CXXNullPtrLiteralExprClass, Ty, false, false), Loc(l) {} 3066e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl 307eb7f96141f754150a92433286fa385910a22f494Sam Weinig explicit CXXNullPtrLiteralExpr(EmptyShell Empty) 308eb7f96141f754150a92433286fa385910a22f494Sam Weinig : Expr(CXXNullPtrLiteralExprClass, Empty) { } 309eb7f96141f754150a92433286fa385910a22f494Sam Weinig 3106e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl virtual SourceRange getSourceRange() const { return SourceRange(Loc); } 3116e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl 312eb7f96141f754150a92433286fa385910a22f494Sam Weinig SourceLocation getLocation() const { return Loc; } 313eb7f96141f754150a92433286fa385910a22f494Sam Weinig void setLocation(SourceLocation L) { Loc = L; } 314eb7f96141f754150a92433286fa385910a22f494Sam Weinig 3156e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl static bool classof(const Stmt *T) { 3166e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl return T->getStmtClass() == CXXNullPtrLiteralExprClass; 3176e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl } 3186e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl static bool classof(const CXXNullPtrLiteralExpr *) { return true; } 3196e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl 3206e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl virtual child_iterator child_begin(); 3216e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl virtual child_iterator child_end(); 3226e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl}; 3236e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl 324c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl/// CXXTypeidExpr - A C++ @c typeid expression (C++ [expr.typeid]), which gets 325c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl/// the type_info that corresponds to the supplied type, or the (possibly 326c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl/// dynamic) type of the supplied expression. 327c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl/// 328c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl/// This represents code like @c typeid(int) or @c typeid(*objPtr) 329c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redlclass CXXTypeidExpr : public Expr { 330c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redlprivate: 33157fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor llvm::PointerUnion<Stmt *, TypeSourceInfo *> Operand; 332c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl SourceRange Range; 333c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl 334c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redlpublic: 33557fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor CXXTypeidExpr(QualType Ty, TypeSourceInfo *Operand, SourceRange R) 33657fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor : Expr(CXXTypeidExprClass, Ty, 33757fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor // typeid is never type-dependent (C++ [temp.dep.expr]p4) 33857fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor false, 33957fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor // typeid is value-dependent if the type or expression are dependent 34057fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor Operand->getType()->isDependentType()), 34157fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor Operand(Operand), Range(R) { } 34257fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor 34357fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor CXXTypeidExpr(QualType Ty, Expr *Operand, SourceRange R) 34457fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor : Expr(CXXTypeidExprClass, Ty, 3452850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl // typeid is never type-dependent (C++ [temp.dep.expr]p4) 3462850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl false, 3472850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl // typeid is value-dependent if the type or expression are dependent 34857fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor Operand->isTypeDependent() || Operand->isValueDependent()), 34957fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor Operand(Operand), Range(R) { } 350c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl 35114ab24f01e36d495fce183aa67b41e45cdd54f39Chris Lattner CXXTypeidExpr(EmptyShell Empty, bool isExpr) 35214ab24f01e36d495fce183aa67b41e45cdd54f39Chris Lattner : Expr(CXXTypeidExprClass, Empty) { 35314ab24f01e36d495fce183aa67b41e45cdd54f39Chris Lattner if (isExpr) 35414ab24f01e36d495fce183aa67b41e45cdd54f39Chris Lattner Operand = (Expr*)0; 35514ab24f01e36d495fce183aa67b41e45cdd54f39Chris Lattner else 35614ab24f01e36d495fce183aa67b41e45cdd54f39Chris Lattner Operand = (TypeSourceInfo*)0; 35714ab24f01e36d495fce183aa67b41e45cdd54f39Chris Lattner } 35814ab24f01e36d495fce183aa67b41e45cdd54f39Chris Lattner 35957fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor bool isTypeOperand() const { return Operand.is<TypeSourceInfo *>(); } 36057fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor 36157fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor /// \brief Retrieves the type operand of this typeid() expression after 36257fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor /// various required adjustments (removing reference types, cv-qualifiers). 36357fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor QualType getTypeOperand() const; 36457fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor 36557fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor /// \brief Retrieve source information for the type operand. 36657fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor TypeSourceInfo *getTypeOperandSourceInfo() const { 367c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl assert(isTypeOperand() && "Cannot call getTypeOperand for typeid(expr)"); 36857fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor return Operand.get<TypeSourceInfo *>(); 369c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl } 37014ab24f01e36d495fce183aa67b41e45cdd54f39Chris Lattner 37114ab24f01e36d495fce183aa67b41e45cdd54f39Chris Lattner void setTypeOperandSourceInfo(TypeSourceInfo *TSI) { 37214ab24f01e36d495fce183aa67b41e45cdd54f39Chris Lattner assert(isTypeOperand() && "Cannot call getTypeOperand for typeid(expr)"); 37314ab24f01e36d495fce183aa67b41e45cdd54f39Chris Lattner Operand = TSI; 37414ab24f01e36d495fce183aa67b41e45cdd54f39Chris Lattner } 37557fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor 37614ab24f01e36d495fce183aa67b41e45cdd54f39Chris Lattner Expr *getExprOperand() const { 377c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl assert(!isTypeOperand() && "Cannot call getExprOperand for typeid(type)"); 37857fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor return static_cast<Expr*>(Operand.get<Stmt *>()); 379c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl } 38014ab24f01e36d495fce183aa67b41e45cdd54f39Chris Lattner 381030854b95f7bfd86aaa8afd9ae1aff9768a37e9aChris Lattner void setExprOperand(Expr *E) { 382030854b95f7bfd86aaa8afd9ae1aff9768a37e9aChris Lattner assert(!isTypeOperand() && "Cannot call getExprOperand for typeid(type)"); 383030854b95f7bfd86aaa8afd9ae1aff9768a37e9aChris Lattner Operand = E; 384030854b95f7bfd86aaa8afd9ae1aff9768a37e9aChris Lattner } 385030854b95f7bfd86aaa8afd9ae1aff9768a37e9aChris Lattner 38614ab24f01e36d495fce183aa67b41e45cdd54f39Chris Lattner virtual SourceRange getSourceRange() const { return Range; } 38714ab24f01e36d495fce183aa67b41e45cdd54f39Chris Lattner void setSourceRange(SourceRange R) { Range = R; } 38814ab24f01e36d495fce183aa67b41e45cdd54f39Chris Lattner 389c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl static bool classof(const Stmt *T) { 390c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl return T->getStmtClass() == CXXTypeidExprClass; 391c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl } 392c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl static bool classof(const CXXTypeidExpr *) { return true; } 393c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl 394c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl // Iterators 395c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl virtual child_iterator child_begin(); 396c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl virtual child_iterator child_end(); 397c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl}; 398c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl 399796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// CXXThisExpr - Represents the "this" expression in C++, which is a 400796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// pointer to the object on which the current member function is 401796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// executing (C++ [expr.prim]p3). Example: 402796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// 403796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// @code 404796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// class Foo { 405796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// public: 406796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// void bar(); 407796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// void test() { this->bar(); } 408796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// }; 409796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// @endcode 410796da18402f286b897782a298ae3b20c459c102eDouglas Gregorclass CXXThisExpr : public Expr { 411796da18402f286b897782a298ae3b20c459c102eDouglas Gregor SourceLocation Loc; 412828a197317288e3333b0ce6f5cedadd036e3531fDouglas Gregor bool Implicit : 1; 413828a197317288e3333b0ce6f5cedadd036e3531fDouglas Gregor 414796da18402f286b897782a298ae3b20c459c102eDouglas Gregorpublic: 415828a197317288e3333b0ce6f5cedadd036e3531fDouglas Gregor CXXThisExpr(SourceLocation L, QualType Type, bool isImplicit) 4162850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl : Expr(CXXThisExprClass, Type, 4172850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl // 'this' is type-dependent if the class type of the enclosing 4182850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl // member function is dependent (C++ [temp.dep.expr]p2) 4192850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl Type->isDependentType(), Type->isDependentType()), 420828a197317288e3333b0ce6f5cedadd036e3531fDouglas Gregor Loc(L), Implicit(isImplicit) { } 421796da18402f286b897782a298ae3b20c459c102eDouglas Gregor 4222fbdfcdf3bbf7b941853d38b123930755e837437Chris Lattner CXXThisExpr(EmptyShell Empty) : Expr(CXXThisExprClass, Empty) {} 4232fbdfcdf3bbf7b941853d38b123930755e837437Chris Lattner 4242fbdfcdf3bbf7b941853d38b123930755e837437Chris Lattner SourceLocation getLocation() const { return Loc; } 4252fbdfcdf3bbf7b941853d38b123930755e837437Chris Lattner void setLocation(SourceLocation L) { Loc = L; } 4262fbdfcdf3bbf7b941853d38b123930755e837437Chris Lattner 427796da18402f286b897782a298ae3b20c459c102eDouglas Gregor virtual SourceRange getSourceRange() const { return SourceRange(Loc); } 428796da18402f286b897782a298ae3b20c459c102eDouglas Gregor 429828a197317288e3333b0ce6f5cedadd036e3531fDouglas Gregor bool isImplicit() const { return Implicit; } 430828a197317288e3333b0ce6f5cedadd036e3531fDouglas Gregor void setImplicit(bool I) { Implicit = I; } 431828a197317288e3333b0ce6f5cedadd036e3531fDouglas Gregor 4321eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump static bool classof(const Stmt *T) { 433796da18402f286b897782a298ae3b20c459c102eDouglas Gregor return T->getStmtClass() == CXXThisExprClass; 434796da18402f286b897782a298ae3b20c459c102eDouglas Gregor } 435796da18402f286b897782a298ae3b20c459c102eDouglas Gregor static bool classof(const CXXThisExpr *) { return true; } 436796da18402f286b897782a298ae3b20c459c102eDouglas Gregor 437796da18402f286b897782a298ae3b20c459c102eDouglas Gregor // Iterators 438796da18402f286b897782a298ae3b20c459c102eDouglas Gregor virtual child_iterator child_begin(); 439796da18402f286b897782a298ae3b20c459c102eDouglas Gregor virtual child_iterator child_end(); 440796da18402f286b897782a298ae3b20c459c102eDouglas Gregor}; 441796da18402f286b897782a298ae3b20c459c102eDouglas Gregor 4421060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek/// CXXThrowExpr - [C++ 15] C++ Throw Expression. This handles 4431060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek/// 'throw' and 'throw' assignment-expression. When 4441060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek/// assignment-expression isn't present, Op will be null. 4451060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek/// 4461060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenekclass CXXThrowExpr : public Expr { 4471060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek Stmt *Op; 4481060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek SourceLocation ThrowLoc; 4491060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenekpublic: 4501060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek // Ty is the void type which is used as the result type of the 4511060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek // exepression. The l is the location of the throw keyword. expr 4521060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek // can by null, if the optional expression to throw isn't present. 4531060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek CXXThrowExpr(Expr *expr, QualType Ty, SourceLocation l) : 4542850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl Expr(CXXThrowExprClass, Ty, false, false), Op(expr), ThrowLoc(l) {} 4552fbdfcdf3bbf7b941853d38b123930755e837437Chris Lattner CXXThrowExpr(EmptyShell Empty) : Expr(CXXThrowExprClass, Empty) {} 4562fbdfcdf3bbf7b941853d38b123930755e837437Chris Lattner 4571060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek const Expr *getSubExpr() const { return cast_or_null<Expr>(Op); } 4581060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek Expr *getSubExpr() { return cast_or_null<Expr>(Op); } 45942e5b50f4dc897f252e0d476063a7f9846d96624Douglas Gregor void setSubExpr(Expr *E) { Op = E; } 46042e5b50f4dc897f252e0d476063a7f9846d96624Douglas Gregor 46142e5b50f4dc897f252e0d476063a7f9846d96624Douglas Gregor SourceLocation getThrowLoc() const { return ThrowLoc; } 46242e5b50f4dc897f252e0d476063a7f9846d96624Douglas Gregor void setThrowLoc(SourceLocation L) { ThrowLoc = L; } 4631060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek 4641060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek virtual SourceRange getSourceRange() const { 4651060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek if (getSubExpr() == 0) 4661060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek return SourceRange(ThrowLoc, ThrowLoc); 4671060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek return SourceRange(ThrowLoc, getSubExpr()->getSourceRange().getEnd()); 4681060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek } 4691060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek 4701060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek static bool classof(const Stmt *T) { 4711060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek return T->getStmtClass() == CXXThrowExprClass; 4721060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek } 4731060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek static bool classof(const CXXThrowExpr *) { return true; } 4741060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek 4751060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek // Iterators 4761060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek virtual child_iterator child_begin(); 4771060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek virtual child_iterator child_end(); 4781060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek}; 4791060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek 4801060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek/// CXXDefaultArgExpr - C++ [dcl.fct.default]. This wraps up a 4811060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek/// function call argument that was created from the corresponding 4821060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek/// parameter's default argument, when the call did not explicitly 4831060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek/// supply arguments for all of the parameters. 4841060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenekclass CXXDefaultArgExpr : public Expr { 48565222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor /// \brief The parameter whose default is being used. 48665222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor /// 48765222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor /// When the bit is set, the subexpression is stored after the 48865222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor /// CXXDefaultArgExpr itself. When the bit is clear, the parameter's 48965222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor /// actual default expression is the subexpression. 49065222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor llvm::PointerIntPair<ParmVarDecl *, 1, bool> Param; 4911eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 492036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor /// \brief The location where the default argument expression was used. 493036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor SourceLocation Loc; 494036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor 495036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor CXXDefaultArgExpr(StmtClass SC, SourceLocation Loc, ParmVarDecl *param) 49665222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor : Expr(SC, 49765222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor param->hasUnparsedDefaultArg() 49865222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor ? param->getType().getNonReferenceType() 4992333f7727f97018d6742e1e0938133bcfad967abEli Friedman : param->getDefaultArg()->getType(), 5002333f7727f97018d6742e1e0938133bcfad967abEli Friedman false, false), 501036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor Param(param, false), Loc(Loc) { } 50265222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor 503036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor CXXDefaultArgExpr(StmtClass SC, SourceLocation Loc, ParmVarDecl *param, 504036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor Expr *SubExpr) 505030854b95f7bfd86aaa8afd9ae1aff9768a37e9aChris Lattner : Expr(SC, SubExpr->getType(), false, false), Param(param, true), Loc(Loc) { 50665222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor *reinterpret_cast<Expr **>(this + 1) = SubExpr; 50765222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor } 50865222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor 5091060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenekpublic: 510030854b95f7bfd86aaa8afd9ae1aff9768a37e9aChris Lattner CXXDefaultArgExpr(EmptyShell Empty) : Expr(CXXDefaultArgExprClass, Empty) {} 511030854b95f7bfd86aaa8afd9ae1aff9768a37e9aChris Lattner 512030854b95f7bfd86aaa8afd9ae1aff9768a37e9aChris Lattner 5131060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek // Param is the parameter whose default argument is used by this 5141060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek // expression. 515036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor static CXXDefaultArgExpr *Create(ASTContext &C, SourceLocation Loc, 516036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor ParmVarDecl *Param) { 517036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor return new (C) CXXDefaultArgExpr(CXXDefaultArgExprClass, Loc, Param); 518f1480eee38b59d15438fb7bc50865ac7c7e22403Anders Carlsson } 5191060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek 52065222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor // Param is the parameter whose default argument is used by this 52165222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor // expression, and SubExpr is the expression that will actually be used. 522036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor static CXXDefaultArgExpr *Create(ASTContext &C, 523036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor SourceLocation Loc, 524036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor ParmVarDecl *Param, 52565222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor Expr *SubExpr); 52665222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor 5271060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek // Retrieve the parameter that the argument was created from. 52865222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor const ParmVarDecl *getParam() const { return Param.getPointer(); } 52965222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor ParmVarDecl *getParam() { return Param.getPointer(); } 530030854b95f7bfd86aaa8afd9ae1aff9768a37e9aChris Lattner 5311060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek // Retrieve the actual argument to the function call. 53265222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor const Expr *getExpr() const { 53365222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor if (Param.getInt()) 53465222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor return *reinterpret_cast<Expr const * const*> (this + 1); 53565222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor return getParam()->getDefaultArg(); 53665222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor } 53765222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor Expr *getExpr() { 53865222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor if (Param.getInt()) 53965222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor return *reinterpret_cast<Expr **> (this + 1); 54065222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor return getParam()->getDefaultArg(); 54165222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor } 5421060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek 543036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor /// \brief Retrieve the location where this default argument was actually 544036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor /// used. 545036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor SourceLocation getUsedLocation() const { return Loc; } 546036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor 5471060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek virtual SourceRange getSourceRange() const { 5481060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek // Default argument expressions have no representation in the 5491060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek // source, so they have an empty source range. 5501060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek return SourceRange(); 5511060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek } 5521060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek 5531060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek static bool classof(const Stmt *T) { 5541060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek return T->getStmtClass() == CXXDefaultArgExprClass; 5551060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek } 5561060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek static bool classof(const CXXDefaultArgExpr *) { return true; } 5571060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek 5581060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek // Iterators 5591060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek virtual child_iterator child_begin(); 5601060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek virtual child_iterator child_end(); 5618a50733034edd6a349b34e2b9f0c8d0a874846d3Argyrios Kyrtzidis 56260adf4acf40b72227740bf966fb87eebddff3f37Sebastian Redl friend class ASTStmtReader; 5633397c5570369f19b2d6c52e898f708d75ceede1fSebastian Redl friend class ASTStmtWriter; 5641060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek}; 565987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis 566c1ce477119fed070299668aab24084b17ff5f14bAnders Carlsson/// CXXTemporary - Represents a C++ temporary. 567c1ce477119fed070299668aab24084b17ff5f14bAnders Carlssonclass CXXTemporary { 568c1ce477119fed070299668aab24084b17ff5f14bAnders Carlsson /// Destructor - The destructor that needs to be called. 569b859f35459ae3e1188d1e1b86df08d649695fd86Anders Carlsson const CXXDestructorDecl *Destructor; 5701eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 571b859f35459ae3e1188d1e1b86df08d649695fd86Anders Carlsson CXXTemporary(const CXXDestructorDecl *destructor) 572c1ce477119fed070299668aab24084b17ff5f14bAnders Carlsson : Destructor(destructor) { } 573c1ce477119fed070299668aab24084b17ff5f14bAnders Carlsson 574c1ce477119fed070299668aab24084b17ff5f14bAnders Carlssonpublic: 5751eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump static CXXTemporary *Create(ASTContext &C, 576b859f35459ae3e1188d1e1b86df08d649695fd86Anders Carlsson const CXXDestructorDecl *Destructor); 5771eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 578f0721fe438d7e40c168e5d664970e7830bc138fbAnders Carlsson const CXXDestructorDecl *getDestructor() const { return Destructor; } 579c1ce477119fed070299668aab24084b17ff5f14bAnders Carlsson}; 580fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson 581ddfe960d252a93525692b547945236d361d1929fChandler Carruth/// \brief Represents binding an expression to a temporary. 582ddfe960d252a93525692b547945236d361d1929fChandler Carruth/// 583ddfe960d252a93525692b547945236d361d1929fChandler Carruth/// This ensures the destructor is called for the temporary. It should only be 584ddfe960d252a93525692b547945236d361d1929fChandler Carruth/// needed for non-POD, non-trivially destructable class types. For example: 585ddfe960d252a93525692b547945236d361d1929fChandler Carruth/// 586ddfe960d252a93525692b547945236d361d1929fChandler Carruth/// \code 587ddfe960d252a93525692b547945236d361d1929fChandler Carruth/// struct S { 588ddfe960d252a93525692b547945236d361d1929fChandler Carruth/// S() { } // User defined constructor makes S non-POD. 589ddfe960d252a93525692b547945236d361d1929fChandler Carruth/// ~S() { } // User defined destructor makes it non-trivial. 590ddfe960d252a93525692b547945236d361d1929fChandler Carruth/// }; 591ddfe960d252a93525692b547945236d361d1929fChandler Carruth/// void test() { 592ddfe960d252a93525692b547945236d361d1929fChandler Carruth/// const S &s_ref = S(); // Requires a CXXBindTemporaryExpr. 593ddfe960d252a93525692b547945236d361d1929fChandler Carruth/// } 594ddfe960d252a93525692b547945236d361d1929fChandler Carruth/// \endcode 595fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlssonclass CXXBindTemporaryExpr : public Expr { 596fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson CXXTemporary *Temp; 5971eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 598fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson Stmt *SubExpr; 599fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson 6001eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump CXXBindTemporaryExpr(CXXTemporary *temp, Expr* subexpr) 6012333f7727f97018d6742e1e0938133bcfad967abEli Friedman : Expr(CXXBindTemporaryExprClass, subexpr->getType(), false, false), 6022333f7727f97018d6742e1e0938133bcfad967abEli Friedman Temp(temp), SubExpr(subexpr) { } 60388eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlsson 604fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlssonpublic: 605d2598368876cfe40bc8465540033bc5b5e58d8afChris Lattner CXXBindTemporaryExpr(EmptyShell Empty) 606d2598368876cfe40bc8465540033bc5b5e58d8afChris Lattner : Expr(CXXBindTemporaryExprClass, Empty), Temp(0), SubExpr(0) {} 607d2598368876cfe40bc8465540033bc5b5e58d8afChris Lattner 6081eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump static CXXBindTemporaryExpr *Create(ASTContext &C, CXXTemporary *Temp, 609fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson Expr* SubExpr); 6101eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 61188eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlsson CXXTemporary *getTemporary() { return Temp; } 612f0721fe438d7e40c168e5d664970e7830bc138fbAnders Carlsson const CXXTemporary *getTemporary() const { return Temp; } 613d2598368876cfe40bc8465540033bc5b5e58d8afChris Lattner void setTemporary(CXXTemporary *T) { Temp = T; } 614f0721fe438d7e40c168e5d664970e7830bc138fbAnders Carlsson 615fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson const Expr *getSubExpr() const { return cast<Expr>(SubExpr); } 616fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson Expr *getSubExpr() { return cast<Expr>(SubExpr); } 61788eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlsson void setSubExpr(Expr *E) { SubExpr = E; } 618fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson 61996be6917e1c4ba1f4435a14c9e7c6c139571d086Douglas Gregor virtual SourceRange getSourceRange() const { 62096be6917e1c4ba1f4435a14c9e7c6c139571d086Douglas Gregor return SubExpr->getSourceRange(); 62196be6917e1c4ba1f4435a14c9e7c6c139571d086Douglas Gregor } 622fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson 623fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson // Implement isa/cast/dyncast/etc. 624fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson static bool classof(const Stmt *T) { 625fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson return T->getStmtClass() == CXXBindTemporaryExprClass; 626fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson } 627fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson static bool classof(const CXXBindTemporaryExpr *) { return true; } 628fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson 629fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson // Iterators 630fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson virtual child_iterator child_begin(); 631fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson virtual child_iterator child_end(); 632fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson}; 633fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson 63415ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson/// CXXConstructExpr - Represents a call to a C++ constructor. 63515ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlssonclass CXXConstructExpr : public Expr { 63672e96fd181b19b8d01144a685cda6e955584c7eaAnders Carlssonpublic: 63772e96fd181b19b8d01144a685cda6e955584c7eaAnders Carlsson enum ConstructionKind { 63872e96fd181b19b8d01144a685cda6e955584c7eaAnders Carlsson CK_Complete, 63972e96fd181b19b8d01144a685cda6e955584c7eaAnders Carlsson CK_NonVirtualBase, 64072e96fd181b19b8d01144a685cda6e955584c7eaAnders Carlsson CK_VirtualBase 64172e96fd181b19b8d01144a685cda6e955584c7eaAnders Carlsson }; 64272e96fd181b19b8d01144a685cda6e955584c7eaAnders Carlsson 64372e96fd181b19b8d01144a685cda6e955584c7eaAnders Carlssonprivate: 64415ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson CXXConstructorDecl *Constructor; 64515ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson 64699a2e600f9e2e51d3ce10fb6f27191677ac65b2aDouglas Gregor SourceLocation Loc; 64716006c901315fa12a108b4e571f187f4b676e426Douglas Gregor bool Elidable : 1; 64816006c901315fa12a108b4e571f187f4b676e426Douglas Gregor bool ZeroInitialization : 1; 64972e96fd181b19b8d01144a685cda6e955584c7eaAnders Carlsson unsigned ConstructKind : 2; 65015ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson Stmt **Args; 65115ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson unsigned NumArgs; 6521eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 653bd6734e5f6432ce0cc07171c490ffaa094796198Anders Carlssonprotected: 6541eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump CXXConstructExpr(ASTContext &C, StmtClass SC, QualType T, 65599a2e600f9e2e51d3ce10fb6f27191677ac65b2aDouglas Gregor SourceLocation Loc, 656bd6734e5f6432ce0cc07171c490ffaa094796198Anders Carlsson CXXConstructorDecl *d, bool elidable, 65716006c901315fa12a108b4e571f187f4b676e426Douglas Gregor Expr **args, unsigned numargs, 6589db7dbb918ca49f4ee6c181e4917e7b6ec547353Douglas Gregor bool ZeroInitialization = false, 65972e96fd181b19b8d01144a685cda6e955584c7eaAnders Carlsson ConstructionKind ConstructKind = CK_Complete); 660bd6734e5f6432ce0cc07171c490ffaa094796198Anders Carlsson 6616d00c1365dd3601f6d93bbda9162913c57ae788fArgyrios Kyrtzidis /// \brief Construct an empty C++ construction expression. 6626d00c1365dd3601f6d93bbda9162913c57ae788fArgyrios Kyrtzidis CXXConstructExpr(StmtClass SC, EmptyShell Empty) 6636d00c1365dd3601f6d93bbda9162913c57ae788fArgyrios Kyrtzidis : Expr(SC, Empty), Constructor(0), Elidable(0), ZeroInitialization(0), 6646d00c1365dd3601f6d93bbda9162913c57ae788fArgyrios Kyrtzidis ConstructKind(0), Args(0), NumArgs(0) { } 6656d00c1365dd3601f6d93bbda9162913c57ae788fArgyrios Kyrtzidis 66615ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlssonpublic: 6676d00c1365dd3601f6d93bbda9162913c57ae788fArgyrios Kyrtzidis /// \brief Construct an empty C++ construction expression. 6686d00c1365dd3601f6d93bbda9162913c57ae788fArgyrios Kyrtzidis explicit CXXConstructExpr(EmptyShell Empty) 6696d00c1365dd3601f6d93bbda9162913c57ae788fArgyrios Kyrtzidis : Expr(CXXConstructExprClass, Empty), Constructor(0), 6706d00c1365dd3601f6d93bbda9162913c57ae788fArgyrios Kyrtzidis Elidable(0), ZeroInitialization(0), 6716d00c1365dd3601f6d93bbda9162913c57ae788fArgyrios Kyrtzidis ConstructKind(0), Args(0), NumArgs(0) { } 6726d00c1365dd3601f6d93bbda9162913c57ae788fArgyrios Kyrtzidis 6738e587a15da6d3457a418239d5eb4146fcbd209f3Anders Carlsson static CXXConstructExpr *Create(ASTContext &C, QualType T, 67499a2e600f9e2e51d3ce10fb6f27191677ac65b2aDouglas Gregor SourceLocation Loc, 6751eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump CXXConstructorDecl *D, bool Elidable, 67616006c901315fa12a108b4e571f187f4b676e426Douglas Gregor Expr **Args, unsigned NumArgs, 6779db7dbb918ca49f4ee6c181e4917e7b6ec547353Douglas Gregor bool ZeroInitialization = false, 678fcaeef2ae00ec643eb024e0aca2c98701cf5627cAnders Carlsson ConstructionKind ConstructKind = CK_Complete); 6791eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 6801eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 681d94546a0a1deef7286c13e49b9584621ae81cc9aDouglas Gregor CXXConstructorDecl* getConstructor() const { return Constructor; } 68239da0b8145eaec7da7004f9b3645c5c9f4f63b1dDouglas Gregor void setConstructor(CXXConstructorDecl *C) { Constructor = C; } 68339da0b8145eaec7da7004f9b3645c5c9f4f63b1dDouglas Gregor 68499a2e600f9e2e51d3ce10fb6f27191677ac65b2aDouglas Gregor SourceLocation getLocation() const { return Loc; } 68599a2e600f9e2e51d3ce10fb6f27191677ac65b2aDouglas Gregor void setLocation(SourceLocation Loc) { this->Loc = Loc; } 68699a2e600f9e2e51d3ce10fb6f27191677ac65b2aDouglas Gregor 687d94546a0a1deef7286c13e49b9584621ae81cc9aDouglas Gregor /// \brief Whether this construction is elidable. 688d94546a0a1deef7286c13e49b9584621ae81cc9aDouglas Gregor bool isElidable() const { return Elidable; } 68939da0b8145eaec7da7004f9b3645c5c9f4f63b1dDouglas Gregor void setElidable(bool E) { Elidable = E; } 69039da0b8145eaec7da7004f9b3645c5c9f4f63b1dDouglas Gregor 69116006c901315fa12a108b4e571f187f4b676e426Douglas Gregor /// \brief Whether this construction first requires 69216006c901315fa12a108b4e571f187f4b676e426Douglas Gregor /// zero-initialization before the initializer is called. 69316006c901315fa12a108b4e571f187f4b676e426Douglas Gregor bool requiresZeroInitialization() const { return ZeroInitialization; } 69416006c901315fa12a108b4e571f187f4b676e426Douglas Gregor void setRequiresZeroInitialization(bool ZeroInit) { 69516006c901315fa12a108b4e571f187f4b676e426Douglas Gregor ZeroInitialization = ZeroInit; 69616006c901315fa12a108b4e571f187f4b676e426Douglas Gregor } 69716006c901315fa12a108b4e571f187f4b676e426Douglas Gregor 6989db7dbb918ca49f4ee6c181e4917e7b6ec547353Douglas Gregor /// \brief Determines whether this constructor is actually constructing 6999db7dbb918ca49f4ee6c181e4917e7b6ec547353Douglas Gregor /// a base class (rather than a complete object). 70024eb78e38aba55c507bc3c05c37035a9ab2defa7Anders Carlsson ConstructionKind getConstructionKind() const { 70124eb78e38aba55c507bc3c05c37035a9ab2defa7Anders Carlsson return (ConstructionKind)ConstructKind; 70272e96fd181b19b8d01144a685cda6e955584c7eaAnders Carlsson } 70372e96fd181b19b8d01144a685cda6e955584c7eaAnders Carlsson void setConstructionKind(ConstructionKind CK) { 70472e96fd181b19b8d01144a685cda6e955584c7eaAnders Carlsson ConstructKind = CK; 70572e96fd181b19b8d01144a685cda6e955584c7eaAnders Carlsson } 7069db7dbb918ca49f4ee6c181e4917e7b6ec547353Douglas Gregor 70715ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson typedef ExprIterator arg_iterator; 70815ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson typedef ConstExprIterator const_arg_iterator; 7091eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 71015ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson arg_iterator arg_begin() { return Args; } 71115ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson arg_iterator arg_end() { return Args + NumArgs; } 71215ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson const_arg_iterator arg_begin() const { return Args; } 71315ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson const_arg_iterator arg_end() const { return Args + NumArgs; } 71415ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson 715a88cfbfac9bbcbb9858f048d6d73a48711d8e93dDouglas Gregor Expr **getArgs() const { return reinterpret_cast<Expr **>(Args); } 71615ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson unsigned getNumArgs() const { return NumArgs; } 71715ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson 718bcb11d01c034f967503bd98f28bdf458c1ab8001Anders Carlsson /// getArg - Return the specified argument. 719bcb11d01c034f967503bd98f28bdf458c1ab8001Anders Carlsson Expr *getArg(unsigned Arg) { 720bcb11d01c034f967503bd98f28bdf458c1ab8001Anders Carlsson assert(Arg < NumArgs && "Arg access out of range!"); 721bcb11d01c034f967503bd98f28bdf458c1ab8001Anders Carlsson return cast<Expr>(Args[Arg]); 722bcb11d01c034f967503bd98f28bdf458c1ab8001Anders Carlsson } 723bcb11d01c034f967503bd98f28bdf458c1ab8001Anders Carlsson const Expr *getArg(unsigned Arg) const { 724bcb11d01c034f967503bd98f28bdf458c1ab8001Anders Carlsson assert(Arg < NumArgs && "Arg access out of range!"); 725bcb11d01c034f967503bd98f28bdf458c1ab8001Anders Carlsson return cast<Expr>(Args[Arg]); 726bcb11d01c034f967503bd98f28bdf458c1ab8001Anders Carlsson } 7271eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 7282eeed7bc4fd457ac57ff32ab3b02674588545f65Fariborz Jahanian /// setArg - Set the specified argument. 7292eeed7bc4fd457ac57ff32ab3b02674588545f65Fariborz Jahanian void setArg(unsigned Arg, Expr *ArgExpr) { 7302eeed7bc4fd457ac57ff32ab3b02674588545f65Fariborz Jahanian assert(Arg < NumArgs && "Arg access out of range!"); 7312eeed7bc4fd457ac57ff32ab3b02674588545f65Fariborz Jahanian Args[Arg] = ArgExpr; 7322eeed7bc4fd457ac57ff32ab3b02674588545f65Fariborz Jahanian } 7332eeed7bc4fd457ac57ff32ab3b02674588545f65Fariborz Jahanian 734e383768f7f5d45ca4af0b1c11cbf072de18bce98Ted Kremenek virtual SourceRange getSourceRange() const; 73515ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson 7361eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump static bool classof(const Stmt *T) { 737524fa13fd81e88533c7a1d4b1232c0de2c97dc7cAnders Carlsson return T->getStmtClass() == CXXConstructExprClass || 738524fa13fd81e88533c7a1d4b1232c0de2c97dc7cAnders Carlsson T->getStmtClass() == CXXTemporaryObjectExprClass; 73915ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson } 74015ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson static bool classof(const CXXConstructExpr *) { return true; } 7411eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 74215ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson // Iterators 74315ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson virtual child_iterator child_begin(); 74415ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson virtual child_iterator child_end(); 7456d00c1365dd3601f6d93bbda9162913c57ae788fArgyrios Kyrtzidis 74660adf4acf40b72227740bf966fb87eebddff3f37Sebastian Redl friend class ASTStmtReader; 74715ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson}; 74815ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson 74949badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// CXXFunctionalCastExpr - Represents an explicit C++ type conversion 75049badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// that uses "functional" notion (C++ [expr.type.conv]). Example: @c 75149badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// x = int(0.5); 75249badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregorclass CXXFunctionalCastExpr : public ExplicitCastExpr { 753987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis SourceLocation TyBeginLoc; 754987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis SourceLocation RParenLoc; 755f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall 7569d125033a9853f3b572a4c9e2f9e2d4e5e346973John McCall CXXFunctionalCastExpr(QualType ty, TypeSourceInfo *writtenTy, 7571eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump SourceLocation tyBeginLoc, CastKind kind, 758f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall Expr *castExpr, unsigned pathSize, 75941b2dcd465f1e438502c420effc9d0c747f9db8fAnders Carlsson SourceLocation rParenLoc) 7600aebc81e02397a5987aaa8e8c7acbdb01a31d7c3Anders Carlsson : ExplicitCastExpr(CXXFunctionalCastExprClass, ty, kind, castExpr, 761f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall pathSize, writtenTy), 7620aebc81e02397a5987aaa8e8c7acbdb01a31d7c3Anders Carlsson TyBeginLoc(tyBeginLoc), RParenLoc(rParenLoc) {} 7630aebc81e02397a5987aaa8e8c7acbdb01a31d7c3Anders Carlsson 764f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall explicit CXXFunctionalCastExpr(EmptyShell Shell, unsigned PathSize) 765f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall : ExplicitCastExpr(CXXFunctionalCastExprClass, Shell, PathSize) { } 766f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall 767f871d0cc377a1367b519a6cce26be74607566ebaJohn McCallpublic: 768f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall static CXXFunctionalCastExpr *Create(ASTContext &Context, QualType T, 769f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall TypeSourceInfo *Written, 770f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall SourceLocation TyBeginLoc, 771f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall CastKind Kind, Expr *Op, 772f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall const CXXCastPath *Path, 773f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall SourceLocation RPLoc); 774f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall static CXXFunctionalCastExpr *CreateEmpty(ASTContext &Context, 775f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall unsigned PathSize); 776ce757a7a1ee905f87551996a69da3e95e8afeeb7Sam Weinig 777987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis SourceLocation getTypeBeginLoc() const { return TyBeginLoc; } 778ce757a7a1ee905f87551996a69da3e95e8afeeb7Sam Weinig void setTypeBeginLoc(SourceLocation L) { TyBeginLoc = L; } 779987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis SourceLocation getRParenLoc() const { return RParenLoc; } 780ce757a7a1ee905f87551996a69da3e95e8afeeb7Sam Weinig void setRParenLoc(SourceLocation L) { RParenLoc = L; } 7811eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 782987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis virtual SourceRange getSourceRange() const { 783987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis return SourceRange(TyBeginLoc, RParenLoc); 784987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis } 7851eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump static bool classof(const Stmt *T) { 7861eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump return T->getStmtClass() == CXXFunctionalCastExprClass; 787987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis } 788987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis static bool classof(const CXXFunctionalCastExpr *) { return true; } 789987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis}; 790987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis 791506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// @brief Represents a C++ functional cast expression that builds a 792506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// temporary object. 793506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// 7941eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump/// This expression type represents a C++ "functional" cast 795506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// (C++[expr.type.conv]) with N != 1 arguments that invokes a 796ed8abf18329df67b0abcbb3a10458bd8c1d2a595Douglas Gregor/// constructor to build a temporary object. With N == 1 arguments the 797ed8abf18329df67b0abcbb3a10458bd8c1d2a595Douglas Gregor/// functional cast expression will be represented by CXXFunctionalCastExpr. 798506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// Example: 799506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// @code 800506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// struct X { X(int, float); } 801506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// 802506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// X create_X() { 803506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// return X(1, 3.14f); // creates a CXXTemporaryObjectExpr 804506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// }; 805506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// @endcode 806524fa13fd81e88533c7a1d4b1232c0de2c97dc7cAnders Carlssonclass CXXTemporaryObjectExpr : public CXXConstructExpr { 807506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor SourceLocation TyBeginLoc; 808506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor SourceLocation RParenLoc; 809506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor 810506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregorpublic: 8111eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump CXXTemporaryObjectExpr(ASTContext &C, CXXConstructorDecl *Cons, 8121eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump QualType writtenTy, SourceLocation tyBeginLoc, 8131eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump Expr **Args,unsigned NumArgs, 8141c63b9c15d48cb8c833a4b2d6fd6c496c0766e88Douglas Gregor SourceLocation rParenLoc, 8151c63b9c15d48cb8c833a4b2d6fd6c496c0766e88Douglas Gregor bool ZeroInitialization = false); 8166d00c1365dd3601f6d93bbda9162913c57ae788fArgyrios Kyrtzidis explicit CXXTemporaryObjectExpr(EmptyShell Empty) 8176d00c1365dd3601f6d93bbda9162913c57ae788fArgyrios Kyrtzidis : CXXConstructExpr(CXXTemporaryObjectExprClass, Empty) { } 818506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor 819506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor SourceLocation getTypeBeginLoc() const { return TyBeginLoc; } 820506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor SourceLocation getRParenLoc() const { return RParenLoc; } 821ba49817c5b9f502602672861cf369fd0e53966e8Douglas Gregor 822506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor virtual SourceRange getSourceRange() const { 823506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor return SourceRange(TyBeginLoc, RParenLoc); 824506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor } 8251eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump static bool classof(const Stmt *T) { 826506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor return T->getStmtClass() == CXXTemporaryObjectExprClass; 827506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor } 828506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor static bool classof(const CXXTemporaryObjectExpr *) { return true; } 8296d00c1365dd3601f6d93bbda9162913c57ae788fArgyrios Kyrtzidis 83060adf4acf40b72227740bf966fb87eebddff3f37Sebastian Redl friend class ASTStmtReader; 831506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor}; 832506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor 833ed8abf18329df67b0abcbb3a10458bd8c1d2a595Douglas Gregor/// CXXScalarValueInitExpr - [C++ 5.2.3p2] 834506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// Expression "T()" which creates a value-initialized rvalue of type 835ed8abf18329df67b0abcbb3a10458bd8c1d2a595Douglas Gregor/// T, which is a non-class type. 836987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis/// 837ed8abf18329df67b0abcbb3a10458bd8c1d2a595Douglas Gregorclass CXXScalarValueInitExpr : public Expr { 838987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis SourceLocation TyBeginLoc; 839987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis SourceLocation RParenLoc; 840987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis 841987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidispublic: 842ed8abf18329df67b0abcbb3a10458bd8c1d2a595Douglas Gregor CXXScalarValueInitExpr(QualType ty, SourceLocation tyBeginLoc, 8431eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump SourceLocation rParenLoc ) : 844ed8abf18329df67b0abcbb3a10458bd8c1d2a595Douglas Gregor Expr(CXXScalarValueInitExprClass, ty, false, false), 845987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis TyBeginLoc(tyBeginLoc), RParenLoc(rParenLoc) {} 846ed8abf18329df67b0abcbb3a10458bd8c1d2a595Douglas Gregor explicit CXXScalarValueInitExpr(EmptyShell Shell) 847ed8abf18329df67b0abcbb3a10458bd8c1d2a595Douglas Gregor : Expr(CXXScalarValueInitExprClass, Shell) { } 8481eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 849987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis SourceLocation getTypeBeginLoc() const { return TyBeginLoc; } 850987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis SourceLocation getRParenLoc() const { return RParenLoc; } 851987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis 8525921863d8f24084797863b5df37842113bac4352Chris Lattner void setTypeBeginLoc(SourceLocation L) { TyBeginLoc = L; } 8535921863d8f24084797863b5df37842113bac4352Chris Lattner void setRParenLoc(SourceLocation L) { RParenLoc = L; } 8545921863d8f24084797863b5df37842113bac4352Chris Lattner 8554c67834407ca6ab344dcf44fc599ad4938cfa96dDouglas Gregor /// @brief Whether this initialization expression was 8564c67834407ca6ab344dcf44fc599ad4938cfa96dDouglas Gregor /// implicitly-generated. 8571eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump bool isImplicit() const { 8581eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump return TyBeginLoc.isInvalid() && RParenLoc.isInvalid(); 8594c67834407ca6ab344dcf44fc599ad4938cfa96dDouglas Gregor } 8604c67834407ca6ab344dcf44fc599ad4938cfa96dDouglas Gregor 861987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis virtual SourceRange getSourceRange() const { 862987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis return SourceRange(TyBeginLoc, RParenLoc); 863987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis } 8641eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 8651eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump static bool classof(const Stmt *T) { 866ed8abf18329df67b0abcbb3a10458bd8c1d2a595Douglas Gregor return T->getStmtClass() == CXXScalarValueInitExprClass; 867987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis } 868ed8abf18329df67b0abcbb3a10458bd8c1d2a595Douglas Gregor static bool classof(const CXXScalarValueInitExpr *) { return true; } 8691eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 870987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis // Iterators 871987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis virtual child_iterator child_begin(); 872987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis virtual child_iterator child_end(); 873987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis}; 874987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis 8754c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl/// CXXNewExpr - A new expression for memory allocation and constructor calls, 8764c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl/// e.g: "new CXXNewExpr(foo)". 8774c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redlclass CXXNewExpr : public Expr { 8784c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // Was the usage ::new, i.e. is the global new to be used? 8794c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl bool GlobalNew : 1; 8804c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // Is there an initializer? If not, built-ins are uninitialized, else they're 8814c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // value-initialized. 8824c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl bool Initializer : 1; 883cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl // Do we allocate an array? If so, the first SubExpr is the size expression. 884cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl bool Array : 1; 8854c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // The number of placement new arguments. 886e4b8f1171d699c56ba2b39aabf1d7cb4c38ce4f8Douglas Gregor unsigned NumPlacementArgs : 15; 8874c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // The number of constructor arguments. This may be 1 even for non-class 8884c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // types; use the pseudo copy constructor. 889cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl unsigned NumConstructorArgs : 14; 890cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl // Contains an optional array size expression, any number of optional 891cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl // placement arguments, and any number of optional constructor arguments, 892cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl // in that order. 8934c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl Stmt **SubExprs; 8944c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // Points to the allocation function used. 8954c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl FunctionDecl *OperatorNew; 8964c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // Points to the deallocation function used in case of error. May be null. 8974c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl FunctionDecl *OperatorDelete; 8984c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // Points to the constructor used. Cannot be null if AllocType is a record; 8994c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // it would still point at the default constructor (even an implicit one). 9004c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // Must be null for all other types. 9014c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl CXXConstructorDecl *Constructor; 9024c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 9031bb2a93ab7b1499dda6f6b58865bd0dce1864228Douglas Gregor /// \brief The allocated type-source information, as written in the source. 9041bb2a93ab7b1499dda6f6b58865bd0dce1864228Douglas Gregor TypeSourceInfo *AllocatedTypeInfo; 9051bb2a93ab7b1499dda6f6b58865bd0dce1864228Douglas Gregor 9064bd40318cbea15310a37343db46de96c4fcc15e6Douglas Gregor /// \brief If the allocated type was expressed as a parenthesized type-id, 9074bd40318cbea15310a37343db46de96c4fcc15e6Douglas Gregor /// the source range covering the parenthesized type-id. 9084bd40318cbea15310a37343db46de96c4fcc15e6Douglas Gregor SourceRange TypeIdParens; 9094bd40318cbea15310a37343db46de96c4fcc15e6Douglas Gregor 9104c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl SourceLocation StartLoc; 9114c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl SourceLocation EndLoc; 9124c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 91360adf4acf40b72227740bf966fb87eebddff3f37Sebastian Redl friend class ASTStmtReader; 9144c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redlpublic: 915ad7fe864862305c2f71e047cdf6706ef43aebdc0Ted Kremenek CXXNewExpr(ASTContext &C, bool globalNew, FunctionDecl *operatorNew, 9164bd40318cbea15310a37343db46de96c4fcc15e6Douglas Gregor Expr **placementArgs, unsigned numPlaceArgs, 9174bd40318cbea15310a37343db46de96c4fcc15e6Douglas Gregor SourceRange TypeIdParens, 918ad7fe864862305c2f71e047cdf6706ef43aebdc0Ted Kremenek Expr *arraySize, CXXConstructorDecl *constructor, bool initializer, 9194c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl Expr **constructorArgs, unsigned numConsArgs, 9204c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl FunctionDecl *operatorDelete, QualType ty, 9211bb2a93ab7b1499dda6f6b58865bd0dce1864228Douglas Gregor TypeSourceInfo *AllocatedTypeInfo, 9224c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl SourceLocation startLoc, SourceLocation endLoc); 9235921863d8f24084797863b5df37842113bac4352Chris Lattner explicit CXXNewExpr(EmptyShell Shell) 9245921863d8f24084797863b5df37842113bac4352Chris Lattner : Expr(CXXNewExprClass, Shell), SubExprs(0) { } 9255921863d8f24084797863b5df37842113bac4352Chris Lattner 9265921863d8f24084797863b5df37842113bac4352Chris Lattner void AllocateArgsArray(ASTContext &C, bool isArray, unsigned numPlaceArgs, 9275921863d8f24084797863b5df37842113bac4352Chris Lattner unsigned numConsArgs); 928ad7fe864862305c2f71e047cdf6706ef43aebdc0Ted Kremenek 929cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl QualType getAllocatedType() const { 930cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl assert(getType()->isPointerType()); 9316217b80b7a1379b74cced1c076338262c3c980b3Ted Kremenek return getType()->getAs<PointerType>()->getPointeeType(); 932cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl } 9334c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 9341bb2a93ab7b1499dda6f6b58865bd0dce1864228Douglas Gregor TypeSourceInfo *getAllocatedTypeSourceInfo() const { 9351bb2a93ab7b1499dda6f6b58865bd0dce1864228Douglas Gregor return AllocatedTypeInfo; 9361bb2a93ab7b1499dda6f6b58865bd0dce1864228Douglas Gregor } 9371bb2a93ab7b1499dda6f6b58865bd0dce1864228Douglas Gregor 9384c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl FunctionDecl *getOperatorNew() const { return OperatorNew; } 9395921863d8f24084797863b5df37842113bac4352Chris Lattner void setOperatorNew(FunctionDecl *D) { OperatorNew = D; } 9404c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl FunctionDecl *getOperatorDelete() const { return OperatorDelete; } 9415921863d8f24084797863b5df37842113bac4352Chris Lattner void setOperatorDelete(FunctionDecl *D) { OperatorDelete = D; } 9424c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl CXXConstructorDecl *getConstructor() const { return Constructor; } 9435921863d8f24084797863b5df37842113bac4352Chris Lattner void setConstructor(CXXConstructorDecl *D) { Constructor = D; } 9444c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 945cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl bool isArray() const { return Array; } 946cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl Expr *getArraySize() { 947cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl return Array ? cast<Expr>(SubExprs[0]) : 0; 948cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl } 949cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl const Expr *getArraySize() const { 950cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl return Array ? cast<Expr>(SubExprs[0]) : 0; 951cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl } 952cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl 9534c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl unsigned getNumPlacementArgs() const { return NumPlacementArgs; } 9544c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl Expr *getPlacementArg(unsigned i) { 9554c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl assert(i < NumPlacementArgs && "Index out of range"); 956cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl return cast<Expr>(SubExprs[Array + i]); 9574c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 9584c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl const Expr *getPlacementArg(unsigned i) const { 9594c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl assert(i < NumPlacementArgs && "Index out of range"); 960cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl return cast<Expr>(SubExprs[Array + i]); 9614c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 9624c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 9634bd40318cbea15310a37343db46de96c4fcc15e6Douglas Gregor bool isParenTypeId() const { return TypeIdParens.isValid(); } 9644bd40318cbea15310a37343db46de96c4fcc15e6Douglas Gregor SourceRange getTypeIdParens() const { return TypeIdParens; } 9654bd40318cbea15310a37343db46de96c4fcc15e6Douglas Gregor 9664c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl bool isGlobalNew() const { return GlobalNew; } 9675921863d8f24084797863b5df37842113bac4352Chris Lattner void setGlobalNew(bool V) { GlobalNew = V; } 9684c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl bool hasInitializer() const { return Initializer; } 9695921863d8f24084797863b5df37842113bac4352Chris Lattner void setHasInitializer(bool V) { Initializer = V; } 9704c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 9714c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl unsigned getNumConstructorArgs() const { return NumConstructorArgs; } 9724c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl Expr *getConstructorArg(unsigned i) { 9734c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl assert(i < NumConstructorArgs && "Index out of range"); 974cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl return cast<Expr>(SubExprs[Array + NumPlacementArgs + i]); 9754c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 9764c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl const Expr *getConstructorArg(unsigned i) const { 9774c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl assert(i < NumConstructorArgs && "Index out of range"); 978cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl return cast<Expr>(SubExprs[Array + NumPlacementArgs + i]); 9794c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 9804c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 9814c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl typedef ExprIterator arg_iterator; 9824c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl typedef ConstExprIterator const_arg_iterator; 9834c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 9844c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl arg_iterator placement_arg_begin() { 985cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl return SubExprs + Array; 9864c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 9874c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl arg_iterator placement_arg_end() { 988cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl return SubExprs + Array + getNumPlacementArgs(); 9894c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 9904c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl const_arg_iterator placement_arg_begin() const { 991cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl return SubExprs + Array; 9924c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 9934c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl const_arg_iterator placement_arg_end() const { 994cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl return SubExprs + Array + getNumPlacementArgs(); 9954c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 9964c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 9974c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl arg_iterator constructor_arg_begin() { 998cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl return SubExprs + Array + getNumPlacementArgs(); 9994c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 10004c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl arg_iterator constructor_arg_end() { 1001cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl return SubExprs + Array + getNumPlacementArgs() + getNumConstructorArgs(); 10024c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 10034c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl const_arg_iterator constructor_arg_begin() const { 1004cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl return SubExprs + Array + getNumPlacementArgs(); 10054c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 10064c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl const_arg_iterator constructor_arg_end() const { 1007cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl return SubExprs + Array + getNumPlacementArgs() + getNumConstructorArgs(); 10084c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 10095921863d8f24084797863b5df37842113bac4352Chris Lattner 10105921863d8f24084797863b5df37842113bac4352Chris Lattner typedef Stmt **raw_arg_iterator; 10115921863d8f24084797863b5df37842113bac4352Chris Lattner raw_arg_iterator raw_arg_begin() { return SubExprs; } 10125921863d8f24084797863b5df37842113bac4352Chris Lattner raw_arg_iterator raw_arg_end() { 10135921863d8f24084797863b5df37842113bac4352Chris Lattner return SubExprs + Array + getNumPlacementArgs() + getNumConstructorArgs(); 10145921863d8f24084797863b5df37842113bac4352Chris Lattner } 10155921863d8f24084797863b5df37842113bac4352Chris Lattner const_arg_iterator raw_arg_begin() const { return SubExprs; } 10165921863d8f24084797863b5df37842113bac4352Chris Lattner const_arg_iterator raw_arg_end() const { return constructor_arg_end(); } 10174c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 10185921863d8f24084797863b5df37842113bac4352Chris Lattner 10195921863d8f24084797863b5df37842113bac4352Chris Lattner SourceLocation getStartLoc() const { return StartLoc; } 10205921863d8f24084797863b5df37842113bac4352Chris Lattner void setStartLoc(SourceLocation L) { StartLoc = L; } 10215921863d8f24084797863b5df37842113bac4352Chris Lattner SourceLocation getEndLoc() const { return EndLoc; } 10225921863d8f24084797863b5df37842113bac4352Chris Lattner void setEndLoc(SourceLocation L) { EndLoc = L; } 10235921863d8f24084797863b5df37842113bac4352Chris Lattner 10244c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl virtual SourceRange getSourceRange() const { 10254c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl return SourceRange(StartLoc, EndLoc); 10264c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 10274c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 10284c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl static bool classof(const Stmt *T) { 10294c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl return T->getStmtClass() == CXXNewExprClass; 10304c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 10314c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl static bool classof(const CXXNewExpr *) { return true; } 10324c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 10334c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // Iterators 10344c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl virtual child_iterator child_begin(); 10354c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl virtual child_iterator child_end(); 10364c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl}; 10374c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 10384c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl/// CXXDeleteExpr - A delete expression for memory deallocation and destructor 10394c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl/// calls, e.g. "delete[] pArray". 10404c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redlclass CXXDeleteExpr : public Expr { 10414c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // Is this a forced global delete, i.e. "::delete"? 10424c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl bool GlobalDelete : 1; 10434c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // Is this the array form of delete, i.e. "delete[]"? 10444c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl bool ArrayForm : 1; 10454c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // Points to the operator delete overload that is used. Could be a member. 10464c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl FunctionDecl *OperatorDelete; 10474c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // The pointer expression to be deleted. 10484c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl Stmt *Argument; 10494c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // Location of the expression. 10504c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl SourceLocation Loc; 10514c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redlpublic: 10524c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl CXXDeleteExpr(QualType ty, bool globalDelete, bool arrayForm, 10534c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl FunctionDecl *operatorDelete, Expr *arg, SourceLocation loc) 10542850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl : Expr(CXXDeleteExprClass, ty, false, false), GlobalDelete(globalDelete), 10554c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl ArrayForm(arrayForm), OperatorDelete(operatorDelete), Argument(arg), 10564c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl Loc(loc) { } 105795fc98ce95d4faa4f1bb2783384150530404ea6fArgyrios Kyrtzidis explicit CXXDeleteExpr(EmptyShell Shell) 105895fc98ce95d4faa4f1bb2783384150530404ea6fArgyrios Kyrtzidis : Expr(CXXDeleteExprClass, Shell), OperatorDelete(0), Argument(0) { } 10594c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 10604c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl bool isGlobalDelete() const { return GlobalDelete; } 10614c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl bool isArrayForm() const { return ArrayForm; } 106295fc98ce95d4faa4f1bb2783384150530404ea6fArgyrios Kyrtzidis 106395fc98ce95d4faa4f1bb2783384150530404ea6fArgyrios Kyrtzidis void setGlobalDelete(bool V) { GlobalDelete = V; } 106495fc98ce95d4faa4f1bb2783384150530404ea6fArgyrios Kyrtzidis void setArrayForm(bool V) { ArrayForm = V; } 10654c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 10664c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl FunctionDecl *getOperatorDelete() const { return OperatorDelete; } 106795fc98ce95d4faa4f1bb2783384150530404ea6fArgyrios Kyrtzidis void setOperatorDelete(FunctionDecl *D) { OperatorDelete = D; } 10684c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 10694c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl Expr *getArgument() { return cast<Expr>(Argument); } 10704c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl const Expr *getArgument() const { return cast<Expr>(Argument); } 107195fc98ce95d4faa4f1bb2783384150530404ea6fArgyrios Kyrtzidis void setArgument(Expr *E) { Argument = E; } 10724c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 10734c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl virtual SourceRange getSourceRange() const { 10744c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl return SourceRange(Loc, Argument->getLocEnd()); 10754c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 107695fc98ce95d4faa4f1bb2783384150530404ea6fArgyrios Kyrtzidis void setStartLoc(SourceLocation L) { Loc = L; } 10774c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 10784c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl static bool classof(const Stmt *T) { 10794c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl return T->getStmtClass() == CXXDeleteExprClass; 10804c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 10814c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl static bool classof(const CXXDeleteExpr *) { return true; } 10824c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 10834c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // Iterators 10844c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl virtual child_iterator child_begin(); 10854c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl virtual child_iterator child_end(); 10864c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl}; 10874c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 1088a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor/// \brief Structure used to store the type being destroyed by a 1089a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor/// pseudo-destructor expression. 1090a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregorclass PseudoDestructorTypeStorage { 1091a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor /// \brief Either the type source information or the name of the type, if 1092a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor /// it couldn't be resolved due to type-dependence. 1093a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor llvm::PointerUnion<TypeSourceInfo *, IdentifierInfo *> Type; 1094a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor 1095a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor /// \brief The starting source location of the pseudo-destructor type. 1096a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor SourceLocation Location; 1097a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor 1098a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregorpublic: 1099a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor PseudoDestructorTypeStorage() { } 1100a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor 1101a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor PseudoDestructorTypeStorage(IdentifierInfo *II, SourceLocation Loc) 1102a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor : Type(II), Location(Loc) { } 1103a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor 1104a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor PseudoDestructorTypeStorage(TypeSourceInfo *Info); 1105a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor 1106a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor TypeSourceInfo *getTypeSourceInfo() const { 1107a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor return Type.dyn_cast<TypeSourceInfo *>(); 1108a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor } 1109a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor 1110a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor IdentifierInfo *getIdentifier() const { 1111a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor return Type.dyn_cast<IdentifierInfo *>(); 1112a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor } 1113a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor 1114a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor SourceLocation getLocation() const { return Location; } 1115a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor}; 1116a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor 1117a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor/// \brief Represents a C++ pseudo-destructor (C++ [expr.pseudo]). 1118a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor/// 1119e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor/// A pseudo-destructor is an expression that looks like a member access to a 1120e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor/// destructor of a scalar type, except that scalar types don't have 1121e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor/// destructors. For example: 1122e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor/// 1123e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor/// \code 1124e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor/// typedef int T; 1125e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor/// void f(int *p) { 1126e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor/// p->T::~T(); 1127e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor/// } 1128e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor/// \endcode 1129a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor/// 1130e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor/// Pseudo-destructors typically occur when instantiating templates such as: 1131e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor/// 1132a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor/// \code 11331eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump/// template<typename T> 1134a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor/// void destroy(T* ptr) { 1135e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor/// ptr->T::~T(); 1136a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor/// } 1137a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor/// \endcode 1138a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor/// 1139e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor/// for scalar types. A pseudo-destructor expression has no run-time semantics 1140e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor/// beyond evaluating the base expression. 1141a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregorclass CXXPseudoDestructorExpr : public Expr { 1142a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor /// \brief The base expression (that is being destroyed). 1143a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor Stmt *Base; 11441eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1145a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor /// \brief Whether the operator was an arrow ('->'); otherwise, it was a 1146a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor /// period ('.'). 1147a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor bool IsArrow : 1; 11481eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1149a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor /// \brief The location of the '.' or '->' operator. 1150a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor SourceLocation OperatorLoc; 11511eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1152a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor /// \brief The nested-name-specifier that follows the operator, if present. 1153a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor NestedNameSpecifier *Qualifier; 11541eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 11551eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump /// \brief The source range that covers the nested-name-specifier, if 1156a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor /// present. 1157a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor SourceRange QualifierRange; 11581eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1159e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor /// \brief The type that precedes the '::' in a qualified pseudo-destructor 1160e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor /// expression. 1161e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor TypeSourceInfo *ScopeType; 1162e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor 1163e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor /// \brief The location of the '::' in a qualified pseudo-destructor 1164e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor /// expression. 1165e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor SourceLocation ColonColonLoc; 1166e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor 1167fce46ee68f779e239826e69e45d01d4c8e5323caDouglas Gregor /// \brief The location of the '~'. 1168fce46ee68f779e239826e69e45d01d4c8e5323caDouglas Gregor SourceLocation TildeLoc; 1169fce46ee68f779e239826e69e45d01d4c8e5323caDouglas Gregor 1170a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor /// \brief The type being destroyed, or its name if we were unable to 1171a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor /// resolve the name. 1172a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor PseudoDestructorTypeStorage DestroyedType; 11731eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1174a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregorpublic: 1175a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor CXXPseudoDestructorExpr(ASTContext &Context, 1176a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor Expr *Base, bool isArrow, SourceLocation OperatorLoc, 1177a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor NestedNameSpecifier *Qualifier, 1178a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor SourceRange QualifierRange, 1179e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor TypeSourceInfo *ScopeType, 1180e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor SourceLocation ColonColonLoc, 1181fce46ee68f779e239826e69e45d01d4c8e5323caDouglas Gregor SourceLocation TildeLoc, 1182a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor PseudoDestructorTypeStorage DestroyedType) 11831eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump : Expr(CXXPseudoDestructorExprClass, 1184a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor Context.getPointerType(Context.getFunctionType(Context.VoidTy, 0, 0, 1185ce056bcaa1c97b89a4b2de2112c62d060863be2bDouglas Gregor false, 0, false, 1186264ba48dc98f3f843935a485d5b086f7e0fdc4f1Rafael Espindola false, 0, 0, 1187264ba48dc98f3f843935a485d5b086f7e0fdc4f1Rafael Espindola FunctionType::ExtInfo())), 118826d4ac97fb514bb60c2536eae6f203dc569159d9Douglas Gregor /*isTypeDependent=*/(Base->isTypeDependent() || 1189a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor (DestroyedType.getTypeSourceInfo() && 1190a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor DestroyedType.getTypeSourceInfo()->getType()->isDependentType())), 1191a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor /*isValueDependent=*/Base->isValueDependent()), 11921eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump Base(static_cast<Stmt *>(Base)), IsArrow(isArrow), 1193a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor OperatorLoc(OperatorLoc), Qualifier(Qualifier), 1194e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor QualifierRange(QualifierRange), 1195fce46ee68f779e239826e69e45d01d4c8e5323caDouglas Gregor ScopeType(ScopeType), ColonColonLoc(ColonColonLoc), TildeLoc(TildeLoc), 119626d4ac97fb514bb60c2536eae6f203dc569159d9Douglas Gregor DestroyedType(DestroyedType) { } 11971eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1198de4bd18bb45a1db68996cfb949db3015fc25d10dArgyrios Kyrtzidis explicit CXXPseudoDestructorExpr(EmptyShell Shell) 1199de4bd18bb45a1db68996cfb949db3015fc25d10dArgyrios Kyrtzidis : Expr(CXXPseudoDestructorExprClass, Shell), 1200de4bd18bb45a1db68996cfb949db3015fc25d10dArgyrios Kyrtzidis Base(0), IsArrow(false), Qualifier(0), ScopeType(0) { } 1201de4bd18bb45a1db68996cfb949db3015fc25d10dArgyrios Kyrtzidis 1202a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor void setBase(Expr *E) { Base = E; } 1203a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor Expr *getBase() const { return cast<Expr>(Base); } 12041eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 12051eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump /// \brief Determines whether this member expression actually had 1206a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor /// a C++ nested-name-specifier prior to the name of the member, e.g., 1207a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor /// x->Base::foo. 1208a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor bool hasQualifier() const { return Qualifier != 0; } 12091eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1210a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor /// \brief If the member name was qualified, retrieves the source range of 1211a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor /// the nested-name-specifier that precedes the member name. Otherwise, 1212a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor /// returns an empty source range. 1213a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor SourceRange getQualifierRange() const { return QualifierRange; } 1214de4bd18bb45a1db68996cfb949db3015fc25d10dArgyrios Kyrtzidis void setQualifierRange(SourceRange R) { QualifierRange = R; } 12151eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 12161eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump /// \brief If the member name was qualified, retrieves the 1217a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor /// nested-name-specifier that precedes the member name. Otherwise, returns 1218a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor /// NULL. 1219a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor NestedNameSpecifier *getQualifier() const { return Qualifier; } 1220de4bd18bb45a1db68996cfb949db3015fc25d10dArgyrios Kyrtzidis void setQualifier(NestedNameSpecifier *NNS) { Qualifier = NNS; } 12211eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1222a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor /// \brief Determine whether this pseudo-destructor expression was written 1223a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor /// using an '->' (otherwise, it used a '.'). 1224a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor bool isArrow() const { return IsArrow; } 1225a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor void setArrow(bool A) { IsArrow = A; } 1226a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor 1227a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor /// \brief Retrieve the location of the '.' or '->' operator. 1228a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor SourceLocation getOperatorLoc() const { return OperatorLoc; } 1229de4bd18bb45a1db68996cfb949db3015fc25d10dArgyrios Kyrtzidis void setOperatorLoc(SourceLocation L) { OperatorLoc = L; } 12301eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1231e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor /// \brief Retrieve the scope type in a qualified pseudo-destructor 1232e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor /// expression. 1233e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor /// 1234e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor /// Pseudo-destructor expressions can have extra qualification within them 1235e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor /// that is not part of the nested-name-specifier, e.g., \c p->T::~T(). 1236e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor /// Here, if the object type of the expression is (or may be) a scalar type, 1237e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor /// \p T may also be a scalar type and, therefore, cannot be part of a 1238e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor /// nested-name-specifier. It is stored as the "scope type" of the pseudo- 1239e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor /// destructor expression. 124026d4ac97fb514bb60c2536eae6f203dc569159d9Douglas Gregor TypeSourceInfo *getScopeTypeInfo() const { return ScopeType; } 1241de4bd18bb45a1db68996cfb949db3015fc25d10dArgyrios Kyrtzidis void setScopeTypeInfo(TypeSourceInfo *Info) { ScopeType = Info; } 1242e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor 1243e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor /// \brief Retrieve the location of the '::' in a qualified pseudo-destructor 1244e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor /// expression. 1245e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor SourceLocation getColonColonLoc() const { return ColonColonLoc; } 1246de4bd18bb45a1db68996cfb949db3015fc25d10dArgyrios Kyrtzidis void setColonColonLoc(SourceLocation L) { ColonColonLoc = L; } 1247e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor 1248fce46ee68f779e239826e69e45d01d4c8e5323caDouglas Gregor /// \brief Retrieve the location of the '~'. 1249fce46ee68f779e239826e69e45d01d4c8e5323caDouglas Gregor SourceLocation getTildeLoc() const { return TildeLoc; } 1250de4bd18bb45a1db68996cfb949db3015fc25d10dArgyrios Kyrtzidis void setTildeLoc(SourceLocation L) { TildeLoc = L; } 1251fce46ee68f779e239826e69e45d01d4c8e5323caDouglas Gregor 125226d4ac97fb514bb60c2536eae6f203dc569159d9Douglas Gregor /// \brief Retrieve the source location information for the type 125326d4ac97fb514bb60c2536eae6f203dc569159d9Douglas Gregor /// being destroyed. 1254a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor /// 1255a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor /// This type-source information is available for non-dependent 1256a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor /// pseudo-destructor expressions and some dependent pseudo-destructor 1257a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor /// expressions. Returns NULL if we only have the identifier for a 1258a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor /// dependent pseudo-destructor expression. 1259a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor TypeSourceInfo *getDestroyedTypeInfo() const { 1260a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor return DestroyedType.getTypeSourceInfo(); 1261a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor } 1262a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor 1263a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor /// \brief In a dependent pseudo-destructor expression for which we do not 1264a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor /// have full type information on the destroyed type, provides the name 1265a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor /// of the destroyed type. 1266a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor IdentifierInfo *getDestroyedTypeIdentifier() const { 1267a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor return DestroyedType.getIdentifier(); 1268a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor } 1269a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor 1270a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor /// \brief Retrieve the type being destroyed. 1271a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor QualType getDestroyedType() const; 1272a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor 1273a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor /// \brief Retrieve the starting location of the type being destroyed. 1274a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor SourceLocation getDestroyedTypeLoc() const { 1275a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor return DestroyedType.getLocation(); 1276a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor } 12771eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1278de4bd18bb45a1db68996cfb949db3015fc25d10dArgyrios Kyrtzidis /// \brief Set the name of destroyed type for a dependent pseudo-destructor 1279de4bd18bb45a1db68996cfb949db3015fc25d10dArgyrios Kyrtzidis /// expression. 1280de4bd18bb45a1db68996cfb949db3015fc25d10dArgyrios Kyrtzidis void setDestroyedType(IdentifierInfo *II, SourceLocation Loc) { 1281de4bd18bb45a1db68996cfb949db3015fc25d10dArgyrios Kyrtzidis DestroyedType = PseudoDestructorTypeStorage(II, Loc); 1282de4bd18bb45a1db68996cfb949db3015fc25d10dArgyrios Kyrtzidis } 1283de4bd18bb45a1db68996cfb949db3015fc25d10dArgyrios Kyrtzidis 1284de4bd18bb45a1db68996cfb949db3015fc25d10dArgyrios Kyrtzidis /// \brief Set the destroyed type. 1285de4bd18bb45a1db68996cfb949db3015fc25d10dArgyrios Kyrtzidis void setDestroyedType(TypeSourceInfo *Info) { 1286de4bd18bb45a1db68996cfb949db3015fc25d10dArgyrios Kyrtzidis DestroyedType = PseudoDestructorTypeStorage(Info); 1287de4bd18bb45a1db68996cfb949db3015fc25d10dArgyrios Kyrtzidis } 1288de4bd18bb45a1db68996cfb949db3015fc25d10dArgyrios Kyrtzidis 128926d4ac97fb514bb60c2536eae6f203dc569159d9Douglas Gregor virtual SourceRange getSourceRange() const; 12901eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 12911eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump static bool classof(const Stmt *T) { 1292a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor return T->getStmtClass() == CXXPseudoDestructorExprClass; 1293a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor } 1294a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor static bool classof(const CXXPseudoDestructorExpr *) { return true; } 12951eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1296a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor // Iterators 1297a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor virtual child_iterator child_begin(); 12981eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump virtual child_iterator child_end(); 1299a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor}; 13001eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 130164b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl/// UnaryTypeTraitExpr - A GCC or MS unary type trait, as used in the 130264b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl/// implementation of TR1/C++0x type trait templates. 130364b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl/// Example: 130464b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl/// __is_pod(int) == true 130564b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl/// __is_enum(std::string) == false 130664b45f7e0d3167f040841ac2920aead7f080730dSebastian Redlclass UnaryTypeTraitExpr : public Expr { 130764b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl /// UTT - The trait. 130864b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl UnaryTypeTrait UTT; 130964b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl 131064b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl /// Loc - The location of the type trait keyword. 131164b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl SourceLocation Loc; 131264b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl 131364b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl /// RParen - The location of the closing paren. 131464b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl SourceLocation RParen; 131564b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl 131664b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl /// QueriedType - The type we're testing. 131764b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl QualType QueriedType; 131864b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl 131964b45f7e0d3167f040841ac2920aead7f080730dSebastian Redlpublic: 132064b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl UnaryTypeTraitExpr(SourceLocation loc, UnaryTypeTrait utt, QualType queried, 132164b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl SourceLocation rparen, QualType ty) 132264b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl : Expr(UnaryTypeTraitExprClass, ty, false, queried->isDependentType()), 132364b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl UTT(utt), Loc(loc), RParen(rparen), QueriedType(queried) { } 132464b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl 13256d00c1365dd3601f6d93bbda9162913c57ae788fArgyrios Kyrtzidis explicit UnaryTypeTraitExpr(EmptyShell Empty) 13266d00c1365dd3601f6d93bbda9162913c57ae788fArgyrios Kyrtzidis : Expr(UnaryTypeTraitExprClass, Empty), UTT((UnaryTypeTrait)0) { } 13276d00c1365dd3601f6d93bbda9162913c57ae788fArgyrios Kyrtzidis 132864b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl virtual SourceRange getSourceRange() const { return SourceRange(Loc, RParen);} 132964b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl 133064b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl UnaryTypeTrait getTrait() const { return UTT; } 133164b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl 133264b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl QualType getQueriedType() const { return QueriedType; } 133364b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl 13345e03f9ea8174ae588c5e69ec6b5ef4c68f8fd766Douglas Gregor bool EvaluateTrait(ASTContext&) const; 133564b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl 133664b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl static bool classof(const Stmt *T) { 133764b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl return T->getStmtClass() == UnaryTypeTraitExprClass; 133864b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl } 133964b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl static bool classof(const UnaryTypeTraitExpr *) { return true; } 134064b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl 134164b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl // Iterators 134264b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl virtual child_iterator child_begin(); 134364b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl virtual child_iterator child_end(); 13446d00c1365dd3601f6d93bbda9162913c57ae788fArgyrios Kyrtzidis 134560adf4acf40b72227740bf966fb87eebddff3f37Sebastian Redl friend class ASTStmtReader; 134664b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl}; 134764b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl 13487bb12da2b0749eeebb21854c77877736969e59f2John McCall/// \brief A reference to an overloaded function set, either an 13497bb12da2b0749eeebb21854c77877736969e59f2John McCall/// \t UnresolvedLookupExpr or an \t UnresolvedMemberExpr. 13507bb12da2b0749eeebb21854c77877736969e59f2John McCallclass OverloadExpr : public Expr { 1351ba13543329afac4a0d01304ec2ec4924d99306a6John McCall /// The results. These are undesugared, which is to say, they may 13527bb12da2b0749eeebb21854c77877736969e59f2John McCall /// include UsingShadowDecls. Access is relative to the naming 13537bb12da2b0749eeebb21854c77877736969e59f2John McCall /// class. 1354928e6fcf66fc4f342bcf7cc96bf56986c9c2a833Douglas Gregor // FIXME: Allocate this data after the OverloadExpr subclass. 1355928e6fcf66fc4f342bcf7cc96bf56986c9c2a833Douglas Gregor DeclAccessPair *Results; 1356928e6fcf66fc4f342bcf7cc96bf56986c9c2a833Douglas Gregor unsigned NumResults; 1357ba13543329afac4a0d01304ec2ec4924d99306a6John McCall 13587bb12da2b0749eeebb21854c77877736969e59f2John McCall /// The common name of these declarations. 13592577743c5650c646fb705df01403707e94f2df04Abramo Bagnara DeclarationNameInfo NameInfo; 1360ba13543329afac4a0d01304ec2ec4924d99306a6John McCall 13617bb12da2b0749eeebb21854c77877736969e59f2John McCall /// The scope specifier, if any. 1362ba13543329afac4a0d01304ec2ec4924d99306a6John McCall NestedNameSpecifier *Qualifier; 13637bb12da2b0749eeebb21854c77877736969e59f2John McCall 13647bb12da2b0749eeebb21854c77877736969e59f2John McCall /// The source range of the scope specifier. 1365ba13543329afac4a0d01304ec2ec4924d99306a6John McCall SourceRange QualifierRange; 1366ba13543329afac4a0d01304ec2ec4924d99306a6John McCall 1367a77eb0862507b900a10fa352af1568e639ed10b1Argyrios Kyrtzidisprotected: 13687bb12da2b0749eeebb21854c77877736969e59f2John McCall /// True if the name was a template-id. 13697bb12da2b0749eeebb21854c77877736969e59f2John McCall bool HasExplicitTemplateArgs; 13707bb12da2b0749eeebb21854c77877736969e59f2John McCall 1371928e6fcf66fc4f342bcf7cc96bf56986c9c2a833Douglas Gregor OverloadExpr(StmtClass K, ASTContext &C, QualType T, bool Dependent, 13727bb12da2b0749eeebb21854c77877736969e59f2John McCall NestedNameSpecifier *Qualifier, SourceRange QRange, 13732577743c5650c646fb705df01403707e94f2df04Abramo Bagnara const DeclarationNameInfo &NameInfo, 13745a84dec38cfa9e084377a3167b474c79283c82faDouglas Gregor bool HasTemplateArgs, 1375928e6fcf66fc4f342bcf7cc96bf56986c9c2a833Douglas Gregor UnresolvedSetIterator Begin, UnresolvedSetIterator End); 13767bb12da2b0749eeebb21854c77877736969e59f2John McCall 1377a77eb0862507b900a10fa352af1568e639ed10b1Argyrios Kyrtzidis OverloadExpr(StmtClass K, EmptyShell Empty) 1378a77eb0862507b900a10fa352af1568e639ed10b1Argyrios Kyrtzidis : Expr(K, Empty), Results(0), NumResults(0), 1379a77eb0862507b900a10fa352af1568e639ed10b1Argyrios Kyrtzidis Qualifier(0), HasExplicitTemplateArgs(false) { } 1380a77eb0862507b900a10fa352af1568e639ed10b1Argyrios Kyrtzidis 13817bb12da2b0749eeebb21854c77877736969e59f2John McCallpublic: 13827bb12da2b0749eeebb21854c77877736969e59f2John McCall /// Computes whether an unresolved lookup on the given declarations 13837bb12da2b0749eeebb21854c77877736969e59f2John McCall /// and optional template arguments is type- and value-dependent. 13847bb12da2b0749eeebb21854c77877736969e59f2John McCall static bool ComputeDependence(UnresolvedSetIterator Begin, 13857bb12da2b0749eeebb21854c77877736969e59f2John McCall UnresolvedSetIterator End, 13867bb12da2b0749eeebb21854c77877736969e59f2John McCall const TemplateArgumentListInfo *Args); 13877bb12da2b0749eeebb21854c77877736969e59f2John McCall 13889c72c6088d591ace8503b842d39448c2040f3033John McCall struct FindResult { 13899c72c6088d591ace8503b842d39448c2040f3033John McCall OverloadExpr *Expression; 13909c72c6088d591ace8503b842d39448c2040f3033John McCall bool IsAddressOfOperand; 13919c72c6088d591ace8503b842d39448c2040f3033John McCall bool HasFormOfMemberPointer; 13929c72c6088d591ace8503b842d39448c2040f3033John McCall }; 13939c72c6088d591ace8503b842d39448c2040f3033John McCall 13947bb12da2b0749eeebb21854c77877736969e59f2John McCall /// Finds the overloaded expression in the given expression of 13957bb12da2b0749eeebb21854c77877736969e59f2John McCall /// OverloadTy. 13967bb12da2b0749eeebb21854c77877736969e59f2John McCall /// 13979c72c6088d591ace8503b842d39448c2040f3033John McCall /// \return the expression (which must be there) and true if it has 13989c72c6088d591ace8503b842d39448c2040f3033John McCall /// the particular form of a member pointer expression 13999c72c6088d591ace8503b842d39448c2040f3033John McCall static FindResult find(Expr *E) { 14007bb12da2b0749eeebb21854c77877736969e59f2John McCall assert(E->getType()->isSpecificBuiltinType(BuiltinType::Overload)); 14017bb12da2b0749eeebb21854c77877736969e59f2John McCall 14029c72c6088d591ace8503b842d39448c2040f3033John McCall FindResult Result; 14039c72c6088d591ace8503b842d39448c2040f3033John McCall 14047bb12da2b0749eeebb21854c77877736969e59f2John McCall E = E->IgnoreParens(); 14059c72c6088d591ace8503b842d39448c2040f3033John McCall if (isa<UnaryOperator>(E)) { 14069c72c6088d591ace8503b842d39448c2040f3033John McCall assert(cast<UnaryOperator>(E)->getOpcode() == UO_AddrOf); 14079c72c6088d591ace8503b842d39448c2040f3033John McCall E = cast<UnaryOperator>(E)->getSubExpr(); 14089c72c6088d591ace8503b842d39448c2040f3033John McCall OverloadExpr *Ovl = cast<OverloadExpr>(E->IgnoreParens()); 14099c72c6088d591ace8503b842d39448c2040f3033John McCall 14109c72c6088d591ace8503b842d39448c2040f3033John McCall Result.HasFormOfMemberPointer = (E == Ovl && Ovl->getQualifier()); 14119c72c6088d591ace8503b842d39448c2040f3033John McCall Result.IsAddressOfOperand = true; 14129c72c6088d591ace8503b842d39448c2040f3033John McCall Result.Expression = Ovl; 14139c72c6088d591ace8503b842d39448c2040f3033John McCall } else { 14149c72c6088d591ace8503b842d39448c2040f3033John McCall Result.HasFormOfMemberPointer = false; 14159c72c6088d591ace8503b842d39448c2040f3033John McCall Result.IsAddressOfOperand = false; 14169c72c6088d591ace8503b842d39448c2040f3033John McCall Result.Expression = cast<OverloadExpr>(E); 14179c72c6088d591ace8503b842d39448c2040f3033John McCall } 14189c72c6088d591ace8503b842d39448c2040f3033John McCall 14199c72c6088d591ace8503b842d39448c2040f3033John McCall return Result; 14207bb12da2b0749eeebb21854c77877736969e59f2John McCall } 14217bb12da2b0749eeebb21854c77877736969e59f2John McCall 1422e9ee23edd17c4bb7f271e67f8790792b4de677fcJohn McCall /// Gets the naming class of this lookup, if any. 1423e9ee23edd17c4bb7f271e67f8790792b4de677fcJohn McCall CXXRecordDecl *getNamingClass() const; 1424e9ee23edd17c4bb7f271e67f8790792b4de677fcJohn McCall 14257bb12da2b0749eeebb21854c77877736969e59f2John McCall typedef UnresolvedSetImpl::iterator decls_iterator; 1426928e6fcf66fc4f342bcf7cc96bf56986c9c2a833Douglas Gregor decls_iterator decls_begin() const { return UnresolvedSetIterator(Results); } 1427928e6fcf66fc4f342bcf7cc96bf56986c9c2a833Douglas Gregor decls_iterator decls_end() const { 1428928e6fcf66fc4f342bcf7cc96bf56986c9c2a833Douglas Gregor return UnresolvedSetIterator(Results + NumResults); 1429928e6fcf66fc4f342bcf7cc96bf56986c9c2a833Douglas Gregor } 1430a77eb0862507b900a10fa352af1568e639ed10b1Argyrios Kyrtzidis 1431a77eb0862507b900a10fa352af1568e639ed10b1Argyrios Kyrtzidis void initializeResults(ASTContext &C, 1432a77eb0862507b900a10fa352af1568e639ed10b1Argyrios Kyrtzidis UnresolvedSetIterator Begin,UnresolvedSetIterator End); 14337bb12da2b0749eeebb21854c77877736969e59f2John McCall 14347bb12da2b0749eeebb21854c77877736969e59f2John McCall /// Gets the number of declarations in the unresolved set. 1435928e6fcf66fc4f342bcf7cc96bf56986c9c2a833Douglas Gregor unsigned getNumDecls() const { return NumResults; } 14367bb12da2b0749eeebb21854c77877736969e59f2John McCall 14372577743c5650c646fb705df01403707e94f2df04Abramo Bagnara /// Gets the full name info. 14382577743c5650c646fb705df01403707e94f2df04Abramo Bagnara const DeclarationNameInfo &getNameInfo() const { return NameInfo; } 14392577743c5650c646fb705df01403707e94f2df04Abramo Bagnara void setNameInfo(const DeclarationNameInfo &N) { NameInfo = N; } 14402577743c5650c646fb705df01403707e94f2df04Abramo Bagnara 14417bb12da2b0749eeebb21854c77877736969e59f2John McCall /// Gets the name looked up. 14422577743c5650c646fb705df01403707e94f2df04Abramo Bagnara DeclarationName getName() const { return NameInfo.getName(); } 14432577743c5650c646fb705df01403707e94f2df04Abramo Bagnara void setName(DeclarationName N) { NameInfo.setName(N); } 14447bb12da2b0749eeebb21854c77877736969e59f2John McCall 14457bb12da2b0749eeebb21854c77877736969e59f2John McCall /// Gets the location of the name. 14462577743c5650c646fb705df01403707e94f2df04Abramo Bagnara SourceLocation getNameLoc() const { return NameInfo.getLoc(); } 14472577743c5650c646fb705df01403707e94f2df04Abramo Bagnara void setNameLoc(SourceLocation Loc) { NameInfo.setLoc(Loc); } 14487bb12da2b0749eeebb21854c77877736969e59f2John McCall 14497bb12da2b0749eeebb21854c77877736969e59f2John McCall /// Fetches the nested-name qualifier, if one was given. 14507bb12da2b0749eeebb21854c77877736969e59f2John McCall NestedNameSpecifier *getQualifier() const { return Qualifier; } 1451a77eb0862507b900a10fa352af1568e639ed10b1Argyrios Kyrtzidis void setQualifier(NestedNameSpecifier *NNS) { Qualifier = NNS; } 14527bb12da2b0749eeebb21854c77877736969e59f2John McCall 14537bb12da2b0749eeebb21854c77877736969e59f2John McCall /// Fetches the range of the nested-name qualifier. 14547bb12da2b0749eeebb21854c77877736969e59f2John McCall SourceRange getQualifierRange() const { return QualifierRange; } 1455a77eb0862507b900a10fa352af1568e639ed10b1Argyrios Kyrtzidis void setQualifierRange(SourceRange R) { QualifierRange = R; } 14567bb12da2b0749eeebb21854c77877736969e59f2John McCall 14577bb12da2b0749eeebb21854c77877736969e59f2John McCall /// \brief Determines whether this expression had an explicit 14587bb12da2b0749eeebb21854c77877736969e59f2John McCall /// template argument list, e.g. f<int>. 14597bb12da2b0749eeebb21854c77877736969e59f2John McCall bool hasExplicitTemplateArgs() const { return HasExplicitTemplateArgs; } 14607bb12da2b0749eeebb21854c77877736969e59f2John McCall 14617bb12da2b0749eeebb21854c77877736969e59f2John McCall ExplicitTemplateArgumentList &getExplicitTemplateArgs(); // defined far below 14627bb12da2b0749eeebb21854c77877736969e59f2John McCall 14637bb12da2b0749eeebb21854c77877736969e59f2John McCall const ExplicitTemplateArgumentList &getExplicitTemplateArgs() const { 14647bb12da2b0749eeebb21854c77877736969e59f2John McCall return const_cast<OverloadExpr*>(this)->getExplicitTemplateArgs(); 14657bb12da2b0749eeebb21854c77877736969e59f2John McCall } 14667bb12da2b0749eeebb21854c77877736969e59f2John McCall 1467096832c5ed5b9106fa177ebc148489760c3bc496John McCall /// \brief Retrieves the optional explicit template arguments. 1468096832c5ed5b9106fa177ebc148489760c3bc496John McCall /// This points to the same data as getExplicitTemplateArgs(), but 1469096832c5ed5b9106fa177ebc148489760c3bc496John McCall /// returns null if there are no explicit template arguments. 1470096832c5ed5b9106fa177ebc148489760c3bc496John McCall const ExplicitTemplateArgumentList *getOptionalExplicitTemplateArgs() { 1471096832c5ed5b9106fa177ebc148489760c3bc496John McCall if (!hasExplicitTemplateArgs()) return 0; 1472096832c5ed5b9106fa177ebc148489760c3bc496John McCall return &getExplicitTemplateArgs(); 14737bb12da2b0749eeebb21854c77877736969e59f2John McCall } 14747bb12da2b0749eeebb21854c77877736969e59f2John McCall 14757bb12da2b0749eeebb21854c77877736969e59f2John McCall static bool classof(const Stmt *T) { 14767bb12da2b0749eeebb21854c77877736969e59f2John McCall return T->getStmtClass() == UnresolvedLookupExprClass || 14777bb12da2b0749eeebb21854c77877736969e59f2John McCall T->getStmtClass() == UnresolvedMemberExprClass; 14787bb12da2b0749eeebb21854c77877736969e59f2John McCall } 14797bb12da2b0749eeebb21854c77877736969e59f2John McCall static bool classof(const OverloadExpr *) { return true; } 14807bb12da2b0749eeebb21854c77877736969e59f2John McCall}; 14817bb12da2b0749eeebb21854c77877736969e59f2John McCall 14827bb12da2b0749eeebb21854c77877736969e59f2John McCall/// \brief A reference to a name which we were able to look up during 14837bb12da2b0749eeebb21854c77877736969e59f2John McCall/// parsing but could not resolve to a specific declaration. This 14847bb12da2b0749eeebb21854c77877736969e59f2John McCall/// arises in several ways: 14857bb12da2b0749eeebb21854c77877736969e59f2John McCall/// * we might be waiting for argument-dependent lookup 14867bb12da2b0749eeebb21854c77877736969e59f2John McCall/// * the name might resolve to an overloaded function 14877bb12da2b0749eeebb21854c77877736969e59f2John McCall/// and eventually: 14887bb12da2b0749eeebb21854c77877736969e59f2John McCall/// * the lookup might have included a function template 14897bb12da2b0749eeebb21854c77877736969e59f2John McCall/// These never include UnresolvedUsingValueDecls, which are always 14907bb12da2b0749eeebb21854c77877736969e59f2John McCall/// class members and therefore appear only in 14917bb12da2b0749eeebb21854c77877736969e59f2John McCall/// UnresolvedMemberLookupExprs. 14927bb12da2b0749eeebb21854c77877736969e59f2John McCallclass UnresolvedLookupExpr : public OverloadExpr { 1493ba13543329afac4a0d01304ec2ec4924d99306a6John McCall /// True if these lookup results should be extended by 1494ba13543329afac4a0d01304ec2ec4924d99306a6John McCall /// argument-dependent lookup if this is the operand of a function 1495ba13543329afac4a0d01304ec2ec4924d99306a6John McCall /// call. 1496ba13543329afac4a0d01304ec2ec4924d99306a6John McCall bool RequiresADL; 1497ba13543329afac4a0d01304ec2ec4924d99306a6John McCall 14987453ed4cb2cab113de3378df371b1c6f1243d832John McCall /// True if these lookup results are overloaded. This is pretty 14997453ed4cb2cab113de3378df371b1c6f1243d832John McCall /// trivially rederivable if we urgently need to kill this field. 15007453ed4cb2cab113de3378df371b1c6f1243d832John McCall bool Overloaded; 15017453ed4cb2cab113de3378df371b1c6f1243d832John McCall 15027bb12da2b0749eeebb21854c77877736969e59f2John McCall /// The naming class (C++ [class.access.base]p5) of the lookup, if 15037bb12da2b0749eeebb21854c77877736969e59f2John McCall /// any. This can generally be recalculated from the context chain, 15047bb12da2b0749eeebb21854c77877736969e59f2John McCall /// but that can be fairly expensive for unqualified lookups. If we 15057bb12da2b0749eeebb21854c77877736969e59f2John McCall /// want to improve memory use here, this could go in a union 15067bb12da2b0749eeebb21854c77877736969e59f2John McCall /// against the qualified-lookup bits. 15077bb12da2b0749eeebb21854c77877736969e59f2John McCall CXXRecordDecl *NamingClass; 1508f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall 1509928e6fcf66fc4f342bcf7cc96bf56986c9c2a833Douglas Gregor UnresolvedLookupExpr(ASTContext &C, QualType T, bool Dependent, 1510928e6fcf66fc4f342bcf7cc96bf56986c9c2a833Douglas Gregor CXXRecordDecl *NamingClass, 1511ba13543329afac4a0d01304ec2ec4924d99306a6John McCall NestedNameSpecifier *Qualifier, SourceRange QRange, 15122577743c5650c646fb705df01403707e94f2df04Abramo Bagnara const DeclarationNameInfo &NameInfo, 15135a84dec38cfa9e084377a3167b474c79283c82faDouglas Gregor bool RequiresADL, bool Overloaded, bool HasTemplateArgs, 15145a84dec38cfa9e084377a3167b474c79283c82faDouglas Gregor UnresolvedSetIterator Begin, UnresolvedSetIterator End) 1515928e6fcf66fc4f342bcf7cc96bf56986c9c2a833Douglas Gregor : OverloadExpr(UnresolvedLookupExprClass, C, T, Dependent, Qualifier, 15162577743c5650c646fb705df01403707e94f2df04Abramo Bagnara QRange, NameInfo, HasTemplateArgs, Begin, End), 15177bb12da2b0749eeebb21854c77877736969e59f2John McCall RequiresADL(RequiresADL), Overloaded(Overloaded), NamingClass(NamingClass) 1518ba13543329afac4a0d01304ec2ec4924d99306a6John McCall {} 1519ba13543329afac4a0d01304ec2ec4924d99306a6John McCall 1520bd65bb511c26549c96b829c1282e4c877588564aArgyrios Kyrtzidis UnresolvedLookupExpr(EmptyShell Empty) 1521bd65bb511c26549c96b829c1282e4c877588564aArgyrios Kyrtzidis : OverloadExpr(UnresolvedLookupExprClass, Empty), 1522bd65bb511c26549c96b829c1282e4c877588564aArgyrios Kyrtzidis RequiresADL(false), Overloaded(false), NamingClass(0) 1523bd65bb511c26549c96b829c1282e4c877588564aArgyrios Kyrtzidis {} 1524bd65bb511c26549c96b829c1282e4c877588564aArgyrios Kyrtzidis 1525ba13543329afac4a0d01304ec2ec4924d99306a6John McCallpublic: 1526ba13543329afac4a0d01304ec2ec4924d99306a6John McCall static UnresolvedLookupExpr *Create(ASTContext &C, 1527f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall bool Dependent, 1528c373d48502ca7683ab55385f5bd624d778eb288dJohn McCall CXXRecordDecl *NamingClass, 1529ba13543329afac4a0d01304ec2ec4924d99306a6John McCall NestedNameSpecifier *Qualifier, 1530ba13543329afac4a0d01304ec2ec4924d99306a6John McCall SourceRange QualifierRange, 15312577743c5650c646fb705df01403707e94f2df04Abramo Bagnara const DeclarationNameInfo &NameInfo, 15325a84dec38cfa9e084377a3167b474c79283c82faDouglas Gregor bool ADL, bool Overloaded, 15335a84dec38cfa9e084377a3167b474c79283c82faDouglas Gregor UnresolvedSetIterator Begin, 15345a84dec38cfa9e084377a3167b474c79283c82faDouglas Gregor UnresolvedSetIterator End) { 1535928e6fcf66fc4f342bcf7cc96bf56986c9c2a833Douglas Gregor return new(C) UnresolvedLookupExpr(C, 1536928e6fcf66fc4f342bcf7cc96bf56986c9c2a833Douglas Gregor Dependent ? C.DependentTy : C.OverloadTy, 1537c373d48502ca7683ab55385f5bd624d778eb288dJohn McCall Dependent, NamingClass, 15382577743c5650c646fb705df01403707e94f2df04Abramo Bagnara Qualifier, QualifierRange, NameInfo, 15392577743c5650c646fb705df01403707e94f2df04Abramo Bagnara ADL, Overloaded, false, 15405a84dec38cfa9e084377a3167b474c79283c82faDouglas Gregor Begin, End); 1541ba13543329afac4a0d01304ec2ec4924d99306a6John McCall } 1542ba13543329afac4a0d01304ec2ec4924d99306a6John McCall 1543f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall static UnresolvedLookupExpr *Create(ASTContext &C, 1544f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall bool Dependent, 1545c373d48502ca7683ab55385f5bd624d778eb288dJohn McCall CXXRecordDecl *NamingClass, 1546f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall NestedNameSpecifier *Qualifier, 1547f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall SourceRange QualifierRange, 15482577743c5650c646fb705df01403707e94f2df04Abramo Bagnara const DeclarationNameInfo &NameInfo, 1549f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall bool ADL, 15505a84dec38cfa9e084377a3167b474c79283c82faDouglas Gregor const TemplateArgumentListInfo &Args, 15515a84dec38cfa9e084377a3167b474c79283c82faDouglas Gregor UnresolvedSetIterator Begin, 15525a84dec38cfa9e084377a3167b474c79283c82faDouglas Gregor UnresolvedSetIterator End); 1553f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall 1554bd65bb511c26549c96b829c1282e4c877588564aArgyrios Kyrtzidis static UnresolvedLookupExpr *CreateEmpty(ASTContext &C, 1555bd65bb511c26549c96b829c1282e4c877588564aArgyrios Kyrtzidis unsigned NumTemplateArgs); 1556bd65bb511c26549c96b829c1282e4c877588564aArgyrios Kyrtzidis 1557ba13543329afac4a0d01304ec2ec4924d99306a6John McCall /// True if this declaration should be extended by 1558ba13543329afac4a0d01304ec2ec4924d99306a6John McCall /// argument-dependent lookup. 1559ba13543329afac4a0d01304ec2ec4924d99306a6John McCall bool requiresADL() const { return RequiresADL; } 1560bd65bb511c26549c96b829c1282e4c877588564aArgyrios Kyrtzidis void setRequiresADL(bool V) { RequiresADL = V; } 1561ba13543329afac4a0d01304ec2ec4924d99306a6John McCall 15627453ed4cb2cab113de3378df371b1c6f1243d832John McCall /// True if this lookup is overloaded. 15637453ed4cb2cab113de3378df371b1c6f1243d832John McCall bool isOverloaded() const { return Overloaded; } 1564bd65bb511c26549c96b829c1282e4c877588564aArgyrios Kyrtzidis void setOverloaded(bool V) { Overloaded = V; } 15657453ed4cb2cab113de3378df371b1c6f1243d832John McCall 1566c373d48502ca7683ab55385f5bd624d778eb288dJohn McCall /// Gets the 'naming class' (in the sense of C++0x 1567c373d48502ca7683ab55385f5bd624d778eb288dJohn McCall /// [class.access.base]p5) of the lookup. This is the scope 1568c373d48502ca7683ab55385f5bd624d778eb288dJohn McCall /// that was looked in to find these results. 1569c373d48502ca7683ab55385f5bd624d778eb288dJohn McCall CXXRecordDecl *getNamingClass() const { return NamingClass; } 1570bd65bb511c26549c96b829c1282e4c877588564aArgyrios Kyrtzidis void setNamingClass(CXXRecordDecl *D) { NamingClass = D; } 1571c373d48502ca7683ab55385f5bd624d778eb288dJohn McCall 1572f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall // Note that, inconsistently with the explicit-template-argument AST 1573f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall // nodes, users are *forbidden* from calling these methods on objects 1574f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall // without explicit template arguments. 1575f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall 15767bb12da2b0749eeebb21854c77877736969e59f2John McCall ExplicitTemplateArgumentList &getExplicitTemplateArgs() { 15777bb12da2b0749eeebb21854c77877736969e59f2John McCall assert(hasExplicitTemplateArgs()); 15787bb12da2b0749eeebb21854c77877736969e59f2John McCall return *reinterpret_cast<ExplicitTemplateArgumentList*>(this + 1); 15797bb12da2b0749eeebb21854c77877736969e59f2John McCall } 15807bb12da2b0749eeebb21854c77877736969e59f2John McCall 1581f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall /// Gets a reference to the explicit template argument list. 1582f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall const ExplicitTemplateArgumentList &getExplicitTemplateArgs() const { 1583f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall assert(hasExplicitTemplateArgs()); 1584f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall return *reinterpret_cast<const ExplicitTemplateArgumentList*>(this + 1); 1585f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall } 1586f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall 1587096832c5ed5b9106fa177ebc148489760c3bc496John McCall /// \brief Retrieves the optional explicit template arguments. 1588096832c5ed5b9106fa177ebc148489760c3bc496John McCall /// This points to the same data as getExplicitTemplateArgs(), but 1589096832c5ed5b9106fa177ebc148489760c3bc496John McCall /// returns null if there are no explicit template arguments. 1590096832c5ed5b9106fa177ebc148489760c3bc496John McCall const ExplicitTemplateArgumentList *getOptionalExplicitTemplateArgs() { 1591096832c5ed5b9106fa177ebc148489760c3bc496John McCall if (!hasExplicitTemplateArgs()) return 0; 1592096832c5ed5b9106fa177ebc148489760c3bc496John McCall return &getExplicitTemplateArgs(); 1593096832c5ed5b9106fa177ebc148489760c3bc496John McCall } 1594096832c5ed5b9106fa177ebc148489760c3bc496John McCall 1595f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall /// \brief Copies the template arguments (if present) into the given 1596f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall /// structure. 1597f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall void copyTemplateArgumentsInto(TemplateArgumentListInfo &List) const { 1598f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall getExplicitTemplateArgs().copyInto(List); 1599f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall } 1600ba13543329afac4a0d01304ec2ec4924d99306a6John McCall 1601f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall SourceLocation getLAngleLoc() const { 1602f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall return getExplicitTemplateArgs().LAngleLoc; 1603f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall } 1604f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall 1605f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall SourceLocation getRAngleLoc() const { 1606f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall return getExplicitTemplateArgs().RAngleLoc; 1607f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall } 1608f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall 1609f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall TemplateArgumentLoc const *getTemplateArgs() const { 1610f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall return getExplicitTemplateArgs().getTemplateArgs(); 1611f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall } 1612f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall 1613f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall unsigned getNumTemplateArgs() const { 1614f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall return getExplicitTemplateArgs().NumTemplateArgs; 1615f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall } 1616ba13543329afac4a0d01304ec2ec4924d99306a6John McCall 1617ba13543329afac4a0d01304ec2ec4924d99306a6John McCall virtual SourceRange getSourceRange() const { 16182577743c5650c646fb705df01403707e94f2df04Abramo Bagnara SourceRange Range(getNameInfo().getSourceRange()); 16197bb12da2b0749eeebb21854c77877736969e59f2John McCall if (getQualifier()) Range.setBegin(getQualifierRange().getBegin()); 1620f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall if (hasExplicitTemplateArgs()) Range.setEnd(getRAngleLoc()); 1621f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall return Range; 1622ba13543329afac4a0d01304ec2ec4924d99306a6John McCall } 1623ba13543329afac4a0d01304ec2ec4924d99306a6John McCall 1624ba13543329afac4a0d01304ec2ec4924d99306a6John McCall virtual StmtIterator child_begin(); 1625ba13543329afac4a0d01304ec2ec4924d99306a6John McCall virtual StmtIterator child_end(); 1626ba13543329afac4a0d01304ec2ec4924d99306a6John McCall 1627ba13543329afac4a0d01304ec2ec4924d99306a6John McCall static bool classof(const Stmt *T) { 1628ba13543329afac4a0d01304ec2ec4924d99306a6John McCall return T->getStmtClass() == UnresolvedLookupExprClass; 1629ba13543329afac4a0d01304ec2ec4924d99306a6John McCall } 1630ba13543329afac4a0d01304ec2ec4924d99306a6John McCall static bool classof(const UnresolvedLookupExpr *) { return true; } 1631ba13543329afac4a0d01304ec2ec4924d99306a6John McCall}; 1632ba13543329afac4a0d01304ec2ec4924d99306a6John McCall 16335953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor/// \brief A qualified reference to a name whose declaration cannot 16345953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor/// yet be resolved. 16355953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor/// 1636ba13543329afac4a0d01304ec2ec4924d99306a6John McCall/// DependentScopeDeclRefExpr is similar to DeclRefExpr in that 1637a2813cec2605ce7878d1b13471d685f689b251afDouglas Gregor/// it expresses a reference to a declaration such as 16385953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor/// X<T>::value. The difference, however, is that an 1639865d447ac6a4721ab58e898d014a21f2eff74b06John McCall/// DependentScopeDeclRefExpr node is used only within C++ templates when 16405953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor/// the qualification (e.g., X<T>::) refers to a dependent type. In 16415953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor/// this case, X<T>::value cannot resolve to a declaration because the 16425953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor/// declaration will differ from on instantiation of X<T> to the 1643865d447ac6a4721ab58e898d014a21f2eff74b06John McCall/// next. Therefore, DependentScopeDeclRefExpr keeps track of the 1644ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor/// qualifier (X<T>::) and the name of the entity being referenced 1645a2813cec2605ce7878d1b13471d685f689b251afDouglas Gregor/// ("value"). Such expressions will instantiate to a DeclRefExpr once the 1646a2813cec2605ce7878d1b13471d685f689b251afDouglas Gregor/// declaration can be found. 1647865d447ac6a4721ab58e898d014a21f2eff74b06John McCallclass DependentScopeDeclRefExpr : public Expr { 16485953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor /// The name of the entity we will be referencing. 16492577743c5650c646fb705df01403707e94f2df04Abramo Bagnara DeclarationNameInfo NameInfo; 16505953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor 16515953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor /// QualifierRange - The source range that covers the 16525953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor /// nested-name-specifier. 16535953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor SourceRange QualifierRange; 16545953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor 1655ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor /// \brief The nested-name-specifier that qualifies this unresolved 1656ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor /// declaration name. 1657f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall NestedNameSpecifier *Qualifier; 16585953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor 1659f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall /// \brief Whether the name includes explicit template arguments. 1660f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall bool HasExplicitTemplateArgs; 16611eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1662f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall DependentScopeDeclRefExpr(QualType T, 1663f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall NestedNameSpecifier *Qualifier, 1664f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall SourceRange QualifierRange, 16652577743c5650c646fb705df01403707e94f2df04Abramo Bagnara const DeclarationNameInfo &NameInfo, 1666f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall bool HasExplicitTemplateArgs) 1667865d447ac6a4721ab58e898d014a21f2eff74b06John McCall : Expr(DependentScopeDeclRefExprClass, T, true, true), 16682577743c5650c646fb705df01403707e94f2df04Abramo Bagnara NameInfo(NameInfo), QualifierRange(QualifierRange), Qualifier(Qualifier), 1669f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall HasExplicitTemplateArgs(HasExplicitTemplateArgs) 1670f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall {} 1671f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall 1672f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCallpublic: 1673f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall static DependentScopeDeclRefExpr *Create(ASTContext &C, 1674f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall NestedNameSpecifier *Qualifier, 1675f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall SourceRange QualifierRange, 16762577743c5650c646fb705df01403707e94f2df04Abramo Bagnara const DeclarationNameInfo &NameInfo, 1677f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall const TemplateArgumentListInfo *TemplateArgs = 0); 16785953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor 167912dffcddb60380c5bed4f085a1f51534afda3b87Argyrios Kyrtzidis static DependentScopeDeclRefExpr *CreateEmpty(ASTContext &C, 168012dffcddb60380c5bed4f085a1f51534afda3b87Argyrios Kyrtzidis unsigned NumTemplateArgs); 168112dffcddb60380c5bed4f085a1f51534afda3b87Argyrios Kyrtzidis 16825953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor /// \brief Retrieve the name that this expression refers to. 16832577743c5650c646fb705df01403707e94f2df04Abramo Bagnara const DeclarationNameInfo &getNameInfo() const { return NameInfo; } 16842577743c5650c646fb705df01403707e94f2df04Abramo Bagnara void setNameInfo(const DeclarationNameInfo &N) { NameInfo = N; } 16852577743c5650c646fb705df01403707e94f2df04Abramo Bagnara 16862577743c5650c646fb705df01403707e94f2df04Abramo Bagnara /// \brief Retrieve the name that this expression refers to. 16872577743c5650c646fb705df01403707e94f2df04Abramo Bagnara DeclarationName getDeclName() const { return NameInfo.getName(); } 16882577743c5650c646fb705df01403707e94f2df04Abramo Bagnara void setDeclName(DeclarationName N) { NameInfo.setName(N); } 16895953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor 16905953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor /// \brief Retrieve the location of the name within the expression. 16912577743c5650c646fb705df01403707e94f2df04Abramo Bagnara SourceLocation getLocation() const { return NameInfo.getLoc(); } 16922577743c5650c646fb705df01403707e94f2df04Abramo Bagnara void setLocation(SourceLocation L) { NameInfo.setLoc(L); } 16935953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor 16945953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor /// \brief Retrieve the source range of the nested-name-specifier. 16955953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor SourceRange getQualifierRange() const { return QualifierRange; } 169612dffcddb60380c5bed4f085a1f51534afda3b87Argyrios Kyrtzidis void setQualifierRange(SourceRange R) { QualifierRange = R; } 16975953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor 1698ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor /// \brief Retrieve the nested-name-specifier that qualifies this 1699ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor /// declaration. 1700edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor NestedNameSpecifier *getQualifier() const { return Qualifier; } 170112dffcddb60380c5bed4f085a1f51534afda3b87Argyrios Kyrtzidis void setQualifier(NestedNameSpecifier *NNS) { Qualifier = NNS; } 17021eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1703f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall /// Determines whether this lookup had explicit template arguments. 1704f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall bool hasExplicitTemplateArgs() const { return HasExplicitTemplateArgs; } 17051eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1706f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall // Note that, inconsistently with the explicit-template-argument AST 1707f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall // nodes, users are *forbidden* from calling these methods on objects 1708f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall // without explicit template arguments. 17091eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 171012dffcddb60380c5bed4f085a1f51534afda3b87Argyrios Kyrtzidis ExplicitTemplateArgumentList &getExplicitTemplateArgs() { 171112dffcddb60380c5bed4f085a1f51534afda3b87Argyrios Kyrtzidis assert(hasExplicitTemplateArgs()); 171212dffcddb60380c5bed4f085a1f51534afda3b87Argyrios Kyrtzidis return *reinterpret_cast<ExplicitTemplateArgumentList*>(this + 1); 171312dffcddb60380c5bed4f085a1f51534afda3b87Argyrios Kyrtzidis } 171412dffcddb60380c5bed4f085a1f51534afda3b87Argyrios Kyrtzidis 1715f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall /// Gets a reference to the explicit template argument list. 1716f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall const ExplicitTemplateArgumentList &getExplicitTemplateArgs() const { 1717f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall assert(hasExplicitTemplateArgs()); 1718f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall return *reinterpret_cast<const ExplicitTemplateArgumentList*>(this + 1); 1719f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall } 17201eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1721096832c5ed5b9106fa177ebc148489760c3bc496John McCall /// \brief Retrieves the optional explicit template arguments. 1722096832c5ed5b9106fa177ebc148489760c3bc496John McCall /// This points to the same data as getExplicitTemplateArgs(), but 1723096832c5ed5b9106fa177ebc148489760c3bc496John McCall /// returns null if there are no explicit template arguments. 1724096832c5ed5b9106fa177ebc148489760c3bc496John McCall const ExplicitTemplateArgumentList *getOptionalExplicitTemplateArgs() { 1725096832c5ed5b9106fa177ebc148489760c3bc496John McCall if (!hasExplicitTemplateArgs()) return 0; 1726096832c5ed5b9106fa177ebc148489760c3bc496John McCall return &getExplicitTemplateArgs(); 1727096832c5ed5b9106fa177ebc148489760c3bc496John McCall } 1728096832c5ed5b9106fa177ebc148489760c3bc496John McCall 1729f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall /// \brief Copies the template arguments (if present) into the given 1730f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall /// structure. 1731f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall void copyTemplateArgumentsInto(TemplateArgumentListInfo &List) const { 1732f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall getExplicitTemplateArgs().copyInto(List); 1733f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall } 1734f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall 1735f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall SourceLocation getLAngleLoc() const { 1736f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall return getExplicitTemplateArgs().LAngleLoc; 1737edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor } 17381eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1739f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall SourceLocation getRAngleLoc() const { 1740f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall return getExplicitTemplateArgs().RAngleLoc; 1741f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall } 17421eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1743f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall TemplateArgumentLoc const *getTemplateArgs() const { 1744f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall return getExplicitTemplateArgs().getTemplateArgs(); 1745d5532b6cfff2977e0c59fa6ead7f7973984a620dJohn McCall } 1746d5532b6cfff2977e0c59fa6ead7f7973984a620dJohn McCall 1747f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall unsigned getNumTemplateArgs() const { 1748f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall return getExplicitTemplateArgs().NumTemplateArgs; 1749f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall } 17501eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1751edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor virtual SourceRange getSourceRange() const { 1752f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall SourceRange Range(QualifierRange.getBegin(), getLocation()); 1753f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall if (hasExplicitTemplateArgs()) 1754f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall Range.setEnd(getRAngleLoc()); 1755f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall return Range; 1756edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor } 17571eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 17581eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump static bool classof(const Stmt *T) { 1759f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall return T->getStmtClass() == DependentScopeDeclRefExprClass; 1760edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor } 1761f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall static bool classof(const DependentScopeDeclRefExpr *) { return true; } 1762f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall 1763f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall virtual StmtIterator child_begin(); 1764f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall virtual StmtIterator child_end(); 1765edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor}; 17661eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 17672d44e8a41de8a33c0f04ac198714f71dc841bab0Anders Carlssonclass CXXExprWithTemporaries : public Expr { 176802bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson Stmt *SubExpr; 17691eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1770ff6b3d64c9f07155f1414411b8451d7bf8937c62Anders Carlsson CXXTemporary **Temps; 1771ff6b3d64c9f07155f1414411b8451d7bf8937c62Anders Carlsson unsigned NumTemps; 177202bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson 1773d04ed416be7c55bddddab1fa3fd38a0113a6b3daTed Kremenek CXXExprWithTemporaries(ASTContext &C, Expr *SubExpr, CXXTemporary **Temps, 17740ece491d8f62ce67f047491a6703fac0d3bd4ff4Anders Carlsson unsigned NumTemps); 177542602bb40aefcc2751d4078ba88aacf4d965c9bdDouglas Gregor 177688eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlssonpublic: 1777d2598368876cfe40bc8465540033bc5b5e58d8afChris Lattner CXXExprWithTemporaries(EmptyShell Empty) 1778d2598368876cfe40bc8465540033bc5b5e58d8afChris Lattner : Expr(CXXExprWithTemporariesClass, Empty), 1779d2598368876cfe40bc8465540033bc5b5e58d8afChris Lattner SubExpr(0), Temps(0), NumTemps(0) {} 1780d2598368876cfe40bc8465540033bc5b5e58d8afChris Lattner 178188eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlsson static CXXExprWithTemporaries *Create(ASTContext &C, Expr *SubExpr, 17820ece491d8f62ce67f047491a6703fac0d3bd4ff4Anders Carlsson CXXTemporary **Temps, 17830ece491d8f62ce67f047491a6703fac0d3bd4ff4Anders Carlsson unsigned NumTemps); 17841eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 178588eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlsson unsigned getNumTemporaries() const { return NumTemps; } 1786d04ed416be7c55bddddab1fa3fd38a0113a6b3daTed Kremenek void setNumTemporaries(ASTContext &C, unsigned N); 1787d2598368876cfe40bc8465540033bc5b5e58d8afChris Lattner 178888eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlsson CXXTemporary *getTemporary(unsigned i) { 178988eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlsson assert(i < NumTemps && "Index out of range"); 179088eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlsson return Temps[i]; 179188eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlsson } 1792f0721fe438d7e40c168e5d664970e7830bc138fbAnders Carlsson const CXXTemporary *getTemporary(unsigned i) const { 17930ece491d8f62ce67f047491a6703fac0d3bd4ff4Anders Carlsson return const_cast<CXXExprWithTemporaries*>(this)->getTemporary(i); 1794f0721fe438d7e40c168e5d664970e7830bc138fbAnders Carlsson } 1795d2598368876cfe40bc8465540033bc5b5e58d8afChris Lattner void setTemporary(unsigned i, CXXTemporary *T) { 1796d2598368876cfe40bc8465540033bc5b5e58d8afChris Lattner assert(i < NumTemps && "Index out of range"); 1797d2598368876cfe40bc8465540033bc5b5e58d8afChris Lattner Temps[i] = T; 1798d2598368876cfe40bc8465540033bc5b5e58d8afChris Lattner } 17991eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 180002bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson Expr *getSubExpr() { return cast<Expr>(SubExpr); } 1801f0721fe438d7e40c168e5d664970e7830bc138fbAnders Carlsson const Expr *getSubExpr() const { return cast<Expr>(SubExpr); } 180288eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlsson void setSubExpr(Expr *E) { SubExpr = E; } 180302bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson 180496be6917e1c4ba1f4435a14c9e7c6c139571d086Douglas Gregor virtual SourceRange getSourceRange() const { 180596be6917e1c4ba1f4435a14c9e7c6c139571d086Douglas Gregor return SubExpr->getSourceRange(); 180696be6917e1c4ba1f4435a14c9e7c6c139571d086Douglas Gregor } 180702bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson 180802bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson // Implement isa/cast/dyncast/etc. 180902bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson static bool classof(const Stmt *T) { 18102d44e8a41de8a33c0f04ac198714f71dc841bab0Anders Carlsson return T->getStmtClass() == CXXExprWithTemporariesClass; 181102bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson } 18122d44e8a41de8a33c0f04ac198714f71dc841bab0Anders Carlsson static bool classof(const CXXExprWithTemporaries *) { return true; } 181302bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson 181402bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson // Iterators 181502bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson virtual child_iterator child_begin(); 181602bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson virtual child_iterator child_end(); 181702bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson}; 181802bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson 1819d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// \brief Describes an explicit type conversion that uses functional 1820d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// notion but could not be resolved because one or more arguments are 1821d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// type-dependent. 1822d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// 1823d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// The explicit type conversions expressed by 1824d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// CXXUnresolvedConstructExpr have the form \c T(a1, a2, ..., aN), 1825d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// where \c T is some type and \c a1, a2, ..., aN are values, and 1826d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// either \C T is a dependent type or one or more of the \c a's is 1827d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// type-dependent. For example, this would occur in a template such 1828d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// as: 1829d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// 1830d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// \code 1831d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// template<typename T, typename A1> 1832d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// inline T make_a(const A1& a1) { 1833d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// return T(a1); 1834d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// } 1835d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// \endcode 1836d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// 1837d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// When the returned expression is instantiated, it may resolve to a 1838d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// constructor call, conversion function call, or some kind of type 1839d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// conversion. 1840d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregorclass CXXUnresolvedConstructExpr : public Expr { 1841d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor /// \brief The starting location of the type 1842d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor SourceLocation TyBeginLoc; 1843d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor 1844d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor /// \brief The type being constructed. 1845d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor QualType Type; 1846d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor 1847d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor /// \brief The location of the left parentheses ('('). 1848d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor SourceLocation LParenLoc; 1849d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor 1850d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor /// \brief The location of the right parentheses (')'). 1851d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor SourceLocation RParenLoc; 1852d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor 1853d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor /// \brief The number of arguments used to construct the type. 1854d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor unsigned NumArgs; 18551eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1856d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor CXXUnresolvedConstructExpr(SourceLocation TyBegin, 1857d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor QualType T, 1858d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor SourceLocation LParenLoc, 1859d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor Expr **Args, 1860d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor unsigned NumArgs, 1861d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor SourceLocation RParenLoc); 1862d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor 18638dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis CXXUnresolvedConstructExpr(EmptyShell Empty, unsigned NumArgs) 18648dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis : Expr(CXXUnresolvedConstructExprClass, Empty), NumArgs(NumArgs) { } 18658dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis 1866d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregorpublic: 18671eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump static CXXUnresolvedConstructExpr *Create(ASTContext &C, 1868d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor SourceLocation TyBegin, 1869d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor QualType T, 1870d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor SourceLocation LParenLoc, 1871d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor Expr **Args, 1872d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor unsigned NumArgs, 1873d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor SourceLocation RParenLoc); 1874d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor 18758dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis static CXXUnresolvedConstructExpr *CreateEmpty(ASTContext &C, 18768dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis unsigned NumArgs); 18778dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis 1878d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor /// \brief Retrieve the source location where the type begins. 1879d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor SourceLocation getTypeBeginLoc() const { return TyBeginLoc; } 1880d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor void setTypeBeginLoc(SourceLocation L) { TyBeginLoc = L; } 1881d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor 1882d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor /// \brief Retrieve the type that is being constructed, as specified 1883d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor /// in the source code. 1884d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor QualType getTypeAsWritten() const { return Type; } 1885d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor void setTypeAsWritten(QualType T) { Type = T; } 1886d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor 1887d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor /// \brief Retrieve the location of the left parentheses ('(') that 1888d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor /// precedes the argument list. 1889d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor SourceLocation getLParenLoc() const { return LParenLoc; } 1890d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor void setLParenLoc(SourceLocation L) { LParenLoc = L; } 1891d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor 1892d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor /// \brief Retrieve the location of the right parentheses (')') that 1893d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor /// follows the argument list. 1894d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor SourceLocation getRParenLoc() const { return RParenLoc; } 1895d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor void setRParenLoc(SourceLocation L) { RParenLoc = L; } 1896d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor 1897d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor /// \brief Retrieve the number of arguments. 1898d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor unsigned arg_size() const { return NumArgs; } 1899d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor 1900d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor typedef Expr** arg_iterator; 1901d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor arg_iterator arg_begin() { return reinterpret_cast<Expr**>(this + 1); } 1902d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor arg_iterator arg_end() { return arg_begin() + NumArgs; } 1903d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor 19041dd7383dc48718c452e71a625b29531dd96fbb9dJohn McCall typedef const Expr* const * const_arg_iterator; 19051dd7383dc48718c452e71a625b29531dd96fbb9dJohn McCall const_arg_iterator arg_begin() const { 19061dd7383dc48718c452e71a625b29531dd96fbb9dJohn McCall return reinterpret_cast<const Expr* const *>(this + 1); 19071dd7383dc48718c452e71a625b29531dd96fbb9dJohn McCall } 19081dd7383dc48718c452e71a625b29531dd96fbb9dJohn McCall const_arg_iterator arg_end() const { 19091dd7383dc48718c452e71a625b29531dd96fbb9dJohn McCall return arg_begin() + NumArgs; 19101dd7383dc48718c452e71a625b29531dd96fbb9dJohn McCall } 19111dd7383dc48718c452e71a625b29531dd96fbb9dJohn McCall 1912d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor Expr *getArg(unsigned I) { 1913d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor assert(I < NumArgs && "Argument index out-of-range"); 1914d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor return *(arg_begin() + I); 1915d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor } 1916d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor 19171dd7383dc48718c452e71a625b29531dd96fbb9dJohn McCall const Expr *getArg(unsigned I) const { 19181dd7383dc48718c452e71a625b29531dd96fbb9dJohn McCall assert(I < NumArgs && "Argument index out-of-range"); 19191dd7383dc48718c452e71a625b29531dd96fbb9dJohn McCall return *(arg_begin() + I); 19201dd7383dc48718c452e71a625b29531dd96fbb9dJohn McCall } 19211dd7383dc48718c452e71a625b29531dd96fbb9dJohn McCall 19228dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis void setArg(unsigned I, Expr *E) { 19238dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis assert(I < NumArgs && "Argument index out-of-range"); 19248dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis *(arg_begin() + I) = E; 19258dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis } 19268dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis 1927d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor virtual SourceRange getSourceRange() const { 1928d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor return SourceRange(TyBeginLoc, RParenLoc); 1929d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor } 19301eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump static bool classof(const Stmt *T) { 1931d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor return T->getStmtClass() == CXXUnresolvedConstructExprClass; 1932d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor } 1933d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor static bool classof(const CXXUnresolvedConstructExpr *) { return true; } 1934d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor 1935d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor // Iterators 1936d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor virtual child_iterator child_begin(); 1937d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor virtual child_iterator child_end(); 1938d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor}; 1939d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor 1940ba13543329afac4a0d01304ec2ec4924d99306a6John McCall/// \brief Represents a C++ member access expression where the actual 1941ba13543329afac4a0d01304ec2ec4924d99306a6John McCall/// member referenced could not be resolved because the base 1942ba13543329afac4a0d01304ec2ec4924d99306a6John McCall/// expression or the member name was dependent. 1943aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall/// 1944aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall/// Like UnresolvedMemberExprs, these can be either implicit or 1945aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall/// explicit accesses. It is only possible to get one of these with 1946aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall/// an implicit access if a qualifier is provided. 1947865d447ac6a4721ab58e898d014a21f2eff74b06John McCallclass CXXDependentScopeMemberExpr : public Expr { 19481c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor /// \brief The expression for the base pointer or class reference, 1949aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall /// e.g., the \c x in x.f. Can be null in implicit accesses. 19501c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor Stmt *Base; 19511eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1952aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall /// \brief The type of the base expression. Never null, even for 1953aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall /// implicit accesses. 1954aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall QualType BaseType; 1955aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall 19561c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor /// \brief Whether this member expression used the '->' operator or 19571c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor /// the '.' operator. 19583b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor bool IsArrow : 1; 19591c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor 19603b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor /// \brief Whether this member expression has explicitly-specified template 19613b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor /// arguments. 1962aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall bool HasExplicitTemplateArgs : 1; 19631eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 19641c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor /// \brief The location of the '->' or '.' operator. 19651c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor SourceLocation OperatorLoc; 19661c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor 1967a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor /// \brief The nested-name-specifier that precedes the member name, if any. 1968a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor NestedNameSpecifier *Qualifier; 19691eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1970a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor /// \brief The source range covering the nested name specifier. 1971a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor SourceRange QualifierRange; 19721eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1973c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor /// \brief In a qualified member access expression such as t->Base::f, this 19741eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump /// member stores the resolves of name lookup in the context of the member 1975c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor /// access expression, to be used at instantiation time. 1976c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor /// 1977c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor /// FIXME: This member, along with the Qualifier and QualifierRange, could 1978c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor /// be stuck into a structure that is optionally allocated at the end of 1979865d447ac6a4721ab58e898d014a21f2eff74b06John McCall /// the CXXDependentScopeMemberExpr, to save space in the common case. 1980c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor NamedDecl *FirstQualifierFoundInScope; 19811eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 19821c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor /// \brief The member to which this member expression refers, which 19831c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor /// can be name, overloaded operator, or destructor. 1984a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor /// FIXME: could also be a template-id 19852577743c5650c646fb705df01403707e94f2df04Abramo Bagnara DeclarationNameInfo MemberNameInfo; 19861eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1987865d447ac6a4721ab58e898d014a21f2eff74b06John McCall CXXDependentScopeMemberExpr(ASTContext &C, 1988aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall Expr *Base, QualType BaseType, bool IsArrow, 19893b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor SourceLocation OperatorLoc, 19903b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor NestedNameSpecifier *Qualifier, 19913b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor SourceRange QualifierRange, 19923b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor NamedDecl *FirstQualifierFoundInScope, 19932577743c5650c646fb705df01403707e94f2df04Abramo Bagnara DeclarationNameInfo MemberNameInfo, 1994d5532b6cfff2977e0c59fa6ead7f7973984a620dJohn McCall const TemplateArgumentListInfo *TemplateArgs); 19951eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 19961c0ca59416999129d0439c2661d137ef38e86209Douglas Gregorpublic: 1997865d447ac6a4721ab58e898d014a21f2eff74b06John McCall CXXDependentScopeMemberExpr(ASTContext &C, 1998aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall Expr *Base, QualType BaseType, 1999aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall bool IsArrow, 20001c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor SourceLocation OperatorLoc, 2001a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor NestedNameSpecifier *Qualifier, 2002a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor SourceRange QualifierRange, 2003c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor NamedDecl *FirstQualifierFoundInScope, 20042577743c5650c646fb705df01403707e94f2df04Abramo Bagnara DeclarationNameInfo MemberNameInfo) 2005865d447ac6a4721ab58e898d014a21f2eff74b06John McCall : Expr(CXXDependentScopeMemberExprClass, C.DependentTy, true, true), 2006aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall Base(Base), BaseType(BaseType), IsArrow(IsArrow), 2007aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall HasExplicitTemplateArgs(false), OperatorLoc(OperatorLoc), 20083b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor Qualifier(Qualifier), QualifierRange(QualifierRange), 20093b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor FirstQualifierFoundInScope(FirstQualifierFoundInScope), 20102577743c5650c646fb705df01403707e94f2df04Abramo Bagnara MemberNameInfo(MemberNameInfo) { } 20111eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 2012865d447ac6a4721ab58e898d014a21f2eff74b06John McCall static CXXDependentScopeMemberExpr * 20131eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump Create(ASTContext &C, 2014aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall Expr *Base, QualType BaseType, bool IsArrow, 20153b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor SourceLocation OperatorLoc, 20163b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor NestedNameSpecifier *Qualifier, 20173b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor SourceRange QualifierRange, 20183b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor NamedDecl *FirstQualifierFoundInScope, 20192577743c5650c646fb705df01403707e94f2df04Abramo Bagnara DeclarationNameInfo MemberNameInfo, 2020d5532b6cfff2977e0c59fa6ead7f7973984a620dJohn McCall const TemplateArgumentListInfo *TemplateArgs); 20211eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 20228dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis static CXXDependentScopeMemberExpr * 20238dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis CreateEmpty(ASTContext &C, unsigned NumTemplateArgs); 20248dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis 2025aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall /// \brief True if this is an implicit access, i.e. one in which the 2026aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall /// member being accessed was not written in the source. The source 2027aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall /// location of the operator is invalid in this case. 2028aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall bool isImplicitAccess() const { return Base == 0; } 2029aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall 20301c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor /// \brief Retrieve the base object of this member expressions, 20311c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor /// e.g., the \c x in \c x.m. 2032aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall Expr *getBase() const { 2033aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall assert(!isImplicitAccess()); 2034aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall return cast<Expr>(Base); 2035aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall } 20361c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor void setBase(Expr *E) { Base = E; } 20371c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor 2038aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall QualType getBaseType() const { return BaseType; } 20398dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis void setBaseType(QualType T) { BaseType = T; } 2040aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall 20411c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor /// \brief Determine whether this member expression used the '->' 20421c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor /// operator; otherwise, it used the '.' operator. 20431c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor bool isArrow() const { return IsArrow; } 20441c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor void setArrow(bool A) { IsArrow = A; } 20451c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor 20461c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor /// \brief Retrieve the location of the '->' or '.' operator. 20471c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor SourceLocation getOperatorLoc() const { return OperatorLoc; } 20481c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor void setOperatorLoc(SourceLocation L) { OperatorLoc = L; } 20491c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor 2050a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor /// \brief Retrieve the nested-name-specifier that qualifies the member 2051a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor /// name. 2052a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor NestedNameSpecifier *getQualifier() const { return Qualifier; } 20538dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis void setQualifier(NestedNameSpecifier *NNS) { Qualifier = NNS; } 20541eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 2055a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor /// \brief Retrieve the source range covering the nested-name-specifier 2056a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor /// that qualifies the member name. 2057a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor SourceRange getQualifierRange() const { return QualifierRange; } 20588dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis void setQualifierRange(SourceRange R) { QualifierRange = R; } 20591eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 2060c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor /// \brief Retrieve the first part of the nested-name-specifier that was 2061c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor /// found in the scope of the member access expression when the member access 2062c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor /// was initially parsed. 2063c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor /// 2064c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor /// This function only returns a useful result when member access expression 20651eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump /// uses a qualified member name, e.g., "x.Base::f". Here, the declaration 20661eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump /// returned by this function describes what was found by unqualified name 2067c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor /// lookup for the identifier "Base" within the scope of the member access 2068c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor /// expression itself. At template instantiation time, this information is 2069c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor /// combined with the results of name lookup into the type of the object 2070c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor /// expression itself (the class type of x). 20711eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump NamedDecl *getFirstQualifierFoundInScope() const { 2072c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor return FirstQualifierFoundInScope; 2073c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor } 20748dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis void setFirstQualifierFoundInScope(NamedDecl *D) { 20758dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis FirstQualifierFoundInScope = D; 20768dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis } 20771eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 20781c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor /// \brief Retrieve the name of the member that this expression 20791c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor /// refers to. 20802577743c5650c646fb705df01403707e94f2df04Abramo Bagnara const DeclarationNameInfo &getMemberNameInfo() const { 20812577743c5650c646fb705df01403707e94f2df04Abramo Bagnara return MemberNameInfo; 20822577743c5650c646fb705df01403707e94f2df04Abramo Bagnara } 20832577743c5650c646fb705df01403707e94f2df04Abramo Bagnara void setMemberNameInfo(const DeclarationNameInfo &N) { MemberNameInfo = N; } 20842577743c5650c646fb705df01403707e94f2df04Abramo Bagnara 20852577743c5650c646fb705df01403707e94f2df04Abramo Bagnara /// \brief Retrieve the name of the member that this expression 20862577743c5650c646fb705df01403707e94f2df04Abramo Bagnara /// refers to. 20872577743c5650c646fb705df01403707e94f2df04Abramo Bagnara DeclarationName getMember() const { return MemberNameInfo.getName(); } 20882577743c5650c646fb705df01403707e94f2df04Abramo Bagnara void setMember(DeclarationName N) { MemberNameInfo.setName(N); } 20891c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor 20901c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor // \brief Retrieve the location of the name of the member that this 20911c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor // expression refers to. 20922577743c5650c646fb705df01403707e94f2df04Abramo Bagnara SourceLocation getMemberLoc() const { return MemberNameInfo.getLoc(); } 20932577743c5650c646fb705df01403707e94f2df04Abramo Bagnara void setMemberLoc(SourceLocation L) { MemberNameInfo.setLoc(L); } 20941c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor 20953b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor /// \brief Determines whether this member expression actually had a C++ 20963b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor /// template argument list explicitly specified, e.g., x.f<int>. 2097aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall bool hasExplicitTemplateArgs() const { 2098aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall return HasExplicitTemplateArgs; 20993b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor } 21001eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 210136c76f0bea0d3595a25a5362225c642019cc3176Argyrios Kyrtzidis /// \brief Retrieve the explicit template argument list that followed the 210236c76f0bea0d3595a25a5362225c642019cc3176Argyrios Kyrtzidis /// member template name, if any. 2103096832c5ed5b9106fa177ebc148489760c3bc496John McCall ExplicitTemplateArgumentList &getExplicitTemplateArgs() { 210436c76f0bea0d3595a25a5362225c642019cc3176Argyrios Kyrtzidis assert(HasExplicitTemplateArgs); 2105096832c5ed5b9106fa177ebc148489760c3bc496John McCall return *reinterpret_cast<ExplicitTemplateArgumentList *>(this + 1); 210636c76f0bea0d3595a25a5362225c642019cc3176Argyrios Kyrtzidis } 210736c76f0bea0d3595a25a5362225c642019cc3176Argyrios Kyrtzidis 210836c76f0bea0d3595a25a5362225c642019cc3176Argyrios Kyrtzidis /// \brief Retrieve the explicit template argument list that followed the 210936c76f0bea0d3595a25a5362225c642019cc3176Argyrios Kyrtzidis /// member template name, if any. 2110096832c5ed5b9106fa177ebc148489760c3bc496John McCall const ExplicitTemplateArgumentList &getExplicitTemplateArgs() const { 211136c76f0bea0d3595a25a5362225c642019cc3176Argyrios Kyrtzidis return const_cast<CXXDependentScopeMemberExpr *>(this) 2112096832c5ed5b9106fa177ebc148489760c3bc496John McCall ->getExplicitTemplateArgs(); 2113096832c5ed5b9106fa177ebc148489760c3bc496John McCall } 2114096832c5ed5b9106fa177ebc148489760c3bc496John McCall 2115096832c5ed5b9106fa177ebc148489760c3bc496John McCall /// \brief Retrieves the optional explicit template arguments. 2116096832c5ed5b9106fa177ebc148489760c3bc496John McCall /// This points to the same data as getExplicitTemplateArgs(), but 2117096832c5ed5b9106fa177ebc148489760c3bc496John McCall /// returns null if there are no explicit template arguments. 2118096832c5ed5b9106fa177ebc148489760c3bc496John McCall const ExplicitTemplateArgumentList *getOptionalExplicitTemplateArgs() { 2119096832c5ed5b9106fa177ebc148489760c3bc496John McCall if (!hasExplicitTemplateArgs()) return 0; 2120096832c5ed5b9106fa177ebc148489760c3bc496John McCall return &getExplicitTemplateArgs(); 212136c76f0bea0d3595a25a5362225c642019cc3176Argyrios Kyrtzidis } 212236c76f0bea0d3595a25a5362225c642019cc3176Argyrios Kyrtzidis 2123d5532b6cfff2977e0c59fa6ead7f7973984a620dJohn McCall /// \brief Copies the template arguments (if present) into the given 2124d5532b6cfff2977e0c59fa6ead7f7973984a620dJohn McCall /// structure. 2125d5532b6cfff2977e0c59fa6ead7f7973984a620dJohn McCall void copyTemplateArgumentsInto(TemplateArgumentListInfo &List) const { 2126096832c5ed5b9106fa177ebc148489760c3bc496John McCall getExplicitTemplateArgs().copyInto(List); 2127d5532b6cfff2977e0c59fa6ead7f7973984a620dJohn McCall } 2128d5532b6cfff2977e0c59fa6ead7f7973984a620dJohn McCall 21298dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis /// \brief Initializes the template arguments using the given structure. 21308dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis void initializeTemplateArgumentsFrom(const TemplateArgumentListInfo &List) { 2131096832c5ed5b9106fa177ebc148489760c3bc496John McCall getExplicitTemplateArgs().initializeFrom(List); 21328dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis } 21338dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis 21341eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump /// \brief Retrieve the location of the left angle bracket following the 21353b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor /// member name ('<'), if any. 21361eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump SourceLocation getLAngleLoc() const { 2137096832c5ed5b9106fa177ebc148489760c3bc496John McCall return getExplicitTemplateArgs().LAngleLoc; 21383b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor } 21391eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 21403b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor /// \brief Retrieve the template arguments provided as part of this 21413b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor /// template-id. 2142833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall const TemplateArgumentLoc *getTemplateArgs() const { 2143096832c5ed5b9106fa177ebc148489760c3bc496John McCall return getExplicitTemplateArgs().getTemplateArgs(); 21443b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor } 21451eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 21463b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor /// \brief Retrieve the number of template arguments provided as part of this 21473b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor /// template-id. 21481eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump unsigned getNumTemplateArgs() const { 2149096832c5ed5b9106fa177ebc148489760c3bc496John McCall return getExplicitTemplateArgs().NumTemplateArgs; 21503b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor } 21511eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 21521eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump /// \brief Retrieve the location of the right angle bracket following the 21533b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor /// template arguments ('>'). 21541eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump SourceLocation getRAngleLoc() const { 2155096832c5ed5b9106fa177ebc148489760c3bc496John McCall return getExplicitTemplateArgs().RAngleLoc; 21563b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor } 21571eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 21581c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor virtual SourceRange getSourceRange() const { 2159aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall SourceRange Range; 2160aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall if (!isImplicitAccess()) 2161aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall Range.setBegin(Base->getSourceRange().getBegin()); 2162aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall else if (getQualifier()) 2163aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall Range.setBegin(getQualifierRange().getBegin()); 2164aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall else 21652577743c5650c646fb705df01403707e94f2df04Abramo Bagnara Range.setBegin(MemberNameInfo.getBeginLoc()); 21661eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 2167aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall if (hasExplicitTemplateArgs()) 2168aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall Range.setEnd(getRAngleLoc()); 2169aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall else 21702577743c5650c646fb705df01403707e94f2df04Abramo Bagnara Range.setEnd(MemberNameInfo.getEndLoc()); 2171aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall return Range; 21721c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor } 21731eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 21741eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump static bool classof(const Stmt *T) { 2175865d447ac6a4721ab58e898d014a21f2eff74b06John McCall return T->getStmtClass() == CXXDependentScopeMemberExprClass; 21761c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor } 2177865d447ac6a4721ab58e898d014a21f2eff74b06John McCall static bool classof(const CXXDependentScopeMemberExpr *) { return true; } 21781c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor 21791c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor // Iterators 21801c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor virtual child_iterator child_begin(); 21811c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor virtual child_iterator child_end(); 21821c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor}; 21831c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor 2184129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall/// \brief Represents a C++ member access expression for which lookup 2185aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall/// produced a set of overloaded functions. 2186aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall/// 2187aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall/// The member access may be explicit or implicit: 2188aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall/// struct A { 2189aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall/// int a, b; 2190aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall/// int explicitAccess() { return this->a + this->A::b; } 2191aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall/// int implicitAccess() { return a + A::b; } 2192aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall/// }; 2193aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall/// 2194aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall/// In the final AST, an explicit access always becomes a MemberExpr. 2195aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall/// An implicit access may become either a MemberExpr or a 2196aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall/// DeclRefExpr, depending on whether the member is static. 21977bb12da2b0749eeebb21854c77877736969e59f2John McCallclass UnresolvedMemberExpr : public OverloadExpr { 2198129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall /// \brief Whether this member expression used the '->' operator or 2199129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall /// the '.' operator. 2200129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall bool IsArrow : 1; 2201129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall 2202129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall /// \brief Whether the lookup results contain an unresolved using 2203129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall /// declaration. 2204129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall bool HasUnresolvedUsing : 1; 2205129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall 22067bb12da2b0749eeebb21854c77877736969e59f2John McCall /// \brief The expression for the base pointer or class reference, 22077bb12da2b0749eeebb21854c77877736969e59f2John McCall /// e.g., the \c x in x.f. This can be null if this is an 'unbased' 22087bb12da2b0749eeebb21854c77877736969e59f2John McCall /// member expression 22097bb12da2b0749eeebb21854c77877736969e59f2John McCall Stmt *Base; 22107bb12da2b0749eeebb21854c77877736969e59f2John McCall 22117bb12da2b0749eeebb21854c77877736969e59f2John McCall /// \brief The type of the base expression; never null. 22127bb12da2b0749eeebb21854c77877736969e59f2John McCall QualType BaseType; 2213129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall 2214129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall /// \brief The location of the '->' or '.' operator. 2215129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall SourceLocation OperatorLoc; 2216129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall 2217928e6fcf66fc4f342bcf7cc96bf56986c9c2a833Douglas Gregor UnresolvedMemberExpr(ASTContext &C, QualType T, bool Dependent, 2218129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall bool HasUnresolvedUsing, 2219aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall Expr *Base, QualType BaseType, bool IsArrow, 2220129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall SourceLocation OperatorLoc, 2221129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall NestedNameSpecifier *Qualifier, 2222129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall SourceRange QualifierRange, 22232577743c5650c646fb705df01403707e94f2df04Abramo Bagnara const DeclarationNameInfo &MemberNameInfo, 22245a84dec38cfa9e084377a3167b474c79283c82faDouglas Gregor const TemplateArgumentListInfo *TemplateArgs, 22255a84dec38cfa9e084377a3167b474c79283c82faDouglas Gregor UnresolvedSetIterator Begin, UnresolvedSetIterator End); 2226a77eb0862507b900a10fa352af1568e639ed10b1Argyrios Kyrtzidis 2227a77eb0862507b900a10fa352af1568e639ed10b1Argyrios Kyrtzidis UnresolvedMemberExpr(EmptyShell Empty) 2228a77eb0862507b900a10fa352af1568e639ed10b1Argyrios Kyrtzidis : OverloadExpr(UnresolvedMemberExprClass, Empty), IsArrow(false), 2229a77eb0862507b900a10fa352af1568e639ed10b1Argyrios Kyrtzidis HasUnresolvedUsing(false), Base(0) { } 2230129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall 2231129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCallpublic: 2232129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall static UnresolvedMemberExpr * 2233129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall Create(ASTContext &C, bool Dependent, bool HasUnresolvedUsing, 2234aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall Expr *Base, QualType BaseType, bool IsArrow, 2235129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall SourceLocation OperatorLoc, 2236129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall NestedNameSpecifier *Qualifier, 2237129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall SourceRange QualifierRange, 22382577743c5650c646fb705df01403707e94f2df04Abramo Bagnara const DeclarationNameInfo &MemberNameInfo, 22395a84dec38cfa9e084377a3167b474c79283c82faDouglas Gregor const TemplateArgumentListInfo *TemplateArgs, 22405a84dec38cfa9e084377a3167b474c79283c82faDouglas Gregor UnresolvedSetIterator Begin, UnresolvedSetIterator End); 2241129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall 2242a77eb0862507b900a10fa352af1568e639ed10b1Argyrios Kyrtzidis static UnresolvedMemberExpr * 2243a77eb0862507b900a10fa352af1568e639ed10b1Argyrios Kyrtzidis CreateEmpty(ASTContext &C, unsigned NumTemplateArgs); 2244a77eb0862507b900a10fa352af1568e639ed10b1Argyrios Kyrtzidis 2245aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall /// \brief True if this is an implicit access, i.e. one in which the 2246aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall /// member being accessed was not written in the source. The source 2247aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall /// location of the operator is invalid in this case. 2248aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall bool isImplicitAccess() const { return Base == 0; } 2249aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall 2250129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall /// \brief Retrieve the base object of this member expressions, 2251129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall /// e.g., the \c x in \c x.m. 2252aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall Expr *getBase() { 2253aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall assert(!isImplicitAccess()); 2254aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall return cast<Expr>(Base); 2255aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall } 22562f27bf854f0519810b34afd209089cc75536b757John McCall const Expr *getBase() const { 22572f27bf854f0519810b34afd209089cc75536b757John McCall assert(!isImplicitAccess()); 22582f27bf854f0519810b34afd209089cc75536b757John McCall return cast<Expr>(Base); 22592f27bf854f0519810b34afd209089cc75536b757John McCall } 2260129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall void setBase(Expr *E) { Base = E; } 2261129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall 2262aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall QualType getBaseType() const { return BaseType; } 2263a77eb0862507b900a10fa352af1568e639ed10b1Argyrios Kyrtzidis void setBaseType(QualType T) { BaseType = T; } 2264a77eb0862507b900a10fa352af1568e639ed10b1Argyrios Kyrtzidis 2265a77eb0862507b900a10fa352af1568e639ed10b1Argyrios Kyrtzidis /// \brief Determine whether the lookup results contain an unresolved using 2266a77eb0862507b900a10fa352af1568e639ed10b1Argyrios Kyrtzidis /// declaration. 2267a77eb0862507b900a10fa352af1568e639ed10b1Argyrios Kyrtzidis bool hasUnresolvedUsing() const { return HasUnresolvedUsing; } 2268a77eb0862507b900a10fa352af1568e639ed10b1Argyrios Kyrtzidis void setHasUnresolvedUsing(bool V) { HasUnresolvedUsing = V; } 2269aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall 2270129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall /// \brief Determine whether this member expression used the '->' 2271129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall /// operator; otherwise, it used the '.' operator. 2272129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall bool isArrow() const { return IsArrow; } 2273129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall void setArrow(bool A) { IsArrow = A; } 2274129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall 2275129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall /// \brief Retrieve the location of the '->' or '.' operator. 2276129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall SourceLocation getOperatorLoc() const { return OperatorLoc; } 2277129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall void setOperatorLoc(SourceLocation L) { OperatorLoc = L; } 2278129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall 2279c373d48502ca7683ab55385f5bd624d778eb288dJohn McCall /// \brief Retrieves the naming class of this lookup. 2280c373d48502ca7683ab55385f5bd624d778eb288dJohn McCall CXXRecordDecl *getNamingClass() const; 2281c373d48502ca7683ab55385f5bd624d778eb288dJohn McCall 22822577743c5650c646fb705df01403707e94f2df04Abramo Bagnara /// \brief Retrieve the full name info for the member that this expression 22832577743c5650c646fb705df01403707e94f2df04Abramo Bagnara /// refers to. 22842577743c5650c646fb705df01403707e94f2df04Abramo Bagnara const DeclarationNameInfo &getMemberNameInfo() const { return getNameInfo(); } 22852577743c5650c646fb705df01403707e94f2df04Abramo Bagnara void setMemberNameInfo(const DeclarationNameInfo &N) { setNameInfo(N); } 22862577743c5650c646fb705df01403707e94f2df04Abramo Bagnara 2287129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall /// \brief Retrieve the name of the member that this expression 2288129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall /// refers to. 22897bb12da2b0749eeebb21854c77877736969e59f2John McCall DeclarationName getMemberName() const { return getName(); } 22907bb12da2b0749eeebb21854c77877736969e59f2John McCall void setMemberName(DeclarationName N) { setName(N); } 2291129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall 2292129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall // \brief Retrieve the location of the name of the member that this 2293129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall // expression refers to. 22947bb12da2b0749eeebb21854c77877736969e59f2John McCall SourceLocation getMemberLoc() const { return getNameLoc(); } 22957bb12da2b0749eeebb21854c77877736969e59f2John McCall void setMemberLoc(SourceLocation L) { setNameLoc(L); } 2296129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall 22977bb12da2b0749eeebb21854c77877736969e59f2John McCall /// \brief Retrieve the explicit template argument list that followed the 22987bb12da2b0749eeebb21854c77877736969e59f2John McCall /// member template name. 22997bb12da2b0749eeebb21854c77877736969e59f2John McCall ExplicitTemplateArgumentList &getExplicitTemplateArgs() { 23007bb12da2b0749eeebb21854c77877736969e59f2John McCall assert(hasExplicitTemplateArgs()); 23017bb12da2b0749eeebb21854c77877736969e59f2John McCall return *reinterpret_cast<ExplicitTemplateArgumentList *>(this + 1); 23027bb12da2b0749eeebb21854c77877736969e59f2John McCall } 23037bb12da2b0749eeebb21854c77877736969e59f2John McCall 23047bb12da2b0749eeebb21854c77877736969e59f2John McCall /// \brief Retrieve the explicit template argument list that followed the 23057bb12da2b0749eeebb21854c77877736969e59f2John McCall /// member template name, if any. 23067bb12da2b0749eeebb21854c77877736969e59f2John McCall const ExplicitTemplateArgumentList &getExplicitTemplateArgs() const { 23077bb12da2b0749eeebb21854c77877736969e59f2John McCall assert(hasExplicitTemplateArgs()); 23087bb12da2b0749eeebb21854c77877736969e59f2John McCall return *reinterpret_cast<const ExplicitTemplateArgumentList *>(this + 1); 2309129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall } 2310129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall 2311096832c5ed5b9106fa177ebc148489760c3bc496John McCall /// \brief Retrieves the optional explicit template arguments. 2312096832c5ed5b9106fa177ebc148489760c3bc496John McCall /// This points to the same data as getExplicitTemplateArgs(), but 2313096832c5ed5b9106fa177ebc148489760c3bc496John McCall /// returns null if there are no explicit template arguments. 2314096832c5ed5b9106fa177ebc148489760c3bc496John McCall const ExplicitTemplateArgumentList *getOptionalExplicitTemplateArgs() { 2315096832c5ed5b9106fa177ebc148489760c3bc496John McCall if (!hasExplicitTemplateArgs()) return 0; 2316096832c5ed5b9106fa177ebc148489760c3bc496John McCall return &getExplicitTemplateArgs(); 2317096832c5ed5b9106fa177ebc148489760c3bc496John McCall } 2318096832c5ed5b9106fa177ebc148489760c3bc496John McCall 2319129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall /// \brief Copies the template arguments into the given structure. 2320129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall void copyTemplateArgumentsInto(TemplateArgumentListInfo &List) const { 23217bb12da2b0749eeebb21854c77877736969e59f2John McCall getExplicitTemplateArgs().copyInto(List); 2322129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall } 2323129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall 2324129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall /// \brief Retrieve the location of the left angle bracket following 2325129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall /// the member name ('<'). 2326129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall SourceLocation getLAngleLoc() const { 23277bb12da2b0749eeebb21854c77877736969e59f2John McCall return getExplicitTemplateArgs().LAngleLoc; 2328129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall } 2329129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall 2330129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall /// \brief Retrieve the template arguments provided as part of this 2331129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall /// template-id. 2332129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall const TemplateArgumentLoc *getTemplateArgs() const { 23337bb12da2b0749eeebb21854c77877736969e59f2John McCall return getExplicitTemplateArgs().getTemplateArgs(); 2334129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall } 2335129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall 2336129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall /// \brief Retrieve the number of template arguments provided as 2337129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall /// part of this template-id. 2338129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall unsigned getNumTemplateArgs() const { 23397bb12da2b0749eeebb21854c77877736969e59f2John McCall return getExplicitTemplateArgs().NumTemplateArgs; 2340129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall } 2341129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall 2342129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall /// \brief Retrieve the location of the right angle bracket 2343129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall /// following the template arguments ('>'). 2344129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall SourceLocation getRAngleLoc() const { 23457bb12da2b0749eeebb21854c77877736969e59f2John McCall return getExplicitTemplateArgs().RAngleLoc; 2346129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall } 2347129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall 2348129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall virtual SourceRange getSourceRange() const { 23492577743c5650c646fb705df01403707e94f2df04Abramo Bagnara SourceRange Range = getMemberNameInfo().getSourceRange(); 2350aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall if (!isImplicitAccess()) 2351aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall Range.setBegin(Base->getSourceRange().getBegin()); 2352aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall else if (getQualifier()) 2353aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall Range.setBegin(getQualifierRange().getBegin()); 2354aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall 2355129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall if (hasExplicitTemplateArgs()) 2356129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall Range.setEnd(getRAngleLoc()); 2357129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall return Range; 2358129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall } 2359129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall 2360129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall static bool classof(const Stmt *T) { 2361129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall return T->getStmtClass() == UnresolvedMemberExprClass; 2362129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall } 2363129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall static bool classof(const UnresolvedMemberExpr *) { return true; } 2364129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall 2365129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall // Iterators 2366129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall virtual child_iterator child_begin(); 2367129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall virtual child_iterator child_end(); 2368129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall}; 2369129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall 23707bb12da2b0749eeebb21854c77877736969e59f2John McCallinline ExplicitTemplateArgumentList &OverloadExpr::getExplicitTemplateArgs() { 23717bb12da2b0749eeebb21854c77877736969e59f2John McCall if (isa<UnresolvedLookupExpr>(this)) 23727bb12da2b0749eeebb21854c77877736969e59f2John McCall return cast<UnresolvedLookupExpr>(this)->getExplicitTemplateArgs(); 23737bb12da2b0749eeebb21854c77877736969e59f2John McCall else 23747bb12da2b0749eeebb21854c77877736969e59f2John McCall return cast<UnresolvedMemberExpr>(this)->getExplicitTemplateArgs(); 23757bb12da2b0749eeebb21854c77877736969e59f2John McCall} 23767bb12da2b0749eeebb21854c77877736969e59f2John McCall 23775f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer} // end namespace clang 23785f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 23795f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer#endif 2380