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