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