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