clang 20.0.0git
ExprCXX.h
Go to the documentation of this file.
1//===- ExprCXX.h - Classes for representing expressions ---------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9/// \file
10/// Defines the clang::Expr interface and subclasses for C++ expressions.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef LLVM_CLANG_AST_EXPRCXX_H
15#define LLVM_CLANG_AST_EXPRCXX_H
16
19#include "clang/AST/Decl.h"
20#include "clang/AST/DeclBase.h"
21#include "clang/AST/DeclCXX.h"
25#include "clang/AST/Expr.h"
28#include "clang/AST/Stmt.h"
29#include "clang/AST/StmtCXX.h"
31#include "clang/AST/Type.h"
35#include "clang/Basic/LLVM.h"
36#include "clang/Basic/Lambda.h"
42#include "llvm/ADT/ArrayRef.h"
43#include "llvm/ADT/PointerUnion.h"
44#include "llvm/ADT/StringRef.h"
45#include "llvm/ADT/iterator_range.h"
46#include "llvm/Support/Casting.h"
47#include "llvm/Support/Compiler.h"
48#include "llvm/Support/TrailingObjects.h"
49#include <cassert>
50#include <cstddef>
51#include <cstdint>
52#include <memory>
53#include <optional>
54
55namespace clang {
56
57class ASTContext;
58class DeclAccessPair;
59class IdentifierInfo;
60class LambdaCapture;
61class NonTypeTemplateParmDecl;
62class TemplateParameterList;
63
64//===--------------------------------------------------------------------===//
65// C++ Expressions.
66//===--------------------------------------------------------------------===//
67
68/// A call to an overloaded operator written using operator
69/// syntax.
70///
71/// Represents a call to an overloaded operator written using operator
72/// syntax, e.g., "x + y" or "*p". While semantically equivalent to a
73/// normal call, this AST node provides better information about the
74/// syntactic representation of the call.
75///
76/// In a C++ template, this expression node kind will be used whenever
77/// any of the arguments are type-dependent. In this case, the
78/// function itself will be a (possibly empty) set of functions and
79/// function templates that were found by name lookup at template
80/// definition time.
81class CXXOperatorCallExpr final : public CallExpr {
82 friend class ASTStmtReader;
83 friend class ASTStmtWriter;
84
86
87 // CXXOperatorCallExpr has some trailing objects belonging
88 // to CallExpr. See CallExpr for the details.
89
90 SourceRange getSourceRangeImpl() const LLVM_READONLY;
91
93 ArrayRef<Expr *> Args, QualType Ty, ExprValueKind VK,
94 SourceLocation OperatorLoc, FPOptionsOverride FPFeatures,
96
97 CXXOperatorCallExpr(unsigned NumArgs, bool HasFPFeatures, EmptyShell Empty);
98
99public:
100 static CXXOperatorCallExpr *
101 Create(const ASTContext &Ctx, OverloadedOperatorKind OpKind, Expr *Fn,
102 ArrayRef<Expr *> Args, QualType Ty, ExprValueKind VK,
103 SourceLocation OperatorLoc, FPOptionsOverride FPFeatures,
105
106 static CXXOperatorCallExpr *CreateEmpty(const ASTContext &Ctx,
107 unsigned NumArgs, bool HasFPFeatures,
109
110 /// Returns the kind of overloaded operator that this expression refers to.
112 return static_cast<OverloadedOperatorKind>(
113 CXXOperatorCallExprBits.OperatorKind);
114 }
115
117 return Opc == OO_Equal || Opc == OO_StarEqual || Opc == OO_SlashEqual ||
118 Opc == OO_PercentEqual || Opc == OO_PlusEqual ||
119 Opc == OO_MinusEqual || Opc == OO_LessLessEqual ||
120 Opc == OO_GreaterGreaterEqual || Opc == OO_AmpEqual ||
121 Opc == OO_CaretEqual || Opc == OO_PipeEqual;
122 }
123 bool isAssignmentOp() const { return isAssignmentOp(getOperator()); }
124
126 switch (Opc) {
127 case OO_EqualEqual:
128 case OO_ExclaimEqual:
129 case OO_Greater:
130 case OO_GreaterEqual:
131 case OO_Less:
132 case OO_LessEqual:
133 case OO_Spaceship:
134 return true;
135 default:
136 return false;
137 }
138 }
139 bool isComparisonOp() const { return isComparisonOp(getOperator()); }
140
141 /// Is this written as an infix binary operator?
142 bool isInfixBinaryOp() const;
143
144 /// Returns the location of the operator symbol in the expression.
145 ///
146 /// When \c getOperator()==OO_Call, this is the location of the right
147 /// parentheses; when \c getOperator()==OO_Subscript, this is the location
148 /// of the right bracket.
150
151 SourceLocation getExprLoc() const LLVM_READONLY {
153 return (Operator < OO_Plus || Operator >= OO_Arrow ||
154 Operator == OO_PlusPlus || Operator == OO_MinusMinus)
155 ? getBeginLoc()
156 : getOperatorLoc();
157 }
158
159 SourceLocation getBeginLoc() const { return Range.getBegin(); }
160 SourceLocation getEndLoc() const { return Range.getEnd(); }
161 SourceRange getSourceRange() const { return Range; }
162
163 static bool classof(const Stmt *T) {
164 return T->getStmtClass() == CXXOperatorCallExprClass;
165 }
166};
167
168/// Represents a call to a member function that
169/// may be written either with member call syntax (e.g., "obj.func()"
170/// or "objptr->func()") or with normal function-call syntax
171/// ("func()") within a member function that ends up calling a member
172/// function. The callee in either case is a MemberExpr that contains
173/// both the object argument and the member function, while the
174/// arguments are the arguments within the parentheses (not including
175/// the object argument).
176class CXXMemberCallExpr final : public CallExpr {
177 // CXXMemberCallExpr has some trailing objects belonging
178 // to CallExpr. See CallExpr for the details.
179
182 FPOptionsOverride FPOptions, unsigned MinNumArgs);
183
184 CXXMemberCallExpr(unsigned NumArgs, bool HasFPFeatures, EmptyShell Empty);
185
186public:
187 static CXXMemberCallExpr *Create(const ASTContext &Ctx, Expr *Fn,
188 ArrayRef<Expr *> Args, QualType Ty,
190 FPOptionsOverride FPFeatures,
191 unsigned MinNumArgs = 0);
192
193 static CXXMemberCallExpr *CreateEmpty(const ASTContext &Ctx, unsigned NumArgs,
194 bool HasFPFeatures, EmptyShell Empty);
195
196 /// Retrieve the implicit object argument for the member call.
197 ///
198 /// For example, in "x.f(5)", this returns the sub-expression "x".
200
201 /// Retrieve the type of the object argument.
202 ///
203 /// Note that this always returns a non-pointer type.
204 QualType getObjectType() const;
205
206 /// Retrieve the declaration of the called method.
208
209 /// Retrieve the CXXRecordDecl for the underlying type of
210 /// the implicit object argument.
211 ///
212 /// Note that this is may not be the same declaration as that of the class
213 /// context of the CXXMethodDecl which this function is calling.
214 /// FIXME: Returns 0 for member pointer call exprs.
216
217 SourceLocation getExprLoc() const LLVM_READONLY {
219 if (CLoc.isValid())
220 return CLoc;
221
222 return getBeginLoc();
223 }
224
225 static bool classof(const Stmt *T) {
226 return T->getStmtClass() == CXXMemberCallExprClass;
227 }
228};
229
230/// Represents a call to a CUDA kernel function.
231class CUDAKernelCallExpr final : public CallExpr {
232 friend class ASTStmtReader;
233
234 enum { CONFIG, END_PREARG };
235
236 // CUDAKernelCallExpr has some trailing objects belonging
237 // to CallExpr. See CallExpr for the details.
238
241 FPOptionsOverride FPFeatures, unsigned MinNumArgs);
242
243 CUDAKernelCallExpr(unsigned NumArgs, bool HasFPFeatures, EmptyShell Empty);
244
245public:
246 static CUDAKernelCallExpr *Create(const ASTContext &Ctx, Expr *Fn,
247 CallExpr *Config, ArrayRef<Expr *> Args,
248 QualType Ty, ExprValueKind VK,
250 FPOptionsOverride FPFeatures,
251 unsigned MinNumArgs = 0);
252
253 static CUDAKernelCallExpr *CreateEmpty(const ASTContext &Ctx,
254 unsigned NumArgs, bool HasFPFeatures,
255 EmptyShell Empty);
256
257 const CallExpr *getConfig() const {
258 return cast_or_null<CallExpr>(getPreArg(CONFIG));
259 }
260 CallExpr *getConfig() { return cast_or_null<CallExpr>(getPreArg(CONFIG)); }
261
262 static bool classof(const Stmt *T) {
263 return T->getStmtClass() == CUDAKernelCallExprClass;
264 }
265};
266
267/// A rewritten comparison expression that was originally written using
268/// operator syntax.
269///
270/// In C++20, the following rewrites are performed:
271/// - <tt>a == b</tt> -> <tt>b == a</tt>
272/// - <tt>a != b</tt> -> <tt>!(a == b)</tt>
273/// - <tt>a != b</tt> -> <tt>!(b == a)</tt>
274/// - For \c \@ in \c <, \c <=, \c >, \c >=, \c <=>:
275/// - <tt>a @ b</tt> -> <tt>(a <=> b) @ 0</tt>
276/// - <tt>a @ b</tt> -> <tt>0 @ (b <=> a)</tt>
277///
278/// This expression provides access to both the original syntax and the
279/// rewritten expression.
280///
281/// Note that the rewritten calls to \c ==, \c <=>, and \c \@ are typically
282/// \c CXXOperatorCallExprs, but could theoretically be \c BinaryOperators.
284 friend class ASTStmtReader;
285
286 /// The rewritten semantic form.
287 Stmt *SemanticForm;
288
289public:
290 CXXRewrittenBinaryOperator(Expr *SemanticForm, bool IsReversed)
291 : Expr(CXXRewrittenBinaryOperatorClass, SemanticForm->getType(),
292 SemanticForm->getValueKind(), SemanticForm->getObjectKind()),
293 SemanticForm(SemanticForm) {
294 CXXRewrittenBinaryOperatorBits.IsReversed = IsReversed;
296 }
298 : Expr(CXXRewrittenBinaryOperatorClass, Empty), SemanticForm() {}
299
300 /// Get an equivalent semantic form for this expression.
301 Expr *getSemanticForm() { return cast<Expr>(SemanticForm); }
302 const Expr *getSemanticForm() const { return cast<Expr>(SemanticForm); }
303
305 /// The original opcode, prior to rewriting.
307 /// The original left-hand side.
308 const Expr *LHS;
309 /// The original right-hand side.
310 const Expr *RHS;
311 /// The inner \c == or \c <=> operator expression.
313 };
314
315 /// Decompose this operator into its syntactic form.
316 DecomposedForm getDecomposedForm() const LLVM_READONLY;
317
318 /// Determine whether this expression was rewritten in reverse form.
319 bool isReversed() const { return CXXRewrittenBinaryOperatorBits.IsReversed; }
320
323 static StringRef getOpcodeStr(BinaryOperatorKind Op) {
325 }
326 StringRef getOpcodeStr() const {
328 }
329 bool isComparisonOp() const { return true; }
330 bool isAssignmentOp() const { return false; }
331
332 const Expr *getLHS() const { return getDecomposedForm().LHS; }
333 const Expr *getRHS() const { return getDecomposedForm().RHS; }
334
335 SourceLocation getOperatorLoc() const LLVM_READONLY {
337 }
338 SourceLocation getExprLoc() const LLVM_READONLY { return getOperatorLoc(); }
339
340 /// Compute the begin and end locations from the decomposed form.
341 /// The locations of the semantic form are not reliable if this is
342 /// a reversed expression.
343 //@{
344 SourceLocation getBeginLoc() const LLVM_READONLY {
346 }
347 SourceLocation getEndLoc() const LLVM_READONLY {
348 return getDecomposedForm().RHS->getEndLoc();
349 }
350 SourceRange getSourceRange() const LLVM_READONLY {
352 return SourceRange(DF.LHS->getBeginLoc(), DF.RHS->getEndLoc());
353 }
354 //@}
355
357 return child_range(&SemanticForm, &SemanticForm + 1);
358 }
359
360 static bool classof(const Stmt *T) {
361 return T->getStmtClass() == CXXRewrittenBinaryOperatorClass;
362 }
363};
364
365/// Abstract class common to all of the C++ "named"/"keyword" casts.
366///
367/// This abstract class is inherited by all of the classes
368/// representing "named" casts: CXXStaticCastExpr for \c static_cast,
369/// CXXDynamicCastExpr for \c dynamic_cast, CXXReinterpretCastExpr for
370/// reinterpret_cast, CXXConstCastExpr for \c const_cast and
371/// CXXAddrspaceCastExpr for addrspace_cast (in OpenCL).
373private:
374 // the location of the casting op
375 SourceLocation Loc;
376
377 // the location of the right parenthesis
378 SourceLocation RParenLoc;
379
380 // range for '<' '>'
381 SourceRange AngleBrackets;
382
383protected:
384 friend class ASTStmtReader;
385
387 Expr *op, unsigned PathSize, bool HasFPFeatures,
388 TypeSourceInfo *writtenTy, SourceLocation l,
389 SourceLocation RParenLoc, SourceRange AngleBrackets)
390 : ExplicitCastExpr(SC, ty, VK, kind, op, PathSize, HasFPFeatures,
391 writtenTy),
392 Loc(l), RParenLoc(RParenLoc), AngleBrackets(AngleBrackets) {}
393
394 explicit CXXNamedCastExpr(StmtClass SC, EmptyShell Shell, unsigned PathSize,
395 bool HasFPFeatures)
396 : ExplicitCastExpr(SC, Shell, PathSize, HasFPFeatures) {}
397
398public:
399 const char *getCastName() const;
400
401 /// Retrieve the location of the cast operator keyword, e.g.,
402 /// \c static_cast.
404
405 /// Retrieve the location of the closing parenthesis.
406 SourceLocation getRParenLoc() const { return RParenLoc; }
407
408 SourceLocation getBeginLoc() const LLVM_READONLY { return Loc; }
409 SourceLocation getEndLoc() const LLVM_READONLY { return RParenLoc; }
410 SourceRange getAngleBrackets() const LLVM_READONLY { return AngleBrackets; }
411
412 static bool classof(const Stmt *T) {
413 switch (T->getStmtClass()) {
414 case CXXStaticCastExprClass:
415 case CXXDynamicCastExprClass:
416 case CXXReinterpretCastExprClass:
417 case CXXConstCastExprClass:
418 case CXXAddrspaceCastExprClass:
419 return true;
420 default:
421 return false;
422 }
423 }
424};
425
426/// A C++ \c static_cast expression (C++ [expr.static.cast]).
427///
428/// This expression node represents a C++ static cast, e.g.,
429/// \c static_cast<int>(1.0).
431 : public CXXNamedCastExpr,
432 private llvm::TrailingObjects<CXXStaticCastExpr, CXXBaseSpecifier *,
433 FPOptionsOverride> {
435 unsigned pathSize, TypeSourceInfo *writtenTy,
437 SourceLocation RParenLoc, SourceRange AngleBrackets)
438 : CXXNamedCastExpr(CXXStaticCastExprClass, ty, vk, kind, op, pathSize,
439 FPO.requiresTrailingStorage(), writtenTy, l, RParenLoc,
440 AngleBrackets) {
442 *getTrailingFPFeatures() = FPO;
443 }
444
445 explicit CXXStaticCastExpr(EmptyShell Empty, unsigned PathSize,
446 bool HasFPFeatures)
447 : CXXNamedCastExpr(CXXStaticCastExprClass, Empty, PathSize,
448 HasFPFeatures) {}
449
450 unsigned numTrailingObjects(OverloadToken<CXXBaseSpecifier *>) const {
451 return path_size();
452 }
453
454public:
455 friend class CastExpr;
457
458 static CXXStaticCastExpr *
459 Create(const ASTContext &Context, QualType T, ExprValueKind VK, CastKind K,
460 Expr *Op, const CXXCastPath *Path, TypeSourceInfo *Written,
462 SourceRange AngleBrackets);
463 static CXXStaticCastExpr *CreateEmpty(const ASTContext &Context,
464 unsigned PathSize, bool hasFPFeatures);
465
466 static bool classof(const Stmt *T) {
467 return T->getStmtClass() == CXXStaticCastExprClass;
468 }
469};
470
471/// A C++ @c dynamic_cast expression (C++ [expr.dynamic.cast]).
472///
473/// This expression node represents a dynamic cast, e.g.,
474/// \c dynamic_cast<Derived*>(BasePtr). Such a cast may perform a run-time
475/// check to determine how to perform the type conversion.
477 : public CXXNamedCastExpr,
478 private llvm::TrailingObjects<CXXDynamicCastExpr, CXXBaseSpecifier *> {
480 unsigned pathSize, TypeSourceInfo *writtenTy,
481 SourceLocation l, SourceLocation RParenLoc,
482 SourceRange AngleBrackets)
483 : CXXNamedCastExpr(CXXDynamicCastExprClass, ty, VK, kind, op, pathSize,
484 /*HasFPFeatures*/ false, writtenTy, l, RParenLoc,
485 AngleBrackets) {}
486
487 explicit CXXDynamicCastExpr(EmptyShell Empty, unsigned pathSize)
488 : CXXNamedCastExpr(CXXDynamicCastExprClass, Empty, pathSize,
489 /*HasFPFeatures*/ false) {}
490
491public:
492 friend class CastExpr;
494
495 static CXXDynamicCastExpr *Create(const ASTContext &Context, QualType T,
497 const CXXCastPath *Path,
498 TypeSourceInfo *Written, SourceLocation L,
499 SourceLocation RParenLoc,
500 SourceRange AngleBrackets);
501
502 static CXXDynamicCastExpr *CreateEmpty(const ASTContext &Context,
503 unsigned pathSize);
504
505 bool isAlwaysNull() const;
506
507 static bool classof(const Stmt *T) {
508 return T->getStmtClass() == CXXDynamicCastExprClass;
509 }
510};
511
512/// A C++ @c reinterpret_cast expression (C++ [expr.reinterpret.cast]).
513///
514/// This expression node represents a reinterpret cast, e.g.,
515/// @c reinterpret_cast<int>(VoidPtr).
516///
517/// A reinterpret_cast provides a differently-typed view of a value but
518/// (in Clang, as in most C++ implementations) performs no actual work at
519/// run time.
521 : public CXXNamedCastExpr,
522 private llvm::TrailingObjects<CXXReinterpretCastExpr,
523 CXXBaseSpecifier *> {
525 unsigned pathSize, TypeSourceInfo *writtenTy,
526 SourceLocation l, SourceLocation RParenLoc,
527 SourceRange AngleBrackets)
528 : CXXNamedCastExpr(CXXReinterpretCastExprClass, ty, vk, kind, op,
529 pathSize, /*HasFPFeatures*/ false, writtenTy, l,
530 RParenLoc, AngleBrackets) {}
531
532 CXXReinterpretCastExpr(EmptyShell Empty, unsigned pathSize)
533 : CXXNamedCastExpr(CXXReinterpretCastExprClass, Empty, pathSize,
534 /*HasFPFeatures*/ false) {}
535
536public:
537 friend class CastExpr;
539
540 static CXXReinterpretCastExpr *Create(const ASTContext &Context, QualType T,
542 Expr *Op, const CXXCastPath *Path,
543 TypeSourceInfo *WrittenTy, SourceLocation L,
544 SourceLocation RParenLoc,
545 SourceRange AngleBrackets);
546 static CXXReinterpretCastExpr *CreateEmpty(const ASTContext &Context,
547 unsigned pathSize);
548
549 static bool classof(const Stmt *T) {
550 return T->getStmtClass() == CXXReinterpretCastExprClass;
551 }
552};
553
554/// A C++ \c const_cast expression (C++ [expr.const.cast]).
555///
556/// This expression node represents a const cast, e.g.,
557/// \c const_cast<char*>(PtrToConstChar).
558///
559/// A const_cast can remove type qualifiers but does not change the underlying
560/// value.
562 : public CXXNamedCastExpr,
563 private llvm::TrailingObjects<CXXConstCastExpr, CXXBaseSpecifier *> {
565 TypeSourceInfo *writtenTy, SourceLocation l,
566 SourceLocation RParenLoc, SourceRange AngleBrackets)
567 : CXXNamedCastExpr(CXXConstCastExprClass, ty, VK, CK_NoOp, op, 0,
568 /*HasFPFeatures*/ false, writtenTy, l, RParenLoc,
569 AngleBrackets) {}
570
572 : CXXNamedCastExpr(CXXConstCastExprClass, Empty, 0,
573 /*HasFPFeatures*/ false) {}
574
575public:
576 friend class CastExpr;
578
579 static CXXConstCastExpr *Create(const ASTContext &Context, QualType T,
580 ExprValueKind VK, Expr *Op,
581 TypeSourceInfo *WrittenTy, SourceLocation L,
582 SourceLocation RParenLoc,
583 SourceRange AngleBrackets);
584 static CXXConstCastExpr *CreateEmpty(const ASTContext &Context);
585
586 static bool classof(const Stmt *T) {
587 return T->getStmtClass() == CXXConstCastExprClass;
588 }
589};
590
591/// A C++ addrspace_cast expression (currently only enabled for OpenCL).
592///
593/// This expression node represents a cast between pointers to objects in
594/// different address spaces e.g.,
595/// \c addrspace_cast<global int*>(PtrToGenericInt).
596///
597/// A addrspace_cast can cast address space type qualifiers but does not change
598/// the underlying value.
600 : public CXXNamedCastExpr,
601 private llvm::TrailingObjects<CXXAddrspaceCastExpr, CXXBaseSpecifier *> {
603 TypeSourceInfo *writtenTy, SourceLocation l,
604 SourceLocation RParenLoc, SourceRange AngleBrackets)
605 : CXXNamedCastExpr(CXXAddrspaceCastExprClass, ty, VK, Kind, op, 0,
606 /*HasFPFeatures*/ false, writtenTy, l, RParenLoc,
607 AngleBrackets) {}
608
610 : CXXNamedCastExpr(CXXAddrspaceCastExprClass, Empty, 0,
611 /*HasFPFeatures*/ false) {}
612
613public:
614 friend class CastExpr;
616
617 static CXXAddrspaceCastExpr *
619 Expr *Op, TypeSourceInfo *WrittenTy, SourceLocation L,
620 SourceLocation RParenLoc, SourceRange AngleBrackets);
621 static CXXAddrspaceCastExpr *CreateEmpty(const ASTContext &Context);
622
623 static bool classof(const Stmt *T) {
624 return T->getStmtClass() == CXXAddrspaceCastExprClass;
625 }
626};
627
628/// A call to a literal operator (C++11 [over.literal])
629/// written as a user-defined literal (C++11 [lit.ext]).
630///
631/// Represents a user-defined literal, e.g. "foo"_bar or 1.23_xyz. While this
632/// is semantically equivalent to a normal call, this AST node provides better
633/// information about the syntactic representation of the literal.
634///
635/// Since literal operators are never found by ADL and can only be declared at
636/// namespace scope, a user-defined literal is never dependent.
637class UserDefinedLiteral final : public CallExpr {
638 friend class ASTStmtReader;
639 friend class ASTStmtWriter;
640
641 /// The location of a ud-suffix within the literal.
642 SourceLocation UDSuffixLoc;
643
644 // UserDefinedLiteral has some trailing objects belonging
645 // to CallExpr. See CallExpr for the details.
646
648 ExprValueKind VK, SourceLocation LitEndLoc,
649 SourceLocation SuffixLoc, FPOptionsOverride FPFeatures);
650
651 UserDefinedLiteral(unsigned NumArgs, bool HasFPFeatures, EmptyShell Empty);
652
653public:
654 static UserDefinedLiteral *Create(const ASTContext &Ctx, Expr *Fn,
655 ArrayRef<Expr *> Args, QualType Ty,
656 ExprValueKind VK, SourceLocation LitEndLoc,
657 SourceLocation SuffixLoc,
658 FPOptionsOverride FPFeatures);
659
660 static UserDefinedLiteral *CreateEmpty(const ASTContext &Ctx,
661 unsigned NumArgs, bool HasFPOptions,
663
664 /// The kind of literal operator which is invoked.
666 /// Raw form: operator "" X (const char *)
668
669 /// Raw form: operator "" X<cs...> ()
671
672 /// operator "" X (unsigned long long)
674
675 /// operator "" X (long double)
677
678 /// operator "" X (const CharT *, size_t)
680
681 /// operator "" X (CharT)
683 };
684
685 /// Returns the kind of literal operator invocation
686 /// which this expression represents.
688
689 /// If this is not a raw user-defined literal, get the
690 /// underlying cooked literal (representing the literal with the suffix
691 /// removed).
693 const Expr *getCookedLiteral() const {
694 return const_cast<UserDefinedLiteral*>(this)->getCookedLiteral();
695 }
696
699 return getRParenLoc();
700 return getArg(0)->getBeginLoc();
701 }
702
704
705 /// Returns the location of a ud-suffix in the expression.
706 ///
707 /// For a string literal, there may be multiple identical suffixes. This
708 /// returns the first.
709 SourceLocation getUDSuffixLoc() const { return UDSuffixLoc; }
710
711 /// Returns the ud-suffix specified for this literal.
712 const IdentifierInfo *getUDSuffix() const;
713
714 static bool classof(const Stmt *S) {
715 return S->getStmtClass() == UserDefinedLiteralClass;
716 }
717};
718
719/// A boolean literal, per ([C++ lex.bool] Boolean literals).
720class CXXBoolLiteralExpr : public Expr {
721public:
723 : Expr(CXXBoolLiteralExprClass, Ty, VK_PRValue, OK_Ordinary) {
724 CXXBoolLiteralExprBits.Value = Val;
726 setDependence(ExprDependence::None);
727 }
728
730 : Expr(CXXBoolLiteralExprClass, Empty) {}
731
732 static CXXBoolLiteralExpr *Create(const ASTContext &C, bool Val, QualType Ty,
734 return new (C) CXXBoolLiteralExpr(Val, Ty, Loc);
735 }
736
737 bool getValue() const { return CXXBoolLiteralExprBits.Value; }
738 void setValue(bool V) { CXXBoolLiteralExprBits.Value = V; }
739
742
745
746 static bool classof(const Stmt *T) {
747 return T->getStmtClass() == CXXBoolLiteralExprClass;
748 }
749
750 // Iterators
753 }
754
757 }
758};
759
760/// The null pointer literal (C++11 [lex.nullptr])
761///
762/// Introduced in C++11, the only literal of type \c nullptr_t is \c nullptr.
763/// This also implements the null pointer literal in C23 (C23 6.4.1) which is
764/// intended to have the same semantics as the feature in C++.
766public:
768 : Expr(CXXNullPtrLiteralExprClass, Ty, VK_PRValue, OK_Ordinary) {
770 setDependence(ExprDependence::None);
771 }
772
774 : Expr(CXXNullPtrLiteralExprClass, Empty) {}
775
778
781
782 static bool classof(const Stmt *T) {
783 return T->getStmtClass() == CXXNullPtrLiteralExprClass;
784 }
785
788 }
789
792 }
793};
794
795/// Implicit construction of a std::initializer_list<T> object from an
796/// array temporary within list-initialization (C++11 [dcl.init.list]p5).
798 Stmt *SubExpr = nullptr;
799
801 : Expr(CXXStdInitializerListExprClass, Empty) {}
802
803public:
804 friend class ASTReader;
805 friend class ASTStmtReader;
806
808 : Expr(CXXStdInitializerListExprClass, Ty, VK_PRValue, OK_Ordinary),
809 SubExpr(SubExpr) {
811 }
812
813 Expr *getSubExpr() { return static_cast<Expr*>(SubExpr); }
814 const Expr *getSubExpr() const { return static_cast<const Expr*>(SubExpr); }
815
816 SourceLocation getBeginLoc() const LLVM_READONLY {
817 return SubExpr->getBeginLoc();
818 }
819
820 SourceLocation getEndLoc() const LLVM_READONLY {
821 return SubExpr->getEndLoc();
822 }
823
824 /// Retrieve the source range of the expression.
825 SourceRange getSourceRange() const LLVM_READONLY {
826 return SubExpr->getSourceRange();
827 }
828
829 static bool classof(const Stmt *S) {
830 return S->getStmtClass() == CXXStdInitializerListExprClass;
831 }
832
833 child_range children() { return child_range(&SubExpr, &SubExpr + 1); }
834
836 return const_child_range(&SubExpr, &SubExpr + 1);
837 }
838};
839
840/// A C++ \c typeid expression (C++ [expr.typeid]), which gets
841/// the \c type_info that corresponds to the supplied type, or the (possibly
842/// dynamic) type of the supplied expression.
843///
844/// This represents code like \c typeid(int) or \c typeid(*objPtr)
845class CXXTypeidExpr : public Expr {
846 friend class ASTStmtReader;
847
848private:
849 llvm::PointerUnion<Stmt *, TypeSourceInfo *> Operand;
851
852public:
854 : Expr(CXXTypeidExprClass, Ty, VK_LValue, OK_Ordinary), Operand(Operand),
855 Range(R) {
857 }
858
860 : Expr(CXXTypeidExprClass, Ty, VK_LValue, OK_Ordinary), Operand(Operand),
861 Range(R) {
863 }
864
866 : Expr(CXXTypeidExprClass, Empty) {
867 if (isExpr)
868 Operand = (Expr*)nullptr;
869 else
870 Operand = (TypeSourceInfo*)nullptr;
871 }
872
873 /// Determine whether this typeid has a type operand which is potentially
874 /// evaluated, per C++11 [expr.typeid]p3.
875 bool isPotentiallyEvaluated() const;
876
877 /// Best-effort check if the expression operand refers to a most derived
878 /// object. This is not a strong guarantee.
879 bool isMostDerived(ASTContext &Context) const;
880
881 bool isTypeOperand() const { return Operand.is<TypeSourceInfo *>(); }
882
883 /// Retrieves the type operand of this typeid() expression after
884 /// various required adjustments (removing reference types, cv-qualifiers).
885 QualType getTypeOperand(ASTContext &Context) const;
886
887 /// Retrieve source information for the type operand.
889 assert(isTypeOperand() && "Cannot call getTypeOperand for typeid(expr)");
890 return Operand.get<TypeSourceInfo *>();
891 }
893 assert(!isTypeOperand() && "Cannot call getExprOperand for typeid(type)");
894 return static_cast<Expr*>(Operand.get<Stmt *>());
895 }
896
897 SourceLocation getBeginLoc() const LLVM_READONLY { return Range.getBegin(); }
898 SourceLocation getEndLoc() const LLVM_READONLY { return Range.getEnd(); }
899 SourceRange getSourceRange() const LLVM_READONLY { return Range; }
901
902 static bool classof(const Stmt *T) {
903 return T->getStmtClass() == CXXTypeidExprClass;
904 }
905
906 // Iterators
908 if (isTypeOperand())
910 auto **begin = reinterpret_cast<Stmt **>(&Operand);
911 return child_range(begin, begin + 1);
912 }
913
915 if (isTypeOperand())
917
918 auto **begin =
919 reinterpret_cast<Stmt **>(&const_cast<CXXTypeidExpr *>(this)->Operand);
920 return const_child_range(begin, begin + 1);
921 }
922
923 /// Whether this is of a form like "typeid(*ptr)" that can throw a
924 /// std::bad_typeid if a pointer is a null pointer ([expr.typeid]p2)
925 bool hasNullCheck() const;
926};
927
928/// A member reference to an MSPropertyDecl.
929///
930/// This expression always has pseudo-object type, and therefore it is
931/// typically not encountered in a fully-typechecked expression except
932/// within the syntactic form of a PseudoObjectExpr.
933class MSPropertyRefExpr : public Expr {
934 Expr *BaseExpr;
935 MSPropertyDecl *TheDecl;
936 SourceLocation MemberLoc;
937 bool IsArrow;
938 NestedNameSpecifierLoc QualifierLoc;
939
940public:
941 friend class ASTStmtReader;
942
944 QualType ty, ExprValueKind VK,
945 NestedNameSpecifierLoc qualifierLoc, SourceLocation nameLoc)
946 : Expr(MSPropertyRefExprClass, ty, VK, OK_Ordinary), BaseExpr(baseExpr),
947 TheDecl(decl), MemberLoc(nameLoc), IsArrow(isArrow),
948 QualifierLoc(qualifierLoc) {
950 }
951
952 MSPropertyRefExpr(EmptyShell Empty) : Expr(MSPropertyRefExprClass, Empty) {}
953
954 SourceRange getSourceRange() const LLVM_READONLY {
955 return SourceRange(getBeginLoc(), getEndLoc());
956 }
957
958 bool isImplicitAccess() const {
960 }
961
963 if (!isImplicitAccess())
964 return BaseExpr->getBeginLoc();
965 else if (QualifierLoc)
966 return QualifierLoc.getBeginLoc();
967 else
968 return MemberLoc;
969 }
970
972
974 return child_range((Stmt**)&BaseExpr, (Stmt**)&BaseExpr + 1);
975 }
976
978 auto Children = const_cast<MSPropertyRefExpr *>(this)->children();
979 return const_child_range(Children.begin(), Children.end());
980 }
981
982 static bool classof(const Stmt *T) {
983 return T->getStmtClass() == MSPropertyRefExprClass;
984 }
985
986 Expr *getBaseExpr() const { return BaseExpr; }
987 MSPropertyDecl *getPropertyDecl() const { return TheDecl; }
988 bool isArrow() const { return IsArrow; }
989 SourceLocation getMemberLoc() const { return MemberLoc; }
990 NestedNameSpecifierLoc getQualifierLoc() const { return QualifierLoc; }
991};
992
993/// MS property subscript expression.
994/// MSVC supports 'property' attribute and allows to apply it to the
995/// declaration of an empty array in a class or structure definition.
996/// For example:
997/// \code
998/// __declspec(property(get=GetX, put=PutX)) int x[];
999/// \endcode
1000/// The above statement indicates that x[] can be used with one or more array
1001/// indices. In this case, i=p->x[a][b] will be turned into i=p->GetX(a, b), and
1002/// p->x[a][b] = i will be turned into p->PutX(a, b, i).
1003/// This is a syntactic pseudo-object expression.
1005 friend class ASTStmtReader;
1006
1007 enum { BASE_EXPR, IDX_EXPR, NUM_SUBEXPRS = 2 };
1008
1009 Stmt *SubExprs[NUM_SUBEXPRS];
1010 SourceLocation RBracketLoc;
1011
1012 void setBase(Expr *Base) { SubExprs[BASE_EXPR] = Base; }
1013 void setIdx(Expr *Idx) { SubExprs[IDX_EXPR] = Idx; }
1014
1015public:
1017 ExprObjectKind OK, SourceLocation RBracketLoc)
1018 : Expr(MSPropertySubscriptExprClass, Ty, VK, OK),
1019 RBracketLoc(RBracketLoc) {
1020 SubExprs[BASE_EXPR] = Base;
1021 SubExprs[IDX_EXPR] = Idx;
1023 }
1024
1025 /// Create an empty array subscript expression.
1027 : Expr(MSPropertySubscriptExprClass, Shell) {}
1028
1029 Expr *getBase() { return cast<Expr>(SubExprs[BASE_EXPR]); }
1030 const Expr *getBase() const { return cast<Expr>(SubExprs[BASE_EXPR]); }
1031
1032 Expr *getIdx() { return cast<Expr>(SubExprs[IDX_EXPR]); }
1033 const Expr *getIdx() const { return cast<Expr>(SubExprs[IDX_EXPR]); }
1034
1035 SourceLocation getBeginLoc() const LLVM_READONLY {
1036 return getBase()->getBeginLoc();
1037 }
1038
1039 SourceLocation getEndLoc() const LLVM_READONLY { return RBracketLoc; }
1040
1041 SourceLocation getRBracketLoc() const { return RBracketLoc; }
1042 void setRBracketLoc(SourceLocation L) { RBracketLoc = L; }
1043
1044 SourceLocation getExprLoc() const LLVM_READONLY {
1045 return getBase()->getExprLoc();
1046 }
1047
1048 static bool classof(const Stmt *T) {
1049 return T->getStmtClass() == MSPropertySubscriptExprClass;
1050 }
1051
1052 // Iterators
1054 return child_range(&SubExprs[0], &SubExprs[0] + NUM_SUBEXPRS);
1055 }
1056
1058 return const_child_range(&SubExprs[0], &SubExprs[0] + NUM_SUBEXPRS);
1059 }
1060};
1061
1062/// A Microsoft C++ @c __uuidof expression, which gets
1063/// the _GUID that corresponds to the supplied type or expression.
1064///
1065/// This represents code like @c __uuidof(COMTYPE) or @c __uuidof(*comPtr)
1066class CXXUuidofExpr : public Expr {
1067 friend class ASTStmtReader;
1068
1069private:
1070 llvm::PointerUnion<Stmt *, TypeSourceInfo *> Operand;
1071 MSGuidDecl *Guid;
1073
1074public:
1076 SourceRange R)
1077 : Expr(CXXUuidofExprClass, Ty, VK_LValue, OK_Ordinary), Operand(Operand),
1078 Guid(Guid), Range(R) {
1080 }
1081
1083 : Expr(CXXUuidofExprClass, Ty, VK_LValue, OK_Ordinary), Operand(Operand),
1084 Guid(Guid), Range(R) {
1086 }
1087
1089 : Expr(CXXUuidofExprClass, Empty) {
1090 if (isExpr)
1091 Operand = (Expr*)nullptr;
1092 else
1093 Operand = (TypeSourceInfo*)nullptr;
1094 }
1095
1096 bool isTypeOperand() const { return Operand.is<TypeSourceInfo *>(); }
1097
1098 /// Retrieves the type operand of this __uuidof() expression after
1099 /// various required adjustments (removing reference types, cv-qualifiers).
1100 QualType getTypeOperand(ASTContext &Context) const;
1101
1102 /// Retrieve source information for the type operand.
1104 assert(isTypeOperand() && "Cannot call getTypeOperand for __uuidof(expr)");
1105 return Operand.get<TypeSourceInfo *>();
1106 }
1108 assert(!isTypeOperand() && "Cannot call getExprOperand for __uuidof(type)");
1109 return static_cast<Expr*>(Operand.get<Stmt *>());
1110 }
1111
1112 MSGuidDecl *getGuidDecl() const { return Guid; }
1113
1114 SourceLocation getBeginLoc() const LLVM_READONLY { return Range.getBegin(); }
1115 SourceLocation getEndLoc() const LLVM_READONLY { return Range.getEnd(); }
1116 SourceRange getSourceRange() const LLVM_READONLY { return Range; }
1118
1119 static bool classof(const Stmt *T) {
1120 return T->getStmtClass() == CXXUuidofExprClass;
1121 }
1122
1123 // Iterators
1125 if (isTypeOperand())
1127 auto **begin = reinterpret_cast<Stmt **>(&Operand);
1128 return child_range(begin, begin + 1);
1129 }
1130
1132 if (isTypeOperand())
1134 auto **begin =
1135 reinterpret_cast<Stmt **>(&const_cast<CXXUuidofExpr *>(this)->Operand);
1136 return const_child_range(begin, begin + 1);
1137 }
1138};
1139
1140/// Represents the \c this expression in C++.
1141///
1142/// This is a pointer to the object on which the current member function is
1143/// executing (C++ [expr.prim]p3). Example:
1144///
1145/// \code
1146/// class Foo {
1147/// public:
1148/// void bar();
1149/// void test() { this->bar(); }
1150/// };
1151/// \endcode
1152class CXXThisExpr : public Expr {
1153 CXXThisExpr(SourceLocation L, QualType Ty, bool IsImplicit, ExprValueKind VK)
1154 : Expr(CXXThisExprClass, Ty, VK, OK_Ordinary) {
1155 CXXThisExprBits.IsImplicit = IsImplicit;
1156 CXXThisExprBits.CapturedByCopyInLambdaWithExplicitObjectParameter = false;
1157 CXXThisExprBits.Loc = L;
1159 }
1160
1161 CXXThisExpr(EmptyShell Empty) : Expr(CXXThisExprClass, Empty) {}
1162
1163public:
1164 static CXXThisExpr *Create(const ASTContext &Ctx, SourceLocation L,
1165 QualType Ty, bool IsImplicit);
1166
1167 static CXXThisExpr *CreateEmpty(const ASTContext &Ctx);
1168
1171
1174
1175 bool isImplicit() const { return CXXThisExprBits.IsImplicit; }
1176 void setImplicit(bool I) { CXXThisExprBits.IsImplicit = I; }
1177
1179 return CXXThisExprBits.CapturedByCopyInLambdaWithExplicitObjectParameter;
1180 }
1181
1183 CXXThisExprBits.CapturedByCopyInLambdaWithExplicitObjectParameter = Set;
1185 }
1186
1187 static bool classof(const Stmt *T) {
1188 return T->getStmtClass() == CXXThisExprClass;
1189 }
1190
1191 // Iterators
1194 }
1195
1198 }
1199};
1200
1201/// A C++ throw-expression (C++ [except.throw]).
1202///
1203/// This handles 'throw' (for re-throwing the current exception) and
1204/// 'throw' assignment-expression. When assignment-expression isn't
1205/// present, Op will be null.
1206class CXXThrowExpr : public Expr {
1207 friend class ASTStmtReader;
1208
1209 /// The optional expression in the throw statement.
1210 Stmt *Operand;
1211
1212public:
1213 // \p Ty is the void type which is used as the result type of the
1214 // expression. The \p Loc is the location of the throw keyword.
1215 // \p Operand is the expression in the throw statement, and can be
1216 // null if not present.
1218 bool IsThrownVariableInScope)
1219 : Expr(CXXThrowExprClass, Ty, VK_PRValue, OK_Ordinary), Operand(Operand) {
1220 CXXThrowExprBits.ThrowLoc = Loc;
1221 CXXThrowExprBits.IsThrownVariableInScope = IsThrownVariableInScope;
1223 }
1224 CXXThrowExpr(EmptyShell Empty) : Expr(CXXThrowExprClass, Empty) {}
1225
1226 const Expr *getSubExpr() const { return cast_or_null<Expr>(Operand); }
1227 Expr *getSubExpr() { return cast_or_null<Expr>(Operand); }
1228
1229 SourceLocation getThrowLoc() const { return CXXThrowExprBits.ThrowLoc; }
1230
1231 /// Determines whether the variable thrown by this expression (if any!)
1232 /// is within the innermost try block.
1233 ///
1234 /// This information is required to determine whether the NRVO can apply to
1235 /// this variable.
1237 return CXXThrowExprBits.IsThrownVariableInScope;
1238 }
1239
1241 SourceLocation getEndLoc() const LLVM_READONLY {
1242 if (!getSubExpr())
1243 return getThrowLoc();
1244 return getSubExpr()->getEndLoc();
1245 }
1246
1247 static bool classof(const Stmt *T) {
1248 return T->getStmtClass() == CXXThrowExprClass;
1249 }
1250
1251 // Iterators
1253 return child_range(&Operand, Operand ? &Operand + 1 : &Operand);
1254 }
1255
1257 return const_child_range(&Operand, Operand ? &Operand + 1 : &Operand);
1258 }
1259};
1260
1261/// A default argument (C++ [dcl.fct.default]).
1262///
1263/// This wraps up a function call argument that was created from the
1264/// corresponding parameter's default argument, when the call did not
1265/// explicitly supply arguments for all of the parameters.
1267 : public Expr,
1268 private llvm::TrailingObjects<CXXDefaultArgExpr, Expr *> {
1269 friend class ASTStmtReader;
1270 friend class ASTReader;
1271 friend TrailingObjects;
1272
1273 /// The parameter whose default is being used.
1274 ParmVarDecl *Param;
1275
1276 /// The context where the default argument expression was used.
1277 DeclContext *UsedContext;
1278
1280 Expr *RewrittenExpr, DeclContext *UsedContext)
1281 : Expr(SC,
1282 Param->hasUnparsedDefaultArg()
1283 ? Param->getType().getNonReferenceType()
1284 : Param->getDefaultArg()->getType(),
1285 Param->getDefaultArg()->getValueKind(),
1286 Param->getDefaultArg()->getObjectKind()),
1287 Param(Param), UsedContext(UsedContext) {
1289 CXXDefaultArgExprBits.HasRewrittenInit = RewrittenExpr != nullptr;
1290 if (RewrittenExpr)
1291 *getTrailingObjects<Expr *>() = RewrittenExpr;
1293 }
1294
1295 CXXDefaultArgExpr(EmptyShell Empty, bool HasRewrittenInit)
1296 : Expr(CXXDefaultArgExprClass, Empty) {
1297 CXXDefaultArgExprBits.HasRewrittenInit = HasRewrittenInit;
1298 }
1299
1300public:
1301 static CXXDefaultArgExpr *CreateEmpty(const ASTContext &C,
1302 bool HasRewrittenInit);
1303
1304 // \p Param is the parameter whose default argument is used by this
1305 // expression.
1306 static CXXDefaultArgExpr *Create(const ASTContext &C, SourceLocation Loc,
1307 ParmVarDecl *Param, Expr *RewrittenExpr,
1308 DeclContext *UsedContext);
1309 // Retrieve the parameter that the argument was created from.
1310 const ParmVarDecl *getParam() const { return Param; }
1311 ParmVarDecl *getParam() { return Param; }
1312
1313 bool hasRewrittenInit() const {
1314 return CXXDefaultArgExprBits.HasRewrittenInit;
1315 }
1316
1317 // Retrieve the argument to the function call.
1318 Expr *getExpr();
1319 const Expr *getExpr() const {
1320 return const_cast<CXXDefaultArgExpr *>(this)->getExpr();
1321 }
1322
1324 return hasRewrittenInit() ? *getTrailingObjects<Expr *>() : nullptr;
1325 }
1326
1327 const Expr *getRewrittenExpr() const {
1328 return const_cast<CXXDefaultArgExpr *>(this)->getRewrittenExpr();
1329 }
1330
1331 // Retrieve the rewritten init expression (for an init expression containing
1332 // immediate calls) with the top level FullExpr and ConstantExpr stripped off.
1335 return const_cast<CXXDefaultArgExpr *>(this)->getAdjustedRewrittenExpr();
1336 }
1337
1338 const DeclContext *getUsedContext() const { return UsedContext; }
1339 DeclContext *getUsedContext() { return UsedContext; }
1340
1341 /// Retrieve the location where this default argument was actually used.
1343
1344 /// Default argument expressions have no representation in the
1345 /// source, so they have an empty source range.
1348
1350
1351 static bool classof(const Stmt *T) {
1352 return T->getStmtClass() == CXXDefaultArgExprClass;
1353 }
1354
1355 // Iterators
1358 }
1359
1362 }
1363};
1364
1365/// A use of a default initializer in a constructor or in aggregate
1366/// initialization.
1367///
1368/// This wraps a use of a C++ default initializer (technically,
1369/// a brace-or-equal-initializer for a non-static data member) when it
1370/// is implicitly used in a mem-initializer-list in a constructor
1371/// (C++11 [class.base.init]p8) or in aggregate initialization
1372/// (C++1y [dcl.init.aggr]p7).
1374 : public Expr,
1375 private llvm::TrailingObjects<CXXDefaultInitExpr, Expr *> {
1376
1377 friend class ASTStmtReader;
1378 friend class ASTReader;
1379 friend TrailingObjects;
1380 /// The field whose default is being used.
1381 FieldDecl *Field;
1382
1383 /// The context where the default initializer expression was used.
1384 DeclContext *UsedContext;
1385
1387 FieldDecl *Field, QualType Ty, DeclContext *UsedContext,
1388 Expr *RewrittenInitExpr);
1389
1390 CXXDefaultInitExpr(EmptyShell Empty, bool HasRewrittenInit)
1391 : Expr(CXXDefaultInitExprClass, Empty) {
1392 CXXDefaultInitExprBits.HasRewrittenInit = HasRewrittenInit;
1393 }
1394
1395public:
1397 bool HasRewrittenInit);
1398 /// \p Field is the non-static data member whose default initializer is used
1399 /// by this expression.
1401 FieldDecl *Field, DeclContext *UsedContext,
1402 Expr *RewrittenInitExpr);
1403
1404 bool hasRewrittenInit() const {
1405 return CXXDefaultInitExprBits.HasRewrittenInit;
1406 }
1407
1408 /// Get the field whose initializer will be used.
1409 FieldDecl *getField() { return Field; }
1410 const FieldDecl *getField() const { return Field; }
1411
1412 /// Get the initialization expression that will be used.
1413 Expr *getExpr();
1414 const Expr *getExpr() const {
1415 return const_cast<CXXDefaultInitExpr *>(this)->getExpr();
1416 }
1417
1418 /// Retrieve the initializing expression with evaluated immediate calls, if
1419 /// any.
1420 const Expr *getRewrittenExpr() const {
1421 assert(hasRewrittenInit() && "expected a rewritten init expression");
1422 return *getTrailingObjects<Expr *>();
1423 }
1424
1425 /// Retrieve the initializing expression with evaluated immediate calls, if
1426 /// any.
1428 assert(hasRewrittenInit() && "expected a rewritten init expression");
1429 return *getTrailingObjects<Expr *>();
1430 }
1431
1432 const DeclContext *getUsedContext() const { return UsedContext; }
1433 DeclContext *getUsedContext() { return UsedContext; }
1434
1435 /// Retrieve the location where this default initializer expression was
1436 /// actually used.
1438
1441
1442 static bool classof(const Stmt *T) {
1443 return T->getStmtClass() == CXXDefaultInitExprClass;
1444 }
1445
1446 // Iterators
1449 }
1450
1453 }
1454};
1455
1456/// Represents a C++ temporary.
1458 /// The destructor that needs to be called.
1459 const CXXDestructorDecl *Destructor;
1460
1461 explicit CXXTemporary(const CXXDestructorDecl *destructor)
1462 : Destructor(destructor) {}
1463
1464public:
1465 static CXXTemporary *Create(const ASTContext &C,
1466 const CXXDestructorDecl *Destructor);
1467
1468 const CXXDestructorDecl *getDestructor() const { return Destructor; }
1469
1471 Destructor = Dtor;
1472 }
1473};
1474
1475/// Represents binding an expression to a temporary.
1476///
1477/// This ensures the destructor is called for the temporary. It should only be
1478/// needed for non-POD, non-trivially destructable class types. For example:
1479///
1480/// \code
1481/// struct S {
1482/// S() { } // User defined constructor makes S non-POD.
1483/// ~S() { } // User defined destructor makes it non-trivial.
1484/// };
1485/// void test() {
1486/// const S &s_ref = S(); // Requires a CXXBindTemporaryExpr.
1487/// }
1488/// \endcode
1489///
1490/// Destructor might be null if destructor declaration is not valid.
1492 CXXTemporary *Temp = nullptr;
1493 Stmt *SubExpr = nullptr;
1494
1495 CXXBindTemporaryExpr(CXXTemporary *temp, Expr *SubExpr)
1496 : Expr(CXXBindTemporaryExprClass, SubExpr->getType(), VK_PRValue,
1497 OK_Ordinary),
1498 Temp(temp), SubExpr(SubExpr) {
1500 }
1501
1502public:
1504 : Expr(CXXBindTemporaryExprClass, Empty) {}
1505
1506 static CXXBindTemporaryExpr *Create(const ASTContext &C, CXXTemporary *Temp,
1507 Expr* SubExpr);
1508
1509 CXXTemporary *getTemporary() { return Temp; }
1510 const CXXTemporary *getTemporary() const { return Temp; }
1511 void setTemporary(CXXTemporary *T) { Temp = T; }
1512
1513 const Expr *getSubExpr() const { return cast<Expr>(SubExpr); }
1514 Expr *getSubExpr() { return cast<Expr>(SubExpr); }
1515 void setSubExpr(Expr *E) { SubExpr = E; }
1516
1517 SourceLocation getBeginLoc() const LLVM_READONLY {
1518 return SubExpr->getBeginLoc();
1519 }
1520
1521 SourceLocation getEndLoc() const LLVM_READONLY {
1522 return SubExpr->getEndLoc();
1523 }
1524
1525 // Implement isa/cast/dyncast/etc.
1526 static bool classof(const Stmt *T) {
1527 return T->getStmtClass() == CXXBindTemporaryExprClass;
1528 }
1529
1530 // Iterators
1531 child_range children() { return child_range(&SubExpr, &SubExpr + 1); }
1532
1534 return const_child_range(&SubExpr, &SubExpr + 1);
1535 }
1536};
1537
1539 Complete,
1543};
1544
1545/// Represents a call to a C++ constructor.
1546class CXXConstructExpr : public Expr {
1547 friend class ASTStmtReader;
1548
1549 /// A pointer to the constructor which will be ultimately called.
1550 CXXConstructorDecl *Constructor;
1551
1552 SourceRange ParenOrBraceRange;
1553
1554 /// The number of arguments.
1555 unsigned NumArgs;
1556
1557 // We would like to stash the arguments of the constructor call after
1558 // CXXConstructExpr. However CXXConstructExpr is used as a base class of
1559 // CXXTemporaryObjectExpr which makes the use of llvm::TrailingObjects
1560 // impossible.
1561 //
1562 // Instead we manually stash the trailing object after the full object
1563 // containing CXXConstructExpr (that is either CXXConstructExpr or
1564 // CXXTemporaryObjectExpr).
1565 //
1566 // The trailing objects are:
1567 //
1568 // * An array of getNumArgs() "Stmt *" for the arguments of the
1569 // constructor call.
1570
1571 /// Return a pointer to the start of the trailing arguments.
1572 /// Defined just after CXXTemporaryObjectExpr.
1573 inline Stmt **getTrailingArgs();
1574 const Stmt *const *getTrailingArgs() const {
1575 return const_cast<CXXConstructExpr *>(this)->getTrailingArgs();
1576 }
1577
1578protected:
1579 /// Build a C++ construction expression.
1581 CXXConstructorDecl *Ctor, bool Elidable,
1582 ArrayRef<Expr *> Args, bool HadMultipleCandidates,
1583 bool ListInitialization, bool StdInitListInitialization,
1584 bool ZeroInitialization, CXXConstructionKind ConstructKind,
1585 SourceRange ParenOrBraceRange);
1586
1587 /// Build an empty C++ construction expression.
1588 CXXConstructExpr(StmtClass SC, EmptyShell Empty, unsigned NumArgs);
1589
1590 /// Return the size in bytes of the trailing objects. Used by
1591 /// CXXTemporaryObjectExpr to allocate the right amount of storage.
1592 static unsigned sizeOfTrailingObjects(unsigned NumArgs) {
1593 return NumArgs * sizeof(Stmt *);
1594 }
1595
1596public:
1597 /// Create a C++ construction expression.
1598 static CXXConstructExpr *
1600 CXXConstructorDecl *Ctor, bool Elidable, ArrayRef<Expr *> Args,
1601 bool HadMultipleCandidates, bool ListInitialization,
1602 bool StdInitListInitialization, bool ZeroInitialization,
1603 CXXConstructionKind ConstructKind, SourceRange ParenOrBraceRange);
1604
1605 /// Create an empty C++ construction expression.
1606 static CXXConstructExpr *CreateEmpty(const ASTContext &Ctx, unsigned NumArgs);
1607
1608 /// Get the constructor that this expression will (ultimately) call.
1609 CXXConstructorDecl *getConstructor() const { return Constructor; }
1610
1613
1614 /// Whether this construction is elidable.
1615 bool isElidable() const { return CXXConstructExprBits.Elidable; }
1616 void setElidable(bool E) { CXXConstructExprBits.Elidable = E; }
1617
1618 /// Whether the referred constructor was resolved from
1619 /// an overloaded set having size greater than 1.
1621 return CXXConstructExprBits.HadMultipleCandidates;
1622 }
1624 CXXConstructExprBits.HadMultipleCandidates = V;
1625 }
1626
1627 /// Whether this constructor call was written as list-initialization.
1629 return CXXConstructExprBits.ListInitialization;
1630 }
1632 CXXConstructExprBits.ListInitialization = V;
1633 }
1634
1635 /// Whether this constructor call was written as list-initialization,
1636 /// but was interpreted as forming a std::initializer_list<T> from the list
1637 /// and passing that as a single constructor argument.
1638 /// See C++11 [over.match.list]p1 bullet 1.
1640 return CXXConstructExprBits.StdInitListInitialization;
1641 }
1643 CXXConstructExprBits.StdInitListInitialization = V;
1644 }
1645
1646 /// Whether this construction first requires
1647 /// zero-initialization before the initializer is called.
1649 return CXXConstructExprBits.ZeroInitialization;
1650 }
1651 void setRequiresZeroInitialization(bool ZeroInit) {
1652 CXXConstructExprBits.ZeroInitialization = ZeroInit;
1653 }
1654
1655 /// Determine whether this constructor is actually constructing
1656 /// a base class (rather than a complete object).
1658 return static_cast<CXXConstructionKind>(
1659 CXXConstructExprBits.ConstructionKind);
1660 }
1662 CXXConstructExprBits.ConstructionKind = llvm::to_underlying(CK);
1663 }
1664
1667 using arg_range = llvm::iterator_range<arg_iterator>;
1668 using const_arg_range = llvm::iterator_range<const_arg_iterator>;
1669
1672 return const_arg_range(arg_begin(), arg_end());
1673 }
1674
1675 arg_iterator arg_begin() { return getTrailingArgs(); }
1677 const_arg_iterator arg_begin() const { return getTrailingArgs(); }
1679
1680 Expr **getArgs() { return reinterpret_cast<Expr **>(getTrailingArgs()); }
1681 const Expr *const *getArgs() const {
1682 return reinterpret_cast<const Expr *const *>(getTrailingArgs());
1683 }
1684
1685 /// Return the number of arguments to the constructor call.
1686 unsigned getNumArgs() const { return NumArgs; }
1687
1688 /// Return the specified argument.
1689 Expr *getArg(unsigned Arg) {
1690 assert(Arg < getNumArgs() && "Arg access out of range!");
1691 return getArgs()[Arg];
1692 }
1693 const Expr *getArg(unsigned Arg) const {
1694 assert(Arg < getNumArgs() && "Arg access out of range!");
1695 return getArgs()[Arg];
1696 }
1697
1698 /// Set the specified argument.
1699 void setArg(unsigned Arg, Expr *ArgExpr) {
1700 assert(Arg < getNumArgs() && "Arg access out of range!");
1701 getArgs()[Arg] = ArgExpr;
1702 }
1703
1705 return CXXConstructExprBits.IsImmediateEscalating;
1706 }
1707
1709 CXXConstructExprBits.IsImmediateEscalating = Set;
1710 }
1711
1712 SourceLocation getBeginLoc() const LLVM_READONLY;
1713 SourceLocation getEndLoc() const LLVM_READONLY;
1714 SourceRange getParenOrBraceRange() const { return ParenOrBraceRange; }
1715 void setParenOrBraceRange(SourceRange Range) { ParenOrBraceRange = Range; }
1716
1717 static bool classof(const Stmt *T) {
1718 return T->getStmtClass() == CXXConstructExprClass ||
1719 T->getStmtClass() == CXXTemporaryObjectExprClass;
1720 }
1721
1722 // Iterators
1724 return child_range(getTrailingArgs(), getTrailingArgs() + getNumArgs());
1725 }
1726
1728 auto Children = const_cast<CXXConstructExpr *>(this)->children();
1729 return const_child_range(Children.begin(), Children.end());
1730 }
1731};
1732
1733/// Represents a call to an inherited base class constructor from an
1734/// inheriting constructor. This call implicitly forwards the arguments from
1735/// the enclosing context (an inheriting constructor) to the specified inherited
1736/// base class constructor.
1738private:
1739 CXXConstructorDecl *Constructor = nullptr;
1740
1741 /// The location of the using declaration.
1743
1744 /// Whether this is the construction of a virtual base.
1745 LLVM_PREFERRED_TYPE(bool)
1746 unsigned ConstructsVirtualBase : 1;
1747
1748 /// Whether the constructor is inherited from a virtual base class of the
1749 /// class that we construct.
1750 LLVM_PREFERRED_TYPE(bool)
1751 unsigned InheritedFromVirtualBase : 1;
1752
1753public:
1754 friend class ASTStmtReader;
1755
1756 /// Construct a C++ inheriting construction expression.
1758 CXXConstructorDecl *Ctor, bool ConstructsVirtualBase,
1759 bool InheritedFromVirtualBase)
1760 : Expr(CXXInheritedCtorInitExprClass, T, VK_PRValue, OK_Ordinary),
1761 Constructor(Ctor), Loc(Loc),
1762 ConstructsVirtualBase(ConstructsVirtualBase),
1763 InheritedFromVirtualBase(InheritedFromVirtualBase) {
1764 assert(!T->isDependentType());
1765 setDependence(ExprDependence::None);
1766 }
1767
1768 /// Construct an empty C++ inheriting construction expression.
1770 : Expr(CXXInheritedCtorInitExprClass, Empty),
1771 ConstructsVirtualBase(false), InheritedFromVirtualBase(false) {}
1772
1773 /// Get the constructor that this expression will call.
1774 CXXConstructorDecl *getConstructor() const { return Constructor; }
1775
1776 /// Determine whether this constructor is actually constructing
1777 /// a base class (rather than a complete object).
1778 bool constructsVBase() const { return ConstructsVirtualBase; }
1780 return ConstructsVirtualBase ? CXXConstructionKind::VirtualBase
1782 }
1783
1784 /// Determine whether the inherited constructor is inherited from a
1785 /// virtual base of the object we construct. If so, we are not responsible
1786 /// for calling the inherited constructor (the complete object constructor
1787 /// does that), and so we don't need to pass any arguments.
1788 bool inheritedFromVBase() const { return InheritedFromVirtualBase; }
1789
1790 SourceLocation getLocation() const LLVM_READONLY { return Loc; }
1791 SourceLocation getBeginLoc() const LLVM_READONLY { return Loc; }
1792 SourceLocation getEndLoc() const LLVM_READONLY { return Loc; }
1793
1794 static bool classof(const Stmt *T) {
1795 return T->getStmtClass() == CXXInheritedCtorInitExprClass;
1796 }
1797
1800 }
1801
1804 }
1805};
1806
1807/// Represents an explicit C++ type conversion that uses "functional"
1808/// notation (C++ [expr.type.conv]).
1809///
1810/// Example:
1811/// \code
1812/// x = int(0.5);
1813/// \endcode
1815 : public ExplicitCastExpr,
1816 private llvm::TrailingObjects<CXXFunctionalCastExpr, CXXBaseSpecifier *,
1817 FPOptionsOverride> {
1818 SourceLocation LParenLoc;
1819 SourceLocation RParenLoc;
1820
1822 TypeSourceInfo *writtenTy, CastKind kind,
1823 Expr *castExpr, unsigned pathSize,
1824 FPOptionsOverride FPO, SourceLocation lParenLoc,
1825 SourceLocation rParenLoc)
1826 : ExplicitCastExpr(CXXFunctionalCastExprClass, ty, VK, kind, castExpr,
1827 pathSize, FPO.requiresTrailingStorage(), writtenTy),
1828 LParenLoc(lParenLoc), RParenLoc(rParenLoc) {
1829 if (hasStoredFPFeatures())
1830 *getTrailingFPFeatures() = FPO;
1831 }
1832
1833 explicit CXXFunctionalCastExpr(EmptyShell Shell, unsigned PathSize,
1834 bool HasFPFeatures)
1835 : ExplicitCastExpr(CXXFunctionalCastExprClass, Shell, PathSize,
1836 HasFPFeatures) {}
1837
1838 unsigned numTrailingObjects(OverloadToken<CXXBaseSpecifier *>) const {
1839 return path_size();
1840 }
1841
1842public:
1843 friend class CastExpr;
1845
1846 static CXXFunctionalCastExpr *
1847 Create(const ASTContext &Context, QualType T, ExprValueKind VK,
1848 TypeSourceInfo *Written, CastKind Kind, Expr *Op,
1850 SourceLocation RPLoc);
1851 static CXXFunctionalCastExpr *
1852 CreateEmpty(const ASTContext &Context, unsigned PathSize, bool HasFPFeatures);
1853
1854 SourceLocation getLParenLoc() const { return LParenLoc; }
1855 void setLParenLoc(SourceLocation L) { LParenLoc = L; }
1856 SourceLocation getRParenLoc() const { return RParenLoc; }
1857 void setRParenLoc(SourceLocation L) { RParenLoc = L; }
1858
1859 /// Determine whether this expression models list-initialization.
1860 bool isListInitialization() const { return LParenLoc.isInvalid(); }
1861
1862 SourceLocation getBeginLoc() const LLVM_READONLY;
1863 SourceLocation getEndLoc() const LLVM_READONLY;
1864
1865 static bool classof(const Stmt *T) {
1866 return T->getStmtClass() == CXXFunctionalCastExprClass;
1867 }
1868};
1869
1870/// Represents a C++ functional cast expression that builds a
1871/// temporary object.
1872///
1873/// This expression type represents a C++ "functional" cast
1874/// (C++[expr.type.conv]) with N != 1 arguments that invokes a
1875/// constructor to build a temporary object. With N == 1 arguments the
1876/// functional cast expression will be represented by CXXFunctionalCastExpr.
1877/// Example:
1878/// \code
1879/// struct X { X(int, float); }
1880///
1881/// X create_X() {
1882/// return X(1, 3.14f); // creates a CXXTemporaryObjectExpr
1883/// };
1884/// \endcode
1886 friend class ASTStmtReader;
1887
1888 // CXXTemporaryObjectExpr has some trailing objects belonging
1889 // to CXXConstructExpr. See the comment inside CXXConstructExpr
1890 // for more details.
1891
1892 TypeSourceInfo *TSI;
1893
1896 SourceRange ParenOrBraceRange,
1897 bool HadMultipleCandidates, bool ListInitialization,
1898 bool StdInitListInitialization,
1899 bool ZeroInitialization);
1900
1901 CXXTemporaryObjectExpr(EmptyShell Empty, unsigned NumArgs);
1902
1903public:
1904 static CXXTemporaryObjectExpr *
1905 Create(const ASTContext &Ctx, CXXConstructorDecl *Cons, QualType Ty,
1907 SourceRange ParenOrBraceRange, bool HadMultipleCandidates,
1908 bool ListInitialization, bool StdInitListInitialization,
1909 bool ZeroInitialization);
1910
1912 unsigned NumArgs);
1913
1914 TypeSourceInfo *getTypeSourceInfo() const { return TSI; }
1915
1916 SourceLocation getBeginLoc() const LLVM_READONLY;
1917 SourceLocation getEndLoc() const LLVM_READONLY;
1918
1919 static bool classof(const Stmt *T) {
1920 return T->getStmtClass() == CXXTemporaryObjectExprClass;
1921 }
1922};
1923
1924Stmt **CXXConstructExpr::getTrailingArgs() {
1925 if (auto *E = dyn_cast<CXXTemporaryObjectExpr>(this))
1926 return reinterpret_cast<Stmt **>(E + 1);
1927 assert((getStmtClass() == CXXConstructExprClass) &&
1928 "Unexpected class deriving from CXXConstructExpr!");
1929 return reinterpret_cast<Stmt **>(this + 1);
1930}
1931
1932/// A C++ lambda expression, which produces a function object
1933/// (of unspecified type) that can be invoked later.
1934///
1935/// Example:
1936/// \code
1937/// void low_pass_filter(std::vector<double> &values, double cutoff) {
1938/// values.erase(std::remove_if(values.begin(), values.end(),
1939/// [=](double value) { return value > cutoff; });
1940/// }
1941/// \endcode
1942///
1943/// C++11 lambda expressions can capture local variables, either by copying
1944/// the values of those local variables at the time the function
1945/// object is constructed (not when it is called!) or by holding a
1946/// reference to the local variable. These captures can occur either
1947/// implicitly or can be written explicitly between the square
1948/// brackets ([...]) that start the lambda expression.
1949///
1950/// C++1y introduces a new form of "capture" called an init-capture that
1951/// includes an initializing expression (rather than capturing a variable),
1952/// and which can never occur implicitly.
1953class LambdaExpr final : public Expr,
1954 private llvm::TrailingObjects<LambdaExpr, Stmt *> {
1955 // LambdaExpr has some data stored in LambdaExprBits.
1956
1957 /// The source range that covers the lambda introducer ([...]).
1958 SourceRange IntroducerRange;
1959
1960 /// The source location of this lambda's capture-default ('=' or '&').
1961 SourceLocation CaptureDefaultLoc;
1962
1963 /// The location of the closing brace ('}') that completes
1964 /// the lambda.
1965 ///
1966 /// The location of the brace is also available by looking up the
1967 /// function call operator in the lambda class. However, it is
1968 /// stored here to improve the performance of getSourceRange(), and
1969 /// to avoid having to deserialize the function call operator from a
1970 /// module file just to determine the source range.
1971 SourceLocation ClosingBrace;
1972
1973 /// Construct a lambda expression.
1974 LambdaExpr(QualType T, SourceRange IntroducerRange,
1975 LambdaCaptureDefault CaptureDefault,
1976 SourceLocation CaptureDefaultLoc, bool ExplicitParams,
1977 bool ExplicitResultType, ArrayRef<Expr *> CaptureInits,
1978 SourceLocation ClosingBrace, bool ContainsUnexpandedParameterPack);
1979
1980 /// Construct an empty lambda expression.
1981 LambdaExpr(EmptyShell Empty, unsigned NumCaptures);
1982
1983 Stmt **getStoredStmts() { return getTrailingObjects<Stmt *>(); }
1984 Stmt *const *getStoredStmts() const { return getTrailingObjects<Stmt *>(); }
1985
1986 void initBodyIfNeeded() const;
1987
1988public:
1989 friend class ASTStmtReader;
1990 friend class ASTStmtWriter;
1992
1993 /// Construct a new lambda expression.
1994 static LambdaExpr *
1995 Create(const ASTContext &C, CXXRecordDecl *Class, SourceRange IntroducerRange,
1996 LambdaCaptureDefault CaptureDefault, SourceLocation CaptureDefaultLoc,
1997 bool ExplicitParams, bool ExplicitResultType,
1998 ArrayRef<Expr *> CaptureInits, SourceLocation ClosingBrace,
1999 bool ContainsUnexpandedParameterPack);
2000
2001 /// Construct a new lambda expression that will be deserialized from
2002 /// an external source.
2004 unsigned NumCaptures);
2005
2006 /// Determine the default capture kind for this lambda.
2008 return static_cast<LambdaCaptureDefault>(LambdaExprBits.CaptureDefault);
2009 }
2010
2011 /// Retrieve the location of this lambda's capture-default, if any.
2012 SourceLocation getCaptureDefaultLoc() const { return CaptureDefaultLoc; }
2013
2014 /// Determine whether one of this lambda's captures is an init-capture.
2015 bool isInitCapture(const LambdaCapture *Capture) const;
2016
2017 /// An iterator that walks over the captures of the lambda,
2018 /// both implicit and explicit.
2020
2021 /// An iterator over a range of lambda captures.
2022 using capture_range = llvm::iterator_range<capture_iterator>;
2023
2024 /// Retrieve this lambda's captures.
2025 capture_range captures() const;
2026
2027 /// Retrieve an iterator pointing to the first lambda capture.
2029
2030 /// Retrieve an iterator pointing past the end of the
2031 /// sequence of lambda captures.
2033
2034 /// Determine the number of captures in this lambda.
2035 unsigned capture_size() const { return LambdaExprBits.NumCaptures; }
2036
2037 /// Retrieve this lambda's explicit captures.
2039
2040 /// Retrieve an iterator pointing to the first explicit
2041 /// lambda capture.
2043
2044 /// Retrieve an iterator pointing past the end of the sequence of
2045 /// explicit lambda captures.
2047
2048 /// Retrieve this lambda's implicit captures.
2050
2051 /// Retrieve an iterator pointing to the first implicit
2052 /// lambda capture.
2054
2055 /// Retrieve an iterator pointing past the end of the sequence of
2056 /// implicit lambda captures.
2058
2059 /// Iterator that walks over the capture initialization
2060 /// arguments.
2062
2063 /// Const iterator that walks over the capture initialization
2064 /// arguments.
2065 /// FIXME: This interface is prone to being used incorrectly.
2067
2068 /// Retrieve the initialization expressions for this lambda's captures.
2069 llvm::iterator_range<capture_init_iterator> capture_inits() {
2070 return llvm::make_range(capture_init_begin(), capture_init_end());
2071 }
2072
2073 /// Retrieve the initialization expressions for this lambda's captures.
2074 llvm::iterator_range<const_capture_init_iterator> capture_inits() const {
2075 return llvm::make_range(capture_init_begin(), capture_init_end());
2076 }
2077
2078 /// Retrieve the first initialization argument for this
2079 /// lambda expression (which initializes the first capture field).
2081 return reinterpret_cast<Expr **>(getStoredStmts());
2082 }
2083
2084 /// Retrieve the first initialization argument for this
2085 /// lambda expression (which initializes the first capture field).
2087 return reinterpret_cast<Expr *const *>(getStoredStmts());
2088 }
2089
2090 /// Retrieve the iterator pointing one past the last
2091 /// initialization argument for this lambda expression.
2093 return capture_init_begin() + capture_size();
2094 }
2095
2096 /// Retrieve the iterator pointing one past the last
2097 /// initialization argument for this lambda expression.
2099 return capture_init_begin() + capture_size();
2100 }
2101
2102 /// Retrieve the source range covering the lambda introducer,
2103 /// which contains the explicit capture list surrounded by square
2104 /// brackets ([...]).
2105 SourceRange getIntroducerRange() const { return IntroducerRange; }
2106
2107 /// Retrieve the class that corresponds to the lambda.
2108 ///
2109 /// This is the "closure type" (C++1y [expr.prim.lambda]), and stores the
2110 /// captures in its fields and provides the various operations permitted
2111 /// on a lambda (copying, calling).
2113
2114 /// Retrieve the function call operator associated with this
2115 /// lambda expression.
2117
2118 /// Retrieve the function template call operator associated with this
2119 /// lambda expression.
2121
2122 /// If this is a generic lambda expression, retrieve the template
2123 /// parameter list associated with it, or else return null.
2125
2126 /// Get the template parameters were explicitly specified (as opposed to being
2127 /// invented by use of an auto parameter).
2129
2130 /// Get the trailing requires clause, if any.
2132
2133 /// Whether this is a generic lambda.
2135
2136 /// Retrieve the body of the lambda. This will be most of the time
2137 /// a \p CompoundStmt, but can also be \p CoroutineBodyStmt wrapping
2138 /// a \p CompoundStmt. Note that unlike functions, lambda-expressions
2139 /// cannot have a function-try-block.
2140 Stmt *getBody() const;
2141
2142 /// Retrieve the \p CompoundStmt representing the body of the lambda.
2143 /// This is a convenience function for callers who do not need
2144 /// to handle node(s) which may wrap a \p CompoundStmt.
2145 const CompoundStmt *getCompoundStmtBody() const;
2147 const auto *ConstThis = this;
2148 return const_cast<CompoundStmt *>(ConstThis->getCompoundStmtBody());
2149 }
2150
2151 /// Determine whether the lambda is mutable, meaning that any
2152 /// captures values can be modified.
2153 bool isMutable() const;
2154
2155 /// Determine whether this lambda has an explicit parameter
2156 /// list vs. an implicit (empty) parameter list.
2157 bool hasExplicitParameters() const { return LambdaExprBits.ExplicitParams; }
2158
2159 /// Whether this lambda had its result type explicitly specified.
2161 return LambdaExprBits.ExplicitResultType;
2162 }
2163
2164 static bool classof(const Stmt *T) {
2165 return T->getStmtClass() == LambdaExprClass;
2166 }
2167
2168 SourceLocation getBeginLoc() const LLVM_READONLY {
2169 return IntroducerRange.getBegin();
2170 }
2171
2172 SourceLocation getEndLoc() const LLVM_READONLY { return ClosingBrace; }
2173
2174 /// Includes the captures and the body of the lambda.
2177};
2178
2179/// An expression "T()" which creates an rvalue of a non-class type T.
2180/// For non-void T, the rvalue is value-initialized.
2181/// See (C++98 [5.2.3p2]).
2183 friend class ASTStmtReader;
2184
2186
2187public:
2188 /// Create an explicitly-written scalar-value initialization
2189 /// expression.
2191 SourceLocation RParenLoc)
2192 : Expr(CXXScalarValueInitExprClass, Type, VK_PRValue, OK_Ordinary),
2194 CXXScalarValueInitExprBits.RParenLoc = RParenLoc;
2196 }
2197
2199 : Expr(CXXScalarValueInitExprClass, Shell) {}
2200
2202 return TypeInfo;
2203 }
2204
2206 return CXXScalarValueInitExprBits.RParenLoc;
2207 }
2208
2209 SourceLocation getBeginLoc() const LLVM_READONLY;
2211
2212 static bool classof(const Stmt *T) {
2213 return T->getStmtClass() == CXXScalarValueInitExprClass;
2214 }
2215
2216 // Iterators
2219 }
2220
2223 }
2224};
2225
2227 /// New-expression has no initializer as written.
2228 None,
2229
2230 /// New-expression has a C++98 paren-delimited initializer.
2231 Parens,
2232
2233 /// New-expression has a C++11 list-initializer.
2234 Braces
2235};
2236
2237/// Represents a new-expression for memory allocation and constructor
2238/// calls, e.g: "new CXXNewExpr(foo)".
2239class CXXNewExpr final
2240 : public Expr,
2241 private llvm::TrailingObjects<CXXNewExpr, Stmt *, SourceRange> {
2242 friend class ASTStmtReader;
2243 friend class ASTStmtWriter;
2244 friend TrailingObjects;
2245
2246 /// Points to the allocation function used.
2247 FunctionDecl *OperatorNew;
2248
2249 /// Points to the deallocation function used in case of error. May be null.
2250 FunctionDecl *OperatorDelete;
2251
2252 /// The allocated type-source information, as written in the source.
2253 TypeSourceInfo *AllocatedTypeInfo;
2254
2255 /// Range of the entire new expression.
2257
2258 /// Source-range of a paren-delimited initializer.
2259 SourceRange DirectInitRange;
2260
2261 // CXXNewExpr is followed by several optional trailing objects.
2262 // They are in order:
2263 //
2264 // * An optional "Stmt *" for the array size expression.
2265 // Present if and ony if isArray().
2266 //
2267 // * An optional "Stmt *" for the init expression.
2268 // Present if and only if hasInitializer().
2269 //
2270 // * An array of getNumPlacementArgs() "Stmt *" for the placement new
2271 // arguments, if any.
2272 //
2273 // * An optional SourceRange for the range covering the parenthesized type-id
2274 // if the allocated type was expressed as a parenthesized type-id.
2275 // Present if and only if isParenTypeId().
2276 unsigned arraySizeOffset() const { return 0; }
2277 unsigned initExprOffset() const { return arraySizeOffset() + isArray(); }
2278 unsigned placementNewArgsOffset() const {
2279 return initExprOffset() + hasInitializer();
2280 }
2281
2282 unsigned numTrailingObjects(OverloadToken<Stmt *>) const {
2284 }
2285
2286 unsigned numTrailingObjects(OverloadToken<SourceRange>) const {
2287 return isParenTypeId();
2288 }
2289
2290 /// Build a c++ new expression.
2291 CXXNewExpr(bool IsGlobalNew, FunctionDecl *OperatorNew,
2292 FunctionDecl *OperatorDelete, bool ShouldPassAlignment,
2293 bool UsualArrayDeleteWantsSize, ArrayRef<Expr *> PlacementArgs,
2294 SourceRange TypeIdParens, std::optional<Expr *> ArraySize,
2295 CXXNewInitializationStyle InitializationStyle, Expr *Initializer,
2296 QualType Ty, TypeSourceInfo *AllocatedTypeInfo, SourceRange Range,
2297 SourceRange DirectInitRange);
2298
2299 /// Build an empty c++ new expression.
2300 CXXNewExpr(EmptyShell Empty, bool IsArray, unsigned NumPlacementArgs,
2301 bool IsParenTypeId);
2302
2303public:
2304 /// Create a c++ new expression.
2305 static CXXNewExpr *
2306 Create(const ASTContext &Ctx, bool IsGlobalNew, FunctionDecl *OperatorNew,
2307 FunctionDecl *OperatorDelete, bool ShouldPassAlignment,
2308 bool UsualArrayDeleteWantsSize, ArrayRef<Expr *> PlacementArgs,
2309 SourceRange TypeIdParens, std::optional<Expr *> ArraySize,
2310 CXXNewInitializationStyle InitializationStyle, Expr *Initializer,
2311 QualType Ty, TypeSourceInfo *AllocatedTypeInfo, SourceRange Range,
2312 SourceRange DirectInitRange);
2313
2314 /// Create an empty c++ new expression.
2315 static CXXNewExpr *CreateEmpty(const ASTContext &Ctx, bool IsArray,
2316 bool HasInit, unsigned NumPlacementArgs,
2317 bool IsParenTypeId);
2318
2320 return getType()->castAs<PointerType>()->getPointeeType();
2321 }
2322
2324 return AllocatedTypeInfo;
2325 }
2326
2327 /// True if the allocation result needs to be null-checked.
2328 ///
2329 /// C++11 [expr.new]p13:
2330 /// If the allocation function returns null, initialization shall
2331 /// not be done, the deallocation function shall not be called,
2332 /// and the value of the new-expression shall be null.
2333 ///
2334 /// C++ DR1748:
2335 /// If the allocation function is a reserved placement allocation
2336 /// function that returns null, the behavior is undefined.
2337 ///
2338 /// An allocation function is not allowed to return null unless it
2339 /// has a non-throwing exception-specification. The '03 rule is
2340 /// identical except that the definition of a non-throwing
2341 /// exception specification is just "is it throw()?".
2342 bool shouldNullCheckAllocation() const;
2343
2344 FunctionDecl *getOperatorNew() const { return OperatorNew; }
2345 void setOperatorNew(FunctionDecl *D) { OperatorNew = D; }
2346 FunctionDecl *getOperatorDelete() const { return OperatorDelete; }
2347 void setOperatorDelete(FunctionDecl *D) { OperatorDelete = D; }
2348
2349 bool isArray() const { return CXXNewExprBits.IsArray; }
2350
2351 /// This might return std::nullopt even if isArray() returns true,
2352 /// since there might not be an array size expression.
2353 /// If the result is not std::nullopt, it will never wrap a nullptr.
2354 std::optional<Expr *> getArraySize() {
2355 if (!isArray())
2356 return std::nullopt;
2357
2358 if (auto *Result =
2359 cast_or_null<Expr>(getTrailingObjects<Stmt *>()[arraySizeOffset()]))
2360 return Result;
2361
2362 return std::nullopt;
2363 }
2364
2365 /// This might return std::nullopt even if isArray() returns true,
2366 /// since there might not be an array size expression.
2367 /// If the result is not std::nullopt, it will never wrap a nullptr.
2368 std::optional<const Expr *> getArraySize() const {
2369 if (!isArray())
2370 return std::nullopt;
2371
2372 if (auto *Result =
2373 cast_or_null<Expr>(getTrailingObjects<Stmt *>()[arraySizeOffset()]))
2374 return Result;
2375
2376 return std::nullopt;
2377 }
2378
2379 unsigned getNumPlacementArgs() const {
2380 return CXXNewExprBits.NumPlacementArgs;
2381 }
2382
2384 return reinterpret_cast<Expr **>(getTrailingObjects<Stmt *>() +
2385 placementNewArgsOffset());
2386 }
2387
2388 Expr *getPlacementArg(unsigned I) {
2389 assert((I < getNumPlacementArgs()) && "Index out of range!");
2390 return getPlacementArgs()[I];
2391 }
2392 const Expr *getPlacementArg(unsigned I) const {
2393 return const_cast<CXXNewExpr *>(this)->getPlacementArg(I);
2394 }
2395
2396 bool isParenTypeId() const { return CXXNewExprBits.IsParenTypeId; }
2398 return isParenTypeId() ? getTrailingObjects<SourceRange>()[0]
2399 : SourceRange();
2400 }
2401
2402 bool isGlobalNew() const { return CXXNewExprBits.IsGlobalNew; }
2403
2404 /// Whether this new-expression has any initializer at all.
2405 bool hasInitializer() const { return CXXNewExprBits.HasInitializer; }
2406
2407 /// The kind of initializer this new-expression has.
2409 return static_cast<CXXNewInitializationStyle>(
2410 CXXNewExprBits.StoredInitializationStyle);
2411 }
2412
2413 /// The initializer of this new-expression.
2415 return hasInitializer()
2416 ? cast<Expr>(getTrailingObjects<Stmt *>()[initExprOffset()])
2417 : nullptr;
2418 }
2419 const Expr *getInitializer() const {
2420 return hasInitializer()
2421 ? cast<Expr>(getTrailingObjects<Stmt *>()[initExprOffset()])
2422 : nullptr;
2423 }
2424
2425 /// Returns the CXXConstructExpr from this new-expression, or null.
2427 return dyn_cast_or_null<CXXConstructExpr>(getInitializer());
2428 }
2429
2430 /// Indicates whether the required alignment should be implicitly passed to
2431 /// the allocation function.
2432 bool passAlignment() const { return CXXNewExprBits.ShouldPassAlignment; }
2433
2434 /// Answers whether the usual array deallocation function for the
2435 /// allocated type expects the size of the allocation as a
2436 /// parameter.
2438 return CXXNewExprBits.UsualArrayDeleteWantsSize;
2439 }
2440
2443
2444 llvm::iterator_range<arg_iterator> placement_arguments() {
2445 return llvm::make_range(placement_arg_begin(), placement_arg_end());
2446 }
2447
2448 llvm::iterator_range<const_arg_iterator> placement_arguments() const {
2449 return llvm::make_range(placement_arg_begin(), placement_arg_end());
2450 }
2451
2453 return getTrailingObjects<Stmt *>() + placementNewArgsOffset();
2454 }
2457 }
2459 return getTrailingObjects<Stmt *>() + placementNewArgsOffset();
2460 }
2463 }
2464
2466
2467 raw_arg_iterator raw_arg_begin() { return getTrailingObjects<Stmt *>(); }
2469 return raw_arg_begin() + numTrailingObjects(OverloadToken<Stmt *>());
2470 }
2472 return getTrailingObjects<Stmt *>();
2473 }
2475 return raw_arg_begin() + numTrailingObjects(OverloadToken<Stmt *>());
2476 }
2477
2478 SourceLocation getBeginLoc() const { return Range.getBegin(); }
2479 SourceLocation getEndLoc() const { return Range.getEnd(); }
2480
2481 SourceRange getDirectInitRange() const { return DirectInitRange; }
2483
2484 static bool classof(const Stmt *T) {
2485 return T->getStmtClass() == CXXNewExprClass;
2486 }
2487
2488 // Iterators
2490
2492 return const_child_range(const_cast<CXXNewExpr *>(this)->children());
2493 }
2494};
2495
2496/// Represents a \c delete expression for memory deallocation and
2497/// destructor calls, e.g. "delete[] pArray".
2498class CXXDeleteExpr : public Expr {
2499 friend class ASTStmtReader;
2500
2501 /// Points to the operator delete overload that is used. Could be a member.
2502 FunctionDecl *OperatorDelete = nullptr;
2503
2504 /// The pointer expression to be deleted.
2505 Stmt *Argument = nullptr;
2506
2507public:
2508 CXXDeleteExpr(QualType Ty, bool GlobalDelete, bool ArrayForm,
2509 bool ArrayFormAsWritten, bool UsualArrayDeleteWantsSize,
2510 FunctionDecl *OperatorDelete, Expr *Arg, SourceLocation Loc)
2511 : Expr(CXXDeleteExprClass, Ty, VK_PRValue, OK_Ordinary),
2512 OperatorDelete(OperatorDelete), Argument(Arg) {
2513 CXXDeleteExprBits.GlobalDelete = GlobalDelete;
2514 CXXDeleteExprBits.ArrayForm = ArrayForm;
2515 CXXDeleteExprBits.ArrayFormAsWritten = ArrayFormAsWritten;
2516 CXXDeleteExprBits.UsualArrayDeleteWantsSize = UsualArrayDeleteWantsSize;
2517 CXXDeleteExprBits.Loc = Loc;
2519 }
2520
2521 explicit CXXDeleteExpr(EmptyShell Shell) : Expr(CXXDeleteExprClass, Shell) {}
2522
2523 bool isGlobalDelete() const { return CXXDeleteExprBits.GlobalDelete; }
2524 bool isArrayForm() const { return CXXDeleteExprBits.ArrayForm; }
2526 return CXXDeleteExprBits.ArrayFormAsWritten;
2527 }
2528
2529 /// Answers whether the usual array deallocation function for the
2530 /// allocated type expects the size of the allocation as a
2531 /// parameter. This can be true even if the actual deallocation
2532 /// function that we're using doesn't want a size.
2534 return CXXDeleteExprBits.UsualArrayDeleteWantsSize;
2535 }
2536
2537 FunctionDecl *getOperatorDelete() const { return OperatorDelete; }
2538
2539 Expr *getArgument() { return cast<Expr>(Argument); }
2540 const Expr *getArgument() const { return cast<Expr>(Argument); }
2541
2542 /// Retrieve the type being destroyed.
2543 ///
2544 /// If the type being destroyed is a dependent type which may or may not
2545 /// be a pointer, return an invalid type.
2546 QualType getDestroyedType() const;
2547
2549 SourceLocation getEndLoc() const LLVM_READONLY {
2550 return Argument->getEndLoc();
2551 }
2552
2553 static bool classof(const Stmt *T) {
2554 return T->getStmtClass() == CXXDeleteExprClass;
2555 }
2556
2557 // Iterators
2558 child_range children() { return child_range(&Argument, &Argument + 1); }
2559
2561 return const_child_range(&Argument, &Argument + 1);
2562 }
2563};
2564
2565/// Stores the type being destroyed by a pseudo-destructor expression.
2567 /// Either the type source information or the name of the type, if
2568 /// it couldn't be resolved due to type-dependence.
2569 llvm::PointerUnion<TypeSourceInfo *, const IdentifierInfo *> Type;
2570
2571 /// The starting source location of the pseudo-destructor type.
2572 SourceLocation Location;
2573
2574public:
2576
2578 : Type(II), Location(Loc) {}
2579
2581
2583 return Type.dyn_cast<TypeSourceInfo *>();
2584 }
2585
2587 return Type.dyn_cast<const IdentifierInfo *>();
2588 }
2589
2590 SourceLocation getLocation() const { return Location; }
2591};
2592
2593/// Represents a C++ pseudo-destructor (C++ [expr.pseudo]).
2594///
2595/// A pseudo-destructor is an expression that looks like a member access to a
2596/// destructor of a scalar type, except that scalar types don't have
2597/// destructors. For example:
2598///
2599/// \code
2600/// typedef int T;
2601/// void f(int *p) {
2602/// p->T::~T();
2603/// }
2604/// \endcode
2605///
2606/// Pseudo-destructors typically occur when instantiating templates such as:
2607///
2608/// \code
2609/// template<typename T>
2610/// void destroy(T* ptr) {
2611/// ptr->T::~T();
2612/// }
2613/// \endcode
2614///
2615/// for scalar types. A pseudo-destructor expression has no run-time semantics
2616/// beyond evaluating the base expression.
2618 friend class ASTStmtReader;
2619
2620 /// The base expression (that is being destroyed).
2621 Stmt *Base = nullptr;
2622
2623 /// Whether the operator was an arrow ('->'); otherwise, it was a
2624 /// period ('.').
2625 LLVM_PREFERRED_TYPE(bool)
2626 bool IsArrow : 1;
2627
2628 /// The location of the '.' or '->' operator.
2629 SourceLocation OperatorLoc;
2630
2631 /// The nested-name-specifier that follows the operator, if present.
2632 NestedNameSpecifierLoc QualifierLoc;
2633
2634 /// The type that precedes the '::' in a qualified pseudo-destructor
2635 /// expression.
2636 TypeSourceInfo *ScopeType = nullptr;
2637
2638 /// The location of the '::' in a qualified pseudo-destructor
2639 /// expression.
2640 SourceLocation ColonColonLoc;
2641
2642 /// The location of the '~'.
2643 SourceLocation TildeLoc;
2644
2645 /// The type being destroyed, or its name if we were unable to
2646 /// resolve the name.
2647 PseudoDestructorTypeStorage DestroyedType;
2648
2649public:
2650 CXXPseudoDestructorExpr(const ASTContext &Context,
2651 Expr *Base, bool isArrow, SourceLocation OperatorLoc,
2652 NestedNameSpecifierLoc QualifierLoc,
2653 TypeSourceInfo *ScopeType,
2654 SourceLocation ColonColonLoc,
2655 SourceLocation TildeLoc,
2656 PseudoDestructorTypeStorage DestroyedType);
2657
2659 : Expr(CXXPseudoDestructorExprClass, Shell), IsArrow(false) {}
2660
2661 Expr *getBase() const { return cast<Expr>(Base); }
2662
2663 /// Determines whether this member expression actually had
2664 /// a C++ nested-name-specifier prior to the name of the member, e.g.,
2665 /// x->Base::foo.
2666 bool hasQualifier() const { return QualifierLoc.hasQualifier(); }
2667
2668 /// Retrieves the nested-name-specifier that qualifies the type name,
2669 /// with source-location information.
2670 NestedNameSpecifierLoc getQualifierLoc() const { return QualifierLoc; }
2671
2672 /// If the member name was qualified, retrieves the
2673 /// nested-name-specifier that precedes the member name. Otherwise, returns
2674 /// null.
2676 return QualifierLoc.getNestedNameSpecifier();
2677 }
2678
2679 /// Determine whether this pseudo-destructor expression was written
2680 /// using an '->' (otherwise, it used a '.').
2681 bool isArrow() const { return IsArrow; }
2682
2683 /// Retrieve the location of the '.' or '->' operator.
2684 SourceLocation getOperatorLoc() const { return OperatorLoc; }
2685
2686 /// Retrieve the scope type in a qualified pseudo-destructor
2687 /// expression.
2688 ///
2689 /// Pseudo-destructor expressions can have extra qualification within them
2690 /// that is not part of the nested-name-specifier, e.g., \c p->T::~T().
2691 /// Here, if the object type of the expression is (or may be) a scalar type,
2692 /// \p T may also be a scalar type and, therefore, cannot be part of a
2693 /// nested-name-specifier. It is stored as the "scope type" of the pseudo-
2694 /// destructor expression.
2695 TypeSourceInfo *getScopeTypeInfo() const { return ScopeType; }
2696
2697 /// Retrieve the location of the '::' in a qualified pseudo-destructor
2698 /// expression.
2699 SourceLocation getColonColonLoc() const { return ColonColonLoc; }
2700
2701 /// Retrieve the location of the '~'.
2702 SourceLocation getTildeLoc() const { return TildeLoc; }
2703
2704 /// Retrieve the source location information for the type
2705 /// being destroyed.
2706 ///
2707 /// This type-source information is available for non-dependent
2708 /// pseudo-destructor expressions and some dependent pseudo-destructor
2709 /// expressions. Returns null if we only have the identifier for a
2710 /// dependent pseudo-destructor expression.
2712 return DestroyedType.getTypeSourceInfo();
2713 }
2714
2715 /// In a dependent pseudo-destructor expression for which we do not
2716 /// have full type information on the destroyed type, provides the name
2717 /// of the destroyed type.
2719 return DestroyedType.getIdentifier();
2720 }
2721
2722 /// Retrieve the type being destroyed.
2723 QualType getDestroyedType() const;
2724
2725 /// Retrieve the starting location of the type being destroyed.
2727 return DestroyedType.getLocation();
2728 }
2729
2730 /// Set the name of destroyed type for a dependent pseudo-destructor
2731 /// expression.
2733 DestroyedType = PseudoDestructorTypeStorage(II, Loc);
2734 }
2735
2736 /// Set the destroyed type.
2738 DestroyedType = PseudoDestructorTypeStorage(Info);
2739 }
2740
2741 SourceLocation getBeginLoc() const LLVM_READONLY {
2742 return Base->getBeginLoc();
2743 }
2744 SourceLocation getEndLoc() const LLVM_READONLY;
2745
2746 static bool classof(const Stmt *T) {
2747 return T->getStmtClass() == CXXPseudoDestructorExprClass;
2748 }
2749
2750 // Iterators
2752
2754 return const_child_range(&Base, &Base + 1);
2755 }
2756};
2757
2758/// A type trait used in the implementation of various C++11 and
2759/// Library TR1 trait templates.
2760///
2761/// \code
2762/// __is_pod(int) == true
2763/// __is_enum(std::string) == false
2764/// __is_trivially_constructible(vector<int>, int*, int*)
2765/// \endcode
2766class TypeTraitExpr final
2767 : public Expr,
2768 private llvm::TrailingObjects<TypeTraitExpr, TypeSourceInfo *> {
2769 /// The location of the type trait keyword.
2771
2772 /// The location of the closing parenthesis.
2773 SourceLocation RParenLoc;
2774
2775 // Note: The TypeSourceInfos for the arguments are allocated after the
2776 // TypeTraitExpr.
2777
2780 SourceLocation RParenLoc,
2781 bool Value);
2782
2783 TypeTraitExpr(EmptyShell Empty) : Expr(TypeTraitExprClass, Empty) {}
2784
2785 size_t numTrailingObjects(OverloadToken<TypeSourceInfo *>) const {
2786 return getNumArgs();
2787 }
2788
2789public:
2790 friend class ASTStmtReader;
2791 friend class ASTStmtWriter;
2793
2794 /// Create a new type trait expression.
2795 static TypeTraitExpr *Create(const ASTContext &C, QualType T,
2798 SourceLocation RParenLoc,
2799 bool Value);
2800
2802 unsigned NumArgs);
2803
2804 /// Determine which type trait this expression uses.
2806 return static_cast<TypeTrait>(TypeTraitExprBits.Kind);
2807 }
2808
2809 bool getValue() const {
2810 assert(!isValueDependent());
2811 return TypeTraitExprBits.Value;
2812 }
2813
2814 /// Determine the number of arguments to this type trait.
2815 unsigned getNumArgs() const { return TypeTraitExprBits.NumArgs; }
2816
2817 /// Retrieve the Ith argument.
2818 TypeSourceInfo *getArg(unsigned I) const {
2819 assert(I < getNumArgs() && "Argument out-of-range");
2820 return getArgs()[I];
2821 }
2822
2823 /// Retrieve the argument types.
2825 return llvm::ArrayRef(getTrailingObjects<TypeSourceInfo *>(), getNumArgs());
2826 }
2827
2828 SourceLocation getBeginLoc() const LLVM_READONLY { return Loc; }
2829 SourceLocation getEndLoc() const LLVM_READONLY { return RParenLoc; }
2830
2831 static bool classof(const Stmt *T) {
2832 return T->getStmtClass() == TypeTraitExprClass;
2833 }
2834
2835 // Iterators
2838 }
2839
2842 }
2843};
2844
2845/// An Embarcadero array type trait, as used in the implementation of
2846/// __array_rank and __array_extent.
2847///
2848/// Example:
2849/// \code
2850/// __array_rank(int[10][20]) == 2
2851/// __array_extent(int, 1) == 20
2852/// \endcode
2853class ArrayTypeTraitExpr : public Expr {
2854 /// The trait. An ArrayTypeTrait enum in MSVC compat unsigned.
2855 LLVM_PREFERRED_TYPE(ArrayTypeTrait)
2856 unsigned ATT : 2;
2857
2858 /// The value of the type trait. Unspecified if dependent.
2859 uint64_t Value = 0;
2860
2861 /// The array dimension being queried, or -1 if not used.
2862 Expr *Dimension;
2863
2864 /// The location of the type trait keyword.
2866
2867 /// The location of the closing paren.
2868 SourceLocation RParen;
2869
2870 /// The type being queried.
2871 TypeSourceInfo *QueriedType = nullptr;
2872
2873public:
2874 friend class ASTStmtReader;
2875
2877 TypeSourceInfo *queried, uint64_t value, Expr *dimension,
2878 SourceLocation rparen, QualType ty)
2879 : Expr(ArrayTypeTraitExprClass, ty, VK_PRValue, OK_Ordinary), ATT(att),
2880 Value(value), Dimension(dimension), Loc(loc), RParen(rparen),
2881 QueriedType(queried) {
2882 assert(att <= ATT_Last && "invalid enum value!");
2883 assert(static_cast<unsigned>(att) == ATT && "ATT overflow!");
2885 }
2886
2888 : Expr(ArrayTypeTraitExprClass, Empty), ATT(0) {}
2889
2890 SourceLocation getBeginLoc() const LLVM_READONLY { return Loc; }
2891 SourceLocation getEndLoc() const LLVM_READONLY { return RParen; }
2892
2893 ArrayTypeTrait getTrait() const { return static_cast<ArrayTypeTrait>(ATT); }
2894
2895 QualType getQueriedType() const { return QueriedType->getType(); }
2896
2897 TypeSourceInfo *getQueriedTypeSourceInfo() const { return QueriedType; }
2898
2899 uint64_t getValue() const { assert(!isTypeDependent()); return Value; }
2900
2901 Expr *getDimensionExpression() const { return Dimension; }
2902
2903 static bool classof(const Stmt *T) {
2904 return T->getStmtClass() == ArrayTypeTraitExprClass;
2905 }
2906
2907 // Iterators
2910 }
2911
2914 }
2915};
2916
2917/// An expression trait intrinsic.
2918///
2919/// Example:
2920/// \code
2921/// __is_lvalue_expr(std::cout) == true
2922/// __is_lvalue_expr(1) == false
2923/// \endcode
2925 /// The trait. A ExpressionTrait enum in MSVC compatible unsigned.
2926 LLVM_PREFERRED_TYPE(ExpressionTrait)
2927 unsigned ET : 31;
2928
2929 /// The value of the type trait. Unspecified if dependent.
2930 LLVM_PREFERRED_TYPE(bool)
2931 unsigned Value : 1;
2932
2933 /// The location of the type trait keyword.
2935
2936 /// The location of the closing paren.
2937 SourceLocation RParen;
2938
2939 /// The expression being queried.
2940 Expr* QueriedExpression = nullptr;
2941
2942public:
2943 friend class ASTStmtReader;
2944
2946 bool value, SourceLocation rparen, QualType resultType)
2947 : Expr(ExpressionTraitExprClass, resultType, VK_PRValue, OK_Ordinary),
2948 ET(et), Value(value), Loc(loc), RParen(rparen),
2949 QueriedExpression(queried) {
2950 assert(et <= ET_Last && "invalid enum value!");
2951 assert(static_cast<unsigned>(et) == ET && "ET overflow!");
2953 }
2954
2956 : Expr(ExpressionTraitExprClass, Empty), ET(0), Value(false) {}
2957
2958 SourceLocation getBeginLoc() const LLVM_READONLY { return Loc; }
2959 SourceLocation getEndLoc() const LLVM_READONLY { return RParen; }
2960
2961 ExpressionTrait getTrait() const { return static_cast<ExpressionTrait>(ET); }
2962
2963 Expr *getQueriedExpression() const { return QueriedExpression; }
2964
2965 bool getValue() const { return Value; }
2966
2967 static bool classof(const Stmt *T) {
2968 return T->getStmtClass() == ExpressionTraitExprClass;
2969 }
2970
2971 // Iterators
2974 }
2975
2978 }
2979};
2980
2981/// A reference to an overloaded function set, either an
2982/// \c UnresolvedLookupExpr or an \c UnresolvedMemberExpr.
2983class OverloadExpr : public Expr {
2984 friend class ASTStmtReader;
2985 friend class ASTStmtWriter;
2986
2987 /// The common name of these declarations.
2988 DeclarationNameInfo NameInfo;
2989
2990 /// The nested-name-specifier that qualifies the name, if any.
2991 NestedNameSpecifierLoc QualifierLoc;
2992
2993protected:
2994 OverloadExpr(StmtClass SC, const ASTContext &Context,
2995 NestedNameSpecifierLoc QualifierLoc,
2996 SourceLocation TemplateKWLoc,
2997 const DeclarationNameInfo &NameInfo,
2998 const TemplateArgumentListInfo *TemplateArgs,
3000 bool KnownDependent, bool KnownInstantiationDependent,
3001 bool KnownContainsUnexpandedParameterPack);
3002
3003 OverloadExpr(StmtClass SC, EmptyShell Empty, unsigned NumResults,
3004 bool HasTemplateKWAndArgsInfo);
3005
3006 /// Return the results. Defined after UnresolvedMemberExpr.
3009 return const_cast<OverloadExpr *>(this)->getTrailingResults();
3010 }
3011
3012 /// Return the optional template keyword and arguments info.
3013 /// Defined after UnresolvedMemberExpr.
3016 return const_cast<OverloadExpr *>(this)
3018 }
3019
3020 /// Return the optional template arguments. Defined after
3021 /// UnresolvedMemberExpr.
3024 return const_cast<OverloadExpr *>(this)->getTrailingTemplateArgumentLoc();
3025 }
3026
3028 return OverloadExprBits.HasTemplateKWAndArgsInfo;
3029 }
3030
3031public:
3032 struct FindResult {
3037 };
3038
3039 /// Finds the overloaded expression in the given expression \p E of
3040 /// OverloadTy.
3041 ///
3042 /// \return the expression (which must be there) and true if it has
3043 /// the particular form of a member pointer expression
3045 assert(E->getType()->isSpecificBuiltinType(BuiltinType::Overload));
3046
3048 bool HasParen = isa<ParenExpr>(E);
3049
3050 E = E->IgnoreParens();
3051 if (isa<UnaryOperator>(E)) {
3052 assert(cast<UnaryOperator>(E)->getOpcode() == UO_AddrOf);
3053 E = cast<UnaryOperator>(E)->getSubExpr();
3054 auto *Ovl = cast<OverloadExpr>(E->IgnoreParens());
3055
3056 Result.HasFormOfMemberPointer = (E == Ovl && Ovl->getQualifier());
3057 Result.IsAddressOfOperand = true;
3058 Result.IsAddressOfOperandWithParen = HasParen;
3059 Result.Expression = Ovl;
3060 } else {
3061 Result.Expression = cast<OverloadExpr>(E);
3062 }
3063
3064 return Result;
3065 }
3066
3067 /// Gets the naming class of this lookup, if any.
3068 /// Defined after UnresolvedMemberExpr.
3069 inline CXXRecordDecl *getNamingClass();
3071 return const_cast<OverloadExpr *>(this)->getNamingClass();
3072 }
3073
3075
3078 }
3081 }
3082 llvm::iterator_range<decls_iterator> decls() const {
3083 return llvm::make_range(decls_begin(), decls_end());
3084 }
3085
3086 /// Gets the number of declarations in the unresolved set.
3087 unsigned getNumDecls() const { return OverloadExprBits.NumResults; }
3088
3089 /// Gets the full name info.
3090 const DeclarationNameInfo &getNameInfo() const { return NameInfo; }
3091
3092 /// Gets the name looked up.
3093 DeclarationName getName() const { return NameInfo.getName(); }
3094
3095 /// Gets the location of the name.
3096 SourceLocation getNameLoc() const { return NameInfo.getLoc(); }
3097
3098 /// Fetches the nested-name qualifier, if one was given.
3100 return QualifierLoc.getNestedNameSpecifier();
3101 }
3102
3103 /// Fetches the nested-name qualifier with source-location
3104 /// information, if one was given.
3105 NestedNameSpecifierLoc getQualifierLoc() const { return QualifierLoc; }
3106
3107 /// Retrieve the location of the template keyword preceding
3108 /// this name, if any.
3111 return SourceLocation();
3113 }
3114
3115 /// Retrieve the location of the left angle bracket starting the
3116 /// explicit template argument list following the name, if any.
3119 return SourceLocation();
3121 }
3122
3123 /// Retrieve the location of the right angle bracket ending the
3124 /// explicit template argument list following the name, if any.
3127 return SourceLocation();
3129 }
3130
3131 /// Determines whether the name was preceded by the template keyword.
3133
3134 /// Determines whether this expression had explicit template arguments.
3135 bool hasExplicitTemplateArgs() const { return getLAngleLoc().isValid(); }
3136
3139 return nullptr;
3140 return const_cast<OverloadExpr *>(this)->getTrailingTemplateArgumentLoc();
3141 }
3142
3143 unsigned getNumTemplateArgs() const {
3145 return 0;
3146
3148 }
3149
3151 return {getTemplateArgs(), getNumTemplateArgs()};
3152 }
3153
3154 /// Copies the template arguments into the given structure.
3158 }
3159
3160 static bool classof(const Stmt *T) {
3161 return T->getStmtClass() == UnresolvedLookupExprClass ||
3162 T->getStmtClass() == UnresolvedMemberExprClass;
3163 }
3164};
3165
3166/// A reference to a name which we were able to look up during
3167/// parsing but could not resolve to a specific declaration.
3168///
3169/// This arises in several ways:
3170/// * we might be waiting for argument-dependent lookup;
3171/// * the name might resolve to an overloaded function;
3172/// * the name might resolve to a non-function template; for example, in the
3173/// following snippet, the return expression of the member function
3174/// 'foo()' might remain unresolved until instantiation:
3175///
3176/// \code
3177/// struct P {
3178/// template <class T> using I = T;
3179/// };
3180///
3181/// struct Q {
3182/// template <class T> int foo() {
3183/// return T::template I<int>;
3184/// }
3185/// };
3186/// \endcode
3187///
3188/// ...which is distinct from modeling function overloads, and therefore we use
3189/// a different builtin type 'UnresolvedTemplate' to avoid confusion. This is
3190/// done in Sema::BuildTemplateIdExpr.
3191///
3192/// and eventually:
3193/// * the lookup might have included a function template.
3194/// * the unresolved template gets transformed in an instantiation or gets
3195/// diagnosed for its direct use.
3196///
3197/// These never include UnresolvedUsingValueDecls, which are always class
3198/// members and therefore appear only in UnresolvedMemberLookupExprs.
3200 : public OverloadExpr,
3201 private llvm::TrailingObjects<UnresolvedLookupExpr, DeclAccessPair,
3202 ASTTemplateKWAndArgsInfo,
3203 TemplateArgumentLoc> {
3204 friend class ASTStmtReader;
3205 friend class OverloadExpr;
3206 friend TrailingObjects;
3207
3208 /// The naming class (C++ [class.access.base]p5) of the lookup, if
3209 /// any. This can generally be recalculated from the context chain,
3210 /// but that can be fairly expensive for unqualified lookups.
3211 CXXRecordDecl *NamingClass;
3212
3213 // UnresolvedLookupExpr is followed by several trailing objects.
3214 // They are in order:
3215 //
3216 // * An array of getNumResults() DeclAccessPair for the results. These are
3217 // undesugared, which is to say, they may include UsingShadowDecls.
3218 // Access is relative to the naming class.
3219 //
3220 // * An optional ASTTemplateKWAndArgsInfo for the explicitly specified
3221 // template keyword and arguments. Present if and only if
3222 // hasTemplateKWAndArgsInfo().
3223 //
3224 // * An array of getNumTemplateArgs() TemplateArgumentLoc containing
3225 // location information for the explicitly specified template arguments.
3226
3227 UnresolvedLookupExpr(const ASTContext &Context, CXXRecordDecl *NamingClass,
3228 NestedNameSpecifierLoc QualifierLoc,
3229 SourceLocation TemplateKWLoc,
3230 const DeclarationNameInfo &NameInfo, bool RequiresADL,
3231 const TemplateArgumentListInfo *TemplateArgs,
3233 bool KnownDependent, bool KnownInstantiationDependent);
3234
3235 UnresolvedLookupExpr(EmptyShell Empty, unsigned NumResults,
3236 bool HasTemplateKWAndArgsInfo);
3237
3238 unsigned numTrailingObjects(OverloadToken<DeclAccessPair>) const {
3239 return getNumDecls();
3240 }
3241
3242 unsigned numTrailingObjects(OverloadToken<ASTTemplateKWAndArgsInfo>) const {
3243 return hasTemplateKWAndArgsInfo();
3244 }
3245
3246public:
3247 static UnresolvedLookupExpr *
3248 Create(const ASTContext &Context, CXXRecordDecl *NamingClass,
3249 NestedNameSpecifierLoc QualifierLoc,
3250 const DeclarationNameInfo &NameInfo, bool RequiresADL,
3251 UnresolvedSetIterator Begin, UnresolvedSetIterator End,
3252 bool KnownDependent, bool KnownInstantiationDependent);
3253
3254 // After canonicalization, there may be dependent template arguments in
3255 // CanonicalConverted But none of Args is dependent. When any of
3256 // CanonicalConverted dependent, KnownDependent is true.
3257 static UnresolvedLookupExpr *
3258 Create(const ASTContext &Context, CXXRecordDecl *NamingClass,
3259 NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc,
3260 const DeclarationNameInfo &NameInfo, bool RequiresADL,
3261 const TemplateArgumentListInfo *Args, UnresolvedSetIterator Begin,
3262 UnresolvedSetIterator End, bool KnownDependent,
3263 bool KnownInstantiationDependent);
3264
3265 static UnresolvedLookupExpr *CreateEmpty(const ASTContext &Context,
3266 unsigned NumResults,
3267 bool HasTemplateKWAndArgsInfo,
3268 unsigned NumTemplateArgs);
3269
3270 /// True if this declaration should be extended by
3271 /// argument-dependent lookup.
3272 bool requiresADL() const { return UnresolvedLookupExprBits.RequiresADL; }
3273
3274 /// Gets the 'naming class' (in the sense of C++0x
3275 /// [class.access.base]p5) of the lookup. This is the scope
3276 /// that was looked in to find these results.
3277 CXXRecordDecl *getNamingClass() { return NamingClass; }
3278 const CXXRecordDecl *getNamingClass() const { return NamingClass; }
3279
3280 SourceLocation getBeginLoc() const LLVM_READONLY {
3282 return l.getBeginLoc();
3283 return getNameInfo().getBeginLoc();
3284 }
3285
3286 SourceLocation getEndLoc() const LLVM_READONLY {
3288 return getRAngleLoc();
3289 return getNameInfo().getEndLoc();
3290 }
3291
3294 }
3295
3298 }
3299
3300 static bool classof(const Stmt *T) {
3301 return T->getStmtClass() == UnresolvedLookupExprClass;
3302 }
3303};
3304
3305/// A qualified reference to a name whose declaration cannot
3306/// yet be resolved.
3307///
3308/// DependentScopeDeclRefExpr is similar to DeclRefExpr in that
3309/// it expresses a reference to a declaration such as
3310/// X<T>::value. The difference, however, is that an
3311/// DependentScopeDeclRefExpr node is used only within C++ templates when
3312/// the qualification (e.g., X<T>::) refers to a dependent type. In
3313/// this case, X<T>::value cannot resolve to a declaration because the
3314/// declaration will differ from one instantiation of X<T> to the
3315/// next. Therefore, DependentScopeDeclRefExpr keeps track of the
3316/// qualifier (X<T>::) and the name of the entity being referenced
3317/// ("value"). Such expressions will instantiate to a DeclRefExpr once the
3318/// declaration can be found.
3320 : public Expr,
3321 private llvm::TrailingObjects<DependentScopeDeclRefExpr,
3322 ASTTemplateKWAndArgsInfo,
3323 TemplateArgumentLoc> {
3324 friend class ASTStmtReader;
3325 friend class ASTStmtWriter;
3326 friend TrailingObjects;
3327
3328 /// The nested-name-specifier that qualifies this unresolved
3329 /// declaration name.
3330 NestedNameSpecifierLoc QualifierLoc;
3331
3332 /// The name of the entity we will be referencing.
3333 DeclarationNameInfo NameInfo;
3334
3336 SourceLocation TemplateKWLoc,
3337 const DeclarationNameInfo &NameInfo,
3338 const TemplateArgumentListInfo *Args);
3339
3340 size_t numTrailingObjects(OverloadToken<ASTTemplateKWAndArgsInfo>) const {
3341 return hasTemplateKWAndArgsInfo();
3342 }
3343
3344 bool hasTemplateKWAndArgsInfo() const {
3345 return DependentScopeDeclRefExprBits.HasTemplateKWAndArgsInfo;
3346 }
3347
3348public:
3349 static DependentScopeDeclRefExpr *
3350 Create(const ASTContext &Context, NestedNameSpecifierLoc QualifierLoc,
3351 SourceLocation TemplateKWLoc, const DeclarationNameInfo &NameInfo,
3352 const TemplateArgumentListInfo *TemplateArgs);
3353
3354 static DependentScopeDeclRefExpr *CreateEmpty(const ASTContext &Context,
3355 bool HasTemplateKWAndArgsInfo,
3356 unsigned NumTemplateArgs);
3357
3358 /// Retrieve the name that this expression refers to.
3359 const DeclarationNameInfo &getNameInfo() const { return NameInfo; }
3360
3361 /// Retrieve the name that this expression refers to.
3362 DeclarationName getDeclName() const { return NameInfo.getName(); }
3363
3364 /// Retrieve the location of the name within the expression.
3365 ///
3366 /// For example, in "X<T>::value" this is the location of "value".
3367 SourceLocation getLocation() const { return NameInfo.getLoc(); }
3368
3369 /// Retrieve the nested-name-specifier that qualifies the
3370 /// name, with source location information.
3371 NestedNameSpecifierLoc getQualifierLoc() const { return QualifierLoc; }
3372
3373 /// Retrieve the nested-name-specifier that qualifies this
3374 /// declaration.
3376 return QualifierLoc.getNestedNameSpecifier();
3377 }
3378
3379 /// Retrieve the location of the template keyword preceding
3380 /// this name, if any.
3382 if (!hasTemplateKWAndArgsInfo())
3383 return SourceLocation();
3384 return getTrailingObjects<ASTTemplateKWAndArgsInfo>()->TemplateKWLoc;
3385 }
3386
3387 /// Retrieve the location of the left angle bracket starting the
3388 /// explicit template argument list following the name, if any.
3390 if (!hasTemplateKWAndArgsInfo())
3391 return SourceLocation();
3392 return getTrailingObjects<ASTTemplateKWAndArgsInfo>()->LAngleLoc;
3393 }
3394
3395 /// Retrieve the location of the right angle bracket ending the
3396 /// explicit template argument list following the name, if any.
3398 if (!hasTemplateKWAndArgsInfo())
3399 return SourceLocation();
3400 return getTrailingObjects<ASTTemplateKWAndArgsInfo>()->RAngleLoc;
3401 }
3402
3403 /// Determines whether the name was preceded by the template keyword.
3405
3406 /// Determines whether this lookup had explicit template arguments.
3407 bool hasExplicitTemplateArgs() const { return getLAngleLoc().isValid(); }
3408
3409 /// Copies the template arguments (if present) into the given
3410 /// structure.
3413 getTrailingObjects<ASTTemplateKWAndArgsInfo>()->copyInto(
3414 getTrailingObjects<TemplateArgumentLoc>(), List);
3415 }
3416
3419 return nullptr;
3420
3421 return getTrailingObjects<TemplateArgumentLoc>();
3422 }
3423
3424 unsigned getNumTemplateArgs() const {
3426 return 0;
3427
3428 return getTrailingObjects<ASTTemplateKWAndArgsInfo>()->NumTemplateArgs;
3429 }
3430
3432 return {getTemplateArgs(), getNumTemplateArgs()};
3433 }
3434
3435 /// Note: getBeginLoc() is the start of the whole DependentScopeDeclRefExpr,
3436 /// and differs from getLocation().getStart().
3437 SourceLocation getBeginLoc() const LLVM_READONLY {
3438 return QualifierLoc.getBeginLoc();
3439 }
3440
3441 SourceLocation getEndLoc() const LLVM_READONLY {
3443 return getRAngleLoc();
3444 return getLocation();
3445 }
3446
3447 static bool classof(const Stmt *T) {
3448 return T->getStmtClass() == DependentScopeDeclRefExprClass;
3449 }
3450
3453 }
3454
3457 }
3458};
3459
3460/// Represents an expression -- generally a full-expression -- that
3461/// introduces cleanups to be run at the end of the sub-expression's
3462/// evaluation. The most common source of expression-introduced
3463/// cleanups is temporary objects in C++, but several other kinds of
3464/// expressions can create cleanups, including basically every
3465/// call in ARC that returns an Objective-C pointer.
3466///
3467/// This expression also tracks whether the sub-expression contains a
3468/// potentially-evaluated block literal. The lifetime of a block
3469/// literal is the extent of the enclosing scope.
3471 : public FullExpr,
3472 private llvm::TrailingObjects<
3473 ExprWithCleanups,
3474 llvm::PointerUnion<BlockDecl *, CompoundLiteralExpr *>> {
3475public:
3476 /// The type of objects that are kept in the cleanup.
3477 /// It's useful to remember the set of blocks and block-scoped compound
3478 /// literals; we could also remember the set of temporaries, but there's
3479 /// currently no need.
3480 using CleanupObject = llvm::PointerUnion<BlockDecl *, CompoundLiteralExpr *>;
3481
3482private:
3483 friend class ASTStmtReader;
3484 friend TrailingObjects;
3485
3486 ExprWithCleanups(EmptyShell, unsigned NumObjects);
3487 ExprWithCleanups(Expr *SubExpr, bool CleanupsHaveSideEffects,
3488 ArrayRef<CleanupObject> Objects);
3489
3490public:
3491 static ExprWithCleanups *Create(const ASTContext &C, EmptyShell empty,
3492 unsigned numObjects);
3493
3494 static ExprWithCleanups *Create(const ASTContext &C, Expr *subexpr,
3495 bool CleanupsHaveSideEffects,
3496 ArrayRef<CleanupObject> objects);
3497
3499 return llvm::ArrayRef(getTrailingObjects<CleanupObject>(), getNumObjects());
3500 }
3501
3502 unsigned getNumObjects() const { return ExprWithCleanupsBits.NumObjects; }
3503
3504 CleanupObject getObject(unsigned i) const {
3505 assert(i < getNumObjects() && "Index out of range");
3506 return getObjects()[i];
3507 }
3508
3510 return ExprWithCleanupsBits.CleanupsHaveSideEffects;
3511 }
3512
3513 SourceLocation getBeginLoc() const LLVM_READONLY {
3514 return SubExpr->getBeginLoc();
3515 }
3516
3517 SourceLocation getEndLoc() const LLVM_READONLY {
3518 return SubExpr->getEndLoc();
3519 }
3520
3521 // Implement isa/cast/dyncast/etc.
3522 static bool classof(const Stmt *T) {
3523 return T->getStmtClass() == ExprWithCleanupsClass;
3524 }
3525
3526 // Iterators
3528
3530 return const_child_range(&SubExpr, &SubExpr + 1);
3531 }
3532};
3533
3534/// Describes an explicit type conversion that uses functional
3535/// notion but could not be resolved because one or more arguments are
3536/// type-dependent.
3537///
3538/// The explicit type conversions expressed by
3539/// CXXUnresolvedConstructExpr have the form <tt>T(a1, a2, ..., aN)</tt>,
3540/// where \c T is some type and \c a1, \c a2, ..., \c aN are values, and
3541/// either \c T is a dependent type or one or more of the <tt>a</tt>'s is
3542/// type-dependent. For example, this would occur in a template such
3543/// as:
3544///
3545/// \code
3546/// template<typename T, typename A1>
3547/// inline T make_a(const A1& a1) {
3548/// return T(a1);
3549/// }
3550/// \endcode
3551///
3552/// When the returned expression is instantiated, it may resolve to a
3553/// constructor call, conversion function call, or some kind of type
3554/// conversion.
3556 : public Expr,
3557 private llvm::TrailingObjects<CXXUnresolvedConstructExpr, Expr *> {
3558 friend class ASTStmtReader;
3559 friend TrailingObjects;
3560
3561 /// The type being constructed, and whether the construct expression models
3562 /// list initialization or not.
3563 llvm::PointerIntPair<TypeSourceInfo *, 1> TypeAndInitForm;
3564
3565 /// The location of the left parentheses ('(').
3566 SourceLocation LParenLoc;
3567
3568 /// The location of the right parentheses (')').
3569 SourceLocation RParenLoc;
3570
3572 SourceLocation LParenLoc, ArrayRef<Expr *> Args,
3573 SourceLocation RParenLoc, bool IsListInit);
3574
3576 : Expr(CXXUnresolvedConstructExprClass, Empty) {
3577 CXXUnresolvedConstructExprBits.NumArgs = NumArgs;
3578 }
3579
3580public:
3582 Create(const ASTContext &Context, QualType T, TypeSourceInfo *TSI,
3583 SourceLocation LParenLoc, ArrayRef<Expr *> Args,
3584 SourceLocation RParenLoc, bool IsListInit);
3585
3586 static CXXUnresolvedConstructExpr *CreateEmpty(const ASTContext &Context,
3587 unsigned NumArgs);
3588
3589 /// Retrieve the type that is being constructed, as specified
3590 /// in the source code.
3592
3593 /// Retrieve the type source information for the type being
3594 /// constructed.
3596 return TypeAndInitForm.getPointer();
3597 }
3598
3599 /// Retrieve the location of the left parentheses ('(') that
3600 /// precedes the argument list.
3601 SourceLocation getLParenLoc() const { return LParenLoc; }
3602 void setLParenLoc(SourceLocation L) { LParenLoc = L; }
3603
3604 /// Retrieve the location of the right parentheses (')') that
3605 /// follows the argument list.
3606 SourceLocation getRParenLoc() const { return RParenLoc; }
3607 void setRParenLoc(SourceLocation L) { RParenLoc = L; }
3608
3609 /// Determine whether this expression models list-initialization.
3610 /// If so, there will be exactly one subexpression, which will be
3611 /// an InitListExpr.
3612 bool isListInitialization() const { return TypeAndInitForm.getInt(); }
3613
3614 /// Retrieve the number of arguments.
3615 unsigned getNumArgs() const { return CXXUnresolvedConstructExprBits.NumArgs; }
3616
3617 using arg_iterator = Expr **;
3618 using arg_range = llvm::iterator_range<arg_iterator>;
3619
3620 arg_iterator arg_begin() { return getTrailingObjects<Expr *>(); }
3623
3624 using const_arg_iterator = const Expr* const *;
3625 using const_arg_range = llvm::iterator_range<const_arg_iterator>;
3626
3627 const_arg_iterator arg_begin() const { return getTrailingObjects<Expr *>(); }
3630 return const_arg_range(arg_begin(), arg_end());
3631 }
3632
3633 Expr *getArg(unsigned I) {
3634 assert(I < getNumArgs() && "Argument index out-of-range");
3635 return arg_begin()[I];
3636 }
3637
3638 const Expr *getArg(unsigned I) const {
3639 assert(I < getNumArgs() && "Argument index out-of-range");
3640 return arg_begin()[I];
3641 }
3642
3643 void setArg(unsigned I, Expr *E) {
3644 assert(I < getNumArgs() && "Argument index out-of-range");
3645 arg_begin()[I] = E;
3646 }
3647
3648 SourceLocation getBeginLoc() const LLVM_READONLY;
3649 SourceLocation getEndLoc() const LLVM_READONLY {
3650 if (!RParenLoc.isValid() && getNumArgs() > 0)
3651 return getArg(getNumArgs() - 1)->getEndLoc();
3652 return RParenLoc;
3653 }
3654
3655 static bool classof(const Stmt *T) {
3656 return T->getStmtClass() == CXXUnresolvedConstructExprClass;
3657 }
3658
3659 // Iterators
3661 auto **begin = reinterpret_cast<Stmt **>(arg_begin());
3662 return child_range(begin, begin + getNumArgs());
3663 }
3664
3666 auto **begin = reinterpret_cast<Stmt **>(
3667 const_cast<CXXUnresolvedConstructExpr *>(this)->arg_begin());
3668 return const_child_range(begin, begin + getNumArgs());
3669 }
3670};
3671
3672/// Represents a C++ member access expression where the actual
3673/// member referenced could not be resolved because the base
3674/// expression or the member name was dependent.
3675///
3676/// Like UnresolvedMemberExprs, these can be either implicit or
3677/// explicit accesses. It is only possible to get one of these with
3678/// an implicit access if a qualifier is provided.
3680 : public Expr,
3681 private llvm::TrailingObjects<CXXDependentScopeMemberExpr,
3682 ASTTemplateKWAndArgsInfo,
3683 TemplateArgumentLoc, NamedDecl *> {
3684 friend class ASTStmtReader;
3685 friend class ASTStmtWriter;
3686 friend TrailingObjects;
3687
3688 /// The expression for the base pointer or class reference,
3689 /// e.g., the \c x in x.f. Can be null in implicit accesses.
3690 Stmt *Base;
3691
3692 /// The type of the base expression. Never null, even for
3693 /// implicit accesses.
3694 QualType BaseType;
3695
3696 /// The nested-name-specifier that precedes the member name, if any.
3697 /// FIXME: This could be in principle store as a trailing object.
3698 /// However the performance impact of doing so should be investigated first.
3699 NestedNameSpecifierLoc QualifierLoc;
3700
3701 /// The member to which this member expression refers, which
3702 /// can be name, overloaded operator, or destructor.
3703 ///
3704 /// FIXME: could also be a template-id
3705 DeclarationNameInfo MemberNameInfo;
3706
3707 // CXXDependentScopeMemberExpr is followed by several trailing objects,
3708 // some of which optional. They are in order:
3709 //
3710 // * An optional ASTTemplateKWAndArgsInfo for the explicitly specified
3711 // template keyword and arguments. Present if and only if
3712 // hasTemplateKWAndArgsInfo().
3713 //
3714 // * An array of getNumTemplateArgs() TemplateArgumentLoc containing location
3715 // information for the explicitly specified template arguments.
3716 //
3717 // * An optional NamedDecl *. In a qualified member access expression such
3718 // as t->Base::f, this member stores the resolves of name lookup in the
3719 // context of the member access expression, to be used at instantiation
3720 // time. Present if and only if hasFirstQualifierFoundInScope().
3721
3722 bool hasTemplateKWAndArgsInfo() const {
3723 return CXXDependentScopeMemberExprBits.HasTemplateKWAndArgsInfo;
3724 }
3725
3726 bool hasFirstQualifierFoundInScope() const {
3727 return CXXDependentScopeMemberExprBits.HasFirstQualifierFoundInScope;
3728 }
3729
3730 unsigned numTrailingObjects(OverloadToken<ASTTemplateKWAndArgsInfo>) const {
3731 return hasTemplateKWAndArgsInfo();
3732 }
3733
3734 unsigned numTrailingObjects(OverloadToken<TemplateArgumentLoc>) const {
3735 return getNumTemplateArgs();
3736 }
3737
3738 unsigned numTrailingObjects(OverloadToken<NamedDecl *>) const {
3739 return hasFirstQualifierFoundInScope();
3740 }
3741
3742 CXXDependentScopeMemberExpr(const ASTContext &Ctx, Expr *Base,
3743 QualType BaseType, bool IsArrow,
3744 SourceLocation OperatorLoc,
3745 NestedNameSpecifierLoc QualifierLoc,
3746 SourceLocation TemplateKWLoc,
3747 NamedDecl *FirstQualifierFoundInScope,
3748 DeclarationNameInfo MemberNameInfo,
3749 const TemplateArgumentListInfo *TemplateArgs);
3750
3751 CXXDependentScopeMemberExpr(EmptyShell Empty, bool HasTemplateKWAndArgsInfo,
3752 bool HasFirstQualifierFoundInScope);
3753
3754public:
3755 static CXXDependentScopeMemberExpr *
3756 Create(const ASTContext &Ctx, Expr *Base, QualType BaseType, bool IsArrow,
3757 SourceLocation OperatorLoc, NestedNameSpecifierLoc QualifierLoc,
3758 SourceLocation TemplateKWLoc, NamedDecl *FirstQualifierFoundInScope,
3759 DeclarationNameInfo MemberNameInfo,
3760 const TemplateArgumentListInfo *TemplateArgs);
3761
3762 static CXXDependentScopeMemberExpr *
3763 CreateEmpty(const ASTContext &Ctx, bool HasTemplateKWAndArgsInfo,
3764 unsigned NumTemplateArgs, bool HasFirstQualifierFoundInScope);
3765
3766 /// True if this is an implicit access, i.e. one in which the
3767 /// member being accessed was not written in the source. The source
3768 /// location of the operator is invalid in this case.
3769 bool isImplicitAccess() const {
3770 if (!Base)
3771 return true;
3772 return cast<Expr>(Base)->isImplicitCXXThis();
3773 }
3774
3775 /// Retrieve the base object of this member expressions,
3776 /// e.g., the \c x in \c x.m.
3777 Expr *getBase() const {
3778 assert(!isImplicitAccess());
3779 return cast<Expr>(Base);
3780 }
3781
3782 QualType getBaseType() const { return BaseType; }
3783
3784 /// Determine whether this member expression used the '->'
3785 /// operator; otherwise, it used the '.' operator.
3786 bool isArrow() const { return CXXDependentScopeMemberExprBits.IsArrow; }
3787
3788 /// Retrieve the location of the '->' or '.' operator.
3790 return CXXDependentScopeMemberExprBits.OperatorLoc;
3791 }
3792
3793 /// Retrieve the nested-name-specifier that qualifies the member name.
3795 return QualifierLoc.getNestedNameSpecifier();
3796 }
3797
3798 /// Retrieve the nested-name-specifier that qualifies the member
3799 /// name, with source location information.
3800 NestedNameSpecifierLoc getQualifierLoc() const { return QualifierLoc; }
3801
3802 /// Retrieve the first part of the nested-name-specifier that was
3803 /// found in the scope of the member access expression when the member access
3804 /// was initially parsed.
3805 ///
3806 /// This function only returns a useful result when member access expression
3807 /// uses a qualified member name, e.g., "x.Base::f". Here, the declaration
3808 /// returned by this function describes what was found by unqualified name
3809 /// lookup for the identifier "Base" within the scope of the member access
3810 /// expression itself. At template instantiation time, this information is
3811 /// combined with the results of name lookup into the type of the object
3812 /// expression itself (the class type of x).
3814 if (!hasFirstQualifierFoundInScope())
3815 return nullptr;
3816 return *getTrailingObjects<NamedDecl *>();
3817 }
3818
3819 /// Retrieve the name of the member that this expression refers to.
3821 return MemberNameInfo;
3822 }
3823
3824 /// Retrieve the name of the member that this expression refers to.
3825 DeclarationName getMember() const { return MemberNameInfo.getName(); }
3826
3827 // Retrieve the location of the name of the member that this
3828 // expression refers to.
3829 SourceLocation getMemberLoc() const { return MemberNameInfo.getLoc(); }
3830
3831 /// Retrieve the location of the template keyword preceding the
3832 /// member name, if any.
3834 if (!hasTemplateKWAndArgsInfo())
3835 return SourceLocation();
3836 return getTrailingObjects<ASTTemplateKWAndArgsInfo>()->TemplateKWLoc;
3837 }
3838
3839 /// Retrieve the location of the left angle bracket starting the
3840 /// explicit template argument list following the member name, if any.
3842 if (!hasTemplateKWAndArgsInfo())
3843 return SourceLocation();
3844 return getTrailingObjects<ASTTemplateKWAndArgsInfo>()->LAngleLoc;
3845 }
3846
3847 /// Retrieve the location of the right angle bracket ending the
3848 /// explicit template argument list following the member name, if any.
3850 if (!hasTemplateKWAndArgsInfo())
3851 return SourceLocation();
3852 return getTrailingObjects<ASTTemplateKWAndArgsInfo>()->RAngleLoc;
3853 }
3854
3855 /// Determines whether the member name was preceded by the template keyword.
3857
3858 /// Determines whether this member expression actually had a C++
3859 /// template argument list explicitly specified, e.g., x.f<int>.
3860 bool hasExplicitTemplateArgs() const { return getLAngleLoc().isValid(); }
3861
3862 /// Copies the template arguments (if present) into the given
3863 /// structure.
3866 getTrailingObjects<ASTTemplateKWAndArgsInfo>()->copyInto(
3867 getTrailingObjects<TemplateArgumentLoc>(), List);
3868 }
3869
3870 /// Retrieve the template arguments provided as part of this
3871 /// template-id.
3874 return nullptr;
3875
3876 return getTrailingObjects<TemplateArgumentLoc>();
3877 }
3878
3879 /// Retrieve the number of template arguments provided as part of this
3880 /// template-id.
3881 unsigned getNumTemplateArgs() const {
3883 return 0;
3884
3885 return getTrailingObjects<ASTTemplateKWAndArgsInfo>()->NumTemplateArgs;
3886 }
3887
3889 return {getTemplateArgs(), getNumTemplateArgs()};
3890 }
3891
3892 SourceLocation getBeginLoc() const LLVM_READONLY {
3893 if (!isImplicitAccess())
3894 return Base->getBeginLoc();
3895 if (getQualifier())
3896 return getQualifierLoc().getBeginLoc();
3897 return MemberNameInfo.getBeginLoc();
3898 }
3899
3900 SourceLocation getEndLoc() const LLVM_READONLY {
3902 return getRAngleLoc();
3903 return MemberNameInfo.getEndLoc();
3904 }
3905
3906 static bool classof(const Stmt *T) {
3907 return T->getStmtClass() == CXXDependentScopeMemberExprClass;
3908 }
3909
3910 // Iterators
3912 if (isImplicitAccess())
3914 return child_range(&Base, &Base + 1);
3915 }
3916
3918 if (isImplicitAccess())
3920 return const_child_range(&Base, &Base + 1);
3921 }
3922};
3923
3924/// Represents a C++ member access expression for which lookup
3925/// produced a set of overloaded functions.
3926///
3927/// The member access may be explicit or implicit:
3928/// \code
3929/// struct A {
3930/// int a, b;
3931/// int explicitAccess() { return this->a + this->A::b; }
3932/// int implicitAccess() { return a + A::b; }
3933/// };
3934/// \endcode
3935///
3936/// In the final AST, an explicit access always becomes a MemberExpr.
3937/// An implicit access may become either a MemberExpr or a
3938/// DeclRefExpr, depending on whether the member is static.
3940 : public OverloadExpr,
3941 private llvm::TrailingObjects<UnresolvedMemberExpr, DeclAccessPair,
3942 ASTTemplateKWAndArgsInfo,
3943 TemplateArgumentLoc> {
3944 friend class ASTStmtReader;
3945 friend class OverloadExpr;
3946 friend TrailingObjects;
3947
3948 /// The expression for the base pointer or class reference,
3949 /// e.g., the \c x in x.f.
3950 ///
3951 /// This can be null if this is an 'unbased' member expression.
3952 Stmt *Base;
3953
3954 /// The type of the base expression; never null.
3955 QualType BaseType;
3956
3957 /// The location of the '->' or '.' operator.
3958 SourceLocation OperatorLoc;
3959
3960 // UnresolvedMemberExpr is followed by several trailing objects.
3961 // They are in order:
3962 //
3963 // * An array of getNumResults() DeclAccessPair for the results. These are
3964 // undesugared, which is to say, they may include UsingShadowDecls.
3965 // Access is relative to the naming class.
3966 //
3967 // * An optional ASTTemplateKWAndArgsInfo for the explicitly specified
3968 // template keyword and arguments. Present if and only if
3969 // hasTemplateKWAndArgsInfo().
3970 //
3971 // * An array of getNumTemplateArgs() TemplateArgumentLoc containing
3972 // location information for the explicitly specified template arguments.
3973
3974 UnresolvedMemberExpr(const ASTContext &Context, bool HasUnresolvedUsing,
3975 Expr *Base, QualType BaseType, bool IsArrow,
3976 SourceLocation OperatorLoc,
3977 NestedNameSpecifierLoc QualifierLoc,
3978 SourceLocation TemplateKWLoc,
3979 const DeclarationNameInfo &MemberNameInfo,
3980 const TemplateArgumentListInfo *TemplateArgs,
3982
3983 UnresolvedMemberExpr(EmptyShell Empty, unsigned NumResults,
3984 bool HasTemplateKWAndArgsInfo);
3985
3986 unsigned numTrailingObjects(OverloadToken<DeclAccessPair>) const {
3987 return getNumDecls();
3988 }
3989
3990 unsigned numTrailingObjects(OverloadToken<ASTTemplateKWAndArgsInfo>) const {
3991 return hasTemplateKWAndArgsInfo();
3992 }
3993
3994public:
3995 static UnresolvedMemberExpr *
3996 Create(const ASTContext &Context, bool HasUnresolvedUsing, Expr *Base,
3997 QualType BaseType, bool IsArrow, SourceLocation OperatorLoc,
3998 NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc,
3999 const DeclarationNameInfo &MemberNameInfo,
4000 const TemplateArgumentListInfo *TemplateArgs,
4001 UnresolvedSetIterator Begin, UnresolvedSetIterator End);
4002
4003 static UnresolvedMemberExpr *CreateEmpty(const ASTContext &Context,
4004 unsigned NumResults,
4005 bool HasTemplateKWAndArgsInfo,
4006 unsigned NumTemplateArgs);
4007
4008 /// True if this is an implicit access, i.e., one in which the
4009 /// member being accessed was not written in the source.
4010 ///
4011 /// The source location of the operator is invalid in this case.
4012 bool isImplicitAccess() const;
4013
4014 /// Retrieve the base object of this member expressions,
4015 /// e.g., the \c x in \c x.m.
4017 assert(!isImplicitAccess());
4018 return cast<Expr>(Base);
4019 }
4020 const Expr *getBase() const {
4021 assert(!isImplicitAccess());
4022 return cast<Expr>(Base);
4023 }
4024
4025 QualType getBaseType() const { return BaseType; }
4026
4027 /// Determine whether the lookup results contain an unresolved using
4028 /// declaration.
4029 bool hasUnresolvedUsing() const {
4030 return UnresolvedMemberExprBits.HasUnresolvedUsing;
4031 }
4032
4033 /// Determine whether this member expression used the '->'
4034 /// operator; otherwise, it used the '.' operator.
4035 bool isArrow() const { return UnresolvedMemberExprBits.IsArrow; }
4036
4037 /// Retrieve the location of the '->' or '.' operator.
4038 SourceLocation getOperatorLoc() const { return OperatorLoc; }
4039
4040 /// Retrieve the naming class of this lookup.
4043 return const_cast<UnresolvedMemberExpr *>(this)->getNamingClass();
4044 }
4045
4046 /// Retrieve the full name info for the member that this expression
4047 /// refers to.
4049
4050 /// Retrieve the name of the member that this expression refers to.
4052
4053 /// Retrieve the location of the name of the member that this
4054 /// expression refers to.
4056
4057 /// Return the preferred location (the member name) for the arrow when
4058 /// diagnosing a problem with this expression.
4059 SourceLocation getExprLoc() const LLVM_READONLY { return getMemberLoc(); }
4060
4061 SourceLocation getBeginLoc() const LLVM_READONLY {
4062 if (!isImplicitAccess())
4063 return Base->getBeginLoc();
4065 return l.getBeginLoc();
4066 return getMemberNameInfo().getBeginLoc();
4067 }
4068
4069 SourceLocation getEndLoc() const LLVM_READONLY {
4071 return getRAngleLoc();
4072 return getMemberNameInfo().getEndLoc();
4073 }
4074
4075 static bool classof(const Stmt *T) {
4076 return T->getStmtClass() == UnresolvedMemberExprClass;
4077 }
4078
4079 // Iterators
4081 if (isImplicitAccess())
4083 return child_range(&Base, &Base + 1);
4084 }
4085
4087 if (isImplicitAccess())
4089 return const_child_range(&Base, &Base + 1);
4090 }
4091};
4092
4094 if (auto *ULE = dyn_cast<UnresolvedLookupExpr>(this))
4095 return ULE->getTrailingObjects<DeclAccessPair>();
4096 return cast<UnresolvedMemberExpr>(this)->getTrailingObjects<DeclAccessPair>();
4097}
4098
4101 return nullptr;
4102
4103 if (auto *ULE = dyn_cast<UnresolvedLookupExpr>(this))
4104 return ULE->getTrailingObjects<ASTTemplateKWAndArgsInfo>();
4105 return cast<UnresolvedMemberExpr>(this)
4106 ->getTrailingObjects<ASTTemplateKWAndArgsInfo>();
4107}
4108
4110 if (auto *ULE = dyn_cast<UnresolvedLookupExpr>(this))
4111 return ULE->getTrailingObjects<TemplateArgumentLoc>();
4112 return cast<UnresolvedMemberExpr>(this)
4113 ->getTrailingObjects<TemplateArgumentLoc>();
4114}
4115
4117 if (auto *ULE = dyn_cast<UnresolvedLookupExpr>(this))
4118 return ULE->getNamingClass();
4119 return cast<UnresolvedMemberExpr>(this)->getNamingClass();
4120}
4121
4122/// Represents a C++11 noexcept expression (C++ [expr.unary.noexcept]).
4123///
4124/// The noexcept expression tests whether a given expression might throw. Its
4125/// result is a boolean constant.
4126class CXXNoexceptExpr : public Expr {
4127 friend class ASTStmtReader;
4128
4129 Stmt *Operand;
4131
4132public:
4134 SourceLocation Keyword, SourceLocation RParen)
4135 : Expr(CXXNoexceptExprClass, Ty, VK_PRValue, OK_Ordinary),
4136 Operand(Operand), Range(Keyword, RParen) {
4137 CXXNoexceptExprBits.Value = Val == CT_Cannot;
4138 setDependence(computeDependence(this, Val));
4139 }
4140
4141 CXXNoexceptExpr(EmptyShell Empty) : Expr(CXXNoexceptExprClass, Empty) {}
4142
4143 Expr *getOperand() const { return static_cast<Expr *>(Operand); }
4144
4145 SourceLocation getBeginLoc() const { return Range.getBegin(); }
4146 SourceLocation getEndLoc() const { return Range.getEnd(); }
4148
4149 bool getValue() const { return CXXNoexceptExprBits.Value; }
4150
4151 static bool classof(const Stmt *T) {
4152 return T->getStmtClass() == CXXNoexceptExprClass;
4153 }
4154
4155 // Iterators
4156 child_range children() { return child_range(&Operand, &Operand + 1); }
4157
4159 return const_child_range(&Operand, &Operand + 1);
4160 }
4161};
4162
4163/// Represents a C++11 pack expansion that produces a sequence of
4164/// expressions.
4165///
4166/// A pack expansion expression contains a pattern (which itself is an
4167/// expression) followed by an ellipsis. For example:
4168///
4169/// \code
4170/// template<typename F, typename ...Types>
4171/// void forward(F f, Types &&...args) {
4172/// f(static_cast<Types&&>(args)...);
4173/// }
4174/// \endcode
4175///
4176/// Here, the argument to the function object \c f is a pack expansion whose
4177/// pattern is \c static_cast<Types&&>(args). When the \c forward function
4178/// template is instantiated, the pack expansion will instantiate to zero or
4179/// or more function arguments to the function object \c f.
4180class PackExpansionExpr : public Expr {
4181 friend class ASTStmtReader;
4182 friend class ASTStmtWriter;
4183
4184 SourceLocation EllipsisLoc;
4185
4186 /// The number of expansions that will be produced by this pack
4187 /// expansion expression, if known.
4188 ///
4189 /// When zero, the number of expansions is not known. Otherwise, this value
4190 /// is the number of expansions + 1.
4191 unsigned NumExpansions;
4192
4193 Stmt *Pattern;
4194
4195public:
4197 std::optional<unsigned> NumExpansions)
4198 : Expr(PackExpansionExprClass, T, Pattern->getValueKind(),
4199 Pattern->getObjectKind()),
4200 EllipsisLoc(EllipsisLoc),
4201 NumExpansions(NumExpansions ? *NumExpansions + 1 : 0),
4202 Pattern(Pattern) {
4204 }
4205
4206 PackExpansionExpr(EmptyShell Empty) : Expr(PackExpansionExprClass, Empty) {}
4207
4208 /// Retrieve the pattern of the pack expansion.
4209 Expr *getPattern() { return reinterpret_cast<Expr *>(Pattern); }
4210
4211 /// Retrieve the pattern of the pack expansion.
4212 const Expr *getPattern() const { return reinterpret_cast<Expr *>(Pattern); }
4213
4214 /// Retrieve the location of the ellipsis that describes this pack
4215 /// expansion.
4216 SourceLocation getEllipsisLoc() const { return EllipsisLoc; }
4217
4218 /// Determine the number of expansions that will be produced when
4219 /// this pack expansion is instantiated, if already known.
4220 std::optional<unsigned> getNumExpansions() const {
4221 if (NumExpansions)
4222 return NumExpansions - 1;
4223
4224 return std::nullopt;
4225 }
4226
4227 SourceLocation getBeginLoc() const LLVM_READONLY {
4228 return Pattern->getBeginLoc();
4229 }
4230
4231 SourceLocation getEndLoc() const LLVM_READONLY { return EllipsisLoc; }
4232
4233 static bool classof(const Stmt *T) {
4234 return T->getStmtClass() == PackExpansionExprClass;
4235 }
4236
4237 // Iterators
4239 return child_range(&Pattern, &Pattern + 1);
4240 }
4241
4243 return const_child_range(&Pattern, &Pattern + 1);
4244 }
4245};
4246
4247/// Represents an expression that computes the length of a parameter
4248/// pack.
4249///
4250/// \code
4251/// template<typename ...Types>
4252/// struct count {
4253/// static const unsigned value = sizeof...(Types);
4254/// };
4255/// \endcode
4257 : public Expr,
4258 private llvm::TrailingObjects<SizeOfPackExpr, TemplateArgument> {
4259 friend class ASTStmtReader;
4260 friend class ASTStmtWriter;
4261 friend TrailingObjects;
4262
4263 /// The location of the \c sizeof keyword.
4264 SourceLocation OperatorLoc;
4265
4266 /// The location of the name of the parameter pack.
4267 SourceLocation PackLoc;
4268
4269 /// The location of the closing parenthesis.
4270 SourceLocation RParenLoc;
4271
4272 /// The length of the parameter pack, if known.
4273 ///
4274 /// When this expression is not value-dependent, this is the length of
4275 /// the pack. When the expression was parsed rather than instantiated
4276 /// (and thus is value-dependent), this is zero.
4277 ///
4278 /// After partial substitution into a sizeof...(X) expression (for instance,
4279 /// within an alias template or during function template argument deduction),
4280 /// we store a trailing array of partially-substituted TemplateArguments,
4281 /// and this is the length of that array.
4282 unsigned Length;
4283
4284 /// The parameter pack.
4285 NamedDecl *Pack = nullptr;
4286
4287 /// Create an expression that computes the length of
4288 /// the given parameter pack.
4289 SizeOfPackExpr(QualType SizeType, SourceLocation OperatorLoc, NamedDecl *Pack,
4290 SourceLocation PackLoc, SourceLocation RParenLoc,
4291 std::optional<unsigned> Length,
4292 ArrayRef<TemplateArgument> PartialArgs)
4293 : Expr(SizeOfPackExprClass, SizeType, VK_PRValue, OK_Ordinary),
4294 OperatorLoc(OperatorLoc), PackLoc(PackLoc), RParenLoc(RParenLoc),
4295 Length(Length ? *Length : PartialArgs.size()), Pack(Pack) {
4296 assert((!Length || PartialArgs.empty()) &&
4297 "have partial args for non-dependent sizeof... expression");
4298 auto *Args = getTrailingObjects<TemplateArgument>();
4299 std::uninitialized_copy(PartialArgs.begin(), PartialArgs.end(), Args);
4300 setDependence(Length ? ExprDependence::None
4301 : ExprDependence::ValueInstantiation);
4302 }
4303
4304 /// Create an empty expression.
4305 SizeOfPackExpr(EmptyShell Empty, unsigned NumPartialArgs)
4306 : Expr(SizeOfPackExprClass, Empty), Length(NumPartialArgs) {}
4307
4308public:
4309 static SizeOfPackExpr *
4310 Create(ASTContext &Context, SourceLocation OperatorLoc, NamedDecl *Pack,
4311 SourceLocation PackLoc, SourceLocation RParenLoc,
4312 std::optional<unsigned> Length = std::nullopt,
4313 ArrayRef<TemplateArgument> PartialArgs = std::nullopt);
4314 static SizeOfPackExpr *CreateDeserialized(ASTContext &Context,
4315 unsigned NumPartialArgs);
4316
4317 /// Determine the location of the 'sizeof' keyword.
4318 SourceLocation getOperatorLoc() const { return OperatorLoc; }
4319
4320 /// Determine the location of the parameter pack.
4321 SourceLocation getPackLoc() const { return PackLoc; }
4322
4323 /// Determine the location of the right parenthesis.
4324 SourceLocation getRParenLoc() const { return RParenLoc; }
4325
4326 /// Retrieve the parameter pack.
4327 NamedDecl *getPack() const { return Pack; }
4328
4329 /// Retrieve the length of the parameter pack.
4330 ///
4331 /// This routine may only be invoked when the expression is not
4332 /// value-dependent.
4333 unsigned getPackLength() const {
4334 assert(!isValueDependent() &&
4335 "Cannot get the length of a value-dependent pack size expression");
4336 return Length;
4337 }
4338
4339 /// Determine whether this represents a partially-substituted sizeof...
4340 /// expression, such as is produced for:
4341 ///
4342 /// template<typename ...Ts> using X = int[sizeof...(Ts)];
4343 /// template<typename ...Us> void f(X<Us..., 1, 2, 3, Us...>);
4345 return isValueDependent() && Length;
4346 }
4347
4348 /// Get
4350 assert(isPartiallySubstituted());
4351 const auto *Args = getTrailingObjects<TemplateArgument>();
4352 return llvm::ArrayRef(Args, Args + Length);
4353 }
4354
4355 SourceLocation getBeginLoc() const LLVM_READONLY { return OperatorLoc; }
4356 SourceLocation getEndLoc() const LLVM_READONLY { return RParenLoc; }
4357
4358 static bool classof(const Stmt *T) {
4359 return T->getStmtClass() == SizeOfPackExprClass;
4360 }
4361
4362 // Iterators
4365 }
4366
4369 }
4370};
4371
4373 : public Expr,
4374 private llvm::TrailingObjects<PackIndexingExpr, Expr *> {
4375 friend class ASTStmtReader;
4376 friend class ASTStmtWriter;
4377 friend TrailingObjects;
4378
4379 SourceLocation EllipsisLoc;
4380
4381 // The location of the closing bracket
4382 SourceLocation RSquareLoc;
4383
4384 // The pack being indexed, followed by the index
4385 Stmt *SubExprs[2];
4386
4387 // The size of the trailing expressions.
4388 unsigned TransformedExpressions : 31;
4389
4390 LLVM_PREFERRED_TYPE(bool)
4391 unsigned ExpandedToEmptyPack : 1;
4392
4394 SourceLocation RSquareLoc, Expr *PackIdExpr, Expr *IndexExpr,
4395 ArrayRef<Expr *> SubstitutedExprs = {},
4396 bool ExpandedToEmptyPack = false)
4397 : Expr(PackIndexingExprClass, Type, VK_LValue, OK_Ordinary),
4398 EllipsisLoc(EllipsisLoc), RSquareLoc(RSquareLoc),
4399 SubExprs{PackIdExpr, IndexExpr},
4400 TransformedExpressions(SubstitutedExprs.size()),
4401 ExpandedToEmptyPack(ExpandedToEmptyPack) {
4402
4403 auto *Exprs = getTrailingObjects<Expr *>();
4404 std::uninitialized_copy(SubstitutedExprs.begin(), SubstitutedExprs.end(),
4405 Exprs);
4406
4410 }
4411
4412 /// Create an empty expression.
4413 PackIndexingExpr(EmptyShell Empty) : Expr(PackIndexingExprClass, Empty) {}
4414
4415 unsigned numTrailingObjects(OverloadToken<Expr *>) const {
4416 return TransformedExpressions;
4417 }
4418
4419public:
4420 static PackIndexingExpr *Create(ASTContext &Context,
4421 SourceLocation EllipsisLoc,
4422 SourceLocation RSquareLoc, Expr *PackIdExpr,
4423 Expr *IndexExpr, std::optional<int64_t> Index,
4424 ArrayRef<Expr *> SubstitutedExprs = {},
4425 bool ExpandedToEmptyPack = false);
4426 static PackIndexingExpr *CreateDeserialized(ASTContext &Context,
4427 unsigned NumTransformedExprs);
4428
4429 /// Determine if the expression was expanded to empty.
4430 bool expandsToEmptyPack() const { return ExpandedToEmptyPack; }
4431
4432 /// Determine the location of the 'sizeof' keyword.
4433 SourceLocation getEllipsisLoc() const { return EllipsisLoc; }
4434
4435 /// Determine the location of the parameter pack.
4436 SourceLocation getPackLoc() const { return SubExprs[0]->getBeginLoc(); }
4437
4438 /// Determine the location of the right parenthesis.
4439 SourceLocation getRSquareLoc() const { return RSquareLoc; }
4440
4441 SourceLocation getBeginLoc() const LLVM_READONLY { return getPackLoc(); }
4442 SourceLocation getEndLoc() const LLVM_READONLY { return RSquareLoc; }
4443
4444 Expr *getPackIdExpression() const { return cast<Expr>(SubExprs[0]); }
4445
4446 NamedDecl *getPackDecl() const;
4447
4448 Expr *getIndexExpr() const { return cast<Expr>(SubExprs[1]); }
4449
4450 std::optional<unsigned> getSelectedIndex() const {
4452 return std::nullopt;
4453 ConstantExpr *CE = cast<ConstantExpr>(getIndexExpr());
4454 auto Index = CE->getResultAsAPSInt();
4455 assert(Index.isNonNegative() && "Invalid index");
4456 return static_cast<unsigned>(Index.getExtValue());
4457 }
4458
4460 std::optional<unsigned> Index = getSelectedIndex();
4461 assert(Index && "extracting the indexed expression of a dependant pack");
4462 return getTrailingObjects<Expr *>()[*Index];
4463 }
4464
4465 /// Return the trailing expressions, regardless of the expansion.
4467 return {getTrailingObjects<Expr *>(), TransformedExpressions};
4468 }
4469
4470 static bool classof(const Stmt *T) {
4471 return T->getStmtClass() == PackIndexingExprClass;
4472 }
4473
4474 // Iterators
4475 child_range children() { return child_range(SubExprs, SubExprs + 2); }
4476
4478 return const_child_range(SubExprs, SubExprs + 2);
4479 }
4480};
4481
4482/// Represents a reference to a non-type template parameter
4483/// that has been substituted with a template argument.
4485 friend class ASTReader;
4486 friend class ASTStmtReader;
4487
4488 /// The replacement expression.
4489 Stmt *Replacement;
4490
4491 /// The associated declaration and a flag indicating if it was a reference
4492 /// parameter. For class NTTPs, we can't determine that based on the value
4493 /// category alone.
4494 llvm::PointerIntPair<Decl *, 1, bool> AssociatedDeclAndRef;
4495
4496 unsigned Index : 15;
4497 unsigned PackIndex : 16;
4498
4500 : Expr(SubstNonTypeTemplateParmExprClass, Empty) {}
4501
4502public:
4504 SourceLocation Loc, Expr *Replacement,
4505 Decl *AssociatedDecl, unsigned Index,
4506 std::optional<unsigned> PackIndex, bool RefParam)
4507 : Expr(SubstNonTypeTemplateParmExprClass, Ty, ValueKind, OK_Ordinary),
4508 Replacement(Replacement),
4509 AssociatedDeclAndRef(AssociatedDecl, RefParam), Index(Index),
4510 PackIndex(PackIndex ? *PackIndex + 1 : 0) {
4511 assert(AssociatedDecl != nullptr);
4514 }
4515
4517 return SubstNonTypeTemplateParmExprBits.NameLoc;
4518 }
4521
4522 Expr *getReplacement() const { return cast<Expr>(Replacement); }
4523
4524 /// A template-like entity which owns the whole pattern being substituted.
4525 /// This will own a set of template parameters.
4526 Decl *getAssociatedDecl() const { return AssociatedDeclAndRef.getPointer(); }
4527
4528 /// Returns the index of the replaced parameter in the associated declaration.
4529 /// This should match the result of `getParameter()->getIndex()`.
4530 unsigned getIndex() const { return Index; }
4531
4532 std::optional<unsigned> getPackIndex() const {
4533 if (PackIndex == 0)
4534 return std::nullopt;
4535 return PackIndex - 1;
4536 }
4537
4539
4540 bool isReferenceParameter() const { return AssociatedDeclAndRef.getInt(); }
4541
4542 /// Determine the substituted type of the template parameter.
4543 QualType getParameterType(const ASTContext &Ctx) const;
4544
4545 static bool classof(const Stmt *s) {
4546 return s->getStmtClass() == SubstNonTypeTemplateParmExprClass;
4547 }
4548
4549 // Iterators
4550 child_range children() { return child_range(&Replacement, &Replacement + 1); }
4551
4553 return const_child_range(&Replacement, &Replacement + 1);
4554 }
4555};
4556
4557/// Represents a reference to a non-type template parameter pack that
4558/// has been substituted with a non-template argument pack.
4559///
4560/// When a pack expansion in the source code contains multiple parameter packs
4561/// and those parameter packs correspond to different levels of template
4562/// parameter lists, this node is used to represent a non-type template
4563/// parameter pack from an outer level, which has already had its argument pack
4564/// substituted but that still lives within a pack expansion that itself
4565/// could not be instantiated. When actually performing a substitution into
4566/// that pack expansion (e.g., when all template parameters have corresponding
4567/// arguments), this type will be replaced with the appropriate underlying
4568/// expression at the current pack substitution index.
4570 friend class ASTReader;
4571 friend class ASTStmtReader;
4572
4573 /// The non-type template parameter pack itself.
4574 Decl *AssociatedDecl;
4575
4576 /// A pointer to the set of template arguments that this
4577 /// parameter pack is instantiated with.
4578 const TemplateArgument *Arguments;
4579
4580 /// The number of template arguments in \c Arguments.
4581 unsigned NumArguments : 16;
4582
4583 unsigned Index : 16;
4584
4585 /// The location of the non-type template parameter pack reference.
4586 SourceLocation NameLoc;
4587
4589 : Expr(SubstNonTypeTemplateParmPackExprClass, Empty) {}
4590
4591public:
4593 SourceLocation NameLoc,
4594 const TemplateArgument &ArgPack,
4595 Decl *AssociatedDecl, unsigned Index);
4596
4597 /// A template-like entity which owns the whole pattern being substituted.
4598 /// This will own a set of template parameters.
4599 Decl *getAssociatedDecl() const { return AssociatedDecl; }
4600
4601 /// Returns the index of the replaced parameter in the associated declaration.
4602 /// This should match the result of `getParameterPack()->getIndex()`.
4603 unsigned getIndex() const { return Index; }
4604
4605 /// Retrieve the non-type template parameter pack being substituted.
4607
4608 /// Retrieve the location of the parameter pack name.
4609 SourceLocation getParameterPackLocation() const { return NameLoc; }
4610
4611 /// Retrieve the template argument pack containing the substituted
4612 /// template arguments.
4614
4615 SourceLocation getBeginLoc() const LLVM_READONLY { return NameLoc; }
4616 SourceLocation getEndLoc() const LLVM_READONLY { return NameLoc; }
4617
4618 static bool classof(const Stmt *T) {
4619 return T->getStmtClass() == SubstNonTypeTemplateParmPackExprClass;
4620 }
4621
4622 // Iterators
4625 }
4626
4629 }
4630};
4631
4632/// Represents a reference to a function parameter pack or init-capture pack
4633/// that has been substituted but not yet expanded.
4634///
4635/// When a pack expansion contains multiple parameter packs at different levels,
4636/// this node is used to represent a function parameter pack at an outer level
4637/// which we have already substituted to refer to expanded parameters, but where
4638/// the containing pack expansion cannot yet be expanded.
4639///
4640/// \code
4641/// template<typename...Ts> struct S {
4642/// template<typename...Us> auto f(Ts ...ts) -> decltype(g(Us(ts)...));
4643/// };
4644/// template struct S<int, int>;
4645/// \endcode
4647 : public Expr,
4648 private llvm::TrailingObjects<FunctionParmPackExpr, VarDecl *> {
4649 friend class ASTReader;
4650 friend class ASTStmtReader;
4651 friend TrailingObjects;
4652
4653 /// The function parameter pack which was referenced.
4654 VarDecl *ParamPack;
4655
4656 /// The location of the function parameter pack reference.
4657 SourceLocation NameLoc;
4658
4659 /// The number of expansions of this pack.
4660 unsigned NumParameters;
4661
4663 SourceLocation NameLoc, unsigned NumParams,
4664 VarDecl *const *Params);
4665
4666public:
4667 static FunctionParmPackExpr *Create(const ASTContext &Context, QualType T,
4668 VarDecl *ParamPack,
4669 SourceLocation NameLoc,
4670 ArrayRef<VarDecl *> Params);
4671 static FunctionParmPackExpr *CreateEmpty(const ASTContext &Context,
4672 unsigned NumParams);
4673
4674 /// Get the parameter pack which this expression refers to.
4675 VarDecl *getParameterPack() const { return ParamPack; }
4676
4677 /// Get the location of the parameter pack.
4678 SourceLocation getParameterPackLocation() const { return NameLoc; }
4679
4680 /// Iterators over the parameters which the parameter pack expanded
4681 /// into.
4682 using iterator = VarDecl * const *;
4683 iterator begin() const { return getTrailingObjects<VarDecl *>(); }
4684 iterator end() const { return begin() + NumParameters; }
4685
4686 /// Get the number of parameters in this parameter pack.
4687 unsigned getNumExpansions() const { return NumParameters; }
4688
4689 /// Get an expansion of the parameter pack by index.
4690 VarDecl *getExpansion(unsigned I) const { return begin()[I]; }
4691
4692 SourceLocation getBeginLoc() const LLVM_READONLY { return NameLoc; }
4693 SourceLocation getEndLoc() const LLVM_READONLY { return NameLoc; }
4694
4695 static bool classof(const Stmt *T) {
4696 return T->getStmtClass() == FunctionParmPackExprClass;
4697 }
4698
4701 }
4702
4705 }
4706};
4707
4708/// Represents a prvalue temporary that is written into memory so that
4709/// a reference can bind to it.
4710///
4711/// Prvalue expressions are materialized when they need to have an address
4712/// in memory for a reference to bind to. This happens when binding a
4713/// reference to the result of a conversion, e.g.,
4714///
4715/// \code
4716/// const int &r = 1.0;
4717/// \endcode
4718///
4719/// Here, 1.0 is implicitly converted to an \c int. That resulting \c int is
4720/// then materialized via a \c MaterializeTemporaryExpr, and the reference
4721/// binds to the temporary. \c MaterializeTemporaryExprs are always glvalues
4722/// (either an lvalue or an xvalue, depending on the kind of reference binding
4723/// to it), maintaining the invariant that references always bind to glvalues.
4724///
4725/// Reference binding and copy-elision can both extend the lifetime of a
4726/// temporary. When either happens, the expression will also track the
4727/// declaration which is responsible for the lifetime extension.
4729private:
4730 friend class ASTStmtReader;
4731 friend class ASTStmtWriter;
4732
4733 llvm::PointerUnion<Stmt *, LifetimeExtendedTemporaryDecl *> State;
4734
4735public:
4737 bool BoundToLvalueReference,
4738 LifetimeExtendedTemporaryDecl *MTD = nullptr);
4739
4741 : Expr(MaterializeTemporaryExprClass, Empty) {}
4742
4743 /// Retrieve the temporary-generating subexpression whose value will
4744 /// be materialized into a glvalue.
4745 Expr *getSubExpr() const {
4746 return cast<Expr>(
4747 State.is<Stmt *>()
4748 ? State.get<Stmt *>()
4750 }
4751
4752 /// Retrieve the storage duration for the materialized temporary.
4754 return State.is<Stmt *>() ? SD_FullExpression
4755 : State.get<LifetimeExtendedTemporaryDecl *>()
4757 }
4758
4759 /// Get the storage for the constant value of a materialized temporary
4760 /// of static storage duration.
4761 APValue *getOrCreateValue(bool MayCreate) const {
4762 assert(State.is<LifetimeExtendedTemporaryDecl *>() &&
4763 "the temporary has not been lifetime extended");
4764 return State.get<LifetimeExtendedTemporaryDecl *>()->getOrCreateValue(
4765 MayCreate);
4766 }
4767
4769 return State.dyn_cast<LifetimeExtendedTemporaryDecl *>();
4770 }
4773 return State.dyn_cast<LifetimeExtendedTemporaryDecl *>();
4774 }
4775
4776 /// Get the declaration which triggered the lifetime-extension of this
4777 /// temporary, if any.
4779 return State.is<Stmt *>() ? nullptr
4780 : State.get<LifetimeExtendedTemporaryDecl *>()
4781 ->getExtendingDecl();
4782 }
4784 return const_cast<MaterializeTemporaryExpr *>(this)->getExtendingDecl();
4785 }
4786
4787 void setExtendingDecl(ValueDecl *ExtendedBy, unsigned ManglingNumber);
4788
4789 unsigned getManglingNumber() const {
4790 return State.is<Stmt *>() ? 0
4791 : State.get<LifetimeExtendedTemporaryDecl *>()
4793 }
4794
4795 /// Determine whether this materialized temporary is bound to an
4796 /// lvalue reference; otherwise, it's bound to an rvalue reference.
4797 bool isBoundToLvalueReference() const { return isLValue(); }
4798
4799 /// Determine whether this temporary object is usable in constant
4800 /// expressions, as specified in C++20 [expr.const]p4.
4801 bool isUsableInConstantExpressions(const ASTContext &Context) const;
4802
4803 SourceLocation getBeginLoc() const LLVM_READONLY {
4804 return getSubExpr()->getBeginLoc();
4805 }
4806
4807 SourceLocation getEndLoc() const LLVM_READONLY {
4808 return getSubExpr()->getEndLoc();
4809 }
4810
4811 static bool classof(const Stmt *T) {
4812 return T->getStmtClass() == MaterializeTemporaryExprClass;
4813 }
4814
4815 // Iterators
4817 return State.is<Stmt *>()
4818 ? child_range(State.getAddrOfPtr1(), State.getAddrOfPtr1() + 1)
4819 : State.get<LifetimeExtendedTemporaryDecl *>()->childrenExpr();
4820 }
4821
4823 return State.is<Stmt *>()
4824 ? const_child_range(State.getAddrOfPtr1(),
4825 State.getAddrOfPtr1() + 1)
4826 : const_cast<const LifetimeExtendedTemporaryDecl *>(
4827 State.get<LifetimeExtendedTemporaryDecl *>())
4828 ->childrenExpr();
4829 }
4830};
4831
4832/// Represents a folding of a pack over an operator.
4833///
4834/// This expression is always dependent and represents a pack expansion of the
4835/// forms:
4836///
4837/// ( expr op ... )
4838/// ( ... op expr )
4839/// ( expr op ... op expr )
4840class CXXFoldExpr : public Expr {
4841 friend class ASTStmtReader;
4842 friend class ASTStmtWriter;
4843
4844 enum SubExpr { Callee, LHS, RHS, Count };
4845
4846 SourceLocation LParenLoc;
4847 SourceLocation EllipsisLoc;
4848 SourceLocation RParenLoc;
4849 // When 0, the number of expansions is not known. Otherwise, this is one more
4850 // than the number of expansions.
4851 unsigned NumExpansions;
4852 Stmt *SubExprs[SubExpr::Count];
4853 BinaryOperatorKind Opcode;
4854
4855public:
4857 SourceLocation LParenLoc, Expr *LHS, BinaryOperatorKind Opcode,
4858 SourceLocation EllipsisLoc, Expr *RHS, SourceLocation RParenLoc,
4859 std::optional<unsigned> NumExpansions);
4860
4861 CXXFoldExpr(EmptyShell Empty) : Expr(CXXFoldExprClass, Empty) {}
4862
4864 return static_cast<UnresolvedLookupExpr *>(SubExprs[SubExpr::Callee]);
4865 }
4866 Expr *getLHS() const { return static_cast<Expr*>(SubExprs[SubExpr::LHS]); }
4867 Expr *getRHS() const { return static_cast<Expr*>(SubExprs[SubExpr::RHS]); }
4868
4869 /// Does this produce a right-associated sequence of operators?
4870 bool isRightFold() const {
4872 }
4873
4874 /// Does this produce a left-associated sequence of operators?
4875 bool isLeftFold() const { return !isRightFold(); }
4876
4877 /// Get the pattern, that is, the operand that contains an unexpanded pack.
4878 Expr *getPattern() const { return isLeftFold() ? getRHS() : getLHS(); }
4879
4880 /// Get the operand that doesn't contain a pack, for a binary fold.
4881 Expr *getInit() const { return isLeftFold() ? getLHS() : getRHS(); }
4882
4883 SourceLocation getLParenLoc() const { return LParenLoc; }
4884 SourceLocation getRParenLoc() const { return RParenLoc; }
4885 SourceLocation getEllipsisLoc() const { return EllipsisLoc; }
4886 BinaryOperatorKind getOperator() const { return Opcode; }
4887
4888 std::optional<unsigned> getNumExpansions() const {
4889 if (NumExpansions)
4890 return NumExpansions - 1;
4891 return std::nullopt;
4892 }
4893
4894 SourceLocation getBeginLoc() const LLVM_READONLY {
4895 if (LParenLoc.isValid())
4896 return LParenLoc;
4897 if (isLeftFold())
4898 return getEllipsisLoc();
4899 return getLHS()->getBeginLoc();
4900 }
4901
4902 SourceLocation getEndLoc() const LLVM_READONLY {
4903 if (RParenLoc.isValid())
4904 return RParenLoc;
4905 if (isRightFold())
4906 return getEllipsisLoc();
4907 return getRHS()->getEndLoc();
4908 }
4909
4910 static bool classof(const Stmt *T) {
4911 return T->getStmtClass() == CXXFoldExprClass;
4912 }
4913
4914 // Iterators
4916 return child_range(SubExprs, SubExprs + SubExpr::Count);
4917 }
4918
4920 return const_child_range(SubExprs, SubExprs + SubExpr::Count);
4921 }
4922};
4923
4924/// Represents a list-initialization with parenthesis.
4925///
4926/// As per P0960R3, this is a C++20 feature that allows aggregate to
4927/// be initialized with a parenthesized list of values:
4928/// ```
4929/// struct A {
4930/// int a;
4931/// double b;
4932/// };
4933///
4934/// void foo() {
4935/// A a1(0); // Well-formed in C++20
4936/// A a2(1.5, 1.0); // Well-formed in C++20
4937/// }
4938/// ```
4939/// It has some sort of similiarity to braced
4940/// list-initialization, with some differences such as
4941/// it allows narrowing conversion whilst braced
4942/// list-initialization doesn't.
4943/// ```
4944/// struct A {
4945/// char a;
4946/// };
4947/// void foo() {
4948/// A a(1.5); // Well-formed in C++20
4949/// A b{1.5}; // Ill-formed !
4950/// }
4951/// ```
4953 : public Expr,
4954 private llvm::TrailingObjects<CXXParenListInitExpr, Expr *> {
4955 friend class TrailingObjects;
4956 friend class ASTStmtReader;
4957 friend class ASTStmtWriter;
4958
4959 unsigned NumExprs;
4960 unsigned NumUserSpecifiedExprs;
4961 SourceLocation InitLoc, LParenLoc, RParenLoc;
4962 llvm::PointerUnion<Expr *, FieldDecl *> ArrayFillerOrUnionFieldInit;
4963
4965 unsigned NumUserSpecifiedExprs, SourceLocation InitLoc,
4966 SourceLocation LParenLoc, SourceLocation RParenLoc)
4967 : Expr(CXXParenListInitExprClass, T, getValueKindForType(T), OK_Ordinary),
4968 NumExprs(Args.size()), NumUserSpecifiedExprs(NumUserSpecifiedExprs),
4969 InitLoc(InitLoc), LParenLoc(LParenLoc), RParenLoc(RParenLoc) {
4970 std::copy(Args.begin(), Args.end(), getTrailingObjects<Expr *>());
4971 assert(NumExprs >= NumUserSpecifiedExprs &&
4972 "number of user specified inits is greater than the number of "
4973 "passed inits");
4975 }
4976
4977 size_t numTrailingObjects(OverloadToken<Expr *>) const { return NumExprs; }
4978
4979public:
4980 static CXXParenListInitExpr *
4981 Create(ASTContext &C, ArrayRef<Expr *> Args, QualType T,
4982 unsigned NumUserSpecifiedExprs, SourceLocation InitLoc,
4983 SourceLocation LParenLoc, SourceLocation RParenLoc);
4984
4985 static CXXParenListInitExpr *CreateEmpty(ASTContext &C, unsigned numExprs,
4986 EmptyShell Empty);
4987
4988 explicit CXXParenListInitExpr(EmptyShell Empty, unsigned NumExprs)
4989 : Expr(CXXParenListInitExprClass, Empty), NumExprs(NumExprs),
4990 NumUserSpecifiedExprs(0) {}
4991
4993
4995 return ArrayRef(getTrailingObjects<Expr *>(), NumExprs);
4996 }
4997
4999 return ArrayRef(getTrailingObjects<Expr *>(), NumExprs);
5000 }
5001
5003 return ArrayRef(getTrailingObjects<Expr *>(), NumUserSpecifiedExprs);
5004 }
5005
5007 return ArrayRef(getTrailingObjects<Expr *>(), NumUserSpecifiedExprs);
5008 }
5009
5010 SourceLocation getBeginLoc() const LLVM_READONLY { return LParenLoc; }
5011
5012 SourceLocation getEndLoc() const LLVM_READONLY { return RParenLoc; }
5013
5014 SourceLocation getInitLoc() const LLVM_READONLY { return InitLoc; }
5015
5016 SourceRange getSourceRange() const LLVM_READONLY {
5017 return SourceRange(getBeginLoc(), getEndLoc());
5018 }
5019
5020 void setArrayFiller(Expr *E) { ArrayFillerOrUnionFieldInit = E; }
5021
5023 return ArrayFillerOrUnionFieldInit.dyn_cast<Expr *>();
5024 }
5025
5026 const Expr *getArrayFiller() const {
5027 return ArrayFillerOrUnionFieldInit.dyn_cast<Expr *>();
5028 }
5029
5031 ArrayFillerOrUnionFieldInit = FD;
5032 }
5033
5035 return ArrayFillerOrUnionFieldInit.dyn_cast<FieldDecl *>();
5036 }
5037
5039 return ArrayFillerOrUnionFieldInit.dyn_cast<FieldDecl *>();
5040 }
5041
5043 Stmt **Begin = reinterpret_cast<Stmt **>(getTrailingObjects<Expr *>());
5044 return child_range(Begin, Begin + NumExprs);
5045 }
5046
5048 Stmt *const *Begin =
5049 reinterpret_cast<Stmt *const *>(getTrailingObjects<Expr *>());
5050 return const_child_range(Begin, Begin + NumExprs);
5051 }
5052
5053 static bool classof(const Stmt *T) {
5054 return T->getStmtClass() == CXXParenListInitExprClass;
5055 }
5056};
5057
5058/// Represents an expression that might suspend coroutine execution;
5059/// either a co_await or co_yield expression.
5060///
5061/// Evaluation of this expression first evaluates its 'ready' expression. If
5062/// that returns 'false':
5063/// -- execution of the coroutine is suspended
5064/// -- the 'suspend' expression is evaluated
5065/// -- if the 'suspend' expression returns 'false', the coroutine is
5066/// resumed
5067/// -- otherwise, control passes back to the resumer.
5068/// If the coroutine is not suspended, or when it is resumed, the 'resume'
5069/// expression is evaluated, and its result is the result of the overall
5070/// expression.
5072 friend class ASTStmtReader;
5073
5074 SourceLocation KeywordLoc;
5075
5076 enum SubExpr { Operand, Common, Ready, Suspend, Resume, Count };
5077
5078 Stmt *SubExprs[SubExpr::Count];
5079 OpaqueValueExpr *OpaqueValue = nullptr;
5080
5081public:
5082 // These types correspond to the three C++ 'await_suspend' return variants
5084
5086 Expr *Common, Expr *Ready, Expr *Suspend, Expr *Resume,
5087 OpaqueValueExpr *OpaqueValue)
5088 : Expr(SC, Resume->getType(), Resume->getValueKind(),
5089 Resume->getObjectKind()),
5090 KeywordLoc(KeywordLoc), OpaqueValue(OpaqueValue) {
5091 SubExprs[SubExpr::Operand] = Operand;
5092 SubExprs[SubExpr::Common] = Common;
5093 SubExprs[SubExpr::Ready] = Ready;
5094 SubExprs[SubExpr::Suspend] = Suspend;
5095 SubExprs[SubExpr::Resume] = Resume;
5097 }
5098
5100 Expr *Operand, Expr *Common)
5101 : Expr(SC, Ty, VK_PRValue, OK_Ordinary), KeywordLoc(KeywordLoc) {
5102 assert(Common->isTypeDependent() && Ty->isDependentType() &&
5103 "wrong constructor for non-dependent co_await/co_yield expression");
5104 SubExprs[SubExpr::Operand] = Operand;
5105 SubExprs[SubExpr::Common] = Common;
5106 SubExprs[SubExpr::Ready] = nullptr;
5107 SubExprs[SubExpr::Suspend] = nullptr;
5108 SubExprs[SubExpr::Resume] = nullptr;
5110 }
5111
5113 SubExprs[SubExpr::Operand] = nullptr;
5114 SubExprs[SubExpr::Common] = nullptr;
5115 SubExprs[SubExpr::Ready] = nullptr;
5116 SubExprs[SubExpr::Suspend] = nullptr;
5117 SubExprs[SubExpr::Resume] = nullptr;
5118 }
5119
5121 return static_cast<Expr*>(SubExprs[SubExpr::Common]);
5122 }
5123
5124 /// getOpaqueValue - Return the opaque value placeholder.
5125 OpaqueValueExpr *getOpaqueValue() const { return OpaqueValue; }
5126
5128 return static_cast<Expr*>(SubExprs[SubExpr::Ready]);
5129 }
5130
5132 return static_cast<Expr*>(SubExprs[SubExpr::Suspend]);
5133 }
5134
5136 return static_cast<Expr*>(SubExprs[SubExpr::Resume]);
5137 }
5138
5139 // The syntactic operand written in the code
5140 Expr *getOperand() const {
5141 return static_cast<Expr *>(SubExprs[SubExpr::Operand]);
5142 }
5143
5145 auto *SuspendExpr = getSuspendExpr();
5146 assert(SuspendExpr);
5147
5148 auto SuspendType = SuspendExpr->getType();
5149
5150 if (SuspendType->isVoidType())
5152 if (SuspendType->isBooleanType())
5154
5155 // Void pointer is the type of handle.address(), which is returned
5156 // from the await suspend wrapper so that the temporary coroutine handle
5157 // value won't go to the frame by mistake
5158 assert(SuspendType->isVoidPointerType());
5160 }
5161
5162 SourceLocation getKeywordLoc() const { return KeywordLoc; }
5163
5164 SourceLocation getBeginLoc() const LLVM_READONLY { return KeywordLoc; }
5165
5166 SourceLocation getEndLoc() const LLVM_READONLY {
5167 return getOperand()->getEndLoc();
5168 }
5169
5171 return child_range(SubExprs, SubExprs + SubExpr::Count);
5172 }
5173
5175 return const_child_range(SubExprs, SubExprs + SubExpr::Count);
5176 }
5177
5178 static bool classof(const Stmt *T) {
5179 return T->getStmtClass() == CoawaitExprClass ||
5180 T->getStmtClass() == CoyieldExprClass;
5181 }
5182};
5183
5184/// Represents a 'co_await' expression.
5186 friend class ASTStmtReader;
5187
5188public:
5189 CoawaitExpr(SourceLocation CoawaitLoc, Expr *Operand, Expr *Common,
5190 Expr *Ready, Expr *Suspend, Expr *Resume,
5191 OpaqueValueExpr *OpaqueValue, bool IsImplicit = false)
5192 : CoroutineSuspendExpr(CoawaitExprClass, CoawaitLoc, Operand, Common,
5193 Ready, Suspend, Resume, OpaqueValue) {
5194 CoawaitBits.IsImplicit = IsImplicit;
5195 }
5196
5197 CoawaitExpr(SourceLocation CoawaitLoc, QualType Ty, Expr *Operand,
5198 Expr *Common, bool IsImplicit = false)
5199 : CoroutineSuspendExpr(CoawaitExprClass, CoawaitLoc, Ty, Operand,
5200 Common) {
5201 CoawaitBits.IsImplicit = IsImplicit;
5202 }
5203
5205 : CoroutineSuspendExpr(CoawaitExprClass, Empty) {}
5206
5207 bool isImplicit() const { return CoawaitBits.IsImplicit; }
5208 void setIsImplicit(bool value = true) { CoawaitBits.IsImplicit = value; }
5209
5210 static bool classof(const Stmt *T) {
5211 return T->getStmtClass() == CoawaitExprClass;
5212 }
5213};
5214
5215/// Represents a 'co_await' expression while the type of the promise
5216/// is dependent.
5218 friend class ASTStmtReader;
5219
5220 SourceLocation KeywordLoc;
5221 Stmt *SubExprs[2];
5222
5223public:
5225 UnresolvedLookupExpr *OpCoawait)
5226 : Expr(DependentCoawaitExprClass, Ty, VK_PRValue, OK_Ordinary),
5227 KeywordLoc(KeywordLoc) {
5228 // NOTE: A co_await expression is dependent on the coroutines promise
5229 // type and may be dependent even when the `Op` expression is not.
5230 assert(Ty->isDependentType() &&
5231 "wrong constructor for non-dependent co_await/co_yield expression");
5232 SubExprs[0] = Op;
5233 SubExprs[1] = OpCoawait;
5235 }
5236
5238 : Expr(DependentCoawaitExprClass, Empty) {}
5239
5240 Expr *getOperand() const { return cast<Expr>(SubExprs[0]); }
5241
5243 return cast<UnresolvedLookupExpr>(SubExprs[1]);
5244 }
5245
5246 SourceLocation getKeywordLoc() const { return KeywordLoc; }
5247
5248 SourceLocation getBeginLoc() const LLVM_READONLY { return KeywordLoc; }
5249
5250 SourceLocation getEndLoc() const LLVM_READONLY {
5251 return getOperand()->getEndLoc();
5252 }
5253
5254 child_range children() { return child_range(SubExprs, SubExprs + 2); }
5255
5257 return const_child_range(SubExprs, SubExprs + 2);
5258 }
5259
5260 static bool classof(const Stmt *T) {
5261 return T->getStmtClass() == DependentCoawaitExprClass;
5262 }
5263};
5264
5265/// Represents a 'co_yield' expression.
5267 friend class ASTStmtReader;
5268
5269public:
5270 CoyieldExpr(SourceLocation CoyieldLoc, Expr *Operand, Expr *Common,
5271 Expr *Ready, Expr *Suspend, Expr *Resume,
5272 OpaqueValueExpr *OpaqueValue)
5273 : CoroutineSuspendExpr(CoyieldExprClass, CoyieldLoc, Operand, Common,
5274 Ready, Suspend, Resume, OpaqueValue) {}
5275 CoyieldExpr(SourceLocation CoyieldLoc, QualType Ty, Expr *Operand,
5276 Expr *Common)
5277 : CoroutineSuspendExpr(CoyieldExprClass, CoyieldLoc, Ty, Operand,
5278 Common) {}
5280 : CoroutineSuspendExpr(CoyieldExprClass, Empty) {}
5281
5282 static bool classof(const Stmt *T) {
5283 return T->getStmtClass() == CoyieldExprClass;
5284 }
5285};
5286
5287/// Represents a C++2a __builtin_bit_cast(T, v) expression. Used to implement
5288/// std::bit_cast. These can sometimes be evaluated as part of a constant
5289/// expression, but otherwise CodeGen to a simple memcpy in general.
5291 : public ExplicitCastExpr,
5292 private llvm::TrailingObjects<BuiltinBitCastExpr, CXXBaseSpecifier *> {
5293 friend class ASTStmtReader;
5294 friend class CastExpr;
5295 friend TrailingObjects;
5296
5297 SourceLocation KWLoc;
5298 SourceLocation RParenLoc;
5299
5300public:
5302 TypeSourceInfo *DstType, SourceLocation KWLoc,
5303 SourceLocation RParenLoc)
5304 : ExplicitCastExpr(BuiltinBitCastExprClass, T, VK, CK, SrcExpr, 0, false,
5305 DstType),
5306 KWLoc(KWLoc), RParenLoc(RParenLoc) {}
5308 : ExplicitCastExpr(BuiltinBitCastExprClass, Empty, 0, false) {}
5309
5310 SourceLocation getBeginLoc() const LLVM_READONLY { return KWLoc; }
5311 SourceLocation getEndLoc() const LLVM_READONLY { return RParenLoc; }
5312
5313 static bool classof(const Stmt *T) {
5314 return T->getStmtClass() == BuiltinBitCastExprClass;
5315 }
5316};
5317
5318} // namespace clang
5319
5320#endif // LLVM_CLANG_AST_EXPRCXX_H
This file provides AST data structures related to concepts.
#define V(N, I)
Definition: ASTContext.h:3341
const Decl * D
enum clang::sema::@1655::IndirectLocalPathEntry::EntryKind Kind
IndirectLocalPath & Path
Expr * E
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate....
Defines the C++ template declaration subclasses.
Defines the ExceptionSpecificationType enumeration and various utility functions.
Defines enumerations for expression traits intrinsics.
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified.
Defines several types used to describe C++ lambda expressions that are shared between the parser and ...
Defines the clang::LangOptions interface.
Defines an enumeration for C++ overloaded operators.
SourceRange Range
Definition: SemaObjC.cpp:758
SourceLocation Loc
Definition: SemaObjC.cpp:759
Defines the clang::SourceLocation class and associated facilities.
Defines various enumerations that describe declaration and type specifiers.
static QualType getPointeeType(const MemRegion *R)
Defines enumerations for the type traits support.
C Language Family Type Representation.
SourceLocation Begin
__device__ __2f16 float __ockl_bool s
APValue - This class implements a discriminated union of [uninitialized] [APSInt] [APFloat],...
Definition: APValue.h:122
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition: ASTContext.h:187
Reads an AST files chain containing the contents of a translation unit.
Definition: ASTReader.h:378
An Embarcadero array type trait, as used in the implementation of __array_rank and __array_extent.
Definition: ExprCXX.h:2853
ArrayTypeTraitExpr(SourceLocation loc, ArrayTypeTrait att, TypeSourceInfo *queried, uint64_t value, Expr *dimension, SourceLocation rparen, QualType ty)
Definition: ExprCXX.h:2876
uint64_t getValue() const
Definition: ExprCXX.h:2899
SourceLocation getEndLoc() const LLVM_READONLY
Definition: ExprCXX.h:2891
ArrayTypeTrait getTrait() const
Definition: ExprCXX.h:2893
QualType getQueriedType() const
Definition: ExprCXX.h:2895
Expr * getDimensionExpression() const
Definition: ExprCXX.h:2901
ArrayTypeTraitExpr(EmptyShell Empty)
Definition: ExprCXX.h:2887
child_range children()
Definition: ExprCXX.h:2908
const_child_range children() const
Definition: ExprCXX.h:2912
static bool classof(const Stmt *T)
Definition: ExprCXX.h:2903
TypeSourceInfo * getQueriedTypeSourceInfo() const
Definition: ExprCXX.h:2897
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprCXX.h:2890
StringRef getOpcodeStr() const
Definition: Expr.h:3926
Represents a C++2a __builtin_bit_cast(T, v) expression.
Definition: ExprCXX.h:5292
static bool classof(const Stmt *T)
Definition: ExprCXX.h:5313
SourceLocation getEndLoc() const LLVM_READONLY
Definition: ExprCXX.h:5311
BuiltinBitCastExpr(EmptyShell Empty)
Definition: ExprCXX.h:5307
BuiltinBitCastExpr(QualType T, ExprValueKind VK, CastKind CK, Expr *SrcExpr, TypeSourceInfo *DstType, SourceLocation KWLoc, SourceLocation RParenLoc)
Definition: ExprCXX.h:5301
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprCXX.h:5310
Represents a call to a CUDA kernel function.
Definition: ExprCXX.h:231
const CallExpr * getConfig() const
Definition: ExprCXX.h:257
static CUDAKernelCallExpr * CreateEmpty(const ASTContext &Ctx, unsigned NumArgs, bool HasFPFeatures, EmptyShell Empty)
Definition: ExprCXX.cpp:1921
static bool classof(const Stmt *T)
Definition: ExprCXX.h:262
CallExpr * getConfig()
Definition: ExprCXX.h:260
A C++ addrspace_cast expression (currently only enabled for OpenCL).
Definition: ExprCXX.h:601
static bool classof(const Stmt *T)
Definition: ExprCXX.h:623
static CXXAddrspaceCastExpr * CreateEmpty(const ASTContext &Context)
Definition: ExprCXX.cpp:898
Represents binding an expression to a temporary.
Definition: ExprCXX.h:1491
CXXBindTemporaryExpr(EmptyShell Empty)
Definition: ExprCXX.h:1503
static bool classof(const Stmt *T)
Definition: ExprCXX.h:1526
void setTemporary(CXXTemporary *T)
Definition: ExprCXX.h:1511
void setSubExpr(Expr *E)
Definition: ExprCXX.h:1515
const_child_range children() const
Definition: ExprCXX.h:1533
CXXTemporary * getTemporary()
Definition: ExprCXX.h:1509
const CXXTemporary * getTemporary() const
Definition: ExprCXX.h:1510
const Expr * getSubExpr() const
Definition: ExprCXX.h:1513
child_range children()
Definition: ExprCXX.h:1531
SourceLocation getEndLoc() const LLVM_READONLY
Definition: ExprCXX.h:1521
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprCXX.h:1517
A boolean literal, per ([C++ lex.bool] Boolean literals).
Definition: ExprCXX.h:720
const_child_range children() const
Definition: ExprCXX.h:755
CXXBoolLiteralExpr(bool Val, QualType Ty, SourceLocation Loc)
Definition: ExprCXX.h:722
SourceLocation getEndLoc() const
Definition: ExprCXX.h:741
static bool classof(const Stmt *T)
Definition: ExprCXX.h:746
static CXXBoolLiteralExpr * Create(const ASTContext &C, bool Val, QualType Ty, SourceLocation Loc)
Definition: ExprCXX.h:732
bool getValue() const
Definition: ExprCXX.h:737
CXXBoolLiteralExpr(EmptyShell Empty)
Definition: ExprCXX.h:729
SourceLocation getBeginLoc() const
Definition: ExprCXX.h:740
void setValue(bool V)
Definition: ExprCXX.h:738
SourceLocation getLocation() const
Definition: ExprCXX.h:743
void setLocation(SourceLocation L)
Definition: ExprCXX.h:744
child_range children()
Definition: ExprCXX.h:751
A C++ const_cast expression (C++ [expr.const.cast]).
Definition: ExprCXX.h:563
static bool classof(const Stmt *T)
Definition: ExprCXX.h:586
static CXXConstCastExpr * CreateEmpty(const ASTContext &Context)
Definition: ExprCXX.cpp:885
Represents a call to a C++ constructor.
Definition: ExprCXX.h:1546
arg_iterator arg_begin()
Definition: ExprCXX.h:1675
SourceRange getParenOrBraceRange() const
Definition: ExprCXX.h:1714
void setElidable(bool E)
Definition: ExprCXX.h:1616
const_arg_iterator arg_end() const
Definition: ExprCXX.h:1678
void setStdInitListInitialization(bool V)
Definition: ExprCXX.h:1642
void setConstructionKind(CXXConstructionKind CK)
Definition: ExprCXX.h:1661
void setIsImmediateEscalating(bool Set)
Definition: ExprCXX.h:1708
llvm::iterator_range< arg_iterator > arg_range
Definition: ExprCXX.h:1667
bool isElidable() const
Whether this construction is elidable.
Definition: ExprCXX.h:1615
bool hadMultipleCandidates() const
Whether the referred constructor was resolved from an overloaded set having size greater than 1.
Definition: ExprCXX.h:1620
child_range children()
Definition: ExprCXX.h:1723
Expr * getArg(unsigned Arg)
Return the specified argument.
Definition: ExprCXX.h:1689
arg_range arguments()
Definition: ExprCXX.h:1670
bool isStdInitListInitialization() const
Whether this constructor call was written as list-initialization, but was interpreted as forming a st...
Definition: ExprCXX.h:1639
void setListInitialization(bool V)
Definition: ExprCXX.h:1631
bool isImmediateEscalating() const
Definition: ExprCXX.h:1704
bool requiresZeroInitialization() const
Whether this construction first requires zero-initialization before the initializer is called.
Definition: ExprCXX.h:1648
void setRequiresZeroInitialization(bool ZeroInit)
Definition: ExprCXX.h:1651
SourceLocation getLocation() const
Definition: ExprCXX.h:1611
const_arg_range arguments() const
Definition: ExprCXX.h:1671
arg_iterator arg_end()
Definition: ExprCXX.h:1676
static unsigned sizeOfTrailingObjects(unsigned NumArgs)
Return the size in bytes of the trailing objects.
Definition: ExprCXX.h:1592
void setArg(unsigned Arg, Expr *ArgExpr)
Set the specified argument.
Definition: ExprCXX.h:1699
SourceLocation getEndLoc() const LLVM_READONLY
Definition: ExprCXX.cpp:569
llvm::iterator_range< const_arg_iterator > const_arg_range
Definition: ExprCXX.h:1668
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprCXX.cpp:563
void setParenOrBraceRange(SourceRange Range)
Definition: ExprCXX.h:1715
const_arg_iterator arg_begin() const
Definition: ExprCXX.h:1677
const_child_range children() const
Definition: ExprCXX.h:1727
CXXConstructorDecl * getConstructor() const
Get the constructor that this expression will (ultimately) call.
Definition: ExprCXX.h:1609
bool isListInitialization() const
Whether this constructor call was written as list-initialization.
Definition: ExprCXX.h:1628
unsigned getNumArgs() const
Return the number of arguments to the constructor call.
Definition: ExprCXX.h:1686
CXXConstructionKind getConstructionKind() const
Determine whether this constructor is actually constructing a base class (rather than a complete obje...
Definition: ExprCXX.h:1657
void setHadMultipleCandidates(bool V)
Definition: ExprCXX.h:1623
void setLocation(SourceLocation Loc)
Definition: ExprCXX.h:1612
const Expr * getArg(unsigned Arg) const
Definition: ExprCXX.h:1693
const Expr *const * getArgs() const
Definition: ExprCXX.h:1681
static bool classof(const Stmt *T)
Definition: ExprCXX.h:1717
static CXXConstructExpr * CreateEmpty(const ASTContext &Ctx, unsigned NumArgs)
Create an empty C++ construction expression.
Definition: ExprCXX.cpp:1175
Represents a C++ constructor within a class.
Definition: DeclCXX.h:2539
A default argument (C++ [dcl.fct.default]).
Definition: ExprCXX.h:1268
SourceLocation getEndLoc() const
Definition: ExprCXX.h:1347
const_child_range children() const
Definition: ExprCXX.h:1360
SourceLocation getBeginLoc() const
Default argument expressions have no representation in the source, so they have an empty source range...
Definition: ExprCXX.h:1346
SourceLocation getUsedLocation() const
Retrieve the location where this default argument was actually used.
Definition: ExprCXX.h:1342
ParmVarDecl * getParam()
Definition: ExprCXX.h:1311
const ParmVarDecl * getParam() const
Definition: ExprCXX.h:1310
const Expr * getExpr() const
Definition: ExprCXX.h:1319
Expr * getAdjustedRewrittenExpr()
Definition: ExprCXX.cpp:1035
const Expr * getAdjustedRewrittenExpr() const
Definition: ExprCXX.h:1334
DeclContext * getUsedContext()
Definition: ExprCXX.h:1339
SourceLocation getExprLoc() const
Definition: ExprCXX.h:1349
const DeclContext * getUsedContext() const
Definition: ExprCXX.h:1338
const Expr * getRewrittenExpr() const
Definition: ExprCXX.h:1327
static bool classof(const Stmt *T)
Definition: ExprCXX.h:1351
static CXXDefaultArgExpr * CreateEmpty(const ASTContext &C, bool HasRewrittenInit)
Definition: ExprCXX.cpp:1012
child_range children()
Definition: ExprCXX.h:1356
bool hasRewrittenInit() const
Definition: ExprCXX.h:1313
A use of a default initializer in a constructor or in aggregate initialization.
Definition: ExprCXX.h:1375
static bool classof(const Stmt *T)
Definition: ExprCXX.h:1442
const DeclContext * getUsedContext() const
Definition: ExprCXX.h:1432
child_range children()
Definition: ExprCXX.h:1447
const FieldDecl * getField() const
Definition: ExprCXX.h:1410
const Expr * getRewrittenExpr() const
Retrieve the initializing expression with evaluated immediate calls, if any.
Definition: ExprCXX.h:1420
const Expr * getExpr() const
Definition: ExprCXX.h:1414
bool hasRewrittenInit() const
Definition: ExprCXX.h:1404
Expr * getExpr()
Get the initialization expression that will be used.
Definition: ExprCXX.cpp:1085
FieldDecl * getField()
Get the field whose initializer will be used.
Definition: ExprCXX.h:1409
static CXXDefaultInitExpr * CreateEmpty(const ASTContext &C, bool HasRewrittenInit)
Definition: ExprCXX.cpp:1066
Expr * getRewrittenExpr()
Retrieve the initializing expression with evaluated immediate calls, if any.
Definition: ExprCXX.h:1427
SourceLocation getBeginLoc() const
Definition: ExprCXX.h:1439
SourceLocation getEndLoc() const
Definition: ExprCXX.h:1440
const_child_range children() const
Definition: ExprCXX.h:1451
DeclContext * getUsedContext()
Definition: ExprCXX.h:1433
SourceLocation getUsedLocation() const
Retrieve the location where this default initializer expression was actually used.
Definition: ExprCXX.h:1437
Represents a delete expression for memory deallocation and destructor calls, e.g.
Definition: ExprCXX.h:2498
static bool classof(const Stmt *T)
Definition: ExprCXX.h:2553
child_range children()
Definition: ExprCXX.h:2558
FunctionDecl * getOperatorDelete() const
Definition: ExprCXX.h:2537
SourceLocation getEndLoc() const LLVM_READONLY
Definition: ExprCXX.h:2549
bool isArrayForm() const
Definition: ExprCXX.h:2524
CXXDeleteExpr(EmptyShell Shell)
Definition: ExprCXX.h:2521
const_child_range children() const
Definition: ExprCXX.h:2560
SourceLocation getBeginLoc() const
Definition: ExprCXX.h:2548
const Expr * getArgument() const
Definition: ExprCXX.h:2540
bool isGlobalDelete() const
Definition: ExprCXX.h:2523
Expr * getArgument()
Definition: ExprCXX.h:2539
bool doesUsualArrayDeleteWantSize() const
Answers whether the usual array deallocation function for the allocated type expects the size of the ...
Definition: ExprCXX.h:2533
QualType getDestroyedType() const
Retrieve the type being destroyed.
Definition: ExprCXX.cpp:338
bool isArrayFormAsWritten() const
Definition: ExprCXX.h:2525
CXXDeleteExpr(QualType Ty, bool GlobalDelete, bool ArrayForm, bool ArrayFormAsWritten, bool UsualArrayDeleteWantsSize, FunctionDecl *OperatorDelete, Expr *Arg, SourceLocation Loc)
Definition: ExprCXX.h:2508
Represents a C++ member access expression where the actual member referenced could not be resolved be...
Definition: ExprCXX.h:3683
bool isArrow() const
Determine whether this member expression used the '->' operator; otherwise, it used the '.
Definition: ExprCXX.h:3786
SourceLocation getOperatorLoc() const
Retrieve the location of the '->' or '.' operator.
Definition: ExprCXX.h:3789
SourceLocation getLAngleLoc() const
Retrieve the location of the left angle bracket starting the explicit template argument list followin...
Definition: ExprCXX.h:3841
SourceLocation getTemplateKeywordLoc() const
Retrieve the location of the template keyword preceding the member name, if any.
Definition: ExprCXX.h:3833
const DeclarationNameInfo & getMemberNameInfo() const
Retrieve the name of the member that this expression refers to.
Definition: ExprCXX.h:3820
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprCXX.h:3892
NestedNameSpecifier * getQualifier() const
Retrieve the nested-name-specifier that qualifies the member name.
Definition: ExprCXX.h:3794
void copyTemplateArgumentsInto(TemplateArgumentListInfo &List) const
Copies the template arguments (if present) into the given structure.
Definition: ExprCXX.h:3864
unsigned getNumTemplateArgs() const
Retrieve the number of template arguments provided as part of this template-id.
Definition: ExprCXX.h:3881
const TemplateArgumentLoc * getTemplateArgs() const
Retrieve the template arguments provided as part of this template-id.
Definition: ExprCXX.h:3872
bool hasExplicitTemplateArgs() const
Determines whether this member expression actually had a C++ template argument list explicitly specif...
Definition: ExprCXX.h:3860
static CXXDependentScopeMemberExpr * CreateEmpty(const ASTContext &Ctx, bool HasTemplateKWAndArgsInfo, unsigned NumTemplateArgs, bool HasFirstQualifierFoundInScope)
Definition: ExprCXX.cpp:1555
SourceLocation getMemberLoc() const
Definition: ExprCXX.h:3829
static bool classof(const Stmt *T)
Definition: ExprCXX.h:3906
SourceLocation getRAngleLoc() const
Retrieve the location of the right angle bracket ending the explicit template argument list following...
Definition: ExprCXX.h:3849
DeclarationName getMember() const
Retrieve the name of the member that this expression refers to.
Definition: ExprCXX.h:3825
SourceLocation getEndLoc() const LLVM_READONLY
Definition: ExprCXX.h:3900
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:3813
Expr * getBase() const
Retrieve the base object of this member expressions, e.g., the x in x.m.
Definition: ExprCXX.h:3777
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier that qualifies the member name, with source location information.
Definition: ExprCXX.h:3800
const_child_range children() const
Definition: ExprCXX.h:3917
bool hasTemplateKeyword() const
Determines whether the member name was preceded by the template keyword.
Definition: ExprCXX.h:3856
bool isImplicitAccess() const
True if this is an implicit access, i.e.
Definition: ExprCXX.h:3769
ArrayRef< TemplateArgumentLoc > template_arguments() const
Definition: ExprCXX.h:3888
Represents a C++ destructor within a class.
Definition: DeclCXX.h:2803
A C++ dynamic_cast expression (C++ [expr.dynamic.cast]).
Definition: ExprCXX.h:478
static bool classof(const Stmt *T)
Definition: ExprCXX.h:507
static CXXDynamicCastExpr * CreateEmpty(const ASTContext &Context, unsigned pathSize)
Definition: ExprCXX.cpp:807
bool isAlwaysNull() const
isAlwaysNull - Return whether the result of the dynamic_cast is proven to always be null.
Definition: ExprCXX.cpp:821
Represents a folding of a pack over an operator.
Definition: ExprCXX.h:4840
static bool classof(const Stmt *T)
Definition: ExprCXX.h:4910
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprCXX.h:4894
UnresolvedLookupExpr * getCallee() const
Definition: ExprCXX.h:4863
Expr * getInit() const
Get the operand that doesn't contain a pack, for a binary fold.
Definition: ExprCXX.h:4881
CXXFoldExpr(EmptyShell Empty)
Definition: ExprCXX.h:4861
std::optional< unsigned > getNumExpansions() const
Definition: ExprCXX.h:4888
SourceLocation getEndLoc() const LLVM_READONLY
Definition: ExprCXX.h:4902
Expr * getRHS() const
Definition: ExprCXX.h:4867
const_child_range children() const
Definition: ExprCXX.h:4919
SourceLocation getLParenLoc() const
Definition: ExprCXX.h:4883
SourceLocation getEllipsisLoc() const
Definition: ExprCXX.h:4885
bool isLeftFold() const
Does this produce a left-associated sequence of operators?
Definition: ExprCXX.h:4875
child_range children()
Definition: ExprCXX.h:4915
bool isRightFold() const
Does this produce a right-associated sequence of operators?
Definition: ExprCXX.h:4870
Expr * getPattern() const
Get the pattern, that is, the operand that contains an unexpanded pack.
Definition: ExprCXX.h:4878
Expr * getLHS() const
Definition: ExprCXX.h:4866
SourceLocation getRParenLoc() const
Definition: ExprCXX.h:4884
BinaryOperatorKind getOperator() const
Definition: ExprCXX.h:4886
Represents an explicit C++ type conversion that uses "functional" notation (C++ [expr....
Definition: ExprCXX.h:1817
void setLParenLoc(SourceLocation L)
Definition: ExprCXX.h:1855
SourceLocation getLParenLoc() const
Definition: ExprCXX.h:1854
static CXXFunctionalCastExpr * CreateEmpty(const ASTContext &Context, unsigned PathSize, bool HasFPFeatures)
Definition: ExprCXX.cpp:918
SourceLocation getRParenLoc() const
Definition: ExprCXX.h:1856
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprCXX.cpp:928
void setRParenLoc(SourceLocation L)
Definition: ExprCXX.h:1857
static bool classof(const Stmt *T)
Definition: ExprCXX.h:1865
bool isListInitialization() const
Determine whether this expression models list-initialization.
Definition: ExprCXX.h:1860
SourceLocation getEndLoc() const LLVM_READONLY
Definition: ExprCXX.cpp:932
Represents a call to an inherited base class constructor from an inheriting constructor.
Definition: ExprCXX.h:1737
CXXInheritedCtorInitExpr(EmptyShell Empty)
Construct an empty C++ inheriting construction expression.
Definition: ExprCXX.h:1769
const_child_range children() const
Definition: ExprCXX.h:1802
CXXConstructionKind getConstructionKind() const
Definition: ExprCXX.h:1779
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprCXX.h:1791
static bool classof(const Stmt *T)
Definition: ExprCXX.h:1794
bool constructsVBase() const
Determine whether this constructor is actually constructing a base class (rather than a complete obje...
Definition: ExprCXX.h:1778
CXXConstructorDecl * getConstructor() const
Get the constructor that this expression will call.
Definition: ExprCXX.h:1774
CXXInheritedCtorInitExpr(SourceLocation Loc, QualType T, CXXConstructorDecl *Ctor, bool ConstructsVirtualBase, bool InheritedFromVirtualBase)
Construct a C++ inheriting construction expression.
Definition: ExprCXX.h:1757
SourceLocation getLocation() const LLVM_READONLY
Definition: ExprCXX.h:1790
SourceLocation getEndLoc() const LLVM_READONLY
Definition: ExprCXX.h:1792
bool inheritedFromVBase() const
Determine whether the inherited constructor is inherited from a virtual base of the object we constru...
Definition: ExprCXX.h:1788
Represents a call to a member function that may be written either with member call syntax (e....
Definition: ExprCXX.h:176
CXXMethodDecl * getMethodDecl() const
Retrieve the declaration of the called method.
Definition: ExprCXX.cpp:723
Expr * getImplicitObjectArgument() const
Retrieve the implicit object argument for the member call.
Definition: ExprCXX.cpp:704
static CXXMemberCallExpr * CreateEmpty(const ASTContext &Ctx, unsigned NumArgs, bool HasFPFeatures, EmptyShell Empty)
Definition: ExprCXX.cpp:692
QualType getObjectType() const
Retrieve the type of the object argument.
Definition: ExprCXX.cpp:716
SourceLocation getExprLoc() const LLVM_READONLY
Definition: ExprCXX.h:217
static bool classof(const Stmt *T)
Definition: ExprCXX.h:225
CXXRecordDecl * getRecordDecl() const
Retrieve the CXXRecordDecl for the underlying type of the implicit object argument.
Definition: ExprCXX.cpp:732
Represents a static or instance method of a struct/union/class.
Definition: DeclCXX.h:2064
Abstract class common to all of the C++ "named"/"keyword" casts.
Definition: ExprCXX.h:372
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprCXX.h:408
SourceLocation getOperatorLoc() const
Retrieve the location of the cast operator keyword, e.g., static_cast.
Definition: ExprCXX.h:403
const char * getCastName() const
getCastName - Get the name of the C++ cast being used, e.g., "static_cast", "dynamic_cast",...
Definition: ExprCXX.cpp:750
CXXNamedCastExpr(StmtClass SC, QualType ty, ExprValueKind VK, CastKind kind, Expr *op, unsigned PathSize, bool HasFPFeatures, TypeSourceInfo *writtenTy, SourceLocation l, SourceLocation RParenLoc, SourceRange AngleBrackets)
Definition: ExprCXX.h:386
static bool classof(const Stmt *T)
Definition: ExprCXX.h:412
CXXNamedCastExpr(StmtClass SC, EmptyShell Shell, unsigned PathSize, bool HasFPFeatures)
Definition: ExprCXX.h:394
SourceRange getAngleBrackets() const LLVM_READONLY
Definition: ExprCXX.h:410
SourceLocation getEndLoc() const LLVM_READONLY
Definition: ExprCXX.h:409
SourceLocation getRParenLoc() const
Retrieve the location of the closing parenthesis.
Definition: ExprCXX.h:406
Represents a new-expression for memory allocation and constructor calls, e.g: "new CXXNewExpr(foo)".
Definition: ExprCXX.h:2241
static CXXNewExpr * CreateEmpty(const ASTContext &Ctx, bool IsArray, bool HasInit, unsigned NumPlacementArgs, bool IsParenTypeId)
Create an empty c++ new expression.
Definition: ExprCXX.cpp:315
bool isArray() const
Definition: ExprCXX.h:2349
SourceRange getDirectInitRange() const
Definition: ExprCXX.h:2481
llvm::iterator_range< arg_iterator > placement_arguments()
Definition: ExprCXX.h:2444
QualType getAllocatedType() const
Definition: ExprCXX.h:2319
arg_iterator placement_arg_end()
Definition: ExprCXX.h:2455
std::optional< const Expr * > getArraySize() const
This might return std::nullopt even if isArray() returns true, since there might not be an array size...
Definition: ExprCXX.h:2368
const_arg_iterator placement_arg_begin() const
Definition: ExprCXX.h:2458
std::optional< Expr * > getArraySize()
This might return std::nullopt even if isArray() returns true, since there might not be an array size...
Definition: ExprCXX.h:2354
SourceLocation getEndLoc() const
Definition: ExprCXX.h:2479
CXXNewInitializationStyle getInitializationStyle() const
The kind of initializer this new-expression has.
Definition: ExprCXX.h:2408
Expr * getPlacementArg(unsigned I)
Definition: ExprCXX.h:2388
bool hasInitializer() const
Whether this new-expression has any initializer at all.
Definition: ExprCXX.h:2405
const Expr * getInitializer() const
Definition: ExprCXX.h:2419
bool shouldNullCheckAllocation() const
True if the allocation result needs to be null-checked.
Definition: ExprCXX.cpp:326
const Expr * getPlacementArg(unsigned I) const
Definition: ExprCXX.h:2392
static bool classof(const Stmt *T)
Definition: ExprCXX.h:2484
SourceLocation getBeginLoc() const
Definition: ExprCXX.h:2478
void setOperatorDelete(FunctionDecl *D)
Definition: ExprCXX.h:2347
bool passAlignment() const
Indicates whether the required alignment should be implicitly passed to the allocation function.
Definition: ExprCXX.h:2432
FunctionDecl * getOperatorDelete() const
Definition: ExprCXX.h:2346
unsigned getNumPlacementArgs() const
Definition: ExprCXX.h:2379
const CXXConstructExpr * getConstructExpr() const
Returns the CXXConstructExpr from this new-expression, or null.
Definition: ExprCXX.h:2426
llvm::iterator_range< const_arg_iterator > placement_arguments() const
Definition: ExprCXX.h:2448
const_arg_iterator placement_arg_end() const
Definition: ExprCXX.h:2461
TypeSourceInfo * getAllocatedTypeSourceInfo() const
Definition: ExprCXX.h:2323
SourceRange getSourceRange() const
Definition: ExprCXX.h:2482
SourceRange getTypeIdParens() const
Definition: ExprCXX.h:2397
Expr ** getPlacementArgs()
Definition: ExprCXX.h:2383
bool isParenTypeId() const
Definition: ExprCXX.h:2396
raw_arg_iterator raw_arg_end()
Definition: ExprCXX.h:2468
child_range children()
Definition: ExprCXX.h:2489
bool doesUsualArrayDeleteWantSize() const
Answers whether the usual array deallocation function for the allocated type expects the size of the ...
Definition: ExprCXX.h:2437
const_arg_iterator raw_arg_end() const
Definition: ExprCXX.h:2474
const_child_range children() const
Definition: ExprCXX.h:2491
arg_iterator placement_arg_begin()
Definition: ExprCXX.h:2452
raw_arg_iterator raw_arg_begin()
Definition: ExprCXX.h:2467
void setOperatorNew(FunctionDecl *D)
Definition: ExprCXX.h:2345
FunctionDecl * getOperatorNew() const
Definition: ExprCXX.h:2344
const_arg_iterator raw_arg_begin() const
Definition: ExprCXX.h:2471
bool isGlobalNew() const
Definition: ExprCXX.h:2402
Expr * getInitializer()
The initializer of this new-expression.
Definition: ExprCXX.h:2414
Represents a C++11 noexcept expression (C++ [expr.unary.noexcept]).
Definition: ExprCXX.h:4126
bool getValue() const
Definition: ExprCXX.h:4149
static bool classof(const Stmt *T)
Definition: ExprCXX.h:4151
const_child_range children() const
Definition: ExprCXX.h:4158
SourceLocation getEndLoc() const
Definition: ExprCXX.h:4146
Expr * getOperand() const
Definition: ExprCXX.h:4143
SourceLocation getBeginLoc() const
Definition: ExprCXX.h:4145
SourceRange getSourceRange() const
Definition: ExprCXX.h:4147
CXXNoexceptExpr(EmptyShell Empty)
Definition: ExprCXX.h:4141
CXXNoexceptExpr(QualType Ty, Expr *Operand, CanThrowResult Val, SourceLocation Keyword, SourceLocation RParen)
Definition: ExprCXX.h:4133
child_range children()
Definition: ExprCXX.h:4156
The null pointer literal (C++11 [lex.nullptr])
Definition: ExprCXX.h:765
const_child_range children() const
Definition: ExprCXX.h:790
CXXNullPtrLiteralExpr(EmptyShell Empty)
Definition: ExprCXX.h:773
void setLocation(SourceLocation L)
Definition: ExprCXX.h:780
SourceLocation getEndLoc() const
Definition: ExprCXX.h:777
static bool classof(const Stmt *T)
Definition: ExprCXX.h:782
CXXNullPtrLiteralExpr(QualType Ty, SourceLocation Loc)
Definition: ExprCXX.h:767
SourceLocation getLocation() const
Definition: ExprCXX.h:779
child_range children()
Definition: ExprCXX.h:786
SourceLocation getBeginLoc() const
Definition: ExprCXX.h:776
A call to an overloaded operator written using operator syntax.
Definition: ExprCXX.h:81
bool isInfixBinaryOp() const
Is this written as an infix binary operator?
Definition: ExprCXX.cpp:49
bool isAssignmentOp() const
Definition: ExprCXX.h:123
static bool classof(const Stmt *T)
Definition: ExprCXX.h:163
SourceLocation getOperatorLoc() const
Returns the location of the operator symbol in the expression.
Definition: ExprCXX.h:149
SourceLocation getEndLoc() const
Definition: ExprCXX.h:160
SourceLocation getExprLoc() const LLVM_READONLY
Definition: ExprCXX.h:151
OverloadedOperatorKind getOperator() const
Returns the kind of overloaded operator that this expression refers to.
Definition: ExprCXX.h:111
static CXXOperatorCallExpr * CreateEmpty(const ASTContext &Ctx, unsigned NumArgs, bool HasFPFeatures, EmptyShell Empty)
Definition: ExprCXX.cpp:627
SourceLocation getBeginLoc() const
Definition: ExprCXX.h:159
static bool isComparisonOp(OverloadedOperatorKind Opc)
Definition: ExprCXX.h:125
static bool isAssignmentOp(OverloadedOperatorKind Opc)
Definition: ExprCXX.h:116
bool isComparisonOp() const
Definition: ExprCXX.h:139
SourceRange getSourceRange() const
Definition: ExprCXX.h:161
Represents a list-initialization with parenthesis.
Definition: ExprCXX.h:4954
SourceRange getSourceRange() const LLVM_READONLY
Definition: ExprCXX.h:5016
const_child_range children() const
Definition: ExprCXX.h:5047
void setInitializedFieldInUnion(FieldDecl *FD)
Definition: ExprCXX.h:5030
SourceLocation getEndLoc() const LLVM_READONLY
Definition: ExprCXX.h:5012
const ArrayRef< Expr * > getUserSpecifiedInitExprs() const
Definition: ExprCXX.h:5006
SourceLocation getInitLoc() const LLVM_READONLY
Definition: ExprCXX.h:5014
ArrayRef< Expr * > getUserSpecifiedInitExprs()
Definition: ExprCXX.h:5002
ArrayRef< Expr * > getInitExprs()
Definition: ExprCXX.h:4994
CXXParenListInitExpr(EmptyShell Empty, unsigned NumExprs)
Definition: ExprCXX.h:4988
friend class TrailingObjects
Definition: ExprCXX.h:4955
static CXXParenListInitExpr * CreateEmpty(ASTContext &C, unsigned numExprs, EmptyShell Empty)
Definition: ExprCXX.cpp:1943
const FieldDecl * getInitializedFieldInUnion() const
Definition: ExprCXX.h:5038
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprCXX.h:5010
static bool classof(const Stmt *T)
Definition: ExprCXX.h:5053
const ArrayRef< Expr * > getInitExprs() const
Definition: ExprCXX.h:4998
FieldDecl * getInitializedFieldInUnion()
Definition: ExprCXX.h:5034
const Expr * getArrayFiller() const
Definition: ExprCXX.h:5026
child_range children()
Definition: ExprCXX.h:5042
void setArrayFiller(Expr *E)
Definition: ExprCXX.h:5020
Represents a C++ pseudo-destructor (C++ [expr.pseudo]).
Definition: ExprCXX.h:2617
TypeSourceInfo * getDestroyedTypeInfo() const
Retrieve the source location information for the type being destroyed.
Definition: ExprCXX.h:2711
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprCXX.h:2741
bool isArrow() const
Determine whether this pseudo-destructor expression was written using an '->' (otherwise,...
Definition: ExprCXX.h:2681
TypeSourceInfo * getScopeTypeInfo() const
Retrieve the scope type in a qualified pseudo-destructor expression.
Definition: ExprCXX.h:2695
static bool classof(const Stmt *T)
Definition: ExprCXX.h:2746
SourceLocation getTildeLoc() const
Retrieve the location of the '~'.
Definition: ExprCXX.h:2702
NestedNameSpecifierLoc getQualifierLoc() const
Retrieves the nested-name-specifier that qualifies the type name, with source-location information.
Definition: ExprCXX.h:2670
SourceLocation getEndLoc() const LLVM_READONLY
Definition: ExprCXX.cpp:392
SourceLocation getDestroyedTypeLoc() const
Retrieve the starting location of the type being destroyed.
Definition: ExprCXX.h:2726
SourceLocation getColonColonLoc() const
Retrieve the location of the '::' in a qualified pseudo-destructor expression.
Definition: ExprCXX.h:2699
const_child_range children() const
Definition: ExprCXX.h:2753
QualType getDestroyedType() const
Retrieve the type being destroyed.
Definition: ExprCXX.cpp:385
SourceLocation getOperatorLoc() const
Retrieve the location of the '.' or '->' operator.
Definition: ExprCXX.h:2684
NestedNameSpecifier * getQualifier() const
If the member name was qualified, retrieves the nested-name-specifier that precedes the member name.
Definition: ExprCXX.h:2675
void setDestroyedType(IdentifierInfo *II, SourceLocation Loc)
Set the name of destroyed type for a dependent pseudo-destructor expression.
Definition: ExprCXX.h:2732
const IdentifierInfo * getDestroyedTypeIdentifier() const
In a dependent pseudo-destructor expression for which we do not have full type information on the des...
Definition: ExprCXX.h:2718
void setDestroyedType(TypeSourceInfo *Info)
Set the destroyed type.
Definition: ExprCXX.h:2737
bool hasQualifier() const
Determines whether this member expression actually had a C++ nested-name-specifier prior to the name ...
Definition: ExprCXX.h:2666
CXXPseudoDestructorExpr(EmptyShell Shell)
Definition: ExprCXX.h:2658
Represents a C++ struct/union/class.
Definition: DeclCXX.h:258
A C++ reinterpret_cast expression (C++ [expr.reinterpret.cast]).
Definition: ExprCXX.h:523
static bool classof(const Stmt *T)
Definition: ExprCXX.h:549
static CXXReinterpretCastExpr * CreateEmpty(const ASTContext &Context, unsigned pathSize)
Definition: ExprCXX.cpp:871
A rewritten comparison expression that was originally written using operator syntax.
Definition: ExprCXX.h:283
Expr * getSemanticForm()
Get an equivalent semantic form for this expression.
Definition: ExprCXX.h:301
SourceLocation getOperatorLoc() const LLVM_READONLY
Definition: ExprCXX.h:335
BinaryOperatorKind getOperator() const
Definition: ExprCXX.h:321
SourceLocation getEndLoc() const LLVM_READONLY
Definition: ExprCXX.h:347
SourceRange getSourceRange() const LLVM_READONLY
Definition: ExprCXX.h:350
bool isReversed() const
Determine whether this expression was rewritten in reverse form.
Definition: ExprCXX.h:319
CXXRewrittenBinaryOperator(Expr *SemanticForm, bool IsReversed)
Definition: ExprCXX.h:290
const Expr * getLHS() const
Definition: ExprCXX.h:332
StringRef getOpcodeStr() const
Definition: ExprCXX.h:326
CXXRewrittenBinaryOperator(EmptyShell Empty)
Definition: ExprCXX.h:297
SourceLocation getBeginLoc() const LLVM_READONLY
Compute the begin and end locations from the decomposed form.
Definition: ExprCXX.h:344
SourceLocation getExprLoc() const LLVM_READONLY
Definition: ExprCXX.h:338
const Expr * getRHS() const
Definition: ExprCXX.h:333
static bool classof(const Stmt *T)
Definition: ExprCXX.h:360
BinaryOperatorKind getOpcode() const
Definition: ExprCXX.h:322
static StringRef getOpcodeStr(BinaryOperatorKind Op)
Definition: ExprCXX.h:323
DecomposedForm getDecomposedForm() const LLVM_READONLY
Decompose this operator into its syntactic form.
Definition: ExprCXX.cpp:66
const Expr * getSemanticForm() const
Definition: ExprCXX.h:302
An expression "T()" which creates an rvalue of a non-class type T.
Definition: ExprCXX.h:2182
CXXScalarValueInitExpr(EmptyShell Shell)
Definition: ExprCXX.h:2198
const_child_range children() const
Definition: ExprCXX.h:2221
TypeSourceInfo * getTypeSourceInfo() const
Definition: ExprCXX.h:2201
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprCXX.cpp:224
static bool classof(const Stmt *T)
Definition: ExprCXX.h:2212
SourceLocation getEndLoc() const
Definition: ExprCXX.h:2210
SourceLocation getRParenLoc() const
Definition: ExprCXX.h:2205
CXXScalarValueInitExpr(QualType Type, TypeSourceInfo *TypeInfo, SourceLocation RParenLoc)
Create an explicitly-written scalar-value initialization expression.
Definition: ExprCXX.h:2190
A C++ static_cast expression (C++ [expr.static.cast]).
Definition: ExprCXX.h:433
static CXXStaticCastExpr * CreateEmpty(const ASTContext &Context, unsigned PathSize, bool hasFPFeatures)
Definition: ExprCXX.cpp:779
static bool classof(const Stmt *T)
Definition: ExprCXX.h:466
Implicit construction of a std::initializer_list<T> object from an array temporary within list-initia...
Definition: ExprCXX.h:797
SourceRange getSourceRange() const LLVM_READONLY
Retrieve the source range of the expression.
Definition: ExprCXX.h:825
const_child_range children() const
Definition: ExprCXX.h:835
CXXStdInitializerListExpr(QualType Ty, Expr *SubExpr)
Definition: ExprCXX.h:807
SourceLocation getEndLoc() const LLVM_READONLY
Definition: ExprCXX.h:820
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprCXX.h:816
const Expr * getSubExpr() const
Definition: ExprCXX.h:814
static bool classof(const Stmt *S)
Definition: ExprCXX.h:829
Represents a C++ functional cast expression that builds a temporary object.
Definition: ExprCXX.h:1885
TypeSourceInfo * getTypeSourceInfo() const
Definition: ExprCXX.h:1914
SourceLocation getEndLoc() const LLVM_READONLY
Definition: ExprCXX.cpp:1153
static CXXTemporaryObjectExpr * CreateEmpty(const ASTContext &Ctx, unsigned NumArgs)
Definition: ExprCXX.cpp:1141
static bool classof(const Stmt *T)
Definition: ExprCXX.h:1919
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprCXX.cpp:1149
Represents a C++ temporary.
Definition: ExprCXX.h:1457
const CXXDestructorDecl * getDestructor() const
Definition: ExprCXX.h:1468
void setDestructor(const CXXDestructorDecl *Dtor)
Definition: ExprCXX.h:1470
Represents the this expression in C++.
Definition: ExprCXX.h:1152
void setCapturedByCopyInLambdaWithExplicitObjectParameter(bool Set)
Definition: ExprCXX.h:1182
SourceLocation getBeginLoc() const
Definition: ExprCXX.h:1172
void setLocation(SourceLocation L)
Definition: ExprCXX.h:1170
SourceLocation getEndLoc() const
Definition: ExprCXX.h:1173
bool isCapturedByCopyInLambdaWithExplicitObjectParameter() const
Definition: ExprCXX.h:1178
static CXXThisExpr * CreateEmpty(const ASTContext &Ctx)
Definition: ExprCXX.cpp:1575
void setImplicit(bool I)
Definition: ExprCXX.h:1176
child_range children()
Definition: ExprCXX.h:1192
bool isImplicit() const
Definition: ExprCXX.h:1175
static bool classof(const Stmt *T)
Definition: ExprCXX.h:1187
const_child_range children() const
Definition: ExprCXX.h:1196
SourceLocation getLocation() const
Definition: ExprCXX.h:1169
A C++ throw-expression (C++ [except.throw]).
Definition: ExprCXX.h:1206
CXXThrowExpr(EmptyShell Empty)
Definition: ExprCXX.h:1224
const_child_range children() const
Definition: ExprCXX.h:1256
SourceLocation getEndLoc() const LLVM_READONLY
Definition: ExprCXX.h:1241
const Expr * getSubExpr() const
Definition: ExprCXX.h:1226
CXXThrowExpr(Expr *Operand, QualType Ty, SourceLocation Loc, bool IsThrownVariableInScope)
Definition: ExprCXX.h:1217
SourceLocation getThrowLoc() const
Definition: ExprCXX.h:1229
Expr * getSubExpr()
Definition: ExprCXX.h:1227
SourceLocation getBeginLoc() const
Definition: ExprCXX.h:1240
bool isThrownVariableInScope() const
Determines whether the variable thrown by this expression (if any!) is within the innermost try block...
Definition: ExprCXX.h:1236
static bool classof(const Stmt *T)
Definition: ExprCXX.h:1247
child_range children()
Definition: ExprCXX.h:1252
A C++ typeid expression (C++ [expr.typeid]), which gets the type_info that corresponds to the supplie...
Definition: ExprCXX.h:845
CXXTypeidExpr(QualType Ty, Expr *Operand, SourceRange R)
Definition: ExprCXX.h:859
static bool classof(const Stmt *T)
Definition: ExprCXX.h:902
QualType getTypeOperand(ASTContext &Context) const
Retrieves the type operand of this typeid() expression after various required adjustments (removing r...
Definition: ExprCXX.cpp:162
CXXTypeidExpr(QualType Ty, TypeSourceInfo *Operand, SourceRange R)
Definition: ExprCXX.h:853
bool isTypeOperand() const
Definition: ExprCXX.h:881
TypeSourceInfo * getTypeOperandSourceInfo() const
Retrieve source information for the type operand.
Definition: ExprCXX.h:888
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprCXX.h:897
Expr * getExprOperand() const
Definition: ExprCXX.h:892
child_range children()
Definition: ExprCXX.h:907
bool isMostDerived(ASTContext &Context) const
Best-effort check if the expression operand refers to a most derived object.
Definition: ExprCXX.cpp:150
SourceRange getSourceRange() const LLVM_READONLY
Definition: ExprCXX.h:899
void setSourceRange(SourceRange R)
Definition: ExprCXX.h:900
const_child_range children() const
Definition: ExprCXX.h:914
SourceLocation getEndLoc() const LLVM_READONLY
Definition: ExprCXX.h:898
bool isPotentiallyEvaluated() const
Determine whether this typeid has a type operand which is potentially evaluated, per C++11 [expr....
Definition: ExprCXX.cpp:135
CXXTypeidExpr(EmptyShell Empty, bool isExpr)
Definition: ExprCXX.h:865
bool hasNullCheck() const
Whether this is of a form like "typeid(*ptr)" that can throw a std::bad_typeid if a pointer is a null...
Definition: ExprCXX.cpp:201
Describes an explicit type conversion that uses functional notion but could not be resolved because o...
Definition: ExprCXX.h:3557
const_child_range children() const
Definition: ExprCXX.h:3665
const Expr *const * const_arg_iterator
Definition: ExprCXX.h:3624
void setRParenLoc(SourceLocation L)
Definition: ExprCXX.h:3607
void setArg(unsigned I, Expr *E)
Definition: ExprCXX.h:3643
SourceLocation getLParenLoc() const
Retrieve the location of the left parentheses ('(') that precedes the argument list.
Definition: ExprCXX.h:3601
bool isListInitialization() const
Determine whether this expression models list-initialization.
Definition: ExprCXX.h:3612
TypeSourceInfo * getTypeSourceInfo() const
Retrieve the type source information for the type being constructed.
Definition: ExprCXX.h:3595
const_arg_range arguments() const
Definition: ExprCXX.h:3629
QualType getTypeAsWritten() const
Retrieve the type that is being constructed, as specified in the source code.
Definition: ExprCXX.h:3591
const_arg_iterator arg_end() const
Definition: ExprCXX.h:3628
SourceLocation getEndLoc() const LLVM_READONLY
Definition: ExprCXX.h:3649
llvm::iterator_range< const_arg_iterator > const_arg_range
Definition: ExprCXX.h:3625
void setLParenLoc(SourceLocation L)
Definition: ExprCXX.h:3602
const Expr * getArg(unsigned I) const
Definition: ExprCXX.h:3638
Expr * getArg(unsigned I)
Definition: ExprCXX.h:3633
SourceLocation getRParenLoc() const
Retrieve the location of the right parentheses (')') that follows the argument list.
Definition: ExprCXX.h:3606
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprCXX.cpp:1488
unsigned getNumArgs() const
Retrieve the number of arguments.
Definition: ExprCXX.h:3615
static bool classof(const Stmt *T)
Definition: ExprCXX.h:3655
static CXXUnresolvedConstructExpr * CreateEmpty(const ASTContext &Context, unsigned NumArgs)
Definition: ExprCXX.cpp:1482
llvm::iterator_range< arg_iterator > arg_range
Definition: ExprCXX.h:3618
const_arg_iterator arg_begin() const
Definition: ExprCXX.h:3627
A Microsoft C++ __uuidof expression, which gets the _GUID that corresponds to the supplied type or ex...
Definition: ExprCXX.h:1066
child_range children()
Definition: ExprCXX.h:1124
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprCXX.h:1114
static bool classof(const Stmt *T)
Definition: ExprCXX.h:1119
const_child_range children() const
Definition: ExprCXX.h:1131
Expr * getExprOperand() const
Definition: ExprCXX.h:1107
CXXUuidofExpr(QualType Ty, TypeSourceInfo *Operand, MSGuidDecl *Guid, SourceRange R)
Definition: ExprCXX.h:1075
MSGuidDecl * getGuidDecl() const
Definition: ExprCXX.h:1112
QualType getTypeOperand(ASTContext &Context) const
Retrieves the type operand of this __uuidof() expression after various required adjustments (removing...
Definition: ExprCXX.cpp:216
bool isTypeOperand() const
Definition: ExprCXX.h:1096
CXXUuidofExpr(QualType Ty, Expr *Operand, MSGuidDecl *Guid, SourceRange R)
Definition: ExprCXX.h:1082
TypeSourceInfo * getTypeOperandSourceInfo() const
Retrieve source information for the type operand.
Definition: ExprCXX.h:1103
void setSourceRange(SourceRange R)
Definition: ExprCXX.h:1117
SourceRange getSourceRange() const LLVM_READONLY
Definition: ExprCXX.h:1116
SourceLocation getEndLoc() const LLVM_READONLY
Definition: ExprCXX.h:1115
CXXUuidofExpr(EmptyShell Empty, bool isExpr)
Definition: ExprCXX.h:1088
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
Definition: Expr.h:2830
Expr * getArg(unsigned Arg)
getArg - Return the specified argument.
Definition: Expr.h:3021
static constexpr ADLCallKind NotADL
Definition: Expr.h:2887
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: Expr.cpp:1638
Expr * getCallee()
Definition: Expr.h:2980
SourceLocation getRParenLoc() const
Definition: Expr.h:3145
static constexpr ADLCallKind UsesADL
Definition: Expr.h:2888
Stmt * getPreArg(unsigned I)
Definition: Expr.h:2910
CastExpr - Base class for type casts, including both implicit casts (ImplicitCastExpr) and explicit c...
Definition: Expr.h:3498
FPOptionsOverride * getTrailingFPFeatures()
Return a pointer to the trailing FPOptions.
Definition: Expr.cpp:2054
unsigned path_size() const
Definition: Expr.h:3567
bool hasStoredFPFeatures() const
Definition: Expr.h:3597
Represents a 'co_await' expression.
Definition: ExprCXX.h:5185
void setIsImplicit(bool value=true)
Definition: ExprCXX.h:5208
bool isImplicit() const
Definition: ExprCXX.h:5207
static bool classof(const Stmt *T)
Definition: ExprCXX.h:5210
CoawaitExpr(EmptyShell Empty)
Definition: ExprCXX.h:5204
CoawaitExpr(SourceLocation CoawaitLoc, QualType Ty, Expr *Operand, Expr *Common, bool IsImplicit=false)
Definition: ExprCXX.h:5197
CoawaitExpr(SourceLocation CoawaitLoc, Expr *Operand, Expr *Common, Expr *Ready, Expr *Suspend, Expr *Resume, OpaqueValueExpr *OpaqueValue, bool IsImplicit=false)
Definition: ExprCXX.h:5189
CompoundStmt - This represents a group of statements like { stmt stmt }.
Definition: Stmt.h:1611
ConstantExpr - An expression that occurs in a constant context and optionally the result of evaluatin...
Definition: Expr.h:1077
llvm::APSInt getResultAsAPSInt() const
Definition: Expr.cpp:401
Represents an expression that might suspend coroutine execution; either a co_await or co_yield expres...
Definition: ExprCXX.h:5071
SuspendReturnType getSuspendReturnType() const
Definition: ExprCXX.h:5144
CoroutineSuspendExpr(StmtClass SC, SourceLocation KeywordLoc, Expr *Operand, Expr *Common, Expr *Ready, Expr *Suspend, Expr *Resume, OpaqueValueExpr *OpaqueValue)
Definition: ExprCXX.h:5085
Expr * getReadyExpr() const
Definition: ExprCXX.h:5127
SourceLocation getKeywordLoc() const
Definition: ExprCXX.h:5162
Expr * getResumeExpr() const
Definition: ExprCXX.h:5135
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprCXX.h:5164
Expr * getSuspendExpr() const
Definition: ExprCXX.h:5131
CoroutineSuspendExpr(StmtClass SC, SourceLocation KeywordLoc, QualType Ty, Expr *Operand, Expr *Common)
Definition: ExprCXX.h:5099
static bool classof(const Stmt *T)
Definition: ExprCXX.h:5178
OpaqueValueExpr * getOpaqueValue() const
getOpaqueValue - Return the opaque value placeholder.
Definition: ExprCXX.h:5125
Expr * getCommonExpr() const
Definition: ExprCXX.h:5120
Expr * getOperand() const
Definition: ExprCXX.h:5140
const_child_range children() const
Definition: ExprCXX.h:5174
child_range children()
Definition: ExprCXX.h:5170
CoroutineSuspendExpr(StmtClass SC, EmptyShell Empty)
Definition: ExprCXX.h:5112
SourceLocation getEndLoc() const LLVM_READONLY
Definition: ExprCXX.h:5166
Represents a 'co_yield' expression.
Definition: ExprCXX.h:5266
CoyieldExpr(EmptyShell Empty)
Definition: ExprCXX.h:5279
CoyieldExpr(SourceLocation CoyieldLoc, Expr *Operand, Expr *Common, Expr *Ready, Expr *Suspend, Expr *Resume, OpaqueValueExpr *OpaqueValue)
Definition: ExprCXX.h:5270
static bool classof(const Stmt *T)
Definition: ExprCXX.h:5282
CoyieldExpr(SourceLocation CoyieldLoc, QualType Ty, Expr *Operand, Expr *Common)
Definition: ExprCXX.h:5275
A POD class for pairing a NamedDecl* with an access specifier.
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
Definition: DeclBase.h:1436
Decl - This represents one declaration (or definition), e.g.
Definition: DeclBase.h:86
The name of a declaration.
Represents a 'co_await' expression while the type of the promise is dependent.
Definition: ExprCXX.h:5217
static bool classof(const Stmt *T)
Definition: ExprCXX.h:5260
DependentCoawaitExpr(EmptyShell Empty)
Definition: ExprCXX.h:5237
SourceLocation getEndLoc() const LLVM_READONLY
Definition: ExprCXX.h:5250
const_child_range children() const
Definition: ExprCXX.h:5256
Expr * getOperand() const
Definition: ExprCXX.h:5240
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprCXX.h:5248
DependentCoawaitExpr(SourceLocation KeywordLoc, QualType Ty, Expr *Op, UnresolvedLookupExpr *OpCoawait)
Definition: ExprCXX.h:5224
SourceLocation getKeywordLoc() const
Definition: ExprCXX.h:5246
child_range children()
Definition: ExprCXX.h:5254
UnresolvedLookupExpr * getOperatorCoawaitLookup() const
Definition: ExprCXX.h:5242
A qualified reference to a name whose declaration cannot yet be resolved.
Definition: ExprCXX.h:3323
SourceLocation getRAngleLoc() const
Retrieve the location of the right angle bracket ending the explicit template argument list following...
Definition: ExprCXX.h:3397
static DependentScopeDeclRefExpr * CreateEmpty(const ASTContext &Context, bool HasTemplateKWAndArgsInfo, unsigned NumTemplateArgs)
Definition: ExprCXX.cpp:547
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier that qualifies the name, with source location information.
Definition: ExprCXX.h:3371
SourceLocation getLocation() const
Retrieve the location of the name within the expression.
Definition: ExprCXX.h:3367
SourceLocation getLAngleLoc() const
Retrieve the location of the left angle bracket starting the explicit template argument list followin...
Definition: ExprCXX.h:3389
ArrayRef< TemplateArgumentLoc > template_arguments() const
Definition: ExprCXX.h:3431
const_child_range children() const
Definition: ExprCXX.h:3455
static bool classof(const Stmt *T)
Definition: ExprCXX.h:3447
bool hasExplicitTemplateArgs() const
Determines whether this lookup had explicit template arguments.
Definition: ExprCXX.h:3407
SourceLocation getEndLoc() const LLVM_READONLY
Definition: ExprCXX.h:3441
SourceLocation getBeginLoc() const LLVM_READONLY
Note: getBeginLoc() is the start of the whole DependentScopeDeclRefExpr, and differs from getLocation...
Definition: ExprCXX.h:3437
NestedNameSpecifier * getQualifier() const
Retrieve the nested-name-specifier that qualifies this declaration.
Definition: ExprCXX.h:3375
SourceLocation getTemplateKeywordLoc() const
Retrieve the location of the template keyword preceding this name, if any.
Definition: ExprCXX.h:3381
bool hasTemplateKeyword() const
Determines whether the name was preceded by the template keyword.
Definition: ExprCXX.h:3404
unsigned getNumTemplateArgs() const
Definition: ExprCXX.h:3424
DeclarationName getDeclName() const
Retrieve the name that this expression refers to.
Definition: ExprCXX.h:3362
TemplateArgumentLoc const * getTemplateArgs() const
Definition: ExprCXX.h:3417
void copyTemplateArgumentsInto(TemplateArgumentListInfo &List) const
Copies the template arguments (if present) into the given structure.
Definition: ExprCXX.h:3411
const DeclarationNameInfo & getNameInfo() const
Retrieve the name that this expression refers to.
Definition: ExprCXX.h:3359
ExplicitCastExpr - An explicit cast written in the source code.
Definition: Expr.h:3750
Represents an expression – generally a full-expression – that introduces cleanups to be run at the en...
Definition: ExprCXX.h:3474
bool cleanupsHaveSideEffects() const
Definition: ExprCXX.h:3509
static bool classof(const Stmt *T)
Definition: ExprCXX.h:3522
CleanupObject getObject(unsigned i) const
Definition: ExprCXX.h:3504
child_range children()
Definition: ExprCXX.h:3527
ArrayRef< CleanupObject > getObjects() const
Definition: ExprCXX.h:3498
unsigned getNumObjects() const
Definition: ExprCXX.h:3502
SourceLocation getEndLoc() const LLVM_READONLY
Definition: ExprCXX.h:3517
const_child_range children() const
Definition: ExprCXX.h:3529
llvm::PointerUnion< BlockDecl *, CompoundLiteralExpr * > CleanupObject
The type of objects that are kept in the cleanup.
Definition: ExprCXX.h:3480
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprCXX.h:3513
This represents one expression.
Definition: Expr.h:110
bool isImplicitCXXThis() const
Whether this expression is an implicit reference to 'this' in C++.
Definition: Expr.cpp:3246
bool isValueDependent() const
Determines whether the value of this expression depends on.
Definition: Expr.h:175
ExprValueKind getValueKind() const
getValueKind - The value kind that this expression produces.
Definition: Expr.h:437
bool isTypeDependent() const
Determines whether the type of this expression depends on.
Definition: Expr.h:192
bool containsUnexpandedParameterPack() const
Whether this expression contains an unexpanded parameter pack (for C++11 variadic templates).
Definition: Expr.h:239
bool isLValue() const
isLValue - True if this expression is an "l-value" according to the rules of the current language.
Definition: Expr.h:277
ExprObjectKind getObjectKind() const
getObjectKind - The object kind that this expression produces.
Definition: Expr.h:444
bool isInstantiationDependent() const
Whether this expression is instantiation-dependent, meaning that it depends in some way on.
Definition: Expr.h:221
Expr()=delete
void setValueKind(ExprValueKind Cat)
setValueKind - Set the value kind produced by this expression.
Definition: Expr.h:454
SourceLocation getExprLoc() const LLVM_READONLY
getExprLoc - Return the preferred location for the arrow when diagnosing a problem with a generic exp...
Definition: Expr.cpp:277
QualType getType() const
Definition: Expr.h:142
static ExprValueKind getValueKindForType(QualType T)
getValueKindForType - Given a formal return or parameter type, give its value kind.
Definition: Expr.h:427
void setDependence(ExprDependence Deps)
Each concrete expr subclass is expected to compute its dependence and call this in the constructor.
Definition: Expr.h:135
An expression trait intrinsic.
Definition: ExprCXX.h:2924
ExpressionTraitExpr(SourceLocation loc, ExpressionTrait et, Expr *queried, bool value, SourceLocation rparen, QualType resultType)
Definition: ExprCXX.h:2945
static bool classof(const Stmt *T)
Definition: ExprCXX.h:2967
ExpressionTraitExpr(EmptyShell Empty)
Definition: ExprCXX.h:2955
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprCXX.h:2958
Expr * getQueriedExpression() const
Definition: ExprCXX.h:2963
ExpressionTrait getTrait() const
Definition: ExprCXX.h:2961
child_range children()
Definition: ExprCXX.h:2972
SourceLocation getEndLoc() const LLVM_READONLY
Definition: ExprCXX.h:2959
const_child_range children() const
Definition: ExprCXX.h:2976
Represents difference between two FPOptions values.
Definition: LangOptions.h:947
bool requiresTrailingStorage() const
Definition: LangOptions.h:973
Represents a member of a struct/union/class.
Definition: Decl.h:3030
FullExpr - Represents a "full-expression" node.
Definition: Expr.h:1044
Stmt * SubExpr
Definition: Expr.h:1046
Represents a function declaration or definition.
Definition: Decl.h:1932
Represents a reference to a function parameter pack or init-capture pack that has been substituted bu...
Definition: ExprCXX.h:4648
VarDecl * getParameterPack() const
Get the parameter pack which this expression refers to.
Definition: ExprCXX.h:4675
const_child_range children() const
Definition: ExprCXX.h:4703
SourceLocation getEndLoc() const LLVM_READONLY
Definition: ExprCXX.h:4693
iterator end() const
Definition: ExprCXX.h:4684
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprCXX.h:4692
VarDecl * getExpansion(unsigned I) const
Get an expansion of the parameter pack by index.
Definition: ExprCXX.h:4690
VarDecl *const * iterator
Iterators over the parameters which the parameter pack expanded into.
Definition: ExprCXX.h:4682
unsigned getNumExpansions() const
Get the number of parameters in this parameter pack.
Definition: ExprCXX.h:4687
static bool classof(const Stmt *T)
Definition: ExprCXX.h:4695
SourceLocation getParameterPackLocation() const
Get the location of the parameter pack.
Definition: ExprCXX.h:4678
child_range children()
Definition: ExprCXX.h:4699
static FunctionParmPackExpr * CreateEmpty(const ASTContext &Context, unsigned NumParams)
Definition: ExprCXX.cpp:1805
iterator begin() const
Definition: ExprCXX.h:4683
Declaration of a template function.
Definition: DeclTemplate.h:957
One of these records is kept for each identifier that is lexed.
Describes the capture of a variable or of this, or of a C++1y init-capture.
Definition: LambdaCapture.h:25
A C++ lambda expression, which produces a function object (of unspecified type) that can be invoked l...
Definition: ExprCXX.h:1954
llvm::iterator_range< const_capture_init_iterator > capture_inits() const
Retrieve the initialization expressions for this lambda's captures.
Definition: ExprCXX.h:2074
capture_iterator capture_begin() const
Retrieve an iterator pointing to the first lambda capture.
Definition: ExprCXX.cpp:1345
static LambdaExpr * CreateDeserialized(const ASTContext &C, unsigned NumCaptures)
Construct a new lambda expression that will be deserialized from an external source.
Definition: ExprCXX.cpp:1314
SourceLocation getEndLoc() const LLVM_READONLY
Definition: ExprCXX.h:2172
Stmt * getBody() const
Retrieve the body of the lambda.
Definition: ExprCXX.cpp:1328
bool hasExplicitParameters() const
Determine whether this lambda has an explicit parameter list vs.
Definition: ExprCXX.h:2157
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:2086
bool isGenericLambda() const
Whether this is a generic lambda.
Definition: ExprCXX.h:2134
SourceRange getIntroducerRange() const
Retrieve the source range covering the lambda introducer, which contains the explicit capture list su...
Definition: ExprCXX.h:2105
bool isMutable() const
Determine whether the lambda is mutable, meaning that any captures values can be modified.
Definition: ExprCXX.cpp:1410
capture_iterator implicit_capture_end() const
Retrieve an iterator pointing past the end of the sequence of implicit lambda captures.
Definition: ExprCXX.cpp:1374
friend TrailingObjects
Definition: ExprCXX.h:1991
CompoundStmt * getCompoundStmtBody()
Definition: ExprCXX.h:2146
unsigned capture_size() const
Determine the number of captures in this lambda.
Definition: ExprCXX.h:2035
capture_range explicit_captures() const
Retrieve this lambda's explicit captures.
Definition: ExprCXX.cpp:1366
bool isInitCapture(const LambdaCapture *Capture) const
Determine whether one of this lambda's captures is an init-capture.
Definition: ExprCXX.cpp:1340
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:2098
CXXMethodDecl * getCallOperator() const
Retrieve the function call operator associated with this lambda expression.
Definition: ExprCXX.cpp:1386
const CompoundStmt * getCompoundStmtBody() const
Retrieve the CompoundStmt representing the body of the lambda.
Definition: ExprCXX.cpp:1333
bool hasExplicitResultType() const
Whether this lambda had its result type explicitly specified.
Definition: ExprCXX.h:2160
capture_range implicit_captures() const
Retrieve this lambda's implicit captures.
Definition: ExprCXX.cpp:1378
TemplateParameterList * getTemplateParameterList() const
If this is a generic lambda expression, retrieve the template parameter list associated with it,...
Definition: ExprCXX.cpp:1396
ArrayRef< NamedDecl * > getExplicitTemplateParameters() const
Get the template parameters were explicitly specified (as opposed to being invented by use of an auto...
Definition: ExprCXX.cpp:1401
capture_iterator implicit_capture_begin() const
Retrieve an iterator pointing to the first implicit lambda capture.
Definition: ExprCXX.cpp:1370
capture_iterator explicit_capture_end() const
Retrieve an iterator pointing past the end of the sequence of explicit lambda captures.
Definition: ExprCXX.cpp:1361
capture_iterator capture_end() const
Retrieve an iterator pointing past the end of the sequence of lambda captures.
Definition: ExprCXX.cpp:1349
llvm::iterator_range< capture_iterator > capture_range
An iterator over a range of lambda captures.
Definition: ExprCXX.h:2022
SourceLocation getCaptureDefaultLoc() const
Retrieve the location of this lambda's capture-default, if any.
Definition: ExprCXX.h:2012
capture_init_iterator capture_init_end()
Retrieve the iterator pointing one past the last initialization argument for this lambda expression.
Definition: ExprCXX.h:2092
const LambdaCapture * capture_iterator
An iterator that walks over the captures of the lambda, both implicit and explicit.
Definition: ExprCXX.h:2019
Expr *const * const_capture_init_iterator
Const iterator that walks over the capture initialization arguments.
Definition: ExprCXX.h:2066
Expr * getTrailingRequiresClause() const
Get the trailing requires clause, if any.
Definition: ExprCXX.cpp:1406
capture_iterator explicit_capture_begin() const
Retrieve an iterator pointing to the first explicit lambda capture.
Definition: ExprCXX.cpp:1357
llvm::iterator_range< capture_init_iterator > capture_inits()
Retrieve the initialization expressions for this lambda's captures.
Definition: ExprCXX.h:2069
child_range children()
Includes the captures and the body of the lambda.
Definition: ExprCXX.cpp:1412
FunctionTemplateDecl * getDependentCallOperator() const
Retrieve the function template call operator associated with this lambda expression.
Definition: ExprCXX.cpp:1391
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprCXX.h:2168
static bool classof(const Stmt *T)
Definition: ExprCXX.h:2164
capture_range captures() const
Retrieve this lambda's captures.
Definition: ExprCXX.cpp:1353
capture_init_iterator capture_init_begin()
Retrieve the first initialization argument for this lambda expression (which initializes the first ca...
Definition: ExprCXX.h:2080
LambdaCaptureDefault getCaptureDefault() const
Determine the default capture kind for this lambda.
Definition: ExprCXX.h:2007
CXXRecordDecl * getLambdaClass() const
Retrieve the class that corresponds to the lambda.
Definition: ExprCXX.cpp:1382
Implicit declaration of a temporary that was materialized by a MaterializeTemporaryExpr and lifetime-...
Definition: DeclCXX.h:3233
unsigned getManglingNumber() const
Definition: DeclCXX.h:3282
Stmt::child_range childrenExpr()
Definition: DeclCXX.h:3291
StorageDuration getStorageDuration() const
Retrieve the storage duration for the materialized temporary.
Definition: DeclCXX.cpp:3078
Expr * getTemporaryExpr()
Retrieve the expression to which the temporary materialization conversion was applied.
Definition: DeclCXX.h:3279
A global _GUID constant.
Definition: DeclCXX.h:4293
An instance of this class represents the declaration of a property member.
Definition: DeclCXX.h:4239
A member reference to an MSPropertyDecl.
Definition: ExprCXX.h:933
const_child_range children() const
Definition: ExprCXX.h:977
NestedNameSpecifierLoc getQualifierLoc() const
Definition: ExprCXX.h:990
MSPropertyRefExpr(EmptyShell Empty)
Definition: ExprCXX.h:952
bool isArrow() const
Definition: ExprCXX.h:988
bool isImplicitAccess() const
Definition: ExprCXX.h:958
SourceRange getSourceRange() const LLVM_READONLY
Definition: ExprCXX.h:954
SourceLocation getEndLoc() const
Definition: ExprCXX.h:971
MSPropertyDecl * getPropertyDecl() const
Definition: ExprCXX.h:987
Expr * getBaseExpr() const
Definition: ExprCXX.h:986
child_range children()
Definition: ExprCXX.h:973
MSPropertyRefExpr(Expr *baseExpr, MSPropertyDecl *decl, bool isArrow, QualType ty, ExprValueKind VK, NestedNameSpecifierLoc qualifierLoc, SourceLocation nameLoc)
Definition: ExprCXX.h:943
static bool classof(const Stmt *T)
Definition: ExprCXX.h:982
SourceLocation getBeginLoc() const
Definition: ExprCXX.h:962
SourceLocation getMemberLoc() const
Definition: ExprCXX.h:989
MS property subscript expression.
Definition: ExprCXX.h:1004
static bool classof(const Stmt *T)
Definition: ExprCXX.h:1048
const Expr * getIdx() const
Definition: ExprCXX.h:1033
void setRBracketLoc(SourceLocation L)
Definition: ExprCXX.h:1042
SourceLocation getEndLoc() const LLVM_READONLY
Definition: ExprCXX.h:1039
MSPropertySubscriptExpr(Expr *Base, Expr *Idx, QualType Ty, ExprValueKind VK, ExprObjectKind OK, SourceLocation RBracketLoc)
Definition: ExprCXX.h:1016
SourceLocation getExprLoc() const LLVM_READONLY
Definition: ExprCXX.h:1044
const_child_range children() const
Definition: ExprCXX.h:1057
MSPropertySubscriptExpr(EmptyShell Shell)
Create an empty array subscript expression.
Definition: ExprCXX.h:1026
const Expr * getBase() const
Definition: ExprCXX.h:1030
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprCXX.h:1035
SourceLocation getRBracketLoc() const
Definition: ExprCXX.h:1041
Represents a prvalue temporary that is written into memory so that a reference can bind to it.
Definition: ExprCXX.h:4728
const LifetimeExtendedTemporaryDecl * getLifetimeExtendedTemporaryDecl() const
Definition: ExprCXX.h:4772
StorageDuration getStorageDuration() const
Retrieve the storage duration for the materialized temporary.
Definition: ExprCXX.h:4753
Expr * getSubExpr() const
Retrieve the temporary-generating subexpression whose value will be materialized into a glvalue.
Definition: ExprCXX.h:4745
APValue * getOrCreateValue(bool MayCreate) const
Get the storage for the constant value of a materialized temporary of static storage duration.
Definition: ExprCXX.h:4761
bool isBoundToLvalueReference() const
Determine whether this materialized temporary is bound to an lvalue reference; otherwise,...
Definition: ExprCXX.h:4797
ValueDecl * getExtendingDecl()
Get the declaration which triggered the lifetime-extension of this temporary, if any.
Definition: ExprCXX.h:4778
bool isUsableInConstantExpressions(const ASTContext &Context) const
Determine whether this temporary object is usable in constant expressions, as specified in C++20 [exp...
Definition: ExprCXX.cpp:1842
MaterializeTemporaryExpr(EmptyShell Empty)
Definition: ExprCXX.h:4740
LifetimeExtendedTemporaryDecl * getLifetimeExtendedTemporaryDecl()
Definition: ExprCXX.h:4768
void setExtendingDecl(ValueDecl *ExtendedBy, unsigned ManglingNumber)
Definition: ExprCXX.cpp:1825
SourceLocation getEndLoc() const LLVM_READONLY
Definition: ExprCXX.h:4807
const ValueDecl * getExtendingDecl() const
Definition: ExprCXX.h:4783
static bool classof(const Stmt *T)
Definition: ExprCXX.h:4811
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprCXX.h:4803
unsigned getManglingNumber() const
Definition: ExprCXX.h:4789
const_child_range children() const
Definition: ExprCXX.h:4822
This represents a decl that may have a name.
Definition: Decl.h:249
A C++ nested-name-specifier augmented with source location information.
SourceLocation getBeginLoc() const
Retrieve the location of the beginning of this nested-name-specifier.
bool hasQualifier() const
Evaluates true when this nested-name-specifier location is non-empty.
NestedNameSpecifier * getNestedNameSpecifier() const
Retrieve the nested-name-specifier to which this instance refers.
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
NonTypeTemplateParmDecl - Declares a non-type template parameter, e.g., "Size" in.
OpaqueValueExpr - An expression referring to an opaque object of a fixed type and value class.
Definition: Expr.h:1173
A reference to an overloaded function set, either an UnresolvedLookupExpr or an UnresolvedMemberExpr.
Definition: ExprCXX.h:2983
static bool classof(const Stmt *T)
Definition: ExprCXX.h:3160
NestedNameSpecifier * getQualifier() const
Fetches the nested-name qualifier, if one was given.
Definition: ExprCXX.h:3099
ASTTemplateKWAndArgsInfo * getTrailingASTTemplateKWAndArgsInfo()
Return the optional template keyword and arguments info.
Definition: ExprCXX.h:4099
bool hasExplicitTemplateArgs() const
Determines whether this expression had explicit template arguments.
Definition: ExprCXX.h:3135
static FindResult find(Expr *E)
Finds the overloaded expression in the given expression E of OverloadTy.
Definition: ExprCXX.h:3044
SourceLocation getLAngleLoc() const
Retrieve the location of the left angle bracket starting the explicit template argument list followin...
Definition: ExprCXX.h:3117
const DeclarationNameInfo & getNameInfo() const
Gets the full name info.
Definition: ExprCXX.h:3090
const CXXRecordDecl * getNamingClass() const
Definition: ExprCXX.h:3070
SourceLocation getNameLoc() const
Gets the location of the name.
Definition: ExprCXX.h:3096
decls_iterator decls_begin() const
Definition: ExprCXX.h:3076
CXXRecordDecl * getNamingClass()
Gets the naming class of this lookup, if any.
Definition: ExprCXX.h:4116
unsigned getNumDecls() const
Gets the number of declarations in the unresolved set.
Definition: ExprCXX.h:3087
SourceLocation getTemplateKeywordLoc() const
Retrieve the location of the template keyword preceding this name, if any.
Definition: ExprCXX.h:3109
NestedNameSpecifierLoc getQualifierLoc() const
Fetches the nested-name qualifier with source-location information, if one was given.
Definition: ExprCXX.h:3105
const ASTTemplateKWAndArgsInfo * getTrailingASTTemplateKWAndArgsInfo() const
Definition: ExprCXX.h:3015
TemplateArgumentLoc const * getTemplateArgs() const
Definition: ExprCXX.h:3137
llvm::iterator_range< decls_iterator > decls() const
Definition: ExprCXX.h:3082
void copyTemplateArgumentsInto(TemplateArgumentListInfo &List) const
Copies the template arguments into the given structure.
Definition: ExprCXX.h:3155
TemplateArgumentLoc * getTrailingTemplateArgumentLoc()
Return the optional template arguments.
Definition: ExprCXX.h:4109
DeclAccessPair * getTrailingResults()
Return the results. Defined after UnresolvedMemberExpr.
Definition: ExprCXX.h:4093
const DeclAccessPair * getTrailingResults() const
Definition: ExprCXX.h:3008
bool hasTemplateKWAndArgsInfo() const
Definition: ExprCXX.h:3027
decls_iterator decls_end() const
Definition: ExprCXX.h:3079
unsigned getNumTemplateArgs() const
Definition: ExprCXX.h:3143
const TemplateArgumentLoc * getTrailingTemplateArgumentLoc() const
Definition: ExprCXX.h:3023
DeclarationName getName() const
Gets the name looked up.
Definition: ExprCXX.h:3093
SourceLocation getRAngleLoc() const
Retrieve the location of the right angle bracket ending the explicit template argument list following...
Definition: ExprCXX.h:3125
bool hasTemplateKeyword() const
Determines whether the name was preceded by the template keyword.
Definition: ExprCXX.h:3132
ArrayRef< TemplateArgumentLoc > template_arguments() const
Definition: ExprCXX.h:3150
Represents a C++11 pack expansion that produces a sequence of expressions.
Definition: ExprCXX.h:4180
Expr * getPattern()
Retrieve the pattern of the pack expansion.
Definition: ExprCXX.h:4209
const Expr * getPattern() const
Retrieve the pattern of the pack expansion.
Definition: ExprCXX.h:4212
child_range children()
Definition: ExprCXX.h:4238
PackExpansionExpr(QualType T, Expr *Pattern, SourceLocation EllipsisLoc, std::optional< unsigned > NumExpansions)
Definition: ExprCXX.h:4196
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprCXX.h:4227
std::optional< unsigned > getNumExpansions() const
Determine the number of expansions that will be produced when this pack expansion is instantiated,...
Definition: ExprCXX.h:4220
SourceLocation getEndLoc() const LLVM_READONLY
Definition: ExprCXX.h:4231
const_child_range children() const
Definition: ExprCXX.h:4242
SourceLocation getEllipsisLoc() const
Retrieve the location of the ellipsis that describes this pack expansion.
Definition: ExprCXX.h:4216
PackExpansionExpr(EmptyShell Empty)
Definition: ExprCXX.h:4206
static bool classof(const Stmt *T)
Definition: ExprCXX.h:4233
NamedDecl * getPackDecl() const
Definition: ExprCXX.cpp:1735
static PackIndexingExpr * CreateDeserialized(ASTContext &Context, unsigned NumTransformedExprs)
Definition: ExprCXX.cpp:1746
SourceLocation getEllipsisLoc() const
Determine the location of the 'sizeof' keyword.
Definition: ExprCXX.h:4433
Expr * getIndexExpr() const
Definition: ExprCXX.h:4448
child_range children()
Definition: ExprCXX.h:4475
ArrayRef< Expr * > getExpressions() const
Return the trailing expressions, regardless of the expansion.
Definition: ExprCXX.h:4466
SourceLocation getEndLoc() const LLVM_READONLY
Definition: ExprCXX.h:4442
SourceLocation getPackLoc() const
Determine the location of the parameter pack.
Definition: ExprCXX.h:4436
SourceLocation getRSquareLoc() const
Determine the location of the right parenthesis.
Definition: ExprCXX.h:4439
std::optional< unsigned > getSelectedIndex() const
Definition: ExprCXX.h:4450
bool expandsToEmptyPack() const
Determine if the expression was expanded to empty.
Definition: ExprCXX.h:4430
Expr * getPackIdExpression() const
Definition: ExprCXX.h:4444
Expr * getSelectedExpr() const
Definition: ExprCXX.h:4459
static bool classof(const Stmt *T)
Definition: ExprCXX.h:4470
const_child_range children() const
Definition: ExprCXX.h:4477
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprCXX.h:4441
Represents a parameter to a function.
Definition: Decl.h:1722
PointerType - C99 6.7.5.1 - Pointer Declarators.
Definition: Type.h:3187
Stores the type being destroyed by a pseudo-destructor expression.
Definition: ExprCXX.h:2566
PseudoDestructorTypeStorage(const IdentifierInfo *II, SourceLocation Loc)
Definition: ExprCXX.h:2577
const IdentifierInfo * getIdentifier() const
Definition: ExprCXX.h:2586
SourceLocation getLocation() const
Definition: ExprCXX.h:2590
TypeSourceInfo * getTypeSourceInfo() const
Definition: ExprCXX.h:2582
A (possibly-)qualified type.
Definition: Type.h:941
Represents an expression that computes the length of a parameter pack.
Definition: ExprCXX.h:4258
SourceLocation getPackLoc() const
Determine the location of the parameter pack.
Definition: ExprCXX.h:4321
child_range children()
Definition: ExprCXX.h:4363
static bool classof(const Stmt *T)
Definition: ExprCXX.h:4358
SourceLocation getEndLoc() const LLVM_READONLY
Definition: ExprCXX.h:4356
static SizeOfPackExpr * CreateDeserialized(ASTContext &Context, unsigned NumPartialArgs)
Definition: ExprCXX.cpp:1706
bool isPartiallySubstituted() const
Determine whether this represents a partially-substituted sizeof... expression, such as is produced f...
Definition: ExprCXX.h:4344
const_child_range children() const
Definition: ExprCXX.h:4367
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprCXX.h:4355
ArrayRef< TemplateArgument > getPartialArguments() const
Get.
Definition: ExprCXX.h:4349
SourceLocation getOperatorLoc() const
Determine the location of the 'sizeof' keyword.
Definition: ExprCXX.h:4318
SourceLocation getRParenLoc() const
Determine the location of the right parenthesis.
Definition: ExprCXX.h:4324
NamedDecl * getPack() const
Retrieve the parameter pack.
Definition: ExprCXX.h:4327
unsigned getPackLength() const
Retrieve the length of the parameter pack.
Definition: ExprCXX.h:4333
Encodes a location in the source.
bool isValid() const
Return true if this is a valid SourceLocation object.
A trivial tuple used to represent a source range.
Stmt - This represents one statement.
Definition: Stmt.h:84
SourceLocation getEndLoc() const LLVM_READONLY
Definition: Stmt.cpp:350
StmtClass
Definition: Stmt.h:86
CXXUnresolvedConstructExprBitfields CXXUnresolvedConstructExprBits
Definition: Stmt.h:1261
LambdaExprBitfields LambdaExprBits
Definition: Stmt.h:1268
UnresolvedLookupExprBitfields UnresolvedLookupExprBits
Definition: Stmt.h:1264
SubstNonTypeTemplateParmExprBitfields SubstNonTypeTemplateParmExprBits
Definition: Stmt.h:1267
CXXNoexceptExprBitfields CXXNoexceptExprBits
Definition: Stmt.h:1266
StmtIterator child_iterator
Child Iterators: All subclasses must implement 'children' to permit easy iteration over the substatem...
Definition: Stmt.h:1449
CXXRewrittenBinaryOperatorBitfields CXXRewrittenBinaryOperatorBits
Definition: Stmt.h:1247
ExprWithCleanupsBitfields ExprWithCleanupsBits
Definition: Stmt.h:1260
StmtClass getStmtClass() const
Definition: Stmt.h:1363
CXXScalarValueInitExprBitfields CXXScalarValueInitExprBits
Definition: Stmt.h:1254
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation tokens are not useful in isolation - they are low level value objects created/interpre...
Definition: Stmt.cpp:326
OverloadExprBitfields OverloadExprBits
Definition: Stmt.h:1263
CXXConstructExprBitfields CXXConstructExprBits
Definition: Stmt.h:1259
CXXDependentScopeMemberExprBitfields CXXDependentScopeMemberExprBits
Definition: Stmt.h:1262
ConstCastIterator< Expr > ConstExprIterator
Definition: Stmt.h:1337
TypeTraitExprBitfields TypeTraitExprBits
Definition: Stmt.h:1257
CXXNewExprBitfields CXXNewExprBits
Definition: Stmt.h:1255
CXXNullPtrLiteralExprBitfields CXXNullPtrLiteralExprBits
Definition: Stmt.h:1249
CoawaitExprBitfields CoawaitBits
Definition: Stmt.h:1272
llvm::iterator_range< child_iterator > child_range
Definition: Stmt.h:1452
CXXThrowExprBitfields CXXThrowExprBits
Definition: Stmt.h:1251
ConstStmtIterator const_child_iterator
Definition: Stmt.h:1450
CXXBoolLiteralExprBitfields CXXBoolLiteralExprBits
Definition: Stmt.h:1248
CXXOperatorCallExprBitfields CXXOperatorCallExprBits
Definition: Stmt.h:1246
CXXDefaultInitExprBitfields CXXDefaultInitExprBits
Definition: Stmt.h:1253
DependentScopeDeclRefExprBitfields DependentScopeDeclRefExprBits
Definition: Stmt.h:1258
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: Stmt.cpp:338
UnresolvedMemberExprBitfields UnresolvedMemberExprBits
Definition: Stmt.h:1265
llvm::iterator_range< const_child_iterator > const_child_range
Definition: Stmt.h:1453
CXXDeleteExprBitfields CXXDeleteExprBits
Definition: Stmt.h:1256
CXXDefaultArgExprBitfields CXXDefaultArgExprBits
Definition: Stmt.h:1252
CXXThisExprBitfields CXXThisExprBits
Definition: Stmt.h:1250
CastIterator< Expr > ExprIterator
Definition: Stmt.h:1336
Represents a reference to a non-type template parameter that has been substituted with a template arg...
Definition: ExprCXX.h:4484
std::optional< unsigned > getPackIndex() const
Definition: ExprCXX.h:4532
Decl * getAssociatedDecl() const
A template-like entity which owns the whole pattern being substituted.
Definition: ExprCXX.h:4526
SourceLocation getEndLoc() const
Definition: ExprCXX.h:4520
QualType getParameterType(const ASTContext &Ctx) const
Determine the substituted type of the template parameter.
Definition: ExprCXX.cpp:1753
const_child_range children() const
Definition: ExprCXX.h:4552
unsigned getIndex() const
Returns the index of the replaced parameter in the associated declaration.
Definition: ExprCXX.h:4530
SourceLocation getNameLoc() const
Definition: ExprCXX.h:4516
NonTypeTemplateParmDecl * getParameter() const
Definition: ExprCXX.cpp:1713
SourceLocation getBeginLoc() const
Definition: ExprCXX.h:4519
SubstNonTypeTemplateParmExpr(QualType Ty, ExprValueKind ValueKind, SourceLocation Loc, Expr *Replacement, Decl *AssociatedDecl, unsigned Index, std::optional< unsigned > PackIndex, bool RefParam)
Definition: ExprCXX.h:4503
static bool classof(const Stmt *s)
Definition: ExprCXX.h:4545
Represents a reference to a non-type template parameter pack that has been substituted with a non-tem...
Definition: ExprCXX.h:4569
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprCXX.h:4615
TemplateArgument getArgumentPack() const
Retrieve the template argument pack containing the substituted template arguments.
Definition: ExprCXX.cpp:1779
SourceLocation getParameterPackLocation() const
Retrieve the location of the parameter pack name.
Definition: ExprCXX.h:4609
const_child_range children() const
Definition: ExprCXX.h:4627
NonTypeTemplateParmDecl * getParameterPack() const
Retrieve the non-type template parameter pack being substituted.
Definition: ExprCXX.cpp:1774
Decl * getAssociatedDecl() const
A template-like entity which owns the whole pattern being substituted.
Definition: ExprCXX.h:4599
static bool classof(const Stmt *T)
Definition: ExprCXX.h:4618
unsigned getIndex() const
Returns the index of the replaced parameter in the associated declaration.
Definition: ExprCXX.h:4603
SourceLocation getEndLoc() const LLVM_READONLY
Definition: ExprCXX.h:4616
A convenient class for passing around template argument information.
Definition: TemplateBase.h:632
Location wrapper for a TemplateArgument.
Definition: TemplateBase.h:524
Represents a template argument.
Definition: TemplateBase.h:61
Stores a list of template parameters for a TemplateDecl and its derived classes.
Definition: DeclTemplate.h:73
A container of type source information.
Definition: Type.h:7721
QualType getType() const
Return the type wrapped by this type source info.
Definition: Type.h:7732
A type trait used in the implementation of various C++11 and Library TR1 trait templates.
Definition: ExprCXX.h:2768
ArrayRef< TypeSourceInfo * > getArgs() const
Retrieve the argument types.
Definition: ExprCXX.h:2824
friend TrailingObjects
Definition: ExprCXX.h:2792
static TypeTraitExpr * CreateDeserialized(const ASTContext &C, unsigned NumArgs)
Definition: ExprCXX.cpp:1887
child_range children()
Definition: ExprCXX.h:2836
SourceLocation getEndLoc() const LLVM_READONLY
Definition: ExprCXX.h:2829
TypeSourceInfo * getArg(unsigned I) const
Retrieve the Ith argument.
Definition: ExprCXX.h:2818
const_child_range children() const
Definition: ExprCXX.h:2840
unsigned getNumArgs() const
Determine the number of arguments to this type trait.
Definition: ExprCXX.h:2815
bool getValue() const
Definition: ExprCXX.h:2809
TypeTrait getTrait() const
Determine which type trait this expression uses.
Definition: ExprCXX.h:2805
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprCXX.h:2828
static bool classof(const Stmt *T)
Definition: ExprCXX.h:2831
The base class of the type hierarchy.
Definition: Type.h:1829
const T * castAs() const
Member-template castAs<specific type>.
Definition: Type.h:8607
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
Definition: Type.h:2695
A reference to a name which we were able to look up during parsing but could not resolve to a specifi...
Definition: ExprCXX.h:3203
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprCXX.h:3280
const CXXRecordDecl * getNamingClass() const
Definition: ExprCXX.h:3278
CXXRecordDecl * getNamingClass()
Gets the 'naming class' (in the sense of C++0x [class.access.base]p5) of the lookup.
Definition: ExprCXX.h:3277
SourceLocation getEndLoc() const LLVM_READONLY
Definition: ExprCXX.h:3286
child_range children()
Definition: ExprCXX.h:3292
static UnresolvedLookupExpr * CreateEmpty(const ASTContext &Context, unsigned NumResults, bool HasTemplateKWAndArgsInfo, unsigned NumTemplateArgs)
Definition: ExprCXX.cpp:455
static bool classof(const Stmt *T)
Definition: ExprCXX.h:3300
bool requiresADL() const
True if this declaration should be extended by argument-dependent lookup.
Definition: ExprCXX.h:3272
const_child_range children() const
Definition: ExprCXX.h:3296
Represents a C++ member access expression for which lookup produced a set of overloaded functions.
Definition: ExprCXX.h:3943
SourceLocation getEndLoc() const LLVM_READONLY
Definition: ExprCXX.h:4069
DeclarationName getMemberName() const
Retrieve the name of the member that this expression refers to.
Definition: ExprCXX.h:4051
QualType getBaseType() const
Definition: ExprCXX.h:4025
bool isArrow() const
Determine whether this member expression used the '->' operator; otherwise, it used the '.
Definition: ExprCXX.h:4035
SourceLocation getOperatorLoc() const
Retrieve the location of the '->' or '.' operator.
Definition: ExprCXX.h:4038
bool hasUnresolvedUsing() const
Determine whether the lookup results contain an unresolved using declaration.
Definition: ExprCXX.h:4029
const Expr * getBase() const
Definition: ExprCXX.h:4020
const CXXRecordDecl * getNamingClass() const
Definition: ExprCXX.h:4042
child_range children()
Definition: ExprCXX.h:4080
SourceLocation getExprLoc() const LLVM_READONLY
Return the preferred location (the member name) for the arrow when diagnosing a problem with this exp...
Definition: ExprCXX.h:4059
Expr * getBase()
Retrieve the base object of this member expressions, e.g., the x in x.m.
Definition: ExprCXX.h:4016
static bool classof(const Stmt *T)
Definition: ExprCXX.h:4075
CXXRecordDecl * getNamingClass()
Retrieve the naming class of this lookup.
Definition: ExprCXX.cpp:1667
bool isImplicitAccess() const
True if this is an implicit access, i.e., one in which the member being accessed was not written in t...
Definition: ExprCXX.cpp:1629
const DeclarationNameInfo & getMemberNameInfo() const
Retrieve the full name info for the member that this expression refers to.
Definition: ExprCXX.h:4048
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprCXX.h:4061
static UnresolvedMemberExpr * CreateEmpty(const ASTContext &Context, unsigned NumResults, bool HasTemplateKWAndArgsInfo, unsigned NumTemplateArgs)
Definition: ExprCXX.cpp:1655
const_child_range children() const
Definition: ExprCXX.h:4086
SourceLocation getMemberLoc() const
Retrieve the location of the name of the member that this expression refers to.
Definition: ExprCXX.h:4055
UnresolvedSetIterator iterator
Definition: UnresolvedSet.h:81
The iterator over UnresolvedSets.
Definition: UnresolvedSet.h:35
A call to a literal operator (C++11 [over.literal]) written as a user-defined literal (C++11 [lit....
Definition: ExprCXX.h:637
LiteralOperatorKind getLiteralOperatorKind() const
Returns the kind of literal operator invocation which this expression represents.
Definition: ExprCXX.cpp:979
const Expr * getCookedLiteral() const
Definition: ExprCXX.h:693
const IdentifierInfo * getUDSuffix() const
Returns the ud-suffix specified for this literal.
Definition: ExprCXX.cpp:1008
static UserDefinedLiteral * CreateEmpty(const ASTContext &Ctx, unsigned NumArgs, bool HasFPOptions, EmptyShell Empty)
Definition: ExprCXX.cpp:966
SourceLocation getEndLoc() const
Definition: ExprCXX.h:703
Expr * getCookedLiteral()
If this is not a raw user-defined literal, get the underlying cooked literal (representing the litera...
Definition: ExprCXX.cpp:1000
SourceLocation getBeginLoc() const
Definition: ExprCXX.h:697
SourceLocation getUDSuffixLoc() const
Returns the location of a ud-suffix in the expression.
Definition: ExprCXX.h:709
LiteralOperatorKind
The kind of literal operator which is invoked.
Definition: ExprCXX.h:665
@ LOK_String
operator "" X (const CharT *, size_t)
Definition: ExprCXX.h:679
@ LOK_Raw
Raw form: operator "" X (const char *)
Definition: ExprCXX.h:667
@ LOK_Floating
operator "" X (long double)
Definition: ExprCXX.h:676
@ LOK_Integer
operator "" X (unsigned long long)
Definition: ExprCXX.h:673
@ LOK_Template
Raw form: operator "" X<cs...> ()
Definition: ExprCXX.h:670
@ LOK_Character
operator "" X (CharT)
Definition: ExprCXX.h:682
static bool classof(const Stmt *S)
Definition: ExprCXX.h:714
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
Definition: Decl.h:667
Represents a variable declaration or definition.
Definition: Decl.h:879
const internal::VariadicAllOfMatcher< Decl > decl
Matches declarations.
const internal::VariadicDynCastAllOfMatcher< Stmt, CastExpr > castExpr
Matches any cast nodes of Clang's AST.
The JSON file list parser is used to communicate input to InstallAPI.
@ Create
'create' clause, allowed on Compute and Combined constructs, plus 'data', 'enter data',...
OverloadedOperatorKind
Enumeration specifying the different kinds of C++ overloaded operators.
Definition: OperatorKinds.h:21
ArrayTypeTrait
Names for the array type traits.
Definition: TypeTraits.h:42
@ ATT_Last
Definition: TypeTraits.h:45
CanThrowResult
Possible results from evaluation of a noexcept expression.
CXXConstructionKind
Definition: ExprCXX.h:1538
ExprObjectKind
A further classification of the kind of object referenced by an l-value or x-value.
Definition: Specifiers.h:149
@ OK_Ordinary
An ordinary object is located at an address in memory.
Definition: Specifiers.h:151
BinaryOperatorKind
ExprDependence computeDependence(FullExpr *E)
StorageDuration
The storage duration for an object (per C++ [basic.stc]).
Definition: Specifiers.h:327
@ SD_FullExpression
Full-expression storage duration (for temporaries).
Definition: Specifiers.h:328
@ Result
The result type of a method or function.
CastKind
CastKind - The kind of operation required for a conversion.
LambdaCaptureDefault
The default, if any, capture method for a lambda expression.
Definition: Lambda.h:22
ExprValueKind
The categorization of expression values, currently following the C++11 scheme.
Definition: Specifiers.h:132
@ VK_PRValue
A pr-value expression (in the C++11 taxonomy) produces a temporary value.
Definition: Specifiers.h:135
@ VK_LValue
An l-value expression is a reference to an object with independent storage.
Definition: Specifiers.h:139
const FunctionProtoType * T
@ None
The alignment was not explicit in code.
@ Class
The "class" keyword introduces the elaborated-type-specifier.
TypeTrait
Names for traits that operate specifically on types.
Definition: TypeTraits.h:21
CXXNewInitializationStyle
Definition: ExprCXX.h:2226
@ Parens
New-expression has a C++98 paren-delimited initializer.
@ Braces
New-expression has a C++11 list-initializer.
#define false
Definition: stdbool.h:26
Represents an explicit template argument list in C++, e.g., the "<int>" in "sort<int>".
Definition: TemplateBase.h:728
SourceLocation LAngleLoc
The source location of the left angle bracket ('<').
Definition: TemplateBase.h:730
void copyInto(const TemplateArgumentLoc *ArgArray, TemplateArgumentListInfo &List) const
unsigned NumTemplateArgs
The number of template arguments in TemplateArgs.
Definition: TemplateBase.h:742
SourceLocation RAngleLoc
The source location of the right angle bracket ('>').
Definition: TemplateBase.h:733
SourceLocation TemplateKWLoc
The source location of the template keyword; this is used as part of the representation of qualified ...
Definition: TemplateBase.h:739
const Expr * RHS
The original right-hand side.
Definition: ExprCXX.h:310
const Expr * InnerBinOp
The inner == or <=> operator expression.
Definition: ExprCXX.h:312
BinaryOperatorKind Opcode
The original opcode, prior to rewriting.
Definition: ExprCXX.h:306
const Expr * LHS
The original left-hand side.
Definition: ExprCXX.h:308
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspon...
SourceLocation getLoc() const
getLoc - Returns the main location of the declaration name.
DeclarationName getName() const
getName - Returns the embedded declaration name.
SourceLocation getBeginLoc() const
getBeginLoc - Retrieve the location of the first token.
SourceLocation getEndLoc() const LLVM_READONLY
Iterator for iterating over Stmt * arrays that contain only T *.
Definition: Stmt.h:1321
A placeholder type used to construct an empty shell of a type, that will be filled in later (e....
Definition: Stmt.h:1303