ExprCXX.h revision aa165f8458b51c546bebff947343e1a36f3594cb
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" 19eec51cf1ba5f0e62c9cdb81b5c63babdd6e649abJohn McCall#include "clang/AST/UnresolvedSet.h" 20d5532b6cfff2977e0c59fa6ead7f7973984a620dJohn McCall#include "clang/AST/TemplateBase.h" 215f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 225f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencernamespace clang { 235f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 24aa165f8458b51c546bebff947343e1a36f3594cbDouglas Gregorclass CXXConstructorDecl; 25aa165f8458b51c546bebff947343e1a36f3594cbDouglas Gregorclass CXXDestructorDecl; 26aa165f8458b51c546bebff947343e1a36f3594cbDouglas Gregorclass CXXMethodDecl; 27aa165f8458b51c546bebff947343e1a36f3594cbDouglas Gregorclass CXXTemporary; 28aa165f8458b51c546bebff947343e1a36f3594cbDouglas Gregorclass 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, 54f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall ExprValueKind VK, SourceLocation operatorloc) 55f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall : CallExpr(C, CXXOperatorCallExprClass, fn, args, numargs, t, VK, 56f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall operatorloc), 57063daf6e196c51f162e0485478355d8e280eef5cDouglas Gregor Operator(Op) {} 581eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump explicit CXXOperatorCallExpr(ASTContext& C, EmptyShell Empty) : 59ba0a9006dbc4814e1e35f82812cb5a1dad65e8b8Argyrios Kyrtzidis CallExpr(C, CXXOperatorCallExprClass, Empty) { } 601eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 61b4609806e9232593ece09ce08b630836e825865cDouglas Gregor 62b4609806e9232593ece09ce08b630836e825865cDouglas Gregor /// getOperator - Returns the kind of overloaded operator that this 63b4609806e9232593ece09ce08b630836e825865cDouglas Gregor /// expression refers to. 64063daf6e196c51f162e0485478355d8e280eef5cDouglas Gregor OverloadedOperatorKind getOperator() const { return Operator; } 65ba0a9006dbc4814e1e35f82812cb5a1dad65e8b8Argyrios Kyrtzidis void setOperator(OverloadedOperatorKind Kind) { Operator = Kind; } 66b4609806e9232593ece09ce08b630836e825865cDouglas Gregor 67b4609806e9232593ece09ce08b630836e825865cDouglas Gregor /// getOperatorLoc - Returns the location of the operator symbol in 68b4609806e9232593ece09ce08b630836e825865cDouglas Gregor /// the expression. When @c getOperator()==OO_Call, this is the 69b4609806e9232593ece09ce08b630836e825865cDouglas Gregor /// location of the right parentheses; when @c 70b4609806e9232593ece09ce08b630836e825865cDouglas Gregor /// getOperator()==OO_Subscript, this is the location of the right 71b4609806e9232593ece09ce08b630836e825865cDouglas Gregor /// bracket. 72b4609806e9232593ece09ce08b630836e825865cDouglas Gregor SourceLocation getOperatorLoc() const { return getRParenLoc(); } 73b4609806e9232593ece09ce08b630836e825865cDouglas Gregor 74b4609806e9232593ece09ce08b630836e825865cDouglas Gregor virtual SourceRange getSourceRange() const; 751eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 761eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump static bool classof(const Stmt *T) { 771eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump return T->getStmtClass() == CXXOperatorCallExprClass; 78b4609806e9232593ece09ce08b630836e825865cDouglas Gregor } 79b4609806e9232593ece09ce08b630836e825865cDouglas Gregor static bool classof(const CXXOperatorCallExpr *) { return true; } 80b4609806e9232593ece09ce08b630836e825865cDouglas Gregor}; 81b4609806e9232593ece09ce08b630836e825865cDouglas Gregor 8288a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor/// CXXMemberCallExpr - Represents a call to a member function that 8388a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor/// may be written either with member call syntax (e.g., "obj.func()" 8488a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor/// or "objptr->func()") or with normal function-call syntax 8588a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor/// ("func()") within a member function that ends up calling a member 8688a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor/// function. The callee in either case is a MemberExpr that contains 8788a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor/// both the object argument and the member function, while the 8888a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor/// arguments are the arguments within the parentheses (not including 8988a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor/// the object argument). 9088a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregorclass CXXMemberCallExpr : public CallExpr { 9188a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregorpublic: 921817bd483b538fd3f4530649f5cb900bad9e8a76Chris Lattner CXXMemberCallExpr(ASTContext &C, Expr *fn, Expr **args, unsigned numargs, 93f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall QualType t, ExprValueKind VK, SourceLocation RP) 94f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall : CallExpr(C, CXXMemberCallExprClass, fn, args, numargs, t, VK, RP) {} 9588a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor 961817bd483b538fd3f4530649f5cb900bad9e8a76Chris Lattner CXXMemberCallExpr(ASTContext &C, EmptyShell Empty) 971817bd483b538fd3f4530649f5cb900bad9e8a76Chris Lattner : CallExpr(C, CXXMemberCallExprClass, Empty) { } 981817bd483b538fd3f4530649f5cb900bad9e8a76Chris Lattner 9988a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor /// getImplicitObjectArgument - Retrieves the implicit object 10088a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor /// argument for the member call. For example, in "x.f(5)", this 10188a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor /// operation would return "x". 10288a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor Expr *getImplicitObjectArgument(); 10388a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor 104007a9b1c632bfaac20e41c60cbe07fdc6d0e647cChandler Carruth /// getRecordDecl - Retrieves the CXXRecordDecl for the underlying type of 105007a9b1c632bfaac20e41c60cbe07fdc6d0e647cChandler Carruth /// the implicit object argument. Note that this is may not be the same 106007a9b1c632bfaac20e41c60cbe07fdc6d0e647cChandler Carruth /// declaration as that of the class context of the CXXMethodDecl which this 107007a9b1c632bfaac20e41c60cbe07fdc6d0e647cChandler Carruth /// function is calling. 108007a9b1c632bfaac20e41c60cbe07fdc6d0e647cChandler Carruth /// FIXME: Returns 0 for member pointer call exprs. 109007a9b1c632bfaac20e41c60cbe07fdc6d0e647cChandler Carruth CXXRecordDecl *getRecordDecl(); 110007a9b1c632bfaac20e41c60cbe07fdc6d0e647cChandler Carruth 11100b98c229ef28a5e82943bb23d09fb46d24ca381Douglas Gregor virtual SourceRange getSourceRange() const; 11200b98c229ef28a5e82943bb23d09fb46d24ca381Douglas Gregor 1131eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump static bool classof(const Stmt *T) { 11488a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor return T->getStmtClass() == CXXMemberCallExprClass; 11588a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor } 11688a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor static bool classof(const CXXMemberCallExpr *) { return true; } 11788a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor}; 11888a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor 11949badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// CXXNamedCastExpr - Abstract class common to all of the C++ "named" 12049badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// casts, @c static_cast, @c dynamic_cast, @c reinterpret_cast, or @c 12149badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// const_cast. 12249badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// 12349badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// This abstract class is inherited by all of the classes 12449badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// representing "named" casts, e.g., CXXStaticCastExpr, 12549badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// CXXDynamicCastExpr, CXXReinterpretCastExpr, and CXXConstCastExpr. 12649badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregorclass CXXNamedCastExpr : public ExplicitCastExpr { 1271060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenekprivate: 1281060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek SourceLocation Loc; // the location of the casting op 12949badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor 13049badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregorprotected: 131f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall CXXNamedCastExpr(StmtClass SC, QualType ty, ExprValueKind VK, 132f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall CastKind kind, Expr *op, unsigned PathSize, 133f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall TypeSourceInfo *writtenTy, SourceLocation l) 134f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall : ExplicitCastExpr(SC, ty, VK, kind, op, PathSize, writtenTy), Loc(l) {} 13549badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor 136f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall explicit CXXNamedCastExpr(StmtClass SC, EmptyShell Shell, unsigned PathSize) 137f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall : ExplicitCastExpr(SC, Shell, PathSize) { } 138ce757a7a1ee905f87551996a69da3e95e8afeeb7Sam Weinig 1391060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenekpublic: 14049badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor const char *getCastName() const; 14149badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor 142a3a7b8eea87c90a5a257f685749222b212ddaf36Douglas Gregor /// \brief Retrieve the location of the cast operator keyword, e.g., 143a3a7b8eea87c90a5a257f685749222b212ddaf36Douglas Gregor /// "static_cast". 144a3a7b8eea87c90a5a257f685749222b212ddaf36Douglas Gregor SourceLocation getOperatorLoc() const { return Loc; } 145a3a7b8eea87c90a5a257f685749222b212ddaf36Douglas Gregor void setOperatorLoc(SourceLocation L) { Loc = L; } 146a3a7b8eea87c90a5a257f685749222b212ddaf36Douglas Gregor 1471060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek virtual SourceRange getSourceRange() const { 1481060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek return SourceRange(Loc, getSubExpr()->getSourceRange().getEnd()); 1491060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek } 1501eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump static bool classof(const Stmt *T) { 15149badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor switch (T->getStmtClass()) { 15249badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor case CXXStaticCastExprClass: 15349badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor case CXXDynamicCastExprClass: 15449badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor case CXXReinterpretCastExprClass: 15549badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor case CXXConstCastExprClass: 15649badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor return true; 15749badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor default: 15849badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor return false; 15949badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor } 1601060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek } 16149badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor static bool classof(const CXXNamedCastExpr *) { return true; } 16249badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor}; 16349badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor 16449badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// CXXStaticCastExpr - A C++ @c static_cast expression (C++ [expr.static.cast]). 1651eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump/// 16649badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// This expression node represents a C++ static cast, e.g., 16749badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// @c static_cast<int>(1.0). 16849badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregorclass CXXStaticCastExpr : public CXXNamedCastExpr { 169f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall CXXStaticCastExpr(QualType ty, ExprValueKind vk, CastKind kind, Expr *op, 170f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall unsigned pathSize, TypeSourceInfo *writtenTy, 17141b2dcd465f1e438502c420effc9d0c747f9db8fAnders Carlsson SourceLocation l) 172f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall : CXXNamedCastExpr(CXXStaticCastExprClass, ty, vk, kind, op, pathSize, 173f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall writtenTy, l) {} 17449badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor 175f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall explicit CXXStaticCastExpr(EmptyShell Empty, unsigned PathSize) 176f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall : CXXNamedCastExpr(CXXStaticCastExprClass, Empty, PathSize) { } 177f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall 178f871d0cc377a1367b519a6cce26be74607566ebaJohn McCallpublic: 179f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall static CXXStaticCastExpr *Create(ASTContext &Context, QualType T, 180f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall ExprValueKind VK, CastKind K, Expr *Op, 181f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall const CXXCastPath *Path, 182f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall TypeSourceInfo *Written, SourceLocation L); 183f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall static CXXStaticCastExpr *CreateEmpty(ASTContext &Context, 184f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall unsigned PathSize); 185ce757a7a1ee905f87551996a69da3e95e8afeeb7Sam Weinig 1861eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump static bool classof(const Stmt *T) { 18749badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor return T->getStmtClass() == CXXStaticCastExprClass; 18849badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor } 18949badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor static bool classof(const CXXStaticCastExpr *) { return true; } 19049badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor}; 19149badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor 19249badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// CXXDynamicCastExpr - A C++ @c dynamic_cast expression 1931eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump/// (C++ [expr.dynamic.cast]), which may perform a run-time check to 19449badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// determine how to perform the type cast. 1951eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump/// 19649badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// This expression node represents a dynamic cast, e.g., 19749badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// @c dynamic_cast<Derived*>(BasePtr). 19849badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregorclass CXXDynamicCastExpr : public CXXNamedCastExpr { 199f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall CXXDynamicCastExpr(QualType ty, ExprValueKind VK, CastKind kind, 200f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall Expr *op, unsigned pathSize, TypeSourceInfo *writtenTy, 20141b2dcd465f1e438502c420effc9d0c747f9db8fAnders Carlsson SourceLocation l) 202f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall : CXXNamedCastExpr(CXXDynamicCastExprClass, ty, VK, kind, op, pathSize, 20341b2dcd465f1e438502c420effc9d0c747f9db8fAnders Carlsson writtenTy, l) {} 20449badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor 205f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall explicit CXXDynamicCastExpr(EmptyShell Empty, unsigned pathSize) 206f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall : CXXNamedCastExpr(CXXDynamicCastExprClass, Empty, pathSize) { } 207f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall 208f871d0cc377a1367b519a6cce26be74607566ebaJohn McCallpublic: 209f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall static CXXDynamicCastExpr *Create(ASTContext &Context, QualType T, 210f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall ExprValueKind VK, CastKind Kind, Expr *Op, 211f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall const CXXCastPath *Path, 212f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall TypeSourceInfo *Written, SourceLocation L); 213f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall 214f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall static CXXDynamicCastExpr *CreateEmpty(ASTContext &Context, 215f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall unsigned pathSize); 216ce757a7a1ee905f87551996a69da3e95e8afeeb7Sam Weinig 2171eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump static bool classof(const Stmt *T) { 21849badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor return T->getStmtClass() == CXXDynamicCastExprClass; 21949badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor } 22049badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor static bool classof(const CXXDynamicCastExpr *) { return true; } 22149badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor}; 22249badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor 22349badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// CXXReinterpretCastExpr - A C++ @c reinterpret_cast expression (C++ 22449badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// [expr.reinterpret.cast]), which provides a differently-typed view 22549badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// of a value but performs no actual work at run time. 2261eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump/// 22749badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// This expression node represents a reinterpret cast, e.g., 22849badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// @c reinterpret_cast<int>(VoidPtr). 22949badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregorclass CXXReinterpretCastExpr : public CXXNamedCastExpr { 230f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall CXXReinterpretCastExpr(QualType ty, ExprValueKind vk, CastKind kind, 231f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall Expr *op, unsigned pathSize, 2329d125033a9853f3b572a4c9e2f9e2d4e5e346973John McCall TypeSourceInfo *writtenTy, SourceLocation l) 233f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall : CXXNamedCastExpr(CXXReinterpretCastExprClass, ty, vk, kind, op, 234f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall pathSize, writtenTy, l) {} 23549badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor 236f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall CXXReinterpretCastExpr(EmptyShell Empty, unsigned pathSize) 237f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall : CXXNamedCastExpr(CXXReinterpretCastExprClass, Empty, pathSize) { } 238f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall 239f871d0cc377a1367b519a6cce26be74607566ebaJohn McCallpublic: 240f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall static CXXReinterpretCastExpr *Create(ASTContext &Context, QualType T, 241f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall ExprValueKind VK, CastKind Kind, 242f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall Expr *Op, const CXXCastPath *Path, 243f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall TypeSourceInfo *WrittenTy, SourceLocation L); 244f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall static CXXReinterpretCastExpr *CreateEmpty(ASTContext &Context, 245f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall unsigned pathSize); 246ce757a7a1ee905f87551996a69da3e95e8afeeb7Sam Weinig 2471eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump static bool classof(const Stmt *T) { 24849badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor return T->getStmtClass() == CXXReinterpretCastExprClass; 24949badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor } 25049badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor static bool classof(const CXXReinterpretCastExpr *) { return true; } 25149badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor}; 25249badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor 25349badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// CXXConstCastExpr - A C++ @c const_cast expression (C++ [expr.const.cast]), 25449badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// which can remove type qualifiers but does not change the underlying value. 2551eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump/// 25649badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// This expression node represents a const cast, e.g., 25749badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// @c const_cast<char*>(PtrToConstChar). 25849badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregorclass CXXConstCastExpr : public CXXNamedCastExpr { 259f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall CXXConstCastExpr(QualType ty, ExprValueKind VK, Expr *op, 260f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall TypeSourceInfo *writtenTy, SourceLocation l) 261f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall : CXXNamedCastExpr(CXXConstCastExprClass, ty, VK, CK_NoOp, op, 262f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall 0, writtenTy, l) {} 26349badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor 264ce757a7a1ee905f87551996a69da3e95e8afeeb7Sam Weinig explicit CXXConstCastExpr(EmptyShell Empty) 265f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall : CXXNamedCastExpr(CXXConstCastExprClass, Empty, 0) { } 266f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall 267f871d0cc377a1367b519a6cce26be74607566ebaJohn McCallpublic: 268f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall static CXXConstCastExpr *Create(ASTContext &Context, QualType T, 269f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall ExprValueKind VK, Expr *Op, 270f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall TypeSourceInfo *WrittenTy, SourceLocation L); 271f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall static CXXConstCastExpr *CreateEmpty(ASTContext &Context); 272ce757a7a1ee905f87551996a69da3e95e8afeeb7Sam Weinig 2731eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump static bool classof(const Stmt *T) { 27449badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor return T->getStmtClass() == CXXConstCastExprClass; 27549badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor } 27649badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor static bool classof(const CXXConstCastExpr *) { return true; } 2771060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek}; 2781060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek 2791060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek/// CXXBoolLiteralExpr - [C++ 2.13.5] C++ Boolean Literal. 2801eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump/// 2811060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenekclass CXXBoolLiteralExpr : public Expr { 2821060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek bool Value; 2831060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek SourceLocation Loc; 2841060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenekpublic: 2851eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump CXXBoolLiteralExpr(bool val, QualType Ty, SourceLocation l) : 286bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor Expr(CXXBoolLiteralExprClass, Ty, VK_RValue, OK_Ordinary, false, false, 287bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor false), 288f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall Value(val), Loc(l) {} 2898b0b475b3464b0f70b91ba7d679d23c424677d5eSebastian Redl 290eb7f96141f754150a92433286fa385910a22f494Sam Weinig explicit CXXBoolLiteralExpr(EmptyShell Empty) 291eb7f96141f754150a92433286fa385910a22f494Sam Weinig : Expr(CXXBoolLiteralExprClass, Empty) { } 292eb7f96141f754150a92433286fa385910a22f494Sam Weinig 2931060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek bool getValue() const { return Value; } 294eb7f96141f754150a92433286fa385910a22f494Sam Weinig void setValue(bool V) { Value = V; } 2955f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 2961060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek virtual SourceRange getSourceRange() const { return SourceRange(Loc); } 2971eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 298eb7f96141f754150a92433286fa385910a22f494Sam Weinig SourceLocation getLocation() const { return Loc; } 299eb7f96141f754150a92433286fa385910a22f494Sam Weinig void setLocation(SourceLocation L) { Loc = L; } 300eb7f96141f754150a92433286fa385910a22f494Sam Weinig 3011eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump static bool classof(const Stmt *T) { 3021060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek return T->getStmtClass() == CXXBoolLiteralExprClass; 3031060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek } 3041060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek static bool classof(const CXXBoolLiteralExpr *) { return true; } 3051eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 3061060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek // Iterators 3071060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek virtual child_iterator child_begin(); 3081060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek virtual child_iterator child_end(); 3091060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek}; 3101060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek 3116e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl/// CXXNullPtrLiteralExpr - [C++0x 2.14.7] C++ Pointer Literal 3126e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redlclass CXXNullPtrLiteralExpr : public Expr { 3136e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl SourceLocation Loc; 3146e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redlpublic: 3156e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl CXXNullPtrLiteralExpr(QualType Ty, SourceLocation l) : 316bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor Expr(CXXNullPtrLiteralExprClass, Ty, VK_RValue, OK_Ordinary, false, false, 317bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor false), 318f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall Loc(l) {} 3196e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl 320eb7f96141f754150a92433286fa385910a22f494Sam Weinig explicit CXXNullPtrLiteralExpr(EmptyShell Empty) 321eb7f96141f754150a92433286fa385910a22f494Sam Weinig : Expr(CXXNullPtrLiteralExprClass, Empty) { } 322eb7f96141f754150a92433286fa385910a22f494Sam Weinig 3236e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl virtual SourceRange getSourceRange() const { return SourceRange(Loc); } 3246e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl 325eb7f96141f754150a92433286fa385910a22f494Sam Weinig SourceLocation getLocation() const { return Loc; } 326eb7f96141f754150a92433286fa385910a22f494Sam Weinig void setLocation(SourceLocation L) { Loc = L; } 327eb7f96141f754150a92433286fa385910a22f494Sam Weinig 3286e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl static bool classof(const Stmt *T) { 3296e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl return T->getStmtClass() == CXXNullPtrLiteralExprClass; 3306e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl } 3316e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl static bool classof(const CXXNullPtrLiteralExpr *) { return true; } 3326e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl 3336e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl virtual child_iterator child_begin(); 3346e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl virtual child_iterator child_end(); 3356e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl}; 3366e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl 337c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl/// CXXTypeidExpr - A C++ @c typeid expression (C++ [expr.typeid]), which gets 338c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl/// the type_info that corresponds to the supplied type, or the (possibly 339c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl/// dynamic) type of the supplied expression. 340c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl/// 341c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl/// This represents code like @c typeid(int) or @c typeid(*objPtr) 342c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redlclass CXXTypeidExpr : public Expr { 343c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redlprivate: 34457fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor llvm::PointerUnion<Stmt *, TypeSourceInfo *> Operand; 345c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl SourceRange Range; 346c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl 347c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redlpublic: 34857fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor CXXTypeidExpr(QualType Ty, TypeSourceInfo *Operand, SourceRange R) 349f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall : Expr(CXXTypeidExprClass, Ty, VK_LValue, OK_Ordinary, 35057fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor // typeid is never type-dependent (C++ [temp.dep.expr]p4) 35157fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor false, 35257fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor // typeid is value-dependent if the type or expression are dependent 353bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor Operand->getType()->isDependentType(), 354bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor Operand->getType()->containsUnexpandedParameterPack()), 35557fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor Operand(Operand), Range(R) { } 35657fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor 35757fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor CXXTypeidExpr(QualType Ty, Expr *Operand, SourceRange R) 358f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall : Expr(CXXTypeidExprClass, Ty, VK_LValue, OK_Ordinary, 3592850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl // typeid is never type-dependent (C++ [temp.dep.expr]p4) 360bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor false, 3612850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl // typeid is value-dependent if the type or expression are dependent 362bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor Operand->isTypeDependent() || Operand->isValueDependent(), 363bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor Operand->containsUnexpandedParameterPack()), 36457fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor Operand(Operand), Range(R) { } 365c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl 36614ab24f01e36d495fce183aa67b41e45cdd54f39Chris Lattner CXXTypeidExpr(EmptyShell Empty, bool isExpr) 36714ab24f01e36d495fce183aa67b41e45cdd54f39Chris Lattner : Expr(CXXTypeidExprClass, Empty) { 36814ab24f01e36d495fce183aa67b41e45cdd54f39Chris Lattner if (isExpr) 36914ab24f01e36d495fce183aa67b41e45cdd54f39Chris Lattner Operand = (Expr*)0; 37014ab24f01e36d495fce183aa67b41e45cdd54f39Chris Lattner else 37114ab24f01e36d495fce183aa67b41e45cdd54f39Chris Lattner Operand = (TypeSourceInfo*)0; 37214ab24f01e36d495fce183aa67b41e45cdd54f39Chris Lattner } 37314ab24f01e36d495fce183aa67b41e45cdd54f39Chris Lattner 37457fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor bool isTypeOperand() const { return Operand.is<TypeSourceInfo *>(); } 37557fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor 37657fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor /// \brief Retrieves the type operand of this typeid() expression after 37757fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor /// various required adjustments (removing reference types, cv-qualifiers). 37857fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor QualType getTypeOperand() const; 37957fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor 38057fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor /// \brief Retrieve source information for the type operand. 38157fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor TypeSourceInfo *getTypeOperandSourceInfo() const { 382c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl assert(isTypeOperand() && "Cannot call getTypeOperand for typeid(expr)"); 38357fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor return Operand.get<TypeSourceInfo *>(); 384c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl } 38514ab24f01e36d495fce183aa67b41e45cdd54f39Chris Lattner 38614ab24f01e36d495fce183aa67b41e45cdd54f39Chris Lattner void setTypeOperandSourceInfo(TypeSourceInfo *TSI) { 38714ab24f01e36d495fce183aa67b41e45cdd54f39Chris Lattner assert(isTypeOperand() && "Cannot call getTypeOperand for typeid(expr)"); 38814ab24f01e36d495fce183aa67b41e45cdd54f39Chris Lattner Operand = TSI; 38914ab24f01e36d495fce183aa67b41e45cdd54f39Chris Lattner } 39057fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor 39114ab24f01e36d495fce183aa67b41e45cdd54f39Chris Lattner Expr *getExprOperand() const { 392c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl assert(!isTypeOperand() && "Cannot call getExprOperand for typeid(type)"); 39357fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor return static_cast<Expr*>(Operand.get<Stmt *>()); 394c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl } 39514ab24f01e36d495fce183aa67b41e45cdd54f39Chris Lattner 396030854b95f7bfd86aaa8afd9ae1aff9768a37e9aChris Lattner void setExprOperand(Expr *E) { 397030854b95f7bfd86aaa8afd9ae1aff9768a37e9aChris Lattner assert(!isTypeOperand() && "Cannot call getExprOperand for typeid(type)"); 398030854b95f7bfd86aaa8afd9ae1aff9768a37e9aChris Lattner Operand = E; 399030854b95f7bfd86aaa8afd9ae1aff9768a37e9aChris Lattner } 400030854b95f7bfd86aaa8afd9ae1aff9768a37e9aChris Lattner 40114ab24f01e36d495fce183aa67b41e45cdd54f39Chris Lattner virtual SourceRange getSourceRange() const { return Range; } 40214ab24f01e36d495fce183aa67b41e45cdd54f39Chris Lattner void setSourceRange(SourceRange R) { Range = R; } 40314ab24f01e36d495fce183aa67b41e45cdd54f39Chris Lattner 404c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl static bool classof(const Stmt *T) { 405c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl return T->getStmtClass() == CXXTypeidExprClass; 406c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl } 407c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl static bool classof(const CXXTypeidExpr *) { return true; } 408c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl 409c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl // Iterators 410c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl virtual child_iterator child_begin(); 411c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl virtual child_iterator child_end(); 412c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl}; 413c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl 41401b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet/// CXXUuidofExpr - A microsoft C++ @c __uuidof expression, which gets 41501b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet/// the _GUID that corresponds to the supplied type or expression. 41601b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet/// 41701b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet/// This represents code like @c __uuidof(COMTYPE) or @c __uuidof(*comPtr) 41801b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichetclass CXXUuidofExpr : public Expr { 41901b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichetprivate: 42001b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet llvm::PointerUnion<Stmt *, TypeSourceInfo *> Operand; 42101b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet SourceRange Range; 42201b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet 42301b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichetpublic: 42401b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet CXXUuidofExpr(QualType Ty, TypeSourceInfo *Operand, SourceRange R) 4252e219b8d253dbb901206b14e5643cc9d0edd662bFrancois Pichet : Expr(CXXUuidofExprClass, Ty, VK_LValue, OK_Ordinary, 426bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor false, Operand->getType()->isDependentType(), 427bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor Operand->getType()->containsUnexpandedParameterPack()), 42801b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet Operand(Operand), Range(R) { } 42901b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet 43001b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet CXXUuidofExpr(QualType Ty, Expr *Operand, SourceRange R) 4312e219b8d253dbb901206b14e5643cc9d0edd662bFrancois Pichet : Expr(CXXUuidofExprClass, Ty, VK_LValue, OK_Ordinary, 432bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor false, Operand->isTypeDependent(), 433bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor Operand->containsUnexpandedParameterPack()), 43401b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet Operand(Operand), Range(R) { } 43501b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet 43601b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet CXXUuidofExpr(EmptyShell Empty, bool isExpr) 43701b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet : Expr(CXXUuidofExprClass, Empty) { 43801b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet if (isExpr) 43901b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet Operand = (Expr*)0; 44001b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet else 44101b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet Operand = (TypeSourceInfo*)0; 44201b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet } 44301b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet 44401b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet bool isTypeOperand() const { return Operand.is<TypeSourceInfo *>(); } 44501b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet 44601b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet /// \brief Retrieves the type operand of this __uuidof() expression after 44701b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet /// various required adjustments (removing reference types, cv-qualifiers). 44801b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet QualType getTypeOperand() const; 44901b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet 45001b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet /// \brief Retrieve source information for the type operand. 45101b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet TypeSourceInfo *getTypeOperandSourceInfo() const { 45201b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet assert(isTypeOperand() && "Cannot call getTypeOperand for __uuidof(expr)"); 45301b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet return Operand.get<TypeSourceInfo *>(); 45401b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet } 45501b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet 45601b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet void setTypeOperandSourceInfo(TypeSourceInfo *TSI) { 45701b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet assert(isTypeOperand() && "Cannot call getTypeOperand for __uuidof(expr)"); 45801b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet Operand = TSI; 45901b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet } 46001b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet 46101b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet Expr *getExprOperand() const { 46201b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet assert(!isTypeOperand() && "Cannot call getExprOperand for __uuidof(type)"); 46301b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet return static_cast<Expr*>(Operand.get<Stmt *>()); 46401b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet } 46501b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet 46601b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet void setExprOperand(Expr *E) { 46701b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet assert(!isTypeOperand() && "Cannot call getExprOperand for __uuidof(type)"); 46801b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet Operand = E; 46901b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet } 47001b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet 47101b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet virtual SourceRange getSourceRange() const { return Range; } 47201b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet void setSourceRange(SourceRange R) { Range = R; } 47301b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet 47401b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet static bool classof(const Stmt *T) { 47501b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet return T->getStmtClass() == CXXUuidofExprClass; 47601b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet } 47701b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet static bool classof(const CXXUuidofExpr *) { return true; } 47801b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet 47901b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet // Iterators 48001b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet virtual child_iterator child_begin(); 48101b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet virtual child_iterator child_end(); 48201b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet}; 48301b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet 484796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// CXXThisExpr - Represents the "this" expression in C++, which is a 485796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// pointer to the object on which the current member function is 486796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// executing (C++ [expr.prim]p3). Example: 487796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// 488796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// @code 489796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// class Foo { 490796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// public: 491796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// void bar(); 492796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// void test() { this->bar(); } 493796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// }; 494796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// @endcode 495796da18402f286b897782a298ae3b20c459c102eDouglas Gregorclass CXXThisExpr : public Expr { 496796da18402f286b897782a298ae3b20c459c102eDouglas Gregor SourceLocation Loc; 497828a197317288e3333b0ce6f5cedadd036e3531fDouglas Gregor bool Implicit : 1; 498828a197317288e3333b0ce6f5cedadd036e3531fDouglas Gregor 499796da18402f286b897782a298ae3b20c459c102eDouglas Gregorpublic: 500828a197317288e3333b0ce6f5cedadd036e3531fDouglas Gregor CXXThisExpr(SourceLocation L, QualType Type, bool isImplicit) 501f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall : Expr(CXXThisExprClass, Type, VK_RValue, OK_Ordinary, 5022850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl // 'this' is type-dependent if the class type of the enclosing 5032850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl // member function is dependent (C++ [temp.dep.expr]p2) 504bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor Type->isDependentType(), Type->isDependentType(), 505bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor /*ContainsUnexpandedParameterPack=*/false), 506828a197317288e3333b0ce6f5cedadd036e3531fDouglas Gregor Loc(L), Implicit(isImplicit) { } 507796da18402f286b897782a298ae3b20c459c102eDouglas Gregor 5082fbdfcdf3bbf7b941853d38b123930755e837437Chris Lattner CXXThisExpr(EmptyShell Empty) : Expr(CXXThisExprClass, Empty) {} 5092fbdfcdf3bbf7b941853d38b123930755e837437Chris Lattner 5102fbdfcdf3bbf7b941853d38b123930755e837437Chris Lattner SourceLocation getLocation() const { return Loc; } 5112fbdfcdf3bbf7b941853d38b123930755e837437Chris Lattner void setLocation(SourceLocation L) { Loc = L; } 5122fbdfcdf3bbf7b941853d38b123930755e837437Chris Lattner 513796da18402f286b897782a298ae3b20c459c102eDouglas Gregor virtual SourceRange getSourceRange() const { return SourceRange(Loc); } 514796da18402f286b897782a298ae3b20c459c102eDouglas Gregor 515828a197317288e3333b0ce6f5cedadd036e3531fDouglas Gregor bool isImplicit() const { return Implicit; } 516828a197317288e3333b0ce6f5cedadd036e3531fDouglas Gregor void setImplicit(bool I) { Implicit = I; } 517828a197317288e3333b0ce6f5cedadd036e3531fDouglas Gregor 5181eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump static bool classof(const Stmt *T) { 519796da18402f286b897782a298ae3b20c459c102eDouglas Gregor return T->getStmtClass() == CXXThisExprClass; 520796da18402f286b897782a298ae3b20c459c102eDouglas Gregor } 521796da18402f286b897782a298ae3b20c459c102eDouglas Gregor static bool classof(const CXXThisExpr *) { return true; } 522796da18402f286b897782a298ae3b20c459c102eDouglas Gregor 523796da18402f286b897782a298ae3b20c459c102eDouglas Gregor // Iterators 524796da18402f286b897782a298ae3b20c459c102eDouglas Gregor virtual child_iterator child_begin(); 525796da18402f286b897782a298ae3b20c459c102eDouglas Gregor virtual child_iterator child_end(); 526796da18402f286b897782a298ae3b20c459c102eDouglas Gregor}; 527796da18402f286b897782a298ae3b20c459c102eDouglas Gregor 5281060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek/// CXXThrowExpr - [C++ 15] C++ Throw Expression. This handles 5291060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek/// 'throw' and 'throw' assignment-expression. When 5301060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek/// assignment-expression isn't present, Op will be null. 5311060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek/// 5321060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenekclass CXXThrowExpr : public Expr { 5331060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek Stmt *Op; 5341060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek SourceLocation ThrowLoc; 5351060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenekpublic: 5361060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek // Ty is the void type which is used as the result type of the 5371060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek // exepression. The l is the location of the throw keyword. expr 5381060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek // can by null, if the optional expression to throw isn't present. 5391060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek CXXThrowExpr(Expr *expr, QualType Ty, SourceLocation l) : 540bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor Expr(CXXThrowExprClass, Ty, VK_RValue, OK_Ordinary, false, false, 541bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor expr && expr->containsUnexpandedParameterPack()), 542f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall Op(expr), ThrowLoc(l) {} 5432fbdfcdf3bbf7b941853d38b123930755e837437Chris Lattner CXXThrowExpr(EmptyShell Empty) : Expr(CXXThrowExprClass, Empty) {} 5442fbdfcdf3bbf7b941853d38b123930755e837437Chris Lattner 5451060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek const Expr *getSubExpr() const { return cast_or_null<Expr>(Op); } 5461060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek Expr *getSubExpr() { return cast_or_null<Expr>(Op); } 54742e5b50f4dc897f252e0d476063a7f9846d96624Douglas Gregor void setSubExpr(Expr *E) { Op = E; } 54842e5b50f4dc897f252e0d476063a7f9846d96624Douglas Gregor 54942e5b50f4dc897f252e0d476063a7f9846d96624Douglas Gregor SourceLocation getThrowLoc() const { return ThrowLoc; } 55042e5b50f4dc897f252e0d476063a7f9846d96624Douglas Gregor void setThrowLoc(SourceLocation L) { ThrowLoc = L; } 5511060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek 5521060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek virtual SourceRange getSourceRange() const { 5531060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek if (getSubExpr() == 0) 5541060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek return SourceRange(ThrowLoc, ThrowLoc); 5551060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek return SourceRange(ThrowLoc, getSubExpr()->getSourceRange().getEnd()); 5561060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek } 5571060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek 5581060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek static bool classof(const Stmt *T) { 5591060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek return T->getStmtClass() == CXXThrowExprClass; 5601060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek } 5611060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek static bool classof(const CXXThrowExpr *) { return true; } 5621060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek 5631060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek // Iterators 5641060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek virtual child_iterator child_begin(); 5651060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek virtual child_iterator child_end(); 5661060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek}; 5671060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek 5681060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek/// CXXDefaultArgExpr - C++ [dcl.fct.default]. This wraps up a 5691060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek/// function call argument that was created from the corresponding 5701060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek/// parameter's default argument, when the call did not explicitly 5711060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek/// supply arguments for all of the parameters. 5721060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenekclass CXXDefaultArgExpr : public Expr { 57365222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor /// \brief The parameter whose default is being used. 57465222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor /// 57565222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor /// When the bit is set, the subexpression is stored after the 57665222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor /// CXXDefaultArgExpr itself. When the bit is clear, the parameter's 57765222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor /// actual default expression is the subexpression. 57865222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor llvm::PointerIntPair<ParmVarDecl *, 1, bool> Param; 5791eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 580036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor /// \brief The location where the default argument expression was used. 581036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor SourceLocation Loc; 582036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor 583036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor CXXDefaultArgExpr(StmtClass SC, SourceLocation Loc, ParmVarDecl *param) 58465222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor : Expr(SC, 58565222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor param->hasUnparsedDefaultArg() 58665222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor ? param->getType().getNonReferenceType() 5872333f7727f97018d6742e1e0938133bcfad967abEli Friedman : param->getDefaultArg()->getType(), 588dfa1edbebeda7ec3a7a9c45e4317de9241aa9883John McCall param->getDefaultArg()->getValueKind(), 589bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor param->getDefaultArg()->getObjectKind(), false, false, false), 590036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor Param(param, false), Loc(Loc) { } 59165222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor 592036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor CXXDefaultArgExpr(StmtClass SC, SourceLocation Loc, ParmVarDecl *param, 593036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor Expr *SubExpr) 594dfa1edbebeda7ec3a7a9c45e4317de9241aa9883John McCall : Expr(SC, SubExpr->getType(), 595dfa1edbebeda7ec3a7a9c45e4317de9241aa9883John McCall SubExpr->getValueKind(), SubExpr->getObjectKind(), 596bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor false, false, false), 597bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor Param(param, true), Loc(Loc) { 59865222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor *reinterpret_cast<Expr **>(this + 1) = SubExpr; 59965222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor } 60065222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor 6011060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenekpublic: 602030854b95f7bfd86aaa8afd9ae1aff9768a37e9aChris Lattner CXXDefaultArgExpr(EmptyShell Empty) : Expr(CXXDefaultArgExprClass, Empty) {} 603030854b95f7bfd86aaa8afd9ae1aff9768a37e9aChris Lattner 604030854b95f7bfd86aaa8afd9ae1aff9768a37e9aChris Lattner 6051060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek // Param is the parameter whose default argument is used by this 6061060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek // expression. 607036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor static CXXDefaultArgExpr *Create(ASTContext &C, SourceLocation Loc, 608036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor ParmVarDecl *Param) { 609036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor return new (C) CXXDefaultArgExpr(CXXDefaultArgExprClass, Loc, Param); 610f1480eee38b59d15438fb7bc50865ac7c7e22403Anders Carlsson } 6111060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek 61265222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor // Param is the parameter whose default argument is used by this 61365222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor // expression, and SubExpr is the expression that will actually be used. 614036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor static CXXDefaultArgExpr *Create(ASTContext &C, 615036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor SourceLocation Loc, 616036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor ParmVarDecl *Param, 61765222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor Expr *SubExpr); 61865222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor 6191060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek // Retrieve the parameter that the argument was created from. 62065222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor const ParmVarDecl *getParam() const { return Param.getPointer(); } 62165222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor ParmVarDecl *getParam() { return Param.getPointer(); } 622030854b95f7bfd86aaa8afd9ae1aff9768a37e9aChris Lattner 6231060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek // Retrieve the actual argument to the function call. 62465222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor const Expr *getExpr() const { 62565222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor if (Param.getInt()) 62665222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor return *reinterpret_cast<Expr const * const*> (this + 1); 62765222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor return getParam()->getDefaultArg(); 62865222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor } 62965222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor Expr *getExpr() { 63065222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor if (Param.getInt()) 63165222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor return *reinterpret_cast<Expr **> (this + 1); 63265222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor return getParam()->getDefaultArg(); 63365222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor } 6341060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek 635036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor /// \brief Retrieve the location where this default argument was actually 636036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor /// used. 637036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor SourceLocation getUsedLocation() const { return Loc; } 638036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor 6391060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek virtual SourceRange getSourceRange() const { 6401060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek // Default argument expressions have no representation in the 6411060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek // source, so they have an empty source range. 6421060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek return SourceRange(); 6431060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek } 6441060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek 6451060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek static bool classof(const Stmt *T) { 6461060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek return T->getStmtClass() == CXXDefaultArgExprClass; 6471060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek } 6481060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek static bool classof(const CXXDefaultArgExpr *) { return true; } 6491060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek 6501060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek // Iterators 6511060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek virtual child_iterator child_begin(); 6521060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek virtual child_iterator child_end(); 6538a50733034edd6a349b34e2b9f0c8d0a874846d3Argyrios Kyrtzidis 65460adf4acf40b72227740bf966fb87eebddff3f37Sebastian Redl friend class ASTStmtReader; 6553397c5570369f19b2d6c52e898f708d75ceede1fSebastian Redl friend class ASTStmtWriter; 6561060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek}; 657987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis 658c1ce477119fed070299668aab24084b17ff5f14bAnders Carlsson/// CXXTemporary - Represents a C++ temporary. 659c1ce477119fed070299668aab24084b17ff5f14bAnders Carlssonclass CXXTemporary { 660c1ce477119fed070299668aab24084b17ff5f14bAnders Carlsson /// Destructor - The destructor that needs to be called. 661b859f35459ae3e1188d1e1b86df08d649695fd86Anders Carlsson const CXXDestructorDecl *Destructor; 6621eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 663b859f35459ae3e1188d1e1b86df08d649695fd86Anders Carlsson CXXTemporary(const CXXDestructorDecl *destructor) 664c1ce477119fed070299668aab24084b17ff5f14bAnders Carlsson : Destructor(destructor) { } 665c1ce477119fed070299668aab24084b17ff5f14bAnders Carlsson 666c1ce477119fed070299668aab24084b17ff5f14bAnders Carlssonpublic: 6671eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump static CXXTemporary *Create(ASTContext &C, 668b859f35459ae3e1188d1e1b86df08d649695fd86Anders Carlsson const CXXDestructorDecl *Destructor); 6691eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 670f0721fe438d7e40c168e5d664970e7830bc138fbAnders Carlsson const CXXDestructorDecl *getDestructor() const { return Destructor; } 671c1ce477119fed070299668aab24084b17ff5f14bAnders Carlsson}; 672fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson 673ddfe960d252a93525692b547945236d361d1929fChandler Carruth/// \brief Represents binding an expression to a temporary. 674ddfe960d252a93525692b547945236d361d1929fChandler Carruth/// 675ddfe960d252a93525692b547945236d361d1929fChandler Carruth/// This ensures the destructor is called for the temporary. It should only be 676ddfe960d252a93525692b547945236d361d1929fChandler Carruth/// needed for non-POD, non-trivially destructable class types. For example: 677ddfe960d252a93525692b547945236d361d1929fChandler Carruth/// 678ddfe960d252a93525692b547945236d361d1929fChandler Carruth/// \code 679ddfe960d252a93525692b547945236d361d1929fChandler Carruth/// struct S { 680ddfe960d252a93525692b547945236d361d1929fChandler Carruth/// S() { } // User defined constructor makes S non-POD. 681ddfe960d252a93525692b547945236d361d1929fChandler Carruth/// ~S() { } // User defined destructor makes it non-trivial. 682ddfe960d252a93525692b547945236d361d1929fChandler Carruth/// }; 683ddfe960d252a93525692b547945236d361d1929fChandler Carruth/// void test() { 684ddfe960d252a93525692b547945236d361d1929fChandler Carruth/// const S &s_ref = S(); // Requires a CXXBindTemporaryExpr. 685ddfe960d252a93525692b547945236d361d1929fChandler Carruth/// } 686ddfe960d252a93525692b547945236d361d1929fChandler Carruth/// \endcode 687fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlssonclass CXXBindTemporaryExpr : public Expr { 688fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson CXXTemporary *Temp; 6891eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 690fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson Stmt *SubExpr; 691fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson 692bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor CXXBindTemporaryExpr(CXXTemporary *temp, Expr* SubExpr) 693bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor : Expr(CXXBindTemporaryExprClass, SubExpr->getType(), 694bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor VK_RValue, OK_Ordinary, SubExpr->isTypeDependent(), 695bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor SubExpr->isValueDependent(), 696bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor SubExpr->containsUnexpandedParameterPack()), 697bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor Temp(temp), SubExpr(SubExpr) { } 69888eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlsson 699fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlssonpublic: 700d2598368876cfe40bc8465540033bc5b5e58d8afChris Lattner CXXBindTemporaryExpr(EmptyShell Empty) 701d2598368876cfe40bc8465540033bc5b5e58d8afChris Lattner : Expr(CXXBindTemporaryExprClass, Empty), Temp(0), SubExpr(0) {} 702d2598368876cfe40bc8465540033bc5b5e58d8afChris Lattner 7031eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump static CXXBindTemporaryExpr *Create(ASTContext &C, CXXTemporary *Temp, 704fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson Expr* SubExpr); 7051eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 70688eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlsson CXXTemporary *getTemporary() { return Temp; } 707f0721fe438d7e40c168e5d664970e7830bc138fbAnders Carlsson const CXXTemporary *getTemporary() const { return Temp; } 708d2598368876cfe40bc8465540033bc5b5e58d8afChris Lattner void setTemporary(CXXTemporary *T) { Temp = T; } 709f0721fe438d7e40c168e5d664970e7830bc138fbAnders Carlsson 710fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson const Expr *getSubExpr() const { return cast<Expr>(SubExpr); } 711fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson Expr *getSubExpr() { return cast<Expr>(SubExpr); } 71288eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlsson void setSubExpr(Expr *E) { SubExpr = E; } 713fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson 71496be6917e1c4ba1f4435a14c9e7c6c139571d086Douglas Gregor virtual SourceRange getSourceRange() const { 71596be6917e1c4ba1f4435a14c9e7c6c139571d086Douglas Gregor return SubExpr->getSourceRange(); 71696be6917e1c4ba1f4435a14c9e7c6c139571d086Douglas Gregor } 717fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson 718fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson // Implement isa/cast/dyncast/etc. 719fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson static bool classof(const Stmt *T) { 720fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson return T->getStmtClass() == CXXBindTemporaryExprClass; 721fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson } 722fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson static bool classof(const CXXBindTemporaryExpr *) { return true; } 723fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson 724fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson // Iterators 725fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson virtual child_iterator child_begin(); 726fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson virtual child_iterator child_end(); 727fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson}; 728fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson 72915ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson/// CXXConstructExpr - Represents a call to a C++ constructor. 73015ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlssonclass CXXConstructExpr : public Expr { 73172e96fd181b19b8d01144a685cda6e955584c7eaAnders Carlssonpublic: 73272e96fd181b19b8d01144a685cda6e955584c7eaAnders Carlsson enum ConstructionKind { 73372e96fd181b19b8d01144a685cda6e955584c7eaAnders Carlsson CK_Complete, 73472e96fd181b19b8d01144a685cda6e955584c7eaAnders Carlsson CK_NonVirtualBase, 73572e96fd181b19b8d01144a685cda6e955584c7eaAnders Carlsson CK_VirtualBase 73672e96fd181b19b8d01144a685cda6e955584c7eaAnders Carlsson }; 73772e96fd181b19b8d01144a685cda6e955584c7eaAnders Carlsson 73872e96fd181b19b8d01144a685cda6e955584c7eaAnders Carlssonprivate: 73915ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson CXXConstructorDecl *Constructor; 74015ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson 74199a2e600f9e2e51d3ce10fb6f27191677ac65b2aDouglas Gregor SourceLocation Loc; 742428edafa9eb80e01dd40aab31d4166a787a741e1Chandler Carruth SourceRange ParenRange; 74316006c901315fa12a108b4e571f187f4b676e426Douglas Gregor bool Elidable : 1; 74416006c901315fa12a108b4e571f187f4b676e426Douglas Gregor bool ZeroInitialization : 1; 74572e96fd181b19b8d01144a685cda6e955584c7eaAnders Carlsson unsigned ConstructKind : 2; 74615ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson Stmt **Args; 74715ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson unsigned NumArgs; 7481eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 749bd6734e5f6432ce0cc07171c490ffaa094796198Anders Carlssonprotected: 7501eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump CXXConstructExpr(ASTContext &C, StmtClass SC, QualType T, 75199a2e600f9e2e51d3ce10fb6f27191677ac65b2aDouglas Gregor SourceLocation Loc, 752bd6734e5f6432ce0cc07171c490ffaa094796198Anders Carlsson CXXConstructorDecl *d, bool elidable, 75316006c901315fa12a108b4e571f187f4b676e426Douglas Gregor Expr **args, unsigned numargs, 7549db7dbb918ca49f4ee6c181e4917e7b6ec547353Douglas Gregor bool ZeroInitialization = false, 755428edafa9eb80e01dd40aab31d4166a787a741e1Chandler Carruth ConstructionKind ConstructKind = CK_Complete, 756428edafa9eb80e01dd40aab31d4166a787a741e1Chandler Carruth SourceRange ParenRange = SourceRange()); 757bd6734e5f6432ce0cc07171c490ffaa094796198Anders Carlsson 7586d00c1365dd3601f6d93bbda9162913c57ae788fArgyrios Kyrtzidis /// \brief Construct an empty C++ construction expression. 7596d00c1365dd3601f6d93bbda9162913c57ae788fArgyrios Kyrtzidis CXXConstructExpr(StmtClass SC, EmptyShell Empty) 7606d00c1365dd3601f6d93bbda9162913c57ae788fArgyrios Kyrtzidis : Expr(SC, Empty), Constructor(0), Elidable(0), ZeroInitialization(0), 7616d00c1365dd3601f6d93bbda9162913c57ae788fArgyrios Kyrtzidis ConstructKind(0), Args(0), NumArgs(0) { } 7626d00c1365dd3601f6d93bbda9162913c57ae788fArgyrios Kyrtzidis 76315ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlssonpublic: 7646d00c1365dd3601f6d93bbda9162913c57ae788fArgyrios Kyrtzidis /// \brief Construct an empty C++ construction expression. 7656d00c1365dd3601f6d93bbda9162913c57ae788fArgyrios Kyrtzidis explicit CXXConstructExpr(EmptyShell Empty) 7666d00c1365dd3601f6d93bbda9162913c57ae788fArgyrios Kyrtzidis : Expr(CXXConstructExprClass, Empty), Constructor(0), 7676d00c1365dd3601f6d93bbda9162913c57ae788fArgyrios Kyrtzidis Elidable(0), ZeroInitialization(0), 7686d00c1365dd3601f6d93bbda9162913c57ae788fArgyrios Kyrtzidis ConstructKind(0), Args(0), NumArgs(0) { } 7696d00c1365dd3601f6d93bbda9162913c57ae788fArgyrios Kyrtzidis 7708e587a15da6d3457a418239d5eb4146fcbd209f3Anders Carlsson static CXXConstructExpr *Create(ASTContext &C, QualType T, 77199a2e600f9e2e51d3ce10fb6f27191677ac65b2aDouglas Gregor SourceLocation Loc, 7721eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump CXXConstructorDecl *D, bool Elidable, 77316006c901315fa12a108b4e571f187f4b676e426Douglas Gregor Expr **Args, unsigned NumArgs, 7749db7dbb918ca49f4ee6c181e4917e7b6ec547353Douglas Gregor bool ZeroInitialization = false, 775428edafa9eb80e01dd40aab31d4166a787a741e1Chandler Carruth ConstructionKind ConstructKind = CK_Complete, 776428edafa9eb80e01dd40aab31d4166a787a741e1Chandler Carruth SourceRange ParenRange = SourceRange()); 7771eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 7781eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 779d94546a0a1deef7286c13e49b9584621ae81cc9aDouglas Gregor CXXConstructorDecl* getConstructor() const { return Constructor; } 78039da0b8145eaec7da7004f9b3645c5c9f4f63b1dDouglas Gregor void setConstructor(CXXConstructorDecl *C) { Constructor = C; } 78139da0b8145eaec7da7004f9b3645c5c9f4f63b1dDouglas Gregor 78299a2e600f9e2e51d3ce10fb6f27191677ac65b2aDouglas Gregor SourceLocation getLocation() const { return Loc; } 78399a2e600f9e2e51d3ce10fb6f27191677ac65b2aDouglas Gregor void setLocation(SourceLocation Loc) { this->Loc = Loc; } 78499a2e600f9e2e51d3ce10fb6f27191677ac65b2aDouglas Gregor 785d94546a0a1deef7286c13e49b9584621ae81cc9aDouglas Gregor /// \brief Whether this construction is elidable. 786d94546a0a1deef7286c13e49b9584621ae81cc9aDouglas Gregor bool isElidable() const { return Elidable; } 78739da0b8145eaec7da7004f9b3645c5c9f4f63b1dDouglas Gregor void setElidable(bool E) { Elidable = E; } 78839da0b8145eaec7da7004f9b3645c5c9f4f63b1dDouglas Gregor 78916006c901315fa12a108b4e571f187f4b676e426Douglas Gregor /// \brief Whether this construction first requires 79016006c901315fa12a108b4e571f187f4b676e426Douglas Gregor /// zero-initialization before the initializer is called. 79116006c901315fa12a108b4e571f187f4b676e426Douglas Gregor bool requiresZeroInitialization() const { return ZeroInitialization; } 79216006c901315fa12a108b4e571f187f4b676e426Douglas Gregor void setRequiresZeroInitialization(bool ZeroInit) { 79316006c901315fa12a108b4e571f187f4b676e426Douglas Gregor ZeroInitialization = ZeroInit; 79416006c901315fa12a108b4e571f187f4b676e426Douglas Gregor } 79516006c901315fa12a108b4e571f187f4b676e426Douglas Gregor 7969db7dbb918ca49f4ee6c181e4917e7b6ec547353Douglas Gregor /// \brief Determines whether this constructor is actually constructing 7979db7dbb918ca49f4ee6c181e4917e7b6ec547353Douglas Gregor /// a base class (rather than a complete object). 79824eb78e38aba55c507bc3c05c37035a9ab2defa7Anders Carlsson ConstructionKind getConstructionKind() const { 79924eb78e38aba55c507bc3c05c37035a9ab2defa7Anders Carlsson return (ConstructionKind)ConstructKind; 80072e96fd181b19b8d01144a685cda6e955584c7eaAnders Carlsson } 80172e96fd181b19b8d01144a685cda6e955584c7eaAnders Carlsson void setConstructionKind(ConstructionKind CK) { 80272e96fd181b19b8d01144a685cda6e955584c7eaAnders Carlsson ConstructKind = CK; 80372e96fd181b19b8d01144a685cda6e955584c7eaAnders Carlsson } 8049db7dbb918ca49f4ee6c181e4917e7b6ec547353Douglas Gregor 80515ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson typedef ExprIterator arg_iterator; 80615ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson typedef ConstExprIterator const_arg_iterator; 8071eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 80815ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson arg_iterator arg_begin() { return Args; } 80915ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson arg_iterator arg_end() { return Args + NumArgs; } 81015ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson const_arg_iterator arg_begin() const { return Args; } 81115ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson const_arg_iterator arg_end() const { return Args + NumArgs; } 81215ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson 813a88cfbfac9bbcbb9858f048d6d73a48711d8e93dDouglas Gregor Expr **getArgs() const { return reinterpret_cast<Expr **>(Args); } 81415ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson unsigned getNumArgs() const { return NumArgs; } 81515ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson 816bcb11d01c034f967503bd98f28bdf458c1ab8001Anders Carlsson /// getArg - Return the specified argument. 817bcb11d01c034f967503bd98f28bdf458c1ab8001Anders Carlsson Expr *getArg(unsigned Arg) { 818bcb11d01c034f967503bd98f28bdf458c1ab8001Anders Carlsson assert(Arg < NumArgs && "Arg access out of range!"); 819bcb11d01c034f967503bd98f28bdf458c1ab8001Anders Carlsson return cast<Expr>(Args[Arg]); 820bcb11d01c034f967503bd98f28bdf458c1ab8001Anders Carlsson } 821bcb11d01c034f967503bd98f28bdf458c1ab8001Anders Carlsson const Expr *getArg(unsigned Arg) const { 822bcb11d01c034f967503bd98f28bdf458c1ab8001Anders Carlsson assert(Arg < NumArgs && "Arg access out of range!"); 823bcb11d01c034f967503bd98f28bdf458c1ab8001Anders Carlsson return cast<Expr>(Args[Arg]); 824bcb11d01c034f967503bd98f28bdf458c1ab8001Anders Carlsson } 8251eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 8262eeed7bc4fd457ac57ff32ab3b02674588545f65Fariborz Jahanian /// setArg - Set the specified argument. 8272eeed7bc4fd457ac57ff32ab3b02674588545f65Fariborz Jahanian void setArg(unsigned Arg, Expr *ArgExpr) { 8282eeed7bc4fd457ac57ff32ab3b02674588545f65Fariborz Jahanian assert(Arg < NumArgs && "Arg access out of range!"); 8292eeed7bc4fd457ac57ff32ab3b02674588545f65Fariborz Jahanian Args[Arg] = ArgExpr; 8302eeed7bc4fd457ac57ff32ab3b02674588545f65Fariborz Jahanian } 8312eeed7bc4fd457ac57ff32ab3b02674588545f65Fariborz Jahanian 832e383768f7f5d45ca4af0b1c11cbf072de18bce98Ted Kremenek virtual SourceRange getSourceRange() const; 833428edafa9eb80e01dd40aab31d4166a787a741e1Chandler Carruth SourceRange getParenRange() const { return ParenRange; } 83415ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson 8351eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump static bool classof(const Stmt *T) { 836524fa13fd81e88533c7a1d4b1232c0de2c97dc7cAnders Carlsson return T->getStmtClass() == CXXConstructExprClass || 837524fa13fd81e88533c7a1d4b1232c0de2c97dc7cAnders Carlsson T->getStmtClass() == CXXTemporaryObjectExprClass; 83815ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson } 83915ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson static bool classof(const CXXConstructExpr *) { return true; } 8401eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 84115ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson // Iterators 84215ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson virtual child_iterator child_begin(); 84315ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson virtual child_iterator child_end(); 8446d00c1365dd3601f6d93bbda9162913c57ae788fArgyrios Kyrtzidis 84560adf4acf40b72227740bf966fb87eebddff3f37Sebastian Redl friend class ASTStmtReader; 84615ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson}; 84715ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson 84849badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// CXXFunctionalCastExpr - Represents an explicit C++ type conversion 84949badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// that uses "functional" notion (C++ [expr.type.conv]). Example: @c 85049badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// x = int(0.5); 85149badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregorclass CXXFunctionalCastExpr : public ExplicitCastExpr { 852987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis SourceLocation TyBeginLoc; 853987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis SourceLocation RParenLoc; 854f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall 855f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall CXXFunctionalCastExpr(QualType ty, ExprValueKind VK, 856f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall TypeSourceInfo *writtenTy, 8571eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump SourceLocation tyBeginLoc, CastKind kind, 858f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall Expr *castExpr, unsigned pathSize, 85941b2dcd465f1e438502c420effc9d0c747f9db8fAnders Carlsson SourceLocation rParenLoc) 860f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall : ExplicitCastExpr(CXXFunctionalCastExprClass, ty, VK, kind, 861f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall castExpr, pathSize, writtenTy), 8620aebc81e02397a5987aaa8e8c7acbdb01a31d7c3Anders Carlsson TyBeginLoc(tyBeginLoc), RParenLoc(rParenLoc) {} 8630aebc81e02397a5987aaa8e8c7acbdb01a31d7c3Anders Carlsson 864f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall explicit CXXFunctionalCastExpr(EmptyShell Shell, unsigned PathSize) 865f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall : ExplicitCastExpr(CXXFunctionalCastExprClass, Shell, PathSize) { } 866f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall 867f871d0cc377a1367b519a6cce26be74607566ebaJohn McCallpublic: 868f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall static CXXFunctionalCastExpr *Create(ASTContext &Context, QualType T, 869f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall ExprValueKind VK, 870f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall TypeSourceInfo *Written, 871f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall SourceLocation TyBeginLoc, 872f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall CastKind Kind, Expr *Op, 873f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall const CXXCastPath *Path, 874f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall SourceLocation RPLoc); 875f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall static CXXFunctionalCastExpr *CreateEmpty(ASTContext &Context, 876f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall unsigned PathSize); 877ce757a7a1ee905f87551996a69da3e95e8afeeb7Sam Weinig 878987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis SourceLocation getTypeBeginLoc() const { return TyBeginLoc; } 879ce757a7a1ee905f87551996a69da3e95e8afeeb7Sam Weinig void setTypeBeginLoc(SourceLocation L) { TyBeginLoc = L; } 880987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis SourceLocation getRParenLoc() const { return RParenLoc; } 881ce757a7a1ee905f87551996a69da3e95e8afeeb7Sam Weinig void setRParenLoc(SourceLocation L) { RParenLoc = L; } 8821eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 883987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis virtual SourceRange getSourceRange() const { 884987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis return SourceRange(TyBeginLoc, RParenLoc); 885987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis } 8861eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump static bool classof(const Stmt *T) { 8871eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump return T->getStmtClass() == CXXFunctionalCastExprClass; 888987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis } 889987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis static bool classof(const CXXFunctionalCastExpr *) { return true; } 890987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis}; 891987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis 892506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// @brief Represents a C++ functional cast expression that builds a 893506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// temporary object. 894506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// 8951eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump/// This expression type represents a C++ "functional" cast 896506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// (C++[expr.type.conv]) with N != 1 arguments that invokes a 897ed8abf18329df67b0abcbb3a10458bd8c1d2a595Douglas Gregor/// constructor to build a temporary object. With N == 1 arguments the 898ed8abf18329df67b0abcbb3a10458bd8c1d2a595Douglas Gregor/// functional cast expression will be represented by CXXFunctionalCastExpr. 899506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// Example: 900506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// @code 901506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// struct X { X(int, float); } 902506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// 903506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// X create_X() { 904506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// return X(1, 3.14f); // creates a CXXTemporaryObjectExpr 905506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// }; 906506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// @endcode 907524fa13fd81e88533c7a1d4b1232c0de2c97dc7cAnders Carlssonclass CXXTemporaryObjectExpr : public CXXConstructExpr { 908ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor TypeSourceInfo *Type; 909506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor 910506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregorpublic: 9111eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump CXXTemporaryObjectExpr(ASTContext &C, CXXConstructorDecl *Cons, 912ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor TypeSourceInfo *Type, 9131eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump Expr **Args,unsigned NumArgs, 914428edafa9eb80e01dd40aab31d4166a787a741e1Chandler Carruth SourceRange parenRange, 9151c63b9c15d48cb8c833a4b2d6fd6c496c0766e88Douglas Gregor bool ZeroInitialization = false); 9166d00c1365dd3601f6d93bbda9162913c57ae788fArgyrios Kyrtzidis explicit CXXTemporaryObjectExpr(EmptyShell Empty) 917ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor : CXXConstructExpr(CXXTemporaryObjectExprClass, Empty), Type() { } 918506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor 919ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor TypeSourceInfo *getTypeSourceInfo() const { return Type; } 920ba49817c5b9f502602672861cf369fd0e53966e8Douglas Gregor 921ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor virtual SourceRange getSourceRange() const; 922ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor 9231eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump static bool classof(const Stmt *T) { 924506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor return T->getStmtClass() == CXXTemporaryObjectExprClass; 925506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor } 926506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor static bool classof(const CXXTemporaryObjectExpr *) { return true; } 9276d00c1365dd3601f6d93bbda9162913c57ae788fArgyrios Kyrtzidis 92860adf4acf40b72227740bf966fb87eebddff3f37Sebastian Redl friend class ASTStmtReader; 929506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor}; 930506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor 931ed8abf18329df67b0abcbb3a10458bd8c1d2a595Douglas Gregor/// CXXScalarValueInitExpr - [C++ 5.2.3p2] 932506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// Expression "T()" which creates a value-initialized rvalue of type 933ed8abf18329df67b0abcbb3a10458bd8c1d2a595Douglas Gregor/// T, which is a non-class type. 934987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis/// 935ed8abf18329df67b0abcbb3a10458bd8c1d2a595Douglas Gregorclass CXXScalarValueInitExpr : public Expr { 936987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis SourceLocation RParenLoc; 937ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor TypeSourceInfo *TypeInfo; 938987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis 939ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor friend class ASTStmtReader; 940ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor 941987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidispublic: 942ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor /// \brief Create an explicitly-written scalar-value initialization 943ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor /// expression. 944ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor CXXScalarValueInitExpr(QualType Type, 945ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor TypeSourceInfo *TypeInfo, 946ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor SourceLocation rParenLoc ) : 947f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall Expr(CXXScalarValueInitExprClass, Type, VK_RValue, OK_Ordinary, 948bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor false, false, false), 949ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor RParenLoc(rParenLoc), TypeInfo(TypeInfo) {} 950ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor 951ed8abf18329df67b0abcbb3a10458bd8c1d2a595Douglas Gregor explicit CXXScalarValueInitExpr(EmptyShell Shell) 952ed8abf18329df67b0abcbb3a10458bd8c1d2a595Douglas Gregor : Expr(CXXScalarValueInitExprClass, Shell) { } 9531eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 954ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor TypeSourceInfo *getTypeSourceInfo() const { 955ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor return TypeInfo; 9564c67834407ca6ab344dcf44fc599ad4938cfa96dDouglas Gregor } 957ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor 958ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor SourceLocation getRParenLoc() const { return RParenLoc; } 9594c67834407ca6ab344dcf44fc599ad4938cfa96dDouglas Gregor 960ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor virtual SourceRange getSourceRange() const; 9611eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 9621eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump static bool classof(const Stmt *T) { 963ed8abf18329df67b0abcbb3a10458bd8c1d2a595Douglas Gregor return T->getStmtClass() == CXXScalarValueInitExprClass; 964987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis } 965ed8abf18329df67b0abcbb3a10458bd8c1d2a595Douglas Gregor static bool classof(const CXXScalarValueInitExpr *) { return true; } 9661eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 967987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis // Iterators 968987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis virtual child_iterator child_begin(); 969987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis virtual child_iterator child_end(); 970987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis}; 971987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis 9724c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl/// CXXNewExpr - A new expression for memory allocation and constructor calls, 9734c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl/// e.g: "new CXXNewExpr(foo)". 9744c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redlclass CXXNewExpr : public Expr { 9754c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // Was the usage ::new, i.e. is the global new to be used? 9764c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl bool GlobalNew : 1; 9774c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // Is there an initializer? If not, built-ins are uninitialized, else they're 9784c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // value-initialized. 9794c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl bool Initializer : 1; 980cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl // Do we allocate an array? If so, the first SubExpr is the size expression. 981cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl bool Array : 1; 9824c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // The number of placement new arguments. 983e4b8f1171d699c56ba2b39aabf1d7cb4c38ce4f8Douglas Gregor unsigned NumPlacementArgs : 15; 9844c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // The number of constructor arguments. This may be 1 even for non-class 9854c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // types; use the pseudo copy constructor. 986cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl unsigned NumConstructorArgs : 14; 987cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl // Contains an optional array size expression, any number of optional 988cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl // placement arguments, and any number of optional constructor arguments, 989cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl // in that order. 9904c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl Stmt **SubExprs; 9914c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // Points to the allocation function used. 9924c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl FunctionDecl *OperatorNew; 9934c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // Points to the deallocation function used in case of error. May be null. 9944c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl FunctionDecl *OperatorDelete; 9954c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // Points to the constructor used. Cannot be null if AllocType is a record; 9964c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // it would still point at the default constructor (even an implicit one). 9974c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // Must be null for all other types. 9984c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl CXXConstructorDecl *Constructor; 9994c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 10001bb2a93ab7b1499dda6f6b58865bd0dce1864228Douglas Gregor /// \brief The allocated type-source information, as written in the source. 10011bb2a93ab7b1499dda6f6b58865bd0dce1864228Douglas Gregor TypeSourceInfo *AllocatedTypeInfo; 10021bb2a93ab7b1499dda6f6b58865bd0dce1864228Douglas Gregor 10034bd40318cbea15310a37343db46de96c4fcc15e6Douglas Gregor /// \brief If the allocated type was expressed as a parenthesized type-id, 10044bd40318cbea15310a37343db46de96c4fcc15e6Douglas Gregor /// the source range covering the parenthesized type-id. 10054bd40318cbea15310a37343db46de96c4fcc15e6Douglas Gregor SourceRange TypeIdParens; 10064bd40318cbea15310a37343db46de96c4fcc15e6Douglas Gregor 10074c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl SourceLocation StartLoc; 10084c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl SourceLocation EndLoc; 1009428edafa9eb80e01dd40aab31d4166a787a741e1Chandler Carruth SourceLocation ConstructorLParen; 1010428edafa9eb80e01dd40aab31d4166a787a741e1Chandler Carruth SourceLocation ConstructorRParen; 10114c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 101260adf4acf40b72227740bf966fb87eebddff3f37Sebastian Redl friend class ASTStmtReader; 10134c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redlpublic: 1014ad7fe864862305c2f71e047cdf6706ef43aebdc0Ted Kremenek CXXNewExpr(ASTContext &C, bool globalNew, FunctionDecl *operatorNew, 10154bd40318cbea15310a37343db46de96c4fcc15e6Douglas Gregor Expr **placementArgs, unsigned numPlaceArgs, 10164bd40318cbea15310a37343db46de96c4fcc15e6Douglas Gregor SourceRange TypeIdParens, 1017ad7fe864862305c2f71e047cdf6706ef43aebdc0Ted Kremenek Expr *arraySize, CXXConstructorDecl *constructor, bool initializer, 10184c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl Expr **constructorArgs, unsigned numConsArgs, 10194c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl FunctionDecl *operatorDelete, QualType ty, 10201bb2a93ab7b1499dda6f6b58865bd0dce1864228Douglas Gregor TypeSourceInfo *AllocatedTypeInfo, 1021428edafa9eb80e01dd40aab31d4166a787a741e1Chandler Carruth SourceLocation startLoc, SourceLocation endLoc, 1022428edafa9eb80e01dd40aab31d4166a787a741e1Chandler Carruth SourceLocation constructorLParen, 1023428edafa9eb80e01dd40aab31d4166a787a741e1Chandler Carruth SourceLocation constructorRParen); 10245921863d8f24084797863b5df37842113bac4352Chris Lattner explicit CXXNewExpr(EmptyShell Shell) 10255921863d8f24084797863b5df37842113bac4352Chris Lattner : Expr(CXXNewExprClass, Shell), SubExprs(0) { } 10265921863d8f24084797863b5df37842113bac4352Chris Lattner 10275921863d8f24084797863b5df37842113bac4352Chris Lattner void AllocateArgsArray(ASTContext &C, bool isArray, unsigned numPlaceArgs, 10285921863d8f24084797863b5df37842113bac4352Chris Lattner unsigned numConsArgs); 1029ad7fe864862305c2f71e047cdf6706ef43aebdc0Ted Kremenek 1030cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl QualType getAllocatedType() const { 1031cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl assert(getType()->isPointerType()); 10326217b80b7a1379b74cced1c076338262c3c980b3Ted Kremenek return getType()->getAs<PointerType>()->getPointeeType(); 1033cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl } 10344c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 10351bb2a93ab7b1499dda6f6b58865bd0dce1864228Douglas Gregor TypeSourceInfo *getAllocatedTypeSourceInfo() const { 10361bb2a93ab7b1499dda6f6b58865bd0dce1864228Douglas Gregor return AllocatedTypeInfo; 10371bb2a93ab7b1499dda6f6b58865bd0dce1864228Douglas Gregor } 10381bb2a93ab7b1499dda6f6b58865bd0dce1864228Douglas Gregor 10394c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl FunctionDecl *getOperatorNew() const { return OperatorNew; } 10405921863d8f24084797863b5df37842113bac4352Chris Lattner void setOperatorNew(FunctionDecl *D) { OperatorNew = D; } 10414c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl FunctionDecl *getOperatorDelete() const { return OperatorDelete; } 10425921863d8f24084797863b5df37842113bac4352Chris Lattner void setOperatorDelete(FunctionDecl *D) { OperatorDelete = D; } 10434c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl CXXConstructorDecl *getConstructor() const { return Constructor; } 10445921863d8f24084797863b5df37842113bac4352Chris Lattner void setConstructor(CXXConstructorDecl *D) { Constructor = D; } 10454c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 1046cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl bool isArray() const { return Array; } 1047cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl Expr *getArraySize() { 1048cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl return Array ? cast<Expr>(SubExprs[0]) : 0; 1049cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl } 1050cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl const Expr *getArraySize() const { 1051cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl return Array ? cast<Expr>(SubExprs[0]) : 0; 1052cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl } 1053cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl 10544c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl unsigned getNumPlacementArgs() const { return NumPlacementArgs; } 1055aa165f8458b51c546bebff947343e1a36f3594cbDouglas Gregor Expr **getPlacementArgs() { 1056aa165f8458b51c546bebff947343e1a36f3594cbDouglas Gregor return reinterpret_cast<Expr **>(SubExprs + Array); 1057aa165f8458b51c546bebff947343e1a36f3594cbDouglas Gregor } 1058aa165f8458b51c546bebff947343e1a36f3594cbDouglas Gregor 10594c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl Expr *getPlacementArg(unsigned i) { 10604c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl assert(i < NumPlacementArgs && "Index out of range"); 1061cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl return cast<Expr>(SubExprs[Array + i]); 10624c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 10634c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl const Expr *getPlacementArg(unsigned i) const { 10644c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl assert(i < NumPlacementArgs && "Index out of range"); 1065cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl return cast<Expr>(SubExprs[Array + i]); 10664c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 10674c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 10684bd40318cbea15310a37343db46de96c4fcc15e6Douglas Gregor bool isParenTypeId() const { return TypeIdParens.isValid(); } 10694bd40318cbea15310a37343db46de96c4fcc15e6Douglas Gregor SourceRange getTypeIdParens() const { return TypeIdParens; } 10704bd40318cbea15310a37343db46de96c4fcc15e6Douglas Gregor 10714c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl bool isGlobalNew() const { return GlobalNew; } 10725921863d8f24084797863b5df37842113bac4352Chris Lattner void setGlobalNew(bool V) { GlobalNew = V; } 10734c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl bool hasInitializer() const { return Initializer; } 10745921863d8f24084797863b5df37842113bac4352Chris Lattner void setHasInitializer(bool V) { Initializer = V; } 10754c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 10764c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl unsigned getNumConstructorArgs() const { return NumConstructorArgs; } 1077aa165f8458b51c546bebff947343e1a36f3594cbDouglas Gregor 1078aa165f8458b51c546bebff947343e1a36f3594cbDouglas Gregor Expr **getConstructorArgs() { 1079aa165f8458b51c546bebff947343e1a36f3594cbDouglas Gregor return reinterpret_cast<Expr **>(SubExprs + Array + NumPlacementArgs); 1080aa165f8458b51c546bebff947343e1a36f3594cbDouglas Gregor } 1081aa165f8458b51c546bebff947343e1a36f3594cbDouglas Gregor 10824c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl Expr *getConstructorArg(unsigned i) { 10834c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl assert(i < NumConstructorArgs && "Index out of range"); 1084cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl return cast<Expr>(SubExprs[Array + NumPlacementArgs + i]); 10854c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 10864c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl const Expr *getConstructorArg(unsigned i) const { 10874c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl assert(i < NumConstructorArgs && "Index out of range"); 1088cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl return cast<Expr>(SubExprs[Array + NumPlacementArgs + i]); 10894c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 10904c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 10914c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl typedef ExprIterator arg_iterator; 10924c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl typedef ConstExprIterator const_arg_iterator; 10934c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 10944c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl arg_iterator placement_arg_begin() { 1095cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl return SubExprs + Array; 10964c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 10974c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl arg_iterator placement_arg_end() { 1098cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl return SubExprs + Array + getNumPlacementArgs(); 10994c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 11004c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl const_arg_iterator placement_arg_begin() const { 1101cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl return SubExprs + Array; 11024c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 11034c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl const_arg_iterator placement_arg_end() const { 1104cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl return SubExprs + Array + getNumPlacementArgs(); 11054c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 11064c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 11074c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl arg_iterator constructor_arg_begin() { 1108cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl return SubExprs + Array + getNumPlacementArgs(); 11094c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 11104c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl arg_iterator constructor_arg_end() { 1111cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl return SubExprs + Array + getNumPlacementArgs() + getNumConstructorArgs(); 11124c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 11134c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl const_arg_iterator constructor_arg_begin() const { 1114cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl return SubExprs + Array + getNumPlacementArgs(); 11154c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 11164c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl const_arg_iterator constructor_arg_end() const { 1117cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl return SubExprs + Array + getNumPlacementArgs() + getNumConstructorArgs(); 11184c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 11195921863d8f24084797863b5df37842113bac4352Chris Lattner 11205921863d8f24084797863b5df37842113bac4352Chris Lattner typedef Stmt **raw_arg_iterator; 11215921863d8f24084797863b5df37842113bac4352Chris Lattner raw_arg_iterator raw_arg_begin() { return SubExprs; } 11225921863d8f24084797863b5df37842113bac4352Chris Lattner raw_arg_iterator raw_arg_end() { 11235921863d8f24084797863b5df37842113bac4352Chris Lattner return SubExprs + Array + getNumPlacementArgs() + getNumConstructorArgs(); 11245921863d8f24084797863b5df37842113bac4352Chris Lattner } 11255921863d8f24084797863b5df37842113bac4352Chris Lattner const_arg_iterator raw_arg_begin() const { return SubExprs; } 11265921863d8f24084797863b5df37842113bac4352Chris Lattner const_arg_iterator raw_arg_end() const { return constructor_arg_end(); } 11274c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 11285921863d8f24084797863b5df37842113bac4352Chris Lattner SourceLocation getStartLoc() const { return StartLoc; } 11295921863d8f24084797863b5df37842113bac4352Chris Lattner SourceLocation getEndLoc() const { return EndLoc; } 1130428edafa9eb80e01dd40aab31d4166a787a741e1Chandler Carruth 1131428edafa9eb80e01dd40aab31d4166a787a741e1Chandler Carruth SourceLocation getConstructorLParen() const { return ConstructorLParen; } 1132428edafa9eb80e01dd40aab31d4166a787a741e1Chandler Carruth SourceLocation getConstructorRParen() const { return ConstructorRParen; } 1133428edafa9eb80e01dd40aab31d4166a787a741e1Chandler Carruth 11344c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl virtual SourceRange getSourceRange() const { 11354c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl return SourceRange(StartLoc, EndLoc); 11364c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 11374c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 11384c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl static bool classof(const Stmt *T) { 11394c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl return T->getStmtClass() == CXXNewExprClass; 11404c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 11414c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl static bool classof(const CXXNewExpr *) { return true; } 11424c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 11434c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // Iterators 11444c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl virtual child_iterator child_begin(); 11454c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl virtual child_iterator child_end(); 11464c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl}; 11474c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 11484c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl/// CXXDeleteExpr - A delete expression for memory deallocation and destructor 11494c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl/// calls, e.g. "delete[] pArray". 11504c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redlclass CXXDeleteExpr : public Expr { 11514c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // Is this a forced global delete, i.e. "::delete"? 11524c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl bool GlobalDelete : 1; 11534c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // Is this the array form of delete, i.e. "delete[]"? 11544c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl bool ArrayForm : 1; 11554076dacf1497fb95cb298b9d964fbdbdaf9bde6cArgyrios Kyrtzidis // ArrayFormAsWritten can be different from ArrayForm if 'delete' is applied 11564076dacf1497fb95cb298b9d964fbdbdaf9bde6cArgyrios Kyrtzidis // to pointer-to-array type (ArrayFormAsWritten will be false while ArrayForm 11574076dacf1497fb95cb298b9d964fbdbdaf9bde6cArgyrios Kyrtzidis // will be true). 11584076dacf1497fb95cb298b9d964fbdbdaf9bde6cArgyrios Kyrtzidis bool ArrayFormAsWritten : 1; 11594c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // Points to the operator delete overload that is used. Could be a member. 11604c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl FunctionDecl *OperatorDelete; 11614c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // The pointer expression to be deleted. 11624c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl Stmt *Argument; 11634c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // Location of the expression. 11644c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl SourceLocation Loc; 11654c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redlpublic: 11664c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl CXXDeleteExpr(QualType ty, bool globalDelete, bool arrayForm, 11674076dacf1497fb95cb298b9d964fbdbdaf9bde6cArgyrios Kyrtzidis bool arrayFormAsWritten, FunctionDecl *operatorDelete, 11684076dacf1497fb95cb298b9d964fbdbdaf9bde6cArgyrios Kyrtzidis Expr *arg, SourceLocation loc) 1169bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor : Expr(CXXDeleteExprClass, ty, VK_RValue, OK_Ordinary, false, false, 1170bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor arg->containsUnexpandedParameterPack()), 1171f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall GlobalDelete(globalDelete), 11724076dacf1497fb95cb298b9d964fbdbdaf9bde6cArgyrios Kyrtzidis ArrayForm(arrayForm), ArrayFormAsWritten(arrayFormAsWritten), 11734076dacf1497fb95cb298b9d964fbdbdaf9bde6cArgyrios Kyrtzidis OperatorDelete(operatorDelete), Argument(arg), Loc(loc) { } 117495fc98ce95d4faa4f1bb2783384150530404ea6fArgyrios Kyrtzidis explicit CXXDeleteExpr(EmptyShell Shell) 117595fc98ce95d4faa4f1bb2783384150530404ea6fArgyrios Kyrtzidis : Expr(CXXDeleteExprClass, Shell), OperatorDelete(0), Argument(0) { } 11764c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 11774c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl bool isGlobalDelete() const { return GlobalDelete; } 11784c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl bool isArrayForm() const { return ArrayForm; } 11794076dacf1497fb95cb298b9d964fbdbdaf9bde6cArgyrios Kyrtzidis bool isArrayFormAsWritten() const { return ArrayFormAsWritten; } 11804c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 11814c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl FunctionDecl *getOperatorDelete() const { return OperatorDelete; } 11824c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 11834c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl Expr *getArgument() { return cast<Expr>(Argument); } 11844c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl const Expr *getArgument() const { return cast<Expr>(Argument); } 11854c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 1186a437ad3ec5b407ede394d74e6f9f463fa3657dbeCraig Silverstein /// \brief Retrieve the type being destroyed. If the type being 1187a437ad3ec5b407ede394d74e6f9f463fa3657dbeCraig Silverstein /// destroyed is a dependent type which may or may not be a pointer, 1188a437ad3ec5b407ede394d74e6f9f463fa3657dbeCraig Silverstein /// return an invalid type. 11895833b0b831d6afae2885e6af420e2bda639652e6Douglas Gregor QualType getDestroyedType() const; 11905833b0b831d6afae2885e6af420e2bda639652e6Douglas Gregor 11914c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl virtual SourceRange getSourceRange() const { 11924c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl return SourceRange(Loc, Argument->getLocEnd()); 11934c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 11944c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 11954c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl static bool classof(const Stmt *T) { 11964c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl return T->getStmtClass() == CXXDeleteExprClass; 11974c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 11984c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl static bool classof(const CXXDeleteExpr *) { return true; } 11994c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 12004c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // Iterators 12014c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl virtual child_iterator child_begin(); 12024c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl virtual child_iterator child_end(); 1203f1b8911d35bb2830a13267581d3cbde4b6b85db6Argyrios Kyrtzidis 1204f1b8911d35bb2830a13267581d3cbde4b6b85db6Argyrios Kyrtzidis friend class ASTStmtReader; 12054c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl}; 12064c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 1207a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor/// \brief Structure used to store the type being destroyed by a 1208a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor/// pseudo-destructor expression. 1209a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregorclass PseudoDestructorTypeStorage { 1210a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor /// \brief Either the type source information or the name of the type, if 1211a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor /// it couldn't be resolved due to type-dependence. 1212a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor llvm::PointerUnion<TypeSourceInfo *, IdentifierInfo *> Type; 1213a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor 1214a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor /// \brief The starting source location of the pseudo-destructor type. 1215a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor SourceLocation Location; 1216a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor 1217a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregorpublic: 1218a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor PseudoDestructorTypeStorage() { } 1219a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor 1220a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor PseudoDestructorTypeStorage(IdentifierInfo *II, SourceLocation Loc) 1221a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor : Type(II), Location(Loc) { } 1222a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor 1223a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor PseudoDestructorTypeStorage(TypeSourceInfo *Info); 1224a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor 1225a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor TypeSourceInfo *getTypeSourceInfo() const { 1226a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor return Type.dyn_cast<TypeSourceInfo *>(); 1227a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor } 1228a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor 1229a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor IdentifierInfo *getIdentifier() const { 1230a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor return Type.dyn_cast<IdentifierInfo *>(); 1231a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor } 1232a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor 1233a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor SourceLocation getLocation() const { return Location; } 1234a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor}; 1235a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor 1236a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor/// \brief Represents a C++ pseudo-destructor (C++ [expr.pseudo]). 1237a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor/// 1238e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor/// A pseudo-destructor is an expression that looks like a member access to a 1239e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor/// destructor of a scalar type, except that scalar types don't have 1240e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor/// destructors. For example: 1241e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor/// 1242e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor/// \code 1243e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor/// typedef int T; 1244e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor/// void f(int *p) { 1245e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor/// p->T::~T(); 1246e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor/// } 1247e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor/// \endcode 1248a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor/// 1249e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor/// Pseudo-destructors typically occur when instantiating templates such as: 1250e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor/// 1251a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor/// \code 12521eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump/// template<typename T> 1253a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor/// void destroy(T* ptr) { 1254e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor/// ptr->T::~T(); 1255a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor/// } 1256a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor/// \endcode 1257a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor/// 1258e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor/// for scalar types. A pseudo-destructor expression has no run-time semantics 1259e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor/// beyond evaluating the base expression. 1260a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregorclass CXXPseudoDestructorExpr : public Expr { 1261a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor /// \brief The base expression (that is being destroyed). 1262a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor Stmt *Base; 12631eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1264a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor /// \brief Whether the operator was an arrow ('->'); otherwise, it was a 1265a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor /// period ('.'). 1266a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor bool IsArrow : 1; 12671eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1268a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor /// \brief The location of the '.' or '->' operator. 1269a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor SourceLocation OperatorLoc; 12701eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1271a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor /// \brief The nested-name-specifier that follows the operator, if present. 1272a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor NestedNameSpecifier *Qualifier; 12731eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 12741eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump /// \brief The source range that covers the nested-name-specifier, if 1275a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor /// present. 1276a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor SourceRange QualifierRange; 12771eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1278e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor /// \brief The type that precedes the '::' in a qualified pseudo-destructor 1279e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor /// expression. 1280e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor TypeSourceInfo *ScopeType; 1281e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor 1282e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor /// \brief The location of the '::' in a qualified pseudo-destructor 1283e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor /// expression. 1284e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor SourceLocation ColonColonLoc; 1285e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor 1286fce46ee68f779e239826e69e45d01d4c8e5323caDouglas Gregor /// \brief The location of the '~'. 1287fce46ee68f779e239826e69e45d01d4c8e5323caDouglas Gregor SourceLocation TildeLoc; 1288fce46ee68f779e239826e69e45d01d4c8e5323caDouglas Gregor 1289a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor /// \brief The type being destroyed, or its name if we were unable to 1290a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor /// resolve the name. 1291a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor PseudoDestructorTypeStorage DestroyedType; 12921eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1293a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregorpublic: 1294a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor CXXPseudoDestructorExpr(ASTContext &Context, 1295a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor Expr *Base, bool isArrow, SourceLocation OperatorLoc, 1296a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor NestedNameSpecifier *Qualifier, 1297a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor SourceRange QualifierRange, 1298e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor TypeSourceInfo *ScopeType, 1299e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor SourceLocation ColonColonLoc, 1300fce46ee68f779e239826e69e45d01d4c8e5323caDouglas Gregor SourceLocation TildeLoc, 1301e23cf437fe76b1ed02d63c3f61b456fd48a915f5John McCall PseudoDestructorTypeStorage DestroyedType); 13021eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1303de4bd18bb45a1db68996cfb949db3015fc25d10dArgyrios Kyrtzidis explicit CXXPseudoDestructorExpr(EmptyShell Shell) 1304de4bd18bb45a1db68996cfb949db3015fc25d10dArgyrios Kyrtzidis : Expr(CXXPseudoDestructorExprClass, Shell), 1305de4bd18bb45a1db68996cfb949db3015fc25d10dArgyrios Kyrtzidis Base(0), IsArrow(false), Qualifier(0), ScopeType(0) { } 1306de4bd18bb45a1db68996cfb949db3015fc25d10dArgyrios Kyrtzidis 1307a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor void setBase(Expr *E) { Base = E; } 1308a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor Expr *getBase() const { return cast<Expr>(Base); } 13091eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 13101eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump /// \brief Determines whether this member expression actually had 1311a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor /// a C++ nested-name-specifier prior to the name of the member, e.g., 1312a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor /// x->Base::foo. 1313a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor bool hasQualifier() const { return Qualifier != 0; } 13141eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1315a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor /// \brief If the member name was qualified, retrieves the source range of 1316a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor /// the nested-name-specifier that precedes the member name. Otherwise, 1317a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor /// returns an empty source range. 1318a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor SourceRange getQualifierRange() const { return QualifierRange; } 1319de4bd18bb45a1db68996cfb949db3015fc25d10dArgyrios Kyrtzidis void setQualifierRange(SourceRange R) { QualifierRange = R; } 13201eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 13211eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump /// \brief If the member name was qualified, retrieves the 1322a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor /// nested-name-specifier that precedes the member name. Otherwise, returns 1323a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor /// NULL. 1324a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor NestedNameSpecifier *getQualifier() const { return Qualifier; } 1325de4bd18bb45a1db68996cfb949db3015fc25d10dArgyrios Kyrtzidis void setQualifier(NestedNameSpecifier *NNS) { Qualifier = NNS; } 13261eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1327a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor /// \brief Determine whether this pseudo-destructor expression was written 1328a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor /// using an '->' (otherwise, it used a '.'). 1329a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor bool isArrow() const { return IsArrow; } 1330a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor void setArrow(bool A) { IsArrow = A; } 1331a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor 1332a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor /// \brief Retrieve the location of the '.' or '->' operator. 1333a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor SourceLocation getOperatorLoc() const { return OperatorLoc; } 1334de4bd18bb45a1db68996cfb949db3015fc25d10dArgyrios Kyrtzidis void setOperatorLoc(SourceLocation L) { OperatorLoc = L; } 13351eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1336e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor /// \brief Retrieve the scope type in a qualified pseudo-destructor 1337e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor /// expression. 1338e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor /// 1339e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor /// Pseudo-destructor expressions can have extra qualification within them 1340e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor /// that is not part of the nested-name-specifier, e.g., \c p->T::~T(). 1341e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor /// Here, if the object type of the expression is (or may be) a scalar type, 1342e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor /// \p T may also be a scalar type and, therefore, cannot be part of a 1343e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor /// nested-name-specifier. It is stored as the "scope type" of the pseudo- 1344e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor /// destructor expression. 134526d4ac97fb514bb60c2536eae6f203dc569159d9Douglas Gregor TypeSourceInfo *getScopeTypeInfo() const { return ScopeType; } 1346de4bd18bb45a1db68996cfb949db3015fc25d10dArgyrios Kyrtzidis void setScopeTypeInfo(TypeSourceInfo *Info) { ScopeType = Info; } 1347e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor 1348e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor /// \brief Retrieve the location of the '::' in a qualified pseudo-destructor 1349e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor /// expression. 1350e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor SourceLocation getColonColonLoc() const { return ColonColonLoc; } 1351de4bd18bb45a1db68996cfb949db3015fc25d10dArgyrios Kyrtzidis void setColonColonLoc(SourceLocation L) { ColonColonLoc = L; } 1352e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor 1353fce46ee68f779e239826e69e45d01d4c8e5323caDouglas Gregor /// \brief Retrieve the location of the '~'. 1354fce46ee68f779e239826e69e45d01d4c8e5323caDouglas Gregor SourceLocation getTildeLoc() const { return TildeLoc; } 1355de4bd18bb45a1db68996cfb949db3015fc25d10dArgyrios Kyrtzidis void setTildeLoc(SourceLocation L) { TildeLoc = L; } 1356fce46ee68f779e239826e69e45d01d4c8e5323caDouglas Gregor 135726d4ac97fb514bb60c2536eae6f203dc569159d9Douglas Gregor /// \brief Retrieve the source location information for the type 135826d4ac97fb514bb60c2536eae6f203dc569159d9Douglas Gregor /// being destroyed. 1359a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor /// 1360a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor /// This type-source information is available for non-dependent 1361a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor /// pseudo-destructor expressions and some dependent pseudo-destructor 1362a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor /// expressions. Returns NULL if we only have the identifier for a 1363a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor /// dependent pseudo-destructor expression. 1364a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor TypeSourceInfo *getDestroyedTypeInfo() const { 1365a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor return DestroyedType.getTypeSourceInfo(); 1366a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor } 1367a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor 1368a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor /// \brief In a dependent pseudo-destructor expression for which we do not 1369a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor /// have full type information on the destroyed type, provides the name 1370a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor /// of the destroyed type. 1371a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor IdentifierInfo *getDestroyedTypeIdentifier() const { 1372a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor return DestroyedType.getIdentifier(); 1373a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor } 1374a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor 1375a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor /// \brief Retrieve the type being destroyed. 1376a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor QualType getDestroyedType() const; 1377a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor 1378a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor /// \brief Retrieve the starting location of the type being destroyed. 1379a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor SourceLocation getDestroyedTypeLoc() const { 1380a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor return DestroyedType.getLocation(); 1381a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor } 13821eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1383de4bd18bb45a1db68996cfb949db3015fc25d10dArgyrios Kyrtzidis /// \brief Set the name of destroyed type for a dependent pseudo-destructor 1384de4bd18bb45a1db68996cfb949db3015fc25d10dArgyrios Kyrtzidis /// expression. 1385de4bd18bb45a1db68996cfb949db3015fc25d10dArgyrios Kyrtzidis void setDestroyedType(IdentifierInfo *II, SourceLocation Loc) { 1386de4bd18bb45a1db68996cfb949db3015fc25d10dArgyrios Kyrtzidis DestroyedType = PseudoDestructorTypeStorage(II, Loc); 1387de4bd18bb45a1db68996cfb949db3015fc25d10dArgyrios Kyrtzidis } 1388de4bd18bb45a1db68996cfb949db3015fc25d10dArgyrios Kyrtzidis 1389de4bd18bb45a1db68996cfb949db3015fc25d10dArgyrios Kyrtzidis /// \brief Set the destroyed type. 1390de4bd18bb45a1db68996cfb949db3015fc25d10dArgyrios Kyrtzidis void setDestroyedType(TypeSourceInfo *Info) { 1391de4bd18bb45a1db68996cfb949db3015fc25d10dArgyrios Kyrtzidis DestroyedType = PseudoDestructorTypeStorage(Info); 1392de4bd18bb45a1db68996cfb949db3015fc25d10dArgyrios Kyrtzidis } 1393de4bd18bb45a1db68996cfb949db3015fc25d10dArgyrios Kyrtzidis 139426d4ac97fb514bb60c2536eae6f203dc569159d9Douglas Gregor virtual SourceRange getSourceRange() const; 13951eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 13961eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump static bool classof(const Stmt *T) { 1397a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor return T->getStmtClass() == CXXPseudoDestructorExprClass; 1398a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor } 1399a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor static bool classof(const CXXPseudoDestructorExpr *) { return true; } 14001eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1401a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor // Iterators 1402a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor virtual child_iterator child_begin(); 14031eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump virtual child_iterator child_end(); 1404a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor}; 14051eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 140664b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl/// UnaryTypeTraitExpr - A GCC or MS unary type trait, as used in the 140764b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl/// implementation of TR1/C++0x type trait templates. 140864b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl/// Example: 140964b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl/// __is_pod(int) == true 141064b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl/// __is_enum(std::string) == false 141164b45f7e0d3167f040841ac2920aead7f080730dSebastian Redlclass UnaryTypeTraitExpr : public Expr { 14120dfd848fa4c9664852ba8c929a8bd3fce93ddca2Sebastian Redl /// UTT - The trait. A UnaryTypeTrait enum in MSVC compat unsigned. 14130dfd848fa4c9664852ba8c929a8bd3fce93ddca2Sebastian Redl unsigned UTT : 31; 14140dfd848fa4c9664852ba8c929a8bd3fce93ddca2Sebastian Redl /// The value of the type trait. Unspecified if dependent. 14150dfd848fa4c9664852ba8c929a8bd3fce93ddca2Sebastian Redl bool Value : 1; 141664b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl 141764b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl /// Loc - The location of the type trait keyword. 141864b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl SourceLocation Loc; 141964b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl 142064b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl /// RParen - The location of the closing paren. 142164b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl SourceLocation RParen; 142264b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl 14230dfd848fa4c9664852ba8c929a8bd3fce93ddca2Sebastian Redl /// The type being queried. 14243d37c0ada0e46b87be0a10e8d52d990a97d3907aDouglas Gregor TypeSourceInfo *QueriedType; 142564b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl 142664b45f7e0d3167f040841ac2920aead7f080730dSebastian Redlpublic: 14273d37c0ada0e46b87be0a10e8d52d990a97d3907aDouglas Gregor UnaryTypeTraitExpr(SourceLocation loc, UnaryTypeTrait utt, 14280dfd848fa4c9664852ba8c929a8bd3fce93ddca2Sebastian Redl TypeSourceInfo *queried, bool value, 142964b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl SourceLocation rparen, QualType ty) 1430f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall : Expr(UnaryTypeTraitExprClass, ty, VK_RValue, OK_Ordinary, 1431bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor false, queried->getType()->isDependentType(), 1432bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor queried->getType()->containsUnexpandedParameterPack()), 14330dfd848fa4c9664852ba8c929a8bd3fce93ddca2Sebastian Redl UTT(utt), Value(value), Loc(loc), RParen(rparen), QueriedType(queried) { } 143464b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl 14356d00c1365dd3601f6d93bbda9162913c57ae788fArgyrios Kyrtzidis explicit UnaryTypeTraitExpr(EmptyShell Empty) 14360dfd848fa4c9664852ba8c929a8bd3fce93ddca2Sebastian Redl : Expr(UnaryTypeTraitExprClass, Empty), UTT(0), Value(false), 14373d37c0ada0e46b87be0a10e8d52d990a97d3907aDouglas Gregor QueriedType() { } 14386d00c1365dd3601f6d93bbda9162913c57ae788fArgyrios Kyrtzidis 143964b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl virtual SourceRange getSourceRange() const { return SourceRange(Loc, RParen);} 144064b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl 14410dfd848fa4c9664852ba8c929a8bd3fce93ddca2Sebastian Redl UnaryTypeTrait getTrait() const { return static_cast<UnaryTypeTrait>(UTT); } 144264b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl 14433d37c0ada0e46b87be0a10e8d52d990a97d3907aDouglas Gregor QualType getQueriedType() const { return QueriedType->getType(); } 144464b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl 14453d37c0ada0e46b87be0a10e8d52d990a97d3907aDouglas Gregor TypeSourceInfo *getQueriedTypeSourceInfo() const { return QueriedType; } 14463d37c0ada0e46b87be0a10e8d52d990a97d3907aDouglas Gregor 14470dfd848fa4c9664852ba8c929a8bd3fce93ddca2Sebastian Redl bool getValue() const { return Value; } 144864b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl 144964b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl static bool classof(const Stmt *T) { 145064b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl return T->getStmtClass() == UnaryTypeTraitExprClass; 145164b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl } 145264b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl static bool classof(const UnaryTypeTraitExpr *) { return true; } 145364b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl 145464b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl // Iterators 145564b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl virtual child_iterator child_begin(); 145664b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl virtual child_iterator child_end(); 14576d00c1365dd3601f6d93bbda9162913c57ae788fArgyrios Kyrtzidis 145860adf4acf40b72227740bf966fb87eebddff3f37Sebastian Redl friend class ASTStmtReader; 145964b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl}; 146064b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl 14616ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet/// BinaryTypeTraitExpr - A GCC or MS binary type trait, as used in the 14626ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet/// implementation of TR1/C++0x type trait templates. 14636ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet/// Example: 14646ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet/// __is_base_of(Base, Derived) == true 14656ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichetclass BinaryTypeTraitExpr : public Expr { 14666ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet /// BTT - The trait. A BinaryTypeTrait enum in MSVC compat unsigned. 14676ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet unsigned BTT : 8; 14686ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet 14696ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet /// The value of the type trait. Unspecified if dependent. 14706ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet bool Value : 1; 14716ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet 14726ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet /// Loc - The location of the type trait keyword. 14736ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet SourceLocation Loc; 14746ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet 14756ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet /// RParen - The location of the closing paren. 14766ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet SourceLocation RParen; 14776ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet 14786ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet /// The lhs type being queried. 14796ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet TypeSourceInfo *LhsType; 14806ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet 14816ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet /// The rhs type being queried. 14826ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet TypeSourceInfo *RhsType; 14836ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet 14846ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichetpublic: 14856ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet BinaryTypeTraitExpr(SourceLocation loc, BinaryTypeTrait btt, 14866ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet TypeSourceInfo *lhsType, TypeSourceInfo *rhsType, 14876ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet bool value, SourceLocation rparen, QualType ty) 14886ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet : Expr(BinaryTypeTraitExprClass, ty, VK_RValue, OK_Ordinary, false, 14896ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet lhsType->getType()->isDependentType() || 1490bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor rhsType->getType()->isDependentType(), 1491bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor (lhsType->getType()->containsUnexpandedParameterPack() || 1492bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor rhsType->getType()->containsUnexpandedParameterPack())), 14936ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet BTT(btt), Value(value), Loc(loc), RParen(rparen), 14946ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet LhsType(lhsType), RhsType(rhsType) { } 14956ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet 14966ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet 14976ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet explicit BinaryTypeTraitExpr(EmptyShell Empty) 14986ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet : Expr(BinaryTypeTraitExprClass, Empty), BTT(0), Value(false), 1499f187237d916afa97c491ac32fe98be7d335c5b63Francois Pichet LhsType(), RhsType() { } 15006ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet 15016ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet virtual SourceRange getSourceRange() const { 15026ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet return SourceRange(Loc, RParen); 15036ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet } 15046ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet 15056ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet BinaryTypeTrait getTrait() const { 15066ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet return static_cast<BinaryTypeTrait>(BTT); 15076ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet } 15086ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet 15096ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet QualType getLhsType() const { return LhsType->getType(); } 15106ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet QualType getRhsType() const { return RhsType->getType(); } 15116ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet 15126ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet TypeSourceInfo *getLhsTypeSourceInfo() const { return LhsType; } 15136ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet TypeSourceInfo *getRhsTypeSourceInfo() const { return RhsType; } 15146ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet 15156ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet bool getValue() const { assert(!isTypeDependent()); return Value; } 15166ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet 15176ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet static bool classof(const Stmt *T) { 15186ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet return T->getStmtClass() == BinaryTypeTraitExprClass; 15196ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet } 15206ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet static bool classof(const BinaryTypeTraitExpr *) { return true; } 15216ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet 15226ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet // Iterators 15236ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet virtual child_iterator child_begin(); 15246ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet virtual child_iterator child_end(); 15256ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet 15266ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet friend class ASTStmtReader; 15276ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet}; 15286ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet 15297bb12da2b0749eeebb21854c77877736969e59f2John McCall/// \brief A reference to an overloaded function set, either an 15307bb12da2b0749eeebb21854c77877736969e59f2John McCall/// \t UnresolvedLookupExpr or an \t UnresolvedMemberExpr. 15317bb12da2b0749eeebb21854c77877736969e59f2John McCallclass OverloadExpr : public Expr { 1532ba13543329afac4a0d01304ec2ec4924d99306a6John McCall /// The results. These are undesugared, which is to say, they may 15337bb12da2b0749eeebb21854c77877736969e59f2John McCall /// include UsingShadowDecls. Access is relative to the naming 15347bb12da2b0749eeebb21854c77877736969e59f2John McCall /// class. 1535928e6fcf66fc4f342bcf7cc96bf56986c9c2a833Douglas Gregor // FIXME: Allocate this data after the OverloadExpr subclass. 1536928e6fcf66fc4f342bcf7cc96bf56986c9c2a833Douglas Gregor DeclAccessPair *Results; 1537928e6fcf66fc4f342bcf7cc96bf56986c9c2a833Douglas Gregor unsigned NumResults; 1538ba13543329afac4a0d01304ec2ec4924d99306a6John McCall 15397bb12da2b0749eeebb21854c77877736969e59f2John McCall /// The common name of these declarations. 15402577743c5650c646fb705df01403707e94f2df04Abramo Bagnara DeclarationNameInfo NameInfo; 1541ba13543329afac4a0d01304ec2ec4924d99306a6John McCall 15427bb12da2b0749eeebb21854c77877736969e59f2John McCall /// The scope specifier, if any. 1543ba13543329afac4a0d01304ec2ec4924d99306a6John McCall NestedNameSpecifier *Qualifier; 15447bb12da2b0749eeebb21854c77877736969e59f2John McCall 15457bb12da2b0749eeebb21854c77877736969e59f2John McCall /// The source range of the scope specifier. 1546ba13543329afac4a0d01304ec2ec4924d99306a6John McCall SourceRange QualifierRange; 1547ba13543329afac4a0d01304ec2ec4924d99306a6John McCall 1548a77eb0862507b900a10fa352af1568e639ed10b1Argyrios Kyrtzidisprotected: 15497bb12da2b0749eeebb21854c77877736969e59f2John McCall /// True if the name was a template-id. 15507bb12da2b0749eeebb21854c77877736969e59f2John McCall bool HasExplicitTemplateArgs; 15517bb12da2b0749eeebb21854c77877736969e59f2John McCall 1552bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor OverloadExpr(StmtClass K, ASTContext &C, 15537bb12da2b0749eeebb21854c77877736969e59f2John McCall NestedNameSpecifier *Qualifier, SourceRange QRange, 15542577743c5650c646fb705df01403707e94f2df04Abramo Bagnara const DeclarationNameInfo &NameInfo, 1555bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor const TemplateArgumentListInfo *TemplateArgs, 1556bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor UnresolvedSetIterator Begin, UnresolvedSetIterator End, 1557bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor bool KnownDependent = false, 1558bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor bool KnownContainsUnexpandedParameterPack = false); 15597bb12da2b0749eeebb21854c77877736969e59f2John McCall 1560a77eb0862507b900a10fa352af1568e639ed10b1Argyrios Kyrtzidis OverloadExpr(StmtClass K, EmptyShell Empty) 1561a77eb0862507b900a10fa352af1568e639ed10b1Argyrios Kyrtzidis : Expr(K, Empty), Results(0), NumResults(0), 1562a77eb0862507b900a10fa352af1568e639ed10b1Argyrios Kyrtzidis Qualifier(0), HasExplicitTemplateArgs(false) { } 1563a77eb0862507b900a10fa352af1568e639ed10b1Argyrios Kyrtzidis 1564bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor void initializeResults(ASTContext &C, 1565bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor UnresolvedSetIterator Begin, 1566bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor UnresolvedSetIterator End); 15677bb12da2b0749eeebb21854c77877736969e59f2John McCall 1568bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregorpublic: 15699c72c6088d591ace8503b842d39448c2040f3033John McCall struct FindResult { 15709c72c6088d591ace8503b842d39448c2040f3033John McCall OverloadExpr *Expression; 15719c72c6088d591ace8503b842d39448c2040f3033John McCall bool IsAddressOfOperand; 15729c72c6088d591ace8503b842d39448c2040f3033John McCall bool HasFormOfMemberPointer; 15739c72c6088d591ace8503b842d39448c2040f3033John McCall }; 15749c72c6088d591ace8503b842d39448c2040f3033John McCall 15757bb12da2b0749eeebb21854c77877736969e59f2John McCall /// Finds the overloaded expression in the given expression of 15767bb12da2b0749eeebb21854c77877736969e59f2John McCall /// OverloadTy. 15777bb12da2b0749eeebb21854c77877736969e59f2John McCall /// 15789c72c6088d591ace8503b842d39448c2040f3033John McCall /// \return the expression (which must be there) and true if it has 15799c72c6088d591ace8503b842d39448c2040f3033John McCall /// the particular form of a member pointer expression 15809c72c6088d591ace8503b842d39448c2040f3033John McCall static FindResult find(Expr *E) { 15817bb12da2b0749eeebb21854c77877736969e59f2John McCall assert(E->getType()->isSpecificBuiltinType(BuiltinType::Overload)); 15827bb12da2b0749eeebb21854c77877736969e59f2John McCall 15839c72c6088d591ace8503b842d39448c2040f3033John McCall FindResult Result; 15849c72c6088d591ace8503b842d39448c2040f3033John McCall 15857bb12da2b0749eeebb21854c77877736969e59f2John McCall E = E->IgnoreParens(); 15869c72c6088d591ace8503b842d39448c2040f3033John McCall if (isa<UnaryOperator>(E)) { 15879c72c6088d591ace8503b842d39448c2040f3033John McCall assert(cast<UnaryOperator>(E)->getOpcode() == UO_AddrOf); 15889c72c6088d591ace8503b842d39448c2040f3033John McCall E = cast<UnaryOperator>(E)->getSubExpr(); 15899c72c6088d591ace8503b842d39448c2040f3033John McCall OverloadExpr *Ovl = cast<OverloadExpr>(E->IgnoreParens()); 15909c72c6088d591ace8503b842d39448c2040f3033John McCall 15919c72c6088d591ace8503b842d39448c2040f3033John McCall Result.HasFormOfMemberPointer = (E == Ovl && Ovl->getQualifier()); 15929c72c6088d591ace8503b842d39448c2040f3033John McCall Result.IsAddressOfOperand = true; 15939c72c6088d591ace8503b842d39448c2040f3033John McCall Result.Expression = Ovl; 15949c72c6088d591ace8503b842d39448c2040f3033John McCall } else { 15959c72c6088d591ace8503b842d39448c2040f3033John McCall Result.HasFormOfMemberPointer = false; 15969c72c6088d591ace8503b842d39448c2040f3033John McCall Result.IsAddressOfOperand = false; 15979c72c6088d591ace8503b842d39448c2040f3033John McCall Result.Expression = cast<OverloadExpr>(E); 15989c72c6088d591ace8503b842d39448c2040f3033John McCall } 15999c72c6088d591ace8503b842d39448c2040f3033John McCall 16009c72c6088d591ace8503b842d39448c2040f3033John McCall return Result; 16017bb12da2b0749eeebb21854c77877736969e59f2John McCall } 16027bb12da2b0749eeebb21854c77877736969e59f2John McCall 1603e9ee23edd17c4bb7f271e67f8790792b4de677fcJohn McCall /// Gets the naming class of this lookup, if any. 1604e9ee23edd17c4bb7f271e67f8790792b4de677fcJohn McCall CXXRecordDecl *getNamingClass() const; 1605e9ee23edd17c4bb7f271e67f8790792b4de677fcJohn McCall 16067bb12da2b0749eeebb21854c77877736969e59f2John McCall typedef UnresolvedSetImpl::iterator decls_iterator; 1607928e6fcf66fc4f342bcf7cc96bf56986c9c2a833Douglas Gregor decls_iterator decls_begin() const { return UnresolvedSetIterator(Results); } 1608928e6fcf66fc4f342bcf7cc96bf56986c9c2a833Douglas Gregor decls_iterator decls_end() const { 1609928e6fcf66fc4f342bcf7cc96bf56986c9c2a833Douglas Gregor return UnresolvedSetIterator(Results + NumResults); 1610928e6fcf66fc4f342bcf7cc96bf56986c9c2a833Douglas Gregor } 1611a77eb0862507b900a10fa352af1568e639ed10b1Argyrios Kyrtzidis 16127bb12da2b0749eeebb21854c77877736969e59f2John McCall /// Gets the number of declarations in the unresolved set. 1613928e6fcf66fc4f342bcf7cc96bf56986c9c2a833Douglas Gregor unsigned getNumDecls() const { return NumResults; } 16147bb12da2b0749eeebb21854c77877736969e59f2John McCall 16152577743c5650c646fb705df01403707e94f2df04Abramo Bagnara /// Gets the full name info. 16162577743c5650c646fb705df01403707e94f2df04Abramo Bagnara const DeclarationNameInfo &getNameInfo() const { return NameInfo; } 16172577743c5650c646fb705df01403707e94f2df04Abramo Bagnara void setNameInfo(const DeclarationNameInfo &N) { NameInfo = N; } 16182577743c5650c646fb705df01403707e94f2df04Abramo Bagnara 16197bb12da2b0749eeebb21854c77877736969e59f2John McCall /// Gets the name looked up. 16202577743c5650c646fb705df01403707e94f2df04Abramo Bagnara DeclarationName getName() const { return NameInfo.getName(); } 16212577743c5650c646fb705df01403707e94f2df04Abramo Bagnara void setName(DeclarationName N) { NameInfo.setName(N); } 16227bb12da2b0749eeebb21854c77877736969e59f2John McCall 16237bb12da2b0749eeebb21854c77877736969e59f2John McCall /// Gets the location of the name. 16242577743c5650c646fb705df01403707e94f2df04Abramo Bagnara SourceLocation getNameLoc() const { return NameInfo.getLoc(); } 16252577743c5650c646fb705df01403707e94f2df04Abramo Bagnara void setNameLoc(SourceLocation Loc) { NameInfo.setLoc(Loc); } 16267bb12da2b0749eeebb21854c77877736969e59f2John McCall 16277bb12da2b0749eeebb21854c77877736969e59f2John McCall /// Fetches the nested-name qualifier, if one was given. 16287bb12da2b0749eeebb21854c77877736969e59f2John McCall NestedNameSpecifier *getQualifier() const { return Qualifier; } 1629a77eb0862507b900a10fa352af1568e639ed10b1Argyrios Kyrtzidis void setQualifier(NestedNameSpecifier *NNS) { Qualifier = NNS; } 16307bb12da2b0749eeebb21854c77877736969e59f2John McCall 16317bb12da2b0749eeebb21854c77877736969e59f2John McCall /// Fetches the range of the nested-name qualifier. 16327bb12da2b0749eeebb21854c77877736969e59f2John McCall SourceRange getQualifierRange() const { return QualifierRange; } 1633a77eb0862507b900a10fa352af1568e639ed10b1Argyrios Kyrtzidis void setQualifierRange(SourceRange R) { QualifierRange = R; } 16347bb12da2b0749eeebb21854c77877736969e59f2John McCall 16357bb12da2b0749eeebb21854c77877736969e59f2John McCall /// \brief Determines whether this expression had an explicit 16367bb12da2b0749eeebb21854c77877736969e59f2John McCall /// template argument list, e.g. f<int>. 16377bb12da2b0749eeebb21854c77877736969e59f2John McCall bool hasExplicitTemplateArgs() const { return HasExplicitTemplateArgs; } 16387bb12da2b0749eeebb21854c77877736969e59f2John McCall 16397bb12da2b0749eeebb21854c77877736969e59f2John McCall ExplicitTemplateArgumentList &getExplicitTemplateArgs(); // defined far below 16407bb12da2b0749eeebb21854c77877736969e59f2John McCall 16417bb12da2b0749eeebb21854c77877736969e59f2John McCall const ExplicitTemplateArgumentList &getExplicitTemplateArgs() const { 16427bb12da2b0749eeebb21854c77877736969e59f2John McCall return const_cast<OverloadExpr*>(this)->getExplicitTemplateArgs(); 16437bb12da2b0749eeebb21854c77877736969e59f2John McCall } 16447bb12da2b0749eeebb21854c77877736969e59f2John McCall 1645096832c5ed5b9106fa177ebc148489760c3bc496John McCall /// \brief Retrieves the optional explicit template arguments. 1646096832c5ed5b9106fa177ebc148489760c3bc496John McCall /// This points to the same data as getExplicitTemplateArgs(), but 1647096832c5ed5b9106fa177ebc148489760c3bc496John McCall /// returns null if there are no explicit template arguments. 1648096832c5ed5b9106fa177ebc148489760c3bc496John McCall const ExplicitTemplateArgumentList *getOptionalExplicitTemplateArgs() { 1649096832c5ed5b9106fa177ebc148489760c3bc496John McCall if (!hasExplicitTemplateArgs()) return 0; 1650096832c5ed5b9106fa177ebc148489760c3bc496John McCall return &getExplicitTemplateArgs(); 16517bb12da2b0749eeebb21854c77877736969e59f2John McCall } 16527bb12da2b0749eeebb21854c77877736969e59f2John McCall 16537bb12da2b0749eeebb21854c77877736969e59f2John McCall static bool classof(const Stmt *T) { 16547bb12da2b0749eeebb21854c77877736969e59f2John McCall return T->getStmtClass() == UnresolvedLookupExprClass || 16557bb12da2b0749eeebb21854c77877736969e59f2John McCall T->getStmtClass() == UnresolvedMemberExprClass; 16567bb12da2b0749eeebb21854c77877736969e59f2John McCall } 16577bb12da2b0749eeebb21854c77877736969e59f2John McCall static bool classof(const OverloadExpr *) { return true; } 16584045107b7384fd68eed5e3e2f06fc2a47e7be0a6Argyrios Kyrtzidis 16594045107b7384fd68eed5e3e2f06fc2a47e7be0a6Argyrios Kyrtzidis friend class ASTStmtReader; 16604045107b7384fd68eed5e3e2f06fc2a47e7be0a6Argyrios Kyrtzidis friend class ASTStmtWriter; 16617bb12da2b0749eeebb21854c77877736969e59f2John McCall}; 16627bb12da2b0749eeebb21854c77877736969e59f2John McCall 16637bb12da2b0749eeebb21854c77877736969e59f2John McCall/// \brief A reference to a name which we were able to look up during 16647bb12da2b0749eeebb21854c77877736969e59f2John McCall/// parsing but could not resolve to a specific declaration. This 16657bb12da2b0749eeebb21854c77877736969e59f2John McCall/// arises in several ways: 16667bb12da2b0749eeebb21854c77877736969e59f2John McCall/// * we might be waiting for argument-dependent lookup 16677bb12da2b0749eeebb21854c77877736969e59f2John McCall/// * the name might resolve to an overloaded function 16687bb12da2b0749eeebb21854c77877736969e59f2John McCall/// and eventually: 16697bb12da2b0749eeebb21854c77877736969e59f2John McCall/// * the lookup might have included a function template 16707bb12da2b0749eeebb21854c77877736969e59f2John McCall/// These never include UnresolvedUsingValueDecls, which are always 16717bb12da2b0749eeebb21854c77877736969e59f2John McCall/// class members and therefore appear only in 16727bb12da2b0749eeebb21854c77877736969e59f2John McCall/// UnresolvedMemberLookupExprs. 16737bb12da2b0749eeebb21854c77877736969e59f2John McCallclass UnresolvedLookupExpr : public OverloadExpr { 1674ba13543329afac4a0d01304ec2ec4924d99306a6John McCall /// True if these lookup results should be extended by 1675ba13543329afac4a0d01304ec2ec4924d99306a6John McCall /// argument-dependent lookup if this is the operand of a function 1676ba13543329afac4a0d01304ec2ec4924d99306a6John McCall /// call. 1677ba13543329afac4a0d01304ec2ec4924d99306a6John McCall bool RequiresADL; 1678ba13543329afac4a0d01304ec2ec4924d99306a6John McCall 16797453ed4cb2cab113de3378df371b1c6f1243d832John McCall /// True if these lookup results are overloaded. This is pretty 16807453ed4cb2cab113de3378df371b1c6f1243d832John McCall /// trivially rederivable if we urgently need to kill this field. 16817453ed4cb2cab113de3378df371b1c6f1243d832John McCall bool Overloaded; 16827453ed4cb2cab113de3378df371b1c6f1243d832John McCall 16837bb12da2b0749eeebb21854c77877736969e59f2John McCall /// The naming class (C++ [class.access.base]p5) of the lookup, if 16847bb12da2b0749eeebb21854c77877736969e59f2John McCall /// any. This can generally be recalculated from the context chain, 16857bb12da2b0749eeebb21854c77877736969e59f2John McCall /// but that can be fairly expensive for unqualified lookups. If we 16867bb12da2b0749eeebb21854c77877736969e59f2John McCall /// want to improve memory use here, this could go in a union 16877bb12da2b0749eeebb21854c77877736969e59f2John McCall /// against the qualified-lookup bits. 16887bb12da2b0749eeebb21854c77877736969e59f2John McCall CXXRecordDecl *NamingClass; 1689f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall 1690bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor UnresolvedLookupExpr(ASTContext &C, 1691928e6fcf66fc4f342bcf7cc96bf56986c9c2a833Douglas Gregor CXXRecordDecl *NamingClass, 1692ba13543329afac4a0d01304ec2ec4924d99306a6John McCall NestedNameSpecifier *Qualifier, SourceRange QRange, 16932577743c5650c646fb705df01403707e94f2df04Abramo Bagnara const DeclarationNameInfo &NameInfo, 1694bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor bool RequiresADL, bool Overloaded, 1695bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor const TemplateArgumentListInfo *TemplateArgs, 16965a84dec38cfa9e084377a3167b474c79283c82faDouglas Gregor UnresolvedSetIterator Begin, UnresolvedSetIterator End) 1697bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor : OverloadExpr(UnresolvedLookupExprClass, C, Qualifier, QRange, NameInfo, 1698bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor TemplateArgs, Begin, End), 16997bb12da2b0749eeebb21854c77877736969e59f2John McCall RequiresADL(RequiresADL), Overloaded(Overloaded), NamingClass(NamingClass) 1700ba13543329afac4a0d01304ec2ec4924d99306a6John McCall {} 1701ba13543329afac4a0d01304ec2ec4924d99306a6John McCall 1702bd65bb511c26549c96b829c1282e4c877588564aArgyrios Kyrtzidis UnresolvedLookupExpr(EmptyShell Empty) 1703bd65bb511c26549c96b829c1282e4c877588564aArgyrios Kyrtzidis : OverloadExpr(UnresolvedLookupExprClass, Empty), 1704bd65bb511c26549c96b829c1282e4c877588564aArgyrios Kyrtzidis RequiresADL(false), Overloaded(false), NamingClass(0) 1705bd65bb511c26549c96b829c1282e4c877588564aArgyrios Kyrtzidis {} 1706bd65bb511c26549c96b829c1282e4c877588564aArgyrios Kyrtzidis 1707ba13543329afac4a0d01304ec2ec4924d99306a6John McCallpublic: 1708ba13543329afac4a0d01304ec2ec4924d99306a6John McCall static UnresolvedLookupExpr *Create(ASTContext &C, 1709c373d48502ca7683ab55385f5bd624d778eb288dJohn McCall CXXRecordDecl *NamingClass, 1710ba13543329afac4a0d01304ec2ec4924d99306a6John McCall NestedNameSpecifier *Qualifier, 1711ba13543329afac4a0d01304ec2ec4924d99306a6John McCall SourceRange QualifierRange, 17122577743c5650c646fb705df01403707e94f2df04Abramo Bagnara const DeclarationNameInfo &NameInfo, 17135a84dec38cfa9e084377a3167b474c79283c82faDouglas Gregor bool ADL, bool Overloaded, 17145a84dec38cfa9e084377a3167b474c79283c82faDouglas Gregor UnresolvedSetIterator Begin, 17155a84dec38cfa9e084377a3167b474c79283c82faDouglas Gregor UnresolvedSetIterator End) { 1716bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor return new(C) UnresolvedLookupExpr(C, NamingClass, Qualifier, 1717bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor QualifierRange, NameInfo, ADL, 1718bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor Overloaded, 0, Begin, End); 1719ba13543329afac4a0d01304ec2ec4924d99306a6John McCall } 1720ba13543329afac4a0d01304ec2ec4924d99306a6John McCall 1721f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall static UnresolvedLookupExpr *Create(ASTContext &C, 1722c373d48502ca7683ab55385f5bd624d778eb288dJohn McCall CXXRecordDecl *NamingClass, 1723f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall NestedNameSpecifier *Qualifier, 1724f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall SourceRange QualifierRange, 17252577743c5650c646fb705df01403707e94f2df04Abramo Bagnara const DeclarationNameInfo &NameInfo, 1726f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall bool ADL, 17275a84dec38cfa9e084377a3167b474c79283c82faDouglas Gregor const TemplateArgumentListInfo &Args, 17285a84dec38cfa9e084377a3167b474c79283c82faDouglas Gregor UnresolvedSetIterator Begin, 17295a84dec38cfa9e084377a3167b474c79283c82faDouglas Gregor UnresolvedSetIterator End); 1730f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall 1731bd65bb511c26549c96b829c1282e4c877588564aArgyrios Kyrtzidis static UnresolvedLookupExpr *CreateEmpty(ASTContext &C, 1732bd65bb511c26549c96b829c1282e4c877588564aArgyrios Kyrtzidis unsigned NumTemplateArgs); 1733bd65bb511c26549c96b829c1282e4c877588564aArgyrios Kyrtzidis 1734ba13543329afac4a0d01304ec2ec4924d99306a6John McCall /// True if this declaration should be extended by 1735ba13543329afac4a0d01304ec2ec4924d99306a6John McCall /// argument-dependent lookup. 1736ba13543329afac4a0d01304ec2ec4924d99306a6John McCall bool requiresADL() const { return RequiresADL; } 1737bd65bb511c26549c96b829c1282e4c877588564aArgyrios Kyrtzidis void setRequiresADL(bool V) { RequiresADL = V; } 1738ba13543329afac4a0d01304ec2ec4924d99306a6John McCall 17397453ed4cb2cab113de3378df371b1c6f1243d832John McCall /// True if this lookup is overloaded. 17407453ed4cb2cab113de3378df371b1c6f1243d832John McCall bool isOverloaded() const { return Overloaded; } 1741bd65bb511c26549c96b829c1282e4c877588564aArgyrios Kyrtzidis void setOverloaded(bool V) { Overloaded = V; } 17427453ed4cb2cab113de3378df371b1c6f1243d832John McCall 1743c373d48502ca7683ab55385f5bd624d778eb288dJohn McCall /// Gets the 'naming class' (in the sense of C++0x 1744c373d48502ca7683ab55385f5bd624d778eb288dJohn McCall /// [class.access.base]p5) of the lookup. This is the scope 1745c373d48502ca7683ab55385f5bd624d778eb288dJohn McCall /// that was looked in to find these results. 1746c373d48502ca7683ab55385f5bd624d778eb288dJohn McCall CXXRecordDecl *getNamingClass() const { return NamingClass; } 1747bd65bb511c26549c96b829c1282e4c877588564aArgyrios Kyrtzidis void setNamingClass(CXXRecordDecl *D) { NamingClass = D; } 1748c373d48502ca7683ab55385f5bd624d778eb288dJohn McCall 1749f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall // Note that, inconsistently with the explicit-template-argument AST 1750f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall // nodes, users are *forbidden* from calling these methods on objects 1751f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall // without explicit template arguments. 1752f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall 17537bb12da2b0749eeebb21854c77877736969e59f2John McCall ExplicitTemplateArgumentList &getExplicitTemplateArgs() { 17547bb12da2b0749eeebb21854c77877736969e59f2John McCall assert(hasExplicitTemplateArgs()); 17557bb12da2b0749eeebb21854c77877736969e59f2John McCall return *reinterpret_cast<ExplicitTemplateArgumentList*>(this + 1); 17567bb12da2b0749eeebb21854c77877736969e59f2John McCall } 17577bb12da2b0749eeebb21854c77877736969e59f2John McCall 1758f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall /// Gets a reference to the explicit template argument list. 1759f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall const ExplicitTemplateArgumentList &getExplicitTemplateArgs() const { 1760f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall assert(hasExplicitTemplateArgs()); 1761f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall return *reinterpret_cast<const ExplicitTemplateArgumentList*>(this + 1); 1762f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall } 1763f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall 1764096832c5ed5b9106fa177ebc148489760c3bc496John McCall /// \brief Retrieves the optional explicit template arguments. 1765096832c5ed5b9106fa177ebc148489760c3bc496John McCall /// This points to the same data as getExplicitTemplateArgs(), but 1766096832c5ed5b9106fa177ebc148489760c3bc496John McCall /// returns null if there are no explicit template arguments. 1767096832c5ed5b9106fa177ebc148489760c3bc496John McCall const ExplicitTemplateArgumentList *getOptionalExplicitTemplateArgs() { 1768096832c5ed5b9106fa177ebc148489760c3bc496John McCall if (!hasExplicitTemplateArgs()) return 0; 1769096832c5ed5b9106fa177ebc148489760c3bc496John McCall return &getExplicitTemplateArgs(); 1770096832c5ed5b9106fa177ebc148489760c3bc496John McCall } 1771096832c5ed5b9106fa177ebc148489760c3bc496John McCall 1772f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall /// \brief Copies the template arguments (if present) into the given 1773f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall /// structure. 1774f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall void copyTemplateArgumentsInto(TemplateArgumentListInfo &List) const { 1775f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall getExplicitTemplateArgs().copyInto(List); 1776f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall } 1777ba13543329afac4a0d01304ec2ec4924d99306a6John McCall 1778f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall SourceLocation getLAngleLoc() const { 1779f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall return getExplicitTemplateArgs().LAngleLoc; 1780f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall } 1781f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall 1782f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall SourceLocation getRAngleLoc() const { 1783f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall return getExplicitTemplateArgs().RAngleLoc; 1784f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall } 1785f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall 1786f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall TemplateArgumentLoc const *getTemplateArgs() const { 1787f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall return getExplicitTemplateArgs().getTemplateArgs(); 1788f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall } 1789f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall 1790f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall unsigned getNumTemplateArgs() const { 1791f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall return getExplicitTemplateArgs().NumTemplateArgs; 1792f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall } 1793ba13543329afac4a0d01304ec2ec4924d99306a6John McCall 1794ba13543329afac4a0d01304ec2ec4924d99306a6John McCall virtual SourceRange getSourceRange() const { 17952577743c5650c646fb705df01403707e94f2df04Abramo Bagnara SourceRange Range(getNameInfo().getSourceRange()); 17967bb12da2b0749eeebb21854c77877736969e59f2John McCall if (getQualifier()) Range.setBegin(getQualifierRange().getBegin()); 1797f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall if (hasExplicitTemplateArgs()) Range.setEnd(getRAngleLoc()); 1798f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall return Range; 1799ba13543329afac4a0d01304ec2ec4924d99306a6John McCall } 1800ba13543329afac4a0d01304ec2ec4924d99306a6John McCall 1801ba13543329afac4a0d01304ec2ec4924d99306a6John McCall virtual StmtIterator child_begin(); 1802ba13543329afac4a0d01304ec2ec4924d99306a6John McCall virtual StmtIterator child_end(); 1803ba13543329afac4a0d01304ec2ec4924d99306a6John McCall 1804ba13543329afac4a0d01304ec2ec4924d99306a6John McCall static bool classof(const Stmt *T) { 1805ba13543329afac4a0d01304ec2ec4924d99306a6John McCall return T->getStmtClass() == UnresolvedLookupExprClass; 1806ba13543329afac4a0d01304ec2ec4924d99306a6John McCall } 1807ba13543329afac4a0d01304ec2ec4924d99306a6John McCall static bool classof(const UnresolvedLookupExpr *) { return true; } 1808ba13543329afac4a0d01304ec2ec4924d99306a6John McCall}; 1809ba13543329afac4a0d01304ec2ec4924d99306a6John McCall 18105953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor/// \brief A qualified reference to a name whose declaration cannot 18115953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor/// yet be resolved. 18125953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor/// 1813ba13543329afac4a0d01304ec2ec4924d99306a6John McCall/// DependentScopeDeclRefExpr is similar to DeclRefExpr in that 1814a2813cec2605ce7878d1b13471d685f689b251afDouglas Gregor/// it expresses a reference to a declaration such as 18155953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor/// X<T>::value. The difference, however, is that an 1816865d447ac6a4721ab58e898d014a21f2eff74b06John McCall/// DependentScopeDeclRefExpr node is used only within C++ templates when 18175953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor/// the qualification (e.g., X<T>::) refers to a dependent type. In 18185953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor/// this case, X<T>::value cannot resolve to a declaration because the 18195953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor/// declaration will differ from on instantiation of X<T> to the 1820865d447ac6a4721ab58e898d014a21f2eff74b06John McCall/// next. Therefore, DependentScopeDeclRefExpr keeps track of the 1821ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor/// qualifier (X<T>::) and the name of the entity being referenced 1822a2813cec2605ce7878d1b13471d685f689b251afDouglas Gregor/// ("value"). Such expressions will instantiate to a DeclRefExpr once the 1823a2813cec2605ce7878d1b13471d685f689b251afDouglas Gregor/// declaration can be found. 1824865d447ac6a4721ab58e898d014a21f2eff74b06John McCallclass DependentScopeDeclRefExpr : public Expr { 18255953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor /// The name of the entity we will be referencing. 18262577743c5650c646fb705df01403707e94f2df04Abramo Bagnara DeclarationNameInfo NameInfo; 18275953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor 18285953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor /// QualifierRange - The source range that covers the 18295953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor /// nested-name-specifier. 18305953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor SourceRange QualifierRange; 18315953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor 1832ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor /// \brief The nested-name-specifier that qualifies this unresolved 1833ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor /// declaration name. 1834f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall NestedNameSpecifier *Qualifier; 18355953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor 1836f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall /// \brief Whether the name includes explicit template arguments. 1837f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall bool HasExplicitTemplateArgs; 18381eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1839f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall DependentScopeDeclRefExpr(QualType T, 1840f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall NestedNameSpecifier *Qualifier, 1841f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall SourceRange QualifierRange, 18422577743c5650c646fb705df01403707e94f2df04Abramo Bagnara const DeclarationNameInfo &NameInfo, 1843bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor const TemplateArgumentListInfo *Args); 1844f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall 1845f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCallpublic: 1846f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall static DependentScopeDeclRefExpr *Create(ASTContext &C, 1847f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall NestedNameSpecifier *Qualifier, 1848f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall SourceRange QualifierRange, 18492577743c5650c646fb705df01403707e94f2df04Abramo Bagnara const DeclarationNameInfo &NameInfo, 1850f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall const TemplateArgumentListInfo *TemplateArgs = 0); 18515953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor 185212dffcddb60380c5bed4f085a1f51534afda3b87Argyrios Kyrtzidis static DependentScopeDeclRefExpr *CreateEmpty(ASTContext &C, 185312dffcddb60380c5bed4f085a1f51534afda3b87Argyrios Kyrtzidis unsigned NumTemplateArgs); 185412dffcddb60380c5bed4f085a1f51534afda3b87Argyrios Kyrtzidis 18555953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor /// \brief Retrieve the name that this expression refers to. 18562577743c5650c646fb705df01403707e94f2df04Abramo Bagnara const DeclarationNameInfo &getNameInfo() const { return NameInfo; } 18572577743c5650c646fb705df01403707e94f2df04Abramo Bagnara void setNameInfo(const DeclarationNameInfo &N) { NameInfo = N; } 18582577743c5650c646fb705df01403707e94f2df04Abramo Bagnara 18592577743c5650c646fb705df01403707e94f2df04Abramo Bagnara /// \brief Retrieve the name that this expression refers to. 18602577743c5650c646fb705df01403707e94f2df04Abramo Bagnara DeclarationName getDeclName() const { return NameInfo.getName(); } 18612577743c5650c646fb705df01403707e94f2df04Abramo Bagnara void setDeclName(DeclarationName N) { NameInfo.setName(N); } 18625953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor 18635953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor /// \brief Retrieve the location of the name within the expression. 18642577743c5650c646fb705df01403707e94f2df04Abramo Bagnara SourceLocation getLocation() const { return NameInfo.getLoc(); } 18652577743c5650c646fb705df01403707e94f2df04Abramo Bagnara void setLocation(SourceLocation L) { NameInfo.setLoc(L); } 18665953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor 18675953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor /// \brief Retrieve the source range of the nested-name-specifier. 18685953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor SourceRange getQualifierRange() const { return QualifierRange; } 186912dffcddb60380c5bed4f085a1f51534afda3b87Argyrios Kyrtzidis void setQualifierRange(SourceRange R) { QualifierRange = R; } 18705953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor 1871ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor /// \brief Retrieve the nested-name-specifier that qualifies this 1872ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor /// declaration. 1873edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor NestedNameSpecifier *getQualifier() const { return Qualifier; } 187412dffcddb60380c5bed4f085a1f51534afda3b87Argyrios Kyrtzidis void setQualifier(NestedNameSpecifier *NNS) { Qualifier = NNS; } 18751eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1876f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall /// Determines whether this lookup had explicit template arguments. 1877f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall bool hasExplicitTemplateArgs() const { return HasExplicitTemplateArgs; } 18781eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1879f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall // Note that, inconsistently with the explicit-template-argument AST 1880f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall // nodes, users are *forbidden* from calling these methods on objects 1881f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall // without explicit template arguments. 18821eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 188312dffcddb60380c5bed4f085a1f51534afda3b87Argyrios Kyrtzidis ExplicitTemplateArgumentList &getExplicitTemplateArgs() { 188412dffcddb60380c5bed4f085a1f51534afda3b87Argyrios Kyrtzidis assert(hasExplicitTemplateArgs()); 188512dffcddb60380c5bed4f085a1f51534afda3b87Argyrios Kyrtzidis return *reinterpret_cast<ExplicitTemplateArgumentList*>(this + 1); 188612dffcddb60380c5bed4f085a1f51534afda3b87Argyrios Kyrtzidis } 188712dffcddb60380c5bed4f085a1f51534afda3b87Argyrios Kyrtzidis 1888f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall /// Gets a reference to the explicit template argument list. 1889f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall const ExplicitTemplateArgumentList &getExplicitTemplateArgs() const { 1890f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall assert(hasExplicitTemplateArgs()); 1891f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall return *reinterpret_cast<const ExplicitTemplateArgumentList*>(this + 1); 1892f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall } 18931eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1894096832c5ed5b9106fa177ebc148489760c3bc496John McCall /// \brief Retrieves the optional explicit template arguments. 1895096832c5ed5b9106fa177ebc148489760c3bc496John McCall /// This points to the same data as getExplicitTemplateArgs(), but 1896096832c5ed5b9106fa177ebc148489760c3bc496John McCall /// returns null if there are no explicit template arguments. 1897096832c5ed5b9106fa177ebc148489760c3bc496John McCall const ExplicitTemplateArgumentList *getOptionalExplicitTemplateArgs() { 1898096832c5ed5b9106fa177ebc148489760c3bc496John McCall if (!hasExplicitTemplateArgs()) return 0; 1899096832c5ed5b9106fa177ebc148489760c3bc496John McCall return &getExplicitTemplateArgs(); 1900096832c5ed5b9106fa177ebc148489760c3bc496John McCall } 1901096832c5ed5b9106fa177ebc148489760c3bc496John McCall 1902f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall /// \brief Copies the template arguments (if present) into the given 1903f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall /// structure. 1904f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall void copyTemplateArgumentsInto(TemplateArgumentListInfo &List) const { 1905f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall getExplicitTemplateArgs().copyInto(List); 1906f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall } 1907f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall 1908f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall SourceLocation getLAngleLoc() const { 1909f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall return getExplicitTemplateArgs().LAngleLoc; 1910edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor } 19111eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1912f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall SourceLocation getRAngleLoc() const { 1913f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall return getExplicitTemplateArgs().RAngleLoc; 1914f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall } 19151eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1916f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall TemplateArgumentLoc const *getTemplateArgs() const { 1917f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall return getExplicitTemplateArgs().getTemplateArgs(); 1918d5532b6cfff2977e0c59fa6ead7f7973984a620dJohn McCall } 1919d5532b6cfff2977e0c59fa6ead7f7973984a620dJohn McCall 1920f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall unsigned getNumTemplateArgs() const { 1921f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall return getExplicitTemplateArgs().NumTemplateArgs; 1922f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall } 19231eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1924edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor virtual SourceRange getSourceRange() const { 1925f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall SourceRange Range(QualifierRange.getBegin(), getLocation()); 1926f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall if (hasExplicitTemplateArgs()) 1927f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall Range.setEnd(getRAngleLoc()); 1928f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall return Range; 1929edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor } 19301eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 19311eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump static bool classof(const Stmt *T) { 1932f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall return T->getStmtClass() == DependentScopeDeclRefExprClass; 1933edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor } 1934f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall static bool classof(const DependentScopeDeclRefExpr *) { return true; } 1935f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall 1936f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall virtual StmtIterator child_begin(); 1937f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall virtual StmtIterator child_end(); 19384045107b7384fd68eed5e3e2f06fc2a47e7be0a6Argyrios Kyrtzidis 19394045107b7384fd68eed5e3e2f06fc2a47e7be0a6Argyrios Kyrtzidis friend class ASTStmtReader; 19404045107b7384fd68eed5e3e2f06fc2a47e7be0a6Argyrios Kyrtzidis friend class ASTStmtWriter; 1941edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor}; 19421eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 19434765fa05b5652fcc4356371c2f481d0ea9a1b007John McCall/// Represents an expression --- generally a full-expression --- which 19444765fa05b5652fcc4356371c2f481d0ea9a1b007John McCall/// introduces cleanups to be run at the end of the sub-expression's 19454765fa05b5652fcc4356371c2f481d0ea9a1b007John McCall/// evaluation. The most common source of expression-introduced 19464765fa05b5652fcc4356371c2f481d0ea9a1b007John McCall/// cleanups is temporary objects in C++, but several other C++ 19474765fa05b5652fcc4356371c2f481d0ea9a1b007John McCall/// expressions can create cleanups. 19484765fa05b5652fcc4356371c2f481d0ea9a1b007John McCallclass ExprWithCleanups : public Expr { 194902bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson Stmt *SubExpr; 19501eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1951ff6b3d64c9f07155f1414411b8451d7bf8937c62Anders Carlsson CXXTemporary **Temps; 1952ff6b3d64c9f07155f1414411b8451d7bf8937c62Anders Carlsson unsigned NumTemps; 195302bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson 19544765fa05b5652fcc4356371c2f481d0ea9a1b007John McCall ExprWithCleanups(ASTContext &C, Expr *SubExpr, 19554765fa05b5652fcc4356371c2f481d0ea9a1b007John McCall CXXTemporary **Temps, unsigned NumTemps); 19564765fa05b5652fcc4356371c2f481d0ea9a1b007John McCall 195788eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlssonpublic: 19584765fa05b5652fcc4356371c2f481d0ea9a1b007John McCall ExprWithCleanups(EmptyShell Empty) 19594765fa05b5652fcc4356371c2f481d0ea9a1b007John McCall : Expr(ExprWithCleanupsClass, Empty), 1960d2598368876cfe40bc8465540033bc5b5e58d8afChris Lattner SubExpr(0), Temps(0), NumTemps(0) {} 1961d2598368876cfe40bc8465540033bc5b5e58d8afChris Lattner 19624765fa05b5652fcc4356371c2f481d0ea9a1b007John McCall static ExprWithCleanups *Create(ASTContext &C, Expr *SubExpr, 19630ece491d8f62ce67f047491a6703fac0d3bd4ff4Anders Carlsson CXXTemporary **Temps, 19640ece491d8f62ce67f047491a6703fac0d3bd4ff4Anders Carlsson unsigned NumTemps); 19651eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 196688eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlsson unsigned getNumTemporaries() const { return NumTemps; } 1967d04ed416be7c55bddddab1fa3fd38a0113a6b3daTed Kremenek void setNumTemporaries(ASTContext &C, unsigned N); 1968d2598368876cfe40bc8465540033bc5b5e58d8afChris Lattner 196988eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlsson CXXTemporary *getTemporary(unsigned i) { 197088eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlsson assert(i < NumTemps && "Index out of range"); 197188eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlsson return Temps[i]; 197288eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlsson } 1973f0721fe438d7e40c168e5d664970e7830bc138fbAnders Carlsson const CXXTemporary *getTemporary(unsigned i) const { 19744765fa05b5652fcc4356371c2f481d0ea9a1b007John McCall return const_cast<ExprWithCleanups*>(this)->getTemporary(i); 1975f0721fe438d7e40c168e5d664970e7830bc138fbAnders Carlsson } 1976d2598368876cfe40bc8465540033bc5b5e58d8afChris Lattner void setTemporary(unsigned i, CXXTemporary *T) { 1977d2598368876cfe40bc8465540033bc5b5e58d8afChris Lattner assert(i < NumTemps && "Index out of range"); 1978d2598368876cfe40bc8465540033bc5b5e58d8afChris Lattner Temps[i] = T; 1979d2598368876cfe40bc8465540033bc5b5e58d8afChris Lattner } 19801eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 198102bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson Expr *getSubExpr() { return cast<Expr>(SubExpr); } 1982f0721fe438d7e40c168e5d664970e7830bc138fbAnders Carlsson const Expr *getSubExpr() const { return cast<Expr>(SubExpr); } 198388eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlsson void setSubExpr(Expr *E) { SubExpr = E; } 198402bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson 198596be6917e1c4ba1f4435a14c9e7c6c139571d086Douglas Gregor virtual SourceRange getSourceRange() const { 198696be6917e1c4ba1f4435a14c9e7c6c139571d086Douglas Gregor return SubExpr->getSourceRange(); 198796be6917e1c4ba1f4435a14c9e7c6c139571d086Douglas Gregor } 198802bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson 198902bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson // Implement isa/cast/dyncast/etc. 199002bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson static bool classof(const Stmt *T) { 19914765fa05b5652fcc4356371c2f481d0ea9a1b007John McCall return T->getStmtClass() == ExprWithCleanupsClass; 199202bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson } 19934765fa05b5652fcc4356371c2f481d0ea9a1b007John McCall static bool classof(const ExprWithCleanups *) { return true; } 199402bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson 199502bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson // Iterators 199602bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson virtual child_iterator child_begin(); 199702bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson virtual child_iterator child_end(); 199802bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson}; 199902bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson 2000d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// \brief Describes an explicit type conversion that uses functional 2001d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// notion but could not be resolved because one or more arguments are 2002d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// type-dependent. 2003d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// 2004d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// The explicit type conversions expressed by 2005d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// CXXUnresolvedConstructExpr have the form \c T(a1, a2, ..., aN), 2006d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// where \c T is some type and \c a1, a2, ..., aN are values, and 2007d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// either \C T is a dependent type or one or more of the \c a's is 2008d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// type-dependent. For example, this would occur in a template such 2009d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// as: 2010d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// 2011d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// \code 2012d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// template<typename T, typename A1> 2013d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// inline T make_a(const A1& a1) { 2014d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// return T(a1); 2015d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// } 2016d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// \endcode 2017d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// 2018d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// When the returned expression is instantiated, it may resolve to a 2019d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// constructor call, conversion function call, or some kind of type 2020d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// conversion. 2021d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregorclass CXXUnresolvedConstructExpr : public Expr { 2022d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor /// \brief The type being constructed. 2023ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor TypeSourceInfo *Type; 2024ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor 2025d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor /// \brief The location of the left parentheses ('('). 2026d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor SourceLocation LParenLoc; 2027d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor 2028d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor /// \brief The location of the right parentheses (')'). 2029d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor SourceLocation RParenLoc; 2030d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor 2031d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor /// \brief The number of arguments used to construct the type. 2032d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor unsigned NumArgs; 20331eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 2034ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor CXXUnresolvedConstructExpr(TypeSourceInfo *Type, 2035d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor SourceLocation LParenLoc, 2036d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor Expr **Args, 2037d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor unsigned NumArgs, 2038d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor SourceLocation RParenLoc); 2039d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor 20408dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis CXXUnresolvedConstructExpr(EmptyShell Empty, unsigned NumArgs) 2041ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor : Expr(CXXUnresolvedConstructExprClass, Empty), Type(), NumArgs(NumArgs) { } 20428dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis 2043ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor friend class ASTStmtReader; 2044ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor 2045d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregorpublic: 20461eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump static CXXUnresolvedConstructExpr *Create(ASTContext &C, 2047ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor TypeSourceInfo *Type, 2048d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor SourceLocation LParenLoc, 2049d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor Expr **Args, 2050d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor unsigned NumArgs, 2051d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor SourceLocation RParenLoc); 2052d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor 20538dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis static CXXUnresolvedConstructExpr *CreateEmpty(ASTContext &C, 20548dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis unsigned NumArgs); 20558dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis 2056d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor /// \brief Retrieve the type that is being constructed, as specified 2057d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor /// in the source code. 2058ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor QualType getTypeAsWritten() const { return Type->getType(); } 2059d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor 2060ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor /// \brief Retrieve the type source information for the type being 2061ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor /// constructed. 2062ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor TypeSourceInfo *getTypeSourceInfo() const { return Type; } 2063ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor 2064d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor /// \brief Retrieve the location of the left parentheses ('(') that 2065d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor /// precedes the argument list. 2066d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor SourceLocation getLParenLoc() const { return LParenLoc; } 2067d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor void setLParenLoc(SourceLocation L) { LParenLoc = L; } 2068d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor 2069d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor /// \brief Retrieve the location of the right parentheses (')') that 2070d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor /// follows the argument list. 2071d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor SourceLocation getRParenLoc() const { return RParenLoc; } 2072d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor void setRParenLoc(SourceLocation L) { RParenLoc = L; } 2073d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor 2074d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor /// \brief Retrieve the number of arguments. 2075d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor unsigned arg_size() const { return NumArgs; } 2076d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor 2077d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor typedef Expr** arg_iterator; 2078d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor arg_iterator arg_begin() { return reinterpret_cast<Expr**>(this + 1); } 2079d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor arg_iterator arg_end() { return arg_begin() + NumArgs; } 2080d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor 20811dd7383dc48718c452e71a625b29531dd96fbb9dJohn McCall typedef const Expr* const * const_arg_iterator; 20821dd7383dc48718c452e71a625b29531dd96fbb9dJohn McCall const_arg_iterator arg_begin() const { 20831dd7383dc48718c452e71a625b29531dd96fbb9dJohn McCall return reinterpret_cast<const Expr* const *>(this + 1); 20841dd7383dc48718c452e71a625b29531dd96fbb9dJohn McCall } 20851dd7383dc48718c452e71a625b29531dd96fbb9dJohn McCall const_arg_iterator arg_end() const { 20861dd7383dc48718c452e71a625b29531dd96fbb9dJohn McCall return arg_begin() + NumArgs; 20871dd7383dc48718c452e71a625b29531dd96fbb9dJohn McCall } 20881dd7383dc48718c452e71a625b29531dd96fbb9dJohn McCall 2089d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor Expr *getArg(unsigned I) { 2090d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor assert(I < NumArgs && "Argument index out-of-range"); 2091d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor return *(arg_begin() + I); 2092d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor } 2093d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor 20941dd7383dc48718c452e71a625b29531dd96fbb9dJohn McCall const Expr *getArg(unsigned I) const { 20951dd7383dc48718c452e71a625b29531dd96fbb9dJohn McCall assert(I < NumArgs && "Argument index out-of-range"); 20961dd7383dc48718c452e71a625b29531dd96fbb9dJohn McCall return *(arg_begin() + I); 20971dd7383dc48718c452e71a625b29531dd96fbb9dJohn McCall } 20981dd7383dc48718c452e71a625b29531dd96fbb9dJohn McCall 20998dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis void setArg(unsigned I, Expr *E) { 21008dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis assert(I < NumArgs && "Argument index out-of-range"); 21018dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis *(arg_begin() + I) = E; 21028dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis } 21038dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis 2104ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor virtual SourceRange getSourceRange() const; 2105ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor 21061eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump static bool classof(const Stmt *T) { 2107d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor return T->getStmtClass() == CXXUnresolvedConstructExprClass; 2108d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor } 2109d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor static bool classof(const CXXUnresolvedConstructExpr *) { return true; } 2110d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor 2111d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor // Iterators 2112d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor virtual child_iterator child_begin(); 2113d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor virtual child_iterator child_end(); 2114d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor}; 2115d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor 2116ba13543329afac4a0d01304ec2ec4924d99306a6John McCall/// \brief Represents a C++ member access expression where the actual 2117ba13543329afac4a0d01304ec2ec4924d99306a6John McCall/// member referenced could not be resolved because the base 2118ba13543329afac4a0d01304ec2ec4924d99306a6John McCall/// expression or the member name was dependent. 2119aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall/// 2120aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall/// Like UnresolvedMemberExprs, these can be either implicit or 2121aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall/// explicit accesses. It is only possible to get one of these with 2122aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall/// an implicit access if a qualifier is provided. 2123865d447ac6a4721ab58e898d014a21f2eff74b06John McCallclass CXXDependentScopeMemberExpr : public Expr { 21241c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor /// \brief The expression for the base pointer or class reference, 2125aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall /// e.g., the \c x in x.f. Can be null in implicit accesses. 21261c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor Stmt *Base; 21271eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 2128aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall /// \brief The type of the base expression. Never null, even for 2129aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall /// implicit accesses. 2130aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall QualType BaseType; 2131aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall 21321c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor /// \brief Whether this member expression used the '->' operator or 21331c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor /// the '.' operator. 21343b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor bool IsArrow : 1; 21351c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor 21363b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor /// \brief Whether this member expression has explicitly-specified template 21373b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor /// arguments. 2138aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall bool HasExplicitTemplateArgs : 1; 21391eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 21401c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor /// \brief The location of the '->' or '.' operator. 21411c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor SourceLocation OperatorLoc; 21421c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor 2143a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor /// \brief The nested-name-specifier that precedes the member name, if any. 2144a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor NestedNameSpecifier *Qualifier; 21451eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 2146a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor /// \brief The source range covering the nested name specifier. 2147a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor SourceRange QualifierRange; 21481eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 2149c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor /// \brief In a qualified member access expression such as t->Base::f, this 21501eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump /// member stores the resolves of name lookup in the context of the member 2151c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor /// access expression, to be used at instantiation time. 2152c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor /// 2153c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor /// FIXME: This member, along with the Qualifier and QualifierRange, could 2154c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor /// be stuck into a structure that is optionally allocated at the end of 2155865d447ac6a4721ab58e898d014a21f2eff74b06John McCall /// the CXXDependentScopeMemberExpr, to save space in the common case. 2156c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor NamedDecl *FirstQualifierFoundInScope; 21571eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 21581c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor /// \brief The member to which this member expression refers, which 21591c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor /// can be name, overloaded operator, or destructor. 2160a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor /// FIXME: could also be a template-id 21612577743c5650c646fb705df01403707e94f2df04Abramo Bagnara DeclarationNameInfo MemberNameInfo; 21621eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 2163865d447ac6a4721ab58e898d014a21f2eff74b06John McCall CXXDependentScopeMemberExpr(ASTContext &C, 2164aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall Expr *Base, QualType BaseType, bool IsArrow, 21653b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor SourceLocation OperatorLoc, 21663b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor NestedNameSpecifier *Qualifier, 21673b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor SourceRange QualifierRange, 21683b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor NamedDecl *FirstQualifierFoundInScope, 21692577743c5650c646fb705df01403707e94f2df04Abramo Bagnara DeclarationNameInfo MemberNameInfo, 2170d5532b6cfff2977e0c59fa6ead7f7973984a620dJohn McCall const TemplateArgumentListInfo *TemplateArgs); 21711eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 21721c0ca59416999129d0439c2661d137ef38e86209Douglas Gregorpublic: 2173865d447ac6a4721ab58e898d014a21f2eff74b06John McCall CXXDependentScopeMemberExpr(ASTContext &C, 2174bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor Expr *Base, QualType BaseType, 2175bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor bool IsArrow, 2176bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor SourceLocation OperatorLoc, 2177bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor NestedNameSpecifier *Qualifier, 2178bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor SourceRange QualifierRange, 2179bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor NamedDecl *FirstQualifierFoundInScope, 2180bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor DeclarationNameInfo MemberNameInfo); 21811eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 2182865d447ac6a4721ab58e898d014a21f2eff74b06John McCall static CXXDependentScopeMemberExpr * 21831eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump Create(ASTContext &C, 2184aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall Expr *Base, QualType BaseType, bool IsArrow, 21853b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor SourceLocation OperatorLoc, 21863b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor NestedNameSpecifier *Qualifier, 21873b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor SourceRange QualifierRange, 21883b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor NamedDecl *FirstQualifierFoundInScope, 21892577743c5650c646fb705df01403707e94f2df04Abramo Bagnara DeclarationNameInfo MemberNameInfo, 2190d5532b6cfff2977e0c59fa6ead7f7973984a620dJohn McCall const TemplateArgumentListInfo *TemplateArgs); 21911eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 21928dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis static CXXDependentScopeMemberExpr * 21938dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis CreateEmpty(ASTContext &C, unsigned NumTemplateArgs); 21948dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis 2195aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall /// \brief True if this is an implicit access, i.e. one in which the 2196aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall /// member being accessed was not written in the source. The source 2197aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall /// location of the operator is invalid in this case. 2198aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall bool isImplicitAccess() const { return Base == 0; } 2199aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall 22001c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor /// \brief Retrieve the base object of this member expressions, 22011c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor /// e.g., the \c x in \c x.m. 2202aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall Expr *getBase() const { 2203aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall assert(!isImplicitAccess()); 2204aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall return cast<Expr>(Base); 2205aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall } 22061c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor void setBase(Expr *E) { Base = E; } 22071c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor 2208aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall QualType getBaseType() const { return BaseType; } 22098dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis void setBaseType(QualType T) { BaseType = T; } 2210aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall 22111c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor /// \brief Determine whether this member expression used the '->' 22121c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor /// operator; otherwise, it used the '.' operator. 22131c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor bool isArrow() const { return IsArrow; } 22141c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor void setArrow(bool A) { IsArrow = A; } 22151c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor 22161c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor /// \brief Retrieve the location of the '->' or '.' operator. 22171c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor SourceLocation getOperatorLoc() const { return OperatorLoc; } 22181c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor void setOperatorLoc(SourceLocation L) { OperatorLoc = L; } 22191c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor 2220a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor /// \brief Retrieve the nested-name-specifier that qualifies the member 2221a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor /// name. 2222a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor NestedNameSpecifier *getQualifier() const { return Qualifier; } 22238dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis void setQualifier(NestedNameSpecifier *NNS) { Qualifier = NNS; } 22241eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 2225a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor /// \brief Retrieve the source range covering the nested-name-specifier 2226a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor /// that qualifies the member name. 2227a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor SourceRange getQualifierRange() const { return QualifierRange; } 22288dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis void setQualifierRange(SourceRange R) { QualifierRange = R; } 22291eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 2230c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor /// \brief Retrieve the first part of the nested-name-specifier that was 2231c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor /// found in the scope of the member access expression when the member access 2232c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor /// was initially parsed. 2233c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor /// 2234c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor /// This function only returns a useful result when member access expression 22351eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump /// uses a qualified member name, e.g., "x.Base::f". Here, the declaration 22361eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump /// returned by this function describes what was found by unqualified name 2237c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor /// lookup for the identifier "Base" within the scope of the member access 2238c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor /// expression itself. At template instantiation time, this information is 2239c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor /// combined with the results of name lookup into the type of the object 2240c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor /// expression itself (the class type of x). 22411eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump NamedDecl *getFirstQualifierFoundInScope() const { 2242c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor return FirstQualifierFoundInScope; 2243c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor } 22448dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis void setFirstQualifierFoundInScope(NamedDecl *D) { 22458dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis FirstQualifierFoundInScope = D; 22468dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis } 22471eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 22481c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor /// \brief Retrieve the name of the member that this expression 22491c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor /// refers to. 22502577743c5650c646fb705df01403707e94f2df04Abramo Bagnara const DeclarationNameInfo &getMemberNameInfo() const { 22512577743c5650c646fb705df01403707e94f2df04Abramo Bagnara return MemberNameInfo; 22522577743c5650c646fb705df01403707e94f2df04Abramo Bagnara } 22532577743c5650c646fb705df01403707e94f2df04Abramo Bagnara void setMemberNameInfo(const DeclarationNameInfo &N) { MemberNameInfo = N; } 22542577743c5650c646fb705df01403707e94f2df04Abramo Bagnara 22552577743c5650c646fb705df01403707e94f2df04Abramo Bagnara /// \brief Retrieve the name of the member that this expression 22562577743c5650c646fb705df01403707e94f2df04Abramo Bagnara /// refers to. 22572577743c5650c646fb705df01403707e94f2df04Abramo Bagnara DeclarationName getMember() const { return MemberNameInfo.getName(); } 22582577743c5650c646fb705df01403707e94f2df04Abramo Bagnara void setMember(DeclarationName N) { MemberNameInfo.setName(N); } 22591c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor 22601c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor // \brief Retrieve the location of the name of the member that this 22611c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor // expression refers to. 22622577743c5650c646fb705df01403707e94f2df04Abramo Bagnara SourceLocation getMemberLoc() const { return MemberNameInfo.getLoc(); } 22632577743c5650c646fb705df01403707e94f2df04Abramo Bagnara void setMemberLoc(SourceLocation L) { MemberNameInfo.setLoc(L); } 22641c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor 22653b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor /// \brief Determines whether this member expression actually had a C++ 22663b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor /// template argument list explicitly specified, e.g., x.f<int>. 2267aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall bool hasExplicitTemplateArgs() const { 2268aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall return HasExplicitTemplateArgs; 22693b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor } 22701eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 227136c76f0bea0d3595a25a5362225c642019cc3176Argyrios Kyrtzidis /// \brief Retrieve the explicit template argument list that followed the 227236c76f0bea0d3595a25a5362225c642019cc3176Argyrios Kyrtzidis /// member template name, if any. 2273096832c5ed5b9106fa177ebc148489760c3bc496John McCall ExplicitTemplateArgumentList &getExplicitTemplateArgs() { 227436c76f0bea0d3595a25a5362225c642019cc3176Argyrios Kyrtzidis assert(HasExplicitTemplateArgs); 2275096832c5ed5b9106fa177ebc148489760c3bc496John McCall return *reinterpret_cast<ExplicitTemplateArgumentList *>(this + 1); 227636c76f0bea0d3595a25a5362225c642019cc3176Argyrios Kyrtzidis } 227736c76f0bea0d3595a25a5362225c642019cc3176Argyrios Kyrtzidis 227836c76f0bea0d3595a25a5362225c642019cc3176Argyrios Kyrtzidis /// \brief Retrieve the explicit template argument list that followed the 227936c76f0bea0d3595a25a5362225c642019cc3176Argyrios Kyrtzidis /// member template name, if any. 2280096832c5ed5b9106fa177ebc148489760c3bc496John McCall const ExplicitTemplateArgumentList &getExplicitTemplateArgs() const { 228136c76f0bea0d3595a25a5362225c642019cc3176Argyrios Kyrtzidis return const_cast<CXXDependentScopeMemberExpr *>(this) 2282096832c5ed5b9106fa177ebc148489760c3bc496John McCall ->getExplicitTemplateArgs(); 2283096832c5ed5b9106fa177ebc148489760c3bc496John McCall } 2284096832c5ed5b9106fa177ebc148489760c3bc496John McCall 2285096832c5ed5b9106fa177ebc148489760c3bc496John McCall /// \brief Retrieves the optional explicit template arguments. 2286096832c5ed5b9106fa177ebc148489760c3bc496John McCall /// This points to the same data as getExplicitTemplateArgs(), but 2287096832c5ed5b9106fa177ebc148489760c3bc496John McCall /// returns null if there are no explicit template arguments. 2288096832c5ed5b9106fa177ebc148489760c3bc496John McCall const ExplicitTemplateArgumentList *getOptionalExplicitTemplateArgs() { 2289096832c5ed5b9106fa177ebc148489760c3bc496John McCall if (!hasExplicitTemplateArgs()) return 0; 2290096832c5ed5b9106fa177ebc148489760c3bc496John McCall return &getExplicitTemplateArgs(); 229136c76f0bea0d3595a25a5362225c642019cc3176Argyrios Kyrtzidis } 229236c76f0bea0d3595a25a5362225c642019cc3176Argyrios Kyrtzidis 2293d5532b6cfff2977e0c59fa6ead7f7973984a620dJohn McCall /// \brief Copies the template arguments (if present) into the given 2294d5532b6cfff2977e0c59fa6ead7f7973984a620dJohn McCall /// structure. 2295d5532b6cfff2977e0c59fa6ead7f7973984a620dJohn McCall void copyTemplateArgumentsInto(TemplateArgumentListInfo &List) const { 2296096832c5ed5b9106fa177ebc148489760c3bc496John McCall getExplicitTemplateArgs().copyInto(List); 2297d5532b6cfff2977e0c59fa6ead7f7973984a620dJohn McCall } 2298d5532b6cfff2977e0c59fa6ead7f7973984a620dJohn McCall 22998dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis /// \brief Initializes the template arguments using the given structure. 23008dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis void initializeTemplateArgumentsFrom(const TemplateArgumentListInfo &List) { 2301096832c5ed5b9106fa177ebc148489760c3bc496John McCall getExplicitTemplateArgs().initializeFrom(List); 23028dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis } 23038dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis 23041eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump /// \brief Retrieve the location of the left angle bracket following the 23053b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor /// member name ('<'), if any. 23061eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump SourceLocation getLAngleLoc() const { 2307096832c5ed5b9106fa177ebc148489760c3bc496John McCall return getExplicitTemplateArgs().LAngleLoc; 23083b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor } 23091eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 23103b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor /// \brief Retrieve the template arguments provided as part of this 23113b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor /// template-id. 2312833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall const TemplateArgumentLoc *getTemplateArgs() const { 2313096832c5ed5b9106fa177ebc148489760c3bc496John McCall return getExplicitTemplateArgs().getTemplateArgs(); 23143b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor } 23151eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 23163b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor /// \brief Retrieve the number of template arguments provided as part of this 23173b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor /// template-id. 23181eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump unsigned getNumTemplateArgs() const { 2319096832c5ed5b9106fa177ebc148489760c3bc496John McCall return getExplicitTemplateArgs().NumTemplateArgs; 23203b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor } 23211eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 23221eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump /// \brief Retrieve the location of the right angle bracket following the 23233b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor /// template arguments ('>'). 23241eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump SourceLocation getRAngleLoc() const { 2325096832c5ed5b9106fa177ebc148489760c3bc496John McCall return getExplicitTemplateArgs().RAngleLoc; 23263b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor } 23271eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 23281c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor virtual SourceRange getSourceRange() const { 2329aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall SourceRange Range; 2330aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall if (!isImplicitAccess()) 2331aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall Range.setBegin(Base->getSourceRange().getBegin()); 2332aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall else if (getQualifier()) 2333aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall Range.setBegin(getQualifierRange().getBegin()); 2334aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall else 23352577743c5650c646fb705df01403707e94f2df04Abramo Bagnara Range.setBegin(MemberNameInfo.getBeginLoc()); 23361eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 2337aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall if (hasExplicitTemplateArgs()) 2338aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall Range.setEnd(getRAngleLoc()); 2339aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall else 23402577743c5650c646fb705df01403707e94f2df04Abramo Bagnara Range.setEnd(MemberNameInfo.getEndLoc()); 2341aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall return Range; 23421c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor } 23431eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 23441eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump static bool classof(const Stmt *T) { 2345865d447ac6a4721ab58e898d014a21f2eff74b06John McCall return T->getStmtClass() == CXXDependentScopeMemberExprClass; 23461c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor } 2347865d447ac6a4721ab58e898d014a21f2eff74b06John McCall static bool classof(const CXXDependentScopeMemberExpr *) { return true; } 23481c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor 23491c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor // Iterators 23501c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor virtual child_iterator child_begin(); 23511c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor virtual child_iterator child_end(); 23524045107b7384fd68eed5e3e2f06fc2a47e7be0a6Argyrios Kyrtzidis 23534045107b7384fd68eed5e3e2f06fc2a47e7be0a6Argyrios Kyrtzidis friend class ASTStmtReader; 23544045107b7384fd68eed5e3e2f06fc2a47e7be0a6Argyrios Kyrtzidis friend class ASTStmtWriter; 23551c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor}; 23561c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor 2357129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall/// \brief Represents a C++ member access expression for which lookup 2358aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall/// produced a set of overloaded functions. 2359aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall/// 2360aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall/// The member access may be explicit or implicit: 2361aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall/// struct A { 2362aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall/// int a, b; 2363aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall/// int explicitAccess() { return this->a + this->A::b; } 2364aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall/// int implicitAccess() { return a + A::b; } 2365aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall/// }; 2366aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall/// 2367aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall/// In the final AST, an explicit access always becomes a MemberExpr. 2368aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall/// An implicit access may become either a MemberExpr or a 2369aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall/// DeclRefExpr, depending on whether the member is static. 23707bb12da2b0749eeebb21854c77877736969e59f2John McCallclass UnresolvedMemberExpr : public OverloadExpr { 2371129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall /// \brief Whether this member expression used the '->' operator or 2372129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall /// the '.' operator. 2373129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall bool IsArrow : 1; 2374129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall 2375129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall /// \brief Whether the lookup results contain an unresolved using 2376129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall /// declaration. 2377129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall bool HasUnresolvedUsing : 1; 2378129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall 23797bb12da2b0749eeebb21854c77877736969e59f2John McCall /// \brief The expression for the base pointer or class reference, 23807bb12da2b0749eeebb21854c77877736969e59f2John McCall /// e.g., the \c x in x.f. This can be null if this is an 'unbased' 23817bb12da2b0749eeebb21854c77877736969e59f2John McCall /// member expression 23827bb12da2b0749eeebb21854c77877736969e59f2John McCall Stmt *Base; 23837bb12da2b0749eeebb21854c77877736969e59f2John McCall 23847bb12da2b0749eeebb21854c77877736969e59f2John McCall /// \brief The type of the base expression; never null. 23857bb12da2b0749eeebb21854c77877736969e59f2John McCall QualType BaseType; 2386129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall 2387129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall /// \brief The location of the '->' or '.' operator. 2388129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall SourceLocation OperatorLoc; 2389129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall 2390bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor UnresolvedMemberExpr(ASTContext &C, bool HasUnresolvedUsing, 2391aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall Expr *Base, QualType BaseType, bool IsArrow, 2392129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall SourceLocation OperatorLoc, 2393129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall NestedNameSpecifier *Qualifier, 2394129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall SourceRange QualifierRange, 23952577743c5650c646fb705df01403707e94f2df04Abramo Bagnara const DeclarationNameInfo &MemberNameInfo, 23965a84dec38cfa9e084377a3167b474c79283c82faDouglas Gregor const TemplateArgumentListInfo *TemplateArgs, 23975a84dec38cfa9e084377a3167b474c79283c82faDouglas Gregor UnresolvedSetIterator Begin, UnresolvedSetIterator End); 2398a77eb0862507b900a10fa352af1568e639ed10b1Argyrios Kyrtzidis 2399a77eb0862507b900a10fa352af1568e639ed10b1Argyrios Kyrtzidis UnresolvedMemberExpr(EmptyShell Empty) 2400a77eb0862507b900a10fa352af1568e639ed10b1Argyrios Kyrtzidis : OverloadExpr(UnresolvedMemberExprClass, Empty), IsArrow(false), 2401a77eb0862507b900a10fa352af1568e639ed10b1Argyrios Kyrtzidis HasUnresolvedUsing(false), Base(0) { } 2402129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall 2403129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCallpublic: 2404129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall static UnresolvedMemberExpr * 2405bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor Create(ASTContext &C, bool HasUnresolvedUsing, 2406aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall Expr *Base, QualType BaseType, bool IsArrow, 2407129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall SourceLocation OperatorLoc, 2408129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall NestedNameSpecifier *Qualifier, 2409129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall SourceRange QualifierRange, 24102577743c5650c646fb705df01403707e94f2df04Abramo Bagnara const DeclarationNameInfo &MemberNameInfo, 24115a84dec38cfa9e084377a3167b474c79283c82faDouglas Gregor const TemplateArgumentListInfo *TemplateArgs, 24125a84dec38cfa9e084377a3167b474c79283c82faDouglas Gregor UnresolvedSetIterator Begin, UnresolvedSetIterator End); 2413129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall 2414a77eb0862507b900a10fa352af1568e639ed10b1Argyrios Kyrtzidis static UnresolvedMemberExpr * 2415a77eb0862507b900a10fa352af1568e639ed10b1Argyrios Kyrtzidis CreateEmpty(ASTContext &C, unsigned NumTemplateArgs); 2416a77eb0862507b900a10fa352af1568e639ed10b1Argyrios Kyrtzidis 2417aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall /// \brief True if this is an implicit access, i.e. one in which the 2418aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall /// member being accessed was not written in the source. The source 2419aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall /// location of the operator is invalid in this case. 2420aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall bool isImplicitAccess() const { return Base == 0; } 2421aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall 2422129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall /// \brief Retrieve the base object of this member expressions, 2423129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall /// e.g., the \c x in \c x.m. 2424aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall Expr *getBase() { 2425aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall assert(!isImplicitAccess()); 2426aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall return cast<Expr>(Base); 2427aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall } 24282f27bf854f0519810b34afd209089cc75536b757John McCall const Expr *getBase() const { 24292f27bf854f0519810b34afd209089cc75536b757John McCall assert(!isImplicitAccess()); 24302f27bf854f0519810b34afd209089cc75536b757John McCall return cast<Expr>(Base); 24312f27bf854f0519810b34afd209089cc75536b757John McCall } 2432129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall void setBase(Expr *E) { Base = E; } 2433129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall 2434aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall QualType getBaseType() const { return BaseType; } 2435a77eb0862507b900a10fa352af1568e639ed10b1Argyrios Kyrtzidis void setBaseType(QualType T) { BaseType = T; } 2436a77eb0862507b900a10fa352af1568e639ed10b1Argyrios Kyrtzidis 2437a77eb0862507b900a10fa352af1568e639ed10b1Argyrios Kyrtzidis /// \brief Determine whether the lookup results contain an unresolved using 2438a77eb0862507b900a10fa352af1568e639ed10b1Argyrios Kyrtzidis /// declaration. 2439a77eb0862507b900a10fa352af1568e639ed10b1Argyrios Kyrtzidis bool hasUnresolvedUsing() const { return HasUnresolvedUsing; } 2440a77eb0862507b900a10fa352af1568e639ed10b1Argyrios Kyrtzidis void setHasUnresolvedUsing(bool V) { HasUnresolvedUsing = V; } 2441aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall 2442129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall /// \brief Determine whether this member expression used the '->' 2443129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall /// operator; otherwise, it used the '.' operator. 2444129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall bool isArrow() const { return IsArrow; } 2445129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall void setArrow(bool A) { IsArrow = A; } 2446129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall 2447129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall /// \brief Retrieve the location of the '->' or '.' operator. 2448129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall SourceLocation getOperatorLoc() const { return OperatorLoc; } 2449129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall void setOperatorLoc(SourceLocation L) { OperatorLoc = L; } 2450129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall 2451c373d48502ca7683ab55385f5bd624d778eb288dJohn McCall /// \brief Retrieves the naming class of this lookup. 2452c373d48502ca7683ab55385f5bd624d778eb288dJohn McCall CXXRecordDecl *getNamingClass() const; 2453c373d48502ca7683ab55385f5bd624d778eb288dJohn McCall 24542577743c5650c646fb705df01403707e94f2df04Abramo Bagnara /// \brief Retrieve the full name info for the member that this expression 24552577743c5650c646fb705df01403707e94f2df04Abramo Bagnara /// refers to. 24562577743c5650c646fb705df01403707e94f2df04Abramo Bagnara const DeclarationNameInfo &getMemberNameInfo() const { return getNameInfo(); } 24572577743c5650c646fb705df01403707e94f2df04Abramo Bagnara void setMemberNameInfo(const DeclarationNameInfo &N) { setNameInfo(N); } 24582577743c5650c646fb705df01403707e94f2df04Abramo Bagnara 2459129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall /// \brief Retrieve the name of the member that this expression 2460129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall /// refers to. 24617bb12da2b0749eeebb21854c77877736969e59f2John McCall DeclarationName getMemberName() const { return getName(); } 24627bb12da2b0749eeebb21854c77877736969e59f2John McCall void setMemberName(DeclarationName N) { setName(N); } 2463129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall 2464129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall // \brief Retrieve the location of the name of the member that this 2465129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall // expression refers to. 24667bb12da2b0749eeebb21854c77877736969e59f2John McCall SourceLocation getMemberLoc() const { return getNameLoc(); } 24677bb12da2b0749eeebb21854c77877736969e59f2John McCall void setMemberLoc(SourceLocation L) { setNameLoc(L); } 2468129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall 24697bb12da2b0749eeebb21854c77877736969e59f2John McCall /// \brief Retrieve the explicit template argument list that followed the 24707bb12da2b0749eeebb21854c77877736969e59f2John McCall /// member template name. 24717bb12da2b0749eeebb21854c77877736969e59f2John McCall ExplicitTemplateArgumentList &getExplicitTemplateArgs() { 24727bb12da2b0749eeebb21854c77877736969e59f2John McCall assert(hasExplicitTemplateArgs()); 24737bb12da2b0749eeebb21854c77877736969e59f2John McCall return *reinterpret_cast<ExplicitTemplateArgumentList *>(this + 1); 24747bb12da2b0749eeebb21854c77877736969e59f2John McCall } 24757bb12da2b0749eeebb21854c77877736969e59f2John McCall 24767bb12da2b0749eeebb21854c77877736969e59f2John McCall /// \brief Retrieve the explicit template argument list that followed the 24777bb12da2b0749eeebb21854c77877736969e59f2John McCall /// member template name, if any. 24787bb12da2b0749eeebb21854c77877736969e59f2John McCall const ExplicitTemplateArgumentList &getExplicitTemplateArgs() const { 24797bb12da2b0749eeebb21854c77877736969e59f2John McCall assert(hasExplicitTemplateArgs()); 24807bb12da2b0749eeebb21854c77877736969e59f2John McCall return *reinterpret_cast<const ExplicitTemplateArgumentList *>(this + 1); 2481129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall } 2482129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall 2483096832c5ed5b9106fa177ebc148489760c3bc496John McCall /// \brief Retrieves the optional explicit template arguments. 2484096832c5ed5b9106fa177ebc148489760c3bc496John McCall /// This points to the same data as getExplicitTemplateArgs(), but 2485096832c5ed5b9106fa177ebc148489760c3bc496John McCall /// returns null if there are no explicit template arguments. 2486096832c5ed5b9106fa177ebc148489760c3bc496John McCall const ExplicitTemplateArgumentList *getOptionalExplicitTemplateArgs() { 2487096832c5ed5b9106fa177ebc148489760c3bc496John McCall if (!hasExplicitTemplateArgs()) return 0; 2488096832c5ed5b9106fa177ebc148489760c3bc496John McCall return &getExplicitTemplateArgs(); 2489096832c5ed5b9106fa177ebc148489760c3bc496John McCall } 2490096832c5ed5b9106fa177ebc148489760c3bc496John McCall 2491129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall /// \brief Copies the template arguments into the given structure. 2492129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall void copyTemplateArgumentsInto(TemplateArgumentListInfo &List) const { 24937bb12da2b0749eeebb21854c77877736969e59f2John McCall getExplicitTemplateArgs().copyInto(List); 2494129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall } 2495129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall 2496129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall /// \brief Retrieve the location of the left angle bracket following 2497129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall /// the member name ('<'). 2498129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall SourceLocation getLAngleLoc() const { 24997bb12da2b0749eeebb21854c77877736969e59f2John McCall return getExplicitTemplateArgs().LAngleLoc; 2500129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall } 2501129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall 2502129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall /// \brief Retrieve the template arguments provided as part of this 2503129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall /// template-id. 2504129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall const TemplateArgumentLoc *getTemplateArgs() const { 25057bb12da2b0749eeebb21854c77877736969e59f2John McCall return getExplicitTemplateArgs().getTemplateArgs(); 2506129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall } 2507129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall 2508129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall /// \brief Retrieve the number of template arguments provided as 2509129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall /// part of this template-id. 2510129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall unsigned getNumTemplateArgs() const { 25117bb12da2b0749eeebb21854c77877736969e59f2John McCall return getExplicitTemplateArgs().NumTemplateArgs; 2512129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall } 2513129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall 2514129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall /// \brief Retrieve the location of the right angle bracket 2515129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall /// following the template arguments ('>'). 2516129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall SourceLocation getRAngleLoc() const { 25177bb12da2b0749eeebb21854c77877736969e59f2John McCall return getExplicitTemplateArgs().RAngleLoc; 2518129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall } 2519129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall 2520129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall virtual SourceRange getSourceRange() const { 25212577743c5650c646fb705df01403707e94f2df04Abramo Bagnara SourceRange Range = getMemberNameInfo().getSourceRange(); 2522aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall if (!isImplicitAccess()) 2523aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall Range.setBegin(Base->getSourceRange().getBegin()); 2524aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall else if (getQualifier()) 2525aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall Range.setBegin(getQualifierRange().getBegin()); 2526aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall 2527129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall if (hasExplicitTemplateArgs()) 2528129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall Range.setEnd(getRAngleLoc()); 2529129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall return Range; 2530129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall } 2531129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall 2532129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall static bool classof(const Stmt *T) { 2533129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall return T->getStmtClass() == UnresolvedMemberExprClass; 2534129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall } 2535129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall static bool classof(const UnresolvedMemberExpr *) { return true; } 2536129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall 2537129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall // Iterators 2538129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall virtual child_iterator child_begin(); 2539129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall virtual child_iterator child_end(); 2540129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall}; 2541129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall 25422e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl/// \brief Represents a C++0x noexcept expression (C++ [expr.unary.noexcept]). 25432e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl/// 25442e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl/// The noexcept expression tests whether a given expression might throw. Its 25452e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl/// result is a boolean constant. 25462e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redlclass CXXNoexceptExpr : public Expr { 25472e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl bool Value : 1; 25482e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl Stmt *Operand; 25492e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl SourceRange Range; 25502e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl 2551c8aecc2dfb2e393d9eeaedeca22ff8cd7149af81Sebastian Redl friend class ASTStmtReader; 2552c8aecc2dfb2e393d9eeaedeca22ff8cd7149af81Sebastian Redl 25532e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redlpublic: 25542e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl CXXNoexceptExpr(QualType Ty, Expr *Operand, CanThrowResult Val, 25552e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl SourceLocation Keyword, SourceLocation RParen) 2556f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall : Expr(CXXNoexceptExprClass, Ty, VK_RValue, OK_Ordinary, 2557f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall /*TypeDependent*/false, 2558bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor /*ValueDependent*/Val == CT_Dependent, 2559bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor Operand->containsUnexpandedParameterPack()), 25606b219d082434394c1ac401390ec1d1967727815aSebastian Redl Value(Val == CT_Cannot), Operand(Operand), Range(Keyword, RParen) 25616b219d082434394c1ac401390ec1d1967727815aSebastian Redl { } 25626b219d082434394c1ac401390ec1d1967727815aSebastian Redl 25636b219d082434394c1ac401390ec1d1967727815aSebastian Redl CXXNoexceptExpr(EmptyShell Empty) 25646b219d082434394c1ac401390ec1d1967727815aSebastian Redl : Expr(CXXNoexceptExprClass, Empty) 25652e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl { } 25662e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl 25672e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl Expr *getOperand() const { return static_cast<Expr*>(Operand); } 25682e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl 25692e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl virtual SourceRange getSourceRange() const { return Range; } 25702e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl 25712e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl bool getValue() const { return Value; } 25722e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl 25732e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl static bool classof(const Stmt *T) { 25742e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl return T->getStmtClass() == CXXNoexceptExprClass; 25752e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl } 25762e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl static bool classof(const CXXNoexceptExpr *) { return true; } 25772e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl 25782e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl // Iterators 25792e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl virtual child_iterator child_begin(); 25802e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl virtual child_iterator child_end(); 25812e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl}; 25822e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl 2583be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor/// \brief Represents a C++0x pack expansion that produces a sequence of 2584be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor/// expressions. 2585be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor/// 2586be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor/// A pack expansion expression contains a pattern (which itself is an 2587be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor/// expression) followed by an ellipsis. For example: 2588be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor/// 2589be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor/// \code 2590be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor/// template<typename F, typename ...Types> 2591be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor/// void forward(F f, Types &&...args) { 2592be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor/// f(static_cast<Types&&>(args)...); 2593be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor/// } 2594be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor/// \endcode 2595be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor/// 2596be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor/// Here, the argument to the function object \c f is a pack expansion whose 2597be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor/// pattern is \c static_cast<Types&&>(args). When the \c forward function 2598be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor/// template is instantiated, the pack expansion will instantiate to zero or 2599be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor/// or more function arguments to the function object \c f. 2600be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregorclass PackExpansionExpr : public Expr { 2601be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor SourceLocation EllipsisLoc; 2602be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor Stmt *Pattern; 2603be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor 2604be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor friend class ASTStmtReader; 2605be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor 2606be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregorpublic: 2607be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor PackExpansionExpr(QualType T, Expr *Pattern, SourceLocation EllipsisLoc) 2608be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor : Expr(PackExpansionExprClass, T, Pattern->getValueKind(), 2609be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor Pattern->getObjectKind(), /*TypeDependent=*/true, 2610be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor /*ValueDependent=*/true, /*ContainsUnexpandedParameterPack=*/false), 2611be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor EllipsisLoc(EllipsisLoc), 2612be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor Pattern(Pattern) { } 2613be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor 2614be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor PackExpansionExpr(EmptyShell Empty) : Expr(PackExpansionExprClass, Empty) { } 2615be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor 2616be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor /// \brief Retrieve the pattern of the pack expansion. 2617be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor Expr *getPattern() { return reinterpret_cast<Expr *>(Pattern); } 2618be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor 2619be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor /// \brief Retrieve the pattern of the pack expansion. 2620be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor const Expr *getPattern() const { return reinterpret_cast<Expr *>(Pattern); } 2621be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor 2622be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor /// \brief Retrieve the location of the ellipsis that describes this pack 2623be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor /// expansion. 2624be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor SourceLocation getEllipsisLoc() const { return EllipsisLoc; } 2625be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor 2626be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor virtual SourceRange getSourceRange() const; 2627be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor 2628be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor static bool classof(const Stmt *T) { 2629be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor return T->getStmtClass() == PackExpansionExprClass; 2630be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor } 2631be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor static bool classof(const PackExpansionExpr *) { return true; } 2632be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor 2633be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor // Iterators 2634be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor virtual child_iterator child_begin(); 2635be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor virtual child_iterator child_end(); 2636be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor}; 2637be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor 26387bb12da2b0749eeebb21854c77877736969e59f2John McCallinline ExplicitTemplateArgumentList &OverloadExpr::getExplicitTemplateArgs() { 26397bb12da2b0749eeebb21854c77877736969e59f2John McCall if (isa<UnresolvedLookupExpr>(this)) 26407bb12da2b0749eeebb21854c77877736969e59f2John McCall return cast<UnresolvedLookupExpr>(this)->getExplicitTemplateArgs(); 26417bb12da2b0749eeebb21854c77877736969e59f2John McCall else 26427bb12da2b0749eeebb21854c77877736969e59f2John McCall return cast<UnresolvedMemberExpr>(this)->getExplicitTemplateArgs(); 26437bb12da2b0749eeebb21854c77877736969e59f2John McCall} 26447bb12da2b0749eeebb21854c77877736969e59f2John McCall 26455f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer} // end namespace clang 26465f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 26475f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer#endif 2648