ExprCXX.h revision a38c687ef5354678b9d76a7b29354159f2b83736
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: 50063daf6e196c51f162e0485478355d8e280eef5cDouglas Gregor CXXOperatorCallExpr(ASTContext& C, OverloadedOperatorKind Op, Expr *fn, 51063daf6e196c51f162e0485478355d8e280eef5cDouglas Gregor Expr **args, unsigned numargs, QualType t, 52063daf6e196c51f162e0485478355d8e280eef5cDouglas Gregor SourceLocation operatorloc) 53063daf6e196c51f162e0485478355d8e280eef5cDouglas Gregor : CallExpr(C, CXXOperatorCallExprClass, fn, args, numargs, t, operatorloc), 54063daf6e196c51f162e0485478355d8e280eef5cDouglas Gregor Operator(Op) {} 55ba0a9006dbc4814e1e35f82812cb5a1dad65e8b8Argyrios Kyrtzidis explicit CXXOperatorCallExpr(ASTContext& C, EmptyShell Empty) : 56ba0a9006dbc4814e1e35f82812cb5a1dad65e8b8Argyrios Kyrtzidis CallExpr(C, CXXOperatorCallExprClass, Empty) { } 57ba0a9006dbc4814e1e35f82812cb5a1dad65e8b8Argyrios Kyrtzidis 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; 72b4609806e9232593ece09ce08b630836e825865cDouglas Gregor 73b4609806e9232593ece09ce08b630836e825865cDouglas Gregor static bool classof(const Stmt *T) { 74b4609806e9232593ece09ce08b630836e825865cDouglas Gregor 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 9888a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor static bool classof(const Stmt *T) { 9988a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor return T->getStmtClass() == CXXMemberCallExprClass; 10088a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor } 10188a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor static bool classof(const CXXMemberCallExpr *) { return true; } 10288a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor}; 10388a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor 10449badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// CXXNamedCastExpr - Abstract class common to all of the C++ "named" 10549badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// casts, @c static_cast, @c dynamic_cast, @c reinterpret_cast, or @c 10649badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// const_cast. 10749badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// 10849badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// This abstract class is inherited by all of the classes 10949badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// representing "named" casts, e.g., CXXStaticCastExpr, 11049badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// CXXDynamicCastExpr, CXXReinterpretCastExpr, and CXXConstCastExpr. 11149badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregorclass CXXNamedCastExpr : public ExplicitCastExpr { 1121060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenekprivate: 1131060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek SourceLocation Loc; // the location of the casting op 11449badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor 11549badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregorprotected: 116bd0fb30fa2a039439d1a30a83ea896801394d780Anders Carlsson CXXNamedCastExpr(StmtClass SC, QualType ty, const CastInfo &info, Expr *op, 117cdef2b75aa60cde1ca00e0aa3f89139ac89c6ae4Anders Carlsson QualType writtenTy, SourceLocation l) 118bd0fb30fa2a039439d1a30a83ea896801394d780Anders Carlsson : ExplicitCastExpr(SC, ty, info, op, writtenTy), Loc(l) {} 11949badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor 1201060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenekpublic: 12149badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor const char *getCastName() const; 12249badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor 123a3a7b8eea87c90a5a257f685749222b212ddaf36Douglas Gregor /// \brief Retrieve the location of the cast operator keyword, e.g., 124a3a7b8eea87c90a5a257f685749222b212ddaf36Douglas Gregor /// "static_cast". 125a3a7b8eea87c90a5a257f685749222b212ddaf36Douglas Gregor SourceLocation getOperatorLoc() const { return Loc; } 126a3a7b8eea87c90a5a257f685749222b212ddaf36Douglas Gregor void setOperatorLoc(SourceLocation L) { Loc = L; } 127a3a7b8eea87c90a5a257f685749222b212ddaf36Douglas Gregor 1281060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek virtual SourceRange getSourceRange() const { 1291060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek return SourceRange(Loc, getSubExpr()->getSourceRange().getEnd()); 1301060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek } 1311060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek static bool classof(const Stmt *T) { 13249badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor switch (T->getStmtClass()) { 13349badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor case CXXNamedCastExprClass: 13449badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor case CXXStaticCastExprClass: 13549badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor case CXXDynamicCastExprClass: 13649badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor case CXXReinterpretCastExprClass: 13749badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor case CXXConstCastExprClass: 13849badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor return true; 13949badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor default: 14049badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor return false; 14149badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor } 1421060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek } 14349badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor static bool classof(const CXXNamedCastExpr *) { return true; } 14449badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor}; 14549badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor 14649badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// CXXStaticCastExpr - A C++ @c static_cast expression (C++ [expr.static.cast]). 14749badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// 14849badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// This expression node represents a C++ static cast, e.g., 14949badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// @c static_cast<int>(1.0). 15049badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregorclass CXXStaticCastExpr : public CXXNamedCastExpr { 15149badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregorpublic: 152bd0fb30fa2a039439d1a30a83ea896801394d780Anders Carlsson CXXStaticCastExpr(QualType ty, const CastInfo &info, Expr *op, 153bd0fb30fa2a039439d1a30a83ea896801394d780Anders Carlsson QualType writtenTy, SourceLocation l) 154bd0fb30fa2a039439d1a30a83ea896801394d780Anders Carlsson : CXXNamedCastExpr(CXXStaticCastExprClass, ty, info, op, writtenTy, l) {} 15549badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor 15649badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor static bool classof(const Stmt *T) { 15749badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor return T->getStmtClass() == CXXStaticCastExprClass; 15849badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor } 15949badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor static bool classof(const CXXStaticCastExpr *) { return true; } 16049badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor}; 16149badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor 16249badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// CXXDynamicCastExpr - A C++ @c dynamic_cast expression 16349badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// (C++ [expr.dynamic.cast]), which may perform a run-time check to 16449badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// determine how to perform the type cast. 16549badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// 16649badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// This expression node represents a dynamic cast, e.g., 16749badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// @c dynamic_cast<Derived*>(BasePtr). 16849badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregorclass CXXDynamicCastExpr : public CXXNamedCastExpr { 16949badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregorpublic: 170cdef2b75aa60cde1ca00e0aa3f89139ac89c6ae4Anders Carlsson CXXDynamicCastExpr(QualType ty, CastKind kind, Expr *op, QualType writtenTy, 171cdef2b75aa60cde1ca00e0aa3f89139ac89c6ae4Anders Carlsson SourceLocation l) 172cdef2b75aa60cde1ca00e0aa3f89139ac89c6ae4Anders Carlsson : CXXNamedCastExpr(CXXDynamicCastExprClass, ty, kind, op, writtenTy, l) {} 17349badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor 17449badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor static bool classof(const Stmt *T) { 17549badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor return T->getStmtClass() == CXXDynamicCastExprClass; 17649badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor } 17749badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor static bool classof(const CXXDynamicCastExpr *) { return true; } 17849badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor}; 17949badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor 18049badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// CXXReinterpretCastExpr - A C++ @c reinterpret_cast expression (C++ 18149badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// [expr.reinterpret.cast]), which provides a differently-typed view 18249badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// of a value but performs no actual work at run time. 18349badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// 18449badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// This expression node represents a reinterpret cast, e.g., 18549badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// @c reinterpret_cast<int>(VoidPtr). 18649badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregorclass CXXReinterpretCastExpr : public CXXNamedCastExpr { 18749badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregorpublic: 18849badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor CXXReinterpretCastExpr(QualType ty, Expr *op, QualType writtenTy, 18949badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor SourceLocation l) 190cdef2b75aa60cde1ca00e0aa3f89139ac89c6ae4Anders Carlsson : CXXNamedCastExpr(CXXReinterpretCastExprClass, ty, CK_BitCast, op, 191cdef2b75aa60cde1ca00e0aa3f89139ac89c6ae4Anders Carlsson writtenTy, l) {} 19249badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor 19349badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor static bool classof(const Stmt *T) { 19449badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor return T->getStmtClass() == CXXReinterpretCastExprClass; 19549badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor } 19649badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor static bool classof(const CXXReinterpretCastExpr *) { return true; } 19749badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor}; 19849badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor 19949badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// CXXConstCastExpr - A C++ @c const_cast expression (C++ [expr.const.cast]), 20049badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// which can remove type qualifiers but does not change the underlying value. 20149badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// 20249badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// This expression node represents a const cast, e.g., 20349badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// @c const_cast<char*>(PtrToConstChar). 20449badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregorclass CXXConstCastExpr : public CXXNamedCastExpr { 20549badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregorpublic: 20649badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor CXXConstCastExpr(QualType ty, Expr *op, QualType writtenTy, 20749badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor SourceLocation l) 208cdef2b75aa60cde1ca00e0aa3f89139ac89c6ae4Anders Carlsson : CXXNamedCastExpr(CXXConstCastExprClass, ty, CK_NoOp, op, writtenTy, l) {} 20949badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor 21049badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor static bool classof(const Stmt *T) { 21149badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor return T->getStmtClass() == CXXConstCastExprClass; 21249badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor } 21349badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor static bool classof(const CXXConstCastExpr *) { return true; } 2141060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek}; 2151060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek 2161060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek/// CXXBoolLiteralExpr - [C++ 2.13.5] C++ Boolean Literal. 2171060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek/// 2181060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenekclass CXXBoolLiteralExpr : public Expr { 2191060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek bool Value; 2201060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek SourceLocation Loc; 2211060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenekpublic: 2221060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek CXXBoolLiteralExpr(bool val, QualType Ty, SourceLocation l) : 2231060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek Expr(CXXBoolLiteralExprClass, Ty), Value(val), Loc(l) {} 2248b0b475b3464b0f70b91ba7d679d23c424677d5eSebastian Redl 2251060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek bool getValue() const { return Value; } 2265f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 2271060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek virtual SourceRange getSourceRange() const { return SourceRange(Loc); } 2285f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 2291060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek static bool classof(const Stmt *T) { 2301060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek return T->getStmtClass() == CXXBoolLiteralExprClass; 2311060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek } 2321060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek static bool classof(const CXXBoolLiteralExpr *) { return true; } 2335f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 2341060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek // Iterators 2351060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek virtual child_iterator child_begin(); 2361060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek virtual child_iterator child_end(); 2371060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek}; 2381060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek 2396e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl/// CXXNullPtrLiteralExpr - [C++0x 2.14.7] C++ Pointer Literal 2406e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redlclass CXXNullPtrLiteralExpr : public Expr { 2416e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl SourceLocation Loc; 2426e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redlpublic: 2436e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl CXXNullPtrLiteralExpr(QualType Ty, SourceLocation l) : 2446e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl Expr(CXXNullPtrLiteralExprClass, Ty), Loc(l) {} 2456e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl 2466e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl virtual SourceRange getSourceRange() const { return SourceRange(Loc); } 2476e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl 2486e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl static bool classof(const Stmt *T) { 2496e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl return T->getStmtClass() == CXXNullPtrLiteralExprClass; 2506e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl } 2516e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl static bool classof(const CXXNullPtrLiteralExpr *) { return true; } 2526e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl 2536e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl virtual child_iterator child_begin(); 2546e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl virtual child_iterator child_end(); 2556e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl}; 2566e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl 257c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl/// CXXTypeidExpr - A C++ @c typeid expression (C++ [expr.typeid]), which gets 258c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl/// the type_info that corresponds to the supplied type, or the (possibly 259c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl/// dynamic) type of the supplied expression. 260c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl/// 261c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl/// This represents code like @c typeid(int) or @c typeid(*objPtr) 262c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redlclass CXXTypeidExpr : public Expr { 263c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redlprivate: 264c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl bool isTypeOp : 1; 265d457589fc69dc7a9c80cd74d317c0b81a35a27c9Sebastian Redl union { 266d457589fc69dc7a9c80cd74d317c0b81a35a27c9Sebastian Redl void *Ty; 267d457589fc69dc7a9c80cd74d317c0b81a35a27c9Sebastian Redl Stmt *Ex; 268d457589fc69dc7a9c80cd74d317c0b81a35a27c9Sebastian Redl } Operand; 269c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl SourceRange Range; 270c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl 271c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redlpublic: 272c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl CXXTypeidExpr(bool isTypeOp, void *op, QualType Ty, const SourceRange r) : 2732850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl Expr(CXXTypeidExprClass, Ty, 2742850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl // typeid is never type-dependent (C++ [temp.dep.expr]p4) 2752850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl false, 2762850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl // typeid is value-dependent if the type or expression are dependent 2772850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl (isTypeOp ? QualType::getFromOpaquePtr(op)->isDependentType() 2782850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl : static_cast<Expr*>(op)->isValueDependent())), 2792850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl isTypeOp(isTypeOp), Range(r) { 280d457589fc69dc7a9c80cd74d317c0b81a35a27c9Sebastian Redl if (isTypeOp) 281d457589fc69dc7a9c80cd74d317c0b81a35a27c9Sebastian Redl Operand.Ty = op; 282d457589fc69dc7a9c80cd74d317c0b81a35a27c9Sebastian Redl else 283d457589fc69dc7a9c80cd74d317c0b81a35a27c9Sebastian Redl // op was an Expr*, so cast it back to that to be safe 2842850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl Operand.Ex = static_cast<Expr*>(op); 285d457589fc69dc7a9c80cd74d317c0b81a35a27c9Sebastian Redl } 286c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl 287c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl bool isTypeOperand() const { return isTypeOp; } 288c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl QualType getTypeOperand() const { 289c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl assert(isTypeOperand() && "Cannot call getTypeOperand for typeid(expr)"); 290d457589fc69dc7a9c80cd74d317c0b81a35a27c9Sebastian Redl return QualType::getFromOpaquePtr(Operand.Ty); 291c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl } 292c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl Expr* getExprOperand() const { 293c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl assert(!isTypeOperand() && "Cannot call getExprOperand for typeid(type)"); 294d457589fc69dc7a9c80cd74d317c0b81a35a27c9Sebastian Redl return static_cast<Expr*>(Operand.Ex); 295c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl } 296c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl 297c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl virtual SourceRange getSourceRange() const { 298c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl return Range; 299c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl } 300c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl static bool classof(const Stmt *T) { 301c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl return T->getStmtClass() == CXXTypeidExprClass; 302c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl } 303c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl static bool classof(const CXXTypeidExpr *) { return true; } 304c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl 305c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl // Iterators 306c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl virtual child_iterator child_begin(); 307c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl virtual child_iterator child_end(); 308c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl}; 309c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl 310796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// CXXThisExpr - Represents the "this" expression in C++, which is a 311796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// pointer to the object on which the current member function is 312796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// executing (C++ [expr.prim]p3). Example: 313796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// 314796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// @code 315796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// class Foo { 316796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// public: 317796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// void bar(); 318796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// void test() { this->bar(); } 319796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// }; 320796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// @endcode 321796da18402f286b897782a298ae3b20c459c102eDouglas Gregorclass CXXThisExpr : public Expr { 322796da18402f286b897782a298ae3b20c459c102eDouglas Gregor SourceLocation Loc; 323796da18402f286b897782a298ae3b20c459c102eDouglas Gregor 324796da18402f286b897782a298ae3b20c459c102eDouglas Gregorpublic: 325796da18402f286b897782a298ae3b20c459c102eDouglas Gregor CXXThisExpr(SourceLocation L, QualType Type) 3262850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl : Expr(CXXThisExprClass, Type, 3272850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl // 'this' is type-dependent if the class type of the enclosing 3282850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl // member function is dependent (C++ [temp.dep.expr]p2) 3292850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl Type->isDependentType(), Type->isDependentType()), 3302850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl Loc(L) { } 331796da18402f286b897782a298ae3b20c459c102eDouglas Gregor 332796da18402f286b897782a298ae3b20c459c102eDouglas Gregor virtual SourceRange getSourceRange() const { return SourceRange(Loc); } 333796da18402f286b897782a298ae3b20c459c102eDouglas Gregor 334796da18402f286b897782a298ae3b20c459c102eDouglas Gregor static bool classof(const Stmt *T) { 335796da18402f286b897782a298ae3b20c459c102eDouglas Gregor return T->getStmtClass() == CXXThisExprClass; 336796da18402f286b897782a298ae3b20c459c102eDouglas Gregor } 337796da18402f286b897782a298ae3b20c459c102eDouglas Gregor static bool classof(const CXXThisExpr *) { return true; } 338796da18402f286b897782a298ae3b20c459c102eDouglas Gregor 339796da18402f286b897782a298ae3b20c459c102eDouglas Gregor // Iterators 340796da18402f286b897782a298ae3b20c459c102eDouglas Gregor virtual child_iterator child_begin(); 341796da18402f286b897782a298ae3b20c459c102eDouglas Gregor virtual child_iterator child_end(); 342796da18402f286b897782a298ae3b20c459c102eDouglas Gregor}; 343796da18402f286b897782a298ae3b20c459c102eDouglas Gregor 3441060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek/// CXXThrowExpr - [C++ 15] C++ Throw Expression. This handles 3451060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek/// 'throw' and 'throw' assignment-expression. When 3461060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek/// assignment-expression isn't present, Op will be null. 3471060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek/// 3481060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenekclass CXXThrowExpr : public Expr { 3491060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek Stmt *Op; 3501060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek SourceLocation ThrowLoc; 3511060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenekpublic: 3521060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek // Ty is the void type which is used as the result type of the 3531060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek // exepression. The l is the location of the throw keyword. expr 3541060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek // can by null, if the optional expression to throw isn't present. 3551060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek CXXThrowExpr(Expr *expr, QualType Ty, SourceLocation l) : 3562850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl Expr(CXXThrowExprClass, Ty, false, false), Op(expr), ThrowLoc(l) {} 3571060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek const Expr *getSubExpr() const { return cast_or_null<Expr>(Op); } 3581060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek Expr *getSubExpr() { return cast_or_null<Expr>(Op); } 35942e5b50f4dc897f252e0d476063a7f9846d96624Douglas Gregor void setSubExpr(Expr *E) { Op = E; } 36042e5b50f4dc897f252e0d476063a7f9846d96624Douglas Gregor 36142e5b50f4dc897f252e0d476063a7f9846d96624Douglas Gregor SourceLocation getThrowLoc() const { return ThrowLoc; } 36242e5b50f4dc897f252e0d476063a7f9846d96624Douglas Gregor void setThrowLoc(SourceLocation L) { ThrowLoc = L; } 3631060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek 3641060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek virtual SourceRange getSourceRange() const { 3651060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek if (getSubExpr() == 0) 3661060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek return SourceRange(ThrowLoc, ThrowLoc); 3671060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek return SourceRange(ThrowLoc, getSubExpr()->getSourceRange().getEnd()); 3681060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek } 3691060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek 3701060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek static bool classof(const Stmt *T) { 3711060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek return T->getStmtClass() == CXXThrowExprClass; 3721060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek } 3731060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek static bool classof(const CXXThrowExpr *) { return true; } 3741060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek 3751060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek // Iterators 3761060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek virtual child_iterator child_begin(); 3771060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek virtual child_iterator child_end(); 3781060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek}; 3791060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek 3801060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek/// CXXDefaultArgExpr - C++ [dcl.fct.default]. This wraps up a 3811060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek/// function call argument that was created from the corresponding 3821060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek/// parameter's default argument, when the call did not explicitly 3831060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek/// supply arguments for all of the parameters. 3841060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenekclass CXXDefaultArgExpr : public Expr { 3851060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek ParmVarDecl *Param; 386f1480eee38b59d15438fb7bc50865ac7c7e22403Anders Carlsson 387f1480eee38b59d15438fb7bc50865ac7c7e22403Anders Carlssonprotected: 388f1480eee38b59d15438fb7bc50865ac7c7e22403Anders Carlsson CXXDefaultArgExpr(StmtClass SC, ParmVarDecl *param) 389f1480eee38b59d15438fb7bc50865ac7c7e22403Anders Carlsson : Expr(SC, param->hasUnparsedDefaultArg() ? 390f1480eee38b59d15438fb7bc50865ac7c7e22403Anders Carlsson param->getType().getNonReferenceType() 391f1480eee38b59d15438fb7bc50865ac7c7e22403Anders Carlsson : param->getDefaultArg()->getType()), 392f1480eee38b59d15438fb7bc50865ac7c7e22403Anders Carlsson Param(param) { } 393f1480eee38b59d15438fb7bc50865ac7c7e22403Anders Carlsson 3941060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenekpublic: 3951060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek // Param is the parameter whose default argument is used by this 3961060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek // expression. 397f1480eee38b59d15438fb7bc50865ac7c7e22403Anders Carlsson static CXXDefaultArgExpr *Create(ASTContext &C, ParmVarDecl *Param) { 398f1480eee38b59d15438fb7bc50865ac7c7e22403Anders Carlsson return new (C) CXXDefaultArgExpr(CXXDefaultArgExprClass, Param); 399f1480eee38b59d15438fb7bc50865ac7c7e22403Anders Carlsson } 4001060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek 4011060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek // Retrieve the parameter that the argument was created from. 4021060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek const ParmVarDecl *getParam() const { return Param; } 4031060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek ParmVarDecl *getParam() { return Param; } 4041060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek 4051060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek // Retrieve the actual argument to the function call. 4061060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek const Expr *getExpr() const { return Param->getDefaultArg(); } 4071060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek Expr *getExpr() { return Param->getDefaultArg(); } 4081060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek 4091060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek virtual SourceRange getSourceRange() const { 4101060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek // Default argument expressions have no representation in the 4111060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek // source, so they have an empty source range. 4121060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek return SourceRange(); 4131060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek } 4141060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek 4151060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek static bool classof(const Stmt *T) { 4161060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek return T->getStmtClass() == CXXDefaultArgExprClass; 4171060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek } 4181060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek static bool classof(const CXXDefaultArgExpr *) { return true; } 4191060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek 4201060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek // Iterators 4211060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek virtual child_iterator child_begin(); 4221060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek virtual child_iterator child_end(); 4231060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek}; 424987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis 425c1ce477119fed070299668aab24084b17ff5f14bAnders Carlsson/// CXXTemporary - Represents a C++ temporary. 426c1ce477119fed070299668aab24084b17ff5f14bAnders Carlssonclass CXXTemporary { 427c1ce477119fed070299668aab24084b17ff5f14bAnders Carlsson /// Destructor - The destructor that needs to be called. 428b859f35459ae3e1188d1e1b86df08d649695fd86Anders Carlsson const CXXDestructorDecl *Destructor; 429c1ce477119fed070299668aab24084b17ff5f14bAnders Carlsson 430b859f35459ae3e1188d1e1b86df08d649695fd86Anders Carlsson CXXTemporary(const CXXDestructorDecl *destructor) 431c1ce477119fed070299668aab24084b17ff5f14bAnders Carlsson : Destructor(destructor) { } 43288eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlsson ~CXXTemporary() { } 433c1ce477119fed070299668aab24084b17ff5f14bAnders Carlsson 434c1ce477119fed070299668aab24084b17ff5f14bAnders Carlssonpublic: 435b859f35459ae3e1188d1e1b86df08d649695fd86Anders Carlsson static CXXTemporary *Create(ASTContext &C, 436b859f35459ae3e1188d1e1b86df08d649695fd86Anders Carlsson const CXXDestructorDecl *Destructor); 43742602bb40aefcc2751d4078ba88aacf4d965c9bdDouglas Gregor 43842602bb40aefcc2751d4078ba88aacf4d965c9bdDouglas Gregor void Destroy(ASTContext &Ctx); 439f0721fe438d7e40c168e5d664970e7830bc138fbAnders Carlsson 440f0721fe438d7e40c168e5d664970e7830bc138fbAnders Carlsson const CXXDestructorDecl *getDestructor() const { return Destructor; } 441c1ce477119fed070299668aab24084b17ff5f14bAnders Carlsson}; 442fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson 443fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson/// CXXBindTemporaryExpr - Represents binding an expression to a temporary, 444fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson/// so its destructor can be called later. 445fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlssonclass CXXBindTemporaryExpr : public Expr { 446fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson CXXTemporary *Temp; 447fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson 448fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson Stmt *SubExpr; 449fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson 450fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson CXXBindTemporaryExpr(CXXTemporary *temp, Expr* subexpr) 451fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson : Expr(CXXBindTemporaryExprClass, 452fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson subexpr->getType()), Temp(temp), SubExpr(subexpr) { } 45388eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlsson ~CXXBindTemporaryExpr() { } 45488eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlsson 45542602bb40aefcc2751d4078ba88aacf4d965c9bdDouglas Gregorprotected: 45642602bb40aefcc2751d4078ba88aacf4d965c9bdDouglas Gregor virtual void DoDestroy(ASTContext &C); 45742602bb40aefcc2751d4078ba88aacf4d965c9bdDouglas Gregor 458fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlssonpublic: 459fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson static CXXBindTemporaryExpr *Create(ASTContext &C, CXXTemporary *Temp, 460fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson Expr* SubExpr); 46188eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlsson 46288eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlsson CXXTemporary *getTemporary() { return Temp; } 463f0721fe438d7e40c168e5d664970e7830bc138fbAnders Carlsson const CXXTemporary *getTemporary() const { return Temp; } 464f0721fe438d7e40c168e5d664970e7830bc138fbAnders Carlsson 465fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson const Expr *getSubExpr() const { return cast<Expr>(SubExpr); } 466fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson Expr *getSubExpr() { return cast<Expr>(SubExpr); } 46788eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlsson void setSubExpr(Expr *E) { SubExpr = E; } 468fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson 469fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson virtual SourceRange getSourceRange() const { return SourceRange(); } 470fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson 471fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson // Implement isa/cast/dyncast/etc. 472fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson static bool classof(const Stmt *T) { 473fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson return T->getStmtClass() == CXXBindTemporaryExprClass; 474fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson } 475fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson static bool classof(const CXXBindTemporaryExpr *) { return true; } 476fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson 477fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson // Iterators 478fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson virtual child_iterator child_begin(); 479fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson virtual child_iterator child_end(); 480fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson}; 481fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson 48215ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson/// CXXConstructExpr - Represents a call to a C++ constructor. 48315ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlssonclass CXXConstructExpr : public Expr { 48415ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson CXXConstructorDecl *Constructor; 48515ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson 48615ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson bool Elidable; 48715ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson 48815ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson Stmt **Args; 48915ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson unsigned NumArgs; 49015ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson 491bd6734e5f6432ce0cc07171c490ffaa094796198Anders Carlssonprotected: 4928e587a15da6d3457a418239d5eb4146fcbd209f3Anders Carlsson CXXConstructExpr(ASTContext &C, StmtClass SC, QualType T, 493bd6734e5f6432ce0cc07171c490ffaa094796198Anders Carlsson CXXConstructorDecl *d, bool elidable, 494bd6734e5f6432ce0cc07171c490ffaa094796198Anders Carlsson Expr **args, unsigned numargs); 495524fa13fd81e88533c7a1d4b1232c0de2c97dc7cAnders Carlsson ~CXXConstructExpr() { } 496bd6734e5f6432ce0cc07171c490ffaa094796198Anders Carlsson 49742602bb40aefcc2751d4078ba88aacf4d965c9bdDouglas Gregor virtual void DoDestroy(ASTContext &C); 49842602bb40aefcc2751d4078ba88aacf4d965c9bdDouglas Gregor 49915ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlssonpublic: 5008e587a15da6d3457a418239d5eb4146fcbd209f3Anders Carlsson static CXXConstructExpr *Create(ASTContext &C, QualType T, 50115ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson CXXConstructorDecl *D, bool Elidable, 50215ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson Expr **Args, unsigned NumArgs); 50315ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson 50415ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson 505d94546a0a1deef7286c13e49b9584621ae81cc9aDouglas Gregor CXXConstructorDecl* getConstructor() const { return Constructor; } 506d94546a0a1deef7286c13e49b9584621ae81cc9aDouglas Gregor 507d94546a0a1deef7286c13e49b9584621ae81cc9aDouglas Gregor /// \brief Whether this construction is elidable. 508d94546a0a1deef7286c13e49b9584621ae81cc9aDouglas Gregor bool isElidable() const { return Elidable; } 50915ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson 51015ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson typedef ExprIterator arg_iterator; 51115ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson typedef ConstExprIterator const_arg_iterator; 51215ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson 51315ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson arg_iterator arg_begin() { return Args; } 51415ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson arg_iterator arg_end() { return Args + NumArgs; } 51515ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson const_arg_iterator arg_begin() const { return Args; } 51615ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson const_arg_iterator arg_end() const { return Args + NumArgs; } 51715ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson 51815ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson unsigned getNumArgs() const { return NumArgs; } 51915ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson 5202eeed7bc4fd457ac57ff32ab3b02674588545f65Fariborz Jahanian /// setArg - Set the specified argument. 5212eeed7bc4fd457ac57ff32ab3b02674588545f65Fariborz Jahanian void setArg(unsigned Arg, Expr *ArgExpr) { 5222eeed7bc4fd457ac57ff32ab3b02674588545f65Fariborz Jahanian assert(Arg < NumArgs && "Arg access out of range!"); 5232eeed7bc4fd457ac57ff32ab3b02674588545f65Fariborz Jahanian Args[Arg] = ArgExpr; 5242eeed7bc4fd457ac57ff32ab3b02674588545f65Fariborz Jahanian } 5252eeed7bc4fd457ac57ff32ab3b02674588545f65Fariborz Jahanian 52615ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson virtual SourceRange getSourceRange() const { return SourceRange(); } 52715ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson 52815ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson static bool classof(const Stmt *T) { 529524fa13fd81e88533c7a1d4b1232c0de2c97dc7cAnders Carlsson return T->getStmtClass() == CXXConstructExprClass || 530524fa13fd81e88533c7a1d4b1232c0de2c97dc7cAnders Carlsson T->getStmtClass() == CXXTemporaryObjectExprClass; 53115ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson } 53215ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson static bool classof(const CXXConstructExpr *) { return true; } 53315ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson 53415ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson // Iterators 53515ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson virtual child_iterator child_begin(); 53615ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson virtual child_iterator child_end(); 53715ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson}; 53815ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson 53949badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// CXXFunctionalCastExpr - Represents an explicit C++ type conversion 54049badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// that uses "functional" notion (C++ [expr.type.conv]). Example: @c 54149badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// x = int(0.5); 54249badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregorclass CXXFunctionalCastExpr : public ExplicitCastExpr { 543e9f42087aabfdb6b2afc35c7e38ac65da063b409Fariborz Jahanian CXXMethodDecl *TypeConversionMethod; 544987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis SourceLocation TyBeginLoc; 545987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis SourceLocation RParenLoc; 546987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidispublic: 54749badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor CXXFunctionalCastExpr(QualType ty, QualType writtenTy, 548cdef2b75aa60cde1ca00e0aa3f89139ac89c6ae4Anders Carlsson SourceLocation tyBeginLoc, CastKind kind, 549e9f42087aabfdb6b2afc35c7e38ac65da063b409Fariborz Jahanian Expr *castExpr, CXXMethodDecl *typeConversionMethod, 550e9f42087aabfdb6b2afc35c7e38ac65da063b409Fariborz Jahanian SourceLocation rParenLoc) : 551cdef2b75aa60cde1ca00e0aa3f89139ac89c6ae4Anders Carlsson ExplicitCastExpr(CXXFunctionalCastExprClass, ty, kind, castExpr, writtenTy), 552e9f42087aabfdb6b2afc35c7e38ac65da063b409Fariborz Jahanian TypeConversionMethod(typeConversionMethod), 553987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis TyBeginLoc(tyBeginLoc), RParenLoc(rParenLoc) {} 554987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis 555e9f42087aabfdb6b2afc35c7e38ac65da063b409Fariborz Jahanian CXXMethodDecl *getTypeConversionMethod() const 556e9f42087aabfdb6b2afc35c7e38ac65da063b409Fariborz Jahanian { return TypeConversionMethod; } 557987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis SourceLocation getTypeBeginLoc() const { return TyBeginLoc; } 558987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis SourceLocation getRParenLoc() const { return RParenLoc; } 559987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis 560987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis virtual SourceRange getSourceRange() const { 561987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis return SourceRange(TyBeginLoc, RParenLoc); 562987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis } 563987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis static bool classof(const Stmt *T) { 564987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis return T->getStmtClass() == CXXFunctionalCastExprClass; 565987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis } 566987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis static bool classof(const CXXFunctionalCastExpr *) { return true; } 567987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis}; 568987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis 569506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// @brief Represents a C++ functional cast expression that builds a 570506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// temporary object. 571506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// 572506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// This expression type represents a C++ "functional" cast 573506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// (C++[expr.type.conv]) with N != 1 arguments that invokes a 574506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// constructor to build a temporary object. If N == 0 but no 575506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// constructor will be called (because the functional cast is 576506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// performing a value-initialized an object whose class type has no 577506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// user-declared constructors), CXXZeroInitValueExpr will represent 578506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// the functional cast. Finally, with N == 1 arguments the functional 579506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// cast expression will be represented by CXXFunctionalCastExpr. 580506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// Example: 581506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// @code 582506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// struct X { X(int, float); } 583506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// 584506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// X create_X() { 585506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// return X(1, 3.14f); // creates a CXXTemporaryObjectExpr 586506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// }; 587506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// @endcode 588524fa13fd81e88533c7a1d4b1232c0de2c97dc7cAnders Carlssonclass CXXTemporaryObjectExpr : public CXXConstructExpr { 589506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor SourceLocation TyBeginLoc; 590506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor SourceLocation RParenLoc; 591506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor 592506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregorpublic: 5938e587a15da6d3457a418239d5eb4146fcbd209f3Anders Carlsson CXXTemporaryObjectExpr(ASTContext &C, CXXConstructorDecl *Cons, 5948e587a15da6d3457a418239d5eb4146fcbd209f3Anders Carlsson QualType writtenTy, SourceLocation tyBeginLoc, 5958e587a15da6d3457a418239d5eb4146fcbd209f3Anders Carlsson Expr **Args,unsigned NumArgs, 5968e587a15da6d3457a418239d5eb4146fcbd209f3Anders Carlsson SourceLocation rParenLoc); 597506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor 598524fa13fd81e88533c7a1d4b1232c0de2c97dc7cAnders Carlsson ~CXXTemporaryObjectExpr() { } 599506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor 600506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor SourceLocation getTypeBeginLoc() const { return TyBeginLoc; } 601506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor SourceLocation getRParenLoc() const { return RParenLoc; } 602ba49817c5b9f502602672861cf369fd0e53966e8Douglas Gregor 603506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor virtual SourceRange getSourceRange() const { 604506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor return SourceRange(TyBeginLoc, RParenLoc); 605506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor } 606506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor static bool classof(const Stmt *T) { 607506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor return T->getStmtClass() == CXXTemporaryObjectExprClass; 608506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor } 609506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor static bool classof(const CXXTemporaryObjectExpr *) { return true; } 610506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor}; 611506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor 612987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis/// CXXZeroInitValueExpr - [C++ 5.2.3p2] 613506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// Expression "T()" which creates a value-initialized rvalue of type 614506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// T, which is either a non-class type or a class type without any 615506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// user-defined constructors. 616987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis/// 617987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidisclass CXXZeroInitValueExpr : public Expr { 618987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis SourceLocation TyBeginLoc; 619987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis SourceLocation RParenLoc; 620987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis 621987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidispublic: 622987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis CXXZeroInitValueExpr(QualType ty, SourceLocation tyBeginLoc, 623987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis SourceLocation rParenLoc ) : 624d94546a0a1deef7286c13e49b9584621ae81cc9aDouglas Gregor Expr(CXXZeroInitValueExprClass, ty, false, false), 625987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis TyBeginLoc(tyBeginLoc), RParenLoc(rParenLoc) {} 626987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis 627987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis SourceLocation getTypeBeginLoc() const { return TyBeginLoc; } 628987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis SourceLocation getRParenLoc() const { return RParenLoc; } 629987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis 6304c67834407ca6ab344dcf44fc599ad4938cfa96dDouglas Gregor /// @brief Whether this initialization expression was 6314c67834407ca6ab344dcf44fc599ad4938cfa96dDouglas Gregor /// implicitly-generated. 6324c67834407ca6ab344dcf44fc599ad4938cfa96dDouglas Gregor bool isImplicit() const { 6334c67834407ca6ab344dcf44fc599ad4938cfa96dDouglas Gregor return TyBeginLoc.isInvalid() && RParenLoc.isInvalid(); 6344c67834407ca6ab344dcf44fc599ad4938cfa96dDouglas Gregor } 6354c67834407ca6ab344dcf44fc599ad4938cfa96dDouglas Gregor 636987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis virtual SourceRange getSourceRange() const { 637987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis return SourceRange(TyBeginLoc, RParenLoc); 638987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis } 639987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis 640987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis static bool classof(const Stmt *T) { 641987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis return T->getStmtClass() == CXXZeroInitValueExprClass; 642987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis } 643987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis static bool classof(const CXXZeroInitValueExpr *) { return true; } 644987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis 645987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis // Iterators 646987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis virtual child_iterator child_begin(); 647987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis virtual child_iterator child_end(); 648987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis}; 649987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis 6509e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis/// CXXConditionDeclExpr - Condition declaration of a if/switch/while/for 6519e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis/// statement, e.g: "if (int x = f()) {...}". 6529e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis/// The main difference with DeclRefExpr is that CXXConditionDeclExpr owns the 6539e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis/// decl that it references. 6549e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis/// 6559e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidisclass CXXConditionDeclExpr : public DeclRefExpr { 6569e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidispublic: 6579e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis CXXConditionDeclExpr(SourceLocation startLoc, 6589e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis SourceLocation eqLoc, VarDecl *var) 6599d293dfc0ad7c44ae0b5eb9517f1ed8c8d8b7ff7Douglas Gregor : DeclRefExpr(CXXConditionDeclExprClass, var, 6604a2e2041edc63db687677325e113b39b9d123c40Douglas Gregor var->getType().getNonReferenceType(), startLoc, 6614a2e2041edc63db687677325e113b39b9d123c40Douglas Gregor var->getType()->isDependentType(), 6624a2e2041edc63db687677325e113b39b9d123c40Douglas Gregor /*FIXME:integral constant?*/ 6634a2e2041edc63db687677325e113b39b9d123c40Douglas Gregor var->getType()->isDependentType()) {} 6649e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis 6659e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis SourceLocation getStartLoc() const { return getLocation(); } 6669e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis 6679e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis VarDecl *getVarDecl() { return cast<VarDecl>(getDecl()); } 6689e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis const VarDecl *getVarDecl() const { return cast<VarDecl>(getDecl()); } 6699e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis 6709e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis virtual SourceRange getSourceRange() const { 6719e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis return SourceRange(getStartLoc(), getVarDecl()->getInit()->getLocEnd()); 6729e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis } 6739e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis 6749e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis static bool classof(const Stmt *T) { 6759e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis return T->getStmtClass() == CXXConditionDeclExprClass; 6769e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis } 6779e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis static bool classof(const CXXConditionDeclExpr *) { return true; } 6789e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis 6799e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis // Iterators 6809e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis virtual child_iterator child_begin(); 6819e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis virtual child_iterator child_end(); 6829e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis}; 6839e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis 6844c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl/// CXXNewExpr - A new expression for memory allocation and constructor calls, 6854c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl/// e.g: "new CXXNewExpr(foo)". 6864c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redlclass CXXNewExpr : public Expr { 6874c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // Was the usage ::new, i.e. is the global new to be used? 6884c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl bool GlobalNew : 1; 6894c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // Was the form (type-id) used? Otherwise, it was new-type-id. 6904c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl bool ParenTypeId : 1; 6914c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // Is there an initializer? If not, built-ins are uninitialized, else they're 6924c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // value-initialized. 6934c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl bool Initializer : 1; 694cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl // Do we allocate an array? If so, the first SubExpr is the size expression. 695cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl bool Array : 1; 6964c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // The number of placement new arguments. 6974c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl unsigned NumPlacementArgs : 14; 6984c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // The number of constructor arguments. This may be 1 even for non-class 6994c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // types; use the pseudo copy constructor. 700cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl unsigned NumConstructorArgs : 14; 701cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl // Contains an optional array size expression, any number of optional 702cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl // placement arguments, and any number of optional constructor arguments, 703cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl // in that order. 7044c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl Stmt **SubExprs; 7054c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // Points to the allocation function used. 7064c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl FunctionDecl *OperatorNew; 7074c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // Points to the deallocation function used in case of error. May be null. 7084c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl FunctionDecl *OperatorDelete; 7094c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // Points to the constructor used. Cannot be null if AllocType is a record; 7104c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // it would still point at the default constructor (even an implicit one). 7114c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // Must be null for all other types. 7124c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl CXXConstructorDecl *Constructor; 7134c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 7144c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl SourceLocation StartLoc; 7154c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl SourceLocation EndLoc; 7164c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 7174c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redlpublic: 7184c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl CXXNewExpr(bool globalNew, FunctionDecl *operatorNew, Expr **placementArgs, 719cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl unsigned numPlaceArgs, bool ParenTypeId, Expr *arraySize, 7204c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl CXXConstructorDecl *constructor, bool initializer, 7214c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl Expr **constructorArgs, unsigned numConsArgs, 7224c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl FunctionDecl *operatorDelete, QualType ty, 7234c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl SourceLocation startLoc, SourceLocation endLoc); 7244c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl ~CXXNewExpr() { 7254c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl delete[] SubExprs; 7264c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 7274c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 728cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl QualType getAllocatedType() const { 729cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl assert(getType()->isPointerType()); 7306217b80b7a1379b74cced1c076338262c3c980b3Ted Kremenek return getType()->getAs<PointerType>()->getPointeeType(); 731cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl } 7324c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 7334c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl FunctionDecl *getOperatorNew() const { return OperatorNew; } 7344c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl FunctionDecl *getOperatorDelete() const { return OperatorDelete; } 7354c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl CXXConstructorDecl *getConstructor() const { return Constructor; } 7364c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 737cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl bool isArray() const { return Array; } 738cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl Expr *getArraySize() { 739cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl return Array ? cast<Expr>(SubExprs[0]) : 0; 740cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl } 741cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl const Expr *getArraySize() const { 742cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl return Array ? cast<Expr>(SubExprs[0]) : 0; 743cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl } 744cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl 7454c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl unsigned getNumPlacementArgs() const { return NumPlacementArgs; } 7464c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl Expr *getPlacementArg(unsigned i) { 7474c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl assert(i < NumPlacementArgs && "Index out of range"); 748cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl return cast<Expr>(SubExprs[Array + i]); 7494c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 7504c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl const Expr *getPlacementArg(unsigned i) const { 7514c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl assert(i < NumPlacementArgs && "Index out of range"); 752cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl return cast<Expr>(SubExprs[Array + i]); 7534c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 7544c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 7554c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl bool isGlobalNew() const { return GlobalNew; } 7564c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl bool isParenTypeId() const { return ParenTypeId; } 7574c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl bool hasInitializer() const { return Initializer; } 7584c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 7594c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl unsigned getNumConstructorArgs() const { return NumConstructorArgs; } 7604c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl Expr *getConstructorArg(unsigned i) { 7614c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl assert(i < NumConstructorArgs && "Index out of range"); 762cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl return cast<Expr>(SubExprs[Array + NumPlacementArgs + i]); 7634c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 7644c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl const Expr *getConstructorArg(unsigned i) const { 7654c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl assert(i < NumConstructorArgs && "Index out of range"); 766cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl return cast<Expr>(SubExprs[Array + NumPlacementArgs + i]); 7674c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 7684c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 7694c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl typedef ExprIterator arg_iterator; 7704c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl typedef ConstExprIterator const_arg_iterator; 7714c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 7724c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl arg_iterator placement_arg_begin() { 773cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl return SubExprs + Array; 7744c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 7754c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl arg_iterator placement_arg_end() { 776cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl return SubExprs + Array + getNumPlacementArgs(); 7774c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 7784c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl const_arg_iterator placement_arg_begin() const { 779cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl return SubExprs + Array; 7804c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 7814c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl const_arg_iterator placement_arg_end() const { 782cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl return SubExprs + Array + getNumPlacementArgs(); 7834c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 7844c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 7854c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl arg_iterator constructor_arg_begin() { 786cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl return SubExprs + Array + getNumPlacementArgs(); 7874c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 7884c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl arg_iterator constructor_arg_end() { 789cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl return SubExprs + Array + getNumPlacementArgs() + getNumConstructorArgs(); 7904c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 7914c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl const_arg_iterator constructor_arg_begin() const { 792cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl return SubExprs + Array + getNumPlacementArgs(); 7934c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 7944c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl const_arg_iterator constructor_arg_end() const { 795cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl return SubExprs + Array + getNumPlacementArgs() + getNumConstructorArgs(); 7964c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 7974c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 7984c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl virtual SourceRange getSourceRange() const { 7994c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl return SourceRange(StartLoc, EndLoc); 8004c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 8014c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 8024c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl static bool classof(const Stmt *T) { 8034c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl return T->getStmtClass() == CXXNewExprClass; 8044c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 8054c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl static bool classof(const CXXNewExpr *) { return true; } 8064c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 8074c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // Iterators 8084c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl virtual child_iterator child_begin(); 8094c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl virtual child_iterator child_end(); 8104c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl}; 8114c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 8124c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl/// CXXDeleteExpr - A delete expression for memory deallocation and destructor 8134c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl/// calls, e.g. "delete[] pArray". 8144c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redlclass CXXDeleteExpr : public Expr { 8154c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // Is this a forced global delete, i.e. "::delete"? 8164c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl bool GlobalDelete : 1; 8174c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // Is this the array form of delete, i.e. "delete[]"? 8184c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl bool ArrayForm : 1; 8194c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // Points to the operator delete overload that is used. Could be a member. 8204c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl FunctionDecl *OperatorDelete; 8214c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // The pointer expression to be deleted. 8224c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl Stmt *Argument; 8234c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // Location of the expression. 8244c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl SourceLocation Loc; 8254c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redlpublic: 8264c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl CXXDeleteExpr(QualType ty, bool globalDelete, bool arrayForm, 8274c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl FunctionDecl *operatorDelete, Expr *arg, SourceLocation loc) 8282850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl : Expr(CXXDeleteExprClass, ty, false, false), GlobalDelete(globalDelete), 8294c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl ArrayForm(arrayForm), OperatorDelete(operatorDelete), Argument(arg), 8304c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl Loc(loc) { } 8314c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 8324c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl bool isGlobalDelete() const { return GlobalDelete; } 8334c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl bool isArrayForm() const { return ArrayForm; } 8344c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 8354c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl FunctionDecl *getOperatorDelete() const { return OperatorDelete; } 8364c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 8374c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl Expr *getArgument() { return cast<Expr>(Argument); } 8384c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl const Expr *getArgument() const { return cast<Expr>(Argument); } 8394c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 8404c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl virtual SourceRange getSourceRange() const { 8414c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl return SourceRange(Loc, Argument->getLocEnd()); 8424c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 8434c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 8444c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl static bool classof(const Stmt *T) { 8454c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl return T->getStmtClass() == CXXDeleteExprClass; 8464c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 8474c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl static bool classof(const CXXDeleteExpr *) { return true; } 8484c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 8494c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // Iterators 8504c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl virtual child_iterator child_begin(); 8514c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl virtual child_iterator child_end(); 8524c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl}; 8534c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 85417330019f05966762bc952840ef1926b9becb145Douglas Gregor/// \brief Represents the name of a function that has not been 85517330019f05966762bc952840ef1926b9becb145Douglas Gregor/// resolved to any declaration. 85617330019f05966762bc952840ef1926b9becb145Douglas Gregor/// 85717330019f05966762bc952840ef1926b9becb145Douglas Gregor/// Unresolved function names occur when a function name is 85817330019f05966762bc952840ef1926b9becb145Douglas Gregor/// encountered prior to an open parentheses ('(') in a C++ function 85917330019f05966762bc952840ef1926b9becb145Douglas Gregor/// call, and the function name itself did not resolve to a 86017330019f05966762bc952840ef1926b9becb145Douglas Gregor/// declaration. These function names can only be resolved when they 86117330019f05966762bc952840ef1926b9becb145Douglas Gregor/// form the postfix-expression of a function call, so that 86217330019f05966762bc952840ef1926b9becb145Douglas Gregor/// argument-dependent lookup finds declarations corresponding to 86317330019f05966762bc952840ef1926b9becb145Douglas Gregor/// these functions. 86417330019f05966762bc952840ef1926b9becb145Douglas Gregor 8655c37de788529cd9180f22069970737a7208bd625Douglas Gregor/// @code 8665c37de788529cd9180f22069970737a7208bd625Douglas Gregor/// template<typename T> void f(T x) { 86717330019f05966762bc952840ef1926b9becb145Douglas Gregor/// g(x); // g is an unresolved function name (that is also a dependent name) 8685c37de788529cd9180f22069970737a7208bd625Douglas Gregor/// } 8695c37de788529cd9180f22069970737a7208bd625Douglas Gregor/// @endcode 87017330019f05966762bc952840ef1926b9becb145Douglas Gregorclass UnresolvedFunctionNameExpr : public Expr { 87117330019f05966762bc952840ef1926b9becb145Douglas Gregor /// The name that was present in the source 87217330019f05966762bc952840ef1926b9becb145Douglas Gregor DeclarationName Name; 8735c37de788529cd9180f22069970737a7208bd625Douglas Gregor 87417330019f05966762bc952840ef1926b9becb145Douglas Gregor /// The location of this name in the source code 8755c37de788529cd9180f22069970737a7208bd625Douglas Gregor SourceLocation Loc; 8765c37de788529cd9180f22069970737a7208bd625Douglas Gregor 8775c37de788529cd9180f22069970737a7208bd625Douglas Gregorpublic: 87817330019f05966762bc952840ef1926b9becb145Douglas Gregor UnresolvedFunctionNameExpr(DeclarationName N, QualType T, SourceLocation L) 87917330019f05966762bc952840ef1926b9becb145Douglas Gregor : Expr(UnresolvedFunctionNameExprClass, T, false, false), Name(N), Loc(L) { } 8805c37de788529cd9180f22069970737a7208bd625Douglas Gregor 88117330019f05966762bc952840ef1926b9becb145Douglas Gregor /// \brief Retrieves the name that occurred in the source code. 88217330019f05966762bc952840ef1926b9becb145Douglas Gregor DeclarationName getName() const { return Name; } 8835c37de788529cd9180f22069970737a7208bd625Douglas Gregor 8845c37de788529cd9180f22069970737a7208bd625Douglas Gregor /// getLocation - Retrieves the location in the source code where 8855c37de788529cd9180f22069970737a7208bd625Douglas Gregor /// the name occurred. 8865c37de788529cd9180f22069970737a7208bd625Douglas Gregor SourceLocation getLocation() const { return Loc; } 8875c37de788529cd9180f22069970737a7208bd625Douglas Gregor 8885c37de788529cd9180f22069970737a7208bd625Douglas Gregor virtual SourceRange getSourceRange() const { return SourceRange(Loc); } 8895c37de788529cd9180f22069970737a7208bd625Douglas Gregor 8905c37de788529cd9180f22069970737a7208bd625Douglas Gregor static bool classof(const Stmt *T) { 89117330019f05966762bc952840ef1926b9becb145Douglas Gregor return T->getStmtClass() == UnresolvedFunctionNameExprClass; 8925c37de788529cd9180f22069970737a7208bd625Douglas Gregor } 89317330019f05966762bc952840ef1926b9becb145Douglas Gregor static bool classof(const UnresolvedFunctionNameExpr *) { return true; } 8945c37de788529cd9180f22069970737a7208bd625Douglas Gregor 8955c37de788529cd9180f22069970737a7208bd625Douglas Gregor // Iterators 8965c37de788529cd9180f22069970737a7208bd625Douglas Gregor virtual child_iterator child_begin(); 8975c37de788529cd9180f22069970737a7208bd625Douglas Gregor virtual child_iterator child_end(); 8985c37de788529cd9180f22069970737a7208bd625Douglas Gregor}; 8995c37de788529cd9180f22069970737a7208bd625Douglas Gregor 90064b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl/// UnaryTypeTraitExpr - A GCC or MS unary type trait, as used in the 90164b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl/// implementation of TR1/C++0x type trait templates. 90264b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl/// Example: 90364b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl/// __is_pod(int) == true 90464b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl/// __is_enum(std::string) == false 90564b45f7e0d3167f040841ac2920aead7f080730dSebastian Redlclass UnaryTypeTraitExpr : public Expr { 90664b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl /// UTT - The trait. 90764b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl UnaryTypeTrait UTT; 90864b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl 90964b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl /// Loc - The location of the type trait keyword. 91064b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl SourceLocation Loc; 91164b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl 91264b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl /// RParen - The location of the closing paren. 91364b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl SourceLocation RParen; 91464b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl 91564b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl /// QueriedType - The type we're testing. 91664b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl QualType QueriedType; 91764b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl 91864b45f7e0d3167f040841ac2920aead7f080730dSebastian Redlpublic: 91964b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl UnaryTypeTraitExpr(SourceLocation loc, UnaryTypeTrait utt, QualType queried, 92064b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl SourceLocation rparen, QualType ty) 92164b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl : Expr(UnaryTypeTraitExprClass, ty, false, queried->isDependentType()), 92264b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl UTT(utt), Loc(loc), RParen(rparen), QueriedType(queried) { } 92364b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl 92464b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl virtual SourceRange getSourceRange() const { return SourceRange(Loc, RParen);} 92564b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl 92664b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl UnaryTypeTrait getTrait() const { return UTT; } 92764b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl 92864b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl QualType getQueriedType() const { return QueriedType; } 92964b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl 9305e03f9ea8174ae588c5e69ec6b5ef4c68f8fd766Douglas Gregor bool EvaluateTrait(ASTContext&) const; 93164b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl 93264b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl static bool classof(const Stmt *T) { 93364b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl return T->getStmtClass() == UnaryTypeTraitExprClass; 93464b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl } 93564b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl static bool classof(const UnaryTypeTraitExpr *) { return true; } 93664b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl 93764b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl // Iterators 93864b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl virtual child_iterator child_begin(); 93964b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl virtual child_iterator child_end(); 94064b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl}; 94164b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl 9421a49af9681c350fef58e677f85ccb9a77e8e9d0aDouglas Gregor/// QualifiedDeclRefExpr - A reference to a declared variable, 9431a49af9681c350fef58e677f85ccb9a77e8e9d0aDouglas Gregor/// function, enum, etc., that includes a qualification, e.g., 9441a49af9681c350fef58e677f85ccb9a77e8e9d0aDouglas Gregor/// "N::foo". 9451a49af9681c350fef58e677f85ccb9a77e8e9d0aDouglas Gregorclass QualifiedDeclRefExpr : public DeclRefExpr { 946bad351822117eaf280081494e3dbe4a06c0dbfcfDouglas Gregor /// QualifierRange - The source range that covers the 947bad351822117eaf280081494e3dbe4a06c0dbfcfDouglas Gregor /// nested-name-specifier. 948bad351822117eaf280081494e3dbe4a06c0dbfcfDouglas Gregor SourceRange QualifierRange; 949bad351822117eaf280081494e3dbe4a06c0dbfcfDouglas Gregor 950ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor /// \brief The nested-name-specifier that qualifies this declaration 951ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor /// name. 952ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor NestedNameSpecifier *NNS; 953bad351822117eaf280081494e3dbe4a06c0dbfcfDouglas Gregor 954bad351822117eaf280081494e3dbe4a06c0dbfcfDouglas Gregorpublic: 955ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor QualifiedDeclRefExpr(NamedDecl *d, QualType t, SourceLocation l, bool TD, 956ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor bool VD, SourceRange R, NestedNameSpecifier *NNS) 957ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor : DeclRefExpr(QualifiedDeclRefExprClass, d, t, l, TD, VD), 958ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor QualifierRange(R), NNS(NNS) { } 959bad351822117eaf280081494e3dbe4a06c0dbfcfDouglas Gregor 960bad351822117eaf280081494e3dbe4a06c0dbfcfDouglas Gregor /// \brief Retrieve the source range of the nested-name-specifier. 961bad351822117eaf280081494e3dbe4a06c0dbfcfDouglas Gregor SourceRange getQualifierRange() const { return QualifierRange; } 962bad351822117eaf280081494e3dbe4a06c0dbfcfDouglas Gregor 963ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor /// \brief Retrieve the nested-name-specifier that qualifies this 964ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor /// declaration. 965ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor NestedNameSpecifier *getQualifier() const { return NNS; } 9661a49af9681c350fef58e677f85ccb9a77e8e9d0aDouglas Gregor 9671a49af9681c350fef58e677f85ccb9a77e8e9d0aDouglas Gregor virtual SourceRange getSourceRange() const { 968bad351822117eaf280081494e3dbe4a06c0dbfcfDouglas Gregor return SourceRange(QualifierRange.getBegin(), getLocation()); 9691a49af9681c350fef58e677f85ccb9a77e8e9d0aDouglas Gregor } 9701a49af9681c350fef58e677f85ccb9a77e8e9d0aDouglas Gregor 9711a49af9681c350fef58e677f85ccb9a77e8e9d0aDouglas Gregor static bool classof(const Stmt *T) { 9721a49af9681c350fef58e677f85ccb9a77e8e9d0aDouglas Gregor return T->getStmtClass() == QualifiedDeclRefExprClass; 9731a49af9681c350fef58e677f85ccb9a77e8e9d0aDouglas Gregor } 9741a49af9681c350fef58e677f85ccb9a77e8e9d0aDouglas Gregor static bool classof(const QualifiedDeclRefExpr *) { return true; } 9751a49af9681c350fef58e677f85ccb9a77e8e9d0aDouglas Gregor}; 9761a49af9681c350fef58e677f85ccb9a77e8e9d0aDouglas Gregor 9775953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor/// \brief A qualified reference to a name whose declaration cannot 9785953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor/// yet be resolved. 9795953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor/// 9805953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor/// UnresolvedDeclRefExpr is similar to QualifiedDeclRefExpr in that 9815953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor/// it expresses a qualified reference to a declaration such as 9825953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor/// X<T>::value. The difference, however, is that an 9835953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor/// UnresolvedDeclRefExpr node is used only within C++ templates when 9845953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor/// the qualification (e.g., X<T>::) refers to a dependent type. In 9855953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor/// this case, X<T>::value cannot resolve to a declaration because the 9865953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor/// declaration will differ from on instantiation of X<T> to the 987ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor/// next. Therefore, UnresolvedDeclRefExpr keeps track of the 988ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor/// qualifier (X<T>::) and the name of the entity being referenced 989ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor/// ("value"). Such expressions will instantiate to 990ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor/// QualifiedDeclRefExprs. 9915953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregorclass UnresolvedDeclRefExpr : public Expr { 9925953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor /// The name of the entity we will be referencing. 9935953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor DeclarationName Name; 9945953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor 9955953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor /// Location of the name of the declaration we're referencing. 9965953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor SourceLocation Loc; 9975953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor 9985953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor /// QualifierRange - The source range that covers the 9995953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor /// nested-name-specifier. 10005953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor SourceRange QualifierRange; 10015953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor 1002ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor /// \brief The nested-name-specifier that qualifies this unresolved 1003ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor /// declaration name. 1004ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor NestedNameSpecifier *NNS; 10055953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor 10069b31df4acdeeb61bb084a03fc37bc5bd570a659eAnders Carlsson /// \brief Whether this expr is an address of (&) operand. 10079b31df4acdeeb61bb084a03fc37bc5bd570a659eAnders Carlsson bool IsAddressOfOperand; 10089b31df4acdeeb61bb084a03fc37bc5bd570a659eAnders Carlsson 10095953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregorpublic: 1010ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor UnresolvedDeclRefExpr(DeclarationName N, QualType T, SourceLocation L, 10119b31df4acdeeb61bb084a03fc37bc5bd570a659eAnders Carlsson SourceRange R, NestedNameSpecifier *NNS, 10129b31df4acdeeb61bb084a03fc37bc5bd570a659eAnders Carlsson bool IsAddressOfOperand) 1013ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor : Expr(UnresolvedDeclRefExprClass, T, true, true), 10149b31df4acdeeb61bb084a03fc37bc5bd570a659eAnders Carlsson Name(N), Loc(L), QualifierRange(R), NNS(NNS), 10159b31df4acdeeb61bb084a03fc37bc5bd570a659eAnders Carlsson IsAddressOfOperand(IsAddressOfOperand) { } 10165953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor 10175953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor /// \brief Retrieve the name that this expression refers to. 10185953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor DeclarationName getDeclName() const { return Name; } 10195953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor 10205953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor /// \brief Retrieve the location of the name within the expression. 10215953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor SourceLocation getLocation() const { return Loc; } 10225953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor 10235953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor /// \brief Retrieve the source range of the nested-name-specifier. 10245953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor SourceRange getQualifierRange() const { return QualifierRange; } 10255953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor 1026ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor /// \brief Retrieve the nested-name-specifier that qualifies this 1027ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor /// declaration. 1028ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor NestedNameSpecifier *getQualifier() const { return NNS; } 10295953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor 10309b31df4acdeeb61bb084a03fc37bc5bd570a659eAnders Carlsson /// \brief Retrieve whether this is an address of (&) operand. 10319b31df4acdeeb61bb084a03fc37bc5bd570a659eAnders Carlsson 10329b31df4acdeeb61bb084a03fc37bc5bd570a659eAnders Carlsson bool isAddressOfOperand() const { return IsAddressOfOperand; } 10335953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor virtual SourceRange getSourceRange() const { 10345953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor return SourceRange(QualifierRange.getBegin(), getLocation()); 10355953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor } 10365953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor 10375953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor static bool classof(const Stmt *T) { 10385953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor return T->getStmtClass() == UnresolvedDeclRefExprClass; 10395953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor } 10405953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor static bool classof(const UnresolvedDeclRefExpr *) { return true; } 10415953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor 10425953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor virtual StmtIterator child_begin(); 10435953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor virtual StmtIterator child_end(); 10445953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor}; 10455953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor 1046edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor/// \brief An expression that refers to a C++ template-id, such as 1047edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor/// @c isa<FunctionDecl>. 1048edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregorclass TemplateIdRefExpr : public Expr { 1049edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor /// \brief If this template-id was qualified-id, e.g., @c std::sort<int>, 1050edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor /// this nested name specifier contains the @c std::. 1051edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor NestedNameSpecifier *Qualifier; 1052edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor 1053edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor /// \brief If this template-id was a qualified-id, e.g., @c std::sort<int>, 1054edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor /// this covers the source code range of the @c std::. 1055edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor SourceRange QualifierRange; 1056edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor 1057edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor /// \brief The actual template to which this template-id refers. 1058edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor TemplateName Template; 1059edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor 1060edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor /// \brief The source location of the template name. 1061edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor SourceLocation TemplateNameLoc; 1062edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor 1063edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor /// \brief The source location of the left angle bracket ('<'); 1064edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor SourceLocation LAngleLoc; 1065edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor 1066edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor /// \brief The source location of the right angle bracket ('>'); 1067edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor SourceLocation RAngleLoc; 1068edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor 1069edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor /// \brief The number of template arguments in TemplateArgs. 1070edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor unsigned NumTemplateArgs; 1071edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor 1072edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor TemplateIdRefExpr(QualType T, 1073edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor NestedNameSpecifier *Qualifier, SourceRange QualifierRange, 1074edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor TemplateName Template, SourceLocation TemplateNameLoc, 1075edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor SourceLocation LAngleLoc, 1076edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor const TemplateArgument *TemplateArgs, 1077edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor unsigned NumTemplateArgs, 1078edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor SourceLocation RAngleLoc); 1079edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor 108042602bb40aefcc2751d4078ba88aacf4d965c9bdDouglas Gregor virtual void DoDestroy(ASTContext &Context); 108142602bb40aefcc2751d4078ba88aacf4d965c9bdDouglas Gregor 1082edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregorpublic: 1083edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor static TemplateIdRefExpr * 1084edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor Create(ASTContext &Context, QualType T, 1085edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor NestedNameSpecifier *Qualifier, SourceRange QualifierRange, 1086edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor TemplateName Template, SourceLocation TemplateNameLoc, 1087edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor SourceLocation LAngleLoc, const TemplateArgument *TemplateArgs, 1088edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor unsigned NumTemplateArgs, SourceLocation RAngleLoc); 1089edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor 1090edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor /// \brief Retrieve the nested name specifier used to qualify the name of 1091edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor /// this template-id, e.g., the "std::sort" in @c std::sort<int>, or NULL 1092edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor /// if this template-id was an unqualified-id. 1093edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor NestedNameSpecifier *getQualifier() const { return Qualifier; } 1094edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor 1095edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor /// \brief Retrieve the source range describing the nested name specifier 1096edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor /// used to qualified the name of this template-id, if the name was qualified. 1097edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor SourceRange getQualifierRange() const { return QualifierRange; } 1098edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor 1099edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor /// \brief Retrieve the name of the template referenced, e.g., "sort" in 1100edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor /// @c std::sort<int>; 1101edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor TemplateName getTemplateName() const { return Template; } 1102edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor 1103edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor /// \brief Retrieve the location of the name of the template referenced, e.g., 1104edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor /// the location of "sort" in @c std::sort<int>. 1105edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor SourceLocation getTemplateNameLoc() const { return TemplateNameLoc; } 1106edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor 1107edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor /// \brief Retrieve the location of the left angle bracket following the 1108edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor /// template name ('<'). 1109edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor SourceLocation getLAngleLoc() const { return LAngleLoc; } 1110edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor 1111edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor /// \brief Retrieve the template arguments provided as part of this 1112edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor /// template-id. 1113edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor const TemplateArgument *getTemplateArgs() const { 1114edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor return reinterpret_cast<const TemplateArgument *>(this + 1); 1115edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor } 1116edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor 1117edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor /// \brief Retrieve the number of template arguments provided as part of this 1118edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor /// template-id. 1119edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor unsigned getNumTemplateArgs() const { return NumTemplateArgs; } 1120edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor 1121edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor /// \brief Retrieve the location of the right angle bracket following the 1122edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor /// template arguments ('>'). 1123edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor SourceLocation getRAngleLoc() const { return RAngleLoc; } 1124edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor 1125edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor virtual SourceRange getSourceRange() const { 1126edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor return SourceRange(Qualifier? QualifierRange.getBegin() : TemplateNameLoc, 1127edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor RAngleLoc); 1128edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor } 1129edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor 1130edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor // Iterators 1131edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor virtual child_iterator child_begin(); 1132edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor virtual child_iterator child_end(); 1133edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor 1134edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor static bool classof(const Stmt *T) { 1135edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor return T->getStmtClass() == TemplateIdRefExprClass; 1136edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor } 1137edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor static bool classof(const TemplateIdRefExpr *) { return true; } 1138edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor}; 1139edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor 11402d44e8a41de8a33c0f04ac198714f71dc841bab0Anders Carlssonclass CXXExprWithTemporaries : public Expr { 114102bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson Stmt *SubExpr; 114202bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson 1143ff6b3d64c9f07155f1414411b8451d7bf8937c62Anders Carlsson CXXTemporary **Temps; 1144ff6b3d64c9f07155f1414411b8451d7bf8937c62Anders Carlsson unsigned NumTemps; 114502bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson 1146f54741e6465692d3bdbae974ac3beeeab92e4a95Anders Carlsson bool ShouldDestroyTemps; 114799ba36de0d5b34624e74e77bffa73929617976cbAnders Carlsson 114899ba36de0d5b34624e74e77bffa73929617976cbAnders Carlsson CXXExprWithTemporaries(Expr *SubExpr, CXXTemporary **Temps, 1149f54741e6465692d3bdbae974ac3beeeab92e4a95Anders Carlsson unsigned NumTemps, bool ShouldDestroyTemps); 11502d44e8a41de8a33c0f04ac198714f71dc841bab0Anders Carlsson ~CXXExprWithTemporaries(); 115142602bb40aefcc2751d4078ba88aacf4d965c9bdDouglas Gregor 115242602bb40aefcc2751d4078ba88aacf4d965c9bdDouglas Gregorprotected: 115342602bb40aefcc2751d4078ba88aacf4d965c9bdDouglas Gregor virtual void DoDestroy(ASTContext &C); 115442602bb40aefcc2751d4078ba88aacf4d965c9bdDouglas Gregor 115588eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlssonpublic: 115688eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlsson static CXXExprWithTemporaries *Create(ASTContext &C, Expr *SubExpr, 1157f54741e6465692d3bdbae974ac3beeeab92e4a95Anders Carlsson CXXTemporary **Temps, unsigned NumTemps, 1158f54741e6465692d3bdbae974ac3beeeab92e4a95Anders Carlsson bool ShouldDestroyTemporaries); 115988eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlsson 116088eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlsson unsigned getNumTemporaries() const { return NumTemps; } 116188eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlsson CXXTemporary *getTemporary(unsigned i) { 116288eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlsson assert(i < NumTemps && "Index out of range"); 116388eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlsson return Temps[i]; 116488eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlsson } 1165f0721fe438d7e40c168e5d664970e7830bc138fbAnders Carlsson const CXXTemporary *getTemporary(unsigned i) const { 1166f0721fe438d7e40c168e5d664970e7830bc138fbAnders Carlsson assert(i < NumTemps && "Index out of range"); 1167f0721fe438d7e40c168e5d664970e7830bc138fbAnders Carlsson return Temps[i]; 1168f0721fe438d7e40c168e5d664970e7830bc138fbAnders Carlsson } 1169f0721fe438d7e40c168e5d664970e7830bc138fbAnders Carlsson 1170f54741e6465692d3bdbae974ac3beeeab92e4a95Anders Carlsson bool shouldDestroyTemporaries() const { return ShouldDestroyTemps; } 1171f54741e6465692d3bdbae974ac3beeeab92e4a95Anders Carlsson 117288eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlsson void removeLastTemporary() { NumTemps--; } 117388eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlsson 117402bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson Expr *getSubExpr() { return cast<Expr>(SubExpr); } 1175f0721fe438d7e40c168e5d664970e7830bc138fbAnders Carlsson const Expr *getSubExpr() const { return cast<Expr>(SubExpr); } 117688eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlsson void setSubExpr(Expr *E) { SubExpr = E; } 117702bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson 117802bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson virtual SourceRange getSourceRange() const { return SourceRange(); } 117902bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson 118002bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson // Implement isa/cast/dyncast/etc. 118102bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson static bool classof(const Stmt *T) { 11822d44e8a41de8a33c0f04ac198714f71dc841bab0Anders Carlsson return T->getStmtClass() == CXXExprWithTemporariesClass; 118302bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson } 11842d44e8a41de8a33c0f04ac198714f71dc841bab0Anders Carlsson static bool classof(const CXXExprWithTemporaries *) { return true; } 118502bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson 118602bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson // Iterators 118702bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson virtual child_iterator child_begin(); 118802bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson virtual child_iterator child_end(); 118902bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson}; 119002bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson 1191d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// \brief Describes an explicit type conversion that uses functional 1192d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// notion but could not be resolved because one or more arguments are 1193d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// type-dependent. 1194d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// 1195d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// The explicit type conversions expressed by 1196d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// CXXUnresolvedConstructExpr have the form \c T(a1, a2, ..., aN), 1197d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// where \c T is some type and \c a1, a2, ..., aN are values, and 1198d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// either \C T is a dependent type or one or more of the \c a's is 1199d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// type-dependent. For example, this would occur in a template such 1200d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// as: 1201d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// 1202d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// \code 1203d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// template<typename T, typename A1> 1204d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// inline T make_a(const A1& a1) { 1205d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// return T(a1); 1206d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// } 1207d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// \endcode 1208d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// 1209d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// When the returned expression is instantiated, it may resolve to a 1210d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// constructor call, conversion function call, or some kind of type 1211d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// conversion. 1212d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregorclass CXXUnresolvedConstructExpr : public Expr { 1213d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor /// \brief The starting location of the type 1214d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor SourceLocation TyBeginLoc; 1215d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor 1216d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor /// \brief The type being constructed. 1217d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor QualType Type; 1218d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor 1219d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor /// \brief The location of the left parentheses ('('). 1220d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor SourceLocation LParenLoc; 1221d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor 1222d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor /// \brief The location of the right parentheses (')'). 1223d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor SourceLocation RParenLoc; 1224d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor 1225d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor /// \brief The number of arguments used to construct the type. 1226d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor unsigned NumArgs; 1227d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor 1228d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor CXXUnresolvedConstructExpr(SourceLocation TyBegin, 1229d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor QualType T, 1230d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor SourceLocation LParenLoc, 1231d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor Expr **Args, 1232d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor unsigned NumArgs, 1233d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor SourceLocation RParenLoc); 1234d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor 1235d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregorpublic: 1236d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor static CXXUnresolvedConstructExpr *Create(ASTContext &C, 1237d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor SourceLocation TyBegin, 1238d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor QualType T, 1239d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor SourceLocation LParenLoc, 1240d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor Expr **Args, 1241d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor unsigned NumArgs, 1242d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor SourceLocation RParenLoc); 1243d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor 1244d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor /// \brief Retrieve the source location where the type begins. 1245d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor SourceLocation getTypeBeginLoc() const { return TyBeginLoc; } 1246d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor void setTypeBeginLoc(SourceLocation L) { TyBeginLoc = L; } 1247d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor 1248d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor /// \brief Retrieve the type that is being constructed, as specified 1249d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor /// in the source code. 1250d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor QualType getTypeAsWritten() const { return Type; } 1251d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor void setTypeAsWritten(QualType T) { Type = T; } 1252d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor 1253d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor /// \brief Retrieve the location of the left parentheses ('(') that 1254d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor /// precedes the argument list. 1255d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor SourceLocation getLParenLoc() const { return LParenLoc; } 1256d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor void setLParenLoc(SourceLocation L) { LParenLoc = L; } 1257d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor 1258d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor /// \brief Retrieve the location of the right parentheses (')') that 1259d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor /// follows the argument list. 1260d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor SourceLocation getRParenLoc() const { return RParenLoc; } 1261d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor void setRParenLoc(SourceLocation L) { RParenLoc = L; } 1262d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor 1263d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor /// \brief Retrieve the number of arguments. 1264d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor unsigned arg_size() const { return NumArgs; } 1265d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor 1266d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor typedef Expr** arg_iterator; 1267d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor arg_iterator arg_begin() { return reinterpret_cast<Expr**>(this + 1); } 1268d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor arg_iterator arg_end() { return arg_begin() + NumArgs; } 1269d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor 1270d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor Expr *getArg(unsigned I) { 1271d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor assert(I < NumArgs && "Argument index out-of-range"); 1272d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor return *(arg_begin() + I); 1273d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor } 1274d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor 1275d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor virtual SourceRange getSourceRange() const { 1276d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor return SourceRange(TyBeginLoc, RParenLoc); 1277d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor } 1278d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor static bool classof(const Stmt *T) { 1279d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor return T->getStmtClass() == CXXUnresolvedConstructExprClass; 1280d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor } 1281d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor static bool classof(const CXXUnresolvedConstructExpr *) { return true; } 1282d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor 1283d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor // Iterators 1284d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor virtual child_iterator child_begin(); 1285d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor virtual child_iterator child_end(); 1286d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor}; 1287d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor 1288bd4c4aebe6035e7a7125470cc9f0f92511230ee3Douglas Gregor/// \brief Represents a C++ member access expression where the actual member 1289bd4c4aebe6035e7a7125470cc9f0f92511230ee3Douglas Gregor/// referenced could not be resolved, e.g., because the base expression or the 1290bd4c4aebe6035e7a7125470cc9f0f92511230ee3Douglas Gregor/// member name was dependent. 12911c0ca59416999129d0439c2661d137ef38e86209Douglas Gregorclass CXXUnresolvedMemberExpr : public Expr { 12921c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor /// \brief The expression for the base pointer or class reference, 12931c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor /// e.g., the \c x in x.f. 12941c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor Stmt *Base; 12951c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor 12961c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor /// \brief Whether this member expression used the '->' operator or 12971c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor /// the '.' operator. 12981c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor bool IsArrow; 12991c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor 13001c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor /// \brief The location of the '->' or '.' operator. 13011c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor SourceLocation OperatorLoc; 13021c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor 1303a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor /// \brief The nested-name-specifier that precedes the member name, if any. 1304a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor NestedNameSpecifier *Qualifier; 1305a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor 1306a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor /// \brief The source range covering the nested name specifier. 1307a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor SourceRange QualifierRange; 1308a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor 13091c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor /// \brief The member to which this member expression refers, which 13101c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor /// can be name, overloaded operator, or destructor. 1311a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor /// FIXME: could also be a template-id 13121c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor DeclarationName Member; 13131c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor 13141c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor /// \brief The location of the member name. 13151c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor SourceLocation MemberLoc; 1316a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor 13171c0ca59416999129d0439c2661d137ef38e86209Douglas Gregorpublic: 13181c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor CXXUnresolvedMemberExpr(ASTContext &C, 13191c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor Expr *Base, bool IsArrow, 13201c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor SourceLocation OperatorLoc, 1321a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor NestedNameSpecifier *Qualifier, 1322a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor SourceRange QualifierRange, 13231c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor DeclarationName Member, 13241c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor SourceLocation MemberLoc) 13251c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor : Expr(CXXUnresolvedMemberExprClass, C.DependentTy, true, true), 13261c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor Base(Base), IsArrow(IsArrow), OperatorLoc(OperatorLoc), 1327a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor Qualifier(Qualifier), QualifierRange(QualifierRange), 13281c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor Member(Member), MemberLoc(MemberLoc) { } 13291c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor 13301c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor /// \brief Retrieve the base object of this member expressions, 13311c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor /// e.g., the \c x in \c x.m. 13321c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor Expr *getBase() { return cast<Expr>(Base); } 13331c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor void setBase(Expr *E) { Base = E; } 13341c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor 13351c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor /// \brief Determine whether this member expression used the '->' 13361c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor /// operator; otherwise, it used the '.' operator. 13371c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor bool isArrow() const { return IsArrow; } 13381c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor void setArrow(bool A) { IsArrow = A; } 13391c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor 13401c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor /// \brief Retrieve the location of the '->' or '.' operator. 13411c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor SourceLocation getOperatorLoc() const { return OperatorLoc; } 13421c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor void setOperatorLoc(SourceLocation L) { OperatorLoc = L; } 13431c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor 1344a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor /// \brief Retrieve the nested-name-specifier that qualifies the member 1345a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor /// name. 1346a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor NestedNameSpecifier *getQualifier() const { return Qualifier; } 1347a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor 1348a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor /// \brief Retrieve the source range covering the nested-name-specifier 1349a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor /// that qualifies the member name. 1350a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor SourceRange getQualifierRange() const { return QualifierRange; } 1351a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor 13521c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor /// \brief Retrieve the name of the member that this expression 13531c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor /// refers to. 13541c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor DeclarationName getMember() const { return Member; } 13551c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor void setMember(DeclarationName N) { Member = N; } 13561c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor 13571c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor // \brief Retrieve the location of the name of the member that this 13581c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor // expression refers to. 13591c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor SourceLocation getMemberLoc() const { return MemberLoc; } 13601c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor void setMemberLoc(SourceLocation L) { MemberLoc = L; } 13611c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor 13621c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor virtual SourceRange getSourceRange() const { 13631c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor return SourceRange(Base->getSourceRange().getBegin(), 13641c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor MemberLoc); 13651c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor } 13661c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor static bool classof(const Stmt *T) { 13671c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor return T->getStmtClass() == CXXUnresolvedMemberExprClass; 13681c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor } 13691c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor static bool classof(const CXXUnresolvedMemberExpr *) { return true; } 13701c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor 13711c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor // Iterators 13721c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor virtual child_iterator child_begin(); 13731c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor virtual child_iterator child_end(); 13741c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor}; 13751c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor 13765f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer} // end namespace clang 13775f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 13785f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer#endif 1379