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