clang  7.0.0
ExprCXX.h
Go to the documentation of this file.
1 //===- ExprCXX.h - Classes for representing expressions ---------*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 /// \file
11 /// Defines the clang::Expr interface and subclasses for C++ expressions.
12 //
13 //===----------------------------------------------------------------------===//
14 
15 #ifndef LLVM_CLANG_AST_EXPRCXX_H
16 #define LLVM_CLANG_AST_EXPRCXX_H
17 
18 #include "clang/AST/Decl.h"
19 #include "clang/AST/DeclBase.h"
20 #include "clang/AST/DeclCXX.h"
22 #include "clang/AST/Expr.h"
25 #include "clang/AST/Stmt.h"
26 #include "clang/AST/TemplateBase.h"
27 #include "clang/AST/Type.h"
31 #include "clang/Basic/LLVM.h"
32 #include "clang/Basic/Lambda.h"
36 #include "clang/Basic/Specifiers.h"
37 #include "clang/Basic/TypeTraits.h"
38 #include "llvm/ADT/ArrayRef.h"
39 #include "llvm/ADT/None.h"
40 #include "llvm/ADT/Optional.h"
41 #include "llvm/ADT/PointerUnion.h"
42 #include "llvm/ADT/StringRef.h"
43 #include "llvm/ADT/iterator_range.h"
44 #include "llvm/Support/Casting.h"
45 #include "llvm/Support/Compiler.h"
46 #include "llvm/Support/TrailingObjects.h"
47 #include <cassert>
48 #include <cstddef>
49 #include <cstdint>
50 #include <memory>
51 
52 namespace clang {
53 
54 class ASTContext;
55 class DeclAccessPair;
56 class IdentifierInfo;
57 class LambdaCapture;
58 class NonTypeTemplateParmDecl;
59 class TemplateParameterList;
60 
61 //===--------------------------------------------------------------------===//
62 // C++ Expressions.
63 //===--------------------------------------------------------------------===//
64 
65 /// A call to an overloaded operator written using operator
66 /// syntax.
67 ///
68 /// Represents a call to an overloaded operator written using operator
69 /// syntax, e.g., "x + y" or "*p". While semantically equivalent to a
70 /// normal call, this AST node provides better information about the
71 /// syntactic representation of the call.
72 ///
73 /// In a C++ template, this expression node kind will be used whenever
74 /// any of the arguments are type-dependent. In this case, the
75 /// function itself will be a (possibly empty) set of functions and
76 /// function templates that were found by name lookup at template
77 /// definition time.
78 class CXXOperatorCallExpr : public CallExpr {
79  /// The overloaded operator.
80  OverloadedOperatorKind Operator;
81 
82  SourceRange Range;
83 
84  // Only meaningful for floating point types.
85  FPOptions FPFeatures;
86 
87  SourceRange getSourceRangeImpl() const LLVM_READONLY;
88 
89 public:
90  friend class ASTStmtReader;
91  friend class ASTStmtWriter;
92 
95  SourceLocation operatorloc, FPOptions FPFeatures)
96  : CallExpr(C, CXXOperatorCallExprClass, fn, args, t, VK, operatorloc),
97  Operator(Op), FPFeatures(FPFeatures) {
98  Range = getSourceRangeImpl();
99  }
100 
102  : CallExpr(C, CXXOperatorCallExprClass, Empty) {}
103 
104  /// Returns the kind of overloaded operator that this
105  /// expression refers to.
106  OverloadedOperatorKind getOperator() const { return Operator; }
107 
109  return Opc == OO_Equal || Opc == OO_StarEqual ||
110  Opc == OO_SlashEqual || Opc == OO_PercentEqual ||
111  Opc == OO_PlusEqual || Opc == OO_MinusEqual ||
112  Opc == OO_LessLessEqual || Opc == OO_GreaterGreaterEqual ||
113  Opc == OO_AmpEqual || Opc == OO_CaretEqual ||
114  Opc == OO_PipeEqual;
115  }
116  bool isAssignmentOp() const { return isAssignmentOp(getOperator()); }
117 
118  /// Is this written as an infix binary operator?
119  bool isInfixBinaryOp() const;
120 
121  /// Returns the location of the operator symbol in the expression.
122  ///
123  /// When \c getOperator()==OO_Call, this is the location of the right
124  /// parentheses; when \c getOperator()==OO_Subscript, this is the location
125  /// of the right bracket.
127 
128  SourceLocation getExprLoc() const LLVM_READONLY {
129  return (Operator < OO_Plus || Operator >= OO_Arrow ||
130  Operator == OO_PlusPlus || Operator == OO_MinusMinus)
131  ? getLocStart()
132  : getOperatorLoc();
133  }
134 
135  SourceLocation getLocStart() const LLVM_READONLY { return getBeginLoc(); }
136  SourceLocation getBeginLoc() const LLVM_READONLY { return Range.getBegin(); }
137  SourceLocation getLocEnd() const LLVM_READONLY { return getEndLoc(); }
138  SourceLocation getEndLoc() const LLVM_READONLY { return Range.getEnd(); }
139  SourceRange getSourceRange() const { return Range; }
140 
141  static bool classof(const Stmt *T) {
142  return T->getStmtClass() == CXXOperatorCallExprClass;
143  }
144 
145  // Set the FP contractability status of this operator. Only meaningful for
146  // operations on floating point types.
147  void setFPFeatures(FPOptions F) { FPFeatures = F; }
148 
149  FPOptions getFPFeatures() const { return FPFeatures; }
150 
151  // Get the FP contractability status of this operator. Only meaningful for
152  // operations on floating point types.
154  return FPFeatures.allowFPContractWithinStatement();
155  }
156 };
157 
158 /// Represents a call to a member function that
159 /// may be written either with member call syntax (e.g., "obj.func()"
160 /// or "objptr->func()") or with normal function-call syntax
161 /// ("func()") within a member function that ends up calling a member
162 /// function. The callee in either case is a MemberExpr that contains
163 /// both the object argument and the member function, while the
164 /// arguments are the arguments within the parentheses (not including
165 /// the object argument).
166 class CXXMemberCallExpr : public CallExpr {
167 public:
170  : CallExpr(C, CXXMemberCallExprClass, fn, args, t, VK, RP) {}
171 
173  : CallExpr(C, CXXMemberCallExprClass, Empty) {}
174 
175  /// Retrieves the implicit object argument for the member call.
176  ///
177  /// For example, in "x.f(5)", this returns the sub-expression "x".
178  Expr *getImplicitObjectArgument() const;
179 
180  /// Retrieves the declaration of the called method.
181  CXXMethodDecl *getMethodDecl() const;
182 
183  /// Retrieves the CXXRecordDecl for the underlying type of
184  /// the implicit object argument.
185  ///
186  /// Note that this is may not be the same declaration as that of the class
187  /// context of the CXXMethodDecl which this function is calling.
188  /// FIXME: Returns 0 for member pointer call exprs.
189  CXXRecordDecl *getRecordDecl() const;
190 
191  SourceLocation getExprLoc() const LLVM_READONLY {
192  SourceLocation CLoc = getCallee()->getExprLoc();
193  if (CLoc.isValid())
194  return CLoc;
195 
196  return getLocStart();
197  }
198 
199  static bool classof(const Stmt *T) {
200  return T->getStmtClass() == CXXMemberCallExprClass;
201  }
202 };
203 
204 /// Represents a call to a CUDA kernel function.
205 class CUDAKernelCallExpr : public CallExpr {
206 private:
207  enum { CONFIG, END_PREARG };
208 
209 public:
212  SourceLocation RP)
213  : CallExpr(C, CUDAKernelCallExprClass, fn, Config, args, t, VK, RP) {}
214 
216  : CallExpr(C, CUDAKernelCallExprClass, END_PREARG, Empty) {}
217 
218  const CallExpr *getConfig() const {
219  return cast_or_null<CallExpr>(getPreArg(CONFIG));
220  }
221  CallExpr *getConfig() { return cast_or_null<CallExpr>(getPreArg(CONFIG)); }
222 
223  /// Sets the kernel configuration expression.
224  ///
225  /// Note that this method cannot be called if config has already been set to a
226  /// non-null value.
227  void setConfig(CallExpr *E) {
228  assert(!getConfig() &&
229  "Cannot call setConfig if config is not null");
230  setPreArg(CONFIG, E);
235  }
236 
237  static bool classof(const Stmt *T) {
238  return T->getStmtClass() == CUDAKernelCallExprClass;
239  }
240 };
241 
242 /// Abstract class common to all of the C++ "named"/"keyword" casts.
243 ///
244 /// This abstract class is inherited by all of the classes
245 /// representing "named" casts: CXXStaticCastExpr for \c static_cast,
246 /// CXXDynamicCastExpr for \c dynamic_cast, CXXReinterpretCastExpr for
247 /// reinterpret_cast, and CXXConstCastExpr for \c const_cast.
249 private:
250  // the location of the casting op
251  SourceLocation Loc;
252 
253  // the location of the right parenthesis
254  SourceLocation RParenLoc;
255 
256  // range for '<' '>'
257  SourceRange AngleBrackets;
258 
259 protected:
260  friend class ASTStmtReader;
261 
263  CastKind kind, Expr *op, unsigned PathSize,
264  TypeSourceInfo *writtenTy, SourceLocation l,
265  SourceLocation RParenLoc,
266  SourceRange AngleBrackets)
267  : ExplicitCastExpr(SC, ty, VK, kind, op, PathSize, writtenTy), Loc(l),
268  RParenLoc(RParenLoc), AngleBrackets(AngleBrackets) {}
269 
270  explicit CXXNamedCastExpr(StmtClass SC, EmptyShell Shell, unsigned PathSize)
271  : ExplicitCastExpr(SC, Shell, PathSize) {}
272 
273 public:
274  const char *getCastName() const;
275 
276  /// Retrieve the location of the cast operator keyword, e.g.,
277  /// \c static_cast.
278  SourceLocation getOperatorLoc() const { return Loc; }
279 
280  /// Retrieve the location of the closing parenthesis.
281  SourceLocation getRParenLoc() const { return RParenLoc; }
282 
283  SourceLocation getLocStart() const LLVM_READONLY { return getBeginLoc(); }
284  SourceLocation getBeginLoc() const LLVM_READONLY { return Loc; }
285  SourceLocation getLocEnd() const LLVM_READONLY { return getEndLoc(); }
286  SourceLocation getEndLoc() const LLVM_READONLY { return RParenLoc; }
287  SourceRange getAngleBrackets() const LLVM_READONLY { return AngleBrackets; }
288 
289  static bool classof(const Stmt *T) {
290  switch (T->getStmtClass()) {
291  case CXXStaticCastExprClass:
292  case CXXDynamicCastExprClass:
293  case CXXReinterpretCastExprClass:
294  case CXXConstCastExprClass:
295  return true;
296  default:
297  return false;
298  }
299  }
300 };
301 
302 /// A C++ \c static_cast expression (C++ [expr.static.cast]).
303 ///
304 /// This expression node represents a C++ static cast, e.g.,
305 /// \c static_cast<int>(1.0).
306 class CXXStaticCastExpr final
307  : public CXXNamedCastExpr,
308  private llvm::TrailingObjects<CXXStaticCastExpr, CastExpr::BasePathSizeTy,
309  CXXBaseSpecifier *> {
311  unsigned pathSize, TypeSourceInfo *writtenTy,
312  SourceLocation l, SourceLocation RParenLoc,
313  SourceRange AngleBrackets)
314  : CXXNamedCastExpr(CXXStaticCastExprClass, ty, vk, kind, op, pathSize,
315  writtenTy, l, RParenLoc, AngleBrackets) {}
316 
317  explicit CXXStaticCastExpr(EmptyShell Empty, unsigned PathSize)
318  : CXXNamedCastExpr(CXXStaticCastExprClass, Empty, PathSize) {}
319 
320  size_t numTrailingObjects(OverloadToken<CastExpr::BasePathSizeTy>) const {
321  return path_empty() ? 0 : 1;
322  }
323 
324 public:
325  friend class CastExpr;
327 
328  static CXXStaticCastExpr *Create(const ASTContext &Context, QualType T,
329  ExprValueKind VK, CastKind K, Expr *Op,
330  const CXXCastPath *Path,
331  TypeSourceInfo *Written, SourceLocation L,
332  SourceLocation RParenLoc,
333  SourceRange AngleBrackets);
334  static CXXStaticCastExpr *CreateEmpty(const ASTContext &Context,
335  unsigned PathSize);
336 
337  static bool classof(const Stmt *T) {
338  return T->getStmtClass() == CXXStaticCastExprClass;
339  }
340 };
341 
342 /// A C++ @c dynamic_cast expression (C++ [expr.dynamic.cast]).
343 ///
344 /// This expression node represents a dynamic cast, e.g.,
345 /// \c dynamic_cast<Derived*>(BasePtr). Such a cast may perform a run-time
346 /// check to determine how to perform the type conversion.
348  : public CXXNamedCastExpr,
349  private llvm::TrailingObjects<
350  CXXDynamicCastExpr, CastExpr::BasePathSizeTy, CXXBaseSpecifier *> {
352  Expr *op, unsigned pathSize, TypeSourceInfo *writtenTy,
353  SourceLocation l, SourceLocation RParenLoc,
354  SourceRange AngleBrackets)
355  : CXXNamedCastExpr(CXXDynamicCastExprClass, ty, VK, kind, op, pathSize,
356  writtenTy, l, RParenLoc, AngleBrackets) {}
357 
358  explicit CXXDynamicCastExpr(EmptyShell Empty, unsigned pathSize)
359  : CXXNamedCastExpr(CXXDynamicCastExprClass, Empty, pathSize) {}
360 
361  size_t numTrailingObjects(OverloadToken<CastExpr::BasePathSizeTy>) const {
362  return path_empty() ? 0 : 1;
363  }
364 
365 public:
366  friend class CastExpr;
368 
369  static CXXDynamicCastExpr *Create(const ASTContext &Context, QualType T,
370  ExprValueKind VK, CastKind Kind, Expr *Op,
371  const CXXCastPath *Path,
372  TypeSourceInfo *Written, SourceLocation L,
373  SourceLocation RParenLoc,
374  SourceRange AngleBrackets);
375 
376  static CXXDynamicCastExpr *CreateEmpty(const ASTContext &Context,
377  unsigned pathSize);
378 
379  bool isAlwaysNull() const;
380 
381  static bool classof(const Stmt *T) {
382  return T->getStmtClass() == CXXDynamicCastExprClass;
383  }
384 };
385 
386 /// A C++ @c reinterpret_cast expression (C++ [expr.reinterpret.cast]).
387 ///
388 /// This expression node represents a reinterpret cast, e.g.,
389 /// @c reinterpret_cast<int>(VoidPtr).
390 ///
391 /// A reinterpret_cast provides a differently-typed view of a value but
392 /// (in Clang, as in most C++ implementations) performs no actual work at
393 /// run time.
395  : public CXXNamedCastExpr,
396  private llvm::TrailingObjects<CXXReinterpretCastExpr,
397  CastExpr::BasePathSizeTy,
398  CXXBaseSpecifier *> {
400  Expr *op, unsigned pathSize,
401  TypeSourceInfo *writtenTy, SourceLocation l,
402  SourceLocation RParenLoc,
403  SourceRange AngleBrackets)
404  : CXXNamedCastExpr(CXXReinterpretCastExprClass, ty, vk, kind, op,
405  pathSize, writtenTy, l, RParenLoc, AngleBrackets) {}
406 
407  CXXReinterpretCastExpr(EmptyShell Empty, unsigned pathSize)
408  : CXXNamedCastExpr(CXXReinterpretCastExprClass, Empty, pathSize) {}
409 
410  size_t numTrailingObjects(OverloadToken<CastExpr::BasePathSizeTy>) const {
411  return path_empty() ? 0 : 1;
412  }
413 
414 public:
415  friend class CastExpr;
417 
418  static CXXReinterpretCastExpr *Create(const ASTContext &Context, QualType T,
420  Expr *Op, const CXXCastPath *Path,
421  TypeSourceInfo *WrittenTy, SourceLocation L,
422  SourceLocation RParenLoc,
423  SourceRange AngleBrackets);
424  static CXXReinterpretCastExpr *CreateEmpty(const ASTContext &Context,
425  unsigned pathSize);
426 
427  static bool classof(const Stmt *T) {
428  return T->getStmtClass() == CXXReinterpretCastExprClass;
429  }
430 };
431 
432 /// A C++ \c const_cast expression (C++ [expr.const.cast]).
433 ///
434 /// This expression node represents a const cast, e.g.,
435 /// \c const_cast<char*>(PtrToConstChar).
436 ///
437 /// A const_cast can remove type qualifiers but does not change the underlying
438 /// value.
439 class CXXConstCastExpr final
440  : public CXXNamedCastExpr,
441  private llvm::TrailingObjects<CXXConstCastExpr, CastExpr::BasePathSizeTy,
442  CXXBaseSpecifier *> {
444  TypeSourceInfo *writtenTy, SourceLocation l,
445  SourceLocation RParenLoc, SourceRange AngleBrackets)
446  : CXXNamedCastExpr(CXXConstCastExprClass, ty, VK, CK_NoOp, op,
447  0, writtenTy, l, RParenLoc, AngleBrackets) {}
448 
449  explicit CXXConstCastExpr(EmptyShell Empty)
450  : CXXNamedCastExpr(CXXConstCastExprClass, Empty, 0) {}
451 
452  size_t numTrailingObjects(OverloadToken<CastExpr::BasePathSizeTy>) const {
453  return path_empty() ? 0 : 1;
454  }
455 
456 public:
457  friend class CastExpr;
459 
460  static CXXConstCastExpr *Create(const ASTContext &Context, QualType T,
461  ExprValueKind VK, Expr *Op,
462  TypeSourceInfo *WrittenTy, SourceLocation L,
463  SourceLocation RParenLoc,
464  SourceRange AngleBrackets);
465  static CXXConstCastExpr *CreateEmpty(const ASTContext &Context);
466 
467  static bool classof(const Stmt *T) {
468  return T->getStmtClass() == CXXConstCastExprClass;
469  }
470 };
471 
472 /// A call to a literal operator (C++11 [over.literal])
473 /// written as a user-defined literal (C++11 [lit.ext]).
474 ///
475 /// Represents a user-defined literal, e.g. "foo"_bar or 1.23_xyz. While this
476 /// is semantically equivalent to a normal call, this AST node provides better
477 /// information about the syntactic representation of the literal.
478 ///
479 /// Since literal operators are never found by ADL and can only be declared at
480 /// namespace scope, a user-defined literal is never dependent.
481 class UserDefinedLiteral : public CallExpr {
482  /// The location of a ud-suffix within the literal.
483  SourceLocation UDSuffixLoc;
484 
485 public:
486  friend class ASTStmtReader;
487  friend class ASTStmtWriter;
488 
490  QualType T, ExprValueKind VK, SourceLocation LitEndLoc,
491  SourceLocation SuffixLoc)
492  : CallExpr(C, UserDefinedLiteralClass, Fn, Args, T, VK, LitEndLoc),
493  UDSuffixLoc(SuffixLoc) {}
494 
495  explicit UserDefinedLiteral(const ASTContext &C, EmptyShell Empty)
496  : CallExpr(C, UserDefinedLiteralClass, Empty) {}
497 
498  /// The kind of literal operator which is invoked.
500  /// Raw form: operator "" X (const char *)
502 
503  /// Raw form: operator "" X<cs...> ()
505 
506  /// operator "" X (unsigned long long)
508 
509  /// operator "" X (long double)
511 
512  /// operator "" X (const CharT *, size_t)
514 
515  /// operator "" X (CharT)
516  LOK_Character
517  };
518 
519  /// Returns the kind of literal operator invocation
520  /// which this expression represents.
521  LiteralOperatorKind getLiteralOperatorKind() const;
522 
523  /// If this is not a raw user-defined literal, get the
524  /// underlying cooked literal (representing the literal with the suffix
525  /// removed).
526  Expr *getCookedLiteral();
527  const Expr *getCookedLiteral() const {
528  return const_cast<UserDefinedLiteral*>(this)->getCookedLiteral();
529  }
530 
531  SourceLocation getLocStart() const LLVM_READONLY { return getBeginLoc(); }
533  if (getLiteralOperatorKind() == LOK_Template)
534  return getRParenLoc();
535  return getArg(0)->getLocStart();
536  }
537 
538  SourceLocation getLocEnd() const LLVM_READONLY { return getEndLoc(); }
539  SourceLocation getEndLoc() const { return getRParenLoc(); }
540 
541  /// Returns the location of a ud-suffix in the expression.
542  ///
543  /// For a string literal, there may be multiple identical suffixes. This
544  /// returns the first.
545  SourceLocation getUDSuffixLoc() const { return UDSuffixLoc; }
546 
547  /// Returns the ud-suffix specified for this literal.
548  const IdentifierInfo *getUDSuffix() const;
549 
550  static bool classof(const Stmt *S) {
551  return S->getStmtClass() == UserDefinedLiteralClass;
552  }
553 };
554 
555 /// A boolean literal, per ([C++ lex.bool] Boolean literals).
556 class CXXBoolLiteralExpr : public Expr {
557  bool Value;
558  SourceLocation Loc;
559 
560 public:
562  : Expr(CXXBoolLiteralExprClass, Ty, VK_RValue, OK_Ordinary, false, false,
563  false, false),
564  Value(val), Loc(l) {}
565 
567  : Expr(CXXBoolLiteralExprClass, Empty) {}
568 
569  bool getValue() const { return Value; }
570  void setValue(bool V) { Value = V; }
571 
572  SourceLocation getLocStart() const LLVM_READONLY { return getBeginLoc(); }
573  SourceLocation getBeginLoc() const LLVM_READONLY { return Loc; }
574  SourceLocation getLocEnd() const LLVM_READONLY { return getEndLoc(); }
575  SourceLocation getEndLoc() const LLVM_READONLY { return Loc; }
576 
577  SourceLocation getLocation() const { return Loc; }
578  void setLocation(SourceLocation L) { Loc = L; }
579 
580  static bool classof(const Stmt *T) {
581  return T->getStmtClass() == CXXBoolLiteralExprClass;
582  }
583 
584  // Iterators
587  }
588 };
589 
590 /// The null pointer literal (C++11 [lex.nullptr])
591 ///
592 /// Introduced in C++11, the only literal of type \c nullptr_t is \c nullptr.
593 class CXXNullPtrLiteralExpr : public Expr {
594  SourceLocation Loc;
595 
596 public:
598  : Expr(CXXNullPtrLiteralExprClass, Ty, VK_RValue, OK_Ordinary, false,
599  false, false, false),
600  Loc(l) {}
601 
603  : Expr(CXXNullPtrLiteralExprClass, Empty) {}
604 
605  SourceLocation getLocStart() const LLVM_READONLY { return getBeginLoc(); }
606  SourceLocation getBeginLoc() const LLVM_READONLY { return Loc; }
607  SourceLocation getLocEnd() const LLVM_READONLY { return getEndLoc(); }
608  SourceLocation getEndLoc() const LLVM_READONLY { return Loc; }
609 
610  SourceLocation getLocation() const { return Loc; }
611  void setLocation(SourceLocation L) { Loc = L; }
612 
613  static bool classof(const Stmt *T) {
614  return T->getStmtClass() == CXXNullPtrLiteralExprClass;
615  }
616 
619  }
620 };
621 
622 /// Implicit construction of a std::initializer_list<T> object from an
623 /// array temporary within list-initialization (C++11 [dcl.init.list]p5).
625  Stmt *SubExpr = nullptr;
626 
628  : Expr(CXXStdInitializerListExprClass, Empty) {}
629 
630 public:
631  friend class ASTReader;
632  friend class ASTStmtReader;
633 
635  : Expr(CXXStdInitializerListExprClass, Ty, VK_RValue, OK_Ordinary,
636  Ty->isDependentType(), SubExpr->isValueDependent(),
637  SubExpr->isInstantiationDependent(),
639  SubExpr(SubExpr) {}
640 
641  Expr *getSubExpr() { return static_cast<Expr*>(SubExpr); }
642  const Expr *getSubExpr() const { return static_cast<const Expr*>(SubExpr); }
643 
644  SourceLocation getLocStart() const LLVM_READONLY { return getBeginLoc(); }
645  SourceLocation getBeginLoc() const LLVM_READONLY {
646  return SubExpr->getLocStart();
647  }
648 
649  SourceLocation getLocEnd() const LLVM_READONLY { return getEndLoc(); }
650  SourceLocation getEndLoc() const LLVM_READONLY {
651  return SubExpr->getLocEnd();
652  }
653 
654  /// Retrieve the source range of the expression.
655  SourceRange getSourceRange() const LLVM_READONLY {
656  return SubExpr->getSourceRange();
657  }
658 
659  static bool classof(const Stmt *S) {
660  return S->getStmtClass() == CXXStdInitializerListExprClass;
661  }
662 
663  child_range children() { return child_range(&SubExpr, &SubExpr + 1); }
664 };
665 
666 /// A C++ \c typeid expression (C++ [expr.typeid]), which gets
667 /// the \c type_info that corresponds to the supplied type, or the (possibly
668 /// dynamic) type of the supplied expression.
669 ///
670 /// This represents code like \c typeid(int) or \c typeid(*objPtr)
671 class CXXTypeidExpr : public Expr {
672 private:
673  llvm::PointerUnion<Stmt *, TypeSourceInfo *> Operand;
674  SourceRange Range;
675 
676 public:
678  : Expr(CXXTypeidExprClass, Ty, VK_LValue, OK_Ordinary,
679  // typeid is never type-dependent (C++ [temp.dep.expr]p4)
680  false,
681  // typeid is value-dependent if the type or expression are
682  // dependent
683  Operand->getType()->isDependentType(),
684  Operand->getType()->isInstantiationDependentType(),
686  Operand(Operand), Range(R) {}
687 
689  : Expr(CXXTypeidExprClass, Ty, VK_LValue, OK_Ordinary,
690  // typeid is never type-dependent (C++ [temp.dep.expr]p4)
691  false,
692  // typeid is value-dependent if the type or expression are
693  // dependent
694  Operand->isTypeDependent() || Operand->isValueDependent(),
695  Operand->isInstantiationDependent(),
697  Operand(Operand), Range(R) {}
698 
699  CXXTypeidExpr(EmptyShell Empty, bool isExpr)
700  : Expr(CXXTypeidExprClass, Empty) {
701  if (isExpr)
702  Operand = (Expr*)nullptr;
703  else
704  Operand = (TypeSourceInfo*)nullptr;
705  }
706 
707  /// Determine whether this typeid has a type operand which is potentially
708  /// evaluated, per C++11 [expr.typeid]p3.
709  bool isPotentiallyEvaluated() const;
710 
711  bool isTypeOperand() const { return Operand.is<TypeSourceInfo *>(); }
712 
713  /// Retrieves the type operand of this typeid() expression after
714  /// various required adjustments (removing reference types, cv-qualifiers).
715  QualType getTypeOperand(ASTContext &Context) const;
716 
717  /// Retrieve source information for the type operand.
719  assert(isTypeOperand() && "Cannot call getTypeOperand for typeid(expr)");
720  return Operand.get<TypeSourceInfo *>();
721  }
722 
724  assert(isTypeOperand() && "Cannot call getTypeOperand for typeid(expr)");
725  Operand = TSI;
726  }
727 
728  Expr *getExprOperand() const {
729  assert(!isTypeOperand() && "Cannot call getExprOperand for typeid(type)");
730  return static_cast<Expr*>(Operand.get<Stmt *>());
731  }
732 
733  void setExprOperand(Expr *E) {
734  assert(!isTypeOperand() && "Cannot call getExprOperand for typeid(type)");
735  Operand = E;
736  }
737 
738  SourceLocation getLocStart() const LLVM_READONLY { return getBeginLoc(); }
739  SourceLocation getBeginLoc() const LLVM_READONLY { return Range.getBegin(); }
740  SourceLocation getLocEnd() const LLVM_READONLY { return getEndLoc(); }
741  SourceLocation getEndLoc() const LLVM_READONLY { return Range.getEnd(); }
742  SourceRange getSourceRange() const LLVM_READONLY { return Range; }
743  void setSourceRange(SourceRange R) { Range = R; }
744 
745  static bool classof(const Stmt *T) {
746  return T->getStmtClass() == CXXTypeidExprClass;
747  }
748 
749  // Iterators
751  if (isTypeOperand())
753  auto **begin = reinterpret_cast<Stmt **>(&Operand);
754  return child_range(begin, begin + 1);
755  }
756 };
757 
758 /// A member reference to an MSPropertyDecl.
759 ///
760 /// This expression always has pseudo-object type, and therefore it is
761 /// typically not encountered in a fully-typechecked expression except
762 /// within the syntactic form of a PseudoObjectExpr.
763 class MSPropertyRefExpr : public Expr {
764  Expr *BaseExpr;
765  MSPropertyDecl *TheDecl;
766  SourceLocation MemberLoc;
767  bool IsArrow;
768  NestedNameSpecifierLoc QualifierLoc;
769 
770 public:
771  friend class ASTStmtReader;
772 
773  MSPropertyRefExpr(Expr *baseExpr, MSPropertyDecl *decl, bool isArrow,
774  QualType ty, ExprValueKind VK,
775  NestedNameSpecifierLoc qualifierLoc,
776  SourceLocation nameLoc)
777  : Expr(MSPropertyRefExprClass, ty, VK, OK_Ordinary,
778  /*type-dependent*/ false, baseExpr->isValueDependent(),
779  baseExpr->isInstantiationDependent(),
780  baseExpr->containsUnexpandedParameterPack()),
781  BaseExpr(baseExpr), TheDecl(decl),
782  MemberLoc(nameLoc), IsArrow(isArrow),
783  QualifierLoc(qualifierLoc) {}
784 
785  MSPropertyRefExpr(EmptyShell Empty) : Expr(MSPropertyRefExprClass, Empty) {}
786 
787  SourceRange getSourceRange() const LLVM_READONLY {
788  return SourceRange(getLocStart(), getLocEnd());
789  }
790 
791  bool isImplicitAccess() const {
792  return getBaseExpr() && getBaseExpr()->isImplicitCXXThis();
793  }
794 
795  SourceLocation getLocStart() const LLVM_READONLY { return getBeginLoc(); }
797  if (!isImplicitAccess())
798  return BaseExpr->getLocStart();
799  else if (QualifierLoc)
800  return QualifierLoc.getBeginLoc();
801  else
802  return MemberLoc;
803  }
804 
805  SourceLocation getLocEnd() const LLVM_READONLY { return getEndLoc(); }
806  SourceLocation getEndLoc() const { return getMemberLoc(); }
807 
809  return child_range((Stmt**)&BaseExpr, (Stmt**)&BaseExpr + 1);
810  }
811 
812  static bool classof(const Stmt *T) {
813  return T->getStmtClass() == MSPropertyRefExprClass;
814  }
815 
816  Expr *getBaseExpr() const { return BaseExpr; }
817  MSPropertyDecl *getPropertyDecl() const { return TheDecl; }
818  bool isArrow() const { return IsArrow; }
819  SourceLocation getMemberLoc() const { return MemberLoc; }
820  NestedNameSpecifierLoc getQualifierLoc() const { return QualifierLoc; }
821 };
822 
823 /// MS property subscript expression.
824 /// MSVC supports 'property' attribute and allows to apply it to the
825 /// declaration of an empty array in a class or structure definition.
826 /// For example:
827 /// \code
828 /// __declspec(property(get=GetX, put=PutX)) int x[];
829 /// \endcode
830 /// The above statement indicates that x[] can be used with one or more array
831 /// indices. In this case, i=p->x[a][b] will be turned into i=p->GetX(a, b), and
832 /// p->x[a][b] = i will be turned into p->PutX(a, b, i).
833 /// This is a syntactic pseudo-object expression.
835  friend class ASTStmtReader;
836 
837  enum { BASE_EXPR, IDX_EXPR, NUM_SUBEXPRS = 2 };
838 
839  Stmt *SubExprs[NUM_SUBEXPRS];
840  SourceLocation RBracketLoc;
841 
842  void setBase(Expr *Base) { SubExprs[BASE_EXPR] = Base; }
843  void setIdx(Expr *Idx) { SubExprs[IDX_EXPR] = Idx; }
844 
845 public:
847  ExprObjectKind OK, SourceLocation RBracketLoc)
848  : Expr(MSPropertySubscriptExprClass, Ty, VK, OK, Idx->isTypeDependent(),
851  RBracketLoc(RBracketLoc) {
852  SubExprs[BASE_EXPR] = Base;
853  SubExprs[IDX_EXPR] = Idx;
854  }
855 
856  /// Create an empty array subscript expression.
858  : Expr(MSPropertySubscriptExprClass, Shell) {}
859 
860  Expr *getBase() { return cast<Expr>(SubExprs[BASE_EXPR]); }
861  const Expr *getBase() const { return cast<Expr>(SubExprs[BASE_EXPR]); }
862 
863  Expr *getIdx() { return cast<Expr>(SubExprs[IDX_EXPR]); }
864  const Expr *getIdx() const { return cast<Expr>(SubExprs[IDX_EXPR]); }
865 
866  SourceLocation getLocStart() const LLVM_READONLY { return getBeginLoc(); }
867  SourceLocation getBeginLoc() const LLVM_READONLY {
868  return getBase()->getLocStart();
869  }
870 
871  SourceLocation getLocEnd() const LLVM_READONLY { return getEndLoc(); }
872  SourceLocation getEndLoc() const LLVM_READONLY { return RBracketLoc; }
873 
874  SourceLocation getRBracketLoc() const { return RBracketLoc; }
875  void setRBracketLoc(SourceLocation L) { RBracketLoc = L; }
876 
877  SourceLocation getExprLoc() const LLVM_READONLY {
878  return getBase()->getExprLoc();
879  }
880 
881  static bool classof(const Stmt *T) {
882  return T->getStmtClass() == MSPropertySubscriptExprClass;
883  }
884 
885  // Iterators
887  return child_range(&SubExprs[0], &SubExprs[0] + NUM_SUBEXPRS);
888  }
889 };
890 
891 /// A Microsoft C++ @c __uuidof expression, which gets
892 /// the _GUID that corresponds to the supplied type or expression.
893 ///
894 /// This represents code like @c __uuidof(COMTYPE) or @c __uuidof(*comPtr)
895 class CXXUuidofExpr : public Expr {
896 private:
897  llvm::PointerUnion<Stmt *, TypeSourceInfo *> Operand;
898  StringRef UuidStr;
899  SourceRange Range;
900 
901 public:
902  CXXUuidofExpr(QualType Ty, TypeSourceInfo *Operand, StringRef UuidStr,
903  SourceRange R)
904  : Expr(CXXUuidofExprClass, Ty, VK_LValue, OK_Ordinary, false,
905  Operand->getType()->isDependentType(),
906  Operand->getType()->isInstantiationDependentType(),
908  Operand(Operand), UuidStr(UuidStr), Range(R) {}
909 
910  CXXUuidofExpr(QualType Ty, Expr *Operand, StringRef UuidStr, SourceRange R)
911  : Expr(CXXUuidofExprClass, Ty, VK_LValue, OK_Ordinary, false,
912  Operand->isTypeDependent(), Operand->isInstantiationDependent(),
914  Operand(Operand), UuidStr(UuidStr), Range(R) {}
915 
916  CXXUuidofExpr(EmptyShell Empty, bool isExpr)
917  : Expr(CXXUuidofExprClass, Empty) {
918  if (isExpr)
919  Operand = (Expr*)nullptr;
920  else
921  Operand = (TypeSourceInfo*)nullptr;
922  }
923 
924  bool isTypeOperand() const { return Operand.is<TypeSourceInfo *>(); }
925 
926  /// Retrieves the type operand of this __uuidof() expression after
927  /// various required adjustments (removing reference types, cv-qualifiers).
928  QualType getTypeOperand(ASTContext &Context) const;
929 
930  /// Retrieve source information for the type operand.
932  assert(isTypeOperand() && "Cannot call getTypeOperand for __uuidof(expr)");
933  return Operand.get<TypeSourceInfo *>();
934  }
935 
937  assert(isTypeOperand() && "Cannot call getTypeOperand for __uuidof(expr)");
938  Operand = TSI;
939  }
940 
941  Expr *getExprOperand() const {
942  assert(!isTypeOperand() && "Cannot call getExprOperand for __uuidof(type)");
943  return static_cast<Expr*>(Operand.get<Stmt *>());
944  }
945 
946  void setExprOperand(Expr *E) {
947  assert(!isTypeOperand() && "Cannot call getExprOperand for __uuidof(type)");
948  Operand = E;
949  }
950 
951  void setUuidStr(StringRef US) { UuidStr = US; }
952  StringRef getUuidStr() const { return UuidStr; }
953 
954  SourceLocation getLocStart() const LLVM_READONLY { return getBeginLoc(); }
955  SourceLocation getBeginLoc() const LLVM_READONLY { return Range.getBegin(); }
956  SourceLocation getLocEnd() const LLVM_READONLY { return getEndLoc(); }
957  SourceLocation getEndLoc() const LLVM_READONLY { return Range.getEnd(); }
958  SourceRange getSourceRange() const LLVM_READONLY { return Range; }
959  void setSourceRange(SourceRange R) { Range = R; }
960 
961  static bool classof(const Stmt *T) {
962  return T->getStmtClass() == CXXUuidofExprClass;
963  }
964 
965  // Iterators
967  if (isTypeOperand())
969  auto **begin = reinterpret_cast<Stmt **>(&Operand);
970  return child_range(begin, begin + 1);
971  }
972 };
973 
974 /// Represents the \c this expression in C++.
975 ///
976 /// This is a pointer to the object on which the current member function is
977 /// executing (C++ [expr.prim]p3). Example:
978 ///
979 /// \code
980 /// class Foo {
981 /// public:
982 /// void bar();
983 /// void test() { this->bar(); }
984 /// };
985 /// \endcode
986 class CXXThisExpr : public Expr {
987  SourceLocation Loc;
988  bool Implicit : 1;
989 
990 public:
992  : Expr(CXXThisExprClass, Type, VK_RValue, OK_Ordinary,
993  // 'this' is type-dependent if the class type of the enclosing
994  // member function is dependent (C++ [temp.dep.expr]p2)
995  Type->isDependentType(), Type->isDependentType(),
996  Type->isInstantiationDependentType(),
997  /*ContainsUnexpandedParameterPack=*/false),
998  Loc(L), Implicit(isImplicit) {}
999 
1000  CXXThisExpr(EmptyShell Empty) : Expr(CXXThisExprClass, Empty) {}
1001 
1002  SourceLocation getLocation() const { return Loc; }
1003  void setLocation(SourceLocation L) { Loc = L; }
1004 
1005  SourceLocation getLocStart() const LLVM_READONLY { return getBeginLoc(); }
1006  SourceLocation getBeginLoc() const LLVM_READONLY { return Loc; }
1007  SourceLocation getLocEnd() const LLVM_READONLY { return getEndLoc(); }
1008  SourceLocation getEndLoc() const LLVM_READONLY { return Loc; }
1009 
1010  bool isImplicit() const { return Implicit; }
1011  void setImplicit(bool I) { Implicit = I; }
1012 
1013  static bool classof(const Stmt *T) {
1014  return T->getStmtClass() == CXXThisExprClass;
1015  }
1016 
1017  // Iterators
1020  }
1021 };
1022 
1023 /// A C++ throw-expression (C++ [except.throw]).
1024 ///
1025 /// This handles 'throw' (for re-throwing the current exception) and
1026 /// 'throw' assignment-expression. When assignment-expression isn't
1027 /// present, Op will be null.
1028 class CXXThrowExpr : public Expr {
1029  friend class ASTStmtReader;
1030 
1031  Stmt *Op;
1032  SourceLocation ThrowLoc;
1033 
1034  /// Whether the thrown variable (if any) is in scope.
1035  unsigned IsThrownVariableInScope : 1;
1036 
1037 public:
1038  // \p Ty is the void type which is used as the result type of the
1039  // expression. The \p l is the location of the throw keyword. \p expr
1040  // can by null, if the optional expression to throw isn't present.
1042  bool IsThrownVariableInScope)
1043  : Expr(CXXThrowExprClass, Ty, VK_RValue, OK_Ordinary, false, false,
1044  expr && expr->isInstantiationDependent(),
1045  expr && expr->containsUnexpandedParameterPack()),
1046  Op(expr), ThrowLoc(l),
1047  IsThrownVariableInScope(IsThrownVariableInScope) {}
1048  CXXThrowExpr(EmptyShell Empty) : Expr(CXXThrowExprClass, Empty) {}
1049 
1050  const Expr *getSubExpr() const { return cast_or_null<Expr>(Op); }
1051  Expr *getSubExpr() { return cast_or_null<Expr>(Op); }
1052 
1053  SourceLocation getThrowLoc() const { return ThrowLoc; }
1054 
1055  /// Determines whether the variable thrown by this expression (if any!)
1056  /// is within the innermost try block.
1057  ///
1058  /// This information is required to determine whether the NRVO can apply to
1059  /// this variable.
1060  bool isThrownVariableInScope() const { return IsThrownVariableInScope; }
1061 
1062  SourceLocation getLocStart() const LLVM_READONLY { return getBeginLoc(); }
1063  SourceLocation getBeginLoc() const LLVM_READONLY { return ThrowLoc; }
1064 
1065  SourceLocation getLocEnd() const LLVM_READONLY { return getEndLoc(); }
1066  SourceLocation getEndLoc() const LLVM_READONLY {
1067  if (!getSubExpr())
1068  return ThrowLoc;
1069  return getSubExpr()->getLocEnd();
1070  }
1071 
1072  static bool classof(const Stmt *T) {
1073  return T->getStmtClass() == CXXThrowExprClass;
1074  }
1075 
1076  // Iterators
1078  return child_range(&Op, Op ? &Op+1 : &Op);
1079  }
1080 };
1081 
1082 /// A default argument (C++ [dcl.fct.default]).
1083 ///
1084 /// This wraps up a function call argument that was created from the
1085 /// corresponding parameter's default argument, when the call did not
1086 /// explicitly supply arguments for all of the parameters.
1087 class CXXDefaultArgExpr final : public Expr {
1088  /// The parameter whose default is being used.
1089  ParmVarDecl *Param;
1090 
1091  /// The location where the default argument expression was used.
1092  SourceLocation Loc;
1093 
1095  : Expr(SC,
1096  param->hasUnparsedDefaultArg()
1097  ? param->getType().getNonReferenceType()
1098  : param->getDefaultArg()->getType(),
1099  param->getDefaultArg()->getValueKind(),
1100  param->getDefaultArg()->getObjectKind(), false, false, false,
1101  false),
1102  Param(param), Loc(Loc) {}
1103 
1104 public:
1105  friend class ASTStmtReader;
1106  friend class ASTStmtWriter;
1107 
1108  CXXDefaultArgExpr(EmptyShell Empty) : Expr(CXXDefaultArgExprClass, Empty) {}
1109 
1110  // \p Param is the parameter whose default argument is used by this
1111  // expression.
1113  ParmVarDecl *Param) {
1114  return new (C) CXXDefaultArgExpr(CXXDefaultArgExprClass, Loc, Param);
1115  }
1116 
1117  // Retrieve the parameter that the argument was created from.
1118  const ParmVarDecl *getParam() const { return Param; }
1119  ParmVarDecl *getParam() { return Param; }
1120 
1121  // Retrieve the actual argument to the function call.
1122  const Expr *getExpr() const {
1123  return getParam()->getDefaultArg();
1124  }
1126  return getParam()->getDefaultArg();
1127  }
1128 
1129  /// Retrieve the location where this default argument was actually
1130  /// used.
1131  SourceLocation getUsedLocation() const { return Loc; }
1132 
1133  /// Default argument expressions have no representation in the
1134  /// source, so they have an empty source range.
1135  SourceLocation getLocStart() const LLVM_READONLY { return getBeginLoc(); }
1136  SourceLocation getBeginLoc() const LLVM_READONLY { return SourceLocation(); }
1137  SourceLocation getLocEnd() const LLVM_READONLY { return getEndLoc(); }
1138  SourceLocation getEndLoc() const LLVM_READONLY { return SourceLocation(); }
1139 
1140  SourceLocation getExprLoc() const LLVM_READONLY { return Loc; }
1141 
1142  static bool classof(const Stmt *T) {
1143  return T->getStmtClass() == CXXDefaultArgExprClass;
1144  }
1145 
1146  // Iterators
1149  }
1150 };
1151 
1152 /// A use of a default initializer in a constructor or in aggregate
1153 /// initialization.
1154 ///
1155 /// This wraps a use of a C++ default initializer (technically,
1156 /// a brace-or-equal-initializer for a non-static data member) when it
1157 /// is implicitly used in a mem-initializer-list in a constructor
1158 /// (C++11 [class.base.init]p8) or in aggregate initialization
1159 /// (C++1y [dcl.init.aggr]p7).
1160 class CXXDefaultInitExpr : public Expr {
1161  /// The field whose default is being used.
1162  FieldDecl *Field;
1163 
1164  /// The location where the default initializer expression was used.
1165  SourceLocation Loc;
1166 
1168  QualType T);
1169 
1170  CXXDefaultInitExpr(EmptyShell Empty) : Expr(CXXDefaultInitExprClass, Empty) {}
1171 
1172 public:
1173  friend class ASTReader;
1174  friend class ASTStmtReader;
1175 
1176  /// \p Field is the non-static data member whose default initializer is used
1177  /// by this expression.
1179  FieldDecl *Field) {
1180  return new (C) CXXDefaultInitExpr(C, Loc, Field, Field->getType());
1181  }
1182 
1183  /// Get the field whose initializer will be used.
1184  FieldDecl *getField() { return Field; }
1185  const FieldDecl *getField() const { return Field; }
1186 
1187  /// Get the initialization expression that will be used.
1188  const Expr *getExpr() const {
1189  assert(Field->getInClassInitializer() && "initializer hasn't been parsed");
1190  return Field->getInClassInitializer();
1191  }
1193  assert(Field->getInClassInitializer() && "initializer hasn't been parsed");
1194  return Field->getInClassInitializer();
1195  }
1196 
1197  SourceLocation getLocStart() const LLVM_READONLY { return getBeginLoc(); }
1198  SourceLocation getBeginLoc() const LLVM_READONLY { return Loc; }
1199  SourceLocation getLocEnd() const LLVM_READONLY { return getEndLoc(); }
1200  SourceLocation getEndLoc() const LLVM_READONLY { return Loc; }
1201 
1202  static bool classof(const Stmt *T) {
1203  return T->getStmtClass() == CXXDefaultInitExprClass;
1204  }
1205 
1206  // Iterators
1209  }
1210 };
1211 
1212 /// Represents a C++ temporary.
1214  /// The destructor that needs to be called.
1215  const CXXDestructorDecl *Destructor;
1216 
1217  explicit CXXTemporary(const CXXDestructorDecl *destructor)
1218  : Destructor(destructor) {}
1219 
1220 public:
1221  static CXXTemporary *Create(const ASTContext &C,
1222  const CXXDestructorDecl *Destructor);
1223 
1224  const CXXDestructorDecl *getDestructor() const { return Destructor; }
1225 
1226  void setDestructor(const CXXDestructorDecl *Dtor) {
1227  Destructor = Dtor;
1228  }
1229 };
1230 
1231 /// Represents binding an expression to a temporary.
1232 ///
1233 /// This ensures the destructor is called for the temporary. It should only be
1234 /// needed for non-POD, non-trivially destructable class types. For example:
1235 ///
1236 /// \code
1237 /// struct S {
1238 /// S() { } // User defined constructor makes S non-POD.
1239 /// ~S() { } // User defined destructor makes it non-trivial.
1240 /// };
1241 /// void test() {
1242 /// const S &s_ref = S(); // Requires a CXXBindTemporaryExpr.
1243 /// }
1244 /// \endcode
1245 class CXXBindTemporaryExpr : public Expr {
1246  CXXTemporary *Temp = nullptr;
1247  Stmt *SubExpr = nullptr;
1248 
1249  CXXBindTemporaryExpr(CXXTemporary *temp, Expr* SubExpr)
1250  : Expr(CXXBindTemporaryExprClass, SubExpr->getType(),
1251  VK_RValue, OK_Ordinary, SubExpr->isTypeDependent(),
1252  SubExpr->isValueDependent(),
1253  SubExpr->isInstantiationDependent(),
1254  SubExpr->containsUnexpandedParameterPack()),
1255  Temp(temp), SubExpr(SubExpr) {}
1256 
1257 public:
1259  : Expr(CXXBindTemporaryExprClass, Empty) {}
1260 
1261  static CXXBindTemporaryExpr *Create(const ASTContext &C, CXXTemporary *Temp,
1262  Expr* SubExpr);
1263 
1264  CXXTemporary *getTemporary() { return Temp; }
1265  const CXXTemporary *getTemporary() const { return Temp; }
1266  void setTemporary(CXXTemporary *T) { Temp = T; }
1267 
1268  const Expr *getSubExpr() const { return cast<Expr>(SubExpr); }
1269  Expr *getSubExpr() { return cast<Expr>(SubExpr); }
1270  void setSubExpr(Expr *E) { SubExpr = E; }
1271 
1272  SourceLocation getLocStart() const LLVM_READONLY { return getBeginLoc(); }
1273  SourceLocation getBeginLoc() const LLVM_READONLY {
1274  return SubExpr->getLocStart();
1275  }
1276 
1277  SourceLocation getLocEnd() const LLVM_READONLY { return getEndLoc(); }
1278  SourceLocation getEndLoc() const LLVM_READONLY {
1279  return SubExpr->getLocEnd();
1280  }
1281 
1282  // Implement isa/cast/dyncast/etc.
1283  static bool classof(const Stmt *T) {
1284  return T->getStmtClass() == CXXBindTemporaryExprClass;
1285  }
1286 
1287  // Iterators
1288  child_range children() { return child_range(&SubExpr, &SubExpr + 1); }
1289 };
1290 
1291 /// Represents a call to a C++ constructor.
1292 class CXXConstructExpr : public Expr {
1293 public:
1298  CK_Delegating
1299  };
1300 
1301 private:
1302  CXXConstructorDecl *Constructor = nullptr;
1303  SourceLocation Loc;
1304  SourceRange ParenOrBraceRange;
1305  unsigned NumArgs : 16;
1306  unsigned Elidable : 1;
1307  unsigned HadMultipleCandidates : 1;
1308  unsigned ListInitialization : 1;
1309  unsigned StdInitListInitialization : 1;
1310  unsigned ZeroInitialization : 1;
1311  unsigned ConstructKind : 2;
1312  Stmt **Args = nullptr;
1313 
1314  void setConstructor(CXXConstructorDecl *C) { Constructor = C; }
1315 
1316 protected:
1318  SourceLocation Loc,
1319  CXXConstructorDecl *Ctor,
1320  bool Elidable,
1321  ArrayRef<Expr *> Args,
1322  bool HadMultipleCandidates,
1323  bool ListInitialization,
1324  bool StdInitListInitialization,
1325  bool ZeroInitialization,
1326  ConstructionKind ConstructKind,
1327  SourceRange ParenOrBraceRange);
1328 
1329  /// Construct an empty C++ construction expression.
1331  : Expr(SC, Empty), NumArgs(0), Elidable(false),
1332  HadMultipleCandidates(false), ListInitialization(false),
1333  ZeroInitialization(false), ConstructKind(0) {}
1334 
1335 public:
1336  friend class ASTStmtReader;
1337 
1338  /// Construct an empty C++ construction expression.
1340  : CXXConstructExpr(CXXConstructExprClass, Empty) {}
1341 
1342  static CXXConstructExpr *Create(const ASTContext &C, QualType T,
1343  SourceLocation Loc,
1344  CXXConstructorDecl *Ctor,
1345  bool Elidable,
1346  ArrayRef<Expr *> Args,
1347  bool HadMultipleCandidates,
1348  bool ListInitialization,
1349  bool StdInitListInitialization,
1350  bool ZeroInitialization,
1351  ConstructionKind ConstructKind,
1352  SourceRange ParenOrBraceRange);
1353 
1354  /// Get the constructor that this expression will (ultimately) call.
1355  CXXConstructorDecl *getConstructor() const { return Constructor; }
1356 
1357  SourceLocation getLocation() const { return Loc; }
1358  void setLocation(SourceLocation Loc) { this->Loc = Loc; }
1359 
1360  /// Whether this construction is elidable.
1361  bool isElidable() const { return Elidable; }
1362  void setElidable(bool E) { Elidable = E; }
1363 
1364  /// Whether the referred constructor was resolved from
1365  /// an overloaded set having size greater than 1.
1366  bool hadMultipleCandidates() const { return HadMultipleCandidates; }
1367  void setHadMultipleCandidates(bool V) { HadMultipleCandidates = V; }
1368 
1369  /// Whether this constructor call was written as list-initialization.
1370  bool isListInitialization() const { return ListInitialization; }
1371  void setListInitialization(bool V) { ListInitialization = V; }
1372 
1373  /// Whether this constructor call was written as list-initialization,
1374  /// but was interpreted as forming a std::initializer_list<T> from the list
1375  /// and passing that as a single constructor argument.
1376  /// See C++11 [over.match.list]p1 bullet 1.
1377  bool isStdInitListInitialization() const { return StdInitListInitialization; }
1378  void setStdInitListInitialization(bool V) { StdInitListInitialization = V; }
1379 
1380  /// Whether this construction first requires
1381  /// zero-initialization before the initializer is called.
1382  bool requiresZeroInitialization() const { return ZeroInitialization; }
1383  void setRequiresZeroInitialization(bool ZeroInit) {
1384  ZeroInitialization = ZeroInit;
1385  }
1386 
1387  /// Determine whether this constructor is actually constructing
1388  /// a base class (rather than a complete object).
1390  return (ConstructionKind)ConstructKind;
1391  }
1393  ConstructKind = CK;
1394  }
1395 
1398  using arg_range = llvm::iterator_range<arg_iterator>;
1399  using arg_const_range = llvm::iterator_range<const_arg_iterator>;
1400 
1403  return arg_const_range(arg_begin(), arg_end());
1404  }
1405 
1406  arg_iterator arg_begin() { return Args; }
1407  arg_iterator arg_end() { return Args + NumArgs; }
1408  const_arg_iterator arg_begin() const { return Args; }
1409  const_arg_iterator arg_end() const { return Args + NumArgs; }
1410 
1411  Expr **getArgs() { return reinterpret_cast<Expr **>(Args); }
1412  const Expr *const *getArgs() const {
1413  return const_cast<CXXConstructExpr *>(this)->getArgs();
1414  }
1415  unsigned getNumArgs() const { return NumArgs; }
1416 
1417  /// Return the specified argument.
1418  Expr *getArg(unsigned Arg) {
1419  assert(Arg < NumArgs && "Arg access out of range!");
1420  return cast<Expr>(Args[Arg]);
1421  }
1422  const Expr *getArg(unsigned Arg) const {
1423  assert(Arg < NumArgs && "Arg access out of range!");
1424  return cast<Expr>(Args[Arg]);
1425  }
1426 
1427  /// Set the specified argument.
1428  void setArg(unsigned Arg, Expr *ArgExpr) {
1429  assert(Arg < NumArgs && "Arg access out of range!");
1430  Args[Arg] = ArgExpr;
1431  }
1432 
1433  SourceLocation getLocStart() const LLVM_READONLY { return getBeginLoc(); }
1434  SourceLocation getBeginLoc() const LLVM_READONLY;
1435  SourceLocation getLocEnd() const LLVM_READONLY { return getEndLoc(); }
1436  SourceLocation getEndLoc() const LLVM_READONLY;
1437  SourceRange getParenOrBraceRange() const { return ParenOrBraceRange; }
1438  void setParenOrBraceRange(SourceRange Range) { ParenOrBraceRange = Range; }
1439 
1440  static bool classof(const Stmt *T) {
1441  return T->getStmtClass() == CXXConstructExprClass ||
1442  T->getStmtClass() == CXXTemporaryObjectExprClass;
1443  }
1444 
1445  // Iterators
1447  return child_range(&Args[0], &Args[0]+NumArgs);
1448  }
1449 };
1450 
1451 /// Represents a call to an inherited base class constructor from an
1452 /// inheriting constructor. This call implicitly forwards the arguments from
1453 /// the enclosing context (an inheriting constructor) to the specified inherited
1454 /// base class constructor.
1456 private:
1457  CXXConstructorDecl *Constructor = nullptr;
1458 
1459  /// The location of the using declaration.
1460  SourceLocation Loc;
1461 
1462  /// Whether this is the construction of a virtual base.
1463  unsigned ConstructsVirtualBase : 1;
1464 
1465  /// Whether the constructor is inherited from a virtual base class of the
1466  /// class that we construct.
1467  unsigned InheritedFromVirtualBase : 1;
1468 
1469 public:
1470  friend class ASTStmtReader;
1471 
1472  /// Construct a C++ inheriting construction expression.
1474  CXXConstructorDecl *Ctor, bool ConstructsVirtualBase,
1475  bool InheritedFromVirtualBase)
1476  : Expr(CXXInheritedCtorInitExprClass, T, VK_RValue, OK_Ordinary, false,
1477  false, false, false),
1478  Constructor(Ctor), Loc(Loc),
1479  ConstructsVirtualBase(ConstructsVirtualBase),
1480  InheritedFromVirtualBase(InheritedFromVirtualBase) {
1481  assert(!T->isDependentType());
1482  }
1483 
1484  /// Construct an empty C++ inheriting construction expression.
1486  : Expr(CXXInheritedCtorInitExprClass, Empty),
1487  ConstructsVirtualBase(false), InheritedFromVirtualBase(false) {}
1488 
1489  /// Get the constructor that this expression will call.
1490  CXXConstructorDecl *getConstructor() const { return Constructor; }
1491 
1492  /// Determine whether this constructor is actually constructing
1493  /// a base class (rather than a complete object).
1494  bool constructsVBase() const { return ConstructsVirtualBase; }
1496  return ConstructsVirtualBase ? CXXConstructExpr::CK_VirtualBase
1498  }
1499 
1500  /// Determine whether the inherited constructor is inherited from a
1501  /// virtual base of the object we construct. If so, we are not responsible
1502  /// for calling the inherited constructor (the complete object constructor
1503  /// does that), and so we don't need to pass any arguments.
1504  bool inheritedFromVBase() const { return InheritedFromVirtualBase; }
1505 
1506  SourceLocation getLocation() const LLVM_READONLY { return Loc; }
1507  SourceLocation getLocStart() const LLVM_READONLY { return getBeginLoc(); }
1508  SourceLocation getBeginLoc() const LLVM_READONLY { return Loc; }
1509  SourceLocation getLocEnd() const LLVM_READONLY { return getEndLoc(); }
1510  SourceLocation getEndLoc() const LLVM_READONLY { return Loc; }
1511 
1512  static bool classof(const Stmt *T) {
1513  return T->getStmtClass() == CXXInheritedCtorInitExprClass;
1514  }
1515 
1518  }
1519 };
1520 
1521 /// Represents an explicit C++ type conversion that uses "functional"
1522 /// notation (C++ [expr.type.conv]).
1523 ///
1524 /// Example:
1525 /// \code
1526 /// x = int(0.5);
1527 /// \endcode
1529  : public ExplicitCastExpr,
1530  private llvm::TrailingObjects<
1531  CXXFunctionalCastExpr, CastExpr::BasePathSizeTy, CXXBaseSpecifier *> {
1532  SourceLocation LParenLoc;
1533  SourceLocation RParenLoc;
1534 
1536  TypeSourceInfo *writtenTy,
1537  CastKind kind, Expr *castExpr, unsigned pathSize,
1538  SourceLocation lParenLoc, SourceLocation rParenLoc)
1539  : ExplicitCastExpr(CXXFunctionalCastExprClass, ty, VK, kind,
1540  castExpr, pathSize, writtenTy),
1541  LParenLoc(lParenLoc), RParenLoc(rParenLoc) {}
1542 
1543  explicit CXXFunctionalCastExpr(EmptyShell Shell, unsigned PathSize)
1544  : ExplicitCastExpr(CXXFunctionalCastExprClass, Shell, PathSize) {}
1545 
1546  size_t numTrailingObjects(OverloadToken<CastExpr::BasePathSizeTy>) const {
1547  return path_empty() ? 0 : 1;
1548  }
1549 
1550 public:
1551  friend class CastExpr;
1553 
1554  static CXXFunctionalCastExpr *Create(const ASTContext &Context, QualType T,
1555  ExprValueKind VK,
1556  TypeSourceInfo *Written,
1557  CastKind Kind, Expr *Op,
1558  const CXXCastPath *Path,
1559  SourceLocation LPLoc,
1560  SourceLocation RPLoc);
1561  static CXXFunctionalCastExpr *CreateEmpty(const ASTContext &Context,
1562  unsigned PathSize);
1563 
1564  SourceLocation getLParenLoc() const { return LParenLoc; }
1565  void setLParenLoc(SourceLocation L) { LParenLoc = L; }
1566  SourceLocation getRParenLoc() const { return RParenLoc; }
1567  void setRParenLoc(SourceLocation L) { RParenLoc = L; }
1568 
1569  /// Determine whether this expression models list-initialization.
1570  bool isListInitialization() const { return LParenLoc.isInvalid(); }
1571 
1572  SourceLocation getLocStart() const LLVM_READONLY { return getBeginLoc(); }
1573  SourceLocation getBeginLoc() const LLVM_READONLY;
1574  SourceLocation getLocEnd() const LLVM_READONLY { return getEndLoc(); }
1575  SourceLocation getEndLoc() const LLVM_READONLY;
1576 
1577  static bool classof(const Stmt *T) {
1578  return T->getStmtClass() == CXXFunctionalCastExprClass;
1579  }
1580 };
1581 
1582 /// Represents a C++ functional cast expression that builds a
1583 /// temporary object.
1584 ///
1585 /// This expression type represents a C++ "functional" cast
1586 /// (C++[expr.type.conv]) with N != 1 arguments that invokes a
1587 /// constructor to build a temporary object. With N == 1 arguments the
1588 /// functional cast expression will be represented by CXXFunctionalCastExpr.
1589 /// Example:
1590 /// \code
1591 /// struct X { X(int, float); }
1592 ///
1593 /// X create_X() {
1594 /// return X(1, 3.14f); // creates a CXXTemporaryObjectExpr
1595 /// };
1596 /// \endcode
1598  TypeSourceInfo *Type = nullptr;
1599 
1600 public:
1601  friend class ASTStmtReader;
1602 
1604  CXXConstructorDecl *Cons,
1605  QualType Type,
1606  TypeSourceInfo *TSI,
1607  ArrayRef<Expr *> Args,
1608  SourceRange ParenOrBraceRange,
1609  bool HadMultipleCandidates,
1610  bool ListInitialization,
1611  bool StdInitListInitialization,
1612  bool ZeroInitialization);
1614  : CXXConstructExpr(CXXTemporaryObjectExprClass, Empty) {}
1615 
1617 
1618  SourceLocation getLocStart() const LLVM_READONLY { return getBeginLoc(); }
1619  SourceLocation getBeginLoc() const LLVM_READONLY;
1620  SourceLocation getLocEnd() const LLVM_READONLY { return getEndLoc(); }
1621  SourceLocation getEndLoc() const LLVM_READONLY;
1622 
1623  static bool classof(const Stmt *T) {
1624  return T->getStmtClass() == CXXTemporaryObjectExprClass;
1625  }
1626 };
1627 
1628 /// A C++ lambda expression, which produces a function object
1629 /// (of unspecified type) that can be invoked later.
1630 ///
1631 /// Example:
1632 /// \code
1633 /// void low_pass_filter(std::vector<double> &values, double cutoff) {
1634 /// values.erase(std::remove_if(values.begin(), values.end(),
1635 /// [=](double value) { return value > cutoff; });
1636 /// }
1637 /// \endcode
1638 ///
1639 /// C++11 lambda expressions can capture local variables, either by copying
1640 /// the values of those local variables at the time the function
1641 /// object is constructed (not when it is called!) or by holding a
1642 /// reference to the local variable. These captures can occur either
1643 /// implicitly or can be written explicitly between the square
1644 /// brackets ([...]) that start the lambda expression.
1645 ///
1646 /// C++1y introduces a new form of "capture" called an init-capture that
1647 /// includes an initializing expression (rather than capturing a variable),
1648 /// and which can never occur implicitly.
1649 class LambdaExpr final : public Expr,
1650  private llvm::TrailingObjects<LambdaExpr, Stmt *> {
1651  /// The source range that covers the lambda introducer ([...]).
1652  SourceRange IntroducerRange;
1653 
1654  /// The source location of this lambda's capture-default ('=' or '&').
1655  SourceLocation CaptureDefaultLoc;
1656 
1657  /// The number of captures.
1658  unsigned NumCaptures : 16;
1659 
1660  /// The default capture kind, which is a value of type
1661  /// LambdaCaptureDefault.
1662  unsigned CaptureDefault : 2;
1663 
1664  /// Whether this lambda had an explicit parameter list vs. an
1665  /// implicit (and empty) parameter list.
1666  unsigned ExplicitParams : 1;
1667 
1668  /// Whether this lambda had the result type explicitly specified.
1669  unsigned ExplicitResultType : 1;
1670 
1671  /// The location of the closing brace ('}') that completes
1672  /// the lambda.
1673  ///
1674  /// The location of the brace is also available by looking up the
1675  /// function call operator in the lambda class. However, it is
1676  /// stored here to improve the performance of getSourceRange(), and
1677  /// to avoid having to deserialize the function call operator from a
1678  /// module file just to determine the source range.
1679  SourceLocation ClosingBrace;
1680 
1681  /// Construct a lambda expression.
1682  LambdaExpr(QualType T, SourceRange IntroducerRange,
1683  LambdaCaptureDefault CaptureDefault,
1684  SourceLocation CaptureDefaultLoc, ArrayRef<LambdaCapture> Captures,
1685  bool ExplicitParams, bool ExplicitResultType,
1686  ArrayRef<Expr *> CaptureInits, SourceLocation ClosingBrace,
1687  bool ContainsUnexpandedParameterPack);
1688 
1689  /// Construct an empty lambda expression.
1690  LambdaExpr(EmptyShell Empty, unsigned NumCaptures)
1691  : Expr(LambdaExprClass, Empty), NumCaptures(NumCaptures),
1692  CaptureDefault(LCD_None), ExplicitParams(false),
1693  ExplicitResultType(false) {
1694  getStoredStmts()[NumCaptures] = nullptr;
1695  }
1696 
1697  Stmt **getStoredStmts() { return getTrailingObjects<Stmt *>(); }
1698 
1699  Stmt *const *getStoredStmts() const { return getTrailingObjects<Stmt *>(); }
1700 
1701 public:
1702  friend class ASTStmtReader;
1703  friend class ASTStmtWriter;
1705 
1706  /// Construct a new lambda expression.
1707  static LambdaExpr *
1708  Create(const ASTContext &C, CXXRecordDecl *Class, SourceRange IntroducerRange,
1709  LambdaCaptureDefault CaptureDefault, SourceLocation CaptureDefaultLoc,
1710  ArrayRef<LambdaCapture> Captures, bool ExplicitParams,
1711  bool ExplicitResultType, ArrayRef<Expr *> CaptureInits,
1712  SourceLocation ClosingBrace, bool ContainsUnexpandedParameterPack);
1713 
1714  /// Construct a new lambda expression that will be deserialized from
1715  /// an external source.
1716  static LambdaExpr *CreateDeserialized(const ASTContext &C,
1717  unsigned NumCaptures);
1718 
1719  /// Determine the default capture kind for this lambda.
1721  return static_cast<LambdaCaptureDefault>(CaptureDefault);
1722  }
1723 
1724  /// Retrieve the location of this lambda's capture-default, if any.
1726  return CaptureDefaultLoc;
1727  }
1728 
1729  /// Determine whether one of this lambda's captures is an init-capture.
1730  bool isInitCapture(const LambdaCapture *Capture) const;
1731 
1732  /// An iterator that walks over the captures of the lambda,
1733  /// both implicit and explicit.
1735 
1736  /// An iterator over a range of lambda captures.
1737  using capture_range = llvm::iterator_range<capture_iterator>;
1738 
1739  /// Retrieve this lambda's captures.
1740  capture_range captures() const;
1741 
1742  /// Retrieve an iterator pointing to the first lambda capture.
1743  capture_iterator capture_begin() const;
1744 
1745  /// Retrieve an iterator pointing past the end of the
1746  /// sequence of lambda captures.
1747  capture_iterator capture_end() const;
1748 
1749  /// Determine the number of captures in this lambda.
1750  unsigned capture_size() const { return NumCaptures; }
1751 
1752  /// Retrieve this lambda's explicit captures.
1753  capture_range explicit_captures() const;
1754 
1755  /// Retrieve an iterator pointing to the first explicit
1756  /// lambda capture.
1757  capture_iterator explicit_capture_begin() const;
1758 
1759  /// Retrieve an iterator pointing past the end of the sequence of
1760  /// explicit lambda captures.
1761  capture_iterator explicit_capture_end() const;
1762 
1763  /// Retrieve this lambda's implicit captures.
1764  capture_range implicit_captures() const;
1765 
1766  /// Retrieve an iterator pointing to the first implicit
1767  /// lambda capture.
1768  capture_iterator implicit_capture_begin() const;
1769 
1770  /// Retrieve an iterator pointing past the end of the sequence of
1771  /// implicit lambda captures.
1772  capture_iterator implicit_capture_end() const;
1773 
1774  /// Iterator that walks over the capture initialization
1775  /// arguments.
1777 
1778  /// Const iterator that walks over the capture initialization
1779  /// arguments.
1781 
1782  /// Retrieve the initialization expressions for this lambda's captures.
1783  llvm::iterator_range<capture_init_iterator> capture_inits() {
1784  return llvm::make_range(capture_init_begin(), capture_init_end());
1785  }
1786 
1787  /// Retrieve the initialization expressions for this lambda's captures.
1788  llvm::iterator_range<const_capture_init_iterator> capture_inits() const {
1789  return llvm::make_range(capture_init_begin(), capture_init_end());
1790  }
1791 
1792  /// Retrieve the first initialization argument for this
1793  /// lambda expression (which initializes the first capture field).
1795  return reinterpret_cast<Expr **>(getStoredStmts());
1796  }
1797 
1798  /// Retrieve the first initialization argument for this
1799  /// lambda expression (which initializes the first capture field).
1801  return reinterpret_cast<Expr *const *>(getStoredStmts());
1802  }
1803 
1804  /// Retrieve the iterator pointing one past the last
1805  /// initialization argument for this lambda expression.
1807  return capture_init_begin() + NumCaptures;
1808  }
1809 
1810  /// Retrieve the iterator pointing one past the last
1811  /// initialization argument for this lambda expression.
1813  return capture_init_begin() + NumCaptures;
1814  }
1815 
1816  /// Retrieve the source range covering the lambda introducer,
1817  /// which contains the explicit capture list surrounded by square
1818  /// brackets ([...]).
1819  SourceRange getIntroducerRange() const { return IntroducerRange; }
1820 
1821  /// Retrieve the class that corresponds to the lambda.
1822  ///
1823  /// This is the "closure type" (C++1y [expr.prim.lambda]), and stores the
1824  /// captures in its fields and provides the various operations permitted
1825  /// on a lambda (copying, calling).
1826  CXXRecordDecl *getLambdaClass() const;
1827 
1828  /// Retrieve the function call operator associated with this
1829  /// lambda expression.
1830  CXXMethodDecl *getCallOperator() const;
1831 
1832  /// If this is a generic lambda expression, retrieve the template
1833  /// parameter list associated with it, or else return null.
1834  TemplateParameterList *getTemplateParameterList() const;
1835 
1836  /// Whether this is a generic lambda.
1837  bool isGenericLambda() const { return getTemplateParameterList(); }
1838 
1839  /// Retrieve the body of the lambda.
1840  CompoundStmt *getBody() const;
1841 
1842  /// Determine whether the lambda is mutable, meaning that any
1843  /// captures values can be modified.
1844  bool isMutable() const;
1845 
1846  /// Determine whether this lambda has an explicit parameter
1847  /// list vs. an implicit (empty) parameter list.
1848  bool hasExplicitParameters() const { return ExplicitParams; }
1849 
1850  /// Whether this lambda had its result type explicitly specified.
1851  bool hasExplicitResultType() const { return ExplicitResultType; }
1852 
1853  static bool classof(const Stmt *T) {
1854  return T->getStmtClass() == LambdaExprClass;
1855  }
1856 
1857  SourceLocation getLocStart() const LLVM_READONLY { return getBeginLoc(); }
1858  SourceLocation getBeginLoc() const LLVM_READONLY {
1859  return IntroducerRange.getBegin();
1860  }
1861 
1862  SourceLocation getLocEnd() const LLVM_READONLY { return getEndLoc(); }
1863  SourceLocation getEndLoc() const LLVM_READONLY { return ClosingBrace; }
1864 
1866  // Includes initialization exprs plus body stmt
1867  return child_range(getStoredStmts(), getStoredStmts() + NumCaptures + 1);
1868  }
1869 };
1870 
1871 /// An expression "T()" which creates a value-initialized rvalue of type
1872 /// T, which is a non-class type. See (C++98 [5.2.3p2]).
1874  friend class ASTStmtReader;
1875 
1876  SourceLocation RParenLoc;
1878 
1879 public:
1880  /// Create an explicitly-written scalar-value initialization
1881  /// expression.
1883  SourceLocation rParenLoc)
1884  : Expr(CXXScalarValueInitExprClass, Type, VK_RValue, OK_Ordinary,
1885  false, false, Type->isInstantiationDependentType(),
1887  RParenLoc(rParenLoc), TypeInfo(TypeInfo) {}
1888 
1890  : Expr(CXXScalarValueInitExprClass, Shell) {}
1891 
1893  return TypeInfo;
1894  }
1895 
1896  SourceLocation getRParenLoc() const { return RParenLoc; }
1897 
1898  SourceLocation getLocStart() const LLVM_READONLY { return getBeginLoc(); }
1899  SourceLocation getBeginLoc() const LLVM_READONLY;
1900  SourceLocation getLocEnd() const LLVM_READONLY { return getEndLoc(); }
1901  SourceLocation getEndLoc() const LLVM_READONLY { return RParenLoc; }
1902 
1903  static bool classof(const Stmt *T) {
1904  return T->getStmtClass() == CXXScalarValueInitExprClass;
1905  }
1906 
1907  // Iterators
1910  }
1911 };
1912 
1913 /// Represents a new-expression for memory allocation and constructor
1914 /// calls, e.g: "new CXXNewExpr(foo)".
1915 class CXXNewExpr : public Expr {
1916  friend class ASTStmtReader;
1917  friend class ASTStmtWriter;
1918 
1919  /// Contains an optional array size expression, an optional initialization
1920  /// expression, and any number of optional placement arguments, in that order.
1921  Stmt **SubExprs = nullptr;
1922 
1923  /// Points to the allocation function used.
1924  FunctionDecl *OperatorNew;
1925 
1926  /// Points to the deallocation function used in case of error. May be
1927  /// null.
1928  FunctionDecl *OperatorDelete;
1929 
1930  /// The allocated type-source information, as written in the source.
1931  TypeSourceInfo *AllocatedTypeInfo;
1932 
1933  /// If the allocated type was expressed as a parenthesized type-id,
1934  /// the source range covering the parenthesized type-id.
1935  SourceRange TypeIdParens;
1936 
1937  /// Range of the entire new expression.
1938  SourceRange Range;
1939 
1940  /// Source-range of a paren-delimited initializer.
1941  SourceRange DirectInitRange;
1942 
1943  /// Was the usage ::new, i.e. is the global new to be used?
1944  unsigned GlobalNew : 1;
1945 
1946  /// Do we allocate an array? If so, the first SubExpr is the size expression.
1947  unsigned Array : 1;
1948 
1949  /// Should the alignment be passed to the allocation function?
1950  unsigned PassAlignment : 1;
1951 
1952  /// If this is an array allocation, does the usual deallocation
1953  /// function for the allocated type want to know the allocated size?
1954  unsigned UsualArrayDeleteWantsSize : 1;
1955 
1956  /// The number of placement new arguments.
1957  unsigned NumPlacementArgs : 26;
1958 
1959  /// What kind of initializer do we have? Could be none, parens, or braces.
1960  /// In storage, we distinguish between "none, and no initializer expr", and
1961  /// "none, but an implicit initializer expr".
1962  unsigned StoredInitializationStyle : 2;
1963 
1964 public:
1966  /// New-expression has no initializer as written.
1968 
1969  /// New-expression has a C++98 paren-delimited initializer.
1971 
1972  /// New-expression has a C++11 list-initializer.
1974  };
1975 
1976  CXXNewExpr(const ASTContext &C, bool globalNew, FunctionDecl *operatorNew,
1977  FunctionDecl *operatorDelete, bool PassAlignment,
1978  bool usualArrayDeleteWantsSize, ArrayRef<Expr*> placementArgs,
1979  SourceRange typeIdParens, Expr *arraySize,
1980  InitializationStyle initializationStyle, Expr *initializer,
1981  QualType ty, TypeSourceInfo *AllocatedTypeInfo,
1982  SourceRange Range, SourceRange directInitRange);
1983  explicit CXXNewExpr(EmptyShell Shell)
1984  : Expr(CXXNewExprClass, Shell) {}
1985 
1986  void AllocateArgsArray(const ASTContext &C, bool isArray,
1987  unsigned numPlaceArgs, bool hasInitializer);
1988 
1990  assert(getType()->isPointerType());
1991  return getType()->getAs<PointerType>()->getPointeeType();
1992  }
1993 
1995  return AllocatedTypeInfo;
1996  }
1997 
1998  /// True if the allocation result needs to be null-checked.
1999  ///
2000  /// C++11 [expr.new]p13:
2001  /// If the allocation function returns null, initialization shall
2002  /// not be done, the deallocation function shall not be called,
2003  /// and the value of the new-expression shall be null.
2004  ///
2005  /// C++ DR1748:
2006  /// If the allocation function is a reserved placement allocation
2007  /// function that returns null, the behavior is undefined.
2008  ///
2009  /// An allocation function is not allowed to return null unless it
2010  /// has a non-throwing exception-specification. The '03 rule is
2011  /// identical except that the definition of a non-throwing
2012  /// exception specification is just "is it throw()?".
2013  bool shouldNullCheckAllocation(const ASTContext &Ctx) const;
2014 
2015  FunctionDecl *getOperatorNew() const { return OperatorNew; }
2016  void setOperatorNew(FunctionDecl *D) { OperatorNew = D; }
2017  FunctionDecl *getOperatorDelete() const { return OperatorDelete; }
2018  void setOperatorDelete(FunctionDecl *D) { OperatorDelete = D; }
2019 
2020  bool isArray() const { return Array; }
2021 
2023  return Array ? cast<Expr>(SubExprs[0]) : nullptr;
2024  }
2025  const Expr *getArraySize() const {
2026  return Array ? cast<Expr>(SubExprs[0]) : nullptr;
2027  }
2028 
2029  unsigned getNumPlacementArgs() const { return NumPlacementArgs; }
2030 
2032  return reinterpret_cast<Expr **>(SubExprs + Array + hasInitializer());
2033  }
2034 
2035  Expr *getPlacementArg(unsigned i) {
2036  assert(i < NumPlacementArgs && "Index out of range");
2037  return getPlacementArgs()[i];
2038  }
2039  const Expr *getPlacementArg(unsigned i) const {
2040  assert(i < NumPlacementArgs && "Index out of range");
2041  return const_cast<CXXNewExpr*>(this)->getPlacementArg(i);
2042  }
2043 
2044  bool isParenTypeId() const { return TypeIdParens.isValid(); }
2045  SourceRange getTypeIdParens() const { return TypeIdParens; }
2046 
2047  bool isGlobalNew() const { return GlobalNew; }
2048 
2049  /// Whether this new-expression has any initializer at all.
2050  bool hasInitializer() const { return StoredInitializationStyle > 0; }
2051 
2052  /// The kind of initializer this new-expression has.
2054  if (StoredInitializationStyle == 0)
2055  return NoInit;
2056  return static_cast<InitializationStyle>(StoredInitializationStyle-1);
2057  }
2058 
2059  /// The initializer of this new-expression.
2061  return hasInitializer() ? cast<Expr>(SubExprs[Array]) : nullptr;
2062  }
2063  const Expr *getInitializer() const {
2064  return hasInitializer() ? cast<Expr>(SubExprs[Array]) : nullptr;
2065  }
2066 
2067  /// Returns the CXXConstructExpr from this new-expression, or null.
2069  return dyn_cast_or_null<CXXConstructExpr>(getInitializer());
2070  }
2071 
2072  /// Indicates whether the required alignment should be implicitly passed to
2073  /// the allocation function.
2074  bool passAlignment() const {
2075  return PassAlignment;
2076  }
2077 
2078  /// Answers whether the usual array deallocation function for the
2079  /// allocated type expects the size of the allocation as a
2080  /// parameter.
2082  return UsualArrayDeleteWantsSize;
2083  }
2084 
2087 
2088  llvm::iterator_range<arg_iterator> placement_arguments() {
2089  return llvm::make_range(placement_arg_begin(), placement_arg_end());
2090  }
2091 
2092  llvm::iterator_range<const_arg_iterator> placement_arguments() const {
2093  return llvm::make_range(placement_arg_begin(), placement_arg_end());
2094  }
2095 
2097  return SubExprs + Array + hasInitializer();
2098  }
2100  return SubExprs + Array + hasInitializer() + getNumPlacementArgs();
2101  }
2103  return SubExprs + Array + hasInitializer();
2104  }
2106  return SubExprs + Array + hasInitializer() + getNumPlacementArgs();
2107  }
2108 
2110 
2111  raw_arg_iterator raw_arg_begin() { return SubExprs; }
2113  return SubExprs + Array + hasInitializer() + getNumPlacementArgs();
2114  }
2115  const_arg_iterator raw_arg_begin() const { return SubExprs; }
2117  return SubExprs + Array + hasInitializer() + getNumPlacementArgs();
2118  }
2119 
2120  SourceLocation getStartLoc() const LLVM_READONLY { return getBeginLoc(); }
2121  SourceLocation getBeginLoc() const { return Range.getBegin(); }
2122  SourceLocation getEndLoc() const { return Range.getEnd(); }
2123 
2124  SourceRange getDirectInitRange() const { return DirectInitRange; }
2125 
2126  SourceRange getSourceRange() const LLVM_READONLY {
2127  return Range;
2128  }
2129 
2130  SourceLocation getLocStart() const LLVM_READONLY { return getBeginLoc(); }
2131  SourceLocation getLocEnd() const LLVM_READONLY { return getEndLoc(); }
2132 
2133  static bool classof(const Stmt *T) {
2134  return T->getStmtClass() == CXXNewExprClass;
2135  }
2136 
2137  // Iterators
2139  return child_range(raw_arg_begin(), raw_arg_end());
2140  }
2141 };
2142 
2143 /// Represents a \c delete expression for memory deallocation and
2144 /// destructor calls, e.g. "delete[] pArray".
2145 class CXXDeleteExpr : public Expr {
2146  /// Points to the operator delete overload that is used. Could be a member.
2147  FunctionDecl *OperatorDelete = nullptr;
2148 
2149  /// The pointer expression to be deleted.
2150  Stmt *Argument = nullptr;
2151 
2152  /// Location of the expression.
2153  SourceLocation Loc;
2154 
2155  /// Is this a forced global delete, i.e. "::delete"?
2156  bool GlobalDelete : 1;
2157 
2158  /// Is this the array form of delete, i.e. "delete[]"?
2159  bool ArrayForm : 1;
2160 
2161  /// ArrayFormAsWritten can be different from ArrayForm if 'delete' is applied
2162  /// to pointer-to-array type (ArrayFormAsWritten will be false while ArrayForm
2163  /// will be true).
2164  bool ArrayFormAsWritten : 1;
2165 
2166  /// Does the usual deallocation function for the element type require
2167  /// a size_t argument?
2168  bool UsualArrayDeleteWantsSize : 1;
2169 
2170 public:
2171  friend class ASTStmtReader;
2172 
2173  CXXDeleteExpr(QualType ty, bool globalDelete, bool arrayForm,
2174  bool arrayFormAsWritten, bool usualArrayDeleteWantsSize,
2175  FunctionDecl *operatorDelete, Expr *arg, SourceLocation loc)
2176  : Expr(CXXDeleteExprClass, ty, VK_RValue, OK_Ordinary, false, false,
2177  arg->isInstantiationDependent(),
2179  OperatorDelete(operatorDelete), Argument(arg), Loc(loc),
2180  GlobalDelete(globalDelete),
2181  ArrayForm(arrayForm), ArrayFormAsWritten(arrayFormAsWritten),
2182  UsualArrayDeleteWantsSize(usualArrayDeleteWantsSize) {}
2183  explicit CXXDeleteExpr(EmptyShell Shell) : Expr(CXXDeleteExprClass, Shell) {}
2184 
2185  bool isGlobalDelete() const { return GlobalDelete; }
2186  bool isArrayForm() const { return ArrayForm; }
2187  bool isArrayFormAsWritten() const { return ArrayFormAsWritten; }
2188 
2189  /// Answers whether the usual array deallocation function for the
2190  /// allocated type expects the size of the allocation as a
2191  /// parameter. This can be true even if the actual deallocation
2192  /// function that we're using doesn't want a size.
2194  return UsualArrayDeleteWantsSize;
2195  }
2196 
2197  FunctionDecl *getOperatorDelete() const { return OperatorDelete; }
2198 
2199  Expr *getArgument() { return cast<Expr>(Argument); }
2200  const Expr *getArgument() const { return cast<Expr>(Argument); }
2201 
2202  /// Retrieve the type being destroyed.
2203  ///
2204  /// If the type being destroyed is a dependent type which may or may not
2205  /// be a pointer, return an invalid type.
2206  QualType getDestroyedType() const;
2207 
2208  SourceLocation getLocStart() const LLVM_READONLY { return getBeginLoc(); }
2209  SourceLocation getBeginLoc() const LLVM_READONLY { return Loc; }
2210  SourceLocation getLocEnd() const LLVM_READONLY { return getEndLoc(); }
2211  SourceLocation getEndLoc() const LLVM_READONLY {
2212  return Argument->getLocEnd();
2213  }
2214 
2215  static bool classof(const Stmt *T) {
2216  return T->getStmtClass() == CXXDeleteExprClass;
2217  }
2218 
2219  // Iterators
2220  child_range children() { return child_range(&Argument, &Argument+1); }
2221 };
2222 
2223 /// Stores the type being destroyed by a pseudo-destructor expression.
2225  /// Either the type source information or the name of the type, if
2226  /// it couldn't be resolved due to type-dependence.
2227  llvm::PointerUnion<TypeSourceInfo *, IdentifierInfo *> Type;
2228 
2229  /// The starting source location of the pseudo-destructor type.
2230  SourceLocation Location;
2231 
2232 public:
2233  PseudoDestructorTypeStorage() = default;
2234 
2236  : Type(II), Location(Loc) {}
2237 
2239 
2241  return Type.dyn_cast<TypeSourceInfo *>();
2242  }
2243 
2245  return Type.dyn_cast<IdentifierInfo *>();
2246  }
2247 
2248  SourceLocation getLocation() const { return Location; }
2249 };
2250 
2251 /// Represents a C++ pseudo-destructor (C++ [expr.pseudo]).
2252 ///
2253 /// A pseudo-destructor is an expression that looks like a member access to a
2254 /// destructor of a scalar type, except that scalar types don't have
2255 /// destructors. For example:
2256 ///
2257 /// \code
2258 /// typedef int T;
2259 /// void f(int *p) {
2260 /// p->T::~T();
2261 /// }
2262 /// \endcode
2263 ///
2264 /// Pseudo-destructors typically occur when instantiating templates such as:
2265 ///
2266 /// \code
2267 /// template<typename T>
2268 /// void destroy(T* ptr) {
2269 /// ptr->T::~T();
2270 /// }
2271 /// \endcode
2272 ///
2273 /// for scalar types. A pseudo-destructor expression has no run-time semantics
2274 /// beyond evaluating the base expression.
2276  friend class ASTStmtReader;
2277 
2278  /// The base expression (that is being destroyed).
2279  Stmt *Base = nullptr;
2280 
2281  /// Whether the operator was an arrow ('->'); otherwise, it was a
2282  /// period ('.').
2283  bool IsArrow : 1;
2284 
2285  /// The location of the '.' or '->' operator.
2286  SourceLocation OperatorLoc;
2287 
2288  /// The nested-name-specifier that follows the operator, if present.
2289  NestedNameSpecifierLoc QualifierLoc;
2290 
2291  /// The type that precedes the '::' in a qualified pseudo-destructor
2292  /// expression.
2293  TypeSourceInfo *ScopeType = nullptr;
2294 
2295  /// The location of the '::' in a qualified pseudo-destructor
2296  /// expression.
2297  SourceLocation ColonColonLoc;
2298 
2299  /// The location of the '~'.
2300  SourceLocation TildeLoc;
2301 
2302  /// The type being destroyed, or its name if we were unable to
2303  /// resolve the name.
2304  PseudoDestructorTypeStorage DestroyedType;
2305 
2306 public:
2307  CXXPseudoDestructorExpr(const ASTContext &Context,
2308  Expr *Base, bool isArrow, SourceLocation OperatorLoc,
2309  NestedNameSpecifierLoc QualifierLoc,
2310  TypeSourceInfo *ScopeType,
2311  SourceLocation ColonColonLoc,
2312  SourceLocation TildeLoc,
2313  PseudoDestructorTypeStorage DestroyedType);
2314 
2316  : Expr(CXXPseudoDestructorExprClass, Shell), IsArrow(false) {}
2317 
2318  Expr *getBase() const { return cast<Expr>(Base); }
2319 
2320  /// Determines whether this member expression actually had
2321  /// a C++ nested-name-specifier prior to the name of the member, e.g.,
2322  /// x->Base::foo.
2323  bool hasQualifier() const { return QualifierLoc.hasQualifier(); }
2324 
2325  /// Retrieves the nested-name-specifier that qualifies the type name,
2326  /// with source-location information.
2327  NestedNameSpecifierLoc getQualifierLoc() const { return QualifierLoc; }
2328 
2329  /// If the member name was qualified, retrieves the
2330  /// nested-name-specifier that precedes the member name. Otherwise, returns
2331  /// null.
2333  return QualifierLoc.getNestedNameSpecifier();
2334  }
2335 
2336  /// Determine whether this pseudo-destructor expression was written
2337  /// using an '->' (otherwise, it used a '.').
2338  bool isArrow() const { return IsArrow; }
2339 
2340  /// Retrieve the location of the '.' or '->' operator.
2341  SourceLocation getOperatorLoc() const { return OperatorLoc; }
2342 
2343  /// Retrieve the scope type in a qualified pseudo-destructor
2344  /// expression.
2345  ///
2346  /// Pseudo-destructor expressions can have extra qualification within them
2347  /// that is not part of the nested-name-specifier, e.g., \c p->T::~T().
2348  /// Here, if the object type of the expression is (or may be) a scalar type,
2349  /// \p T may also be a scalar type and, therefore, cannot be part of a
2350  /// nested-name-specifier. It is stored as the "scope type" of the pseudo-
2351  /// destructor expression.
2352  TypeSourceInfo *getScopeTypeInfo() const { return ScopeType; }
2353 
2354  /// Retrieve the location of the '::' in a qualified pseudo-destructor
2355  /// expression.
2356  SourceLocation getColonColonLoc() const { return ColonColonLoc; }
2357 
2358  /// Retrieve the location of the '~'.
2359  SourceLocation getTildeLoc() const { return TildeLoc; }
2360 
2361  /// Retrieve the source location information for the type
2362  /// being destroyed.
2363  ///
2364  /// This type-source information is available for non-dependent
2365  /// pseudo-destructor expressions and some dependent pseudo-destructor
2366  /// expressions. Returns null if we only have the identifier for a
2367  /// dependent pseudo-destructor expression.
2369  return DestroyedType.getTypeSourceInfo();
2370  }
2371 
2372  /// In a dependent pseudo-destructor expression for which we do not
2373  /// have full type information on the destroyed type, provides the name
2374  /// of the destroyed type.
2376  return DestroyedType.getIdentifier();
2377  }
2378 
2379  /// Retrieve the type being destroyed.
2380  QualType getDestroyedType() const;
2381 
2382  /// Retrieve the starting location of the type being destroyed.
2384  return DestroyedType.getLocation();
2385  }
2386 
2387  /// Set the name of destroyed type for a dependent pseudo-destructor
2388  /// expression.
2390  DestroyedType = PseudoDestructorTypeStorage(II, Loc);
2391  }
2392 
2393  /// Set the destroyed type.
2395  DestroyedType = PseudoDestructorTypeStorage(Info);
2396  }
2397 
2398  SourceLocation getLocStart() const LLVM_READONLY { return getBeginLoc(); }
2399  SourceLocation getBeginLoc() const LLVM_READONLY {
2400  return Base->getLocStart();
2401  }
2402  SourceLocation getLocEnd() const LLVM_READONLY { return getEndLoc(); }
2403  SourceLocation getEndLoc() const LLVM_READONLY;
2404 
2405  static bool classof(const Stmt *T) {
2406  return T->getStmtClass() == CXXPseudoDestructorExprClass;
2407  }
2408 
2409  // Iterators
2410  child_range children() { return child_range(&Base, &Base + 1); }
2411 };
2412 
2413 /// A type trait used in the implementation of various C++11 and
2414 /// Library TR1 trait templates.
2415 ///
2416 /// \code
2417 /// __is_pod(int) == true
2418 /// __is_enum(std::string) == false
2419 /// __is_trivially_constructible(vector<int>, int*, int*)
2420 /// \endcode
2421 class TypeTraitExpr final
2422  : public Expr,
2423  private llvm::TrailingObjects<TypeTraitExpr, TypeSourceInfo *> {
2424  /// The location of the type trait keyword.
2425  SourceLocation Loc;
2426 
2427  /// The location of the closing parenthesis.
2428  SourceLocation RParenLoc;
2429 
2430  // Note: The TypeSourceInfos for the arguments are allocated after the
2431  // TypeTraitExpr.
2432 
2435  SourceLocation RParenLoc,
2436  bool Value);
2437 
2438  TypeTraitExpr(EmptyShell Empty) : Expr(TypeTraitExprClass, Empty) {}
2439 
2440  size_t numTrailingObjects(OverloadToken<TypeSourceInfo *>) const {
2441  return getNumArgs();
2442  }
2443 
2444 public:
2445  friend class ASTStmtReader;
2446  friend class ASTStmtWriter;
2448 
2449  /// Create a new type trait expression.
2450  static TypeTraitExpr *Create(const ASTContext &C, QualType T,
2451  SourceLocation Loc, TypeTrait Kind,
2453  SourceLocation RParenLoc,
2454  bool Value);
2455 
2456  static TypeTraitExpr *CreateDeserialized(const ASTContext &C,
2457  unsigned NumArgs);
2458 
2459  /// Determine which type trait this expression uses.
2461  return static_cast<TypeTrait>(TypeTraitExprBits.Kind);
2462  }
2463 
2464  bool getValue() const {
2465  assert(!isValueDependent());
2466  return TypeTraitExprBits.Value;
2467  }
2468 
2469  /// Determine the number of arguments to this type trait.
2470  unsigned getNumArgs() const { return TypeTraitExprBits.NumArgs; }
2471 
2472  /// Retrieve the Ith argument.
2473  TypeSourceInfo *getArg(unsigned I) const {
2474  assert(I < getNumArgs() && "Argument out-of-range");
2475  return getArgs()[I];
2476  }
2477 
2478  /// Retrieve the argument types.
2480  return llvm::makeArrayRef(getTrailingObjects<TypeSourceInfo *>(),
2481  getNumArgs());
2482  }
2483 
2484  SourceLocation getLocStart() const LLVM_READONLY { return getBeginLoc(); }
2485  SourceLocation getBeginLoc() const LLVM_READONLY { return Loc; }
2486  SourceLocation getLocEnd() const LLVM_READONLY { return getEndLoc(); }
2487  SourceLocation getEndLoc() const LLVM_READONLY { return RParenLoc; }
2488 
2489  static bool classof(const Stmt *T) {
2490  return T->getStmtClass() == TypeTraitExprClass;
2491  }
2492 
2493  // Iterators
2496  }
2497 };
2498 
2499 /// An Embarcadero array type trait, as used in the implementation of
2500 /// __array_rank and __array_extent.
2501 ///
2502 /// Example:
2503 /// \code
2504 /// __array_rank(int[10][20]) == 2
2505 /// __array_extent(int, 1) == 20
2506 /// \endcode
2507 class ArrayTypeTraitExpr : public Expr {
2508  /// The trait. An ArrayTypeTrait enum in MSVC compat unsigned.
2509  unsigned ATT : 2;
2510 
2511  /// The value of the type trait. Unspecified if dependent.
2512  uint64_t Value = 0;
2513 
2514  /// The array dimension being queried, or -1 if not used.
2515  Expr *Dimension;
2516 
2517  /// The location of the type trait keyword.
2518  SourceLocation Loc;
2519 
2520  /// The location of the closing paren.
2521  SourceLocation RParen;
2522 
2523  /// The type being queried.
2524  TypeSourceInfo *QueriedType = nullptr;
2525 
2526  virtual void anchor();
2527 
2528 public:
2529  friend class ASTStmtReader;
2530 
2532  TypeSourceInfo *queried, uint64_t value,
2533  Expr *dimension, SourceLocation rparen, QualType ty)
2534  : Expr(ArrayTypeTraitExprClass, ty, VK_RValue, OK_Ordinary,
2535  false, queried->getType()->isDependentType(),
2536  (queried->getType()->isInstantiationDependentType() ||
2537  (dimension && dimension->isInstantiationDependent())),
2539  ATT(att), Value(value), Dimension(dimension),
2540  Loc(loc), RParen(rparen), QueriedType(queried) {}
2541 
2543  : Expr(ArrayTypeTraitExprClass, Empty), ATT(0) {}
2544 
2545  virtual ~ArrayTypeTraitExpr() = default;
2546 
2547  SourceLocation getLocStart() const LLVM_READONLY { return getBeginLoc(); }
2548  SourceLocation getBeginLoc() const LLVM_READONLY { return Loc; }
2549  SourceLocation getLocEnd() const LLVM_READONLY { return getEndLoc(); }
2550  SourceLocation getEndLoc() const LLVM_READONLY { return RParen; }
2551 
2552  ArrayTypeTrait getTrait() const { return static_cast<ArrayTypeTrait>(ATT); }
2553 
2554  QualType getQueriedType() const { return QueriedType->getType(); }
2555 
2556  TypeSourceInfo *getQueriedTypeSourceInfo() const { return QueriedType; }
2557 
2558  uint64_t getValue() const { assert(!isTypeDependent()); return Value; }
2559 
2560  Expr *getDimensionExpression() const { return Dimension; }
2561 
2562  static bool classof(const Stmt *T) {
2563  return T->getStmtClass() == ArrayTypeTraitExprClass;
2564  }
2565 
2566  // Iterators
2569  }
2570 };
2571 
2572 /// An expression trait intrinsic.
2573 ///
2574 /// Example:
2575 /// \code
2576 /// __is_lvalue_expr(std::cout) == true
2577 /// __is_lvalue_expr(1) == false
2578 /// \endcode
2579 class ExpressionTraitExpr : public Expr {
2580  /// The trait. A ExpressionTrait enum in MSVC compatible unsigned.
2581  unsigned ET : 31;
2582 
2583  /// The value of the type trait. Unspecified if dependent.
2584  unsigned Value : 1;
2585 
2586  /// The location of the type trait keyword.
2587  SourceLocation Loc;
2588 
2589  /// The location of the closing paren.
2590  SourceLocation RParen;
2591 
2592  /// The expression being queried.
2593  Expr* QueriedExpression = nullptr;
2594 
2595 public:
2596  friend class ASTStmtReader;
2597 
2599  Expr *queried, bool value,
2600  SourceLocation rparen, QualType resultType)
2601  : Expr(ExpressionTraitExprClass, resultType, VK_RValue, OK_Ordinary,
2602  false, // Not type-dependent
2603  // Value-dependent if the argument is type-dependent.
2604  queried->isTypeDependent(),
2605  queried->isInstantiationDependent(),
2606  queried->containsUnexpandedParameterPack()),
2607  ET(et), Value(value), Loc(loc), RParen(rparen),
2608  QueriedExpression(queried) {}
2609 
2611  : Expr(ExpressionTraitExprClass, Empty), ET(0), Value(false) {}
2612 
2613  SourceLocation getLocStart() const LLVM_READONLY { return getBeginLoc(); }
2614  SourceLocation getBeginLoc() const LLVM_READONLY { return Loc; }
2615  SourceLocation getLocEnd() const LLVM_READONLY { return getEndLoc(); }
2616  SourceLocation getEndLoc() const LLVM_READONLY { return RParen; }
2617 
2618  ExpressionTrait getTrait() const { return static_cast<ExpressionTrait>(ET); }
2619 
2620  Expr *getQueriedExpression() const { return QueriedExpression; }
2621 
2622  bool getValue() const { return Value; }
2623 
2624  static bool classof(const Stmt *T) {
2625  return T->getStmtClass() == ExpressionTraitExprClass;
2626  }
2627 
2628  // Iterators
2631  }
2632 };
2633 
2634 /// A reference to an overloaded function set, either an
2635 /// \c UnresolvedLookupExpr or an \c UnresolvedMemberExpr.
2636 class OverloadExpr : public Expr {
2637  /// The common name of these declarations.
2638  DeclarationNameInfo NameInfo;
2639 
2640  /// The nested-name-specifier that qualifies the name, if any.
2641  NestedNameSpecifierLoc QualifierLoc;
2642 
2643  /// The results. These are undesugared, which is to say, they may
2644  /// include UsingShadowDecls. Access is relative to the naming
2645  /// class.
2646  // FIXME: Allocate this data after the OverloadExpr subclass.
2647  DeclAccessPair *Results = nullptr;
2648 
2649  unsigned NumResults = 0;
2650 
2651 protected:
2652  /// Whether the name includes info for explicit template
2653  /// keyword and arguments.
2654  bool HasTemplateKWAndArgsInfo = false;
2655 
2656  OverloadExpr(StmtClass K, const ASTContext &C,
2657  NestedNameSpecifierLoc QualifierLoc,
2658  SourceLocation TemplateKWLoc,
2659  const DeclarationNameInfo &NameInfo,
2660  const TemplateArgumentListInfo *TemplateArgs,
2662  bool KnownDependent,
2663  bool KnownInstantiationDependent,
2664  bool KnownContainsUnexpandedParameterPack);
2665 
2666  OverloadExpr(StmtClass K, EmptyShell Empty) : Expr(K, Empty) {}
2667 
2668  /// Return the optional template keyword and arguments info.
2670  getTrailingASTTemplateKWAndArgsInfo(); // defined far below.
2671 
2672  /// Return the optional template keyword and arguments info.
2674  return const_cast<OverloadExpr *>(this)
2675  ->getTrailingASTTemplateKWAndArgsInfo();
2676  }
2677 
2678  /// Return the optional template arguments.
2679  TemplateArgumentLoc *getTrailingTemplateArgumentLoc(); // defined far below
2680 
2681  void initializeResults(const ASTContext &C,
2684 
2685 public:
2686  friend class ASTStmtReader;
2687  friend class ASTStmtWriter;
2688 
2689  struct FindResult {
2693  };
2694 
2695  /// Finds the overloaded expression in the given expression \p E of
2696  /// OverloadTy.
2697  ///
2698  /// \return the expression (which must be there) and true if it has
2699  /// the particular form of a member pointer expression
2700  static FindResult find(Expr *E) {
2701  assert(E->getType()->isSpecificBuiltinType(BuiltinType::Overload));
2702 
2704 
2705  E = E->IgnoreParens();
2706  if (isa<UnaryOperator>(E)) {
2707  assert(cast<UnaryOperator>(E)->getOpcode() == UO_AddrOf);
2708  E = cast<UnaryOperator>(E)->getSubExpr();
2709  auto *Ovl = cast<OverloadExpr>(E->IgnoreParens());
2710 
2711  Result.HasFormOfMemberPointer = (E == Ovl && Ovl->getQualifier());
2712  Result.IsAddressOfOperand = true;
2713  Result.Expression = Ovl;
2714  } else {
2715  Result.HasFormOfMemberPointer = false;
2716  Result.IsAddressOfOperand = false;
2717  Result.Expression = cast<OverloadExpr>(E);
2718  }
2719 
2720  return Result;
2721  }
2722 
2723  /// Gets the naming class of this lookup, if any.
2724  CXXRecordDecl *getNamingClass() const;
2725 
2727 
2728  decls_iterator decls_begin() const { return UnresolvedSetIterator(Results); }
2730  return UnresolvedSetIterator(Results + NumResults);
2731  }
2732  llvm::iterator_range<decls_iterator> decls() const {
2733  return llvm::make_range(decls_begin(), decls_end());
2734  }
2735 
2736  /// Gets the number of declarations in the unresolved set.
2737  unsigned getNumDecls() const { return NumResults; }
2738 
2739  /// Gets the full name info.
2740  const DeclarationNameInfo &getNameInfo() const { return NameInfo; }
2741 
2742  /// Gets the name looked up.
2743  DeclarationName getName() const { return NameInfo.getName(); }
2744 
2745  /// Gets the location of the name.
2746  SourceLocation getNameLoc() const { return NameInfo.getLoc(); }
2747 
2748  /// Fetches the nested-name qualifier, if one was given.
2750  return QualifierLoc.getNestedNameSpecifier();
2751  }
2752 
2753  /// Fetches the nested-name qualifier with source-location
2754  /// information, if one was given.
2755  NestedNameSpecifierLoc getQualifierLoc() const { return QualifierLoc; }
2756 
2757  /// Retrieve the location of the template keyword preceding
2758  /// this name, if any.
2760  if (!HasTemplateKWAndArgsInfo) return SourceLocation();
2761  return getTrailingASTTemplateKWAndArgsInfo()->TemplateKWLoc;
2762  }
2763 
2764  /// Retrieve the location of the left angle bracket starting the
2765  /// explicit template argument list following the name, if any.
2767  if (!HasTemplateKWAndArgsInfo) return SourceLocation();
2768  return getTrailingASTTemplateKWAndArgsInfo()->LAngleLoc;
2769  }
2770 
2771  /// Retrieve the location of the right angle bracket ending the
2772  /// explicit template argument list following the name, if any.
2774  if (!HasTemplateKWAndArgsInfo) return SourceLocation();
2775  return getTrailingASTTemplateKWAndArgsInfo()->RAngleLoc;
2776  }
2777 
2778  /// Determines whether the name was preceded by the template keyword.
2779  bool hasTemplateKeyword() const { return getTemplateKeywordLoc().isValid(); }
2780 
2781  /// Determines whether this expression had explicit template arguments.
2782  bool hasExplicitTemplateArgs() const { return getLAngleLoc().isValid(); }
2783 
2785  if (!hasExplicitTemplateArgs())
2786  return nullptr;
2787  return const_cast<OverloadExpr *>(this)->getTrailingTemplateArgumentLoc();
2788  }
2789 
2790  unsigned getNumTemplateArgs() const {
2791  if (!hasExplicitTemplateArgs())
2792  return 0;
2793 
2794  return getTrailingASTTemplateKWAndArgsInfo()->NumTemplateArgs;
2795  }
2796 
2798  return {getTemplateArgs(), getNumTemplateArgs()};
2799  }
2800 
2801  /// Copies the template arguments into the given structure.
2803  if (hasExplicitTemplateArgs())
2804  getTrailingASTTemplateKWAndArgsInfo()->copyInto(getTemplateArgs(), List);
2805  }
2806 
2807  static bool classof(const Stmt *T) {
2808  return T->getStmtClass() == UnresolvedLookupExprClass ||
2809  T->getStmtClass() == UnresolvedMemberExprClass;
2810  }
2811 };
2812 
2813 /// A reference to a name which we were able to look up during
2814 /// parsing but could not resolve to a specific declaration.
2815 ///
2816 /// This arises in several ways:
2817 /// * we might be waiting for argument-dependent lookup;
2818 /// * the name might resolve to an overloaded function;
2819 /// and eventually:
2820 /// * the lookup might have included a function template.
2821 ///
2822 /// These never include UnresolvedUsingValueDecls, which are always class
2823 /// members and therefore appear only in UnresolvedMemberLookupExprs.
2825  : public OverloadExpr,
2826  private llvm::TrailingObjects<
2827  UnresolvedLookupExpr, ASTTemplateKWAndArgsInfo, TemplateArgumentLoc> {
2828  friend class ASTStmtReader;
2829  friend class OverloadExpr;
2830  friend TrailingObjects;
2831 
2832  /// True if these lookup results should be extended by
2833  /// argument-dependent lookup if this is the operand of a function
2834  /// call.
2835  bool RequiresADL = false;
2836 
2837  /// True if these lookup results are overloaded. This is pretty
2838  /// trivially rederivable if we urgently need to kill this field.
2839  bool Overloaded = false;
2840 
2841  /// The naming class (C++ [class.access.base]p5) of the lookup, if
2842  /// any. This can generally be recalculated from the context chain,
2843  /// but that can be fairly expensive for unqualified lookups. If we
2844  /// want to improve memory use here, this could go in a union
2845  /// against the qualified-lookup bits.
2846  CXXRecordDecl *NamingClass = nullptr;
2847 
2849  CXXRecordDecl *NamingClass,
2850  NestedNameSpecifierLoc QualifierLoc,
2851  SourceLocation TemplateKWLoc,
2852  const DeclarationNameInfo &NameInfo,
2853  bool RequiresADL, bool Overloaded,
2854  const TemplateArgumentListInfo *TemplateArgs,
2856  : OverloadExpr(UnresolvedLookupExprClass, C, QualifierLoc, TemplateKWLoc,
2857  NameInfo, TemplateArgs, Begin, End, false, false, false),
2858  RequiresADL(RequiresADL),
2859  Overloaded(Overloaded), NamingClass(NamingClass) {}
2860 
2862  : OverloadExpr(UnresolvedLookupExprClass, Empty) {}
2863 
2864  size_t numTrailingObjects(OverloadToken<ASTTemplateKWAndArgsInfo>) const {
2865  return HasTemplateKWAndArgsInfo ? 1 : 0;
2866  }
2867 
2868 public:
2870  CXXRecordDecl *NamingClass,
2871  NestedNameSpecifierLoc QualifierLoc,
2872  const DeclarationNameInfo &NameInfo,
2873  bool ADL, bool Overloaded,
2876  return new(C) UnresolvedLookupExpr(C, NamingClass, QualifierLoc,
2877  SourceLocation(), NameInfo,
2878  ADL, Overloaded, nullptr, Begin, End);
2879  }
2880 
2881  static UnresolvedLookupExpr *Create(const ASTContext &C,
2882  CXXRecordDecl *NamingClass,
2883  NestedNameSpecifierLoc QualifierLoc,
2884  SourceLocation TemplateKWLoc,
2885  const DeclarationNameInfo &NameInfo,
2886  bool ADL,
2887  const TemplateArgumentListInfo *Args,
2890 
2891  static UnresolvedLookupExpr *CreateEmpty(const ASTContext &C,
2892  bool HasTemplateKWAndArgsInfo,
2893  unsigned NumTemplateArgs);
2894 
2895  /// True if this declaration should be extended by
2896  /// argument-dependent lookup.
2897  bool requiresADL() const { return RequiresADL; }
2898 
2899  /// True if this lookup is overloaded.
2900  bool isOverloaded() const { return Overloaded; }
2901 
2902  /// Gets the 'naming class' (in the sense of C++0x
2903  /// [class.access.base]p5) of the lookup. This is the scope
2904  /// that was looked in to find these results.
2905  CXXRecordDecl *getNamingClass() const { return NamingClass; }
2906 
2907  SourceLocation getLocStart() const LLVM_READONLY { return getBeginLoc(); }
2908  SourceLocation getBeginLoc() const LLVM_READONLY {
2909  if (NestedNameSpecifierLoc l = getQualifierLoc())
2910  return l.getBeginLoc();
2911  return getNameInfo().getLocStart();
2912  }
2913 
2914  SourceLocation getLocEnd() const LLVM_READONLY { return getEndLoc(); }
2915  SourceLocation getEndLoc() const LLVM_READONLY {
2916  if (hasExplicitTemplateArgs())
2917  return getRAngleLoc();
2918  return getNameInfo().getLocEnd();
2919  }
2920 
2923  }
2924 
2925  static bool classof(const Stmt *T) {
2926  return T->getStmtClass() == UnresolvedLookupExprClass;
2927  }
2928 };
2929 
2930 /// A qualified reference to a name whose declaration cannot
2931 /// yet be resolved.
2932 ///
2933 /// DependentScopeDeclRefExpr is similar to DeclRefExpr in that
2934 /// it expresses a reference to a declaration such as
2935 /// X<T>::value. The difference, however, is that an
2936 /// DependentScopeDeclRefExpr node is used only within C++ templates when
2937 /// the qualification (e.g., X<T>::) refers to a dependent type. In
2938 /// this case, X<T>::value cannot resolve to a declaration because the
2939 /// declaration will differ from one instantiation of X<T> to the
2940 /// next. Therefore, DependentScopeDeclRefExpr keeps track of the
2941 /// qualifier (X<T>::) and the name of the entity being referenced
2942 /// ("value"). Such expressions will instantiate to a DeclRefExpr once the
2943 /// declaration can be found.
2945  : public Expr,
2946  private llvm::TrailingObjects<DependentScopeDeclRefExpr,
2947  ASTTemplateKWAndArgsInfo,
2948  TemplateArgumentLoc> {
2949  /// The nested-name-specifier that qualifies this unresolved
2950  /// declaration name.
2951  NestedNameSpecifierLoc QualifierLoc;
2952 
2953  /// The name of the entity we will be referencing.
2954  DeclarationNameInfo NameInfo;
2955 
2956  /// Whether the name includes info for explicit template
2957  /// keyword and arguments.
2958  bool HasTemplateKWAndArgsInfo;
2959 
2961  NestedNameSpecifierLoc QualifierLoc,
2962  SourceLocation TemplateKWLoc,
2963  const DeclarationNameInfo &NameInfo,
2964  const TemplateArgumentListInfo *Args);
2965 
2966  size_t numTrailingObjects(OverloadToken<ASTTemplateKWAndArgsInfo>) const {
2967  return HasTemplateKWAndArgsInfo ? 1 : 0;
2968  }
2969 
2970 public:
2971  friend class ASTStmtReader;
2972  friend class ASTStmtWriter;
2974 
2976  NestedNameSpecifierLoc QualifierLoc,
2977  SourceLocation TemplateKWLoc,
2978  const DeclarationNameInfo &NameInfo,
2979  const TemplateArgumentListInfo *TemplateArgs);
2980 
2982  bool HasTemplateKWAndArgsInfo,
2983  unsigned NumTemplateArgs);
2984 
2985  /// Retrieve the name that this expression refers to.
2986  const DeclarationNameInfo &getNameInfo() const { return NameInfo; }
2987 
2988  /// Retrieve the name that this expression refers to.
2989  DeclarationName getDeclName() const { return NameInfo.getName(); }
2990 
2991  /// Retrieve the location of the name within the expression.
2992  ///
2993  /// For example, in "X<T>::value" this is the location of "value".
2994  SourceLocation getLocation() const { return NameInfo.getLoc(); }
2995 
2996  /// Retrieve the nested-name-specifier that qualifies the
2997  /// name, with source location information.
2998  NestedNameSpecifierLoc getQualifierLoc() const { return QualifierLoc; }
2999 
3000  /// Retrieve the nested-name-specifier that qualifies this
3001  /// declaration.
3003  return QualifierLoc.getNestedNameSpecifier();
3004  }
3005 
3006  /// Retrieve the location of the template keyword preceding
3007  /// this name, if any.
3009  if (!HasTemplateKWAndArgsInfo) return SourceLocation();
3010  return getTrailingObjects<ASTTemplateKWAndArgsInfo>()->TemplateKWLoc;
3011  }
3012 
3013  /// Retrieve the location of the left angle bracket starting the
3014  /// explicit template argument list following the name, if any.
3016  if (!HasTemplateKWAndArgsInfo) return SourceLocation();
3017  return getTrailingObjects<ASTTemplateKWAndArgsInfo>()->LAngleLoc;
3018  }
3019 
3020  /// Retrieve the location of the right angle bracket ending the
3021  /// explicit template argument list following the name, if any.
3023  if (!HasTemplateKWAndArgsInfo) return SourceLocation();
3024  return getTrailingObjects<ASTTemplateKWAndArgsInfo>()->RAngleLoc;
3025  }
3026 
3027  /// Determines whether the name was preceded by the template keyword.
3028  bool hasTemplateKeyword() const { return getTemplateKeywordLoc().isValid(); }
3029 
3030  /// Determines whether this lookup had explicit template arguments.
3031  bool hasExplicitTemplateArgs() const { return getLAngleLoc().isValid(); }
3032 
3033  /// Copies the template arguments (if present) into the given
3034  /// structure.
3036  if (hasExplicitTemplateArgs())
3037  getTrailingObjects<ASTTemplateKWAndArgsInfo>()->copyInto(
3038  getTrailingObjects<TemplateArgumentLoc>(), List);
3039  }
3040 
3042  if (!hasExplicitTemplateArgs())
3043  return nullptr;
3044 
3045  return getTrailingObjects<TemplateArgumentLoc>();
3046  }
3047 
3048  unsigned getNumTemplateArgs() const {
3049  if (!hasExplicitTemplateArgs())
3050  return 0;
3051 
3052  return getTrailingObjects<ASTTemplateKWAndArgsInfo>()->NumTemplateArgs;
3053  }
3054 
3056  return {getTemplateArgs(), getNumTemplateArgs()};
3057  }
3058 
3059  /// Note: getLocStart() is the start of the whole DependentScopeDeclRefExpr,
3060  /// and differs from getLocation().getStart().
3061  SourceLocation getLocStart() const LLVM_READONLY { return getBeginLoc(); }
3062  SourceLocation getBeginLoc() const LLVM_READONLY {
3063  return QualifierLoc.getBeginLoc();
3064  }
3065 
3066  SourceLocation getLocEnd() const LLVM_READONLY { return getEndLoc(); }
3067  SourceLocation getEndLoc() const LLVM_READONLY {
3068  if (hasExplicitTemplateArgs())
3069  return getRAngleLoc();
3070  return getLocation();
3071  }
3072 
3073  static bool classof(const Stmt *T) {
3074  return T->getStmtClass() == DependentScopeDeclRefExprClass;
3075  }
3076 
3079  }
3080 };
3081 
3082 /// Represents an expression -- generally a full-expression -- that
3083 /// introduces cleanups to be run at the end of the sub-expression's
3084 /// evaluation. The most common source of expression-introduced
3085 /// cleanups is temporary objects in C++, but several other kinds of
3086 /// expressions can create cleanups, including basically every
3087 /// call in ARC that returns an Objective-C pointer.
3088 ///
3089 /// This expression also tracks whether the sub-expression contains a
3090 /// potentially-evaluated block literal. The lifetime of a block
3091 /// literal is the extent of the enclosing scope.
3092 class ExprWithCleanups final
3093  : public Expr,
3094  private llvm::TrailingObjects<ExprWithCleanups, BlockDecl *> {
3095 public:
3096  /// The type of objects that are kept in the cleanup.
3097  /// It's useful to remember the set of blocks; we could also
3098  /// remember the set of temporaries, but there's currently
3099  /// no need.
3101 
3102 private:
3103  friend class ASTStmtReader;
3104  friend TrailingObjects;
3105 
3106  Stmt *SubExpr;
3107 
3108  ExprWithCleanups(EmptyShell, unsigned NumObjects);
3109  ExprWithCleanups(Expr *SubExpr, bool CleanupsHaveSideEffects,
3110  ArrayRef<CleanupObject> Objects);
3111 
3112 public:
3113  static ExprWithCleanups *Create(const ASTContext &C, EmptyShell empty,
3114  unsigned numObjects);
3115 
3116  static ExprWithCleanups *Create(const ASTContext &C, Expr *subexpr,
3117  bool CleanupsHaveSideEffects,
3118  ArrayRef<CleanupObject> objects);
3119 
3121  return llvm::makeArrayRef(getTrailingObjects<CleanupObject>(),
3122  getNumObjects());
3123  }
3124 
3125  unsigned getNumObjects() const { return ExprWithCleanupsBits.NumObjects; }
3126 
3127  CleanupObject getObject(unsigned i) const {
3128  assert(i < getNumObjects() && "Index out of range");
3129  return getObjects()[i];
3130  }
3131 
3132  Expr *getSubExpr() { return cast<Expr>(SubExpr); }
3133  const Expr *getSubExpr() const { return cast<Expr>(SubExpr); }
3134 
3136  return ExprWithCleanupsBits.CleanupsHaveSideEffects;
3137  }
3138 
3139  /// As with any mutator of the AST, be very careful
3140  /// when modifying an existing AST to preserve its invariants.
3141  void setSubExpr(Expr *E) { SubExpr = E; }
3142 
3143  SourceLocation getLocStart() const LLVM_READONLY { return getBeginLoc(); }
3144  SourceLocation getBeginLoc() const LLVM_READONLY {
3145  return SubExpr->getLocStart();
3146  }
3147 
3148  SourceLocation getLocEnd() const LLVM_READONLY { return getEndLoc(); }
3149  SourceLocation getEndLoc() const LLVM_READONLY {
3150  return SubExpr->getLocEnd();
3151  }
3152 
3153  // Implement isa/cast/dyncast/etc.
3154  static bool classof(const Stmt *T) {
3155  return T->getStmtClass() == ExprWithCleanupsClass;
3156  }
3157 
3158  // Iterators
3159  child_range children() { return child_range(&SubExpr, &SubExpr + 1); }
3160 };
3161 
3162 /// Describes an explicit type conversion that uses functional
3163 /// notion but could not be resolved because one or more arguments are
3164 /// type-dependent.
3165 ///
3166 /// The explicit type conversions expressed by
3167 /// CXXUnresolvedConstructExpr have the form <tt>T(a1, a2, ..., aN)</tt>,
3168 /// where \c T is some type and \c a1, \c a2, ..., \c aN are values, and
3169 /// either \c T is a dependent type or one or more of the <tt>a</tt>'s is
3170 /// type-dependent. For example, this would occur in a template such
3171 /// as:
3172 ///
3173 /// \code
3174 /// template<typename T, typename A1>
3175 /// inline T make_a(const A1& a1) {
3176 /// return T(a1);
3177 /// }
3178 /// \endcode
3179 ///
3180 /// When the returned expression is instantiated, it may resolve to a
3181 /// constructor call, conversion function call, or some kind of type
3182 /// conversion.
3184  : public Expr,
3185  private llvm::TrailingObjects<CXXUnresolvedConstructExpr, Expr *> {
3186  friend class ASTStmtReader;
3187  friend TrailingObjects;
3188 
3189  /// The type being constructed.
3190  TypeSourceInfo *Type = nullptr;
3191 
3192  /// The location of the left parentheses ('(').
3193  SourceLocation LParenLoc;
3194 
3195  /// The location of the right parentheses (')').
3196  SourceLocation RParenLoc;
3197 
3198  /// The number of arguments used to construct the type.
3199  unsigned NumArgs;
3200 
3202  SourceLocation LParenLoc,
3203  ArrayRef<Expr*> Args,
3204  SourceLocation RParenLoc);
3205 
3206  CXXUnresolvedConstructExpr(EmptyShell Empty, unsigned NumArgs)
3207  : Expr(CXXUnresolvedConstructExprClass, Empty), NumArgs(NumArgs) {}
3208 
3209 public:
3211  TypeSourceInfo *Type,
3212  SourceLocation LParenLoc,
3213  ArrayRef<Expr*> Args,
3214  SourceLocation RParenLoc);
3215 
3217  unsigned NumArgs);
3218 
3219  /// Retrieve the type that is being constructed, as specified
3220  /// in the source code.
3221  QualType getTypeAsWritten() const { return Type->getType(); }
3222 
3223  /// Retrieve the type source information for the type being
3224  /// constructed.
3226 
3227  /// Retrieve the location of the left parentheses ('(') that
3228  /// precedes the argument list.
3229  SourceLocation getLParenLoc() const { return LParenLoc; }
3230  void setLParenLoc(SourceLocation L) { LParenLoc = L; }
3231 
3232  /// Retrieve the location of the right parentheses (')') that
3233  /// follows the argument list.
3234  SourceLocation getRParenLoc() const { return RParenLoc; }
3235  void setRParenLoc(SourceLocation L) { RParenLoc = L; }
3236 
3237  /// Determine whether this expression models list-initialization.
3238  /// If so, there will be exactly one subexpression, which will be
3239  /// an InitListExpr.
3240  bool isListInitialization() const { return LParenLoc.isInvalid(); }
3241 
3242  /// Retrieve the number of arguments.
3243  unsigned arg_size() const { return NumArgs; }
3244 
3245  using arg_iterator = Expr **;
3246 
3247  arg_iterator arg_begin() { return getTrailingObjects<Expr *>(); }
3248  arg_iterator arg_end() { return arg_begin() + NumArgs; }
3249 
3250  using const_arg_iterator = const Expr* const *;
3251 
3252  const_arg_iterator arg_begin() const { return getTrailingObjects<Expr *>(); }
3254  return arg_begin() + NumArgs;
3255  }
3256 
3257  Expr *getArg(unsigned I) {
3258  assert(I < NumArgs && "Argument index out-of-range");
3259  return *(arg_begin() + I);
3260  }
3261 
3262  const Expr *getArg(unsigned I) const {
3263  assert(I < NumArgs && "Argument index out-of-range");
3264  return *(arg_begin() + I);
3265  }
3266 
3267  void setArg(unsigned I, Expr *E) {
3268  assert(I < NumArgs && "Argument index out-of-range");
3269  *(arg_begin() + I) = E;
3270  }
3271 
3272  SourceLocation getLocStart() const LLVM_READONLY { return getBeginLoc(); }
3273  SourceLocation getBeginLoc() const LLVM_READONLY;
3274 
3275  SourceLocation getLocEnd() const LLVM_READONLY { return getEndLoc(); }
3276  SourceLocation getEndLoc() const LLVM_READONLY {
3277  if (!RParenLoc.isValid() && NumArgs > 0)
3278  return getArg(NumArgs - 1)->getLocEnd();
3279  return RParenLoc;
3280  }
3281 
3282  static bool classof(const Stmt *T) {
3283  return T->getStmtClass() == CXXUnresolvedConstructExprClass;
3284  }
3285 
3286  // Iterators
3288  auto **begin = reinterpret_cast<Stmt **>(arg_begin());
3289  return child_range(begin, begin + NumArgs);
3290  }
3291 };
3292 
3293 /// Represents a C++ member access expression where the actual
3294 /// member referenced could not be resolved because the base
3295 /// expression or the member name was dependent.
3296 ///
3297 /// Like UnresolvedMemberExprs, these can be either implicit or
3298 /// explicit accesses. It is only possible to get one of these with
3299 /// an implicit access if a qualifier is provided.
3301  : public Expr,
3302  private llvm::TrailingObjects<CXXDependentScopeMemberExpr,
3303  ASTTemplateKWAndArgsInfo,
3304  TemplateArgumentLoc> {
3305  /// The expression for the base pointer or class reference,
3306  /// e.g., the \c x in x.f. Can be null in implicit accesses.
3307  Stmt *Base;
3308 
3309  /// The type of the base expression. Never null, even for
3310  /// implicit accesses.
3311  QualType BaseType;
3312 
3313  /// Whether this member expression used the '->' operator or
3314  /// the '.' operator.
3315  bool IsArrow : 1;
3316 
3317  /// Whether this member expression has info for explicit template
3318  /// keyword and arguments.
3319  bool HasTemplateKWAndArgsInfo : 1;
3320 
3321  /// The location of the '->' or '.' operator.
3322  SourceLocation OperatorLoc;
3323 
3324  /// The nested-name-specifier that precedes the member name, if any.
3325  NestedNameSpecifierLoc QualifierLoc;
3326 
3327  /// In a qualified member access expression such as t->Base::f, this
3328  /// member stores the resolves of name lookup in the context of the member
3329  /// access expression, to be used at instantiation time.
3330  ///
3331  /// FIXME: This member, along with the QualifierLoc, could
3332  /// be stuck into a structure that is optionally allocated at the end of
3333  /// the CXXDependentScopeMemberExpr, to save space in the common case.
3334  NamedDecl *FirstQualifierFoundInScope;
3335 
3336  /// The member to which this member expression refers, which
3337  /// can be name, overloaded operator, or destructor.
3338  ///
3339  /// FIXME: could also be a template-id
3340  DeclarationNameInfo MemberNameInfo;
3341 
3342  size_t numTrailingObjects(OverloadToken<ASTTemplateKWAndArgsInfo>) const {
3343  return HasTemplateKWAndArgsInfo ? 1 : 0;
3344  }
3345 
3347  QualType BaseType, bool IsArrow,
3348  SourceLocation OperatorLoc,
3349  NestedNameSpecifierLoc QualifierLoc,
3350  SourceLocation TemplateKWLoc,
3351  NamedDecl *FirstQualifierFoundInScope,
3352  DeclarationNameInfo MemberNameInfo,
3353  const TemplateArgumentListInfo *TemplateArgs);
3354 
3355 public:
3356  friend class ASTStmtReader;
3357  friend class ASTStmtWriter;
3359 
3361  QualType BaseType, bool IsArrow,
3362  SourceLocation OperatorLoc,
3363  NestedNameSpecifierLoc QualifierLoc,
3364  NamedDecl *FirstQualifierFoundInScope,
3365  DeclarationNameInfo MemberNameInfo);
3366 
3368  Create(const ASTContext &C, Expr *Base, QualType BaseType, bool IsArrow,
3369  SourceLocation OperatorLoc, NestedNameSpecifierLoc QualifierLoc,
3370  SourceLocation TemplateKWLoc, NamedDecl *FirstQualifierFoundInScope,
3371  DeclarationNameInfo MemberNameInfo,
3372  const TemplateArgumentListInfo *TemplateArgs);
3373 
3375  CreateEmpty(const ASTContext &C, bool HasTemplateKWAndArgsInfo,
3376  unsigned NumTemplateArgs);
3377 
3378  /// True if this is an implicit access, i.e. one in which the
3379  /// member being accessed was not written in the source. The source
3380  /// location of the operator is invalid in this case.
3381  bool isImplicitAccess() const;
3382 
3383  /// Retrieve the base object of this member expressions,
3384  /// e.g., the \c x in \c x.m.
3385  Expr *getBase() const {
3386  assert(!isImplicitAccess());
3387  return cast<Expr>(Base);
3388  }
3389 
3390  QualType getBaseType() const { return BaseType; }
3391 
3392  /// Determine whether this member expression used the '->'
3393  /// operator; otherwise, it used the '.' operator.
3394  bool isArrow() const { return IsArrow; }
3395 
3396  /// Retrieve the location of the '->' or '.' operator.
3397  SourceLocation getOperatorLoc() const { return OperatorLoc; }
3398 
3399  /// Retrieve the nested-name-specifier that qualifies the member
3400  /// name.
3402  return QualifierLoc.getNestedNameSpecifier();
3403  }
3404 
3405  /// Retrieve the nested-name-specifier that qualifies the member
3406  /// name, with source location information.
3407  NestedNameSpecifierLoc getQualifierLoc() const { return QualifierLoc; }
3408 
3409  /// Retrieve the first part of the nested-name-specifier that was
3410  /// found in the scope of the member access expression when the member access
3411  /// was initially parsed.
3412  ///
3413  /// This function only returns a useful result when member access expression
3414  /// uses a qualified member name, e.g., "x.Base::f". Here, the declaration
3415  /// returned by this function describes what was found by unqualified name
3416  /// lookup for the identifier "Base" within the scope of the member access
3417  /// expression itself. At template instantiation time, this information is
3418  /// combined with the results of name lookup into the type of the object
3419  /// expression itself (the class type of x).
3421  return FirstQualifierFoundInScope;
3422  }
3423 
3424  /// Retrieve the name of the member that this expression
3425  /// refers to.
3427  return MemberNameInfo;
3428  }
3429 
3430  /// Retrieve the name of the member that this expression
3431  /// refers to.
3432  DeclarationName getMember() const { return MemberNameInfo.getName(); }
3433 
3434  // Retrieve the location of the name of the member that this
3435  // expression refers to.
3436  SourceLocation getMemberLoc() const { return MemberNameInfo.getLoc(); }
3437 
3438  /// Retrieve the location of the template keyword preceding the
3439  /// member name, if any.
3441  if (!HasTemplateKWAndArgsInfo) return SourceLocation();
3442  return getTrailingObjects<ASTTemplateKWAndArgsInfo>()->TemplateKWLoc;
3443  }
3444 
3445  /// Retrieve the location of the left angle bracket starting the
3446  /// explicit template argument list following the member name, if any.
3448  if (!HasTemplateKWAndArgsInfo) return SourceLocation();
3449  return getTrailingObjects<ASTTemplateKWAndArgsInfo>()->LAngleLoc;
3450  }
3451 
3452  /// Retrieve the location of the right angle bracket ending the
3453  /// explicit template argument list following the member name, if any.
3455  if (!HasTemplateKWAndArgsInfo) return SourceLocation();
3456  return getTrailingObjects<ASTTemplateKWAndArgsInfo>()->RAngleLoc;
3457  }
3458 
3459  /// Determines whether the member name was preceded by the template keyword.
3460  bool hasTemplateKeyword() const { return getTemplateKeywordLoc().isValid(); }
3461 
3462  /// Determines whether this member expression actually had a C++
3463  /// template argument list explicitly specified, e.g., x.f<int>.
3464  bool hasExplicitTemplateArgs() const { return getLAngleLoc().isValid(); }
3465 
3466  /// Copies the template arguments (if present) into the given
3467  /// structure.
3469  if (hasExplicitTemplateArgs())
3470  getTrailingObjects<ASTTemplateKWAndArgsInfo>()->copyInto(
3471  getTrailingObjects<TemplateArgumentLoc>(), List);
3472  }
3473 
3474  /// Retrieve the template arguments provided as part of this
3475  /// template-id.
3477  if (!hasExplicitTemplateArgs())
3478  return nullptr;
3479 
3480  return getTrailingObjects<TemplateArgumentLoc>();
3481  }
3482 
3483  /// Retrieve the number of template arguments provided as part of this
3484  /// template-id.
3485  unsigned getNumTemplateArgs() const {
3486  if (!hasExplicitTemplateArgs())
3487  return 0;
3488 
3489  return getTrailingObjects<ASTTemplateKWAndArgsInfo>()->NumTemplateArgs;
3490  }
3491 
3493  return {getTemplateArgs(), getNumTemplateArgs()};
3494  }
3495 
3496  SourceLocation getLocStart() const LLVM_READONLY { return getBeginLoc(); }
3497  SourceLocation getBeginLoc() const LLVM_READONLY {
3498  if (!isImplicitAccess())
3499  return Base->getLocStart();
3500  if (getQualifier())
3501  return getQualifierLoc().getBeginLoc();
3502  return MemberNameInfo.getBeginLoc();
3503  }
3504 
3505  SourceLocation getLocEnd() const LLVM_READONLY { return getEndLoc(); }
3506  SourceLocation getEndLoc() const LLVM_READONLY {
3507  if (hasExplicitTemplateArgs())
3508  return getRAngleLoc();
3509  return MemberNameInfo.getEndLoc();
3510  }
3511 
3512  static bool classof(const Stmt *T) {
3513  return T->getStmtClass() == CXXDependentScopeMemberExprClass;
3514  }
3515 
3516  // Iterators
3518  if (isImplicitAccess())
3520  return child_range(&Base, &Base + 1);
3521  }
3522 };
3523 
3524 /// Represents a C++ member access expression for which lookup
3525 /// produced a set of overloaded functions.
3526 ///
3527 /// The member access may be explicit or implicit:
3528 /// \code
3529 /// struct A {
3530 /// int a, b;
3531 /// int explicitAccess() { return this->a + this->A::b; }
3532 /// int implicitAccess() { return a + A::b; }
3533 /// };
3534 /// \endcode
3535 ///
3536 /// In the final AST, an explicit access always becomes a MemberExpr.
3537 /// An implicit access may become either a MemberExpr or a
3538 /// DeclRefExpr, depending on whether the member is static.
3540  : public OverloadExpr,
3541  private llvm::TrailingObjects<
3542  UnresolvedMemberExpr, ASTTemplateKWAndArgsInfo, TemplateArgumentLoc> {
3543  friend class ASTStmtReader;
3544  friend class OverloadExpr;
3545  friend TrailingObjects;
3546 
3547  /// Whether this member expression used the '->' operator or
3548  /// the '.' operator.
3549  bool IsArrow : 1;
3550 
3551  /// Whether the lookup results contain an unresolved using
3552  /// declaration.
3553  bool HasUnresolvedUsing : 1;
3554 
3555  /// The expression for the base pointer or class reference,
3556  /// e.g., the \c x in x.f.
3557  ///
3558  /// This can be null if this is an 'unbased' member expression.
3559  Stmt *Base = nullptr;
3560 
3561  /// The type of the base expression; never null.
3562  QualType BaseType;
3563 
3564  /// The location of the '->' or '.' operator.
3565  SourceLocation OperatorLoc;
3566 
3567  UnresolvedMemberExpr(const ASTContext &C, bool HasUnresolvedUsing,
3568  Expr *Base, QualType BaseType, bool IsArrow,
3569  SourceLocation OperatorLoc,
3570  NestedNameSpecifierLoc QualifierLoc,
3571  SourceLocation TemplateKWLoc,
3572  const DeclarationNameInfo &MemberNameInfo,
3573  const TemplateArgumentListInfo *TemplateArgs,
3575 
3577  : OverloadExpr(UnresolvedMemberExprClass, Empty), IsArrow(false),
3578  HasUnresolvedUsing(false) {}
3579 
3580  size_t numTrailingObjects(OverloadToken<ASTTemplateKWAndArgsInfo>) const {
3581  return HasTemplateKWAndArgsInfo ? 1 : 0;
3582  }
3583 
3584 public:
3585  static UnresolvedMemberExpr *
3586  Create(const ASTContext &C, bool HasUnresolvedUsing,
3587  Expr *Base, QualType BaseType, bool IsArrow,
3588  SourceLocation OperatorLoc,
3589  NestedNameSpecifierLoc QualifierLoc,
3590  SourceLocation TemplateKWLoc,
3591  const DeclarationNameInfo &MemberNameInfo,
3592  const TemplateArgumentListInfo *TemplateArgs,
3594 
3595  static UnresolvedMemberExpr *
3596  CreateEmpty(const ASTContext &C, bool HasTemplateKWAndArgsInfo,
3597  unsigned NumTemplateArgs);
3598 
3599  /// True if this is an implicit access, i.e., one in which the
3600  /// member being accessed was not written in the source.
3601  ///
3602  /// The source location of the operator is invalid in this case.
3603  bool isImplicitAccess() const;
3604 
3605  /// Retrieve the base object of this member expressions,
3606  /// e.g., the \c x in \c x.m.
3608  assert(!isImplicitAccess());
3609  return cast<Expr>(Base);
3610  }
3611  const Expr *getBase() const {
3612  assert(!isImplicitAccess());
3613  return cast<Expr>(Base);
3614  }
3615 
3616  QualType getBaseType() const { return BaseType; }
3617 
3618  /// Determine whether the lookup results contain an unresolved using
3619  /// declaration.
3620  bool hasUnresolvedUsing() const { return HasUnresolvedUsing; }
3621 
3622  /// Determine whether this member expression used the '->'
3623  /// operator; otherwise, it used the '.' operator.
3624  bool isArrow() const { return IsArrow; }
3625 
3626  /// Retrieve the location of the '->' or '.' operator.
3627  SourceLocation getOperatorLoc() const { return OperatorLoc; }
3628 
3629  /// Retrieve the naming class of this lookup.
3630  CXXRecordDecl *getNamingClass() const;
3631 
3632  /// Retrieve the full name info for the member that this expression
3633  /// refers to.
3634  const DeclarationNameInfo &getMemberNameInfo() const { return getNameInfo(); }
3635 
3636  /// Retrieve the name of the member that this expression
3637  /// refers to.
3638  DeclarationName getMemberName() const { return getName(); }
3639 
3640  // Retrieve the location of the name of the member that this
3641  // expression refers to.
3642  SourceLocation getMemberLoc() const { return getNameLoc(); }
3643 
3644  // Return the preferred location (the member name) for the arrow when
3645  // diagnosing a problem with this expression.
3646  SourceLocation getExprLoc() const LLVM_READONLY { return getMemberLoc(); }
3647 
3648  SourceLocation getLocStart() const LLVM_READONLY { return getBeginLoc(); }
3649  SourceLocation getBeginLoc() const LLVM_READONLY {
3650  if (!isImplicitAccess())
3651  return Base->getLocStart();
3652  if (NestedNameSpecifierLoc l = getQualifierLoc())
3653  return l.getBeginLoc();
3654  return getMemberNameInfo().getLocStart();
3655  }
3656 
3657  SourceLocation getLocEnd() const LLVM_READONLY { return getEndLoc(); }
3658  SourceLocation getEndLoc() const LLVM_READONLY {
3659  if (hasExplicitTemplateArgs())
3660  return getRAngleLoc();
3661  return getMemberNameInfo().getLocEnd();
3662  }
3663 
3664  static bool classof(const Stmt *T) {
3665  return T->getStmtClass() == UnresolvedMemberExprClass;
3666  }
3667 
3668  // Iterators
3670  if (isImplicitAccess())
3672  return child_range(&Base, &Base + 1);
3673  }
3674 };
3675 
3676 inline ASTTemplateKWAndArgsInfo *
3678  if (!HasTemplateKWAndArgsInfo)
3679  return nullptr;
3680 
3681  if (isa<UnresolvedLookupExpr>(this))
3682  return cast<UnresolvedLookupExpr>(this)
3683  ->getTrailingObjects<ASTTemplateKWAndArgsInfo>();
3684  else
3685  return cast<UnresolvedMemberExpr>(this)
3686  ->getTrailingObjects<ASTTemplateKWAndArgsInfo>();
3687 }
3688 
3690  if (isa<UnresolvedLookupExpr>(this))
3691  return cast<UnresolvedLookupExpr>(this)
3692  ->getTrailingObjects<TemplateArgumentLoc>();
3693  else
3694  return cast<UnresolvedMemberExpr>(this)
3695  ->getTrailingObjects<TemplateArgumentLoc>();
3696 }
3697 
3698 /// Represents a C++11 noexcept expression (C++ [expr.unary.noexcept]).
3699 ///
3700 /// The noexcept expression tests whether a given expression might throw. Its
3701 /// result is a boolean constant.
3702 class CXXNoexceptExpr : public Expr {
3703  friend class ASTStmtReader;
3704 
3705  bool Value : 1;
3706  Stmt *Operand;
3707  SourceRange Range;
3708 
3709 public:
3711  SourceLocation Keyword, SourceLocation RParen)
3712  : Expr(CXXNoexceptExprClass, Ty, VK_RValue, OK_Ordinary,
3713  /*TypeDependent*/false,
3714  /*ValueDependent*/Val == CT_Dependent,
3715  Val == CT_Dependent || Operand->isInstantiationDependent(),
3716  Operand->containsUnexpandedParameterPack()),
3717  Value(Val == CT_Cannot), Operand(Operand), Range(Keyword, RParen) {}
3718 
3719  CXXNoexceptExpr(EmptyShell Empty) : Expr(CXXNoexceptExprClass, Empty) {}
3720 
3721  Expr *getOperand() const { return static_cast<Expr*>(Operand); }
3722 
3723  SourceLocation getLocStart() const LLVM_READONLY { return getBeginLoc(); }
3724  SourceLocation getBeginLoc() const LLVM_READONLY { return Range.getBegin(); }
3725  SourceLocation getLocEnd() const LLVM_READONLY { return getEndLoc(); }
3726  SourceLocation getEndLoc() const LLVM_READONLY { return Range.getEnd(); }
3727  SourceRange getSourceRange() const LLVM_READONLY { return Range; }
3728 
3729  bool getValue() const { return Value; }
3730 
3731  static bool classof(const Stmt *T) {
3732  return T->getStmtClass() == CXXNoexceptExprClass;
3733  }
3734 
3735  // Iterators
3736  child_range children() { return child_range(&Operand, &Operand + 1); }
3737 };
3738 
3739 /// Represents a C++11 pack expansion that produces a sequence of
3740 /// expressions.
3741 ///
3742 /// A pack expansion expression contains a pattern (which itself is an
3743 /// expression) followed by an ellipsis. For example:
3744 ///
3745 /// \code
3746 /// template<typename F, typename ...Types>
3747 /// void forward(F f, Types &&...args) {
3748 /// f(static_cast<Types&&>(args)...);
3749 /// }
3750 /// \endcode
3751 ///
3752 /// Here, the argument to the function object \c f is a pack expansion whose
3753 /// pattern is \c static_cast<Types&&>(args). When the \c forward function
3754 /// template is instantiated, the pack expansion will instantiate to zero or
3755 /// or more function arguments to the function object \c f.
3756 class PackExpansionExpr : public Expr {
3757  friend class ASTStmtReader;
3758  friend class ASTStmtWriter;
3759 
3760  SourceLocation EllipsisLoc;
3761 
3762  /// The number of expansions that will be produced by this pack
3763  /// expansion expression, if known.
3764  ///
3765  /// When zero, the number of expansions is not known. Otherwise, this value
3766  /// is the number of expansions + 1.
3767  unsigned NumExpansions;
3768 
3769  Stmt *Pattern;
3770 
3771 public:
3772  PackExpansionExpr(QualType T, Expr *Pattern, SourceLocation EllipsisLoc,
3773  Optional<unsigned> NumExpansions)
3774  : Expr(PackExpansionExprClass, T, Pattern->getValueKind(),
3775  Pattern->getObjectKind(), /*TypeDependent=*/true,
3776  /*ValueDependent=*/true, /*InstantiationDependent=*/true,
3777  /*ContainsUnexpandedParameterPack=*/false),
3778  EllipsisLoc(EllipsisLoc),
3779  NumExpansions(NumExpansions ? *NumExpansions + 1 : 0),
3780  Pattern(Pattern) {}
3781 
3782  PackExpansionExpr(EmptyShell Empty) : Expr(PackExpansionExprClass, Empty) {}
3783 
3784  /// Retrieve the pattern of the pack expansion.
3785  Expr *getPattern() { return reinterpret_cast<Expr *>(Pattern); }
3786 
3787  /// Retrieve the pattern of the pack expansion.
3788  const Expr *getPattern() const { return reinterpret_cast<Expr *>(Pattern); }
3789 
3790  /// Retrieve the location of the ellipsis that describes this pack
3791  /// expansion.
3792  SourceLocation getEllipsisLoc() const { return EllipsisLoc; }
3793 
3794  /// Determine the number of expansions that will be produced when
3795  /// this pack expansion is instantiated, if already known.
3797  if (NumExpansions)
3798  return NumExpansions - 1;
3799 
3800  return None;
3801  }
3802 
3803  SourceLocation getLocStart() const LLVM_READONLY { return getBeginLoc(); }
3804  SourceLocation getBeginLoc() const LLVM_READONLY {
3805  return Pattern->getLocStart();
3806  }
3807 
3808  SourceLocation getLocEnd() const LLVM_READONLY { return getEndLoc(); }
3809  SourceLocation getEndLoc() const LLVM_READONLY { return EllipsisLoc; }
3810 
3811  static bool classof(const Stmt *T) {
3812  return T->getStmtClass() == PackExpansionExprClass;
3813  }
3814 
3815  // Iterators
3817  return child_range(&Pattern, &Pattern + 1);
3818  }
3819 };
3820 
3821 /// Represents an expression that computes the length of a parameter
3822 /// pack.
3823 ///
3824 /// \code
3825 /// template<typename ...Types>
3826 /// struct count {
3827 /// static const unsigned value = sizeof...(Types);
3828 /// };
3829 /// \endcode
3830 class SizeOfPackExpr final
3831  : public Expr,
3832  private llvm::TrailingObjects<SizeOfPackExpr, TemplateArgument> {
3833  friend class ASTStmtReader;
3834  friend class ASTStmtWriter;
3835  friend TrailingObjects;
3836 
3837  /// The location of the \c sizeof keyword.
3838  SourceLocation OperatorLoc;
3839 
3840  /// The location of the name of the parameter pack.
3841  SourceLocation PackLoc;
3842 
3843  /// The location of the closing parenthesis.
3844  SourceLocation RParenLoc;
3845 
3846  /// The length of the parameter pack, if known.
3847  ///
3848  /// When this expression is not value-dependent, this is the length of
3849  /// the pack. When the expression was parsed rather than instantiated
3850  /// (and thus is value-dependent), this is zero.
3851  ///
3852  /// After partial substitution into a sizeof...(X) expression (for instance,
3853  /// within an alias template or during function template argument deduction),
3854  /// we store a trailing array of partially-substituted TemplateArguments,
3855  /// and this is the length of that array.
3856  unsigned Length;
3857 
3858  /// The parameter pack.
3859  NamedDecl *Pack = nullptr;
3860 
3861  /// Create an expression that computes the length of
3862  /// the given parameter pack.
3863  SizeOfPackExpr(QualType SizeType, SourceLocation OperatorLoc, NamedDecl *Pack,
3864  SourceLocation PackLoc, SourceLocation RParenLoc,
3865  Optional<unsigned> Length, ArrayRef<TemplateArgument> PartialArgs)
3866  : Expr(SizeOfPackExprClass, SizeType, VK_RValue, OK_Ordinary,
3867  /*TypeDependent=*/false, /*ValueDependent=*/!Length,
3868  /*InstantiationDependent=*/!Length,
3869  /*ContainsUnexpandedParameterPack=*/false),
3870  OperatorLoc(OperatorLoc), PackLoc(PackLoc), RParenLoc(RParenLoc),
3871  Length(Length ? *Length : PartialArgs.size()), Pack(Pack) {
3872  assert((!Length || PartialArgs.empty()) &&
3873  "have partial args for non-dependent sizeof... expression");
3874  auto *Args = getTrailingObjects<TemplateArgument>();
3875  std::uninitialized_copy(PartialArgs.begin(), PartialArgs.end(), Args);
3876  }
3877 
3878  /// Create an empty expression.
3879  SizeOfPackExpr(EmptyShell Empty, unsigned NumPartialArgs)
3880  : Expr(SizeOfPackExprClass, Empty), Length(NumPartialArgs) {}
3881 
3882 public:
3883  static SizeOfPackExpr *Create(ASTContext &Context, SourceLocation OperatorLoc,
3884  NamedDecl *Pack, SourceLocation PackLoc,
3885  SourceLocation RParenLoc,
3886  Optional<unsigned> Length = None,
3887  ArrayRef<TemplateArgument> PartialArgs = None);
3888  static SizeOfPackExpr *CreateDeserialized(ASTContext &Context,
3889  unsigned NumPartialArgs);
3890 
3891  /// Determine the location of the 'sizeof' keyword.
3892  SourceLocation getOperatorLoc() const { return OperatorLoc; }
3893 
3894  /// Determine the location of the parameter pack.
3895  SourceLocation getPackLoc() const { return PackLoc; }
3896 
3897  /// Determine the location of the right parenthesis.
3898  SourceLocation getRParenLoc() const { return RParenLoc; }
3899 
3900  /// Retrieve the parameter pack.
3901  NamedDecl *getPack() const { return Pack; }
3902 
3903  /// Retrieve the length of the parameter pack.
3904  ///
3905  /// This routine may only be invoked when the expression is not
3906  /// value-dependent.
3907  unsigned getPackLength() const {
3908  assert(!isValueDependent() &&
3909  "Cannot get the length of a value-dependent pack size expression");
3910  return Length;
3911  }
3912 
3913  /// Determine whether this represents a partially-substituted sizeof...
3914  /// expression, such as is produced for:
3915  ///
3916  /// template<typename ...Ts> using X = int[sizeof...(Ts)];
3917  /// template<typename ...Us> void f(X<Us..., 1, 2, 3, Us...>);
3918  bool isPartiallySubstituted() const {
3919  return isValueDependent() && Length;
3920  }
3921 
3922  /// Get
3924  assert(isPartiallySubstituted());
3925  const auto *Args = getTrailingObjects<TemplateArgument>();
3926  return llvm::makeArrayRef(Args, Args + Length);
3927  }
3928 
3929  SourceLocation getLocStart() const LLVM_READONLY { return getBeginLoc(); }
3930  SourceLocation getBeginLoc() const LLVM_READONLY { return OperatorLoc; }
3931  SourceLocation getLocEnd() const LLVM_READONLY { return getEndLoc(); }
3932  SourceLocation getEndLoc() const LLVM_READONLY { return RParenLoc; }
3933 
3934  static bool classof(const Stmt *T) {
3935  return T->getStmtClass() == SizeOfPackExprClass;
3936  }
3937 
3938  // Iterators
3941  }
3942 };
3943 
3944 /// Represents a reference to a non-type template parameter
3945 /// that has been substituted with a template argument.
3947  friend class ASTReader;
3948  friend class ASTStmtReader;
3949 
3950  /// The replaced parameter.
3951  NonTypeTemplateParmDecl *Param;
3952 
3953  /// The replacement expression.
3954  Stmt *Replacement;
3955 
3956  /// The location of the non-type template parameter reference.
3957  SourceLocation NameLoc;
3958 
3960  : Expr(SubstNonTypeTemplateParmExprClass, Empty) {}
3961 
3962 public:
3964  ExprValueKind valueKind,
3965  SourceLocation loc,
3966  NonTypeTemplateParmDecl *param,
3967  Expr *replacement)
3968  : Expr(SubstNonTypeTemplateParmExprClass, type, valueKind, OK_Ordinary,
3969  replacement->isTypeDependent(), replacement->isValueDependent(),
3970  replacement->isInstantiationDependent(),
3971  replacement->containsUnexpandedParameterPack()),
3972  Param(param), Replacement(replacement), NameLoc(loc) {}
3973 
3974  SourceLocation getNameLoc() const { return NameLoc; }
3975  SourceLocation getLocStart() const LLVM_READONLY { return getBeginLoc(); }
3976  SourceLocation getBeginLoc() const LLVM_READONLY { return NameLoc; }
3977  SourceLocation getLocEnd() const LLVM_READONLY { return getEndLoc(); }
3978  SourceLocation getEndLoc() const LLVM_READONLY { return NameLoc; }
3979 
3980  Expr *getReplacement() const { return cast<Expr>(Replacement); }
3981 
3982  NonTypeTemplateParmDecl *getParameter() const { return Param; }
3983 
3984  static bool classof(const Stmt *s) {
3985  return s->getStmtClass() == SubstNonTypeTemplateParmExprClass;
3986  }
3987 
3988  // Iterators
3989  child_range children() { return child_range(&Replacement, &Replacement+1); }
3990 };
3991 
3992 /// Represents a reference to a non-type template parameter pack that
3993 /// has been substituted with a non-template argument pack.
3994 ///
3995 /// When a pack expansion in the source code contains multiple parameter packs
3996 /// and those parameter packs correspond to different levels of template
3997 /// parameter lists, this node is used to represent a non-type template
3998 /// parameter pack from an outer level, which has already had its argument pack
3999 /// substituted but that still lives within a pack expansion that itself
4000 /// could not be instantiated. When actually performing a substitution into
4001 /// that pack expansion (e.g., when all template parameters have corresponding
4002 /// arguments), this type will be replaced with the appropriate underlying
4003 /// expression at the current pack substitution index.
4005  friend class ASTReader;
4006  friend class ASTStmtReader;
4007 
4008  /// The non-type template parameter pack itself.
4009  NonTypeTemplateParmDecl *Param;
4010 
4011  /// A pointer to the set of template arguments that this
4012  /// parameter pack is instantiated with.
4013  const TemplateArgument *Arguments;
4014 
4015  /// The number of template arguments in \c Arguments.
4016  unsigned NumArguments;
4017 
4018  /// The location of the non-type template parameter pack reference.
4019  SourceLocation NameLoc;
4020 
4022  : Expr(SubstNonTypeTemplateParmPackExprClass, Empty) {}
4023 
4024 public:
4026  ExprValueKind ValueKind,
4027  NonTypeTemplateParmDecl *Param,
4028  SourceLocation NameLoc,
4029  const TemplateArgument &ArgPack);
4030 
4031  /// Retrieve the non-type template parameter pack being substituted.
4032  NonTypeTemplateParmDecl *getParameterPack() const { return Param; }
4033 
4034  /// Retrieve the location of the parameter pack name.
4035  SourceLocation getParameterPackLocation() const { return NameLoc; }
4036 
4037  /// Retrieve the template argument pack containing the substituted
4038  /// template arguments.
4039  TemplateArgument getArgumentPack() const;
4040 
4041  SourceLocation getLocStart() const LLVM_READONLY { return getBeginLoc(); }
4042  SourceLocation getBeginLoc() const LLVM_READONLY { return NameLoc; }
4043  SourceLocation getLocEnd() const LLVM_READONLY { return getEndLoc(); }
4044  SourceLocation getEndLoc() const LLVM_READONLY { return NameLoc; }
4045 
4046  static bool classof(const Stmt *T) {
4047  return T->getStmtClass() == SubstNonTypeTemplateParmPackExprClass;
4048  }
4049 
4050  // Iterators
4053  }
4054 };
4055 
4056 /// Represents a reference to a function parameter pack that has been
4057 /// substituted but not yet expanded.
4058 ///
4059 /// When a pack expansion contains multiple parameter packs at different levels,
4060 /// this node is used to represent a function parameter pack at an outer level
4061 /// which we have already substituted to refer to expanded parameters, but where
4062 /// the containing pack expansion cannot yet be expanded.
4063 ///
4064 /// \code
4065 /// template<typename...Ts> struct S {
4066 /// template<typename...Us> auto f(Ts ...ts) -> decltype(g(Us(ts)...));
4067 /// };
4068 /// template struct S<int, int>;
4069 /// \endcode
4071  : public Expr,
4072  private llvm::TrailingObjects<FunctionParmPackExpr, ParmVarDecl *> {
4073  friend class ASTReader;
4074  friend class ASTStmtReader;
4075  friend TrailingObjects;
4076 
4077  /// The function parameter pack which was referenced.
4078  ParmVarDecl *ParamPack;
4079 
4080  /// The location of the function parameter pack reference.
4081  SourceLocation NameLoc;
4082 
4083  /// The number of expansions of this pack.
4084  unsigned NumParameters;
4085 
4087  SourceLocation NameLoc, unsigned NumParams,
4088  ParmVarDecl *const *Params);
4089 
4090 public:
4091  static FunctionParmPackExpr *Create(const ASTContext &Context, QualType T,
4092  ParmVarDecl *ParamPack,
4093  SourceLocation NameLoc,
4094  ArrayRef<ParmVarDecl *> Params);
4095  static FunctionParmPackExpr *CreateEmpty(const ASTContext &Context,
4096  unsigned NumParams);
4097 
4098  /// Get the parameter pack which this expression refers to.
4099  ParmVarDecl *getParameterPack() const { return ParamPack; }
4100 
4101  /// Get the location of the parameter pack.
4102  SourceLocation getParameterPackLocation() const { return NameLoc; }
4103 
4104  /// Iterators over the parameters which the parameter pack expanded
4105  /// into.
4106  using iterator = ParmVarDecl * const *;
4107  iterator begin() const { return getTrailingObjects<ParmVarDecl *>(); }
4108  iterator end() const { return begin() + NumParameters; }
4109 
4110  /// Get the number of parameters in this parameter pack.
4111  unsigned getNumExpansions() const { return NumParameters; }
4112 
4113  /// Get an expansion of the parameter pack by index.
4114  ParmVarDecl *getExpansion(unsigned I) const { return begin()[I]; }
4115 
4116  SourceLocation getLocStart() const LLVM_READONLY { return getBeginLoc(); }
4117  SourceLocation getBeginLoc() const LLVM_READONLY { return NameLoc; }
4118  SourceLocation getLocEnd() const LLVM_READONLY { return getEndLoc(); }
4119  SourceLocation getEndLoc() const LLVM_READONLY { return NameLoc; }
4120 
4121  static bool classof(const Stmt *T) {
4122  return T->getStmtClass() == FunctionParmPackExprClass;
4123  }
4124 
4127  }
4128 };
4129 
4130 /// Represents a prvalue temporary that is written into memory so that
4131 /// a reference can bind to it.
4132 ///
4133 /// Prvalue expressions are materialized when they need to have an address
4134 /// in memory for a reference to bind to. This happens when binding a
4135 /// reference to the result of a conversion, e.g.,
4136 ///
4137 /// \code
4138 /// const int &r = 1.0;
4139 /// \endcode
4140 ///
4141 /// Here, 1.0 is implicitly converted to an \c int. That resulting \c int is
4142 /// then materialized via a \c MaterializeTemporaryExpr, and the reference
4143 /// binds to the temporary. \c MaterializeTemporaryExprs are always glvalues
4144 /// (either an lvalue or an xvalue, depending on the kind of reference binding
4145 /// to it), maintaining the invariant that references always bind to glvalues.
4146 ///
4147 /// Reference binding and copy-elision can both extend the lifetime of a
4148 /// temporary. When either happens, the expression will also track the
4149 /// declaration which is responsible for the lifetime extension.
4151 private:
4152  friend class ASTStmtReader;
4153  friend class ASTStmtWriter;
4154 
4155  struct ExtraState {
4156  /// The temporary-generating expression whose value will be
4157  /// materialized.
4158  Stmt *Temporary;
4159 
4160  /// The declaration which lifetime-extended this reference, if any.
4161  /// Either a VarDecl, or (for a ctor-initializer) a FieldDecl.
4162  const ValueDecl *ExtendingDecl;
4163 
4164  unsigned ManglingNumber;
4165  };
4166  llvm::PointerUnion<Stmt *, ExtraState *> State;
4167 
4168  void initializeExtraState(const ValueDecl *ExtendedBy,
4169  unsigned ManglingNumber);
4170 
4171 public:
4173  bool BoundToLvalueReference)
4174  : Expr(MaterializeTemporaryExprClass, T,
4175  BoundToLvalueReference? VK_LValue : VK_XValue, OK_Ordinary,
4176  Temporary->isTypeDependent(), Temporary->isValueDependent(),
4177  Temporary->isInstantiationDependent(),
4178  Temporary->containsUnexpandedParameterPack()),
4179  State(Temporary) {}
4180 
4182  : Expr(MaterializeTemporaryExprClass, Empty) {}
4183 
4184  Stmt *getTemporary() const {
4185  return State.is<Stmt *>() ? State.get<Stmt *>()
4186  : State.get<ExtraState *>()->Temporary;
4187  }
4188 
4189  /// Retrieve the temporary-generating subexpression whose value will
4190  /// be materialized into a glvalue.
4191  Expr *GetTemporaryExpr() const { return static_cast<Expr *>(getTemporary()); }
4192 
4193  /// Retrieve the storage duration for the materialized temporary.
4195  const ValueDecl *ExtendingDecl = getExtendingDecl();
4196  if (!ExtendingDecl)
4197  return SD_FullExpression;
4198  // FIXME: This is not necessarily correct for a temporary materialized
4199  // within a default initializer.
4200  if (isa<FieldDecl>(ExtendingDecl))
4201  return SD_Automatic;
4202  // FIXME: This only works because storage class specifiers are not allowed
4203  // on decomposition declarations.
4204  if (isa<BindingDecl>(ExtendingDecl))
4205  return ExtendingDecl->getDeclContext()->isFunctionOrMethod()
4206  ? SD_Automatic
4207  : SD_Static;
4208  return cast<VarDecl>(ExtendingDecl)->getStorageDuration();
4209  }
4210 
4211  /// Get the declaration which triggered the lifetime-extension of this
4212  /// temporary, if any.
4213  const ValueDecl *getExtendingDecl() const {
4214  return State.is<Stmt *>() ? nullptr
4215  : State.get<ExtraState *>()->ExtendingDecl;
4216  }
4217 
4218  void setExtendingDecl(const ValueDecl *ExtendedBy, unsigned ManglingNumber);
4219 
4220  unsigned getManglingNumber() const {
4221  return State.is<Stmt *>() ? 0 : State.get<ExtraState *>()->ManglingNumber;
4222  }
4223 
4224  /// Determine whether this materialized temporary is bound to an
4225  /// lvalue reference; otherwise, it's bound to an rvalue reference.
4227  return getValueKind() == VK_LValue;
4228  }
4229 
4230  SourceLocation getLocStart() const LLVM_READONLY { return getBeginLoc(); }
4231  SourceLocation getBeginLoc() const LLVM_READONLY {
4232  return getTemporary()->getLocStart();
4233  }
4234 
4235  SourceLocation getLocEnd() const LLVM_READONLY { return getEndLoc(); }
4236  SourceLocation getEndLoc() const LLVM_READONLY {
4237  return getTemporary()->getLocEnd();
4238  }
4239 
4240  static bool classof(const Stmt *T) {
4241  return T->getStmtClass() == MaterializeTemporaryExprClass;
4242  }
4243 
4244  // Iterators
4246  if (State.is<Stmt *>())
4247  return child_range(State.getAddrOfPtr1(), State.getAddrOfPtr1() + 1);
4248 
4249  auto ES = State.get<ExtraState *>();
4250  return child_range(&ES->Temporary, &ES->Temporary + 1);
4251  }
4252 };
4253 
4254 /// Represents a folding of a pack over an operator.
4255 ///
4256 /// This expression is always dependent and represents a pack expansion of the
4257 /// forms:
4258 ///
4259 /// ( expr op ... )
4260 /// ( ... op expr )
4261 /// ( expr op ... op expr )
4262 class CXXFoldExpr : public Expr {
4263  friend class ASTStmtReader;
4264  friend class ASTStmtWriter;
4265 
4266  SourceLocation LParenLoc;
4267  SourceLocation EllipsisLoc;
4268  SourceLocation RParenLoc;
4269  Stmt *SubExprs[2];
4270  BinaryOperatorKind Opcode;
4271 
4272 public:
4274  BinaryOperatorKind Opcode, SourceLocation EllipsisLoc, Expr *RHS,
4275  SourceLocation RParenLoc)
4276  : Expr(CXXFoldExprClass, T, VK_RValue, OK_Ordinary,
4277  /*Dependent*/ true, true, true,
4278  /*ContainsUnexpandedParameterPack*/ false),
4279  LParenLoc(LParenLoc), EllipsisLoc(EllipsisLoc), RParenLoc(RParenLoc),
4280  Opcode(Opcode) {
4281  SubExprs[0] = LHS;
4282  SubExprs[1] = RHS;
4283  }
4284 
4285  CXXFoldExpr(EmptyShell Empty) : Expr(CXXFoldExprClass, Empty) {}
4286 
4287  Expr *getLHS() const { return static_cast<Expr*>(SubExprs[0]); }
4288  Expr *getRHS() const { return static_cast<Expr*>(SubExprs[1]); }
4289 
4290  /// Does this produce a right-associated sequence of operators?
4291  bool isRightFold() const {
4292  return getLHS() && getLHS()->containsUnexpandedParameterPack();
4293  }
4294 
4295  /// Does this produce a left-associated sequence of operators?
4296  bool isLeftFold() const { return !isRightFold(); }
4297 
4298  /// Get the pattern, that is, the operand that contains an unexpanded pack.
4299  Expr *getPattern() const { return isLeftFold() ? getRHS() : getLHS(); }
4300 
4301  /// Get the operand that doesn't contain a pack, for a binary fold.
4302  Expr *getInit() const { return isLeftFold() ? getLHS() : getRHS(); }
4303 
4304  SourceLocation getEllipsisLoc() const { return EllipsisLoc; }
4305  BinaryOperatorKind getOperator() const { return Opcode; }
4306 
4307  SourceLocation getLocStart() const LLVM_READONLY { return getBeginLoc(); }
4308  SourceLocation getBeginLoc() const LLVM_READONLY { return LParenLoc; }
4309 
4310  SourceLocation getLocEnd() const LLVM_READONLY { return getEndLoc(); }
4311  SourceLocation getEndLoc() const LLVM_READONLY { return RParenLoc; }
4312 
4313  static bool classof(const Stmt *T) {
4314  return T->getStmtClass() == CXXFoldExprClass;
4315  }
4316 
4317  // Iterators
4318  child_range children() { return child_range(SubExprs, SubExprs + 2); }
4319 };
4320 
4321 /// Represents an expression that might suspend coroutine execution;
4322 /// either a co_await or co_yield expression.
4323 ///
4324 /// Evaluation of this expression first evaluates its 'ready' expression. If
4325 /// that returns 'false':
4326 /// -- execution of the coroutine is suspended
4327 /// -- the 'suspend' expression is evaluated
4328 /// -- if the 'suspend' expression returns 'false', the coroutine is
4329 /// resumed
4330 /// -- otherwise, control passes back to the resumer.
4331 /// If the coroutine is not suspended, or when it is resumed, the 'resume'
4332 /// expression is evaluated, and its result is the result of the overall
4333 /// expression.
4334 class CoroutineSuspendExpr : public Expr {
4335  friend class ASTStmtReader;
4336 
4337  SourceLocation KeywordLoc;
4338 
4339  enum SubExpr { Common, Ready, Suspend, Resume, Count };
4340 
4341  Stmt *SubExprs[SubExpr::Count];
4342  OpaqueValueExpr *OpaqueValue = nullptr;
4343 
4344 public:
4346  Expr *Ready, Expr *Suspend, Expr *Resume,
4347  OpaqueValueExpr *OpaqueValue)
4348  : Expr(SC, Resume->getType(), Resume->getValueKind(),
4349  Resume->getObjectKind(), Resume->isTypeDependent(),
4350  Resume->isValueDependent(), Common->isInstantiationDependent(),
4352  KeywordLoc(KeywordLoc), OpaqueValue(OpaqueValue) {
4353  SubExprs[SubExpr::Common] = Common;
4354  SubExprs[SubExpr::Ready] = Ready;
4355  SubExprs[SubExpr::Suspend] = Suspend;
4356  SubExprs[SubExpr::Resume] = Resume;
4357  }
4358 
4360  Expr *Common)
4361  : Expr(SC, Ty, VK_RValue, OK_Ordinary, true, true, true,
4363  KeywordLoc(KeywordLoc) {
4364  assert(Common->isTypeDependent() && Ty->isDependentType() &&
4365  "wrong constructor for non-dependent co_await/co_yield expression");
4366  SubExprs[SubExpr::Common] = Common;
4367  SubExprs[SubExpr::Ready] = nullptr;
4368  SubExprs[SubExpr::Suspend] = nullptr;
4369  SubExprs[SubExpr::Resume] = nullptr;
4370  }
4371 
4372  CoroutineSuspendExpr(StmtClass SC, EmptyShell Empty) : Expr(SC, Empty) {
4373  SubExprs[SubExpr::Common] = nullptr;
4374  SubExprs[SubExpr::Ready] = nullptr;
4375  SubExprs[SubExpr::Suspend] = nullptr;
4376  SubExprs[SubExpr::Resume] = nullptr;
4377  }
4378 
4379  SourceLocation getKeywordLoc() const { return KeywordLoc; }
4380 
4381  Expr *getCommonExpr() const {
4382  return static_cast<Expr*>(SubExprs[SubExpr::Common]);
4383  }
4384 
4385  /// getOpaqueValue - Return the opaque value placeholder.
4386  OpaqueValueExpr *getOpaqueValue() const { return OpaqueValue; }
4387 
4388  Expr *getReadyExpr() const {
4389  return static_cast<Expr*>(SubExprs[SubExpr::Ready]);
4390  }
4391 
4393  return static_cast<Expr*>(SubExprs[SubExpr::Suspend]);
4394  }
4395 
4396  Expr *getResumeExpr() const {
4397  return static_cast<Expr*>(SubExprs[SubExpr::Resume]);
4398  }
4399 
4400  SourceLocation getLocStart() const LLVM_READONLY { return getBeginLoc(); }
4401  SourceLocation getBeginLoc() const LLVM_READONLY { return KeywordLoc; }
4402 
4403  SourceLocation getLocEnd() const LLVM_READONLY { return getEndLoc(); }
4404  SourceLocation getEndLoc() const LLVM_READONLY {
4405  return getCommonExpr()->getLocEnd();
4406  }
4407 
4409  return child_range(SubExprs, SubExprs + SubExpr::Count);
4410  }
4411 
4412  static bool classof(const Stmt *T) {
4413  return T->getStmtClass() == CoawaitExprClass ||
4414  T->getStmtClass() == CoyieldExprClass;
4415  }
4416 };
4417 
4418 /// Represents a 'co_await' expression.
4420  friend class ASTStmtReader;
4421 
4422 public:
4423  CoawaitExpr(SourceLocation CoawaitLoc, Expr *Operand, Expr *Ready,
4424  Expr *Suspend, Expr *Resume, OpaqueValueExpr *OpaqueValue,
4425  bool IsImplicit = false)
4426  : CoroutineSuspendExpr(CoawaitExprClass, CoawaitLoc, Operand, Ready,
4427  Suspend, Resume, OpaqueValue) {
4428  CoawaitBits.IsImplicit = IsImplicit;
4429  }
4430 
4431  CoawaitExpr(SourceLocation CoawaitLoc, QualType Ty, Expr *Operand,
4432  bool IsImplicit = false)
4433  : CoroutineSuspendExpr(CoawaitExprClass, CoawaitLoc, Ty, Operand) {
4434  CoawaitBits.IsImplicit = IsImplicit;
4435  }
4436 
4438  : CoroutineSuspendExpr(CoawaitExprClass, Empty) {}
4439 
4440  Expr *getOperand() const {
4441  // FIXME: Dig out the actual operand or store it.
4442  return getCommonExpr();
4443  }
4444 
4445  bool isImplicit() const { return CoawaitBits.IsImplicit; }
4446  void setIsImplicit(bool value = true) { CoawaitBits.IsImplicit = value; }
4447 
4448  static bool classof(const Stmt *T) {
4449  return T->getStmtClass() == CoawaitExprClass;
4450  }
4451 };
4452 
4453 /// Represents a 'co_await' expression while the type of the promise
4454 /// is dependent.
4455 class DependentCoawaitExpr : public Expr {
4456  friend class ASTStmtReader;
4457 
4458  SourceLocation KeywordLoc;
4459  Stmt *SubExprs[2];
4460 
4461 public:
4463  UnresolvedLookupExpr *OpCoawait)
4464  : Expr(DependentCoawaitExprClass, Ty, VK_RValue, OK_Ordinary,
4465  /*TypeDependent*/ true, /*ValueDependent*/ true,
4466  /*InstantiationDependent*/ true,
4468  KeywordLoc(KeywordLoc) {
4469  // NOTE: A co_await expression is dependent on the coroutines promise
4470  // type and may be dependent even when the `Op` expression is not.
4471  assert(Ty->isDependentType() &&
4472  "wrong constructor for non-dependent co_await/co_yield expression");
4473  SubExprs[0] = Op;
4474  SubExprs[1] = OpCoawait;
4475  }
4476 
4478  : Expr(DependentCoawaitExprClass, Empty) {}
4479 
4480  Expr *getOperand() const { return cast<Expr>(SubExprs[0]); }
4481 
4483  return cast<UnresolvedLookupExpr>(SubExprs[1]);
4484  }
4485 
4486  SourceLocation getKeywordLoc() const { return KeywordLoc; }
4487 
4488  SourceLocation getLocStart() const LLVM_READONLY { return getBeginLoc(); }
4489  SourceLocation getBeginLoc() const LLVM_READONLY { return KeywordLoc; }
4490 
4491  SourceLocation getLocEnd() const LLVM_READONLY { return getEndLoc(); }
4492  SourceLocation getEndLoc() const LLVM_READONLY {
4493  return getOperand()->getLocEnd();
4494  }
4495 
4496  child_range children() { return child_range(SubExprs, SubExprs + 2); }
4497 
4498  static bool classof(const Stmt *T) {
4499  return T->getStmtClass() == DependentCoawaitExprClass;
4500  }
4501 };
4502 
4503 /// Represents a 'co_yield' expression.
4505  friend class ASTStmtReader;
4506 
4507 public:
4508  CoyieldExpr(SourceLocation CoyieldLoc, Expr *Operand, Expr *Ready,
4509  Expr *Suspend, Expr *Resume, OpaqueValueExpr *OpaqueValue)
4510  : CoroutineSuspendExpr(CoyieldExprClass, CoyieldLoc, Operand, Ready,
4511  Suspend, Resume, OpaqueValue) {}
4512  CoyieldExpr(SourceLocation CoyieldLoc, QualType Ty, Expr *Operand)
4513  : CoroutineSuspendExpr(CoyieldExprClass, CoyieldLoc, Ty, Operand) {}
4515  : CoroutineSuspendExpr(CoyieldExprClass, Empty) {}
4516 
4517  Expr *getOperand() const {
4518  // FIXME: Dig out the actual operand or store it.
4519  return getCommonExpr();
4520  }
4521 
4522  static bool classof(const Stmt *T) {
4523  return T->getStmtClass() == CoyieldExprClass;
4524  }
4525 };
4526 
4527 } // namespace clang
4528 
4529 #endif // LLVM_CLANG_AST_EXPRCXX_H
CXXUuidofExpr(QualType Ty, TypeSourceInfo *Operand, StringRef UuidStr, SourceRange R)
Definition: ExprCXX.h:902
SourceLocation getLocStart() const LLVM_READONLY
Definition: ExprCXX.h:1272
CoroutineSuspendExpr(StmtClass SC, SourceLocation KeywordLoc, Expr *Common, Expr *Ready, Expr *Suspend, Expr *Resume, OpaqueValueExpr *OpaqueValue)
Definition: ExprCXX.h:4345
Expr * getReadyExpr() const
Definition: ExprCXX.h:4388
A call to an overloaded operator written using operator syntax.
Definition: ExprCXX.h:78
SourceLocation getLoc() const
getLoc - Returns the main location of the declaration name.
Raw form: operator "" X (const char *)
Definition: ExprCXX.h:501
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprCXX.h:645
MSPropertySubscriptExpr(EmptyShell Shell)
Create an empty array subscript expression.
Definition: ExprCXX.h:857
CXXDeleteExpr(EmptyShell Shell)
Definition: ExprCXX.h:2183
void setRParenLoc(SourceLocation L)
Definition: ExprCXX.h:1567
LiteralOperatorKind
The kind of literal operator which is invoked.
Definition: ExprCXX.h:499
operator "" X (long double)
Definition: ExprCXX.h:510
TypeSourceInfo * getTypeOperandSourceInfo() const
Retrieve source information for the type operand.
Definition: ExprCXX.h:931
The null pointer literal (C++11 [lex.nullptr])
Definition: ExprCXX.h:593
const CXXDestructorDecl * getDestructor() const
Definition: ExprCXX.h:1224
SourceLocation getLAngleLoc() const
Retrieve the location of the left angle bracket starting the explicit template argument list followin...
Definition: ExprCXX.h:2766
unsigned getNumDecls() const
Gets the number of declarations in the unresolved set.
Definition: ExprCXX.h:2737
Represents a function declaration or definition.
Definition: Decl.h:1716
Represents a &#39;co_await&#39; expression while the type of the promise is dependent.
Definition: ExprCXX.h:4455
bool getValue() const
Definition: ExprCXX.h:2464
void setPreArg(unsigned i, Stmt *PreArg)
Definition: Expr.h:2342
Expr ** getArgs()
Retrieve the call arguments.
Definition: Expr.h:2376
SourceLocation getEndLoc() const LLVM_READONLY
Definition: ExprCXX.h:3932
bool hasExplicitTemplateArgs() const
Determines whether this expression had explicit template arguments.
Definition: ExprCXX.h:2782
SourceRange getSourceRange() const LLVM_READONLY
Definition: ExprCXX.h:3727
static bool classof(const Stmt *T)
Definition: ExprCXX.h:1853
CoawaitExpr(SourceLocation CoawaitLoc, QualType Ty, Expr *Operand, bool IsImplicit=false)
Definition: ExprCXX.h:4431
bool hasTemplateKeyword() const
Determines whether the name was preceded by the template keyword.
Definition: ExprCXX.h:3028
SourceLocation getRParenLoc() const
Definition: Expr.h:2452
PointerType - C99 6.7.5.1 - Pointer Declarators.
Definition: Type.h:2393
llvm::iterator_range< arg_iterator > placement_arguments()
Definition: ExprCXX.h:2088
SourceLocation getUsedLocation() const
Retrieve the location where this default argument was actually used.
Definition: ExprCXX.h:1131
Stores the type being destroyed by a pseudo-destructor expression.
Definition: ExprCXX.h:2224
A (possibly-)qualified type.
Definition: Type.h:655
CXXBoolLiteralExpr(EmptyShell Empty)
Definition: ExprCXX.h:566
uint64_t getValue() const
Definition: ExprCXX.h:2558
Static storage duration.
Definition: Specifiers.h:280
ArrayRef< TemplateArgumentLoc > template_arguments() const
Definition: ExprCXX.h:3055
Expr * getArg(unsigned Arg)
getArg - Return the specified argument.
Definition: Expr.h:2385
SourceLocation getEndLoc() const LLVM_READONLY
Definition: ExprCXX.h:1138
Defines enumerations for the type traits support.
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprCXX.h:1063
void setLocation(SourceLocation L)
Definition: ExprCXX.h:578
const Expr * getSubExpr() const
Definition: ExprCXX.h:1050
Expr(StmtClass SC, QualType T, ExprValueKind VK, ExprObjectKind OK, bool TD, bool VD, bool ID, bool ContainsUnexpandedParameterPack)
Definition: Expr.h:110
SourceLocation getLocStart() const LLVM_READONLY
Definition: ExprCXX.h:4400
SourceLocation getLocEnd() const LLVM_READONLY
Definition: ExprCXX.h:1199
CoawaitExpr(EmptyShell Empty)
Definition: ExprCXX.h:4437
const_capture_init_iterator capture_init_begin() const
Retrieve the first initialization argument for this lambda expression (which initializes the first ca...
Definition: ExprCXX.h:1800
A type trait used in the implementation of various C++11 and Library TR1 trait templates.
Definition: ExprCXX.h:2421
SourceLocation TemplateKWLoc
The source location of the template keyword; this is used as part of the representation of qualified ...
Definition: TemplateBase.h:655
const_arg_iterator placement_arg_end() const
Definition: ExprCXX.h:2105
CXXDeleteExpr(QualType ty, bool globalDelete, bool arrayForm, bool arrayFormAsWritten, bool usualArrayDeleteWantsSize, FunctionDecl *operatorDelete, Expr *arg, SourceLocation loc)
Definition: ExprCXX.h:2173
bool isListInitialization() const
Determine whether this expression models list-initialization.
Definition: ExprCXX.h:3240
child_range children()
Definition: ExprCXX.h:1288
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprCXX.h:4401
static UnresolvedLookupExpr * Create(const ASTContext &C, CXXRecordDecl *NamingClass, NestedNameSpecifierLoc QualifierLoc, const DeclarationNameInfo &NameInfo, bool ADL, bool Overloaded, UnresolvedSetIterator Begin, UnresolvedSetIterator End)
Definition: ExprCXX.h:2869
bool hasExplicitResultType() const
Whether this lambda had its result type explicitly specified.
Definition: ExprCXX.h:1851
bool isThrownVariableInScope() const
Determines whether the variable thrown by this expression (if any!) is within the innermost try block...
Definition: ExprCXX.h:1060
SourceLocation getStartLoc() const LLVM_READONLY
Definition: ExprCXX.h:2120
bool isLeftFold() const
Does this produce a left-associated sequence of operators?
Definition: ExprCXX.h:4296
Stmt - This represents one statement.
Definition: Stmt.h:66
unsigned getNumArgs() const
getNumArgs - Return the number of actual arguments to this call.
Definition: Expr.h:2373
Expr * getDimensionExpression() const
Definition: ExprCXX.h:2560
SourceLocation getLocStart() const LLVM_READONLY
Definition: ExprCXX.h:2484
SourceLocation getUDSuffixLoc() const
Returns the location of a ud-suffix in the expression.
Definition: ExprCXX.h:545
child_range children()
Definition: ExprCXX.h:3159
bool isArrayFormAsWritten() const
Definition: ExprCXX.h:2187
SourceLocation getLAngleLoc() const
Retrieve the location of the left angle bracket starting the explicit template argument list followin...
Definition: ExprCXX.h:3015
TemplateArgumentLoc const * getTemplateArgs() const
Definition: ExprCXX.h:3041
static bool classof(const Stmt *T)
Definition: ExprCXX.h:4448
C Language Family Type Representation.
SourceLocation getLocStart() const LLVM_READONLY
Definition: ExprCXX.h:954
SourceLocation getEndLoc() const LLVM_READONLY
Definition: ExprCXX.h:741
ArrayRef< CleanupObject > getObjects() const
Definition: ExprCXX.h:3120
CXXOperatorCallExpr(ASTContext &C, OverloadedOperatorKind Op, Expr *fn, ArrayRef< Expr *> args, QualType t, ExprValueKind VK, SourceLocation operatorloc, FPOptions FPFeatures)
Definition: ExprCXX.h:93
SourceLocation getLocStart() const LLVM_READONLY
Definition: ExprCXX.h:1197
arg_iterator arg_begin()
Definition: ExprCXX.h:1406
SourceLocation getLocStart() const LLVM_READONLY
Definition: ExprCXX.h:2130
FunctionDecl * getOperatorNew() const
Definition: ExprCXX.h:2015
LambdaCaptureDefault
The default, if any, capture method for a lambda expression.
Definition: Lambda.h:23
A reference to a name which we were able to look up during parsing but could not resolve to a specifi...
Definition: ExprCXX.h:2824
SourceLocation getEndLoc() const
Definition: ExprCXX.h:2122
QualType getNonReferenceType() const
If Type is a reference type (e.g., const int&), returns the type that the reference refers to ("const...
Definition: Type.h:6062
SourceLocation getLocEnd() const LLVM_READONLY
Definition: ExprCXX.h:3505
The base class of the type hierarchy.
Definition: Type.h:1428
NestedNameSpecifier * getQualifier() const
Retrieve the nested-name-specifier that qualifies this declaration.
Definition: ExprCXX.h:3002
bool requiresZeroInitialization() const
Whether this construction first requires zero-initialization before the initializer is called...
Definition: ExprCXX.h:1382
SourceLocation getBeginLoc() const
getBeginLoc - Retrieve the location of the first token.
static bool classof(const Stmt *T)
Definition: ExprCXX.h:3282
SourceLocation getLocation() const
Definition: ExprCXX.h:610
llvm::iterator_range< child_iterator > child_range
Definition: Stmt.h:458
SourceLocation getKeywordLoc() const
Definition: ExprCXX.h:4486
Represents a call to a C++ constructor.
Definition: ExprCXX.h:1292
SourceLocation getEndLoc() const LLVM_READONLY
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprCXX.h:3497
An Embarcadero array type trait, as used in the implementation of __array_rank and __array_extent...
Definition: ExprCXX.h:2507
static bool classof(const Stmt *S)
Definition: ExprCXX.h:659
A container of type source information.
Definition: Decl.h:86
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprCXX.h:4308
NestedNameSpecifier * getQualifier() const
If the member name was qualified, retrieves the nested-name-specifier that precedes the member name...
Definition: ExprCXX.h:2332
SourceLocation getEndLoc() const LLVM_READONLY
Definition: ExprCXX.h:1008
StorageDuration
The storage duration for an object (per C++ [basic.stc]).
Definition: Specifiers.h:276
Floating point control options.
Definition: LangOptions.h:263
MS property subscript expression.
Definition: ExprCXX.h:834
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprCXX.h:2485
SourceLocation getOperatorLoc() const
Determine the location of the &#39;sizeof&#39; keyword.
Definition: ExprCXX.h:3892
SourceLocation getRParenLoc() const
Definition: ExprCXX.h:1896
static bool classof(const Stmt *T)
Definition: ExprCXX.h:1512
child_range children()
Definition: ExprCXX.h:2921
SourceLocation getLocEnd() const LLVM_READONLY
Definition: ExprCXX.h:1574
void setLocation(SourceLocation Loc)
Definition: ExprCXX.h:1358
Describes the capture of a variable or of this, or of a C++1y init-capture.
Definition: LambdaCapture.h:26
Represents a C++ constructor within a class.
Definition: DeclCXX.h:2477
Represents a prvalue temporary that is written into memory so that a reference can bind to it...
Definition: ExprCXX.h:4150
SourceLocation getEndLoc() const LLVM_READONLY
Definition: ExprCXX.h:3658
const Expr * getSubExpr() const
Definition: ExprCXX.h:3133
void setRParenLoc(SourceLocation L)
Definition: ExprCXX.h:3235
SourceLocation getLocStart() const LLVM_READONLY
Definition: ExprCXX.h:4230
SourceLocation getLocStart() const LLVM_READONLY
Definition: ExprCXX.h:3803
SourceRange getSourceRange() const LLVM_READONLY
Definition: ExprCXX.h:2126
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprCXX.h:2548
child_range children()
Definition: ExprCXX.h:4125
SourceLocation getEndLoc() const LLVM_READONLY
Definition: ExprCXX.h:3067
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprCXX.h:3976
SourceRange getSourceRange() const LLVM_READONLY
Definition: ExprCXX.h:742
SourceLocation getOperatorLoc() const
Retrieve the location of the &#39;.&#39; or &#39;->&#39; operator.
Definition: ExprCXX.h:2341
const internal::VariadicDynCastAllOfMatcher< Stmt, Expr > expr
Matches expressions.
UnresolvedLookupExpr * getOperatorCoawaitLookup() const
Definition: ExprCXX.h:4482
IdentifierInfo * getIdentifier() const
Definition: ExprCXX.h:2244
const T * getAs() const
Member-template getAs<specific type>&#39;.
Definition: Type.h:6526
unsigned getNumArgs() const
Determine the number of arguments to this type trait.
Definition: ExprCXX.h:2470
llvm::iterator_range< arg_iterator > arg_range
Definition: Expr.h:2407
static bool classof(const Stmt *T)
Definition: ExprCXX.h:2133
DeclarationName getName() const
Gets the name looked up.
Definition: ExprCXX.h:2743
SourceLocation getEndLoc() const LLVM_READONLY
Definition: ExprCXX.h:1066
friend TrailingObjects
Definition: ExprCXX.h:2447
Implicit construction of a std::initializer_list<T> object from an array temporary within list-initia...
Definition: ExprCXX.h:624
static bool classof(const Stmt *T)
Definition: ExprCXX.h:381
Stores a list of template parameters for a TemplateDecl and its derived classes.
Definition: DeclTemplate.h:68
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprCXX.h:284
void setContainsUnexpandedParameterPack(bool PP=true)
Set the bit that describes whether this expression contains an unexpanded parameter pack...
Definition: Expr.h:220
static bool classof(const Stmt *T)
Definition: ExprCXX.h:289
unsigned getNumPlacementArgs() const
Definition: ExprCXX.h:2029
bool requiresADL() const
True if this declaration should be extended by argument-dependent lookup.
Definition: ExprCXX.h:2897
child_range children()
Definition: ExprCXX.h:3939
SourceLocation getLocEnd() const LLVM_READONLY
Definition: ExprCXX.h:538
SourceLocation getLocStart() const LLVM_READONLY
Definition: ExprCXX.h:866
raw_arg_iterator raw_arg_begin()
Definition: ExprCXX.h:2111
CXXConstructorDecl * getConstructor() const
Get the constructor that this expression will call.
Definition: ExprCXX.h:1490
A C++ throw-expression (C++ [except.throw]).
Definition: ExprCXX.h:1028
Expr * getExprOperand() const
Definition: ExprCXX.h:728
Represents an expression – generally a full-expression – that introduces cleanups to be run at the ...
Definition: ExprCXX.h:3092
TypeSourceInfo * getArg(unsigned I) const
Retrieve the Ith argument.
Definition: ExprCXX.h:2473
Represents a parameter to a function.
Definition: Decl.h:1535
bool isAssignmentOp() const
Definition: ExprCXX.h:116
CXXDefaultArgExpr(EmptyShell Empty)
Definition: ExprCXX.h:1108
bool hasQualifier() const
Evaluates true when this nested-name-specifier location is empty.
iterator begin() const
Definition: ExprCXX.h:4107
std::string getName(ArrayRef< StringRef > Parts) const
Get the platform-specific name separator.
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprCXX.h:1508
CoawaitExprBitfields CoawaitBits
Definition: Stmt.h:313
A C++ static_cast expression (C++ [expr.static.cast]).
Definition: ExprCXX.h:306
SourceLocation getLocEnd() const LLVM_READONLY
Definition: ExprCXX.h:4235
Expr * getExprOperand() const
Definition: ExprCXX.h:941
SourceLocation getEndLoc() const LLVM_READONLY
Definition: ExprCXX.h:957
SourceLocation getRParenLoc() const
Retrieve the location of the closing parenthesis.
Definition: ExprCXX.h:281
CXXConstructExpr(StmtClass SC, EmptyShell Empty)
Construct an empty C++ construction expression.
Definition: ExprCXX.h:1330
SourceLocation getLocEnd() const LLVM_READONLY
Definition: ExprCXX.h:2210
SourceLocation getLocEnd() const LLVM_READONLY
Definition: ExprCXX.h:871
SourceLocation getLocEnd() const LLVM_READONLY
Definition: ExprCXX.h:3931
TypeSourceInfo * getScopeTypeInfo() const
Retrieve the scope type in a qualified pseudo-destructor expression.
Definition: ExprCXX.h:2352
One of these records is kept for each identifier that is lexed.
Expr * GetTemporaryExpr() const
Retrieve the temporary-generating subexpression whose value will be materialized into a glvalue...
Definition: ExprCXX.h:4191
SourceLocation getTildeLoc() const
Retrieve the location of the &#39;~&#39;.
Definition: ExprCXX.h:2359
SourceLocation getLocEnd() const LLVM_READONLY
Definition: ExprCXX.h:4118
bool cleanupsHaveSideEffects() const
Definition: ExprCXX.h:3135
const Expr * getArg(unsigned Arg) const
Definition: ExprCXX.h:1422
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprCXX.h:3649
void setExprOperand(Expr *E)
Definition: ExprCXX.h:946
ExpressionTraitExpr(SourceLocation loc, ExpressionTrait et, Expr *queried, bool value, SourceLocation rparen, QualType resultType)
Definition: ExprCXX.h:2598
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition: ASTContext.h:150
A C++ nested-name-specifier augmented with source location information.
static bool classof(const Stmt *T)
Definition: ExprCXX.h:1142
LineState State
static bool classof(const Stmt *T)
Definition: ExprCXX.h:1577
SourceLocation getLocStart() const LLVM_READONLY
Definition: ExprCXX.h:2547
Represents a member of a struct/union/class.
Definition: Decl.h:2534
const FieldDecl * getField() const
Definition: ExprCXX.h:1185
SourceLocation getEndLoc() const LLVM_READONLY
Definition: ExprCXX.h:3978
llvm::iterator_range< const_arg_iterator > arg_const_range
Definition: ExprCXX.h:1399
Expr * getBase()
Retrieve the base object of this member expressions, e.g., the x in x.m.
Definition: ExprCXX.h:3607
static bool classof(const Stmt *T)
Definition: ExprCXX.h:3512
Defines the ExceptionSpecificationType enumeration and various utility functions. ...
SourceLocation getLocStart() const LLVM_READONLY
Definition: ExprCXX.h:3496
NonTypeTemplateParmDecl * getParameter() const
Definition: ExprCXX.h:3982
SourceLocation getBeginLoc() const
Definition: ExprCXX.h:532
const DeclarationNameInfo & getNameInfo() const
Gets the full name info.
Definition: ExprCXX.h:2740
llvm::iterator_range< const_arg_iterator > placement_arguments() const
Definition: ExprCXX.h:2092
SourceLocation getLocStart() const LLVM_READONLY
Definition: ExprCXX.h:3929
void setRequiresZeroInitialization(bool ZeroInit)
Definition: ExprCXX.h:1383
SourceLocation getEndLoc() const LLVM_READONLY
Definition: ExprCXX.h:650
void setArg(unsigned I, Expr *E)
Definition: ExprCXX.h:3267
SourceLocation getLocEnd() const LLVM_READONLY
Definition: ExprCXX.h:607
const CXXConstructExpr * getConstructExpr() const
Returns the CXXConstructExpr from this new-expression, or null.
Definition: ExprCXX.h:2068
const Expr * getCookedLiteral() const
Definition: ExprCXX.h:527
The iterator over UnresolvedSets.
Definition: UnresolvedSet.h:32
void copyTemplateArgumentsInto(TemplateArgumentListInfo &List) const
Copies the template arguments (if present) into the given structure.
Definition: ExprCXX.h:3035
Expr * getPlacementArg(unsigned i)
Definition: ExprCXX.h:2035
void copyTemplateArgumentsInto(TemplateArgumentListInfo &List) const
Copies the template arguments into the given structure.
Definition: ExprCXX.h:2802
bool isSpecificBuiltinType(unsigned K) const
Test for a particular builtin type.
Definition: Type.h:6307
Expr * getArg(unsigned I)
Definition: ExprCXX.h:3257
Represents a C++ member access expression for which lookup produced a set of overloaded functions...
Definition: ExprCXX.h:3539
SourceLocation getLocStart() const LLVM_READONLY
Definition: ExprCXX.h:1572
CXXScalarValueInitExpr(QualType Type, TypeSourceInfo *TypeInfo, SourceLocation rParenLoc)
Create an explicitly-written scalar-value initialization expression.
Definition: ExprCXX.h:1882
CXXInheritedCtorInitExpr(EmptyShell Empty)
Construct an empty C++ inheriting construction expression.
Definition: ExprCXX.h:1485
SourceLocation getEndLoc() const LLVM_READONLY
Definition: ExprCXX.h:3149
SourceLocation getLocStart() const LLVM_READONLY
Definition: ExprCXX.h:4307
static bool classof(const Stmt *T)
Definition: ExprCXX.h:3664
CXXUuidofExpr(QualType Ty, Expr *Operand, StringRef UuidStr, SourceRange R)
Definition: ExprCXX.h:910
Represents a reference to a non-type template parameter pack that has been substituted with a non-tem...
Definition: ExprCXX.h:4004
SourceLocation getLocStart() const LLVM_READONLY
Definition: ExprCXX.h:3648
LambdaCaptureDefault getCaptureDefault() const
Determine the default capture kind for this lambda.
Definition: ExprCXX.h:1720
ArrayRef< TemplateArgumentLoc > template_arguments() const
Definition: ExprCXX.h:2797
bool isGenericLambda() const
Whether this is a generic lambda.
Definition: ExprCXX.h:1837
bool hasExplicitTemplateArgs() const
Determines whether this lookup had explicit template arguments.
Definition: ExprCXX.h:3031
SourceLocation getLocEnd() const LLVM_READONLY
Definition: ExprCXX.h:1007
An r-value expression (a pr-value in the C++11 taxonomy) produces a temporary value.
Definition: Specifiers.h:110
SourceLocation getEndLoc() const LLVM_READONLY
Definition: ExprCXX.h:3506
void setDestroyedType(TypeSourceInfo *Info)
Set the destroyed type.
Definition: ExprCXX.h:2394
Expr * getLHS() const
Definition: ExprCXX.h:4287
const Expr *const * const_arg_iterator
Definition: ExprCXX.h:3250
SubstNonTypeTemplateParmExpr(QualType type, ExprValueKind valueKind, SourceLocation loc, NonTypeTemplateParmDecl *param, Expr *replacement)
Definition: ExprCXX.h:3963
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprCXX.h:1006
child_range children()
Definition: ExprCXX.h:585
SourceLocation getMemberLoc() const
Definition: ExprCXX.h:3436
A C++ typeid expression (C++ [expr.typeid]), which gets the type_info that corresponds to the supplie...
Definition: ExprCXX.h:671
child_range children()
Definition: ExprCXX.h:3816
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprCXX.h:3062
BinaryOperatorKind
Expr * getArraySize()
Definition: ExprCXX.h:2022
child_range children()
Definition: ExprCXX.h:966
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprCXX.h:3144
SourceLocation getLocStart() const LLVM_READONLY
Definition: ExprCXX.h:4041
MSPropertyRefExpr(Expr *baseExpr, MSPropertyDecl *decl, bool isArrow, QualType ty, ExprValueKind VK, NestedNameSpecifierLoc qualifierLoc, SourceLocation nameLoc)
Definition: ExprCXX.h:773
CXXThisExpr(SourceLocation L, QualType Type, bool isImplicit)
Definition: ExprCXX.h:991
unsigned getNumExpansions() const
Get the number of parameters in this parameter pack.
Definition: ExprCXX.h:4111
SourceLocation getLocStart() const LLVM_READONLY
Definition: ExprCXX.h:738
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprCXX.h:3804
SourceLocation getLocStart() const LLVM_READONLY
Definition: ExprCXX.h:3975
void setOperatorNew(FunctionDecl *D)
Definition: ExprCXX.h:2016
FunctionDecl * getOperatorDelete() const
Definition: ExprCXX.h:2197
void setLocation(SourceLocation L)
Definition: ExprCXX.h:611
bool isElidable() const
Whether this construction is elidable.
Definition: ExprCXX.h:1361
Expr * getOperand() const
Definition: ExprCXX.h:3721
static bool classof(const Stmt *T)
Definition: ExprCXX.h:2925
bool isGlobalNew() const
Definition: ExprCXX.h:2047
SourceLocation getParameterPackLocation() const
Retrieve the location of the parameter pack name.
Definition: ExprCXX.h:4035
A convenient class for passing around template argument information.
Definition: TemplateBase.h:552
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprCXX.h:1198
PseudoDestructorTypeStorage(IdentifierInfo *II, SourceLocation Loc)
Definition: ExprCXX.h:2235
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprCXX.h:1273
SourceLocation getLocation() const
Definition: ExprCXX.h:2248
bool doesUsualArrayDeleteWantSize() const
Answers whether the usual array deallocation function for the allocated type expects the size of the ...
Definition: ExprCXX.h:2193
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified...
SourceLocation getEndLoc() const LLVM_READONLY
Definition: ExprCXX.h:4311
capture_init_iterator capture_init_begin()
Retrieve the first initialization argument for this lambda expression (which initializes the first ca...
Definition: ExprCXX.h:1794
SourceLocation getLocStart() const LLVM_READONLY
Definition: ExprCXX.h:3272
Expr * getInitializer()
The initializer of this new-expression.
Definition: ExprCXX.h:2060
An x-value expression is a reference to an object with independent storage but which can be "moved"...
Definition: Specifiers.h:119
ExprValueKind getValueKind() const
getValueKind - The value kind that this expression produces.
Definition: Expr.h:405
SourceLocation getTemplateKeywordLoc() const
Retrieve the location of the template keyword preceding this name, if any.
Definition: ExprCXX.h:2759
SourceLocation getLocStart() const LLVM_READONLY
Definition: ExprCXX.h:605
static bool classof(const Stmt *T)
Definition: ExprCXX.h:3934
CXXFoldExpr(QualType T, SourceLocation LParenLoc, Expr *LHS, BinaryOperatorKind Opcode, SourceLocation EllipsisLoc, Expr *RHS, SourceLocation RParenLoc)
Definition: ExprCXX.h:4273
unsigned getNumTemplateArgs() const
Retrieve the number of template arguments provided as part of this template-id.
Definition: ExprCXX.h:3485
bool constructsVBase() const
Determine whether this constructor is actually constructing a base class (rather than a complete obje...
Definition: ExprCXX.h:1494
SourceLocation getThrowLoc() const
Definition: ExprCXX.h:1053
SourceLocation getEndLoc() const LLVM_READONLY
Definition: ExprCXX.h:4404
static bool classof(const Stmt *T)
Definition: ExprCXX.h:2624
SourceLocation getLocStart() const LLVM_READONLY
Definition: ExprCXX.h:3723
SourceLocation getRAngleLoc() const
Retrieve the location of the right angle bracket ending the explicit template argument list following...
Definition: ExprCXX.h:3454
Expr * getRHS() const
Definition: ExprCXX.h:4288
const CallExpr * getConfig() const
Definition: ExprCXX.h:218
bool isArrow() const
Definition: ExprCXX.h:818
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprCXX.h:4117
FPOptions getFPFeatures() const
Definition: ExprCXX.h:149
New-expression has a C++98 paren-delimited initializer.
Definition: ExprCXX.h:1970
bool hasUnparsedDefaultArg() const
Determines whether this parameter has a default argument that has not yet been parsed.
Definition: Decl.h:1645
SourceLocation getLocEnd() const LLVM_READONLY
Definition: ExprCXX.h:805
void setListInitialization(bool V)
Definition: ExprCXX.h:1371
const Expr * getArraySize() const
Definition: ExprCXX.h:2025
NestedNameSpecifier * getQualifier() const
Fetches the nested-name qualifier, if one was given.
Definition: ExprCXX.h:2749
CastExpr - Base class for type casts, including both implicit casts (ImplicitCastExpr) and explicit c...
Definition: Expr.h:2827
FieldDecl * getField()
Get the field whose initializer will be used.
Definition: ExprCXX.h:1184
CXXStdInitializerListExpr(QualType Ty, Expr *SubExpr)
Definition: ExprCXX.h:634
Expr * getOperand() const
Definition: ExprCXX.h:4480
SourceLocation getLocEnd() const LLVM_READONLY
Definition: ExprCXX.h:2402
SourceLocation getEndLoc() const LLVM_READONLY
Definition: ExprCXX.h:4236
Represents binding an expression to a temporary.
Definition: ExprCXX.h:1245
OpaqueValueExpr * getOpaqueValue() const
getOpaqueValue - Return the opaque value placeholder.
Definition: ExprCXX.h:4386
void setDestroyedType(IdentifierInfo *II, SourceLocation Loc)
Set the name of destroyed type for a dependent pseudo-destructor expression.
Definition: ExprCXX.h:2389
Expr * getCommonExpr() const
Definition: ExprCXX.h:4381
ArrayTypeTrait
Names for the array type traits.
Definition: TypeTraits.h:91
const internal::VariadicDynCastAllOfMatcher< Stmt, CastExpr > castExpr
Matches any cast nodes of Clang&#39;s AST.
CXXTemporary * getTemporary()
Definition: ExprCXX.h:1264
static bool classof(const Stmt *T)
Definition: ExprCXX.h:745
SourceLocation getLocStart() const LLVM_READONLY
Definition: ExprCXX.h:1005
A C++ lambda expression, which produces a function object (of unspecified type) that can be invoked l...
Definition: ExprCXX.h:1649
SourceLocation getLocEnd() const LLVM_READONLY
Definition: ExprCXX.h:4403
bool isTypeDependent() const
isTypeDependent - Determines whether this expression is type-dependent (C++ [temp.dep.expr]), which means that its type could change from one template instantiation to the next.
Definition: Expr.h:167
DeclarationName getDeclName() const
Retrieve the name that this expression refers to.
Definition: ExprCXX.h:2989
An ordinary object is located at an address in memory.
Definition: Specifiers.h:126
Represents a C++ member access expression where the actual member referenced could not be resolved be...
Definition: ExprCXX.h:3300
CXXBindTemporaryExpr(EmptyShell Empty)
Definition: ExprCXX.h:1258
StmtClass
Definition: Stmt.h:68
SourceLocation getNameLoc() const
Definition: ExprCXX.h:3974
TypeSourceInfo * getTypeSourceInfo() const
Definition: ExprCXX.h:1892
const_arg_iterator arg_begin() const
Definition: ExprCXX.h:1408
A default argument (C++ [dcl.fct.default]).
Definition: ExprCXX.h:1087
bool isTypeOperand() const
Definition: ExprCXX.h:924
void setSourceRange(SourceRange R)
Definition: ExprCXX.h:959
arg_iterator placement_arg_end()
Definition: ExprCXX.h:2099
Iterator for iterating over Stmt * arrays that contain only Expr *.
Definition: Stmt.h:345
CoyieldExpr(SourceLocation CoyieldLoc, Expr *Operand, Expr *Ready, Expr *Suspend, Expr *Resume, OpaqueValueExpr *OpaqueValue)
Definition: ExprCXX.h:4508
SourceLocation getMemberLoc() const
Definition: ExprCXX.h:3642
NamedDecl * getFirstQualifierFoundInScope() const
Retrieve the first part of the nested-name-specifier that was found in the scope of the member access...
Definition: ExprCXX.h:3420
Represents the this expression in C++.
Definition: ExprCXX.h:986
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprCXX.h:1858
arg_iterator arg_end()
Definition: Expr.h:2416
DeclarationName getMemberName() const
Retrieve the name of the member that this expression refers to.
Definition: ExprCXX.h:3638
New-expression has no initializer as written.
Definition: ExprCXX.h:1967
SourceLocation getRParenLoc() const
Retrieve the location of the right parentheses (&#39;)&#39;) that follows the argument list.
Definition: ExprCXX.h:3234
TypeSourceInfo * getAllocatedTypeSourceInfo() const
Definition: ExprCXX.h:1994
Represents an explicit template argument list in C++, e.g., the "<int>" in "sort<int>".
Definition: TemplateBase.h:644
TypeTrait
Names for traits that operate specifically on types.
Definition: TypeTraits.h:21
const Expr * getExpr() const
Get the initialization expression that will be used.
Definition: ExprCXX.h:1188
TypeSourceInfo * getQueriedTypeSourceInfo() const
Definition: ExprCXX.h:2556
arg_const_range arguments() const
Definition: ExprCXX.h:1402
bool isArrayForm() const
Definition: ExprCXX.h:2186
bool isRightFold() const
Does this produce a right-associated sequence of operators?
Definition: ExprCXX.h:4291
UserDefinedLiteral(const ASTContext &C, EmptyShell Empty)
Definition: ExprCXX.h:495
CXXScalarValueInitExpr(EmptyShell Shell)
Definition: ExprCXX.h:1889
Const iterator for iterating over Stmt * arrays that contain only Expr *.
Definition: Stmt.h:359
const ValueDecl * getExtendingDecl() const
Get the declaration which triggered the lifetime-extension of this temporary, if any.
Definition: ExprCXX.h:4213
TypeSourceInfo * getTypeSourceInfo() const
Definition: ExprCXX.h:1616
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprCXX.h:3930
bool isStdInitListInitialization() const
Whether this constructor call was written as list-initialization, but was interpreted as forming a st...
Definition: ExprCXX.h:1377
Represents a C++ pseudo-destructor (C++ [expr.pseudo]).
Definition: ExprCXX.h:2275
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprCXX.h:955
ASTTemplateKWAndArgsInfo * getTrailingASTTemplateKWAndArgsInfo()
Return the optional template keyword and arguments info.
Definition: ExprCXX.h:3677
CompoundStmt - This represents a group of statements like { stmt stmt }.
Definition: Stmt.h:616
void setFPFeatures(FPOptions F)
Definition: ExprCXX.h:147
unsigned NumTemplateArgs
The number of template arguments in TemplateArgs.
Definition: TemplateBase.h:658
static bool classof(const Stmt *T)
Definition: ExprCXX.h:613
QualType getQueriedType() const
Definition: ExprCXX.h:2554
CXXTypeidExpr(QualType Ty, TypeSourceInfo *Operand, SourceRange R)
Definition: ExprCXX.h:677
CXXConstructorDecl * getConstructor() const
Get the constructor that this expression will (ultimately) call.
Definition: ExprCXX.h:1355
ArrayTypeTraitExpr(EmptyShell Empty)
Definition: ExprCXX.h:2542
CastKind
CastKind - The kind of operation required for a conversion.
SourceLocation getLocStart() const LLVM_READONLY
Definition: ExprCXX.h:4488
const TemplateArgumentLoc * getTemplateArgs() const
Retrieve the template arguments provided as part of this template-id.
Definition: ExprCXX.h:3476
static bool classof(const Stmt *T)
Definition: ExprCXX.h:337
CXXTypeidExpr(QualType Ty, Expr *Operand, SourceRange R)
Definition: ExprCXX.h:688
Stmt * getPreArg(unsigned i)
Definition: Expr.h:2334
static bool classof(const Stmt *T)
Definition: ExprCXX.h:812
arg_iterator arg_end()
Definition: ExprCXX.h:1407
SourceLocation getLocation() const
Definition: ExprCXX.h:1357
SourceLocation getRBracketLoc() const
Definition: ExprCXX.h:874
SourceLocation getLocStart() const LLVM_READONLY
Definition: ExprCXX.h:644
ArrayRef< TypeSourceInfo * > getArgs() const
Retrieve the argument types.
Definition: ExprCXX.h:2479
static CXXDefaultArgExpr * Create(const ASTContext &C, SourceLocation Loc, ParmVarDecl *Param)
Definition: ExprCXX.h:1112
SourceLocation getEndLoc() const LLVM_READONLY
Definition: ExprCXX.h:3809
SourceLocation getLocEnd() const LLVM_READONLY
Definition: ExprCXX.h:4310
SourceLocation getLocEnd() const LLVM_READONLY
Definition: ExprCXX.h:1620
SourceLocation getLocStart() const LLVM_READONLY
Definition: ExprCXX.h:1618
SourceLocation getLocEnd() const LLVM_READONLY
Definition: ExprCXX.h:1065
SourceLocation getDestroyedTypeLoc() const
Retrieve the starting location of the type being destroyed.
Definition: ExprCXX.h:2383
void setOperatorDelete(FunctionDecl *D)
Definition: ExprCXX.h:2018
An expression "T()" which creates a value-initialized rvalue of type T, which is a non-class type...
Definition: ExprCXX.h:1873
SourceLocation getOperatorLoc() const
Retrieve the location of the &#39;->&#39; or &#39;.&#39; operator.
Definition: ExprCXX.h:3627
SourceLocation getEndLoc() const LLVM_READONLY
Definition: ExprCXX.h:1901
SourceLocation getLocEnd() const LLVM_READONLY
Definition: ExprCXX.h:956
SourceRange getSourceRange() const LLVM_READONLY
Retrieve the source range of the expression.
Definition: ExprCXX.h:655
Pepresents a block literal declaration, which is like an unnamed FunctionDecl.
Definition: Decl.h:3860
static bool classof(const Stmt *T)
Definition: ExprCXX.h:580
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
Definition: Decl.h:637
Expr - This represents one expression.
Definition: Expr.h:106
Defines the clang::LangOptions interface.
SourceLocation getLocStart() const LLVM_READONLY
Definition: ExprCXX.h:1433
static bool classof(const Stmt *T)
Definition: ExprCXX.h:4412
SourceLocation getLocEnd() const LLVM_READONLY
Definition: ExprCXX.h:649
void setIsImplicit(bool value=true)
Definition: ExprCXX.h:4446
SourceLocation End
SourceLocation getLocStart() const LLVM_READONLY
Definition: ExprCXX.h:283
ExprValueKind
The categorization of expression values, currently following the C++11 scheme.
Definition: Specifiers.h:107
SourceLocation getCaptureDefaultLoc() const
Retrieve the location of this lambda&#39;s capture-default, if any.
Definition: ExprCXX.h:1725
TemplateArgumentLoc const * getTemplateArgs() const
Definition: ExprCXX.h:2784
SourceLocation getLocEnd() const LLVM_READONLY
Definition: ExprCXX.h:3657
bool isArrow() const
Determine whether this member expression used the &#39;->&#39; operator; otherwise, it used the &#39;...
Definition: ExprCXX.h:3624
SourceLocation getLocStart() const LLVM_READONLY
Definition: ExprCXX.h:531
ParmVarDecl * getParam()
Definition: ExprCXX.h:1119
child_range children()
Definition: ExprCXX.h:2220
static FindResult find(Expr *E)
Finds the overloaded expression in the given expression E of OverloadTy.
Definition: ExprCXX.h:2700
unsigned getPackLength() const
Retrieve the length of the parameter pack.
Definition: ExprCXX.h:3907
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprCXX.h:4231
Represents a C++ functional cast expression that builds a temporary object.
Definition: ExprCXX.h:1597
SourceLocation getBeginLoc() const
Retrieve the location of the beginning of this nested-name-specifier.
A C++ const_cast expression (C++ [expr.const.cast]).
Definition: ExprCXX.h:439
SourceLocation getExprLoc() const LLVM_READONLY
Definition: ExprCXX.h:191
SourceLocation getLocation() const
Definition: ExprCXX.h:1002
void setTypeOperandSourceInfo(TypeSourceInfo *TSI)
Definition: ExprCXX.h:936
Represents a C++ destructor within a class.
Definition: DeclCXX.h:2700
const internal::VariadicAllOfMatcher< Decl > decl
Matches declarations.
IdentifierInfo * getDestroyedTypeIdentifier() const
In a dependent pseudo-destructor expression for which we do not have full type information on the des...
Definition: ExprCXX.h:2375
Defines an enumeration for C++ overloaded operators.
friend TrailingObjects
Definition: ExprCXX.h:1704
const Expr * getCallee() const
Definition: Expr.h:2356
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprCXX.h:867
raw_arg_iterator raw_arg_end()
Definition: ExprCXX.h:2112
bool isArrow() const
Determine whether this pseudo-destructor expression was written using an &#39;->&#39; (otherwise, it used a &#39;.
Definition: ExprCXX.h:2338
void setUuidStr(StringRef US)
Definition: ExprCXX.h:951
unsigned getNumTemplateArgs() const
Definition: ExprCXX.h:2790
arg_range arguments()
Definition: ExprCXX.h:1401
DeclContext * getDeclContext()
Definition: DeclBase.h:428
SourceLocation Begin
void copyTemplateArgumentsInto(TemplateArgumentListInfo &List) const
Copies the template arguments (if present) into the given structure.
Definition: ExprCXX.h:3468
static bool classof(const Stmt *T)
Definition: ExprCXX.h:2405
Represents an expression that computes the length of a parameter pack.
Definition: ExprCXX.h:3830
llvm::iterator_range< const_capture_init_iterator > capture_inits() const
Retrieve the initialization expressions for this lambda&#39;s captures.
Definition: ExprCXX.h:1788
static bool classof(const Stmt *T)
Definition: ExprCXX.h:961
NonTypeTemplateParmDecl - Declares a non-type template parameter, e.g., "Size" in.
ArrayTypeTraitExpr(SourceLocation loc, ArrayTypeTrait att, TypeSourceInfo *queried, uint64_t value, Expr *dimension, SourceLocation rparen, QualType ty)
Definition: ExprCXX.h:2531
static bool classof(const Stmt *s)
Definition: ExprCXX.h:3984
ArrayTypeTrait getTrait() const
Definition: ExprCXX.h:2552
decls_iterator decls_begin() const
Definition: ExprCXX.h:2728
static bool classof(const Stmt *T)
Definition: ExprCXX.h:199
SourceLocation getLocStart() const LLVM_READONLY
Definition: ExprCXX.h:1857
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprCXX.h:3724
ExprWithCleanupsBitfields ExprWithCleanupsBits
Definition: Stmt.h:307
SourceRange getAngleBrackets() const LLVM_READONLY
Definition: ExprCXX.h:287
const Expr * getIdx() const
Definition: ExprCXX.h:864
QualType getType() const
Definition: Expr.h:128
bool isFunctionOrMethod() const
Definition: DeclBase.h:1392
SourceLocation getLocation() const
Retrieve the location of the name within the expression.
Definition: ExprCXX.h:2994
const Expr * getInitializer() const
Definition: ExprCXX.h:2063
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprCXX.h:136
SourceLocation getExprLoc() const LLVM_READONLY
Definition: ExprCXX.h:128
static OMPLinearClause * CreateEmpty(const ASTContext &C, unsigned NumVars)
Creates an empty clause with the place for NumVars variables.
Expr * getPattern() const
Get the pattern, that is, the operand that contains an unexpanded pack.
Definition: ExprCXX.h:4299
static bool classof(const Stmt *T)
Definition: ExprCXX.h:141
CXXConstructExpr::ConstructionKind getConstructionKind() const
Definition: ExprCXX.h:1495
bool hasInitializer() const
Whether this new-expression has any initializer at all.
Definition: ExprCXX.h:2050
StorageDuration getStorageDuration() const
Retrieve the storage duration for the materialized temporary.
Definition: ExprCXX.h:4194
Represents a folding of a pack over an operator.
Definition: ExprCXX.h:4262
static bool classof(const Stmt *T)
Definition: ExprCXX.h:1072
SourceLocation getEndLoc() const LLVM_READONLY
Definition: ExprCXX.h:2211
const Expr * getBase() const
Definition: ExprCXX.h:861
SourceLocation getEnd() const
SourceLocation getEndLoc() const LLVM_READONLY
Definition: ExprCXX.h:2616
SourceLocation getLocEnd() const LLVM_READONLY
Definition: ExprCXX.h:4043
A member reference to an MSPropertyDecl.
Definition: ExprCXX.h:763
StmtIterator child_iterator
Child Iterators: All subclasses must implement &#39;children&#39; to permit easy iteration over the substatem...
Definition: Stmt.h:455
Represents a reference to a non-type template parameter that has been substituted with a template arg...
Definition: ExprCXX.h:3946
CXXMemberCallExpr(ASTContext &C, EmptyShell Empty)
Definition: ExprCXX.h:172
The result type of a method or function.
ParmVarDecl *const * iterator
Iterators over the parameters which the parameter pack expanded into.
Definition: ExprCXX.h:4106
SourceRange getSourceRange() const LLVM_READONLY
Definition: ExprCXX.h:958
const Expr * getSubExpr() const
Definition: ExprCXX.h:1268
SourceLocation getPackLoc() const
Determine the location of the parameter pack.
Definition: ExprCXX.h:3895
MSPropertyRefExpr(EmptyShell Empty)
Definition: ExprCXX.h:785
const Expr *const * getArgs() const
Definition: ExprCXX.h:1412
CoyieldExpr(EmptyShell Empty)
Definition: ExprCXX.h:4514
SourceLocation getLocStart() const LLVM_READONLY
Definition: ExprCXX.h:135
DependentCoawaitExpr(SourceLocation KeywordLoc, QualType Ty, Expr *Op, UnresolvedLookupExpr *OpCoawait)
Definition: ExprCXX.h:4462
bool getValue() const
Definition: ExprCXX.h:569
SourceLocation getEndLoc() const LLVM_READONLY
Definition: ExprCXX.h:1863
CXXNewExpr(EmptyShell Shell)
Definition: ExprCXX.h:1983
MSPropertySubscriptExpr(Expr *Base, Expr *Idx, QualType Ty, ExprValueKind VK, ExprObjectKind OK, SourceLocation RBracketLoc)
Definition: ExprCXX.h:846
SourceRange getSourceRange() const
Definition: ExprCXX.h:139
static bool classof(const Stmt *T)
Definition: ExprCXX.h:467
ExprObjectKind getObjectKind() const
getObjectKind - The object kind that this expression produces.
Definition: Expr.h:412
static bool classof(const Stmt *T)
Definition: ExprCXX.h:1013
SourceLocation getOperatorLoc() const
Retrieve the location of the &#39;->&#39; or &#39;.&#39; operator.
Definition: ExprCXX.h:3397
void setTypeOperandSourceInfo(TypeSourceInfo *TSI)
Definition: ExprCXX.h:723
const Expr * getArgument() const
Definition: ExprCXX.h:2200
child_range children()
Definition: ExprCXX.h:3736
SourceLocation getLParenLoc() const
Retrieve the location of the left parentheses (&#39;(&#39;) that precedes the argument list.
Definition: ExprCXX.h:3229
NestedNameSpecifier * getQualifier() const
Retrieve the nested-name-specifier that qualifies the member name.
Definition: ExprCXX.h:3401
SourceLocation getOperatorLoc() const
Returns the location of the operator symbol in the expression.
Definition: ExprCXX.h:126
static bool classof(const Stmt *T)
Definition: ExprCXX.h:1903
Expr * getSubExpr()
Definition: ExprCXX.h:1051
const DeclarationNameInfo & getNameInfo() const
Retrieve the name that this expression refers to.
Definition: ExprCXX.h:2986
SourceRange getSourceRange() const LLVM_READONLY
Definition: ExprCXX.h:787
static bool classof(const Stmt *S)
Definition: ExprCXX.h:550
Expr * getArgument()
Definition: ExprCXX.h:2199
const Expr * getBase() const
Definition: ExprCXX.h:3611
void copyInto(const TemplateArgumentLoc *ArgArray, TemplateArgumentListInfo &List) const
CanThrowResult
Possible results from evaluation of a noexcept expression.
void setLParenLoc(SourceLocation L)
Definition: ExprCXX.h:1565
bool getValue() const
Definition: ExprCXX.h:3729
A C++ dynamic_cast expression (C++ [expr.dynamic.cast]).
Definition: ExprCXX.h:347
OpaqueValueExpr - An expression referring to an opaque object of a fixed type and value class...
Definition: Expr.h:875
UnresolvedSetIterator iterator
Definition: UnresolvedSet.h:80
SourceLocation getLocEnd() const LLVM_READONLY
Definition: ExprCXX.h:3725
MaterializeTemporaryExpr(EmptyShell Empty)
Definition: ExprCXX.h:4181
SourceLocation getEndLoc() const LLVM_READONLY
Definition: ExprCXX.h:575
llvm::iterator_range< arg_iterator > arg_range
Definition: ExprCXX.h:1398
#define false
Definition: stdbool.h:33
Kind
child_range children()
Definition: ExprCXX.h:3669
A reference to an overloaded function set, either an UnresolvedLookupExpr or an UnresolvedMemberExpr...
Definition: ExprCXX.h:2636
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprCXX.h:573
Expr * getInit() const
Get the operand that doesn&#39;t contain a pack, for a binary fold.
Definition: ExprCXX.h:4302
Represents a call to an inherited base class constructor from an inheriting constructor.
Definition: ExprCXX.h:1455
operator "" X (const CharT *, size_t)
Definition: ExprCXX.h:513
ExpressionTrait getTrait() const
Definition: ExprCXX.h:2618
Expr ** getPlacementArgs()
Definition: ExprCXX.h:2031
static bool classof(const Stmt *T)
Definition: ExprCXX.h:1283
bool isInstantiationDependent() const
Whether this expression is instantiation-dependent, meaning that it depends in some way on a template...
Definition: Expr.h:191
SourceLocation getLocEnd() const LLVM_READONLY
Definition: ExprCXX.h:1277
void setElidable(bool E)
Definition: ExprCXX.h:1362
SourceLocation getLocStart() const LLVM_READONLY
Definition: ExprCXX.h:2613
Raw form: operator "" X<cs...> ()
Definition: ExprCXX.h:504
SourceLocation getNameLoc() const
Gets the location of the name.
Definition: ExprCXX.h:2746
bool inheritedFromVBase() const
Determine whether the inherited constructor is inherited from a virtual base of the object we constru...
Definition: ExprCXX.h:1504
void setHadMultipleCandidates(bool V)
Definition: ExprCXX.h:1367
Encodes a location in the source.
child_range children()
Definition: ExprCXX.h:750
SourceLocation getEndLoc() const LLVM_READONLY
Definition: ExprCXX.h:2550
const_arg_iterator placement_arg_begin() const
Definition: ExprCXX.h:2102
SourceLocation getLocEnd() const LLVM_READONLY
Definition: ExprCXX.h:740
Defines enumerations for expression traits intrinsics.
static bool classof(const Stmt *T)
Definition: ExprCXX.h:4046
CXXNamedCastExpr(StmtClass SC, QualType ty, ExprValueKind VK, CastKind kind, Expr *op, unsigned PathSize, TypeSourceInfo *writtenTy, SourceLocation l, SourceLocation RParenLoc, SourceRange AngleBrackets)
Definition: ExprCXX.h:262
Represents a C++ temporary.
Definition: ExprCXX.h:1213
bool hasExplicitTemplateArgs() const
Determines whether this member expression actually had a C++ template argument list explicitly specif...
Definition: ExprCXX.h:3464
SourceLocation getEndLoc() const LLVM_READONLY
Definition: ExprCXX.h:138
SourceLocation getRAngleLoc() const
Retrieve the location of the right angle bracket ending the explicit template argument list following...
Definition: ExprCXX.h:3022
SourceLocation getLocEnd() const LLVM_READONLY
Definition: ExprCXX.h:3977
NestedNameSpecifierLoc getQualifierLoc() const
Retrieves the nested-name-specifier that qualifies the type name, with source-location information...
Definition: ExprCXX.h:2327
SourceLocation getEndLoc() const LLVM_READONLY
Definition: ExprCXX.h:4044
bool hasUnresolvedUsing() const
Determine whether the lookup results contain an unresolved using declaration.
Definition: ExprCXX.h:3620
bool hasQualifier() const
Determines whether this member expression actually had a C++ nested-name-specifier prior to the name ...
Definition: ExprCXX.h:2323
PackExpansionExpr(EmptyShell Empty)
Definition: ExprCXX.h:3782
SourceLocation getOperatorLoc() const
Retrieve the location of the cast operator keyword, e.g., static_cast.
Definition: ExprCXX.h:278
Represents a new-expression for memory allocation and constructor calls, e.g: "new CXXNewExpr(foo)"...
Definition: ExprCXX.h:1915
SourceLocation getBeginLoc() const
Definition: ExprCXX.h:2121
DeclarationName getName() const
getName - Returns the embedded declaration name.
A call to a literal operator (C++11 [over.literal]) written as a user-defined literal (C++11 [lit...
Definition: ExprCXX.h:481
child_range children()
Definition: ExprCXX.h:1865
void setSourceRange(SourceRange R)
Definition: ExprCXX.h:743
SourceLocation getEllipsisLoc() const
Retrieve the location of the ellipsis that describes this pack expansion.
Definition: ExprCXX.h:3792
Represents a call to a member function that may be written either with member call syntax (e...
Definition: ExprCXX.h:166
llvm::iterator_range< capture_init_iterator > capture_inits()
Retrieve the initialization expressions for this lambda&#39;s captures.
Definition: ExprCXX.h:1783
SourceLocation getLocStart() const LLVM_READONLY
Definition: Stmt.h:401
static bool classof(const Stmt *T)
Definition: ExprCXX.h:881
Defines several types used to describe C++ lambda expressions that are shared between the parser and ...
SourceLocation getEndLoc() const LLVM_READONLY
Definition: ExprCXX.h:2487
SourceLocation getEndLoc() const LLVM_READONLY
Definition: ExprCXX.h:286
Expr * getInClassInitializer() const
Get the C++11 default member initializer for this member, or null if one has not been set...
Definition: Decl.h:2676
ExprObjectKind
A further classification of the kind of object referenced by an l-value or x-value.
Definition: Specifiers.h:124
SourceLocation getLocStart() const LLVM_READONLY
Definition: ExprCXX.h:2208
Represents a static or instance method of a struct/union/class.
Definition: DeclCXX.h:2045
void setTemporary(CXXTemporary *T)
Definition: ExprCXX.h:1266
static bool classof(const Stmt *T)
Definition: ExprCXX.h:4522
static bool classof(const Stmt *T)
Definition: ExprCXX.h:4121
SourceLocation getEndLoc() const
Definition: ExprCXX.h:806
SourceLocation RAngleLoc
The source location of the right angle bracket (&#39;>&#39;).
Definition: TemplateBase.h:649
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
SourceLocation getEndLoc() const LLVM_READONLY
Definition: ExprCXX.h:3276
bool isFPContractableWithinStatement() const
Definition: ExprCXX.h:153
void setDestructor(const CXXDestructorDecl *Dtor)
Definition: ExprCXX.h:1226
QualType getAllocatedType() const
Definition: ExprCXX.h:1989
child_range children()
Definition: ExprCXX.h:2494
bool isBoundToLvalueReference() const
Determine whether this materialized temporary is bound to an lvalue reference; otherwise, it&#39;s bound to an rvalue reference.
Definition: ExprCXX.h:4226
Expr * getSuspendExpr() const
Definition: ExprCXX.h:4392
void setConfig(CallExpr *E)
Sets the kernel configuration expression.
Definition: ExprCXX.h:227
CUDAKernelCallExpr(ASTContext &C, Expr *fn, CallExpr *Config, ArrayRef< Expr *> args, QualType t, ExprValueKind VK, SourceLocation RP)
Definition: ExprCXX.h:210
unsigned capture_size() const
Determine the number of captures in this lambda.
Definition: ExprCXX.h:1750
bool isArray() const
Definition: ExprCXX.h:2020
static bool classof(const Stmt *T)
Definition: ExprCXX.h:1440
const_capture_init_iterator capture_init_end() const
Retrieve the iterator pointing one past the last initialization argument for this lambda expression...
Definition: ExprCXX.h:1812
bool isValueDependent() const
isValueDependent - Determines whether this expression is value-dependent (C++ [temp.dep.constexpr]).
Definition: Expr.h:149
child_range children()
Definition: ExprCXX.h:1207
SourceLocation getEndLoc() const LLVM_READONLY
Definition: ExprCXX.h:2915
CXXNamedCastExpr(StmtClass SC, EmptyShell Shell, unsigned PathSize)
Definition: ExprCXX.h:270
static CXXDefaultInitExpr * Create(const ASTContext &C, SourceLocation Loc, FieldDecl *Field)
Field is the non-static data member whose default initializer is used by this expression.
Definition: ExprCXX.h:1178
SourceLocation getLocEnd() const LLVM_READONLY
Definition: ExprCXX.h:2486
bool hasTemplateKeyword() const
Determines whether the member name was preceded by the template keyword.
Definition: ExprCXX.h:3460
SourceLocation getLocEnd() const LLVM_READONLY
Definition: Stmt.h:403
void setSubExpr(Expr *E)
Definition: ExprCXX.h:1270
OverloadExpr(StmtClass K, EmptyShell Empty)
Definition: ExprCXX.h:2666
bool isParenTypeId() const
Definition: ExprCXX.h:2044
bool isInfixBinaryOp() const
Is this written as an infix binary operator?
Definition: ExprCXX.cpp:46
bool isImplicitAccess() const
Definition: ExprCXX.h:791
An expression trait intrinsic.
Definition: ExprCXX.h:2579
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprCXX.h:739
CXXOperatorCallExpr(ASTContext &C, EmptyShell Empty)
Definition: ExprCXX.h:101
SourceLocation getLocStart() const LLVM_READONLY
Definition: ExprCXX.h:3143
ArrayRef< TemplateArgumentLoc > template_arguments() const
Definition: ExprCXX.h:3492
CoyieldExpr(SourceLocation CoyieldLoc, QualType Ty, Expr *Operand)
Definition: ExprCXX.h:4512
ParmVarDecl * getExpansion(unsigned I) const
Get an expansion of the parameter pack by index.
Definition: ExprCXX.h:4114
child_range children()
Definition: ExprCXX.h:1018
bool passAlignment() const
Indicates whether the required alignment should be implicitly passed to the allocation function...
Definition: ExprCXX.h:2074
FunctionDecl * getOperatorDelete() const
Definition: ExprCXX.h:2017
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprCXX.h:2614
SourceLocation getTemplateKeywordLoc() const
Retrieve the location of the template keyword preceding this name, if any.
Definition: ExprCXX.h:3008
A placeholder type used to construct an empty shell of a type, that will be filled in later (e...
Definition: Stmt.h:338
SourceLocation getExprLoc() const LLVM_READONLY
getExprLoc - Return the preferred location for the arrow when diagnosing a problem with a generic exp...
Definition: Expr.cpp:216
PackExpansionExpr(QualType T, Expr *Pattern, SourceLocation EllipsisLoc, Optional< unsigned > NumExpansions)
Definition: ExprCXX.h:3772
A qualified reference to a name whose declaration cannot yet be resolved.
Definition: ExprCXX.h:2944
void setRBracketLoc(SourceLocation L)
Definition: ExprCXX.h:875
SourceLocation getLocEnd() const LLVM_READONLY
Definition: ExprCXX.h:285
InitializationStyle getInitializationStyle() const
The kind of initializer this new-expression has.
Definition: ExprCXX.h:2053
SourceLocation getLocation() const LLVM_READONLY
Definition: ExprCXX.h:1506
Defines various enumerations that describe declaration and type specifiers.
A POD class for pairing a NamedDecl* with an access specifier.
SourceLocation getLocEnd() const LLVM_READONLY
Definition: ExprCXX.h:2131
ArrayRef< TemplateArgument > getPartialArguments() const
Get.
Definition: ExprCXX.h:3923
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprCXX.h:2908
SourceLocation getLocStart() const LLVM_READONLY
Definition: ExprCXX.h:572
Represents a reference to a function parameter pack that has been substituted but not yet expanded...
Definition: ExprCXX.h:4070
Represents a template argument.
Definition: TemplateBase.h:51
unsigned getManglingNumber() const
Definition: ExprCXX.h:4220
SourceLocation getMemberLoc() const
Definition: ExprCXX.h:819
TypeSourceInfo * getDestroyedTypeInfo() const
Retrieve the source location information for the type being destroyed.
Definition: ExprCXX.h:2368
SourceLocation getEndLoc() const LLVM_READONLY
Definition: ExprCXX.h:1510
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprCXX.h:2209
bool isTypeOperand() const
Definition: ExprCXX.h:711
CXXTemporaryObjectExpr(EmptyShell Empty)
Definition: ExprCXX.h:1613
SourceLocation getLocation() const
Definition: ExprCXX.h:577
static bool classof(const Stmt *T)
Definition: ExprCXX.h:3811
Dataflow Directional Tag Classes.
SourceLocation getLocStart() const LLVM_READONLY
Definition: ExprCXX.h:1062
NestedNameSpecifier * getNestedNameSpecifier() const
Retrieve the nested-name-specifier to which this instance refers.
SourceLocation getLocStart() const LLVM_READONLY
Definition: ExprCXX.h:1898
bool isValid() const
Return true if this is a valid SourceLocation object.
SourceLocation getLocEnd() const LLVM_READONLY
Definition: ExprCXX.h:574
CallExpr * getConfig()
Definition: ExprCXX.h:221
void setValue(bool V)
Definition: ExprCXX.h:570
Represents a delete expression for memory deallocation and destructor calls, e.g. ...
Definition: ExprCXX.h:2145
CXXMemberCallExpr(ASTContext &C, Expr *fn, ArrayRef< Expr *> args, QualType t, ExprValueKind VK, SourceLocation RP)
Definition: ExprCXX.h:168
SourceLocation getLocEnd() const LLVM_READONLY
Definition: ExprCXX.h:3275
static bool classof(const Stmt *T)
Definition: ExprCXX.h:2215
OverloadedOperatorKind getOperator() const
Returns the kind of overloaded operator that this expression refers to.
Definition: ExprCXX.h:106
OverloadedOperatorKind
Enumeration specifying the different kinds of C++ overloaded operators.
Definition: OperatorKinds.h:22
NonTypeTemplateParmDecl * getParameterPack() const
Retrieve the non-type template parameter pack being substituted.
Definition: ExprCXX.h:4032
const_arg_iterator arg_end() const
Definition: ExprCXX.h:1409
MSPropertyDecl * getPropertyDecl() const
Definition: ExprCXX.h:817
CXXNoexceptExpr(EmptyShell Empty)
Definition: ExprCXX.h:3719
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprCXX.h:4489
bool isImplicit() const
Definition: ExprCXX.h:1010
CXXFoldExpr(EmptyShell Empty)
Definition: ExprCXX.h:4285
Reads an AST files chain containing the contents of a translation unit.
Definition: ASTReader.h:354
SourceLocation getLocStart() const LLVM_READONLY
Definition: ExprCXX.h:2907
BinaryOperator::Opcode getOpcode(const SymExpr *SE)
const Expr * getPattern() const
Retrieve the pattern of the pack expansion.
Definition: ExprCXX.h:3788
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprCXX.h:4042
TypeSourceInfo * getTypeSourceInfo() const
Retrieve the type source information for the type being constructed.
Definition: ExprCXX.h:3225
A C++ reinterpret_cast expression (C++ [expr.reinterpret.cast]).
Definition: ExprCXX.h:394
CXXNoexceptExpr(QualType Ty, Expr *Operand, CanThrowResult Val, SourceLocation Keyword, SourceLocation RParen)
Definition: ExprCXX.h:3710
TypeSourceInfo * getTypeSourceInfo() const
Definition: ExprCXX.h:2240
SourceLocation getLocEnd() const LLVM_READONLY
Definition: ExprCXX.h:1137
Represents a &#39;co_yield&#39; expression.
Definition: ExprCXX.h:4504
void setConstructionKind(ConstructionKind CK)
Definition: ExprCXX.h:1392
DeclarationName getMember() const
Retrieve the name of the member that this expression refers to.
Definition: ExprCXX.h:3432
DeclarationName - The name of a declaration.
StmtClass getStmtClass() const
Definition: Stmt.h:391
Expr * getDefaultArg()
Definition: Decl.cpp:2539
SourceRange getIntroducerRange() const
Retrieve the source range covering the lambda introducer, which contains the explicit capture list su...
Definition: ExprCXX.h:1819
const Expr * getExpr() const
Definition: ExprCXX.h:1122
SourceLocation getEndLoc() const LLVM_READONLY
Definition: ExprCXX.h:4119
Represents a C++11 pack expansion that produces a sequence of expressions.
Definition: ExprCXX.h:3756
bool isListInitialization() const
Whether this constructor call was written as list-initialization.
Definition: ExprCXX.h:1370
static bool classof(const Stmt *T)
Definition: ExprCXX.h:2562
bool isImplicit() const
Definition: ExprCXX.h:4445
SourceLocation getLocEnd() const LLVM_READONLY
Definition: ExprCXX.h:1862
SourceLocation getLocEnd() const LLVM_READONLY
Definition: ExprCXX.h:2914
SourceLocation getLocEnd() const LLVM_READONLY
Definition: ExprCXX.h:3066
void setInstantiationDependent(bool ID)
Set whether this expression is instantiation-dependent or not.
Definition: Expr.h:196
llvm::iterator_range< const_arg_iterator > arg_const_range
Definition: Expr.h:2408
child_range children()
Definition: ExprCXX.h:2629
SourceLocation getParameterPackLocation() const
Get the location of the parameter pack.
Definition: ExprCXX.h:4102
child_range children()
Definition: ExprCXX.h:617
CXXNullPtrLiteralExpr(QualType Ty, SourceLocation l)
Definition: ExprCXX.h:597
NestedNameSpecifierLoc getQualifierLoc() const
Definition: ExprCXX.h:820
ExplicitCastExpr - An explicit cast written in the source code.
Definition: Expr.h:3039
const DeclarationNameInfo & getMemberNameInfo() const
Retrieve the full name info for the member that this expression refers to.
Definition: ExprCXX.h:3634
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspnd...
child_range children()
Definition: ExprCXX.h:4408
void setImplicit(bool I)
Definition: ExprCXX.h:1011
CXXNullPtrLiteralExpr(EmptyShell Empty)
Definition: ExprCXX.h:602
SourceLocation getLocEnd() const LLVM_READONLY
Definition: ExprCXX.h:1509
const Expr * Replacement
Definition: ParsedAttr.h:67
const_arg_iterator arg_begin() const
Definition: ExprCXX.h:3252
TypeSourceInfo * getTypeOperandSourceInfo() const
Retrieve source information for the type operand.
Definition: ExprCXX.h:718
CXXRecordDecl * getNamingClass() const
Gets the &#39;naming class&#39; (in the sense of C++0x [class.access.base]p5) of the lookup.
Definition: ExprCXX.h:2905
iterator end() const
Definition: ExprCXX.h:4108
Represents a C++11 noexcept expression (C++ [expr.unary.noexcept]).
Definition: ExprCXX.h:3702
SourceLocation getColonColonLoc() const
Retrieve the location of the &#39;::&#39; in a qualified pseudo-destructor expression.
Definition: ExprCXX.h:2356
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier that qualifies the name, with source location information.
Definition: ExprCXX.h:2998
TemplateArgumentLoc * getTrailingTemplateArgumentLoc()
Return the optional template arguments.
Definition: ExprCXX.h:3689
Location wrapper for a TemplateArgument.
Definition: TemplateBase.h:450
bool hasTemplateKeyword() const
Determines whether the name was preceded by the template keyword.
Definition: ExprCXX.h:2779
SourceLocation getLocEnd() const LLVM_READONLY
Definition: ExprCXX.h:2615
SourceLocation getExprLoc() const LLVM_READONLY
Definition: ExprCXX.h:3646
static bool classof(const Stmt *T)
Definition: ExprCXX.h:1202
child_range children()
Definition: ExprCXX.h:4318
SourceLocation getLocEnd() const LLVM_READONLY
Definition: ExprCXX.h:3808
SourceLocation getEndLoc() const LLVM_READONLY
Definition: ExprCXX.h:608
arg_iterator arg_begin()
Definition: Expr.h:2415
unsigned getNumObjects() const
Definition: ExprCXX.h:3125
CoroutineSuspendExpr(StmtClass SC, EmptyShell Empty)
Definition: ExprCXX.h:4372
SourceLocation getRParenLoc() const
Determine the location of the right parenthesis.
Definition: ExprCXX.h:3898
friend TrailingObjects
Definition: OpenMPClause.h:93
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprCXX.h:2399
void setSubExpr(Expr *E)
As with any mutator of the AST, be very careful when modifying an existing AST to preserve its invari...
Definition: ExprCXX.h:3141
Represents a call to a CUDA kernel function.
Definition: ExprCXX.h:205
Represents a &#39;co_await&#39; expression.
Definition: ExprCXX.h:4419
TypeTraitExprBitfields TypeTraitExprBits
Definition: Stmt.h:312
MaterializeTemporaryExpr(QualType T, Expr *Temporary, bool BoundToLvalueReference)
Definition: ExprCXX.h:4172
void setParenOrBraceRange(SourceRange Range)
Definition: ExprCXX.h:1438
child_range children()
Definition: ExprCXX.h:1147
bool doesUsualArrayDeleteWantSize() const
Answers whether the usual array deallocation function for the allocated type expects the size of the ...
Definition: ExprCXX.h:2081
void setArg(unsigned Arg, Expr *ArgExpr)
Set the specified argument.
Definition: ExprCXX.h:1428
static bool classof(const Stmt *T)
Definition: ExprCXX.h:4498
CXXInheritedCtorInitExpr(SourceLocation Loc, QualType T, CXXConstructorDecl *Ctor, bool ConstructsVirtualBase, bool InheritedFromVirtualBase)
Construct a C++ inheriting construction expression.
Definition: ExprCXX.h:1473
SourceRange getDirectInitRange() const
Definition: ExprCXX.h:2124
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier that qualifies the member name, with source location information...
Definition: ExprCXX.h:3407
SourceLocation getLocStart() const LLVM_READONLY
Note: getLocStart() is the start of the whole DependentScopeDeclRefExpr, and differs from getLocation...
Definition: ExprCXX.h:3061
Expr * getArg(unsigned Arg)
Return the specified argument.
Definition: ExprCXX.h:1418
CXXBoolLiteralExpr(bool val, QualType Ty, SourceLocation l)
Definition: ExprCXX.h:561
static bool classof(const Stmt *T)
Definition: ExprCXX.h:3731
SourceLocation getLocStart() const LLVM_READONLY
Default argument expressions have no representation in the source, so they have an empty source range...
Definition: ExprCXX.h:1135
static bool classof(const Stmt *T)
Definition: ExprCXX.h:2489
static bool isAssignmentOp(OverloadedOperatorKind Opc)
Definition: ExprCXX.h:108
bool isArrow() const
Determine whether this member expression used the &#39;->&#39; operator; otherwise, it used the &#39;...
Definition: ExprCXX.h:3394
CXXThrowExpr(EmptyShell Empty)
Definition: ExprCXX.h:1048
SourceLocation getLocStart() const LLVM_READONLY
Definition: ExprCXX.h:2398
arg_iterator placement_arg_begin()
Definition: ExprCXX.h:2096
child_range children()
Definition: ExprCXX.h:4496
bool isPartiallySubstituted() const
Determine whether this represents a partially-substituted sizeof...
Definition: ExprCXX.h:3918
Represents an expression that might suspend coroutine execution; either a co_await or co_yield expres...
Definition: ExprCXX.h:4334
unsigned arg_size() const
Retrieve the number of arguments.
Definition: ExprCXX.h:3243
SourceLocation getLocEnd() const LLVM_READONLY
Definition: ExprCXX.h:2549
void setLParenLoc(SourceLocation L)
Definition: ExprCXX.h:3230
llvm::iterator_range< decls_iterator > decls() const
Definition: ExprCXX.h:2732
Describes an explicit type conversion that uses functional notion but could not be resolved because o...
Definition: ExprCXX.h:3183
Expr * getResumeExpr() const
Definition: ExprCXX.h:4396
A use of a default initializer in a constructor or in aggregate initialization.
Definition: ExprCXX.h:1160
bool isListInitialization() const
Determine whether this expression models list-initialization.
Definition: ExprCXX.h:1570
SourceLocation getLAngleLoc() const
Retrieve the location of the left angle bracket starting the explicit template argument list followin...
Definition: ExprCXX.h:3447
void setLocation(SourceLocation L)
Definition: ExprCXX.h:1003
child_range children()
Definition: ExprCXX.h:1077
StringRef getUuidStr() const
Definition: ExprCXX.h:952
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate.h) and friends (in DeclFriend.h).
bool allowFPContractWithinStatement() const
Definition: LangOptions.h:274
const Expr * getSubExpr() const
Definition: ExprCXX.h:642
CoroutineSuspendExpr(StmtClass SC, SourceLocation KeywordLoc, QualType Ty, Expr *Common)
Definition: ExprCXX.h:4359
Defines the clang::SourceLocation class and associated facilities.
SourceLocation getLocStart() const LLVM_READONLY
Definition: ExprCXX.h:4116
UserDefinedLiteral(const ASTContext &C, Expr *Fn, ArrayRef< Expr *> Args, QualType T, ExprValueKind VK, SourceLocation LitEndLoc, SourceLocation SuffixLoc)
Definition: ExprCXX.h:489
Represents a C++ struct/union/class.
Definition: DeclCXX.h:302
SourceLocation getExprLoc() const LLVM_READONLY
Definition: ExprCXX.h:877
bool isValid() const
SourceLocation getLocStart() const LLVM_READONLY
Definition: ExprCXX.h:1507
const CXXTemporary * getTemporary() const
Definition: ExprCXX.h:1265
SourceLocation getLocEnd() const LLVM_READONLY
Definition: ExprCXX.h:4491
child_range children()
Definition: ExprCXX.h:1446
Represents an explicit C++ type conversion that uses "functional" notation (C++ [expr.type.conv]).
Definition: ExprCXX.h:1528
static bool classof(const Stmt *T)
Definition: ExprCXX.h:2807
Expr * getOperand() const
Definition: ExprCXX.h:4440
ExpressionTraitExpr(EmptyShell Empty)
Definition: ExprCXX.h:2610
SourceRange getParenOrBraceRange() const
Definition: ExprCXX.h:1437
CleanupObject getObject(unsigned i) const
Definition: ExprCXX.h:3127
const_arg_iterator raw_arg_end() const
Definition: ExprCXX.h:2116
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprCXX.h:1136
SourceLocation getLParenLoc() const
Definition: ExprCXX.h:1564
bool containsUnexpandedParameterPack() const
Whether this expression contains an unexpanded parameter pack (for C++11 variadic templates)...
Definition: Expr.h:214
SourceLocation getEndLoc() const LLVM_READONLY
Definition: ExprCXX.h:3726
SourceLocation getLocEnd() const LLVM_READONLY
Definition: ExprCXX.h:137
unsigned kind
All of the diagnostics that can be emitted by the frontend.
Definition: DiagnosticIDs.h:61
Optional< unsigned > getNumExpansions() const
Determine the number of expansions that will be produced when this pack expansion is instantiated...
Definition: ExprCXX.h:3796
void setExprOperand(Expr *E)
Definition: ExprCXX.h:733
SourceLocation getEllipsisLoc() const
Definition: ExprCXX.h:4304
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation tokens are not useful in isolation - they are low level value objects created/interpre...
Definition: Stmt.cpp:266
bool isGlobalDelete() const
Definition: ExprCXX.h:2185
Expr * getBase() const
Retrieve the base object of this member expressions, e.g., the x in x.m.
Definition: ExprCXX.h:3385
Full-expression storage duration (for temporaries).
Definition: Specifiers.h:277
bool hasExplicitParameters() const
Determine whether this lambda has an explicit parameter list vs.
Definition: ExprCXX.h:1848
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
Definition: Expr.h:2316
SourceLocation getExprLoc() const LLVM_READONLY
Definition: ExprCXX.h:1140
CXXUuidofExpr(EmptyShell Empty, bool isExpr)
Definition: ExprCXX.h:916
SourceRange getTypeIdParens() const
Definition: ExprCXX.h:2045
Expr * getPattern()
Retrieve the pattern of the pack expansion.
Definition: ExprCXX.h:3785
const Expr * getArg(unsigned I) const
Definition: ExprCXX.h:3262
CXXTypeidExpr(EmptyShell Empty, bool isExpr)
Definition: ExprCXX.h:699
static bool classof(const Stmt *T)
Definition: ExprCXX.h:1623
Abstract class common to all of the C++ "named"/"keyword" casts.
Definition: ExprCXX.h:248
SourceLocation getRAngleLoc() const
Retrieve the location of the right angle bracket ending the explicit template argument list following...
Definition: ExprCXX.h:2773
SourceLocation getLocEnd() const LLVM_READONLY
Definition: ExprCXX.h:3148
const ParmVarDecl * getParam() const
Definition: ExprCXX.h:1118
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
Definition: Type.h:1942
SourceLocation getBeginLoc() const
Definition: ExprCXX.h:796
SourceLocation getEndLoc() const
Definition: ExprCXX.h:539
capture_init_iterator capture_init_end()
Retrieve the iterator pointing one past the last initialization argument for this lambda expression...
Definition: ExprCXX.h:1806
SourceLocation getEndLoc() const LLVM_READONLY
Definition: ExprCXX.h:1278
static bool classof(const Stmt *T)
Definition: ExprCXX.h:427
SourceLocation getLocEnd() const LLVM_READONLY
Definition: ExprCXX.h:1435
SourceLocation getEndLoc() const LLVM_READONLY
Definition: ExprCXX.h:1200
NestedNameSpecifierLoc getQualifierLoc() const
Fetches the nested-name qualifier with source-location information, if one was given.
Definition: ExprCXX.h:2755
Expr *const * const_capture_init_iterator
Const iterator that walks over the capture initialization arguments.
Definition: ExprCXX.h:1780
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprCXX.h:606
Expr * getOperand() const
Definition: ExprCXX.h:4517
const ASTTemplateKWAndArgsInfo * getTrailingASTTemplateKWAndArgsInfo() const
Return the optional template keyword and arguments info.
Definition: ExprCXX.h:2673
CUDAKernelCallExpr(ASTContext &C, EmptyShell Empty)
Definition: ExprCXX.h:215
SourceLocation getTemplateKeywordLoc() const
Retrieve the location of the template keyword preceding the member name, if any.
Definition: ExprCXX.h:3440
CoawaitExpr(SourceLocation CoawaitLoc, Expr *Operand, Expr *Ready, Expr *Suspend, Expr *Resume, OpaqueValueExpr *OpaqueValue, bool IsImplicit=false)
Definition: ExprCXX.h:4423
bool hadMultipleCandidates() const
Whether the referred constructor was resolved from an overloaded set having size greater than 1...
Definition: ExprCXX.h:1366
An instance of this class represents the declaration of a property member.
Definition: DeclCXX.h:3920
QualType getTypeAsWritten() const
Retrieve the type that is being constructed, as specified in the source code.
Definition: ExprCXX.h:3221
QualType getType() const
Definition: Decl.h:648
ParmVarDecl * getParameterPack() const
Get the parameter pack which this expression refers to.
Definition: ExprCXX.h:4099
#define true
Definition: stdbool.h:32
An l-value expression is a reference to an object with independent storage.
Definition: Specifiers.h:114
unsigned getNumArgs() const
Definition: ExprCXX.h:1415
A trivial tuple used to represent a source range.
DependentCoawaitExpr(EmptyShell Empty)
Definition: ExprCXX.h:4477
This represents a decl that may have a name.
Definition: Decl.h:248
A boolean literal, per ([C++ lex.bool] Boolean literals).
Definition: ExprCXX.h:556
static bool classof(const Stmt *T)
Definition: ExprCXX.h:3073
CXXPseudoDestructorExpr(EmptyShell Shell)
Definition: ExprCXX.h:2315
Expr * getQueriedExpression() const
Definition: ExprCXX.h:2620
A Microsoft C++ __uuidof expression, which gets the _GUID that corresponds to the supplied type or ex...
Definition: ExprCXX.h:895
SourceLocation getRParenLoc() const
Definition: ExprCXX.h:1566
Automatic storage duration (most local variables).
Definition: Specifiers.h:278
child_range children()
Definition: ExprCXX.h:2138
void setStdInitListInitialization(bool V)
Definition: ExprCXX.h:1378
unsigned getNumTemplateArgs() const
Definition: ExprCXX.h:3048
const Expr * getPlacementArg(unsigned i) const
Definition: ExprCXX.h:2039
static bool classof(const Stmt *T)
Definition: ExprCXX.h:4313
SourceLocation LAngleLoc
The source location of the left angle bracket (&#39;<&#39;).
Definition: TemplateBase.h:646
static bool classof(const Stmt *T)
Definition: ExprCXX.h:3154
const_arg_iterator arg_end() const
Definition: ExprCXX.h:3253
SourceLocation getBegin() const
CXXThrowExpr(Expr *expr, QualType Ty, SourceLocation l, bool IsThrownVariableInScope)
Definition: ExprCXX.h:1041
BinaryOperatorKind getOperator() const
Definition: ExprCXX.h:4305
NamedDecl * getPack() const
Retrieve the parameter pack.
Definition: ExprCXX.h:3901
decls_iterator decls_end() const
Definition: ExprCXX.h:2729
SourceLocation getKeywordLoc() const
Definition: ExprCXX.h:4379
QualType getBaseType() const
Definition: ExprCXX.h:3616
Expr * getBaseExpr() const
Definition: ExprCXX.h:816
static bool classof(const Stmt *T)
Definition: ExprCXX.h:237
CXXThisExpr(EmptyShell Empty)
Definition: ExprCXX.h:1000
SourceLocation getLocStart() const LLVM_READONLY
Definition: ExprCXX.h:795
llvm::iterator_range< capture_iterator > capture_range
An iterator over a range of lambda captures.
Definition: ExprCXX.h:1737
const_arg_iterator raw_arg_begin() const
Definition: ExprCXX.h:2115
operator "" X (unsigned long long)
Definition: ExprCXX.h:507
QualType getType() const
Return the type wrapped by this type source info.
Definition: Decl.h:97
TypeTrait getTrait() const
Determine which type trait this expression uses.
Definition: ExprCXX.h:2460
const DeclarationNameInfo & getMemberNameInfo() const
Retrieve the name of the member that this expression refers to.
Definition: ExprCXX.h:3426
SourceLocation getEndLoc() const LLVM_READONLY
Definition: ExprCXX.h:4492
CXXConstructExpr(EmptyShell Empty)
Construct an empty C++ construction expression.
Definition: ExprCXX.h:1339
Expr * IgnoreParens() LLVM_READONLY
IgnoreParens - Ignore parentheses.
Definition: Expr.cpp:2513
static OMPLinearClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, OpenMPLinearClauseKind Modifier, SourceLocation ModifierLoc, SourceLocation ColonLoc, SourceLocation EndLoc, ArrayRef< Expr *> VL, ArrayRef< Expr *> PL, ArrayRef< Expr *> IL, Expr *Step, Expr *CalcStep, Stmt *PreInit, Expr *PostUpdate)
Creates clause with a list of variables VL and a linear step Step.
ConstructionKind getConstructionKind() const
Determine whether this constructor is actually constructing a base class (rather than a complete obje...
Definition: ExprCXX.h:1389
SourceLocation getLocEnd() const LLVM_READONLY
Definition: ExprCXX.h:1900
SourceLocation getEndLoc() const LLVM_READONLY
Definition: ExprCXX.h:872
child_range children()
Definition: ExprCXX.h:808
static bool classof(const Stmt *T)
Definition: ExprCXX.h:4240
bool isOverloaded() const
True if this lookup is overloaded.
Definition: ExprCXX.h:2900
child_range children()
Definition: ExprCXX.h:2567