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