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