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