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