ExprCXX.h revision 561f81243f665cf2001caadc45df505f826b72d6
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, 333561f81243f665cf2001caadc45df505f826b72d6Douglas Gregor false, 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, 362561f81243f665cf2001caadc45df505f826b72d6Douglas Gregor false, 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(), 398561f81243f665cf2001caadc45df505f826b72d6Douglas Gregor Operand->getType()->isInstantiationDependentType(), 399bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor Operand->getType()->containsUnexpandedParameterPack()), 40057fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor Operand(Operand), Range(R) { } 40157fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor 40257fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor CXXTypeidExpr(QualType Ty, Expr *Operand, SourceRange R) 403f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall : Expr(CXXTypeidExprClass, Ty, VK_LValue, OK_Ordinary, 4042850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl // typeid is never type-dependent (C++ [temp.dep.expr]p4) 405bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor false, 4062850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl // typeid is value-dependent if the type or expression are dependent 407bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor Operand->isTypeDependent() || Operand->isValueDependent(), 408561f81243f665cf2001caadc45df505f826b72d6Douglas Gregor Operand->isInstantiationDependent(), 409bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor Operand->containsUnexpandedParameterPack()), 41057fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor Operand(Operand), Range(R) { } 411c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl 41214ab24f01e36d495fce183aa67b41e45cdd54f39Chris Lattner CXXTypeidExpr(EmptyShell Empty, bool isExpr) 41314ab24f01e36d495fce183aa67b41e45cdd54f39Chris Lattner : Expr(CXXTypeidExprClass, Empty) { 41414ab24f01e36d495fce183aa67b41e45cdd54f39Chris Lattner if (isExpr) 41514ab24f01e36d495fce183aa67b41e45cdd54f39Chris Lattner Operand = (Expr*)0; 41614ab24f01e36d495fce183aa67b41e45cdd54f39Chris Lattner else 41714ab24f01e36d495fce183aa67b41e45cdd54f39Chris Lattner Operand = (TypeSourceInfo*)0; 41814ab24f01e36d495fce183aa67b41e45cdd54f39Chris Lattner } 41914ab24f01e36d495fce183aa67b41e45cdd54f39Chris Lattner 42057fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor bool isTypeOperand() const { return Operand.is<TypeSourceInfo *>(); } 42157fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor 42257fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor /// \brief Retrieves the type operand of this typeid() expression after 42357fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor /// various required adjustments (removing reference types, cv-qualifiers). 42457fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor QualType getTypeOperand() const; 42557fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor 42657fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor /// \brief Retrieve source information for the type operand. 42757fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor TypeSourceInfo *getTypeOperandSourceInfo() const { 428c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl assert(isTypeOperand() && "Cannot call getTypeOperand for typeid(expr)"); 42957fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor return Operand.get<TypeSourceInfo *>(); 430c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl } 43114ab24f01e36d495fce183aa67b41e45cdd54f39Chris Lattner 43214ab24f01e36d495fce183aa67b41e45cdd54f39Chris Lattner void setTypeOperandSourceInfo(TypeSourceInfo *TSI) { 43314ab24f01e36d495fce183aa67b41e45cdd54f39Chris Lattner assert(isTypeOperand() && "Cannot call getTypeOperand for typeid(expr)"); 43414ab24f01e36d495fce183aa67b41e45cdd54f39Chris Lattner Operand = TSI; 43514ab24f01e36d495fce183aa67b41e45cdd54f39Chris Lattner } 43657fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor 43714ab24f01e36d495fce183aa67b41e45cdd54f39Chris Lattner Expr *getExprOperand() const { 438c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl assert(!isTypeOperand() && "Cannot call getExprOperand for typeid(type)"); 43957fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor return static_cast<Expr*>(Operand.get<Stmt *>()); 440c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl } 44114ab24f01e36d495fce183aa67b41e45cdd54f39Chris Lattner 442030854b95f7bfd86aaa8afd9ae1aff9768a37e9aChris Lattner void setExprOperand(Expr *E) { 443030854b95f7bfd86aaa8afd9ae1aff9768a37e9aChris Lattner assert(!isTypeOperand() && "Cannot call getExprOperand for typeid(type)"); 444030854b95f7bfd86aaa8afd9ae1aff9768a37e9aChris Lattner Operand = E; 445030854b95f7bfd86aaa8afd9ae1aff9768a37e9aChris Lattner } 446030854b95f7bfd86aaa8afd9ae1aff9768a37e9aChris Lattner 44763c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall SourceRange getSourceRange() const { return Range; } 44814ab24f01e36d495fce183aa67b41e45cdd54f39Chris Lattner void setSourceRange(SourceRange R) { Range = R; } 44914ab24f01e36d495fce183aa67b41e45cdd54f39Chris Lattner 450c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl static bool classof(const Stmt *T) { 451c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl return T->getStmtClass() == CXXTypeidExprClass; 452c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl } 453c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl static bool classof(const CXXTypeidExpr *) { return true; } 454c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl 455c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl // Iterators 45663c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall child_range children() { 45763c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall if (isTypeOperand()) return child_range(); 45863c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall Stmt **begin = reinterpret_cast<Stmt**>(&Operand); 45963c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall return child_range(begin, begin + 1); 46063c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall } 461c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl}; 462c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl 46301b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet/// CXXUuidofExpr - A microsoft C++ @c __uuidof expression, which gets 46401b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet/// the _GUID that corresponds to the supplied type or expression. 46501b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet/// 46601b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet/// This represents code like @c __uuidof(COMTYPE) or @c __uuidof(*comPtr) 46701b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichetclass CXXUuidofExpr : public Expr { 46801b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichetprivate: 46901b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet llvm::PointerUnion<Stmt *, TypeSourceInfo *> Operand; 47001b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet SourceRange Range; 47101b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet 47201b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichetpublic: 47301b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet CXXUuidofExpr(QualType Ty, TypeSourceInfo *Operand, SourceRange R) 4742e219b8d253dbb901206b14e5643cc9d0edd662bFrancois Pichet : Expr(CXXUuidofExprClass, Ty, VK_LValue, OK_Ordinary, 475bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor false, Operand->getType()->isDependentType(), 476561f81243f665cf2001caadc45df505f826b72d6Douglas Gregor Operand->getType()->isInstantiationDependentType(), 477bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor Operand->getType()->containsUnexpandedParameterPack()), 47801b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet Operand(Operand), Range(R) { } 47901b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet 48001b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet CXXUuidofExpr(QualType Ty, Expr *Operand, SourceRange R) 4812e219b8d253dbb901206b14e5643cc9d0edd662bFrancois Pichet : Expr(CXXUuidofExprClass, Ty, VK_LValue, OK_Ordinary, 482bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor false, Operand->isTypeDependent(), 483561f81243f665cf2001caadc45df505f826b72d6Douglas Gregor Operand->isInstantiationDependent(), 484bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor Operand->containsUnexpandedParameterPack()), 48501b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet Operand(Operand), Range(R) { } 48601b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet 48701b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet CXXUuidofExpr(EmptyShell Empty, bool isExpr) 48801b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet : Expr(CXXUuidofExprClass, Empty) { 48901b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet if (isExpr) 49001b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet Operand = (Expr*)0; 49101b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet else 49201b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet Operand = (TypeSourceInfo*)0; 49301b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet } 49401b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet 49501b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet bool isTypeOperand() const { return Operand.is<TypeSourceInfo *>(); } 49601b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet 49701b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet /// \brief Retrieves the type operand of this __uuidof() expression after 49801b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet /// various required adjustments (removing reference types, cv-qualifiers). 49901b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet QualType getTypeOperand() const; 50001b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet 50101b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet /// \brief Retrieve source information for the type operand. 50201b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet TypeSourceInfo *getTypeOperandSourceInfo() const { 50301b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet assert(isTypeOperand() && "Cannot call getTypeOperand for __uuidof(expr)"); 50401b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet return Operand.get<TypeSourceInfo *>(); 50501b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet } 50601b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet 50701b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet void setTypeOperandSourceInfo(TypeSourceInfo *TSI) { 50801b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet assert(isTypeOperand() && "Cannot call getTypeOperand for __uuidof(expr)"); 50901b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet Operand = TSI; 51001b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet } 51101b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet 51201b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet Expr *getExprOperand() const { 51301b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet assert(!isTypeOperand() && "Cannot call getExprOperand for __uuidof(type)"); 51401b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet return static_cast<Expr*>(Operand.get<Stmt *>()); 51501b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet } 51601b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet 51701b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet void setExprOperand(Expr *E) { 51801b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet assert(!isTypeOperand() && "Cannot call getExprOperand for __uuidof(type)"); 51901b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet Operand = E; 52001b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet } 52101b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet 52263c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall SourceRange getSourceRange() const { return Range; } 52301b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet void setSourceRange(SourceRange R) { Range = R; } 52401b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet 52501b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet static bool classof(const Stmt *T) { 52601b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet return T->getStmtClass() == CXXUuidofExprClass; 52701b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet } 52801b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet static bool classof(const CXXUuidofExpr *) { return true; } 52901b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet 53001b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet // Iterators 53163c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall child_range children() { 53263c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall if (isTypeOperand()) return child_range(); 53363c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall Stmt **begin = reinterpret_cast<Stmt**>(&Operand); 53463c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall return child_range(begin, begin + 1); 53563c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall } 53601b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet}; 53701b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet 538796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// CXXThisExpr - Represents the "this" expression in C++, which is a 539796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// pointer to the object on which the current member function is 540796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// executing (C++ [expr.prim]p3). Example: 541796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// 542796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// @code 543796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// class Foo { 544796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// public: 545796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// void bar(); 546796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// void test() { this->bar(); } 547796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// }; 548796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// @endcode 549796da18402f286b897782a298ae3b20c459c102eDouglas Gregorclass CXXThisExpr : public Expr { 550796da18402f286b897782a298ae3b20c459c102eDouglas Gregor SourceLocation Loc; 551828a197317288e3333b0ce6f5cedadd036e3531fDouglas Gregor bool Implicit : 1; 552828a197317288e3333b0ce6f5cedadd036e3531fDouglas Gregor 553796da18402f286b897782a298ae3b20c459c102eDouglas Gregorpublic: 554828a197317288e3333b0ce6f5cedadd036e3531fDouglas Gregor CXXThisExpr(SourceLocation L, QualType Type, bool isImplicit) 555f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall : Expr(CXXThisExprClass, Type, VK_RValue, OK_Ordinary, 5562850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl // 'this' is type-dependent if the class type of the enclosing 5572850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl // member function is dependent (C++ [temp.dep.expr]p2) 558bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor Type->isDependentType(), Type->isDependentType(), 559561f81243f665cf2001caadc45df505f826b72d6Douglas Gregor Type->isInstantiationDependentType(), 560bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor /*ContainsUnexpandedParameterPack=*/false), 561828a197317288e3333b0ce6f5cedadd036e3531fDouglas Gregor Loc(L), Implicit(isImplicit) { } 562796da18402f286b897782a298ae3b20c459c102eDouglas Gregor 5632fbdfcdf3bbf7b941853d38b123930755e837437Chris Lattner CXXThisExpr(EmptyShell Empty) : Expr(CXXThisExprClass, Empty) {} 5642fbdfcdf3bbf7b941853d38b123930755e837437Chris Lattner 5652fbdfcdf3bbf7b941853d38b123930755e837437Chris Lattner SourceLocation getLocation() const { return Loc; } 5662fbdfcdf3bbf7b941853d38b123930755e837437Chris Lattner void setLocation(SourceLocation L) { Loc = L; } 5672fbdfcdf3bbf7b941853d38b123930755e837437Chris Lattner 56863c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall SourceRange getSourceRange() const { return SourceRange(Loc); } 569796da18402f286b897782a298ae3b20c459c102eDouglas Gregor 570828a197317288e3333b0ce6f5cedadd036e3531fDouglas Gregor bool isImplicit() const { return Implicit; } 571828a197317288e3333b0ce6f5cedadd036e3531fDouglas Gregor void setImplicit(bool I) { Implicit = I; } 572828a197317288e3333b0ce6f5cedadd036e3531fDouglas Gregor 5731eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump static bool classof(const Stmt *T) { 574796da18402f286b897782a298ae3b20c459c102eDouglas Gregor return T->getStmtClass() == CXXThisExprClass; 575796da18402f286b897782a298ae3b20c459c102eDouglas Gregor } 576796da18402f286b897782a298ae3b20c459c102eDouglas Gregor static bool classof(const CXXThisExpr *) { return true; } 577796da18402f286b897782a298ae3b20c459c102eDouglas Gregor 578796da18402f286b897782a298ae3b20c459c102eDouglas Gregor // Iterators 57963c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall child_range children() { return child_range(); } 580796da18402f286b897782a298ae3b20c459c102eDouglas Gregor}; 581796da18402f286b897782a298ae3b20c459c102eDouglas Gregor 5821060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek/// CXXThrowExpr - [C++ 15] C++ Throw Expression. This handles 5831060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek/// 'throw' and 'throw' assignment-expression. When 5841060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek/// assignment-expression isn't present, Op will be null. 5851060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek/// 5861060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenekclass CXXThrowExpr : public Expr { 5871060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek Stmt *Op; 5881060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek SourceLocation ThrowLoc; 5891060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenekpublic: 5901060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek // Ty is the void type which is used as the result type of the 5911060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek // exepression. The l is the location of the throw keyword. expr 5921060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek // can by null, if the optional expression to throw isn't present. 5931060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek CXXThrowExpr(Expr *expr, QualType Ty, SourceLocation l) : 594bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor Expr(CXXThrowExprClass, Ty, VK_RValue, OK_Ordinary, false, false, 595561f81243f665cf2001caadc45df505f826b72d6Douglas Gregor expr && expr->isInstantiationDependent(), 596bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor expr && expr->containsUnexpandedParameterPack()), 597f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall Op(expr), ThrowLoc(l) {} 5982fbdfcdf3bbf7b941853d38b123930755e837437Chris Lattner CXXThrowExpr(EmptyShell Empty) : Expr(CXXThrowExprClass, Empty) {} 5992fbdfcdf3bbf7b941853d38b123930755e837437Chris Lattner 6001060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek const Expr *getSubExpr() const { return cast_or_null<Expr>(Op); } 6011060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek Expr *getSubExpr() { return cast_or_null<Expr>(Op); } 60242e5b50f4dc897f252e0d476063a7f9846d96624Douglas Gregor void setSubExpr(Expr *E) { Op = E; } 60342e5b50f4dc897f252e0d476063a7f9846d96624Douglas Gregor 60442e5b50f4dc897f252e0d476063a7f9846d96624Douglas Gregor SourceLocation getThrowLoc() const { return ThrowLoc; } 60542e5b50f4dc897f252e0d476063a7f9846d96624Douglas Gregor void setThrowLoc(SourceLocation L) { ThrowLoc = L; } 6061060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek 60763c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall SourceRange getSourceRange() const { 6081060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek if (getSubExpr() == 0) 6091060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek return SourceRange(ThrowLoc, ThrowLoc); 6101060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek return SourceRange(ThrowLoc, getSubExpr()->getSourceRange().getEnd()); 6111060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek } 6121060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek 6131060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek static bool classof(const Stmt *T) { 6141060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek return T->getStmtClass() == CXXThrowExprClass; 6151060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek } 6161060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek static bool classof(const CXXThrowExpr *) { return true; } 6171060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek 6181060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek // Iterators 61963c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall child_range children() { 62063c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall return child_range(&Op, Op ? &Op+1 : &Op); 62163c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall } 6221060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek}; 6231060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek 6241060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek/// CXXDefaultArgExpr - C++ [dcl.fct.default]. This wraps up a 6251060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek/// function call argument that was created from the corresponding 6261060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek/// parameter's default argument, when the call did not explicitly 6271060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek/// supply arguments for all of the parameters. 6281060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenekclass CXXDefaultArgExpr : public Expr { 62965222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor /// \brief The parameter whose default is being used. 63065222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor /// 63165222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor /// When the bit is set, the subexpression is stored after the 63265222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor /// CXXDefaultArgExpr itself. When the bit is clear, the parameter's 63365222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor /// actual default expression is the subexpression. 63465222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor llvm::PointerIntPair<ParmVarDecl *, 1, bool> Param; 6351eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 636036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor /// \brief The location where the default argument expression was used. 637036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor SourceLocation Loc; 638036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor 639036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor CXXDefaultArgExpr(StmtClass SC, SourceLocation Loc, ParmVarDecl *param) 64065222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor : Expr(SC, 64165222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor param->hasUnparsedDefaultArg() 64265222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor ? param->getType().getNonReferenceType() 6432333f7727f97018d6742e1e0938133bcfad967abEli Friedman : param->getDefaultArg()->getType(), 644dfa1edbebeda7ec3a7a9c45e4317de9241aa9883John McCall param->getDefaultArg()->getValueKind(), 645561f81243f665cf2001caadc45df505f826b72d6Douglas Gregor param->getDefaultArg()->getObjectKind(), false, false, false, false), 646036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor Param(param, false), Loc(Loc) { } 64765222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor 648036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor CXXDefaultArgExpr(StmtClass SC, SourceLocation Loc, ParmVarDecl *param, 649036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor Expr *SubExpr) 650dfa1edbebeda7ec3a7a9c45e4317de9241aa9883John McCall : Expr(SC, SubExpr->getType(), 651dfa1edbebeda7ec3a7a9c45e4317de9241aa9883John McCall SubExpr->getValueKind(), SubExpr->getObjectKind(), 652561f81243f665cf2001caadc45df505f826b72d6Douglas Gregor false, false, false, false), 653bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor Param(param, true), Loc(Loc) { 65465222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor *reinterpret_cast<Expr **>(this + 1) = SubExpr; 65565222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor } 65665222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor 6571060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenekpublic: 658030854b95f7bfd86aaa8afd9ae1aff9768a37e9aChris Lattner CXXDefaultArgExpr(EmptyShell Empty) : Expr(CXXDefaultArgExprClass, Empty) {} 659030854b95f7bfd86aaa8afd9ae1aff9768a37e9aChris Lattner 660030854b95f7bfd86aaa8afd9ae1aff9768a37e9aChris Lattner 6611060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek // Param is the parameter whose default argument is used by this 6621060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek // expression. 663036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor static CXXDefaultArgExpr *Create(ASTContext &C, SourceLocation Loc, 664036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor ParmVarDecl *Param) { 665036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor return new (C) CXXDefaultArgExpr(CXXDefaultArgExprClass, Loc, Param); 666f1480eee38b59d15438fb7bc50865ac7c7e22403Anders Carlsson } 6671060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek 66865222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor // Param is the parameter whose default argument is used by this 66965222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor // expression, and SubExpr is the expression that will actually be used. 670036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor static CXXDefaultArgExpr *Create(ASTContext &C, 671036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor SourceLocation Loc, 672036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor ParmVarDecl *Param, 67365222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor Expr *SubExpr); 67465222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor 6751060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek // Retrieve the parameter that the argument was created from. 67665222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor const ParmVarDecl *getParam() const { return Param.getPointer(); } 67765222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor ParmVarDecl *getParam() { return Param.getPointer(); } 678030854b95f7bfd86aaa8afd9ae1aff9768a37e9aChris Lattner 6791060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek // Retrieve the actual argument to the function call. 68065222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor const Expr *getExpr() const { 68165222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor if (Param.getInt()) 68265222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor return *reinterpret_cast<Expr const * const*> (this + 1); 68365222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor return getParam()->getDefaultArg(); 68465222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor } 68565222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor Expr *getExpr() { 68665222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor if (Param.getInt()) 68765222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor return *reinterpret_cast<Expr **> (this + 1); 68865222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor return getParam()->getDefaultArg(); 68965222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor } 6901060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek 691036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor /// \brief Retrieve the location where this default argument was actually 692036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor /// used. 693036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor SourceLocation getUsedLocation() const { return Loc; } 694036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor 69563c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall SourceRange getSourceRange() const { 6961060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek // Default argument expressions have no representation in the 6971060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek // source, so they have an empty source range. 6981060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek return SourceRange(); 6991060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek } 7001060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek 7011060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek static bool classof(const Stmt *T) { 7021060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek return T->getStmtClass() == CXXDefaultArgExprClass; 7031060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek } 7041060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek static bool classof(const CXXDefaultArgExpr *) { return true; } 7051060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek 7061060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek // Iterators 70763c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall child_range children() { return child_range(); } 7088a50733034edd6a349b34e2b9f0c8d0a874846d3Argyrios Kyrtzidis 70960adf4acf40b72227740bf966fb87eebddff3f37Sebastian Redl friend class ASTStmtReader; 7103397c5570369f19b2d6c52e898f708d75ceede1fSebastian Redl friend class ASTStmtWriter; 7111060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek}; 712987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis 713c1ce477119fed070299668aab24084b17ff5f14bAnders Carlsson/// CXXTemporary - Represents a C++ temporary. 714c1ce477119fed070299668aab24084b17ff5f14bAnders Carlssonclass CXXTemporary { 715c1ce477119fed070299668aab24084b17ff5f14bAnders Carlsson /// Destructor - The destructor that needs to be called. 716b859f35459ae3e1188d1e1b86df08d649695fd86Anders Carlsson const CXXDestructorDecl *Destructor; 7171eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 718b859f35459ae3e1188d1e1b86df08d649695fd86Anders Carlsson CXXTemporary(const CXXDestructorDecl *destructor) 719c1ce477119fed070299668aab24084b17ff5f14bAnders Carlsson : Destructor(destructor) { } 720c1ce477119fed070299668aab24084b17ff5f14bAnders Carlsson 721c1ce477119fed070299668aab24084b17ff5f14bAnders Carlssonpublic: 7221eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump static CXXTemporary *Create(ASTContext &C, 723b859f35459ae3e1188d1e1b86df08d649695fd86Anders Carlsson const CXXDestructorDecl *Destructor); 7241eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 725f0721fe438d7e40c168e5d664970e7830bc138fbAnders Carlsson const CXXDestructorDecl *getDestructor() const { return Destructor; } 726c1ce477119fed070299668aab24084b17ff5f14bAnders Carlsson}; 727fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson 728ddfe960d252a93525692b547945236d361d1929fChandler Carruth/// \brief Represents binding an expression to a temporary. 729ddfe960d252a93525692b547945236d361d1929fChandler Carruth/// 730ddfe960d252a93525692b547945236d361d1929fChandler Carruth/// This ensures the destructor is called for the temporary. It should only be 731ddfe960d252a93525692b547945236d361d1929fChandler Carruth/// needed for non-POD, non-trivially destructable class types. For example: 732ddfe960d252a93525692b547945236d361d1929fChandler Carruth/// 733ddfe960d252a93525692b547945236d361d1929fChandler Carruth/// \code 734ddfe960d252a93525692b547945236d361d1929fChandler Carruth/// struct S { 735ddfe960d252a93525692b547945236d361d1929fChandler Carruth/// S() { } // User defined constructor makes S non-POD. 736ddfe960d252a93525692b547945236d361d1929fChandler Carruth/// ~S() { } // User defined destructor makes it non-trivial. 737ddfe960d252a93525692b547945236d361d1929fChandler Carruth/// }; 738ddfe960d252a93525692b547945236d361d1929fChandler Carruth/// void test() { 739ddfe960d252a93525692b547945236d361d1929fChandler Carruth/// const S &s_ref = S(); // Requires a CXXBindTemporaryExpr. 740ddfe960d252a93525692b547945236d361d1929fChandler Carruth/// } 741ddfe960d252a93525692b547945236d361d1929fChandler Carruth/// \endcode 742fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlssonclass CXXBindTemporaryExpr : public Expr { 743fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson CXXTemporary *Temp; 7441eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 745fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson Stmt *SubExpr; 746fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson 747bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor CXXBindTemporaryExpr(CXXTemporary *temp, Expr* SubExpr) 748bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor : Expr(CXXBindTemporaryExprClass, SubExpr->getType(), 749bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor VK_RValue, OK_Ordinary, SubExpr->isTypeDependent(), 750bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor SubExpr->isValueDependent(), 751561f81243f665cf2001caadc45df505f826b72d6Douglas Gregor SubExpr->isInstantiationDependent(), 752bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor SubExpr->containsUnexpandedParameterPack()), 753bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor Temp(temp), SubExpr(SubExpr) { } 75488eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlsson 755fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlssonpublic: 756d2598368876cfe40bc8465540033bc5b5e58d8afChris Lattner CXXBindTemporaryExpr(EmptyShell Empty) 757d2598368876cfe40bc8465540033bc5b5e58d8afChris Lattner : Expr(CXXBindTemporaryExprClass, Empty), Temp(0), SubExpr(0) {} 758d2598368876cfe40bc8465540033bc5b5e58d8afChris Lattner 7591eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump static CXXBindTemporaryExpr *Create(ASTContext &C, CXXTemporary *Temp, 760fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson Expr* SubExpr); 7611eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 76288eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlsson CXXTemporary *getTemporary() { return Temp; } 763f0721fe438d7e40c168e5d664970e7830bc138fbAnders Carlsson const CXXTemporary *getTemporary() const { return Temp; } 764d2598368876cfe40bc8465540033bc5b5e58d8afChris Lattner void setTemporary(CXXTemporary *T) { Temp = T; } 765f0721fe438d7e40c168e5d664970e7830bc138fbAnders Carlsson 766fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson const Expr *getSubExpr() const { return cast<Expr>(SubExpr); } 767fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson Expr *getSubExpr() { return cast<Expr>(SubExpr); } 76888eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlsson void setSubExpr(Expr *E) { SubExpr = E; } 769fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson 77063c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall SourceRange getSourceRange() const { 77196be6917e1c4ba1f4435a14c9e7c6c139571d086Douglas Gregor return SubExpr->getSourceRange(); 77296be6917e1c4ba1f4435a14c9e7c6c139571d086Douglas Gregor } 773fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson 774fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson // Implement isa/cast/dyncast/etc. 775fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson static bool classof(const Stmt *T) { 776fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson return T->getStmtClass() == CXXBindTemporaryExprClass; 777fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson } 778fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson static bool classof(const CXXBindTemporaryExpr *) { return true; } 779fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson 780fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson // Iterators 78163c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall child_range children() { return child_range(&SubExpr, &SubExpr + 1); } 782fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson}; 783fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson 78415ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson/// CXXConstructExpr - Represents a call to a C++ constructor. 78515ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlssonclass CXXConstructExpr : public Expr { 78672e96fd181b19b8d01144a685cda6e955584c7eaAnders Carlssonpublic: 78772e96fd181b19b8d01144a685cda6e955584c7eaAnders Carlsson enum ConstructionKind { 78872e96fd181b19b8d01144a685cda6e955584c7eaAnders Carlsson CK_Complete, 78972e96fd181b19b8d01144a685cda6e955584c7eaAnders Carlsson CK_NonVirtualBase, 790059ce0d92eb5a7da900ae735dc0a2ea3d64f4b0bSean Hunt CK_VirtualBase, 791059ce0d92eb5a7da900ae735dc0a2ea3d64f4b0bSean Hunt CK_Delegating 79272e96fd181b19b8d01144a685cda6e955584c7eaAnders Carlsson }; 79372e96fd181b19b8d01144a685cda6e955584c7eaAnders Carlsson 79472e96fd181b19b8d01144a685cda6e955584c7eaAnders Carlssonprivate: 79515ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson CXXConstructorDecl *Constructor; 79615ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson 79799a2e600f9e2e51d3ce10fb6f27191677ac65b2aDouglas Gregor SourceLocation Loc; 798428edafa9eb80e01dd40aab31d4166a787a741e1Chandler Carruth SourceRange ParenRange; 79916006c901315fa12a108b4e571f187f4b676e426Douglas Gregor bool Elidable : 1; 80016006c901315fa12a108b4e571f187f4b676e426Douglas Gregor bool ZeroInitialization : 1; 80172e96fd181b19b8d01144a685cda6e955584c7eaAnders Carlsson unsigned ConstructKind : 2; 80215ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson Stmt **Args; 80315ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson unsigned NumArgs; 8041eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 805bd6734e5f6432ce0cc07171c490ffaa094796198Anders Carlssonprotected: 8061eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump CXXConstructExpr(ASTContext &C, StmtClass SC, QualType T, 80799a2e600f9e2e51d3ce10fb6f27191677ac65b2aDouglas Gregor SourceLocation Loc, 808bd6734e5f6432ce0cc07171c490ffaa094796198Anders Carlsson CXXConstructorDecl *d, bool elidable, 80916006c901315fa12a108b4e571f187f4b676e426Douglas Gregor Expr **args, unsigned numargs, 8109db7dbb918ca49f4ee6c181e4917e7b6ec547353Douglas Gregor bool ZeroInitialization = false, 811428edafa9eb80e01dd40aab31d4166a787a741e1Chandler Carruth ConstructionKind ConstructKind = CK_Complete, 812428edafa9eb80e01dd40aab31d4166a787a741e1Chandler Carruth SourceRange ParenRange = SourceRange()); 813bd6734e5f6432ce0cc07171c490ffaa094796198Anders Carlsson 8146d00c1365dd3601f6d93bbda9162913c57ae788fArgyrios Kyrtzidis /// \brief Construct an empty C++ construction expression. 8156d00c1365dd3601f6d93bbda9162913c57ae788fArgyrios Kyrtzidis CXXConstructExpr(StmtClass SC, EmptyShell Empty) 8166d00c1365dd3601f6d93bbda9162913c57ae788fArgyrios Kyrtzidis : Expr(SC, Empty), Constructor(0), Elidable(0), ZeroInitialization(0), 8176d00c1365dd3601f6d93bbda9162913c57ae788fArgyrios Kyrtzidis ConstructKind(0), Args(0), NumArgs(0) { } 8186d00c1365dd3601f6d93bbda9162913c57ae788fArgyrios Kyrtzidis 81915ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlssonpublic: 8206d00c1365dd3601f6d93bbda9162913c57ae788fArgyrios Kyrtzidis /// \brief Construct an empty C++ construction expression. 8216d00c1365dd3601f6d93bbda9162913c57ae788fArgyrios Kyrtzidis explicit CXXConstructExpr(EmptyShell Empty) 8226d00c1365dd3601f6d93bbda9162913c57ae788fArgyrios Kyrtzidis : Expr(CXXConstructExprClass, Empty), Constructor(0), 8236d00c1365dd3601f6d93bbda9162913c57ae788fArgyrios Kyrtzidis Elidable(0), ZeroInitialization(0), 8246d00c1365dd3601f6d93bbda9162913c57ae788fArgyrios Kyrtzidis ConstructKind(0), Args(0), NumArgs(0) { } 8256d00c1365dd3601f6d93bbda9162913c57ae788fArgyrios Kyrtzidis 8268e587a15da6d3457a418239d5eb4146fcbd209f3Anders Carlsson static CXXConstructExpr *Create(ASTContext &C, QualType T, 82799a2e600f9e2e51d3ce10fb6f27191677ac65b2aDouglas Gregor SourceLocation Loc, 8281eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump CXXConstructorDecl *D, bool Elidable, 82916006c901315fa12a108b4e571f187f4b676e426Douglas Gregor Expr **Args, unsigned NumArgs, 8309db7dbb918ca49f4ee6c181e4917e7b6ec547353Douglas Gregor bool ZeroInitialization = false, 831428edafa9eb80e01dd40aab31d4166a787a741e1Chandler Carruth ConstructionKind ConstructKind = CK_Complete, 832428edafa9eb80e01dd40aab31d4166a787a741e1Chandler Carruth SourceRange ParenRange = SourceRange()); 8331eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 8341eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 835d94546a0a1deef7286c13e49b9584621ae81cc9aDouglas Gregor CXXConstructorDecl* getConstructor() const { return Constructor; } 83639da0b8145eaec7da7004f9b3645c5c9f4f63b1dDouglas Gregor void setConstructor(CXXConstructorDecl *C) { Constructor = C; } 83739da0b8145eaec7da7004f9b3645c5c9f4f63b1dDouglas Gregor 83899a2e600f9e2e51d3ce10fb6f27191677ac65b2aDouglas Gregor SourceLocation getLocation() const { return Loc; } 83999a2e600f9e2e51d3ce10fb6f27191677ac65b2aDouglas Gregor void setLocation(SourceLocation Loc) { this->Loc = Loc; } 84099a2e600f9e2e51d3ce10fb6f27191677ac65b2aDouglas Gregor 841d94546a0a1deef7286c13e49b9584621ae81cc9aDouglas Gregor /// \brief Whether this construction is elidable. 842d94546a0a1deef7286c13e49b9584621ae81cc9aDouglas Gregor bool isElidable() const { return Elidable; } 84339da0b8145eaec7da7004f9b3645c5c9f4f63b1dDouglas Gregor void setElidable(bool E) { Elidable = E; } 84439da0b8145eaec7da7004f9b3645c5c9f4f63b1dDouglas Gregor 84516006c901315fa12a108b4e571f187f4b676e426Douglas Gregor /// \brief Whether this construction first requires 84616006c901315fa12a108b4e571f187f4b676e426Douglas Gregor /// zero-initialization before the initializer is called. 84716006c901315fa12a108b4e571f187f4b676e426Douglas Gregor bool requiresZeroInitialization() const { return ZeroInitialization; } 84816006c901315fa12a108b4e571f187f4b676e426Douglas Gregor void setRequiresZeroInitialization(bool ZeroInit) { 84916006c901315fa12a108b4e571f187f4b676e426Douglas Gregor ZeroInitialization = ZeroInit; 85016006c901315fa12a108b4e571f187f4b676e426Douglas Gregor } 85116006c901315fa12a108b4e571f187f4b676e426Douglas Gregor 8529db7dbb918ca49f4ee6c181e4917e7b6ec547353Douglas Gregor /// \brief Determines whether this constructor is actually constructing 8539db7dbb918ca49f4ee6c181e4917e7b6ec547353Douglas Gregor /// a base class (rather than a complete object). 85424eb78e38aba55c507bc3c05c37035a9ab2defa7Anders Carlsson ConstructionKind getConstructionKind() const { 85524eb78e38aba55c507bc3c05c37035a9ab2defa7Anders Carlsson return (ConstructionKind)ConstructKind; 85672e96fd181b19b8d01144a685cda6e955584c7eaAnders Carlsson } 85772e96fd181b19b8d01144a685cda6e955584c7eaAnders Carlsson void setConstructionKind(ConstructionKind CK) { 85872e96fd181b19b8d01144a685cda6e955584c7eaAnders Carlsson ConstructKind = CK; 85972e96fd181b19b8d01144a685cda6e955584c7eaAnders Carlsson } 8609db7dbb918ca49f4ee6c181e4917e7b6ec547353Douglas Gregor 86115ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson typedef ExprIterator arg_iterator; 86215ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson typedef ConstExprIterator const_arg_iterator; 8631eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 86415ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson arg_iterator arg_begin() { return Args; } 86515ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson arg_iterator arg_end() { return Args + NumArgs; } 86615ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson const_arg_iterator arg_begin() const { return Args; } 86715ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson const_arg_iterator arg_end() const { return Args + NumArgs; } 86815ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson 869a88cfbfac9bbcbb9858f048d6d73a48711d8e93dDouglas Gregor Expr **getArgs() const { return reinterpret_cast<Expr **>(Args); } 87015ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson unsigned getNumArgs() const { return NumArgs; } 87115ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson 872bcb11d01c034f967503bd98f28bdf458c1ab8001Anders Carlsson /// getArg - Return the specified argument. 873bcb11d01c034f967503bd98f28bdf458c1ab8001Anders Carlsson Expr *getArg(unsigned Arg) { 874bcb11d01c034f967503bd98f28bdf458c1ab8001Anders Carlsson assert(Arg < NumArgs && "Arg access out of range!"); 875bcb11d01c034f967503bd98f28bdf458c1ab8001Anders Carlsson return cast<Expr>(Args[Arg]); 876bcb11d01c034f967503bd98f28bdf458c1ab8001Anders Carlsson } 877bcb11d01c034f967503bd98f28bdf458c1ab8001Anders Carlsson const Expr *getArg(unsigned Arg) const { 878bcb11d01c034f967503bd98f28bdf458c1ab8001Anders Carlsson assert(Arg < NumArgs && "Arg access out of range!"); 879bcb11d01c034f967503bd98f28bdf458c1ab8001Anders Carlsson return cast<Expr>(Args[Arg]); 880bcb11d01c034f967503bd98f28bdf458c1ab8001Anders Carlsson } 8811eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 8822eeed7bc4fd457ac57ff32ab3b02674588545f65Fariborz Jahanian /// setArg - Set the specified argument. 8832eeed7bc4fd457ac57ff32ab3b02674588545f65Fariborz Jahanian void setArg(unsigned Arg, Expr *ArgExpr) { 8842eeed7bc4fd457ac57ff32ab3b02674588545f65Fariborz Jahanian assert(Arg < NumArgs && "Arg access out of range!"); 8852eeed7bc4fd457ac57ff32ab3b02674588545f65Fariborz Jahanian Args[Arg] = ArgExpr; 8862eeed7bc4fd457ac57ff32ab3b02674588545f65Fariborz Jahanian } 8872eeed7bc4fd457ac57ff32ab3b02674588545f65Fariborz Jahanian 88863c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall SourceRange getSourceRange() const; 889428edafa9eb80e01dd40aab31d4166a787a741e1Chandler Carruth SourceRange getParenRange() const { return ParenRange; } 89015ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson 8911eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump static bool classof(const Stmt *T) { 892524fa13fd81e88533c7a1d4b1232c0de2c97dc7cAnders Carlsson return T->getStmtClass() == CXXConstructExprClass || 893524fa13fd81e88533c7a1d4b1232c0de2c97dc7cAnders Carlsson T->getStmtClass() == CXXTemporaryObjectExprClass; 89415ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson } 89515ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson static bool classof(const CXXConstructExpr *) { return true; } 8961eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 89715ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson // Iterators 89863c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall child_range children() { 89963c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall return child_range(&Args[0], &Args[0]+NumArgs); 90063c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall } 9016d00c1365dd3601f6d93bbda9162913c57ae788fArgyrios Kyrtzidis 90260adf4acf40b72227740bf966fb87eebddff3f37Sebastian Redl friend class ASTStmtReader; 90315ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson}; 90415ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson 90549badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// CXXFunctionalCastExpr - Represents an explicit C++ type conversion 90649badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// that uses "functional" notion (C++ [expr.type.conv]). Example: @c 90749badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// x = int(0.5); 90849badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregorclass CXXFunctionalCastExpr : public ExplicitCastExpr { 909987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis SourceLocation TyBeginLoc; 910987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis SourceLocation RParenLoc; 911f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall 912f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall CXXFunctionalCastExpr(QualType ty, ExprValueKind VK, 913f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall TypeSourceInfo *writtenTy, 9141eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump SourceLocation tyBeginLoc, CastKind kind, 915f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall Expr *castExpr, unsigned pathSize, 91641b2dcd465f1e438502c420effc9d0c747f9db8fAnders Carlsson SourceLocation rParenLoc) 917f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall : ExplicitCastExpr(CXXFunctionalCastExprClass, ty, VK, kind, 918f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall castExpr, pathSize, writtenTy), 9190aebc81e02397a5987aaa8e8c7acbdb01a31d7c3Anders Carlsson TyBeginLoc(tyBeginLoc), RParenLoc(rParenLoc) {} 9200aebc81e02397a5987aaa8e8c7acbdb01a31d7c3Anders Carlsson 921f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall explicit CXXFunctionalCastExpr(EmptyShell Shell, unsigned PathSize) 922f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall : ExplicitCastExpr(CXXFunctionalCastExprClass, Shell, PathSize) { } 923f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall 924f871d0cc377a1367b519a6cce26be74607566ebaJohn McCallpublic: 925f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall static CXXFunctionalCastExpr *Create(ASTContext &Context, QualType T, 926f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall ExprValueKind VK, 927f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall TypeSourceInfo *Written, 928f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall SourceLocation TyBeginLoc, 929f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall CastKind Kind, Expr *Op, 930f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall const CXXCastPath *Path, 931f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall SourceLocation RPLoc); 932f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall static CXXFunctionalCastExpr *CreateEmpty(ASTContext &Context, 933f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall unsigned PathSize); 934ce757a7a1ee905f87551996a69da3e95e8afeeb7Sam Weinig 935987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis SourceLocation getTypeBeginLoc() const { return TyBeginLoc; } 936ce757a7a1ee905f87551996a69da3e95e8afeeb7Sam Weinig void setTypeBeginLoc(SourceLocation L) { TyBeginLoc = L; } 937987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis SourceLocation getRParenLoc() const { return RParenLoc; } 938ce757a7a1ee905f87551996a69da3e95e8afeeb7Sam Weinig void setRParenLoc(SourceLocation L) { RParenLoc = L; } 9391eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 94063c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall SourceRange getSourceRange() const { 941987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis return SourceRange(TyBeginLoc, RParenLoc); 942987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis } 9431eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump static bool classof(const Stmt *T) { 9441eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump return T->getStmtClass() == CXXFunctionalCastExprClass; 945987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis } 946987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis static bool classof(const CXXFunctionalCastExpr *) { return true; } 947987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis}; 948987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis 949506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// @brief Represents a C++ functional cast expression that builds a 950506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// temporary object. 951506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// 9521eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump/// This expression type represents a C++ "functional" cast 953506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// (C++[expr.type.conv]) with N != 1 arguments that invokes a 954ed8abf18329df67b0abcbb3a10458bd8c1d2a595Douglas Gregor/// constructor to build a temporary object. With N == 1 arguments the 955ed8abf18329df67b0abcbb3a10458bd8c1d2a595Douglas Gregor/// functional cast expression will be represented by CXXFunctionalCastExpr. 956506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// Example: 957506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// @code 958506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// struct X { X(int, float); } 959506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// 960506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// X create_X() { 961506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// return X(1, 3.14f); // creates a CXXTemporaryObjectExpr 962506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// }; 963506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// @endcode 964524fa13fd81e88533c7a1d4b1232c0de2c97dc7cAnders Carlssonclass CXXTemporaryObjectExpr : public CXXConstructExpr { 965ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor TypeSourceInfo *Type; 966506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor 967506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregorpublic: 9681eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump CXXTemporaryObjectExpr(ASTContext &C, CXXConstructorDecl *Cons, 969ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor TypeSourceInfo *Type, 9701eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump Expr **Args,unsigned NumArgs, 971428edafa9eb80e01dd40aab31d4166a787a741e1Chandler Carruth SourceRange parenRange, 9721c63b9c15d48cb8c833a4b2d6fd6c496c0766e88Douglas Gregor bool ZeroInitialization = false); 9736d00c1365dd3601f6d93bbda9162913c57ae788fArgyrios Kyrtzidis explicit CXXTemporaryObjectExpr(EmptyShell Empty) 974ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor : CXXConstructExpr(CXXTemporaryObjectExprClass, Empty), Type() { } 975506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor 976ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor TypeSourceInfo *getTypeSourceInfo() const { return Type; } 977ba49817c5b9f502602672861cf369fd0e53966e8Douglas Gregor 97863c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall SourceRange getSourceRange() const; 979ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor 9801eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump static bool classof(const Stmt *T) { 981506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor return T->getStmtClass() == CXXTemporaryObjectExprClass; 982506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor } 983506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor static bool classof(const CXXTemporaryObjectExpr *) { return true; } 9846d00c1365dd3601f6d93bbda9162913c57ae788fArgyrios Kyrtzidis 98560adf4acf40b72227740bf966fb87eebddff3f37Sebastian Redl friend class ASTStmtReader; 986506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor}; 987506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor 988ed8abf18329df67b0abcbb3a10458bd8c1d2a595Douglas Gregor/// CXXScalarValueInitExpr - [C++ 5.2.3p2] 989506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// Expression "T()" which creates a value-initialized rvalue of type 990ed8abf18329df67b0abcbb3a10458bd8c1d2a595Douglas Gregor/// T, which is a non-class type. 991987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis/// 992ed8abf18329df67b0abcbb3a10458bd8c1d2a595Douglas Gregorclass CXXScalarValueInitExpr : public Expr { 993987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis SourceLocation RParenLoc; 994ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor TypeSourceInfo *TypeInfo; 995987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis 996ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor friend class ASTStmtReader; 997ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor 998987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidispublic: 999ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor /// \brief Create an explicitly-written scalar-value initialization 1000ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor /// expression. 1001ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor CXXScalarValueInitExpr(QualType Type, 1002ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor TypeSourceInfo *TypeInfo, 1003ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor SourceLocation rParenLoc ) : 1004f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall Expr(CXXScalarValueInitExprClass, Type, VK_RValue, OK_Ordinary, 1005561f81243f665cf2001caadc45df505f826b72d6Douglas Gregor false, false, Type->isInstantiationDependentType(), false), 1006ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor RParenLoc(rParenLoc), TypeInfo(TypeInfo) {} 1007ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor 1008ed8abf18329df67b0abcbb3a10458bd8c1d2a595Douglas Gregor explicit CXXScalarValueInitExpr(EmptyShell Shell) 1009ed8abf18329df67b0abcbb3a10458bd8c1d2a595Douglas Gregor : Expr(CXXScalarValueInitExprClass, Shell) { } 10101eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1011ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor TypeSourceInfo *getTypeSourceInfo() const { 1012ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor return TypeInfo; 10134c67834407ca6ab344dcf44fc599ad4938cfa96dDouglas Gregor } 1014ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor 1015ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor SourceLocation getRParenLoc() const { return RParenLoc; } 10164c67834407ca6ab344dcf44fc599ad4938cfa96dDouglas Gregor 101763c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall SourceRange getSourceRange() const; 10181eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 10191eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump static bool classof(const Stmt *T) { 1020ed8abf18329df67b0abcbb3a10458bd8c1d2a595Douglas Gregor return T->getStmtClass() == CXXScalarValueInitExprClass; 1021987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis } 1022ed8abf18329df67b0abcbb3a10458bd8c1d2a595Douglas Gregor static bool classof(const CXXScalarValueInitExpr *) { return true; } 10231eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1024987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis // Iterators 102563c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall child_range children() { return child_range(); } 1026987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis}; 1027987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis 10284c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl/// CXXNewExpr - A new expression for memory allocation and constructor calls, 10294c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl/// e.g: "new CXXNewExpr(foo)". 10304c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redlclass CXXNewExpr : public Expr { 10314c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // Was the usage ::new, i.e. is the global new to be used? 10324c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl bool GlobalNew : 1; 10334c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // Is there an initializer? If not, built-ins are uninitialized, else they're 10344c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // value-initialized. 10354c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl bool Initializer : 1; 1036cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl // Do we allocate an array? If so, the first SubExpr is the size expression. 1037cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl bool Array : 1; 10386ec278d1a354517e20f13a877481453ee7940c78John McCall // If this is an array allocation, does the usual deallocation 10396ec278d1a354517e20f13a877481453ee7940c78John McCall // function for the allocated type want to know the allocated size? 10406ec278d1a354517e20f13a877481453ee7940c78John McCall bool UsualArrayDeleteWantsSize : 1; 10414c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // The number of placement new arguments. 10426ec278d1a354517e20f13a877481453ee7940c78John McCall unsigned NumPlacementArgs : 14; 10434c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // The number of constructor arguments. This may be 1 even for non-class 10444c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // types; use the pseudo copy constructor. 1045cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl unsigned NumConstructorArgs : 14; 1046cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl // Contains an optional array size expression, any number of optional 1047cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl // placement arguments, and any number of optional constructor arguments, 1048cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl // in that order. 10494c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl Stmt **SubExprs; 10504c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // Points to the allocation function used. 10514c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl FunctionDecl *OperatorNew; 10524c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // Points to the deallocation function used in case of error. May be null. 10534c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl FunctionDecl *OperatorDelete; 10544c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // Points to the constructor used. Cannot be null if AllocType is a record; 10554c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // it would still point at the default constructor (even an implicit one). 10564c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // Must be null for all other types. 10574c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl CXXConstructorDecl *Constructor; 10584c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 10591bb2a93ab7b1499dda6f6b58865bd0dce1864228Douglas Gregor /// \brief The allocated type-source information, as written in the source. 10601bb2a93ab7b1499dda6f6b58865bd0dce1864228Douglas Gregor TypeSourceInfo *AllocatedTypeInfo; 10611bb2a93ab7b1499dda6f6b58865bd0dce1864228Douglas Gregor 10624bd40318cbea15310a37343db46de96c4fcc15e6Douglas Gregor /// \brief If the allocated type was expressed as a parenthesized type-id, 10634bd40318cbea15310a37343db46de96c4fcc15e6Douglas Gregor /// the source range covering the parenthesized type-id. 10644bd40318cbea15310a37343db46de96c4fcc15e6Douglas Gregor SourceRange TypeIdParens; 10654bd40318cbea15310a37343db46de96c4fcc15e6Douglas Gregor 10664c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl SourceLocation StartLoc; 10674c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl SourceLocation EndLoc; 1068428edafa9eb80e01dd40aab31d4166a787a741e1Chandler Carruth SourceLocation ConstructorLParen; 1069428edafa9eb80e01dd40aab31d4166a787a741e1Chandler Carruth SourceLocation ConstructorRParen; 10704c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 107160adf4acf40b72227740bf966fb87eebddff3f37Sebastian Redl friend class ASTStmtReader; 10724c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redlpublic: 1073ad7fe864862305c2f71e047cdf6706ef43aebdc0Ted Kremenek CXXNewExpr(ASTContext &C, bool globalNew, FunctionDecl *operatorNew, 10744bd40318cbea15310a37343db46de96c4fcc15e6Douglas Gregor Expr **placementArgs, unsigned numPlaceArgs, 10754bd40318cbea15310a37343db46de96c4fcc15e6Douglas Gregor SourceRange TypeIdParens, 1076ad7fe864862305c2f71e047cdf6706ef43aebdc0Ted Kremenek Expr *arraySize, CXXConstructorDecl *constructor, bool initializer, 10774c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl Expr **constructorArgs, unsigned numConsArgs, 10786ec278d1a354517e20f13a877481453ee7940c78John McCall FunctionDecl *operatorDelete, bool usualArrayDeleteWantsSize, 10796ec278d1a354517e20f13a877481453ee7940c78John McCall QualType ty, TypeSourceInfo *AllocatedTypeInfo, 1080428edafa9eb80e01dd40aab31d4166a787a741e1Chandler Carruth SourceLocation startLoc, SourceLocation endLoc, 1081428edafa9eb80e01dd40aab31d4166a787a741e1Chandler Carruth SourceLocation constructorLParen, 1082428edafa9eb80e01dd40aab31d4166a787a741e1Chandler Carruth SourceLocation constructorRParen); 10835921863d8f24084797863b5df37842113bac4352Chris Lattner explicit CXXNewExpr(EmptyShell Shell) 10845921863d8f24084797863b5df37842113bac4352Chris Lattner : Expr(CXXNewExprClass, Shell), SubExprs(0) { } 10855921863d8f24084797863b5df37842113bac4352Chris Lattner 10865921863d8f24084797863b5df37842113bac4352Chris Lattner void AllocateArgsArray(ASTContext &C, bool isArray, unsigned numPlaceArgs, 10875921863d8f24084797863b5df37842113bac4352Chris Lattner unsigned numConsArgs); 1088ad7fe864862305c2f71e047cdf6706ef43aebdc0Ted Kremenek 1089cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl QualType getAllocatedType() const { 1090cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl assert(getType()->isPointerType()); 10916217b80b7a1379b74cced1c076338262c3c980b3Ted Kremenek return getType()->getAs<PointerType>()->getPointeeType(); 1092cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl } 10934c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 10941bb2a93ab7b1499dda6f6b58865bd0dce1864228Douglas Gregor TypeSourceInfo *getAllocatedTypeSourceInfo() const { 10951bb2a93ab7b1499dda6f6b58865bd0dce1864228Douglas Gregor return AllocatedTypeInfo; 10961bb2a93ab7b1499dda6f6b58865bd0dce1864228Douglas Gregor } 1097c2f3e7f42c8bf9e8d4393a6e8c4762dafc4f28ddJohn McCall 1098c2f3e7f42c8bf9e8d4393a6e8c4762dafc4f28ddJohn McCall /// \brief True if the allocation result needs to be null-checked. 1099c2f3e7f42c8bf9e8d4393a6e8c4762dafc4f28ddJohn McCall /// C++0x [expr.new]p13: 1100c2f3e7f42c8bf9e8d4393a6e8c4762dafc4f28ddJohn McCall /// If the allocation function returns null, initialization shall 1101c2f3e7f42c8bf9e8d4393a6e8c4762dafc4f28ddJohn McCall /// not be done, the deallocation function shall not be called, 1102c2f3e7f42c8bf9e8d4393a6e8c4762dafc4f28ddJohn McCall /// and the value of the new-expression shall be null. 1103c2f3e7f42c8bf9e8d4393a6e8c4762dafc4f28ddJohn McCall /// An allocation function is not allowed to return null unless it 1104c2f3e7f42c8bf9e8d4393a6e8c4762dafc4f28ddJohn McCall /// has a non-throwing exception-specification. The '03 rule is 1105c2f3e7f42c8bf9e8d4393a6e8c4762dafc4f28ddJohn McCall /// identical except that the definition of a non-throwing 1106c2f3e7f42c8bf9e8d4393a6e8c4762dafc4f28ddJohn McCall /// exception specification is just "is it throw()?". 11078026f6d82f7fa544bc0453714fe94bca62a1196eSebastian Redl bool shouldNullCheckAllocation(ASTContext &Ctx) const; 11081bb2a93ab7b1499dda6f6b58865bd0dce1864228Douglas Gregor 11094c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl FunctionDecl *getOperatorNew() const { return OperatorNew; } 11105921863d8f24084797863b5df37842113bac4352Chris Lattner void setOperatorNew(FunctionDecl *D) { OperatorNew = D; } 11114c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl FunctionDecl *getOperatorDelete() const { return OperatorDelete; } 11125921863d8f24084797863b5df37842113bac4352Chris Lattner void setOperatorDelete(FunctionDecl *D) { OperatorDelete = D; } 11134c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl CXXConstructorDecl *getConstructor() const { return Constructor; } 11145921863d8f24084797863b5df37842113bac4352Chris Lattner void setConstructor(CXXConstructorDecl *D) { Constructor = D; } 11154c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 1116cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl bool isArray() const { return Array; } 1117cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl Expr *getArraySize() { 1118cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl return Array ? cast<Expr>(SubExprs[0]) : 0; 1119cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl } 1120cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl const Expr *getArraySize() const { 1121cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl return Array ? cast<Expr>(SubExprs[0]) : 0; 1122cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl } 1123cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl 11244c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl unsigned getNumPlacementArgs() const { return NumPlacementArgs; } 1125aa165f8458b51c546bebff947343e1a36f3594cbDouglas Gregor Expr **getPlacementArgs() { 1126aa165f8458b51c546bebff947343e1a36f3594cbDouglas Gregor return reinterpret_cast<Expr **>(SubExprs + Array); 1127aa165f8458b51c546bebff947343e1a36f3594cbDouglas Gregor } 1128aa165f8458b51c546bebff947343e1a36f3594cbDouglas Gregor 11294c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl Expr *getPlacementArg(unsigned i) { 11304c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl assert(i < NumPlacementArgs && "Index out of range"); 1131cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl return cast<Expr>(SubExprs[Array + i]); 11324c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 11334c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl const Expr *getPlacementArg(unsigned i) const { 11344c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl assert(i < NumPlacementArgs && "Index out of range"); 1135cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl return cast<Expr>(SubExprs[Array + i]); 11364c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 11374c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 11384bd40318cbea15310a37343db46de96c4fcc15e6Douglas Gregor bool isParenTypeId() const { return TypeIdParens.isValid(); } 11394bd40318cbea15310a37343db46de96c4fcc15e6Douglas Gregor SourceRange getTypeIdParens() const { return TypeIdParens; } 11404bd40318cbea15310a37343db46de96c4fcc15e6Douglas Gregor 11414c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl bool isGlobalNew() const { return GlobalNew; } 11424c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl bool hasInitializer() const { return Initializer; } 11436ec278d1a354517e20f13a877481453ee7940c78John McCall 11446ec278d1a354517e20f13a877481453ee7940c78John McCall /// Answers whether the usual array deallocation function for the 11456ec278d1a354517e20f13a877481453ee7940c78John McCall /// allocated type expects the size of the allocation as a 11466ec278d1a354517e20f13a877481453ee7940c78John McCall /// parameter. 11476ec278d1a354517e20f13a877481453ee7940c78John McCall bool doesUsualArrayDeleteWantSize() const { 11486ec278d1a354517e20f13a877481453ee7940c78John McCall return UsualArrayDeleteWantsSize; 11496ec278d1a354517e20f13a877481453ee7940c78John McCall } 11504c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 11514c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl unsigned getNumConstructorArgs() const { return NumConstructorArgs; } 1152aa165f8458b51c546bebff947343e1a36f3594cbDouglas Gregor 1153aa165f8458b51c546bebff947343e1a36f3594cbDouglas Gregor Expr **getConstructorArgs() { 1154aa165f8458b51c546bebff947343e1a36f3594cbDouglas Gregor return reinterpret_cast<Expr **>(SubExprs + Array + NumPlacementArgs); 1155aa165f8458b51c546bebff947343e1a36f3594cbDouglas Gregor } 1156aa165f8458b51c546bebff947343e1a36f3594cbDouglas Gregor 11574c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl Expr *getConstructorArg(unsigned i) { 11584c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl assert(i < NumConstructorArgs && "Index out of range"); 1159cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl return cast<Expr>(SubExprs[Array + NumPlacementArgs + i]); 11604c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 11614c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl const Expr *getConstructorArg(unsigned i) const { 11624c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl assert(i < NumConstructorArgs && "Index out of range"); 1163cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl return cast<Expr>(SubExprs[Array + NumPlacementArgs + i]); 11644c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 11654c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 11664c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl typedef ExprIterator arg_iterator; 11674c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl typedef ConstExprIterator const_arg_iterator; 11684c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 11694c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl arg_iterator placement_arg_begin() { 1170cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl return SubExprs + Array; 11714c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 11724c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl arg_iterator placement_arg_end() { 1173cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl return SubExprs + Array + getNumPlacementArgs(); 11744c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 11754c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl const_arg_iterator placement_arg_begin() const { 1176cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl return SubExprs + Array; 11774c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 11784c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl const_arg_iterator placement_arg_end() const { 1179cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl return SubExprs + Array + getNumPlacementArgs(); 11804c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 11814c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 11824c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl arg_iterator constructor_arg_begin() { 1183cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl return SubExprs + Array + getNumPlacementArgs(); 11844c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 11854c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl arg_iterator constructor_arg_end() { 1186cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl return SubExprs + Array + getNumPlacementArgs() + getNumConstructorArgs(); 11874c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 11884c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl const_arg_iterator constructor_arg_begin() const { 1189cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl return SubExprs + Array + getNumPlacementArgs(); 11904c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 11914c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl const_arg_iterator constructor_arg_end() const { 1192cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl return SubExprs + Array + getNumPlacementArgs() + getNumConstructorArgs(); 11934c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 11945921863d8f24084797863b5df37842113bac4352Chris Lattner 11955921863d8f24084797863b5df37842113bac4352Chris Lattner typedef Stmt **raw_arg_iterator; 11965921863d8f24084797863b5df37842113bac4352Chris Lattner raw_arg_iterator raw_arg_begin() { return SubExprs; } 11975921863d8f24084797863b5df37842113bac4352Chris Lattner raw_arg_iterator raw_arg_end() { 11985921863d8f24084797863b5df37842113bac4352Chris Lattner return SubExprs + Array + getNumPlacementArgs() + getNumConstructorArgs(); 11995921863d8f24084797863b5df37842113bac4352Chris Lattner } 12005921863d8f24084797863b5df37842113bac4352Chris Lattner const_arg_iterator raw_arg_begin() const { return SubExprs; } 12015921863d8f24084797863b5df37842113bac4352Chris Lattner const_arg_iterator raw_arg_end() const { return constructor_arg_end(); } 12024c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 12035921863d8f24084797863b5df37842113bac4352Chris Lattner SourceLocation getStartLoc() const { return StartLoc; } 12045921863d8f24084797863b5df37842113bac4352Chris Lattner SourceLocation getEndLoc() const { return EndLoc; } 1205428edafa9eb80e01dd40aab31d4166a787a741e1Chandler Carruth 1206428edafa9eb80e01dd40aab31d4166a787a741e1Chandler Carruth SourceLocation getConstructorLParen() const { return ConstructorLParen; } 1207428edafa9eb80e01dd40aab31d4166a787a741e1Chandler Carruth SourceLocation getConstructorRParen() const { return ConstructorRParen; } 1208428edafa9eb80e01dd40aab31d4166a787a741e1Chandler Carruth 120963c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall SourceRange getSourceRange() const { 12104c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl return SourceRange(StartLoc, EndLoc); 12114c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 12124c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 12134c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl static bool classof(const Stmt *T) { 12144c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl return T->getStmtClass() == CXXNewExprClass; 12154c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 12164c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl static bool classof(const CXXNewExpr *) { return true; } 12174c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 12184c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // Iterators 121963c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall child_range children() { 122063c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall return child_range(&SubExprs[0], 122163c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall &SubExprs[0] + Array + getNumPlacementArgs() 122263c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall + getNumConstructorArgs()); 122363c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall } 12244c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl}; 12254c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 12264c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl/// CXXDeleteExpr - A delete expression for memory deallocation and destructor 12274c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl/// calls, e.g. "delete[] pArray". 12284c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redlclass CXXDeleteExpr : public Expr { 12294c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // Is this a forced global delete, i.e. "::delete"? 12304c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl bool GlobalDelete : 1; 12314c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // Is this the array form of delete, i.e. "delete[]"? 12324c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl bool ArrayForm : 1; 12334076dacf1497fb95cb298b9d964fbdbdaf9bde6cArgyrios Kyrtzidis // ArrayFormAsWritten can be different from ArrayForm if 'delete' is applied 12344076dacf1497fb95cb298b9d964fbdbdaf9bde6cArgyrios Kyrtzidis // to pointer-to-array type (ArrayFormAsWritten will be false while ArrayForm 12354076dacf1497fb95cb298b9d964fbdbdaf9bde6cArgyrios Kyrtzidis // will be true). 12364076dacf1497fb95cb298b9d964fbdbdaf9bde6cArgyrios Kyrtzidis bool ArrayFormAsWritten : 1; 12376ec278d1a354517e20f13a877481453ee7940c78John McCall // Does the usual deallocation function for the element type require 12386ec278d1a354517e20f13a877481453ee7940c78John McCall // a size_t argument? 12396ec278d1a354517e20f13a877481453ee7940c78John McCall bool UsualArrayDeleteWantsSize : 1; 12404c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // Points to the operator delete overload that is used. Could be a member. 12414c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl FunctionDecl *OperatorDelete; 12424c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // The pointer expression to be deleted. 12434c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl Stmt *Argument; 12444c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // Location of the expression. 12454c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl SourceLocation Loc; 12464c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redlpublic: 12474c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl CXXDeleteExpr(QualType ty, bool globalDelete, bool arrayForm, 12486ec278d1a354517e20f13a877481453ee7940c78John McCall bool arrayFormAsWritten, bool usualArrayDeleteWantsSize, 12496ec278d1a354517e20f13a877481453ee7940c78John McCall FunctionDecl *operatorDelete, Expr *arg, SourceLocation loc) 1250bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor : Expr(CXXDeleteExprClass, ty, VK_RValue, OK_Ordinary, false, false, 1251561f81243f665cf2001caadc45df505f826b72d6Douglas Gregor arg->isInstantiationDependent(), 1252bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor arg->containsUnexpandedParameterPack()), 1253f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall GlobalDelete(globalDelete), 12544076dacf1497fb95cb298b9d964fbdbdaf9bde6cArgyrios Kyrtzidis ArrayForm(arrayForm), ArrayFormAsWritten(arrayFormAsWritten), 12556ec278d1a354517e20f13a877481453ee7940c78John McCall UsualArrayDeleteWantsSize(usualArrayDeleteWantsSize), 12564076dacf1497fb95cb298b9d964fbdbdaf9bde6cArgyrios Kyrtzidis OperatorDelete(operatorDelete), Argument(arg), Loc(loc) { } 125795fc98ce95d4faa4f1bb2783384150530404ea6fArgyrios Kyrtzidis explicit CXXDeleteExpr(EmptyShell Shell) 125895fc98ce95d4faa4f1bb2783384150530404ea6fArgyrios Kyrtzidis : Expr(CXXDeleteExprClass, Shell), OperatorDelete(0), Argument(0) { } 12594c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 12604c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl bool isGlobalDelete() const { return GlobalDelete; } 12614c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl bool isArrayForm() const { return ArrayForm; } 12624076dacf1497fb95cb298b9d964fbdbdaf9bde6cArgyrios Kyrtzidis bool isArrayFormAsWritten() const { return ArrayFormAsWritten; } 12634c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 12646ec278d1a354517e20f13a877481453ee7940c78John McCall /// Answers whether the usual array deallocation function for the 12656ec278d1a354517e20f13a877481453ee7940c78John McCall /// allocated type expects the size of the allocation as a 12666ec278d1a354517e20f13a877481453ee7940c78John McCall /// parameter. This can be true even if the actual deallocation 12676ec278d1a354517e20f13a877481453ee7940c78John McCall /// function that we're using doesn't want a size. 12686ec278d1a354517e20f13a877481453ee7940c78John McCall bool doesUsualArrayDeleteWantSize() const { 12696ec278d1a354517e20f13a877481453ee7940c78John McCall return UsualArrayDeleteWantsSize; 12706ec278d1a354517e20f13a877481453ee7940c78John McCall } 12716ec278d1a354517e20f13a877481453ee7940c78John McCall 12724c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl FunctionDecl *getOperatorDelete() const { return OperatorDelete; } 12734c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 12744c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl Expr *getArgument() { return cast<Expr>(Argument); } 12754c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl const Expr *getArgument() const { return cast<Expr>(Argument); } 12764c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 1277a437ad3ec5b407ede394d74e6f9f463fa3657dbeCraig Silverstein /// \brief Retrieve the type being destroyed. If the type being 1278a437ad3ec5b407ede394d74e6f9f463fa3657dbeCraig Silverstein /// destroyed is a dependent type which may or may not be a pointer, 1279a437ad3ec5b407ede394d74e6f9f463fa3657dbeCraig Silverstein /// return an invalid type. 12805833b0b831d6afae2885e6af420e2bda639652e6Douglas Gregor QualType getDestroyedType() const; 12815833b0b831d6afae2885e6af420e2bda639652e6Douglas Gregor 128263c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall SourceRange getSourceRange() const { 12834c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl return SourceRange(Loc, Argument->getLocEnd()); 12844c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 12854c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 12864c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl static bool classof(const Stmt *T) { 12874c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl return T->getStmtClass() == CXXDeleteExprClass; 12884c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 12894c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl static bool classof(const CXXDeleteExpr *) { return true; } 12904c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 12914c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // Iterators 129263c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall child_range children() { return child_range(&Argument, &Argument+1); } 1293f1b8911d35bb2830a13267581d3cbde4b6b85db6Argyrios Kyrtzidis 1294f1b8911d35bb2830a13267581d3cbde4b6b85db6Argyrios Kyrtzidis friend class ASTStmtReader; 12954c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl}; 12964c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 1297a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor/// \brief Structure used to store the type being destroyed by a 1298a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor/// pseudo-destructor expression. 1299a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregorclass PseudoDestructorTypeStorage { 1300a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor /// \brief Either the type source information or the name of the type, if 1301a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor /// it couldn't be resolved due to type-dependence. 1302a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor llvm::PointerUnion<TypeSourceInfo *, IdentifierInfo *> Type; 1303a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor 1304a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor /// \brief The starting source location of the pseudo-destructor type. 1305a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor SourceLocation Location; 1306a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor 1307a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregorpublic: 1308a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor PseudoDestructorTypeStorage() { } 1309a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor 1310a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor PseudoDestructorTypeStorage(IdentifierInfo *II, SourceLocation Loc) 1311a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor : Type(II), Location(Loc) { } 1312a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor 1313a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor PseudoDestructorTypeStorage(TypeSourceInfo *Info); 1314a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor 1315a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor TypeSourceInfo *getTypeSourceInfo() const { 1316a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor return Type.dyn_cast<TypeSourceInfo *>(); 1317a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor } 1318a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor 1319a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor IdentifierInfo *getIdentifier() const { 1320a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor return Type.dyn_cast<IdentifierInfo *>(); 1321a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor } 1322a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor 1323a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor SourceLocation getLocation() const { return Location; } 1324a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor}; 1325a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor 1326a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor/// \brief Represents a C++ pseudo-destructor (C++ [expr.pseudo]). 1327a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor/// 1328e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor/// A pseudo-destructor is an expression that looks like a member access to a 1329e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor/// destructor of a scalar type, except that scalar types don't have 1330e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor/// destructors. For example: 1331e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor/// 1332e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor/// \code 1333e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor/// typedef int T; 1334e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor/// void f(int *p) { 1335e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor/// p->T::~T(); 1336e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor/// } 1337e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor/// \endcode 1338a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor/// 1339e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor/// Pseudo-destructors typically occur when instantiating templates such as: 1340e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor/// 1341a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor/// \code 13421eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump/// template<typename T> 1343a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor/// void destroy(T* ptr) { 1344e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor/// ptr->T::~T(); 1345a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor/// } 1346a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor/// \endcode 1347a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor/// 1348e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor/// for scalar types. A pseudo-destructor expression has no run-time semantics 1349e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor/// beyond evaluating the base expression. 1350a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregorclass CXXPseudoDestructorExpr : public Expr { 1351a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor /// \brief The base expression (that is being destroyed). 1352a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor Stmt *Base; 13531eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1354a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor /// \brief Whether the operator was an arrow ('->'); otherwise, it was a 1355a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor /// period ('.'). 1356a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor bool IsArrow : 1; 13571eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1358a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor /// \brief The location of the '.' or '->' operator. 1359a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor SourceLocation OperatorLoc; 1360f3db29fff6a583ecda823cf909ab7737d8d30129Douglas Gregor 1361a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor /// \brief The nested-name-specifier that follows the operator, if present. 1362f3db29fff6a583ecda823cf909ab7737d8d30129Douglas Gregor NestedNameSpecifierLoc QualifierLoc; 13631eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1364e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor /// \brief The type that precedes the '::' in a qualified pseudo-destructor 1365e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor /// expression. 1366e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor TypeSourceInfo *ScopeType; 1367e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor 1368e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor /// \brief The location of the '::' in a qualified pseudo-destructor 1369e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor /// expression. 1370e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor SourceLocation ColonColonLoc; 1371e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor 1372fce46ee68f779e239826e69e45d01d4c8e5323caDouglas Gregor /// \brief The location of the '~'. 1373fce46ee68f779e239826e69e45d01d4c8e5323caDouglas Gregor SourceLocation TildeLoc; 1374fce46ee68f779e239826e69e45d01d4c8e5323caDouglas Gregor 1375a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor /// \brief The type being destroyed, or its name if we were unable to 1376a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor /// resolve the name. 1377a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor PseudoDestructorTypeStorage DestroyedType; 13781eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1379f3db29fff6a583ecda823cf909ab7737d8d30129Douglas Gregor friend class ASTStmtReader; 1380f3db29fff6a583ecda823cf909ab7737d8d30129Douglas Gregor 1381a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregorpublic: 1382a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor CXXPseudoDestructorExpr(ASTContext &Context, 1383a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor Expr *Base, bool isArrow, SourceLocation OperatorLoc, 1384f3db29fff6a583ecda823cf909ab7737d8d30129Douglas Gregor NestedNameSpecifierLoc QualifierLoc, 1385e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor TypeSourceInfo *ScopeType, 1386e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor SourceLocation ColonColonLoc, 1387fce46ee68f779e239826e69e45d01d4c8e5323caDouglas Gregor SourceLocation TildeLoc, 1388e23cf437fe76b1ed02d63c3f61b456fd48a915f5John McCall PseudoDestructorTypeStorage DestroyedType); 13891eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1390de4bd18bb45a1db68996cfb949db3015fc25d10dArgyrios Kyrtzidis explicit CXXPseudoDestructorExpr(EmptyShell Shell) 1391de4bd18bb45a1db68996cfb949db3015fc25d10dArgyrios Kyrtzidis : Expr(CXXPseudoDestructorExprClass, Shell), 1392f3db29fff6a583ecda823cf909ab7737d8d30129Douglas Gregor Base(0), IsArrow(false), QualifierLoc(), ScopeType(0) { } 1393de4bd18bb45a1db68996cfb949db3015fc25d10dArgyrios Kyrtzidis 1394a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor Expr *getBase() const { return cast<Expr>(Base); } 13951eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 13961eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump /// \brief Determines whether this member expression actually had 1397a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor /// a C++ nested-name-specifier prior to the name of the member, e.g., 1398a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor /// x->Base::foo. 1399f3db29fff6a583ecda823cf909ab7737d8d30129Douglas Gregor bool hasQualifier() const { return QualifierLoc; } 14001eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1401f3db29fff6a583ecda823cf909ab7737d8d30129Douglas Gregor /// \brief Retrieves the nested-name-specifier that qualifies the type name, 1402f3db29fff6a583ecda823cf909ab7737d8d30129Douglas Gregor /// with source-location information. 1403f3db29fff6a583ecda823cf909ab7737d8d30129Douglas Gregor NestedNameSpecifierLoc getQualifierLoc() const { return QualifierLoc; } 1404f3db29fff6a583ecda823cf909ab7737d8d30129Douglas Gregor 14051eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump /// \brief If the member name was qualified, retrieves the 1406a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor /// nested-name-specifier that precedes the member name. Otherwise, returns 1407a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor /// NULL. 1408f3db29fff6a583ecda823cf909ab7737d8d30129Douglas Gregor NestedNameSpecifier *getQualifier() const { 1409f3db29fff6a583ecda823cf909ab7737d8d30129Douglas Gregor return QualifierLoc.getNestedNameSpecifier(); 1410f3db29fff6a583ecda823cf909ab7737d8d30129Douglas Gregor } 14111eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1412a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor /// \brief Determine whether this pseudo-destructor expression was written 1413a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor /// using an '->' (otherwise, it used a '.'). 1414a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor bool isArrow() const { return IsArrow; } 1415a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor 1416a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor /// \brief Retrieve the location of the '.' or '->' operator. 1417a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor SourceLocation getOperatorLoc() const { return OperatorLoc; } 14181eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1419e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor /// \brief Retrieve the scope type in a qualified pseudo-destructor 1420e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor /// expression. 1421e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor /// 1422e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor /// Pseudo-destructor expressions can have extra qualification within them 1423e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor /// that is not part of the nested-name-specifier, e.g., \c p->T::~T(). 1424e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor /// Here, if the object type of the expression is (or may be) a scalar type, 1425e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor /// \p T may also be a scalar type and, therefore, cannot be part of a 1426e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor /// nested-name-specifier. It is stored as the "scope type" of the pseudo- 1427e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor /// destructor expression. 142826d4ac97fb514bb60c2536eae6f203dc569159d9Douglas Gregor TypeSourceInfo *getScopeTypeInfo() const { return ScopeType; } 1429e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor 1430e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor /// \brief Retrieve the location of the '::' in a qualified pseudo-destructor 1431e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor /// expression. 1432e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor SourceLocation getColonColonLoc() const { return ColonColonLoc; } 1433e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor 1434fce46ee68f779e239826e69e45d01d4c8e5323caDouglas Gregor /// \brief Retrieve the location of the '~'. 1435fce46ee68f779e239826e69e45d01d4c8e5323caDouglas Gregor SourceLocation getTildeLoc() const { return TildeLoc; } 1436fce46ee68f779e239826e69e45d01d4c8e5323caDouglas Gregor 143726d4ac97fb514bb60c2536eae6f203dc569159d9Douglas Gregor /// \brief Retrieve the source location information for the type 143826d4ac97fb514bb60c2536eae6f203dc569159d9Douglas Gregor /// being destroyed. 1439a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor /// 1440a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor /// This type-source information is available for non-dependent 1441a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor /// pseudo-destructor expressions and some dependent pseudo-destructor 1442a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor /// expressions. Returns NULL if we only have the identifier for a 1443a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor /// dependent pseudo-destructor expression. 1444a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor TypeSourceInfo *getDestroyedTypeInfo() const { 1445a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor return DestroyedType.getTypeSourceInfo(); 1446a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor } 1447a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor 1448a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor /// \brief In a dependent pseudo-destructor expression for which we do not 1449a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor /// have full type information on the destroyed type, provides the name 1450a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor /// of the destroyed type. 1451a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor IdentifierInfo *getDestroyedTypeIdentifier() const { 1452a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor return DestroyedType.getIdentifier(); 1453a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor } 1454a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor 1455a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor /// \brief Retrieve the type being destroyed. 1456a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor QualType getDestroyedType() const; 1457a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor 1458a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor /// \brief Retrieve the starting location of the type being destroyed. 1459a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor SourceLocation getDestroyedTypeLoc() const { 1460a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor return DestroyedType.getLocation(); 1461a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor } 14621eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1463de4bd18bb45a1db68996cfb949db3015fc25d10dArgyrios Kyrtzidis /// \brief Set the name of destroyed type for a dependent pseudo-destructor 1464de4bd18bb45a1db68996cfb949db3015fc25d10dArgyrios Kyrtzidis /// expression. 1465de4bd18bb45a1db68996cfb949db3015fc25d10dArgyrios Kyrtzidis void setDestroyedType(IdentifierInfo *II, SourceLocation Loc) { 1466de4bd18bb45a1db68996cfb949db3015fc25d10dArgyrios Kyrtzidis DestroyedType = PseudoDestructorTypeStorage(II, Loc); 1467de4bd18bb45a1db68996cfb949db3015fc25d10dArgyrios Kyrtzidis } 1468de4bd18bb45a1db68996cfb949db3015fc25d10dArgyrios Kyrtzidis 1469de4bd18bb45a1db68996cfb949db3015fc25d10dArgyrios Kyrtzidis /// \brief Set the destroyed type. 1470de4bd18bb45a1db68996cfb949db3015fc25d10dArgyrios Kyrtzidis void setDestroyedType(TypeSourceInfo *Info) { 1471de4bd18bb45a1db68996cfb949db3015fc25d10dArgyrios Kyrtzidis DestroyedType = PseudoDestructorTypeStorage(Info); 1472de4bd18bb45a1db68996cfb949db3015fc25d10dArgyrios Kyrtzidis } 1473de4bd18bb45a1db68996cfb949db3015fc25d10dArgyrios Kyrtzidis 147463c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall SourceRange getSourceRange() const; 14751eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 14761eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump static bool classof(const Stmt *T) { 1477a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor return T->getStmtClass() == CXXPseudoDestructorExprClass; 1478a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor } 1479a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor static bool classof(const CXXPseudoDestructorExpr *) { return true; } 14801eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1481a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor // Iterators 148263c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall child_range children() { return child_range(&Base, &Base + 1); } 1483a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor}; 14841eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 148564b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl/// UnaryTypeTraitExpr - A GCC or MS unary type trait, as used in the 148664b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl/// implementation of TR1/C++0x type trait templates. 148764b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl/// Example: 148864b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl/// __is_pod(int) == true 148964b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl/// __is_enum(std::string) == false 149064b45f7e0d3167f040841ac2920aead7f080730dSebastian Redlclass UnaryTypeTraitExpr : public Expr { 14910dfd848fa4c9664852ba8c929a8bd3fce93ddca2Sebastian Redl /// UTT - The trait. A UnaryTypeTrait enum in MSVC compat unsigned. 14920dfd848fa4c9664852ba8c929a8bd3fce93ddca2Sebastian Redl unsigned UTT : 31; 14930dfd848fa4c9664852ba8c929a8bd3fce93ddca2Sebastian Redl /// The value of the type trait. Unspecified if dependent. 14940dfd848fa4c9664852ba8c929a8bd3fce93ddca2Sebastian Redl bool Value : 1; 149564b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl 149664b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl /// Loc - The location of the type trait keyword. 149764b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl SourceLocation Loc; 149864b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl 149964b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl /// RParen - The location of the closing paren. 150064b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl SourceLocation RParen; 150164b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl 15020dfd848fa4c9664852ba8c929a8bd3fce93ddca2Sebastian Redl /// The type being queried. 15033d37c0ada0e46b87be0a10e8d52d990a97d3907aDouglas Gregor TypeSourceInfo *QueriedType; 150464b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl 150564b45f7e0d3167f040841ac2920aead7f080730dSebastian Redlpublic: 15063d37c0ada0e46b87be0a10e8d52d990a97d3907aDouglas Gregor UnaryTypeTraitExpr(SourceLocation loc, UnaryTypeTrait utt, 15070dfd848fa4c9664852ba8c929a8bd3fce93ddca2Sebastian Redl TypeSourceInfo *queried, bool value, 150864b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl SourceLocation rparen, QualType ty) 1509f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall : Expr(UnaryTypeTraitExprClass, ty, VK_RValue, OK_Ordinary, 1510bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor false, queried->getType()->isDependentType(), 1511561f81243f665cf2001caadc45df505f826b72d6Douglas Gregor queried->getType()->isInstantiationDependentType(), 1512bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor queried->getType()->containsUnexpandedParameterPack()), 15130dfd848fa4c9664852ba8c929a8bd3fce93ddca2Sebastian Redl UTT(utt), Value(value), Loc(loc), RParen(rparen), QueriedType(queried) { } 151464b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl 15156d00c1365dd3601f6d93bbda9162913c57ae788fArgyrios Kyrtzidis explicit UnaryTypeTraitExpr(EmptyShell Empty) 15160dfd848fa4c9664852ba8c929a8bd3fce93ddca2Sebastian Redl : Expr(UnaryTypeTraitExprClass, Empty), UTT(0), Value(false), 15173d37c0ada0e46b87be0a10e8d52d990a97d3907aDouglas Gregor QueriedType() { } 15186d00c1365dd3601f6d93bbda9162913c57ae788fArgyrios Kyrtzidis 151963c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall SourceRange getSourceRange() const { return SourceRange(Loc, RParen);} 152064b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl 15210dfd848fa4c9664852ba8c929a8bd3fce93ddca2Sebastian Redl UnaryTypeTrait getTrait() const { return static_cast<UnaryTypeTrait>(UTT); } 152264b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl 15233d37c0ada0e46b87be0a10e8d52d990a97d3907aDouglas Gregor QualType getQueriedType() const { return QueriedType->getType(); } 152464b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl 15253d37c0ada0e46b87be0a10e8d52d990a97d3907aDouglas Gregor TypeSourceInfo *getQueriedTypeSourceInfo() const { return QueriedType; } 15263d37c0ada0e46b87be0a10e8d52d990a97d3907aDouglas Gregor 15270dfd848fa4c9664852ba8c929a8bd3fce93ddca2Sebastian Redl bool getValue() const { return Value; } 152864b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl 152964b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl static bool classof(const Stmt *T) { 153064b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl return T->getStmtClass() == UnaryTypeTraitExprClass; 153164b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl } 153264b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl static bool classof(const UnaryTypeTraitExpr *) { return true; } 153364b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl 153464b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl // Iterators 153563c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall child_range children() { return child_range(); } 15366d00c1365dd3601f6d93bbda9162913c57ae788fArgyrios Kyrtzidis 153760adf4acf40b72227740bf966fb87eebddff3f37Sebastian Redl friend class ASTStmtReader; 153864b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl}; 153964b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl 15406ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet/// BinaryTypeTraitExpr - A GCC or MS binary type trait, as used in the 15416ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet/// implementation of TR1/C++0x type trait templates. 15426ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet/// Example: 15436ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet/// __is_base_of(Base, Derived) == true 15446ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichetclass BinaryTypeTraitExpr : public Expr { 15456ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet /// BTT - The trait. A BinaryTypeTrait enum in MSVC compat unsigned. 15466ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet unsigned BTT : 8; 15476ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet 15486ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet /// The value of the type trait. Unspecified if dependent. 15496ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet bool Value : 1; 15506ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet 15516ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet /// Loc - The location of the type trait keyword. 15526ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet SourceLocation Loc; 15536ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet 15546ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet /// RParen - The location of the closing paren. 15556ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet SourceLocation RParen; 15566ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet 15576ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet /// The lhs type being queried. 15586ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet TypeSourceInfo *LhsType; 15596ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet 15606ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet /// The rhs type being queried. 15616ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet TypeSourceInfo *RhsType; 15626ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet 15636ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichetpublic: 15646ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet BinaryTypeTraitExpr(SourceLocation loc, BinaryTypeTrait btt, 15656ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet TypeSourceInfo *lhsType, TypeSourceInfo *rhsType, 15666ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet bool value, SourceLocation rparen, QualType ty) 15676ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet : Expr(BinaryTypeTraitExprClass, ty, VK_RValue, OK_Ordinary, false, 15686ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet lhsType->getType()->isDependentType() || 1569bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor rhsType->getType()->isDependentType(), 1570561f81243f665cf2001caadc45df505f826b72d6Douglas Gregor (lhsType->getType()->isInstantiationDependentType() || 1571561f81243f665cf2001caadc45df505f826b72d6Douglas Gregor rhsType->getType()->isInstantiationDependentType()), 1572bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor (lhsType->getType()->containsUnexpandedParameterPack() || 1573bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor rhsType->getType()->containsUnexpandedParameterPack())), 15746ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet BTT(btt), Value(value), Loc(loc), RParen(rparen), 15756ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet LhsType(lhsType), RhsType(rhsType) { } 15766ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet 15776ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet 15786ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet explicit BinaryTypeTraitExpr(EmptyShell Empty) 15796ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet : Expr(BinaryTypeTraitExprClass, Empty), BTT(0), Value(false), 1580f187237d916afa97c491ac32fe98be7d335c5b63Francois Pichet LhsType(), RhsType() { } 15816ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet 158263c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall SourceRange getSourceRange() const { 15836ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet return SourceRange(Loc, RParen); 15846ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet } 15856ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet 15866ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet BinaryTypeTrait getTrait() const { 15876ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet return static_cast<BinaryTypeTrait>(BTT); 15886ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet } 15896ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet 15906ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet QualType getLhsType() const { return LhsType->getType(); } 15916ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet QualType getRhsType() const { return RhsType->getType(); } 15926ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet 15936ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet TypeSourceInfo *getLhsTypeSourceInfo() const { return LhsType; } 15946ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet TypeSourceInfo *getRhsTypeSourceInfo() const { return RhsType; } 15956ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet 15966ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet bool getValue() const { assert(!isTypeDependent()); return Value; } 15976ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet 15986ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet static bool classof(const Stmt *T) { 15996ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet return T->getStmtClass() == BinaryTypeTraitExprClass; 16006ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet } 16016ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet static bool classof(const BinaryTypeTraitExpr *) { return true; } 16026ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet 16036ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet // Iterators 160463c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall child_range children() { return child_range(); } 16056ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet 16066ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet friend class ASTStmtReader; 16076ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet}; 16086ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet 160921ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley/// ArrayTypeTraitExpr - An Embarcadero array type trait, as used in the 161021ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley/// implementation of __array_rank and __array_extent. 161121ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley/// Example: 161221ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley/// __array_rank(int[10][20]) == 2 161321ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley/// __array_extent(int, 1) == 20 161421ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegleyclass ArrayTypeTraitExpr : public Expr { 161521ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley /// ATT - The trait. An ArrayTypeTrait enum in MSVC compat unsigned. 161621ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley unsigned ATT : 2; 161721ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley 161821ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley /// The value of the type trait. Unspecified if dependent. 161921ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley uint64_t Value; 162021ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley 162121ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley /// The array dimension being queried, or -1 if not used 162221ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley Expr *Dimension; 162321ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley 162421ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley /// Loc - The location of the type trait keyword. 162521ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley SourceLocation Loc; 162621ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley 162721ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley /// RParen - The location of the closing paren. 162821ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley SourceLocation RParen; 162921ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley 163021ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley /// The type being queried. 163121ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley TypeSourceInfo *QueriedType; 163221ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley 163321ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegleypublic: 163421ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley ArrayTypeTraitExpr(SourceLocation loc, ArrayTypeTrait att, 163521ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley TypeSourceInfo *queried, uint64_t value, 163621ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley Expr *dimension, SourceLocation rparen, QualType ty) 163721ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley : Expr(ArrayTypeTraitExprClass, ty, VK_RValue, OK_Ordinary, 163821ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley false, queried->getType()->isDependentType(), 1639561f81243f665cf2001caadc45df505f826b72d6Douglas Gregor (queried->getType()->isInstantiationDependentType() || 1640561f81243f665cf2001caadc45df505f826b72d6Douglas Gregor (dimension && dimension->isInstantiationDependent())), 164121ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley queried->getType()->containsUnexpandedParameterPack()), 164221ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley ATT(att), Value(value), Dimension(dimension), 164321ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley Loc(loc), RParen(rparen), QueriedType(queried) { } 164421ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley 164521ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley 164621ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley explicit ArrayTypeTraitExpr(EmptyShell Empty) 164721ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley : Expr(ArrayTypeTraitExprClass, Empty), ATT(0), Value(false), 164821ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley QueriedType() { } 164921ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley 165025aaf28c5bec71d5d005df67ee78b908ba5940f4Manuel Klimek virtual ~ArrayTypeTraitExpr() { } 165125aaf28c5bec71d5d005df67ee78b908ba5940f4Manuel Klimek 165221ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley virtual SourceRange getSourceRange() const { return SourceRange(Loc, RParen); } 165321ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley 165421ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley ArrayTypeTrait getTrait() const { return static_cast<ArrayTypeTrait>(ATT); } 165521ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley 165621ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley QualType getQueriedType() const { return QueriedType->getType(); } 165721ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley 165821ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley TypeSourceInfo *getQueriedTypeSourceInfo() const { return QueriedType; } 165921ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley 166021ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley uint64_t getValue() const { assert(!isTypeDependent()); return Value; } 166121ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley 166221ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley Expr *getDimensionExpression() const { return Dimension; } 166321ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley 166421ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley static bool classof(const Stmt *T) { 166521ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley return T->getStmtClass() == ArrayTypeTraitExprClass; 166621ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley } 166721ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley static bool classof(const ArrayTypeTraitExpr *) { return true; } 166821ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley 166921ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley // Iterators 167021ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley child_range children() { return child_range(); } 167121ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley 167221ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley friend class ASTStmtReader; 167321ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley}; 167421ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley 1675552622067dc45013d240f73952fece703f5e63bdJohn Wiegley/// ExpressionTraitExpr - An expression trait intrinsic 1676552622067dc45013d240f73952fece703f5e63bdJohn Wiegley/// Example: 1677552622067dc45013d240f73952fece703f5e63bdJohn Wiegley/// __is_lvalue_expr(std::cout) == true 1678552622067dc45013d240f73952fece703f5e63bdJohn Wiegley/// __is_lvalue_expr(1) == false 1679552622067dc45013d240f73952fece703f5e63bdJohn Wiegleyclass ExpressionTraitExpr : public Expr { 1680552622067dc45013d240f73952fece703f5e63bdJohn Wiegley /// ET - The trait. A ExpressionTrait enum in MSVC compat unsigned. 1681552622067dc45013d240f73952fece703f5e63bdJohn Wiegley unsigned ET : 31; 1682552622067dc45013d240f73952fece703f5e63bdJohn Wiegley /// The value of the type trait. Unspecified if dependent. 1683552622067dc45013d240f73952fece703f5e63bdJohn Wiegley bool Value : 1; 1684552622067dc45013d240f73952fece703f5e63bdJohn Wiegley 1685552622067dc45013d240f73952fece703f5e63bdJohn Wiegley /// Loc - The location of the type trait keyword. 1686552622067dc45013d240f73952fece703f5e63bdJohn Wiegley SourceLocation Loc; 1687552622067dc45013d240f73952fece703f5e63bdJohn Wiegley 1688552622067dc45013d240f73952fece703f5e63bdJohn Wiegley /// RParen - The location of the closing paren. 1689552622067dc45013d240f73952fece703f5e63bdJohn Wiegley SourceLocation RParen; 1690552622067dc45013d240f73952fece703f5e63bdJohn Wiegley 1691552622067dc45013d240f73952fece703f5e63bdJohn Wiegley Expr* QueriedExpression; 1692552622067dc45013d240f73952fece703f5e63bdJohn Wiegleypublic: 1693552622067dc45013d240f73952fece703f5e63bdJohn Wiegley ExpressionTraitExpr(SourceLocation loc, ExpressionTrait et, 1694552622067dc45013d240f73952fece703f5e63bdJohn Wiegley Expr *queried, bool value, 1695552622067dc45013d240f73952fece703f5e63bdJohn Wiegley SourceLocation rparen, QualType resultType) 1696552622067dc45013d240f73952fece703f5e63bdJohn Wiegley : Expr(ExpressionTraitExprClass, resultType, VK_RValue, OK_Ordinary, 1697552622067dc45013d240f73952fece703f5e63bdJohn Wiegley false, // Not type-dependent 1698552622067dc45013d240f73952fece703f5e63bdJohn Wiegley // Value-dependent if the argument is type-dependent. 1699552622067dc45013d240f73952fece703f5e63bdJohn Wiegley queried->isTypeDependent(), 1700561f81243f665cf2001caadc45df505f826b72d6Douglas Gregor queried->isInstantiationDependent(), 1701552622067dc45013d240f73952fece703f5e63bdJohn Wiegley queried->containsUnexpandedParameterPack()), 1702552622067dc45013d240f73952fece703f5e63bdJohn Wiegley ET(et), Value(value), Loc(loc), RParen(rparen), QueriedExpression(queried) { } 1703552622067dc45013d240f73952fece703f5e63bdJohn Wiegley 1704552622067dc45013d240f73952fece703f5e63bdJohn Wiegley explicit ExpressionTraitExpr(EmptyShell Empty) 1705552622067dc45013d240f73952fece703f5e63bdJohn Wiegley : Expr(ExpressionTraitExprClass, Empty), ET(0), Value(false), 1706552622067dc45013d240f73952fece703f5e63bdJohn Wiegley QueriedExpression() { } 1707552622067dc45013d240f73952fece703f5e63bdJohn Wiegley 1708552622067dc45013d240f73952fece703f5e63bdJohn Wiegley SourceRange getSourceRange() const { return SourceRange(Loc, RParen);} 1709552622067dc45013d240f73952fece703f5e63bdJohn Wiegley 1710552622067dc45013d240f73952fece703f5e63bdJohn Wiegley ExpressionTrait getTrait() const { return static_cast<ExpressionTrait>(ET); } 1711552622067dc45013d240f73952fece703f5e63bdJohn Wiegley 1712552622067dc45013d240f73952fece703f5e63bdJohn Wiegley Expr *getQueriedExpression() const { return QueriedExpression; } 1713552622067dc45013d240f73952fece703f5e63bdJohn Wiegley 1714552622067dc45013d240f73952fece703f5e63bdJohn Wiegley bool getValue() const { return Value; } 1715552622067dc45013d240f73952fece703f5e63bdJohn Wiegley 1716552622067dc45013d240f73952fece703f5e63bdJohn Wiegley static bool classof(const Stmt *T) { 1717552622067dc45013d240f73952fece703f5e63bdJohn Wiegley return T->getStmtClass() == ExpressionTraitExprClass; 1718552622067dc45013d240f73952fece703f5e63bdJohn Wiegley } 1719552622067dc45013d240f73952fece703f5e63bdJohn Wiegley static bool classof(const ExpressionTraitExpr *) { return true; } 1720552622067dc45013d240f73952fece703f5e63bdJohn Wiegley 1721552622067dc45013d240f73952fece703f5e63bdJohn Wiegley // Iterators 1722552622067dc45013d240f73952fece703f5e63bdJohn Wiegley child_range children() { return child_range(); } 1723552622067dc45013d240f73952fece703f5e63bdJohn Wiegley 1724552622067dc45013d240f73952fece703f5e63bdJohn Wiegley friend class ASTStmtReader; 1725552622067dc45013d240f73952fece703f5e63bdJohn Wiegley}; 1726552622067dc45013d240f73952fece703f5e63bdJohn Wiegley 1727552622067dc45013d240f73952fece703f5e63bdJohn Wiegley 17287bb12da2b0749eeebb21854c77877736969e59f2John McCall/// \brief A reference to an overloaded function set, either an 17297bb12da2b0749eeebb21854c77877736969e59f2John McCall/// \t UnresolvedLookupExpr or an \t UnresolvedMemberExpr. 17307bb12da2b0749eeebb21854c77877736969e59f2John McCallclass OverloadExpr : public Expr { 1731ba13543329afac4a0d01304ec2ec4924d99306a6John McCall /// The results. These are undesugared, which is to say, they may 17327bb12da2b0749eeebb21854c77877736969e59f2John McCall /// include UsingShadowDecls. Access is relative to the naming 17337bb12da2b0749eeebb21854c77877736969e59f2John McCall /// class. 1734928e6fcf66fc4f342bcf7cc96bf56986c9c2a833Douglas Gregor // FIXME: Allocate this data after the OverloadExpr subclass. 1735928e6fcf66fc4f342bcf7cc96bf56986c9c2a833Douglas Gregor DeclAccessPair *Results; 1736928e6fcf66fc4f342bcf7cc96bf56986c9c2a833Douglas Gregor unsigned NumResults; 1737ba13543329afac4a0d01304ec2ec4924d99306a6John McCall 17387bb12da2b0749eeebb21854c77877736969e59f2John McCall /// The common name of these declarations. 17392577743c5650c646fb705df01403707e94f2df04Abramo Bagnara DeclarationNameInfo NameInfo; 1740ba13543329afac4a0d01304ec2ec4924d99306a6John McCall 17414c9be89bb615ec07eb3ed507c8fa9d0baa8a5ad7Douglas Gregor /// \brief The nested-name-specifier that qualifies the name, if any. 17424c9be89bb615ec07eb3ed507c8fa9d0baa8a5ad7Douglas Gregor NestedNameSpecifierLoc QualifierLoc; 1743ba13543329afac4a0d01304ec2ec4924d99306a6John McCall 1744a77eb0862507b900a10fa352af1568e639ed10b1Argyrios Kyrtzidisprotected: 17457bb12da2b0749eeebb21854c77877736969e59f2John McCall /// True if the name was a template-id. 17467bb12da2b0749eeebb21854c77877736969e59f2John McCall bool HasExplicitTemplateArgs; 17477bb12da2b0749eeebb21854c77877736969e59f2John McCall 1748bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor OverloadExpr(StmtClass K, ASTContext &C, 17494c9be89bb615ec07eb3ed507c8fa9d0baa8a5ad7Douglas Gregor NestedNameSpecifierLoc QualifierLoc, 17502577743c5650c646fb705df01403707e94f2df04Abramo Bagnara const DeclarationNameInfo &NameInfo, 1751bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor const TemplateArgumentListInfo *TemplateArgs, 1752bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor UnresolvedSetIterator Begin, UnresolvedSetIterator End, 1753561f81243f665cf2001caadc45df505f826b72d6Douglas Gregor bool KnownDependent, 1754561f81243f665cf2001caadc45df505f826b72d6Douglas Gregor bool KnownInstantiationDependent, 1755561f81243f665cf2001caadc45df505f826b72d6Douglas Gregor bool KnownContainsUnexpandedParameterPack); 17567bb12da2b0749eeebb21854c77877736969e59f2John McCall 1757a77eb0862507b900a10fa352af1568e639ed10b1Argyrios Kyrtzidis OverloadExpr(StmtClass K, EmptyShell Empty) 1758a77eb0862507b900a10fa352af1568e639ed10b1Argyrios Kyrtzidis : Expr(K, Empty), Results(0), NumResults(0), 17594c9be89bb615ec07eb3ed507c8fa9d0baa8a5ad7Douglas Gregor QualifierLoc(), HasExplicitTemplateArgs(false) { } 1760a77eb0862507b900a10fa352af1568e639ed10b1Argyrios Kyrtzidis 1761bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor void initializeResults(ASTContext &C, 1762bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor UnresolvedSetIterator Begin, 1763bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor UnresolvedSetIterator End); 17647bb12da2b0749eeebb21854c77877736969e59f2John McCall 1765bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregorpublic: 17669c72c6088d591ace8503b842d39448c2040f3033John McCall struct FindResult { 17679c72c6088d591ace8503b842d39448c2040f3033John McCall OverloadExpr *Expression; 17689c72c6088d591ace8503b842d39448c2040f3033John McCall bool IsAddressOfOperand; 17699c72c6088d591ace8503b842d39448c2040f3033John McCall bool HasFormOfMemberPointer; 17709c72c6088d591ace8503b842d39448c2040f3033John McCall }; 17719c72c6088d591ace8503b842d39448c2040f3033John McCall 17727bb12da2b0749eeebb21854c77877736969e59f2John McCall /// Finds the overloaded expression in the given expression of 17737bb12da2b0749eeebb21854c77877736969e59f2John McCall /// OverloadTy. 17747bb12da2b0749eeebb21854c77877736969e59f2John McCall /// 17759c72c6088d591ace8503b842d39448c2040f3033John McCall /// \return the expression (which must be there) and true if it has 17769c72c6088d591ace8503b842d39448c2040f3033John McCall /// the particular form of a member pointer expression 17779c72c6088d591ace8503b842d39448c2040f3033John McCall static FindResult find(Expr *E) { 17787bb12da2b0749eeebb21854c77877736969e59f2John McCall assert(E->getType()->isSpecificBuiltinType(BuiltinType::Overload)); 17797bb12da2b0749eeebb21854c77877736969e59f2John McCall 17809c72c6088d591ace8503b842d39448c2040f3033John McCall FindResult Result; 17819c72c6088d591ace8503b842d39448c2040f3033John McCall 17827bb12da2b0749eeebb21854c77877736969e59f2John McCall E = E->IgnoreParens(); 17839c72c6088d591ace8503b842d39448c2040f3033John McCall if (isa<UnaryOperator>(E)) { 17849c72c6088d591ace8503b842d39448c2040f3033John McCall assert(cast<UnaryOperator>(E)->getOpcode() == UO_AddrOf); 17859c72c6088d591ace8503b842d39448c2040f3033John McCall E = cast<UnaryOperator>(E)->getSubExpr(); 17869c72c6088d591ace8503b842d39448c2040f3033John McCall OverloadExpr *Ovl = cast<OverloadExpr>(E->IgnoreParens()); 17879c72c6088d591ace8503b842d39448c2040f3033John McCall 17889c72c6088d591ace8503b842d39448c2040f3033John McCall Result.HasFormOfMemberPointer = (E == Ovl && Ovl->getQualifier()); 17899c72c6088d591ace8503b842d39448c2040f3033John McCall Result.IsAddressOfOperand = true; 17909c72c6088d591ace8503b842d39448c2040f3033John McCall Result.Expression = Ovl; 17919c72c6088d591ace8503b842d39448c2040f3033John McCall } else { 17929c72c6088d591ace8503b842d39448c2040f3033John McCall Result.HasFormOfMemberPointer = false; 17939c72c6088d591ace8503b842d39448c2040f3033John McCall Result.IsAddressOfOperand = false; 17949c72c6088d591ace8503b842d39448c2040f3033John McCall Result.Expression = cast<OverloadExpr>(E); 17959c72c6088d591ace8503b842d39448c2040f3033John McCall } 17969c72c6088d591ace8503b842d39448c2040f3033John McCall 17979c72c6088d591ace8503b842d39448c2040f3033John McCall return Result; 17987bb12da2b0749eeebb21854c77877736969e59f2John McCall } 17997bb12da2b0749eeebb21854c77877736969e59f2John McCall 1800e9ee23edd17c4bb7f271e67f8790792b4de677fcJohn McCall /// Gets the naming class of this lookup, if any. 1801e9ee23edd17c4bb7f271e67f8790792b4de677fcJohn McCall CXXRecordDecl *getNamingClass() const; 1802e9ee23edd17c4bb7f271e67f8790792b4de677fcJohn McCall 18037bb12da2b0749eeebb21854c77877736969e59f2John McCall typedef UnresolvedSetImpl::iterator decls_iterator; 1804928e6fcf66fc4f342bcf7cc96bf56986c9c2a833Douglas Gregor decls_iterator decls_begin() const { return UnresolvedSetIterator(Results); } 1805928e6fcf66fc4f342bcf7cc96bf56986c9c2a833Douglas Gregor decls_iterator decls_end() const { 1806928e6fcf66fc4f342bcf7cc96bf56986c9c2a833Douglas Gregor return UnresolvedSetIterator(Results + NumResults); 1807928e6fcf66fc4f342bcf7cc96bf56986c9c2a833Douglas Gregor } 1808a77eb0862507b900a10fa352af1568e639ed10b1Argyrios Kyrtzidis 18097bb12da2b0749eeebb21854c77877736969e59f2John McCall /// Gets the number of declarations in the unresolved set. 1810928e6fcf66fc4f342bcf7cc96bf56986c9c2a833Douglas Gregor unsigned getNumDecls() const { return NumResults; } 18117bb12da2b0749eeebb21854c77877736969e59f2John McCall 18122577743c5650c646fb705df01403707e94f2df04Abramo Bagnara /// Gets the full name info. 18132577743c5650c646fb705df01403707e94f2df04Abramo Bagnara const DeclarationNameInfo &getNameInfo() const { return NameInfo; } 18142577743c5650c646fb705df01403707e94f2df04Abramo Bagnara 18157bb12da2b0749eeebb21854c77877736969e59f2John McCall /// Gets the name looked up. 18162577743c5650c646fb705df01403707e94f2df04Abramo Bagnara DeclarationName getName() const { return NameInfo.getName(); } 18177bb12da2b0749eeebb21854c77877736969e59f2John McCall 18187bb12da2b0749eeebb21854c77877736969e59f2John McCall /// Gets the location of the name. 18192577743c5650c646fb705df01403707e94f2df04Abramo Bagnara SourceLocation getNameLoc() const { return NameInfo.getLoc(); } 18207bb12da2b0749eeebb21854c77877736969e59f2John McCall 18217bb12da2b0749eeebb21854c77877736969e59f2John McCall /// Fetches the nested-name qualifier, if one was given. 18224c9be89bb615ec07eb3ed507c8fa9d0baa8a5ad7Douglas Gregor NestedNameSpecifier *getQualifier() const { 18234c9be89bb615ec07eb3ed507c8fa9d0baa8a5ad7Douglas Gregor return QualifierLoc.getNestedNameSpecifier(); 18244c9be89bb615ec07eb3ed507c8fa9d0baa8a5ad7Douglas Gregor } 18257bb12da2b0749eeebb21854c77877736969e59f2John McCall 18264c9be89bb615ec07eb3ed507c8fa9d0baa8a5ad7Douglas Gregor /// Fetches the nested-name qualifier with source-location information, if 18274c9be89bb615ec07eb3ed507c8fa9d0baa8a5ad7Douglas Gregor /// one was given. 18284c9be89bb615ec07eb3ed507c8fa9d0baa8a5ad7Douglas Gregor NestedNameSpecifierLoc getQualifierLoc() const { return QualifierLoc; } 18297bb12da2b0749eeebb21854c77877736969e59f2John McCall 18307bb12da2b0749eeebb21854c77877736969e59f2John McCall /// \brief Determines whether this expression had an explicit 18317bb12da2b0749eeebb21854c77877736969e59f2John McCall /// template argument list, e.g. f<int>. 18327bb12da2b0749eeebb21854c77877736969e59f2John McCall bool hasExplicitTemplateArgs() const { return HasExplicitTemplateArgs; } 18337bb12da2b0749eeebb21854c77877736969e59f2John McCall 18347bb12da2b0749eeebb21854c77877736969e59f2John McCall ExplicitTemplateArgumentList &getExplicitTemplateArgs(); // defined far below 18357bb12da2b0749eeebb21854c77877736969e59f2John McCall 18367bb12da2b0749eeebb21854c77877736969e59f2John McCall const ExplicitTemplateArgumentList &getExplicitTemplateArgs() const { 18377bb12da2b0749eeebb21854c77877736969e59f2John McCall return const_cast<OverloadExpr*>(this)->getExplicitTemplateArgs(); 18387bb12da2b0749eeebb21854c77877736969e59f2John McCall } 18397bb12da2b0749eeebb21854c77877736969e59f2John McCall 1840096832c5ed5b9106fa177ebc148489760c3bc496John McCall /// \brief Retrieves the optional explicit template arguments. 1841096832c5ed5b9106fa177ebc148489760c3bc496John McCall /// This points to the same data as getExplicitTemplateArgs(), but 1842096832c5ed5b9106fa177ebc148489760c3bc496John McCall /// returns null if there are no explicit template arguments. 1843096832c5ed5b9106fa177ebc148489760c3bc496John McCall const ExplicitTemplateArgumentList *getOptionalExplicitTemplateArgs() { 1844096832c5ed5b9106fa177ebc148489760c3bc496John McCall if (!hasExplicitTemplateArgs()) return 0; 1845096832c5ed5b9106fa177ebc148489760c3bc496John McCall return &getExplicitTemplateArgs(); 18467bb12da2b0749eeebb21854c77877736969e59f2John McCall } 18477bb12da2b0749eeebb21854c77877736969e59f2John McCall 18487bb12da2b0749eeebb21854c77877736969e59f2John McCall static bool classof(const Stmt *T) { 18497bb12da2b0749eeebb21854c77877736969e59f2John McCall return T->getStmtClass() == UnresolvedLookupExprClass || 18507bb12da2b0749eeebb21854c77877736969e59f2John McCall T->getStmtClass() == UnresolvedMemberExprClass; 18517bb12da2b0749eeebb21854c77877736969e59f2John McCall } 18527bb12da2b0749eeebb21854c77877736969e59f2John McCall static bool classof(const OverloadExpr *) { return true; } 18534045107b7384fd68eed5e3e2f06fc2a47e7be0a6Argyrios Kyrtzidis 18544045107b7384fd68eed5e3e2f06fc2a47e7be0a6Argyrios Kyrtzidis friend class ASTStmtReader; 18554045107b7384fd68eed5e3e2f06fc2a47e7be0a6Argyrios Kyrtzidis friend class ASTStmtWriter; 18567bb12da2b0749eeebb21854c77877736969e59f2John McCall}; 18577bb12da2b0749eeebb21854c77877736969e59f2John McCall 18587bb12da2b0749eeebb21854c77877736969e59f2John McCall/// \brief A reference to a name which we were able to look up during 18597bb12da2b0749eeebb21854c77877736969e59f2John McCall/// parsing but could not resolve to a specific declaration. This 18607bb12da2b0749eeebb21854c77877736969e59f2John McCall/// arises in several ways: 18617bb12da2b0749eeebb21854c77877736969e59f2John McCall/// * we might be waiting for argument-dependent lookup 18627bb12da2b0749eeebb21854c77877736969e59f2John McCall/// * the name might resolve to an overloaded function 18637bb12da2b0749eeebb21854c77877736969e59f2John McCall/// and eventually: 18647bb12da2b0749eeebb21854c77877736969e59f2John McCall/// * the lookup might have included a function template 18657bb12da2b0749eeebb21854c77877736969e59f2John McCall/// These never include UnresolvedUsingValueDecls, which are always 18667bb12da2b0749eeebb21854c77877736969e59f2John McCall/// class members and therefore appear only in 18677bb12da2b0749eeebb21854c77877736969e59f2John McCall/// UnresolvedMemberLookupExprs. 18687bb12da2b0749eeebb21854c77877736969e59f2John McCallclass UnresolvedLookupExpr : public OverloadExpr { 1869ba13543329afac4a0d01304ec2ec4924d99306a6John McCall /// True if these lookup results should be extended by 1870ba13543329afac4a0d01304ec2ec4924d99306a6John McCall /// argument-dependent lookup if this is the operand of a function 1871ba13543329afac4a0d01304ec2ec4924d99306a6John McCall /// call. 1872ba13543329afac4a0d01304ec2ec4924d99306a6John McCall bool RequiresADL; 1873ba13543329afac4a0d01304ec2ec4924d99306a6John McCall 1874ad762fcdc16b9e4705b12b09d92b8c026212b906Richard Smith /// True if namespace ::std should be considered an associated namespace 1875ad762fcdc16b9e4705b12b09d92b8c026212b906Richard Smith /// for the purposes of argument-dependent lookup. See C++0x [stmt.ranged]p1. 1876ad762fcdc16b9e4705b12b09d92b8c026212b906Richard Smith bool StdIsAssociatedNamespace; 1877ad762fcdc16b9e4705b12b09d92b8c026212b906Richard Smith 18787453ed4cb2cab113de3378df371b1c6f1243d832John McCall /// True if these lookup results are overloaded. This is pretty 18797453ed4cb2cab113de3378df371b1c6f1243d832John McCall /// trivially rederivable if we urgently need to kill this field. 18807453ed4cb2cab113de3378df371b1c6f1243d832John McCall bool Overloaded; 18817453ed4cb2cab113de3378df371b1c6f1243d832John McCall 18827bb12da2b0749eeebb21854c77877736969e59f2John McCall /// The naming class (C++ [class.access.base]p5) of the lookup, if 18837bb12da2b0749eeebb21854c77877736969e59f2John McCall /// any. This can generally be recalculated from the context chain, 18847bb12da2b0749eeebb21854c77877736969e59f2John McCall /// but that can be fairly expensive for unqualified lookups. If we 18857bb12da2b0749eeebb21854c77877736969e59f2John McCall /// want to improve memory use here, this could go in a union 18867bb12da2b0749eeebb21854c77877736969e59f2John McCall /// against the qualified-lookup bits. 18877bb12da2b0749eeebb21854c77877736969e59f2John McCall CXXRecordDecl *NamingClass; 1888f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall 1889bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor UnresolvedLookupExpr(ASTContext &C, 1890928e6fcf66fc4f342bcf7cc96bf56986c9c2a833Douglas Gregor CXXRecordDecl *NamingClass, 18914c9be89bb615ec07eb3ed507c8fa9d0baa8a5ad7Douglas Gregor NestedNameSpecifierLoc QualifierLoc, 18922577743c5650c646fb705df01403707e94f2df04Abramo Bagnara const DeclarationNameInfo &NameInfo, 1893bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor bool RequiresADL, bool Overloaded, 1894bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor const TemplateArgumentListInfo *TemplateArgs, 1895ad762fcdc16b9e4705b12b09d92b8c026212b906Richard Smith UnresolvedSetIterator Begin, UnresolvedSetIterator End, 1896ad762fcdc16b9e4705b12b09d92b8c026212b906Richard Smith bool StdIsAssociatedNamespace) 18974c9be89bb615ec07eb3ed507c8fa9d0baa8a5ad7Douglas Gregor : OverloadExpr(UnresolvedLookupExprClass, C, QualifierLoc, NameInfo, 1898561f81243f665cf2001caadc45df505f826b72d6Douglas Gregor TemplateArgs, Begin, End, false, false, false), 1899ad762fcdc16b9e4705b12b09d92b8c026212b906Richard Smith RequiresADL(RequiresADL), 1900ad762fcdc16b9e4705b12b09d92b8c026212b906Richard Smith StdIsAssociatedNamespace(StdIsAssociatedNamespace), 1901ad762fcdc16b9e4705b12b09d92b8c026212b906Richard Smith Overloaded(Overloaded), NamingClass(NamingClass) 1902ba13543329afac4a0d01304ec2ec4924d99306a6John McCall {} 1903ba13543329afac4a0d01304ec2ec4924d99306a6John McCall 1904bd65bb511c26549c96b829c1282e4c877588564aArgyrios Kyrtzidis UnresolvedLookupExpr(EmptyShell Empty) 1905bd65bb511c26549c96b829c1282e4c877588564aArgyrios Kyrtzidis : OverloadExpr(UnresolvedLookupExprClass, Empty), 1906ad762fcdc16b9e4705b12b09d92b8c026212b906Richard Smith RequiresADL(false), StdIsAssociatedNamespace(false), Overloaded(false), 1907ad762fcdc16b9e4705b12b09d92b8c026212b906Richard Smith NamingClass(0) 1908bd65bb511c26549c96b829c1282e4c877588564aArgyrios Kyrtzidis {} 1909bd65bb511c26549c96b829c1282e4c877588564aArgyrios Kyrtzidis 19104c9be89bb615ec07eb3ed507c8fa9d0baa8a5ad7Douglas Gregor friend class ASTStmtReader; 19114c9be89bb615ec07eb3ed507c8fa9d0baa8a5ad7Douglas Gregor 1912ba13543329afac4a0d01304ec2ec4924d99306a6John McCallpublic: 1913ba13543329afac4a0d01304ec2ec4924d99306a6John McCall static UnresolvedLookupExpr *Create(ASTContext &C, 1914c373d48502ca7683ab55385f5bd624d778eb288dJohn McCall CXXRecordDecl *NamingClass, 19154c9be89bb615ec07eb3ed507c8fa9d0baa8a5ad7Douglas Gregor NestedNameSpecifierLoc QualifierLoc, 19162577743c5650c646fb705df01403707e94f2df04Abramo Bagnara const DeclarationNameInfo &NameInfo, 19175a84dec38cfa9e084377a3167b474c79283c82faDouglas Gregor bool ADL, bool Overloaded, 19185a84dec38cfa9e084377a3167b474c79283c82faDouglas Gregor UnresolvedSetIterator Begin, 1919ad762fcdc16b9e4705b12b09d92b8c026212b906Richard Smith UnresolvedSetIterator End, 1920ad762fcdc16b9e4705b12b09d92b8c026212b906Richard Smith bool StdIsAssociatedNamespace = false) { 1921ad762fcdc16b9e4705b12b09d92b8c026212b906Richard Smith assert((ADL || !StdIsAssociatedNamespace) && 1922ad762fcdc16b9e4705b12b09d92b8c026212b906Richard Smith "std considered associated namespace when not performing ADL"); 19234c9be89bb615ec07eb3ed507c8fa9d0baa8a5ad7Douglas Gregor return new(C) UnresolvedLookupExpr(C, NamingClass, QualifierLoc, NameInfo, 1924ad762fcdc16b9e4705b12b09d92b8c026212b906Richard Smith ADL, Overloaded, 0, Begin, End, 1925ad762fcdc16b9e4705b12b09d92b8c026212b906Richard Smith StdIsAssociatedNamespace); 1926ba13543329afac4a0d01304ec2ec4924d99306a6John McCall } 1927ba13543329afac4a0d01304ec2ec4924d99306a6John McCall 1928f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall static UnresolvedLookupExpr *Create(ASTContext &C, 1929c373d48502ca7683ab55385f5bd624d778eb288dJohn McCall CXXRecordDecl *NamingClass, 19304c9be89bb615ec07eb3ed507c8fa9d0baa8a5ad7Douglas Gregor NestedNameSpecifierLoc QualifierLoc, 19312577743c5650c646fb705df01403707e94f2df04Abramo Bagnara const DeclarationNameInfo &NameInfo, 1932f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall bool ADL, 19335a84dec38cfa9e084377a3167b474c79283c82faDouglas Gregor const TemplateArgumentListInfo &Args, 19345a84dec38cfa9e084377a3167b474c79283c82faDouglas Gregor UnresolvedSetIterator Begin, 19355a84dec38cfa9e084377a3167b474c79283c82faDouglas Gregor UnresolvedSetIterator End); 1936f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall 1937bd65bb511c26549c96b829c1282e4c877588564aArgyrios Kyrtzidis static UnresolvedLookupExpr *CreateEmpty(ASTContext &C, 1938def0354384d9c4431f7b58b664b59896d4623028Douglas Gregor bool HasExplicitTemplateArgs, 1939bd65bb511c26549c96b829c1282e4c877588564aArgyrios Kyrtzidis unsigned NumTemplateArgs); 1940bd65bb511c26549c96b829c1282e4c877588564aArgyrios Kyrtzidis 1941ba13543329afac4a0d01304ec2ec4924d99306a6John McCall /// True if this declaration should be extended by 1942ba13543329afac4a0d01304ec2ec4924d99306a6John McCall /// argument-dependent lookup. 1943ba13543329afac4a0d01304ec2ec4924d99306a6John McCall bool requiresADL() const { return RequiresADL; } 1944ba13543329afac4a0d01304ec2ec4924d99306a6John McCall 1945ad762fcdc16b9e4705b12b09d92b8c026212b906Richard Smith /// True if namespace ::std should be artificially added to the set of 1946ad762fcdc16b9e4705b12b09d92b8c026212b906Richard Smith /// associated namespaecs for argument-dependent lookup purposes. 1947ad762fcdc16b9e4705b12b09d92b8c026212b906Richard Smith bool isStdAssociatedNamespace() const { return StdIsAssociatedNamespace; } 1948ad762fcdc16b9e4705b12b09d92b8c026212b906Richard Smith 19497453ed4cb2cab113de3378df371b1c6f1243d832John McCall /// True if this lookup is overloaded. 19507453ed4cb2cab113de3378df371b1c6f1243d832John McCall bool isOverloaded() const { return Overloaded; } 19517453ed4cb2cab113de3378df371b1c6f1243d832John McCall 1952c373d48502ca7683ab55385f5bd624d778eb288dJohn McCall /// Gets the 'naming class' (in the sense of C++0x 1953c373d48502ca7683ab55385f5bd624d778eb288dJohn McCall /// [class.access.base]p5) of the lookup. This is the scope 1954c373d48502ca7683ab55385f5bd624d778eb288dJohn McCall /// that was looked in to find these results. 1955c373d48502ca7683ab55385f5bd624d778eb288dJohn McCall CXXRecordDecl *getNamingClass() const { return NamingClass; } 1956c373d48502ca7683ab55385f5bd624d778eb288dJohn McCall 1957f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall // Note that, inconsistently with the explicit-template-argument AST 1958f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall // nodes, users are *forbidden* from calling these methods on objects 1959f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall // without explicit template arguments. 1960f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall 19617bb12da2b0749eeebb21854c77877736969e59f2John McCall ExplicitTemplateArgumentList &getExplicitTemplateArgs() { 19627bb12da2b0749eeebb21854c77877736969e59f2John McCall assert(hasExplicitTemplateArgs()); 19637bb12da2b0749eeebb21854c77877736969e59f2John McCall return *reinterpret_cast<ExplicitTemplateArgumentList*>(this + 1); 19647bb12da2b0749eeebb21854c77877736969e59f2John McCall } 19657bb12da2b0749eeebb21854c77877736969e59f2John McCall 1966f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall /// Gets a reference to the explicit template argument list. 1967f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall const ExplicitTemplateArgumentList &getExplicitTemplateArgs() const { 1968f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall assert(hasExplicitTemplateArgs()); 1969f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall return *reinterpret_cast<const ExplicitTemplateArgumentList*>(this + 1); 1970f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall } 1971f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall 1972096832c5ed5b9106fa177ebc148489760c3bc496John McCall /// \brief Retrieves the optional explicit template arguments. 1973096832c5ed5b9106fa177ebc148489760c3bc496John McCall /// This points to the same data as getExplicitTemplateArgs(), but 1974096832c5ed5b9106fa177ebc148489760c3bc496John McCall /// returns null if there are no explicit template arguments. 1975096832c5ed5b9106fa177ebc148489760c3bc496John McCall const ExplicitTemplateArgumentList *getOptionalExplicitTemplateArgs() { 1976096832c5ed5b9106fa177ebc148489760c3bc496John McCall if (!hasExplicitTemplateArgs()) return 0; 1977096832c5ed5b9106fa177ebc148489760c3bc496John McCall return &getExplicitTemplateArgs(); 1978096832c5ed5b9106fa177ebc148489760c3bc496John McCall } 1979096832c5ed5b9106fa177ebc148489760c3bc496John McCall 1980f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall /// \brief Copies the template arguments (if present) into the given 1981f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall /// structure. 1982f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall void copyTemplateArgumentsInto(TemplateArgumentListInfo &List) const { 1983f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall getExplicitTemplateArgs().copyInto(List); 1984f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall } 1985ba13543329afac4a0d01304ec2ec4924d99306a6John McCall 1986f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall SourceLocation getLAngleLoc() const { 1987f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall return getExplicitTemplateArgs().LAngleLoc; 1988f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall } 1989f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall 1990f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall SourceLocation getRAngleLoc() const { 1991f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall return getExplicitTemplateArgs().RAngleLoc; 1992f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall } 1993f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall 1994f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall TemplateArgumentLoc const *getTemplateArgs() const { 1995f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall return getExplicitTemplateArgs().getTemplateArgs(); 1996f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall } 1997f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall 1998f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall unsigned getNumTemplateArgs() const { 1999f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall return getExplicitTemplateArgs().NumTemplateArgs; 2000f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall } 2001ba13543329afac4a0d01304ec2ec4924d99306a6John McCall 200263c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall SourceRange getSourceRange() const { 20032577743c5650c646fb705df01403707e94f2df04Abramo Bagnara SourceRange Range(getNameInfo().getSourceRange()); 20044c9be89bb615ec07eb3ed507c8fa9d0baa8a5ad7Douglas Gregor if (getQualifierLoc()) 20054c9be89bb615ec07eb3ed507c8fa9d0baa8a5ad7Douglas Gregor Range.setBegin(getQualifierLoc().getBeginLoc()); 20064c9be89bb615ec07eb3ed507c8fa9d0baa8a5ad7Douglas Gregor if (hasExplicitTemplateArgs()) 20074c9be89bb615ec07eb3ed507c8fa9d0baa8a5ad7Douglas Gregor Range.setEnd(getRAngleLoc()); 2008f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall return Range; 2009ba13543329afac4a0d01304ec2ec4924d99306a6John McCall } 2010ba13543329afac4a0d01304ec2ec4924d99306a6John McCall 201163c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall child_range children() { return child_range(); } 2012ba13543329afac4a0d01304ec2ec4924d99306a6John McCall 2013ba13543329afac4a0d01304ec2ec4924d99306a6John McCall static bool classof(const Stmt *T) { 2014ba13543329afac4a0d01304ec2ec4924d99306a6John McCall return T->getStmtClass() == UnresolvedLookupExprClass; 2015ba13543329afac4a0d01304ec2ec4924d99306a6John McCall } 2016ba13543329afac4a0d01304ec2ec4924d99306a6John McCall static bool classof(const UnresolvedLookupExpr *) { return true; } 2017ba13543329afac4a0d01304ec2ec4924d99306a6John McCall}; 2018ba13543329afac4a0d01304ec2ec4924d99306a6John McCall 20195953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor/// \brief A qualified reference to a name whose declaration cannot 20205953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor/// yet be resolved. 20215953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor/// 2022ba13543329afac4a0d01304ec2ec4924d99306a6John McCall/// DependentScopeDeclRefExpr is similar to DeclRefExpr in that 2023a2813cec2605ce7878d1b13471d685f689b251afDouglas Gregor/// it expresses a reference to a declaration such as 20245953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor/// X<T>::value. The difference, however, is that an 2025865d447ac6a4721ab58e898d014a21f2eff74b06John McCall/// DependentScopeDeclRefExpr node is used only within C++ templates when 20265953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor/// the qualification (e.g., X<T>::) refers to a dependent type. In 20275953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor/// this case, X<T>::value cannot resolve to a declaration because the 20285953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor/// declaration will differ from on instantiation of X<T> to the 2029865d447ac6a4721ab58e898d014a21f2eff74b06John McCall/// next. Therefore, DependentScopeDeclRefExpr keeps track of the 2030ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor/// qualifier (X<T>::) and the name of the entity being referenced 2031a2813cec2605ce7878d1b13471d685f689b251afDouglas Gregor/// ("value"). Such expressions will instantiate to a DeclRefExpr once the 2032a2813cec2605ce7878d1b13471d685f689b251afDouglas Gregor/// declaration can be found. 2033865d447ac6a4721ab58e898d014a21f2eff74b06John McCallclass DependentScopeDeclRefExpr : public Expr { 2034ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor /// \brief The nested-name-specifier that qualifies this unresolved 2035ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor /// declaration name. 203600cf3cc2718671aa48e8da264a523b0058a8591eDouglas Gregor NestedNameSpecifierLoc QualifierLoc; 203700cf3cc2718671aa48e8da264a523b0058a8591eDouglas Gregor 203800cf3cc2718671aa48e8da264a523b0058a8591eDouglas Gregor /// The name of the entity we will be referencing. 203900cf3cc2718671aa48e8da264a523b0058a8591eDouglas Gregor DeclarationNameInfo NameInfo; 20405953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor 2041f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall /// \brief Whether the name includes explicit template arguments. 2042f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall bool HasExplicitTemplateArgs; 20431eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 2044f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall DependentScopeDeclRefExpr(QualType T, 204500cf3cc2718671aa48e8da264a523b0058a8591eDouglas Gregor NestedNameSpecifierLoc QualifierLoc, 20462577743c5650c646fb705df01403707e94f2df04Abramo Bagnara const DeclarationNameInfo &NameInfo, 2047bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor const TemplateArgumentListInfo *Args); 2048f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall 2049f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCallpublic: 2050f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall static DependentScopeDeclRefExpr *Create(ASTContext &C, 205100cf3cc2718671aa48e8da264a523b0058a8591eDouglas Gregor NestedNameSpecifierLoc QualifierLoc, 20522577743c5650c646fb705df01403707e94f2df04Abramo Bagnara const DeclarationNameInfo &NameInfo, 2053f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall const TemplateArgumentListInfo *TemplateArgs = 0); 20545953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor 205512dffcddb60380c5bed4f085a1f51534afda3b87Argyrios Kyrtzidis static DependentScopeDeclRefExpr *CreateEmpty(ASTContext &C, 2056def0354384d9c4431f7b58b664b59896d4623028Douglas Gregor bool HasExplicitTemplateArgs, 205712dffcddb60380c5bed4f085a1f51534afda3b87Argyrios Kyrtzidis unsigned NumTemplateArgs); 205812dffcddb60380c5bed4f085a1f51534afda3b87Argyrios Kyrtzidis 20595953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor /// \brief Retrieve the name that this expression refers to. 20602577743c5650c646fb705df01403707e94f2df04Abramo Bagnara const DeclarationNameInfo &getNameInfo() const { return NameInfo; } 20612577743c5650c646fb705df01403707e94f2df04Abramo Bagnara 20622577743c5650c646fb705df01403707e94f2df04Abramo Bagnara /// \brief Retrieve the name that this expression refers to. 20632577743c5650c646fb705df01403707e94f2df04Abramo Bagnara DeclarationName getDeclName() const { return NameInfo.getName(); } 20645953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor 20655953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor /// \brief Retrieve the location of the name within the expression. 20662577743c5650c646fb705df01403707e94f2df04Abramo Bagnara SourceLocation getLocation() const { return NameInfo.getLoc(); } 20675953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor 206800cf3cc2718671aa48e8da264a523b0058a8591eDouglas Gregor /// \brief Retrieve the nested-name-specifier that qualifies the 206900cf3cc2718671aa48e8da264a523b0058a8591eDouglas Gregor /// name, with source location information. 207000cf3cc2718671aa48e8da264a523b0058a8591eDouglas Gregor NestedNameSpecifierLoc getQualifierLoc() const { return QualifierLoc; } 207100cf3cc2718671aa48e8da264a523b0058a8591eDouglas Gregor 207200cf3cc2718671aa48e8da264a523b0058a8591eDouglas Gregor 2073ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor /// \brief Retrieve the nested-name-specifier that qualifies this 2074ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor /// declaration. 207500cf3cc2718671aa48e8da264a523b0058a8591eDouglas Gregor NestedNameSpecifier *getQualifier() const { 207600cf3cc2718671aa48e8da264a523b0058a8591eDouglas Gregor return QualifierLoc.getNestedNameSpecifier(); 207700cf3cc2718671aa48e8da264a523b0058a8591eDouglas Gregor } 20781eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 2079f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall /// Determines whether this lookup had explicit template arguments. 2080f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall bool hasExplicitTemplateArgs() const { return HasExplicitTemplateArgs; } 20811eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 2082f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall // Note that, inconsistently with the explicit-template-argument AST 2083f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall // nodes, users are *forbidden* from calling these methods on objects 2084f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall // without explicit template arguments. 20851eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 208612dffcddb60380c5bed4f085a1f51534afda3b87Argyrios Kyrtzidis ExplicitTemplateArgumentList &getExplicitTemplateArgs() { 208712dffcddb60380c5bed4f085a1f51534afda3b87Argyrios Kyrtzidis assert(hasExplicitTemplateArgs()); 208812dffcddb60380c5bed4f085a1f51534afda3b87Argyrios Kyrtzidis return *reinterpret_cast<ExplicitTemplateArgumentList*>(this + 1); 208912dffcddb60380c5bed4f085a1f51534afda3b87Argyrios Kyrtzidis } 209012dffcddb60380c5bed4f085a1f51534afda3b87Argyrios Kyrtzidis 2091f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall /// Gets a reference to the explicit template argument list. 2092f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall const ExplicitTemplateArgumentList &getExplicitTemplateArgs() const { 2093f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall assert(hasExplicitTemplateArgs()); 2094f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall return *reinterpret_cast<const ExplicitTemplateArgumentList*>(this + 1); 2095f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall } 20961eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 2097096832c5ed5b9106fa177ebc148489760c3bc496John McCall /// \brief Retrieves the optional explicit template arguments. 2098096832c5ed5b9106fa177ebc148489760c3bc496John McCall /// This points to the same data as getExplicitTemplateArgs(), but 2099096832c5ed5b9106fa177ebc148489760c3bc496John McCall /// returns null if there are no explicit template arguments. 2100096832c5ed5b9106fa177ebc148489760c3bc496John McCall const ExplicitTemplateArgumentList *getOptionalExplicitTemplateArgs() { 2101096832c5ed5b9106fa177ebc148489760c3bc496John McCall if (!hasExplicitTemplateArgs()) return 0; 2102096832c5ed5b9106fa177ebc148489760c3bc496John McCall return &getExplicitTemplateArgs(); 2103096832c5ed5b9106fa177ebc148489760c3bc496John McCall } 2104096832c5ed5b9106fa177ebc148489760c3bc496John McCall 2105f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall /// \brief Copies the template arguments (if present) into the given 2106f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall /// structure. 2107f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall void copyTemplateArgumentsInto(TemplateArgumentListInfo &List) const { 2108f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall getExplicitTemplateArgs().copyInto(List); 2109f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall } 2110f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall 2111f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall SourceLocation getLAngleLoc() const { 2112f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall return getExplicitTemplateArgs().LAngleLoc; 2113edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor } 21141eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 2115f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall SourceLocation getRAngleLoc() const { 2116f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall return getExplicitTemplateArgs().RAngleLoc; 2117f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall } 21181eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 2119f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall TemplateArgumentLoc const *getTemplateArgs() const { 2120f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall return getExplicitTemplateArgs().getTemplateArgs(); 2121d5532b6cfff2977e0c59fa6ead7f7973984a620dJohn McCall } 2122d5532b6cfff2977e0c59fa6ead7f7973984a620dJohn McCall 2123f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall unsigned getNumTemplateArgs() const { 2124f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall return getExplicitTemplateArgs().NumTemplateArgs; 2125f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall } 21261eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 212763c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall SourceRange getSourceRange() const { 212800cf3cc2718671aa48e8da264a523b0058a8591eDouglas Gregor SourceRange Range(QualifierLoc.getBeginLoc(), getLocation()); 2129f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall if (hasExplicitTemplateArgs()) 2130f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall Range.setEnd(getRAngleLoc()); 2131f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall return Range; 2132edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor } 21331eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 21341eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump static bool classof(const Stmt *T) { 2135f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall return T->getStmtClass() == DependentScopeDeclRefExprClass; 2136edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor } 2137f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall static bool classof(const DependentScopeDeclRefExpr *) { return true; } 2138f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall 213963c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall child_range children() { return child_range(); } 21404045107b7384fd68eed5e3e2f06fc2a47e7be0a6Argyrios Kyrtzidis 21414045107b7384fd68eed5e3e2f06fc2a47e7be0a6Argyrios Kyrtzidis friend class ASTStmtReader; 21424045107b7384fd68eed5e3e2f06fc2a47e7be0a6Argyrios Kyrtzidis friend class ASTStmtWriter; 2143edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor}; 21441eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 21454765fa05b5652fcc4356371c2f481d0ea9a1b007John McCall/// Represents an expression --- generally a full-expression --- which 21464765fa05b5652fcc4356371c2f481d0ea9a1b007John McCall/// introduces cleanups to be run at the end of the sub-expression's 21474765fa05b5652fcc4356371c2f481d0ea9a1b007John McCall/// evaluation. The most common source of expression-introduced 21484765fa05b5652fcc4356371c2f481d0ea9a1b007John McCall/// cleanups is temporary objects in C++, but several other C++ 21494765fa05b5652fcc4356371c2f481d0ea9a1b007John McCall/// expressions can create cleanups. 21504765fa05b5652fcc4356371c2f481d0ea9a1b007John McCallclass ExprWithCleanups : public Expr { 215102bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson Stmt *SubExpr; 21521eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 2153ff6b3d64c9f07155f1414411b8451d7bf8937c62Anders Carlsson CXXTemporary **Temps; 2154ff6b3d64c9f07155f1414411b8451d7bf8937c62Anders Carlsson unsigned NumTemps; 215502bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson 21564765fa05b5652fcc4356371c2f481d0ea9a1b007John McCall ExprWithCleanups(ASTContext &C, Expr *SubExpr, 21574765fa05b5652fcc4356371c2f481d0ea9a1b007John McCall CXXTemporary **Temps, unsigned NumTemps); 21584765fa05b5652fcc4356371c2f481d0ea9a1b007John McCall 215988eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlssonpublic: 21604765fa05b5652fcc4356371c2f481d0ea9a1b007John McCall ExprWithCleanups(EmptyShell Empty) 21614765fa05b5652fcc4356371c2f481d0ea9a1b007John McCall : Expr(ExprWithCleanupsClass, Empty), 2162d2598368876cfe40bc8465540033bc5b5e58d8afChris Lattner SubExpr(0), Temps(0), NumTemps(0) {} 2163d2598368876cfe40bc8465540033bc5b5e58d8afChris Lattner 21644765fa05b5652fcc4356371c2f481d0ea9a1b007John McCall static ExprWithCleanups *Create(ASTContext &C, Expr *SubExpr, 21650ece491d8f62ce67f047491a6703fac0d3bd4ff4Anders Carlsson CXXTemporary **Temps, 21660ece491d8f62ce67f047491a6703fac0d3bd4ff4Anders Carlsson unsigned NumTemps); 21671eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 216888eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlsson unsigned getNumTemporaries() const { return NumTemps; } 2169d04ed416be7c55bddddab1fa3fd38a0113a6b3daTed Kremenek void setNumTemporaries(ASTContext &C, unsigned N); 2170d2598368876cfe40bc8465540033bc5b5e58d8afChris Lattner 217188eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlsson CXXTemporary *getTemporary(unsigned i) { 217288eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlsson assert(i < NumTemps && "Index out of range"); 217388eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlsson return Temps[i]; 217488eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlsson } 2175f0721fe438d7e40c168e5d664970e7830bc138fbAnders Carlsson const CXXTemporary *getTemporary(unsigned i) const { 21764765fa05b5652fcc4356371c2f481d0ea9a1b007John McCall return const_cast<ExprWithCleanups*>(this)->getTemporary(i); 2177f0721fe438d7e40c168e5d664970e7830bc138fbAnders Carlsson } 2178d2598368876cfe40bc8465540033bc5b5e58d8afChris Lattner void setTemporary(unsigned i, CXXTemporary *T) { 2179d2598368876cfe40bc8465540033bc5b5e58d8afChris Lattner assert(i < NumTemps && "Index out of range"); 2180d2598368876cfe40bc8465540033bc5b5e58d8afChris Lattner Temps[i] = T; 2181d2598368876cfe40bc8465540033bc5b5e58d8afChris Lattner } 21821eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 218302bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson Expr *getSubExpr() { return cast<Expr>(SubExpr); } 2184f0721fe438d7e40c168e5d664970e7830bc138fbAnders Carlsson const Expr *getSubExpr() const { return cast<Expr>(SubExpr); } 218588eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlsson void setSubExpr(Expr *E) { SubExpr = E; } 218602bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson 218763c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall SourceRange getSourceRange() const { 218896be6917e1c4ba1f4435a14c9e7c6c139571d086Douglas Gregor return SubExpr->getSourceRange(); 218996be6917e1c4ba1f4435a14c9e7c6c139571d086Douglas Gregor } 219002bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson 219102bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson // Implement isa/cast/dyncast/etc. 219202bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson static bool classof(const Stmt *T) { 21934765fa05b5652fcc4356371c2f481d0ea9a1b007John McCall return T->getStmtClass() == ExprWithCleanupsClass; 219402bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson } 21954765fa05b5652fcc4356371c2f481d0ea9a1b007John McCall static bool classof(const ExprWithCleanups *) { return true; } 219602bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson 219702bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson // Iterators 219863c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall child_range children() { return child_range(&SubExpr, &SubExpr + 1); } 219902bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson}; 220002bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson 2201d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// \brief Describes an explicit type conversion that uses functional 2202d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// notion but could not be resolved because one or more arguments are 2203d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// type-dependent. 2204d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// 2205d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// The explicit type conversions expressed by 2206d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// CXXUnresolvedConstructExpr have the form \c T(a1, a2, ..., aN), 2207d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// where \c T is some type and \c a1, a2, ..., aN are values, and 2208d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// either \C T is a dependent type or one or more of the \c a's is 2209d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// type-dependent. For example, this would occur in a template such 2210d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// as: 2211d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// 2212d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// \code 2213d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// template<typename T, typename A1> 2214d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// inline T make_a(const A1& a1) { 2215d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// return T(a1); 2216d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// } 2217d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// \endcode 2218d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// 2219d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// When the returned expression is instantiated, it may resolve to a 2220d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// constructor call, conversion function call, or some kind of type 2221d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// conversion. 2222d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregorclass CXXUnresolvedConstructExpr : public Expr { 2223d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor /// \brief The type being constructed. 2224ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor TypeSourceInfo *Type; 2225ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor 2226d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor /// \brief The location of the left parentheses ('('). 2227d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor SourceLocation LParenLoc; 2228d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor 2229d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor /// \brief The location of the right parentheses (')'). 2230d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor SourceLocation RParenLoc; 2231d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor 2232d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor /// \brief The number of arguments used to construct the type. 2233d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor unsigned NumArgs; 22341eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 2235ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor CXXUnresolvedConstructExpr(TypeSourceInfo *Type, 2236d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor SourceLocation LParenLoc, 2237d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor Expr **Args, 2238d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor unsigned NumArgs, 2239d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor SourceLocation RParenLoc); 2240d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor 22418dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis CXXUnresolvedConstructExpr(EmptyShell Empty, unsigned NumArgs) 2242ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor : Expr(CXXUnresolvedConstructExprClass, Empty), Type(), NumArgs(NumArgs) { } 22438dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis 2244ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor friend class ASTStmtReader; 2245ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor 2246d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregorpublic: 22471eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump static CXXUnresolvedConstructExpr *Create(ASTContext &C, 2248ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor TypeSourceInfo *Type, 2249d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor SourceLocation LParenLoc, 2250d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor Expr **Args, 2251d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor unsigned NumArgs, 2252d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor SourceLocation RParenLoc); 2253d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor 22548dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis static CXXUnresolvedConstructExpr *CreateEmpty(ASTContext &C, 22558dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis unsigned NumArgs); 22568dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis 2257d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor /// \brief Retrieve the type that is being constructed, as specified 2258d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor /// in the source code. 2259ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor QualType getTypeAsWritten() const { return Type->getType(); } 2260d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor 2261ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor /// \brief Retrieve the type source information for the type being 2262ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor /// constructed. 2263ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor TypeSourceInfo *getTypeSourceInfo() const { return Type; } 2264ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor 2265d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor /// \brief Retrieve the location of the left parentheses ('(') that 2266d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor /// precedes the argument list. 2267d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor SourceLocation getLParenLoc() const { return LParenLoc; } 2268d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor void setLParenLoc(SourceLocation L) { LParenLoc = L; } 2269d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor 2270d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor /// \brief Retrieve the location of the right parentheses (')') that 2271d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor /// follows the argument list. 2272d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor SourceLocation getRParenLoc() const { return RParenLoc; } 2273d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor void setRParenLoc(SourceLocation L) { RParenLoc = L; } 2274d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor 2275d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor /// \brief Retrieve the number of arguments. 2276d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor unsigned arg_size() const { return NumArgs; } 2277d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor 2278d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor typedef Expr** arg_iterator; 2279d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor arg_iterator arg_begin() { return reinterpret_cast<Expr**>(this + 1); } 2280d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor arg_iterator arg_end() { return arg_begin() + NumArgs; } 2281d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor 22821dd7383dc48718c452e71a625b29531dd96fbb9dJohn McCall typedef const Expr* const * const_arg_iterator; 22831dd7383dc48718c452e71a625b29531dd96fbb9dJohn McCall const_arg_iterator arg_begin() const { 22841dd7383dc48718c452e71a625b29531dd96fbb9dJohn McCall return reinterpret_cast<const Expr* const *>(this + 1); 22851dd7383dc48718c452e71a625b29531dd96fbb9dJohn McCall } 22861dd7383dc48718c452e71a625b29531dd96fbb9dJohn McCall const_arg_iterator arg_end() const { 22871dd7383dc48718c452e71a625b29531dd96fbb9dJohn McCall return arg_begin() + NumArgs; 22881dd7383dc48718c452e71a625b29531dd96fbb9dJohn McCall } 22891dd7383dc48718c452e71a625b29531dd96fbb9dJohn McCall 2290d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor Expr *getArg(unsigned I) { 2291d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor assert(I < NumArgs && "Argument index out-of-range"); 2292d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor return *(arg_begin() + I); 2293d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor } 2294d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor 22951dd7383dc48718c452e71a625b29531dd96fbb9dJohn McCall const Expr *getArg(unsigned I) const { 22961dd7383dc48718c452e71a625b29531dd96fbb9dJohn McCall assert(I < NumArgs && "Argument index out-of-range"); 22971dd7383dc48718c452e71a625b29531dd96fbb9dJohn McCall return *(arg_begin() + I); 22981dd7383dc48718c452e71a625b29531dd96fbb9dJohn McCall } 22991dd7383dc48718c452e71a625b29531dd96fbb9dJohn McCall 23008dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis void setArg(unsigned I, Expr *E) { 23018dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis assert(I < NumArgs && "Argument index out-of-range"); 23028dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis *(arg_begin() + I) = E; 23038dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis } 23048dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis 230563c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall SourceRange getSourceRange() const; 2306ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor 23071eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump static bool classof(const Stmt *T) { 2308d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor return T->getStmtClass() == CXXUnresolvedConstructExprClass; 2309d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor } 2310d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor static bool classof(const CXXUnresolvedConstructExpr *) { return true; } 2311d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor 2312d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor // Iterators 231363c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall child_range children() { 231463c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall Stmt **begin = reinterpret_cast<Stmt**>(this+1); 231563c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall return child_range(begin, begin + NumArgs); 231663c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall } 2317d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor}; 2318d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor 2319ba13543329afac4a0d01304ec2ec4924d99306a6John McCall/// \brief Represents a C++ member access expression where the actual 2320ba13543329afac4a0d01304ec2ec4924d99306a6John McCall/// member referenced could not be resolved because the base 2321ba13543329afac4a0d01304ec2ec4924d99306a6John McCall/// expression or the member name was dependent. 2322aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall/// 2323aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall/// Like UnresolvedMemberExprs, these can be either implicit or 2324aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall/// explicit accesses. It is only possible to get one of these with 2325aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall/// an implicit access if a qualifier is provided. 2326865d447ac6a4721ab58e898d014a21f2eff74b06John McCallclass CXXDependentScopeMemberExpr : public Expr { 23271c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor /// \brief The expression for the base pointer or class reference, 2328aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall /// e.g., the \c x in x.f. Can be null in implicit accesses. 23291c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor Stmt *Base; 23301eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 2331aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall /// \brief The type of the base expression. Never null, even for 2332aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall /// implicit accesses. 2333aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall QualType BaseType; 2334aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall 23351c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor /// \brief Whether this member expression used the '->' operator or 23361c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor /// the '.' operator. 23373b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor bool IsArrow : 1; 23381c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor 23393b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor /// \brief Whether this member expression has explicitly-specified template 23403b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor /// arguments. 2341aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall bool HasExplicitTemplateArgs : 1; 23421eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 23431c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor /// \brief The location of the '->' or '.' operator. 23441c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor SourceLocation OperatorLoc; 23451c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor 2346a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor /// \brief The nested-name-specifier that precedes the member name, if any. 23477c3179cf463c3b3b8c21dbb955f933ba50b74f28Douglas Gregor NestedNameSpecifierLoc QualifierLoc; 23481eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 2349c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor /// \brief In a qualified member access expression such as t->Base::f, this 23501eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump /// member stores the resolves of name lookup in the context of the member 2351c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor /// access expression, to be used at instantiation time. 2352c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor /// 235346bb4f1a3ac9517406887939612eb8df4b7be006Douglas Gregor /// FIXME: This member, along with the QualifierLoc, could 2354c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor /// be stuck into a structure that is optionally allocated at the end of 2355865d447ac6a4721ab58e898d014a21f2eff74b06John McCall /// the CXXDependentScopeMemberExpr, to save space in the common case. 2356c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor NamedDecl *FirstQualifierFoundInScope; 23571eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 23581c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor /// \brief The member to which this member expression refers, which 23591c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor /// can be name, overloaded operator, or destructor. 2360a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor /// FIXME: could also be a template-id 23612577743c5650c646fb705df01403707e94f2df04Abramo Bagnara DeclarationNameInfo MemberNameInfo; 23621eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 2363865d447ac6a4721ab58e898d014a21f2eff74b06John McCall CXXDependentScopeMemberExpr(ASTContext &C, 2364aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall Expr *Base, QualType BaseType, bool IsArrow, 23653b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor SourceLocation OperatorLoc, 23667c3179cf463c3b3b8c21dbb955f933ba50b74f28Douglas Gregor NestedNameSpecifierLoc QualifierLoc, 23673b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor NamedDecl *FirstQualifierFoundInScope, 23682577743c5650c646fb705df01403707e94f2df04Abramo Bagnara DeclarationNameInfo MemberNameInfo, 2369d5532b6cfff2977e0c59fa6ead7f7973984a620dJohn McCall const TemplateArgumentListInfo *TemplateArgs); 23701eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 23711c0ca59416999129d0439c2661d137ef38e86209Douglas Gregorpublic: 2372865d447ac6a4721ab58e898d014a21f2eff74b06John McCall CXXDependentScopeMemberExpr(ASTContext &C, 2373bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor Expr *Base, QualType BaseType, 2374bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor bool IsArrow, 2375bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor SourceLocation OperatorLoc, 23767c3179cf463c3b3b8c21dbb955f933ba50b74f28Douglas Gregor NestedNameSpecifierLoc QualifierLoc, 2377bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor NamedDecl *FirstQualifierFoundInScope, 2378bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor DeclarationNameInfo MemberNameInfo); 23791eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 2380865d447ac6a4721ab58e898d014a21f2eff74b06John McCall static CXXDependentScopeMemberExpr * 23811eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump Create(ASTContext &C, 2382aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall Expr *Base, QualType BaseType, bool IsArrow, 23833b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor SourceLocation OperatorLoc, 23847c3179cf463c3b3b8c21dbb955f933ba50b74f28Douglas Gregor NestedNameSpecifierLoc QualifierLoc, 23853b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor NamedDecl *FirstQualifierFoundInScope, 23862577743c5650c646fb705df01403707e94f2df04Abramo Bagnara DeclarationNameInfo MemberNameInfo, 2387d5532b6cfff2977e0c59fa6ead7f7973984a620dJohn McCall const TemplateArgumentListInfo *TemplateArgs); 23881eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 23898dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis static CXXDependentScopeMemberExpr * 2390def0354384d9c4431f7b58b664b59896d4623028Douglas Gregor CreateEmpty(ASTContext &C, bool HasExplicitTemplateArgs, 2391def0354384d9c4431f7b58b664b59896d4623028Douglas Gregor unsigned NumTemplateArgs); 23928dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis 2393aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall /// \brief True if this is an implicit access, i.e. one in which the 2394aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall /// member being accessed was not written in the source. The source 2395aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall /// location of the operator is invalid in this case. 23964c9be89bb615ec07eb3ed507c8fa9d0baa8a5ad7Douglas Gregor bool isImplicitAccess() const; 2397aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall 23981c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor /// \brief Retrieve the base object of this member expressions, 23991c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor /// e.g., the \c x in \c x.m. 2400aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall Expr *getBase() const { 2401aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall assert(!isImplicitAccess()); 2402aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall return cast<Expr>(Base); 2403aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall } 24041c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor 2405aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall QualType getBaseType() const { return BaseType; } 2406aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall 24071c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor /// \brief Determine whether this member expression used the '->' 24081c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor /// operator; otherwise, it used the '.' operator. 24091c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor bool isArrow() const { return IsArrow; } 24101c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor 24111c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor /// \brief Retrieve the location of the '->' or '.' operator. 24121c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor SourceLocation getOperatorLoc() const { return OperatorLoc; } 24131c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor 2414a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor /// \brief Retrieve the nested-name-specifier that qualifies the member 2415a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor /// name. 24167c3179cf463c3b3b8c21dbb955f933ba50b74f28Douglas Gregor NestedNameSpecifier *getQualifier() const { 24177c3179cf463c3b3b8c21dbb955f933ba50b74f28Douglas Gregor return QualifierLoc.getNestedNameSpecifier(); 24187c3179cf463c3b3b8c21dbb955f933ba50b74f28Douglas Gregor } 24191eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 24207c3179cf463c3b3b8c21dbb955f933ba50b74f28Douglas Gregor /// \brief Retrieve the nested-name-specifier that qualifies the member 24217c3179cf463c3b3b8c21dbb955f933ba50b74f28Douglas Gregor /// name, with source location information. 24227c3179cf463c3b3b8c21dbb955f933ba50b74f28Douglas Gregor NestedNameSpecifierLoc getQualifierLoc() const { return QualifierLoc; } 24237c3179cf463c3b3b8c21dbb955f933ba50b74f28Douglas Gregor 24247c3179cf463c3b3b8c21dbb955f933ba50b74f28Douglas Gregor 2425c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor /// \brief Retrieve the first part of the nested-name-specifier that was 2426c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor /// found in the scope of the member access expression when the member access 2427c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor /// was initially parsed. 2428c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor /// 2429c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor /// This function only returns a useful result when member access expression 24301eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump /// uses a qualified member name, e.g., "x.Base::f". Here, the declaration 24311eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump /// returned by this function describes what was found by unqualified name 2432c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor /// lookup for the identifier "Base" within the scope of the member access 2433c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor /// expression itself. At template instantiation time, this information is 2434c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor /// combined with the results of name lookup into the type of the object 2435c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor /// expression itself (the class type of x). 24361eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump NamedDecl *getFirstQualifierFoundInScope() const { 2437c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor return FirstQualifierFoundInScope; 2438c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor } 24391eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 24401c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor /// \brief Retrieve the name of the member that this expression 24411c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor /// refers to. 24422577743c5650c646fb705df01403707e94f2df04Abramo Bagnara const DeclarationNameInfo &getMemberNameInfo() const { 24432577743c5650c646fb705df01403707e94f2df04Abramo Bagnara return MemberNameInfo; 24442577743c5650c646fb705df01403707e94f2df04Abramo Bagnara } 24452577743c5650c646fb705df01403707e94f2df04Abramo Bagnara 24462577743c5650c646fb705df01403707e94f2df04Abramo Bagnara /// \brief Retrieve the name of the member that this expression 24472577743c5650c646fb705df01403707e94f2df04Abramo Bagnara /// refers to. 24482577743c5650c646fb705df01403707e94f2df04Abramo Bagnara DeclarationName getMember() const { return MemberNameInfo.getName(); } 24491c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor 24501c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor // \brief Retrieve the location of the name of the member that this 24511c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor // expression refers to. 24522577743c5650c646fb705df01403707e94f2df04Abramo Bagnara SourceLocation getMemberLoc() const { return MemberNameInfo.getLoc(); } 24531c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor 24543b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor /// \brief Determines whether this member expression actually had a C++ 24553b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor /// template argument list explicitly specified, e.g., x.f<int>. 2456aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall bool hasExplicitTemplateArgs() const { 2457aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall return HasExplicitTemplateArgs; 24583b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor } 24591eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 246036c76f0bea0d3595a25a5362225c642019cc3176Argyrios Kyrtzidis /// \brief Retrieve the explicit template argument list that followed the 246136c76f0bea0d3595a25a5362225c642019cc3176Argyrios Kyrtzidis /// member template name, if any. 2462096832c5ed5b9106fa177ebc148489760c3bc496John McCall ExplicitTemplateArgumentList &getExplicitTemplateArgs() { 246336c76f0bea0d3595a25a5362225c642019cc3176Argyrios Kyrtzidis assert(HasExplicitTemplateArgs); 2464096832c5ed5b9106fa177ebc148489760c3bc496John McCall return *reinterpret_cast<ExplicitTemplateArgumentList *>(this + 1); 246536c76f0bea0d3595a25a5362225c642019cc3176Argyrios Kyrtzidis } 246636c76f0bea0d3595a25a5362225c642019cc3176Argyrios Kyrtzidis 246736c76f0bea0d3595a25a5362225c642019cc3176Argyrios Kyrtzidis /// \brief Retrieve the explicit template argument list that followed the 246836c76f0bea0d3595a25a5362225c642019cc3176Argyrios Kyrtzidis /// member template name, if any. 2469096832c5ed5b9106fa177ebc148489760c3bc496John McCall const ExplicitTemplateArgumentList &getExplicitTemplateArgs() const { 247036c76f0bea0d3595a25a5362225c642019cc3176Argyrios Kyrtzidis return const_cast<CXXDependentScopeMemberExpr *>(this) 2471096832c5ed5b9106fa177ebc148489760c3bc496John McCall ->getExplicitTemplateArgs(); 2472096832c5ed5b9106fa177ebc148489760c3bc496John McCall } 2473096832c5ed5b9106fa177ebc148489760c3bc496John McCall 2474096832c5ed5b9106fa177ebc148489760c3bc496John McCall /// \brief Retrieves the optional explicit template arguments. 2475096832c5ed5b9106fa177ebc148489760c3bc496John McCall /// This points to the same data as getExplicitTemplateArgs(), but 2476096832c5ed5b9106fa177ebc148489760c3bc496John McCall /// returns null if there are no explicit template arguments. 2477096832c5ed5b9106fa177ebc148489760c3bc496John McCall const ExplicitTemplateArgumentList *getOptionalExplicitTemplateArgs() { 2478096832c5ed5b9106fa177ebc148489760c3bc496John McCall if (!hasExplicitTemplateArgs()) return 0; 2479096832c5ed5b9106fa177ebc148489760c3bc496John McCall return &getExplicitTemplateArgs(); 248036c76f0bea0d3595a25a5362225c642019cc3176Argyrios Kyrtzidis } 248136c76f0bea0d3595a25a5362225c642019cc3176Argyrios Kyrtzidis 2482d5532b6cfff2977e0c59fa6ead7f7973984a620dJohn McCall /// \brief Copies the template arguments (if present) into the given 2483d5532b6cfff2977e0c59fa6ead7f7973984a620dJohn McCall /// structure. 2484d5532b6cfff2977e0c59fa6ead7f7973984a620dJohn McCall void copyTemplateArgumentsInto(TemplateArgumentListInfo &List) const { 2485096832c5ed5b9106fa177ebc148489760c3bc496John McCall getExplicitTemplateArgs().copyInto(List); 2486d5532b6cfff2977e0c59fa6ead7f7973984a620dJohn McCall } 2487d5532b6cfff2977e0c59fa6ead7f7973984a620dJohn McCall 24888dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis /// \brief Initializes the template arguments using the given structure. 24898dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis void initializeTemplateArgumentsFrom(const TemplateArgumentListInfo &List) { 2490096832c5ed5b9106fa177ebc148489760c3bc496John McCall getExplicitTemplateArgs().initializeFrom(List); 24918dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis } 24928dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis 24931eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump /// \brief Retrieve the location of the left angle bracket following the 24943b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor /// member name ('<'), if any. 24951eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump SourceLocation getLAngleLoc() const { 2496096832c5ed5b9106fa177ebc148489760c3bc496John McCall return getExplicitTemplateArgs().LAngleLoc; 24973b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor } 24981eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 24993b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor /// \brief Retrieve the template arguments provided as part of this 25003b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor /// template-id. 2501833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall const TemplateArgumentLoc *getTemplateArgs() const { 2502096832c5ed5b9106fa177ebc148489760c3bc496John McCall return getExplicitTemplateArgs().getTemplateArgs(); 25033b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor } 25041eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 25053b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor /// \brief Retrieve the number of template arguments provided as part of this 25063b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor /// template-id. 25071eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump unsigned getNumTemplateArgs() const { 2508096832c5ed5b9106fa177ebc148489760c3bc496John McCall return getExplicitTemplateArgs().NumTemplateArgs; 25093b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor } 25101eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 25111eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump /// \brief Retrieve the location of the right angle bracket following the 25123b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor /// template arguments ('>'). 25131eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump SourceLocation getRAngleLoc() const { 2514096832c5ed5b9106fa177ebc148489760c3bc496John McCall return getExplicitTemplateArgs().RAngleLoc; 25153b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor } 25161eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 251763c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall SourceRange getSourceRange() const { 2518aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall SourceRange Range; 2519aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall if (!isImplicitAccess()) 2520aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall Range.setBegin(Base->getSourceRange().getBegin()); 2521aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall else if (getQualifier()) 25227c3179cf463c3b3b8c21dbb955f933ba50b74f28Douglas Gregor Range.setBegin(getQualifierLoc().getBeginLoc()); 2523aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall else 25242577743c5650c646fb705df01403707e94f2df04Abramo Bagnara Range.setBegin(MemberNameInfo.getBeginLoc()); 25251eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 2526aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall if (hasExplicitTemplateArgs()) 2527aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall Range.setEnd(getRAngleLoc()); 2528aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall else 25292577743c5650c646fb705df01403707e94f2df04Abramo Bagnara Range.setEnd(MemberNameInfo.getEndLoc()); 2530aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall return Range; 25311c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor } 25321eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 25331eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump static bool classof(const Stmt *T) { 2534865d447ac6a4721ab58e898d014a21f2eff74b06John McCall return T->getStmtClass() == CXXDependentScopeMemberExprClass; 25351c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor } 2536865d447ac6a4721ab58e898d014a21f2eff74b06John McCall static bool classof(const CXXDependentScopeMemberExpr *) { return true; } 25371c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor 25381c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor // Iterators 253963c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall child_range children() { 254063c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall if (isImplicitAccess()) return child_range(); 254163c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall return child_range(&Base, &Base + 1); 254263c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall } 25434045107b7384fd68eed5e3e2f06fc2a47e7be0a6Argyrios Kyrtzidis 25444045107b7384fd68eed5e3e2f06fc2a47e7be0a6Argyrios Kyrtzidis friend class ASTStmtReader; 25454045107b7384fd68eed5e3e2f06fc2a47e7be0a6Argyrios Kyrtzidis friend class ASTStmtWriter; 25461c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor}; 25471c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor 2548129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall/// \brief Represents a C++ member access expression for which lookup 2549aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall/// produced a set of overloaded functions. 2550aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall/// 2551aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall/// The member access may be explicit or implicit: 2552aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall/// struct A { 2553aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall/// int a, b; 2554aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall/// int explicitAccess() { return this->a + this->A::b; } 2555aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall/// int implicitAccess() { return a + A::b; } 2556aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall/// }; 2557aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall/// 2558aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall/// In the final AST, an explicit access always becomes a MemberExpr. 2559aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall/// An implicit access may become either a MemberExpr or a 2560aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall/// DeclRefExpr, depending on whether the member is static. 25617bb12da2b0749eeebb21854c77877736969e59f2John McCallclass UnresolvedMemberExpr : public OverloadExpr { 2562129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall /// \brief Whether this member expression used the '->' operator or 2563129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall /// the '.' operator. 2564129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall bool IsArrow : 1; 2565129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall 2566129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall /// \brief Whether the lookup results contain an unresolved using 2567129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall /// declaration. 2568129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall bool HasUnresolvedUsing : 1; 2569129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall 25707bb12da2b0749eeebb21854c77877736969e59f2John McCall /// \brief The expression for the base pointer or class reference, 25717bb12da2b0749eeebb21854c77877736969e59f2John McCall /// e.g., the \c x in x.f. This can be null if this is an 'unbased' 25727bb12da2b0749eeebb21854c77877736969e59f2John McCall /// member expression 25737bb12da2b0749eeebb21854c77877736969e59f2John McCall Stmt *Base; 25747bb12da2b0749eeebb21854c77877736969e59f2John McCall 25757bb12da2b0749eeebb21854c77877736969e59f2John McCall /// \brief The type of the base expression; never null. 25767bb12da2b0749eeebb21854c77877736969e59f2John McCall QualType BaseType; 2577129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall 2578129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall /// \brief The location of the '->' or '.' operator. 2579129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall SourceLocation OperatorLoc; 2580129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall 2581bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor UnresolvedMemberExpr(ASTContext &C, bool HasUnresolvedUsing, 2582aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall Expr *Base, QualType BaseType, bool IsArrow, 2583129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall SourceLocation OperatorLoc, 25844c9be89bb615ec07eb3ed507c8fa9d0baa8a5ad7Douglas Gregor NestedNameSpecifierLoc QualifierLoc, 25852577743c5650c646fb705df01403707e94f2df04Abramo Bagnara const DeclarationNameInfo &MemberNameInfo, 25865a84dec38cfa9e084377a3167b474c79283c82faDouglas Gregor const TemplateArgumentListInfo *TemplateArgs, 25875a84dec38cfa9e084377a3167b474c79283c82faDouglas Gregor UnresolvedSetIterator Begin, UnresolvedSetIterator End); 2588a77eb0862507b900a10fa352af1568e639ed10b1Argyrios Kyrtzidis 2589a77eb0862507b900a10fa352af1568e639ed10b1Argyrios Kyrtzidis UnresolvedMemberExpr(EmptyShell Empty) 2590a77eb0862507b900a10fa352af1568e639ed10b1Argyrios Kyrtzidis : OverloadExpr(UnresolvedMemberExprClass, Empty), IsArrow(false), 2591a77eb0862507b900a10fa352af1568e639ed10b1Argyrios Kyrtzidis HasUnresolvedUsing(false), Base(0) { } 2592129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall 25934c9be89bb615ec07eb3ed507c8fa9d0baa8a5ad7Douglas Gregor friend class ASTStmtReader; 25944c9be89bb615ec07eb3ed507c8fa9d0baa8a5ad7Douglas Gregor 2595129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCallpublic: 2596129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall static UnresolvedMemberExpr * 2597bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor Create(ASTContext &C, bool HasUnresolvedUsing, 2598aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall Expr *Base, QualType BaseType, bool IsArrow, 2599129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall SourceLocation OperatorLoc, 26004c9be89bb615ec07eb3ed507c8fa9d0baa8a5ad7Douglas Gregor NestedNameSpecifierLoc QualifierLoc, 26012577743c5650c646fb705df01403707e94f2df04Abramo Bagnara const DeclarationNameInfo &MemberNameInfo, 26025a84dec38cfa9e084377a3167b474c79283c82faDouglas Gregor const TemplateArgumentListInfo *TemplateArgs, 26035a84dec38cfa9e084377a3167b474c79283c82faDouglas Gregor UnresolvedSetIterator Begin, UnresolvedSetIterator End); 2604129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall 2605a77eb0862507b900a10fa352af1568e639ed10b1Argyrios Kyrtzidis static UnresolvedMemberExpr * 2606def0354384d9c4431f7b58b664b59896d4623028Douglas Gregor CreateEmpty(ASTContext &C, bool HasExplicitTemplateArgs, 2607def0354384d9c4431f7b58b664b59896d4623028Douglas Gregor unsigned NumTemplateArgs); 2608a77eb0862507b900a10fa352af1568e639ed10b1Argyrios Kyrtzidis 2609aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall /// \brief True if this is an implicit access, i.e. one in which the 2610aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall /// member being accessed was not written in the source. The source 2611aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall /// location of the operator is invalid in this case. 26124c9be89bb615ec07eb3ed507c8fa9d0baa8a5ad7Douglas Gregor bool isImplicitAccess() const; 2613aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall 2614129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall /// \brief Retrieve the base object of this member expressions, 2615129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall /// e.g., the \c x in \c x.m. 2616aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall Expr *getBase() { 2617aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall assert(!isImplicitAccess()); 2618aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall return cast<Expr>(Base); 2619aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall } 26202f27bf854f0519810b34afd209089cc75536b757John McCall const Expr *getBase() const { 26212f27bf854f0519810b34afd209089cc75536b757John McCall assert(!isImplicitAccess()); 26222f27bf854f0519810b34afd209089cc75536b757John McCall return cast<Expr>(Base); 26232f27bf854f0519810b34afd209089cc75536b757John McCall } 2624129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall 2625aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall QualType getBaseType() const { return BaseType; } 2626a77eb0862507b900a10fa352af1568e639ed10b1Argyrios Kyrtzidis 2627a77eb0862507b900a10fa352af1568e639ed10b1Argyrios Kyrtzidis /// \brief Determine whether the lookup results contain an unresolved using 2628a77eb0862507b900a10fa352af1568e639ed10b1Argyrios Kyrtzidis /// declaration. 2629a77eb0862507b900a10fa352af1568e639ed10b1Argyrios Kyrtzidis bool hasUnresolvedUsing() const { return HasUnresolvedUsing; } 2630aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall 2631129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall /// \brief Determine whether this member expression used the '->' 2632129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall /// operator; otherwise, it used the '.' operator. 2633129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall bool isArrow() const { return IsArrow; } 2634129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall 2635129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall /// \brief Retrieve the location of the '->' or '.' operator. 2636129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall SourceLocation getOperatorLoc() const { return OperatorLoc; } 2637129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall 2638c373d48502ca7683ab55385f5bd624d778eb288dJohn McCall /// \brief Retrieves the naming class of this lookup. 2639c373d48502ca7683ab55385f5bd624d778eb288dJohn McCall CXXRecordDecl *getNamingClass() const; 2640c373d48502ca7683ab55385f5bd624d778eb288dJohn McCall 26412577743c5650c646fb705df01403707e94f2df04Abramo Bagnara /// \brief Retrieve the full name info for the member that this expression 26422577743c5650c646fb705df01403707e94f2df04Abramo Bagnara /// refers to. 26432577743c5650c646fb705df01403707e94f2df04Abramo Bagnara const DeclarationNameInfo &getMemberNameInfo() const { return getNameInfo(); } 26442577743c5650c646fb705df01403707e94f2df04Abramo Bagnara 2645129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall /// \brief Retrieve the name of the member that this expression 2646129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall /// refers to. 26477bb12da2b0749eeebb21854c77877736969e59f2John McCall DeclarationName getMemberName() const { return getName(); } 2648129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall 2649129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall // \brief Retrieve the location of the name of the member that this 2650129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall // expression refers to. 26517bb12da2b0749eeebb21854c77877736969e59f2John McCall SourceLocation getMemberLoc() const { return getNameLoc(); } 2652129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall 26537bb12da2b0749eeebb21854c77877736969e59f2John McCall /// \brief Retrieve the explicit template argument list that followed the 26547bb12da2b0749eeebb21854c77877736969e59f2John McCall /// member template name. 26557bb12da2b0749eeebb21854c77877736969e59f2John McCall ExplicitTemplateArgumentList &getExplicitTemplateArgs() { 26567bb12da2b0749eeebb21854c77877736969e59f2John McCall assert(hasExplicitTemplateArgs()); 26577bb12da2b0749eeebb21854c77877736969e59f2John McCall return *reinterpret_cast<ExplicitTemplateArgumentList *>(this + 1); 26587bb12da2b0749eeebb21854c77877736969e59f2John McCall } 26597bb12da2b0749eeebb21854c77877736969e59f2John McCall 26607bb12da2b0749eeebb21854c77877736969e59f2John McCall /// \brief Retrieve the explicit template argument list that followed the 26617bb12da2b0749eeebb21854c77877736969e59f2John McCall /// member template name, if any. 26627bb12da2b0749eeebb21854c77877736969e59f2John McCall const ExplicitTemplateArgumentList &getExplicitTemplateArgs() const { 26637bb12da2b0749eeebb21854c77877736969e59f2John McCall assert(hasExplicitTemplateArgs()); 26647bb12da2b0749eeebb21854c77877736969e59f2John McCall return *reinterpret_cast<const ExplicitTemplateArgumentList *>(this + 1); 2665129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall } 2666129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall 2667096832c5ed5b9106fa177ebc148489760c3bc496John McCall /// \brief Retrieves the optional explicit template arguments. 2668096832c5ed5b9106fa177ebc148489760c3bc496John McCall /// This points to the same data as getExplicitTemplateArgs(), but 2669096832c5ed5b9106fa177ebc148489760c3bc496John McCall /// returns null if there are no explicit template arguments. 2670096832c5ed5b9106fa177ebc148489760c3bc496John McCall const ExplicitTemplateArgumentList *getOptionalExplicitTemplateArgs() { 2671096832c5ed5b9106fa177ebc148489760c3bc496John McCall if (!hasExplicitTemplateArgs()) return 0; 2672096832c5ed5b9106fa177ebc148489760c3bc496John McCall return &getExplicitTemplateArgs(); 2673096832c5ed5b9106fa177ebc148489760c3bc496John McCall } 2674096832c5ed5b9106fa177ebc148489760c3bc496John McCall 2675129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall /// \brief Copies the template arguments into the given structure. 2676129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall void copyTemplateArgumentsInto(TemplateArgumentListInfo &List) const { 26777bb12da2b0749eeebb21854c77877736969e59f2John McCall getExplicitTemplateArgs().copyInto(List); 2678129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall } 2679129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall 2680129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall /// \brief Retrieve the location of the left angle bracket following 2681129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall /// the member name ('<'). 2682129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall SourceLocation getLAngleLoc() const { 26837bb12da2b0749eeebb21854c77877736969e59f2John McCall return getExplicitTemplateArgs().LAngleLoc; 2684129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall } 2685129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall 2686129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall /// \brief Retrieve the template arguments provided as part of this 2687129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall /// template-id. 2688129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall const TemplateArgumentLoc *getTemplateArgs() const { 26897bb12da2b0749eeebb21854c77877736969e59f2John McCall return getExplicitTemplateArgs().getTemplateArgs(); 2690129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall } 2691129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall 2692129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall /// \brief Retrieve the number of template arguments provided as 2693129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall /// part of this template-id. 2694129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall unsigned getNumTemplateArgs() const { 26957bb12da2b0749eeebb21854c77877736969e59f2John McCall return getExplicitTemplateArgs().NumTemplateArgs; 2696129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall } 2697129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall 2698129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall /// \brief Retrieve the location of the right angle bracket 2699129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall /// following the template arguments ('>'). 2700129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall SourceLocation getRAngleLoc() const { 27017bb12da2b0749eeebb21854c77877736969e59f2John McCall return getExplicitTemplateArgs().RAngleLoc; 2702129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall } 2703129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall 270463c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall SourceRange getSourceRange() const { 27052577743c5650c646fb705df01403707e94f2df04Abramo Bagnara SourceRange Range = getMemberNameInfo().getSourceRange(); 2706aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall if (!isImplicitAccess()) 2707aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall Range.setBegin(Base->getSourceRange().getBegin()); 27084c9be89bb615ec07eb3ed507c8fa9d0baa8a5ad7Douglas Gregor else if (getQualifierLoc()) 27094c9be89bb615ec07eb3ed507c8fa9d0baa8a5ad7Douglas Gregor Range.setBegin(getQualifierLoc().getBeginLoc()); 2710aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall 2711129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall if (hasExplicitTemplateArgs()) 2712129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall Range.setEnd(getRAngleLoc()); 2713129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall return Range; 2714129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall } 2715129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall 2716129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall static bool classof(const Stmt *T) { 2717129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall return T->getStmtClass() == UnresolvedMemberExprClass; 2718129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall } 2719129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall static bool classof(const UnresolvedMemberExpr *) { return true; } 2720129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall 2721129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall // Iterators 272263c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall child_range children() { 272363c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall if (isImplicitAccess()) return child_range(); 272463c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall return child_range(&Base, &Base + 1); 272563c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall } 2726129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall}; 2727129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall 27282e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl/// \brief Represents a C++0x noexcept expression (C++ [expr.unary.noexcept]). 27292e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl/// 27302e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl/// The noexcept expression tests whether a given expression might throw. Its 27312e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl/// result is a boolean constant. 27322e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redlclass CXXNoexceptExpr : public Expr { 27332e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl bool Value : 1; 27342e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl Stmt *Operand; 27352e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl SourceRange Range; 27362e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl 2737c8aecc2dfb2e393d9eeaedeca22ff8cd7149af81Sebastian Redl friend class ASTStmtReader; 2738c8aecc2dfb2e393d9eeaedeca22ff8cd7149af81Sebastian Redl 27392e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redlpublic: 27402e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl CXXNoexceptExpr(QualType Ty, Expr *Operand, CanThrowResult Val, 27412e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl SourceLocation Keyword, SourceLocation RParen) 2742f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall : Expr(CXXNoexceptExprClass, Ty, VK_RValue, OK_Ordinary, 2743f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall /*TypeDependent*/false, 2744bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor /*ValueDependent*/Val == CT_Dependent, 2745561f81243f665cf2001caadc45df505f826b72d6Douglas Gregor Val == CT_Dependent || Operand->isInstantiationDependent(), 2746bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor Operand->containsUnexpandedParameterPack()), 27476b219d082434394c1ac401390ec1d1967727815aSebastian Redl Value(Val == CT_Cannot), Operand(Operand), Range(Keyword, RParen) 27486b219d082434394c1ac401390ec1d1967727815aSebastian Redl { } 27496b219d082434394c1ac401390ec1d1967727815aSebastian Redl 27506b219d082434394c1ac401390ec1d1967727815aSebastian Redl CXXNoexceptExpr(EmptyShell Empty) 27516b219d082434394c1ac401390ec1d1967727815aSebastian Redl : Expr(CXXNoexceptExprClass, Empty) 27522e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl { } 27532e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl 27542e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl Expr *getOperand() const { return static_cast<Expr*>(Operand); } 27552e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl 275663c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall SourceRange getSourceRange() const { return Range; } 27572e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl 27582e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl bool getValue() const { return Value; } 27592e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl 27602e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl static bool classof(const Stmt *T) { 27612e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl return T->getStmtClass() == CXXNoexceptExprClass; 27622e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl } 27632e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl static bool classof(const CXXNoexceptExpr *) { return true; } 27642e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl 27652e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl // Iterators 276663c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall child_range children() { return child_range(&Operand, &Operand + 1); } 27672e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl}; 27682e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl 2769be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor/// \brief Represents a C++0x pack expansion that produces a sequence of 2770be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor/// expressions. 2771be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor/// 2772be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor/// A pack expansion expression contains a pattern (which itself is an 2773be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor/// expression) followed by an ellipsis. For example: 2774be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor/// 2775be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor/// \code 2776be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor/// template<typename F, typename ...Types> 2777be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor/// void forward(F f, Types &&...args) { 2778be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor/// f(static_cast<Types&&>(args)...); 2779be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor/// } 2780be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor/// \endcode 2781be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor/// 2782be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor/// Here, the argument to the function object \c f is a pack expansion whose 2783be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor/// pattern is \c static_cast<Types&&>(args). When the \c forward function 2784be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor/// template is instantiated, the pack expansion will instantiate to zero or 2785be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor/// or more function arguments to the function object \c f. 2786be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregorclass PackExpansionExpr : public Expr { 2787be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor SourceLocation EllipsisLoc; 278867fd1251aad51bb80d050b7fa5e506fef0ec8e02Douglas Gregor 278967fd1251aad51bb80d050b7fa5e506fef0ec8e02Douglas Gregor /// \brief The number of expansions that will be produced by this pack 279067fd1251aad51bb80d050b7fa5e506fef0ec8e02Douglas Gregor /// expansion expression, if known. 279167fd1251aad51bb80d050b7fa5e506fef0ec8e02Douglas Gregor /// 279267fd1251aad51bb80d050b7fa5e506fef0ec8e02Douglas Gregor /// When zero, the number of expansions is not known. Otherwise, this value 279367fd1251aad51bb80d050b7fa5e506fef0ec8e02Douglas Gregor /// is the number of expansions + 1. 279467fd1251aad51bb80d050b7fa5e506fef0ec8e02Douglas Gregor unsigned NumExpansions; 279567fd1251aad51bb80d050b7fa5e506fef0ec8e02Douglas Gregor 2796be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor Stmt *Pattern; 2797be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor 2798be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor friend class ASTStmtReader; 279967fd1251aad51bb80d050b7fa5e506fef0ec8e02Douglas Gregor friend class ASTStmtWriter; 2800be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor 2801be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregorpublic: 280267fd1251aad51bb80d050b7fa5e506fef0ec8e02Douglas Gregor PackExpansionExpr(QualType T, Expr *Pattern, SourceLocation EllipsisLoc, 280367fd1251aad51bb80d050b7fa5e506fef0ec8e02Douglas Gregor llvm::Optional<unsigned> NumExpansions) 2804be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor : Expr(PackExpansionExprClass, T, Pattern->getValueKind(), 2805be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor Pattern->getObjectKind(), /*TypeDependent=*/true, 2806561f81243f665cf2001caadc45df505f826b72d6Douglas Gregor /*ValueDependent=*/true, /*InstantiationDependent=*/true, 2807561f81243f665cf2001caadc45df505f826b72d6Douglas Gregor /*ContainsUnexpandedParameterPack=*/false), 2808be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor EllipsisLoc(EllipsisLoc), 280967fd1251aad51bb80d050b7fa5e506fef0ec8e02Douglas Gregor NumExpansions(NumExpansions? *NumExpansions + 1 : 0), 2810be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor Pattern(Pattern) { } 2811be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor 2812be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor PackExpansionExpr(EmptyShell Empty) : Expr(PackExpansionExprClass, Empty) { } 2813be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor 2814be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor /// \brief Retrieve the pattern of the pack expansion. 2815be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor Expr *getPattern() { return reinterpret_cast<Expr *>(Pattern); } 2816be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor 2817be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor /// \brief Retrieve the pattern of the pack expansion. 2818be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor const Expr *getPattern() const { return reinterpret_cast<Expr *>(Pattern); } 2819be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor 2820be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor /// \brief Retrieve the location of the ellipsis that describes this pack 2821be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor /// expansion. 2822be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor SourceLocation getEllipsisLoc() const { return EllipsisLoc; } 2823be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor 282467fd1251aad51bb80d050b7fa5e506fef0ec8e02Douglas Gregor /// \brief Determine the number of expansions that will be produced when 282567fd1251aad51bb80d050b7fa5e506fef0ec8e02Douglas Gregor /// this pack expansion is instantiated, if already known. 282667fd1251aad51bb80d050b7fa5e506fef0ec8e02Douglas Gregor llvm::Optional<unsigned> getNumExpansions() const { 282767fd1251aad51bb80d050b7fa5e506fef0ec8e02Douglas Gregor if (NumExpansions) 282867fd1251aad51bb80d050b7fa5e506fef0ec8e02Douglas Gregor return NumExpansions - 1; 282967fd1251aad51bb80d050b7fa5e506fef0ec8e02Douglas Gregor 283067fd1251aad51bb80d050b7fa5e506fef0ec8e02Douglas Gregor return llvm::Optional<unsigned>(); 283167fd1251aad51bb80d050b7fa5e506fef0ec8e02Douglas Gregor } 283267fd1251aad51bb80d050b7fa5e506fef0ec8e02Douglas Gregor 283363c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall SourceRange getSourceRange() const { 283463c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall return SourceRange(Pattern->getLocStart(), EllipsisLoc); 283563c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall } 2836be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor 2837be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor static bool classof(const Stmt *T) { 2838be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor return T->getStmtClass() == PackExpansionExprClass; 2839be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor } 2840be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor static bool classof(const PackExpansionExpr *) { return true; } 2841be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor 2842be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor // Iterators 284363c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall child_range children() { 284463c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall return child_range(&Pattern, &Pattern + 1); 284563c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall } 2846be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor}; 2847be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor 28487bb12da2b0749eeebb21854c77877736969e59f2John McCallinline ExplicitTemplateArgumentList &OverloadExpr::getExplicitTemplateArgs() { 28497bb12da2b0749eeebb21854c77877736969e59f2John McCall if (isa<UnresolvedLookupExpr>(this)) 28507bb12da2b0749eeebb21854c77877736969e59f2John McCall return cast<UnresolvedLookupExpr>(this)->getExplicitTemplateArgs(); 28517bb12da2b0749eeebb21854c77877736969e59f2John McCall else 28527bb12da2b0749eeebb21854c77877736969e59f2John McCall return cast<UnresolvedMemberExpr>(this)->getExplicitTemplateArgs(); 28537bb12da2b0749eeebb21854c77877736969e59f2John McCall} 28547bb12da2b0749eeebb21854c77877736969e59f2John McCall 2855ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor/// \brief Represents an expression that computes the length of a parameter 2856ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor/// pack. 2857ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor/// 2858ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor/// \code 2859ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor/// template<typename ...Types> 2860ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor/// struct count { 2861ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor/// static const unsigned value = sizeof...(Types); 2862ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor/// }; 2863ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor/// \endcode 2864ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregorclass SizeOfPackExpr : public Expr { 2865ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor /// \brief The location of the 'sizeof' keyword. 2866ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor SourceLocation OperatorLoc; 2867ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor 2868ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor /// \brief The location of the name of the parameter pack. 2869ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor SourceLocation PackLoc; 2870ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor 2871ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor /// \brief The location of the closing parenthesis. 2872ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor SourceLocation RParenLoc; 2873ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor 2874ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor /// \brief The length of the parameter pack, if known. 2875ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor /// 2876ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor /// When this expression is value-dependent, the length of the parameter pack 2877ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor /// is unknown. When this expression is not value-dependent, the length is 2878ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor /// known. 2879ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor unsigned Length; 2880ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor 2881ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor /// \brief The parameter pack itself. 2882ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor NamedDecl *Pack; 2883ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor 2884ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor friend class ASTStmtReader; 2885ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor friend class ASTStmtWriter; 2886ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor 2887ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregorpublic: 2888ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor /// \brief Creates a value-dependent expression that computes the length of 2889ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor /// the given parameter pack. 2890ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor SizeOfPackExpr(QualType SizeType, SourceLocation OperatorLoc, NamedDecl *Pack, 2891ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor SourceLocation PackLoc, SourceLocation RParenLoc) 2892ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor : Expr(SizeOfPackExprClass, SizeType, VK_RValue, OK_Ordinary, 2893ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor /*TypeDependent=*/false, /*ValueDependent=*/true, 2894561f81243f665cf2001caadc45df505f826b72d6Douglas Gregor /*InstantiationDependent=*/true, 2895ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor /*ContainsUnexpandedParameterPack=*/false), 2896ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor OperatorLoc(OperatorLoc), PackLoc(PackLoc), RParenLoc(RParenLoc), 2897ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor Length(0), Pack(Pack) { } 2898ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor 2899ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor /// \brief Creates an expression that computes the length of 2900ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor /// the given parameter pack, which is already known. 2901ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor SizeOfPackExpr(QualType SizeType, SourceLocation OperatorLoc, NamedDecl *Pack, 2902ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor SourceLocation PackLoc, SourceLocation RParenLoc, 2903ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor unsigned Length) 2904ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor : Expr(SizeOfPackExprClass, SizeType, VK_RValue, OK_Ordinary, 2905ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor /*TypeDependent=*/false, /*ValueDependent=*/false, 2906561f81243f665cf2001caadc45df505f826b72d6Douglas Gregor /*InstantiationDependent=*/false, 2907ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor /*ContainsUnexpandedParameterPack=*/false), 2908ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor OperatorLoc(OperatorLoc), PackLoc(PackLoc), RParenLoc(RParenLoc), 2909ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor Length(Length), Pack(Pack) { } 2910ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor 2911ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor /// \brief Create an empty expression. 2912ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor SizeOfPackExpr(EmptyShell Empty) : Expr(SizeOfPackExprClass, Empty) { } 2913ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor 2914ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor /// \brief Determine the location of the 'sizeof' keyword. 2915ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor SourceLocation getOperatorLoc() const { return OperatorLoc; } 2916ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor 2917ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor /// \brief Determine the location of the parameter pack. 2918ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor SourceLocation getPackLoc() const { return PackLoc; } 2919ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor 2920ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor /// \brief Determine the location of the right parenthesis. 2921ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor SourceLocation getRParenLoc() const { return RParenLoc; } 2922ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor 2923ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor /// \brief Retrieve the parameter pack. 2924ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor NamedDecl *getPack() const { return Pack; } 2925ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor 2926ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor /// \brief Retrieve the length of the parameter pack. 2927ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor /// 2928c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor /// This routine may only be invoked when the expression is not 2929c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor /// value-dependent. 2930ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor unsigned getPackLength() const { 2931ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor assert(!isValueDependent() && 2932ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor "Cannot get the length of a value-dependent pack size expression"); 2933ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor return Length; 2934ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor } 2935ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor 293663c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall SourceRange getSourceRange() const { 293763c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall return SourceRange(OperatorLoc, RParenLoc); 293863c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall } 2939ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor 2940ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor static bool classof(const Stmt *T) { 2941ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor return T->getStmtClass() == SizeOfPackExprClass; 2942ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor } 2943ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor static bool classof(const SizeOfPackExpr *) { return true; } 2944ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor 2945ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor // Iterators 294663c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall child_range children() { return child_range(); } 2947ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor}; 2948c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor 2949c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor/// \brief Represents a reference to a non-type template parameter pack that 2950c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor/// has been substituted with a non-template argument pack. 2951c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor/// 2952c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor/// When a pack expansion in the source code contains multiple parameter packs 2953c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor/// and those parameter packs correspond to different levels of template 2954c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor/// parameter lists, this node node is used to represent a non-type template 2955c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor/// parameter pack from an outer level, which has already had its argument pack 2956c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor/// substituted but that still lives within a pack expansion that itself 2957c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor/// could not be instantiated. When actually performing a substitution into 2958c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor/// that pack expansion (e.g., when all template parameters have corresponding 2959c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor/// arguments), this type will be replaced with the appropriate underlying 2960c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor/// expression at the current pack substitution index. 2961c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregorclass SubstNonTypeTemplateParmPackExpr : public Expr { 2962c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor /// \brief The non-type template parameter pack itself. 2963c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor NonTypeTemplateParmDecl *Param; 2964c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor 2965c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor /// \brief A pointer to the set of template arguments that this 2966c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor /// parameter pack is instantiated with. 2967c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor const TemplateArgument *Arguments; 2968c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor 2969c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor /// \brief The number of template arguments in \c Arguments. 2970c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor unsigned NumArguments; 2971c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor 2972c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor /// \brief The location of the non-type template parameter pack reference. 2973c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor SourceLocation NameLoc; 2974c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor 2975c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor friend class ASTStmtReader; 2976c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor friend class ASTStmtWriter; 2977c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor 2978c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregorpublic: 2979c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor SubstNonTypeTemplateParmPackExpr(QualType T, 2980c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor NonTypeTemplateParmDecl *Param, 2981c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor SourceLocation NameLoc, 2982c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor const TemplateArgument &ArgPack); 2983c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor 2984c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor SubstNonTypeTemplateParmPackExpr(EmptyShell Empty) 2985c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor : Expr(SubstNonTypeTemplateParmPackExprClass, Empty) { } 2986c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor 2987c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor /// \brief Retrieve the non-type template parameter pack being substituted. 2988c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor NonTypeTemplateParmDecl *getParameterPack() const { return Param; } 2989c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor 2990c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor /// \brief Retrieve the location of the parameter pack name. 2991c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor SourceLocation getParameterPackLocation() const { return NameLoc; } 2992c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor 2993c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor /// \brief Retrieve the template argument pack containing the substituted 2994c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor /// template arguments. 2995c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor TemplateArgument getArgumentPack() const; 2996c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor 299763c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall SourceRange getSourceRange() const { return NameLoc; } 2998c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor 2999c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor static bool classof(const Stmt *T) { 3000c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor return T->getStmtClass() == SubstNonTypeTemplateParmPackExprClass; 3001c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor } 3002c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor static bool classof(const SubstNonTypeTemplateParmPackExpr *) { 3003c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor return true; 3004c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor } 3005c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor 3006c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor // Iterators 300763c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall child_range children() { return child_range(); } 3008c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor}; 300903e80030515c800d1ab44125b9052dfffd1bd04cDouglas Gregor 301003e80030515c800d1ab44125b9052dfffd1bd04cDouglas Gregor/// \brief Represents a prvalue temporary that written into memory so that 301103e80030515c800d1ab44125b9052dfffd1bd04cDouglas Gregor/// a reference can bind to it. 301203e80030515c800d1ab44125b9052dfffd1bd04cDouglas Gregor/// 301303e80030515c800d1ab44125b9052dfffd1bd04cDouglas Gregor/// Prvalue expressions are materialized when they need to have an address 301403e80030515c800d1ab44125b9052dfffd1bd04cDouglas Gregor/// in memory for a reference to bind to. This happens when binding a 301503e80030515c800d1ab44125b9052dfffd1bd04cDouglas Gregor/// reference to the result of a conversion, e.g., 301603e80030515c800d1ab44125b9052dfffd1bd04cDouglas Gregor/// 301703e80030515c800d1ab44125b9052dfffd1bd04cDouglas Gregor/// \code 301803e80030515c800d1ab44125b9052dfffd1bd04cDouglas Gregor/// const int &r = 1.0; 301903e80030515c800d1ab44125b9052dfffd1bd04cDouglas Gregor/// \endcode 302003e80030515c800d1ab44125b9052dfffd1bd04cDouglas Gregor/// 302103e80030515c800d1ab44125b9052dfffd1bd04cDouglas Gregor/// Here, 1.0 is implicitly converted to an \c int. That resulting \c int is 302203e80030515c800d1ab44125b9052dfffd1bd04cDouglas Gregor/// then materialized via a \c MaterializeTemporaryExpr, and the reference 302303e80030515c800d1ab44125b9052dfffd1bd04cDouglas Gregor/// binds to the temporary. \c MaterializeTemporaryExprs are always glvalues 302403e80030515c800d1ab44125b9052dfffd1bd04cDouglas Gregor/// (either an lvalue or an xvalue, depending on the kind of reference binding 302503e80030515c800d1ab44125b9052dfffd1bd04cDouglas Gregor/// to it), maintaining the invariant that references always bind to glvalues. 302603e80030515c800d1ab44125b9052dfffd1bd04cDouglas Gregorclass MaterializeTemporaryExpr : public Expr { 302703e80030515c800d1ab44125b9052dfffd1bd04cDouglas Gregor /// \brief The temporary-generating expression whose value will be 302803e80030515c800d1ab44125b9052dfffd1bd04cDouglas Gregor /// materialized. 302903e80030515c800d1ab44125b9052dfffd1bd04cDouglas Gregor Stmt *Temporary; 303003e80030515c800d1ab44125b9052dfffd1bd04cDouglas Gregor 303103e80030515c800d1ab44125b9052dfffd1bd04cDouglas Gregor friend class ASTStmtReader; 303203e80030515c800d1ab44125b9052dfffd1bd04cDouglas Gregor friend class ASTStmtWriter; 303303e80030515c800d1ab44125b9052dfffd1bd04cDouglas Gregor 303403e80030515c800d1ab44125b9052dfffd1bd04cDouglas Gregorpublic: 3035b4b7b5034bb8304ed03416635bf64c75c39889fcDouglas Gregor MaterializeTemporaryExpr(QualType T, Expr *Temporary, 3036b4b7b5034bb8304ed03416635bf64c75c39889fcDouglas Gregor bool BoundToLvalueReference) 3037b4b7b5034bb8304ed03416635bf64c75c39889fcDouglas Gregor : Expr(MaterializeTemporaryExprClass, T, 303803e80030515c800d1ab44125b9052dfffd1bd04cDouglas Gregor BoundToLvalueReference? VK_LValue : VK_XValue, OK_Ordinary, 303903e80030515c800d1ab44125b9052dfffd1bd04cDouglas Gregor Temporary->isTypeDependent(), Temporary->isValueDependent(), 3040561f81243f665cf2001caadc45df505f826b72d6Douglas Gregor Temporary->isInstantiationDependent(), 304103e80030515c800d1ab44125b9052dfffd1bd04cDouglas Gregor Temporary->containsUnexpandedParameterPack()), 304203e80030515c800d1ab44125b9052dfffd1bd04cDouglas Gregor Temporary(Temporary) { } 304303e80030515c800d1ab44125b9052dfffd1bd04cDouglas Gregor 304403e80030515c800d1ab44125b9052dfffd1bd04cDouglas Gregor MaterializeTemporaryExpr(EmptyShell Empty) 304503e80030515c800d1ab44125b9052dfffd1bd04cDouglas Gregor : Expr(MaterializeTemporaryExprClass, Empty) { } 304603e80030515c800d1ab44125b9052dfffd1bd04cDouglas Gregor 304703e80030515c800d1ab44125b9052dfffd1bd04cDouglas Gregor /// \brief Retrieve the temporary-generating subexpression whose value will 304803e80030515c800d1ab44125b9052dfffd1bd04cDouglas Gregor /// be materialized into a glvalue. 304903e80030515c800d1ab44125b9052dfffd1bd04cDouglas Gregor Expr *GetTemporaryExpr() const { return reinterpret_cast<Expr *>(Temporary); } 305003e80030515c800d1ab44125b9052dfffd1bd04cDouglas Gregor 305103e80030515c800d1ab44125b9052dfffd1bd04cDouglas Gregor /// \brief Determine whether this materialized temporary is bound to an 305203e80030515c800d1ab44125b9052dfffd1bd04cDouglas Gregor /// lvalue reference; otherwise, it's bound to an rvalue reference. 30530b5810882bd34183c2b764676cafa4c2ce324740Douglas Gregor bool isBoundToLvalueReference() const { 305403e80030515c800d1ab44125b9052dfffd1bd04cDouglas Gregor return getValueKind() == VK_LValue; 305503e80030515c800d1ab44125b9052dfffd1bd04cDouglas Gregor } 305603e80030515c800d1ab44125b9052dfffd1bd04cDouglas Gregor 305703e80030515c800d1ab44125b9052dfffd1bd04cDouglas Gregor SourceRange getSourceRange() const { return Temporary->getSourceRange(); } 305803e80030515c800d1ab44125b9052dfffd1bd04cDouglas Gregor 305903e80030515c800d1ab44125b9052dfffd1bd04cDouglas Gregor static bool classof(const Stmt *T) { 306003e80030515c800d1ab44125b9052dfffd1bd04cDouglas Gregor return T->getStmtClass() == MaterializeTemporaryExprClass; 306103e80030515c800d1ab44125b9052dfffd1bd04cDouglas Gregor } 306203e80030515c800d1ab44125b9052dfffd1bd04cDouglas Gregor static bool classof(const MaterializeTemporaryExpr *) { 306303e80030515c800d1ab44125b9052dfffd1bd04cDouglas Gregor return true; 306403e80030515c800d1ab44125b9052dfffd1bd04cDouglas Gregor } 306503e80030515c800d1ab44125b9052dfffd1bd04cDouglas Gregor 306603e80030515c800d1ab44125b9052dfffd1bd04cDouglas Gregor // Iterators 306703e80030515c800d1ab44125b9052dfffd1bd04cDouglas Gregor child_range children() { return child_range(&Temporary, &Temporary + 1); } 306803e80030515c800d1ab44125b9052dfffd1bd04cDouglas Gregor}; 3069ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor 30705f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer} // end namespace clang 30715f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 30725f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer#endif 3073