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