ExprCXX.h revision 15ef2b5820f9daccc44b9e847163b705b6f5863b
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; 244c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 251060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek//===--------------------------------------------------------------------===// 261060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek// C++ Expressions. 271060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek//===--------------------------------------------------------------------===// 281060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek 293fd95ce225393fe4a3623e429766a8c3f487ff9dDouglas Gregor/// \brief A call to an overloaded operator written using operator 303fd95ce225393fe4a3623e429766a8c3f487ff9dDouglas Gregor/// syntax. 313fd95ce225393fe4a3623e429766a8c3f487ff9dDouglas Gregor/// 323fd95ce225393fe4a3623e429766a8c3f487ff9dDouglas Gregor/// Represents a call to an overloaded operator written using operator 333fd95ce225393fe4a3623e429766a8c3f487ff9dDouglas Gregor/// syntax, e.g., "x + y" or "*p". While semantically equivalent to a 343fd95ce225393fe4a3623e429766a8c3f487ff9dDouglas Gregor/// normal call, this AST node provides better information about the 353fd95ce225393fe4a3623e429766a8c3f487ff9dDouglas Gregor/// syntactic representation of the call. 363fd95ce225393fe4a3623e429766a8c3f487ff9dDouglas Gregor/// 373fd95ce225393fe4a3623e429766a8c3f487ff9dDouglas Gregor/// In a C++ template, this expression node kind will be used whenever 383fd95ce225393fe4a3623e429766a8c3f487ff9dDouglas Gregor/// any of the arguments are type-dependent. In this case, the 393fd95ce225393fe4a3623e429766a8c3f487ff9dDouglas Gregor/// function itself will be a (possibly empty) set of functions and 403fd95ce225393fe4a3623e429766a8c3f487ff9dDouglas Gregor/// function templates that were found by name lookup at template 413fd95ce225393fe4a3623e429766a8c3f487ff9dDouglas Gregor/// definition time. 42b4609806e9232593ece09ce08b630836e825865cDouglas Gregorclass CXXOperatorCallExpr : public CallExpr { 43063daf6e196c51f162e0485478355d8e280eef5cDouglas Gregor /// \brief The overloaded operator. 44063daf6e196c51f162e0485478355d8e280eef5cDouglas Gregor OverloadedOperatorKind Operator; 45063daf6e196c51f162e0485478355d8e280eef5cDouglas Gregor 46b4609806e9232593ece09ce08b630836e825865cDouglas Gregorpublic: 47063daf6e196c51f162e0485478355d8e280eef5cDouglas Gregor CXXOperatorCallExpr(ASTContext& C, OverloadedOperatorKind Op, Expr *fn, 48063daf6e196c51f162e0485478355d8e280eef5cDouglas Gregor Expr **args, unsigned numargs, QualType t, 49063daf6e196c51f162e0485478355d8e280eef5cDouglas Gregor SourceLocation operatorloc) 50063daf6e196c51f162e0485478355d8e280eef5cDouglas Gregor : CallExpr(C, CXXOperatorCallExprClass, fn, args, numargs, t, operatorloc), 51063daf6e196c51f162e0485478355d8e280eef5cDouglas Gregor Operator(Op) {} 52b4609806e9232593ece09ce08b630836e825865cDouglas Gregor 53b4609806e9232593ece09ce08b630836e825865cDouglas Gregor /// getOperator - Returns the kind of overloaded operator that this 54b4609806e9232593ece09ce08b630836e825865cDouglas Gregor /// expression refers to. 55063daf6e196c51f162e0485478355d8e280eef5cDouglas Gregor OverloadedOperatorKind getOperator() const { return Operator; } 56b4609806e9232593ece09ce08b630836e825865cDouglas Gregor 57b4609806e9232593ece09ce08b630836e825865cDouglas Gregor /// getOperatorLoc - Returns the location of the operator symbol in 58b4609806e9232593ece09ce08b630836e825865cDouglas Gregor /// the expression. When @c getOperator()==OO_Call, this is the 59b4609806e9232593ece09ce08b630836e825865cDouglas Gregor /// location of the right parentheses; when @c 60b4609806e9232593ece09ce08b630836e825865cDouglas Gregor /// getOperator()==OO_Subscript, this is the location of the right 61b4609806e9232593ece09ce08b630836e825865cDouglas Gregor /// bracket. 62b4609806e9232593ece09ce08b630836e825865cDouglas Gregor SourceLocation getOperatorLoc() const { return getRParenLoc(); } 63b4609806e9232593ece09ce08b630836e825865cDouglas Gregor 64b4609806e9232593ece09ce08b630836e825865cDouglas Gregor virtual SourceRange getSourceRange() const; 65b4609806e9232593ece09ce08b630836e825865cDouglas Gregor 66b4609806e9232593ece09ce08b630836e825865cDouglas Gregor static bool classof(const Stmt *T) { 67b4609806e9232593ece09ce08b630836e825865cDouglas Gregor return T->getStmtClass() == CXXOperatorCallExprClass; 68b4609806e9232593ece09ce08b630836e825865cDouglas Gregor } 69b4609806e9232593ece09ce08b630836e825865cDouglas Gregor static bool classof(const CXXOperatorCallExpr *) { return true; } 70b4609806e9232593ece09ce08b630836e825865cDouglas Gregor}; 71b4609806e9232593ece09ce08b630836e825865cDouglas Gregor 7288a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor/// CXXMemberCallExpr - Represents a call to a member function that 7388a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor/// may be written either with member call syntax (e.g., "obj.func()" 7488a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor/// or "objptr->func()") or with normal function-call syntax 7588a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor/// ("func()") within a member function that ends up calling a member 7688a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor/// function. The callee in either case is a MemberExpr that contains 7788a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor/// both the object argument and the member function, while the 7888a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor/// arguments are the arguments within the parentheses (not including 7988a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor/// the object argument). 8088a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregorclass CXXMemberCallExpr : public CallExpr { 8188a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregorpublic: 82668bf91d31265b6ea8c3eb854ba450857701f269Ted Kremenek CXXMemberCallExpr(ASTContext& C, Expr *fn, Expr **args, unsigned numargs, 83668bf91d31265b6ea8c3eb854ba450857701f269Ted Kremenek QualType t, SourceLocation rparenloc) 84668bf91d31265b6ea8c3eb854ba450857701f269Ted Kremenek : CallExpr(C, CXXMemberCallExprClass, fn, args, numargs, t, rparenloc) {} 8588a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor 8688a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor /// getImplicitObjectArgument - Retrieves the implicit object 8788a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor /// argument for the member call. For example, in "x.f(5)", this 8888a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor /// operation would return "x". 8988a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor Expr *getImplicitObjectArgument(); 9088a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor 9188a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor static bool classof(const Stmt *T) { 9288a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor return T->getStmtClass() == CXXMemberCallExprClass; 9388a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor } 9488a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor static bool classof(const CXXMemberCallExpr *) { return true; } 9588a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor}; 9688a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor 9749badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// CXXNamedCastExpr - Abstract class common to all of the C++ "named" 9849badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// casts, @c static_cast, @c dynamic_cast, @c reinterpret_cast, or @c 9949badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// const_cast. 10049badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// 10149badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// This abstract class is inherited by all of the classes 10249badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// representing "named" casts, e.g., CXXStaticCastExpr, 10349badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// CXXDynamicCastExpr, CXXReinterpretCastExpr, and CXXConstCastExpr. 10449badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregorclass CXXNamedCastExpr : public ExplicitCastExpr { 1051060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenekprivate: 1061060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek SourceLocation Loc; // the location of the casting op 10749badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor 10849badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregorprotected: 10949badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor CXXNamedCastExpr(StmtClass SC, QualType ty, Expr *op, QualType writtenTy, 11049badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor SourceLocation l) 11149badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor : ExplicitCastExpr(SC, ty, op, writtenTy), Loc(l) {} 11249badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor 1131060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenekpublic: 11449badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor const char *getCastName() const; 11549badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor 1161060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek virtual SourceRange getSourceRange() const { 1171060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek return SourceRange(Loc, getSubExpr()->getSourceRange().getEnd()); 1181060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek } 1191060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek static bool classof(const Stmt *T) { 12049badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor switch (T->getStmtClass()) { 12149badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor case CXXNamedCastExprClass: 12249badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor case CXXStaticCastExprClass: 12349badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor case CXXDynamicCastExprClass: 12449badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor case CXXReinterpretCastExprClass: 12549badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor case CXXConstCastExprClass: 12649badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor return true; 12749badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor default: 12849badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor return false; 12949badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor } 1301060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek } 13149badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor static bool classof(const CXXNamedCastExpr *) { return true; } 13249badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor}; 13349badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor 13449badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// CXXStaticCastExpr - A C++ @c static_cast expression (C++ [expr.static.cast]). 13549badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// 13649badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// This expression node represents a C++ static cast, e.g., 13749badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// @c static_cast<int>(1.0). 13849badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregorclass CXXStaticCastExpr : public CXXNamedCastExpr { 13949badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregorpublic: 14049badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor CXXStaticCastExpr(QualType ty, Expr *op, QualType writtenTy, SourceLocation l) 14149badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor : CXXNamedCastExpr(CXXStaticCastExprClass, ty, op, writtenTy, l) {} 14249badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor 14349badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor static bool classof(const Stmt *T) { 14449badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor return T->getStmtClass() == CXXStaticCastExprClass; 14549badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor } 14649badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor static bool classof(const CXXStaticCastExpr *) { return true; } 14749badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor}; 14849badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor 14949badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// CXXDynamicCastExpr - A C++ @c dynamic_cast expression 15049badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// (C++ [expr.dynamic.cast]), which may perform a run-time check to 15149badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// determine how to perform the type cast. 15249badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// 15349badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// This expression node represents a dynamic cast, e.g., 15449badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// @c dynamic_cast<Derived*>(BasePtr). 15549badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregorclass CXXDynamicCastExpr : public CXXNamedCastExpr { 15649badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregorpublic: 15749badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor CXXDynamicCastExpr(QualType ty, Expr *op, QualType writtenTy, SourceLocation l) 15849badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor : CXXNamedCastExpr(CXXDynamicCastExprClass, ty, op, writtenTy, l) {} 15949badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor 16049badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor static bool classof(const Stmt *T) { 16149badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor return T->getStmtClass() == CXXDynamicCastExprClass; 16249badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor } 16349badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor static bool classof(const CXXDynamicCastExpr *) { return true; } 16449badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor}; 16549badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor 16649badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// CXXReinterpretCastExpr - A C++ @c reinterpret_cast expression (C++ 16749badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// [expr.reinterpret.cast]), which provides a differently-typed view 16849badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// of a value but performs no actual work at run time. 16949badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// 17049badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// This expression node represents a reinterpret cast, e.g., 17149badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// @c reinterpret_cast<int>(VoidPtr). 17249badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregorclass CXXReinterpretCastExpr : public CXXNamedCastExpr { 17349badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregorpublic: 17449badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor CXXReinterpretCastExpr(QualType ty, Expr *op, QualType writtenTy, 17549badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor SourceLocation l) 17649badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor : CXXNamedCastExpr(CXXReinterpretCastExprClass, ty, op, writtenTy, l) {} 17749badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor 17849badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor static bool classof(const Stmt *T) { 17949badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor return T->getStmtClass() == CXXReinterpretCastExprClass; 18049badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor } 18149badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor static bool classof(const CXXReinterpretCastExpr *) { return true; } 18249badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor}; 18349badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor 18449badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// CXXConstCastExpr - A C++ @c const_cast expression (C++ [expr.const.cast]), 18549badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// which can remove type qualifiers but does not change the underlying value. 18649badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// 18749badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// This expression node represents a const cast, e.g., 18849badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// @c const_cast<char*>(PtrToConstChar). 18949badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregorclass CXXConstCastExpr : public CXXNamedCastExpr { 19049badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregorpublic: 19149badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor CXXConstCastExpr(QualType ty, Expr *op, QualType writtenTy, 19249badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor SourceLocation l) 19349badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor : CXXNamedCastExpr(CXXConstCastExprClass, ty, op, writtenTy, l) {} 19449badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor 19549badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor static bool classof(const Stmt *T) { 19649badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor return T->getStmtClass() == CXXConstCastExprClass; 19749badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor } 19849badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor static bool classof(const CXXConstCastExpr *) { return true; } 1991060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek}; 2001060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek 2011060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek/// CXXBoolLiteralExpr - [C++ 2.13.5] C++ Boolean Literal. 2021060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek/// 2031060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenekclass CXXBoolLiteralExpr : public Expr { 2041060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek bool Value; 2051060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek SourceLocation Loc; 2061060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenekpublic: 2071060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek CXXBoolLiteralExpr(bool val, QualType Ty, SourceLocation l) : 2081060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek Expr(CXXBoolLiteralExprClass, Ty), Value(val), Loc(l) {} 2091060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek 2101060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek bool getValue() const { return Value; } 2115f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 2121060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek virtual SourceRange getSourceRange() const { return SourceRange(Loc); } 2135f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 2141060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek static bool classof(const Stmt *T) { 2151060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek return T->getStmtClass() == CXXBoolLiteralExprClass; 2161060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek } 2171060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek static bool classof(const CXXBoolLiteralExpr *) { return true; } 2185f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 2191060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek // Iterators 2201060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek virtual child_iterator child_begin(); 2211060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek virtual child_iterator child_end(); 2221060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek}; 2231060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek 224c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl/// CXXTypeidExpr - A C++ @c typeid expression (C++ [expr.typeid]), which gets 225c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl/// the type_info that corresponds to the supplied type, or the (possibly 226c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl/// dynamic) type of the supplied expression. 227c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl/// 228c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl/// This represents code like @c typeid(int) or @c typeid(*objPtr) 229c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redlclass CXXTypeidExpr : public Expr { 230c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redlprivate: 231c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl bool isTypeOp : 1; 232d457589fc69dc7a9c80cd74d317c0b81a35a27c9Sebastian Redl union { 233d457589fc69dc7a9c80cd74d317c0b81a35a27c9Sebastian Redl void *Ty; 234d457589fc69dc7a9c80cd74d317c0b81a35a27c9Sebastian Redl Stmt *Ex; 235d457589fc69dc7a9c80cd74d317c0b81a35a27c9Sebastian Redl } Operand; 236c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl SourceRange Range; 237c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl 238c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redlpublic: 239c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl CXXTypeidExpr(bool isTypeOp, void *op, QualType Ty, const SourceRange r) : 2402850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl Expr(CXXTypeidExprClass, Ty, 2412850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl // typeid is never type-dependent (C++ [temp.dep.expr]p4) 2422850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl false, 2432850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl // typeid is value-dependent if the type or expression are dependent 2442850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl (isTypeOp ? QualType::getFromOpaquePtr(op)->isDependentType() 2452850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl : static_cast<Expr*>(op)->isValueDependent())), 2462850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl isTypeOp(isTypeOp), Range(r) { 247d457589fc69dc7a9c80cd74d317c0b81a35a27c9Sebastian Redl if (isTypeOp) 248d457589fc69dc7a9c80cd74d317c0b81a35a27c9Sebastian Redl Operand.Ty = op; 249d457589fc69dc7a9c80cd74d317c0b81a35a27c9Sebastian Redl else 250d457589fc69dc7a9c80cd74d317c0b81a35a27c9Sebastian Redl // op was an Expr*, so cast it back to that to be safe 2512850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl Operand.Ex = static_cast<Expr*>(op); 252d457589fc69dc7a9c80cd74d317c0b81a35a27c9Sebastian Redl } 253c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl 254c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl bool isTypeOperand() const { return isTypeOp; } 255c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl QualType getTypeOperand() const { 256c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl assert(isTypeOperand() && "Cannot call getTypeOperand for typeid(expr)"); 257d457589fc69dc7a9c80cd74d317c0b81a35a27c9Sebastian Redl return QualType::getFromOpaquePtr(Operand.Ty); 258c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl } 259c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl Expr* getExprOperand() const { 260c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl assert(!isTypeOperand() && "Cannot call getExprOperand for typeid(type)"); 261d457589fc69dc7a9c80cd74d317c0b81a35a27c9Sebastian Redl return static_cast<Expr*>(Operand.Ex); 262c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl } 263c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl 264c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl virtual SourceRange getSourceRange() const { 265c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl return Range; 266c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl } 267c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl static bool classof(const Stmt *T) { 268c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl return T->getStmtClass() == CXXTypeidExprClass; 269c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl } 270c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl static bool classof(const CXXTypeidExpr *) { return true; } 271c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl 272c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl // Iterators 273c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl virtual child_iterator child_begin(); 274c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl virtual child_iterator child_end(); 275c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl}; 276c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl 277796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// CXXThisExpr - Represents the "this" expression in C++, which is a 278796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// pointer to the object on which the current member function is 279796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// executing (C++ [expr.prim]p3). Example: 280796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// 281796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// @code 282796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// class Foo { 283796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// public: 284796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// void bar(); 285796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// void test() { this->bar(); } 286796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// }; 287796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// @endcode 288796da18402f286b897782a298ae3b20c459c102eDouglas Gregorclass CXXThisExpr : public Expr { 289796da18402f286b897782a298ae3b20c459c102eDouglas Gregor SourceLocation Loc; 290796da18402f286b897782a298ae3b20c459c102eDouglas Gregor 291796da18402f286b897782a298ae3b20c459c102eDouglas Gregorpublic: 292796da18402f286b897782a298ae3b20c459c102eDouglas Gregor CXXThisExpr(SourceLocation L, QualType Type) 2932850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl : Expr(CXXThisExprClass, Type, 2942850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl // 'this' is type-dependent if the class type of the enclosing 2952850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl // member function is dependent (C++ [temp.dep.expr]p2) 2962850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl Type->isDependentType(), Type->isDependentType()), 2972850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl Loc(L) { } 298796da18402f286b897782a298ae3b20c459c102eDouglas Gregor 299796da18402f286b897782a298ae3b20c459c102eDouglas Gregor virtual SourceRange getSourceRange() const { return SourceRange(Loc); } 300796da18402f286b897782a298ae3b20c459c102eDouglas Gregor 301796da18402f286b897782a298ae3b20c459c102eDouglas Gregor static bool classof(const Stmt *T) { 302796da18402f286b897782a298ae3b20c459c102eDouglas Gregor return T->getStmtClass() == CXXThisExprClass; 303796da18402f286b897782a298ae3b20c459c102eDouglas Gregor } 304796da18402f286b897782a298ae3b20c459c102eDouglas Gregor static bool classof(const CXXThisExpr *) { return true; } 305796da18402f286b897782a298ae3b20c459c102eDouglas Gregor 306796da18402f286b897782a298ae3b20c459c102eDouglas Gregor // Iterators 307796da18402f286b897782a298ae3b20c459c102eDouglas Gregor virtual child_iterator child_begin(); 308796da18402f286b897782a298ae3b20c459c102eDouglas Gregor virtual child_iterator child_end(); 309796da18402f286b897782a298ae3b20c459c102eDouglas Gregor}; 310796da18402f286b897782a298ae3b20c459c102eDouglas Gregor 3111060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek/// CXXThrowExpr - [C++ 15] C++ Throw Expression. This handles 3121060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek/// 'throw' and 'throw' assignment-expression. When 3131060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek/// assignment-expression isn't present, Op will be null. 3141060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek/// 3151060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenekclass CXXThrowExpr : public Expr { 3161060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek Stmt *Op; 3171060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek SourceLocation ThrowLoc; 3181060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenekpublic: 3191060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek // Ty is the void type which is used as the result type of the 3201060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek // exepression. The l is the location of the throw keyword. expr 3211060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek // can by null, if the optional expression to throw isn't present. 3221060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek CXXThrowExpr(Expr *expr, QualType Ty, SourceLocation l) : 3232850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl Expr(CXXThrowExprClass, Ty, false, false), Op(expr), ThrowLoc(l) {} 3241060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek const Expr *getSubExpr() const { return cast_or_null<Expr>(Op); } 3251060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek Expr *getSubExpr() { return cast_or_null<Expr>(Op); } 3261060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek 3271060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek virtual SourceRange getSourceRange() const { 3281060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek if (getSubExpr() == 0) 3291060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek return SourceRange(ThrowLoc, ThrowLoc); 3301060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek return SourceRange(ThrowLoc, getSubExpr()->getSourceRange().getEnd()); 3311060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek } 3321060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek 3331060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek static bool classof(const Stmt *T) { 3341060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek return T->getStmtClass() == CXXThrowExprClass; 3351060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek } 3361060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek static bool classof(const CXXThrowExpr *) { return true; } 3371060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek 3381060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek // Iterators 3391060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek virtual child_iterator child_begin(); 3401060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek virtual child_iterator child_end(); 3411060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek}; 3421060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek 3431060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek/// CXXDefaultArgExpr - C++ [dcl.fct.default]. This wraps up a 3441060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek/// function call argument that was created from the corresponding 3451060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek/// parameter's default argument, when the call did not explicitly 3461060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek/// supply arguments for all of the parameters. 3471060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenekclass CXXDefaultArgExpr : public Expr { 3481060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek ParmVarDecl *Param; 3491060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenekpublic: 3501060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek // Param is the parameter whose default argument is used by this 3511060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek // expression. 3521060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek explicit CXXDefaultArgExpr(ParmVarDecl *param) 35361366e9cd41a6dbde4e66416dac21269c8ac1d94Douglas Gregor : Expr(CXXDefaultArgExprClass, 35461366e9cd41a6dbde4e66416dac21269c8ac1d94Douglas Gregor param->hasUnparsedDefaultArg()? param->getType().getNonReferenceType() 35561366e9cd41a6dbde4e66416dac21269c8ac1d94Douglas Gregor : param->getDefaultArg()->getType()), 3561060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek Param(param) { } 3571060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek 3581060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek // Retrieve the parameter that the argument was created from. 3591060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek const ParmVarDecl *getParam() const { return Param; } 3601060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek ParmVarDecl *getParam() { return Param; } 3611060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek 3621060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek // Retrieve the actual argument to the function call. 3631060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek const Expr *getExpr() const { return Param->getDefaultArg(); } 3641060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek Expr *getExpr() { return Param->getDefaultArg(); } 3651060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek 3661060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek virtual SourceRange getSourceRange() const { 3671060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek // Default argument expressions have no representation in the 3681060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek // source, so they have an empty source range. 3691060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek return SourceRange(); 3701060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek } 3711060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek 3721060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek static bool classof(const Stmt *T) { 3731060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek return T->getStmtClass() == CXXDefaultArgExprClass; 3741060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek } 3751060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek static bool classof(const CXXDefaultArgExpr *) { return true; } 3761060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek 3771060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek // Iterators 3781060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek virtual child_iterator child_begin(); 3791060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek virtual child_iterator child_end(); 3801060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek}; 381987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis 38215ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson 38315ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson/// CXXConstructExpr - Represents a call to a C++ constructor. 38415ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlssonclass CXXConstructExpr : public Expr { 38515ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson VarDecl *VD; 38615ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson CXXConstructorDecl *Constructor; 38715ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson 38815ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson bool Elidable; 38915ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson 39015ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson Stmt **Args; 39115ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson unsigned NumArgs; 39215ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson 39315ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson CXXConstructExpr(ASTContext &C, VarDecl *vd, QualType T, 39415ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson CXXConstructorDecl *d, bool elidable, 39515ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson Expr **args, unsigned numargs); 39615ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson ~CXXConstructExpr() { } 39715ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson 39815ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlssonpublic: 39915ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson static CXXConstructExpr *Create(ASTContext &C, VarDecl *VD, QualType T, 40015ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson CXXConstructorDecl *D, bool Elidable, 40115ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson Expr **Args, unsigned NumArgs); 40215ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson 40315ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson void Destroy(ASTContext &C); 40415ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson 40515ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson const VarDecl* getVarDecl() const { return VD; } 40615ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson const CXXConstructorDecl* getConstructor() const { return Constructor; } 40715ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson 40815ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson typedef ExprIterator arg_iterator; 40915ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson typedef ConstExprIterator const_arg_iterator; 41015ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson 41115ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson arg_iterator arg_begin() { return Args; } 41215ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson arg_iterator arg_end() { return Args + NumArgs; } 41315ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson const_arg_iterator arg_begin() const { return Args; } 41415ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson const_arg_iterator arg_end() const { return Args + NumArgs; } 41515ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson 41615ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson unsigned getNumArgs() const { return NumArgs; } 41715ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson 41815ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson virtual SourceRange getSourceRange() const { return SourceRange(); } 41915ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson 42015ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson static bool classof(const Stmt *T) { 42115ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson return T->getStmtClass() == CXXConstructExprClass; 42215ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson } 42315ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson static bool classof(const CXXConstructExpr *) { return true; } 42415ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson 42515ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson // Iterators 42615ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson virtual child_iterator child_begin(); 42715ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson virtual child_iterator child_end(); 42815ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson}; 42915ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson 43049badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// CXXFunctionalCastExpr - Represents an explicit C++ type conversion 43149badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// that uses "functional" notion (C++ [expr.type.conv]). Example: @c 43249badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// x = int(0.5); 43349badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregorclass CXXFunctionalCastExpr : public ExplicitCastExpr { 434987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis SourceLocation TyBeginLoc; 435987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis SourceLocation RParenLoc; 436987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidispublic: 43749badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor CXXFunctionalCastExpr(QualType ty, QualType writtenTy, 43849badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor SourceLocation tyBeginLoc, Expr *castExpr, 439987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis SourceLocation rParenLoc) : 44049badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor ExplicitCastExpr(CXXFunctionalCastExprClass, ty, castExpr, writtenTy), 441987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis TyBeginLoc(tyBeginLoc), RParenLoc(rParenLoc) {} 442987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis 443987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis SourceLocation getTypeBeginLoc() const { return TyBeginLoc; } 444987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis SourceLocation getRParenLoc() const { return RParenLoc; } 445987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis 446987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis virtual SourceRange getSourceRange() const { 447987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis return SourceRange(TyBeginLoc, RParenLoc); 448987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis } 449987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis static bool classof(const Stmt *T) { 450987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis return T->getStmtClass() == CXXFunctionalCastExprClass; 451987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis } 452987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis static bool classof(const CXXFunctionalCastExpr *) { return true; } 453987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis}; 454987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis 455506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// @brief Represents a C++ functional cast expression that builds a 456506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// temporary object. 457506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// 458506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// This expression type represents a C++ "functional" cast 459506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// (C++[expr.type.conv]) with N != 1 arguments that invokes a 460506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// constructor to build a temporary object. If N == 0 but no 461506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// constructor will be called (because the functional cast is 462506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// performing a value-initialized an object whose class type has no 463506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// user-declared constructors), CXXZeroInitValueExpr will represent 464506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// the functional cast. Finally, with N == 1 arguments the functional 465506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// cast expression will be represented by CXXFunctionalCastExpr. 466506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// Example: 467506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// @code 468506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// struct X { X(int, float); } 469506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// 470506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// X create_X() { 471506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// return X(1, 3.14f); // creates a CXXTemporaryObjectExpr 472506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// }; 473506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// @endcode 474506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregorclass CXXTemporaryObjectExpr : public Expr { 475506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor SourceLocation TyBeginLoc; 476506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor SourceLocation RParenLoc; 477506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor CXXConstructorDecl *Constructor; 478506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor Stmt **Args; 479506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor unsigned NumArgs; 480506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor 481506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregorpublic: 482506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor CXXTemporaryObjectExpr(CXXConstructorDecl *Cons, QualType writtenTy, 483506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor SourceLocation tyBeginLoc, Expr **Args, 484506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor unsigned NumArgs, SourceLocation rParenLoc); 485506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor 486506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor ~CXXTemporaryObjectExpr(); 487506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor 488506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor SourceLocation getTypeBeginLoc() const { return TyBeginLoc; } 489506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor SourceLocation getRParenLoc() const { return RParenLoc; } 490506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor 491506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor typedef ExprIterator arg_iterator; 492506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor typedef ConstExprIterator const_arg_iterator; 493506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor 494506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor arg_iterator arg_begin() { return Args; } 495506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor arg_iterator arg_end() { return Args + NumArgs; } 496506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor const_arg_iterator arg_begin() const { return Args; } 497506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor const_arg_iterator arg_end() const { return Args + NumArgs; } 498506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor 499ba49817c5b9f502602672861cf369fd0e53966e8Douglas Gregor unsigned getNumArgs() const { return NumArgs; } 500ba49817c5b9f502602672861cf369fd0e53966e8Douglas Gregor 501d87a5012d174ae5aa076b3fa800aecf55d70bac4Anders Carlsson const CXXConstructorDecl* getConstructor() const { return Constructor; } 502d87a5012d174ae5aa076b3fa800aecf55d70bac4Anders Carlsson 503506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor virtual SourceRange getSourceRange() const { 504506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor return SourceRange(TyBeginLoc, RParenLoc); 505506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor } 506506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor static bool classof(const Stmt *T) { 507506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor return T->getStmtClass() == CXXTemporaryObjectExprClass; 508506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor } 509506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor static bool classof(const CXXTemporaryObjectExpr *) { return true; } 510506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor 511506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor // Iterators 512506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor virtual child_iterator child_begin(); 513506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor virtual child_iterator child_end(); 514506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor}; 515506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor 516987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis/// CXXZeroInitValueExpr - [C++ 5.2.3p2] 517506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// Expression "T()" which creates a value-initialized rvalue of type 518506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// T, which is either a non-class type or a class type without any 519506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// user-defined constructors. 520987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis/// 521987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidisclass CXXZeroInitValueExpr : public Expr { 522987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis SourceLocation TyBeginLoc; 523987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis SourceLocation RParenLoc; 524987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis 525987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidispublic: 526987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis CXXZeroInitValueExpr(QualType ty, SourceLocation tyBeginLoc, 527987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis SourceLocation rParenLoc ) : 528987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis Expr(CXXZeroInitValueExprClass, ty), 529987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis TyBeginLoc(tyBeginLoc), RParenLoc(rParenLoc) {} 530987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis 531987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis SourceLocation getTypeBeginLoc() const { return TyBeginLoc; } 532987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis SourceLocation getRParenLoc() const { return RParenLoc; } 533987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis 5344c67834407ca6ab344dcf44fc599ad4938cfa96dDouglas Gregor /// @brief Whether this initialization expression was 5354c67834407ca6ab344dcf44fc599ad4938cfa96dDouglas Gregor /// implicitly-generated. 5364c67834407ca6ab344dcf44fc599ad4938cfa96dDouglas Gregor bool isImplicit() const { 5374c67834407ca6ab344dcf44fc599ad4938cfa96dDouglas Gregor return TyBeginLoc.isInvalid() && RParenLoc.isInvalid(); 5384c67834407ca6ab344dcf44fc599ad4938cfa96dDouglas Gregor } 5394c67834407ca6ab344dcf44fc599ad4938cfa96dDouglas Gregor 540987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis virtual SourceRange getSourceRange() const { 541987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis return SourceRange(TyBeginLoc, RParenLoc); 542987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis } 543987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis 544987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis static bool classof(const Stmt *T) { 545987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis return T->getStmtClass() == CXXZeroInitValueExprClass; 546987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis } 547987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis static bool classof(const CXXZeroInitValueExpr *) { return true; } 548987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis 549987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis // Iterators 550987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis virtual child_iterator child_begin(); 551987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis virtual child_iterator child_end(); 552987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis}; 553987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis 5549e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis/// CXXConditionDeclExpr - Condition declaration of a if/switch/while/for 5559e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis/// statement, e.g: "if (int x = f()) {...}". 5569e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis/// The main difference with DeclRefExpr is that CXXConditionDeclExpr owns the 5579e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis/// decl that it references. 5589e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis/// 5599e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidisclass CXXConditionDeclExpr : public DeclRefExpr { 5609e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidispublic: 5619e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis CXXConditionDeclExpr(SourceLocation startLoc, 5629e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis SourceLocation eqLoc, VarDecl *var) 5639d293dfc0ad7c44ae0b5eb9517f1ed8c8d8b7ff7Douglas Gregor : DeclRefExpr(CXXConditionDeclExprClass, var, 5649d293dfc0ad7c44ae0b5eb9517f1ed8c8d8b7ff7Douglas Gregor var->getType().getNonReferenceType(), startLoc) {} 5659e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis 5669e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis virtual void Destroy(ASTContext& Ctx); 5679e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis 5689e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis SourceLocation getStartLoc() const { return getLocation(); } 5699e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis 5709e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis VarDecl *getVarDecl() { return cast<VarDecl>(getDecl()); } 5719e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis const VarDecl *getVarDecl() const { return cast<VarDecl>(getDecl()); } 5729e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis 5739e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis virtual SourceRange getSourceRange() const { 5749e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis return SourceRange(getStartLoc(), getVarDecl()->getInit()->getLocEnd()); 5759e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis } 5769e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis 5779e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis static bool classof(const Stmt *T) { 5789e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis return T->getStmtClass() == CXXConditionDeclExprClass; 5799e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis } 5809e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis static bool classof(const CXXConditionDeclExpr *) { return true; } 5819e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis 5829e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis // Iterators 5839e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis virtual child_iterator child_begin(); 5849e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis virtual child_iterator child_end(); 5859e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis}; 5869e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis 5874c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl/// CXXNewExpr - A new expression for memory allocation and constructor calls, 5884c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl/// e.g: "new CXXNewExpr(foo)". 5894c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redlclass CXXNewExpr : public Expr { 5904c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // Was the usage ::new, i.e. is the global new to be used? 5914c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl bool GlobalNew : 1; 5924c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // Was the form (type-id) used? Otherwise, it was new-type-id. 5934c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl bool ParenTypeId : 1; 5944c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // Is there an initializer? If not, built-ins are uninitialized, else they're 5954c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // value-initialized. 5964c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl bool Initializer : 1; 597cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl // Do we allocate an array? If so, the first SubExpr is the size expression. 598cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl bool Array : 1; 5994c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // The number of placement new arguments. 6004c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl unsigned NumPlacementArgs : 14; 6014c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // The number of constructor arguments. This may be 1 even for non-class 6024c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // types; use the pseudo copy constructor. 603cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl unsigned NumConstructorArgs : 14; 604cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl // Contains an optional array size expression, any number of optional 605cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl // placement arguments, and any number of optional constructor arguments, 606cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl // in that order. 6074c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl Stmt **SubExprs; 6084c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // Points to the allocation function used. 6094c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl FunctionDecl *OperatorNew; 6104c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // Points to the deallocation function used in case of error. May be null. 6114c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl FunctionDecl *OperatorDelete; 6124c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // Points to the constructor used. Cannot be null if AllocType is a record; 6134c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // it would still point at the default constructor (even an implicit one). 6144c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // Must be null for all other types. 6154c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl CXXConstructorDecl *Constructor; 6164c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 6174c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl SourceLocation StartLoc; 6184c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl SourceLocation EndLoc; 6194c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 6204c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redlpublic: 6214c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl CXXNewExpr(bool globalNew, FunctionDecl *operatorNew, Expr **placementArgs, 622cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl unsigned numPlaceArgs, bool ParenTypeId, Expr *arraySize, 6234c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl CXXConstructorDecl *constructor, bool initializer, 6244c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl Expr **constructorArgs, unsigned numConsArgs, 6254c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl FunctionDecl *operatorDelete, QualType ty, 6264c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl SourceLocation startLoc, SourceLocation endLoc); 6274c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl ~CXXNewExpr() { 6284c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl delete[] SubExprs; 6294c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 6304c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 631cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl QualType getAllocatedType() const { 632cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl assert(getType()->isPointerType()); 633cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl return getType()->getAsPointerType()->getPointeeType(); 634cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl } 6354c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 6364c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl FunctionDecl *getOperatorNew() const { return OperatorNew; } 6374c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl FunctionDecl *getOperatorDelete() const { return OperatorDelete; } 6384c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl CXXConstructorDecl *getConstructor() const { return Constructor; } 6394c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 640cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl bool isArray() const { return Array; } 641cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl Expr *getArraySize() { 642cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl return Array ? cast<Expr>(SubExprs[0]) : 0; 643cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl } 644cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl const Expr *getArraySize() const { 645cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl return Array ? cast<Expr>(SubExprs[0]) : 0; 646cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl } 647cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl 6484c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl unsigned getNumPlacementArgs() const { return NumPlacementArgs; } 6494c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl Expr *getPlacementArg(unsigned i) { 6504c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl assert(i < NumPlacementArgs && "Index out of range"); 651cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl return cast<Expr>(SubExprs[Array + i]); 6524c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 6534c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl const Expr *getPlacementArg(unsigned i) const { 6544c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl assert(i < NumPlacementArgs && "Index out of range"); 655cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl return cast<Expr>(SubExprs[Array + i]); 6564c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 6574c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 6584c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl bool isGlobalNew() const { return GlobalNew; } 6594c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl bool isParenTypeId() const { return ParenTypeId; } 6604c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl bool hasInitializer() const { return Initializer; } 6614c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 6624c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl unsigned getNumConstructorArgs() const { return NumConstructorArgs; } 6634c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl Expr *getConstructorArg(unsigned i) { 6644c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl assert(i < NumConstructorArgs && "Index out of range"); 665cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl return cast<Expr>(SubExprs[Array + NumPlacementArgs + i]); 6664c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 6674c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl const Expr *getConstructorArg(unsigned i) const { 6684c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl assert(i < NumConstructorArgs && "Index out of range"); 669cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl return cast<Expr>(SubExprs[Array + NumPlacementArgs + i]); 6704c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 6714c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 6724c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl typedef ExprIterator arg_iterator; 6734c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl typedef ConstExprIterator const_arg_iterator; 6744c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 6754c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl arg_iterator placement_arg_begin() { 676cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl return SubExprs + Array; 6774c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 6784c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl arg_iterator placement_arg_end() { 679cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl return SubExprs + Array + getNumPlacementArgs(); 6804c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 6814c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl const_arg_iterator placement_arg_begin() const { 682cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl return SubExprs + Array; 6834c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 6844c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl const_arg_iterator placement_arg_end() const { 685cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl return SubExprs + Array + getNumPlacementArgs(); 6864c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 6874c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 6884c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl arg_iterator constructor_arg_begin() { 689cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl return SubExprs + Array + getNumPlacementArgs(); 6904c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 6914c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl arg_iterator constructor_arg_end() { 692cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl return SubExprs + Array + getNumPlacementArgs() + getNumConstructorArgs(); 6934c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 6944c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl const_arg_iterator constructor_arg_begin() const { 695cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl return SubExprs + Array + getNumPlacementArgs(); 6964c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 6974c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl const_arg_iterator constructor_arg_end() const { 698cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl return SubExprs + Array + getNumPlacementArgs() + getNumConstructorArgs(); 6994c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 7004c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 7014c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl virtual SourceRange getSourceRange() const { 7024c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl return SourceRange(StartLoc, EndLoc); 7034c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 7044c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 7054c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl static bool classof(const Stmt *T) { 7064c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl return T->getStmtClass() == CXXNewExprClass; 7074c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 7084c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl static bool classof(const CXXNewExpr *) { return true; } 7094c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 7104c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // Iterators 7114c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl virtual child_iterator child_begin(); 7124c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl virtual child_iterator child_end(); 7134c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl}; 7144c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 7154c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl/// CXXDeleteExpr - A delete expression for memory deallocation and destructor 7164c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl/// calls, e.g. "delete[] pArray". 7174c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redlclass CXXDeleteExpr : public Expr { 7184c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // Is this a forced global delete, i.e. "::delete"? 7194c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl bool GlobalDelete : 1; 7204c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // Is this the array form of delete, i.e. "delete[]"? 7214c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl bool ArrayForm : 1; 7224c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // Points to the operator delete overload that is used. Could be a member. 7234c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl FunctionDecl *OperatorDelete; 7244c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // The pointer expression to be deleted. 7254c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl Stmt *Argument; 7264c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // Location of the expression. 7274c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl SourceLocation Loc; 7284c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redlpublic: 7294c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl CXXDeleteExpr(QualType ty, bool globalDelete, bool arrayForm, 7304c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl FunctionDecl *operatorDelete, Expr *arg, SourceLocation loc) 7312850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl : Expr(CXXDeleteExprClass, ty, false, false), GlobalDelete(globalDelete), 7324c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl ArrayForm(arrayForm), OperatorDelete(operatorDelete), Argument(arg), 7334c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl Loc(loc) { } 7344c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 7354c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl bool isGlobalDelete() const { return GlobalDelete; } 7364c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl bool isArrayForm() const { return ArrayForm; } 7374c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 7384c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl FunctionDecl *getOperatorDelete() const { return OperatorDelete; } 7394c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 7404c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl Expr *getArgument() { return cast<Expr>(Argument); } 7414c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl const Expr *getArgument() const { return cast<Expr>(Argument); } 7424c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 7434c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl virtual SourceRange getSourceRange() const { 7444c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl return SourceRange(Loc, Argument->getLocEnd()); 7454c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 7464c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 7474c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl static bool classof(const Stmt *T) { 7484c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl return T->getStmtClass() == CXXDeleteExprClass; 7494c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 7504c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl static bool classof(const CXXDeleteExpr *) { return true; } 7514c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 7524c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // Iterators 7534c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl virtual child_iterator child_begin(); 7544c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl virtual child_iterator child_end(); 7554c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl}; 7564c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 75717330019f05966762bc952840ef1926b9becb145Douglas Gregor/// \brief Represents the name of a function that has not been 75817330019f05966762bc952840ef1926b9becb145Douglas Gregor/// resolved to any declaration. 75917330019f05966762bc952840ef1926b9becb145Douglas Gregor/// 76017330019f05966762bc952840ef1926b9becb145Douglas Gregor/// Unresolved function names occur when a function name is 76117330019f05966762bc952840ef1926b9becb145Douglas Gregor/// encountered prior to an open parentheses ('(') in a C++ function 76217330019f05966762bc952840ef1926b9becb145Douglas Gregor/// call, and the function name itself did not resolve to a 76317330019f05966762bc952840ef1926b9becb145Douglas Gregor/// declaration. These function names can only be resolved when they 76417330019f05966762bc952840ef1926b9becb145Douglas Gregor/// form the postfix-expression of a function call, so that 76517330019f05966762bc952840ef1926b9becb145Douglas Gregor/// argument-dependent lookup finds declarations corresponding to 76617330019f05966762bc952840ef1926b9becb145Douglas Gregor/// these functions. 76717330019f05966762bc952840ef1926b9becb145Douglas Gregor 7685c37de788529cd9180f22069970737a7208bd625Douglas Gregor/// @code 7695c37de788529cd9180f22069970737a7208bd625Douglas Gregor/// template<typename T> void f(T x) { 77017330019f05966762bc952840ef1926b9becb145Douglas Gregor/// g(x); // g is an unresolved function name (that is also a dependent name) 7715c37de788529cd9180f22069970737a7208bd625Douglas Gregor/// } 7725c37de788529cd9180f22069970737a7208bd625Douglas Gregor/// @endcode 77317330019f05966762bc952840ef1926b9becb145Douglas Gregorclass UnresolvedFunctionNameExpr : public Expr { 77417330019f05966762bc952840ef1926b9becb145Douglas Gregor /// The name that was present in the source 77517330019f05966762bc952840ef1926b9becb145Douglas Gregor DeclarationName Name; 7765c37de788529cd9180f22069970737a7208bd625Douglas Gregor 77717330019f05966762bc952840ef1926b9becb145Douglas Gregor /// The location of this name in the source code 7785c37de788529cd9180f22069970737a7208bd625Douglas Gregor SourceLocation Loc; 7795c37de788529cd9180f22069970737a7208bd625Douglas Gregor 7805c37de788529cd9180f22069970737a7208bd625Douglas Gregorpublic: 78117330019f05966762bc952840ef1926b9becb145Douglas Gregor UnresolvedFunctionNameExpr(DeclarationName N, QualType T, SourceLocation L) 78217330019f05966762bc952840ef1926b9becb145Douglas Gregor : Expr(UnresolvedFunctionNameExprClass, T, false, false), Name(N), Loc(L) { } 7835c37de788529cd9180f22069970737a7208bd625Douglas Gregor 78417330019f05966762bc952840ef1926b9becb145Douglas Gregor /// \brief Retrieves the name that occurred in the source code. 78517330019f05966762bc952840ef1926b9becb145Douglas Gregor DeclarationName getName() const { return Name; } 7865c37de788529cd9180f22069970737a7208bd625Douglas Gregor 7875c37de788529cd9180f22069970737a7208bd625Douglas Gregor /// getLocation - Retrieves the location in the source code where 7885c37de788529cd9180f22069970737a7208bd625Douglas Gregor /// the name occurred. 7895c37de788529cd9180f22069970737a7208bd625Douglas Gregor SourceLocation getLocation() const { return Loc; } 7905c37de788529cd9180f22069970737a7208bd625Douglas Gregor 7915c37de788529cd9180f22069970737a7208bd625Douglas Gregor virtual SourceRange getSourceRange() const { return SourceRange(Loc); } 7925c37de788529cd9180f22069970737a7208bd625Douglas Gregor 7935c37de788529cd9180f22069970737a7208bd625Douglas Gregor static bool classof(const Stmt *T) { 79417330019f05966762bc952840ef1926b9becb145Douglas Gregor return T->getStmtClass() == UnresolvedFunctionNameExprClass; 7955c37de788529cd9180f22069970737a7208bd625Douglas Gregor } 79617330019f05966762bc952840ef1926b9becb145Douglas Gregor static bool classof(const UnresolvedFunctionNameExpr *) { return true; } 7975c37de788529cd9180f22069970737a7208bd625Douglas Gregor 7985c37de788529cd9180f22069970737a7208bd625Douglas Gregor // Iterators 7995c37de788529cd9180f22069970737a7208bd625Douglas Gregor virtual child_iterator child_begin(); 8005c37de788529cd9180f22069970737a7208bd625Douglas Gregor virtual child_iterator child_end(); 8015c37de788529cd9180f22069970737a7208bd625Douglas Gregor}; 8025c37de788529cd9180f22069970737a7208bd625Douglas Gregor 80364b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl/// UnaryTypeTraitExpr - A GCC or MS unary type trait, as used in the 80464b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl/// implementation of TR1/C++0x type trait templates. 80564b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl/// Example: 80664b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl/// __is_pod(int) == true 80764b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl/// __is_enum(std::string) == false 80864b45f7e0d3167f040841ac2920aead7f080730dSebastian Redlclass UnaryTypeTraitExpr : public Expr { 80964b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl /// UTT - The trait. 81064b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl UnaryTypeTrait UTT; 81164b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl 81264b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl /// Loc - The location of the type trait keyword. 81364b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl SourceLocation Loc; 81464b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl 81564b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl /// RParen - The location of the closing paren. 81664b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl SourceLocation RParen; 81764b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl 81864b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl /// QueriedType - The type we're testing. 81964b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl QualType QueriedType; 82064b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl 82164b45f7e0d3167f040841ac2920aead7f080730dSebastian Redlpublic: 82264b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl UnaryTypeTraitExpr(SourceLocation loc, UnaryTypeTrait utt, QualType queried, 82364b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl SourceLocation rparen, QualType ty) 82464b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl : Expr(UnaryTypeTraitExprClass, ty, false, queried->isDependentType()), 82564b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl UTT(utt), Loc(loc), RParen(rparen), QueriedType(queried) { } 82664b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl 82764b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl virtual SourceRange getSourceRange() const { return SourceRange(Loc, RParen);} 82864b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl 82964b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl UnaryTypeTrait getTrait() const { return UTT; } 83064b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl 83164b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl QualType getQueriedType() const { return QueriedType; } 83264b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl 833c87a282e7b80c055088fc51bdbe8fc73da64d4f8Daniel Dunbar bool EvaluateTrait() const; 83464b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl 83564b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl static bool classof(const Stmt *T) { 83664b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl return T->getStmtClass() == UnaryTypeTraitExprClass; 83764b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl } 83864b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl static bool classof(const UnaryTypeTraitExpr *) { return true; } 83964b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl 84064b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl // Iterators 84164b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl virtual child_iterator child_begin(); 84264b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl virtual child_iterator child_end(); 84364b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl}; 84464b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl 8451a49af9681c350fef58e677f85ccb9a77e8e9d0aDouglas Gregor/// QualifiedDeclRefExpr - A reference to a declared variable, 8461a49af9681c350fef58e677f85ccb9a77e8e9d0aDouglas Gregor/// function, enum, etc., that includes a qualification, e.g., 8471a49af9681c350fef58e677f85ccb9a77e8e9d0aDouglas Gregor/// "N::foo". 8481a49af9681c350fef58e677f85ccb9a77e8e9d0aDouglas Gregorclass QualifiedDeclRefExpr : public DeclRefExpr { 849bad351822117eaf280081494e3dbe4a06c0dbfcfDouglas Gregor /// QualifierRange - The source range that covers the 850bad351822117eaf280081494e3dbe4a06c0dbfcfDouglas Gregor /// nested-name-specifier. 851bad351822117eaf280081494e3dbe4a06c0dbfcfDouglas Gregor SourceRange QualifierRange; 852bad351822117eaf280081494e3dbe4a06c0dbfcfDouglas Gregor 853ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor /// \brief The nested-name-specifier that qualifies this declaration 854ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor /// name. 855ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor NestedNameSpecifier *NNS; 856bad351822117eaf280081494e3dbe4a06c0dbfcfDouglas Gregor 857bad351822117eaf280081494e3dbe4a06c0dbfcfDouglas Gregorpublic: 858ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor QualifiedDeclRefExpr(NamedDecl *d, QualType t, SourceLocation l, bool TD, 859ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor bool VD, SourceRange R, NestedNameSpecifier *NNS) 860ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor : DeclRefExpr(QualifiedDeclRefExprClass, d, t, l, TD, VD), 861ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor QualifierRange(R), NNS(NNS) { } 862bad351822117eaf280081494e3dbe4a06c0dbfcfDouglas Gregor 863bad351822117eaf280081494e3dbe4a06c0dbfcfDouglas Gregor /// \brief Retrieve the source range of the nested-name-specifier. 864bad351822117eaf280081494e3dbe4a06c0dbfcfDouglas Gregor SourceRange getQualifierRange() const { return QualifierRange; } 865bad351822117eaf280081494e3dbe4a06c0dbfcfDouglas Gregor 866ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor /// \brief Retrieve the nested-name-specifier that qualifies this 867ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor /// declaration. 868ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor NestedNameSpecifier *getQualifier() const { return NNS; } 8691a49af9681c350fef58e677f85ccb9a77e8e9d0aDouglas Gregor 8701a49af9681c350fef58e677f85ccb9a77e8e9d0aDouglas Gregor virtual SourceRange getSourceRange() const { 871bad351822117eaf280081494e3dbe4a06c0dbfcfDouglas Gregor return SourceRange(QualifierRange.getBegin(), getLocation()); 8721a49af9681c350fef58e677f85ccb9a77e8e9d0aDouglas Gregor } 8731a49af9681c350fef58e677f85ccb9a77e8e9d0aDouglas Gregor 8741a49af9681c350fef58e677f85ccb9a77e8e9d0aDouglas Gregor static bool classof(const Stmt *T) { 8751a49af9681c350fef58e677f85ccb9a77e8e9d0aDouglas Gregor return T->getStmtClass() == QualifiedDeclRefExprClass; 8761a49af9681c350fef58e677f85ccb9a77e8e9d0aDouglas Gregor } 8771a49af9681c350fef58e677f85ccb9a77e8e9d0aDouglas Gregor static bool classof(const QualifiedDeclRefExpr *) { return true; } 8781a49af9681c350fef58e677f85ccb9a77e8e9d0aDouglas Gregor}; 8791a49af9681c350fef58e677f85ccb9a77e8e9d0aDouglas Gregor 8805953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor/// \brief A qualified reference to a name whose declaration cannot 8815953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor/// yet be resolved. 8825953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor/// 8835953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor/// UnresolvedDeclRefExpr is similar to QualifiedDeclRefExpr in that 8845953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor/// it expresses a qualified reference to a declaration such as 8855953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor/// X<T>::value. The difference, however, is that an 8865953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor/// UnresolvedDeclRefExpr node is used only within C++ templates when 8875953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor/// the qualification (e.g., X<T>::) refers to a dependent type. In 8885953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor/// this case, X<T>::value cannot resolve to a declaration because the 8895953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor/// declaration will differ from on instantiation of X<T> to the 890ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor/// next. Therefore, UnresolvedDeclRefExpr keeps track of the 891ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor/// qualifier (X<T>::) and the name of the entity being referenced 892ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor/// ("value"). Such expressions will instantiate to 893ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor/// QualifiedDeclRefExprs. 8945953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregorclass UnresolvedDeclRefExpr : public Expr { 8955953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor /// The name of the entity we will be referencing. 8965953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor DeclarationName Name; 8975953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor 8985953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor /// Location of the name of the declaration we're referencing. 8995953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor SourceLocation Loc; 9005953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor 9015953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor /// QualifierRange - The source range that covers the 9025953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor /// nested-name-specifier. 9035953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor SourceRange QualifierRange; 9045953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor 905ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor /// \brief The nested-name-specifier that qualifies this unresolved 906ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor /// declaration name. 907ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor NestedNameSpecifier *NNS; 9085953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor 9095953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregorpublic: 910ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor UnresolvedDeclRefExpr(DeclarationName N, QualType T, SourceLocation L, 911ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor SourceRange R, NestedNameSpecifier *NNS) 912ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor : Expr(UnresolvedDeclRefExprClass, T, true, true), 913ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor Name(N), Loc(L), QualifierRange(R), NNS(NNS) { } 9145953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor 9155953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor /// \brief Retrieve the name that this expression refers to. 9165953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor DeclarationName getDeclName() const { return Name; } 9175953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor 9185953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor /// \brief Retrieve the location of the name within the expression. 9195953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor SourceLocation getLocation() const { return Loc; } 9205953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor 9215953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor /// \brief Retrieve the source range of the nested-name-specifier. 9225953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor SourceRange getQualifierRange() const { return QualifierRange; } 9235953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor 924ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor /// \brief Retrieve the nested-name-specifier that qualifies this 925ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor /// declaration. 926ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor NestedNameSpecifier *getQualifier() const { return NNS; } 9275953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor 9285953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor virtual SourceRange getSourceRange() const { 9295953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor return SourceRange(QualifierRange.getBegin(), getLocation()); 9305953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor } 9315953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor 9325953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor static bool classof(const Stmt *T) { 9335953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor return T->getStmtClass() == UnresolvedDeclRefExprClass; 9345953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor } 9355953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor static bool classof(const UnresolvedDeclRefExpr *) { return true; } 9365953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor 9375953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor virtual StmtIterator child_begin(); 9385953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor virtual StmtIterator child_end(); 9395953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor}; 9405953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor 941e349bea668622ef31bd51a229960a73d69940709Anders Carlsson/// CXXDestroyExpr - Represents an implicit call to a C++ destructor. 94219d28a650ca6d98f7907ad891557fccca7baaea8Anders Carlssonclass CXXDestroyExpr : public Expr { 94319d28a650ca6d98f7907ad891557fccca7baaea8Anders Carlsson VarDecl *VD; 94419d28a650ca6d98f7907ad891557fccca7baaea8Anders Carlsson 94519d28a650ca6d98f7907ad891557fccca7baaea8Anders Carlsson CXXDestroyExpr(VarDecl* vd, QualType T) 94619d28a650ca6d98f7907ad891557fccca7baaea8Anders Carlsson : Expr(CXXDestroyExprClass, T, false, vd->getType()->isDependentType()), 94719d28a650ca6d98f7907ad891557fccca7baaea8Anders Carlsson VD(vd) { } 94819d28a650ca6d98f7907ad891557fccca7baaea8Anders Carlsson 94919d28a650ca6d98f7907ad891557fccca7baaea8Anders Carlssonpublic: 95019d28a650ca6d98f7907ad891557fccca7baaea8Anders Carlsson static CXXDestroyExpr *Create(ASTContext &C, VarDecl *vd); 95119d28a650ca6d98f7907ad891557fccca7baaea8Anders Carlsson 95219d28a650ca6d98f7907ad891557fccca7baaea8Anders Carlsson virtual SourceRange getSourceRange() const { return SourceRange(); } 95319d28a650ca6d98f7907ad891557fccca7baaea8Anders Carlsson 95419d28a650ca6d98f7907ad891557fccca7baaea8Anders Carlsson // Implement isa/cast/dyncast/etc. 95519d28a650ca6d98f7907ad891557fccca7baaea8Anders Carlsson static bool classof(const Stmt *T) { 95619d28a650ca6d98f7907ad891557fccca7baaea8Anders Carlsson return T->getStmtClass() == CXXDestroyExprClass; 95719d28a650ca6d98f7907ad891557fccca7baaea8Anders Carlsson } 95819d28a650ca6d98f7907ad891557fccca7baaea8Anders Carlsson static bool classof(const CXXDestroyExpr *) { return true; } 95919d28a650ca6d98f7907ad891557fccca7baaea8Anders Carlsson 96019d28a650ca6d98f7907ad891557fccca7baaea8Anders Carlsson // Iterators 96119d28a650ca6d98f7907ad891557fccca7baaea8Anders Carlsson virtual child_iterator child_begin(); 96219d28a650ca6d98f7907ad891557fccca7baaea8Anders Carlsson virtual child_iterator child_end(); 96319d28a650ca6d98f7907ad891557fccca7baaea8Anders Carlsson}; 96419d28a650ca6d98f7907ad891557fccca7baaea8Anders Carlsson 9655f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer} // end namespace clang 9665f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 9675f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer#endif 968