ExprCXX.h revision 865d447ac6a4721ab58e898d014a21f2eff74b06
15f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer//===--- ExprCXX.h - Classes for representing expressions -------*- C++ -*-===// 25f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer// 35f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer// The LLVM Compiler Infrastructure 45f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer// 50bc735ffcfb223c0186419547abaa5c84482663eChris Lattner// This file is distributed under the University of Illinois Open Source 60bc735ffcfb223c0186419547abaa5c84482663eChris Lattner// License. See LICENSE.TXT for details. 75f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer// 85f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer//===----------------------------------------------------------------------===// 95f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer// 105f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer// This file defines the Expr interface and subclasses for C++ expressions. 115f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer// 125f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer//===----------------------------------------------------------------------===// 135f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 145f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer#ifndef LLVM_CLANG_AST_EXPRCXX_H 155f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer#define LLVM_CLANG_AST_EXPRCXX_H 165f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 1764b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl#include "clang/Basic/TypeTraits.h" 185f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer#include "clang/AST/Expr.h" 19c4a1dea2dc56bd1357ec91b829a0b9e68229a13eDaniel Dunbar#include "clang/AST/Decl.h" 205f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 215f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencernamespace clang { 225f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 234c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl class CXXConstructorDecl; 24c1ce477119fed070299668aab24084b17ff5f14bAnders Carlsson class CXXDestructorDecl; 25e9f42087aabfdb6b2afc35c7e38ac65da063b409Fariborz Jahanian class CXXMethodDecl; 26ff6b3d64c9f07155f1414411b8451d7bf8937c62Anders Carlsson class CXXTemporary; 274c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 281060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek//===--------------------------------------------------------------------===// 291060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek// C++ Expressions. 301060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek//===--------------------------------------------------------------------===// 311060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek 323fd95ce225393fe4a3623e429766a8c3f487ff9dDouglas Gregor/// \brief A call to an overloaded operator written using operator 333fd95ce225393fe4a3623e429766a8c3f487ff9dDouglas Gregor/// syntax. 343fd95ce225393fe4a3623e429766a8c3f487ff9dDouglas Gregor/// 353fd95ce225393fe4a3623e429766a8c3f487ff9dDouglas Gregor/// Represents a call to an overloaded operator written using operator 363fd95ce225393fe4a3623e429766a8c3f487ff9dDouglas Gregor/// syntax, e.g., "x + y" or "*p". While semantically equivalent to a 373fd95ce225393fe4a3623e429766a8c3f487ff9dDouglas Gregor/// normal call, this AST node provides better information about the 383fd95ce225393fe4a3623e429766a8c3f487ff9dDouglas Gregor/// syntactic representation of the call. 393fd95ce225393fe4a3623e429766a8c3f487ff9dDouglas Gregor/// 403fd95ce225393fe4a3623e429766a8c3f487ff9dDouglas Gregor/// In a C++ template, this expression node kind will be used whenever 413fd95ce225393fe4a3623e429766a8c3f487ff9dDouglas Gregor/// any of the arguments are type-dependent. In this case, the 423fd95ce225393fe4a3623e429766a8c3f487ff9dDouglas Gregor/// function itself will be a (possibly empty) set of functions and 433fd95ce225393fe4a3623e429766a8c3f487ff9dDouglas Gregor/// function templates that were found by name lookup at template 443fd95ce225393fe4a3623e429766a8c3f487ff9dDouglas Gregor/// definition time. 45b4609806e9232593ece09ce08b630836e825865cDouglas Gregorclass CXXOperatorCallExpr : public CallExpr { 46063daf6e196c51f162e0485478355d8e280eef5cDouglas Gregor /// \brief The overloaded operator. 47063daf6e196c51f162e0485478355d8e280eef5cDouglas Gregor OverloadedOperatorKind Operator; 48063daf6e196c51f162e0485478355d8e280eef5cDouglas Gregor 49b4609806e9232593ece09ce08b630836e825865cDouglas Gregorpublic: 501eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump CXXOperatorCallExpr(ASTContext& C, OverloadedOperatorKind Op, Expr *fn, 511eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump Expr **args, unsigned numargs, QualType t, 52063daf6e196c51f162e0485478355d8e280eef5cDouglas Gregor SourceLocation operatorloc) 53063daf6e196c51f162e0485478355d8e280eef5cDouglas Gregor : CallExpr(C, CXXOperatorCallExprClass, fn, args, numargs, t, operatorloc), 54063daf6e196c51f162e0485478355d8e280eef5cDouglas Gregor Operator(Op) {} 551eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump explicit CXXOperatorCallExpr(ASTContext& C, EmptyShell Empty) : 56ba0a9006dbc4814e1e35f82812cb5a1dad65e8b8Argyrios Kyrtzidis CallExpr(C, CXXOperatorCallExprClass, Empty) { } 571eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 58b4609806e9232593ece09ce08b630836e825865cDouglas Gregor 59b4609806e9232593ece09ce08b630836e825865cDouglas Gregor /// getOperator - Returns the kind of overloaded operator that this 60b4609806e9232593ece09ce08b630836e825865cDouglas Gregor /// expression refers to. 61063daf6e196c51f162e0485478355d8e280eef5cDouglas Gregor OverloadedOperatorKind getOperator() const { return Operator; } 62ba0a9006dbc4814e1e35f82812cb5a1dad65e8b8Argyrios Kyrtzidis void setOperator(OverloadedOperatorKind Kind) { Operator = Kind; } 63b4609806e9232593ece09ce08b630836e825865cDouglas Gregor 64b4609806e9232593ece09ce08b630836e825865cDouglas Gregor /// getOperatorLoc - Returns the location of the operator symbol in 65b4609806e9232593ece09ce08b630836e825865cDouglas Gregor /// the expression. When @c getOperator()==OO_Call, this is the 66b4609806e9232593ece09ce08b630836e825865cDouglas Gregor /// location of the right parentheses; when @c 67b4609806e9232593ece09ce08b630836e825865cDouglas Gregor /// getOperator()==OO_Subscript, this is the location of the right 68b4609806e9232593ece09ce08b630836e825865cDouglas Gregor /// bracket. 69b4609806e9232593ece09ce08b630836e825865cDouglas Gregor SourceLocation getOperatorLoc() const { return getRParenLoc(); } 70b4609806e9232593ece09ce08b630836e825865cDouglas Gregor 71b4609806e9232593ece09ce08b630836e825865cDouglas Gregor virtual SourceRange getSourceRange() const; 721eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 731eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump static bool classof(const Stmt *T) { 741eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump return T->getStmtClass() == CXXOperatorCallExprClass; 75b4609806e9232593ece09ce08b630836e825865cDouglas Gregor } 76b4609806e9232593ece09ce08b630836e825865cDouglas Gregor static bool classof(const CXXOperatorCallExpr *) { return true; } 77b4609806e9232593ece09ce08b630836e825865cDouglas Gregor}; 78b4609806e9232593ece09ce08b630836e825865cDouglas Gregor 7988a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor/// CXXMemberCallExpr - Represents a call to a member function that 8088a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor/// may be written either with member call syntax (e.g., "obj.func()" 8188a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor/// or "objptr->func()") or with normal function-call syntax 8288a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor/// ("func()") within a member function that ends up calling a member 8388a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor/// function. The callee in either case is a MemberExpr that contains 8488a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor/// both the object argument and the member function, while the 8588a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor/// arguments are the arguments within the parentheses (not including 8688a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor/// the object argument). 8788a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregorclass CXXMemberCallExpr : public CallExpr { 8888a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregorpublic: 89668bf91d31265b6ea8c3eb854ba450857701f269Ted Kremenek CXXMemberCallExpr(ASTContext& C, Expr *fn, Expr **args, unsigned numargs, 90668bf91d31265b6ea8c3eb854ba450857701f269Ted Kremenek QualType t, SourceLocation rparenloc) 91668bf91d31265b6ea8c3eb854ba450857701f269Ted Kremenek : CallExpr(C, CXXMemberCallExprClass, fn, args, numargs, t, rparenloc) {} 9288a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor 9388a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor /// getImplicitObjectArgument - Retrieves the implicit object 9488a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor /// argument for the member call. For example, in "x.f(5)", this 9588a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor /// operation would return "x". 9688a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor Expr *getImplicitObjectArgument(); 9788a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor 9800b98c229ef28a5e82943bb23d09fb46d24ca381Douglas Gregor virtual SourceRange getSourceRange() const; 9900b98c229ef28a5e82943bb23d09fb46d24ca381Douglas Gregor 1001eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump static bool classof(const Stmt *T) { 10188a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor return T->getStmtClass() == CXXMemberCallExprClass; 10288a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor } 10388a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor static bool classof(const CXXMemberCallExpr *) { return true; } 10488a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor}; 10588a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor 10649badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// CXXNamedCastExpr - Abstract class common to all of the C++ "named" 10749badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// casts, @c static_cast, @c dynamic_cast, @c reinterpret_cast, or @c 10849badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// const_cast. 10949badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// 11049badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// This abstract class is inherited by all of the classes 11149badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// representing "named" casts, e.g., CXXStaticCastExpr, 11249badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// CXXDynamicCastExpr, CXXReinterpretCastExpr, and CXXConstCastExpr. 11349badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregorclass CXXNamedCastExpr : public ExplicitCastExpr { 1141060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenekprivate: 1151060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek SourceLocation Loc; // the location of the casting op 11649badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor 11749badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregorprotected: 118c0a2fd8f092722c8f78b566ac4506a21437040e9Anders Carlsson CXXNamedCastExpr(StmtClass SC, QualType ty, CastKind kind, Expr *op, 119cdef2b75aa60cde1ca00e0aa3f89139ac89c6ae4Anders Carlsson QualType writtenTy, SourceLocation l) 120c0a2fd8f092722c8f78b566ac4506a21437040e9Anders Carlsson : ExplicitCastExpr(SC, ty, kind, op, writtenTy), Loc(l) {} 12149badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor 1221060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenekpublic: 12349badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor const char *getCastName() const; 12449badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor 125a3a7b8eea87c90a5a257f685749222b212ddaf36Douglas Gregor /// \brief Retrieve the location of the cast operator keyword, e.g., 126a3a7b8eea87c90a5a257f685749222b212ddaf36Douglas Gregor /// "static_cast". 127a3a7b8eea87c90a5a257f685749222b212ddaf36Douglas Gregor SourceLocation getOperatorLoc() const { return Loc; } 128a3a7b8eea87c90a5a257f685749222b212ddaf36Douglas Gregor void setOperatorLoc(SourceLocation L) { Loc = L; } 129a3a7b8eea87c90a5a257f685749222b212ddaf36Douglas Gregor 1301060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek virtual SourceRange getSourceRange() const { 1311060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek return SourceRange(Loc, getSubExpr()->getSourceRange().getEnd()); 1321060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek } 1331eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump static bool classof(const Stmt *T) { 13449badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor switch (T->getStmtClass()) { 13549badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor case CXXNamedCastExprClass: 13649badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor case CXXStaticCastExprClass: 13749badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor case CXXDynamicCastExprClass: 13849badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor case CXXReinterpretCastExprClass: 13949badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor case CXXConstCastExprClass: 14049badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor return true; 14149badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor default: 14249badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor return false; 14349badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor } 1441060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek } 14549badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor static bool classof(const CXXNamedCastExpr *) { return true; } 14649badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor}; 14749badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor 14849badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// CXXStaticCastExpr - A C++ @c static_cast expression (C++ [expr.static.cast]). 1491eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump/// 15049badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// This expression node represents a C++ static cast, e.g., 15149badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// @c static_cast<int>(1.0). 15249badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregorclass CXXStaticCastExpr : public CXXNamedCastExpr { 15349badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregorpublic: 154c0a2fd8f092722c8f78b566ac4506a21437040e9Anders Carlsson CXXStaticCastExpr(QualType ty, CastKind kind, Expr *op, 155bd0fb30fa2a039439d1a30a83ea896801394d780Anders Carlsson QualType writtenTy, SourceLocation l) 156c0a2fd8f092722c8f78b566ac4506a21437040e9Anders Carlsson : CXXNamedCastExpr(CXXStaticCastExprClass, ty, kind, op, writtenTy, l) {} 15749badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor 1581eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump static bool classof(const Stmt *T) { 15949badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor return T->getStmtClass() == CXXStaticCastExprClass; 16049badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor } 16149badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor static bool classof(const CXXStaticCastExpr *) { return true; } 16249badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor}; 16349badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor 16449badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// CXXDynamicCastExpr - A C++ @c dynamic_cast expression 1651eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump/// (C++ [expr.dynamic.cast]), which may perform a run-time check to 16649badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// determine how to perform the type cast. 1671eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump/// 16849badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// This expression node represents a dynamic cast, e.g., 16949badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// @c dynamic_cast<Derived*>(BasePtr). 17049badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregorclass CXXDynamicCastExpr : public CXXNamedCastExpr { 17149badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregorpublic: 1721eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump CXXDynamicCastExpr(QualType ty, CastKind kind, Expr *op, QualType writtenTy, 173cdef2b75aa60cde1ca00e0aa3f89139ac89c6ae4Anders Carlsson SourceLocation l) 174cdef2b75aa60cde1ca00e0aa3f89139ac89c6ae4Anders Carlsson : CXXNamedCastExpr(CXXDynamicCastExprClass, ty, kind, op, writtenTy, l) {} 17549badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor 1761eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump static bool classof(const Stmt *T) { 17749badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor return T->getStmtClass() == CXXDynamicCastExprClass; 17849badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor } 17949badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor static bool classof(const CXXDynamicCastExpr *) { return true; } 18049badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor}; 18149badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor 18249badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// CXXReinterpretCastExpr - A C++ @c reinterpret_cast expression (C++ 18349badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// [expr.reinterpret.cast]), which provides a differently-typed view 18449badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// of a value but performs no actual work at run time. 1851eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump/// 18649badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// This expression node represents a reinterpret cast, e.g., 18749badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// @c reinterpret_cast<int>(VoidPtr). 18849badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregorclass CXXReinterpretCastExpr : public CXXNamedCastExpr { 18949badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregorpublic: 1907f9e646b7ed47bc8e9a60031ad0c2b55031e2077Anders Carlsson CXXReinterpretCastExpr(QualType ty, CastKind kind, Expr *op, 1917f9e646b7ed47bc8e9a60031ad0c2b55031e2077Anders Carlsson QualType writtenTy, SourceLocation l) 1927f9e646b7ed47bc8e9a60031ad0c2b55031e2077Anders Carlsson : CXXNamedCastExpr(CXXReinterpretCastExprClass, ty, kind, op, 193cdef2b75aa60cde1ca00e0aa3f89139ac89c6ae4Anders Carlsson writtenTy, l) {} 19449badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor 1951eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump static bool classof(const Stmt *T) { 19649badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor return T->getStmtClass() == CXXReinterpretCastExprClass; 19749badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor } 19849badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor static bool classof(const CXXReinterpretCastExpr *) { return true; } 19949badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor}; 20049badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor 20149badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// CXXConstCastExpr - A C++ @c const_cast expression (C++ [expr.const.cast]), 20249badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// which can remove type qualifiers but does not change the underlying value. 2031eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump/// 20449badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// This expression node represents a const cast, e.g., 20549badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// @c const_cast<char*>(PtrToConstChar). 20649badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregorclass CXXConstCastExpr : public CXXNamedCastExpr { 20749badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregorpublic: 2081eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump CXXConstCastExpr(QualType ty, Expr *op, QualType writtenTy, 20949badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor SourceLocation l) 210cdef2b75aa60cde1ca00e0aa3f89139ac89c6ae4Anders Carlsson : CXXNamedCastExpr(CXXConstCastExprClass, ty, CK_NoOp, op, writtenTy, l) {} 21149badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor 2121eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump static bool classof(const Stmt *T) { 21349badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor return T->getStmtClass() == CXXConstCastExprClass; 21449badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor } 21549badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor static bool classof(const CXXConstCastExpr *) { return true; } 2161060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek}; 2171060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek 2181060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek/// CXXBoolLiteralExpr - [C++ 2.13.5] C++ Boolean Literal. 2191eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump/// 2201060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenekclass CXXBoolLiteralExpr : public Expr { 2211060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek bool Value; 2221060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek SourceLocation Loc; 2231060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenekpublic: 2241eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump CXXBoolLiteralExpr(bool val, QualType Ty, SourceLocation l) : 2251060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek Expr(CXXBoolLiteralExprClass, Ty), Value(val), Loc(l) {} 2268b0b475b3464b0f70b91ba7d679d23c424677d5eSebastian Redl 2271060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek bool getValue() const { return Value; } 2285f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 2291060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek virtual SourceRange getSourceRange() const { return SourceRange(Loc); } 2301eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 2311eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump static bool classof(const Stmt *T) { 2321060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek return T->getStmtClass() == CXXBoolLiteralExprClass; 2331060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek } 2341060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek static bool classof(const CXXBoolLiteralExpr *) { return true; } 2351eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 2361060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek // Iterators 2371060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek virtual child_iterator child_begin(); 2381060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek virtual child_iterator child_end(); 2391060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek}; 2401060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek 2416e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl/// CXXNullPtrLiteralExpr - [C++0x 2.14.7] C++ Pointer Literal 2426e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redlclass CXXNullPtrLiteralExpr : public Expr { 2436e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl SourceLocation Loc; 2446e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redlpublic: 2456e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl CXXNullPtrLiteralExpr(QualType Ty, SourceLocation l) : 2466e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl Expr(CXXNullPtrLiteralExprClass, Ty), Loc(l) {} 2476e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl 2486e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl virtual SourceRange getSourceRange() const { return SourceRange(Loc); } 2496e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl 2506e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl static bool classof(const Stmt *T) { 2516e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl return T->getStmtClass() == CXXNullPtrLiteralExprClass; 2526e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl } 2536e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl static bool classof(const CXXNullPtrLiteralExpr *) { return true; } 2546e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl 2556e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl virtual child_iterator child_begin(); 2566e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl virtual child_iterator child_end(); 2576e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl}; 2586e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl 259c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl/// CXXTypeidExpr - A C++ @c typeid expression (C++ [expr.typeid]), which gets 260c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl/// the type_info that corresponds to the supplied type, or the (possibly 261c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl/// dynamic) type of the supplied expression. 262c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl/// 263c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl/// This represents code like @c typeid(int) or @c typeid(*objPtr) 264c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redlclass CXXTypeidExpr : public Expr { 265c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redlprivate: 266c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl bool isTypeOp : 1; 267d457589fc69dc7a9c80cd74d317c0b81a35a27c9Sebastian Redl union { 268d457589fc69dc7a9c80cd74d317c0b81a35a27c9Sebastian Redl void *Ty; 269d457589fc69dc7a9c80cd74d317c0b81a35a27c9Sebastian Redl Stmt *Ex; 270d457589fc69dc7a9c80cd74d317c0b81a35a27c9Sebastian Redl } Operand; 271c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl SourceRange Range; 272c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl 273c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redlpublic: 274c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl CXXTypeidExpr(bool isTypeOp, void *op, QualType Ty, const SourceRange r) : 2752850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl Expr(CXXTypeidExprClass, Ty, 2762850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl // typeid is never type-dependent (C++ [temp.dep.expr]p4) 2772850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl false, 2782850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl // typeid is value-dependent if the type or expression are dependent 2792850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl (isTypeOp ? QualType::getFromOpaquePtr(op)->isDependentType() 2802850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl : static_cast<Expr*>(op)->isValueDependent())), 2812850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl isTypeOp(isTypeOp), Range(r) { 282d457589fc69dc7a9c80cd74d317c0b81a35a27c9Sebastian Redl if (isTypeOp) 283d457589fc69dc7a9c80cd74d317c0b81a35a27c9Sebastian Redl Operand.Ty = op; 284d457589fc69dc7a9c80cd74d317c0b81a35a27c9Sebastian Redl else 285d457589fc69dc7a9c80cd74d317c0b81a35a27c9Sebastian Redl // op was an Expr*, so cast it back to that to be safe 2862850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl Operand.Ex = static_cast<Expr*>(op); 287d457589fc69dc7a9c80cd74d317c0b81a35a27c9Sebastian Redl } 288c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl 289c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl bool isTypeOperand() const { return isTypeOp; } 290c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl QualType getTypeOperand() const { 291c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl assert(isTypeOperand() && "Cannot call getTypeOperand for typeid(expr)"); 292d457589fc69dc7a9c80cd74d317c0b81a35a27c9Sebastian Redl return QualType::getFromOpaquePtr(Operand.Ty); 293c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl } 294c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl Expr* getExprOperand() const { 295c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl assert(!isTypeOperand() && "Cannot call getExprOperand for typeid(type)"); 296d457589fc69dc7a9c80cd74d317c0b81a35a27c9Sebastian Redl return static_cast<Expr*>(Operand.Ex); 297c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl } 298c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl 299c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl virtual SourceRange getSourceRange() const { 300c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl return Range; 301c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl } 302c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl static bool classof(const Stmt *T) { 303c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl return T->getStmtClass() == CXXTypeidExprClass; 304c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl } 305c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl static bool classof(const CXXTypeidExpr *) { return true; } 306c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl 307c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl // Iterators 308c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl virtual child_iterator child_begin(); 309c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl virtual child_iterator child_end(); 310c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl}; 311c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl 312796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// CXXThisExpr - Represents the "this" expression in C++, which is a 313796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// pointer to the object on which the current member function is 314796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// executing (C++ [expr.prim]p3). Example: 315796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// 316796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// @code 317796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// class Foo { 318796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// public: 319796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// void bar(); 320796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// void test() { this->bar(); } 321796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// }; 322796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// @endcode 323796da18402f286b897782a298ae3b20c459c102eDouglas Gregorclass CXXThisExpr : public Expr { 324796da18402f286b897782a298ae3b20c459c102eDouglas Gregor SourceLocation Loc; 325796da18402f286b897782a298ae3b20c459c102eDouglas Gregor 326796da18402f286b897782a298ae3b20c459c102eDouglas Gregorpublic: 3271eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump CXXThisExpr(SourceLocation L, QualType Type) 3282850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl : Expr(CXXThisExprClass, Type, 3292850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl // 'this' is type-dependent if the class type of the enclosing 3302850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl // member function is dependent (C++ [temp.dep.expr]p2) 3312850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl Type->isDependentType(), Type->isDependentType()), 3322850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl Loc(L) { } 333796da18402f286b897782a298ae3b20c459c102eDouglas Gregor 334796da18402f286b897782a298ae3b20c459c102eDouglas Gregor virtual SourceRange getSourceRange() const { return SourceRange(Loc); } 335796da18402f286b897782a298ae3b20c459c102eDouglas Gregor 3361eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump static bool classof(const Stmt *T) { 337796da18402f286b897782a298ae3b20c459c102eDouglas Gregor return T->getStmtClass() == CXXThisExprClass; 338796da18402f286b897782a298ae3b20c459c102eDouglas Gregor } 339796da18402f286b897782a298ae3b20c459c102eDouglas Gregor static bool classof(const CXXThisExpr *) { return true; } 340796da18402f286b897782a298ae3b20c459c102eDouglas Gregor 341796da18402f286b897782a298ae3b20c459c102eDouglas Gregor // Iterators 342796da18402f286b897782a298ae3b20c459c102eDouglas Gregor virtual child_iterator child_begin(); 343796da18402f286b897782a298ae3b20c459c102eDouglas Gregor virtual child_iterator child_end(); 344796da18402f286b897782a298ae3b20c459c102eDouglas Gregor}; 345796da18402f286b897782a298ae3b20c459c102eDouglas Gregor 3461060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek/// CXXThrowExpr - [C++ 15] C++ Throw Expression. This handles 3471060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek/// 'throw' and 'throw' assignment-expression. When 3481060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek/// assignment-expression isn't present, Op will be null. 3491060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek/// 3501060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenekclass CXXThrowExpr : public Expr { 3511060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek Stmt *Op; 3521060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek SourceLocation ThrowLoc; 3531060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenekpublic: 3541060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek // Ty is the void type which is used as the result type of the 3551060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek // exepression. The l is the location of the throw keyword. expr 3561060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek // can by null, if the optional expression to throw isn't present. 3571060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek CXXThrowExpr(Expr *expr, QualType Ty, SourceLocation l) : 3582850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl Expr(CXXThrowExprClass, Ty, false, false), Op(expr), ThrowLoc(l) {} 3591060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek const Expr *getSubExpr() const { return cast_or_null<Expr>(Op); } 3601060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek Expr *getSubExpr() { return cast_or_null<Expr>(Op); } 36142e5b50f4dc897f252e0d476063a7f9846d96624Douglas Gregor void setSubExpr(Expr *E) { Op = E; } 36242e5b50f4dc897f252e0d476063a7f9846d96624Douglas Gregor 36342e5b50f4dc897f252e0d476063a7f9846d96624Douglas Gregor SourceLocation getThrowLoc() const { return ThrowLoc; } 36442e5b50f4dc897f252e0d476063a7f9846d96624Douglas Gregor void setThrowLoc(SourceLocation L) { ThrowLoc = L; } 3651060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek 3661060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek virtual SourceRange getSourceRange() const { 3671060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek if (getSubExpr() == 0) 3681060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek return SourceRange(ThrowLoc, ThrowLoc); 3691060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek return SourceRange(ThrowLoc, getSubExpr()->getSourceRange().getEnd()); 3701060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek } 3711060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek 3721060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek static bool classof(const Stmt *T) { 3731060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek return T->getStmtClass() == CXXThrowExprClass; 3741060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek } 3751060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek static bool classof(const CXXThrowExpr *) { return true; } 3761060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek 3771060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek // Iterators 3781060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek virtual child_iterator child_begin(); 3791060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek virtual child_iterator child_end(); 3801060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek}; 3811060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek 3821060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek/// CXXDefaultArgExpr - C++ [dcl.fct.default]. This wraps up a 3831060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek/// function call argument that was created from the corresponding 3841060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek/// parameter's default argument, when the call did not explicitly 3851060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek/// supply arguments for all of the parameters. 3861060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenekclass CXXDefaultArgExpr : public Expr { 3871060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek ParmVarDecl *Param; 3881eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 389f1480eee38b59d15438fb7bc50865ac7c7e22403Anders Carlssonprotected: 3901eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump CXXDefaultArgExpr(StmtClass SC, ParmVarDecl *param) 3911eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump : Expr(SC, param->hasUnparsedDefaultArg() ? 392f1480eee38b59d15438fb7bc50865ac7c7e22403Anders Carlsson param->getType().getNonReferenceType() 393f1480eee38b59d15438fb7bc50865ac7c7e22403Anders Carlsson : param->getDefaultArg()->getType()), 394f1480eee38b59d15438fb7bc50865ac7c7e22403Anders Carlsson Param(param) { } 3951eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 3961060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenekpublic: 3971060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek // Param is the parameter whose default argument is used by this 3981060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek // expression. 399f1480eee38b59d15438fb7bc50865ac7c7e22403Anders Carlsson static CXXDefaultArgExpr *Create(ASTContext &C, ParmVarDecl *Param) { 400f1480eee38b59d15438fb7bc50865ac7c7e22403Anders Carlsson return new (C) CXXDefaultArgExpr(CXXDefaultArgExprClass, Param); 401f1480eee38b59d15438fb7bc50865ac7c7e22403Anders Carlsson } 4021060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek 4031060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek // Retrieve the parameter that the argument was created from. 4041060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek const ParmVarDecl *getParam() const { return Param; } 4051060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek ParmVarDecl *getParam() { return Param; } 4061060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek 4071060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek // Retrieve the actual argument to the function call. 4081060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek const Expr *getExpr() const { return Param->getDefaultArg(); } 4091060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek Expr *getExpr() { return Param->getDefaultArg(); } 4101060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek 4111060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek virtual SourceRange getSourceRange() const { 4121060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek // Default argument expressions have no representation in the 4131060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek // source, so they have an empty source range. 4141060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek return SourceRange(); 4151060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek } 4161060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek 4171060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek static bool classof(const Stmt *T) { 4181060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek return T->getStmtClass() == CXXDefaultArgExprClass; 4191060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek } 4201060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek static bool classof(const CXXDefaultArgExpr *) { return true; } 4211060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek 4221060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek // Iterators 4231060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek virtual child_iterator child_begin(); 4241060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek virtual child_iterator child_end(); 4251060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek}; 426987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis 427c1ce477119fed070299668aab24084b17ff5f14bAnders Carlsson/// CXXTemporary - Represents a C++ temporary. 428c1ce477119fed070299668aab24084b17ff5f14bAnders Carlssonclass CXXTemporary { 429c1ce477119fed070299668aab24084b17ff5f14bAnders Carlsson /// Destructor - The destructor that needs to be called. 430b859f35459ae3e1188d1e1b86df08d649695fd86Anders Carlsson const CXXDestructorDecl *Destructor; 4311eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 432b859f35459ae3e1188d1e1b86df08d649695fd86Anders Carlsson CXXTemporary(const CXXDestructorDecl *destructor) 433c1ce477119fed070299668aab24084b17ff5f14bAnders Carlsson : Destructor(destructor) { } 43488eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlsson ~CXXTemporary() { } 435c1ce477119fed070299668aab24084b17ff5f14bAnders Carlsson 436c1ce477119fed070299668aab24084b17ff5f14bAnders Carlssonpublic: 4371eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump static CXXTemporary *Create(ASTContext &C, 438b859f35459ae3e1188d1e1b86df08d649695fd86Anders Carlsson const CXXDestructorDecl *Destructor); 4391eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 44042602bb40aefcc2751d4078ba88aacf4d965c9bdDouglas Gregor void Destroy(ASTContext &Ctx); 4411eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 442f0721fe438d7e40c168e5d664970e7830bc138fbAnders Carlsson const CXXDestructorDecl *getDestructor() const { return Destructor; } 443c1ce477119fed070299668aab24084b17ff5f14bAnders Carlsson}; 444fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson 4451eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump/// CXXBindTemporaryExpr - Represents binding an expression to a temporary, 446fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson/// so its destructor can be called later. 447fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlssonclass CXXBindTemporaryExpr : public Expr { 448fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson CXXTemporary *Temp; 4491eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 450fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson Stmt *SubExpr; 451fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson 4521eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump CXXBindTemporaryExpr(CXXTemporary *temp, Expr* subexpr) 453fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson : Expr(CXXBindTemporaryExprClass, 454fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson subexpr->getType()), Temp(temp), SubExpr(subexpr) { } 4551eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump ~CXXBindTemporaryExpr() { } 45688eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlsson 45742602bb40aefcc2751d4078ba88aacf4d965c9bdDouglas Gregorprotected: 45842602bb40aefcc2751d4078ba88aacf4d965c9bdDouglas Gregor virtual void DoDestroy(ASTContext &C); 45942602bb40aefcc2751d4078ba88aacf4d965c9bdDouglas Gregor 460fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlssonpublic: 4611eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump static CXXBindTemporaryExpr *Create(ASTContext &C, CXXTemporary *Temp, 462fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson Expr* SubExpr); 4631eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 46488eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlsson CXXTemporary *getTemporary() { return Temp; } 465f0721fe438d7e40c168e5d664970e7830bc138fbAnders Carlsson const CXXTemporary *getTemporary() const { return Temp; } 466f0721fe438d7e40c168e5d664970e7830bc138fbAnders Carlsson 467fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson const Expr *getSubExpr() const { return cast<Expr>(SubExpr); } 468fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson Expr *getSubExpr() { return cast<Expr>(SubExpr); } 46988eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlsson void setSubExpr(Expr *E) { SubExpr = E; } 470fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson 47196be6917e1c4ba1f4435a14c9e7c6c139571d086Douglas Gregor virtual SourceRange getSourceRange() const { 47296be6917e1c4ba1f4435a14c9e7c6c139571d086Douglas Gregor return SubExpr->getSourceRange(); 47396be6917e1c4ba1f4435a14c9e7c6c139571d086Douglas Gregor } 474fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson 475fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson // Implement isa/cast/dyncast/etc. 476fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson static bool classof(const Stmt *T) { 477fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson return T->getStmtClass() == CXXBindTemporaryExprClass; 478fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson } 479fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson static bool classof(const CXXBindTemporaryExpr *) { return true; } 480fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson 481fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson // Iterators 482fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson virtual child_iterator child_begin(); 483fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson virtual child_iterator child_end(); 484fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson}; 485fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson 48615ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson/// CXXConstructExpr - Represents a call to a C++ constructor. 48715ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlssonclass CXXConstructExpr : public Expr { 48815ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson CXXConstructorDecl *Constructor; 48915ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson 49015ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson bool Elidable; 4911eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 49215ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson Stmt **Args; 49315ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson unsigned NumArgs; 4941eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 495bd6734e5f6432ce0cc07171c490ffaa094796198Anders Carlssonprotected: 4961eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump CXXConstructExpr(ASTContext &C, StmtClass SC, QualType T, 497bd6734e5f6432ce0cc07171c490ffaa094796198Anders Carlsson CXXConstructorDecl *d, bool elidable, 498bd6734e5f6432ce0cc07171c490ffaa094796198Anders Carlsson Expr **args, unsigned numargs); 4991eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump ~CXXConstructExpr() { } 500bd6734e5f6432ce0cc07171c490ffaa094796198Anders Carlsson 50142602bb40aefcc2751d4078ba88aacf4d965c9bdDouglas Gregor virtual void DoDestroy(ASTContext &C); 50242602bb40aefcc2751d4078ba88aacf4d965c9bdDouglas Gregor 50315ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlssonpublic: 50439da0b8145eaec7da7004f9b3645c5c9f4f63b1dDouglas Gregor /// \brief Construct an empty C++ construction expression that will store 50539da0b8145eaec7da7004f9b3645c5c9f4f63b1dDouglas Gregor /// \p numargs arguments. 50639da0b8145eaec7da7004f9b3645c5c9f4f63b1dDouglas Gregor CXXConstructExpr(EmptyShell Empty, ASTContext &C, unsigned numargs); 50739da0b8145eaec7da7004f9b3645c5c9f4f63b1dDouglas Gregor 5088e587a15da6d3457a418239d5eb4146fcbd209f3Anders Carlsson static CXXConstructExpr *Create(ASTContext &C, QualType T, 5091eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump CXXConstructorDecl *D, bool Elidable, 51015ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson Expr **Args, unsigned NumArgs); 5111eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 5121eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 513d94546a0a1deef7286c13e49b9584621ae81cc9aDouglas Gregor CXXConstructorDecl* getConstructor() const { return Constructor; } 51439da0b8145eaec7da7004f9b3645c5c9f4f63b1dDouglas Gregor void setConstructor(CXXConstructorDecl *C) { Constructor = C; } 51539da0b8145eaec7da7004f9b3645c5c9f4f63b1dDouglas Gregor 516d94546a0a1deef7286c13e49b9584621ae81cc9aDouglas Gregor /// \brief Whether this construction is elidable. 517d94546a0a1deef7286c13e49b9584621ae81cc9aDouglas Gregor bool isElidable() const { return Elidable; } 51839da0b8145eaec7da7004f9b3645c5c9f4f63b1dDouglas Gregor void setElidable(bool E) { Elidable = E; } 51939da0b8145eaec7da7004f9b3645c5c9f4f63b1dDouglas Gregor 52015ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson typedef ExprIterator arg_iterator; 52115ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson typedef ConstExprIterator const_arg_iterator; 5221eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 52315ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson arg_iterator arg_begin() { return Args; } 52415ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson arg_iterator arg_end() { return Args + NumArgs; } 52515ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson const_arg_iterator arg_begin() const { return Args; } 52615ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson const_arg_iterator arg_end() const { return Args + NumArgs; } 52715ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson 52815ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson unsigned getNumArgs() const { return NumArgs; } 52915ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson 530bcb11d01c034f967503bd98f28bdf458c1ab8001Anders Carlsson /// getArg - Return the specified argument. 531bcb11d01c034f967503bd98f28bdf458c1ab8001Anders Carlsson Expr *getArg(unsigned Arg) { 532bcb11d01c034f967503bd98f28bdf458c1ab8001Anders Carlsson assert(Arg < NumArgs && "Arg access out of range!"); 533bcb11d01c034f967503bd98f28bdf458c1ab8001Anders Carlsson return cast<Expr>(Args[Arg]); 534bcb11d01c034f967503bd98f28bdf458c1ab8001Anders Carlsson } 535bcb11d01c034f967503bd98f28bdf458c1ab8001Anders Carlsson const Expr *getArg(unsigned Arg) const { 536bcb11d01c034f967503bd98f28bdf458c1ab8001Anders Carlsson assert(Arg < NumArgs && "Arg access out of range!"); 537bcb11d01c034f967503bd98f28bdf458c1ab8001Anders Carlsson return cast<Expr>(Args[Arg]); 538bcb11d01c034f967503bd98f28bdf458c1ab8001Anders Carlsson } 5391eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 5402eeed7bc4fd457ac57ff32ab3b02674588545f65Fariborz Jahanian /// setArg - Set the specified argument. 5412eeed7bc4fd457ac57ff32ab3b02674588545f65Fariborz Jahanian void setArg(unsigned Arg, Expr *ArgExpr) { 5422eeed7bc4fd457ac57ff32ab3b02674588545f65Fariborz Jahanian assert(Arg < NumArgs && "Arg access out of range!"); 5432eeed7bc4fd457ac57ff32ab3b02674588545f65Fariborz Jahanian Args[Arg] = ArgExpr; 5442eeed7bc4fd457ac57ff32ab3b02674588545f65Fariborz Jahanian } 5452eeed7bc4fd457ac57ff32ab3b02674588545f65Fariborz Jahanian 54696be6917e1c4ba1f4435a14c9e7c6c139571d086Douglas Gregor virtual SourceRange getSourceRange() const { 54796be6917e1c4ba1f4435a14c9e7c6c139571d086Douglas Gregor // FIXME: Should we know where the parentheses are, if there are any? 54896be6917e1c4ba1f4435a14c9e7c6c139571d086Douglas Gregor if (NumArgs == 0) 54996be6917e1c4ba1f4435a14c9e7c6c139571d086Douglas Gregor return SourceRange(); 55096be6917e1c4ba1f4435a14c9e7c6c139571d086Douglas Gregor 55196be6917e1c4ba1f4435a14c9e7c6c139571d086Douglas Gregor return SourceRange(Args[0]->getLocStart(), Args[NumArgs - 1]->getLocEnd()); 55296be6917e1c4ba1f4435a14c9e7c6c139571d086Douglas Gregor } 55315ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson 5541eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump static bool classof(const Stmt *T) { 555524fa13fd81e88533c7a1d4b1232c0de2c97dc7cAnders Carlsson return T->getStmtClass() == CXXConstructExprClass || 556524fa13fd81e88533c7a1d4b1232c0de2c97dc7cAnders Carlsson T->getStmtClass() == CXXTemporaryObjectExprClass; 55715ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson } 55815ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson static bool classof(const CXXConstructExpr *) { return true; } 5591eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 56015ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson // Iterators 56115ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson virtual child_iterator child_begin(); 56215ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson virtual child_iterator child_end(); 56315ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson}; 56415ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson 56549badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// CXXFunctionalCastExpr - Represents an explicit C++ type conversion 56649badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// that uses "functional" notion (C++ [expr.type.conv]). Example: @c 56749badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// x = int(0.5); 56849badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregorclass CXXFunctionalCastExpr : public ExplicitCastExpr { 569987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis SourceLocation TyBeginLoc; 570987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis SourceLocation RParenLoc; 571987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidispublic: 5721eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump CXXFunctionalCastExpr(QualType ty, QualType writtenTy, 5731eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump SourceLocation tyBeginLoc, CastKind kind, 5740aebc81e02397a5987aaa8e8c7acbdb01a31d7c3Anders Carlsson Expr *castExpr, SourceLocation rParenLoc) 5750aebc81e02397a5987aaa8e8c7acbdb01a31d7c3Anders Carlsson : ExplicitCastExpr(CXXFunctionalCastExprClass, ty, kind, castExpr, 5760aebc81e02397a5987aaa8e8c7acbdb01a31d7c3Anders Carlsson writtenTy), 5770aebc81e02397a5987aaa8e8c7acbdb01a31d7c3Anders Carlsson TyBeginLoc(tyBeginLoc), RParenLoc(rParenLoc) {} 5780aebc81e02397a5987aaa8e8c7acbdb01a31d7c3Anders Carlsson 579987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis SourceLocation getTypeBeginLoc() const { return TyBeginLoc; } 580987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis SourceLocation getRParenLoc() const { return RParenLoc; } 5811eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 582987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis virtual SourceRange getSourceRange() const { 583987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis return SourceRange(TyBeginLoc, RParenLoc); 584987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis } 5851eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump static bool classof(const Stmt *T) { 5861eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump return T->getStmtClass() == CXXFunctionalCastExprClass; 587987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis } 588987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis static bool classof(const CXXFunctionalCastExpr *) { return true; } 589987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis}; 590987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis 591506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// @brief Represents a C++ functional cast expression that builds a 592506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// temporary object. 593506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// 5941eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump/// This expression type represents a C++ "functional" cast 595506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// (C++[expr.type.conv]) with N != 1 arguments that invokes a 596506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// constructor to build a temporary object. If N == 0 but no 597506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// constructor will be called (because the functional cast is 598506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// performing a value-initialized an object whose class type has no 599506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// user-declared constructors), CXXZeroInitValueExpr will represent 600506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// the functional cast. Finally, with N == 1 arguments the functional 601506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// cast expression will be represented by CXXFunctionalCastExpr. 602506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// Example: 603506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// @code 604506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// struct X { X(int, float); } 605506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// 606506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// X create_X() { 607506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// return X(1, 3.14f); // creates a CXXTemporaryObjectExpr 608506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// }; 609506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// @endcode 610524fa13fd81e88533c7a1d4b1232c0de2c97dc7cAnders Carlssonclass CXXTemporaryObjectExpr : public CXXConstructExpr { 611506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor SourceLocation TyBeginLoc; 612506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor SourceLocation RParenLoc; 613506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor 614506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregorpublic: 6151eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump CXXTemporaryObjectExpr(ASTContext &C, CXXConstructorDecl *Cons, 6161eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump QualType writtenTy, SourceLocation tyBeginLoc, 6171eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump Expr **Args,unsigned NumArgs, 6188e587a15da6d3457a418239d5eb4146fcbd209f3Anders Carlsson SourceLocation rParenLoc); 619506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor 6201eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump ~CXXTemporaryObjectExpr() { } 621506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor 622506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor SourceLocation getTypeBeginLoc() const { return TyBeginLoc; } 623506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor SourceLocation getRParenLoc() const { return RParenLoc; } 624ba49817c5b9f502602672861cf369fd0e53966e8Douglas Gregor 625506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor virtual SourceRange getSourceRange() const { 626506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor return SourceRange(TyBeginLoc, RParenLoc); 627506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor } 6281eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump static bool classof(const Stmt *T) { 629506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor return T->getStmtClass() == CXXTemporaryObjectExprClass; 630506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor } 631506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor static bool classof(const CXXTemporaryObjectExpr *) { return true; } 632506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor}; 633506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor 634987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis/// CXXZeroInitValueExpr - [C++ 5.2.3p2] 635506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// Expression "T()" which creates a value-initialized rvalue of type 636506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// T, which is either a non-class type or a class type without any 637506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// user-defined constructors. 638987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis/// 639987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidisclass CXXZeroInitValueExpr : public Expr { 640987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis SourceLocation TyBeginLoc; 641987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis SourceLocation RParenLoc; 642987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis 643987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidispublic: 644987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis CXXZeroInitValueExpr(QualType ty, SourceLocation tyBeginLoc, 6451eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump SourceLocation rParenLoc ) : 646d94546a0a1deef7286c13e49b9584621ae81cc9aDouglas Gregor Expr(CXXZeroInitValueExprClass, ty, false, false), 647987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis TyBeginLoc(tyBeginLoc), RParenLoc(rParenLoc) {} 6481eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 649987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis SourceLocation getTypeBeginLoc() const { return TyBeginLoc; } 650987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis SourceLocation getRParenLoc() const { return RParenLoc; } 651987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis 6524c67834407ca6ab344dcf44fc599ad4938cfa96dDouglas Gregor /// @brief Whether this initialization expression was 6534c67834407ca6ab344dcf44fc599ad4938cfa96dDouglas Gregor /// implicitly-generated. 6541eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump bool isImplicit() const { 6551eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump return TyBeginLoc.isInvalid() && RParenLoc.isInvalid(); 6564c67834407ca6ab344dcf44fc599ad4938cfa96dDouglas Gregor } 6574c67834407ca6ab344dcf44fc599ad4938cfa96dDouglas Gregor 658987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis virtual SourceRange getSourceRange() const { 659987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis return SourceRange(TyBeginLoc, RParenLoc); 660987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis } 6611eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 6621eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump static bool classof(const Stmt *T) { 663987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis return T->getStmtClass() == CXXZeroInitValueExprClass; 664987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis } 665987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis static bool classof(const CXXZeroInitValueExpr *) { return true; } 6661eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 667987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis // Iterators 668987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis virtual child_iterator child_begin(); 669987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis virtual child_iterator child_end(); 670987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis}; 671987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis 6729e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis/// CXXConditionDeclExpr - Condition declaration of a if/switch/while/for 6739e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis/// statement, e.g: "if (int x = f()) {...}". 6749e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis/// The main difference with DeclRefExpr is that CXXConditionDeclExpr owns the 6759e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis/// decl that it references. 6769e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis/// 6779e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidisclass CXXConditionDeclExpr : public DeclRefExpr { 6789e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidispublic: 6799e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis CXXConditionDeclExpr(SourceLocation startLoc, 6809e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis SourceLocation eqLoc, VarDecl *var) 6811eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump : DeclRefExpr(CXXConditionDeclExprClass, var, 6824a2e2041edc63db687677325e113b39b9d123c40Douglas Gregor var->getType().getNonReferenceType(), startLoc, 6834a2e2041edc63db687677325e113b39b9d123c40Douglas Gregor var->getType()->isDependentType(), 6844a2e2041edc63db687677325e113b39b9d123c40Douglas Gregor /*FIXME:integral constant?*/ 6854a2e2041edc63db687677325e113b39b9d123c40Douglas Gregor var->getType()->isDependentType()) {} 6869e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis 6879e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis SourceLocation getStartLoc() const { return getLocation(); } 6881eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 6899e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis VarDecl *getVarDecl() { return cast<VarDecl>(getDecl()); } 6909e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis const VarDecl *getVarDecl() const { return cast<VarDecl>(getDecl()); } 6919e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis 6929e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis virtual SourceRange getSourceRange() const { 6939e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis return SourceRange(getStartLoc(), getVarDecl()->getInit()->getLocEnd()); 6949e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis } 6951eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 6961eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump static bool classof(const Stmt *T) { 6979e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis return T->getStmtClass() == CXXConditionDeclExprClass; 6989e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis } 6999e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis static bool classof(const CXXConditionDeclExpr *) { return true; } 7001eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 7019e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis // Iterators 7029e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis virtual child_iterator child_begin(); 7039e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis virtual child_iterator child_end(); 7049e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis}; 7059e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis 7064c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl/// CXXNewExpr - A new expression for memory allocation and constructor calls, 7074c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl/// e.g: "new CXXNewExpr(foo)". 7084c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redlclass CXXNewExpr : public Expr { 7094c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // Was the usage ::new, i.e. is the global new to be used? 7104c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl bool GlobalNew : 1; 7114c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // Was the form (type-id) used? Otherwise, it was new-type-id. 7124c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl bool ParenTypeId : 1; 7134c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // Is there an initializer? If not, built-ins are uninitialized, else they're 7144c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // value-initialized. 7154c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl bool Initializer : 1; 716cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl // Do we allocate an array? If so, the first SubExpr is the size expression. 717cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl bool Array : 1; 7184c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // The number of placement new arguments. 7194c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl unsigned NumPlacementArgs : 14; 7204c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // The number of constructor arguments. This may be 1 even for non-class 7214c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // types; use the pseudo copy constructor. 722cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl unsigned NumConstructorArgs : 14; 723cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl // Contains an optional array size expression, any number of optional 724cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl // placement arguments, and any number of optional constructor arguments, 725cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl // in that order. 7264c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl Stmt **SubExprs; 7274c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // Points to the allocation function used. 7284c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl FunctionDecl *OperatorNew; 7294c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // Points to the deallocation function used in case of error. May be null. 7304c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl FunctionDecl *OperatorDelete; 7314c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // Points to the constructor used. Cannot be null if AllocType is a record; 7324c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // it would still point at the default constructor (even an implicit one). 7334c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // Must be null for all other types. 7344c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl CXXConstructorDecl *Constructor; 7354c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 7364c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl SourceLocation StartLoc; 7374c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl SourceLocation EndLoc; 7384c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 7394c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redlpublic: 7404c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl CXXNewExpr(bool globalNew, FunctionDecl *operatorNew, Expr **placementArgs, 741cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl unsigned numPlaceArgs, bool ParenTypeId, Expr *arraySize, 7424c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl CXXConstructorDecl *constructor, bool initializer, 7434c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl Expr **constructorArgs, unsigned numConsArgs, 7444c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl FunctionDecl *operatorDelete, QualType ty, 7454c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl SourceLocation startLoc, SourceLocation endLoc); 7464c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl ~CXXNewExpr() { 7474c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl delete[] SubExprs; 7484c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 7494c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 750cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl QualType getAllocatedType() const { 751cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl assert(getType()->isPointerType()); 7526217b80b7a1379b74cced1c076338262c3c980b3Ted Kremenek return getType()->getAs<PointerType>()->getPointeeType(); 753cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl } 7544c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 7554c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl FunctionDecl *getOperatorNew() const { return OperatorNew; } 7564c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl FunctionDecl *getOperatorDelete() const { return OperatorDelete; } 7574c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl CXXConstructorDecl *getConstructor() const { return Constructor; } 7584c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 759cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl bool isArray() const { return Array; } 760cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl Expr *getArraySize() { 761cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl return Array ? cast<Expr>(SubExprs[0]) : 0; 762cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl } 763cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl const Expr *getArraySize() const { 764cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl return Array ? cast<Expr>(SubExprs[0]) : 0; 765cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl } 766cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl 7674c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl unsigned getNumPlacementArgs() const { return NumPlacementArgs; } 7684c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl Expr *getPlacementArg(unsigned i) { 7694c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl assert(i < NumPlacementArgs && "Index out of range"); 770cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl return cast<Expr>(SubExprs[Array + i]); 7714c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 7724c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl const Expr *getPlacementArg(unsigned i) const { 7734c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl assert(i < NumPlacementArgs && "Index out of range"); 774cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl return cast<Expr>(SubExprs[Array + i]); 7754c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 7764c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 7774c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl bool isGlobalNew() const { return GlobalNew; } 7784c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl bool isParenTypeId() const { return ParenTypeId; } 7794c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl bool hasInitializer() const { return Initializer; } 7804c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 7814c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl unsigned getNumConstructorArgs() const { return NumConstructorArgs; } 7824c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl Expr *getConstructorArg(unsigned i) { 7834c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl assert(i < NumConstructorArgs && "Index out of range"); 784cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl return cast<Expr>(SubExprs[Array + NumPlacementArgs + i]); 7854c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 7864c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl const Expr *getConstructorArg(unsigned i) const { 7874c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl assert(i < NumConstructorArgs && "Index out of range"); 788cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl return cast<Expr>(SubExprs[Array + NumPlacementArgs + i]); 7894c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 7904c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 7914c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl typedef ExprIterator arg_iterator; 7924c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl typedef ConstExprIterator const_arg_iterator; 7934c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 7944c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl arg_iterator placement_arg_begin() { 795cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl return SubExprs + Array; 7964c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 7974c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl arg_iterator placement_arg_end() { 798cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl return SubExprs + Array + getNumPlacementArgs(); 7994c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 8004c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl const_arg_iterator placement_arg_begin() const { 801cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl return SubExprs + Array; 8024c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 8034c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl const_arg_iterator placement_arg_end() const { 804cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl return SubExprs + Array + getNumPlacementArgs(); 8054c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 8064c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 8074c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl arg_iterator constructor_arg_begin() { 808cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl return SubExprs + Array + getNumPlacementArgs(); 8094c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 8104c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl arg_iterator constructor_arg_end() { 811cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl return SubExprs + Array + getNumPlacementArgs() + getNumConstructorArgs(); 8124c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 8134c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl const_arg_iterator constructor_arg_begin() const { 814cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl return SubExprs + Array + getNumPlacementArgs(); 8154c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 8164c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl const_arg_iterator constructor_arg_end() const { 817cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl return SubExprs + Array + getNumPlacementArgs() + getNumConstructorArgs(); 8184c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 8194c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 8204c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl virtual SourceRange getSourceRange() const { 8214c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl return SourceRange(StartLoc, EndLoc); 8224c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 8234c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 8244c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl static bool classof(const Stmt *T) { 8254c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl return T->getStmtClass() == CXXNewExprClass; 8264c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 8274c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl static bool classof(const CXXNewExpr *) { return true; } 8284c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 8294c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // Iterators 8304c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl virtual child_iterator child_begin(); 8314c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl virtual child_iterator child_end(); 8324c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl}; 8334c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 8344c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl/// CXXDeleteExpr - A delete expression for memory deallocation and destructor 8354c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl/// calls, e.g. "delete[] pArray". 8364c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redlclass CXXDeleteExpr : public Expr { 8374c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // Is this a forced global delete, i.e. "::delete"? 8384c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl bool GlobalDelete : 1; 8394c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // Is this the array form of delete, i.e. "delete[]"? 8404c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl bool ArrayForm : 1; 8414c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // Points to the operator delete overload that is used. Could be a member. 8424c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl FunctionDecl *OperatorDelete; 8434c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // The pointer expression to be deleted. 8444c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl Stmt *Argument; 8454c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // Location of the expression. 8464c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl SourceLocation Loc; 8474c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redlpublic: 8484c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl CXXDeleteExpr(QualType ty, bool globalDelete, bool arrayForm, 8494c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl FunctionDecl *operatorDelete, Expr *arg, SourceLocation loc) 8502850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl : Expr(CXXDeleteExprClass, ty, false, false), GlobalDelete(globalDelete), 8514c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl ArrayForm(arrayForm), OperatorDelete(operatorDelete), Argument(arg), 8524c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl Loc(loc) { } 8534c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 8544c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl bool isGlobalDelete() const { return GlobalDelete; } 8554c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl bool isArrayForm() const { return ArrayForm; } 8564c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 8574c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl FunctionDecl *getOperatorDelete() const { return OperatorDelete; } 8584c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 8594c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl Expr *getArgument() { return cast<Expr>(Argument); } 8604c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl const Expr *getArgument() const { return cast<Expr>(Argument); } 8614c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 8624c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl virtual SourceRange getSourceRange() const { 8634c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl return SourceRange(Loc, Argument->getLocEnd()); 8644c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 8654c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 8664c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl static bool classof(const Stmt *T) { 8674c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl return T->getStmtClass() == CXXDeleteExprClass; 8684c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 8694c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl static bool classof(const CXXDeleteExpr *) { return true; } 8704c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 8714c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // Iterators 8724c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl virtual child_iterator child_begin(); 8734c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl virtual child_iterator child_end(); 8744c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl}; 8754c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 876a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor/// \brief Represents a C++ pseudo-destructor (C++ [expr.pseudo]). 877a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor/// 878a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor/// Example: 879a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor/// 880a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor/// \code 8811eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump/// template<typename T> 882a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor/// void destroy(T* ptr) { 883a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor/// ptr->~T(); 884a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor/// } 885a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor/// \endcode 886a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor/// 887a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor/// When the template is parsed, the expression \c ptr->~T will be stored as 888a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor/// a member reference expression. If it then instantiated with a scalar type 8891eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump/// as a template argument for T, the resulting expression will be a 890a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor/// pseudo-destructor expression. 891a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregorclass CXXPseudoDestructorExpr : public Expr { 892a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor /// \brief The base expression (that is being destroyed). 893a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor Stmt *Base; 8941eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 895a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor /// \brief Whether the operator was an arrow ('->'); otherwise, it was a 896a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor /// period ('.'). 897a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor bool IsArrow : 1; 8981eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 899a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor /// \brief The location of the '.' or '->' operator. 900a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor SourceLocation OperatorLoc; 9011eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 902a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor /// \brief The nested-name-specifier that follows the operator, if present. 903a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor NestedNameSpecifier *Qualifier; 9041eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 9051eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump /// \brief The source range that covers the nested-name-specifier, if 906a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor /// present. 907a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor SourceRange QualifierRange; 9081eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 909a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor /// \brief The type being destroyed. 910a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor QualType DestroyedType; 9111eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 912a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor /// \brief The location of the type after the '~'. 913a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor SourceLocation DestroyedTypeLoc; 9141eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 915a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregorpublic: 916a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor CXXPseudoDestructorExpr(ASTContext &Context, 917a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor Expr *Base, bool isArrow, SourceLocation OperatorLoc, 918a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor NestedNameSpecifier *Qualifier, 919a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor SourceRange QualifierRange, 9201eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump QualType DestroyedType, 921a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor SourceLocation DestroyedTypeLoc) 9221eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump : Expr(CXXPseudoDestructorExprClass, 923a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor Context.getPointerType(Context.getFunctionType(Context.VoidTy, 0, 0, 924a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor false, 0)), 925a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor /*isTypeDependent=*/false, 926a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor /*isValueDependent=*/Base->isValueDependent()), 9271eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump Base(static_cast<Stmt *>(Base)), IsArrow(isArrow), 928a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor OperatorLoc(OperatorLoc), Qualifier(Qualifier), 929a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor QualifierRange(QualifierRange), DestroyedType(DestroyedType), 930a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor DestroyedTypeLoc(DestroyedTypeLoc) { } 9311eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 932a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor void setBase(Expr *E) { Base = E; } 933a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor Expr *getBase() const { return cast<Expr>(Base); } 9341eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 9351eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump /// \brief Determines whether this member expression actually had 936a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor /// a C++ nested-name-specifier prior to the name of the member, e.g., 937a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor /// x->Base::foo. 938a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor bool hasQualifier() const { return Qualifier != 0; } 9391eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 940a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor /// \brief If the member name was qualified, retrieves the source range of 941a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor /// the nested-name-specifier that precedes the member name. Otherwise, 942a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor /// returns an empty source range. 943a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor SourceRange getQualifierRange() const { return QualifierRange; } 9441eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 9451eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump /// \brief If the member name was qualified, retrieves the 946a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor /// nested-name-specifier that precedes the member name. Otherwise, returns 947a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor /// NULL. 948a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor NestedNameSpecifier *getQualifier() const { return Qualifier; } 9491eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 950a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor /// \brief Determine whether this pseudo-destructor expression was written 951a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor /// using an '->' (otherwise, it used a '.'). 952a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor bool isArrow() const { return IsArrow; } 953a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor void setArrow(bool A) { IsArrow = A; } 954a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor 955a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor /// \brief Retrieve the location of the '.' or '->' operator. 956a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor SourceLocation getOperatorLoc() const { return OperatorLoc; } 9571eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 958a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor /// \brief Retrieve the type that is being destroyed. 959a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor QualType getDestroyedType() const { return DestroyedType; } 9601eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 961a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor /// \brief Retrieve the location of the type being destroyed. 962a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor SourceLocation getDestroyedTypeLoc() const { return DestroyedTypeLoc; } 9631eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 964a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor virtual SourceRange getSourceRange() const { 965a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor return SourceRange(Base->getLocStart(), DestroyedTypeLoc); 966a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor } 9671eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 9681eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump static bool classof(const Stmt *T) { 969a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor return T->getStmtClass() == CXXPseudoDestructorExprClass; 970a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor } 971a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor static bool classof(const CXXPseudoDestructorExpr *) { return true; } 9721eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 973a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor // Iterators 974a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor virtual child_iterator child_begin(); 9751eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump virtual child_iterator child_end(); 976a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor}; 9771eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 97817330019f05966762bc952840ef1926b9becb145Douglas Gregor/// \brief Represents the name of a function that has not been 97917330019f05966762bc952840ef1926b9becb145Douglas Gregor/// resolved to any declaration. 98017330019f05966762bc952840ef1926b9becb145Douglas Gregor/// 98117330019f05966762bc952840ef1926b9becb145Douglas Gregor/// Unresolved function names occur when a function name is 98217330019f05966762bc952840ef1926b9becb145Douglas Gregor/// encountered prior to an open parentheses ('(') in a C++ function 98317330019f05966762bc952840ef1926b9becb145Douglas Gregor/// call, and the function name itself did not resolve to a 98417330019f05966762bc952840ef1926b9becb145Douglas Gregor/// declaration. These function names can only be resolved when they 98517330019f05966762bc952840ef1926b9becb145Douglas Gregor/// form the postfix-expression of a function call, so that 98617330019f05966762bc952840ef1926b9becb145Douglas Gregor/// argument-dependent lookup finds declarations corresponding to 98717330019f05966762bc952840ef1926b9becb145Douglas Gregor/// these functions. 98817330019f05966762bc952840ef1926b9becb145Douglas Gregor 9895c37de788529cd9180f22069970737a7208bd625Douglas Gregor/// @code 9905c37de788529cd9180f22069970737a7208bd625Douglas Gregor/// template<typename T> void f(T x) { 99117330019f05966762bc952840ef1926b9becb145Douglas Gregor/// g(x); // g is an unresolved function name (that is also a dependent name) 9925c37de788529cd9180f22069970737a7208bd625Douglas Gregor/// } 9935c37de788529cd9180f22069970737a7208bd625Douglas Gregor/// @endcode 99417330019f05966762bc952840ef1926b9becb145Douglas Gregorclass UnresolvedFunctionNameExpr : public Expr { 9951eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump /// The name that was present in the source 99617330019f05966762bc952840ef1926b9becb145Douglas Gregor DeclarationName Name; 9975c37de788529cd9180f22069970737a7208bd625Douglas Gregor 99817330019f05966762bc952840ef1926b9becb145Douglas Gregor /// The location of this name in the source code 9995c37de788529cd9180f22069970737a7208bd625Douglas Gregor SourceLocation Loc; 10005c37de788529cd9180f22069970737a7208bd625Douglas Gregor 10015c37de788529cd9180f22069970737a7208bd625Douglas Gregorpublic: 100217330019f05966762bc952840ef1926b9becb145Douglas Gregor UnresolvedFunctionNameExpr(DeclarationName N, QualType T, SourceLocation L) 100317330019f05966762bc952840ef1926b9becb145Douglas Gregor : Expr(UnresolvedFunctionNameExprClass, T, false, false), Name(N), Loc(L) { } 10045c37de788529cd9180f22069970737a7208bd625Douglas Gregor 100517330019f05966762bc952840ef1926b9becb145Douglas Gregor /// \brief Retrieves the name that occurred in the source code. 100617330019f05966762bc952840ef1926b9becb145Douglas Gregor DeclarationName getName() const { return Name; } 10075c37de788529cd9180f22069970737a7208bd625Douglas Gregor 10085c37de788529cd9180f22069970737a7208bd625Douglas Gregor /// getLocation - Retrieves the location in the source code where 10095c37de788529cd9180f22069970737a7208bd625Douglas Gregor /// the name occurred. 10105c37de788529cd9180f22069970737a7208bd625Douglas Gregor SourceLocation getLocation() const { return Loc; } 10115c37de788529cd9180f22069970737a7208bd625Douglas Gregor 10125c37de788529cd9180f22069970737a7208bd625Douglas Gregor virtual SourceRange getSourceRange() const { return SourceRange(Loc); } 10135c37de788529cd9180f22069970737a7208bd625Douglas Gregor 10141eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump static bool classof(const Stmt *T) { 101517330019f05966762bc952840ef1926b9becb145Douglas Gregor return T->getStmtClass() == UnresolvedFunctionNameExprClass; 10165c37de788529cd9180f22069970737a7208bd625Douglas Gregor } 101717330019f05966762bc952840ef1926b9becb145Douglas Gregor static bool classof(const UnresolvedFunctionNameExpr *) { return true; } 10185c37de788529cd9180f22069970737a7208bd625Douglas Gregor 10195c37de788529cd9180f22069970737a7208bd625Douglas Gregor // Iterators 10205c37de788529cd9180f22069970737a7208bd625Douglas Gregor virtual child_iterator child_begin(); 10215c37de788529cd9180f22069970737a7208bd625Douglas Gregor virtual child_iterator child_end(); 10225c37de788529cd9180f22069970737a7208bd625Douglas Gregor}; 10235c37de788529cd9180f22069970737a7208bd625Douglas Gregor 102464b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl/// UnaryTypeTraitExpr - A GCC or MS unary type trait, as used in the 102564b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl/// implementation of TR1/C++0x type trait templates. 102664b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl/// Example: 102764b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl/// __is_pod(int) == true 102864b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl/// __is_enum(std::string) == false 102964b45f7e0d3167f040841ac2920aead7f080730dSebastian Redlclass UnaryTypeTraitExpr : public Expr { 103064b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl /// UTT - The trait. 103164b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl UnaryTypeTrait UTT; 103264b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl 103364b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl /// Loc - The location of the type trait keyword. 103464b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl SourceLocation Loc; 103564b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl 103664b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl /// RParen - The location of the closing paren. 103764b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl SourceLocation RParen; 103864b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl 103964b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl /// QueriedType - The type we're testing. 104064b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl QualType QueriedType; 104164b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl 104264b45f7e0d3167f040841ac2920aead7f080730dSebastian Redlpublic: 104364b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl UnaryTypeTraitExpr(SourceLocation loc, UnaryTypeTrait utt, QualType queried, 104464b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl SourceLocation rparen, QualType ty) 104564b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl : Expr(UnaryTypeTraitExprClass, ty, false, queried->isDependentType()), 104664b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl UTT(utt), Loc(loc), RParen(rparen), QueriedType(queried) { } 104764b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl 104864b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl virtual SourceRange getSourceRange() const { return SourceRange(Loc, RParen);} 104964b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl 105064b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl UnaryTypeTrait getTrait() const { return UTT; } 105164b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl 105264b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl QualType getQueriedType() const { return QueriedType; } 105364b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl 10545e03f9ea8174ae588c5e69ec6b5ef4c68f8fd766Douglas Gregor bool EvaluateTrait(ASTContext&) const; 105564b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl 105664b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl static bool classof(const Stmt *T) { 105764b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl return T->getStmtClass() == UnaryTypeTraitExprClass; 105864b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl } 105964b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl static bool classof(const UnaryTypeTraitExpr *) { return true; } 106064b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl 106164b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl // Iterators 106264b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl virtual child_iterator child_begin(); 106364b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl virtual child_iterator child_end(); 106464b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl}; 106564b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl 10665953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor/// \brief A qualified reference to a name whose declaration cannot 10675953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor/// yet be resolved. 10685953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor/// 1069865d447ac6a4721ab58e898d014a21f2eff74b06John McCall/// DependentScopeDeclRefExpr is similar to eclRefExpr in that 1070a2813cec2605ce7878d1b13471d685f689b251afDouglas Gregor/// it expresses a reference to a declaration such as 10715953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor/// X<T>::value. The difference, however, is that an 1072865d447ac6a4721ab58e898d014a21f2eff74b06John McCall/// DependentScopeDeclRefExpr node is used only within C++ templates when 10735953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor/// the qualification (e.g., X<T>::) refers to a dependent type. In 10745953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor/// this case, X<T>::value cannot resolve to a declaration because the 10755953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor/// declaration will differ from on instantiation of X<T> to the 1076865d447ac6a4721ab58e898d014a21f2eff74b06John McCall/// next. Therefore, DependentScopeDeclRefExpr keeps track of the 1077ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor/// qualifier (X<T>::) and the name of the entity being referenced 1078a2813cec2605ce7878d1b13471d685f689b251afDouglas Gregor/// ("value"). Such expressions will instantiate to a DeclRefExpr once the 1079a2813cec2605ce7878d1b13471d685f689b251afDouglas Gregor/// declaration can be found. 1080865d447ac6a4721ab58e898d014a21f2eff74b06John McCallclass DependentScopeDeclRefExpr : public Expr { 10815953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor /// The name of the entity we will be referencing. 10825953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor DeclarationName Name; 10835953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor 10845953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor /// Location of the name of the declaration we're referencing. 10855953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor SourceLocation Loc; 10865953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor 10875953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor /// QualifierRange - The source range that covers the 10885953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor /// nested-name-specifier. 10895953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor SourceRange QualifierRange; 10905953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor 1091ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor /// \brief The nested-name-specifier that qualifies this unresolved 1092ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor /// declaration name. 1093ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor NestedNameSpecifier *NNS; 10945953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor 10959b31df4acdeeb61bb084a03fc37bc5bd570a659eAnders Carlsson /// \brief Whether this expr is an address of (&) operand. 1096a2813cec2605ce7878d1b13471d685f689b251afDouglas Gregor /// FIXME: Stash this bit into NNS! 10979b31df4acdeeb61bb084a03fc37bc5bd570a659eAnders Carlsson bool IsAddressOfOperand; 10981eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 10995953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregorpublic: 1100865d447ac6a4721ab58e898d014a21f2eff74b06John McCall DependentScopeDeclRefExpr(DeclarationName N, QualType T, SourceLocation L, 1101865d447ac6a4721ab58e898d014a21f2eff74b06John McCall SourceRange R, NestedNameSpecifier *NNS, 1102865d447ac6a4721ab58e898d014a21f2eff74b06John McCall bool IsAddressOfOperand) 1103865d447ac6a4721ab58e898d014a21f2eff74b06John McCall : Expr(DependentScopeDeclRefExprClass, T, true, true), 11041eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump Name(N), Loc(L), QualifierRange(R), NNS(NNS), 11059b31df4acdeeb61bb084a03fc37bc5bd570a659eAnders Carlsson IsAddressOfOperand(IsAddressOfOperand) { } 11065953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor 11075953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor /// \brief Retrieve the name that this expression refers to. 11085953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor DeclarationName getDeclName() const { return Name; } 11095953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor 11105953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor /// \brief Retrieve the location of the name within the expression. 11115953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor SourceLocation getLocation() const { return Loc; } 11125953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor 11135953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor /// \brief Retrieve the source range of the nested-name-specifier. 11145953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor SourceRange getQualifierRange() const { return QualifierRange; } 11155953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor 1116ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor /// \brief Retrieve the nested-name-specifier that qualifies this 1117ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor /// declaration. 1118ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor NestedNameSpecifier *getQualifier() const { return NNS; } 11195953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor 11209b31df4acdeeb61bb084a03fc37bc5bd570a659eAnders Carlsson /// \brief Retrieve whether this is an address of (&) operand. 11211eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 11229b31df4acdeeb61bb084a03fc37bc5bd570a659eAnders Carlsson bool isAddressOfOperand() const { return IsAddressOfOperand; } 11231eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump virtual SourceRange getSourceRange() const { 11241eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump return SourceRange(QualifierRange.getBegin(), getLocation()); 11255953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor } 11265953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor 11275953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor static bool classof(const Stmt *T) { 1128865d447ac6a4721ab58e898d014a21f2eff74b06John McCall return T->getStmtClass() == DependentScopeDeclRefExprClass; 11295953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor } 1130865d447ac6a4721ab58e898d014a21f2eff74b06John McCall static bool classof(const DependentScopeDeclRefExpr *) { return true; } 11315953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor 11325953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor virtual StmtIterator child_begin(); 11335953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor virtual StmtIterator child_end(); 11345953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor}; 11355953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor 11361eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump/// \brief An expression that refers to a C++ template-id, such as 11371eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump/// @c isa<FunctionDecl>. 1138edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregorclass TemplateIdRefExpr : public Expr { 1139edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor /// \brief If this template-id was qualified-id, e.g., @c std::sort<int>, 1140edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor /// this nested name specifier contains the @c std::. 1141edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor NestedNameSpecifier *Qualifier; 11421eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1143edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor /// \brief If this template-id was a qualified-id, e.g., @c std::sort<int>, 1144edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor /// this covers the source code range of the @c std::. 1145edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor SourceRange QualifierRange; 11461eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1147edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor /// \brief The actual template to which this template-id refers. 1148edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor TemplateName Template; 11491eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1150edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor /// \brief The source location of the template name. 1151edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor SourceLocation TemplateNameLoc; 1152edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor 1153edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor /// \brief The source location of the left angle bracket ('<'); 1154edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor SourceLocation LAngleLoc; 11551eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1156edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor /// \brief The source location of the right angle bracket ('>'); 1157edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor SourceLocation RAngleLoc; 11581eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1159edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor /// \brief The number of template arguments in TemplateArgs. 1160edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor unsigned NumTemplateArgs; 11611eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1162edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor TemplateIdRefExpr(QualType T, 1163edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor NestedNameSpecifier *Qualifier, SourceRange QualifierRange, 1164edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor TemplateName Template, SourceLocation TemplateNameLoc, 11651eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump SourceLocation LAngleLoc, 1166833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall const TemplateArgumentLoc *TemplateArgs, 1167edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor unsigned NumTemplateArgs, 1168edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor SourceLocation RAngleLoc); 11691eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 117042602bb40aefcc2751d4078ba88aacf4d965c9bdDouglas Gregor virtual void DoDestroy(ASTContext &Context); 11711eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1172edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregorpublic: 1173edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor static TemplateIdRefExpr * 1174edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor Create(ASTContext &Context, QualType T, 1175edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor NestedNameSpecifier *Qualifier, SourceRange QualifierRange, 1176edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor TemplateName Template, SourceLocation TemplateNameLoc, 1177833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall SourceLocation LAngleLoc, const TemplateArgumentLoc *TemplateArgs, 1178edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor unsigned NumTemplateArgs, SourceLocation RAngleLoc); 11791eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1180edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor /// \brief Retrieve the nested name specifier used to qualify the name of 1181edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor /// this template-id, e.g., the "std::sort" in @c std::sort<int>, or NULL 1182edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor /// if this template-id was an unqualified-id. 1183edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor NestedNameSpecifier *getQualifier() const { return Qualifier; } 11841eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1185edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor /// \brief Retrieve the source range describing the nested name specifier 1186edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor /// used to qualified the name of this template-id, if the name was qualified. 1187edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor SourceRange getQualifierRange() const { return QualifierRange; } 11881eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1189edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor /// \brief Retrieve the name of the template referenced, e.g., "sort" in 1190edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor /// @c std::sort<int>; 1191edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor TemplateName getTemplateName() const { return Template; } 11921eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1193edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor /// \brief Retrieve the location of the name of the template referenced, e.g., 1194edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor /// the location of "sort" in @c std::sort<int>. 1195edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor SourceLocation getTemplateNameLoc() const { return TemplateNameLoc; } 11961eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 11971eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump /// \brief Retrieve the location of the left angle bracket following the 1198edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor /// template name ('<'). 1199edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor SourceLocation getLAngleLoc() const { return LAngleLoc; } 12001eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1201edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor /// \brief Retrieve the template arguments provided as part of this 1202edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor /// template-id. 1203833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall const TemplateArgumentLoc *getTemplateArgs() const { 1204833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall return reinterpret_cast<const TemplateArgumentLoc *>(this + 1); 1205edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor } 12061eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1207edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor /// \brief Retrieve the number of template arguments provided as part of this 1208edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor /// template-id. 1209edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor unsigned getNumTemplateArgs() const { return NumTemplateArgs; } 12101eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 12111eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump /// \brief Retrieve the location of the right angle bracket following the 1212edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor /// template arguments ('>'). 1213edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor SourceLocation getRAngleLoc() const { return RAngleLoc; } 12141eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1215edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor virtual SourceRange getSourceRange() const { 1216edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor return SourceRange(Qualifier? QualifierRange.getBegin() : TemplateNameLoc, 1217edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor RAngleLoc); 1218edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor } 12191eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1220edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor // Iterators 1221edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor virtual child_iterator child_begin(); 1222edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor virtual child_iterator child_end(); 12231eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 12241eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump static bool classof(const Stmt *T) { 1225edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor return T->getStmtClass() == TemplateIdRefExprClass; 1226edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor } 1227edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor static bool classof(const TemplateIdRefExpr *) { return true; } 1228edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor}; 12291eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 12302d44e8a41de8a33c0f04ac198714f71dc841bab0Anders Carlssonclass CXXExprWithTemporaries : public Expr { 123102bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson Stmt *SubExpr; 12321eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1233ff6b3d64c9f07155f1414411b8451d7bf8937c62Anders Carlsson CXXTemporary **Temps; 1234ff6b3d64c9f07155f1414411b8451d7bf8937c62Anders Carlsson unsigned NumTemps; 123502bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson 1236f54741e6465692d3bdbae974ac3beeeab92e4a95Anders Carlsson bool ShouldDestroyTemps; 12371eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 12381eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump CXXExprWithTemporaries(Expr *SubExpr, CXXTemporary **Temps, 1239f54741e6465692d3bdbae974ac3beeeab92e4a95Anders Carlsson unsigned NumTemps, bool ShouldDestroyTemps); 12402d44e8a41de8a33c0f04ac198714f71dc841bab0Anders Carlsson ~CXXExprWithTemporaries(); 124142602bb40aefcc2751d4078ba88aacf4d965c9bdDouglas Gregor 124242602bb40aefcc2751d4078ba88aacf4d965c9bdDouglas Gregorprotected: 124342602bb40aefcc2751d4078ba88aacf4d965c9bdDouglas Gregor virtual void DoDestroy(ASTContext &C); 124442602bb40aefcc2751d4078ba88aacf4d965c9bdDouglas Gregor 124588eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlssonpublic: 124688eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlsson static CXXExprWithTemporaries *Create(ASTContext &C, Expr *SubExpr, 1247f54741e6465692d3bdbae974ac3beeeab92e4a95Anders Carlsson CXXTemporary **Temps, unsigned NumTemps, 1248f54741e6465692d3bdbae974ac3beeeab92e4a95Anders Carlsson bool ShouldDestroyTemporaries); 12491eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 125088eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlsson unsigned getNumTemporaries() const { return NumTemps; } 125188eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlsson CXXTemporary *getTemporary(unsigned i) { 125288eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlsson assert(i < NumTemps && "Index out of range"); 125388eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlsson return Temps[i]; 125488eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlsson } 1255f0721fe438d7e40c168e5d664970e7830bc138fbAnders Carlsson const CXXTemporary *getTemporary(unsigned i) const { 1256f0721fe438d7e40c168e5d664970e7830bc138fbAnders Carlsson assert(i < NumTemps && "Index out of range"); 1257f0721fe438d7e40c168e5d664970e7830bc138fbAnders Carlsson return Temps[i]; 1258f0721fe438d7e40c168e5d664970e7830bc138fbAnders Carlsson } 12591eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1260f54741e6465692d3bdbae974ac3beeeab92e4a95Anders Carlsson bool shouldDestroyTemporaries() const { return ShouldDestroyTemps; } 12611eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 126288eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlsson void removeLastTemporary() { NumTemps--; } 12631eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 126402bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson Expr *getSubExpr() { return cast<Expr>(SubExpr); } 1265f0721fe438d7e40c168e5d664970e7830bc138fbAnders Carlsson const Expr *getSubExpr() const { return cast<Expr>(SubExpr); } 126688eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlsson void setSubExpr(Expr *E) { SubExpr = E; } 126702bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson 126896be6917e1c4ba1f4435a14c9e7c6c139571d086Douglas Gregor virtual SourceRange getSourceRange() const { 126996be6917e1c4ba1f4435a14c9e7c6c139571d086Douglas Gregor return SubExpr->getSourceRange(); 127096be6917e1c4ba1f4435a14c9e7c6c139571d086Douglas Gregor } 127102bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson 127202bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson // Implement isa/cast/dyncast/etc. 127302bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson static bool classof(const Stmt *T) { 12742d44e8a41de8a33c0f04ac198714f71dc841bab0Anders Carlsson return T->getStmtClass() == CXXExprWithTemporariesClass; 127502bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson } 12762d44e8a41de8a33c0f04ac198714f71dc841bab0Anders Carlsson static bool classof(const CXXExprWithTemporaries *) { return true; } 127702bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson 127802bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson // Iterators 127902bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson virtual child_iterator child_begin(); 128002bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson virtual child_iterator child_end(); 128102bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson}; 128202bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson 1283d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// \brief Describes an explicit type conversion that uses functional 1284d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// notion but could not be resolved because one or more arguments are 1285d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// type-dependent. 1286d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// 1287d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// The explicit type conversions expressed by 1288d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// CXXUnresolvedConstructExpr have the form \c T(a1, a2, ..., aN), 1289d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// where \c T is some type and \c a1, a2, ..., aN are values, and 1290d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// either \C T is a dependent type or one or more of the \c a's is 1291d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// type-dependent. For example, this would occur in a template such 1292d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// as: 1293d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// 1294d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// \code 1295d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// template<typename T, typename A1> 1296d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// inline T make_a(const A1& a1) { 1297d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// return T(a1); 1298d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// } 1299d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// \endcode 1300d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// 1301d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// When the returned expression is instantiated, it may resolve to a 1302d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// constructor call, conversion function call, or some kind of type 1303d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// conversion. 1304d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregorclass CXXUnresolvedConstructExpr : public Expr { 1305d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor /// \brief The starting location of the type 1306d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor SourceLocation TyBeginLoc; 1307d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor 1308d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor /// \brief The type being constructed. 1309d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor QualType Type; 1310d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor 1311d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor /// \brief The location of the left parentheses ('('). 1312d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor SourceLocation LParenLoc; 1313d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor 1314d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor /// \brief The location of the right parentheses (')'). 1315d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor SourceLocation RParenLoc; 1316d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor 1317d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor /// \brief The number of arguments used to construct the type. 1318d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor unsigned NumArgs; 13191eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1320d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor CXXUnresolvedConstructExpr(SourceLocation TyBegin, 1321d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor QualType T, 1322d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor SourceLocation LParenLoc, 1323d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor Expr **Args, 1324d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor unsigned NumArgs, 1325d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor SourceLocation RParenLoc); 1326d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor 1327d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregorpublic: 13281eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump static CXXUnresolvedConstructExpr *Create(ASTContext &C, 1329d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor SourceLocation TyBegin, 1330d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor QualType T, 1331d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor SourceLocation LParenLoc, 1332d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor Expr **Args, 1333d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor unsigned NumArgs, 1334d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor SourceLocation RParenLoc); 1335d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor 1336d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor /// \brief Retrieve the source location where the type begins. 1337d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor SourceLocation getTypeBeginLoc() const { return TyBeginLoc; } 1338d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor void setTypeBeginLoc(SourceLocation L) { TyBeginLoc = L; } 1339d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor 1340d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor /// \brief Retrieve the type that is being constructed, as specified 1341d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor /// in the source code. 1342d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor QualType getTypeAsWritten() const { return Type; } 1343d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor void setTypeAsWritten(QualType T) { Type = T; } 1344d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor 1345d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor /// \brief Retrieve the location of the left parentheses ('(') that 1346d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor /// precedes the argument list. 1347d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor SourceLocation getLParenLoc() const { return LParenLoc; } 1348d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor void setLParenLoc(SourceLocation L) { LParenLoc = L; } 1349d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor 1350d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor /// \brief Retrieve the location of the right parentheses (')') that 1351d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor /// follows the argument list. 1352d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor SourceLocation getRParenLoc() const { return RParenLoc; } 1353d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor void setRParenLoc(SourceLocation L) { RParenLoc = L; } 1354d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor 1355d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor /// \brief Retrieve the number of arguments. 1356d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor unsigned arg_size() const { return NumArgs; } 1357d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor 1358d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor typedef Expr** arg_iterator; 1359d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor arg_iterator arg_begin() { return reinterpret_cast<Expr**>(this + 1); } 1360d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor arg_iterator arg_end() { return arg_begin() + NumArgs; } 1361d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor 1362d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor Expr *getArg(unsigned I) { 1363d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor assert(I < NumArgs && "Argument index out-of-range"); 1364d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor return *(arg_begin() + I); 1365d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor } 1366d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor 1367d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor virtual SourceRange getSourceRange() const { 1368d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor return SourceRange(TyBeginLoc, RParenLoc); 1369d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor } 13701eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump static bool classof(const Stmt *T) { 1371d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor return T->getStmtClass() == CXXUnresolvedConstructExprClass; 1372d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor } 1373d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor static bool classof(const CXXUnresolvedConstructExpr *) { return true; } 1374d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor 1375d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor // Iterators 1376d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor virtual child_iterator child_begin(); 1377d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor virtual child_iterator child_end(); 1378d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor}; 1379d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor 1380bd4c4aebe6035e7a7125470cc9f0f92511230ee3Douglas Gregor/// \brief Represents a C++ member access expression where the actual member 1381bd4c4aebe6035e7a7125470cc9f0f92511230ee3Douglas Gregor/// referenced could not be resolved, e.g., because the base expression or the 1382bd4c4aebe6035e7a7125470cc9f0f92511230ee3Douglas Gregor/// member name was dependent. 1383865d447ac6a4721ab58e898d014a21f2eff74b06John McCallclass CXXDependentScopeMemberExpr : public Expr { 13841c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor /// \brief The expression for the base pointer or class reference, 13851c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor /// e.g., the \c x in x.f. 13861c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor Stmt *Base; 13871eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 13881c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor /// \brief Whether this member expression used the '->' operator or 13891c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor /// the '.' operator. 13903b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor bool IsArrow : 1; 13911c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor 13923b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor /// \brief Whether this member expression has explicitly-specified template 13933b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor /// arguments. 13943b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor bool HasExplicitTemplateArgumentList : 1; 13951eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 13961c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor /// \brief The location of the '->' or '.' operator. 13971c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor SourceLocation OperatorLoc; 13981c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor 1399a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor /// \brief The nested-name-specifier that precedes the member name, if any. 1400a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor NestedNameSpecifier *Qualifier; 14011eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1402a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor /// \brief The source range covering the nested name specifier. 1403a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor SourceRange QualifierRange; 14041eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1405c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor /// \brief In a qualified member access expression such as t->Base::f, this 14061eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump /// member stores the resolves of name lookup in the context of the member 1407c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor /// access expression, to be used at instantiation time. 1408c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor /// 1409c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor /// FIXME: This member, along with the Qualifier and QualifierRange, could 1410c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor /// be stuck into a structure that is optionally allocated at the end of 1411865d447ac6a4721ab58e898d014a21f2eff74b06John McCall /// the CXXDependentScopeMemberExpr, to save space in the common case. 1412c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor NamedDecl *FirstQualifierFoundInScope; 14131eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 14141c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor /// \brief The member to which this member expression refers, which 14151c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor /// can be name, overloaded operator, or destructor. 1416a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor /// FIXME: could also be a template-id 14171c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor DeclarationName Member; 14181c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor 14191c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor /// \brief The location of the member name. 14201c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor SourceLocation MemberLoc; 14211eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 14223b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor /// \brief Retrieve the explicit template argument list that followed the 14233b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor /// member template name, if any. 14243b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor ExplicitTemplateArgumentList *getExplicitTemplateArgumentList() { 14253b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor if (!HasExplicitTemplateArgumentList) 14263b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor return 0; 14271eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 14283b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor return reinterpret_cast<ExplicitTemplateArgumentList *>(this + 1); 14293b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor } 14301eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 14313b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor /// \brief Retrieve the explicit template argument list that followed the 14323b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor /// member template name, if any. 14333b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor const ExplicitTemplateArgumentList *getExplicitTemplateArgumentList() const { 1434865d447ac6a4721ab58e898d014a21f2eff74b06John McCall return const_cast<CXXDependentScopeMemberExpr *>(this) 14353b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor ->getExplicitTemplateArgumentList(); 14363b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor } 14371eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1438865d447ac6a4721ab58e898d014a21f2eff74b06John McCall CXXDependentScopeMemberExpr(ASTContext &C, 14391eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump Expr *Base, bool IsArrow, 14403b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor SourceLocation OperatorLoc, 14413b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor NestedNameSpecifier *Qualifier, 14423b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor SourceRange QualifierRange, 14433b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor NamedDecl *FirstQualifierFoundInScope, 14443b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor DeclarationName Member, 14453b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor SourceLocation MemberLoc, 14463b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor bool HasExplicitTemplateArgs, 14473b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor SourceLocation LAngleLoc, 1448833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall const TemplateArgumentLoc *TemplateArgs, 14493b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor unsigned NumTemplateArgs, 14503b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor SourceLocation RAngleLoc); 14511eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 14521c0ca59416999129d0439c2661d137ef38e86209Douglas Gregorpublic: 1453865d447ac6a4721ab58e898d014a21f2eff74b06John McCall CXXDependentScopeMemberExpr(ASTContext &C, 14541eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump Expr *Base, bool IsArrow, 14551c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor SourceLocation OperatorLoc, 1456a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor NestedNameSpecifier *Qualifier, 1457a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor SourceRange QualifierRange, 1458c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor NamedDecl *FirstQualifierFoundInScope, 14591c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor DeclarationName Member, 14601c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor SourceLocation MemberLoc) 1461865d447ac6a4721ab58e898d014a21f2eff74b06John McCall : Expr(CXXDependentScopeMemberExprClass, C.DependentTy, true, true), 14623b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor Base(Base), IsArrow(IsArrow), HasExplicitTemplateArgumentList(false), 14633b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor OperatorLoc(OperatorLoc), 14643b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor Qualifier(Qualifier), QualifierRange(QualifierRange), 14653b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor FirstQualifierFoundInScope(FirstQualifierFoundInScope), 14663b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor Member(Member), MemberLoc(MemberLoc) { } 14671eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1468865d447ac6a4721ab58e898d014a21f2eff74b06John McCall static CXXDependentScopeMemberExpr * 14691eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump Create(ASTContext &C, 14701eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump Expr *Base, bool IsArrow, 14713b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor SourceLocation OperatorLoc, 14723b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor NestedNameSpecifier *Qualifier, 14733b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor SourceRange QualifierRange, 14743b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor NamedDecl *FirstQualifierFoundInScope, 14753b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor DeclarationName Member, 14763b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor SourceLocation MemberLoc, 14773b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor bool HasExplicitTemplateArgs, 14783b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor SourceLocation LAngleLoc, 1479833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall const TemplateArgumentLoc *TemplateArgs, 14803b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor unsigned NumTemplateArgs, 14813b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor SourceLocation RAngleLoc); 14821eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 14831c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor /// \brief Retrieve the base object of this member expressions, 14841c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor /// e.g., the \c x in \c x.m. 14851c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor Expr *getBase() { return cast<Expr>(Base); } 14861c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor void setBase(Expr *E) { Base = E; } 14871c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor 14881c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor /// \brief Determine whether this member expression used the '->' 14891c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor /// operator; otherwise, it used the '.' operator. 14901c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor bool isArrow() const { return IsArrow; } 14911c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor void setArrow(bool A) { IsArrow = A; } 14921c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor 14931c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor /// \brief Retrieve the location of the '->' or '.' operator. 14941c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor SourceLocation getOperatorLoc() const { return OperatorLoc; } 14951c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor void setOperatorLoc(SourceLocation L) { OperatorLoc = L; } 14961c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor 1497a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor /// \brief Retrieve the nested-name-specifier that qualifies the member 1498a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor /// name. 1499a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor NestedNameSpecifier *getQualifier() const { return Qualifier; } 15001eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1501a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor /// \brief Retrieve the source range covering the nested-name-specifier 1502a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor /// that qualifies the member name. 1503a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor SourceRange getQualifierRange() const { return QualifierRange; } 15041eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1505c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor /// \brief Retrieve the first part of the nested-name-specifier that was 1506c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor /// found in the scope of the member access expression when the member access 1507c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor /// was initially parsed. 1508c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor /// 1509c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor /// This function only returns a useful result when member access expression 15101eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump /// uses a qualified member name, e.g., "x.Base::f". Here, the declaration 15111eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump /// returned by this function describes what was found by unqualified name 1512c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor /// lookup for the identifier "Base" within the scope of the member access 1513c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor /// expression itself. At template instantiation time, this information is 1514c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor /// combined with the results of name lookup into the type of the object 1515c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor /// expression itself (the class type of x). 15161eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump NamedDecl *getFirstQualifierFoundInScope() const { 1517c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor return FirstQualifierFoundInScope; 1518c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor } 15191eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 15201c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor /// \brief Retrieve the name of the member that this expression 15211c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor /// refers to. 15221c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor DeclarationName getMember() const { return Member; } 15231c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor void setMember(DeclarationName N) { Member = N; } 15241c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor 15251c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor // \brief Retrieve the location of the name of the member that this 15261c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor // expression refers to. 15271c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor SourceLocation getMemberLoc() const { return MemberLoc; } 15281c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor void setMemberLoc(SourceLocation L) { MemberLoc = L; } 15291c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor 15303b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor /// \brief Determines whether this member expression actually had a C++ 15313b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor /// template argument list explicitly specified, e.g., x.f<int>. 15321eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump bool hasExplicitTemplateArgumentList() { 15331eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump return HasExplicitTemplateArgumentList; 15343b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor } 15351eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 15361eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump /// \brief Retrieve the location of the left angle bracket following the 15373b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor /// member name ('<'), if any. 15381eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump SourceLocation getLAngleLoc() const { 15393b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor if (!HasExplicitTemplateArgumentList) 15403b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor return SourceLocation(); 15411eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 15423b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor return getExplicitTemplateArgumentList()->LAngleLoc; 15433b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor } 15441eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 15453b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor /// \brief Retrieve the template arguments provided as part of this 15463b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor /// template-id. 1547833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall const TemplateArgumentLoc *getTemplateArgs() const { 15483b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor if (!HasExplicitTemplateArgumentList) 15491eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump return 0; 15501eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 15513b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor return getExplicitTemplateArgumentList()->getTemplateArgs(); 15523b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor } 15531eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 15543b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor /// \brief Retrieve the number of template arguments provided as part of this 15553b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor /// template-id. 15561eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump unsigned getNumTemplateArgs() const { 15573b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor if (!HasExplicitTemplateArgumentList) 15581eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump return 0; 15591eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 15603b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor return getExplicitTemplateArgumentList()->NumTemplateArgs; 15613b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor } 15621eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 15631eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump /// \brief Retrieve the location of the right angle bracket following the 15643b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor /// template arguments ('>'). 15651eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump SourceLocation getRAngleLoc() const { 15663b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor if (!HasExplicitTemplateArgumentList) 15673b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor return SourceLocation(); 15681eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 15693b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor return getExplicitTemplateArgumentList()->RAngleLoc; 15703b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor } 15711eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 15721c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor virtual SourceRange getSourceRange() const { 15733b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor if (HasExplicitTemplateArgumentList) 15743b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor return SourceRange(Base->getSourceRange().getBegin(), 15753b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor getRAngleLoc()); 15761eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 15771c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor return SourceRange(Base->getSourceRange().getBegin(), 15781c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor MemberLoc); 15791c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor } 15801eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 15811eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump static bool classof(const Stmt *T) { 1582865d447ac6a4721ab58e898d014a21f2eff74b06John McCall return T->getStmtClass() == CXXDependentScopeMemberExprClass; 15831c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor } 1584865d447ac6a4721ab58e898d014a21f2eff74b06John McCall static bool classof(const CXXDependentScopeMemberExpr *) { return true; } 15851c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor 15861c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor // Iterators 15871c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor virtual child_iterator child_begin(); 15881c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor virtual child_iterator child_end(); 15891c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor}; 15901c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor 15915f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer} // end namespace clang 15925f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 15935f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer#endif 1594