clang 24.0.0git
Expr.h
Go to the documentation of this file.
1//===--- Expr.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// This file defines the Expr interface and subclasses.
10//
11//===----------------------------------------------------------------------===//
12
13#ifndef LLVM_CLANG_AST_EXPR_H
14#define LLVM_CLANG_AST_EXPR_H
15
17#include "clang/AST/APValue.h"
18#include "clang/AST/ASTVector.h"
20#include "clang/AST/Decl.h"
24#include "clang/AST/Stmt.h"
26#include "clang/AST/TypeBase.h"
31#include "llvm/ADT/APFloat.h"
32#include "llvm/ADT/APSInt.h"
33#include "llvm/ADT/SmallVector.h"
34#include "llvm/ADT/StringRef.h"
35#include "llvm/ADT/iterator.h"
36#include "llvm/ADT/iterator_range.h"
37#include "llvm/Support/AtomicOrdering.h"
38#include "llvm/Support/Compiler.h"
39#include "llvm/Support/TrailingObjects.h"
40#include <optional>
41
42namespace clang {
43class AllocSizeAttr;
44class APValue;
45class ASTContext;
46class BlockDecl;
50class CastExpr;
51class Decl;
52class IdentifierInfo;
54class NamedDecl;
56class OpaqueValueExpr;
57class ParmVarDecl;
58class SemaProxy;
59class StringLiteral;
60class TargetInfo;
61class ValueDecl;
62class WarnUnusedResultAttr;
63
64/// A simple array of base specifiers.
66
67/// An adjustment to be made to the temporary created when emitting a
68/// reference binding, which accesses a particular subobject of that
69/// temporary.
71 enum {
75 } Kind;
76
77 struct DTB {
80 };
81
82 struct P {
85 };
86
87 union {
90 struct P Ptr;
91 };
92
94 const CXXRecordDecl *DerivedClass)
96 DerivedToBase.BasePath = BasePath;
97 DerivedToBase.DerivedClass = DerivedClass;
98 }
99
101 this->Field = Field;
102 }
103
106 this->Ptr.MPT = MPT;
107 this->Ptr.RHS = RHS;
108 }
109};
110
111/// This represents one expression. Note that Expr's are subclasses of Stmt.
112/// This allows an expression to be transparently used any place a Stmt is
113/// required.
114class Expr : public ValueStmt {
115 QualType TR;
116
117public:
118 Expr() = delete;
119 Expr(const Expr&) = delete;
120 Expr(Expr &&) = delete;
121 Expr &operator=(const Expr&) = delete;
122 Expr &operator=(Expr&&) = delete;
123
124protected:
126 : ValueStmt(SC) {
127 ExprBits.Dependent = 0;
128 ExprBits.ValueKind = VK;
129 ExprBits.ObjectKind = OK;
130 assert(ExprBits.ObjectKind == OK && "truncated kind");
131 setType(T);
132 }
133
134 /// Construct an empty expression.
135 explicit Expr(StmtClass SC, EmptyShell) : ValueStmt(SC) { }
136
137 /// Each concrete expr subclass is expected to compute its dependence and call
138 /// this in the constructor.
140 ExprBits.Dependent = static_cast<unsigned>(Deps);
141 }
142 friend class ASTImporter; // Sets dependence directly.
143 friend class ASTStmtReader; // Sets dependence directly.
144
145public:
146 QualType getType() const { return TR; }
148 // In C++, the type of an expression is always adjusted so that it
149 // will not have reference type (C++ [expr]p6). Use
150 // QualType::getNonReferenceType() to retrieve the non-reference
151 // type. Additionally, inspect Expr::isLvalue to determine whether
152 // an expression that is adjusted in this manner should be
153 // considered an lvalue.
154 assert((t.isNull() || !t->isReferenceType()) &&
155 "Expressions can't have reference type");
156
157 TR = t;
158 }
159
160 /// If this expression is an enumeration constant, return the
161 /// enumeration type under which said constant was declared.
162 /// Otherwise return the expression's type.
163 /// Note this effectively circumvents the weak typing of C's enum constants
164 QualType getEnumCoercedType(const ASTContext &Ctx) const;
165
167 return static_cast<ExprDependence>(ExprBits.Dependent);
168 }
169
170 /// Determines whether the value of this expression depends on
171 /// - a template parameter (C++ [temp.dep.constexpr])
172 /// - or an error, whose resolution is unknown
173 ///
174 /// For example, the array bound of "Chars" in the following example is
175 /// value-dependent.
176 /// @code
177 /// template<int Size, char (&Chars)[Size]> struct meta_string;
178 /// @endcode
179 bool isValueDependent() const {
180 return static_cast<bool>(getDependence() & ExprDependence::Value);
181 }
182
183 /// Determines whether the type of this expression depends on
184 /// - a template parameter (C++ [temp.dep.expr], which means that its type
185 /// could change from one template instantiation to the next)
186 /// - or an error
187 ///
188 /// For example, the expressions "x" and "x + y" are type-dependent in
189 /// the following code, but "y" is not type-dependent:
190 /// @code
191 /// template<typename T>
192 /// void add(T x, int y) {
193 /// x + y;
194 /// }
195 /// @endcode
196 bool isTypeDependent() const {
197 return static_cast<bool>(getDependence() & ExprDependence::Type);
198 }
199
200 /// Whether this expression is instantiation-dependent, meaning that
201 /// it depends in some way on
202 /// - a template parameter (even if neither its type nor (constant) value
203 /// can change due to the template instantiation)
204 /// - or an error
205 ///
206 /// In the following example, the expression \c sizeof(sizeof(T() + T())) is
207 /// instantiation-dependent (since it involves a template parameter \c T), but
208 /// is neither type- nor value-dependent, since the type of the inner
209 /// \c sizeof is known (\c std::size_t) and therefore the size of the outer
210 /// \c sizeof is known.
211 ///
212 /// \code
213 /// template<typename T>
214 /// void f(T x, T y) {
215 /// sizeof(sizeof(T() + T());
216 /// }
217 /// \endcode
218 ///
219 /// \code
220 /// void func(int) {
221 /// func(); // the expression is instantiation-dependent, because it depends
222 /// // on an error.
223 /// }
224 /// \endcode
226 return static_cast<bool>(getDependence() & ExprDependence::Instantiation);
227 }
228
229 /// Whether this expression contains an unexpanded parameter
230 /// pack (for C++11 variadic templates).
231 ///
232 /// Given the following function template:
233 ///
234 /// \code
235 /// template<typename F, typename ...Types>
236 /// void forward(const F &f, Types &&...args) {
237 /// f(static_cast<Types&&>(args)...);
238 /// }
239 /// \endcode
240 ///
241 /// The expressions \c args and \c static_cast<Types&&>(args) both
242 /// contain parameter packs.
244 return static_cast<bool>(getDependence() & ExprDependence::UnexpandedPack);
245 }
246
247 /// Whether this expression contains subexpressions which had errors.
248 bool containsErrors() const {
249 return static_cast<bool>(getDependence() & ExprDependence::Error);
250 }
251
252 /// getExprLoc - Return the preferred location for the arrow when diagnosing
253 /// a problem with a generic expression.
254 SourceLocation getExprLoc() const LLVM_READONLY;
255
256 /// Determine whether an lvalue-to-rvalue conversion should implicitly be
257 /// applied to this expression if it appears as a discarded-value expression
258 /// in C++11 onwards. This applies to certain forms of volatile glvalues.
260
261 /// isUnusedResultAWarning - Return true if this immediate expression should
262 /// be warned about if the result is unused. If so, fill in expr, location,
263 /// and ranges with expr to warn on and source locations/ranges appropriate
264 /// for a warning.
265 bool isUnusedResultAWarning(const Expr *&WarnExpr, SourceLocation &Loc,
266 SourceRange &R1, SourceRange &R2,
267 ASTContext &Ctx) const;
268
269 /// Returns the WarnUnusedResultAttr that is declared on the callee
270 /// or its return type declaration, together with a NamedDecl that
271 /// refers to the declaration the attribute is attached to.
272 static std::pair<const NamedDecl *, const WarnUnusedResultAttr *>
273 getUnusedResultAttrImpl(const Decl *Callee, QualType ReturnType);
274
275 /// isLValue - True if this expression is an "l-value" according to
276 /// the rules of the current language. C and C++ give somewhat
277 /// different rules for this concept, but in general, the result of
278 /// an l-value expression identifies a specific object whereas the
279 /// result of an r-value expression is a value detached from any
280 /// specific storage.
281 ///
282 /// C++11 divides the concept of "r-value" into pure r-values
283 /// ("pr-values") and so-called expiring values ("x-values"), which
284 /// identify specific objects that can be safely cannibalized for
285 /// their resources.
286 bool isLValue() const { return getValueKind() == VK_LValue; }
287 bool isPRValue() const { return getValueKind() == VK_PRValue; }
288 bool isXValue() const { return getValueKind() == VK_XValue; }
289 bool isGLValue() const { return getValueKind() != VK_PRValue; }
290
304 /// Reasons why an expression might not be an l-value.
306
327 /// isModifiableLvalue - C99 6.3.2.1: an lvalue that does not have array type,
328 /// does not have an incomplete type, does not have a const-qualified type,
329 /// and if it is a structure or union, does not have any member (including,
330 /// recursively, any member or element of all contained aggregates or unions)
331 /// with a const-qualified type.
332 ///
333 /// \param Loc [in,out] - A source location which *may* be filled
334 /// in with the location of the expression making this a
335 /// non-modifiable lvalue, if specified.
337 isModifiableLvalue(ASTContext &Ctx, SourceLocation *Loc = nullptr) const;
338
339 /// The return type of classify(). Represents the C++11 expression
340 /// taxonomy.
341 class Classification {
342 public:
343 /// The various classification results. Most of these mean prvalue.
344 enum Kinds {
347 CL_Function, // Functions cannot be lvalues in C.
348 CL_Void, // Void cannot be an lvalue in C.
349 CL_AddressableVoid, // Void expression whose address can be taken in C.
350 CL_DuplicateVectorComponents, // A vector shuffle with dupes.
351 CL_DuplicateMatrixComponents, // A matrix shuffle with dupes.
352 CL_MemberFunction, // An expression referring to a member function
354 CL_ClassTemporary, // A temporary of class type, or subobject thereof.
355 CL_ArrayTemporary, // A temporary of array type.
356 CL_ObjCMessageRValue, // ObjC message is an rvalue
357 CL_PRValue // A prvalue for any other reason, of any other type
358 };
359 /// The results of modification testing.
361 CM_Untested, // testModifiable was false.
363 CM_RValue, // Not modifiable because it's an rvalue
364 CM_Function, // Not modifiable because it's a function; C++ only
365 CM_LValueCast, // Same as CM_RValue, but indicates GCC cast-as-lvalue ext
366 CM_NoSetterProperty,// Implicit assignment to ObjC property without setter
372 };
373
374 private:
375 friend class Expr;
376
377 unsigned short Kind;
378 unsigned short Modifiable;
379
380 explicit Classification(Kinds k, ModifiableType m)
381 : Kind(k), Modifiable(m)
382 {}
383
384 public:
386
387 Kinds getKind() const { return static_cast<Kinds>(Kind); }
389 assert(Modifiable != CM_Untested && "Did not test for modifiability.");
390 return static_cast<ModifiableType>(Modifiable);
391 }
392 bool isLValue() const { return Kind == CL_LValue; }
393 bool isXValue() const { return Kind == CL_XValue; }
394 bool isGLValue() const { return Kind <= CL_XValue; }
395 bool isPRValue() const { return Kind >= CL_Function; }
396 bool isRValue() const { return Kind >= CL_XValue; }
397 bool isModifiable() const { return getModifiable() == CM_Modifiable; }
398
399 /// Create a simple, modifiable lvalue
400 static Classification makeSimpleLValue() {
402 }
403
404 };
405 /// Classify - Classify this expression according to the C++11
406 /// expression taxonomy.
407 ///
408 /// C++11 defines ([basic.lval]) a new taxonomy of expressions to replace the
409 /// old lvalue vs rvalue. This function determines the type of expression this
410 /// is. There are three expression types:
411 /// - lvalues are classical lvalues as in C++03.
412 /// - prvalues are equivalent to rvalues in C++03.
413 /// - xvalues are expressions yielding unnamed rvalue references, e.g. a
414 /// function returning an rvalue reference.
415 /// lvalues and xvalues are collectively referred to as glvalues, while
416 /// prvalues and xvalues together form rvalues.
418 return ClassifyImpl(Ctx, nullptr);
419 }
420
421 /// ClassifyModifiable - Classify this expression according to the
422 /// C++11 expression taxonomy, and see if it is valid on the left side
423 /// of an assignment.
424 ///
425 /// This function extends classify in that it also tests whether the
426 /// expression is modifiable (C99 6.3.2.1p1).
427 /// \param Loc A source location that might be filled with a relevant location
428 /// if the expression is not modifiable.
430 return ClassifyImpl(Ctx, &Loc);
431 }
432
433 /// Returns the set of floating point options that apply to this expression.
434 /// Only meaningful for operations on floating point values.
436
437 /// getValueKindForType - Given a formal return or parameter type,
438 /// give its value kind.
440 if (const ReferenceType *RT = T->getAs<ReferenceType>())
441 return (isa<LValueReferenceType>(RT)
442 ? VK_LValue
443 : (RT->getPointeeType()->isFunctionType()
444 ? VK_LValue : VK_XValue));
445 return VK_PRValue;
446 }
447
448 /// getValueKind - The value kind that this expression produces.
450 return static_cast<ExprValueKind>(ExprBits.ValueKind);
451 }
452
453 /// getObjectKind - The object kind that this expression produces.
454 /// Object kinds are meaningful only for expressions that yield an
455 /// l-value or x-value.
457 return static_cast<ExprObjectKind>(ExprBits.ObjectKind);
458 }
459
462 return (OK == OK_Ordinary || OK == OK_BitField);
463 }
464
465 /// setValueKind - Set the value kind produced by this expression.
466 void setValueKind(ExprValueKind Cat) { ExprBits.ValueKind = Cat; }
467
468 /// setObjectKind - Set the object kind produced by this expression.
469 void setObjectKind(ExprObjectKind Cat) { ExprBits.ObjectKind = Cat; }
470
471private:
472 Classification ClassifyImpl(ASTContext &Ctx, SourceLocation *Loc) const;
473
474public:
475
476 /// Returns true if this expression is a gl-value that
477 /// potentially refers to a bit-field.
478 ///
479 /// In C++, whether a gl-value refers to a bitfield is essentially
480 /// an aspect of the value-kind type system.
481 bool refersToBitField() const { return getObjectKind() == OK_BitField; }
482
483 /// If this expression refers to a bit-field, retrieve the
484 /// declaration of that bit-field.
485 ///
486 /// Note that this returns a non-null pointer in subtly different
487 /// places than refersToBitField returns true. In particular, this can
488 /// return a non-null pointer even for r-values loaded from
489 /// bit-fields, but it will return null for a conditional bit-field.
491
492 /// If this expression refers to an enum constant, retrieve its declaration
494
496 return const_cast<Expr *>(this)->getEnumConstantDecl();
497 }
498
500 return const_cast<Expr*>(this)->getSourceBitField();
501 }
502
505 return const_cast<Expr*>(this)->getReferencedDeclOfCallee();
506 }
507
508 /// If this expression is an l-value for an Objective C
509 /// property, find the underlying property reference expression.
511
512 /// Check if this expression is the ObjC 'self' implicit parameter.
513 bool isObjCSelfExpr() const;
514
515 /// Returns whether this expression refers to a vector element.
516 bool refersToVectorElement() const;
517
518 /// Returns whether this expression refers to a matrix element.
521 }
522
523 /// Returns whether this expression refers to a global register
524 /// variable.
525 bool refersToGlobalRegisterVar() const;
526
527 /// Returns whether this expression has a placeholder type.
528 bool hasPlaceholderType() const {
529 return getType()->isPlaceholderType();
530 }
531
532 /// Returns whether this expression has a specific placeholder type.
535 if (const BuiltinType *BT = dyn_cast<BuiltinType>(getType()))
536 return BT->getKind() == K;
537 return false;
538 }
539
540 /// isKnownToHaveBooleanValue - Return true if this is an integer expression
541 /// that is known to return 0 or 1. This happens for _Bool/bool expressions
542 /// but also int expressions which are produced by things like comparisons in
543 /// C.
544 ///
545 /// \param Semantic If true, only return true for expressions that are known
546 /// to be semantically boolean, which might not be true even for expressions
547 /// that are known to evaluate to 0/1. For instance, reading an unsigned
548 /// bit-field with width '1' will evaluate to 0/1, but doesn't necessarily
549 /// semantically correspond to a bool.
550 bool isKnownToHaveBooleanValue(bool Semantic = true) const;
551
552 /// Check whether this array fits the idiom of a flexible array member,
553 /// depending on the value of -fstrict-flex-array.
554 /// When IgnoreTemplateOrMacroSubstitution is set, it doesn't consider sizes
555 /// resulting from the substitution of a macro or a template as special sizes.
557 const ASTContext &Context,
558 LangOptions::StrictFlexArraysLevelKind StrictFlexArraysLevel,
559 bool IgnoreTemplateOrMacroSubstitution = false) const;
560
561 /// isIntegerConstantExpr - Return the value if this expression is a valid
562 /// integer constant expression. If not a valid i-c-e, return std::nullopt.
563 ///
564 /// Note: This does not perform the implicit conversions required by C++11
565 /// [expr.const]p5.
566 ///
567 /// If \p AllowRelaxedEval is \c true, this will allow certain constructs that
568 /// are not valid per the specification.
569 // FIXME: Add proper documentation about the constructs we allow.
570 std::optional<llvm::APSInt>
572 bool AllowRelaxedEval = false) const;
573 bool isIntegerConstantExpr(const ASTContext &Ctx) const;
574
575 /// isCXX98IntegralConstantExpr - Return true if this expression is an
576 /// integral constant expression in C++98. Can only be used in C++.
577 bool isCXX98IntegralConstantExpr(const ASTContext &Ctx) const;
578
579 /// isCXX11ConstantExpr - Return true if this expression is a constant
580 /// expression in C++11. Can only be used in C++.
581 ///
582 /// Note: This does not perform the implicit conversions required by C++11
583 /// [expr.const]p5.
584 ///
585 /// If \p AllowRelaxedEval is \c true, this will allow certain constructs that
586 /// are not valid per the specification.
587 // FIXME: Add proper documentation about the constructs we allow.
589 bool AllowRelaxedEval = false) const;
590
591 /// isPotentialConstantExpr - Return true if this function's definition
592 /// might be usable in a constant expression in C++11, if it were marked
593 /// constexpr. Return false if the function can never produce a constant
594 /// expression, along with diagnostics describing why not.
595 static bool isPotentialConstantExpr(const FunctionDecl *FD,
597 PartialDiagnosticAt> &Diags);
598
599 /// isPotentialConstantExprUnevaluated - Return true if this expression might
600 /// be usable in a constant expression in C++11 in an unevaluated context, if
601 /// it were in function FD marked constexpr. Return false if the function can
602 /// never produce a constant expression, along with diagnostics describing
603 /// why not.
605 const FunctionDecl *FD,
607 PartialDiagnosticAt> &Diags);
608
609 /// Returns true if this expression can be emitted to
610 /// IR as a constant, and thus can be used as a constant initializer in C.
611 /// If this expression is not constant and Culprit is non-null,
612 /// it is used to store the address of first non constant expr.
613 bool isConstantInitializer(ASTContext &Ctx, bool ForRef = false,
614 const Expr **Culprit = nullptr) const;
615
616 /// If this expression is an unambiguous reference to a single declaration,
617 /// in the style of __builtin_function_start, return that declaration. Note
618 /// that this may return a non-static member function or field in C++ if this
619 /// expression is a member pointer constant.
620 const ValueDecl *getAsBuiltinConstantDeclRef(const ASTContext &Context) const;
621
622 /// EvalStatus is a struct with detailed info about an evaluation in progress.
623 struct EvalStatus {
624 /// Whether the evaluated expression has side effects.
625 /// For example, (f() && 0) can be folded, but it still has side effects.
626 bool HasSideEffects = false;
627
628 /// Whether the evaluation hit undefined behavior.
629 /// For example, 1.0 / 0.0 can be folded to Inf, but has undefined behavior.
630 /// Likewise, INT_MAX + 1 can be folded to INT_MIN, but has UB.
632
633 /// Whether any diagnostic has been emitted. This is set regardless of
634 /// whether @ref #Diag is set or not.
635 bool DiagEmitted = false;
636
637 /// Diag - If this is non-null, it will be filled in with a stack of notes
638 /// indicating why evaluation failed (or why it failed to produce a constant
639 /// expression).
640 /// If the expression is unfoldable, the notes will indicate why it's not
641 /// foldable. If the expression is foldable, but not a constant expression,
642 /// the notes will describes why it isn't a constant expression. If the
643 /// expression *is* a constant expression, no notes will be produced.
644 ///
645 /// FIXME: this causes significant performance concerns and should be
646 /// refactored at some point. Not all evaluations of the constant
647 /// expression interpreter will display the given diagnostics, this means
648 /// those kinds of uses are paying the expense of generating a diagnostic
649 /// (which may include expensive operations like converting APValue objects
650 /// to a string representation).
652
653 /// Location where we spot ptr to int cast or null subobject while
654 /// evaluating constant expression in MS compatibility mode.
656
657 EvalStatus() = default;
658
659 /// Return true if the evaluated expression has
660 /// side effects.
661 bool hasSideEffects() const {
662 return HasSideEffects;
663 }
664 };
665
666 /// EvalResult is a struct with detailed info about an evaluated expression.
668 /// Val - This is the value the expression can be folded to.
670
671 /// Return true if the evaluated lvalue expression
672 /// is global.
673 bool isGlobalLValue() const;
674 };
675
676 /// EvaluateAsRValue - Return true if this is a constant which we can fold to
677 /// an rvalue using any crazy technique (that has nothing to do with language
678 /// standards) that we want to, even if the expression has side-effects. If
679 /// this function returns true, it returns the folded constant in Result. If
680 /// the expression is a glvalue, an lvalue-to-rvalue conversion will be
681 /// applied.
683 bool InConstantContext = false) const;
684
685 /// Evaluate an expression that is required by the language to be a constant
686 /// expression, and fold the resulting rvalue constant into Result. If the
687 /// expression is a glvalue, an lvalue-to-rvalue conversion will be applied.
689 const ASTContext &Ctx,
690 SemaProxy &SProxy) const;
691
692 /// EvaluateAsBooleanCondition - Return true if this is a constant
693 /// which we can fold and convert to a boolean condition using
694 /// any crazy technique that we want to, even if the expression has
695 /// side-effects.
696 bool EvaluateAsBooleanCondition(bool &Result, const ASTContext &Ctx,
697 bool InConstantContext = false) const;
698
700 SE_NoSideEffects, ///< Strictly evaluate the expression.
701 SE_AllowUndefinedBehavior, ///< Allow UB that we can give a value, but not
702 ///< arbitrary unmodeled side effects.
703 SE_AllowSideEffects ///< Allow any unmodeled side effect.
704 };
705
706 /// EvaluateAsInt - Return true if this is a constant which we can fold and
707 /// convert to an integer, using any crazy technique that we want to.
708 bool EvaluateAsInt(EvalResult &Result, const ASTContext &Ctx,
709 SideEffectsKind AllowSideEffects = SE_NoSideEffects,
710 bool InConstantContext = false) const;
711
712 /// EvaluateAsFloat - Return true if this is a constant which we can fold and
713 /// convert to a floating point value, using any crazy technique that we
714 /// want to.
715 bool EvaluateAsFloat(llvm::APFloat &Result, const ASTContext &Ctx,
716 SideEffectsKind AllowSideEffects = SE_NoSideEffects,
717 bool InConstantContext = false) const;
718
719 /// EvaluateAsFixedPoint - Return true if this is a constant which we can fold
720 /// and convert to a fixed point value.
721 bool EvaluateAsFixedPoint(EvalResult &Result, const ASTContext &Ctx,
722 SideEffectsKind AllowSideEffects = SE_NoSideEffects,
723 bool InConstantContext = false) const;
724
725 /// isEvaluatable - Call EvaluateAsRValue to see if this expression can be
726 /// constant folded without side-effects, but discard the result.
727 bool isEvaluatable(const ASTContext &Ctx,
728 SideEffectsKind AllowSideEffects = SE_NoSideEffects) const;
729
730 /// HasSideEffects - This routine returns true for all those expressions
731 /// which have any effect other than producing a value. Example is a function
732 /// call, volatile variable read, or throwing an exception. If
733 /// IncludePossibleEffects is false, this call treats certain expressions with
734 /// potential side effects (such as function call-like expressions,
735 /// instantiation-dependent expressions, or invocations from a macro) as not
736 /// having side effects.
737 bool HasSideEffects(const ASTContext &Ctx,
738 bool IncludePossibleEffects = true) const;
739
740 /// Determine whether this expression involves a call to any function
741 /// that is not trivial.
742 bool hasNonTrivialCall(const ASTContext &Ctx) const;
743
744 /// EvaluateKnownConstInt - Call EvaluateAsRValue and return the folded
745 /// integer. This must be called on an expression that constant folds to an
746 /// integer.
747 llvm::APSInt EvaluateKnownConstInt(const ASTContext &Ctx) const;
748
750 const ASTContext &Ctx,
752
753 void EvaluateForOverflow(const ASTContext &Ctx) const;
754
755 /// EvaluateAsLValue - Evaluate an expression to see if we can fold it to an
756 /// lvalue with link time known address, with no side-effects.
757 bool EvaluateAsLValue(EvalResult &Result, const ASTContext &Ctx,
758 bool InConstantContext = false) const;
759
760 /// EvaluateAsInitializer - Evaluate an expression as if it were the
761 /// initializer of the given declaration. Returns true if the initializer
762 /// can be folded to a constant, and produces any relevant notes. In C++11,
763 /// notes will be produced if the expression is not a constant expression.
764 bool EvaluateAsInitializer(const ASTContext &Ctx, const VarDecl *VD,
765 EvalResult &Result,
766 bool IsConstantInitializer) const;
767
768 /// Evaluate an expression that is required by the language to be a constant
769 /// expression.
771 const ASTContext &Ctx,
772 SemaProxy &SProxy,
773 const VarDecl *VD) const;
774
775 /// EvaluateWithSubstitution - Evaluate an expression as if from the context
776 /// of a call to the given function with the given arguments, inside an
777 /// unevaluated context. Returns true if the expression could be folded to a
778 /// constant.
780 const FunctionDecl *Callee,
782 const Expr *This = nullptr) const;
783
784 enum class ConstantExprKind {
785 /// An integer constant expression (an array bound, enumerator, case value,
786 /// bit-field width, or similar) or similar.
788 /// A non-class template argument. Such a value is only used for mangling,
789 /// not for code generation, so can refer to dllimported functions.
791 /// A class template argument. Such a value is used for code generation.
793 /// An immediate invocation. The destruction of the end result of this
794 /// evaluation is not part of the evaluation, but all other temporaries
795 /// are destroyed.
797 /// The initializer of an object with static storage duration. The object
798 /// is not destroyed, and undefined behavior is folded through like
799 /// isConstantInitializer allows.
801 };
802
803 /// Evaluate an expression that is required to be a constant expression. Does
804 /// not check the syntactic constraints for C and C++98 constant expressions.
806 EvalResult &Result, const ASTContext &Ctx,
807 ConstantExprKind Kind = ConstantExprKind::Normal) const;
808
809 /// Evaluate an expression that is required by the language to be a constant
810 /// expression.
812 EvalResult &Result, const ASTContext &Ctx, SemaProxy &SProxy,
813 ConstantExprKind Kind = ConstantExprKind::Normal) const;
814
815 /// If the current Expr is a pointer, this will try to statically
816 /// determine the number of bytes available where the pointer is pointing.
817 /// Returns true if all of the above holds and we were able to figure out the
818 /// size, false otherwise.
819 ///
820 /// \param Type - How to evaluate the size of the Expr, as defined by the
821 /// "type" parameter of __builtin_object_size
822 std::optional<uint64_t> tryEvaluateObjectSize(const ASTContext &Ctx,
823 unsigned Type) const;
824
825 /// If the current Expr is a pointer, this will try to statically
826 /// determine the strlen of the string pointed to.
827 /// Returns true if all of the above holds and we were able to figure out the
828 /// strlen, false otherwise.
829 std::optional<uint64_t> tryEvaluateStrLen(const ASTContext &Ctx) const;
830
831 bool EvaluateCharRangeAsString(std::string &Result,
832 const Expr *SizeExpression,
833 const Expr *PtrExpression, ASTContext &Ctx,
834 SemaProxy &SProxy, EvalResult &Status) const;
835
836 bool EvaluateCharRangeAsString(APValue &Result, const Expr *SizeExpression,
837 const Expr *PtrExpression, ASTContext &Ctx,
838 SemaProxy &SProxy, EvalResult &Status) const;
839
840 /// If the current Expr can be evaluated to a pointer to a null-terminated
841 /// constant string, return the constant string (without the terminating
842 /// null).
843 std::optional<std::string> tryEvaluateString(ASTContext &Ctx) const;
844
845 /// Enumeration used to describe the kind of Null pointer constant
846 /// returned from \c isNullPointerConstant().
848 /// Expression is not a Null pointer constant.
850
851 /// Expression is a Null pointer constant built from a zero integer
852 /// expression that is not a simple, possibly parenthesized, zero literal.
853 /// C++ Core Issue 903 will classify these expressions as "not pointers"
854 /// once it is adopted.
855 /// http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#903
857
858 /// Expression is a Null pointer constant built from a literal zero.
860
861 /// Expression is a C++11 nullptr.
863
864 /// Expression is a GNU-style __null constant.
866 };
867
868 /// Enumeration used to describe how \c isNullPointerConstant()
869 /// should cope with value-dependent expressions.
871 /// Specifies that the expression should never be value-dependent.
873
874 /// Specifies that a value-dependent expression of integral or
875 /// dependent type should be considered a null pointer constant.
877
878 /// Specifies that a value-dependent expression should be considered
879 /// to never be a null pointer constant.
881 };
882
883 /// isNullPointerConstant - C99 6.3.2.3p3 - Test if this reduces down to
884 /// a Null pointer constant. The return value can further distinguish the
885 /// kind of NULL pointer constant that was detected.
887 ASTContext &Ctx,
889
890 /// isOBJCGCCandidate - Return true if this expression may be used in a read/
891 /// write barrier.
892 bool isOBJCGCCandidate(ASTContext &Ctx) const;
893
894 /// Returns true if this expression is a bound member function.
895 bool isBoundMemberFunction(ASTContext &Ctx) const;
896
897 /// Given an expression of bound-member type, find the type
898 /// of the member. Returns null if this is an *overloaded* bound
899 /// member expression.
900 static QualType findBoundMemberType(const Expr *expr);
901
902 /// Skip past any invisible AST nodes which might surround this
903 /// statement, such as ExprWithCleanups or ImplicitCastExpr nodes,
904 /// but also injected CXXMemberExpr and CXXConstructExpr which represent
905 /// implicit conversions.
908 return const_cast<Expr *>(this)->IgnoreUnlessSpelledInSource();
909 }
910
911 /// Skip past any implicit casts which might surround this expression until
912 /// reaching a fixed point. Skips:
913 /// * ImplicitCastExpr
914 /// * FullExpr
915 Expr *IgnoreImpCasts() LLVM_READONLY;
916 const Expr *IgnoreImpCasts() const {
917 return const_cast<Expr *>(this)->IgnoreImpCasts();
918 }
919
920 /// Skip past any casts which might surround this expression until reaching
921 /// a fixed point. Skips:
922 /// * CastExpr
923 /// * FullExpr
924 /// * MaterializeTemporaryExpr
925 /// * SubstNonTypeTemplateParmExpr
926 Expr *IgnoreCasts() LLVM_READONLY;
927 const Expr *IgnoreCasts() const {
928 return const_cast<Expr *>(this)->IgnoreCasts();
929 }
930
931 /// Skip past any implicit AST nodes which might surround this expression
932 /// until reaching a fixed point. Skips:
933 /// * What IgnoreImpCasts() skips
934 /// * MaterializeTemporaryExpr
935 /// * CXXBindTemporaryExpr
936 Expr *IgnoreImplicit() LLVM_READONLY;
937 const Expr *IgnoreImplicit() const {
938 return const_cast<Expr *>(this)->IgnoreImplicit();
939 }
940
941 /// Skip past any implicit AST nodes which might surround this expression
942 /// until reaching a fixed point. Same as IgnoreImplicit, except that it
943 /// also skips over implicit calls to constructors and conversion functions.
944 ///
945 /// FIXME: Should IgnoreImplicit do this?
946 Expr *IgnoreImplicitAsWritten() LLVM_READONLY;
948 return const_cast<Expr *>(this)->IgnoreImplicitAsWritten();
949 }
950
951 /// Skip past any parentheses which might surround this expression until
952 /// reaching a fixed point. Skips:
953 /// * ParenExpr
954 /// * UnaryOperator if `UO_Extension`
955 /// * GenericSelectionExpr if `!isResultDependent()`
956 /// * ChooseExpr if `!isConditionDependent()`
957 /// * ConstantExpr
958 Expr *IgnoreParens() LLVM_READONLY;
959 const Expr *IgnoreParens() const {
960 return const_cast<Expr *>(this)->IgnoreParens();
961 }
962
963 /// Skip past any parentheses and implicit casts which might surround this
964 /// expression until reaching a fixed point.
965 /// FIXME: IgnoreParenImpCasts really ought to be equivalent to
966 /// IgnoreParens() + IgnoreImpCasts() until reaching a fixed point. However
967 /// this is currently not the case. Instead IgnoreParenImpCasts() skips:
968 /// * What IgnoreParens() skips
969 /// * What IgnoreImpCasts() skips
970 /// * MaterializeTemporaryExpr
971 /// * SubstNonTypeTemplateParmExpr
972 Expr *IgnoreParenImpCasts() LLVM_READONLY;
973 const Expr *IgnoreParenImpCasts() const {
974 return const_cast<Expr *>(this)->IgnoreParenImpCasts();
975 }
976
977 /// Skip past any parentheses and casts which might surround this expression
978 /// until reaching a fixed point. Skips:
979 /// * What IgnoreParens() skips
980 /// * What IgnoreCasts() skips
981 Expr *IgnoreParenCasts() LLVM_READONLY;
982 const Expr *IgnoreParenCasts() const {
983 return const_cast<Expr *>(this)->IgnoreParenCasts();
984 }
985
986 /// Skip conversion operators. If this Expr is a call to a conversion
987 /// operator, return the argument.
990 return const_cast<Expr *>(this)->IgnoreConversionOperatorSingleStep();
991 }
992
993 /// Skip past any parentheses and lvalue casts which might surround this
994 /// expression until reaching a fixed point. Skips:
995 /// * What IgnoreParens() skips
996 /// * What IgnoreCasts() skips, except that only lvalue-to-rvalue
997 /// casts are skipped
998 /// FIXME: This is intended purely as a temporary workaround for code
999 /// that hasn't yet been rewritten to do the right thing about those
1000 /// casts, and may disappear along with the last internal use.
1001 Expr *IgnoreParenLValueCasts() LLVM_READONLY;
1003 return const_cast<Expr *>(this)->IgnoreParenLValueCasts();
1004 }
1005
1006 /// Skip past any parentheses and casts which do not change the value
1007 /// (including ptr->int casts of the same size) until reaching a fixed point.
1008 /// Skips:
1009 /// * What IgnoreParens() skips
1010 /// * CastExpr which do not change the value
1011 /// * SubstNonTypeTemplateParmExpr
1012 Expr *IgnoreParenNoopCasts(const ASTContext &Ctx) LLVM_READONLY;
1013 const Expr *IgnoreParenNoopCasts(const ASTContext &Ctx) const {
1014 return const_cast<Expr *>(this)->IgnoreParenNoopCasts(Ctx);
1015 }
1016
1017 /// Skip past any parentheses and derived-to-base casts until reaching a
1018 /// fixed point. Skips:
1019 /// * What IgnoreParens() skips
1020 /// * CastExpr which represent a derived-to-base cast (CK_DerivedToBase,
1021 /// CK_UncheckedDerivedToBase and CK_NoOp)
1022 Expr *IgnoreParenBaseCasts() LLVM_READONLY;
1024 return const_cast<Expr *>(this)->IgnoreParenBaseCasts();
1025 }
1026
1027 /// Determine whether this expression is a default function argument.
1028 ///
1029 /// Default arguments are implicitly generated in the abstract syntax tree
1030 /// by semantic analysis for function calls, object constructions, etc. in
1031 /// C++. Default arguments are represented by \c CXXDefaultArgExpr nodes;
1032 /// this routine also looks through any implicit casts to determine whether
1033 /// the expression is a default argument.
1034 bool isDefaultArgument() const;
1035
1036 /// Determine whether the result of this expression is a
1037 /// temporary object of the given class type.
1038 bool isTemporaryObject(ASTContext &Ctx, const CXXRecordDecl *TempTy) const;
1039
1040 /// Whether this expression is an implicit reference to 'this' in C++.
1041 bool isImplicitCXXThis() const;
1042
1044
1045 /// For an expression of class type or pointer to class type,
1046 /// return the most derived class decl the expression is known to refer to.
1047 ///
1048 /// If this expression is a cast, this method looks through it to find the
1049 /// most derived decl that can be inferred from the expression.
1050 /// This is valid because derived-to-base conversions have undefined
1051 /// behavior if the object isn't dynamically of the derived type.
1053
1054 /// Get the inner expression that determines the best dynamic class.
1055 /// If this is a prvalue, we guarantee that it is of the most-derived type
1056 /// for the object itself.
1057 const Expr *getBestDynamicClassTypeExpr() const;
1058
1059 /// Walk outwards from an expression we want to bind a reference to and
1060 /// find the expression whose lifetime needs to be extended. Record
1061 /// the LHSs of comma expressions and adjustments needed along the path.
1064 SmallVectorImpl<SubobjectAdjustment> &Adjustments) const;
1068 return skipRValueSubobjectAdjustments(CommaLHSs, Adjustments);
1069 }
1070
1071 /// Checks that the two Expr's will refer to the same value as a comparison
1072 /// operand. The caller must ensure that the values referenced by the Expr's
1073 /// are not modified between E1 and E2 or the result my be invalid.
1074 static bool isSameComparisonOperand(const Expr* E1, const Expr* E2);
1075
1076 static bool classof(const Stmt *T) {
1077 return T->getStmtClass() >= firstExprConstant &&
1078 T->getStmtClass() <= lastExprConstant;
1079 }
1080};
1081// PointerLikeTypeTraits is specialized so it can be used with a forward-decl of
1082// Expr. Verify that we got it right.
1084 llvm::ConstantLog2<alignof(Expr)>(),
1085 "PointerLikeTypeTraits<Expr*> assumes too much alignment.");
1086
1088
1089//===----------------------------------------------------------------------===//
1090// Wrapper Expressions.
1091//===----------------------------------------------------------------------===//
1092
1093/// FullExpr - Represents a "full-expression" node.
1094class FullExpr : public Expr {
1095protected:
1097
1099 : Expr(SC, subexpr->getType(), subexpr->getValueKind(),
1100 subexpr->getObjectKind()),
1101 SubExpr(subexpr) {
1103 }
1106public:
1107 const Expr *getSubExpr() const { return cast<Expr>(SubExpr); }
1109
1110 /// As with any mutator of the AST, be very careful when modifying an
1111 /// existing AST to preserve its invariants.
1112 void setSubExpr(Expr *E) { SubExpr = E; }
1113
1114 static bool classof(const Stmt *T) {
1115 return T->getStmtClass() >= firstFullExprConstant &&
1116 T->getStmtClass() <= lastFullExprConstant;
1117 }
1118};
1119
1120/// Describes the kind of result that can be tail-allocated.
1122
1123/// An expression that occurs in a constant context and
1124/// the result of evaluating the expression.
1125class ConstantExpr final
1126 : public FullExpr,
1127 private llvm::TrailingObjects<ConstantExpr, APValue, uint64_t> {
1128 static_assert(std::is_same<uint64_t, llvm::APInt::WordType>::value,
1129 "ConstantExpr assumes that llvm::APInt::WordType is uint64_t "
1130 "for tail-allocated storage");
1131 friend TrailingObjects;
1132 friend class ASTStmtReader;
1133 friend class ASTStmtWriter;
1134
1135 size_t numTrailingObjects(OverloadToken<APValue>) const {
1137 }
1138 size_t numTrailingObjects(OverloadToken<uint64_t>) const {
1140 }
1141
1142 uint64_t &Int64Result() {
1144 "invalid accessor");
1145 return *getTrailingObjects<uint64_t>();
1146 }
1147 const uint64_t &Int64Result() const {
1148 return const_cast<ConstantExpr *>(this)->Int64Result();
1149 }
1150 APValue &APValueResult() {
1152 "invalid accessor");
1153 return *getTrailingObjects<APValue>();
1154 }
1155 APValue &APValueResult() const {
1156 return const_cast<ConstantExpr *>(this)->APValueResult();
1157 }
1158
1159 ConstantExpr(Expr *SubExpr, ConstantResultStorageKind StorageKind,
1160 bool IsImmediateInvocation);
1161 ConstantExpr(EmptyShell Empty, ConstantResultStorageKind StorageKind);
1162
1163public:
1164 static ConstantExpr *Create(const ASTContext &Context, Expr *E,
1165 const APValue &Result);
1166 static ConstantExpr *
1167 Create(const ASTContext &Context, Expr *E,
1169 bool IsImmediateInvocation = false);
1170 static ConstantExpr *CreateEmpty(const ASTContext &Context,
1171 ConstantResultStorageKind StorageKind);
1172
1175 const ASTContext &Context);
1176
1177 SourceLocation getBeginLoc() const LLVM_READONLY {
1178 return SubExpr->getBeginLoc();
1179 }
1180 SourceLocation getEndLoc() const LLVM_READONLY {
1181 return SubExpr->getEndLoc();
1182 }
1183
1184 static bool classof(const Stmt *T) {
1185 return T->getStmtClass() == ConstantExprClass;
1186 }
1187
1188 void SetResult(APValue Value, const ASTContext &Context) {
1189 MoveIntoResult(Value, Context);
1190 }
1191 void MoveIntoResult(APValue &Value, const ASTContext &Context);
1192
1194 return static_cast<APValue::ValueKind>(ConstantExprBits.APValueKind);
1195 }
1200 return ConstantExprBits.IsImmediateInvocation;
1201 }
1202 bool hasAPValueResult() const {
1203 return ConstantExprBits.APValueKind != APValue::None;
1204 }
1205 APValue getAPValueResult() const;
1206 llvm::APSInt getResultAsAPSInt() const;
1207 // Iterators
1210 return const_child_range(&SubExpr, &SubExpr + 1);
1211 }
1212};
1213
1214//===----------------------------------------------------------------------===//
1215// Primary Expressions.
1216//===----------------------------------------------------------------------===//
1217
1218/// OpaqueValueExpr - An expression referring to an opaque object of a
1219/// fixed type and value class. These don't correspond to concrete
1220/// syntax; instead they're used to express operations (usually copy
1221/// operations) on values whose source is generally obvious from
1222/// context.
1223class OpaqueValueExpr : public Expr {
1224 friend class ASTStmtReader;
1225 Expr *SourceExpr;
1226
1227public:
1229 ExprObjectKind OK = OK_Ordinary, Expr *SourceExpr = nullptr)
1230 : Expr(OpaqueValueExprClass, T, VK, OK), SourceExpr(SourceExpr) {
1231 setIsUnique(false);
1232 OpaqueValueExprBits.Loc = Loc;
1234 }
1235
1236 /// Given an expression which invokes a copy constructor --- i.e. a
1237 /// CXXConstructExpr, possibly wrapped in an ExprWithCleanups ---
1238 /// find the OpaqueValueExpr that's the source of the construction.
1239 static const OpaqueValueExpr *findInCopyConstruct(const Expr *expr);
1240
1242 : Expr(OpaqueValueExprClass, Empty) {}
1243
1244 /// Retrieve the location of this expression.
1246
1247 SourceLocation getBeginLoc() const LLVM_READONLY {
1248 return SourceExpr ? SourceExpr->getBeginLoc() : getLocation();
1249 }
1250 SourceLocation getEndLoc() const LLVM_READONLY {
1251 return SourceExpr ? SourceExpr->getEndLoc() : getLocation();
1252 }
1253 SourceLocation getExprLoc() const LLVM_READONLY {
1254 return SourceExpr ? SourceExpr->getExprLoc() : getLocation();
1255 }
1256
1260
1264
1265 /// The source expression of an opaque value expression is the
1266 /// expression which originally generated the value. This is
1267 /// provided as a convenience for analyses that don't wish to
1268 /// precisely model the execution behavior of the program.
1269 ///
1270 /// The source expression is typically set when building the
1271 /// expression which binds the opaque value expression in the first
1272 /// place.
1273 Expr *getSourceExpr() const { return SourceExpr; }
1274
1275 void setIsUnique(bool V) {
1276 assert((!V || SourceExpr) &&
1277 "unique OVEs are expected to have source expressions");
1278 OpaqueValueExprBits.IsUnique = V;
1279 }
1280
1281 bool isUnique() const { return OpaqueValueExprBits.IsUnique; }
1282
1283 static bool classof(const Stmt *T) {
1284 return T->getStmtClass() == OpaqueValueExprClass;
1285 }
1286};
1287
1288/// A reference to a declared variable, function, enum, etc.
1289/// [C99 6.5.1p2]
1290///
1291/// This encodes all the information about how a declaration is referenced
1292/// within an expression.
1293///
1294/// There are several optional constructs attached to DeclRefExprs only when
1295/// they apply in order to conserve memory. These are laid out past the end of
1296/// the object, and flags in the DeclRefExprBitfield track whether they exist:
1297///
1298/// DeclRefExprBits.HasQualifier:
1299/// Specifies when this declaration reference expression has a C++
1300/// nested-name-specifier.
1301/// DeclRefExprBits.HasFoundDecl:
1302/// Specifies when this declaration reference expression has a record of
1303/// a NamedDecl (different from the referenced ValueDecl) which was found
1304/// during name lookup and/or overload resolution.
1305/// DeclRefExprBits.HasTemplateKWAndArgsInfo:
1306/// Specifies when this declaration reference expression has an explicit
1307/// C++ template keyword and/or template argument list.
1308/// DeclRefExprBits.RefersToEnclosingVariableOrCapture
1309/// Specifies when this declaration reference expression (validly)
1310/// refers to an enclosed local or a captured variable.
1311class DeclRefExpr final
1312 : public Expr,
1313 private llvm::TrailingObjects<DeclRefExpr, NestedNameSpecifierLoc,
1314 NamedDecl *, ASTTemplateKWAndArgsInfo,
1315 TemplateArgumentLoc> {
1316 friend class ASTStmtReader;
1317 friend class ASTStmtWriter;
1318 friend TrailingObjects;
1319
1320 /// The declaration that we are referencing.
1321 ValueDecl *D;
1322
1323 /// Provides source/type location info for the declaration name
1324 /// embedded in D.
1325 DeclarationNameLoc DNLoc;
1326
1327 size_t numTrailingObjects(OverloadToken<NestedNameSpecifierLoc>) const {
1328 return hasQualifier();
1329 }
1330
1331 size_t numTrailingObjects(OverloadToken<NamedDecl *>) const {
1332 return hasFoundDecl();
1333 }
1334
1335 size_t numTrailingObjects(OverloadToken<ASTTemplateKWAndArgsInfo>) const {
1336 return hasTemplateKWAndArgsInfo();
1337 }
1338
1339 /// Test whether there is a distinct FoundDecl attached to the end of
1340 /// this DRE.
1341 bool hasFoundDecl() const { return DeclRefExprBits.HasFoundDecl; }
1342
1343 DeclRefExpr(const ASTContext &Ctx, NestedNameSpecifierLoc QualifierLoc,
1344 SourceLocation TemplateKWLoc, ValueDecl *D,
1345 bool RefersToEnclosingVariableOrCapture,
1346 const DeclarationNameInfo &NameInfo, NamedDecl *FoundD,
1347 const TemplateArgumentListInfo *TemplateArgs, QualType T,
1349
1350 /// Construct an empty declaration reference expression.
1351 explicit DeclRefExpr(EmptyShell Empty) : Expr(DeclRefExprClass, Empty) {}
1352
1353public:
1354 DeclRefExpr(const ASTContext &Ctx, ValueDecl *D,
1355 bool RefersToEnclosingVariableOrCapture, QualType T,
1356 ExprValueKind VK, SourceLocation L,
1357 const DeclarationNameLoc &LocInfo = DeclarationNameLoc(),
1358 NonOdrUseReason NOUR = NOUR_None);
1359
1360 static DeclRefExpr *
1361 Create(const ASTContext &Context, NestedNameSpecifierLoc QualifierLoc,
1362 SourceLocation TemplateKWLoc, ValueDecl *D,
1363 bool RefersToEnclosingVariableOrCapture, SourceLocation NameLoc,
1364 QualType T, ExprValueKind VK, NamedDecl *FoundD = nullptr,
1365 const TemplateArgumentListInfo *TemplateArgs = nullptr,
1366 NonOdrUseReason NOUR = NOUR_None);
1367
1368 static DeclRefExpr *
1369 Create(const ASTContext &Context, NestedNameSpecifierLoc QualifierLoc,
1370 SourceLocation TemplateKWLoc, ValueDecl *D,
1371 bool RefersToEnclosingVariableOrCapture,
1372 const DeclarationNameInfo &NameInfo, QualType T, ExprValueKind VK,
1373 NamedDecl *FoundD = nullptr,
1374 const TemplateArgumentListInfo *TemplateArgs = nullptr,
1375 NonOdrUseReason NOUR = NOUR_None);
1376
1377 /// Construct an empty declaration reference expression.
1378 static DeclRefExpr *CreateEmpty(const ASTContext &Context, bool HasQualifier,
1379 bool HasFoundDecl,
1380 bool HasTemplateKWAndArgsInfo,
1381 unsigned NumTemplateArgs);
1382
1383 ValueDecl *getDecl() { return D; }
1384 const ValueDecl *getDecl() const { return D; }
1385 void setDecl(ValueDecl *NewD);
1386
1388 return DeclarationNameInfo(getDecl()->getDeclName(), getLocation(), DNLoc);
1389 }
1390
1393
1395 if (hasQualifier())
1396 return getQualifierLoc().getBeginLoc();
1397 return DeclRefExprBits.Loc;
1398 }
1399
1400 SourceLocation getEndLoc() const LLVM_READONLY;
1401
1402 /// Determine whether this declaration reference was preceded by a
1403 /// C++ nested-name-specifier, e.g., \c N::foo.
1404 bool hasQualifier() const { return DeclRefExprBits.HasQualifier; }
1405
1406 /// If the name was qualified, retrieves the nested-name-specifier
1407 /// that precedes the name, with source-location information.
1409 if (!hasQualifier())
1410 return NestedNameSpecifierLoc();
1411 return *getTrailingObjects<NestedNameSpecifierLoc>();
1412 }
1413
1414 /// If the name was qualified, retrieves the nested-name-specifier
1415 /// that precedes the name. Otherwise, returns NULL.
1419
1420 /// Get the NamedDecl through which this reference occurred.
1421 ///
1422 /// This Decl may be different from the ValueDecl actually referred to in the
1423 /// presence of using declarations, etc. It always returns non-NULL, and may
1424 /// simple return the ValueDecl when appropriate.
1425
1427 return hasFoundDecl() ? *getTrailingObjects<NamedDecl *>() : D;
1428 }
1429
1430 /// Get the NamedDecl through which this reference occurred.
1431 /// See non-const variant.
1432 const NamedDecl *getFoundDecl() const {
1433 return hasFoundDecl() ? *getTrailingObjects<NamedDecl *>() : D;
1434 }
1435
1437 return DeclRefExprBits.HasTemplateKWAndArgsInfo;
1438 }
1439
1440 /// Retrieve the location of the template keyword preceding
1441 /// this name, if any.
1444 return SourceLocation();
1445 return getTrailingObjects<ASTTemplateKWAndArgsInfo>()->TemplateKWLoc;
1446 }
1447
1448 /// Retrieve the location of the left angle bracket starting the
1449 /// explicit template argument list following the name, if any.
1452 return SourceLocation();
1453 return getTrailingObjects<ASTTemplateKWAndArgsInfo>()->LAngleLoc;
1454 }
1455
1456 /// Retrieve the location of the right angle bracket ending the
1457 /// explicit template argument list following the name, if any.
1460 return SourceLocation();
1461 return getTrailingObjects<ASTTemplateKWAndArgsInfo>()->RAngleLoc;
1462 }
1463
1464 /// Determines whether the name in this declaration reference
1465 /// was preceded by the template keyword.
1467
1468 /// Determines whether this declaration reference was followed by an
1469 /// explicit template argument list.
1470 bool hasExplicitTemplateArgs() const { return getLAngleLoc().isValid(); }
1471
1472 /// Copies the template arguments (if present) into the given
1473 /// structure.
1476 getTrailingObjects<ASTTemplateKWAndArgsInfo>()->copyInto(
1477 getTrailingObjects<TemplateArgumentLoc>(), List);
1478 }
1479
1480 /// Retrieve the template arguments provided as part of this
1481 /// template-id.
1484 return nullptr;
1485 return getTrailingObjects<TemplateArgumentLoc>();
1486 }
1487
1488 /// Retrieve the number of template arguments provided as part of this
1489 /// template-id.
1490 unsigned getNumTemplateArgs() const {
1492 return 0;
1493 return getTrailingObjects<ASTTemplateKWAndArgsInfo>()->NumTemplateArgs;
1494 }
1495
1499
1500 /// Returns true if this expression refers to a function that
1501 /// was resolved from an overloaded set having size greater than 1.
1503 return DeclRefExprBits.HadMultipleCandidates;
1504 }
1505 /// Sets the flag telling whether this expression refers to
1506 /// a function that was resolved from an overloaded set having size
1507 /// greater than 1.
1508 void setHadMultipleCandidates(bool V = true) {
1509 DeclRefExprBits.HadMultipleCandidates = V;
1510 }
1511
1512 /// Is this expression a non-odr-use reference, and if so, why?
1514 return static_cast<NonOdrUseReason>(DeclRefExprBits.NonOdrUseReason);
1515 }
1516
1517 /// Does this DeclRefExpr refer to an enclosing local or a captured
1518 /// variable?
1520 return DeclRefExprBits.RefersToEnclosingVariableOrCapture;
1521 }
1522
1524 return DeclRefExprBits.IsImmediateEscalating;
1525 }
1526
1528 DeclRefExprBits.IsImmediateEscalating = Set;
1529 }
1530
1532 return DeclRefExprBits.CapturedByCopyInLambdaWithExplicitObjectParameter;
1533 }
1534
1536 bool Set, const ASTContext &Context) {
1537 DeclRefExprBits.CapturedByCopyInLambdaWithExplicitObjectParameter = Set;
1538 setDependence(computeDependence(this, Context));
1539 }
1540
1541 static bool classof(const Stmt *T) {
1542 return T->getStmtClass() == DeclRefExprClass;
1543 }
1544
1545 // Iterators
1549
1553};
1554
1555class IntegerLiteral : public Expr, public APIntStorage {
1556 SourceLocation Loc;
1557
1558 /// Construct an empty integer literal.
1559 explicit IntegerLiteral(EmptyShell Empty)
1560 : Expr(IntegerLiteralClass, Empty) { }
1561
1562public:
1563 // type should be IntTy, LongTy, LongLongTy, UnsignedIntTy, UnsignedLongTy,
1564 // or UnsignedLongLongTy
1565 IntegerLiteral(const ASTContext &C, const llvm::APInt &V, QualType type,
1566 SourceLocation l);
1567
1568 /// Returns a new integer literal with value 'V' and type 'type'.
1569 /// \param type - either IntTy, LongTy, LongLongTy, UnsignedIntTy,
1570 /// UnsignedLongTy, or UnsignedLongLongTy which should match the size of V
1571 /// \param V - the value that the returned integer literal contains.
1572 static IntegerLiteral *Create(const ASTContext &C, const llvm::APInt &V,
1574 /// Returns a new empty integer literal.
1575 static IntegerLiteral *Create(const ASTContext &C, EmptyShell Empty);
1576
1577 SourceLocation getBeginLoc() const LLVM_READONLY { return Loc; }
1578 SourceLocation getEndLoc() const LLVM_READONLY { return Loc; }
1579
1580 /// Retrieve the location of the literal.
1581 SourceLocation getLocation() const { return Loc; }
1582
1583 void setLocation(SourceLocation Location) { Loc = Location; }
1584
1585 static bool classof(const Stmt *T) {
1586 return T->getStmtClass() == IntegerLiteralClass;
1587 }
1588
1589 // Iterators
1596};
1597
1598class FixedPointLiteral : public Expr, public APIntStorage {
1599 SourceLocation Loc;
1600 unsigned Scale;
1601
1602 /// \brief Construct an empty fixed-point literal.
1603 explicit FixedPointLiteral(EmptyShell Empty)
1604 : Expr(FixedPointLiteralClass, Empty) {}
1605
1606 public:
1607 FixedPointLiteral(const ASTContext &C, const llvm::APInt &V, QualType type,
1608 SourceLocation l, unsigned Scale);
1609
1610 // Store the int as is without any bit shifting.
1611 static FixedPointLiteral *CreateFromRawInt(const ASTContext &C,
1612 const llvm::APInt &V,
1614 unsigned Scale);
1615
1616 /// Returns an empty fixed-point literal.
1617 static FixedPointLiteral *Create(const ASTContext &C, EmptyShell Empty);
1618
1619 /// Returns an internal integer representation of the literal.
1620 llvm::APInt getValue() const { return APIntStorage::getValue(); }
1621
1622 SourceLocation getBeginLoc() const LLVM_READONLY { return Loc; }
1623 SourceLocation getEndLoc() const LLVM_READONLY { return Loc; }
1624
1625 /// \brief Retrieve the location of the literal.
1626 SourceLocation getLocation() const { return Loc; }
1627
1628 void setLocation(SourceLocation Location) { Loc = Location; }
1629
1630 unsigned getScale() const { return Scale; }
1631 void setScale(unsigned S) { Scale = S; }
1632
1633 static bool classof(const Stmt *T) {
1634 return T->getStmtClass() == FixedPointLiteralClass;
1635 }
1636
1637 std::string getValueAsString(unsigned Radix) const;
1638
1639 // Iterators
1646};
1647
1649
1650class CharacterLiteral : public Expr {
1651 unsigned Value;
1652 SourceLocation Loc;
1653public:
1654 // type should be IntTy
1657 : Expr(CharacterLiteralClass, type, VK_PRValue, OK_Ordinary),
1658 Value(value), Loc(l) {
1659 CharacterLiteralBits.Kind = llvm::to_underlying(kind);
1660 setDependence(ExprDependence::None);
1661 }
1662
1663 /// Construct an empty character literal.
1664 CharacterLiteral(EmptyShell Empty) : Expr(CharacterLiteralClass, Empty) { }
1665
1666 SourceLocation getLocation() const { return Loc; }
1668 return static_cast<CharacterLiteralKind>(CharacterLiteralBits.Kind);
1669 }
1670
1671 SourceLocation getBeginLoc() const LLVM_READONLY { return Loc; }
1672 SourceLocation getEndLoc() const LLVM_READONLY { return Loc; }
1673
1674 unsigned getValue() const { return Value; }
1675
1676 void setLocation(SourceLocation Location) { Loc = Location; }
1678 CharacterLiteralBits.Kind = llvm::to_underlying(kind);
1679 }
1680 void setValue(unsigned Val) { Value = Val; }
1681
1682 static bool classof(const Stmt *T) {
1683 return T->getStmtClass() == CharacterLiteralClass;
1684 }
1685
1686 static void print(unsigned val, CharacterLiteralKind Kind, raw_ostream &OS);
1687
1688 // Iterators
1695};
1696
1697class FloatingLiteral : public Expr, private APFloatStorage {
1698 SourceLocation Loc;
1699
1700 FloatingLiteral(const ASTContext &C, const llvm::APFloat &V, bool isexact,
1702
1703 /// Construct an empty floating-point literal.
1704 explicit FloatingLiteral(const ASTContext &C, EmptyShell Empty);
1705
1706public:
1707 static FloatingLiteral *Create(const ASTContext &C, const llvm::APFloat &V,
1708 bool isexact, QualType Type, SourceLocation L);
1709 static FloatingLiteral *Create(const ASTContext &C, EmptyShell Empty);
1710
1711 llvm::APFloat getValue() const {
1713 }
1714 void setValue(const ASTContext &C, const llvm::APFloat &Val) {
1715 assert(&getSemantics() == &Val.getSemantics() && "Inconsistent semantics");
1717 }
1718
1719 /// Get a raw enumeration value representing the floating-point semantics of
1720 /// this literal (32-bit IEEE, x87, ...), suitable for serialization.
1721 llvm::APFloatBase::Semantics getRawSemantics() const {
1722 return static_cast<llvm::APFloatBase::Semantics>(
1723 FloatingLiteralBits.Semantics);
1724 }
1725
1726 /// Set the raw enumeration value representing the floating-point semantics of
1727 /// this literal (32-bit IEEE, x87, ...), suitable for serialization.
1728 void setRawSemantics(llvm::APFloatBase::Semantics Sem) {
1729 FloatingLiteralBits.Semantics = Sem;
1730 }
1731
1732 /// Return the APFloat semantics this literal uses.
1733 const llvm::fltSemantics &getSemantics() const {
1734 return llvm::APFloatBase::EnumToSemantics(
1735 static_cast<llvm::APFloatBase::Semantics>(
1736 FloatingLiteralBits.Semantics));
1737 }
1738
1739 /// Set the APFloat semantics this literal uses.
1740 void setSemantics(const llvm::fltSemantics &Sem) {
1741 FloatingLiteralBits.Semantics = llvm::APFloatBase::SemanticsToEnum(Sem);
1742 }
1743
1744 bool isExact() const { return FloatingLiteralBits.IsExact; }
1745 void setExact(bool E) { FloatingLiteralBits.IsExact = E; }
1746
1747 /// getValueAsApproximateDouble - This returns the value as an inaccurate
1748 /// double. Note that this may cause loss of precision, but is useful for
1749 /// debugging dumps, etc.
1750 double getValueAsApproximateDouble() const;
1751
1752 SourceLocation getLocation() const { return Loc; }
1753 void setLocation(SourceLocation L) { Loc = L; }
1754
1755 SourceLocation getBeginLoc() const LLVM_READONLY { return Loc; }
1756 SourceLocation getEndLoc() const LLVM_READONLY { return Loc; }
1757
1758 static bool classof(const Stmt *T) {
1759 return T->getStmtClass() == FloatingLiteralClass;
1760 }
1761
1762 // Iterators
1769};
1770
1771/// ImaginaryLiteral - We support imaginary integer and floating point literals,
1772/// like "1.0i". We represent these as a wrapper around FloatingLiteral and
1773/// IntegerLiteral classes. Instances of this class always have a Complex type
1774/// whose element type matches the subexpression.
1775///
1776class ImaginaryLiteral : public Expr {
1777 Stmt *Val;
1778public:
1780 : Expr(ImaginaryLiteralClass, Ty, VK_PRValue, OK_Ordinary), Val(val) {
1781 setDependence(ExprDependence::None);
1782 }
1783
1784 /// Build an empty imaginary literal.
1786 : Expr(ImaginaryLiteralClass, Empty) { }
1787
1788 const Expr *getSubExpr() const { return cast<Expr>(Val); }
1789 Expr *getSubExpr() { return cast<Expr>(Val); }
1790 void setSubExpr(Expr *E) { Val = E; }
1791
1792 SourceLocation getBeginLoc() const LLVM_READONLY {
1793 return Val->getBeginLoc();
1794 }
1795 SourceLocation getEndLoc() const LLVM_READONLY { return Val->getEndLoc(); }
1796
1797 static bool classof(const Stmt *T) {
1798 return T->getStmtClass() == ImaginaryLiteralClass;
1799 }
1800
1801 // Iterators
1802 child_range children() { return child_range(&Val, &Val+1); }
1804 return const_child_range(&Val, &Val + 1);
1805 }
1806};
1807
1815 // Binary kind of string literal is used for the data coming via #embed
1816 // directive. File's binary contents is transformed to a special kind of
1817 // string literal that in some cases may be used directly as an initializer
1818 // and some features of classic string literals are not applicable to this
1819 // kind of a string literal, for example finding a particular byte's source
1820 // location for better diagnosing.
1822};
1823
1824/// StringLiteral - This represents a string literal expression, e.g. "foo"
1825/// or L"bar" (wide strings). The actual string data can be obtained with
1826/// getBytes() and is NOT null-terminated. The length of the string data is
1827/// determined by calling getByteLength().
1828///
1829/// The C type for a string is always a ConstantArrayType. In C++, the char
1830/// type is const qualified, in C it is not.
1831///
1832/// Note that strings in C can be formed by concatenation of multiple string
1833/// literal pptokens in translation phase #6. This keeps track of the locations
1834/// of each of these pieces.
1835///
1836/// Strings in C can also be truncated and extended by assigning into arrays,
1837/// e.g. with constructs like:
1838/// char X[2] = "foobar";
1839/// In this case, getByteLength() will return 6, but the string literal will
1840/// have type "char[2]".
1841class StringLiteral final
1842 : public Expr,
1843 private llvm::TrailingObjects<StringLiteral, unsigned, SourceLocation,
1844 char> {
1845 friend class ASTStmtReader;
1846 friend TrailingObjects;
1847
1848 /// StringLiteral is followed by several trailing objects. They are in order:
1849 ///
1850 /// * A single unsigned storing the length in characters of this string. The
1851 /// length in bytes is this length times the width of a single character.
1852 /// Always present and stored as a trailing objects because storing it in
1853 /// StringLiteral would increase the size of StringLiteral by sizeof(void *)
1854 /// due to alignment requirements. If you add some data to StringLiteral,
1855 /// consider moving it inside StringLiteral.
1856 ///
1857 /// * An array of getNumConcatenated() SourceLocation, one for each of the
1858 /// token this string is made of.
1859 ///
1860 /// * An array of getByteLength() char used to store the string data.
1861
1862 unsigned numTrailingObjects(OverloadToken<unsigned>) const { return 1; }
1863 unsigned numTrailingObjects(OverloadToken<SourceLocation>) const {
1864 return getNumConcatenated();
1865 }
1866
1867 unsigned numTrailingObjects(OverloadToken<char>) const {
1868 return getByteLength();
1869 }
1870
1871 char *getStrDataAsChar() { return getTrailingObjects<char>(); }
1872 const char *getStrDataAsChar() const { return getTrailingObjects<char>(); }
1873
1874 const uint16_t *getStrDataAsUInt16() const {
1875 return reinterpret_cast<const uint16_t *>(getTrailingObjects<char>());
1876 }
1877
1878 const uint32_t *getStrDataAsUInt32() const {
1879 return reinterpret_cast<const uint32_t *>(getTrailingObjects<char>());
1880 }
1881
1882 /// Build a string literal.
1883 StringLiteral(const ASTContext &Ctx, StringRef Str, StringLiteralKind Kind,
1884 bool Pascal, QualType Ty, ArrayRef<SourceLocation> Locs);
1885
1886 /// Build an empty string literal.
1887 StringLiteral(EmptyShell Empty, unsigned NumConcatenated, unsigned Length,
1888 unsigned CharByteWidth);
1889
1890 /// Map a target and string kind to the appropriate character width.
1891 static unsigned mapCharByteWidth(TargetInfo const &Target,
1893
1894 /// Set one of the string literal token.
1895 void setStrTokenLoc(unsigned TokNum, SourceLocation L) {
1896 assert(TokNum < getNumConcatenated() && "Invalid tok number");
1897 getTrailingObjects<SourceLocation>()[TokNum] = L;
1898 }
1899
1900public:
1901 /// This is the "fully general" constructor that allows representation of
1902 /// strings formed from one or more concatenated tokens.
1903 static StringLiteral *Create(const ASTContext &Ctx, StringRef Str,
1904 StringLiteralKind Kind, bool Pascal, QualType Ty,
1905 ArrayRef<SourceLocation> Locs);
1906
1907 /// Construct an empty string literal.
1908 static StringLiteral *CreateEmpty(const ASTContext &Ctx,
1909 unsigned NumConcatenated, unsigned Length,
1910 unsigned CharByteWidth);
1911
1912 StringRef getString() const {
1913 assert((isUnevaluated() || getCharByteWidth() == 1) &&
1914 "This function is used in places that assume strings use char");
1915 return StringRef(getStrDataAsChar(), getByteLength());
1916 }
1917
1918 /// Allow access to clients that need the byte representation, such as
1919 /// ASTWriterStmt::VisitStringLiteral().
1920 StringRef getBytes() const {
1921 // FIXME: StringRef may not be the right type to use as a result for this.
1922 return StringRef(getStrDataAsChar(), getByteLength());
1923 }
1924
1925 /// Prints the contents of the string to \p OS.
1926 void outputString(raw_ostream &OS) const;
1927
1928 /// Return the code unit at the given position.
1929 ///
1930 /// \pre \p I < getLength()
1931 uint32_t getCodeUnit(size_t I) const {
1932 assert(I < getLength() && "out of bounds access");
1933 switch (getCharByteWidth()) {
1934 case 1:
1935 return static_cast<unsigned char>(getStrDataAsChar()[I]);
1936 case 2:
1937 return getStrDataAsUInt16()[I];
1938 case 4:
1939 return getStrDataAsUInt32()[I];
1940 }
1941 llvm_unreachable("Unsupported character width!");
1942 }
1943
1944 // Get code unit but preserve sign info.
1945 int64_t getCodeUnitS(size_t I, uint64_t BitWidth) const {
1946 int64_t V = getCodeUnit(I);
1947 if (isOrdinary() || isWide()) {
1948 // Ordinary and wide string literals have types that can be signed.
1949 // It is important for checking C23 constexpr initializers.
1950 unsigned Width = getCharByteWidth() * BitWidth;
1951 llvm::APInt AInt(Width, (uint64_t)V);
1952 V = AInt.getSExtValue();
1953 }
1954 return V;
1955 }
1956
1957 /// Scan the string literal contents for a code unit with value 0.
1958 /// If \p StartIndex is outside of the length of the string, this returns \c
1959 /// std::nullopt.
1960 ///
1961 /// Otherwise, returns the offset (in code units, not bytes) of the zero code
1962 /// unit, starting at index \p StartIndex. If no such code unit could be
1963 /// found, this returns `getLength() - StartIndex`.
1964 UnsignedOrNone findZeroCodeUnit(unsigned StartIndex = 0) const;
1965
1966 /// \returns The length of the full string in bytes.
1967 unsigned getByteLength() const { return getCharByteWidth() * getLength(); }
1968 /// \returns The length of the full string in characters.
1969 unsigned getLength() const { return *getTrailingObjects<unsigned>(); }
1970 /// \returns The size of one character in the string, in bytes.
1971 unsigned getCharByteWidth() const { return StringLiteralBits.CharByteWidth; }
1972
1974 return static_cast<StringLiteralKind>(StringLiteralBits.Kind);
1975 }
1976
1977 bool isOrdinary() const { return getKind() == StringLiteralKind::Ordinary; }
1978 bool isWide() const { return getKind() == StringLiteralKind::Wide; }
1979 bool isUTF8() const { return getKind() == StringLiteralKind::UTF8; }
1980 bool isUTF16() const { return getKind() == StringLiteralKind::UTF16; }
1981 bool isUTF32() const { return getKind() == StringLiteralKind::UTF32; }
1983 bool isPascal() const { return StringLiteralBits.IsPascal; }
1984
1985 /// Scans the string contents for any non-ascii characters.
1986 ///
1987 /// \pre isUnevaluated() || getCharByteWidth() == 1
1988 /// \returns \c true if a non-ascii character was found, \c false otherwise.
1989 bool containsNonAscii() const {
1990 for (auto c : getString())
1991 if (!isASCII(c))
1992 return true;
1993 return false;
1994 }
1995
1996 /// Scans the string contents for any non-ascii or null characters.
1997 ///
1998 /// \pre isUnevaluated() || getCharByteWidth() == 1
1999 /// \returns \c true if a non-ascii or null character was found, \c false
2000 /// otherwise.
2002 for (auto c : getString())
2003 if (!isASCII(c) || !c)
2004 return true;
2005 return false;
2006 }
2007
2008 /// Get the number of string literal tokens that were
2009 /// concatenated in translation phase #6 to form this string literal.
2010 unsigned getNumConcatenated() const {
2011 return StringLiteralBits.NumConcatenated;
2012 }
2013
2014 /// Get one of the string literal token.
2015 SourceLocation getStrTokenLoc(unsigned TokNum) const {
2016 assert(TokNum < getNumConcatenated() && "Invalid tok number");
2017 return getTrailingObjects<SourceLocation>()[TokNum];
2018 }
2019
2020 /// Return a source location that points to the specified
2021 /// byte of this string literal.
2022 ///
2023 /// Strings are amazingly complex. They can be formed from multiple tokens
2024 /// and can have escape sequences in them in addition to the usual trigraph
2025 /// and escaped newline business. This routine handles this complexity.
2027 getLocationOfByte(unsigned ByteNo, const SourceManager &SM,
2028 const LangOptions &Features, const TargetInfo &Target,
2029 unsigned *StartToken = nullptr,
2030 unsigned *StartTokenByteOffset = nullptr) const;
2031
2033
2035 return getTrailingObjects<SourceLocation>();
2036 }
2037
2039 return getTrailingObjects<SourceLocation>() + getNumConcatenated();
2040 }
2041
2042 SourceLocation getBeginLoc() const LLVM_READONLY { return *tokloc_begin(); }
2043 SourceLocation getEndLoc() const LLVM_READONLY { return *(tokloc_end() - 1); }
2044
2045 static bool classof(const Stmt *T) {
2046 return T->getStmtClass() == StringLiteralClass;
2047 }
2048
2049 // Iterators
2056};
2057
2061 LFunction, // Same as Function, but as wide string.
2064 LFuncSig, // Same as FuncSig, but as wide string
2066 /// The same as PrettyFunction, except that the
2067 /// 'virtual' keyword is omitted for virtual member functions.
2069};
2070
2071/// [C99 6.4.2.2] - A predefined identifier such as __func__.
2072class PredefinedExpr final
2073 : public Expr,
2074 private llvm::TrailingObjects<PredefinedExpr, Stmt *> {
2075 friend class ASTStmtReader;
2076 friend TrailingObjects;
2077
2078 // PredefinedExpr is optionally followed by a single trailing
2079 // "Stmt *" for the predefined identifier. It is present if and only if
2080 // hasFunctionName() is true and is always a "StringLiteral *".
2081
2082 PredefinedExpr(SourceLocation L, QualType FNTy, PredefinedIdentKind IK,
2083 bool IsTransparent, StringLiteral *SL);
2084
2085 explicit PredefinedExpr(EmptyShell Empty, bool HasFunctionName);
2086
2087 /// True if this PredefinedExpr has storage for a function name.
2088 bool hasFunctionName() const { return PredefinedExprBits.HasFunctionName; }
2089
2090 void setFunctionName(StringLiteral *SL) {
2091 assert(hasFunctionName() &&
2092 "This PredefinedExpr has no storage for a function name!");
2093 *getTrailingObjects() = SL;
2094 }
2095
2096public:
2097 /// Create a PredefinedExpr.
2098 ///
2099 /// If IsTransparent, the PredefinedExpr is transparently handled as a
2100 /// StringLiteral.
2101 static PredefinedExpr *Create(const ASTContext &Ctx, SourceLocation L,
2102 QualType FNTy, PredefinedIdentKind IK,
2103 bool IsTransparent, StringLiteral *SL);
2104
2105 /// Create an empty PredefinedExpr.
2106 static PredefinedExpr *CreateEmpty(const ASTContext &Ctx,
2107 bool HasFunctionName);
2108
2110 return static_cast<PredefinedIdentKind>(PredefinedExprBits.Kind);
2111 }
2112
2113 bool isTransparent() const { return PredefinedExprBits.IsTransparent; }
2114
2117
2119 return hasFunctionName()
2120 ? static_cast<StringLiteral *>(*getTrailingObjects())
2121 : nullptr;
2122 }
2123
2125 return hasFunctionName()
2126 ? static_cast<StringLiteral *>(*getTrailingObjects())
2127 : nullptr;
2128 }
2129
2130 static StringRef getIdentKindName(PredefinedIdentKind IK);
2131 StringRef getIdentKindName() const {
2133 }
2134
2135 static std::string ComputeName(PredefinedIdentKind IK,
2136 const Decl *CurrentDecl,
2137 bool ForceElaboratedPrinting = false);
2138
2141
2142 static bool classof(const Stmt *T) {
2143 return T->getStmtClass() == PredefinedExprClass;
2144 }
2145
2146 // Iterators
2148 return child_range(getTrailingObjects(hasFunctionName()));
2149 }
2150
2152 return const_child_range(getTrailingObjects(hasFunctionName()));
2153 }
2154};
2155
2156/// This expression type represents an asterisk in an OpenACC Size-Expr, used in
2157/// the 'tile' and 'gang' clauses. It is of 'int' type, but should not be
2158/// evaluated.
2159class OpenACCAsteriskSizeExpr final : public Expr {
2160 friend class ASTStmtReader;
2161 SourceLocation AsteriskLoc;
2162
2163 OpenACCAsteriskSizeExpr(SourceLocation AsteriskLoc, QualType IntTy)
2164 : Expr(OpenACCAsteriskSizeExprClass, IntTy, VK_PRValue, OK_Ordinary),
2165 AsteriskLoc(AsteriskLoc) {}
2166
2167 void setAsteriskLocation(SourceLocation Loc) { AsteriskLoc = Loc; }
2168
2169public:
2170 static OpenACCAsteriskSizeExpr *Create(const ASTContext &C,
2171 SourceLocation Loc);
2172 static OpenACCAsteriskSizeExpr *CreateEmpty(const ASTContext &C);
2173
2174 SourceLocation getBeginLoc() const { return AsteriskLoc; }
2175 SourceLocation getEndLoc() const { return AsteriskLoc; }
2176 SourceLocation getLocation() const { return AsteriskLoc; }
2177
2178 static bool classof(const Stmt *T) {
2179 return T->getStmtClass() == OpenACCAsteriskSizeExprClass;
2180 }
2181 // Iterators
2185
2189};
2190
2191// This represents a use of the __builtin_sycl_unique_stable_name, which takes a
2192// type-id, and at CodeGen time emits a unique string representation of the
2193// type in a way that permits us to properly encode information about the SYCL
2194// kernels.
2195class SYCLUniqueStableNameExpr final : public Expr {
2196 friend class ASTStmtReader;
2197 SourceLocation OpLoc, LParen, RParen;
2198 TypeSourceInfo *TypeInfo;
2199
2200 SYCLUniqueStableNameExpr(EmptyShell Empty, QualType ResultTy);
2201 SYCLUniqueStableNameExpr(SourceLocation OpLoc, SourceLocation LParen,
2202 SourceLocation RParen, QualType ResultTy,
2203 TypeSourceInfo *TSI);
2204
2205 void setTypeSourceInfo(TypeSourceInfo *Ty) { TypeInfo = Ty; }
2206
2207 void setLocation(SourceLocation L) { OpLoc = L; }
2208 void setLParenLocation(SourceLocation L) { LParen = L; }
2209 void setRParenLocation(SourceLocation L) { RParen = L; }
2210
2211public:
2212 TypeSourceInfo *getTypeSourceInfo() { return TypeInfo; }
2213
2214 const TypeSourceInfo *getTypeSourceInfo() const { return TypeInfo; }
2215
2217 Create(const ASTContext &Ctx, SourceLocation OpLoc, SourceLocation LParen,
2218 SourceLocation RParen, TypeSourceInfo *TSI);
2219
2221
2223 SourceLocation getEndLoc() const { return RParen; }
2224 SourceLocation getLocation() const { return OpLoc; }
2225 SourceLocation getLParenLocation() const { return LParen; }
2226 SourceLocation getRParenLocation() const { return RParen; }
2227
2228 static bool classof(const Stmt *T) {
2229 return T->getStmtClass() == SYCLUniqueStableNameExprClass;
2230 }
2231
2232 // Iterators
2236
2240
2241 // Convenience function to generate the name of the currently stored type.
2242 std::string ComputeName(ASTContext &Context) const;
2243
2244 // Get the generated name of the type. Note that this only works after all
2245 // kernels have been instantiated.
2246 static std::string ComputeName(ASTContext &Context, QualType Ty);
2247};
2248
2249/// ParenExpr - This represents a parenthesized expression, e.g. "(1)". This
2250/// AST node is only formed if full location information is requested.
2251class ParenExpr : public Expr {
2252 SourceLocation L, R;
2253 Stmt *Val;
2254
2255public:
2257 : Expr(ParenExprClass, val->getType(), val->getValueKind(),
2258 val->getObjectKind()),
2259 L(l), R(r), Val(val) {
2260 ParenExprBits.ProducedByFoldExpansion = false;
2262 }
2263
2264 /// Construct an empty parenthesized expression.
2266 : Expr(ParenExprClass, Empty) { }
2267
2268 const Expr *getSubExpr() const { return cast<Expr>(Val); }
2269 Expr *getSubExpr() { return cast<Expr>(Val); }
2270 void setSubExpr(Expr *E) { Val = E; }
2271
2272 SourceLocation getBeginLoc() const LLVM_READONLY { return L; }
2273 SourceLocation getEndLoc() const LLVM_READONLY { return R; }
2274
2275 /// Get the location of the left parentheses '('.
2276 SourceLocation getLParen() const { return L; }
2277 void setLParen(SourceLocation Loc) { L = Loc; }
2278
2279 /// Get the location of the right parentheses ')'.
2280 SourceLocation getRParen() const { return R; }
2281 void setRParen(SourceLocation Loc) { R = Loc; }
2282
2283 static bool classof(const Stmt *T) {
2284 return T->getStmtClass() == ParenExprClass;
2285 }
2286
2287 // Iterators
2288 child_range children() { return child_range(&Val, &Val+1); }
2290 return const_child_range(&Val, &Val + 1);
2291 }
2292
2294 return ParenExprBits.ProducedByFoldExpansion != 0;
2295 }
2296 void setIsProducedByFoldExpansion(bool ProducedByFoldExpansion = true) {
2297 ParenExprBits.ProducedByFoldExpansion = ProducedByFoldExpansion;
2298 }
2299};
2300
2301/// UnaryOperator - This represents the unary-expression's (except sizeof and
2302/// alignof), the postinc/postdec operators from postfix-expression, and various
2303/// extensions.
2304///
2305/// Notes on various nodes:
2306///
2307/// Real/Imag - These return the real/imag part of a complex operand. If
2308/// applied to a non-complex value, the former returns its operand and the
2309/// later returns zero in the type of the operand.
2310///
2311class UnaryOperator final
2312 : public Expr,
2313 private llvm::TrailingObjects<UnaryOperator, FPOptionsOverride> {
2314 Stmt *Val;
2315
2316 FPOptionsOverride &getTrailingFPFeatures() {
2317 assert(UnaryOperatorBits.HasFPFeatures);
2318 return *getTrailingObjects();
2319 }
2320
2321 const FPOptionsOverride &getTrailingFPFeatures() const {
2322 assert(UnaryOperatorBits.HasFPFeatures);
2323 return *getTrailingObjects();
2324 }
2325
2326public:
2328
2329protected:
2330 UnaryOperator(const ASTContext &Ctx, Expr *input, Opcode opc, QualType type,
2332 bool CanOverflow, FPOptionsOverride FPFeatures);
2333
2334 /// Build an empty unary operator.
2335 explicit UnaryOperator(bool HasFPFeatures, EmptyShell Empty)
2336 : Expr(UnaryOperatorClass, Empty) {
2337 UnaryOperatorBits.Opc = UO_AddrOf;
2338 UnaryOperatorBits.HasFPFeatures = HasFPFeatures;
2339 }
2340
2341public:
2342 static UnaryOperator *CreateEmpty(const ASTContext &C, bool hasFPFeatures);
2343
2344 static UnaryOperator *Create(const ASTContext &C, Expr *input, Opcode opc,
2347 bool CanOverflow, FPOptionsOverride FPFeatures);
2348
2350 return static_cast<Opcode>(UnaryOperatorBits.Opc);
2351 }
2352 void setOpcode(Opcode Opc) { UnaryOperatorBits.Opc = Opc; }
2353
2354 Expr *getSubExpr() const { return cast<Expr>(Val); }
2355 void setSubExpr(Expr *E) { Val = E; }
2356
2357 /// getOperatorLoc - Return the location of the operator.
2360
2361 /// Returns true if the unary operator can cause an overflow. For instance,
2362 /// signed int i = INT_MAX; i++;
2363 /// signed char c = CHAR_MAX; c++;
2364 /// Due to integer promotions, c++ is promoted to an int before the postfix
2365 /// increment, and the result is an int that cannot overflow. However, i++
2366 /// can overflow.
2367 bool canOverflow() const { return UnaryOperatorBits.CanOverflow; }
2368 void setCanOverflow(bool C) { UnaryOperatorBits.CanOverflow = C; }
2369
2370 /// Get the FP contractibility status of this operator. Only meaningful for
2371 /// operations on floating point types.
2375
2376 /// Get the FENV_ACCESS status of this operator. Only meaningful for
2377 /// operations on floating point types.
2378 bool isFEnvAccessOn(const LangOptions &LO) const {
2379 return getFPFeaturesInEffect(LO).getAllowFEnvAccess();
2380 }
2381
2382 /// isPostfix - Return true if this is a postfix operation, like x++.
2383 static bool isPostfix(Opcode Op) {
2384 return Op == UO_PostInc || Op == UO_PostDec;
2385 }
2386
2387 /// isPrefix - Return true if this is a prefix operation, like --x.
2388 static bool isPrefix(Opcode Op) {
2389 return Op == UO_PreInc || Op == UO_PreDec;
2390 }
2391
2392 bool isPrefix() const { return isPrefix(getOpcode()); }
2393 bool isPostfix() const { return isPostfix(getOpcode()); }
2394
2395 static bool isIncrementOp(Opcode Op) {
2396 return Op == UO_PreInc || Op == UO_PostInc;
2397 }
2398 bool isIncrementOp() const {
2399 return isIncrementOp(getOpcode());
2400 }
2401
2402 static bool isDecrementOp(Opcode Op) {
2403 return Op == UO_PreDec || Op == UO_PostDec;
2404 }
2405 bool isDecrementOp() const {
2406 return isDecrementOp(getOpcode());
2407 }
2408
2409 static bool isIncrementDecrementOp(Opcode Op) { return Op <= UO_PreDec; }
2412 }
2413
2414 static bool isArithmeticOp(Opcode Op) {
2415 return Op >= UO_Plus && Op <= UO_LNot;
2416 }
2417 bool isArithmeticOp() const { return isArithmeticOp(getOpcode()); }
2418
2419 /// getOpcodeStr - Turn an Opcode enum value into the punctuation char it
2420 /// corresponds to, e.g. "sizeof" or "[pre]++"
2421 static StringRef getOpcodeStr(Opcode Op);
2422
2423 /// Retrieve the unary opcode that corresponds to the given
2424 /// overloaded operator.
2425 static Opcode getOverloadedOpcode(OverloadedOperatorKind OO, bool Postfix);
2426
2427 /// Retrieve the overloaded operator kind that corresponds to
2428 /// the given unary opcode.
2430
2431 SourceLocation getBeginLoc() const LLVM_READONLY {
2432 return isPostfix() ? Val->getBeginLoc() : getOperatorLoc();
2433 }
2434 SourceLocation getEndLoc() const LLVM_READONLY {
2435 return isPostfix() ? getOperatorLoc() : Val->getEndLoc();
2436 }
2438
2439 static bool classof(const Stmt *T) {
2440 return T->getStmtClass() == UnaryOperatorClass;
2441 }
2442
2443 // Iterators
2444 child_range children() { return child_range(&Val, &Val+1); }
2446 return const_child_range(&Val, &Val + 1);
2447 }
2448
2449 /// Is FPFeatures in Trailing Storage?
2450 bool hasStoredFPFeatures() const { return UnaryOperatorBits.HasFPFeatures; }
2451
2452 /// Get FPFeatures from trailing storage.
2454 return getTrailingFPFeatures();
2455 }
2456
2457 /// Get the store FPOptionsOverride or default if not stored.
2461
2462protected:
2463 /// Set FPFeatures in trailing storage, used by Serialization & ASTImporter.
2464 void setStoredFPFeatures(FPOptionsOverride F) { getTrailingFPFeatures() = F; }
2465
2466public:
2467 /// Get the FP features status of this operator. Only meaningful for
2468 /// operations on floating point types.
2470 if (UnaryOperatorBits.HasFPFeatures)
2473 }
2475 if (UnaryOperatorBits.HasFPFeatures)
2476 return getStoredFPFeatures();
2477 return FPOptionsOverride();
2478 }
2479
2481 friend class ASTNodeImporter;
2482 friend class ASTReader;
2483 friend class ASTStmtReader;
2484 friend class ASTStmtWriter;
2485};
2486
2487/// Helper class for OffsetOfExpr.
2488
2489// __builtin_offsetof(type, identifier(.identifier|[expr])*)
2491public:
2492 /// The kind of offsetof node we have.
2493 enum Kind {
2494 /// An index into an array.
2495 Array = 0x00,
2496 /// A field.
2497 Field = 0x01,
2498 /// A field in a dependent type, known only by its name.
2500 /// An implicit indirection through a C++ base class, when the
2501 /// field found is in a base class.
2502 Base = 0x03
2503 };
2504
2505private:
2506 enum { MaskBits = 2, Mask = 0x03 };
2507
2508 /// The source range that covers this part of the designator.
2509 SourceRange Range;
2510
2511 /// The data describing the designator, which comes in three
2512 /// different forms, depending on the lower two bits.
2513 /// - An unsigned index into the array of Expr*'s stored after this node
2514 /// in memory, for [constant-expression] designators.
2515 /// - A FieldDecl*, for references to a known field.
2516 /// - An IdentifierInfo*, for references to a field with a given name
2517 /// when the class type is dependent.
2518 /// - A CXXBaseSpecifier*, for references that look at a field in a
2519 /// base class.
2521
2522public:
2523 /// Create an offsetof node that refers to an array element.
2524 OffsetOfNode(SourceLocation LBracketLoc, unsigned Index,
2525 SourceLocation RBracketLoc)
2526 : Range(LBracketLoc, RBracketLoc), Data((Index << 2) | Array) {}
2527
2528 /// Create an offsetof node that refers to a field.
2530 : Range(DotLoc.isValid() ? DotLoc : NameLoc, NameLoc),
2531 Data(reinterpret_cast<uintptr_t>(Field) | OffsetOfNode::Field) {}
2532
2533 /// Create an offsetof node that refers to an identifier.
2535 SourceLocation NameLoc)
2536 : Range(DotLoc.isValid() ? DotLoc : NameLoc, NameLoc),
2537 Data(reinterpret_cast<uintptr_t>(Name) | Identifier) {}
2538
2539 /// Create an offsetof node that refers into a C++ base class.
2541 : Data(reinterpret_cast<uintptr_t>(Base) | OffsetOfNode::Base) {}
2542
2543 /// Determine what kind of offsetof node this is.
2544 Kind getKind() const { return static_cast<Kind>(Data & Mask); }
2545
2546 /// For an array element node, returns the index into the array
2547 /// of expressions.
2548 unsigned getArrayExprIndex() const {
2549 assert(getKind() == Array);
2550 return Data >> 2;
2551 }
2552
2553 /// For a field offsetof node, returns the field.
2555 assert(getKind() == Field);
2556 return reinterpret_cast<FieldDecl *>(Data & ~(uintptr_t)Mask);
2557 }
2558
2559 /// For a field or identifier offsetof node, returns the name of
2560 /// the field.
2561 const IdentifierInfo *getFieldName() const;
2562
2563 /// For a base class node, returns the base specifier.
2565 assert(getKind() == Base);
2566 return reinterpret_cast<CXXBaseSpecifier *>(Data & ~(uintptr_t)Mask);
2567 }
2568
2569 /// Retrieve the source range that covers this offsetof node.
2570 ///
2571 /// For an array element node, the source range contains the locations of
2572 /// the square brackets. For a field or identifier node, the source range
2573 /// contains the location of the period (if there is one) and the
2574 /// identifier.
2575 SourceRange getSourceRange() const LLVM_READONLY { return Range; }
2576 SourceLocation getBeginLoc() const LLVM_READONLY { return Range.getBegin(); }
2577 SourceLocation getEndLoc() const LLVM_READONLY { return Range.getEnd(); }
2578};
2579
2580/// OffsetOfExpr - [C99 7.17] - This represents an expression of the form
2581/// offsetof(record-type, member-designator). For example, given:
2582/// @code
2583/// struct S {
2584/// float f;
2585/// double d;
2586/// };
2587/// struct T {
2588/// int i;
2589/// struct S s[10];
2590/// };
2591/// @endcode
2592/// we can represent and evaluate the expression @c offsetof(struct T, s[2].d).
2593
2594class OffsetOfExpr final
2595 : public Expr,
2596 private llvm::TrailingObjects<OffsetOfExpr, OffsetOfNode, Expr *> {
2597 SourceLocation OperatorLoc, RParenLoc;
2598 // Base type;
2599 TypeSourceInfo *TSInfo;
2600 // Number of sub-components (i.e. instances of OffsetOfNode).
2601 unsigned NumComps;
2602 // Number of sub-expressions (i.e. array subscript expressions).
2603 unsigned NumExprs;
2604
2605 size_t numTrailingObjects(OverloadToken<OffsetOfNode>) const {
2606 return NumComps;
2607 }
2608
2609 OffsetOfExpr(const ASTContext &C, QualType type,
2610 SourceLocation OperatorLoc, TypeSourceInfo *tsi,
2612 SourceLocation RParenLoc);
2613
2614 explicit OffsetOfExpr(unsigned numComps, unsigned numExprs)
2615 : Expr(OffsetOfExprClass, EmptyShell()),
2616 TSInfo(nullptr), NumComps(numComps), NumExprs(numExprs) {}
2617
2618public:
2619
2620 static OffsetOfExpr *Create(const ASTContext &C, QualType type,
2621 SourceLocation OperatorLoc, TypeSourceInfo *tsi,
2623 ArrayRef<Expr*> exprs, SourceLocation RParenLoc);
2624
2625 static OffsetOfExpr *CreateEmpty(const ASTContext &C,
2626 unsigned NumComps, unsigned NumExprs);
2627
2628 /// getOperatorLoc - Return the location of the operator.
2629 SourceLocation getOperatorLoc() const { return OperatorLoc; }
2630 void setOperatorLoc(SourceLocation L) { OperatorLoc = L; }
2631
2632 /// Return the location of the right parentheses.
2633 SourceLocation getRParenLoc() const { return RParenLoc; }
2634 void setRParenLoc(SourceLocation R) { RParenLoc = R; }
2635
2637 return TSInfo;
2638 }
2640 TSInfo = tsi;
2641 }
2642
2643 const OffsetOfNode &getComponent(unsigned Idx) const {
2644 return getTrailingObjects<OffsetOfNode>(NumComps)[Idx];
2645 }
2646
2647 void setComponent(unsigned Idx, OffsetOfNode ON) {
2648 getTrailingObjects<OffsetOfNode>(NumComps)[Idx] = ON;
2649 }
2650
2651 unsigned getNumComponents() const {
2652 return NumComps;
2653 }
2654
2655 Expr* getIndexExpr(unsigned Idx) {
2656 return getTrailingObjects<Expr *>(NumExprs)[Idx];
2657 }
2658
2659 const Expr *getIndexExpr(unsigned Idx) const {
2660 return getTrailingObjects<Expr *>(NumExprs)[Idx];
2661 }
2662
2663 void setIndexExpr(unsigned Idx, Expr* E) {
2664 getTrailingObjects<Expr *>(NumComps)[Idx] = E;
2665 }
2666
2667 unsigned getNumExpressions() const {
2668 return NumExprs;
2669 }
2670
2671 SourceLocation getBeginLoc() const LLVM_READONLY { return OperatorLoc; }
2672 SourceLocation getEndLoc() const LLVM_READONLY { return RParenLoc; }
2673
2674 static bool classof(const Stmt *T) {
2675 return T->getStmtClass() == OffsetOfExprClass;
2676 }
2677
2678 // Iterators
2680 Stmt **begin = reinterpret_cast<Stmt **>(getTrailingObjects<Expr *>());
2681 return child_range(begin, begin + NumExprs);
2682 }
2684 Stmt *const *begin =
2685 reinterpret_cast<Stmt *const *>(getTrailingObjects<Expr *>());
2686 return const_child_range(begin, begin + NumExprs);
2687 }
2689};
2690
2691/// UnaryExprOrTypeTraitExpr - expression with either a type or (unevaluated)
2692/// expression operand. Used for sizeof/alignof (C99 6.5.3.4) and
2693/// vec_step (OpenCL 1.1 6.11.12).
2695 union {
2698 } Argument;
2699 SourceLocation OpLoc, RParenLoc;
2700
2701public:
2702 UnaryExprOrTypeTraitExpr(UnaryExprOrTypeTrait ExprKind, TypeSourceInfo *TInfo,
2703 QualType resultType, SourceLocation op,
2704 SourceLocation rp)
2705 : Expr(UnaryExprOrTypeTraitExprClass, resultType, VK_PRValue,
2706 OK_Ordinary),
2707 OpLoc(op), RParenLoc(rp) {
2708 assert(ExprKind <= UETT_Last && "invalid enum value!");
2709 UnaryExprOrTypeTraitExprBits.Kind = ExprKind;
2710 assert(static_cast<unsigned>(ExprKind) ==
2712 "UnaryExprOrTypeTraitExprBits.Kind overflow!");
2713 UnaryExprOrTypeTraitExprBits.IsType = true;
2714 Argument.Ty = TInfo;
2716 }
2717
2718 UnaryExprOrTypeTraitExpr(UnaryExprOrTypeTrait ExprKind, Expr *E,
2719 QualType resultType, SourceLocation op,
2720 SourceLocation rp);
2721
2722 /// Construct an empty sizeof/alignof expression.
2724 : Expr(UnaryExprOrTypeTraitExprClass, Empty) { }
2725
2726 UnaryExprOrTypeTrait getKind() const {
2727 return static_cast<UnaryExprOrTypeTrait>(UnaryExprOrTypeTraitExprBits.Kind);
2728 }
2729 void setKind(UnaryExprOrTypeTrait K) {
2730 assert(K <= UETT_Last && "invalid enum value!");
2732 assert(static_cast<unsigned>(K) == UnaryExprOrTypeTraitExprBits.Kind &&
2733 "UnaryExprOrTypeTraitExprBits.Kind overflow!");
2734 }
2735
2736 bool isArgumentType() const { return UnaryExprOrTypeTraitExprBits.IsType; }
2738 return getArgumentTypeInfo()->getType();
2739 }
2741 assert(isArgumentType() && "calling getArgumentType() when arg is expr");
2742 return Argument.Ty;
2743 }
2745 assert(!isArgumentType() && "calling getArgumentExpr() when arg is type");
2746 return static_cast<Expr*>(Argument.Ex);
2747 }
2748 const Expr *getArgumentExpr() const {
2749 return const_cast<UnaryExprOrTypeTraitExpr*>(this)->getArgumentExpr();
2750 }
2751
2753 Argument.Ex = E;
2754 UnaryExprOrTypeTraitExprBits.IsType = false;
2755 }
2757 Argument.Ty = TInfo;
2758 UnaryExprOrTypeTraitExprBits.IsType = true;
2759 }
2760
2761 /// Gets the argument type, or the type of the argument expression, whichever
2762 /// is appropriate.
2766
2767 SourceLocation getOperatorLoc() const { return OpLoc; }
2768 void setOperatorLoc(SourceLocation L) { OpLoc = L; }
2769
2770 SourceLocation getRParenLoc() const { return RParenLoc; }
2771 void setRParenLoc(SourceLocation L) { RParenLoc = L; }
2772
2773 SourceLocation getBeginLoc() const LLVM_READONLY { return OpLoc; }
2774 SourceLocation getEndLoc() const LLVM_READONLY { return RParenLoc; }
2775
2776 static bool classof(const Stmt *T) {
2777 return T->getStmtClass() == UnaryExprOrTypeTraitExprClass;
2778 }
2779
2780 // Iterators
2783};
2784
2785//===----------------------------------------------------------------------===//
2786// Postfix Operators.
2787//===----------------------------------------------------------------------===//
2788
2789/// ArraySubscriptExpr - [C99 6.5.2.1] Array Subscripting.
2790class ArraySubscriptExpr : public Expr {
2791 enum { LHS, RHS, END_EXPR };
2792 Stmt *SubExprs[END_EXPR];
2793
2794 bool lhsIsBase() const { return getRHS()->getType()->isIntegerType(); }
2795
2796public:
2798 ExprObjectKind OK, SourceLocation rbracketloc)
2799 : Expr(ArraySubscriptExprClass, t, VK, OK) {
2800 SubExprs[LHS] = lhs;
2801 SubExprs[RHS] = rhs;
2802 ArrayOrMatrixSubscriptExprBits.RBracketLoc = rbracketloc;
2804 }
2805
2806 /// Create an empty array subscript expression.
2808 : Expr(ArraySubscriptExprClass, Shell) { }
2809
2810 /// An array access can be written A[4] or 4[A] (both are equivalent).
2811 /// - getBase() and getIdx() always present the normalized view: A[4].
2812 /// In this case getBase() returns "A" and getIdx() returns "4".
2813 /// - getLHS() and getRHS() present the syntactic view. e.g. for
2814 /// 4[A] getLHS() returns "4".
2815 /// Note: Because vector element access is also written A[4] we must
2816 /// predicate the format conversion in getBase and getIdx only on the
2817 /// the type of the RHS, as it is possible for the LHS to be a vector of
2818 /// integer type
2819 Expr *getLHS() { return cast<Expr>(SubExprs[LHS]); }
2820 const Expr *getLHS() const { return cast<Expr>(SubExprs[LHS]); }
2821 void setLHS(Expr *E) { SubExprs[LHS] = E; }
2822
2823 Expr *getRHS() { return cast<Expr>(SubExprs[RHS]); }
2824 const Expr *getRHS() const { return cast<Expr>(SubExprs[RHS]); }
2825 void setRHS(Expr *E) { SubExprs[RHS] = E; }
2826
2827 Expr *getBase() { return lhsIsBase() ? getLHS() : getRHS(); }
2828 const Expr *getBase() const { return lhsIsBase() ? getLHS() : getRHS(); }
2829
2830 Expr *getIdx() { return lhsIsBase() ? getRHS() : getLHS(); }
2831 const Expr *getIdx() const { return lhsIsBase() ? getRHS() : getLHS(); }
2832
2833 SourceLocation getBeginLoc() const LLVM_READONLY {
2834 return getLHS()->getBeginLoc();
2835 }
2837
2839 return ArrayOrMatrixSubscriptExprBits.RBracketLoc;
2840 }
2842 ArrayOrMatrixSubscriptExprBits.RBracketLoc = L;
2843 }
2844
2845 SourceLocation getExprLoc() const LLVM_READONLY {
2846 return getBase()->getExprLoc();
2847 }
2848
2849 static bool classof(const Stmt *T) {
2850 return T->getStmtClass() == ArraySubscriptExprClass;
2851 }
2852
2853 // Iterators
2855 return child_range(&SubExprs[0], &SubExprs[0]+END_EXPR);
2856 }
2858 return const_child_range(&SubExprs[0], &SubExprs[0] + END_EXPR);
2859 }
2860};
2861
2862/// MatrixSingleSubscriptExpr - Matrix single subscript expression for the
2863/// MatrixType extension when you want to get\set a vector from a Matrix.
2865 enum { BASE, ROW_IDX, END_EXPR };
2866 Stmt *SubExprs[END_EXPR];
2867
2868public:
2869 /// matrix[row]
2870 ///
2871 /// \param Base The matrix expression.
2872 /// \param RowIdx The row index expression.
2873 /// \param T The type of the row (usually a vector type).
2874 /// \param RBracketLoc Location of the closing ']'.
2876 SourceLocation RBracketLoc)
2877 : Expr(MatrixSingleSubscriptExprClass, T,
2878 Base->getValueKind(), // lvalue/rvalue follows the matrix base
2880 SubExprs[BASE] = Base;
2881 SubExprs[ROW_IDX] = RowIdx;
2882 ArrayOrMatrixSubscriptExprBits.RBracketLoc = RBracketLoc;
2884 }
2885
2886 /// Create an empty matrix single-subscript expression.
2888 : Expr(MatrixSingleSubscriptExprClass, Shell) {}
2889
2890 Expr *getBase() { return cast<Expr>(SubExprs[BASE]); }
2891 const Expr *getBase() const { return cast<Expr>(SubExprs[BASE]); }
2892 void setBase(Expr *E) { SubExprs[BASE] = E; }
2893
2894 Expr *getRowIdx() { return cast<Expr>(SubExprs[ROW_IDX]); }
2895 const Expr *getRowIdx() const { return cast<Expr>(SubExprs[ROW_IDX]); }
2896 void setRowIdx(Expr *E) { SubExprs[ROW_IDX] = E; }
2897
2898 SourceLocation getBeginLoc() const LLVM_READONLY {
2899 return getBase()->getBeginLoc();
2900 }
2901
2903
2904 SourceLocation getExprLoc() const LLVM_READONLY {
2905 return getBase()->getExprLoc();
2906 }
2907
2909 return ArrayOrMatrixSubscriptExprBits.RBracketLoc;
2910 }
2912 ArrayOrMatrixSubscriptExprBits.RBracketLoc = L;
2913 }
2914
2915 static bool classof(const Stmt *T) {
2916 return T->getStmtClass() == MatrixSingleSubscriptExprClass;
2917 }
2918
2919 // Iterators
2921 return child_range(&SubExprs[0], &SubExprs[0] + END_EXPR);
2922 }
2924 return const_child_range(&SubExprs[0], &SubExprs[0] + END_EXPR);
2925 }
2926};
2927
2928/// MatrixSubscriptExpr - Matrix subscript expression for the MatrixType
2929/// extension.
2930/// MatrixSubscriptExpr can be either incomplete (only Base and RowIdx are set
2931/// so far, the type is IncompleteMatrixIdx) or complete (Base, RowIdx and
2932/// ColumnIdx refer to valid expressions). Incomplete matrix expressions only
2933/// exist during the initial construction of the AST.
2935 enum { BASE, ROW_IDX, COLUMN_IDX, END_EXPR };
2936 Stmt *SubExprs[END_EXPR];
2937
2938public:
2940 SourceLocation RBracketLoc)
2941 : Expr(MatrixSubscriptExprClass, T, Base->getValueKind(),
2943 SubExprs[BASE] = Base;
2944 SubExprs[ROW_IDX] = RowIdx;
2945 SubExprs[COLUMN_IDX] = ColumnIdx;
2946 ArrayOrMatrixSubscriptExprBits.RBracketLoc = RBracketLoc;
2948 }
2949
2950 /// Create an empty matrix subscript expression.
2952 : Expr(MatrixSubscriptExprClass, Shell) {}
2953
2954 bool isIncomplete() const {
2955 bool IsIncomplete = hasPlaceholderType(BuiltinType::IncompleteMatrixIdx);
2956 assert((SubExprs[COLUMN_IDX] || IsIncomplete) &&
2957 "expressions without column index must be marked as incomplete");
2958 return IsIncomplete;
2959 }
2960 Expr *getBase() { return cast<Expr>(SubExprs[BASE]); }
2961 const Expr *getBase() const { return cast<Expr>(SubExprs[BASE]); }
2962 void setBase(Expr *E) { SubExprs[BASE] = E; }
2963
2964 Expr *getRowIdx() { return cast<Expr>(SubExprs[ROW_IDX]); }
2965 const Expr *getRowIdx() const { return cast<Expr>(SubExprs[ROW_IDX]); }
2966 void setRowIdx(Expr *E) { SubExprs[ROW_IDX] = E; }
2967
2968 Expr *getColumnIdx() { return cast_or_null<Expr>(SubExprs[COLUMN_IDX]); }
2969 const Expr *getColumnIdx() const {
2970 assert(!isIncomplete() &&
2971 "cannot get the column index of an incomplete expression");
2972 return cast<Expr>(SubExprs[COLUMN_IDX]);
2973 }
2974 void setColumnIdx(Expr *E) { SubExprs[COLUMN_IDX] = E; }
2975
2976 SourceLocation getBeginLoc() const LLVM_READONLY {
2977 return getBase()->getBeginLoc();
2978 }
2979
2981
2982 SourceLocation getExprLoc() const LLVM_READONLY {
2983 return getBase()->getExprLoc();
2984 }
2985
2987 return ArrayOrMatrixSubscriptExprBits.RBracketLoc;
2988 }
2990 ArrayOrMatrixSubscriptExprBits.RBracketLoc = L;
2991 }
2992
2993 static bool classof(const Stmt *T) {
2994 return T->getStmtClass() == MatrixSubscriptExprClass;
2995 }
2996
2997 // Iterators
2999 return child_range(&SubExprs[0], &SubExprs[0] + END_EXPR);
3000 }
3002 return const_child_range(&SubExprs[0], &SubExprs[0] + END_EXPR);
3003 }
3004};
3005
3006/// CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
3007/// CallExpr itself represents a normal function call, e.g., "f(x, 2)",
3008/// while its subclasses may represent alternative syntax that (semantically)
3009/// results in a function call. For example, CXXOperatorCallExpr is
3010/// a subclass for overloaded operator calls that use operator syntax, e.g.,
3011/// "str1 + str2" to resolve to a function call.
3012class CallExpr : public Expr {
3013 enum { FN = 0, PREARGS_START = 1 };
3014
3015 /// The number of arguments in the call expression.
3016 unsigned NumArgs;
3017
3018 /// The location of the right parentheses. This has a different meaning for
3019 /// the derived classes of CallExpr.
3020 SourceLocation RParenLoc;
3021
3022 // CallExpr store some data in trailing objects. However since CallExpr
3023 // is used a base of other expression classes we cannot use
3024 // llvm::TrailingObjects. Instead we manually perform the pointer arithmetic
3025 // and casts.
3026 //
3027 // The trailing objects are in order:
3028 //
3029 // * A single "Stmt *" for the callee expression.
3030 //
3031 // * An array of getNumPreArgs() "Stmt *" for the pre-argument expressions.
3032 //
3033 // * An array of getNumArgs() "Stmt *" for the argument expressions.
3034 //
3035 // * An optional of type FPOptionsOverride.
3036 //
3037 // CallExpr subclasses are asssumed to be 32 bytes or less, and CallExpr
3038 // itself is 24 bytes. To avoid having to recompute or store the offset of the
3039 // trailing objects, we put it at 32 bytes (such that it is suitable for all
3040 // subclasses) We use the 8 bytes gap left for instances of CallExpr to store
3041 // the begin source location, which has a significant impact on perf as
3042 // getBeginLoc is assumed to be cheap.
3043 // The layourt is as follow:
3044 // CallExpr | Begin | 4 bytes left | Trailing Objects
3045 // CXXMemberCallExpr | Trailing Objects
3046 // A bit in CallExprBitfields indicates if source locations are present.
3047
3048protected:
3049 static constexpr unsigned OffsetToTrailingObjects = 32;
3050 template <typename T>
3051 static constexpr unsigned
3052 sizeToAllocateForCallExprSubclass(unsigned SizeOfTrailingObjects) {
3053 static_assert(sizeof(T) <= CallExpr::OffsetToTrailingObjects);
3054 return SizeOfTrailingObjects + CallExpr::OffsetToTrailingObjects;
3055 }
3056
3057private:
3058 /// Return a pointer to the start of the trailing array of "Stmt *".
3059 Stmt **getTrailingStmts() {
3060 return reinterpret_cast<Stmt **>(reinterpret_cast<char *>(this) +
3062 }
3063 Stmt *const *getTrailingStmts() const {
3064 return const_cast<CallExpr *>(this)->getTrailingStmts();
3065 }
3066
3067 unsigned getSizeOfTrailingStmts() const {
3068 return (1 + getNumPreArgs() + getNumArgs()) * sizeof(Stmt *);
3069 }
3070
3071 size_t getOffsetOfTrailingFPFeatures() const {
3072 assert(hasStoredFPFeatures());
3073 return OffsetToTrailingObjects + getSizeOfTrailingStmts();
3074 }
3075
3076public:
3077 enum class ADLCallKind : bool { NotADL, UsesADL };
3080
3081protected:
3082 /// Build a call expression, assuming that appropriate storage has been
3083 /// allocated for the trailing objects.
3084 CallExpr(StmtClass SC, Expr *Fn, ArrayRef<Expr *> PreArgs,
3086 SourceLocation RParenLoc, FPOptionsOverride FPFeatures,
3087 unsigned MinNumArgs, ADLCallKind UsesADL);
3088
3089 /// Build an empty call expression, for deserialization.
3090 CallExpr(StmtClass SC, unsigned NumPreArgs, unsigned NumArgs,
3091 bool hasFPFeatures, EmptyShell Empty);
3092
3093 /// Return the size in bytes needed for the trailing objects.
3094 /// Used by the derived classes to allocate the right amount of storage.
3095 static unsigned sizeOfTrailingObjects(unsigned NumPreArgs, unsigned NumArgs,
3096 bool HasFPFeatures) {
3097 return (1 + NumPreArgs + NumArgs) * sizeof(Stmt *) +
3098 HasFPFeatures * sizeof(FPOptionsOverride);
3099 }
3100
3101 Stmt *getPreArg(unsigned I) {
3102 assert(I < getNumPreArgs() && "Prearg access out of range!");
3103 return getTrailingStmts()[PREARGS_START + I];
3104 }
3105 const Stmt *getPreArg(unsigned I) const {
3106 assert(I < getNumPreArgs() && "Prearg access out of range!");
3107 return getTrailingStmts()[PREARGS_START + I];
3108 }
3109 void setPreArg(unsigned I, Stmt *PreArg) {
3110 assert(I < getNumPreArgs() && "Prearg access out of range!");
3111 getTrailingStmts()[PREARGS_START + I] = PreArg;
3112 }
3113
3114 unsigned getNumPreArgs() const { return CallExprBits.NumPreArgs; }
3115
3116 /// Return a pointer to the trailing FPOptions
3118 assert(hasStoredFPFeatures());
3119 return reinterpret_cast<FPOptionsOverride *>(
3120 reinterpret_cast<char *>(this) + OffsetToTrailingObjects +
3121 getSizeOfTrailingStmts());
3122 }
3124 assert(hasStoredFPFeatures());
3125 return reinterpret_cast<const FPOptionsOverride *>(
3126 reinterpret_cast<const char *>(this) + OffsetToTrailingObjects +
3127 getSizeOfTrailingStmts());
3128 }
3129
3130public:
3131 /// Create a call expression.
3132 /// \param Fn The callee expression,
3133 /// \param Args The argument array,
3134 /// \param Ty The type of the call expression (which is *not* the return
3135 /// type in general),
3136 /// \param VK The value kind of the call expression (lvalue, rvalue, ...),
3137 /// \param RParenLoc The location of the right parenthesis in the call
3138 /// expression.
3139 /// \param FPFeatures Floating-point features associated with the call,
3140 /// \param MinNumArgs Specifies the minimum number of arguments. The actual
3141 /// number of arguments will be the greater of Args.size()
3142 /// and MinNumArgs. This is used in a few places to allocate
3143 /// enough storage for the default arguments.
3144 /// \param UsesADL Specifies whether the callee was found through
3145 /// argument-dependent lookup.
3146 ///
3147 /// Note that you can use CreateTemporary if you need a temporary call
3148 /// expression on the stack.
3149 static CallExpr *Create(const ASTContext &Ctx, Expr *Fn,
3151 SourceLocation RParenLoc,
3152 FPOptionsOverride FPFeatures, unsigned MinNumArgs = 0,
3153 ADLCallKind UsesADL = NotADL);
3154
3155 /// Create an empty call expression, for deserialization.
3156 static CallExpr *CreateEmpty(const ASTContext &Ctx, unsigned NumArgs,
3157 bool HasFPFeatures, EmptyShell Empty);
3158
3159 Expr *getCallee() { return cast<Expr>(getTrailingStmts()[FN]); }
3160 const Expr *getCallee() const { return cast<Expr>(getTrailingStmts()[FN]); }
3161 void setCallee(Expr *F) { getTrailingStmts()[FN] = F; }
3162
3164 return static_cast<ADLCallKind>(CallExprBits.UsesADL);
3165 }
3167 CallExprBits.UsesADL = static_cast<bool>(V);
3168 }
3169 bool usesADL() const { return getADLCallKind() == UsesADL; }
3170
3171 bool hasStoredFPFeatures() const { return CallExprBits.HasFPFeatures; }
3172
3173 bool usesMemberSyntax() const {
3174 return CallExprBits.ExplicitObjectMemFunUsingMemberSyntax;
3175 }
3176 void setUsesMemberSyntax(bool V = true) {
3177 CallExprBits.ExplicitObjectMemFunUsingMemberSyntax = V;
3178 // Because the source location may be different for explicit
3179 // member, we reset the cached values.
3180 if (CallExprBits.HasTrailingSourceLoc) {
3181 CallExprBits.HasTrailingSourceLoc = false;
3182 updateTrailingSourceLoc();
3183 }
3184 }
3185
3186 bool isCoroElideSafe() const { return CallExprBits.IsCoroElideSafe; }
3187 void setCoroElideSafe(bool V = true) { CallExprBits.IsCoroElideSafe = V; }
3188
3190 const Decl *getCalleeDecl() const {
3192 }
3193
3194 /// If the callee is a FunctionDecl, return it. Otherwise return null.
3196 return dyn_cast_or_null<FunctionDecl>(getCalleeDecl());
3197 }
3199 return dyn_cast_or_null<FunctionDecl>(getCalleeDecl());
3200 }
3201
3202 /// getNumArgs - Return the number of actual arguments to this call.
3203 unsigned getNumArgs() const { return NumArgs; }
3204
3205 /// Retrieve the call arguments.
3207 return reinterpret_cast<Expr **>(getTrailingStmts() + PREARGS_START +
3208 getNumPreArgs());
3209 }
3210 const Expr *const *getArgs() const {
3211 return reinterpret_cast<const Expr *const *>(
3212 getTrailingStmts() + PREARGS_START + getNumPreArgs());
3213 }
3214
3215 /// getArg - Return the specified argument.
3216 Expr *getArg(unsigned Arg) {
3217 assert(Arg < getNumArgs() && "Arg access out of range!");
3218 return getArgs()[Arg];
3219 }
3220 const Expr *getArg(unsigned Arg) const {
3221 assert(Arg < getNumArgs() && "Arg access out of range!");
3222 return getArgs()[Arg];
3223 }
3224
3225 /// setArg - Set the specified argument.
3226 /// ! the dependence bits might be stale after calling this setter, it is
3227 /// *caller*'s responsibility to recompute them by calling
3228 /// computeDependence().
3229 void setArg(unsigned Arg, Expr *ArgExpr) {
3230 assert(Arg < getNumArgs() && "Arg access out of range!");
3231 getArgs()[Arg] = ArgExpr;
3232 }
3233
3234 /// Compute and set dependence bits.
3237 this,
3238 ArrayRef(reinterpret_cast<Expr **>(getTrailingStmts() + PREARGS_START),
3239 getNumPreArgs())));
3240 }
3241
3242 /// Reduce the number of arguments in this call expression. This is used for
3243 /// example during error recovery to drop extra arguments. There is no way
3244 /// to perform the opposite because: 1.) We don't track how much storage
3245 /// we have for the argument array 2.) This would potentially require growing
3246 /// the argument array, something we cannot support since the arguments are
3247 /// stored in a trailing array.
3248 void shrinkNumArgs(unsigned NewNumArgs) {
3249 assert((NewNumArgs <= getNumArgs()) &&
3250 "shrinkNumArgs cannot increase the number of arguments!");
3251 NumArgs = NewNumArgs;
3252 }
3253
3254 /// Bluntly set a new number of arguments without doing any checks whatsoever.
3255 /// Only used during construction of a CallExpr in a few places in Sema.
3256 /// FIXME: Find a way to remove it.
3257 void setNumArgsUnsafe(unsigned NewNumArgs) { NumArgs = NewNumArgs; }
3258
3261 typedef llvm::iterator_range<arg_iterator> arg_range;
3262 typedef llvm::iterator_range<const_arg_iterator> const_arg_range;
3263
3266 return const_arg_range(arg_begin(), arg_end());
3267 }
3268
3270 return getTrailingStmts() + PREARGS_START + getNumPreArgs();
3271 }
3273
3275 return getTrailingStmts() + PREARGS_START + getNumPreArgs();
3276 }
3278
3279 /// This method provides fast access to all the subexpressions of
3280 /// a CallExpr without going through the slower virtual child_iterator
3281 /// interface. This provides efficient reverse iteration of the
3282 /// subexpressions. This is currently used for CFG construction.
3284 return {getTrailingStmts(), PREARGS_START + getNumPreArgs() + getNumArgs()};
3285 }
3286
3287 /// Get FPOptionsOverride from trailing storage.
3289 assert(hasStoredFPFeatures());
3290 return *getTrailingFPFeatures();
3291 }
3292 /// Set FPOptionsOverride in trailing storage. Used only by Serialization.
3297
3298 /// Get the store FPOptionsOverride or default if not stored.
3302
3303 /// Get the FP features status of this operator. Only meaningful for
3304 /// operations on floating point types.
3310
3312 if (hasStoredFPFeatures())
3313 return getStoredFPFeatures();
3314 return FPOptionsOverride();
3315 }
3316
3317 /// getBuiltinCallee - If this is a call to a builtin, return the builtin ID
3318 /// of the callee. If not, return 0.
3319 unsigned getBuiltinCallee() const;
3320
3321 /// Returns \c true if this is a call to a builtin which does not
3322 /// evaluate side-effects within its arguments.
3323 bool isUnevaluatedBuiltinCall(const ASTContext &Ctx) const;
3324
3325 /// getCallReturnType - Get the return type of the call expr. This is not
3326 /// always the type of the expr itself, if the return type is a reference
3327 /// type.
3328 QualType getCallReturnType(const ASTContext &Ctx) const;
3329
3330 /// Returns the WarnUnusedResultAttr that is declared on the callee
3331 /// or its return type declaration, together with a NamedDecl that
3332 /// refers to the declaration the attribute is attached to.
3333 std::pair<const NamedDecl *, const WarnUnusedResultAttr *>
3337
3338 /// Returns true if this call expression should warn on unused results.
3339 bool hasUnusedResultAttr(const ASTContext &Ctx) const {
3340 return getUnusedResultAttr(Ctx).second != nullptr;
3341 }
3342
3343 SourceLocation getRParenLoc() const { return RParenLoc; }
3344 void setRParenLoc(SourceLocation L) { RParenLoc = L; }
3345
3347 if (CallExprBits.HasTrailingSourceLoc) {
3348 static_assert(sizeof(CallExpr) <=
3350 return *reinterpret_cast<const SourceLocation *>(
3351 reinterpret_cast<const char *>(this + 1));
3352 }
3353
3354 if (usesMemberSyntax())
3355 if (auto FirstArgLoc = getArg(0)->getBeginLoc(); FirstArgLoc.isValid())
3356 return FirstArgLoc;
3357
3358 // FIXME: Some builtins have no callee begin location
3360 if (begin.isInvalid() && getNumArgs() > 0 && getArg(0))
3361 begin = getArg(0)->getBeginLoc();
3362 return begin;
3363 }
3364
3366
3367private:
3368 friend class ASTStmtReader;
3369 bool hasTrailingSourceLoc() const {
3370 return CallExprBits.HasTrailingSourceLoc;
3371 }
3372
3373 void updateTrailingSourceLoc() {
3374 assert(!CallExprBits.HasTrailingSourceLoc &&
3375 "Trailing source loc already set?");
3376 assert(getStmtClass() == CallExprClass &&
3377 "Calling setTrailingSourceLocs on a subclass of CallExpr");
3378 static_assert(sizeof(CallExpr) <=
3380
3381 SourceLocation *Locs =
3382 reinterpret_cast<SourceLocation *>(reinterpret_cast<char *>(this + 1));
3383 new (Locs) SourceLocation(getBeginLoc());
3384 CallExprBits.HasTrailingSourceLoc = true;
3385 }
3386
3387public:
3388 /// Return true if this is a call to __assume() or __builtin_assume() with
3389 /// a non-value-dependent constant parameter evaluating as false.
3390 bool isBuiltinAssumeFalse(const ASTContext &Ctx) const;
3391
3392 /// Used by Sema to implement MSVC-compatible delayed name lookup.
3393 /// (Usually Exprs themselves should set dependence).
3395 setDependence(getDependence() | ExprDependence::TypeValueInstantiation);
3396 }
3397
3398 /// Try to get the alloc_size attribute of the callee. May return null.
3399 const AllocSizeAttr *getCalleeAllocSizeAttr() const;
3400
3401 /// Evaluates the total size in bytes allocated by calling a function
3402 /// decorated with alloc_size. Returns std::nullopt if the the result cannot
3403 /// be evaluated.
3404 std::optional<llvm::APInt>
3406
3407 bool isCallToStdMove() const;
3408
3409 static bool classof(const Stmt *T) {
3410 return T->getStmtClass() >= firstCallExprConstant &&
3411 T->getStmtClass() <= lastCallExprConstant;
3412 }
3413
3414 // Iterators
3416 return child_range(getTrailingStmts(), getTrailingStmts() + PREARGS_START +
3418 }
3419
3421 return const_child_range(getTrailingStmts(),
3422 getTrailingStmts() + PREARGS_START +
3424 }
3425};
3426
3427/// MemberExpr - [C99 6.5.2.3] Structure and Union Members. X->F and X.F.
3428///
3429class MemberExpr final
3430 : public Expr,
3431 private llvm::TrailingObjects<MemberExpr, NestedNameSpecifierLoc,
3432 DeclAccessPair, ASTTemplateKWAndArgsInfo,
3433 TemplateArgumentLoc> {
3434 friend class ASTReader;
3435 friend class ASTStmtReader;
3436 friend class ASTStmtWriter;
3437 friend TrailingObjects;
3438
3439 /// Base - the expression for the base pointer or structure references. In
3440 /// X.F, this is "X".
3441 Stmt *Base;
3442
3443 /// MemberDecl - This is the decl being referenced by the field/member name.
3444 /// In X.F, this is the decl referenced by F.
3445 ValueDecl *MemberDecl;
3446
3447 /// MemberDNLoc - Provides source/type location info for the
3448 /// declaration name embedded in MemberDecl.
3449 DeclarationNameLoc MemberDNLoc;
3450
3451 /// MemberLoc - This is the location of the member name.
3452 SourceLocation MemberLoc;
3453
3454 size_t numTrailingObjects(OverloadToken<NestedNameSpecifierLoc>) const {
3455 return hasQualifier();
3456 }
3457
3458 size_t numTrailingObjects(OverloadToken<DeclAccessPair>) const {
3459 return hasFoundDecl();
3460 }
3461
3462 size_t numTrailingObjects(OverloadToken<ASTTemplateKWAndArgsInfo>) const {
3463 return hasTemplateKWAndArgsInfo();
3464 }
3465
3466 bool hasFoundDecl() const { return MemberExprBits.HasFoundDecl; }
3467
3468 bool hasTemplateKWAndArgsInfo() const {
3469 return MemberExprBits.HasTemplateKWAndArgsInfo;
3470 }
3471
3472 MemberExpr(Expr *Base, bool IsArrow, SourceLocation OperatorLoc,
3473 NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc,
3474 ValueDecl *MemberDecl, DeclAccessPair FoundDecl,
3475 const DeclarationNameInfo &NameInfo,
3476 const TemplateArgumentListInfo *TemplateArgs, QualType T,
3478 MemberExpr(EmptyShell Empty)
3479 : Expr(MemberExprClass, Empty), Base(), MemberDecl() {}
3480
3481public:
3482 static MemberExpr *Create(const ASTContext &C, Expr *Base, bool IsArrow,
3483 SourceLocation OperatorLoc,
3484 NestedNameSpecifierLoc QualifierLoc,
3485 SourceLocation TemplateKWLoc, ValueDecl *MemberDecl,
3486 DeclAccessPair FoundDecl,
3487 DeclarationNameInfo MemberNameInfo,
3488 const TemplateArgumentListInfo *TemplateArgs,
3489 QualType T, ExprValueKind VK, ExprObjectKind OK,
3490 NonOdrUseReason NOUR);
3491
3492 /// Create an implicit MemberExpr, with no location, qualifier, template
3493 /// arguments, and so on. Suitable only for non-static member access.
3494 static MemberExpr *CreateImplicit(const ASTContext &C, Expr *Base,
3495 bool IsArrow, ValueDecl *MemberDecl,
3497 ExprObjectKind OK) {
3498 return Create(C, Base, IsArrow, SourceLocation(), NestedNameSpecifierLoc(),
3499 SourceLocation(), MemberDecl,
3500 DeclAccessPair::make(MemberDecl, MemberDecl->getAccess()),
3501 DeclarationNameInfo(), nullptr, T, VK, OK, NOUR_None);
3502 }
3503
3504 static MemberExpr *CreateEmpty(const ASTContext &Context, bool HasQualifier,
3505 bool HasFoundDecl,
3506 bool HasTemplateKWAndArgsInfo,
3507 unsigned NumTemplateArgs);
3508
3509 void setBase(Expr *E) { Base = E; }
3510 Expr *getBase() const { return cast<Expr>(Base); }
3511
3512 /// Retrieve the member declaration to which this expression refers.
3513 ///
3514 /// The returned declaration will be a FieldDecl or (in C++) a VarDecl (for
3515 /// static data members), a CXXMethodDecl, or an EnumConstantDecl.
3516 ValueDecl *getMemberDecl() const { return MemberDecl; }
3517 void setMemberDecl(ValueDecl *D);
3518
3519 /// Retrieves the declaration found by lookup.
3521 if (!hasFoundDecl())
3523 getMemberDecl()->getAccess());
3524 return *getTrailingObjects<DeclAccessPair>();
3525 }
3526
3527 /// Determines whether this member expression actually had
3528 /// a C++ nested-name-specifier prior to the name of the member, e.g.,
3529 /// x->Base::foo.
3530 bool hasQualifier() const { return MemberExprBits.HasQualifier; }
3531
3532 /// If the member name was qualified, retrieves the
3533 /// nested-name-specifier that precedes the member name, with source-location
3534 /// information.
3536 if (!hasQualifier())
3537 return NestedNameSpecifierLoc();
3538 return *getTrailingObjects<NestedNameSpecifierLoc>();
3539 }
3540
3541 /// If the member name was qualified, retrieves the
3542 /// nested-name-specifier that precedes the member name. Otherwise, returns
3543 /// NULL.
3547
3548 /// Retrieve the location of the template keyword preceding
3549 /// the member name, if any.
3551 if (!hasTemplateKWAndArgsInfo())
3552 return SourceLocation();
3553 return getTrailingObjects<ASTTemplateKWAndArgsInfo>()->TemplateKWLoc;
3554 }
3555
3556 /// Retrieve the location of the left angle bracket starting the
3557 /// explicit template argument list following the member name, if any.
3559 if (!hasTemplateKWAndArgsInfo())
3560 return SourceLocation();
3561 return getTrailingObjects<ASTTemplateKWAndArgsInfo>()->LAngleLoc;
3562 }
3563
3564 /// Retrieve the location of the right angle bracket ending the
3565 /// explicit template argument list following the member name, if any.
3567 if (!hasTemplateKWAndArgsInfo())
3568 return SourceLocation();
3569 return getTrailingObjects<ASTTemplateKWAndArgsInfo>()->RAngleLoc;
3570 }
3571
3572 /// Determines whether the member name was preceded by the template keyword.
3574
3575 /// Determines whether the member name was followed by an
3576 /// explicit template argument list.
3577 bool hasExplicitTemplateArgs() const { return getLAngleLoc().isValid(); }
3578
3579 /// Copies the template arguments (if present) into the given
3580 /// structure.
3583 getTrailingObjects<ASTTemplateKWAndArgsInfo>()->copyInto(
3584 getTrailingObjects<TemplateArgumentLoc>(), List);
3585 }
3586
3587 /// Retrieve the template arguments provided as part of this
3588 /// template-id.
3591 return nullptr;
3592
3593 return getTrailingObjects<TemplateArgumentLoc>();
3594 }
3595
3596 /// Retrieve the number of template arguments provided as part of this
3597 /// template-id.
3598 unsigned getNumTemplateArgs() const {
3600 return 0;
3601
3602 return getTrailingObjects<ASTTemplateKWAndArgsInfo>()->NumTemplateArgs;
3603 }
3604
3608
3609 /// Retrieve the member declaration name info.
3611 return DeclarationNameInfo(MemberDecl->getDeclName(),
3612 MemberLoc, MemberDNLoc);
3613 }
3614
3615 SourceLocation getOperatorLoc() const { return MemberExprBits.OperatorLoc; }
3616
3617 bool isArrow() const { return MemberExprBits.IsArrow; }
3618 void setArrow(bool A) { MemberExprBits.IsArrow = A; }
3619
3620 /// getMemberLoc - Return the location of the "member", in X->F, it is the
3621 /// location of 'F'.
3622 SourceLocation getMemberLoc() const { return MemberLoc; }
3623 void setMemberLoc(SourceLocation L) { MemberLoc = L; }
3624
3625 SourceLocation getBeginLoc() const LLVM_READONLY;
3626 SourceLocation getEndLoc() const LLVM_READONLY;
3627
3628 SourceLocation getExprLoc() const LLVM_READONLY { return MemberLoc; }
3629
3630 /// Determine whether the base of this explicit is implicit.
3631 bool isImplicitAccess() const {
3632 return getBase() && getBase()->isImplicitCXXThis();
3633 }
3634
3635 /// Returns true if this member expression refers to a method that
3636 /// was resolved from an overloaded set having size greater than 1.
3638 return MemberExprBits.HadMultipleCandidates;
3639 }
3640 /// Sets the flag telling whether this expression refers to
3641 /// a method that was resolved from an overloaded set having size
3642 /// greater than 1.
3643 void setHadMultipleCandidates(bool V = true) {
3644 MemberExprBits.HadMultipleCandidates = V;
3645 }
3646
3647 /// Returns true if virtual dispatch is performed.
3648 /// If the member access is fully qualified, (i.e. X::f()), virtual
3649 /// dispatching is not performed. In -fapple-kext mode qualified
3650 /// calls to virtual method will still go through the vtable.
3651 bool performsVirtualDispatch(const LangOptions &LO) const {
3652 return LO.AppleKext || !hasQualifier();
3653 }
3654
3655 /// Is this expression a non-odr-use reference, and if so, why?
3656 /// This is only meaningful if the named member is a static member.
3658 return static_cast<NonOdrUseReason>(MemberExprBits.NonOdrUseReason);
3659 }
3660
3661 static bool classof(const Stmt *T) {
3662 return T->getStmtClass() == MemberExprClass;
3663 }
3664
3665 // Iterators
3666 child_range children() { return child_range(&Base, &Base+1); }
3668 return const_child_range(&Base, &Base + 1);
3669 }
3670};
3671
3672/// CompoundLiteralExpr - [C99 6.5.2.5]
3673///
3675 /// LParenLoc - If non-null, this is the location of the left paren in a
3676 /// compound literal like "(int){4}". This can be null if this is a
3677 /// synthesized compound expression.
3678 SourceLocation LParenLoc;
3679
3680 /// The type as written. This can be an incomplete array type, in
3681 /// which case the actual expression type will be different.
3682 /// The int part of the pair stores whether this expr is file scope.
3683 llvm::PointerIntPair<TypeSourceInfo *, 1, bool> TInfoAndScope;
3684 Stmt *Init;
3685
3686 /// Value of constant literals with static storage duration.
3687 mutable APValue *StaticValue = nullptr;
3688
3689public:
3691 QualType T, ExprValueKind VK, Expr *init, bool fileScope)
3692 : Expr(CompoundLiteralExprClass, T, VK, OK_Ordinary),
3693 LParenLoc(lparenloc), TInfoAndScope(tinfo, fileScope), Init(init) {
3694 assert(Init && "Init is a nullptr");
3696 }
3697
3698 /// Construct an empty compound literal.
3700 : Expr(CompoundLiteralExprClass, Empty) { }
3701
3702 const Expr *getInitializer() const { return cast<Expr>(Init); }
3703 Expr *getInitializer() { return cast<Expr>(Init); }
3704 void setInitializer(Expr *E) { Init = E; }
3705
3706 bool isFileScope() const { return TInfoAndScope.getInt(); }
3707 void setFileScope(bool FS) { TInfoAndScope.setInt(FS); }
3708
3709 SourceLocation getLParenLoc() const { return LParenLoc; }
3710 void setLParenLoc(SourceLocation L) { LParenLoc = L; }
3711
3713 return TInfoAndScope.getPointer();
3714 }
3716 TInfoAndScope.setPointer(tinfo);
3717 }
3718
3719 bool hasStaticStorage() const { return isFileScope() && isGLValue(); }
3721 APValue &getStaticValue() const;
3722
3723 SourceLocation getBeginLoc() const LLVM_READONLY {
3724 if (LParenLoc.isInvalid())
3725 return Init->getBeginLoc();
3726 return LParenLoc;
3727 }
3728 SourceLocation getEndLoc() const LLVM_READONLY { return Init->getEndLoc(); }
3729
3730 static bool classof(const Stmt *T) {
3731 return T->getStmtClass() == CompoundLiteralExprClass;
3732 }
3733
3734 // Iterators
3735 child_range children() { return child_range(&Init, &Init+1); }
3737 return const_child_range(&Init, &Init + 1);
3738 }
3739};
3740
3741/// CastExpr - Base class for type casts, including both implicit
3742/// casts (ImplicitCastExpr) and explicit casts that have some
3743/// representation in the source code (ExplicitCastExpr's derived
3744/// classes).
3745class CastExpr : public Expr {
3746 Stmt *Op;
3747
3748 bool CastConsistency() const;
3749
3750 const CXXBaseSpecifier * const *path_buffer() const {
3751 return const_cast<CastExpr*>(this)->path_buffer();
3752 }
3753 CXXBaseSpecifier **path_buffer();
3754
3755 friend class ASTStmtReader;
3756
3757protected:
3759 Expr *op, unsigned BasePathSize, bool HasFPFeatures)
3760 : Expr(SC, ty, VK, OK_Ordinary), Op(op) {
3761 CastExprBits.Kind = kind;
3762 CastExprBits.PartOfExplicitCast = false;
3763 CastExprBits.BasePathSize = BasePathSize;
3764 assert((CastExprBits.BasePathSize == BasePathSize) &&
3765 "BasePathSize overflow!");
3766 assert(CastConsistency());
3767 CastExprBits.HasFPFeatures = HasFPFeatures;
3768 }
3769
3770 /// Construct an empty cast.
3771 CastExpr(StmtClass SC, EmptyShell Empty, unsigned BasePathSize,
3772 bool HasFPFeatures)
3773 : Expr(SC, Empty) {
3774 CastExprBits.PartOfExplicitCast = false;
3775 CastExprBits.BasePathSize = BasePathSize;
3776 CastExprBits.HasFPFeatures = HasFPFeatures;
3777 assert((CastExprBits.BasePathSize == BasePathSize) &&
3778 "BasePathSize overflow!");
3779 }
3780
3781 /// Return a pointer to the trailing FPOptions.
3782 /// \pre hasStoredFPFeatures() == true
3785 return const_cast<CastExpr *>(this)->getTrailingFPFeatures();
3786 }
3787
3788public:
3789 CastKind getCastKind() const { return (CastKind) CastExprBits.Kind; }
3790 void setCastKind(CastKind K) { CastExprBits.Kind = K; }
3791
3792 static const char *getCastKindName(CastKind CK);
3793 const char *getCastKindName() const { return getCastKindName(getCastKind()); }
3794
3795 Expr *getSubExpr() { return cast<Expr>(Op); }
3796 const Expr *getSubExpr() const { return cast<Expr>(Op); }
3797 void setSubExpr(Expr *E) { Op = E; }
3798
3799 /// Retrieve the cast subexpression as it was written in the source
3800 /// code, looking through any implicit casts or other intermediate nodes
3801 /// introduced by semantic analysis.
3803 const Expr *getSubExprAsWritten() const {
3804 return const_cast<CastExpr *>(this)->getSubExprAsWritten();
3805 }
3806
3807 /// If this cast applies a user-defined conversion, retrieve the conversion
3808 /// function that it invokes.
3810
3813 bool path_empty() const { return path_size() == 0; }
3814 unsigned path_size() const { return CastExprBits.BasePathSize; }
3815 path_iterator path_begin() { return path_buffer(); }
3816 path_iterator path_end() { return path_buffer() + path_size(); }
3817 path_const_iterator path_begin() const { return path_buffer(); }
3818 path_const_iterator path_end() const { return path_buffer() + path_size(); }
3819
3820 /// Path through the class hierarchy taken by casts between base and derived
3821 /// classes (see implementation of `CastConsistency()` for a full list of
3822 /// cast kinds that have a path).
3823 ///
3824 /// For each derived-to-base edge in the path, the path contains a
3825 /// `CXXBaseSpecifier` for the base class of that edge; the entries are
3826 /// ordered from derived class to base class.
3827 ///
3828 /// For example, given classes `Base`, `Intermediate : public Base` and
3829 /// `Derived : public Intermediate`, the path for a cast from `Derived *` to
3830 /// `Base *` contains two entries: One for `Intermediate`, and one for `Base`,
3831 /// in that order.
3832 llvm::iterator_range<path_iterator> path() {
3833 return llvm::make_range(path_begin(), path_end());
3834 }
3835 llvm::iterator_range<path_const_iterator> path() const {
3836 return llvm::make_range(path_begin(), path_end());
3837 }
3838
3840 assert(getCastKind() == CK_ToUnion);
3842 }
3843
3844 bool hasStoredFPFeatures() const { return CastExprBits.HasFPFeatures; }
3845
3846 /// Get FPOptionsOverride from trailing storage.
3848 assert(hasStoredFPFeatures());
3849 return *getTrailingFPFeatures();
3850 }
3851
3852 /// Get the store FPOptionsOverride or default if not stored.
3856
3857 /// Get the FP features status of this operation. Only meaningful for
3858 /// operations on floating point types.
3864
3866 if (hasStoredFPFeatures())
3867 return getStoredFPFeatures();
3868 return FPOptionsOverride();
3869 }
3870
3871 /// Return
3872 // True : if this conversion changes the volatile-ness of a gl-value.
3873 // Qualification conversions on gl-values currently use CK_NoOp, but
3874 // it's important to recognize volatile-changing conversions in
3875 // clients code generation that normally eagerly peephole loads. Note
3876 // that the query is answering for this specific node; Sema may
3877 // produce multiple cast nodes for any particular conversion sequence.
3878 // False : Otherwise.
3880 return (isGLValue() && (getType().isVolatileQualified() !=
3881 getSubExpr()->getType().isVolatileQualified()));
3882 }
3883
3884 static const FieldDecl *getTargetFieldForToUnionCast(QualType unionType,
3885 QualType opType);
3886 static const FieldDecl *getTargetFieldForToUnionCast(const RecordDecl *RD,
3887 QualType opType);
3888
3889 static bool classof(const Stmt *T) {
3890 return T->getStmtClass() >= firstCastExprConstant &&
3891 T->getStmtClass() <= lastCastExprConstant;
3892 }
3893
3894 // Iterators
3895 child_range children() { return child_range(&Op, &Op+1); }
3896 const_child_range children() const { return const_child_range(&Op, &Op + 1); }
3897};
3898
3899/// ImplicitCastExpr - Allows us to explicitly represent implicit type
3900/// conversions, which have no direct representation in the original
3901/// source code. For example: converting T[]->T*, void f()->void
3902/// (*f)(), float->double, short->int, etc.
3903///
3904/// In C, implicit casts always produce rvalues. However, in C++, an
3905/// implicit cast whose result is being bound to a reference will be
3906/// an lvalue or xvalue. For example:
3907///
3908/// @code
3909/// class Base { };
3910/// class Derived : public Base { };
3911/// Derived &&ref();
3912/// void f(Derived d) {
3913/// Base& b = d; // initializer is an ImplicitCastExpr
3914/// // to an lvalue of type Base
3915/// Base&& r = ref(); // initializer is an ImplicitCastExpr
3916/// // to an xvalue of type Base
3917/// }
3918/// @endcode
3919class ImplicitCastExpr final
3920 : public CastExpr,
3921 private llvm::TrailingObjects<ImplicitCastExpr, CXXBaseSpecifier *,
3922 FPOptionsOverride> {
3923
3924 ImplicitCastExpr(QualType ty, CastKind kind, Expr *op,
3925 unsigned BasePathLength, FPOptionsOverride FPO,
3927 : CastExpr(ImplicitCastExprClass, ty, VK, kind, op, BasePathLength,
3930 if (hasStoredFPFeatures())
3931 *getTrailingFPFeatures() = FPO;
3932 }
3933
3934 /// Construct an empty implicit cast.
3935 explicit ImplicitCastExpr(EmptyShell Shell, unsigned PathSize,
3936 bool HasFPFeatures)
3937 : CastExpr(ImplicitCastExprClass, Shell, PathSize, HasFPFeatures) {}
3938
3939 unsigned numTrailingObjects(OverloadToken<CXXBaseSpecifier *>) const {
3940 return path_size();
3941 }
3942
3943public:
3947 : CastExpr(ImplicitCastExprClass, ty, VK, kind, op, 0,
3948 FPO.requiresTrailingStorage()) {
3949 if (hasStoredFPFeatures())
3950 *getTrailingFPFeatures() = FPO;
3951 }
3952
3953 bool isPartOfExplicitCast() const { return CastExprBits.PartOfExplicitCast; }
3954 void setIsPartOfExplicitCast(bool PartOfExplicitCast) {
3955 CastExprBits.PartOfExplicitCast = PartOfExplicitCast;
3956 }
3957
3958 static ImplicitCastExpr *Create(const ASTContext &Context, QualType T,
3959 CastKind Kind, Expr *Operand,
3960 const CXXCastPath *BasePath,
3962
3963 static ImplicitCastExpr *CreateEmpty(const ASTContext &Context,
3964 unsigned PathSize, bool HasFPFeatures);
3965
3966 SourceLocation getBeginLoc() const LLVM_READONLY {
3967 return getSubExpr()->getBeginLoc();
3968 }
3969 SourceLocation getEndLoc() const LLVM_READONLY {
3970 return getSubExpr()->getEndLoc();
3971 }
3972
3973 static bool classof(const Stmt *T) {
3974 return T->getStmtClass() == ImplicitCastExprClass;
3975 }
3976
3978 friend class CastExpr;
3979};
3980
3981/// ExplicitCastExpr - An explicit cast written in the source
3982/// code.
3983///
3984/// This class is effectively an abstract class, because it provides
3985/// the basic representation of an explicitly-written cast without
3986/// specifying which kind of cast (C cast, functional cast, static
3987/// cast, etc.) was written; specific derived classes represent the
3988/// particular style of cast and its location information.
3989///
3990/// Unlike implicit casts, explicit cast nodes have two different
3991/// types: the type that was written into the source code, and the
3992/// actual type of the expression as determined by semantic
3993/// analysis. These types may differ slightly. For example, in C++ one
3994/// can cast to a reference type, which indicates that the resulting
3995/// expression will be an lvalue or xvalue. The reference type, however,
3996/// will not be used as the type of the expression.
3998 /// TInfo - Source type info for the (written) type
3999 /// this expression is casting to.
4000 TypeSourceInfo *TInfo;
4001
4002protected:
4004 CastKind kind, Expr *op, unsigned PathSize,
4005 bool HasFPFeatures, TypeSourceInfo *writtenTy)
4006 : CastExpr(SC, exprTy, VK, kind, op, PathSize, HasFPFeatures),
4007 TInfo(writtenTy) {
4009 }
4010
4011 /// Construct an empty explicit cast.
4012 ExplicitCastExpr(StmtClass SC, EmptyShell Shell, unsigned PathSize,
4013 bool HasFPFeatures)
4014 : CastExpr(SC, Shell, PathSize, HasFPFeatures) {}
4015
4016public:
4017 /// getTypeInfoAsWritten - Returns the type source info for the type
4018 /// that this expression is casting to.
4019 TypeSourceInfo *getTypeInfoAsWritten() const { return TInfo; }
4020 void setTypeInfoAsWritten(TypeSourceInfo *writtenTy) { TInfo = writtenTy; }
4021
4022 /// getTypeAsWritten - Returns the type that this expression is
4023 /// casting to, as written in the source code.
4024 QualType getTypeAsWritten() const { return TInfo->getType(); }
4025
4026 static bool classof(const Stmt *T) {
4027 return T->getStmtClass() >= firstExplicitCastExprConstant &&
4028 T->getStmtClass() <= lastExplicitCastExprConstant;
4029 }
4030};
4031
4032/// CStyleCastExpr - An explicit cast in C (C99 6.5.4) or a C-style
4033/// cast in C++ (C++ [expr.cast]), which uses the syntax
4034/// (Type)expr. For example: @c (int)f.
4035class CStyleCastExpr final
4036 : public ExplicitCastExpr,
4037 private llvm::TrailingObjects<CStyleCastExpr, CXXBaseSpecifier *,
4038 FPOptionsOverride> {
4039 SourceLocation LPLoc; // the location of the left paren
4040 SourceLocation RPLoc; // the location of the right paren
4041
4042 CStyleCastExpr(QualType exprTy, ExprValueKind vk, CastKind kind, Expr *op,
4043 unsigned PathSize, FPOptionsOverride FPO,
4045 : ExplicitCastExpr(CStyleCastExprClass, exprTy, vk, kind, op, PathSize,
4046 FPO.requiresTrailingStorage(), writtenTy),
4047 LPLoc(l), RPLoc(r) {
4048 if (hasStoredFPFeatures())
4049 *getTrailingFPFeatures() = FPO;
4050 }
4051
4052 /// Construct an empty C-style explicit cast.
4053 explicit CStyleCastExpr(EmptyShell Shell, unsigned PathSize,
4054 bool HasFPFeatures)
4055 : ExplicitCastExpr(CStyleCastExprClass, Shell, PathSize, HasFPFeatures) {}
4056
4057 unsigned numTrailingObjects(OverloadToken<CXXBaseSpecifier *>) const {
4058 return path_size();
4059 }
4060
4061public:
4062 static CStyleCastExpr *
4063 Create(const ASTContext &Context, QualType T, ExprValueKind VK, CastKind K,
4064 Expr *Op, const CXXCastPath *BasePath, FPOptionsOverride FPO,
4066
4067 static CStyleCastExpr *CreateEmpty(const ASTContext &Context,
4068 unsigned PathSize, bool HasFPFeatures);
4069
4070 SourceLocation getLParenLoc() const { return LPLoc; }
4071 void setLParenLoc(SourceLocation L) { LPLoc = L; }
4072
4073 SourceLocation getRParenLoc() const { return RPLoc; }
4074 void setRParenLoc(SourceLocation L) { RPLoc = L; }
4075
4076 SourceLocation getBeginLoc() const LLVM_READONLY { return LPLoc; }
4077 SourceLocation getEndLoc() const LLVM_READONLY {
4078 return getSubExpr()->getEndLoc();
4079 }
4080
4081 static bool classof(const Stmt *T) {
4082 return T->getStmtClass() == CStyleCastExprClass;
4083 }
4084
4086 friend class CastExpr;
4087};
4088
4089/// A builtin binary operation expression such as "x + y" or "x <= y".
4090///
4091/// This expression node kind describes a builtin binary operation,
4092/// such as "x + y" for integer values "x" and "y". The operands will
4093/// already have been converted to appropriate types (e.g., by
4094/// performing promotions or conversions).
4095///
4096/// In C++, where operators may be overloaded, a different kind of
4097/// expression node (CXXOperatorCallExpr) is used to express the
4098/// invocation of an overloaded operator with operator syntax. Within
4099/// a C++ template, whether BinaryOperator or CXXOperatorCallExpr is
4100/// used to store an expression "x + y" depends on the subexpressions
4101/// for x and y. If neither x or y is type-dependent, and the "+"
4102/// operator resolves to a built-in operation, BinaryOperator will be
4103/// used to express the computation (x and y may still be
4104/// value-dependent). If either x or y is type-dependent, or if the
4105/// "+" resolves to an overloaded operator, CXXOperatorCallExpr will
4106/// be used to express the computation.
4107class BinaryOperator : public Expr {
4108 enum { LHS, RHS, END_EXPR };
4109 Stmt *SubExprs[END_EXPR];
4110
4111public:
4113
4114protected:
4115 size_t offsetOfTrailingStorage() const;
4116
4117 /// Return a pointer to the trailing FPOptions
4119 assert(BinaryOperatorBits.HasFPFeatures);
4120 return reinterpret_cast<FPOptionsOverride *>(
4121 reinterpret_cast<char *>(this) + offsetOfTrailingStorage());
4122 }
4124 assert(BinaryOperatorBits.HasFPFeatures);
4125 return reinterpret_cast<const FPOptionsOverride *>(
4126 reinterpret_cast<const char *>(this) + offsetOfTrailingStorage());
4127 }
4128
4129 /// Build a binary operator, assuming that appropriate storage has been
4130 /// allocated for the trailing objects when needed.
4131 BinaryOperator(const ASTContext &Ctx, Expr *lhs, Expr *rhs, Opcode opc,
4133 SourceLocation opLoc, FPOptionsOverride FPFeatures);
4134
4135 /// Construct an empty binary operator.
4136 explicit BinaryOperator(EmptyShell Empty) : Expr(BinaryOperatorClass, Empty) {
4137 BinaryOperatorBits.Opc = BO_Comma;
4138 BinaryOperatorBits.ExcludedOverflowPattern = false;
4139 }
4140
4141public:
4142 static BinaryOperator *CreateEmpty(const ASTContext &C, bool hasFPFeatures);
4143
4144 static BinaryOperator *Create(const ASTContext &C, Expr *lhs, Expr *rhs,
4145 Opcode opc, QualType ResTy, ExprValueKind VK,
4147 FPOptionsOverride FPFeatures);
4151
4153 return static_cast<Opcode>(BinaryOperatorBits.Opc);
4154 }
4155 void setOpcode(Opcode Opc) { BinaryOperatorBits.Opc = Opc; }
4156
4157 Expr *getLHS() const { return cast<Expr>(SubExprs[LHS]); }
4158 void setLHS(Expr *E) { SubExprs[LHS] = E; }
4159 Expr *getRHS() const { return cast<Expr>(SubExprs[RHS]); }
4160 void setRHS(Expr *E) { SubExprs[RHS] = E; }
4161
4162 SourceLocation getBeginLoc() const LLVM_READONLY {
4163 return getLHS()->getBeginLoc();
4164 }
4165 SourceLocation getEndLoc() const LLVM_READONLY {
4166 return getRHS()->getEndLoc();
4167 }
4168
4169 /// getOpcodeStr - Turn an Opcode enum value into the punctuation char it
4170 /// corresponds to, e.g. "<<=".
4171 static StringRef getOpcodeStr(Opcode Op);
4172
4173 StringRef getOpcodeStr() const { return getOpcodeStr(getOpcode()); }
4174
4175 /// Retrieve the binary opcode that corresponds to the given
4176 /// overloaded operator.
4178
4179 /// Retrieve the overloaded operator kind that corresponds to
4180 /// the given binary opcode.
4182
4183 /// predicates to categorize the respective opcodes.
4184 static bool isPtrMemOp(Opcode Opc) {
4185 return Opc == BO_PtrMemD || Opc == BO_PtrMemI;
4186 }
4187 bool isPtrMemOp() const { return isPtrMemOp(getOpcode()); }
4188
4189 static bool isMultiplicativeOp(Opcode Opc) {
4190 return Opc >= BO_Mul && Opc <= BO_Rem;
4191 }
4193 static bool isAdditiveOp(Opcode Opc) { return Opc == BO_Add || Opc==BO_Sub; }
4194 bool isAdditiveOp() const { return isAdditiveOp(getOpcode()); }
4195 static bool isShiftOp(Opcode Opc) { return Opc == BO_Shl || Opc == BO_Shr; }
4196 bool isShiftOp() const { return isShiftOp(getOpcode()); }
4197
4198 static bool isBitwiseOp(Opcode Opc) { return Opc >= BO_And && Opc <= BO_Or; }
4199 bool isBitwiseOp() const { return isBitwiseOp(getOpcode()); }
4200
4201 static bool isRelationalOp(Opcode Opc) { return Opc >= BO_LT && Opc<=BO_GE; }
4202 bool isRelationalOp() const { return isRelationalOp(getOpcode()); }
4203
4204 static bool isEqualityOp(Opcode Opc) { return Opc == BO_EQ || Opc == BO_NE; }
4205 bool isEqualityOp() const { return isEqualityOp(getOpcode()); }
4206
4207 static bool isComparisonOp(Opcode Opc) { return Opc >= BO_Cmp && Opc<=BO_NE; }
4208 bool isComparisonOp() const { return isComparisonOp(getOpcode()); }
4209
4210 static bool isCommaOp(Opcode Opc) { return Opc == BO_Comma; }
4211 bool isCommaOp() const { return isCommaOp(getOpcode()); }
4212
4214 switch (Opc) {
4215 default:
4216 llvm_unreachable("Not a comparison operator.");
4217 case BO_LT: return BO_GE;
4218 case BO_GT: return BO_LE;
4219 case BO_LE: return BO_GT;
4220 case BO_GE: return BO_LT;
4221 case BO_EQ: return BO_NE;
4222 case BO_NE: return BO_EQ;
4223 }
4224 }
4225
4227 switch (Opc) {
4228 default:
4229 llvm_unreachable("Not a comparison operator.");
4230 case BO_LT: return BO_GT;
4231 case BO_GT: return BO_LT;
4232 case BO_LE: return BO_GE;
4233 case BO_GE: return BO_LE;
4234 case BO_EQ:
4235 case BO_NE:
4236 return Opc;
4237 }
4238 }
4239
4240 static bool isLogicalOp(Opcode Opc) { return Opc == BO_LAnd || Opc==BO_LOr; }
4241 bool isLogicalOp() const { return isLogicalOp(getOpcode()); }
4242
4243 static bool isAssignmentOp(Opcode Opc) {
4244 return Opc >= BO_Assign && Opc <= BO_OrAssign;
4245 }
4246 bool isAssignmentOp() const { return isAssignmentOp(getOpcode()); }
4247
4249 return Opc > BO_Assign && Opc <= BO_OrAssign;
4250 }
4253 }
4255 assert(isCompoundAssignmentOp(Opc));
4256 if (Opc >= BO_AndAssign)
4257 return Opcode(unsigned(Opc) - BO_AndAssign + BO_And);
4258 else
4259 return Opcode(unsigned(Opc) - BO_MulAssign + BO_Mul);
4260 }
4261
4262 static bool isShiftAssignOp(Opcode Opc) {
4263 return Opc == BO_ShlAssign || Opc == BO_ShrAssign;
4264 }
4265 bool isShiftAssignOp() const {
4266 return isShiftAssignOp(getOpcode());
4267 }
4268
4269 /// Return true if a binary operator using the specified opcode and operands
4270 /// would match the 'p = (i8*)nullptr + n' idiom for casting a pointer-sized
4271 /// integer to a pointer.
4272 static bool isNullPointerArithmeticExtension(ASTContext &Ctx, Opcode Opc,
4273 const Expr *LHS,
4274 const Expr *RHS);
4275
4276 static bool classof(const Stmt *S) {
4277 return S->getStmtClass() >= firstBinaryOperatorConstant &&
4278 S->getStmtClass() <= lastBinaryOperatorConstant;
4279 }
4280
4281 // Iterators
4283 return child_range(&SubExprs[0], &SubExprs[0]+END_EXPR);
4284 }
4286 return const_child_range(&SubExprs[0], &SubExprs[0] + END_EXPR);
4287 }
4288
4289 /// Set and fetch the bit that shows whether FPFeatures needs to be
4290 /// allocated in Trailing Storage
4291 void setHasStoredFPFeatures(bool B) { BinaryOperatorBits.HasFPFeatures = B; }
4292 bool hasStoredFPFeatures() const { return BinaryOperatorBits.HasFPFeatures; }
4293
4294 /// Set and get the bit that informs arithmetic overflow sanitizers whether
4295 /// or not they should exclude certain BinaryOperators from instrumentation
4297 BinaryOperatorBits.ExcludedOverflowPattern = B;
4298 }
4300 return BinaryOperatorBits.ExcludedOverflowPattern;
4301 }
4302
4303 /// Get FPFeatures from trailing storage
4305 assert(hasStoredFPFeatures());
4306 return *getTrailingFPFeatures();
4307 }
4308 /// Set FPFeatures in trailing storage, used only by Serialization
4310 assert(BinaryOperatorBits.HasFPFeatures);
4311 *getTrailingFPFeatures() = F;
4312 }
4313 /// Get the store FPOptionsOverride or default if not stored.
4317
4318 /// Get the FP features status of this operator. Only meaningful for
4319 /// operations on floating point types.
4321 if (BinaryOperatorBits.HasFPFeatures)
4324 }
4325
4326 // This is used in ASTImporter
4328 if (BinaryOperatorBits.HasFPFeatures)
4329 return getStoredFPFeatures();
4330 return FPOptionsOverride();
4331 }
4332
4333 /// Get the FP contractibility status of this operator. Only meaningful for
4334 /// operations on floating point types.
4338
4339 /// Get the FENV_ACCESS status of this operator. Only meaningful for
4340 /// operations on floating point types.
4341 bool isFEnvAccessOn(const LangOptions &LO) const {
4342 return getFPFeaturesInEffect(LO).getAllowFEnvAccess();
4343 }
4344
4345protected:
4346 BinaryOperator(const ASTContext &Ctx, Expr *lhs, Expr *rhs, Opcode opc,
4348 SourceLocation opLoc, FPOptionsOverride FPFeatures,
4349 bool dead2);
4350
4351 /// Construct an empty BinaryOperator, SC is CompoundAssignOperator.
4353 BinaryOperatorBits.Opc = BO_MulAssign;
4354 }
4355
4356 /// Return the size in bytes needed for the trailing objects.
4357 /// Used to allocate the right amount of storage.
4358 static unsigned sizeOfTrailingObjects(bool HasFPFeatures) {
4359 return HasFPFeatures * sizeof(FPOptionsOverride);
4360 }
4361};
4362
4363/// CompoundAssignOperator - For compound assignments (e.g. +=), we keep
4364/// track of the type the operation is performed in. Due to the semantics of
4365/// these operators, the operands are promoted, the arithmetic performed, an
4366/// implicit conversion back to the result type done, then the assignment takes
4367/// place. This captures the intermediate type which the computation is done
4368/// in.
4369class CompoundAssignOperator : public BinaryOperator {
4370 QualType ComputationLHSType;
4371 QualType ComputationResultType;
4372
4373 /// Construct an empty CompoundAssignOperator.
4374 explicit CompoundAssignOperator(const ASTContext &C, EmptyShell Empty,
4375 bool hasFPFeatures)
4376 : BinaryOperator(CompoundAssignOperatorClass, Empty) {}
4377
4378protected:
4381 SourceLocation OpLoc, FPOptionsOverride FPFeatures,
4382 QualType CompLHSType, QualType CompResultType)
4383 : BinaryOperator(C, lhs, rhs, opc, ResType, VK, OK, OpLoc, FPFeatures,
4384 true),
4385 ComputationLHSType(CompLHSType), ComputationResultType(CompResultType) {
4386 assert(isCompoundAssignmentOp() &&
4387 "Only should be used for compound assignments");
4388 }
4389
4390public:
4392 bool hasFPFeatures);
4393
4394 static CompoundAssignOperator *
4395 Create(const ASTContext &C, Expr *lhs, Expr *rhs, Opcode opc, QualType ResTy,
4397 FPOptionsOverride FPFeatures, QualType CompLHSType = QualType(),
4398 QualType CompResultType = QualType());
4399
4400 // The two computation types are the type the LHS is converted
4401 // to for the computation and the type of the result; the two are
4402 // distinct in a few cases (specifically, int+=ptr and ptr-=ptr).
4403 QualType getComputationLHSType() const { return ComputationLHSType; }
4404 void setComputationLHSType(QualType T) { ComputationLHSType = T; }
4405
4406 QualType getComputationResultType() const { return ComputationResultType; }
4407 void setComputationResultType(QualType T) { ComputationResultType = T; }
4408
4409 static bool classof(const Stmt *S) {
4410 return S->getStmtClass() == CompoundAssignOperatorClass;
4411 }
4412};
4413
4415 assert(BinaryOperatorBits.HasFPFeatures);
4417 : sizeof(BinaryOperator);
4418}
4419
4420/// AbstractConditionalOperator - An abstract base class for
4421/// ConditionalOperator and BinaryConditionalOperator.
4423 SourceLocation QuestionLoc, ColonLoc;
4424 friend class ASTStmtReader;
4425
4426protected:
4429 SourceLocation cloc)
4430 : Expr(SC, T, VK, OK), QuestionLoc(qloc), ColonLoc(cloc) {}
4431
4434
4435public:
4436 /// getCond - Return the expression representing the condition for
4437 /// the ?: operator.
4438 Expr *getCond() const;
4439
4440 /// getTrueExpr - Return the subexpression representing the value of
4441 /// the expression if the condition evaluates to true.
4442 Expr *getTrueExpr() const;
4443
4444 /// getFalseExpr - Return the subexpression representing the value of
4445 /// the expression if the condition evaluates to false. This is
4446 /// the same as getRHS.
4447 Expr *getFalseExpr() const;
4448
4449 SourceLocation getQuestionLoc() const { return QuestionLoc; }
4450 SourceLocation getColonLoc() const { return ColonLoc; }
4451
4452 static bool classof(const Stmt *T) {
4453 return T->getStmtClass() == ConditionalOperatorClass ||
4454 T->getStmtClass() == BinaryConditionalOperatorClass;
4455 }
4456};
4457
4458/// ConditionalOperator - The ?: ternary operator. The GNU "missing
4459/// middle" extension is a BinaryConditionalOperator.
4461 enum { COND, LHS, RHS, END_EXPR };
4462 Stmt* SubExprs[END_EXPR]; // Left/Middle/Right hand sides.
4463
4464 friend class ASTStmtReader;
4465public:
4467 SourceLocation CLoc, Expr *rhs, QualType t,
4469 : AbstractConditionalOperator(ConditionalOperatorClass, t, VK, OK, QLoc,
4470 CLoc) {
4471 SubExprs[COND] = cond;
4472 SubExprs[LHS] = lhs;
4473 SubExprs[RHS] = rhs;
4475 }
4476
4477 /// Build an empty conditional operator.
4479 : AbstractConditionalOperator(ConditionalOperatorClass, Empty) { }
4480
4481 /// getCond - Return the expression representing the condition for
4482 /// the ?: operator.
4483 Expr *getCond() const { return cast<Expr>(SubExprs[COND]); }
4484
4485 /// getTrueExpr - Return the subexpression representing the value of
4486 /// the expression if the condition evaluates to true.
4487 Expr *getTrueExpr() const { return cast<Expr>(SubExprs[LHS]); }
4488
4489 /// getFalseExpr - Return the subexpression representing the value of
4490 /// the expression if the condition evaluates to false. This is
4491 /// the same as getRHS.
4492 Expr *getFalseExpr() const { return cast<Expr>(SubExprs[RHS]); }
4493
4494 Expr *getLHS() const { return cast<Expr>(SubExprs[LHS]); }
4495 Expr *getRHS() const { return cast<Expr>(SubExprs[RHS]); }
4496
4497 SourceLocation getBeginLoc() const LLVM_READONLY {
4498 return getCond()->getBeginLoc();
4499 }
4500 SourceLocation getEndLoc() const LLVM_READONLY {
4501 return getRHS()->getEndLoc();
4502 }
4503
4504 static bool classof(const Stmt *T) {
4505 return T->getStmtClass() == ConditionalOperatorClass;
4506 }
4507
4508 // Iterators
4510 return child_range(&SubExprs[0], &SubExprs[0]+END_EXPR);
4511 }
4513 return const_child_range(&SubExprs[0], &SubExprs[0] + END_EXPR);
4514 }
4515};
4516
4517/// BinaryConditionalOperator - The GNU extension to the conditional
4518/// operator which allows the middle operand to be omitted.
4519///
4520/// This is a different expression kind on the assumption that almost
4521/// every client ends up needing to know that these are different.
4523 enum { COMMON, COND, LHS, RHS, NUM_SUBEXPRS };
4524
4525 /// - the common condition/left-hand-side expression, which will be
4526 /// evaluated as the opaque value
4527 /// - the condition, expressed in terms of the opaque value
4528 /// - the left-hand-side, expressed in terms of the opaque value
4529 /// - the right-hand-side
4530 Stmt *SubExprs[NUM_SUBEXPRS];
4531 OpaqueValueExpr *OpaqueValue;
4532
4533 friend class ASTStmtReader;
4534public:
4536 Expr *cond, Expr *lhs, Expr *rhs,
4537 SourceLocation qloc, SourceLocation cloc,
4539 : AbstractConditionalOperator(BinaryConditionalOperatorClass, t, VK, OK,
4540 qloc, cloc),
4541 OpaqueValue(opaqueValue) {
4542 SubExprs[COMMON] = common;
4543 SubExprs[COND] = cond;
4544 SubExprs[LHS] = lhs;
4545 SubExprs[RHS] = rhs;
4546 assert(OpaqueValue->getSourceExpr() == common && "Wrong opaque value");
4548 }
4549
4550 /// Build an empty conditional operator.
4552 : AbstractConditionalOperator(BinaryConditionalOperatorClass, Empty) { }
4553
4554 /// getCommon - Return the common expression, written to the
4555 /// left of the condition. The opaque value will be bound to the
4556 /// result of this expression.
4557 Expr *getCommon() const { return cast<Expr>(SubExprs[COMMON]); }
4558
4559 /// getOpaqueValue - Return the opaque value placeholder.
4560 OpaqueValueExpr *getOpaqueValue() const { return OpaqueValue; }
4561
4562 /// getCond - Return the condition expression; this is defined
4563 /// in terms of the opaque value.
4564 Expr *getCond() const { return cast<Expr>(SubExprs[COND]); }
4565
4566 /// getTrueExpr - Return the subexpression which will be
4567 /// evaluated if the condition evaluates to true; this is defined
4568 /// in terms of the opaque value.
4570 return cast<Expr>(SubExprs[LHS]);
4571 }
4572
4573 /// getFalseExpr - Return the subexpression which will be
4574 /// evaluated if the condition evaluates to false; this is
4575 /// defined in terms of the opaque value.
4577 return cast<Expr>(SubExprs[RHS]);
4578 }
4579
4580 SourceLocation getBeginLoc() const LLVM_READONLY {
4581 return getCommon()->getBeginLoc();
4582 }
4583 SourceLocation getEndLoc() const LLVM_READONLY {
4584 return getFalseExpr()->getEndLoc();
4585 }
4586
4587 static bool classof(const Stmt *T) {
4588 return T->getStmtClass() == BinaryConditionalOperatorClass;
4589 }
4590
4591 // Iterators
4593 return child_range(SubExprs, SubExprs + NUM_SUBEXPRS);
4594 }
4596 return const_child_range(SubExprs, SubExprs + NUM_SUBEXPRS);
4597 }
4598};
4599
4601 if (const ConditionalOperator *co = dyn_cast<ConditionalOperator>(this))
4602 return co->getCond();
4603 return cast<BinaryConditionalOperator>(this)->getCond();
4604}
4605
4607 if (const ConditionalOperator *co = dyn_cast<ConditionalOperator>(this))
4608 return co->getTrueExpr();
4609 return cast<BinaryConditionalOperator>(this)->getTrueExpr();
4610}
4611
4613 if (const ConditionalOperator *co = dyn_cast<ConditionalOperator>(this))
4614 return co->getFalseExpr();
4615 return cast<BinaryConditionalOperator>(this)->getFalseExpr();
4616}
4617
4618/// AddrLabelExpr - The GNU address of label extension, representing &&label.
4619class AddrLabelExpr : public Expr {
4620 SourceLocation AmpAmpLoc, LabelLoc;
4621 LabelDecl *Label;
4622public:
4624 QualType t)
4625 : Expr(AddrLabelExprClass, t, VK_PRValue, OK_Ordinary), AmpAmpLoc(AALoc),
4626 LabelLoc(LLoc), Label(L) {
4627 setDependence(ExprDependence::None);
4628 }
4629
4630 /// Build an empty address of a label expression.
4632 : Expr(AddrLabelExprClass, Empty) { }
4633
4634 SourceLocation getAmpAmpLoc() const { return AmpAmpLoc; }
4635 void setAmpAmpLoc(SourceLocation L) { AmpAmpLoc = L; }
4636 SourceLocation getLabelLoc() const { return LabelLoc; }
4637 void setLabelLoc(SourceLocation L) { LabelLoc = L; }
4638
4639 SourceLocation getBeginLoc() const LLVM_READONLY { return AmpAmpLoc; }
4640 SourceLocation getEndLoc() const LLVM_READONLY { return LabelLoc; }
4641
4642 LabelDecl *getLabel() const { return Label; }
4643 void setLabel(LabelDecl *L) { Label = L; }
4644
4645 static bool classof(const Stmt *T) {
4646 return T->getStmtClass() == AddrLabelExprClass;
4647 }
4648
4649 // Iterators
4656};
4657
4658/// StmtExpr - This is the GNU Statement Expression extension: ({int X=4; X;}).
4659/// The StmtExpr contains a single CompoundStmt node, which it evaluates and
4660/// takes the value of the last subexpression.
4661///
4662/// A StmtExpr is always an r-value; values "returned" out of a
4663/// StmtExpr will be copied.
4664class StmtExpr : public Expr {
4665 Stmt *SubStmt;
4666 SourceLocation LParenLoc, RParenLoc;
4667public:
4669 SourceLocation RParenLoc, unsigned TemplateDepth)
4670 : Expr(StmtExprClass, T, VK_PRValue, OK_Ordinary), SubStmt(SubStmt),
4671 LParenLoc(LParenLoc), RParenLoc(RParenLoc) {
4672 setDependence(computeDependence(this, TemplateDepth));
4673 // FIXME: A templated statement expression should have an associated
4674 // DeclContext so that nested declarations always have a dependent context.
4675 StmtExprBits.TemplateDepth = TemplateDepth;
4676 }
4677
4678 /// Build an empty statement expression.
4679 explicit StmtExpr(EmptyShell Empty) : Expr(StmtExprClass, Empty) { }
4680
4682 const CompoundStmt *getSubStmt() const { return cast<CompoundStmt>(SubStmt); }
4683 void setSubStmt(CompoundStmt *S) { SubStmt = S; }
4684
4685 SourceLocation getBeginLoc() const LLVM_READONLY { return LParenLoc; }
4686 SourceLocation getEndLoc() const LLVM_READONLY { return RParenLoc; }
4687
4688 SourceLocation getLParenLoc() const { return LParenLoc; }
4689 void setLParenLoc(SourceLocation L) { LParenLoc = L; }
4690 SourceLocation getRParenLoc() const { return RParenLoc; }
4691 void setRParenLoc(SourceLocation L) { RParenLoc = L; }
4692
4693 unsigned getTemplateDepth() const { return StmtExprBits.TemplateDepth; }
4694
4695 static bool classof(const Stmt *T) {
4696 return T->getStmtClass() == StmtExprClass;
4697 }
4698
4699 // Iterators
4700 child_range children() { return child_range(&SubStmt, &SubStmt+1); }
4702 return const_child_range(&SubStmt, &SubStmt + 1);
4703 }
4704};
4705
4706/// ShuffleVectorExpr - clang-specific builtin-in function
4707/// __builtin_shufflevector.
4708/// This AST node represents a operator that does a constant
4709/// shuffle, similar to LLVM's shufflevector instruction. It takes
4710/// two vectors and a variable number of constant indices,
4711/// and returns the appropriately shuffled vector.
4712class ShuffleVectorExpr : public Expr {
4713 SourceLocation BuiltinLoc, RParenLoc;
4714
4715 // SubExprs - the list of values passed to the __builtin_shufflevector
4716 // function. The first two are vectors, and the rest are constant
4717 // indices. The number of values in this list is always
4718 // 2+the number of indices in the vector type.
4719 Stmt **SubExprs;
4720
4721public:
4724
4725 /// Build an empty vector-shuffle expression.
4727 : Expr(ShuffleVectorExprClass, Empty), SubExprs(nullptr) { }
4728
4729 SourceLocation getBuiltinLoc() const { return BuiltinLoc; }
4730 void setBuiltinLoc(SourceLocation L) { BuiltinLoc = L; }
4731
4732 SourceLocation getRParenLoc() const { return RParenLoc; }
4733 void setRParenLoc(SourceLocation L) { RParenLoc = L; }
4734
4735 SourceLocation getBeginLoc() const LLVM_READONLY { return BuiltinLoc; }
4736 SourceLocation getEndLoc() const LLVM_READONLY { return RParenLoc; }
4737
4738 static bool classof(const Stmt *T) {
4739 return T->getStmtClass() == ShuffleVectorExprClass;
4740 }
4741
4742 /// getNumSubExprs - Return the size of the SubExprs array. This includes the
4743 /// constant expression, the actual arguments passed in, and the function
4744 /// pointers.
4745 unsigned getNumSubExprs() const { return ShuffleVectorExprBits.NumExprs; }
4746
4747 /// Retrieve the array of expressions.
4748 Expr **getSubExprs() { return reinterpret_cast<Expr **>(SubExprs); }
4749
4750 /// getExpr - Return the Expr at the specified index.
4751 Expr *getExpr(unsigned Index) {
4752 assert((Index < ShuffleVectorExprBits.NumExprs) &&
4753 "Arg access out of range!");
4754 return cast<Expr>(SubExprs[Index]);
4755 }
4756 const Expr *getExpr(unsigned Index) const {
4757 assert((Index < ShuffleVectorExprBits.NumExprs) &&
4758 "Arg access out of range!");
4759 return cast<Expr>(SubExprs[Index]);
4760 }
4761
4762 void setExprs(const ASTContext &C, ArrayRef<Expr *> Exprs);
4763
4764 llvm::APSInt getShuffleMaskIdx(unsigned N) const {
4765 assert((N < ShuffleVectorExprBits.NumExprs - 2) &&
4766 "Shuffle idx out of range!");
4767 assert(isa<ConstantExpr>(getExpr(N + 2)) &&
4768 "Index expression must be a ConstantExpr");
4769 return cast<ConstantExpr>(getExpr(N + 2))->getAPValueResult().getInt();
4770 }
4771
4772 // Iterators
4774 return child_range(&SubExprs[0],
4775 &SubExprs[0] + ShuffleVectorExprBits.NumExprs);
4776 }
4778 return const_child_range(&SubExprs[0],
4779 &SubExprs[0] + ShuffleVectorExprBits.NumExprs);
4780 }
4781};
4782
4783/// ConvertVectorExpr - Clang builtin function __builtin_convertvector
4784/// This AST node provides support for converting a vector type to another
4785/// vector type of the same arity.
4786class ConvertVectorExpr final
4787 : public Expr,
4788 private llvm::TrailingObjects<ConvertVectorExpr, FPOptionsOverride> {
4789private:
4790 Stmt *SrcExpr;
4791 TypeSourceInfo *TInfo;
4792 SourceLocation BuiltinLoc, RParenLoc;
4793
4794 friend TrailingObjects;
4795 friend class ASTReader;
4796 friend class ASTStmtReader;
4797 explicit ConvertVectorExpr(bool HasFPFeatures, EmptyShell Empty)
4798 : Expr(ConvertVectorExprClass, Empty) {
4799 ConvertVectorExprBits.HasFPFeatures = HasFPFeatures;
4800 }
4801
4802 ConvertVectorExpr(Expr *SrcExpr, TypeSourceInfo *TI, QualType DstType,
4804 SourceLocation BuiltinLoc, SourceLocation RParenLoc,
4805 FPOptionsOverride FPFeatures)
4806 : Expr(ConvertVectorExprClass, DstType, VK, OK), SrcExpr(SrcExpr),
4807 TInfo(TI), BuiltinLoc(BuiltinLoc), RParenLoc(RParenLoc) {
4808 ConvertVectorExprBits.HasFPFeatures = FPFeatures.requiresTrailingStorage();
4809 if (hasStoredFPFeatures())
4810 setStoredFPFeatures(FPFeatures);
4812 }
4813
4814 size_t numTrailingObjects(OverloadToken<FPOptionsOverride>) const {
4815 return ConvertVectorExprBits.HasFPFeatures ? 1 : 0;
4816 }
4817
4818 FPOptionsOverride &getTrailingFPFeatures() {
4819 assert(ConvertVectorExprBits.HasFPFeatures);
4820 return *getTrailingObjects();
4821 }
4822
4823 const FPOptionsOverride &getTrailingFPFeatures() const {
4824 assert(ConvertVectorExprBits.HasFPFeatures);
4825 return *getTrailingObjects();
4826 }
4827
4828public:
4829 static ConvertVectorExpr *CreateEmpty(const ASTContext &C,
4830 bool hasFPFeatures);
4831
4832 static ConvertVectorExpr *Create(const ASTContext &C, Expr *SrcExpr,
4833 TypeSourceInfo *TI, QualType DstType,
4835 SourceLocation BuiltinLoc,
4836 SourceLocation RParenLoc,
4837 FPOptionsOverride FPFeatures);
4838
4839 /// Get the FP contractibility status of this operator. Only meaningful for
4840 /// operations on floating point types.
4844
4845 /// Is FPFeatures in Trailing Storage?
4846 bool hasStoredFPFeatures() const {
4847 return ConvertVectorExprBits.HasFPFeatures;
4848 }
4849
4850 /// Get FPFeatures from trailing storage.
4852 return getTrailingFPFeatures();
4853 }
4854
4855 /// Get the store FPOptionsOverride or default if not stored.
4859
4860 /// Set FPFeatures in trailing storage, used by Serialization & ASTImporter.
4861 void setStoredFPFeatures(FPOptionsOverride F) { getTrailingFPFeatures() = F; }
4862
4863 /// Get the FP features status of this operator. Only meaningful for
4864 /// operations on floating point types.
4866 if (ConvertVectorExprBits.HasFPFeatures)
4869 }
4870
4872 if (ConvertVectorExprBits.HasFPFeatures)
4873 return getStoredFPFeatures();
4874 return FPOptionsOverride();
4875 }
4876
4877 /// getSrcExpr - Return the Expr to be converted.
4878 Expr *getSrcExpr() const { return cast<Expr>(SrcExpr); }
4879
4880 /// getTypeSourceInfo - Return the destination type.
4882 return TInfo;
4883 }
4885 TInfo = ti;
4886 }
4887
4888 /// getBuiltinLoc - Return the location of the __builtin_convertvector token.
4889 SourceLocation getBuiltinLoc() const { return BuiltinLoc; }
4890
4891 /// getRParenLoc - Return the location of final right parenthesis.
4892 SourceLocation getRParenLoc() const { return RParenLoc; }
4893
4894 SourceLocation getBeginLoc() const LLVM_READONLY { return BuiltinLoc; }
4895 SourceLocation getEndLoc() const LLVM_READONLY { return RParenLoc; }
4896
4897 static bool classof(const Stmt *T) {
4898 return T->getStmtClass() == ConvertVectorExprClass;
4899 }
4900
4901 // Iterators
4902 child_range children() { return child_range(&SrcExpr, &SrcExpr+1); }
4904 return const_child_range(&SrcExpr, &SrcExpr + 1);
4905 }
4906};
4907
4908/// ChooseExpr - GNU builtin-in function __builtin_choose_expr.
4909/// This AST node is similar to the conditional operator (?:) in C, with
4910/// the following exceptions:
4911/// - the test expression must be a integer constant expression.
4912/// - the expression returned acts like the chosen subexpression in every
4913/// visible way: the type is the same as that of the chosen subexpression,
4914/// and all predicates (whether it's an l-value, whether it's an integer
4915/// constant expression, etc.) return the same result as for the chosen
4916/// sub-expression.
4917class ChooseExpr : public Expr {
4918 enum { COND, LHS, RHS, END_EXPR };
4919 Stmt* SubExprs[END_EXPR]; // Left/Middle/Right hand sides.
4920 SourceLocation BuiltinLoc, RParenLoc;
4921
4922public:
4923 ChooseExpr(SourceLocation BLoc, Expr *cond, Expr *lhs, Expr *rhs, QualType t,
4925 bool condIsTrue)
4926 : Expr(ChooseExprClass, t, VK, OK), BuiltinLoc(BLoc), RParenLoc(RP) {
4927 ChooseExprBits.CondIsTrue = condIsTrue;
4928 SubExprs[COND] = cond;
4929 SubExprs[LHS] = lhs;
4930 SubExprs[RHS] = rhs;
4931
4933 }
4934
4935 /// Build an empty __builtin_choose_expr.
4936 explicit ChooseExpr(EmptyShell Empty) : Expr(ChooseExprClass, Empty) { }
4937
4938 /// isConditionTrue - Return whether the condition is true (i.e. not
4939 /// equal to zero).
4940 bool isConditionTrue() const {
4941 assert(!isConditionDependent() &&
4942 "Dependent condition isn't true or false");
4943 return ChooseExprBits.CondIsTrue;
4944 }
4945 void setIsConditionTrue(bool isTrue) { ChooseExprBits.CondIsTrue = isTrue; }
4946
4948 return getCond()->isTypeDependent() || getCond()->isValueDependent();
4949 }
4950
4951 /// getChosenSubExpr - Return the subexpression chosen according to the
4952 /// condition.
4954 return isConditionTrue() ? getLHS() : getRHS();
4955 }
4956
4957 Expr *getCond() const { return cast<Expr>(SubExprs[COND]); }
4958 void setCond(Expr *E) { SubExprs[COND] = E; }
4959 Expr *getLHS() const { return cast<Expr>(SubExprs[LHS]); }
4960 void setLHS(Expr *E) { SubExprs[LHS] = E; }
4961 Expr *getRHS() const { return cast<Expr>(SubExprs[RHS]); }
4962 void setRHS(Expr *E) { SubExprs[RHS] = E; }
4963
4964 SourceLocation getBuiltinLoc() const { return BuiltinLoc; }
4965 void setBuiltinLoc(SourceLocation L) { BuiltinLoc = L; }
4966
4967 SourceLocation getRParenLoc() const { return RParenLoc; }
4968 void setRParenLoc(SourceLocation L) { RParenLoc = L; }
4969
4970 SourceLocation getBeginLoc() const LLVM_READONLY { return BuiltinLoc; }
4971 SourceLocation getEndLoc() const LLVM_READONLY { return RParenLoc; }
4972
4973 static bool classof(const Stmt *T) {
4974 return T->getStmtClass() == ChooseExprClass;
4975 }
4976
4977 // Iterators
4979 return child_range(&SubExprs[0], &SubExprs[0]+END_EXPR);
4980 }
4982 return const_child_range(&SubExprs[0], &SubExprs[0] + END_EXPR);
4983 }
4984};
4985
4986/// GNUNullExpr - Implements the GNU __null extension, which is a name
4987/// for a null pointer constant that has integral type (e.g., int or
4988/// long) and is the same size and alignment as a pointer. The __null
4989/// extension is typically only used by system headers, which define
4990/// NULL as __null in C++ rather than using 0 (which is an integer
4991/// that may not match the size of a pointer).
4992class GNUNullExpr : public Expr {
4993 /// TokenLoc - The location of the __null keyword.
4994 SourceLocation TokenLoc;
4995
4996public:
4998 : Expr(GNUNullExprClass, Ty, VK_PRValue, OK_Ordinary), TokenLoc(Loc) {
4999 setDependence(ExprDependence::None);
5000 }
5001
5002 /// Build an empty GNU __null expression.
5003 explicit GNUNullExpr(EmptyShell Empty) : Expr(GNUNullExprClass, Empty) { }
5004
5005 /// getTokenLocation - The location of the __null token.
5006 SourceLocation getTokenLocation() const { return TokenLoc; }
5007 void setTokenLocation(SourceLocation L) { TokenLoc = L; }
5008
5009 SourceLocation getBeginLoc() const LLVM_READONLY { return TokenLoc; }
5010 SourceLocation getEndLoc() const LLVM_READONLY { return TokenLoc; }
5011
5012 static bool classof(const Stmt *T) {
5013 return T->getStmtClass() == GNUNullExprClass;
5014 }
5015
5016 // Iterators
5023};
5024
5025/// Represents a call to the builtin function \c __builtin_va_arg.
5026class VAArgExpr : public Expr {
5027public:
5029
5030private:
5031 Stmt *Val;
5032 llvm::PointerIntPair<TypeSourceInfo *, 2, VarArgKind> TInfo;
5033 SourceLocation BuiltinLoc, RParenLoc;
5034public:
5036 SourceLocation RPLoc, QualType t, VarArgKind VaKind)
5037 : Expr(VAArgExprClass, t, VK_PRValue, OK_Ordinary), Val(e),
5038 TInfo(TInfo, VaKind), BuiltinLoc(BLoc), RParenLoc(RPLoc) {
5040 }
5041
5042 /// Create an empty __builtin_va_arg expression.
5044 : Expr(VAArgExprClass, Empty), Val(nullptr), TInfo(nullptr, VA_Std) {}
5045
5046 const Expr *getSubExpr() const { return cast<Expr>(Val); }
5047 Expr *getSubExpr() { return cast<Expr>(Val); }
5048 void setSubExpr(Expr *E) { Val = E; }
5049
5050 VarArgKind getVarargABI() const { return TInfo.getInt(); }
5051 void setVarargABI(VarArgKind Kind) { TInfo.setInt(Kind); }
5052
5053 /// Returns whether this is really a Win64 ABI va_arg expression.
5054 bool isMicrosoftABI() const { return TInfo.getInt() == VA_MS; }
5055
5056 /// Returns whether this is really a z/OS ABI va_arg expression.
5057 bool isZOSABI() const { return TInfo.getInt() == VA_ZOS; }
5058
5059 TypeSourceInfo *getWrittenTypeInfo() const { return TInfo.getPointer(); }
5060 void setWrittenTypeInfo(TypeSourceInfo *TI) { TInfo.setPointer(TI); }
5061
5062 SourceLocation getBuiltinLoc() const { return BuiltinLoc; }
5063 void setBuiltinLoc(SourceLocation L) { BuiltinLoc = L; }
5064
5065 SourceLocation getRParenLoc() const { return RParenLoc; }
5066 void setRParenLoc(SourceLocation L) { RParenLoc = L; }
5067
5068 SourceLocation getBeginLoc() const LLVM_READONLY { return BuiltinLoc; }
5069 SourceLocation getEndLoc() const LLVM_READONLY { return RParenLoc; }
5070
5071 static bool classof(const Stmt *T) {
5072 return T->getStmtClass() == VAArgExprClass;
5073 }
5074
5075 // Iterators
5076 child_range children() { return child_range(&Val, &Val+1); }
5078 return const_child_range(&Val, &Val + 1);
5079 }
5080};
5081
5091
5092/// Represents a function call to one of __builtin_LINE(), __builtin_COLUMN(),
5093/// __builtin_FUNCTION(), __builtin_FUNCSIG(), __builtin_FILE(),
5094/// __builtin_FILE_NAME() or __builtin_source_location().
5095class SourceLocExpr final : public Expr {
5096 SourceLocation BuiltinLoc, RParenLoc;
5097 DeclContext *ParentContext;
5098
5099public:
5101 QualType ResultTy, SourceLocation BLoc,
5102 SourceLocation RParenLoc, DeclContext *Context);
5103
5104 /// Build an empty call expression.
5105 explicit SourceLocExpr(EmptyShell Empty) : Expr(SourceLocExprClass, Empty) {}
5106
5107 /// Return the result of evaluating this SourceLocExpr in the specified
5108 /// (and possibly null) default argument or initialization context.
5110 const Expr *DefaultExpr) const;
5111
5112 /// Return a string representing the name of the specific builtin function.
5113 StringRef getBuiltinStr() const;
5114
5116 return static_cast<SourceLocIdentKind>(SourceLocExprBits.Kind);
5117 }
5118
5119 bool isIntType() const {
5120 switch (getIdentKind()) {
5126 return false;
5129 return true;
5130 }
5131 llvm_unreachable("unknown source location expression kind");
5132 }
5133
5134 /// If the SourceLocExpr has been resolved return the subexpression
5135 /// representing the resolved value. Otherwise return null.
5136 const DeclContext *getParentContext() const { return ParentContext; }
5137 DeclContext *getParentContext() { return ParentContext; }
5138
5139 SourceLocation getLocation() const { return BuiltinLoc; }
5140 SourceLocation getBeginLoc() const { return BuiltinLoc; }
5141 SourceLocation getEndLoc() const { return RParenLoc; }
5142
5146
5150
5151 static bool classof(const Stmt *T) {
5152 return T->getStmtClass() == SourceLocExprClass;
5153 }
5154
5156 switch (Kind) {
5160 return true;
5161 default:
5162 return false;
5163 }
5164 }
5165
5166private:
5167 friend class ASTStmtReader;
5168};
5169
5170/// Stores data related to a single #embed directive.
5173 // FileName string already includes braces, i.e. it is <files/my_file> for a
5174 // directive #embed <files/my_file>.
5175 StringRef FileName;
5176 size_t getDataElementCount() const { return BinaryData->getByteLength(); }
5177};
5178
5179/// Represents a reference to #emded data. By default, this references the whole
5180/// range. Otherwise it represents a subrange of data imported by #embed
5181/// directive. Needed to handle nested initializer lists with #embed directives.
5182/// Example:
5183/// struct S {
5184/// int x, y;
5185/// };
5186///
5187/// struct T {
5188/// int x[2];
5189/// struct S s
5190/// };
5191///
5192/// struct T t[] = {
5193/// #embed "data" // data contains 10 elements;
5194/// };
5195///
5196/// The resulting semantic form of initializer list will contain (EE stands
5197/// for EmbedExpr):
5198/// { {EE(first two data elements), {EE(3rd element), EE(4th element) }},
5199/// { {EE(5th and 6th element), {EE(7th element), EE(8th element) }},
5200/// { {EE(9th and 10th element), { zeroinitializer }}}
5201///
5202/// EmbedExpr inside of a semantic initializer list and referencing more than
5203/// one element can only appear for arrays of integer or floating-point type.
5204class EmbedExpr final : public Expr {
5205 SourceLocation EmbedKeywordLoc;
5206 IntegerLiteral *FakeChildNode = nullptr;
5207 const ASTContext *Ctx = nullptr;
5208 EmbedDataStorage *Data;
5209 unsigned Begin = 0;
5210 unsigned NumOfElements;
5211
5212public:
5213 EmbedExpr(const ASTContext &Ctx, SourceLocation Loc, EmbedDataStorage *Data,
5214 unsigned Begin, unsigned NumOfElements);
5215 explicit EmbedExpr(EmptyShell Empty) : Expr(EmbedExprClass, Empty) {}
5216
5217 SourceLocation getLocation() const { return EmbedKeywordLoc; }
5218 SourceLocation getBeginLoc() const { return EmbedKeywordLoc; }
5219 SourceLocation getEndLoc() const { return EmbedKeywordLoc; }
5220
5221 StringLiteral *getDataStringLiteral() const { return Data->BinaryData; }
5222 StringRef getFileName() const { return Data->FileName; }
5223 EmbedDataStorage *getData() const { return Data; }
5224
5225 unsigned getStartingElementPos() const { return Begin; }
5226 size_t getDataElementCount() const { return NumOfElements; }
5227
5228 // Allows accessing every byte of EmbedExpr data and iterating over it.
5229 // An Iterator knows the EmbedExpr that it refers to, and an offset value
5230 // within the data.
5231 // Dereferencing an Iterator results in construction of IntegerLiteral AST
5232 // node filled with byte of data of the corresponding EmbedExpr within offset
5233 // that the Iterator currently has.
5234 template <bool Const>
5235 class ChildElementIter
5236 : public llvm::iterator_facade_base<
5237 ChildElementIter<Const>, std::random_access_iterator_tag,
5238 std::conditional_t<Const, const IntegerLiteral *,
5239 IntegerLiteral *>> {
5240 friend class EmbedExpr;
5241
5242 EmbedExpr *EExpr = nullptr;
5243 unsigned long long CurOffset = ULLONG_MAX;
5244 using BaseTy = typename ChildElementIter::iterator_facade_base;
5245
5246 ChildElementIter(EmbedExpr *E) : EExpr(E) {
5247 if (E)
5248 CurOffset = E->getStartingElementPos();
5249 }
5250
5251 public:
5252 ChildElementIter() : CurOffset(ULLONG_MAX) {}
5253 typename BaseTy::reference operator*() const {
5254 assert(EExpr && CurOffset != ULLONG_MAX &&
5255 "trying to dereference an invalid iterator");
5256 IntegerLiteral *N = EExpr->FakeChildNode;
5257 N->setValue(*EExpr->Ctx,
5258 llvm::APInt(N->getBitWidth(),
5259 EExpr->Data->BinaryData->getCodeUnit(CurOffset),
5260 /*Signed=*/true));
5261 // We want to return a reference to the fake child node in the
5262 // EmbedExpr, not the local variable N.
5263 return const_cast<typename BaseTy::reference>(EExpr->FakeChildNode);
5264 }
5265 typename BaseTy::pointer operator->() const { return **this; }
5266 using BaseTy::operator++;
5267 ChildElementIter &operator++() {
5268 assert(EExpr && "trying to increment an invalid iterator");
5269 assert(CurOffset != ULLONG_MAX &&
5270 "Already at the end of what we can iterate over");
5271 if (++CurOffset >=
5272 EExpr->getDataElementCount() + EExpr->getStartingElementPos()) {
5273 CurOffset = ULLONG_MAX;
5274 EExpr = nullptr;
5275 }
5276 return *this;
5277 }
5278 bool operator==(ChildElementIter Other) const {
5279 return (EExpr == Other.EExpr && CurOffset == Other.CurOffset);
5280 }
5281 }; // class ChildElementIter
5282
5283public:
5284 using fake_child_range = llvm::iterator_range<ChildElementIter<false>>;
5285 using const_fake_child_range = llvm::iterator_range<ChildElementIter<true>>;
5286
5291
5297
5301
5305
5306 static bool classof(const Stmt *T) {
5307 return T->getStmtClass() == EmbedExprClass;
5308 }
5309
5311
5313 return ChildElementIter<true>(const_cast<EmbedExpr *>(this));
5314 }
5315
5316 template <typename Call, typename... Targs>
5317 bool doForEachDataElement(Call &&C, unsigned &StartingIndexInArray,
5318 Targs &&...Fargs) const {
5319 for (auto It : underlying_data_elements()) {
5320 if (!std::invoke(std::forward<Call>(C), const_cast<IntegerLiteral *>(It),
5321 StartingIndexInArray, std::forward<Targs>(Fargs)...))
5322 return false;
5323 StartingIndexInArray++;
5324 }
5325 return true;
5326 }
5327
5328private:
5329 friend class ASTStmtReader;
5330};
5331
5332/// Describes an C or C++ initializer list.
5333///
5334/// InitListExpr describes an initializer list, which can be used to
5335/// initialize objects of different types, including
5336/// struct/class/union types, arrays, and vectors. For example:
5337///
5338/// @code
5339/// struct foo x = { 1, { 2, 3 } };
5340/// @endcode
5341///
5342/// Prior to semantic analysis, an initializer list will represent the
5343/// initializer list as written by the user, but will have the
5344/// placeholder type "void". This initializer list is called the
5345/// syntactic form of the initializer, and may contain C99 designated
5346/// initializers (represented as DesignatedInitExprs), initializations
5347/// of subobject members without explicit braces, and so on. Clients
5348/// interested in the original syntax of the initializer list should
5349/// use the syntactic form of the initializer list.
5350///
5351/// After semantic analysis, the initializer list will represent the
5352/// semantic form of the initializer, where the initializations of all
5353/// subobjects are made explicit with nested InitListExpr nodes and
5354/// C99 designators have been eliminated by placing the designated
5355/// initializations into the subobject they initialize. Additionally,
5356/// any "holes" in the initialization, where no initializer has been
5357/// specified for a particular subobject, will be replaced with
5358/// implicitly-generated ImplicitValueInitExpr expressions that
5359/// value-initialize the subobjects. Note, however, that the
5360/// initializer lists may still have fewer initializers than there are
5361/// elements to initialize within the object.
5362///
5363/// After semantic analysis has completed, given an initializer list,
5364/// method isSemanticForm() returns true if and only if this is the
5365/// semantic form of the initializer list (note: the same AST node
5366/// may at the same time be the syntactic form).
5367/// Given the semantic form of the initializer list, one can retrieve
5368/// the syntactic form of that initializer list (when different)
5369/// using method getSyntacticForm(); the method returns null if applied
5370/// to a initializer list which is already in syntactic form.
5371/// Similarly, given the syntactic form (i.e., an initializer list such
5372/// that isSemanticForm() returns false), one can retrieve the semantic
5373/// form using method getSemanticForm().
5374/// Since many initializer lists have the same syntactic and semantic forms,
5375/// getSyntacticForm() may return NULL, indicating that the current
5376/// semantic initializer list also serves as its syntactic form.
5377class InitListExpr : public Expr {
5378 // FIXME: Eliminate this vector in favor of ASTContext allocation
5379 typedef ASTVector<Stmt *> InitExprsTy;
5380 InitExprsTy InitExprs;
5381 SourceLocation LBraceLoc, RBraceLoc;
5382
5383 /// The alternative form of the initializer list (if it exists).
5384 /// The int part of the pair stores whether this initializer list is
5385 /// in semantic form. If not null, the pointer points to:
5386 /// - the syntactic form, if this is in semantic form;
5387 /// - the semantic form, if this is in syntactic form.
5388 llvm::PointerIntPair<InitListExpr *, 1, bool> AltForm;
5389
5390 /// Either:
5391 /// If this initializer list initializes an array with more elements than
5392 /// there are initializers in the list, specifies an expression to be used
5393 /// for value initialization of the rest of the elements.
5394 /// Or
5395 /// If this initializer list initializes a union, specifies which
5396 /// field within the union will be initialized.
5397 llvm::PointerUnion<Expr *, FieldDecl *> ArrayFillerOrUnionFieldInit;
5398
5399public:
5400 InitListExpr(const ASTContext &C, SourceLocation lbraceloc,
5401 ArrayRef<Expr *> initExprs, SourceLocation rbraceloc,
5402 bool isExplicit);
5403
5404 /// Build an empty initializer list.
5406 : Expr(InitListExprClass, Empty), AltForm(nullptr, true) {
5407 InitListExprBits.IsExplicit = false;
5408 }
5409
5410 unsigned getNumInits() const { return InitExprs.size(); }
5411
5412 /// getNumInits but if the list has an EmbedExpr inside includes full length
5413 /// of embedded data.
5415 unsigned Sum = InitExprs.size();
5416 for (auto *IE : InitExprs)
5417 if (auto *EE = dyn_cast<EmbedExpr>(cast<Expr>(IE)->IgnoreParenImpCasts()))
5418 Sum += EE->getDataElementCount() - 1;
5419 return Sum;
5420 }
5421
5422 bool hasZeroInits() const { return InitExprs.empty(); }
5423
5424 /// Whether getNumInitsWithEmbedExpanded() is 1, without walking the list.
5425 bool hasOneInit() const {
5426 if (InitExprs.size() != 1)
5427 return false;
5428 auto *EE =
5429 dyn_cast<EmbedExpr>(cast<Expr>(InitExprs[0])->IgnoreParenImpCasts());
5430 return !EE || EE->getDataElementCount() == 1;
5431 }
5432
5433 /// Retrieve the set of initializers.
5434 Expr **getInits() { return reinterpret_cast<Expr **>(InitExprs.data()); }
5435
5436 /// Retrieve the set of initializers.
5437 Expr * const *getInits() const {
5438 return reinterpret_cast<Expr * const *>(InitExprs.data());
5439 }
5440
5441 ArrayRef<Expr *> inits() const { return {getInits(), getNumInits()}; }
5442
5443 const Expr *getInit(unsigned Init) const {
5444 assert(Init < getNumInits() && "Initializer access out of range!");
5445 return cast_or_null<Expr>(InitExprs[Init]);
5446 }
5447
5448 Expr *getInit(unsigned Init) {
5449 assert(Init < getNumInits() && "Initializer access out of range!");
5450 return cast_or_null<Expr>(InitExprs[Init]);
5451 }
5452
5453 void setInit(unsigned Init, Expr *expr) {
5454 assert(Init < getNumInits() && "Initializer access out of range!");
5455 InitExprs[Init] = expr;
5456
5457 if (expr)
5458 setDependence(getDependence() | expr->getDependence());
5459 }
5460
5461 /// Mark the semantic form of the InitListExpr as error when the semantic
5462 /// analysis fails.
5463 void markError() {
5464 assert(isSemanticForm());
5465 setDependence(getDependence() | ExprDependence::ErrorDependent);
5466 }
5467
5468 /// Reserve space for some number of initializers.
5469 void reserveInits(const ASTContext &C, unsigned NumInits);
5470
5471 /// Specify the number of initializers
5472 ///
5473 /// If there are more than @p NumInits initializers, the remaining
5474 /// initializers will be destroyed. If there are fewer than @p
5475 /// NumInits initializers, NULL expressions will be added for the
5476 /// unknown initializers.
5477 void resizeInits(const ASTContext &Context, unsigned NumInits);
5478
5479 /// Updates the initializer at index @p Init with the new
5480 /// expression @p expr, and returns the old expression at that
5481 /// location.
5482 ///
5483 /// When @p Init is out of range for this initializer list, the
5484 /// initializer list will be extended with NULL expressions to
5485 /// accommodate the new entry.
5486 Expr *updateInit(const ASTContext &C, unsigned Init, Expr *expr);
5487
5488 /// If this initializer list initializes an array with more elements
5489 /// than there are initializers in the list, specifies an expression to be
5490 /// used for value initialization of the rest of the elements.
5492 return dyn_cast_if_present<Expr *>(ArrayFillerOrUnionFieldInit);
5493 }
5494 const Expr *getArrayFiller() const {
5495 return const_cast<InitListExpr *>(this)->getArrayFiller();
5496 }
5497 void setArrayFiller(Expr *filler);
5498
5499 /// Return true if this is an array initializer and its array "filler"
5500 /// has been set.
5501 bool hasArrayFiller() const { return getArrayFiller(); }
5502
5503 /// Determine whether this initializer list contains a designated initializer.
5504 bool hasDesignatedInit() const {
5505 return llvm::any_of(
5506 *this, [](const Stmt *S) { return isa<DesignatedInitExpr>(S); });
5507 }
5508
5509 /// If this initializes a union, specifies which field in the
5510 /// union to initialize.
5511 ///
5512 /// Typically, this field is the first named field within the
5513 /// union. However, a designated initializer can specify the
5514 /// initialization of a different field within the union.
5516 return dyn_cast_if_present<FieldDecl *>(ArrayFillerOrUnionFieldInit);
5517 }
5519 return const_cast<InitListExpr *>(this)->getInitializedFieldInUnion();
5520 }
5522 assert((FD == nullptr
5523 || getInitializedFieldInUnion() == nullptr
5524 || getInitializedFieldInUnion() == FD)
5525 && "Only one field of a union may be initialized at a time!");
5526 ArrayFillerOrUnionFieldInit = FD;
5527 }
5528
5529 // Explicit InitListExpr's originate from source code (and have valid source
5530 // locations). Implicit InitListExpr's are created by the semantic analyzer.
5531 bool isExplicit() const { return InitListExprBits.IsExplicit; }
5532
5533 /// Is this an initializer for an array of characters, initialized by a string
5534 /// literal or an @encode?
5535 bool isStringLiteralInit() const;
5536
5537 /// Is this a transparent initializer list (that is, an InitListExpr that is
5538 /// purely syntactic, and whose semantics are that of the sole contained
5539 /// initializer)?
5540 bool isTransparent() const;
5541
5542 /// Is this the zero initializer {0} in a language which considers it
5543 /// idiomatic?
5544 bool isIdiomaticZeroInitializer(const LangOptions &LangOpts) const;
5545
5546 SourceLocation getLBraceLoc() const { return LBraceLoc; }
5547 void setLBraceLoc(SourceLocation Loc) { LBraceLoc = Loc; }
5548 SourceLocation getRBraceLoc() const { return RBraceLoc; }
5549 void setRBraceLoc(SourceLocation Loc) { RBraceLoc = Loc; }
5550
5551 bool isSemanticForm() const { return AltForm.getInt(); }
5553 return isSemanticForm() ? nullptr : AltForm.getPointer();
5554 }
5555 bool isSyntacticForm() const {
5556 return !AltForm.getInt() || !AltForm.getPointer();
5557 }
5559 return isSemanticForm() ? AltForm.getPointer() : nullptr;
5560 }
5561
5563 AltForm.setPointer(Init);
5564 AltForm.setInt(true);
5565 Init->AltForm.setPointer(this);
5566 Init->AltForm.setInt(false);
5567 }
5568
5570 return InitListExprBits.HadArrayRangeDesignator != 0;
5571 }
5572 void sawArrayRangeDesignator(bool ARD = true) {
5573 InitListExprBits.HadArrayRangeDesignator = ARD;
5574 }
5575
5576 SourceLocation getBeginLoc() const LLVM_READONLY;
5577 SourceLocation getEndLoc() const LLVM_READONLY;
5578
5579 static bool classof(const Stmt *T) {
5580 return T->getStmtClass() == InitListExprClass;
5581 }
5582
5583 // Iterators
5585 const_child_range CCR = const_cast<const InitListExpr *>(this)->children();
5586 return child_range(cast_away_const(CCR.begin()),
5587 cast_away_const(CCR.end()));
5588 }
5589
5591 // FIXME: This does not include the array filler expression.
5592 if (InitExprs.empty())
5594 return const_child_range(&InitExprs[0], &InitExprs[0] + InitExprs.size());
5595 }
5596
5601
5602 iterator begin() { return InitExprs.begin(); }
5603 const_iterator begin() const { return InitExprs.begin(); }
5604 iterator end() { return InitExprs.end(); }
5605 const_iterator end() const { return InitExprs.end(); }
5606 reverse_iterator rbegin() { return InitExprs.rbegin(); }
5607 const_reverse_iterator rbegin() const { return InitExprs.rbegin(); }
5608 reverse_iterator rend() { return InitExprs.rend(); }
5609 const_reverse_iterator rend() const { return InitExprs.rend(); }
5610
5611 friend class ASTStmtReader;
5612 friend class ASTStmtWriter;
5613};
5614
5615/// Represents a C99 designated initializer expression.
5616///
5617/// A designated initializer expression (C99 6.7.8) contains one or
5618/// more designators (which can be field designators, array
5619/// designators, or GNU array-range designators) followed by an
5620/// expression that initializes the field or element(s) that the
5621/// designators refer to. For example, given:
5622///
5623/// @code
5624/// struct point {
5625/// double x;
5626/// double y;
5627/// };
5628/// struct point ptarray[10] = { [2].y = 1.0, [2].x = 2.0, [0].x = 1.0 };
5629/// @endcode
5630///
5631/// The InitListExpr contains three DesignatedInitExprs, the first of
5632/// which covers @c [2].y=1.0. This DesignatedInitExpr will have two
5633/// designators, one array designator for @c [2] followed by one field
5634/// designator for @c .y. The initialization expression will be 1.0.
5635class DesignatedInitExpr final
5636 : public Expr,
5637 private llvm::TrailingObjects<DesignatedInitExpr, Stmt *> {
5638public:
5639 /// Forward declaration of the Designator class.
5640 class Designator;
5641
5642private:
5643 /// The location of the '=' or ':' prior to the actual initializer
5644 /// expression.
5645 SourceLocation EqualOrColonLoc;
5646
5647 /// Whether this designated initializer used the GNU deprecated
5648 /// syntax rather than the C99 '=' syntax.
5649 LLVM_PREFERRED_TYPE(bool)
5650 unsigned GNUSyntax : 1;
5651
5652 /// The number of designators in this initializer expression.
5653 unsigned NumDesignators : 15;
5654
5655 /// The number of subexpressions of this initializer expression,
5656 /// which contains both the initializer and any additional
5657 /// expressions used by array and array-range designators.
5658 unsigned NumSubExprs : 16;
5659
5660 /// The designators in this designated initialization
5661 /// expression.
5662 Designator *Designators;
5663
5664 DesignatedInitExpr(const ASTContext &C, QualType Ty,
5665 ArrayRef<Designator> Designators,
5666 SourceLocation EqualOrColonLoc, bool GNUSyntax,
5667 ArrayRef<Expr *> IndexExprs, Expr *Init);
5668
5669 explicit DesignatedInitExpr(unsigned NumSubExprs)
5670 : Expr(DesignatedInitExprClass, EmptyShell()),
5671 NumDesignators(0), NumSubExprs(NumSubExprs), Designators(nullptr) { }
5672
5673public:
5674 /// Represents a single C99 designator.
5675 ///
5676 /// @todo This class is infuriatingly similar to clang::Designator,
5677 /// but minor differences (storing indices vs. storing pointers)
5678 /// keep us from reusing it. Try harder, later, to rectify these
5679 /// differences.
5680 class Designator {
5681 /// A field designator, e.g., ".x".
5682 struct FieldDesignatorInfo {
5683 /// Refers to the field that is being initialized. The low bit
5684 /// of this field determines whether this is actually a pointer
5685 /// to an IdentifierInfo (if 1) or a FieldDecl (if 0). When
5686 /// initially constructed, a field designator will store an
5687 /// IdentifierInfo*. After semantic analysis has resolved that
5688 /// name, the field designator will instead store a FieldDecl*.
5689 uintptr_t NameOrField;
5690
5691 /// The location of the '.' in the designated initializer.
5692 SourceLocation DotLoc;
5693
5694 /// The location of the field name in the designated initializer.
5695 SourceLocation FieldLoc;
5696
5697 FieldDesignatorInfo(const IdentifierInfo *II, SourceLocation DotLoc,
5698 SourceLocation FieldLoc)
5699 : NameOrField(reinterpret_cast<uintptr_t>(II) | 0x1), DotLoc(DotLoc),
5700 FieldLoc(FieldLoc) {}
5701 };
5702
5703 /// An array or GNU array-range designator, e.g., "[9]" or "[10...15]".
5704 struct ArrayOrRangeDesignatorInfo {
5705 /// Location of the first index expression within the designated
5706 /// initializer expression's list of subexpressions.
5707 unsigned Index;
5708
5709 /// The location of the '[' starting the array range designator.
5710 SourceLocation LBracketLoc;
5711
5712 /// The location of the ellipsis separating the start and end
5713 /// indices. Only valid for GNU array-range designators.
5714 SourceLocation EllipsisLoc;
5715
5716 /// The location of the ']' terminating the array range designator.
5717 SourceLocation RBracketLoc;
5718
5719 ArrayOrRangeDesignatorInfo(unsigned Index, SourceLocation LBracketLoc,
5720 SourceLocation RBracketLoc)
5721 : Index(Index), LBracketLoc(LBracketLoc), RBracketLoc(RBracketLoc) {}
5722
5723 ArrayOrRangeDesignatorInfo(unsigned Index,
5724 SourceLocation LBracketLoc,
5725 SourceLocation EllipsisLoc,
5726 SourceLocation RBracketLoc)
5727 : Index(Index), LBracketLoc(LBracketLoc), EllipsisLoc(EllipsisLoc),
5728 RBracketLoc(RBracketLoc) {}
5729 };
5730
5731 /// The kind of designator this describes.
5732 enum DesignatorKind {
5733 FieldDesignator,
5734 ArrayDesignator,
5735 ArrayRangeDesignator
5736 };
5737
5738 DesignatorKind Kind;
5739
5740 union {
5741 /// A field designator, e.g., ".x".
5742 struct FieldDesignatorInfo FieldInfo;
5743
5744 /// An array or GNU array-range designator, e.g., "[9]" or "[10..15]".
5745 struct ArrayOrRangeDesignatorInfo ArrayOrRangeInfo;
5746 };
5747
5748 Designator(DesignatorKind Kind) : Kind(Kind) {}
5749
5750 public:
5752
5753 bool isFieldDesignator() const { return Kind == FieldDesignator; }
5754 bool isArrayDesignator() const { return Kind == ArrayDesignator; }
5755 bool isArrayRangeDesignator() const { return Kind == ArrayRangeDesignator; }
5756
5757 //===------------------------------------------------------------------===//
5758 // FieldDesignatorInfo
5759
5760 /// Creates a field designator.
5761 static Designator CreateFieldDesignator(const IdentifierInfo *FieldName,
5762 SourceLocation DotLoc,
5763 SourceLocation FieldLoc) {
5764 Designator D(FieldDesignator);
5765 new (&D.FieldInfo) FieldDesignatorInfo(FieldName, DotLoc, FieldLoc);
5766 return D;
5767 }
5768
5769 const IdentifierInfo *getFieldName() const;
5770
5772 assert(isFieldDesignator() && "Only valid on a field designator");
5773 if (FieldInfo.NameOrField & 0x01)
5774 return nullptr;
5775 return reinterpret_cast<FieldDecl *>(FieldInfo.NameOrField);
5776 }
5777
5779 assert(isFieldDesignator() && "Only valid on a field designator");
5780 FieldInfo.NameOrField = reinterpret_cast<uintptr_t>(FD);
5781 }
5782
5784 assert(isFieldDesignator() && "Only valid on a field designator");
5785 return FieldInfo.DotLoc;
5786 }
5787
5789 assert(isFieldDesignator() && "Only valid on a field designator");
5790 return FieldInfo.FieldLoc;
5791 }
5792
5793 //===------------------------------------------------------------------===//
5794 // ArrayOrRangeDesignator
5795
5796 /// Creates an array designator.
5797 static Designator CreateArrayDesignator(unsigned Index,
5798 SourceLocation LBracketLoc,
5799 SourceLocation RBracketLoc) {
5800 Designator D(ArrayDesignator);
5801 new (&D.ArrayOrRangeInfo) ArrayOrRangeDesignatorInfo(Index, LBracketLoc,
5802 RBracketLoc);
5803 return D;
5804 }
5805
5806 /// Creates a GNU array-range designator.
5807 static Designator CreateArrayRangeDesignator(unsigned Index,
5808 SourceLocation LBracketLoc,
5809 SourceLocation EllipsisLoc,
5810 SourceLocation RBracketLoc) {
5811 Designator D(ArrayRangeDesignator);
5812 new (&D.ArrayOrRangeInfo) ArrayOrRangeDesignatorInfo(Index, LBracketLoc,
5813 EllipsisLoc,
5814 RBracketLoc);
5815 return D;
5816 }
5817
5818 unsigned getArrayIndex() const {
5819 assert((isArrayDesignator() || isArrayRangeDesignator()) &&
5820 "Only valid on an array or array-range designator");
5821 return ArrayOrRangeInfo.Index;
5822 }
5823
5825 assert((isArrayDesignator() || isArrayRangeDesignator()) &&
5826 "Only valid on an array or array-range designator");
5827 return ArrayOrRangeInfo.LBracketLoc;
5828 }
5829
5831 assert(isArrayRangeDesignator() &&
5832 "Only valid on an array-range designator");
5833 return ArrayOrRangeInfo.EllipsisLoc;
5834 }
5835
5837 assert((isArrayDesignator() || isArrayRangeDesignator()) &&
5838 "Only valid on an array or array-range designator");
5839 return ArrayOrRangeInfo.RBracketLoc;
5840 }
5841
5842 SourceLocation getBeginLoc() const LLVM_READONLY {
5843 if (isFieldDesignator())
5844 return getDotLoc().isInvalid() ? getFieldLoc() : getDotLoc();
5845 return getLBracketLoc();
5846 }
5847
5848 SourceLocation getEndLoc() const LLVM_READONLY {
5850 }
5851
5852 SourceRange getSourceRange() const LLVM_READONLY {
5853 return SourceRange(getBeginLoc(), getEndLoc());
5854 }
5855 };
5856
5857 static DesignatedInitExpr *Create(const ASTContext &C,
5858 ArrayRef<Designator> Designators,
5859 ArrayRef<Expr *> IndexExprs,
5860 SourceLocation EqualOrColonLoc,
5861 bool GNUSyntax, Expr *Init);
5862
5864 unsigned NumIndexExprs);
5865
5866 /// Returns the number of designators in this initializer.
5867 unsigned size() const { return NumDesignators; }
5868
5869 // Iterator access to the designators.
5871 return {Designators, NumDesignators};
5872 }
5873
5875 return {Designators, NumDesignators};
5876 }
5877
5878 Designator *getDesignator(unsigned Idx) { return &designators()[Idx]; }
5879 const Designator *getDesignator(unsigned Idx) const {
5880 return &designators()[Idx];
5881 }
5882
5883 void setDesignators(const ASTContext &C, const Designator *Desigs,
5884 unsigned NumDesigs);
5885
5886 Expr *getArrayIndex(const Designator &D) const;
5887 Expr *getArrayRangeStart(const Designator &D) const;
5888 Expr *getArrayRangeEnd(const Designator &D) const;
5889
5890 /// Retrieve the location of the '=' that precedes the
5891 /// initializer value itself, if present.
5892 SourceLocation getEqualOrColonLoc() const { return EqualOrColonLoc; }
5893 void setEqualOrColonLoc(SourceLocation L) { EqualOrColonLoc = L; }
5894
5895 /// Whether this designated initializer should result in direct-initialization
5896 /// of the designated subobject (eg, '{.foo{1, 2, 3}}').
5897 bool isDirectInit() const { return EqualOrColonLoc.isInvalid(); }
5898
5899 /// Determines whether this designated initializer used the
5900 /// deprecated GNU syntax for designated initializers.
5901 bool usesGNUSyntax() const { return GNUSyntax; }
5902 void setGNUSyntax(bool GNU) { GNUSyntax = GNU; }
5903
5904 /// Retrieve the initializer value.
5905 Expr *getInit() const {
5906 return cast<Expr>(*const_cast<DesignatedInitExpr*>(this)->child_begin());
5907 }
5908
5909 void setInit(Expr *init) {
5910 *child_begin() = init;
5911 }
5912
5913 /// Retrieve the total number of subexpressions in this
5914 /// designated initializer expression, including the actual
5915 /// initialized value and any expressions that occur within array
5916 /// and array-range designators.
5917 unsigned getNumSubExprs() const { return NumSubExprs; }
5918
5919 Expr *getSubExpr(unsigned Idx) const {
5920 return cast<Expr>(getTrailingObjects(NumSubExprs)[Idx]);
5921 }
5922
5923 void setSubExpr(unsigned Idx, Expr *E) {
5924 getTrailingObjects(NumSubExprs)[Idx] = E;
5925 }
5926
5927 /// Replaces the designator at index @p Idx with the series
5928 /// of designators in [First, Last).
5929 void ExpandDesignator(const ASTContext &C, unsigned Idx,
5930 const Designator *First, const Designator *Last);
5931
5933
5934 SourceLocation getBeginLoc() const LLVM_READONLY;
5935 SourceLocation getEndLoc() const LLVM_READONLY;
5936
5937 static bool classof(const Stmt *T) {
5938 return T->getStmtClass() == DesignatedInitExprClass;
5939 }
5940
5941 // Iterators
5943 Stmt **begin = getTrailingObjects();
5944 return child_range(begin, begin + NumSubExprs);
5945 }
5947 Stmt *const *begin = getTrailingObjects();
5948 return const_child_range(begin, begin + NumSubExprs);
5949 }
5950
5952};
5953
5954/// Represents a place-holder for an object not to be initialized by
5955/// anything.
5956///
5957/// This only makes sense when it appears as part of an updater of a
5958/// DesignatedInitUpdateExpr (see below). The base expression of a DIUE
5959/// initializes a big object, and the NoInitExpr's mark the spots within the
5960/// big object not to be overwritten by the updater.
5961///
5962/// \see DesignatedInitUpdateExpr
5963class NoInitExpr : public Expr {
5964public:
5966 : Expr(NoInitExprClass, ty, VK_PRValue, OK_Ordinary) {
5968 }
5969
5971 : Expr(NoInitExprClass, Empty) { }
5972
5973 static bool classof(const Stmt *T) {
5974 return T->getStmtClass() == NoInitExprClass;
5975 }
5976
5977 SourceLocation getBeginLoc() const LLVM_READONLY { return SourceLocation(); }
5978 SourceLocation getEndLoc() const LLVM_READONLY { return SourceLocation(); }
5979
5980 // Iterators
5987};
5988
5989// In cases like:
5990// struct Q { int a, b, c; };
5991// Q *getQ();
5992// void foo() {
5993// struct A { Q q; } a = { *getQ(), .q.b = 3 };
5994// }
5995//
5996// We will have an InitListExpr for a, with type A, and then a
5997// DesignatedInitUpdateExpr for "a.q" with type Q. The "base" for this DIUE
5998// is the call expression *getQ(); the "updater" for the DIUE is ".q.b = 3"
5999//
6001 // BaseAndUpdaterExprs[0] is the base expression;
6002 // BaseAndUpdaterExprs[1] is an InitListExpr overwriting part of the base.
6003 Stmt *BaseAndUpdaterExprs[2];
6004
6005public:
6007 Expr *baseExprs, SourceLocation rBraceLoc);
6008
6010 : Expr(DesignatedInitUpdateExprClass, Empty) { }
6011
6012 SourceLocation getBeginLoc() const LLVM_READONLY;
6013 SourceLocation getEndLoc() const LLVM_READONLY;
6014
6015 static bool classof(const Stmt *T) {
6016 return T->getStmtClass() == DesignatedInitUpdateExprClass;
6017 }
6018
6019 Expr *getBase() const { return cast<Expr>(BaseAndUpdaterExprs[0]); }
6020 void setBase(Expr *Base) { BaseAndUpdaterExprs[0] = Base; }
6021
6023 return cast<InitListExpr>(BaseAndUpdaterExprs[1]);
6024 }
6025 void setUpdater(Expr *Updater) { BaseAndUpdaterExprs[1] = Updater; }
6026
6027 // Iterators
6028 // children = the base and the updater
6030 return child_range(&BaseAndUpdaterExprs[0], &BaseAndUpdaterExprs[0] + 2);
6031 }
6033 return const_child_range(&BaseAndUpdaterExprs[0],
6034 &BaseAndUpdaterExprs[0] + 2);
6035 }
6036};
6037
6038/// Represents a loop initializing the elements of an array.
6039///
6040/// The need to initialize the elements of an array occurs in a number of
6041/// contexts:
6042///
6043/// * in the implicit copy/move constructor for a class with an array member
6044/// * when a lambda-expression captures an array by value
6045/// * when a decomposition declaration decomposes an array
6046///
6047/// There are two subexpressions: a common expression (the source array)
6048/// that is evaluated once up-front, and a per-element initializer that
6049/// runs once for each array element.
6050///
6051/// Within the per-element initializer, the common expression may be referenced
6052/// via an OpaqueValueExpr, and the current index may be obtained via an
6053/// ArrayInitIndexExpr.
6054class ArrayInitLoopExpr : public Expr {
6055 Stmt *SubExprs[2];
6056
6057 explicit ArrayInitLoopExpr(EmptyShell Empty)
6058 : Expr(ArrayInitLoopExprClass, Empty), SubExprs{} {}
6059
6060public:
6061 explicit ArrayInitLoopExpr(QualType T, Expr *CommonInit, Expr *ElementInit)
6062 : Expr(ArrayInitLoopExprClass, T, VK_PRValue, OK_Ordinary),
6063 SubExprs{CommonInit, ElementInit} {
6065 }
6066
6067 /// Get the common subexpression shared by all initializations (the source
6068 /// array).
6070 return cast<OpaqueValueExpr>(SubExprs[0]);
6071 }
6072
6073 /// Get the initializer to use for each array element.
6074 Expr *getSubExpr() const { return cast<Expr>(SubExprs[1]); }
6075
6076 llvm::APInt getArraySize() const {
6077 return cast<ConstantArrayType>(getType()->castAsArrayTypeUnsafe())
6078 ->getSize();
6079 }
6080
6081 static bool classof(const Stmt *S) {
6082 return S->getStmtClass() == ArrayInitLoopExprClass;
6083 }
6084
6085 SourceLocation getBeginLoc() const LLVM_READONLY {
6086 return getCommonExpr()->getBeginLoc();
6087 }
6088 SourceLocation getEndLoc() const LLVM_READONLY {
6089 return getCommonExpr()->getEndLoc();
6090 }
6091
6093 return child_range(SubExprs, SubExprs + 2);
6094 }
6096 return const_child_range(SubExprs, SubExprs + 2);
6097 }
6098
6099 friend class ASTReader;
6100 friend class ASTStmtReader;
6101 friend class ASTStmtWriter;
6102};
6103
6104/// Represents the index of the current element of an array being
6105/// initialized by an ArrayInitLoopExpr. This can only appear within the
6106/// subexpression of an ArrayInitLoopExpr.
6107class ArrayInitIndexExpr : public Expr {
6108 explicit ArrayInitIndexExpr(EmptyShell Empty)
6109 : Expr(ArrayInitIndexExprClass, Empty) {}
6110
6111public:
6113 : Expr(ArrayInitIndexExprClass, T, VK_PRValue, OK_Ordinary) {
6114 setDependence(ExprDependence::None);
6115 }
6116
6117 static bool classof(const Stmt *S) {
6118 return S->getStmtClass() == ArrayInitIndexExprClass;
6119 }
6120
6121 SourceLocation getBeginLoc() const LLVM_READONLY { return SourceLocation(); }
6122 SourceLocation getEndLoc() const LLVM_READONLY { return SourceLocation(); }
6123
6130
6131 friend class ASTReader;
6132 friend class ASTStmtReader;
6133};
6134
6135/// Represents an implicitly-generated value initialization of
6136/// an object of a given type.
6137///
6138/// Implicit value initializations occur within semantic initializer
6139/// list expressions (InitListExpr) as placeholders for subobject
6140/// initializations not explicitly specified by the user.
6141///
6142/// \see InitListExpr
6144public:
6146 : Expr(ImplicitValueInitExprClass, ty, VK_PRValue, OK_Ordinary) {
6148 }
6149
6150 /// Construct an empty implicit value initialization.
6152 : Expr(ImplicitValueInitExprClass, Empty) { }
6153
6154 static bool classof(const Stmt *T) {
6155 return T->getStmtClass() == ImplicitValueInitExprClass;
6156 }
6157
6158 SourceLocation getBeginLoc() const LLVM_READONLY { return SourceLocation(); }
6159 SourceLocation getEndLoc() const LLVM_READONLY { return SourceLocation(); }
6160
6161 // Iterators
6168};
6169
6170class ParenListExpr final
6171 : public Expr,
6172 private llvm::TrailingObjects<ParenListExpr, Stmt *> {
6173 friend class ASTStmtReader;
6174 friend TrailingObjects;
6175
6176 /// The location of the left and right parentheses.
6177 SourceLocation LParenLoc, RParenLoc;
6178
6179 /// Build a paren list.
6180 ParenListExpr(SourceLocation LParenLoc, ArrayRef<Expr *> Exprs,
6181 SourceLocation RParenLoc);
6182
6183 /// Build an empty paren list.
6184 ParenListExpr(EmptyShell Empty, unsigned NumExprs);
6185
6186public:
6187 /// Create a paren list.
6188 static ParenListExpr *Create(const ASTContext &Ctx, SourceLocation LParenLoc,
6189 ArrayRef<Expr *> Exprs,
6190 SourceLocation RParenLoc);
6191
6192 /// Create an empty paren list.
6193 static ParenListExpr *CreateEmpty(const ASTContext &Ctx, unsigned NumExprs);
6194
6195 /// Return the number of expressions in this paren list.
6196 unsigned getNumExprs() const { return ParenListExprBits.NumExprs; }
6197
6198 Expr *getExpr(unsigned Init) {
6199 assert(Init < getNumExprs() && "Initializer access out of range!");
6200 return getExprs()[Init];
6201 }
6202
6203 const Expr *getExpr(unsigned Init) const {
6204 return const_cast<ParenListExpr *>(this)->getExpr(Init);
6205 }
6206
6207 Expr **getExprs() { return reinterpret_cast<Expr **>(getTrailingObjects()); }
6208
6209 Expr *const *getExprs() const {
6210 return reinterpret_cast<Expr *const *>(getTrailingObjects());
6211 }
6212
6213 ArrayRef<Expr *> exprs() const { return {getExprs(), getNumExprs()}; }
6214
6215 SourceLocation getLParenLoc() const { return LParenLoc; }
6216 SourceLocation getRParenLoc() const { return RParenLoc; }
6219
6220 static bool classof(const Stmt *T) {
6221 return T->getStmtClass() == ParenListExprClass;
6222 }
6223
6224 // Iterators
6226 return child_range(getTrailingObjects(getNumExprs()));
6227 }
6229 return const_child_range(getTrailingObjects(getNumExprs()));
6230 }
6231};
6232
6233/// Represents a C11 generic selection.
6234///
6235/// A generic selection (C11 6.5.1.1) contains an unevaluated controlling
6236/// expression, followed by one or more generic associations. Each generic
6237/// association specifies a type name and an expression, or "default" and an
6238/// expression (in which case it is known as a default generic association).
6239/// The type and value of the generic selection are identical to those of its
6240/// result expression, which is defined as the expression in the generic
6241/// association with a type name that is compatible with the type of the
6242/// controlling expression, or the expression in the default generic association
6243/// if no types are compatible. For example:
6244///
6245/// @code
6246/// _Generic(X, double: 1, float: 2, default: 3)
6247/// @endcode
6248///
6249/// The above expression evaluates to 1 if 1.0 is substituted for X, 2 if 1.0f
6250/// or 3 if "hello".
6251///
6252/// As an extension, generic selections are allowed in C++, where the following
6253/// additional semantics apply:
6254///
6255/// Any generic selection whose controlling expression is type-dependent or
6256/// which names a dependent type in its association list is result-dependent,
6257/// which means that the choice of result expression is dependent.
6258/// Result-dependent generic associations are both type- and value-dependent.
6259///
6260/// We also allow an extended form in both C and C++ where the controlling
6261/// predicate for the selection expression is a type rather than an expression.
6262/// This type argument form does not perform any conversions for the
6263/// controlling type, which makes it suitable for use with qualified type
6264/// associations, which is not possible with the expression form.
6265class GenericSelectionExpr final
6266 : public Expr,
6267 private llvm::TrailingObjects<GenericSelectionExpr, Stmt *,
6268 TypeSourceInfo *> {
6269 friend class ASTStmtReader;
6270 friend class ASTStmtWriter;
6271 friend TrailingObjects;
6272
6273 /// The number of association expressions and the index of the result
6274 /// expression in the case where the generic selection expression is not
6275 /// result-dependent. The result index is equal to ResultDependentIndex
6276 /// if and only if the generic selection expression is result-dependent.
6277 unsigned NumAssocs : 15;
6278 unsigned ResultIndex : 15; // NB: ResultDependentIndex is tied to this width.
6279 LLVM_PREFERRED_TYPE(bool)
6280 unsigned IsExprPredicate : 1;
6281 enum : unsigned {
6282 ResultDependentIndex = 0x7FFF
6283 };
6284
6285 unsigned getIndexOfControllingExpression() const {
6286 // If controlled by an expression, the first offset into the Stmt *
6287 // trailing array is the controlling expression, the associated expressions
6288 // follow this.
6289 assert(isExprPredicate() && "Asking for the controlling expression of a "
6290 "selection expr predicated by a type");
6291 return 0;
6292 }
6293
6294 unsigned getIndexOfControllingType() const {
6295 // If controlled by a type, the first offset into the TypeSourceInfo *
6296 // trailing array is the controlling type, the associated types follow this.
6297 assert(isTypePredicate() && "Asking for the controlling type of a "
6298 "selection expr predicated by an expression");
6299 return 0;
6300 }
6301
6302 unsigned getIndexOfStartOfAssociatedExprs() const {
6303 // If the predicate is a type, then the associated expressions are the only
6304 // Stmt * in the trailing array, otherwise we need to offset past the
6305 // predicate expression.
6306 return (int)isExprPredicate();
6307 }
6308
6309 unsigned getIndexOfStartOfAssociatedTypes() const {
6310 // If the predicate is a type, then the associated types follow it in the
6311 // trailing array. Otherwise, the associated types are the only
6312 // TypeSourceInfo * in the trailing array.
6313 return (int)isTypePredicate();
6314 }
6315
6316
6317 /// The location of the "default" and of the right parenthesis.
6318 SourceLocation DefaultLoc, RParenLoc;
6319
6320 // GenericSelectionExpr is followed by several trailing objects.
6321 // They are (in order):
6322 //
6323 // * An array of either
6324 // - getNumAssocs() (if what controls the generic is not an expression), or
6325 // - getNumAssocs() + 1 (if what controls the generic is an expression)
6326 // Stmt * for the association expressions.
6327 // * An array of
6328 // - getNumAssocs() (if what controls the generic is not a type), or
6329 // - getNumAssocs() + 1 (if what controls the generic is a type)
6330 // TypeSourceInfo * for the association types.
6331 unsigned numTrailingObjects(OverloadToken<Stmt *>) const {
6332 // Add one to account for the controlling expression; the remainder
6333 // are the associated expressions.
6334 return getNumAssocs() + (int)isExprPredicate();
6335 }
6336
6337 unsigned numTrailingObjects(OverloadToken<TypeSourceInfo *>) const {
6338 // Add one to account for the controlling type predicate, the remainder
6339 // are the associated types.
6340 return getNumAssocs() + (int)isTypePredicate();
6341 }
6342
6343 template <bool Const> class AssociationIteratorTy;
6344 /// Bundle together an association expression and its TypeSourceInfo.
6345 /// The Const template parameter is for the const and non-const versions
6346 /// of AssociationTy.
6347 template <bool Const> class AssociationTy {
6348 friend class GenericSelectionExpr;
6349 template <bool OtherConst> friend class AssociationIteratorTy;
6350 using ExprPtrTy = std::conditional_t<Const, const Expr *, Expr *>;
6351 using TSIPtrTy =
6352 std::conditional_t<Const, const TypeSourceInfo *, TypeSourceInfo *>;
6353 ExprPtrTy E;
6354 TSIPtrTy TSI;
6355 bool Selected;
6356 AssociationTy(ExprPtrTy E, TSIPtrTy TSI, bool Selected)
6357 : E(E), TSI(TSI), Selected(Selected) {}
6358
6359 public:
6360 ExprPtrTy getAssociationExpr() const { return E; }
6361 TSIPtrTy getTypeSourceInfo() const { return TSI; }
6362 QualType getType() const { return TSI ? TSI->getType() : QualType(); }
6363 bool isSelected() const { return Selected; }
6364 AssociationTy *operator->() { return this; }
6365 const AssociationTy *operator->() const { return this; }
6366 }; // class AssociationTy
6367
6368 /// Iterator over const and non-const Association objects. The Association
6369 /// objects are created on the fly when the iterator is dereferenced.
6370 /// This abstract over how exactly the association expressions and the
6371 /// corresponding TypeSourceInfo * are stored.
6372 template <bool Const>
6373 class AssociationIteratorTy
6374 : public llvm::iterator_facade_base<
6375 AssociationIteratorTy<Const>, std::input_iterator_tag,
6376 AssociationTy<Const>, std::ptrdiff_t, AssociationTy<Const>,
6377 AssociationTy<Const>> {
6378 friend class GenericSelectionExpr;
6379 // FIXME: This iterator could conceptually be a random access iterator, and
6380 // it would be nice if we could strengthen the iterator category someday.
6381 // However this iterator does not satisfy two requirements of forward
6382 // iterators:
6383 // a) reference = T& or reference = const T&
6384 // b) If It1 and It2 are both dereferenceable, then It1 == It2 if and only
6385 // if *It1 and *It2 are bound to the same objects.
6386 // An alternative design approach was discussed during review;
6387 // store an Association object inside the iterator, and return a reference
6388 // to it when dereferenced. This idea was discarded because of nasty
6389 // lifetime issues:
6390 // AssociationIterator It = ...;
6391 // const Association &Assoc = *It++; // Oops, Assoc is dangling.
6392 using BaseTy = typename AssociationIteratorTy::iterator_facade_base;
6393 using StmtPtrPtrTy =
6394 std::conditional_t<Const, const Stmt *const *, Stmt **>;
6395 using TSIPtrPtrTy = std::conditional_t<Const, const TypeSourceInfo *const *,
6396 TypeSourceInfo **>;
6397 StmtPtrPtrTy E = nullptr;
6398 TSIPtrPtrTy TSI; // Kept in sync with E.
6399 unsigned Offset = 0, SelectedOffset = 0;
6400 AssociationIteratorTy(StmtPtrPtrTy E, TSIPtrPtrTy TSI, unsigned Offset,
6401 unsigned SelectedOffset)
6402 : E(E), TSI(TSI), Offset(Offset), SelectedOffset(SelectedOffset) {}
6403
6404 public:
6405 AssociationIteratorTy() : E(nullptr), TSI(nullptr) {}
6406 typename BaseTy::reference operator*() const {
6407 return AssociationTy<Const>(cast<Expr>(*E), *TSI,
6408 Offset == SelectedOffset);
6409 }
6410 typename BaseTy::pointer operator->() const { return **this; }
6411 using BaseTy::operator++;
6412 AssociationIteratorTy &operator++() {
6413 ++E;
6414 ++TSI;
6415 ++Offset;
6416 return *this;
6417 }
6418 bool operator==(AssociationIteratorTy Other) const { return E == Other.E; }
6419 }; // class AssociationIterator
6420
6421 /// Build a non-result-dependent generic selection expression accepting an
6422 /// expression predicate.
6423 GenericSelectionExpr(const ASTContext &Context, SourceLocation GenericLoc,
6424 Expr *ControllingExpr,
6425 ArrayRef<TypeSourceInfo *> AssocTypes,
6426 ArrayRef<Expr *> AssocExprs, SourceLocation DefaultLoc,
6427 SourceLocation RParenLoc,
6428 bool ContainsUnexpandedParameterPack,
6429 unsigned ResultIndex);
6430
6431 /// Build a result-dependent generic selection expression accepting an
6432 /// expression predicate.
6433 GenericSelectionExpr(const ASTContext &Context, SourceLocation GenericLoc,
6434 Expr *ControllingExpr,
6435 ArrayRef<TypeSourceInfo *> AssocTypes,
6436 ArrayRef<Expr *> AssocExprs, SourceLocation DefaultLoc,
6437 SourceLocation RParenLoc,
6438 bool ContainsUnexpandedParameterPack);
6439
6440 /// Build a non-result-dependent generic selection expression accepting a
6441 /// type predicate.
6442 GenericSelectionExpr(const ASTContext &Context, SourceLocation GenericLoc,
6443 TypeSourceInfo *ControllingType,
6444 ArrayRef<TypeSourceInfo *> AssocTypes,
6445 ArrayRef<Expr *> AssocExprs, SourceLocation DefaultLoc,
6446 SourceLocation RParenLoc,
6447 bool ContainsUnexpandedParameterPack,
6448 unsigned ResultIndex);
6449
6450 /// Build a result-dependent generic selection expression accepting a type
6451 /// predicate.
6452 GenericSelectionExpr(const ASTContext &Context, SourceLocation GenericLoc,
6453 TypeSourceInfo *ControllingType,
6454 ArrayRef<TypeSourceInfo *> AssocTypes,
6455 ArrayRef<Expr *> AssocExprs, SourceLocation DefaultLoc,
6456 SourceLocation RParenLoc,
6457 bool ContainsUnexpandedParameterPack);
6458
6459 /// Build an empty generic selection expression for deserialization.
6460 explicit GenericSelectionExpr(EmptyShell Empty, unsigned NumAssocs);
6461
6462public:
6463 /// Create a non-result-dependent generic selection expression accepting an
6464 /// expression predicate.
6465 static GenericSelectionExpr *
6466 Create(const ASTContext &Context, SourceLocation GenericLoc,
6467 Expr *ControllingExpr, ArrayRef<TypeSourceInfo *> AssocTypes,
6468 ArrayRef<Expr *> AssocExprs, SourceLocation DefaultLoc,
6469 SourceLocation RParenLoc, bool ContainsUnexpandedParameterPack,
6470 unsigned ResultIndex);
6471
6472 /// Create a result-dependent generic selection expression accepting an
6473 /// expression predicate.
6474 static GenericSelectionExpr *
6475 Create(const ASTContext &Context, SourceLocation GenericLoc,
6476 Expr *ControllingExpr, ArrayRef<TypeSourceInfo *> AssocTypes,
6477 ArrayRef<Expr *> AssocExprs, SourceLocation DefaultLoc,
6478 SourceLocation RParenLoc, bool ContainsUnexpandedParameterPack);
6479
6480 /// Create a non-result-dependent generic selection expression accepting a
6481 /// type predicate.
6482 static GenericSelectionExpr *
6483 Create(const ASTContext &Context, SourceLocation GenericLoc,
6484 TypeSourceInfo *ControllingType, ArrayRef<TypeSourceInfo *> AssocTypes,
6485 ArrayRef<Expr *> AssocExprs, SourceLocation DefaultLoc,
6486 SourceLocation RParenLoc, bool ContainsUnexpandedParameterPack,
6487 unsigned ResultIndex);
6488
6489 /// Create a result-dependent generic selection expression accepting a type
6490 /// predicate
6491 static GenericSelectionExpr *
6492 Create(const ASTContext &Context, SourceLocation GenericLoc,
6493 TypeSourceInfo *ControllingType, ArrayRef<TypeSourceInfo *> AssocTypes,
6494 ArrayRef<Expr *> AssocExprs, SourceLocation DefaultLoc,
6495 SourceLocation RParenLoc, bool ContainsUnexpandedParameterPack);
6496
6497 /// Create an empty generic selection expression for deserialization.
6498 static GenericSelectionExpr *CreateEmpty(const ASTContext &Context,
6499 unsigned NumAssocs);
6500
6501 using Association = AssociationTy<false>;
6502 using ConstAssociation = AssociationTy<true>;
6503 using AssociationIterator = AssociationIteratorTy<false>;
6504 using ConstAssociationIterator = AssociationIteratorTy<true>;
6505 using association_range = llvm::iterator_range<AssociationIterator>;
6507 llvm::iterator_range<ConstAssociationIterator>;
6508
6509 /// The number of association expressions.
6510 unsigned getNumAssocs() const { return NumAssocs; }
6511
6512 /// The zero-based index of the result expression's generic association in
6513 /// the generic selection's association list. Defined only if the
6514 /// generic selection is not result-dependent.
6515 unsigned getResultIndex() const {
6516 assert(!isResultDependent() &&
6517 "Generic selection is result-dependent but getResultIndex called!");
6518 return ResultIndex;
6519 }
6520
6521 /// Whether this generic selection is result-dependent.
6522 bool isResultDependent() const { return ResultIndex == ResultDependentIndex; }
6523
6524 /// Whether this generic selection uses an expression as its controlling
6525 /// argument.
6526 bool isExprPredicate() const { return IsExprPredicate; }
6527 /// Whether this generic selection uses a type as its controlling argument.
6528 bool isTypePredicate() const { return !IsExprPredicate; }
6529
6530 /// Return the controlling expression of this generic selection expression.
6531 /// Only valid to call if the selection expression used an expression as its
6532 /// controlling argument.
6534 return cast<Expr>(
6535 getTrailingObjects<Stmt *>()[getIndexOfControllingExpression()]);
6536 }
6537 const Expr *getControllingExpr() const {
6538 return cast<Expr>(
6539 getTrailingObjects<Stmt *>()[getIndexOfControllingExpression()]);
6540 }
6541
6542 /// Return the controlling type of this generic selection expression. Only
6543 /// valid to call if the selection expression used a type as its controlling
6544 /// argument.
6546 return getTrailingObjects<TypeSourceInfo *>()[getIndexOfControllingType()];
6547 }
6549 return getTrailingObjects<TypeSourceInfo *>()[getIndexOfControllingType()];
6550 }
6551
6552 /// Return the result expression of this controlling expression. Defined if
6553 /// and only if the generic selection expression is not result-dependent.
6555 return cast<Expr>(
6556 getTrailingObjects<Stmt *>()[getIndexOfStartOfAssociatedExprs() +
6557 getResultIndex()]);
6558 }
6559 const Expr *getResultExpr() const {
6560 return cast<Expr>(
6561 getTrailingObjects<Stmt *>()[getIndexOfStartOfAssociatedExprs() +
6562 getResultIndex()]);
6563 }
6564
6566 return {reinterpret_cast<Expr *const *>(getTrailingObjects<Stmt *>() +
6567 getIndexOfStartOfAssociatedExprs()),
6568 NumAssocs};
6569 }
6571 return {getTrailingObjects<TypeSourceInfo *>() +
6572 getIndexOfStartOfAssociatedTypes(),
6573 NumAssocs};
6574 }
6575
6576 /// Return the Ith association expression with its TypeSourceInfo,
6577 /// bundled together in GenericSelectionExpr::(Const)Association.
6579 assert(I < getNumAssocs() &&
6580 "Out-of-range index in GenericSelectionExpr::getAssociation!");
6581 return Association(
6582 cast<Expr>(
6583 getTrailingObjects<Stmt *>()[getIndexOfStartOfAssociatedExprs() +
6584 I]),
6585 getTrailingObjects<
6586 TypeSourceInfo *>()[getIndexOfStartOfAssociatedTypes() + I],
6587 !isResultDependent() && (getResultIndex() == I));
6588 }
6590 assert(I < getNumAssocs() &&
6591 "Out-of-range index in GenericSelectionExpr::getAssociation!");
6592 return ConstAssociation(
6593 cast<Expr>(
6594 getTrailingObjects<Stmt *>()[getIndexOfStartOfAssociatedExprs() +
6595 I]),
6596 getTrailingObjects<
6597 TypeSourceInfo *>()[getIndexOfStartOfAssociatedTypes() + I],
6598 !isResultDependent() && (getResultIndex() == I));
6599 }
6600
6602 AssociationIterator Begin(getTrailingObjects<Stmt *>() +
6603 getIndexOfStartOfAssociatedExprs(),
6604 getTrailingObjects<TypeSourceInfo *>() +
6605 getIndexOfStartOfAssociatedTypes(),
6606 /*Offset=*/0, ResultIndex);
6607 AssociationIterator End(Begin.E + NumAssocs, Begin.TSI + NumAssocs,
6608 /*Offset=*/NumAssocs, ResultIndex);
6609 return llvm::make_range(Begin, End);
6610 }
6611
6613 ConstAssociationIterator Begin(getTrailingObjects<Stmt *>() +
6614 getIndexOfStartOfAssociatedExprs(),
6615 getTrailingObjects<TypeSourceInfo *>() +
6616 getIndexOfStartOfAssociatedTypes(),
6617 /*Offset=*/0, ResultIndex);
6618 ConstAssociationIterator End(Begin.E + NumAssocs, Begin.TSI + NumAssocs,
6619 /*Offset=*/NumAssocs, ResultIndex);
6620 return llvm::make_range(Begin, End);
6621 }
6622
6624 return GenericSelectionExprBits.GenericLoc;
6625 }
6626 SourceLocation getDefaultLoc() const { return DefaultLoc; }
6627 SourceLocation getRParenLoc() const { return RParenLoc; }
6630
6631 static bool classof(const Stmt *T) {
6632 return T->getStmtClass() == GenericSelectionExprClass;
6633 }
6634
6636 return child_range(getTrailingObjects<Stmt *>(
6637 numTrailingObjects(OverloadToken<Stmt *>())));
6638 }
6640 return const_child_range(getTrailingObjects<Stmt *>(
6641 numTrailingObjects(OverloadToken<Stmt *>())));
6642 }
6643};
6644
6645//===----------------------------------------------------------------------===//
6646// Clang Extensions
6647//===----------------------------------------------------------------------===//
6648
6649template <class Derived> class ElementAccessExprBase : public Expr {
6650protected:
6654
6657 ExprObjectKind OK)
6658 : Expr(SC, Ty, VK, OK), Base(Base), Accessor(&Accessor),
6659 AccessorLoc(Loc) {
6660 setDependence(computeDependence(static_cast<Derived *>(this)));
6661 }
6662
6665
6666public:
6667 const Expr *getBase() const { return cast<Expr>(Base); }
6668 Expr *getBase() { return cast<Expr>(Base); }
6669 void setBase(Expr *E) { Base = E; }
6670
6673
6676
6677 SourceLocation getBeginLoc() const LLVM_READONLY {
6678 return getBase()->getBeginLoc();
6679 }
6680 SourceLocation getEndLoc() const LLVM_READONLY { return AccessorLoc; }
6681
6684 return const_child_range(&Base, &Base + 1);
6685 }
6686};
6687
6688/// ExtVectorElementExpr - This represents access to specific elements of a
6689/// vector, and may occur on the left hand side or right hand side. For example
6690/// the following is legal: "V.xy = V.zw" if V is a 4 element extended vector.
6691///
6692/// Note that the base may have either vector or pointer to vector type, just
6693/// like a struct field reference.
6694///
6696 : public ElementAccessExprBase<ExtVectorElementExpr> {
6697public:
6703
6704 /// Build an empty vector element expression.
6706 : ElementAccessExprBase(ExtVectorElementExprClass, Empty) {}
6707
6708 /// getNumElements - Get the number of components being selected.
6709 unsigned getNumElements() const;
6710
6711 /// containsDuplicateElements - Return true if any element access is
6712 /// repeated.
6713 bool containsDuplicateElements() const;
6714
6715 /// getEncodedElementAccess - Encode the elements accessed into an llvm
6716 /// aggregate Constant of ConstantInt(s).
6718
6719 /// isArrow - Return true if the base expression is a pointer to vector,
6720 /// return false if the base expression is a vector.
6721 bool isArrow() const;
6722
6723 static bool classof(const Stmt *T) {
6724 return T->getStmtClass() == ExtVectorElementExprClass;
6725 }
6726};
6727
6728class MatrixElementExpr : public ElementAccessExprBase<MatrixElementExpr> {
6729public:
6733 MatrixElementExprClass, Ty, VK, Base, Accessor, Loc,
6734 OK_Ordinary /*TODO: Should we add a new OK_MatrixComponent?*/) {}
6735
6736 /// Build an empty matrix element expression.
6738 : ElementAccessExprBase(MatrixElementExprClass, Empty) {}
6739
6740 /// getNumElements - Get the number of components being selected.
6741 unsigned getNumElements() const;
6742
6743 /// containsDuplicateElements - Return true if any element access is
6744 /// repeated.
6745 bool containsDuplicateElements() const;
6746
6747 /// getEncodedElementAccess - Encode the elements accessed into an llvm
6748 /// aggregate Constant of ConstantInt(s).
6750
6751 static bool classof(const Stmt *T) {
6752 return T->getStmtClass() == MatrixElementExprClass;
6753 }
6754};
6755
6756/// BlockExpr - Adaptor class for mixing a BlockDecl with expressions.
6757/// ^{ statement-body } or ^(int arg1, float arg2){ statement-body }
6758class BlockExpr : public Expr {
6759protected:
6761public:
6762 BlockExpr(BlockDecl *BD, QualType ty, bool ContainsUnexpandedParameterPack)
6763 : Expr(BlockExprClass, ty, VK_PRValue, OK_Ordinary), TheBlock(BD) {
6764 setDependence(computeDependence(this, ContainsUnexpandedParameterPack));
6765 }
6766
6767 /// Build an empty block expression.
6768 explicit BlockExpr(EmptyShell Empty) : Expr(BlockExprClass, Empty) { }
6769
6770 const BlockDecl *getBlockDecl() const { return TheBlock; }
6772 void setBlockDecl(BlockDecl *BD) { TheBlock = BD; }
6773
6774 // Convenience functions for probing the underlying BlockDecl.
6776 const Stmt *getBody() const;
6777 Stmt *getBody();
6778
6779 SourceLocation getBeginLoc() const LLVM_READONLY {
6780 return getCaretLocation();
6781 }
6782 SourceLocation getEndLoc() const LLVM_READONLY {
6783 return getBody()->getEndLoc();
6784 }
6785
6786 /// getFunctionType - Return the underlying function type for this block.
6787 const FunctionProtoType *getFunctionType() const;
6788
6789 static bool classof(const Stmt *T) {
6790 return T->getStmtClass() == BlockExprClass;
6791 }
6792
6793 // Iterators
6800};
6801
6802/// Copy initialization expr of a __block variable and a boolean flag that
6803/// indicates whether the expression can throw.
6805 BlockVarCopyInit() = default;
6807 : ExprAndFlag(CopyExpr, CanThrow) {}
6808 void setExprAndFlag(Expr *CopyExpr, bool CanThrow) {
6809 ExprAndFlag.setPointerAndInt(CopyExpr, CanThrow);
6810 }
6811 Expr *getCopyExpr() const { return ExprAndFlag.getPointer(); }
6812 bool canThrow() const { return ExprAndFlag.getInt(); }
6813 llvm::PointerIntPair<Expr *, 1, bool> ExprAndFlag;
6814};
6815
6816/// AsTypeExpr - Clang builtin function __builtin_astype [OpenCL 6.2.4.2]
6817/// This AST node provides support for reinterpreting a type to another
6818/// type of the same size.
6819class AsTypeExpr : public Expr {
6820private:
6821 Stmt *SrcExpr;
6822 SourceLocation BuiltinLoc, RParenLoc;
6823
6824 friend class ASTReader;
6825 friend class ASTStmtReader;
6826 explicit AsTypeExpr(EmptyShell Empty) : Expr(AsTypeExprClass, Empty) {}
6827
6828public:
6830 ExprObjectKind OK, SourceLocation BuiltinLoc,
6831 SourceLocation RParenLoc)
6832 : Expr(AsTypeExprClass, DstType, VK, OK), SrcExpr(SrcExpr),
6833 BuiltinLoc(BuiltinLoc), RParenLoc(RParenLoc) {
6835 }
6836
6837 /// getSrcExpr - Return the Expr to be converted.
6838 Expr *getSrcExpr() const { return cast<Expr>(SrcExpr); }
6839
6840 /// getBuiltinLoc - Return the location of the __builtin_astype token.
6841 SourceLocation getBuiltinLoc() const { return BuiltinLoc; }
6842
6843 /// getRParenLoc - Return the location of final right parenthesis.
6844 SourceLocation getRParenLoc() const { return RParenLoc; }
6845
6846 SourceLocation getBeginLoc() const LLVM_READONLY { return BuiltinLoc; }
6847 SourceLocation getEndLoc() const LLVM_READONLY { return RParenLoc; }
6848
6849 static bool classof(const Stmt *T) {
6850 return T->getStmtClass() == AsTypeExprClass;
6851 }
6852
6853 // Iterators
6854 child_range children() { return child_range(&SrcExpr, &SrcExpr+1); }
6856 return const_child_range(&SrcExpr, &SrcExpr + 1);
6857 }
6858};
6859
6860/// PseudoObjectExpr - An expression which accesses a pseudo-object
6861/// l-value. A pseudo-object is an abstract object, accesses to which
6862/// are translated to calls. The pseudo-object expression has a
6863/// syntactic form, which shows how the expression was actually
6864/// written in the source code, and a semantic form, which is a series
6865/// of expressions to be executed in order which detail how the
6866/// operation is actually evaluated. Optionally, one of the semantic
6867/// forms may also provide a result value for the expression.
6868///
6869/// If any of the semantic-form expressions is an OpaqueValueExpr,
6870/// that OVE is required to have a source expression, and it is bound
6871/// to the result of that source expression. Such OVEs may appear
6872/// only in subsequent semantic-form expressions and as
6873/// sub-expressions of the syntactic form.
6874///
6875/// PseudoObjectExpr should be used only when an operation can be
6876/// usefully described in terms of fairly simple rewrite rules on
6877/// objects and functions that are meant to be used by end-developers.
6878/// For example, under the Itanium ABI, dynamic casts are implemented
6879/// as a call to a runtime function called __dynamic_cast; using this
6880/// class to describe that would be inappropriate because that call is
6881/// not really part of the user-visible semantics, and instead the
6882/// cast is properly reflected in the AST and IR-generation has been
6883/// taught to generate the call as necessary. In contrast, an
6884/// Objective-C property access is semantically defined to be
6885/// equivalent to a particular message send, and this is very much
6886/// part of the user model. The name of this class encourages this
6887/// modelling design.
6888class PseudoObjectExpr final
6889 : public Expr,
6890 private llvm::TrailingObjects<PseudoObjectExpr, Expr *> {
6891 // PseudoObjectExprBits.NumSubExprs - The number of sub-expressions.
6892 // Always at least two, because the first sub-expression is the
6893 // syntactic form.
6894
6895 // PseudoObjectExprBits.ResultIndex - The index of the
6896 // sub-expression holding the result. 0 means the result is void,
6897 // which is unambiguous because it's the index of the syntactic
6898 // form. Note that this is therefore 1 higher than the value passed
6899 // in to Create, which is an index within the semantic forms.
6900 // Note also that ASTStmtWriter assumes this encoding.
6901
6902 PseudoObjectExpr(QualType type, ExprValueKind VK,
6903 Expr *syntactic, ArrayRef<Expr*> semantic,
6904 unsigned resultIndex);
6905
6906 PseudoObjectExpr(EmptyShell shell, unsigned numSemanticExprs);
6907
6908 unsigned getNumSubExprs() const {
6909 return PseudoObjectExprBits.NumSubExprs;
6910 }
6911
6912public:
6913 /// NoResult - A value for the result index indicating that there is
6914 /// no semantic result.
6915 enum : unsigned { NoResult = ~0U };
6916
6917 static PseudoObjectExpr *Create(const ASTContext &Context, Expr *syntactic,
6918 ArrayRef<Expr*> semantic,
6919 unsigned resultIndex);
6920
6921 static PseudoObjectExpr *Create(const ASTContext &Context, EmptyShell shell,
6922 unsigned numSemanticExprs);
6923
6924 /// Return the syntactic form of this expression, i.e. the
6925 /// expression it actually looks like. Likely to be expressed in
6926 /// terms of OpaqueValueExprs bound in the semantic form.
6927 Expr *getSyntacticForm() { return getTrailingObjects()[0]; }
6928 const Expr *getSyntacticForm() const { return getTrailingObjects()[0]; }
6929
6930 /// Return the index of the result-bearing expression into the semantics
6931 /// expressions, or PseudoObjectExpr::NoResult if there is none.
6932 unsigned getResultExprIndex() const {
6933 if (PseudoObjectExprBits.ResultIndex == 0) return NoResult;
6934 return PseudoObjectExprBits.ResultIndex - 1;
6935 }
6936
6937 /// Return the result-bearing expression, or null if there is none.
6939 if (PseudoObjectExprBits.ResultIndex == 0)
6940 return nullptr;
6941 return getTrailingObjects()[PseudoObjectExprBits.ResultIndex];
6942 }
6943 const Expr *getResultExpr() const {
6944 return const_cast<PseudoObjectExpr*>(this)->getResultExpr();
6945 }
6946
6947 unsigned getNumSemanticExprs() const { return getNumSubExprs() - 1; }
6948
6949 typedef Expr * const *semantics_iterator;
6950 typedef const Expr * const *const_semantics_iterator;
6951 semantics_iterator semantics_begin() { return getTrailingObjects() + 1; }
6953 return getTrailingObjects() + 1;
6954 }
6956 return getTrailingObjects() + getNumSubExprs();
6957 }
6959 return getTrailingObjects() + getNumSubExprs();
6960 }
6961
6963 return getTrailingObjects(getNumSubExprs()).drop_front();
6964 }
6966 return getTrailingObjects(getNumSubExprs()).drop_front();
6967 }
6968
6970 return getTrailingObjects(getNumSubExprs())[index + 1];
6971 }
6972 const Expr *getSemanticExpr(unsigned index) const {
6973 return const_cast<PseudoObjectExpr*>(this)->getSemanticExpr(index);
6974 }
6975
6976 SourceLocation getExprLoc() const LLVM_READONLY {
6977 return getSyntacticForm()->getExprLoc();
6978 }
6979
6980 SourceLocation getBeginLoc() const LLVM_READONLY {
6981 return getSyntacticForm()->getBeginLoc();
6982 }
6983 SourceLocation getEndLoc() const LLVM_READONLY {
6984 return getSyntacticForm()->getEndLoc();
6985 }
6986
6988 const_child_range CCR =
6989 const_cast<const PseudoObjectExpr *>(this)->children();
6990 return child_range(cast_away_const(CCR.begin()),
6991 cast_away_const(CCR.end()));
6992 }
6994 Stmt *const *cs = const_cast<Stmt *const *>(
6995 reinterpret_cast<const Stmt *const *>(getTrailingObjects()));
6996 return const_child_range(cs, cs + getNumSubExprs());
6997 }
6998
6999 static bool classof(const Stmt *T) {
7000 return T->getStmtClass() == PseudoObjectExprClass;
7001 }
7002
7004 friend class ASTStmtReader;
7005};
7006
7007/// AtomicExpr - Variadic atomic builtins: __atomic_exchange, __atomic_fetch_*,
7008/// __atomic_load, __atomic_store, and __atomic_compare_exchange_*, for the
7009/// similarly-named C++11 instructions, and __c11 variants for <stdatomic.h>,
7010/// and corresponding __opencl_atomic_* for OpenCL 2.0.
7011/// All of these instructions take one primary pointer, at least one memory
7012/// order. The instructions for which getScopeModel returns non-null value
7013/// take one sync scope.
7014class AtomicExpr : public Expr {
7015public:
7017#define ATOMIC_BUILTIN(ID, TYPE, ATTRS) AO ## ID,
7018#include "clang/Basic/Builtins.inc"
7019 // Avoid trailing comma
7021 };
7022
7023private:
7024 /// Location of sub-expressions.
7025 /// The location of Scope sub-expression is NumSubExprs - 1, which is
7026 /// not fixed, therefore is not defined in enum.
7027 enum { PTR, ORDER, VAL1, ORDER_FAIL, VAL2, WEAK, END_EXPR };
7028 Stmt *SubExprs[END_EXPR + 1];
7029 unsigned NumSubExprs;
7030 SourceLocation BuiltinLoc, RParenLoc;
7031 AtomicOp Op;
7032
7033 friend class ASTStmtReader;
7034public:
7036 AtomicOp op, SourceLocation RP);
7037
7038 /// Determine the number of arguments the specified atomic builtin
7039 /// should have.
7040 static unsigned getNumSubExprs(AtomicOp Op);
7041
7042 /// Build an empty AtomicExpr.
7043 explicit AtomicExpr(EmptyShell Empty) : Expr(AtomicExprClass, Empty) { }
7044
7045 Expr *getPtr() const {
7046 return cast<Expr>(SubExprs[PTR]);
7047 }
7048 Expr *getOrder() const {
7049 return cast<Expr>(SubExprs[ORDER]);
7050 }
7051 Expr *getScope() const {
7052 assert(getScopeModel() && "No scope");
7053 return cast<Expr>(SubExprs[NumSubExprs - 1]);
7054 }
7055 Expr *getVal1() const {
7056 if (Op == AO__c11_atomic_init || Op == AO__opencl_atomic_init)
7057 return cast<Expr>(SubExprs[ORDER]);
7058 assert(NumSubExprs > VAL1);
7059 return cast<Expr>(SubExprs[VAL1]);
7060 }
7062 assert(NumSubExprs > ORDER_FAIL);
7063 return cast<Expr>(SubExprs[ORDER_FAIL]);
7064 }
7065 Expr *getVal2() const {
7066 if (Op == AO__atomic_exchange || Op == AO__scoped_atomic_exchange)
7067 return cast<Expr>(SubExprs[ORDER_FAIL]);
7068 assert(NumSubExprs > VAL2);
7069 return cast<Expr>(SubExprs[VAL2]);
7070 }
7071 Expr *getWeak() const {
7072 assert(NumSubExprs > WEAK);
7073 return cast<Expr>(SubExprs[WEAK]);
7074 }
7075 QualType getValueType() const;
7076
7077 AtomicOp getOp() const { return Op; }
7078 StringRef getOpAsString() const {
7079 switch (Op) {
7080#define ATOMIC_BUILTIN(ID, TYPE, ATTRS) \
7081 case AO##ID: \
7082 return #ID;
7083#include "clang/Basic/Builtins.inc"
7084 }
7085 llvm_unreachable("not an atomic operator?");
7086 }
7087 unsigned getNumSubExprs() const { return NumSubExprs; }
7088
7089 Expr **getSubExprs() { return reinterpret_cast<Expr **>(SubExprs); }
7090 const Expr * const *getSubExprs() const {
7091 return reinterpret_cast<Expr * const *>(SubExprs);
7092 }
7093
7094 bool isVolatile() const {
7096 }
7097
7098 bool isCmpXChg() const {
7099 return getOp() == AO__c11_atomic_compare_exchange_strong ||
7100 getOp() == AO__c11_atomic_compare_exchange_weak ||
7101 getOp() == AO__hip_atomic_compare_exchange_strong ||
7102 getOp() == AO__opencl_atomic_compare_exchange_strong ||
7103 getOp() == AO__opencl_atomic_compare_exchange_weak ||
7104 getOp() == AO__hip_atomic_compare_exchange_weak ||
7105 getOp() == AO__atomic_compare_exchange ||
7106 getOp() == AO__atomic_compare_exchange_n ||
7107 getOp() == AO__scoped_atomic_compare_exchange ||
7108 getOp() == AO__scoped_atomic_compare_exchange_n;
7109 }
7110
7111 bool hasVal1Operand() const {
7112 switch (getOp()) {
7113 case AO__atomic_load_n:
7114 case AO__scoped_atomic_load_n:
7115 case AO__c11_atomic_load:
7116 case AO__opencl_atomic_load:
7117 case AO__hip_atomic_load:
7118 case AO__atomic_test_and_set:
7119 case AO__atomic_clear:
7120 return false;
7121 default:
7122 return true;
7123 }
7124 }
7125
7126 bool isOpenCL() const {
7127 return getOp() >= AO__opencl_atomic_compare_exchange_strong &&
7128 getOp() <= AO__opencl_atomic_store;
7129 }
7130
7131 bool isHIP() const {
7132 return Op >= AO__hip_atomic_compare_exchange_strong &&
7133 Op <= AO__hip_atomic_store;
7134 }
7135
7136 /// Return true if atomics operations targeting allocations in private memory
7137 /// are undefined.
7139 return isOpenCL() || isHIP();
7140 }
7141
7142 SourceLocation getBuiltinLoc() const { return BuiltinLoc; }
7143 SourceLocation getRParenLoc() const { return RParenLoc; }
7144
7145 SourceLocation getBeginLoc() const LLVM_READONLY { return BuiltinLoc; }
7146 SourceLocation getEndLoc() const LLVM_READONLY { return RParenLoc; }
7147
7148 static bool classof(const Stmt *T) {
7149 return T->getStmtClass() == AtomicExprClass;
7150 }
7151
7152 // Iterators
7154 return child_range(SubExprs, SubExprs+NumSubExprs);
7155 }
7157 return const_child_range(SubExprs, SubExprs + NumSubExprs);
7158 }
7159
7160 /// Get atomic scope model for the atomic op code.
7161 /// \return empty atomic scope model if the atomic op code does not have
7162 /// scope operand.
7163 static std::unique_ptr<AtomicScopeModel> getScopeModel(AtomicOp Op) {
7164 // FIXME: Allow grouping of builtins to be able to only check >= and <=
7165 if (Op >= AO__opencl_atomic_compare_exchange_strong &&
7166 Op <= AO__opencl_atomic_store && Op != AO__opencl_atomic_init)
7168 if (Op >= AO__hip_atomic_compare_exchange_strong &&
7169 Op <= AO__hip_atomic_store)
7171 if (Op >= AO__scoped_atomic_add_fetch && Op <= AO__scoped_atomic_xor_fetch)
7174 }
7175
7176 /// Get atomic scope model.
7177 /// \return empty atomic scope model if this atomic expression does not have
7178 /// scope operand.
7179 std::unique_ptr<AtomicScopeModel> getScopeModel() const {
7180 return getScopeModel(getOp());
7181 }
7182};
7183
7184/// This class represents BOTH the OpenMP Array Section and OpenACC 'subarray',
7185/// with a boolean differentiator.
7186/// OpenMP 5.0 [2.1.5, Array Sections].
7187/// To specify an array section in an OpenMP construct, array subscript
7188/// expressions are extended with the following syntax:
7189/// \code
7190/// [ lower-bound : length : stride ]
7191/// [ lower-bound : length : ]
7192/// [ lower-bound : length ]
7193/// [ lower-bound : : stride ]
7194/// [ lower-bound : : ]
7195/// [ lower-bound : ]
7196/// [ : length : stride ]
7197/// [ : length : ]
7198/// [ : length ]
7199/// [ : : stride ]
7200/// [ : : ]
7201/// [ : ]
7202/// \endcode
7203/// The array section must be a subset of the original array.
7204/// Array sections are allowed on multidimensional arrays. Base language array
7205/// subscript expressions can be used to specify length-one dimensions of
7206/// multidimensional array sections.
7207/// Each of the lower-bound, length, and stride expressions if specified must be
7208/// an integral type expressions of the base language. When evaluated
7209/// they represent a set of integer values as follows:
7210/// \code
7211/// { lower-bound, lower-bound + stride, lower-bound + 2 * stride,... ,
7212/// lower-bound + ((length - 1) * stride) }
7213/// \endcode
7214/// The lower-bound and length must evaluate to non-negative integers.
7215/// The stride must evaluate to a positive integer.
7216/// When the size of the array dimension is not known, the length must be
7217/// specified explicitly.
7218/// When the stride is absent it defaults to 1.
7219/// When the length is absent it defaults to ⌈(size − lower-bound)/stride⌉,
7220/// where size is the size of the array dimension. When the lower-bound is
7221/// absent it defaults to 0.
7222///
7223///
7224/// OpenACC 3.3 [2.7.1 Data Specification in Data Clauses]
7225/// In C and C++, a subarray is an array name followed by an extended array
7226/// range specification in brackets, with start and length, such as
7227///
7228/// AA[2:n]
7229///
7230/// If the lower bound is missing, zero is used. If the length is missing and
7231/// the array has known size, the size of the array is used; otherwise the
7232/// length is required. The subarray AA[2:n] means elements AA[2], AA[3], . . .
7233/// , AA[2+n-1]. In C and C++, a two dimensional array may be declared in at
7234/// least four ways:
7235///
7236/// -Statically-sized array: float AA[100][200];
7237/// -Pointer to statically sized rows: typedef float row[200]; row* BB;
7238/// -Statically-sized array of pointers: float* CC[200];
7239/// -Pointer to pointers: float** DD;
7240///
7241/// Each dimension may be statically sized, or a pointer to dynamically
7242/// allocated memory. Each of these may be included in a data clause using
7243/// subarray notation to specify a rectangular array:
7244///
7245/// -AA[2:n][0:200]
7246/// -BB[2:n][0:m]
7247/// -CC[2:n][0:m]
7248/// -DD[2:n][0:m]
7249///
7250/// Multidimensional rectangular subarrays in C and C++ may be specified for any
7251/// array with any combination of statically-sized or dynamically-allocated
7252/// dimensions. For statically sized dimensions, all dimensions except the first
7253/// must specify the whole extent to preserve the contiguous data restriction,
7254/// discussed below. For dynamically allocated dimensions, the implementation
7255/// will allocate pointers in device memory corresponding to the pointers in
7256/// local memory and will fill in those pointers as appropriate.
7257///
7258/// In Fortran, a subarray is an array name followed by a comma-separated list
7259/// of range specifications in parentheses, with lower and upper bound
7260/// subscripts, such as
7261///
7262/// arr(1:high,low:100)
7263///
7264/// If either the lower or upper bounds are missing, the declared or allocated
7265/// bounds of the array, if known, are used. All dimensions except the last must
7266/// specify the whole extent, to preserve the contiguous data restriction,
7267/// discussed below.
7268///
7269/// Restrictions
7270///
7271/// -In Fortran, the upper bound for the last dimension of an assumed-size dummy
7272/// array must be specified.
7273///
7274/// -In C and C++, the length for dynamically allocated dimensions of an array
7275/// must be explicitly specified.
7276///
7277/// -In C and C++, modifying pointers in pointer arrays during the data
7278/// lifetime, either on the host or on the device, may result in undefined
7279/// behavior.
7280///
7281/// -If a subarray appears in a data clause, the implementation may choose to
7282/// allocate memory for only that subarray on the accelerator.
7283///
7284/// -In Fortran, array pointers may appear, but pointer association is not
7285/// preserved in device memory.
7286///
7287/// -Any array or subarray in a data clause, including Fortran array pointers,
7288/// must be a contiguous section of memory, except for dynamic multidimensional
7289/// C arrays.
7290///
7291/// -In C and C++, if a variable or array of composite type appears, all the
7292/// data members of the struct or class are allocated and copied, as
7293/// appropriate. If a composite member is a pointer type, the data addressed by
7294/// that pointer are not implicitly copied.
7295///
7296/// -In Fortran, if a variable or array of composite type appears, all the
7297/// members of that derived type are allocated and copied, as appropriate. If
7298/// any member has the allocatable or pointer attribute, the data accessed
7299/// through that member are not copied.
7300///
7301/// -If an expression is used in a subscript or subarray expression in a clause
7302/// on a data construct, the same value is used when copying data at the end of
7303/// the data region, even if the values of variables in the expression change
7304/// during the data region.
7305class ArraySectionExpr : public Expr {
7306 friend class ASTStmtReader;
7307 friend class ASTStmtWriter;
7308
7309public:
7311
7312private:
7313 enum {
7314 BASE,
7315 LOWER_BOUND,
7316 LENGTH,
7317 STRIDE,
7318 END_EXPR,
7319 OPENACC_END_EXPR = STRIDE
7320 };
7321
7322 ArraySectionType ASType = OMPArraySection;
7323 Stmt *SubExprs[END_EXPR] = {nullptr};
7324 SourceLocation ColonLocFirst;
7325 SourceLocation ColonLocSecond;
7326 SourceLocation RBracketLoc;
7327
7328public:
7329 // Constructor for OMP array sections, which include a 'stride'.
7330 ArraySectionExpr(Expr *Base, Expr *LowerBound, Expr *Length, Expr *Stride,
7332 SourceLocation ColonLocFirst, SourceLocation ColonLocSecond,
7333 SourceLocation RBracketLoc)
7334 : Expr(ArraySectionExprClass, Type, VK, OK), ASType(OMPArraySection),
7335 ColonLocFirst(ColonLocFirst), ColonLocSecond(ColonLocSecond),
7336 RBracketLoc(RBracketLoc) {
7337 setBase(Base);
7338 setLowerBound(LowerBound);
7339 setLength(Length);
7340 setStride(Stride);
7342 }
7343
7344 // Constructor for OpenACC sub-arrays, which do not permit a 'stride'.
7347 SourceLocation RBracketLoc)
7348 : Expr(ArraySectionExprClass, Type, VK, OK), ASType(OpenACCArraySection),
7349 ColonLocFirst(ColonLoc), RBracketLoc(RBracketLoc) {
7350 setBase(Base);
7351 setLowerBound(LowerBound);
7352 setLength(Length);
7354 }
7355
7356 /// Create an empty array section expression.
7358 : Expr(ArraySectionExprClass, Shell) {}
7359
7360 /// Return original type of the base expression for array section.
7361 static QualType getBaseOriginalType(const Expr *Base);
7362
7363 /// Return the effective 'element' type of this array section. As the array
7364 /// section itself returns a collection of elements (closer to its `getBase`
7365 /// type), this is only useful for figuring out the effective type of this if
7366 /// it were a normal Array subscript expr.
7367 QualType getElementType() const;
7368
7369 /// Returns the effective 'type' of the base of this array section. This
7370 /// should be the array/pointer type that this operates on. Just
7371 /// getBase->getType isn't sufficient, since it doesn't look through existing
7372 /// Array sections to figure out the actual 'base' of this.
7373 QualType getBaseType() const;
7374
7375 static bool classof(const Stmt *T) {
7376 return T->getStmtClass() == ArraySectionExprClass;
7377 }
7378
7379 bool isOMPArraySection() const { return ASType == OMPArraySection; }
7380 bool isOpenACCArraySection() const { return ASType == OpenACCArraySection; }
7381
7382 /// Get base of the array section.
7383 Expr *getBase() { return cast<Expr>(SubExprs[BASE]); }
7384 const Expr *getBase() const { return cast<Expr>(SubExprs[BASE]); }
7385
7386 /// Get lower bound of array section.
7387 Expr *getLowerBound() { return cast_or_null<Expr>(SubExprs[LOWER_BOUND]); }
7388 const Expr *getLowerBound() const {
7389 return cast_or_null<Expr>(SubExprs[LOWER_BOUND]);
7390 }
7391
7392 /// Get length of array section.
7393 Expr *getLength() { return cast_or_null<Expr>(SubExprs[LENGTH]); }
7394 const Expr *getLength() const { return cast_or_null<Expr>(SubExprs[LENGTH]); }
7395
7396 /// Get stride of array section.
7398 assert(ASType != OpenACCArraySection &&
7399 "Stride not valid in OpenACC subarrays");
7400 return cast_or_null<Expr>(SubExprs[STRIDE]);
7401 }
7402
7403 const Expr *getStride() const {
7404 assert(ASType != OpenACCArraySection &&
7405 "Stride not valid in OpenACC subarrays");
7406 return cast_or_null<Expr>(SubExprs[STRIDE]);
7407 }
7408
7409 SourceLocation getBeginLoc() const LLVM_READONLY {
7410 return getBase()->getBeginLoc();
7411 }
7412 SourceLocation getEndLoc() const LLVM_READONLY { return RBracketLoc; }
7413
7414 SourceLocation getColonLocFirst() const { return ColonLocFirst; }
7416 assert(ASType != OpenACCArraySection &&
7417 "second colon for stride not valid in OpenACC subarrays");
7418 return ColonLocSecond;
7419 }
7420 SourceLocation getRBracketLoc() const { return RBracketLoc; }
7421
7422 SourceLocation getExprLoc() const LLVM_READONLY {
7423 return getBase()->getExprLoc();
7424 }
7425
7427 return child_range(
7428 &SubExprs[BASE],
7429 &SubExprs[ASType == OMPArraySection ? END_EXPR : OPENACC_END_EXPR]);
7430 }
7431
7433 return const_child_range(
7434 &SubExprs[BASE],
7435 &SubExprs[ASType == OMPArraySection ? END_EXPR : OPENACC_END_EXPR]);
7436 }
7437
7438private:
7439 /// Set base of the array section.
7440 void setBase(Expr *E) { SubExprs[BASE] = E; }
7441
7442 /// Set lower bound of the array section.
7443 void setLowerBound(Expr *E) { SubExprs[LOWER_BOUND] = E; }
7444
7445 /// Set length of the array section.
7446 void setLength(Expr *E) { SubExprs[LENGTH] = E; }
7447
7448 /// Set length of the array section.
7449 void setStride(Expr *E) {
7450 assert(ASType != OpenACCArraySection &&
7451 "Stride not valid in OpenACC subarrays");
7452 SubExprs[STRIDE] = E;
7453 }
7454
7455 void setColonLocFirst(SourceLocation L) { ColonLocFirst = L; }
7456
7457 void setColonLocSecond(SourceLocation L) {
7458 assert(ASType != OpenACCArraySection &&
7459 "second colon for stride not valid in OpenACC subarrays");
7460 ColonLocSecond = L;
7461 }
7462 void setRBracketLoc(SourceLocation L) { RBracketLoc = L; }
7463};
7464
7465/// This class represents temporary values used to represent inout and out
7466/// arguments in HLSL. From the callee perspective these parameters are more or
7467/// less __restrict__ T&. They are guaranteed to not alias any memory. inout
7468/// parameters are initialized by the caller, and out parameters are references
7469/// to uninitialized memory.
7470///
7471/// In the caller, the argument expression creates a temporary in local memory
7472/// and the address of the temporary is passed into the callee. There may be
7473/// implicit conversion sequences to initialize the temporary, and on expiration
7474/// of the temporary an inverse conversion sequence is applied as a write-back
7475/// conversion to the source l-value.
7476///
7477/// This AST node has three sub-expressions:
7478/// - An OpaqueValueExpr with a source that is the argument lvalue expression.
7479/// - An OpaqueValueExpr with a source that is an implicit conversion
7480/// sequence from the source lvalue to the argument type.
7481/// - An expression that assigns the second expression into the first,
7482/// performing any necessary conversions.
7483class HLSLOutArgExpr : public Expr {
7484 friend class ASTStmtReader;
7485
7486 enum {
7487 BaseLValue,
7488 CastedTemporary,
7489 WritebackCast,
7490 NumSubExprs,
7491 };
7492
7493 Stmt *SubExprs[NumSubExprs];
7494 bool IsInOut;
7495
7497 Expr *WB, bool IsInOut)
7498 : Expr(HLSLOutArgExprClass, Ty, VK_LValue, OK_Ordinary),
7499 IsInOut(IsInOut) {
7500 SubExprs[BaseLValue] = B;
7501 SubExprs[CastedTemporary] = OpV;
7502 SubExprs[WritebackCast] = WB;
7503 assert(!Ty->isDependentType() && "HLSLOutArgExpr given a dependent type!");
7504 }
7505
7506 explicit HLSLOutArgExpr(EmptyShell Shell)
7507 : Expr(HLSLOutArgExprClass, Shell) {}
7508
7509public:
7510 static HLSLOutArgExpr *Create(const ASTContext &C, QualType Ty,
7511 OpaqueValueExpr *Base, OpaqueValueExpr *OpV,
7512 Expr *WB, bool IsInOut);
7513 static HLSLOutArgExpr *CreateEmpty(const ASTContext &Ctx);
7514
7516 return cast<OpaqueValueExpr>(SubExprs[BaseLValue]);
7517 }
7519 return cast<OpaqueValueExpr>(SubExprs[BaseLValue]);
7520 }
7521
7522 /// Return the l-value expression that was written as the argument
7523 /// in source. Everything else here is implicitly generated.
7524 const Expr *getArgLValue() const {
7526 }
7528
7529 const Expr *getWritebackCast() const {
7530 return cast<Expr>(SubExprs[WritebackCast]);
7531 }
7532 Expr *getWritebackCast() { return cast<Expr>(SubExprs[WritebackCast]); }
7533
7535 return cast<OpaqueValueExpr>(SubExprs[CastedTemporary]);
7536 }
7538 return cast<OpaqueValueExpr>(SubExprs[CastedTemporary]);
7539 }
7540
7541 /// returns true if the parameter is inout and false if the parameter is out.
7542 bool isInOut() const { return IsInOut; }
7543
7544 SourceLocation getBeginLoc() const LLVM_READONLY {
7545 return SubExprs[BaseLValue]->getBeginLoc();
7546 }
7547
7548 SourceLocation getEndLoc() const LLVM_READONLY {
7549 return SubExprs[BaseLValue]->getEndLoc();
7550 }
7551
7552 static bool classof(const Stmt *T) {
7553 return T->getStmtClass() == HLSLOutArgExprClass;
7554 }
7555
7556 // Iterators
7558 return child_range(&SubExprs[BaseLValue], &SubExprs[NumSubExprs]);
7559 }
7560};
7561
7562/// Frontend produces RecoveryExprs on semantic errors that prevent creating
7563/// other well-formed expressions. E.g. when type-checking of a binary operator
7564/// fails, we cannot produce a BinaryOperator expression. Instead, we can choose
7565/// to produce a recovery expression storing left and right operands.
7566///
7567/// RecoveryExpr does not have any semantic meaning in C++, it is only useful to
7568/// preserve expressions in AST that would otherwise be dropped. It captures
7569/// subexpressions of some expression that we could not construct and source
7570/// range covered by the expression.
7571///
7572/// By default, RecoveryExpr uses dependence-bits to take advantage of existing
7573/// machinery to deal with dependent code in C++, e.g. RecoveryExpr is preserved
7574/// in `decltype(<broken-expr>)` as part of the `DependentDecltypeType`. In
7575/// addition to that, clang does not report most errors on dependent
7576/// expressions, so we get rid of bogus errors for free. However, note that
7577/// unlike other dependent expressions, RecoveryExpr can be produced in
7578/// non-template contexts.
7579///
7580/// We will preserve the type in RecoveryExpr when the type is known, e.g.
7581/// preserving the return type for a broken non-overloaded function call, a
7582/// overloaded call where all candidates have the same return type. In this
7583/// case, the expression is not type-dependent (unless the known type is itself
7584/// dependent)
7585///
7586/// One can also reliably suppress all bogus errors on expressions containing
7587/// recovery expressions by examining results of Expr::containsErrors().
7588class RecoveryExpr final : public Expr,
7589 private llvm::TrailingObjects<RecoveryExpr, Expr *> {
7590public:
7591 static RecoveryExpr *Create(ASTContext &Ctx, QualType T,
7592 SourceLocation BeginLoc, SourceLocation EndLoc,
7593 ArrayRef<Expr *> SubExprs);
7594 static RecoveryExpr *CreateEmpty(ASTContext &Ctx, unsigned NumSubExprs);
7595
7596 ArrayRef<Expr *> subExpressions() { return getTrailingObjects(NumExprs); }
7597
7599 return const_cast<RecoveryExpr *>(this)->subExpressions();
7600 }
7601
7603 Stmt **B = reinterpret_cast<Stmt **>(getTrailingObjects());
7604 return child_range(B, B + NumExprs);
7605 }
7606
7607 SourceLocation getBeginLoc() const { return BeginLoc; }
7608 SourceLocation getEndLoc() const { return EndLoc; }
7609
7610 static bool classof(const Stmt *T) {
7611 return T->getStmtClass() == RecoveryExprClass;
7612 }
7613
7614private:
7616 SourceLocation EndLoc, ArrayRef<Expr *> SubExprs);
7617 RecoveryExpr(EmptyShell Empty, unsigned NumSubExprs)
7618 : Expr(RecoveryExprClass, Empty), NumExprs(NumSubExprs) {}
7619
7620 size_t numTrailingObjects(OverloadToken<Stmt *>) const { return NumExprs; }
7621
7622 SourceLocation BeginLoc, EndLoc;
7623 unsigned NumExprs;
7624 friend TrailingObjects;
7625 friend class ASTStmtReader;
7626 friend class ASTStmtWriter;
7627};
7628
7629/// Insertion operator for diagnostics. This allows sending
7630/// Expr into a diagnostic with <<.
7632 const Expr *E) {
7633 DB.AddTaggedVal(reinterpret_cast<uint64_t>(E), DiagnosticsEngine::ak_expr);
7634 return DB;
7635}
7636
7637/// Walk @p E through parens, implicit casts, unary &/*, array subscripts and
7638/// comma operators to find the head of a struct-field access -- typically a
7639/// MemberExpr, or an LValueToRValue ImplicitCastExpr over a pointer-typed
7640/// field. Returns nullptr for shapes we don't handle (multiple subscripts,
7641/// non-comma binary ops, or '&fam' on an array lvalue which designates the
7642/// array-as-a-whole rather than an element pointer).
7643///
7644/// If @p OutArrayIndex / @p OutArrayElementTy are non-null, they receive the
7645/// index expression and base array type for forms like '&p->fam[idx]'.
7646///
7647/// Shared by CGBuiltin's __builtin_*_object_size lowering and the AST
7648/// constant evaluator so they recognize the same 'counted_by' access shapes.
7649const Expr *findStructFieldAccess(const Expr *E,
7650 const Expr **OutArrayIndex = nullptr,
7651 QualType *OutArrayElementTy = nullptr);
7652
7653} // end namespace clang
7654
7655#endif // LLVM_CLANG_AST_EXPR_H
#define V(N, I)
#define PTR(CLASS)
Definition AttrVisitor.h:27
Defines enumerations for traits support.
static bool CanThrow(Expr *E, ASTContext &Ctx)
Definition CFG.cpp:2854
clang::CharUnits operator*(clang::CharUnits::QuantityType Scale, clang::CharUnits CU)
Definition CharUnits.h:194
Defines the clang::LangOptions interface.
static DiagnosticBuilder Diag(DiagnosticsEngine *Diags, const LangOptions &Features, FullSourceLoc TokLoc, const char *TokBegin, const char *TokRangeBegin, const char *TokRangeEnd, unsigned DiagID)
Produce a diagnostic highlighting some portion of a literal.
*collection of selector each with an associated kind and an ordered *collection of selectors A selector has a kind
Provides definitions for the atomic synchronization scopes.
C Language Family Type Representation.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition ASTContext.h:245
a trap message and trap category.
llvm::APFloat getValue(const llvm::fltSemantics &Semantics) const
void setValue(const ASTContext &C, const llvm::APFloat &Val)
unsigned getBitWidth() const
void setValue(const ASTContext &C, const llvm::APInt &Val)
llvm::APInt getValue() const
APValue - This class implements a discriminated union of [uninitialized] [APSInt] [APFloat],...
Definition APValue.h:158
@ None
There is no such object (it's outside its lifetime).
Definition APValue.h:165
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition ASTContext.h:245
std::reverse_iterator< iterator > reverse_iterator
Definition ASTVector.h:89
std::reverse_iterator< const_iterator > const_reverse_iterator
Definition ASTVector.h:88
const Stmt ** const_iterator
Definition ASTVector.h:86
AbstractConditionalOperator(StmtClass SC, EmptyShell Empty)
Definition Expr.h:4432
SourceLocation getColonLoc() const
Definition Expr.h:4450
Expr * getCond() const
getCond - Return the expression representing the condition for the ?
Definition Expr.h:4600
static bool classof(const Stmt *T)
Definition Expr.h:4452
AbstractConditionalOperator(StmtClass SC, QualType T, ExprValueKind VK, ExprObjectKind OK, SourceLocation qloc, SourceLocation cloc)
Definition Expr.h:4427
Expr * getTrueExpr() const
getTrueExpr - Return the subexpression representing the value of the expression if the condition eval...
Definition Expr.h:4606
SourceLocation getQuestionLoc() const
Definition Expr.h:4449
Expr * getFalseExpr() const
getFalseExpr - Return the subexpression representing the value of the expression if the condition eva...
Definition Expr.h:4612
SourceLocation getAmpAmpLoc() const
Definition Expr.h:4634
static bool classof(const Stmt *T)
Definition Expr.h:4645
void setLabel(LabelDecl *L)
Definition Expr.h:4643
child_range children()
Definition Expr.h:4650
void setLabelLoc(SourceLocation L)
Definition Expr.h:4637
AddrLabelExpr(SourceLocation AALoc, SourceLocation LLoc, LabelDecl *L, QualType t)
Definition Expr.h:4623
void setAmpAmpLoc(SourceLocation L)
Definition Expr.h:4635
SourceLocation getEndLoc() const LLVM_READONLY
Definition Expr.h:4640
AddrLabelExpr(EmptyShell Empty)
Build an empty address of a label expression.
Definition Expr.h:4631
SourceLocation getLabelLoc() const
Definition Expr.h:4636
const_child_range children() const
Definition Expr.h:4653
SourceLocation getBeginLoc() const LLVM_READONLY
Definition Expr.h:4639
LabelDecl * getLabel() const
Definition Expr.h:4642
const_child_range children() const
Definition Expr.h:6127
ArrayInitIndexExpr(QualType T)
Definition Expr.h:6112
SourceLocation getBeginLoc() const LLVM_READONLY
Definition Expr.h:6121
friend class ASTReader
Definition Expr.h:6131
static bool classof(const Stmt *S)
Definition Expr.h:6117
child_range children()
Definition Expr.h:6124
SourceLocation getEndLoc() const LLVM_READONLY
Definition Expr.h:6122
friend class ASTStmtReader
Definition Expr.h:6132
child_range children()
Definition Expr.h:6092
ArrayInitLoopExpr(QualType T, Expr *CommonInit, Expr *ElementInit)
Definition Expr.h:6061
const_child_range children() const
Definition Expr.h:6095
llvm::APInt getArraySize() const
Definition Expr.h:6076
SourceLocation getEndLoc() const LLVM_READONLY
Definition Expr.h:6088
static bool classof(const Stmt *S)
Definition Expr.h:6081
friend class ASTReader
Definition Expr.h:6099
SourceLocation getBeginLoc() const LLVM_READONLY
Definition Expr.h:6085
OpaqueValueExpr * getCommonExpr() const
Get the common subexpression shared by all initializations (the source array).
Definition Expr.h:6069
Expr * getSubExpr() const
Get the initializer to use for each array element.
Definition Expr.h:6074
friend class ASTStmtWriter
Definition Expr.h:6101
friend class ASTStmtReader
Definition Expr.h:6100
const Expr * getStride() const
Definition Expr.h:7403
QualType getElementType() const
Return the effective 'element' type of this array section.
Definition Expr.cpp:5470
SourceLocation getRBracketLoc() const
Definition Expr.h:7420
const_child_range children() const
Definition Expr.h:7432
Expr * getBase()
Get base of the array section.
Definition Expr.h:7383
static bool classof(const Stmt *T)
Definition Expr.h:7375
SourceLocation getEndLoc() const LLVM_READONLY
Definition Expr.h:7412
Expr * getLength()
Get length of array section.
Definition Expr.h:7393
static QualType getBaseOriginalType(const Expr *Base)
Return original type of the base expression for array section.
Definition Expr.cpp:5442
SourceLocation getExprLoc() const LLVM_READONLY
Definition Expr.h:7422
const Expr * getLowerBound() const
Definition Expr.h:7388
bool isOMPArraySection() const
Definition Expr.h:7379
Expr * getStride()
Get stride of array section.
Definition Expr.h:7397
const Expr * getBase() const
Definition Expr.h:7384
ArraySectionExpr(Expr *Base, Expr *LowerBound, Expr *Length, QualType Type, ExprValueKind VK, ExprObjectKind OK, SourceLocation ColonLoc, SourceLocation RBracketLoc)
Definition Expr.h:7345
const Expr * getLength() const
Definition Expr.h:7394
ArraySectionExpr(EmptyShell Shell)
Create an empty array section expression.
Definition Expr.h:7357
friend class ASTStmtWriter
Definition Expr.h:7307
ArraySectionExpr(Expr *Base, Expr *LowerBound, Expr *Length, Expr *Stride, QualType Type, ExprValueKind VK, ExprObjectKind OK, SourceLocation ColonLocFirst, SourceLocation ColonLocSecond, SourceLocation RBracketLoc)
Definition Expr.h:7330
SourceLocation getColonLocSecond() const
Definition Expr.h:7415
Expr * getLowerBound()
Get lower bound of array section.
Definition Expr.h:7387
QualType getBaseType() const
Returns the effective 'type' of the base of this array section.
Definition Expr.cpp:5488
child_range children()
Definition Expr.h:7426
friend class ASTStmtReader
Definition Expr.h:7306
SourceLocation getBeginLoc() const LLVM_READONLY
Definition Expr.h:7409
bool isOpenACCArraySection() const
Definition Expr.h:7380
SourceLocation getColonLocFirst() const
Definition Expr.h:7414
ArraySubscriptExpr(Expr *lhs, Expr *rhs, QualType t, ExprValueKind VK, ExprObjectKind OK, SourceLocation rbracketloc)
Definition Expr.h:2797
SourceLocation getExprLoc() const LLVM_READONLY
Definition Expr.h:2845
const Expr * getLHS() const
Definition Expr.h:2820
const_child_range children() const
Definition Expr.h:2857
const Expr * getBase() const
Definition Expr.h:2828
SourceLocation getRBracketLoc() const
Definition Expr.h:2838
const Expr * getRHS() const
Definition Expr.h:2824
Expr * getLHS()
An array access can be written A[4] or 4[A] (both are equivalent).
Definition Expr.h:2819
void setRHS(Expr *E)
Definition Expr.h:2825
SourceLocation getBeginLoc() const LLVM_READONLY
Definition Expr.h:2833
const Expr * getIdx() const
Definition Expr.h:2831
SourceLocation getEndLoc() const
Definition Expr.h:2836
void setRBracketLoc(SourceLocation L)
Definition Expr.h:2841
child_range children()
Definition Expr.h:2854
static bool classof(const Stmt *T)
Definition Expr.h:2849
void setLHS(Expr *E)
Definition Expr.h:2821
ArraySubscriptExpr(EmptyShell Shell)
Create an empty array subscript expression.
Definition Expr.h:2807
Expr * getSrcExpr() const
getSrcExpr - Return the Expr to be converted.
Definition Expr.h:6838
SourceLocation getEndLoc() const LLVM_READONLY
Definition Expr.h:6847
AsTypeExpr(Expr *SrcExpr, QualType DstType, ExprValueKind VK, ExprObjectKind OK, SourceLocation BuiltinLoc, SourceLocation RParenLoc)
Definition Expr.h:6829
SourceLocation getBuiltinLoc() const
getBuiltinLoc - Return the location of the __builtin_astype token.
Definition Expr.h:6841
const_child_range children() const
Definition Expr.h:6855
SourceLocation getBeginLoc() const LLVM_READONLY
Definition Expr.h:6846
friend class ASTReader
Definition Expr.h:6824
SourceLocation getRParenLoc() const
getRParenLoc - Return the location of final right parenthesis.
Definition Expr.h:6844
static bool classof(const Stmt *T)
Definition Expr.h:6849
friend class ASTStmtReader
Definition Expr.h:6825
child_range children()
Definition Expr.h:6854
Expr ** getSubExprs()
Definition Expr.h:7089
static std::unique_ptr< AtomicScopeModel > getScopeModel(AtomicOp Op)
Get atomic scope model for the atomic op code.
Definition Expr.h:7163
Expr * getVal2() const
Definition Expr.h:7065
SourceLocation getRParenLoc() const
Definition Expr.h:7143
Expr * getOrder() const
Definition Expr.h:7048
SourceLocation getEndLoc() const LLVM_READONLY
Definition Expr.h:7146
QualType getValueType() const
Definition Expr.cpp:5435
Expr * getScope() const
Definition Expr.h:7051
bool isCmpXChg() const
Definition Expr.h:7098
bool isHIP() const
Definition Expr.h:7131
AtomicOp getOp() const
Definition Expr.h:7077
bool isOpenCL() const
Definition Expr.h:7126
AtomicExpr(EmptyShell Empty)
Build an empty AtomicExpr.
Definition Expr.h:7043
Expr * getVal1() const
Definition Expr.h:7055
child_range children()
Definition Expr.h:7153
StringRef getOpAsString() const
Definition Expr.h:7078
bool threadPrivateMemoryAtomicsAreUndefined() const
Return true if atomics operations targeting allocations in private memory are undefined.
Definition Expr.h:7138
const Expr *const * getSubExprs() const
Definition Expr.h:7090
Expr * getPtr() const
Definition Expr.h:7045
std::unique_ptr< AtomicScopeModel > getScopeModel() const
Get atomic scope model.
Definition Expr.h:7179
Expr * getWeak() const
Definition Expr.h:7071
const_child_range children() const
Definition Expr.h:7156
SourceLocation getBeginLoc() const LLVM_READONLY
Definition Expr.h:7145
AtomicExpr(SourceLocation BLoc, ArrayRef< Expr * > args, QualType t, AtomicOp op, SourceLocation RP)
Definition Expr.cpp:5308
friend class ASTStmtReader
Definition Expr.h:7033
SourceLocation getBuiltinLoc() const
Definition Expr.h:7142
Expr * getOrderFail() const
Definition Expr.h:7061
bool hasVal1Operand() const
Definition Expr.h:7111
unsigned getNumSubExprs() const
Definition Expr.h:7087
static bool classof(const Stmt *T)
Definition Expr.h:7148
bool isVolatile() const
Definition Expr.h:7094
static std::unique_ptr< AtomicScopeModel > create(AtomicScopeModelKind K)
Create an atomic scope model by AtomicScopeModelKind.
Definition SyncScope.h:299
static bool classof(const Stmt *T)
Definition Expr.h:4587
BinaryConditionalOperator(Expr *common, OpaqueValueExpr *opaqueValue, Expr *cond, Expr *lhs, Expr *rhs, SourceLocation qloc, SourceLocation cloc, QualType t, ExprValueKind VK, ExprObjectKind OK)
Definition Expr.h:4535
const_child_range children() const
Definition Expr.h:4595
SourceLocation getBeginLoc() const LLVM_READONLY
Definition Expr.h:4580
Expr * getFalseExpr() const
getFalseExpr - Return the subexpression which will be evaluated if the condition evaluates to false; ...
Definition Expr.h:4576
BinaryConditionalOperator(EmptyShell Empty)
Build an empty conditional operator.
Definition Expr.h:4551
OpaqueValueExpr * getOpaqueValue() const
getOpaqueValue - Return the opaque value placeholder.
Definition Expr.h:4560
SourceLocation getEndLoc() const LLVM_READONLY
Definition Expr.h:4583
Expr * getCond() const
getCond - Return the condition expression; this is defined in terms of the opaque value.
Definition Expr.h:4564
Expr * getTrueExpr() const
getTrueExpr - Return the subexpression which will be evaluated if the condition evaluates to true; th...
Definition Expr.h:4569
Expr * getCommon() const
getCommon - Return the common expression, written to the left of the condition.
Definition Expr.h:4557
A builtin binary operation expression such as "x + y" or "x <= y".
Definition Expr.h:4107
static bool isLogicalOp(Opcode Opc)
Definition Expr.h:4240
void setLHS(Expr *E)
Definition Expr.h:4158
Expr * getLHS() const
Definition Expr.h:4157
child_range children()
Definition Expr.h:4282
BinaryOperator(EmptyShell Empty)
Construct an empty binary operator.
Definition Expr.h:4136
static bool isRelationalOp(Opcode Opc)
Definition Expr.h:4201
static OverloadedOperatorKind getOverloadedOperator(Opcode Opc)
Retrieve the overloaded operator kind that corresponds to the given binary opcode.
Definition Expr.cpp:2217
const FPOptionsOverride * getTrailingFPFeatures() const
Definition Expr.h:4123
const_child_range children() const
Definition Expr.h:4285
static bool isComparisonOp(Opcode Opc)
Definition Expr.h:4207
void setHasStoredFPFeatures(bool B)
Set and fetch the bit that shows whether FPFeatures needs to be allocated in Trailing Storage.
Definition Expr.h:4291
void setOperatorLoc(SourceLocation L)
Definition Expr.h:4150
static bool isShiftOp(Opcode Opc)
Definition Expr.h:4195
bool isComparisonOp() const
Definition Expr.h:4208
FPOptionsOverride getStoredFPFeaturesOrDefault() const
Get the store FPOptionsOverride or default if not stored.
Definition Expr.h:4314
StringRef getOpcodeStr() const
Definition Expr.h:4173
static bool isCommaOp(Opcode Opc)
Definition Expr.h:4210
static Opcode getOpForCompoundAssignment(Opcode Opc)
Definition Expr.h:4254
SourceLocation getBeginLoc() const LLVM_READONLY
Definition Expr.h:4162
FPOptionsOverride * getTrailingFPFeatures()
Return a pointer to the trailing FPOptions.
Definition Expr.h:4118
bool isRelationalOp() const
Definition Expr.h:4202
void setRHS(Expr *E)
Definition Expr.h:4160
SourceLocation getOperatorLoc() const
Definition Expr.h:4149
bool isPtrMemOp() const
Definition Expr.h:4187
bool isFEnvAccessOn(const LangOptions &LO) const
Get the FENV_ACCESS status of this operator.
Definition Expr.h:4341
bool hasStoredFPFeatures() const
Definition Expr.h:4292
bool isCompoundAssignmentOp() const
Definition Expr.h:4251
static Opcode negateComparisonOp(Opcode Opc)
Definition Expr.h:4213
bool isLogicalOp() const
Definition Expr.h:4241
bool isMultiplicativeOp() const
Definition Expr.h:4192
SourceLocation getExprLoc() const
Definition Expr.h:4148
static Opcode reverseComparisonOp(Opcode Opc)
Definition Expr.h:4226
static bool isShiftAssignOp(Opcode Opc)
Definition Expr.h:4262
bool isFPContractableWithinStatement(const LangOptions &LO) const
Get the FP contractibility status of this operator.
Definition Expr.h:4335
bool isShiftOp() const
Definition Expr.h:4196
Expr * getRHS() const
Definition Expr.h:4159
static unsigned sizeOfTrailingObjects(bool HasFPFeatures)
Return the size in bytes needed for the trailing objects.
Definition Expr.h:4358
bool isEqualityOp() const
Definition Expr.h:4205
BinaryOperator(StmtClass SC, EmptyShell Empty)
Construct an empty BinaryOperator, SC is CompoundAssignOperator.
Definition Expr.h:4352
void setExcludedOverflowPattern(bool B)
Set and get the bit that informs arithmetic overflow sanitizers whether or not they should exclude ce...
Definition Expr.h:4296
bool isBitwiseOp() const
Definition Expr.h:4199
static BinaryOperator * CreateEmpty(const ASTContext &C, bool hasFPFeatures)
Definition Expr.cpp:5136
FPOptionsOverride getStoredFPFeatures() const
Get FPFeatures from trailing storage.
Definition Expr.h:4304
static bool classof(const Stmt *S)
Definition Expr.h:4276
bool isAdditiveOp() const
Definition Expr.h:4194
static bool isAdditiveOp(Opcode Opc)
Definition Expr.h:4193
static bool isPtrMemOp(Opcode Opc)
predicates to categorize the respective opcodes.
Definition Expr.h:4184
static bool isAssignmentOp(Opcode Opc)
Definition Expr.h:4243
static bool isCompoundAssignmentOp(Opcode Opc)
Definition Expr.h:4248
bool isShiftAssignOp() const
Definition Expr.h:4265
SourceLocation getEndLoc() const LLVM_READONLY
Definition Expr.h:4165
FPOptions getFPFeaturesInEffect(const LangOptions &LO) const
Get the FP features status of this operator.
Definition Expr.h:4320
static bool isNullPointerArithmeticExtension(ASTContext &Ctx, Opcode Opc, const Expr *LHS, const Expr *RHS)
Return true if a binary operator using the specified opcode and operands would match the 'p = (i8*)nu...
Definition Expr.cpp:2242
Opcode getOpcode() const
Definition Expr.h:4152
void setStoredFPFeatures(FPOptionsOverride F)
Set FPFeatures in trailing storage, used only by Serialization.
Definition Expr.h:4309
FPOptionsOverride getFPFeatures() const
Definition Expr.h:4327
bool isCommaOp() const
Definition Expr.h:4211
bool isAssignmentOp() const
Definition Expr.h:4246
static Opcode getOverloadedOpcode(OverloadedOperatorKind OO)
Retrieve the binary opcode that corresponds to the given overloaded operator.
Definition Expr.cpp:2179
size_t offsetOfTrailingStorage() const
Definition Expr.h:4414
static bool isEqualityOp(Opcode Opc)
Definition Expr.h:4204
bool hasExcludedOverflowPattern() const
Definition Expr.h:4299
void setOpcode(Opcode Opc)
Definition Expr.h:4155
static bool isBitwiseOp(Opcode Opc)
Definition Expr.h:4198
static bool isMultiplicativeOp(Opcode Opc)
Definition Expr.h:4189
BinaryOperator(const ASTContext &Ctx, Expr *lhs, Expr *rhs, Opcode opc, QualType ResTy, ExprValueKind VK, ExprObjectKind OK, SourceLocation opLoc, FPOptionsOverride FPFeatures)
Build a binary operator, assuming that appropriate storage has been allocated for the trailing object...
Definition Expr.cpp:5099
BinaryOperatorKind Opcode
Definition Expr.h:4112
Represents a block literal declaration, which is like an unnamed FunctionDecl.
Definition Decl.h:4826
BlockExpr(EmptyShell Empty)
Build an empty block expression.
Definition Expr.h:6768
SourceLocation getCaretLocation() const
Definition Expr.cpp:2577
SourceLocation getBeginLoc() const LLVM_READONLY
Definition Expr.h:6779
BlockDecl * TheBlock
Definition Expr.h:6760
child_range children()
Definition Expr.h:6794
BlockDecl * getBlockDecl()
Definition Expr.h:6771
const Stmt * getBody() const
Definition Expr.cpp:2580
BlockExpr(BlockDecl *BD, QualType ty, bool ContainsUnexpandedParameterPack)
Definition Expr.h:6762
const_child_range children() const
Definition Expr.h:6797
SourceLocation getEndLoc() const LLVM_READONLY
Definition Expr.h:6782
void setBlockDecl(BlockDecl *BD)
Definition Expr.h:6772
static bool classof(const Stmt *T)
Definition Expr.h:6789
const FunctionProtoType * getFunctionType() const
getFunctionType - Return the underlying function type for this block.
Definition Expr.cpp:2571
const BlockDecl * getBlockDecl() const
Definition Expr.h:6770
This class is used for builtin types like 'int'.
Definition TypeBase.h:3245
static bool isPlaceholderTypeKind(Kind K)
Determines whether the given kind corresponds to a placeholder type.
Definition TypeBase.h:3333
SourceLocation getRParenLoc() const
Definition Expr.h:4073
static CStyleCastExpr * CreateEmpty(const ASTContext &Context, unsigned PathSize, bool HasFPFeatures)
Definition Expr.cpp:2159
SourceLocation getBeginLoc() const LLVM_READONLY
Definition Expr.h:4076
friend class CastExpr
Definition Expr.h:4086
void setRParenLoc(SourceLocation L)
Definition Expr.h:4074
static bool classof(const Stmt *T)
Definition Expr.h:4081
friend TrailingObjects
Definition Expr.h:4085
SourceLocation getLParenLoc() const
Definition Expr.h:4070
SourceLocation getEndLoc() const LLVM_READONLY
Definition Expr.h:4077
void setLParenLoc(SourceLocation L)
Definition Expr.h:4071
Represents a base class of a C++ class.
Definition DeclCXX.h:146
Represents a call to a member function that may be written either with member call syntax (e....
Definition ExprCXX.h:184
A call to an overloaded operator written using operator syntax.
Definition ExprCXX.h:86
Represents a C++ struct/union/class.
Definition DeclCXX.h:258
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
Definition Expr.h:3012
Expr * getArg(unsigned Arg)
getArg - Return the specified argument.
Definition Expr.h:3216
bool hasStoredFPFeatures() const
Definition Expr.h:3171
const FPOptionsOverride * getTrailingFPFeatures() const
Definition Expr.h:3123
bool usesMemberSyntax() const
Definition Expr.h:3173
std::optional< llvm::APInt > evaluateBytesReturnedByAllocSizeCall(const ASTContext &Ctx) const
Evaluates the total size in bytes allocated by calling a function decorated with alloc_size.
Definition Expr.cpp:3641
static unsigned sizeOfTrailingObjects(unsigned NumPreArgs, unsigned NumArgs, bool HasFPFeatures)
Return the size in bytes needed for the trailing objects.
Definition Expr.h:3095
static constexpr ADLCallKind NotADL
Definition Expr.h:3078
bool usesADL() const
Definition Expr.h:3169
const Stmt * getPreArg(unsigned I) const
Definition Expr.h:3105
SourceLocation getBeginLoc() const
Definition Expr.h:3346
void setRParenLoc(SourceLocation L)
Definition Expr.h:3344
const_arg_iterator arg_begin() const
Definition Expr.h:3274
static bool classof(const Stmt *T)
Definition Expr.h:3409
llvm::iterator_range< const_arg_iterator > const_arg_range
Definition Expr.h:3262
void setCoroElideSafe(bool V=true)
Definition Expr.h:3187
const Expr *const * getArgs() const
Definition Expr.h:3210
void setArg(unsigned Arg, Expr *ArgExpr)
setArg - Set the specified argument.
Definition Expr.h:3229
ConstExprIterator const_arg_iterator
Definition Expr.h:3260
ExprIterator arg_iterator
Definition Expr.h:3259
child_range children()
Definition Expr.h:3415
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 Expr.h:3334
void setADLCallKind(ADLCallKind V=UsesADL)
Definition Expr.h:3166
const AllocSizeAttr * getCalleeAllocSizeAttr() const
Try to get the alloc_size attribute of the callee. May return null.
Definition Expr.cpp:3632
llvm::iterator_range< arg_iterator > arg_range
Definition Expr.h:3261
const_arg_range arguments() const
Definition Expr.h:3265
unsigned getBuiltinCallee() const
getBuiltinCallee - If this is a call to a builtin, return the builtin ID of the callee.
Definition Expr.cpp:1624
arg_iterator arg_begin()
Definition Expr.h:3269
FPOptionsOverride getStoredFPFeaturesOrDefault() const
Get the store FPOptionsOverride or default if not stored.
Definition Expr.h:3299
FPOptionsOverride getStoredFPFeatures() const
Get FPOptionsOverride from trailing storage.
Definition Expr.h:3288
arg_iterator arg_end()
Definition Expr.h:3272
FunctionDecl * getDirectCallee()
If the callee is a FunctionDecl, return it. Otherwise return null.
Definition Expr.h:3195
static CallExpr * CreateEmpty(const ASTContext &Ctx, unsigned NumArgs, bool HasFPFeatures, EmptyShell Empty)
Create an empty call expression, for deserialization.
Definition Expr.cpp:1567
bool isCallToStdMove() const
Definition Expr.cpp:3682
void setUsesMemberSyntax(bool V=true)
Definition Expr.h:3176
void setPreArg(unsigned I, Stmt *PreArg)
Definition Expr.h:3109
ADLCallKind getADLCallKind() const
Definition Expr.h:3163
Expr * getCallee()
Definition Expr.h:3159
FPOptionsOverride getFPFeatures() const
Definition Expr.h:3311
static constexpr unsigned OffsetToTrailingObjects
Definition Expr.h:3049
void markDependentForPostponedNameLookup()
Used by Sema to implement MSVC-compatible delayed name lookup.
Definition Expr.h:3394
const Expr * getCallee() const
Definition Expr.h:3160
const Decl * getCalleeDecl() const
Definition Expr.h:3190
void computeDependence()
Compute and set dependence bits.
Definition Expr.h:3235
void setStoredFPFeatures(FPOptionsOverride F)
Set FPOptionsOverride in trailing storage. Used only by Serialization.
Definition Expr.h:3293
unsigned getNumArgs() const
getNumArgs - Return the number of actual arguments to this call.
Definition Expr.h:3203
FPOptions getFPFeaturesInEffect(const LangOptions &LO) const
Get the FP features status of this operator.
Definition Expr.h:3305
bool isCoroElideSafe() const
Definition Expr.h:3186
Expr ** getArgs()
Retrieve the call arguments.
Definition Expr.h:3206
const_child_range children() const
Definition Expr.h:3420
CallExpr(StmtClass SC, Expr *Fn, ArrayRef< Expr * > PreArgs, ArrayRef< Expr * > Args, QualType Ty, ExprValueKind VK, SourceLocation RParenLoc, FPOptionsOverride FPFeatures, unsigned MinNumArgs, ADLCallKind UsesADL)
Build a call expression, assuming that appropriate storage has been allocated for the trailing object...
Definition Expr.cpp:1505
arg_range arguments()
Definition Expr.h:3264
static constexpr unsigned sizeToAllocateForCallExprSubclass(unsigned SizeOfTrailingObjects)
Definition Expr.h:3052
SourceLocation getEndLoc() const
Definition Expr.h:3365
SourceLocation getRParenLoc() const
Definition Expr.h:3343
static constexpr ADLCallKind UsesADL
Definition Expr.h:3079
bool isBuiltinAssumeFalse(const ASTContext &Ctx) const
Return true if this is a call to __assume() or __builtin_assume() with a non-value-dependent constant...
Definition Expr.cpp:3620
const_arg_iterator arg_end() const
Definition Expr.h:3277
const FunctionDecl * getDirectCallee() const
Definition Expr.h:3198
Stmt * getPreArg(unsigned I)
Definition Expr.h:3101
friend class ASTStmtReader
Definition Expr.h:3368
FPOptionsOverride * getTrailingFPFeatures()
Return a pointer to the trailing FPOptions.
Definition Expr.h:3117
Decl * getCalleeDecl()
Definition Expr.h:3189
QualType getCallReturnType(const ASTContext &Ctx) const
getCallReturnType - Get the return type of the call expr.
Definition Expr.cpp:1635
bool isUnevaluatedBuiltinCall(const ASTContext &Ctx) const
Returns true if this is a call to a builtin which does not evaluate side-effects within its arguments...
Definition Expr.cpp:1629
void setNumArgsUnsafe(unsigned NewNumArgs)
Bluntly set a new number of arguments without doing any checks whatsoever.
Definition Expr.h:3257
void setCallee(Expr *F)
Definition Expr.h:3161
unsigned getNumPreArgs() const
Definition Expr.h:3114
ArrayRef< Stmt * > getRawSubExprs() const
This method provides fast access to all the subexpressions of a CallExpr without going through the sl...
Definition Expr.h:3283
bool hasUnusedResultAttr(const ASTContext &Ctx) const
Returns true if this call expression should warn on unused results.
Definition Expr.h:3339
void shrinkNumArgs(unsigned NewNumArgs)
Reduce the number of arguments in this call expression.
Definition Expr.h:3248
const Expr * getArg(unsigned Arg) const
Definition Expr.h:3220
CastExpr - Base class for type casts, including both implicit casts (ImplicitCastExpr) and explicit c...
Definition Expr.h:3745
FPOptionsOverride * getTrailingFPFeatures()
Return a pointer to the trailing FPOptions.
Definition Expr.cpp:2089
path_iterator path_begin()
Definition Expr.h:3815
unsigned path_size() const
Definition Expr.h:3814
NamedDecl * getConversionFunction() const
If this cast applies a user-defined conversion, retrieve the conversion function that it invokes.
Definition Expr.cpp:2038
const Expr * getSubExprAsWritten() const
Definition Expr.h:3803
Expr * getSubExprAsWritten()
Retrieve the cast subexpression as it was written in the source code, looking through any implicit ca...
Definition Expr.cpp:2016
CastKind getCastKind() const
Definition Expr.h:3789
void setCastKind(CastKind K)
Definition Expr.h:3790
llvm::iterator_range< path_iterator > path()
Path through the class hierarchy taken by casts between base and derived classes (see implementation ...
Definition Expr.h:3832
const FieldDecl * getTargetUnionField() const
Definition Expr.h:3839
CastExpr(StmtClass SC, EmptyShell Empty, unsigned BasePathSize, bool HasFPFeatures)
Construct an empty cast.
Definition Expr.h:3771
static bool classof(const Stmt *T)
Definition Expr.h:3889
llvm::iterator_range< path_const_iterator > path() const
Definition Expr.h:3835
bool hasStoredFPFeatures() const
Definition Expr.h:3844
bool changesVolatileQualification() const
Return.
Definition Expr.h:3879
static const FieldDecl * getTargetFieldForToUnionCast(QualType unionType, QualType opType)
Definition Expr.cpp:2070
FPOptionsOverride getStoredFPFeatures() const
Get FPOptionsOverride from trailing storage.
Definition Expr.h:3847
CastExpr(StmtClass SC, QualType ty, ExprValueKind VK, const CastKind kind, Expr *op, unsigned BasePathSize, bool HasFPFeatures)
Definition Expr.h:3758
const Expr * getSubExpr() const
Definition Expr.h:3796
path_iterator path_end()
Definition Expr.h:3816
const_child_range children() const
Definition Expr.h:3896
const FPOptionsOverride * getTrailingFPFeatures() const
Definition Expr.h:3784
CXXBaseSpecifier ** path_iterator
Definition Expr.h:3811
path_const_iterator path_end() const
Definition Expr.h:3818
const char * getCastKindName() const
Definition Expr.h:3793
child_range children()
Definition Expr.h:3895
friend class ASTStmtReader
Definition Expr.h:3755
void setSubExpr(Expr *E)
Definition Expr.h:3797
path_const_iterator path_begin() const
Definition Expr.h:3817
const CXXBaseSpecifier *const * path_const_iterator
Definition Expr.h:3812
bool path_empty() const
Definition Expr.h:3813
FPOptionsOverride getFPFeatures() const
Definition Expr.h:3865
FPOptionsOverride getStoredFPFeaturesOrDefault() const
Get the store FPOptionsOverride or default if not stored.
Definition Expr.h:3853
Expr * getSubExpr()
Definition Expr.h:3795
FPOptions getFPFeaturesInEffect(const LangOptions &LO) const
Get the FP features status of this operation.
Definition Expr.h:3859
void setValue(unsigned Val)
Definition Expr.h:1680
SourceLocation getLocation() const
Definition Expr.h:1666
SourceLocation getEndLoc() const LLVM_READONLY
Definition Expr.h:1672
void setLocation(SourceLocation Location)
Definition Expr.h:1676
static bool classof(const Stmt *T)
Definition Expr.h:1682
static void print(unsigned val, CharacterLiteralKind Kind, raw_ostream &OS)
Definition Expr.cpp:1030
unsigned getValue() const
Definition Expr.h:1674
child_range children()
Definition Expr.h:1689
void setKind(CharacterLiteralKind kind)
Definition Expr.h:1677
const_child_range children() const
Definition Expr.h:1692
CharacterLiteralKind getKind() const
Definition Expr.h:1667
CharacterLiteral(EmptyShell Empty)
Construct an empty character literal.
Definition Expr.h:1664
SourceLocation getBeginLoc() const LLVM_READONLY
Definition Expr.h:1671
CharacterLiteral(unsigned value, CharacterLiteralKind kind, QualType type, SourceLocation l)
Definition Expr.h:1655
void setRParenLoc(SourceLocation L)
Definition Expr.h:4968
void setIsConditionTrue(bool isTrue)
Definition Expr.h:4945
SourceLocation getBuiltinLoc() const
Definition Expr.h:4964
Expr * getLHS() const
Definition Expr.h:4959
Expr * getChosenSubExpr() const
getChosenSubExpr - Return the subexpression chosen according to the condition.
Definition Expr.h:4953
bool isConditionDependent() const
Definition Expr.h:4947
void setBuiltinLoc(SourceLocation L)
Definition Expr.h:4965
bool isConditionTrue() const
isConditionTrue - Return whether the condition is true (i.e.
Definition Expr.h:4940
ChooseExpr(SourceLocation BLoc, Expr *cond, Expr *lhs, Expr *rhs, QualType t, ExprValueKind VK, ExprObjectKind OK, SourceLocation RP, bool condIsTrue)
Definition Expr.h:4923
void setRHS(Expr *E)
Definition Expr.h:4962
SourceLocation getEndLoc() const LLVM_READONLY
Definition Expr.h:4971
child_range children()
Definition Expr.h:4978
Expr * getRHS() const
Definition Expr.h:4961
SourceLocation getRParenLoc() const
Definition Expr.h:4967
ChooseExpr(EmptyShell Empty)
Build an empty __builtin_choose_expr.
Definition Expr.h:4936
const_child_range children() const
Definition Expr.h:4981
Expr * getCond() const
Definition Expr.h:4957
SourceLocation getBeginLoc() const LLVM_READONLY
Definition Expr.h:4970
void setCond(Expr *E)
Definition Expr.h:4958
void setLHS(Expr *E)
Definition Expr.h:4960
static bool classof(const Stmt *T)
Definition Expr.h:4973
CompoundAssignOperator - For compound assignments (e.g.
Definition Expr.h:4369
void setComputationResultType(QualType T)
Definition Expr.h:4407
static CompoundAssignOperator * CreateEmpty(const ASTContext &C, bool hasFPFeatures)
Definition Expr.cpp:5158
CompoundAssignOperator(const ASTContext &C, Expr *lhs, Expr *rhs, Opcode opc, QualType ResType, ExprValueKind VK, ExprObjectKind OK, SourceLocation OpLoc, FPOptionsOverride FPFeatures, QualType CompLHSType, QualType CompResultType)
Definition Expr.h:4379
QualType getComputationLHSType() const
Definition Expr.h:4403
void setComputationLHSType(QualType T)
Definition Expr.h:4404
static bool classof(const Stmt *S)
Definition Expr.h:4409
QualType getComputationResultType() const
Definition Expr.h:4406
void setFileScope(bool FS)
Definition Expr.h:3707
const_child_range children() const
Definition Expr.h:3736
void setTypeSourceInfo(TypeSourceInfo *tinfo)
Definition Expr.h:3715
bool hasStaticStorage() const
Definition Expr.h:3719
SourceLocation getLParenLoc() const
Definition Expr.h:3709
child_range children()
Definition Expr.h:3735
SourceLocation getBeginLoc() const LLVM_READONLY
Definition Expr.h:3723
APValue & getStaticValue() const
Definition Expr.cpp:5751
CompoundLiteralExpr(EmptyShell Empty)
Construct an empty compound literal.
Definition Expr.h:3699
void setLParenLoc(SourceLocation L)
Definition Expr.h:3710
SourceLocation getEndLoc() const LLVM_READONLY
Definition Expr.h:3728
APValue & getOrCreateStaticValue(ASTContext &Ctx) const
Definition Expr.cpp:5742
bool isFileScope() const
Definition Expr.h:3706
static bool classof(const Stmt *T)
Definition Expr.h:3730
const Expr * getInitializer() const
Definition Expr.h:3702
TypeSourceInfo * getTypeSourceInfo() const
Definition Expr.h:3712
void setInitializer(Expr *E)
Definition Expr.h:3704
CompoundLiteralExpr(SourceLocation lparenloc, TypeSourceInfo *tinfo, QualType T, ExprValueKind VK, Expr *init, bool fileScope)
Definition Expr.h:3690
CompoundStmt - This represents a group of statements like { stmt stmt }.
Definition Stmt.h:1751
ConditionalOperator - The ?
Definition Expr.h:4460
const_child_range children() const
Definition Expr.h:4512
Expr * getFalseExpr() const
getFalseExpr - Return the subexpression representing the value of the expression if the condition eva...
Definition Expr.h:4492
Expr * getLHS() const
Definition Expr.h:4494
static bool classof(const Stmt *T)
Definition Expr.h:4504
ConditionalOperator(Expr *cond, SourceLocation QLoc, Expr *lhs, SourceLocation CLoc, Expr *rhs, QualType t, ExprValueKind VK, ExprObjectKind OK)
Definition Expr.h:4466
SourceLocation getBeginLoc() const LLVM_READONLY
Definition Expr.h:4497
Expr * getCond() const
getCond - Return the expression representing the condition for the ?
Definition Expr.h:4483
Expr * getTrueExpr() const
getTrueExpr - Return the subexpression representing the value of the expression if the condition eval...
Definition Expr.h:4487
SourceLocation getEndLoc() const LLVM_READONLY
Definition Expr.h:4500
child_range children()
Definition Expr.h:4509
Expr * getRHS() const
Definition Expr.h:4495
friend class ASTStmtReader
Definition Expr.h:4464
ConditionalOperator(EmptyShell Empty)
Build an empty conditional operator.
Definition Expr.h:4478
APValue getAPValueResult() const
Definition Expr.cpp:419
static ConstantResultStorageKind getStorageKind(const APValue &Value)
Definition Expr.cpp:308
child_range children()
Definition Expr.h:1208
void MoveIntoResult(APValue &Value, const ASTContext &Context)
Definition Expr.cpp:384
llvm::APSInt getResultAsAPSInt() const
Definition Expr.cpp:407
SourceLocation getBeginLoc() const LLVM_READONLY
Definition Expr.h:1177
ConstantResultStorageKind getResultStorageKind() const
Definition Expr.h:1196
void SetResult(APValue Value, const ASTContext &Context)
Definition Expr.h:1188
APValue::ValueKind getResultAPValueKind() const
Definition Expr.h:1193
static bool classof(const Stmt *T)
Definition Expr.h:1184
bool hasAPValueResult() const
Definition Expr.h:1202
friend class ASTStmtWriter
Definition Expr.h:1133
const_child_range children() const
Definition Expr.h:1209
friend class ASTStmtReader
Definition Expr.h:1132
bool isImmediateInvocation() const
Definition Expr.h:1199
SourceLocation getEndLoc() const LLVM_READONLY
Definition Expr.h:1180
static ConstantExpr * CreateEmpty(const ASTContext &Context, ConstantResultStorageKind StorageKind)
Definition Expr.cpp:373
ConvertVectorExpr - Clang builtin function __builtin_convertvector This AST node provides support for...
Definition Expr.h:4788
FPOptionsOverride getStoredFPFeaturesOrDefault() const
Get the store FPOptionsOverride or default if not stored.
Definition Expr.h:4856
SourceLocation getRParenLoc() const
getRParenLoc - Return the location of final right parenthesis.
Definition Expr.h:4892
const_child_range children() const
Definition Expr.h:4903
FPOptions getFPFeaturesInEffect(const LangOptions &LO) const
Get the FP features status of this operator.
Definition Expr.h:4865
bool isFPContractableWithinStatement(const LangOptions &LO) const
Get the FP contractibility status of this operator.
Definition Expr.h:4841
friend class ASTReader
Definition Expr.h:4795
static ConvertVectorExpr * CreateEmpty(const ASTContext &C, bool hasFPFeatures)
Definition Expr.cpp:5724
static bool classof(const Stmt *T)
Definition Expr.h:4897
SourceLocation getEndLoc() const LLVM_READONLY
Definition Expr.h:4895
child_range children()
Definition Expr.h:4902
SourceLocation getBeginLoc() const LLVM_READONLY
Definition Expr.h:4894
SourceLocation getBuiltinLoc() const
getBuiltinLoc - Return the location of the __builtin_convertvector token.
Definition Expr.h:4889
FPOptionsOverride getStoredFPFeatures() const
Get FPFeatures from trailing storage.
Definition Expr.h:4851
TypeSourceInfo * getTypeSourceInfo() const
getTypeSourceInfo - Return the destination type.
Definition Expr.h:4881
void setStoredFPFeatures(FPOptionsOverride F)
Set FPFeatures in trailing storage, used by Serialization & ASTImporter.
Definition Expr.h:4861
bool hasStoredFPFeatures() const
Is FPFeatures in Trailing Storage?
Definition Expr.h:4846
friend class ASTStmtReader
Definition Expr.h:4796
void setTypeSourceInfo(TypeSourceInfo *ti)
Definition Expr.h:4884
Expr * getSrcExpr() const
getSrcExpr - Return the Expr to be converted.
Definition Expr.h:4878
FPOptionsOverride getFPOptionsOverride() const
Definition Expr.h:4871
A POD class for pairing a NamedDecl* with an access specifier.
static DeclAccessPair make(NamedDecl *D, AccessSpecifier AS)
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
Definition DeclBase.h:1467
unsigned getNumTemplateArgs() const
Retrieve the number of template arguments provided as part of this template-id.
Definition Expr.h:1490
NamedDecl * getFoundDecl()
Get the NamedDecl through which this reference occurred.
Definition Expr.h:1426
bool hasExplicitTemplateArgs() const
Determines whether this declaration reference was followed by an explicit template argument list.
Definition Expr.h:1470
NestedNameSpecifier getQualifier() const
If the name was qualified, retrieves the nested-name-specifier that precedes the name.
Definition Expr.h:1416
void setIsImmediateEscalating(bool Set)
Definition Expr.h:1527
const_child_range children() const
Definition Expr.h:1550
bool refersToEnclosingVariableOrCapture() const
Does this DeclRefExpr refer to an enclosing local or a captured variable?
Definition Expr.h:1519
void setDecl(ValueDecl *NewD)
Definition Expr.cpp:554
bool hasTemplateKWAndArgsInfo() const
Definition Expr.h:1436
const NamedDecl * getFoundDecl() const
Get the NamedDecl through which this reference occurred.
Definition Expr.h:1432
static DeclRefExpr * CreateEmpty(const ASTContext &Context, bool HasQualifier, bool HasFoundDecl, bool HasTemplateKWAndArgsInfo, unsigned NumTemplateArgs)
Construct an empty declaration reference expression.
Definition Expr.cpp:539
void setLocation(SourceLocation L)
Definition Expr.h:1392
void copyTemplateArgumentsInto(TemplateArgumentListInfo &List) const
Copies the template arguments (if present) into the given structure.
Definition Expr.h:1474
DeclarationNameInfo getNameInfo() const
Definition Expr.h:1387
void setHadMultipleCandidates(bool V=true)
Sets the flag telling whether this expression refers to a function that was resolved from an overload...
Definition Expr.h:1508
SourceLocation getTemplateKeywordLoc() const
Retrieve the location of the template keyword preceding this name, if any.
Definition Expr.h:1442
bool isCapturedByCopyInLambdaWithExplicitObjectParameter() const
Definition Expr.h:1531
SourceLocation getLAngleLoc() const
Retrieve the location of the left angle bracket starting the explicit template argument list followin...
Definition Expr.h:1450
bool hasQualifier() const
Determine whether this declaration reference was preceded by a C++ nested-name-specifier,...
Definition Expr.h:1404
NestedNameSpecifierLoc getQualifierLoc() const
If the name was qualified, retrieves the nested-name-specifier that precedes the name,...
Definition Expr.h:1408
ValueDecl * getDecl()
Definition Expr.h:1383
child_range children()
Definition Expr.h:1546
const ValueDecl * getDecl() const
Definition Expr.h:1384
const TemplateArgumentLoc * getTemplateArgs() const
Retrieve the template arguments provided as part of this template-id.
Definition Expr.h:1482
friend class ASTStmtWriter
Definition Expr.h:1317
ArrayRef< TemplateArgumentLoc > template_arguments() const
Definition Expr.h:1496
static bool classof(const Stmt *T)
Definition Expr.h:1541
NonOdrUseReason isNonOdrUse() const
Is this expression a non-odr-use reference, and if so, why?
Definition Expr.h:1513
SourceLocation getEndLoc() const LLVM_READONLY
Definition Expr.cpp:561
bool hadMultipleCandidates() const
Returns true if this expression refers to a function that was resolved from an overloaded set having ...
Definition Expr.h:1502
friend class ASTStmtReader
Definition Expr.h:1316
void setCapturedByCopyInLambdaWithExplicitObjectParameter(bool Set, const ASTContext &Context)
Definition Expr.h:1535
SourceLocation getBeginLoc() const
Definition Expr.h:1394
bool hasTemplateKeyword() const
Determines whether the name in this declaration reference was preceded by the template keyword.
Definition Expr.h:1466
SourceLocation getLocation() const
Definition Expr.h:1391
SourceLocation getRAngleLoc() const
Retrieve the location of the right angle bracket ending the explicit template argument list following...
Definition Expr.h:1458
bool isImmediateEscalating() const
Definition Expr.h:1523
Decl - This represents one declaration (or definition), e.g.
Definition DeclBase.h:86
DeclarationNameLoc - Additional source/type location info for a declaration name.
Represents a single C99 designator.
Definition Expr.h:5680
SourceRange getSourceRange() const LLVM_READONLY
Definition Expr.h:5852
SourceLocation getBeginLoc() const LLVM_READONLY
Definition Expr.h:5842
static Designator CreateArrayRangeDesignator(unsigned Index, SourceLocation LBracketLoc, SourceLocation EllipsisLoc, SourceLocation RBracketLoc)
Creates a GNU array-range designator.
Definition Expr.h:5807
struct FieldDesignatorInfo FieldInfo
A field designator, e.g., ".x".
Definition Expr.h:5742
static Designator CreateFieldDesignator(const IdentifierInfo *FieldName, SourceLocation DotLoc, SourceLocation FieldLoc)
Creates a field designator.
Definition Expr.h:5761
struct ArrayOrRangeDesignatorInfo ArrayOrRangeInfo
An array or GNU array-range designator, e.g., "[9]" or "[10..15]".
Definition Expr.h:5745
void setFieldDecl(FieldDecl *FD)
Definition Expr.h:5778
static Designator CreateArrayDesignator(unsigned Index, SourceLocation LBracketLoc, SourceLocation RBracketLoc)
Creates an array designator.
Definition Expr.h:5797
FieldDecl * getFieldDecl() const
Definition Expr.h:5771
SourceLocation getFieldLoc() const
Definition Expr.h:5788
SourceLocation getRBracketLoc() const
Definition Expr.h:5836
SourceLocation getEndLoc() const LLVM_READONLY
Definition Expr.h:5848
const IdentifierInfo * getFieldName() const
Definition Expr.cpp:4835
SourceLocation getEllipsisLoc() const
Definition Expr.h:5830
SourceLocation getDotLoc() const
Definition Expr.h:5783
SourceLocation getLBracketLoc() const
Definition Expr.h:5824
Represents a C99 designated initializer expression.
Definition Expr.h:5637
bool isDirectInit() const
Whether this designated initializer should result in direct-initialization of the designated subobjec...
Definition Expr.h:5897
static DesignatedInitExpr * CreateEmpty(const ASTContext &C, unsigned NumIndexExprs)
Definition Expr.cpp:4889
Expr * getArrayRangeEnd(const Designator &D) const
Definition Expr.cpp:4944
void setInit(Expr *init)
Definition Expr.h:5909
const_child_range children() const
Definition Expr.h:5946
const Designator * getDesignator(unsigned Idx) const
Definition Expr.h:5879
Expr * getSubExpr(unsigned Idx) const
Definition Expr.h:5919
SourceRange getDesignatorsSourceRange() const
Definition Expr.cpp:4905
void setSubExpr(unsigned Idx, Expr *E)
Definition Expr.h:5923
bool usesGNUSyntax() const
Determines whether this designated initializer used the deprecated GNU syntax for designated initiali...
Definition Expr.h:5901
Expr * getArrayRangeStart(const Designator &D) const
Definition Expr.cpp:4939
void ExpandDesignator(const ASTContext &C, unsigned Idx, const Designator *First, const Designator *Last)
Replaces the designator at index Idx with the series of designators in [First, Last).
Definition Expr.cpp:4951
MutableArrayRef< Designator > designators()
Definition Expr.h:5870
void setGNUSyntax(bool GNU)
Definition Expr.h:5902
child_range children()
Definition Expr.h:5942
void setEqualOrColonLoc(SourceLocation L)
Definition Expr.h:5893
Expr * getArrayIndex(const Designator &D) const
Definition Expr.cpp:4934
Designator * getDesignator(unsigned Idx)
Definition Expr.h:5878
ArrayRef< Designator > designators() const
Definition Expr.h:5874
Expr * getInit() const
Retrieve the initializer value.
Definition Expr.h:5905
unsigned size() const
Returns the number of designators in this initializer.
Definition Expr.h:5867
SourceLocation getBeginLoc() const LLVM_READONLY
Definition Expr.cpp:4913
void setDesignators(const ASTContext &C, const Designator *Desigs, unsigned NumDesigs)
Definition Expr.cpp:4896
SourceLocation getEndLoc() const LLVM_READONLY
Definition Expr.cpp:4930
SourceLocation getEqualOrColonLoc() const
Retrieve the location of the '=' that precedes the initializer value itself, if present.
Definition Expr.h:5892
unsigned getNumSubExprs() const
Retrieve the total number of subexpressions in this designated initializer expression,...
Definition Expr.h:5917
static bool classof(const Stmt *T)
Definition Expr.h:5937
SourceLocation getBeginLoc() const LLVM_READONLY
Definition Expr.cpp:4994
DesignatedInitUpdateExpr(EmptyShell Empty)
Definition Expr.h:6009
DesignatedInitUpdateExpr(const ASTContext &C, SourceLocation lBraceLoc, Expr *baseExprs, SourceLocation rBraceLoc)
Definition Expr.cpp:4977
static bool classof(const Stmt *T)
Definition Expr.h:6015
void setBase(Expr *Base)
Definition Expr.h:6020
SourceLocation getEndLoc() const LLVM_READONLY
Definition Expr.cpp:4998
const_child_range children() const
Definition Expr.h:6032
void setUpdater(Expr *Updater)
Definition Expr.h:6025
InitListExpr * getUpdater() const
Definition Expr.h:6022
Designator - A designator in a C99 designated initializer.
Definition Designator.h:38
child_range children()
Definition Expr.h:6682
IdentifierInfo & getAccessor() const
Definition Expr.h:6671
void setAccessorLoc(SourceLocation L)
Definition Expr.h:6675
SourceLocation AccessorLoc
Definition Expr.h:6653
void setAccessor(IdentifierInfo *II)
Definition Expr.h:6672
const Expr * getBase() const
Definition Expr.h:6667
const_child_range children() const
Definition Expr.h:6683
SourceLocation getAccessorLoc() const
Definition Expr.h:6674
IdentifierInfo * Accessor
Definition Expr.h:6652
void setBase(Expr *E)
Definition Expr.h:6669
ElementAccessExprBase(StmtClass SC, EmptyShell Empty)
Definition Expr.h:6663
SourceLocation getEndLoc() const LLVM_READONLY
Definition Expr.h:6680
SourceLocation getBeginLoc() const LLVM_READONLY
Definition Expr.h:6677
ElementAccessExprBase(StmtClass SC, QualType Ty, ExprValueKind VK, Expr *Base, IdentifierInfo &Accessor, SourceLocation Loc, ExprObjectKind OK)
Definition Expr.h:6655
BaseTy::pointer operator->() const
Definition Expr.h:5265
ChildElementIter & operator++()
Definition Expr.h:5267
BaseTy::reference operator*() const
Definition Expr.h:5253
bool operator==(ChildElementIter Other) const
Definition Expr.h:5278
unsigned getStartingElementPos() const
Definition Expr.h:5225
ChildElementIter< false > begin()
Definition Expr.h:5310
bool doForEachDataElement(Call &&C, unsigned &StartingIndexInArray, Targs &&...Fargs) const
Definition Expr.h:5317
llvm::iterator_range< ChildElementIter< false > > fake_child_range
Definition Expr.h:5284
SourceLocation getEndLoc() const
Definition Expr.h:5219
ChildElementIter< true > begin() const
Definition Expr.h:5312
StringLiteral * getDataStringLiteral() const
Definition Expr.h:5221
const_fake_child_range underlying_data_elements() const
Definition Expr.h:5292
EmbedExpr(EmptyShell Empty)
Definition Expr.h:5215
child_range children()
Definition Expr.h:5298
EmbedDataStorage * getData() const
Definition Expr.h:5223
EmbedExpr(const ASTContext &Ctx, SourceLocation Loc, EmbedDataStorage *Data, unsigned Begin, unsigned NumOfElements)
Definition Expr.cpp:2431
StringRef getFileName() const
Definition Expr.h:5222
fake_child_range underlying_data_elements()
Definition Expr.h:5287
SourceLocation getBeginLoc() const
Definition Expr.h:5218
SourceLocation getLocation() const
Definition Expr.h:5217
static bool classof(const Stmt *T)
Definition Expr.h:5306
llvm::iterator_range< ChildElementIter< true > > const_fake_child_range
Definition Expr.h:5285
friend class ASTStmtReader
Definition Expr.h:5329
const_child_range children() const
Definition Expr.h:5302
size_t getDataElementCount() const
Definition Expr.h:5226
An instance of this object exists for each enum constant that is defined.
Definition Decl.h:3574
TypeSourceInfo * getTypeInfoAsWritten() const
getTypeInfoAsWritten - Returns the type source info for the type that this expression is casting to.
Definition Expr.h:4019
ExplicitCastExpr(StmtClass SC, QualType exprTy, ExprValueKind VK, CastKind kind, Expr *op, unsigned PathSize, bool HasFPFeatures, TypeSourceInfo *writtenTy)
Definition Expr.h:4003
void setTypeInfoAsWritten(TypeSourceInfo *writtenTy)
Definition Expr.h:4020
static bool classof(const Stmt *T)
Definition Expr.h:4026
ExplicitCastExpr(StmtClass SC, EmptyShell Shell, unsigned PathSize, bool HasFPFeatures)
Construct an empty explicit cast.
Definition Expr.h:4012
QualType getTypeAsWritten() const
getTypeAsWritten - Returns the type that this expression is casting to, as written in the source code...
Definition Expr.h:4024
The return type of classify().
Definition Expr.h:341
bool isLValue() const
Definition Expr.h:392
bool isPRValue() const
Definition Expr.h:395
bool isXValue() const
Definition Expr.h:393
ModifiableType
The results of modification testing.
Definition Expr.h:360
ModifiableType getModifiable() const
Definition Expr.h:388
bool isGLValue() const
Definition Expr.h:394
Kinds getKind() const
Definition Expr.h:387
Kinds
The various classification results. Most of these mean prvalue.
Definition Expr.h:344
static Classification makeSimpleLValue()
Create a simple, modifiable lvalue.
Definition Expr.h:400
bool isRValue() const
Definition Expr.h:396
bool isModifiable() const
Definition Expr.h:397
This represents one expression.
Definition Expr.h:114
LValueClassification
Definition Expr.h:291
@ LV_DuplicateMatrixComponents
Definition Expr.h:296
@ LV_ArrayTemporary
Definition Expr.h:302
@ LV_DuplicateVectorComponents
Definition Expr.h:295
@ LV_ClassTemporary
Definition Expr.h:301
@ LV_InvalidMessageExpression
Definition Expr.h:298
@ LV_NotObjectType
Definition Expr.h:293
@ LV_MemberFunction
Definition Expr.h:299
@ LV_InvalidExpression
Definition Expr.h:297
@ LV_IncompleteVoidType
Definition Expr.h:294
@ LV_Valid
Definition Expr.h:292
@ LV_SubObjCPropertySetting
Definition Expr.h:300
Classification ClassifyModifiable(ASTContext &Ctx, SourceLocation &Loc) const
ClassifyModifiable - Classify this expression according to the C++11 expression taxonomy,...
Definition Expr.h:429
Expr(StmtClass SC, QualType T, ExprValueKind VK, ExprObjectKind OK)
Definition Expr.h:125
Expr(StmtClass SC, EmptyShell)
Construct an empty expression.
Definition Expr.h:135
bool EvaluateAsInt(EvalResult &Result, const ASTContext &Ctx, SideEffectsKind AllowSideEffects=SE_NoSideEffects, bool InConstantContext=false) const
EvaluateAsInt - Return true if this is a constant which we can fold and convert to an integer,...
EnumConstantDecl * getEnumConstantDecl()
If this expression refers to an enum constant, retrieve its declaration.
Definition Expr.cpp:4325
static bool isPotentialConstantExpr(const FunctionDecl *FD, SmallVectorImpl< PartialDiagnosticAt > &Diags)
isPotentialConstantExpr - Return true if this function's definition might be usable in a constant exp...
bool isReadIfDiscardedInCPlusPlus11() const
Determine whether an lvalue-to-rvalue conversion should implicitly be applied to this expression if i...
Definition Expr.cpp:2604
bool isXValue() const
Definition Expr.h:288
bool isIntegerConstantExpr(const ASTContext &Ctx) const
static bool isPotentialConstantExprUnevaluated(Expr *E, const FunctionDecl *FD, SmallVectorImpl< PartialDiagnosticAt > &Diags)
isPotentialConstantExprUnevaluated - Return true if this expression might be usable in a constant exp...
bool isGLValue() const
Definition Expr.h:289
Expr * IgnoreParenNoopCasts(const ASTContext &Ctx) LLVM_READONLY
Skip past any parentheses and casts which do not change the value (including ptr->int casts of the sa...
Definition Expr.cpp:3156
isModifiableLvalueResult isModifiableLvalue(ASTContext &Ctx, SourceLocation *Loc=nullptr) const
isModifiableLvalue - C99 6.3.2.1: an lvalue that does not have array type, does not have an incomplet...
SideEffectsKind
Definition Expr.h:699
@ SE_AllowSideEffects
Allow any unmodeled side effect.
Definition Expr.h:703
@ SE_NoSideEffects
Strictly evaluate the expression.
Definition Expr.h:700
@ SE_AllowUndefinedBehavior
Allow UB that we can give a value, but not arbitrary unmodeled side effects.
Definition Expr.h:701
static bool classof(const Stmt *T)
Definition Expr.h:1076
static QualType findBoundMemberType(const Expr *expr)
Given an expression of bound-member type, find the type of the member.
Definition Expr.cpp:3085
Expr & operator=(const Expr &)=delete
static std::pair< const NamedDecl *, const WarnUnusedResultAttr * > getUnusedResultAttrImpl(const Decl *Callee, QualType ReturnType)
Returns the WarnUnusedResultAttr that is declared on the callee or its return type declaration,...
Definition Expr.cpp:1671
bool isImplicitCXXThis() const
Whether this expression is an implicit reference to 'this' in C++.
Definition Expr.cpp:3334
const Expr * IgnoreParenNoopCasts(const ASTContext &Ctx) const
Definition Expr.h:1013
llvm::APSInt EvaluateKnownConstIntCheckOverflow(const ASTContext &Ctx, SmallVectorImpl< PartialDiagnosticAt > *Diag=nullptr) const
Expr * IgnoreParenCasts() LLVM_READONLY
Skip past any parentheses and casts which might surround this expression until reaching a fixed point...
Definition Expr.cpp:3134
bool EvaluateAsMandatedConstantInitializer(EvalResult &Result, const ASTContext &Ctx, SemaProxy &SProxy, const VarDecl *VD) const
Evaluate an expression that is required by the language to be a constant expression.
void setType(QualType t)
Definition Expr.h:147
bool isUnusedResultAWarning(const Expr *&WarnExpr, SourceLocation &Loc, SourceRange &R1, SourceRange &R2, ASTContext &Ctx) const
isUnusedResultAWarning - Return true if this immediate expression should be warned about if the resul...
Definition Expr.cpp:2670
LValueClassification ClassifyLValue(ASTContext &Ctx) const
Reasons why an expression might not be an l-value.
bool isValueDependent() const
Determines whether the value of this expression depends on.
Definition Expr.h:179
ExprValueKind getValueKind() const
getValueKind - The value kind that this expression produces.
Definition Expr.h:449
bool refersToVectorElement() const
Returns whether this expression refers to a vector element.
Definition Expr.cpp:4332
bool isTypeDependent() const
Determines whether the type of this expression depends on.
Definition Expr.h:196
llvm::APSInt EvaluateKnownConstInt(const ASTContext &Ctx) const
EvaluateKnownConstInt - Call EvaluateAsRValue and return the folded integer.
bool EvaluateAsMandatedConstantExpr(EvalResult &Result, const ASTContext &Ctx, SemaProxy &SProxy, ConstantExprKind Kind=ConstantExprKind::Normal) const
Evaluate an expression that is required by the language to be a constant expression.
bool containsUnexpandedParameterPack() const
Whether this expression contains an unexpanded parameter pack (for C++11 variadic templates).
Definition Expr.h:243
bool isCXX11ConstantExpr(const ASTContext &Ctx, APValue &Result, bool AllowRelaxedEval=false) const
isCXX11ConstantExpr - Return true if this expression is a constant expression in C++11.
Expr * IgnoreParenLValueCasts() LLVM_READONLY
Skip past any parentheses and lvalue casts which might surround this expression until reaching a fixe...
Definition Expr.cpp:3146
bool EvaluateAsMandatedConstantRValue(EvalResult &Result, const ASTContext &Ctx, SemaProxy &SProxy) const
Evaluate an expression that is required by the language to be a constant expression,...
FPOptions getFPFeaturesInEffect(const LangOptions &LO) const
Returns the set of floating point options that apply to this expression.
Definition Expr.cpp:4031
const CXXRecordDecl * getBestDynamicClassType() const
For an expression of class type or pointer to class type, return the most derived class decl the expr...
Definition Expr.cpp:70
Expr * IgnoreParenImpCasts() LLVM_READONLY
Skip past any parentheses and implicit casts which might surround this expression until reaching a fi...
Definition Expr.cpp:3129
Expr * IgnoreImplicit() LLVM_READONLY
Skip past any implicit AST nodes which might surround this expression until reaching a fixed point.
Definition Expr.cpp:3117
Expr * IgnoreConversionOperatorSingleStep() LLVM_READONLY
Skip conversion operators.
Definition Expr.cpp:3138
bool containsErrors() const
Whether this expression contains subexpressions which had errors.
Definition Expr.h:248
bool EvaluateAsFloat(llvm::APFloat &Result, const ASTContext &Ctx, SideEffectsKind AllowSideEffects=SE_NoSideEffects, bool InConstantContext=false) const
EvaluateAsFloat - Return true if this is a constant which we can fold and convert to a floating point...
bool isObjCSelfExpr() const
Check if this expression is the ObjC 'self' implicit parameter.
Definition Expr.cpp:4253
Expr * IgnoreParens() LLVM_READONLY
Skip past any parentheses which might surround this expression until reaching a fixed point.
Definition Expr.cpp:3125
bool isFlexibleArrayMemberLike(const ASTContext &Context, LangOptions::StrictFlexArraysLevelKind StrictFlexArraysLevel, bool IgnoreTemplateOrMacroSubstitution=false) const
Check whether this array fits the idiom of a flexible array member, depending on the value of -fstric...
Definition Expr.cpp:212
bool hasPlaceholderType(BuiltinType::Kind K) const
Returns whether this expression has a specific placeholder type.
Definition Expr.h:533
bool EvaluateAsLValue(EvalResult &Result, const ASTContext &Ctx, bool InConstantContext=false) const
EvaluateAsLValue - Evaluate an expression to see if we can fold it to an lvalue with link time known ...
bool EvaluateAsInitializer(const ASTContext &Ctx, const VarDecl *VD, EvalResult &Result, bool IsConstantInitializer) const
EvaluateAsInitializer - Evaluate an expression as if it were the initializer of the given declaration...
bool EvaluateAsFixedPoint(EvalResult &Result, const ASTContext &Ctx, SideEffectsKind AllowSideEffects=SE_NoSideEffects, bool InConstantContext=false) const
EvaluateAsFixedPoint - Return true if this is a constant which we can fold and convert to a fixed poi...
bool isEvaluatable(const ASTContext &Ctx, SideEffectsKind AllowSideEffects=SE_NoSideEffects) const
isEvaluatable - Call EvaluateAsRValue to see if this expression can be constant folded without side-e...
Expr * IgnoreParenBaseCasts() LLVM_READONLY
Skip past any parentheses and derived-to-base casts until reaching a fixed point.
Definition Expr.cpp:3151
bool isConstantInitializer(ASTContext &Ctx, bool ForRef=false, const Expr **Culprit=nullptr) const
Returns true if this expression can be emitted to IR as a constant, and thus can be used as a constan...
Definition Expr.cpp:3386
bool isPRValue() const
Definition Expr.h:287
bool isLValue() const
isLValue - True if this expression is an "l-value" according to the rules of the current language.
Definition Expr.h:286
static bool hasAnyTypeDependentArguments(ArrayRef< Expr * > Exprs)
hasAnyTypeDependentArguments - Determines if any of the expressions in Exprs is type-dependent.
Definition Expr.cpp:3378
FieldDecl * getSourceBitField()
If this expression refers to a bit-field, retrieve the declaration of that bit-field.
Definition Expr.cpp:4271
NullPointerConstantValueDependence
Enumeration used to describe how isNullPointerConstant() should cope with value-dependent expressions...
Definition Expr.h:870
@ NPC_ValueDependentIsNull
Specifies that a value-dependent expression of integral or dependent type should be considered a null...
Definition Expr.h:876
@ NPC_NeverValueDependent
Specifies that the expression should never be value-dependent.
Definition Expr.h:872
@ NPC_ValueDependentIsNotNull
Specifies that a value-dependent expression should be considered to never be a null pointer constant.
Definition Expr.h:880
Expr * IgnoreUnlessSpelledInSource()
Skip past any invisible AST nodes which might surround this statement, such as ExprWithCleanups or Im...
Definition Expr.cpp:3182
ExprObjectKind getObjectKind() const
getObjectKind - The object kind that this expression produces.
Definition Expr.h:456
bool EvaluateAsRValue(EvalResult &Result, const ASTContext &Ctx, bool InConstantContext=false) const
EvaluateAsRValue - Return true if this is a constant which we can fold to an rvalue using any crazy t...
Expr * IgnoreCasts() LLVM_READONLY
Skip past any casts which might surround this expression until reaching a fixed point.
Definition Expr.cpp:3113
Decl * getReferencedDeclOfCallee()
Definition Expr.cpp:1578
Expr * IgnoreImplicitAsWritten() LLVM_READONLY
Skip past any implicit AST nodes which might surround this expression until reaching a fixed point.
Definition Expr.cpp:3121
std::optional< uint64_t > tryEvaluateStrLen(const ASTContext &Ctx) const
If the current Expr is a pointer, this will try to statically determine the strlen of the string poin...
bool HasSideEffects(const ASTContext &Ctx, bool IncludePossibleEffects=true) const
HasSideEffects - This routine returns true for all those expressions which have any effect other than...
Definition Expr.cpp:3728
bool EvaluateAsConstantExpr(EvalResult &Result, const ASTContext &Ctx, ConstantExprKind Kind=ConstantExprKind::Normal) const
Evaluate an expression that is required to be a constant expression.
bool isInstantiationDependent() const
Whether this expression is instantiation-dependent, meaning that it depends in some way on.
Definition Expr.h:225
const Expr * getBestDynamicClassTypeExpr() const
Get the inner expression that determines the best dynamic class.
Definition Expr.cpp:45
const Expr * IgnoreUnlessSpelledInSource() const
Definition Expr.h:907
std::optional< llvm::APSInt > getIntegerConstantExpr(const ASTContext &Ctx, bool AllowRelaxedEval=false) const
isIntegerConstantExpr - Return the value if this expression is a valid integer constant expression.
std::optional< std::string > tryEvaluateString(ASTContext &Ctx) const
If the current Expr can be evaluated to a pointer to a null-terminated constant string,...
Expr * IgnoreImpCasts() LLVM_READONLY
Skip past any implicit casts which might surround this expression until reaching a fixed point.
Definition Expr.cpp:3109
NullPointerConstantKind
Enumeration used to describe the kind of Null pointer constant returned from isNullPointerConstant().
Definition Expr.h:847
@ NPCK_ZeroExpression
Expression is a Null pointer constant built from a zero integer expression that is not a simple,...
Definition Expr.h:856
@ NPCK_ZeroLiteral
Expression is a Null pointer constant built from a literal zero.
Definition Expr.h:859
@ NPCK_CXX11_nullptr
Expression is a C++11 nullptr.
Definition Expr.h:862
@ NPCK_GNUNull
Expression is a GNU-style __null constant.
Definition Expr.h:865
@ NPCK_NotNull
Expression is not a Null pointer constant.
Definition Expr.h:849
bool EvaluateAsBooleanCondition(bool &Result, const ASTContext &Ctx, bool InConstantContext=false) const
EvaluateAsBooleanCondition - Return true if this is a constant which we can fold and convert to a boo...
bool isTemporaryObject(ASTContext &Ctx, const CXXRecordDecl *TempTy) const
Determine whether the result of this expression is a temporary object of the given class type.
Definition Expr.cpp:3292
NullPointerConstantKind isNullPointerConstant(ASTContext &Ctx, NullPointerConstantValueDependence NPC) const
isNullPointerConstant - C99 6.3.2.3p3 - Test if this reduces down to a Null pointer constant.
Definition Expr.cpp:4110
QualType getEnumCoercedType(const ASTContext &Ctx) const
If this expression is an enumeration constant, return the enumeration type under which said constant ...
Definition Expr.cpp:272
bool isBoundMemberFunction(ASTContext &Ctx) const
Returns true if this expression is a bound member function.
Definition Expr.cpp:3079
Expr()=delete
ConstantExprKind
Definition Expr.h:784
@ ClassTemplateArgument
A class template argument. Such a value is used for code generation.
Definition Expr.h:792
@ Normal
An integer constant expression (an array bound, enumerator, case value, bit-field width,...
Definition Expr.h:787
@ ImmediateInvocation
An immediate invocation.
Definition Expr.h:796
@ Initializer
The initializer of an object with static storage duration.
Definition Expr.h:800
@ NonClassTemplateArgument
A non-class template argument.
Definition Expr.h:790
std::optional< uint64_t > tryEvaluateObjectSize(const ASTContext &Ctx, unsigned Type) const
If the current Expr is a pointer, this will try to statically determine the number of bytes available...
void setValueKind(ExprValueKind Cat)
setValueKind - Set the value kind produced by this expression.
Definition Expr.h:466
SourceLocation getExprLoc() const LLVM_READONLY
getExprLoc - Return the preferred location for the arrow when diagnosing a problem with a generic exp...
Definition Expr.cpp:283
const FieldDecl * getSourceBitField() const
Definition Expr.h:499
static bool isSameComparisonOperand(const Expr *E1, const Expr *E2)
Checks that the two Expr's will refer to the same value as a comparison operand.
Definition Expr.cpp:4369
void setObjectKind(ExprObjectKind Cat)
setObjectKind - Set the object kind produced by this expression.
Definition Expr.h:469
friend class ASTImporter
Definition Expr.h:142
bool refersToMatrixElement() const
Returns whether this expression refers to a matrix element.
Definition Expr.h:519
bool refersToBitField() const
Returns true if this expression is a gl-value that potentially refers to a bit-field.
Definition Expr.h:481
bool EvaluateCharRangeAsString(std::string &Result, const Expr *SizeExpression, const Expr *PtrExpression, ASTContext &Ctx, SemaProxy &SProxy, EvalResult &Status) const
bool isDefaultArgument() const
Determine whether this expression is a default function argument.
Definition Expr.cpp:3253
isModifiableLvalueResult
Definition Expr.h:307
@ MLV_DuplicateVectorComponents
Definition Expr.h:311
@ MLV_LValueCast
Definition Expr.h:314
@ MLV_InvalidMessageExpression
Definition Expr.h:323
@ MLV_DuplicateMatrixComponents
Definition Expr.h:312
@ MLV_ConstQualifiedField
Definition Expr.h:317
@ MLV_InvalidExpression
Definition Expr.h:313
@ MLV_IncompleteType
Definition Expr.h:315
@ MLV_Valid
Definition Expr.h:308
@ MLV_ConstQualified
Definition Expr.h:316
@ MLV_NoSetterProperty
Definition Expr.h:320
@ MLV_ArrayTemporary
Definition Expr.h:325
@ MLV_SubObjCPropertySetting
Definition Expr.h:322
@ MLV_ConstAddrSpace
Definition Expr.h:318
@ MLV_MemberFunction
Definition Expr.h:321
@ MLV_NotObjectType
Definition Expr.h:309
@ MLV_ArrayType
Definition Expr.h:319
@ MLV_ClassTemporary
Definition Expr.h:324
@ MLV_IncompleteVoidType
Definition Expr.h:310
Classification Classify(ASTContext &Ctx) const
Classify - Classify this expression according to the C++11 expression taxonomy.
Definition Expr.h:417
QualType getType() const
Definition Expr.h:146
const Decl * getReferencedDeclOfCallee() const
Definition Expr.h:504
bool hasNonTrivialCall(const ASTContext &Ctx) const
Determine whether this expression involves a call to any function that is not trivial.
Definition Expr.cpp:4098
bool isOrdinaryOrBitFieldObject() const
Definition Expr.h:460
bool hasPlaceholderType() const
Returns whether this expression has a placeholder type.
Definition Expr.h:528
bool refersToGlobalRegisterVar() const
Returns whether this expression refers to a global register variable.
Definition Expr.cpp:4357
friend class ASTStmtReader
Definition Expr.h:143
bool isCXX98IntegralConstantExpr(const ASTContext &Ctx) const
isCXX98IntegralConstantExpr - Return true if this expression is an integral constant expression in C+...
const ValueDecl * getAsBuiltinConstantDeclRef(const ASTContext &Context) const
If this expression is an unambiguous reference to a single declaration, in the style of __builtin_fun...
Definition Expr.cpp:232
bool isOBJCGCCandidate(ASTContext &Ctx) const
isOBJCGCCandidate - Return true if this expression may be used in a read/ write barrier.
Definition Expr.cpp:3040
static ExprValueKind getValueKindForType(QualType T)
getValueKindForType - Given a formal return or parameter type, give its value kind.
Definition Expr.h:439
bool EvaluateWithSubstitution(APValue &Value, ASTContext &Ctx, const FunctionDecl *Callee, ArrayRef< const Expr * > Args, const Expr *This=nullptr) const
EvaluateWithSubstitution - Evaluate an expression as if from the context of a call to the given funct...
const Expr * skipRValueSubobjectAdjustments() const
Definition Expr.h:1065
bool isKnownToHaveBooleanValue(bool Semantic=true) const
isKnownToHaveBooleanValue - Return true if this is an integer expression that is known to return 0 or...
Definition Expr.cpp:138
void setDependence(ExprDependence Deps)
Each concrete expr subclass is expected to compute its dependence and call this in the constructor.
Definition Expr.h:139
Expr(const Expr &)=delete
Expr(Expr &&)=delete
void EvaluateForOverflow(const ASTContext &Ctx) const
ExprDependence getDependence() const
Definition Expr.h:166
Expr & operator=(Expr &&)=delete
const EnumConstantDecl * getEnumConstantDecl() const
Definition Expr.h:495
const ObjCPropertyRefExpr * getObjCProperty() const
If this expression is an l-value for an Objective C property, find the underlying property reference ...
Definition Expr.cpp:4234
ExtVectorElementExpr(QualType Ty, ExprValueKind VK, Expr *Base, IdentifierInfo &Accessor, SourceLocation Loc)
Definition Expr.h:6698
ExtVectorElementExpr(EmptyShell Empty)
Build an empty vector element expression.
Definition Expr.h:6705
bool containsDuplicateElements() const
containsDuplicateElements - Return true if any element access is repeated.
Definition Expr.cpp:4503
bool isArrow() const
isArrow - Return true if the base expression is a pointer to vector, return false if the base express...
Definition Expr.cpp:4485
void getEncodedElementAccess(SmallVectorImpl< uint32_t > &Elts) const
getEncodedElementAccess - Encode the elements accessed into an llvm aggregate Constant of ConstantInt...
Definition Expr.cpp:4598
static bool classof(const Stmt *T)
Definition Expr.h:6723
unsigned getNumElements() const
getNumElements - Get the number of components being selected.
Definition Expr.cpp:4489
Represents difference between two FPOptions values.
FPOptions applyOverrides(FPOptions Base)
bool requiresTrailingStorage() const
static FPOptions defaultWithoutTrailingStorage(const LangOptions &LO)
Return the default value of FPOptions that's used when trailing storage isn't required.
bool allowFPContractWithinStatement() const
Represents a member of a struct/union/class.
Definition Decl.h:3311
SourceLocation getLocation() const
Retrieve the location of the literal.
Definition Expr.h:1626
std::string getValueAsString(unsigned Radix) const
Definition Expr.cpp:1020
unsigned getScale() const
Definition Expr.h:1630
SourceLocation getBeginLoc() const LLVM_READONLY
Definition Expr.h:1622
const_child_range children() const
Definition Expr.h:1643
void setLocation(SourceLocation Location)
Definition Expr.h:1628
llvm::APInt getValue() const
Returns an internal integer representation of the literal.
Definition Expr.h:1620
static bool classof(const Stmt *T)
Definition Expr.h:1633
void setScale(unsigned S)
Definition Expr.h:1631
static FixedPointLiteral * CreateFromRawInt(const ASTContext &C, const llvm::APInt &V, QualType type, SourceLocation l, unsigned Scale)
Definition Expr.cpp:1007
child_range children()
Definition Expr.h:1640
SourceLocation getEndLoc() const LLVM_READONLY
Definition Expr.h:1623
SourceLocation getLocation() const
Definition Expr.h:1752
llvm::APFloatBase::Semantics getRawSemantics() const
Get a raw enumeration value representing the floating-point semantics of this literal (32-bit IEEE,...
Definition Expr.h:1721
child_range children()
Definition Expr.h:1763
const llvm::fltSemantics & getSemantics() const
Return the APFloat semantics this literal uses.
Definition Expr.h:1733
void setValue(const ASTContext &C, const llvm::APFloat &Val)
Definition Expr.h:1714
const_child_range children() const
Definition Expr.h:1766
SourceLocation getBeginLoc() const LLVM_READONLY
Definition Expr.h:1755
void setRawSemantics(llvm::APFloatBase::Semantics Sem)
Set the raw enumeration value representing the floating-point semantics of this literal (32-bit IEEE,...
Definition Expr.h:1728
double getValueAsApproximateDouble() const
getValueAsApproximateDouble - This returns the value as an inaccurate double.
Definition Expr.cpp:1099
llvm::APFloat getValue() const
Definition Expr.h:1711
void setExact(bool E)
Definition Expr.h:1745
static bool classof(const Stmt *T)
Definition Expr.h:1758
void setLocation(SourceLocation L)
Definition Expr.h:1753
bool isExact() const
Definition Expr.h:1744
SourceLocation getEndLoc() const LLVM_READONLY
Definition Expr.h:1756
void setSemantics(const llvm::fltSemantics &Sem)
Set the APFloat semantics this literal uses.
Definition Expr.h:1740
Expr * getSubExpr()
Definition Expr.h:1108
FullExpr(StmtClass SC, EmptyShell Empty)
Definition Expr.h:1104
void setSubExpr(Expr *E)
As with any mutator of the AST, be very careful when modifying an existing AST to preserve its invari...
Definition Expr.h:1112
Stmt * SubExpr
Definition Expr.h:1096
static bool classof(const Stmt *T)
Definition Expr.h:1114
FullExpr(StmtClass SC, Expr *subexpr)
Definition Expr.h:1098
const Expr * getSubExpr() const
Definition Expr.h:1107
Represents a function declaration or definition.
Definition Decl.h:2071
Represents a prototype with parameter type info, e.g.
Definition TypeBase.h:5416
SourceLocation getTokenLocation() const
getTokenLocation - The location of the __null token.
Definition Expr.h:5006
static bool classof(const Stmt *T)
Definition Expr.h:5012
child_range children()
Definition Expr.h:5017
SourceLocation getBeginLoc() const LLVM_READONLY
Definition Expr.h:5009
const_child_range children() const
Definition Expr.h:5020
GNUNullExpr(QualType Ty, SourceLocation Loc)
Definition Expr.h:4997
SourceLocation getEndLoc() const LLVM_READONLY
Definition Expr.h:5010
GNUNullExpr(EmptyShell Empty)
Build an empty GNU __null expression.
Definition Expr.h:5003
void setTokenLocation(SourceLocation L)
Definition Expr.h:5007
SourceLocation getBeginLoc() const
Definition Expr.h:6628
AssociationTy< false > Association
Definition Expr.h:6501
TypeSourceInfo * getControllingType()
Return the controlling type of this generic selection expression.
Definition Expr.h:6545
static bool classof(const Stmt *T)
Definition Expr.h:6631
const Expr * getControllingExpr() const
Definition Expr.h:6537
unsigned getNumAssocs() const
The number of association expressions.
Definition Expr.h:6510
const_association_range associations() const
Definition Expr.h:6612
AssociationIteratorTy< true > ConstAssociationIterator
Definition Expr.h:6504
SourceLocation getEndLoc() const
Definition Expr.h:6629
ArrayRef< Expr * > getAssocExprs() const
Definition Expr.h:6565
bool isExprPredicate() const
Whether this generic selection uses an expression as its controlling argument.
Definition Expr.h:6526
ConstAssociation getAssociation(unsigned I) const
Definition Expr.h:6589
association_range associations()
Definition Expr.h:6601
AssociationTy< true > ConstAssociation
Definition Expr.h:6502
SourceLocation getGenericLoc() const
Definition Expr.h:6623
SourceLocation getRParenLoc() const
Definition Expr.h:6627
unsigned getResultIndex() const
The zero-based index of the result expression's generic association in the generic selection's associ...
Definition Expr.h:6515
Expr * getResultExpr()
Return the result expression of this controlling expression.
Definition Expr.h:6554
AssociationIteratorTy< false > AssociationIterator
Definition Expr.h:6503
SourceLocation getDefaultLoc() const
Definition Expr.h:6626
llvm::iterator_range< AssociationIterator > association_range
Definition Expr.h:6505
const Expr * getResultExpr() const
Definition Expr.h:6559
bool isResultDependent() const
Whether this generic selection is result-dependent.
Definition Expr.h:6522
child_range children()
Definition Expr.h:6635
friend class ASTStmtWriter
Definition Expr.h:6270
const_child_range children() const
Definition Expr.h:6639
Association getAssociation(unsigned I)
Return the Ith association expression with its TypeSourceInfo, bundled together in GenericSelectionEx...
Definition Expr.h:6578
friend class ASTStmtReader
Definition Expr.h:6269
bool isTypePredicate() const
Whether this generic selection uses a type as its controlling argument.
Definition Expr.h:6528
const TypeSourceInfo * getControllingType() const
Definition Expr.h:6548
llvm::iterator_range< ConstAssociationIterator > const_association_range
Definition Expr.h:6506
static GenericSelectionExpr * CreateEmpty(const ASTContext &Context, unsigned NumAssocs)
Create an empty generic selection expression for deserialization.
Definition Expr.cpp:4823
Expr * getControllingExpr()
Return the controlling expression of this generic selection expression.
Definition Expr.h:6533
ArrayRef< TypeSourceInfo * > getAssocTypeSourceInfos() const
Definition Expr.h:6570
This class represents temporary values used to represent inout and out arguments in HLSL.
Definition Expr.h:7483
SourceLocation getEndLoc() const LLVM_READONLY
Definition Expr.h:7548
const OpaqueValueExpr * getCastedTemporary() const
Definition Expr.h:7534
const OpaqueValueExpr * getOpaqueArgLValue() const
Definition Expr.h:7515
Expr * getWritebackCast()
Definition Expr.h:7532
bool isInOut() const
returns true if the parameter is inout and false if the parameter is out.
Definition Expr.h:7542
static HLSLOutArgExpr * CreateEmpty(const ASTContext &Ctx)
Definition Expr.cpp:5710
static bool classof(const Stmt *T)
Definition Expr.h:7552
Expr * getArgLValue()
Definition Expr.h:7527
child_range children()
Definition Expr.h:7557
OpaqueValueExpr * getCastedTemporary()
Definition Expr.h:7537
const Expr * getWritebackCast() const
Definition Expr.h:7529
SourceLocation getBeginLoc() const LLVM_READONLY
Definition Expr.h:7544
const Expr * getArgLValue() const
Return the l-value expression that was written as the argument in source.
Definition Expr.h:7524
OpaqueValueExpr * getOpaqueArgLValue()
Definition Expr.h:7518
friend class ASTStmtReader
Definition Expr.h:7484
One of these records is kept for each identifier that is lexed.
SourceLocation getEndLoc() const LLVM_READONLY
Definition Expr.h:1795
ImaginaryLiteral(Expr *val, QualType Ty)
Definition Expr.h:1779
const Expr * getSubExpr() const
Definition Expr.h:1788
SourceLocation getBeginLoc() const LLVM_READONLY
Definition Expr.h:1792
ImaginaryLiteral(EmptyShell Empty)
Build an empty imaginary literal.
Definition Expr.h:1785
child_range children()
Definition Expr.h:1802
static bool classof(const Stmt *T)
Definition Expr.h:1797
const_child_range children() const
Definition Expr.h:1803
void setSubExpr(Expr *E)
Definition Expr.h:1790
ImplicitCastExpr - Allows us to explicitly represent implicit type conversions, which have no direct ...
Definition Expr.h:3922
SourceLocation getEndLoc() const LLVM_READONLY
Definition Expr.h:3969
SourceLocation getBeginLoc() const LLVM_READONLY
Definition Expr.h:3966
static ImplicitCastExpr * CreateEmpty(const ASTContext &Context, unsigned PathSize, bool HasFPFeatures)
Definition Expr.cpp:2132
ImplicitCastExpr(OnStack_t _, QualType ty, CastKind kind, Expr *op, ExprValueKind VK, FPOptionsOverride FPO)
Definition Expr.h:3945
bool isPartOfExplicitCast() const
Definition Expr.h:3953
friend class CastExpr
Definition Expr.h:3978
static bool classof(const Stmt *T)
Definition Expr.h:3973
void setIsPartOfExplicitCast(bool PartOfExplicitCast)
Definition Expr.h:3954
SourceLocation getEndLoc() const LLVM_READONLY
Definition Expr.h:6159
static bool classof(const Stmt *T)
Definition Expr.h:6154
child_range children()
Definition Expr.h:6162
ImplicitValueInitExpr(EmptyShell Empty)
Construct an empty implicit value initialization.
Definition Expr.h:6151
const_child_range children() const
Definition Expr.h:6165
ImplicitValueInitExpr(QualType ty)
Definition Expr.h:6145
SourceLocation getBeginLoc() const LLVM_READONLY
Definition Expr.h:6158
Describes an C or C++ initializer list.
Definition Expr.h:5377
const_reverse_iterator rend() const
Definition Expr.h:5609
bool hasArrayFiller() const
Return true if this is an array initializer and its array "filler" has been set.
Definition Expr.h:5501
void setSyntacticForm(InitListExpr *Init)
Definition Expr.h:5562
InitExprsTy::reverse_iterator reverse_iterator
Definition Expr.h:5599
InitExprsTy::const_reverse_iterator const_reverse_iterator
Definition Expr.h:5600
void markError()
Mark the semantic form of the InitListExpr as error when the semantic analysis fails.
Definition Expr.h:5463
bool hasDesignatedInit() const
Determine whether this initializer list contains a designated initializer.
Definition Expr.h:5504
bool isTransparent() const
Is this a transparent initializer list (that is, an InitListExpr that is purely syntactic,...
Definition Expr.cpp:2501
bool hasOneInit() const
Whether getNumInitsWithEmbedExpanded() is 1, without walking the list.
Definition Expr.h:5425
void resizeInits(const ASTContext &Context, unsigned NumInits)
Specify the number of initializers.
Definition Expr.cpp:2461
bool isStringLiteralInit() const
Is this an initializer for an array of characters, initialized by a string literal or an @encode?
Definition Expr.cpp:2487
FieldDecl * getInitializedFieldInUnion()
If this initializes a union, specifies which field in the union to initialize.
Definition Expr.h:5515
unsigned getNumInits() const
Definition Expr.h:5410
SourceLocation getBeginLoc() const LLVM_READONLY
Definition Expr.cpp:2535
bool isSemanticForm() const
Definition Expr.h:5551
void setInit(unsigned Init, Expr *expr)
Definition Expr.h:5453
const_iterator begin() const
Definition Expr.h:5603
reverse_iterator rbegin()
Definition Expr.h:5606
bool hasZeroInits() const
Definition Expr.h:5422
const_reverse_iterator rbegin() const
Definition Expr.h:5607
InitExprsTy::const_iterator const_iterator
Definition Expr.h:5598
Expr *const * getInits() const
Retrieve the set of initializers.
Definition Expr.h:5437
SourceLocation getLBraceLoc() const
Definition Expr.h:5546
Expr * updateInit(const ASTContext &C, unsigned Init, Expr *expr)
Updates the initializer at index Init with the new expression expr, and returns the old expression at...
Definition Expr.cpp:2465
void setArrayFiller(Expr *filler)
Definition Expr.cpp:2477
InitListExpr * getSyntacticForm() const
Definition Expr.h:5558
static bool classof(const Stmt *T)
Definition Expr.h:5579
bool hadArrayRangeDesignator() const
Definition Expr.h:5569
Expr * getArrayFiller()
If this initializer list initializes an array with more elements than there are initializers in the l...
Definition Expr.h:5491
iterator end()
Definition Expr.h:5604
bool isExplicit() const
Definition Expr.h:5531
iterator begin()
Definition Expr.h:5602
unsigned getNumInitsWithEmbedExpanded() const
getNumInits but if the list has an EmbedExpr inside includes full length of embedded data.
Definition Expr.h:5414
SourceLocation getRBraceLoc() const
Definition Expr.h:5548
InitListExpr * getSemanticForm() const
Definition Expr.h:5552
const FieldDecl * getInitializedFieldInUnion() const
Definition Expr.h:5518
InitListExpr(const ASTContext &C, SourceLocation lbraceloc, ArrayRef< Expr * > initExprs, SourceLocation rbraceloc, bool isExplicit)
Definition Expr.cpp:2443
friend class ASTStmtWriter
Definition Expr.h:5612
const Expr * getInit(unsigned Init) const
Definition Expr.h:5443
InitListExpr(EmptyShell Empty)
Build an empty initializer list.
Definition Expr.h:5405
void setLBraceLoc(SourceLocation Loc)
Definition Expr.h:5547
const Expr * getArrayFiller() const
Definition Expr.h:5494
const_child_range children() const
Definition Expr.h:5590
bool isIdiomaticZeroInitializer(const LangOptions &LangOpts) const
Is this the zero initializer {0} in a language which considers it idiomatic?
Definition Expr.cpp:2524
reverse_iterator rend()
Definition Expr.h:5608
friend class ASTStmtReader
Definition Expr.h:5611
const_iterator end() const
Definition Expr.h:5605
SourceLocation getEndLoc() const LLVM_READONLY
Definition Expr.cpp:2553
void setInitializedFieldInUnion(FieldDecl *FD)
Definition Expr.h:5521
bool isSyntacticForm() const
Definition Expr.h:5555
void setRBraceLoc(SourceLocation Loc)
Definition Expr.h:5549
ArrayRef< Expr * > inits() const
Definition Expr.h:5441
InitExprsTy::iterator iterator
Definition Expr.h:5597
void sawArrayRangeDesignator(bool ARD=true)
Definition Expr.h:5572
Expr ** getInits()
Retrieve the set of initializers.
Definition Expr.h:5434
Expr * getInit(unsigned Init)
Definition Expr.h:5448
child_range children()
Definition Expr.h:5584
void reserveInits(const ASTContext &C, unsigned NumInits)
Reserve space for some number of initializers.
Definition Expr.cpp:2456
void setLocation(SourceLocation Location)
Definition Expr.h:1583
child_range children()
Definition Expr.h:1590
SourceLocation getEndLoc() const LLVM_READONLY
Definition Expr.h:1578
static bool classof(const Stmt *T)
Definition Expr.h:1585
SourceLocation getLocation() const
Retrieve the location of the literal.
Definition Expr.h:1581
const_child_range children() const
Definition Expr.h:1593
SourceLocation getBeginLoc() const LLVM_READONLY
Definition Expr.h:1577
Represents the declaration of a label.
Definition Decl.h:526
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
Represents a prvalue temporary that is written into memory so that a reference can bind to it.
Definition ExprCXX.h:4974
MatrixElementExpr(QualType Ty, ExprValueKind VK, Expr *Base, IdentifierInfo &Accessor, SourceLocation Loc)
Definition Expr.h:6730
bool containsDuplicateElements() const
containsDuplicateElements - Return true if any element access is repeated.
Definition Expr.cpp:4579
void getEncodedElementAccess(SmallVectorImpl< uint32_t > &Elts) const
getEncodedElementAccess - Encode the elements accessed into an llvm aggregate Constant of ConstantInt...
Definition Expr.cpp:4630
unsigned getNumElements() const
getNumElements - Get the number of components being selected.
Definition Expr.cpp:4495
static bool classof(const Stmt *T)
Definition Expr.h:6751
MatrixElementExpr(EmptyShell Empty)
Build an empty matrix element expression.
Definition Expr.h:6737
MatrixSingleSubscriptExpr(Expr *Base, Expr *RowIdx, QualType T, SourceLocation RBracketLoc)
matrix[row]
Definition Expr.h:2875
SourceLocation getRBracketLoc() const
Definition Expr.h:2908
const Expr * getRowIdx() const
Definition Expr.h:2895
const_child_range children() const
Definition Expr.h:2923
SourceLocation getBeginLoc() const LLVM_READONLY
Definition Expr.h:2898
void setRBracketLoc(SourceLocation L)
Definition Expr.h:2911
MatrixSingleSubscriptExpr(EmptyShell Shell)
Create an empty matrix single-subscript expression.
Definition Expr.h:2887
SourceLocation getExprLoc() const LLVM_READONLY
Definition Expr.h:2904
const Expr * getBase() const
Definition Expr.h:2891
static bool classof(const Stmt *T)
Definition Expr.h:2915
SourceLocation getEndLoc() const
Definition Expr.h:2902
void setColumnIdx(Expr *E)
Definition Expr.h:2974
SourceLocation getEndLoc() const
Definition Expr.h:2980
void setBase(Expr *E)
Definition Expr.h:2962
const Expr * getBase() const
Definition Expr.h:2961
const_child_range children() const
Definition Expr.h:3001
SourceLocation getRBracketLoc() const
Definition Expr.h:2986
SourceLocation getExprLoc() const LLVM_READONLY
Definition Expr.h:2982
MatrixSubscriptExpr(Expr *Base, Expr *RowIdx, Expr *ColumnIdx, QualType T, SourceLocation RBracketLoc)
Definition Expr.h:2939
const Expr * getRowIdx() const
Definition Expr.h:2965
void setRowIdx(Expr *E)
Definition Expr.h:2966
bool isIncomplete() const
Definition Expr.h:2954
MatrixSubscriptExpr(EmptyShell Shell)
Create an empty matrix subscript expression.
Definition Expr.h:2951
static bool classof(const Stmt *T)
Definition Expr.h:2993
child_range children()
Definition Expr.h:2998
const Expr * getColumnIdx() const
Definition Expr.h:2969
void setRBracketLoc(SourceLocation L)
Definition Expr.h:2989
SourceLocation getBeginLoc() const LLVM_READONLY
Definition Expr.h:2976
MemberExpr - [C99 6.5.2.3] Structure and Union Members.
Definition Expr.h:3433
static MemberExpr * CreateEmpty(const ASTContext &Context, bool HasQualifier, bool HasFoundDecl, bool HasTemplateKWAndArgsInfo, unsigned NumTemplateArgs)
Definition Expr.cpp:1808
ArrayRef< TemplateArgumentLoc > template_arguments() const
Definition Expr.h:3605
void setMemberDecl(ValueDecl *D)
Definition Expr.cpp:1823
SourceLocation getMemberLoc() const
getMemberLoc - Return the location of the "member", in X->F, it is the location of 'F'.
Definition Expr.h:3622
void setMemberLoc(SourceLocation L)
Definition Expr.h:3623
void setHadMultipleCandidates(bool V=true)
Sets the flag telling whether this expression refers to a method that was resolved from an overloaded...
Definition Expr.h:3643
SourceLocation getOperatorLoc() const
Definition Expr.h:3615
void setArrow(bool A)
Definition Expr.h:3618
child_range children()
Definition Expr.h:3666
NestedNameSpecifier getQualifier() const
If the member name was qualified, retrieves the nested-name-specifier that precedes the member name.
Definition Expr.h:3544
static bool classof(const Stmt *T)
Definition Expr.h:3661
SourceLocation getTemplateKeywordLoc() const
Retrieve the location of the template keyword preceding the member name, if any.
Definition Expr.h:3550
NestedNameSpecifierLoc getQualifierLoc() const
If the member name was qualified, retrieves the nested-name-specifier that precedes the member name,...
Definition Expr.h:3535
ValueDecl * getMemberDecl() const
Retrieve the member declaration to which this expression refers.
Definition Expr.h:3516
const_child_range children() const
Definition Expr.h:3667
bool hasExplicitTemplateArgs() const
Determines whether the member name was followed by an explicit template argument list.
Definition Expr.h:3577
friend class ASTReader
Definition Expr.h:3434
NonOdrUseReason isNonOdrUse() const
Is this expression a non-odr-use reference, and if so, why?
Definition Expr.h:3657
bool hasQualifier() const
Determines whether this member expression actually had a C++ nested-name-specifier prior to the name ...
Definition Expr.h:3530
void copyTemplateArgumentsInto(TemplateArgumentListInfo &List) const
Copies the template arguments (if present) into the given structure.
Definition Expr.h:3581
bool isImplicitAccess() const
Determine whether the base of this explicit is implicit.
Definition Expr.h:3631
const TemplateArgumentLoc * getTemplateArgs() const
Retrieve the template arguments provided as part of this template-id.
Definition Expr.h:3589
bool performsVirtualDispatch(const LangOptions &LO) const
Returns true if virtual dispatch is performed.
Definition Expr.h:3651
Expr * getBase() const
Definition Expr.h:3510
unsigned getNumTemplateArgs() const
Retrieve the number of template arguments provided as part of this template-id.
Definition Expr.h:3598
SourceLocation getRAngleLoc() const
Retrieve the location of the right angle bracket ending the explicit template argument list following...
Definition Expr.h:3566
SourceLocation getEndLoc() const LLVM_READONLY
Definition Expr.cpp:1844
void setBase(Expr *E)
Definition Expr.h:3509
friend class ASTStmtWriter
Definition Expr.h:3436
static MemberExpr * CreateImplicit(const ASTContext &C, Expr *Base, bool IsArrow, ValueDecl *MemberDecl, QualType T, ExprValueKind VK, ExprObjectKind OK)
Create an implicit MemberExpr, with no location, qualifier, template arguments, and so on.
Definition Expr.h:3494
bool hadMultipleCandidates() const
Returns true if this member expression refers to a method that was resolved from an overloaded set ha...
Definition Expr.h:3637
bool hasTemplateKeyword() const
Determines whether the member name was preceded by the template keyword.
Definition Expr.h:3573
friend class ASTStmtReader
Definition Expr.h:3435
SourceLocation getBeginLoc() const LLVM_READONLY
Definition Expr.cpp:1830
SourceLocation getLAngleLoc() const
Retrieve the location of the left angle bracket starting the explicit template argument list followin...
Definition Expr.h:3558
DeclarationNameInfo getMemberNameInfo() const
Retrieve the member declaration name info.
Definition Expr.h:3610
bool isArrow() const
Definition Expr.h:3617
SourceLocation getExprLoc() const LLVM_READONLY
Definition Expr.h:3628
DeclAccessPair getFoundDecl() const
Retrieves the declaration found by lookup.
Definition Expr.h:3520
A pointer to member type per C++ 8.3.3 - Pointers to members.
Definition TypeBase.h:3751
This represents a decl that may have a name.
Definition Decl.h:276
A C++ nested-name-specifier augmented with source location information.
NestedNameSpecifier getNestedNameSpecifier() const
Retrieve the nested-name-specifier to which this instance refers.
SourceLocation getBeginLoc() const
Retrieve the location of the beginning of this nested-name-specifier.
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
static bool classof(const Stmt *T)
Definition Expr.h:5973
SourceLocation getEndLoc() const LLVM_READONLY
Definition Expr.h:5978
child_range children()
Definition Expr.h:5981
SourceLocation getBeginLoc() const LLVM_READONLY
Definition Expr.h:5977
NoInitExpr(QualType ty)
Definition Expr.h:5965
NoInitExpr(EmptyShell Empty)
Definition Expr.h:5970
const_child_range children() const
Definition Expr.h:5984
ObjCPropertyRefExpr - A dot-syntax expression to access an ObjC property.
Definition ExprObjC.h:649
const Expr * getIndexExpr(unsigned Idx) const
Definition Expr.h:2659
SourceLocation getBeginLoc() const LLVM_READONLY
Definition Expr.h:2671
void setOperatorLoc(SourceLocation L)
Definition Expr.h:2630
static OffsetOfExpr * CreateEmpty(const ASTContext &C, unsigned NumComps, unsigned NumExprs)
Definition Expr.cpp:1703
Expr * getIndexExpr(unsigned Idx)
Definition Expr.h:2655
SourceLocation getEndLoc() const LLVM_READONLY
Definition Expr.h:2672
static bool classof(const Stmt *T)
Definition Expr.h:2674
SourceLocation getOperatorLoc() const
getOperatorLoc - Return the location of the operator.
Definition Expr.h:2629
const OffsetOfNode & getComponent(unsigned Idx) const
Definition Expr.h:2643
void setIndexExpr(unsigned Idx, Expr *E)
Definition Expr.h:2663
TypeSourceInfo * getTypeSourceInfo() const
Definition Expr.h:2636
void setTypeSourceInfo(TypeSourceInfo *tsi)
Definition Expr.h:2639
const_child_range children() const
Definition Expr.h:2683
child_range children()
Definition Expr.h:2679
void setComponent(unsigned Idx, OffsetOfNode ON)
Definition Expr.h:2647
unsigned getNumExpressions() const
Definition Expr.h:2667
SourceLocation getRParenLoc() const
Return the location of the right parentheses.
Definition Expr.h:2633
void setRParenLoc(SourceLocation R)
Definition Expr.h:2634
friend TrailingObjects
Definition Expr.h:2688
unsigned getNumComponents() const
Definition Expr.h:2651
Helper class for OffsetOfExpr.
Definition Expr.h:2490
const IdentifierInfo * getFieldName() const
For a field or identifier offsetof node, returns the name of the field.
Definition Expr.cpp:1725
unsigned getArrayExprIndex() const
For an array element node, returns the index into the array of expressions.
Definition Expr.h:2548
FieldDecl * getField() const
For a field offsetof node, returns the field.
Definition Expr.h:2554
OffsetOfNode(const CXXBaseSpecifier *Base)
Create an offsetof node that refers into a C++ base class.
Definition Expr.h:2540
OffsetOfNode(SourceLocation LBracketLoc, unsigned Index, SourceLocation RBracketLoc)
Create an offsetof node that refers to an array element.
Definition Expr.h:2524
SourceRange getSourceRange() const LLVM_READONLY
Retrieve the source range that covers this offsetof node.
Definition Expr.h:2575
Kind
The kind of offsetof node we have.
Definition Expr.h:2493
@ Array
An index into an array.
Definition Expr.h:2495
@ Identifier
A field in a dependent type, known only by its name.
Definition Expr.h:2499
@ Field
A field.
Definition Expr.h:2497
@ Base
An implicit indirection through a C++ base class, when the field found is in a base class.
Definition Expr.h:2502
SourceLocation getBeginLoc() const LLVM_READONLY
Definition Expr.h:2576
Kind getKind() const
Determine what kind of offsetof node this is.
Definition Expr.h:2544
OffsetOfNode(SourceLocation DotLoc, FieldDecl *Field, SourceLocation NameLoc)
Create an offsetof node that refers to a field.
Definition Expr.h:2529
SourceLocation getEndLoc() const LLVM_READONLY
Definition Expr.h:2577
CXXBaseSpecifier * getBase() const
For a base class node, returns the base specifier.
Definition Expr.h:2564
OffsetOfNode(SourceLocation DotLoc, const IdentifierInfo *Name, SourceLocation NameLoc)
Create an offsetof node that refers to an identifier.
Definition Expr.h:2534
OpaqueValueExpr - An expression referring to an opaque object of a fixed type and value class.
Definition Expr.h:1223
static const OpaqueValueExpr * findInCopyConstruct(const Expr *expr)
Given an expression which invokes a copy constructor — i.e.
Definition Expr.cpp:5213
OpaqueValueExpr(EmptyShell Empty)
Definition Expr.h:1241
OpaqueValueExpr(SourceLocation Loc, QualType T, ExprValueKind VK, ExprObjectKind OK=OK_Ordinary, Expr *SourceExpr=nullptr)
Definition Expr.h:1228
SourceLocation getBeginLoc() const LLVM_READONLY
Definition Expr.h:1247
SourceLocation getEndLoc() const LLVM_READONLY
Definition Expr.h:1250
static bool classof(const Stmt *T)
Definition Expr.h:1283
Expr * getSourceExpr() const
The source expression of an opaque value expression is the expression which originally generated the ...
Definition Expr.h:1273
SourceLocation getLocation() const
Retrieve the location of this expression.
Definition Expr.h:1245
friend class ASTStmtReader
Definition Expr.h:1224
const_child_range children() const
Definition Expr.h:1261
child_range children()
Definition Expr.h:1257
SourceLocation getExprLoc() const LLVM_READONLY
Definition Expr.h:1253
bool isUnique() const
Definition Expr.h:1281
void setIsUnique(bool V)
Definition Expr.h:1275
static OpenACCAsteriskSizeExpr * CreateEmpty(const ASTContext &C)
Definition Expr.cpp:5720
SourceLocation getEndLoc() const
Definition Expr.h:2175
SourceLocation getLocation() const
Definition Expr.h:2176
const_child_range children() const
Definition Expr.h:2186
SourceLocation getBeginLoc() const
Definition Expr.h:2174
static bool classof(const Stmt *T)
Definition Expr.h:2178
ParenExpr(SourceLocation l, SourceLocation r, Expr *val)
Definition Expr.h:2256
SourceLocation getLParen() const
Get the location of the left parentheses '('.
Definition Expr.h:2276
Expr * getSubExpr()
Definition Expr.h:2269
static bool classof(const Stmt *T)
Definition Expr.h:2283
ParenExpr(EmptyShell Empty)
Construct an empty parenthesized expression.
Definition Expr.h:2265
void setLParen(SourceLocation Loc)
Definition Expr.h:2277
void setIsProducedByFoldExpansion(bool ProducedByFoldExpansion=true)
Definition Expr.h:2296
const_child_range children() const
Definition Expr.h:2289
void setRParen(SourceLocation Loc)
Definition Expr.h:2281
SourceLocation getBeginLoc() const LLVM_READONLY
Definition Expr.h:2272
child_range children()
Definition Expr.h:2288
const Expr * getSubExpr() const
Definition Expr.h:2268
bool isProducedByFoldExpansion() const
Definition Expr.h:2293
SourceLocation getRParen() const
Get the location of the right parentheses ')'.
Definition Expr.h:2280
SourceLocation getEndLoc() const LLVM_READONLY
Definition Expr.h:2273
void setSubExpr(Expr *E)
Definition Expr.h:2270
Expr *const * getExprs() const
Definition Expr.h:6209
static ParenListExpr * CreateEmpty(const ASTContext &Ctx, unsigned NumExprs)
Create an empty paren list.
Definition Expr.cpp:5025
SourceLocation getBeginLoc() const
Definition Expr.h:6217
Expr * getExpr(unsigned Init)
Definition Expr.h:6198
ArrayRef< Expr * > exprs() const
Definition Expr.h:6213
const Expr * getExpr(unsigned Init) const
Definition Expr.h:6203
const_child_range children() const
Definition Expr.h:6228
Expr ** getExprs()
Definition Expr.h:6207
SourceLocation getEndLoc() const
Definition Expr.h:6218
unsigned getNumExprs() const
Return the number of expressions in this paren list.
Definition Expr.h:6196
SourceLocation getLParenLoc() const
Definition Expr.h:6215
friend class ASTStmtReader
Definition Expr.h:6173
SourceLocation getRParenLoc() const
Definition Expr.h:6216
static bool classof(const Stmt *T)
Definition Expr.h:6220
child_range children()
Definition Expr.h:6225
Represents a parameter to a function.
Definition Decl.h:1832
SourceLocation getBeginLoc() const
Definition Expr.h:2139
void setLocation(SourceLocation L)
Definition Expr.h:2116
static bool classof(const Stmt *T)
Definition Expr.h:2142
SourceLocation getEndLoc() const
Definition Expr.h:2140
const StringLiteral * getFunctionName() const
Definition Expr.h:2124
StringRef getIdentKindName() const
Definition Expr.h:2131
static PredefinedExpr * CreateEmpty(const ASTContext &Ctx, bool HasFunctionName)
Create an empty PredefinedExpr.
Definition Expr.cpp:652
bool isTransparent() const
Definition Expr.h:2113
static std::string ComputeName(PredefinedIdentKind IK, const Decl *CurrentDecl, bool ForceElaboratedPrinting=false)
Definition Expr.cpp:683
const_child_range children() const
Definition Expr.h:2151
child_range children()
Definition Expr.h:2147
PredefinedIdentKind getIdentKind() const
Definition Expr.h:2109
SourceLocation getLocation() const
Definition Expr.h:2115
friend class ASTStmtReader
Definition Expr.h:2075
StringLiteral * getFunctionName()
Definition Expr.h:2118
PseudoObjectExpr - An expression which accesses a pseudo-object l-value.
Definition Expr.h:6890
const Expr * getResultExpr() const
Definition Expr.h:6943
const_semantics_iterator semantics_begin() const
Definition Expr.h:6952
semantics_iterator semantics_end()
Definition Expr.h:6955
SourceLocation getExprLoc() const LLVM_READONLY
Definition Expr.h:6976
unsigned getResultExprIndex() const
Return the index of the result-bearing expression into the semantics expressions, or PseudoObjectExpr...
Definition Expr.h:6932
semantics_iterator semantics_begin()
Definition Expr.h:6951
const Expr *const * const_semantics_iterator
Definition Expr.h:6950
SourceLocation getBeginLoc() const LLVM_READONLY
Definition Expr.h:6980
Expr *const * semantics_iterator
Definition Expr.h:6949
const_semantics_iterator semantics_end() const
Definition Expr.h:6958
const Expr * getSyntacticForm() const
Definition Expr.h:6928
static bool classof(const Stmt *T)
Definition Expr.h:6999
const Expr * getSemanticExpr(unsigned index) const
Definition Expr.h:6972
Expr * getResultExpr()
Return the result-bearing expression, or null if there is none.
Definition Expr.h:6938
child_range children()
Definition Expr.h:6987
ArrayRef< Expr * > semantics()
Definition Expr.h:6962
ArrayRef< const Expr * > semantics() const
Definition Expr.h:6965
unsigned getNumSemanticExprs() const
Definition Expr.h:6947
friend class ASTStmtReader
Definition Expr.h:7004
Expr * getSemanticExpr(unsigned index)
Definition Expr.h:6969
Expr * getSyntacticForm()
Return the syntactic form of this expression, i.e.
Definition Expr.h:6927
SourceLocation getEndLoc() const LLVM_READONLY
Definition Expr.h:6983
const_child_range children() const
Definition Expr.h:6993
A (possibly-)qualified type.
Definition TypeBase.h:938
bool isVolatileQualified() const
Determine whether this type is volatile-qualified.
Definition TypeBase.h:8530
bool isNull() const
Return true if this QualType doesn't point to a type yet.
Definition TypeBase.h:1005
Represents a struct/union/class.
Definition Decl.h:4476
Frontend produces RecoveryExprs on semantic errors that prevent creating other well-formed expression...
Definition Expr.h:7589
ArrayRef< const Expr * > subExpressions() const
Definition Expr.h:7598
ArrayRef< Expr * > subExpressions()
Definition Expr.h:7596
SourceLocation getEndLoc() const
Definition Expr.h:7608
static bool classof(const Stmt *T)
Definition Expr.h:7610
child_range children()
Definition Expr.h:7602
friend class ASTStmtWriter
Definition Expr.h:7626
friend class ASTStmtReader
Definition Expr.h:7625
SourceLocation getBeginLoc() const
Definition Expr.h:7607
static RecoveryExpr * CreateEmpty(ASTContext &Ctx, unsigned NumSubExprs)
Definition Expr.cpp:5519
Base for LValueReferenceType and RValueReferenceType.
Definition TypeBase.h:3678
static bool classof(const Stmt *T)
Definition Expr.h:2228
const_child_range children() const
Definition Expr.h:2237
SourceLocation getLocation() const
Definition Expr.h:2224
const TypeSourceInfo * getTypeSourceInfo() const
Definition Expr.h:2214
SourceLocation getLParenLocation() const
Definition Expr.h:2225
TypeSourceInfo * getTypeSourceInfo()
Definition Expr.h:2212
std::string ComputeName(ASTContext &Context) const
Definition Expr.cpp:597
SourceLocation getBeginLoc() const
Definition Expr.h:2222
SourceLocation getRParenLocation() const
Definition Expr.h:2226
SourceLocation getEndLoc() const
Definition Expr.h:2223
static SYCLUniqueStableNameExpr * CreateEmpty(const ASTContext &Ctx)
Definition Expr.cpp:592
Classes implementing SemaProxy present a restricted view of the (possibly mutating) actions and queri...
Definition SemaProxy.h:29
ShuffleVectorExpr(EmptyShell Empty)
Build an empty vector-shuffle expression.
Definition Expr.h:4726
llvm::APSInt getShuffleMaskIdx(unsigned N) const
Definition Expr.h:4764
void setExprs(const ASTContext &C, ArrayRef< Expr * > Exprs)
Definition Expr.cpp:4653
Expr ** getSubExprs()
Retrieve the array of expressions.
Definition Expr.h:4748
const_child_range children() const
Definition Expr.h:4777
child_range children()
Definition Expr.h:4773
ShuffleVectorExpr(const ASTContext &C, ArrayRef< Expr * > args, QualType Type, SourceLocation BLoc, SourceLocation RP)
Definition Expr.cpp:4640
SourceLocation getBuiltinLoc() const
Definition Expr.h:4729
SourceLocation getEndLoc() const LLVM_READONLY
Definition Expr.h:4736
void setRParenLoc(SourceLocation L)
Definition Expr.h:4733
const Expr * getExpr(unsigned Index) const
Definition Expr.h:4756
unsigned getNumSubExprs() const
getNumSubExprs - Return the size of the SubExprs array.
Definition Expr.h:4745
static bool classof(const Stmt *T)
Definition Expr.h:4738
SourceLocation getRParenLoc() const
Definition Expr.h:4732
SourceLocation getBeginLoc() const LLVM_READONLY
Definition Expr.h:4735
Expr * getExpr(unsigned Index)
getExpr - Return the Expr at the specified index.
Definition Expr.h:4751
void setBuiltinLoc(SourceLocation L)
Definition Expr.h:4730
SourceLocExpr(EmptyShell Empty)
Build an empty call expression.
Definition Expr.h:5105
SourceLocation getBeginLoc() const
Definition Expr.h:5140
APValue EvaluateInContext(const ASTContext &Ctx, const Expr *DefaultExpr) const
Return the result of evaluating this SourceLocExpr in the specified (and possibly null) default argum...
Definition Expr.cpp:2319
bool isIntType() const
Definition Expr.h:5119
static bool classof(const Stmt *T)
Definition Expr.h:5151
child_range children()
Definition Expr.h:5143
SourceLocExpr(const ASTContext &Ctx, SourceLocIdentKind Type, QualType ResultTy, SourceLocation BLoc, SourceLocation RParenLoc, DeclContext *Context)
Definition Expr.cpp:2286
SourceLocation getLocation() const
Definition Expr.h:5139
const DeclContext * getParentContext() const
If the SourceLocExpr has been resolved return the subexpression representing the resolved value.
Definition Expr.h:5136
SourceLocation getEndLoc() const
Definition Expr.h:5141
DeclContext * getParentContext()
Definition Expr.h:5137
StringRef getBuiltinStr() const
Return a string representing the name of the specific builtin function.
Definition Expr.cpp:2299
const_child_range children() const
Definition Expr.h:5147
static bool MayBeDependent(SourceLocIdentKind Kind)
Definition Expr.h:5155
SourceLocIdentKind getIdentKind() const
Definition Expr.h:5115
friend class ASTStmtReader
Definition Expr.h:5167
Encodes a location in the source.
bool isValid() const
Return true if this is a valid SourceLocation object.
This class handles loading and caching of source files into memory.
A trivial tuple used to represent a source range.
const CompoundStmt * getSubStmt() const
Definition Expr.h:4682
void setRParenLoc(SourceLocation L)
Definition Expr.h:4691
const_child_range children() const
Definition Expr.h:4701
child_range children()
Definition Expr.h:4700
CompoundStmt * getSubStmt()
Definition Expr.h:4681
static bool classof(const Stmt *T)
Definition Expr.h:4695
StmtExpr(CompoundStmt *SubStmt, QualType T, SourceLocation LParenLoc, SourceLocation RParenLoc, unsigned TemplateDepth)
Definition Expr.h:4668
StmtExpr(EmptyShell Empty)
Build an empty statement expression.
Definition Expr.h:4679
void setLParenLoc(SourceLocation L)
Definition Expr.h:4689
SourceLocation getEndLoc() const LLVM_READONLY
Definition Expr.h:4686
unsigned getTemplateDepth() const
Definition Expr.h:4693
SourceLocation getBeginLoc() const LLVM_READONLY
Definition Expr.h:4685
SourceLocation getRParenLoc() const
Definition Expr.h:4690
void setSubStmt(CompoundStmt *S)
Definition Expr.h:4683
SourceLocation getLParenLoc() const
Definition Expr.h:4688
Stmt - This represents one statement.
Definition Stmt.h:85
SourceLocation getEndLoc() const LLVM_READONLY
Definition Stmt.cpp:367
UnaryExprOrTypeTraitExprBitfields UnaryExprOrTypeTraitExprBits
Definition Stmt.h:1362
GenericSelectionExprBitfields GenericSelectionExprBits
Definition Stmt.h:1370
InitListExprBitfields InitListExprBits
Definition Stmt.h:1368
ParenListExprBitfields ParenListExprBits
Definition Stmt.h:1369
ArrayOrMatrixSubscriptExprBitfields ArrayOrMatrixSubscriptExprBits
Definition Stmt.h:1363
ParenExprBitfields ParenExprBits
Definition Stmt.h:1373
StmtIterator child_iterator
Child Iterators: All subclasses must implement 'children' to permit easy iteration over the substatem...
Definition Stmt.h:1590
CallExprBitfields CallExprBits
Definition Stmt.h:1364
ShuffleVectorExprBitfields ShuffleVectorExprBits
Definition Stmt.h:1374
FloatingLiteralBitfields FloatingLiteralBits
Definition Stmt.h:1358
child_iterator child_begin()
Definition Stmt.h:1602
StmtClass getStmtClass() const
Definition Stmt.h:1504
CharacterLiteralBitfields CharacterLiteralBits
Definition Stmt.h:1360
UnaryOperatorBitfields UnaryOperatorBits
Definition Stmt.h:1361
ConstCastIterator< Expr > ConstExprIterator
Definition Stmt.h:1478
SourceLocExprBitfields SourceLocExprBits
Definition Stmt.h:1372
Stmt(StmtClass SC, EmptyShell)
Construct an empty statement.
Definition Stmt.h:1486
ChooseExprBitfields ChooseExprBits
Definition Stmt.h:1378
ConstantExprBitfields ConstantExprBits
Definition Stmt.h:1355
llvm::iterator_range< child_iterator > child_range
Definition Stmt.h:1593
StmtExprBitfields StmtExprBits
Definition Stmt.h:1377
StringLiteralBitfields StringLiteralBits
Definition Stmt.h:1359
OpaqueValueExprBitfields OpaqueValueExprBits
Definition Stmt.h:1418
CastExprBitfields CastExprBits
Definition Stmt.h:1366
MemberExprBitfields MemberExprBits
Definition Stmt.h:1365
DeclRefExprBitfields DeclRefExprBits
Definition Stmt.h:1357
ConstStmtIterator const_child_iterator
Definition Stmt.h:1591
PredefinedExprBitfields PredefinedExprBits
Definition Stmt.h:1356
ConvertVectorExprBitfields ConvertVectorExprBits
Definition Stmt.h:1419
SourceLocation getBeginLoc() const LLVM_READONLY
Definition Stmt.cpp:355
BinaryOperatorBitfields BinaryOperatorBits
Definition Stmt.h:1367
PseudoObjectExprBitfields PseudoObjectExprBits
Definition Stmt.h:1371
ExprBitfields ExprBits
Definition Stmt.h:1354
llvm::iterator_range< const_child_iterator > const_child_range
Definition Stmt.h:1594
CastIterator< Expr > ExprIterator
Definition Stmt.h:1477
The streaming interface shared between DiagnosticBuilder and PartialDiagnostic.
void AddTaggedVal(uint64_t V, DiagnosticsEngine::ArgumentKind Kind) const
StringLiteral - This represents a string literal expression, e.g.
Definition Expr.h:1844
const_child_range children() const
Definition Expr.h:2053
UnsignedOrNone findZeroCodeUnit(unsigned StartIndex=0) const
Scan the string literal contents for a code unit with value 0.
Definition Expr.cpp:1414
SourceLocation getStrTokenLoc(unsigned TokNum) const
Get one of the string literal token.
Definition Expr.h:2015
SourceLocation getBeginLoc() const LLVM_READONLY
Definition Expr.h:2042
bool containsNonAscii() const
Scans the string contents for any non-ascii characters.
Definition Expr.h:1989
bool isUTF8() const
Definition Expr.h:1979
bool isWide() const
Definition Expr.h:1978
bool containsNonAsciiOrNull() const
Scans the string contents for any non-ascii or null characters.
Definition Expr.h:2001
bool isPascal() const
Definition Expr.h:1983
unsigned getLength() const
Definition Expr.h:1969
static bool classof(const Stmt *T)
Definition Expr.h:2045
uint32_t getCodeUnit(size_t I) const
Return the code unit at the given position.
Definition Expr.h:1931
tokloc_iterator tokloc_begin() const
Definition Expr.h:2034
tokloc_iterator tokloc_end() const
Definition Expr.h:2038
child_range children()
Definition Expr.h:2050
StringLiteralKind getKind() const
Definition Expr.h:1973
SourceLocation getLocationOfByte(unsigned ByteNo, const SourceManager &SM, const LangOptions &Features, const TargetInfo &Target, unsigned *StartToken=nullptr, unsigned *StartTokenByteOffset=nullptr) const
Return a source location that points to the specified byte of this string literal.
Definition Expr.cpp:1336
StringRef getBytes() const
Allow access to clients that need the byte representation, such as ASTWriterStmt::VisitStringLiteral(...
Definition Expr.h:1920
bool isUnevaluated() const
Definition Expr.h:1982
void outputString(raw_ostream &OS) const
Prints the contents of the string to OS.
Definition Expr.cpp:1219
bool isUTF32() const
Definition Expr.h:1981
int64_t getCodeUnitS(size_t I, uint64_t BitWidth) const
Definition Expr.h:1945
unsigned getByteLength() const
Definition Expr.h:1967
StringRef getString() const
Definition Expr.h:1912
friend class ASTStmtReader
Definition Expr.h:1845
bool isUTF16() const
Definition Expr.h:1980
static StringLiteral * CreateEmpty(const ASTContext &Ctx, unsigned NumConcatenated, unsigned Length, unsigned CharByteWidth)
Construct an empty string literal.
Definition Expr.cpp:1208
SourceLocation getEndLoc() const LLVM_READONLY
Definition Expr.h:2043
const SourceLocation * tokloc_iterator
Definition Expr.h:2032
unsigned getNumConcatenated() const
Get the number of string literal tokens that were concatenated in translation phase #6 to form this s...
Definition Expr.h:2010
bool isOrdinary() const
Definition Expr.h:1977
unsigned getCharByteWidth() const
Definition Expr.h:1971
Exposes information about the current target.
Definition TargetInfo.h:228
A convenient class for passing around template argument information.
Location wrapper for a TemplateArgument.
A container of type source information.
Definition TypeBase.h:8417
QualType getType() const
Return the type wrapped by this type source info.
Definition TypeBase.h:8428
The base class of the type hierarchy.
Definition TypeBase.h:1879
bool isPlaceholderType() const
Test for a type which does not represent an actual type-system type but is instead used as a placehol...
Definition TypeBase.h:9044
bool isIntegerType() const
isIntegerType() does not include complex integers (a GCC extension).
Definition TypeBase.h:9116
bool isReferenceType() const
Definition TypeBase.h:8707
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee.
Definition Type.cpp:885
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
Definition TypeBase.h:2863
SourceLocation getRParenLoc() const
Definition Expr.h:2770
SourceLocation getEndLoc() const LLVM_READONLY
Definition Expr.h:2774
void setKind(UnaryExprOrTypeTrait K)
Definition Expr.h:2729
QualType getArgumentType() const
Definition Expr.h:2737
void setOperatorLoc(SourceLocation L)
Definition Expr.h:2768
SourceLocation getOperatorLoc() const
Definition Expr.h:2767
const Expr * getArgumentExpr() const
Definition Expr.h:2748
SourceLocation getBeginLoc() const LLVM_READONLY
Definition Expr.h:2773
void setRParenLoc(SourceLocation L)
Definition Expr.h:2771
static bool classof(const Stmt *T)
Definition Expr.h:2776
QualType getTypeOfArgument() const
Gets the argument type, or the type of the argument expression, whichever is appropriate.
Definition Expr.h:2763
UnaryExprOrTypeTraitExpr(UnaryExprOrTypeTrait ExprKind, TypeSourceInfo *TInfo, QualType resultType, SourceLocation op, SourceLocation rp)
Definition Expr.h:2702
TypeSourceInfo * getArgumentTypeInfo() const
Definition Expr.h:2740
UnaryExprOrTypeTraitExpr(EmptyShell Empty)
Construct an empty sizeof/alignof expression.
Definition Expr.h:2723
UnaryExprOrTypeTrait getKind() const
Definition Expr.h:2726
void setArgument(TypeSourceInfo *TInfo)
Definition Expr.h:2756
UnaryOperator - This represents the unary-expression's (except sizeof and alignof),...
Definition Expr.h:2313
static bool classof(const Stmt *T)
Definition Expr.h:2439
static bool isPostfix(Opcode Op)
isPostfix - Return true if this is a postfix operation, like x++.
Definition Expr.h:2383
bool isDecrementOp() const
Definition Expr.h:2405
void setSubExpr(Expr *E)
Definition Expr.h:2355
SourceLocation getExprLoc() const
Definition Expr.h:2437
bool isPostfix() const
Definition Expr.h:2393
bool isFEnvAccessOn(const LangOptions &LO) const
Get the FENV_ACCESS status of this operator.
Definition Expr.h:2378
bool isPrefix() const
Definition Expr.h:2392
void setOperatorLoc(SourceLocation L)
Definition Expr.h:2359
SourceLocation getOperatorLoc() const
getOperatorLoc - Return the location of the operator.
Definition Expr.h:2358
Expr * getSubExpr() const
Definition Expr.h:2354
friend class ASTReader
Definition Expr.h:2482
SourceLocation getEndLoc() const LLVM_READONLY
Definition Expr.h:2434
bool isArithmeticOp() const
Definition Expr.h:2417
void setCanOverflow(bool C)
Definition Expr.h:2368
UnaryOperator(bool HasFPFeatures, EmptyShell Empty)
Build an empty unary operator.
Definition Expr.h:2335
Opcode getOpcode() const
Definition Expr.h:2349
friend class ASTNodeImporter
Definition Expr.h:2481
bool hasStoredFPFeatures() const
Is FPFeatures in Trailing Storage?
Definition Expr.h:2450
static OverloadedOperatorKind getOverloadedOperator(Opcode Opc)
Retrieve the overloaded operator kind that corresponds to the given unary opcode.
Definition Expr.cpp:1462
void setOpcode(Opcode Opc)
Definition Expr.h:2352
child_range children()
Definition Expr.h:2444
static bool isIncrementOp(Opcode Op)
Definition Expr.h:2395
static bool isIncrementDecrementOp(Opcode Op)
Definition Expr.h:2409
SourceLocation getBeginLoc() const LLVM_READONLY
Definition Expr.h:2431
static bool isDecrementOp(Opcode Op)
Definition Expr.h:2402
FPOptionsOverride getStoredFPFeaturesOrDefault() const
Get the store FPOptionsOverride or default if not stored.
Definition Expr.h:2458
FPOptionsOverride getStoredFPFeatures() const
Get FPFeatures from trailing storage.
Definition Expr.h:2453
bool isFPContractableWithinStatement(const LangOptions &LO) const
Get the FP contractibility status of this operator.
Definition Expr.h:2372
static Opcode getOverloadedOpcode(OverloadedOperatorKind OO, bool Postfix)
Retrieve the unary opcode that corresponds to the given overloaded operator.
Definition Expr.cpp:1447
FPOptions getFPFeaturesInEffect(const LangOptions &LO) const
Get the FP features status of this operator.
Definition Expr.h:2469
friend class ASTStmtWriter
Definition Expr.h:2484
void setStoredFPFeatures(FPOptionsOverride F)
Set FPFeatures in trailing storage, used by Serialization & ASTImporter.
Definition Expr.h:2464
UnaryOperatorKind Opcode
Definition Expr.h:2327
UnaryOperator(const ASTContext &Ctx, Expr *input, Opcode opc, QualType type, ExprValueKind VK, ExprObjectKind OK, SourceLocation l, bool CanOverflow, FPOptionsOverride FPFeatures)
Definition Expr.cpp:5187
FPOptionsOverride getFPOptionsOverride() const
Definition Expr.h:2474
friend class ASTStmtReader
Definition Expr.h:2483
static UnaryOperator * CreateEmpty(const ASTContext &C, bool hasFPFeatures)
Definition Expr.cpp:5180
static bool isPrefix(Opcode Op)
isPrefix - Return true if this is a prefix operation, like –x.
Definition Expr.h:2388
friend TrailingObjects
Definition Expr.h:2480
static StringRef getOpcodeStr(Opcode Op)
getOpcodeStr - Turn an Opcode enum value into the punctuation char it corresponds to,...
Definition Expr.cpp:1438
static bool isArithmeticOp(Opcode Op)
Definition Expr.h:2414
bool isIncrementDecrementOp() const
Definition Expr.h:2410
bool isIncrementOp() const
Definition Expr.h:2398
const_child_range children() const
Definition Expr.h:2445
bool canOverflow() const
Returns true if the unary operator can cause an overflow.
Definition Expr.h:2367
void setVarargABI(VarArgKind Kind)
Definition Expr.h:5051
void setRParenLoc(SourceLocation L)
Definition Expr.h:5066
TypeSourceInfo * getWrittenTypeInfo() const
Definition Expr.h:5059
child_range children()
Definition Expr.h:5076
SourceLocation getBuiltinLoc() const
Definition Expr.h:5062
SourceLocation getRParenLoc() const
Definition Expr.h:5065
bool isZOSABI() const
Returns whether this is really a z/OS ABI va_arg expression.
Definition Expr.h:5057
VAArgExpr(EmptyShell Empty)
Create an empty __builtin_va_arg expression.
Definition Expr.h:5043
Expr * getSubExpr()
Definition Expr.h:5047
bool isMicrosoftABI() const
Returns whether this is really a Win64 ABI va_arg expression.
Definition Expr.h:5054
void setSubExpr(Expr *E)
Definition Expr.h:5048
static bool classof(const Stmt *T)
Definition Expr.h:5071
SourceLocation getBeginLoc() const LLVM_READONLY
Definition Expr.h:5068
VAArgExpr(SourceLocation BLoc, Expr *e, TypeSourceInfo *TInfo, SourceLocation RPLoc, QualType t, VarArgKind VaKind)
Definition Expr.h:5035
SourceLocation getEndLoc() const LLVM_READONLY
Definition Expr.h:5069
void setBuiltinLoc(SourceLocation L)
Definition Expr.h:5063
VarArgKind getVarargABI() const
Definition Expr.h:5050
void setWrittenTypeInfo(TypeSourceInfo *TI)
Definition Expr.h:5060
const_child_range children() const
Definition Expr.h:5077
const Expr * getSubExpr() const
Definition Expr.h:5046
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
Definition Decl.h:714
Represents a statement that could possibly have a value and type.
Definition Stmt.h:2138
Stmt(StmtClass SC, EmptyShell)
Construct an empty statement.
Definition Stmt.h:1486
Represents a variable declaration or definition.
Definition Decl.h:934
Definition SPIR.cpp:47
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
const internal::VariadicDynCastAllOfMatcher< Stmt, Expr > expr
Matches expressions.
bool Const(InterpState &S, const T &Arg)
Definition Interp.h:1569
Top level wrappers for InstallAPI frontend operations.
LLVM_READNONE bool isASCII(char c)
Returns true if a byte is an ASCII character.
Definition CharInfo.h:41
OverloadedOperatorKind
Enumeration specifying the different kinds of C++ overloaded operators.
ConstantResultStorageKind
Describes the kind of result that can be tail-allocated.
Definition Expr.h:1121
bool isa(CodeGen::Address addr)
Definition Address.h:330
const Expr * findStructFieldAccess(const Expr *E, const Expr **OutArrayIndex=nullptr, QualType *OutArrayElementTy=nullptr)
Walk E through parens, implicit casts, unary &/*, array subscripts and comma operators to find the he...
Definition Expr.cpp:5807
ExprDependenceScope::ExprDependence ExprDependence
StmtIterator cast_away_const(const ConstStmtIterator &RHS)
ExprObjectKind
A further classification of the kind of object referenced by an l-value or x-value.
Definition Specifiers.h:153
@ OK_VectorComponent
A vector component is an element or range of elements of a vector.
Definition Specifiers.h:161
@ OK_Ordinary
An ordinary object is located at an address in memory.
Definition Specifiers.h:155
@ OK_BitField
A bitfield object is a bitfield on a C or C++ record.
Definition Specifiers.h:158
@ OK_MatrixComponent
A matrix component is a single element or range of elements of a matrix.
Definition Specifiers.h:173
Expr::ConstantExprKind ConstantExprKind
Definition Expr.h:1087
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',...
@ Result
The result type of a method or function.
Definition TypeBase.h:906
OptionalUnsigned< unsigned > UnsignedOrNone
const FunctionProtoType * T
CastKind
CastKind - The kind of operation required for a conversion.
std::pair< SourceLocation, PartialDiagnostic > PartialDiagnosticAt
A partial diagnostic along with the source location where this diagnostic occurs.
ExprValueKind
The categorization of expression values, currently following the C++11 scheme.
Definition Specifiers.h:136
@ VK_PRValue
A pr-value expression (in the C++11 taxonomy) produces a temporary value.
Definition Specifiers.h:139
@ VK_XValue
An x-value expression is a reference to an object with independent storage but which can be "moved",...
Definition Specifiers.h:148
@ VK_LValue
An l-value expression is a reference to an object with independent storage.
Definition Specifiers.h:143
SmallVector< CXXBaseSpecifier *, 4 > CXXCastPath
A simple array of base specifiers.
Definition ASTContext.h:147
StringLiteralKind
Definition Expr.h:1808
const StreamingDiagnostic & operator<<(const StreamingDiagnostic &DB, const ConceptReference *C)
Insertion operator for diagnostics.
U cast(CodeGen::Address addr)
Definition Address.h:327
SourceLocIdentKind
Definition Expr.h:5082
@ Other
Other implicit parameter.
Definition Decl.h:1787
PredefinedIdentKind
Definition Expr.h:2058
@ PrettyFunctionNoVirtual
The same as PrettyFunction, except that the 'virtual' keyword is omitted for virtual member functions...
Definition Expr.h:2068
CharacterLiteralKind
Definition Expr.h:1648
NonOdrUseReason
The reason why a DeclRefExpr does not constitute an odr-use.
Definition Specifiers.h:177
@ NOUR_None
This is an odr-use.
Definition Specifiers.h:179
unsigned long uint64_t
__UINTPTR_TYPE__ uintptr_t
An unsigned integer type with the property that any valid pointer to void can be converted to this ty...
__builtin_bitreverse32 uint32_t __builtin_riscv_aaddu_u32 __builtin_riscv_asubu_u32 __builtin_elementwise_add_sat __builtin_elementwise_sub_sat int32_t uint32_t uint32_t __builtin_riscv_mhacc_i32 __builtin_riscv_mhaccu_u32 __builtin_riscv_mhaccsu_i32 __builtin_riscv_mulq_i32 __builtin_riscv_mqwacc_i64 __packed_splat4 uint16_t
__builtin_bitreverse32 uint32_t __builtin_riscv_aaddu_u32 __builtin_riscv_asubu_u32 __builtin_elementwise_add_sat __builtin_elementwise_sub_sat int32_t uint32_t uint32_t __builtin_riscv_mhacc_i32 __builtin_riscv_mhaccu_u32 __builtin_riscv_mhaccsu_i32 __builtin_riscv_mulq_i32 int64_t
#define true
Definition stdbool.h:25
BlockVarCopyInit(Expr *CopyExpr, bool CanThrow)
Definition Expr.h:6806
Expr * getCopyExpr() const
Definition Expr.h:6811
llvm::PointerIntPair< Expr *, 1, bool > ExprAndFlag
Definition Expr.h:6813
bool canThrow() const
Definition Expr.h:6812
void setExprAndFlag(Expr *CopyExpr, bool CanThrow)
Definition Expr.h:6808
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspon...
Stores data related to a single embed directive.
Definition Expr.h:5171
StringLiteral * BinaryData
Definition Expr.h:5172
size_t getDataElementCount() const
Definition Expr.h:5176
EvalResult is a struct with detailed info about an evaluated expression.
Definition Expr.h:667
APValue Val
Val - This is the value the expression can be folded to.
Definition Expr.h:669
bool isGlobalLValue() const
Return true if the evaluated lvalue expression is global.
bool hasSideEffects() const
Return true if the evaluated expression has side effects.
Definition Expr.h:661
SmallVectorImpl< PartialDiagnosticAt > * Diag
Diag - If this is non-null, it will be filled in with a stack of notes indicating why evaluation fail...
Definition Expr.h:651
bool DiagEmitted
Whether any diagnostic has been emitted.
Definition Expr.h:635
bool HasUndefinedBehavior
Whether the evaluation hit undefined behavior.
Definition Expr.h:631
bool HasSideEffects
Whether the evaluated expression has side effects.
Definition Expr.h:626
SmallVectorImpl< PartialDiagnosticAt > * ExtendedDiag
Location where we spot ptr to int cast or null subobject while evaluating constant expression in MS c...
Definition Expr.h:655
A placeholder type used to construct an empty shell of a type, that will be filled in later (e....
Definition Stmt.h:1444
const CastExpr * BasePath
Definition Expr.h:78
const CXXRecordDecl * DerivedClass
Definition Expr.h:79
const MemberPointerType * MPT
Definition Expr.h:83
const FieldDecl * Field
Definition Expr.h:89
SubobjectAdjustment(const MemberPointerType *MPT, Expr *RHS)
Definition Expr.h:104
SubobjectAdjustment(const FieldDecl *Field)
Definition Expr.h:100
SubobjectAdjustment(const CastExpr *BasePath, const CXXRecordDecl *DerivedClass)
Definition Expr.h:93
struct DTB DerivedToBase
Definition Expr.h:88
enum clang::SubobjectAdjustment::@253221166153022235222106274120241151060023135167 Kind