clang  10.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 
16 #include "clang/AST/APValue.h"
17 #include "clang/AST/ASTVector.h"
18 #include "clang/AST/Decl.h"
21 #include "clang/AST/Stmt.h"
22 #include "clang/AST/TemplateBase.h"
23 #include "clang/AST/Type.h"
24 #include "clang/Basic/CharInfo.h"
25 #include "clang/Basic/FixedPoint.h"
27 #include "clang/Basic/SyncScope.h"
28 #include "clang/Basic/TypeTraits.h"
29 #include "llvm/ADT/APFloat.h"
30 #include "llvm/ADT/APSInt.h"
31 #include "llvm/ADT/iterator.h"
32 #include "llvm/ADT/iterator_range.h"
33 #include "llvm/ADT/SmallVector.h"
34 #include "llvm/ADT/StringRef.h"
35 #include "llvm/Support/AtomicOrdering.h"
36 #include "llvm/Support/Compiler.h"
37 #include "llvm/Support/TrailingObjects.h"
38 
39 namespace clang {
40  class APValue;
41  class ASTContext;
42  class BlockDecl;
43  class CXXBaseSpecifier;
44  class CXXMemberCallExpr;
45  class CXXOperatorCallExpr;
46  class CastExpr;
47  class Decl;
48  class IdentifierInfo;
49  class MaterializeTemporaryExpr;
50  class NamedDecl;
51  class ObjCPropertyRefExpr;
52  class OpaqueValueExpr;
53  class ParmVarDecl;
54  class StringLiteral;
55  class TargetInfo;
56  class ValueDecl;
57 
58 /// A simple array of base specifiers.
60 
61 /// An adjustment to be made to the temporary created when emitting a
62 /// reference binding, which accesses a particular subobject of that temporary.
64  enum {
68  } Kind;
69 
70  struct DTB {
73  };
74 
75  struct P {
78  };
79 
80  union {
83  struct P Ptr;
84  };
85 
88  : Kind(DerivedToBaseAdjustment) {
91  }
92 
94  : Kind(FieldAdjustment) {
95  this->Field = Field;
96  }
97 
99  : Kind(MemberPointerAdjustment) {
100  this->Ptr.MPT = MPT;
101  this->Ptr.RHS = RHS;
102  }
103 };
104 
105 /// This represents one expression. Note that Expr's are subclasses of Stmt.
106 /// This allows an expression to be transparently used any place a Stmt is
107 /// required.
108 class Expr : public ValueStmt {
109  QualType TR;
110 
111 public:
112  Expr() = delete;
113  Expr(const Expr&) = delete;
114  Expr(Expr &&) = delete;
115  Expr &operator=(const Expr&) = delete;
116  Expr &operator=(Expr&&) = delete;
117 
118 protected:
120  bool TD, bool VD, bool ID, bool ContainsUnexpandedParameterPack)
121  : ValueStmt(SC)
122  {
123  ExprBits.TypeDependent = TD;
124  ExprBits.ValueDependent = VD;
125  ExprBits.InstantiationDependent = ID;
126  ExprBits.ValueKind = VK;
127  ExprBits.ObjectKind = OK;
128  assert(ExprBits.ObjectKind == OK && "truncated kind");
129  ExprBits.ContainsUnexpandedParameterPack = ContainsUnexpandedParameterPack;
130  setType(T);
131  }
132 
133  /// Construct an empty expression.
134  explicit Expr(StmtClass SC, EmptyShell) : ValueStmt(SC) { }
135 
136 public:
137  QualType getType() const { return TR; }
138  void setType(QualType t) {
139  // In C++, the type of an expression is always adjusted so that it
140  // will not have reference type (C++ [expr]p6). Use
141  // QualType::getNonReferenceType() to retrieve the non-reference
142  // type. Additionally, inspect Expr::isLvalue to determine whether
143  // an expression that is adjusted in this manner should be
144  // considered an lvalue.
145  assert((t.isNull() || !t->isReferenceType()) &&
146  "Expressions can't have reference type");
147 
148  TR = t;
149  }
150 
151  /// isValueDependent - Determines whether this expression is
152  /// value-dependent (C++ [temp.dep.constexpr]). For example, the
153  /// array bound of "Chars" in the following example is
154  /// value-dependent.
155  /// @code
156  /// template<int Size, char (&Chars)[Size]> struct meta_string;
157  /// @endcode
158  bool isValueDependent() const { return ExprBits.ValueDependent; }
159 
160  /// Set whether this expression is value-dependent or not.
161  void setValueDependent(bool VD) {
162  ExprBits.ValueDependent = VD;
163  }
164 
165  /// isTypeDependent - Determines whether this expression is
166  /// type-dependent (C++ [temp.dep.expr]), which means that its type
167  /// could change from one template instantiation to the next. For
168  /// example, the expressions "x" and "x + y" are type-dependent in
169  /// the following code, but "y" is not type-dependent:
170  /// @code
171  /// template<typename T>
172  /// void add(T x, int y) {
173  /// x + y;
174  /// }
175  /// @endcode
176  bool isTypeDependent() const { return ExprBits.TypeDependent; }
177 
178  /// Set whether this expression is type-dependent or not.
179  void setTypeDependent(bool TD) {
180  ExprBits.TypeDependent = TD;
181  }
182 
183  /// Whether this expression is instantiation-dependent, meaning that
184  /// it depends in some way on a template parameter, even if neither its type
185  /// nor (constant) value can change due to the template instantiation.
186  ///
187  /// In the following example, the expression \c sizeof(sizeof(T() + T())) is
188  /// instantiation-dependent (since it involves a template parameter \c T), but
189  /// is neither type- nor value-dependent, since the type of the inner
190  /// \c sizeof is known (\c std::size_t) and therefore the size of the outer
191  /// \c sizeof is known.
192  ///
193  /// \code
194  /// template<typename T>
195  /// void f(T x, T y) {
196  /// sizeof(sizeof(T() + T());
197  /// }
198  /// \endcode
199  ///
201  return ExprBits.InstantiationDependent;
202  }
203 
204  /// Set whether this expression is instantiation-dependent or not.
206  ExprBits.InstantiationDependent = ID;
207  }
208 
209  /// Whether this expression contains an unexpanded parameter
210  /// pack (for C++11 variadic templates).
211  ///
212  /// Given the following function template:
213  ///
214  /// \code
215  /// template<typename F, typename ...Types>
216  /// void forward(const F &f, Types &&...args) {
217  /// f(static_cast<Types&&>(args)...);
218  /// }
219  /// \endcode
220  ///
221  /// The expressions \c args and \c static_cast<Types&&>(args) both
222  /// contain parameter packs.
224  return ExprBits.ContainsUnexpandedParameterPack;
225  }
226 
227  /// Set the bit that describes whether this expression
228  /// contains an unexpanded parameter pack.
229  void setContainsUnexpandedParameterPack(bool PP = true) {
230  ExprBits.ContainsUnexpandedParameterPack = PP;
231  }
232 
233  /// getExprLoc - Return the preferred location for the arrow when diagnosing
234  /// a problem with a generic expression.
235  SourceLocation getExprLoc() const LLVM_READONLY;
236 
237  /// isUnusedResultAWarning - Return true if this immediate expression should
238  /// be warned about if the result is unused. If so, fill in expr, location,
239  /// and ranges with expr to warn on and source locations/ranges appropriate
240  /// for a warning.
241  bool isUnusedResultAWarning(const Expr *&WarnExpr, SourceLocation &Loc,
242  SourceRange &R1, SourceRange &R2,
243  ASTContext &Ctx) const;
244 
245  /// isLValue - True if this expression is an "l-value" according to
246  /// the rules of the current language. C and C++ give somewhat
247  /// different rules for this concept, but in general, the result of
248  /// an l-value expression identifies a specific object whereas the
249  /// result of an r-value expression is a value detached from any
250  /// specific storage.
251  ///
252  /// C++11 divides the concept of "r-value" into pure r-values
253  /// ("pr-values") and so-called expiring values ("x-values"), which
254  /// identify specific objects that can be safely cannibalized for
255  /// their resources. This is an unfortunate abuse of terminology on
256  /// the part of the C++ committee. In Clang, when we say "r-value",
257  /// we generally mean a pr-value.
258  bool isLValue() const { return getValueKind() == VK_LValue; }
259  bool isRValue() const { return getValueKind() == VK_RValue; }
260  bool isXValue() const { return getValueKind() == VK_XValue; }
261  bool isGLValue() const { return getValueKind() != VK_RValue; }
262 
273  LV_ArrayTemporary
274  };
275  /// Reasons why an expression might not be an l-value.
276  LValueClassification ClassifyLValue(ASTContext &Ctx) const;
277 
284  MLV_LValueCast, // Specialized form of MLV_InvalidExpression.
295  MLV_ArrayTemporary
296  };
297  /// isModifiableLvalue - C99 6.3.2.1: an lvalue that does not have array type,
298  /// does not have an incomplete type, does not have a const-qualified type,
299  /// and if it is a structure or union, does not have any member (including,
300  /// recursively, any member or element of all contained aggregates or unions)
301  /// with a const-qualified type.
302  ///
303  /// \param Loc [in,out] - A source location which *may* be filled
304  /// in with the location of the expression making this a
305  /// non-modifiable lvalue, if specified.
307  isModifiableLvalue(ASTContext &Ctx, SourceLocation *Loc = nullptr) const;
308 
309  /// The return type of classify(). Represents the C++11 expression
310  /// taxonomy.
312  public:
313  /// The various classification results. Most of these mean prvalue.
314  enum Kinds {
317  CL_Function, // Functions cannot be lvalues in C.
318  CL_Void, // Void cannot be an lvalue in C.
319  CL_AddressableVoid, // Void expression whose address can be taken in C.
320  CL_DuplicateVectorComponents, // A vector shuffle with dupes.
321  CL_MemberFunction, // An expression referring to a member function
323  CL_ClassTemporary, // A temporary of class type, or subobject thereof.
324  CL_ArrayTemporary, // A temporary of array type.
325  CL_ObjCMessageRValue, // ObjC message is an rvalue
326  CL_PRValue // A prvalue for any other reason, of any other type
327  };
328  /// The results of modification testing.
330  CM_Untested, // testModifiable was false.
332  CM_RValue, // Not modifiable because it's an rvalue
333  CM_Function, // Not modifiable because it's a function; C++ only
334  CM_LValueCast, // Same as CM_RValue, but indicates GCC cast-as-lvalue ext
335  CM_NoSetterProperty,// Implicit assignment to ObjC property without setter
340  CM_IncompleteType
341  };
342 
343  private:
344  friend class Expr;
345 
346  unsigned short Kind;
347  unsigned short Modifiable;
348 
349  explicit Classification(Kinds k, ModifiableType m)
350  : Kind(k), Modifiable(m)
351  {}
352 
353  public:
355 
356  Kinds getKind() const { return static_cast<Kinds>(Kind); }
358  assert(Modifiable != CM_Untested && "Did not test for modifiability.");
359  return static_cast<ModifiableType>(Modifiable);
360  }
361  bool isLValue() const { return Kind == CL_LValue; }
362  bool isXValue() const { return Kind == CL_XValue; }
363  bool isGLValue() const { return Kind <= CL_XValue; }
364  bool isPRValue() const { return Kind >= CL_Function; }
365  bool isRValue() const { return Kind >= CL_XValue; }
366  bool isModifiable() const { return getModifiable() == CM_Modifiable; }
367 
368  /// Create a simple, modifiably lvalue
370  return Classification(CL_LValue, CM_Modifiable);
371  }
372 
373  };
374  /// Classify - Classify this expression according to the C++11
375  /// expression taxonomy.
376  ///
377  /// C++11 defines ([basic.lval]) a new taxonomy of expressions to replace the
378  /// old lvalue vs rvalue. This function determines the type of expression this
379  /// is. There are three expression types:
380  /// - lvalues are classical lvalues as in C++03.
381  /// - prvalues are equivalent to rvalues in C++03.
382  /// - xvalues are expressions yielding unnamed rvalue references, e.g. a
383  /// function returning an rvalue reference.
384  /// lvalues and xvalues are collectively referred to as glvalues, while
385  /// prvalues and xvalues together form rvalues.
387  return ClassifyImpl(Ctx, nullptr);
388  }
389 
390  /// ClassifyModifiable - Classify this expression according to the
391  /// C++11 expression taxonomy, and see if it is valid on the left side
392  /// of an assignment.
393  ///
394  /// This function extends classify in that it also tests whether the
395  /// expression is modifiable (C99 6.3.2.1p1).
396  /// \param Loc A source location that might be filled with a relevant location
397  /// if the expression is not modifiable.
399  return ClassifyImpl(Ctx, &Loc);
400  }
401 
402  /// getValueKindForType - Given a formal return or parameter type,
403  /// give its value kind.
405  if (const ReferenceType *RT = T->getAs<ReferenceType>())
406  return (isa<LValueReferenceType>(RT)
407  ? VK_LValue
408  : (RT->getPointeeType()->isFunctionType()
409  ? VK_LValue : VK_XValue));
410  return VK_RValue;
411  }
412 
413  /// getValueKind - The value kind that this expression produces.
415  return static_cast<ExprValueKind>(ExprBits.ValueKind);
416  }
417 
418  /// getObjectKind - The object kind that this expression produces.
419  /// Object kinds are meaningful only for expressions that yield an
420  /// l-value or x-value.
422  return static_cast<ExprObjectKind>(ExprBits.ObjectKind);
423  }
424 
426  ExprObjectKind OK = getObjectKind();
427  return (OK == OK_Ordinary || OK == OK_BitField);
428  }
429 
430  /// setValueKind - Set the value kind produced by this expression.
431  void setValueKind(ExprValueKind Cat) { ExprBits.ValueKind = Cat; }
432 
433  /// setObjectKind - Set the object kind produced by this expression.
434  void setObjectKind(ExprObjectKind Cat) { ExprBits.ObjectKind = Cat; }
435 
436 private:
437  Classification ClassifyImpl(ASTContext &Ctx, SourceLocation *Loc) const;
438 
439 public:
440 
441  /// Returns true if this expression is a gl-value that
442  /// potentially refers to a bit-field.
443  ///
444  /// In C++, whether a gl-value refers to a bitfield is essentially
445  /// an aspect of the value-kind type system.
446  bool refersToBitField() const { return getObjectKind() == OK_BitField; }
447 
448  /// If this expression refers to a bit-field, retrieve the
449  /// declaration of that bit-field.
450  ///
451  /// Note that this returns a non-null pointer in subtly different
452  /// places than refersToBitField returns true. In particular, this can
453  /// return a non-null pointer even for r-values loaded from
454  /// bit-fields, but it will return null for a conditional bit-field.
455  FieldDecl *getSourceBitField();
456 
457  const FieldDecl *getSourceBitField() const {
458  return const_cast<Expr*>(this)->getSourceBitField();
459  }
460 
461  Decl *getReferencedDeclOfCallee();
463  return const_cast<Expr*>(this)->getReferencedDeclOfCallee();
464  }
465 
466  /// If this expression is an l-value for an Objective C
467  /// property, find the underlying property reference expression.
468  const ObjCPropertyRefExpr *getObjCProperty() const;
469 
470  /// Check if this expression is the ObjC 'self' implicit parameter.
471  bool isObjCSelfExpr() const;
472 
473  /// Returns whether this expression refers to a vector element.
474  bool refersToVectorElement() const;
475 
476  /// Returns whether this expression refers to a global register
477  /// variable.
478  bool refersToGlobalRegisterVar() const;
479 
480  /// Returns whether this expression has a placeholder type.
481  bool hasPlaceholderType() const {
482  return getType()->isPlaceholderType();
483  }
484 
485  /// Returns whether this expression has a specific placeholder type.
488  if (const BuiltinType *BT = dyn_cast<BuiltinType>(getType()))
489  return BT->getKind() == K;
490  return false;
491  }
492 
493  /// isKnownToHaveBooleanValue - Return true if this is an integer expression
494  /// that is known to return 0 or 1. This happens for _Bool/bool expressions
495  /// but also int expressions which are produced by things like comparisons in
496  /// C.
497  ///
498  /// \param Semantic If true, only return true for expressions that are known
499  /// to be semantically boolean, which might not be true even for expressions
500  /// that are known to evaluate to 0/1. For instance, reading an unsigned
501  /// bit-field with width '1' will evaluate to 0/1, but doesn't necessarily
502  /// semantically correspond to a bool.
503  bool isKnownToHaveBooleanValue(bool Semantic = true) const;
504 
505  /// isIntegerConstantExpr - Return true if this expression is a valid integer
506  /// constant expression, and, if so, return its value in Result. If not a
507  /// valid i-c-e, return false and fill in Loc (if specified) with the location
508  /// of the invalid expression.
509  ///
510  /// Note: This does not perform the implicit conversions required by C++11
511  /// [expr.const]p5.
512  bool isIntegerConstantExpr(llvm::APSInt &Result, const ASTContext &Ctx,
513  SourceLocation *Loc = nullptr,
514  bool isEvaluated = true) const;
515  bool isIntegerConstantExpr(const ASTContext &Ctx,
516  SourceLocation *Loc = nullptr) const;
517 
518  /// isCXX98IntegralConstantExpr - Return true if this expression is an
519  /// integral constant expression in C++98. Can only be used in C++.
520  bool isCXX98IntegralConstantExpr(const ASTContext &Ctx) const;
521 
522  /// isCXX11ConstantExpr - Return true if this expression is a constant
523  /// expression in C++11. Can only be used in C++.
524  ///
525  /// Note: This does not perform the implicit conversions required by C++11
526  /// [expr.const]p5.
527  bool isCXX11ConstantExpr(const ASTContext &Ctx, APValue *Result = nullptr,
528  SourceLocation *Loc = nullptr) const;
529 
530  /// isPotentialConstantExpr - Return true if this function's definition
531  /// might be usable in a constant expression in C++11, if it were marked
532  /// constexpr. Return false if the function can never produce a constant
533  /// expression, along with diagnostics describing why not.
534  static bool isPotentialConstantExpr(const FunctionDecl *FD,
536  PartialDiagnosticAt> &Diags);
537 
538  /// isPotentialConstantExprUnevaluted - Return true if this expression might
539  /// be usable in a constant expression in C++11 in an unevaluated context, if
540  /// it were in function FD marked constexpr. Return false if the function can
541  /// never produce a constant expression, along with diagnostics describing
542  /// why not.
543  static bool isPotentialConstantExprUnevaluated(Expr *E,
544  const FunctionDecl *FD,
546  PartialDiagnosticAt> &Diags);
547 
548  /// isConstantInitializer - Returns true if this expression can be emitted to
549  /// IR as a constant, and thus can be used as a constant initializer in C.
550  /// If this expression is not constant and Culprit is non-null,
551  /// it is used to store the address of first non constant expr.
552  bool isConstantInitializer(ASTContext &Ctx, bool ForRef,
553  const Expr **Culprit = nullptr) const;
554 
555  /// EvalStatus is a struct with detailed info about an evaluation in progress.
556  struct EvalStatus {
557  /// Whether the evaluated expression has side effects.
558  /// For example, (f() && 0) can be folded, but it still has side effects.
560 
561  /// Whether the evaluation hit undefined behavior.
562  /// For example, 1.0 / 0.0 can be folded to Inf, but has undefined behavior.
563  /// Likewise, INT_MAX + 1 can be folded to INT_MIN, but has UB.
565 
566  /// Diag - If this is non-null, it will be filled in with a stack of notes
567  /// indicating why evaluation failed (or why it failed to produce a constant
568  /// expression).
569  /// If the expression is unfoldable, the notes will indicate why it's not
570  /// foldable. If the expression is foldable, but not a constant expression,
571  /// the notes will describes why it isn't a constant expression. If the
572  /// expression *is* a constant expression, no notes will be produced.
574 
576  : HasSideEffects(false), HasUndefinedBehavior(false), Diag(nullptr) {}
577 
578  // hasSideEffects - Return true if the evaluated expression has
579  // side effects.
580  bool hasSideEffects() const {
581  return HasSideEffects;
582  }
583  };
584 
585  /// EvalResult is a struct with detailed info about an evaluated expression.
587  /// Val - This is the value the expression can be folded to.
589 
590  // isGlobalLValue - Return true if the evaluated lvalue expression
591  // is global.
592  bool isGlobalLValue() const;
593  };
594 
595  /// EvaluateAsRValue - Return true if this is a constant which we can fold to
596  /// an rvalue using any crazy technique (that has nothing to do with language
597  /// standards) that we want to, even if the expression has side-effects. If
598  /// this function returns true, it returns the folded constant in Result. If
599  /// the expression is a glvalue, an lvalue-to-rvalue conversion will be
600  /// applied.
601  bool EvaluateAsRValue(EvalResult &Result, const ASTContext &Ctx,
602  bool InConstantContext = false) const;
603 
604  /// EvaluateAsBooleanCondition - Return true if this is a constant
605  /// which we can fold and convert to a boolean condition using
606  /// any crazy technique that we want to, even if the expression has
607  /// side-effects.
608  bool EvaluateAsBooleanCondition(bool &Result, const ASTContext &Ctx,
609  bool InConstantContext = false) const;
610 
612  SE_NoSideEffects, ///< Strictly evaluate the expression.
613  SE_AllowUndefinedBehavior, ///< Allow UB that we can give a value, but not
614  ///< arbitrary unmodeled side effects.
615  SE_AllowSideEffects ///< Allow any unmodeled side effect.
616  };
617 
618  /// EvaluateAsInt - Return true if this is a constant which we can fold and
619  /// convert to an integer, using any crazy technique that we want to.
620  bool EvaluateAsInt(EvalResult &Result, const ASTContext &Ctx,
621  SideEffectsKind AllowSideEffects = SE_NoSideEffects,
622  bool InConstantContext = false) const;
623 
624  /// EvaluateAsFloat - Return true if this is a constant which we can fold and
625  /// convert to a floating point value, using any crazy technique that we
626  /// want to.
627  bool EvaluateAsFloat(llvm::APFloat &Result, const ASTContext &Ctx,
628  SideEffectsKind AllowSideEffects = SE_NoSideEffects,
629  bool InConstantContext = false) const;
630 
631  /// EvaluateAsFloat - Return true if this is a constant which we can fold and
632  /// convert to a fixed point value.
633  bool EvaluateAsFixedPoint(EvalResult &Result, const ASTContext &Ctx,
634  SideEffectsKind AllowSideEffects = SE_NoSideEffects,
635  bool InConstantContext = false) const;
636 
637  /// isEvaluatable - Call EvaluateAsRValue to see if this expression can be
638  /// constant folded without side-effects, but discard the result.
639  bool isEvaluatable(const ASTContext &Ctx,
640  SideEffectsKind AllowSideEffects = SE_NoSideEffects) const;
641 
642  /// HasSideEffects - This routine returns true for all those expressions
643  /// which have any effect other than producing a value. Example is a function
644  /// call, volatile variable read, or throwing an exception. If
645  /// IncludePossibleEffects is false, this call treats certain expressions with
646  /// potential side effects (such as function call-like expressions,
647  /// instantiation-dependent expressions, or invocations from a macro) as not
648  /// having side effects.
649  bool HasSideEffects(const ASTContext &Ctx,
650  bool IncludePossibleEffects = true) const;
651 
652  /// Determine whether this expression involves a call to any function
653  /// that is not trivial.
654  bool hasNonTrivialCall(const ASTContext &Ctx) const;
655 
656  /// EvaluateKnownConstInt - Call EvaluateAsRValue and return the folded
657  /// integer. This must be called on an expression that constant folds to an
658  /// integer.
659  llvm::APSInt EvaluateKnownConstInt(
660  const ASTContext &Ctx,
661  SmallVectorImpl<PartialDiagnosticAt> *Diag = nullptr) const;
662 
663  llvm::APSInt EvaluateKnownConstIntCheckOverflow(
664  const ASTContext &Ctx,
665  SmallVectorImpl<PartialDiagnosticAt> *Diag = nullptr) const;
666 
667  void EvaluateForOverflow(const ASTContext &Ctx) const;
668 
669  /// EvaluateAsLValue - Evaluate an expression to see if we can fold it to an
670  /// lvalue with link time known address, with no side-effects.
671  bool EvaluateAsLValue(EvalResult &Result, const ASTContext &Ctx,
672  bool InConstantContext = false) const;
673 
674  /// EvaluateAsInitializer - Evaluate an expression as if it were the
675  /// initializer of the given declaration. Returns true if the initializer
676  /// can be folded to a constant, and produces any relevant notes. In C++11,
677  /// notes will be produced if the expression is not a constant expression.
678  bool EvaluateAsInitializer(APValue &Result, const ASTContext &Ctx,
679  const VarDecl *VD,
681 
682  /// EvaluateWithSubstitution - Evaluate an expression as if from the context
683  /// of a call to the given function with the given arguments, inside an
684  /// unevaluated context. Returns true if the expression could be folded to a
685  /// constant.
686  bool EvaluateWithSubstitution(APValue &Value, ASTContext &Ctx,
687  const FunctionDecl *Callee,
689  const Expr *This = nullptr) const;
690 
691  /// Indicates how the constant expression will be used.
692  enum ConstExprUsage { EvaluateForCodeGen, EvaluateForMangling };
693 
694  /// Evaluate an expression that is required to be a constant expression.
695  bool EvaluateAsConstantExpr(EvalResult &Result, ConstExprUsage Usage,
696  const ASTContext &Ctx) const;
697 
698  /// If the current Expr is a pointer, this will try to statically
699  /// determine the number of bytes available where the pointer is pointing.
700  /// Returns true if all of the above holds and we were able to figure out the
701  /// size, false otherwise.
702  ///
703  /// \param Type - How to evaluate the size of the Expr, as defined by the
704  /// "type" parameter of __builtin_object_size
705  bool tryEvaluateObjectSize(uint64_t &Result, ASTContext &Ctx,
706  unsigned Type) const;
707 
708  /// Enumeration used to describe the kind of Null pointer constant
709  /// returned from \c isNullPointerConstant().
711  /// Expression is not a Null pointer constant.
712  NPCK_NotNull = 0,
713 
714  /// Expression is a Null pointer constant built from a zero integer
715  /// expression that is not a simple, possibly parenthesized, zero literal.
716  /// C++ Core Issue 903 will classify these expressions as "not pointers"
717  /// once it is adopted.
718  /// http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#903
720 
721  /// Expression is a Null pointer constant built from a literal zero.
723 
724  /// Expression is a C++11 nullptr.
726 
727  /// Expression is a GNU-style __null constant.
728  NPCK_GNUNull
729  };
730 
731  /// Enumeration used to describe how \c isNullPointerConstant()
732  /// should cope with value-dependent expressions.
734  /// Specifies that the expression should never be value-dependent.
735  NPC_NeverValueDependent = 0,
736 
737  /// Specifies that a value-dependent expression of integral or
738  /// dependent type should be considered a null pointer constant.
740 
741  /// Specifies that a value-dependent expression should be considered
742  /// to never be a null pointer constant.
743  NPC_ValueDependentIsNotNull
744  };
745 
746  /// isNullPointerConstant - C99 6.3.2.3p3 - Test if this reduces down to
747  /// a Null pointer constant. The return value can further distinguish the
748  /// kind of NULL pointer constant that was detected.
749  NullPointerConstantKind isNullPointerConstant(
750  ASTContext &Ctx,
752 
753  /// isOBJCGCCandidate - Return true if this expression may be used in a read/
754  /// write barrier.
755  bool isOBJCGCCandidate(ASTContext &Ctx) const;
756 
757  /// Returns true if this expression is a bound member function.
758  bool isBoundMemberFunction(ASTContext &Ctx) const;
759 
760  /// Given an expression of bound-member type, find the type
761  /// of the member. Returns null if this is an *overloaded* bound
762  /// member expression.
763  static QualType findBoundMemberType(const Expr *expr);
764 
765  /// Skip past any invisble AST nodes which might surround this
766  /// statement, such as ExprWithCleanups or ImplicitCastExpr nodes,
767  /// but also injected CXXMemberExpr and CXXConstructExpr which represent
768  /// implicit conversions.
769  Expr *IgnoreUnlessSpelledInSource();
771  return const_cast<Expr *>(this)->IgnoreUnlessSpelledInSource();
772  }
773 
774  /// Skip past any implicit casts which might surround this expression until
775  /// reaching a fixed point. Skips:
776  /// * ImplicitCastExpr
777  /// * FullExpr
778  Expr *IgnoreImpCasts() LLVM_READONLY;
779  const Expr *IgnoreImpCasts() const {
780  return const_cast<Expr *>(this)->IgnoreImpCasts();
781  }
782 
783  /// Skip past any casts which might surround this expression until reaching
784  /// a fixed point. Skips:
785  /// * CastExpr
786  /// * FullExpr
787  /// * MaterializeTemporaryExpr
788  /// * SubstNonTypeTemplateParmExpr
789  Expr *IgnoreCasts() LLVM_READONLY;
790  const Expr *IgnoreCasts() const {
791  return const_cast<Expr *>(this)->IgnoreCasts();
792  }
793 
794  /// Skip past any implicit AST nodes which might surround this expression
795  /// until reaching a fixed point. Skips:
796  /// * What IgnoreImpCasts() skips
797  /// * MaterializeTemporaryExpr
798  /// * CXXBindTemporaryExpr
799  Expr *IgnoreImplicit() LLVM_READONLY;
800  const Expr *IgnoreImplicit() const {
801  return const_cast<Expr *>(this)->IgnoreImplicit();
802  }
803 
804  /// Skip past any implicit AST nodes which might surround this expression
805  /// until reaching a fixed point. Same as IgnoreImplicit, except that it
806  /// also skips over implicit calls to constructors and conversion functions.
807  ///
808  /// FIXME: Should IgnoreImplicit do this?
809  Expr *IgnoreImplicitAsWritten() LLVM_READONLY;
810  const Expr *IgnoreImplicitAsWritten() const {
811  return const_cast<Expr *>(this)->IgnoreImplicitAsWritten();
812  }
813 
814  /// Skip past any parentheses which might surround this expression until
815  /// reaching a fixed point. Skips:
816  /// * ParenExpr
817  /// * UnaryOperator if `UO_Extension`
818  /// * GenericSelectionExpr if `!isResultDependent()`
819  /// * ChooseExpr if `!isConditionDependent()`
820  /// * ConstantExpr
821  Expr *IgnoreParens() LLVM_READONLY;
822  const Expr *IgnoreParens() const {
823  return const_cast<Expr *>(this)->IgnoreParens();
824  }
825 
826  /// Skip past any parentheses and implicit casts which might surround this
827  /// expression until reaching a fixed point.
828  /// FIXME: IgnoreParenImpCasts really ought to be equivalent to
829  /// IgnoreParens() + IgnoreImpCasts() until reaching a fixed point. However
830  /// this is currently not the case. Instead IgnoreParenImpCasts() skips:
831  /// * What IgnoreParens() skips
832  /// * What IgnoreImpCasts() skips
833  /// * MaterializeTemporaryExpr
834  /// * SubstNonTypeTemplateParmExpr
835  Expr *IgnoreParenImpCasts() LLVM_READONLY;
836  const Expr *IgnoreParenImpCasts() const {
837  return const_cast<Expr *>(this)->IgnoreParenImpCasts();
838  }
839 
840  /// Skip past any parentheses and casts which might surround this expression
841  /// until reaching a fixed point. Skips:
842  /// * What IgnoreParens() skips
843  /// * What IgnoreCasts() skips
844  Expr *IgnoreParenCasts() LLVM_READONLY;
845  const Expr *IgnoreParenCasts() const {
846  return const_cast<Expr *>(this)->IgnoreParenCasts();
847  }
848 
849  /// Skip conversion operators. If this Expr is a call to a conversion
850  /// operator, return the argument.
851  Expr *IgnoreConversionOperator() LLVM_READONLY;
853  return const_cast<Expr *>(this)->IgnoreConversionOperator();
854  }
855 
856  /// Skip past any parentheses and lvalue casts which might surround this
857  /// expression until reaching a fixed point. Skips:
858  /// * What IgnoreParens() skips
859  /// * What IgnoreCasts() skips, except that only lvalue-to-rvalue
860  /// casts are skipped
861  /// FIXME: This is intended purely as a temporary workaround for code
862  /// that hasn't yet been rewritten to do the right thing about those
863  /// casts, and may disappear along with the last internal use.
864  Expr *IgnoreParenLValueCasts() LLVM_READONLY;
865  const Expr *IgnoreParenLValueCasts() const {
866  return const_cast<Expr *>(this)->IgnoreParenLValueCasts();
867  }
868 
869  /// Skip past any parenthese and casts which do not change the value
870  /// (including ptr->int casts of the same size) until reaching a fixed point.
871  /// Skips:
872  /// * What IgnoreParens() skips
873  /// * CastExpr which do not change the value
874  /// * SubstNonTypeTemplateParmExpr
875  Expr *IgnoreParenNoopCasts(const ASTContext &Ctx) LLVM_READONLY;
876  const Expr *IgnoreParenNoopCasts(const ASTContext &Ctx) const {
877  return const_cast<Expr *>(this)->IgnoreParenNoopCasts(Ctx);
878  }
879 
880  /// Skip past any parentheses and derived-to-base casts until reaching a
881  /// fixed point. Skips:
882  /// * What IgnoreParens() skips
883  /// * CastExpr which represent a derived-to-base cast (CK_DerivedToBase,
884  /// CK_UncheckedDerivedToBase and CK_NoOp)
885  Expr *ignoreParenBaseCasts() LLVM_READONLY;
886  const Expr *ignoreParenBaseCasts() const {
887  return const_cast<Expr *>(this)->ignoreParenBaseCasts();
888  }
889 
890  /// Determine whether this expression is a default function argument.
891  ///
892  /// Default arguments are implicitly generated in the abstract syntax tree
893  /// by semantic analysis for function calls, object constructions, etc. in
894  /// C++. Default arguments are represented by \c CXXDefaultArgExpr nodes;
895  /// this routine also looks through any implicit casts to determine whether
896  /// the expression is a default argument.
897  bool isDefaultArgument() const;
898 
899  /// Determine whether the result of this expression is a
900  /// temporary object of the given class type.
901  bool isTemporaryObject(ASTContext &Ctx, const CXXRecordDecl *TempTy) const;
902 
903  /// Whether this expression is an implicit reference to 'this' in C++.
904  bool isImplicitCXXThis() const;
905 
906  static bool hasAnyTypeDependentArguments(ArrayRef<Expr *> Exprs);
907 
908  /// For an expression of class type or pointer to class type,
909  /// return the most derived class decl the expression is known to refer to.
910  ///
911  /// If this expression is a cast, this method looks through it to find the
912  /// most derived decl that can be inferred from the expression.
913  /// This is valid because derived-to-base conversions have undefined
914  /// behavior if the object isn't dynamically of the derived type.
915  const CXXRecordDecl *getBestDynamicClassType() const;
916 
917  /// Get the inner expression that determines the best dynamic class.
918  /// If this is a prvalue, we guarantee that it is of the most-derived type
919  /// for the object itself.
920  const Expr *getBestDynamicClassTypeExpr() const;
921 
922  /// Walk outwards from an expression we want to bind a reference to and
923  /// find the expression whose lifetime needs to be extended. Record
924  /// the LHSs of comma expressions and adjustments needed along the path.
925  const Expr *skipRValueSubobjectAdjustments(
927  SmallVectorImpl<SubobjectAdjustment> &Adjustments) const;
931  return skipRValueSubobjectAdjustments(CommaLHSs, Adjustments);
932  }
933 
934  /// Checks that the two Expr's will refer to the same value as a comparison
935  /// operand. The caller must ensure that the values referenced by the Expr's
936  /// are not modified between E1 and E2 or the result my be invalid.
937  static bool isSameComparisonOperand(const Expr* E1, const Expr* E2);
938 
939  static bool classof(const Stmt *T) {
940  return T->getStmtClass() >= firstExprConstant &&
941  T->getStmtClass() <= lastExprConstant;
942  }
943 };
944 
945 //===----------------------------------------------------------------------===//
946 // Wrapper Expressions.
947 //===----------------------------------------------------------------------===//
948 
949 /// FullExpr - Represents a "full-expression" node.
950 class FullExpr : public Expr {
951 protected:
953 
954  FullExpr(StmtClass SC, Expr *subexpr)
955  : Expr(SC, subexpr->getType(),
956  subexpr->getValueKind(), subexpr->getObjectKind(),
957  subexpr->isTypeDependent(), subexpr->isValueDependent(),
958  subexpr->isInstantiationDependent(),
959  subexpr->containsUnexpandedParameterPack()), SubExpr(subexpr) {}
961  : Expr(SC, Empty) {}
962 public:
963  const Expr *getSubExpr() const { return cast<Expr>(SubExpr); }
964  Expr *getSubExpr() { return cast<Expr>(SubExpr); }
965 
966  /// As with any mutator of the AST, be very careful when modifying an
967  /// existing AST to preserve its invariants.
968  void setSubExpr(Expr *E) { SubExpr = E; }
969 
970  static bool classof(const Stmt *T) {
971  return T->getStmtClass() >= firstFullExprConstant &&
972  T->getStmtClass() <= lastFullExprConstant;
973  }
974 };
975 
976 /// ConstantExpr - An expression that occurs in a constant context and
977 /// optionally the result of evaluating the expression.
978 class ConstantExpr final
979  : public FullExpr,
980  private llvm::TrailingObjects<ConstantExpr, APValue, uint64_t> {
981  static_assert(std::is_same<uint64_t, llvm::APInt::WordType>::value,
982  "this class assumes llvm::APInt::WordType is uint64_t for "
983  "trail-allocated storage");
984 
985 public:
986  /// Describes the kind of result that can be trail-allocated.
987  enum ResultStorageKind { RSK_None, RSK_Int64, RSK_APValue };
988 
989 private:
990  size_t numTrailingObjects(OverloadToken<APValue>) const {
991  return ConstantExprBits.ResultKind == ConstantExpr::RSK_APValue;
992  }
993  size_t numTrailingObjects(OverloadToken<uint64_t>) const {
994  return ConstantExprBits.ResultKind == ConstantExpr::RSK_Int64;
995  }
996 
997  void DefaultInit(ResultStorageKind StorageKind);
998  uint64_t &Int64Result() {
999  assert(ConstantExprBits.ResultKind == ConstantExpr::RSK_Int64 &&
1000  "invalid accessor");
1001  return *getTrailingObjects<uint64_t>();
1002  }
1003  const uint64_t &Int64Result() const {
1004  return const_cast<ConstantExpr *>(this)->Int64Result();
1005  }
1006  APValue &APValueResult() {
1007  assert(ConstantExprBits.ResultKind == ConstantExpr::RSK_APValue &&
1008  "invalid accessor");
1009  return *getTrailingObjects<APValue>();
1010  }
1011  const APValue &APValueResult() const {
1012  return const_cast<ConstantExpr *>(this)->APValueResult();
1013  }
1014 
1015  ConstantExpr(Expr *subexpr, ResultStorageKind StorageKind);
1016  ConstantExpr(ResultStorageKind StorageKind, EmptyShell Empty);
1017 
1018 public:
1020  friend class ASTStmtReader;
1021  friend class ASTStmtWriter;
1022  static ConstantExpr *Create(const ASTContext &Context, Expr *E,
1023  const APValue &Result);
1024  static ConstantExpr *Create(const ASTContext &Context, Expr *E,
1025  ResultStorageKind Storage = RSK_None);
1026  static ConstantExpr *CreateEmpty(const ASTContext &Context,
1027  ResultStorageKind StorageKind,
1028  EmptyShell Empty);
1029 
1030  static ResultStorageKind getStorageKind(const APValue &Value);
1031  static ResultStorageKind getStorageKind(const Type *T,
1032  const ASTContext &Context);
1033 
1034  SourceLocation getBeginLoc() const LLVM_READONLY {
1035  return SubExpr->getBeginLoc();
1036  }
1037  SourceLocation getEndLoc() const LLVM_READONLY {
1038  return SubExpr->getEndLoc();
1039  }
1040 
1041  static bool classof(const Stmt *T) {
1042  return T->getStmtClass() == ConstantExprClass;
1043  }
1044 
1045  void SetResult(APValue Value, const ASTContext &Context) {
1046  MoveIntoResult(Value, Context);
1047  }
1048  void MoveIntoResult(APValue &Value, const ASTContext &Context);
1049 
1051  return static_cast<APValue::ValueKind>(ConstantExprBits.APValueKind);
1052  }
1054  return static_cast<ResultStorageKind>(ConstantExprBits.ResultKind);
1055  }
1056  APValue getAPValueResult() const;
1057  const APValue &getResultAsAPValue() const { return APValueResult(); }
1058  llvm::APSInt getResultAsAPSInt() const;
1059  // Iterators
1060  child_range children() { return child_range(&SubExpr, &SubExpr+1); }
1062  return const_child_range(&SubExpr, &SubExpr + 1);
1063  }
1064 };
1065 
1066 //===----------------------------------------------------------------------===//
1067 // Primary Expressions.
1068 //===----------------------------------------------------------------------===//
1069 
1070 /// OpaqueValueExpr - An expression referring to an opaque object of a
1071 /// fixed type and value class. These don't correspond to concrete
1072 /// syntax; instead they're used to express operations (usually copy
1073 /// operations) on values whose source is generally obvious from
1074 /// context.
1075 class OpaqueValueExpr : public Expr {
1076  friend class ASTStmtReader;
1077  Expr *SourceExpr;
1078 
1079 public:
1082  Expr *SourceExpr = nullptr)
1083  : Expr(OpaqueValueExprClass, T, VK, OK,
1084  T->isDependentType() ||
1085  (SourceExpr && SourceExpr->isTypeDependent()),
1086  T->isDependentType() ||
1087  (SourceExpr && SourceExpr->isValueDependent()),
1088  T->isInstantiationDependentType() ||
1089  (SourceExpr && SourceExpr->isInstantiationDependent()),
1090  false),
1091  SourceExpr(SourceExpr) {
1092  setIsUnique(false);
1093  OpaqueValueExprBits.Loc = Loc;
1094  }
1095 
1096  /// Given an expression which invokes a copy constructor --- i.e. a
1097  /// CXXConstructExpr, possibly wrapped in an ExprWithCleanups ---
1098  /// find the OpaqueValueExpr that's the source of the construction.
1099  static const OpaqueValueExpr *findInCopyConstruct(const Expr *expr);
1100 
1101  explicit OpaqueValueExpr(EmptyShell Empty)
1102  : Expr(OpaqueValueExprClass, Empty) {}
1103 
1104  /// Retrieve the location of this expression.
1105  SourceLocation getLocation() const { return OpaqueValueExprBits.Loc; }
1106 
1107  SourceLocation getBeginLoc() const LLVM_READONLY {
1108  return SourceExpr ? SourceExpr->getBeginLoc() : getLocation();
1109  }
1110  SourceLocation getEndLoc() const LLVM_READONLY {
1111  return SourceExpr ? SourceExpr->getEndLoc() : getLocation();
1112  }
1113  SourceLocation getExprLoc() const LLVM_READONLY {
1114  return SourceExpr ? SourceExpr->getExprLoc() : getLocation();
1115  }
1116 
1119  }
1120 
1123  }
1124 
1125  /// The source expression of an opaque value expression is the
1126  /// expression which originally generated the value. This is
1127  /// provided as a convenience for analyses that don't wish to
1128  /// precisely model the execution behavior of the program.
1129  ///
1130  /// The source expression is typically set when building the
1131  /// expression which binds the opaque value expression in the first
1132  /// place.
1133  Expr *getSourceExpr() const { return SourceExpr; }
1134 
1135  void setIsUnique(bool V) {
1136  assert((!V || SourceExpr) &&
1137  "unique OVEs are expected to have source expressions");
1138  OpaqueValueExprBits.IsUnique = V;
1139  }
1140 
1141  bool isUnique() const { return OpaqueValueExprBits.IsUnique; }
1142 
1143  static bool classof(const Stmt *T) {
1144  return T->getStmtClass() == OpaqueValueExprClass;
1145  }
1146 };
1147 
1148 /// A reference to a declared variable, function, enum, etc.
1149 /// [C99 6.5.1p2]
1150 ///
1151 /// This encodes all the information about how a declaration is referenced
1152 /// within an expression.
1153 ///
1154 /// There are several optional constructs attached to DeclRefExprs only when
1155 /// they apply in order to conserve memory. These are laid out past the end of
1156 /// the object, and flags in the DeclRefExprBitfield track whether they exist:
1157 ///
1158 /// DeclRefExprBits.HasQualifier:
1159 /// Specifies when this declaration reference expression has a C++
1160 /// nested-name-specifier.
1161 /// DeclRefExprBits.HasFoundDecl:
1162 /// Specifies when this declaration reference expression has a record of
1163 /// a NamedDecl (different from the referenced ValueDecl) which was found
1164 /// during name lookup and/or overload resolution.
1165 /// DeclRefExprBits.HasTemplateKWAndArgsInfo:
1166 /// Specifies when this declaration reference expression has an explicit
1167 /// C++ template keyword and/or template argument list.
1168 /// DeclRefExprBits.RefersToEnclosingVariableOrCapture
1169 /// Specifies when this declaration reference expression (validly)
1170 /// refers to an enclosed local or a captured variable.
1171 class DeclRefExpr final
1172  : public Expr,
1173  private llvm::TrailingObjects<DeclRefExpr, NestedNameSpecifierLoc,
1174  NamedDecl *, ASTTemplateKWAndArgsInfo,
1175  TemplateArgumentLoc> {
1176  friend class ASTStmtReader;
1177  friend class ASTStmtWriter;
1178  friend TrailingObjects;
1179 
1180  /// The declaration that we are referencing.
1181  ValueDecl *D;
1182 
1183  /// Provides source/type location info for the declaration name
1184  /// embedded in D.
1185  DeclarationNameLoc DNLoc;
1186 
1187  size_t numTrailingObjects(OverloadToken<NestedNameSpecifierLoc>) const {
1188  return hasQualifier();
1189  }
1190 
1191  size_t numTrailingObjects(OverloadToken<NamedDecl *>) const {
1192  return hasFoundDecl();
1193  }
1194 
1195  size_t numTrailingObjects(OverloadToken<ASTTemplateKWAndArgsInfo>) const {
1196  return hasTemplateKWAndArgsInfo();
1197  }
1198 
1199  /// Test whether there is a distinct FoundDecl attached to the end of
1200  /// this DRE.
1201  bool hasFoundDecl() const { return DeclRefExprBits.HasFoundDecl; }
1202 
1203  DeclRefExpr(const ASTContext &Ctx, NestedNameSpecifierLoc QualifierLoc,
1204  SourceLocation TemplateKWLoc, ValueDecl *D,
1205  bool RefersToEnlosingVariableOrCapture,
1206  const DeclarationNameInfo &NameInfo, NamedDecl *FoundD,
1207  const TemplateArgumentListInfo *TemplateArgs, QualType T,
1208  ExprValueKind VK, NonOdrUseReason NOUR);
1209 
1210  /// Construct an empty declaration reference expression.
1211  explicit DeclRefExpr(EmptyShell Empty) : Expr(DeclRefExprClass, Empty) {}
1212 
1213  /// Computes the type- and value-dependence flags for this
1214  /// declaration reference expression.
1215  void computeDependence(const ASTContext &Ctx);
1216 
1217 public:
1218  DeclRefExpr(const ASTContext &Ctx, ValueDecl *D,
1219  bool RefersToEnclosingVariableOrCapture, QualType T,
1221  const DeclarationNameLoc &LocInfo = DeclarationNameLoc(),
1222  NonOdrUseReason NOUR = NOUR_None);
1223 
1224  static DeclRefExpr *
1225  Create(const ASTContext &Context, NestedNameSpecifierLoc QualifierLoc,
1226  SourceLocation TemplateKWLoc, ValueDecl *D,
1227  bool RefersToEnclosingVariableOrCapture, SourceLocation NameLoc,
1228  QualType T, ExprValueKind VK, NamedDecl *FoundD = nullptr,
1229  const TemplateArgumentListInfo *TemplateArgs = nullptr,
1230  NonOdrUseReason NOUR = NOUR_None);
1231 
1232  static DeclRefExpr *
1233  Create(const ASTContext &Context, NestedNameSpecifierLoc QualifierLoc,
1234  SourceLocation TemplateKWLoc, ValueDecl *D,
1235  bool RefersToEnclosingVariableOrCapture,
1236  const DeclarationNameInfo &NameInfo, QualType T, ExprValueKind VK,
1237  NamedDecl *FoundD = nullptr,
1238  const TemplateArgumentListInfo *TemplateArgs = nullptr,
1239  NonOdrUseReason NOUR = NOUR_None);
1240 
1241  /// Construct an empty declaration reference expression.
1242  static DeclRefExpr *CreateEmpty(const ASTContext &Context, bool HasQualifier,
1243  bool HasFoundDecl,
1244  bool HasTemplateKWAndArgsInfo,
1245  unsigned NumTemplateArgs);
1246 
1247  ValueDecl *getDecl() { return D; }
1248  const ValueDecl *getDecl() const { return D; }
1249  void setDecl(ValueDecl *NewD) { D = NewD; }
1250 
1252  return DeclarationNameInfo(getDecl()->getDeclName(), getLocation(), DNLoc);
1253  }
1254 
1255  SourceLocation getLocation() const { return DeclRefExprBits.Loc; }
1256  void setLocation(SourceLocation L) { DeclRefExprBits.Loc = L; }
1257  SourceLocation getBeginLoc() const LLVM_READONLY;
1258  SourceLocation getEndLoc() const LLVM_READONLY;
1259 
1260  /// Determine whether this declaration reference was preceded by a
1261  /// C++ nested-name-specifier, e.g., \c N::foo.
1262  bool hasQualifier() const { return DeclRefExprBits.HasQualifier; }
1263 
1264  /// If the name was qualified, retrieves the nested-name-specifier
1265  /// that precedes the name, with source-location information.
1267  if (!hasQualifier())
1268  return NestedNameSpecifierLoc();
1269  return *getTrailingObjects<NestedNameSpecifierLoc>();
1270  }
1271 
1272  /// If the name was qualified, retrieves the nested-name-specifier
1273  /// that precedes the name. Otherwise, returns NULL.
1275  return getQualifierLoc().getNestedNameSpecifier();
1276  }
1277 
1278  /// Get the NamedDecl through which this reference occurred.
1279  ///
1280  /// This Decl may be different from the ValueDecl actually referred to in the
1281  /// presence of using declarations, etc. It always returns non-NULL, and may
1282  /// simple return the ValueDecl when appropriate.
1283 
1285  return hasFoundDecl() ? *getTrailingObjects<NamedDecl *>() : D;
1286  }
1287 
1288  /// Get the NamedDecl through which this reference occurred.
1289  /// See non-const variant.
1290  const NamedDecl *getFoundDecl() const {
1291  return hasFoundDecl() ? *getTrailingObjects<NamedDecl *>() : D;
1292  }
1293 
1295  return DeclRefExprBits.HasTemplateKWAndArgsInfo;
1296  }
1297 
1298  /// Retrieve the location of the template keyword preceding
1299  /// this name, if any.
1301  if (!hasTemplateKWAndArgsInfo())
1302  return SourceLocation();
1303  return getTrailingObjects<ASTTemplateKWAndArgsInfo>()->TemplateKWLoc;
1304  }
1305 
1306  /// Retrieve the location of the left angle bracket starting the
1307  /// explicit template argument list following the name, if any.
1309  if (!hasTemplateKWAndArgsInfo())
1310  return SourceLocation();
1311  return getTrailingObjects<ASTTemplateKWAndArgsInfo>()->LAngleLoc;
1312  }
1313 
1314  /// Retrieve the location of the right angle bracket ending the
1315  /// explicit template argument list following the name, if any.
1317  if (!hasTemplateKWAndArgsInfo())
1318  return SourceLocation();
1319  return getTrailingObjects<ASTTemplateKWAndArgsInfo>()->RAngleLoc;
1320  }
1321 
1322  /// Determines whether the name in this declaration reference
1323  /// was preceded by the template keyword.
1324  bool hasTemplateKeyword() const { return getTemplateKeywordLoc().isValid(); }
1325 
1326  /// Determines whether this declaration reference was followed by an
1327  /// explicit template argument list.
1328  bool hasExplicitTemplateArgs() const { return getLAngleLoc().isValid(); }
1329 
1330  /// Copies the template arguments (if present) into the given
1331  /// structure.
1333  if (hasExplicitTemplateArgs())
1334  getTrailingObjects<ASTTemplateKWAndArgsInfo>()->copyInto(
1335  getTrailingObjects<TemplateArgumentLoc>(), List);
1336  }
1337 
1338  /// Retrieve the template arguments provided as part of this
1339  /// template-id.
1341  if (!hasExplicitTemplateArgs())
1342  return nullptr;
1343  return getTrailingObjects<TemplateArgumentLoc>();
1344  }
1345 
1346  /// Retrieve the number of template arguments provided as part of this
1347  /// template-id.
1348  unsigned getNumTemplateArgs() const {
1349  if (!hasExplicitTemplateArgs())
1350  return 0;
1351  return getTrailingObjects<ASTTemplateKWAndArgsInfo>()->NumTemplateArgs;
1352  }
1353 
1355  return {getTemplateArgs(), getNumTemplateArgs()};
1356  }
1357 
1358  /// Returns true if this expression refers to a function that
1359  /// was resolved from an overloaded set having size greater than 1.
1360  bool hadMultipleCandidates() const {
1361  return DeclRefExprBits.HadMultipleCandidates;
1362  }
1363  /// Sets the flag telling whether this expression refers to
1364  /// a function that was resolved from an overloaded set having size
1365  /// greater than 1.
1366  void setHadMultipleCandidates(bool V = true) {
1367  DeclRefExprBits.HadMultipleCandidates = V;
1368  }
1369 
1370  /// Is this expression a non-odr-use reference, and if so, why?
1372  return static_cast<NonOdrUseReason>(DeclRefExprBits.NonOdrUseReason);
1373  }
1374 
1375  /// Does this DeclRefExpr refer to an enclosing local or a captured
1376  /// variable?
1378  return DeclRefExprBits.RefersToEnclosingVariableOrCapture;
1379  }
1380 
1381  static bool classof(const Stmt *T) {
1382  return T->getStmtClass() == DeclRefExprClass;
1383  }
1384 
1385  // Iterators
1388  }
1389 
1392  }
1393 };
1394 
1395 /// Used by IntegerLiteral/FloatingLiteral to store the numeric without
1396 /// leaking memory.
1397 ///
1398 /// For large floats/integers, APFloat/APInt will allocate memory from the heap
1399 /// to represent these numbers. Unfortunately, when we use a BumpPtrAllocator
1400 /// to allocate IntegerLiteral/FloatingLiteral nodes the memory associated with
1401 /// the APFloat/APInt values will never get freed. APNumericStorage uses
1402 /// ASTContext's allocator for memory allocation.
1404  union {
1405  uint64_t VAL; ///< Used to store the <= 64 bits integer value.
1406  uint64_t *pVal; ///< Used to store the >64 bits integer value.
1407  };
1408  unsigned BitWidth;
1409 
1410  bool hasAllocation() const { return llvm::APInt::getNumWords(BitWidth) > 1; }
1411 
1412  APNumericStorage(const APNumericStorage &) = delete;
1413  void operator=(const APNumericStorage &) = delete;
1414 
1415 protected:
1416  APNumericStorage() : VAL(0), BitWidth(0) { }
1417 
1419  unsigned NumWords = llvm::APInt::getNumWords(BitWidth);
1420  if (NumWords > 1)
1421  return llvm::APInt(BitWidth, NumWords, pVal);
1422  else
1423  return llvm::APInt(BitWidth, VAL);
1424  }
1425  void setIntValue(const ASTContext &C, const llvm::APInt &Val);
1426 };
1427 
1429 public:
1430  llvm::APInt getValue() const { return getIntValue(); }
1431  void setValue(const ASTContext &C, const llvm::APInt &Val) {
1432  setIntValue(C, Val);
1433  }
1434 };
1435 
1437 public:
1438  llvm::APFloat getValue(const llvm::fltSemantics &Semantics) const {
1439  return llvm::APFloat(Semantics, getIntValue());
1440  }
1441  void setValue(const ASTContext &C, const llvm::APFloat &Val) {
1442  setIntValue(C, Val.bitcastToAPInt());
1443  }
1444 };
1445 
1446 class IntegerLiteral : public Expr, public APIntStorage {
1447  SourceLocation Loc;
1448 
1449  /// Construct an empty integer literal.
1450  explicit IntegerLiteral(EmptyShell Empty)
1451  : Expr(IntegerLiteralClass, Empty) { }
1452 
1453 public:
1454  // type should be IntTy, LongTy, LongLongTy, UnsignedIntTy, UnsignedLongTy,
1455  // or UnsignedLongLongTy
1457  SourceLocation l);
1458 
1459  /// Returns a new integer literal with value 'V' and type 'type'.
1460  /// \param type - either IntTy, LongTy, LongLongTy, UnsignedIntTy,
1461  /// UnsignedLongTy, or UnsignedLongLongTy which should match the size of V
1462  /// \param V - the value that the returned integer literal contains.
1463  static IntegerLiteral *Create(const ASTContext &C, const llvm::APInt &V,
1464  QualType type, SourceLocation l);
1465  /// Returns a new empty integer literal.
1466  static IntegerLiteral *Create(const ASTContext &C, EmptyShell Empty);
1467 
1468  SourceLocation getBeginLoc() const LLVM_READONLY { return Loc; }
1469  SourceLocation getEndLoc() const LLVM_READONLY { return Loc; }
1470 
1471  /// Retrieve the location of the literal.
1472  SourceLocation getLocation() const { return Loc; }
1473 
1474  void setLocation(SourceLocation Location) { Loc = Location; }
1475 
1476  static bool classof(const Stmt *T) {
1477  return T->getStmtClass() == IntegerLiteralClass;
1478  }
1479 
1480  // Iterators
1483  }
1486  }
1487 };
1488 
1489 class FixedPointLiteral : public Expr, public APIntStorage {
1490  SourceLocation Loc;
1491  unsigned Scale;
1492 
1493  /// \brief Construct an empty integer literal.
1494  explicit FixedPointLiteral(EmptyShell Empty)
1495  : Expr(FixedPointLiteralClass, Empty) {}
1496 
1497  public:
1499  SourceLocation l, unsigned Scale);
1500 
1501  // Store the int as is without any bit shifting.
1502  static FixedPointLiteral *CreateFromRawInt(const ASTContext &C,
1503  const llvm::APInt &V,
1504  QualType type, SourceLocation l,
1505  unsigned Scale);
1506 
1507  SourceLocation getBeginLoc() const LLVM_READONLY { return Loc; }
1508  SourceLocation getEndLoc() const LLVM_READONLY { return Loc; }
1509 
1510  /// \brief Retrieve the location of the literal.
1511  SourceLocation getLocation() const { return Loc; }
1512 
1513  void setLocation(SourceLocation Location) { Loc = Location; }
1514 
1515  static bool classof(const Stmt *T) {
1516  return T->getStmtClass() == FixedPointLiteralClass;
1517  }
1518 
1519  std::string getValueAsString(unsigned Radix) const;
1520 
1521  // Iterators
1524  }
1527  }
1528 };
1529 
1530 class CharacterLiteral : public Expr {
1531 public:
1537  UTF32
1538  };
1539 
1540 private:
1541  unsigned Value;
1542  SourceLocation Loc;
1543 public:
1544  // type should be IntTy
1546  SourceLocation l)
1547  : Expr(CharacterLiteralClass, type, VK_RValue, OK_Ordinary, false, false,
1548  false, false),
1549  Value(value), Loc(l) {
1550  CharacterLiteralBits.Kind = kind;
1551  }
1552 
1553  /// Construct an empty character literal.
1554  CharacterLiteral(EmptyShell Empty) : Expr(CharacterLiteralClass, Empty) { }
1555 
1556  SourceLocation getLocation() const { return Loc; }
1558  return static_cast<CharacterKind>(CharacterLiteralBits.Kind);
1559  }
1560 
1561  SourceLocation getBeginLoc() const LLVM_READONLY { return Loc; }
1562  SourceLocation getEndLoc() const LLVM_READONLY { return Loc; }
1563 
1564  unsigned getValue() const { return Value; }
1565 
1566  void setLocation(SourceLocation Location) { Loc = Location; }
1567  void setKind(CharacterKind kind) { CharacterLiteralBits.Kind = kind; }
1568  void setValue(unsigned Val) { Value = Val; }
1569 
1570  static bool classof(const Stmt *T) {
1571  return T->getStmtClass() == CharacterLiteralClass;
1572  }
1573 
1574  // Iterators
1577  }
1580  }
1581 };
1582 
1583 class FloatingLiteral : public Expr, private APFloatStorage {
1584  SourceLocation Loc;
1585 
1586  FloatingLiteral(const ASTContext &C, const llvm::APFloat &V, bool isexact,
1588 
1589  /// Construct an empty floating-point literal.
1590  explicit FloatingLiteral(const ASTContext &C, EmptyShell Empty);
1591 
1592 public:
1593  static FloatingLiteral *Create(const ASTContext &C, const llvm::APFloat &V,
1594  bool isexact, QualType Type, SourceLocation L);
1595  static FloatingLiteral *Create(const ASTContext &C, EmptyShell Empty);
1596 
1597  llvm::APFloat getValue() const {
1598  return APFloatStorage::getValue(getSemantics());
1599  }
1600  void setValue(const ASTContext &C, const llvm::APFloat &Val) {
1601  assert(&getSemantics() == &Val.getSemantics() && "Inconsistent semantics");
1602  APFloatStorage::setValue(C, Val);
1603  }
1604 
1605  /// Get a raw enumeration value representing the floating-point semantics of
1606  /// this literal (32-bit IEEE, x87, ...), suitable for serialisation.
1607  llvm::APFloatBase::Semantics getRawSemantics() const {
1608  return static_cast<llvm::APFloatBase::Semantics>(
1609  FloatingLiteralBits.Semantics);
1610  }
1611 
1612  /// Set the raw enumeration value representing the floating-point semantics of
1613  /// this literal (32-bit IEEE, x87, ...), suitable for serialisation.
1614  void setRawSemantics(llvm::APFloatBase::Semantics Sem) {
1615  FloatingLiteralBits.Semantics = Sem;
1616  }
1617 
1618  /// Return the APFloat semantics this literal uses.
1619  const llvm::fltSemantics &getSemantics() const {
1620  return llvm::APFloatBase::EnumToSemantics(
1621  static_cast<llvm::APFloatBase::Semantics>(
1622  FloatingLiteralBits.Semantics));
1623  }
1624 
1625  /// Set the APFloat semantics this literal uses.
1626  void setSemantics(const llvm::fltSemantics &Sem) {
1627  FloatingLiteralBits.Semantics = llvm::APFloatBase::SemanticsToEnum(Sem);
1628  }
1629 
1630  bool isExact() const { return FloatingLiteralBits.IsExact; }
1631  void setExact(bool E) { FloatingLiteralBits.IsExact = E; }
1632 
1633  /// getValueAsApproximateDouble - This returns the value as an inaccurate
1634  /// double. Note that this may cause loss of precision, but is useful for
1635  /// debugging dumps, etc.
1636  double getValueAsApproximateDouble() const;
1637 
1638  SourceLocation getLocation() const { return Loc; }
1639  void setLocation(SourceLocation L) { Loc = L; }
1640 
1641  SourceLocation getBeginLoc() const LLVM_READONLY { return Loc; }
1642  SourceLocation getEndLoc() const LLVM_READONLY { return Loc; }
1643 
1644  static bool classof(const Stmt *T) {
1645  return T->getStmtClass() == FloatingLiteralClass;
1646  }
1647 
1648  // Iterators
1651  }
1654  }
1655 };
1656 
1657 /// ImaginaryLiteral - We support imaginary integer and floating point literals,
1658 /// like "1.0i". We represent these as a wrapper around FloatingLiteral and
1659 /// IntegerLiteral classes. Instances of this class always have a Complex type
1660 /// whose element type matches the subexpression.
1661 ///
1662 class ImaginaryLiteral : public Expr {
1663  Stmt *Val;
1664 public:
1666  : Expr(ImaginaryLiteralClass, Ty, VK_RValue, OK_Ordinary, false, false,
1667  false, false),
1668  Val(val) {}
1669 
1670  /// Build an empty imaginary literal.
1672  : Expr(ImaginaryLiteralClass, Empty) { }
1673 
1674  const Expr *getSubExpr() const { return cast<Expr>(Val); }
1675  Expr *getSubExpr() { return cast<Expr>(Val); }
1676  void setSubExpr(Expr *E) { Val = E; }
1677 
1678  SourceLocation getBeginLoc() const LLVM_READONLY {
1679  return Val->getBeginLoc();
1680  }
1681  SourceLocation getEndLoc() const LLVM_READONLY { return Val->getEndLoc(); }
1682 
1683  static bool classof(const Stmt *T) {
1684  return T->getStmtClass() == ImaginaryLiteralClass;
1685  }
1686 
1687  // Iterators
1688  child_range children() { return child_range(&Val, &Val+1); }
1690  return const_child_range(&Val, &Val + 1);
1691  }
1692 };
1693 
1694 /// StringLiteral - This represents a string literal expression, e.g. "foo"
1695 /// or L"bar" (wide strings). The actual string data can be obtained with
1696 /// getBytes() and is NOT null-terminated. The length of the string data is
1697 /// determined by calling getByteLength().
1698 ///
1699 /// The C type for a string is always a ConstantArrayType. In C++, the char
1700 /// type is const qualified, in C it is not.
1701 ///
1702 /// Note that strings in C can be formed by concatenation of multiple string
1703 /// literal pptokens in translation phase #6. This keeps track of the locations
1704 /// of each of these pieces.
1705 ///
1706 /// Strings in C can also be truncated and extended by assigning into arrays,
1707 /// e.g. with constructs like:
1708 /// char X[2] = "foobar";
1709 /// In this case, getByteLength() will return 6, but the string literal will
1710 /// have type "char[2]".
1711 class StringLiteral final
1712  : public Expr,
1713  private llvm::TrailingObjects<StringLiteral, unsigned, SourceLocation,
1714  char> {
1715  friend class ASTStmtReader;
1716  friend TrailingObjects;
1717 
1718  /// StringLiteral is followed by several trailing objects. They are in order:
1719  ///
1720  /// * A single unsigned storing the length in characters of this string. The
1721  /// length in bytes is this length times the width of a single character.
1722  /// Always present and stored as a trailing objects because storing it in
1723  /// StringLiteral would increase the size of StringLiteral by sizeof(void *)
1724  /// due to alignment requirements. If you add some data to StringLiteral,
1725  /// consider moving it inside StringLiteral.
1726  ///
1727  /// * An array of getNumConcatenated() SourceLocation, one for each of the
1728  /// token this string is made of.
1729  ///
1730  /// * An array of getByteLength() char used to store the string data.
1731 
1732 public:
1733  enum StringKind { Ascii, Wide, UTF8, UTF16, UTF32 };
1734 
1735 private:
1736  unsigned numTrailingObjects(OverloadToken<unsigned>) const { return 1; }
1737  unsigned numTrailingObjects(OverloadToken<SourceLocation>) const {
1738  return getNumConcatenated();
1739  }
1740 
1741  unsigned numTrailingObjects(OverloadToken<char>) const {
1742  return getByteLength();
1743  }
1744 
1745  char *getStrDataAsChar() { return getTrailingObjects<char>(); }
1746  const char *getStrDataAsChar() const { return getTrailingObjects<char>(); }
1747 
1748  const uint16_t *getStrDataAsUInt16() const {
1749  return reinterpret_cast<const uint16_t *>(getTrailingObjects<char>());
1750  }
1751 
1752  const uint32_t *getStrDataAsUInt32() const {
1753  return reinterpret_cast<const uint32_t *>(getTrailingObjects<char>());
1754  }
1755 
1756  /// Build a string literal.
1757  StringLiteral(const ASTContext &Ctx, StringRef Str, StringKind Kind,
1758  bool Pascal, QualType Ty, const SourceLocation *Loc,
1759  unsigned NumConcatenated);
1760 
1761  /// Build an empty string literal.
1762  StringLiteral(EmptyShell Empty, unsigned NumConcatenated, unsigned Length,
1763  unsigned CharByteWidth);
1764 
1765  /// Map a target and string kind to the appropriate character width.
1766  static unsigned mapCharByteWidth(TargetInfo const &Target, StringKind SK);
1767 
1768  /// Set one of the string literal token.
1769  void setStrTokenLoc(unsigned TokNum, SourceLocation L) {
1770  assert(TokNum < getNumConcatenated() && "Invalid tok number");
1771  getTrailingObjects<SourceLocation>()[TokNum] = L;
1772  }
1773 
1774 public:
1775  /// This is the "fully general" constructor that allows representation of
1776  /// strings formed from multiple concatenated tokens.
1777  static StringLiteral *Create(const ASTContext &Ctx, StringRef Str,
1778  StringKind Kind, bool Pascal, QualType Ty,
1779  const SourceLocation *Loc,
1780  unsigned NumConcatenated);
1781 
1782  /// Simple constructor for string literals made from one token.
1783  static StringLiteral *Create(const ASTContext &Ctx, StringRef Str,
1784  StringKind Kind, bool Pascal, QualType Ty,
1785  SourceLocation Loc) {
1786  return Create(Ctx, Str, Kind, Pascal, Ty, &Loc, 1);
1787  }
1788 
1789  /// Construct an empty string literal.
1790  static StringLiteral *CreateEmpty(const ASTContext &Ctx,
1791  unsigned NumConcatenated, unsigned Length,
1792  unsigned CharByteWidth);
1793 
1794  StringRef getString() const {
1795  assert(getCharByteWidth() == 1 &&
1796  "This function is used in places that assume strings use char");
1797  return StringRef(getStrDataAsChar(), getByteLength());
1798  }
1799 
1800  /// Allow access to clients that need the byte representation, such as
1801  /// ASTWriterStmt::VisitStringLiteral().
1802  StringRef getBytes() const {
1803  // FIXME: StringRef may not be the right type to use as a result for this.
1804  return StringRef(getStrDataAsChar(), getByteLength());
1805  }
1806 
1807  void outputString(raw_ostream &OS) const;
1808 
1809  uint32_t getCodeUnit(size_t i) const {
1810  assert(i < getLength() && "out of bounds access");
1811  switch (getCharByteWidth()) {
1812  case 1:
1813  return static_cast<unsigned char>(getStrDataAsChar()[i]);
1814  case 2:
1815  return getStrDataAsUInt16()[i];
1816  case 4:
1817  return getStrDataAsUInt32()[i];
1818  }
1819  llvm_unreachable("Unsupported character width!");
1820  }
1821 
1822  unsigned getByteLength() const { return getCharByteWidth() * getLength(); }
1823  unsigned getLength() const { return *getTrailingObjects<unsigned>(); }
1824  unsigned getCharByteWidth() const { return StringLiteralBits.CharByteWidth; }
1825 
1827  return static_cast<StringKind>(StringLiteralBits.Kind);
1828  }
1829 
1830  bool isAscii() const { return getKind() == Ascii; }
1831  bool isWide() const { return getKind() == Wide; }
1832  bool isUTF8() const { return getKind() == UTF8; }
1833  bool isUTF16() const { return getKind() == UTF16; }
1834  bool isUTF32() const { return getKind() == UTF32; }
1835  bool isPascal() const { return StringLiteralBits.IsPascal; }
1836 
1837  bool containsNonAscii() const {
1838  for (auto c : getString())
1839  if (!isASCII(c))
1840  return true;
1841  return false;
1842  }
1843 
1844  bool containsNonAsciiOrNull() const {
1845  for (auto c : getString())
1846  if (!isASCII(c) || !c)
1847  return true;
1848  return false;
1849  }
1850 
1851  /// getNumConcatenated - Get the number of string literal tokens that were
1852  /// concatenated in translation phase #6 to form this string literal.
1853  unsigned getNumConcatenated() const {
1854  return StringLiteralBits.NumConcatenated;
1855  }
1856 
1857  /// Get one of the string literal token.
1858  SourceLocation getStrTokenLoc(unsigned TokNum) const {
1859  assert(TokNum < getNumConcatenated() && "Invalid tok number");
1860  return getTrailingObjects<SourceLocation>()[TokNum];
1861  }
1862 
1863  /// getLocationOfByte - Return a source location that points to the specified
1864  /// byte of this string literal.
1865  ///
1866  /// Strings are amazingly complex. They can be formed from multiple tokens
1867  /// and can have escape sequences in them in addition to the usual trigraph
1868  /// and escaped newline business. This routine handles this complexity.
1869  ///
1871  getLocationOfByte(unsigned ByteNo, const SourceManager &SM,
1872  const LangOptions &Features, const TargetInfo &Target,
1873  unsigned *StartToken = nullptr,
1874  unsigned *StartTokenByteOffset = nullptr) const;
1875 
1877 
1878  tokloc_iterator tokloc_begin() const {
1879  return getTrailingObjects<SourceLocation>();
1880  }
1881 
1882  tokloc_iterator tokloc_end() const {
1883  return getTrailingObjects<SourceLocation>() + getNumConcatenated();
1884  }
1885 
1886  SourceLocation getBeginLoc() const LLVM_READONLY { return *tokloc_begin(); }
1887  SourceLocation getEndLoc() const LLVM_READONLY { return *(tokloc_end() - 1); }
1888 
1889  static bool classof(const Stmt *T) {
1890  return T->getStmtClass() == StringLiteralClass;
1891  }
1892 
1893  // Iterators
1896  }
1899  }
1900 };
1901 
1902 /// [C99 6.4.2.2] - A predefined identifier such as __func__.
1903 class PredefinedExpr final
1904  : public Expr,
1905  private llvm::TrailingObjects<PredefinedExpr, Stmt *> {
1906  friend class ASTStmtReader;
1907  friend TrailingObjects;
1908 
1909  // PredefinedExpr is optionally followed by a single trailing
1910  // "Stmt *" for the predefined identifier. It is present if and only if
1911  // hasFunctionName() is true and is always a "StringLiteral *".
1912 
1913 public:
1914  enum IdentKind {
1917  LFunction, // Same as Function, but as wide string.
1920  LFuncSig, // Same as FuncSig, but as as wide string
1922  /// The same as PrettyFunction, except that the
1923  /// 'virtual' keyword is omitted for virtual member functions.
1924  PrettyFunctionNoVirtual
1925  };
1926 
1927 private:
1929  StringLiteral *SL);
1930 
1931  explicit PredefinedExpr(EmptyShell Empty, bool HasFunctionName);
1932 
1933  /// True if this PredefinedExpr has storage for a function name.
1934  bool hasFunctionName() const { return PredefinedExprBits.HasFunctionName; }
1935 
1936  void setFunctionName(StringLiteral *SL) {
1937  assert(hasFunctionName() &&
1938  "This PredefinedExpr has no storage for a function name!");
1939  *getTrailingObjects<Stmt *>() = SL;
1940  }
1941 
1942 public:
1943  /// Create a PredefinedExpr.
1944  static PredefinedExpr *Create(const ASTContext &Ctx, SourceLocation L,
1945  QualType FNTy, IdentKind IK, StringLiteral *SL);
1946 
1947  /// Create an empty PredefinedExpr.
1948  static PredefinedExpr *CreateEmpty(const ASTContext &Ctx,
1949  bool HasFunctionName);
1950 
1952  return static_cast<IdentKind>(PredefinedExprBits.Kind);
1953  }
1954 
1955  SourceLocation getLocation() const { return PredefinedExprBits.Loc; }
1956  void setLocation(SourceLocation L) { PredefinedExprBits.Loc = L; }
1957 
1959  return hasFunctionName()
1960  ? static_cast<StringLiteral *>(*getTrailingObjects<Stmt *>())
1961  : nullptr;
1962  }
1963 
1965  return hasFunctionName()
1966  ? static_cast<StringLiteral *>(*getTrailingObjects<Stmt *>())
1967  : nullptr;
1968  }
1969 
1970  static StringRef getIdentKindName(IdentKind IK);
1971  static std::string ComputeName(IdentKind IK, const Decl *CurrentDecl);
1972 
1973  SourceLocation getBeginLoc() const { return getLocation(); }
1974  SourceLocation getEndLoc() const { return getLocation(); }
1975 
1976  static bool classof(const Stmt *T) {
1977  return T->getStmtClass() == PredefinedExprClass;
1978  }
1979 
1980  // Iterators
1982  return child_range(getTrailingObjects<Stmt *>(),
1983  getTrailingObjects<Stmt *>() + hasFunctionName());
1984  }
1985 
1987  return const_child_range(getTrailingObjects<Stmt *>(),
1988  getTrailingObjects<Stmt *>() + hasFunctionName());
1989  }
1990 };
1991 
1992 /// ParenExpr - This represents a parethesized expression, e.g. "(1)". This
1993 /// AST node is only formed if full location information is requested.
1994 class ParenExpr : public Expr {
1995  SourceLocation L, R;
1996  Stmt *Val;
1997 public:
1999  : Expr(ParenExprClass, val->getType(),
2000  val->getValueKind(), val->getObjectKind(),
2001  val->isTypeDependent(), val->isValueDependent(),
2002  val->isInstantiationDependent(),
2003  val->containsUnexpandedParameterPack()),
2004  L(l), R(r), Val(val) {}
2005 
2006  /// Construct an empty parenthesized expression.
2007  explicit ParenExpr(EmptyShell Empty)
2008  : Expr(ParenExprClass, Empty) { }
2009 
2010  const Expr *getSubExpr() const { return cast<Expr>(Val); }
2011  Expr *getSubExpr() { return cast<Expr>(Val); }
2012  void setSubExpr(Expr *E) { Val = E; }
2013 
2014  SourceLocation getBeginLoc() const LLVM_READONLY { return L; }
2015  SourceLocation getEndLoc() const LLVM_READONLY { return R; }
2016 
2017  /// Get the location of the left parentheses '('.
2018  SourceLocation getLParen() const { return L; }
2019  void setLParen(SourceLocation Loc) { L = Loc; }
2020 
2021  /// Get the location of the right parentheses ')'.
2022  SourceLocation getRParen() const { return R; }
2023  void setRParen(SourceLocation Loc) { R = Loc; }
2024 
2025  static bool classof(const Stmt *T) {
2026  return T->getStmtClass() == ParenExprClass;
2027  }
2028 
2029  // Iterators
2030  child_range children() { return child_range(&Val, &Val+1); }
2032  return const_child_range(&Val, &Val + 1);
2033  }
2034 };
2035 
2036 /// UnaryOperator - This represents the unary-expression's (except sizeof and
2037 /// alignof), the postinc/postdec operators from postfix-expression, and various
2038 /// extensions.
2039 ///
2040 /// Notes on various nodes:
2041 ///
2042 /// Real/Imag - These return the real/imag part of a complex operand. If
2043 /// applied to a non-complex value, the former returns its operand and the
2044 /// later returns zero in the type of the operand.
2045 ///
2046 class UnaryOperator : public Expr {
2047  Stmt *Val;
2048 
2049 public:
2051 
2052  UnaryOperator(Expr *input, Opcode opc, QualType type, ExprValueKind VK,
2053  ExprObjectKind OK, SourceLocation l, bool CanOverflow)
2054  : Expr(UnaryOperatorClass, type, VK, OK,
2055  input->isTypeDependent() || type->isDependentType(),
2056  input->isValueDependent(),
2057  (input->isInstantiationDependent() ||
2058  type->isInstantiationDependentType()),
2059  input->containsUnexpandedParameterPack()),
2060  Val(input) {
2061  UnaryOperatorBits.Opc = opc;
2062  UnaryOperatorBits.CanOverflow = CanOverflow;
2063  UnaryOperatorBits.Loc = l;
2064  }
2065 
2066  /// Build an empty unary operator.
2067  explicit UnaryOperator(EmptyShell Empty) : Expr(UnaryOperatorClass, Empty) {
2068  UnaryOperatorBits.Opc = UO_AddrOf;
2069  }
2070 
2071  Opcode getOpcode() const {
2072  return static_cast<Opcode>(UnaryOperatorBits.Opc);
2073  }
2074  void setOpcode(Opcode Opc) { UnaryOperatorBits.Opc = Opc; }
2075 
2076  Expr *getSubExpr() const { return cast<Expr>(Val); }
2077  void setSubExpr(Expr *E) { Val = E; }
2078 
2079  /// getOperatorLoc - Return the location of the operator.
2080  SourceLocation getOperatorLoc() const { return UnaryOperatorBits.Loc; }
2081  void setOperatorLoc(SourceLocation L) { UnaryOperatorBits.Loc = L; }
2082 
2083  /// Returns true if the unary operator can cause an overflow. For instance,
2084  /// signed int i = INT_MAX; i++;
2085  /// signed char c = CHAR_MAX; c++;
2086  /// Due to integer promotions, c++ is promoted to an int before the postfix
2087  /// increment, and the result is an int that cannot overflow. However, i++
2088  /// can overflow.
2089  bool canOverflow() const { return UnaryOperatorBits.CanOverflow; }
2090  void setCanOverflow(bool C) { UnaryOperatorBits.CanOverflow = C; }
2091 
2092  /// isPostfix - Return true if this is a postfix operation, like x++.
2093  static bool isPostfix(Opcode Op) {
2094  return Op == UO_PostInc || Op == UO_PostDec;
2095  }
2096 
2097  /// isPrefix - Return true if this is a prefix operation, like --x.
2098  static bool isPrefix(Opcode Op) {
2099  return Op == UO_PreInc || Op == UO_PreDec;
2100  }
2101 
2102  bool isPrefix() const { return isPrefix(getOpcode()); }
2103  bool isPostfix() const { return isPostfix(getOpcode()); }
2104 
2105  static bool isIncrementOp(Opcode Op) {
2106  return Op == UO_PreInc || Op == UO_PostInc;
2107  }
2108  bool isIncrementOp() const {
2109  return isIncrementOp(getOpcode());
2110  }
2111 
2112  static bool isDecrementOp(Opcode Op) {
2113  return Op == UO_PreDec || Op == UO_PostDec;
2114  }
2115  bool isDecrementOp() const {
2116  return isDecrementOp(getOpcode());
2117  }
2118 
2119  static bool isIncrementDecrementOp(Opcode Op) { return Op <= UO_PreDec; }
2120  bool isIncrementDecrementOp() const {
2121  return isIncrementDecrementOp(getOpcode());
2122  }
2123 
2124  static bool isArithmeticOp(Opcode Op) {
2125  return Op >= UO_Plus && Op <= UO_LNot;
2126  }
2127  bool isArithmeticOp() const { return isArithmeticOp(getOpcode()); }
2128 
2129  /// getOpcodeStr - Turn an Opcode enum value into the punctuation char it
2130  /// corresponds to, e.g. "sizeof" or "[pre]++"
2131  static StringRef getOpcodeStr(Opcode Op);
2132 
2133  /// Retrieve the unary opcode that corresponds to the given
2134  /// overloaded operator.
2135  static Opcode getOverloadedOpcode(OverloadedOperatorKind OO, bool Postfix);
2136 
2137  /// Retrieve the overloaded operator kind that corresponds to
2138  /// the given unary opcode.
2139  static OverloadedOperatorKind getOverloadedOperator(Opcode Opc);
2140 
2141  SourceLocation getBeginLoc() const LLVM_READONLY {
2142  return isPostfix() ? Val->getBeginLoc() : getOperatorLoc();
2143  }
2144  SourceLocation getEndLoc() const LLVM_READONLY {
2145  return isPostfix() ? getOperatorLoc() : Val->getEndLoc();
2146  }
2147  SourceLocation getExprLoc() const { return getOperatorLoc(); }
2148 
2149  static bool classof(const Stmt *T) {
2150  return T->getStmtClass() == UnaryOperatorClass;
2151  }
2152 
2153  // Iterators
2154  child_range children() { return child_range(&Val, &Val+1); }
2156  return const_child_range(&Val, &Val + 1);
2157  }
2158 };
2159 
2160 /// Helper class for OffsetOfExpr.
2161 
2162 // __builtin_offsetof(type, identifier(.identifier|[expr])*)
2164 public:
2165  /// The kind of offsetof node we have.
2166  enum Kind {
2167  /// An index into an array.
2168  Array = 0x00,
2169  /// A field.
2170  Field = 0x01,
2171  /// A field in a dependent type, known only by its name.
2172  Identifier = 0x02,
2173  /// An implicit indirection through a C++ base class, when the
2174  /// field found is in a base class.
2175  Base = 0x03
2176  };
2177 
2178 private:
2179  enum { MaskBits = 2, Mask = 0x03 };
2180 
2181  /// The source range that covers this part of the designator.
2182  SourceRange Range;
2183 
2184  /// The data describing the designator, which comes in three
2185  /// different forms, depending on the lower two bits.
2186  /// - An unsigned index into the array of Expr*'s stored after this node
2187  /// in memory, for [constant-expression] designators.
2188  /// - A FieldDecl*, for references to a known field.
2189  /// - An IdentifierInfo*, for references to a field with a given name
2190  /// when the class type is dependent.
2191  /// - A CXXBaseSpecifier*, for references that look at a field in a
2192  /// base class.
2193  uintptr_t Data;
2194 
2195 public:
2196  /// Create an offsetof node that refers to an array element.
2197  OffsetOfNode(SourceLocation LBracketLoc, unsigned Index,
2198  SourceLocation RBracketLoc)
2199  : Range(LBracketLoc, RBracketLoc), Data((Index << 2) | Array) {}
2200 
2201  /// Create an offsetof node that refers to a field.
2203  : Range(DotLoc.isValid() ? DotLoc : NameLoc, NameLoc),
2204  Data(reinterpret_cast<uintptr_t>(Field) | OffsetOfNode::Field) {}
2205 
2206  /// Create an offsetof node that refers to an identifier.
2208  SourceLocation NameLoc)
2209  : Range(DotLoc.isValid() ? DotLoc : NameLoc, NameLoc),
2210  Data(reinterpret_cast<uintptr_t>(Name) | Identifier) {}
2211 
2212  /// Create an offsetof node that refers into a C++ base class.
2214  : Range(), Data(reinterpret_cast<uintptr_t>(Base) | OffsetOfNode::Base) {}
2215 
2216  /// Determine what kind of offsetof node this is.
2217  Kind getKind() const { return static_cast<Kind>(Data & Mask); }
2218 
2219  /// For an array element node, returns the index into the array
2220  /// of expressions.
2221  unsigned getArrayExprIndex() const {
2222  assert(getKind() == Array);
2223  return Data >> 2;
2224  }
2225 
2226  /// For a field offsetof node, returns the field.
2227  FieldDecl *getField() const {
2228  assert(getKind() == Field);
2229  return reinterpret_cast<FieldDecl *>(Data & ~(uintptr_t)Mask);
2230  }
2231 
2232  /// For a field or identifier offsetof node, returns the name of
2233  /// the field.
2234  IdentifierInfo *getFieldName() const;
2235 
2236  /// For a base class node, returns the base specifier.
2238  assert(getKind() == Base);
2239  return reinterpret_cast<CXXBaseSpecifier *>(Data & ~(uintptr_t)Mask);
2240  }
2241 
2242  /// Retrieve the source range that covers this offsetof node.
2243  ///
2244  /// For an array element node, the source range contains the locations of
2245  /// the square brackets. For a field or identifier node, the source range
2246  /// contains the location of the period (if there is one) and the
2247  /// identifier.
2248  SourceRange getSourceRange() const LLVM_READONLY { return Range; }
2249  SourceLocation getBeginLoc() const LLVM_READONLY { return Range.getBegin(); }
2250  SourceLocation getEndLoc() const LLVM_READONLY { return Range.getEnd(); }
2251 };
2252 
2253 /// OffsetOfExpr - [C99 7.17] - This represents an expression of the form
2254 /// offsetof(record-type, member-designator). For example, given:
2255 /// @code
2256 /// struct S {
2257 /// float f;
2258 /// double d;
2259 /// };
2260 /// struct T {
2261 /// int i;
2262 /// struct S s[10];
2263 /// };
2264 /// @endcode
2265 /// we can represent and evaluate the expression @c offsetof(struct T, s[2].d).
2266 
2267 class OffsetOfExpr final
2268  : public Expr,
2269  private llvm::TrailingObjects<OffsetOfExpr, OffsetOfNode, Expr *> {
2270  SourceLocation OperatorLoc, RParenLoc;
2271  // Base type;
2272  TypeSourceInfo *TSInfo;
2273  // Number of sub-components (i.e. instances of OffsetOfNode).
2274  unsigned NumComps;
2275  // Number of sub-expressions (i.e. array subscript expressions).
2276  unsigned NumExprs;
2277 
2278  size_t numTrailingObjects(OverloadToken<OffsetOfNode>) const {
2279  return NumComps;
2280  }
2281 
2283  SourceLocation OperatorLoc, TypeSourceInfo *tsi,
2285  SourceLocation RParenLoc);
2286 
2287  explicit OffsetOfExpr(unsigned numComps, unsigned numExprs)
2288  : Expr(OffsetOfExprClass, EmptyShell()),
2289  TSInfo(nullptr), NumComps(numComps), NumExprs(numExprs) {}
2290 
2291 public:
2292 
2293  static OffsetOfExpr *Create(const ASTContext &C, QualType type,
2294  SourceLocation OperatorLoc, TypeSourceInfo *tsi,
2295  ArrayRef<OffsetOfNode> comps,
2296  ArrayRef<Expr*> exprs, SourceLocation RParenLoc);
2297 
2298  static OffsetOfExpr *CreateEmpty(const ASTContext &C,
2299  unsigned NumComps, unsigned NumExprs);
2300 
2301  /// getOperatorLoc - Return the location of the operator.
2302  SourceLocation getOperatorLoc() const { return OperatorLoc; }
2303  void setOperatorLoc(SourceLocation L) { OperatorLoc = L; }
2304 
2305  /// Return the location of the right parentheses.
2306  SourceLocation getRParenLoc() const { return RParenLoc; }
2307  void setRParenLoc(SourceLocation R) { RParenLoc = R; }
2308 
2310  return TSInfo;
2311  }
2313  TSInfo = tsi;
2314  }
2315 
2316  const OffsetOfNode &getComponent(unsigned Idx) const {
2317  assert(Idx < NumComps && "Subscript out of range");
2318  return getTrailingObjects<OffsetOfNode>()[Idx];
2319  }
2320 
2321  void setComponent(unsigned Idx, OffsetOfNode ON) {
2322  assert(Idx < NumComps && "Subscript out of range");
2323  getTrailingObjects<OffsetOfNode>()[Idx] = ON;
2324  }
2325 
2326  unsigned getNumComponents() const {
2327  return NumComps;
2328  }
2329 
2330  Expr* getIndexExpr(unsigned Idx) {
2331  assert(Idx < NumExprs && "Subscript out of range");
2332  return getTrailingObjects<Expr *>()[Idx];
2333  }
2334 
2335  const Expr *getIndexExpr(unsigned Idx) const {
2336  assert(Idx < NumExprs && "Subscript out of range");
2337  return getTrailingObjects<Expr *>()[Idx];
2338  }
2339 
2340  void setIndexExpr(unsigned Idx, Expr* E) {
2341  assert(Idx < NumComps && "Subscript out of range");
2342  getTrailingObjects<Expr *>()[Idx] = E;
2343  }
2344 
2345  unsigned getNumExpressions() const {
2346  return NumExprs;
2347  }
2348 
2349  SourceLocation getBeginLoc() const LLVM_READONLY { return OperatorLoc; }
2350  SourceLocation getEndLoc() const LLVM_READONLY { return RParenLoc; }
2351 
2352  static bool classof(const Stmt *T) {
2353  return T->getStmtClass() == OffsetOfExprClass;
2354  }
2355 
2356  // Iterators
2358  Stmt **begin = reinterpret_cast<Stmt **>(getTrailingObjects<Expr *>());
2359  return child_range(begin, begin + NumExprs);
2360  }
2362  Stmt *const *begin =
2363  reinterpret_cast<Stmt *const *>(getTrailingObjects<Expr *>());
2364  return const_child_range(begin, begin + NumExprs);
2365  }
2367 };
2368 
2369 /// UnaryExprOrTypeTraitExpr - expression with either a type or (unevaluated)
2370 /// expression operand. Used for sizeof/alignof (C99 6.5.3.4) and
2371 /// vec_step (OpenCL 1.1 6.11.12).
2373  union {
2376  } Argument;
2377  SourceLocation OpLoc, RParenLoc;
2378 
2379 public:
2381  QualType resultType, SourceLocation op,
2382  SourceLocation rp) :
2383  Expr(UnaryExprOrTypeTraitExprClass, resultType, VK_RValue, OK_Ordinary,
2384  false, // Never type-dependent (C++ [temp.dep.expr]p3).
2385  // Value-dependent if the argument is type-dependent.
2386  TInfo->getType()->isDependentType(),
2387  TInfo->getType()->isInstantiationDependentType(),
2388  TInfo->getType()->containsUnexpandedParameterPack()),
2389  OpLoc(op), RParenLoc(rp) {
2390  UnaryExprOrTypeTraitExprBits.Kind = ExprKind;
2391  UnaryExprOrTypeTraitExprBits.IsType = true;
2392  Argument.Ty = TInfo;
2393  }
2394 
2396  QualType resultType, SourceLocation op,
2397  SourceLocation rp);
2398 
2399  /// Construct an empty sizeof/alignof expression.
2401  : Expr(UnaryExprOrTypeTraitExprClass, Empty) { }
2402 
2404  return static_cast<UnaryExprOrTypeTrait>(UnaryExprOrTypeTraitExprBits.Kind);
2405  }
2406  void setKind(UnaryExprOrTypeTrait K) { UnaryExprOrTypeTraitExprBits.Kind = K;}
2407 
2408  bool isArgumentType() const { return UnaryExprOrTypeTraitExprBits.IsType; }
2410  return getArgumentTypeInfo()->getType();
2411  }
2413  assert(isArgumentType() && "calling getArgumentType() when arg is expr");
2414  return Argument.Ty;
2415  }
2417  assert(!isArgumentType() && "calling getArgumentExpr() when arg is type");
2418  return static_cast<Expr*>(Argument.Ex);
2419  }
2420  const Expr *getArgumentExpr() const {
2421  return const_cast<UnaryExprOrTypeTraitExpr*>(this)->getArgumentExpr();
2422  }
2423 
2424  void setArgument(Expr *E) {
2425  Argument.Ex = E;
2426  UnaryExprOrTypeTraitExprBits.IsType = false;
2427  }
2429  Argument.Ty = TInfo;
2430  UnaryExprOrTypeTraitExprBits.IsType = true;
2431  }
2432 
2433  /// Gets the argument type, or the type of the argument expression, whichever
2434  /// is appropriate.
2436  return isArgumentType() ? getArgumentType() : getArgumentExpr()->getType();
2437  }
2438 
2439  SourceLocation getOperatorLoc() const { return OpLoc; }
2440  void setOperatorLoc(SourceLocation L) { OpLoc = L; }
2441 
2442  SourceLocation getRParenLoc() const { return RParenLoc; }
2443  void setRParenLoc(SourceLocation L) { RParenLoc = L; }
2444 
2445  SourceLocation getBeginLoc() const LLVM_READONLY { return OpLoc; }
2446  SourceLocation getEndLoc() const LLVM_READONLY { return RParenLoc; }
2447 
2448  static bool classof(const Stmt *T) {
2449  return T->getStmtClass() == UnaryExprOrTypeTraitExprClass;
2450  }
2451 
2452  // Iterators
2454  const_child_range children() const;
2455 };
2456 
2457 //===----------------------------------------------------------------------===//
2458 // Postfix Operators.
2459 //===----------------------------------------------------------------------===//
2460 
2461 /// ArraySubscriptExpr - [C99 6.5.2.1] Array Subscripting.
2462 class ArraySubscriptExpr : public Expr {
2463  enum { LHS, RHS, END_EXPR };
2464  Stmt *SubExprs[END_EXPR];
2465 
2466  bool lhsIsBase() const { return getRHS()->getType()->isIntegerType(); }
2467 
2468 public:
2471  SourceLocation rbracketloc)
2472  : Expr(ArraySubscriptExprClass, t, VK, OK,
2473  lhs->isTypeDependent() || rhs->isTypeDependent(),
2474  lhs->isValueDependent() || rhs->isValueDependent(),
2475  (lhs->isInstantiationDependent() ||
2476  rhs->isInstantiationDependent()),
2477  (lhs->containsUnexpandedParameterPack() ||
2478  rhs->containsUnexpandedParameterPack())) {
2479  SubExprs[LHS] = lhs;
2480  SubExprs[RHS] = rhs;
2481  ArraySubscriptExprBits.RBracketLoc = rbracketloc;
2482  }
2483 
2484  /// Create an empty array subscript expression.
2486  : Expr(ArraySubscriptExprClass, Shell) { }
2487 
2488  /// An array access can be written A[4] or 4[A] (both are equivalent).
2489  /// - getBase() and getIdx() always present the normalized view: A[4].
2490  /// In this case getBase() returns "A" and getIdx() returns "4".
2491  /// - getLHS() and getRHS() present the syntactic view. e.g. for
2492  /// 4[A] getLHS() returns "4".
2493  /// Note: Because vector element access is also written A[4] we must
2494  /// predicate the format conversion in getBase and getIdx only on the
2495  /// the type of the RHS, as it is possible for the LHS to be a vector of
2496  /// integer type
2497  Expr *getLHS() { return cast<Expr>(SubExprs[LHS]); }
2498  const Expr *getLHS() const { return cast<Expr>(SubExprs[LHS]); }
2499  void setLHS(Expr *E) { SubExprs[LHS] = E; }
2500 
2501  Expr *getRHS() { return cast<Expr>(SubExprs[RHS]); }
2502  const Expr *getRHS() const { return cast<Expr>(SubExprs[RHS]); }
2503  void setRHS(Expr *E) { SubExprs[RHS] = E; }
2504 
2505  Expr *getBase() { return lhsIsBase() ? getLHS() : getRHS(); }
2506  const Expr *getBase() const { return lhsIsBase() ? getLHS() : getRHS(); }
2507 
2508  Expr *getIdx() { return lhsIsBase() ? getRHS() : getLHS(); }
2509  const Expr *getIdx() const { return lhsIsBase() ? getRHS() : getLHS(); }
2510 
2511  SourceLocation getBeginLoc() const LLVM_READONLY {
2512  return getLHS()->getBeginLoc();
2513  }
2514  SourceLocation getEndLoc() const { return getRBracketLoc(); }
2515 
2517  return ArraySubscriptExprBits.RBracketLoc;
2518  }
2520  ArraySubscriptExprBits.RBracketLoc = L;
2521  }
2522 
2523  SourceLocation getExprLoc() const LLVM_READONLY {
2524  return getBase()->getExprLoc();
2525  }
2526 
2527  static bool classof(const Stmt *T) {
2528  return T->getStmtClass() == ArraySubscriptExprClass;
2529  }
2530 
2531  // Iterators
2533  return child_range(&SubExprs[0], &SubExprs[0]+END_EXPR);
2534  }
2536  return const_child_range(&SubExprs[0], &SubExprs[0] + END_EXPR);
2537  }
2538 };
2539 
2540 /// CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
2541 /// CallExpr itself represents a normal function call, e.g., "f(x, 2)",
2542 /// while its subclasses may represent alternative syntax that (semantically)
2543 /// results in a function call. For example, CXXOperatorCallExpr is
2544 /// a subclass for overloaded operator calls that use operator syntax, e.g.,
2545 /// "str1 + str2" to resolve to a function call.
2546 class CallExpr : public Expr {
2547  enum { FN = 0, PREARGS_START = 1 };
2548 
2549  /// The number of arguments in the call expression.
2550  unsigned NumArgs;
2551 
2552  /// The location of the right parenthese. This has a different meaning for
2553  /// the derived classes of CallExpr.
2554  SourceLocation RParenLoc;
2555 
2556  void updateDependenciesFromArg(Expr *Arg);
2557 
2558  // CallExpr store some data in trailing objects. However since CallExpr
2559  // is used a base of other expression classes we cannot use
2560  // llvm::TrailingObjects. Instead we manually perform the pointer arithmetic
2561  // and casts.
2562  //
2563  // The trailing objects are in order:
2564  //
2565  // * A single "Stmt *" for the callee expression.
2566  //
2567  // * An array of getNumPreArgs() "Stmt *" for the pre-argument expressions.
2568  //
2569  // * An array of getNumArgs() "Stmt *" for the argument expressions.
2570  //
2571  // Note that we store the offset in bytes from the this pointer to the start
2572  // of the trailing objects. It would be perfectly possible to compute it
2573  // based on the dynamic kind of the CallExpr. However 1.) we have plenty of
2574  // space in the bit-fields of Stmt. 2.) It was benchmarked to be faster to
2575  // compute this once and then load the offset from the bit-fields of Stmt,
2576  // instead of re-computing the offset each time the trailing objects are
2577  // accessed.
2578 
2579  /// Return a pointer to the start of the trailing array of "Stmt *".
2580  Stmt **getTrailingStmts() {
2581  return reinterpret_cast<Stmt **>(reinterpret_cast<char *>(this) +
2582  CallExprBits.OffsetToTrailingObjects);
2583  }
2584  Stmt *const *getTrailingStmts() const {
2585  return const_cast<CallExpr *>(this)->getTrailingStmts();
2586  }
2587 
2588  /// Map a statement class to the appropriate offset in bytes from the
2589  /// this pointer to the trailing objects.
2590  static unsigned offsetToTrailingObjects(StmtClass SC);
2591 
2592 public:
2593  enum class ADLCallKind : bool { NotADL, UsesADL };
2594  static constexpr ADLCallKind NotADL = ADLCallKind::NotADL;
2595  static constexpr ADLCallKind UsesADL = ADLCallKind::UsesADL;
2596 
2597 protected:
2598  /// Build a call expression, assuming that appropriate storage has been
2599  /// allocated for the trailing objects.
2600  CallExpr(StmtClass SC, Expr *Fn, ArrayRef<Expr *> PreArgs,
2602  SourceLocation RParenLoc, unsigned MinNumArgs, ADLCallKind UsesADL);
2603 
2604  /// Build an empty call expression, for deserialization.
2605  CallExpr(StmtClass SC, unsigned NumPreArgs, unsigned NumArgs,
2606  EmptyShell Empty);
2607 
2608  /// Return the size in bytes needed for the trailing objects.
2609  /// Used by the derived classes to allocate the right amount of storage.
2610  static unsigned sizeOfTrailingObjects(unsigned NumPreArgs, unsigned NumArgs) {
2611  return (1 + NumPreArgs + NumArgs) * sizeof(Stmt *);
2612  }
2613 
2614  Stmt *getPreArg(unsigned I) {
2615  assert(I < getNumPreArgs() && "Prearg access out of range!");
2616  return getTrailingStmts()[PREARGS_START + I];
2617  }
2618  const Stmt *getPreArg(unsigned I) const {
2619  assert(I < getNumPreArgs() && "Prearg access out of range!");
2620  return getTrailingStmts()[PREARGS_START + I];
2621  }
2622  void setPreArg(unsigned I, Stmt *PreArg) {
2623  assert(I < getNumPreArgs() && "Prearg access out of range!");
2624  getTrailingStmts()[PREARGS_START + I] = PreArg;
2625  }
2626 
2627  unsigned getNumPreArgs() const { return CallExprBits.NumPreArgs; }
2628 
2629 public:
2630  /// Create a call expression. Fn is the callee expression, Args is the
2631  /// argument array, Ty is the type of the call expression (which is *not*
2632  /// the return type in general), VK is the value kind of the call expression
2633  /// (lvalue, rvalue, ...), and RParenLoc is the location of the right
2634  /// parenthese in the call expression. MinNumArgs specifies the minimum
2635  /// number of arguments. The actual number of arguments will be the greater
2636  /// of Args.size() and MinNumArgs. This is used in a few places to allocate
2637  /// enough storage for the default arguments. UsesADL specifies whether the
2638  /// callee was found through argument-dependent lookup.
2639  ///
2640  /// Note that you can use CreateTemporary if you need a temporary call
2641  /// expression on the stack.
2642  static CallExpr *Create(const ASTContext &Ctx, Expr *Fn,
2644  SourceLocation RParenLoc, unsigned MinNumArgs = 0,
2645  ADLCallKind UsesADL = NotADL);
2646 
2647  /// Create a temporary call expression with no arguments in the memory
2648  /// pointed to by Mem. Mem must points to at least sizeof(CallExpr)
2649  /// + sizeof(Stmt *) bytes of storage, aligned to alignof(CallExpr):
2650  ///
2651  /// \code{.cpp}
2652  /// alignas(CallExpr) char Buffer[sizeof(CallExpr) + sizeof(Stmt *)];
2653  /// CallExpr *TheCall = CallExpr::CreateTemporary(Buffer, etc);
2654  /// \endcode
2655  static CallExpr *CreateTemporary(void *Mem, Expr *Fn, QualType Ty,
2656  ExprValueKind VK, SourceLocation RParenLoc,
2657  ADLCallKind UsesADL = NotADL);
2658 
2659  /// Create an empty call expression, for deserialization.
2660  static CallExpr *CreateEmpty(const ASTContext &Ctx, unsigned NumArgs,
2661  EmptyShell Empty);
2662 
2663  Expr *getCallee() { return cast<Expr>(getTrailingStmts()[FN]); }
2664  const Expr *getCallee() const { return cast<Expr>(getTrailingStmts()[FN]); }
2665  void setCallee(Expr *F) { getTrailingStmts()[FN] = F; }
2666 
2668  return static_cast<ADLCallKind>(CallExprBits.UsesADL);
2669  }
2670  void setADLCallKind(ADLCallKind V = UsesADL) {
2671  CallExprBits.UsesADL = static_cast<bool>(V);
2672  }
2673  bool usesADL() const { return getADLCallKind() == UsesADL; }
2674 
2675  Decl *getCalleeDecl() { return getCallee()->getReferencedDeclOfCallee(); }
2676  const Decl *getCalleeDecl() const {
2677  return getCallee()->getReferencedDeclOfCallee();
2678  }
2679 
2680  /// If the callee is a FunctionDecl, return it. Otherwise return null.
2682  return dyn_cast_or_null<FunctionDecl>(getCalleeDecl());
2683  }
2685  return dyn_cast_or_null<FunctionDecl>(getCalleeDecl());
2686  }
2687 
2688  /// getNumArgs - Return the number of actual arguments to this call.
2689  unsigned getNumArgs() const { return NumArgs; }
2690 
2691  /// Retrieve the call arguments.
2693  return reinterpret_cast<Expr **>(getTrailingStmts() + PREARGS_START +
2694  getNumPreArgs());
2695  }
2696  const Expr *const *getArgs() const {
2697  return reinterpret_cast<const Expr *const *>(
2698  getTrailingStmts() + PREARGS_START + getNumPreArgs());
2699  }
2700 
2701  /// getArg - Return the specified argument.
2702  Expr *getArg(unsigned Arg) {
2703  assert(Arg < getNumArgs() && "Arg access out of range!");
2704  return getArgs()[Arg];
2705  }
2706  const Expr *getArg(unsigned Arg) const {
2707  assert(Arg < getNumArgs() && "Arg access out of range!");
2708  return getArgs()[Arg];
2709  }
2710 
2711  /// setArg - Set the specified argument.
2712  void setArg(unsigned Arg, Expr *ArgExpr) {
2713  assert(Arg < getNumArgs() && "Arg access out of range!");
2714  getArgs()[Arg] = ArgExpr;
2715  }
2716 
2717  /// Reduce the number of arguments in this call expression. This is used for
2718  /// example during error recovery to drop extra arguments. There is no way
2719  /// to perform the opposite because: 1.) We don't track how much storage
2720  /// we have for the argument array 2.) This would potentially require growing
2721  /// the argument array, something we cannot support since the arguments are
2722  /// stored in a trailing array.
2723  void shrinkNumArgs(unsigned NewNumArgs) {
2724  assert((NewNumArgs <= getNumArgs()) &&
2725  "shrinkNumArgs cannot increase the number of arguments!");
2726  NumArgs = NewNumArgs;
2727  }
2728 
2729  /// Bluntly set a new number of arguments without doing any checks whatsoever.
2730  /// Only used during construction of a CallExpr in a few places in Sema.
2731  /// FIXME: Find a way to remove it.
2732  void setNumArgsUnsafe(unsigned NewNumArgs) { NumArgs = NewNumArgs; }
2733 
2736  typedef llvm::iterator_range<arg_iterator> arg_range;
2737  typedef llvm::iterator_range<const_arg_iterator> const_arg_range;
2738 
2739  arg_range arguments() { return arg_range(arg_begin(), arg_end()); }
2740  const_arg_range arguments() const {
2741  return const_arg_range(arg_begin(), arg_end());
2742  }
2743 
2744  arg_iterator arg_begin() {
2745  return getTrailingStmts() + PREARGS_START + getNumPreArgs();
2746  }
2747  arg_iterator arg_end() { return arg_begin() + getNumArgs(); }
2748 
2749  const_arg_iterator arg_begin() const {
2750  return getTrailingStmts() + PREARGS_START + getNumPreArgs();
2751  }
2752  const_arg_iterator arg_end() const { return arg_begin() + getNumArgs(); }
2753 
2754  /// This method provides fast access to all the subexpressions of
2755  /// a CallExpr without going through the slower virtual child_iterator
2756  /// interface. This provides efficient reverse iteration of the
2757  /// subexpressions. This is currently used for CFG construction.
2759  return llvm::makeArrayRef(getTrailingStmts(),
2760  PREARGS_START + getNumPreArgs() + getNumArgs());
2761  }
2762 
2763  /// getNumCommas - Return the number of commas that must have been present in
2764  /// this function call.
2765  unsigned getNumCommas() const { return getNumArgs() ? getNumArgs() - 1 : 0; }
2766 
2767  /// getBuiltinCallee - If this is a call to a builtin, return the builtin ID
2768  /// of the callee. If not, return 0.
2769  unsigned getBuiltinCallee() const;
2770 
2771  /// Returns \c true if this is a call to a builtin which does not
2772  /// evaluate side-effects within its arguments.
2773  bool isUnevaluatedBuiltinCall(const ASTContext &Ctx) const;
2774 
2775  /// getCallReturnType - Get the return type of the call expr. This is not
2776  /// always the type of the expr itself, if the return type is a reference
2777  /// type.
2778  QualType getCallReturnType(const ASTContext &Ctx) const;
2779 
2780  /// Returns the WarnUnusedResultAttr that is either declared on the called
2781  /// function, or its return type declaration.
2782  const Attr *getUnusedResultAttr(const ASTContext &Ctx) const;
2783 
2784  /// Returns true if this call expression should warn on unused results.
2785  bool hasUnusedResultAttr(const ASTContext &Ctx) const {
2786  return getUnusedResultAttr(Ctx) != nullptr;
2787  }
2788 
2789  SourceLocation getRParenLoc() const { return RParenLoc; }
2790  void setRParenLoc(SourceLocation L) { RParenLoc = L; }
2791 
2792  SourceLocation getBeginLoc() const LLVM_READONLY;
2793  SourceLocation getEndLoc() const LLVM_READONLY;
2794 
2795  /// Return true if this is a call to __assume() or __builtin_assume() with
2796  /// a non-value-dependent constant parameter evaluating as false.
2797  bool isBuiltinAssumeFalse(const ASTContext &Ctx) const;
2798 
2799  bool isCallToStdMove() const {
2800  const FunctionDecl *FD = getDirectCallee();
2801  return getNumArgs() == 1 && FD && FD->isInStdNamespace() &&
2802  FD->getIdentifier() && FD->getIdentifier()->isStr("move");
2803  }
2804 
2805  static bool classof(const Stmt *T) {
2806  return T->getStmtClass() >= firstCallExprConstant &&
2807  T->getStmtClass() <= lastCallExprConstant;
2808  }
2809 
2810  // Iterators
2812  return child_range(getTrailingStmts(), getTrailingStmts() + PREARGS_START +
2813  getNumPreArgs() + getNumArgs());
2814  }
2815 
2817  return const_child_range(getTrailingStmts(),
2818  getTrailingStmts() + PREARGS_START +
2819  getNumPreArgs() + getNumArgs());
2820  }
2821 };
2822 
2823 /// Extra data stored in some MemberExpr objects.
2825  /// The nested-name-specifier that qualifies the name, including
2826  /// source-location information.
2828 
2829  /// The DeclAccessPair through which the MemberDecl was found due to
2830  /// name qualifiers.
2832 };
2833 
2834 /// MemberExpr - [C99 6.5.2.3] Structure and Union Members. X->F and X.F.
2835 ///
2836 class MemberExpr final
2837  : public Expr,
2838  private llvm::TrailingObjects<MemberExpr, MemberExprNameQualifier,
2839  ASTTemplateKWAndArgsInfo,
2840  TemplateArgumentLoc> {
2841  friend class ASTReader;
2842  friend class ASTStmtReader;
2843  friend class ASTStmtWriter;
2844  friend TrailingObjects;
2845 
2846  /// Base - the expression for the base pointer or structure references. In
2847  /// X.F, this is "X".
2848  Stmt *Base;
2849 
2850  /// MemberDecl - This is the decl being referenced by the field/member name.
2851  /// In X.F, this is the decl referenced by F.
2852  ValueDecl *MemberDecl;
2853 
2854  /// MemberDNLoc - Provides source/type location info for the
2855  /// declaration name embedded in MemberDecl.
2856  DeclarationNameLoc MemberDNLoc;
2857 
2858  /// MemberLoc - This is the location of the member name.
2859  SourceLocation MemberLoc;
2860 
2861  size_t numTrailingObjects(OverloadToken<MemberExprNameQualifier>) const {
2862  return hasQualifierOrFoundDecl();
2863  }
2864 
2865  size_t numTrailingObjects(OverloadToken<ASTTemplateKWAndArgsInfo>) const {
2866  return hasTemplateKWAndArgsInfo();
2867  }
2868 
2869  bool hasQualifierOrFoundDecl() const {
2870  return MemberExprBits.HasQualifierOrFoundDecl;
2871  }
2872 
2873  bool hasTemplateKWAndArgsInfo() const {
2874  return MemberExprBits.HasTemplateKWAndArgsInfo;
2875  }
2876 
2877  MemberExpr(Expr *Base, bool IsArrow, SourceLocation OperatorLoc,
2878  ValueDecl *MemberDecl, const DeclarationNameInfo &NameInfo,
2880  NonOdrUseReason NOUR);
2881  MemberExpr(EmptyShell Empty)
2882  : Expr(MemberExprClass, Empty), Base(), MemberDecl() {}
2883 
2884 public:
2885  static MemberExpr *Create(const ASTContext &C, Expr *Base, bool IsArrow,
2886  SourceLocation OperatorLoc,
2887  NestedNameSpecifierLoc QualifierLoc,
2888  SourceLocation TemplateKWLoc, ValueDecl *MemberDecl,
2889  DeclAccessPair FoundDecl,
2890  DeclarationNameInfo MemberNameInfo,
2891  const TemplateArgumentListInfo *TemplateArgs,
2893  NonOdrUseReason NOUR);
2894 
2895  /// Create an implicit MemberExpr, with no location, qualifier, template
2896  /// arguments, and so on. Suitable only for non-static member access.
2897  static MemberExpr *CreateImplicit(const ASTContext &C, Expr *Base,
2898  bool IsArrow, ValueDecl *MemberDecl,
2899  QualType T, ExprValueKind VK,
2900  ExprObjectKind OK) {
2901  return Create(C, Base, IsArrow, SourceLocation(), NestedNameSpecifierLoc(),
2902  SourceLocation(), MemberDecl,
2903  DeclAccessPair::make(MemberDecl, MemberDecl->getAccess()),
2904  DeclarationNameInfo(), nullptr, T, VK, OK, NOUR_None);
2905  }
2906 
2907  static MemberExpr *CreateEmpty(const ASTContext &Context, bool HasQualifier,
2908  bool HasFoundDecl,
2909  bool HasTemplateKWAndArgsInfo,
2910  unsigned NumTemplateArgs);
2911 
2912  void setBase(Expr *E) { Base = E; }
2913  Expr *getBase() const { return cast<Expr>(Base); }
2914 
2915  /// Retrieve the member declaration to which this expression refers.
2916  ///
2917  /// The returned declaration will be a FieldDecl or (in C++) a VarDecl (for
2918  /// static data members), a CXXMethodDecl, or an EnumConstantDecl.
2919  ValueDecl *getMemberDecl() const { return MemberDecl; }
2920  void setMemberDecl(ValueDecl *D) { MemberDecl = D; }
2921 
2922  /// Retrieves the declaration found by lookup.
2924  if (!hasQualifierOrFoundDecl())
2925  return DeclAccessPair::make(getMemberDecl(),
2926  getMemberDecl()->getAccess());
2927  return getTrailingObjects<MemberExprNameQualifier>()->FoundDecl;
2928  }
2929 
2930  /// Determines whether this member expression actually had
2931  /// a C++ nested-name-specifier prior to the name of the member, e.g.,
2932  /// x->Base::foo.
2933  bool hasQualifier() const { return getQualifier() != nullptr; }
2934 
2935  /// If the member name was qualified, retrieves the
2936  /// nested-name-specifier that precedes the member name, with source-location
2937  /// information.
2939  if (!hasQualifierOrFoundDecl())
2940  return NestedNameSpecifierLoc();
2941  return getTrailingObjects<MemberExprNameQualifier>()->QualifierLoc;
2942  }
2943 
2944  /// If the member name was qualified, retrieves the
2945  /// nested-name-specifier that precedes the member name. Otherwise, returns
2946  /// NULL.
2948  return getQualifierLoc().getNestedNameSpecifier();
2949  }
2950 
2951  /// Retrieve the location of the template keyword preceding
2952  /// the member name, if any.
2954  if (!hasTemplateKWAndArgsInfo())
2955  return SourceLocation();
2956  return getTrailingObjects<ASTTemplateKWAndArgsInfo>()->TemplateKWLoc;
2957  }
2958 
2959  /// Retrieve the location of the left angle bracket starting the
2960  /// explicit template argument list following the member name, if any.
2962  if (!hasTemplateKWAndArgsInfo())
2963  return SourceLocation();
2964  return getTrailingObjects<ASTTemplateKWAndArgsInfo>()->LAngleLoc;
2965  }
2966 
2967  /// Retrieve the location of the right angle bracket ending the
2968  /// explicit template argument list following the member name, if any.
2970  if (!hasTemplateKWAndArgsInfo())
2971  return SourceLocation();
2972  return getTrailingObjects<ASTTemplateKWAndArgsInfo>()->RAngleLoc;
2973  }
2974 
2975  /// Determines whether the member name was preceded by the template keyword.
2976  bool hasTemplateKeyword() const { return getTemplateKeywordLoc().isValid(); }
2977 
2978  /// Determines whether the member name was followed by an
2979  /// explicit template argument list.
2980  bool hasExplicitTemplateArgs() const { return getLAngleLoc().isValid(); }
2981 
2982  /// Copies the template arguments (if present) into the given
2983  /// structure.
2985  if (hasExplicitTemplateArgs())
2986  getTrailingObjects<ASTTemplateKWAndArgsInfo>()->copyInto(
2987  getTrailingObjects<TemplateArgumentLoc>(), List);
2988  }
2989 
2990  /// Retrieve the template arguments provided as part of this
2991  /// template-id.
2993  if (!hasExplicitTemplateArgs())
2994  return nullptr;
2995 
2996  return getTrailingObjects<TemplateArgumentLoc>();
2997  }
2998 
2999  /// Retrieve the number of template arguments provided as part of this
3000  /// template-id.
3001  unsigned getNumTemplateArgs() const {
3002  if (!hasExplicitTemplateArgs())
3003  return 0;
3004 
3005  return getTrailingObjects<ASTTemplateKWAndArgsInfo>()->NumTemplateArgs;
3006  }
3007 
3009  return {getTemplateArgs(), getNumTemplateArgs()};
3010  }
3011 
3012  /// Retrieve the member declaration name info.
3014  return DeclarationNameInfo(MemberDecl->getDeclName(),
3015  MemberLoc, MemberDNLoc);
3016  }
3017 
3018  SourceLocation getOperatorLoc() const { return MemberExprBits.OperatorLoc; }
3019 
3020  bool isArrow() const { return MemberExprBits.IsArrow; }
3021  void setArrow(bool A) { MemberExprBits.IsArrow = A; }
3022 
3023  /// getMemberLoc - Return the location of the "member", in X->F, it is the
3024  /// location of 'F'.
3025  SourceLocation getMemberLoc() const { return MemberLoc; }
3026  void setMemberLoc(SourceLocation L) { MemberLoc = L; }
3027 
3028  SourceLocation getBeginLoc() const LLVM_READONLY;
3029  SourceLocation getEndLoc() const LLVM_READONLY;
3030 
3031  SourceLocation getExprLoc() const LLVM_READONLY { return MemberLoc; }
3032 
3033  /// Determine whether the base of this explicit is implicit.
3034  bool isImplicitAccess() const {
3035  return getBase() && getBase()->isImplicitCXXThis();
3036  }
3037 
3038  /// Returns true if this member expression refers to a method that
3039  /// was resolved from an overloaded set having size greater than 1.
3040  bool hadMultipleCandidates() const {
3041  return MemberExprBits.HadMultipleCandidates;
3042  }
3043  /// Sets the flag telling whether this expression refers to
3044  /// a method that was resolved from an overloaded set having size
3045  /// greater than 1.
3046  void setHadMultipleCandidates(bool V = true) {
3047  MemberExprBits.HadMultipleCandidates = V;
3048  }
3049 
3050  /// Returns true if virtual dispatch is performed.
3051  /// If the member access is fully qualified, (i.e. X::f()), virtual
3052  /// dispatching is not performed. In -fapple-kext mode qualified
3053  /// calls to virtual method will still go through the vtable.
3054  bool performsVirtualDispatch(const LangOptions &LO) const {
3055  return LO.AppleKext || !hasQualifier();
3056  }
3057 
3058  /// Is this expression a non-odr-use reference, and if so, why?
3059  /// This is only meaningful if the named member is a static member.
3061  return static_cast<NonOdrUseReason>(MemberExprBits.NonOdrUseReason);
3062  }
3063 
3064  static bool classof(const Stmt *T) {
3065  return T->getStmtClass() == MemberExprClass;
3066  }
3067 
3068  // Iterators
3069  child_range children() { return child_range(&Base, &Base+1); }
3071  return const_child_range(&Base, &Base + 1);
3072  }
3073 };
3074 
3075 /// CompoundLiteralExpr - [C99 6.5.2.5]
3076 ///
3077 class CompoundLiteralExpr : public Expr {
3078  /// LParenLoc - If non-null, this is the location of the left paren in a
3079  /// compound literal like "(int){4}". This can be null if this is a
3080  /// synthesized compound expression.
3081  SourceLocation LParenLoc;
3082 
3083  /// The type as written. This can be an incomplete array type, in
3084  /// which case the actual expression type will be different.
3085  /// The int part of the pair stores whether this expr is file scope.
3086  llvm::PointerIntPair<TypeSourceInfo *, 1, bool> TInfoAndScope;
3087  Stmt *Init;
3088 public:
3090  QualType T, ExprValueKind VK, Expr *init, bool fileScope)
3091  : Expr(CompoundLiteralExprClass, T, VK, OK_Ordinary,
3092  tinfo->getType()->isDependentType(),
3093  init->isValueDependent(),
3094  (init->isInstantiationDependent() ||
3095  tinfo->getType()->isInstantiationDependentType()),
3096  init->containsUnexpandedParameterPack()),
3097  LParenLoc(lparenloc), TInfoAndScope(tinfo, fileScope), Init(init) {}
3098 
3099  /// Construct an empty compound literal.
3101  : Expr(CompoundLiteralExprClass, Empty) { }
3102 
3103  const Expr *getInitializer() const { return cast<Expr>(Init); }
3104  Expr *getInitializer() { return cast<Expr>(Init); }
3105  void setInitializer(Expr *E) { Init = E; }
3106 
3107  bool isFileScope() const { return TInfoAndScope.getInt(); }
3108  void setFileScope(bool FS) { TInfoAndScope.setInt(FS); }
3109 
3110  SourceLocation getLParenLoc() const { return LParenLoc; }
3111  void setLParenLoc(SourceLocation L) { LParenLoc = L; }
3112 
3114  return TInfoAndScope.getPointer();
3115  }
3117  TInfoAndScope.setPointer(tinfo);
3118  }
3119 
3120  SourceLocation getBeginLoc() const LLVM_READONLY {
3121  // FIXME: Init should never be null.
3122  if (!Init)
3123  return SourceLocation();
3124  if (LParenLoc.isInvalid())
3125  return Init->getBeginLoc();
3126  return LParenLoc;
3127  }
3128  SourceLocation getEndLoc() const LLVM_READONLY {
3129  // FIXME: Init should never be null.
3130  if (!Init)
3131  return SourceLocation();
3132  return Init->getEndLoc();
3133  }
3134 
3135  static bool classof(const Stmt *T) {
3136  return T->getStmtClass() == CompoundLiteralExprClass;
3137  }
3138 
3139  // Iterators
3140  child_range children() { return child_range(&Init, &Init+1); }
3142  return const_child_range(&Init, &Init + 1);
3143  }
3144 };
3145 
3146 /// CastExpr - Base class for type casts, including both implicit
3147 /// casts (ImplicitCastExpr) and explicit casts that have some
3148 /// representation in the source code (ExplicitCastExpr's derived
3149 /// classes).
3150 class CastExpr : public Expr {
3151  Stmt *Op;
3152 
3153  bool CastConsistency() const;
3154 
3155  const CXXBaseSpecifier * const *path_buffer() const {
3156  return const_cast<CastExpr*>(this)->path_buffer();
3157  }
3158  CXXBaseSpecifier **path_buffer();
3159 
3160 protected:
3162  Expr *op, unsigned BasePathSize)
3163  : Expr(SC, ty, VK, OK_Ordinary,
3164  // Cast expressions are type-dependent if the type is
3165  // dependent (C++ [temp.dep.expr]p3).
3166  ty->isDependentType(),
3167  // Cast expressions are value-dependent if the type is
3168  // dependent or if the subexpression is value-dependent.
3169  ty->isDependentType() || (op && op->isValueDependent()),
3170  (ty->isInstantiationDependentType() ||
3171  (op && op->isInstantiationDependent())),
3172  // An implicit cast expression doesn't (lexically) contain an
3173  // unexpanded pack, even if its target type does.
3174  ((SC != ImplicitCastExprClass &&
3175  ty->containsUnexpandedParameterPack()) ||
3176  (op && op->containsUnexpandedParameterPack()))),
3177  Op(op) {
3178  CastExprBits.Kind = kind;
3179  CastExprBits.PartOfExplicitCast = false;
3180  CastExprBits.BasePathSize = BasePathSize;
3181  assert((CastExprBits.BasePathSize == BasePathSize) &&
3182  "BasePathSize overflow!");
3183  assert(CastConsistency());
3184  }
3185 
3186  /// Construct an empty cast.
3187  CastExpr(StmtClass SC, EmptyShell Empty, unsigned BasePathSize)
3188  : Expr(SC, Empty) {
3189  CastExprBits.PartOfExplicitCast = false;
3190  CastExprBits.BasePathSize = BasePathSize;
3191  assert((CastExprBits.BasePathSize == BasePathSize) &&
3192  "BasePathSize overflow!");
3193  }
3194 
3195 public:
3196  CastKind getCastKind() const { return (CastKind) CastExprBits.Kind; }
3197  void setCastKind(CastKind K) { CastExprBits.Kind = K; }
3198 
3199  static const char *getCastKindName(CastKind CK);
3200  const char *getCastKindName() const { return getCastKindName(getCastKind()); }
3201 
3202  Expr *getSubExpr() { return cast<Expr>(Op); }
3203  const Expr *getSubExpr() const { return cast<Expr>(Op); }
3204  void setSubExpr(Expr *E) { Op = E; }
3205 
3206  /// Retrieve the cast subexpression as it was written in the source
3207  /// code, looking through any implicit casts or other intermediate nodes
3208  /// introduced by semantic analysis.
3209  Expr *getSubExprAsWritten();
3210  const Expr *getSubExprAsWritten() const {
3211  return const_cast<CastExpr *>(this)->getSubExprAsWritten();
3212  }
3213 
3214  /// If this cast applies a user-defined conversion, retrieve the conversion
3215  /// function that it invokes.
3216  NamedDecl *getConversionFunction() const;
3217 
3219  typedef const CXXBaseSpecifier *const *path_const_iterator;
3220  bool path_empty() const { return path_size() == 0; }
3221  unsigned path_size() const { return CastExprBits.BasePathSize; }
3222  path_iterator path_begin() { return path_buffer(); }
3223  path_iterator path_end() { return path_buffer() + path_size(); }
3224  path_const_iterator path_begin() const { return path_buffer(); }
3225  path_const_iterator path_end() const { return path_buffer() + path_size(); }
3226 
3227  llvm::iterator_range<path_iterator> path() {
3228  return llvm::make_range(path_begin(), path_end());
3229  }
3230  llvm::iterator_range<path_const_iterator> path() const {
3231  return llvm::make_range(path_begin(), path_end());
3232  }
3233 
3235  assert(getCastKind() == CK_ToUnion);
3236  return getTargetFieldForToUnionCast(getType(), getSubExpr()->getType());
3237  }
3238 
3239  static const FieldDecl *getTargetFieldForToUnionCast(QualType unionType,
3240  QualType opType);
3241  static const FieldDecl *getTargetFieldForToUnionCast(const RecordDecl *RD,
3242  QualType opType);
3243 
3244  static bool classof(const Stmt *T) {
3245  return T->getStmtClass() >= firstCastExprConstant &&
3246  T->getStmtClass() <= lastCastExprConstant;
3247  }
3248 
3249  // Iterators
3250  child_range children() { return child_range(&Op, &Op+1); }
3251  const_child_range children() const { return const_child_range(&Op, &Op + 1); }
3252 };
3253 
3254 /// ImplicitCastExpr - Allows us to explicitly represent implicit type
3255 /// conversions, which have no direct representation in the original
3256 /// source code. For example: converting T[]->T*, void f()->void
3257 /// (*f)(), float->double, short->int, etc.
3258 ///
3259 /// In C, implicit casts always produce rvalues. However, in C++, an
3260 /// implicit cast whose result is being bound to a reference will be
3261 /// an lvalue or xvalue. For example:
3262 ///
3263 /// @code
3264 /// class Base { };
3265 /// class Derived : public Base { };
3266 /// Derived &&ref();
3267 /// void f(Derived d) {
3268 /// Base& b = d; // initializer is an ImplicitCastExpr
3269 /// // to an lvalue of type Base
3270 /// Base&& r = ref(); // initializer is an ImplicitCastExpr
3271 /// // to an xvalue of type Base
3272 /// }
3273 /// @endcode
3274 class ImplicitCastExpr final
3275  : public CastExpr,
3276  private llvm::TrailingObjects<ImplicitCastExpr, CXXBaseSpecifier *> {
3277 
3279  unsigned BasePathLength, ExprValueKind VK)
3280  : CastExpr(ImplicitCastExprClass, ty, VK, kind, op, BasePathLength) { }
3281 
3282  /// Construct an empty implicit cast.
3283  explicit ImplicitCastExpr(EmptyShell Shell, unsigned PathSize)
3284  : CastExpr(ImplicitCastExprClass, Shell, PathSize) { }
3285 
3286 public:
3287  enum OnStack_t { OnStack };
3289  ExprValueKind VK)
3290  : CastExpr(ImplicitCastExprClass, ty, VK, kind, op, 0) {
3291  }
3292 
3293  bool isPartOfExplicitCast() const { return CastExprBits.PartOfExplicitCast; }
3294  void setIsPartOfExplicitCast(bool PartOfExplicitCast) {
3295  CastExprBits.PartOfExplicitCast = PartOfExplicitCast;
3296  }
3297 
3298  static ImplicitCastExpr *Create(const ASTContext &Context, QualType T,
3299  CastKind Kind, Expr *Operand,
3300  const CXXCastPath *BasePath,
3301  ExprValueKind Cat);
3302 
3303  static ImplicitCastExpr *CreateEmpty(const ASTContext &Context,
3304  unsigned PathSize);
3305 
3306  SourceLocation getBeginLoc() const LLVM_READONLY {
3307  return getSubExpr()->getBeginLoc();
3308  }
3309  SourceLocation getEndLoc() const LLVM_READONLY {
3310  return getSubExpr()->getEndLoc();
3311  }
3312 
3313  static bool classof(const Stmt *T) {
3314  return T->getStmtClass() == ImplicitCastExprClass;
3315  }
3316 
3318  friend class CastExpr;
3319 };
3320 
3321 /// ExplicitCastExpr - An explicit cast written in the source
3322 /// code.
3323 ///
3324 /// This class is effectively an abstract class, because it provides
3325 /// the basic representation of an explicitly-written cast without
3326 /// specifying which kind of cast (C cast, functional cast, static
3327 /// cast, etc.) was written; specific derived classes represent the
3328 /// particular style of cast and its location information.
3329 ///
3330 /// Unlike implicit casts, explicit cast nodes have two different
3331 /// types: the type that was written into the source code, and the
3332 /// actual type of the expression as determined by semantic
3333 /// analysis. These types may differ slightly. For example, in C++ one
3334 /// can cast to a reference type, which indicates that the resulting
3335 /// expression will be an lvalue or xvalue. The reference type, however,
3336 /// will not be used as the type of the expression.
3337 class ExplicitCastExpr : public CastExpr {
3338  /// TInfo - Source type info for the (written) type
3339  /// this expression is casting to.
3340  TypeSourceInfo *TInfo;
3341 
3342 protected:
3344  CastKind kind, Expr *op, unsigned PathSize,
3345  TypeSourceInfo *writtenTy)
3346  : CastExpr(SC, exprTy, VK, kind, op, PathSize), TInfo(writtenTy) {}
3347 
3348  /// Construct an empty explicit cast.
3349  ExplicitCastExpr(StmtClass SC, EmptyShell Shell, unsigned PathSize)
3350  : CastExpr(SC, Shell, PathSize) { }
3351 
3352 public:
3353  /// getTypeInfoAsWritten - Returns the type source info for the type
3354  /// that this expression is casting to.
3355  TypeSourceInfo *getTypeInfoAsWritten() const { return TInfo; }
3356  void setTypeInfoAsWritten(TypeSourceInfo *writtenTy) { TInfo = writtenTy; }
3357 
3358  /// getTypeAsWritten - Returns the type that this expression is
3359  /// casting to, as written in the source code.
3360  QualType getTypeAsWritten() const { return TInfo->getType(); }
3361 
3362  static bool classof(const Stmt *T) {
3363  return T->getStmtClass() >= firstExplicitCastExprConstant &&
3364  T->getStmtClass() <= lastExplicitCastExprConstant;
3365  }
3366 };
3367 
3368 /// CStyleCastExpr - An explicit cast in C (C99 6.5.4) or a C-style
3369 /// cast in C++ (C++ [expr.cast]), which uses the syntax
3370 /// (Type)expr. For example: @c (int)f.
3371 class CStyleCastExpr final
3372  : public ExplicitCastExpr,
3373  private llvm::TrailingObjects<CStyleCastExpr, CXXBaseSpecifier *> {
3374  SourceLocation LPLoc; // the location of the left paren
3375  SourceLocation RPLoc; // the location of the right paren
3376 
3378  unsigned PathSize, TypeSourceInfo *writtenTy,
3380  : ExplicitCastExpr(CStyleCastExprClass, exprTy, vk, kind, op, PathSize,
3381  writtenTy), LPLoc(l), RPLoc(r) {}
3382 
3383  /// Construct an empty C-style explicit cast.
3384  explicit CStyleCastExpr(EmptyShell Shell, unsigned PathSize)
3385  : ExplicitCastExpr(CStyleCastExprClass, Shell, PathSize) { }
3386 
3387 public:
3388  static CStyleCastExpr *Create(const ASTContext &Context, QualType T,
3389  ExprValueKind VK, CastKind K,
3390  Expr *Op, const CXXCastPath *BasePath,
3391  TypeSourceInfo *WrittenTy, SourceLocation L,
3392  SourceLocation R);
3393 
3394  static CStyleCastExpr *CreateEmpty(const ASTContext &Context,
3395  unsigned PathSize);
3396 
3397  SourceLocation getLParenLoc() const { return LPLoc; }
3398  void setLParenLoc(SourceLocation L) { LPLoc = L; }
3399 
3400  SourceLocation getRParenLoc() const { return RPLoc; }
3401  void setRParenLoc(SourceLocation L) { RPLoc = L; }
3402 
3403  SourceLocation getBeginLoc() const LLVM_READONLY { return LPLoc; }
3404  SourceLocation getEndLoc() const LLVM_READONLY {
3405  return getSubExpr()->getEndLoc();
3406  }
3407 
3408  static bool classof(const Stmt *T) {
3409  return T->getStmtClass() == CStyleCastExprClass;
3410  }
3411 
3413  friend class CastExpr;
3414 };
3415 
3416 /// A builtin binary operation expression such as "x + y" or "x <= y".
3417 ///
3418 /// This expression node kind describes a builtin binary operation,
3419 /// such as "x + y" for integer values "x" and "y". The operands will
3420 /// already have been converted to appropriate types (e.g., by
3421 /// performing promotions or conversions).
3422 ///
3423 /// In C++, where operators may be overloaded, a different kind of
3424 /// expression node (CXXOperatorCallExpr) is used to express the
3425 /// invocation of an overloaded operator with operator syntax. Within
3426 /// a C++ template, whether BinaryOperator or CXXOperatorCallExpr is
3427 /// used to store an expression "x + y" depends on the subexpressions
3428 /// for x and y. If neither x or y is type-dependent, and the "+"
3429 /// operator resolves to a built-in operation, BinaryOperator will be
3430 /// used to express the computation (x and y may still be
3431 /// value-dependent). If either x or y is type-dependent, or if the
3432 /// "+" resolves to an overloaded operator, CXXOperatorCallExpr will
3433 /// be used to express the computation.
3434 class BinaryOperator : public Expr {
3435  enum { LHS, RHS, END_EXPR };
3436  Stmt *SubExprs[END_EXPR];
3437 
3438 public:
3440 
3441  BinaryOperator(Expr *lhs, Expr *rhs, Opcode opc, QualType ResTy,
3443  SourceLocation opLoc, FPOptions FPFeatures)
3444  : Expr(BinaryOperatorClass, ResTy, VK, OK,
3445  lhs->isTypeDependent() || rhs->isTypeDependent(),
3446  lhs->isValueDependent() || rhs->isValueDependent(),
3447  (lhs->isInstantiationDependent() ||
3448  rhs->isInstantiationDependent()),
3449  (lhs->containsUnexpandedParameterPack() ||
3450  rhs->containsUnexpandedParameterPack())) {
3451  BinaryOperatorBits.Opc = opc;
3452  BinaryOperatorBits.FPFeatures = FPFeatures.getInt();
3453  BinaryOperatorBits.OpLoc = opLoc;
3454  SubExprs[LHS] = lhs;
3455  SubExprs[RHS] = rhs;
3456  assert(!isCompoundAssignmentOp() &&
3457  "Use CompoundAssignOperator for compound assignments");
3458  }
3459 
3460  /// Construct an empty binary operator.
3461  explicit BinaryOperator(EmptyShell Empty) : Expr(BinaryOperatorClass, Empty) {
3462  BinaryOperatorBits.Opc = BO_Comma;
3463  }
3464 
3465  SourceLocation getExprLoc() const { return getOperatorLoc(); }
3466  SourceLocation getOperatorLoc() const { return BinaryOperatorBits.OpLoc; }
3467  void setOperatorLoc(SourceLocation L) { BinaryOperatorBits.OpLoc = L; }
3468 
3469  Opcode getOpcode() const {
3470  return static_cast<Opcode>(BinaryOperatorBits.Opc);
3471  }
3472  void setOpcode(Opcode Opc) { BinaryOperatorBits.Opc = Opc; }
3473 
3474  Expr *getLHS() const { return cast<Expr>(SubExprs[LHS]); }
3475  void setLHS(Expr *E) { SubExprs[LHS] = E; }
3476  Expr *getRHS() const { return cast<Expr>(SubExprs[RHS]); }
3477  void setRHS(Expr *E) { SubExprs[RHS] = E; }
3478 
3479  SourceLocation getBeginLoc() const LLVM_READONLY {
3480  return getLHS()->getBeginLoc();
3481  }
3482  SourceLocation getEndLoc() const LLVM_READONLY {
3483  return getRHS()->getEndLoc();
3484  }
3485 
3486  /// getOpcodeStr - Turn an Opcode enum value into the punctuation char it
3487  /// corresponds to, e.g. "<<=".
3488  static StringRef getOpcodeStr(Opcode Op);
3489 
3490  StringRef getOpcodeStr() const { return getOpcodeStr(getOpcode()); }
3491 
3492  /// Retrieve the binary opcode that corresponds to the given
3493  /// overloaded operator.
3494  static Opcode getOverloadedOpcode(OverloadedOperatorKind OO);
3495 
3496  /// Retrieve the overloaded operator kind that corresponds to
3497  /// the given binary opcode.
3498  static OverloadedOperatorKind getOverloadedOperator(Opcode Opc);
3499 
3500  /// predicates to categorize the respective opcodes.
3501  static bool isPtrMemOp(Opcode Opc) {
3502  return Opc == BO_PtrMemD || Opc == BO_PtrMemI;
3503  }
3504  bool isPtrMemOp() const { return isPtrMemOp(getOpcode()); }
3505 
3506  static bool isMultiplicativeOp(Opcode Opc) {
3507  return Opc >= BO_Mul && Opc <= BO_Rem;
3508  }
3509  bool isMultiplicativeOp() const { return isMultiplicativeOp(getOpcode()); }
3510  static bool isAdditiveOp(Opcode Opc) { return Opc == BO_Add || Opc==BO_Sub; }
3511  bool isAdditiveOp() const { return isAdditiveOp(getOpcode()); }
3512  static bool isShiftOp(Opcode Opc) { return Opc == BO_Shl || Opc == BO_Shr; }
3513  bool isShiftOp() const { return isShiftOp(getOpcode()); }
3514 
3515  static bool isBitwiseOp(Opcode Opc) { return Opc >= BO_And && Opc <= BO_Or; }
3516  bool isBitwiseOp() const { return isBitwiseOp(getOpcode()); }
3517 
3518  static bool isRelationalOp(Opcode Opc) { return Opc >= BO_LT && Opc<=BO_GE; }
3519  bool isRelationalOp() const { return isRelationalOp(getOpcode()); }
3520 
3521  static bool isEqualityOp(Opcode Opc) { return Opc == BO_EQ || Opc == BO_NE; }
3522  bool isEqualityOp() const { return isEqualityOp(getOpcode()); }
3523 
3524  static bool isComparisonOp(Opcode Opc) { return Opc >= BO_Cmp && Opc<=BO_NE; }
3525  bool isComparisonOp() const { return isComparisonOp(getOpcode()); }
3526 
3527  static bool isCommaOp(Opcode Opc) { return Opc == BO_Comma; }
3528  bool isCommaOp() const { return isCommaOp(getOpcode()); }
3529 
3530  static Opcode negateComparisonOp(Opcode Opc) {
3531  switch (Opc) {
3532  default:
3533  llvm_unreachable("Not a comparison operator.");
3534  case BO_LT: return BO_GE;
3535  case BO_GT: return BO_LE;
3536  case BO_LE: return BO_GT;
3537  case BO_GE: return BO_LT;
3538  case BO_EQ: return BO_NE;
3539  case BO_NE: return BO_EQ;
3540  }
3541  }
3542 
3543  static Opcode reverseComparisonOp(Opcode Opc) {
3544  switch (Opc) {
3545  default:
3546  llvm_unreachable("Not a comparison operator.");
3547  case BO_LT: return BO_GT;
3548  case BO_GT: return BO_LT;
3549  case BO_LE: return BO_GE;
3550  case BO_GE: return BO_LE;
3551  case BO_EQ:
3552  case BO_NE:
3553  return Opc;
3554  }
3555  }
3556 
3557  static bool isLogicalOp(Opcode Opc) { return Opc == BO_LAnd || Opc==BO_LOr; }
3558  bool isLogicalOp() const { return isLogicalOp(getOpcode()); }
3559 
3560  static bool isAssignmentOp(Opcode Opc) {
3561  return Opc >= BO_Assign && Opc <= BO_OrAssign;
3562  }
3563  bool isAssignmentOp() const { return isAssignmentOp(getOpcode()); }
3564 
3565  static bool isCompoundAssignmentOp(Opcode Opc) {
3566  return Opc > BO_Assign && Opc <= BO_OrAssign;
3567  }
3568  bool isCompoundAssignmentOp() const {
3569  return isCompoundAssignmentOp(getOpcode());
3570  }
3571  static Opcode getOpForCompoundAssignment(Opcode Opc) {
3572  assert(isCompoundAssignmentOp(Opc));
3573  if (Opc >= BO_AndAssign)
3574  return Opcode(unsigned(Opc) - BO_AndAssign + BO_And);
3575  else
3576  return Opcode(unsigned(Opc) - BO_MulAssign + BO_Mul);
3577  }
3578 
3579  static bool isShiftAssignOp(Opcode Opc) {
3580  return Opc == BO_ShlAssign || Opc == BO_ShrAssign;
3581  }
3582  bool isShiftAssignOp() const {
3583  return isShiftAssignOp(getOpcode());
3584  }
3585 
3586  // Return true if a binary operator using the specified opcode and operands
3587  // would match the 'p = (i8*)nullptr + n' idiom for casting a pointer-sized
3588  // integer to a pointer.
3589  static bool isNullPointerArithmeticExtension(ASTContext &Ctx, Opcode Opc,
3590  Expr *LHS, Expr *RHS);
3591 
3592  static bool classof(const Stmt *S) {
3593  return S->getStmtClass() >= firstBinaryOperatorConstant &&
3594  S->getStmtClass() <= lastBinaryOperatorConstant;
3595  }
3596 
3597  // Iterators
3599  return child_range(&SubExprs[0], &SubExprs[0]+END_EXPR);
3600  }
3602  return const_child_range(&SubExprs[0], &SubExprs[0] + END_EXPR);
3603  }
3604 
3605  // Set the FP contractability status of this operator. Only meaningful for
3606  // operations on floating point types.
3608  BinaryOperatorBits.FPFeatures = F.getInt();
3609  }
3610 
3612  return FPOptions(BinaryOperatorBits.FPFeatures);
3613  }
3614 
3615  // Get the FP contractability status of this operator. Only meaningful for
3616  // operations on floating point types.
3618  return getFPFeatures().allowFPContractWithinStatement();
3619  }
3620 
3621  // Get the FENV_ACCESS status of this operator. Only meaningful for
3622  // operations on floating point types.
3623  bool isFEnvAccessOn() const { return getFPFeatures().allowFEnvAccess(); }
3624 
3625 protected:
3626  BinaryOperator(Expr *lhs, Expr *rhs, Opcode opc, QualType ResTy,
3628  SourceLocation opLoc, FPOptions FPFeatures, bool dead2)
3629  : Expr(CompoundAssignOperatorClass, ResTy, VK, OK,
3630  lhs->isTypeDependent() || rhs->isTypeDependent(),
3631  lhs->isValueDependent() || rhs->isValueDependent(),
3632  (lhs->isInstantiationDependent() ||
3633  rhs->isInstantiationDependent()),
3634  (lhs->containsUnexpandedParameterPack() ||
3635  rhs->containsUnexpandedParameterPack())) {
3636  BinaryOperatorBits.Opc = opc;
3637  BinaryOperatorBits.FPFeatures = FPFeatures.getInt();
3638  BinaryOperatorBits.OpLoc = opLoc;
3639  SubExprs[LHS] = lhs;
3640  SubExprs[RHS] = rhs;
3641  }
3642 
3643  BinaryOperator(StmtClass SC, EmptyShell Empty) : Expr(SC, Empty) {
3644  BinaryOperatorBits.Opc = BO_MulAssign;
3645  }
3646 };
3647 
3648 /// CompoundAssignOperator - For compound assignments (e.g. +=), we keep
3649 /// track of the type the operation is performed in. Due to the semantics of
3650 /// these operators, the operands are promoted, the arithmetic performed, an
3651 /// implicit conversion back to the result type done, then the assignment takes
3652 /// place. This captures the intermediate type which the computation is done
3653 /// in.
3655  QualType ComputationLHSType;
3656  QualType ComputationResultType;
3657 public:
3658  CompoundAssignOperator(Expr *lhs, Expr *rhs, Opcode opc, QualType ResType,
3660  QualType CompLHSType, QualType CompResultType,
3661  SourceLocation OpLoc, FPOptions FPFeatures)
3662  : BinaryOperator(lhs, rhs, opc, ResType, VK, OK, OpLoc, FPFeatures,
3663  true),
3664  ComputationLHSType(CompLHSType),
3665  ComputationResultType(CompResultType) {
3666  assert(isCompoundAssignmentOp() &&
3667  "Only should be used for compound assignments");
3668  }
3669 
3670  /// Build an empty compound assignment operator expression.
3672  : BinaryOperator(CompoundAssignOperatorClass, Empty) { }
3673 
3674  // The two computation types are the type the LHS is converted
3675  // to for the computation and the type of the result; the two are
3676  // distinct in a few cases (specifically, int+=ptr and ptr-=ptr).
3677  QualType getComputationLHSType() const { return ComputationLHSType; }
3678  void setComputationLHSType(QualType T) { ComputationLHSType = T; }
3679 
3680  QualType getComputationResultType() const { return ComputationResultType; }
3681  void setComputationResultType(QualType T) { ComputationResultType = T; }
3682 
3683  static bool classof(const Stmt *S) {
3684  return S->getStmtClass() == CompoundAssignOperatorClass;
3685  }
3686 };
3687 
3688 /// AbstractConditionalOperator - An abstract base class for
3689 /// ConditionalOperator and BinaryConditionalOperator.
3691  SourceLocation QuestionLoc, ColonLoc;
3692  friend class ASTStmtReader;
3693 
3694 protected:
3697  bool TD, bool VD, bool ID,
3698  bool ContainsUnexpandedParameterPack,
3699  SourceLocation qloc,
3700  SourceLocation cloc)
3701  : Expr(SC, T, VK, OK, TD, VD, ID, ContainsUnexpandedParameterPack),
3702  QuestionLoc(qloc), ColonLoc(cloc) {}
3703 
3705  : Expr(SC, Empty) { }
3706 
3707 public:
3708  // getCond - Return the expression representing the condition for
3709  // the ?: operator.
3710  Expr *getCond() const;
3711 
3712  // getTrueExpr - Return the subexpression representing the value of
3713  // the expression if the condition evaluates to true.
3714  Expr *getTrueExpr() const;
3715 
3716  // getFalseExpr - Return the subexpression representing the value of
3717  // the expression if the condition evaluates to false. This is
3718  // the same as getRHS.
3719  Expr *getFalseExpr() const;
3720 
3721  SourceLocation getQuestionLoc() const { return QuestionLoc; }
3723 
3724  static bool classof(const Stmt *T) {
3725  return T->getStmtClass() == ConditionalOperatorClass ||
3726  T->getStmtClass() == BinaryConditionalOperatorClass;
3727  }
3728 };
3729 
3730 /// ConditionalOperator - The ?: ternary operator. The GNU "missing
3731 /// middle" extension is a BinaryConditionalOperator.
3733  enum { COND, LHS, RHS, END_EXPR };
3734  Stmt* SubExprs[END_EXPR]; // Left/Middle/Right hand sides.
3735 
3736  friend class ASTStmtReader;
3737 public:
3739  SourceLocation CLoc, Expr *rhs, QualType t,
3742  ConditionalOperatorClass, t, VK, OK,
3743  // The type of the conditional operator depends on the type
3744  // of the conditional to support the GCC vector conditional
3745  // extension. Additionally, [temp.dep.expr] does specify state that
3746  // this should be dependent on ALL sub expressions.
3747  (cond->isTypeDependent() || lhs->isTypeDependent() ||
3748  rhs->isTypeDependent()),
3749  (cond->isValueDependent() || lhs->isValueDependent() ||
3750  rhs->isValueDependent()),
3751  (cond->isInstantiationDependent() ||
3752  lhs->isInstantiationDependent() ||
3753  rhs->isInstantiationDependent()),
3754  (cond->containsUnexpandedParameterPack() ||
3755  lhs->containsUnexpandedParameterPack() ||
3756  rhs->containsUnexpandedParameterPack()),
3757  QLoc, CLoc) {
3758  SubExprs[COND] = cond;
3759  SubExprs[LHS] = lhs;
3760  SubExprs[RHS] = rhs;
3761  }
3762 
3763  /// Build an empty conditional operator.
3765  : AbstractConditionalOperator(ConditionalOperatorClass, Empty) { }
3766 
3767  // getCond - Return the expression representing the condition for
3768  // the ?: operator.
3769  Expr *getCond() const { return cast<Expr>(SubExprs[COND]); }
3770 
3771  // getTrueExpr - Return the subexpression representing the value of
3772  // the expression if the condition evaluates to true.
3773  Expr *getTrueExpr() const { return cast<Expr>(SubExprs[LHS]); }
3774 
3775  // getFalseExpr - Return the subexpression representing the value of
3776  // the expression if the condition evaluates to false. This is
3777  // the same as getRHS.
3778  Expr *getFalseExpr() const { return cast<Expr>(SubExprs[RHS]); }
3779 
3780  Expr *getLHS() const { return cast<Expr>(SubExprs[LHS]); }
3781  Expr *getRHS() const { return cast<Expr>(SubExprs[RHS]); }
3782 
3783  SourceLocation getBeginLoc() const LLVM_READONLY {
3784  return getCond()->getBeginLoc();
3785  }
3786  SourceLocation getEndLoc() const LLVM_READONLY {
3787  return getRHS()->getEndLoc();
3788  }
3789 
3790  static bool classof(const Stmt *T) {
3791  return T->getStmtClass() == ConditionalOperatorClass;
3792  }
3793 
3794  // Iterators
3796  return child_range(&SubExprs[0], &SubExprs[0]+END_EXPR);
3797  }
3799  return const_child_range(&SubExprs[0], &SubExprs[0] + END_EXPR);
3800  }
3801 };
3802 
3803 /// BinaryConditionalOperator - The GNU extension to the conditional
3804 /// operator which allows the middle operand to be omitted.
3805 ///
3806 /// This is a different expression kind on the assumption that almost
3807 /// every client ends up needing to know that these are different.
3809  enum { COMMON, COND, LHS, RHS, NUM_SUBEXPRS };
3810 
3811  /// - the common condition/left-hand-side expression, which will be
3812  /// evaluated as the opaque value
3813  /// - the condition, expressed in terms of the opaque value
3814  /// - the left-hand-side, expressed in terms of the opaque value
3815  /// - the right-hand-side
3816  Stmt *SubExprs[NUM_SUBEXPRS];
3817  OpaqueValueExpr *OpaqueValue;
3818 
3819  friend class ASTStmtReader;
3820 public:
3822  Expr *cond, Expr *lhs, Expr *rhs,
3823  SourceLocation qloc, SourceLocation cloc,
3825  : AbstractConditionalOperator(BinaryConditionalOperatorClass, t, VK, OK,
3826  (common->isTypeDependent() || rhs->isTypeDependent()),
3827  (common->isValueDependent() || rhs->isValueDependent()),
3828  (common->isInstantiationDependent() ||
3829  rhs->isInstantiationDependent()),
3830  (common->containsUnexpandedParameterPack() ||
3831  rhs->containsUnexpandedParameterPack()),
3832  qloc, cloc),
3833  OpaqueValue(opaqueValue) {
3834  SubExprs[COMMON] = common;
3835  SubExprs[COND] = cond;
3836  SubExprs[LHS] = lhs;
3837  SubExprs[RHS] = rhs;
3838  assert(OpaqueValue->getSourceExpr() == common && "Wrong opaque value");
3839  }
3840 
3841  /// Build an empty conditional operator.
3843  : AbstractConditionalOperator(BinaryConditionalOperatorClass, Empty) { }
3844 
3845  /// getCommon - Return the common expression, written to the
3846  /// left of the condition. The opaque value will be bound to the
3847  /// result of this expression.
3848  Expr *getCommon() const { return cast<Expr>(SubExprs[COMMON]); }
3849 
3850  /// getOpaqueValue - Return the opaque value placeholder.
3851  OpaqueValueExpr *getOpaqueValue() const { return OpaqueValue; }
3852 
3853  /// getCond - Return the condition expression; this is defined
3854  /// in terms of the opaque value.
3855  Expr *getCond() const { return cast<Expr>(SubExprs[COND]); }
3856 
3857  /// getTrueExpr - Return the subexpression which will be
3858  /// evaluated if the condition evaluates to true; this is defined
3859  /// in terms of the opaque value.
3860  Expr *getTrueExpr() const {
3861  return cast<Expr>(SubExprs[LHS]);
3862  }
3863 
3864  /// getFalseExpr - Return the subexpression which will be
3865  /// evaluated if the condnition evaluates to false; this is
3866  /// defined in terms of the opaque value.
3867  Expr *getFalseExpr() const {
3868  return cast<Expr>(SubExprs[RHS]);
3869  }
3870 
3871  SourceLocation getBeginLoc() const LLVM_READONLY {
3872  return getCommon()->getBeginLoc();
3873  }
3874  SourceLocation getEndLoc() const LLVM_READONLY {
3875  return getFalseExpr()->getEndLoc();
3876  }
3877 
3878  static bool classof(const Stmt *T) {
3879  return T->getStmtClass() == BinaryConditionalOperatorClass;
3880  }
3881 
3882  // Iterators
3884  return child_range(SubExprs, SubExprs + NUM_SUBEXPRS);
3885  }
3887  return const_child_range(SubExprs, SubExprs + NUM_SUBEXPRS);
3888  }
3889 };
3890 
3892  if (const ConditionalOperator *co = dyn_cast<ConditionalOperator>(this))
3893  return co->getCond();
3894  return cast<BinaryConditionalOperator>(this)->getCond();
3895 }
3896 
3898  if (const ConditionalOperator *co = dyn_cast<ConditionalOperator>(this))
3899  return co->getTrueExpr();
3900  return cast<BinaryConditionalOperator>(this)->getTrueExpr();
3901 }
3902 
3904  if (const ConditionalOperator *co = dyn_cast<ConditionalOperator>(this))
3905  return co->getFalseExpr();
3906  return cast<BinaryConditionalOperator>(this)->getFalseExpr();
3907 }
3908 
3909 /// AddrLabelExpr - The GNU address of label extension, representing &&label.
3910 class AddrLabelExpr : public Expr {
3911  SourceLocation AmpAmpLoc, LabelLoc;
3912  LabelDecl *Label;
3913 public:
3915  QualType t)
3916  : Expr(AddrLabelExprClass, t, VK_RValue, OK_Ordinary, false, false, false,
3917  false),
3918  AmpAmpLoc(AALoc), LabelLoc(LLoc), Label(L) {}
3919 
3920  /// Build an empty address of a label expression.
3921  explicit AddrLabelExpr(EmptyShell Empty)
3922  : Expr(AddrLabelExprClass, Empty) { }
3923 
3924  SourceLocation getAmpAmpLoc() const { return AmpAmpLoc; }
3925  void setAmpAmpLoc(SourceLocation L) { AmpAmpLoc = L; }
3926  SourceLocation getLabelLoc() const { return LabelLoc; }
3927  void setLabelLoc(SourceLocation L) { LabelLoc = L; }
3928 
3929  SourceLocation getBeginLoc() const LLVM_READONLY { return AmpAmpLoc; }
3930  SourceLocation getEndLoc() const LLVM_READONLY { return LabelLoc; }
3931 
3932  LabelDecl *getLabel() const { return Label; }
3933  void setLabel(LabelDecl *L) { Label = L; }
3934 
3935  static bool classof(const Stmt *T) {
3936  return T->getStmtClass() == AddrLabelExprClass;
3937  }
3938 
3939  // Iterators
3942  }
3945  }
3946 };
3947 
3948 /// StmtExpr - This is the GNU Statement Expression extension: ({int X=4; X;}).
3949 /// The StmtExpr contains a single CompoundStmt node, which it evaluates and
3950 /// takes the value of the last subexpression.
3951 ///
3952 /// A StmtExpr is always an r-value; values "returned" out of a
3953 /// StmtExpr will be copied.
3954 class StmtExpr : public Expr {
3955  Stmt *SubStmt;
3956  SourceLocation LParenLoc, RParenLoc;
3957 public:
3958  // FIXME: Does type-dependence need to be computed differently?
3959  // FIXME: Do we need to compute instantiation instantiation-dependence for
3960  // statements? (ugh!)
3962  SourceLocation lp, SourceLocation rp) :
3963  Expr(StmtExprClass, T, VK_RValue, OK_Ordinary,
3964  T->isDependentType(), false, false, false),
3965  SubStmt(substmt), LParenLoc(lp), RParenLoc(rp) { }
3966 
3967  /// Build an empty statement expression.
3968  explicit StmtExpr(EmptyShell Empty) : Expr(StmtExprClass, Empty) { }
3969 
3970  CompoundStmt *getSubStmt() { return cast<CompoundStmt>(SubStmt); }
3971  const CompoundStmt *getSubStmt() const { return cast<CompoundStmt>(SubStmt); }
3972  void setSubStmt(CompoundStmt *S) { SubStmt = S; }
3973 
3974  SourceLocation getBeginLoc() const LLVM_READONLY { return LParenLoc; }
3975  SourceLocation getEndLoc() const LLVM_READONLY { return RParenLoc; }
3976 
3977  SourceLocation getLParenLoc() const { return LParenLoc; }
3978  void setLParenLoc(SourceLocation L) { LParenLoc = L; }
3979  SourceLocation getRParenLoc() const { return RParenLoc; }
3980  void setRParenLoc(SourceLocation L) { RParenLoc = L; }
3981 
3982  static bool classof(const Stmt *T) {
3983  return T->getStmtClass() == StmtExprClass;
3984  }
3985 
3986  // Iterators
3987  child_range children() { return child_range(&SubStmt, &SubStmt+1); }
3989  return const_child_range(&SubStmt, &SubStmt + 1);
3990  }
3991 };
3992 
3993 /// ShuffleVectorExpr - clang-specific builtin-in function
3994 /// __builtin_shufflevector.
3995 /// This AST node represents a operator that does a constant
3996 /// shuffle, similar to LLVM's shufflevector instruction. It takes
3997 /// two vectors and a variable number of constant indices,
3998 /// and returns the appropriately shuffled vector.
3999 class ShuffleVectorExpr : public Expr {
4000  SourceLocation BuiltinLoc, RParenLoc;
4001 
4002  // SubExprs - the list of values passed to the __builtin_shufflevector
4003  // function. The first two are vectors, and the rest are constant
4004  // indices. The number of values in this list is always
4005  // 2+the number of indices in the vector type.
4006  Stmt **SubExprs;
4007  unsigned NumExprs;
4008 
4009 public:
4011  SourceLocation BLoc, SourceLocation RP);
4012 
4013  /// Build an empty vector-shuffle expression.
4015  : Expr(ShuffleVectorExprClass, Empty), SubExprs(nullptr) { }
4016 
4017  SourceLocation getBuiltinLoc() const { return BuiltinLoc; }
4018  void setBuiltinLoc(SourceLocation L) { BuiltinLoc = L; }
4019 
4020  SourceLocation getRParenLoc() const { return RParenLoc; }
4021  void setRParenLoc(SourceLocation L) { RParenLoc = L; }
4022 
4023  SourceLocation getBeginLoc() const LLVM_READONLY { return BuiltinLoc; }
4024  SourceLocation getEndLoc() const LLVM_READONLY { return RParenLoc; }
4025 
4026  static bool classof(const Stmt *T) {
4027  return T->getStmtClass() == ShuffleVectorExprClass;
4028  }
4029 
4030  /// getNumSubExprs - Return the size of the SubExprs array. This includes the
4031  /// constant expression, the actual arguments passed in, and the function
4032  /// pointers.
4033  unsigned getNumSubExprs() const { return NumExprs; }
4034 
4035  /// Retrieve the array of expressions.
4036  Expr **getSubExprs() { return reinterpret_cast<Expr **>(SubExprs); }
4037 
4038  /// getExpr - Return the Expr at the specified index.
4039  Expr *getExpr(unsigned Index) {
4040  assert((Index < NumExprs) && "Arg access out of range!");
4041  return cast<Expr>(SubExprs[Index]);
4042  }
4043  const Expr *getExpr(unsigned Index) const {
4044  assert((Index < NumExprs) && "Arg access out of range!");
4045  return cast<Expr>(SubExprs[Index]);
4046  }
4047 
4048  void setExprs(const ASTContext &C, ArrayRef<Expr *> Exprs);
4049 
4050  llvm::APSInt getShuffleMaskIdx(const ASTContext &Ctx, unsigned N) const {
4051  assert((N < NumExprs - 2) && "Shuffle idx out of range!");
4052  return getExpr(N+2)->EvaluateKnownConstInt(Ctx);
4053  }
4054 
4055  // Iterators
4057  return child_range(&SubExprs[0], &SubExprs[0]+NumExprs);
4058  }
4060  return const_child_range(&SubExprs[0], &SubExprs[0] + NumExprs);
4061  }
4062 };
4063 
4064 /// ConvertVectorExpr - Clang builtin function __builtin_convertvector
4065 /// This AST node provides support for converting a vector type to another
4066 /// vector type of the same arity.
4067 class ConvertVectorExpr : public Expr {
4068 private:
4069  Stmt *SrcExpr;
4070  TypeSourceInfo *TInfo;
4071  SourceLocation BuiltinLoc, RParenLoc;
4072 
4073  friend class ASTReader;
4074  friend class ASTStmtReader;
4075  explicit ConvertVectorExpr(EmptyShell Empty) : Expr(ConvertVectorExprClass, Empty) {}
4076 
4077 public:
4080  SourceLocation BuiltinLoc, SourceLocation RParenLoc)
4081  : Expr(ConvertVectorExprClass, DstType, VK, OK,
4082  DstType->isDependentType(),
4083  DstType->isDependentType() || SrcExpr->isValueDependent(),
4084  (DstType->isInstantiationDependentType() ||
4085  SrcExpr->isInstantiationDependent()),
4086  (DstType->containsUnexpandedParameterPack() ||
4087  SrcExpr->containsUnexpandedParameterPack())),
4088  SrcExpr(SrcExpr), TInfo(TI), BuiltinLoc(BuiltinLoc), RParenLoc(RParenLoc) {}
4089 
4090  /// getSrcExpr - Return the Expr to be converted.
4091  Expr *getSrcExpr() const { return cast<Expr>(SrcExpr); }
4092 
4093  /// getTypeSourceInfo - Return the destination type.
4095  return TInfo;
4096  }
4098  TInfo = ti;
4099  }
4100 
4101  /// getBuiltinLoc - Return the location of the __builtin_convertvector token.
4102  SourceLocation getBuiltinLoc() const { return BuiltinLoc; }
4103 
4104  /// getRParenLoc - Return the location of final right parenthesis.
4105  SourceLocation getRParenLoc() const { return RParenLoc; }
4106 
4107  SourceLocation getBeginLoc() const LLVM_READONLY { return BuiltinLoc; }
4108  SourceLocation getEndLoc() const LLVM_READONLY { return RParenLoc; }
4109 
4110  static bool classof(const Stmt *T) {
4111  return T->getStmtClass() == ConvertVectorExprClass;
4112  }
4113 
4114  // Iterators
4115  child_range children() { return child_range(&SrcExpr, &SrcExpr+1); }
4117  return const_child_range(&SrcExpr, &SrcExpr + 1);
4118  }
4119 };
4120 
4121 /// ChooseExpr - GNU builtin-in function __builtin_choose_expr.
4122 /// This AST node is similar to the conditional operator (?:) in C, with
4123 /// the following exceptions:
4124 /// - the test expression must be a integer constant expression.
4125 /// - the expression returned acts like the chosen subexpression in every
4126 /// visible way: the type is the same as that of the chosen subexpression,
4127 /// and all predicates (whether it's an l-value, whether it's an integer
4128 /// constant expression, etc.) return the same result as for the chosen
4129 /// sub-expression.
4130 class ChooseExpr : public Expr {
4131  enum { COND, LHS, RHS, END_EXPR };
4132  Stmt* SubExprs[END_EXPR]; // Left/Middle/Right hand sides.
4133  SourceLocation BuiltinLoc, RParenLoc;
4134  bool CondIsTrue;
4135 public:
4136  ChooseExpr(SourceLocation BLoc, Expr *cond, Expr *lhs, Expr *rhs,
4138  SourceLocation RP, bool condIsTrue,
4139  bool TypeDependent, bool ValueDependent)
4140  : Expr(ChooseExprClass, t, VK, OK, TypeDependent, ValueDependent,
4141  (cond->isInstantiationDependent() ||
4142  lhs->isInstantiationDependent() ||
4143  rhs->isInstantiationDependent()),
4144  (cond->containsUnexpandedParameterPack() ||
4145  lhs->containsUnexpandedParameterPack() ||
4146  rhs->containsUnexpandedParameterPack())),
4147  BuiltinLoc(BLoc), RParenLoc(RP), CondIsTrue(condIsTrue) {
4148  SubExprs[COND] = cond;
4149  SubExprs[LHS] = lhs;
4150  SubExprs[RHS] = rhs;
4151  }
4152 
4153  /// Build an empty __builtin_choose_expr.
4154  explicit ChooseExpr(EmptyShell Empty) : Expr(ChooseExprClass, Empty) { }
4155 
4156  /// isConditionTrue - Return whether the condition is true (i.e. not
4157  /// equal to zero).
4158  bool isConditionTrue() const {
4159  assert(!isConditionDependent() &&
4160  "Dependent condition isn't true or false");
4161  return CondIsTrue;
4162  }
4163  void setIsConditionTrue(bool isTrue) { CondIsTrue = isTrue; }
4164 
4165  bool isConditionDependent() const {
4166  return getCond()->isTypeDependent() || getCond()->isValueDependent();
4167  }
4168 
4169  /// getChosenSubExpr - Return the subexpression chosen according to the
4170  /// condition.
4172  return isConditionTrue() ? getLHS() : getRHS();
4173  }
4174 
4175  Expr *getCond() const { return cast<Expr>(SubExprs[COND]); }
4176  void setCond(Expr *E) { SubExprs[COND] = E; }
4177  Expr *getLHS() const { return cast<Expr>(SubExprs[LHS]); }
4178  void setLHS(Expr *E) { SubExprs[LHS] = E; }
4179  Expr *getRHS() const { return cast<Expr>(SubExprs[RHS]); }
4180  void setRHS(Expr *E) { SubExprs[RHS] = E; }
4181 
4182  SourceLocation getBuiltinLoc() const { return BuiltinLoc; }
4183  void setBuiltinLoc(SourceLocation L) { BuiltinLoc = L; }
4184 
4185  SourceLocation getRParenLoc() const { return RParenLoc; }
4186  void setRParenLoc(SourceLocation L) { RParenLoc = L; }
4187 
4188  SourceLocation getBeginLoc() const LLVM_READONLY { return BuiltinLoc; }
4189  SourceLocation getEndLoc() const LLVM_READONLY { return RParenLoc; }
4190 
4191  static bool classof(const Stmt *T) {
4192  return T->getStmtClass() == ChooseExprClass;
4193  }
4194 
4195  // Iterators
4197  return child_range(&SubExprs[0], &SubExprs[0]+END_EXPR);
4198  }
4200  return const_child_range(&SubExprs[0], &SubExprs[0] + END_EXPR);
4201  }
4202 };
4203 
4204 /// GNUNullExpr - Implements the GNU __null extension, which is a name
4205 /// for a null pointer constant that has integral type (e.g., int or
4206 /// long) and is the same size and alignment as a pointer. The __null
4207 /// extension is typically only used by system headers, which define
4208 /// NULL as __null in C++ rather than using 0 (which is an integer
4209 /// that may not match the size of a pointer).
4210 class GNUNullExpr : public Expr {
4211  /// TokenLoc - The location of the __null keyword.
4212  SourceLocation TokenLoc;
4213 
4214 public:
4216  : Expr(GNUNullExprClass, Ty, VK_RValue, OK_Ordinary, false, false, false,
4217  false),
4218  TokenLoc(Loc) { }
4219 
4220  /// Build an empty GNU __null expression.
4221  explicit GNUNullExpr(EmptyShell Empty) : Expr(GNUNullExprClass, Empty) { }
4222 
4223  /// getTokenLocation - The location of the __null token.
4224  SourceLocation getTokenLocation() const { return TokenLoc; }
4225  void setTokenLocation(SourceLocation L) { TokenLoc = L; }
4226 
4227  SourceLocation getBeginLoc() const LLVM_READONLY { return TokenLoc; }
4228  SourceLocation getEndLoc() const LLVM_READONLY { return TokenLoc; }
4229 
4230  static bool classof(const Stmt *T) {
4231  return T->getStmtClass() == GNUNullExprClass;
4232  }
4233 
4234  // Iterators
4237  }
4240  }
4241 };
4242 
4243 /// Represents a call to the builtin function \c __builtin_va_arg.
4244 class VAArgExpr : public Expr {
4245  Stmt *Val;
4246  llvm::PointerIntPair<TypeSourceInfo *, 1, bool> TInfo;
4247  SourceLocation BuiltinLoc, RParenLoc;
4248 public:
4250  SourceLocation RPLoc, QualType t, bool IsMS)
4251  : Expr(VAArgExprClass, t, VK_RValue, OK_Ordinary, t->isDependentType(),
4252  false, (TInfo->getType()->isInstantiationDependentType() ||
4253  e->isInstantiationDependent()),
4254  (TInfo->getType()->containsUnexpandedParameterPack() ||
4255  e->containsUnexpandedParameterPack())),
4256  Val(e), TInfo(TInfo, IsMS), BuiltinLoc(BLoc), RParenLoc(RPLoc) {}
4257 
4258  /// Create an empty __builtin_va_arg expression.
4259  explicit VAArgExpr(EmptyShell Empty)
4260  : Expr(VAArgExprClass, Empty), Val(nullptr), TInfo(nullptr, false) {}
4261 
4262  const Expr *getSubExpr() const { return cast<Expr>(Val); }
4263  Expr *getSubExpr() { return cast<Expr>(Val); }
4264  void setSubExpr(Expr *E) { Val = E; }
4265 
4266  /// Returns whether this is really a Win64 ABI va_arg expression.
4267  bool isMicrosoftABI() const { return TInfo.getInt(); }
4268  void setIsMicrosoftABI(bool IsMS) { TInfo.setInt(IsMS); }
4269 
4270  TypeSourceInfo *getWrittenTypeInfo() const { return TInfo.getPointer(); }
4271  void setWrittenTypeInfo(TypeSourceInfo *TI) { TInfo.setPointer(TI); }
4272 
4273  SourceLocation getBuiltinLoc() const { return BuiltinLoc; }
4274  void setBuiltinLoc(SourceLocation L) { BuiltinLoc = L; }
4275 
4276  SourceLocation getRParenLoc() const { return RParenLoc; }
4277  void setRParenLoc(SourceLocation L) { RParenLoc = L; }
4278 
4279  SourceLocation getBeginLoc() const LLVM_READONLY { return BuiltinLoc; }
4280  SourceLocation getEndLoc() const LLVM_READONLY { return RParenLoc; }
4281 
4282  static bool classof(const Stmt *T) {
4283  return T->getStmtClass() == VAArgExprClass;
4284  }
4285 
4286  // Iterators
4287  child_range children() { return child_range(&Val, &Val+1); }
4289  return const_child_range(&Val, &Val + 1);
4290  }
4291 };
4292 
4293 /// Represents a function call to one of __builtin_LINE(), __builtin_COLUMN(),
4294 /// __builtin_FUNCTION(), or __builtin_FILE().
4295 class SourceLocExpr final : public Expr {
4296  SourceLocation BuiltinLoc, RParenLoc;
4297  DeclContext *ParentContext;
4298 
4299 public:
4300  enum IdentKind { Function, File, Line, Column };
4301 
4303  SourceLocation RParenLoc, DeclContext *Context);
4304 
4305  /// Build an empty call expression.
4306  explicit SourceLocExpr(EmptyShell Empty) : Expr(SourceLocExprClass, Empty) {}
4307 
4308  /// Return the result of evaluating this SourceLocExpr in the specified
4309  /// (and possibly null) default argument or initialization context.
4310  APValue EvaluateInContext(const ASTContext &Ctx,
4311  const Expr *DefaultExpr) const;
4312 
4313  /// Return a string representing the name of the specific builtin function.
4314  StringRef getBuiltinStr() const;
4315 
4317  return static_cast<IdentKind>(SourceLocExprBits.Kind);
4318  }
4319 
4320  bool isStringType() const {
4321  switch (getIdentKind()) {
4322  case File:
4323  case Function:
4324  return true;
4325  case Line:
4326  case Column:
4327  return false;
4328  }
4329  llvm_unreachable("unknown source location expression kind");
4330  }
4331  bool isIntType() const LLVM_READONLY { return !isStringType(); }
4332 
4333  /// If the SourceLocExpr has been resolved return the subexpression
4334  /// representing the resolved value. Otherwise return null.
4335  const DeclContext *getParentContext() const { return ParentContext; }
4336  DeclContext *getParentContext() { return ParentContext; }
4337 
4338  SourceLocation getLocation() const { return BuiltinLoc; }
4339  SourceLocation getBeginLoc() const { return BuiltinLoc; }
4340  SourceLocation getEndLoc() const { return RParenLoc; }
4341 
4344  }
4345 
4348  }
4349 
4350  static bool classof(const Stmt *T) {
4351  return T->getStmtClass() == SourceLocExprClass;
4352  }
4353 
4354 private:
4355  friend class ASTStmtReader;
4356 };
4357 
4358 /// Describes an C or C++ initializer list.
4359 ///
4360 /// InitListExpr describes an initializer list, which can be used to
4361 /// initialize objects of different types, including
4362 /// struct/class/union types, arrays, and vectors. For example:
4363 ///
4364 /// @code
4365 /// struct foo x = { 1, { 2, 3 } };
4366 /// @endcode
4367 ///
4368 /// Prior to semantic analysis, an initializer list will represent the
4369 /// initializer list as written by the user, but will have the
4370 /// placeholder type "void". This initializer list is called the
4371 /// syntactic form of the initializer, and may contain C99 designated
4372 /// initializers (represented as DesignatedInitExprs), initializations
4373 /// of subobject members without explicit braces, and so on. Clients
4374 /// interested in the original syntax of the initializer list should
4375 /// use the syntactic form of the initializer list.
4376 ///
4377 /// After semantic analysis, the initializer list will represent the
4378 /// semantic form of the initializer, where the initializations of all
4379 /// subobjects are made explicit with nested InitListExpr nodes and
4380 /// C99 designators have been eliminated by placing the designated
4381 /// initializations into the subobject they initialize. Additionally,
4382 /// any "holes" in the initialization, where no initializer has been
4383 /// specified for a particular subobject, will be replaced with
4384 /// implicitly-generated ImplicitValueInitExpr expressions that
4385 /// value-initialize the subobjects. Note, however, that the
4386 /// initializer lists may still have fewer initializers than there are
4387 /// elements to initialize within the object.
4388 ///
4389 /// After semantic analysis has completed, given an initializer list,
4390 /// method isSemanticForm() returns true if and only if this is the
4391 /// semantic form of the initializer list (note: the same AST node
4392 /// may at the same time be the syntactic form).
4393 /// Given the semantic form of the initializer list, one can retrieve
4394 /// the syntactic form of that initializer list (when different)
4395 /// using method getSyntacticForm(); the method returns null if applied
4396 /// to a initializer list which is already in syntactic form.
4397 /// Similarly, given the syntactic form (i.e., an initializer list such
4398 /// that isSemanticForm() returns false), one can retrieve the semantic
4399 /// form using method getSemanticForm().
4400 /// Since many initializer lists have the same syntactic and semantic forms,
4401 /// getSyntacticForm() may return NULL, indicating that the current
4402 /// semantic initializer list also serves as its syntactic form.
4403 class InitListExpr : public Expr {
4404  // FIXME: Eliminate this vector in favor of ASTContext allocation
4406  InitExprsTy InitExprs;
4407  SourceLocation LBraceLoc, RBraceLoc;
4408 
4409  /// The alternative form of the initializer list (if it exists).
4410  /// The int part of the pair stores whether this initializer list is
4411  /// in semantic form. If not null, the pointer points to:
4412  /// - the syntactic form, if this is in semantic form;
4413  /// - the semantic form, if this is in syntactic form.
4414  llvm::PointerIntPair<InitListExpr *, 1, bool> AltForm;
4415 
4416  /// Either:
4417  /// If this initializer list initializes an array with more elements than
4418  /// there are initializers in the list, specifies an expression to be used
4419  /// for value initialization of the rest of the elements.
4420  /// Or
4421  /// If this initializer list initializes a union, specifies which
4422  /// field within the union will be initialized.
4423  llvm::PointerUnion<Expr *, FieldDecl *> ArrayFillerOrUnionFieldInit;
4424 
4425 public:
4426  InitListExpr(const ASTContext &C, SourceLocation lbraceloc,
4427  ArrayRef<Expr*> initExprs, SourceLocation rbraceloc);
4428 
4429  /// Build an empty initializer list.
4430  explicit InitListExpr(EmptyShell Empty)
4431  : Expr(InitListExprClass, Empty), AltForm(nullptr, true) { }
4432 
4433  unsigned getNumInits() const { return InitExprs.size(); }
4434 
4435  /// Retrieve the set of initializers.
4436  Expr **getInits() { return reinterpret_cast<Expr **>(InitExprs.data()); }
4437 
4438  /// Retrieve the set of initializers.
4439  Expr * const *getInits() const {
4440  return reinterpret_cast<Expr * const *>(InitExprs.data());
4441  }
4442 
4444  return llvm::makeArrayRef(getInits(), getNumInits());
4445  }
4446 
4448  return llvm::makeArrayRef(getInits(), getNumInits());
4449  }
4450 
4451  const Expr *getInit(unsigned Init) const {
4452  assert(Init < getNumInits() && "Initializer access out of range!");
4453  return cast_or_null<Expr>(InitExprs[Init]);
4454  }
4455 
4456  Expr *getInit(unsigned Init) {
4457  assert(Init < getNumInits() && "Initializer access out of range!");
4458  return cast_or_null<Expr>(InitExprs[Init]);
4459  }
4460 
4461  void setInit(unsigned Init, Expr *expr) {
4462  assert(Init < getNumInits() && "Initializer access out of range!");
4463  InitExprs[Init] = expr;
4464 
4465  if (expr) {
4466  ExprBits.TypeDependent |= expr->isTypeDependent();
4467  ExprBits.ValueDependent |= expr->isValueDependent();
4468  ExprBits.InstantiationDependent |= expr->isInstantiationDependent();
4469  ExprBits.ContainsUnexpandedParameterPack |=
4471  }
4472  }
4473 
4474  /// Reserve space for some number of initializers.
4475  void reserveInits(const ASTContext &C, unsigned NumInits);
4476 
4477  /// Specify the number of initializers
4478  ///
4479  /// If there are more than @p NumInits initializers, the remaining
4480  /// initializers will be destroyed. If there are fewer than @p
4481  /// NumInits initializers, NULL expressions will be added for the
4482  /// unknown initializers.
4483  void resizeInits(const ASTContext &Context, unsigned NumInits);
4484 
4485  /// Updates the initializer at index @p Init with the new
4486  /// expression @p expr, and returns the old expression at that
4487  /// location.
4488  ///
4489  /// When @p Init is out of range for this initializer list, the
4490  /// initializer list will be extended with NULL expressions to
4491  /// accommodate the new entry.
4492  Expr *updateInit(const ASTContext &C, unsigned Init, Expr *expr);
4493 
4494  /// If this initializer list initializes an array with more elements
4495  /// than there are initializers in the list, specifies an expression to be
4496  /// used for value initialization of the rest of the elements.
4498  return ArrayFillerOrUnionFieldInit.dyn_cast<Expr *>();
4499  }
4500  const Expr *getArrayFiller() const {
4501  return const_cast<InitListExpr *>(this)->getArrayFiller();
4502  }
4503  void setArrayFiller(Expr *filler);
4504 
4505  /// Return true if this is an array initializer and its array "filler"
4506  /// has been set.
4507  bool hasArrayFiller() const { return getArrayFiller(); }
4508 
4509  /// If this initializes a union, specifies which field in the
4510  /// union to initialize.
4511  ///
4512  /// Typically, this field is the first named field within the
4513  /// union. However, a designated initializer can specify the
4514  /// initialization of a different field within the union.
4516  return ArrayFillerOrUnionFieldInit.dyn_cast<FieldDecl *>();
4517  }
4519  return const_cast<InitListExpr *>(this)->getInitializedFieldInUnion();
4520  }
4522  assert((FD == nullptr
4523  || getInitializedFieldInUnion() == nullptr
4524  || getInitializedFieldInUnion() == FD)
4525  && "Only one field of a union may be initialized at a time!");
4526  ArrayFillerOrUnionFieldInit = FD;
4527  }
4528 
4529  // Explicit InitListExpr's originate from source code (and have valid source
4530  // locations). Implicit InitListExpr's are created by the semantic analyzer.
4531  // FIXME: This is wrong; InitListExprs created by semantic analysis have
4532  // valid source locations too!
4533  bool isExplicit() const {
4534  return LBraceLoc.isValid() && RBraceLoc.isValid();
4535  }
4536 
4537  // Is this an initializer for an array of characters, initialized by a string
4538  // literal or an @encode?
4539  bool isStringLiteralInit() const;
4540 
4541  /// Is this a transparent initializer list (that is, an InitListExpr that is
4542  /// purely syntactic, and whose semantics are that of the sole contained
4543  /// initializer)?
4544  bool isTransparent() const;
4545 
4546  /// Is this the zero initializer {0} in a language which considers it
4547  /// idiomatic?
4548  bool isIdiomaticZeroInitializer(const LangOptions &LangOpts) const;
4549 
4550  SourceLocation getLBraceLoc() const { return LBraceLoc; }
4551  void setLBraceLoc(SourceLocation Loc) { LBraceLoc = Loc; }
4552  SourceLocation getRBraceLoc() const { return RBraceLoc; }
4553  void setRBraceLoc(SourceLocation Loc) { RBraceLoc = Loc; }
4554 
4555  bool isSemanticForm() const { return AltForm.getInt(); }
4557  return isSemanticForm() ? nullptr : AltForm.getPointer();
4558  }
4559  bool isSyntacticForm() const {
4560  return !AltForm.getInt() || !AltForm.getPointer();
4561  }
4563  return isSemanticForm() ? AltForm.getPointer() : nullptr;
4564  }
4565 
4567  AltForm.setPointer(Init);
4568  AltForm.setInt(true);
4569  Init->AltForm.setPointer(this);
4570  Init->AltForm.setInt(false);
4571  }
4572 
4574  return InitListExprBits.HadArrayRangeDesignator != 0;
4575  }
4576  void sawArrayRangeDesignator(bool ARD = true) {
4577  InitListExprBits.HadArrayRangeDesignator = ARD;
4578  }
4579 
4580  SourceLocation getBeginLoc() const LLVM_READONLY;
4581  SourceLocation getEndLoc() const LLVM_READONLY;
4582 
4583  static bool classof(const Stmt *T) {
4584  return T->getStmtClass() == InitListExprClass;
4585  }
4586 
4587  // Iterators
4589  const_child_range CCR = const_cast<const InitListExpr *>(this)->children();
4590  return child_range(cast_away_const(CCR.begin()),
4591  cast_away_const(CCR.end()));
4592  }
4593 
4595  // FIXME: This does not include the array filler expression.
4596  if (InitExprs.empty())
4598  return const_child_range(&InitExprs[0], &InitExprs[0] + InitExprs.size());
4599  }
4600 
4605 
4606  iterator begin() { return InitExprs.begin(); }
4607  const_iterator begin() const { return InitExprs.begin(); }
4608  iterator end() { return InitExprs.end(); }
4609  const_iterator end() const { return InitExprs.end(); }
4610  reverse_iterator rbegin() { return InitExprs.rbegin(); }
4611  const_reverse_iterator rbegin() const { return InitExprs.rbegin(); }
4612  reverse_iterator rend() { return InitExprs.rend(); }
4613  const_reverse_iterator rend() const { return InitExprs.rend(); }
4614 
4615  friend class ASTStmtReader;
4616  friend class ASTStmtWriter;
4617 };
4618 
4619 /// Represents a C99 designated initializer expression.
4620 ///
4621 /// A designated initializer expression (C99 6.7.8) contains one or
4622 /// more designators (which can be field designators, array
4623 /// designators, or GNU array-range designators) followed by an
4624 /// expression that initializes the field or element(s) that the
4625 /// designators refer to. For example, given:
4626 ///
4627 /// @code
4628 /// struct point {
4629 /// double x;
4630 /// double y;
4631 /// };
4632 /// struct point ptarray[10] = { [2].y = 1.0, [2].x = 2.0, [0].x = 1.0 };
4633 /// @endcode
4634 ///
4635 /// The InitListExpr contains three DesignatedInitExprs, the first of
4636 /// which covers @c [2].y=1.0. This DesignatedInitExpr will have two
4637 /// designators, one array designator for @c [2] followed by one field
4638 /// designator for @c .y. The initialization expression will be 1.0.
4640  : public Expr,
4641  private llvm::TrailingObjects<DesignatedInitExpr, Stmt *> {
4642 public:
4643  /// Forward declaration of the Designator class.
4644  class Designator;
4645 
4646 private:
4647  /// The location of the '=' or ':' prior to the actual initializer
4648  /// expression.
4649  SourceLocation EqualOrColonLoc;
4650 
4651  /// Whether this designated initializer used the GNU deprecated
4652  /// syntax rather than the C99 '=' syntax.
4653  unsigned GNUSyntax : 1;
4654 
4655  /// The number of designators in this initializer expression.
4656  unsigned NumDesignators : 15;
4657 
4658  /// The number of subexpressions of this initializer expression,
4659  /// which contains both the initializer and any additional
4660  /// expressions used by array and array-range designators.
4661  unsigned NumSubExprs : 16;
4662 
4663  /// The designators in this designated initialization
4664  /// expression.
4665  Designator *Designators;
4666 
4668  llvm::ArrayRef<Designator> Designators,
4669  SourceLocation EqualOrColonLoc, bool GNUSyntax,
4670  ArrayRef<Expr *> IndexExprs, Expr *Init);
4671 
4672  explicit DesignatedInitExpr(unsigned NumSubExprs)
4673  : Expr(DesignatedInitExprClass, EmptyShell()),
4674  NumDesignators(0), NumSubExprs(NumSubExprs), Designators(nullptr) { }
4675 
4676 public:
4677  /// A field designator, e.g., ".x".
4679  /// Refers to the field that is being initialized. The low bit
4680  /// of this field determines whether this is actually a pointer
4681  /// to an IdentifierInfo (if 1) or a FieldDecl (if 0). When
4682  /// initially constructed, a field designator will store an
4683  /// IdentifierInfo*. After semantic analysis has resolved that
4684  /// name, the field designator will instead store a FieldDecl*.
4686 
4687  /// The location of the '.' in the designated initializer.
4688  unsigned DotLoc;
4689 
4690  /// The location of the field name in the designated initializer.
4691  unsigned FieldLoc;
4692  };
4693 
4694  /// An array or GNU array-range designator, e.g., "[9]" or "[10..15]".
4696  /// Location of the first index expression within the designated
4697  /// initializer expression's list of subexpressions.
4698  unsigned Index;
4699  /// The location of the '[' starting the array range designator.
4700  unsigned LBracketLoc;
4701  /// The location of the ellipsis separating the start and end
4702  /// indices. Only valid for GNU array-range designators.
4703  unsigned EllipsisLoc;
4704  /// The location of the ']' terminating the array range designator.
4705  unsigned RBracketLoc;
4706  };
4707 
4708  /// Represents a single C99 designator.
4709  ///
4710  /// @todo This class is infuriatingly similar to clang::Designator,
4711  /// but minor differences (storing indices vs. storing pointers)
4712  /// keep us from reusing it. Try harder, later, to rectify these
4713  /// differences.
4714  class Designator {
4715  /// The kind of designator this describes.
4716  enum {
4718  ArrayDesignator,
4719  ArrayRangeDesignator
4720  } Kind;
4721 
4722  union {
4723  /// A field designator, e.g., ".x".
4725  /// An array or GNU array-range designator, e.g., "[9]" or "[10..15]".
4726  struct ArrayOrRangeDesignator ArrayOrRange;
4727  };
4728  friend class DesignatedInitExpr;
4729 
4730  public:
4732 
4733  /// Initializes a field designator.
4734  Designator(const IdentifierInfo *FieldName, SourceLocation DotLoc,
4735  SourceLocation FieldLoc)
4736  : Kind(FieldDesignator) {
4737  Field.NameOrField = reinterpret_cast<uintptr_t>(FieldName) | 0x01;
4738  Field.DotLoc = DotLoc.getRawEncoding();
4739  Field.FieldLoc = FieldLoc.getRawEncoding();
4740  }
4741 
4742  /// Initializes an array designator.
4743  Designator(unsigned Index, SourceLocation LBracketLoc,
4744  SourceLocation RBracketLoc)
4745  : Kind(ArrayDesignator) {
4746  ArrayOrRange.Index = Index;
4747  ArrayOrRange.LBracketLoc = LBracketLoc.getRawEncoding();
4748  ArrayOrRange.EllipsisLoc = SourceLocation().getRawEncoding();
4749  ArrayOrRange.RBracketLoc = RBracketLoc.getRawEncoding();
4750  }
4751 
4752  /// Initializes a GNU array-range designator.
4753  Designator(unsigned Index, SourceLocation LBracketLoc,
4754  SourceLocation EllipsisLoc, SourceLocation RBracketLoc)
4755  : Kind(ArrayRangeDesignator) {
4756  ArrayOrRange.Index = Index;
4757  ArrayOrRange.LBracketLoc = LBracketLoc.getRawEncoding();
4758  ArrayOrRange.EllipsisLoc = EllipsisLoc.getRawEncoding();
4759  ArrayOrRange.RBracketLoc = RBracketLoc.getRawEncoding();
4760  }
4761 
4762  bool isFieldDesignator() const { return Kind == FieldDesignator; }
4763  bool isArrayDesignator() const { return Kind == ArrayDesignator; }
4764  bool isArrayRangeDesignator() const { return Kind == ArrayRangeDesignator; }
4765 
4766  IdentifierInfo *getFieldName() const;
4767 
4768  FieldDecl *getField() const {
4769  assert(Kind == FieldDesignator && "Only valid on a field designator");
4770  if (Field.NameOrField & 0x01)
4771  return nullptr;
4772  else
4773  return reinterpret_cast<FieldDecl *>(Field.NameOrField);
4774  }
4775 
4776  void setField(FieldDecl *FD) {
4777  assert(Kind == FieldDesignator && "Only valid on a field designator");
4778  Field.NameOrField = reinterpret_cast<uintptr_t>(FD);
4779  }
4780 
4782  assert(Kind == FieldDesignator && "Only valid on a field designator");
4784  }
4785 
4787  assert(Kind == FieldDesignator && "Only valid on a field designator");
4788  return SourceLocation::getFromRawEncoding(Field.FieldLoc);
4789  }
4790 
4792  assert((Kind == ArrayDesignator || Kind == ArrayRangeDesignator) &&
4793  "Only valid on an array or array-range designator");
4794  return SourceLocation::getFromRawEncoding(ArrayOrRange.LBracketLoc);
4795  }
4796 
4798  assert((Kind == ArrayDesignator || Kind == ArrayRangeDesignator) &&
4799  "Only valid on an array or array-range designator");
4800  return SourceLocation::getFromRawEncoding(ArrayOrRange.RBracketLoc);
4801  }
4802 
4804  assert(Kind == ArrayRangeDesignator &&
4805  "Only valid on an array-range designator");
4806  return SourceLocation::getFromRawEncoding(ArrayOrRange.EllipsisLoc);
4807  }
4808 
4809  unsigned getFirstExprIndex() const {
4810  assert((Kind == ArrayDesignator || Kind == ArrayRangeDesignator) &&
4811  "Only valid on an array or array-range designator");
4812  return ArrayOrRange.Index;
4813  }
4814 
4815  SourceLocation getBeginLoc() const LLVM_READONLY {
4816  if (Kind == FieldDesignator)
4817  return getDotLoc().isInvalid()? getFieldLoc() : getDotLoc();
4818  else
4819  return getLBracketLoc();
4820  }
4821  SourceLocation getEndLoc() const LLVM_READONLY {
4822  return Kind == FieldDesignator ? getFieldLoc() : getRBracketLoc();
4823  }
4824  SourceRange getSourceRange() const LLVM_READONLY {
4825  return SourceRange(getBeginLoc(), getEndLoc());
4826  }
4827  };
4828 
4829  static DesignatedInitExpr *Create(const ASTContext &C,
4830  llvm::ArrayRef<Designator> Designators,
4831  ArrayRef<Expr*> IndexExprs,
4832  SourceLocation EqualOrColonLoc,
4833  bool GNUSyntax, Expr *Init);
4834 
4835  static DesignatedInitExpr *CreateEmpty(const ASTContext &C,
4836  unsigned NumIndexExprs);
4837 
4838  /// Returns the number of designators in this initializer.
4839  unsigned size() const { return NumDesignators; }
4840 
4841  // Iterator access to the designators.
4843  return {Designators, NumDesignators};
4844  }
4845 
4847  return {Designators, NumDesignators};
4848  }
4849 
4850  Designator *getDesignator(unsigned Idx) { return &designators()[Idx]; }
4851  const Designator *getDesignator(unsigned Idx) const {
4852  return &designators()[Idx];
4853  }
4854 
4855  void setDesignators(const ASTContext &C, const Designator *Desigs,
4856  unsigned NumDesigs);
4857 
4858  Expr *getArrayIndex(const Designator &D) const;
4859  Expr *getArrayRangeStart(const Designator &D) const;
4860  Expr *getArrayRangeEnd(const Designator &D) const;
4861 
4862  /// Retrieve the location of the '=' that precedes the
4863  /// initializer value itself, if present.
4864  SourceLocation getEqualOrColonLoc() const { return EqualOrColonLoc; }
4865  void setEqualOrColonLoc(SourceLocation L) { EqualOrColonLoc = L; }
4866 
4867  /// Whether this designated initializer should result in direct-initialization
4868  /// of the designated subobject (eg, '{.foo{1, 2, 3}}').
4869  bool isDirectInit() const { return EqualOrColonLoc.isInvalid(); }
4870 
4871  /// Determines whether this designated initializer used the
4872  /// deprecated GNU syntax for designated initializers.
4873  bool usesGNUSyntax() const { return GNUSyntax; }
4874  void setGNUSyntax(bool GNU) { GNUSyntax = GNU; }
4875 
4876  /// Retrieve the initializer value.
4877  Expr *getInit() const {
4878  return cast<Expr>(*const_cast<DesignatedInitExpr*>(this)->child_begin());
4879  }
4880 
4881  void setInit(Expr *init) {
4882  *child_begin() = init;
4883  }
4884 
4885  /// Retrieve the total number of subexpressions in this
4886  /// designated initializer expression, including the actual
4887  /// initialized value and any expressions that occur within array
4888  /// and array-range designators.
4889  unsigned getNumSubExprs() const { return NumSubExprs; }
4890 
4891  Expr *getSubExpr(unsigned Idx) const {
4892  assert(Idx < NumSubExprs && "Subscript out of range");
4893  return cast<Expr>(getTrailingObjects<Stmt *>()[Idx]);
4894  }
4895 
4896  void setSubExpr(unsigned Idx, Expr *E) {
4897  assert(Idx < NumSubExprs && "Subscript out of range");
4898  getTrailingObjects<Stmt *>()[Idx] = E;
4899  }
4900 
4901  /// Replaces the designator at index @p Idx with the series
4902  /// of designators in [First, Last).
4903  void ExpandDesignator(const ASTContext &C, unsigned Idx,
4904  const Designator *First, const Designator *Last);
4905 
4906  SourceRange getDesignatorsSourceRange() const;
4907 
4908  SourceLocation getBeginLoc() const LLVM_READONLY;
4909  SourceLocation getEndLoc() const LLVM_READONLY;
4910 
4911  static bool classof(const Stmt *T) {
4912  return T->getStmtClass() == DesignatedInitExprClass;
4913  }
4914 
4915  // Iterators
4917  Stmt **begin = getTrailingObjects<Stmt *>();
4918  return child_range(begin, begin + NumSubExprs);
4919  }
4921  Stmt * const *begin = getTrailingObjects<Stmt *>();
4922  return const_child_range(begin, begin + NumSubExprs);
4923  }
4924 
4926 };
4927 
4928 /// Represents a place-holder for an object not to be initialized by
4929 /// anything.
4930 ///
4931 /// This only makes sense when it appears as part of an updater of a
4932 /// DesignatedInitUpdateExpr (see below). The base expression of a DIUE
4933 /// initializes a big object, and the NoInitExpr's mark the spots within the
4934 /// big object not to be overwritten by the updater.
4935 ///
4936 /// \see DesignatedInitUpdateExpr
4937 class NoInitExpr : public Expr {
4938 public:
4939  explicit NoInitExpr(QualType ty)
4940  : Expr(NoInitExprClass, ty, VK_RValue, OK_Ordinary,
4941  false, false, ty->isInstantiationDependentType(), false) { }
4942 
4943  explicit NoInitExpr(EmptyShell Empty)
4944  : Expr(NoInitExprClass, Empty) { }
4945 
4946  static bool classof(const Stmt *T) {
4947  return T->getStmtClass() == NoInitExprClass;
4948  }
4949 
4950  SourceLocation getBeginLoc() const LLVM_READONLY { return SourceLocation(); }
4951  SourceLocation getEndLoc() const LLVM_READONLY { return SourceLocation(); }
4952 
4953  // Iterators
4956  }
4959  }
4960 };
4961 
4962 // In cases like:
4963 // struct Q { int a, b, c; };
4964 // Q *getQ();
4965 // void foo() {
4966 // struct A { Q q; } a = { *getQ(), .q.b = 3 };
4967 // }
4968 //
4969 // We will have an InitListExpr for a, with type A, and then a
4970 // DesignatedInitUpdateExpr for "a.q" with type Q. The "base" for this DIUE
4971 // is the call expression *getQ(); the "updater" for the DIUE is ".q.b = 3"
4972 //
4974  // BaseAndUpdaterExprs[0] is the base expression;
4975  // BaseAndUpdaterExprs[1] is an InitListExpr overwriting part of the base.
4976  Stmt *BaseAndUpdaterExprs[2];
4977 
4978 public:
4980  Expr *baseExprs, SourceLocation rBraceLoc);
4981 
4983  : Expr(DesignatedInitUpdateExprClass, Empty) { }
4984 
4985  SourceLocation getBeginLoc() const LLVM_READONLY;
4986  SourceLocation getEndLoc() const LLVM_READONLY;
4987 
4988  static bool classof(const Stmt *T) {
4989  return T->getStmtClass() == DesignatedInitUpdateExprClass;
4990  }
4991 
4992  Expr *getBase() const { return cast<Expr>(BaseAndUpdaterExprs[0]); }
4993  void setBase(Expr *Base) { BaseAndUpdaterExprs[0] = Base; }
4994 
4996  return cast<InitListExpr>(BaseAndUpdaterExprs[1]);
4997  }
4998  void setUpdater(Expr *Updater) { BaseAndUpdaterExprs[1] = Updater; }
4999 
5000  // Iterators
5001  // children = the base and the updater
5003  return child_range(&BaseAndUpdaterExprs[0], &BaseAndUpdaterExprs[0] + 2);
5004  }
5006  return const_child_range(&BaseAndUpdaterExprs[0],
5007  &BaseAndUpdaterExprs[0] + 2);
5008  }
5009 };
5010 
5011 /// Represents a loop initializing the elements of an array.
5012 ///
5013 /// The need to initialize the elements of an array occurs in a number of
5014 /// contexts:
5015 ///
5016 /// * in the implicit copy/move constructor for a class with an array member
5017 /// * when a lambda-expression captures an array by value
5018 /// * when a decomposition declaration decomposes an array
5019 ///
5020 /// There are two subexpressions: a common expression (the source array)
5021 /// that is evaluated once up-front, and a per-element initializer that
5022 /// runs once for each array element.
5023 ///
5024 /// Within the per-element initializer, the common expression may be referenced
5025 /// via an OpaqueValueExpr, and the current index may be obtained via an
5026 /// ArrayInitIndexExpr.
5027 class ArrayInitLoopExpr : public Expr {
5028  Stmt *SubExprs[2];
5029 
5030  explicit ArrayInitLoopExpr(EmptyShell Empty)
5031  : Expr(ArrayInitLoopExprClass, Empty), SubExprs{} {}
5032 
5033 public:
5034  explicit ArrayInitLoopExpr(QualType T, Expr *CommonInit, Expr *ElementInit)
5035  : Expr(ArrayInitLoopExprClass, T, VK_RValue, OK_Ordinary, false,
5036  CommonInit->isValueDependent() || ElementInit->isValueDependent(),
5037  T->isInstantiationDependentType(),
5038  CommonInit->containsUnexpandedParameterPack() ||
5039  ElementInit->containsUnexpandedParameterPack()),
5040  SubExprs{CommonInit, ElementInit} {}
5041 
5042  /// Get the common subexpression shared by all initializations (the source
5043  /// array).
5045  return cast<OpaqueValueExpr>(SubExprs[0]);
5046  }
5047 
5048  /// Get the initializer to use for each array element.
5049  Expr *getSubExpr() const { return cast<Expr>(SubExprs[1]); }
5050 
5052  return cast<ConstantArrayType>(getType()->castAsArrayTypeUnsafe())
5053  ->getSize();
5054  }
5055 
5056  static bool classof(const Stmt *S) {
5057  return S->getStmtClass() == ArrayInitLoopExprClass;
5058  }
5059 
5060  SourceLocation getBeginLoc() const LLVM_READONLY {
5061  return getCommonExpr()->getBeginLoc();
5062  }
5063  SourceLocation getEndLoc() const LLVM_READONLY {
5064  return getCommonExpr()->getEndLoc();
5065  }
5066 
5068  return child_range(SubExprs, SubExprs + 2);
5069  }
5071  return const_child_range(SubExprs, SubExprs + 2);
5072  }
5073 
5074  friend class ASTReader;
5075  friend class ASTStmtReader;
5076  friend class ASTStmtWriter;
5077 };
5078 
5079 /// Represents the index of the current element of an array being
5080 /// initialized by an ArrayInitLoopExpr. This can only appear within the
5081 /// subexpression of an ArrayInitLoopExpr.
5082 class ArrayInitIndexExpr : public Expr {
5083  explicit ArrayInitIndexExpr(EmptyShell Empty)
5084  : Expr(ArrayInitIndexExprClass, Empty) {}
5085 
5086 public:
5088  : Expr(ArrayInitIndexExprClass, T, VK_RValue, OK_Ordinary,
5089  false, false, false, false) {}
5090 
5091  static bool classof(const Stmt *S) {
5092  return S->getStmtClass() == ArrayInitIndexExprClass;
5093  }
5094 
5095  SourceLocation getBeginLoc() const LLVM_READONLY { return SourceLocation(); }
5096  SourceLocation getEndLoc() const LLVM_READONLY { return SourceLocation(); }
5097 
5100  }
5103  }
5104 
5105  friend class ASTReader;
5106  friend class ASTStmtReader;
5107 };
5108 
5109 /// Represents an implicitly-generated value initialization of
5110 /// an object of a given type.
5111 ///
5112 /// Implicit value initializations occur within semantic initializer
5113 /// list expressions (InitListExpr) as placeholders for subobject
5114 /// initializations not explicitly specified by the user.
5115 ///
5116 /// \see InitListExpr
5117 class ImplicitValueInitExpr : public Expr {
5118 public:
5120  : Expr(ImplicitValueInitExprClass, ty, VK_RValue, OK_Ordinary,
5121  false, false, ty->isInstantiationDependentType(), false) { }
5122 
5123  /// Construct an empty implicit value initialization.
5125  : Expr(ImplicitValueInitExprClass, Empty) { }
5126 
5127  static bool classof(const Stmt *T) {
5128  return T->getStmtClass() == ImplicitValueInitExprClass;
5129  }
5130 
5131  SourceLocation getBeginLoc() const LLVM_READONLY { return SourceLocation(); }
5132  SourceLocation getEndLoc() const LLVM_READONLY { return SourceLocation(); }
5133 
5134  // Iterators
5137  }
5140  }
5141 };
5142 
5143 class ParenListExpr final
5144  : public Expr,
5145  private llvm::TrailingObjects<ParenListExpr, Stmt *> {
5146  friend class ASTStmtReader;
5147  friend TrailingObjects;
5148 
5149  /// The location of the left and right parentheses.
5150  SourceLocation LParenLoc, RParenLoc;
5151 
5152  /// Build a paren list.
5154  SourceLocation RParenLoc);
5155 
5156  /// Build an empty paren list.
5157  ParenListExpr(EmptyShell Empty, unsigned NumExprs);
5158 
5159 public:
5160  /// Create a paren list.
5161  static ParenListExpr *Create(const ASTContext &Ctx, SourceLocation LParenLoc,
5162  ArrayRef<Expr *> Exprs,
5163  SourceLocation RParenLoc);
5164 
5165  /// Create an empty paren list.
5166  static ParenListExpr *CreateEmpty(const ASTContext &Ctx, unsigned NumExprs);
5167 
5168  /// Return the number of expressions in this paren list.
5169  unsigned getNumExprs() const { return ParenListExprBits.NumExprs; }
5170 
5171  Expr *getExpr(unsigned Init) {
5172  assert(Init < getNumExprs() && "Initializer access out of range!");
5173  return getExprs()[Init];
5174  }
5175 
5176  const Expr *getExpr(unsigned Init) const {
5177  return const_cast<ParenListExpr *>(this)->getExpr(Init);
5178  }
5179 
5181  return reinterpret_cast<Expr **>(getTrailingObjects<Stmt *>());
5182  }
5183 
5185  return llvm::makeArrayRef(getExprs(), getNumExprs());
5186  }
5187 
5188  SourceLocation getLParenLoc() const { return LParenLoc; }
5189  SourceLocation getRParenLoc() const { return RParenLoc; }
5190  SourceLocation getBeginLoc() const { return getLParenLoc(); }
5191  SourceLocation getEndLoc() const { return getRParenLoc(); }
5192 
5193  static bool classof(const Stmt *T) {
5194  return T->getStmtClass() == ParenListExprClass;
5195  }
5196 
5197  // Iterators
5199  return child_range(getTrailingObjects<Stmt *>(),
5200  getTrailingObjects<Stmt *>() + getNumExprs());
5201  }
5203  return const_child_range(getTrailingObjects<Stmt *>(),
5204  getTrailingObjects<Stmt *>() + getNumExprs());
5205  }
5206 };
5207 
5208 /// Represents a C11 generic selection.
5209 ///
5210 /// A generic selection (C11 6.5.1.1) contains an unevaluated controlling
5211 /// expression, followed by one or more generic associations. Each generic
5212 /// association specifies a type name and an expression, or "default" and an
5213 /// expression (in which case it is known as a default generic association).
5214 /// The type and value of the generic selection are identical to those of its
5215 /// result expression, which is defined as the expression in the generic
5216 /// association with a type name that is compatible with the type of the
5217 /// controlling expression, or the expression in the default generic association
5218 /// if no types are compatible. For example:
5219 ///
5220 /// @code
5221 /// _Generic(X, double: 1, float: 2, default: 3)
5222 /// @endcode
5223 ///
5224 /// The above expression evaluates to 1 if 1.0 is substituted for X, 2 if 1.0f
5225 /// or 3 if "hello".
5226 ///
5227 /// As an extension, generic selections are allowed in C++, where the following
5228 /// additional semantics apply:
5229 ///
5230 /// Any generic selection whose controlling expression is type-dependent or
5231 /// which names a dependent type in its association list is result-dependent,
5232 /// which means that the choice of result expression is dependent.
5233 /// Result-dependent generic associations are both type- and value-dependent.
5235  : public Expr,
5236  private llvm::TrailingObjects<GenericSelectionExpr, Stmt *,
5237  TypeSourceInfo *> {
5238  friend class ASTStmtReader;
5239  friend class ASTStmtWriter;
5240  friend TrailingObjects;
5241 
5242  /// The number of association expressions and the index of the result
5243  /// expression in the case where the generic selection expression is not
5244  /// result-dependent. The result index is equal to ResultDependentIndex
5245  /// if and only if the generic selection expression is result-dependent.
5246  unsigned NumAssocs, ResultIndex;
5247  enum : unsigned {
5248  ResultDependentIndex = std::numeric_limits<unsigned>::max(),
5249  ControllingIndex = 0,
5250  AssocExprStartIndex = 1
5251  };
5252 
5253  /// The location of the "default" and of the right parenthesis.
5254  SourceLocation DefaultLoc, RParenLoc;
5255 
5256  // GenericSelectionExpr is followed by several trailing objects.
5257  // They are (in order):
5258  //
5259  // * A single Stmt * for the controlling expression.
5260  // * An array of getNumAssocs() Stmt * for the association expressions.
5261  // * An array of getNumAssocs() TypeSourceInfo *, one for each of the
5262  // association expressions.
5263  unsigned numTrailingObjects(OverloadToken<Stmt *>) const {
5264  // Add one to account for the controlling expression; the remainder
5265  // are the associated expressions.
5266  return 1 + getNumAssocs();
5267  }
5268 
5269  unsigned numTrailingObjects(OverloadToken<TypeSourceInfo *>) const {
5270  return getNumAssocs();
5271  }
5272 
5273  template <bool Const> class AssociationIteratorTy;
5274  /// Bundle together an association expression and its TypeSourceInfo.
5275  /// The Const template parameter is for the const and non-const versions
5276  /// of AssociationTy.
5277  template <bool Const> class AssociationTy {
5278  friend class GenericSelectionExpr;
5279  template <bool OtherConst> friend class AssociationIteratorTy;
5280  using ExprPtrTy =
5282  using TSIPtrTy = typename std::conditional<Const, const TypeSourceInfo *,
5283  TypeSourceInfo *>::type;
5284  ExprPtrTy E;
5285  TSIPtrTy TSI;
5286  bool Selected;
5287  AssociationTy(ExprPtrTy E, TSIPtrTy TSI, bool Selected)
5288  : E(E), TSI(TSI), Selected(Selected) {}
5289 
5290  public:
5291  ExprPtrTy getAssociationExpr() const { return E; }
5292  TSIPtrTy getTypeSourceInfo() const { return TSI; }
5293  QualType getType() const { return TSI ? TSI->getType() : QualType(); }
5294  bool isSelected() const { return Selected; }
5295  AssociationTy *operator->() { return this; }
5296  const AssociationTy *operator->() const { return this; }
5297  }; // class AssociationTy
5298 
5299  /// Iterator over const and non-const Association objects. The Association
5300  /// objects are created on the fly when the iterator is dereferenced.
5301  /// This abstract over how exactly the association expressions and the
5302  /// corresponding TypeSourceInfo * are stored.
5303  template <bool Const>
5304  class AssociationIteratorTy
5305  : public llvm::iterator_facade_base<
5306  AssociationIteratorTy<Const>, std::input_iterator_tag,
5307  AssociationTy<Const>, std::ptrdiff_t, AssociationTy<Const>,
5308  AssociationTy<Const>> {
5309  friend class GenericSelectionExpr;
5310  // FIXME: This iterator could conceptually be a random access iterator, and
5311  // it would be nice if we could strengthen the iterator category someday.
5312  // However this iterator does not satisfy two requirements of forward
5313  // iterators:
5314  // a) reference = T& or reference = const T&
5315  // b) If It1 and It2 are both dereferenceable, then It1 == It2 if and only
5316  // if *It1 and *It2 are bound to the same objects.
5317  // An alternative design approach was discussed during review;
5318  // store an Association object inside the iterator, and return a reference
5319  // to it when dereferenced. This idea was discarded beacuse of nasty
5320  // lifetime issues:
5321  // AssociationIterator It = ...;
5322  // const Association &Assoc = *It++; // Oops, Assoc is dangling.
5323  using BaseTy = typename AssociationIteratorTy::iterator_facade_base;
5324  using StmtPtrPtrTy =
5326  using TSIPtrPtrTy =
5327  typename std::conditional<Const, const TypeSourceInfo *const *,
5328  TypeSourceInfo **>::type;
5329  StmtPtrPtrTy E; // = nullptr; FIXME: Once support for gcc 4.8 is dropped.
5330  TSIPtrPtrTy TSI; // Kept in sync with E.
5331  unsigned Offset = 0, SelectedOffset = 0;
5332  AssociationIteratorTy(StmtPtrPtrTy E, TSIPtrPtrTy TSI, unsigned Offset,
5333  unsigned SelectedOffset)
5334  : E(E), TSI(TSI), Offset(Offset), SelectedOffset(SelectedOffset) {}
5335 
5336  public:
5337  AssociationIteratorTy() : E(nullptr), TSI(nullptr) {}
5338  typename BaseTy::reference operator*() const {
5339  return AssociationTy<Const>(cast<Expr>(*E), *TSI,
5340  Offset == SelectedOffset);
5341  }
5342  typename BaseTy::pointer operator->() const { return **this; }
5343  using BaseTy::operator++;
5344  AssociationIteratorTy &operator++() {
5345  ++E;
5346  ++TSI;
5347  ++Offset;
5348  return *this;
5349  }
5350  bool operator==(AssociationIteratorTy Other) const { return E == Other.E; }
5351  }; // class AssociationIterator
5352 
5353  /// Build a non-result-dependent generic selection expression.
5354  GenericSelectionExpr(const ASTContext &Context, SourceLocation GenericLoc,
5355  Expr *ControllingExpr,
5356  ArrayRef<TypeSourceInfo *> AssocTypes,
5357  ArrayRef<Expr *> AssocExprs, SourceLocation DefaultLoc,
5358  SourceLocation RParenLoc,
5359  bool ContainsUnexpandedParameterPack,
5360  unsigned ResultIndex);
5361 
5362  /// Build a result-dependent generic selection expression.
5363  GenericSelectionExpr(const ASTContext &Context, SourceLocation GenericLoc,
5364  Expr *ControllingExpr,
5365  ArrayRef<TypeSourceInfo *> AssocTypes,
5366  ArrayRef<Expr *> AssocExprs, SourceLocation DefaultLoc,
5367  SourceLocation RParenLoc,
5368  bool ContainsUnexpandedParameterPack);
5369 
5370  /// Build an empty generic selection expression for deserialization.
5371  explicit GenericSelectionExpr(EmptyShell Empty, unsigned NumAssocs);
5372 
5373 public:
5374  /// Create a non-result-dependent generic selection expression.
5375  static GenericSelectionExpr *
5376  Create(const ASTContext &Context, SourceLocation GenericLoc,
5377  Expr *ControllingExpr, ArrayRef<TypeSourceInfo *> AssocTypes,
5378  ArrayRef<Expr *> AssocExprs, SourceLocation DefaultLoc,
5379  SourceLocation RParenLoc, bool ContainsUnexpandedParameterPack,
5380  unsigned ResultIndex);
5381 
5382  /// Create a result-dependent generic selection expression.
5383  static GenericSelectionExpr *
5384  Create(const ASTContext &Context, SourceLocation GenericLoc,
5385  Expr *ControllingExpr, ArrayRef<TypeSourceInfo *> AssocTypes,
5386  ArrayRef<Expr *> AssocExprs, SourceLocation DefaultLoc,
5387  SourceLocation RParenLoc, bool ContainsUnexpandedParameterPack);
5388 
5389  /// Create an empty generic selection expression for deserialization.
5390  static GenericSelectionExpr *CreateEmpty(const ASTContext &Context,
5391  unsigned NumAssocs);
5392 
5393  using Association = AssociationTy<false>;
5394  using ConstAssociation = AssociationTy<true>;
5395  using AssociationIterator = AssociationIteratorTy<false>;
5396  using ConstAssociationIterator = AssociationIteratorTy<true>;
5397  using association_range = llvm::iterator_range<AssociationIterator>;
5398  using const_association_range =
5399  llvm::iterator_range<ConstAssociationIterator>;
5400 
5401  /// The number of association expressions.
5402  unsigned getNumAssocs() const { return NumAssocs; }
5403 
5404  /// The zero-based index of the result expression's generic association in
5405  /// the generic selection's association list. Defined only if the
5406  /// generic selection is not result-dependent.
5407  unsigned getResultIndex() const {
5408  assert(!isResultDependent() &&
5409  "Generic selection is result-dependent but getResultIndex called!");
5410  return ResultIndex;
5411  }
5412 
5413  /// Whether this generic selection is result-dependent.
5414  bool isResultDependent() const { return ResultIndex == ResultDependentIndex; }
5415 
5416  /// Return the controlling expression of this generic selection expression.
5418  return cast<Expr>(getTrailingObjects<Stmt *>()[ControllingIndex]);
5419  }
5420  const Expr *getControllingExpr() const {
5421  return cast<Expr>(getTrailingObjects<Stmt *>()[ControllingIndex]);
5422  }
5423 
5424  /// Return the result expression of this controlling expression. Defined if
5425  /// and only if the generic selection expression is not result-dependent.
5427  return cast<Expr>(
5428  getTrailingObjects<Stmt *>()[AssocExprStartIndex + getResultIndex()]);
5429  }
5430  const Expr *getResultExpr() const {
5431  return cast<Expr>(
5432  getTrailingObjects<Stmt *>()[AssocExprStartIndex + getResultIndex()]);
5433  }
5434 
5436  return {reinterpret_cast<Expr *const *>(getTrailingObjects<Stmt *>() +
5437  AssocExprStartIndex),
5438  NumAssocs};
5439  }
5441  return {getTrailingObjects<TypeSourceInfo *>(), NumAssocs};
5442  }
5443 
5444  /// Return the Ith association expression with its TypeSourceInfo,
5445  /// bundled together in GenericSelectionExpr::(Const)Association.
5447  assert(I < getNumAssocs() &&
5448  "Out-of-range index in GenericSelectionExpr::getAssociation!");
5449  return Association(
5450  cast<Expr>(getTrailingObjects<Stmt *>()[AssocExprStartIndex + I]),
5451  getTrailingObjects<TypeSourceInfo *>()[I],
5452  !isResultDependent() && (getResultIndex() == I));
5453  }
5454  ConstAssociation getAssociation(unsigned I) const {
5455  assert(I < getNumAssocs() &&
5456  "Out-of-range index in GenericSelectionExpr::getAssociation!");
5457  return ConstAssociation(
5458  cast<Expr>(getTrailingObjects<Stmt *>()[AssocExprStartIndex + I]),
5459  getTrailingObjects<TypeSourceInfo *>()[I],
5460  !isResultDependent() && (getResultIndex() == I));
5461  }
5462 
5464  AssociationIterator Begin(getTrailingObjects<Stmt *>() +
5465  AssocExprStartIndex,
5466  getTrailingObjects<TypeSourceInfo *>(),
5467  /*Offset=*/0, ResultIndex);
5468  AssociationIterator End(Begin.E + NumAssocs, Begin.TSI + NumAssocs,
5469  /*Offset=*/NumAssocs, ResultIndex);
5470  return llvm::make_range(Begin, End);
5471  }
5472 
5474  ConstAssociationIterator Begin(getTrailingObjects<Stmt *>() +
5475  AssocExprStartIndex,
5476  getTrailingObjects<TypeSourceInfo *>(),
5477  /*Offset=*/0, ResultIndex);
5478  ConstAssociationIterator End(Begin.E + NumAssocs, Begin.TSI + NumAssocs,
5479  /*Offset=*/NumAssocs, ResultIndex);
5480  return llvm::make_range(Begin, End);
5481  }
5482 
5484  return GenericSelectionExprBits.GenericLoc;
5485  }
5486  SourceLocation getDefaultLoc() const { return DefaultLoc; }
5487  SourceLocation getRParenLoc() const { return RParenLoc; }
5488  SourceLocation getBeginLoc() const { return getGenericLoc(); }
5489  SourceLocation getEndLoc() const { return getRParenLoc(); }
5490 
5491  static bool classof(const Stmt *T) {
5492  return T->getStmtClass() == GenericSelectionExprClass;
5493  }
5494 
5496  return child_range(getTrailingObjects<Stmt *>(),
5497  getTrailingObjects<Stmt *>() +
5498  numTrailingObjects(OverloadToken<Stmt *>()));
5499  }
5501  return const_child_range(getTrailingObjects<Stmt *>(),
5502  getTrailingObjects<Stmt *>() +
5503  numTrailingObjects(OverloadToken<Stmt *>()));
5504  }
5505 };
5506 
5507 //===----------------------------------------------------------------------===//
5508 // Clang Extensions
5509 //===----------------------------------------------------------------------===//
5510 
5511 /// ExtVectorElementExpr - This represents access to specific elements of a
5512 /// vector, and may occur on the left hand side or right hand side. For example
5513 /// the following is legal: "V.xy = V.zw" if V is a 4 element extended vector.
5514 ///
5515 /// Note that the base may have either vector or pointer to vector type, just
5516 /// like a struct field reference.
5517 ///
5518 class ExtVectorElementExpr : public Expr {
5519  Stmt *Base;
5520  IdentifierInfo *Accessor;
5521  SourceLocation AccessorLoc;
5522 public:
5524  IdentifierInfo &accessor, SourceLocation loc)
5525  : Expr(ExtVectorElementExprClass, ty, VK,
5527  base->isTypeDependent(), base->isValueDependent(),
5528  base->isInstantiationDependent(),
5529  base->containsUnexpandedParameterPack()),
5530  Base(base), Accessor(&accessor), AccessorLoc(loc) {}
5531 
5532  /// Build an empty vector element expression.
5534  : Expr(ExtVectorElementExprClass, Empty) { }
5535 
5536  const Expr *getBase() const { return cast<Expr>(Base); }
5537  Expr *getBase() { return cast<Expr>(Base); }
5538  void setBase(Expr *E) { Base = E; }
5539 
5540  IdentifierInfo &getAccessor() const { return *Accessor; }
5541  void setAccessor(IdentifierInfo *II) { Accessor = II; }
5542 
5543  SourceLocation getAccessorLoc() const { return AccessorLoc; }
5544  void setAccessorLoc(SourceLocation L) { AccessorLoc = L; }
5545 
5546  /// getNumElements - Get the number of components being selected.
5547  unsigned getNumElements() const;
5548 
5549  /// containsDuplicateElements - Return true if any element access is
5550  /// repeated.
5551  bool containsDuplicateElements() const;
5552 
5553  /// getEncodedElementAccess - Encode the elements accessed into an llvm
5554  /// aggregate Constant of ConstantInt(s).
5555  void getEncodedElementAccess(SmallVectorImpl<uint32_t> &Elts) const;
5556 
5557  SourceLocation getBeginLoc() const LLVM_READONLY {
5558  return getBase()->getBeginLoc();
5559  }
5560  SourceLocation getEndLoc() const LLVM_READONLY { return AccessorLoc; }
5561 
5562  /// isArrow - Return true if the base expression is a pointer to vector,
5563  /// return false if the base expression is a vector.
5564  bool isArrow() const;
5565 
5566  static bool classof(const Stmt *T) {
5567  return T->getStmtClass() == ExtVectorElementExprClass;
5568  }
5569 
5570  // Iterators
5571  child_range children() { return child_range(&Base, &Base+1); }
5573  return const_child_range(&Base, &Base + 1);
5574  }
5575 };
5576 
5577 /// BlockExpr - Adaptor class for mixing a BlockDecl with expressions.
5578 /// ^{ statement-body } or ^(int arg1, float arg2){ statement-body }
5579 class BlockExpr : public Expr {
5580 protected:
5582 public:
5584  : Expr(BlockExprClass, ty, VK_RValue, OK_Ordinary,
5585  ty->isDependentType(), ty->isDependentType(),
5586  ty->isInstantiationDependentType() || BD->isDependentContext(),
5587  false),
5588  TheBlock(BD) {}
5589 
5590  /// Build an empty block expression.
5591  explicit BlockExpr(EmptyShell Empty) : Expr(BlockExprClass, Empty) { }
5592 
5593  const BlockDecl *getBlockDecl() const { return TheBlock; }
5594  BlockDecl *getBlockDecl() { return TheBlock; }
5595  void setBlockDecl(BlockDecl *BD) { TheBlock = BD; }
5596 
5597  // Convenience functions for probing the underlying BlockDecl.
5598  SourceLocation getCaretLocation() const;
5599  const Stmt *getBody() const;
5600  Stmt *getBody();
5601 
5602  SourceLocation getBeginLoc() const LLVM_READONLY {
5603  return getCaretLocation();
5604  }
5605  SourceLocation getEndLoc() const LLVM_READONLY {
5606  return getBody()->getEndLoc();
5607  }
5608 
5609  /// getFunctionType - Return the underlying function type for this block.
5610  const FunctionProtoType *getFunctionType() const;
5611 
5612  static bool classof(const Stmt *T) {
5613  return T->getStmtClass() == BlockExprClass;
5614  }
5615 
5616  // Iterators
5619  }
5622  }
5623 };
5624 
5625 /// Copy initialization expr of a __block variable and a boolean flag that
5626 /// indicates whether the expression can throw.
5628  BlockVarCopyInit() = default;
5629  BlockVarCopyInit(Expr *CopyExpr, bool CanThrow)
5630  : ExprAndFlag(CopyExpr, CanThrow) {}
5631  void setExprAndFlag(Expr *CopyExpr, bool CanThrow) {
5632  ExprAndFlag.setPointerAndInt(CopyExpr, CanThrow);
5633  }
5634  Expr *getCopyExpr() const { return ExprAndFlag.getPointer(); }
5635  bool canThrow() const { return ExprAndFlag.getInt(); }
5636  llvm::PointerIntPair<Expr *, 1, bool> ExprAndFlag;
5637 };
5638 
5639 /// AsTypeExpr - Clang builtin function __builtin_astype [OpenCL 6.2.4.2]
5640 /// This AST node provides support for reinterpreting a type to another
5641 /// type of the same size.
5642 class AsTypeExpr : public Expr {
5643 private:
5644  Stmt *SrcExpr;
5645  SourceLocation BuiltinLoc, RParenLoc;
5646 
5647  friend class ASTReader;
5648  friend class ASTStmtReader;
5649  explicit AsTypeExpr(EmptyShell Empty) : Expr(AsTypeExprClass, Empty) {}
5650 
5651 public:
5652  AsTypeExpr(Expr* SrcExpr, QualType DstType,
5654  SourceLocation BuiltinLoc, SourceLocation RParenLoc)
5655  : Expr(AsTypeExprClass, DstType, VK, OK,
5656  DstType->isDependentType(),
5657  DstType->isDependentType() || SrcExpr->isValueDependent(),
5658  (DstType->isInstantiationDependentType() ||
5659  SrcExpr->isInstantiationDependent()),
5660  (DstType->containsUnexpandedParameterPack() ||
5661  SrcExpr->containsUnexpandedParameterPack())),
5662  SrcExpr(SrcExpr), BuiltinLoc(BuiltinLoc), RParenLoc(RParenLoc) {}
5663 
5664  /// getSrcExpr - Return the Expr to be converted.
5665  Expr *getSrcExpr() const { return cast<Expr>(SrcExpr); }
5666 
5667  /// getBuiltinLoc - Return the location of the __builtin_astype token.
5668  SourceLocation getBuiltinLoc() const { return BuiltinLoc; }
5669 
5670  /// getRParenLoc - Return the location of final right parenthesis.
5671  SourceLocation getRParenLoc() const { return RParenLoc; }
5672 
5673  SourceLocation getBeginLoc() const LLVM_READONLY { return BuiltinLoc; }
5674  SourceLocation getEndLoc() const LLVM_READONLY { return RParenLoc; }
5675 
5676  static bool classof(const Stmt *T) {
5677  return T->getStmtClass() == AsTypeExprClass;
5678  }
5679 
5680  // Iterators
5681  child_range children() { return child_range(&SrcExpr, &SrcExpr+1); }
5683  return const_child_range(&SrcExpr, &SrcExpr + 1);
5684  }
5685 };
5686 
5687 /// PseudoObjectExpr - An expression which accesses a pseudo-object
5688 /// l-value. A pseudo-object is an abstract object, accesses to which
5689 /// are translated to calls. The pseudo-object expression has a
5690 /// syntactic form, which shows how the expression was actually
5691 /// written in the source code, and a semantic form, which is a series
5692 /// of expressions to be executed in order which detail how the
5693 /// operation is actually evaluated. Optionally, one of the semantic
5694 /// forms may also provide a result value for the expression.
5695 ///
5696 /// If any of the semantic-form expressions is an OpaqueValueExpr,
5697 /// that OVE is required to have a source expression, and it is bound
5698 /// to the result of that source expression. Such OVEs may appear
5699 /// only in subsequent semantic-form expressions and as
5700 /// sub-expressions of the syntactic form.
5701 ///
5702 /// PseudoObjectExpr should be used only when an operation can be
5703 /// usefully described in terms of fairly simple rewrite rules on
5704 /// objects and functions that are meant to be used by end-developers.
5705 /// For example, under the Itanium ABI, dynamic casts are implemented
5706 /// as a call to a runtime function called __dynamic_cast; using this
5707 /// class to describe that would be inappropriate because that call is
5708 /// not really part of the user-visible semantics, and instead the
5709 /// cast is properly reflected in the AST and IR-generation has been
5710 /// taught to generate the call as necessary. In contrast, an
5711 /// Objective-C property access is semantically defined to be
5712 /// equivalent to a particular message send, and this is very much
5713 /// part of the user model. The name of this class encourages this
5714 /// modelling design.
5715 class PseudoObjectExpr final
5716  : public Expr,
5717  private llvm::TrailingObjects<PseudoObjectExpr, Expr *> {
5718  // PseudoObjectExprBits.NumSubExprs - The number of sub-expressions.
5719  // Always at least two, because the first sub-expression is the
5720  // syntactic form.
5721 
5722  // PseudoObjectExprBits.ResultIndex - The index of the
5723  // sub-expression holding the result. 0 means the result is void,
5724  // which is unambiguous because it's the index of the syntactic
5725  // form. Note that this is therefore 1 higher than the value passed
5726  // in to Create, which is an index within the semantic forms.
5727  // Note also that ASTStmtWriter assumes this encoding.
5728 
5729  Expr **getSubExprsBuffer() { return getTrailingObjects<Expr *>(); }
5730  const Expr * const *getSubExprsBuffer() const {
5731  return getTrailingObjects<Expr *>();
5732  }
5733 
5735  Expr *syntactic, ArrayRef<Expr*> semantic,
5736  unsigned resultIndex);
5737 
5738  PseudoObjectExpr(EmptyShell shell, unsigned numSemanticExprs);
5739 
5740  unsigned getNumSubExprs() const {
5741  return PseudoObjectExprBits.NumSubExprs;
5742  }
5743 
5744 public:
5745  /// NoResult - A value for the result index indicating that there is
5746  /// no semantic result.
5747  enum : unsigned { NoResult = ~0U };
5748 
5749  static PseudoObjectExpr *Create(const ASTContext &Context, Expr *syntactic,
5750  ArrayRef<Expr*> semantic,
5751  unsigned resultIndex);
5752 
5753  static PseudoObjectExpr *Create(const ASTContext &Context, EmptyShell shell,
5754  unsigned numSemanticExprs);
5755 
5756  /// Return the syntactic form of this expression, i.e. the
5757  /// expression it actually looks like. Likely to be expressed in
5758  /// terms of OpaqueValueExprs bound in the semantic form.
5759  Expr *getSyntacticForm() { return getSubExprsBuffer()[0]; }
5760  const Expr *getSyntacticForm() const { return getSubExprsBuffer()[0]; }
5761 
5762  /// Return the index of the result-bearing expression into the semantics
5763  /// expressions, or PseudoObjectExpr::NoResult if there is none.
5764  unsigned getResultExprIndex() const {
5765  if (PseudoObjectExprBits.ResultIndex == 0) return NoResult;
5766  return PseudoObjectExprBits.ResultIndex - 1;
5767  }
5768 
5769  /// Return the result-bearing expression, or null if there is none.
5771  if (PseudoObjectExprBits.ResultIndex == 0)
5772  return nullptr;
5773  return getSubExprsBuffer()[PseudoObjectExprBits.ResultIndex];
5774  }
5775  const Expr *getResultExpr() const {
5776  return const_cast<PseudoObjectExpr*>(this)->getResultExpr();
5777  }
5778 
5779  unsigned getNumSemanticExprs() const { return getNumSubExprs() - 1; }
5780 
5781  typedef Expr * const *semantics_iterator;
5782  typedef const Expr * const *const_semantics_iterator;
5783  semantics_iterator semantics_begin() {
5784  return getSubExprsBuffer() + 1;
5785  }
5786  const_semantics_iterator semantics_begin() const {
5787  return getSubExprsBuffer() + 1;
5788  }
5789  semantics_iterator semantics_end() {
5790  return getSubExprsBuffer() + getNumSubExprs();
5791  }
5792  const_semantics_iterator semantics_end() const {
5793  return getSubExprsBuffer() + getNumSubExprs();
5794  }
5795 
5796  llvm::iterator_range<semantics_iterator> semantics() {
5797  return llvm::make_range(semantics_begin(), semantics_end());
5798  }
5799  llvm::iterator_range<const_semantics_iterator> semantics() const {
5800  return llvm::make_range(semantics_begin(), semantics_end());
5801  }
5802 
5803  Expr *getSemanticExpr(unsigned index) {
5804  assert(index + 1 < getNumSubExprs());
5805  return getSubExprsBuffer()[index + 1];
5806  }
5807  const Expr *getSemanticExpr(unsigned index) const {
5808  return const_cast<PseudoObjectExpr*>(this)->getSemanticExpr(index);
5809  }
5810 
5811  SourceLocation getExprLoc() const LLVM_READONLY {
5812  return getSyntacticForm()->getExprLoc();
5813  }
5814 
5815  SourceLocation getBeginLoc() const LLVM_READONLY {
5816  return getSyntacticForm()->getBeginLoc();
5817  }
5818  SourceLocation getEndLoc() const LLVM_READONLY {
5819  return getSyntacticForm()->getEndLoc();
5820  }
5821 
5823  const_child_range CCR =
5824  const_cast<const PseudoObjectExpr *>(this)->children();
5825  return child_range(cast_away_const(CCR.begin()),
5826  cast_away_const(CCR.end()));
5827  }
5829  Stmt *const *cs = const_cast<Stmt *const *>(
5830  reinterpret_cast<const Stmt *const *>(getSubExprsBuffer()));
5831  return const_child_range(cs, cs + getNumSubExprs());
5832  }
5833 
5834  static bool classof(const Stmt *T) {
5835  return T->getStmtClass() == PseudoObjectExprClass;
5836  }
5837 
5839  friend class ASTStmtReader;
5840 };
5841 
5842 /// AtomicExpr - Variadic atomic builtins: __atomic_exchange, __atomic_fetch_*,
5843 /// __atomic_load, __atomic_store, and __atomic_compare_exchange_*, for the
5844 /// similarly-named C++11 instructions, and __c11 variants for <stdatomic.h>,
5845 /// and corresponding __opencl_atomic_* for OpenCL 2.0.
5846 /// All of these instructions take one primary pointer, at least one memory
5847 /// order. The instructions for which getScopeModel returns non-null value
5848 /// take one synch scope.
5849 class AtomicExpr : public Expr {
5850 public:
5851  enum AtomicOp {
5852 #define BUILTIN(ID, TYPE, ATTRS)
5853 #define ATOMIC_BUILTIN(ID, TYPE, ATTRS) AO ## ID,
5854 #include "clang/Basic/Builtins.def"
5855  // Avoid trailing comma
5856  BI_First = 0
5857  };
5858 
5859 private:
5860  /// Location of sub-expressions.
5861  /// The location of Scope sub-expression is NumSubExprs - 1, which is
5862  /// not fixed, therefore is not defined in enum.
5863  enum { PTR, ORDER, VAL1, ORDER_FAIL, VAL2, WEAK, END_EXPR };
5864  Stmt *SubExprs[END_EXPR + 1];
5865  unsigned NumSubExprs;
5866  SourceLocation BuiltinLoc, RParenLoc;
5867  AtomicOp Op;
5868 
5869  friend class ASTStmtReader;
5870 public:
5872  AtomicOp op, SourceLocation RP);
5873 
5874  /// Determine the number of arguments the specified atomic builtin
5875  /// should have.
5876  static unsigned getNumSubExprs(AtomicOp Op);
5877 
5878  /// Build an empty AtomicExpr.
5879  explicit AtomicExpr(EmptyShell Empty) : Expr(AtomicExprClass, Empty) { }
5880 
5881  Expr *getPtr() const {
5882  return cast<Expr>(SubExprs[PTR]);
5883  }
5884  Expr *getOrder() const {
5885  return cast<Expr>(SubExprs[ORDER]);
5886  }
5887  Expr *getScope() const {
5888  assert(getScopeModel() && "No scope");
5889  return cast<Expr>(SubExprs[NumSubExprs - 1]);
5890  }
5891  Expr *getVal1() const {
5892  if (Op == AO__c11_atomic_init || Op == AO__opencl_atomic_init)
5893  return cast<Expr>(SubExprs[ORDER]);
5894  assert(NumSubExprs > VAL1);
5895  return cast<Expr>(SubExprs[VAL1]);
5896  }
5897  Expr *getOrderFail() const {
5898  assert(NumSubExprs > ORDER_FAIL);
5899  return cast<Expr>(SubExprs[ORDER_FAIL]);
5900  }
5901  Expr *getVal2() const {
5902  if (Op == AO__atomic_exchange)
5903  return cast<Expr>(SubExprs[ORDER_FAIL]);
5904  assert(NumSubExprs > VAL2);
5905  return cast<Expr>(SubExprs[VAL2]);
5906  }
5907  Expr *getWeak() const {
5908  assert(NumSubExprs > WEAK);
5909  return cast<Expr>(SubExprs[WEAK]);
5910  }
5911  QualType getValueType() const;
5912 
5913  AtomicOp getOp() const { return Op; }
5914  unsigned getNumSubExprs() const { return NumSubExprs; }
5915 
5916  Expr **getSubExprs() { return reinterpret_cast<Expr **>(SubExprs); }
5917  const Expr * const *getSubExprs() const {
5918  return reinterpret_cast<Expr * const *>(SubExprs);
5919  }
5920 
5921  bool isVolatile() const {
5922  return getPtr()->getType()->getPointeeType().isVolatileQualified();
5923  }
5924 
5925  bool isCmpXChg() const {
5926  return getOp() == AO__c11_atomic_compare_exchange_strong ||
5927  getOp() == AO__c11_atomic_compare_exchange_weak ||
5928  getOp() == AO__opencl_atomic_compare_exchange_strong ||
5929  getOp() == AO__opencl_atomic_compare_exchange_weak ||
5930  getOp() == AO__atomic_compare_exchange ||
5931  getOp() == AO__atomic_compare_exchange_n;
5932  }
5933 
5934  bool isOpenCL() const {
5935  return getOp() >= AO__opencl_atomic_init &&
5936  getOp() <= AO__opencl_atomic_fetch_max;
5937  }
5938 
5939  SourceLocation getBuiltinLoc() const { return BuiltinLoc; }
5940  SourceLocation getRParenLoc() const { return RParenLoc; }
5941 
5942  SourceLocation getBeginLoc() const LLVM_READONLY { return BuiltinLoc; }
5943  SourceLocation getEndLoc() const LLVM_READONLY { return RParenLoc; }
5944 
5945  static bool classof(const Stmt *T) {
5946  return T->getStmtClass() == AtomicExprClass;
5947  }
5948 
5949  // Iterators
5951  return child_range(SubExprs, SubExprs+NumSubExprs);
5952  }
5954  return const_child_range(SubExprs, SubExprs + NumSubExprs);
5955  }
5956 
5957  /// Get atomic scope model for the atomic op code.
5958  /// \return empty atomic scope model if the atomic op code does not have
5959  /// scope operand.
5960  static std::unique_ptr<AtomicScopeModel> getScopeModel(AtomicOp Op) {
5961  auto Kind =
5962  (Op >= AO__opencl_atomic_load && Op <= AO__opencl_atomic_fetch_max)
5966  }
5967 
5968  /// Get atomic scope model.
5969  /// \return empty atomic scope model if this atomic expression does not have
5970  /// scope operand.
5971  std::unique_ptr<AtomicScopeModel> getScopeModel() const {
5972  return getScopeModel(getOp());
5973  }
5974 };
5975 
5976 /// TypoExpr - Internal placeholder for expressions where typo correction
5977 /// still needs to be performed and/or an error diagnostic emitted.
5978 class TypoExpr : public Expr {
5979 public:
5981  : Expr(TypoExprClass, T, VK_LValue, OK_Ordinary,
5982  /*isTypeDependent*/ true,
5983  /*isValueDependent*/ true,
5984  /*isInstantiationDependent*/ true,
5985  /*containsUnexpandedParameterPack*/ false) {
5986  assert(T->isDependentType() && "TypoExpr given a non-dependent type");
5987  }
5988 
5991  }
5994  }
5995 
5996  SourceLocation getBeginLoc() const LLVM_READONLY { return SourceLocation(); }
5997  SourceLocation getEndLoc() const LLVM_READONLY { return SourceLocation(); }
5998 
5999  static bool classof(const Stmt *T) {
6000  return T->getStmtClass() == TypoExprClass;
6001  }
6002 
6003 };
6004 } // end namespace clang
6005 
6006 #endif // LLVM_CLANG_AST_EXPR_H
void setFPFeatures(FPOptions F)
Definition: Expr.h:3607
ObjCPropertyRefExpr - A dot-syntax expression to access an ObjC property.
Definition: ExprObjC.h:614
unsigned getNumSemanticExprs() const
Definition: Expr.h:5779
const Expr * getSubExpr() const
Definition: Expr.h:963
bool hasArrayFiller() const
Return true if this is an array initializer and its array "filler" has been set.
Definition: Expr.h:4507
Represents a single C99 designator.
Definition: Expr.h:4714
unsigned getNumTemplateArgs() const
Retrieve the number of template arguments provided as part of this template-id.
Definition: Expr.h:1348
child_range children()
Definition: Expr.h:5617
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: Expr.h:5996
Expr * getVal2() const
Definition: Expr.h:5901
void setValueDependent(bool VD)
Set whether this expression is value-dependent or not.
Definition: Expr.h:161
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
friend TrailingObjects
Definition: Expr.h:3412
const BlockDecl * getBlockDecl() const
Definition: Expr.h:5593
const_child_range children() const
Definition: Expr.h:3251
bool isCallToStdMove() const
Definition: Expr.h:2799
bool isIncrementOp() const
Definition: Expr.h:2108
bool path_empty() const
Definition: Expr.h:3220
Expr * getChosenSubExpr() const
getChosenSubExpr - Return the subexpression chosen according to the condition.
Definition: Expr.h:4171
const_child_range children() const
Definition: Expr.h:5005
Represents a function declaration or definition.
Definition: Decl.h:1783
NamedDecl * getFoundDecl()
Get the NamedDecl through which this reference occurred.
Definition: Expr.h:1284
const StringLiteral * getFunctionName() const
Definition: Expr.h:1964
void setSubStmt(CompoundStmt *S)
Definition: Expr.h:3972
const Expr * IgnoreParenLValueCasts() const
Definition: Expr.h:865
const Expr * IgnoreParens() const
Definition: Expr.h:822
Expr ** getArgs()
Retrieve the call arguments.
Definition: Expr.h:2692
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.
BlockExpr(EmptyShell Empty)
Build an empty block expression.
Definition: Expr.h:5591
Expr * getLHS() const
Definition: Expr.h:3780
child_range children()
Definition: Expr.h:2154
StringRef Identifier
Definition: Format.cpp:1833
BlockDecl * TheBlock
Definition: Expr.h:5581
ImplicitCastExpr(OnStack_t _, QualType ty, CastKind kind, Expr *op, ExprValueKind VK)
Definition: Expr.h:3288
Expr * getSyntacticForm()
Return the syntactic form of this expression, i.e.
Definition: Expr.h:5759
SourceLocation getEndLoc() const LLVM_READONLY
Definition: Expr.h:1562
bool hasTemplateKeyword() const
Determines whether the member name was preceded by the template keyword.
Definition: Expr.h:2976
reverse_iterator rbegin()
Definition: Expr.h:4610
SourceLocation getRParenLoc() const
Definition: Expr.h:2789
const TemplateArgumentLoc * getTemplateArgs() const
Retrieve the template arguments provided as part of this template-id.
Definition: Expr.h:1340
child_range children()
Definition: Expr.h:2532
unsigned getRawEncoding() const
When a SourceLocation itself cannot be used, this returns an (opaque) 32-bit integer encoding for it...
const Expr * getIdx() const
Definition: Expr.h:2509
A (possibly-)qualified type.
Definition: Type.h:654
SourceLocation getEndLoc() const LLVM_READONLY
Definition: Expr.h:5096
StringKind getKind() const
Definition: Expr.h:1826
ResultStorageKind
Describes the kind of result that can be trail-allocated.
Definition: Expr.h:987
enum clang::SubobjectAdjustment::@49 Kind
ValueDecl * getMemberDecl() const
Retrieve the member declaration to which this expression refers.
Definition: Expr.h:2919
Expr * getCond() const
Definition: Expr.h:4175
void setOperatorLoc(SourceLocation L)
Definition: Expr.h:2440
static Opcode getOpForCompoundAssignment(Opcode Opc)
Definition: Expr.h:3571
Expr * getArg(unsigned Arg)
getArg - Return the specified argument.
Definition: Expr.h:2702
SourceLocation getExprLoc() const
Definition: Expr.h:3465
void setArrow(bool A)
Definition: Expr.h:3021
Defines enumerations for the type traits support.
SourceLocation getLParen() const
Get the location of the left parentheses &#39;(&#39;.
Definition: Expr.h:2018
SourceLocation getEndLoc() const LLVM_READONLY
Definition: Expr.h:5063
Expr(StmtClass SC, QualType T, ExprValueKind VK, ExprObjectKind OK, bool TD, bool VD, bool ID, bool ContainsUnexpandedParameterPack)
Definition: Expr.h:119
const_association_range associations() const
Definition: Expr.h:5473
bool operator==(CanQual< T > x, CanQual< U > y)
Expr * getExpr(unsigned Index)
getExpr - Return the Expr at the specified index.
Definition: Expr.h:4039
llvm::APFloat getValue(const llvm::fltSemantics &Semantics) const
Definition: Expr.h:1438
Designator(unsigned Index, SourceLocation LBracketLoc, SourceLocation RBracketLoc)
Initializes an array designator.
Definition: Expr.h:4743
unsigned FieldLoc
The location of the field name in the designated initializer.
Definition: Expr.h:4691
CharacterLiteral(EmptyShell Empty)
Construct an empty character literal.
Definition: Expr.h:1554
unsigned getNumSubExprs() const
getNumSubExprs - Return the size of the SubExprs array.
Definition: Expr.h:4033
unsigned getResultIndex() const
The zero-based index of the result expression&#39;s generic association in the generic selection&#39;s associ...
Definition: Expr.h:5407
Expr * getResultExpr()
Return the result expression of this controlling expression.
Definition: Expr.h:5426
CompoundStmt * getSubStmt()
Definition: Expr.h:3970
InitExprsTy::const_iterator const_iterator
Definition: Expr.h:4602
SourceLocation getEndLoc() const LLVM_READONLY
Definition: Expr.h:5560
const Expr * getInit(unsigned Init) const
Definition: Expr.h:4451
const DeclContext * getParentContext() const
If the SourceLocExpr has been resolved return the subexpression representing the resolved value...
Definition: Expr.h:4335
static bool classof(const Stmt *S)
Definition: Expr.h:5091
Designator(const IdentifierInfo *FieldName, SourceLocation DotLoc, SourceLocation FieldLoc)
Initializes a field designator.
Definition: Expr.h:4734
Expr * getControllingExpr()
Return the controlling expression of this generic selection expression.
Definition: Expr.h:5417
void setRHS(Expr *E)
Definition: Expr.h:2503
bool containsNonAsciiOrNull() const
Definition: Expr.h:1844
static bool isBuiltinAssumeFalse(const CFGBlock *B, const Stmt *S, ASTContext &C)
TypeSourceInfo * Ty
Definition: Expr.h:2374
Expr *const * semantics_iterator
Definition: Expr.h:5781
Stmt - This represents one statement.
Definition: Stmt.h:66
unsigned getNumArgs() const
getNumArgs - Return the number of actual arguments to this call.
Definition: Expr.h:2689
CompoundLiteralExpr(EmptyShell Empty)
Construct an empty compound literal.
Definition: Expr.h:3100
SourceLocation getOperatorLoc() const
getOperatorLoc - Return the location of the operator.
Definition: Expr.h:2302
SourceLocation getRParenLoc() const
Definition: Expr.h:4020
SourceLocation getLocation() const
Definition: Expr.h:1638
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: Expr.h:3974
StmtExpr(CompoundStmt *substmt, QualType T, SourceLocation lp, SourceLocation rp)
Definition: Expr.h:3961
bool isFEnvAccessOn() const
Definition: Expr.h:3623
bool hasPlaceholderType() const
Returns whether this expression has a placeholder type.
Definition: Expr.h:481
ArrayRef< Stmt * > getRawSubExprs()
This method provides fast access to all the subexpressions of a CallExpr without going through the sl...
Definition: Expr.h:2758
C Language Family Type Representation.
static bool isMultiplicativeOp(Opcode Opc)
Definition: Expr.h:3506
bool isLogicalOp() const
Definition: Expr.h:3558
SourceLocation getRBracketLoc() const
Definition: Expr.h:4797
void setOpcode(Opcode Opc)
Definition: Expr.h:3472
const_child_range children() const
Definition: Expr.h:1652
bool isAscii() const
Definition: Expr.h:1830
reverse_iterator rbegin()
Definition: ASTVector.h:103
const_child_range children() const
Definition: Expr.h:4199
Expr * getBase() const
Definition: Expr.h:2913
TypeSourceInfo * getTypeSourceInfo() const
Definition: Expr.h:3113
static unsigned sizeOfTrailingObjects(unsigned NumPreArgs, unsigned NumArgs)
Return the size in bytes needed for the trailing objects.
Definition: Expr.h:2610
Decl - This represents one declaration (or definition), e.g.
Definition: DeclBase.h:88
static bool classof(const Stmt *T)
Definition: Expr.h:1476
llvm::APFloat getValue() const
Definition: Expr.h:1597
Represents the index of the current element of an array being initialized by an ArrayInitLoopExpr.
Definition: Expr.h:5082
LLVM_READNONE bool isASCII(char c)
Returns true if this is an ASCII character.
Definition: CharInfo.h:42
void setType(QualType t)
Definition: Expr.h:138
ConstExprUsage
Indicates how the constant expression will be used.
Definition: Expr.h:692
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: Expr.h:2445
const Expr * getSubExpr() const
Definition: Expr.h:4262
const_child_range children() const
Definition: Expr.h:2816
SourceLocation getEndLoc() const LLVM_READONLY
Definition: Expr.h:5997
Opcode getOpcode() const
Definition: Expr.h:3469
Classification Classify(ASTContext &Ctx) const
Classify - Classify this expression according to the C++11 expression taxonomy.
Definition: Expr.h:386
static bool classof(const Stmt *T)
Definition: Expr.h:3313
const CastExpr * BasePath
Definition: Expr.h:71
unsigned getNumSubExprs() const
Retrieve the total number of subexpressions in this designated initializer expression, including the actual initialized value and any expressions that occur within array and array-range designators.
Definition: Expr.h:4889
void setNumArgsUnsafe(unsigned NewNumArgs)
Bluntly set a new number of arguments without doing any checks whatsoever.
Definition: Expr.h:2732
void setComputationResultType(QualType T)
Definition: Expr.h:3681
ParenExpr - This represents a parethesized expression, e.g.
Definition: Expr.h:1994
Is the identifier known as a GNU-style attribute?
bool hasQualifier() const
Determines whether this member expression actually had a C++ nested-name-specifier prior to the name ...
Definition: Expr.h:2933
Strictly evaluate the expression.
Definition: Expr.h:612
child_range children()
Definition: Expr.h:3598
const_arg_iterator arg_begin() const
Definition: Expr.h:2749
The base class of the type hierarchy.
Definition: Type.h:1450
FullExpr(StmtClass SC, Expr *subexpr)
Definition: Expr.h:954
ImplicitValueInitExpr(QualType ty)
Definition: Expr.h:5119
Expr * getCopyExpr() const
Definition: Expr.h:5634
bool isSemanticForm() const
Definition: Expr.h:4555
bool hasExplicitTemplateArgs() const
Determines whether this declaration reference was followed by an explicit template argument list...
Definition: Expr.h:1328
llvm::iterator_range< child_iterator > child_range
Definition: Stmt.h:1180
SourceLocation getRParenLoc() const
Definition: Expr.h:2442
CastExpr(StmtClass SC, EmptyShell Empty, unsigned BasePathSize)
Construct an empty cast.
Definition: Expr.h:3187
bool isIntType() const LLVM_READONLY
Definition: Expr.h:4331
static bool isShiftOp(Opcode Opc)
Definition: Expr.h:3512
static ExprValueKind getValueKindForType(QualType T)
getValueKindForType - Given a formal return or parameter type, give its value kind.
Definition: Expr.h:404
const Designator * getDesignator(unsigned Idx) const
Definition: Expr.h:4851
TypeSourceInfo * getTypeInfoAsWritten() const
getTypeInfoAsWritten - Returns the type source info for the type that this expression is casting to...
Definition: Expr.h:3355
void setADLCallKind(ADLCallKind V=UsesADL)
Definition: Expr.h:2670
FPOptions getFPFeatures() const
Definition: Expr.h:3611
InitExprsTy::iterator iterator
Definition: Expr.h:4601
SourceLocation getLParenLoc() const
Definition: Expr.h:3397
The l-value was an access to a declared entity or something equivalently strong, like the address of ...
A container of type source information.
Definition: Type.h:6227
SourceLocation getLocation() const
Definition: Expr.h:4338
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: Expr.h:3306
Stmt * SubExpr
Definition: Expr.h:952
void setCanOverflow(bool C)
Definition: Expr.h:2090
Floating point control options.
Definition: LangOptions.h:357
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: Expr.h:3403
IdentKind getIdentKind() const
Definition: Expr.h:1951
static bool classof(const Stmt *T)
Definition: Expr.h:3244
const_child_range children() const
Definition: Expr.h:5500
SourceLocation getExprLoc() const LLVM_READONLY
Definition: Expr.h:5811
SourceLocation getEndLoc() const LLVM_READONLY
Definition: Expr.h:5132
const_child_range children() const
Definition: Expr.h:4288
ShuffleVectorExpr(EmptyShell Empty)
Build an empty vector-shuffle expression.
Definition: Expr.h:4014
SourceLocation getAccessorLoc() const
Definition: Expr.h:5543
bool isDirectInit() const
Whether this designated initializer should result in direct-initialization of the designated subobjec...
Definition: Expr.h:4869
BinaryOperator(Expr *lhs, Expr *rhs, Opcode opc, QualType ResTy, ExprValueKind VK, ExprObjectKind OK, SourceLocation opLoc, FPOptions FPFeatures)
Definition: Expr.h:3441
const Expr * getResultExpr() const
Definition: Expr.h:5430
bool isImplicitAccess() const
Determine whether the base of this explicit is implicit.
Definition: Expr.h:3034
SourceLocation getRParenLoc() const
getRParenLoc - Return the location of final right parenthesis.
Definition: Expr.h:4105
isModifiableLvalueResult
Definition: Expr.h:278
const Expr * getSubExpr() const
Definition: Expr.h:1674
Expr * getIndexExpr(unsigned Idx)
Definition: Expr.h:2330
const Expr * getIndexExpr(unsigned Idx) const
Definition: Expr.h:2335
const CXXBaseSpecifier *const * path_const_iterator
Definition: Expr.h:3219
child_range children()
Definition: Expr.h:4342
Represents a variable declaration or definition.
Definition: Decl.h:820
bool hasTemplateKWAndArgsInfo() const
Definition: Expr.h:1294
void setIsPartOfExplicitCast(bool PartOfExplicitCast)
Definition: Expr.h:3294
CompoundLiteralExpr - [C99 6.5.2.5].
Definition: Expr.h:3077
void setSubExpr(unsigned Idx, Expr *E)
Definition: Expr.h:4896
static bool isArithmeticOp(Opcode Op)
Definition: Expr.h:2124
const internal::VariadicDynCastAllOfMatcher< Stmt, Expr > expr
Matches expressions.
OpaqueValueExpr * getCommonExpr() const
Get the common subexpression shared by all initializations (the source array).
Definition: Expr.h:5044
const T * getAs() const
Member-template getAs<specific type>&#39;.
Definition: Type.h:7002
void setInitializer(Expr *E)
Definition: Expr.h:3105
bool This(InterpState &S, CodePtr OpPC)
Definition: Interp.h:827
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: Expr.h:5131
const Expr * getSemanticExpr(unsigned index) const
Definition: Expr.h:5807
unsigned EllipsisLoc
The location of the ellipsis separating the start and end indices.
Definition: Expr.h:4703
llvm::iterator_range< arg_iterator > arg_range
Definition: Expr.h:2736
SourceLocation getColonLoc() const
Definition: Expr.h:3722
BlockExpr(BlockDecl *BD, QualType ty)
Definition: Expr.h:5583
void setInit(unsigned Init, Expr *expr)
Definition: Expr.h:4461
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:2897
AddrLabelExpr(EmptyShell Empty)
Build an empty address of a label expression.
Definition: Expr.h:3921
void setValue(unsigned Val)
Definition: Expr.h:1568
const_iterator begin() const
Definition: Expr.h:4607
void setLocation(SourceLocation Location)
Definition: Expr.h:1513
size_type size() const
Definition: ASTVector.h:109
Expr * getVal1() const
Definition: Expr.h:5891
static bool classof(const Stmt *T)
Definition: Expr.h:1041
static std::unique_ptr< AtomicScopeModel > create(AtomicScopeModelKind K)
Create an atomic scope model by AtomicScopeModelKind.
Definition: SyncScope.h:142
void setContainsUnexpandedParameterPack(bool PP=true)
Set the bit that describes whether this expression contains an unexpanded parameter pack...
Definition: Expr.h:229
ConditionalOperator(EmptyShell Empty)
Build an empty conditional operator.
Definition: Expr.h:3764
static bool classof(const Stmt *T)
Definition: Expr.h:4350
void setGNUSyntax(bool GNU)
Definition: Expr.h:4874
TypeSourceInfo * getArgumentTypeInfo() const
Definition: Expr.h:2412
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: Expr.h:3929
SourceRange getSourceRange() const LLVM_READONLY
Retrieve the source range that covers this offsetof node.
Definition: Expr.h:2248
bool isShiftAssignOp() const
Definition: Expr.h:3582
unsigned getNumExpressions() const
Definition: Expr.h:2345
SourceLocation getLocation() const
Retrieve the location of the literal.
Definition: Expr.h:1472
child_range children()
Definition: Expr.h:1117
const_child_range children() const
Definition: Expr.h:5101
static bool isAssignmentOp(Opcode Opc)
Definition: Expr.h:3560
child_range children()
Definition: Expr.h:3987
SourceLocation getRParenLoc() const
Definition: Expr.h:5487
SourceLocation getLocation() const
Retrieve the location of the literal.
Definition: Expr.h:1511
bool isAdditiveOp() const
Definition: Expr.h:3511
bool isEqualityOp() const
Definition: Expr.h:3522
SourceLocation getBuiltinLoc() const
Definition: Expr.h:4182
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: Expr.h:3120
SourceLocation getEndLoc() const LLVM_READONLY
Definition: Expr.h:3930
bool isXValue() const
Definition: Expr.h:260
iterator end()
Definition: Expr.h:4608
IdentifierInfo * getIdentifier() const
Get the identifier that names this declaration, if there is one.
Definition: Decl.h:244
const Expr * getBase() const
Definition: Expr.h:2506
static bool classof(const Stmt *T)
Definition: Expr.h:2025
const_child_range children() const
Definition: Expr.h:4957
SourceLocation getDotLoc() const
Definition: Expr.h:4781
Represents a struct/union/class.
Definition: Decl.h:3748
InitExprsTy::const_reverse_iterator const_reverse_iterator
Definition: Expr.h:4604
Represents a C99 designated initializer expression.
Definition: Expr.h:4639
AbstractConditionalOperator(StmtClass SC, EmptyShell Empty)
Definition: Expr.h:3704
bool isOrdinaryOrBitFieldObject() const
Definition: Expr.h:425
bool canThrow() const
Definition: Expr.h:5635
DeclarationName getDeclName() const
Get the actual, stored name of the declaration, which may be a special name.
Definition: Decl.h:272
static bool classof(const Stmt *T)
Definition: Expr.h:2448
const Expr * IgnoreParenImpCasts() const
Definition: Expr.h:836
static StringLiteral * Create(const ASTContext &Ctx, StringRef Str, StringKind Kind, bool Pascal, QualType Ty, SourceLocation Loc)
Simple constructor for string literals made from one token.
Definition: Expr.h:1783
One of these records is kept for each identifier that is lexed.
Represents a statement that could possibly have a value and type.
Definition: Stmt.h:1713
Expr * getFalseExpr() const
Definition: Expr.h:3778
FieldDecl * getField() const
For a field offsetof node, returns the field.
Definition: Expr.h:2227
SourceLocation getRParenLoc() const
Definition: Expr.h:5940
child_range children()
Definition: Expr.h:5822
AddrLabelExpr(SourceLocation AALoc, SourceLocation LLoc, LabelDecl *L, QualType t)
Definition: Expr.h:3914
Represents a function call to one of __builtin_LINE(), __builtin_COLUMN(), __builtin_FUNCTION(), or __builtin_FILE().
Definition: Expr.h:4295
const_reverse_iterator rend() const
Definition: Expr.h:4613
ShuffleVectorExpr - clang-specific builtin-in function __builtin_shufflevector.
Definition: Expr.h:3999
static Opcode reverseComparisonOp(Opcode Opc)
Definition: Expr.h:3543
QualType getComputationResultType() const
Definition: Expr.h:3680
bool isStr(const char(&Str)[StrLen]) const
Return true if this is the identifier for the specified string.
SourceLocation getRParen() const
Get the location of the right parentheses &#39;)&#39;.
Definition: Expr.h:2022
A vector component is an element or range of elements on a vector.
Definition: Specifiers.h:147
StmtIterator cast_away_const(const ConstStmtIterator &RHS)
Definition: StmtIterator.h:151
const_child_range children() const
Definition: Expr.h:2361
static bool classof(const Stmt *T)
Definition: Expr.h:4583
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition: ASTContext.h:168
A C++ nested-name-specifier augmented with source location information.
Expr * getInit() const
Retrieve the initializer value.
Definition: Expr.h:4877
void setLHS(Expr *E)
Definition: Expr.h:2499
SourceLocation getExprLoc() const LLVM_READONLY
Definition: Expr.h:2523
bool isFileScope() const
Definition: Expr.h:3107
friend TrailingObjects
Definition: Expr.h:3317
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: Expr.h:3783
bool isUTF8() const
Definition: Expr.h:1832
FullExpr - Represents a "full-expression" node.
Definition: Expr.h:950
child_range children()
Definition: Expr.h:3140
SourceLocation getAmpAmpLoc() const
Definition: Expr.h:3924
static SourceLocation getFromRawEncoding(unsigned Encoding)
Turn a raw encoding of a SourceLocation object into a real SourceLocation.
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: Stmt.cpp:275
Represents a member of a struct/union/class.
Definition: Decl.h:2729
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: Expr.h:5673
void setIsMicrosoftABI(bool IsMS)
Definition: Expr.h:4268
Represents a place-holder for an object not to be initialized by anything.
Definition: Expr.h:4937
bool empty() const
Definition: ASTVector.h:108
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: Expr.h:4227
UnaryOperator(Expr *input, Opcode opc, QualType type, ExprValueKind VK, ExprObjectKind OK, SourceLocation l, bool CanOverflow)
Definition: Expr.h:2052
static bool isPtrMemOp(Opcode Opc)
predicates to categorize the respective opcodes.
Definition: Expr.h:3501
UnaryExprOrTypeTrait
Names for the "expression or type" traits.
Definition: TypeTraits.h:96
static bool isIncrementDecrementOp(Opcode Op)
Definition: Expr.h:2119
unsigned getArrayExprIndex() const
For an array element node, returns the index into the array of expressions.
Definition: Expr.h:2221
SourceLocation getLabelLoc() const
Definition: Expr.h:3926
ExtVectorElementExpr(EmptyShell Empty)
Build an empty vector element expression.
Definition: Expr.h:5533
bool hasExplicitTemplateArgs() const
Determines whether the member name was followed by an explicit template argument list.
Definition: Expr.h:2980
UnaryOperator(EmptyShell Empty)
Build an empty unary operator.
Definition: Expr.h:2067
const Expr * getResultExpr() const
Definition: Expr.h:5775
SourceLocation getRBraceLoc() const
Definition: Expr.h:4552
SourceLocation getOperatorLoc() const
Definition: Expr.h:2439
SourceLocation getExprLoc() const LLVM_READONLY
Definition: Expr.h:3031
unsigned getNumCommas() const
getNumCommas - Return the number of commas that must have been present in this function call...
Definition: Expr.h:2765
static bool classof(const Stmt *T)
Definition: Expr.h:3408
GNUNullExpr - Implements the GNU __null extension, which is a name for a null pointer constant that h...
Definition: Expr.h:4210
bool isReferenceType() const
Definition: Type.h:6516
SourceLocation getRParenLoc() const
Definition: Expr.h:3400
void setArg(unsigned Arg, Expr *ArgExpr)
setArg - Set the specified argument.
Definition: Expr.h:2712
SourceLocation getEndLoc() const LLVM_READONLY
Definition: Expr.h:3482
child_range children()
Definition: Expr.h:1649
child_range children()
Definition: Expr.h:4235
child_range children()
Definition: Expr.h:1575
void shrinkNumArgs(unsigned NewNumArgs)
Reduce the number of arguments in this call expression.
Definition: Expr.h:2723
void setRParen(SourceLocation Loc)
Definition: Expr.h:2023
GNUNullExpr(EmptyShell Empty)
Build an empty GNU __null expression.
Definition: Expr.h:4221
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: Expr.h:5060
Expr * getSourceExpr() const
The source expression of an opaque value expression is the expression which originally generated the ...
Definition: Expr.h:1133
const_child_range children() const
Definition: Expr.h:2031
clang::CharUnits operator*(clang::CharUnits::QuantityType Scale, const clang::CharUnits &CU)
Definition: CharUnits.h:212
const_child_range children() const
Definition: Expr.h:1578
ExtVectorElementExpr - This represents access to specific elements of a vector, and may occur on the ...
Definition: Expr.h:5518
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: Expr.h:4950
__DEVICE__ int max(int __a, int __b)
Classification ClassifyModifiable(ASTContext &Ctx, SourceLocation &Loc) const
ClassifyModifiable - Classify this expression according to the C++11 expression taxonomy, and see if it is valid on the left side of an assignment.
Definition: Expr.h:398
Expr * getSubExpr()
Definition: Expr.h:3202
Association getAssociation(unsigned I)
Return the Ith association expression with its TypeSourceInfo, bundled together in GenericSelectionEx...
Definition: Expr.h:5446
std::unique_ptr< AtomicScopeModel > getScopeModel() const
Get atomic scope model.
Definition: Expr.h:5971
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: Expr.h:4279
SourceLocation getQuestionLoc() const
Definition: Expr.h:3721
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
Definition: LangOptions.h:53
void setComponent(unsigned Idx, OffsetOfNode ON)
Definition: Expr.h:2321
SourceLocation getEndLoc() const LLVM_READONLY
Definition: Expr.h:2446
const_child_range children() const
Definition: Expr.h:4238
unsigned getCharByteWidth() const
Definition: Expr.h:1824
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: Expr.h:5095
const Expr * ignoreParenBaseCasts() const
Definition: Expr.h:886
bool isAssignmentOp() const
Definition: Expr.h:3563
SourceLocation getEndLoc() const LLVM_READONLY
Definition: Expr.h:4228
NestedNameSpecifierLoc QualifierLoc
The nested-name-specifier that qualifies the name, including source-location information.
Definition: Expr.h:2827
void setRParenLoc(SourceLocation L)
Definition: Expr.h:3980
static bool classof(const Stmt *T)
Definition: Expr.h:4988
bool hadArrayRangeDesignator() const
Definition: Expr.h:4573
An r-value expression (a pr-value in the C++11 taxonomy) produces a temporary value.
Definition: Specifiers.h:125
child_range children()
Definition: Expr.h:1481
const Expr *const * const_semantics_iterator
Definition: Expr.h:5782
static bool classof(const Stmt *T)
Definition: Expr.h:5834
SourceLocation getEndLoc() const LLVM_READONLY
Definition: Expr.h:4951
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:968
static bool isRelationalOp(Opcode Opc)
Definition: Expr.h:3518
Expr *const * getInits() const
Retrieve the set of initializers.
Definition: Expr.h:4439
void setLBraceLoc(SourceLocation Loc)
Definition: Expr.h:4551
StringRef getOpcodeStr() const
Definition: Expr.h:3490
bool isGLValue() const
Definition: Expr.h:261
const_child_range children() const
Definition: Expr.h:5682
void copyTemplateArgumentsInto(TemplateArgumentListInfo &List) const
Copies the template arguments (if present) into the given structure.
Definition: Expr.h:1332
Describes an C or C++ initializer list.
Definition: Expr.h:4403
SourceLocation getEndLoc() const LLVM_READONLY
Definition: Expr.h:4108
AsTypeExpr(Expr *SrcExpr, QualType DstType, ExprValueKind VK, ExprObjectKind OK, SourceLocation BuiltinLoc, SourceLocation RParenLoc)
Definition: Expr.h:5652
void setValue(const ASTContext &C, const llvm::APInt &Val)
Definition: Expr.h:1431
void setBuiltinLoc(SourceLocation L)
Definition: Expr.h:4018
BinaryOperatorKind
bool isPostfix() const
Definition: Expr.h:2103
void setSubExpr(Expr *E)
Definition: Expr.h:2012
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: Expr.h:1468
AssociationTy< true > ConstAssociation
Definition: Expr.h:5394
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:573
void setLHS(Expr *E)
Definition: Expr.h:4178
child_range children()
Definition: Expr.h:4115
unsigned getLength() const
Definition: Expr.h:1823
static bool isEqualityOp(Opcode Opc)
Definition: Expr.h:3521
unsigned getFirstExprIndex() const
Definition: Expr.h:4809
bool refersToBitField() const
Returns true if this expression is a gl-value that potentially refers to a bit-field.
Definition: Expr.h:446
static DeclAccessPair make(NamedDecl *D, AccessSpecifier AS)
static bool classof(const Stmt *T)
Definition: Expr.h:1976
BlockVarCopyInit(Expr *CopyExpr, bool CanThrow)
Definition: Expr.h:5629
APValue Val
Val - This is the value the expression can be folded to.
Definition: Expr.h:588
A convenient class for passing around template argument information.
Definition: TemplateBase.h:554
Expr * getPtr() const
Definition: Expr.h:5881
child_range children()
Definition: Expr.h:1522
static bool classof(const Stmt *T)
Definition: Expr.h:1570
child_range children()
Definition: Expr.h:1386
OffsetOfNode(SourceLocation LBracketLoc, unsigned Index, SourceLocation RBracketLoc)
Create an offsetof node that refers to an array element.
Definition: Expr.h:2197
ExprValueKind getValueKind() const
getValueKind - The value kind that this expression produces.
Definition: Expr.h:414
An x-value expression is a reference to an object with independent storage but which can be "moved"...
Definition: Specifiers.h:134
path_iterator path_begin()
Definition: Expr.h:3222
const Expr * getArg(unsigned Arg) const
Definition: Expr.h:2706
child_range children()
Definition: Expr.h:2811
OffsetOfNode(const CXXBaseSpecifier *Base)
Create an offsetof node that refers into a C++ base class.
Definition: Expr.h:2213
NullPointerConstantValueDependence
Enumeration used to describe how isNullPointerConstant() should cope with value-dependent expressions...
Definition: Expr.h:733
static bool classof(const Stmt *T)
Definition: Expr.h:1683
unsigned getNumPreArgs() const
Definition: Expr.h:2627
static bool classof(const Stmt *S)
Definition: Expr.h:5056
const Expr * IgnoreCasts() const
Definition: Expr.h:790
semantics_iterator semantics_end()
Definition: Expr.h:5789
A builtin binary operation expression such as "x + y" or "x <= y".
Definition: Expr.h:3434
static bool classof(const Stmt *T)
Definition: Expr.h:4282
TypoExpr(QualType T)
Definition: Expr.h:5980
tokloc_iterator tokloc_end() const
Definition: Expr.h:1882
unsigned RBracketLoc
The location of the &#39;]&#39; terminating the array range designator.
Definition: Expr.h:4705
ArrayRef< TemplateArgumentLoc > template_arguments() const
Definition: Expr.h:3008
void setAccessor(IdentifierInfo *II)
Definition: Expr.h:5541
bool hadMultipleCandidates() const
Returns true if this member expression refers to a method that was resolved from an overloaded set ha...
Definition: Expr.h:3040
unsigned getResultExprIndex() const
Return the index of the result-bearing expression into the semantics expressions, or PseudoObjectExpr...
Definition: Expr.h:5764
static bool isPostfix(Opcode Op)
isPostfix - Return true if this is a postfix operation, like x++.
Definition: Expr.h:2093
static bool classof(const Stmt *T)
Definition: Expr.h:2527
child_range children()
Definition: Expr.h:4588
bool isArrow() const
Definition: Expr.h:3020
ChooseExpr(EmptyShell Empty)
Build an empty __builtin_choose_expr.
Definition: Expr.h:4154
static bool classof(const Stmt *T)
Definition: Expr.h:3935
bool isFPContractableWithinStatement() const
Definition: Expr.h:3617
SourceLocation getEqualOrColonLoc() const
Retrieve the location of the &#39;=&#39; that precedes the initializer value itself, if present.
Definition: Expr.h:4864
BinaryOperator(EmptyShell Empty)
Construct an empty binary operator.
Definition: Expr.h:3461
StringKind
StringLiteral is followed by several trailing objects.
Definition: Expr.h:1733
child_range children()
Definition: Expr.h:5098
TypoExpr - Internal placeholder for expressions where typo correction still needs to be performed and...
Definition: Expr.h:5978
const_child_range children() const
Definition: Expr.h:5138
IdentKind getIdentKind() const
Definition: Expr.h:4316
void setOperatorLoc(SourceLocation L)
Definition: Expr.h:2303
unsigned getInt() const
Used to serialize this.
Definition: LangOptions.h:402
SourceLocation getEndLoc() const
Definition: Expr.h:4340
bool isRelationalOp() const
Definition: Expr.h:3519
An adjustment to be made to the temporary created when emitting a reference binding, which accesses a particular subobject of that temporary.
Definition: Expr.h:63
ResultStorageKind getResultStorageKind() const
Definition: Expr.h:1053
const Expr * getControllingExpr() const
Definition: Expr.h:5420
CastExpr - Base class for type casts, including both implicit casts (ImplicitCastExpr) and explicit c...
Definition: Expr.h:3150
Helper class for OffsetOfExpr.
Definition: Expr.h:2163
AssociationTy< false > Association
Definition: Expr.h:5393
const llvm::fltSemantics & getSemantics() const
Return the APFloat semantics this literal uses.
Definition: Expr.h:1619
SourceLocation getBuiltinLoc() const
Definition: Expr.h:4273
void setOpcode(Opcode Opc)
Definition: Expr.h:2074
NestedNameSpecifierLoc getQualifierLoc() const
If the name was qualified, retrieves the nested-name-specifier that precedes the name, with source-location information.
Definition: Expr.h:1266
bool isTypeDependent() const
isTypeDependent - Determines whether this expression is type-dependent (C++ [temp.dep.expr]), which means that its type could change from one template instantiation to the next.
Definition: Expr.h:176
An ordinary object is located at an address in memory.
Definition: Specifiers.h:141
bool Const(InterpState &S, CodePtr OpPC, const T &Arg)
Definition: Interp.h:294
This is an odr-use.
Definition: Specifiers.h:162
SourceLocation getOperatorLoc() const
getOperatorLoc - Return the location of the operator.
Definition: Expr.h:2080
const Expr * IgnoreImplicit() const
Definition: Expr.h:800
bool isCmpXChg() const
Definition: Expr.h:5925
StmtClass
Definition: Stmt.h:68
void setRParenLoc(SourceLocation R)
Definition: Expr.h:2307
SourceLocation getEndLoc() const
Definition: Expr.h:1974
static Classification makeSimpleLValue()
Create a simple, modifiably lvalue.
Definition: Expr.h:369
bool isExact() const
Definition: Expr.h:1630
GNUNullExpr(QualType Ty, SourceLocation Loc)
Definition: Expr.h:4215
child_range children()
Definition: Expr.h:3795
ConvertVectorExpr(Expr *SrcExpr, TypeSourceInfo *TI, QualType DstType, ExprValueKind VK, ExprObjectKind OK, SourceLocation BuiltinLoc, SourceLocation RParenLoc)
Definition: Expr.h:4078
SourceLocation getTokenLocation() const
getTokenLocation - The location of the __null token.
Definition: Expr.h:4224
llvm::APFloatBase::Semantics getRawSemantics() const
Get a raw enumeration value representing the floating-point semantics of this literal (32-bit IEEE...
Definition: Expr.h:1607
void setRParenLoc(SourceLocation L)
Definition: Expr.h:3401
uint64_t * pVal
Used to store the >64 bits integer value.
Definition: Expr.h:1406
const_child_range children() const
Definition: Expr.h:3886
arg_iterator arg_end()
Definition: Expr.h:2747
void setCastKind(CastKind K)
Definition: Expr.h:3197
NestedNameSpecifierLoc getQualifierLoc() const
If the member name was qualified, retrieves the nested-name-specifier that precedes the member name...
Definition: Expr.h:2938
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: Expr.h:2349
SourceLocation getEndLoc() const LLVM_READONLY
Definition: Expr.h:1642
Expr ** getSubExprs()
Retrieve the array of expressions.
Definition: Expr.h:4036
FullExpr(StmtClass SC, EmptyShell Empty)
Definition: Expr.h:960
ChooseExpr(SourceLocation BLoc, Expr *cond, Expr *lhs, Expr *rhs, QualType t, ExprValueKind VK, ExprObjectKind OK, SourceLocation RP, bool condIsTrue, bool TypeDependent, bool ValueDependent)
Definition: Expr.h:4136
Expr * getSubExpr()
Definition: Expr.h:2011
static bool classof(const Stmt *T)
Definition: Expr.h:5491
void setEqualOrColonLoc(SourceLocation L)
Definition: Expr.h:4865
SourceLocation getEllipsisLoc() const
Definition: Expr.h:4803
const Expr * getLHS() const
Definition: Expr.h:2498
void setArgument(Expr *E)
Definition: Expr.h:2424
QualType getTypeAsWritten() const
getTypeAsWritten - Returns the type that this expression is casting to, as written in the source code...
Definition: Expr.h:3360
void setTypeSourceInfo(TypeSourceInfo *tsi)
Definition: Expr.h:2312
static Opcode negateComparisonOp(Opcode Opc)
Definition: Expr.h:3530
SourceLocation getEndLoc() const
Definition: Expr.h:2514
static bool classof(const Stmt *T)
Definition: Expr.h:2805
const Expr * getExpr(unsigned Index) const
Definition: Expr.h:4043
ConditionalOperator - The ?: ternary operator.
Definition: Expr.h:3732
Expr * getScope() const
Definition: Expr.h:5887
void setField(FieldDecl *FD)
Definition: Expr.h:4776
StringRef getString() const
Definition: Expr.h:1794
ParenExpr(SourceLocation l, SourceLocation r, Expr *val)
Definition: Expr.h:1998
void setAmpAmpLoc(SourceLocation L)
Definition: Expr.h:3925
llvm::iterator_range< const_child_iterator > const_child_range
Definition: Stmt.h:1181
CompoundStmt - This represents a group of statements like { stmt stmt }.
Definition: Stmt.h:1332
Represents a prototype with parameter type info, e.g.
Definition: Type.h:3754
void setBlockDecl(BlockDecl *BD)
Definition: Expr.h:5595
bool isMicrosoftABI() const
Returns whether this is really a Win64 ABI va_arg expression.
Definition: Expr.h:4267
ArrayInitIndexExpr(QualType T)
Definition: Expr.h:5087
Expr ** getSubExprs()
Definition: Expr.h:5916
SubobjectAdjustment(FieldDecl *Field)
Definition: Expr.h:93
void copyTemplateArgumentsInto(TemplateArgumentListInfo &List) const
Copies the template arguments (if present) into the given structure.
Definition: Expr.h:2984
QualType getComputationLHSType() const
Definition: Expr.h:3677
CastKind
CastKind - The kind of operation required for a conversion.
NestedNameSpecifier * getQualifier() const
If the member name was qualified, retrieves the nested-name-specifier that precedes the member name...
Definition: Expr.h:2947
The return type of classify().
Definition: Expr.h:311
const_semantics_iterator semantics_begin() const
Definition: Expr.h:5786
Used by IntegerLiteral/FloatingLiteral to store the numeric without leaking memory.
Definition: Expr.h:1403
static std::unique_ptr< AtomicScopeModel > getScopeModel(AtomicOp Op)
Get atomic scope model for the atomic op code.
Definition: Expr.h:5960
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: Expr.h:2249
void setSubExpr(Expr *E)
Definition: Expr.h:2077
UnaryExprOrTypeTraitExpr - expression with either a type or (unevaluated) expression operand...
Definition: Expr.h:2372
iterator end()
Definition: ASTVector.h:99
void setLParen(SourceLocation Loc)
Definition: Expr.h:2019
llvm::APInt getIntValue() const
Definition: Expr.h:1418
SourceLocation getLocation() const
Definition: Expr.h:1255
InitListExpr * getUpdater() const
Definition: Expr.h:4995
ConditionalOperator(Expr *cond, SourceLocation QLoc, Expr *lhs, SourceLocation CLoc, Expr *rhs, QualType t, ExprValueKind VK, ExprObjectKind OK)
Definition: Expr.h:3738
ConstantExpr - An expression that occurs in a constant context and optionally the result of evaluatin...
Definition: Expr.h:978
bool HasUndefinedBehavior
Whether the evaluation hit undefined behavior.
Definition: Expr.h:564
Represents a call to the builtin function __builtin_va_arg.
Definition: Expr.h:4244
Kinds
The various classification results. Most of these mean prvalue.
Definition: Expr.h:314
SourceLocation getEndLoc() const LLVM_READONLY
Definition: Expr.h:2144
unsigned Offset
Definition: Format.cpp:1827
unsigned getValue() const
Definition: Expr.h:1564
AssociationIteratorTy< true > ConstAssociationIterator
Definition: Expr.h:5396
Exposes information about the current target.
Definition: TargetInfo.h:164
Expr * getSrcExpr() const
getSrcExpr - Return the Expr to be converted.
Definition: Expr.h:5665
CompoundAssignOperator(Expr *lhs, Expr *rhs, Opcode opc, QualType ResType, ExprValueKind VK, ExprObjectKind OK, QualType CompLHSType, QualType CompResultType, SourceLocation OpLoc, FPOptions FPFeatures)
Definition: Expr.h:3658
llvm::APSInt getShuffleMaskIdx(const ASTContext &Ctx, unsigned N) const
Definition: Expr.h:4050
ADLCallKind getADLCallKind() const
Definition: Expr.h:2667
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: Expr.h:4023
const_child_range children() const
Definition: Expr.h:2155
SourceLocation getEndLoc() const LLVM_READONLY
Definition: Expr.h:3975
void setLocation(SourceLocation Location)
Definition: Expr.h:1566
Expr * getCond() const
Definition: Expr.h:3769
const_arg_range arguments() const
Definition: Expr.h:2740
Represents a block literal declaration, which is like an unnamed FunctionDecl.
Definition: Decl.h:4037
llvm::MutableArrayRef< Designator > designators()
Definition: Expr.h:4842
static bool classof(const Stmt *T)
Definition: Expr.h:1889
DeclAccessPair getFoundDecl() const
Retrieves the declaration found by lookup.
Definition: Expr.h:2923
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
Definition: Decl.h:619
This represents one expression.
Definition: Expr.h:108
Defines the clang::LangOptions interface.
void setRBraceLoc(SourceLocation Loc)
Definition: Expr.h:4553
SourceLocation End
const_child_range children() const
Definition: Expr.h:4059
ExprValueKind
The categorization of expression values, currently following the C++11 scheme.
Definition: Specifiers.h:122
child_range children()
Definition: Expr.h:4056
void setCallee(Expr *F)
Definition: Expr.h:2665
llvm::iterator_range< ConstAssociationIterator > const_association_range
Definition: Expr.h:5399
std::string Label
const Expr * getSyntacticForm() const
Definition: Expr.h:5760
const_child_range children() const
Definition: Expr.h:5070
CXXBaseSpecifier * getBase() const
For a base class node, returns the base specifier.
Definition: Expr.h:2237
void setRParenLoc(SourceLocation L)
Definition: Expr.h:4021
const Expr * getRHS() const
Definition: Expr.h:2502
friend TrailingObjects
Definition: Expr.h:1019
const AnnotatedLine * Line
static bool classof(const Stmt *T)
Definition: Expr.h:1381
void setBase(Expr *Base)
Definition: Expr.h:4993
void setSyntacticForm(InitListExpr *Init)
Definition: Expr.h:4566
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:3060
SourceLocation getEndLoc() const LLVM_READONLY
Definition: Expr.h:3128
SourceLocation getEndLoc() const LLVM_READONLY
Definition: Expr.h:1681
void setMemberLoc(SourceLocation L)
Definition: Expr.h:3026
NoInitExpr(QualType ty)
Definition: Expr.h:4939
void setTypeDependent(bool TD)
Set whether this expression is type-dependent or not.
Definition: Expr.h:179
#define V(N, I)
Definition: ASTContext.h:2941
__UINTPTR_TYPE__ uintptr_t
An unsigned integer type with the property that any valid pointer to void can be converted to this ty...
Definition: opencl-c-base.h:62
BlockExpr - Adaptor class for mixing a BlockDecl with expressions.
Definition: Expr.h:5579
Expr * getCallee()
Definition: Expr.h:2663
unsigned getNumInits() const
Definition: Expr.h:4433
static bool classof(const Stmt *T)
Definition: Expr.h:4911
void setExprAndFlag(Expr *CopyExpr, bool CanThrow)
Definition: Expr.h:5631
Expr * getSubExpr() const
Get the initializer to use for each array element.
Definition: Expr.h:5049
SourceLocation getBeginLoc() const
Definition: Expr.h:1973
const Expr * getCallee() const
Definition: Expr.h:2664
void setRHS(Expr *E)
Definition: Expr.h:3477
SourceLocation getEndLoc() const LLVM_READONLY
Definition: Expr.h:5818
An array or GNU array-range designator, e.g., "[9]" or "[10..15]".
Definition: Expr.h:4695
Stmt * getPreArg(unsigned I)
Definition: Expr.h:2614
const Expr * skipRValueSubobjectAdjustments() const
Definition: Expr.h:928
void setTypeSourceInfo(TypeSourceInfo *ti)
Definition: Expr.h:4097
const_iterator end() const
Definition: Expr.h:4609
const_child_range children() const
Definition: Expr.h:1897
QualType getArgumentType() const
Definition: Expr.h:2409
#define bool
Definition: stdbool.h:15
struct DTB DerivedToBase
Definition: Expr.h:81
const Expr * IgnoreConversionOperator() const
Definition: Expr.h:852
bool performsVirtualDispatch(const LangOptions &LO) const
Returns true if virtual dispatch is performed.
Definition: Expr.h:3054
void setWrittenTypeInfo(TypeSourceInfo *TI)
Definition: Expr.h:4271
Expr * getOrder() const
Definition: Expr.h:5884
child_range children()
Definition: Expr.h:5198
SourceLocation getLParenLoc() const
Definition: Expr.h:5188
const Expr * IgnoreImplicitAsWritten() const
Definition: Expr.h:810
ParenExpr(EmptyShell Empty)
Construct an empty parenthesized expression.
Definition: Expr.h:2007
uint32_t getCodeUnit(size_t i) const
Definition: Expr.h:1809
void setObjectKind(ExprObjectKind Cat)
setObjectKind - Set the object kind produced by this expression.
Definition: Expr.h:434
bool hasQualifier() const
Determine whether this declaration reference was preceded by a C++ nested-name-specifier, e.g., N::foo.
Definition: Expr.h:1262
Expr * getSubExpr()
Definition: Expr.h:4263
SourceLocation Begin
TypeSourceInfo * getTypeSourceInfo() const
Definition: Expr.h:2309
unsigned size() const
Returns the number of designators in this initializer.
Definition: Expr.h:4839
AsTypeExpr - Clang builtin function __builtin_astype [OpenCL 6.2.4.2] This AST node provides support ...
Definition: Expr.h:5642
const_child_range children() const
Definition: Expr.h:3798
FunctionDecl * getDirectCallee()
If the callee is a FunctionDecl, return it. Otherwise return null.
Definition: Expr.h:2681
bool refersToEnclosingVariableOrCapture() const
Does this DeclRefExpr refer to an enclosing local or a captured variable?
Definition: Expr.h:1377
IdentifierInfo & getAccessor() const
Definition: Expr.h:5540
static bool EvaluateAsBooleanCondition(const Expr *E, bool &Result, EvalInfo &Info)
BinaryOperator(Expr *lhs, Expr *rhs, Opcode opc, QualType ResTy, ExprValueKind VK, ExprObjectKind OK, SourceLocation opLoc, FPOptions FPFeatures, bool dead2)
Definition: Expr.h:3626
const ValueDecl * getDecl() const
Definition: Expr.h:1248
ArrayRef< Expr * > inits()
Definition: Expr.h:4443
ArraySubscriptExpr(EmptyShell Shell)
Create an empty array subscript expression.
Definition: Expr.h:2485
child_range children()
Definition: Expr.h:1894
Specifies that a value-dependent expression of integral or dependent type should be considered a null...
Definition: Expr.h:739
Extra data stored in some MemberExpr objects.
Definition: Expr.h:2824
Kind getKind() const
Determine what kind of offsetof node this is.
Definition: Expr.h:2217
SourceLocation getLAngleLoc() const
Retrieve the location of the left angle bracket starting the explicit template argument list followin...
Definition: Expr.h:2961
QualType getType() const
Definition: Expr.h:137
ArrayRef< Expr * > getAssocExprs() const
Definition: Expr.h:5435
QualType getTypeOfArgument() const
Gets the argument type, or the type of the argument expression, whichever is appropriate.
Definition: Expr.h:2435
bool isVolatile() const
Definition: Expr.h:5921
bool isWide() const
Definition: Expr.h:1831
const_semantics_iterator semantics_end() const
Definition: Expr.h:5792
void setValueKind(ExprValueKind Cat)
setValueKind - Set the value kind produced by this expression.
Definition: Expr.h:431
SourceLocation getEndLoc() const LLVM_READONLY
Definition: Expr.h:5943
static OMPLinearClause * CreateEmpty(const ASTContext &C, unsigned NumVars)
Creates an empty clause with the place for NumVars variables.
SourceLocation getRParenLoc() const
getRParenLoc - Return the location of final right parenthesis.
Definition: Expr.h:5671
void setMemberDecl(ValueDecl *D)
Definition: Expr.h:2920
const_child_range children() const
Definition: Expr.h:5202
const_child_range children() const
Definition: Expr.h:5620
ModifiableType
The results of modification testing.
Definition: Expr.h:329
void setRParenLoc(SourceLocation L)
Definition: Expr.h:4186
SourceLocation getLBracketLoc() const
Definition: Expr.h:4791
SourceLocation getRBracketLoc() const
Definition: Expr.h:2516
SourceLocation getEnd() const
const_child_range children() const
Definition: Expr.h:3943
UnaryOperator - This represents the unary-expression&#39;s (except sizeof and alignof), the postinc/postdec operators from postfix-expression, and various extensions.
Definition: Expr.h:2046
unsigned Index
Location of the first index expression within the designated initializer expression&#39;s list of subexpr...
Definition: Expr.h:4698
SourceLocation getMemberLoc() const
getMemberLoc - Return the location of the "member", in X->F, it is the location of &#39;F&#39;...
Definition: Expr.h:3025
const_child_range children() const
Definition: Expr.h:1484
bool usesGNUSyntax() const
Determines whether this designated initializer used the deprecated GNU syntax for designated initiali...
Definition: Expr.h:4873
static bool CanThrow(Expr *E, ASTContext &Ctx)
Definition: CFG.cpp:2580
AtomicOp getOp() const
Definition: Expr.h:5913
static bool EvaluateAsInt(const Expr *E, Expr::EvalResult &ExprResult, const ASTContext &Ctx, Expr::SideEffectsKind AllowSideEffects, EvalInfo &Info)
ArrayRef< Expr * > inits() const
Definition: Expr.h:4447
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: Expr.h:4815
SourceLocation getEndLoc() const LLVM_READONLY
Definition: Expr.h:3874
const_arg_iterator arg_end() const
Definition: Expr.h:2752
SourceLocation getEndLoc() const LLVM_READONLY
Definition: Expr.h:3404
const OffsetOfNode & getComponent(unsigned Idx) const
Definition: Expr.h:2316
Expr * getTrueExpr() const
getTrueExpr - Return the subexpression which will be evaluated if the condition evaluates to true; th...
Definition: Expr.h:3860
SourceLocation getTemplateKeywordLoc() const
Retrieve the location of the template keyword preceding this name, if any.
Definition: Expr.h:1300
static bool classof(const Stmt *T)
Definition: Expr.h:3724
ValueDecl * getDecl()
Definition: Expr.h:1247
child_range children()
Definition: Expr.h:5950
SourceLocation getLocation() const
Definition: Expr.h:1955
child_range children()
Definition: Expr.h:1060
SourceLocation getRParenLoc() const
Definition: Expr.h:4276
The result type of a method or function.
Designator(unsigned Index, SourceLocation LBracketLoc, SourceLocation EllipsisLoc, SourceLocation RBracketLoc)
Initializes a GNU array-range designator.
Definition: Expr.h:4753
const Expr * getSubExpr() const
Definition: Expr.h:2010
CStyleCastExpr - An explicit cast in C (C99 6.5.4) or a C-style cast in C++ (C++ [expr.cast]), which uses the syntax (Type)expr.
Definition: Expr.h:3371
llvm::iterator_range< semantics_iterator > semantics()
Definition: Expr.h:5796
bool isNull() const
Return true if this QualType doesn&#39;t point to a type yet.
Definition: Type.h:719
Expr * getLHS()
An array access can be written A[4] or 4[A] (both are equivalent).
Definition: Expr.h:2497
reverse_iterator rend()
Definition: ASTVector.h:105
static bool classof(const Stmt *T)
Definition: Expr.h:1143
bool hadMultipleCandidates() const
Returns true if this expression refers to a function that was resolved from an overloaded set having ...
Definition: Expr.h:1360
const_child_range children() const
Definition: Expr.h:1525
const SourceManager & SM
Definition: Format.cpp:1685
const_child_range children() const
Definition: Expr.h:4116
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: Expr.h:5815
ExplicitCastExpr(StmtClass SC, QualType exprTy, ExprValueKind VK, CastKind kind, Expr *op, unsigned PathSize, TypeSourceInfo *writtenTy)
Definition: Expr.h:3343
child_range children()
Definition: Expr.h:3069
ImaginaryLiteral - We support imaginary integer and floating point literals, like "1...
Definition: Expr.h:1662
SourceLocation getEndLoc() const LLVM_READONLY
Definition: Expr.h:4280
ArrayRef< TypeSourceInfo * > getAssocTypeSourceInfos() const
Definition: Expr.h:5440
SourceLocation getEndLoc() const LLVM_READONLY
Definition: Stmt.cpp:288
void setRParenLoc(SourceLocation L)
Definition: Expr.h:4277
bool isDecrementOp() const
Definition: Expr.h:2115
ExprObjectKind getObjectKind() const
getObjectKind - The object kind that this expression produces.
Definition: Expr.h:421
static bool classof(const Stmt *T)
Definition: Expr.h:5999
SideEffectsKind
Definition: Expr.h:611
llvm::iterator_range< AssociationIterator > association_range
Definition: Expr.h:5397
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: Expr.h:1034
static bool isCommaOp(Opcode Opc)
Definition: Expr.h:3527
bool isComparisonOp() const
Definition: Expr.h:3525
llvm::iterator_range< path_iterator > path()
Definition: Expr.h:3227
static bool isBitwiseOp(Opcode Opc)
Definition: Expr.h:3515
const_child_range children() const
Definition: Expr.h:5953
static bool classof(const Stmt *T)
Definition: Expr.h:1515
Copy initialization expr of a __block variable and a boolean flag that indicates whether the expressi...
Definition: Expr.h:5627
void setTypeSourceInfo(TypeSourceInfo *tinfo)
Definition: Expr.h:3116
bool isCommaOp() const
Definition: Expr.h:3528
static bool classof(const Stmt *T)
Definition: Expr.h:5676
unsigned DotLoc
The location of the &#39;.&#39; in the designated initializer.
Definition: Expr.h:4688
UnaryExprOrTypeTraitExpr(UnaryExprOrTypeTrait ExprKind, TypeSourceInfo *TInfo, QualType resultType, SourceLocation op, SourceLocation rp)
Definition: Expr.h:2380
OpaqueValueExpr - An expression referring to an opaque object of a fixed type and value class...
Definition: Expr.h:1075
void setComputationLHSType(QualType T)
Definition: Expr.h:3678
Expr * getBase() const
Definition: Expr.h:4992
ConvertVectorExpr - Clang builtin function __builtin_convertvector This AST node provides support for...
Definition: Expr.h:4067
const Stmt * getPreArg(unsigned I) const
Definition: Expr.h:2618
#define false
Definition: stdbool.h:17
SourceLocation getLParenLoc() const
Definition: Expr.h:3110
Kind
DesignatedInitUpdateExpr(EmptyShell Empty)
Definition: Expr.h:4982
unsigned path_size() const
Definition: Expr.h:3221
PseudoObjectExpr - An expression which accesses a pseudo-object l-value.
Definition: Expr.h:5715
void setLParenLoc(SourceLocation L)
Definition: Expr.h:3398
SmallVector< CXXBaseSpecifier *, 4 > CXXCastPath
A simple array of base specifiers.
Definition: Expr.h:56
bool isInstantiationDependent() const
Whether this expression is instantiation-dependent, meaning that it depends in some way on a template...
Definition: Expr.h:200
friend TrailingObjects
Definition: Expr.h:5838
const CompoundStmt * getSubStmt() const
Definition: Expr.h:3971
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: Expr.h:1678
SourceLocation getRAngleLoc() const
Retrieve the location of the right angle bracket ending the explicit template argument list following...
Definition: Expr.h:1316
ConstExprIterator const_arg_iterator
Definition: Expr.h:2735
SourceLocation getEndLoc() const LLVM_READONLY
Definition: Expr.h:2350
void setAccessorLoc(SourceLocation L)
Definition: Expr.h:5544
const_child_range children() const
Definition: Expr.h:1121
SourceLocation getEndLoc() const LLVM_READONLY
Definition: Expr.h:2250
SourceLocation getRAngleLoc() const
Retrieve the location of the right angle bracket ending the explicit template argument list following...
Definition: Expr.h:2969
StringLiteral * getFunctionName()
Definition: Expr.h:1958
SourceLocation getEndLoc() const
Definition: Expr.h:5489
const_child_range children() const
Definition: Expr.h:1061
unsigned getNumExprs() const
Return the number of expressions in this paren list.
Definition: Expr.h:5169
void setLocation(SourceLocation L)
Definition: Expr.h:1256
Encodes a location in the source.
void setLocation(SourceLocation L)
Definition: Expr.h:1956
void setValue(const ASTContext &C, const llvm::APFloat &Val)
Definition: Expr.h:1441
SourceLocation getEndLoc() const LLVM_READONLY
Definition: Expr.h:1887
MutableArrayRef< Expr * > getInits()
const NamedDecl * getFoundDecl() const
Get the NamedDecl through which this reference occurred.
Definition: Expr.h:1290
SourceLocation getOperatorLoc() const
Definition: Expr.h:3466
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: Expr.h:5602
llvm::APSInt APSInt
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: Expr.h:5557
Expr * getSubExpr() const
Definition: Expr.h:2076
const Decl * getReferencedDeclOfCallee() const
Definition: Expr.h:462
SourceLocation getLAngleLoc() const
Retrieve the location of the left angle bracket starting the explicit template argument list followin...
Definition: Expr.h:1308
void setUpdater(Expr *Updater)
Definition: Expr.h:4998
SourceLocation getBuiltinLoc() const
getBuiltinLoc - Return the location of the __builtin_astype token.
Definition: Expr.h:5668
NoInitExpr(EmptyShell Empty)
Definition: Expr.h:4943
CastKind getCastKind() const
Definition: Expr.h:3196
Expr * getSubExpr(unsigned Idx) const
Definition: Expr.h:4891
child_range children()
Definition: Expr.h:4287
const Expr *const * getArgs() const
Definition: Expr.h:2696
pointer data()
data - Return a pointer to the vector&#39;s buffer, even if empty().
Definition: ASTVector.h:153
bool isModifiable() const
Definition: Expr.h:366
static bool isPlaceholderTypeKind(Kind K)
Determines whether the given kind corresponds to a placeholder type.
Definition: Type.h:2525
static bool classof(const Stmt *T)
Definition: Expr.h:4110
Represents the declaration of a label.
Definition: Decl.h:451
static bool classof(const Stmt *T)
Definition: Expr.h:3064
void setLabelLoc(SourceLocation L)
Definition: Expr.h:3927
const Expr * getExpr(unsigned Init) const
Definition: Expr.h:5176
ExprObjectKind
A further classification of the kind of object referenced by an l-value or x-value.
Definition: Specifiers.h:139
std::pair< SourceLocation, PartialDiagnostic > PartialDiagnosticAt
A partial diagnostic along with the source location where this diagnostic occurs. ...
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: Expr.h:2511
SourceLocation getStrTokenLoc(unsigned TokNum) const
Get one of the string literal token.
Definition: Expr.h:1858
const Expr * IgnoreParenCasts() const
Definition: Expr.h:845
child_range children()
Definition: Expr.h:2357
StmtExpr(EmptyShell Empty)
Build an empty statement expression.
Definition: Expr.h:3968
bool canOverflow() const
Returns true if the unary operator can cause an overflow.
Definition: Expr.h:2089
CompoundAssignOperator(EmptyShell Empty)
Build an empty compound assignment operator expression.
Definition: Expr.h:3671
SourceLocation getRParenLoc() const
Definition: Expr.h:3979
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
void setLHS(Expr *E)
Definition: Expr.h:3475
static bool classof(const Stmt *T)
Definition: Expr.h:939
bool isPascal() const
Definition: Expr.h:1835
SourceLocation getEndLoc() const LLVM_READONLY
Definition: Expr.h:1037
uint64_t VAL
Used to store the <= 64 bits integer value.
Definition: Expr.h:1405
const Expr * getSubExprAsWritten() const
Definition: Expr.h:3210
static bool classof(const Stmt *T)
Definition: Expr.h:3135
const Expr * getArgumentExpr() const
Definition: Expr.h:2420
AtomicExpr - Variadic atomic builtins: __atomic_exchange, __atomic_fetch_*, __atomic_load, __atomic_store, and __atomic_compare_exchange_*, for the similarly-named C++11 instructions, and __c11 variants for <stdatomic.h>, and corresponding __opencl_atomic_* for OpenCL 2.0.
Definition: Expr.h:5849
UnaryExprOrTypeTrait getKind() const
Definition: Expr.h:2403
child_range children()
Definition: Expr.h:5681
const_child_range children() const
Definition: Expr.h:5992
const Expr * IgnoreParenNoopCasts(const ASTContext &Ctx) const
Definition: Expr.h:876
Expr * getExpr(unsigned Init)
Definition: Expr.h:5171
const_reverse_iterator rbegin() const
Definition: Expr.h:4611
bool isValueDependent() const
isValueDependent - Determines whether this expression is value-dependent (C++ [temp.dep.constexpr]).
Definition: Expr.h:158
static bool classof(const Stmt *T)
Definition: Expr.h:4230
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: Expr.h:1886
SourceLocation getLParenLoc() const
Definition: Expr.h:3977
const_child_range children() const
Definition: Expr.h:3988
void setDecl(ValueDecl *NewD)
Definition: Expr.h:1249
arg_range arguments()
Definition: Expr.h:2739
void setArgument(TypeSourceInfo *TInfo)
Definition: Expr.h:2428
SourceLocation getEndLoc() const LLVM_READONLY
Definition: Expr.h:3786
llvm::APInt APInt
Definition: Integral.h:27
ImplicitCastExpr - Allows us to explicitly represent implicit type conversions, which have no direct ...
Definition: Expr.h:3274
Expr ** getInits()
Retrieve the set of initializers.
Definition: Expr.h:4436
bool isLValue() const
isLValue - True if this expression is an "l-value" according to the rules of the current language...
Definition: Expr.h:258
CharacterKind getKind() const
Definition: Expr.h:1557
static bool classof(const Stmt *T)
Definition: Expr.h:5945
InitListExpr(EmptyShell Empty)
Build an empty initializer list.
Definition: Expr.h:4430
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: Expr.h:1507
AtomicExpr(EmptyShell Empty)
Build an empty AtomicExpr.
Definition: Expr.h:5879
Expr * getSubExpr()
Definition: Expr.h:1675
bool isRValue() const
Definition: Expr.h:365
static bool isLogicalOp(Opcode Opc)
Definition: Expr.h:3557
const_child_range children() const
Definition: Expr.h:3070
friend TrailingObjects
Definition: Expr.h:2366
Expr ** getExprs()
Definition: Expr.h:5180
ArrayRef< Expr * > exprs()
Definition: Expr.h:5184
child_range children()
Definition: Expr.h:5495
uintptr_t NameOrField
Refers to the field that is being initialized.
Definition: Expr.h:4685
StmtExpr - This is the GNU Statement Expression extension: ({int X=4; X;}).
Definition: Expr.h:3954
OpaqueValueExpr(EmptyShell Empty)
Definition: Expr.h:1101
unsigned LBracketLoc
The location of the &#39;[&#39; starting the array range designator.
Definition: Expr.h:4700
child_range children()
Definition: Expr.h:4916
path_const_iterator path_end() const
Definition: Expr.h:3225
bool isArgumentType() const
Definition: Expr.h:2408
const SourceLocation * tokloc_iterator
Definition: Expr.h:1876
static bool classof(const Stmt *T)
Definition: Expr.h:970
Expr * getArrayFiller()
If this initializer list initializes an array with more elements than there are initializers in the l...
Definition: Expr.h:4497
void setSubExpr(Expr *E)
Definition: Expr.h:4264
void sawArrayRangeDesignator(bool ARD=true)
Definition: Expr.h:4576
bool isPartOfExplicitCast() const
Definition: Expr.h:3293
SourceLocation getEndLoc() const LLVM_READONLY
Definition: Expr.h:3309
SourceLocation getBeginLoc() const
Definition: Expr.h:5488
Defines the fixed point number interface.
A placeholder type used to construct an empty shell of a type, that will be filled in later (e...
Definition: Stmt.h:1056
SourceLocation getExprLoc() const LLVM_READONLY
getExprLoc - Return the preferred location for the arrow when diagnosing a problem with a generic exp...
Definition: Expr.cpp:224
bool hasTemplateKeyword() const
Determines whether the name in this declaration reference was preceded by the template keyword...
Definition: Expr.h:1324
NonOdrUseReason isNonOdrUse() const
Is this expression a non-odr-use reference, and if so, why?
Definition: Expr.h:1371
const Expr * getInitializer() const
Definition: Expr.h:3103
Expr * getLHS() const
Definition: Expr.h:3474
CompoundAssignOperator - For compound assignments (e.g.
Definition: Expr.h:3654
A POD class for pairing a NamedDecl* with an access specifier.
DeclarationNameLoc - Additional source/type location info for a declaration name. ...
Represents a C11 generic selection.
Definition: Expr.h:5234
VAArgExpr(SourceLocation BLoc, Expr *e, TypeSourceInfo *TInfo, SourceLocation RPLoc, QualType t, bool IsMS)
Definition: Expr.h:4249
const Expr * getBase() const
Definition: Expr.h:5536
EvalStatus is a struct with detailed info about an evaluation in progress.
Definition: Expr.h:556
Expr * getSubExpr()
Definition: Expr.h:964
ArrayInitLoopExpr(QualType T, Expr *CommonInit, Expr *ElementInit)
Definition: Expr.h:5034
AddrLabelExpr - The GNU address of label extension, representing &&label.
Definition: Expr.h:3910
Expr * getResultExpr()
Return the result-bearing expression, or null if there is none.
Definition: Expr.h:5770
Expr(StmtClass SC, EmptyShell)
Construct an empty expression.
Definition: Expr.h:134
OpaqueValueExpr * getOpaqueValue() const
getOpaqueValue - Return the opaque value placeholder.
Definition: Expr.h:3851
void setSemantics(const llvm::fltSemantics &Sem)
Set the APFloat semantics this literal uses.
Definition: Expr.h:1626
bool isStringType() const
Definition: Expr.h:4320
const FieldDecl * getTargetUnionField() const
Definition: Expr.h:3234
const FieldDecl * getInitializedFieldInUnion() const
Definition: Expr.h:4518
static bool classof(const Stmt *T)
Definition: Expr.h:4946
Expr * getFalseExpr() const
getFalseExpr - Return the subexpression which will be evaluated if the condnition evaluates to false;...
Definition: Expr.h:3867
BinaryOperator(StmtClass SC, EmptyShell Empty)
Definition: Expr.h:3643
void setLocation(SourceLocation L)
Definition: Expr.h:1639
SourceLocation getExprLoc() const LLVM_READONLY
Definition: Expr.h:1113
static bool classof(const Stmt *T)
Definition: Expr.h:3790
OffsetOfNode(SourceLocation DotLoc, FieldDecl *Field, SourceLocation NameLoc)
Create an offsetof node that refers to a field.
Definition: Expr.h:2202
iterator begin()
Definition: Expr.h:4606
unsigned getNumAssocs() const
The number of association expressions.
Definition: Expr.h:5402
Dataflow Directional Tag Classes.
bool isResultDependent() const
Whether this generic selection is result-dependent.
Definition: Expr.h:5414
bool isValid() const
Return true if this is a valid SourceLocation object.
bool hasSideEffects() const
Definition: Expr.h:580
tokloc_iterator tokloc_begin() const
Definition: Expr.h:1878
void setBuiltinLoc(SourceLocation L)
Definition: Expr.h:4183
const TemplateArgumentLoc * getTemplateArgs() const
Retrieve the template arguments provided as part of this template-id.
Definition: Expr.h:2992
[C99 6.4.2.2] - A predefined identifier such as func.
Definition: Expr.h:1903
DeclarationNameInfo getMemberNameInfo() const
Retrieve the member declaration name info.
Definition: Expr.h:3013
UnaryOperatorKind
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
Definition: DeclBase.h:1271
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: Expr.h:5942
EvalResult is a struct with detailed info about an evaluated expression.
Definition: Expr.h:586
std::reverse_iterator< iterator > reverse_iterator
Definition: ASTVector.h:89
OverloadedOperatorKind
Enumeration specifying the different kinds of C++ overloaded operators.
Definition: OperatorKinds.h:21
void setRParenLoc(SourceLocation L)
Definition: Expr.h:2790
UnaryOperatorKind Opcode
Definition: Expr.h:2050
ModifiableType getModifiable() const
Definition: Expr.h:357
void setLabel(LabelDecl *L)
Definition: Expr.h:3933
bool isExplicit() const
Definition: Expr.h:4533
static bool isShiftAssignOp(Opcode Opc)
Definition: Expr.h:3579
bool isShiftOp() const
Definition: Expr.h:3513
void setTypeInfoAsWritten(TypeSourceInfo *writtenTy)
Definition: Expr.h:3356
const_child_range children() const
Definition: Expr.h:4346
BinaryConditionalOperator(EmptyShell Empty)
Build an empty conditional operator.
Definition: Expr.h:3842
Reads an AST files chain containing the contents of a translation unit.
Definition: ASTReader.h:340
A field designator, e.g., ".x".
Definition: Expr.h:4678
InitExprsTy::reverse_iterator reverse_iterator
Definition: Expr.h:4603
void setIsUnique(bool V)
Definition: Expr.h:1135
ExtVectorElementExpr(QualType ty, ExprValueKind VK, Expr *base, IdentifierInfo &accessor, SourceLocation loc)
Definition: Expr.h:5523
child_range children()
Definition: Expr.h:2030
void setSubExpr(Expr *E)
Definition: Expr.h:1676
void setSubExpr(Expr *E)
Definition: Expr.h:3204
bool isOpenCL() const
Definition: Expr.h:5934
AccessSpecifier getAccess() const
Definition: DeclBase.h:473
void setFileScope(bool FS)
Definition: Expr.h:3108
void setExact(bool E)
Definition: Expr.h:1631
OpaqueValueExpr(SourceLocation Loc, QualType T, ExprValueKind VK, ExprObjectKind OK=OK_Ordinary, Expr *SourceExpr=nullptr)
Definition: Expr.h:1080
child_range children()
Definition: Expr.h:5571
const Decl * getCalleeDecl() const
Definition: Expr.h:2676
const FieldDecl * getSourceBitField() const
Definition: Expr.h:457
bool usesADL() const
Definition: Expr.h:2673
SourceLocation getLBraceLoc() const
Definition: Expr.h:4550
StmtClass getStmtClass() const
Definition: Stmt.h:1109
const char * getCastKindName() const
Definition: Expr.h:3200
const_child_range children() const
Definition: Expr.h:5828
const Expr * getArrayFiller() const
Definition: Expr.h:4500
Expression is a Null pointer constant built from a zero integer expression that is not a simple...
Definition: Expr.h:719
Kinds getKind() const
Definition: Expr.h:356
llvm::iterator_range< const_semantics_iterator > semantics() const
Definition: Expr.h:5799
void setInstantiationDependent(bool ID)
Set whether this expression is instantiation-dependent or not.
Definition: Expr.h:205
const T * const_iterator
Definition: ASTVector.h:86
Kind
The kind of offsetof node we have.
Definition: Expr.h:2166
Expression is a C++11 nullptr.
Definition: Expr.h:725
OffsetOfNode(SourceLocation DotLoc, IdentifierInfo *Name, SourceLocation NameLoc)
Create an offsetof node that refers to an identifier.
Definition: Expr.h:2207
A pointer to member type per C++ 8.3.3 - Pointers to members.
Definition: Type.h:2833
SourceLocation getEndLoc() const LLVM_READONLY
Definition: Expr.h:1508
const Expr * getSubExpr() const
Definition: Expr.h:3203
VAArgExpr(EmptyShell Empty)
Create an empty __builtin_va_arg expression.
Definition: Expr.h:4259
semantics_iterator semantics_begin()
Definition: Expr.h:5783
void setLParenLoc(SourceLocation L)
Definition: Expr.h:3978
SourceLocation getBeginLoc() const
Definition: Expr.h:4339
ExplicitCastExpr - An explicit cast written in the source code.
Definition: Expr.h:3337
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspnd...
static bool isPrefix(Opcode Op)
isPrefix - Return true if this is a prefix operation, like –x.
Definition: Expr.h:2098
void setInitializedFieldInUnion(FieldDecl *FD)
Definition: Expr.h:4521
static bool classof(const Stmt *T)
Definition: Expr.h:4191
bool isPtrMemOp() const
Definition: Expr.h:3504
ExplicitCastExpr(StmtClass SC, EmptyShell Shell, unsigned PathSize)
Construct an empty explicit cast.
Definition: Expr.h:3349
llvm::APInt getValue() const
Definition: Expr.h:1430
unsigned getNumSubExprs() const
Definition: Expr.h:5914
LabelDecl * getLabel() const
Definition: Expr.h:3932
void setRBracketLoc(SourceLocation L)
Definition: Expr.h:2519
path_iterator path_end()
Definition: Expr.h:3223
static bool EvaluateAsFixedPoint(const Expr *E, Expr::EvalResult &ExprResult, const ASTContext &Ctx, Expr::SideEffectsKind AllowSideEffects, EvalInfo &Info)
bool hasPlaceholderType(BuiltinType::Kind K) const
Returns whether this expression has a specific placeholder type.
Definition: Expr.h:486
unsigned getByteLength() const
Definition: Expr.h:1822
static bool classof(const Stmt *T)
Definition: Expr.h:4026
SourceLocation getFieldLoc() const
Definition: Expr.h:4786
ConstAssociation getAssociation(unsigned I) const
Definition: Expr.h:5454
Expr * getOrderFail() const
Definition: Expr.h:5897
DeclarationNameInfo getNameInfo() const
Definition: Expr.h:1251
bool HasSideEffects
Whether the evaluated expression has side effects.
Definition: Expr.h:559
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:3046
Location wrapper for a TemplateArgument.
Definition: TemplateBase.h:449
Iterator for iterating over Stmt * arrays that contain only T *.
Definition: Stmt.h:1064
SourceLocation getBuiltinLoc() const
Definition: Expr.h:4017
CompoundLiteralExpr(SourceLocation lparenloc, TypeSourceInfo *tinfo, QualType T, ExprValueKind VK, Expr *init, bool fileScope)
Definition: Expr.h:3089
SourceLocation getEndLoc() const LLVM_READONLY
Definition: Expr.h:1469
static bool classof(const Stmt *S)
Definition: Expr.h:3683
const_child_range children() const
Definition: Expr.h:5572
ArraySubscriptExpr - [C99 6.5.2.1] Array Subscripting.
Definition: Expr.h:2462
bool isUTF32() const
Definition: Expr.h:1834
static bool classof(const Stmt *S)
Definition: Expr.h:3592
AbstractConditionalOperator - An abstract base class for ConditionalOperator and BinaryConditionalOpe...
Definition: Expr.h:3690
child_range children()
Definition: Expr.h:5989
llvm::iterator_range< path_const_iterator > path() const
Definition: Expr.h:3230
llvm::PointerIntPair< Expr *, 1, bool > ExprAndFlag
Definition: Expr.h:5636
arg_iterator arg_begin()
Definition: Expr.h:2744
const_child_range children() const
Definition: Expr.h:1390
void setIndexExpr(unsigned Idx, Expr *E)
Definition: Expr.h:2340
SourceLocation getLocation() const
Retrieve the location of this expression.
Definition: Expr.h:1105
friend TrailingObjects
Definition: OpenMPClause.h:98
const Expr * IgnoreImpCasts() const
Definition: Expr.h:779
child_range children()
Definition: Expr.h:1688
SourceLocation getEndLoc() const
Definition: Expr.h:5191
Expr * getCond() const
getCond - Return the condition expression; this is defined in terms of the opaque value...
Definition: Expr.h:3855
SourceLocation getRParenLoc() const
Definition: Expr.h:4185
bool isUnique() const
Definition: Expr.h:1141
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: Expr.h:4188
static bool classof(const Stmt *T)
Definition: Expr.h:1644
FieldDecl * getField() const
Definition: Expr.h:4768
const_child_range children() const
Definition: Expr.h:3601
SourceLocation getEndLoc() const LLVM_READONLY
Definition: Expr.h:5674
ImaginaryLiteral(Expr *val, QualType Ty)
Definition: Expr.h:1665
void setKind(UnaryExprOrTypeTrait K)
Definition: Expr.h:2406
void setRParenLoc(SourceLocation L)
Definition: Expr.h:2443
Opcode getOpcode() const
Definition: Expr.h:2071
static bool isAdditiveOp(Opcode Opc)
Definition: Expr.h:3510
Base for LValueReferenceType and RValueReferenceType.
Definition: Type.h:2750
void setRHS(Expr *E)
Definition: Expr.h:4180
LValueClassification
Definition: Expr.h:263
void setOperatorLoc(SourceLocation L)
Definition: Expr.h:3467
void setValue(const ASTContext &C, const llvm::APFloat &Val)
Definition: Expr.h:1600
SourceLocation getBeginLoc() const
Definition: Expr.h:5190
StringRef getBytes() const
Allow access to clients that need the byte representation, such as ASTWriterStmt::VisitStringLiteral(...
Definition: Expr.h:1802
child_range children()
Definition: Expr.h:5067
SourceLocation getDefaultLoc() const
Definition: Expr.h:5486
const_child_range children() const
Definition: Expr.h:2535
UnaryExprOrTypeTraitExpr(EmptyShell Empty)
Construct an empty sizeof/alignof expression.
Definition: Expr.h:2400
SubobjectAdjustment(const MemberPointerType *MPT, Expr *RHS)
Definition: Expr.h:98
ExprIterator arg_iterator
Definition: Expr.h:2734
void setLParenLoc(SourceLocation L)
Definition: Expr.h:3111
unsigned getNumTemplateArgs() const
Retrieve the number of template arguments provided as part of this template-id.
Definition: Expr.h:3001
APValue - This class implements a discriminated union of [uninitialized] [APSInt] [APFloat]...
Definition: APValue.h:115
ArraySubscriptExpr(Expr *lhs, Expr *rhs, QualType t, ExprValueKind VK, ExprObjectKind OK, SourceLocation rbracketloc)
Definition: Expr.h:2469
const_child_range children() const
Definition: Expr.h:3141
Represents a base class of a C++ class.
Definition: DeclCXX.h:145
CharacterLiteral(unsigned value, CharacterKind kind, QualType type, SourceLocation l)
Definition: Expr.h:1545
A bitfield object is a bitfield on a C or C++ record.
Definition: Specifiers.h:144
iterator begin()
Definition: ASTVector.h:97
bool isGLValue() const
Definition: Expr.h:363
const_child_range children() const
Definition: Expr.h:4920
void setOperatorLoc(SourceLocation L)
Definition: Expr.h:2081
void setLocation(SourceLocation Location)
Definition: Expr.h:1474
static bool isIncrementOp(Opcode Op)
Definition: Expr.h:2105
Expr * getRHS() const
Definition: Expr.h:4179
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:1366
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: Expr.h:2141
child_range children()
reverse_iterator rend()
Definition: Expr.h:4612
Expr * getSrcExpr() const
getSrcExpr - Return the Expr to be converted.
Definition: Expr.h:4091
bool isArithmeticOp() const
Definition: Expr.h:2127
ImplicitValueInitExpr(EmptyShell Empty)
Construct an empty implicit value initialization.
Definition: Expr.h:5124
child_range children()
Definition: Expr.h:3250
BinaryOperatorKind Opcode
Definition: Expr.h:3439
static bool classof(const Stmt *T)
Definition: Expr.h:5612
ArrayRef< TemplateArgumentLoc > template_arguments() const
Definition: Expr.h:1354
static bool classof(const Stmt *T)
Definition: Expr.h:3982
void setBuiltinLoc(SourceLocation L)
Definition: Expr.h:4274
static bool classof(const Stmt *T)
Definition: Expr.h:3878
Expression is a Null pointer constant built from a literal zero.
Definition: Expr.h:722
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: Expr.h:4107
MemberExpr - [C99 6.5.2.3] Structure and Union Members.
Definition: Expr.h:2836
const_child_range children() const
Definition: Expr.h:1689
void setBase(Expr *E)
Definition: Expr.h:5538
BinaryConditionalOperator(Expr *common, OpaqueValueExpr *opaqueValue, Expr *cond, Expr *lhs, Expr *rhs, SourceLocation qloc, SourceLocation cloc, QualType t, ExprValueKind VK, ExprObjectKind OK)
Definition: Expr.h:3821
CXXBaseSpecifier ** path_iterator
Definition: Expr.h:3218
Provides definitions for the atomic synchronization scopes.
Represents a C++ struct/union/class.
Definition: DeclCXX.h:253
static bool isCompoundAssignmentOp(Opcode Opc)
Definition: Expr.h:3565
Expr * getTrueExpr() const
Definition: Expr.h:3773
Represents a loop initializing the elements of an array.
Definition: Expr.h:5027
bool isSyntacticForm() const
Definition: Expr.h:4559
ChooseExpr - GNU builtin-in function __builtin_choose_expr.
Definition: Expr.h:4130
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: Expr.h:2014
static bool classof(const Stmt *T)
Definition: Expr.h:5566
BinaryConditionalOperator - The GNU extension to the conditional operator which allows the middle ope...
Definition: Expr.h:3808
static bool classof(const Stmt *T)
Definition: Expr.h:2352
SourceLocation getRParenLoc() const
Definition: Expr.h:5189
Expr * getRHS() const
Definition: Expr.h:3781
bool isMultiplicativeOp() const
Definition: Expr.h:3509
bool hasUnusedResultAttr(const ASTContext &Ctx) const
Returns true if this call expression should warn on unused results.
Definition: Expr.h:2785
unsigned getNumConcatenated() const
getNumConcatenated - Get the number of string literal tokens that were concatenated in translation ph...
Definition: Expr.h:1853
bool containsNonAscii() const
Definition: Expr.h:1837
bool isPRValue() const
Definition: Expr.h:364
bool containsUnexpandedParameterPack() const
Whether this expression contains an unexpanded parameter pack (for C++11 variadic templates)...
Definition: Expr.h:223
bool isRValue() const
Definition: Expr.h:259
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: Expr.h:1107
bool isPrefix() const
Definition: Expr.h:2102
unsigned kind
All of the diagnostics that can be emitted by the frontend.
Definition: DiagnosticIDs.h:60
This class is used for builtin types like &#39;int&#39;.
Definition: Type.h:2465
bool isXValue() const
Definition: Expr.h:362
void SetResult(APValue Value, const ASTContext &Context)
Definition: Expr.h:1045
void setPreArg(unsigned I, Stmt *PreArg)
Definition: Expr.h:2622
SourceLocation getEndLoc() const LLVM_READONLY
Definition: Expr.h:5605
Expr * getInit(unsigned Init)
Definition: Expr.h:4456
FieldDecl * Field
Definition: Expr.h:82
void setTokenLocation(SourceLocation L)
Definition: Expr.h:4225
SourceLocation getBuiltinLoc() const
getBuiltinLoc - Return the location of the __builtin_convertvector token.
Definition: Expr.h:4102
StringLiteral - This represents a string literal expression, e.g.
Definition: Expr.h:1711
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
Definition: Expr.h:2546
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: Expr.h:1641
const MemberPointerType * MPT
Definition: Expr.h:76
llvm::ArrayRef< Designator > designators() const
Definition: Expr.h:4846
Designator * getDesignator(unsigned Idx)
Definition: Expr.h:4850
void setInit(Expr *init)
Definition: Expr.h:4881
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: Expr.h:3479
child_range children()
Definition: Expr.h:3940
AbstractConditionalOperator(StmtClass SC, QualType T, ExprValueKind VK, ExprObjectKind OK, bool TD, bool VD, bool ID, bool ContainsUnexpandedParameterPack, SourceLocation qloc, SourceLocation cloc)
Definition: Expr.h:3695
Expr * getLHS() const
Definition: Expr.h:4177
static Decl::Kind getKind(const Decl *D)
Definition: DeclBase.cpp:947
NonOdrUseReason
The reason why a DeclRefExpr does not constitute an odr-use.
Definition: Specifiers.h:160
static bool classof(const Stmt *T)
Definition: Expr.h:5127
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: Expr.h:3871
DeclAccessPair FoundDecl
The DeclAccessPair through which the MemberDecl was found due to name qualifiers. ...
Definition: Expr.h:2831
unsigned getNumComponents() const
Definition: Expr.h:2326
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
Definition: Type.h:2150
std::reverse_iterator< const_iterator > const_reverse_iterator
Definition: ASTVector.h:88
void setKind(CharacterKind kind)
Definition: Expr.h:1567
A reference to a declared variable, function, enum, etc.
Definition: Expr.h:1171
const_child_range children() const
Definition: Expr.h:1986
Expr * getRHS() const
Definition: Expr.h:3476
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:1614
#define PTR(CLASS)
Definition: AttrVisitor.h:27
bool isBitwiseOp() const
Definition: Expr.h:3516
bool isIncrementDecrementOp() const
Definition: Expr.h:2120
Expr * getSemanticExpr(unsigned index)
Definition: Expr.h:5803
const APValue & getResultAsAPValue() const
Definition: Expr.h:1057
SourceLocation getEndLoc() const LLVM_READONLY
Definition: Expr.h:4189
const Expr * IgnoreUnlessSpelledInSource() const
Definition: Expr.h:770
SourceLocation getLocation() const
Definition: Expr.h:1556
const Expr *const * getSubExprs() const
Definition: Expr.h:5917
FieldDecl * getInitializedFieldInUnion()
If this initializes a union, specifies which field in the union to initialize.
Definition: Expr.h:4515
bool isConditionDependent() const
Definition: Expr.h:4165
AssociationIteratorTy< false > AssociationIterator
Definition: Expr.h:5395
#define true
Definition: stdbool.h:16
An l-value expression is a reference to an object with independent storage.
Definition: Specifiers.h:129
bool isUTF16() const
Definition: Expr.h:1833
A trivial tuple used to represent a source range.
This represents a decl that may have a name.
Definition: Decl.h:223
SourceLocation getTemplateKeywordLoc() const
Retrieve the location of the template keyword preceding the member name, if any.
Definition: Expr.h:2953
NestedNameSpecifier * getQualifier() const
If the name was qualified, retrieves the nested-name-specifier that precedes the name.
Definition: Expr.h:1274
OffsetOfExpr - [C99 7.17] - This represents an expression of the form offsetof(record-type, member-designator).
Definition: Expr.h:2267
SourceLocation getEndLoc() const LLVM_READONLY
Definition: Expr.h:1110
SourceLocation getEndLoc() const LLVM_READONLY
Definition: Expr.h:4821
static bool classof(const Stmt *T)
Definition: Expr.h:3362
SourceLocation getBuiltinLoc() const
Definition: Expr.h:5939
APValue::ValueKind getResultAPValueKind() const
Definition: Expr.h:1050
DeclContext * getParentContext()
Definition: Expr.h:4336
SourceLocExpr(EmptyShell Empty)
Build an empty call expression.
Definition: Expr.h:4306
static bool isDecrementOp(Opcode Op)
Definition: Expr.h:2112
Expr * getCommon() const
getCommon - Return the common expression, written to the left of the condition.
Definition: Expr.h:3848
TypeSourceInfo * getWrittenTypeInfo() const
Definition: Expr.h:4270
const CXXRecordDecl * DerivedClass
Definition: Expr.h:72
path_const_iterator path_begin() const
Definition: Expr.h:3224
child_range children()
Definition: Expr.h:1981
BlockDecl * getBlockDecl()
Definition: Expr.h:5594
bool isInStdNamespace() const
Definition: DeclBase.cpp:357
static bool classof(const Stmt *T)
Definition: Expr.h:2149
SourceLocation getGenericLoc() const
Definition: Expr.h:5483
bool isLValue() const
Definition: Expr.h:361
SubobjectAdjustment(const CastExpr *BasePath, const CXXRecordDecl *DerivedClass)
Definition: Expr.h:86
ImaginaryLiteral(EmptyShell Empty)
Build an empty imaginary literal.
Definition: Expr.h:1671
Decl * getCalleeDecl()
Definition: Expr.h:2675
void setBase(Expr *E)
Definition: Expr.h:2912
static bool isComparisonOp(Opcode Opc)
Definition: Expr.h:3524
SourceLocation getBegin() const
TypeSourceInfo * getTypeSourceInfo() const
getTypeSourceInfo - Return the destination type.
Definition: Expr.h:4094
const_child_range children() const
Definition: Expr.h:4594
SourceLocation ColonLoc
Location of &#39;:&#39;.
Definition: OpenMPClause.h:107
SourceLocation getRParenLoc() const
Return the location of the right parentheses.
Definition: Expr.h:2306
llvm::APInt getArraySize() const
Definition: Expr.h:5051
bool isConditionTrue() const
isConditionTrue - Return whether the condition is true (i.e.
Definition: Expr.h:4158
CastExpr(StmtClass SC, QualType ty, ExprValueKind VK, const CastKind kind, Expr *op, unsigned BasePathSize)
Definition: Expr.h:3161
This class handles loading and caching of source files into memory.
InitListExpr * getSyntacticForm() const
Definition: Expr.h:4562
child_range children()
Definition: Expr.h:4196
Represents an implicitly-generated value initialization of an object of a given type.
Definition: Expr.h:5117
NullPointerConstantKind
Enumeration used to describe the kind of Null pointer constant returned from isNullPointerConstant()...
Definition: Expr.h:710
Expr * getWeak() const
Definition: Expr.h:5907
child_range children()
Definition: Expr.h:5135
Attr - This represents one attribute.
Definition: Attr.h:45
SourceLocation getEndLoc() const LLVM_READONLY
Definition: Expr.h:4024
child_range children()
Definition: Expr.h:4954
QualType getType() const
Return the type wrapped by this type source info.
Definition: Type.h:6238
association_range associations()
Definition: Expr.h:5463
const FunctionDecl * getDirectCallee() const
Definition: Expr.h:2684
SourceLocation getOperatorLoc() const
Definition: Expr.h:3018
InitListExpr * getSemanticForm() const
Definition: Expr.h:4556
SourceLocation getEndLoc() const LLVM_READONLY
Definition: Expr.h:2015
static OMPLinearClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, OpenMPLinearClauseKind Modifier, SourceLocation ModifierLoc, SourceLocation ColonLoc, SourceLocation EndLoc, ArrayRef< Expr *> VL, ArrayRef< Expr *> PL, ArrayRef< Expr *> IL, Expr *Step, Expr *CalcStep, Stmt *PreInit, Expr *PostUpdate)
Creates clause with a list of variables VL and a linear step Step.
static bool classof(const Stmt *T)
Definition: Expr.h:5193
void setCond(Expr *E)
Definition: Expr.h:4176
void setIsConditionTrue(bool isTrue)
Definition: Expr.h:4163
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: Expr.h:1561
bool isCompoundAssignmentOp() const
Definition: Expr.h:3568
SourceLocation getExprLoc() const
Definition: Expr.h:2147
SourceRange getSourceRange() const LLVM_READONLY
Definition: Expr.h:4824
static bool EvaluateAsRValue(EvalInfo &Info, const Expr *E, APValue &Result)
EvaluateAsRValue - Try to evaluate this expression, performing an implicit lvalue-to-rvalue cast if i...
llvm::iterator_range< const_arg_iterator > const_arg_range
Definition: Expr.h:2737