ExprCXX.h revision 3fd95ce225393fe4a3623e429766a8c3f487ff9d
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 { 43b4609806e9232593ece09ce08b630836e825865cDouglas Gregorpublic: 44668bf91d31265b6ea8c3eb854ba450857701f269Ted Kremenek CXXOperatorCallExpr(ASTContext& C, Expr *fn, Expr **args, unsigned numargs, 45668bf91d31265b6ea8c3eb854ba450857701f269Ted Kremenek QualType t, SourceLocation operatorloc) 46668bf91d31265b6ea8c3eb854ba450857701f269Ted Kremenek : CallExpr(C, CXXOperatorCallExprClass, fn, args, numargs, t, operatorloc){} 47b4609806e9232593ece09ce08b630836e825865cDouglas Gregor 48b4609806e9232593ece09ce08b630836e825865cDouglas Gregor /// getOperator - Returns the kind of overloaded operator that this 49b4609806e9232593ece09ce08b630836e825865cDouglas Gregor /// expression refers to. 50b4609806e9232593ece09ce08b630836e825865cDouglas Gregor OverloadedOperatorKind getOperator() const; 51b4609806e9232593ece09ce08b630836e825865cDouglas Gregor 52b4609806e9232593ece09ce08b630836e825865cDouglas Gregor /// getOperatorLoc - Returns the location of the operator symbol in 53b4609806e9232593ece09ce08b630836e825865cDouglas Gregor /// the expression. When @c getOperator()==OO_Call, this is the 54b4609806e9232593ece09ce08b630836e825865cDouglas Gregor /// location of the right parentheses; when @c 55b4609806e9232593ece09ce08b630836e825865cDouglas Gregor /// getOperator()==OO_Subscript, this is the location of the right 56b4609806e9232593ece09ce08b630836e825865cDouglas Gregor /// bracket. 57b4609806e9232593ece09ce08b630836e825865cDouglas Gregor SourceLocation getOperatorLoc() const { return getRParenLoc(); } 58b4609806e9232593ece09ce08b630836e825865cDouglas Gregor 59b4609806e9232593ece09ce08b630836e825865cDouglas Gregor virtual SourceRange getSourceRange() const; 60b4609806e9232593ece09ce08b630836e825865cDouglas Gregor 61b4609806e9232593ece09ce08b630836e825865cDouglas Gregor static bool classof(const Stmt *T) { 62b4609806e9232593ece09ce08b630836e825865cDouglas Gregor return T->getStmtClass() == CXXOperatorCallExprClass; 63b4609806e9232593ece09ce08b630836e825865cDouglas Gregor } 64b4609806e9232593ece09ce08b630836e825865cDouglas Gregor static bool classof(const CXXOperatorCallExpr *) { return true; } 65b4609806e9232593ece09ce08b630836e825865cDouglas Gregor}; 66b4609806e9232593ece09ce08b630836e825865cDouglas Gregor 6788a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor/// CXXMemberCallExpr - Represents a call to a member function that 6888a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor/// may be written either with member call syntax (e.g., "obj.func()" 6988a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor/// or "objptr->func()") or with normal function-call syntax 7088a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor/// ("func()") within a member function that ends up calling a member 7188a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor/// function. The callee in either case is a MemberExpr that contains 7288a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor/// both the object argument and the member function, while the 7388a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor/// arguments are the arguments within the parentheses (not including 7488a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor/// the object argument). 7588a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregorclass CXXMemberCallExpr : public CallExpr { 7688a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregorpublic: 77668bf91d31265b6ea8c3eb854ba450857701f269Ted Kremenek CXXMemberCallExpr(ASTContext& C, Expr *fn, Expr **args, unsigned numargs, 78668bf91d31265b6ea8c3eb854ba450857701f269Ted Kremenek QualType t, SourceLocation rparenloc) 79668bf91d31265b6ea8c3eb854ba450857701f269Ted Kremenek : CallExpr(C, CXXMemberCallExprClass, fn, args, numargs, t, rparenloc) {} 8088a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor 8188a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor /// getImplicitObjectArgument - Retrieves the implicit object 8288a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor /// argument for the member call. For example, in "x.f(5)", this 8388a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor /// operation would return "x". 8488a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor Expr *getImplicitObjectArgument(); 8588a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor 8688a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor static bool classof(const Stmt *T) { 8788a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor return T->getStmtClass() == CXXMemberCallExprClass; 8888a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor } 8988a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor static bool classof(const CXXMemberCallExpr *) { return true; } 9088a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor}; 9188a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor 9249badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// CXXNamedCastExpr - Abstract class common to all of the C++ "named" 9349badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// casts, @c static_cast, @c dynamic_cast, @c reinterpret_cast, or @c 9449badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// const_cast. 9549badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// 9649badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// This abstract class is inherited by all of the classes 9749badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// representing "named" casts, e.g., CXXStaticCastExpr, 9849badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// CXXDynamicCastExpr, CXXReinterpretCastExpr, and CXXConstCastExpr. 9949badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregorclass CXXNamedCastExpr : public ExplicitCastExpr { 1001060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenekprivate: 1011060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek SourceLocation Loc; // the location of the casting op 10249badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor 10349badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregorprotected: 10449badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor CXXNamedCastExpr(StmtClass SC, QualType ty, Expr *op, QualType writtenTy, 10549badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor SourceLocation l) 10649badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor : ExplicitCastExpr(SC, ty, op, writtenTy), Loc(l) {} 10749badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor 1081060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenekpublic: 10949badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor const char *getCastName() const; 11049badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor 1111060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek virtual SourceRange getSourceRange() const { 1121060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek return SourceRange(Loc, getSubExpr()->getSourceRange().getEnd()); 1131060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek } 1141060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek static bool classof(const Stmt *T) { 11549badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor switch (T->getStmtClass()) { 11649badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor case CXXNamedCastExprClass: 11749badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor case CXXStaticCastExprClass: 11849badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor case CXXDynamicCastExprClass: 11949badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor case CXXReinterpretCastExprClass: 12049badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor case CXXConstCastExprClass: 12149badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor return true; 12249badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor default: 12349badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor return false; 12449badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor } 1251060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek } 12649badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor static bool classof(const CXXNamedCastExpr *) { return true; } 1271060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek 12849badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor virtual void EmitImpl(llvm::Serializer& S) const; 12949badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor static CXXNamedCastExpr *CreateImpl(llvm::Deserializer& D, ASTContext& C, 13049badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor StmtClass SC); 13149badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor}; 13249badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor 13349badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// CXXStaticCastExpr - A C++ @c static_cast expression (C++ [expr.static.cast]). 13449badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// 13549badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// This expression node represents a C++ static cast, e.g., 13649badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// @c static_cast<int>(1.0). 13749badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregorclass CXXStaticCastExpr : public CXXNamedCastExpr { 13849badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregorpublic: 13949badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor CXXStaticCastExpr(QualType ty, Expr *op, QualType writtenTy, SourceLocation l) 14049badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor : CXXNamedCastExpr(CXXStaticCastExprClass, ty, op, writtenTy, l) {} 14149badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor 14249badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor static bool classof(const Stmt *T) { 14349badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor return T->getStmtClass() == CXXStaticCastExprClass; 14449badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor } 14549badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor static bool classof(const CXXStaticCastExpr *) { return true; } 14649badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor}; 14749badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor 14849badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// CXXDynamicCastExpr - A C++ @c dynamic_cast expression 14949badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// (C++ [expr.dynamic.cast]), which may perform a run-time check to 15049badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// determine how to perform the type cast. 15149badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// 15249badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// This expression node represents a dynamic cast, e.g., 15349badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// @c dynamic_cast<Derived*>(BasePtr). 15449badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregorclass CXXDynamicCastExpr : public CXXNamedCastExpr { 15549badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregorpublic: 15649badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor CXXDynamicCastExpr(QualType ty, Expr *op, QualType writtenTy, SourceLocation l) 15749badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor : CXXNamedCastExpr(CXXDynamicCastExprClass, ty, op, writtenTy, l) {} 15849badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor 15949badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor static bool classof(const Stmt *T) { 16049badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor return T->getStmtClass() == CXXDynamicCastExprClass; 16149badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor } 16249badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor static bool classof(const CXXDynamicCastExpr *) { return true; } 16349badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor}; 16449badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor 16549badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// CXXReinterpretCastExpr - A C++ @c reinterpret_cast expression (C++ 16649badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// [expr.reinterpret.cast]), which provides a differently-typed view 16749badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// of a value but performs no actual work at run time. 16849badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// 16949badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// This expression node represents a reinterpret cast, e.g., 17049badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// @c reinterpret_cast<int>(VoidPtr). 17149badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregorclass CXXReinterpretCastExpr : public CXXNamedCastExpr { 17249badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregorpublic: 17349badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor CXXReinterpretCastExpr(QualType ty, Expr *op, QualType writtenTy, 17449badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor SourceLocation l) 17549badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor : CXXNamedCastExpr(CXXReinterpretCastExprClass, ty, op, writtenTy, l) {} 17649badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor 17749badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor static bool classof(const Stmt *T) { 17849badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor return T->getStmtClass() == CXXReinterpretCastExprClass; 17949badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor } 18049badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor static bool classof(const CXXReinterpretCastExpr *) { return true; } 18149badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor}; 18249badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor 18349badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// CXXConstCastExpr - A C++ @c const_cast expression (C++ [expr.const.cast]), 18449badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// which can remove type qualifiers but does not change the underlying value. 18549badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// 18649badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// This expression node represents a const cast, e.g., 18749badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// @c const_cast<char*>(PtrToConstChar). 18849badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregorclass CXXConstCastExpr : public CXXNamedCastExpr { 18949badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregorpublic: 19049badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor CXXConstCastExpr(QualType ty, Expr *op, QualType writtenTy, 19149badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor SourceLocation l) 19249badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor : CXXNamedCastExpr(CXXConstCastExprClass, ty, op, writtenTy, l) {} 19349badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor 19449badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor static bool classof(const Stmt *T) { 19549badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor return T->getStmtClass() == CXXConstCastExprClass; 19649badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor } 19749badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor static bool classof(const CXXConstCastExpr *) { return true; } 1981060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek}; 1991060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek 2001060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek/// CXXBoolLiteralExpr - [C++ 2.13.5] C++ Boolean Literal. 2011060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek/// 2021060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenekclass CXXBoolLiteralExpr : public Expr { 2031060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek bool Value; 2041060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek SourceLocation Loc; 2051060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenekpublic: 2061060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek CXXBoolLiteralExpr(bool val, QualType Ty, SourceLocation l) : 2071060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek Expr(CXXBoolLiteralExprClass, Ty), Value(val), Loc(l) {} 2081060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek 2091060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek bool getValue() const { return Value; } 2105f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 2111060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek virtual SourceRange getSourceRange() const { return SourceRange(Loc); } 2125f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 2131060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek static bool classof(const Stmt *T) { 2141060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek return T->getStmtClass() == CXXBoolLiteralExprClass; 2151060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek } 2161060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek static bool classof(const CXXBoolLiteralExpr *) { return true; } 2175f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 2181060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek // Iterators 2191060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek virtual child_iterator child_begin(); 2201060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek virtual child_iterator child_end(); 2211060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek}; 2221060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek 223c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl/// CXXTypeidExpr - A C++ @c typeid expression (C++ [expr.typeid]), which gets 224c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl/// the type_info that corresponds to the supplied type, or the (possibly 225c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl/// dynamic) type of the supplied expression. 226c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl/// 227c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl/// This represents code like @c typeid(int) or @c typeid(*objPtr) 228c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redlclass CXXTypeidExpr : public Expr { 229c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redlprivate: 230c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl bool isTypeOp : 1; 231d457589fc69dc7a9c80cd74d317c0b81a35a27c9Sebastian Redl union { 232d457589fc69dc7a9c80cd74d317c0b81a35a27c9Sebastian Redl void *Ty; 233d457589fc69dc7a9c80cd74d317c0b81a35a27c9Sebastian Redl Stmt *Ex; 234d457589fc69dc7a9c80cd74d317c0b81a35a27c9Sebastian Redl } Operand; 235c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl SourceRange Range; 236c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl 237c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redlpublic: 238c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl CXXTypeidExpr(bool isTypeOp, void *op, QualType Ty, const SourceRange r) : 2392850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl Expr(CXXTypeidExprClass, Ty, 2402850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl // typeid is never type-dependent (C++ [temp.dep.expr]p4) 2412850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl false, 2422850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl // typeid is value-dependent if the type or expression are dependent 2432850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl (isTypeOp ? QualType::getFromOpaquePtr(op)->isDependentType() 2442850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl : static_cast<Expr*>(op)->isValueDependent())), 2452850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl isTypeOp(isTypeOp), Range(r) { 246d457589fc69dc7a9c80cd74d317c0b81a35a27c9Sebastian Redl if (isTypeOp) 247d457589fc69dc7a9c80cd74d317c0b81a35a27c9Sebastian Redl Operand.Ty = op; 248d457589fc69dc7a9c80cd74d317c0b81a35a27c9Sebastian Redl else 249d457589fc69dc7a9c80cd74d317c0b81a35a27c9Sebastian Redl // op was an Expr*, so cast it back to that to be safe 2502850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl Operand.Ex = static_cast<Expr*>(op); 251d457589fc69dc7a9c80cd74d317c0b81a35a27c9Sebastian Redl } 252c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl 253c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl bool isTypeOperand() const { return isTypeOp; } 254c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl QualType getTypeOperand() const { 255c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl assert(isTypeOperand() && "Cannot call getTypeOperand for typeid(expr)"); 256d457589fc69dc7a9c80cd74d317c0b81a35a27c9Sebastian Redl return QualType::getFromOpaquePtr(Operand.Ty); 257c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl } 258c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl Expr* getExprOperand() const { 259c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl assert(!isTypeOperand() && "Cannot call getExprOperand for typeid(type)"); 260d457589fc69dc7a9c80cd74d317c0b81a35a27c9Sebastian Redl return static_cast<Expr*>(Operand.Ex); 261c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl } 262c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl 263c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl virtual SourceRange getSourceRange() const { 264c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl return Range; 265c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl } 266c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl static bool classof(const Stmt *T) { 267c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl return T->getStmtClass() == CXXTypeidExprClass; 268c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl } 269c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl static bool classof(const CXXTypeidExpr *) { return true; } 270c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl 271c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl // Iterators 272c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl virtual child_iterator child_begin(); 273c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl virtual child_iterator child_end(); 274c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl 275c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl virtual void EmitImpl(llvm::Serializer& S) const; 276c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl static CXXTypeidExpr* CreateImpl(llvm::Deserializer& D, ASTContext& C); 277c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl}; 278c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl 279796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// CXXThisExpr - Represents the "this" expression in C++, which is a 280796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// pointer to the object on which the current member function is 281796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// executing (C++ [expr.prim]p3). Example: 282796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// 283796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// @code 284796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// class Foo { 285796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// public: 286796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// void bar(); 287796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// void test() { this->bar(); } 288796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// }; 289796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// @endcode 290796da18402f286b897782a298ae3b20c459c102eDouglas Gregorclass CXXThisExpr : public Expr { 291796da18402f286b897782a298ae3b20c459c102eDouglas Gregor SourceLocation Loc; 292796da18402f286b897782a298ae3b20c459c102eDouglas Gregor 293796da18402f286b897782a298ae3b20c459c102eDouglas Gregorpublic: 294796da18402f286b897782a298ae3b20c459c102eDouglas Gregor CXXThisExpr(SourceLocation L, QualType Type) 2952850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl : Expr(CXXThisExprClass, Type, 2962850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl // 'this' is type-dependent if the class type of the enclosing 2972850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl // member function is dependent (C++ [temp.dep.expr]p2) 2982850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl Type->isDependentType(), Type->isDependentType()), 2992850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl Loc(L) { } 300796da18402f286b897782a298ae3b20c459c102eDouglas Gregor 301796da18402f286b897782a298ae3b20c459c102eDouglas Gregor virtual SourceRange getSourceRange() const { return SourceRange(Loc); } 302796da18402f286b897782a298ae3b20c459c102eDouglas Gregor 303796da18402f286b897782a298ae3b20c459c102eDouglas Gregor static bool classof(const Stmt *T) { 304796da18402f286b897782a298ae3b20c459c102eDouglas Gregor return T->getStmtClass() == CXXThisExprClass; 305796da18402f286b897782a298ae3b20c459c102eDouglas Gregor } 306796da18402f286b897782a298ae3b20c459c102eDouglas Gregor static bool classof(const CXXThisExpr *) { return true; } 307796da18402f286b897782a298ae3b20c459c102eDouglas Gregor 308796da18402f286b897782a298ae3b20c459c102eDouglas Gregor // Iterators 309796da18402f286b897782a298ae3b20c459c102eDouglas Gregor virtual child_iterator child_begin(); 310796da18402f286b897782a298ae3b20c459c102eDouglas Gregor virtual child_iterator child_end(); 311796da18402f286b897782a298ae3b20c459c102eDouglas Gregor 312796da18402f286b897782a298ae3b20c459c102eDouglas Gregor virtual void EmitImpl(llvm::Serializer& S) const; 313796da18402f286b897782a298ae3b20c459c102eDouglas Gregor static CXXThisExpr* CreateImpl(llvm::Deserializer& D, ASTContext& C); 314796da18402f286b897782a298ae3b20c459c102eDouglas Gregor}; 315796da18402f286b897782a298ae3b20c459c102eDouglas Gregor 3161060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek/// CXXThrowExpr - [C++ 15] C++ Throw Expression. This handles 3171060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek/// 'throw' and 'throw' assignment-expression. When 3181060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek/// assignment-expression isn't present, Op will be null. 3191060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek/// 3201060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenekclass CXXThrowExpr : public Expr { 3211060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek Stmt *Op; 3221060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek SourceLocation ThrowLoc; 3231060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenekpublic: 3241060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek // Ty is the void type which is used as the result type of the 3251060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek // exepression. The l is the location of the throw keyword. expr 3261060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek // can by null, if the optional expression to throw isn't present. 3271060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek CXXThrowExpr(Expr *expr, QualType Ty, SourceLocation l) : 3282850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl Expr(CXXThrowExprClass, Ty, false, false), Op(expr), ThrowLoc(l) {} 3291060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek const Expr *getSubExpr() const { return cast_or_null<Expr>(Op); } 3301060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek Expr *getSubExpr() { return cast_or_null<Expr>(Op); } 3311060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek 3321060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek virtual SourceRange getSourceRange() const { 3331060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek if (getSubExpr() == 0) 3341060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek return SourceRange(ThrowLoc, ThrowLoc); 3351060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek return SourceRange(ThrowLoc, getSubExpr()->getSourceRange().getEnd()); 3361060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek } 3371060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek 3381060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek static bool classof(const Stmt *T) { 3391060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek return T->getStmtClass() == CXXThrowExprClass; 3401060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek } 3411060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek static bool classof(const CXXThrowExpr *) { return true; } 3421060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek 3431060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek // Iterators 3441060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek virtual child_iterator child_begin(); 3451060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek virtual child_iterator child_end(); 3461060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek}; 3471060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek 3481060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek/// CXXDefaultArgExpr - C++ [dcl.fct.default]. This wraps up a 3491060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek/// function call argument that was created from the corresponding 3501060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek/// parameter's default argument, when the call did not explicitly 3511060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek/// supply arguments for all of the parameters. 3521060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenekclass CXXDefaultArgExpr : public Expr { 3531060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek ParmVarDecl *Param; 3541060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenekpublic: 3551060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek // Param is the parameter whose default argument is used by this 3561060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek // expression. 3571060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek explicit CXXDefaultArgExpr(ParmVarDecl *param) 35861366e9cd41a6dbde4e66416dac21269c8ac1d94Douglas Gregor : Expr(CXXDefaultArgExprClass, 35961366e9cd41a6dbde4e66416dac21269c8ac1d94Douglas Gregor param->hasUnparsedDefaultArg()? param->getType().getNonReferenceType() 36061366e9cd41a6dbde4e66416dac21269c8ac1d94Douglas Gregor : param->getDefaultArg()->getType()), 3611060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek Param(param) { } 3621060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek 3631060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek // Retrieve the parameter that the argument was created from. 3641060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek const ParmVarDecl *getParam() const { return Param; } 3651060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek ParmVarDecl *getParam() { return Param; } 3661060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek 3671060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek // Retrieve the actual argument to the function call. 3681060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek const Expr *getExpr() const { return Param->getDefaultArg(); } 3691060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek Expr *getExpr() { return Param->getDefaultArg(); } 3701060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek 3711060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek virtual SourceRange getSourceRange() const { 3721060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek // Default argument expressions have no representation in the 3731060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek // source, so they have an empty source range. 3741060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek return SourceRange(); 3751060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek } 3761060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek 3771060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek static bool classof(const Stmt *T) { 3781060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek return T->getStmtClass() == CXXDefaultArgExprClass; 3791060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek } 3801060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek static bool classof(const CXXDefaultArgExpr *) { return true; } 3811060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek 3821060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek // Iterators 3831060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek virtual child_iterator child_begin(); 3841060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek virtual child_iterator child_end(); 3851060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek 3861060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek // Serialization 3871060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek virtual void EmitImpl(llvm::Serializer& S) const; 3881060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek static CXXDefaultArgExpr* CreateImpl(llvm::Deserializer& D, 3891060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek ASTContext& C); 3901060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek}; 391987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis 39249badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// CXXFunctionalCastExpr - Represents an explicit C++ type conversion 39349badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// that uses "functional" notion (C++ [expr.type.conv]). Example: @c 39449badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// x = int(0.5); 39549badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregorclass CXXFunctionalCastExpr : public ExplicitCastExpr { 396987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis SourceLocation TyBeginLoc; 397987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis SourceLocation RParenLoc; 398987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidispublic: 39949badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor CXXFunctionalCastExpr(QualType ty, QualType writtenTy, 40049badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor SourceLocation tyBeginLoc, Expr *castExpr, 401987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis SourceLocation rParenLoc) : 40249badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor ExplicitCastExpr(CXXFunctionalCastExprClass, ty, castExpr, writtenTy), 403987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis TyBeginLoc(tyBeginLoc), RParenLoc(rParenLoc) {} 404987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis 405987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis SourceLocation getTypeBeginLoc() const { return TyBeginLoc; } 406987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis SourceLocation getRParenLoc() const { return RParenLoc; } 407987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis 408987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis virtual SourceRange getSourceRange() const { 409987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis return SourceRange(TyBeginLoc, RParenLoc); 410987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis } 411987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis static bool classof(const Stmt *T) { 412987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis return T->getStmtClass() == CXXFunctionalCastExprClass; 413987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis } 414987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis static bool classof(const CXXFunctionalCastExpr *) { return true; } 415987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis 416987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis virtual void EmitImpl(llvm::Serializer& S) const; 417987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis static CXXFunctionalCastExpr * 418987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis CreateImpl(llvm::Deserializer& D, ASTContext& C); 419987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis}; 420987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis 421506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// @brief Represents a C++ functional cast expression that builds a 422506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// temporary object. 423506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// 424506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// This expression type represents a C++ "functional" cast 425506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// (C++[expr.type.conv]) with N != 1 arguments that invokes a 426506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// constructor to build a temporary object. If N == 0 but no 427506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// constructor will be called (because the functional cast is 428506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// performing a value-initialized an object whose class type has no 429506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// user-declared constructors), CXXZeroInitValueExpr will represent 430506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// the functional cast. Finally, with N == 1 arguments the functional 431506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// cast expression will be represented by CXXFunctionalCastExpr. 432506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// Example: 433506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// @code 434506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// struct X { X(int, float); } 435506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// 436506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// X create_X() { 437506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// return X(1, 3.14f); // creates a CXXTemporaryObjectExpr 438506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// }; 439506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// @endcode 440506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregorclass CXXTemporaryObjectExpr : public Expr { 441506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor SourceLocation TyBeginLoc; 442506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor SourceLocation RParenLoc; 443506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor CXXConstructorDecl *Constructor; 444506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor Stmt **Args; 445506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor unsigned NumArgs; 446506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor 447506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregorpublic: 448506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor CXXTemporaryObjectExpr(CXXConstructorDecl *Cons, QualType writtenTy, 449506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor SourceLocation tyBeginLoc, Expr **Args, 450506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor unsigned NumArgs, SourceLocation rParenLoc); 451506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor 452506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor ~CXXTemporaryObjectExpr(); 453506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor 454506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor SourceLocation getTypeBeginLoc() const { return TyBeginLoc; } 455506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor SourceLocation getRParenLoc() const { return RParenLoc; } 456506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor 457506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor typedef ExprIterator arg_iterator; 458506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor typedef ConstExprIterator const_arg_iterator; 459506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor 460506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor arg_iterator arg_begin() { return Args; } 461506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor arg_iterator arg_end() { return Args + NumArgs; } 462506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor const_arg_iterator arg_begin() const { return Args; } 463506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor const_arg_iterator arg_end() const { return Args + NumArgs; } 464506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor 465506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor virtual SourceRange getSourceRange() const { 466506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor return SourceRange(TyBeginLoc, RParenLoc); 467506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor } 468506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor static bool classof(const Stmt *T) { 469506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor return T->getStmtClass() == CXXTemporaryObjectExprClass; 470506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor } 471506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor static bool classof(const CXXTemporaryObjectExpr *) { return true; } 472506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor 473506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor // Iterators 474506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor virtual child_iterator child_begin(); 475506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor virtual child_iterator child_end(); 476506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor 477506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor virtual void EmitImpl(llvm::Serializer& S) const; 478506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor static CXXTemporaryObjectExpr *CreateImpl(llvm::Deserializer& D, ASTContext& C); 479506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor}; 480506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor 481987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis/// CXXZeroInitValueExpr - [C++ 5.2.3p2] 482506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// Expression "T()" which creates a value-initialized rvalue of type 483506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// T, which is either a non-class type or a class type without any 484506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// user-defined constructors. 485987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis/// 486987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidisclass CXXZeroInitValueExpr : public Expr { 487987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis SourceLocation TyBeginLoc; 488987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis SourceLocation RParenLoc; 489987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis 490987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidispublic: 491987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis CXXZeroInitValueExpr(QualType ty, SourceLocation tyBeginLoc, 492987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis SourceLocation rParenLoc ) : 493987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis Expr(CXXZeroInitValueExprClass, ty), 494987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis TyBeginLoc(tyBeginLoc), RParenLoc(rParenLoc) {} 495987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis 496987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis SourceLocation getTypeBeginLoc() const { return TyBeginLoc; } 497987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis SourceLocation getRParenLoc() const { return RParenLoc; } 498987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis 4994c67834407ca6ab344dcf44fc599ad4938cfa96dDouglas Gregor /// @brief Whether this initialization expression was 5004c67834407ca6ab344dcf44fc599ad4938cfa96dDouglas Gregor /// implicitly-generated. 5014c67834407ca6ab344dcf44fc599ad4938cfa96dDouglas Gregor bool isImplicit() const { 5024c67834407ca6ab344dcf44fc599ad4938cfa96dDouglas Gregor return TyBeginLoc.isInvalid() && RParenLoc.isInvalid(); 5034c67834407ca6ab344dcf44fc599ad4938cfa96dDouglas Gregor } 5044c67834407ca6ab344dcf44fc599ad4938cfa96dDouglas Gregor 505987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis virtual SourceRange getSourceRange() const { 506987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis return SourceRange(TyBeginLoc, RParenLoc); 507987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis } 508987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis 509987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis static bool classof(const Stmt *T) { 510987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis return T->getStmtClass() == CXXZeroInitValueExprClass; 511987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis } 512987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis static bool classof(const CXXZeroInitValueExpr *) { return true; } 513987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis 514987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis // Iterators 515987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis virtual child_iterator child_begin(); 516987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis virtual child_iterator child_end(); 517987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis 518987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis virtual void EmitImpl(llvm::Serializer& S) const; 519987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis static CXXZeroInitValueExpr * 520987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis CreateImpl(llvm::Deserializer& D, ASTContext& C); 521987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis}; 522987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis 5239e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis/// CXXConditionDeclExpr - Condition declaration of a if/switch/while/for 5249e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis/// statement, e.g: "if (int x = f()) {...}". 5259e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis/// The main difference with DeclRefExpr is that CXXConditionDeclExpr owns the 5269e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis/// decl that it references. 5279e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis/// 5289e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidisclass CXXConditionDeclExpr : public DeclRefExpr { 5299e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidispublic: 5309e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis CXXConditionDeclExpr(SourceLocation startLoc, 5319e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis SourceLocation eqLoc, VarDecl *var) 5329d293dfc0ad7c44ae0b5eb9517f1ed8c8d8b7ff7Douglas Gregor : DeclRefExpr(CXXConditionDeclExprClass, var, 5339d293dfc0ad7c44ae0b5eb9517f1ed8c8d8b7ff7Douglas Gregor var->getType().getNonReferenceType(), startLoc) {} 5349e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis 5359e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis virtual void Destroy(ASTContext& Ctx); 5369e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis 5379e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis SourceLocation getStartLoc() const { return getLocation(); } 5389e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis 5399e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis VarDecl *getVarDecl() { return cast<VarDecl>(getDecl()); } 5409e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis const VarDecl *getVarDecl() const { return cast<VarDecl>(getDecl()); } 5419e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis 5429e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis virtual SourceRange getSourceRange() const { 5439e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis return SourceRange(getStartLoc(), getVarDecl()->getInit()->getLocEnd()); 5449e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis } 5459e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis 5469e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis static bool classof(const Stmt *T) { 5479e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis return T->getStmtClass() == CXXConditionDeclExprClass; 5489e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis } 5499e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis static bool classof(const CXXConditionDeclExpr *) { return true; } 5509e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis 5519e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis // Iterators 5529e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis virtual child_iterator child_begin(); 5539e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis virtual child_iterator child_end(); 5549e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis 5559e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis // FIXME: Implement these. 5569e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis //virtual void EmitImpl(llvm::Serializer& S) const; 5579e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis //static CXXConditionDeclExpr * 5589e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis // CreateImpl(llvm::Deserializer& D, ASTContext& C); 5599e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis}; 5609e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis 5614c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl/// CXXNewExpr - A new expression for memory allocation and constructor calls, 5624c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl/// e.g: "new CXXNewExpr(foo)". 5634c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redlclass CXXNewExpr : public Expr { 5644c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // Was the usage ::new, i.e. is the global new to be used? 5654c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl bool GlobalNew : 1; 5664c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // Was the form (type-id) used? Otherwise, it was new-type-id. 5674c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl bool ParenTypeId : 1; 5684c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // Is there an initializer? If not, built-ins are uninitialized, else they're 5694c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // value-initialized. 5704c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl bool Initializer : 1; 571cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl // Do we allocate an array? If so, the first SubExpr is the size expression. 572cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl bool Array : 1; 5734c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // The number of placement new arguments. 5744c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl unsigned NumPlacementArgs : 14; 5754c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // The number of constructor arguments. This may be 1 even for non-class 5764c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // types; use the pseudo copy constructor. 577cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl unsigned NumConstructorArgs : 14; 578cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl // Contains an optional array size expression, any number of optional 579cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl // placement arguments, and any number of optional constructor arguments, 580cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl // in that order. 5814c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl Stmt **SubExprs; 5824c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // Points to the allocation function used. 5834c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl FunctionDecl *OperatorNew; 5844c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // Points to the deallocation function used in case of error. May be null. 5854c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl FunctionDecl *OperatorDelete; 5864c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // Points to the constructor used. Cannot be null if AllocType is a record; 5874c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // it would still point at the default constructor (even an implicit one). 5884c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // Must be null for all other types. 5894c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl CXXConstructorDecl *Constructor; 5904c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 5914c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl SourceLocation StartLoc; 5924c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl SourceLocation EndLoc; 5934c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 5944c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // Deserialization constructor 595cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl CXXNewExpr(QualType ty, bool globalNew, bool parenTypeId, bool initializer, 596cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl bool array, unsigned numPlaceArgs, unsigned numConsArgs, 597cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl Stmt **subExprs, FunctionDecl *operatorNew, 598cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl FunctionDecl *operatorDelete, CXXConstructorDecl *constructor, 599cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl SourceLocation startLoc, SourceLocation endLoc) 6002850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl : Expr(CXXNewExprClass, ty, ty->isDependentType(), ty->isDependentType()), 6012850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl GlobalNew(globalNew), ParenTypeId(parenTypeId), 602cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl Initializer(initializer), Array(array), NumPlacementArgs(numPlaceArgs), 603cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl NumConstructorArgs(numConsArgs), SubExprs(subExprs), 6044c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl OperatorNew(operatorNew), OperatorDelete(operatorDelete), 605cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl Constructor(constructor), StartLoc(startLoc), EndLoc(endLoc) 6064c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl { } 6074c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redlpublic: 6084c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl CXXNewExpr(bool globalNew, FunctionDecl *operatorNew, Expr **placementArgs, 609cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl unsigned numPlaceArgs, bool ParenTypeId, Expr *arraySize, 6104c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl CXXConstructorDecl *constructor, bool initializer, 6114c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl Expr **constructorArgs, unsigned numConsArgs, 6124c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl FunctionDecl *operatorDelete, QualType ty, 6134c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl SourceLocation startLoc, SourceLocation endLoc); 6144c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl ~CXXNewExpr() { 6154c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl delete[] SubExprs; 6164c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 6174c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 618cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl QualType getAllocatedType() const { 619cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl assert(getType()->isPointerType()); 620cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl return getType()->getAsPointerType()->getPointeeType(); 621cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl } 6224c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 6234c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl FunctionDecl *getOperatorNew() const { return OperatorNew; } 6244c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl FunctionDecl *getOperatorDelete() const { return OperatorDelete; } 6254c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl CXXConstructorDecl *getConstructor() const { return Constructor; } 6264c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 627cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl bool isArray() const { return Array; } 628cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl Expr *getArraySize() { 629cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl return Array ? cast<Expr>(SubExprs[0]) : 0; 630cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl } 631cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl const Expr *getArraySize() const { 632cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl return Array ? cast<Expr>(SubExprs[0]) : 0; 633cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl } 634cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl 6354c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl unsigned getNumPlacementArgs() const { return NumPlacementArgs; } 6364c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl Expr *getPlacementArg(unsigned i) { 6374c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl assert(i < NumPlacementArgs && "Index out of range"); 638cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl return cast<Expr>(SubExprs[Array + i]); 6394c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 6404c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl const Expr *getPlacementArg(unsigned i) const { 6414c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl assert(i < NumPlacementArgs && "Index out of range"); 642cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl return cast<Expr>(SubExprs[Array + i]); 6434c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 6444c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 6454c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl bool isGlobalNew() const { return GlobalNew; } 6464c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl bool isParenTypeId() const { return ParenTypeId; } 6474c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl bool hasInitializer() const { return Initializer; } 6484c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 6494c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl unsigned getNumConstructorArgs() const { return NumConstructorArgs; } 6504c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl Expr *getConstructorArg(unsigned i) { 6514c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl assert(i < NumConstructorArgs && "Index out of range"); 652cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl return cast<Expr>(SubExprs[Array + NumPlacementArgs + i]); 6534c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 6544c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl const Expr *getConstructorArg(unsigned i) const { 6554c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl assert(i < NumConstructorArgs && "Index out of range"); 656cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl return cast<Expr>(SubExprs[Array + NumPlacementArgs + i]); 6574c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 6584c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 6594c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl typedef ExprIterator arg_iterator; 6604c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl typedef ConstExprIterator const_arg_iterator; 6614c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 6624c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl arg_iterator placement_arg_begin() { 663cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl return SubExprs + Array; 6644c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 6654c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl arg_iterator placement_arg_end() { 666cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl return SubExprs + Array + getNumPlacementArgs(); 6674c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 6684c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl const_arg_iterator placement_arg_begin() const { 669cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl return SubExprs + Array; 6704c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 6714c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl const_arg_iterator placement_arg_end() const { 672cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl return SubExprs + Array + getNumPlacementArgs(); 6734c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 6744c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 6754c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl arg_iterator constructor_arg_begin() { 676cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl return SubExprs + Array + getNumPlacementArgs(); 6774c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 6784c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl arg_iterator constructor_arg_end() { 679cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl return SubExprs + Array + getNumPlacementArgs() + getNumConstructorArgs(); 6804c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 6814c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl const_arg_iterator constructor_arg_begin() const { 682cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl return SubExprs + Array + getNumPlacementArgs(); 6834c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 6844c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl const_arg_iterator constructor_arg_end() const { 685cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl return SubExprs + Array + getNumPlacementArgs() + getNumConstructorArgs(); 6864c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 6874c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 6884c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl virtual SourceRange getSourceRange() const { 6894c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl return SourceRange(StartLoc, EndLoc); 6904c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 6914c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 6924c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl static bool classof(const Stmt *T) { 6934c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl return T->getStmtClass() == CXXNewExprClass; 6944c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 6954c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl static bool classof(const CXXNewExpr *) { return true; } 6964c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 6974c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // Iterators 6984c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl virtual child_iterator child_begin(); 6994c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl virtual child_iterator child_end(); 7004c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 7014c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl virtual void EmitImpl(llvm::Serializer& S) const; 7024c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl static CXXNewExpr* CreateImpl(llvm::Deserializer& D, ASTContext& C); 7034c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl}; 7044c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 7054c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl/// CXXDeleteExpr - A delete expression for memory deallocation and destructor 7064c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl/// calls, e.g. "delete[] pArray". 7074c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redlclass CXXDeleteExpr : public Expr { 7084c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // Is this a forced global delete, i.e. "::delete"? 7094c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl bool GlobalDelete : 1; 7104c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // Is this the array form of delete, i.e. "delete[]"? 7114c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl bool ArrayForm : 1; 7124c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // Points to the operator delete overload that is used. Could be a member. 7134c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl FunctionDecl *OperatorDelete; 7144c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // The pointer expression to be deleted. 7154c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl Stmt *Argument; 7164c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // Location of the expression. 7174c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl SourceLocation Loc; 7184c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redlpublic: 7194c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl CXXDeleteExpr(QualType ty, bool globalDelete, bool arrayForm, 7204c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl FunctionDecl *operatorDelete, Expr *arg, SourceLocation loc) 7212850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl : Expr(CXXDeleteExprClass, ty, false, false), GlobalDelete(globalDelete), 7224c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl ArrayForm(arrayForm), OperatorDelete(operatorDelete), Argument(arg), 7234c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl Loc(loc) { } 7244c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 7254c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl bool isGlobalDelete() const { return GlobalDelete; } 7264c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl bool isArrayForm() const { return ArrayForm; } 7274c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 7284c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl FunctionDecl *getOperatorDelete() const { return OperatorDelete; } 7294c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 7304c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl Expr *getArgument() { return cast<Expr>(Argument); } 7314c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl const Expr *getArgument() const { return cast<Expr>(Argument); } 7324c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 7334c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl virtual SourceRange getSourceRange() const { 7344c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl return SourceRange(Loc, Argument->getLocEnd()); 7354c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 7364c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 7374c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl static bool classof(const Stmt *T) { 7384c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl return T->getStmtClass() == CXXDeleteExprClass; 7394c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 7404c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl static bool classof(const CXXDeleteExpr *) { return true; } 7414c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 7424c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // Iterators 7434c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl virtual child_iterator child_begin(); 7444c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl virtual child_iterator child_end(); 7454c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 7464c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl virtual void EmitImpl(llvm::Serializer& S) const; 7474c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl static CXXDeleteExpr * CreateImpl(llvm::Deserializer& D, ASTContext& C); 7484c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl}; 7494c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 75017330019f05966762bc952840ef1926b9becb145Douglas Gregor/// \brief Represents the name of a function that has not been 75117330019f05966762bc952840ef1926b9becb145Douglas Gregor/// resolved to any declaration. 75217330019f05966762bc952840ef1926b9becb145Douglas Gregor/// 75317330019f05966762bc952840ef1926b9becb145Douglas Gregor/// Unresolved function names occur when a function name is 75417330019f05966762bc952840ef1926b9becb145Douglas Gregor/// encountered prior to an open parentheses ('(') in a C++ function 75517330019f05966762bc952840ef1926b9becb145Douglas Gregor/// call, and the function name itself did not resolve to a 75617330019f05966762bc952840ef1926b9becb145Douglas Gregor/// declaration. These function names can only be resolved when they 75717330019f05966762bc952840ef1926b9becb145Douglas Gregor/// form the postfix-expression of a function call, so that 75817330019f05966762bc952840ef1926b9becb145Douglas Gregor/// argument-dependent lookup finds declarations corresponding to 75917330019f05966762bc952840ef1926b9becb145Douglas Gregor/// these functions. 76017330019f05966762bc952840ef1926b9becb145Douglas Gregor 7615c37de788529cd9180f22069970737a7208bd625Douglas Gregor/// @code 7625c37de788529cd9180f22069970737a7208bd625Douglas Gregor/// template<typename T> void f(T x) { 76317330019f05966762bc952840ef1926b9becb145Douglas Gregor/// g(x); // g is an unresolved function name (that is also a dependent name) 7645c37de788529cd9180f22069970737a7208bd625Douglas Gregor/// } 7655c37de788529cd9180f22069970737a7208bd625Douglas Gregor/// @endcode 76617330019f05966762bc952840ef1926b9becb145Douglas Gregorclass UnresolvedFunctionNameExpr : public Expr { 76717330019f05966762bc952840ef1926b9becb145Douglas Gregor /// The name that was present in the source 76817330019f05966762bc952840ef1926b9becb145Douglas Gregor DeclarationName Name; 7695c37de788529cd9180f22069970737a7208bd625Douglas Gregor 77017330019f05966762bc952840ef1926b9becb145Douglas Gregor /// The location of this name in the source code 7715c37de788529cd9180f22069970737a7208bd625Douglas Gregor SourceLocation Loc; 7725c37de788529cd9180f22069970737a7208bd625Douglas Gregor 7735c37de788529cd9180f22069970737a7208bd625Douglas Gregorpublic: 77417330019f05966762bc952840ef1926b9becb145Douglas Gregor UnresolvedFunctionNameExpr(DeclarationName N, QualType T, SourceLocation L) 77517330019f05966762bc952840ef1926b9becb145Douglas Gregor : Expr(UnresolvedFunctionNameExprClass, T, false, false), Name(N), Loc(L) { } 7765c37de788529cd9180f22069970737a7208bd625Douglas Gregor 77717330019f05966762bc952840ef1926b9becb145Douglas Gregor /// \brief Retrieves the name that occurred in the source code. 77817330019f05966762bc952840ef1926b9becb145Douglas Gregor DeclarationName getName() const { return Name; } 7795c37de788529cd9180f22069970737a7208bd625Douglas Gregor 7805c37de788529cd9180f22069970737a7208bd625Douglas Gregor /// getLocation - Retrieves the location in the source code where 7815c37de788529cd9180f22069970737a7208bd625Douglas Gregor /// the name occurred. 7825c37de788529cd9180f22069970737a7208bd625Douglas Gregor SourceLocation getLocation() const { return Loc; } 7835c37de788529cd9180f22069970737a7208bd625Douglas Gregor 7845c37de788529cd9180f22069970737a7208bd625Douglas Gregor virtual SourceRange getSourceRange() const { return SourceRange(Loc); } 7855c37de788529cd9180f22069970737a7208bd625Douglas Gregor 7865c37de788529cd9180f22069970737a7208bd625Douglas Gregor static bool classof(const Stmt *T) { 78717330019f05966762bc952840ef1926b9becb145Douglas Gregor return T->getStmtClass() == UnresolvedFunctionNameExprClass; 7885c37de788529cd9180f22069970737a7208bd625Douglas Gregor } 78917330019f05966762bc952840ef1926b9becb145Douglas Gregor static bool classof(const UnresolvedFunctionNameExpr *) { return true; } 7905c37de788529cd9180f22069970737a7208bd625Douglas Gregor 7915c37de788529cd9180f22069970737a7208bd625Douglas Gregor // Iterators 7925c37de788529cd9180f22069970737a7208bd625Douglas Gregor virtual child_iterator child_begin(); 7935c37de788529cd9180f22069970737a7208bd625Douglas Gregor virtual child_iterator child_end(); 7945c37de788529cd9180f22069970737a7208bd625Douglas Gregor 7955c37de788529cd9180f22069970737a7208bd625Douglas Gregor virtual void EmitImpl(llvm::Serializer& S) const; 79617330019f05966762bc952840ef1926b9becb145Douglas Gregor static UnresolvedFunctionNameExpr *CreateImpl(llvm::Deserializer& D, ASTContext& C); 7975c37de788529cd9180f22069970737a7208bd625Douglas Gregor}; 7985c37de788529cd9180f22069970737a7208bd625Douglas Gregor 79964b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl/// UnaryTypeTraitExpr - A GCC or MS unary type trait, as used in the 80064b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl/// implementation of TR1/C++0x type trait templates. 80164b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl/// Example: 80264b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl/// __is_pod(int) == true 80364b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl/// __is_enum(std::string) == false 80464b45f7e0d3167f040841ac2920aead7f080730dSebastian Redlclass UnaryTypeTraitExpr : public Expr { 80564b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl /// UTT - The trait. 80664b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl UnaryTypeTrait UTT; 80764b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl 80864b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl /// Loc - The location of the type trait keyword. 80964b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl SourceLocation Loc; 81064b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl 81164b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl /// RParen - The location of the closing paren. 81264b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl SourceLocation RParen; 81364b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl 81464b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl /// QueriedType - The type we're testing. 81564b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl QualType QueriedType; 81664b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl 81764b45f7e0d3167f040841ac2920aead7f080730dSebastian Redlpublic: 81864b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl UnaryTypeTraitExpr(SourceLocation loc, UnaryTypeTrait utt, QualType queried, 81964b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl SourceLocation rparen, QualType ty) 82064b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl : Expr(UnaryTypeTraitExprClass, ty, false, queried->isDependentType()), 82164b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl UTT(utt), Loc(loc), RParen(rparen), QueriedType(queried) { } 82264b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl 82364b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl virtual SourceRange getSourceRange() const { return SourceRange(Loc, RParen);} 82464b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl 82564b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl UnaryTypeTrait getTrait() const { return UTT; } 82664b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl 82764b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl QualType getQueriedType() const { return QueriedType; } 82864b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl 829c87a282e7b80c055088fc51bdbe8fc73da64d4f8Daniel Dunbar bool EvaluateTrait() const; 83064b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl 83164b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl static bool classof(const Stmt *T) { 83264b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl return T->getStmtClass() == UnaryTypeTraitExprClass; 83364b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl } 83464b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl static bool classof(const UnaryTypeTraitExpr *) { return true; } 83564b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl 83664b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl // Iterators 83764b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl virtual child_iterator child_begin(); 83864b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl virtual child_iterator child_end(); 83964b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl 84064b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl virtual void EmitImpl(llvm::Serializer& S) const; 84164b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl static UnaryTypeTraitExpr *CreateImpl(llvm::Deserializer& D, ASTContext& C); 84264b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl}; 84364b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl 8441a49af9681c350fef58e677f85ccb9a77e8e9d0aDouglas Gregor/// QualifiedDeclRefExpr - A reference to a declared variable, 8451a49af9681c350fef58e677f85ccb9a77e8e9d0aDouglas Gregor/// function, enum, etc., that includes a qualification, e.g., 8461a49af9681c350fef58e677f85ccb9a77e8e9d0aDouglas Gregor/// "N::foo". 8471a49af9681c350fef58e677f85ccb9a77e8e9d0aDouglas Gregorclass QualifiedDeclRefExpr : public DeclRefExpr { 8481a49af9681c350fef58e677f85ccb9a77e8e9d0aDouglas Gregor /// NestedNameLoc - The location of the beginning of the 8491a49af9681c350fef58e677f85ccb9a77e8e9d0aDouglas Gregor /// nested-name-specifier that qualifies this declaration. 8501a49af9681c350fef58e677f85ccb9a77e8e9d0aDouglas Gregor SourceLocation NestedNameLoc; 8511a49af9681c350fef58e677f85ccb9a77e8e9d0aDouglas Gregor 8521a49af9681c350fef58e677f85ccb9a77e8e9d0aDouglas Gregorpublic: 8531a49af9681c350fef58e677f85ccb9a77e8e9d0aDouglas Gregor QualifiedDeclRefExpr(NamedDecl *d, QualType t, SourceLocation l, bool TD, 8541a49af9681c350fef58e677f85ccb9a77e8e9d0aDouglas Gregor bool VD, SourceLocation nnl) 8551a49af9681c350fef58e677f85ccb9a77e8e9d0aDouglas Gregor : DeclRefExpr(QualifiedDeclRefExprClass, d, t, l, TD, VD), 8561a49af9681c350fef58e677f85ccb9a77e8e9d0aDouglas Gregor NestedNameLoc(nnl) { } 8571a49af9681c350fef58e677f85ccb9a77e8e9d0aDouglas Gregor 8581a49af9681c350fef58e677f85ccb9a77e8e9d0aDouglas Gregor virtual SourceRange getSourceRange() const { 8591a49af9681c350fef58e677f85ccb9a77e8e9d0aDouglas Gregor return SourceRange(NestedNameLoc, getLocation()); 8601a49af9681c350fef58e677f85ccb9a77e8e9d0aDouglas Gregor } 8611a49af9681c350fef58e677f85ccb9a77e8e9d0aDouglas Gregor 8621a49af9681c350fef58e677f85ccb9a77e8e9d0aDouglas Gregor static bool classof(const Stmt *T) { 8631a49af9681c350fef58e677f85ccb9a77e8e9d0aDouglas Gregor return T->getStmtClass() == QualifiedDeclRefExprClass; 8641a49af9681c350fef58e677f85ccb9a77e8e9d0aDouglas Gregor } 8651a49af9681c350fef58e677f85ccb9a77e8e9d0aDouglas Gregor static bool classof(const QualifiedDeclRefExpr *) { return true; } 8661a49af9681c350fef58e677f85ccb9a77e8e9d0aDouglas Gregor 8671a49af9681c350fef58e677f85ccb9a77e8e9d0aDouglas Gregor virtual void EmitImpl(llvm::Serializer& S) const; 8681a49af9681c350fef58e677f85ccb9a77e8e9d0aDouglas Gregor static QualifiedDeclRefExpr* CreateImpl(llvm::Deserializer& D, ASTContext& C); 8691a49af9681c350fef58e677f85ccb9a77e8e9d0aDouglas Gregor}; 8701a49af9681c350fef58e677f85ccb9a77e8e9d0aDouglas Gregor 8715f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer} // end namespace clang 8725f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 8735f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer#endif 874