ExprCXX.h revision d5532b6cfff2977e0c59fa6ead7f7973984a620d
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" 20d5532b6cfff2977e0c59fa6ead7f7973984a620dJohn McCall#include "clang/AST/TemplateBase.h" 215f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 225f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencernamespace clang { 235f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 244c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl class CXXConstructorDecl; 25c1ce477119fed070299668aab24084b17ff5f14bAnders Carlsson class CXXDestructorDecl; 26e9f42087aabfdb6b2afc35c7e38ac65da063b409Fariborz Jahanian class CXXMethodDecl; 27ff6b3d64c9f07155f1414411b8451d7bf8937c62Anders Carlsson class CXXTemporary; 28d5532b6cfff2977e0c59fa6ead7f7973984a620dJohn McCall class TemplateArgumentListInfo; 294c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 301060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek//===--------------------------------------------------------------------===// 311060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek// C++ Expressions. 321060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek//===--------------------------------------------------------------------===// 331060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek 343fd95ce225393fe4a3623e429766a8c3f487ff9dDouglas Gregor/// \brief A call to an overloaded operator written using operator 353fd95ce225393fe4a3623e429766a8c3f487ff9dDouglas Gregor/// syntax. 363fd95ce225393fe4a3623e429766a8c3f487ff9dDouglas Gregor/// 373fd95ce225393fe4a3623e429766a8c3f487ff9dDouglas Gregor/// Represents a call to an overloaded operator written using operator 383fd95ce225393fe4a3623e429766a8c3f487ff9dDouglas Gregor/// syntax, e.g., "x + y" or "*p". While semantically equivalent to a 393fd95ce225393fe4a3623e429766a8c3f487ff9dDouglas Gregor/// normal call, this AST node provides better information about the 403fd95ce225393fe4a3623e429766a8c3f487ff9dDouglas Gregor/// syntactic representation of the call. 413fd95ce225393fe4a3623e429766a8c3f487ff9dDouglas Gregor/// 423fd95ce225393fe4a3623e429766a8c3f487ff9dDouglas Gregor/// In a C++ template, this expression node kind will be used whenever 433fd95ce225393fe4a3623e429766a8c3f487ff9dDouglas Gregor/// any of the arguments are type-dependent. In this case, the 443fd95ce225393fe4a3623e429766a8c3f487ff9dDouglas Gregor/// function itself will be a (possibly empty) set of functions and 453fd95ce225393fe4a3623e429766a8c3f487ff9dDouglas Gregor/// function templates that were found by name lookup at template 463fd95ce225393fe4a3623e429766a8c3f487ff9dDouglas Gregor/// definition time. 47b4609806e9232593ece09ce08b630836e825865cDouglas Gregorclass CXXOperatorCallExpr : public CallExpr { 48063daf6e196c51f162e0485478355d8e280eef5cDouglas Gregor /// \brief The overloaded operator. 49063daf6e196c51f162e0485478355d8e280eef5cDouglas Gregor OverloadedOperatorKind Operator; 50063daf6e196c51f162e0485478355d8e280eef5cDouglas Gregor 51b4609806e9232593ece09ce08b630836e825865cDouglas Gregorpublic: 521eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump CXXOperatorCallExpr(ASTContext& C, OverloadedOperatorKind Op, Expr *fn, 531eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump Expr **args, unsigned numargs, QualType t, 54063daf6e196c51f162e0485478355d8e280eef5cDouglas Gregor SourceLocation operatorloc) 55063daf6e196c51f162e0485478355d8e280eef5cDouglas Gregor : CallExpr(C, CXXOperatorCallExprClass, fn, args, numargs, t, operatorloc), 56063daf6e196c51f162e0485478355d8e280eef5cDouglas Gregor Operator(Op) {} 571eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump explicit CXXOperatorCallExpr(ASTContext& C, EmptyShell Empty) : 58ba0a9006dbc4814e1e35f82812cb5a1dad65e8b8Argyrios Kyrtzidis CallExpr(C, CXXOperatorCallExprClass, Empty) { } 591eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 60b4609806e9232593ece09ce08b630836e825865cDouglas Gregor 61b4609806e9232593ece09ce08b630836e825865cDouglas Gregor /// getOperator - Returns the kind of overloaded operator that this 62b4609806e9232593ece09ce08b630836e825865cDouglas Gregor /// expression refers to. 63063daf6e196c51f162e0485478355d8e280eef5cDouglas Gregor OverloadedOperatorKind getOperator() const { return Operator; } 64ba0a9006dbc4814e1e35f82812cb5a1dad65e8b8Argyrios Kyrtzidis void setOperator(OverloadedOperatorKind Kind) { Operator = Kind; } 65b4609806e9232593ece09ce08b630836e825865cDouglas Gregor 66b4609806e9232593ece09ce08b630836e825865cDouglas Gregor /// getOperatorLoc - Returns the location of the operator symbol in 67b4609806e9232593ece09ce08b630836e825865cDouglas Gregor /// the expression. When @c getOperator()==OO_Call, this is the 68b4609806e9232593ece09ce08b630836e825865cDouglas Gregor /// location of the right parentheses; when @c 69b4609806e9232593ece09ce08b630836e825865cDouglas Gregor /// getOperator()==OO_Subscript, this is the location of the right 70b4609806e9232593ece09ce08b630836e825865cDouglas Gregor /// bracket. 71b4609806e9232593ece09ce08b630836e825865cDouglas Gregor SourceLocation getOperatorLoc() const { return getRParenLoc(); } 72b4609806e9232593ece09ce08b630836e825865cDouglas Gregor 73b4609806e9232593ece09ce08b630836e825865cDouglas Gregor virtual SourceRange getSourceRange() const; 741eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 751eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump static bool classof(const Stmt *T) { 761eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump return T->getStmtClass() == CXXOperatorCallExprClass; 77b4609806e9232593ece09ce08b630836e825865cDouglas Gregor } 78b4609806e9232593ece09ce08b630836e825865cDouglas Gregor static bool classof(const CXXOperatorCallExpr *) { return true; } 79b4609806e9232593ece09ce08b630836e825865cDouglas Gregor}; 80b4609806e9232593ece09ce08b630836e825865cDouglas Gregor 8188a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor/// CXXMemberCallExpr - Represents a call to a member function that 8288a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor/// may be written either with member call syntax (e.g., "obj.func()" 8388a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor/// or "objptr->func()") or with normal function-call syntax 8488a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor/// ("func()") within a member function that ends up calling a member 8588a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor/// function. The callee in either case is a MemberExpr that contains 8688a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor/// both the object argument and the member function, while the 8788a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor/// arguments are the arguments within the parentheses (not including 8888a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor/// the object argument). 8988a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregorclass CXXMemberCallExpr : public CallExpr { 9088a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregorpublic: 91668bf91d31265b6ea8c3eb854ba450857701f269Ted Kremenek CXXMemberCallExpr(ASTContext& C, Expr *fn, Expr **args, unsigned numargs, 92668bf91d31265b6ea8c3eb854ba450857701f269Ted Kremenek QualType t, SourceLocation rparenloc) 93668bf91d31265b6ea8c3eb854ba450857701f269Ted Kremenek : CallExpr(C, CXXMemberCallExprClass, fn, args, numargs, t, rparenloc) {} 9488a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor 9588a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor /// getImplicitObjectArgument - Retrieves the implicit object 9688a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor /// argument for the member call. For example, in "x.f(5)", this 9788a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor /// operation would return "x". 9888a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor Expr *getImplicitObjectArgument(); 9988a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor 10000b98c229ef28a5e82943bb23d09fb46d24ca381Douglas Gregor virtual SourceRange getSourceRange() const; 10100b98c229ef28a5e82943bb23d09fb46d24ca381Douglas Gregor 1021eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump static bool classof(const Stmt *T) { 10388a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor return T->getStmtClass() == CXXMemberCallExprClass; 10488a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor } 10588a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor static bool classof(const CXXMemberCallExpr *) { return true; } 10688a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor}; 10788a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor 10849badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// CXXNamedCastExpr - Abstract class common to all of the C++ "named" 10949badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// casts, @c static_cast, @c dynamic_cast, @c reinterpret_cast, or @c 11049badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// const_cast. 11149badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// 11249badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// This abstract class is inherited by all of the classes 11349badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// representing "named" casts, e.g., CXXStaticCastExpr, 11449badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// CXXDynamicCastExpr, CXXReinterpretCastExpr, and CXXConstCastExpr. 11549badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregorclass CXXNamedCastExpr : public ExplicitCastExpr { 1161060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenekprivate: 1171060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek SourceLocation Loc; // the location of the casting op 11849badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor 11949badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregorprotected: 120c0a2fd8f092722c8f78b566ac4506a21437040e9Anders Carlsson CXXNamedCastExpr(StmtClass SC, QualType ty, CastKind kind, Expr *op, 121cdef2b75aa60cde1ca00e0aa3f89139ac89c6ae4Anders Carlsson QualType writtenTy, SourceLocation l) 122c0a2fd8f092722c8f78b566ac4506a21437040e9Anders Carlsson : ExplicitCastExpr(SC, ty, kind, op, writtenTy), Loc(l) {} 12349badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor 1241060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenekpublic: 12549badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor const char *getCastName() const; 12649badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor 127a3a7b8eea87c90a5a257f685749222b212ddaf36Douglas Gregor /// \brief Retrieve the location of the cast operator keyword, e.g., 128a3a7b8eea87c90a5a257f685749222b212ddaf36Douglas Gregor /// "static_cast". 129a3a7b8eea87c90a5a257f685749222b212ddaf36Douglas Gregor SourceLocation getOperatorLoc() const { return Loc; } 130a3a7b8eea87c90a5a257f685749222b212ddaf36Douglas Gregor void setOperatorLoc(SourceLocation L) { Loc = L; } 131a3a7b8eea87c90a5a257f685749222b212ddaf36Douglas Gregor 1321060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek virtual SourceRange getSourceRange() const { 1331060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek return SourceRange(Loc, getSubExpr()->getSourceRange().getEnd()); 1341060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek } 1351eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump static bool classof(const Stmt *T) { 13649badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor switch (T->getStmtClass()) { 13749badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor case CXXNamedCastExprClass: 13849badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor case CXXStaticCastExprClass: 13949badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor case CXXDynamicCastExprClass: 14049badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor case CXXReinterpretCastExprClass: 14149badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor case CXXConstCastExprClass: 14249badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor return true; 14349badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor default: 14449badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor return false; 14549badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor } 1461060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek } 14749badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor static bool classof(const CXXNamedCastExpr *) { return true; } 14849badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor}; 14949badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor 15049badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// CXXStaticCastExpr - A C++ @c static_cast expression (C++ [expr.static.cast]). 1511eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump/// 15249badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// This expression node represents a C++ static cast, e.g., 15349badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// @c static_cast<int>(1.0). 15449badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregorclass CXXStaticCastExpr : public CXXNamedCastExpr { 15549badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregorpublic: 156c0a2fd8f092722c8f78b566ac4506a21437040e9Anders Carlsson CXXStaticCastExpr(QualType ty, CastKind kind, Expr *op, 157bd0fb30fa2a039439d1a30a83ea896801394d780Anders Carlsson QualType writtenTy, SourceLocation l) 158c0a2fd8f092722c8f78b566ac4506a21437040e9Anders Carlsson : CXXNamedCastExpr(CXXStaticCastExprClass, ty, kind, op, writtenTy, l) {} 15949badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor 1601eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump static bool classof(const Stmt *T) { 16149badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor return T->getStmtClass() == CXXStaticCastExprClass; 16249badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor } 16349badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor static bool classof(const CXXStaticCastExpr *) { return true; } 16449badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor}; 16549badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor 16649badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// CXXDynamicCastExpr - A C++ @c dynamic_cast expression 1671eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump/// (C++ [expr.dynamic.cast]), which may perform a run-time check to 16849badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// determine how to perform the type cast. 1691eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump/// 17049badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// This expression node represents a dynamic cast, e.g., 17149badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// @c dynamic_cast<Derived*>(BasePtr). 17249badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregorclass CXXDynamicCastExpr : public CXXNamedCastExpr { 17349badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregorpublic: 1741eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump CXXDynamicCastExpr(QualType ty, CastKind kind, Expr *op, QualType writtenTy, 175cdef2b75aa60cde1ca00e0aa3f89139ac89c6ae4Anders Carlsson SourceLocation l) 176cdef2b75aa60cde1ca00e0aa3f89139ac89c6ae4Anders Carlsson : CXXNamedCastExpr(CXXDynamicCastExprClass, ty, kind, op, writtenTy, l) {} 17749badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor 1781eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump static bool classof(const Stmt *T) { 17949badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor return T->getStmtClass() == CXXDynamicCastExprClass; 18049badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor } 18149badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor static bool classof(const CXXDynamicCastExpr *) { return true; } 18249badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor}; 18349badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor 18449badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// CXXReinterpretCastExpr - A C++ @c reinterpret_cast expression (C++ 18549badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// [expr.reinterpret.cast]), which provides a differently-typed view 18649badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// of a value but performs no actual work at run time. 1871eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump/// 18849badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// This expression node represents a reinterpret cast, e.g., 18949badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// @c reinterpret_cast<int>(VoidPtr). 19049badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregorclass CXXReinterpretCastExpr : public CXXNamedCastExpr { 19149badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregorpublic: 1927f9e646b7ed47bc8e9a60031ad0c2b55031e2077Anders Carlsson CXXReinterpretCastExpr(QualType ty, CastKind kind, Expr *op, 1937f9e646b7ed47bc8e9a60031ad0c2b55031e2077Anders Carlsson QualType writtenTy, SourceLocation l) 1947f9e646b7ed47bc8e9a60031ad0c2b55031e2077Anders Carlsson : CXXNamedCastExpr(CXXReinterpretCastExprClass, ty, kind, op, 195cdef2b75aa60cde1ca00e0aa3f89139ac89c6ae4Anders Carlsson writtenTy, l) {} 19649badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor 1971eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump static bool classof(const Stmt *T) { 19849badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor return T->getStmtClass() == CXXReinterpretCastExprClass; 19949badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor } 20049badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor static bool classof(const CXXReinterpretCastExpr *) { return true; } 20149badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor}; 20249badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor 20349badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// CXXConstCastExpr - A C++ @c const_cast expression (C++ [expr.const.cast]), 20449badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// which can remove type qualifiers but does not change the underlying value. 2051eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump/// 20649badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// This expression node represents a const cast, e.g., 20749badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// @c const_cast<char*>(PtrToConstChar). 20849badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregorclass CXXConstCastExpr : public CXXNamedCastExpr { 20949badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregorpublic: 2101eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump CXXConstCastExpr(QualType ty, Expr *op, QualType writtenTy, 21149badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor SourceLocation l) 212cdef2b75aa60cde1ca00e0aa3f89139ac89c6ae4Anders Carlsson : CXXNamedCastExpr(CXXConstCastExprClass, ty, CK_NoOp, op, writtenTy, l) {} 21349badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor 2141eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump static bool classof(const Stmt *T) { 21549badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor return T->getStmtClass() == CXXConstCastExprClass; 21649badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor } 21749badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor static bool classof(const CXXConstCastExpr *) { return true; } 2181060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek}; 2191060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek 2201060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek/// CXXBoolLiteralExpr - [C++ 2.13.5] C++ Boolean Literal. 2211eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump/// 2221060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenekclass CXXBoolLiteralExpr : public Expr { 2231060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek bool Value; 2241060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek SourceLocation Loc; 2251060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenekpublic: 2261eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump CXXBoolLiteralExpr(bool val, QualType Ty, SourceLocation l) : 2271060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek Expr(CXXBoolLiteralExprClass, Ty), Value(val), Loc(l) {} 2288b0b475b3464b0f70b91ba7d679d23c424677d5eSebastian Redl 2291060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek bool getValue() const { return Value; } 2305f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 2311060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek virtual SourceRange getSourceRange() const { return SourceRange(Loc); } 2321eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 2331eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump static bool classof(const Stmt *T) { 2341060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek return T->getStmtClass() == CXXBoolLiteralExprClass; 2351060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek } 2361060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek static bool classof(const CXXBoolLiteralExpr *) { return true; } 2371eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 2381060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek // Iterators 2391060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek virtual child_iterator child_begin(); 2401060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek virtual child_iterator child_end(); 2411060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek}; 2421060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek 2436e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl/// CXXNullPtrLiteralExpr - [C++0x 2.14.7] C++ Pointer Literal 2446e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redlclass CXXNullPtrLiteralExpr : public Expr { 2456e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl SourceLocation Loc; 2466e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redlpublic: 2476e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl CXXNullPtrLiteralExpr(QualType Ty, SourceLocation l) : 2486e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl Expr(CXXNullPtrLiteralExprClass, Ty), Loc(l) {} 2496e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl 2506e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl virtual SourceRange getSourceRange() const { return SourceRange(Loc); } 2516e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl 2526e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl static bool classof(const Stmt *T) { 2536e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl return T->getStmtClass() == CXXNullPtrLiteralExprClass; 2546e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl } 2556e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl static bool classof(const CXXNullPtrLiteralExpr *) { return true; } 2566e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl 2576e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl virtual child_iterator child_begin(); 2586e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl virtual child_iterator child_end(); 2596e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl}; 2606e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl 261c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl/// CXXTypeidExpr - A C++ @c typeid expression (C++ [expr.typeid]), which gets 262c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl/// the type_info that corresponds to the supplied type, or the (possibly 263c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl/// dynamic) type of the supplied expression. 264c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl/// 265c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl/// This represents code like @c typeid(int) or @c typeid(*objPtr) 266c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redlclass CXXTypeidExpr : public Expr { 267c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redlprivate: 268c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl bool isTypeOp : 1; 269d457589fc69dc7a9c80cd74d317c0b81a35a27c9Sebastian Redl union { 270d457589fc69dc7a9c80cd74d317c0b81a35a27c9Sebastian Redl void *Ty; 271d457589fc69dc7a9c80cd74d317c0b81a35a27c9Sebastian Redl Stmt *Ex; 272d457589fc69dc7a9c80cd74d317c0b81a35a27c9Sebastian Redl } Operand; 273c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl SourceRange Range; 274c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl 275c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redlpublic: 276c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl CXXTypeidExpr(bool isTypeOp, void *op, QualType Ty, const SourceRange r) : 2772850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl Expr(CXXTypeidExprClass, Ty, 2782850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl // typeid is never type-dependent (C++ [temp.dep.expr]p4) 2792850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl false, 2802850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl // typeid is value-dependent if the type or expression are dependent 2812850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl (isTypeOp ? QualType::getFromOpaquePtr(op)->isDependentType() 2822850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl : static_cast<Expr*>(op)->isValueDependent())), 2832850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl isTypeOp(isTypeOp), Range(r) { 284d457589fc69dc7a9c80cd74d317c0b81a35a27c9Sebastian Redl if (isTypeOp) 285d457589fc69dc7a9c80cd74d317c0b81a35a27c9Sebastian Redl Operand.Ty = op; 286d457589fc69dc7a9c80cd74d317c0b81a35a27c9Sebastian Redl else 287d457589fc69dc7a9c80cd74d317c0b81a35a27c9Sebastian Redl // op was an Expr*, so cast it back to that to be safe 2882850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl Operand.Ex = static_cast<Expr*>(op); 289d457589fc69dc7a9c80cd74d317c0b81a35a27c9Sebastian Redl } 290c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl 291c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl bool isTypeOperand() const { return isTypeOp; } 292c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl QualType getTypeOperand() const { 293c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl assert(isTypeOperand() && "Cannot call getTypeOperand for typeid(expr)"); 294d457589fc69dc7a9c80cd74d317c0b81a35a27c9Sebastian Redl return QualType::getFromOpaquePtr(Operand.Ty); 295c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl } 296c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl Expr* getExprOperand() const { 297c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl assert(!isTypeOperand() && "Cannot call getExprOperand for typeid(type)"); 298d457589fc69dc7a9c80cd74d317c0b81a35a27c9Sebastian Redl return static_cast<Expr*>(Operand.Ex); 299c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl } 300c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl 301c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl virtual SourceRange getSourceRange() const { 302c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl return Range; 303c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl } 304c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl static bool classof(const Stmt *T) { 305c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl return T->getStmtClass() == CXXTypeidExprClass; 306c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl } 307c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl static bool classof(const CXXTypeidExpr *) { return true; } 308c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl 309c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl // Iterators 310c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl virtual child_iterator child_begin(); 311c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl virtual child_iterator child_end(); 312c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl}; 313c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl 314796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// CXXThisExpr - Represents the "this" expression in C++, which is a 315796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// pointer to the object on which the current member function is 316796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// executing (C++ [expr.prim]p3). Example: 317796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// 318796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// @code 319796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// class Foo { 320796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// public: 321796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// void bar(); 322796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// void test() { this->bar(); } 323796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// }; 324796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// @endcode 325796da18402f286b897782a298ae3b20c459c102eDouglas Gregorclass CXXThisExpr : public Expr { 326796da18402f286b897782a298ae3b20c459c102eDouglas Gregor SourceLocation Loc; 327796da18402f286b897782a298ae3b20c459c102eDouglas Gregor 328796da18402f286b897782a298ae3b20c459c102eDouglas Gregorpublic: 3291eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump CXXThisExpr(SourceLocation L, QualType Type) 3302850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl : Expr(CXXThisExprClass, Type, 3312850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl // 'this' is type-dependent if the class type of the enclosing 3322850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl // member function is dependent (C++ [temp.dep.expr]p2) 3332850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl Type->isDependentType(), Type->isDependentType()), 3342850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl Loc(L) { } 335796da18402f286b897782a298ae3b20c459c102eDouglas Gregor 336796da18402f286b897782a298ae3b20c459c102eDouglas Gregor virtual SourceRange getSourceRange() const { return SourceRange(Loc); } 337796da18402f286b897782a298ae3b20c459c102eDouglas Gregor 3381eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump static bool classof(const Stmt *T) { 339796da18402f286b897782a298ae3b20c459c102eDouglas Gregor return T->getStmtClass() == CXXThisExprClass; 340796da18402f286b897782a298ae3b20c459c102eDouglas Gregor } 341796da18402f286b897782a298ae3b20c459c102eDouglas Gregor static bool classof(const CXXThisExpr *) { return true; } 342796da18402f286b897782a298ae3b20c459c102eDouglas Gregor 343796da18402f286b897782a298ae3b20c459c102eDouglas Gregor // Iterators 344796da18402f286b897782a298ae3b20c459c102eDouglas Gregor virtual child_iterator child_begin(); 345796da18402f286b897782a298ae3b20c459c102eDouglas Gregor virtual child_iterator child_end(); 346796da18402f286b897782a298ae3b20c459c102eDouglas Gregor}; 347796da18402f286b897782a298ae3b20c459c102eDouglas Gregor 3481060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek/// CXXThrowExpr - [C++ 15] C++ Throw Expression. This handles 3491060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek/// 'throw' and 'throw' assignment-expression. When 3501060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek/// assignment-expression isn't present, Op will be null. 3511060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek/// 3521060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenekclass CXXThrowExpr : public Expr { 3531060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek Stmt *Op; 3541060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek SourceLocation ThrowLoc; 3551060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenekpublic: 3561060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek // Ty is the void type which is used as the result type of the 3571060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek // exepression. The l is the location of the throw keyword. expr 3581060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek // can by null, if the optional expression to throw isn't present. 3591060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek CXXThrowExpr(Expr *expr, QualType Ty, SourceLocation l) : 3602850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl Expr(CXXThrowExprClass, Ty, false, false), Op(expr), ThrowLoc(l) {} 3611060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek const Expr *getSubExpr() const { return cast_or_null<Expr>(Op); } 3621060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek Expr *getSubExpr() { return cast_or_null<Expr>(Op); } 36342e5b50f4dc897f252e0d476063a7f9846d96624Douglas Gregor void setSubExpr(Expr *E) { Op = E; } 36442e5b50f4dc897f252e0d476063a7f9846d96624Douglas Gregor 36542e5b50f4dc897f252e0d476063a7f9846d96624Douglas Gregor SourceLocation getThrowLoc() const { return ThrowLoc; } 36642e5b50f4dc897f252e0d476063a7f9846d96624Douglas Gregor void setThrowLoc(SourceLocation L) { ThrowLoc = L; } 3671060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek 3681060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek virtual SourceRange getSourceRange() const { 3691060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek if (getSubExpr() == 0) 3701060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek return SourceRange(ThrowLoc, ThrowLoc); 3711060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek return SourceRange(ThrowLoc, getSubExpr()->getSourceRange().getEnd()); 3721060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek } 3731060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek 3741060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek static bool classof(const Stmt *T) { 3751060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek return T->getStmtClass() == CXXThrowExprClass; 3761060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek } 3771060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek static bool classof(const CXXThrowExpr *) { return true; } 3781060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek 3791060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek // Iterators 3801060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek virtual child_iterator child_begin(); 3811060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek virtual child_iterator child_end(); 3821060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek}; 3831060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek 3841060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek/// CXXDefaultArgExpr - C++ [dcl.fct.default]. This wraps up a 3851060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek/// function call argument that was created from the corresponding 3861060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek/// parameter's default argument, when the call did not explicitly 3871060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek/// supply arguments for all of the parameters. 3881060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenekclass CXXDefaultArgExpr : public Expr { 3891060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek ParmVarDecl *Param; 3901eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 391f1480eee38b59d15438fb7bc50865ac7c7e22403Anders Carlssonprotected: 3921eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump CXXDefaultArgExpr(StmtClass SC, ParmVarDecl *param) 3931eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump : Expr(SC, param->hasUnparsedDefaultArg() ? 394f1480eee38b59d15438fb7bc50865ac7c7e22403Anders Carlsson param->getType().getNonReferenceType() 395f1480eee38b59d15438fb7bc50865ac7c7e22403Anders Carlsson : param->getDefaultArg()->getType()), 396f1480eee38b59d15438fb7bc50865ac7c7e22403Anders Carlsson Param(param) { } 3971eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 3981060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenekpublic: 3991060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek // Param is the parameter whose default argument is used by this 4001060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek // expression. 401f1480eee38b59d15438fb7bc50865ac7c7e22403Anders Carlsson static CXXDefaultArgExpr *Create(ASTContext &C, ParmVarDecl *Param) { 402f1480eee38b59d15438fb7bc50865ac7c7e22403Anders Carlsson return new (C) CXXDefaultArgExpr(CXXDefaultArgExprClass, Param); 403f1480eee38b59d15438fb7bc50865ac7c7e22403Anders Carlsson } 4041060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek 4051060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek // Retrieve the parameter that the argument was created from. 4061060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek const ParmVarDecl *getParam() const { return Param; } 4071060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek ParmVarDecl *getParam() { return Param; } 4081060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek 4091060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek // Retrieve the actual argument to the function call. 4101060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek const Expr *getExpr() const { return Param->getDefaultArg(); } 4111060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek Expr *getExpr() { return Param->getDefaultArg(); } 4121060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek 4131060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek virtual SourceRange getSourceRange() const { 4141060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek // Default argument expressions have no representation in the 4151060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek // source, so they have an empty source range. 4161060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek return SourceRange(); 4171060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek } 4181060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek 4191060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek static bool classof(const Stmt *T) { 4201060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek return T->getStmtClass() == CXXDefaultArgExprClass; 4211060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek } 4221060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek static bool classof(const CXXDefaultArgExpr *) { return true; } 4231060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek 4241060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek // Iterators 4251060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek virtual child_iterator child_begin(); 4261060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek virtual child_iterator child_end(); 4271060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek}; 428987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis 429c1ce477119fed070299668aab24084b17ff5f14bAnders Carlsson/// CXXTemporary - Represents a C++ temporary. 430c1ce477119fed070299668aab24084b17ff5f14bAnders Carlssonclass CXXTemporary { 431c1ce477119fed070299668aab24084b17ff5f14bAnders Carlsson /// Destructor - The destructor that needs to be called. 432b859f35459ae3e1188d1e1b86df08d649695fd86Anders Carlsson const CXXDestructorDecl *Destructor; 4331eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 434b859f35459ae3e1188d1e1b86df08d649695fd86Anders Carlsson CXXTemporary(const CXXDestructorDecl *destructor) 435c1ce477119fed070299668aab24084b17ff5f14bAnders Carlsson : Destructor(destructor) { } 43688eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlsson ~CXXTemporary() { } 437c1ce477119fed070299668aab24084b17ff5f14bAnders Carlsson 438c1ce477119fed070299668aab24084b17ff5f14bAnders Carlssonpublic: 4391eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump static CXXTemporary *Create(ASTContext &C, 440b859f35459ae3e1188d1e1b86df08d649695fd86Anders Carlsson const CXXDestructorDecl *Destructor); 4411eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 44242602bb40aefcc2751d4078ba88aacf4d965c9bdDouglas Gregor void Destroy(ASTContext &Ctx); 4431eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 444f0721fe438d7e40c168e5d664970e7830bc138fbAnders Carlsson const CXXDestructorDecl *getDestructor() const { return Destructor; } 445c1ce477119fed070299668aab24084b17ff5f14bAnders Carlsson}; 446fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson 4471eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump/// CXXBindTemporaryExpr - Represents binding an expression to a temporary, 448fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson/// so its destructor can be called later. 449fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlssonclass CXXBindTemporaryExpr : public Expr { 450fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson CXXTemporary *Temp; 4511eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 452fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson Stmt *SubExpr; 453fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson 4541eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump CXXBindTemporaryExpr(CXXTemporary *temp, Expr* subexpr) 455fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson : Expr(CXXBindTemporaryExprClass, 456fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson subexpr->getType()), Temp(temp), SubExpr(subexpr) { } 4571eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump ~CXXBindTemporaryExpr() { } 45888eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlsson 45942602bb40aefcc2751d4078ba88aacf4d965c9bdDouglas Gregorprotected: 46042602bb40aefcc2751d4078ba88aacf4d965c9bdDouglas Gregor virtual void DoDestroy(ASTContext &C); 46142602bb40aefcc2751d4078ba88aacf4d965c9bdDouglas Gregor 462fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlssonpublic: 4631eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump static CXXBindTemporaryExpr *Create(ASTContext &C, CXXTemporary *Temp, 464fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson Expr* SubExpr); 4651eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 46688eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlsson CXXTemporary *getTemporary() { return Temp; } 467f0721fe438d7e40c168e5d664970e7830bc138fbAnders Carlsson const CXXTemporary *getTemporary() const { return Temp; } 468f0721fe438d7e40c168e5d664970e7830bc138fbAnders Carlsson 469fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson const Expr *getSubExpr() const { return cast<Expr>(SubExpr); } 470fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson Expr *getSubExpr() { return cast<Expr>(SubExpr); } 47188eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlsson void setSubExpr(Expr *E) { SubExpr = E; } 472fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson 47396be6917e1c4ba1f4435a14c9e7c6c139571d086Douglas Gregor virtual SourceRange getSourceRange() const { 47496be6917e1c4ba1f4435a14c9e7c6c139571d086Douglas Gregor return SubExpr->getSourceRange(); 47596be6917e1c4ba1f4435a14c9e7c6c139571d086Douglas Gregor } 476fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson 477fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson // Implement isa/cast/dyncast/etc. 478fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson static bool classof(const Stmt *T) { 479fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson return T->getStmtClass() == CXXBindTemporaryExprClass; 480fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson } 481fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson static bool classof(const CXXBindTemporaryExpr *) { return true; } 482fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson 483fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson // Iterators 484fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson virtual child_iterator child_begin(); 485fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson virtual child_iterator child_end(); 486fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson}; 487fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson 48815ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson/// CXXConstructExpr - Represents a call to a C++ constructor. 48915ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlssonclass CXXConstructExpr : public Expr { 49015ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson CXXConstructorDecl *Constructor; 49115ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson 49215ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson bool Elidable; 4931eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 49415ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson Stmt **Args; 49515ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson unsigned NumArgs; 4961eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 497bd6734e5f6432ce0cc07171c490ffaa094796198Anders Carlssonprotected: 4981eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump CXXConstructExpr(ASTContext &C, StmtClass SC, QualType T, 499bd6734e5f6432ce0cc07171c490ffaa094796198Anders Carlsson CXXConstructorDecl *d, bool elidable, 500bd6734e5f6432ce0cc07171c490ffaa094796198Anders Carlsson Expr **args, unsigned numargs); 5011eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump ~CXXConstructExpr() { } 502bd6734e5f6432ce0cc07171c490ffaa094796198Anders Carlsson 50342602bb40aefcc2751d4078ba88aacf4d965c9bdDouglas Gregor virtual void DoDestroy(ASTContext &C); 50442602bb40aefcc2751d4078ba88aacf4d965c9bdDouglas Gregor 50515ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlssonpublic: 50639da0b8145eaec7da7004f9b3645c5c9f4f63b1dDouglas Gregor /// \brief Construct an empty C++ construction expression that will store 50739da0b8145eaec7da7004f9b3645c5c9f4f63b1dDouglas Gregor /// \p numargs arguments. 50839da0b8145eaec7da7004f9b3645c5c9f4f63b1dDouglas Gregor CXXConstructExpr(EmptyShell Empty, ASTContext &C, unsigned numargs); 50939da0b8145eaec7da7004f9b3645c5c9f4f63b1dDouglas Gregor 5108e587a15da6d3457a418239d5eb4146fcbd209f3Anders Carlsson static CXXConstructExpr *Create(ASTContext &C, QualType T, 5111eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump CXXConstructorDecl *D, bool Elidable, 51215ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson Expr **Args, unsigned NumArgs); 5131eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 5141eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 515d94546a0a1deef7286c13e49b9584621ae81cc9aDouglas Gregor CXXConstructorDecl* getConstructor() const { return Constructor; } 51639da0b8145eaec7da7004f9b3645c5c9f4f63b1dDouglas Gregor void setConstructor(CXXConstructorDecl *C) { Constructor = C; } 51739da0b8145eaec7da7004f9b3645c5c9f4f63b1dDouglas Gregor 518d94546a0a1deef7286c13e49b9584621ae81cc9aDouglas Gregor /// \brief Whether this construction is elidable. 519d94546a0a1deef7286c13e49b9584621ae81cc9aDouglas Gregor bool isElidable() const { return Elidable; } 52039da0b8145eaec7da7004f9b3645c5c9f4f63b1dDouglas Gregor void setElidable(bool E) { Elidable = E; } 52139da0b8145eaec7da7004f9b3645c5c9f4f63b1dDouglas Gregor 52215ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson typedef ExprIterator arg_iterator; 52315ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson typedef ConstExprIterator const_arg_iterator; 5241eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 52515ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson arg_iterator arg_begin() { return Args; } 52615ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson arg_iterator arg_end() { return Args + NumArgs; } 52715ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson const_arg_iterator arg_begin() const { return Args; } 52815ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson const_arg_iterator arg_end() const { return Args + NumArgs; } 52915ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson 53015ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson unsigned getNumArgs() const { return NumArgs; } 53115ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson 532bcb11d01c034f967503bd98f28bdf458c1ab8001Anders Carlsson /// getArg - Return the specified argument. 533bcb11d01c034f967503bd98f28bdf458c1ab8001Anders Carlsson Expr *getArg(unsigned Arg) { 534bcb11d01c034f967503bd98f28bdf458c1ab8001Anders Carlsson assert(Arg < NumArgs && "Arg access out of range!"); 535bcb11d01c034f967503bd98f28bdf458c1ab8001Anders Carlsson return cast<Expr>(Args[Arg]); 536bcb11d01c034f967503bd98f28bdf458c1ab8001Anders Carlsson } 537bcb11d01c034f967503bd98f28bdf458c1ab8001Anders Carlsson const Expr *getArg(unsigned Arg) const { 538bcb11d01c034f967503bd98f28bdf458c1ab8001Anders Carlsson assert(Arg < NumArgs && "Arg access out of range!"); 539bcb11d01c034f967503bd98f28bdf458c1ab8001Anders Carlsson return cast<Expr>(Args[Arg]); 540bcb11d01c034f967503bd98f28bdf458c1ab8001Anders Carlsson } 5411eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 5422eeed7bc4fd457ac57ff32ab3b02674588545f65Fariborz Jahanian /// setArg - Set the specified argument. 5432eeed7bc4fd457ac57ff32ab3b02674588545f65Fariborz Jahanian void setArg(unsigned Arg, Expr *ArgExpr) { 5442eeed7bc4fd457ac57ff32ab3b02674588545f65Fariborz Jahanian assert(Arg < NumArgs && "Arg access out of range!"); 5452eeed7bc4fd457ac57ff32ab3b02674588545f65Fariborz Jahanian Args[Arg] = ArgExpr; 5462eeed7bc4fd457ac57ff32ab3b02674588545f65Fariborz Jahanian } 5472eeed7bc4fd457ac57ff32ab3b02674588545f65Fariborz Jahanian 54896be6917e1c4ba1f4435a14c9e7c6c139571d086Douglas Gregor virtual SourceRange getSourceRange() const { 54996be6917e1c4ba1f4435a14c9e7c6c139571d086Douglas Gregor // FIXME: Should we know where the parentheses are, if there are any? 55096be6917e1c4ba1f4435a14c9e7c6c139571d086Douglas Gregor if (NumArgs == 0) 55196be6917e1c4ba1f4435a14c9e7c6c139571d086Douglas Gregor return SourceRange(); 55296be6917e1c4ba1f4435a14c9e7c6c139571d086Douglas Gregor 55396be6917e1c4ba1f4435a14c9e7c6c139571d086Douglas Gregor return SourceRange(Args[0]->getLocStart(), Args[NumArgs - 1]->getLocEnd()); 55496be6917e1c4ba1f4435a14c9e7c6c139571d086Douglas Gregor } 55515ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson 5561eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump static bool classof(const Stmt *T) { 557524fa13fd81e88533c7a1d4b1232c0de2c97dc7cAnders Carlsson return T->getStmtClass() == CXXConstructExprClass || 558524fa13fd81e88533c7a1d4b1232c0de2c97dc7cAnders Carlsson T->getStmtClass() == CXXTemporaryObjectExprClass; 55915ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson } 56015ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson static bool classof(const CXXConstructExpr *) { return true; } 5611eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 56215ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson // Iterators 56315ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson virtual child_iterator child_begin(); 56415ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson virtual child_iterator child_end(); 56515ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson}; 56615ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson 56749badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// CXXFunctionalCastExpr - Represents an explicit C++ type conversion 56849badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// that uses "functional" notion (C++ [expr.type.conv]). Example: @c 56949badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// x = int(0.5); 57049badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregorclass CXXFunctionalCastExpr : public ExplicitCastExpr { 571987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis SourceLocation TyBeginLoc; 572987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis SourceLocation RParenLoc; 573987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidispublic: 5741eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump CXXFunctionalCastExpr(QualType ty, QualType writtenTy, 5751eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump SourceLocation tyBeginLoc, CastKind kind, 5760aebc81e02397a5987aaa8e8c7acbdb01a31d7c3Anders Carlsson Expr *castExpr, SourceLocation rParenLoc) 5770aebc81e02397a5987aaa8e8c7acbdb01a31d7c3Anders Carlsson : ExplicitCastExpr(CXXFunctionalCastExprClass, ty, kind, castExpr, 5780aebc81e02397a5987aaa8e8c7acbdb01a31d7c3Anders Carlsson writtenTy), 5790aebc81e02397a5987aaa8e8c7acbdb01a31d7c3Anders Carlsson TyBeginLoc(tyBeginLoc), RParenLoc(rParenLoc) {} 5800aebc81e02397a5987aaa8e8c7acbdb01a31d7c3Anders Carlsson 581987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis SourceLocation getTypeBeginLoc() const { return TyBeginLoc; } 582987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis SourceLocation getRParenLoc() const { return RParenLoc; } 5831eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 584987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis virtual SourceRange getSourceRange() const { 585987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis return SourceRange(TyBeginLoc, RParenLoc); 586987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis } 5871eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump static bool classof(const Stmt *T) { 5881eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump return T->getStmtClass() == CXXFunctionalCastExprClass; 589987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis } 590987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis static bool classof(const CXXFunctionalCastExpr *) { return true; } 591987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis}; 592987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis 593506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// @brief Represents a C++ functional cast expression that builds a 594506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// temporary object. 595506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// 5961eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump/// This expression type represents a C++ "functional" cast 597506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// (C++[expr.type.conv]) with N != 1 arguments that invokes a 598506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// constructor to build a temporary object. If N == 0 but no 599506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// constructor will be called (because the functional cast is 600506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// performing a value-initialized an object whose class type has no 601506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// user-declared constructors), CXXZeroInitValueExpr will represent 602506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// the functional cast. Finally, with N == 1 arguments the functional 603506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// cast expression will be represented by CXXFunctionalCastExpr. 604506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// Example: 605506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// @code 606506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// struct X { X(int, float); } 607506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// 608506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// X create_X() { 609506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// return X(1, 3.14f); // creates a CXXTemporaryObjectExpr 610506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// }; 611506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// @endcode 612524fa13fd81e88533c7a1d4b1232c0de2c97dc7cAnders Carlssonclass CXXTemporaryObjectExpr : public CXXConstructExpr { 613506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor SourceLocation TyBeginLoc; 614506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor SourceLocation RParenLoc; 615506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor 616506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregorpublic: 6171eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump CXXTemporaryObjectExpr(ASTContext &C, CXXConstructorDecl *Cons, 6181eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump QualType writtenTy, SourceLocation tyBeginLoc, 6191eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump Expr **Args,unsigned NumArgs, 6208e587a15da6d3457a418239d5eb4146fcbd209f3Anders Carlsson SourceLocation rParenLoc); 621506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor 6221eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump ~CXXTemporaryObjectExpr() { } 623506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor 624506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor SourceLocation getTypeBeginLoc() const { return TyBeginLoc; } 625506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor SourceLocation getRParenLoc() const { return RParenLoc; } 626ba49817c5b9f502602672861cf369fd0e53966e8Douglas Gregor 627506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor virtual SourceRange getSourceRange() const { 628506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor return SourceRange(TyBeginLoc, RParenLoc); 629506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor } 6301eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump static bool classof(const Stmt *T) { 631506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor return T->getStmtClass() == CXXTemporaryObjectExprClass; 632506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor } 633506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor static bool classof(const CXXTemporaryObjectExpr *) { return true; } 634506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor}; 635506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor 636987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis/// CXXZeroInitValueExpr - [C++ 5.2.3p2] 637506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// Expression "T()" which creates a value-initialized rvalue of type 638506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// T, which is either a non-class type or a class type without any 639506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// user-defined constructors. 640987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis/// 641987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidisclass CXXZeroInitValueExpr : public Expr { 642987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis SourceLocation TyBeginLoc; 643987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis SourceLocation RParenLoc; 644987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis 645987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidispublic: 646987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis CXXZeroInitValueExpr(QualType ty, SourceLocation tyBeginLoc, 6471eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump SourceLocation rParenLoc ) : 648d94546a0a1deef7286c13e49b9584621ae81cc9aDouglas Gregor Expr(CXXZeroInitValueExprClass, ty, false, false), 649987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis TyBeginLoc(tyBeginLoc), RParenLoc(rParenLoc) {} 6501eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 651987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis SourceLocation getTypeBeginLoc() const { return TyBeginLoc; } 652987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis SourceLocation getRParenLoc() const { return RParenLoc; } 653987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis 6544c67834407ca6ab344dcf44fc599ad4938cfa96dDouglas Gregor /// @brief Whether this initialization expression was 6554c67834407ca6ab344dcf44fc599ad4938cfa96dDouglas Gregor /// implicitly-generated. 6561eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump bool isImplicit() const { 6571eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump return TyBeginLoc.isInvalid() && RParenLoc.isInvalid(); 6584c67834407ca6ab344dcf44fc599ad4938cfa96dDouglas Gregor } 6594c67834407ca6ab344dcf44fc599ad4938cfa96dDouglas Gregor 660987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis virtual SourceRange getSourceRange() const { 661987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis return SourceRange(TyBeginLoc, RParenLoc); 662987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis } 6631eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 6641eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump static bool classof(const Stmt *T) { 665987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis return T->getStmtClass() == CXXZeroInitValueExprClass; 666987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis } 667987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis static bool classof(const CXXZeroInitValueExpr *) { return true; } 6681eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 669987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis // Iterators 670987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis virtual child_iterator child_begin(); 671987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis virtual child_iterator child_end(); 672987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis}; 673987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis 6749e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis/// CXXConditionDeclExpr - Condition declaration of a if/switch/while/for 6759e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis/// statement, e.g: "if (int x = f()) {...}". 6769e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis/// The main difference with DeclRefExpr is that CXXConditionDeclExpr owns the 6779e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis/// decl that it references. 6789e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis/// 6799e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidisclass CXXConditionDeclExpr : public DeclRefExpr { 6809e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidispublic: 6819e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis CXXConditionDeclExpr(SourceLocation startLoc, 6829e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis SourceLocation eqLoc, VarDecl *var) 6831eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump : DeclRefExpr(CXXConditionDeclExprClass, var, 6844a2e2041edc63db687677325e113b39b9d123c40Douglas Gregor var->getType().getNonReferenceType(), startLoc, 6854a2e2041edc63db687677325e113b39b9d123c40Douglas Gregor var->getType()->isDependentType(), 6864a2e2041edc63db687677325e113b39b9d123c40Douglas Gregor /*FIXME:integral constant?*/ 6874a2e2041edc63db687677325e113b39b9d123c40Douglas Gregor var->getType()->isDependentType()) {} 6889e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis 6899e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis SourceLocation getStartLoc() const { return getLocation(); } 6901eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 6919e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis VarDecl *getVarDecl() { return cast<VarDecl>(getDecl()); } 6929e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis const VarDecl *getVarDecl() const { return cast<VarDecl>(getDecl()); } 6939e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis 6949e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis virtual SourceRange getSourceRange() const { 6959e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis return SourceRange(getStartLoc(), getVarDecl()->getInit()->getLocEnd()); 6969e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis } 6971eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 6981eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump static bool classof(const Stmt *T) { 6999e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis return T->getStmtClass() == CXXConditionDeclExprClass; 7009e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis } 7019e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis static bool classof(const CXXConditionDeclExpr *) { return true; } 7021eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 7039e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis // Iterators 7049e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis virtual child_iterator child_begin(); 7059e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis virtual child_iterator child_end(); 7069e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis}; 7079e922b1663ecb95dc7eee03002fd66ed18fb3192Argyrios Kyrtzidis 7084c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl/// CXXNewExpr - A new expression for memory allocation and constructor calls, 7094c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl/// e.g: "new CXXNewExpr(foo)". 7104c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redlclass CXXNewExpr : public Expr { 7114c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // Was the usage ::new, i.e. is the global new to be used? 7124c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl bool GlobalNew : 1; 7134c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // Was the form (type-id) used? Otherwise, it was new-type-id. 7144c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl bool ParenTypeId : 1; 7154c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // Is there an initializer? If not, built-ins are uninitialized, else they're 7164c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // value-initialized. 7174c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl bool Initializer : 1; 718cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl // Do we allocate an array? If so, the first SubExpr is the size expression. 719cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl bool Array : 1; 7204c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // The number of placement new arguments. 7214c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl unsigned NumPlacementArgs : 14; 7224c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // The number of constructor arguments. This may be 1 even for non-class 7234c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // types; use the pseudo copy constructor. 724cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl unsigned NumConstructorArgs : 14; 725cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl // Contains an optional array size expression, any number of optional 726cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl // placement arguments, and any number of optional constructor arguments, 727cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl // in that order. 7284c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl Stmt **SubExprs; 7294c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // Points to the allocation function used. 7304c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl FunctionDecl *OperatorNew; 7314c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // Points to the deallocation function used in case of error. May be null. 7324c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl FunctionDecl *OperatorDelete; 7334c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // Points to the constructor used. Cannot be null if AllocType is a record; 7344c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // it would still point at the default constructor (even an implicit one). 7354c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // Must be null for all other types. 7364c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl CXXConstructorDecl *Constructor; 7374c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 7384c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl SourceLocation StartLoc; 7394c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl SourceLocation EndLoc; 7404c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 7414c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redlpublic: 7424c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl CXXNewExpr(bool globalNew, FunctionDecl *operatorNew, Expr **placementArgs, 743cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl unsigned numPlaceArgs, bool ParenTypeId, Expr *arraySize, 7444c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl CXXConstructorDecl *constructor, bool initializer, 7454c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl Expr **constructorArgs, unsigned numConsArgs, 7464c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl FunctionDecl *operatorDelete, QualType ty, 7474c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl SourceLocation startLoc, SourceLocation endLoc); 7484c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl ~CXXNewExpr() { 7494c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl delete[] SubExprs; 7504c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 7514c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 752cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl QualType getAllocatedType() const { 753cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl assert(getType()->isPointerType()); 7546217b80b7a1379b74cced1c076338262c3c980b3Ted Kremenek return getType()->getAs<PointerType>()->getPointeeType(); 755cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl } 7564c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 7574c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl FunctionDecl *getOperatorNew() const { return OperatorNew; } 7584c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl FunctionDecl *getOperatorDelete() const { return OperatorDelete; } 7594c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl CXXConstructorDecl *getConstructor() const { return Constructor; } 7604c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 761cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl bool isArray() const { return Array; } 762cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl Expr *getArraySize() { 763cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl return Array ? cast<Expr>(SubExprs[0]) : 0; 764cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl } 765cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl const Expr *getArraySize() const { 766cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl return Array ? cast<Expr>(SubExprs[0]) : 0; 767cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl } 768cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl 7694c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl unsigned getNumPlacementArgs() const { return NumPlacementArgs; } 7704c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl Expr *getPlacementArg(unsigned i) { 7714c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl assert(i < NumPlacementArgs && "Index out of range"); 772cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl return cast<Expr>(SubExprs[Array + i]); 7734c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 7744c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl const Expr *getPlacementArg(unsigned i) const { 7754c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl assert(i < NumPlacementArgs && "Index out of range"); 776cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl return cast<Expr>(SubExprs[Array + i]); 7774c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 7784c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 7794c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl bool isGlobalNew() const { return GlobalNew; } 7804c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl bool isParenTypeId() const { return ParenTypeId; } 7814c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl bool hasInitializer() const { return Initializer; } 7824c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 7834c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl unsigned getNumConstructorArgs() const { return NumConstructorArgs; } 7844c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl Expr *getConstructorArg(unsigned i) { 7854c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl assert(i < NumConstructorArgs && "Index out of range"); 786cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl return cast<Expr>(SubExprs[Array + NumPlacementArgs + i]); 7874c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 7884c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl const Expr *getConstructorArg(unsigned i) const { 7894c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl assert(i < NumConstructorArgs && "Index out of range"); 790cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl return cast<Expr>(SubExprs[Array + NumPlacementArgs + i]); 7914c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 7924c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 7934c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl typedef ExprIterator arg_iterator; 7944c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl typedef ConstExprIterator const_arg_iterator; 7954c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 7964c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl arg_iterator placement_arg_begin() { 797cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl return SubExprs + Array; 7984c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 7994c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl arg_iterator placement_arg_end() { 800cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl return SubExprs + Array + getNumPlacementArgs(); 8014c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 8024c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl const_arg_iterator placement_arg_begin() const { 803cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl return SubExprs + Array; 8044c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 8054c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl const_arg_iterator placement_arg_end() const { 806cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl return SubExprs + Array + getNumPlacementArgs(); 8074c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 8084c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 8094c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl arg_iterator constructor_arg_begin() { 810cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl return SubExprs + Array + getNumPlacementArgs(); 8114c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 8124c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl arg_iterator constructor_arg_end() { 813cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl return SubExprs + Array + getNumPlacementArgs() + getNumConstructorArgs(); 8144c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 8154c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl const_arg_iterator constructor_arg_begin() const { 816cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl return SubExprs + Array + getNumPlacementArgs(); 8174c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 8184c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl const_arg_iterator constructor_arg_end() const { 819cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl return SubExprs + Array + getNumPlacementArgs() + getNumConstructorArgs(); 8204c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 8214c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 8224c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl virtual SourceRange getSourceRange() const { 8234c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl return SourceRange(StartLoc, EndLoc); 8244c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 8254c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 8264c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl static bool classof(const Stmt *T) { 8274c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl return T->getStmtClass() == CXXNewExprClass; 8284c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 8294c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl static bool classof(const CXXNewExpr *) { return true; } 8304c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 8314c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // Iterators 8324c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl virtual child_iterator child_begin(); 8334c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl virtual child_iterator child_end(); 8344c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl}; 8354c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 8364c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl/// CXXDeleteExpr - A delete expression for memory deallocation and destructor 8374c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl/// calls, e.g. "delete[] pArray". 8384c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redlclass CXXDeleteExpr : public Expr { 8394c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // Is this a forced global delete, i.e. "::delete"? 8404c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl bool GlobalDelete : 1; 8414c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // Is this the array form of delete, i.e. "delete[]"? 8424c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl bool ArrayForm : 1; 8434c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // Points to the operator delete overload that is used. Could be a member. 8444c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl FunctionDecl *OperatorDelete; 8454c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // The pointer expression to be deleted. 8464c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl Stmt *Argument; 8474c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // Location of the expression. 8484c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl SourceLocation Loc; 8494c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redlpublic: 8504c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl CXXDeleteExpr(QualType ty, bool globalDelete, bool arrayForm, 8514c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl FunctionDecl *operatorDelete, Expr *arg, SourceLocation loc) 8522850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl : Expr(CXXDeleteExprClass, ty, false, false), GlobalDelete(globalDelete), 8534c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl ArrayForm(arrayForm), OperatorDelete(operatorDelete), Argument(arg), 8544c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl Loc(loc) { } 8554c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 8564c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl bool isGlobalDelete() const { return GlobalDelete; } 8574c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl bool isArrayForm() const { return ArrayForm; } 8584c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 8594c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl FunctionDecl *getOperatorDelete() const { return OperatorDelete; } 8604c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 8614c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl Expr *getArgument() { return cast<Expr>(Argument); } 8624c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl const Expr *getArgument() const { return cast<Expr>(Argument); } 8634c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 8644c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl virtual SourceRange getSourceRange() const { 8654c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl return SourceRange(Loc, Argument->getLocEnd()); 8664c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 8674c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 8684c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl static bool classof(const Stmt *T) { 8694c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl return T->getStmtClass() == CXXDeleteExprClass; 8704c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 8714c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl static bool classof(const CXXDeleteExpr *) { return true; } 8724c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 8734c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // Iterators 8744c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl virtual child_iterator child_begin(); 8754c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl virtual child_iterator child_end(); 8764c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl}; 8774c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 878a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor/// \brief Represents a C++ pseudo-destructor (C++ [expr.pseudo]). 879a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor/// 880a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor/// Example: 881a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor/// 882a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor/// \code 8831eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump/// template<typename T> 884a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor/// void destroy(T* ptr) { 885a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor/// ptr->~T(); 886a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor/// } 887a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor/// \endcode 888a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor/// 889a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor/// When the template is parsed, the expression \c ptr->~T will be stored as 890a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor/// a member reference expression. If it then instantiated with a scalar type 8911eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump/// as a template argument for T, the resulting expression will be a 892a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor/// pseudo-destructor expression. 893a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregorclass CXXPseudoDestructorExpr : public Expr { 894a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor /// \brief The base expression (that is being destroyed). 895a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor Stmt *Base; 8961eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 897a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor /// \brief Whether the operator was an arrow ('->'); otherwise, it was a 898a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor /// period ('.'). 899a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor bool IsArrow : 1; 9001eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 901a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor /// \brief The location of the '.' or '->' operator. 902a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor SourceLocation OperatorLoc; 9031eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 904a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor /// \brief The nested-name-specifier that follows the operator, if present. 905a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor NestedNameSpecifier *Qualifier; 9061eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 9071eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump /// \brief The source range that covers the nested-name-specifier, if 908a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor /// present. 909a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor SourceRange QualifierRange; 9101eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 911a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor /// \brief The type being destroyed. 912a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor QualType DestroyedType; 9131eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 914a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor /// \brief The location of the type after the '~'. 915a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor SourceLocation DestroyedTypeLoc; 9161eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 917a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregorpublic: 918a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor CXXPseudoDestructorExpr(ASTContext &Context, 919a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor Expr *Base, bool isArrow, SourceLocation OperatorLoc, 920a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor NestedNameSpecifier *Qualifier, 921a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor SourceRange QualifierRange, 9221eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump QualType DestroyedType, 923a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor SourceLocation DestroyedTypeLoc) 9241eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump : Expr(CXXPseudoDestructorExprClass, 925a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor Context.getPointerType(Context.getFunctionType(Context.VoidTy, 0, 0, 926a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor false, 0)), 927a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor /*isTypeDependent=*/false, 928a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor /*isValueDependent=*/Base->isValueDependent()), 9291eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump Base(static_cast<Stmt *>(Base)), IsArrow(isArrow), 930a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor OperatorLoc(OperatorLoc), Qualifier(Qualifier), 931a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor QualifierRange(QualifierRange), DestroyedType(DestroyedType), 932a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor DestroyedTypeLoc(DestroyedTypeLoc) { } 9331eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 934a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor void setBase(Expr *E) { Base = E; } 935a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor Expr *getBase() const { return cast<Expr>(Base); } 9361eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 9371eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump /// \brief Determines whether this member expression actually had 938a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor /// a C++ nested-name-specifier prior to the name of the member, e.g., 939a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor /// x->Base::foo. 940a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor bool hasQualifier() const { return Qualifier != 0; } 9411eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 942a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor /// \brief If the member name was qualified, retrieves the source range of 943a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor /// the nested-name-specifier that precedes the member name. Otherwise, 944a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor /// returns an empty source range. 945a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor SourceRange getQualifierRange() const { return QualifierRange; } 9461eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 9471eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump /// \brief If the member name was qualified, retrieves the 948a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor /// nested-name-specifier that precedes the member name. Otherwise, returns 949a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor /// NULL. 950a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor NestedNameSpecifier *getQualifier() const { return Qualifier; } 9511eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 952a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor /// \brief Determine whether this pseudo-destructor expression was written 953a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor /// using an '->' (otherwise, it used a '.'). 954a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor bool isArrow() const { return IsArrow; } 955a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor void setArrow(bool A) { IsArrow = A; } 956a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor 957a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor /// \brief Retrieve the location of the '.' or '->' operator. 958a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor SourceLocation getOperatorLoc() const { return OperatorLoc; } 9591eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 960a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor /// \brief Retrieve the type that is being destroyed. 961a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor QualType getDestroyedType() const { return DestroyedType; } 9621eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 963a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor /// \brief Retrieve the location of the type being destroyed. 964a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor SourceLocation getDestroyedTypeLoc() const { return DestroyedTypeLoc; } 9651eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 966a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor virtual SourceRange getSourceRange() const { 967a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor return SourceRange(Base->getLocStart(), DestroyedTypeLoc); 968a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor } 9691eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 9701eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump static bool classof(const Stmt *T) { 971a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor return T->getStmtClass() == CXXPseudoDestructorExprClass; 972a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor } 973a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor static bool classof(const CXXPseudoDestructorExpr *) { return true; } 9741eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 975a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor // Iterators 976a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor virtual child_iterator child_begin(); 9771eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump virtual child_iterator child_end(); 978a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor}; 9791eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 98064b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl/// UnaryTypeTraitExpr - A GCC or MS unary type trait, as used in the 98164b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl/// implementation of TR1/C++0x type trait templates. 98264b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl/// Example: 98364b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl/// __is_pod(int) == true 98464b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl/// __is_enum(std::string) == false 98564b45f7e0d3167f040841ac2920aead7f080730dSebastian Redlclass UnaryTypeTraitExpr : public Expr { 98664b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl /// UTT - The trait. 98764b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl UnaryTypeTrait UTT; 98864b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl 98964b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl /// Loc - The location of the type trait keyword. 99064b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl SourceLocation Loc; 99164b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl 99264b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl /// RParen - The location of the closing paren. 99364b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl SourceLocation RParen; 99464b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl 99564b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl /// QueriedType - The type we're testing. 99664b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl QualType QueriedType; 99764b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl 99864b45f7e0d3167f040841ac2920aead7f080730dSebastian Redlpublic: 99964b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl UnaryTypeTraitExpr(SourceLocation loc, UnaryTypeTrait utt, QualType queried, 100064b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl SourceLocation rparen, QualType ty) 100164b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl : Expr(UnaryTypeTraitExprClass, ty, false, queried->isDependentType()), 100264b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl UTT(utt), Loc(loc), RParen(rparen), QueriedType(queried) { } 100364b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl 100464b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl virtual SourceRange getSourceRange() const { return SourceRange(Loc, RParen);} 100564b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl 100664b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl UnaryTypeTrait getTrait() const { return UTT; } 100764b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl 100864b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl QualType getQueriedType() const { return QueriedType; } 100964b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl 10105e03f9ea8174ae588c5e69ec6b5ef4c68f8fd766Douglas Gregor bool EvaluateTrait(ASTContext&) const; 101164b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl 101264b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl static bool classof(const Stmt *T) { 101364b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl return T->getStmtClass() == UnaryTypeTraitExprClass; 101464b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl } 101564b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl static bool classof(const UnaryTypeTraitExpr *) { return true; } 101664b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl 101764b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl // Iterators 101864b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl virtual child_iterator child_begin(); 101964b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl virtual child_iterator child_end(); 102064b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl}; 102164b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl 1022ba13543329afac4a0d01304ec2ec4924d99306a6John McCall/// \brief A reference to a name which we were able to look up during 1023ba13543329afac4a0d01304ec2ec4924d99306a6John McCall/// parsing but could not resolve to a specific declaration. This 1024ba13543329afac4a0d01304ec2ec4924d99306a6John McCall/// arises in several ways: 1025ba13543329afac4a0d01304ec2ec4924d99306a6John McCall/// * we might be waiting for argument-dependent lookup 1026ba13543329afac4a0d01304ec2ec4924d99306a6John McCall/// * the name might resolve to an overloaded function 1027ba13543329afac4a0d01304ec2ec4924d99306a6John McCall/// and eventually: 1028ba13543329afac4a0d01304ec2ec4924d99306a6John McCall/// * the lookup might have included a function template 1029ba13543329afac4a0d01304ec2ec4924d99306a6John McCall/// These never include UnresolvedUsingValueDecls, which are always 1030ba13543329afac4a0d01304ec2ec4924d99306a6John McCall/// class members and therefore appear only in 1031ba13543329afac4a0d01304ec2ec4924d99306a6John McCall/// UnresolvedMemberLookupExprs. 1032ba13543329afac4a0d01304ec2ec4924d99306a6John McCallclass UnresolvedLookupExpr : public Expr { 1033ba13543329afac4a0d01304ec2ec4924d99306a6John McCall /// The results. These are undesugared, which is to say, they may 1034ba13543329afac4a0d01304ec2ec4924d99306a6John McCall /// include UsingShadowDecls. 1035ba13543329afac4a0d01304ec2ec4924d99306a6John McCall UnresolvedSet Results; 1036ba13543329afac4a0d01304ec2ec4924d99306a6John McCall 1037ba13543329afac4a0d01304ec2ec4924d99306a6John McCall /// The name declared. 1038ba13543329afac4a0d01304ec2ec4924d99306a6John McCall DeclarationName Name; 1039ba13543329afac4a0d01304ec2ec4924d99306a6John McCall 1040ba13543329afac4a0d01304ec2ec4924d99306a6John McCall /// The qualifier given, if any. 1041ba13543329afac4a0d01304ec2ec4924d99306a6John McCall NestedNameSpecifier *Qualifier; 1042ba13543329afac4a0d01304ec2ec4924d99306a6John McCall 1043ba13543329afac4a0d01304ec2ec4924d99306a6John McCall /// The source range of the nested name specifier. 1044ba13543329afac4a0d01304ec2ec4924d99306a6John McCall SourceRange QualifierRange; 1045ba13543329afac4a0d01304ec2ec4924d99306a6John McCall 1046ba13543329afac4a0d01304ec2ec4924d99306a6John McCall /// The location of the name. 1047ba13543329afac4a0d01304ec2ec4924d99306a6John McCall SourceLocation NameLoc; 1048ba13543329afac4a0d01304ec2ec4924d99306a6John McCall 1049ba13543329afac4a0d01304ec2ec4924d99306a6John McCall /// True if these lookup results should be extended by 1050ba13543329afac4a0d01304ec2ec4924d99306a6John McCall /// argument-dependent lookup if this is the operand of a function 1051ba13543329afac4a0d01304ec2ec4924d99306a6John McCall /// call. 1052ba13543329afac4a0d01304ec2ec4924d99306a6John McCall bool RequiresADL; 1053ba13543329afac4a0d01304ec2ec4924d99306a6John McCall 10547453ed4cb2cab113de3378df371b1c6f1243d832John McCall /// True if these lookup results are overloaded. This is pretty 10557453ed4cb2cab113de3378df371b1c6f1243d832John McCall /// trivially rederivable if we urgently need to kill this field. 10567453ed4cb2cab113de3378df371b1c6f1243d832John McCall bool Overloaded; 10577453ed4cb2cab113de3378df371b1c6f1243d832John McCall 1058ba13543329afac4a0d01304ec2ec4924d99306a6John McCall UnresolvedLookupExpr(QualType T, 1059ba13543329afac4a0d01304ec2ec4924d99306a6John McCall NestedNameSpecifier *Qualifier, SourceRange QRange, 1060ba13543329afac4a0d01304ec2ec4924d99306a6John McCall DeclarationName Name, SourceLocation NameLoc, 10617453ed4cb2cab113de3378df371b1c6f1243d832John McCall bool RequiresADL, bool Overloaded) 1062ba13543329afac4a0d01304ec2ec4924d99306a6John McCall : Expr(UnresolvedLookupExprClass, T, false, false), 1063ba13543329afac4a0d01304ec2ec4924d99306a6John McCall Name(Name), Qualifier(Qualifier), QualifierRange(QRange), 10647453ed4cb2cab113de3378df371b1c6f1243d832John McCall NameLoc(NameLoc), RequiresADL(RequiresADL), Overloaded(Overloaded) 1065ba13543329afac4a0d01304ec2ec4924d99306a6John McCall {} 1066ba13543329afac4a0d01304ec2ec4924d99306a6John McCall 1067ba13543329afac4a0d01304ec2ec4924d99306a6John McCallpublic: 1068ba13543329afac4a0d01304ec2ec4924d99306a6John McCall static UnresolvedLookupExpr *Create(ASTContext &C, 1069ba13543329afac4a0d01304ec2ec4924d99306a6John McCall NestedNameSpecifier *Qualifier, 1070ba13543329afac4a0d01304ec2ec4924d99306a6John McCall SourceRange QualifierRange, 1071ba13543329afac4a0d01304ec2ec4924d99306a6John McCall DeclarationName Name, 1072ba13543329afac4a0d01304ec2ec4924d99306a6John McCall SourceLocation NameLoc, 10737453ed4cb2cab113de3378df371b1c6f1243d832John McCall bool ADL, bool Overloaded) { 1074ba13543329afac4a0d01304ec2ec4924d99306a6John McCall return new(C) UnresolvedLookupExpr(C.OverloadTy, Qualifier, QualifierRange, 10757453ed4cb2cab113de3378df371b1c6f1243d832John McCall Name, NameLoc, ADL, Overloaded); 1076ba13543329afac4a0d01304ec2ec4924d99306a6John McCall } 1077ba13543329afac4a0d01304ec2ec4924d99306a6John McCall 1078ba13543329afac4a0d01304ec2ec4924d99306a6John McCall void addDecl(NamedDecl *Decl) { 1079ba13543329afac4a0d01304ec2ec4924d99306a6John McCall Results.addDecl(Decl); 1080ba13543329afac4a0d01304ec2ec4924d99306a6John McCall } 1081ba13543329afac4a0d01304ec2ec4924d99306a6John McCall 1082ba13543329afac4a0d01304ec2ec4924d99306a6John McCall typedef UnresolvedSet::iterator decls_iterator; 1083ba13543329afac4a0d01304ec2ec4924d99306a6John McCall decls_iterator decls_begin() const { return Results.begin(); } 1084ba13543329afac4a0d01304ec2ec4924d99306a6John McCall decls_iterator decls_end() const { return Results.end(); } 1085ba13543329afac4a0d01304ec2ec4924d99306a6John McCall 1086ba13543329afac4a0d01304ec2ec4924d99306a6John McCall /// True if this declaration should be extended by 1087ba13543329afac4a0d01304ec2ec4924d99306a6John McCall /// argument-dependent lookup. 1088ba13543329afac4a0d01304ec2ec4924d99306a6John McCall bool requiresADL() const { return RequiresADL; } 1089ba13543329afac4a0d01304ec2ec4924d99306a6John McCall 10907453ed4cb2cab113de3378df371b1c6f1243d832John McCall /// True if this lookup is overloaded. 10917453ed4cb2cab113de3378df371b1c6f1243d832John McCall bool isOverloaded() const { return Overloaded; } 10927453ed4cb2cab113de3378df371b1c6f1243d832John McCall 1093ba13543329afac4a0d01304ec2ec4924d99306a6John McCall /// Fetches the name looked up. 1094ba13543329afac4a0d01304ec2ec4924d99306a6John McCall DeclarationName getName() const { return Name; } 1095ba13543329afac4a0d01304ec2ec4924d99306a6John McCall 1096ba13543329afac4a0d01304ec2ec4924d99306a6John McCall /// Gets the location of the name. 1097ba13543329afac4a0d01304ec2ec4924d99306a6John McCall SourceLocation getNameLoc() const { return NameLoc; } 1098ba13543329afac4a0d01304ec2ec4924d99306a6John McCall 1099ba13543329afac4a0d01304ec2ec4924d99306a6John McCall /// Fetches the nested-name qualifier, if one was given. 1100ba13543329afac4a0d01304ec2ec4924d99306a6John McCall NestedNameSpecifier *getQualifier() const { return Qualifier; } 1101ba13543329afac4a0d01304ec2ec4924d99306a6John McCall 1102ba13543329afac4a0d01304ec2ec4924d99306a6John McCall /// Fetches the range of the nested-name qualifier. 1103ba13543329afac4a0d01304ec2ec4924d99306a6John McCall SourceRange getQualifierRange() const { return QualifierRange; } 1104ba13543329afac4a0d01304ec2ec4924d99306a6John McCall 1105ba13543329afac4a0d01304ec2ec4924d99306a6John McCall 1106ba13543329afac4a0d01304ec2ec4924d99306a6John McCall virtual SourceRange getSourceRange() const { 1107ba13543329afac4a0d01304ec2ec4924d99306a6John McCall if (Qualifier) return SourceRange(QualifierRange.getBegin(), NameLoc); 1108ba13543329afac4a0d01304ec2ec4924d99306a6John McCall return SourceRange(NameLoc, NameLoc); 1109ba13543329afac4a0d01304ec2ec4924d99306a6John McCall } 1110ba13543329afac4a0d01304ec2ec4924d99306a6John McCall 1111ba13543329afac4a0d01304ec2ec4924d99306a6John McCall virtual StmtIterator child_begin(); 1112ba13543329afac4a0d01304ec2ec4924d99306a6John McCall virtual StmtIterator child_end(); 1113ba13543329afac4a0d01304ec2ec4924d99306a6John McCall 1114ba13543329afac4a0d01304ec2ec4924d99306a6John McCall static bool classof(const Stmt *T) { 1115ba13543329afac4a0d01304ec2ec4924d99306a6John McCall return T->getStmtClass() == UnresolvedLookupExprClass; 1116ba13543329afac4a0d01304ec2ec4924d99306a6John McCall } 1117ba13543329afac4a0d01304ec2ec4924d99306a6John McCall static bool classof(const UnresolvedLookupExpr *) { return true; } 1118ba13543329afac4a0d01304ec2ec4924d99306a6John McCall}; 1119ba13543329afac4a0d01304ec2ec4924d99306a6John McCall 11205953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor/// \brief A qualified reference to a name whose declaration cannot 11215953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor/// yet be resolved. 11225953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor/// 1123ba13543329afac4a0d01304ec2ec4924d99306a6John McCall/// DependentScopeDeclRefExpr is similar to DeclRefExpr in that 1124a2813cec2605ce7878d1b13471d685f689b251afDouglas Gregor/// it expresses a reference to a declaration such as 11255953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor/// X<T>::value. The difference, however, is that an 1126865d447ac6a4721ab58e898d014a21f2eff74b06John McCall/// DependentScopeDeclRefExpr node is used only within C++ templates when 11275953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor/// the qualification (e.g., X<T>::) refers to a dependent type. In 11285953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor/// this case, X<T>::value cannot resolve to a declaration because the 11295953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor/// declaration will differ from on instantiation of X<T> to the 1130865d447ac6a4721ab58e898d014a21f2eff74b06John McCall/// next. Therefore, DependentScopeDeclRefExpr keeps track of the 1131ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor/// qualifier (X<T>::) and the name of the entity being referenced 1132a2813cec2605ce7878d1b13471d685f689b251afDouglas Gregor/// ("value"). Such expressions will instantiate to a DeclRefExpr once the 1133a2813cec2605ce7878d1b13471d685f689b251afDouglas Gregor/// declaration can be found. 1134865d447ac6a4721ab58e898d014a21f2eff74b06John McCallclass DependentScopeDeclRefExpr : public Expr { 11355953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor /// The name of the entity we will be referencing. 11365953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor DeclarationName Name; 11375953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor 11385953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor /// Location of the name of the declaration we're referencing. 11395953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor SourceLocation Loc; 11405953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor 11415953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor /// QualifierRange - The source range that covers the 11425953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor /// nested-name-specifier. 11435953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor SourceRange QualifierRange; 11445953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor 1145ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor /// \brief The nested-name-specifier that qualifies this unresolved 1146ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor /// declaration name. 1147ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor NestedNameSpecifier *NNS; 11485953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor 11499b31df4acdeeb61bb084a03fc37bc5bd570a659eAnders Carlsson /// \brief Whether this expr is an address of (&) operand. 1150a2813cec2605ce7878d1b13471d685f689b251afDouglas Gregor /// FIXME: Stash this bit into NNS! 11519b31df4acdeeb61bb084a03fc37bc5bd570a659eAnders Carlsson bool IsAddressOfOperand; 11521eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 11535953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregorpublic: 1154865d447ac6a4721ab58e898d014a21f2eff74b06John McCall DependentScopeDeclRefExpr(DeclarationName N, QualType T, SourceLocation L, 1155865d447ac6a4721ab58e898d014a21f2eff74b06John McCall SourceRange R, NestedNameSpecifier *NNS, 1156865d447ac6a4721ab58e898d014a21f2eff74b06John McCall bool IsAddressOfOperand) 1157865d447ac6a4721ab58e898d014a21f2eff74b06John McCall : Expr(DependentScopeDeclRefExprClass, T, true, true), 11581eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump Name(N), Loc(L), QualifierRange(R), NNS(NNS), 11599b31df4acdeeb61bb084a03fc37bc5bd570a659eAnders Carlsson IsAddressOfOperand(IsAddressOfOperand) { } 11605953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor 11615953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor /// \brief Retrieve the name that this expression refers to. 11625953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor DeclarationName getDeclName() const { return Name; } 11635953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor 11645953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor /// \brief Retrieve the location of the name within the expression. 11655953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor SourceLocation getLocation() const { return Loc; } 11665953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor 11675953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor /// \brief Retrieve the source range of the nested-name-specifier. 11685953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor SourceRange getQualifierRange() const { return QualifierRange; } 11695953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor 1170ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor /// \brief Retrieve the nested-name-specifier that qualifies this 1171ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor /// declaration. 1172ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor NestedNameSpecifier *getQualifier() const { return NNS; } 11735953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor 11749b31df4acdeeb61bb084a03fc37bc5bd570a659eAnders Carlsson /// \brief Retrieve whether this is an address of (&) operand. 11751eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 11769b31df4acdeeb61bb084a03fc37bc5bd570a659eAnders Carlsson bool isAddressOfOperand() const { return IsAddressOfOperand; } 11771eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump virtual SourceRange getSourceRange() const { 11781eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump return SourceRange(QualifierRange.getBegin(), getLocation()); 11795953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor } 11805953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor 11815953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor static bool classof(const Stmt *T) { 1182865d447ac6a4721ab58e898d014a21f2eff74b06John McCall return T->getStmtClass() == DependentScopeDeclRefExprClass; 11835953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor } 1184865d447ac6a4721ab58e898d014a21f2eff74b06John McCall static bool classof(const DependentScopeDeclRefExpr *) { return true; } 11855953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor 11865953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor virtual StmtIterator child_begin(); 11875953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor virtual StmtIterator child_end(); 11885953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor}; 11895953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor 11901eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump/// \brief An expression that refers to a C++ template-id, such as 11911eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump/// @c isa<FunctionDecl>. 1192edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregorclass TemplateIdRefExpr : public Expr { 1193edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor /// \brief If this template-id was qualified-id, e.g., @c std::sort<int>, 1194edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor /// this nested name specifier contains the @c std::. 1195edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor NestedNameSpecifier *Qualifier; 11961eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1197edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor /// \brief If this template-id was a qualified-id, e.g., @c std::sort<int>, 1198edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor /// this covers the source code range of the @c std::. 1199edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor SourceRange QualifierRange; 12001eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1201edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor /// \brief The actual template to which this template-id refers. 1202edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor TemplateName Template; 12031eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1204edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor /// \brief The source location of the template name. 1205edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor SourceLocation TemplateNameLoc; 1206edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor 1207edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor /// \brief The source location of the left angle bracket ('<'); 1208edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor SourceLocation LAngleLoc; 12091eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1210edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor /// \brief The source location of the right angle bracket ('>'); 1211edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor SourceLocation RAngleLoc; 12121eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1213edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor /// \brief The number of template arguments in TemplateArgs. 1214edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor unsigned NumTemplateArgs; 12151eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1216edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor TemplateIdRefExpr(QualType T, 1217edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor NestedNameSpecifier *Qualifier, SourceRange QualifierRange, 1218edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor TemplateName Template, SourceLocation TemplateNameLoc, 1219d5532b6cfff2977e0c59fa6ead7f7973984a620dJohn McCall const TemplateArgumentListInfo &TemplateArgs); 12201eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 122142602bb40aefcc2751d4078ba88aacf4d965c9bdDouglas Gregor virtual void DoDestroy(ASTContext &Context); 12221eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1223edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregorpublic: 1224edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor static TemplateIdRefExpr * 1225edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor Create(ASTContext &Context, QualType T, 1226edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor NestedNameSpecifier *Qualifier, SourceRange QualifierRange, 1227edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor TemplateName Template, SourceLocation TemplateNameLoc, 1228d5532b6cfff2977e0c59fa6ead7f7973984a620dJohn McCall const TemplateArgumentListInfo &TemplateArgs); 12291eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1230edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor /// \brief Retrieve the nested name specifier used to qualify the name of 1231edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor /// this template-id, e.g., the "std::sort" in @c std::sort<int>, or NULL 1232edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor /// if this template-id was an unqualified-id. 1233edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor NestedNameSpecifier *getQualifier() const { return Qualifier; } 12341eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1235edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor /// \brief Retrieve the source range describing the nested name specifier 1236edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor /// used to qualified the name of this template-id, if the name was qualified. 1237edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor SourceRange getQualifierRange() const { return QualifierRange; } 12381eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1239edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor /// \brief Retrieve the name of the template referenced, e.g., "sort" in 1240edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor /// @c std::sort<int>; 1241edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor TemplateName getTemplateName() const { return Template; } 12421eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1243edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor /// \brief Retrieve the location of the name of the template referenced, e.g., 1244edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor /// the location of "sort" in @c std::sort<int>. 1245edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor SourceLocation getTemplateNameLoc() const { return TemplateNameLoc; } 12461eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 12471eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump /// \brief Retrieve the location of the left angle bracket following the 1248edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor /// template name ('<'). 1249edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor SourceLocation getLAngleLoc() const { return LAngleLoc; } 12501eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1251edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor /// \brief Retrieve the template arguments provided as part of this 1252edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor /// template-id. 1253833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall const TemplateArgumentLoc *getTemplateArgs() const { 1254833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall return reinterpret_cast<const TemplateArgumentLoc *>(this + 1); 1255edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor } 12561eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1257edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor /// \brief Retrieve the number of template arguments provided as part of this 1258edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor /// template-id. 1259edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor unsigned getNumTemplateArgs() const { return NumTemplateArgs; } 12601eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1261d5532b6cfff2977e0c59fa6ead7f7973984a620dJohn McCall /// \brief Copies the template-argument information into the given 1262d5532b6cfff2977e0c59fa6ead7f7973984a620dJohn McCall /// structure. 1263d5532b6cfff2977e0c59fa6ead7f7973984a620dJohn McCall void copyTemplateArgumentsInto(TemplateArgumentListInfo &Info) const { 1264d5532b6cfff2977e0c59fa6ead7f7973984a620dJohn McCall Info.setLAngleLoc(LAngleLoc); 1265d5532b6cfff2977e0c59fa6ead7f7973984a620dJohn McCall Info.setRAngleLoc(RAngleLoc); 1266d5532b6cfff2977e0c59fa6ead7f7973984a620dJohn McCall for (unsigned i = 0; i < NumTemplateArgs; ++i) 1267d5532b6cfff2977e0c59fa6ead7f7973984a620dJohn McCall Info.addArgument(getTemplateArgs()[i]); 1268d5532b6cfff2977e0c59fa6ead7f7973984a620dJohn McCall } 1269d5532b6cfff2977e0c59fa6ead7f7973984a620dJohn McCall 12701eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump /// \brief Retrieve the location of the right angle bracket following the 1271edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor /// template arguments ('>'). 1272edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor SourceLocation getRAngleLoc() const { return RAngleLoc; } 12731eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1274edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor virtual SourceRange getSourceRange() const { 1275edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor return SourceRange(Qualifier? QualifierRange.getBegin() : TemplateNameLoc, 1276edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor RAngleLoc); 1277edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor } 12781eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1279edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor // Iterators 1280edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor virtual child_iterator child_begin(); 1281edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor virtual child_iterator child_end(); 12821eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 12831eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump static bool classof(const Stmt *T) { 1284edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor return T->getStmtClass() == TemplateIdRefExprClass; 1285edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor } 1286edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor static bool classof(const TemplateIdRefExpr *) { return true; } 1287edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor}; 12881eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 12892d44e8a41de8a33c0f04ac198714f71dc841bab0Anders Carlssonclass CXXExprWithTemporaries : public Expr { 129002bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson Stmt *SubExpr; 12911eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1292ff6b3d64c9f07155f1414411b8451d7bf8937c62Anders Carlsson CXXTemporary **Temps; 1293ff6b3d64c9f07155f1414411b8451d7bf8937c62Anders Carlsson unsigned NumTemps; 129402bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson 1295f54741e6465692d3bdbae974ac3beeeab92e4a95Anders Carlsson bool ShouldDestroyTemps; 12961eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 12971eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump CXXExprWithTemporaries(Expr *SubExpr, CXXTemporary **Temps, 1298f54741e6465692d3bdbae974ac3beeeab92e4a95Anders Carlsson unsigned NumTemps, bool ShouldDestroyTemps); 12992d44e8a41de8a33c0f04ac198714f71dc841bab0Anders Carlsson ~CXXExprWithTemporaries(); 130042602bb40aefcc2751d4078ba88aacf4d965c9bdDouglas Gregor 130142602bb40aefcc2751d4078ba88aacf4d965c9bdDouglas Gregorprotected: 130242602bb40aefcc2751d4078ba88aacf4d965c9bdDouglas Gregor virtual void DoDestroy(ASTContext &C); 130342602bb40aefcc2751d4078ba88aacf4d965c9bdDouglas Gregor 130488eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlssonpublic: 130588eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlsson static CXXExprWithTemporaries *Create(ASTContext &C, Expr *SubExpr, 1306f54741e6465692d3bdbae974ac3beeeab92e4a95Anders Carlsson CXXTemporary **Temps, unsigned NumTemps, 1307f54741e6465692d3bdbae974ac3beeeab92e4a95Anders Carlsson bool ShouldDestroyTemporaries); 13081eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 130988eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlsson unsigned getNumTemporaries() const { return NumTemps; } 131088eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlsson CXXTemporary *getTemporary(unsigned i) { 131188eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlsson assert(i < NumTemps && "Index out of range"); 131288eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlsson return Temps[i]; 131388eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlsson } 1314f0721fe438d7e40c168e5d664970e7830bc138fbAnders Carlsson const CXXTemporary *getTemporary(unsigned i) const { 1315f0721fe438d7e40c168e5d664970e7830bc138fbAnders Carlsson assert(i < NumTemps && "Index out of range"); 1316f0721fe438d7e40c168e5d664970e7830bc138fbAnders Carlsson return Temps[i]; 1317f0721fe438d7e40c168e5d664970e7830bc138fbAnders Carlsson } 13181eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1319f54741e6465692d3bdbae974ac3beeeab92e4a95Anders Carlsson bool shouldDestroyTemporaries() const { return ShouldDestroyTemps; } 13201eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 132188eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlsson void removeLastTemporary() { NumTemps--; } 13221eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 132302bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson Expr *getSubExpr() { return cast<Expr>(SubExpr); } 1324f0721fe438d7e40c168e5d664970e7830bc138fbAnders Carlsson const Expr *getSubExpr() const { return cast<Expr>(SubExpr); } 132588eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlsson void setSubExpr(Expr *E) { SubExpr = E; } 132602bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson 132796be6917e1c4ba1f4435a14c9e7c6c139571d086Douglas Gregor virtual SourceRange getSourceRange() const { 132896be6917e1c4ba1f4435a14c9e7c6c139571d086Douglas Gregor return SubExpr->getSourceRange(); 132996be6917e1c4ba1f4435a14c9e7c6c139571d086Douglas Gregor } 133002bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson 133102bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson // Implement isa/cast/dyncast/etc. 133202bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson static bool classof(const Stmt *T) { 13332d44e8a41de8a33c0f04ac198714f71dc841bab0Anders Carlsson return T->getStmtClass() == CXXExprWithTemporariesClass; 133402bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson } 13352d44e8a41de8a33c0f04ac198714f71dc841bab0Anders Carlsson static bool classof(const CXXExprWithTemporaries *) { return true; } 133602bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson 133702bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson // Iterators 133802bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson virtual child_iterator child_begin(); 133902bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson virtual child_iterator child_end(); 134002bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson}; 134102bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson 1342d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// \brief Describes an explicit type conversion that uses functional 1343d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// notion but could not be resolved because one or more arguments are 1344d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// type-dependent. 1345d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// 1346d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// The explicit type conversions expressed by 1347d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// CXXUnresolvedConstructExpr have the form \c T(a1, a2, ..., aN), 1348d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// where \c T is some type and \c a1, a2, ..., aN are values, and 1349d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// either \C T is a dependent type or one or more of the \c a's is 1350d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// type-dependent. For example, this would occur in a template such 1351d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// as: 1352d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// 1353d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// \code 1354d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// template<typename T, typename A1> 1355d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// inline T make_a(const A1& a1) { 1356d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// return T(a1); 1357d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// } 1358d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// \endcode 1359d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// 1360d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// When the returned expression is instantiated, it may resolve to a 1361d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// constructor call, conversion function call, or some kind of type 1362d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// conversion. 1363d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregorclass CXXUnresolvedConstructExpr : public Expr { 1364d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor /// \brief The starting location of the type 1365d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor SourceLocation TyBeginLoc; 1366d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor 1367d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor /// \brief The type being constructed. 1368d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor QualType Type; 1369d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor 1370d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor /// \brief The location of the left parentheses ('('). 1371d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor SourceLocation LParenLoc; 1372d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor 1373d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor /// \brief The location of the right parentheses (')'). 1374d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor SourceLocation RParenLoc; 1375d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor 1376d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor /// \brief The number of arguments used to construct the type. 1377d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor unsigned NumArgs; 13781eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1379d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor CXXUnresolvedConstructExpr(SourceLocation TyBegin, 1380d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor QualType T, 1381d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor SourceLocation LParenLoc, 1382d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor Expr **Args, 1383d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor unsigned NumArgs, 1384d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor SourceLocation RParenLoc); 1385d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor 1386d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregorpublic: 13871eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump static CXXUnresolvedConstructExpr *Create(ASTContext &C, 1388d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor SourceLocation TyBegin, 1389d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor QualType T, 1390d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor SourceLocation LParenLoc, 1391d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor Expr **Args, 1392d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor unsigned NumArgs, 1393d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor SourceLocation RParenLoc); 1394d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor 1395d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor /// \brief Retrieve the source location where the type begins. 1396d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor SourceLocation getTypeBeginLoc() const { return TyBeginLoc; } 1397d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor void setTypeBeginLoc(SourceLocation L) { TyBeginLoc = L; } 1398d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor 1399d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor /// \brief Retrieve the type that is being constructed, as specified 1400d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor /// in the source code. 1401d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor QualType getTypeAsWritten() const { return Type; } 1402d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor void setTypeAsWritten(QualType T) { Type = T; } 1403d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor 1404d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor /// \brief Retrieve the location of the left parentheses ('(') that 1405d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor /// precedes the argument list. 1406d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor SourceLocation getLParenLoc() const { return LParenLoc; } 1407d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor void setLParenLoc(SourceLocation L) { LParenLoc = L; } 1408d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor 1409d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor /// \brief Retrieve the location of the right parentheses (')') that 1410d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor /// follows the argument list. 1411d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor SourceLocation getRParenLoc() const { return RParenLoc; } 1412d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor void setRParenLoc(SourceLocation L) { RParenLoc = L; } 1413d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor 1414d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor /// \brief Retrieve the number of arguments. 1415d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor unsigned arg_size() const { return NumArgs; } 1416d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor 1417d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor typedef Expr** arg_iterator; 1418d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor arg_iterator arg_begin() { return reinterpret_cast<Expr**>(this + 1); } 1419d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor arg_iterator arg_end() { return arg_begin() + NumArgs; } 1420d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor 1421d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor Expr *getArg(unsigned I) { 1422d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor assert(I < NumArgs && "Argument index out-of-range"); 1423d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor return *(arg_begin() + I); 1424d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor } 1425d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor 1426d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor virtual SourceRange getSourceRange() const { 1427d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor return SourceRange(TyBeginLoc, RParenLoc); 1428d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor } 14291eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump static bool classof(const Stmt *T) { 1430d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor return T->getStmtClass() == CXXUnresolvedConstructExprClass; 1431d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor } 1432d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor static bool classof(const CXXUnresolvedConstructExpr *) { return true; } 1433d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor 1434d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor // Iterators 1435d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor virtual child_iterator child_begin(); 1436d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor virtual child_iterator child_end(); 1437d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor}; 1438d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor 1439ba13543329afac4a0d01304ec2ec4924d99306a6John McCall/// \brief Represents a C++ member access expression where the actual 1440ba13543329afac4a0d01304ec2ec4924d99306a6John McCall/// member referenced could not be resolved because the base 1441ba13543329afac4a0d01304ec2ec4924d99306a6John McCall/// expression or the member name was dependent. 1442865d447ac6a4721ab58e898d014a21f2eff74b06John McCallclass CXXDependentScopeMemberExpr : public Expr { 14431c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor /// \brief The expression for the base pointer or class reference, 14441c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor /// e.g., the \c x in x.f. 14451c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor Stmt *Base; 14461eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 14471c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor /// \brief Whether this member expression used the '->' operator or 14481c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor /// the '.' operator. 14493b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor bool IsArrow : 1; 14501c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor 14513b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor /// \brief Whether this member expression has explicitly-specified template 14523b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor /// arguments. 14533b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor bool HasExplicitTemplateArgumentList : 1; 14541eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 14551c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor /// \brief The location of the '->' or '.' operator. 14561c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor SourceLocation OperatorLoc; 14571c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor 1458a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor /// \brief The nested-name-specifier that precedes the member name, if any. 1459a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor NestedNameSpecifier *Qualifier; 14601eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1461a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor /// \brief The source range covering the nested name specifier. 1462a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor SourceRange QualifierRange; 14631eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1464c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor /// \brief In a qualified member access expression such as t->Base::f, this 14651eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump /// member stores the resolves of name lookup in the context of the member 1466c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor /// access expression, to be used at instantiation time. 1467c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor /// 1468c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor /// FIXME: This member, along with the Qualifier and QualifierRange, could 1469c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor /// be stuck into a structure that is optionally allocated at the end of 1470865d447ac6a4721ab58e898d014a21f2eff74b06John McCall /// the CXXDependentScopeMemberExpr, to save space in the common case. 1471c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor NamedDecl *FirstQualifierFoundInScope; 14721eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 14731c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor /// \brief The member to which this member expression refers, which 14741c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor /// can be name, overloaded operator, or destructor. 1475a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor /// FIXME: could also be a template-id 14761c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor DeclarationName Member; 14771c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor 14781c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor /// \brief The location of the member name. 14791c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor SourceLocation MemberLoc; 14801eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 14813b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor /// \brief Retrieve the explicit template argument list that followed the 14823b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor /// member template name, if any. 14833b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor ExplicitTemplateArgumentList *getExplicitTemplateArgumentList() { 14843b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor if (!HasExplicitTemplateArgumentList) 14853b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor return 0; 14861eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 14873b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor return reinterpret_cast<ExplicitTemplateArgumentList *>(this + 1); 14883b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor } 14891eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 14903b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor /// \brief Retrieve the explicit template argument list that followed the 14913b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor /// member template name, if any. 14923b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor const ExplicitTemplateArgumentList *getExplicitTemplateArgumentList() const { 1493865d447ac6a4721ab58e898d014a21f2eff74b06John McCall return const_cast<CXXDependentScopeMemberExpr *>(this) 14943b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor ->getExplicitTemplateArgumentList(); 14953b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor } 14961eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1497865d447ac6a4721ab58e898d014a21f2eff74b06John McCall CXXDependentScopeMemberExpr(ASTContext &C, 14981eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump Expr *Base, bool IsArrow, 14993b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor SourceLocation OperatorLoc, 15003b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor NestedNameSpecifier *Qualifier, 15013b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor SourceRange QualifierRange, 15023b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor NamedDecl *FirstQualifierFoundInScope, 15033b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor DeclarationName Member, 15043b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor SourceLocation MemberLoc, 1505d5532b6cfff2977e0c59fa6ead7f7973984a620dJohn McCall const TemplateArgumentListInfo *TemplateArgs); 15061eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 15071c0ca59416999129d0439c2661d137ef38e86209Douglas Gregorpublic: 1508865d447ac6a4721ab58e898d014a21f2eff74b06John McCall CXXDependentScopeMemberExpr(ASTContext &C, 15091eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump Expr *Base, bool IsArrow, 15101c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor SourceLocation OperatorLoc, 1511a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor NestedNameSpecifier *Qualifier, 1512a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor SourceRange QualifierRange, 1513c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor NamedDecl *FirstQualifierFoundInScope, 15141c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor DeclarationName Member, 15151c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor SourceLocation MemberLoc) 1516865d447ac6a4721ab58e898d014a21f2eff74b06John McCall : Expr(CXXDependentScopeMemberExprClass, C.DependentTy, true, true), 15173b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor Base(Base), IsArrow(IsArrow), HasExplicitTemplateArgumentList(false), 15183b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor OperatorLoc(OperatorLoc), 15193b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor Qualifier(Qualifier), QualifierRange(QualifierRange), 15203b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor FirstQualifierFoundInScope(FirstQualifierFoundInScope), 15213b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor Member(Member), MemberLoc(MemberLoc) { } 15221eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1523865d447ac6a4721ab58e898d014a21f2eff74b06John McCall static CXXDependentScopeMemberExpr * 15241eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump Create(ASTContext &C, 15251eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump Expr *Base, bool IsArrow, 15263b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor SourceLocation OperatorLoc, 15273b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor NestedNameSpecifier *Qualifier, 15283b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor SourceRange QualifierRange, 15293b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor NamedDecl *FirstQualifierFoundInScope, 15303b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor DeclarationName Member, 15313b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor SourceLocation MemberLoc, 1532d5532b6cfff2977e0c59fa6ead7f7973984a620dJohn McCall const TemplateArgumentListInfo *TemplateArgs); 15331eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 15341c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor /// \brief Retrieve the base object of this member expressions, 15351c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor /// e.g., the \c x in \c x.m. 15361c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor Expr *getBase() { return cast<Expr>(Base); } 15371c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor void setBase(Expr *E) { Base = E; } 15381c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor 15391c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor /// \brief Determine whether this member expression used the '->' 15401c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor /// operator; otherwise, it used the '.' operator. 15411c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor bool isArrow() const { return IsArrow; } 15421c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor void setArrow(bool A) { IsArrow = A; } 15431c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor 15441c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor /// \brief Retrieve the location of the '->' or '.' operator. 15451c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor SourceLocation getOperatorLoc() const { return OperatorLoc; } 15461c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor void setOperatorLoc(SourceLocation L) { OperatorLoc = L; } 15471c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor 1548a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor /// \brief Retrieve the nested-name-specifier that qualifies the member 1549a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor /// name. 1550a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor NestedNameSpecifier *getQualifier() const { return Qualifier; } 15511eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1552a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor /// \brief Retrieve the source range covering the nested-name-specifier 1553a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor /// that qualifies the member name. 1554a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor SourceRange getQualifierRange() const { return QualifierRange; } 15551eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1556c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor /// \brief Retrieve the first part of the nested-name-specifier that was 1557c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor /// found in the scope of the member access expression when the member access 1558c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor /// was initially parsed. 1559c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor /// 1560c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor /// This function only returns a useful result when member access expression 15611eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump /// uses a qualified member name, e.g., "x.Base::f". Here, the declaration 15621eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump /// returned by this function describes what was found by unqualified name 1563c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor /// lookup for the identifier "Base" within the scope of the member access 1564c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor /// expression itself. At template instantiation time, this information is 1565c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor /// combined with the results of name lookup into the type of the object 1566c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor /// expression itself (the class type of x). 15671eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump NamedDecl *getFirstQualifierFoundInScope() const { 1568c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor return FirstQualifierFoundInScope; 1569c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor } 15701eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 15711c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor /// \brief Retrieve the name of the member that this expression 15721c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor /// refers to. 15731c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor DeclarationName getMember() const { return Member; } 15741c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor void setMember(DeclarationName N) { Member = N; } 15751c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor 15761c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor // \brief Retrieve the location of the name of the member that this 15771c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor // expression refers to. 15781c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor SourceLocation getMemberLoc() const { return MemberLoc; } 15791c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor void setMemberLoc(SourceLocation L) { MemberLoc = L; } 15801c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor 15813b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor /// \brief Determines whether this member expression actually had a C++ 15823b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor /// template argument list explicitly specified, e.g., x.f<int>. 1583d5532b6cfff2977e0c59fa6ead7f7973984a620dJohn McCall bool hasExplicitTemplateArgumentList() const { 15841eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump return HasExplicitTemplateArgumentList; 15853b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor } 15861eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1587d5532b6cfff2977e0c59fa6ead7f7973984a620dJohn McCall /// \brief Copies the template arguments (if present) into the given 1588d5532b6cfff2977e0c59fa6ead7f7973984a620dJohn McCall /// structure. 1589d5532b6cfff2977e0c59fa6ead7f7973984a620dJohn McCall void copyTemplateArgumentsInto(TemplateArgumentListInfo &List) const { 1590d5532b6cfff2977e0c59fa6ead7f7973984a620dJohn McCall if (hasExplicitTemplateArgumentList()) 1591d5532b6cfff2977e0c59fa6ead7f7973984a620dJohn McCall getExplicitTemplateArgumentList()->copyInto(List); 1592d5532b6cfff2977e0c59fa6ead7f7973984a620dJohn McCall } 1593d5532b6cfff2977e0c59fa6ead7f7973984a620dJohn McCall 15941eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump /// \brief Retrieve the location of the left angle bracket following the 15953b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor /// member name ('<'), if any. 15961eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump SourceLocation getLAngleLoc() const { 15973b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor if (!HasExplicitTemplateArgumentList) 15983b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor return SourceLocation(); 15991eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 16003b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor return getExplicitTemplateArgumentList()->LAngleLoc; 16013b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor } 16021eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 16033b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor /// \brief Retrieve the template arguments provided as part of this 16043b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor /// template-id. 1605833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall const TemplateArgumentLoc *getTemplateArgs() const { 16063b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor if (!HasExplicitTemplateArgumentList) 16071eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump return 0; 16081eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 16093b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor return getExplicitTemplateArgumentList()->getTemplateArgs(); 16103b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor } 16111eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 16123b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor /// \brief Retrieve the number of template arguments provided as part of this 16133b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor /// template-id. 16141eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump unsigned getNumTemplateArgs() const { 16153b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor if (!HasExplicitTemplateArgumentList) 16161eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump return 0; 16171eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 16183b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor return getExplicitTemplateArgumentList()->NumTemplateArgs; 16193b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor } 16201eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 16211eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump /// \brief Retrieve the location of the right angle bracket following the 16223b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor /// template arguments ('>'). 16231eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump SourceLocation getRAngleLoc() const { 16243b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor if (!HasExplicitTemplateArgumentList) 16253b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor return SourceLocation(); 16261eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 16273b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor return getExplicitTemplateArgumentList()->RAngleLoc; 16283b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor } 16291eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 16301c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor virtual SourceRange getSourceRange() const { 16313b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor if (HasExplicitTemplateArgumentList) 16323b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor return SourceRange(Base->getSourceRange().getBegin(), 16333b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor getRAngleLoc()); 16341eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 16351c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor return SourceRange(Base->getSourceRange().getBegin(), 16361c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor MemberLoc); 16371c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor } 16381eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 16391eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump static bool classof(const Stmt *T) { 1640865d447ac6a4721ab58e898d014a21f2eff74b06John McCall return T->getStmtClass() == CXXDependentScopeMemberExprClass; 16411c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor } 1642865d447ac6a4721ab58e898d014a21f2eff74b06John McCall static bool classof(const CXXDependentScopeMemberExpr *) { return true; } 16431c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor 16441c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor // Iterators 16451c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor virtual child_iterator child_begin(); 16461c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor virtual child_iterator child_end(); 16471c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor}; 16481c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor 16495f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer} // end namespace clang 16505f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 16515f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer#endif 1652