ExprCXX.h revision 03e80030515c800d1ab44125b9052dfffd1bd04c
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" 18552622067dc45013d240f73952fece703f5e63bdJohn Wiegley#include "clang/Basic/ExpressionTraits.h" 195f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer#include "clang/AST/Expr.h" 20eec51cf1ba5f0e62c9cdb81b5c63babdd6e649abJohn McCall#include "clang/AST/UnresolvedSet.h" 21d5532b6cfff2977e0c59fa6ead7f7973984a620dJohn McCall#include "clang/AST/TemplateBase.h" 225f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 235f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencernamespace clang { 245f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 25aa165f8458b51c546bebff947343e1a36f3594cbDouglas Gregorclass CXXConstructorDecl; 26aa165f8458b51c546bebff947343e1a36f3594cbDouglas Gregorclass CXXDestructorDecl; 27aa165f8458b51c546bebff947343e1a36f3594cbDouglas Gregorclass CXXMethodDecl; 28aa165f8458b51c546bebff947343e1a36f3594cbDouglas Gregorclass CXXTemporary; 29aa165f8458b51c546bebff947343e1a36f3594cbDouglas Gregorclass TemplateArgumentListInfo; 304c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 311060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek//===--------------------------------------------------------------------===// 321060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek// C++ Expressions. 331060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek//===--------------------------------------------------------------------===// 341060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek 353fd95ce225393fe4a3623e429766a8c3f487ff9dDouglas Gregor/// \brief A call to an overloaded operator written using operator 363fd95ce225393fe4a3623e429766a8c3f487ff9dDouglas Gregor/// syntax. 373fd95ce225393fe4a3623e429766a8c3f487ff9dDouglas Gregor/// 383fd95ce225393fe4a3623e429766a8c3f487ff9dDouglas Gregor/// Represents a call to an overloaded operator written using operator 393fd95ce225393fe4a3623e429766a8c3f487ff9dDouglas Gregor/// syntax, e.g., "x + y" or "*p". While semantically equivalent to a 403fd95ce225393fe4a3623e429766a8c3f487ff9dDouglas Gregor/// normal call, this AST node provides better information about the 413fd95ce225393fe4a3623e429766a8c3f487ff9dDouglas Gregor/// syntactic representation of the call. 423fd95ce225393fe4a3623e429766a8c3f487ff9dDouglas Gregor/// 433fd95ce225393fe4a3623e429766a8c3f487ff9dDouglas Gregor/// In a C++ template, this expression node kind will be used whenever 443fd95ce225393fe4a3623e429766a8c3f487ff9dDouglas Gregor/// any of the arguments are type-dependent. In this case, the 453fd95ce225393fe4a3623e429766a8c3f487ff9dDouglas Gregor/// function itself will be a (possibly empty) set of functions and 463fd95ce225393fe4a3623e429766a8c3f487ff9dDouglas Gregor/// function templates that were found by name lookup at template 473fd95ce225393fe4a3623e429766a8c3f487ff9dDouglas Gregor/// definition time. 48b4609806e9232593ece09ce08b630836e825865cDouglas Gregorclass CXXOperatorCallExpr : public CallExpr { 49063daf6e196c51f162e0485478355d8e280eef5cDouglas Gregor /// \brief The overloaded operator. 50063daf6e196c51f162e0485478355d8e280eef5cDouglas Gregor OverloadedOperatorKind Operator; 51063daf6e196c51f162e0485478355d8e280eef5cDouglas Gregor 52b4609806e9232593ece09ce08b630836e825865cDouglas Gregorpublic: 531eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump CXXOperatorCallExpr(ASTContext& C, OverloadedOperatorKind Op, Expr *fn, 541eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump Expr **args, unsigned numargs, QualType t, 55f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall ExprValueKind VK, SourceLocation operatorloc) 56cc324ad80ab940efca006b0064f7ca70a6181816Peter Collingbourne : CallExpr(C, CXXOperatorCallExprClass, fn, 0, args, numargs, t, VK, 57f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall operatorloc), 58063daf6e196c51f162e0485478355d8e280eef5cDouglas Gregor Operator(Op) {} 591eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump explicit CXXOperatorCallExpr(ASTContext& C, EmptyShell Empty) : 60ba0a9006dbc4814e1e35f82812cb5a1dad65e8b8Argyrios Kyrtzidis CallExpr(C, CXXOperatorCallExprClass, Empty) { } 611eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 62b4609806e9232593ece09ce08b630836e825865cDouglas Gregor 63b4609806e9232593ece09ce08b630836e825865cDouglas Gregor /// getOperator - Returns the kind of overloaded operator that this 64b4609806e9232593ece09ce08b630836e825865cDouglas Gregor /// expression refers to. 65063daf6e196c51f162e0485478355d8e280eef5cDouglas Gregor OverloadedOperatorKind getOperator() const { return Operator; } 66ba0a9006dbc4814e1e35f82812cb5a1dad65e8b8Argyrios Kyrtzidis void setOperator(OverloadedOperatorKind Kind) { Operator = Kind; } 67b4609806e9232593ece09ce08b630836e825865cDouglas Gregor 68b4609806e9232593ece09ce08b630836e825865cDouglas Gregor /// getOperatorLoc - Returns the location of the operator symbol in 69b4609806e9232593ece09ce08b630836e825865cDouglas Gregor /// the expression. When @c getOperator()==OO_Call, this is the 70b4609806e9232593ece09ce08b630836e825865cDouglas Gregor /// location of the right parentheses; when @c 71b4609806e9232593ece09ce08b630836e825865cDouglas Gregor /// getOperator()==OO_Subscript, this is the location of the right 72b4609806e9232593ece09ce08b630836e825865cDouglas Gregor /// bracket. 73b4609806e9232593ece09ce08b630836e825865cDouglas Gregor SourceLocation getOperatorLoc() const { return getRParenLoc(); } 74b4609806e9232593ece09ce08b630836e825865cDouglas Gregor 7563c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall SourceRange getSourceRange() const; 761eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 771eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump static bool classof(const Stmt *T) { 781eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump return T->getStmtClass() == CXXOperatorCallExprClass; 79b4609806e9232593ece09ce08b630836e825865cDouglas Gregor } 80b4609806e9232593ece09ce08b630836e825865cDouglas Gregor static bool classof(const CXXOperatorCallExpr *) { return true; } 81b4609806e9232593ece09ce08b630836e825865cDouglas Gregor}; 82b4609806e9232593ece09ce08b630836e825865cDouglas Gregor 8388a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor/// CXXMemberCallExpr - Represents a call to a member function that 8488a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor/// may be written either with member call syntax (e.g., "obj.func()" 8588a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor/// or "objptr->func()") or with normal function-call syntax 8688a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor/// ("func()") within a member function that ends up calling a member 8788a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor/// function. The callee in either case is a MemberExpr that contains 8888a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor/// both the object argument and the member function, while the 8988a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor/// arguments are the arguments within the parentheses (not including 9088a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor/// the object argument). 9188a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregorclass CXXMemberCallExpr : public CallExpr { 9288a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregorpublic: 931817bd483b538fd3f4530649f5cb900bad9e8a76Chris Lattner CXXMemberCallExpr(ASTContext &C, Expr *fn, Expr **args, unsigned numargs, 94f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall QualType t, ExprValueKind VK, SourceLocation RP) 95cc324ad80ab940efca006b0064f7ca70a6181816Peter Collingbourne : CallExpr(C, CXXMemberCallExprClass, fn, 0, args, numargs, t, VK, RP) {} 9688a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor 971817bd483b538fd3f4530649f5cb900bad9e8a76Chris Lattner CXXMemberCallExpr(ASTContext &C, EmptyShell Empty) 981817bd483b538fd3f4530649f5cb900bad9e8a76Chris Lattner : CallExpr(C, CXXMemberCallExprClass, Empty) { } 991817bd483b538fd3f4530649f5cb900bad9e8a76Chris Lattner 10088a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor /// getImplicitObjectArgument - Retrieves the implicit object 10188a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor /// argument for the member call. For example, in "x.f(5)", this 10288a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor /// operation would return "x". 103b277159055933e610bbc80262b600d3ad7e0595cTed Kremenek Expr *getImplicitObjectArgument() const; 104b277159055933e610bbc80262b600d3ad7e0595cTed Kremenek 105b277159055933e610bbc80262b600d3ad7e0595cTed Kremenek /// Retrieves the declaration of the called method. 106b277159055933e610bbc80262b600d3ad7e0595cTed Kremenek CXXMethodDecl *getMethodDecl() const; 10788a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor 108007a9b1c632bfaac20e41c60cbe07fdc6d0e647cChandler Carruth /// getRecordDecl - Retrieves the CXXRecordDecl for the underlying type of 109007a9b1c632bfaac20e41c60cbe07fdc6d0e647cChandler Carruth /// the implicit object argument. Note that this is may not be the same 110007a9b1c632bfaac20e41c60cbe07fdc6d0e647cChandler Carruth /// declaration as that of the class context of the CXXMethodDecl which this 111007a9b1c632bfaac20e41c60cbe07fdc6d0e647cChandler Carruth /// function is calling. 112007a9b1c632bfaac20e41c60cbe07fdc6d0e647cChandler Carruth /// FIXME: Returns 0 for member pointer call exprs. 113007a9b1c632bfaac20e41c60cbe07fdc6d0e647cChandler Carruth CXXRecordDecl *getRecordDecl(); 114007a9b1c632bfaac20e41c60cbe07fdc6d0e647cChandler Carruth 1151eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump static bool classof(const Stmt *T) { 11688a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor return T->getStmtClass() == CXXMemberCallExprClass; 11788a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor } 11888a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor static bool classof(const CXXMemberCallExpr *) { return true; } 11988a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor}; 12088a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor 121e08ce650a2b02410eddd1f60a4aa6b3d4be71e73Peter Collingbourne/// CUDAKernelCallExpr - Represents a call to a CUDA kernel function. 122e08ce650a2b02410eddd1f60a4aa6b3d4be71e73Peter Collingbourneclass CUDAKernelCallExpr : public CallExpr { 123e08ce650a2b02410eddd1f60a4aa6b3d4be71e73Peter Collingbourneprivate: 124e08ce650a2b02410eddd1f60a4aa6b3d4be71e73Peter Collingbourne enum { CONFIG, END_PREARG }; 125e08ce650a2b02410eddd1f60a4aa6b3d4be71e73Peter Collingbourne 126e08ce650a2b02410eddd1f60a4aa6b3d4be71e73Peter Collingbournepublic: 127e08ce650a2b02410eddd1f60a4aa6b3d4be71e73Peter Collingbourne CUDAKernelCallExpr(ASTContext &C, Expr *fn, CallExpr *Config, 128e08ce650a2b02410eddd1f60a4aa6b3d4be71e73Peter Collingbourne Expr **args, unsigned numargs, QualType t, 129e08ce650a2b02410eddd1f60a4aa6b3d4be71e73Peter Collingbourne ExprValueKind VK, SourceLocation RP) 130e08ce650a2b02410eddd1f60a4aa6b3d4be71e73Peter Collingbourne : CallExpr(C, CUDAKernelCallExprClass, fn, END_PREARG, args, numargs, t, VK, 131e08ce650a2b02410eddd1f60a4aa6b3d4be71e73Peter Collingbourne RP) { 132e08ce650a2b02410eddd1f60a4aa6b3d4be71e73Peter Collingbourne setConfig(Config); 133e08ce650a2b02410eddd1f60a4aa6b3d4be71e73Peter Collingbourne } 134e08ce650a2b02410eddd1f60a4aa6b3d4be71e73Peter Collingbourne 135e08ce650a2b02410eddd1f60a4aa6b3d4be71e73Peter Collingbourne CUDAKernelCallExpr(ASTContext &C, EmptyShell Empty) 136e08ce650a2b02410eddd1f60a4aa6b3d4be71e73Peter Collingbourne : CallExpr(C, CUDAKernelCallExprClass, END_PREARG, Empty) { } 137e08ce650a2b02410eddd1f60a4aa6b3d4be71e73Peter Collingbourne 138e08ce650a2b02410eddd1f60a4aa6b3d4be71e73Peter Collingbourne const CallExpr *getConfig() const { 139e08ce650a2b02410eddd1f60a4aa6b3d4be71e73Peter Collingbourne return cast_or_null<CallExpr>(getPreArg(CONFIG)); 140e08ce650a2b02410eddd1f60a4aa6b3d4be71e73Peter Collingbourne } 141e08ce650a2b02410eddd1f60a4aa6b3d4be71e73Peter Collingbourne CallExpr *getConfig() { return cast_or_null<CallExpr>(getPreArg(CONFIG)); } 142e08ce650a2b02410eddd1f60a4aa6b3d4be71e73Peter Collingbourne void setConfig(CallExpr *E) { setPreArg(CONFIG, E); } 143e08ce650a2b02410eddd1f60a4aa6b3d4be71e73Peter Collingbourne 144e08ce650a2b02410eddd1f60a4aa6b3d4be71e73Peter Collingbourne static bool classof(const Stmt *T) { 145e08ce650a2b02410eddd1f60a4aa6b3d4be71e73Peter Collingbourne return T->getStmtClass() == CUDAKernelCallExprClass; 146e08ce650a2b02410eddd1f60a4aa6b3d4be71e73Peter Collingbourne } 147e08ce650a2b02410eddd1f60a4aa6b3d4be71e73Peter Collingbourne static bool classof(const CUDAKernelCallExpr *) { return true; } 148e08ce650a2b02410eddd1f60a4aa6b3d4be71e73Peter Collingbourne}; 149e08ce650a2b02410eddd1f60a4aa6b3d4be71e73Peter Collingbourne 15049badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// CXXNamedCastExpr - Abstract class common to all of the C++ "named" 15149badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// casts, @c static_cast, @c dynamic_cast, @c reinterpret_cast, or @c 15249badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// const_cast. 15349badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// 15449badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// This abstract class is inherited by all of the classes 15549badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// representing "named" casts, e.g., CXXStaticCastExpr, 15649badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// CXXDynamicCastExpr, CXXReinterpretCastExpr, and CXXConstCastExpr. 15749badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregorclass CXXNamedCastExpr : public ExplicitCastExpr { 1581060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenekprivate: 1591060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek SourceLocation Loc; // the location of the casting op 1601d5d0b9df6d2a3df338bc3e63000536406e7666cDouglas Gregor SourceLocation RParenLoc; // the location of the right parenthesis 1611d5d0b9df6d2a3df338bc3e63000536406e7666cDouglas Gregor 16249badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregorprotected: 163f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall CXXNamedCastExpr(StmtClass SC, QualType ty, ExprValueKind VK, 164f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall CastKind kind, Expr *op, unsigned PathSize, 1651d5d0b9df6d2a3df338bc3e63000536406e7666cDouglas Gregor TypeSourceInfo *writtenTy, SourceLocation l, 1661d5d0b9df6d2a3df338bc3e63000536406e7666cDouglas Gregor SourceLocation RParenLoc) 1671d5d0b9df6d2a3df338bc3e63000536406e7666cDouglas Gregor : ExplicitCastExpr(SC, ty, VK, kind, op, PathSize, writtenTy), Loc(l), 1681d5d0b9df6d2a3df338bc3e63000536406e7666cDouglas Gregor RParenLoc(RParenLoc) {} 16949badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor 170f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall explicit CXXNamedCastExpr(StmtClass SC, EmptyShell Shell, unsigned PathSize) 171f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall : ExplicitCastExpr(SC, Shell, PathSize) { } 172ce757a7a1ee905f87551996a69da3e95e8afeeb7Sam Weinig 1731d5d0b9df6d2a3df338bc3e63000536406e7666cDouglas Gregor friend class ASTStmtReader; 1741d5d0b9df6d2a3df338bc3e63000536406e7666cDouglas Gregor 1751060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenekpublic: 17649badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor const char *getCastName() const; 17749badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor 178a3a7b8eea87c90a5a257f685749222b212ddaf36Douglas Gregor /// \brief Retrieve the location of the cast operator keyword, e.g., 179a3a7b8eea87c90a5a257f685749222b212ddaf36Douglas Gregor /// "static_cast". 180a3a7b8eea87c90a5a257f685749222b212ddaf36Douglas Gregor SourceLocation getOperatorLoc() const { return Loc; } 181a3a7b8eea87c90a5a257f685749222b212ddaf36Douglas Gregor 1821d5d0b9df6d2a3df338bc3e63000536406e7666cDouglas Gregor /// \brief Retrieve the location of the closing parenthesis. 1831d5d0b9df6d2a3df338bc3e63000536406e7666cDouglas Gregor SourceLocation getRParenLoc() const { return RParenLoc; } 1841d5d0b9df6d2a3df338bc3e63000536406e7666cDouglas Gregor 18563c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall SourceRange getSourceRange() const { 1861d5d0b9df6d2a3df338bc3e63000536406e7666cDouglas Gregor return SourceRange(Loc, RParenLoc); 1871060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek } 1881eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump static bool classof(const Stmt *T) { 18949badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor switch (T->getStmtClass()) { 19049badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor case CXXStaticCastExprClass: 19149badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor case CXXDynamicCastExprClass: 19249badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor case CXXReinterpretCastExprClass: 19349badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor case CXXConstCastExprClass: 19449badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor return true; 19549badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor default: 19649badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor return false; 19749badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor } 1981060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek } 19949badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor static bool classof(const CXXNamedCastExpr *) { return true; } 20049badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor}; 20149badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor 20249badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// CXXStaticCastExpr - A C++ @c static_cast expression (C++ [expr.static.cast]). 2031eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump/// 20449badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// This expression node represents a C++ static cast, e.g., 20549badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// @c static_cast<int>(1.0). 20649badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregorclass CXXStaticCastExpr : public CXXNamedCastExpr { 207f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall CXXStaticCastExpr(QualType ty, ExprValueKind vk, CastKind kind, Expr *op, 208f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall unsigned pathSize, TypeSourceInfo *writtenTy, 2091d5d0b9df6d2a3df338bc3e63000536406e7666cDouglas Gregor SourceLocation l, SourceLocation RParenLoc) 210f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall : CXXNamedCastExpr(CXXStaticCastExprClass, ty, vk, kind, op, pathSize, 2111d5d0b9df6d2a3df338bc3e63000536406e7666cDouglas Gregor writtenTy, l, RParenLoc) {} 21249badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor 213f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall explicit CXXStaticCastExpr(EmptyShell Empty, unsigned PathSize) 214f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall : CXXNamedCastExpr(CXXStaticCastExprClass, Empty, PathSize) { } 215f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall 216f871d0cc377a1367b519a6cce26be74607566ebaJohn McCallpublic: 217f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall static CXXStaticCastExpr *Create(ASTContext &Context, QualType T, 218f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall ExprValueKind VK, CastKind K, Expr *Op, 219f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall const CXXCastPath *Path, 2201d5d0b9df6d2a3df338bc3e63000536406e7666cDouglas Gregor TypeSourceInfo *Written, SourceLocation L, 2211d5d0b9df6d2a3df338bc3e63000536406e7666cDouglas Gregor SourceLocation RParenLoc); 222f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall static CXXStaticCastExpr *CreateEmpty(ASTContext &Context, 223f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall unsigned PathSize); 224ce757a7a1ee905f87551996a69da3e95e8afeeb7Sam Weinig 2251eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump static bool classof(const Stmt *T) { 22649badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor return T->getStmtClass() == CXXStaticCastExprClass; 22749badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor } 22849badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor static bool classof(const CXXStaticCastExpr *) { return true; } 22949badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor}; 23049badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor 23149badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// CXXDynamicCastExpr - A C++ @c dynamic_cast expression 2321eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump/// (C++ [expr.dynamic.cast]), which may perform a run-time check to 23349badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// determine how to perform the type cast. 2341eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump/// 23549badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// This expression node represents a dynamic cast, e.g., 23649badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// @c dynamic_cast<Derived*>(BasePtr). 23749badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregorclass CXXDynamicCastExpr : public CXXNamedCastExpr { 238f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall CXXDynamicCastExpr(QualType ty, ExprValueKind VK, CastKind kind, 239f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall Expr *op, unsigned pathSize, TypeSourceInfo *writtenTy, 2401d5d0b9df6d2a3df338bc3e63000536406e7666cDouglas Gregor SourceLocation l, SourceLocation RParenLoc) 241f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall : CXXNamedCastExpr(CXXDynamicCastExprClass, ty, VK, kind, op, pathSize, 2421d5d0b9df6d2a3df338bc3e63000536406e7666cDouglas Gregor writtenTy, l, RParenLoc) {} 24349badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor 244f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall explicit CXXDynamicCastExpr(EmptyShell Empty, unsigned pathSize) 245f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall : CXXNamedCastExpr(CXXDynamicCastExprClass, Empty, pathSize) { } 246f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall 247f871d0cc377a1367b519a6cce26be74607566ebaJohn McCallpublic: 248f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall static CXXDynamicCastExpr *Create(ASTContext &Context, QualType T, 249f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall ExprValueKind VK, CastKind Kind, Expr *Op, 250f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall const CXXCastPath *Path, 2511d5d0b9df6d2a3df338bc3e63000536406e7666cDouglas Gregor TypeSourceInfo *Written, SourceLocation L, 2521d5d0b9df6d2a3df338bc3e63000536406e7666cDouglas Gregor SourceLocation RParenLoc); 253f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall 254f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall static CXXDynamicCastExpr *CreateEmpty(ASTContext &Context, 255f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall unsigned pathSize); 256ce757a7a1ee905f87551996a69da3e95e8afeeb7Sam Weinig 2570fee330f5754ca4b248e5bb7363e834668aff06dAnders Carlsson bool isAlwaysNull() const; 2580fee330f5754ca4b248e5bb7363e834668aff06dAnders Carlsson 2591eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump static bool classof(const Stmt *T) { 26049badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor return T->getStmtClass() == CXXDynamicCastExprClass; 26149badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor } 26249badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor static bool classof(const CXXDynamicCastExpr *) { return true; } 26349badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor}; 26449badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor 26549badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// CXXReinterpretCastExpr - A C++ @c reinterpret_cast expression (C++ 26649badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// [expr.reinterpret.cast]), which provides a differently-typed view 26749badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// of a value but performs no actual work at run time. 2681eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump/// 26949badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// This expression node represents a reinterpret cast, e.g., 27049badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// @c reinterpret_cast<int>(VoidPtr). 27149badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregorclass CXXReinterpretCastExpr : public CXXNamedCastExpr { 272f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall CXXReinterpretCastExpr(QualType ty, ExprValueKind vk, CastKind kind, 273f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall Expr *op, unsigned pathSize, 2741d5d0b9df6d2a3df338bc3e63000536406e7666cDouglas Gregor TypeSourceInfo *writtenTy, SourceLocation l, 2751d5d0b9df6d2a3df338bc3e63000536406e7666cDouglas Gregor SourceLocation RParenLoc) 276f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall : CXXNamedCastExpr(CXXReinterpretCastExprClass, ty, vk, kind, op, 2771d5d0b9df6d2a3df338bc3e63000536406e7666cDouglas Gregor pathSize, writtenTy, l, RParenLoc) {} 27849badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor 279f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall CXXReinterpretCastExpr(EmptyShell Empty, unsigned pathSize) 280f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall : CXXNamedCastExpr(CXXReinterpretCastExprClass, Empty, pathSize) { } 281f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall 282f871d0cc377a1367b519a6cce26be74607566ebaJohn McCallpublic: 283f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall static CXXReinterpretCastExpr *Create(ASTContext &Context, QualType T, 284f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall ExprValueKind VK, CastKind Kind, 285f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall Expr *Op, const CXXCastPath *Path, 2861d5d0b9df6d2a3df338bc3e63000536406e7666cDouglas Gregor TypeSourceInfo *WrittenTy, SourceLocation L, 2871d5d0b9df6d2a3df338bc3e63000536406e7666cDouglas Gregor SourceLocation RParenLoc); 288f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall static CXXReinterpretCastExpr *CreateEmpty(ASTContext &Context, 289f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall unsigned pathSize); 290ce757a7a1ee905f87551996a69da3e95e8afeeb7Sam Weinig 2911eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump static bool classof(const Stmt *T) { 29249badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor return T->getStmtClass() == CXXReinterpretCastExprClass; 29349badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor } 29449badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor static bool classof(const CXXReinterpretCastExpr *) { return true; } 29549badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor}; 29649badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor 29749badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// CXXConstCastExpr - A C++ @c const_cast expression (C++ [expr.const.cast]), 29849badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// which can remove type qualifiers but does not change the underlying value. 2991eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump/// 30049badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// This expression node represents a const cast, e.g., 30149badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// @c const_cast<char*>(PtrToConstChar). 30249badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregorclass CXXConstCastExpr : public CXXNamedCastExpr { 303f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall CXXConstCastExpr(QualType ty, ExprValueKind VK, Expr *op, 3041d5d0b9df6d2a3df338bc3e63000536406e7666cDouglas Gregor TypeSourceInfo *writtenTy, SourceLocation l, 3051d5d0b9df6d2a3df338bc3e63000536406e7666cDouglas Gregor SourceLocation RParenLoc) 306f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall : CXXNamedCastExpr(CXXConstCastExprClass, ty, VK, CK_NoOp, op, 3071d5d0b9df6d2a3df338bc3e63000536406e7666cDouglas Gregor 0, writtenTy, l, RParenLoc) {} 30849badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor 309ce757a7a1ee905f87551996a69da3e95e8afeeb7Sam Weinig explicit CXXConstCastExpr(EmptyShell Empty) 310f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall : CXXNamedCastExpr(CXXConstCastExprClass, Empty, 0) { } 311f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall 312f871d0cc377a1367b519a6cce26be74607566ebaJohn McCallpublic: 313f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall static CXXConstCastExpr *Create(ASTContext &Context, QualType T, 314f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall ExprValueKind VK, Expr *Op, 3151d5d0b9df6d2a3df338bc3e63000536406e7666cDouglas Gregor TypeSourceInfo *WrittenTy, SourceLocation L, 3161d5d0b9df6d2a3df338bc3e63000536406e7666cDouglas Gregor SourceLocation RParenLoc); 317f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall static CXXConstCastExpr *CreateEmpty(ASTContext &Context); 318ce757a7a1ee905f87551996a69da3e95e8afeeb7Sam Weinig 3191eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump static bool classof(const Stmt *T) { 32049badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor return T->getStmtClass() == CXXConstCastExprClass; 32149badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor } 32249badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor static bool classof(const CXXConstCastExpr *) { return true; } 3231060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek}; 3241060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek 3251060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek/// CXXBoolLiteralExpr - [C++ 2.13.5] C++ Boolean Literal. 3261eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump/// 3271060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenekclass CXXBoolLiteralExpr : public Expr { 3281060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek bool Value; 3291060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek SourceLocation Loc; 3301060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenekpublic: 3311eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump CXXBoolLiteralExpr(bool val, QualType Ty, SourceLocation l) : 332bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor Expr(CXXBoolLiteralExprClass, Ty, VK_RValue, OK_Ordinary, false, false, 333bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor false), 334f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall Value(val), Loc(l) {} 3358b0b475b3464b0f70b91ba7d679d23c424677d5eSebastian Redl 336eb7f96141f754150a92433286fa385910a22f494Sam Weinig explicit CXXBoolLiteralExpr(EmptyShell Empty) 337eb7f96141f754150a92433286fa385910a22f494Sam Weinig : Expr(CXXBoolLiteralExprClass, Empty) { } 338eb7f96141f754150a92433286fa385910a22f494Sam Weinig 3391060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek bool getValue() const { return Value; } 340eb7f96141f754150a92433286fa385910a22f494Sam Weinig void setValue(bool V) { Value = V; } 3415f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 34263c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall SourceRange getSourceRange() const { return SourceRange(Loc); } 3431eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 344eb7f96141f754150a92433286fa385910a22f494Sam Weinig SourceLocation getLocation() const { return Loc; } 345eb7f96141f754150a92433286fa385910a22f494Sam Weinig void setLocation(SourceLocation L) { Loc = L; } 346eb7f96141f754150a92433286fa385910a22f494Sam Weinig 3471eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump static bool classof(const Stmt *T) { 3481060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek return T->getStmtClass() == CXXBoolLiteralExprClass; 3491060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek } 3501060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek static bool classof(const CXXBoolLiteralExpr *) { return true; } 3511eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 3521060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek // Iterators 35363c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall child_range children() { return child_range(); } 3541060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek}; 3551060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek 3566e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl/// CXXNullPtrLiteralExpr - [C++0x 2.14.7] C++ Pointer Literal 3576e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redlclass CXXNullPtrLiteralExpr : public Expr { 3586e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl SourceLocation Loc; 3596e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redlpublic: 3606e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl CXXNullPtrLiteralExpr(QualType Ty, SourceLocation l) : 361bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor Expr(CXXNullPtrLiteralExprClass, Ty, VK_RValue, OK_Ordinary, false, false, 362bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor false), 363f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall Loc(l) {} 3646e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl 365eb7f96141f754150a92433286fa385910a22f494Sam Weinig explicit CXXNullPtrLiteralExpr(EmptyShell Empty) 366eb7f96141f754150a92433286fa385910a22f494Sam Weinig : Expr(CXXNullPtrLiteralExprClass, Empty) { } 367eb7f96141f754150a92433286fa385910a22f494Sam Weinig 36863c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall SourceRange getSourceRange() const { return SourceRange(Loc); } 3696e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl 370eb7f96141f754150a92433286fa385910a22f494Sam Weinig SourceLocation getLocation() const { return Loc; } 371eb7f96141f754150a92433286fa385910a22f494Sam Weinig void setLocation(SourceLocation L) { Loc = L; } 372eb7f96141f754150a92433286fa385910a22f494Sam Weinig 3736e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl static bool classof(const Stmt *T) { 3746e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl return T->getStmtClass() == CXXNullPtrLiteralExprClass; 3756e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl } 3766e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl static bool classof(const CXXNullPtrLiteralExpr *) { return true; } 3776e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl 37863c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall child_range children() { return child_range(); } 3796e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl}; 3806e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl 381c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl/// CXXTypeidExpr - A C++ @c typeid expression (C++ [expr.typeid]), which gets 382c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl/// the type_info that corresponds to the supplied type, or the (possibly 383c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl/// dynamic) type of the supplied expression. 384c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl/// 385c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl/// This represents code like @c typeid(int) or @c typeid(*objPtr) 386c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redlclass CXXTypeidExpr : public Expr { 387c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redlprivate: 38857fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor llvm::PointerUnion<Stmt *, TypeSourceInfo *> Operand; 389c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl SourceRange Range; 390c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl 391c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redlpublic: 39257fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor CXXTypeidExpr(QualType Ty, TypeSourceInfo *Operand, SourceRange R) 393f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall : Expr(CXXTypeidExprClass, Ty, VK_LValue, OK_Ordinary, 39457fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor // typeid is never type-dependent (C++ [temp.dep.expr]p4) 39557fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor false, 39657fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor // typeid is value-dependent if the type or expression are dependent 397bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor Operand->getType()->isDependentType(), 398bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor Operand->getType()->containsUnexpandedParameterPack()), 39957fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor Operand(Operand), Range(R) { } 40057fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor 40157fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor CXXTypeidExpr(QualType Ty, Expr *Operand, SourceRange R) 402f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall : Expr(CXXTypeidExprClass, Ty, VK_LValue, OK_Ordinary, 4032850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl // typeid is never type-dependent (C++ [temp.dep.expr]p4) 404bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor false, 4052850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl // typeid is value-dependent if the type or expression are dependent 406bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor Operand->isTypeDependent() || Operand->isValueDependent(), 407bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor Operand->containsUnexpandedParameterPack()), 40857fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor Operand(Operand), Range(R) { } 409c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl 41014ab24f01e36d495fce183aa67b41e45cdd54f39Chris Lattner CXXTypeidExpr(EmptyShell Empty, bool isExpr) 41114ab24f01e36d495fce183aa67b41e45cdd54f39Chris Lattner : Expr(CXXTypeidExprClass, Empty) { 41214ab24f01e36d495fce183aa67b41e45cdd54f39Chris Lattner if (isExpr) 41314ab24f01e36d495fce183aa67b41e45cdd54f39Chris Lattner Operand = (Expr*)0; 41414ab24f01e36d495fce183aa67b41e45cdd54f39Chris Lattner else 41514ab24f01e36d495fce183aa67b41e45cdd54f39Chris Lattner Operand = (TypeSourceInfo*)0; 41614ab24f01e36d495fce183aa67b41e45cdd54f39Chris Lattner } 41714ab24f01e36d495fce183aa67b41e45cdd54f39Chris Lattner 41857fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor bool isTypeOperand() const { return Operand.is<TypeSourceInfo *>(); } 41957fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor 42057fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor /// \brief Retrieves the type operand of this typeid() expression after 42157fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor /// various required adjustments (removing reference types, cv-qualifiers). 42257fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor QualType getTypeOperand() const; 42357fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor 42457fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor /// \brief Retrieve source information for the type operand. 42557fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor TypeSourceInfo *getTypeOperandSourceInfo() const { 426c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl assert(isTypeOperand() && "Cannot call getTypeOperand for typeid(expr)"); 42757fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor return Operand.get<TypeSourceInfo *>(); 428c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl } 42914ab24f01e36d495fce183aa67b41e45cdd54f39Chris Lattner 43014ab24f01e36d495fce183aa67b41e45cdd54f39Chris Lattner void setTypeOperandSourceInfo(TypeSourceInfo *TSI) { 43114ab24f01e36d495fce183aa67b41e45cdd54f39Chris Lattner assert(isTypeOperand() && "Cannot call getTypeOperand for typeid(expr)"); 43214ab24f01e36d495fce183aa67b41e45cdd54f39Chris Lattner Operand = TSI; 43314ab24f01e36d495fce183aa67b41e45cdd54f39Chris Lattner } 43457fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor 43514ab24f01e36d495fce183aa67b41e45cdd54f39Chris Lattner Expr *getExprOperand() const { 436c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl assert(!isTypeOperand() && "Cannot call getExprOperand for typeid(type)"); 43757fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor return static_cast<Expr*>(Operand.get<Stmt *>()); 438c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl } 43914ab24f01e36d495fce183aa67b41e45cdd54f39Chris Lattner 440030854b95f7bfd86aaa8afd9ae1aff9768a37e9aChris Lattner void setExprOperand(Expr *E) { 441030854b95f7bfd86aaa8afd9ae1aff9768a37e9aChris Lattner assert(!isTypeOperand() && "Cannot call getExprOperand for typeid(type)"); 442030854b95f7bfd86aaa8afd9ae1aff9768a37e9aChris Lattner Operand = E; 443030854b95f7bfd86aaa8afd9ae1aff9768a37e9aChris Lattner } 444030854b95f7bfd86aaa8afd9ae1aff9768a37e9aChris Lattner 44563c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall SourceRange getSourceRange() const { return Range; } 44614ab24f01e36d495fce183aa67b41e45cdd54f39Chris Lattner void setSourceRange(SourceRange R) { Range = R; } 44714ab24f01e36d495fce183aa67b41e45cdd54f39Chris Lattner 448c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl static bool classof(const Stmt *T) { 449c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl return T->getStmtClass() == CXXTypeidExprClass; 450c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl } 451c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl static bool classof(const CXXTypeidExpr *) { return true; } 452c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl 453c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl // Iterators 45463c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall child_range children() { 45563c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall if (isTypeOperand()) return child_range(); 45663c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall Stmt **begin = reinterpret_cast<Stmt**>(&Operand); 45763c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall return child_range(begin, begin + 1); 45863c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall } 459c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl}; 460c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl 46101b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet/// CXXUuidofExpr - A microsoft C++ @c __uuidof expression, which gets 46201b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet/// the _GUID that corresponds to the supplied type or expression. 46301b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet/// 46401b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet/// This represents code like @c __uuidof(COMTYPE) or @c __uuidof(*comPtr) 46501b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichetclass CXXUuidofExpr : public Expr { 46601b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichetprivate: 46701b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet llvm::PointerUnion<Stmt *, TypeSourceInfo *> Operand; 46801b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet SourceRange Range; 46901b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet 47001b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichetpublic: 47101b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet CXXUuidofExpr(QualType Ty, TypeSourceInfo *Operand, SourceRange R) 4722e219b8d253dbb901206b14e5643cc9d0edd662bFrancois Pichet : Expr(CXXUuidofExprClass, Ty, VK_LValue, OK_Ordinary, 473bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor false, Operand->getType()->isDependentType(), 474bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor Operand->getType()->containsUnexpandedParameterPack()), 47501b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet Operand(Operand), Range(R) { } 47601b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet 47701b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet CXXUuidofExpr(QualType Ty, Expr *Operand, SourceRange R) 4782e219b8d253dbb901206b14e5643cc9d0edd662bFrancois Pichet : Expr(CXXUuidofExprClass, Ty, VK_LValue, OK_Ordinary, 479bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor false, Operand->isTypeDependent(), 480bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor Operand->containsUnexpandedParameterPack()), 48101b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet Operand(Operand), Range(R) { } 48201b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet 48301b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet CXXUuidofExpr(EmptyShell Empty, bool isExpr) 48401b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet : Expr(CXXUuidofExprClass, Empty) { 48501b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet if (isExpr) 48601b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet Operand = (Expr*)0; 48701b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet else 48801b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet Operand = (TypeSourceInfo*)0; 48901b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet } 49001b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet 49101b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet bool isTypeOperand() const { return Operand.is<TypeSourceInfo *>(); } 49201b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet 49301b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet /// \brief Retrieves the type operand of this __uuidof() expression after 49401b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet /// various required adjustments (removing reference types, cv-qualifiers). 49501b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet QualType getTypeOperand() const; 49601b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet 49701b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet /// \brief Retrieve source information for the type operand. 49801b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet TypeSourceInfo *getTypeOperandSourceInfo() const { 49901b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet assert(isTypeOperand() && "Cannot call getTypeOperand for __uuidof(expr)"); 50001b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet return Operand.get<TypeSourceInfo *>(); 50101b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet } 50201b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet 50301b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet void setTypeOperandSourceInfo(TypeSourceInfo *TSI) { 50401b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet assert(isTypeOperand() && "Cannot call getTypeOperand for __uuidof(expr)"); 50501b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet Operand = TSI; 50601b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet } 50701b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet 50801b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet Expr *getExprOperand() const { 50901b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet assert(!isTypeOperand() && "Cannot call getExprOperand for __uuidof(type)"); 51001b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet return static_cast<Expr*>(Operand.get<Stmt *>()); 51101b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet } 51201b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet 51301b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet void setExprOperand(Expr *E) { 51401b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet assert(!isTypeOperand() && "Cannot call getExprOperand for __uuidof(type)"); 51501b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet Operand = E; 51601b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet } 51701b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet 51863c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall SourceRange getSourceRange() const { return Range; } 51901b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet void setSourceRange(SourceRange R) { Range = R; } 52001b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet 52101b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet static bool classof(const Stmt *T) { 52201b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet return T->getStmtClass() == CXXUuidofExprClass; 52301b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet } 52401b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet static bool classof(const CXXUuidofExpr *) { return true; } 52501b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet 52601b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet // Iterators 52763c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall child_range children() { 52863c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall if (isTypeOperand()) return child_range(); 52963c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall Stmt **begin = reinterpret_cast<Stmt**>(&Operand); 53063c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall return child_range(begin, begin + 1); 53163c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall } 53201b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet}; 53301b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet 534796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// CXXThisExpr - Represents the "this" expression in C++, which is a 535796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// pointer to the object on which the current member function is 536796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// executing (C++ [expr.prim]p3). Example: 537796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// 538796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// @code 539796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// class Foo { 540796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// public: 541796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// void bar(); 542796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// void test() { this->bar(); } 543796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// }; 544796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// @endcode 545796da18402f286b897782a298ae3b20c459c102eDouglas Gregorclass CXXThisExpr : public Expr { 546796da18402f286b897782a298ae3b20c459c102eDouglas Gregor SourceLocation Loc; 547828a197317288e3333b0ce6f5cedadd036e3531fDouglas Gregor bool Implicit : 1; 548828a197317288e3333b0ce6f5cedadd036e3531fDouglas Gregor 549796da18402f286b897782a298ae3b20c459c102eDouglas Gregorpublic: 550828a197317288e3333b0ce6f5cedadd036e3531fDouglas Gregor CXXThisExpr(SourceLocation L, QualType Type, bool isImplicit) 551f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall : Expr(CXXThisExprClass, Type, VK_RValue, OK_Ordinary, 5522850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl // 'this' is type-dependent if the class type of the enclosing 5532850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl // member function is dependent (C++ [temp.dep.expr]p2) 554bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor Type->isDependentType(), Type->isDependentType(), 555bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor /*ContainsUnexpandedParameterPack=*/false), 556828a197317288e3333b0ce6f5cedadd036e3531fDouglas Gregor Loc(L), Implicit(isImplicit) { } 557796da18402f286b897782a298ae3b20c459c102eDouglas Gregor 5582fbdfcdf3bbf7b941853d38b123930755e837437Chris Lattner CXXThisExpr(EmptyShell Empty) : Expr(CXXThisExprClass, Empty) {} 5592fbdfcdf3bbf7b941853d38b123930755e837437Chris Lattner 5602fbdfcdf3bbf7b941853d38b123930755e837437Chris Lattner SourceLocation getLocation() const { return Loc; } 5612fbdfcdf3bbf7b941853d38b123930755e837437Chris Lattner void setLocation(SourceLocation L) { Loc = L; } 5622fbdfcdf3bbf7b941853d38b123930755e837437Chris Lattner 56363c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall SourceRange getSourceRange() const { return SourceRange(Loc); } 564796da18402f286b897782a298ae3b20c459c102eDouglas Gregor 565828a197317288e3333b0ce6f5cedadd036e3531fDouglas Gregor bool isImplicit() const { return Implicit; } 566828a197317288e3333b0ce6f5cedadd036e3531fDouglas Gregor void setImplicit(bool I) { Implicit = I; } 567828a197317288e3333b0ce6f5cedadd036e3531fDouglas Gregor 5681eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump static bool classof(const Stmt *T) { 569796da18402f286b897782a298ae3b20c459c102eDouglas Gregor return T->getStmtClass() == CXXThisExprClass; 570796da18402f286b897782a298ae3b20c459c102eDouglas Gregor } 571796da18402f286b897782a298ae3b20c459c102eDouglas Gregor static bool classof(const CXXThisExpr *) { return true; } 572796da18402f286b897782a298ae3b20c459c102eDouglas Gregor 573796da18402f286b897782a298ae3b20c459c102eDouglas Gregor // Iterators 57463c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall child_range children() { return child_range(); } 575796da18402f286b897782a298ae3b20c459c102eDouglas Gregor}; 576796da18402f286b897782a298ae3b20c459c102eDouglas Gregor 5771060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek/// CXXThrowExpr - [C++ 15] C++ Throw Expression. This handles 5781060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek/// 'throw' and 'throw' assignment-expression. When 5791060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek/// assignment-expression isn't present, Op will be null. 5801060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek/// 5811060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenekclass CXXThrowExpr : public Expr { 5821060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek Stmt *Op; 5831060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek SourceLocation ThrowLoc; 5841060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenekpublic: 5851060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek // Ty is the void type which is used as the result type of the 5861060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek // exepression. The l is the location of the throw keyword. expr 5871060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek // can by null, if the optional expression to throw isn't present. 5881060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek CXXThrowExpr(Expr *expr, QualType Ty, SourceLocation l) : 589bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor Expr(CXXThrowExprClass, Ty, VK_RValue, OK_Ordinary, false, false, 590bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor expr && expr->containsUnexpandedParameterPack()), 591f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall Op(expr), ThrowLoc(l) {} 5922fbdfcdf3bbf7b941853d38b123930755e837437Chris Lattner CXXThrowExpr(EmptyShell Empty) : Expr(CXXThrowExprClass, Empty) {} 5932fbdfcdf3bbf7b941853d38b123930755e837437Chris Lattner 5941060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek const Expr *getSubExpr() const { return cast_or_null<Expr>(Op); } 5951060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek Expr *getSubExpr() { return cast_or_null<Expr>(Op); } 59642e5b50f4dc897f252e0d476063a7f9846d96624Douglas Gregor void setSubExpr(Expr *E) { Op = E; } 59742e5b50f4dc897f252e0d476063a7f9846d96624Douglas Gregor 59842e5b50f4dc897f252e0d476063a7f9846d96624Douglas Gregor SourceLocation getThrowLoc() const { return ThrowLoc; } 59942e5b50f4dc897f252e0d476063a7f9846d96624Douglas Gregor void setThrowLoc(SourceLocation L) { ThrowLoc = L; } 6001060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek 60163c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall SourceRange getSourceRange() const { 6021060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek if (getSubExpr() == 0) 6031060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek return SourceRange(ThrowLoc, ThrowLoc); 6041060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek return SourceRange(ThrowLoc, getSubExpr()->getSourceRange().getEnd()); 6051060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek } 6061060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek 6071060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek static bool classof(const Stmt *T) { 6081060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek return T->getStmtClass() == CXXThrowExprClass; 6091060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek } 6101060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek static bool classof(const CXXThrowExpr *) { return true; } 6111060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek 6121060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek // Iterators 61363c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall child_range children() { 61463c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall return child_range(&Op, Op ? &Op+1 : &Op); 61563c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall } 6161060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek}; 6171060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek 6181060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek/// CXXDefaultArgExpr - C++ [dcl.fct.default]. This wraps up a 6191060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek/// function call argument that was created from the corresponding 6201060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek/// parameter's default argument, when the call did not explicitly 6211060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek/// supply arguments for all of the parameters. 6221060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenekclass CXXDefaultArgExpr : public Expr { 62365222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor /// \brief The parameter whose default is being used. 62465222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor /// 62565222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor /// When the bit is set, the subexpression is stored after the 62665222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor /// CXXDefaultArgExpr itself. When the bit is clear, the parameter's 62765222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor /// actual default expression is the subexpression. 62865222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor llvm::PointerIntPair<ParmVarDecl *, 1, bool> Param; 6291eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 630036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor /// \brief The location where the default argument expression was used. 631036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor SourceLocation Loc; 632036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor 633036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor CXXDefaultArgExpr(StmtClass SC, SourceLocation Loc, ParmVarDecl *param) 63465222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor : Expr(SC, 63565222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor param->hasUnparsedDefaultArg() 63665222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor ? param->getType().getNonReferenceType() 6372333f7727f97018d6742e1e0938133bcfad967abEli Friedman : param->getDefaultArg()->getType(), 638dfa1edbebeda7ec3a7a9c45e4317de9241aa9883John McCall param->getDefaultArg()->getValueKind(), 639bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor param->getDefaultArg()->getObjectKind(), false, false, false), 640036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor Param(param, false), Loc(Loc) { } 64165222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor 642036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor CXXDefaultArgExpr(StmtClass SC, SourceLocation Loc, ParmVarDecl *param, 643036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor Expr *SubExpr) 644dfa1edbebeda7ec3a7a9c45e4317de9241aa9883John McCall : Expr(SC, SubExpr->getType(), 645dfa1edbebeda7ec3a7a9c45e4317de9241aa9883John McCall SubExpr->getValueKind(), SubExpr->getObjectKind(), 646bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor false, false, false), 647bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor Param(param, true), Loc(Loc) { 64865222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor *reinterpret_cast<Expr **>(this + 1) = SubExpr; 64965222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor } 65065222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor 6511060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenekpublic: 652030854b95f7bfd86aaa8afd9ae1aff9768a37e9aChris Lattner CXXDefaultArgExpr(EmptyShell Empty) : Expr(CXXDefaultArgExprClass, Empty) {} 653030854b95f7bfd86aaa8afd9ae1aff9768a37e9aChris Lattner 654030854b95f7bfd86aaa8afd9ae1aff9768a37e9aChris Lattner 6551060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek // Param is the parameter whose default argument is used by this 6561060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek // expression. 657036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor static CXXDefaultArgExpr *Create(ASTContext &C, SourceLocation Loc, 658036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor ParmVarDecl *Param) { 659036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor return new (C) CXXDefaultArgExpr(CXXDefaultArgExprClass, Loc, Param); 660f1480eee38b59d15438fb7bc50865ac7c7e22403Anders Carlsson } 6611060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek 66265222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor // Param is the parameter whose default argument is used by this 66365222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor // expression, and SubExpr is the expression that will actually be used. 664036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor static CXXDefaultArgExpr *Create(ASTContext &C, 665036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor SourceLocation Loc, 666036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor ParmVarDecl *Param, 66765222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor Expr *SubExpr); 66865222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor 6691060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek // Retrieve the parameter that the argument was created from. 67065222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor const ParmVarDecl *getParam() const { return Param.getPointer(); } 67165222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor ParmVarDecl *getParam() { return Param.getPointer(); } 672030854b95f7bfd86aaa8afd9ae1aff9768a37e9aChris Lattner 6731060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek // Retrieve the actual argument to the function call. 67465222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor const Expr *getExpr() const { 67565222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor if (Param.getInt()) 67665222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor return *reinterpret_cast<Expr const * const*> (this + 1); 67765222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor return getParam()->getDefaultArg(); 67865222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor } 67965222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor Expr *getExpr() { 68065222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor if (Param.getInt()) 68165222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor return *reinterpret_cast<Expr **> (this + 1); 68265222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor return getParam()->getDefaultArg(); 68365222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor } 6841060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek 685036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor /// \brief Retrieve the location where this default argument was actually 686036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor /// used. 687036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor SourceLocation getUsedLocation() const { return Loc; } 688036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor 68963c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall SourceRange getSourceRange() const { 6901060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek // Default argument expressions have no representation in the 6911060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek // source, so they have an empty source range. 6921060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek return SourceRange(); 6931060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek } 6941060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek 6951060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek static bool classof(const Stmt *T) { 6961060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek return T->getStmtClass() == CXXDefaultArgExprClass; 6971060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek } 6981060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek static bool classof(const CXXDefaultArgExpr *) { return true; } 6991060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek 7001060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek // Iterators 70163c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall child_range children() { return child_range(); } 7028a50733034edd6a349b34e2b9f0c8d0a874846d3Argyrios Kyrtzidis 70360adf4acf40b72227740bf966fb87eebddff3f37Sebastian Redl friend class ASTStmtReader; 7043397c5570369f19b2d6c52e898f708d75ceede1fSebastian Redl friend class ASTStmtWriter; 7051060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek}; 706987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis 707c1ce477119fed070299668aab24084b17ff5f14bAnders Carlsson/// CXXTemporary - Represents a C++ temporary. 708c1ce477119fed070299668aab24084b17ff5f14bAnders Carlssonclass CXXTemporary { 709c1ce477119fed070299668aab24084b17ff5f14bAnders Carlsson /// Destructor - The destructor that needs to be called. 710b859f35459ae3e1188d1e1b86df08d649695fd86Anders Carlsson const CXXDestructorDecl *Destructor; 7111eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 712b859f35459ae3e1188d1e1b86df08d649695fd86Anders Carlsson CXXTemporary(const CXXDestructorDecl *destructor) 713c1ce477119fed070299668aab24084b17ff5f14bAnders Carlsson : Destructor(destructor) { } 714c1ce477119fed070299668aab24084b17ff5f14bAnders Carlsson 715c1ce477119fed070299668aab24084b17ff5f14bAnders Carlssonpublic: 7161eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump static CXXTemporary *Create(ASTContext &C, 717b859f35459ae3e1188d1e1b86df08d649695fd86Anders Carlsson const CXXDestructorDecl *Destructor); 7181eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 719f0721fe438d7e40c168e5d664970e7830bc138fbAnders Carlsson const CXXDestructorDecl *getDestructor() const { return Destructor; } 720c1ce477119fed070299668aab24084b17ff5f14bAnders Carlsson}; 721fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson 722ddfe960d252a93525692b547945236d361d1929fChandler Carruth/// \brief Represents binding an expression to a temporary. 723ddfe960d252a93525692b547945236d361d1929fChandler Carruth/// 724ddfe960d252a93525692b547945236d361d1929fChandler Carruth/// This ensures the destructor is called for the temporary. It should only be 725ddfe960d252a93525692b547945236d361d1929fChandler Carruth/// needed for non-POD, non-trivially destructable class types. For example: 726ddfe960d252a93525692b547945236d361d1929fChandler Carruth/// 727ddfe960d252a93525692b547945236d361d1929fChandler Carruth/// \code 728ddfe960d252a93525692b547945236d361d1929fChandler Carruth/// struct S { 729ddfe960d252a93525692b547945236d361d1929fChandler Carruth/// S() { } // User defined constructor makes S non-POD. 730ddfe960d252a93525692b547945236d361d1929fChandler Carruth/// ~S() { } // User defined destructor makes it non-trivial. 731ddfe960d252a93525692b547945236d361d1929fChandler Carruth/// }; 732ddfe960d252a93525692b547945236d361d1929fChandler Carruth/// void test() { 733ddfe960d252a93525692b547945236d361d1929fChandler Carruth/// const S &s_ref = S(); // Requires a CXXBindTemporaryExpr. 734ddfe960d252a93525692b547945236d361d1929fChandler Carruth/// } 735ddfe960d252a93525692b547945236d361d1929fChandler Carruth/// \endcode 736fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlssonclass CXXBindTemporaryExpr : public Expr { 737fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson CXXTemporary *Temp; 7381eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 739fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson Stmt *SubExpr; 740fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson 741bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor CXXBindTemporaryExpr(CXXTemporary *temp, Expr* SubExpr) 742bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor : Expr(CXXBindTemporaryExprClass, SubExpr->getType(), 743bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor VK_RValue, OK_Ordinary, SubExpr->isTypeDependent(), 744bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor SubExpr->isValueDependent(), 745bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor SubExpr->containsUnexpandedParameterPack()), 746bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor Temp(temp), SubExpr(SubExpr) { } 74788eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlsson 748fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlssonpublic: 749d2598368876cfe40bc8465540033bc5b5e58d8afChris Lattner CXXBindTemporaryExpr(EmptyShell Empty) 750d2598368876cfe40bc8465540033bc5b5e58d8afChris Lattner : Expr(CXXBindTemporaryExprClass, Empty), Temp(0), SubExpr(0) {} 751d2598368876cfe40bc8465540033bc5b5e58d8afChris Lattner 7521eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump static CXXBindTemporaryExpr *Create(ASTContext &C, CXXTemporary *Temp, 753fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson Expr* SubExpr); 7541eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 75588eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlsson CXXTemporary *getTemporary() { return Temp; } 756f0721fe438d7e40c168e5d664970e7830bc138fbAnders Carlsson const CXXTemporary *getTemporary() const { return Temp; } 757d2598368876cfe40bc8465540033bc5b5e58d8afChris Lattner void setTemporary(CXXTemporary *T) { Temp = T; } 758f0721fe438d7e40c168e5d664970e7830bc138fbAnders Carlsson 759fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson const Expr *getSubExpr() const { return cast<Expr>(SubExpr); } 760fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson Expr *getSubExpr() { return cast<Expr>(SubExpr); } 76188eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlsson void setSubExpr(Expr *E) { SubExpr = E; } 762fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson 76363c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall SourceRange getSourceRange() const { 76496be6917e1c4ba1f4435a14c9e7c6c139571d086Douglas Gregor return SubExpr->getSourceRange(); 76596be6917e1c4ba1f4435a14c9e7c6c139571d086Douglas Gregor } 766fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson 767fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson // Implement isa/cast/dyncast/etc. 768fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson static bool classof(const Stmt *T) { 769fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson return T->getStmtClass() == CXXBindTemporaryExprClass; 770fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson } 771fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson static bool classof(const CXXBindTemporaryExpr *) { return true; } 772fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson 773fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson // Iterators 77463c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall child_range children() { return child_range(&SubExpr, &SubExpr + 1); } 775fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson}; 776fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson 77715ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson/// CXXConstructExpr - Represents a call to a C++ constructor. 77815ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlssonclass CXXConstructExpr : public Expr { 77972e96fd181b19b8d01144a685cda6e955584c7eaAnders Carlssonpublic: 78072e96fd181b19b8d01144a685cda6e955584c7eaAnders Carlsson enum ConstructionKind { 78172e96fd181b19b8d01144a685cda6e955584c7eaAnders Carlsson CK_Complete, 78272e96fd181b19b8d01144a685cda6e955584c7eaAnders Carlsson CK_NonVirtualBase, 783059ce0d92eb5a7da900ae735dc0a2ea3d64f4b0bSean Hunt CK_VirtualBase, 784059ce0d92eb5a7da900ae735dc0a2ea3d64f4b0bSean Hunt CK_Delegating 78572e96fd181b19b8d01144a685cda6e955584c7eaAnders Carlsson }; 78672e96fd181b19b8d01144a685cda6e955584c7eaAnders Carlsson 78772e96fd181b19b8d01144a685cda6e955584c7eaAnders Carlssonprivate: 78815ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson CXXConstructorDecl *Constructor; 78915ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson 79099a2e600f9e2e51d3ce10fb6f27191677ac65b2aDouglas Gregor SourceLocation Loc; 791428edafa9eb80e01dd40aab31d4166a787a741e1Chandler Carruth SourceRange ParenRange; 79216006c901315fa12a108b4e571f187f4b676e426Douglas Gregor bool Elidable : 1; 79316006c901315fa12a108b4e571f187f4b676e426Douglas Gregor bool ZeroInitialization : 1; 79472e96fd181b19b8d01144a685cda6e955584c7eaAnders Carlsson unsigned ConstructKind : 2; 79515ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson Stmt **Args; 79615ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson unsigned NumArgs; 7971eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 798bd6734e5f6432ce0cc07171c490ffaa094796198Anders Carlssonprotected: 7991eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump CXXConstructExpr(ASTContext &C, StmtClass SC, QualType T, 80099a2e600f9e2e51d3ce10fb6f27191677ac65b2aDouglas Gregor SourceLocation Loc, 801bd6734e5f6432ce0cc07171c490ffaa094796198Anders Carlsson CXXConstructorDecl *d, bool elidable, 80216006c901315fa12a108b4e571f187f4b676e426Douglas Gregor Expr **args, unsigned numargs, 8039db7dbb918ca49f4ee6c181e4917e7b6ec547353Douglas Gregor bool ZeroInitialization = false, 804428edafa9eb80e01dd40aab31d4166a787a741e1Chandler Carruth ConstructionKind ConstructKind = CK_Complete, 805428edafa9eb80e01dd40aab31d4166a787a741e1Chandler Carruth SourceRange ParenRange = SourceRange()); 806bd6734e5f6432ce0cc07171c490ffaa094796198Anders Carlsson 8076d00c1365dd3601f6d93bbda9162913c57ae788fArgyrios Kyrtzidis /// \brief Construct an empty C++ construction expression. 8086d00c1365dd3601f6d93bbda9162913c57ae788fArgyrios Kyrtzidis CXXConstructExpr(StmtClass SC, EmptyShell Empty) 8096d00c1365dd3601f6d93bbda9162913c57ae788fArgyrios Kyrtzidis : Expr(SC, Empty), Constructor(0), Elidable(0), ZeroInitialization(0), 8106d00c1365dd3601f6d93bbda9162913c57ae788fArgyrios Kyrtzidis ConstructKind(0), Args(0), NumArgs(0) { } 8116d00c1365dd3601f6d93bbda9162913c57ae788fArgyrios Kyrtzidis 81215ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlssonpublic: 8136d00c1365dd3601f6d93bbda9162913c57ae788fArgyrios Kyrtzidis /// \brief Construct an empty C++ construction expression. 8146d00c1365dd3601f6d93bbda9162913c57ae788fArgyrios Kyrtzidis explicit CXXConstructExpr(EmptyShell Empty) 8156d00c1365dd3601f6d93bbda9162913c57ae788fArgyrios Kyrtzidis : Expr(CXXConstructExprClass, Empty), Constructor(0), 8166d00c1365dd3601f6d93bbda9162913c57ae788fArgyrios Kyrtzidis Elidable(0), ZeroInitialization(0), 8176d00c1365dd3601f6d93bbda9162913c57ae788fArgyrios Kyrtzidis ConstructKind(0), Args(0), NumArgs(0) { } 8186d00c1365dd3601f6d93bbda9162913c57ae788fArgyrios Kyrtzidis 8198e587a15da6d3457a418239d5eb4146fcbd209f3Anders Carlsson static CXXConstructExpr *Create(ASTContext &C, QualType T, 82099a2e600f9e2e51d3ce10fb6f27191677ac65b2aDouglas Gregor SourceLocation Loc, 8211eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump CXXConstructorDecl *D, bool Elidable, 82216006c901315fa12a108b4e571f187f4b676e426Douglas Gregor Expr **Args, unsigned NumArgs, 8239db7dbb918ca49f4ee6c181e4917e7b6ec547353Douglas Gregor bool ZeroInitialization = false, 824428edafa9eb80e01dd40aab31d4166a787a741e1Chandler Carruth ConstructionKind ConstructKind = CK_Complete, 825428edafa9eb80e01dd40aab31d4166a787a741e1Chandler Carruth SourceRange ParenRange = SourceRange()); 8261eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 8271eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 828d94546a0a1deef7286c13e49b9584621ae81cc9aDouglas Gregor CXXConstructorDecl* getConstructor() const { return Constructor; } 82939da0b8145eaec7da7004f9b3645c5c9f4f63b1dDouglas Gregor void setConstructor(CXXConstructorDecl *C) { Constructor = C; } 83039da0b8145eaec7da7004f9b3645c5c9f4f63b1dDouglas Gregor 83199a2e600f9e2e51d3ce10fb6f27191677ac65b2aDouglas Gregor SourceLocation getLocation() const { return Loc; } 83299a2e600f9e2e51d3ce10fb6f27191677ac65b2aDouglas Gregor void setLocation(SourceLocation Loc) { this->Loc = Loc; } 83399a2e600f9e2e51d3ce10fb6f27191677ac65b2aDouglas Gregor 834d94546a0a1deef7286c13e49b9584621ae81cc9aDouglas Gregor /// \brief Whether this construction is elidable. 835d94546a0a1deef7286c13e49b9584621ae81cc9aDouglas Gregor bool isElidable() const { return Elidable; } 83639da0b8145eaec7da7004f9b3645c5c9f4f63b1dDouglas Gregor void setElidable(bool E) { Elidable = E; } 83739da0b8145eaec7da7004f9b3645c5c9f4f63b1dDouglas Gregor 83816006c901315fa12a108b4e571f187f4b676e426Douglas Gregor /// \brief Whether this construction first requires 83916006c901315fa12a108b4e571f187f4b676e426Douglas Gregor /// zero-initialization before the initializer is called. 84016006c901315fa12a108b4e571f187f4b676e426Douglas Gregor bool requiresZeroInitialization() const { return ZeroInitialization; } 84116006c901315fa12a108b4e571f187f4b676e426Douglas Gregor void setRequiresZeroInitialization(bool ZeroInit) { 84216006c901315fa12a108b4e571f187f4b676e426Douglas Gregor ZeroInitialization = ZeroInit; 84316006c901315fa12a108b4e571f187f4b676e426Douglas Gregor } 84416006c901315fa12a108b4e571f187f4b676e426Douglas Gregor 8459db7dbb918ca49f4ee6c181e4917e7b6ec547353Douglas Gregor /// \brief Determines whether this constructor is actually constructing 8469db7dbb918ca49f4ee6c181e4917e7b6ec547353Douglas Gregor /// a base class (rather than a complete object). 84724eb78e38aba55c507bc3c05c37035a9ab2defa7Anders Carlsson ConstructionKind getConstructionKind() const { 84824eb78e38aba55c507bc3c05c37035a9ab2defa7Anders Carlsson return (ConstructionKind)ConstructKind; 84972e96fd181b19b8d01144a685cda6e955584c7eaAnders Carlsson } 85072e96fd181b19b8d01144a685cda6e955584c7eaAnders Carlsson void setConstructionKind(ConstructionKind CK) { 85172e96fd181b19b8d01144a685cda6e955584c7eaAnders Carlsson ConstructKind = CK; 85272e96fd181b19b8d01144a685cda6e955584c7eaAnders Carlsson } 8539db7dbb918ca49f4ee6c181e4917e7b6ec547353Douglas Gregor 85415ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson typedef ExprIterator arg_iterator; 85515ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson typedef ConstExprIterator const_arg_iterator; 8561eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 85715ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson arg_iterator arg_begin() { return Args; } 85815ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson arg_iterator arg_end() { return Args + NumArgs; } 85915ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson const_arg_iterator arg_begin() const { return Args; } 86015ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson const_arg_iterator arg_end() const { return Args + NumArgs; } 86115ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson 862a88cfbfac9bbcbb9858f048d6d73a48711d8e93dDouglas Gregor Expr **getArgs() const { return reinterpret_cast<Expr **>(Args); } 86315ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson unsigned getNumArgs() const { return NumArgs; } 86415ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson 865bcb11d01c034f967503bd98f28bdf458c1ab8001Anders Carlsson /// getArg - Return the specified argument. 866bcb11d01c034f967503bd98f28bdf458c1ab8001Anders Carlsson Expr *getArg(unsigned Arg) { 867bcb11d01c034f967503bd98f28bdf458c1ab8001Anders Carlsson assert(Arg < NumArgs && "Arg access out of range!"); 868bcb11d01c034f967503bd98f28bdf458c1ab8001Anders Carlsson return cast<Expr>(Args[Arg]); 869bcb11d01c034f967503bd98f28bdf458c1ab8001Anders Carlsson } 870bcb11d01c034f967503bd98f28bdf458c1ab8001Anders Carlsson const Expr *getArg(unsigned Arg) const { 871bcb11d01c034f967503bd98f28bdf458c1ab8001Anders Carlsson assert(Arg < NumArgs && "Arg access out of range!"); 872bcb11d01c034f967503bd98f28bdf458c1ab8001Anders Carlsson return cast<Expr>(Args[Arg]); 873bcb11d01c034f967503bd98f28bdf458c1ab8001Anders Carlsson } 8741eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 8752eeed7bc4fd457ac57ff32ab3b02674588545f65Fariborz Jahanian /// setArg - Set the specified argument. 8762eeed7bc4fd457ac57ff32ab3b02674588545f65Fariborz Jahanian void setArg(unsigned Arg, Expr *ArgExpr) { 8772eeed7bc4fd457ac57ff32ab3b02674588545f65Fariborz Jahanian assert(Arg < NumArgs && "Arg access out of range!"); 8782eeed7bc4fd457ac57ff32ab3b02674588545f65Fariborz Jahanian Args[Arg] = ArgExpr; 8792eeed7bc4fd457ac57ff32ab3b02674588545f65Fariborz Jahanian } 8802eeed7bc4fd457ac57ff32ab3b02674588545f65Fariborz Jahanian 88163c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall SourceRange getSourceRange() const; 882428edafa9eb80e01dd40aab31d4166a787a741e1Chandler Carruth SourceRange getParenRange() const { return ParenRange; } 88315ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson 8841eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump static bool classof(const Stmt *T) { 885524fa13fd81e88533c7a1d4b1232c0de2c97dc7cAnders Carlsson return T->getStmtClass() == CXXConstructExprClass || 886524fa13fd81e88533c7a1d4b1232c0de2c97dc7cAnders Carlsson T->getStmtClass() == CXXTemporaryObjectExprClass; 88715ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson } 88815ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson static bool classof(const CXXConstructExpr *) { return true; } 8891eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 89015ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson // Iterators 89163c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall child_range children() { 89263c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall return child_range(&Args[0], &Args[0]+NumArgs); 89363c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall } 8946d00c1365dd3601f6d93bbda9162913c57ae788fArgyrios Kyrtzidis 89560adf4acf40b72227740bf966fb87eebddff3f37Sebastian Redl friend class ASTStmtReader; 89615ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson}; 89715ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson 89849badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// CXXFunctionalCastExpr - Represents an explicit C++ type conversion 89949badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// that uses "functional" notion (C++ [expr.type.conv]). Example: @c 90049badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// x = int(0.5); 90149badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregorclass CXXFunctionalCastExpr : public ExplicitCastExpr { 902987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis SourceLocation TyBeginLoc; 903987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis SourceLocation RParenLoc; 904f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall 905f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall CXXFunctionalCastExpr(QualType ty, ExprValueKind VK, 906f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall TypeSourceInfo *writtenTy, 9071eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump SourceLocation tyBeginLoc, CastKind kind, 908f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall Expr *castExpr, unsigned pathSize, 90941b2dcd465f1e438502c420effc9d0c747f9db8fAnders Carlsson SourceLocation rParenLoc) 910f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall : ExplicitCastExpr(CXXFunctionalCastExprClass, ty, VK, kind, 911f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall castExpr, pathSize, writtenTy), 9120aebc81e02397a5987aaa8e8c7acbdb01a31d7c3Anders Carlsson TyBeginLoc(tyBeginLoc), RParenLoc(rParenLoc) {} 9130aebc81e02397a5987aaa8e8c7acbdb01a31d7c3Anders Carlsson 914f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall explicit CXXFunctionalCastExpr(EmptyShell Shell, unsigned PathSize) 915f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall : ExplicitCastExpr(CXXFunctionalCastExprClass, Shell, PathSize) { } 916f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall 917f871d0cc377a1367b519a6cce26be74607566ebaJohn McCallpublic: 918f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall static CXXFunctionalCastExpr *Create(ASTContext &Context, QualType T, 919f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall ExprValueKind VK, 920f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall TypeSourceInfo *Written, 921f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall SourceLocation TyBeginLoc, 922f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall CastKind Kind, Expr *Op, 923f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall const CXXCastPath *Path, 924f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall SourceLocation RPLoc); 925f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall static CXXFunctionalCastExpr *CreateEmpty(ASTContext &Context, 926f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall unsigned PathSize); 927ce757a7a1ee905f87551996a69da3e95e8afeeb7Sam Weinig 928987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis SourceLocation getTypeBeginLoc() const { return TyBeginLoc; } 929ce757a7a1ee905f87551996a69da3e95e8afeeb7Sam Weinig void setTypeBeginLoc(SourceLocation L) { TyBeginLoc = L; } 930987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis SourceLocation getRParenLoc() const { return RParenLoc; } 931ce757a7a1ee905f87551996a69da3e95e8afeeb7Sam Weinig void setRParenLoc(SourceLocation L) { RParenLoc = L; } 9321eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 93363c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall SourceRange getSourceRange() const { 934987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis return SourceRange(TyBeginLoc, RParenLoc); 935987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis } 9361eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump static bool classof(const Stmt *T) { 9371eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump return T->getStmtClass() == CXXFunctionalCastExprClass; 938987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis } 939987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis static bool classof(const CXXFunctionalCastExpr *) { return true; } 940987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis}; 941987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis 942506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// @brief Represents a C++ functional cast expression that builds a 943506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// temporary object. 944506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// 9451eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump/// This expression type represents a C++ "functional" cast 946506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// (C++[expr.type.conv]) with N != 1 arguments that invokes a 947ed8abf18329df67b0abcbb3a10458bd8c1d2a595Douglas Gregor/// constructor to build a temporary object. With N == 1 arguments the 948ed8abf18329df67b0abcbb3a10458bd8c1d2a595Douglas Gregor/// functional cast expression will be represented by CXXFunctionalCastExpr. 949506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// Example: 950506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// @code 951506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// struct X { X(int, float); } 952506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// 953506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// X create_X() { 954506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// return X(1, 3.14f); // creates a CXXTemporaryObjectExpr 955506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// }; 956506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// @endcode 957524fa13fd81e88533c7a1d4b1232c0de2c97dc7cAnders Carlssonclass CXXTemporaryObjectExpr : public CXXConstructExpr { 958ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor TypeSourceInfo *Type; 959506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor 960506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregorpublic: 9611eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump CXXTemporaryObjectExpr(ASTContext &C, CXXConstructorDecl *Cons, 962ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor TypeSourceInfo *Type, 9631eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump Expr **Args,unsigned NumArgs, 964428edafa9eb80e01dd40aab31d4166a787a741e1Chandler Carruth SourceRange parenRange, 9651c63b9c15d48cb8c833a4b2d6fd6c496c0766e88Douglas Gregor bool ZeroInitialization = false); 9666d00c1365dd3601f6d93bbda9162913c57ae788fArgyrios Kyrtzidis explicit CXXTemporaryObjectExpr(EmptyShell Empty) 967ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor : CXXConstructExpr(CXXTemporaryObjectExprClass, Empty), Type() { } 968506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor 969ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor TypeSourceInfo *getTypeSourceInfo() const { return Type; } 970ba49817c5b9f502602672861cf369fd0e53966e8Douglas Gregor 97163c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall SourceRange getSourceRange() const; 972ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor 9731eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump static bool classof(const Stmt *T) { 974506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor return T->getStmtClass() == CXXTemporaryObjectExprClass; 975506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor } 976506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor static bool classof(const CXXTemporaryObjectExpr *) { return true; } 9776d00c1365dd3601f6d93bbda9162913c57ae788fArgyrios Kyrtzidis 97860adf4acf40b72227740bf966fb87eebddff3f37Sebastian Redl friend class ASTStmtReader; 979506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor}; 980506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor 981ed8abf18329df67b0abcbb3a10458bd8c1d2a595Douglas Gregor/// CXXScalarValueInitExpr - [C++ 5.2.3p2] 982506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// Expression "T()" which creates a value-initialized rvalue of type 983ed8abf18329df67b0abcbb3a10458bd8c1d2a595Douglas Gregor/// T, which is a non-class type. 984987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis/// 985ed8abf18329df67b0abcbb3a10458bd8c1d2a595Douglas Gregorclass CXXScalarValueInitExpr : public Expr { 986987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis SourceLocation RParenLoc; 987ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor TypeSourceInfo *TypeInfo; 988987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis 989ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor friend class ASTStmtReader; 990ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor 991987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidispublic: 992ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor /// \brief Create an explicitly-written scalar-value initialization 993ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor /// expression. 994ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor CXXScalarValueInitExpr(QualType Type, 995ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor TypeSourceInfo *TypeInfo, 996ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor SourceLocation rParenLoc ) : 997f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall Expr(CXXScalarValueInitExprClass, Type, VK_RValue, OK_Ordinary, 998bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor false, false, false), 999ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor RParenLoc(rParenLoc), TypeInfo(TypeInfo) {} 1000ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor 1001ed8abf18329df67b0abcbb3a10458bd8c1d2a595Douglas Gregor explicit CXXScalarValueInitExpr(EmptyShell Shell) 1002ed8abf18329df67b0abcbb3a10458bd8c1d2a595Douglas Gregor : Expr(CXXScalarValueInitExprClass, Shell) { } 10031eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1004ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor TypeSourceInfo *getTypeSourceInfo() const { 1005ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor return TypeInfo; 10064c67834407ca6ab344dcf44fc599ad4938cfa96dDouglas Gregor } 1007ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor 1008ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor SourceLocation getRParenLoc() const { return RParenLoc; } 10094c67834407ca6ab344dcf44fc599ad4938cfa96dDouglas Gregor 101063c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall SourceRange getSourceRange() const; 10111eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 10121eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump static bool classof(const Stmt *T) { 1013ed8abf18329df67b0abcbb3a10458bd8c1d2a595Douglas Gregor return T->getStmtClass() == CXXScalarValueInitExprClass; 1014987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis } 1015ed8abf18329df67b0abcbb3a10458bd8c1d2a595Douglas Gregor static bool classof(const CXXScalarValueInitExpr *) { return true; } 10161eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1017987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis // Iterators 101863c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall child_range children() { return child_range(); } 1019987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis}; 1020987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis 10214c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl/// CXXNewExpr - A new expression for memory allocation and constructor calls, 10224c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl/// e.g: "new CXXNewExpr(foo)". 10234c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redlclass CXXNewExpr : public Expr { 10244c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // Was the usage ::new, i.e. is the global new to be used? 10254c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl bool GlobalNew : 1; 10264c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // Is there an initializer? If not, built-ins are uninitialized, else they're 10274c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // value-initialized. 10284c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl bool Initializer : 1; 1029cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl // Do we allocate an array? If so, the first SubExpr is the size expression. 1030cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl bool Array : 1; 10316ec278d1a354517e20f13a877481453ee7940c78John McCall // If this is an array allocation, does the usual deallocation 10326ec278d1a354517e20f13a877481453ee7940c78John McCall // function for the allocated type want to know the allocated size? 10336ec278d1a354517e20f13a877481453ee7940c78John McCall bool UsualArrayDeleteWantsSize : 1; 10344c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // The number of placement new arguments. 10356ec278d1a354517e20f13a877481453ee7940c78John McCall unsigned NumPlacementArgs : 14; 10364c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // The number of constructor arguments. This may be 1 even for non-class 10374c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // types; use the pseudo copy constructor. 1038cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl unsigned NumConstructorArgs : 14; 1039cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl // Contains an optional array size expression, any number of optional 1040cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl // placement arguments, and any number of optional constructor arguments, 1041cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl // in that order. 10424c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl Stmt **SubExprs; 10434c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // Points to the allocation function used. 10444c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl FunctionDecl *OperatorNew; 10454c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // Points to the deallocation function used in case of error. May be null. 10464c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl FunctionDecl *OperatorDelete; 10474c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // Points to the constructor used. Cannot be null if AllocType is a record; 10484c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // it would still point at the default constructor (even an implicit one). 10494c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // Must be null for all other types. 10504c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl CXXConstructorDecl *Constructor; 10514c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 10521bb2a93ab7b1499dda6f6b58865bd0dce1864228Douglas Gregor /// \brief The allocated type-source information, as written in the source. 10531bb2a93ab7b1499dda6f6b58865bd0dce1864228Douglas Gregor TypeSourceInfo *AllocatedTypeInfo; 10541bb2a93ab7b1499dda6f6b58865bd0dce1864228Douglas Gregor 10554bd40318cbea15310a37343db46de96c4fcc15e6Douglas Gregor /// \brief If the allocated type was expressed as a parenthesized type-id, 10564bd40318cbea15310a37343db46de96c4fcc15e6Douglas Gregor /// the source range covering the parenthesized type-id. 10574bd40318cbea15310a37343db46de96c4fcc15e6Douglas Gregor SourceRange TypeIdParens; 10584bd40318cbea15310a37343db46de96c4fcc15e6Douglas Gregor 10594c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl SourceLocation StartLoc; 10604c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl SourceLocation EndLoc; 1061428edafa9eb80e01dd40aab31d4166a787a741e1Chandler Carruth SourceLocation ConstructorLParen; 1062428edafa9eb80e01dd40aab31d4166a787a741e1Chandler Carruth SourceLocation ConstructorRParen; 10634c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 106460adf4acf40b72227740bf966fb87eebddff3f37Sebastian Redl friend class ASTStmtReader; 10654c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redlpublic: 1066ad7fe864862305c2f71e047cdf6706ef43aebdc0Ted Kremenek CXXNewExpr(ASTContext &C, bool globalNew, FunctionDecl *operatorNew, 10674bd40318cbea15310a37343db46de96c4fcc15e6Douglas Gregor Expr **placementArgs, unsigned numPlaceArgs, 10684bd40318cbea15310a37343db46de96c4fcc15e6Douglas Gregor SourceRange TypeIdParens, 1069ad7fe864862305c2f71e047cdf6706ef43aebdc0Ted Kremenek Expr *arraySize, CXXConstructorDecl *constructor, bool initializer, 10704c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl Expr **constructorArgs, unsigned numConsArgs, 10716ec278d1a354517e20f13a877481453ee7940c78John McCall FunctionDecl *operatorDelete, bool usualArrayDeleteWantsSize, 10726ec278d1a354517e20f13a877481453ee7940c78John McCall QualType ty, TypeSourceInfo *AllocatedTypeInfo, 1073428edafa9eb80e01dd40aab31d4166a787a741e1Chandler Carruth SourceLocation startLoc, SourceLocation endLoc, 1074428edafa9eb80e01dd40aab31d4166a787a741e1Chandler Carruth SourceLocation constructorLParen, 1075428edafa9eb80e01dd40aab31d4166a787a741e1Chandler Carruth SourceLocation constructorRParen); 10765921863d8f24084797863b5df37842113bac4352Chris Lattner explicit CXXNewExpr(EmptyShell Shell) 10775921863d8f24084797863b5df37842113bac4352Chris Lattner : Expr(CXXNewExprClass, Shell), SubExprs(0) { } 10785921863d8f24084797863b5df37842113bac4352Chris Lattner 10795921863d8f24084797863b5df37842113bac4352Chris Lattner void AllocateArgsArray(ASTContext &C, bool isArray, unsigned numPlaceArgs, 10805921863d8f24084797863b5df37842113bac4352Chris Lattner unsigned numConsArgs); 1081ad7fe864862305c2f71e047cdf6706ef43aebdc0Ted Kremenek 1082cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl QualType getAllocatedType() const { 1083cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl assert(getType()->isPointerType()); 10846217b80b7a1379b74cced1c076338262c3c980b3Ted Kremenek return getType()->getAs<PointerType>()->getPointeeType(); 1085cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl } 10864c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 10871bb2a93ab7b1499dda6f6b58865bd0dce1864228Douglas Gregor TypeSourceInfo *getAllocatedTypeSourceInfo() const { 10881bb2a93ab7b1499dda6f6b58865bd0dce1864228Douglas Gregor return AllocatedTypeInfo; 10891bb2a93ab7b1499dda6f6b58865bd0dce1864228Douglas Gregor } 1090c2f3e7f42c8bf9e8d4393a6e8c4762dafc4f28ddJohn McCall 1091c2f3e7f42c8bf9e8d4393a6e8c4762dafc4f28ddJohn McCall /// \brief True if the allocation result needs to be null-checked. 1092c2f3e7f42c8bf9e8d4393a6e8c4762dafc4f28ddJohn McCall /// C++0x [expr.new]p13: 1093c2f3e7f42c8bf9e8d4393a6e8c4762dafc4f28ddJohn McCall /// If the allocation function returns null, initialization shall 1094c2f3e7f42c8bf9e8d4393a6e8c4762dafc4f28ddJohn McCall /// not be done, the deallocation function shall not be called, 1095c2f3e7f42c8bf9e8d4393a6e8c4762dafc4f28ddJohn McCall /// and the value of the new-expression shall be null. 1096c2f3e7f42c8bf9e8d4393a6e8c4762dafc4f28ddJohn McCall /// An allocation function is not allowed to return null unless it 1097c2f3e7f42c8bf9e8d4393a6e8c4762dafc4f28ddJohn McCall /// has a non-throwing exception-specification. The '03 rule is 1098c2f3e7f42c8bf9e8d4393a6e8c4762dafc4f28ddJohn McCall /// identical except that the definition of a non-throwing 1099c2f3e7f42c8bf9e8d4393a6e8c4762dafc4f28ddJohn McCall /// exception specification is just "is it throw()?". 11008026f6d82f7fa544bc0453714fe94bca62a1196eSebastian Redl bool shouldNullCheckAllocation(ASTContext &Ctx) const; 11011bb2a93ab7b1499dda6f6b58865bd0dce1864228Douglas Gregor 11024c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl FunctionDecl *getOperatorNew() const { return OperatorNew; } 11035921863d8f24084797863b5df37842113bac4352Chris Lattner void setOperatorNew(FunctionDecl *D) { OperatorNew = D; } 11044c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl FunctionDecl *getOperatorDelete() const { return OperatorDelete; } 11055921863d8f24084797863b5df37842113bac4352Chris Lattner void setOperatorDelete(FunctionDecl *D) { OperatorDelete = D; } 11064c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl CXXConstructorDecl *getConstructor() const { return Constructor; } 11075921863d8f24084797863b5df37842113bac4352Chris Lattner void setConstructor(CXXConstructorDecl *D) { Constructor = D; } 11084c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 1109cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl bool isArray() const { return Array; } 1110cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl Expr *getArraySize() { 1111cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl return Array ? cast<Expr>(SubExprs[0]) : 0; 1112cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl } 1113cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl const Expr *getArraySize() const { 1114cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl return Array ? cast<Expr>(SubExprs[0]) : 0; 1115cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl } 1116cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl 11174c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl unsigned getNumPlacementArgs() const { return NumPlacementArgs; } 1118aa165f8458b51c546bebff947343e1a36f3594cbDouglas Gregor Expr **getPlacementArgs() { 1119aa165f8458b51c546bebff947343e1a36f3594cbDouglas Gregor return reinterpret_cast<Expr **>(SubExprs + Array); 1120aa165f8458b51c546bebff947343e1a36f3594cbDouglas Gregor } 1121aa165f8458b51c546bebff947343e1a36f3594cbDouglas Gregor 11224c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl Expr *getPlacementArg(unsigned i) { 11234c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl assert(i < NumPlacementArgs && "Index out of range"); 1124cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl return cast<Expr>(SubExprs[Array + i]); 11254c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 11264c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl const Expr *getPlacementArg(unsigned i) const { 11274c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl assert(i < NumPlacementArgs && "Index out of range"); 1128cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl return cast<Expr>(SubExprs[Array + i]); 11294c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 11304c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 11314bd40318cbea15310a37343db46de96c4fcc15e6Douglas Gregor bool isParenTypeId() const { return TypeIdParens.isValid(); } 11324bd40318cbea15310a37343db46de96c4fcc15e6Douglas Gregor SourceRange getTypeIdParens() const { return TypeIdParens; } 11334bd40318cbea15310a37343db46de96c4fcc15e6Douglas Gregor 11344c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl bool isGlobalNew() const { return GlobalNew; } 11354c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl bool hasInitializer() const { return Initializer; } 11366ec278d1a354517e20f13a877481453ee7940c78John McCall 11376ec278d1a354517e20f13a877481453ee7940c78John McCall /// Answers whether the usual array deallocation function for the 11386ec278d1a354517e20f13a877481453ee7940c78John McCall /// allocated type expects the size of the allocation as a 11396ec278d1a354517e20f13a877481453ee7940c78John McCall /// parameter. 11406ec278d1a354517e20f13a877481453ee7940c78John McCall bool doesUsualArrayDeleteWantSize() const { 11416ec278d1a354517e20f13a877481453ee7940c78John McCall return UsualArrayDeleteWantsSize; 11426ec278d1a354517e20f13a877481453ee7940c78John McCall } 11434c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 11444c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl unsigned getNumConstructorArgs() const { return NumConstructorArgs; } 1145aa165f8458b51c546bebff947343e1a36f3594cbDouglas Gregor 1146aa165f8458b51c546bebff947343e1a36f3594cbDouglas Gregor Expr **getConstructorArgs() { 1147aa165f8458b51c546bebff947343e1a36f3594cbDouglas Gregor return reinterpret_cast<Expr **>(SubExprs + Array + NumPlacementArgs); 1148aa165f8458b51c546bebff947343e1a36f3594cbDouglas Gregor } 1149aa165f8458b51c546bebff947343e1a36f3594cbDouglas Gregor 11504c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl Expr *getConstructorArg(unsigned i) { 11514c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl assert(i < NumConstructorArgs && "Index out of range"); 1152cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl return cast<Expr>(SubExprs[Array + NumPlacementArgs + i]); 11534c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 11544c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl const Expr *getConstructorArg(unsigned i) const { 11554c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl assert(i < NumConstructorArgs && "Index out of range"); 1156cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl return cast<Expr>(SubExprs[Array + NumPlacementArgs + i]); 11574c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 11584c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 11594c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl typedef ExprIterator arg_iterator; 11604c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl typedef ConstExprIterator const_arg_iterator; 11614c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 11624c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl arg_iterator placement_arg_begin() { 1163cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl return SubExprs + Array; 11644c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 11654c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl arg_iterator placement_arg_end() { 1166cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl return SubExprs + Array + getNumPlacementArgs(); 11674c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 11684c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl const_arg_iterator placement_arg_begin() const { 1169cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl return SubExprs + Array; 11704c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 11714c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl const_arg_iterator placement_arg_end() const { 1172cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl return SubExprs + Array + getNumPlacementArgs(); 11734c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 11744c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 11754c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl arg_iterator constructor_arg_begin() { 1176cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl return SubExprs + Array + getNumPlacementArgs(); 11774c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 11784c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl arg_iterator constructor_arg_end() { 1179cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl return SubExprs + Array + getNumPlacementArgs() + getNumConstructorArgs(); 11804c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 11814c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl const_arg_iterator constructor_arg_begin() const { 1182cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl return SubExprs + Array + getNumPlacementArgs(); 11834c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 11844c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl const_arg_iterator constructor_arg_end() const { 1185cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl return SubExprs + Array + getNumPlacementArgs() + getNumConstructorArgs(); 11864c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 11875921863d8f24084797863b5df37842113bac4352Chris Lattner 11885921863d8f24084797863b5df37842113bac4352Chris Lattner typedef Stmt **raw_arg_iterator; 11895921863d8f24084797863b5df37842113bac4352Chris Lattner raw_arg_iterator raw_arg_begin() { return SubExprs; } 11905921863d8f24084797863b5df37842113bac4352Chris Lattner raw_arg_iterator raw_arg_end() { 11915921863d8f24084797863b5df37842113bac4352Chris Lattner return SubExprs + Array + getNumPlacementArgs() + getNumConstructorArgs(); 11925921863d8f24084797863b5df37842113bac4352Chris Lattner } 11935921863d8f24084797863b5df37842113bac4352Chris Lattner const_arg_iterator raw_arg_begin() const { return SubExprs; } 11945921863d8f24084797863b5df37842113bac4352Chris Lattner const_arg_iterator raw_arg_end() const { return constructor_arg_end(); } 11954c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 11965921863d8f24084797863b5df37842113bac4352Chris Lattner SourceLocation getStartLoc() const { return StartLoc; } 11975921863d8f24084797863b5df37842113bac4352Chris Lattner SourceLocation getEndLoc() const { return EndLoc; } 1198428edafa9eb80e01dd40aab31d4166a787a741e1Chandler Carruth 1199428edafa9eb80e01dd40aab31d4166a787a741e1Chandler Carruth SourceLocation getConstructorLParen() const { return ConstructorLParen; } 1200428edafa9eb80e01dd40aab31d4166a787a741e1Chandler Carruth SourceLocation getConstructorRParen() const { return ConstructorRParen; } 1201428edafa9eb80e01dd40aab31d4166a787a741e1Chandler Carruth 120263c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall SourceRange getSourceRange() const { 12034c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl return SourceRange(StartLoc, EndLoc); 12044c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 12054c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 12064c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl static bool classof(const Stmt *T) { 12074c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl return T->getStmtClass() == CXXNewExprClass; 12084c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 12094c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl static bool classof(const CXXNewExpr *) { return true; } 12104c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 12114c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // Iterators 121263c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall child_range children() { 121363c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall return child_range(&SubExprs[0], 121463c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall &SubExprs[0] + Array + getNumPlacementArgs() 121563c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall + getNumConstructorArgs()); 121663c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall } 12174c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl}; 12184c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 12194c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl/// CXXDeleteExpr - A delete expression for memory deallocation and destructor 12204c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl/// calls, e.g. "delete[] pArray". 12214c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redlclass CXXDeleteExpr : public Expr { 12224c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // Is this a forced global delete, i.e. "::delete"? 12234c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl bool GlobalDelete : 1; 12244c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // Is this the array form of delete, i.e. "delete[]"? 12254c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl bool ArrayForm : 1; 12264076dacf1497fb95cb298b9d964fbdbdaf9bde6cArgyrios Kyrtzidis // ArrayFormAsWritten can be different from ArrayForm if 'delete' is applied 12274076dacf1497fb95cb298b9d964fbdbdaf9bde6cArgyrios Kyrtzidis // to pointer-to-array type (ArrayFormAsWritten will be false while ArrayForm 12284076dacf1497fb95cb298b9d964fbdbdaf9bde6cArgyrios Kyrtzidis // will be true). 12294076dacf1497fb95cb298b9d964fbdbdaf9bde6cArgyrios Kyrtzidis bool ArrayFormAsWritten : 1; 12306ec278d1a354517e20f13a877481453ee7940c78John McCall // Does the usual deallocation function for the element type require 12316ec278d1a354517e20f13a877481453ee7940c78John McCall // a size_t argument? 12326ec278d1a354517e20f13a877481453ee7940c78John McCall bool UsualArrayDeleteWantsSize : 1; 12334c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // Points to the operator delete overload that is used. Could be a member. 12344c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl FunctionDecl *OperatorDelete; 12354c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // The pointer expression to be deleted. 12364c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl Stmt *Argument; 12374c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // Location of the expression. 12384c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl SourceLocation Loc; 12394c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redlpublic: 12404c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl CXXDeleteExpr(QualType ty, bool globalDelete, bool arrayForm, 12416ec278d1a354517e20f13a877481453ee7940c78John McCall bool arrayFormAsWritten, bool usualArrayDeleteWantsSize, 12426ec278d1a354517e20f13a877481453ee7940c78John McCall FunctionDecl *operatorDelete, Expr *arg, SourceLocation loc) 1243bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor : Expr(CXXDeleteExprClass, ty, VK_RValue, OK_Ordinary, false, false, 1244bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor arg->containsUnexpandedParameterPack()), 1245f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall GlobalDelete(globalDelete), 12464076dacf1497fb95cb298b9d964fbdbdaf9bde6cArgyrios Kyrtzidis ArrayForm(arrayForm), ArrayFormAsWritten(arrayFormAsWritten), 12476ec278d1a354517e20f13a877481453ee7940c78John McCall UsualArrayDeleteWantsSize(usualArrayDeleteWantsSize), 12484076dacf1497fb95cb298b9d964fbdbdaf9bde6cArgyrios Kyrtzidis OperatorDelete(operatorDelete), Argument(arg), Loc(loc) { } 124995fc98ce95d4faa4f1bb2783384150530404ea6fArgyrios Kyrtzidis explicit CXXDeleteExpr(EmptyShell Shell) 125095fc98ce95d4faa4f1bb2783384150530404ea6fArgyrios Kyrtzidis : Expr(CXXDeleteExprClass, Shell), OperatorDelete(0), Argument(0) { } 12514c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 12524c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl bool isGlobalDelete() const { return GlobalDelete; } 12534c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl bool isArrayForm() const { return ArrayForm; } 12544076dacf1497fb95cb298b9d964fbdbdaf9bde6cArgyrios Kyrtzidis bool isArrayFormAsWritten() const { return ArrayFormAsWritten; } 12554c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 12566ec278d1a354517e20f13a877481453ee7940c78John McCall /// Answers whether the usual array deallocation function for the 12576ec278d1a354517e20f13a877481453ee7940c78John McCall /// allocated type expects the size of the allocation as a 12586ec278d1a354517e20f13a877481453ee7940c78John McCall /// parameter. This can be true even if the actual deallocation 12596ec278d1a354517e20f13a877481453ee7940c78John McCall /// function that we're using doesn't want a size. 12606ec278d1a354517e20f13a877481453ee7940c78John McCall bool doesUsualArrayDeleteWantSize() const { 12616ec278d1a354517e20f13a877481453ee7940c78John McCall return UsualArrayDeleteWantsSize; 12626ec278d1a354517e20f13a877481453ee7940c78John McCall } 12636ec278d1a354517e20f13a877481453ee7940c78John McCall 12644c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl FunctionDecl *getOperatorDelete() const { return OperatorDelete; } 12654c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 12664c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl Expr *getArgument() { return cast<Expr>(Argument); } 12674c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl const Expr *getArgument() const { return cast<Expr>(Argument); } 12684c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 1269a437ad3ec5b407ede394d74e6f9f463fa3657dbeCraig Silverstein /// \brief Retrieve the type being destroyed. If the type being 1270a437ad3ec5b407ede394d74e6f9f463fa3657dbeCraig Silverstein /// destroyed is a dependent type which may or may not be a pointer, 1271a437ad3ec5b407ede394d74e6f9f463fa3657dbeCraig Silverstein /// return an invalid type. 12725833b0b831d6afae2885e6af420e2bda639652e6Douglas Gregor QualType getDestroyedType() const; 12735833b0b831d6afae2885e6af420e2bda639652e6Douglas Gregor 127463c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall SourceRange getSourceRange() const { 12754c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl return SourceRange(Loc, Argument->getLocEnd()); 12764c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 12774c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 12784c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl static bool classof(const Stmt *T) { 12794c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl return T->getStmtClass() == CXXDeleteExprClass; 12804c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 12814c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl static bool classof(const CXXDeleteExpr *) { return true; } 12824c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 12834c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // Iterators 128463c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall child_range children() { return child_range(&Argument, &Argument+1); } 1285f1b8911d35bb2830a13267581d3cbde4b6b85db6Argyrios Kyrtzidis 1286f1b8911d35bb2830a13267581d3cbde4b6b85db6Argyrios Kyrtzidis friend class ASTStmtReader; 12874c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl}; 12884c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 1289a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor/// \brief Structure used to store the type being destroyed by a 1290a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor/// pseudo-destructor expression. 1291a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregorclass PseudoDestructorTypeStorage { 1292a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor /// \brief Either the type source information or the name of the type, if 1293a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor /// it couldn't be resolved due to type-dependence. 1294a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor llvm::PointerUnion<TypeSourceInfo *, IdentifierInfo *> Type; 1295a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor 1296a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor /// \brief The starting source location of the pseudo-destructor type. 1297a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor SourceLocation Location; 1298a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor 1299a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregorpublic: 1300a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor PseudoDestructorTypeStorage() { } 1301a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor 1302a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor PseudoDestructorTypeStorage(IdentifierInfo *II, SourceLocation Loc) 1303a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor : Type(II), Location(Loc) { } 1304a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor 1305a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor PseudoDestructorTypeStorage(TypeSourceInfo *Info); 1306a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor 1307a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor TypeSourceInfo *getTypeSourceInfo() const { 1308a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor return Type.dyn_cast<TypeSourceInfo *>(); 1309a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor } 1310a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor 1311a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor IdentifierInfo *getIdentifier() const { 1312a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor return Type.dyn_cast<IdentifierInfo *>(); 1313a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor } 1314a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor 1315a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor SourceLocation getLocation() const { return Location; } 1316a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor}; 1317a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor 1318a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor/// \brief Represents a C++ pseudo-destructor (C++ [expr.pseudo]). 1319a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor/// 1320e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor/// A pseudo-destructor is an expression that looks like a member access to a 1321e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor/// destructor of a scalar type, except that scalar types don't have 1322e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor/// destructors. For example: 1323e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor/// 1324e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor/// \code 1325e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor/// typedef int T; 1326e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor/// void f(int *p) { 1327e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor/// p->T::~T(); 1328e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor/// } 1329e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor/// \endcode 1330a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor/// 1331e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor/// Pseudo-destructors typically occur when instantiating templates such as: 1332e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor/// 1333a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor/// \code 13341eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump/// template<typename T> 1335a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor/// void destroy(T* ptr) { 1336e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor/// ptr->T::~T(); 1337a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor/// } 1338a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor/// \endcode 1339a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor/// 1340e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor/// for scalar types. A pseudo-destructor expression has no run-time semantics 1341e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor/// beyond evaluating the base expression. 1342a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregorclass CXXPseudoDestructorExpr : public Expr { 1343a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor /// \brief The base expression (that is being destroyed). 1344a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor Stmt *Base; 13451eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1346a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor /// \brief Whether the operator was an arrow ('->'); otherwise, it was a 1347a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor /// period ('.'). 1348a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor bool IsArrow : 1; 13491eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1350a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor /// \brief The location of the '.' or '->' operator. 1351a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor SourceLocation OperatorLoc; 1352f3db29fff6a583ecda823cf909ab7737d8d30129Douglas Gregor 1353a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor /// \brief The nested-name-specifier that follows the operator, if present. 1354f3db29fff6a583ecda823cf909ab7737d8d30129Douglas Gregor NestedNameSpecifierLoc QualifierLoc; 13551eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1356e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor /// \brief The type that precedes the '::' in a qualified pseudo-destructor 1357e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor /// expression. 1358e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor TypeSourceInfo *ScopeType; 1359e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor 1360e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor /// \brief The location of the '::' in a qualified pseudo-destructor 1361e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor /// expression. 1362e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor SourceLocation ColonColonLoc; 1363e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor 1364fce46ee68f779e239826e69e45d01d4c8e5323caDouglas Gregor /// \brief The location of the '~'. 1365fce46ee68f779e239826e69e45d01d4c8e5323caDouglas Gregor SourceLocation TildeLoc; 1366fce46ee68f779e239826e69e45d01d4c8e5323caDouglas Gregor 1367a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor /// \brief The type being destroyed, or its name if we were unable to 1368a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor /// resolve the name. 1369a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor PseudoDestructorTypeStorage DestroyedType; 13701eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1371f3db29fff6a583ecda823cf909ab7737d8d30129Douglas Gregor friend class ASTStmtReader; 1372f3db29fff6a583ecda823cf909ab7737d8d30129Douglas Gregor 1373a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregorpublic: 1374a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor CXXPseudoDestructorExpr(ASTContext &Context, 1375a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor Expr *Base, bool isArrow, SourceLocation OperatorLoc, 1376f3db29fff6a583ecda823cf909ab7737d8d30129Douglas Gregor NestedNameSpecifierLoc QualifierLoc, 1377e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor TypeSourceInfo *ScopeType, 1378e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor SourceLocation ColonColonLoc, 1379fce46ee68f779e239826e69e45d01d4c8e5323caDouglas Gregor SourceLocation TildeLoc, 1380e23cf437fe76b1ed02d63c3f61b456fd48a915f5John McCall PseudoDestructorTypeStorage DestroyedType); 13811eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1382de4bd18bb45a1db68996cfb949db3015fc25d10dArgyrios Kyrtzidis explicit CXXPseudoDestructorExpr(EmptyShell Shell) 1383de4bd18bb45a1db68996cfb949db3015fc25d10dArgyrios Kyrtzidis : Expr(CXXPseudoDestructorExprClass, Shell), 1384f3db29fff6a583ecda823cf909ab7737d8d30129Douglas Gregor Base(0), IsArrow(false), QualifierLoc(), ScopeType(0) { } 1385de4bd18bb45a1db68996cfb949db3015fc25d10dArgyrios Kyrtzidis 1386a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor Expr *getBase() const { return cast<Expr>(Base); } 13871eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 13881eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump /// \brief Determines whether this member expression actually had 1389a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor /// a C++ nested-name-specifier prior to the name of the member, e.g., 1390a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor /// x->Base::foo. 1391f3db29fff6a583ecda823cf909ab7737d8d30129Douglas Gregor bool hasQualifier() const { return QualifierLoc; } 13921eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1393f3db29fff6a583ecda823cf909ab7737d8d30129Douglas Gregor /// \brief Retrieves the nested-name-specifier that qualifies the type name, 1394f3db29fff6a583ecda823cf909ab7737d8d30129Douglas Gregor /// with source-location information. 1395f3db29fff6a583ecda823cf909ab7737d8d30129Douglas Gregor NestedNameSpecifierLoc getQualifierLoc() const { return QualifierLoc; } 1396f3db29fff6a583ecda823cf909ab7737d8d30129Douglas Gregor 13971eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump /// \brief If the member name was qualified, retrieves the 1398a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor /// nested-name-specifier that precedes the member name. Otherwise, returns 1399a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor /// NULL. 1400f3db29fff6a583ecda823cf909ab7737d8d30129Douglas Gregor NestedNameSpecifier *getQualifier() const { 1401f3db29fff6a583ecda823cf909ab7737d8d30129Douglas Gregor return QualifierLoc.getNestedNameSpecifier(); 1402f3db29fff6a583ecda823cf909ab7737d8d30129Douglas Gregor } 14031eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1404a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor /// \brief Determine whether this pseudo-destructor expression was written 1405a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor /// using an '->' (otherwise, it used a '.'). 1406a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor bool isArrow() const { return IsArrow; } 1407a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor 1408a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor /// \brief Retrieve the location of the '.' or '->' operator. 1409a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor SourceLocation getOperatorLoc() const { return OperatorLoc; } 14101eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1411e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor /// \brief Retrieve the scope type in a qualified pseudo-destructor 1412e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor /// expression. 1413e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor /// 1414e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor /// Pseudo-destructor expressions can have extra qualification within them 1415e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor /// that is not part of the nested-name-specifier, e.g., \c p->T::~T(). 1416e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor /// Here, if the object type of the expression is (or may be) a scalar type, 1417e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor /// \p T may also be a scalar type and, therefore, cannot be part of a 1418e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor /// nested-name-specifier. It is stored as the "scope type" of the pseudo- 1419e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor /// destructor expression. 142026d4ac97fb514bb60c2536eae6f203dc569159d9Douglas Gregor TypeSourceInfo *getScopeTypeInfo() const { return ScopeType; } 1421e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor 1422e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor /// \brief Retrieve the location of the '::' in a qualified pseudo-destructor 1423e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor /// expression. 1424e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor SourceLocation getColonColonLoc() const { return ColonColonLoc; } 1425e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor 1426fce46ee68f779e239826e69e45d01d4c8e5323caDouglas Gregor /// \brief Retrieve the location of the '~'. 1427fce46ee68f779e239826e69e45d01d4c8e5323caDouglas Gregor SourceLocation getTildeLoc() const { return TildeLoc; } 1428fce46ee68f779e239826e69e45d01d4c8e5323caDouglas Gregor 142926d4ac97fb514bb60c2536eae6f203dc569159d9Douglas Gregor /// \brief Retrieve the source location information for the type 143026d4ac97fb514bb60c2536eae6f203dc569159d9Douglas Gregor /// being destroyed. 1431a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor /// 1432a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor /// This type-source information is available for non-dependent 1433a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor /// pseudo-destructor expressions and some dependent pseudo-destructor 1434a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor /// expressions. Returns NULL if we only have the identifier for a 1435a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor /// dependent pseudo-destructor expression. 1436a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor TypeSourceInfo *getDestroyedTypeInfo() const { 1437a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor return DestroyedType.getTypeSourceInfo(); 1438a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor } 1439a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor 1440a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor /// \brief In a dependent pseudo-destructor expression for which we do not 1441a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor /// have full type information on the destroyed type, provides the name 1442a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor /// of the destroyed type. 1443a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor IdentifierInfo *getDestroyedTypeIdentifier() const { 1444a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor return DestroyedType.getIdentifier(); 1445a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor } 1446a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor 1447a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor /// \brief Retrieve the type being destroyed. 1448a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor QualType getDestroyedType() const; 1449a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor 1450a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor /// \brief Retrieve the starting location of the type being destroyed. 1451a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor SourceLocation getDestroyedTypeLoc() const { 1452a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor return DestroyedType.getLocation(); 1453a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor } 14541eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1455de4bd18bb45a1db68996cfb949db3015fc25d10dArgyrios Kyrtzidis /// \brief Set the name of destroyed type for a dependent pseudo-destructor 1456de4bd18bb45a1db68996cfb949db3015fc25d10dArgyrios Kyrtzidis /// expression. 1457de4bd18bb45a1db68996cfb949db3015fc25d10dArgyrios Kyrtzidis void setDestroyedType(IdentifierInfo *II, SourceLocation Loc) { 1458de4bd18bb45a1db68996cfb949db3015fc25d10dArgyrios Kyrtzidis DestroyedType = PseudoDestructorTypeStorage(II, Loc); 1459de4bd18bb45a1db68996cfb949db3015fc25d10dArgyrios Kyrtzidis } 1460de4bd18bb45a1db68996cfb949db3015fc25d10dArgyrios Kyrtzidis 1461de4bd18bb45a1db68996cfb949db3015fc25d10dArgyrios Kyrtzidis /// \brief Set the destroyed type. 1462de4bd18bb45a1db68996cfb949db3015fc25d10dArgyrios Kyrtzidis void setDestroyedType(TypeSourceInfo *Info) { 1463de4bd18bb45a1db68996cfb949db3015fc25d10dArgyrios Kyrtzidis DestroyedType = PseudoDestructorTypeStorage(Info); 1464de4bd18bb45a1db68996cfb949db3015fc25d10dArgyrios Kyrtzidis } 1465de4bd18bb45a1db68996cfb949db3015fc25d10dArgyrios Kyrtzidis 146663c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall SourceRange getSourceRange() const; 14671eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 14681eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump static bool classof(const Stmt *T) { 1469a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor return T->getStmtClass() == CXXPseudoDestructorExprClass; 1470a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor } 1471a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor static bool classof(const CXXPseudoDestructorExpr *) { return true; } 14721eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1473a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor // Iterators 147463c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall child_range children() { return child_range(&Base, &Base + 1); } 1475a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor}; 14761eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 147764b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl/// UnaryTypeTraitExpr - A GCC or MS unary type trait, as used in the 147864b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl/// implementation of TR1/C++0x type trait templates. 147964b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl/// Example: 148064b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl/// __is_pod(int) == true 148164b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl/// __is_enum(std::string) == false 148264b45f7e0d3167f040841ac2920aead7f080730dSebastian Redlclass UnaryTypeTraitExpr : public Expr { 14830dfd848fa4c9664852ba8c929a8bd3fce93ddca2Sebastian Redl /// UTT - The trait. A UnaryTypeTrait enum in MSVC compat unsigned. 14840dfd848fa4c9664852ba8c929a8bd3fce93ddca2Sebastian Redl unsigned UTT : 31; 14850dfd848fa4c9664852ba8c929a8bd3fce93ddca2Sebastian Redl /// The value of the type trait. Unspecified if dependent. 14860dfd848fa4c9664852ba8c929a8bd3fce93ddca2Sebastian Redl bool Value : 1; 148764b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl 148864b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl /// Loc - The location of the type trait keyword. 148964b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl SourceLocation Loc; 149064b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl 149164b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl /// RParen - The location of the closing paren. 149264b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl SourceLocation RParen; 149364b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl 14940dfd848fa4c9664852ba8c929a8bd3fce93ddca2Sebastian Redl /// The type being queried. 14953d37c0ada0e46b87be0a10e8d52d990a97d3907aDouglas Gregor TypeSourceInfo *QueriedType; 149664b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl 149764b45f7e0d3167f040841ac2920aead7f080730dSebastian Redlpublic: 14983d37c0ada0e46b87be0a10e8d52d990a97d3907aDouglas Gregor UnaryTypeTraitExpr(SourceLocation loc, UnaryTypeTrait utt, 14990dfd848fa4c9664852ba8c929a8bd3fce93ddca2Sebastian Redl TypeSourceInfo *queried, bool value, 150064b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl SourceLocation rparen, QualType ty) 1501f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall : Expr(UnaryTypeTraitExprClass, ty, VK_RValue, OK_Ordinary, 1502bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor false, queried->getType()->isDependentType(), 1503bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor queried->getType()->containsUnexpandedParameterPack()), 15040dfd848fa4c9664852ba8c929a8bd3fce93ddca2Sebastian Redl UTT(utt), Value(value), Loc(loc), RParen(rparen), QueriedType(queried) { } 150564b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl 15066d00c1365dd3601f6d93bbda9162913c57ae788fArgyrios Kyrtzidis explicit UnaryTypeTraitExpr(EmptyShell Empty) 15070dfd848fa4c9664852ba8c929a8bd3fce93ddca2Sebastian Redl : Expr(UnaryTypeTraitExprClass, Empty), UTT(0), Value(false), 15083d37c0ada0e46b87be0a10e8d52d990a97d3907aDouglas Gregor QueriedType() { } 15096d00c1365dd3601f6d93bbda9162913c57ae788fArgyrios Kyrtzidis 151063c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall SourceRange getSourceRange() const { return SourceRange(Loc, RParen);} 151164b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl 15120dfd848fa4c9664852ba8c929a8bd3fce93ddca2Sebastian Redl UnaryTypeTrait getTrait() const { return static_cast<UnaryTypeTrait>(UTT); } 151364b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl 15143d37c0ada0e46b87be0a10e8d52d990a97d3907aDouglas Gregor QualType getQueriedType() const { return QueriedType->getType(); } 151564b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl 15163d37c0ada0e46b87be0a10e8d52d990a97d3907aDouglas Gregor TypeSourceInfo *getQueriedTypeSourceInfo() const { return QueriedType; } 15173d37c0ada0e46b87be0a10e8d52d990a97d3907aDouglas Gregor 15180dfd848fa4c9664852ba8c929a8bd3fce93ddca2Sebastian Redl bool getValue() const { return Value; } 151964b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl 152064b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl static bool classof(const Stmt *T) { 152164b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl return T->getStmtClass() == UnaryTypeTraitExprClass; 152264b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl } 152364b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl static bool classof(const UnaryTypeTraitExpr *) { return true; } 152464b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl 152564b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl // Iterators 152663c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall child_range children() { return child_range(); } 15276d00c1365dd3601f6d93bbda9162913c57ae788fArgyrios Kyrtzidis 152860adf4acf40b72227740bf966fb87eebddff3f37Sebastian Redl friend class ASTStmtReader; 152964b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl}; 153064b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl 15316ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet/// BinaryTypeTraitExpr - A GCC or MS binary type trait, as used in the 15326ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet/// implementation of TR1/C++0x type trait templates. 15336ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet/// Example: 15346ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet/// __is_base_of(Base, Derived) == true 15356ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichetclass BinaryTypeTraitExpr : public Expr { 15366ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet /// BTT - The trait. A BinaryTypeTrait enum in MSVC compat unsigned. 15376ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet unsigned BTT : 8; 15386ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet 15396ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet /// The value of the type trait. Unspecified if dependent. 15406ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet bool Value : 1; 15416ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet 15426ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet /// Loc - The location of the type trait keyword. 15436ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet SourceLocation Loc; 15446ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet 15456ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet /// RParen - The location of the closing paren. 15466ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet SourceLocation RParen; 15476ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet 15486ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet /// The lhs type being queried. 15496ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet TypeSourceInfo *LhsType; 15506ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet 15516ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet /// The rhs type being queried. 15526ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet TypeSourceInfo *RhsType; 15536ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet 15546ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichetpublic: 15556ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet BinaryTypeTraitExpr(SourceLocation loc, BinaryTypeTrait btt, 15566ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet TypeSourceInfo *lhsType, TypeSourceInfo *rhsType, 15576ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet bool value, SourceLocation rparen, QualType ty) 15586ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet : Expr(BinaryTypeTraitExprClass, ty, VK_RValue, OK_Ordinary, false, 15596ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet lhsType->getType()->isDependentType() || 1560bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor rhsType->getType()->isDependentType(), 1561bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor (lhsType->getType()->containsUnexpandedParameterPack() || 1562bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor rhsType->getType()->containsUnexpandedParameterPack())), 15636ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet BTT(btt), Value(value), Loc(loc), RParen(rparen), 15646ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet LhsType(lhsType), RhsType(rhsType) { } 15656ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet 15666ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet 15676ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet explicit BinaryTypeTraitExpr(EmptyShell Empty) 15686ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet : Expr(BinaryTypeTraitExprClass, Empty), BTT(0), Value(false), 1569f187237d916afa97c491ac32fe98be7d335c5b63Francois Pichet LhsType(), RhsType() { } 15706ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet 157163c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall SourceRange getSourceRange() const { 15726ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet return SourceRange(Loc, RParen); 15736ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet } 15746ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet 15756ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet BinaryTypeTrait getTrait() const { 15766ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet return static_cast<BinaryTypeTrait>(BTT); 15776ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet } 15786ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet 15796ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet QualType getLhsType() const { return LhsType->getType(); } 15806ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet QualType getRhsType() const { return RhsType->getType(); } 15816ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet 15826ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet TypeSourceInfo *getLhsTypeSourceInfo() const { return LhsType; } 15836ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet TypeSourceInfo *getRhsTypeSourceInfo() const { return RhsType; } 15846ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet 15856ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet bool getValue() const { assert(!isTypeDependent()); return Value; } 15866ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet 15876ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet static bool classof(const Stmt *T) { 15886ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet return T->getStmtClass() == BinaryTypeTraitExprClass; 15896ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet } 15906ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet static bool classof(const BinaryTypeTraitExpr *) { return true; } 15916ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet 15926ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet // Iterators 159363c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall child_range children() { return child_range(); } 15946ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet 15956ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet friend class ASTStmtReader; 15966ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet}; 15976ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet 159821ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley/// ArrayTypeTraitExpr - An Embarcadero array type trait, as used in the 159921ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley/// implementation of __array_rank and __array_extent. 160021ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley/// Example: 160121ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley/// __array_rank(int[10][20]) == 2 160221ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley/// __array_extent(int, 1) == 20 160321ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegleyclass ArrayTypeTraitExpr : public Expr { 160421ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley /// ATT - The trait. An ArrayTypeTrait enum in MSVC compat unsigned. 160521ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley unsigned ATT : 2; 160621ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley 160721ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley /// The value of the type trait. Unspecified if dependent. 160821ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley uint64_t Value; 160921ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley 161021ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley /// The array dimension being queried, or -1 if not used 161121ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley Expr *Dimension; 161221ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley 161321ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley /// Loc - The location of the type trait keyword. 161421ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley SourceLocation Loc; 161521ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley 161621ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley /// RParen - The location of the closing paren. 161721ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley SourceLocation RParen; 161821ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley 161921ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley /// The type being queried. 162021ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley TypeSourceInfo *QueriedType; 162121ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley 162221ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegleypublic: 162321ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley ArrayTypeTraitExpr(SourceLocation loc, ArrayTypeTrait att, 162421ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley TypeSourceInfo *queried, uint64_t value, 162521ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley Expr *dimension, SourceLocation rparen, QualType ty) 162621ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley : Expr(ArrayTypeTraitExprClass, ty, VK_RValue, OK_Ordinary, 162721ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley false, queried->getType()->isDependentType(), 162821ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley queried->getType()->containsUnexpandedParameterPack()), 162921ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley ATT(att), Value(value), Dimension(dimension), 163021ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley Loc(loc), RParen(rparen), QueriedType(queried) { } 163121ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley 163221ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley 163321ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley explicit ArrayTypeTraitExpr(EmptyShell Empty) 163421ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley : Expr(ArrayTypeTraitExprClass, Empty), ATT(0), Value(false), 163521ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley QueriedType() { } 163621ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley 163725aaf28c5bec71d5d005df67ee78b908ba5940f4Manuel Klimek virtual ~ArrayTypeTraitExpr() { } 163825aaf28c5bec71d5d005df67ee78b908ba5940f4Manuel Klimek 163921ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley virtual SourceRange getSourceRange() const { return SourceRange(Loc, RParen); } 164021ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley 164121ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley ArrayTypeTrait getTrait() const { return static_cast<ArrayTypeTrait>(ATT); } 164221ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley 164321ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley QualType getQueriedType() const { return QueriedType->getType(); } 164421ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley 164521ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley TypeSourceInfo *getQueriedTypeSourceInfo() const { return QueriedType; } 164621ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley 164721ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley uint64_t getValue() const { assert(!isTypeDependent()); return Value; } 164821ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley 164921ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley Expr *getDimensionExpression() const { return Dimension; } 165021ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley 165121ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley static bool classof(const Stmt *T) { 165221ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley return T->getStmtClass() == ArrayTypeTraitExprClass; 165321ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley } 165421ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley static bool classof(const ArrayTypeTraitExpr *) { return true; } 165521ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley 165621ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley // Iterators 165721ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley child_range children() { return child_range(); } 165821ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley 165921ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley friend class ASTStmtReader; 166021ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley}; 166121ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley 1662552622067dc45013d240f73952fece703f5e63bdJohn Wiegley/// ExpressionTraitExpr - An expression trait intrinsic 1663552622067dc45013d240f73952fece703f5e63bdJohn Wiegley/// Example: 1664552622067dc45013d240f73952fece703f5e63bdJohn Wiegley/// __is_lvalue_expr(std::cout) == true 1665552622067dc45013d240f73952fece703f5e63bdJohn Wiegley/// __is_lvalue_expr(1) == false 1666552622067dc45013d240f73952fece703f5e63bdJohn Wiegleyclass ExpressionTraitExpr : public Expr { 1667552622067dc45013d240f73952fece703f5e63bdJohn Wiegley /// ET - The trait. A ExpressionTrait enum in MSVC compat unsigned. 1668552622067dc45013d240f73952fece703f5e63bdJohn Wiegley unsigned ET : 31; 1669552622067dc45013d240f73952fece703f5e63bdJohn Wiegley /// The value of the type trait. Unspecified if dependent. 1670552622067dc45013d240f73952fece703f5e63bdJohn Wiegley bool Value : 1; 1671552622067dc45013d240f73952fece703f5e63bdJohn Wiegley 1672552622067dc45013d240f73952fece703f5e63bdJohn Wiegley /// Loc - The location of the type trait keyword. 1673552622067dc45013d240f73952fece703f5e63bdJohn Wiegley SourceLocation Loc; 1674552622067dc45013d240f73952fece703f5e63bdJohn Wiegley 1675552622067dc45013d240f73952fece703f5e63bdJohn Wiegley /// RParen - The location of the closing paren. 1676552622067dc45013d240f73952fece703f5e63bdJohn Wiegley SourceLocation RParen; 1677552622067dc45013d240f73952fece703f5e63bdJohn Wiegley 1678552622067dc45013d240f73952fece703f5e63bdJohn Wiegley Expr* QueriedExpression; 1679552622067dc45013d240f73952fece703f5e63bdJohn Wiegleypublic: 1680552622067dc45013d240f73952fece703f5e63bdJohn Wiegley ExpressionTraitExpr(SourceLocation loc, ExpressionTrait et, 1681552622067dc45013d240f73952fece703f5e63bdJohn Wiegley Expr *queried, bool value, 1682552622067dc45013d240f73952fece703f5e63bdJohn Wiegley SourceLocation rparen, QualType resultType) 1683552622067dc45013d240f73952fece703f5e63bdJohn Wiegley : Expr(ExpressionTraitExprClass, resultType, VK_RValue, OK_Ordinary, 1684552622067dc45013d240f73952fece703f5e63bdJohn Wiegley false, // Not type-dependent 1685552622067dc45013d240f73952fece703f5e63bdJohn Wiegley // Value-dependent if the argument is type-dependent. 1686552622067dc45013d240f73952fece703f5e63bdJohn Wiegley queried->isTypeDependent(), 1687552622067dc45013d240f73952fece703f5e63bdJohn Wiegley queried->containsUnexpandedParameterPack()), 1688552622067dc45013d240f73952fece703f5e63bdJohn Wiegley ET(et), Value(value), Loc(loc), RParen(rparen), QueriedExpression(queried) { } 1689552622067dc45013d240f73952fece703f5e63bdJohn Wiegley 1690552622067dc45013d240f73952fece703f5e63bdJohn Wiegley explicit ExpressionTraitExpr(EmptyShell Empty) 1691552622067dc45013d240f73952fece703f5e63bdJohn Wiegley : Expr(ExpressionTraitExprClass, Empty), ET(0), Value(false), 1692552622067dc45013d240f73952fece703f5e63bdJohn Wiegley QueriedExpression() { } 1693552622067dc45013d240f73952fece703f5e63bdJohn Wiegley 1694552622067dc45013d240f73952fece703f5e63bdJohn Wiegley SourceRange getSourceRange() const { return SourceRange(Loc, RParen);} 1695552622067dc45013d240f73952fece703f5e63bdJohn Wiegley 1696552622067dc45013d240f73952fece703f5e63bdJohn Wiegley ExpressionTrait getTrait() const { return static_cast<ExpressionTrait>(ET); } 1697552622067dc45013d240f73952fece703f5e63bdJohn Wiegley 1698552622067dc45013d240f73952fece703f5e63bdJohn Wiegley Expr *getQueriedExpression() const { return QueriedExpression; } 1699552622067dc45013d240f73952fece703f5e63bdJohn Wiegley 1700552622067dc45013d240f73952fece703f5e63bdJohn Wiegley bool getValue() const { return Value; } 1701552622067dc45013d240f73952fece703f5e63bdJohn Wiegley 1702552622067dc45013d240f73952fece703f5e63bdJohn Wiegley static bool classof(const Stmt *T) { 1703552622067dc45013d240f73952fece703f5e63bdJohn Wiegley return T->getStmtClass() == ExpressionTraitExprClass; 1704552622067dc45013d240f73952fece703f5e63bdJohn Wiegley } 1705552622067dc45013d240f73952fece703f5e63bdJohn Wiegley static bool classof(const ExpressionTraitExpr *) { return true; } 1706552622067dc45013d240f73952fece703f5e63bdJohn Wiegley 1707552622067dc45013d240f73952fece703f5e63bdJohn Wiegley // Iterators 1708552622067dc45013d240f73952fece703f5e63bdJohn Wiegley child_range children() { return child_range(); } 1709552622067dc45013d240f73952fece703f5e63bdJohn Wiegley 1710552622067dc45013d240f73952fece703f5e63bdJohn Wiegley friend class ASTStmtReader; 1711552622067dc45013d240f73952fece703f5e63bdJohn Wiegley}; 1712552622067dc45013d240f73952fece703f5e63bdJohn Wiegley 1713552622067dc45013d240f73952fece703f5e63bdJohn Wiegley 17147bb12da2b0749eeebb21854c77877736969e59f2John McCall/// \brief A reference to an overloaded function set, either an 17157bb12da2b0749eeebb21854c77877736969e59f2John McCall/// \t UnresolvedLookupExpr or an \t UnresolvedMemberExpr. 17167bb12da2b0749eeebb21854c77877736969e59f2John McCallclass OverloadExpr : public Expr { 1717ba13543329afac4a0d01304ec2ec4924d99306a6John McCall /// The results. These are undesugared, which is to say, they may 17187bb12da2b0749eeebb21854c77877736969e59f2John McCall /// include UsingShadowDecls. Access is relative to the naming 17197bb12da2b0749eeebb21854c77877736969e59f2John McCall /// class. 1720928e6fcf66fc4f342bcf7cc96bf56986c9c2a833Douglas Gregor // FIXME: Allocate this data after the OverloadExpr subclass. 1721928e6fcf66fc4f342bcf7cc96bf56986c9c2a833Douglas Gregor DeclAccessPair *Results; 1722928e6fcf66fc4f342bcf7cc96bf56986c9c2a833Douglas Gregor unsigned NumResults; 1723ba13543329afac4a0d01304ec2ec4924d99306a6John McCall 17247bb12da2b0749eeebb21854c77877736969e59f2John McCall /// The common name of these declarations. 17252577743c5650c646fb705df01403707e94f2df04Abramo Bagnara DeclarationNameInfo NameInfo; 1726ba13543329afac4a0d01304ec2ec4924d99306a6John McCall 17274c9be89bb615ec07eb3ed507c8fa9d0baa8a5ad7Douglas Gregor /// \brief The nested-name-specifier that qualifies the name, if any. 17284c9be89bb615ec07eb3ed507c8fa9d0baa8a5ad7Douglas Gregor NestedNameSpecifierLoc QualifierLoc; 1729ba13543329afac4a0d01304ec2ec4924d99306a6John McCall 1730a77eb0862507b900a10fa352af1568e639ed10b1Argyrios Kyrtzidisprotected: 17317bb12da2b0749eeebb21854c77877736969e59f2John McCall /// True if the name was a template-id. 17327bb12da2b0749eeebb21854c77877736969e59f2John McCall bool HasExplicitTemplateArgs; 17337bb12da2b0749eeebb21854c77877736969e59f2John McCall 1734bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor OverloadExpr(StmtClass K, ASTContext &C, 17354c9be89bb615ec07eb3ed507c8fa9d0baa8a5ad7Douglas Gregor NestedNameSpecifierLoc QualifierLoc, 17362577743c5650c646fb705df01403707e94f2df04Abramo Bagnara const DeclarationNameInfo &NameInfo, 1737bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor const TemplateArgumentListInfo *TemplateArgs, 1738bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor UnresolvedSetIterator Begin, UnresolvedSetIterator End, 1739bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor bool KnownDependent = false, 1740bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor bool KnownContainsUnexpandedParameterPack = false); 17417bb12da2b0749eeebb21854c77877736969e59f2John McCall 1742a77eb0862507b900a10fa352af1568e639ed10b1Argyrios Kyrtzidis OverloadExpr(StmtClass K, EmptyShell Empty) 1743a77eb0862507b900a10fa352af1568e639ed10b1Argyrios Kyrtzidis : Expr(K, Empty), Results(0), NumResults(0), 17444c9be89bb615ec07eb3ed507c8fa9d0baa8a5ad7Douglas Gregor QualifierLoc(), HasExplicitTemplateArgs(false) { } 1745a77eb0862507b900a10fa352af1568e639ed10b1Argyrios Kyrtzidis 1746bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor void initializeResults(ASTContext &C, 1747bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor UnresolvedSetIterator Begin, 1748bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor UnresolvedSetIterator End); 17497bb12da2b0749eeebb21854c77877736969e59f2John McCall 1750bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregorpublic: 17519c72c6088d591ace8503b842d39448c2040f3033John McCall struct FindResult { 17529c72c6088d591ace8503b842d39448c2040f3033John McCall OverloadExpr *Expression; 17539c72c6088d591ace8503b842d39448c2040f3033John McCall bool IsAddressOfOperand; 17549c72c6088d591ace8503b842d39448c2040f3033John McCall bool HasFormOfMemberPointer; 17559c72c6088d591ace8503b842d39448c2040f3033John McCall }; 17569c72c6088d591ace8503b842d39448c2040f3033John McCall 17577bb12da2b0749eeebb21854c77877736969e59f2John McCall /// Finds the overloaded expression in the given expression of 17587bb12da2b0749eeebb21854c77877736969e59f2John McCall /// OverloadTy. 17597bb12da2b0749eeebb21854c77877736969e59f2John McCall /// 17609c72c6088d591ace8503b842d39448c2040f3033John McCall /// \return the expression (which must be there) and true if it has 17619c72c6088d591ace8503b842d39448c2040f3033John McCall /// the particular form of a member pointer expression 17629c72c6088d591ace8503b842d39448c2040f3033John McCall static FindResult find(Expr *E) { 17637bb12da2b0749eeebb21854c77877736969e59f2John McCall assert(E->getType()->isSpecificBuiltinType(BuiltinType::Overload)); 17647bb12da2b0749eeebb21854c77877736969e59f2John McCall 17659c72c6088d591ace8503b842d39448c2040f3033John McCall FindResult Result; 17669c72c6088d591ace8503b842d39448c2040f3033John McCall 17677bb12da2b0749eeebb21854c77877736969e59f2John McCall E = E->IgnoreParens(); 17689c72c6088d591ace8503b842d39448c2040f3033John McCall if (isa<UnaryOperator>(E)) { 17699c72c6088d591ace8503b842d39448c2040f3033John McCall assert(cast<UnaryOperator>(E)->getOpcode() == UO_AddrOf); 17709c72c6088d591ace8503b842d39448c2040f3033John McCall E = cast<UnaryOperator>(E)->getSubExpr(); 17719c72c6088d591ace8503b842d39448c2040f3033John McCall OverloadExpr *Ovl = cast<OverloadExpr>(E->IgnoreParens()); 17729c72c6088d591ace8503b842d39448c2040f3033John McCall 17739c72c6088d591ace8503b842d39448c2040f3033John McCall Result.HasFormOfMemberPointer = (E == Ovl && Ovl->getQualifier()); 17749c72c6088d591ace8503b842d39448c2040f3033John McCall Result.IsAddressOfOperand = true; 17759c72c6088d591ace8503b842d39448c2040f3033John McCall Result.Expression = Ovl; 17769c72c6088d591ace8503b842d39448c2040f3033John McCall } else { 17779c72c6088d591ace8503b842d39448c2040f3033John McCall Result.HasFormOfMemberPointer = false; 17789c72c6088d591ace8503b842d39448c2040f3033John McCall Result.IsAddressOfOperand = false; 17799c72c6088d591ace8503b842d39448c2040f3033John McCall Result.Expression = cast<OverloadExpr>(E); 17809c72c6088d591ace8503b842d39448c2040f3033John McCall } 17819c72c6088d591ace8503b842d39448c2040f3033John McCall 17829c72c6088d591ace8503b842d39448c2040f3033John McCall return Result; 17837bb12da2b0749eeebb21854c77877736969e59f2John McCall } 17847bb12da2b0749eeebb21854c77877736969e59f2John McCall 1785e9ee23edd17c4bb7f271e67f8790792b4de677fcJohn McCall /// Gets the naming class of this lookup, if any. 1786e9ee23edd17c4bb7f271e67f8790792b4de677fcJohn McCall CXXRecordDecl *getNamingClass() const; 1787e9ee23edd17c4bb7f271e67f8790792b4de677fcJohn McCall 17887bb12da2b0749eeebb21854c77877736969e59f2John McCall typedef UnresolvedSetImpl::iterator decls_iterator; 1789928e6fcf66fc4f342bcf7cc96bf56986c9c2a833Douglas Gregor decls_iterator decls_begin() const { return UnresolvedSetIterator(Results); } 1790928e6fcf66fc4f342bcf7cc96bf56986c9c2a833Douglas Gregor decls_iterator decls_end() const { 1791928e6fcf66fc4f342bcf7cc96bf56986c9c2a833Douglas Gregor return UnresolvedSetIterator(Results + NumResults); 1792928e6fcf66fc4f342bcf7cc96bf56986c9c2a833Douglas Gregor } 1793a77eb0862507b900a10fa352af1568e639ed10b1Argyrios Kyrtzidis 17947bb12da2b0749eeebb21854c77877736969e59f2John McCall /// Gets the number of declarations in the unresolved set. 1795928e6fcf66fc4f342bcf7cc96bf56986c9c2a833Douglas Gregor unsigned getNumDecls() const { return NumResults; } 17967bb12da2b0749eeebb21854c77877736969e59f2John McCall 17972577743c5650c646fb705df01403707e94f2df04Abramo Bagnara /// Gets the full name info. 17982577743c5650c646fb705df01403707e94f2df04Abramo Bagnara const DeclarationNameInfo &getNameInfo() const { return NameInfo; } 17992577743c5650c646fb705df01403707e94f2df04Abramo Bagnara 18007bb12da2b0749eeebb21854c77877736969e59f2John McCall /// Gets the name looked up. 18012577743c5650c646fb705df01403707e94f2df04Abramo Bagnara DeclarationName getName() const { return NameInfo.getName(); } 18027bb12da2b0749eeebb21854c77877736969e59f2John McCall 18037bb12da2b0749eeebb21854c77877736969e59f2John McCall /// Gets the location of the name. 18042577743c5650c646fb705df01403707e94f2df04Abramo Bagnara SourceLocation getNameLoc() const { return NameInfo.getLoc(); } 18057bb12da2b0749eeebb21854c77877736969e59f2John McCall 18067bb12da2b0749eeebb21854c77877736969e59f2John McCall /// Fetches the nested-name qualifier, if one was given. 18074c9be89bb615ec07eb3ed507c8fa9d0baa8a5ad7Douglas Gregor NestedNameSpecifier *getQualifier() const { 18084c9be89bb615ec07eb3ed507c8fa9d0baa8a5ad7Douglas Gregor return QualifierLoc.getNestedNameSpecifier(); 18094c9be89bb615ec07eb3ed507c8fa9d0baa8a5ad7Douglas Gregor } 18107bb12da2b0749eeebb21854c77877736969e59f2John McCall 18114c9be89bb615ec07eb3ed507c8fa9d0baa8a5ad7Douglas Gregor /// Fetches the nested-name qualifier with source-location information, if 18124c9be89bb615ec07eb3ed507c8fa9d0baa8a5ad7Douglas Gregor /// one was given. 18134c9be89bb615ec07eb3ed507c8fa9d0baa8a5ad7Douglas Gregor NestedNameSpecifierLoc getQualifierLoc() const { return QualifierLoc; } 18147bb12da2b0749eeebb21854c77877736969e59f2John McCall 18157bb12da2b0749eeebb21854c77877736969e59f2John McCall /// \brief Determines whether this expression had an explicit 18167bb12da2b0749eeebb21854c77877736969e59f2John McCall /// template argument list, e.g. f<int>. 18177bb12da2b0749eeebb21854c77877736969e59f2John McCall bool hasExplicitTemplateArgs() const { return HasExplicitTemplateArgs; } 18187bb12da2b0749eeebb21854c77877736969e59f2John McCall 18197bb12da2b0749eeebb21854c77877736969e59f2John McCall ExplicitTemplateArgumentList &getExplicitTemplateArgs(); // defined far below 18207bb12da2b0749eeebb21854c77877736969e59f2John McCall 18217bb12da2b0749eeebb21854c77877736969e59f2John McCall const ExplicitTemplateArgumentList &getExplicitTemplateArgs() const { 18227bb12da2b0749eeebb21854c77877736969e59f2John McCall return const_cast<OverloadExpr*>(this)->getExplicitTemplateArgs(); 18237bb12da2b0749eeebb21854c77877736969e59f2John McCall } 18247bb12da2b0749eeebb21854c77877736969e59f2John McCall 1825096832c5ed5b9106fa177ebc148489760c3bc496John McCall /// \brief Retrieves the optional explicit template arguments. 1826096832c5ed5b9106fa177ebc148489760c3bc496John McCall /// This points to the same data as getExplicitTemplateArgs(), but 1827096832c5ed5b9106fa177ebc148489760c3bc496John McCall /// returns null if there are no explicit template arguments. 1828096832c5ed5b9106fa177ebc148489760c3bc496John McCall const ExplicitTemplateArgumentList *getOptionalExplicitTemplateArgs() { 1829096832c5ed5b9106fa177ebc148489760c3bc496John McCall if (!hasExplicitTemplateArgs()) return 0; 1830096832c5ed5b9106fa177ebc148489760c3bc496John McCall return &getExplicitTemplateArgs(); 18317bb12da2b0749eeebb21854c77877736969e59f2John McCall } 18327bb12da2b0749eeebb21854c77877736969e59f2John McCall 18337bb12da2b0749eeebb21854c77877736969e59f2John McCall static bool classof(const Stmt *T) { 18347bb12da2b0749eeebb21854c77877736969e59f2John McCall return T->getStmtClass() == UnresolvedLookupExprClass || 18357bb12da2b0749eeebb21854c77877736969e59f2John McCall T->getStmtClass() == UnresolvedMemberExprClass; 18367bb12da2b0749eeebb21854c77877736969e59f2John McCall } 18377bb12da2b0749eeebb21854c77877736969e59f2John McCall static bool classof(const OverloadExpr *) { return true; } 18384045107b7384fd68eed5e3e2f06fc2a47e7be0a6Argyrios Kyrtzidis 18394045107b7384fd68eed5e3e2f06fc2a47e7be0a6Argyrios Kyrtzidis friend class ASTStmtReader; 18404045107b7384fd68eed5e3e2f06fc2a47e7be0a6Argyrios Kyrtzidis friend class ASTStmtWriter; 18417bb12da2b0749eeebb21854c77877736969e59f2John McCall}; 18427bb12da2b0749eeebb21854c77877736969e59f2John McCall 18437bb12da2b0749eeebb21854c77877736969e59f2John McCall/// \brief A reference to a name which we were able to look up during 18447bb12da2b0749eeebb21854c77877736969e59f2John McCall/// parsing but could not resolve to a specific declaration. This 18457bb12da2b0749eeebb21854c77877736969e59f2John McCall/// arises in several ways: 18467bb12da2b0749eeebb21854c77877736969e59f2John McCall/// * we might be waiting for argument-dependent lookup 18477bb12da2b0749eeebb21854c77877736969e59f2John McCall/// * the name might resolve to an overloaded function 18487bb12da2b0749eeebb21854c77877736969e59f2John McCall/// and eventually: 18497bb12da2b0749eeebb21854c77877736969e59f2John McCall/// * the lookup might have included a function template 18507bb12da2b0749eeebb21854c77877736969e59f2John McCall/// These never include UnresolvedUsingValueDecls, which are always 18517bb12da2b0749eeebb21854c77877736969e59f2John McCall/// class members and therefore appear only in 18527bb12da2b0749eeebb21854c77877736969e59f2John McCall/// UnresolvedMemberLookupExprs. 18537bb12da2b0749eeebb21854c77877736969e59f2John McCallclass UnresolvedLookupExpr : public OverloadExpr { 1854ba13543329afac4a0d01304ec2ec4924d99306a6John McCall /// True if these lookup results should be extended by 1855ba13543329afac4a0d01304ec2ec4924d99306a6John McCall /// argument-dependent lookup if this is the operand of a function 1856ba13543329afac4a0d01304ec2ec4924d99306a6John McCall /// call. 1857ba13543329afac4a0d01304ec2ec4924d99306a6John McCall bool RequiresADL; 1858ba13543329afac4a0d01304ec2ec4924d99306a6John McCall 1859ad762fcdc16b9e4705b12b09d92b8c026212b906Richard Smith /// True if namespace ::std should be considered an associated namespace 1860ad762fcdc16b9e4705b12b09d92b8c026212b906Richard Smith /// for the purposes of argument-dependent lookup. See C++0x [stmt.ranged]p1. 1861ad762fcdc16b9e4705b12b09d92b8c026212b906Richard Smith bool StdIsAssociatedNamespace; 1862ad762fcdc16b9e4705b12b09d92b8c026212b906Richard Smith 18637453ed4cb2cab113de3378df371b1c6f1243d832John McCall /// True if these lookup results are overloaded. This is pretty 18647453ed4cb2cab113de3378df371b1c6f1243d832John McCall /// trivially rederivable if we urgently need to kill this field. 18657453ed4cb2cab113de3378df371b1c6f1243d832John McCall bool Overloaded; 18667453ed4cb2cab113de3378df371b1c6f1243d832John McCall 18677bb12da2b0749eeebb21854c77877736969e59f2John McCall /// The naming class (C++ [class.access.base]p5) of the lookup, if 18687bb12da2b0749eeebb21854c77877736969e59f2John McCall /// any. This can generally be recalculated from the context chain, 18697bb12da2b0749eeebb21854c77877736969e59f2John McCall /// but that can be fairly expensive for unqualified lookups. If we 18707bb12da2b0749eeebb21854c77877736969e59f2John McCall /// want to improve memory use here, this could go in a union 18717bb12da2b0749eeebb21854c77877736969e59f2John McCall /// against the qualified-lookup bits. 18727bb12da2b0749eeebb21854c77877736969e59f2John McCall CXXRecordDecl *NamingClass; 1873f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall 1874bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor UnresolvedLookupExpr(ASTContext &C, 1875928e6fcf66fc4f342bcf7cc96bf56986c9c2a833Douglas Gregor CXXRecordDecl *NamingClass, 18764c9be89bb615ec07eb3ed507c8fa9d0baa8a5ad7Douglas Gregor NestedNameSpecifierLoc QualifierLoc, 18772577743c5650c646fb705df01403707e94f2df04Abramo Bagnara const DeclarationNameInfo &NameInfo, 1878bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor bool RequiresADL, bool Overloaded, 1879bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor const TemplateArgumentListInfo *TemplateArgs, 1880ad762fcdc16b9e4705b12b09d92b8c026212b906Richard Smith UnresolvedSetIterator Begin, UnresolvedSetIterator End, 1881ad762fcdc16b9e4705b12b09d92b8c026212b906Richard Smith bool StdIsAssociatedNamespace) 18824c9be89bb615ec07eb3ed507c8fa9d0baa8a5ad7Douglas Gregor : OverloadExpr(UnresolvedLookupExprClass, C, QualifierLoc, NameInfo, 1883bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor TemplateArgs, Begin, End), 1884ad762fcdc16b9e4705b12b09d92b8c026212b906Richard Smith RequiresADL(RequiresADL), 1885ad762fcdc16b9e4705b12b09d92b8c026212b906Richard Smith StdIsAssociatedNamespace(StdIsAssociatedNamespace), 1886ad762fcdc16b9e4705b12b09d92b8c026212b906Richard Smith Overloaded(Overloaded), NamingClass(NamingClass) 1887ba13543329afac4a0d01304ec2ec4924d99306a6John McCall {} 1888ba13543329afac4a0d01304ec2ec4924d99306a6John McCall 1889bd65bb511c26549c96b829c1282e4c877588564aArgyrios Kyrtzidis UnresolvedLookupExpr(EmptyShell Empty) 1890bd65bb511c26549c96b829c1282e4c877588564aArgyrios Kyrtzidis : OverloadExpr(UnresolvedLookupExprClass, Empty), 1891ad762fcdc16b9e4705b12b09d92b8c026212b906Richard Smith RequiresADL(false), StdIsAssociatedNamespace(false), Overloaded(false), 1892ad762fcdc16b9e4705b12b09d92b8c026212b906Richard Smith NamingClass(0) 1893bd65bb511c26549c96b829c1282e4c877588564aArgyrios Kyrtzidis {} 1894bd65bb511c26549c96b829c1282e4c877588564aArgyrios Kyrtzidis 18954c9be89bb615ec07eb3ed507c8fa9d0baa8a5ad7Douglas Gregor friend class ASTStmtReader; 18964c9be89bb615ec07eb3ed507c8fa9d0baa8a5ad7Douglas Gregor 1897ba13543329afac4a0d01304ec2ec4924d99306a6John McCallpublic: 1898ba13543329afac4a0d01304ec2ec4924d99306a6John McCall static UnresolvedLookupExpr *Create(ASTContext &C, 1899c373d48502ca7683ab55385f5bd624d778eb288dJohn McCall CXXRecordDecl *NamingClass, 19004c9be89bb615ec07eb3ed507c8fa9d0baa8a5ad7Douglas Gregor NestedNameSpecifierLoc QualifierLoc, 19012577743c5650c646fb705df01403707e94f2df04Abramo Bagnara const DeclarationNameInfo &NameInfo, 19025a84dec38cfa9e084377a3167b474c79283c82faDouglas Gregor bool ADL, bool Overloaded, 19035a84dec38cfa9e084377a3167b474c79283c82faDouglas Gregor UnresolvedSetIterator Begin, 1904ad762fcdc16b9e4705b12b09d92b8c026212b906Richard Smith UnresolvedSetIterator End, 1905ad762fcdc16b9e4705b12b09d92b8c026212b906Richard Smith bool StdIsAssociatedNamespace = false) { 1906ad762fcdc16b9e4705b12b09d92b8c026212b906Richard Smith assert((ADL || !StdIsAssociatedNamespace) && 1907ad762fcdc16b9e4705b12b09d92b8c026212b906Richard Smith "std considered associated namespace when not performing ADL"); 19084c9be89bb615ec07eb3ed507c8fa9d0baa8a5ad7Douglas Gregor return new(C) UnresolvedLookupExpr(C, NamingClass, QualifierLoc, NameInfo, 1909ad762fcdc16b9e4705b12b09d92b8c026212b906Richard Smith ADL, Overloaded, 0, Begin, End, 1910ad762fcdc16b9e4705b12b09d92b8c026212b906Richard Smith StdIsAssociatedNamespace); 1911ba13543329afac4a0d01304ec2ec4924d99306a6John McCall } 1912ba13543329afac4a0d01304ec2ec4924d99306a6John McCall 1913f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall static UnresolvedLookupExpr *Create(ASTContext &C, 1914c373d48502ca7683ab55385f5bd624d778eb288dJohn McCall CXXRecordDecl *NamingClass, 19154c9be89bb615ec07eb3ed507c8fa9d0baa8a5ad7Douglas Gregor NestedNameSpecifierLoc QualifierLoc, 19162577743c5650c646fb705df01403707e94f2df04Abramo Bagnara const DeclarationNameInfo &NameInfo, 1917f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall bool ADL, 19185a84dec38cfa9e084377a3167b474c79283c82faDouglas Gregor const TemplateArgumentListInfo &Args, 19195a84dec38cfa9e084377a3167b474c79283c82faDouglas Gregor UnresolvedSetIterator Begin, 19205a84dec38cfa9e084377a3167b474c79283c82faDouglas Gregor UnresolvedSetIterator End); 1921f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall 1922bd65bb511c26549c96b829c1282e4c877588564aArgyrios Kyrtzidis static UnresolvedLookupExpr *CreateEmpty(ASTContext &C, 1923def0354384d9c4431f7b58b664b59896d4623028Douglas Gregor bool HasExplicitTemplateArgs, 1924bd65bb511c26549c96b829c1282e4c877588564aArgyrios Kyrtzidis unsigned NumTemplateArgs); 1925bd65bb511c26549c96b829c1282e4c877588564aArgyrios Kyrtzidis 1926ba13543329afac4a0d01304ec2ec4924d99306a6John McCall /// True if this declaration should be extended by 1927ba13543329afac4a0d01304ec2ec4924d99306a6John McCall /// argument-dependent lookup. 1928ba13543329afac4a0d01304ec2ec4924d99306a6John McCall bool requiresADL() const { return RequiresADL; } 1929ba13543329afac4a0d01304ec2ec4924d99306a6John McCall 1930ad762fcdc16b9e4705b12b09d92b8c026212b906Richard Smith /// True if namespace ::std should be artificially added to the set of 1931ad762fcdc16b9e4705b12b09d92b8c026212b906Richard Smith /// associated namespaecs for argument-dependent lookup purposes. 1932ad762fcdc16b9e4705b12b09d92b8c026212b906Richard Smith bool isStdAssociatedNamespace() const { return StdIsAssociatedNamespace; } 1933ad762fcdc16b9e4705b12b09d92b8c026212b906Richard Smith 19347453ed4cb2cab113de3378df371b1c6f1243d832John McCall /// True if this lookup is overloaded. 19357453ed4cb2cab113de3378df371b1c6f1243d832John McCall bool isOverloaded() const { return Overloaded; } 19367453ed4cb2cab113de3378df371b1c6f1243d832John McCall 1937c373d48502ca7683ab55385f5bd624d778eb288dJohn McCall /// Gets the 'naming class' (in the sense of C++0x 1938c373d48502ca7683ab55385f5bd624d778eb288dJohn McCall /// [class.access.base]p5) of the lookup. This is the scope 1939c373d48502ca7683ab55385f5bd624d778eb288dJohn McCall /// that was looked in to find these results. 1940c373d48502ca7683ab55385f5bd624d778eb288dJohn McCall CXXRecordDecl *getNamingClass() const { return NamingClass; } 1941c373d48502ca7683ab55385f5bd624d778eb288dJohn McCall 1942f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall // Note that, inconsistently with the explicit-template-argument AST 1943f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall // nodes, users are *forbidden* from calling these methods on objects 1944f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall // without explicit template arguments. 1945f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall 19467bb12da2b0749eeebb21854c77877736969e59f2John McCall ExplicitTemplateArgumentList &getExplicitTemplateArgs() { 19477bb12da2b0749eeebb21854c77877736969e59f2John McCall assert(hasExplicitTemplateArgs()); 19487bb12da2b0749eeebb21854c77877736969e59f2John McCall return *reinterpret_cast<ExplicitTemplateArgumentList*>(this + 1); 19497bb12da2b0749eeebb21854c77877736969e59f2John McCall } 19507bb12da2b0749eeebb21854c77877736969e59f2John McCall 1951f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall /// Gets a reference to the explicit template argument list. 1952f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall const ExplicitTemplateArgumentList &getExplicitTemplateArgs() const { 1953f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall assert(hasExplicitTemplateArgs()); 1954f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall return *reinterpret_cast<const ExplicitTemplateArgumentList*>(this + 1); 1955f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall } 1956f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall 1957096832c5ed5b9106fa177ebc148489760c3bc496John McCall /// \brief Retrieves the optional explicit template arguments. 1958096832c5ed5b9106fa177ebc148489760c3bc496John McCall /// This points to the same data as getExplicitTemplateArgs(), but 1959096832c5ed5b9106fa177ebc148489760c3bc496John McCall /// returns null if there are no explicit template arguments. 1960096832c5ed5b9106fa177ebc148489760c3bc496John McCall const ExplicitTemplateArgumentList *getOptionalExplicitTemplateArgs() { 1961096832c5ed5b9106fa177ebc148489760c3bc496John McCall if (!hasExplicitTemplateArgs()) return 0; 1962096832c5ed5b9106fa177ebc148489760c3bc496John McCall return &getExplicitTemplateArgs(); 1963096832c5ed5b9106fa177ebc148489760c3bc496John McCall } 1964096832c5ed5b9106fa177ebc148489760c3bc496John McCall 1965f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall /// \brief Copies the template arguments (if present) into the given 1966f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall /// structure. 1967f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall void copyTemplateArgumentsInto(TemplateArgumentListInfo &List) const { 1968f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall getExplicitTemplateArgs().copyInto(List); 1969f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall } 1970ba13543329afac4a0d01304ec2ec4924d99306a6John McCall 1971f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall SourceLocation getLAngleLoc() const { 1972f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall return getExplicitTemplateArgs().LAngleLoc; 1973f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall } 1974f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall 1975f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall SourceLocation getRAngleLoc() const { 1976f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall return getExplicitTemplateArgs().RAngleLoc; 1977f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall } 1978f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall 1979f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall TemplateArgumentLoc const *getTemplateArgs() const { 1980f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall return getExplicitTemplateArgs().getTemplateArgs(); 1981f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall } 1982f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall 1983f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall unsigned getNumTemplateArgs() const { 1984f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall return getExplicitTemplateArgs().NumTemplateArgs; 1985f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall } 1986ba13543329afac4a0d01304ec2ec4924d99306a6John McCall 198763c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall SourceRange getSourceRange() const { 19882577743c5650c646fb705df01403707e94f2df04Abramo Bagnara SourceRange Range(getNameInfo().getSourceRange()); 19894c9be89bb615ec07eb3ed507c8fa9d0baa8a5ad7Douglas Gregor if (getQualifierLoc()) 19904c9be89bb615ec07eb3ed507c8fa9d0baa8a5ad7Douglas Gregor Range.setBegin(getQualifierLoc().getBeginLoc()); 19914c9be89bb615ec07eb3ed507c8fa9d0baa8a5ad7Douglas Gregor if (hasExplicitTemplateArgs()) 19924c9be89bb615ec07eb3ed507c8fa9d0baa8a5ad7Douglas Gregor Range.setEnd(getRAngleLoc()); 1993f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall return Range; 1994ba13543329afac4a0d01304ec2ec4924d99306a6John McCall } 1995ba13543329afac4a0d01304ec2ec4924d99306a6John McCall 199663c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall child_range children() { return child_range(); } 1997ba13543329afac4a0d01304ec2ec4924d99306a6John McCall 1998ba13543329afac4a0d01304ec2ec4924d99306a6John McCall static bool classof(const Stmt *T) { 1999ba13543329afac4a0d01304ec2ec4924d99306a6John McCall return T->getStmtClass() == UnresolvedLookupExprClass; 2000ba13543329afac4a0d01304ec2ec4924d99306a6John McCall } 2001ba13543329afac4a0d01304ec2ec4924d99306a6John McCall static bool classof(const UnresolvedLookupExpr *) { return true; } 2002ba13543329afac4a0d01304ec2ec4924d99306a6John McCall}; 2003ba13543329afac4a0d01304ec2ec4924d99306a6John McCall 20045953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor/// \brief A qualified reference to a name whose declaration cannot 20055953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor/// yet be resolved. 20065953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor/// 2007ba13543329afac4a0d01304ec2ec4924d99306a6John McCall/// DependentScopeDeclRefExpr is similar to DeclRefExpr in that 2008a2813cec2605ce7878d1b13471d685f689b251afDouglas Gregor/// it expresses a reference to a declaration such as 20095953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor/// X<T>::value. The difference, however, is that an 2010865d447ac6a4721ab58e898d014a21f2eff74b06John McCall/// DependentScopeDeclRefExpr node is used only within C++ templates when 20115953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor/// the qualification (e.g., X<T>::) refers to a dependent type. In 20125953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor/// this case, X<T>::value cannot resolve to a declaration because the 20135953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor/// declaration will differ from on instantiation of X<T> to the 2014865d447ac6a4721ab58e898d014a21f2eff74b06John McCall/// next. Therefore, DependentScopeDeclRefExpr keeps track of the 2015ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor/// qualifier (X<T>::) and the name of the entity being referenced 2016a2813cec2605ce7878d1b13471d685f689b251afDouglas Gregor/// ("value"). Such expressions will instantiate to a DeclRefExpr once the 2017a2813cec2605ce7878d1b13471d685f689b251afDouglas Gregor/// declaration can be found. 2018865d447ac6a4721ab58e898d014a21f2eff74b06John McCallclass DependentScopeDeclRefExpr : public Expr { 2019ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor /// \brief The nested-name-specifier that qualifies this unresolved 2020ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor /// declaration name. 202100cf3cc2718671aa48e8da264a523b0058a8591eDouglas Gregor NestedNameSpecifierLoc QualifierLoc; 202200cf3cc2718671aa48e8da264a523b0058a8591eDouglas Gregor 202300cf3cc2718671aa48e8da264a523b0058a8591eDouglas Gregor /// The name of the entity we will be referencing. 202400cf3cc2718671aa48e8da264a523b0058a8591eDouglas Gregor DeclarationNameInfo NameInfo; 20255953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor 2026f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall /// \brief Whether the name includes explicit template arguments. 2027f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall bool HasExplicitTemplateArgs; 20281eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 2029f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall DependentScopeDeclRefExpr(QualType T, 203000cf3cc2718671aa48e8da264a523b0058a8591eDouglas Gregor NestedNameSpecifierLoc QualifierLoc, 20312577743c5650c646fb705df01403707e94f2df04Abramo Bagnara const DeclarationNameInfo &NameInfo, 2032bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor const TemplateArgumentListInfo *Args); 2033f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall 2034f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCallpublic: 2035f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall static DependentScopeDeclRefExpr *Create(ASTContext &C, 203600cf3cc2718671aa48e8da264a523b0058a8591eDouglas Gregor NestedNameSpecifierLoc QualifierLoc, 20372577743c5650c646fb705df01403707e94f2df04Abramo Bagnara const DeclarationNameInfo &NameInfo, 2038f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall const TemplateArgumentListInfo *TemplateArgs = 0); 20395953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor 204012dffcddb60380c5bed4f085a1f51534afda3b87Argyrios Kyrtzidis static DependentScopeDeclRefExpr *CreateEmpty(ASTContext &C, 2041def0354384d9c4431f7b58b664b59896d4623028Douglas Gregor bool HasExplicitTemplateArgs, 204212dffcddb60380c5bed4f085a1f51534afda3b87Argyrios Kyrtzidis unsigned NumTemplateArgs); 204312dffcddb60380c5bed4f085a1f51534afda3b87Argyrios Kyrtzidis 20445953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor /// \brief Retrieve the name that this expression refers to. 20452577743c5650c646fb705df01403707e94f2df04Abramo Bagnara const DeclarationNameInfo &getNameInfo() const { return NameInfo; } 20462577743c5650c646fb705df01403707e94f2df04Abramo Bagnara 20472577743c5650c646fb705df01403707e94f2df04Abramo Bagnara /// \brief Retrieve the name that this expression refers to. 20482577743c5650c646fb705df01403707e94f2df04Abramo Bagnara DeclarationName getDeclName() const { return NameInfo.getName(); } 20495953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor 20505953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor /// \brief Retrieve the location of the name within the expression. 20512577743c5650c646fb705df01403707e94f2df04Abramo Bagnara SourceLocation getLocation() const { return NameInfo.getLoc(); } 20525953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor 205300cf3cc2718671aa48e8da264a523b0058a8591eDouglas Gregor /// \brief Retrieve the nested-name-specifier that qualifies the 205400cf3cc2718671aa48e8da264a523b0058a8591eDouglas Gregor /// name, with source location information. 205500cf3cc2718671aa48e8da264a523b0058a8591eDouglas Gregor NestedNameSpecifierLoc getQualifierLoc() const { return QualifierLoc; } 205600cf3cc2718671aa48e8da264a523b0058a8591eDouglas Gregor 205700cf3cc2718671aa48e8da264a523b0058a8591eDouglas Gregor 2058ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor /// \brief Retrieve the nested-name-specifier that qualifies this 2059ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor /// declaration. 206000cf3cc2718671aa48e8da264a523b0058a8591eDouglas Gregor NestedNameSpecifier *getQualifier() const { 206100cf3cc2718671aa48e8da264a523b0058a8591eDouglas Gregor return QualifierLoc.getNestedNameSpecifier(); 206200cf3cc2718671aa48e8da264a523b0058a8591eDouglas Gregor } 20631eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 2064f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall /// Determines whether this lookup had explicit template arguments. 2065f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall bool hasExplicitTemplateArgs() const { return HasExplicitTemplateArgs; } 20661eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 2067f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall // Note that, inconsistently with the explicit-template-argument AST 2068f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall // nodes, users are *forbidden* from calling these methods on objects 2069f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall // without explicit template arguments. 20701eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 207112dffcddb60380c5bed4f085a1f51534afda3b87Argyrios Kyrtzidis ExplicitTemplateArgumentList &getExplicitTemplateArgs() { 207212dffcddb60380c5bed4f085a1f51534afda3b87Argyrios Kyrtzidis assert(hasExplicitTemplateArgs()); 207312dffcddb60380c5bed4f085a1f51534afda3b87Argyrios Kyrtzidis return *reinterpret_cast<ExplicitTemplateArgumentList*>(this + 1); 207412dffcddb60380c5bed4f085a1f51534afda3b87Argyrios Kyrtzidis } 207512dffcddb60380c5bed4f085a1f51534afda3b87Argyrios Kyrtzidis 2076f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall /// Gets a reference to the explicit template argument list. 2077f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall const ExplicitTemplateArgumentList &getExplicitTemplateArgs() const { 2078f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall assert(hasExplicitTemplateArgs()); 2079f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall return *reinterpret_cast<const ExplicitTemplateArgumentList*>(this + 1); 2080f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall } 20811eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 2082096832c5ed5b9106fa177ebc148489760c3bc496John McCall /// \brief Retrieves the optional explicit template arguments. 2083096832c5ed5b9106fa177ebc148489760c3bc496John McCall /// This points to the same data as getExplicitTemplateArgs(), but 2084096832c5ed5b9106fa177ebc148489760c3bc496John McCall /// returns null if there are no explicit template arguments. 2085096832c5ed5b9106fa177ebc148489760c3bc496John McCall const ExplicitTemplateArgumentList *getOptionalExplicitTemplateArgs() { 2086096832c5ed5b9106fa177ebc148489760c3bc496John McCall if (!hasExplicitTemplateArgs()) return 0; 2087096832c5ed5b9106fa177ebc148489760c3bc496John McCall return &getExplicitTemplateArgs(); 2088096832c5ed5b9106fa177ebc148489760c3bc496John McCall } 2089096832c5ed5b9106fa177ebc148489760c3bc496John McCall 2090f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall /// \brief Copies the template arguments (if present) into the given 2091f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall /// structure. 2092f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall void copyTemplateArgumentsInto(TemplateArgumentListInfo &List) const { 2093f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall getExplicitTemplateArgs().copyInto(List); 2094f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall } 2095f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall 2096f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall SourceLocation getLAngleLoc() const { 2097f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall return getExplicitTemplateArgs().LAngleLoc; 2098edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor } 20991eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 2100f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall SourceLocation getRAngleLoc() const { 2101f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall return getExplicitTemplateArgs().RAngleLoc; 2102f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall } 21031eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 2104f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall TemplateArgumentLoc const *getTemplateArgs() const { 2105f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall return getExplicitTemplateArgs().getTemplateArgs(); 2106d5532b6cfff2977e0c59fa6ead7f7973984a620dJohn McCall } 2107d5532b6cfff2977e0c59fa6ead7f7973984a620dJohn McCall 2108f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall unsigned getNumTemplateArgs() const { 2109f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall return getExplicitTemplateArgs().NumTemplateArgs; 2110f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall } 21111eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 211263c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall SourceRange getSourceRange() const { 211300cf3cc2718671aa48e8da264a523b0058a8591eDouglas Gregor SourceRange Range(QualifierLoc.getBeginLoc(), getLocation()); 2114f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall if (hasExplicitTemplateArgs()) 2115f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall Range.setEnd(getRAngleLoc()); 2116f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall return Range; 2117edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor } 21181eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 21191eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump static bool classof(const Stmt *T) { 2120f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall return T->getStmtClass() == DependentScopeDeclRefExprClass; 2121edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor } 2122f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall static bool classof(const DependentScopeDeclRefExpr *) { return true; } 2123f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall 212463c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall child_range children() { return child_range(); } 21254045107b7384fd68eed5e3e2f06fc2a47e7be0a6Argyrios Kyrtzidis 21264045107b7384fd68eed5e3e2f06fc2a47e7be0a6Argyrios Kyrtzidis friend class ASTStmtReader; 21274045107b7384fd68eed5e3e2f06fc2a47e7be0a6Argyrios Kyrtzidis friend class ASTStmtWriter; 2128edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor}; 21291eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 21304765fa05b5652fcc4356371c2f481d0ea9a1b007John McCall/// Represents an expression --- generally a full-expression --- which 21314765fa05b5652fcc4356371c2f481d0ea9a1b007John McCall/// introduces cleanups to be run at the end of the sub-expression's 21324765fa05b5652fcc4356371c2f481d0ea9a1b007John McCall/// evaluation. The most common source of expression-introduced 21334765fa05b5652fcc4356371c2f481d0ea9a1b007John McCall/// cleanups is temporary objects in C++, but several other C++ 21344765fa05b5652fcc4356371c2f481d0ea9a1b007John McCall/// expressions can create cleanups. 21354765fa05b5652fcc4356371c2f481d0ea9a1b007John McCallclass ExprWithCleanups : public Expr { 213602bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson Stmt *SubExpr; 21371eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 2138ff6b3d64c9f07155f1414411b8451d7bf8937c62Anders Carlsson CXXTemporary **Temps; 2139ff6b3d64c9f07155f1414411b8451d7bf8937c62Anders Carlsson unsigned NumTemps; 214002bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson 21414765fa05b5652fcc4356371c2f481d0ea9a1b007John McCall ExprWithCleanups(ASTContext &C, Expr *SubExpr, 21424765fa05b5652fcc4356371c2f481d0ea9a1b007John McCall CXXTemporary **Temps, unsigned NumTemps); 21434765fa05b5652fcc4356371c2f481d0ea9a1b007John McCall 214488eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlssonpublic: 21454765fa05b5652fcc4356371c2f481d0ea9a1b007John McCall ExprWithCleanups(EmptyShell Empty) 21464765fa05b5652fcc4356371c2f481d0ea9a1b007John McCall : Expr(ExprWithCleanupsClass, Empty), 2147d2598368876cfe40bc8465540033bc5b5e58d8afChris Lattner SubExpr(0), Temps(0), NumTemps(0) {} 2148d2598368876cfe40bc8465540033bc5b5e58d8afChris Lattner 21494765fa05b5652fcc4356371c2f481d0ea9a1b007John McCall static ExprWithCleanups *Create(ASTContext &C, Expr *SubExpr, 21500ece491d8f62ce67f047491a6703fac0d3bd4ff4Anders Carlsson CXXTemporary **Temps, 21510ece491d8f62ce67f047491a6703fac0d3bd4ff4Anders Carlsson unsigned NumTemps); 21521eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 215388eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlsson unsigned getNumTemporaries() const { return NumTemps; } 2154d04ed416be7c55bddddab1fa3fd38a0113a6b3daTed Kremenek void setNumTemporaries(ASTContext &C, unsigned N); 2155d2598368876cfe40bc8465540033bc5b5e58d8afChris Lattner 215688eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlsson CXXTemporary *getTemporary(unsigned i) { 215788eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlsson assert(i < NumTemps && "Index out of range"); 215888eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlsson return Temps[i]; 215988eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlsson } 2160f0721fe438d7e40c168e5d664970e7830bc138fbAnders Carlsson const CXXTemporary *getTemporary(unsigned i) const { 21614765fa05b5652fcc4356371c2f481d0ea9a1b007John McCall return const_cast<ExprWithCleanups*>(this)->getTemporary(i); 2162f0721fe438d7e40c168e5d664970e7830bc138fbAnders Carlsson } 2163d2598368876cfe40bc8465540033bc5b5e58d8afChris Lattner void setTemporary(unsigned i, CXXTemporary *T) { 2164d2598368876cfe40bc8465540033bc5b5e58d8afChris Lattner assert(i < NumTemps && "Index out of range"); 2165d2598368876cfe40bc8465540033bc5b5e58d8afChris Lattner Temps[i] = T; 2166d2598368876cfe40bc8465540033bc5b5e58d8afChris Lattner } 21671eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 216802bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson Expr *getSubExpr() { return cast<Expr>(SubExpr); } 2169f0721fe438d7e40c168e5d664970e7830bc138fbAnders Carlsson const Expr *getSubExpr() const { return cast<Expr>(SubExpr); } 217088eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlsson void setSubExpr(Expr *E) { SubExpr = E; } 217102bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson 217263c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall SourceRange getSourceRange() const { 217396be6917e1c4ba1f4435a14c9e7c6c139571d086Douglas Gregor return SubExpr->getSourceRange(); 217496be6917e1c4ba1f4435a14c9e7c6c139571d086Douglas Gregor } 217502bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson 217602bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson // Implement isa/cast/dyncast/etc. 217702bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson static bool classof(const Stmt *T) { 21784765fa05b5652fcc4356371c2f481d0ea9a1b007John McCall return T->getStmtClass() == ExprWithCleanupsClass; 217902bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson } 21804765fa05b5652fcc4356371c2f481d0ea9a1b007John McCall static bool classof(const ExprWithCleanups *) { return true; } 218102bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson 218202bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson // Iterators 218363c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall child_range children() { return child_range(&SubExpr, &SubExpr + 1); } 218402bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson}; 218502bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson 2186d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// \brief Describes an explicit type conversion that uses functional 2187d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// notion but could not be resolved because one or more arguments are 2188d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// type-dependent. 2189d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// 2190d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// The explicit type conversions expressed by 2191d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// CXXUnresolvedConstructExpr have the form \c T(a1, a2, ..., aN), 2192d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// where \c T is some type and \c a1, a2, ..., aN are values, and 2193d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// either \C T is a dependent type or one or more of the \c a's is 2194d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// type-dependent. For example, this would occur in a template such 2195d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// as: 2196d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// 2197d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// \code 2198d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// template<typename T, typename A1> 2199d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// inline T make_a(const A1& a1) { 2200d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// return T(a1); 2201d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// } 2202d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// \endcode 2203d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// 2204d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// When the returned expression is instantiated, it may resolve to a 2205d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// constructor call, conversion function call, or some kind of type 2206d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// conversion. 2207d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregorclass CXXUnresolvedConstructExpr : public Expr { 2208d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor /// \brief The type being constructed. 2209ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor TypeSourceInfo *Type; 2210ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor 2211d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor /// \brief The location of the left parentheses ('('). 2212d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor SourceLocation LParenLoc; 2213d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor 2214d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor /// \brief The location of the right parentheses (')'). 2215d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor SourceLocation RParenLoc; 2216d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor 2217d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor /// \brief The number of arguments used to construct the type. 2218d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor unsigned NumArgs; 22191eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 2220ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor CXXUnresolvedConstructExpr(TypeSourceInfo *Type, 2221d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor SourceLocation LParenLoc, 2222d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor Expr **Args, 2223d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor unsigned NumArgs, 2224d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor SourceLocation RParenLoc); 2225d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor 22268dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis CXXUnresolvedConstructExpr(EmptyShell Empty, unsigned NumArgs) 2227ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor : Expr(CXXUnresolvedConstructExprClass, Empty), Type(), NumArgs(NumArgs) { } 22288dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis 2229ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor friend class ASTStmtReader; 2230ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor 2231d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregorpublic: 22321eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump static CXXUnresolvedConstructExpr *Create(ASTContext &C, 2233ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor TypeSourceInfo *Type, 2234d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor SourceLocation LParenLoc, 2235d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor Expr **Args, 2236d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor unsigned NumArgs, 2237d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor SourceLocation RParenLoc); 2238d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor 22398dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis static CXXUnresolvedConstructExpr *CreateEmpty(ASTContext &C, 22408dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis unsigned NumArgs); 22418dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis 2242d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor /// \brief Retrieve the type that is being constructed, as specified 2243d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor /// in the source code. 2244ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor QualType getTypeAsWritten() const { return Type->getType(); } 2245d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor 2246ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor /// \brief Retrieve the type source information for the type being 2247ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor /// constructed. 2248ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor TypeSourceInfo *getTypeSourceInfo() const { return Type; } 2249ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor 2250d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor /// \brief Retrieve the location of the left parentheses ('(') that 2251d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor /// precedes the argument list. 2252d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor SourceLocation getLParenLoc() const { return LParenLoc; } 2253d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor void setLParenLoc(SourceLocation L) { LParenLoc = L; } 2254d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor 2255d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor /// \brief Retrieve the location of the right parentheses (')') that 2256d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor /// follows the argument list. 2257d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor SourceLocation getRParenLoc() const { return RParenLoc; } 2258d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor void setRParenLoc(SourceLocation L) { RParenLoc = L; } 2259d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor 2260d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor /// \brief Retrieve the number of arguments. 2261d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor unsigned arg_size() const { return NumArgs; } 2262d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor 2263d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor typedef Expr** arg_iterator; 2264d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor arg_iterator arg_begin() { return reinterpret_cast<Expr**>(this + 1); } 2265d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor arg_iterator arg_end() { return arg_begin() + NumArgs; } 2266d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor 22671dd7383dc48718c452e71a625b29531dd96fbb9dJohn McCall typedef const Expr* const * const_arg_iterator; 22681dd7383dc48718c452e71a625b29531dd96fbb9dJohn McCall const_arg_iterator arg_begin() const { 22691dd7383dc48718c452e71a625b29531dd96fbb9dJohn McCall return reinterpret_cast<const Expr* const *>(this + 1); 22701dd7383dc48718c452e71a625b29531dd96fbb9dJohn McCall } 22711dd7383dc48718c452e71a625b29531dd96fbb9dJohn McCall const_arg_iterator arg_end() const { 22721dd7383dc48718c452e71a625b29531dd96fbb9dJohn McCall return arg_begin() + NumArgs; 22731dd7383dc48718c452e71a625b29531dd96fbb9dJohn McCall } 22741dd7383dc48718c452e71a625b29531dd96fbb9dJohn McCall 2275d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor Expr *getArg(unsigned I) { 2276d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor assert(I < NumArgs && "Argument index out-of-range"); 2277d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor return *(arg_begin() + I); 2278d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor } 2279d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor 22801dd7383dc48718c452e71a625b29531dd96fbb9dJohn McCall const Expr *getArg(unsigned I) const { 22811dd7383dc48718c452e71a625b29531dd96fbb9dJohn McCall assert(I < NumArgs && "Argument index out-of-range"); 22821dd7383dc48718c452e71a625b29531dd96fbb9dJohn McCall return *(arg_begin() + I); 22831dd7383dc48718c452e71a625b29531dd96fbb9dJohn McCall } 22841dd7383dc48718c452e71a625b29531dd96fbb9dJohn McCall 22858dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis void setArg(unsigned I, Expr *E) { 22868dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis assert(I < NumArgs && "Argument index out-of-range"); 22878dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis *(arg_begin() + I) = E; 22888dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis } 22898dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis 229063c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall SourceRange getSourceRange() const; 2291ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor 22921eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump static bool classof(const Stmt *T) { 2293d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor return T->getStmtClass() == CXXUnresolvedConstructExprClass; 2294d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor } 2295d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor static bool classof(const CXXUnresolvedConstructExpr *) { return true; } 2296d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor 2297d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor // Iterators 229863c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall child_range children() { 229963c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall Stmt **begin = reinterpret_cast<Stmt**>(this+1); 230063c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall return child_range(begin, begin + NumArgs); 230163c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall } 2302d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor}; 2303d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor 2304ba13543329afac4a0d01304ec2ec4924d99306a6John McCall/// \brief Represents a C++ member access expression where the actual 2305ba13543329afac4a0d01304ec2ec4924d99306a6John McCall/// member referenced could not be resolved because the base 2306ba13543329afac4a0d01304ec2ec4924d99306a6John McCall/// expression or the member name was dependent. 2307aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall/// 2308aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall/// Like UnresolvedMemberExprs, these can be either implicit or 2309aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall/// explicit accesses. It is only possible to get one of these with 2310aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall/// an implicit access if a qualifier is provided. 2311865d447ac6a4721ab58e898d014a21f2eff74b06John McCallclass CXXDependentScopeMemberExpr : public Expr { 23121c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor /// \brief The expression for the base pointer or class reference, 2313aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall /// e.g., the \c x in x.f. Can be null in implicit accesses. 23141c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor Stmt *Base; 23151eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 2316aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall /// \brief The type of the base expression. Never null, even for 2317aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall /// implicit accesses. 2318aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall QualType BaseType; 2319aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall 23201c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor /// \brief Whether this member expression used the '->' operator or 23211c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor /// the '.' operator. 23223b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor bool IsArrow : 1; 23231c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor 23243b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor /// \brief Whether this member expression has explicitly-specified template 23253b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor /// arguments. 2326aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall bool HasExplicitTemplateArgs : 1; 23271eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 23281c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor /// \brief The location of the '->' or '.' operator. 23291c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor SourceLocation OperatorLoc; 23301c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor 2331a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor /// \brief The nested-name-specifier that precedes the member name, if any. 23327c3179cf463c3b3b8c21dbb955f933ba50b74f28Douglas Gregor NestedNameSpecifierLoc QualifierLoc; 23331eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 2334c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor /// \brief In a qualified member access expression such as t->Base::f, this 23351eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump /// member stores the resolves of name lookup in the context of the member 2336c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor /// access expression, to be used at instantiation time. 2337c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor /// 233846bb4f1a3ac9517406887939612eb8df4b7be006Douglas Gregor /// FIXME: This member, along with the QualifierLoc, could 2339c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor /// be stuck into a structure that is optionally allocated at the end of 2340865d447ac6a4721ab58e898d014a21f2eff74b06John McCall /// the CXXDependentScopeMemberExpr, to save space in the common case. 2341c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor NamedDecl *FirstQualifierFoundInScope; 23421eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 23431c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor /// \brief The member to which this member expression refers, which 23441c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor /// can be name, overloaded operator, or destructor. 2345a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor /// FIXME: could also be a template-id 23462577743c5650c646fb705df01403707e94f2df04Abramo Bagnara DeclarationNameInfo MemberNameInfo; 23471eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 2348865d447ac6a4721ab58e898d014a21f2eff74b06John McCall CXXDependentScopeMemberExpr(ASTContext &C, 2349aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall Expr *Base, QualType BaseType, bool IsArrow, 23503b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor SourceLocation OperatorLoc, 23517c3179cf463c3b3b8c21dbb955f933ba50b74f28Douglas Gregor NestedNameSpecifierLoc QualifierLoc, 23523b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor NamedDecl *FirstQualifierFoundInScope, 23532577743c5650c646fb705df01403707e94f2df04Abramo Bagnara DeclarationNameInfo MemberNameInfo, 2354d5532b6cfff2977e0c59fa6ead7f7973984a620dJohn McCall const TemplateArgumentListInfo *TemplateArgs); 23551eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 23561c0ca59416999129d0439c2661d137ef38e86209Douglas Gregorpublic: 2357865d447ac6a4721ab58e898d014a21f2eff74b06John McCall CXXDependentScopeMemberExpr(ASTContext &C, 2358bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor Expr *Base, QualType BaseType, 2359bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor bool IsArrow, 2360bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor SourceLocation OperatorLoc, 23617c3179cf463c3b3b8c21dbb955f933ba50b74f28Douglas Gregor NestedNameSpecifierLoc QualifierLoc, 2362bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor NamedDecl *FirstQualifierFoundInScope, 2363bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor DeclarationNameInfo MemberNameInfo); 23641eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 2365865d447ac6a4721ab58e898d014a21f2eff74b06John McCall static CXXDependentScopeMemberExpr * 23661eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump Create(ASTContext &C, 2367aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall Expr *Base, QualType BaseType, bool IsArrow, 23683b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor SourceLocation OperatorLoc, 23697c3179cf463c3b3b8c21dbb955f933ba50b74f28Douglas Gregor NestedNameSpecifierLoc QualifierLoc, 23703b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor NamedDecl *FirstQualifierFoundInScope, 23712577743c5650c646fb705df01403707e94f2df04Abramo Bagnara DeclarationNameInfo MemberNameInfo, 2372d5532b6cfff2977e0c59fa6ead7f7973984a620dJohn McCall const TemplateArgumentListInfo *TemplateArgs); 23731eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 23748dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis static CXXDependentScopeMemberExpr * 2375def0354384d9c4431f7b58b664b59896d4623028Douglas Gregor CreateEmpty(ASTContext &C, bool HasExplicitTemplateArgs, 2376def0354384d9c4431f7b58b664b59896d4623028Douglas Gregor unsigned NumTemplateArgs); 23778dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis 2378aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall /// \brief True if this is an implicit access, i.e. one in which the 2379aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall /// member being accessed was not written in the source. The source 2380aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall /// location of the operator is invalid in this case. 23814c9be89bb615ec07eb3ed507c8fa9d0baa8a5ad7Douglas Gregor bool isImplicitAccess() const; 2382aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall 23831c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor /// \brief Retrieve the base object of this member expressions, 23841c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor /// e.g., the \c x in \c x.m. 2385aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall Expr *getBase() const { 2386aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall assert(!isImplicitAccess()); 2387aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall return cast<Expr>(Base); 2388aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall } 23891c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor 2390aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall QualType getBaseType() const { return BaseType; } 2391aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall 23921c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor /// \brief Determine whether this member expression used the '->' 23931c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor /// operator; otherwise, it used the '.' operator. 23941c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor bool isArrow() const { return IsArrow; } 23951c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor 23961c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor /// \brief Retrieve the location of the '->' or '.' operator. 23971c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor SourceLocation getOperatorLoc() const { return OperatorLoc; } 23981c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor 2399a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor /// \brief Retrieve the nested-name-specifier that qualifies the member 2400a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor /// name. 24017c3179cf463c3b3b8c21dbb955f933ba50b74f28Douglas Gregor NestedNameSpecifier *getQualifier() const { 24027c3179cf463c3b3b8c21dbb955f933ba50b74f28Douglas Gregor return QualifierLoc.getNestedNameSpecifier(); 24037c3179cf463c3b3b8c21dbb955f933ba50b74f28Douglas Gregor } 24041eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 24057c3179cf463c3b3b8c21dbb955f933ba50b74f28Douglas Gregor /// \brief Retrieve the nested-name-specifier that qualifies the member 24067c3179cf463c3b3b8c21dbb955f933ba50b74f28Douglas Gregor /// name, with source location information. 24077c3179cf463c3b3b8c21dbb955f933ba50b74f28Douglas Gregor NestedNameSpecifierLoc getQualifierLoc() const { return QualifierLoc; } 24087c3179cf463c3b3b8c21dbb955f933ba50b74f28Douglas Gregor 24097c3179cf463c3b3b8c21dbb955f933ba50b74f28Douglas Gregor 2410c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor /// \brief Retrieve the first part of the nested-name-specifier that was 2411c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor /// found in the scope of the member access expression when the member access 2412c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor /// was initially parsed. 2413c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor /// 2414c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor /// This function only returns a useful result when member access expression 24151eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump /// uses a qualified member name, e.g., "x.Base::f". Here, the declaration 24161eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump /// returned by this function describes what was found by unqualified name 2417c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor /// lookup for the identifier "Base" within the scope of the member access 2418c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor /// expression itself. At template instantiation time, this information is 2419c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor /// combined with the results of name lookup into the type of the object 2420c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor /// expression itself (the class type of x). 24211eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump NamedDecl *getFirstQualifierFoundInScope() const { 2422c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor return FirstQualifierFoundInScope; 2423c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor } 24241eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 24251c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor /// \brief Retrieve the name of the member that this expression 24261c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor /// refers to. 24272577743c5650c646fb705df01403707e94f2df04Abramo Bagnara const DeclarationNameInfo &getMemberNameInfo() const { 24282577743c5650c646fb705df01403707e94f2df04Abramo Bagnara return MemberNameInfo; 24292577743c5650c646fb705df01403707e94f2df04Abramo Bagnara } 24302577743c5650c646fb705df01403707e94f2df04Abramo Bagnara 24312577743c5650c646fb705df01403707e94f2df04Abramo Bagnara /// \brief Retrieve the name of the member that this expression 24322577743c5650c646fb705df01403707e94f2df04Abramo Bagnara /// refers to. 24332577743c5650c646fb705df01403707e94f2df04Abramo Bagnara DeclarationName getMember() const { return MemberNameInfo.getName(); } 24341c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor 24351c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor // \brief Retrieve the location of the name of the member that this 24361c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor // expression refers to. 24372577743c5650c646fb705df01403707e94f2df04Abramo Bagnara SourceLocation getMemberLoc() const { return MemberNameInfo.getLoc(); } 24381c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor 24393b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor /// \brief Determines whether this member expression actually had a C++ 24403b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor /// template argument list explicitly specified, e.g., x.f<int>. 2441aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall bool hasExplicitTemplateArgs() const { 2442aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall return HasExplicitTemplateArgs; 24433b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor } 24441eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 244536c76f0bea0d3595a25a5362225c642019cc3176Argyrios Kyrtzidis /// \brief Retrieve the explicit template argument list that followed the 244636c76f0bea0d3595a25a5362225c642019cc3176Argyrios Kyrtzidis /// member template name, if any. 2447096832c5ed5b9106fa177ebc148489760c3bc496John McCall ExplicitTemplateArgumentList &getExplicitTemplateArgs() { 244836c76f0bea0d3595a25a5362225c642019cc3176Argyrios Kyrtzidis assert(HasExplicitTemplateArgs); 2449096832c5ed5b9106fa177ebc148489760c3bc496John McCall return *reinterpret_cast<ExplicitTemplateArgumentList *>(this + 1); 245036c76f0bea0d3595a25a5362225c642019cc3176Argyrios Kyrtzidis } 245136c76f0bea0d3595a25a5362225c642019cc3176Argyrios Kyrtzidis 245236c76f0bea0d3595a25a5362225c642019cc3176Argyrios Kyrtzidis /// \brief Retrieve the explicit template argument list that followed the 245336c76f0bea0d3595a25a5362225c642019cc3176Argyrios Kyrtzidis /// member template name, if any. 2454096832c5ed5b9106fa177ebc148489760c3bc496John McCall const ExplicitTemplateArgumentList &getExplicitTemplateArgs() const { 245536c76f0bea0d3595a25a5362225c642019cc3176Argyrios Kyrtzidis return const_cast<CXXDependentScopeMemberExpr *>(this) 2456096832c5ed5b9106fa177ebc148489760c3bc496John McCall ->getExplicitTemplateArgs(); 2457096832c5ed5b9106fa177ebc148489760c3bc496John McCall } 2458096832c5ed5b9106fa177ebc148489760c3bc496John McCall 2459096832c5ed5b9106fa177ebc148489760c3bc496John McCall /// \brief Retrieves the optional explicit template arguments. 2460096832c5ed5b9106fa177ebc148489760c3bc496John McCall /// This points to the same data as getExplicitTemplateArgs(), but 2461096832c5ed5b9106fa177ebc148489760c3bc496John McCall /// returns null if there are no explicit template arguments. 2462096832c5ed5b9106fa177ebc148489760c3bc496John McCall const ExplicitTemplateArgumentList *getOptionalExplicitTemplateArgs() { 2463096832c5ed5b9106fa177ebc148489760c3bc496John McCall if (!hasExplicitTemplateArgs()) return 0; 2464096832c5ed5b9106fa177ebc148489760c3bc496John McCall return &getExplicitTemplateArgs(); 246536c76f0bea0d3595a25a5362225c642019cc3176Argyrios Kyrtzidis } 246636c76f0bea0d3595a25a5362225c642019cc3176Argyrios Kyrtzidis 2467d5532b6cfff2977e0c59fa6ead7f7973984a620dJohn McCall /// \brief Copies the template arguments (if present) into the given 2468d5532b6cfff2977e0c59fa6ead7f7973984a620dJohn McCall /// structure. 2469d5532b6cfff2977e0c59fa6ead7f7973984a620dJohn McCall void copyTemplateArgumentsInto(TemplateArgumentListInfo &List) const { 2470096832c5ed5b9106fa177ebc148489760c3bc496John McCall getExplicitTemplateArgs().copyInto(List); 2471d5532b6cfff2977e0c59fa6ead7f7973984a620dJohn McCall } 2472d5532b6cfff2977e0c59fa6ead7f7973984a620dJohn McCall 24738dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis /// \brief Initializes the template arguments using the given structure. 24748dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis void initializeTemplateArgumentsFrom(const TemplateArgumentListInfo &List) { 2475096832c5ed5b9106fa177ebc148489760c3bc496John McCall getExplicitTemplateArgs().initializeFrom(List); 24768dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis } 24778dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis 24781eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump /// \brief Retrieve the location of the left angle bracket following the 24793b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor /// member name ('<'), if any. 24801eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump SourceLocation getLAngleLoc() const { 2481096832c5ed5b9106fa177ebc148489760c3bc496John McCall return getExplicitTemplateArgs().LAngleLoc; 24823b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor } 24831eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 24843b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor /// \brief Retrieve the template arguments provided as part of this 24853b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor /// template-id. 2486833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall const TemplateArgumentLoc *getTemplateArgs() const { 2487096832c5ed5b9106fa177ebc148489760c3bc496John McCall return getExplicitTemplateArgs().getTemplateArgs(); 24883b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor } 24891eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 24903b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor /// \brief Retrieve the number of template arguments provided as part of this 24913b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor /// template-id. 24921eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump unsigned getNumTemplateArgs() const { 2493096832c5ed5b9106fa177ebc148489760c3bc496John McCall return getExplicitTemplateArgs().NumTemplateArgs; 24943b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor } 24951eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 24961eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump /// \brief Retrieve the location of the right angle bracket following the 24973b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor /// template arguments ('>'). 24981eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump SourceLocation getRAngleLoc() const { 2499096832c5ed5b9106fa177ebc148489760c3bc496John McCall return getExplicitTemplateArgs().RAngleLoc; 25003b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor } 25011eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 250263c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall SourceRange getSourceRange() const { 2503aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall SourceRange Range; 2504aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall if (!isImplicitAccess()) 2505aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall Range.setBegin(Base->getSourceRange().getBegin()); 2506aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall else if (getQualifier()) 25077c3179cf463c3b3b8c21dbb955f933ba50b74f28Douglas Gregor Range.setBegin(getQualifierLoc().getBeginLoc()); 2508aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall else 25092577743c5650c646fb705df01403707e94f2df04Abramo Bagnara Range.setBegin(MemberNameInfo.getBeginLoc()); 25101eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 2511aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall if (hasExplicitTemplateArgs()) 2512aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall Range.setEnd(getRAngleLoc()); 2513aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall else 25142577743c5650c646fb705df01403707e94f2df04Abramo Bagnara Range.setEnd(MemberNameInfo.getEndLoc()); 2515aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall return Range; 25161c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor } 25171eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 25181eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump static bool classof(const Stmt *T) { 2519865d447ac6a4721ab58e898d014a21f2eff74b06John McCall return T->getStmtClass() == CXXDependentScopeMemberExprClass; 25201c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor } 2521865d447ac6a4721ab58e898d014a21f2eff74b06John McCall static bool classof(const CXXDependentScopeMemberExpr *) { return true; } 25221c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor 25231c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor // Iterators 252463c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall child_range children() { 252563c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall if (isImplicitAccess()) return child_range(); 252663c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall return child_range(&Base, &Base + 1); 252763c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall } 25284045107b7384fd68eed5e3e2f06fc2a47e7be0a6Argyrios Kyrtzidis 25294045107b7384fd68eed5e3e2f06fc2a47e7be0a6Argyrios Kyrtzidis friend class ASTStmtReader; 25304045107b7384fd68eed5e3e2f06fc2a47e7be0a6Argyrios Kyrtzidis friend class ASTStmtWriter; 25311c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor}; 25321c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor 2533129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall/// \brief Represents a C++ member access expression for which lookup 2534aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall/// produced a set of overloaded functions. 2535aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall/// 2536aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall/// The member access may be explicit or implicit: 2537aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall/// struct A { 2538aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall/// int a, b; 2539aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall/// int explicitAccess() { return this->a + this->A::b; } 2540aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall/// int implicitAccess() { return a + A::b; } 2541aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall/// }; 2542aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall/// 2543aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall/// In the final AST, an explicit access always becomes a MemberExpr. 2544aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall/// An implicit access may become either a MemberExpr or a 2545aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall/// DeclRefExpr, depending on whether the member is static. 25467bb12da2b0749eeebb21854c77877736969e59f2John McCallclass UnresolvedMemberExpr : public OverloadExpr { 2547129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall /// \brief Whether this member expression used the '->' operator or 2548129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall /// the '.' operator. 2549129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall bool IsArrow : 1; 2550129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall 2551129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall /// \brief Whether the lookup results contain an unresolved using 2552129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall /// declaration. 2553129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall bool HasUnresolvedUsing : 1; 2554129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall 25557bb12da2b0749eeebb21854c77877736969e59f2John McCall /// \brief The expression for the base pointer or class reference, 25567bb12da2b0749eeebb21854c77877736969e59f2John McCall /// e.g., the \c x in x.f. This can be null if this is an 'unbased' 25577bb12da2b0749eeebb21854c77877736969e59f2John McCall /// member expression 25587bb12da2b0749eeebb21854c77877736969e59f2John McCall Stmt *Base; 25597bb12da2b0749eeebb21854c77877736969e59f2John McCall 25607bb12da2b0749eeebb21854c77877736969e59f2John McCall /// \brief The type of the base expression; never null. 25617bb12da2b0749eeebb21854c77877736969e59f2John McCall QualType BaseType; 2562129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall 2563129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall /// \brief The location of the '->' or '.' operator. 2564129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall SourceLocation OperatorLoc; 2565129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall 2566bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor UnresolvedMemberExpr(ASTContext &C, bool HasUnresolvedUsing, 2567aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall Expr *Base, QualType BaseType, bool IsArrow, 2568129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall SourceLocation OperatorLoc, 25694c9be89bb615ec07eb3ed507c8fa9d0baa8a5ad7Douglas Gregor NestedNameSpecifierLoc QualifierLoc, 25702577743c5650c646fb705df01403707e94f2df04Abramo Bagnara const DeclarationNameInfo &MemberNameInfo, 25715a84dec38cfa9e084377a3167b474c79283c82faDouglas Gregor const TemplateArgumentListInfo *TemplateArgs, 25725a84dec38cfa9e084377a3167b474c79283c82faDouglas Gregor UnresolvedSetIterator Begin, UnresolvedSetIterator End); 2573a77eb0862507b900a10fa352af1568e639ed10b1Argyrios Kyrtzidis 2574a77eb0862507b900a10fa352af1568e639ed10b1Argyrios Kyrtzidis UnresolvedMemberExpr(EmptyShell Empty) 2575a77eb0862507b900a10fa352af1568e639ed10b1Argyrios Kyrtzidis : OverloadExpr(UnresolvedMemberExprClass, Empty), IsArrow(false), 2576a77eb0862507b900a10fa352af1568e639ed10b1Argyrios Kyrtzidis HasUnresolvedUsing(false), Base(0) { } 2577129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall 25784c9be89bb615ec07eb3ed507c8fa9d0baa8a5ad7Douglas Gregor friend class ASTStmtReader; 25794c9be89bb615ec07eb3ed507c8fa9d0baa8a5ad7Douglas Gregor 2580129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCallpublic: 2581129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall static UnresolvedMemberExpr * 2582bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor Create(ASTContext &C, bool HasUnresolvedUsing, 2583aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall Expr *Base, QualType BaseType, bool IsArrow, 2584129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall SourceLocation OperatorLoc, 25854c9be89bb615ec07eb3ed507c8fa9d0baa8a5ad7Douglas Gregor NestedNameSpecifierLoc QualifierLoc, 25862577743c5650c646fb705df01403707e94f2df04Abramo Bagnara const DeclarationNameInfo &MemberNameInfo, 25875a84dec38cfa9e084377a3167b474c79283c82faDouglas Gregor const TemplateArgumentListInfo *TemplateArgs, 25885a84dec38cfa9e084377a3167b474c79283c82faDouglas Gregor UnresolvedSetIterator Begin, UnresolvedSetIterator End); 2589129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall 2590a77eb0862507b900a10fa352af1568e639ed10b1Argyrios Kyrtzidis static UnresolvedMemberExpr * 2591def0354384d9c4431f7b58b664b59896d4623028Douglas Gregor CreateEmpty(ASTContext &C, bool HasExplicitTemplateArgs, 2592def0354384d9c4431f7b58b664b59896d4623028Douglas Gregor unsigned NumTemplateArgs); 2593a77eb0862507b900a10fa352af1568e639ed10b1Argyrios Kyrtzidis 2594aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall /// \brief True if this is an implicit access, i.e. one in which the 2595aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall /// member being accessed was not written in the source. The source 2596aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall /// location of the operator is invalid in this case. 25974c9be89bb615ec07eb3ed507c8fa9d0baa8a5ad7Douglas Gregor bool isImplicitAccess() const; 2598aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall 2599129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall /// \brief Retrieve the base object of this member expressions, 2600129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall /// e.g., the \c x in \c x.m. 2601aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall Expr *getBase() { 2602aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall assert(!isImplicitAccess()); 2603aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall return cast<Expr>(Base); 2604aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall } 26052f27bf854f0519810b34afd209089cc75536b757John McCall const Expr *getBase() const { 26062f27bf854f0519810b34afd209089cc75536b757John McCall assert(!isImplicitAccess()); 26072f27bf854f0519810b34afd209089cc75536b757John McCall return cast<Expr>(Base); 26082f27bf854f0519810b34afd209089cc75536b757John McCall } 2609129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall 2610aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall QualType getBaseType() const { return BaseType; } 2611a77eb0862507b900a10fa352af1568e639ed10b1Argyrios Kyrtzidis 2612a77eb0862507b900a10fa352af1568e639ed10b1Argyrios Kyrtzidis /// \brief Determine whether the lookup results contain an unresolved using 2613a77eb0862507b900a10fa352af1568e639ed10b1Argyrios Kyrtzidis /// declaration. 2614a77eb0862507b900a10fa352af1568e639ed10b1Argyrios Kyrtzidis bool hasUnresolvedUsing() const { return HasUnresolvedUsing; } 2615aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall 2616129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall /// \brief Determine whether this member expression used the '->' 2617129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall /// operator; otherwise, it used the '.' operator. 2618129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall bool isArrow() const { return IsArrow; } 2619129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall 2620129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall /// \brief Retrieve the location of the '->' or '.' operator. 2621129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall SourceLocation getOperatorLoc() const { return OperatorLoc; } 2622129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall 2623c373d48502ca7683ab55385f5bd624d778eb288dJohn McCall /// \brief Retrieves the naming class of this lookup. 2624c373d48502ca7683ab55385f5bd624d778eb288dJohn McCall CXXRecordDecl *getNamingClass() const; 2625c373d48502ca7683ab55385f5bd624d778eb288dJohn McCall 26262577743c5650c646fb705df01403707e94f2df04Abramo Bagnara /// \brief Retrieve the full name info for the member that this expression 26272577743c5650c646fb705df01403707e94f2df04Abramo Bagnara /// refers to. 26282577743c5650c646fb705df01403707e94f2df04Abramo Bagnara const DeclarationNameInfo &getMemberNameInfo() const { return getNameInfo(); } 26292577743c5650c646fb705df01403707e94f2df04Abramo Bagnara 2630129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall /// \brief Retrieve the name of the member that this expression 2631129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall /// refers to. 26327bb12da2b0749eeebb21854c77877736969e59f2John McCall DeclarationName getMemberName() const { return getName(); } 2633129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall 2634129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall // \brief Retrieve the location of the name of the member that this 2635129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall // expression refers to. 26367bb12da2b0749eeebb21854c77877736969e59f2John McCall SourceLocation getMemberLoc() const { return getNameLoc(); } 2637129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall 26387bb12da2b0749eeebb21854c77877736969e59f2John McCall /// \brief Retrieve the explicit template argument list that followed the 26397bb12da2b0749eeebb21854c77877736969e59f2John McCall /// member template name. 26407bb12da2b0749eeebb21854c77877736969e59f2John McCall ExplicitTemplateArgumentList &getExplicitTemplateArgs() { 26417bb12da2b0749eeebb21854c77877736969e59f2John McCall assert(hasExplicitTemplateArgs()); 26427bb12da2b0749eeebb21854c77877736969e59f2John McCall return *reinterpret_cast<ExplicitTemplateArgumentList *>(this + 1); 26437bb12da2b0749eeebb21854c77877736969e59f2John McCall } 26447bb12da2b0749eeebb21854c77877736969e59f2John McCall 26457bb12da2b0749eeebb21854c77877736969e59f2John McCall /// \brief Retrieve the explicit template argument list that followed the 26467bb12da2b0749eeebb21854c77877736969e59f2John McCall /// member template name, if any. 26477bb12da2b0749eeebb21854c77877736969e59f2John McCall const ExplicitTemplateArgumentList &getExplicitTemplateArgs() const { 26487bb12da2b0749eeebb21854c77877736969e59f2John McCall assert(hasExplicitTemplateArgs()); 26497bb12da2b0749eeebb21854c77877736969e59f2John McCall return *reinterpret_cast<const ExplicitTemplateArgumentList *>(this + 1); 2650129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall } 2651129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall 2652096832c5ed5b9106fa177ebc148489760c3bc496John McCall /// \brief Retrieves the optional explicit template arguments. 2653096832c5ed5b9106fa177ebc148489760c3bc496John McCall /// This points to the same data as getExplicitTemplateArgs(), but 2654096832c5ed5b9106fa177ebc148489760c3bc496John McCall /// returns null if there are no explicit template arguments. 2655096832c5ed5b9106fa177ebc148489760c3bc496John McCall const ExplicitTemplateArgumentList *getOptionalExplicitTemplateArgs() { 2656096832c5ed5b9106fa177ebc148489760c3bc496John McCall if (!hasExplicitTemplateArgs()) return 0; 2657096832c5ed5b9106fa177ebc148489760c3bc496John McCall return &getExplicitTemplateArgs(); 2658096832c5ed5b9106fa177ebc148489760c3bc496John McCall } 2659096832c5ed5b9106fa177ebc148489760c3bc496John McCall 2660129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall /// \brief Copies the template arguments into the given structure. 2661129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall void copyTemplateArgumentsInto(TemplateArgumentListInfo &List) const { 26627bb12da2b0749eeebb21854c77877736969e59f2John McCall getExplicitTemplateArgs().copyInto(List); 2663129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall } 2664129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall 2665129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall /// \brief Retrieve the location of the left angle bracket following 2666129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall /// the member name ('<'). 2667129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall SourceLocation getLAngleLoc() const { 26687bb12da2b0749eeebb21854c77877736969e59f2John McCall return getExplicitTemplateArgs().LAngleLoc; 2669129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall } 2670129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall 2671129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall /// \brief Retrieve the template arguments provided as part of this 2672129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall /// template-id. 2673129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall const TemplateArgumentLoc *getTemplateArgs() const { 26747bb12da2b0749eeebb21854c77877736969e59f2John McCall return getExplicitTemplateArgs().getTemplateArgs(); 2675129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall } 2676129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall 2677129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall /// \brief Retrieve the number of template arguments provided as 2678129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall /// part of this template-id. 2679129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall unsigned getNumTemplateArgs() const { 26807bb12da2b0749eeebb21854c77877736969e59f2John McCall return getExplicitTemplateArgs().NumTemplateArgs; 2681129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall } 2682129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall 2683129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall /// \brief Retrieve the location of the right angle bracket 2684129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall /// following the template arguments ('>'). 2685129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall SourceLocation getRAngleLoc() const { 26867bb12da2b0749eeebb21854c77877736969e59f2John McCall return getExplicitTemplateArgs().RAngleLoc; 2687129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall } 2688129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall 268963c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall SourceRange getSourceRange() const { 26902577743c5650c646fb705df01403707e94f2df04Abramo Bagnara SourceRange Range = getMemberNameInfo().getSourceRange(); 2691aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall if (!isImplicitAccess()) 2692aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall Range.setBegin(Base->getSourceRange().getBegin()); 26934c9be89bb615ec07eb3ed507c8fa9d0baa8a5ad7Douglas Gregor else if (getQualifierLoc()) 26944c9be89bb615ec07eb3ed507c8fa9d0baa8a5ad7Douglas Gregor Range.setBegin(getQualifierLoc().getBeginLoc()); 2695aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall 2696129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall if (hasExplicitTemplateArgs()) 2697129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall Range.setEnd(getRAngleLoc()); 2698129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall return Range; 2699129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall } 2700129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall 2701129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall static bool classof(const Stmt *T) { 2702129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall return T->getStmtClass() == UnresolvedMemberExprClass; 2703129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall } 2704129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall static bool classof(const UnresolvedMemberExpr *) { return true; } 2705129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall 2706129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall // Iterators 270763c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall child_range children() { 270863c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall if (isImplicitAccess()) return child_range(); 270963c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall return child_range(&Base, &Base + 1); 271063c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall } 2711129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall}; 2712129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall 27132e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl/// \brief Represents a C++0x noexcept expression (C++ [expr.unary.noexcept]). 27142e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl/// 27152e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl/// The noexcept expression tests whether a given expression might throw. Its 27162e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl/// result is a boolean constant. 27172e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redlclass CXXNoexceptExpr : public Expr { 27182e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl bool Value : 1; 27192e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl Stmt *Operand; 27202e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl SourceRange Range; 27212e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl 2722c8aecc2dfb2e393d9eeaedeca22ff8cd7149af81Sebastian Redl friend class ASTStmtReader; 2723c8aecc2dfb2e393d9eeaedeca22ff8cd7149af81Sebastian Redl 27242e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redlpublic: 27252e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl CXXNoexceptExpr(QualType Ty, Expr *Operand, CanThrowResult Val, 27262e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl SourceLocation Keyword, SourceLocation RParen) 2727f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall : Expr(CXXNoexceptExprClass, Ty, VK_RValue, OK_Ordinary, 2728f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall /*TypeDependent*/false, 2729bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor /*ValueDependent*/Val == CT_Dependent, 2730bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor Operand->containsUnexpandedParameterPack()), 27316b219d082434394c1ac401390ec1d1967727815aSebastian Redl Value(Val == CT_Cannot), Operand(Operand), Range(Keyword, RParen) 27326b219d082434394c1ac401390ec1d1967727815aSebastian Redl { } 27336b219d082434394c1ac401390ec1d1967727815aSebastian Redl 27346b219d082434394c1ac401390ec1d1967727815aSebastian Redl CXXNoexceptExpr(EmptyShell Empty) 27356b219d082434394c1ac401390ec1d1967727815aSebastian Redl : Expr(CXXNoexceptExprClass, Empty) 27362e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl { } 27372e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl 27382e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl Expr *getOperand() const { return static_cast<Expr*>(Operand); } 27392e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl 274063c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall SourceRange getSourceRange() const { return Range; } 27412e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl 27422e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl bool getValue() const { return Value; } 27432e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl 27442e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl static bool classof(const Stmt *T) { 27452e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl return T->getStmtClass() == CXXNoexceptExprClass; 27462e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl } 27472e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl static bool classof(const CXXNoexceptExpr *) { return true; } 27482e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl 27492e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl // Iterators 275063c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall child_range children() { return child_range(&Operand, &Operand + 1); } 27512e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl}; 27522e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl 2753be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor/// \brief Represents a C++0x pack expansion that produces a sequence of 2754be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor/// expressions. 2755be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor/// 2756be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor/// A pack expansion expression contains a pattern (which itself is an 2757be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor/// expression) followed by an ellipsis. For example: 2758be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor/// 2759be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor/// \code 2760be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor/// template<typename F, typename ...Types> 2761be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor/// void forward(F f, Types &&...args) { 2762be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor/// f(static_cast<Types&&>(args)...); 2763be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor/// } 2764be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor/// \endcode 2765be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor/// 2766be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor/// Here, the argument to the function object \c f is a pack expansion whose 2767be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor/// pattern is \c static_cast<Types&&>(args). When the \c forward function 2768be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor/// template is instantiated, the pack expansion will instantiate to zero or 2769be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor/// or more function arguments to the function object \c f. 2770be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregorclass PackExpansionExpr : public Expr { 2771be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor SourceLocation EllipsisLoc; 277267fd1251aad51bb80d050b7fa5e506fef0ec8e02Douglas Gregor 277367fd1251aad51bb80d050b7fa5e506fef0ec8e02Douglas Gregor /// \brief The number of expansions that will be produced by this pack 277467fd1251aad51bb80d050b7fa5e506fef0ec8e02Douglas Gregor /// expansion expression, if known. 277567fd1251aad51bb80d050b7fa5e506fef0ec8e02Douglas Gregor /// 277667fd1251aad51bb80d050b7fa5e506fef0ec8e02Douglas Gregor /// When zero, the number of expansions is not known. Otherwise, this value 277767fd1251aad51bb80d050b7fa5e506fef0ec8e02Douglas Gregor /// is the number of expansions + 1. 277867fd1251aad51bb80d050b7fa5e506fef0ec8e02Douglas Gregor unsigned NumExpansions; 277967fd1251aad51bb80d050b7fa5e506fef0ec8e02Douglas Gregor 2780be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor Stmt *Pattern; 2781be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor 2782be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor friend class ASTStmtReader; 278367fd1251aad51bb80d050b7fa5e506fef0ec8e02Douglas Gregor friend class ASTStmtWriter; 2784be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor 2785be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregorpublic: 278667fd1251aad51bb80d050b7fa5e506fef0ec8e02Douglas Gregor PackExpansionExpr(QualType T, Expr *Pattern, SourceLocation EllipsisLoc, 278767fd1251aad51bb80d050b7fa5e506fef0ec8e02Douglas Gregor llvm::Optional<unsigned> NumExpansions) 2788be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor : Expr(PackExpansionExprClass, T, Pattern->getValueKind(), 2789be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor Pattern->getObjectKind(), /*TypeDependent=*/true, 2790be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor /*ValueDependent=*/true, /*ContainsUnexpandedParameterPack=*/false), 2791be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor EllipsisLoc(EllipsisLoc), 279267fd1251aad51bb80d050b7fa5e506fef0ec8e02Douglas Gregor NumExpansions(NumExpansions? *NumExpansions + 1 : 0), 2793be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor Pattern(Pattern) { } 2794be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor 2795be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor PackExpansionExpr(EmptyShell Empty) : Expr(PackExpansionExprClass, Empty) { } 2796be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor 2797be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor /// \brief Retrieve the pattern of the pack expansion. 2798be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor Expr *getPattern() { return reinterpret_cast<Expr *>(Pattern); } 2799be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor 2800be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor /// \brief Retrieve the pattern of the pack expansion. 2801be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor const Expr *getPattern() const { return reinterpret_cast<Expr *>(Pattern); } 2802be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor 2803be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor /// \brief Retrieve the location of the ellipsis that describes this pack 2804be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor /// expansion. 2805be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor SourceLocation getEllipsisLoc() const { return EllipsisLoc; } 2806be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor 280767fd1251aad51bb80d050b7fa5e506fef0ec8e02Douglas Gregor /// \brief Determine the number of expansions that will be produced when 280867fd1251aad51bb80d050b7fa5e506fef0ec8e02Douglas Gregor /// this pack expansion is instantiated, if already known. 280967fd1251aad51bb80d050b7fa5e506fef0ec8e02Douglas Gregor llvm::Optional<unsigned> getNumExpansions() const { 281067fd1251aad51bb80d050b7fa5e506fef0ec8e02Douglas Gregor if (NumExpansions) 281167fd1251aad51bb80d050b7fa5e506fef0ec8e02Douglas Gregor return NumExpansions - 1; 281267fd1251aad51bb80d050b7fa5e506fef0ec8e02Douglas Gregor 281367fd1251aad51bb80d050b7fa5e506fef0ec8e02Douglas Gregor return llvm::Optional<unsigned>(); 281467fd1251aad51bb80d050b7fa5e506fef0ec8e02Douglas Gregor } 281567fd1251aad51bb80d050b7fa5e506fef0ec8e02Douglas Gregor 281663c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall SourceRange getSourceRange() const { 281763c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall return SourceRange(Pattern->getLocStart(), EllipsisLoc); 281863c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall } 2819be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor 2820be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor static bool classof(const Stmt *T) { 2821be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor return T->getStmtClass() == PackExpansionExprClass; 2822be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor } 2823be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor static bool classof(const PackExpansionExpr *) { return true; } 2824be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor 2825be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor // Iterators 282663c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall child_range children() { 282763c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall return child_range(&Pattern, &Pattern + 1); 282863c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall } 2829be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor}; 2830be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor 28317bb12da2b0749eeebb21854c77877736969e59f2John McCallinline ExplicitTemplateArgumentList &OverloadExpr::getExplicitTemplateArgs() { 28327bb12da2b0749eeebb21854c77877736969e59f2John McCall if (isa<UnresolvedLookupExpr>(this)) 28337bb12da2b0749eeebb21854c77877736969e59f2John McCall return cast<UnresolvedLookupExpr>(this)->getExplicitTemplateArgs(); 28347bb12da2b0749eeebb21854c77877736969e59f2John McCall else 28357bb12da2b0749eeebb21854c77877736969e59f2John McCall return cast<UnresolvedMemberExpr>(this)->getExplicitTemplateArgs(); 28367bb12da2b0749eeebb21854c77877736969e59f2John McCall} 28377bb12da2b0749eeebb21854c77877736969e59f2John McCall 2838ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor/// \brief Represents an expression that computes the length of a parameter 2839ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor/// pack. 2840ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor/// 2841ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor/// \code 2842ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor/// template<typename ...Types> 2843ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor/// struct count { 2844ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor/// static const unsigned value = sizeof...(Types); 2845ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor/// }; 2846ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor/// \endcode 2847ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregorclass SizeOfPackExpr : public Expr { 2848ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor /// \brief The location of the 'sizeof' keyword. 2849ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor SourceLocation OperatorLoc; 2850ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor 2851ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor /// \brief The location of the name of the parameter pack. 2852ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor SourceLocation PackLoc; 2853ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor 2854ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor /// \brief The location of the closing parenthesis. 2855ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor SourceLocation RParenLoc; 2856ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor 2857ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor /// \brief The length of the parameter pack, if known. 2858ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor /// 2859ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor /// When this expression is value-dependent, the length of the parameter pack 2860ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor /// is unknown. When this expression is not value-dependent, the length is 2861ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor /// known. 2862ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor unsigned Length; 2863ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor 2864ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor /// \brief The parameter pack itself. 2865ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor NamedDecl *Pack; 2866ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor 2867ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor friend class ASTStmtReader; 2868ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor friend class ASTStmtWriter; 2869ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor 2870ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregorpublic: 2871ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor /// \brief Creates a value-dependent expression that computes the length of 2872ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor /// the given parameter pack. 2873ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor SizeOfPackExpr(QualType SizeType, SourceLocation OperatorLoc, NamedDecl *Pack, 2874ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor SourceLocation PackLoc, SourceLocation RParenLoc) 2875ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor : Expr(SizeOfPackExprClass, SizeType, VK_RValue, OK_Ordinary, 2876ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor /*TypeDependent=*/false, /*ValueDependent=*/true, 2877ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor /*ContainsUnexpandedParameterPack=*/false), 2878ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor OperatorLoc(OperatorLoc), PackLoc(PackLoc), RParenLoc(RParenLoc), 2879ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor Length(0), Pack(Pack) { } 2880ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor 2881ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor /// \brief Creates an expression that computes the length of 2882ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor /// the given parameter pack, which is already known. 2883ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor SizeOfPackExpr(QualType SizeType, SourceLocation OperatorLoc, NamedDecl *Pack, 2884ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor SourceLocation PackLoc, SourceLocation RParenLoc, 2885ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor unsigned Length) 2886ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor : Expr(SizeOfPackExprClass, SizeType, VK_RValue, OK_Ordinary, 2887ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor /*TypeDependent=*/false, /*ValueDependent=*/false, 2888ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor /*ContainsUnexpandedParameterPack=*/false), 2889ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor OperatorLoc(OperatorLoc), PackLoc(PackLoc), RParenLoc(RParenLoc), 2890ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor Length(Length), Pack(Pack) { } 2891ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor 2892ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor /// \brief Create an empty expression. 2893ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor SizeOfPackExpr(EmptyShell Empty) : Expr(SizeOfPackExprClass, Empty) { } 2894ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor 2895ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor /// \brief Determine the location of the 'sizeof' keyword. 2896ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor SourceLocation getOperatorLoc() const { return OperatorLoc; } 2897ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor 2898ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor /// \brief Determine the location of the parameter pack. 2899ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor SourceLocation getPackLoc() const { return PackLoc; } 2900ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor 2901ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor /// \brief Determine the location of the right parenthesis. 2902ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor SourceLocation getRParenLoc() const { return RParenLoc; } 2903ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor 2904ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor /// \brief Retrieve the parameter pack. 2905ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor NamedDecl *getPack() const { return Pack; } 2906ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor 2907ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor /// \brief Retrieve the length of the parameter pack. 2908ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor /// 2909c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor /// This routine may only be invoked when the expression is not 2910c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor /// value-dependent. 2911ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor unsigned getPackLength() const { 2912ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor assert(!isValueDependent() && 2913ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor "Cannot get the length of a value-dependent pack size expression"); 2914ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor return Length; 2915ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor } 2916ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor 291763c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall SourceRange getSourceRange() const { 291863c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall return SourceRange(OperatorLoc, RParenLoc); 291963c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall } 2920ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor 2921ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor static bool classof(const Stmt *T) { 2922ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor return T->getStmtClass() == SizeOfPackExprClass; 2923ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor } 2924ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor static bool classof(const SizeOfPackExpr *) { return true; } 2925ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor 2926ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor // Iterators 292763c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall child_range children() { return child_range(); } 2928ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor}; 2929c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor 2930c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor/// \brief Represents a reference to a non-type template parameter pack that 2931c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor/// has been substituted with a non-template argument pack. 2932c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor/// 2933c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor/// When a pack expansion in the source code contains multiple parameter packs 2934c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor/// and those parameter packs correspond to different levels of template 2935c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor/// parameter lists, this node node is used to represent a non-type template 2936c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor/// parameter pack from an outer level, which has already had its argument pack 2937c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor/// substituted but that still lives within a pack expansion that itself 2938c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor/// could not be instantiated. When actually performing a substitution into 2939c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor/// that pack expansion (e.g., when all template parameters have corresponding 2940c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor/// arguments), this type will be replaced with the appropriate underlying 2941c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor/// expression at the current pack substitution index. 2942c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregorclass SubstNonTypeTemplateParmPackExpr : public Expr { 2943c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor /// \brief The non-type template parameter pack itself. 2944c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor NonTypeTemplateParmDecl *Param; 2945c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor 2946c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor /// \brief A pointer to the set of template arguments that this 2947c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor /// parameter pack is instantiated with. 2948c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor const TemplateArgument *Arguments; 2949c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor 2950c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor /// \brief The number of template arguments in \c Arguments. 2951c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor unsigned NumArguments; 2952c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor 2953c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor /// \brief The location of the non-type template parameter pack reference. 2954c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor SourceLocation NameLoc; 2955c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor 2956c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor friend class ASTStmtReader; 2957c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor friend class ASTStmtWriter; 2958c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor 2959c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregorpublic: 2960c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor SubstNonTypeTemplateParmPackExpr(QualType T, 2961c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor NonTypeTemplateParmDecl *Param, 2962c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor SourceLocation NameLoc, 2963c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor const TemplateArgument &ArgPack); 2964c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor 2965c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor SubstNonTypeTemplateParmPackExpr(EmptyShell Empty) 2966c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor : Expr(SubstNonTypeTemplateParmPackExprClass, Empty) { } 2967c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor 2968c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor /// \brief Retrieve the non-type template parameter pack being substituted. 2969c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor NonTypeTemplateParmDecl *getParameterPack() const { return Param; } 2970c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor 2971c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor /// \brief Retrieve the location of the parameter pack name. 2972c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor SourceLocation getParameterPackLocation() const { return NameLoc; } 2973c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor 2974c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor /// \brief Retrieve the template argument pack containing the substituted 2975c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor /// template arguments. 2976c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor TemplateArgument getArgumentPack() const; 2977c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor 297863c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall SourceRange getSourceRange() const { return NameLoc; } 2979c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor 2980c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor static bool classof(const Stmt *T) { 2981c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor return T->getStmtClass() == SubstNonTypeTemplateParmPackExprClass; 2982c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor } 2983c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor static bool classof(const SubstNonTypeTemplateParmPackExpr *) { 2984c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor return true; 2985c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor } 2986c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor 2987c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor // Iterators 298863c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall child_range children() { return child_range(); } 2989c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor}; 299003e80030515c800d1ab44125b9052dfffd1bd04cDouglas Gregor 299103e80030515c800d1ab44125b9052dfffd1bd04cDouglas Gregor/// \brief Represents a prvalue temporary that written into memory so that 299203e80030515c800d1ab44125b9052dfffd1bd04cDouglas Gregor/// a reference can bind to it. 299303e80030515c800d1ab44125b9052dfffd1bd04cDouglas Gregor/// 299403e80030515c800d1ab44125b9052dfffd1bd04cDouglas Gregor/// Prvalue expressions are materialized when they need to have an address 299503e80030515c800d1ab44125b9052dfffd1bd04cDouglas Gregor/// in memory for a reference to bind to. This happens when binding a 299603e80030515c800d1ab44125b9052dfffd1bd04cDouglas Gregor/// reference to the result of a conversion, e.g., 299703e80030515c800d1ab44125b9052dfffd1bd04cDouglas Gregor/// 299803e80030515c800d1ab44125b9052dfffd1bd04cDouglas Gregor/// \code 299903e80030515c800d1ab44125b9052dfffd1bd04cDouglas Gregor/// const int &r = 1.0; 300003e80030515c800d1ab44125b9052dfffd1bd04cDouglas Gregor/// \endcode 300103e80030515c800d1ab44125b9052dfffd1bd04cDouglas Gregor/// 300203e80030515c800d1ab44125b9052dfffd1bd04cDouglas Gregor/// Here, 1.0 is implicitly converted to an \c int. That resulting \c int is 300303e80030515c800d1ab44125b9052dfffd1bd04cDouglas Gregor/// then materialized via a \c MaterializeTemporaryExpr, and the reference 300403e80030515c800d1ab44125b9052dfffd1bd04cDouglas Gregor/// binds to the temporary. \c MaterializeTemporaryExprs are always glvalues 300503e80030515c800d1ab44125b9052dfffd1bd04cDouglas Gregor/// (either an lvalue or an xvalue, depending on the kind of reference binding 300603e80030515c800d1ab44125b9052dfffd1bd04cDouglas Gregor/// to it), maintaining the invariant that references always bind to glvalues. 300703e80030515c800d1ab44125b9052dfffd1bd04cDouglas Gregorclass MaterializeTemporaryExpr : public Expr { 300803e80030515c800d1ab44125b9052dfffd1bd04cDouglas Gregor /// \brief The temporary-generating expression whose value will be 300903e80030515c800d1ab44125b9052dfffd1bd04cDouglas Gregor /// materialized. 301003e80030515c800d1ab44125b9052dfffd1bd04cDouglas Gregor Stmt *Temporary; 301103e80030515c800d1ab44125b9052dfffd1bd04cDouglas Gregor 301203e80030515c800d1ab44125b9052dfffd1bd04cDouglas Gregor friend class ASTStmtReader; 301303e80030515c800d1ab44125b9052dfffd1bd04cDouglas Gregor friend class ASTStmtWriter; 301403e80030515c800d1ab44125b9052dfffd1bd04cDouglas Gregor 301503e80030515c800d1ab44125b9052dfffd1bd04cDouglas Gregorpublic: 301603e80030515c800d1ab44125b9052dfffd1bd04cDouglas Gregor MaterializeTemporaryExpr(Expr *Temporary, bool BoundToLvalueReference) 301703e80030515c800d1ab44125b9052dfffd1bd04cDouglas Gregor : Expr(MaterializeTemporaryExprClass, Temporary->getType(), 301803e80030515c800d1ab44125b9052dfffd1bd04cDouglas Gregor BoundToLvalueReference? VK_LValue : VK_XValue, OK_Ordinary, 301903e80030515c800d1ab44125b9052dfffd1bd04cDouglas Gregor Temporary->isTypeDependent(), Temporary->isValueDependent(), 302003e80030515c800d1ab44125b9052dfffd1bd04cDouglas Gregor Temporary->containsUnexpandedParameterPack()), 302103e80030515c800d1ab44125b9052dfffd1bd04cDouglas Gregor Temporary(Temporary) { } 302203e80030515c800d1ab44125b9052dfffd1bd04cDouglas Gregor 302303e80030515c800d1ab44125b9052dfffd1bd04cDouglas Gregor MaterializeTemporaryExpr(EmptyShell Empty) 302403e80030515c800d1ab44125b9052dfffd1bd04cDouglas Gregor : Expr(MaterializeTemporaryExprClass, Empty) { } 302503e80030515c800d1ab44125b9052dfffd1bd04cDouglas Gregor 302603e80030515c800d1ab44125b9052dfffd1bd04cDouglas Gregor /// \brief Retrieve the temporary-generating subexpression whose value will 302703e80030515c800d1ab44125b9052dfffd1bd04cDouglas Gregor /// be materialized into a glvalue. 302803e80030515c800d1ab44125b9052dfffd1bd04cDouglas Gregor Expr *GetTemporaryExpr() const { return reinterpret_cast<Expr *>(Temporary); } 302903e80030515c800d1ab44125b9052dfffd1bd04cDouglas Gregor 303003e80030515c800d1ab44125b9052dfffd1bd04cDouglas Gregor /// \brief Determine whether this materialized temporary is bound to an 303103e80030515c800d1ab44125b9052dfffd1bd04cDouglas Gregor /// lvalue reference; otherwise, it's bound to an rvalue reference. 303203e80030515c800d1ab44125b9052dfffd1bd04cDouglas Gregor bool BoundToLvalueReference() const { 303303e80030515c800d1ab44125b9052dfffd1bd04cDouglas Gregor return getValueKind() == VK_LValue; 303403e80030515c800d1ab44125b9052dfffd1bd04cDouglas Gregor } 303503e80030515c800d1ab44125b9052dfffd1bd04cDouglas Gregor 303603e80030515c800d1ab44125b9052dfffd1bd04cDouglas Gregor SourceRange getSourceRange() const { return Temporary->getSourceRange(); } 303703e80030515c800d1ab44125b9052dfffd1bd04cDouglas Gregor 303803e80030515c800d1ab44125b9052dfffd1bd04cDouglas Gregor static bool classof(const Stmt *T) { 303903e80030515c800d1ab44125b9052dfffd1bd04cDouglas Gregor return T->getStmtClass() == MaterializeTemporaryExprClass; 304003e80030515c800d1ab44125b9052dfffd1bd04cDouglas Gregor } 304103e80030515c800d1ab44125b9052dfffd1bd04cDouglas Gregor static bool classof(const MaterializeTemporaryExpr *) { 304203e80030515c800d1ab44125b9052dfffd1bd04cDouglas Gregor return true; 304303e80030515c800d1ab44125b9052dfffd1bd04cDouglas Gregor } 304403e80030515c800d1ab44125b9052dfffd1bd04cDouglas Gregor 304503e80030515c800d1ab44125b9052dfffd1bd04cDouglas Gregor // Iterators 304603e80030515c800d1ab44125b9052dfffd1bd04cDouglas Gregor child_range children() { return child_range(&Temporary, &Temporary + 1); } 304703e80030515c800d1ab44125b9052dfffd1bd04cDouglas Gregor}; 3048ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor 30495f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer} // end namespace clang 30505f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 30515f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer#endif 3052