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