ExprCXX.h revision 4a2487aeacf9f35ce553318c2eb39c20ec23845e
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; 2402bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson class CXXTempVarDecl; 254c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 261060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek//===--------------------------------------------------------------------===// 271060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek// C++ Expressions. 281060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek//===--------------------------------------------------------------------===// 291060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek 303fd95ce225393fe4a3623e429766a8c3f487ff9dDouglas Gregor/// \brief A call to an overloaded operator written using operator 313fd95ce225393fe4a3623e429766a8c3f487ff9dDouglas Gregor/// syntax. 323fd95ce225393fe4a3623e429766a8c3f487ff9dDouglas Gregor/// 333fd95ce225393fe4a3623e429766a8c3f487ff9dDouglas Gregor/// Represents a call to an overloaded operator written using operator 343fd95ce225393fe4a3623e429766a8c3f487ff9dDouglas Gregor/// syntax, e.g., "x + y" or "*p". While semantically equivalent to a 353fd95ce225393fe4a3623e429766a8c3f487ff9dDouglas Gregor/// normal call, this AST node provides better information about the 363fd95ce225393fe4a3623e429766a8c3f487ff9dDouglas Gregor/// syntactic representation of the call. 373fd95ce225393fe4a3623e429766a8c3f487ff9dDouglas Gregor/// 383fd95ce225393fe4a3623e429766a8c3f487ff9dDouglas Gregor/// In a C++ template, this expression node kind will be used whenever 393fd95ce225393fe4a3623e429766a8c3f487ff9dDouglas Gregor/// any of the arguments are type-dependent. In this case, the 403fd95ce225393fe4a3623e429766a8c3f487ff9dDouglas Gregor/// function itself will be a (possibly empty) set of functions and 413fd95ce225393fe4a3623e429766a8c3f487ff9dDouglas Gregor/// function templates that were found by name lookup at template 423fd95ce225393fe4a3623e429766a8c3f487ff9dDouglas Gregor/// definition time. 43b4609806e9232593ece09ce08b630836e825865cDouglas Gregorclass CXXOperatorCallExpr : public CallExpr { 44063daf6e196c51f162e0485478355d8e280eef5cDouglas Gregor /// \brief The overloaded operator. 45063daf6e196c51f162e0485478355d8e280eef5cDouglas Gregor OverloadedOperatorKind Operator; 46063daf6e196c51f162e0485478355d8e280eef5cDouglas Gregor 47b4609806e9232593ece09ce08b630836e825865cDouglas Gregorpublic: 48063daf6e196c51f162e0485478355d8e280eef5cDouglas Gregor CXXOperatorCallExpr(ASTContext& C, OverloadedOperatorKind Op, Expr *fn, 49063daf6e196c51f162e0485478355d8e280eef5cDouglas Gregor Expr **args, unsigned numargs, QualType t, 50063daf6e196c51f162e0485478355d8e280eef5cDouglas Gregor SourceLocation operatorloc) 51063daf6e196c51f162e0485478355d8e280eef5cDouglas Gregor : CallExpr(C, CXXOperatorCallExprClass, fn, args, numargs, t, operatorloc), 52063daf6e196c51f162e0485478355d8e280eef5cDouglas Gregor Operator(Op) {} 53b4609806e9232593ece09ce08b630836e825865cDouglas Gregor 54b4609806e9232593ece09ce08b630836e825865cDouglas Gregor /// getOperator - Returns the kind of overloaded operator that this 55b4609806e9232593ece09ce08b630836e825865cDouglas Gregor /// expression refers to. 56063daf6e196c51f162e0485478355d8e280eef5cDouglas Gregor OverloadedOperatorKind getOperator() const { return Operator; } 57b4609806e9232593ece09ce08b630836e825865cDouglas Gregor 58b4609806e9232593ece09ce08b630836e825865cDouglas Gregor /// getOperatorLoc - Returns the location of the operator symbol in 59b4609806e9232593ece09ce08b630836e825865cDouglas Gregor /// the expression. When @c getOperator()==OO_Call, this is the 60b4609806e9232593ece09ce08b630836e825865cDouglas Gregor /// location of the right parentheses; when @c 61b4609806e9232593ece09ce08b630836e825865cDouglas Gregor /// getOperator()==OO_Subscript, this is the location of the right 62b4609806e9232593ece09ce08b630836e825865cDouglas Gregor /// bracket. 63b4609806e9232593ece09ce08b630836e825865cDouglas Gregor SourceLocation getOperatorLoc() const { return getRParenLoc(); } 64b4609806e9232593ece09ce08b630836e825865cDouglas Gregor 65b4609806e9232593ece09ce08b630836e825865cDouglas Gregor virtual SourceRange getSourceRange() const; 66b4609806e9232593ece09ce08b630836e825865cDouglas Gregor 67b4609806e9232593ece09ce08b630836e825865cDouglas Gregor static bool classof(const Stmt *T) { 68b4609806e9232593ece09ce08b630836e825865cDouglas Gregor return T->getStmtClass() == CXXOperatorCallExprClass; 69b4609806e9232593ece09ce08b630836e825865cDouglas Gregor } 70b4609806e9232593ece09ce08b630836e825865cDouglas Gregor static bool classof(const CXXOperatorCallExpr *) { return true; } 71b4609806e9232593ece09ce08b630836e825865cDouglas Gregor}; 72b4609806e9232593ece09ce08b630836e825865cDouglas Gregor 7388a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor/// CXXMemberCallExpr - Represents a call to a member function that 7488a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor/// may be written either with member call syntax (e.g., "obj.func()" 7588a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor/// or "objptr->func()") or with normal function-call syntax 7688a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor/// ("func()") within a member function that ends up calling a member 7788a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor/// function. The callee in either case is a MemberExpr that contains 7888a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor/// both the object argument and the member function, while the 7988a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor/// arguments are the arguments within the parentheses (not including 8088a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor/// the object argument). 8188a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregorclass CXXMemberCallExpr : public CallExpr { 8288a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregorpublic: 83668bf91d31265b6ea8c3eb854ba450857701f269Ted Kremenek CXXMemberCallExpr(ASTContext& C, Expr *fn, Expr **args, unsigned numargs, 84668bf91d31265b6ea8c3eb854ba450857701f269Ted Kremenek QualType t, SourceLocation rparenloc) 85668bf91d31265b6ea8c3eb854ba450857701f269Ted Kremenek : CallExpr(C, CXXMemberCallExprClass, fn, args, numargs, t, rparenloc) {} 8688a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor 8788a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor /// getImplicitObjectArgument - Retrieves the implicit object 8888a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor /// argument for the member call. For example, in "x.f(5)", this 8988a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor /// operation would return "x". 9088a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor Expr *getImplicitObjectArgument(); 9188a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor 9288a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor static bool classof(const Stmt *T) { 9388a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor return T->getStmtClass() == CXXMemberCallExprClass; 9488a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor } 9588a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor static bool classof(const CXXMemberCallExpr *) { return true; } 9688a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor}; 9788a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor 9849badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// CXXNamedCastExpr - Abstract class common to all of the C++ "named" 9949badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// casts, @c static_cast, @c dynamic_cast, @c reinterpret_cast, or @c 10049badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// const_cast. 10149badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// 10249badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// This abstract class is inherited by all of the classes 10349badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// representing "named" casts, e.g., CXXStaticCastExpr, 10449badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// CXXDynamicCastExpr, CXXReinterpretCastExpr, and CXXConstCastExpr. 10549badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregorclass CXXNamedCastExpr : public ExplicitCastExpr { 1061060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenekprivate: 1071060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek SourceLocation Loc; // the location of the casting op 10849badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor 10949badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregorprotected: 11049badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor CXXNamedCastExpr(StmtClass SC, QualType ty, Expr *op, QualType writtenTy, 11149badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor SourceLocation l) 11249badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor : ExplicitCastExpr(SC, ty, op, writtenTy), Loc(l) {} 11349badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor 1141060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenekpublic: 11549badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor const char *getCastName() const; 11649badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor 1171060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek virtual SourceRange getSourceRange() const { 1181060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek return SourceRange(Loc, getSubExpr()->getSourceRange().getEnd()); 1191060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek } 1201060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek static bool classof(const Stmt *T) { 12149badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor switch (T->getStmtClass()) { 12249badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor case CXXNamedCastExprClass: 12349badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor case CXXStaticCastExprClass: 12449badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor case CXXDynamicCastExprClass: 12549badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor case CXXReinterpretCastExprClass: 12649badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor case CXXConstCastExprClass: 12749badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor return true; 12849badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor default: 12949badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor return false; 13049badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor } 1311060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek } 13249badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor static bool classof(const CXXNamedCastExpr *) { return true; } 13349badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor}; 13449badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor 13549badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// CXXStaticCastExpr - A C++ @c static_cast expression (C++ [expr.static.cast]). 13649badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// 13749badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// This expression node represents a C++ static cast, e.g., 13849badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// @c static_cast<int>(1.0). 13949badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregorclass CXXStaticCastExpr : public CXXNamedCastExpr { 14049badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregorpublic: 14149badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor CXXStaticCastExpr(QualType ty, Expr *op, QualType writtenTy, SourceLocation l) 14249badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor : CXXNamedCastExpr(CXXStaticCastExprClass, ty, op, writtenTy, l) {} 14349badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor 14449badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor static bool classof(const Stmt *T) { 14549badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor return T->getStmtClass() == CXXStaticCastExprClass; 14649badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor } 14749badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor static bool classof(const CXXStaticCastExpr *) { return true; } 14849badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor}; 14949badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor 15049badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// CXXDynamicCastExpr - A C++ @c dynamic_cast expression 15149badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// (C++ [expr.dynamic.cast]), which may perform a run-time check to 15249badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// determine how to perform the type cast. 15349badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// 15449badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// This expression node represents a dynamic cast, e.g., 15549badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// @c dynamic_cast<Derived*>(BasePtr). 15649badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregorclass CXXDynamicCastExpr : public CXXNamedCastExpr { 15749badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregorpublic: 15849badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor CXXDynamicCastExpr(QualType ty, Expr *op, QualType writtenTy, SourceLocation l) 15949badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor : CXXNamedCastExpr(CXXDynamicCastExprClass, ty, op, writtenTy, l) {} 16049badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor 16149badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor static bool classof(const Stmt *T) { 16249badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor return T->getStmtClass() == CXXDynamicCastExprClass; 16349badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor } 16449badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor static bool classof(const CXXDynamicCastExpr *) { return true; } 16549badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor}; 16649badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor 16749badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// CXXReinterpretCastExpr - A C++ @c reinterpret_cast expression (C++ 16849badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// [expr.reinterpret.cast]), which provides a differently-typed view 16949badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// of a value but performs no actual work at run time. 17049badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// 17149badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// This expression node represents a reinterpret cast, e.g., 17249badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// @c reinterpret_cast<int>(VoidPtr). 17349badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregorclass CXXReinterpretCastExpr : public CXXNamedCastExpr { 17449badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregorpublic: 17549badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor CXXReinterpretCastExpr(QualType ty, Expr *op, QualType writtenTy, 17649badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor SourceLocation l) 17749badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor : CXXNamedCastExpr(CXXReinterpretCastExprClass, ty, op, writtenTy, l) {} 17849badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor 17949badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor static bool classof(const Stmt *T) { 18049badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor return T->getStmtClass() == CXXReinterpretCastExprClass; 18149badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor } 18249badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor static bool classof(const CXXReinterpretCastExpr *) { return true; } 18349badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor}; 18449badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor 18549badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// CXXConstCastExpr - A C++ @c const_cast expression (C++ [expr.const.cast]), 18649badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// which can remove type qualifiers but does not change the underlying value. 18749badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// 18849badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// This expression node represents a const cast, e.g., 18949badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// @c const_cast<char*>(PtrToConstChar). 19049badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregorclass CXXConstCastExpr : public CXXNamedCastExpr { 19149badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregorpublic: 19249badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor CXXConstCastExpr(QualType ty, Expr *op, QualType writtenTy, 19349badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor SourceLocation l) 19449badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor : CXXNamedCastExpr(CXXConstCastExprClass, ty, op, writtenTy, l) {} 19549badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor 19649badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor static bool classof(const Stmt *T) { 19749badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor return T->getStmtClass() == CXXConstCastExprClass; 19849badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor } 19949badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor static bool classof(const CXXConstCastExpr *) { return true; } 2001060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek}; 2011060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek 2021060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek/// CXXBoolLiteralExpr - [C++ 2.13.5] C++ Boolean Literal. 2031060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek/// 2041060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenekclass CXXBoolLiteralExpr : public Expr { 2051060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek bool Value; 2061060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek SourceLocation Loc; 2071060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenekpublic: 2081060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek CXXBoolLiteralExpr(bool val, QualType Ty, SourceLocation l) : 2091060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek Expr(CXXBoolLiteralExprClass, Ty), Value(val), Loc(l) {} 2108b0b475b3464b0f70b91ba7d679d23c424677d5eSebastian Redl 2118b0b475b3464b0f70b91ba7d679d23c424677d5eSebastian Redl CXXBoolLiteralExpr* Clone(ASTContext &C) const; 2128b0b475b3464b0f70b91ba7d679d23c424677d5eSebastian Redl 2131060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek bool getValue() const { return Value; } 2145f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 2151060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek virtual SourceRange getSourceRange() const { return SourceRange(Loc); } 2165f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 2171060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek static bool classof(const Stmt *T) { 2181060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek return T->getStmtClass() == CXXBoolLiteralExprClass; 2191060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek } 2201060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek static bool classof(const CXXBoolLiteralExpr *) { return true; } 2215f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 2221060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek // Iterators 2231060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek virtual child_iterator child_begin(); 2241060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek virtual child_iterator child_end(); 2251060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek}; 2261060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek 2276e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl/// CXXNullPtrLiteralExpr - [C++0x 2.14.7] C++ Pointer Literal 2286e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redlclass CXXNullPtrLiteralExpr : public Expr { 2296e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl SourceLocation Loc; 2306e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redlpublic: 2316e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl CXXNullPtrLiteralExpr(QualType Ty, SourceLocation l) : 2326e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl Expr(CXXNullPtrLiteralExprClass, Ty), Loc(l) {} 2336e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl 2348b0b475b3464b0f70b91ba7d679d23c424677d5eSebastian Redl CXXNullPtrLiteralExpr* Clone(ASTContext &C) const; 2358b0b475b3464b0f70b91ba7d679d23c424677d5eSebastian Redl 2366e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl virtual SourceRange getSourceRange() const { return SourceRange(Loc); } 2376e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl 2386e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl static bool classof(const Stmt *T) { 2396e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl return T->getStmtClass() == CXXNullPtrLiteralExprClass; 2406e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl } 2416e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl static bool classof(const CXXNullPtrLiteralExpr *) { return true; } 2426e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl 2436e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl virtual child_iterator child_begin(); 2446e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl virtual child_iterator child_end(); 2456e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl}; 2466e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl 247c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl/// CXXTypeidExpr - A C++ @c typeid expression (C++ [expr.typeid]), which gets 248c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl/// the type_info that corresponds to the supplied type, or the (possibly 249c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl/// dynamic) type of the supplied expression. 250c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl/// 251c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl/// This represents code like @c typeid(int) or @c typeid(*objPtr) 252c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redlclass CXXTypeidExpr : public Expr { 253c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redlprivate: 254c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl bool isTypeOp : 1; 255d457589fc69dc7a9c80cd74d317c0b81a35a27c9Sebastian Redl union { 256d457589fc69dc7a9c80cd74d317c0b81a35a27c9Sebastian Redl void *Ty; 257d457589fc69dc7a9c80cd74d317c0b81a35a27c9Sebastian Redl Stmt *Ex; 258d457589fc69dc7a9c80cd74d317c0b81a35a27c9Sebastian Redl } Operand; 259c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl SourceRange Range; 260c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl 261c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redlpublic: 262c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl CXXTypeidExpr(bool isTypeOp, void *op, QualType Ty, const SourceRange r) : 2632850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl Expr(CXXTypeidExprClass, Ty, 2642850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl // typeid is never type-dependent (C++ [temp.dep.expr]p4) 2652850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl false, 2662850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl // typeid is value-dependent if the type or expression are dependent 2672850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl (isTypeOp ? QualType::getFromOpaquePtr(op)->isDependentType() 2682850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl : static_cast<Expr*>(op)->isValueDependent())), 2692850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl isTypeOp(isTypeOp), Range(r) { 270d457589fc69dc7a9c80cd74d317c0b81a35a27c9Sebastian Redl if (isTypeOp) 271d457589fc69dc7a9c80cd74d317c0b81a35a27c9Sebastian Redl Operand.Ty = op; 272d457589fc69dc7a9c80cd74d317c0b81a35a27c9Sebastian Redl else 273d457589fc69dc7a9c80cd74d317c0b81a35a27c9Sebastian Redl // op was an Expr*, so cast it back to that to be safe 2742850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl Operand.Ex = static_cast<Expr*>(op); 275d457589fc69dc7a9c80cd74d317c0b81a35a27c9Sebastian Redl } 276c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl 277c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl bool isTypeOperand() const { return isTypeOp; } 278c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl QualType getTypeOperand() const { 279c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl assert(isTypeOperand() && "Cannot call getTypeOperand for typeid(expr)"); 280d457589fc69dc7a9c80cd74d317c0b81a35a27c9Sebastian Redl return QualType::getFromOpaquePtr(Operand.Ty); 281c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl } 282c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl Expr* getExprOperand() const { 283c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl assert(!isTypeOperand() && "Cannot call getExprOperand for typeid(type)"); 284d457589fc69dc7a9c80cd74d317c0b81a35a27c9Sebastian Redl return static_cast<Expr*>(Operand.Ex); 285c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl } 286c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl 287c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl virtual SourceRange getSourceRange() const { 288c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl return Range; 289c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl } 290c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl static bool classof(const Stmt *T) { 291c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl return T->getStmtClass() == CXXTypeidExprClass; 292c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl } 293c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl static bool classof(const CXXTypeidExpr *) { return true; } 294c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl 295c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl // Iterators 296c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl virtual child_iterator child_begin(); 297c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl virtual child_iterator child_end(); 298c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl}; 299c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl 300796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// CXXThisExpr - Represents the "this" expression in C++, which is a 301796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// pointer to the object on which the current member function is 302796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// executing (C++ [expr.prim]p3). Example: 303796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// 304796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// @code 305796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// class Foo { 306796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// public: 307796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// void bar(); 308796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// void test() { this->bar(); } 309796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// }; 310796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// @endcode 311796da18402f286b897782a298ae3b20c459c102eDouglas Gregorclass CXXThisExpr : public Expr { 312796da18402f286b897782a298ae3b20c459c102eDouglas Gregor SourceLocation Loc; 313796da18402f286b897782a298ae3b20c459c102eDouglas Gregor 314796da18402f286b897782a298ae3b20c459c102eDouglas Gregorpublic: 315796da18402f286b897782a298ae3b20c459c102eDouglas Gregor CXXThisExpr(SourceLocation L, QualType Type) 3162850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl : Expr(CXXThisExprClass, Type, 3172850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl // 'this' is type-dependent if the class type of the enclosing 3182850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl // member function is dependent (C++ [temp.dep.expr]p2) 3192850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl Type->isDependentType(), Type->isDependentType()), 3202850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl Loc(L) { } 321796da18402f286b897782a298ae3b20c459c102eDouglas Gregor 322796da18402f286b897782a298ae3b20c459c102eDouglas Gregor virtual SourceRange getSourceRange() const { return SourceRange(Loc); } 323796da18402f286b897782a298ae3b20c459c102eDouglas Gregor 324796da18402f286b897782a298ae3b20c459c102eDouglas Gregor static bool classof(const Stmt *T) { 325796da18402f286b897782a298ae3b20c459c102eDouglas Gregor return T->getStmtClass() == CXXThisExprClass; 326796da18402f286b897782a298ae3b20c459c102eDouglas Gregor } 327796da18402f286b897782a298ae3b20c459c102eDouglas Gregor static bool classof(const CXXThisExpr *) { return true; } 328796da18402f286b897782a298ae3b20c459c102eDouglas Gregor 329796da18402f286b897782a298ae3b20c459c102eDouglas Gregor // Iterators 330796da18402f286b897782a298ae3b20c459c102eDouglas Gregor virtual child_iterator child_begin(); 331796da18402f286b897782a298ae3b20c459c102eDouglas Gregor virtual child_iterator child_end(); 332796da18402f286b897782a298ae3b20c459c102eDouglas Gregor}; 333796da18402f286b897782a298ae3b20c459c102eDouglas Gregor 3341060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek/// CXXThrowExpr - [C++ 15] C++ Throw Expression. This handles 3351060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek/// 'throw' and 'throw' assignment-expression. When 3361060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek/// assignment-expression isn't present, Op will be null. 3371060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek/// 3381060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenekclass CXXThrowExpr : public Expr { 3391060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek Stmt *Op; 3401060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek SourceLocation ThrowLoc; 3411060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenekpublic: 3421060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek // Ty is the void type which is used as the result type of the 3431060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek // exepression. The l is the location of the throw keyword. expr 3441060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek // can by null, if the optional expression to throw isn't present. 3451060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek CXXThrowExpr(Expr *expr, QualType Ty, SourceLocation l) : 3462850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl Expr(CXXThrowExprClass, Ty, false, false), Op(expr), ThrowLoc(l) {} 3471060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek const Expr *getSubExpr() const { return cast_or_null<Expr>(Op); } 3481060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek Expr *getSubExpr() { return cast_or_null<Expr>(Op); } 3491060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek 3501060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek virtual SourceRange getSourceRange() const { 3511060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek if (getSubExpr() == 0) 3521060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek return SourceRange(ThrowLoc, ThrowLoc); 3531060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek return SourceRange(ThrowLoc, getSubExpr()->getSourceRange().getEnd()); 3541060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek } 3551060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek 3561060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek static bool classof(const Stmt *T) { 3571060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek return T->getStmtClass() == CXXThrowExprClass; 3581060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek } 3591060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek static bool classof(const CXXThrowExpr *) { return true; } 3601060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek 3611060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek // Iterators 3621060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek virtual child_iterator child_begin(); 3631060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek virtual child_iterator child_end(); 3641060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek}; 3651060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek 3661060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek/// CXXDefaultArgExpr - C++ [dcl.fct.default]. This wraps up a 3671060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek/// function call argument that was created from the corresponding 3681060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek/// parameter's default argument, when the call did not explicitly 3691060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek/// supply arguments for all of the parameters. 3701060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenekclass CXXDefaultArgExpr : public Expr { 3711060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek ParmVarDecl *Param; 3721060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenekpublic: 3731060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek // Param is the parameter whose default argument is used by this 3741060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek // expression. 3751060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek explicit CXXDefaultArgExpr(ParmVarDecl *param) 37661366e9cd41a6dbde4e66416dac21269c8ac1d94Douglas Gregor : Expr(CXXDefaultArgExprClass, 37761366e9cd41a6dbde4e66416dac21269c8ac1d94Douglas Gregor param->hasUnparsedDefaultArg()? param->getType().getNonReferenceType() 37861366e9cd41a6dbde4e66416dac21269c8ac1d94Douglas Gregor : param->getDefaultArg()->getType()), 3791060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek Param(param) { } 3801060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek 3811060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek // Retrieve the parameter that the argument was created from. 3821060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek const ParmVarDecl *getParam() const { return Param; } 3831060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek ParmVarDecl *getParam() { return Param; } 3841060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek 3851060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek // Retrieve the actual argument to the function call. 3861060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek const Expr *getExpr() const { return Param->getDefaultArg(); } 3871060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek Expr *getExpr() { return Param->getDefaultArg(); } 3881060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek 3891060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek virtual SourceRange getSourceRange() const { 3901060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek // Default argument expressions have no representation in the 3911060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek // source, so they have an empty source range. 3921060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek return SourceRange(); 3931060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek } 3941060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek 3951060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek static bool classof(const Stmt *T) { 3961060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek return T->getStmtClass() == CXXDefaultArgExprClass; 3971060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek } 3981060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek static bool classof(const CXXDefaultArgExpr *) { return true; } 3991060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek 4001060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek // Iterators 4011060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek virtual child_iterator child_begin(); 4021060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek virtual child_iterator child_end(); 4031060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek}; 404987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis 40515ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson/// CXXConstructExpr - Represents a call to a C++ constructor. 40615ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlssonclass CXXConstructExpr : public Expr { 40715ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson VarDecl *VD; 40815ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson CXXConstructorDecl *Constructor; 40915ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson 41015ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson bool Elidable; 41115ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson 41215ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson Stmt **Args; 41315ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson unsigned NumArgs; 41415ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson 41515ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson 416bd6734e5f6432ce0cc07171c490ffaa094796198Anders Carlssonprotected: 417bd6734e5f6432ce0cc07171c490ffaa094796198Anders Carlsson CXXConstructExpr(ASTContext &C, StmtClass SC, VarDecl *vd, QualType T, 418bd6734e5f6432ce0cc07171c490ffaa094796198Anders Carlsson CXXConstructorDecl *d, bool elidable, 419bd6734e5f6432ce0cc07171c490ffaa094796198Anders Carlsson Expr **args, unsigned numargs); 420524fa13fd81e88533c7a1d4b1232c0de2c97dc7cAnders Carlsson ~CXXConstructExpr() { } 421bd6734e5f6432ce0cc07171c490ffaa094796198Anders Carlsson 42215ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlssonpublic: 42315ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson static CXXConstructExpr *Create(ASTContext &C, VarDecl *VD, QualType T, 42415ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson CXXConstructorDecl *D, bool Elidable, 42515ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson Expr **Args, unsigned NumArgs); 42615ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson 42715ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson void Destroy(ASTContext &C); 42815ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson 42915ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson const VarDecl* getVarDecl() const { return VD; } 43015ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson const CXXConstructorDecl* getConstructor() const { return Constructor; } 43115ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson 43215ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson typedef ExprIterator arg_iterator; 43315ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson typedef ConstExprIterator const_arg_iterator; 43415ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson 43515ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson arg_iterator arg_begin() { return Args; } 43615ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson arg_iterator arg_end() { return Args + NumArgs; } 43715ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson const_arg_iterator arg_begin() const { return Args; } 43815ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson const_arg_iterator arg_end() const { return Args + NumArgs; } 43915ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson 44015ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson unsigned getNumArgs() const { return NumArgs; } 44115ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson 44215ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson virtual SourceRange getSourceRange() const { return SourceRange(); } 44315ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson 44415ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson static bool classof(const Stmt *T) { 445524fa13fd81e88533c7a1d4b1232c0de2c97dc7cAnders Carlsson return T->getStmtClass() == CXXConstructExprClass || 446524fa13fd81e88533c7a1d4b1232c0de2c97dc7cAnders Carlsson T->getStmtClass() == CXXTemporaryObjectExprClass; 44715ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson } 44815ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson static bool classof(const CXXConstructExpr *) { return true; } 44915ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson 45015ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson // Iterators 45115ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson virtual child_iterator child_begin(); 45215ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson virtual child_iterator child_end(); 45315ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson}; 45415ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson 45549badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// CXXFunctionalCastExpr - Represents an explicit C++ type conversion 45649badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// that uses "functional" notion (C++ [expr.type.conv]). Example: @c 45749badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// x = int(0.5); 45849badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregorclass CXXFunctionalCastExpr : public ExplicitCastExpr { 459987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis SourceLocation TyBeginLoc; 460987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis SourceLocation RParenLoc; 461987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidispublic: 46249badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor CXXFunctionalCastExpr(QualType ty, QualType writtenTy, 46349badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor SourceLocation tyBeginLoc, Expr *castExpr, 464987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis SourceLocation rParenLoc) : 46549badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor ExplicitCastExpr(CXXFunctionalCastExprClass, ty, castExpr, writtenTy), 466987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis TyBeginLoc(tyBeginLoc), RParenLoc(rParenLoc) {} 467987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis 468987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis SourceLocation getTypeBeginLoc() const { return TyBeginLoc; } 469987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis SourceLocation getRParenLoc() const { return RParenLoc; } 470987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis 471987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis virtual SourceRange getSourceRange() const { 472987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis return SourceRange(TyBeginLoc, RParenLoc); 473987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis } 474987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis static bool classof(const Stmt *T) { 475987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis return T->getStmtClass() == CXXFunctionalCastExprClass; 476987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis } 477987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis static bool classof(const CXXFunctionalCastExpr *) { return true; } 478987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis}; 479987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis 480506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// @brief Represents a C++ functional cast expression that builds a 481506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// temporary object. 482506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// 483506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// This expression type represents a C++ "functional" cast 484506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// (C++[expr.type.conv]) with N != 1 arguments that invokes a 485506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// constructor to build a temporary object. If N == 0 but no 486506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// constructor will be called (because the functional cast is 487506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// performing a value-initialized an object whose class type has no 488506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// user-declared constructors), CXXZeroInitValueExpr will represent 489506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// the functional cast. Finally, with N == 1 arguments the functional 490506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// cast expression will be represented by CXXFunctionalCastExpr. 491506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// Example: 492506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// @code 493506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// struct X { X(int, float); } 494506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// 495506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// X create_X() { 496506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// return X(1, 3.14f); // creates a CXXTemporaryObjectExpr 497506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// }; 498506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// @endcode 499524fa13fd81e88533c7a1d4b1232c0de2c97dc7cAnders Carlssonclass CXXTemporaryObjectExpr : public CXXConstructExpr { 500506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor SourceLocation TyBeginLoc; 501506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor SourceLocation RParenLoc; 502506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor 503506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregorpublic: 50409c4abb1057f0eb53a9c2b5c2f22b1472362156eAnders Carlsson CXXTemporaryObjectExpr(ASTContext &C, VarDecl *vd, 50526de54983e7977fad615c94012f2f67d0d1cf404Anders Carlsson CXXConstructorDecl *Cons, QualType writtenTy, 506506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor SourceLocation tyBeginLoc, Expr **Args, 507506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor unsigned NumArgs, SourceLocation rParenLoc); 508506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor 509524fa13fd81e88533c7a1d4b1232c0de2c97dc7cAnders Carlsson ~CXXTemporaryObjectExpr() { } 510506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor 511506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor SourceLocation getTypeBeginLoc() const { return TyBeginLoc; } 512506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor SourceLocation getRParenLoc() const { return RParenLoc; } 513ba49817c5b9f502602672861cf369fd0e53966e8Douglas Gregor 514506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor virtual SourceRange getSourceRange() const { 515506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor return SourceRange(TyBeginLoc, RParenLoc); 516506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor } 517506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor static bool classof(const Stmt *T) { 518506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor return T->getStmtClass() == CXXTemporaryObjectExprClass; 519506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor } 520506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor static bool classof(const CXXTemporaryObjectExpr *) { return true; } 521506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor}; 522506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor 523987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis/// CXXZeroInitValueExpr - [C++ 5.2.3p2] 524506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// Expression "T()" which creates a value-initialized rvalue of type 525506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// T, which is either a non-class type or a class type without any 526506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// user-defined constructors. 527987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis/// 528987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidisclass CXXZeroInitValueExpr : public Expr { 529987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis SourceLocation TyBeginLoc; 530987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis SourceLocation RParenLoc; 531987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis 532987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidispublic: 533987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis CXXZeroInitValueExpr(QualType ty, SourceLocation tyBeginLoc, 534987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis SourceLocation rParenLoc ) : 535987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis Expr(CXXZeroInitValueExprClass, ty), 536987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis TyBeginLoc(tyBeginLoc), RParenLoc(rParenLoc) {} 537987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis 538987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis SourceLocation getTypeBeginLoc() const { return TyBeginLoc; } 539987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis SourceLocation getRParenLoc() const { return RParenLoc; } 540987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis 5414c67834407ca6ab344dcf44fc599ad4938cfa96dDouglas Gregor /// @brief Whether this initialization expression was 5424c67834407ca6ab344dcf44fc599ad4938cfa96dDouglas Gregor /// implicitly-generated. 5434c67834407ca6ab344dcf44fc599ad4938cfa96dDouglas Gregor bool isImplicit() const { 5444c67834407ca6ab344dcf44fc599ad4938cfa96dDouglas Gregor return TyBeginLoc.isInvalid() && RParenLoc.isInvalid(); 5454c67834407ca6ab344dcf44fc599ad4938cfa96dDouglas Gregor } 5464c67834407ca6ab344dcf44fc599ad4938cfa96dDouglas Gregor 547987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis virtual SourceRange getSourceRange() const { 548987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis return SourceRange(TyBeginLoc, RParenLoc); 549987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis } 550987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis 551987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis static bool classof(const Stmt *T) { 552987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis return T->getStmtClass() == CXXZeroInitValueExprClass; 553987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis } 554987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis static bool classof(const CXXZeroInitValueExpr *) { return true; } 555987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis 556987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis // Iterators 557987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis virtual child_iterator child_begin(); 558987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis virtual child_iterator child_end(); 559987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis}; 560987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis 5619e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis/// CXXConditionDeclExpr - Condition declaration of a if/switch/while/for 5629e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis/// statement, e.g: "if (int x = f()) {...}". 5639e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis/// The main difference with DeclRefExpr is that CXXConditionDeclExpr owns the 5649e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis/// decl that it references. 5659e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis/// 5669e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidisclass CXXConditionDeclExpr : public DeclRefExpr { 5679e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidispublic: 5689e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis CXXConditionDeclExpr(SourceLocation startLoc, 5699e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis SourceLocation eqLoc, VarDecl *var) 5709d293dfc0ad7c44ae0b5eb9517f1ed8c8d8b7ff7Douglas Gregor : DeclRefExpr(CXXConditionDeclExprClass, var, 5714a2e2041edc63db687677325e113b39b9d123c40Douglas Gregor var->getType().getNonReferenceType(), startLoc, 5724a2e2041edc63db687677325e113b39b9d123c40Douglas Gregor var->getType()->isDependentType(), 5734a2e2041edc63db687677325e113b39b9d123c40Douglas Gregor /*FIXME:integral constant?*/ 5744a2e2041edc63db687677325e113b39b9d123c40Douglas Gregor var->getType()->isDependentType()) {} 5759e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis 5769e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis virtual void Destroy(ASTContext& Ctx); 5779e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis 5789e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis SourceLocation getStartLoc() const { return getLocation(); } 5799e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis 5809e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis VarDecl *getVarDecl() { return cast<VarDecl>(getDecl()); } 5819e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis const VarDecl *getVarDecl() const { return cast<VarDecl>(getDecl()); } 5829e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis 5839e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis virtual SourceRange getSourceRange() const { 5849e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis return SourceRange(getStartLoc(), getVarDecl()->getInit()->getLocEnd()); 5859e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis } 5869e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis 5879e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis static bool classof(const Stmt *T) { 5889e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis return T->getStmtClass() == CXXConditionDeclExprClass; 5899e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis } 5909e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis static bool classof(const CXXConditionDeclExpr *) { return true; } 5919e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis 5929e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis // Iterators 5939e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis virtual child_iterator child_begin(); 5949e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis virtual child_iterator child_end(); 5959e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis}; 5969e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis 5974c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl/// CXXNewExpr - A new expression for memory allocation and constructor calls, 5984c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl/// e.g: "new CXXNewExpr(foo)". 5994c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redlclass CXXNewExpr : public Expr { 6004c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // Was the usage ::new, i.e. is the global new to be used? 6014c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl bool GlobalNew : 1; 6024c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // Was the form (type-id) used? Otherwise, it was new-type-id. 6034c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl bool ParenTypeId : 1; 6044c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // Is there an initializer? If not, built-ins are uninitialized, else they're 6054c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // value-initialized. 6064c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl bool Initializer : 1; 607cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl // Do we allocate an array? If so, the first SubExpr is the size expression. 608cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl bool Array : 1; 6094c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // The number of placement new arguments. 6104c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl unsigned NumPlacementArgs : 14; 6114c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // The number of constructor arguments. This may be 1 even for non-class 6124c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // types; use the pseudo copy constructor. 613cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl unsigned NumConstructorArgs : 14; 614cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl // Contains an optional array size expression, any number of optional 615cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl // placement arguments, and any number of optional constructor arguments, 616cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl // in that order. 6174c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl Stmt **SubExprs; 6184c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // Points to the allocation function used. 6194c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl FunctionDecl *OperatorNew; 6204c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // Points to the deallocation function used in case of error. May be null. 6214c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl FunctionDecl *OperatorDelete; 6224c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // Points to the constructor used. Cannot be null if AllocType is a record; 6234c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // it would still point at the default constructor (even an implicit one). 6244c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // Must be null for all other types. 6254c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl CXXConstructorDecl *Constructor; 6264c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 6274c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl SourceLocation StartLoc; 6284c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl SourceLocation EndLoc; 6294c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 6304c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redlpublic: 6314c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl CXXNewExpr(bool globalNew, FunctionDecl *operatorNew, Expr **placementArgs, 632cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl unsigned numPlaceArgs, bool ParenTypeId, Expr *arraySize, 6334c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl CXXConstructorDecl *constructor, bool initializer, 6344c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl Expr **constructorArgs, unsigned numConsArgs, 6354c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl FunctionDecl *operatorDelete, QualType ty, 6364c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl SourceLocation startLoc, SourceLocation endLoc); 6374c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl ~CXXNewExpr() { 6384c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl delete[] SubExprs; 6394c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 6404c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 641cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl QualType getAllocatedType() const { 642cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl assert(getType()->isPointerType()); 643cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl return getType()->getAsPointerType()->getPointeeType(); 644cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl } 6454c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 6464c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl FunctionDecl *getOperatorNew() const { return OperatorNew; } 6474c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl FunctionDecl *getOperatorDelete() const { return OperatorDelete; } 6484c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl CXXConstructorDecl *getConstructor() const { return Constructor; } 6494c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 650cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl bool isArray() const { return Array; } 651cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl Expr *getArraySize() { 652cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl return Array ? cast<Expr>(SubExprs[0]) : 0; 653cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl } 654cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl const Expr *getArraySize() const { 655cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl return Array ? cast<Expr>(SubExprs[0]) : 0; 656cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl } 657cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl 6584c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl unsigned getNumPlacementArgs() const { return NumPlacementArgs; } 6594c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl Expr *getPlacementArg(unsigned i) { 6604c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl assert(i < NumPlacementArgs && "Index out of range"); 661cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl return cast<Expr>(SubExprs[Array + i]); 6624c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 6634c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl const Expr *getPlacementArg(unsigned i) const { 6644c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl assert(i < NumPlacementArgs && "Index out of range"); 665cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl return cast<Expr>(SubExprs[Array + i]); 6664c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 6674c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 6684c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl bool isGlobalNew() const { return GlobalNew; } 6694c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl bool isParenTypeId() const { return ParenTypeId; } 6704c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl bool hasInitializer() const { return Initializer; } 6714c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 6724c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl unsigned getNumConstructorArgs() const { return NumConstructorArgs; } 6734c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl Expr *getConstructorArg(unsigned i) { 6744c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl assert(i < NumConstructorArgs && "Index out of range"); 675cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl return cast<Expr>(SubExprs[Array + NumPlacementArgs + i]); 6764c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 6774c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl const Expr *getConstructorArg(unsigned i) const { 6784c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl assert(i < NumConstructorArgs && "Index out of range"); 679cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl return cast<Expr>(SubExprs[Array + NumPlacementArgs + i]); 6804c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 6814c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 6824c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl typedef ExprIterator arg_iterator; 6834c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl typedef ConstExprIterator const_arg_iterator; 6844c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 6854c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl arg_iterator placement_arg_begin() { 686cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl return SubExprs + Array; 6874c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 6884c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl arg_iterator placement_arg_end() { 689cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl return SubExprs + Array + getNumPlacementArgs(); 6904c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 6914c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl const_arg_iterator placement_arg_begin() const { 692cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl return SubExprs + Array; 6934c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 6944c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl const_arg_iterator placement_arg_end() const { 695cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl return SubExprs + Array + getNumPlacementArgs(); 6964c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 6974c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 6984c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl arg_iterator constructor_arg_begin() { 699cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl return SubExprs + Array + getNumPlacementArgs(); 7004c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 7014c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl arg_iterator constructor_arg_end() { 702cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl return SubExprs + Array + getNumPlacementArgs() + getNumConstructorArgs(); 7034c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 7044c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl const_arg_iterator constructor_arg_begin() const { 705cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl return SubExprs + Array + getNumPlacementArgs(); 7064c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 7074c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl const_arg_iterator constructor_arg_end() const { 708cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl return SubExprs + Array + getNumPlacementArgs() + getNumConstructorArgs(); 7094c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 7104c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 7114c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl virtual SourceRange getSourceRange() const { 7124c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl return SourceRange(StartLoc, EndLoc); 7134c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 7144c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 7154c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl static bool classof(const Stmt *T) { 7164c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl return T->getStmtClass() == CXXNewExprClass; 7174c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 7184c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl static bool classof(const CXXNewExpr *) { return true; } 7194c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 7204c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // Iterators 7214c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl virtual child_iterator child_begin(); 7224c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl virtual child_iterator child_end(); 7234c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl}; 7244c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 7254c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl/// CXXDeleteExpr - A delete expression for memory deallocation and destructor 7264c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl/// calls, e.g. "delete[] pArray". 7274c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redlclass CXXDeleteExpr : public Expr { 7284c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // Is this a forced global delete, i.e. "::delete"? 7294c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl bool GlobalDelete : 1; 7304c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // Is this the array form of delete, i.e. "delete[]"? 7314c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl bool ArrayForm : 1; 7324c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // Points to the operator delete overload that is used. Could be a member. 7334c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl FunctionDecl *OperatorDelete; 7344c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // The pointer expression to be deleted. 7354c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl Stmt *Argument; 7364c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // Location of the expression. 7374c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl SourceLocation Loc; 7384c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redlpublic: 7394c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl CXXDeleteExpr(QualType ty, bool globalDelete, bool arrayForm, 7404c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl FunctionDecl *operatorDelete, Expr *arg, SourceLocation loc) 7412850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl : Expr(CXXDeleteExprClass, ty, false, false), GlobalDelete(globalDelete), 7424c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl ArrayForm(arrayForm), OperatorDelete(operatorDelete), Argument(arg), 7434c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl Loc(loc) { } 7444c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 7454c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl bool isGlobalDelete() const { return GlobalDelete; } 7464c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl bool isArrayForm() const { return ArrayForm; } 7474c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 7484c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl FunctionDecl *getOperatorDelete() const { return OperatorDelete; } 7494c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 7504c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl Expr *getArgument() { return cast<Expr>(Argument); } 7514c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl const Expr *getArgument() const { return cast<Expr>(Argument); } 7524c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 7534c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl virtual SourceRange getSourceRange() const { 7544c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl return SourceRange(Loc, Argument->getLocEnd()); 7554c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 7564c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 7574c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl static bool classof(const Stmt *T) { 7584c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl return T->getStmtClass() == CXXDeleteExprClass; 7594c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 7604c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl static bool classof(const CXXDeleteExpr *) { return true; } 7614c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 7624c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // Iterators 7634c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl virtual child_iterator child_begin(); 7644c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl virtual child_iterator child_end(); 7654c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl}; 7664c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 76717330019f05966762bc952840ef1926b9becb145Douglas Gregor/// \brief Represents the name of a function that has not been 76817330019f05966762bc952840ef1926b9becb145Douglas Gregor/// resolved to any declaration. 76917330019f05966762bc952840ef1926b9becb145Douglas Gregor/// 77017330019f05966762bc952840ef1926b9becb145Douglas Gregor/// Unresolved function names occur when a function name is 77117330019f05966762bc952840ef1926b9becb145Douglas Gregor/// encountered prior to an open parentheses ('(') in a C++ function 77217330019f05966762bc952840ef1926b9becb145Douglas Gregor/// call, and the function name itself did not resolve to a 77317330019f05966762bc952840ef1926b9becb145Douglas Gregor/// declaration. These function names can only be resolved when they 77417330019f05966762bc952840ef1926b9becb145Douglas Gregor/// form the postfix-expression of a function call, so that 77517330019f05966762bc952840ef1926b9becb145Douglas Gregor/// argument-dependent lookup finds declarations corresponding to 77617330019f05966762bc952840ef1926b9becb145Douglas Gregor/// these functions. 77717330019f05966762bc952840ef1926b9becb145Douglas Gregor 7785c37de788529cd9180f22069970737a7208bd625Douglas Gregor/// @code 7795c37de788529cd9180f22069970737a7208bd625Douglas Gregor/// template<typename T> void f(T x) { 78017330019f05966762bc952840ef1926b9becb145Douglas Gregor/// g(x); // g is an unresolved function name (that is also a dependent name) 7815c37de788529cd9180f22069970737a7208bd625Douglas Gregor/// } 7825c37de788529cd9180f22069970737a7208bd625Douglas Gregor/// @endcode 78317330019f05966762bc952840ef1926b9becb145Douglas Gregorclass UnresolvedFunctionNameExpr : public Expr { 78417330019f05966762bc952840ef1926b9becb145Douglas Gregor /// The name that was present in the source 78517330019f05966762bc952840ef1926b9becb145Douglas Gregor DeclarationName Name; 7865c37de788529cd9180f22069970737a7208bd625Douglas Gregor 78717330019f05966762bc952840ef1926b9becb145Douglas Gregor /// The location of this name in the source code 7885c37de788529cd9180f22069970737a7208bd625Douglas Gregor SourceLocation Loc; 7895c37de788529cd9180f22069970737a7208bd625Douglas Gregor 7905c37de788529cd9180f22069970737a7208bd625Douglas Gregorpublic: 79117330019f05966762bc952840ef1926b9becb145Douglas Gregor UnresolvedFunctionNameExpr(DeclarationName N, QualType T, SourceLocation L) 79217330019f05966762bc952840ef1926b9becb145Douglas Gregor : Expr(UnresolvedFunctionNameExprClass, T, false, false), Name(N), Loc(L) { } 7935c37de788529cd9180f22069970737a7208bd625Douglas Gregor 79417330019f05966762bc952840ef1926b9becb145Douglas Gregor /// \brief Retrieves the name that occurred in the source code. 79517330019f05966762bc952840ef1926b9becb145Douglas Gregor DeclarationName getName() const { return Name; } 7965c37de788529cd9180f22069970737a7208bd625Douglas Gregor 7975c37de788529cd9180f22069970737a7208bd625Douglas Gregor /// getLocation - Retrieves the location in the source code where 7985c37de788529cd9180f22069970737a7208bd625Douglas Gregor /// the name occurred. 7995c37de788529cd9180f22069970737a7208bd625Douglas Gregor SourceLocation getLocation() const { return Loc; } 8005c37de788529cd9180f22069970737a7208bd625Douglas Gregor 8015c37de788529cd9180f22069970737a7208bd625Douglas Gregor virtual SourceRange getSourceRange() const { return SourceRange(Loc); } 8025c37de788529cd9180f22069970737a7208bd625Douglas Gregor 8034a2487aeacf9f35ce553318c2eb39c20ec23845eDouglas Gregor UnresolvedFunctionNameExpr* Clone(ASTContext &C) const; 8044a2487aeacf9f35ce553318c2eb39c20ec23845eDouglas Gregor 8055c37de788529cd9180f22069970737a7208bd625Douglas Gregor static bool classof(const Stmt *T) { 80617330019f05966762bc952840ef1926b9becb145Douglas Gregor return T->getStmtClass() == UnresolvedFunctionNameExprClass; 8075c37de788529cd9180f22069970737a7208bd625Douglas Gregor } 80817330019f05966762bc952840ef1926b9becb145Douglas Gregor static bool classof(const UnresolvedFunctionNameExpr *) { return true; } 8095c37de788529cd9180f22069970737a7208bd625Douglas Gregor 8105c37de788529cd9180f22069970737a7208bd625Douglas Gregor // Iterators 8115c37de788529cd9180f22069970737a7208bd625Douglas Gregor virtual child_iterator child_begin(); 8125c37de788529cd9180f22069970737a7208bd625Douglas Gregor virtual child_iterator child_end(); 8135c37de788529cd9180f22069970737a7208bd625Douglas Gregor}; 8145c37de788529cd9180f22069970737a7208bd625Douglas Gregor 81564b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl/// UnaryTypeTraitExpr - A GCC or MS unary type trait, as used in the 81664b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl/// implementation of TR1/C++0x type trait templates. 81764b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl/// Example: 81864b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl/// __is_pod(int) == true 81964b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl/// __is_enum(std::string) == false 82064b45f7e0d3167f040841ac2920aead7f080730dSebastian Redlclass UnaryTypeTraitExpr : public Expr { 82164b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl /// UTT - The trait. 82264b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl UnaryTypeTrait UTT; 82364b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl 82464b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl /// Loc - The location of the type trait keyword. 82564b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl SourceLocation Loc; 82664b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl 82764b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl /// RParen - The location of the closing paren. 82864b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl SourceLocation RParen; 82964b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl 83064b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl /// QueriedType - The type we're testing. 83164b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl QualType QueriedType; 83264b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl 83364b45f7e0d3167f040841ac2920aead7f080730dSebastian Redlpublic: 83464b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl UnaryTypeTraitExpr(SourceLocation loc, UnaryTypeTrait utt, QualType queried, 83564b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl SourceLocation rparen, QualType ty) 83664b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl : Expr(UnaryTypeTraitExprClass, ty, false, queried->isDependentType()), 83764b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl UTT(utt), Loc(loc), RParen(rparen), QueriedType(queried) { } 83864b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl 83964b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl virtual SourceRange getSourceRange() const { return SourceRange(Loc, RParen);} 84064b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl 84164b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl UnaryTypeTrait getTrait() const { return UTT; } 84264b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl 84364b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl QualType getQueriedType() const { return QueriedType; } 84464b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl 845c87a282e7b80c055088fc51bdbe8fc73da64d4f8Daniel Dunbar bool EvaluateTrait() const; 84664b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl 84764b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl static bool classof(const Stmt *T) { 84864b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl return T->getStmtClass() == UnaryTypeTraitExprClass; 84964b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl } 85064b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl static bool classof(const UnaryTypeTraitExpr *) { return true; } 85164b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl 85264b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl // Iterators 85364b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl virtual child_iterator child_begin(); 85464b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl virtual child_iterator child_end(); 85564b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl}; 85664b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl 8571a49af9681c350fef58e677f85ccb9a77e8e9d0aDouglas Gregor/// QualifiedDeclRefExpr - A reference to a declared variable, 8581a49af9681c350fef58e677f85ccb9a77e8e9d0aDouglas Gregor/// function, enum, etc., that includes a qualification, e.g., 8591a49af9681c350fef58e677f85ccb9a77e8e9d0aDouglas Gregor/// "N::foo". 8601a49af9681c350fef58e677f85ccb9a77e8e9d0aDouglas Gregorclass QualifiedDeclRefExpr : public DeclRefExpr { 861bad351822117eaf280081494e3dbe4a06c0dbfcfDouglas Gregor /// QualifierRange - The source range that covers the 862bad351822117eaf280081494e3dbe4a06c0dbfcfDouglas Gregor /// nested-name-specifier. 863bad351822117eaf280081494e3dbe4a06c0dbfcfDouglas Gregor SourceRange QualifierRange; 864bad351822117eaf280081494e3dbe4a06c0dbfcfDouglas Gregor 865ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor /// \brief The nested-name-specifier that qualifies this declaration 866ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor /// name. 867ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor NestedNameSpecifier *NNS; 868bad351822117eaf280081494e3dbe4a06c0dbfcfDouglas Gregor 869bad351822117eaf280081494e3dbe4a06c0dbfcfDouglas Gregorpublic: 870ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor QualifiedDeclRefExpr(NamedDecl *d, QualType t, SourceLocation l, bool TD, 871ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor bool VD, SourceRange R, NestedNameSpecifier *NNS) 872ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor : DeclRefExpr(QualifiedDeclRefExprClass, d, t, l, TD, VD), 873ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor QualifierRange(R), NNS(NNS) { } 874bad351822117eaf280081494e3dbe4a06c0dbfcfDouglas Gregor 875bad351822117eaf280081494e3dbe4a06c0dbfcfDouglas Gregor /// \brief Retrieve the source range of the nested-name-specifier. 876bad351822117eaf280081494e3dbe4a06c0dbfcfDouglas Gregor SourceRange getQualifierRange() const { return QualifierRange; } 877bad351822117eaf280081494e3dbe4a06c0dbfcfDouglas Gregor 878ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor /// \brief Retrieve the nested-name-specifier that qualifies this 879ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor /// declaration. 880ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor NestedNameSpecifier *getQualifier() const { return NNS; } 8811a49af9681c350fef58e677f85ccb9a77e8e9d0aDouglas Gregor 8821a49af9681c350fef58e677f85ccb9a77e8e9d0aDouglas Gregor virtual SourceRange getSourceRange() const { 883bad351822117eaf280081494e3dbe4a06c0dbfcfDouglas Gregor return SourceRange(QualifierRange.getBegin(), getLocation()); 8841a49af9681c350fef58e677f85ccb9a77e8e9d0aDouglas Gregor } 8851a49af9681c350fef58e677f85ccb9a77e8e9d0aDouglas Gregor 8861a49af9681c350fef58e677f85ccb9a77e8e9d0aDouglas Gregor static bool classof(const Stmt *T) { 8871a49af9681c350fef58e677f85ccb9a77e8e9d0aDouglas Gregor return T->getStmtClass() == QualifiedDeclRefExprClass; 8881a49af9681c350fef58e677f85ccb9a77e8e9d0aDouglas Gregor } 8891a49af9681c350fef58e677f85ccb9a77e8e9d0aDouglas Gregor static bool classof(const QualifiedDeclRefExpr *) { return true; } 8901a49af9681c350fef58e677f85ccb9a77e8e9d0aDouglas Gregor}; 8911a49af9681c350fef58e677f85ccb9a77e8e9d0aDouglas Gregor 8925953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor/// \brief A qualified reference to a name whose declaration cannot 8935953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor/// yet be resolved. 8945953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor/// 8955953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor/// UnresolvedDeclRefExpr is similar to QualifiedDeclRefExpr in that 8965953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor/// it expresses a qualified reference to a declaration such as 8975953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor/// X<T>::value. The difference, however, is that an 8985953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor/// UnresolvedDeclRefExpr node is used only within C++ templates when 8995953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor/// the qualification (e.g., X<T>::) refers to a dependent type. In 9005953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor/// this case, X<T>::value cannot resolve to a declaration because the 9015953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor/// declaration will differ from on instantiation of X<T> to the 902ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor/// next. Therefore, UnresolvedDeclRefExpr keeps track of the 903ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor/// qualifier (X<T>::) and the name of the entity being referenced 904ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor/// ("value"). Such expressions will instantiate to 905ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor/// QualifiedDeclRefExprs. 9065953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregorclass UnresolvedDeclRefExpr : public Expr { 9075953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor /// The name of the entity we will be referencing. 9085953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor DeclarationName Name; 9095953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor 9105953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor /// Location of the name of the declaration we're referencing. 9115953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor SourceLocation Loc; 9125953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor 9135953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor /// QualifierRange - The source range that covers the 9145953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor /// nested-name-specifier. 9155953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor SourceRange QualifierRange; 9165953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor 917ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor /// \brief The nested-name-specifier that qualifies this unresolved 918ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor /// declaration name. 919ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor NestedNameSpecifier *NNS; 9205953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor 9215953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregorpublic: 922ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor UnresolvedDeclRefExpr(DeclarationName N, QualType T, SourceLocation L, 923ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor SourceRange R, NestedNameSpecifier *NNS) 924ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor : Expr(UnresolvedDeclRefExprClass, T, true, true), 925ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor Name(N), Loc(L), QualifierRange(R), NNS(NNS) { } 9265953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor 9275953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor /// \brief Retrieve the name that this expression refers to. 9285953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor DeclarationName getDeclName() const { return Name; } 9295953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor 9305953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor /// \brief Retrieve the location of the name within the expression. 9315953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor SourceLocation getLocation() const { return Loc; } 9325953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor 9335953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor /// \brief Retrieve the source range of the nested-name-specifier. 9345953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor SourceRange getQualifierRange() const { return QualifierRange; } 9355953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor 936ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor /// \brief Retrieve the nested-name-specifier that qualifies this 937ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor /// declaration. 938ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor NestedNameSpecifier *getQualifier() const { return NNS; } 9395953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor 9405953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor virtual SourceRange getSourceRange() const { 9415953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor return SourceRange(QualifierRange.getBegin(), getLocation()); 9425953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor } 9435953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor 9445953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor static bool classof(const Stmt *T) { 9455953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor return T->getStmtClass() == UnresolvedDeclRefExprClass; 9465953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor } 9475953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor static bool classof(const UnresolvedDeclRefExpr *) { return true; } 9485953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor 9495953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor virtual StmtIterator child_begin(); 9505953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor virtual StmtIterator child_end(); 9515953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor}; 9525953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor 9532d44e8a41de8a33c0f04ac198714f71dc841bab0Anders Carlssonclass CXXExprWithTemporaries : public Expr { 95402bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson Stmt *SubExpr; 95502bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson 95602bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson CXXTempVarDecl **Decls; 95702bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson unsigned NumDecls; 95802bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson 95902bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlssonpublic: 9602d44e8a41de8a33c0f04ac198714f71dc841bab0Anders Carlsson CXXExprWithTemporaries(Expr *subexpr, CXXTempVarDecl **decls, 9612d44e8a41de8a33c0f04ac198714f71dc841bab0Anders Carlsson unsigned numdecls); 9622d44e8a41de8a33c0f04ac198714f71dc841bab0Anders Carlsson ~CXXExprWithTemporaries(); 96302bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson 96402bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson const Expr *getSubExpr() const { return cast<Expr>(SubExpr); } 96502bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson Expr *getSubExpr() { return cast<Expr>(SubExpr); } 96602bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson 96702bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson virtual SourceRange getSourceRange() const { return SourceRange(); } 96802bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson 96902bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson // Implement isa/cast/dyncast/etc. 97002bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson static bool classof(const Stmt *T) { 9712d44e8a41de8a33c0f04ac198714f71dc841bab0Anders Carlsson return T->getStmtClass() == CXXExprWithTemporariesClass; 97202bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson } 9732d44e8a41de8a33c0f04ac198714f71dc841bab0Anders Carlsson static bool classof(const CXXExprWithTemporaries *) { return true; } 97402bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson 97502bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson // Iterators 97602bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson virtual child_iterator child_begin(); 97702bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson virtual child_iterator child_end(); 97802bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson}; 97902bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson 9805f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer} // end namespace clang 9815f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 9825f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer#endif 983