clang 19.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,
108 EmptyShell Empty);
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,
496 ExprValueKind VK, CastKind Kind, Expr *Op,
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,
541 ExprValueKind VK, CastKind Kind,
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
571 explicit CXXConstCastExpr(EmptyShell Empty)
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
609 explicit CXXAddrspaceCastExpr(EmptyShell Empty)
610 : CXXNamedCastExpr(CXXAddrspaceCastExprClass, Empty, 0,
611 /*HasFPFeatures*/ false) {}
612
613public:
614 friend class CastExpr;
616
617 static CXXAddrspaceCastExpr *
618 Create(const ASTContext &Context, QualType T, ExprValueKind VK, CastKind Kind,
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,
662 EmptyShell Empty);
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
865 CXXTypeidExpr(EmptyShell Empty, bool isExpr)
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
924/// A member reference to an MSPropertyDecl.
925///
926/// This expression always has pseudo-object type, and therefore it is
927/// typically not encountered in a fully-typechecked expression except
928/// within the syntactic form of a PseudoObjectExpr.
929class MSPropertyRefExpr : public Expr {
930 Expr *BaseExpr;
931 MSPropertyDecl *TheDecl;
932 SourceLocation MemberLoc;
933 bool IsArrow;
934 NestedNameSpecifierLoc QualifierLoc;
935
936public:
937 friend class ASTStmtReader;
938
940 QualType ty, ExprValueKind VK,
941 NestedNameSpecifierLoc qualifierLoc, SourceLocation nameLoc)
942 : Expr(MSPropertyRefExprClass, ty, VK, OK_Ordinary), BaseExpr(baseExpr),
943 TheDecl(decl), MemberLoc(nameLoc), IsArrow(isArrow),
944 QualifierLoc(qualifierLoc) {
946 }
947
948 MSPropertyRefExpr(EmptyShell Empty) : Expr(MSPropertyRefExprClass, Empty) {}
949
950 SourceRange getSourceRange() const LLVM_READONLY {
951 return SourceRange(getBeginLoc(), getEndLoc());
952 }
953
954 bool isImplicitAccess() const {
956 }
957
959 if (!isImplicitAccess())
960 return BaseExpr->getBeginLoc();
961 else if (QualifierLoc)
962 return QualifierLoc.getBeginLoc();
963 else
964 return MemberLoc;
965 }
966
968
970 return child_range((Stmt**)&BaseExpr, (Stmt**)&BaseExpr + 1);
971 }
972
974 auto Children = const_cast<MSPropertyRefExpr *>(this)->children();
975 return const_child_range(Children.begin(), Children.end());
976 }
977
978 static bool classof(const Stmt *T) {
979 return T->getStmtClass() == MSPropertyRefExprClass;
980 }
981
982 Expr *getBaseExpr() const { return BaseExpr; }
983 MSPropertyDecl *getPropertyDecl() const { return TheDecl; }
984 bool isArrow() const { return IsArrow; }
985 SourceLocation getMemberLoc() const { return MemberLoc; }
986 NestedNameSpecifierLoc getQualifierLoc() const { return QualifierLoc; }
987};
988
989/// MS property subscript expression.
990/// MSVC supports 'property' attribute and allows to apply it to the
991/// declaration of an empty array in a class or structure definition.
992/// For example:
993/// \code
994/// __declspec(property(get=GetX, put=PutX)) int x[];
995/// \endcode
996/// The above statement indicates that x[] can be used with one or more array
997/// indices. In this case, i=p->x[a][b] will be turned into i=p->GetX(a, b), and
998/// p->x[a][b] = i will be turned into p->PutX(a, b, i).
999/// This is a syntactic pseudo-object expression.
1001 friend class ASTStmtReader;
1002
1003 enum { BASE_EXPR, IDX_EXPR, NUM_SUBEXPRS = 2 };
1004
1005 Stmt *SubExprs[NUM_SUBEXPRS];
1006 SourceLocation RBracketLoc;
1007
1008 void setBase(Expr *Base) { SubExprs[BASE_EXPR] = Base; }
1009 void setIdx(Expr *Idx) { SubExprs[IDX_EXPR] = Idx; }
1010
1011public:
1013 ExprObjectKind OK, SourceLocation RBracketLoc)
1014 : Expr(MSPropertySubscriptExprClass, Ty, VK, OK),
1015 RBracketLoc(RBracketLoc) {
1016 SubExprs[BASE_EXPR] = Base;
1017 SubExprs[IDX_EXPR] = Idx;
1019 }
1020
1021 /// Create an empty array subscript expression.
1023 : Expr(MSPropertySubscriptExprClass, Shell) {}
1024
1025 Expr *getBase() { return cast<Expr>(SubExprs[BASE_EXPR]); }
1026 const Expr *getBase() const { return cast<Expr>(SubExprs[BASE_EXPR]); }
1027
1028 Expr *getIdx() { return cast<Expr>(SubExprs[IDX_EXPR]); }
1029 const Expr *getIdx() const { return cast<Expr>(SubExprs[IDX_EXPR]); }
1030
1031 SourceLocation getBeginLoc() const LLVM_READONLY {
1032 return getBase()->getBeginLoc();
1033 }
1034
1035 SourceLocation getEndLoc() const LLVM_READONLY { return RBracketLoc; }
1036
1037 SourceLocation getRBracketLoc() const { return RBracketLoc; }
1038 void setRBracketLoc(SourceLocation L) { RBracketLoc = L; }
1039
1040 SourceLocation getExprLoc() const LLVM_READONLY {
1041 return getBase()->getExprLoc();
1042 }
1043
1044 static bool classof(const Stmt *T) {
1045 return T->getStmtClass() == MSPropertySubscriptExprClass;
1046 }
1047
1048 // Iterators
1050 return child_range(&SubExprs[0], &SubExprs[0] + NUM_SUBEXPRS);
1051 }
1052
1054 return const_child_range(&SubExprs[0], &SubExprs[0] + NUM_SUBEXPRS);
1055 }
1056};
1057
1058/// A Microsoft C++ @c __uuidof expression, which gets
1059/// the _GUID that corresponds to the supplied type or expression.
1060///
1061/// This represents code like @c __uuidof(COMTYPE) or @c __uuidof(*comPtr)
1062class CXXUuidofExpr : public Expr {
1063 friend class ASTStmtReader;
1064
1065private:
1066 llvm::PointerUnion<Stmt *, TypeSourceInfo *> Operand;
1067 MSGuidDecl *Guid;
1069
1070public:
1072 SourceRange R)
1073 : Expr(CXXUuidofExprClass, Ty, VK_LValue, OK_Ordinary), Operand(Operand),
1074 Guid(Guid), Range(R) {
1076 }
1077
1079 : Expr(CXXUuidofExprClass, Ty, VK_LValue, OK_Ordinary), Operand(Operand),
1080 Guid(Guid), Range(R) {
1082 }
1083
1084 CXXUuidofExpr(EmptyShell Empty, bool isExpr)
1085 : Expr(CXXUuidofExprClass, Empty) {
1086 if (isExpr)
1087 Operand = (Expr*)nullptr;
1088 else
1089 Operand = (TypeSourceInfo*)nullptr;
1090 }
1091
1092 bool isTypeOperand() const { return Operand.is<TypeSourceInfo *>(); }
1093
1094 /// Retrieves the type operand of this __uuidof() expression after
1095 /// various required adjustments (removing reference types, cv-qualifiers).
1096 QualType getTypeOperand(ASTContext &Context) const;
1097
1098 /// Retrieve source information for the type operand.
1100 assert(isTypeOperand() && "Cannot call getTypeOperand for __uuidof(expr)");
1101 return Operand.get<TypeSourceInfo *>();
1102 }
1104 assert(!isTypeOperand() && "Cannot call getExprOperand for __uuidof(type)");
1105 return static_cast<Expr*>(Operand.get<Stmt *>());
1106 }
1107
1108 MSGuidDecl *getGuidDecl() const { return Guid; }
1109
1110 SourceLocation getBeginLoc() const LLVM_READONLY { return Range.getBegin(); }
1111 SourceLocation getEndLoc() const LLVM_READONLY { return Range.getEnd(); }
1112 SourceRange getSourceRange() const LLVM_READONLY { return Range; }
1114
1115 static bool classof(const Stmt *T) {
1116 return T->getStmtClass() == CXXUuidofExprClass;
1117 }
1118
1119 // Iterators
1121 if (isTypeOperand())
1123 auto **begin = reinterpret_cast<Stmt **>(&Operand);
1124 return child_range(begin, begin + 1);
1125 }
1126
1128 if (isTypeOperand())
1130 auto **begin =
1131 reinterpret_cast<Stmt **>(&const_cast<CXXUuidofExpr *>(this)->Operand);
1132 return const_child_range(begin, begin + 1);
1133 }
1134};
1135
1136/// Represents the \c this expression in C++.
1137///
1138/// This is a pointer to the object on which the current member function is
1139/// executing (C++ [expr.prim]p3). Example:
1140///
1141/// \code
1142/// class Foo {
1143/// public:
1144/// void bar();
1145/// void test() { this->bar(); }
1146/// };
1147/// \endcode
1148class CXXThisExpr : public Expr {
1149 CXXThisExpr(SourceLocation L, QualType Ty, bool IsImplicit, ExprValueKind VK)
1150 : Expr(CXXThisExprClass, Ty, VK, OK_Ordinary) {
1151 CXXThisExprBits.IsImplicit = IsImplicit;
1152 CXXThisExprBits.CapturedByCopyInLambdaWithExplicitObjectParameter = false;
1153 CXXThisExprBits.Loc = L;
1155 }
1156
1157 CXXThisExpr(EmptyShell Empty) : Expr(CXXThisExprClass, Empty) {}
1158
1159public:
1160 static CXXThisExpr *Create(const ASTContext &Ctx, SourceLocation L,
1161 QualType Ty, bool IsImplicit);
1162
1163 static CXXThisExpr *CreateEmpty(const ASTContext &Ctx);
1164
1167
1170
1171 bool isImplicit() const { return CXXThisExprBits.IsImplicit; }
1172 void setImplicit(bool I) { CXXThisExprBits.IsImplicit = I; }
1173
1175 return CXXThisExprBits.CapturedByCopyInLambdaWithExplicitObjectParameter;
1176 }
1177
1179 CXXThisExprBits.CapturedByCopyInLambdaWithExplicitObjectParameter = Set;
1181 }
1182
1183 static bool classof(const Stmt *T) {
1184 return T->getStmtClass() == CXXThisExprClass;
1185 }
1186
1187 // Iterators
1190 }
1191
1194 }
1195};
1196
1197/// A C++ throw-expression (C++ [except.throw]).
1198///
1199/// This handles 'throw' (for re-throwing the current exception) and
1200/// 'throw' assignment-expression. When assignment-expression isn't
1201/// present, Op will be null.
1202class CXXThrowExpr : public Expr {
1203 friend class ASTStmtReader;
1204
1205 /// The optional expression in the throw statement.
1206 Stmt *Operand;
1207
1208public:
1209 // \p Ty is the void type which is used as the result type of the
1210 // expression. The \p Loc is the location of the throw keyword.
1211 // \p Operand is the expression in the throw statement, and can be
1212 // null if not present.
1214 bool IsThrownVariableInScope)
1215 : Expr(CXXThrowExprClass, Ty, VK_PRValue, OK_Ordinary), Operand(Operand) {
1216 CXXThrowExprBits.ThrowLoc = Loc;
1217 CXXThrowExprBits.IsThrownVariableInScope = IsThrownVariableInScope;
1219 }
1220 CXXThrowExpr(EmptyShell Empty) : Expr(CXXThrowExprClass, Empty) {}
1221
1222 const Expr *getSubExpr() const { return cast_or_null<Expr>(Operand); }
1223 Expr *getSubExpr() { return cast_or_null<Expr>(Operand); }
1224
1225 SourceLocation getThrowLoc() const { return CXXThrowExprBits.ThrowLoc; }
1226
1227 /// Determines whether the variable thrown by this expression (if any!)
1228 /// is within the innermost try block.
1229 ///
1230 /// This information is required to determine whether the NRVO can apply to
1231 /// this variable.
1233 return CXXThrowExprBits.IsThrownVariableInScope;
1234 }
1235
1237 SourceLocation getEndLoc() const LLVM_READONLY {
1238 if (!getSubExpr())
1239 return getThrowLoc();
1240 return getSubExpr()->getEndLoc();
1241 }
1242
1243 static bool classof(const Stmt *T) {
1244 return T->getStmtClass() == CXXThrowExprClass;
1245 }
1246
1247 // Iterators
1249 return child_range(&Operand, Operand ? &Operand + 1 : &Operand);
1250 }
1251
1253 return const_child_range(&Operand, Operand ? &Operand + 1 : &Operand);
1254 }
1255};
1256
1257/// A default argument (C++ [dcl.fct.default]).
1258///
1259/// This wraps up a function call argument that was created from the
1260/// corresponding parameter's default argument, when the call did not
1261/// explicitly supply arguments for all of the parameters.
1263 : public Expr,
1264 private llvm::TrailingObjects<CXXDefaultArgExpr, Expr *> {
1265 friend class ASTStmtReader;
1266 friend class ASTReader;
1267 friend TrailingObjects;
1268
1269 /// The parameter whose default is being used.
1270 ParmVarDecl *Param;
1271
1272 /// The context where the default argument expression was used.
1273 DeclContext *UsedContext;
1274
1276 Expr *RewrittenExpr, DeclContext *UsedContext)
1277 : Expr(SC,
1278 Param->hasUnparsedDefaultArg()
1279 ? Param->getType().getNonReferenceType()
1280 : Param->getDefaultArg()->getType(),
1281 Param->getDefaultArg()->getValueKind(),
1282 Param->getDefaultArg()->getObjectKind()),
1283 Param(Param), UsedContext(UsedContext) {
1285 CXXDefaultArgExprBits.HasRewrittenInit = RewrittenExpr != nullptr;
1286 if (RewrittenExpr)
1287 *getTrailingObjects<Expr *>() = RewrittenExpr;
1289 }
1290
1291 CXXDefaultArgExpr(EmptyShell Empty, bool HasRewrittenInit)
1292 : Expr(CXXDefaultArgExprClass, Empty) {
1293 CXXDefaultArgExprBits.HasRewrittenInit = HasRewrittenInit;
1294 }
1295
1296public:
1297 static CXXDefaultArgExpr *CreateEmpty(const ASTContext &C,
1298 bool HasRewrittenInit);
1299
1300 // \p Param is the parameter whose default argument is used by this
1301 // expression.
1302 static CXXDefaultArgExpr *Create(const ASTContext &C, SourceLocation Loc,
1303 ParmVarDecl *Param, Expr *RewrittenExpr,
1304 DeclContext *UsedContext);
1305 // Retrieve the parameter that the argument was created from.
1306 const ParmVarDecl *getParam() const { return Param; }
1307 ParmVarDecl *getParam() { return Param; }
1308
1309 bool hasRewrittenInit() const {
1310 return CXXDefaultArgExprBits.HasRewrittenInit;
1311 }
1312
1313 // Retrieve the argument to the function call.
1314 Expr *getExpr();
1315 const Expr *getExpr() const {
1316 return const_cast<CXXDefaultArgExpr *>(this)->getExpr();
1317 }
1318
1320 return hasRewrittenInit() ? *getTrailingObjects<Expr *>() : nullptr;
1321 }
1322
1323 const Expr *getRewrittenExpr() const {
1324 return const_cast<CXXDefaultArgExpr *>(this)->getRewrittenExpr();
1325 }
1326
1327 // Retrieve the rewritten init expression (for an init expression containing
1328 // immediate calls) with the top level FullExpr and ConstantExpr stripped off.
1331 return const_cast<CXXDefaultArgExpr *>(this)->getAdjustedRewrittenExpr();
1332 }
1333
1334 const DeclContext *getUsedContext() const { return UsedContext; }
1335 DeclContext *getUsedContext() { return UsedContext; }
1336
1337 /// Retrieve the location where this default argument was actually used.
1339
1340 /// Default argument expressions have no representation in the
1341 /// source, so they have an empty source range.
1344
1346
1347 static bool classof(const Stmt *T) {
1348 return T->getStmtClass() == CXXDefaultArgExprClass;
1349 }
1350
1351 // Iterators
1354 }
1355
1358 }
1359};
1360
1361/// A use of a default initializer in a constructor or in aggregate
1362/// initialization.
1363///
1364/// This wraps a use of a C++ default initializer (technically,
1365/// a brace-or-equal-initializer for a non-static data member) when it
1366/// is implicitly used in a mem-initializer-list in a constructor
1367/// (C++11 [class.base.init]p8) or in aggregate initialization
1368/// (C++1y [dcl.init.aggr]p7).
1370 : public Expr,
1371 private llvm::TrailingObjects<CXXDefaultInitExpr, Expr *> {
1372
1373 friend class ASTStmtReader;
1374 friend class ASTReader;
1375 friend TrailingObjects;
1376 /// The field whose default is being used.
1377 FieldDecl *Field;
1378
1379 /// The context where the default initializer expression was used.
1380 DeclContext *UsedContext;
1381
1383 FieldDecl *Field, QualType Ty, DeclContext *UsedContext,
1384 Expr *RewrittenInitExpr);
1385
1386 CXXDefaultInitExpr(EmptyShell Empty, bool HasRewrittenInit)
1387 : Expr(CXXDefaultInitExprClass, Empty) {
1388 CXXDefaultInitExprBits.HasRewrittenInit = HasRewrittenInit;
1389 }
1390
1391public:
1393 bool HasRewrittenInit);
1394 /// \p Field is the non-static data member whose default initializer is used
1395 /// by this expression.
1397 FieldDecl *Field, DeclContext *UsedContext,
1398 Expr *RewrittenInitExpr);
1399
1400 bool hasRewrittenInit() const {
1401 return CXXDefaultInitExprBits.HasRewrittenInit;
1402 }
1403
1404 /// Get the field whose initializer will be used.
1405 FieldDecl *getField() { return Field; }
1406 const FieldDecl *getField() const { return Field; }
1407
1408 /// Get the initialization expression that will be used.
1409 Expr *getExpr();
1410 const Expr *getExpr() const {
1411 return const_cast<CXXDefaultInitExpr *>(this)->getExpr();
1412 }
1413
1414 /// Retrieve the initializing expression with evaluated immediate calls, if
1415 /// any.
1416 const Expr *getRewrittenExpr() const {
1417 assert(hasRewrittenInit() && "expected a rewritten init expression");
1418 return *getTrailingObjects<Expr *>();
1419 }
1420
1421 /// Retrieve the initializing expression with evaluated immediate calls, if
1422 /// any.
1424 assert(hasRewrittenInit() && "expected a rewritten init expression");
1425 return *getTrailingObjects<Expr *>();
1426 }
1427
1428 const DeclContext *getUsedContext() const { return UsedContext; }
1429 DeclContext *getUsedContext() { return UsedContext; }
1430
1431 /// Retrieve the location where this default initializer expression was
1432 /// actually used.
1434
1437
1438 static bool classof(const Stmt *T) {
1439 return T->getStmtClass() == CXXDefaultInitExprClass;
1440 }
1441
1442 // Iterators
1445 }
1446
1449 }
1450};
1451
1452/// Represents a C++ temporary.
1454 /// The destructor that needs to be called.
1455 const CXXDestructorDecl *Destructor;
1456
1457 explicit CXXTemporary(const CXXDestructorDecl *destructor)
1458 : Destructor(destructor) {}
1459
1460public:
1461 static CXXTemporary *Create(const ASTContext &C,
1462 const CXXDestructorDecl *Destructor);
1463
1464 const CXXDestructorDecl *getDestructor() const { return Destructor; }
1465
1467 Destructor = Dtor;
1468 }
1469};
1470
1471/// Represents binding an expression to a temporary.
1472///
1473/// This ensures the destructor is called for the temporary. It should only be
1474/// needed for non-POD, non-trivially destructable class types. For example:
1475///
1476/// \code
1477/// struct S {
1478/// S() { } // User defined constructor makes S non-POD.
1479/// ~S() { } // User defined destructor makes it non-trivial.
1480/// };
1481/// void test() {
1482/// const S &s_ref = S(); // Requires a CXXBindTemporaryExpr.
1483/// }
1484/// \endcode
1485///
1486/// Destructor might be null if destructor declaration is not valid.
1488 CXXTemporary *Temp = nullptr;
1489 Stmt *SubExpr = nullptr;
1490
1491 CXXBindTemporaryExpr(CXXTemporary *temp, Expr *SubExpr)
1492 : Expr(CXXBindTemporaryExprClass, SubExpr->getType(), VK_PRValue,
1493 OK_Ordinary),
1494 Temp(temp), SubExpr(SubExpr) {
1496 }
1497
1498public:
1500 : Expr(CXXBindTemporaryExprClass, Empty) {}
1501
1502 static CXXBindTemporaryExpr *Create(const ASTContext &C, CXXTemporary *Temp,
1503 Expr* SubExpr);
1504
1505 CXXTemporary *getTemporary() { return Temp; }
1506 const CXXTemporary *getTemporary() const { return Temp; }
1507 void setTemporary(CXXTemporary *T) { Temp = T; }
1508
1509 const Expr *getSubExpr() const { return cast<Expr>(SubExpr); }
1510 Expr *getSubExpr() { return cast<Expr>(SubExpr); }
1511 void setSubExpr(Expr *E) { SubExpr = E; }
1512
1513 SourceLocation getBeginLoc() const LLVM_READONLY {
1514 return SubExpr->getBeginLoc();
1515 }
1516
1517 SourceLocation getEndLoc() const LLVM_READONLY {
1518 return SubExpr->getEndLoc();
1519 }
1520
1521 // Implement isa/cast/dyncast/etc.
1522 static bool classof(const Stmt *T) {
1523 return T->getStmtClass() == CXXBindTemporaryExprClass;
1524 }
1525
1526 // Iterators
1527 child_range children() { return child_range(&SubExpr, &SubExpr + 1); }
1528
1530 return const_child_range(&SubExpr, &SubExpr + 1);
1531 }
1532};
1533
1535 Complete,
1539};
1540
1541/// Represents a call to a C++ constructor.
1542class CXXConstructExpr : public Expr {
1543 friend class ASTStmtReader;
1544
1545 /// A pointer to the constructor which will be ultimately called.
1546 CXXConstructorDecl *Constructor;
1547
1548 SourceRange ParenOrBraceRange;
1549
1550 /// The number of arguments.
1551 unsigned NumArgs;
1552
1553 // We would like to stash the arguments of the constructor call after
1554 // CXXConstructExpr. However CXXConstructExpr is used as a base class of
1555 // CXXTemporaryObjectExpr which makes the use of llvm::TrailingObjects
1556 // impossible.
1557 //
1558 // Instead we manually stash the trailing object after the full object
1559 // containing CXXConstructExpr (that is either CXXConstructExpr or
1560 // CXXTemporaryObjectExpr).
1561 //
1562 // The trailing objects are:
1563 //
1564 // * An array of getNumArgs() "Stmt *" for the arguments of the
1565 // constructor call.
1566
1567 /// Return a pointer to the start of the trailing arguments.
1568 /// Defined just after CXXTemporaryObjectExpr.
1569 inline Stmt **getTrailingArgs();
1570 const Stmt *const *getTrailingArgs() const {
1571 return const_cast<CXXConstructExpr *>(this)->getTrailingArgs();
1572 }
1573
1574protected:
1575 /// Build a C++ construction expression.
1577 CXXConstructorDecl *Ctor, bool Elidable,
1578 ArrayRef<Expr *> Args, bool HadMultipleCandidates,
1579 bool ListInitialization, bool StdInitListInitialization,
1580 bool ZeroInitialization, CXXConstructionKind ConstructKind,
1581 SourceRange ParenOrBraceRange);
1582
1583 /// Build an empty C++ construction expression.
1584 CXXConstructExpr(StmtClass SC, EmptyShell Empty, unsigned NumArgs);
1585
1586 /// Return the size in bytes of the trailing objects. Used by
1587 /// CXXTemporaryObjectExpr to allocate the right amount of storage.
1588 static unsigned sizeOfTrailingObjects(unsigned NumArgs) {
1589 return NumArgs * sizeof(Stmt *);
1590 }
1591
1592public:
1593 /// Create a C++ construction expression.
1594 static CXXConstructExpr *
1596 CXXConstructorDecl *Ctor, bool Elidable, ArrayRef<Expr *> Args,
1597 bool HadMultipleCandidates, bool ListInitialization,
1598 bool StdInitListInitialization, bool ZeroInitialization,
1599 CXXConstructionKind ConstructKind, SourceRange ParenOrBraceRange);
1600
1601 /// Create an empty C++ construction expression.
1602 static CXXConstructExpr *CreateEmpty(const ASTContext &Ctx, unsigned NumArgs);
1603
1604 /// Get the constructor that this expression will (ultimately) call.
1605 CXXConstructorDecl *getConstructor() const { return Constructor; }
1606
1609
1610 /// Whether this construction is elidable.
1611 bool isElidable() const { return CXXConstructExprBits.Elidable; }
1612 void setElidable(bool E) { CXXConstructExprBits.Elidable = E; }
1613
1614 /// Whether the referred constructor was resolved from
1615 /// an overloaded set having size greater than 1.
1617 return CXXConstructExprBits.HadMultipleCandidates;
1618 }
1620 CXXConstructExprBits.HadMultipleCandidates = V;
1621 }
1622
1623 /// Whether this constructor call was written as list-initialization.
1625 return CXXConstructExprBits.ListInitialization;
1626 }
1628 CXXConstructExprBits.ListInitialization = V;
1629 }
1630
1631 /// Whether this constructor call was written as list-initialization,
1632 /// but was interpreted as forming a std::initializer_list<T> from the list
1633 /// and passing that as a single constructor argument.
1634 /// See C++11 [over.match.list]p1 bullet 1.
1636 return CXXConstructExprBits.StdInitListInitialization;
1637 }
1639 CXXConstructExprBits.StdInitListInitialization = V;
1640 }
1641
1642 /// Whether this construction first requires
1643 /// zero-initialization before the initializer is called.
1645 return CXXConstructExprBits.ZeroInitialization;
1646 }
1647 void setRequiresZeroInitialization(bool ZeroInit) {
1648 CXXConstructExprBits.ZeroInitialization = ZeroInit;
1649 }
1650
1651 /// Determine whether this constructor is actually constructing
1652 /// a base class (rather than a complete object).
1654 return static_cast<CXXConstructionKind>(
1655 CXXConstructExprBits.ConstructionKind);
1656 }
1658 CXXConstructExprBits.ConstructionKind = llvm::to_underlying(CK);
1659 }
1660
1663 using arg_range = llvm::iterator_range<arg_iterator>;
1664 using const_arg_range = llvm::iterator_range<const_arg_iterator>;
1665
1668 return const_arg_range(arg_begin(), arg_end());
1669 }
1670
1671 arg_iterator arg_begin() { return getTrailingArgs(); }
1673 const_arg_iterator arg_begin() const { return getTrailingArgs(); }
1675
1676 Expr **getArgs() { return reinterpret_cast<Expr **>(getTrailingArgs()); }
1677 const Expr *const *getArgs() const {
1678 return reinterpret_cast<const Expr *const *>(getTrailingArgs());
1679 }
1680
1681 /// Return the number of arguments to the constructor call.
1682 unsigned getNumArgs() const { return NumArgs; }
1683
1684 /// Return the specified argument.
1685 Expr *getArg(unsigned Arg) {
1686 assert(Arg < getNumArgs() && "Arg access out of range!");
1687 return getArgs()[Arg];
1688 }
1689 const Expr *getArg(unsigned Arg) const {
1690 assert(Arg < getNumArgs() && "Arg access out of range!");
1691 return getArgs()[Arg];
1692 }
1693
1694 /// Set the specified argument.
1695 void setArg(unsigned Arg, Expr *ArgExpr) {
1696 assert(Arg < getNumArgs() && "Arg access out of range!");
1697 getArgs()[Arg] = ArgExpr;
1698 }
1699
1701 return CXXConstructExprBits.IsImmediateEscalating;
1702 }
1703
1705 CXXConstructExprBits.IsImmediateEscalating = Set;
1706 }
1707
1708 SourceLocation getBeginLoc() const LLVM_READONLY;
1709 SourceLocation getEndLoc() const LLVM_READONLY;
1710 SourceRange getParenOrBraceRange() const { return ParenOrBraceRange; }
1711 void setParenOrBraceRange(SourceRange Range) { ParenOrBraceRange = Range; }
1712
1713 static bool classof(const Stmt *T) {
1714 return T->getStmtClass() == CXXConstructExprClass ||
1715 T->getStmtClass() == CXXTemporaryObjectExprClass;
1716 }
1717
1718 // Iterators
1720 return child_range(getTrailingArgs(), getTrailingArgs() + getNumArgs());
1721 }
1722
1724 auto Children = const_cast<CXXConstructExpr *>(this)->children();
1725 return const_child_range(Children.begin(), Children.end());
1726 }
1727};
1728
1729/// Represents a call to an inherited base class constructor from an
1730/// inheriting constructor. This call implicitly forwards the arguments from
1731/// the enclosing context (an inheriting constructor) to the specified inherited
1732/// base class constructor.
1734private:
1735 CXXConstructorDecl *Constructor = nullptr;
1736
1737 /// The location of the using declaration.
1739
1740 /// Whether this is the construction of a virtual base.
1741 LLVM_PREFERRED_TYPE(bool)
1742 unsigned ConstructsVirtualBase : 1;
1743
1744 /// Whether the constructor is inherited from a virtual base class of the
1745 /// class that we construct.
1746 LLVM_PREFERRED_TYPE(bool)
1747 unsigned InheritedFromVirtualBase : 1;
1748
1749public:
1750 friend class ASTStmtReader;
1751
1752 /// Construct a C++ inheriting construction expression.
1754 CXXConstructorDecl *Ctor, bool ConstructsVirtualBase,
1755 bool InheritedFromVirtualBase)
1756 : Expr(CXXInheritedCtorInitExprClass, T, VK_PRValue, OK_Ordinary),
1757 Constructor(Ctor), Loc(Loc),
1758 ConstructsVirtualBase(ConstructsVirtualBase),
1759 InheritedFromVirtualBase(InheritedFromVirtualBase) {
1760 assert(!T->isDependentType());
1761 setDependence(ExprDependence::None);
1762 }
1763
1764 /// Construct an empty C++ inheriting construction expression.
1766 : Expr(CXXInheritedCtorInitExprClass, Empty),
1767 ConstructsVirtualBase(false), InheritedFromVirtualBase(false) {}
1768
1769 /// Get the constructor that this expression will call.
1770 CXXConstructorDecl *getConstructor() const { return Constructor; }
1771
1772 /// Determine whether this constructor is actually constructing
1773 /// a base class (rather than a complete object).
1774 bool constructsVBase() const { return ConstructsVirtualBase; }
1776 return ConstructsVirtualBase ? CXXConstructionKind::VirtualBase
1778 }
1779
1780 /// Determine whether the inherited constructor is inherited from a
1781 /// virtual base of the object we construct. If so, we are not responsible
1782 /// for calling the inherited constructor (the complete object constructor
1783 /// does that), and so we don't need to pass any arguments.
1784 bool inheritedFromVBase() const { return InheritedFromVirtualBase; }
1785
1786 SourceLocation getLocation() const LLVM_READONLY { return Loc; }
1787 SourceLocation getBeginLoc() const LLVM_READONLY { return Loc; }
1788 SourceLocation getEndLoc() const LLVM_READONLY { return Loc; }
1789
1790 static bool classof(const Stmt *T) {
1791 return T->getStmtClass() == CXXInheritedCtorInitExprClass;
1792 }
1793
1796 }
1797
1800 }
1801};
1802
1803/// Represents an explicit C++ type conversion that uses "functional"
1804/// notation (C++ [expr.type.conv]).
1805///
1806/// Example:
1807/// \code
1808/// x = int(0.5);
1809/// \endcode
1811 : public ExplicitCastExpr,
1812 private llvm::TrailingObjects<CXXFunctionalCastExpr, CXXBaseSpecifier *,
1813 FPOptionsOverride> {
1814 SourceLocation LParenLoc;
1815 SourceLocation RParenLoc;
1816
1818 TypeSourceInfo *writtenTy, CastKind kind,
1819 Expr *castExpr, unsigned pathSize,
1820 FPOptionsOverride FPO, SourceLocation lParenLoc,
1821 SourceLocation rParenLoc)
1822 : ExplicitCastExpr(CXXFunctionalCastExprClass, ty, VK, kind, castExpr,
1823 pathSize, FPO.requiresTrailingStorage(), writtenTy),
1824 LParenLoc(lParenLoc), RParenLoc(rParenLoc) {
1825 if (hasStoredFPFeatures())
1826 *getTrailingFPFeatures() = FPO;
1827 }
1828
1829 explicit CXXFunctionalCastExpr(EmptyShell Shell, unsigned PathSize,
1830 bool HasFPFeatures)
1831 : ExplicitCastExpr(CXXFunctionalCastExprClass, Shell, PathSize,
1832 HasFPFeatures) {}
1833
1834 unsigned numTrailingObjects(OverloadToken<CXXBaseSpecifier *>) const {
1835 return path_size();
1836 }
1837
1838public:
1839 friend class CastExpr;
1841
1842 static CXXFunctionalCastExpr *
1843 Create(const ASTContext &Context, QualType T, ExprValueKind VK,
1844 TypeSourceInfo *Written, CastKind Kind, Expr *Op,
1845 const CXXCastPath *Path, FPOptionsOverride FPO, SourceLocation LPLoc,
1846 SourceLocation RPLoc);
1847 static CXXFunctionalCastExpr *
1848 CreateEmpty(const ASTContext &Context, unsigned PathSize, bool HasFPFeatures);
1849
1850 SourceLocation getLParenLoc() const { return LParenLoc; }
1851 void setLParenLoc(SourceLocation L) { LParenLoc = L; }
1852 SourceLocation getRParenLoc() const { return RParenLoc; }
1853 void setRParenLoc(SourceLocation L) { RParenLoc = L; }
1854
1855 /// Determine whether this expression models list-initialization.
1856 bool isListInitialization() const { return LParenLoc.isInvalid(); }
1857
1858 SourceLocation getBeginLoc() const LLVM_READONLY;
1859 SourceLocation getEndLoc() const LLVM_READONLY;
1860
1861 static bool classof(const Stmt *T) {
1862 return T->getStmtClass() == CXXFunctionalCastExprClass;
1863 }
1864};
1865
1866/// Represents a C++ functional cast expression that builds a
1867/// temporary object.
1868///
1869/// This expression type represents a C++ "functional" cast
1870/// (C++[expr.type.conv]) with N != 1 arguments that invokes a
1871/// constructor to build a temporary object. With N == 1 arguments the
1872/// functional cast expression will be represented by CXXFunctionalCastExpr.
1873/// Example:
1874/// \code
1875/// struct X { X(int, float); }
1876///
1877/// X create_X() {
1878/// return X(1, 3.14f); // creates a CXXTemporaryObjectExpr
1879/// };
1880/// \endcode
1882 friend class ASTStmtReader;
1883
1884 // CXXTemporaryObjectExpr has some trailing objects belonging
1885 // to CXXConstructExpr. See the comment inside CXXConstructExpr
1886 // for more details.
1887
1888 TypeSourceInfo *TSI;
1889
1892 SourceRange ParenOrBraceRange,
1893 bool HadMultipleCandidates, bool ListInitialization,
1894 bool StdInitListInitialization,
1895 bool ZeroInitialization);
1896
1897 CXXTemporaryObjectExpr(EmptyShell Empty, unsigned NumArgs);
1898
1899public:
1900 static CXXTemporaryObjectExpr *
1901 Create(const ASTContext &Ctx, CXXConstructorDecl *Cons, QualType Ty,
1903 SourceRange ParenOrBraceRange, bool HadMultipleCandidates,
1904 bool ListInitialization, bool StdInitListInitialization,
1905 bool ZeroInitialization);
1906
1908 unsigned NumArgs);
1909
1910 TypeSourceInfo *getTypeSourceInfo() const { return TSI; }
1911
1912 SourceLocation getBeginLoc() const LLVM_READONLY;
1913 SourceLocation getEndLoc() const LLVM_READONLY;
1914
1915 static bool classof(const Stmt *T) {
1916 return T->getStmtClass() == CXXTemporaryObjectExprClass;
1917 }
1918};
1919
1920Stmt **CXXConstructExpr::getTrailingArgs() {
1921 if (auto *E = dyn_cast<CXXTemporaryObjectExpr>(this))
1922 return reinterpret_cast<Stmt **>(E + 1);
1923 assert((getStmtClass() == CXXConstructExprClass) &&
1924 "Unexpected class deriving from CXXConstructExpr!");
1925 return reinterpret_cast<Stmt **>(this + 1);
1926}
1927
1928/// A C++ lambda expression, which produces a function object
1929/// (of unspecified type) that can be invoked later.
1930///
1931/// Example:
1932/// \code
1933/// void low_pass_filter(std::vector<double> &values, double cutoff) {
1934/// values.erase(std::remove_if(values.begin(), values.end(),
1935/// [=](double value) { return value > cutoff; });
1936/// }
1937/// \endcode
1938///
1939/// C++11 lambda expressions can capture local variables, either by copying
1940/// the values of those local variables at the time the function
1941/// object is constructed (not when it is called!) or by holding a
1942/// reference to the local variable. These captures can occur either
1943/// implicitly or can be written explicitly between the square
1944/// brackets ([...]) that start the lambda expression.
1945///
1946/// C++1y introduces a new form of "capture" called an init-capture that
1947/// includes an initializing expression (rather than capturing a variable),
1948/// and which can never occur implicitly.
1949class LambdaExpr final : public Expr,
1950 private llvm::TrailingObjects<LambdaExpr, Stmt *> {
1951 // LambdaExpr has some data stored in LambdaExprBits.
1952
1953 /// The source range that covers the lambda introducer ([...]).
1954 SourceRange IntroducerRange;
1955
1956 /// The source location of this lambda's capture-default ('=' or '&').
1957 SourceLocation CaptureDefaultLoc;
1958
1959 /// The location of the closing brace ('}') that completes
1960 /// the lambda.
1961 ///
1962 /// The location of the brace is also available by looking up the
1963 /// function call operator in the lambda class. However, it is
1964 /// stored here to improve the performance of getSourceRange(), and
1965 /// to avoid having to deserialize the function call operator from a
1966 /// module file just to determine the source range.
1967 SourceLocation ClosingBrace;
1968
1969 /// Construct a lambda expression.
1970 LambdaExpr(QualType T, SourceRange IntroducerRange,
1971 LambdaCaptureDefault CaptureDefault,
1972 SourceLocation CaptureDefaultLoc, bool ExplicitParams,
1973 bool ExplicitResultType, ArrayRef<Expr *> CaptureInits,
1974 SourceLocation ClosingBrace, bool ContainsUnexpandedParameterPack);
1975
1976 /// Construct an empty lambda expression.
1977 LambdaExpr(EmptyShell Empty, unsigned NumCaptures);
1978
1979 Stmt **getStoredStmts() { return getTrailingObjects<Stmt *>(); }
1980 Stmt *const *getStoredStmts() const { return getTrailingObjects<Stmt *>(); }
1981
1982 void initBodyIfNeeded() const;
1983
1984public:
1985 friend class ASTStmtReader;
1986 friend class ASTStmtWriter;
1988
1989 /// Construct a new lambda expression.
1990 static LambdaExpr *
1991 Create(const ASTContext &C, CXXRecordDecl *Class, SourceRange IntroducerRange,
1992 LambdaCaptureDefault CaptureDefault, SourceLocation CaptureDefaultLoc,
1993 bool ExplicitParams, bool ExplicitResultType,
1994 ArrayRef<Expr *> CaptureInits, SourceLocation ClosingBrace,
1995 bool ContainsUnexpandedParameterPack);
1996
1997 /// Construct a new lambda expression that will be deserialized from
1998 /// an external source.
2000 unsigned NumCaptures);
2001
2002 /// Determine the default capture kind for this lambda.
2004 return static_cast<LambdaCaptureDefault>(LambdaExprBits.CaptureDefault);
2005 }
2006
2007 /// Retrieve the location of this lambda's capture-default, if any.
2008 SourceLocation getCaptureDefaultLoc() const { return CaptureDefaultLoc; }
2009
2010 /// Determine whether one of this lambda's captures is an init-capture.
2011 bool isInitCapture(const LambdaCapture *Capture) const;
2012
2013 /// An iterator that walks over the captures of the lambda,
2014 /// both implicit and explicit.
2016
2017 /// An iterator over a range of lambda captures.
2018 using capture_range = llvm::iterator_range<capture_iterator>;
2019
2020 /// Retrieve this lambda's captures.
2021 capture_range captures() const;
2022
2023 /// Retrieve an iterator pointing to the first lambda capture.
2025
2026 /// Retrieve an iterator pointing past the end of the
2027 /// sequence of lambda captures.
2029
2030 /// Determine the number of captures in this lambda.
2031 unsigned capture_size() const { return LambdaExprBits.NumCaptures; }
2032
2033 /// Retrieve this lambda's explicit captures.
2035
2036 /// Retrieve an iterator pointing to the first explicit
2037 /// lambda capture.
2039
2040 /// Retrieve an iterator pointing past the end of the sequence of
2041 /// explicit lambda captures.
2043
2044 /// Retrieve this lambda's implicit captures.
2046
2047 /// Retrieve an iterator pointing to the first implicit
2048 /// lambda capture.
2050
2051 /// Retrieve an iterator pointing past the end of the sequence of
2052 /// implicit lambda captures.
2054
2055 /// Iterator that walks over the capture initialization
2056 /// arguments.
2058
2059 /// Const iterator that walks over the capture initialization
2060 /// arguments.
2061 /// FIXME: This interface is prone to being used incorrectly.
2063
2064 /// Retrieve the initialization expressions for this lambda's captures.
2065 llvm::iterator_range<capture_init_iterator> capture_inits() {
2066 return llvm::make_range(capture_init_begin(), capture_init_end());
2067 }
2068
2069 /// Retrieve the initialization expressions for this lambda's captures.
2070 llvm::iterator_range<const_capture_init_iterator> capture_inits() const {
2071 return llvm::make_range(capture_init_begin(), capture_init_end());
2072 }
2073
2074 /// Retrieve the first initialization argument for this
2075 /// lambda expression (which initializes the first capture field).
2077 return reinterpret_cast<Expr **>(getStoredStmts());
2078 }
2079
2080 /// Retrieve the first initialization argument for this
2081 /// lambda expression (which initializes the first capture field).
2083 return reinterpret_cast<Expr *const *>(getStoredStmts());
2084 }
2085
2086 /// Retrieve the iterator pointing one past the last
2087 /// initialization argument for this lambda expression.
2089 return capture_init_begin() + capture_size();
2090 }
2091
2092 /// Retrieve the iterator pointing one past the last
2093 /// initialization argument for this lambda expression.
2095 return capture_init_begin() + capture_size();
2096 }
2097
2098 /// Retrieve the source range covering the lambda introducer,
2099 /// which contains the explicit capture list surrounded by square
2100 /// brackets ([...]).
2101 SourceRange getIntroducerRange() const { return IntroducerRange; }
2102
2103 /// Retrieve the class that corresponds to the lambda.
2104 ///
2105 /// This is the "closure type" (C++1y [expr.prim.lambda]), and stores the
2106 /// captures in its fields and provides the various operations permitted
2107 /// on a lambda (copying, calling).
2109
2110 /// Retrieve the function call operator associated with this
2111 /// lambda expression.
2113
2114 /// Retrieve the function template call operator associated with this
2115 /// lambda expression.
2117
2118 /// If this is a generic lambda expression, retrieve the template
2119 /// parameter list associated with it, or else return null.
2121
2122 /// Get the template parameters were explicitly specified (as opposed to being
2123 /// invented by use of an auto parameter).
2125
2126 /// Get the trailing requires clause, if any.
2128
2129 /// Whether this is a generic lambda.
2131
2132 /// Retrieve the body of the lambda. This will be most of the time
2133 /// a \p CompoundStmt, but can also be \p CoroutineBodyStmt wrapping
2134 /// a \p CompoundStmt. Note that unlike functions, lambda-expressions
2135 /// cannot have a function-try-block.
2136 Stmt *getBody() const;
2137
2138 /// Retrieve the \p CompoundStmt representing the body of the lambda.
2139 /// This is a convenience function for callers who do not need
2140 /// to handle node(s) which may wrap a \p CompoundStmt.
2141 const CompoundStmt *getCompoundStmtBody() const;
2143 const auto *ConstThis = this;
2144 return const_cast<CompoundStmt *>(ConstThis->getCompoundStmtBody());
2145 }
2146
2147 /// Determine whether the lambda is mutable, meaning that any
2148 /// captures values can be modified.
2149 bool isMutable() const;
2150
2151 /// Determine whether this lambda has an explicit parameter
2152 /// list vs. an implicit (empty) parameter list.
2153 bool hasExplicitParameters() const { return LambdaExprBits.ExplicitParams; }
2154
2155 /// Whether this lambda had its result type explicitly specified.
2157 return LambdaExprBits.ExplicitResultType;
2158 }
2159
2160 static bool classof(const Stmt *T) {
2161 return T->getStmtClass() == LambdaExprClass;
2162 }
2163
2164 SourceLocation getBeginLoc() const LLVM_READONLY {
2165 return IntroducerRange.getBegin();
2166 }
2167
2168 SourceLocation getEndLoc() const LLVM_READONLY { return ClosingBrace; }
2169
2170 /// Includes the captures and the body of the lambda.
2173};
2174
2175/// An expression "T()" which creates a value-initialized rvalue of type
2176/// T, which is a non-class type. See (C++98 [5.2.3p2]).
2178 friend class ASTStmtReader;
2179
2181
2182public:
2183 /// Create an explicitly-written scalar-value initialization
2184 /// expression.
2186 SourceLocation RParenLoc)
2187 : Expr(CXXScalarValueInitExprClass, Type, VK_PRValue, OK_Ordinary),
2189 CXXScalarValueInitExprBits.RParenLoc = RParenLoc;
2191 }
2192
2194 : Expr(CXXScalarValueInitExprClass, Shell) {}
2195
2197 return TypeInfo;
2198 }
2199
2201 return CXXScalarValueInitExprBits.RParenLoc;
2202 }
2203
2204 SourceLocation getBeginLoc() const LLVM_READONLY;
2206
2207 static bool classof(const Stmt *T) {
2208 return T->getStmtClass() == CXXScalarValueInitExprClass;
2209 }
2210
2211 // Iterators
2214 }
2215
2218 }
2219};
2220
2222 /// New-expression has no initializer as written.
2223 None,
2224
2225 /// New-expression has a C++98 paren-delimited initializer.
2226 Parens,
2227
2228 /// New-expression has a C++11 list-initializer.
2229 Braces
2230};
2231
2232/// Represents a new-expression for memory allocation and constructor
2233/// calls, e.g: "new CXXNewExpr(foo)".
2234class CXXNewExpr final
2235 : public Expr,
2236 private llvm::TrailingObjects<CXXNewExpr, Stmt *, SourceRange> {
2237 friend class ASTStmtReader;
2238 friend class ASTStmtWriter;
2239 friend TrailingObjects;
2240
2241 /// Points to the allocation function used.
2242 FunctionDecl *OperatorNew;
2243
2244 /// Points to the deallocation function used in case of error. May be null.
2245 FunctionDecl *OperatorDelete;
2246
2247 /// The allocated type-source information, as written in the source.
2248 TypeSourceInfo *AllocatedTypeInfo;
2249
2250 /// Range of the entire new expression.
2252
2253 /// Source-range of a paren-delimited initializer.
2254 SourceRange DirectInitRange;
2255
2256 // CXXNewExpr is followed by several optional trailing objects.
2257 // They are in order:
2258 //
2259 // * An optional "Stmt *" for the array size expression.
2260 // Present if and ony if isArray().
2261 //
2262 // * An optional "Stmt *" for the init expression.
2263 // Present if and only if hasInitializer().
2264 //
2265 // * An array of getNumPlacementArgs() "Stmt *" for the placement new
2266 // arguments, if any.
2267 //
2268 // * An optional SourceRange for the range covering the parenthesized type-id
2269 // if the allocated type was expressed as a parenthesized type-id.
2270 // Present if and only if isParenTypeId().
2271 unsigned arraySizeOffset() const { return 0; }
2272 unsigned initExprOffset() const { return arraySizeOffset() + isArray(); }
2273 unsigned placementNewArgsOffset() const {
2274 return initExprOffset() + hasInitializer();
2275 }
2276
2277 unsigned numTrailingObjects(OverloadToken<Stmt *>) const {
2279 }
2280
2281 unsigned numTrailingObjects(OverloadToken<SourceRange>) const {
2282 return isParenTypeId();
2283 }
2284
2285 /// Build a c++ new expression.
2286 CXXNewExpr(bool IsGlobalNew, FunctionDecl *OperatorNew,
2287 FunctionDecl *OperatorDelete, bool ShouldPassAlignment,
2288 bool UsualArrayDeleteWantsSize, ArrayRef<Expr *> PlacementArgs,
2289 SourceRange TypeIdParens, std::optional<Expr *> ArraySize,
2290 CXXNewInitializationStyle InitializationStyle, Expr *Initializer,
2291 QualType Ty, TypeSourceInfo *AllocatedTypeInfo, SourceRange Range,
2292 SourceRange DirectInitRange);
2293
2294 /// Build an empty c++ new expression.
2295 CXXNewExpr(EmptyShell Empty, bool IsArray, unsigned NumPlacementArgs,
2296 bool IsParenTypeId);
2297
2298public:
2299 /// Create a c++ new expression.
2300 static CXXNewExpr *
2301 Create(const ASTContext &Ctx, bool IsGlobalNew, FunctionDecl *OperatorNew,
2302 FunctionDecl *OperatorDelete, bool ShouldPassAlignment,
2303 bool UsualArrayDeleteWantsSize, ArrayRef<Expr *> PlacementArgs,
2304 SourceRange TypeIdParens, std::optional<Expr *> ArraySize,
2305 CXXNewInitializationStyle InitializationStyle, Expr *Initializer,
2306 QualType Ty, TypeSourceInfo *AllocatedTypeInfo, SourceRange Range,
2307 SourceRange DirectInitRange);
2308
2309 /// Create an empty c++ new expression.
2310 static CXXNewExpr *CreateEmpty(const ASTContext &Ctx, bool IsArray,
2311 bool HasInit, unsigned NumPlacementArgs,
2312 bool IsParenTypeId);
2313
2315 return getType()->castAs<PointerType>()->getPointeeType();
2316 }
2317
2319 return AllocatedTypeInfo;
2320 }
2321
2322 /// True if the allocation result needs to be null-checked.
2323 ///
2324 /// C++11 [expr.new]p13:
2325 /// If the allocation function returns null, initialization shall
2326 /// not be done, the deallocation function shall not be called,
2327 /// and the value of the new-expression shall be null.
2328 ///
2329 /// C++ DR1748:
2330 /// If the allocation function is a reserved placement allocation
2331 /// function that returns null, the behavior is undefined.
2332 ///
2333 /// An allocation function is not allowed to return null unless it
2334 /// has a non-throwing exception-specification. The '03 rule is
2335 /// identical except that the definition of a non-throwing
2336 /// exception specification is just "is it throw()?".
2337 bool shouldNullCheckAllocation() const;
2338
2339 FunctionDecl *getOperatorNew() const { return OperatorNew; }
2340 void setOperatorNew(FunctionDecl *D) { OperatorNew = D; }
2341 FunctionDecl *getOperatorDelete() const { return OperatorDelete; }
2342 void setOperatorDelete(FunctionDecl *D) { OperatorDelete = D; }
2343
2344 bool isArray() const { return CXXNewExprBits.IsArray; }
2345
2346 /// This might return std::nullopt even if isArray() returns true,
2347 /// since there might not be an array size expression.
2348 /// If the result is not std::nullopt, it will never wrap a nullptr.
2349 std::optional<Expr *> getArraySize() {
2350 if (!isArray())
2351 return std::nullopt;
2352
2353 if (auto *Result =
2354 cast_or_null<Expr>(getTrailingObjects<Stmt *>()[arraySizeOffset()]))
2355 return Result;
2356
2357 return std::nullopt;
2358 }
2359
2360 /// This might return std::nullopt even if isArray() returns true,
2361 /// since there might not be an array size expression.
2362 /// If the result is not std::nullopt, it will never wrap a nullptr.
2363 std::optional<const Expr *> getArraySize() const {
2364 if (!isArray())
2365 return std::nullopt;
2366
2367 if (auto *Result =
2368 cast_or_null<Expr>(getTrailingObjects<Stmt *>()[arraySizeOffset()]))
2369 return Result;
2370
2371 return std::nullopt;
2372 }
2373
2374 unsigned getNumPlacementArgs() const {
2375 return CXXNewExprBits.NumPlacementArgs;
2376 }
2377
2379 return reinterpret_cast<Expr **>(getTrailingObjects<Stmt *>() +
2380 placementNewArgsOffset());
2381 }
2382
2383 Expr *getPlacementArg(unsigned I) {
2384 assert((I < getNumPlacementArgs()) && "Index out of range!");
2385 return getPlacementArgs()[I];
2386 }
2387 const Expr *getPlacementArg(unsigned I) const {
2388 return const_cast<CXXNewExpr *>(this)->getPlacementArg(I);
2389 }
2390
2391 bool isParenTypeId() const { return CXXNewExprBits.IsParenTypeId; }
2393 return isParenTypeId() ? getTrailingObjects<SourceRange>()[0]
2394 : SourceRange();
2395 }
2396
2397 bool isGlobalNew() const { return CXXNewExprBits.IsGlobalNew; }
2398
2399 /// Whether this new-expression has any initializer at all.
2400 bool hasInitializer() const { return CXXNewExprBits.HasInitializer; }
2401
2402 /// The kind of initializer this new-expression has.
2404 return static_cast<CXXNewInitializationStyle>(
2405 CXXNewExprBits.StoredInitializationStyle);
2406 }
2407
2408 /// The initializer of this new-expression.
2410 return hasInitializer()
2411 ? cast<Expr>(getTrailingObjects<Stmt *>()[initExprOffset()])
2412 : nullptr;
2413 }
2414 const Expr *getInitializer() const {
2415 return hasInitializer()
2416 ? cast<Expr>(getTrailingObjects<Stmt *>()[initExprOffset()])
2417 : nullptr;
2418 }
2419
2420 /// Returns the CXXConstructExpr from this new-expression, or null.
2422 return dyn_cast_or_null<CXXConstructExpr>(getInitializer());
2423 }
2424
2425 /// Indicates whether the required alignment should be implicitly passed to
2426 /// the allocation function.
2427 bool passAlignment() const { return CXXNewExprBits.ShouldPassAlignment; }
2428
2429 /// Answers whether the usual array deallocation function for the
2430 /// allocated type expects the size of the allocation as a
2431 /// parameter.
2433 return CXXNewExprBits.UsualArrayDeleteWantsSize;
2434 }
2435
2438
2439 llvm::iterator_range<arg_iterator> placement_arguments() {
2440 return llvm::make_range(placement_arg_begin(), placement_arg_end());
2441 }
2442
2443 llvm::iterator_range<const_arg_iterator> placement_arguments() const {
2444 return llvm::make_range(placement_arg_begin(), placement_arg_end());
2445 }
2446
2448 return getTrailingObjects<Stmt *>() + placementNewArgsOffset();
2449 }
2452 }
2454 return getTrailingObjects<Stmt *>() + placementNewArgsOffset();
2455 }
2458 }
2459
2461
2462 raw_arg_iterator raw_arg_begin() { return getTrailingObjects<Stmt *>(); }
2464 return raw_arg_begin() + numTrailingObjects(OverloadToken<Stmt *>());
2465 }
2467 return getTrailingObjects<Stmt *>();
2468 }
2470 return raw_arg_begin() + numTrailingObjects(OverloadToken<Stmt *>());
2471 }
2472
2473 SourceLocation getBeginLoc() const { return Range.getBegin(); }
2474 SourceLocation getEndLoc() const { return Range.getEnd(); }
2475
2476 SourceRange getDirectInitRange() const { return DirectInitRange; }
2478
2479 static bool classof(const Stmt *T) {
2480 return T->getStmtClass() == CXXNewExprClass;
2481 }
2482
2483 // Iterators
2485
2487 return const_child_range(const_cast<CXXNewExpr *>(this)->children());
2488 }
2489};
2490
2491/// Represents a \c delete expression for memory deallocation and
2492/// destructor calls, e.g. "delete[] pArray".
2493class CXXDeleteExpr : public Expr {
2494 friend class ASTStmtReader;
2495
2496 /// Points to the operator delete overload that is used. Could be a member.
2497 FunctionDecl *OperatorDelete = nullptr;
2498
2499 /// The pointer expression to be deleted.
2500 Stmt *Argument = nullptr;
2501
2502public:
2503 CXXDeleteExpr(QualType Ty, bool GlobalDelete, bool ArrayForm,
2504 bool ArrayFormAsWritten, bool UsualArrayDeleteWantsSize,
2505 FunctionDecl *OperatorDelete, Expr *Arg, SourceLocation Loc)
2506 : Expr(CXXDeleteExprClass, Ty, VK_PRValue, OK_Ordinary),
2507 OperatorDelete(OperatorDelete), Argument(Arg) {
2508 CXXDeleteExprBits.GlobalDelete = GlobalDelete;
2509 CXXDeleteExprBits.ArrayForm = ArrayForm;
2510 CXXDeleteExprBits.ArrayFormAsWritten = ArrayFormAsWritten;
2511 CXXDeleteExprBits.UsualArrayDeleteWantsSize = UsualArrayDeleteWantsSize;
2512 CXXDeleteExprBits.Loc = Loc;
2514 }
2515
2516 explicit CXXDeleteExpr(EmptyShell Shell) : Expr(CXXDeleteExprClass, Shell) {}
2517
2518 bool isGlobalDelete() const { return CXXDeleteExprBits.GlobalDelete; }
2519 bool isArrayForm() const { return CXXDeleteExprBits.ArrayForm; }
2521 return CXXDeleteExprBits.ArrayFormAsWritten;
2522 }
2523
2524 /// Answers whether the usual array deallocation function for the
2525 /// allocated type expects the size of the allocation as a
2526 /// parameter. This can be true even if the actual deallocation
2527 /// function that we're using doesn't want a size.
2529 return CXXDeleteExprBits.UsualArrayDeleteWantsSize;
2530 }
2531
2532 FunctionDecl *getOperatorDelete() const { return OperatorDelete; }
2533
2534 Expr *getArgument() { return cast<Expr>(Argument); }
2535 const Expr *getArgument() const { return cast<Expr>(Argument); }
2536
2537 /// Retrieve the type being destroyed.
2538 ///
2539 /// If the type being destroyed is a dependent type which may or may not
2540 /// be a pointer, return an invalid type.
2541 QualType getDestroyedType() const;
2542
2544 SourceLocation getEndLoc() const LLVM_READONLY {
2545 return Argument->getEndLoc();
2546 }
2547
2548 static bool classof(const Stmt *T) {
2549 return T->getStmtClass() == CXXDeleteExprClass;
2550 }
2551
2552 // Iterators
2553 child_range children() { return child_range(&Argument, &Argument + 1); }
2554
2556 return const_child_range(&Argument, &Argument + 1);
2557 }
2558};
2559
2560/// Stores the type being destroyed by a pseudo-destructor expression.
2562 /// Either the type source information or the name of the type, if
2563 /// it couldn't be resolved due to type-dependence.
2564 llvm::PointerUnion<TypeSourceInfo *, const IdentifierInfo *> Type;
2565
2566 /// The starting source location of the pseudo-destructor type.
2567 SourceLocation Location;
2568
2569public:
2571
2573 : Type(II), Location(Loc) {}
2574
2576
2578 return Type.dyn_cast<TypeSourceInfo *>();
2579 }
2580
2582 return Type.dyn_cast<const IdentifierInfo *>();
2583 }
2584
2585 SourceLocation getLocation() const { return Location; }
2586};
2587
2588/// Represents a C++ pseudo-destructor (C++ [expr.pseudo]).
2589///
2590/// A pseudo-destructor is an expression that looks like a member access to a
2591/// destructor of a scalar type, except that scalar types don't have
2592/// destructors. For example:
2593///
2594/// \code
2595/// typedef int T;
2596/// void f(int *p) {
2597/// p->T::~T();
2598/// }
2599/// \endcode
2600///
2601/// Pseudo-destructors typically occur when instantiating templates such as:
2602///
2603/// \code
2604/// template<typename T>
2605/// void destroy(T* ptr) {
2606/// ptr->T::~T();
2607/// }
2608/// \endcode
2609///
2610/// for scalar types. A pseudo-destructor expression has no run-time semantics
2611/// beyond evaluating the base expression.
2613 friend class ASTStmtReader;
2614
2615 /// The base expression (that is being destroyed).
2616 Stmt *Base = nullptr;
2617
2618 /// Whether the operator was an arrow ('->'); otherwise, it was a
2619 /// period ('.').
2620 LLVM_PREFERRED_TYPE(bool)
2621 bool IsArrow : 1;
2622
2623 /// The location of the '.' or '->' operator.
2624 SourceLocation OperatorLoc;
2625
2626 /// The nested-name-specifier that follows the operator, if present.
2627 NestedNameSpecifierLoc QualifierLoc;
2628
2629 /// The type that precedes the '::' in a qualified pseudo-destructor
2630 /// expression.
2631 TypeSourceInfo *ScopeType = nullptr;
2632
2633 /// The location of the '::' in a qualified pseudo-destructor
2634 /// expression.
2635 SourceLocation ColonColonLoc;
2636
2637 /// The location of the '~'.
2638 SourceLocation TildeLoc;
2639
2640 /// The type being destroyed, or its name if we were unable to
2641 /// resolve the name.
2642 PseudoDestructorTypeStorage DestroyedType;
2643
2644public:
2645 CXXPseudoDestructorExpr(const ASTContext &Context,
2646 Expr *Base, bool isArrow, SourceLocation OperatorLoc,
2647 NestedNameSpecifierLoc QualifierLoc,
2648 TypeSourceInfo *ScopeType,
2649 SourceLocation ColonColonLoc,
2650 SourceLocation TildeLoc,
2651 PseudoDestructorTypeStorage DestroyedType);
2652
2654 : Expr(CXXPseudoDestructorExprClass, Shell), IsArrow(false) {}
2655
2656 Expr *getBase() const { return cast<Expr>(Base); }
2657
2658 /// Determines whether this member expression actually had
2659 /// a C++ nested-name-specifier prior to the name of the member, e.g.,
2660 /// x->Base::foo.
2661 bool hasQualifier() const { return QualifierLoc.hasQualifier(); }
2662
2663 /// Retrieves the nested-name-specifier that qualifies the type name,
2664 /// with source-location information.
2665 NestedNameSpecifierLoc getQualifierLoc() const { return QualifierLoc; }
2666
2667 /// If the member name was qualified, retrieves the
2668 /// nested-name-specifier that precedes the member name. Otherwise, returns
2669 /// null.
2671 return QualifierLoc.getNestedNameSpecifier();
2672 }
2673
2674 /// Determine whether this pseudo-destructor expression was written
2675 /// using an '->' (otherwise, it used a '.').
2676 bool isArrow() const { return IsArrow; }
2677
2678 /// Retrieve the location of the '.' or '->' operator.
2679 SourceLocation getOperatorLoc() const { return OperatorLoc; }
2680
2681 /// Retrieve the scope type in a qualified pseudo-destructor
2682 /// expression.
2683 ///
2684 /// Pseudo-destructor expressions can have extra qualification within them
2685 /// that is not part of the nested-name-specifier, e.g., \c p->T::~T().
2686 /// Here, if the object type of the expression is (or may be) a scalar type,
2687 /// \p T may also be a scalar type and, therefore, cannot be part of a
2688 /// nested-name-specifier. It is stored as the "scope type" of the pseudo-
2689 /// destructor expression.
2690 TypeSourceInfo *getScopeTypeInfo() const { return ScopeType; }
2691
2692 /// Retrieve the location of the '::' in a qualified pseudo-destructor
2693 /// expression.
2694 SourceLocation getColonColonLoc() const { return ColonColonLoc; }
2695
2696 /// Retrieve the location of the '~'.
2697 SourceLocation getTildeLoc() const { return TildeLoc; }
2698
2699 /// Retrieve the source location information for the type
2700 /// being destroyed.
2701 ///
2702 /// This type-source information is available for non-dependent
2703 /// pseudo-destructor expressions and some dependent pseudo-destructor
2704 /// expressions. Returns null if we only have the identifier for a
2705 /// dependent pseudo-destructor expression.
2707 return DestroyedType.getTypeSourceInfo();
2708 }
2709
2710 /// In a dependent pseudo-destructor expression for which we do not
2711 /// have full type information on the destroyed type, provides the name
2712 /// of the destroyed type.
2714 return DestroyedType.getIdentifier();
2715 }
2716
2717 /// Retrieve the type being destroyed.
2718 QualType getDestroyedType() const;
2719
2720 /// Retrieve the starting location of the type being destroyed.
2722 return DestroyedType.getLocation();
2723 }
2724
2725 /// Set the name of destroyed type for a dependent pseudo-destructor
2726 /// expression.
2728 DestroyedType = PseudoDestructorTypeStorage(II, Loc);
2729 }
2730
2731 /// Set the destroyed type.
2733 DestroyedType = PseudoDestructorTypeStorage(Info);
2734 }
2735
2736 SourceLocation getBeginLoc() const LLVM_READONLY {
2737 return Base->getBeginLoc();
2738 }
2739 SourceLocation getEndLoc() const LLVM_READONLY;
2740
2741 static bool classof(const Stmt *T) {
2742 return T->getStmtClass() == CXXPseudoDestructorExprClass;
2743 }
2744
2745 // Iterators
2747
2749 return const_child_range(&Base, &Base + 1);
2750 }
2751};
2752
2753/// A type trait used in the implementation of various C++11 and
2754/// Library TR1 trait templates.
2755///
2756/// \code
2757/// __is_pod(int) == true
2758/// __is_enum(std::string) == false
2759/// __is_trivially_constructible(vector<int>, int*, int*)
2760/// \endcode
2761class TypeTraitExpr final
2762 : public Expr,
2763 private llvm::TrailingObjects<TypeTraitExpr, TypeSourceInfo *> {
2764 /// The location of the type trait keyword.
2766
2767 /// The location of the closing parenthesis.
2768 SourceLocation RParenLoc;
2769
2770 // Note: The TypeSourceInfos for the arguments are allocated after the
2771 // TypeTraitExpr.
2772
2775 SourceLocation RParenLoc,
2776 bool Value);
2777
2778 TypeTraitExpr(EmptyShell Empty) : Expr(TypeTraitExprClass, Empty) {}
2779
2780 size_t numTrailingObjects(OverloadToken<TypeSourceInfo *>) const {
2781 return getNumArgs();
2782 }
2783
2784public:
2785 friend class ASTStmtReader;
2786 friend class ASTStmtWriter;
2788
2789 /// Create a new type trait expression.
2790 static TypeTraitExpr *Create(const ASTContext &C, QualType T,
2793 SourceLocation RParenLoc,
2794 bool Value);
2795
2797 unsigned NumArgs);
2798
2799 /// Determine which type trait this expression uses.
2801 return static_cast<TypeTrait>(TypeTraitExprBits.Kind);
2802 }
2803
2804 bool getValue() const {
2805 assert(!isValueDependent());
2806 return TypeTraitExprBits.Value;
2807 }
2808
2809 /// Determine the number of arguments to this type trait.
2810 unsigned getNumArgs() const { return TypeTraitExprBits.NumArgs; }
2811
2812 /// Retrieve the Ith argument.
2813 TypeSourceInfo *getArg(unsigned I) const {
2814 assert(I < getNumArgs() && "Argument out-of-range");
2815 return getArgs()[I];
2816 }
2817
2818 /// Retrieve the argument types.
2820 return llvm::ArrayRef(getTrailingObjects<TypeSourceInfo *>(), getNumArgs());
2821 }
2822
2823 SourceLocation getBeginLoc() const LLVM_READONLY { return Loc; }
2824 SourceLocation getEndLoc() const LLVM_READONLY { return RParenLoc; }
2825
2826 static bool classof(const Stmt *T) {
2827 return T->getStmtClass() == TypeTraitExprClass;
2828 }
2829
2830 // Iterators
2833 }
2834
2837 }
2838};
2839
2840/// An Embarcadero array type trait, as used in the implementation of
2841/// __array_rank and __array_extent.
2842///
2843/// Example:
2844/// \code
2845/// __array_rank(int[10][20]) == 2
2846/// __array_extent(int, 1) == 20
2847/// \endcode
2848class ArrayTypeTraitExpr : public Expr {
2849 /// The trait. An ArrayTypeTrait enum in MSVC compat unsigned.
2850 LLVM_PREFERRED_TYPE(ArrayTypeTrait)
2851 unsigned ATT : 2;
2852
2853 /// The value of the type trait. Unspecified if dependent.
2854 uint64_t Value = 0;
2855
2856 /// The array dimension being queried, or -1 if not used.
2857 Expr *Dimension;
2858
2859 /// The location of the type trait keyword.
2861
2862 /// The location of the closing paren.
2863 SourceLocation RParen;
2864
2865 /// The type being queried.
2866 TypeSourceInfo *QueriedType = nullptr;
2867
2868public:
2869 friend class ASTStmtReader;
2870
2872 TypeSourceInfo *queried, uint64_t value, Expr *dimension,
2873 SourceLocation rparen, QualType ty)
2874 : Expr(ArrayTypeTraitExprClass, ty, VK_PRValue, OK_Ordinary), ATT(att),
2875 Value(value), Dimension(dimension), Loc(loc), RParen(rparen),
2876 QueriedType(queried) {
2877 assert(att <= ATT_Last && "invalid enum value!");
2878 assert(static_cast<unsigned>(att) == ATT && "ATT overflow!");
2880 }
2881
2883 : Expr(ArrayTypeTraitExprClass, Empty), ATT(0) {}
2884
2885 SourceLocation getBeginLoc() const LLVM_READONLY { return Loc; }
2886 SourceLocation getEndLoc() const LLVM_READONLY { return RParen; }
2887
2888 ArrayTypeTrait getTrait() const { return static_cast<ArrayTypeTrait>(ATT); }
2889
2890 QualType getQueriedType() const { return QueriedType->getType(); }
2891
2892 TypeSourceInfo *getQueriedTypeSourceInfo() const { return QueriedType; }
2893
2894 uint64_t getValue() const { assert(!isTypeDependent()); return Value; }
2895
2896 Expr *getDimensionExpression() const { return Dimension; }
2897
2898 static bool classof(const Stmt *T) {
2899 return T->getStmtClass() == ArrayTypeTraitExprClass;
2900 }
2901
2902 // Iterators
2905 }
2906
2909 }
2910};
2911
2912/// An expression trait intrinsic.
2913///
2914/// Example:
2915/// \code
2916/// __is_lvalue_expr(std::cout) == true
2917/// __is_lvalue_expr(1) == false
2918/// \endcode
2920 /// The trait. A ExpressionTrait enum in MSVC compatible unsigned.
2921 LLVM_PREFERRED_TYPE(ExpressionTrait)
2922 unsigned ET : 31;
2923
2924 /// The value of the type trait. Unspecified if dependent.
2925 LLVM_PREFERRED_TYPE(bool)
2926 unsigned Value : 1;
2927
2928 /// The location of the type trait keyword.
2930
2931 /// The location of the closing paren.
2932 SourceLocation RParen;
2933
2934 /// The expression being queried.
2935 Expr* QueriedExpression = nullptr;
2936
2937public:
2938 friend class ASTStmtReader;
2939
2941 bool value, SourceLocation rparen, QualType resultType)
2942 : Expr(ExpressionTraitExprClass, resultType, VK_PRValue, OK_Ordinary),
2943 ET(et), Value(value), Loc(loc), RParen(rparen),
2944 QueriedExpression(queried) {
2945 assert(et <= ET_Last && "invalid enum value!");
2946 assert(static_cast<unsigned>(et) == ET && "ET overflow!");
2948 }
2949
2951 : Expr(ExpressionTraitExprClass, Empty), ET(0), Value(false) {}
2952
2953 SourceLocation getBeginLoc() const LLVM_READONLY { return Loc; }
2954 SourceLocation getEndLoc() const LLVM_READONLY { return RParen; }
2955
2956 ExpressionTrait getTrait() const { return static_cast<ExpressionTrait>(ET); }
2957
2958 Expr *getQueriedExpression() const { return QueriedExpression; }
2959
2960 bool getValue() const { return Value; }
2961
2962 static bool classof(const Stmt *T) {
2963 return T->getStmtClass() == ExpressionTraitExprClass;
2964 }
2965
2966 // Iterators
2969 }
2970
2973 }
2974};
2975
2976/// A reference to an overloaded function set, either an
2977/// \c UnresolvedLookupExpr or an \c UnresolvedMemberExpr.
2978class OverloadExpr : public Expr {
2979 friend class ASTStmtReader;
2980 friend class ASTStmtWriter;
2981
2982 /// The common name of these declarations.
2983 DeclarationNameInfo NameInfo;
2984
2985 /// The nested-name-specifier that qualifies the name, if any.
2986 NestedNameSpecifierLoc QualifierLoc;
2987
2988protected:
2989 OverloadExpr(StmtClass SC, const ASTContext &Context,
2990 NestedNameSpecifierLoc QualifierLoc,
2991 SourceLocation TemplateKWLoc,
2992 const DeclarationNameInfo &NameInfo,
2993 const TemplateArgumentListInfo *TemplateArgs,
2995 bool KnownDependent, bool KnownInstantiationDependent,
2996 bool KnownContainsUnexpandedParameterPack);
2997
2998 OverloadExpr(StmtClass SC, EmptyShell Empty, unsigned NumResults,
2999 bool HasTemplateKWAndArgsInfo);
3000
3001 /// Return the results. Defined after UnresolvedMemberExpr.
3004 return const_cast<OverloadExpr *>(this)->getTrailingResults();
3005 }
3006
3007 /// Return the optional template keyword and arguments info.
3008 /// Defined after UnresolvedMemberExpr.
3011 return const_cast<OverloadExpr *>(this)
3013 }
3014
3015 /// Return the optional template arguments. Defined after
3016 /// UnresolvedMemberExpr.
3019 return const_cast<OverloadExpr *>(this)->getTrailingTemplateArgumentLoc();
3020 }
3021
3023 return OverloadExprBits.HasTemplateKWAndArgsInfo;
3024 }
3025
3026public:
3027 struct FindResult {
3031 };
3032
3033 /// Finds the overloaded expression in the given expression \p E of
3034 /// OverloadTy.
3035 ///
3036 /// \return the expression (which must be there) and true if it has
3037 /// the particular form of a member pointer expression
3038 static FindResult find(Expr *E) {
3039 assert(E->getType()->isSpecificBuiltinType(BuiltinType::Overload));
3040
3042
3043 E = E->IgnoreParens();
3044 if (isa<UnaryOperator>(E)) {
3045 assert(cast<UnaryOperator>(E)->getOpcode() == UO_AddrOf);
3046 E = cast<UnaryOperator>(E)->getSubExpr();
3047 auto *Ovl = cast<OverloadExpr>(E->IgnoreParens());
3048
3049 Result.HasFormOfMemberPointer = (E == Ovl && Ovl->getQualifier());
3050 Result.IsAddressOfOperand = true;
3051 Result.Expression = Ovl;
3052 } else {
3053 Result.HasFormOfMemberPointer = false;
3054 Result.IsAddressOfOperand = false;
3055 Result.Expression = cast<OverloadExpr>(E);
3056 }
3057
3058 return Result;
3059 }
3060
3061 /// Gets the naming class of this lookup, if any.
3062 /// Defined after UnresolvedMemberExpr.
3063 inline CXXRecordDecl *getNamingClass();
3065 return const_cast<OverloadExpr *>(this)->getNamingClass();
3066 }
3067
3069
3072 }
3075 }
3076 llvm::iterator_range<decls_iterator> decls() const {
3077 return llvm::make_range(decls_begin(), decls_end());
3078 }
3079
3080 /// Gets the number of declarations in the unresolved set.
3081 unsigned getNumDecls() const { return OverloadExprBits.NumResults; }
3082
3083 /// Gets the full name info.
3084 const DeclarationNameInfo &getNameInfo() const { return NameInfo; }
3085
3086 /// Gets the name looked up.
3087 DeclarationName getName() const { return NameInfo.getName(); }
3088
3089 /// Gets the location of the name.
3090 SourceLocation getNameLoc() const { return NameInfo.getLoc(); }
3091
3092 /// Fetches the nested-name qualifier, if one was given.
3094 return QualifierLoc.getNestedNameSpecifier();
3095 }
3096
3097 /// Fetches the nested-name qualifier with source-location
3098 /// information, if one was given.
3099 NestedNameSpecifierLoc getQualifierLoc() const { return QualifierLoc; }
3100
3101 /// Retrieve the location of the template keyword preceding
3102 /// this name, if any.
3105 return SourceLocation();
3107 }
3108
3109 /// Retrieve the location of the left angle bracket starting the
3110 /// explicit template argument list following the name, if any.
3113 return SourceLocation();
3115 }
3116
3117 /// Retrieve the location of the right angle bracket ending the
3118 /// explicit template argument list following the name, if any.
3121 return SourceLocation();
3123 }
3124
3125 /// Determines whether the name was preceded by the template keyword.
3127
3128 /// Determines whether this expression had explicit template arguments.
3129 bool hasExplicitTemplateArgs() const { return getLAngleLoc().isValid(); }
3130
3133 return nullptr;
3134 return const_cast<OverloadExpr *>(this)->getTrailingTemplateArgumentLoc();
3135 }
3136
3137 unsigned getNumTemplateArgs() const {
3139 return 0;
3140
3142 }
3143
3145 return {getTemplateArgs(), getNumTemplateArgs()};
3146 }
3147
3148 /// Copies the template arguments into the given structure.
3152 }
3153
3154 static bool classof(const Stmt *T) {
3155 return T->getStmtClass() == UnresolvedLookupExprClass ||
3156 T->getStmtClass() == UnresolvedMemberExprClass;
3157 }
3158};
3159
3160/// A reference to a name which we were able to look up during
3161/// parsing but could not resolve to a specific declaration.
3162///
3163/// This arises in several ways:
3164/// * we might be waiting for argument-dependent lookup;
3165/// * the name might resolve to an overloaded function;
3166/// * the name might resolve to a non-function template; for example, in the
3167/// following snippet, the return expression of the member function
3168/// 'foo()' might remain unresolved until instantiation:
3169///
3170/// \code
3171/// struct P {
3172/// template <class T> using I = T;
3173/// };
3174///
3175/// struct Q {
3176/// template <class T> int foo() {
3177/// return T::template I<int>;
3178/// }
3179/// };
3180/// \endcode
3181///
3182/// ...which is distinct from modeling function overloads, and therefore we use
3183/// a different builtin type 'UnresolvedTemplate' to avoid confusion. This is
3184/// done in Sema::BuildTemplateIdExpr.
3185///
3186/// and eventually:
3187/// * the lookup might have included a function template.
3188/// * the unresolved template gets transformed in an instantiation or gets
3189/// diagnosed for its direct use.
3190///
3191/// These never include UnresolvedUsingValueDecls, which are always class
3192/// members and therefore appear only in UnresolvedMemberLookupExprs.
3194 : public OverloadExpr,
3195 private llvm::TrailingObjects<UnresolvedLookupExpr, DeclAccessPair,
3196 ASTTemplateKWAndArgsInfo,
3197 TemplateArgumentLoc> {
3198 friend class ASTStmtReader;
3199 friend class OverloadExpr;
3200 friend TrailingObjects;
3201
3202 /// The naming class (C++ [class.access.base]p5) of the lookup, if
3203 /// any. This can generally be recalculated from the context chain,
3204 /// but that can be fairly expensive for unqualified lookups.
3205 CXXRecordDecl *NamingClass;
3206
3207 // UnresolvedLookupExpr is followed by several trailing objects.
3208 // They are in order:
3209 //
3210 // * An array of getNumResults() DeclAccessPair for the results. These are
3211 // undesugared, which is to say, they may include UsingShadowDecls.
3212 // Access is relative to the naming class.
3213 //
3214 // * An optional ASTTemplateKWAndArgsInfo for the explicitly specified
3215 // template keyword and arguments. Present if and only if
3216 // hasTemplateKWAndArgsInfo().
3217 //
3218 // * An array of getNumTemplateArgs() TemplateArgumentLoc containing
3219 // location information for the explicitly specified template arguments.
3220
3221 UnresolvedLookupExpr(const ASTContext &Context, CXXRecordDecl *NamingClass,
3222 NestedNameSpecifierLoc QualifierLoc,
3223 SourceLocation TemplateKWLoc,
3224 const DeclarationNameInfo &NameInfo, bool RequiresADL,
3225 const TemplateArgumentListInfo *TemplateArgs,
3227 bool KnownDependent);
3228
3229 UnresolvedLookupExpr(EmptyShell Empty, unsigned NumResults,
3230 bool HasTemplateKWAndArgsInfo);
3231
3232 unsigned numTrailingObjects(OverloadToken<DeclAccessPair>) const {
3233 return getNumDecls();
3234 }
3235
3236 unsigned numTrailingObjects(OverloadToken<ASTTemplateKWAndArgsInfo>) const {
3237 return hasTemplateKWAndArgsInfo();
3238 }
3239
3240public:
3241 static UnresolvedLookupExpr *
3242 Create(const ASTContext &Context, CXXRecordDecl *NamingClass,
3243 NestedNameSpecifierLoc QualifierLoc,
3244 const DeclarationNameInfo &NameInfo, bool RequiresADL,
3245 UnresolvedSetIterator Begin, UnresolvedSetIterator End,
3246 bool KnownDependent);
3247
3248 // After canonicalization, there may be dependent template arguments in
3249 // CanonicalConverted But none of Args is dependent. When any of
3250 // CanonicalConverted dependent, KnownDependent is true.
3251 static UnresolvedLookupExpr *
3252 Create(const ASTContext &Context, CXXRecordDecl *NamingClass,
3253 NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc,
3254 const DeclarationNameInfo &NameInfo, bool RequiresADL,
3255 const TemplateArgumentListInfo *Args, UnresolvedSetIterator Begin,
3256 UnresolvedSetIterator End, bool KnownDependent);
3257
3258 static UnresolvedLookupExpr *CreateEmpty(const ASTContext &Context,
3259 unsigned NumResults,
3260 bool HasTemplateKWAndArgsInfo,
3261 unsigned NumTemplateArgs);
3262
3263 /// True if this declaration should be extended by
3264 /// argument-dependent lookup.
3265 bool requiresADL() const { return UnresolvedLookupExprBits.RequiresADL; }
3266
3267 /// Gets the 'naming class' (in the sense of C++0x
3268 /// [class.access.base]p5) of the lookup. This is the scope
3269 /// that was looked in to find these results.
3270 CXXRecordDecl *getNamingClass() { return NamingClass; }
3271 const CXXRecordDecl *getNamingClass() const { return NamingClass; }
3272
3273 SourceLocation getBeginLoc() const LLVM_READONLY {
3275 return l.getBeginLoc();
3276 return getNameInfo().getBeginLoc();
3277 }
3278
3279 SourceLocation getEndLoc() const LLVM_READONLY {
3281 return getRAngleLoc();
3282 return getNameInfo().getEndLoc();
3283 }
3284
3287 }
3288
3291 }
3292
3293 static bool classof(const Stmt *T) {
3294 return T->getStmtClass() == UnresolvedLookupExprClass;
3295 }
3296};
3297
3298/// A qualified reference to a name whose declaration cannot
3299/// yet be resolved.
3300///
3301/// DependentScopeDeclRefExpr is similar to DeclRefExpr in that
3302/// it expresses a reference to a declaration such as
3303/// X<T>::value. The difference, however, is that an
3304/// DependentScopeDeclRefExpr node is used only within C++ templates when
3305/// the qualification (e.g., X<T>::) refers to a dependent type. In
3306/// this case, X<T>::value cannot resolve to a declaration because the
3307/// declaration will differ from one instantiation of X<T> to the
3308/// next. Therefore, DependentScopeDeclRefExpr keeps track of the
3309/// qualifier (X<T>::) and the name of the entity being referenced
3310/// ("value"). Such expressions will instantiate to a DeclRefExpr once the
3311/// declaration can be found.
3313 : public Expr,
3314 private llvm::TrailingObjects<DependentScopeDeclRefExpr,
3315 ASTTemplateKWAndArgsInfo,
3316 TemplateArgumentLoc> {
3317 friend class ASTStmtReader;
3318 friend class ASTStmtWriter;
3319 friend TrailingObjects;
3320
3321 /// The nested-name-specifier that qualifies this unresolved
3322 /// declaration name.
3323 NestedNameSpecifierLoc QualifierLoc;
3324
3325 /// The name of the entity we will be referencing.
3326 DeclarationNameInfo NameInfo;
3327
3329 SourceLocation TemplateKWLoc,
3330 const DeclarationNameInfo &NameInfo,
3331 const TemplateArgumentListInfo *Args);
3332
3333 size_t numTrailingObjects(OverloadToken<ASTTemplateKWAndArgsInfo>) const {
3334 return hasTemplateKWAndArgsInfo();
3335 }
3336
3337 bool hasTemplateKWAndArgsInfo() const {
3338 return DependentScopeDeclRefExprBits.HasTemplateKWAndArgsInfo;
3339 }
3340
3341public:
3342 static DependentScopeDeclRefExpr *
3343 Create(const ASTContext &Context, NestedNameSpecifierLoc QualifierLoc,
3344 SourceLocation TemplateKWLoc, const DeclarationNameInfo &NameInfo,
3345 const TemplateArgumentListInfo *TemplateArgs);
3346
3347 static DependentScopeDeclRefExpr *CreateEmpty(const ASTContext &Context,
3348 bool HasTemplateKWAndArgsInfo,
3349 unsigned NumTemplateArgs);
3350
3351 /// Retrieve the name that this expression refers to.
3352 const DeclarationNameInfo &getNameInfo() const { return NameInfo; }
3353
3354 /// Retrieve the name that this expression refers to.
3355 DeclarationName getDeclName() const { return NameInfo.getName(); }
3356
3357 /// Retrieve the location of the name within the expression.
3358 ///
3359 /// For example, in "X<T>::value" this is the location of "value".
3360 SourceLocation getLocation() const { return NameInfo.getLoc(); }
3361
3362 /// Retrieve the nested-name-specifier that qualifies the
3363 /// name, with source location information.
3364 NestedNameSpecifierLoc getQualifierLoc() const { return QualifierLoc; }
3365
3366 /// Retrieve the nested-name-specifier that qualifies this
3367 /// declaration.
3369 return QualifierLoc.getNestedNameSpecifier();
3370 }
3371
3372 /// Retrieve the location of the template keyword preceding
3373 /// this name, if any.
3375 if (!hasTemplateKWAndArgsInfo())
3376 return SourceLocation();
3377 return getTrailingObjects<ASTTemplateKWAndArgsInfo>()->TemplateKWLoc;
3378 }
3379
3380 /// Retrieve the location of the left angle bracket starting the
3381 /// explicit template argument list following the name, if any.
3383 if (!hasTemplateKWAndArgsInfo())
3384 return SourceLocation();
3385 return getTrailingObjects<ASTTemplateKWAndArgsInfo>()->LAngleLoc;
3386 }
3387
3388 /// Retrieve the location of the right angle bracket ending the
3389 /// explicit template argument list following the name, if any.
3391 if (!hasTemplateKWAndArgsInfo())
3392 return SourceLocation();
3393 return getTrailingObjects<ASTTemplateKWAndArgsInfo>()->RAngleLoc;
3394 }
3395
3396 /// Determines whether the name was preceded by the template keyword.
3398
3399 /// Determines whether this lookup had explicit template arguments.
3400 bool hasExplicitTemplateArgs() const { return getLAngleLoc().isValid(); }
3401
3402 /// Copies the template arguments (if present) into the given
3403 /// structure.
3406 getTrailingObjects<ASTTemplateKWAndArgsInfo>()->copyInto(
3407 getTrailingObjects<TemplateArgumentLoc>(), List);
3408 }
3409
3412 return nullptr;
3413
3414 return getTrailingObjects<TemplateArgumentLoc>();
3415 }
3416
3417 unsigned getNumTemplateArgs() const {
3419 return 0;
3420
3421 return getTrailingObjects<ASTTemplateKWAndArgsInfo>()->NumTemplateArgs;
3422 }
3423
3425 return {getTemplateArgs(), getNumTemplateArgs()};
3426 }
3427
3428 /// Note: getBeginLoc() is the start of the whole DependentScopeDeclRefExpr,
3429 /// and differs from getLocation().getStart().
3430 SourceLocation getBeginLoc() const LLVM_READONLY {
3431 return QualifierLoc.getBeginLoc();
3432 }
3433
3434 SourceLocation getEndLoc() const LLVM_READONLY {
3436 return getRAngleLoc();
3437 return getLocation();
3438 }
3439
3440 static bool classof(const Stmt *T) {
3441 return T->getStmtClass() == DependentScopeDeclRefExprClass;
3442 }
3443
3446 }
3447
3450 }
3451};
3452
3453/// Represents an expression -- generally a full-expression -- that
3454/// introduces cleanups to be run at the end of the sub-expression's
3455/// evaluation. The most common source of expression-introduced
3456/// cleanups is temporary objects in C++, but several other kinds of
3457/// expressions can create cleanups, including basically every
3458/// call in ARC that returns an Objective-C pointer.
3459///
3460/// This expression also tracks whether the sub-expression contains a
3461/// potentially-evaluated block literal. The lifetime of a block
3462/// literal is the extent of the enclosing scope.
3464 : public FullExpr,
3465 private llvm::TrailingObjects<
3466 ExprWithCleanups,
3467 llvm::PointerUnion<BlockDecl *, CompoundLiteralExpr *>> {
3468public:
3469 /// The type of objects that are kept in the cleanup.
3470 /// It's useful to remember the set of blocks and block-scoped compound
3471 /// literals; we could also remember the set of temporaries, but there's
3472 /// currently no need.
3473 using CleanupObject = llvm::PointerUnion<BlockDecl *, CompoundLiteralExpr *>;
3474
3475private:
3476 friend class ASTStmtReader;
3477 friend TrailingObjects;
3478
3479 ExprWithCleanups(EmptyShell, unsigned NumObjects);
3480 ExprWithCleanups(Expr *SubExpr, bool CleanupsHaveSideEffects,
3481 ArrayRef<CleanupObject> Objects);
3482
3483public:
3484 static ExprWithCleanups *Create(const ASTContext &C, EmptyShell empty,
3485 unsigned numObjects);
3486
3487 static ExprWithCleanups *Create(const ASTContext &C, Expr *subexpr,
3488 bool CleanupsHaveSideEffects,
3489 ArrayRef<CleanupObject> objects);
3490
3492 return llvm::ArrayRef(getTrailingObjects<CleanupObject>(), getNumObjects());
3493 }
3494
3495 unsigned getNumObjects() const { return ExprWithCleanupsBits.NumObjects; }
3496
3497 CleanupObject getObject(unsigned i) const {
3498 assert(i < getNumObjects() && "Index out of range");
3499 return getObjects()[i];
3500 }
3501
3503 return ExprWithCleanupsBits.CleanupsHaveSideEffects;
3504 }
3505
3506 SourceLocation getBeginLoc() const LLVM_READONLY {
3507 return SubExpr->getBeginLoc();
3508 }
3509
3510 SourceLocation getEndLoc() const LLVM_READONLY {
3511 return SubExpr->getEndLoc();
3512 }
3513
3514 // Implement isa/cast/dyncast/etc.
3515 static bool classof(const Stmt *T) {
3516 return T->getStmtClass() == ExprWithCleanupsClass;
3517 }
3518
3519 // Iterators
3521
3523 return const_child_range(&SubExpr, &SubExpr + 1);
3524 }
3525};
3526
3527/// Describes an explicit type conversion that uses functional
3528/// notion but could not be resolved because one or more arguments are
3529/// type-dependent.
3530///
3531/// The explicit type conversions expressed by
3532/// CXXUnresolvedConstructExpr have the form <tt>T(a1, a2, ..., aN)</tt>,
3533/// where \c T is some type and \c a1, \c a2, ..., \c aN are values, and
3534/// either \c T is a dependent type or one or more of the <tt>a</tt>'s is
3535/// type-dependent. For example, this would occur in a template such
3536/// as:
3537///
3538/// \code
3539/// template<typename T, typename A1>
3540/// inline T make_a(const A1& a1) {
3541/// return T(a1);
3542/// }
3543/// \endcode
3544///
3545/// When the returned expression is instantiated, it may resolve to a
3546/// constructor call, conversion function call, or some kind of type
3547/// conversion.
3549 : public Expr,
3550 private llvm::TrailingObjects<CXXUnresolvedConstructExpr, Expr *> {
3551 friend class ASTStmtReader;
3552 friend TrailingObjects;
3553
3554 /// The type being constructed, and whether the construct expression models
3555 /// list initialization or not.
3556 llvm::PointerIntPair<TypeSourceInfo *, 1> TypeAndInitForm;
3557
3558 /// The location of the left parentheses ('(').
3559 SourceLocation LParenLoc;
3560
3561 /// The location of the right parentheses (')').
3562 SourceLocation RParenLoc;
3563
3565 SourceLocation LParenLoc, ArrayRef<Expr *> Args,
3566 SourceLocation RParenLoc, bool IsListInit);
3567
3568 CXXUnresolvedConstructExpr(EmptyShell Empty, unsigned NumArgs)
3569 : Expr(CXXUnresolvedConstructExprClass, Empty) {
3570 CXXUnresolvedConstructExprBits.NumArgs = NumArgs;
3571 }
3572
3573public:
3575 Create(const ASTContext &Context, QualType T, TypeSourceInfo *TSI,
3576 SourceLocation LParenLoc, ArrayRef<Expr *> Args,
3577 SourceLocation RParenLoc, bool IsListInit);
3578
3579 static CXXUnresolvedConstructExpr *CreateEmpty(const ASTContext &Context,
3580 unsigned NumArgs);
3581
3582 /// Retrieve the type that is being constructed, as specified
3583 /// in the source code.
3585
3586 /// Retrieve the type source information for the type being
3587 /// constructed.
3589 return TypeAndInitForm.getPointer();
3590 }
3591
3592 /// Retrieve the location of the left parentheses ('(') that
3593 /// precedes the argument list.
3594 SourceLocation getLParenLoc() const { return LParenLoc; }
3595 void setLParenLoc(SourceLocation L) { LParenLoc = L; }
3596
3597 /// Retrieve the location of the right parentheses (')') that
3598 /// follows the argument list.
3599 SourceLocation getRParenLoc() const { return RParenLoc; }
3600 void setRParenLoc(SourceLocation L) { RParenLoc = L; }
3601
3602 /// Determine whether this expression models list-initialization.
3603 /// If so, there will be exactly one subexpression, which will be
3604 /// an InitListExpr.
3605 bool isListInitialization() const { return TypeAndInitForm.getInt(); }
3606
3607 /// Retrieve the number of arguments.
3608 unsigned getNumArgs() const { return CXXUnresolvedConstructExprBits.NumArgs; }
3609
3610 using arg_iterator = Expr **;
3611 using arg_range = llvm::iterator_range<arg_iterator>;
3612
3613 arg_iterator arg_begin() { return getTrailingObjects<Expr *>(); }
3616
3617 using const_arg_iterator = const Expr* const *;
3618 using const_arg_range = llvm::iterator_range<const_arg_iterator>;
3619
3620 const_arg_iterator arg_begin() const { return getTrailingObjects<Expr *>(); }
3623 return const_arg_range(arg_begin(), arg_end());
3624 }
3625
3626 Expr *getArg(unsigned I) {
3627 assert(I < getNumArgs() && "Argument index out-of-range");
3628 return arg_begin()[I];
3629 }
3630
3631 const Expr *getArg(unsigned I) const {
3632 assert(I < getNumArgs() && "Argument index out-of-range");
3633 return arg_begin()[I];
3634 }
3635
3636 void setArg(unsigned I, Expr *E) {
3637 assert(I < getNumArgs() && "Argument index out-of-range");
3638 arg_begin()[I] = E;
3639 }
3640
3641 SourceLocation getBeginLoc() const LLVM_READONLY;
3642 SourceLocation getEndLoc() const LLVM_READONLY {
3643 if (!RParenLoc.isValid() && getNumArgs() > 0)
3644 return getArg(getNumArgs() - 1)->getEndLoc();
3645 return RParenLoc;
3646 }
3647
3648 static bool classof(const Stmt *T) {
3649 return T->getStmtClass() == CXXUnresolvedConstructExprClass;
3650 }
3651
3652 // Iterators
3654 auto **begin = reinterpret_cast<Stmt **>(arg_begin());
3655 return child_range(begin, begin + getNumArgs());
3656 }
3657
3659 auto **begin = reinterpret_cast<Stmt **>(
3660 const_cast<CXXUnresolvedConstructExpr *>(this)->arg_begin());
3661 return const_child_range(begin, begin + getNumArgs());
3662 }
3663};
3664
3665/// Represents a C++ member access expression where the actual
3666/// member referenced could not be resolved because the base
3667/// expression or the member name was dependent.
3668///
3669/// Like UnresolvedMemberExprs, these can be either implicit or
3670/// explicit accesses. It is only possible to get one of these with
3671/// an implicit access if a qualifier is provided.
3673 : public Expr,
3674 private llvm::TrailingObjects<CXXDependentScopeMemberExpr,
3675 ASTTemplateKWAndArgsInfo,
3676 TemplateArgumentLoc, NamedDecl *> {
3677 friend class ASTStmtReader;
3678 friend class ASTStmtWriter;
3679 friend TrailingObjects;
3680
3681 /// The expression for the base pointer or class reference,
3682 /// e.g., the \c x in x.f. Can be null in implicit accesses.
3683 Stmt *Base;
3684
3685 /// The type of the base expression. Never null, even for
3686 /// implicit accesses.
3687 QualType BaseType;
3688
3689 /// The nested-name-specifier that precedes the member name, if any.
3690 /// FIXME: This could be in principle store as a trailing object.
3691 /// However the performance impact of doing so should be investigated first.
3692 NestedNameSpecifierLoc QualifierLoc;
3693
3694 /// The member to which this member expression refers, which
3695 /// can be name, overloaded operator, or destructor.
3696 ///
3697 /// FIXME: could also be a template-id
3698 DeclarationNameInfo MemberNameInfo;
3699
3700 // CXXDependentScopeMemberExpr is followed by several trailing objects,
3701 // some of which optional. They are in order:
3702 //
3703 // * An optional ASTTemplateKWAndArgsInfo for the explicitly specified
3704 // template keyword and arguments. Present if and only if
3705 // hasTemplateKWAndArgsInfo().
3706 //
3707 // * An array of getNumTemplateArgs() TemplateArgumentLoc containing location
3708 // information for the explicitly specified template arguments.
3709 //
3710 // * An optional NamedDecl *. In a qualified member access expression such
3711 // as t->Base::f, this member stores the resolves of name lookup in the
3712 // context of the member access expression, to be used at instantiation
3713 // time. Present if and only if hasFirstQualifierFoundInScope().
3714
3715 bool hasTemplateKWAndArgsInfo() const {
3716 return CXXDependentScopeMemberExprBits.HasTemplateKWAndArgsInfo;
3717 }
3718
3719 bool hasFirstQualifierFoundInScope() const {
3720 return CXXDependentScopeMemberExprBits.HasFirstQualifierFoundInScope;
3721 }
3722
3723 unsigned numTrailingObjects(OverloadToken<ASTTemplateKWAndArgsInfo>) const {
3724 return hasTemplateKWAndArgsInfo();
3725 }
3726
3727 unsigned numTrailingObjects(OverloadToken<TemplateArgumentLoc>) const {
3728 return getNumTemplateArgs();
3729 }
3730
3731 unsigned numTrailingObjects(OverloadToken<NamedDecl *>) const {
3732 return hasFirstQualifierFoundInScope();
3733 }
3734
3735 CXXDependentScopeMemberExpr(const ASTContext &Ctx, Expr *Base,
3736 QualType BaseType, bool IsArrow,
3737 SourceLocation OperatorLoc,
3738 NestedNameSpecifierLoc QualifierLoc,
3739 SourceLocation TemplateKWLoc,
3740 NamedDecl *FirstQualifierFoundInScope,
3741 DeclarationNameInfo MemberNameInfo,
3742 const TemplateArgumentListInfo *TemplateArgs);
3743
3744 CXXDependentScopeMemberExpr(EmptyShell Empty, bool HasTemplateKWAndArgsInfo,
3745 bool HasFirstQualifierFoundInScope);
3746
3747public:
3748 static CXXDependentScopeMemberExpr *
3749 Create(const ASTContext &Ctx, Expr *Base, QualType BaseType, bool IsArrow,
3750 SourceLocation OperatorLoc, NestedNameSpecifierLoc QualifierLoc,
3751 SourceLocation TemplateKWLoc, NamedDecl *FirstQualifierFoundInScope,
3752 DeclarationNameInfo MemberNameInfo,
3753 const TemplateArgumentListInfo *TemplateArgs);
3754
3755 static CXXDependentScopeMemberExpr *
3756 CreateEmpty(const ASTContext &Ctx, bool HasTemplateKWAndArgsInfo,
3757 unsigned NumTemplateArgs, bool HasFirstQualifierFoundInScope);
3758
3759 /// True if this is an implicit access, i.e. one in which the
3760 /// member being accessed was not written in the source. The source
3761 /// location of the operator is invalid in this case.
3762 bool isImplicitAccess() const {
3763 if (!Base)
3764 return true;
3765 return cast<Expr>(Base)->isImplicitCXXThis();
3766 }
3767
3768 /// Retrieve the base object of this member expressions,
3769 /// e.g., the \c x in \c x.m.
3770 Expr *getBase() const {
3771 assert(!isImplicitAccess());
3772 return cast<Expr>(Base);
3773 }
3774
3775 QualType getBaseType() const { return BaseType; }
3776
3777 /// Determine whether this member expression used the '->'
3778 /// operator; otherwise, it used the '.' operator.
3779 bool isArrow() const { return CXXDependentScopeMemberExprBits.IsArrow; }
3780
3781 /// Retrieve the location of the '->' or '.' operator.
3783 return CXXDependentScopeMemberExprBits.OperatorLoc;
3784 }
3785
3786 /// Retrieve the nested-name-specifier that qualifies the member name.
3788 return QualifierLoc.getNestedNameSpecifier();
3789 }
3790
3791 /// Retrieve the nested-name-specifier that qualifies the member
3792 /// name, with source location information.
3793 NestedNameSpecifierLoc getQualifierLoc() const { return QualifierLoc; }
3794
3795 /// Retrieve the first part of the nested-name-specifier that was
3796 /// found in the scope of the member access expression when the member access
3797 /// was initially parsed.
3798 ///
3799 /// This function only returns a useful result when member access expression
3800 /// uses a qualified member name, e.g., "x.Base::f". Here, the declaration
3801 /// returned by this function describes what was found by unqualified name
3802 /// lookup for the identifier "Base" within the scope of the member access
3803 /// expression itself. At template instantiation time, this information is
3804 /// combined with the results of name lookup into the type of the object
3805 /// expression itself (the class type of x).
3807 if (!hasFirstQualifierFoundInScope())
3808 return nullptr;
3809 return *getTrailingObjects<NamedDecl *>();
3810 }
3811
3812 /// Retrieve the name of the member that this expression refers to.
3814 return MemberNameInfo;
3815 }
3816
3817 /// Retrieve the name of the member that this expression refers to.
3818 DeclarationName getMember() const { return MemberNameInfo.getName(); }
3819
3820 // Retrieve the location of the name of the member that this
3821 // expression refers to.
3822 SourceLocation getMemberLoc() const { return MemberNameInfo.getLoc(); }
3823
3824 /// Retrieve the location of the template keyword preceding the
3825 /// member name, if any.
3827 if (!hasTemplateKWAndArgsInfo())
3828 return SourceLocation();
3829 return getTrailingObjects<ASTTemplateKWAndArgsInfo>()->TemplateKWLoc;
3830 }
3831
3832 /// Retrieve the location of the left angle bracket starting the
3833 /// explicit template argument list following the member name, if any.
3835 if (!hasTemplateKWAndArgsInfo())
3836 return SourceLocation();
3837 return getTrailingObjects<ASTTemplateKWAndArgsInfo>()->LAngleLoc;
3838 }
3839
3840 /// Retrieve the location of the right angle bracket ending the
3841 /// explicit template argument list following the member name, if any.
3843 if (!hasTemplateKWAndArgsInfo())
3844 return SourceLocation();
3845 return getTrailingObjects<ASTTemplateKWAndArgsInfo>()->RAngleLoc;
3846 }
3847
3848 /// Determines whether the member name was preceded by the template keyword.
3850
3851 /// Determines whether this member expression actually had a C++
3852 /// template argument list explicitly specified, e.g., x.f<int>.
3853 bool hasExplicitTemplateArgs() const { return getLAngleLoc().isValid(); }
3854
3855 /// Copies the template arguments (if present) into the given
3856 /// structure.
3859 getTrailingObjects<ASTTemplateKWAndArgsInfo>()->copyInto(
3860 getTrailingObjects<TemplateArgumentLoc>(), List);
3861 }
3862
3863 /// Retrieve the template arguments provided as part of this
3864 /// template-id.
3867 return nullptr;
3868
3869 return getTrailingObjects<TemplateArgumentLoc>();
3870 }
3871
3872 /// Retrieve the number of template arguments provided as part of this
3873 /// template-id.
3874 unsigned getNumTemplateArgs() const {
3876 return 0;
3877
3878 return getTrailingObjects<ASTTemplateKWAndArgsInfo>()->NumTemplateArgs;
3879 }
3880
3882 return {getTemplateArgs(), getNumTemplateArgs()};
3883 }
3884
3885 SourceLocation getBeginLoc() const LLVM_READONLY {
3886 if (!isImplicitAccess())
3887 return Base->getBeginLoc();
3888 if (getQualifier())
3889 return getQualifierLoc().getBeginLoc();
3890 return MemberNameInfo.getBeginLoc();
3891 }
3892
3893 SourceLocation getEndLoc() const LLVM_READONLY {
3895 return getRAngleLoc();
3896 return MemberNameInfo.getEndLoc();
3897 }
3898
3899 static bool classof(const Stmt *T) {
3900 return T->getStmtClass() == CXXDependentScopeMemberExprClass;
3901 }
3902
3903 // Iterators
3905 if (isImplicitAccess())
3907 return child_range(&Base, &Base + 1);
3908 }
3909
3911 if (isImplicitAccess())
3913 return const_child_range(&Base, &Base + 1);
3914 }
3915};
3916
3917/// Represents a C++ member access expression for which lookup
3918/// produced a set of overloaded functions.
3919///
3920/// The member access may be explicit or implicit:
3921/// \code
3922/// struct A {
3923/// int a, b;
3924/// int explicitAccess() { return this->a + this->A::b; }
3925/// int implicitAccess() { return a + A::b; }
3926/// };
3927/// \endcode
3928///
3929/// In the final AST, an explicit access always becomes a MemberExpr.
3930/// An implicit access may become either a MemberExpr or a
3931/// DeclRefExpr, depending on whether the member is static.
3933 : public OverloadExpr,
3934 private llvm::TrailingObjects<UnresolvedMemberExpr, DeclAccessPair,
3935 ASTTemplateKWAndArgsInfo,
3936 TemplateArgumentLoc> {
3937 friend class ASTStmtReader;
3938 friend class OverloadExpr;
3939 friend TrailingObjects;
3940
3941 /// The expression for the base pointer or class reference,
3942 /// e.g., the \c x in x.f.
3943 ///
3944 /// This can be null if this is an 'unbased' member expression.
3945 Stmt *Base;
3946
3947 /// The type of the base expression; never null.
3948 QualType BaseType;
3949
3950 /// The location of the '->' or '.' operator.
3951 SourceLocation OperatorLoc;
3952
3953 // UnresolvedMemberExpr is followed by several trailing objects.
3954 // They are in order:
3955 //
3956 // * An array of getNumResults() DeclAccessPair for the results. These are
3957 // undesugared, which is to say, they may include UsingShadowDecls.
3958 // Access is relative to the naming class.
3959 //
3960 // * An optional ASTTemplateKWAndArgsInfo for the explicitly specified
3961 // template keyword and arguments. Present if and only if
3962 // hasTemplateKWAndArgsInfo().
3963 //
3964 // * An array of getNumTemplateArgs() TemplateArgumentLoc containing
3965 // location information for the explicitly specified template arguments.
3966
3967 UnresolvedMemberExpr(const ASTContext &Context, bool HasUnresolvedUsing,
3968 Expr *Base, QualType BaseType, bool IsArrow,
3969 SourceLocation OperatorLoc,
3970 NestedNameSpecifierLoc QualifierLoc,
3971 SourceLocation TemplateKWLoc,
3972 const DeclarationNameInfo &MemberNameInfo,
3973 const TemplateArgumentListInfo *TemplateArgs,
3975
3976 UnresolvedMemberExpr(EmptyShell Empty, unsigned NumResults,
3977 bool HasTemplateKWAndArgsInfo);
3978
3979 unsigned numTrailingObjects(OverloadToken<DeclAccessPair>) const {
3980 return getNumDecls();
3981 }
3982
3983 unsigned numTrailingObjects(OverloadToken<ASTTemplateKWAndArgsInfo>) const {
3984 return hasTemplateKWAndArgsInfo();
3985 }
3986
3987public:
3988 static UnresolvedMemberExpr *
3989 Create(const ASTContext &Context, bool HasUnresolvedUsing, Expr *Base,
3990 QualType BaseType, bool IsArrow, SourceLocation OperatorLoc,
3991 NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc,
3992 const DeclarationNameInfo &MemberNameInfo,
3993 const TemplateArgumentListInfo *TemplateArgs,
3994 UnresolvedSetIterator Begin, UnresolvedSetIterator End);
3995
3996 static UnresolvedMemberExpr *CreateEmpty(const ASTContext &Context,
3997 unsigned NumResults,
3998 bool HasTemplateKWAndArgsInfo,
3999 unsigned NumTemplateArgs);
4000
4001 /// True if this is an implicit access, i.e., one in which the
4002 /// member being accessed was not written in the source.
4003 ///
4004 /// The source location of the operator is invalid in this case.
4005 bool isImplicitAccess() const;
4006
4007 /// Retrieve the base object of this member expressions,
4008 /// e.g., the \c x in \c x.m.
4010 assert(!isImplicitAccess());
4011 return cast<Expr>(Base);
4012 }
4013 const Expr *getBase() const {
4014 assert(!isImplicitAccess());
4015 return cast<Expr>(Base);
4016 }
4017
4018 QualType getBaseType() const { return BaseType; }
4019
4020 /// Determine whether the lookup results contain an unresolved using
4021 /// declaration.
4022 bool hasUnresolvedUsing() const {
4023 return UnresolvedMemberExprBits.HasUnresolvedUsing;
4024 }
4025
4026 /// Determine whether this member expression used the '->'
4027 /// operator; otherwise, it used the '.' operator.
4028 bool isArrow() const { return UnresolvedMemberExprBits.IsArrow; }
4029
4030 /// Retrieve the location of the '->' or '.' operator.
4031 SourceLocation getOperatorLoc() const { return OperatorLoc; }
4032
4033 /// Retrieve the naming class of this lookup.
4036 return const_cast<UnresolvedMemberExpr *>(this)->getNamingClass();
4037 }
4038
4039 /// Retrieve the full name info for the member that this expression
4040 /// refers to.
4042
4043 /// Retrieve the name of the member that this expression refers to.
4045
4046 /// Retrieve the location of the name of the member that this
4047 /// expression refers to.
4049
4050 /// Return the preferred location (the member name) for the arrow when
4051 /// diagnosing a problem with this expression.
4052 SourceLocation getExprLoc() const LLVM_READONLY { return getMemberLoc(); }
4053
4054 SourceLocation getBeginLoc() const LLVM_READONLY {
4055 if (!isImplicitAccess())
4056 return Base->getBeginLoc();
4058 return l.getBeginLoc();
4059 return getMemberNameInfo().getBeginLoc();
4060 }
4061
4062 SourceLocation getEndLoc() const LLVM_READONLY {
4064 return getRAngleLoc();
4065 return getMemberNameInfo().getEndLoc();
4066 }
4067
4068 static bool classof(const Stmt *T) {
4069 return T->getStmtClass() == UnresolvedMemberExprClass;
4070 }
4071
4072 // Iterators
4074 if (isImplicitAccess())
4076 return child_range(&Base, &Base + 1);
4077 }
4078
4080 if (isImplicitAccess())
4082 return const_child_range(&Base, &Base + 1);
4083 }
4084};
4085
4087 if (auto *ULE = dyn_cast<UnresolvedLookupExpr>(this))
4088 return ULE->getTrailingObjects<DeclAccessPair>();
4089 return cast<UnresolvedMemberExpr>(this)->getTrailingObjects<DeclAccessPair>();
4090}
4091
4094 return nullptr;
4095
4096 if (auto *ULE = dyn_cast<UnresolvedLookupExpr>(this))
4097 return ULE->getTrailingObjects<ASTTemplateKWAndArgsInfo>();
4098 return cast<UnresolvedMemberExpr>(this)
4099 ->getTrailingObjects<ASTTemplateKWAndArgsInfo>();
4100}
4101
4103 if (auto *ULE = dyn_cast<UnresolvedLookupExpr>(this))
4104 return ULE->getTrailingObjects<TemplateArgumentLoc>();
4105 return cast<UnresolvedMemberExpr>(this)
4106 ->getTrailingObjects<TemplateArgumentLoc>();
4107}
4108
4110 if (auto *ULE = dyn_cast<UnresolvedLookupExpr>(this))
4111 return ULE->getNamingClass();
4112 return cast<UnresolvedMemberExpr>(this)->getNamingClass();
4113}
4114
4115/// Represents a C++11 noexcept expression (C++ [expr.unary.noexcept]).
4116///
4117/// The noexcept expression tests whether a given expression might throw. Its
4118/// result is a boolean constant.
4119class CXXNoexceptExpr : public Expr {
4120 friend class ASTStmtReader;
4121
4122 Stmt *Operand;
4124
4125public:
4127 SourceLocation Keyword, SourceLocation RParen)
4128 : Expr(CXXNoexceptExprClass, Ty, VK_PRValue, OK_Ordinary),
4129 Operand(Operand), Range(Keyword, RParen) {
4130 CXXNoexceptExprBits.Value = Val == CT_Cannot;
4131 setDependence(computeDependence(this, Val));
4132 }
4133
4134 CXXNoexceptExpr(EmptyShell Empty) : Expr(CXXNoexceptExprClass, Empty) {}
4135
4136 Expr *getOperand() const { return static_cast<Expr *>(Operand); }
4137
4138 SourceLocation getBeginLoc() const { return Range.getBegin(); }
4139 SourceLocation getEndLoc() const { return Range.getEnd(); }
4141
4142 bool getValue() const { return CXXNoexceptExprBits.Value; }
4143
4144 static bool classof(const Stmt *T) {
4145 return T->getStmtClass() == CXXNoexceptExprClass;
4146 }
4147
4148 // Iterators
4149 child_range children() { return child_range(&Operand, &Operand + 1); }
4150
4152 return const_child_range(&Operand, &Operand + 1);
4153 }
4154};
4155
4156/// Represents a C++11 pack expansion that produces a sequence of
4157/// expressions.
4158///
4159/// A pack expansion expression contains a pattern (which itself is an
4160/// expression) followed by an ellipsis. For example:
4161///
4162/// \code
4163/// template<typename F, typename ...Types>
4164/// void forward(F f, Types &&...args) {
4165/// f(static_cast<Types&&>(args)...);
4166/// }
4167/// \endcode
4168///
4169/// Here, the argument to the function object \c f is a pack expansion whose
4170/// pattern is \c static_cast<Types&&>(args). When the \c forward function
4171/// template is instantiated, the pack expansion will instantiate to zero or
4172/// or more function arguments to the function object \c f.
4173class PackExpansionExpr : public Expr {
4174 friend class ASTStmtReader;
4175 friend class ASTStmtWriter;
4176
4177 SourceLocation EllipsisLoc;
4178
4179 /// The number of expansions that will be produced by this pack
4180 /// expansion expression, if known.
4181 ///
4182 /// When zero, the number of expansions is not known. Otherwise, this value
4183 /// is the number of expansions + 1.
4184 unsigned NumExpansions;
4185
4186 Stmt *Pattern;
4187
4188public:
4190 std::optional<unsigned> NumExpansions)
4191 : Expr(PackExpansionExprClass, T, Pattern->getValueKind(),
4192 Pattern->getObjectKind()),
4193 EllipsisLoc(EllipsisLoc),
4194 NumExpansions(NumExpansions ? *NumExpansions + 1 : 0),
4195 Pattern(Pattern) {
4197 }
4198
4199 PackExpansionExpr(EmptyShell Empty) : Expr(PackExpansionExprClass, Empty) {}
4200
4201 /// Retrieve the pattern of the pack expansion.
4202 Expr *getPattern() { return reinterpret_cast<Expr *>(Pattern); }
4203
4204 /// Retrieve the pattern of the pack expansion.
4205 const Expr *getPattern() const { return reinterpret_cast<Expr *>(Pattern); }
4206
4207 /// Retrieve the location of the ellipsis that describes this pack
4208 /// expansion.
4209 SourceLocation getEllipsisLoc() const { return EllipsisLoc; }
4210
4211 /// Determine the number of expansions that will be produced when
4212 /// this pack expansion is instantiated, if already known.
4213 std::optional<unsigned> getNumExpansions() const {
4214 if (NumExpansions)
4215 return NumExpansions - 1;
4216
4217 return std::nullopt;
4218 }
4219
4220 SourceLocation getBeginLoc() const LLVM_READONLY {
4221 return Pattern->getBeginLoc();
4222 }
4223
4224 SourceLocation getEndLoc() const LLVM_READONLY { return EllipsisLoc; }
4225
4226 static bool classof(const Stmt *T) {
4227 return T->getStmtClass() == PackExpansionExprClass;
4228 }
4229
4230 // Iterators
4232 return child_range(&Pattern, &Pattern + 1);
4233 }
4234
4236 return const_child_range(&Pattern, &Pattern + 1);
4237 }
4238};
4239
4240/// Represents an expression that computes the length of a parameter
4241/// pack.
4242///
4243/// \code
4244/// template<typename ...Types>
4245/// struct count {
4246/// static const unsigned value = sizeof...(Types);
4247/// };
4248/// \endcode
4250 : public Expr,
4251 private llvm::TrailingObjects<SizeOfPackExpr, TemplateArgument> {
4252 friend class ASTStmtReader;
4253 friend class ASTStmtWriter;
4254 friend TrailingObjects;
4255
4256 /// The location of the \c sizeof keyword.
4257 SourceLocation OperatorLoc;
4258
4259 /// The location of the name of the parameter pack.
4260 SourceLocation PackLoc;
4261
4262 /// The location of the closing parenthesis.
4263 SourceLocation RParenLoc;
4264
4265 /// The length of the parameter pack, if known.
4266 ///
4267 /// When this expression is not value-dependent, this is the length of
4268 /// the pack. When the expression was parsed rather than instantiated
4269 /// (and thus is value-dependent), this is zero.
4270 ///
4271 /// After partial substitution into a sizeof...(X) expression (for instance,
4272 /// within an alias template or during function template argument deduction),
4273 /// we store a trailing array of partially-substituted TemplateArguments,
4274 /// and this is the length of that array.
4275 unsigned Length;
4276
4277 /// The parameter pack.
4278 NamedDecl *Pack = nullptr;
4279
4280 /// Create an expression that computes the length of
4281 /// the given parameter pack.
4282 SizeOfPackExpr(QualType SizeType, SourceLocation OperatorLoc, NamedDecl *Pack,
4283 SourceLocation PackLoc, SourceLocation RParenLoc,
4284 std::optional<unsigned> Length,
4285 ArrayRef<TemplateArgument> PartialArgs)
4286 : Expr(SizeOfPackExprClass, SizeType, VK_PRValue, OK_Ordinary),
4287 OperatorLoc(OperatorLoc), PackLoc(PackLoc), RParenLoc(RParenLoc),
4288 Length(Length ? *Length : PartialArgs.size()), Pack(Pack) {
4289 assert((!Length || PartialArgs.empty()) &&
4290 "have partial args for non-dependent sizeof... expression");
4291 auto *Args = getTrailingObjects<TemplateArgument>();
4292 std::uninitialized_copy(PartialArgs.begin(), PartialArgs.end(), Args);
4293 setDependence(Length ? ExprDependence::None
4294 : ExprDependence::ValueInstantiation);
4295 }
4296
4297 /// Create an empty expression.
4298 SizeOfPackExpr(EmptyShell Empty, unsigned NumPartialArgs)
4299 : Expr(SizeOfPackExprClass, Empty), Length(NumPartialArgs) {}
4300
4301public:
4302 static SizeOfPackExpr *
4303 Create(ASTContext &Context, SourceLocation OperatorLoc, NamedDecl *Pack,
4304 SourceLocation PackLoc, SourceLocation RParenLoc,
4305 std::optional<unsigned> Length = std::nullopt,
4306 ArrayRef<TemplateArgument> PartialArgs = std::nullopt);
4307 static SizeOfPackExpr *CreateDeserialized(ASTContext &Context,
4308 unsigned NumPartialArgs);
4309
4310 /// Determine the location of the 'sizeof' keyword.
4311 SourceLocation getOperatorLoc() const { return OperatorLoc; }
4312
4313 /// Determine the location of the parameter pack.
4314 SourceLocation getPackLoc() const { return PackLoc; }
4315
4316 /// Determine the location of the right parenthesis.
4317 SourceLocation getRParenLoc() const { return RParenLoc; }
4318
4319 /// Retrieve the parameter pack.
4320 NamedDecl *getPack() const { return Pack; }
4321
4322 /// Retrieve the length of the parameter pack.
4323 ///
4324 /// This routine may only be invoked when the expression is not
4325 /// value-dependent.
4326 unsigned getPackLength() const {
4327 assert(!isValueDependent() &&
4328 "Cannot get the length of a value-dependent pack size expression");
4329 return Length;
4330 }
4331
4332 /// Determine whether this represents a partially-substituted sizeof...
4333 /// expression, such as is produced for:
4334 ///
4335 /// template<typename ...Ts> using X = int[sizeof...(Ts)];
4336 /// template<typename ...Us> void f(X<Us..., 1, 2, 3, Us...>);
4338 return isValueDependent() && Length;
4339 }
4340
4341 /// Get
4343 assert(isPartiallySubstituted());
4344 const auto *Args = getTrailingObjects<TemplateArgument>();
4345 return llvm::ArrayRef(Args, Args + Length);
4346 }
4347
4348 SourceLocation getBeginLoc() const LLVM_READONLY { return OperatorLoc; }
4349 SourceLocation getEndLoc() const LLVM_READONLY { return RParenLoc; }
4350
4351 static bool classof(const Stmt *T) {
4352 return T->getStmtClass() == SizeOfPackExprClass;
4353 }
4354
4355 // Iterators
4358 }
4359
4362 }
4363};
4364
4366 : public Expr,
4367 private llvm::TrailingObjects<PackIndexingExpr, Expr *> {
4368 friend class ASTStmtReader;
4369 friend class ASTStmtWriter;
4370 friend TrailingObjects;
4371
4372 SourceLocation EllipsisLoc;
4373
4374 // The location of the closing bracket
4375 SourceLocation RSquareLoc;
4376
4377 // The pack being indexed, followed by the index
4378 Stmt *SubExprs[2];
4379
4380 size_t TransformedExpressions;
4381
4383 SourceLocation RSquareLoc, Expr *PackIdExpr, Expr *IndexExpr,
4384 ArrayRef<Expr *> SubstitutedExprs = {})
4385 : Expr(PackIndexingExprClass, Type, VK_LValue, OK_Ordinary),
4386 EllipsisLoc(EllipsisLoc), RSquareLoc(RSquareLoc),
4387 SubExprs{PackIdExpr, IndexExpr},
4388 TransformedExpressions(SubstitutedExprs.size()) {
4389
4390 auto *Exprs = getTrailingObjects<Expr *>();
4391 std::uninitialized_copy(SubstitutedExprs.begin(), SubstitutedExprs.end(),
4392 Exprs);
4393
4397 }
4398
4399 /// Create an empty expression.
4400 PackIndexingExpr(EmptyShell Empty) : Expr(PackIndexingExprClass, Empty) {}
4401
4402 unsigned numTrailingObjects(OverloadToken<Expr *>) const {
4403 return TransformedExpressions;
4404 }
4405
4406public:
4407 static PackIndexingExpr *Create(ASTContext &Context,
4408 SourceLocation EllipsisLoc,
4409 SourceLocation RSquareLoc, Expr *PackIdExpr,
4410 Expr *IndexExpr, std::optional<int64_t> Index,
4411 ArrayRef<Expr *> SubstitutedExprs = {});
4412 static PackIndexingExpr *CreateDeserialized(ASTContext &Context,
4413 unsigned NumTransformedExprs);
4414
4415 /// Determine the location of the 'sizeof' keyword.
4416 SourceLocation getEllipsisLoc() const { return EllipsisLoc; }
4417
4418 /// Determine the location of the parameter pack.
4419 SourceLocation getPackLoc() const { return SubExprs[0]->getBeginLoc(); }
4420
4421 /// Determine the location of the right parenthesis.
4422 SourceLocation getRSquareLoc() const { return RSquareLoc; }
4423
4424 SourceLocation getBeginLoc() const LLVM_READONLY { return getPackLoc(); }
4425 SourceLocation getEndLoc() const LLVM_READONLY { return RSquareLoc; }
4426
4427 Expr *getPackIdExpression() const { return cast<Expr>(SubExprs[0]); }
4428
4429 NamedDecl *getPackDecl() const;
4430
4431 Expr *getIndexExpr() const { return cast<Expr>(SubExprs[1]); }
4432
4433 std::optional<unsigned> getSelectedIndex() const {
4435 return std::nullopt;
4436 ConstantExpr *CE = cast<ConstantExpr>(getIndexExpr());
4437 auto Index = CE->getResultAsAPSInt();
4438 assert(Index.isNonNegative() && "Invalid index");
4439 return static_cast<unsigned>(Index.getExtValue());
4440 }
4441
4443 std::optional<unsigned> Index = getSelectedIndex();
4444 assert(Index && "extracting the indexed expression of a dependant pack");
4445 return getTrailingObjects<Expr *>()[*Index];
4446 }
4447
4449 return {getTrailingObjects<Expr *>(), TransformedExpressions};
4450 }
4451
4452 static bool classof(const Stmt *T) {
4453 return T->getStmtClass() == PackIndexingExprClass;
4454 }
4455
4456 // Iterators
4457 child_range children() { return child_range(SubExprs, SubExprs + 2); }
4458
4460 return const_child_range(SubExprs, SubExprs + 2);
4461 }
4462};
4463
4464/// Represents a reference to a non-type template parameter
4465/// that has been substituted with a template argument.
4467 friend class ASTReader;
4468 friend class ASTStmtReader;
4469
4470 /// The replacement expression.
4471 Stmt *Replacement;
4472
4473 /// The associated declaration and a flag indicating if it was a reference
4474 /// parameter. For class NTTPs, we can't determine that based on the value
4475 /// category alone.
4476 llvm::PointerIntPair<Decl *, 1, bool> AssociatedDeclAndRef;
4477
4478 unsigned Index : 15;
4479 unsigned PackIndex : 16;
4480
4482 : Expr(SubstNonTypeTemplateParmExprClass, Empty) {}
4483
4484public:
4486 SourceLocation Loc, Expr *Replacement,
4487 Decl *AssociatedDecl, unsigned Index,
4488 std::optional<unsigned> PackIndex, bool RefParam)
4489 : Expr(SubstNonTypeTemplateParmExprClass, Ty, ValueKind, OK_Ordinary),
4490 Replacement(Replacement),
4491 AssociatedDeclAndRef(AssociatedDecl, RefParam), Index(Index),
4492 PackIndex(PackIndex ? *PackIndex + 1 : 0) {
4493 assert(AssociatedDecl != nullptr);
4496 }
4497
4499 return SubstNonTypeTemplateParmExprBits.NameLoc;
4500 }
4503
4504 Expr *getReplacement() const { return cast<Expr>(Replacement); }
4505
4506 /// A template-like entity which owns the whole pattern being substituted.
4507 /// This will own a set of template parameters.
4508 Decl *getAssociatedDecl() const { return AssociatedDeclAndRef.getPointer(); }
4509
4510 /// Returns the index of the replaced parameter in the associated declaration.
4511 /// This should match the result of `getParameter()->getIndex()`.
4512 unsigned getIndex() const { return Index; }
4513
4514 std::optional<unsigned> getPackIndex() const {
4515 if (PackIndex == 0)
4516 return std::nullopt;
4517 return PackIndex - 1;
4518 }
4519
4521
4522 bool isReferenceParameter() const { return AssociatedDeclAndRef.getInt(); }
4523
4524 /// Determine the substituted type of the template parameter.
4525 QualType getParameterType(const ASTContext &Ctx) const;
4526
4527 static bool classof(const Stmt *s) {
4528 return s->getStmtClass() == SubstNonTypeTemplateParmExprClass;
4529 }
4530
4531 // Iterators
4532 child_range children() { return child_range(&Replacement, &Replacement + 1); }
4533
4535 return const_child_range(&Replacement, &Replacement + 1);
4536 }
4537};
4538
4539/// Represents a reference to a non-type template parameter pack that
4540/// has been substituted with a non-template argument pack.
4541///
4542/// When a pack expansion in the source code contains multiple parameter packs
4543/// and those parameter packs correspond to different levels of template
4544/// parameter lists, this node is used to represent a non-type template
4545/// parameter pack from an outer level, which has already had its argument pack
4546/// substituted but that still lives within a pack expansion that itself
4547/// could not be instantiated. When actually performing a substitution into
4548/// that pack expansion (e.g., when all template parameters have corresponding
4549/// arguments), this type will be replaced with the appropriate underlying
4550/// expression at the current pack substitution index.
4552 friend class ASTReader;
4553 friend class ASTStmtReader;
4554
4555 /// The non-type template parameter pack itself.
4556 Decl *AssociatedDecl;
4557
4558 /// A pointer to the set of template arguments that this
4559 /// parameter pack is instantiated with.
4560 const TemplateArgument *Arguments;
4561
4562 /// The number of template arguments in \c Arguments.
4563 unsigned NumArguments : 16;
4564
4565 unsigned Index : 16;
4566
4567 /// The location of the non-type template parameter pack reference.
4568 SourceLocation NameLoc;
4569
4571 : Expr(SubstNonTypeTemplateParmPackExprClass, Empty) {}
4572
4573public:
4575 SourceLocation NameLoc,
4576 const TemplateArgument &ArgPack,
4577 Decl *AssociatedDecl, unsigned Index);
4578
4579 /// A template-like entity which owns the whole pattern being substituted.
4580 /// This will own a set of template parameters.
4581 Decl *getAssociatedDecl() const { return AssociatedDecl; }
4582
4583 /// Returns the index of the replaced parameter in the associated declaration.
4584 /// This should match the result of `getParameterPack()->getIndex()`.
4585 unsigned getIndex() const { return Index; }
4586
4587 /// Retrieve the non-type template parameter pack being substituted.
4589
4590 /// Retrieve the location of the parameter pack name.
4591 SourceLocation getParameterPackLocation() const { return NameLoc; }
4592
4593 /// Retrieve the template argument pack containing the substituted
4594 /// template arguments.
4596
4597 SourceLocation getBeginLoc() const LLVM_READONLY { return NameLoc; }
4598 SourceLocation getEndLoc() const LLVM_READONLY { return NameLoc; }
4599
4600 static bool classof(const Stmt *T) {
4601 return T->getStmtClass() == SubstNonTypeTemplateParmPackExprClass;
4602 }
4603
4604 // Iterators
4607 }
4608
4611 }
4612};
4613
4614/// Represents a reference to a function parameter pack or init-capture pack
4615/// that has been substituted but not yet expanded.
4616///
4617/// When a pack expansion contains multiple parameter packs at different levels,
4618/// this node is used to represent a function parameter pack at an outer level
4619/// which we have already substituted to refer to expanded parameters, but where
4620/// the containing pack expansion cannot yet be expanded.
4621///
4622/// \code
4623/// template<typename...Ts> struct S {
4624/// template<typename...Us> auto f(Ts ...ts) -> decltype(g(Us(ts)...));
4625/// };
4626/// template struct S<int, int>;
4627/// \endcode
4629 : public Expr,
4630 private llvm::TrailingObjects<FunctionParmPackExpr, VarDecl *> {
4631 friend class ASTReader;
4632 friend class ASTStmtReader;
4633 friend TrailingObjects;
4634
4635 /// The function parameter pack which was referenced.
4636 VarDecl *ParamPack;
4637
4638 /// The location of the function parameter pack reference.
4639 SourceLocation NameLoc;
4640
4641 /// The number of expansions of this pack.
4642 unsigned NumParameters;
4643
4645 SourceLocation NameLoc, unsigned NumParams,
4646 VarDecl *const *Params);
4647
4648public:
4649 static FunctionParmPackExpr *Create(const ASTContext &Context, QualType T,
4650 VarDecl *ParamPack,
4651 SourceLocation NameLoc,
4652 ArrayRef<VarDecl *> Params);
4653 static FunctionParmPackExpr *CreateEmpty(const ASTContext &Context,
4654 unsigned NumParams);
4655
4656 /// Get the parameter pack which this expression refers to.
4657 VarDecl *getParameterPack() const { return ParamPack; }
4658
4659 /// Get the location of the parameter pack.
4660 SourceLocation getParameterPackLocation() const { return NameLoc; }
4661
4662 /// Iterators over the parameters which the parameter pack expanded
4663 /// into.
4664 using iterator = VarDecl * const *;
4665 iterator begin() const { return getTrailingObjects<VarDecl *>(); }
4666 iterator end() const { return begin() + NumParameters; }
4667
4668 /// Get the number of parameters in this parameter pack.
4669 unsigned getNumExpansions() const { return NumParameters; }
4670
4671 /// Get an expansion of the parameter pack by index.
4672 VarDecl *getExpansion(unsigned I) const { return begin()[I]; }
4673
4674 SourceLocation getBeginLoc() const LLVM_READONLY { return NameLoc; }
4675 SourceLocation getEndLoc() const LLVM_READONLY { return NameLoc; }
4676
4677 static bool classof(const Stmt *T) {
4678 return T->getStmtClass() == FunctionParmPackExprClass;
4679 }
4680
4683 }
4684
4687 }
4688};
4689
4690/// Represents a prvalue temporary that is written into memory so that
4691/// a reference can bind to it.
4692///
4693/// Prvalue expressions are materialized when they need to have an address
4694/// in memory for a reference to bind to. This happens when binding a
4695/// reference to the result of a conversion, e.g.,
4696///
4697/// \code
4698/// const int &r = 1.0;
4699/// \endcode
4700///
4701/// Here, 1.0 is implicitly converted to an \c int. That resulting \c int is
4702/// then materialized via a \c MaterializeTemporaryExpr, and the reference
4703/// binds to the temporary. \c MaterializeTemporaryExprs are always glvalues
4704/// (either an lvalue or an xvalue, depending on the kind of reference binding
4705/// to it), maintaining the invariant that references always bind to glvalues.
4706///
4707/// Reference binding and copy-elision can both extend the lifetime of a
4708/// temporary. When either happens, the expression will also track the
4709/// declaration which is responsible for the lifetime extension.
4711private:
4712 friend class ASTStmtReader;
4713 friend class ASTStmtWriter;
4714
4715 llvm::PointerUnion<Stmt *, LifetimeExtendedTemporaryDecl *> State;
4716
4717public:
4719 bool BoundToLvalueReference,
4720 LifetimeExtendedTemporaryDecl *MTD = nullptr);
4721
4723 : Expr(MaterializeTemporaryExprClass, Empty) {}
4724
4725 /// Retrieve the temporary-generating subexpression whose value will
4726 /// be materialized into a glvalue.
4727 Expr *getSubExpr() const {
4728 return cast<Expr>(
4729 State.is<Stmt *>()
4730 ? State.get<Stmt *>()
4732 }
4733
4734 /// Retrieve the storage duration for the materialized temporary.
4736 return State.is<Stmt *>() ? SD_FullExpression
4737 : State.get<LifetimeExtendedTemporaryDecl *>()
4739 }
4740
4741 /// Get the storage for the constant value of a materialized temporary
4742 /// of static storage duration.
4743 APValue *getOrCreateValue(bool MayCreate) const {
4744 assert(State.is<LifetimeExtendedTemporaryDecl *>() &&
4745 "the temporary has not been lifetime extended");
4746 return State.get<LifetimeExtendedTemporaryDecl *>()->getOrCreateValue(
4747 MayCreate);
4748 }
4749
4751 return State.dyn_cast<LifetimeExtendedTemporaryDecl *>();
4752 }
4755 return State.dyn_cast<LifetimeExtendedTemporaryDecl *>();
4756 }
4757
4758 /// Get the declaration which triggered the lifetime-extension of this
4759 /// temporary, if any.
4761 return State.is<Stmt *>() ? nullptr
4762 : State.get<LifetimeExtendedTemporaryDecl *>()
4763 ->getExtendingDecl();
4764 }
4766 return const_cast<MaterializeTemporaryExpr *>(this)->getExtendingDecl();
4767 }
4768
4769 void setExtendingDecl(ValueDecl *ExtendedBy, unsigned ManglingNumber);
4770
4771 unsigned getManglingNumber() const {
4772 return State.is<Stmt *>() ? 0
4773 : State.get<LifetimeExtendedTemporaryDecl *>()
4775 }
4776
4777 /// Determine whether this materialized temporary is bound to an
4778 /// lvalue reference; otherwise, it's bound to an rvalue reference.
4779 bool isBoundToLvalueReference() const { return isLValue(); }
4780
4781 /// Determine whether this temporary object is usable in constant
4782 /// expressions, as specified in C++20 [expr.const]p4.
4783 bool isUsableInConstantExpressions(const ASTContext &Context) const;
4784
4785 SourceLocation getBeginLoc() const LLVM_READONLY {
4786 return getSubExpr()->getBeginLoc();
4787 }
4788
4789 SourceLocation getEndLoc() const LLVM_READONLY {
4790 return getSubExpr()->getEndLoc();
4791 }
4792
4793 static bool classof(const Stmt *T) {
4794 return T->getStmtClass() == MaterializeTemporaryExprClass;
4795 }
4796
4797 // Iterators
4799 return State.is<Stmt *>()
4800 ? child_range(State.getAddrOfPtr1(), State.getAddrOfPtr1() + 1)
4801 : State.get<LifetimeExtendedTemporaryDecl *>()->childrenExpr();
4802 }
4803
4805 return State.is<Stmt *>()
4806 ? const_child_range(State.getAddrOfPtr1(),
4807 State.getAddrOfPtr1() + 1)
4808 : const_cast<const LifetimeExtendedTemporaryDecl *>(
4809 State.get<LifetimeExtendedTemporaryDecl *>())
4810 ->childrenExpr();
4811 }
4812};
4813
4814/// Represents a folding of a pack over an operator.
4815///
4816/// This expression is always dependent and represents a pack expansion of the
4817/// forms:
4818///
4819/// ( expr op ... )
4820/// ( ... op expr )
4821/// ( expr op ... op expr )
4822class CXXFoldExpr : public Expr {
4823 friend class ASTStmtReader;
4824 friend class ASTStmtWriter;
4825
4826 enum SubExpr { Callee, LHS, RHS, Count };
4827
4828 SourceLocation LParenLoc;
4829 SourceLocation EllipsisLoc;
4830 SourceLocation RParenLoc;
4831 // When 0, the number of expansions is not known. Otherwise, this is one more
4832 // than the number of expansions.
4833 unsigned NumExpansions;
4834 Stmt *SubExprs[SubExpr::Count];
4835 BinaryOperatorKind Opcode;
4836
4837public:
4839 SourceLocation LParenLoc, Expr *LHS, BinaryOperatorKind Opcode,
4840 SourceLocation EllipsisLoc, Expr *RHS, SourceLocation RParenLoc,
4841 std::optional<unsigned> NumExpansions)
4842 : Expr(CXXFoldExprClass, T, VK_PRValue, OK_Ordinary),
4843 LParenLoc(LParenLoc), EllipsisLoc(EllipsisLoc), RParenLoc(RParenLoc),
4844 NumExpansions(NumExpansions ? *NumExpansions + 1 : 0), Opcode(Opcode) {
4845 SubExprs[SubExpr::Callee] = Callee;
4846 SubExprs[SubExpr::LHS] = LHS;
4847 SubExprs[SubExpr::RHS] = RHS;
4849 }
4850
4851 CXXFoldExpr(EmptyShell Empty) : Expr(CXXFoldExprClass, Empty) {}
4852
4854 return static_cast<UnresolvedLookupExpr *>(SubExprs[SubExpr::Callee]);
4855 }
4856 Expr *getLHS() const { return static_cast<Expr*>(SubExprs[SubExpr::LHS]); }
4857 Expr *getRHS() const { return static_cast<Expr*>(SubExprs[SubExpr::RHS]); }
4858
4859 /// Does this produce a right-associated sequence of operators?
4860 bool isRightFold() const {
4862 }
4863
4864 /// Does this produce a left-associated sequence of operators?
4865 bool isLeftFold() const { return !isRightFold(); }
4866
4867 /// Get the pattern, that is, the operand that contains an unexpanded pack.
4868 Expr *getPattern() const { return isLeftFold() ? getRHS() : getLHS(); }
4869
4870 /// Get the operand that doesn't contain a pack, for a binary fold.
4871 Expr *getInit() const { return isLeftFold() ? getLHS() : getRHS(); }
4872
4873 SourceLocation getLParenLoc() const { return LParenLoc; }
4874 SourceLocation getRParenLoc() const { return RParenLoc; }
4875 SourceLocation getEllipsisLoc() const { return EllipsisLoc; }
4876 BinaryOperatorKind getOperator() const { return Opcode; }
4877
4878 std::optional<unsigned> getNumExpansions() const {
4879 if (NumExpansions)
4880 return NumExpansions - 1;
4881 return std::nullopt;
4882 }
4883
4884 SourceLocation getBeginLoc() const LLVM_READONLY {
4885 if (LParenLoc.isValid())
4886 return LParenLoc;
4887 if (isLeftFold())
4888 return getEllipsisLoc();
4889 return getLHS()->getBeginLoc();
4890 }
4891
4892 SourceLocation getEndLoc() const LLVM_READONLY {
4893 if (RParenLoc.isValid())
4894 return RParenLoc;
4895 if (isRightFold())
4896 return getEllipsisLoc();
4897 return getRHS()->getEndLoc();
4898 }
4899
4900 static bool classof(const Stmt *T) {
4901 return T->getStmtClass() == CXXFoldExprClass;
4902 }
4903
4904 // Iterators
4906 return child_range(SubExprs, SubExprs + SubExpr::Count);
4907 }
4908
4910 return const_child_range(SubExprs, SubExprs + SubExpr::Count);
4911 }
4912};
4913
4914/// Represents a list-initialization with parenthesis.
4915///
4916/// As per P0960R3, this is a C++20 feature that allows aggregate to
4917/// be initialized with a parenthesized list of values:
4918/// ```
4919/// struct A {
4920/// int a;
4921/// double b;
4922/// };
4923///
4924/// void foo() {
4925/// A a1(0); // Well-formed in C++20
4926/// A a2(1.5, 1.0); // Well-formed in C++20
4927/// }
4928/// ```
4929/// It has some sort of similiarity to braced
4930/// list-initialization, with some differences such as
4931/// it allows narrowing conversion whilst braced
4932/// list-initialization doesn't.
4933/// ```
4934/// struct A {
4935/// char a;
4936/// };
4937/// void foo() {
4938/// A a(1.5); // Well-formed in C++20
4939/// A b{1.5}; // Ill-formed !
4940/// }
4941/// ```
4943 : public Expr,
4944 private llvm::TrailingObjects<CXXParenListInitExpr, Expr *> {
4945 friend class TrailingObjects;
4946 friend class ASTStmtReader;
4947 friend class ASTStmtWriter;
4948
4949 unsigned NumExprs;
4950 unsigned NumUserSpecifiedExprs;
4951 SourceLocation InitLoc, LParenLoc, RParenLoc;
4952 llvm::PointerUnion<Expr *, FieldDecl *> ArrayFillerOrUnionFieldInit;
4953
4955 unsigned NumUserSpecifiedExprs, SourceLocation InitLoc,
4956 SourceLocation LParenLoc, SourceLocation RParenLoc)
4957 : Expr(CXXParenListInitExprClass, T, getValueKindForType(T), OK_Ordinary),
4958 NumExprs(Args.size()), NumUserSpecifiedExprs(NumUserSpecifiedExprs),
4959 InitLoc(InitLoc), LParenLoc(LParenLoc), RParenLoc(RParenLoc) {
4960 std::copy(Args.begin(), Args.end(), getTrailingObjects<Expr *>());
4961 assert(NumExprs >= NumUserSpecifiedExprs &&
4962 "number of user specified inits is greater than the number of "
4963 "passed inits");
4965 }
4966
4967 size_t numTrailingObjects(OverloadToken<Expr *>) const { return NumExprs; }
4968
4969public:
4970 static CXXParenListInitExpr *
4971 Create(ASTContext &C, ArrayRef<Expr *> Args, QualType T,
4972 unsigned NumUserSpecifiedExprs, SourceLocation InitLoc,
4973 SourceLocation LParenLoc, SourceLocation RParenLoc);
4974
4975 static CXXParenListInitExpr *CreateEmpty(ASTContext &C, unsigned numExprs,
4976 EmptyShell Empty);
4977
4978 explicit CXXParenListInitExpr(EmptyShell Empty, unsigned NumExprs)
4979 : Expr(CXXParenListInitExprClass, Empty), NumExprs(NumExprs),
4980 NumUserSpecifiedExprs(0) {}
4981
4983
4985 return ArrayRef(getTrailingObjects<Expr *>(), NumExprs);
4986 }
4987
4989 return ArrayRef(getTrailingObjects<Expr *>(), NumExprs);
4990 }
4991
4993 return ArrayRef(getTrailingObjects<Expr *>(), NumUserSpecifiedExprs);
4994 }
4995
4997 return ArrayRef(getTrailingObjects<Expr *>(), NumUserSpecifiedExprs);
4998 }
4999
5000 SourceLocation getBeginLoc() const LLVM_READONLY { return LParenLoc; }
5001
5002 SourceLocation getEndLoc() const LLVM_READONLY { return RParenLoc; }
5003
5004 SourceLocation getInitLoc() const LLVM_READONLY { return InitLoc; }
5005
5006 SourceRange getSourceRange() const LLVM_READONLY {
5007 return SourceRange(getBeginLoc(), getEndLoc());
5008 }
5009
5010 void setArrayFiller(Expr *E) { ArrayFillerOrUnionFieldInit = E; }
5011
5013 return ArrayFillerOrUnionFieldInit.dyn_cast<Expr *>();
5014 }
5015
5016 const Expr *getArrayFiller() const {
5017 return ArrayFillerOrUnionFieldInit.dyn_cast<Expr *>();
5018 }
5019
5021 ArrayFillerOrUnionFieldInit = FD;
5022 }
5023
5025 return ArrayFillerOrUnionFieldInit.dyn_cast<FieldDecl *>();
5026 }
5027
5029 return ArrayFillerOrUnionFieldInit.dyn_cast<FieldDecl *>();
5030 }
5031
5033 Stmt **Begin = reinterpret_cast<Stmt **>(getTrailingObjects<Expr *>());
5034 return child_range(Begin, Begin + NumExprs);
5035 }
5036
5038 Stmt *const *Begin =
5039 reinterpret_cast<Stmt *const *>(getTrailingObjects<Expr *>());
5040 return const_child_range(Begin, Begin + NumExprs);
5041 }
5042
5043 static bool classof(const Stmt *T) {
5044 return T->getStmtClass() == CXXParenListInitExprClass;
5045 }
5046};
5047
5048/// Represents an expression that might suspend coroutine execution;
5049/// either a co_await or co_yield expression.
5050///
5051/// Evaluation of this expression first evaluates its 'ready' expression. If
5052/// that returns 'false':
5053/// -- execution of the coroutine is suspended
5054/// -- the 'suspend' expression is evaluated
5055/// -- if the 'suspend' expression returns 'false', the coroutine is
5056/// resumed
5057/// -- otherwise, control passes back to the resumer.
5058/// If the coroutine is not suspended, or when it is resumed, the 'resume'
5059/// expression is evaluated, and its result is the result of the overall
5060/// expression.
5062 friend class ASTStmtReader;
5063
5064 SourceLocation KeywordLoc;
5065
5066 enum SubExpr { Operand, Common, Ready, Suspend, Resume, Count };
5067
5068 Stmt *SubExprs[SubExpr::Count];
5069 OpaqueValueExpr *OpaqueValue = nullptr;
5070
5071public:
5072 // These types correspond to the three C++ 'await_suspend' return variants
5074
5076 Expr *Common, Expr *Ready, Expr *Suspend, Expr *Resume,
5077 OpaqueValueExpr *OpaqueValue)
5078 : Expr(SC, Resume->getType(), Resume->getValueKind(),
5079 Resume->getObjectKind()),
5080 KeywordLoc(KeywordLoc), OpaqueValue(OpaqueValue) {
5081 SubExprs[SubExpr::Operand] = Operand;
5082 SubExprs[SubExpr::Common] = Common;
5083 SubExprs[SubExpr::Ready] = Ready;
5084 SubExprs[SubExpr::Suspend] = Suspend;
5085 SubExprs[SubExpr::Resume] = Resume;
5087 }
5088
5090 Expr *Operand, Expr *Common)
5091 : Expr(SC, Ty, VK_PRValue, OK_Ordinary), KeywordLoc(KeywordLoc) {
5092 assert(Common->isTypeDependent() && Ty->isDependentType() &&
5093 "wrong constructor for non-dependent co_await/co_yield expression");
5094 SubExprs[SubExpr::Operand] = Operand;
5095 SubExprs[SubExpr::Common] = Common;
5096 SubExprs[SubExpr::Ready] = nullptr;
5097 SubExprs[SubExpr::Suspend] = nullptr;
5098 SubExprs[SubExpr::Resume] = nullptr;
5100 }
5101
5103 SubExprs[SubExpr::Operand] = nullptr;
5104 SubExprs[SubExpr::Common] = nullptr;
5105 SubExprs[SubExpr::Ready] = nullptr;
5106 SubExprs[SubExpr::Suspend] = nullptr;
5107 SubExprs[SubExpr::Resume] = nullptr;
5108 }
5109
5111 return static_cast<Expr*>(SubExprs[SubExpr::Common]);
5112 }
5113
5114 /// getOpaqueValue - Return the opaque value placeholder.
5115 OpaqueValueExpr *getOpaqueValue() const { return OpaqueValue; }
5116
5118 return static_cast<Expr*>(SubExprs[SubExpr::Ready]);
5119 }
5120
5122 return static_cast<Expr*>(SubExprs[SubExpr::Suspend]);
5123 }
5124
5126 return static_cast<Expr*>(SubExprs[SubExpr::Resume]);
5127 }
5128
5129 // The syntactic operand written in the code
5130 Expr *getOperand() const {
5131 return static_cast<Expr *>(SubExprs[SubExpr::Operand]);
5132 }
5133
5135 auto *SuspendExpr = getSuspendExpr();
5136 assert(SuspendExpr);
5137
5138 auto SuspendType = SuspendExpr->getType();
5139
5140 if (SuspendType->isVoidType())
5142 if (SuspendType->isBooleanType())
5144
5145 // Void pointer is the type of handle.address(), which is returned
5146 // from the await suspend wrapper so that the temporary coroutine handle
5147 // value won't go to the frame by mistake
5148 assert(SuspendType->isVoidPointerType());
5150 }
5151
5152 SourceLocation getKeywordLoc() const { return KeywordLoc; }
5153
5154 SourceLocation getBeginLoc() const LLVM_READONLY { return KeywordLoc; }
5155
5156 SourceLocation getEndLoc() const LLVM_READONLY {
5157 return getOperand()->getEndLoc();
5158 }
5159
5161 return child_range(SubExprs, SubExprs + SubExpr::Count);
5162 }
5163
5165 return const_child_range(SubExprs, SubExprs + SubExpr::Count);
5166 }
5167
5168 static bool classof(const Stmt *T) {
5169 return T->getStmtClass() == CoawaitExprClass ||
5170 T->getStmtClass() == CoyieldExprClass;
5171 }
5172};
5173
5174/// Represents a 'co_await' expression.
5176 friend class ASTStmtReader;
5177
5178public:
5179 CoawaitExpr(SourceLocation CoawaitLoc, Expr *Operand, Expr *Common,
5180 Expr *Ready, Expr *Suspend, Expr *Resume,
5181 OpaqueValueExpr *OpaqueValue, bool IsImplicit = false)
5182 : CoroutineSuspendExpr(CoawaitExprClass, CoawaitLoc, Operand, Common,
5183 Ready, Suspend, Resume, OpaqueValue) {
5184 CoawaitBits.IsImplicit = IsImplicit;
5185 }
5186
5187 CoawaitExpr(SourceLocation CoawaitLoc, QualType Ty, Expr *Operand,
5188 Expr *Common, bool IsImplicit = false)
5189 : CoroutineSuspendExpr(CoawaitExprClass, CoawaitLoc, Ty, Operand,
5190 Common) {
5191 CoawaitBits.IsImplicit = IsImplicit;
5192 }
5193
5195 : CoroutineSuspendExpr(CoawaitExprClass, Empty) {}
5196
5197 bool isImplicit() const { return CoawaitBits.IsImplicit; }
5198 void setIsImplicit(bool value = true) { CoawaitBits.IsImplicit = value; }
5199
5200 static bool classof(const Stmt *T) {
5201 return T->getStmtClass() == CoawaitExprClass;
5202 }
5203};
5204
5205/// Represents a 'co_await' expression while the type of the promise
5206/// is dependent.
5208 friend class ASTStmtReader;
5209
5210 SourceLocation KeywordLoc;
5211 Stmt *SubExprs[2];
5212
5213public:
5215 UnresolvedLookupExpr *OpCoawait)
5216 : Expr(DependentCoawaitExprClass, Ty, VK_PRValue, OK_Ordinary),
5217 KeywordLoc(KeywordLoc) {
5218 // NOTE: A co_await expression is dependent on the coroutines promise
5219 // type and may be dependent even when the `Op` expression is not.
5220 assert(Ty->isDependentType() &&
5221 "wrong constructor for non-dependent co_await/co_yield expression");
5222 SubExprs[0] = Op;
5223 SubExprs[1] = OpCoawait;
5225 }
5226
5228 : Expr(DependentCoawaitExprClass, Empty) {}
5229
5230 Expr *getOperand() const { return cast<Expr>(SubExprs[0]); }
5231
5233 return cast<UnresolvedLookupExpr>(SubExprs[1]);
5234 }
5235
5236 SourceLocation getKeywordLoc() const { return KeywordLoc; }
5237
5238 SourceLocation getBeginLoc() const LLVM_READONLY { return KeywordLoc; }
5239
5240 SourceLocation getEndLoc() const LLVM_READONLY {
5241 return getOperand()->getEndLoc();
5242 }
5243
5244 child_range children() { return child_range(SubExprs, SubExprs + 2); }
5245
5247 return const_child_range(SubExprs, SubExprs + 2);
5248 }
5249
5250 static bool classof(const Stmt *T) {
5251 return T->getStmtClass() == DependentCoawaitExprClass;
5252 }
5253};
5254
5255/// Represents a 'co_yield' expression.
5257 friend class ASTStmtReader;
5258
5259public:
5260 CoyieldExpr(SourceLocation CoyieldLoc, Expr *Operand, Expr *Common,
5261 Expr *Ready, Expr *Suspend, Expr *Resume,
5262 OpaqueValueExpr *OpaqueValue)
5263 : CoroutineSuspendExpr(CoyieldExprClass, CoyieldLoc, Operand, Common,
5264 Ready, Suspend, Resume, OpaqueValue) {}
5265 CoyieldExpr(SourceLocation CoyieldLoc, QualType Ty, Expr *Operand,
5266 Expr *Common)
5267 : CoroutineSuspendExpr(CoyieldExprClass, CoyieldLoc, Ty, Operand,
5268 Common) {}
5270 : CoroutineSuspendExpr(CoyieldExprClass, Empty) {}
5271
5272 static bool classof(const Stmt *T) {
5273 return T->getStmtClass() == CoyieldExprClass;
5274 }
5275};
5276
5277/// Represents a C++2a __builtin_bit_cast(T, v) expression. Used to implement
5278/// std::bit_cast. These can sometimes be evaluated as part of a constant
5279/// expression, but otherwise CodeGen to a simple memcpy in general.
5281 : public ExplicitCastExpr,
5282 private llvm::TrailingObjects<BuiltinBitCastExpr, CXXBaseSpecifier *> {
5283 friend class ASTStmtReader;
5284 friend class CastExpr;
5285 friend TrailingObjects;
5286
5287 SourceLocation KWLoc;
5288 SourceLocation RParenLoc;
5289
5290public:
5292 TypeSourceInfo *DstType, SourceLocation KWLoc,
5293 SourceLocation RParenLoc)
5294 : ExplicitCastExpr(BuiltinBitCastExprClass, T, VK, CK, SrcExpr, 0, false,
5295 DstType),
5296 KWLoc(KWLoc), RParenLoc(RParenLoc) {}
5298 : ExplicitCastExpr(BuiltinBitCastExprClass, Empty, 0, false) {}
5299
5300 SourceLocation getBeginLoc() const LLVM_READONLY { return KWLoc; }
5301 SourceLocation getEndLoc() const LLVM_READONLY { return RParenLoc; }
5302
5303 static bool classof(const Stmt *T) {
5304 return T->getStmtClass() == BuiltinBitCastExprClass;
5305 }
5306};
5307
5308} // namespace clang
5309
5310#endif // LLVM_CLANG_AST_EXPRCXX_H
This file provides AST data structures related to concepts.
#define V(N, I)
Definition: ASTContext.h:3285
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:754
SourceLocation Loc
Definition: SemaObjC.cpp:755
Defines the clang::SourceLocation class and associated facilities.
Defines various enumerations that describe declaration and type specifiers.
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:182
Reads an AST files chain containing the contents of a translation unit.
Definition: ASTReader.h:366
An Embarcadero array type trait, as used in the implementation of __array_rank and __array_extent.
Definition: ExprCXX.h:2848
ArrayTypeTraitExpr(SourceLocation loc, ArrayTypeTrait att, TypeSourceInfo *queried, uint64_t value, Expr *dimension, SourceLocation rparen, QualType ty)
Definition: ExprCXX.h:2871
uint64_t getValue() const
Definition: ExprCXX.h:2894
SourceLocation getEndLoc() const LLVM_READONLY
Definition: ExprCXX.h:2886
ArrayTypeTrait getTrait() const
Definition: ExprCXX.h:2888
QualType getQueriedType() const
Definition: ExprCXX.h:2890
Expr * getDimensionExpression() const
Definition: ExprCXX.h:2896
ArrayTypeTraitExpr(EmptyShell Empty)
Definition: ExprCXX.h:2882
child_range children()
Definition: ExprCXX.h:2903
const_child_range children() const
Definition: ExprCXX.h:2907
static bool classof(const Stmt *T)
Definition: ExprCXX.h:2898
TypeSourceInfo * getQueriedTypeSourceInfo() const
Definition: ExprCXX.h:2892
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprCXX.h:2885
StringRef getOpcodeStr() const
Definition: Expr.h:3905
Represents a C++2a __builtin_bit_cast(T, v) expression.
Definition: ExprCXX.h:5282
static bool classof(const Stmt *T)
Definition: ExprCXX.h:5303
SourceLocation getEndLoc() const LLVM_READONLY
Definition: ExprCXX.h:5301
BuiltinBitCastExpr(EmptyShell Empty)
Definition: ExprCXX.h:5297
BuiltinBitCastExpr(QualType T, ExprValueKind VK, CastKind CK, Expr *SrcExpr, TypeSourceInfo *DstType, SourceLocation KWLoc, SourceLocation RParenLoc)
Definition: ExprCXX.h:5291
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprCXX.h:5300
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:1872
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:848
Represents binding an expression to a temporary.
Definition: ExprCXX.h:1487
CXXBindTemporaryExpr(EmptyShell Empty)
Definition: ExprCXX.h:1499
static bool classof(const Stmt *T)
Definition: ExprCXX.h:1522
void setTemporary(CXXTemporary *T)
Definition: ExprCXX.h:1507
void setSubExpr(Expr *E)
Definition: ExprCXX.h:1511
const_child_range children() const
Definition: ExprCXX.h:1529
CXXTemporary * getTemporary()
Definition: ExprCXX.h:1505
const CXXTemporary * getTemporary() const
Definition: ExprCXX.h:1506
const Expr * getSubExpr() const
Definition: ExprCXX.h:1509
child_range children()
Definition: ExprCXX.h:1527
SourceLocation getEndLoc() const LLVM_READONLY
Definition: ExprCXX.h:1517
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprCXX.h:1513
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:835
Represents a call to a C++ constructor.
Definition: ExprCXX.h:1542
arg_iterator arg_begin()
Definition: ExprCXX.h:1671
SourceRange getParenOrBraceRange() const
Definition: ExprCXX.h:1710
void setElidable(bool E)
Definition: ExprCXX.h:1612
const_arg_iterator arg_end() const
Definition: ExprCXX.h:1674
void setStdInitListInitialization(bool V)
Definition: ExprCXX.h:1638
void setConstructionKind(CXXConstructionKind CK)
Definition: ExprCXX.h:1657
void setIsImmediateEscalating(bool Set)
Definition: ExprCXX.h:1704
llvm::iterator_range< arg_iterator > arg_range
Definition: ExprCXX.h:1663
bool isElidable() const
Whether this construction is elidable.
Definition: ExprCXX.h:1611
bool hadMultipleCandidates() const
Whether the referred constructor was resolved from an overloaded set having size greater than 1.
Definition: ExprCXX.h:1616
child_range children()
Definition: ExprCXX.h:1719
Expr * getArg(unsigned Arg)
Return the specified argument.
Definition: ExprCXX.h:1685
arg_range arguments()
Definition: ExprCXX.h:1666
bool isStdInitListInitialization() const
Whether this constructor call was written as list-initialization, but was interpreted as forming a st...
Definition: ExprCXX.h:1635
void setListInitialization(bool V)
Definition: ExprCXX.h:1627
bool isImmediateEscalating() const
Definition: ExprCXX.h:1700
bool requiresZeroInitialization() const
Whether this construction first requires zero-initialization before the initializer is called.
Definition: ExprCXX.h:1644
void setRequiresZeroInitialization(bool ZeroInit)
Definition: ExprCXX.h:1647
SourceLocation getLocation() const
Definition: ExprCXX.h:1607
const_arg_range arguments() const
Definition: ExprCXX.h:1667
arg_iterator arg_end()
Definition: ExprCXX.h:1672
static unsigned sizeOfTrailingObjects(unsigned NumArgs)
Return the size in bytes of the trailing objects.
Definition: ExprCXX.h:1588
void setArg(unsigned Arg, Expr *ArgExpr)
Set the specified argument.
Definition: ExprCXX.h:1695
SourceLocation getEndLoc() const LLVM_READONLY
Definition: ExprCXX.cpp:519
llvm::iterator_range< const_arg_iterator > const_arg_range
Definition: ExprCXX.h:1664
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprCXX.cpp:513
void setParenOrBraceRange(SourceRange Range)
Definition: ExprCXX.h:1711
const_arg_iterator arg_begin() const
Definition: ExprCXX.h:1673
const_child_range children() const
Definition: ExprCXX.h:1723
CXXConstructorDecl * getConstructor() const
Get the constructor that this expression will (ultimately) call.
Definition: ExprCXX.h:1605
bool isListInitialization() const
Whether this constructor call was written as list-initialization.
Definition: ExprCXX.h:1624
unsigned getNumArgs() const
Return the number of arguments to the constructor call.
Definition: ExprCXX.h:1682
CXXConstructionKind getConstructionKind() const
Determine whether this constructor is actually constructing a base class (rather than a complete obje...
Definition: ExprCXX.h:1653
void setHadMultipleCandidates(bool V)
Definition: ExprCXX.h:1619
void setLocation(SourceLocation Loc)
Definition: ExprCXX.h:1608
const Expr * getArg(unsigned Arg) const
Definition: ExprCXX.h:1689
const Expr *const * getArgs() const
Definition: ExprCXX.h:1677
static bool classof(const Stmt *T)
Definition: ExprCXX.h:1713
static CXXConstructExpr * CreateEmpty(const ASTContext &Ctx, unsigned NumArgs)
Create an empty C++ construction expression.
Definition: ExprCXX.cpp:1125
Represents a C++ constructor within a class.
Definition: DeclCXX.h:2535
A default argument (C++ [dcl.fct.default]).
Definition: ExprCXX.h:1264
SourceLocation getEndLoc() const
Definition: ExprCXX.h:1343
const_child_range children() const
Definition: ExprCXX.h:1356
SourceLocation getBeginLoc() const
Default argument expressions have no representation in the source, so they have an empty source range...
Definition: ExprCXX.h:1342
SourceLocation getUsedLocation() const
Retrieve the location where this default argument was actually used.
Definition: ExprCXX.h:1338
ParmVarDecl * getParam()
Definition: ExprCXX.h:1307
const ParmVarDecl * getParam() const
Definition: ExprCXX.h:1306
const Expr * getExpr() const
Definition: ExprCXX.h:1315
Expr * getAdjustedRewrittenExpr()
Definition: ExprCXX.cpp:985
const Expr * getAdjustedRewrittenExpr() const
Definition: ExprCXX.h:1330
DeclContext * getUsedContext()
Definition: ExprCXX.h:1335
SourceLocation getExprLoc() const
Definition: ExprCXX.h:1345
const DeclContext * getUsedContext() const
Definition: ExprCXX.h:1334
const Expr * getRewrittenExpr() const
Definition: ExprCXX.h:1323
static bool classof(const Stmt *T)
Definition: ExprCXX.h:1347
static CXXDefaultArgExpr * CreateEmpty(const ASTContext &C, bool HasRewrittenInit)
Definition: ExprCXX.cpp:962
child_range children()
Definition: ExprCXX.h:1352
bool hasRewrittenInit() const
Definition: ExprCXX.h:1309
A use of a default initializer in a constructor or in aggregate initialization.
Definition: ExprCXX.h:1371
static bool classof(const Stmt *T)
Definition: ExprCXX.h:1438
const DeclContext * getUsedContext() const
Definition: ExprCXX.h:1428
child_range children()
Definition: ExprCXX.h:1443
const FieldDecl * getField() const
Definition: ExprCXX.h:1406
const Expr * getRewrittenExpr() const
Retrieve the initializing expression with evaluated immediate calls, if any.
Definition: ExprCXX.h:1416
const Expr * getExpr() const
Definition: ExprCXX.h:1410
bool hasRewrittenInit() const
Definition: ExprCXX.h:1400
Expr * getExpr()
Get the initialization expression that will be used.
Definition: ExprCXX.cpp:1035
FieldDecl * getField()
Get the field whose initializer will be used.
Definition: ExprCXX.h:1405
static CXXDefaultInitExpr * CreateEmpty(const ASTContext &C, bool HasRewrittenInit)
Definition: ExprCXX.cpp:1016
Expr * getRewrittenExpr()
Retrieve the initializing expression with evaluated immediate calls, if any.
Definition: ExprCXX.h:1423
SourceLocation getBeginLoc() const
Definition: ExprCXX.h:1435
SourceLocation getEndLoc() const
Definition: ExprCXX.h:1436
const_child_range children() const
Definition: ExprCXX.h:1447
DeclContext * getUsedContext()
Definition: ExprCXX.h:1429
SourceLocation getUsedLocation() const
Retrieve the location where this default initializer expression was actually used.
Definition: ExprCXX.h:1433
Represents a delete expression for memory deallocation and destructor calls, e.g.
Definition: ExprCXX.h:2493
static bool classof(const Stmt *T)
Definition: ExprCXX.h:2548
child_range children()
Definition: ExprCXX.h:2553
FunctionDecl * getOperatorDelete() const
Definition: ExprCXX.h:2532
SourceLocation getEndLoc() const LLVM_READONLY
Definition: ExprCXX.h:2544
bool isArrayForm() const
Definition: ExprCXX.h:2519
CXXDeleteExpr(EmptyShell Shell)
Definition: ExprCXX.h:2516
const_child_range children() const
Definition: ExprCXX.h:2555
SourceLocation getBeginLoc() const
Definition: ExprCXX.h:2543
const Expr * getArgument() const
Definition: ExprCXX.h:2535
bool isGlobalDelete() const
Definition: ExprCXX.h:2518
Expr * getArgument()
Definition: ExprCXX.h:2534
bool doesUsualArrayDeleteWantSize() const
Answers whether the usual array deallocation function for the allocated type expects the size of the ...
Definition: ExprCXX.h:2528
QualType getDestroyedType() const
Retrieve the type being destroyed.
Definition: ExprCXX.cpp:291
bool isArrayFormAsWritten() const
Definition: ExprCXX.h:2520
CXXDeleteExpr(QualType Ty, bool GlobalDelete, bool ArrayForm, bool ArrayFormAsWritten, bool UsualArrayDeleteWantsSize, FunctionDecl *OperatorDelete, Expr *Arg, SourceLocation Loc)
Definition: ExprCXX.h:2503
Represents a C++ member access expression where the actual member referenced could not be resolved be...
Definition: ExprCXX.h:3676
bool isArrow() const
Determine whether this member expression used the '->' operator; otherwise, it used the '.
Definition: ExprCXX.h:3779
SourceLocation getOperatorLoc() const
Retrieve the location of the '->' or '.' operator.
Definition: ExprCXX.h:3782
SourceLocation getLAngleLoc() const
Retrieve the location of the left angle bracket starting the explicit template argument list followin...
Definition: ExprCXX.h:3834
SourceLocation getTemplateKeywordLoc() const
Retrieve the location of the template keyword preceding the member name, if any.
Definition: ExprCXX.h:3826
const DeclarationNameInfo & getMemberNameInfo() const
Retrieve the name of the member that this expression refers to.
Definition: ExprCXX.h:3813
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprCXX.h:3885
NestedNameSpecifier * getQualifier() const
Retrieve the nested-name-specifier that qualifies the member name.
Definition: ExprCXX.h:3787
void copyTemplateArgumentsInto(TemplateArgumentListInfo &List) const
Copies the template arguments (if present) into the given structure.
Definition: ExprCXX.h:3857
unsigned getNumTemplateArgs() const
Retrieve the number of template arguments provided as part of this template-id.
Definition: ExprCXX.h:3874
const TemplateArgumentLoc * getTemplateArgs() const
Retrieve the template arguments provided as part of this template-id.
Definition: ExprCXX.h:3865
bool hasExplicitTemplateArgs() const
Determines whether this member expression actually had a C++ template argument list explicitly specif...
Definition: ExprCXX.h:3853
static CXXDependentScopeMemberExpr * CreateEmpty(const ASTContext &Ctx, bool HasTemplateKWAndArgsInfo, unsigned NumTemplateArgs, bool HasFirstQualifierFoundInScope)
Definition: ExprCXX.cpp:1505
SourceLocation getMemberLoc() const
Definition: ExprCXX.h:3822
static bool classof(const Stmt *T)
Definition: ExprCXX.h:3899
SourceLocation getRAngleLoc() const
Retrieve the location of the right angle bracket ending the explicit template argument list following...
Definition: ExprCXX.h:3842
DeclarationName getMember() const
Retrieve the name of the member that this expression refers to.
Definition: ExprCXX.h:3818
SourceLocation getEndLoc() const LLVM_READONLY
Definition: ExprCXX.h:3893
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:3806
Expr * getBase() const
Retrieve the base object of this member expressions, e.g., the x in x.m.
Definition: ExprCXX.h:3770
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier that qualifies the member name, with source location information.
Definition: ExprCXX.h:3793
const_child_range children() const
Definition: ExprCXX.h:3910
bool hasTemplateKeyword() const
Determines whether the member name was preceded by the template keyword.
Definition: ExprCXX.h:3849
bool isImplicitAccess() const
True if this is an implicit access, i.e.
Definition: ExprCXX.h:3762
ArrayRef< TemplateArgumentLoc > template_arguments() const
Definition: ExprCXX.h:3881
Represents a C++ destructor within a class.
Definition: DeclCXX.h:2799
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:757
bool isAlwaysNull() const
isAlwaysNull - Return whether the result of the dynamic_cast is proven to always be null.
Definition: ExprCXX.cpp:771
Represents a folding of a pack over an operator.
Definition: ExprCXX.h:4822
static bool classof(const Stmt *T)
Definition: ExprCXX.h:4900
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprCXX.h:4884
UnresolvedLookupExpr * getCallee() const
Definition: ExprCXX.h:4853
Expr * getInit() const
Get the operand that doesn't contain a pack, for a binary fold.
Definition: ExprCXX.h:4871
CXXFoldExpr(EmptyShell Empty)
Definition: ExprCXX.h:4851
std::optional< unsigned > getNumExpansions() const
Definition: ExprCXX.h:4878
SourceLocation getEndLoc() const LLVM_READONLY
Definition: ExprCXX.h:4892
Expr * getRHS() const
Definition: ExprCXX.h:4857
const_child_range children() const
Definition: ExprCXX.h:4909
SourceLocation getLParenLoc() const
Definition: ExprCXX.h:4873
SourceLocation getEllipsisLoc() const
Definition: ExprCXX.h:4875
bool isLeftFold() const
Does this produce a left-associated sequence of operators?
Definition: ExprCXX.h:4865
child_range children()
Definition: ExprCXX.h:4905
bool isRightFold() const
Does this produce a right-associated sequence of operators?
Definition: ExprCXX.h:4860
CXXFoldExpr(QualType T, UnresolvedLookupExpr *Callee, SourceLocation LParenLoc, Expr *LHS, BinaryOperatorKind Opcode, SourceLocation EllipsisLoc, Expr *RHS, SourceLocation RParenLoc, std::optional< unsigned > NumExpansions)
Definition: ExprCXX.h:4838
Expr * getPattern() const
Get the pattern, that is, the operand that contains an unexpanded pack.
Definition: ExprCXX.h:4868
Expr * getLHS() const
Definition: ExprCXX.h:4856
SourceLocation getRParenLoc() const
Definition: ExprCXX.h:4874
BinaryOperatorKind getOperator() const
Definition: ExprCXX.h:4876
Represents an explicit C++ type conversion that uses "functional" notation (C++ [expr....
Definition: ExprCXX.h:1813
void setLParenLoc(SourceLocation L)
Definition: ExprCXX.h:1851
SourceLocation getLParenLoc() const
Definition: ExprCXX.h:1850
static CXXFunctionalCastExpr * CreateEmpty(const ASTContext &Context, unsigned PathSize, bool HasFPFeatures)
Definition: ExprCXX.cpp:868
SourceLocation getRParenLoc() const
Definition: ExprCXX.h:1852
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprCXX.cpp:878
void setRParenLoc(SourceLocation L)
Definition: ExprCXX.h:1853
static bool classof(const Stmt *T)
Definition: ExprCXX.h:1861
bool isListInitialization() const
Determine whether this expression models list-initialization.
Definition: ExprCXX.h:1856
SourceLocation getEndLoc() const LLVM_READONLY
Definition: ExprCXX.cpp:882
Represents a call to an inherited base class constructor from an inheriting constructor.
Definition: ExprCXX.h:1733
CXXInheritedCtorInitExpr(EmptyShell Empty)
Construct an empty C++ inheriting construction expression.
Definition: ExprCXX.h:1765
const_child_range children() const
Definition: ExprCXX.h:1798
CXXConstructionKind getConstructionKind() const
Definition: ExprCXX.h:1775
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprCXX.h:1787
static bool classof(const Stmt *T)
Definition: ExprCXX.h:1790
bool constructsVBase() const
Determine whether this constructor is actually constructing a base class (rather than a complete obje...
Definition: ExprCXX.h:1774
CXXConstructorDecl * getConstructor() const
Get the constructor that this expression will call.
Definition: ExprCXX.h:1770
CXXInheritedCtorInitExpr(SourceLocation Loc, QualType T, CXXConstructorDecl *Ctor, bool ConstructsVirtualBase, bool InheritedFromVirtualBase)
Construct a C++ inheriting construction expression.
Definition: ExprCXX.h:1753
SourceLocation getLocation() const LLVM_READONLY
Definition: ExprCXX.h:1786
SourceLocation getEndLoc() const LLVM_READONLY
Definition: ExprCXX.h:1788
bool inheritedFromVBase() const
Determine whether the inherited constructor is inherited from a virtual base of the object we constru...
Definition: ExprCXX.h:1784
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:673
Expr * getImplicitObjectArgument() const
Retrieve the implicit object argument for the member call.
Definition: ExprCXX.cpp:654
static CXXMemberCallExpr * CreateEmpty(const ASTContext &Ctx, unsigned NumArgs, bool HasFPFeatures, EmptyShell Empty)
Definition: ExprCXX.cpp:642
QualType getObjectType() const
Retrieve the type of the object argument.
Definition: ExprCXX.cpp:666
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:682
Represents a static or instance method of a struct/union/class.
Definition: DeclCXX.h:2060
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:700
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:2236
static CXXNewExpr * CreateEmpty(const ASTContext &Ctx, bool IsArray, bool HasInit, unsigned NumPlacementArgs, bool IsParenTypeId)
Create an empty c++ new expression.
Definition: ExprCXX.cpp:268
bool isArray() const
Definition: ExprCXX.h:2344
SourceRange getDirectInitRange() const
Definition: ExprCXX.h:2476
llvm::iterator_range< arg_iterator > placement_arguments()
Definition: ExprCXX.h:2439
QualType getAllocatedType() const
Definition: ExprCXX.h:2314
arg_iterator placement_arg_end()
Definition: ExprCXX.h:2450
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:2363
const_arg_iterator placement_arg_begin() const
Definition: ExprCXX.h:2453
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:2349
SourceLocation getEndLoc() const
Definition: ExprCXX.h:2474
CXXNewInitializationStyle getInitializationStyle() const
The kind of initializer this new-expression has.
Definition: ExprCXX.h:2403
Expr * getPlacementArg(unsigned I)
Definition: ExprCXX.h:2383
bool hasInitializer() const
Whether this new-expression has any initializer at all.
Definition: ExprCXX.h:2400
const Expr * getInitializer() const
Definition: ExprCXX.h:2414
bool shouldNullCheckAllocation() const
True if the allocation result needs to be null-checked.
Definition: ExprCXX.cpp:279
const Expr * getPlacementArg(unsigned I) const
Definition: ExprCXX.h:2387
static bool classof(const Stmt *T)
Definition: ExprCXX.h:2479
SourceLocation getBeginLoc() const
Definition: ExprCXX.h:2473
void setOperatorDelete(FunctionDecl *D)
Definition: ExprCXX.h:2342
bool passAlignment() const
Indicates whether the required alignment should be implicitly passed to the allocation function.
Definition: ExprCXX.h:2427
FunctionDecl * getOperatorDelete() const
Definition: ExprCXX.h:2341
unsigned getNumPlacementArgs() const
Definition: ExprCXX.h:2374
const CXXConstructExpr * getConstructExpr() const
Returns the CXXConstructExpr from this new-expression, or null.
Definition: ExprCXX.h:2421
llvm::iterator_range< const_arg_iterator > placement_arguments() const
Definition: ExprCXX.h:2443
const_arg_iterator placement_arg_end() const
Definition: ExprCXX.h:2456
TypeSourceInfo * getAllocatedTypeSourceInfo() const
Definition: ExprCXX.h:2318
SourceRange getSourceRange() const
Definition: ExprCXX.h:2477
SourceRange getTypeIdParens() const
Definition: ExprCXX.h:2392
Expr ** getPlacementArgs()
Definition: ExprCXX.h:2378
bool isParenTypeId() const
Definition: ExprCXX.h:2391
raw_arg_iterator raw_arg_end()
Definition: ExprCXX.h:2463
child_range children()
Definition: ExprCXX.h:2484
bool doesUsualArrayDeleteWantSize() const
Answers whether the usual array deallocation function for the allocated type expects the size of the ...
Definition: ExprCXX.h:2432
const_arg_iterator raw_arg_end() const
Definition: ExprCXX.h:2469
const_child_range children() const
Definition: ExprCXX.h:2486
arg_iterator placement_arg_begin()
Definition: ExprCXX.h:2447
raw_arg_iterator raw_arg_begin()
Definition: ExprCXX.h:2462
void setOperatorNew(FunctionDecl *D)
Definition: ExprCXX.h:2340
FunctionDecl * getOperatorNew() const
Definition: ExprCXX.h:2339
const_arg_iterator raw_arg_begin() const
Definition: ExprCXX.h:2466
bool isGlobalNew() const
Definition: ExprCXX.h:2397
Expr * getInitializer()
The initializer of this new-expression.
Definition: ExprCXX.h:2409
Represents a C++11 noexcept expression (C++ [expr.unary.noexcept]).
Definition: ExprCXX.h:4119
bool getValue() const
Definition: ExprCXX.h:4142
static bool classof(const Stmt *T)
Definition: ExprCXX.h:4144
const_child_range children() const
Definition: ExprCXX.h:4151
SourceLocation getEndLoc() const
Definition: ExprCXX.h:4139
Expr * getOperand() const
Definition: ExprCXX.h:4136
SourceLocation getBeginLoc() const
Definition: ExprCXX.h:4138
SourceRange getSourceRange() const
Definition: ExprCXX.h:4140
CXXNoexceptExpr(EmptyShell Empty)
Definition: ExprCXX.h:4134
CXXNoexceptExpr(QualType Ty, Expr *Operand, CanThrowResult Val, SourceLocation Keyword, SourceLocation RParen)
Definition: ExprCXX.h:4126
child_range children()
Definition: ExprCXX.h:4149
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:577
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:4944
SourceRange getSourceRange() const LLVM_READONLY
Definition: ExprCXX.h:5006
const_child_range children() const
Definition: ExprCXX.h:5037
void setInitializedFieldInUnion(FieldDecl *FD)
Definition: ExprCXX.h:5020
SourceLocation getEndLoc() const LLVM_READONLY
Definition: ExprCXX.h:5002
const ArrayRef< Expr * > getUserSpecifiedInitExprs() const
Definition: ExprCXX.h:4996
SourceLocation getInitLoc() const LLVM_READONLY
Definition: ExprCXX.h:5004
ArrayRef< Expr * > getUserSpecifiedInitExprs()
Definition: ExprCXX.h:4992
ArrayRef< Expr * > getInitExprs()
Definition: ExprCXX.h:4984
CXXParenListInitExpr(EmptyShell Empty, unsigned NumExprs)
Definition: ExprCXX.h:4978
friend class TrailingObjects
Definition: ExprCXX.h:4945
static CXXParenListInitExpr * CreateEmpty(ASTContext &C, unsigned numExprs, EmptyShell Empty)
Definition: ExprCXX.cpp:1894
const FieldDecl * getInitializedFieldInUnion() const
Definition: ExprCXX.h:5028
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprCXX.h:5000
static bool classof(const Stmt *T)
Definition: ExprCXX.h:5043
const ArrayRef< Expr * > getInitExprs() const
Definition: ExprCXX.h:4988
FieldDecl * getInitializedFieldInUnion()
Definition: ExprCXX.h:5024
const Expr * getArrayFiller() const
Definition: ExprCXX.h:5016
child_range children()
Definition: ExprCXX.h:5032
void setArrayFiller(Expr *E)
Definition: ExprCXX.h:5010
Represents a C++ pseudo-destructor (C++ [expr.pseudo]).
Definition: ExprCXX.h:2612
TypeSourceInfo * getDestroyedTypeInfo() const
Retrieve the source location information for the type being destroyed.
Definition: ExprCXX.h:2706
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprCXX.h:2736
bool isArrow() const
Determine whether this pseudo-destructor expression was written using an '->' (otherwise,...
Definition: ExprCXX.h:2676
TypeSourceInfo * getScopeTypeInfo() const
Retrieve the scope type in a qualified pseudo-destructor expression.
Definition: ExprCXX.h:2690
static bool classof(const Stmt *T)
Definition: ExprCXX.h:2741
SourceLocation getTildeLoc() const
Retrieve the location of the '~'.
Definition: ExprCXX.h:2697
NestedNameSpecifierLoc getQualifierLoc() const
Retrieves the nested-name-specifier that qualifies the type name, with source-location information.
Definition: ExprCXX.h:2665
SourceLocation getEndLoc() const LLVM_READONLY
Definition: ExprCXX.cpp:345
SourceLocation getDestroyedTypeLoc() const
Retrieve the starting location of the type being destroyed.
Definition: ExprCXX.h:2721
SourceLocation getColonColonLoc() const
Retrieve the location of the '::' in a qualified pseudo-destructor expression.
Definition: ExprCXX.h:2694
const_child_range children() const
Definition: ExprCXX.h:2748
QualType getDestroyedType() const
Retrieve the type being destroyed.
Definition: ExprCXX.cpp:338
SourceLocation getOperatorLoc() const
Retrieve the location of the '.' or '->' operator.
Definition: ExprCXX.h:2679
NestedNameSpecifier * getQualifier() const
If the member name was qualified, retrieves the nested-name-specifier that precedes the member name.
Definition: ExprCXX.h:2670
void setDestroyedType(IdentifierInfo *II, SourceLocation Loc)
Set the name of destroyed type for a dependent pseudo-destructor expression.
Definition: ExprCXX.h:2727
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:2713
void setDestroyedType(TypeSourceInfo *Info)
Set the destroyed type.
Definition: ExprCXX.h:2732
bool hasQualifier() const
Determines whether this member expression actually had a C++ nested-name-specifier prior to the name ...
Definition: ExprCXX.h:2661
CXXPseudoDestructorExpr(EmptyShell Shell)
Definition: ExprCXX.h:2653
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:821
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 a value-initialized rvalue of type T, which is a non-class type.
Definition: ExprCXX.h:2177
CXXScalarValueInitExpr(EmptyShell Shell)
Definition: ExprCXX.h:2193
const_child_range children() const
Definition: ExprCXX.h:2216
TypeSourceInfo * getTypeSourceInfo() const
Definition: ExprCXX.h:2196
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprCXX.cpp:177
static bool classof(const Stmt *T)
Definition: ExprCXX.h:2207
SourceLocation getEndLoc() const
Definition: ExprCXX.h:2205
SourceLocation getRParenLoc() const
Definition: ExprCXX.h:2200
CXXScalarValueInitExpr(QualType Type, TypeSourceInfo *TypeInfo, SourceLocation RParenLoc)
Create an explicitly-written scalar-value initialization expression.
Definition: ExprCXX.h:2185
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:729
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:1881
TypeSourceInfo * getTypeSourceInfo() const
Definition: ExprCXX.h:1910
SourceLocation getEndLoc() const LLVM_READONLY
Definition: ExprCXX.cpp:1103
static CXXTemporaryObjectExpr * CreateEmpty(const ASTContext &Ctx, unsigned NumArgs)
Definition: ExprCXX.cpp:1091
static bool classof(const Stmt *T)
Definition: ExprCXX.h:1915
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprCXX.cpp:1099
Represents a C++ temporary.
Definition: ExprCXX.h:1453
const CXXDestructorDecl * getDestructor() const
Definition: ExprCXX.h:1464
void setDestructor(const CXXDestructorDecl *Dtor)
Definition: ExprCXX.h:1466
Represents the this expression in C++.
Definition: ExprCXX.h:1148
void setCapturedByCopyInLambdaWithExplicitObjectParameter(bool Set)
Definition: ExprCXX.h:1178
SourceLocation getBeginLoc() const
Definition: ExprCXX.h:1168
void setLocation(SourceLocation L)
Definition: ExprCXX.h:1166
SourceLocation getEndLoc() const
Definition: ExprCXX.h:1169
bool isCapturedByCopyInLambdaWithExplicitObjectParameter() const
Definition: ExprCXX.h:1174
static CXXThisExpr * CreateEmpty(const ASTContext &Ctx)
Definition: ExprCXX.cpp:1525
void setImplicit(bool I)
Definition: ExprCXX.h:1172
child_range children()
Definition: ExprCXX.h:1188
bool isImplicit() const
Definition: ExprCXX.h:1171
static bool classof(const Stmt *T)
Definition: ExprCXX.h:1183
const_child_range children() const
Definition: ExprCXX.h:1192
SourceLocation getLocation() const
Definition: ExprCXX.h:1165
A C++ throw-expression (C++ [except.throw]).
Definition: ExprCXX.h:1202
CXXThrowExpr(EmptyShell Empty)
Definition: ExprCXX.h:1220
const_child_range children() const
Definition: ExprCXX.h:1252
SourceLocation getEndLoc() const LLVM_READONLY
Definition: ExprCXX.h:1237
const Expr * getSubExpr() const
Definition: ExprCXX.h:1222
CXXThrowExpr(Expr *Operand, QualType Ty, SourceLocation Loc, bool IsThrownVariableInScope)
Definition: ExprCXX.h:1213
SourceLocation getThrowLoc() const
Definition: ExprCXX.h:1225
Expr * getSubExpr()
Definition: ExprCXX.h:1223
SourceLocation getBeginLoc() const
Definition: ExprCXX.h:1236
bool isThrownVariableInScope() const
Determines whether the variable thrown by this expression (if any!) is within the innermost try block...
Definition: ExprCXX.h:1232
static bool classof(const Stmt *T)
Definition: ExprCXX.h:1243
child_range children()
Definition: ExprCXX.h:1248
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
Describes an explicit type conversion that uses functional notion but could not be resolved because o...
Definition: ExprCXX.h:3550
const_child_range children() const
Definition: ExprCXX.h:3658
const Expr *const * const_arg_iterator
Definition: ExprCXX.h:3617
void setRParenLoc(SourceLocation L)
Definition: ExprCXX.h:3600
void setArg(unsigned I, Expr *E)
Definition: ExprCXX.h:3636
SourceLocation getLParenLoc() const
Retrieve the location of the left parentheses ('(') that precedes the argument list.
Definition: ExprCXX.h:3594
bool isListInitialization() const
Determine whether this expression models list-initialization.
Definition: ExprCXX.h:3605
TypeSourceInfo * getTypeSourceInfo() const
Retrieve the type source information for the type being constructed.
Definition: ExprCXX.h:3588
const_arg_range arguments() const
Definition: ExprCXX.h:3622
QualType getTypeAsWritten() const
Retrieve the type that is being constructed, as specified in the source code.
Definition: ExprCXX.h:3584
const_arg_iterator arg_end() const
Definition: ExprCXX.h:3621
SourceLocation getEndLoc() const LLVM_READONLY
Definition: ExprCXX.h:3642
llvm::iterator_range< const_arg_iterator > const_arg_range
Definition: ExprCXX.h:3618
void setLParenLoc(SourceLocation L)
Definition: ExprCXX.h:3595
const Expr * getArg(unsigned I) const
Definition: ExprCXX.h:3631
Expr * getArg(unsigned I)
Definition: ExprCXX.h:3626
SourceLocation getRParenLoc() const
Retrieve the location of the right parentheses (')') that follows the argument list.
Definition: ExprCXX.h:3599
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprCXX.cpp:1438
unsigned getNumArgs() const
Retrieve the number of arguments.
Definition: ExprCXX.h:3608
static bool classof(const Stmt *T)
Definition: ExprCXX.h:3648
static CXXUnresolvedConstructExpr * CreateEmpty(const ASTContext &Context, unsigned NumArgs)
Definition: ExprCXX.cpp:1432
llvm::iterator_range< arg_iterator > arg_range
Definition: ExprCXX.h:3611
const_arg_iterator arg_begin() const
Definition: ExprCXX.h:3620
A Microsoft C++ __uuidof expression, which gets the _GUID that corresponds to the supplied type or ex...
Definition: ExprCXX.h:1062
child_range children()
Definition: ExprCXX.h:1120
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprCXX.h:1110
static bool classof(const Stmt *T)
Definition: ExprCXX.h:1115
const_child_range children() const
Definition: ExprCXX.h:1127
Expr * getExprOperand() const
Definition: ExprCXX.h:1103
CXXUuidofExpr(QualType Ty, TypeSourceInfo *Operand, MSGuidDecl *Guid, SourceRange R)
Definition: ExprCXX.h:1071
MSGuidDecl * getGuidDecl() const
Definition: ExprCXX.h:1108
QualType getTypeOperand(ASTContext &Context) const
Retrieves the type operand of this __uuidof() expression after various required adjustments (removing...
Definition: ExprCXX.cpp:169
bool isTypeOperand() const
Definition: ExprCXX.h:1092
CXXUuidofExpr(QualType Ty, Expr *Operand, MSGuidDecl *Guid, SourceRange R)
Definition: ExprCXX.h:1078
TypeSourceInfo * getTypeOperandSourceInfo() const
Retrieve source information for the type operand.
Definition: ExprCXX.h:1099
void setSourceRange(SourceRange R)
Definition: ExprCXX.h:1113
SourceRange getSourceRange() const LLVM_READONLY
Definition: ExprCXX.h:1112
SourceLocation getEndLoc() const LLVM_READONLY
Definition: ExprCXX.h:1111
CXXUuidofExpr(EmptyShell Empty, bool isExpr)
Definition: ExprCXX.h:1084
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
Definition: Expr.h:2820
Expr * getArg(unsigned Arg)
getArg - Return the specified argument.
Definition: Expr.h:3011
static constexpr ADLCallKind NotADL
Definition: Expr.h:2877
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: Expr.cpp:1638
Expr * getCallee()
Definition: Expr.h:2970
SourceLocation getRParenLoc() const
Definition: Expr.h:3130
static constexpr ADLCallKind UsesADL
Definition: Expr.h:2878
Stmt * getPreArg(unsigned I)
Definition: Expr.h:2900
CastExpr - Base class for type casts, including both implicit casts (ImplicitCastExpr) and explicit c...
Definition: Expr.h:3483
FPOptionsOverride * getTrailingFPFeatures()
Return a pointer to the trailing FPOptions.
Definition: Expr.cpp:2054
unsigned path_size() const
Definition: Expr.h:3552
bool hasStoredFPFeatures() const
Definition: Expr.h:3582
Represents a 'co_await' expression.
Definition: ExprCXX.h:5175
void setIsImplicit(bool value=true)
Definition: ExprCXX.h:5198
bool isImplicit() const
Definition: ExprCXX.h:5197
static bool classof(const Stmt *T)
Definition: ExprCXX.h:5200
CoawaitExpr(EmptyShell Empty)
Definition: ExprCXX.h:5194
CoawaitExpr(SourceLocation CoawaitLoc, QualType Ty, Expr *Operand, Expr *Common, bool IsImplicit=false)
Definition: ExprCXX.h:5187
CoawaitExpr(SourceLocation CoawaitLoc, Expr *Operand, Expr *Common, Expr *Ready, Expr *Suspend, Expr *Resume, OpaqueValueExpr *OpaqueValue, bool IsImplicit=false)
Definition: ExprCXX.h:5179
CompoundStmt - This represents a group of statements like { stmt stmt }.
Definition: Stmt.h:1606
ConstantExpr - An expression that occurs in a constant context and optionally the result of evaluatin...
Definition: Expr.h:1072
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:5061
SuspendReturnType getSuspendReturnType() const
Definition: ExprCXX.h:5134
CoroutineSuspendExpr(StmtClass SC, SourceLocation KeywordLoc, Expr *Operand, Expr *Common, Expr *Ready, Expr *Suspend, Expr *Resume, OpaqueValueExpr *OpaqueValue)
Definition: ExprCXX.h:5075
Expr * getReadyExpr() const
Definition: ExprCXX.h:5117
SourceLocation getKeywordLoc() const
Definition: ExprCXX.h:5152
Expr * getResumeExpr() const
Definition: ExprCXX.h:5125
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprCXX.h:5154
Expr * getSuspendExpr() const
Definition: ExprCXX.h:5121
CoroutineSuspendExpr(StmtClass SC, SourceLocation KeywordLoc, QualType Ty, Expr *Operand, Expr *Common)
Definition: ExprCXX.h:5089
static bool classof(const Stmt *T)
Definition: ExprCXX.h:5168
OpaqueValueExpr * getOpaqueValue() const
getOpaqueValue - Return the opaque value placeholder.
Definition: ExprCXX.h:5115
Expr * getCommonExpr() const
Definition: ExprCXX.h:5110
Expr * getOperand() const
Definition: ExprCXX.h:5130
const_child_range children() const
Definition: ExprCXX.h:5164
child_range children()
Definition: ExprCXX.h:5160
CoroutineSuspendExpr(StmtClass SC, EmptyShell Empty)
Definition: ExprCXX.h:5102
SourceLocation getEndLoc() const LLVM_READONLY
Definition: ExprCXX.h:5156
Represents a 'co_yield' expression.
Definition: ExprCXX.h:5256
CoyieldExpr(EmptyShell Empty)
Definition: ExprCXX.h:5269
CoyieldExpr(SourceLocation CoyieldLoc, Expr *Operand, Expr *Common, Expr *Ready, Expr *Suspend, Expr *Resume, OpaqueValueExpr *OpaqueValue)
Definition: ExprCXX.h:5260
static bool classof(const Stmt *T)
Definition: ExprCXX.h:5272
CoyieldExpr(SourceLocation CoyieldLoc, QualType Ty, Expr *Operand, Expr *Common)
Definition: ExprCXX.h:5265
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:5207
static bool classof(const Stmt *T)
Definition: ExprCXX.h:5250
DependentCoawaitExpr(EmptyShell Empty)
Definition: ExprCXX.h:5227
SourceLocation getEndLoc() const LLVM_READONLY
Definition: ExprCXX.h:5240
const_child_range children() const
Definition: ExprCXX.h:5246
Expr * getOperand() const
Definition: ExprCXX.h:5230
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprCXX.h:5238
DependentCoawaitExpr(SourceLocation KeywordLoc, QualType Ty, Expr *Op, UnresolvedLookupExpr *OpCoawait)
Definition: ExprCXX.h:5214
SourceLocation getKeywordLoc() const
Definition: ExprCXX.h:5236
child_range children()
Definition: ExprCXX.h:5244
UnresolvedLookupExpr * getOperatorCoawaitLookup() const
Definition: ExprCXX.h:5232
A qualified reference to a name whose declaration cannot yet be resolved.
Definition: ExprCXX.h:3316
SourceLocation getRAngleLoc() const
Retrieve the location of the right angle bracket ending the explicit template argument list following...
Definition: ExprCXX.h:3390
static DependentScopeDeclRefExpr * CreateEmpty(const ASTContext &Context, bool HasTemplateKWAndArgsInfo, unsigned NumTemplateArgs)
Definition: ExprCXX.cpp:497
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier that qualifies the name, with source location information.
Definition: ExprCXX.h:3364
SourceLocation getLocation() const
Retrieve the location of the name within the expression.
Definition: ExprCXX.h:3360
SourceLocation getLAngleLoc() const
Retrieve the location of the left angle bracket starting the explicit template argument list followin...
Definition: ExprCXX.h:3382
ArrayRef< TemplateArgumentLoc > template_arguments() const
Definition: ExprCXX.h:3424
const_child_range children() const
Definition: ExprCXX.h:3448
static bool classof(const Stmt *T)
Definition: ExprCXX.h:3440
bool hasExplicitTemplateArgs() const
Determines whether this lookup had explicit template arguments.
Definition: ExprCXX.h:3400
SourceLocation getEndLoc() const LLVM_READONLY
Definition: ExprCXX.h:3434
SourceLocation getBeginLoc() const LLVM_READONLY
Note: getBeginLoc() is the start of the whole DependentScopeDeclRefExpr, and differs from getLocation...
Definition: ExprCXX.h:3430
NestedNameSpecifier * getQualifier() const
Retrieve the nested-name-specifier that qualifies this declaration.
Definition: ExprCXX.h:3368
SourceLocation getTemplateKeywordLoc() const
Retrieve the location of the template keyword preceding this name, if any.
Definition: ExprCXX.h:3374
bool hasTemplateKeyword() const
Determines whether the name was preceded by the template keyword.
Definition: ExprCXX.h:3397
unsigned getNumTemplateArgs() const
Definition: ExprCXX.h:3417
DeclarationName getDeclName() const
Retrieve the name that this expression refers to.
Definition: ExprCXX.h:3355
TemplateArgumentLoc const * getTemplateArgs() const
Definition: ExprCXX.h:3410
void copyTemplateArgumentsInto(TemplateArgumentListInfo &List) const
Copies the template arguments (if present) into the given structure.
Definition: ExprCXX.h:3404
const DeclarationNameInfo & getNameInfo() const
Retrieve the name that this expression refers to.
Definition: ExprCXX.h:3352
ExplicitCastExpr - An explicit cast written in the source code.
Definition: Expr.h:3730
Represents an expression – generally a full-expression – that introduces cleanups to be run at the en...
Definition: ExprCXX.h:3467
bool cleanupsHaveSideEffects() const
Definition: ExprCXX.h:3502
static bool classof(const Stmt *T)
Definition: ExprCXX.h:3515
CleanupObject getObject(unsigned i) const
Definition: ExprCXX.h:3497
child_range children()
Definition: ExprCXX.h:3520
ArrayRef< CleanupObject > getObjects() const
Definition: ExprCXX.h:3491
unsigned getNumObjects() const
Definition: ExprCXX.h:3495
SourceLocation getEndLoc() const LLVM_READONLY
Definition: ExprCXX.h:3510
const_child_range children() const
Definition: ExprCXX.h:3522
llvm::PointerUnion< BlockDecl *, CompoundLiteralExpr * > CleanupObject
The type of objects that are kept in the cleanup.
Definition: ExprCXX.h:3473
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprCXX.h:3506
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:3235
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
Expr * IgnoreParens() LLVM_READONLY
Skip past any parentheses which might surround this expression until reaching a fixed point.
Definition: Expr.cpp:3055
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:2919
ExpressionTraitExpr(SourceLocation loc, ExpressionTrait et, Expr *queried, bool value, SourceLocation rparen, QualType resultType)
Definition: ExprCXX.h:2940
static bool classof(const Stmt *T)
Definition: ExprCXX.h:2962
ExpressionTraitExpr(EmptyShell Empty)
Definition: ExprCXX.h:2950
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprCXX.h:2953
Expr * getQueriedExpression() const
Definition: ExprCXX.h:2958
ExpressionTrait getTrait() const
Definition: ExprCXX.h:2956
child_range children()
Definition: ExprCXX.h:2967
SourceLocation getEndLoc() const LLVM_READONLY
Definition: ExprCXX.h:2954
const_child_range children() const
Definition: ExprCXX.h:2971
Represents difference between two FPOptions values.
Definition: LangOptions.h:915
bool requiresTrailingStorage() const
Definition: LangOptions.h:941
Represents a member of a struct/union/class.
Definition: Decl.h:3057
FullExpr - Represents a "full-expression" node.
Definition: Expr.h:1039
Stmt * SubExpr
Definition: Expr.h:1041
Represents a function declaration or definition.
Definition: Decl.h:1971
Represents a reference to a function parameter pack or init-capture pack that has been substituted bu...
Definition: ExprCXX.h:4630
VarDecl * getParameterPack() const
Get the parameter pack which this expression refers to.
Definition: ExprCXX.h:4657
const_child_range children() const
Definition: ExprCXX.h:4685
SourceLocation getEndLoc() const LLVM_READONLY
Definition: ExprCXX.h:4675
iterator end() const
Definition: ExprCXX.h:4666
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprCXX.h:4674
VarDecl * getExpansion(unsigned I) const
Get an expansion of the parameter pack by index.
Definition: ExprCXX.h:4672
VarDecl *const * iterator
Iterators over the parameters which the parameter pack expanded into.
Definition: ExprCXX.h:4664
unsigned getNumExpansions() const
Get the number of parameters in this parameter pack.
Definition: ExprCXX.h:4669
static bool classof(const Stmt *T)
Definition: ExprCXX.h:4677
SourceLocation getParameterPackLocation() const
Get the location of the parameter pack.
Definition: ExprCXX.h:4660
child_range children()
Definition: ExprCXX.h:4681
static FunctionParmPackExpr * CreateEmpty(const ASTContext &Context, unsigned NumParams)
Definition: ExprCXX.cpp:1756
iterator begin() const
Definition: ExprCXX.h:4665
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:1950
llvm::iterator_range< const_capture_init_iterator > capture_inits() const
Retrieve the initialization expressions for this lambda's captures.
Definition: ExprCXX.h:2070
capture_iterator capture_begin() const
Retrieve an iterator pointing to the first lambda capture.
Definition: ExprCXX.cpp:1295
static LambdaExpr * CreateDeserialized(const ASTContext &C, unsigned NumCaptures)
Construct a new lambda expression that will be deserialized from an external source.
Definition: ExprCXX.cpp:1264
SourceLocation getEndLoc() const LLVM_READONLY
Definition: ExprCXX.h:2168
Stmt * getBody() const
Retrieve the body of the lambda.
Definition: ExprCXX.cpp:1278
bool hasExplicitParameters() const
Determine whether this lambda has an explicit parameter list vs.
Definition: ExprCXX.h:2153
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:2082
bool isGenericLambda() const
Whether this is a generic lambda.
Definition: ExprCXX.h:2130
SourceRange getIntroducerRange() const
Retrieve the source range covering the lambda introducer, which contains the explicit capture list su...
Definition: ExprCXX.h:2101
bool isMutable() const
Determine whether the lambda is mutable, meaning that any captures values can be modified.
Definition: ExprCXX.cpp:1360
capture_iterator implicit_capture_end() const
Retrieve an iterator pointing past the end of the sequence of implicit lambda captures.
Definition: ExprCXX.cpp:1324
friend TrailingObjects
Definition: ExprCXX.h:1987
CompoundStmt * getCompoundStmtBody()
Definition: ExprCXX.h:2142
unsigned capture_size() const
Determine the number of captures in this lambda.
Definition: ExprCXX.h:2031
capture_range explicit_captures() const
Retrieve this lambda's explicit captures.
Definition: ExprCXX.cpp:1316
bool isInitCapture(const LambdaCapture *Capture) const
Determine whether one of this lambda's captures is an init-capture.
Definition: ExprCXX.cpp:1290
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:2094
CXXMethodDecl * getCallOperator() const
Retrieve the function call operator associated with this lambda expression.
Definition: ExprCXX.cpp:1336
const CompoundStmt * getCompoundStmtBody() const
Retrieve the CompoundStmt representing the body of the lambda.
Definition: ExprCXX.cpp:1283
bool hasExplicitResultType() const
Whether this lambda had its result type explicitly specified.
Definition: ExprCXX.h:2156
capture_range implicit_captures() const
Retrieve this lambda's implicit captures.
Definition: ExprCXX.cpp:1328
TemplateParameterList * getTemplateParameterList() const
If this is a generic lambda expression, retrieve the template parameter list associated with it,...
Definition: ExprCXX.cpp:1346
ArrayRef< NamedDecl * > getExplicitTemplateParameters() const
Get the template parameters were explicitly specified (as opposed to being invented by use of an auto...
Definition: ExprCXX.cpp:1351
capture_iterator implicit_capture_begin() const
Retrieve an iterator pointing to the first implicit lambda capture.
Definition: ExprCXX.cpp:1320
capture_iterator explicit_capture_end() const
Retrieve an iterator pointing past the end of the sequence of explicit lambda captures.
Definition: ExprCXX.cpp:1311
capture_iterator capture_end() const
Retrieve an iterator pointing past the end of the sequence of lambda captures.
Definition: ExprCXX.cpp:1299
llvm::iterator_range< capture_iterator > capture_range
An iterator over a range of lambda captures.
Definition: ExprCXX.h:2018
SourceLocation getCaptureDefaultLoc() const
Retrieve the location of this lambda's capture-default, if any.
Definition: ExprCXX.h:2008
capture_init_iterator capture_init_end()
Retrieve the iterator pointing one past the last initialization argument for this lambda expression.
Definition: ExprCXX.h:2088
const LambdaCapture * capture_iterator
An iterator that walks over the captures of the lambda, both implicit and explicit.
Definition: ExprCXX.h:2015
Expr *const * const_capture_init_iterator
Const iterator that walks over the capture initialization arguments.
Definition: ExprCXX.h:2062
Expr * getTrailingRequiresClause() const
Get the trailing requires clause, if any.
Definition: ExprCXX.cpp:1356
capture_iterator explicit_capture_begin() const
Retrieve an iterator pointing to the first explicit lambda capture.
Definition: ExprCXX.cpp:1307
llvm::iterator_range< capture_init_iterator > capture_inits()
Retrieve the initialization expressions for this lambda's captures.
Definition: ExprCXX.h:2065
child_range children()
Includes the captures and the body of the lambda.
Definition: ExprCXX.cpp:1362
FunctionTemplateDecl * getDependentCallOperator() const
Retrieve the function template call operator associated with this lambda expression.
Definition: ExprCXX.cpp:1341
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprCXX.h:2164
static bool classof(const Stmt *T)
Definition: ExprCXX.h:2160
capture_range captures() const
Retrieve this lambda's captures.
Definition: ExprCXX.cpp:1303
capture_init_iterator capture_init_begin()
Retrieve the first initialization argument for this lambda expression (which initializes the first ca...
Definition: ExprCXX.h:2076
LambdaCaptureDefault getCaptureDefault() const
Determine the default capture kind for this lambda.
Definition: ExprCXX.h:2003
CXXRecordDecl * getLambdaClass() const
Retrieve the class that corresponds to the lambda.
Definition: ExprCXX.cpp:1332
Implicit declaration of a temporary that was materialized by a MaterializeTemporaryExpr and lifetime-...
Definition: DeclCXX.h:3229
unsigned getManglingNumber() const
Definition: DeclCXX.h:3278
Stmt::child_range childrenExpr()
Definition: DeclCXX.h:3287
StorageDuration getStorageDuration() const
Retrieve the storage duration for the materialized temporary.
Definition: DeclCXX.cpp:3063
Expr * getTemporaryExpr()
Retrieve the expression to which the temporary materialization conversion was applied.
Definition: DeclCXX.h:3275
A global _GUID constant.
Definition: DeclCXX.h:4289
An instance of this class represents the declaration of a property member.
Definition: DeclCXX.h:4235
A member reference to an MSPropertyDecl.
Definition: ExprCXX.h:929
const_child_range children() const
Definition: ExprCXX.h:973
NestedNameSpecifierLoc getQualifierLoc() const
Definition: ExprCXX.h:986
MSPropertyRefExpr(EmptyShell Empty)
Definition: ExprCXX.h:948
bool isArrow() const
Definition: ExprCXX.h:984
bool isImplicitAccess() const
Definition: ExprCXX.h:954
SourceRange getSourceRange() const LLVM_READONLY
Definition: ExprCXX.h:950
SourceLocation getEndLoc() const
Definition: ExprCXX.h:967
MSPropertyDecl * getPropertyDecl() const
Definition: ExprCXX.h:983
Expr * getBaseExpr() const
Definition: ExprCXX.h:982
child_range children()
Definition: ExprCXX.h:969
MSPropertyRefExpr(Expr *baseExpr, MSPropertyDecl *decl, bool isArrow, QualType ty, ExprValueKind VK, NestedNameSpecifierLoc qualifierLoc, SourceLocation nameLoc)
Definition: ExprCXX.h:939
static bool classof(const Stmt *T)
Definition: ExprCXX.h:978
SourceLocation getBeginLoc() const
Definition: ExprCXX.h:958
SourceLocation getMemberLoc() const
Definition: ExprCXX.h:985
MS property subscript expression.
Definition: ExprCXX.h:1000
static bool classof(const Stmt *T)
Definition: ExprCXX.h:1044
const Expr * getIdx() const
Definition: ExprCXX.h:1029
void setRBracketLoc(SourceLocation L)
Definition: ExprCXX.h:1038
SourceLocation getEndLoc() const LLVM_READONLY
Definition: ExprCXX.h:1035
MSPropertySubscriptExpr(Expr *Base, Expr *Idx, QualType Ty, ExprValueKind VK, ExprObjectKind OK, SourceLocation RBracketLoc)
Definition: ExprCXX.h:1012
SourceLocation getExprLoc() const LLVM_READONLY
Definition: ExprCXX.h:1040
const_child_range children() const
Definition: ExprCXX.h:1053
MSPropertySubscriptExpr(EmptyShell Shell)
Create an empty array subscript expression.
Definition: ExprCXX.h:1022
const Expr * getBase() const
Definition: ExprCXX.h:1026
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprCXX.h:1031
SourceLocation getRBracketLoc() const
Definition: ExprCXX.h:1037
Represents a prvalue temporary that is written into memory so that a reference can bind to it.
Definition: ExprCXX.h:4710
const LifetimeExtendedTemporaryDecl * getLifetimeExtendedTemporaryDecl() const
Definition: ExprCXX.h:4754
StorageDuration getStorageDuration() const
Retrieve the storage duration for the materialized temporary.
Definition: ExprCXX.h:4735
Expr * getSubExpr() const
Retrieve the temporary-generating subexpression whose value will be materialized into a glvalue.
Definition: ExprCXX.h:4727
APValue * getOrCreateValue(bool MayCreate) const
Get the storage for the constant value of a materialized temporary of static storage duration.
Definition: ExprCXX.h:4743
bool isBoundToLvalueReference() const
Determine whether this materialized temporary is bound to an lvalue reference; otherwise,...
Definition: ExprCXX.h:4779
ValueDecl * getExtendingDecl()
Get the declaration which triggered the lifetime-extension of this temporary, if any.
Definition: ExprCXX.h:4760
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:1793
MaterializeTemporaryExpr(EmptyShell Empty)
Definition: ExprCXX.h:4722
LifetimeExtendedTemporaryDecl * getLifetimeExtendedTemporaryDecl()
Definition: ExprCXX.h:4750
void setExtendingDecl(ValueDecl *ExtendedBy, unsigned ManglingNumber)
Definition: ExprCXX.cpp:1776
SourceLocation getEndLoc() const LLVM_READONLY
Definition: ExprCXX.h:4789
const ValueDecl * getExtendingDecl() const
Definition: ExprCXX.h:4765
static bool classof(const Stmt *T)
Definition: ExprCXX.h:4793
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprCXX.h:4785
unsigned getManglingNumber() const
Definition: ExprCXX.h:4771
const_child_range children() const
Definition: ExprCXX.h:4804
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:1168
A reference to an overloaded function set, either an UnresolvedLookupExpr or an UnresolvedMemberExpr.
Definition: ExprCXX.h:2978
static bool classof(const Stmt *T)
Definition: ExprCXX.h:3154
NestedNameSpecifier * getQualifier() const
Fetches the nested-name qualifier, if one was given.
Definition: ExprCXX.h:3093
ASTTemplateKWAndArgsInfo * getTrailingASTTemplateKWAndArgsInfo()
Return the optional template keyword and arguments info.
Definition: ExprCXX.h:4092
bool hasExplicitTemplateArgs() const
Determines whether this expression had explicit template arguments.
Definition: ExprCXX.h:3129
static FindResult find(Expr *E)
Finds the overloaded expression in the given expression E of OverloadTy.
Definition: ExprCXX.h:3038
SourceLocation getLAngleLoc() const
Retrieve the location of the left angle bracket starting the explicit template argument list followin...
Definition: ExprCXX.h:3111
const DeclarationNameInfo & getNameInfo() const
Gets the full name info.
Definition: ExprCXX.h:3084
const CXXRecordDecl * getNamingClass() const
Definition: ExprCXX.h:3064
SourceLocation getNameLoc() const
Gets the location of the name.
Definition: ExprCXX.h:3090
decls_iterator decls_begin() const
Definition: ExprCXX.h:3070
CXXRecordDecl * getNamingClass()
Gets the naming class of this lookup, if any.
Definition: ExprCXX.h:4109
unsigned getNumDecls() const
Gets the number of declarations in the unresolved set.
Definition: ExprCXX.h:3081
SourceLocation getTemplateKeywordLoc() const
Retrieve the location of the template keyword preceding this name, if any.
Definition: ExprCXX.h:3103
NestedNameSpecifierLoc getQualifierLoc() const
Fetches the nested-name qualifier with source-location information, if one was given.
Definition: ExprCXX.h:3099
const ASTTemplateKWAndArgsInfo * getTrailingASTTemplateKWAndArgsInfo() const
Definition: ExprCXX.h:3010
TemplateArgumentLoc const * getTemplateArgs() const
Definition: ExprCXX.h:3131
llvm::iterator_range< decls_iterator > decls() const
Definition: ExprCXX.h:3076
void copyTemplateArgumentsInto(TemplateArgumentListInfo &List) const
Copies the template arguments into the given structure.
Definition: ExprCXX.h:3149
TemplateArgumentLoc * getTrailingTemplateArgumentLoc()
Return the optional template arguments.
Definition: ExprCXX.h:4102
DeclAccessPair * getTrailingResults()
Return the results. Defined after UnresolvedMemberExpr.
Definition: ExprCXX.h:4086
const DeclAccessPair * getTrailingResults() const
Definition: ExprCXX.h:3003
bool hasTemplateKWAndArgsInfo() const
Definition: ExprCXX.h:3022
decls_iterator decls_end() const
Definition: ExprCXX.h:3073
unsigned getNumTemplateArgs() const
Definition: ExprCXX.h:3137
const TemplateArgumentLoc * getTrailingTemplateArgumentLoc() const
Definition: ExprCXX.h:3018
DeclarationName getName() const
Gets the name looked up.
Definition: ExprCXX.h:3087
SourceLocation getRAngleLoc() const
Retrieve the location of the right angle bracket ending the explicit template argument list following...
Definition: ExprCXX.h:3119
bool hasTemplateKeyword() const
Determines whether the name was preceded by the template keyword.
Definition: ExprCXX.h:3126
ArrayRef< TemplateArgumentLoc > template_arguments() const
Definition: ExprCXX.h:3144
Represents a C++11 pack expansion that produces a sequence of expressions.
Definition: ExprCXX.h:4173
Expr * getPattern()
Retrieve the pattern of the pack expansion.
Definition: ExprCXX.h:4202
const Expr * getPattern() const
Retrieve the pattern of the pack expansion.
Definition: ExprCXX.h:4205
child_range children()
Definition: ExprCXX.h:4231
PackExpansionExpr(QualType T, Expr *Pattern, SourceLocation EllipsisLoc, std::optional< unsigned > NumExpansions)
Definition: ExprCXX.h:4189
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprCXX.h:4220
std::optional< unsigned > getNumExpansions() const
Determine the number of expansions that will be produced when this pack expansion is instantiated,...
Definition: ExprCXX.h:4213
SourceLocation getEndLoc() const LLVM_READONLY
Definition: ExprCXX.h:4224
const_child_range children() const
Definition: ExprCXX.h:4235
SourceLocation getEllipsisLoc() const
Retrieve the location of the ellipsis that describes this pack expansion.
Definition: ExprCXX.h:4209
PackExpansionExpr(EmptyShell Empty)
Definition: ExprCXX.h:4199
static bool classof(const Stmt *T)
Definition: ExprCXX.h:4226
NamedDecl * getPackDecl() const
Definition: ExprCXX.cpp:1686
static PackIndexingExpr * CreateDeserialized(ASTContext &Context, unsigned NumTransformedExprs)
Definition: ExprCXX.cpp:1697
SourceLocation getEllipsisLoc() const
Determine the location of the 'sizeof' keyword.
Definition: ExprCXX.h:4416
Expr * getIndexExpr() const
Definition: ExprCXX.h:4431
child_range children()
Definition: ExprCXX.h:4457
ArrayRef< Expr * > getExpressions() const
Definition: ExprCXX.h:4448
SourceLocation getEndLoc() const LLVM_READONLY
Definition: ExprCXX.h:4425
SourceLocation getPackLoc() const
Determine the location of the parameter pack.
Definition: ExprCXX.h:4419
SourceLocation getRSquareLoc() const
Determine the location of the right parenthesis.
Definition: ExprCXX.h:4422
std::optional< unsigned > getSelectedIndex() const
Definition: ExprCXX.h:4433
Expr * getPackIdExpression() const
Definition: ExprCXX.h:4427
Expr * getSelectedExpr() const
Definition: ExprCXX.h:4442
static bool classof(const Stmt *T)
Definition: ExprCXX.h:4452
const_child_range children() const
Definition: ExprCXX.h:4459
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprCXX.h:4424
Represents a parameter to a function.
Definition: Decl.h:1761
PointerType - C99 6.7.5.1 - Pointer Declarators.
Definition: Type.h:3140
Stores the type being destroyed by a pseudo-destructor expression.
Definition: ExprCXX.h:2561
PseudoDestructorTypeStorage(const IdentifierInfo *II, SourceLocation Loc)
Definition: ExprCXX.h:2572
const IdentifierInfo * getIdentifier() const
Definition: ExprCXX.h:2581
SourceLocation getLocation() const
Definition: ExprCXX.h:2585
TypeSourceInfo * getTypeSourceInfo() const
Definition: ExprCXX.h:2577
A (possibly-)qualified type.
Definition: Type.h:940
Represents an expression that computes the length of a parameter pack.
Definition: ExprCXX.h:4251
SourceLocation getPackLoc() const
Determine the location of the parameter pack.
Definition: ExprCXX.h:4314
child_range children()
Definition: ExprCXX.h:4356
static bool classof(const Stmt *T)
Definition: ExprCXX.h:4351
SourceLocation getEndLoc() const LLVM_READONLY
Definition: ExprCXX.h:4349
static SizeOfPackExpr * CreateDeserialized(ASTContext &Context, unsigned NumPartialArgs)
Definition: ExprCXX.cpp:1656
bool isPartiallySubstituted() const
Determine whether this represents a partially-substituted sizeof... expression, such as is produced f...
Definition: ExprCXX.h:4337
const_child_range children() const
Definition: ExprCXX.h:4360
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprCXX.h:4348
ArrayRef< TemplateArgument > getPartialArguments() const
Get.
Definition: ExprCXX.h:4342
SourceLocation getOperatorLoc() const
Determine the location of the 'sizeof' keyword.
Definition: ExprCXX.h:4311
SourceLocation getRParenLoc() const
Determine the location of the right parenthesis.
Definition: ExprCXX.h:4317
NamedDecl * getPack() const
Retrieve the parameter pack.
Definition: ExprCXX.h:4320
unsigned getPackLength() const
Retrieve the length of the parameter pack.
Definition: ExprCXX.h:4326
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:1256
LambdaExprBitfields LambdaExprBits
Definition: Stmt.h:1263
UnresolvedLookupExprBitfields UnresolvedLookupExprBits
Definition: Stmt.h:1259
SubstNonTypeTemplateParmExprBitfields SubstNonTypeTemplateParmExprBits
Definition: Stmt.h:1262
CXXNoexceptExprBitfields CXXNoexceptExprBits
Definition: Stmt.h:1261
StmtIterator child_iterator
Child Iterators: All subclasses must implement 'children' to permit easy iteration over the substatem...
Definition: Stmt.h:1444
CXXRewrittenBinaryOperatorBitfields CXXRewrittenBinaryOperatorBits
Definition: Stmt.h:1242
ExprWithCleanupsBitfields ExprWithCleanupsBits
Definition: Stmt.h:1255
StmtClass getStmtClass() const
Definition: Stmt.h:1358
CXXScalarValueInitExprBitfields CXXScalarValueInitExprBits
Definition: Stmt.h:1249
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:1258
CXXConstructExprBitfields CXXConstructExprBits
Definition: Stmt.h:1254
CXXDependentScopeMemberExprBitfields CXXDependentScopeMemberExprBits
Definition: Stmt.h:1257
ConstCastIterator< Expr > ConstExprIterator
Definition: Stmt.h:1332
TypeTraitExprBitfields TypeTraitExprBits
Definition: Stmt.h:1252
CXXNewExprBitfields CXXNewExprBits
Definition: Stmt.h:1250
CXXNullPtrLiteralExprBitfields CXXNullPtrLiteralExprBits
Definition: Stmt.h:1244
CoawaitExprBitfields CoawaitBits
Definition: Stmt.h:1267
llvm::iterator_range< child_iterator > child_range
Definition: Stmt.h:1447
CXXThrowExprBitfields CXXThrowExprBits
Definition: Stmt.h:1246
ConstStmtIterator const_child_iterator
Definition: Stmt.h:1445
CXXBoolLiteralExprBitfields CXXBoolLiteralExprBits
Definition: Stmt.h:1243
CXXOperatorCallExprBitfields CXXOperatorCallExprBits
Definition: Stmt.h:1241
CXXDefaultInitExprBitfields CXXDefaultInitExprBits
Definition: Stmt.h:1248
DependentScopeDeclRefExprBitfields DependentScopeDeclRefExprBits
Definition: Stmt.h:1253
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: Stmt.cpp:338
UnresolvedMemberExprBitfields UnresolvedMemberExprBits
Definition: Stmt.h:1260
llvm::iterator_range< const_child_iterator > const_child_range
Definition: Stmt.h:1448
CXXDeleteExprBitfields CXXDeleteExprBits
Definition: Stmt.h:1251
CXXDefaultArgExprBitfields CXXDefaultArgExprBits
Definition: Stmt.h:1247
CXXThisExprBitfields CXXThisExprBits
Definition: Stmt.h:1245
CastIterator< Expr > ExprIterator
Definition: Stmt.h:1331
Represents a reference to a non-type template parameter that has been substituted with a template arg...
Definition: ExprCXX.h:4466
std::optional< unsigned > getPackIndex() const
Definition: ExprCXX.h:4514
Decl * getAssociatedDecl() const
A template-like entity which owns the whole pattern being substituted.
Definition: ExprCXX.h:4508
SourceLocation getEndLoc() const
Definition: ExprCXX.h:4502
QualType getParameterType(const ASTContext &Ctx) const
Determine the substituted type of the template parameter.
Definition: ExprCXX.cpp:1704
const_child_range children() const
Definition: ExprCXX.h:4534
unsigned getIndex() const
Returns the index of the replaced parameter in the associated declaration.
Definition: ExprCXX.h:4512
SourceLocation getNameLoc() const
Definition: ExprCXX.h:4498
NonTypeTemplateParmDecl * getParameter() const
Definition: ExprCXX.cpp:1663
SourceLocation getBeginLoc() const
Definition: ExprCXX.h:4501
SubstNonTypeTemplateParmExpr(QualType Ty, ExprValueKind ValueKind, SourceLocation Loc, Expr *Replacement, Decl *AssociatedDecl, unsigned Index, std::optional< unsigned > PackIndex, bool RefParam)
Definition: ExprCXX.h:4485
static bool classof(const Stmt *s)
Definition: ExprCXX.h:4527
Represents a reference to a non-type template parameter pack that has been substituted with a non-tem...
Definition: ExprCXX.h:4551
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprCXX.h:4597
TemplateArgument getArgumentPack() const
Retrieve the template argument pack containing the substituted template arguments.
Definition: ExprCXX.cpp:1730
SourceLocation getParameterPackLocation() const
Retrieve the location of the parameter pack name.
Definition: ExprCXX.h:4591
const_child_range children() const
Definition: ExprCXX.h:4609
NonTypeTemplateParmDecl * getParameterPack() const
Retrieve the non-type template parameter pack being substituted.
Definition: ExprCXX.cpp:1725
Decl * getAssociatedDecl() const
A template-like entity which owns the whole pattern being substituted.
Definition: ExprCXX.h:4581
static bool classof(const Stmt *T)
Definition: ExprCXX.h:4600
unsigned getIndex() const
Returns the index of the replaced parameter in the associated declaration.
Definition: ExprCXX.h:4585
SourceLocation getEndLoc() const LLVM_READONLY
Definition: ExprCXX.h:4598
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:7331
QualType getType() const
Return the type wrapped by this type source info.
Definition: Type.h:7342
A type trait used in the implementation of various C++11 and Library TR1 trait templates.
Definition: ExprCXX.h:2763
ArrayRef< TypeSourceInfo * > getArgs() const
Retrieve the argument types.
Definition: ExprCXX.h:2819
friend TrailingObjects
Definition: ExprCXX.h:2787
static TypeTraitExpr * CreateDeserialized(const ASTContext &C, unsigned NumArgs)
Definition: ExprCXX.cpp:1838
child_range children()
Definition: ExprCXX.h:2831
SourceLocation getEndLoc() const LLVM_READONLY
Definition: ExprCXX.h:2824
TypeSourceInfo * getArg(unsigned I) const
Retrieve the Ith argument.
Definition: ExprCXX.h:2813
const_child_range children() const
Definition: ExprCXX.h:2835
unsigned getNumArgs() const
Determine the number of arguments to this type trait.
Definition: ExprCXX.h:2810
bool getValue() const
Definition: ExprCXX.h:2804
TypeTrait getTrait() const
Determine which type trait this expression uses.
Definition: ExprCXX.h:2800
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprCXX.h:2823
static bool classof(const Stmt *T)
Definition: ExprCXX.h:2826
The base class of the type hierarchy.
Definition: Type.h:1813
const T * castAs() const
Member-template castAs<specific type>.
Definition: Type.h:8194
bool isSpecificBuiltinType(unsigned K) const
Test for a particular builtin type.
Definition: Type.h:7875
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
Definition: Type.h:2654
A reference to a name which we were able to look up during parsing but could not resolve to a specifi...
Definition: ExprCXX.h:3197
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprCXX.h:3273
const CXXRecordDecl * getNamingClass() const
Definition: ExprCXX.h:3271
CXXRecordDecl * getNamingClass()
Gets the 'naming class' (in the sense of C++0x [class.access.base]p5) of the lookup.
Definition: ExprCXX.h:3270
SourceLocation getEndLoc() const LLVM_READONLY
Definition: ExprCXX.h:3279
child_range children()
Definition: ExprCXX.h:3285
static UnresolvedLookupExpr * CreateEmpty(const ASTContext &Context, unsigned NumResults, bool HasTemplateKWAndArgsInfo, unsigned NumTemplateArgs)
Definition: ExprCXX.cpp:405
static bool classof(const Stmt *T)
Definition: ExprCXX.h:3293
bool requiresADL() const
True if this declaration should be extended by argument-dependent lookup.
Definition: ExprCXX.h:3265
const_child_range children() const
Definition: ExprCXX.h:3289
Represents a C++ member access expression for which lookup produced a set of overloaded functions.
Definition: ExprCXX.h:3936
SourceLocation getEndLoc() const LLVM_READONLY
Definition: ExprCXX.h:4062
DeclarationName getMemberName() const
Retrieve the name of the member that this expression refers to.
Definition: ExprCXX.h:4044
QualType getBaseType() const
Definition: ExprCXX.h:4018
bool isArrow() const
Determine whether this member expression used the '->' operator; otherwise, it used the '.
Definition: ExprCXX.h:4028
SourceLocation getOperatorLoc() const
Retrieve the location of the '->' or '.' operator.
Definition: ExprCXX.h:4031
bool hasUnresolvedUsing() const
Determine whether the lookup results contain an unresolved using declaration.
Definition: ExprCXX.h:4022
const Expr * getBase() const
Definition: ExprCXX.h:4013
const CXXRecordDecl * getNamingClass() const
Definition: ExprCXX.h:4035
child_range children()
Definition: ExprCXX.h:4073
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:4052
Expr * getBase()
Retrieve the base object of this member expressions, e.g., the x in x.m.
Definition: ExprCXX.h:4009
static bool classof(const Stmt *T)
Definition: ExprCXX.h:4068
CXXRecordDecl * getNamingClass()
Retrieve the naming class of this lookup.
Definition: ExprCXX.cpp:1617
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:1579
const DeclarationNameInfo & getMemberNameInfo() const
Retrieve the full name info for the member that this expression refers to.
Definition: ExprCXX.h:4041
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprCXX.h:4054
static UnresolvedMemberExpr * CreateEmpty(const ASTContext &Context, unsigned NumResults, bool HasTemplateKWAndArgsInfo, unsigned NumTemplateArgs)
Definition: ExprCXX.cpp:1605
const_child_range children() const
Definition: ExprCXX.h:4079
SourceLocation getMemberLoc() const
Retrieve the location of the name of the member that this expression refers to.
Definition: ExprCXX.h:4048
UnresolvedSetIterator iterator
Definition: UnresolvedSet.h:80
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:929
const Expr * getCookedLiteral() const
Definition: ExprCXX.h:693
const IdentifierInfo * getUDSuffix() const
Returns the ud-suffix specified for this literal.
Definition: ExprCXX.cpp:958
static UserDefinedLiteral * CreateEmpty(const ASTContext &Ctx, unsigned NumArgs, bool HasFPOptions, EmptyShell Empty)
Definition: ExprCXX.cpp:916
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:950
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:706
Represents a variable declaration or definition.
Definition: Decl.h:918
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:1534
ExprObjectKind
A further classification of the kind of object referenced by an l-value or x-value.
Definition: Specifiers.h:146
@ OK_Ordinary
An ordinary object is located at an address in memory.
Definition: Specifiers.h:148
BinaryOperatorKind
ExprDependence computeDependence(FullExpr *E)
StorageDuration
The storage duration for an object (per C++ [basic.stc]).
Definition: Specifiers.h:324
@ SD_FullExpression
Full-expression storage duration (for temporaries).
Definition: Specifiers.h:325
@ 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:129
@ VK_PRValue
A pr-value expression (in the C++11 taxonomy) produces a temporary value.
Definition: Specifiers.h:132
@ VK_LValue
An l-value expression is a reference to an object with independent storage.
Definition: Specifiers.h:136
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:2221
@ 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:1316
A placeholder type used to construct an empty shell of a type, that will be filled in later (e....
Definition: Stmt.h:1298