ExprCXX.h revision ba243b59a1074e0962f6abfa3bb9aa984eac1245
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; 104ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 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 161ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 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; 174ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 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; } 184ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 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 202ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie/// CXXStaticCastExpr - A C++ @c static_cast expression 203ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie/// (C++ [expr.static.cast]). 2041eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump/// 20549badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// This expression node represents a C++ static cast, e.g., 20649badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// @c static_cast<int>(1.0). 20749badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregorclass CXXStaticCastExpr : public CXXNamedCastExpr { 208f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall CXXStaticCastExpr(QualType ty, ExprValueKind vk, CastKind kind, Expr *op, 209f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall unsigned pathSize, TypeSourceInfo *writtenTy, 2101d5d0b9df6d2a3df338bc3e63000536406e7666cDouglas Gregor SourceLocation l, SourceLocation RParenLoc) 211f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall : CXXNamedCastExpr(CXXStaticCastExprClass, ty, vk, kind, op, pathSize, 2121d5d0b9df6d2a3df338bc3e63000536406e7666cDouglas Gregor writtenTy, l, RParenLoc) {} 21349badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor 214f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall explicit CXXStaticCastExpr(EmptyShell Empty, unsigned PathSize) 215f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall : CXXNamedCastExpr(CXXStaticCastExprClass, Empty, PathSize) { } 216f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall 217f871d0cc377a1367b519a6cce26be74607566ebaJohn McCallpublic: 218f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall static CXXStaticCastExpr *Create(ASTContext &Context, QualType T, 219f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall ExprValueKind VK, CastKind K, Expr *Op, 220f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall const CXXCastPath *Path, 221ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie TypeSourceInfo *Written, SourceLocation L, 2221d5d0b9df6d2a3df338bc3e63000536406e7666cDouglas Gregor SourceLocation RParenLoc); 223f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall static CXXStaticCastExpr *CreateEmpty(ASTContext &Context, 224f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall unsigned PathSize); 225ce757a7a1ee905f87551996a69da3e95e8afeeb7Sam Weinig 2261eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump static bool classof(const Stmt *T) { 22749badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor return T->getStmtClass() == CXXStaticCastExprClass; 22849badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor } 22949badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor static bool classof(const CXXStaticCastExpr *) { return true; } 23049badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor}; 23149badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor 23249badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// CXXDynamicCastExpr - A C++ @c dynamic_cast expression 2331eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump/// (C++ [expr.dynamic.cast]), which may perform a run-time check to 23449badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// determine how to perform the type cast. 2351eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump/// 23649badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// This expression node represents a dynamic cast, e.g., 23749badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// @c dynamic_cast<Derived*>(BasePtr). 23849badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregorclass CXXDynamicCastExpr : public CXXNamedCastExpr { 239f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall CXXDynamicCastExpr(QualType ty, ExprValueKind VK, CastKind kind, 240f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall Expr *op, unsigned pathSize, TypeSourceInfo *writtenTy, 2411d5d0b9df6d2a3df338bc3e63000536406e7666cDouglas Gregor SourceLocation l, SourceLocation RParenLoc) 242f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall : CXXNamedCastExpr(CXXDynamicCastExprClass, ty, VK, kind, op, pathSize, 2431d5d0b9df6d2a3df338bc3e63000536406e7666cDouglas Gregor writtenTy, l, RParenLoc) {} 24449badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor 245f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall explicit CXXDynamicCastExpr(EmptyShell Empty, unsigned pathSize) 246f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall : CXXNamedCastExpr(CXXDynamicCastExprClass, Empty, pathSize) { } 247f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall 248f871d0cc377a1367b519a6cce26be74607566ebaJohn McCallpublic: 249f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall static CXXDynamicCastExpr *Create(ASTContext &Context, QualType T, 250f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall ExprValueKind VK, CastKind Kind, Expr *Op, 251f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall const CXXCastPath *Path, 252ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie TypeSourceInfo *Written, SourceLocation L, 2531d5d0b9df6d2a3df338bc3e63000536406e7666cDouglas Gregor SourceLocation RParenLoc); 254ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 255f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall static CXXDynamicCastExpr *CreateEmpty(ASTContext &Context, 256f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall unsigned pathSize); 257ce757a7a1ee905f87551996a69da3e95e8afeeb7Sam Weinig 2580fee330f5754ca4b248e5bb7363e834668aff06dAnders Carlsson bool isAlwaysNull() const; 2590fee330f5754ca4b248e5bb7363e834668aff06dAnders Carlsson 2601eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump static bool classof(const Stmt *T) { 26149badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor return T->getStmtClass() == CXXDynamicCastExprClass; 26249badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor } 26349badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor static bool classof(const CXXDynamicCastExpr *) { return true; } 26449badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor}; 26549badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor 26649badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// CXXReinterpretCastExpr - A C++ @c reinterpret_cast expression (C++ 26749badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// [expr.reinterpret.cast]), which provides a differently-typed view 26849badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// of a value but performs no actual work at run time. 2691eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump/// 27049badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// This expression node represents a reinterpret cast, e.g., 27149badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// @c reinterpret_cast<int>(VoidPtr). 27249badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregorclass CXXReinterpretCastExpr : public CXXNamedCastExpr { 273f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall CXXReinterpretCastExpr(QualType ty, ExprValueKind vk, CastKind kind, 274f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall Expr *op, unsigned pathSize, 275ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie TypeSourceInfo *writtenTy, SourceLocation l, 2761d5d0b9df6d2a3df338bc3e63000536406e7666cDouglas Gregor SourceLocation RParenLoc) 277f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall : CXXNamedCastExpr(CXXReinterpretCastExprClass, ty, vk, kind, op, 2781d5d0b9df6d2a3df338bc3e63000536406e7666cDouglas Gregor pathSize, writtenTy, l, RParenLoc) {} 27949badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor 280f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall CXXReinterpretCastExpr(EmptyShell Empty, unsigned pathSize) 281f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall : CXXNamedCastExpr(CXXReinterpretCastExprClass, Empty, pathSize) { } 282f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall 283f871d0cc377a1367b519a6cce26be74607566ebaJohn McCallpublic: 284f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall static CXXReinterpretCastExpr *Create(ASTContext &Context, QualType T, 285f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall ExprValueKind VK, CastKind Kind, 286f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall Expr *Op, const CXXCastPath *Path, 287ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie TypeSourceInfo *WrittenTy, SourceLocation L, 2881d5d0b9df6d2a3df338bc3e63000536406e7666cDouglas Gregor SourceLocation RParenLoc); 289f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall static CXXReinterpretCastExpr *CreateEmpty(ASTContext &Context, 290f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall unsigned pathSize); 291ce757a7a1ee905f87551996a69da3e95e8afeeb7Sam Weinig 2921eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump static bool classof(const Stmt *T) { 29349badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor return T->getStmtClass() == CXXReinterpretCastExprClass; 29449badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor } 29549badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor static bool classof(const CXXReinterpretCastExpr *) { return true; } 29649badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor}; 29749badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor 29849badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// CXXConstCastExpr - A C++ @c const_cast expression (C++ [expr.const.cast]), 29949badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// which can remove type qualifiers but does not change the underlying value. 3001eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump/// 30149badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// This expression node represents a const cast, e.g., 30249badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// @c const_cast<char*>(PtrToConstChar). 30349badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregorclass CXXConstCastExpr : public CXXNamedCastExpr { 304f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall CXXConstCastExpr(QualType ty, ExprValueKind VK, Expr *op, 305ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie TypeSourceInfo *writtenTy, SourceLocation l, 3061d5d0b9df6d2a3df338bc3e63000536406e7666cDouglas Gregor SourceLocation RParenLoc) 307ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie : CXXNamedCastExpr(CXXConstCastExprClass, ty, VK, CK_NoOp, op, 3081d5d0b9df6d2a3df338bc3e63000536406e7666cDouglas Gregor 0, writtenTy, l, RParenLoc) {} 30949badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor 310ce757a7a1ee905f87551996a69da3e95e8afeeb7Sam Weinig explicit CXXConstCastExpr(EmptyShell Empty) 311f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall : CXXNamedCastExpr(CXXConstCastExprClass, Empty, 0) { } 312f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall 313f871d0cc377a1367b519a6cce26be74607566ebaJohn McCallpublic: 314f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall static CXXConstCastExpr *Create(ASTContext &Context, QualType T, 315f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall ExprValueKind VK, Expr *Op, 316ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie TypeSourceInfo *WrittenTy, SourceLocation L, 3171d5d0b9df6d2a3df338bc3e63000536406e7666cDouglas Gregor SourceLocation RParenLoc); 318f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall static CXXConstCastExpr *CreateEmpty(ASTContext &Context); 319ce757a7a1ee905f87551996a69da3e95e8afeeb7Sam Weinig 3201eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump static bool classof(const Stmt *T) { 32149badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor return T->getStmtClass() == CXXConstCastExprClass; 32249badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor } 32349badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor static bool classof(const CXXConstCastExpr *) { return true; } 3241060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek}; 3251060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek 3261060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek/// CXXBoolLiteralExpr - [C++ 2.13.5] C++ Boolean Literal. 3271eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump/// 3281060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenekclass CXXBoolLiteralExpr : public Expr { 3291060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek bool Value; 3301060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek SourceLocation Loc; 3311060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenekpublic: 3321eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump CXXBoolLiteralExpr(bool val, QualType Ty, SourceLocation l) : 333bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor Expr(CXXBoolLiteralExprClass, Ty, VK_RValue, OK_Ordinary, false, false, 334561f81243f665cf2001caadc45df505f826b72d6Douglas Gregor false, false), 335f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall Value(val), Loc(l) {} 3368b0b475b3464b0f70b91ba7d679d23c424677d5eSebastian Redl 337eb7f96141f754150a92433286fa385910a22f494Sam Weinig explicit CXXBoolLiteralExpr(EmptyShell Empty) 338eb7f96141f754150a92433286fa385910a22f494Sam Weinig : Expr(CXXBoolLiteralExprClass, Empty) { } 339eb7f96141f754150a92433286fa385910a22f494Sam Weinig 3401060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek bool getValue() const { return Value; } 341eb7f96141f754150a92433286fa385910a22f494Sam Weinig void setValue(bool V) { Value = V; } 3425f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 34363c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall SourceRange getSourceRange() const { return SourceRange(Loc); } 3441eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 345eb7f96141f754150a92433286fa385910a22f494Sam Weinig SourceLocation getLocation() const { return Loc; } 346eb7f96141f754150a92433286fa385910a22f494Sam Weinig void setLocation(SourceLocation L) { Loc = L; } 347eb7f96141f754150a92433286fa385910a22f494Sam Weinig 3481eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump static bool classof(const Stmt *T) { 3491060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek return T->getStmtClass() == CXXBoolLiteralExprClass; 3501060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek } 3511060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek static bool classof(const CXXBoolLiteralExpr *) { return true; } 3521eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 3531060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek // Iterators 35463c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall child_range children() { return child_range(); } 3551060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek}; 3561060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek 3576e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl/// CXXNullPtrLiteralExpr - [C++0x 2.14.7] C++ Pointer Literal 3586e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redlclass CXXNullPtrLiteralExpr : public Expr { 3596e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl SourceLocation Loc; 3606e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redlpublic: 3616e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl CXXNullPtrLiteralExpr(QualType Ty, SourceLocation l) : 362bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor Expr(CXXNullPtrLiteralExprClass, Ty, VK_RValue, OK_Ordinary, false, false, 363561f81243f665cf2001caadc45df505f826b72d6Douglas Gregor false, false), 364f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall Loc(l) {} 3656e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl 366eb7f96141f754150a92433286fa385910a22f494Sam Weinig explicit CXXNullPtrLiteralExpr(EmptyShell Empty) 367eb7f96141f754150a92433286fa385910a22f494Sam Weinig : Expr(CXXNullPtrLiteralExprClass, Empty) { } 368eb7f96141f754150a92433286fa385910a22f494Sam Weinig 36963c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall SourceRange getSourceRange() const { return SourceRange(Loc); } 3706e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl 371eb7f96141f754150a92433286fa385910a22f494Sam Weinig SourceLocation getLocation() const { return Loc; } 372eb7f96141f754150a92433286fa385910a22f494Sam Weinig void setLocation(SourceLocation L) { Loc = L; } 373eb7f96141f754150a92433286fa385910a22f494Sam Weinig 3746e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl static bool classof(const Stmt *T) { 3756e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl return T->getStmtClass() == CXXNullPtrLiteralExprClass; 3766e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl } 3776e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl static bool classof(const CXXNullPtrLiteralExpr *) { return true; } 3786e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl 37963c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall child_range children() { return child_range(); } 3806e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl}; 3816e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl 382c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl/// CXXTypeidExpr - A C++ @c typeid expression (C++ [expr.typeid]), which gets 383c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl/// the type_info that corresponds to the supplied type, or the (possibly 384c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl/// dynamic) type of the supplied expression. 385c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl/// 386c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl/// This represents code like @c typeid(int) or @c typeid(*objPtr) 387c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redlclass CXXTypeidExpr : public Expr { 388c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redlprivate: 38957fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor llvm::PointerUnion<Stmt *, TypeSourceInfo *> Operand; 390c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl SourceRange Range; 391c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl 392c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redlpublic: 39357fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor CXXTypeidExpr(QualType Ty, TypeSourceInfo *Operand, SourceRange R) 394f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall : Expr(CXXTypeidExprClass, Ty, VK_LValue, OK_Ordinary, 39557fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor // typeid is never type-dependent (C++ [temp.dep.expr]p4) 39657fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor false, 39757fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor // typeid is value-dependent if the type or expression are dependent 398bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor Operand->getType()->isDependentType(), 399561f81243f665cf2001caadc45df505f826b72d6Douglas Gregor Operand->getType()->isInstantiationDependentType(), 400bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor Operand->getType()->containsUnexpandedParameterPack()), 40157fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor Operand(Operand), Range(R) { } 402ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 40357fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor CXXTypeidExpr(QualType Ty, Expr *Operand, SourceRange R) 404f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall : Expr(CXXTypeidExprClass, Ty, VK_LValue, OK_Ordinary, 4052850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl // typeid is never type-dependent (C++ [temp.dep.expr]p4) 406bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor false, 4072850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl // typeid is value-dependent if the type or expression are dependent 408bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor Operand->isTypeDependent() || Operand->isValueDependent(), 409561f81243f665cf2001caadc45df505f826b72d6Douglas Gregor Operand->isInstantiationDependent(), 410bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor Operand->containsUnexpandedParameterPack()), 41157fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor Operand(Operand), Range(R) { } 412c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl 41314ab24f01e36d495fce183aa67b41e45cdd54f39Chris Lattner CXXTypeidExpr(EmptyShell Empty, bool isExpr) 41414ab24f01e36d495fce183aa67b41e45cdd54f39Chris Lattner : Expr(CXXTypeidExprClass, Empty) { 41514ab24f01e36d495fce183aa67b41e45cdd54f39Chris Lattner if (isExpr) 41614ab24f01e36d495fce183aa67b41e45cdd54f39Chris Lattner Operand = (Expr*)0; 41714ab24f01e36d495fce183aa67b41e45cdd54f39Chris Lattner else 41814ab24f01e36d495fce183aa67b41e45cdd54f39Chris Lattner Operand = (TypeSourceInfo*)0; 41914ab24f01e36d495fce183aa67b41e45cdd54f39Chris Lattner } 420ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 42157fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor bool isTypeOperand() const { return Operand.is<TypeSourceInfo *>(); } 422ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 42357fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor /// \brief Retrieves the type operand of this typeid() expression after 42457fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor /// various required adjustments (removing reference types, cv-qualifiers). 42557fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor QualType getTypeOperand() const; 42657fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor 42757fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor /// \brief Retrieve source information for the type operand. 42857fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor TypeSourceInfo *getTypeOperandSourceInfo() const { 429c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl assert(isTypeOperand() && "Cannot call getTypeOperand for typeid(expr)"); 43057fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor return Operand.get<TypeSourceInfo *>(); 431c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl } 43214ab24f01e36d495fce183aa67b41e45cdd54f39Chris Lattner 43314ab24f01e36d495fce183aa67b41e45cdd54f39Chris Lattner void setTypeOperandSourceInfo(TypeSourceInfo *TSI) { 43414ab24f01e36d495fce183aa67b41e45cdd54f39Chris Lattner assert(isTypeOperand() && "Cannot call getTypeOperand for typeid(expr)"); 43514ab24f01e36d495fce183aa67b41e45cdd54f39Chris Lattner Operand = TSI; 43614ab24f01e36d495fce183aa67b41e45cdd54f39Chris Lattner } 437ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 43814ab24f01e36d495fce183aa67b41e45cdd54f39Chris Lattner Expr *getExprOperand() const { 439c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl assert(!isTypeOperand() && "Cannot call getExprOperand for typeid(type)"); 44057fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor return static_cast<Expr*>(Operand.get<Stmt *>()); 441c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl } 442ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 443030854b95f7bfd86aaa8afd9ae1aff9768a37e9aChris Lattner void setExprOperand(Expr *E) { 444030854b95f7bfd86aaa8afd9ae1aff9768a37e9aChris Lattner assert(!isTypeOperand() && "Cannot call getExprOperand for typeid(type)"); 445030854b95f7bfd86aaa8afd9ae1aff9768a37e9aChris Lattner Operand = E; 446030854b95f7bfd86aaa8afd9ae1aff9768a37e9aChris Lattner } 447ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 44863c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall SourceRange getSourceRange() const { return Range; } 44914ab24f01e36d495fce183aa67b41e45cdd54f39Chris Lattner void setSourceRange(SourceRange R) { Range = R; } 450ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 451c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl static bool classof(const Stmt *T) { 452c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl return T->getStmtClass() == CXXTypeidExprClass; 453c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl } 454c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl static bool classof(const CXXTypeidExpr *) { return true; } 455c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl 456c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl // Iterators 45763c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall child_range children() { 45863c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall if (isTypeOperand()) return child_range(); 45963c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall Stmt **begin = reinterpret_cast<Stmt**>(&Operand); 46063c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall return child_range(begin, begin + 1); 46163c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall } 462c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl}; 463c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl 46401b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet/// CXXUuidofExpr - A microsoft C++ @c __uuidof expression, which gets 46501b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet/// the _GUID that corresponds to the supplied type or expression. 46601b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet/// 46701b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet/// This represents code like @c __uuidof(COMTYPE) or @c __uuidof(*comPtr) 46801b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichetclass CXXUuidofExpr : public Expr { 46901b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichetprivate: 47001b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet llvm::PointerUnion<Stmt *, TypeSourceInfo *> Operand; 47101b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet SourceRange Range; 47201b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet 47301b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichetpublic: 47401b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet CXXUuidofExpr(QualType Ty, TypeSourceInfo *Operand, SourceRange R) 4752e219b8d253dbb901206b14e5643cc9d0edd662bFrancois Pichet : Expr(CXXUuidofExprClass, Ty, VK_LValue, OK_Ordinary, 476bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor false, Operand->getType()->isDependentType(), 477561f81243f665cf2001caadc45df505f826b72d6Douglas Gregor Operand->getType()->isInstantiationDependentType(), 478bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor Operand->getType()->containsUnexpandedParameterPack()), 47901b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet Operand(Operand), Range(R) { } 480ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 48101b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet CXXUuidofExpr(QualType Ty, Expr *Operand, SourceRange R) 4822e219b8d253dbb901206b14e5643cc9d0edd662bFrancois Pichet : Expr(CXXUuidofExprClass, Ty, VK_LValue, OK_Ordinary, 483bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor false, Operand->isTypeDependent(), 484561f81243f665cf2001caadc45df505f826b72d6Douglas Gregor Operand->isInstantiationDependent(), 485bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor Operand->containsUnexpandedParameterPack()), 48601b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet Operand(Operand), Range(R) { } 48701b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet 48801b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet CXXUuidofExpr(EmptyShell Empty, bool isExpr) 48901b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet : Expr(CXXUuidofExprClass, Empty) { 49001b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet if (isExpr) 49101b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet Operand = (Expr*)0; 49201b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet else 49301b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet Operand = (TypeSourceInfo*)0; 49401b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet } 495ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 49601b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet bool isTypeOperand() const { return Operand.is<TypeSourceInfo *>(); } 497ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 49801b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet /// \brief Retrieves the type operand of this __uuidof() expression after 49901b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet /// various required adjustments (removing reference types, cv-qualifiers). 50001b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet QualType getTypeOperand() const; 50101b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet 50201b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet /// \brief Retrieve source information for the type operand. 50301b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet TypeSourceInfo *getTypeOperandSourceInfo() const { 50401b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet assert(isTypeOperand() && "Cannot call getTypeOperand for __uuidof(expr)"); 50501b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet return Operand.get<TypeSourceInfo *>(); 50601b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet } 50701b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet 50801b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet void setTypeOperandSourceInfo(TypeSourceInfo *TSI) { 50901b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet assert(isTypeOperand() && "Cannot call getTypeOperand for __uuidof(expr)"); 51001b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet Operand = TSI; 51101b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet } 512ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 51301b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet Expr *getExprOperand() const { 51401b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet assert(!isTypeOperand() && "Cannot call getExprOperand for __uuidof(type)"); 51501b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet return static_cast<Expr*>(Operand.get<Stmt *>()); 51601b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet } 517ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 51801b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet void setExprOperand(Expr *E) { 51901b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet assert(!isTypeOperand() && "Cannot call getExprOperand for __uuidof(type)"); 52001b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet Operand = E; 52101b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet } 52201b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet 52363c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall SourceRange getSourceRange() const { return Range; } 52401b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet void setSourceRange(SourceRange R) { Range = R; } 525ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 52601b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet static bool classof(const Stmt *T) { 52701b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet return T->getStmtClass() == CXXUuidofExprClass; 52801b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet } 52901b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet static bool classof(const CXXUuidofExpr *) { return true; } 53001b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet 53101b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet // Iterators 53263c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall child_range children() { 53363c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall if (isTypeOperand()) return child_range(); 53463c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall Stmt **begin = reinterpret_cast<Stmt**>(&Operand); 53563c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall return child_range(begin, begin + 1); 53663c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall } 53701b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet}; 53801b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet 539796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// CXXThisExpr - Represents the "this" expression in C++, which is a 540796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// pointer to the object on which the current member function is 541796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// executing (C++ [expr.prim]p3). Example: 542796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// 543796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// @code 544796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// class Foo { 545796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// public: 546796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// void bar(); 547796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// void test() { this->bar(); } 548796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// }; 549796da18402f286b897782a298ae3b20c459c102eDouglas Gregor/// @endcode 550796da18402f286b897782a298ae3b20c459c102eDouglas Gregorclass CXXThisExpr : public Expr { 551796da18402f286b897782a298ae3b20c459c102eDouglas Gregor SourceLocation Loc; 552828a197317288e3333b0ce6f5cedadd036e3531fDouglas Gregor bool Implicit : 1; 553ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 554796da18402f286b897782a298ae3b20c459c102eDouglas Gregorpublic: 555828a197317288e3333b0ce6f5cedadd036e3531fDouglas Gregor CXXThisExpr(SourceLocation L, QualType Type, bool isImplicit) 556f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall : Expr(CXXThisExprClass, Type, VK_RValue, OK_Ordinary, 5572850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl // 'this' is type-dependent if the class type of the enclosing 5582850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl // member function is dependent (C++ [temp.dep.expr]p2) 559bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor Type->isDependentType(), Type->isDependentType(), 560561f81243f665cf2001caadc45df505f826b72d6Douglas Gregor Type->isInstantiationDependentType(), 561bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor /*ContainsUnexpandedParameterPack=*/false), 562828a197317288e3333b0ce6f5cedadd036e3531fDouglas Gregor Loc(L), Implicit(isImplicit) { } 563796da18402f286b897782a298ae3b20c459c102eDouglas Gregor 5642fbdfcdf3bbf7b941853d38b123930755e837437Chris Lattner CXXThisExpr(EmptyShell Empty) : Expr(CXXThisExprClass, Empty) {} 5652fbdfcdf3bbf7b941853d38b123930755e837437Chris Lattner 5662fbdfcdf3bbf7b941853d38b123930755e837437Chris Lattner SourceLocation getLocation() const { return Loc; } 5672fbdfcdf3bbf7b941853d38b123930755e837437Chris Lattner void setLocation(SourceLocation L) { Loc = L; } 5682fbdfcdf3bbf7b941853d38b123930755e837437Chris Lattner 56963c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall SourceRange getSourceRange() const { return SourceRange(Loc); } 570796da18402f286b897782a298ae3b20c459c102eDouglas Gregor 571828a197317288e3333b0ce6f5cedadd036e3531fDouglas Gregor bool isImplicit() const { return Implicit; } 572828a197317288e3333b0ce6f5cedadd036e3531fDouglas Gregor void setImplicit(bool I) { Implicit = I; } 573ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 5741eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump static bool classof(const Stmt *T) { 575796da18402f286b897782a298ae3b20c459c102eDouglas Gregor return T->getStmtClass() == CXXThisExprClass; 576796da18402f286b897782a298ae3b20c459c102eDouglas Gregor } 577796da18402f286b897782a298ae3b20c459c102eDouglas Gregor static bool classof(const CXXThisExpr *) { return true; } 578796da18402f286b897782a298ae3b20c459c102eDouglas Gregor 579796da18402f286b897782a298ae3b20c459c102eDouglas Gregor // Iterators 58063c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall child_range children() { return child_range(); } 581796da18402f286b897782a298ae3b20c459c102eDouglas Gregor}; 582796da18402f286b897782a298ae3b20c459c102eDouglas Gregor 5831060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek/// CXXThrowExpr - [C++ 15] C++ Throw Expression. This handles 5841060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek/// 'throw' and 'throw' assignment-expression. When 5851060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek/// assignment-expression isn't present, Op will be null. 5861060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek/// 5871060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenekclass CXXThrowExpr : public Expr { 5881060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek Stmt *Op; 5891060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek SourceLocation ThrowLoc; 590bca01b46850f867b2f4137f25c882022b58f8471Douglas Gregor /// \brief Whether the thrown variable (if any) is in scope. 591bca01b46850f867b2f4137f25c882022b58f8471Douglas Gregor unsigned IsThrownVariableInScope : 1; 592ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 593bca01b46850f867b2f4137f25c882022b58f8471Douglas Gregor friend class ASTStmtReader; 594ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 5951060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenekpublic: 5961060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek // Ty is the void type which is used as the result type of the 5971060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek // exepression. The l is the location of the throw keyword. expr 5981060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek // can by null, if the optional expression to throw isn't present. 599bca01b46850f867b2f4137f25c882022b58f8471Douglas Gregor CXXThrowExpr(Expr *expr, QualType Ty, SourceLocation l, 600bca01b46850f867b2f4137f25c882022b58f8471Douglas Gregor bool IsThrownVariableInScope) : 601bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor Expr(CXXThrowExprClass, Ty, VK_RValue, OK_Ordinary, false, false, 602561f81243f665cf2001caadc45df505f826b72d6Douglas Gregor expr && expr->isInstantiationDependent(), 603bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor expr && expr->containsUnexpandedParameterPack()), 604bca01b46850f867b2f4137f25c882022b58f8471Douglas Gregor Op(expr), ThrowLoc(l), IsThrownVariableInScope(IsThrownVariableInScope) {} 6052fbdfcdf3bbf7b941853d38b123930755e837437Chris Lattner CXXThrowExpr(EmptyShell Empty) : Expr(CXXThrowExprClass, Empty) {} 6062fbdfcdf3bbf7b941853d38b123930755e837437Chris Lattner 6071060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek const Expr *getSubExpr() const { return cast_or_null<Expr>(Op); } 6081060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek Expr *getSubExpr() { return cast_or_null<Expr>(Op); } 60942e5b50f4dc897f252e0d476063a7f9846d96624Douglas Gregor 61042e5b50f4dc897f252e0d476063a7f9846d96624Douglas Gregor SourceLocation getThrowLoc() const { return ThrowLoc; } 6111060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek 612bca01b46850f867b2f4137f25c882022b58f8471Douglas Gregor /// \brief Determines whether the variable thrown by this expression (if any!) 613bca01b46850f867b2f4137f25c882022b58f8471Douglas Gregor /// is within the innermost try block. 614bca01b46850f867b2f4137f25c882022b58f8471Douglas Gregor /// 615bca01b46850f867b2f4137f25c882022b58f8471Douglas Gregor /// This information is required to determine whether the NRVO can apply to 616bca01b46850f867b2f4137f25c882022b58f8471Douglas Gregor /// this variable. 617bca01b46850f867b2f4137f25c882022b58f8471Douglas Gregor bool isThrownVariableInScope() const { return IsThrownVariableInScope; } 618ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 61963c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall SourceRange getSourceRange() const { 6201060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek if (getSubExpr() == 0) 6211060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek return SourceRange(ThrowLoc, ThrowLoc); 6221060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek return SourceRange(ThrowLoc, getSubExpr()->getSourceRange().getEnd()); 6231060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek } 6241060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek 6251060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek static bool classof(const Stmt *T) { 6261060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek return T->getStmtClass() == CXXThrowExprClass; 6271060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek } 6281060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek static bool classof(const CXXThrowExpr *) { return true; } 6291060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek 6301060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek // Iterators 63163c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall child_range children() { 63263c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall return child_range(&Op, Op ? &Op+1 : &Op); 63363c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall } 6341060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek}; 6351060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek 6361060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek/// CXXDefaultArgExpr - C++ [dcl.fct.default]. This wraps up a 6371060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek/// function call argument that was created from the corresponding 6381060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek/// parameter's default argument, when the call did not explicitly 6391060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek/// supply arguments for all of the parameters. 6401060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenekclass CXXDefaultArgExpr : public Expr { 64165222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor /// \brief The parameter whose default is being used. 64265222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor /// 643ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie /// When the bit is set, the subexpression is stored after the 64465222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor /// CXXDefaultArgExpr itself. When the bit is clear, the parameter's 64565222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor /// actual default expression is the subexpression. 64665222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor llvm::PointerIntPair<ParmVarDecl *, 1, bool> Param; 6471eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 648036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor /// \brief The location where the default argument expression was used. 649036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor SourceLocation Loc; 650ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 651036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor CXXDefaultArgExpr(StmtClass SC, SourceLocation Loc, ParmVarDecl *param) 652ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie : Expr(SC, 65365222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor param->hasUnparsedDefaultArg() 65465222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor ? param->getType().getNonReferenceType() 6552333f7727f97018d6742e1e0938133bcfad967abEli Friedman : param->getDefaultArg()->getType(), 656dfa1edbebeda7ec3a7a9c45e4317de9241aa9883John McCall param->getDefaultArg()->getValueKind(), 657561f81243f665cf2001caadc45df505f826b72d6Douglas Gregor param->getDefaultArg()->getObjectKind(), false, false, false, false), 658036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor Param(param, false), Loc(Loc) { } 65965222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor 660ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie CXXDefaultArgExpr(StmtClass SC, SourceLocation Loc, ParmVarDecl *param, 661036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor Expr *SubExpr) 662dfa1edbebeda7ec3a7a9c45e4317de9241aa9883John McCall : Expr(SC, SubExpr->getType(), 663dfa1edbebeda7ec3a7a9c45e4317de9241aa9883John McCall SubExpr->getValueKind(), SubExpr->getObjectKind(), 664ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie false, false, false, false), 665bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor Param(param, true), Loc(Loc) { 66665222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor *reinterpret_cast<Expr **>(this + 1) = SubExpr; 66765222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor } 668ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 6691060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenekpublic: 670030854b95f7bfd86aaa8afd9ae1aff9768a37e9aChris Lattner CXXDefaultArgExpr(EmptyShell Empty) : Expr(CXXDefaultArgExprClass, Empty) {} 671030854b95f7bfd86aaa8afd9ae1aff9768a37e9aChris Lattner 672ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 6731060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek // Param is the parameter whose default argument is used by this 6741060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek // expression. 675036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor static CXXDefaultArgExpr *Create(ASTContext &C, SourceLocation Loc, 676036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor ParmVarDecl *Param) { 677036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor return new (C) CXXDefaultArgExpr(CXXDefaultArgExprClass, Loc, Param); 678f1480eee38b59d15438fb7bc50865ac7c7e22403Anders Carlsson } 6791060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek 68065222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor // Param is the parameter whose default argument is used by this 68165222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor // expression, and SubExpr is the expression that will actually be used. 682ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie static CXXDefaultArgExpr *Create(ASTContext &C, 683036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor SourceLocation Loc, 684ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie ParmVarDecl *Param, 68565222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor Expr *SubExpr); 686ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 6871060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek // Retrieve the parameter that the argument was created from. 68865222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor const ParmVarDecl *getParam() const { return Param.getPointer(); } 68965222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor ParmVarDecl *getParam() { return Param.getPointer(); } 690ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 6911060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek // Retrieve the actual argument to the function call. 692ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie const Expr *getExpr() const { 69365222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor if (Param.getInt()) 69465222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor return *reinterpret_cast<Expr const * const*> (this + 1); 695ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie return getParam()->getDefaultArg(); 69665222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor } 697ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie Expr *getExpr() { 69865222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor if (Param.getInt()) 69965222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor return *reinterpret_cast<Expr **> (this + 1); 700ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie return getParam()->getDefaultArg(); 70165222e82d97af2120b3952d19cbd3cd923f4b43eDouglas Gregor } 7021060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek 703ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie /// \brief Retrieve the location where this default argument was actually 704036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor /// used. 705036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor SourceLocation getUsedLocation() const { return Loc; } 706ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 70763c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall SourceRange getSourceRange() const { 7081060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek // Default argument expressions have no representation in the 7091060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek // source, so they have an empty source range. 7101060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek return SourceRange(); 7111060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek } 7121060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek 7131060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek static bool classof(const Stmt *T) { 7141060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek return T->getStmtClass() == CXXDefaultArgExprClass; 7151060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek } 7161060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek static bool classof(const CXXDefaultArgExpr *) { return true; } 7171060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek 7181060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek // Iterators 71963c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall child_range children() { return child_range(); } 7208a50733034edd6a349b34e2b9f0c8d0a874846d3Argyrios Kyrtzidis 72160adf4acf40b72227740bf966fb87eebddff3f37Sebastian Redl friend class ASTStmtReader; 7223397c5570369f19b2d6c52e898f708d75ceede1fSebastian Redl friend class ASTStmtWriter; 7231060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek}; 724987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis 725c1ce477119fed070299668aab24084b17ff5f14bAnders Carlsson/// CXXTemporary - Represents a C++ temporary. 726c1ce477119fed070299668aab24084b17ff5f14bAnders Carlssonclass CXXTemporary { 727c1ce477119fed070299668aab24084b17ff5f14bAnders Carlsson /// Destructor - The destructor that needs to be called. 728b859f35459ae3e1188d1e1b86df08d649695fd86Anders Carlsson const CXXDestructorDecl *Destructor; 7291eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 730b859f35459ae3e1188d1e1b86df08d649695fd86Anders Carlsson CXXTemporary(const CXXDestructorDecl *destructor) 731c1ce477119fed070299668aab24084b17ff5f14bAnders Carlsson : Destructor(destructor) { } 732c1ce477119fed070299668aab24084b17ff5f14bAnders Carlsson 733c1ce477119fed070299668aab24084b17ff5f14bAnders Carlssonpublic: 7341eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump static CXXTemporary *Create(ASTContext &C, 735b859f35459ae3e1188d1e1b86df08d649695fd86Anders Carlsson const CXXDestructorDecl *Destructor); 7361eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 737f0721fe438d7e40c168e5d664970e7830bc138fbAnders Carlsson const CXXDestructorDecl *getDestructor() const { return Destructor; } 738c1ce477119fed070299668aab24084b17ff5f14bAnders Carlsson}; 739fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson 740ddfe960d252a93525692b547945236d361d1929fChandler Carruth/// \brief Represents binding an expression to a temporary. 741ddfe960d252a93525692b547945236d361d1929fChandler Carruth/// 742ddfe960d252a93525692b547945236d361d1929fChandler Carruth/// This ensures the destructor is called for the temporary. It should only be 743ddfe960d252a93525692b547945236d361d1929fChandler Carruth/// needed for non-POD, non-trivially destructable class types. For example: 744ddfe960d252a93525692b547945236d361d1929fChandler Carruth/// 745ddfe960d252a93525692b547945236d361d1929fChandler Carruth/// \code 746ddfe960d252a93525692b547945236d361d1929fChandler Carruth/// struct S { 747ddfe960d252a93525692b547945236d361d1929fChandler Carruth/// S() { } // User defined constructor makes S non-POD. 748ddfe960d252a93525692b547945236d361d1929fChandler Carruth/// ~S() { } // User defined destructor makes it non-trivial. 749ddfe960d252a93525692b547945236d361d1929fChandler Carruth/// }; 750ddfe960d252a93525692b547945236d361d1929fChandler Carruth/// void test() { 751ddfe960d252a93525692b547945236d361d1929fChandler Carruth/// const S &s_ref = S(); // Requires a CXXBindTemporaryExpr. 752ddfe960d252a93525692b547945236d361d1929fChandler Carruth/// } 753ddfe960d252a93525692b547945236d361d1929fChandler Carruth/// \endcode 754fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlssonclass CXXBindTemporaryExpr : public Expr { 755fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson CXXTemporary *Temp; 7561eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 757fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson Stmt *SubExpr; 758fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson 759bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor CXXBindTemporaryExpr(CXXTemporary *temp, Expr* SubExpr) 760bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor : Expr(CXXBindTemporaryExprClass, SubExpr->getType(), 761ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie VK_RValue, OK_Ordinary, SubExpr->isTypeDependent(), 762bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor SubExpr->isValueDependent(), 763561f81243f665cf2001caadc45df505f826b72d6Douglas Gregor SubExpr->isInstantiationDependent(), 764bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor SubExpr->containsUnexpandedParameterPack()), 765bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor Temp(temp), SubExpr(SubExpr) { } 76688eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlsson 767fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlssonpublic: 768d2598368876cfe40bc8465540033bc5b5e58d8afChris Lattner CXXBindTemporaryExpr(EmptyShell Empty) 769d2598368876cfe40bc8465540033bc5b5e58d8afChris Lattner : Expr(CXXBindTemporaryExprClass, Empty), Temp(0), SubExpr(0) {} 770ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 7711eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump static CXXBindTemporaryExpr *Create(ASTContext &C, CXXTemporary *Temp, 772fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson Expr* SubExpr); 7731eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 77488eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlsson CXXTemporary *getTemporary() { return Temp; } 775f0721fe438d7e40c168e5d664970e7830bc138fbAnders Carlsson const CXXTemporary *getTemporary() const { return Temp; } 776d2598368876cfe40bc8465540033bc5b5e58d8afChris Lattner void setTemporary(CXXTemporary *T) { Temp = T; } 777f0721fe438d7e40c168e5d664970e7830bc138fbAnders Carlsson 778fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson const Expr *getSubExpr() const { return cast<Expr>(SubExpr); } 779fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson Expr *getSubExpr() { return cast<Expr>(SubExpr); } 78088eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlsson void setSubExpr(Expr *E) { SubExpr = E; } 781fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson 782ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie SourceRange getSourceRange() const { 78396be6917e1c4ba1f4435a14c9e7c6c139571d086Douglas Gregor return SubExpr->getSourceRange(); 78496be6917e1c4ba1f4435a14c9e7c6c139571d086Douglas Gregor } 785fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson 786fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson // Implement isa/cast/dyncast/etc. 787fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson static bool classof(const Stmt *T) { 788fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson return T->getStmtClass() == CXXBindTemporaryExprClass; 789fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson } 790fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson static bool classof(const CXXBindTemporaryExpr *) { return true; } 791fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson 792fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson // Iterators 79363c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall child_range children() { return child_range(&SubExpr, &SubExpr + 1); } 794fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson}; 795fceb0a8adba9d25db99a4d73e9655c2831a96ecdAnders Carlsson 79615ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson/// CXXConstructExpr - Represents a call to a C++ constructor. 79715ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlssonclass CXXConstructExpr : public Expr { 79872e96fd181b19b8d01144a685cda6e955584c7eaAnders Carlssonpublic: 79972e96fd181b19b8d01144a685cda6e955584c7eaAnders Carlsson enum ConstructionKind { 80072e96fd181b19b8d01144a685cda6e955584c7eaAnders Carlsson CK_Complete, 80172e96fd181b19b8d01144a685cda6e955584c7eaAnders Carlsson CK_NonVirtualBase, 802059ce0d92eb5a7da900ae735dc0a2ea3d64f4b0bSean Hunt CK_VirtualBase, 803059ce0d92eb5a7da900ae735dc0a2ea3d64f4b0bSean Hunt CK_Delegating 80472e96fd181b19b8d01144a685cda6e955584c7eaAnders Carlsson }; 805ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 80672e96fd181b19b8d01144a685cda6e955584c7eaAnders Carlssonprivate: 80715ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson CXXConstructorDecl *Constructor; 80815ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson 80999a2e600f9e2e51d3ce10fb6f27191677ac65b2aDouglas Gregor SourceLocation Loc; 810428edafa9eb80e01dd40aab31d4166a787a741e1Chandler Carruth SourceRange ParenRange; 811a48e676a717309afa50ae06a3d4674acec025bf9Douglas Gregor unsigned NumArgs : 16; 81216006c901315fa12a108b4e571f187f4b676e426Douglas Gregor bool Elidable : 1; 8137cc58b4c927fca539d43eaa58e00dca95946eb7cAbramo Bagnara bool HadMultipleCandidates : 1; 81416006c901315fa12a108b4e571f187f4b676e426Douglas Gregor bool ZeroInitialization : 1; 81572e96fd181b19b8d01144a685cda6e955584c7eaAnders Carlsson unsigned ConstructKind : 2; 81615ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson Stmt **Args; 8171eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 818bd6734e5f6432ce0cc07171c490ffaa094796198Anders Carlssonprotected: 8191eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump CXXConstructExpr(ASTContext &C, StmtClass SC, QualType T, 82099a2e600f9e2e51d3ce10fb6f27191677ac65b2aDouglas Gregor SourceLocation Loc, 821bd6734e5f6432ce0cc07171c490ffaa094796198Anders Carlsson CXXConstructorDecl *d, bool elidable, 82216006c901315fa12a108b4e571f187f4b676e426Douglas Gregor Expr **args, unsigned numargs, 8237cc58b4c927fca539d43eaa58e00dca95946eb7cAbramo Bagnara bool HadMultipleCandidates, 8249db7dbb918ca49f4ee6c181e4917e7b6ec547353Douglas Gregor bool ZeroInitialization = false, 825428edafa9eb80e01dd40aab31d4166a787a741e1Chandler Carruth ConstructionKind ConstructKind = CK_Complete, 826428edafa9eb80e01dd40aab31d4166a787a741e1Chandler Carruth SourceRange ParenRange = SourceRange()); 827bd6734e5f6432ce0cc07171c490ffaa094796198Anders Carlsson 8286d00c1365dd3601f6d93bbda9162913c57ae788fArgyrios Kyrtzidis /// \brief Construct an empty C++ construction expression. 8296d00c1365dd3601f6d93bbda9162913c57ae788fArgyrios Kyrtzidis CXXConstructExpr(StmtClass SC, EmptyShell Empty) 8307cc58b4c927fca539d43eaa58e00dca95946eb7cAbramo Bagnara : Expr(SC, Empty), Constructor(0), NumArgs(0), Elidable(0), 8317cc58b4c927fca539d43eaa58e00dca95946eb7cAbramo Bagnara HadMultipleCandidates(false), ZeroInitialization(0), 8327cc58b4c927fca539d43eaa58e00dca95946eb7cAbramo Bagnara ConstructKind(0), Args(0) { } 8336d00c1365dd3601f6d93bbda9162913c57ae788fArgyrios Kyrtzidis 83415ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlssonpublic: 8356d00c1365dd3601f6d93bbda9162913c57ae788fArgyrios Kyrtzidis /// \brief Construct an empty C++ construction expression. 8366d00c1365dd3601f6d93bbda9162913c57ae788fArgyrios Kyrtzidis explicit CXXConstructExpr(EmptyShell Empty) 8376d00c1365dd3601f6d93bbda9162913c57ae788fArgyrios Kyrtzidis : Expr(CXXConstructExprClass, Empty), Constructor(0), 8387cc58b4c927fca539d43eaa58e00dca95946eb7cAbramo Bagnara NumArgs(0), Elidable(0), HadMultipleCandidates(false), 8397cc58b4c927fca539d43eaa58e00dca95946eb7cAbramo Bagnara ZeroInitialization(0), ConstructKind(0), Args(0) { } 8406d00c1365dd3601f6d93bbda9162913c57ae788fArgyrios Kyrtzidis 8418e587a15da6d3457a418239d5eb4146fcbd209f3Anders Carlsson static CXXConstructExpr *Create(ASTContext &C, QualType T, 84299a2e600f9e2e51d3ce10fb6f27191677ac65b2aDouglas Gregor SourceLocation Loc, 8431eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump CXXConstructorDecl *D, bool Elidable, 84416006c901315fa12a108b4e571f187f4b676e426Douglas Gregor Expr **Args, unsigned NumArgs, 8457cc58b4c927fca539d43eaa58e00dca95946eb7cAbramo Bagnara bool HadMultipleCandidates, 8469db7dbb918ca49f4ee6c181e4917e7b6ec547353Douglas Gregor bool ZeroInitialization = false, 847428edafa9eb80e01dd40aab31d4166a787a741e1Chandler Carruth ConstructionKind ConstructKind = CK_Complete, 848428edafa9eb80e01dd40aab31d4166a787a741e1Chandler Carruth SourceRange ParenRange = SourceRange()); 8491eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 8501eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 851d94546a0a1deef7286c13e49b9584621ae81cc9aDouglas Gregor CXXConstructorDecl* getConstructor() const { return Constructor; } 85239da0b8145eaec7da7004f9b3645c5c9f4f63b1dDouglas Gregor void setConstructor(CXXConstructorDecl *C) { Constructor = C; } 853ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 85499a2e600f9e2e51d3ce10fb6f27191677ac65b2aDouglas Gregor SourceLocation getLocation() const { return Loc; } 85599a2e600f9e2e51d3ce10fb6f27191677ac65b2aDouglas Gregor void setLocation(SourceLocation Loc) { this->Loc = Loc; } 856ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 857d94546a0a1deef7286c13e49b9584621ae81cc9aDouglas Gregor /// \brief Whether this construction is elidable. 858d94546a0a1deef7286c13e49b9584621ae81cc9aDouglas Gregor bool isElidable() const { return Elidable; } 85939da0b8145eaec7da7004f9b3645c5c9f4f63b1dDouglas Gregor void setElidable(bool E) { Elidable = E; } 8607cc58b4c927fca539d43eaa58e00dca95946eb7cAbramo Bagnara 8617cc58b4c927fca539d43eaa58e00dca95946eb7cAbramo Bagnara /// \brief Whether the referred constructor was resolved from 8627cc58b4c927fca539d43eaa58e00dca95946eb7cAbramo Bagnara /// an overloaded set having size greater than 1. 8637cc58b4c927fca539d43eaa58e00dca95946eb7cAbramo Bagnara bool hadMultipleCandidates() const { return HadMultipleCandidates; } 8647cc58b4c927fca539d43eaa58e00dca95946eb7cAbramo Bagnara void setHadMultipleCandidates(bool V) { HadMultipleCandidates = V; } 8657cc58b4c927fca539d43eaa58e00dca95946eb7cAbramo Bagnara 86616006c901315fa12a108b4e571f187f4b676e426Douglas Gregor /// \brief Whether this construction first requires 86716006c901315fa12a108b4e571f187f4b676e426Douglas Gregor /// zero-initialization before the initializer is called. 86816006c901315fa12a108b4e571f187f4b676e426Douglas Gregor bool requiresZeroInitialization() const { return ZeroInitialization; } 86916006c901315fa12a108b4e571f187f4b676e426Douglas Gregor void setRequiresZeroInitialization(bool ZeroInit) { 87016006c901315fa12a108b4e571f187f4b676e426Douglas Gregor ZeroInitialization = ZeroInit; 87116006c901315fa12a108b4e571f187f4b676e426Douglas Gregor } 872ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 8739db7dbb918ca49f4ee6c181e4917e7b6ec547353Douglas Gregor /// \brief Determines whether this constructor is actually constructing 8749db7dbb918ca49f4ee6c181e4917e7b6ec547353Douglas Gregor /// a base class (rather than a complete object). 87524eb78e38aba55c507bc3c05c37035a9ab2defa7Anders Carlsson ConstructionKind getConstructionKind() const { 87624eb78e38aba55c507bc3c05c37035a9ab2defa7Anders Carlsson return (ConstructionKind)ConstructKind; 87772e96fd181b19b8d01144a685cda6e955584c7eaAnders Carlsson } 878ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie void setConstructionKind(ConstructionKind CK) { 87972e96fd181b19b8d01144a685cda6e955584c7eaAnders Carlsson ConstructKind = CK; 88072e96fd181b19b8d01144a685cda6e955584c7eaAnders Carlsson } 881ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 88215ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson typedef ExprIterator arg_iterator; 88315ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson typedef ConstExprIterator const_arg_iterator; 8841eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 88515ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson arg_iterator arg_begin() { return Args; } 88615ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson arg_iterator arg_end() { return Args + NumArgs; } 88715ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson const_arg_iterator arg_begin() const { return Args; } 88815ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson const_arg_iterator arg_end() const { return Args + NumArgs; } 88915ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson 890a88cfbfac9bbcbb9858f048d6d73a48711d8e93dDouglas Gregor Expr **getArgs() const { return reinterpret_cast<Expr **>(Args); } 89115ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson unsigned getNumArgs() const { return NumArgs; } 89215ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson 893bcb11d01c034f967503bd98f28bdf458c1ab8001Anders Carlsson /// getArg - Return the specified argument. 894bcb11d01c034f967503bd98f28bdf458c1ab8001Anders Carlsson Expr *getArg(unsigned Arg) { 895bcb11d01c034f967503bd98f28bdf458c1ab8001Anders Carlsson assert(Arg < NumArgs && "Arg access out of range!"); 896bcb11d01c034f967503bd98f28bdf458c1ab8001Anders Carlsson return cast<Expr>(Args[Arg]); 897bcb11d01c034f967503bd98f28bdf458c1ab8001Anders Carlsson } 898bcb11d01c034f967503bd98f28bdf458c1ab8001Anders Carlsson const Expr *getArg(unsigned Arg) const { 899bcb11d01c034f967503bd98f28bdf458c1ab8001Anders Carlsson assert(Arg < NumArgs && "Arg access out of range!"); 900bcb11d01c034f967503bd98f28bdf458c1ab8001Anders Carlsson return cast<Expr>(Args[Arg]); 901bcb11d01c034f967503bd98f28bdf458c1ab8001Anders Carlsson } 9021eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 9032eeed7bc4fd457ac57ff32ab3b02674588545f65Fariborz Jahanian /// setArg - Set the specified argument. 9042eeed7bc4fd457ac57ff32ab3b02674588545f65Fariborz Jahanian void setArg(unsigned Arg, Expr *ArgExpr) { 9052eeed7bc4fd457ac57ff32ab3b02674588545f65Fariborz Jahanian assert(Arg < NumArgs && "Arg access out of range!"); 9062eeed7bc4fd457ac57ff32ab3b02674588545f65Fariborz Jahanian Args[Arg] = ArgExpr; 9072eeed7bc4fd457ac57ff32ab3b02674588545f65Fariborz Jahanian } 9082eeed7bc4fd457ac57ff32ab3b02674588545f65Fariborz Jahanian 90963c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall SourceRange getSourceRange() const; 910428edafa9eb80e01dd40aab31d4166a787a741e1Chandler Carruth SourceRange getParenRange() const { return ParenRange; } 91115ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson 9121eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump static bool classof(const Stmt *T) { 913524fa13fd81e88533c7a1d4b1232c0de2c97dc7cAnders Carlsson return T->getStmtClass() == CXXConstructExprClass || 914524fa13fd81e88533c7a1d4b1232c0de2c97dc7cAnders Carlsson T->getStmtClass() == CXXTemporaryObjectExprClass; 91515ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson } 91615ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson static bool classof(const CXXConstructExpr *) { return true; } 9171eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 91815ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson // Iterators 91963c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall child_range children() { 92063c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall return child_range(&Args[0], &Args[0]+NumArgs); 92163c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall } 9226d00c1365dd3601f6d93bbda9162913c57ae788fArgyrios Kyrtzidis 92360adf4acf40b72227740bf966fb87eebddff3f37Sebastian Redl friend class ASTStmtReader; 92415ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson}; 92515ef2b5820f9daccc44b9e847163b705b6f5863bAnders Carlsson 92649badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// CXXFunctionalCastExpr - Represents an explicit C++ type conversion 92749badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// that uses "functional" notion (C++ [expr.type.conv]). Example: @c 92849badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// x = int(0.5); 92949badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregorclass CXXFunctionalCastExpr : public ExplicitCastExpr { 930987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis SourceLocation TyBeginLoc; 931987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis SourceLocation RParenLoc; 932f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall 933f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall CXXFunctionalCastExpr(QualType ty, ExprValueKind VK, 934f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall TypeSourceInfo *writtenTy, 9351eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump SourceLocation tyBeginLoc, CastKind kind, 936f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall Expr *castExpr, unsigned pathSize, 937ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie SourceLocation rParenLoc) 938f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall : ExplicitCastExpr(CXXFunctionalCastExprClass, ty, VK, kind, 939f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall castExpr, pathSize, writtenTy), 9400aebc81e02397a5987aaa8e8c7acbdb01a31d7c3Anders Carlsson TyBeginLoc(tyBeginLoc), RParenLoc(rParenLoc) {} 9410aebc81e02397a5987aaa8e8c7acbdb01a31d7c3Anders Carlsson 942f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall explicit CXXFunctionalCastExpr(EmptyShell Shell, unsigned PathSize) 943f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall : ExplicitCastExpr(CXXFunctionalCastExprClass, Shell, PathSize) { } 944f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall 945f871d0cc377a1367b519a6cce26be74607566ebaJohn McCallpublic: 946f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall static CXXFunctionalCastExpr *Create(ASTContext &Context, QualType T, 947f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall ExprValueKind VK, 948f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall TypeSourceInfo *Written, 949f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall SourceLocation TyBeginLoc, 950f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall CastKind Kind, Expr *Op, 951f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall const CXXCastPath *Path, 952f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall SourceLocation RPLoc); 953f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall static CXXFunctionalCastExpr *CreateEmpty(ASTContext &Context, 954f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall unsigned PathSize); 955ce757a7a1ee905f87551996a69da3e95e8afeeb7Sam Weinig 956987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis SourceLocation getTypeBeginLoc() const { return TyBeginLoc; } 957ce757a7a1ee905f87551996a69da3e95e8afeeb7Sam Weinig void setTypeBeginLoc(SourceLocation L) { TyBeginLoc = L; } 958987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis SourceLocation getRParenLoc() const { return RParenLoc; } 959ce757a7a1ee905f87551996a69da3e95e8afeeb7Sam Weinig void setRParenLoc(SourceLocation L) { RParenLoc = L; } 9601eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 96163c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall SourceRange getSourceRange() const { 962987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis return SourceRange(TyBeginLoc, RParenLoc); 963987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis } 9641eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump static bool classof(const Stmt *T) { 9651eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump return T->getStmtClass() == CXXFunctionalCastExprClass; 966987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis } 967987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis static bool classof(const CXXFunctionalCastExpr *) { return true; } 968987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis}; 969987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis 970506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// @brief Represents a C++ functional cast expression that builds a 971506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// temporary object. 972506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// 9731eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump/// This expression type represents a C++ "functional" cast 974506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// (C++[expr.type.conv]) with N != 1 arguments that invokes a 975ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie/// constructor to build a temporary object. With N == 1 arguments the 976ed8abf18329df67b0abcbb3a10458bd8c1d2a595Douglas Gregor/// functional cast expression will be represented by CXXFunctionalCastExpr. 977506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// Example: 978506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// @code 979506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// struct X { X(int, float); } 980506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// 981506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// X create_X() { 982506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// return X(1, 3.14f); // creates a CXXTemporaryObjectExpr 983506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// }; 984506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// @endcode 985524fa13fd81e88533c7a1d4b1232c0de2c97dc7cAnders Carlssonclass CXXTemporaryObjectExpr : public CXXConstructExpr { 986ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor TypeSourceInfo *Type; 987506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor 988506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregorpublic: 9891eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump CXXTemporaryObjectExpr(ASTContext &C, CXXConstructorDecl *Cons, 990ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor TypeSourceInfo *Type, 9911eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump Expr **Args,unsigned NumArgs, 992428edafa9eb80e01dd40aab31d4166a787a741e1Chandler Carruth SourceRange parenRange, 9937cc58b4c927fca539d43eaa58e00dca95946eb7cAbramo Bagnara bool HadMultipleCandidates, 9941c63b9c15d48cb8c833a4b2d6fd6c496c0766e88Douglas Gregor bool ZeroInitialization = false); 9956d00c1365dd3601f6d93bbda9162913c57ae788fArgyrios Kyrtzidis explicit CXXTemporaryObjectExpr(EmptyShell Empty) 996ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor : CXXConstructExpr(CXXTemporaryObjectExprClass, Empty), Type() { } 997506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor 998ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor TypeSourceInfo *getTypeSourceInfo() const { return Type; } 999ba49817c5b9f502602672861cf369fd0e53966e8Douglas Gregor 100063c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall SourceRange getSourceRange() const; 1001ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 10021eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump static bool classof(const Stmt *T) { 1003506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor return T->getStmtClass() == CXXTemporaryObjectExprClass; 1004506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor } 1005506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor static bool classof(const CXXTemporaryObjectExpr *) { return true; } 10066d00c1365dd3601f6d93bbda9162913c57ae788fArgyrios Kyrtzidis 100760adf4acf40b72227740bf966fb87eebddff3f37Sebastian Redl friend class ASTStmtReader; 1008506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor}; 1009506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor 1010ed8abf18329df67b0abcbb3a10458bd8c1d2a595Douglas Gregor/// CXXScalarValueInitExpr - [C++ 5.2.3p2] 1011506ae418eb171d072f2fb4f6bc46d258b52cbf97Douglas Gregor/// Expression "T()" which creates a value-initialized rvalue of type 1012ed8abf18329df67b0abcbb3a10458bd8c1d2a595Douglas Gregor/// T, which is a non-class type. 1013987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis/// 1014ed8abf18329df67b0abcbb3a10458bd8c1d2a595Douglas Gregorclass CXXScalarValueInitExpr : public Expr { 1015987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis SourceLocation RParenLoc; 1016ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor TypeSourceInfo *TypeInfo; 1017987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis 1018ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor friend class ASTStmtReader; 1019ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 1020987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidispublic: 1021ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie /// \brief Create an explicitly-written scalar-value initialization 1022ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor /// expression. 1023ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor CXXScalarValueInitExpr(QualType Type, 1024ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor TypeSourceInfo *TypeInfo, 1025ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor SourceLocation rParenLoc ) : 1026f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall Expr(CXXScalarValueInitExprClass, Type, VK_RValue, OK_Ordinary, 1027561f81243f665cf2001caadc45df505f826b72d6Douglas Gregor false, false, Type->isInstantiationDependentType(), false), 1028ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor RParenLoc(rParenLoc), TypeInfo(TypeInfo) {} 1029ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor 1030ed8abf18329df67b0abcbb3a10458bd8c1d2a595Douglas Gregor explicit CXXScalarValueInitExpr(EmptyShell Shell) 1031ed8abf18329df67b0abcbb3a10458bd8c1d2a595Douglas Gregor : Expr(CXXScalarValueInitExprClass, Shell) { } 10321eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1033ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor TypeSourceInfo *getTypeSourceInfo() const { 1034ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor return TypeInfo; 10354c67834407ca6ab344dcf44fc599ad4938cfa96dDouglas Gregor } 1036ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 1037ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor SourceLocation getRParenLoc() const { return RParenLoc; } 10384c67834407ca6ab344dcf44fc599ad4938cfa96dDouglas Gregor 103963c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall SourceRange getSourceRange() const; 10401eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 10411eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump static bool classof(const Stmt *T) { 1042ed8abf18329df67b0abcbb3a10458bd8c1d2a595Douglas Gregor return T->getStmtClass() == CXXScalarValueInitExprClass; 1043987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis } 1044ed8abf18329df67b0abcbb3a10458bd8c1d2a595Douglas Gregor static bool classof(const CXXScalarValueInitExpr *) { return true; } 10451eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1046987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis // Iterators 104763c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall child_range children() { return child_range(); } 1048987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis}; 1049987a14bf5883ef6e5d07f1c83eb6d41a8212a78cArgyrios Kyrtzidis 10504c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl/// CXXNewExpr - A new expression for memory allocation and constructor calls, 10514c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl/// e.g: "new CXXNewExpr(foo)". 10524c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redlclass CXXNewExpr : public Expr { 10534c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // Was the usage ::new, i.e. is the global new to be used? 10544c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl bool GlobalNew : 1; 10554c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // Is there an initializer? If not, built-ins are uninitialized, else they're 10564c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // value-initialized. 10574c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl bool Initializer : 1; 1058cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl // Do we allocate an array? If so, the first SubExpr is the size expression. 1059cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl bool Array : 1; 10606ec278d1a354517e20f13a877481453ee7940c78John McCall // If this is an array allocation, does the usual deallocation 10616ec278d1a354517e20f13a877481453ee7940c78John McCall // function for the allocated type want to know the allocated size? 10626ec278d1a354517e20f13a877481453ee7940c78John McCall bool UsualArrayDeleteWantsSize : 1; 10637cc58b4c927fca539d43eaa58e00dca95946eb7cAbramo Bagnara // Whether the referred constructor (if any) was resolved from an 10647cc58b4c927fca539d43eaa58e00dca95946eb7cAbramo Bagnara // overload set having size greater than 1. 10657cc58b4c927fca539d43eaa58e00dca95946eb7cAbramo Bagnara bool HadMultipleCandidates : 1; 10664c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // The number of placement new arguments. 10677cc58b4c927fca539d43eaa58e00dca95946eb7cAbramo Bagnara unsigned NumPlacementArgs : 13; 10684c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // The number of constructor arguments. This may be 1 even for non-class 10694c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // types; use the pseudo copy constructor. 1070cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl unsigned NumConstructorArgs : 14; 1071cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl // Contains an optional array size expression, any number of optional 1072cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl // placement arguments, and any number of optional constructor arguments, 1073cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl // in that order. 10744c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl Stmt **SubExprs; 10754c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // Points to the allocation function used. 10764c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl FunctionDecl *OperatorNew; 10774c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // Points to the deallocation function used in case of error. May be null. 10784c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl FunctionDecl *OperatorDelete; 10794c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // Points to the constructor used. Cannot be null if AllocType is a record; 10804c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // it would still point at the default constructor (even an implicit one). 10814c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // Must be null for all other types. 10824c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl CXXConstructorDecl *Constructor; 10834c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 10841bb2a93ab7b1499dda6f6b58865bd0dce1864228Douglas Gregor /// \brief The allocated type-source information, as written in the source. 10851bb2a93ab7b1499dda6f6b58865bd0dce1864228Douglas Gregor TypeSourceInfo *AllocatedTypeInfo; 1086ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 1087ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie /// \brief If the allocated type was expressed as a parenthesized type-id, 10884bd40318cbea15310a37343db46de96c4fcc15e6Douglas Gregor /// the source range covering the parenthesized type-id. 10894bd40318cbea15310a37343db46de96c4fcc15e6Douglas Gregor SourceRange TypeIdParens; 1090ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 10914c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl SourceLocation StartLoc; 10924c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl SourceLocation EndLoc; 1093428edafa9eb80e01dd40aab31d4166a787a741e1Chandler Carruth SourceLocation ConstructorLParen; 1094428edafa9eb80e01dd40aab31d4166a787a741e1Chandler Carruth SourceLocation ConstructorRParen; 10954c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 109660adf4acf40b72227740bf966fb87eebddff3f37Sebastian Redl friend class ASTStmtReader; 10974c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redlpublic: 1098ad7fe864862305c2f71e047cdf6706ef43aebdc0Ted Kremenek CXXNewExpr(ASTContext &C, bool globalNew, FunctionDecl *operatorNew, 10994bd40318cbea15310a37343db46de96c4fcc15e6Douglas Gregor Expr **placementArgs, unsigned numPlaceArgs, 11004bd40318cbea15310a37343db46de96c4fcc15e6Douglas Gregor SourceRange TypeIdParens, 1101ad7fe864862305c2f71e047cdf6706ef43aebdc0Ted Kremenek Expr *arraySize, CXXConstructorDecl *constructor, bool initializer, 11024c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl Expr **constructorArgs, unsigned numConsArgs, 11037cc58b4c927fca539d43eaa58e00dca95946eb7cAbramo Bagnara bool HadMultipleCandidates, 11046ec278d1a354517e20f13a877481453ee7940c78John McCall FunctionDecl *operatorDelete, bool usualArrayDeleteWantsSize, 11056ec278d1a354517e20f13a877481453ee7940c78John McCall QualType ty, TypeSourceInfo *AllocatedTypeInfo, 1106428edafa9eb80e01dd40aab31d4166a787a741e1Chandler Carruth SourceLocation startLoc, SourceLocation endLoc, 1107428edafa9eb80e01dd40aab31d4166a787a741e1Chandler Carruth SourceLocation constructorLParen, 1108428edafa9eb80e01dd40aab31d4166a787a741e1Chandler Carruth SourceLocation constructorRParen); 11095921863d8f24084797863b5df37842113bac4352Chris Lattner explicit CXXNewExpr(EmptyShell Shell) 11105921863d8f24084797863b5df37842113bac4352Chris Lattner : Expr(CXXNewExprClass, Shell), SubExprs(0) { } 11115921863d8f24084797863b5df37842113bac4352Chris Lattner 11125921863d8f24084797863b5df37842113bac4352Chris Lattner void AllocateArgsArray(ASTContext &C, bool isArray, unsigned numPlaceArgs, 11135921863d8f24084797863b5df37842113bac4352Chris Lattner unsigned numConsArgs); 1114ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 1115cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl QualType getAllocatedType() const { 1116cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl assert(getType()->isPointerType()); 11176217b80b7a1379b74cced1c076338262c3c980b3Ted Kremenek return getType()->getAs<PointerType>()->getPointeeType(); 1118cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl } 11194c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 11201bb2a93ab7b1499dda6f6b58865bd0dce1864228Douglas Gregor TypeSourceInfo *getAllocatedTypeSourceInfo() const { 11211bb2a93ab7b1499dda6f6b58865bd0dce1864228Douglas Gregor return AllocatedTypeInfo; 11221bb2a93ab7b1499dda6f6b58865bd0dce1864228Douglas Gregor } 1123c2f3e7f42c8bf9e8d4393a6e8c4762dafc4f28ddJohn McCall 1124c2f3e7f42c8bf9e8d4393a6e8c4762dafc4f28ddJohn McCall /// \brief True if the allocation result needs to be null-checked. 1125c2f3e7f42c8bf9e8d4393a6e8c4762dafc4f28ddJohn McCall /// C++0x [expr.new]p13: 1126c2f3e7f42c8bf9e8d4393a6e8c4762dafc4f28ddJohn McCall /// If the allocation function returns null, initialization shall 1127c2f3e7f42c8bf9e8d4393a6e8c4762dafc4f28ddJohn McCall /// not be done, the deallocation function shall not be called, 1128c2f3e7f42c8bf9e8d4393a6e8c4762dafc4f28ddJohn McCall /// and the value of the new-expression shall be null. 1129c2f3e7f42c8bf9e8d4393a6e8c4762dafc4f28ddJohn McCall /// An allocation function is not allowed to return null unless it 1130c2f3e7f42c8bf9e8d4393a6e8c4762dafc4f28ddJohn McCall /// has a non-throwing exception-specification. The '03 rule is 1131c2f3e7f42c8bf9e8d4393a6e8c4762dafc4f28ddJohn McCall /// identical except that the definition of a non-throwing 1132c2f3e7f42c8bf9e8d4393a6e8c4762dafc4f28ddJohn McCall /// exception specification is just "is it throw()?". 11338026f6d82f7fa544bc0453714fe94bca62a1196eSebastian Redl bool shouldNullCheckAllocation(ASTContext &Ctx) const; 1134ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 11354c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl FunctionDecl *getOperatorNew() const { return OperatorNew; } 11365921863d8f24084797863b5df37842113bac4352Chris Lattner void setOperatorNew(FunctionDecl *D) { OperatorNew = D; } 11374c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl FunctionDecl *getOperatorDelete() const { return OperatorDelete; } 11385921863d8f24084797863b5df37842113bac4352Chris Lattner void setOperatorDelete(FunctionDecl *D) { OperatorDelete = D; } 11394c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl CXXConstructorDecl *getConstructor() const { return Constructor; } 11405921863d8f24084797863b5df37842113bac4352Chris Lattner void setConstructor(CXXConstructorDecl *D) { Constructor = D; } 11414c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 1142cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl bool isArray() const { return Array; } 1143cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl Expr *getArraySize() { 1144cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl return Array ? cast<Expr>(SubExprs[0]) : 0; 1145cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl } 1146cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl const Expr *getArraySize() const { 1147cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl return Array ? cast<Expr>(SubExprs[0]) : 0; 1148cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl } 1149cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl 11504c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl unsigned getNumPlacementArgs() const { return NumPlacementArgs; } 1151ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie Expr **getPlacementArgs() { 1152ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie return reinterpret_cast<Expr **>(SubExprs + Array); 1153aa165f8458b51c546bebff947343e1a36f3594cbDouglas Gregor } 1154ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 11554c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl Expr *getPlacementArg(unsigned i) { 11564c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl assert(i < NumPlacementArgs && "Index out of range"); 1157cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl return cast<Expr>(SubExprs[Array + i]); 11584c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 11594c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl const Expr *getPlacementArg(unsigned i) const { 11604c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl assert(i < NumPlacementArgs && "Index out of range"); 1161cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl return cast<Expr>(SubExprs[Array + i]); 11624c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 11634c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 11644bd40318cbea15310a37343db46de96c4fcc15e6Douglas Gregor bool isParenTypeId() const { return TypeIdParens.isValid(); } 11654bd40318cbea15310a37343db46de96c4fcc15e6Douglas Gregor SourceRange getTypeIdParens() const { return TypeIdParens; } 11664bd40318cbea15310a37343db46de96c4fcc15e6Douglas Gregor 11674c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl bool isGlobalNew() const { return GlobalNew; } 11684c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl bool hasInitializer() const { return Initializer; } 11696ec278d1a354517e20f13a877481453ee7940c78John McCall 11706ec278d1a354517e20f13a877481453ee7940c78John McCall /// Answers whether the usual array deallocation function for the 11716ec278d1a354517e20f13a877481453ee7940c78John McCall /// allocated type expects the size of the allocation as a 11726ec278d1a354517e20f13a877481453ee7940c78John McCall /// parameter. 11736ec278d1a354517e20f13a877481453ee7940c78John McCall bool doesUsualArrayDeleteWantSize() const { 11746ec278d1a354517e20f13a877481453ee7940c78John McCall return UsualArrayDeleteWantsSize; 11756ec278d1a354517e20f13a877481453ee7940c78John McCall } 11764c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 11774c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl unsigned getNumConstructorArgs() const { return NumConstructorArgs; } 1178ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 1179aa165f8458b51c546bebff947343e1a36f3594cbDouglas Gregor Expr **getConstructorArgs() { 1180aa165f8458b51c546bebff947343e1a36f3594cbDouglas Gregor return reinterpret_cast<Expr **>(SubExprs + Array + NumPlacementArgs); 1181aa165f8458b51c546bebff947343e1a36f3594cbDouglas Gregor } 1182ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 11834c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl Expr *getConstructorArg(unsigned i) { 11844c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl assert(i < NumConstructorArgs && "Index out of range"); 1185cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl return cast<Expr>(SubExprs[Array + NumPlacementArgs + i]); 11864c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 11874c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl const Expr *getConstructorArg(unsigned i) const { 11884c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl assert(i < NumConstructorArgs && "Index out of range"); 1189cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl return cast<Expr>(SubExprs[Array + NumPlacementArgs + i]); 11904c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 11914c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 11927cc58b4c927fca539d43eaa58e00dca95946eb7cAbramo Bagnara /// \brief Whether the new expression refers a constructor that was 11937cc58b4c927fca539d43eaa58e00dca95946eb7cAbramo Bagnara /// resolved from an overloaded set having size greater than 1. 11947cc58b4c927fca539d43eaa58e00dca95946eb7cAbramo Bagnara bool hadMultipleCandidates() const { return HadMultipleCandidates; } 11957cc58b4c927fca539d43eaa58e00dca95946eb7cAbramo Bagnara void setHadMultipleCandidates(bool V) { HadMultipleCandidates = V; } 11967cc58b4c927fca539d43eaa58e00dca95946eb7cAbramo Bagnara 11974c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl typedef ExprIterator arg_iterator; 11984c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl typedef ConstExprIterator const_arg_iterator; 11994c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 12004c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl arg_iterator placement_arg_begin() { 1201cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl return SubExprs + Array; 12024c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 12034c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl arg_iterator placement_arg_end() { 1204cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl return SubExprs + Array + getNumPlacementArgs(); 12054c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 12064c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl const_arg_iterator placement_arg_begin() const { 1207cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl return SubExprs + Array; 12084c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 12094c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl const_arg_iterator placement_arg_end() const { 1210cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl return SubExprs + Array + getNumPlacementArgs(); 12114c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 12124c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 12134c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl arg_iterator constructor_arg_begin() { 1214cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl return SubExprs + Array + getNumPlacementArgs(); 12154c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 12164c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl arg_iterator constructor_arg_end() { 1217cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl return SubExprs + Array + getNumPlacementArgs() + getNumConstructorArgs(); 12184c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 12194c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl const_arg_iterator constructor_arg_begin() const { 1220cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl return SubExprs + Array + getNumPlacementArgs(); 12214c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 12224c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl const_arg_iterator constructor_arg_end() const { 1223cee63fbf0e64ac526582312bf8cf33263fc5c16eSebastian Redl return SubExprs + Array + getNumPlacementArgs() + getNumConstructorArgs(); 12244c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 1225ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 12265921863d8f24084797863b5df37842113bac4352Chris Lattner typedef Stmt **raw_arg_iterator; 12275921863d8f24084797863b5df37842113bac4352Chris Lattner raw_arg_iterator raw_arg_begin() { return SubExprs; } 12285921863d8f24084797863b5df37842113bac4352Chris Lattner raw_arg_iterator raw_arg_end() { 12295921863d8f24084797863b5df37842113bac4352Chris Lattner return SubExprs + Array + getNumPlacementArgs() + getNumConstructorArgs(); 12305921863d8f24084797863b5df37842113bac4352Chris Lattner } 12315921863d8f24084797863b5df37842113bac4352Chris Lattner const_arg_iterator raw_arg_begin() const { return SubExprs; } 12325921863d8f24084797863b5df37842113bac4352Chris Lattner const_arg_iterator raw_arg_end() const { return constructor_arg_end(); } 12334c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 12345921863d8f24084797863b5df37842113bac4352Chris Lattner SourceLocation getStartLoc() const { return StartLoc; } 12355921863d8f24084797863b5df37842113bac4352Chris Lattner SourceLocation getEndLoc() const { return EndLoc; } 1236428edafa9eb80e01dd40aab31d4166a787a741e1Chandler Carruth 1237428edafa9eb80e01dd40aab31d4166a787a741e1Chandler Carruth SourceLocation getConstructorLParen() const { return ConstructorLParen; } 1238428edafa9eb80e01dd40aab31d4166a787a741e1Chandler Carruth SourceLocation getConstructorRParen() const { return ConstructorRParen; } 1239428edafa9eb80e01dd40aab31d4166a787a741e1Chandler Carruth 124063c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall SourceRange getSourceRange() const { 12414c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl return SourceRange(StartLoc, EndLoc); 12424c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 12434c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 12444c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl static bool classof(const Stmt *T) { 12454c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl return T->getStmtClass() == CXXNewExprClass; 12464c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 12474c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl static bool classof(const CXXNewExpr *) { return true; } 12484c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 12494c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // Iterators 125063c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall child_range children() { 125163c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall return child_range(&SubExprs[0], 125263c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall &SubExprs[0] + Array + getNumPlacementArgs() 125363c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall + getNumConstructorArgs()); 125463c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall } 12554c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl}; 12564c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 12574c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl/// CXXDeleteExpr - A delete expression for memory deallocation and destructor 12584c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl/// calls, e.g. "delete[] pArray". 12594c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redlclass CXXDeleteExpr : public Expr { 12604c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // Is this a forced global delete, i.e. "::delete"? 12614c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl bool GlobalDelete : 1; 12624c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // Is this the array form of delete, i.e. "delete[]"? 12634c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl bool ArrayForm : 1; 12644076dacf1497fb95cb298b9d964fbdbdaf9bde6cArgyrios Kyrtzidis // ArrayFormAsWritten can be different from ArrayForm if 'delete' is applied 12654076dacf1497fb95cb298b9d964fbdbdaf9bde6cArgyrios Kyrtzidis // to pointer-to-array type (ArrayFormAsWritten will be false while ArrayForm 12664076dacf1497fb95cb298b9d964fbdbdaf9bde6cArgyrios Kyrtzidis // will be true). 12674076dacf1497fb95cb298b9d964fbdbdaf9bde6cArgyrios Kyrtzidis bool ArrayFormAsWritten : 1; 12686ec278d1a354517e20f13a877481453ee7940c78John McCall // Does the usual deallocation function for the element type require 12696ec278d1a354517e20f13a877481453ee7940c78John McCall // a size_t argument? 12706ec278d1a354517e20f13a877481453ee7940c78John McCall bool UsualArrayDeleteWantsSize : 1; 12714c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // Points to the operator delete overload that is used. Could be a member. 12724c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl FunctionDecl *OperatorDelete; 12734c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // The pointer expression to be deleted. 12744c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl Stmt *Argument; 12754c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // Location of the expression. 12764c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl SourceLocation Loc; 12774c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redlpublic: 12784c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl CXXDeleteExpr(QualType ty, bool globalDelete, bool arrayForm, 12796ec278d1a354517e20f13a877481453ee7940c78John McCall bool arrayFormAsWritten, bool usualArrayDeleteWantsSize, 12806ec278d1a354517e20f13a877481453ee7940c78John McCall FunctionDecl *operatorDelete, Expr *arg, SourceLocation loc) 1281bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor : Expr(CXXDeleteExprClass, ty, VK_RValue, OK_Ordinary, false, false, 1282561f81243f665cf2001caadc45df505f826b72d6Douglas Gregor arg->isInstantiationDependent(), 1283bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor arg->containsUnexpandedParameterPack()), 1284f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall GlobalDelete(globalDelete), 12854076dacf1497fb95cb298b9d964fbdbdaf9bde6cArgyrios Kyrtzidis ArrayForm(arrayForm), ArrayFormAsWritten(arrayFormAsWritten), 12866ec278d1a354517e20f13a877481453ee7940c78John McCall UsualArrayDeleteWantsSize(usualArrayDeleteWantsSize), 12874076dacf1497fb95cb298b9d964fbdbdaf9bde6cArgyrios Kyrtzidis OperatorDelete(operatorDelete), Argument(arg), Loc(loc) { } 128895fc98ce95d4faa4f1bb2783384150530404ea6fArgyrios Kyrtzidis explicit CXXDeleteExpr(EmptyShell Shell) 128995fc98ce95d4faa4f1bb2783384150530404ea6fArgyrios Kyrtzidis : Expr(CXXDeleteExprClass, Shell), OperatorDelete(0), Argument(0) { } 12904c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 12914c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl bool isGlobalDelete() const { return GlobalDelete; } 12924c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl bool isArrayForm() const { return ArrayForm; } 12934076dacf1497fb95cb298b9d964fbdbdaf9bde6cArgyrios Kyrtzidis bool isArrayFormAsWritten() const { return ArrayFormAsWritten; } 12944c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 12956ec278d1a354517e20f13a877481453ee7940c78John McCall /// Answers whether the usual array deallocation function for the 12966ec278d1a354517e20f13a877481453ee7940c78John McCall /// allocated type expects the size of the allocation as a 12976ec278d1a354517e20f13a877481453ee7940c78John McCall /// parameter. This can be true even if the actual deallocation 12986ec278d1a354517e20f13a877481453ee7940c78John McCall /// function that we're using doesn't want a size. 12996ec278d1a354517e20f13a877481453ee7940c78John McCall bool doesUsualArrayDeleteWantSize() const { 13006ec278d1a354517e20f13a877481453ee7940c78John McCall return UsualArrayDeleteWantsSize; 13016ec278d1a354517e20f13a877481453ee7940c78John McCall } 13026ec278d1a354517e20f13a877481453ee7940c78John McCall 13034c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl FunctionDecl *getOperatorDelete() const { return OperatorDelete; } 13044c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 13054c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl Expr *getArgument() { return cast<Expr>(Argument); } 13064c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl const Expr *getArgument() const { return cast<Expr>(Argument); } 13074c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 1308a437ad3ec5b407ede394d74e6f9f463fa3657dbeCraig Silverstein /// \brief Retrieve the type being destroyed. If the type being 1309a437ad3ec5b407ede394d74e6f9f463fa3657dbeCraig Silverstein /// destroyed is a dependent type which may or may not be a pointer, 1310a437ad3ec5b407ede394d74e6f9f463fa3657dbeCraig Silverstein /// return an invalid type. 13115833b0b831d6afae2885e6af420e2bda639652e6Douglas Gregor QualType getDestroyedType() const; 1312ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 131363c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall SourceRange getSourceRange() const { 13144c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl return SourceRange(Loc, Argument->getLocEnd()); 13154c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 13164c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 13174c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl static bool classof(const Stmt *T) { 13184c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl return T->getStmtClass() == CXXDeleteExprClass; 13194c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl } 13204c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl static bool classof(const CXXDeleteExpr *) { return true; } 13214c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 13224c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl // Iterators 132363c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall child_range children() { return child_range(&Argument, &Argument+1); } 1324f1b8911d35bb2830a13267581d3cbde4b6b85db6Argyrios Kyrtzidis 1325f1b8911d35bb2830a13267581d3cbde4b6b85db6Argyrios Kyrtzidis friend class ASTStmtReader; 13264c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl}; 13274c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl 1328ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie/// \brief Structure used to store the type being destroyed by a 1329a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor/// pseudo-destructor expression. 1330a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregorclass PseudoDestructorTypeStorage { 1331ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie /// \brief Either the type source information or the name of the type, if 1332a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor /// it couldn't be resolved due to type-dependence. 1333a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor llvm::PointerUnion<TypeSourceInfo *, IdentifierInfo *> Type; 1334ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 1335a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor /// \brief The starting source location of the pseudo-destructor type. 1336a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor SourceLocation Location; 1337ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 1338a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregorpublic: 1339a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor PseudoDestructorTypeStorage() { } 1340ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 1341a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor PseudoDestructorTypeStorage(IdentifierInfo *II, SourceLocation Loc) 1342a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor : Type(II), Location(Loc) { } 1343ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 1344a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor PseudoDestructorTypeStorage(TypeSourceInfo *Info); 1345ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 1346ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie TypeSourceInfo *getTypeSourceInfo() const { 1347ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie return Type.dyn_cast<TypeSourceInfo *>(); 1348a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor } 1349ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 1350a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor IdentifierInfo *getIdentifier() const { 1351a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor return Type.dyn_cast<IdentifierInfo *>(); 1352a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor } 1353ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 1354a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor SourceLocation getLocation() const { return Location; } 1355a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor}; 1356ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 1357a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor/// \brief Represents a C++ pseudo-destructor (C++ [expr.pseudo]). 1358a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor/// 1359e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor/// A pseudo-destructor is an expression that looks like a member access to a 1360ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie/// destructor of a scalar type, except that scalar types don't have 1361e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor/// destructors. For example: 1362e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor/// 1363e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor/// \code 1364e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor/// typedef int T; 1365e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor/// void f(int *p) { 1366e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor/// p->T::~T(); 1367e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor/// } 1368e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor/// \endcode 1369a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor/// 1370e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor/// Pseudo-destructors typically occur when instantiating templates such as: 1371ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie/// 1372a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor/// \code 13731eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump/// template<typename T> 1374a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor/// void destroy(T* ptr) { 1375e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor/// ptr->T::~T(); 1376a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor/// } 1377a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor/// \endcode 1378a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor/// 1379e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor/// for scalar types. A pseudo-destructor expression has no run-time semantics 1380e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor/// beyond evaluating the base expression. 1381a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregorclass CXXPseudoDestructorExpr : public Expr { 1382a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor /// \brief The base expression (that is being destroyed). 1383a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor Stmt *Base; 13841eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1385a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor /// \brief Whether the operator was an arrow ('->'); otherwise, it was a 1386a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor /// period ('.'). 1387a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor bool IsArrow : 1; 13881eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1389a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor /// \brief The location of the '.' or '->' operator. 1390a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor SourceLocation OperatorLoc; 1391ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 1392a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor /// \brief The nested-name-specifier that follows the operator, if present. 1393f3db29fff6a583ecda823cf909ab7737d8d30129Douglas Gregor NestedNameSpecifierLoc QualifierLoc; 13941eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1395e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor /// \brief The type that precedes the '::' in a qualified pseudo-destructor 1396e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor /// expression. 1397e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor TypeSourceInfo *ScopeType; 1398ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 1399ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie /// \brief The location of the '::' in a qualified pseudo-destructor 1400e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor /// expression. 1401e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor SourceLocation ColonColonLoc; 1402ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 1403fce46ee68f779e239826e69e45d01d4c8e5323caDouglas Gregor /// \brief The location of the '~'. 1404fce46ee68f779e239826e69e45d01d4c8e5323caDouglas Gregor SourceLocation TildeLoc; 1405ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 1406ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie /// \brief The type being destroyed, or its name if we were unable to 1407a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor /// resolve the name. 1408a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor PseudoDestructorTypeStorage DestroyedType; 14091eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1410f3db29fff6a583ecda823cf909ab7737d8d30129Douglas Gregor friend class ASTStmtReader; 1411ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 1412a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregorpublic: 1413a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor CXXPseudoDestructorExpr(ASTContext &Context, 1414a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor Expr *Base, bool isArrow, SourceLocation OperatorLoc, 1415f3db29fff6a583ecda823cf909ab7737d8d30129Douglas Gregor NestedNameSpecifierLoc QualifierLoc, 1416e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor TypeSourceInfo *ScopeType, 1417e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor SourceLocation ColonColonLoc, 1418fce46ee68f779e239826e69e45d01d4c8e5323caDouglas Gregor SourceLocation TildeLoc, 1419e23cf437fe76b1ed02d63c3f61b456fd48a915f5John McCall PseudoDestructorTypeStorage DestroyedType); 14201eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1421de4bd18bb45a1db68996cfb949db3015fc25d10dArgyrios Kyrtzidis explicit CXXPseudoDestructorExpr(EmptyShell Shell) 1422de4bd18bb45a1db68996cfb949db3015fc25d10dArgyrios Kyrtzidis : Expr(CXXPseudoDestructorExprClass, Shell), 1423f3db29fff6a583ecda823cf909ab7737d8d30129Douglas Gregor Base(0), IsArrow(false), QualifierLoc(), ScopeType(0) { } 1424de4bd18bb45a1db68996cfb949db3015fc25d10dArgyrios Kyrtzidis 1425a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor Expr *getBase() const { return cast<Expr>(Base); } 14261eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 14271eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump /// \brief Determines whether this member expression actually had 1428a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor /// a C++ nested-name-specifier prior to the name of the member, e.g., 1429a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor /// x->Base::foo. 1430f3db29fff6a583ecda823cf909ab7737d8d30129Douglas Gregor bool hasQualifier() const { return QualifierLoc; } 14311eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1432f3db29fff6a583ecda823cf909ab7737d8d30129Douglas Gregor /// \brief Retrieves the nested-name-specifier that qualifies the type name, 1433f3db29fff6a583ecda823cf909ab7737d8d30129Douglas Gregor /// with source-location information. 1434f3db29fff6a583ecda823cf909ab7737d8d30129Douglas Gregor NestedNameSpecifierLoc getQualifierLoc() const { return QualifierLoc; } 1435ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 14361eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump /// \brief If the member name was qualified, retrieves the 1437a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor /// nested-name-specifier that precedes the member name. Otherwise, returns 1438a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor /// NULL. 1439ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie NestedNameSpecifier *getQualifier() const { 1440ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie return QualifierLoc.getNestedNameSpecifier(); 1441f3db29fff6a583ecda823cf909ab7737d8d30129Douglas Gregor } 14421eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1443a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor /// \brief Determine whether this pseudo-destructor expression was written 1444a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor /// using an '->' (otherwise, it used a '.'). 1445a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor bool isArrow() const { return IsArrow; } 1446a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor 1447a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor /// \brief Retrieve the location of the '.' or '->' operator. 1448a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor SourceLocation getOperatorLoc() const { return OperatorLoc; } 14491eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1450ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie /// \brief Retrieve the scope type in a qualified pseudo-destructor 1451e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor /// expression. 1452e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor /// 1453e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor /// Pseudo-destructor expressions can have extra qualification within them 1454e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor /// that is not part of the nested-name-specifier, e.g., \c p->T::~T(). 1455e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor /// Here, if the object type of the expression is (or may be) a scalar type, 1456ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie /// \p T may also be a scalar type and, therefore, cannot be part of a 1457e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor /// nested-name-specifier. It is stored as the "scope type" of the pseudo- 1458e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor /// destructor expression. 145926d4ac97fb514bb60c2536eae6f203dc569159d9Douglas Gregor TypeSourceInfo *getScopeTypeInfo() const { return ScopeType; } 1460ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 1461e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor /// \brief Retrieve the location of the '::' in a qualified pseudo-destructor 1462e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor /// expression. 1463e0601ea1220348957dacec5f3dd0707837365290Douglas Gregor SourceLocation getColonColonLoc() const { return ColonColonLoc; } 1464ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 1465fce46ee68f779e239826e69e45d01d4c8e5323caDouglas Gregor /// \brief Retrieve the location of the '~'. 1466fce46ee68f779e239826e69e45d01d4c8e5323caDouglas Gregor SourceLocation getTildeLoc() const { return TildeLoc; } 1467ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 146826d4ac97fb514bb60c2536eae6f203dc569159d9Douglas Gregor /// \brief Retrieve the source location information for the type 146926d4ac97fb514bb60c2536eae6f203dc569159d9Douglas Gregor /// being destroyed. 1470a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor /// 1471ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie /// This type-source information is available for non-dependent 1472a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor /// pseudo-destructor expressions and some dependent pseudo-destructor 1473a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor /// expressions. Returns NULL if we only have the identifier for a 1474a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor /// dependent pseudo-destructor expression. 1475ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie TypeSourceInfo *getDestroyedTypeInfo() const { 1476ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie return DestroyedType.getTypeSourceInfo(); 1477a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor } 1478ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 1479a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor /// \brief In a dependent pseudo-destructor expression for which we do not 1480a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor /// have full type information on the destroyed type, provides the name 1481a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor /// of the destroyed type. 1482a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor IdentifierInfo *getDestroyedTypeIdentifier() const { 1483a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor return DestroyedType.getIdentifier(); 1484a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor } 1485ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 1486a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor /// \brief Retrieve the type being destroyed. 1487a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor QualType getDestroyedType() const; 1488ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 1489a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor /// \brief Retrieve the starting location of the type being destroyed. 1490ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie SourceLocation getDestroyedTypeLoc() const { 1491ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie return DestroyedType.getLocation(); 1492a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor } 14931eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1494de4bd18bb45a1db68996cfb949db3015fc25d10dArgyrios Kyrtzidis /// \brief Set the name of destroyed type for a dependent pseudo-destructor 1495de4bd18bb45a1db68996cfb949db3015fc25d10dArgyrios Kyrtzidis /// expression. 1496de4bd18bb45a1db68996cfb949db3015fc25d10dArgyrios Kyrtzidis void setDestroyedType(IdentifierInfo *II, SourceLocation Loc) { 1497de4bd18bb45a1db68996cfb949db3015fc25d10dArgyrios Kyrtzidis DestroyedType = PseudoDestructorTypeStorage(II, Loc); 1498de4bd18bb45a1db68996cfb949db3015fc25d10dArgyrios Kyrtzidis } 1499de4bd18bb45a1db68996cfb949db3015fc25d10dArgyrios Kyrtzidis 1500de4bd18bb45a1db68996cfb949db3015fc25d10dArgyrios Kyrtzidis /// \brief Set the destroyed type. 1501de4bd18bb45a1db68996cfb949db3015fc25d10dArgyrios Kyrtzidis void setDestroyedType(TypeSourceInfo *Info) { 1502de4bd18bb45a1db68996cfb949db3015fc25d10dArgyrios Kyrtzidis DestroyedType = PseudoDestructorTypeStorage(Info); 1503de4bd18bb45a1db68996cfb949db3015fc25d10dArgyrios Kyrtzidis } 1504de4bd18bb45a1db68996cfb949db3015fc25d10dArgyrios Kyrtzidis 150563c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall SourceRange getSourceRange() const; 15061eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 15071eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump static bool classof(const Stmt *T) { 1508a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor return T->getStmtClass() == CXXPseudoDestructorExprClass; 1509a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor } 1510a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor static bool classof(const CXXPseudoDestructorExpr *) { return true; } 15111eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1512a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor // Iterators 151363c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall child_range children() { return child_range(&Base, &Base + 1); } 1514a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor}; 15151eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 151664b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl/// UnaryTypeTraitExpr - A GCC or MS unary type trait, as used in the 151764b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl/// implementation of TR1/C++0x type trait templates. 151864b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl/// Example: 151964b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl/// __is_pod(int) == true 152064b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl/// __is_enum(std::string) == false 152164b45f7e0d3167f040841ac2920aead7f080730dSebastian Redlclass UnaryTypeTraitExpr : public Expr { 15220dfd848fa4c9664852ba8c929a8bd3fce93ddca2Sebastian Redl /// UTT - The trait. A UnaryTypeTrait enum in MSVC compat unsigned. 15230dfd848fa4c9664852ba8c929a8bd3fce93ddca2Sebastian Redl unsigned UTT : 31; 15240dfd848fa4c9664852ba8c929a8bd3fce93ddca2Sebastian Redl /// The value of the type trait. Unspecified if dependent. 15250dfd848fa4c9664852ba8c929a8bd3fce93ddca2Sebastian Redl bool Value : 1; 152664b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl 152764b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl /// Loc - The location of the type trait keyword. 152864b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl SourceLocation Loc; 152964b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl 153064b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl /// RParen - The location of the closing paren. 153164b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl SourceLocation RParen; 153264b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl 15330dfd848fa4c9664852ba8c929a8bd3fce93ddca2Sebastian Redl /// The type being queried. 15343d37c0ada0e46b87be0a10e8d52d990a97d3907aDouglas Gregor TypeSourceInfo *QueriedType; 153564b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl 153664b45f7e0d3167f040841ac2920aead7f080730dSebastian Redlpublic: 1537ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie UnaryTypeTraitExpr(SourceLocation loc, UnaryTypeTrait utt, 15380dfd848fa4c9664852ba8c929a8bd3fce93ddca2Sebastian Redl TypeSourceInfo *queried, bool value, 153964b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl SourceLocation rparen, QualType ty) 1540f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall : Expr(UnaryTypeTraitExprClass, ty, VK_RValue, OK_Ordinary, 1541bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor false, queried->getType()->isDependentType(), 1542561f81243f665cf2001caadc45df505f826b72d6Douglas Gregor queried->getType()->isInstantiationDependentType(), 1543bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor queried->getType()->containsUnexpandedParameterPack()), 15440dfd848fa4c9664852ba8c929a8bd3fce93ddca2Sebastian Redl UTT(utt), Value(value), Loc(loc), RParen(rparen), QueriedType(queried) { } 154564b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl 15466d00c1365dd3601f6d93bbda9162913c57ae788fArgyrios Kyrtzidis explicit UnaryTypeTraitExpr(EmptyShell Empty) 15470dfd848fa4c9664852ba8c929a8bd3fce93ddca2Sebastian Redl : Expr(UnaryTypeTraitExprClass, Empty), UTT(0), Value(false), 15483d37c0ada0e46b87be0a10e8d52d990a97d3907aDouglas Gregor QueriedType() { } 15496d00c1365dd3601f6d93bbda9162913c57ae788fArgyrios Kyrtzidis 155063c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall SourceRange getSourceRange() const { return SourceRange(Loc, RParen);} 155164b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl 15520dfd848fa4c9664852ba8c929a8bd3fce93ddca2Sebastian Redl UnaryTypeTrait getTrait() const { return static_cast<UnaryTypeTrait>(UTT); } 155364b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl 15543d37c0ada0e46b87be0a10e8d52d990a97d3907aDouglas Gregor QualType getQueriedType() const { return QueriedType->getType(); } 155564b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl 15563d37c0ada0e46b87be0a10e8d52d990a97d3907aDouglas Gregor TypeSourceInfo *getQueriedTypeSourceInfo() const { return QueriedType; } 1557ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 15580dfd848fa4c9664852ba8c929a8bd3fce93ddca2Sebastian Redl bool getValue() const { return Value; } 155964b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl 156064b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl static bool classof(const Stmt *T) { 156164b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl return T->getStmtClass() == UnaryTypeTraitExprClass; 156264b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl } 156364b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl static bool classof(const UnaryTypeTraitExpr *) { return true; } 156464b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl 156564b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl // Iterators 156663c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall child_range children() { return child_range(); } 15676d00c1365dd3601f6d93bbda9162913c57ae788fArgyrios Kyrtzidis 156860adf4acf40b72227740bf966fb87eebddff3f37Sebastian Redl friend class ASTStmtReader; 156964b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl}; 157064b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl 15716ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet/// BinaryTypeTraitExpr - A GCC or MS binary type trait, as used in the 15726ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet/// implementation of TR1/C++0x type trait templates. 15736ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet/// Example: 15746ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet/// __is_base_of(Base, Derived) == true 15756ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichetclass BinaryTypeTraitExpr : public Expr { 15766ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet /// BTT - The trait. A BinaryTypeTrait enum in MSVC compat unsigned. 15776ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet unsigned BTT : 8; 15786ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet 15796ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet /// The value of the type trait. Unspecified if dependent. 15806ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet bool Value : 1; 15816ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet 15826ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet /// Loc - The location of the type trait keyword. 15836ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet SourceLocation Loc; 15846ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet 15856ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet /// RParen - The location of the closing paren. 15866ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet SourceLocation RParen; 15876ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet 15886ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet /// The lhs type being queried. 15896ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet TypeSourceInfo *LhsType; 15906ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet 15916ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet /// The rhs type being queried. 15926ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet TypeSourceInfo *RhsType; 15936ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet 15946ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichetpublic: 1595ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie BinaryTypeTraitExpr(SourceLocation loc, BinaryTypeTrait btt, 1596ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie TypeSourceInfo *lhsType, TypeSourceInfo *rhsType, 15976ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet bool value, SourceLocation rparen, QualType ty) 1598ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie : Expr(BinaryTypeTraitExprClass, ty, VK_RValue, OK_Ordinary, false, 15996ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet lhsType->getType()->isDependentType() || 1600bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor rhsType->getType()->isDependentType(), 1601561f81243f665cf2001caadc45df505f826b72d6Douglas Gregor (lhsType->getType()->isInstantiationDependentType() || 1602561f81243f665cf2001caadc45df505f826b72d6Douglas Gregor rhsType->getType()->isInstantiationDependentType()), 1603bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor (lhsType->getType()->containsUnexpandedParameterPack() || 1604bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor rhsType->getType()->containsUnexpandedParameterPack())), 16056ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet BTT(btt), Value(value), Loc(loc), RParen(rparen), 16066ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet LhsType(lhsType), RhsType(rhsType) { } 16076ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet 16086ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet 16096ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet explicit BinaryTypeTraitExpr(EmptyShell Empty) 16106ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet : Expr(BinaryTypeTraitExprClass, Empty), BTT(0), Value(false), 1611f187237d916afa97c491ac32fe98be7d335c5b63Francois Pichet LhsType(), RhsType() { } 16126ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet 161363c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall SourceRange getSourceRange() const { 16146ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet return SourceRange(Loc, RParen); 16156ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet } 16166ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet 16176ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet BinaryTypeTrait getTrait() const { 16186ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet return static_cast<BinaryTypeTrait>(BTT); 16196ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet } 16206ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet 16216ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet QualType getLhsType() const { return LhsType->getType(); } 16226ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet QualType getRhsType() const { return RhsType->getType(); } 16236ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet 16246ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet TypeSourceInfo *getLhsTypeSourceInfo() const { return LhsType; } 16256ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet TypeSourceInfo *getRhsTypeSourceInfo() const { return RhsType; } 1626ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 16276ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet bool getValue() const { assert(!isTypeDependent()); return Value; } 16286ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet 16296ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet static bool classof(const Stmt *T) { 16306ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet return T->getStmtClass() == BinaryTypeTraitExprClass; 16316ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet } 16326ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet static bool classof(const BinaryTypeTraitExpr *) { return true; } 16336ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet 16346ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet // Iterators 163563c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall child_range children() { return child_range(); } 16366ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet 16376ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet friend class ASTStmtReader; 16386ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet}; 16396ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet 164021ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley/// ArrayTypeTraitExpr - An Embarcadero array type trait, as used in the 164121ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley/// implementation of __array_rank and __array_extent. 164221ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley/// Example: 164321ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley/// __array_rank(int[10][20]) == 2 164421ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley/// __array_extent(int, 1) == 20 164521ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegleyclass ArrayTypeTraitExpr : public Expr { 164621ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley /// ATT - The trait. An ArrayTypeTrait enum in MSVC compat unsigned. 164721ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley unsigned ATT : 2; 164821ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley 164921ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley /// The value of the type trait. Unspecified if dependent. 165021ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley uint64_t Value; 165121ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley 165221ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley /// The array dimension being queried, or -1 if not used 165321ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley Expr *Dimension; 165421ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley 165521ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley /// Loc - The location of the type trait keyword. 165621ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley SourceLocation Loc; 165721ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley 165821ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley /// RParen - The location of the closing paren. 165921ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley SourceLocation RParen; 166021ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley 166121ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley /// The type being queried. 166221ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley TypeSourceInfo *QueriedType; 166321ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley 166421ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegleypublic: 166521ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley ArrayTypeTraitExpr(SourceLocation loc, ArrayTypeTrait att, 166621ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley TypeSourceInfo *queried, uint64_t value, 166721ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley Expr *dimension, SourceLocation rparen, QualType ty) 166821ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley : Expr(ArrayTypeTraitExprClass, ty, VK_RValue, OK_Ordinary, 166921ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley false, queried->getType()->isDependentType(), 1670561f81243f665cf2001caadc45df505f826b72d6Douglas Gregor (queried->getType()->isInstantiationDependentType() || 1671561f81243f665cf2001caadc45df505f826b72d6Douglas Gregor (dimension && dimension->isInstantiationDependent())), 167221ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley queried->getType()->containsUnexpandedParameterPack()), 167321ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley ATT(att), Value(value), Dimension(dimension), 167421ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley Loc(loc), RParen(rparen), QueriedType(queried) { } 167521ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley 167621ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley 167721ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley explicit ArrayTypeTraitExpr(EmptyShell Empty) 167821ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley : Expr(ArrayTypeTraitExprClass, Empty), ATT(0), Value(false), 167921ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley QueriedType() { } 168021ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley 168125aaf28c5bec71d5d005df67ee78b908ba5940f4Manuel Klimek virtual ~ArrayTypeTraitExpr() { } 168225aaf28c5bec71d5d005df67ee78b908ba5940f4Manuel Klimek 1683ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie virtual SourceRange getSourceRange() const { 1684ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie return SourceRange(Loc, RParen); 1685ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie } 168621ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley 168721ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley ArrayTypeTrait getTrait() const { return static_cast<ArrayTypeTrait>(ATT); } 168821ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley 168921ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley QualType getQueriedType() const { return QueriedType->getType(); } 169021ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley 169121ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley TypeSourceInfo *getQueriedTypeSourceInfo() const { return QueriedType; } 169221ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley 169321ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley uint64_t getValue() const { assert(!isTypeDependent()); return Value; } 169421ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley 169521ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley Expr *getDimensionExpression() const { return Dimension; } 169621ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley 169721ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley static bool classof(const Stmt *T) { 169821ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley return T->getStmtClass() == ArrayTypeTraitExprClass; 169921ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley } 170021ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley static bool classof(const ArrayTypeTraitExpr *) { return true; } 170121ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley 170221ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley // Iterators 170321ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley child_range children() { return child_range(); } 170421ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley 170521ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley friend class ASTStmtReader; 170621ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley}; 170721ff2e516b0e0bc8c1dbf965cb3d44bac3c64330John Wiegley 1708552622067dc45013d240f73952fece703f5e63bdJohn Wiegley/// ExpressionTraitExpr - An expression trait intrinsic 1709552622067dc45013d240f73952fece703f5e63bdJohn Wiegley/// Example: 1710552622067dc45013d240f73952fece703f5e63bdJohn Wiegley/// __is_lvalue_expr(std::cout) == true 1711552622067dc45013d240f73952fece703f5e63bdJohn Wiegley/// __is_lvalue_expr(1) == false 1712552622067dc45013d240f73952fece703f5e63bdJohn Wiegleyclass ExpressionTraitExpr : public Expr { 1713552622067dc45013d240f73952fece703f5e63bdJohn Wiegley /// ET - The trait. A ExpressionTrait enum in MSVC compat unsigned. 1714552622067dc45013d240f73952fece703f5e63bdJohn Wiegley unsigned ET : 31; 1715552622067dc45013d240f73952fece703f5e63bdJohn Wiegley /// The value of the type trait. Unspecified if dependent. 1716552622067dc45013d240f73952fece703f5e63bdJohn Wiegley bool Value : 1; 1717552622067dc45013d240f73952fece703f5e63bdJohn Wiegley 1718552622067dc45013d240f73952fece703f5e63bdJohn Wiegley /// Loc - The location of the type trait keyword. 1719552622067dc45013d240f73952fece703f5e63bdJohn Wiegley SourceLocation Loc; 1720552622067dc45013d240f73952fece703f5e63bdJohn Wiegley 1721552622067dc45013d240f73952fece703f5e63bdJohn Wiegley /// RParen - The location of the closing paren. 1722552622067dc45013d240f73952fece703f5e63bdJohn Wiegley SourceLocation RParen; 1723552622067dc45013d240f73952fece703f5e63bdJohn Wiegley 1724552622067dc45013d240f73952fece703f5e63bdJohn Wiegley Expr* QueriedExpression; 1725552622067dc45013d240f73952fece703f5e63bdJohn Wiegleypublic: 1726ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie ExpressionTraitExpr(SourceLocation loc, ExpressionTrait et, 1727552622067dc45013d240f73952fece703f5e63bdJohn Wiegley Expr *queried, bool value, 1728552622067dc45013d240f73952fece703f5e63bdJohn Wiegley SourceLocation rparen, QualType resultType) 1729552622067dc45013d240f73952fece703f5e63bdJohn Wiegley : Expr(ExpressionTraitExprClass, resultType, VK_RValue, OK_Ordinary, 1730552622067dc45013d240f73952fece703f5e63bdJohn Wiegley false, // Not type-dependent 1731552622067dc45013d240f73952fece703f5e63bdJohn Wiegley // Value-dependent if the argument is type-dependent. 1732552622067dc45013d240f73952fece703f5e63bdJohn Wiegley queried->isTypeDependent(), 1733561f81243f665cf2001caadc45df505f826b72d6Douglas Gregor queried->isInstantiationDependent(), 1734552622067dc45013d240f73952fece703f5e63bdJohn Wiegley queried->containsUnexpandedParameterPack()), 1735ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie ET(et), Value(value), Loc(loc), RParen(rparen), 1736ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie QueriedExpression(queried) { } 1737552622067dc45013d240f73952fece703f5e63bdJohn Wiegley 1738552622067dc45013d240f73952fece703f5e63bdJohn Wiegley explicit ExpressionTraitExpr(EmptyShell Empty) 1739552622067dc45013d240f73952fece703f5e63bdJohn Wiegley : Expr(ExpressionTraitExprClass, Empty), ET(0), Value(false), 1740552622067dc45013d240f73952fece703f5e63bdJohn Wiegley QueriedExpression() { } 1741552622067dc45013d240f73952fece703f5e63bdJohn Wiegley 1742552622067dc45013d240f73952fece703f5e63bdJohn Wiegley SourceRange getSourceRange() const { return SourceRange(Loc, RParen);} 1743552622067dc45013d240f73952fece703f5e63bdJohn Wiegley 1744552622067dc45013d240f73952fece703f5e63bdJohn Wiegley ExpressionTrait getTrait() const { return static_cast<ExpressionTrait>(ET); } 1745552622067dc45013d240f73952fece703f5e63bdJohn Wiegley 1746552622067dc45013d240f73952fece703f5e63bdJohn Wiegley Expr *getQueriedExpression() const { return QueriedExpression; } 1747552622067dc45013d240f73952fece703f5e63bdJohn Wiegley 1748552622067dc45013d240f73952fece703f5e63bdJohn Wiegley bool getValue() const { return Value; } 1749552622067dc45013d240f73952fece703f5e63bdJohn Wiegley 1750552622067dc45013d240f73952fece703f5e63bdJohn Wiegley static bool classof(const Stmt *T) { 1751552622067dc45013d240f73952fece703f5e63bdJohn Wiegley return T->getStmtClass() == ExpressionTraitExprClass; 1752552622067dc45013d240f73952fece703f5e63bdJohn Wiegley } 1753552622067dc45013d240f73952fece703f5e63bdJohn Wiegley static bool classof(const ExpressionTraitExpr *) { return true; } 1754552622067dc45013d240f73952fece703f5e63bdJohn Wiegley 1755552622067dc45013d240f73952fece703f5e63bdJohn Wiegley // Iterators 1756552622067dc45013d240f73952fece703f5e63bdJohn Wiegley child_range children() { return child_range(); } 1757552622067dc45013d240f73952fece703f5e63bdJohn Wiegley 1758552622067dc45013d240f73952fece703f5e63bdJohn Wiegley friend class ASTStmtReader; 1759552622067dc45013d240f73952fece703f5e63bdJohn Wiegley}; 1760552622067dc45013d240f73952fece703f5e63bdJohn Wiegley 1761552622067dc45013d240f73952fece703f5e63bdJohn Wiegley 17627bb12da2b0749eeebb21854c77877736969e59f2John McCall/// \brief A reference to an overloaded function set, either an 17637bb12da2b0749eeebb21854c77877736969e59f2John McCall/// \t UnresolvedLookupExpr or an \t UnresolvedMemberExpr. 17647bb12da2b0749eeebb21854c77877736969e59f2John McCallclass OverloadExpr : public Expr { 1765ba13543329afac4a0d01304ec2ec4924d99306a6John McCall /// The results. These are undesugared, which is to say, they may 17667bb12da2b0749eeebb21854c77877736969e59f2John McCall /// include UsingShadowDecls. Access is relative to the naming 17677bb12da2b0749eeebb21854c77877736969e59f2John McCall /// class. 1768928e6fcf66fc4f342bcf7cc96bf56986c9c2a833Douglas Gregor // FIXME: Allocate this data after the OverloadExpr subclass. 1769928e6fcf66fc4f342bcf7cc96bf56986c9c2a833Douglas Gregor DeclAccessPair *Results; 1770928e6fcf66fc4f342bcf7cc96bf56986c9c2a833Douglas Gregor unsigned NumResults; 1771ba13543329afac4a0d01304ec2ec4924d99306a6John McCall 17727bb12da2b0749eeebb21854c77877736969e59f2John McCall /// The common name of these declarations. 17732577743c5650c646fb705df01403707e94f2df04Abramo Bagnara DeclarationNameInfo NameInfo; 1774ba13543329afac4a0d01304ec2ec4924d99306a6John McCall 17754c9be89bb615ec07eb3ed507c8fa9d0baa8a5ad7Douglas Gregor /// \brief The nested-name-specifier that qualifies the name, if any. 17764c9be89bb615ec07eb3ed507c8fa9d0baa8a5ad7Douglas Gregor NestedNameSpecifierLoc QualifierLoc; 1777ba13543329afac4a0d01304ec2ec4924d99306a6John McCall 1778a77eb0862507b900a10fa352af1568e639ed10b1Argyrios Kyrtzidisprotected: 17797bb12da2b0749eeebb21854c77877736969e59f2John McCall /// True if the name was a template-id. 17807bb12da2b0749eeebb21854c77877736969e59f2John McCall bool HasExplicitTemplateArgs; 17817bb12da2b0749eeebb21854c77877736969e59f2John McCall 1782bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor OverloadExpr(StmtClass K, ASTContext &C, 17834c9be89bb615ec07eb3ed507c8fa9d0baa8a5ad7Douglas Gregor NestedNameSpecifierLoc QualifierLoc, 17842577743c5650c646fb705df01403707e94f2df04Abramo Bagnara const DeclarationNameInfo &NameInfo, 1785bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor const TemplateArgumentListInfo *TemplateArgs, 1786bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor UnresolvedSetIterator Begin, UnresolvedSetIterator End, 1787561f81243f665cf2001caadc45df505f826b72d6Douglas Gregor bool KnownDependent, 1788561f81243f665cf2001caadc45df505f826b72d6Douglas Gregor bool KnownInstantiationDependent, 1789561f81243f665cf2001caadc45df505f826b72d6Douglas Gregor bool KnownContainsUnexpandedParameterPack); 17907bb12da2b0749eeebb21854c77877736969e59f2John McCall 1791a77eb0862507b900a10fa352af1568e639ed10b1Argyrios Kyrtzidis OverloadExpr(StmtClass K, EmptyShell Empty) 1792a77eb0862507b900a10fa352af1568e639ed10b1Argyrios Kyrtzidis : Expr(K, Empty), Results(0), NumResults(0), 17934c9be89bb615ec07eb3ed507c8fa9d0baa8a5ad7Douglas Gregor QualifierLoc(), HasExplicitTemplateArgs(false) { } 1794a77eb0862507b900a10fa352af1568e639ed10b1Argyrios Kyrtzidis 1795bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor void initializeResults(ASTContext &C, 1796bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor UnresolvedSetIterator Begin, 1797bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor UnresolvedSetIterator End); 17987bb12da2b0749eeebb21854c77877736969e59f2John McCall 1799bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregorpublic: 18009c72c6088d591ace8503b842d39448c2040f3033John McCall struct FindResult { 18019c72c6088d591ace8503b842d39448c2040f3033John McCall OverloadExpr *Expression; 18029c72c6088d591ace8503b842d39448c2040f3033John McCall bool IsAddressOfOperand; 18039c72c6088d591ace8503b842d39448c2040f3033John McCall bool HasFormOfMemberPointer; 18049c72c6088d591ace8503b842d39448c2040f3033John McCall }; 18059c72c6088d591ace8503b842d39448c2040f3033John McCall 18067bb12da2b0749eeebb21854c77877736969e59f2John McCall /// Finds the overloaded expression in the given expression of 18077bb12da2b0749eeebb21854c77877736969e59f2John McCall /// OverloadTy. 18087bb12da2b0749eeebb21854c77877736969e59f2John McCall /// 18099c72c6088d591ace8503b842d39448c2040f3033John McCall /// \return the expression (which must be there) and true if it has 18109c72c6088d591ace8503b842d39448c2040f3033John McCall /// the particular form of a member pointer expression 18119c72c6088d591ace8503b842d39448c2040f3033John McCall static FindResult find(Expr *E) { 18127bb12da2b0749eeebb21854c77877736969e59f2John McCall assert(E->getType()->isSpecificBuiltinType(BuiltinType::Overload)); 18137bb12da2b0749eeebb21854c77877736969e59f2John McCall 18149c72c6088d591ace8503b842d39448c2040f3033John McCall FindResult Result; 18159c72c6088d591ace8503b842d39448c2040f3033John McCall 18167bb12da2b0749eeebb21854c77877736969e59f2John McCall E = E->IgnoreParens(); 18179c72c6088d591ace8503b842d39448c2040f3033John McCall if (isa<UnaryOperator>(E)) { 18189c72c6088d591ace8503b842d39448c2040f3033John McCall assert(cast<UnaryOperator>(E)->getOpcode() == UO_AddrOf); 18199c72c6088d591ace8503b842d39448c2040f3033John McCall E = cast<UnaryOperator>(E)->getSubExpr(); 18209c72c6088d591ace8503b842d39448c2040f3033John McCall OverloadExpr *Ovl = cast<OverloadExpr>(E->IgnoreParens()); 18219c72c6088d591ace8503b842d39448c2040f3033John McCall 18229c72c6088d591ace8503b842d39448c2040f3033John McCall Result.HasFormOfMemberPointer = (E == Ovl && Ovl->getQualifier()); 18239c72c6088d591ace8503b842d39448c2040f3033John McCall Result.IsAddressOfOperand = true; 18249c72c6088d591ace8503b842d39448c2040f3033John McCall Result.Expression = Ovl; 18259c72c6088d591ace8503b842d39448c2040f3033John McCall } else { 18269c72c6088d591ace8503b842d39448c2040f3033John McCall Result.HasFormOfMemberPointer = false; 18279c72c6088d591ace8503b842d39448c2040f3033John McCall Result.IsAddressOfOperand = false; 18289c72c6088d591ace8503b842d39448c2040f3033John McCall Result.Expression = cast<OverloadExpr>(E); 18299c72c6088d591ace8503b842d39448c2040f3033John McCall } 18309c72c6088d591ace8503b842d39448c2040f3033John McCall 18319c72c6088d591ace8503b842d39448c2040f3033John McCall return Result; 18327bb12da2b0749eeebb21854c77877736969e59f2John McCall } 18337bb12da2b0749eeebb21854c77877736969e59f2John McCall 1834e9ee23edd17c4bb7f271e67f8790792b4de677fcJohn McCall /// Gets the naming class of this lookup, if any. 1835e9ee23edd17c4bb7f271e67f8790792b4de677fcJohn McCall CXXRecordDecl *getNamingClass() const; 1836e9ee23edd17c4bb7f271e67f8790792b4de677fcJohn McCall 18377bb12da2b0749eeebb21854c77877736969e59f2John McCall typedef UnresolvedSetImpl::iterator decls_iterator; 1838928e6fcf66fc4f342bcf7cc96bf56986c9c2a833Douglas Gregor decls_iterator decls_begin() const { return UnresolvedSetIterator(Results); } 1839ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie decls_iterator decls_end() const { 1840928e6fcf66fc4f342bcf7cc96bf56986c9c2a833Douglas Gregor return UnresolvedSetIterator(Results + NumResults); 1841928e6fcf66fc4f342bcf7cc96bf56986c9c2a833Douglas Gregor } 1842ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 18437bb12da2b0749eeebb21854c77877736969e59f2John McCall /// Gets the number of declarations in the unresolved set. 1844928e6fcf66fc4f342bcf7cc96bf56986c9c2a833Douglas Gregor unsigned getNumDecls() const { return NumResults; } 18457bb12da2b0749eeebb21854c77877736969e59f2John McCall 18462577743c5650c646fb705df01403707e94f2df04Abramo Bagnara /// Gets the full name info. 18472577743c5650c646fb705df01403707e94f2df04Abramo Bagnara const DeclarationNameInfo &getNameInfo() const { return NameInfo; } 18482577743c5650c646fb705df01403707e94f2df04Abramo Bagnara 18497bb12da2b0749eeebb21854c77877736969e59f2John McCall /// Gets the name looked up. 18502577743c5650c646fb705df01403707e94f2df04Abramo Bagnara DeclarationName getName() const { return NameInfo.getName(); } 18517bb12da2b0749eeebb21854c77877736969e59f2John McCall 18527bb12da2b0749eeebb21854c77877736969e59f2John McCall /// Gets the location of the name. 18532577743c5650c646fb705df01403707e94f2df04Abramo Bagnara SourceLocation getNameLoc() const { return NameInfo.getLoc(); } 18547bb12da2b0749eeebb21854c77877736969e59f2John McCall 18557bb12da2b0749eeebb21854c77877736969e59f2John McCall /// Fetches the nested-name qualifier, if one was given. 1856ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie NestedNameSpecifier *getQualifier() const { 1857ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie return QualifierLoc.getNestedNameSpecifier(); 18584c9be89bb615ec07eb3ed507c8fa9d0baa8a5ad7Douglas Gregor } 18597bb12da2b0749eeebb21854c77877736969e59f2John McCall 1860ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie /// Fetches the nested-name qualifier with source-location information, if 18614c9be89bb615ec07eb3ed507c8fa9d0baa8a5ad7Douglas Gregor /// one was given. 18624c9be89bb615ec07eb3ed507c8fa9d0baa8a5ad7Douglas Gregor NestedNameSpecifierLoc getQualifierLoc() const { return QualifierLoc; } 18637bb12da2b0749eeebb21854c77877736969e59f2John McCall 18647bb12da2b0749eeebb21854c77877736969e59f2John McCall /// \brief Determines whether this expression had an explicit 18657bb12da2b0749eeebb21854c77877736969e59f2John McCall /// template argument list, e.g. f<int>. 18667bb12da2b0749eeebb21854c77877736969e59f2John McCall bool hasExplicitTemplateArgs() const { return HasExplicitTemplateArgs; } 18677bb12da2b0749eeebb21854c77877736969e59f2John McCall 1868b0c3e0909bb04af0bfb82ad01ab6909649d68ccaArgyrios Kyrtzidis ASTTemplateArgumentListInfo &getExplicitTemplateArgs(); // defined far below 18697bb12da2b0749eeebb21854c77877736969e59f2John McCall 1870b0c3e0909bb04af0bfb82ad01ab6909649d68ccaArgyrios Kyrtzidis const ASTTemplateArgumentListInfo &getExplicitTemplateArgs() const { 18717bb12da2b0749eeebb21854c77877736969e59f2John McCall return const_cast<OverloadExpr*>(this)->getExplicitTemplateArgs(); 18727bb12da2b0749eeebb21854c77877736969e59f2John McCall } 18737bb12da2b0749eeebb21854c77877736969e59f2John McCall 1874096832c5ed5b9106fa177ebc148489760c3bc496John McCall /// \brief Retrieves the optional explicit template arguments. 1875096832c5ed5b9106fa177ebc148489760c3bc496John McCall /// This points to the same data as getExplicitTemplateArgs(), but 1876096832c5ed5b9106fa177ebc148489760c3bc496John McCall /// returns null if there are no explicit template arguments. 1877b0c3e0909bb04af0bfb82ad01ab6909649d68ccaArgyrios Kyrtzidis const ASTTemplateArgumentListInfo *getOptionalExplicitTemplateArgs() { 1878096832c5ed5b9106fa177ebc148489760c3bc496John McCall if (!hasExplicitTemplateArgs()) return 0; 1879096832c5ed5b9106fa177ebc148489760c3bc496John McCall return &getExplicitTemplateArgs(); 18807bb12da2b0749eeebb21854c77877736969e59f2John McCall } 18817bb12da2b0749eeebb21854c77877736969e59f2John McCall 18827bb12da2b0749eeebb21854c77877736969e59f2John McCall static bool classof(const Stmt *T) { 18837bb12da2b0749eeebb21854c77877736969e59f2John McCall return T->getStmtClass() == UnresolvedLookupExprClass || 18847bb12da2b0749eeebb21854c77877736969e59f2John McCall T->getStmtClass() == UnresolvedMemberExprClass; 18857bb12da2b0749eeebb21854c77877736969e59f2John McCall } 18867bb12da2b0749eeebb21854c77877736969e59f2John McCall static bool classof(const OverloadExpr *) { return true; } 18874045107b7384fd68eed5e3e2f06fc2a47e7be0a6Argyrios Kyrtzidis 18884045107b7384fd68eed5e3e2f06fc2a47e7be0a6Argyrios Kyrtzidis friend class ASTStmtReader; 18894045107b7384fd68eed5e3e2f06fc2a47e7be0a6Argyrios Kyrtzidis friend class ASTStmtWriter; 18907bb12da2b0749eeebb21854c77877736969e59f2John McCall}; 18917bb12da2b0749eeebb21854c77877736969e59f2John McCall 18927bb12da2b0749eeebb21854c77877736969e59f2John McCall/// \brief A reference to a name which we were able to look up during 18937bb12da2b0749eeebb21854c77877736969e59f2John McCall/// parsing but could not resolve to a specific declaration. This 18947bb12da2b0749eeebb21854c77877736969e59f2John McCall/// arises in several ways: 18957bb12da2b0749eeebb21854c77877736969e59f2John McCall/// * we might be waiting for argument-dependent lookup 18967bb12da2b0749eeebb21854c77877736969e59f2John McCall/// * the name might resolve to an overloaded function 18977bb12da2b0749eeebb21854c77877736969e59f2John McCall/// and eventually: 18987bb12da2b0749eeebb21854c77877736969e59f2John McCall/// * the lookup might have included a function template 18997bb12da2b0749eeebb21854c77877736969e59f2John McCall/// These never include UnresolvedUsingValueDecls, which are always 19007bb12da2b0749eeebb21854c77877736969e59f2John McCall/// class members and therefore appear only in 19017bb12da2b0749eeebb21854c77877736969e59f2John McCall/// UnresolvedMemberLookupExprs. 19027bb12da2b0749eeebb21854c77877736969e59f2John McCallclass UnresolvedLookupExpr : public OverloadExpr { 1903ba13543329afac4a0d01304ec2ec4924d99306a6John McCall /// True if these lookup results should be extended by 1904ba13543329afac4a0d01304ec2ec4924d99306a6John McCall /// argument-dependent lookup if this is the operand of a function 1905ba13543329afac4a0d01304ec2ec4924d99306a6John McCall /// call. 1906ba13543329afac4a0d01304ec2ec4924d99306a6John McCall bool RequiresADL; 1907ba13543329afac4a0d01304ec2ec4924d99306a6John McCall 1908ad762fcdc16b9e4705b12b09d92b8c026212b906Richard Smith /// True if namespace ::std should be considered an associated namespace 1909ad762fcdc16b9e4705b12b09d92b8c026212b906Richard Smith /// for the purposes of argument-dependent lookup. See C++0x [stmt.ranged]p1. 1910ad762fcdc16b9e4705b12b09d92b8c026212b906Richard Smith bool StdIsAssociatedNamespace; 1911ad762fcdc16b9e4705b12b09d92b8c026212b906Richard Smith 19127453ed4cb2cab113de3378df371b1c6f1243d832John McCall /// True if these lookup results are overloaded. This is pretty 19137453ed4cb2cab113de3378df371b1c6f1243d832John McCall /// trivially rederivable if we urgently need to kill this field. 19147453ed4cb2cab113de3378df371b1c6f1243d832John McCall bool Overloaded; 19157453ed4cb2cab113de3378df371b1c6f1243d832John McCall 19167bb12da2b0749eeebb21854c77877736969e59f2John McCall /// The naming class (C++ [class.access.base]p5) of the lookup, if 19177bb12da2b0749eeebb21854c77877736969e59f2John McCall /// any. This can generally be recalculated from the context chain, 19187bb12da2b0749eeebb21854c77877736969e59f2John McCall /// but that can be fairly expensive for unqualified lookups. If we 19197bb12da2b0749eeebb21854c77877736969e59f2John McCall /// want to improve memory use here, this could go in a union 19207bb12da2b0749eeebb21854c77877736969e59f2John McCall /// against the qualified-lookup bits. 19217bb12da2b0749eeebb21854c77877736969e59f2John McCall CXXRecordDecl *NamingClass; 1922f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall 1923ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie UnresolvedLookupExpr(ASTContext &C, 1924928e6fcf66fc4f342bcf7cc96bf56986c9c2a833Douglas Gregor CXXRecordDecl *NamingClass, 19254c9be89bb615ec07eb3ed507c8fa9d0baa8a5ad7Douglas Gregor NestedNameSpecifierLoc QualifierLoc, 19262577743c5650c646fb705df01403707e94f2df04Abramo Bagnara const DeclarationNameInfo &NameInfo, 1927ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie bool RequiresADL, bool Overloaded, 1928bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor const TemplateArgumentListInfo *TemplateArgs, 1929ad762fcdc16b9e4705b12b09d92b8c026212b906Richard Smith UnresolvedSetIterator Begin, UnresolvedSetIterator End, 1930ad762fcdc16b9e4705b12b09d92b8c026212b906Richard Smith bool StdIsAssociatedNamespace) 1931ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie : OverloadExpr(UnresolvedLookupExprClass, C, QualifierLoc, NameInfo, 1932561f81243f665cf2001caadc45df505f826b72d6Douglas Gregor TemplateArgs, Begin, End, false, false, false), 1933ad762fcdc16b9e4705b12b09d92b8c026212b906Richard Smith RequiresADL(RequiresADL), 1934ad762fcdc16b9e4705b12b09d92b8c026212b906Richard Smith StdIsAssociatedNamespace(StdIsAssociatedNamespace), 1935ad762fcdc16b9e4705b12b09d92b8c026212b906Richard Smith Overloaded(Overloaded), NamingClass(NamingClass) 1936ba13543329afac4a0d01304ec2ec4924d99306a6John McCall {} 1937ba13543329afac4a0d01304ec2ec4924d99306a6John McCall 1938bd65bb511c26549c96b829c1282e4c877588564aArgyrios Kyrtzidis UnresolvedLookupExpr(EmptyShell Empty) 1939bd65bb511c26549c96b829c1282e4c877588564aArgyrios Kyrtzidis : OverloadExpr(UnresolvedLookupExprClass, Empty), 1940ad762fcdc16b9e4705b12b09d92b8c026212b906Richard Smith RequiresADL(false), StdIsAssociatedNamespace(false), Overloaded(false), 1941ad762fcdc16b9e4705b12b09d92b8c026212b906Richard Smith NamingClass(0) 1942bd65bb511c26549c96b829c1282e4c877588564aArgyrios Kyrtzidis {} 1943bd65bb511c26549c96b829c1282e4c877588564aArgyrios Kyrtzidis 19444c9be89bb615ec07eb3ed507c8fa9d0baa8a5ad7Douglas Gregor friend class ASTStmtReader; 1945ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 1946ba13543329afac4a0d01304ec2ec4924d99306a6John McCallpublic: 1947ba13543329afac4a0d01304ec2ec4924d99306a6John McCall static UnresolvedLookupExpr *Create(ASTContext &C, 1948c373d48502ca7683ab55385f5bd624d778eb288dJohn McCall CXXRecordDecl *NamingClass, 19494c9be89bb615ec07eb3ed507c8fa9d0baa8a5ad7Douglas Gregor NestedNameSpecifierLoc QualifierLoc, 19502577743c5650c646fb705df01403707e94f2df04Abramo Bagnara const DeclarationNameInfo &NameInfo, 19515a84dec38cfa9e084377a3167b474c79283c82faDouglas Gregor bool ADL, bool Overloaded, 1952ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie UnresolvedSetIterator Begin, 1953ad762fcdc16b9e4705b12b09d92b8c026212b906Richard Smith UnresolvedSetIterator End, 1954ad762fcdc16b9e4705b12b09d92b8c026212b906Richard Smith bool StdIsAssociatedNamespace = false) { 1955ad762fcdc16b9e4705b12b09d92b8c026212b906Richard Smith assert((ADL || !StdIsAssociatedNamespace) && 1956ad762fcdc16b9e4705b12b09d92b8c026212b906Richard Smith "std considered associated namespace when not performing ADL"); 1957ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie return new(C) UnresolvedLookupExpr(C, NamingClass, QualifierLoc, NameInfo, 1958ad762fcdc16b9e4705b12b09d92b8c026212b906Richard Smith ADL, Overloaded, 0, Begin, End, 1959ad762fcdc16b9e4705b12b09d92b8c026212b906Richard Smith StdIsAssociatedNamespace); 1960ba13543329afac4a0d01304ec2ec4924d99306a6John McCall } 1961ba13543329afac4a0d01304ec2ec4924d99306a6John McCall 1962f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall static UnresolvedLookupExpr *Create(ASTContext &C, 1963c373d48502ca7683ab55385f5bd624d778eb288dJohn McCall CXXRecordDecl *NamingClass, 19644c9be89bb615ec07eb3ed507c8fa9d0baa8a5ad7Douglas Gregor NestedNameSpecifierLoc QualifierLoc, 19652577743c5650c646fb705df01403707e94f2df04Abramo Bagnara const DeclarationNameInfo &NameInfo, 1966f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall bool ADL, 19675a84dec38cfa9e084377a3167b474c79283c82faDouglas Gregor const TemplateArgumentListInfo &Args, 1968ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie UnresolvedSetIterator Begin, 19695a84dec38cfa9e084377a3167b474c79283c82faDouglas Gregor UnresolvedSetIterator End); 1970f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall 1971bd65bb511c26549c96b829c1282e4c877588564aArgyrios Kyrtzidis static UnresolvedLookupExpr *CreateEmpty(ASTContext &C, 1972def0354384d9c4431f7b58b664b59896d4623028Douglas Gregor bool HasExplicitTemplateArgs, 1973bd65bb511c26549c96b829c1282e4c877588564aArgyrios Kyrtzidis unsigned NumTemplateArgs); 1974bd65bb511c26549c96b829c1282e4c877588564aArgyrios Kyrtzidis 1975ba13543329afac4a0d01304ec2ec4924d99306a6John McCall /// True if this declaration should be extended by 1976ba13543329afac4a0d01304ec2ec4924d99306a6John McCall /// argument-dependent lookup. 1977ba13543329afac4a0d01304ec2ec4924d99306a6John McCall bool requiresADL() const { return RequiresADL; } 1978ba13543329afac4a0d01304ec2ec4924d99306a6John McCall 1979ad762fcdc16b9e4705b12b09d92b8c026212b906Richard Smith /// True if namespace ::std should be artificially added to the set of 1980ad762fcdc16b9e4705b12b09d92b8c026212b906Richard Smith /// associated namespaecs for argument-dependent lookup purposes. 1981ad762fcdc16b9e4705b12b09d92b8c026212b906Richard Smith bool isStdAssociatedNamespace() const { return StdIsAssociatedNamespace; } 1982ad762fcdc16b9e4705b12b09d92b8c026212b906Richard Smith 19837453ed4cb2cab113de3378df371b1c6f1243d832John McCall /// True if this lookup is overloaded. 19847453ed4cb2cab113de3378df371b1c6f1243d832John McCall bool isOverloaded() const { return Overloaded; } 19857453ed4cb2cab113de3378df371b1c6f1243d832John McCall 1986c373d48502ca7683ab55385f5bd624d778eb288dJohn McCall /// Gets the 'naming class' (in the sense of C++0x 1987c373d48502ca7683ab55385f5bd624d778eb288dJohn McCall /// [class.access.base]p5) of the lookup. This is the scope 1988c373d48502ca7683ab55385f5bd624d778eb288dJohn McCall /// that was looked in to find these results. 1989c373d48502ca7683ab55385f5bd624d778eb288dJohn McCall CXXRecordDecl *getNamingClass() const { return NamingClass; } 1990c373d48502ca7683ab55385f5bd624d778eb288dJohn McCall 1991f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall // Note that, inconsistently with the explicit-template-argument AST 1992f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall // nodes, users are *forbidden* from calling these methods on objects 1993f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall // without explicit template arguments. 1994f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall 1995b0c3e0909bb04af0bfb82ad01ab6909649d68ccaArgyrios Kyrtzidis ASTTemplateArgumentListInfo &getExplicitTemplateArgs() { 19967bb12da2b0749eeebb21854c77877736969e59f2John McCall assert(hasExplicitTemplateArgs()); 1997b0c3e0909bb04af0bfb82ad01ab6909649d68ccaArgyrios Kyrtzidis return *reinterpret_cast<ASTTemplateArgumentListInfo*>(this + 1); 19987bb12da2b0749eeebb21854c77877736969e59f2John McCall } 19997bb12da2b0749eeebb21854c77877736969e59f2John McCall 2000f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall /// Gets a reference to the explicit template argument list. 2001b0c3e0909bb04af0bfb82ad01ab6909649d68ccaArgyrios Kyrtzidis const ASTTemplateArgumentListInfo &getExplicitTemplateArgs() const { 2002f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall assert(hasExplicitTemplateArgs()); 2003b0c3e0909bb04af0bfb82ad01ab6909649d68ccaArgyrios Kyrtzidis return *reinterpret_cast<const ASTTemplateArgumentListInfo*>(this + 1); 2004f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall } 2005f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall 2006096832c5ed5b9106fa177ebc148489760c3bc496John McCall /// \brief Retrieves the optional explicit template arguments. 2007096832c5ed5b9106fa177ebc148489760c3bc496John McCall /// This points to the same data as getExplicitTemplateArgs(), but 2008096832c5ed5b9106fa177ebc148489760c3bc496John McCall /// returns null if there are no explicit template arguments. 2009b0c3e0909bb04af0bfb82ad01ab6909649d68ccaArgyrios Kyrtzidis const ASTTemplateArgumentListInfo *getOptionalExplicitTemplateArgs() { 2010096832c5ed5b9106fa177ebc148489760c3bc496John McCall if (!hasExplicitTemplateArgs()) return 0; 2011096832c5ed5b9106fa177ebc148489760c3bc496John McCall return &getExplicitTemplateArgs(); 2012096832c5ed5b9106fa177ebc148489760c3bc496John McCall } 2013096832c5ed5b9106fa177ebc148489760c3bc496John McCall 2014f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall /// \brief Copies the template arguments (if present) into the given 2015f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall /// structure. 2016f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall void copyTemplateArgumentsInto(TemplateArgumentListInfo &List) const { 2017f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall getExplicitTemplateArgs().copyInto(List); 2018f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall } 2019ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 2020f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall SourceLocation getLAngleLoc() const { 2021f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall return getExplicitTemplateArgs().LAngleLoc; 2022f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall } 2023f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall 2024f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall SourceLocation getRAngleLoc() const { 2025f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall return getExplicitTemplateArgs().RAngleLoc; 2026f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall } 2027f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall 2028f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall TemplateArgumentLoc const *getTemplateArgs() const { 2029f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall return getExplicitTemplateArgs().getTemplateArgs(); 2030f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall } 2031f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall 2032f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall unsigned getNumTemplateArgs() const { 2033f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall return getExplicitTemplateArgs().NumTemplateArgs; 2034f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall } 2035ba13543329afac4a0d01304ec2ec4924d99306a6John McCall 203663c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall SourceRange getSourceRange() const { 20372577743c5650c646fb705df01403707e94f2df04Abramo Bagnara SourceRange Range(getNameInfo().getSourceRange()); 2038ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie if (getQualifierLoc()) 20394c9be89bb615ec07eb3ed507c8fa9d0baa8a5ad7Douglas Gregor Range.setBegin(getQualifierLoc().getBeginLoc()); 2040ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie if (hasExplicitTemplateArgs()) 20414c9be89bb615ec07eb3ed507c8fa9d0baa8a5ad7Douglas Gregor Range.setEnd(getRAngleLoc()); 2042f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall return Range; 2043ba13543329afac4a0d01304ec2ec4924d99306a6John McCall } 2044ba13543329afac4a0d01304ec2ec4924d99306a6John McCall 204563c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall child_range children() { return child_range(); } 2046ba13543329afac4a0d01304ec2ec4924d99306a6John McCall 2047ba13543329afac4a0d01304ec2ec4924d99306a6John McCall static bool classof(const Stmt *T) { 2048ba13543329afac4a0d01304ec2ec4924d99306a6John McCall return T->getStmtClass() == UnresolvedLookupExprClass; 2049ba13543329afac4a0d01304ec2ec4924d99306a6John McCall } 2050ba13543329afac4a0d01304ec2ec4924d99306a6John McCall static bool classof(const UnresolvedLookupExpr *) { return true; } 2051ba13543329afac4a0d01304ec2ec4924d99306a6John McCall}; 2052ba13543329afac4a0d01304ec2ec4924d99306a6John McCall 20535953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor/// \brief A qualified reference to a name whose declaration cannot 20545953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor/// yet be resolved. 20555953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor/// 2056ba13543329afac4a0d01304ec2ec4924d99306a6John McCall/// DependentScopeDeclRefExpr is similar to DeclRefExpr in that 2057a2813cec2605ce7878d1b13471d685f689b251afDouglas Gregor/// it expresses a reference to a declaration such as 20585953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor/// X<T>::value. The difference, however, is that an 2059865d447ac6a4721ab58e898d014a21f2eff74b06John McCall/// DependentScopeDeclRefExpr node is used only within C++ templates when 20605953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor/// the qualification (e.g., X<T>::) refers to a dependent type. In 20615953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor/// this case, X<T>::value cannot resolve to a declaration because the 20625953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor/// declaration will differ from on instantiation of X<T> to the 2063865d447ac6a4721ab58e898d014a21f2eff74b06John McCall/// next. Therefore, DependentScopeDeclRefExpr keeps track of the 2064ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor/// qualifier (X<T>::) and the name of the entity being referenced 2065a2813cec2605ce7878d1b13471d685f689b251afDouglas Gregor/// ("value"). Such expressions will instantiate to a DeclRefExpr once the 2066a2813cec2605ce7878d1b13471d685f689b251afDouglas Gregor/// declaration can be found. 2067865d447ac6a4721ab58e898d014a21f2eff74b06John McCallclass DependentScopeDeclRefExpr : public Expr { 2068ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor /// \brief The nested-name-specifier that qualifies this unresolved 2069ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor /// declaration name. 207000cf3cc2718671aa48e8da264a523b0058a8591eDouglas Gregor NestedNameSpecifierLoc QualifierLoc; 2071ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 207200cf3cc2718671aa48e8da264a523b0058a8591eDouglas Gregor /// The name of the entity we will be referencing. 207300cf3cc2718671aa48e8da264a523b0058a8591eDouglas Gregor DeclarationNameInfo NameInfo; 20745953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor 2075f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall /// \brief Whether the name includes explicit template arguments. 2076f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall bool HasExplicitTemplateArgs; 20771eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 2078f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall DependentScopeDeclRefExpr(QualType T, 207900cf3cc2718671aa48e8da264a523b0058a8591eDouglas Gregor NestedNameSpecifierLoc QualifierLoc, 20802577743c5650c646fb705df01403707e94f2df04Abramo Bagnara const DeclarationNameInfo &NameInfo, 2081bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor const TemplateArgumentListInfo *Args); 2082f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall 2083f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCallpublic: 2084f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall static DependentScopeDeclRefExpr *Create(ASTContext &C, 208500cf3cc2718671aa48e8da264a523b0058a8591eDouglas Gregor NestedNameSpecifierLoc QualifierLoc, 20862577743c5650c646fb705df01403707e94f2df04Abramo Bagnara const DeclarationNameInfo &NameInfo, 2087f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall const TemplateArgumentListInfo *TemplateArgs = 0); 20885953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor 208912dffcddb60380c5bed4f085a1f51534afda3b87Argyrios Kyrtzidis static DependentScopeDeclRefExpr *CreateEmpty(ASTContext &C, 2090def0354384d9c4431f7b58b664b59896d4623028Douglas Gregor bool HasExplicitTemplateArgs, 209112dffcddb60380c5bed4f085a1f51534afda3b87Argyrios Kyrtzidis unsigned NumTemplateArgs); 209212dffcddb60380c5bed4f085a1f51534afda3b87Argyrios Kyrtzidis 20935953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor /// \brief Retrieve the name that this expression refers to. 20942577743c5650c646fb705df01403707e94f2df04Abramo Bagnara const DeclarationNameInfo &getNameInfo() const { return NameInfo; } 20952577743c5650c646fb705df01403707e94f2df04Abramo Bagnara 20962577743c5650c646fb705df01403707e94f2df04Abramo Bagnara /// \brief Retrieve the name that this expression refers to. 20972577743c5650c646fb705df01403707e94f2df04Abramo Bagnara DeclarationName getDeclName() const { return NameInfo.getName(); } 20985953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor 20995953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor /// \brief Retrieve the location of the name within the expression. 21002577743c5650c646fb705df01403707e94f2df04Abramo Bagnara SourceLocation getLocation() const { return NameInfo.getLoc(); } 21015953d8b37f92f0cf548941f617c9b0a7703df33bDouglas Gregor 210200cf3cc2718671aa48e8da264a523b0058a8591eDouglas Gregor /// \brief Retrieve the nested-name-specifier that qualifies the 210300cf3cc2718671aa48e8da264a523b0058a8591eDouglas Gregor /// name, with source location information. 210400cf3cc2718671aa48e8da264a523b0058a8591eDouglas Gregor NestedNameSpecifierLoc getQualifierLoc() const { return QualifierLoc; } 2105ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 2106ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 2107ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor /// \brief Retrieve the nested-name-specifier that qualifies this 2108ab452ba8323d1985e08bade2bced588cddf2cc28Douglas Gregor /// declaration. 2109ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie NestedNameSpecifier *getQualifier() const { 2110ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie return QualifierLoc.getNestedNameSpecifier(); 211100cf3cc2718671aa48e8da264a523b0058a8591eDouglas Gregor } 21121eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 2113f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall /// Determines whether this lookup had explicit template arguments. 2114f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall bool hasExplicitTemplateArgs() const { return HasExplicitTemplateArgs; } 21151eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 2116f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall // Note that, inconsistently with the explicit-template-argument AST 2117f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall // nodes, users are *forbidden* from calling these methods on objects 2118f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall // without explicit template arguments. 21191eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 2120b0c3e0909bb04af0bfb82ad01ab6909649d68ccaArgyrios Kyrtzidis ASTTemplateArgumentListInfo &getExplicitTemplateArgs() { 212112dffcddb60380c5bed4f085a1f51534afda3b87Argyrios Kyrtzidis assert(hasExplicitTemplateArgs()); 2122b0c3e0909bb04af0bfb82ad01ab6909649d68ccaArgyrios Kyrtzidis return *reinterpret_cast<ASTTemplateArgumentListInfo*>(this + 1); 212312dffcddb60380c5bed4f085a1f51534afda3b87Argyrios Kyrtzidis } 212412dffcddb60380c5bed4f085a1f51534afda3b87Argyrios Kyrtzidis 2125f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall /// Gets a reference to the explicit template argument list. 2126b0c3e0909bb04af0bfb82ad01ab6909649d68ccaArgyrios Kyrtzidis const ASTTemplateArgumentListInfo &getExplicitTemplateArgs() const { 2127f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall assert(hasExplicitTemplateArgs()); 2128b0c3e0909bb04af0bfb82ad01ab6909649d68ccaArgyrios Kyrtzidis return *reinterpret_cast<const ASTTemplateArgumentListInfo*>(this + 1); 2129f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall } 21301eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 2131096832c5ed5b9106fa177ebc148489760c3bc496John McCall /// \brief Retrieves the optional explicit template arguments. 2132096832c5ed5b9106fa177ebc148489760c3bc496John McCall /// This points to the same data as getExplicitTemplateArgs(), but 2133096832c5ed5b9106fa177ebc148489760c3bc496John McCall /// returns null if there are no explicit template arguments. 2134b0c3e0909bb04af0bfb82ad01ab6909649d68ccaArgyrios Kyrtzidis const ASTTemplateArgumentListInfo *getOptionalExplicitTemplateArgs() { 2135096832c5ed5b9106fa177ebc148489760c3bc496John McCall if (!hasExplicitTemplateArgs()) return 0; 2136096832c5ed5b9106fa177ebc148489760c3bc496John McCall return &getExplicitTemplateArgs(); 2137096832c5ed5b9106fa177ebc148489760c3bc496John McCall } 2138096832c5ed5b9106fa177ebc148489760c3bc496John McCall 2139f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall /// \brief Copies the template arguments (if present) into the given 2140f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall /// structure. 2141f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall void copyTemplateArgumentsInto(TemplateArgumentListInfo &List) const { 2142f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall getExplicitTemplateArgs().copyInto(List); 2143f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall } 2144ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 2145f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall SourceLocation getLAngleLoc() const { 2146f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall return getExplicitTemplateArgs().LAngleLoc; 2147edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor } 21481eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 2149f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall SourceLocation getRAngleLoc() const { 2150f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall return getExplicitTemplateArgs().RAngleLoc; 2151f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall } 21521eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 2153f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall TemplateArgumentLoc const *getTemplateArgs() const { 2154f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall return getExplicitTemplateArgs().getTemplateArgs(); 2155d5532b6cfff2977e0c59fa6ead7f7973984a620dJohn McCall } 2156d5532b6cfff2977e0c59fa6ead7f7973984a620dJohn McCall 2157f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall unsigned getNumTemplateArgs() const { 2158f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall return getExplicitTemplateArgs().NumTemplateArgs; 2159f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall } 21601eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 216163c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall SourceRange getSourceRange() const { 216200cf3cc2718671aa48e8da264a523b0058a8591eDouglas Gregor SourceRange Range(QualifierLoc.getBeginLoc(), getLocation()); 2163f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall if (hasExplicitTemplateArgs()) 2164f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall Range.setEnd(getRAngleLoc()); 2165f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall return Range; 2166edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor } 21671eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 21681eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump static bool classof(const Stmt *T) { 2169f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall return T->getStmtClass() == DependentScopeDeclRefExprClass; 2170edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor } 2171f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall static bool classof(const DependentScopeDeclRefExpr *) { return true; } 2172f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall 217363c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall child_range children() { return child_range(); } 21744045107b7384fd68eed5e3e2f06fc2a47e7be0a6Argyrios Kyrtzidis 21754045107b7384fd68eed5e3e2f06fc2a47e7be0a6Argyrios Kyrtzidis friend class ASTStmtReader; 21764045107b7384fd68eed5e3e2f06fc2a47e7be0a6Argyrios Kyrtzidis friend class ASTStmtWriter; 2177edce4dd44732dfad69f28822dddcf2b8e92b4483Douglas Gregor}; 21781eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 21794765fa05b5652fcc4356371c2f481d0ea9a1b007John McCall/// Represents an expression --- generally a full-expression --- which 21804765fa05b5652fcc4356371c2f481d0ea9a1b007John McCall/// introduces cleanups to be run at the end of the sub-expression's 21814765fa05b5652fcc4356371c2f481d0ea9a1b007John McCall/// evaluation. The most common source of expression-introduced 21824765fa05b5652fcc4356371c2f481d0ea9a1b007John McCall/// cleanups is temporary objects in C++, but several other C++ 21834765fa05b5652fcc4356371c2f481d0ea9a1b007John McCall/// expressions can create cleanups. 21844765fa05b5652fcc4356371c2f481d0ea9a1b007John McCallclass ExprWithCleanups : public Expr { 218502bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson Stmt *SubExpr; 21861eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 2187ff6b3d64c9f07155f1414411b8451d7bf8937c62Anders Carlsson CXXTemporary **Temps; 2188ff6b3d64c9f07155f1414411b8451d7bf8937c62Anders Carlsson unsigned NumTemps; 218902bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson 21904765fa05b5652fcc4356371c2f481d0ea9a1b007John McCall ExprWithCleanups(ASTContext &C, Expr *SubExpr, 21914765fa05b5652fcc4356371c2f481d0ea9a1b007John McCall CXXTemporary **Temps, unsigned NumTemps); 2192ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 219388eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlssonpublic: 21944765fa05b5652fcc4356371c2f481d0ea9a1b007John McCall ExprWithCleanups(EmptyShell Empty) 21954765fa05b5652fcc4356371c2f481d0ea9a1b007John McCall : Expr(ExprWithCleanupsClass, Empty), 2196d2598368876cfe40bc8465540033bc5b5e58d8afChris Lattner SubExpr(0), Temps(0), NumTemps(0) {} 2197ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 21984765fa05b5652fcc4356371c2f481d0ea9a1b007John McCall static ExprWithCleanups *Create(ASTContext &C, Expr *SubExpr, 2199ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie CXXTemporary **Temps, 22000ece491d8f62ce67f047491a6703fac0d3bd4ff4Anders Carlsson unsigned NumTemps); 22011eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 220288eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlsson unsigned getNumTemporaries() const { return NumTemps; } 2203d04ed416be7c55bddddab1fa3fd38a0113a6b3daTed Kremenek void setNumTemporaries(ASTContext &C, unsigned N); 2204ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 220588eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlsson CXXTemporary *getTemporary(unsigned i) { 220688eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlsson assert(i < NumTemps && "Index out of range"); 220788eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlsson return Temps[i]; 220888eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlsson } 2209f0721fe438d7e40c168e5d664970e7830bc138fbAnders Carlsson const CXXTemporary *getTemporary(unsigned i) const { 22104765fa05b5652fcc4356371c2f481d0ea9a1b007John McCall return const_cast<ExprWithCleanups*>(this)->getTemporary(i); 2211f0721fe438d7e40c168e5d664970e7830bc138fbAnders Carlsson } 2212d2598368876cfe40bc8465540033bc5b5e58d8afChris Lattner void setTemporary(unsigned i, CXXTemporary *T) { 2213d2598368876cfe40bc8465540033bc5b5e58d8afChris Lattner assert(i < NumTemps && "Index out of range"); 2214d2598368876cfe40bc8465540033bc5b5e58d8afChris Lattner Temps[i] = T; 2215d2598368876cfe40bc8465540033bc5b5e58d8afChris Lattner } 22161eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 221702bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson Expr *getSubExpr() { return cast<Expr>(SubExpr); } 2218f0721fe438d7e40c168e5d664970e7830bc138fbAnders Carlsson const Expr *getSubExpr() const { return cast<Expr>(SubExpr); } 221988eaf075c56672761b72cc50957db4a35bf24ebdAnders Carlsson void setSubExpr(Expr *E) { SubExpr = E; } 222002bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson 2221ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie SourceRange getSourceRange() const { 222296be6917e1c4ba1f4435a14c9e7c6c139571d086Douglas Gregor return SubExpr->getSourceRange(); 222396be6917e1c4ba1f4435a14c9e7c6c139571d086Douglas Gregor } 222402bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson 222502bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson // Implement isa/cast/dyncast/etc. 222602bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson static bool classof(const Stmt *T) { 22274765fa05b5652fcc4356371c2f481d0ea9a1b007John McCall return T->getStmtClass() == ExprWithCleanupsClass; 222802bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson } 22294765fa05b5652fcc4356371c2f481d0ea9a1b007John McCall static bool classof(const ExprWithCleanups *) { return true; } 223002bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson 223102bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson // Iterators 223263c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall child_range children() { return child_range(&SubExpr, &SubExpr + 1); } 223302bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson}; 223402bbfa33590dfe3107e801fb526b7ab0bdfd00eeAnders Carlsson 2235d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// \brief Describes an explicit type conversion that uses functional 2236d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// notion but could not be resolved because one or more arguments are 2237d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// type-dependent. 2238d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// 2239d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// The explicit type conversions expressed by 2240d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// CXXUnresolvedConstructExpr have the form \c T(a1, a2, ..., aN), 2241d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// where \c T is some type and \c a1, a2, ..., aN are values, and 2242d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// either \C T is a dependent type or one or more of the \c a's is 2243d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// type-dependent. For example, this would occur in a template such 2244d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// as: 2245d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// 2246d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// \code 2247d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// template<typename T, typename A1> 2248d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// inline T make_a(const A1& a1) { 2249d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// return T(a1); 2250d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// } 2251d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// \endcode 2252d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// 2253d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// When the returned expression is instantiated, it may resolve to a 2254d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// constructor call, conversion function call, or some kind of type 2255d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor/// conversion. 2256d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregorclass CXXUnresolvedConstructExpr : public Expr { 2257d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor /// \brief The type being constructed. 2258ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor TypeSourceInfo *Type; 2259ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 2260d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor /// \brief The location of the left parentheses ('('). 2261d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor SourceLocation LParenLoc; 2262d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor 2263d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor /// \brief The location of the right parentheses (')'). 2264d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor SourceLocation RParenLoc; 2265d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor 2266d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor /// \brief The number of arguments used to construct the type. 2267d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor unsigned NumArgs; 22681eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 2269ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor CXXUnresolvedConstructExpr(TypeSourceInfo *Type, 2270d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor SourceLocation LParenLoc, 2271d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor Expr **Args, 2272d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor unsigned NumArgs, 2273d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor SourceLocation RParenLoc); 2274d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor 22758dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis CXXUnresolvedConstructExpr(EmptyShell Empty, unsigned NumArgs) 2276ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor : Expr(CXXUnresolvedConstructExprClass, Empty), Type(), NumArgs(NumArgs) { } 22778dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis 2278ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor friend class ASTStmtReader; 2279ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 2280d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregorpublic: 22811eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump static CXXUnresolvedConstructExpr *Create(ASTContext &C, 2282ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor TypeSourceInfo *Type, 2283d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor SourceLocation LParenLoc, 2284d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor Expr **Args, 2285d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor unsigned NumArgs, 2286d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor SourceLocation RParenLoc); 2287d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor 22888dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis static CXXUnresolvedConstructExpr *CreateEmpty(ASTContext &C, 22898dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis unsigned NumArgs); 22908dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis 2291d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor /// \brief Retrieve the type that is being constructed, as specified 2292d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor /// in the source code. 2293ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor QualType getTypeAsWritten() const { return Type->getType(); } 2294d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor 2295ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie /// \brief Retrieve the type source information for the type being 2296ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor /// constructed. 2297ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor TypeSourceInfo *getTypeSourceInfo() const { return Type; } 2298ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 2299d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor /// \brief Retrieve the location of the left parentheses ('(') that 2300d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor /// precedes the argument list. 2301d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor SourceLocation getLParenLoc() const { return LParenLoc; } 2302d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor void setLParenLoc(SourceLocation L) { LParenLoc = L; } 2303d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor 2304d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor /// \brief Retrieve the location of the right parentheses (')') that 2305d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor /// follows the argument list. 2306d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor SourceLocation getRParenLoc() const { return RParenLoc; } 2307d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor void setRParenLoc(SourceLocation L) { RParenLoc = L; } 2308d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor 2309d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor /// \brief Retrieve the number of arguments. 2310d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor unsigned arg_size() const { return NumArgs; } 2311d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor 2312d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor typedef Expr** arg_iterator; 2313d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor arg_iterator arg_begin() { return reinterpret_cast<Expr**>(this + 1); } 2314d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor arg_iterator arg_end() { return arg_begin() + NumArgs; } 2315d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor 23161dd7383dc48718c452e71a625b29531dd96fbb9dJohn McCall typedef const Expr* const * const_arg_iterator; 23171dd7383dc48718c452e71a625b29531dd96fbb9dJohn McCall const_arg_iterator arg_begin() const { 23181dd7383dc48718c452e71a625b29531dd96fbb9dJohn McCall return reinterpret_cast<const Expr* const *>(this + 1); 23191dd7383dc48718c452e71a625b29531dd96fbb9dJohn McCall } 23201dd7383dc48718c452e71a625b29531dd96fbb9dJohn McCall const_arg_iterator arg_end() const { 23211dd7383dc48718c452e71a625b29531dd96fbb9dJohn McCall return arg_begin() + NumArgs; 23221dd7383dc48718c452e71a625b29531dd96fbb9dJohn McCall } 23231dd7383dc48718c452e71a625b29531dd96fbb9dJohn McCall 2324d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor Expr *getArg(unsigned I) { 2325d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor assert(I < NumArgs && "Argument index out-of-range"); 2326d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor return *(arg_begin() + I); 2327d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor } 2328d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor 23291dd7383dc48718c452e71a625b29531dd96fbb9dJohn McCall const Expr *getArg(unsigned I) const { 23301dd7383dc48718c452e71a625b29531dd96fbb9dJohn McCall assert(I < NumArgs && "Argument index out-of-range"); 23311dd7383dc48718c452e71a625b29531dd96fbb9dJohn McCall return *(arg_begin() + I); 23321dd7383dc48718c452e71a625b29531dd96fbb9dJohn McCall } 23331dd7383dc48718c452e71a625b29531dd96fbb9dJohn McCall 23348dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis void setArg(unsigned I, Expr *E) { 23358dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis assert(I < NumArgs && "Argument index out-of-range"); 23368dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis *(arg_begin() + I) = E; 23378dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis } 23388dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis 233963c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall SourceRange getSourceRange() const; 2340ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 23411eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump static bool classof(const Stmt *T) { 2342d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor return T->getStmtClass() == CXXUnresolvedConstructExprClass; 2343d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor } 2344d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor static bool classof(const CXXUnresolvedConstructExpr *) { return true; } 2345d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor 2346d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor // Iterators 234763c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall child_range children() { 234863c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall Stmt **begin = reinterpret_cast<Stmt**>(this+1); 234963c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall return child_range(begin, begin + NumArgs); 235063c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall } 2351d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor}; 2352d81e6ca6e378c3996a139066a5c4b7fc1869630cDouglas Gregor 2353ba13543329afac4a0d01304ec2ec4924d99306a6John McCall/// \brief Represents a C++ member access expression where the actual 2354ba13543329afac4a0d01304ec2ec4924d99306a6John McCall/// member referenced could not be resolved because the base 2355ba13543329afac4a0d01304ec2ec4924d99306a6John McCall/// expression or the member name was dependent. 2356aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall/// 2357aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall/// Like UnresolvedMemberExprs, these can be either implicit or 2358aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall/// explicit accesses. It is only possible to get one of these with 2359aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall/// an implicit access if a qualifier is provided. 2360865d447ac6a4721ab58e898d014a21f2eff74b06John McCallclass CXXDependentScopeMemberExpr : public Expr { 23611c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor /// \brief The expression for the base pointer or class reference, 2362aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall /// e.g., the \c x in x.f. Can be null in implicit accesses. 23631c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor Stmt *Base; 23641eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 2365aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall /// \brief The type of the base expression. Never null, even for 2366aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall /// implicit accesses. 2367aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall QualType BaseType; 2368aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall 23691c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor /// \brief Whether this member expression used the '->' operator or 23701c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor /// the '.' operator. 23713b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor bool IsArrow : 1; 23721c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor 23733b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor /// \brief Whether this member expression has explicitly-specified template 23743b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor /// arguments. 2375aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall bool HasExplicitTemplateArgs : 1; 23761eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 23771c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor /// \brief The location of the '->' or '.' operator. 23781c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor SourceLocation OperatorLoc; 23791c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor 2380a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor /// \brief The nested-name-specifier that precedes the member name, if any. 23817c3179cf463c3b3b8c21dbb955f933ba50b74f28Douglas Gregor NestedNameSpecifierLoc QualifierLoc; 23821eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 2383c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor /// \brief In a qualified member access expression such as t->Base::f, this 23841eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump /// member stores the resolves of name lookup in the context of the member 2385c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor /// access expression, to be used at instantiation time. 2386c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor /// 238746bb4f1a3ac9517406887939612eb8df4b7be006Douglas Gregor /// FIXME: This member, along with the QualifierLoc, could 2388c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor /// be stuck into a structure that is optionally allocated at the end of 2389865d447ac6a4721ab58e898d014a21f2eff74b06John McCall /// the CXXDependentScopeMemberExpr, to save space in the common case. 2390c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor NamedDecl *FirstQualifierFoundInScope; 23911eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 23921c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor /// \brief The member to which this member expression refers, which 23931c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor /// can be name, overloaded operator, or destructor. 2394a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor /// FIXME: could also be a template-id 23952577743c5650c646fb705df01403707e94f2df04Abramo Bagnara DeclarationNameInfo MemberNameInfo; 23961eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 2397865d447ac6a4721ab58e898d014a21f2eff74b06John McCall CXXDependentScopeMemberExpr(ASTContext &C, 2398aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall Expr *Base, QualType BaseType, bool IsArrow, 23993b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor SourceLocation OperatorLoc, 24007c3179cf463c3b3b8c21dbb955f933ba50b74f28Douglas Gregor NestedNameSpecifierLoc QualifierLoc, 24013b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor NamedDecl *FirstQualifierFoundInScope, 24022577743c5650c646fb705df01403707e94f2df04Abramo Bagnara DeclarationNameInfo MemberNameInfo, 2403d5532b6cfff2977e0c59fa6ead7f7973984a620dJohn McCall const TemplateArgumentListInfo *TemplateArgs); 24041eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 24051c0ca59416999129d0439c2661d137ef38e86209Douglas Gregorpublic: 2406865d447ac6a4721ab58e898d014a21f2eff74b06John McCall CXXDependentScopeMemberExpr(ASTContext &C, 2407bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor Expr *Base, QualType BaseType, 2408bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor bool IsArrow, 2409bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor SourceLocation OperatorLoc, 24107c3179cf463c3b3b8c21dbb955f933ba50b74f28Douglas Gregor NestedNameSpecifierLoc QualifierLoc, 2411bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor NamedDecl *FirstQualifierFoundInScope, 2412bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor DeclarationNameInfo MemberNameInfo); 24131eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 2414865d447ac6a4721ab58e898d014a21f2eff74b06John McCall static CXXDependentScopeMemberExpr * 24151eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump Create(ASTContext &C, 2416aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall Expr *Base, QualType BaseType, bool IsArrow, 24173b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor SourceLocation OperatorLoc, 24187c3179cf463c3b3b8c21dbb955f933ba50b74f28Douglas Gregor NestedNameSpecifierLoc QualifierLoc, 24193b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor NamedDecl *FirstQualifierFoundInScope, 24202577743c5650c646fb705df01403707e94f2df04Abramo Bagnara DeclarationNameInfo MemberNameInfo, 2421d5532b6cfff2977e0c59fa6ead7f7973984a620dJohn McCall const TemplateArgumentListInfo *TemplateArgs); 24221eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 24238dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis static CXXDependentScopeMemberExpr * 2424ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie CreateEmpty(ASTContext &C, bool HasExplicitTemplateArgs, 2425def0354384d9c4431f7b58b664b59896d4623028Douglas Gregor unsigned NumTemplateArgs); 24268dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis 2427aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall /// \brief True if this is an implicit access, i.e. one in which the 2428aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall /// member being accessed was not written in the source. The source 2429aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall /// location of the operator is invalid in this case. 24304c9be89bb615ec07eb3ed507c8fa9d0baa8a5ad7Douglas Gregor bool isImplicitAccess() const; 2431aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall 24321c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor /// \brief Retrieve the base object of this member expressions, 24331c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor /// e.g., the \c x in \c x.m. 2434aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall Expr *getBase() const { 2435aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall assert(!isImplicitAccess()); 2436aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall return cast<Expr>(Base); 2437aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall } 24381c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor 2439aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall QualType getBaseType() const { return BaseType; } 2440aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall 24411c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor /// \brief Determine whether this member expression used the '->' 24421c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor /// operator; otherwise, it used the '.' operator. 24431c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor bool isArrow() const { return IsArrow; } 24441c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor 24451c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor /// \brief Retrieve the location of the '->' or '.' operator. 24461c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor SourceLocation getOperatorLoc() const { return OperatorLoc; } 24471c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor 2448a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor /// \brief Retrieve the nested-name-specifier that qualifies the member 2449a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor /// name. 2450ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie NestedNameSpecifier *getQualifier() const { 2451ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie return QualifierLoc.getNestedNameSpecifier(); 24527c3179cf463c3b3b8c21dbb955f933ba50b74f28Douglas Gregor } 24531eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 24547c3179cf463c3b3b8c21dbb955f933ba50b74f28Douglas Gregor /// \brief Retrieve the nested-name-specifier that qualifies the member 24557c3179cf463c3b3b8c21dbb955f933ba50b74f28Douglas Gregor /// name, with source location information. 24567c3179cf463c3b3b8c21dbb955f933ba50b74f28Douglas Gregor NestedNameSpecifierLoc getQualifierLoc() const { return QualifierLoc; } 2457ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 2458ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 2459c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor /// \brief Retrieve the first part of the nested-name-specifier that was 2460c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor /// found in the scope of the member access expression when the member access 2461c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor /// was initially parsed. 2462c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor /// 2463c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor /// This function only returns a useful result when member access expression 24641eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump /// uses a qualified member name, e.g., "x.Base::f". Here, the declaration 24651eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump /// returned by this function describes what was found by unqualified name 2466c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor /// lookup for the identifier "Base" within the scope of the member access 2467c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor /// expression itself. At template instantiation time, this information is 2468c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor /// combined with the results of name lookup into the type of the object 2469c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor /// expression itself (the class type of x). 24701eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump NamedDecl *getFirstQualifierFoundInScope() const { 2471c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor return FirstQualifierFoundInScope; 2472c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor } 24731eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 24741c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor /// \brief Retrieve the name of the member that this expression 24751c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor /// refers to. 24762577743c5650c646fb705df01403707e94f2df04Abramo Bagnara const DeclarationNameInfo &getMemberNameInfo() const { 24772577743c5650c646fb705df01403707e94f2df04Abramo Bagnara return MemberNameInfo; 24782577743c5650c646fb705df01403707e94f2df04Abramo Bagnara } 24792577743c5650c646fb705df01403707e94f2df04Abramo Bagnara 24802577743c5650c646fb705df01403707e94f2df04Abramo Bagnara /// \brief Retrieve the name of the member that this expression 24812577743c5650c646fb705df01403707e94f2df04Abramo Bagnara /// refers to. 24822577743c5650c646fb705df01403707e94f2df04Abramo Bagnara DeclarationName getMember() const { return MemberNameInfo.getName(); } 24831c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor 24841c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor // \brief Retrieve the location of the name of the member that this 24851c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor // expression refers to. 24862577743c5650c646fb705df01403707e94f2df04Abramo Bagnara SourceLocation getMemberLoc() const { return MemberNameInfo.getLoc(); } 24871c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor 24883b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor /// \brief Determines whether this member expression actually had a C++ 24893b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor /// template argument list explicitly specified, e.g., x.f<int>. 2490aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall bool hasExplicitTemplateArgs() const { 2491aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall return HasExplicitTemplateArgs; 24923b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor } 24931eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 249436c76f0bea0d3595a25a5362225c642019cc3176Argyrios Kyrtzidis /// \brief Retrieve the explicit template argument list that followed the 249536c76f0bea0d3595a25a5362225c642019cc3176Argyrios Kyrtzidis /// member template name, if any. 2496b0c3e0909bb04af0bfb82ad01ab6909649d68ccaArgyrios Kyrtzidis ASTTemplateArgumentListInfo &getExplicitTemplateArgs() { 249736c76f0bea0d3595a25a5362225c642019cc3176Argyrios Kyrtzidis assert(HasExplicitTemplateArgs); 2498b0c3e0909bb04af0bfb82ad01ab6909649d68ccaArgyrios Kyrtzidis return *reinterpret_cast<ASTTemplateArgumentListInfo *>(this + 1); 249936c76f0bea0d3595a25a5362225c642019cc3176Argyrios Kyrtzidis } 250036c76f0bea0d3595a25a5362225c642019cc3176Argyrios Kyrtzidis 250136c76f0bea0d3595a25a5362225c642019cc3176Argyrios Kyrtzidis /// \brief Retrieve the explicit template argument list that followed the 250236c76f0bea0d3595a25a5362225c642019cc3176Argyrios Kyrtzidis /// member template name, if any. 2503b0c3e0909bb04af0bfb82ad01ab6909649d68ccaArgyrios Kyrtzidis const ASTTemplateArgumentListInfo &getExplicitTemplateArgs() const { 250436c76f0bea0d3595a25a5362225c642019cc3176Argyrios Kyrtzidis return const_cast<CXXDependentScopeMemberExpr *>(this) 2505096832c5ed5b9106fa177ebc148489760c3bc496John McCall ->getExplicitTemplateArgs(); 2506096832c5ed5b9106fa177ebc148489760c3bc496John McCall } 2507096832c5ed5b9106fa177ebc148489760c3bc496John McCall 2508096832c5ed5b9106fa177ebc148489760c3bc496John McCall /// \brief Retrieves the optional explicit template arguments. 2509096832c5ed5b9106fa177ebc148489760c3bc496John McCall /// This points to the same data as getExplicitTemplateArgs(), but 2510096832c5ed5b9106fa177ebc148489760c3bc496John McCall /// returns null if there are no explicit template arguments. 2511b0c3e0909bb04af0bfb82ad01ab6909649d68ccaArgyrios Kyrtzidis const ASTTemplateArgumentListInfo *getOptionalExplicitTemplateArgs() { 2512096832c5ed5b9106fa177ebc148489760c3bc496John McCall if (!hasExplicitTemplateArgs()) return 0; 2513096832c5ed5b9106fa177ebc148489760c3bc496John McCall return &getExplicitTemplateArgs(); 251436c76f0bea0d3595a25a5362225c642019cc3176Argyrios Kyrtzidis } 251536c76f0bea0d3595a25a5362225c642019cc3176Argyrios Kyrtzidis 2516d5532b6cfff2977e0c59fa6ead7f7973984a620dJohn McCall /// \brief Copies the template arguments (if present) into the given 2517d5532b6cfff2977e0c59fa6ead7f7973984a620dJohn McCall /// structure. 2518d5532b6cfff2977e0c59fa6ead7f7973984a620dJohn McCall void copyTemplateArgumentsInto(TemplateArgumentListInfo &List) const { 2519096832c5ed5b9106fa177ebc148489760c3bc496John McCall getExplicitTemplateArgs().copyInto(List); 2520d5532b6cfff2977e0c59fa6ead7f7973984a620dJohn McCall } 2521d5532b6cfff2977e0c59fa6ead7f7973984a620dJohn McCall 25228dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis /// \brief Initializes the template arguments using the given structure. 25238dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis void initializeTemplateArgumentsFrom(const TemplateArgumentListInfo &List) { 2524096832c5ed5b9106fa177ebc148489760c3bc496John McCall getExplicitTemplateArgs().initializeFrom(List); 25258dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis } 25268dfbd8b252ba4e6cf4b7a3422f6ef0ca21312dfeArgyrios Kyrtzidis 25271eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump /// \brief Retrieve the location of the left angle bracket following the 25283b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor /// member name ('<'), if any. 25291eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump SourceLocation getLAngleLoc() const { 2530096832c5ed5b9106fa177ebc148489760c3bc496John McCall return getExplicitTemplateArgs().LAngleLoc; 25313b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor } 25321eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 25333b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor /// \brief Retrieve the template arguments provided as part of this 25343b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor /// template-id. 2535833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall const TemplateArgumentLoc *getTemplateArgs() const { 2536096832c5ed5b9106fa177ebc148489760c3bc496John McCall return getExplicitTemplateArgs().getTemplateArgs(); 25373b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor } 25381eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 25393b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor /// \brief Retrieve the number of template arguments provided as part of this 25403b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor /// template-id. 25411eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump unsigned getNumTemplateArgs() const { 2542096832c5ed5b9106fa177ebc148489760c3bc496John McCall return getExplicitTemplateArgs().NumTemplateArgs; 25433b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor } 25441eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 25451eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump /// \brief Retrieve the location of the right angle bracket following the 25463b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor /// template arguments ('>'). 25471eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump SourceLocation getRAngleLoc() const { 2548096832c5ed5b9106fa177ebc148489760c3bc496John McCall return getExplicitTemplateArgs().RAngleLoc; 25493b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor } 25501eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 255163c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall SourceRange getSourceRange() const { 2552aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall SourceRange Range; 2553aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall if (!isImplicitAccess()) 2554aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall Range.setBegin(Base->getSourceRange().getBegin()); 2555aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall else if (getQualifier()) 25567c3179cf463c3b3b8c21dbb955f933ba50b74f28Douglas Gregor Range.setBegin(getQualifierLoc().getBeginLoc()); 2557aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall else 25582577743c5650c646fb705df01403707e94f2df04Abramo Bagnara Range.setBegin(MemberNameInfo.getBeginLoc()); 25591eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 2560aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall if (hasExplicitTemplateArgs()) 2561aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall Range.setEnd(getRAngleLoc()); 2562aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall else 25632577743c5650c646fb705df01403707e94f2df04Abramo Bagnara Range.setEnd(MemberNameInfo.getEndLoc()); 2564aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall return Range; 25651c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor } 25661eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 25671eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump static bool classof(const Stmt *T) { 2568865d447ac6a4721ab58e898d014a21f2eff74b06John McCall return T->getStmtClass() == CXXDependentScopeMemberExprClass; 25691c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor } 2570865d447ac6a4721ab58e898d014a21f2eff74b06John McCall static bool classof(const CXXDependentScopeMemberExpr *) { return true; } 25711c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor 25721c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor // Iterators 257363c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall child_range children() { 257463c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall if (isImplicitAccess()) return child_range(); 257563c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall return child_range(&Base, &Base + 1); 257663c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall } 25774045107b7384fd68eed5e3e2f06fc2a47e7be0a6Argyrios Kyrtzidis 25784045107b7384fd68eed5e3e2f06fc2a47e7be0a6Argyrios Kyrtzidis friend class ASTStmtReader; 25794045107b7384fd68eed5e3e2f06fc2a47e7be0a6Argyrios Kyrtzidis friend class ASTStmtWriter; 25801c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor}; 25811c0ca59416999129d0439c2661d137ef38e86209Douglas Gregor 2582129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall/// \brief Represents a C++ member access expression for which lookup 2583aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall/// produced a set of overloaded functions. 2584aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall/// 2585aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall/// The member access may be explicit or implicit: 2586aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall/// struct A { 2587aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall/// int a, b; 2588aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall/// int explicitAccess() { return this->a + this->A::b; } 2589aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall/// int implicitAccess() { return a + A::b; } 2590aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall/// }; 2591aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall/// 2592aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall/// In the final AST, an explicit access always becomes a MemberExpr. 2593aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall/// An implicit access may become either a MemberExpr or a 2594aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall/// DeclRefExpr, depending on whether the member is static. 25957bb12da2b0749eeebb21854c77877736969e59f2John McCallclass UnresolvedMemberExpr : public OverloadExpr { 2596129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall /// \brief Whether this member expression used the '->' operator or 2597129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall /// the '.' operator. 2598129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall bool IsArrow : 1; 2599129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall 2600129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall /// \brief Whether the lookup results contain an unresolved using 2601129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall /// declaration. 2602129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall bool HasUnresolvedUsing : 1; 2603129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall 26047bb12da2b0749eeebb21854c77877736969e59f2John McCall /// \brief The expression for the base pointer or class reference, 26057bb12da2b0749eeebb21854c77877736969e59f2John McCall /// e.g., the \c x in x.f. This can be null if this is an 'unbased' 26067bb12da2b0749eeebb21854c77877736969e59f2John McCall /// member expression 26077bb12da2b0749eeebb21854c77877736969e59f2John McCall Stmt *Base; 26087bb12da2b0749eeebb21854c77877736969e59f2John McCall 26097bb12da2b0749eeebb21854c77877736969e59f2John McCall /// \brief The type of the base expression; never null. 26107bb12da2b0749eeebb21854c77877736969e59f2John McCall QualType BaseType; 2611129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall 2612129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall /// \brief The location of the '->' or '.' operator. 2613129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall SourceLocation OperatorLoc; 2614129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall 2615bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor UnresolvedMemberExpr(ASTContext &C, bool HasUnresolvedUsing, 2616aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall Expr *Base, QualType BaseType, bool IsArrow, 2617129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall SourceLocation OperatorLoc, 26184c9be89bb615ec07eb3ed507c8fa9d0baa8a5ad7Douglas Gregor NestedNameSpecifierLoc QualifierLoc, 26192577743c5650c646fb705df01403707e94f2df04Abramo Bagnara const DeclarationNameInfo &MemberNameInfo, 26205a84dec38cfa9e084377a3167b474c79283c82faDouglas Gregor const TemplateArgumentListInfo *TemplateArgs, 26215a84dec38cfa9e084377a3167b474c79283c82faDouglas Gregor UnresolvedSetIterator Begin, UnresolvedSetIterator End); 2622ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 2623a77eb0862507b900a10fa352af1568e639ed10b1Argyrios Kyrtzidis UnresolvedMemberExpr(EmptyShell Empty) 2624a77eb0862507b900a10fa352af1568e639ed10b1Argyrios Kyrtzidis : OverloadExpr(UnresolvedMemberExprClass, Empty), IsArrow(false), 2625a77eb0862507b900a10fa352af1568e639ed10b1Argyrios Kyrtzidis HasUnresolvedUsing(false), Base(0) { } 2626129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall 26274c9be89bb615ec07eb3ed507c8fa9d0baa8a5ad7Douglas Gregor friend class ASTStmtReader; 2628ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 2629129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCallpublic: 2630129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall static UnresolvedMemberExpr * 2631bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor Create(ASTContext &C, bool HasUnresolvedUsing, 2632aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall Expr *Base, QualType BaseType, bool IsArrow, 2633129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall SourceLocation OperatorLoc, 26344c9be89bb615ec07eb3ed507c8fa9d0baa8a5ad7Douglas Gregor NestedNameSpecifierLoc QualifierLoc, 26352577743c5650c646fb705df01403707e94f2df04Abramo Bagnara const DeclarationNameInfo &MemberNameInfo, 26365a84dec38cfa9e084377a3167b474c79283c82faDouglas Gregor const TemplateArgumentListInfo *TemplateArgs, 26375a84dec38cfa9e084377a3167b474c79283c82faDouglas Gregor UnresolvedSetIterator Begin, UnresolvedSetIterator End); 2638129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall 2639a77eb0862507b900a10fa352af1568e639ed10b1Argyrios Kyrtzidis static UnresolvedMemberExpr * 2640def0354384d9c4431f7b58b664b59896d4623028Douglas Gregor CreateEmpty(ASTContext &C, bool HasExplicitTemplateArgs, 2641def0354384d9c4431f7b58b664b59896d4623028Douglas Gregor unsigned NumTemplateArgs); 2642a77eb0862507b900a10fa352af1568e639ed10b1Argyrios Kyrtzidis 2643aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall /// \brief True if this is an implicit access, i.e. one in which the 2644aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall /// member being accessed was not written in the source. The source 2645aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall /// location of the operator is invalid in this case. 26464c9be89bb615ec07eb3ed507c8fa9d0baa8a5ad7Douglas Gregor bool isImplicitAccess() const; 2647aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall 2648129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall /// \brief Retrieve the base object of this member expressions, 2649129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall /// e.g., the \c x in \c x.m. 2650aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall Expr *getBase() { 2651aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall assert(!isImplicitAccess()); 2652aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall return cast<Expr>(Base); 2653aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall } 26542f27bf854f0519810b34afd209089cc75536b757John McCall const Expr *getBase() const { 26552f27bf854f0519810b34afd209089cc75536b757John McCall assert(!isImplicitAccess()); 26562f27bf854f0519810b34afd209089cc75536b757John McCall return cast<Expr>(Base); 26572f27bf854f0519810b34afd209089cc75536b757John McCall } 2658129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall 2659aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall QualType getBaseType() const { return BaseType; } 2660a77eb0862507b900a10fa352af1568e639ed10b1Argyrios Kyrtzidis 2661a77eb0862507b900a10fa352af1568e639ed10b1Argyrios Kyrtzidis /// \brief Determine whether the lookup results contain an unresolved using 2662a77eb0862507b900a10fa352af1568e639ed10b1Argyrios Kyrtzidis /// declaration. 2663a77eb0862507b900a10fa352af1568e639ed10b1Argyrios Kyrtzidis bool hasUnresolvedUsing() const { return HasUnresolvedUsing; } 2664aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall 2665129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall /// \brief Determine whether this member expression used the '->' 2666129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall /// operator; otherwise, it used the '.' operator. 2667129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall bool isArrow() const { return IsArrow; } 2668129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall 2669129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall /// \brief Retrieve the location of the '->' or '.' operator. 2670129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall SourceLocation getOperatorLoc() const { return OperatorLoc; } 2671129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall 2672c373d48502ca7683ab55385f5bd624d778eb288dJohn McCall /// \brief Retrieves the naming class of this lookup. 2673c373d48502ca7683ab55385f5bd624d778eb288dJohn McCall CXXRecordDecl *getNamingClass() const; 2674c373d48502ca7683ab55385f5bd624d778eb288dJohn McCall 26752577743c5650c646fb705df01403707e94f2df04Abramo Bagnara /// \brief Retrieve the full name info for the member that this expression 26762577743c5650c646fb705df01403707e94f2df04Abramo Bagnara /// refers to. 26772577743c5650c646fb705df01403707e94f2df04Abramo Bagnara const DeclarationNameInfo &getMemberNameInfo() const { return getNameInfo(); } 26782577743c5650c646fb705df01403707e94f2df04Abramo Bagnara 2679129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall /// \brief Retrieve the name of the member that this expression 2680129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall /// refers to. 26817bb12da2b0749eeebb21854c77877736969e59f2John McCall DeclarationName getMemberName() const { return getName(); } 2682129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall 2683129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall // \brief Retrieve the location of the name of the member that this 2684129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall // expression refers to. 26857bb12da2b0749eeebb21854c77877736969e59f2John McCall SourceLocation getMemberLoc() const { return getNameLoc(); } 2686129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall 26877bb12da2b0749eeebb21854c77877736969e59f2John McCall /// \brief Retrieve the explicit template argument list that followed the 26887bb12da2b0749eeebb21854c77877736969e59f2John McCall /// member template name. 2689b0c3e0909bb04af0bfb82ad01ab6909649d68ccaArgyrios Kyrtzidis ASTTemplateArgumentListInfo &getExplicitTemplateArgs() { 26907bb12da2b0749eeebb21854c77877736969e59f2John McCall assert(hasExplicitTemplateArgs()); 2691b0c3e0909bb04af0bfb82ad01ab6909649d68ccaArgyrios Kyrtzidis return *reinterpret_cast<ASTTemplateArgumentListInfo *>(this + 1); 26927bb12da2b0749eeebb21854c77877736969e59f2John McCall } 26937bb12da2b0749eeebb21854c77877736969e59f2John McCall 26947bb12da2b0749eeebb21854c77877736969e59f2John McCall /// \brief Retrieve the explicit template argument list that followed the 26957bb12da2b0749eeebb21854c77877736969e59f2John McCall /// member template name, if any. 2696b0c3e0909bb04af0bfb82ad01ab6909649d68ccaArgyrios Kyrtzidis const ASTTemplateArgumentListInfo &getExplicitTemplateArgs() const { 26977bb12da2b0749eeebb21854c77877736969e59f2John McCall assert(hasExplicitTemplateArgs()); 2698b0c3e0909bb04af0bfb82ad01ab6909649d68ccaArgyrios Kyrtzidis return *reinterpret_cast<const ASTTemplateArgumentListInfo *>(this + 1); 2699129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall } 2700129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall 2701096832c5ed5b9106fa177ebc148489760c3bc496John McCall /// \brief Retrieves the optional explicit template arguments. 2702096832c5ed5b9106fa177ebc148489760c3bc496John McCall /// This points to the same data as getExplicitTemplateArgs(), but 2703096832c5ed5b9106fa177ebc148489760c3bc496John McCall /// returns null if there are no explicit template arguments. 2704b0c3e0909bb04af0bfb82ad01ab6909649d68ccaArgyrios Kyrtzidis const ASTTemplateArgumentListInfo *getOptionalExplicitTemplateArgs() { 2705096832c5ed5b9106fa177ebc148489760c3bc496John McCall if (!hasExplicitTemplateArgs()) return 0; 2706096832c5ed5b9106fa177ebc148489760c3bc496John McCall return &getExplicitTemplateArgs(); 2707096832c5ed5b9106fa177ebc148489760c3bc496John McCall } 2708096832c5ed5b9106fa177ebc148489760c3bc496John McCall 2709129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall /// \brief Copies the template arguments into the given structure. 2710129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall void copyTemplateArgumentsInto(TemplateArgumentListInfo &List) const { 27117bb12da2b0749eeebb21854c77877736969e59f2John McCall getExplicitTemplateArgs().copyInto(List); 2712129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall } 2713129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall 2714129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall /// \brief Retrieve the location of the left angle bracket following 2715129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall /// the member name ('<'). 2716129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall SourceLocation getLAngleLoc() const { 27177bb12da2b0749eeebb21854c77877736969e59f2John McCall return getExplicitTemplateArgs().LAngleLoc; 2718129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall } 2719129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall 2720129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall /// \brief Retrieve the template arguments provided as part of this 2721129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall /// template-id. 2722129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall const TemplateArgumentLoc *getTemplateArgs() const { 27237bb12da2b0749eeebb21854c77877736969e59f2John McCall return getExplicitTemplateArgs().getTemplateArgs(); 2724129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall } 2725129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall 2726129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall /// \brief Retrieve the number of template arguments provided as 2727129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall /// part of this template-id. 2728129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall unsigned getNumTemplateArgs() const { 27297bb12da2b0749eeebb21854c77877736969e59f2John McCall return getExplicitTemplateArgs().NumTemplateArgs; 2730129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall } 2731129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall 2732129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall /// \brief Retrieve the location of the right angle bracket 2733129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall /// following the template arguments ('>'). 2734129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall SourceLocation getRAngleLoc() const { 27357bb12da2b0749eeebb21854c77877736969e59f2John McCall return getExplicitTemplateArgs().RAngleLoc; 2736129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall } 2737129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall 273863c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall SourceRange getSourceRange() const { 27392577743c5650c646fb705df01403707e94f2df04Abramo Bagnara SourceRange Range = getMemberNameInfo().getSourceRange(); 2740aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall if (!isImplicitAccess()) 2741aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall Range.setBegin(Base->getSourceRange().getBegin()); 27424c9be89bb615ec07eb3ed507c8fa9d0baa8a5ad7Douglas Gregor else if (getQualifierLoc()) 27434c9be89bb615ec07eb3ed507c8fa9d0baa8a5ad7Douglas Gregor Range.setBegin(getQualifierLoc().getBeginLoc()); 2744aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall 2745129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall if (hasExplicitTemplateArgs()) 2746129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall Range.setEnd(getRAngleLoc()); 2747129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall return Range; 2748129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall } 2749129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall 2750129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall static bool classof(const Stmt *T) { 2751129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall return T->getStmtClass() == UnresolvedMemberExprClass; 2752129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall } 2753129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall static bool classof(const UnresolvedMemberExpr *) { return true; } 2754129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall 2755129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall // Iterators 275663c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall child_range children() { 275763c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall if (isImplicitAccess()) return child_range(); 275863c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall return child_range(&Base, &Base + 1); 275963c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall } 2760129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall}; 2761129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall 27622e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl/// \brief Represents a C++0x noexcept expression (C++ [expr.unary.noexcept]). 27632e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl/// 27642e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl/// The noexcept expression tests whether a given expression might throw. Its 27652e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl/// result is a boolean constant. 27662e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redlclass CXXNoexceptExpr : public Expr { 27672e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl bool Value : 1; 27682e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl Stmt *Operand; 27692e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl SourceRange Range; 27702e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl 2771c8aecc2dfb2e393d9eeaedeca22ff8cd7149af81Sebastian Redl friend class ASTStmtReader; 2772c8aecc2dfb2e393d9eeaedeca22ff8cd7149af81Sebastian Redl 27732e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redlpublic: 27742e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl CXXNoexceptExpr(QualType Ty, Expr *Operand, CanThrowResult Val, 27752e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl SourceLocation Keyword, SourceLocation RParen) 2776f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall : Expr(CXXNoexceptExprClass, Ty, VK_RValue, OK_Ordinary, 2777f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall /*TypeDependent*/false, 2778bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor /*ValueDependent*/Val == CT_Dependent, 2779561f81243f665cf2001caadc45df505f826b72d6Douglas Gregor Val == CT_Dependent || Operand->isInstantiationDependent(), 2780bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor Operand->containsUnexpandedParameterPack()), 27816b219d082434394c1ac401390ec1d1967727815aSebastian Redl Value(Val == CT_Cannot), Operand(Operand), Range(Keyword, RParen) 27826b219d082434394c1ac401390ec1d1967727815aSebastian Redl { } 27836b219d082434394c1ac401390ec1d1967727815aSebastian Redl 27846b219d082434394c1ac401390ec1d1967727815aSebastian Redl CXXNoexceptExpr(EmptyShell Empty) 27856b219d082434394c1ac401390ec1d1967727815aSebastian Redl : Expr(CXXNoexceptExprClass, Empty) 27862e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl { } 27872e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl 27882e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl Expr *getOperand() const { return static_cast<Expr*>(Operand); } 27892e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl 279063c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall SourceRange getSourceRange() const { return Range; } 27912e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl 27922e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl bool getValue() const { return Value; } 27932e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl 27942e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl static bool classof(const Stmt *T) { 27952e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl return T->getStmtClass() == CXXNoexceptExprClass; 27962e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl } 27972e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl static bool classof(const CXXNoexceptExpr *) { return true; } 27982e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl 27992e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl // Iterators 280063c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall child_range children() { return child_range(&Operand, &Operand + 1); } 28012e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl}; 28022e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl 2803ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie/// \brief Represents a C++0x pack expansion that produces a sequence of 2804be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor/// expressions. 2805be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor/// 2806be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor/// A pack expansion expression contains a pattern (which itself is an 2807be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor/// expression) followed by an ellipsis. For example: 2808be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor/// 2809be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor/// \code 2810be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor/// template<typename F, typename ...Types> 2811be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor/// void forward(F f, Types &&...args) { 2812be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor/// f(static_cast<Types&&>(args)...); 2813be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor/// } 2814be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor/// \endcode 2815be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor/// 2816be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor/// Here, the argument to the function object \c f is a pack expansion whose 2817ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie/// pattern is \c static_cast<Types&&>(args). When the \c forward function 2818be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor/// template is instantiated, the pack expansion will instantiate to zero or 2819be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor/// or more function arguments to the function object \c f. 2820be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregorclass PackExpansionExpr : public Expr { 2821be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor SourceLocation EllipsisLoc; 2822ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 282367fd1251aad51bb80d050b7fa5e506fef0ec8e02Douglas Gregor /// \brief The number of expansions that will be produced by this pack 282467fd1251aad51bb80d050b7fa5e506fef0ec8e02Douglas Gregor /// expansion expression, if known. 282567fd1251aad51bb80d050b7fa5e506fef0ec8e02Douglas Gregor /// 282667fd1251aad51bb80d050b7fa5e506fef0ec8e02Douglas Gregor /// When zero, the number of expansions is not known. Otherwise, this value 282767fd1251aad51bb80d050b7fa5e506fef0ec8e02Douglas Gregor /// is the number of expansions + 1. 282867fd1251aad51bb80d050b7fa5e506fef0ec8e02Douglas Gregor unsigned NumExpansions; 2829ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 2830be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor Stmt *Pattern; 2831ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 2832be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor friend class ASTStmtReader; 283367fd1251aad51bb80d050b7fa5e506fef0ec8e02Douglas Gregor friend class ASTStmtWriter; 2834ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 2835be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregorpublic: 283667fd1251aad51bb80d050b7fa5e506fef0ec8e02Douglas Gregor PackExpansionExpr(QualType T, Expr *Pattern, SourceLocation EllipsisLoc, 283767fd1251aad51bb80d050b7fa5e506fef0ec8e02Douglas Gregor llvm::Optional<unsigned> NumExpansions) 2838ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie : Expr(PackExpansionExprClass, T, Pattern->getValueKind(), 2839ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie Pattern->getObjectKind(), /*TypeDependent=*/true, 2840561f81243f665cf2001caadc45df505f826b72d6Douglas Gregor /*ValueDependent=*/true, /*InstantiationDependent=*/true, 2841561f81243f665cf2001caadc45df505f826b72d6Douglas Gregor /*ContainsUnexpandedParameterPack=*/false), 2842be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor EllipsisLoc(EllipsisLoc), 284367fd1251aad51bb80d050b7fa5e506fef0ec8e02Douglas Gregor NumExpansions(NumExpansions? *NumExpansions + 1 : 0), 2844be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor Pattern(Pattern) { } 2845be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor 2846be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor PackExpansionExpr(EmptyShell Empty) : Expr(PackExpansionExprClass, Empty) { } 2847ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 2848be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor /// \brief Retrieve the pattern of the pack expansion. 2849be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor Expr *getPattern() { return reinterpret_cast<Expr *>(Pattern); } 2850be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor 2851be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor /// \brief Retrieve the pattern of the pack expansion. 2852be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor const Expr *getPattern() const { return reinterpret_cast<Expr *>(Pattern); } 2853be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor 2854be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor /// \brief Retrieve the location of the ellipsis that describes this pack 2855be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor /// expansion. 2856be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor SourceLocation getEllipsisLoc() const { return EllipsisLoc; } 2857ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 2858ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie /// \brief Determine the number of expansions that will be produced when 285967fd1251aad51bb80d050b7fa5e506fef0ec8e02Douglas Gregor /// this pack expansion is instantiated, if already known. 286067fd1251aad51bb80d050b7fa5e506fef0ec8e02Douglas Gregor llvm::Optional<unsigned> getNumExpansions() const { 286167fd1251aad51bb80d050b7fa5e506fef0ec8e02Douglas Gregor if (NumExpansions) 286267fd1251aad51bb80d050b7fa5e506fef0ec8e02Douglas Gregor return NumExpansions - 1; 2863ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 286467fd1251aad51bb80d050b7fa5e506fef0ec8e02Douglas Gregor return llvm::Optional<unsigned>(); 286567fd1251aad51bb80d050b7fa5e506fef0ec8e02Douglas Gregor } 2866ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 286763c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall SourceRange getSourceRange() const { 286863c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall return SourceRange(Pattern->getLocStart(), EllipsisLoc); 286963c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall } 2870be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor 2871be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor static bool classof(const Stmt *T) { 2872be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor return T->getStmtClass() == PackExpansionExprClass; 2873be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor } 2874be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor static bool classof(const PackExpansionExpr *) { return true; } 2875ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 2876be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor // Iterators 287763c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall child_range children() { 287863c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall return child_range(&Pattern, &Pattern + 1); 287963c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall } 2880be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor}; 2881ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 2882b0c3e0909bb04af0bfb82ad01ab6909649d68ccaArgyrios Kyrtzidisinline ASTTemplateArgumentListInfo &OverloadExpr::getExplicitTemplateArgs() { 28837bb12da2b0749eeebb21854c77877736969e59f2John McCall if (isa<UnresolvedLookupExpr>(this)) 28847bb12da2b0749eeebb21854c77877736969e59f2John McCall return cast<UnresolvedLookupExpr>(this)->getExplicitTemplateArgs(); 28857bb12da2b0749eeebb21854c77877736969e59f2John McCall else 28867bb12da2b0749eeebb21854c77877736969e59f2John McCall return cast<UnresolvedMemberExpr>(this)->getExplicitTemplateArgs(); 28877bb12da2b0749eeebb21854c77877736969e59f2John McCall} 28887bb12da2b0749eeebb21854c77877736969e59f2John McCall 2889ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie/// \brief Represents an expression that computes the length of a parameter 2890ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor/// pack. 2891ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor/// 2892ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor/// \code 2893ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor/// template<typename ...Types> 2894ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor/// struct count { 2895ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor/// static const unsigned value = sizeof...(Types); 2896ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor/// }; 2897ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor/// \endcode 2898ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregorclass SizeOfPackExpr : public Expr { 2899ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor /// \brief The location of the 'sizeof' keyword. 2900ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor SourceLocation OperatorLoc; 2901ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 2902ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor /// \brief The location of the name of the parameter pack. 2903ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor SourceLocation PackLoc; 2904ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 2905ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor /// \brief The location of the closing parenthesis. 2906ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor SourceLocation RParenLoc; 2907ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 2908ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor /// \brief The length of the parameter pack, if known. 2909ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor /// 2910ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor /// When this expression is value-dependent, the length of the parameter pack 2911ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor /// is unknown. When this expression is not value-dependent, the length is 2912ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor /// known. 2913ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor unsigned Length; 2914ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 2915ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor /// \brief The parameter pack itself. 2916ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor NamedDecl *Pack; 2917ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 2918ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor friend class ASTStmtReader; 2919ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor friend class ASTStmtWriter; 2920ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 2921ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregorpublic: 2922ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor /// \brief Creates a value-dependent expression that computes the length of 2923ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor /// the given parameter pack. 2924ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie SizeOfPackExpr(QualType SizeType, SourceLocation OperatorLoc, NamedDecl *Pack, 2925ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor SourceLocation PackLoc, SourceLocation RParenLoc) 2926ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor : Expr(SizeOfPackExprClass, SizeType, VK_RValue, OK_Ordinary, 2927ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor /*TypeDependent=*/false, /*ValueDependent=*/true, 2928561f81243f665cf2001caadc45df505f826b72d6Douglas Gregor /*InstantiationDependent=*/true, 2929ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor /*ContainsUnexpandedParameterPack=*/false), 2930ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor OperatorLoc(OperatorLoc), PackLoc(PackLoc), RParenLoc(RParenLoc), 2931ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor Length(0), Pack(Pack) { } 2932ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor 2933ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor /// \brief Creates an expression that computes the length of 2934ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor /// the given parameter pack, which is already known. 2935ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie SizeOfPackExpr(QualType SizeType, SourceLocation OperatorLoc, NamedDecl *Pack, 2936ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor SourceLocation PackLoc, SourceLocation RParenLoc, 2937ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor unsigned Length) 2938ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor : Expr(SizeOfPackExprClass, SizeType, VK_RValue, OK_Ordinary, 2939ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor /*TypeDependent=*/false, /*ValueDependent=*/false, 2940561f81243f665cf2001caadc45df505f826b72d6Douglas Gregor /*InstantiationDependent=*/false, 2941ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor /*ContainsUnexpandedParameterPack=*/false), 2942ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor OperatorLoc(OperatorLoc), PackLoc(PackLoc), RParenLoc(RParenLoc), 2943ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor Length(Length), Pack(Pack) { } 2944ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor 2945ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor /// \brief Create an empty expression. 2946ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor SizeOfPackExpr(EmptyShell Empty) : Expr(SizeOfPackExprClass, Empty) { } 2947ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 2948ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor /// \brief Determine the location of the 'sizeof' keyword. 2949ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor SourceLocation getOperatorLoc() const { return OperatorLoc; } 2950ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor 2951ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor /// \brief Determine the location of the parameter pack. 2952ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor SourceLocation getPackLoc() const { return PackLoc; } 2953ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 2954ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor /// \brief Determine the location of the right parenthesis. 2955ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor SourceLocation getRParenLoc() const { return RParenLoc; } 2956ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 2957ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor /// \brief Retrieve the parameter pack. 2958ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor NamedDecl *getPack() const { return Pack; } 2959ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 2960ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor /// \brief Retrieve the length of the parameter pack. 2961ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor /// 2962ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie /// This routine may only be invoked when the expression is not 2963c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor /// value-dependent. 2964ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor unsigned getPackLength() const { 2965ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie assert(!isValueDependent() && 2966ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor "Cannot get the length of a value-dependent pack size expression"); 2967ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor return Length; 2968ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor } 2969ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 297063c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall SourceRange getSourceRange() const { 297163c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall return SourceRange(OperatorLoc, RParenLoc); 297263c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall } 2973ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 2974ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor static bool classof(const Stmt *T) { 2975ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor return T->getStmtClass() == SizeOfPackExprClass; 2976ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor } 2977ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor static bool classof(const SizeOfPackExpr *) { return true; } 2978ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 2979ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor // Iterators 298063c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall child_range children() { return child_range(); } 2981ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor}; 2982c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor 298391a5755ad73c5dc1dfb167e448fdd74e75a6df56John McCall/// \brief Represents a reference to a non-type template parameter 298491a5755ad73c5dc1dfb167e448fdd74e75a6df56John McCall/// that has been substituted with a template argument. 298591a5755ad73c5dc1dfb167e448fdd74e75a6df56John McCallclass SubstNonTypeTemplateParmExpr : public Expr { 298691a5755ad73c5dc1dfb167e448fdd74e75a6df56John McCall /// \brief The replaced parameter. 298791a5755ad73c5dc1dfb167e448fdd74e75a6df56John McCall NonTypeTemplateParmDecl *Param; 298891a5755ad73c5dc1dfb167e448fdd74e75a6df56John McCall 298991a5755ad73c5dc1dfb167e448fdd74e75a6df56John McCall /// \brief The replacement expression. 299091a5755ad73c5dc1dfb167e448fdd74e75a6df56John McCall Stmt *Replacement; 299191a5755ad73c5dc1dfb167e448fdd74e75a6df56John McCall 299291a5755ad73c5dc1dfb167e448fdd74e75a6df56John McCall /// \brief The location of the non-type template parameter reference. 299391a5755ad73c5dc1dfb167e448fdd74e75a6df56John McCall SourceLocation NameLoc; 299491a5755ad73c5dc1dfb167e448fdd74e75a6df56John McCall 29957110fd6c32306b3feb97b9edb8064b1b68a54e6bJohn McCall friend class ASTReader; 29967110fd6c32306b3feb97b9edb8064b1b68a54e6bJohn McCall friend class ASTStmtReader; 2997ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie explicit SubstNonTypeTemplateParmExpr(EmptyShell Empty) 29987110fd6c32306b3feb97b9edb8064b1b68a54e6bJohn McCall : Expr(SubstNonTypeTemplateParmExprClass, Empty) { } 29997110fd6c32306b3feb97b9edb8064b1b68a54e6bJohn McCall 300091a5755ad73c5dc1dfb167e448fdd74e75a6df56John McCallpublic: 3001ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie SubstNonTypeTemplateParmExpr(QualType type, 300291a5755ad73c5dc1dfb167e448fdd74e75a6df56John McCall ExprValueKind valueKind, 300391a5755ad73c5dc1dfb167e448fdd74e75a6df56John McCall SourceLocation loc, 300491a5755ad73c5dc1dfb167e448fdd74e75a6df56John McCall NonTypeTemplateParmDecl *param, 300591a5755ad73c5dc1dfb167e448fdd74e75a6df56John McCall Expr *replacement) 300691a5755ad73c5dc1dfb167e448fdd74e75a6df56John McCall : Expr(SubstNonTypeTemplateParmExprClass, type, valueKind, OK_Ordinary, 300791a5755ad73c5dc1dfb167e448fdd74e75a6df56John McCall replacement->isTypeDependent(), replacement->isValueDependent(), 300891a5755ad73c5dc1dfb167e448fdd74e75a6df56John McCall replacement->isInstantiationDependent(), 300991a5755ad73c5dc1dfb167e448fdd74e75a6df56John McCall replacement->containsUnexpandedParameterPack()), 301091a5755ad73c5dc1dfb167e448fdd74e75a6df56John McCall Param(param), Replacement(replacement), NameLoc(loc) {} 301191a5755ad73c5dc1dfb167e448fdd74e75a6df56John McCall 301291a5755ad73c5dc1dfb167e448fdd74e75a6df56John McCall SourceLocation getNameLoc() const { return NameLoc; } 301391a5755ad73c5dc1dfb167e448fdd74e75a6df56John McCall SourceRange getSourceRange() const { return NameLoc; } 301491a5755ad73c5dc1dfb167e448fdd74e75a6df56John McCall 301591a5755ad73c5dc1dfb167e448fdd74e75a6df56John McCall Expr *getReplacement() const { return cast<Expr>(Replacement); } 3016ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 301791a5755ad73c5dc1dfb167e448fdd74e75a6df56John McCall NonTypeTemplateParmDecl *getParameter() const { return Param; } 301891a5755ad73c5dc1dfb167e448fdd74e75a6df56John McCall 301991a5755ad73c5dc1dfb167e448fdd74e75a6df56John McCall static bool classof(const Stmt *s) { 302091a5755ad73c5dc1dfb167e448fdd74e75a6df56John McCall return s->getStmtClass() == SubstNonTypeTemplateParmExprClass; 302191a5755ad73c5dc1dfb167e448fdd74e75a6df56John McCall } 3022ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie static bool classof(const SubstNonTypeTemplateParmExpr *) { 3023ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie return true; 302491a5755ad73c5dc1dfb167e448fdd74e75a6df56John McCall } 3025ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 302691a5755ad73c5dc1dfb167e448fdd74e75a6df56John McCall // Iterators 302791a5755ad73c5dc1dfb167e448fdd74e75a6df56John McCall child_range children() { return child_range(&Replacement, &Replacement+1); } 302891a5755ad73c5dc1dfb167e448fdd74e75a6df56John McCall}; 302991a5755ad73c5dc1dfb167e448fdd74e75a6df56John McCall 3030c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor/// \brief Represents a reference to a non-type template parameter pack that 3031c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor/// has been substituted with a non-template argument pack. 3032c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor/// 3033c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor/// When a pack expansion in the source code contains multiple parameter packs 3034c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor/// and those parameter packs correspond to different levels of template 3035ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie/// parameter lists, this node node is used to represent a non-type template 3036c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor/// parameter pack from an outer level, which has already had its argument pack 3037c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor/// substituted but that still lives within a pack expansion that itself 3038c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor/// could not be instantiated. When actually performing a substitution into 3039c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor/// that pack expansion (e.g., when all template parameters have corresponding 3040c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor/// arguments), this type will be replaced with the appropriate underlying 3041c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor/// expression at the current pack substitution index. 3042c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregorclass SubstNonTypeTemplateParmPackExpr : public Expr { 3043c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor /// \brief The non-type template parameter pack itself. 3044c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor NonTypeTemplateParmDecl *Param; 3045ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 3046c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor /// \brief A pointer to the set of template arguments that this 3047c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor /// parameter pack is instantiated with. 3048c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor const TemplateArgument *Arguments; 3049ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 3050c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor /// \brief The number of template arguments in \c Arguments. 3051c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor unsigned NumArguments; 3052ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 3053c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor /// \brief The location of the non-type template parameter pack reference. 3054c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor SourceLocation NameLoc; 3055ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 30567110fd6c32306b3feb97b9edb8064b1b68a54e6bJohn McCall friend class ASTReader; 3057c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor friend class ASTStmtReader; 3058ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie explicit SubstNonTypeTemplateParmPackExpr(EmptyShell Empty) 30597110fd6c32306b3feb97b9edb8064b1b68a54e6bJohn McCall : Expr(SubstNonTypeTemplateParmPackExprClass, Empty) { } 3060ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 3061c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregorpublic: 3062ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie SubstNonTypeTemplateParmPackExpr(QualType T, 3063c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor NonTypeTemplateParmDecl *Param, 3064c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor SourceLocation NameLoc, 3065c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor const TemplateArgument &ArgPack); 3066ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 3067c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor /// \brief Retrieve the non-type template parameter pack being substituted. 3068c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor NonTypeTemplateParmDecl *getParameterPack() const { return Param; } 3069c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor 3070c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor /// \brief Retrieve the location of the parameter pack name. 3071c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor SourceLocation getParameterPackLocation() const { return NameLoc; } 3072ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 3073c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor /// \brief Retrieve the template argument pack containing the substituted 3074c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor /// template arguments. 3075c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor TemplateArgument getArgumentPack() const; 3076c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor 307763c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall SourceRange getSourceRange() const { return NameLoc; } 3078ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 3079c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor static bool classof(const Stmt *T) { 3080c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor return T->getStmtClass() == SubstNonTypeTemplateParmPackExprClass; 3081c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor } 3082ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie static bool classof(const SubstNonTypeTemplateParmPackExpr *) { 3083ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie return true; 3084c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor } 3085ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 3086c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor // Iterators 308763c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall child_range children() { return child_range(); } 3088c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor}; 308903e80030515c800d1ab44125b9052dfffd1bd04cDouglas Gregor 309003e80030515c800d1ab44125b9052dfffd1bd04cDouglas Gregor/// \brief Represents a prvalue temporary that written into memory so that 309103e80030515c800d1ab44125b9052dfffd1bd04cDouglas Gregor/// a reference can bind to it. 309203e80030515c800d1ab44125b9052dfffd1bd04cDouglas Gregor/// 309303e80030515c800d1ab44125b9052dfffd1bd04cDouglas Gregor/// Prvalue expressions are materialized when they need to have an address 309403e80030515c800d1ab44125b9052dfffd1bd04cDouglas Gregor/// in memory for a reference to bind to. This happens when binding a 309503e80030515c800d1ab44125b9052dfffd1bd04cDouglas Gregor/// reference to the result of a conversion, e.g., 309603e80030515c800d1ab44125b9052dfffd1bd04cDouglas Gregor/// 309703e80030515c800d1ab44125b9052dfffd1bd04cDouglas Gregor/// \code 309803e80030515c800d1ab44125b9052dfffd1bd04cDouglas Gregor/// const int &r = 1.0; 309903e80030515c800d1ab44125b9052dfffd1bd04cDouglas Gregor/// \endcode 310003e80030515c800d1ab44125b9052dfffd1bd04cDouglas Gregor/// 310103e80030515c800d1ab44125b9052dfffd1bd04cDouglas Gregor/// Here, 1.0 is implicitly converted to an \c int. That resulting \c int is 310203e80030515c800d1ab44125b9052dfffd1bd04cDouglas Gregor/// then materialized via a \c MaterializeTemporaryExpr, and the reference 310303e80030515c800d1ab44125b9052dfffd1bd04cDouglas Gregor/// binds to the temporary. \c MaterializeTemporaryExprs are always glvalues 310403e80030515c800d1ab44125b9052dfffd1bd04cDouglas Gregor/// (either an lvalue or an xvalue, depending on the kind of reference binding 310503e80030515c800d1ab44125b9052dfffd1bd04cDouglas Gregor/// to it), maintaining the invariant that references always bind to glvalues. 310603e80030515c800d1ab44125b9052dfffd1bd04cDouglas Gregorclass MaterializeTemporaryExpr : public Expr { 310703e80030515c800d1ab44125b9052dfffd1bd04cDouglas Gregor /// \brief The temporary-generating expression whose value will be 310803e80030515c800d1ab44125b9052dfffd1bd04cDouglas Gregor /// materialized. 310903e80030515c800d1ab44125b9052dfffd1bd04cDouglas Gregor Stmt *Temporary; 3110ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 311103e80030515c800d1ab44125b9052dfffd1bd04cDouglas Gregor friend class ASTStmtReader; 311203e80030515c800d1ab44125b9052dfffd1bd04cDouglas Gregor friend class ASTStmtWriter; 3113ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 311403e80030515c800d1ab44125b9052dfffd1bd04cDouglas Gregorpublic: 3115ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie MaterializeTemporaryExpr(QualType T, Expr *Temporary, 3116b4b7b5034bb8304ed03416635bf64c75c39889fcDouglas Gregor bool BoundToLvalueReference) 3117b4b7b5034bb8304ed03416635bf64c75c39889fcDouglas Gregor : Expr(MaterializeTemporaryExprClass, T, 311803e80030515c800d1ab44125b9052dfffd1bd04cDouglas Gregor BoundToLvalueReference? VK_LValue : VK_XValue, OK_Ordinary, 311903e80030515c800d1ab44125b9052dfffd1bd04cDouglas Gregor Temporary->isTypeDependent(), Temporary->isValueDependent(), 3120561f81243f665cf2001caadc45df505f826b72d6Douglas Gregor Temporary->isInstantiationDependent(), 312103e80030515c800d1ab44125b9052dfffd1bd04cDouglas Gregor Temporary->containsUnexpandedParameterPack()), 312203e80030515c800d1ab44125b9052dfffd1bd04cDouglas Gregor Temporary(Temporary) { } 3123ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 3124ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie MaterializeTemporaryExpr(EmptyShell Empty) 312503e80030515c800d1ab44125b9052dfffd1bd04cDouglas Gregor : Expr(MaterializeTemporaryExprClass, Empty) { } 3126ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 312703e80030515c800d1ab44125b9052dfffd1bd04cDouglas Gregor /// \brief Retrieve the temporary-generating subexpression whose value will 312803e80030515c800d1ab44125b9052dfffd1bd04cDouglas Gregor /// be materialized into a glvalue. 312903e80030515c800d1ab44125b9052dfffd1bd04cDouglas Gregor Expr *GetTemporaryExpr() const { return reinterpret_cast<Expr *>(Temporary); } 3130ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 313103e80030515c800d1ab44125b9052dfffd1bd04cDouglas Gregor /// \brief Determine whether this materialized temporary is bound to an 313203e80030515c800d1ab44125b9052dfffd1bd04cDouglas Gregor /// lvalue reference; otherwise, it's bound to an rvalue reference. 3133ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie bool isBoundToLvalueReference() const { 313403e80030515c800d1ab44125b9052dfffd1bd04cDouglas Gregor return getValueKind() == VK_LValue; 313503e80030515c800d1ab44125b9052dfffd1bd04cDouglas Gregor } 3136ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 313703e80030515c800d1ab44125b9052dfffd1bd04cDouglas Gregor SourceRange getSourceRange() const { return Temporary->getSourceRange(); } 3138ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 313903e80030515c800d1ab44125b9052dfffd1bd04cDouglas Gregor static bool classof(const Stmt *T) { 314003e80030515c800d1ab44125b9052dfffd1bd04cDouglas Gregor return T->getStmtClass() == MaterializeTemporaryExprClass; 314103e80030515c800d1ab44125b9052dfffd1bd04cDouglas Gregor } 3142ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie static bool classof(const MaterializeTemporaryExpr *) { 3143ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie return true; 314403e80030515c800d1ab44125b9052dfffd1bd04cDouglas Gregor } 3145ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 314603e80030515c800d1ab44125b9052dfffd1bd04cDouglas Gregor // Iterators 314703e80030515c800d1ab44125b9052dfffd1bd04cDouglas Gregor child_range children() { return child_range(&Temporary, &Temporary + 1); } 314803e80030515c800d1ab44125b9052dfffd1bd04cDouglas Gregor}; 3149ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 31505f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer} // end namespace clang 31515f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 31525f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer#endif 3153