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