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