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