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