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//===----------------------------------------------------------------------===//
9010bfc253050626435f006386c0bee4b55329687James Dennett///
10010bfc253050626435f006386c0bee4b55329687James Dennett/// \file
11010bfc253050626435f006386c0bee4b55329687James Dennett/// \brief Defines the clang::Expr interface and subclasses for C++ expressions.
12010bfc253050626435f006386c0bee4b55329687James Dennett///
135f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer//===----------------------------------------------------------------------===//
145f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer
155f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer#ifndef LLVM_CLANG_AST_EXPRCXX_H
165f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer#define LLVM_CLANG_AST_EXPRCXX_H
175f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer
18478851c3ed6bd784e7377dffd8e57b200c1b9ba9Benjamin Kramer#include "clang/AST/Decl.h"
195f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer#include "clang/AST/Expr.h"
20d5532b6cfff2977e0c59fa6ead7f7973984a620dJohn McCall#include "clang/AST/TemplateBase.h"
2130a2e16f6c27f888dd11eba6bbbae1e980078fcbChandler Carruth#include "clang/AST/UnresolvedSet.h"
2201d08018b7cf5ce1601707cfd7a84d22015fc04eDouglas Gregor#include "clang/Basic/ExpressionTraits.h"
236bcf27bb9a4b5c3f79cb44c0e4654a6d7619ad89Stephen Hines#include "clang/AST/LambdaCapture.h"
2401d08018b7cf5ce1601707cfd7a84d22015fc04eDouglas Gregor#include "clang/Basic/TypeTraits.h"
25aa49a7d70e58dac2aeb40664ba16d2ea571b8c95Daniel Dunbar#include "llvm/Support/Compiler.h"
265f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer
275f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencernamespace clang {
285f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer
29aa165f8458b51c546bebff947343e1a36f3594cbDouglas Gregorclass CXXConstructorDecl;
30aa165f8458b51c546bebff947343e1a36f3594cbDouglas Gregorclass CXXDestructorDecl;
31aa165f8458b51c546bebff947343e1a36f3594cbDouglas Gregorclass CXXMethodDecl;
32aa165f8458b51c546bebff947343e1a36f3594cbDouglas Gregorclass CXXTemporary;
3376da55d3a49e1805f51b1ced7c5da5bcd7f759d8John McCallclass MSPropertyDecl;
34aa165f8458b51c546bebff947343e1a36f3594cbDouglas Gregorclass TemplateArgumentListInfo;
352fa67efeaf66a9332c30a026dc1c21bef6c33a6cBenjamin Kramerclass UuidAttr;
364c5d320a7581f4b80b151630c91cea5727fa9923Sebastian Redl
371060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek//===--------------------------------------------------------------------===//
381060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek// C++ Expressions.
391060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek//===--------------------------------------------------------------------===//
401060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek
413fd95ce225393fe4a3623e429766a8c3f487ff9dDouglas Gregor/// \brief A call to an overloaded operator written using operator
423fd95ce225393fe4a3623e429766a8c3f487ff9dDouglas Gregor/// syntax.
433fd95ce225393fe4a3623e429766a8c3f487ff9dDouglas Gregor///
443fd95ce225393fe4a3623e429766a8c3f487ff9dDouglas Gregor/// Represents a call to an overloaded operator written using operator
453fd95ce225393fe4a3623e429766a8c3f487ff9dDouglas Gregor/// syntax, e.g., "x + y" or "*p". While semantically equivalent to a
463fd95ce225393fe4a3623e429766a8c3f487ff9dDouglas Gregor/// normal call, this AST node provides better information about the
473fd95ce225393fe4a3623e429766a8c3f487ff9dDouglas Gregor/// syntactic representation of the call.
483fd95ce225393fe4a3623e429766a8c3f487ff9dDouglas Gregor///
493fd95ce225393fe4a3623e429766a8c3f487ff9dDouglas Gregor/// In a C++ template, this expression node kind will be used whenever
503fd95ce225393fe4a3623e429766a8c3f487ff9dDouglas Gregor/// any of the arguments are type-dependent. In this case, the
513fd95ce225393fe4a3623e429766a8c3f487ff9dDouglas Gregor/// function itself will be a (possibly empty) set of functions and
523fd95ce225393fe4a3623e429766a8c3f487ff9dDouglas Gregor/// function templates that were found by name lookup at template
533fd95ce225393fe4a3623e429766a8c3f487ff9dDouglas Gregor/// definition time.
54b4609806e9232593ece09ce08b630836e825865cDouglas Gregorclass CXXOperatorCallExpr : public CallExpr {
55063daf6e196c51f162e0485478355d8e280eef5cDouglas Gregor  /// \brief The overloaded operator.
56063daf6e196c51f162e0485478355d8e280eef5cDouglas Gregor  OverloadedOperatorKind Operator;
574548ca2912e5f2b78a20e50c58d8a1a9c5e9e67cArgyrios Kyrtzidis  SourceRange Range;
58063daf6e196c51f162e0485478355d8e280eef5cDouglas Gregor
59be9af1288881110e406b87914162eaa59f1e5918Lang Hames  // Record the FP_CONTRACT state that applies to this operator call. Only
60be9af1288881110e406b87914162eaa59f1e5918Lang Hames  // meaningful for floating point types. For other types this value can be
61be9af1288881110e406b87914162eaa59f1e5918Lang Hames  // set to false.
62be9af1288881110e406b87914162eaa59f1e5918Lang Hames  unsigned FPContractable : 1;
63be9af1288881110e406b87914162eaa59f1e5918Lang Hames
644548ca2912e5f2b78a20e50c58d8a1a9c5e9e67cArgyrios Kyrtzidis  SourceRange getSourceRangeImpl() const LLVM_READONLY;
65b4609806e9232593ece09ce08b630836e825865cDouglas Gregorpublic:
661eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  CXXOperatorCallExpr(ASTContext& C, OverloadedOperatorKind Op, Expr *fn,
673b6bef9a213249c6ab6d67c07b1ac6380961be3eBenjamin Kramer                      ArrayRef<Expr*> args, QualType t, ExprValueKind VK,
68be9af1288881110e406b87914162eaa59f1e5918Lang Hames                      SourceLocation operatorloc, bool fpContractable)
693b6bef9a213249c6ab6d67c07b1ac6380961be3eBenjamin Kramer    : CallExpr(C, CXXOperatorCallExprClass, fn, 0, args, t, VK,
70f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall               operatorloc),
71be9af1288881110e406b87914162eaa59f1e5918Lang Hames      Operator(Op), FPContractable(fpContractable) {
724548ca2912e5f2b78a20e50c58d8a1a9c5e9e67cArgyrios Kyrtzidis    Range = getSourceRangeImpl();
734548ca2912e5f2b78a20e50c58d8a1a9c5e9e67cArgyrios Kyrtzidis  }
741eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  explicit CXXOperatorCallExpr(ASTContext& C, EmptyShell Empty) :
75ba0a9006dbc4814e1e35f82812cb5a1dad65e8b8Argyrios Kyrtzidis    CallExpr(C, CXXOperatorCallExprClass, Empty) { }
761eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
77b4609806e9232593ece09ce08b630836e825865cDouglas Gregor
78010bfc253050626435f006386c0bee4b55329687James Dennett  /// \brief Returns the kind of overloaded operator that this
79b4609806e9232593ece09ce08b630836e825865cDouglas Gregor  /// expression refers to.
80063daf6e196c51f162e0485478355d8e280eef5cDouglas Gregor  OverloadedOperatorKind getOperator() const { return Operator; }
81b4609806e9232593ece09ce08b630836e825865cDouglas Gregor
82010bfc253050626435f006386c0bee4b55329687James Dennett  /// \brief Returns the location of the operator symbol in the expression.
83010bfc253050626435f006386c0bee4b55329687James Dennett  ///
84010bfc253050626435f006386c0bee4b55329687James Dennett  /// When \c getOperator()==OO_Call, this is the location of the right
85010bfc253050626435f006386c0bee4b55329687James Dennett  /// parentheses; when \c getOperator()==OO_Subscript, this is the location
86010bfc253050626435f006386c0bee4b55329687James Dennett  /// of the right bracket.
87b4609806e9232593ece09ce08b630836e825865cDouglas Gregor  SourceLocation getOperatorLoc() const { return getRParenLoc(); }
88b4609806e9232593ece09ce08b630836e825865cDouglas Gregor
8965d78312ce026092cb6e7b1d4d06f05e18d02aa0Erik Verbruggen  SourceLocation getLocStart() const LLVM_READONLY { return Range.getBegin(); }
9065d78312ce026092cb6e7b1d4d06f05e18d02aa0Erik Verbruggen  SourceLocation getLocEnd() const LLVM_READONLY { return Range.getEnd(); }
914548ca2912e5f2b78a20e50c58d8a1a9c5e9e67cArgyrios Kyrtzidis  SourceRange getSourceRange() const { return Range; }
921eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
931eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  static bool classof(const Stmt *T) {
941eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump    return T->getStmtClass() == CXXOperatorCallExprClass;
95b4609806e9232593ece09ce08b630836e825865cDouglas Gregor  }
964548ca2912e5f2b78a20e50c58d8a1a9c5e9e67cArgyrios Kyrtzidis
97be9af1288881110e406b87914162eaa59f1e5918Lang Hames  // Set the FP contractability status of this operator. Only meaningful for
98be9af1288881110e406b87914162eaa59f1e5918Lang Hames  // operations on floating point types.
99be9af1288881110e406b87914162eaa59f1e5918Lang Hames  void setFPContractable(bool FPC) { FPContractable = FPC; }
100be9af1288881110e406b87914162eaa59f1e5918Lang Hames
101be9af1288881110e406b87914162eaa59f1e5918Lang Hames  // Get the FP contractability status of this operator. Only meaningful for
102be9af1288881110e406b87914162eaa59f1e5918Lang Hames  // operations on floating point types.
103be9af1288881110e406b87914162eaa59f1e5918Lang Hames  bool isFPContractable() const { return FPContractable; }
104be9af1288881110e406b87914162eaa59f1e5918Lang Hames
1054548ca2912e5f2b78a20e50c58d8a1a9c5e9e67cArgyrios Kyrtzidis  friend class ASTStmtReader;
1064548ca2912e5f2b78a20e50c58d8a1a9c5e9e67cArgyrios Kyrtzidis  friend class ASTStmtWriter;
107b4609806e9232593ece09ce08b630836e825865cDouglas Gregor};
108b4609806e9232593ece09ce08b630836e825865cDouglas Gregor
109010bfc253050626435f006386c0bee4b55329687James Dennett/// Represents a call to a member function that
11088a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor/// may be written either with member call syntax (e.g., "obj.func()"
11188a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor/// or "objptr->func()") or with normal function-call syntax
11288a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor/// ("func()") within a member function that ends up calling a member
11388a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor/// function. The callee in either case is a MemberExpr that contains
11488a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor/// both the object argument and the member function, while the
11588a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor/// arguments are the arguments within the parentheses (not including
11688a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor/// the object argument).
11788a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregorclass CXXMemberCallExpr : public CallExpr {
11888a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregorpublic:
1193b6bef9a213249c6ab6d67c07b1ac6380961be3eBenjamin Kramer  CXXMemberCallExpr(ASTContext &C, Expr *fn, ArrayRef<Expr*> args,
120f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall                    QualType t, ExprValueKind VK, SourceLocation RP)
1213b6bef9a213249c6ab6d67c07b1ac6380961be3eBenjamin Kramer    : CallExpr(C, CXXMemberCallExprClass, fn, 0, args, t, VK, RP) {}
12288a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor
1231817bd483b538fd3f4530649f5cb900bad9e8a76Chris Lattner  CXXMemberCallExpr(ASTContext &C, EmptyShell Empty)
1241817bd483b538fd3f4530649f5cb900bad9e8a76Chris Lattner    : CallExpr(C, CXXMemberCallExprClass, Empty) { }
1251817bd483b538fd3f4530649f5cb900bad9e8a76Chris Lattner
126010bfc253050626435f006386c0bee4b55329687James Dennett  /// \brief Retrieves the implicit object argument for the member call.
127010bfc253050626435f006386c0bee4b55329687James Dennett  ///
128010bfc253050626435f006386c0bee4b55329687James Dennett  /// For example, in "x.f(5)", this returns the sub-expression "x".
129b277159055933e610bbc80262b600d3ad7e0595cTed Kremenek  Expr *getImplicitObjectArgument() const;
130ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie
131010bfc253050626435f006386c0bee4b55329687James Dennett  /// \brief Retrieves the declaration of the called method.
132b277159055933e610bbc80262b600d3ad7e0595cTed Kremenek  CXXMethodDecl *getMethodDecl() const;
13388a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor
134010bfc253050626435f006386c0bee4b55329687James Dennett  /// \brief Retrieves the CXXRecordDecl for the underlying type of
135010bfc253050626435f006386c0bee4b55329687James Dennett  /// the implicit object argument.
136010bfc253050626435f006386c0bee4b55329687James Dennett  ///
137010bfc253050626435f006386c0bee4b55329687James Dennett  /// Note that this is may not be the same declaration as that of the class
138010bfc253050626435f006386c0bee4b55329687James Dennett  /// context of the CXXMethodDecl which this function is calling.
139007a9b1c632bfaac20e41c60cbe07fdc6d0e647cChandler Carruth  /// FIXME: Returns 0 for member pointer call exprs.
1400cf3c0eecbff007cea2750c113894b47d9e09f33David Blaikie  CXXRecordDecl *getRecordDecl() const;
141007a9b1c632bfaac20e41c60cbe07fdc6d0e647cChandler Carruth
1421eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  static bool classof(const Stmt *T) {
14388a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor    return T->getStmtClass() == CXXMemberCallExprClass;
14488a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor  }
14588a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor};
14688a3514f36de96b19cdf50141c640df1a5f13f6cDouglas Gregor
147010bfc253050626435f006386c0bee4b55329687James Dennett/// \brief Represents a call to a CUDA kernel function.
148e08ce650a2b02410eddd1f60a4aa6b3d4be71e73Peter Collingbourneclass CUDAKernelCallExpr : public CallExpr {
149e08ce650a2b02410eddd1f60a4aa6b3d4be71e73Peter Collingbourneprivate:
150e08ce650a2b02410eddd1f60a4aa6b3d4be71e73Peter Collingbourne  enum { CONFIG, END_PREARG };
151e08ce650a2b02410eddd1f60a4aa6b3d4be71e73Peter Collingbourne
152e08ce650a2b02410eddd1f60a4aa6b3d4be71e73Peter Collingbournepublic:
153e08ce650a2b02410eddd1f60a4aa6b3d4be71e73Peter Collingbourne  CUDAKernelCallExpr(ASTContext &C, Expr *fn, CallExpr *Config,
1543b6bef9a213249c6ab6d67c07b1ac6380961be3eBenjamin Kramer                     ArrayRef<Expr*> args, QualType t, ExprValueKind VK,
1553b6bef9a213249c6ab6d67c07b1ac6380961be3eBenjamin Kramer                     SourceLocation RP)
1563b6bef9a213249c6ab6d67c07b1ac6380961be3eBenjamin Kramer    : CallExpr(C, CUDAKernelCallExprClass, fn, END_PREARG, args, t, VK, RP) {
157e08ce650a2b02410eddd1f60a4aa6b3d4be71e73Peter Collingbourne    setConfig(Config);
158e08ce650a2b02410eddd1f60a4aa6b3d4be71e73Peter Collingbourne  }
159e08ce650a2b02410eddd1f60a4aa6b3d4be71e73Peter Collingbourne
160e08ce650a2b02410eddd1f60a4aa6b3d4be71e73Peter Collingbourne  CUDAKernelCallExpr(ASTContext &C, EmptyShell Empty)
161e08ce650a2b02410eddd1f60a4aa6b3d4be71e73Peter Collingbourne    : CallExpr(C, CUDAKernelCallExprClass, END_PREARG, Empty) { }
162e08ce650a2b02410eddd1f60a4aa6b3d4be71e73Peter Collingbourne
163e08ce650a2b02410eddd1f60a4aa6b3d4be71e73Peter Collingbourne  const CallExpr *getConfig() const {
164e08ce650a2b02410eddd1f60a4aa6b3d4be71e73Peter Collingbourne    return cast_or_null<CallExpr>(getPreArg(CONFIG));
165e08ce650a2b02410eddd1f60a4aa6b3d4be71e73Peter Collingbourne  }
166e08ce650a2b02410eddd1f60a4aa6b3d4be71e73Peter Collingbourne  CallExpr *getConfig() { return cast_or_null<CallExpr>(getPreArg(CONFIG)); }
167e08ce650a2b02410eddd1f60a4aa6b3d4be71e73Peter Collingbourne  void setConfig(CallExpr *E) { setPreArg(CONFIG, E); }
168e08ce650a2b02410eddd1f60a4aa6b3d4be71e73Peter Collingbourne
169e08ce650a2b02410eddd1f60a4aa6b3d4be71e73Peter Collingbourne  static bool classof(const Stmt *T) {
170e08ce650a2b02410eddd1f60a4aa6b3d4be71e73Peter Collingbourne    return T->getStmtClass() == CUDAKernelCallExprClass;
171e08ce650a2b02410eddd1f60a4aa6b3d4be71e73Peter Collingbourne  }
172e08ce650a2b02410eddd1f60a4aa6b3d4be71e73Peter Collingbourne};
173e08ce650a2b02410eddd1f60a4aa6b3d4be71e73Peter Collingbourne
174010bfc253050626435f006386c0bee4b55329687James Dennett/// \brief Abstract class common to all of the C++ "named"/"keyword" casts.
17549badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor///
17649badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// This abstract class is inherited by all of the classes
177010bfc253050626435f006386c0bee4b55329687James Dennett/// representing "named" casts: CXXStaticCastExpr for \c static_cast,
178010bfc253050626435f006386c0bee4b55329687James Dennett/// CXXDynamicCastExpr for \c dynamic_cast, CXXReinterpretCastExpr for
179010bfc253050626435f006386c0bee4b55329687James Dennett/// reinterpret_cast, and CXXConstCastExpr for \c const_cast.
18049badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregorclass CXXNamedCastExpr : public ExplicitCastExpr {
1811060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenekprivate:
1821060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  SourceLocation Loc; // the location of the casting op
1831d5d0b9df6d2a3df338bc3e63000536406e7666cDouglas Gregor  SourceLocation RParenLoc; // the location of the right parenthesis
184f799ae1afb897151a84a7170951e367d8307ae04Fariborz Jahanian  SourceRange AngleBrackets; // range for '<' '>'
185ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie
18649badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregorprotected:
187f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall  CXXNamedCastExpr(StmtClass SC, QualType ty, ExprValueKind VK,
188f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall                   CastKind kind, Expr *op, unsigned PathSize,
1891d5d0b9df6d2a3df338bc3e63000536406e7666cDouglas Gregor                   TypeSourceInfo *writtenTy, SourceLocation l,
190f799ae1afb897151a84a7170951e367d8307ae04Fariborz Jahanian                   SourceLocation RParenLoc,
191f799ae1afb897151a84a7170951e367d8307ae04Fariborz Jahanian                   SourceRange AngleBrackets)
1921d5d0b9df6d2a3df338bc3e63000536406e7666cDouglas Gregor    : ExplicitCastExpr(SC, ty, VK, kind, op, PathSize, writtenTy), Loc(l),
193f799ae1afb897151a84a7170951e367d8307ae04Fariborz Jahanian      RParenLoc(RParenLoc), AngleBrackets(AngleBrackets) {}
19449badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor
195f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall  explicit CXXNamedCastExpr(StmtClass SC, EmptyShell Shell, unsigned PathSize)
196f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall    : ExplicitCastExpr(SC, Shell, PathSize) { }
197ce757a7a1ee905f87551996a69da3e95e8afeeb7Sam Weinig
1981d5d0b9df6d2a3df338bc3e63000536406e7666cDouglas Gregor  friend class ASTStmtReader;
199ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie
2001060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenekpublic:
20149badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor  const char *getCastName() const;
20249badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor
203a3a7b8eea87c90a5a257f685749222b212ddaf36Douglas Gregor  /// \brief Retrieve the location of the cast operator keyword, e.g.,
204010bfc253050626435f006386c0bee4b55329687James Dennett  /// \c static_cast.
205a3a7b8eea87c90a5a257f685749222b212ddaf36Douglas Gregor  SourceLocation getOperatorLoc() const { return Loc; }
206a3a7b8eea87c90a5a257f685749222b212ddaf36Douglas Gregor
2071d5d0b9df6d2a3df338bc3e63000536406e7666cDouglas Gregor  /// \brief Retrieve the location of the closing parenthesis.
2081d5d0b9df6d2a3df338bc3e63000536406e7666cDouglas Gregor  SourceLocation getRParenLoc() const { return RParenLoc; }
209ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie
21065d78312ce026092cb6e7b1d4d06f05e18d02aa0Erik Verbruggen  SourceLocation getLocStart() const LLVM_READONLY { return Loc; }
21165d78312ce026092cb6e7b1d4d06f05e18d02aa0Erik Verbruggen  SourceLocation getLocEnd() const LLVM_READONLY { return RParenLoc; }
212f799ae1afb897151a84a7170951e367d8307ae04Fariborz Jahanian  SourceRange getAngleBrackets() const LLVM_READONLY { return AngleBrackets; }
21365d78312ce026092cb6e7b1d4d06f05e18d02aa0Erik Verbruggen
2141eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  static bool classof(const Stmt *T) {
21549badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor    switch (T->getStmtClass()) {
21649badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor    case CXXStaticCastExprClass:
21749badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor    case CXXDynamicCastExprClass:
21849badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor    case CXXReinterpretCastExprClass:
21949badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor    case CXXConstCastExprClass:
22049badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor      return true;
22149badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor    default:
22249badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor      return false;
22349badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor    }
2241060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  }
22549badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor};
22649badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor
227010bfc253050626435f006386c0bee4b55329687James Dennett/// \brief A C++ \c static_cast expression (C++ [expr.static.cast]).
2281eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump///
22949badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// This expression node represents a C++ static cast, e.g.,
230010bfc253050626435f006386c0bee4b55329687James Dennett/// \c static_cast<int>(1.0).
23149badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregorclass CXXStaticCastExpr : public CXXNamedCastExpr {
232f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall  CXXStaticCastExpr(QualType ty, ExprValueKind vk, CastKind kind, Expr *op,
233f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall                    unsigned pathSize, TypeSourceInfo *writtenTy,
234f799ae1afb897151a84a7170951e367d8307ae04Fariborz Jahanian                    SourceLocation l, SourceLocation RParenLoc,
235f799ae1afb897151a84a7170951e367d8307ae04Fariborz Jahanian                    SourceRange AngleBrackets)
236f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall    : CXXNamedCastExpr(CXXStaticCastExprClass, ty, vk, kind, op, pathSize,
237f799ae1afb897151a84a7170951e367d8307ae04Fariborz Jahanian                       writtenTy, l, RParenLoc, AngleBrackets) {}
23849badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor
239f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall  explicit CXXStaticCastExpr(EmptyShell Empty, unsigned PathSize)
240f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall    : CXXNamedCastExpr(CXXStaticCastExprClass, Empty, PathSize) { }
241f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall
242f871d0cc377a1367b519a6cce26be74607566ebaJohn McCallpublic:
24332b5a1e82f535d43e94332183cd330f4a39b2dbdCraig Topper  static CXXStaticCastExpr *Create(const ASTContext &Context, QualType T,
244f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall                                   ExprValueKind VK, CastKind K, Expr *Op,
245f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall                                   const CXXCastPath *Path,
246ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie                                   TypeSourceInfo *Written, SourceLocation L,
247f799ae1afb897151a84a7170951e367d8307ae04Fariborz Jahanian                                   SourceLocation RParenLoc,
248f799ae1afb897151a84a7170951e367d8307ae04Fariborz Jahanian                                   SourceRange AngleBrackets);
24932b5a1e82f535d43e94332183cd330f4a39b2dbdCraig Topper  static CXXStaticCastExpr *CreateEmpty(const ASTContext &Context,
250f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall                                        unsigned PathSize);
251ce757a7a1ee905f87551996a69da3e95e8afeeb7Sam Weinig
2521eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  static bool classof(const Stmt *T) {
25349badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor    return T->getStmtClass() == CXXStaticCastExprClass;
25449badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor  }
25549badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor};
25649badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor
257010bfc253050626435f006386c0bee4b55329687James Dennett/// \brief A C++ @c dynamic_cast expression (C++ [expr.dynamic.cast]).
2581eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump///
25949badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// This expression node represents a dynamic cast, e.g.,
26080747a834cf8b0304b314ede9aba3d6ddb8e9520NAKAMURA Takumi/// \c dynamic_cast<Derived*>(BasePtr). Such a cast may perform a run-time
261010bfc253050626435f006386c0bee4b55329687James Dennett/// check to determine how to perform the type conversion.
26249badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregorclass CXXDynamicCastExpr : public CXXNamedCastExpr {
263f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall  CXXDynamicCastExpr(QualType ty, ExprValueKind VK, CastKind kind,
264f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall                     Expr *op, unsigned pathSize, TypeSourceInfo *writtenTy,
265f799ae1afb897151a84a7170951e367d8307ae04Fariborz Jahanian                     SourceLocation l, SourceLocation RParenLoc,
266f799ae1afb897151a84a7170951e367d8307ae04Fariborz Jahanian                     SourceRange AngleBrackets)
267f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall    : CXXNamedCastExpr(CXXDynamicCastExprClass, ty, VK, kind, op, pathSize,
268f799ae1afb897151a84a7170951e367d8307ae04Fariborz Jahanian                       writtenTy, l, RParenLoc, AngleBrackets) {}
26949badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor
270f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall  explicit CXXDynamicCastExpr(EmptyShell Empty, unsigned pathSize)
271f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall    : CXXNamedCastExpr(CXXDynamicCastExprClass, Empty, pathSize) { }
272f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall
273f871d0cc377a1367b519a6cce26be74607566ebaJohn McCallpublic:
27432b5a1e82f535d43e94332183cd330f4a39b2dbdCraig Topper  static CXXDynamicCastExpr *Create(const ASTContext &Context, QualType T,
275f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall                                    ExprValueKind VK, CastKind Kind, Expr *Op,
276f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall                                    const CXXCastPath *Path,
277ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie                                    TypeSourceInfo *Written, SourceLocation L,
278f799ae1afb897151a84a7170951e367d8307ae04Fariborz Jahanian                                    SourceLocation RParenLoc,
279f799ae1afb897151a84a7170951e367d8307ae04Fariborz Jahanian                                    SourceRange AngleBrackets);
280ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie
28132b5a1e82f535d43e94332183cd330f4a39b2dbdCraig Topper  static CXXDynamicCastExpr *CreateEmpty(const ASTContext &Context,
282f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall                                         unsigned pathSize);
283ce757a7a1ee905f87551996a69da3e95e8afeeb7Sam Weinig
2840fee330f5754ca4b248e5bb7363e834668aff06dAnders Carlsson  bool isAlwaysNull() const;
2850fee330f5754ca4b248e5bb7363e834668aff06dAnders Carlsson
2861eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  static bool classof(const Stmt *T) {
28749badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor    return T->getStmtClass() == CXXDynamicCastExprClass;
28849badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor  }
28949badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor};
29049badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor
291010bfc253050626435f006386c0bee4b55329687James Dennett/// \brief A C++ @c reinterpret_cast expression (C++ [expr.reinterpret.cast]).
2921eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump///
29349badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// This expression node represents a reinterpret cast, e.g.,
29449badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// @c reinterpret_cast<int>(VoidPtr).
295010bfc253050626435f006386c0bee4b55329687James Dennett///
296010bfc253050626435f006386c0bee4b55329687James Dennett/// A reinterpret_cast provides a differently-typed view of a value but
297010bfc253050626435f006386c0bee4b55329687James Dennett/// (in Clang, as in most C++ implementations) performs no actual work at
298010bfc253050626435f006386c0bee4b55329687James Dennett/// run time.
29949badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregorclass CXXReinterpretCastExpr : public CXXNamedCastExpr {
300f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall  CXXReinterpretCastExpr(QualType ty, ExprValueKind vk, CastKind kind,
301f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall                         Expr *op, unsigned pathSize,
302ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie                         TypeSourceInfo *writtenTy, SourceLocation l,
303f799ae1afb897151a84a7170951e367d8307ae04Fariborz Jahanian                         SourceLocation RParenLoc,
304f799ae1afb897151a84a7170951e367d8307ae04Fariborz Jahanian                         SourceRange AngleBrackets)
305f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall    : CXXNamedCastExpr(CXXReinterpretCastExprClass, ty, vk, kind, op,
306f799ae1afb897151a84a7170951e367d8307ae04Fariborz Jahanian                       pathSize, writtenTy, l, RParenLoc, AngleBrackets) {}
30749badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor
308f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall  CXXReinterpretCastExpr(EmptyShell Empty, unsigned pathSize)
309f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall    : CXXNamedCastExpr(CXXReinterpretCastExprClass, Empty, pathSize) { }
310f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall
311f871d0cc377a1367b519a6cce26be74607566ebaJohn McCallpublic:
31232b5a1e82f535d43e94332183cd330f4a39b2dbdCraig Topper  static CXXReinterpretCastExpr *Create(const ASTContext &Context, QualType T,
313f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall                                        ExprValueKind VK, CastKind Kind,
314f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall                                        Expr *Op, const CXXCastPath *Path,
315ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie                                 TypeSourceInfo *WrittenTy, SourceLocation L,
316f799ae1afb897151a84a7170951e367d8307ae04Fariborz Jahanian                                        SourceLocation RParenLoc,
317f799ae1afb897151a84a7170951e367d8307ae04Fariborz Jahanian                                        SourceRange AngleBrackets);
31832b5a1e82f535d43e94332183cd330f4a39b2dbdCraig Topper  static CXXReinterpretCastExpr *CreateEmpty(const ASTContext &Context,
319f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall                                             unsigned pathSize);
320ce757a7a1ee905f87551996a69da3e95e8afeeb7Sam Weinig
3211eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  static bool classof(const Stmt *T) {
32249badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor    return T->getStmtClass() == CXXReinterpretCastExprClass;
32349badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor  }
32449badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor};
32549badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor
326010bfc253050626435f006386c0bee4b55329687James Dennett/// \brief A C++ \c const_cast expression (C++ [expr.const.cast]).
3271eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump///
32849badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor/// This expression node represents a const cast, e.g.,
329010bfc253050626435f006386c0bee4b55329687James Dennett/// \c const_cast<char*>(PtrToConstChar).
330010bfc253050626435f006386c0bee4b55329687James Dennett///
331010bfc253050626435f006386c0bee4b55329687James Dennett/// A const_cast can remove type qualifiers but does not change the underlying
332010bfc253050626435f006386c0bee4b55329687James Dennett/// value.
33349badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregorclass CXXConstCastExpr : public CXXNamedCastExpr {
334f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall  CXXConstCastExpr(QualType ty, ExprValueKind VK, Expr *op,
335ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie                   TypeSourceInfo *writtenTy, SourceLocation l,
336f799ae1afb897151a84a7170951e367d8307ae04Fariborz Jahanian                   SourceLocation RParenLoc, SourceRange AngleBrackets)
337ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie    : CXXNamedCastExpr(CXXConstCastExprClass, ty, VK, CK_NoOp, op,
338f799ae1afb897151a84a7170951e367d8307ae04Fariborz Jahanian                       0, writtenTy, l, RParenLoc, AngleBrackets) {}
33949badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor
340ce757a7a1ee905f87551996a69da3e95e8afeeb7Sam Weinig  explicit CXXConstCastExpr(EmptyShell Empty)
341f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall    : CXXNamedCastExpr(CXXConstCastExprClass, Empty, 0) { }
342f871d0cc377a1367b519a6cce26be74607566ebaJohn McCall
343f871d0cc377a1367b519a6cce26be74607566ebaJohn McCallpublic:
34432b5a1e82f535d43e94332183cd330f4a39b2dbdCraig Topper  static CXXConstCastExpr *Create(const ASTContext &Context, QualType T,
345f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall                                  ExprValueKind VK, Expr *Op,
346ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie                                  TypeSourceInfo *WrittenTy, SourceLocation L,
347f799ae1afb897151a84a7170951e367d8307ae04Fariborz Jahanian                                  SourceLocation RParenLoc,
348f799ae1afb897151a84a7170951e367d8307ae04Fariborz Jahanian                                  SourceRange AngleBrackets);
34932b5a1e82f535d43e94332183cd330f4a39b2dbdCraig Topper  static CXXConstCastExpr *CreateEmpty(const ASTContext &Context);
350ce757a7a1ee905f87551996a69da3e95e8afeeb7Sam Weinig
3511eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  static bool classof(const Stmt *T) {
35249badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor    return T->getStmtClass() == CXXConstCastExprClass;
35349badde06e066d058d6c7fcf4e628a72999b65a9Douglas Gregor  }
3541060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek};
3551060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek
356010bfc253050626435f006386c0bee4b55329687James Dennett/// \brief A call to a literal operator (C++11 [over.literal])
3579fcce65e7e1307b5b8da9be13e4092d6bb94dc1dRichard Smith/// written as a user-defined literal (C++11 [lit.ext]).
3589fcce65e7e1307b5b8da9be13e4092d6bb94dc1dRichard Smith///
3599fcce65e7e1307b5b8da9be13e4092d6bb94dc1dRichard Smith/// Represents a user-defined literal, e.g. "foo"_bar or 1.23_xyz. While this
3609fcce65e7e1307b5b8da9be13e4092d6bb94dc1dRichard Smith/// is semantically equivalent to a normal call, this AST node provides better
3619fcce65e7e1307b5b8da9be13e4092d6bb94dc1dRichard Smith/// information about the syntactic representation of the literal.
3629fcce65e7e1307b5b8da9be13e4092d6bb94dc1dRichard Smith///
3639fcce65e7e1307b5b8da9be13e4092d6bb94dc1dRichard Smith/// Since literal operators are never found by ADL and can only be declared at
3649fcce65e7e1307b5b8da9be13e4092d6bb94dc1dRichard Smith/// namespace scope, a user-defined literal is never dependent.
3659fcce65e7e1307b5b8da9be13e4092d6bb94dc1dRichard Smithclass UserDefinedLiteral : public CallExpr {
3669fcce65e7e1307b5b8da9be13e4092d6bb94dc1dRichard Smith  /// \brief The location of a ud-suffix within the literal.
3679fcce65e7e1307b5b8da9be13e4092d6bb94dc1dRichard Smith  SourceLocation UDSuffixLoc;
3689fcce65e7e1307b5b8da9be13e4092d6bb94dc1dRichard Smith
3699fcce65e7e1307b5b8da9be13e4092d6bb94dc1dRichard Smithpublic:
37032b5a1e82f535d43e94332183cd330f4a39b2dbdCraig Topper  UserDefinedLiteral(const ASTContext &C, Expr *Fn, ArrayRef<Expr*> Args,
3719fcce65e7e1307b5b8da9be13e4092d6bb94dc1dRichard Smith                     QualType T, ExprValueKind VK, SourceLocation LitEndLoc,
3729fcce65e7e1307b5b8da9be13e4092d6bb94dc1dRichard Smith                     SourceLocation SuffixLoc)
3733b6bef9a213249c6ab6d67c07b1ac6380961be3eBenjamin Kramer    : CallExpr(C, UserDefinedLiteralClass, Fn, 0, Args, T, VK, LitEndLoc),
3743b6bef9a213249c6ab6d67c07b1ac6380961be3eBenjamin Kramer      UDSuffixLoc(SuffixLoc) {}
37532b5a1e82f535d43e94332183cd330f4a39b2dbdCraig Topper  explicit UserDefinedLiteral(const ASTContext &C, EmptyShell Empty)
3769fcce65e7e1307b5b8da9be13e4092d6bb94dc1dRichard Smith    : CallExpr(C, UserDefinedLiteralClass, Empty) {}
3779fcce65e7e1307b5b8da9be13e4092d6bb94dc1dRichard Smith
3789fcce65e7e1307b5b8da9be13e4092d6bb94dc1dRichard Smith  /// The kind of literal operator which is invoked.
3799fcce65e7e1307b5b8da9be13e4092d6bb94dc1dRichard Smith  enum LiteralOperatorKind {
3809fcce65e7e1307b5b8da9be13e4092d6bb94dc1dRichard Smith    LOK_Raw,      ///< Raw form: operator "" X (const char *)
3819fcce65e7e1307b5b8da9be13e4092d6bb94dc1dRichard Smith    LOK_Template, ///< Raw form: operator "" X<cs...> ()
3829fcce65e7e1307b5b8da9be13e4092d6bb94dc1dRichard Smith    LOK_Integer,  ///< operator "" X (unsigned long long)
3839fcce65e7e1307b5b8da9be13e4092d6bb94dc1dRichard Smith    LOK_Floating, ///< operator "" X (long double)
3849fcce65e7e1307b5b8da9be13e4092d6bb94dc1dRichard Smith    LOK_String,   ///< operator "" X (const CharT *, size_t)
3859fcce65e7e1307b5b8da9be13e4092d6bb94dc1dRichard Smith    LOK_Character ///< operator "" X (CharT)
3869fcce65e7e1307b5b8da9be13e4092d6bb94dc1dRichard Smith  };
3879fcce65e7e1307b5b8da9be13e4092d6bb94dc1dRichard Smith
388010bfc253050626435f006386c0bee4b55329687James Dennett  /// \brief Returns the kind of literal operator invocation
3899fcce65e7e1307b5b8da9be13e4092d6bb94dc1dRichard Smith  /// which this expression represents.
3909fcce65e7e1307b5b8da9be13e4092d6bb94dc1dRichard Smith  LiteralOperatorKind getLiteralOperatorKind() const;
3919fcce65e7e1307b5b8da9be13e4092d6bb94dc1dRichard Smith
392010bfc253050626435f006386c0bee4b55329687James Dennett  /// \brief If this is not a raw user-defined literal, get the
3939fcce65e7e1307b5b8da9be13e4092d6bb94dc1dRichard Smith  /// underlying cooked literal (representing the literal with the suffix
3949fcce65e7e1307b5b8da9be13e4092d6bb94dc1dRichard Smith  /// removed).
3959fcce65e7e1307b5b8da9be13e4092d6bb94dc1dRichard Smith  Expr *getCookedLiteral();
3969fcce65e7e1307b5b8da9be13e4092d6bb94dc1dRichard Smith  const Expr *getCookedLiteral() const {
3979fcce65e7e1307b5b8da9be13e4092d6bb94dc1dRichard Smith    return const_cast<UserDefinedLiteral*>(this)->getCookedLiteral();
3989fcce65e7e1307b5b8da9be13e4092d6bb94dc1dRichard Smith  }
3999fcce65e7e1307b5b8da9be13e4092d6bb94dc1dRichard Smith
4000265555a0fec81102bfb3757cfc7f3d90dbbe409Abramo Bagnara  SourceLocation getLocStart() const {
4010265555a0fec81102bfb3757cfc7f3d90dbbe409Abramo Bagnara    if (getLiteralOperatorKind() == LOK_Template)
4020265555a0fec81102bfb3757cfc7f3d90dbbe409Abramo Bagnara      return getRParenLoc();
4030265555a0fec81102bfb3757cfc7f3d90dbbe409Abramo Bagnara    return getArg(0)->getLocStart();
4040265555a0fec81102bfb3757cfc7f3d90dbbe409Abramo Bagnara  }
4050265555a0fec81102bfb3757cfc7f3d90dbbe409Abramo Bagnara  SourceLocation getLocEnd() const { return getRParenLoc(); }
4060265555a0fec81102bfb3757cfc7f3d90dbbe409Abramo Bagnara
4070265555a0fec81102bfb3757cfc7f3d90dbbe409Abramo Bagnara
408010bfc253050626435f006386c0bee4b55329687James Dennett  /// \brief Returns the location of a ud-suffix in the expression.
409010bfc253050626435f006386c0bee4b55329687James Dennett  ///
4109fcce65e7e1307b5b8da9be13e4092d6bb94dc1dRichard Smith  /// For a string literal, there may be multiple identical suffixes. This
4119fcce65e7e1307b5b8da9be13e4092d6bb94dc1dRichard Smith  /// returns the first.
4120265555a0fec81102bfb3757cfc7f3d90dbbe409Abramo Bagnara  SourceLocation getUDSuffixLoc() const { return UDSuffixLoc; }
4139fcce65e7e1307b5b8da9be13e4092d6bb94dc1dRichard Smith
414010bfc253050626435f006386c0bee4b55329687James Dennett  /// \brief Returns the ud-suffix specified for this literal.
4159fcce65e7e1307b5b8da9be13e4092d6bb94dc1dRichard Smith  const IdentifierInfo *getUDSuffix() const;
4169fcce65e7e1307b5b8da9be13e4092d6bb94dc1dRichard Smith
4179fcce65e7e1307b5b8da9be13e4092d6bb94dc1dRichard Smith  static bool classof(const Stmt *S) {
4189fcce65e7e1307b5b8da9be13e4092d6bb94dc1dRichard Smith    return S->getStmtClass() == UserDefinedLiteralClass;
4199fcce65e7e1307b5b8da9be13e4092d6bb94dc1dRichard Smith  }
4209fcce65e7e1307b5b8da9be13e4092d6bb94dc1dRichard Smith
4219fcce65e7e1307b5b8da9be13e4092d6bb94dc1dRichard Smith  friend class ASTStmtReader;
4229fcce65e7e1307b5b8da9be13e4092d6bb94dc1dRichard Smith  friend class ASTStmtWriter;
4239fcce65e7e1307b5b8da9be13e4092d6bb94dc1dRichard Smith};
4249fcce65e7e1307b5b8da9be13e4092d6bb94dc1dRichard Smith
425010bfc253050626435f006386c0bee4b55329687James Dennett/// \brief A boolean literal, per ([C++ lex.bool] Boolean literals).
4261eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump///
4271060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenekclass CXXBoolLiteralExpr : public Expr {
4281060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  bool Value;
4291060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  SourceLocation Loc;
4301060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenekpublic:
4311eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  CXXBoolLiteralExpr(bool val, QualType Ty, SourceLocation l) :
432bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor    Expr(CXXBoolLiteralExprClass, Ty, VK_RValue, OK_Ordinary, false, false,
433561f81243f665cf2001caadc45df505f826b72d6Douglas Gregor         false, false),
434f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall    Value(val), Loc(l) {}
4358b0b475b3464b0f70b91ba7d679d23c424677d5eSebastian Redl
436eb7f96141f754150a92433286fa385910a22f494Sam Weinig  explicit CXXBoolLiteralExpr(EmptyShell Empty)
437eb7f96141f754150a92433286fa385910a22f494Sam Weinig    : Expr(CXXBoolLiteralExprClass, Empty) { }
438eb7f96141f754150a92433286fa385910a22f494Sam Weinig
4391060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  bool getValue() const { return Value; }
440eb7f96141f754150a92433286fa385910a22f494Sam Weinig  void setValue(bool V) { Value = V; }
4415f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer
44265d78312ce026092cb6e7b1d4d06f05e18d02aa0Erik Verbruggen  SourceLocation getLocStart() const LLVM_READONLY { return Loc; }
44365d78312ce026092cb6e7b1d4d06f05e18d02aa0Erik Verbruggen  SourceLocation getLocEnd() const LLVM_READONLY { return Loc; }
4441eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
445eb7f96141f754150a92433286fa385910a22f494Sam Weinig  SourceLocation getLocation() const { return Loc; }
446eb7f96141f754150a92433286fa385910a22f494Sam Weinig  void setLocation(SourceLocation L) { Loc = L; }
447eb7f96141f754150a92433286fa385910a22f494Sam Weinig
4481eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  static bool classof(const Stmt *T) {
4491060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek    return T->getStmtClass() == CXXBoolLiteralExprClass;
4501060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  }
4511eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
4521060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek  // Iterators
45363c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall  child_range children() { return child_range(); }
4541060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek};
4551060aff23f72135f8b50034a1e80f16725ebc56cTed Kremenek
456010bfc253050626435f006386c0bee4b55329687James Dennett/// \brief The null pointer literal (C++11 [lex.nullptr])
457010bfc253050626435f006386c0bee4b55329687James Dennett///
458010bfc253050626435f006386c0bee4b55329687James Dennett/// Introduced in C++11, the only literal of type \c nullptr_t is \c nullptr.
4596e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redlclass CXXNullPtrLiteralExpr : public Expr {
4606e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl  SourceLocation Loc;
4616e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redlpublic:
4626e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl  CXXNullPtrLiteralExpr(QualType Ty, SourceLocation l) :
463bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor    Expr(CXXNullPtrLiteralExprClass, Ty, VK_RValue, OK_Ordinary, false, false,
464561f81243f665cf2001caadc45df505f826b72d6Douglas Gregor         false, false),
465f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall    Loc(l) {}
4666e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl
467eb7f96141f754150a92433286fa385910a22f494Sam Weinig  explicit CXXNullPtrLiteralExpr(EmptyShell Empty)
468eb7f96141f754150a92433286fa385910a22f494Sam Weinig    : Expr(CXXNullPtrLiteralExprClass, Empty) { }
469eb7f96141f754150a92433286fa385910a22f494Sam Weinig
47065d78312ce026092cb6e7b1d4d06f05e18d02aa0Erik Verbruggen  SourceLocation getLocStart() const LLVM_READONLY { return Loc; }
47165d78312ce026092cb6e7b1d4d06f05e18d02aa0Erik Verbruggen  SourceLocation getLocEnd() const LLVM_READONLY { return Loc; }
4726e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl
473eb7f96141f754150a92433286fa385910a22f494Sam Weinig  SourceLocation getLocation() const { return Loc; }
474eb7f96141f754150a92433286fa385910a22f494Sam Weinig  void setLocation(SourceLocation L) { Loc = L; }
475eb7f96141f754150a92433286fa385910a22f494Sam Weinig
4766e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl  static bool classof(const Stmt *T) {
4776e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl    return T->getStmtClass() == CXXNullPtrLiteralExprClass;
4786e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl  }
4796e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl
48063c00d7f35fa060c0a446c9df3a4402d9c7757feJohn McCall  child_range children() { return child_range(); }
4816e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl};
4826e8ed16ffef02b82995a90bdcf10ffff7d63839aSebastian Redl
4837c3e615f01e8f9f587315800fdaf2305ed824568Richard Smith/// \brief Implicit construction of a std::initializer_list<T> object from an
4847c3e615f01e8f9f587315800fdaf2305ed824568Richard Smith/// array temporary within list-initialization (C++11 [dcl.init.list]p5).
4857c3e615f01e8f9f587315800fdaf2305ed824568Richard Smithclass CXXStdInitializerListExpr : public Expr {
4867c3e615f01e8f9f587315800fdaf2305ed824568Richard Smith  Stmt *SubExpr;
4877c3e615f01e8f9f587315800fdaf2305ed824568Richard Smith
4887c3e615f01e8f9f587315800fdaf2305ed824568Richard Smith  CXXStdInitializerListExpr(EmptyShell Empty)
4896bcf27bb9a4b5c3f79cb44c0e4654a6d7619ad89Stephen Hines    : Expr(CXXStdInitializerListExprClass, Empty), SubExpr(nullptr) {}
4907c3e615f01e8f9f587315800fdaf2305ed824568Richard Smith
4917c3e615f01e8f9f587315800fdaf2305ed824568Richard Smithpublic:
4927c3e615f01e8f9f587315800fdaf2305ed824568Richard Smith  CXXStdInitializerListExpr(QualType Ty, Expr *SubExpr)
4937c3e615f01e8f9f587315800fdaf2305ed824568Richard Smith    : Expr(CXXStdInitializerListExprClass, Ty, VK_RValue, OK_Ordinary,
4947c3e615f01e8f9f587315800fdaf2305ed824568Richard Smith           Ty->isDependentType(), SubExpr->isValueDependent(),
4957c3e615f01e8f9f587315800fdaf2305ed824568Richard Smith           SubExpr->isInstantiationDependent(),
4967c3e615f01e8f9f587315800fdaf2305ed824568Richard Smith           SubExpr->containsUnexpandedParameterPack()),
4977c3e615f01e8f9f587315800fdaf2305ed824568Richard Smith      SubExpr(SubExpr) {}
4987c3e615f01e8f9f587315800fdaf2305ed824568Richard Smith
4997c3e615f01e8f9f587315800fdaf2305ed824568Richard Smith  Expr *getSubExpr() { return static_cast<Expr*>(SubExpr); }
5007c3e615f01e8f9f587315800fdaf2305ed824568Richard Smith  const Expr *getSubExpr() const { return static_cast<const Expr*>(SubExpr); }
5017c3e615f01e8f9f587315800fdaf2305ed824568Richard Smith
5027c3e615f01e8f9f587315800fdaf2305ed824568Richard Smith  SourceLocation getLocStart() const LLVM_READONLY {
5037c3e615f01e8f9f587315800fdaf2305ed824568Richard Smith    return SubExpr->getLocStart();
5047c3e615f01e8f9f587315800fdaf2305ed824568Richard Smith  }
5057c3e615f01e8f9f587315800fdaf2305ed824568Richard Smith  SourceLocation getLocEnd() const LLVM_READONLY {
5067c3e615f01e8f9f587315800fdaf2305ed824568Richard Smith    return SubExpr->getLocEnd();
5077c3e615f01e8f9f587315800fdaf2305ed824568Richard Smith  }
5087c3e615f01e8f9f587315800fdaf2305ed824568Richard Smith  SourceRange getSourceRange() const LLVM_READONLY {
5097c3e615f01e8f9f587315800fdaf2305ed824568Richard Smith    return SubExpr->getSourceRange();
5107c3e615f01e8f9f587315800fdaf2305ed824568Richard Smith  }
5117c3e615f01e8f9f587315800fdaf2305ed824568Richard Smith
5127c3e615f01e8f9f587315800fdaf2305ed824568Richard Smith  static bool classof(const Stmt *S) {
5137c3e615f01e8f9f587315800fdaf2305ed824568Richard Smith    return S->getStmtClass() == CXXStdInitializerListExprClass;
5147c3e615f01e8f9f587315800fdaf2305ed824568Richard Smith  }
5157c3e615f01e8f9f587315800fdaf2305ed824568Richard Smith
5167c3e615f01e8f9f587315800fdaf2305ed824568Richard Smith  child_range children() { return child_range(&SubExpr, &SubExpr + 1); }
5177c3e615f01e8f9f587315800fdaf2305ed824568Richard Smith
5187c3e615f01e8f9f587315800fdaf2305ed824568Richard Smith  friend class ASTReader;
5197c3e615f01e8f9f587315800fdaf2305ed824568Richard Smith  friend class ASTStmtReader;
5207c3e615f01e8f9f587315800fdaf2305ed824568Richard Smith};
5217c3e615f01e8f9f587315800fdaf2305ed824568Richard Smith
522010bfc253050626435f006386c0bee4b55329687James Dennett/// A C++ \c typeid expression (C++ [expr.typeid]), which gets
523010bfc253050626435f006386c0bee4b55329687James Dennett/// the \c type_info that corresponds to the supplied type, or the (possibly
524c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl/// dynamic) type of the supplied expression.
525c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl///
526010bfc253050626435f006386c0bee4b55329687James Dennett/// This represents code like \c typeid(int) or \c typeid(*objPtr)
527c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redlclass CXXTypeidExpr : public Expr {
528c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redlprivate:
52957fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor  llvm::PointerUnion<Stmt *, TypeSourceInfo *> Operand;
530c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl  SourceRange Range;
531c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl
532c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redlpublic:
53357fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor  CXXTypeidExpr(QualType Ty, TypeSourceInfo *Operand, SourceRange R)
534f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall    : Expr(CXXTypeidExprClass, Ty, VK_LValue, OK_Ordinary,
53557fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor           // typeid is never type-dependent (C++ [temp.dep.expr]p4)
53657fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor           false,
53757fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor           // typeid is value-dependent if the type or expression are dependent
538bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor           Operand->getType()->isDependentType(),
539561f81243f665cf2001caadc45df505f826b72d6Douglas Gregor           Operand->getType()->isInstantiationDependentType(),
540bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor           Operand->getType()->containsUnexpandedParameterPack()),
54157fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor      Operand(Operand), Range(R) { }
542ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie
54357fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor  CXXTypeidExpr(QualType Ty, Expr *Operand, SourceRange R)
544f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall    : Expr(CXXTypeidExprClass, Ty, VK_LValue, OK_Ordinary,
5452850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl        // typeid is never type-dependent (C++ [temp.dep.expr]p4)
546bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor           false,
5472850784bda09416fc7e9d57f5baa36c9351c757cSebastian Redl        // typeid is value-dependent if the type or expression are dependent
548bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor           Operand->isTypeDependent() || Operand->isValueDependent(),
549561f81243f665cf2001caadc45df505f826b72d6Douglas Gregor           Operand->isInstantiationDependent(),
550bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor           Operand->containsUnexpandedParameterPack()),
55157fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor      Operand(Operand), Range(R) { }
552c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl
55314ab24f01e36d495fce183aa67b41e45cdd54f39Chris Lattner  CXXTypeidExpr(EmptyShell Empty, bool isExpr)
55414ab24f01e36d495fce183aa67b41e45cdd54f39Chris Lattner    : Expr(CXXTypeidExprClass, Empty) {
55514ab24f01e36d495fce183aa67b41e45cdd54f39Chris Lattner    if (isExpr)
5566bcf27bb9a4b5c3f79cb44c0e4654a6d7619ad89Stephen Hines      Operand = (Expr*)nullptr;
55714ab24f01e36d495fce183aa67b41e45cdd54f39Chris Lattner    else
5586bcf27bb9a4b5c3f79cb44c0e4654a6d7619ad89Stephen Hines      Operand = (TypeSourceInfo*)nullptr;
55914ab24f01e36d495fce183aa67b41e45cdd54f39Chris Lattner  }
560ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie
5610d729105ecb50a7e3cbe6e57c29149edfa5cf05aRichard Smith  /// Determine whether this typeid has a type operand which is potentially
5620d729105ecb50a7e3cbe6e57c29149edfa5cf05aRichard Smith  /// evaluated, per C++11 [expr.typeid]p3.
5630d729105ecb50a7e3cbe6e57c29149edfa5cf05aRichard Smith  bool isPotentiallyEvaluated() const;
5640d729105ecb50a7e3cbe6e57c29149edfa5cf05aRichard Smith
565