clang  6.0.0svn
ExprObjC.h
Go to the documentation of this file.
1 //===--- ExprObjC.h - Classes for representing ObjC 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 ExprObjC interface and subclasses.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #ifndef LLVM_CLANG_AST_EXPROBJC_H
15 #define LLVM_CLANG_AST_EXPROBJC_H
16 
17 #include "clang/AST/DeclObjC.h"
18 #include "clang/AST/Expr.h"
21 #include "llvm/Support/Compiler.h"
22 
23 namespace clang {
24  class IdentifierInfo;
25  class ASTContext;
26 
27 /// ObjCStringLiteral, used for Objective-C string literals
28 /// i.e. @"foo".
29 class ObjCStringLiteral : public Expr {
30  Stmt *String;
31  SourceLocation AtLoc;
32 public:
34  : Expr(ObjCStringLiteralClass, T, VK_RValue, OK_Ordinary, false, false,
35  false, false),
36  String(SL), AtLoc(L) {}
37  explicit ObjCStringLiteral(EmptyShell Empty)
38  : Expr(ObjCStringLiteralClass, Empty) {}
39 
40  StringLiteral *getString() { return cast<StringLiteral>(String); }
41  const StringLiteral *getString() const { return cast<StringLiteral>(String); }
42  void setString(StringLiteral *S) { String = S; }
43 
44  SourceLocation getAtLoc() const { return AtLoc; }
45  void setAtLoc(SourceLocation L) { AtLoc = L; }
46 
47  SourceLocation getLocStart() const LLVM_READONLY { return AtLoc; }
48  SourceLocation getLocEnd() const LLVM_READONLY { return String->getLocEnd(); }
49 
50  static bool classof(const Stmt *T) {
51  return T->getStmtClass() == ObjCStringLiteralClass;
52  }
53 
54  // Iterators
55  child_range children() { return child_range(&String, &String+1); }
56 };
57 
58 /// ObjCBoolLiteralExpr - Objective-C Boolean Literal.
59 ///
60 class ObjCBoolLiteralExpr : public Expr {
61  bool Value;
62  SourceLocation Loc;
63 public:
65  Expr(ObjCBoolLiteralExprClass, Ty, VK_RValue, OK_Ordinary, false, false,
66  false, false), Value(val), Loc(l) {}
67 
69  : Expr(ObjCBoolLiteralExprClass, Empty) { }
70 
71  bool getValue() const { return Value; }
72  void setValue(bool V) { Value = V; }
73 
74  SourceLocation getLocStart() const LLVM_READONLY { return Loc; }
75  SourceLocation getLocEnd() const LLVM_READONLY { return Loc; }
76 
77  SourceLocation getLocation() const { return Loc; }
78  void setLocation(SourceLocation L) { Loc = L; }
79 
80  static bool classof(const Stmt *T) {
81  return T->getStmtClass() == ObjCBoolLiteralExprClass;
82  }
83 
84  // Iterators
87  }
88 };
89 
90 /// ObjCBoxedExpr - used for generalized expression boxing.
91 /// as in: @(strdup("hello world")), @(random()) or @(view.frame)
92 /// Also used for boxing non-parenthesized numeric literals;
93 /// as in: @42 or \@true (c++/objc++) or \@__objc_yes (c/objc).
94 class ObjCBoxedExpr : public Expr {
95  Stmt *SubExpr;
96  ObjCMethodDecl *BoxingMethod;
97  SourceRange Range;
98 public:
100  SourceRange R)
101  : Expr(ObjCBoxedExprClass, T, VK_RValue, OK_Ordinary,
102  E->isTypeDependent(), E->isValueDependent(),
104  SubExpr(E), BoxingMethod(method), Range(R) {}
105  explicit ObjCBoxedExpr(EmptyShell Empty)
106  : Expr(ObjCBoxedExprClass, Empty) {}
107 
108  Expr *getSubExpr() { return cast<Expr>(SubExpr); }
109  const Expr *getSubExpr() const { return cast<Expr>(SubExpr); }
110 
112  return BoxingMethod;
113  }
114 
115  SourceLocation getAtLoc() const { return Range.getBegin(); }
116 
117  SourceLocation getLocStart() const LLVM_READONLY { return Range.getBegin(); }
118  SourceLocation getLocEnd() const LLVM_READONLY { return Range.getEnd(); }
119  SourceRange getSourceRange() const LLVM_READONLY {
120  return Range;
121  }
122 
123  static bool classof(const Stmt *T) {
124  return T->getStmtClass() == ObjCBoxedExprClass;
125  }
126 
127  // Iterators
128  child_range children() { return child_range(&SubExpr, &SubExpr+1); }
129 
131 
132  const_arg_iterator arg_begin() const {
133  return reinterpret_cast<Stmt const * const*>(&SubExpr);
134  }
135  const_arg_iterator arg_end() const {
136  return reinterpret_cast<Stmt const * const*>(&SubExpr + 1);
137  }
138 
139  friend class ASTStmtReader;
140 };
141 
142 /// ObjCArrayLiteral - used for objective-c array containers; as in:
143 /// @[@"Hello", NSApp, [NSNumber numberWithInt:42]];
144 class ObjCArrayLiteral final
145  : public Expr,
146  private llvm::TrailingObjects<ObjCArrayLiteral, Expr *> {
147  unsigned NumElements;
148  SourceRange Range;
149  ObjCMethodDecl *ArrayWithObjectsMethod;
150 
152  QualType T, ObjCMethodDecl * Method,
153  SourceRange SR);
154 
155  explicit ObjCArrayLiteral(EmptyShell Empty, unsigned NumElements)
156  : Expr(ObjCArrayLiteralClass, Empty), NumElements(NumElements) {}
157 
158 public:
159  static ObjCArrayLiteral *Create(const ASTContext &C,
160  ArrayRef<Expr *> Elements,
161  QualType T, ObjCMethodDecl * Method,
162  SourceRange SR);
163 
164  static ObjCArrayLiteral *CreateEmpty(const ASTContext &C,
165  unsigned NumElements);
166 
167  SourceLocation getLocStart() const LLVM_READONLY { return Range.getBegin(); }
168  SourceLocation getLocEnd() const LLVM_READONLY { return Range.getEnd(); }
169  SourceRange getSourceRange() const LLVM_READONLY { return Range; }
170 
171  static bool classof(const Stmt *T) {
172  return T->getStmtClass() == ObjCArrayLiteralClass;
173  }
174 
175  /// \brief Retrieve elements of array of literals.
176  Expr **getElements() { return getTrailingObjects<Expr *>(); }
177 
178  /// \brief Retrieve elements of array of literals.
179  const Expr * const *getElements() const {
180  return getTrailingObjects<Expr *>();
181  }
182 
183  /// getNumElements - Return number of elements of objective-c array literal.
184  unsigned getNumElements() const { return NumElements; }
185 
186  /// getExpr - Return the Expr at the specified index.
187  Expr *getElement(unsigned Index) {
188  assert((Index < NumElements) && "Arg access out of range!");
189  return cast<Expr>(getElements()[Index]);
190  }
191  const Expr *getElement(unsigned Index) const {
192  assert((Index < NumElements) && "Arg access out of range!");
193  return cast<Expr>(getElements()[Index]);
194  }
195 
197  return ArrayWithObjectsMethod;
198  }
199 
200  // Iterators
202  return child_range(reinterpret_cast<Stmt **>(getElements()),
203  reinterpret_cast<Stmt **>(getElements()) + NumElements);
204  }
205 
207  friend class ASTStmtReader;
208 };
209 
210 /// \brief An element in an Objective-C dictionary literal.
211 ///
213  /// \brief The key for the dictionary element.
215 
216  /// \brief The value of the dictionary element.
218 
219  /// \brief The location of the ellipsis, if this is a pack expansion.
221 
222  /// \brief The number of elements this pack expansion will expand to, if
223  /// this is a pack expansion and is known.
225 
226  /// \brief Determines whether this dictionary element is a pack expansion.
227  bool isPackExpansion() const { return EllipsisLoc.isValid(); }
228 };
229 } // end namespace clang
230 
231 namespace llvm {
232 template <> struct isPodLike<clang::ObjCDictionaryElement> : std::true_type {};
233 }
234 
235 namespace clang {
236 /// \brief Internal struct for storing Key/value pair.
240 };
241 
242 /// \brief Internal struct to describes an element that is a pack
243 /// expansion, used if any of the elements in the dictionary literal
244 /// are pack expansions.
246  /// \brief The location of the ellipsis, if this element is a pack
247  /// expansion.
249 
250  /// \brief If non-zero, the number of elements that this pack
251  /// expansion will expand to (+1).
253 };
254 
255 /// ObjCDictionaryLiteral - AST node to represent objective-c dictionary
256 /// literals; as in: @{@"name" : NSUserName(), @"date" : [NSDate date] };
258  : public Expr,
259  private llvm::TrailingObjects<ObjCDictionaryLiteral,
260  ObjCDictionaryLiteral_KeyValuePair,
261  ObjCDictionaryLiteral_ExpansionData> {
262  /// \brief The number of elements in this dictionary literal.
263  unsigned NumElements : 31;
264 
265  /// \brief Determine whether this dictionary literal has any pack expansions.
266  ///
267  /// If the dictionary literal has pack expansions, then there will
268  /// be an array of pack expansion data following the array of
269  /// key/value pairs, which provide the locations of the ellipses (if
270  /// any) and number of elements in the expansion (if known). If
271  /// there are no pack expansions, we optimize away this storage.
272  unsigned HasPackExpansions : 1;
273 
274  SourceRange Range;
275  ObjCMethodDecl *DictWithObjectsMethod;
276 
279 
280  size_t numTrailingObjects(OverloadToken<KeyValuePair>) const {
281  return NumElements;
282  }
283 
285  bool HasPackExpansions,
286  QualType T, ObjCMethodDecl *method,
287  SourceRange SR);
288 
289  explicit ObjCDictionaryLiteral(EmptyShell Empty, unsigned NumElements,
290  bool HasPackExpansions)
291  : Expr(ObjCDictionaryLiteralClass, Empty), NumElements(NumElements),
292  HasPackExpansions(HasPackExpansions) {}
293 
294 public:
295  static ObjCDictionaryLiteral *Create(const ASTContext &C,
297  bool HasPackExpansions,
298  QualType T, ObjCMethodDecl *method,
299  SourceRange SR);
300 
302  unsigned NumElements,
303  bool HasPackExpansions);
304 
305  /// getNumElements - Return number of elements of objective-c dictionary
306  /// literal.
307  unsigned getNumElements() const { return NumElements; }
308 
310  assert((Index < NumElements) && "Arg access out of range!");
311  const KeyValuePair &KV = getTrailingObjects<KeyValuePair>()[Index];
313  if (HasPackExpansions) {
314  const ExpansionData &Expansion =
315  getTrailingObjects<ExpansionData>()[Index];
316  Result.EllipsisLoc = Expansion.EllipsisLoc;
317  if (Expansion.NumExpansionsPlusOne > 0)
318  Result.NumExpansions = Expansion.NumExpansionsPlusOne - 1;
319  }
320  return Result;
321  }
322 
324  { return DictWithObjectsMethod; }
325 
326  SourceLocation getLocStart() const LLVM_READONLY { return Range.getBegin(); }
327  SourceLocation getLocEnd() const LLVM_READONLY { return Range.getEnd(); }
328  SourceRange getSourceRange() const LLVM_READONLY { return Range; }
329 
330  static bool classof(const Stmt *T) {
331  return T->getStmtClass() == ObjCDictionaryLiteralClass;
332  }
333 
334  // Iterators
336  // Note: we're taking advantage of the layout of the KeyValuePair struct
337  // here. If that struct changes, this code will need to change as well.
338  static_assert(sizeof(KeyValuePair) == sizeof(Stmt *) * 2,
339  "KeyValuePair is expected size");
340  return child_range(
341  reinterpret_cast<Stmt **>(getTrailingObjects<KeyValuePair>()),
342  reinterpret_cast<Stmt **>(getTrailingObjects<KeyValuePair>()) +
343  NumElements * 2);
344  }
345 
346  friend class ASTStmtReader;
347  friend class ASTStmtWriter;
349 };
350 
351 
352 /// ObjCEncodeExpr, used for \@encode in Objective-C. \@encode has the same
353 /// type and behavior as StringLiteral except that the string initializer is
354 /// obtained from ASTContext with the encoding type as an argument.
355 class ObjCEncodeExpr : public Expr {
356  TypeSourceInfo *EncodedType;
357  SourceLocation AtLoc, RParenLoc;
358 public:
361  : Expr(ObjCEncodeExprClass, T, VK_LValue, OK_Ordinary,
362  EncodedType->getType()->isDependentType(),
363  EncodedType->getType()->isDependentType(),
364  EncodedType->getType()->isInstantiationDependentType(),
365  EncodedType->getType()->containsUnexpandedParameterPack()),
366  EncodedType(EncodedType), AtLoc(at), RParenLoc(rp) {}
367 
368  explicit ObjCEncodeExpr(EmptyShell Empty) : Expr(ObjCEncodeExprClass, Empty){}
369 
370 
371  SourceLocation getAtLoc() const { return AtLoc; }
372  void setAtLoc(SourceLocation L) { AtLoc = L; }
373  SourceLocation getRParenLoc() const { return RParenLoc; }
374  void setRParenLoc(SourceLocation L) { RParenLoc = L; }
375 
376  QualType getEncodedType() const { return EncodedType->getType(); }
377 
378  TypeSourceInfo *getEncodedTypeSourceInfo() const { return EncodedType; }
380  EncodedType = EncType;
381  }
382 
383  SourceLocation getLocStart() const LLVM_READONLY { return AtLoc; }
384  SourceLocation getLocEnd() const LLVM_READONLY { return RParenLoc; }
385 
386  static bool classof(const Stmt *T) {
387  return T->getStmtClass() == ObjCEncodeExprClass;
388  }
389 
390  // Iterators
393  }
394 };
395 
396 /// ObjCSelectorExpr used for \@selector in Objective-C.
397 class ObjCSelectorExpr : public Expr {
398  Selector SelName;
399  SourceLocation AtLoc, RParenLoc;
400 public:
403  : Expr(ObjCSelectorExprClass, T, VK_RValue, OK_Ordinary, false, false,
404  false, false),
405  SelName(selInfo), AtLoc(at), RParenLoc(rp){}
406  explicit ObjCSelectorExpr(EmptyShell Empty)
407  : Expr(ObjCSelectorExprClass, Empty) {}
408 
409  Selector getSelector() const { return SelName; }
410  void setSelector(Selector S) { SelName = S; }
411 
412  SourceLocation getAtLoc() const { return AtLoc; }
413  SourceLocation getRParenLoc() const { return RParenLoc; }
414  void setAtLoc(SourceLocation L) { AtLoc = L; }
415  void setRParenLoc(SourceLocation L) { RParenLoc = L; }
416 
417  SourceLocation getLocStart() const LLVM_READONLY { return AtLoc; }
418  SourceLocation getLocEnd() const LLVM_READONLY { return RParenLoc; }
419 
420  /// getNumArgs - Return the number of actual arguments to this call.
421  unsigned getNumArgs() const { return SelName.getNumArgs(); }
422 
423  static bool classof(const Stmt *T) {
424  return T->getStmtClass() == ObjCSelectorExprClass;
425  }
426 
427  // Iterators
430  }
431 };
432 
433 /// ObjCProtocolExpr used for protocol expression in Objective-C.
434 ///
435 /// This is used as: \@protocol(foo), as in:
436 /// \code
437 /// [obj conformsToProtocol:@protocol(foo)]
438 /// \endcode
439 ///
440 /// The return type is "Protocol*".
441 class ObjCProtocolExpr : public Expr {
442  ObjCProtocolDecl *TheProtocol;
443  SourceLocation AtLoc, ProtoLoc, RParenLoc;
444 public:
447  : Expr(ObjCProtocolExprClass, T, VK_RValue, OK_Ordinary, false, false,
448  false, false),
449  TheProtocol(protocol), AtLoc(at), ProtoLoc(protoLoc), RParenLoc(rp) {}
450  explicit ObjCProtocolExpr(EmptyShell Empty)
451  : Expr(ObjCProtocolExprClass, Empty) {}
452 
453  ObjCProtocolDecl *getProtocol() const { return TheProtocol; }
454  void setProtocol(ObjCProtocolDecl *P) { TheProtocol = P; }
455 
456  SourceLocation getProtocolIdLoc() const { return ProtoLoc; }
457  SourceLocation getAtLoc() const { return AtLoc; }
458  SourceLocation getRParenLoc() const { return RParenLoc; }
459  void setAtLoc(SourceLocation L) { AtLoc = L; }
460  void setRParenLoc(SourceLocation L) { RParenLoc = L; }
461 
462  SourceLocation getLocStart() const LLVM_READONLY { return AtLoc; }
463  SourceLocation getLocEnd() const LLVM_READONLY { return RParenLoc; }
464 
465  static bool classof(const Stmt *T) {
466  return T->getStmtClass() == ObjCProtocolExprClass;
467  }
468 
469  // Iterators
472  }
473 
474  friend class ASTStmtReader;
475  friend class ASTStmtWriter;
476 };
477 
478 /// ObjCIvarRefExpr - A reference to an ObjC instance variable.
479 class ObjCIvarRefExpr : public Expr {
480  ObjCIvarDecl *D;
481  Stmt *Base;
482  SourceLocation Loc;
483  /// OpLoc - This is the location of '.' or '->'
484  SourceLocation OpLoc;
485 
486  bool IsArrow:1; // True if this is "X->F", false if this is "X.F".
487  bool IsFreeIvar:1; // True if ivar reference has no base (self assumed).
488 
489 public:
492  Expr *base,
493  bool arrow = false, bool freeIvar = false) :
494  Expr(ObjCIvarRefExprClass, t, VK_LValue,
495  d->isBitField() ? OK_BitField : OK_Ordinary,
496  /*TypeDependent=*/false, base->isValueDependent(),
497  base->isInstantiationDependent(),
499  D(d), Base(base), Loc(l), OpLoc(oploc),
500  IsArrow(arrow), IsFreeIvar(freeIvar) {}
501 
502  explicit ObjCIvarRefExpr(EmptyShell Empty)
503  : Expr(ObjCIvarRefExprClass, Empty) {}
504 
505  ObjCIvarDecl *getDecl() { return D; }
506  const ObjCIvarDecl *getDecl() const { return D; }
507  void setDecl(ObjCIvarDecl *d) { D = d; }
508 
509  const Expr *getBase() const { return cast<Expr>(Base); }
510  Expr *getBase() { return cast<Expr>(Base); }
511  void setBase(Expr * base) { Base = base; }
512 
513  bool isArrow() const { return IsArrow; }
514  bool isFreeIvar() const { return IsFreeIvar; }
515  void setIsArrow(bool A) { IsArrow = A; }
516  void setIsFreeIvar(bool A) { IsFreeIvar = A; }
517 
518  SourceLocation getLocation() const { return Loc; }
519  void setLocation(SourceLocation L) { Loc = L; }
520 
521  SourceLocation getLocStart() const LLVM_READONLY {
522  return isFreeIvar() ? Loc : getBase()->getLocStart();
523  }
524  SourceLocation getLocEnd() const LLVM_READONLY { return Loc; }
525 
526  SourceLocation getOpLoc() const { return OpLoc; }
527  void setOpLoc(SourceLocation L) { OpLoc = L; }
528 
529  static bool classof(const Stmt *T) {
530  return T->getStmtClass() == ObjCIvarRefExprClass;
531  }
532 
533  // Iterators
534  child_range children() { return child_range(&Base, &Base+1); }
535 };
536 
537 /// ObjCPropertyRefExpr - A dot-syntax expression to access an ObjC
538 /// property.
539 class ObjCPropertyRefExpr : public Expr {
540 private:
541  /// If the bool is true, this is an implicit property reference; the
542  /// pointer is an (optional) ObjCMethodDecl and Setter may be set.
543  /// if the bool is false, this is an explicit property reference;
544  /// the pointer is an ObjCPropertyDecl and Setter is always null.
545  llvm::PointerIntPair<NamedDecl*, 1, bool> PropertyOrGetter;
546 
547  /// \brief Indicates whether the property reference will result in a message
548  /// to the getter, the setter, or both.
549  /// This applies to both implicit and explicit property references.
550  enum MethodRefFlags {
551  MethodRef_None = 0,
552  MethodRef_Getter = 0x1,
553  MethodRef_Setter = 0x2
554  };
555 
556  /// \brief Contains the Setter method pointer and MethodRefFlags bit flags.
557  llvm::PointerIntPair<ObjCMethodDecl *, 2, unsigned> SetterAndMethodRefFlags;
558 
559  // FIXME: Maybe we should store the property identifier here,
560  // because it's not rederivable from the other data when there's an
561  // implicit property with no getter (because the 'foo' -> 'setFoo:'
562  // transformation is lossy on the first character).
563 
564  SourceLocation IdLoc;
565 
566  /// \brief When the receiver in property access is 'super', this is
567  /// the location of the 'super' keyword. When it's an interface,
568  /// this is that interface.
569  SourceLocation ReceiverLoc;
570  llvm::PointerUnion3<Stmt*, const Type*, ObjCInterfaceDecl*> Receiver;
571 
572 public:
575  SourceLocation l, Expr *base)
576  : Expr(ObjCPropertyRefExprClass, t, VK, OK,
577  /*TypeDependent=*/false, base->isValueDependent(),
578  base->isInstantiationDependent(),
580  PropertyOrGetter(PD, false), SetterAndMethodRefFlags(),
581  IdLoc(l), ReceiverLoc(), Receiver(base) {
582  assert(t->isSpecificPlaceholderType(BuiltinType::PseudoObject));
583  }
584 
588  : Expr(ObjCPropertyRefExprClass, t, VK, OK,
589  /*TypeDependent=*/false, false, st->isInstantiationDependentType(),
591  PropertyOrGetter(PD, false), SetterAndMethodRefFlags(),
592  IdLoc(l), ReceiverLoc(sl), Receiver(st.getTypePtr()) {
593  assert(t->isSpecificPlaceholderType(BuiltinType::PseudoObject));
594  }
595 
598  SourceLocation IdLoc, Expr *Base)
599  : Expr(ObjCPropertyRefExprClass, T, VK, OK, false,
602  PropertyOrGetter(Getter, true), SetterAndMethodRefFlags(Setter, 0),
603  IdLoc(IdLoc), ReceiverLoc(), Receiver(Base) {
604  assert(T->isSpecificPlaceholderType(BuiltinType::PseudoObject));
605  }
606 
609  SourceLocation IdLoc,
610  SourceLocation SuperLoc, QualType SuperTy)
611  : Expr(ObjCPropertyRefExprClass, T, VK, OK, false, false, false, false),
612  PropertyOrGetter(Getter, true), SetterAndMethodRefFlags(Setter, 0),
613  IdLoc(IdLoc), ReceiverLoc(SuperLoc), Receiver(SuperTy.getTypePtr()) {
614  assert(T->isSpecificPlaceholderType(BuiltinType::PseudoObject));
615  }
616 
619  SourceLocation IdLoc,
620  SourceLocation ReceiverLoc, ObjCInterfaceDecl *Receiver)
621  : Expr(ObjCPropertyRefExprClass, T, VK, OK, false, false, false, false),
622  PropertyOrGetter(Getter, true), SetterAndMethodRefFlags(Setter, 0),
623  IdLoc(IdLoc), ReceiverLoc(ReceiverLoc), Receiver(Receiver) {
624  assert(T->isSpecificPlaceholderType(BuiltinType::PseudoObject));
625  }
626 
628  : Expr(ObjCPropertyRefExprClass, Empty) {}
629 
630  bool isImplicitProperty() const { return PropertyOrGetter.getInt(); }
631  bool isExplicitProperty() const { return !PropertyOrGetter.getInt(); }
632 
634  assert(!isImplicitProperty());
635  return cast<ObjCPropertyDecl>(PropertyOrGetter.getPointer());
636  }
637 
639  assert(isImplicitProperty());
640  return cast_or_null<ObjCMethodDecl>(PropertyOrGetter.getPointer());
641  }
642 
644  assert(isImplicitProperty());
645  return SetterAndMethodRefFlags.getPointer();
646  }
647 
649  if (isImplicitProperty())
650  return getImplicitPropertyGetter()->getSelector();
651  return getExplicitProperty()->getGetterName();
652  }
653 
655  if (isImplicitProperty())
656  return getImplicitPropertySetter()->getSelector();
657  return getExplicitProperty()->getSetterName();
658  }
659 
660  /// \brief True if the property reference will result in a message to the
661  /// getter.
662  /// This applies to both implicit and explicit property references.
663  bool isMessagingGetter() const {
664  return SetterAndMethodRefFlags.getInt() & MethodRef_Getter;
665  }
666 
667  /// \brief True if the property reference will result in a message to the
668  /// setter.
669  /// This applies to both implicit and explicit property references.
670  bool isMessagingSetter() const {
671  return SetterAndMethodRefFlags.getInt() & MethodRef_Setter;
672  }
673 
674  void setIsMessagingGetter(bool val = true) {
675  setMethodRefFlag(MethodRef_Getter, val);
676  }
677 
678  void setIsMessagingSetter(bool val = true) {
679  setMethodRefFlag(MethodRef_Setter, val);
680  }
681 
682  const Expr *getBase() const {
683  return cast<Expr>(Receiver.get<Stmt*>());
684  }
685  Expr *getBase() {
686  return cast<Expr>(Receiver.get<Stmt*>());
687  }
688 
689  SourceLocation getLocation() const { return IdLoc; }
690 
691  SourceLocation getReceiverLocation() const { return ReceiverLoc; }
693  return QualType(Receiver.get<const Type*>(), 0);
694  }
695 
697  return Receiver.get<ObjCInterfaceDecl*>();
698  }
699  bool isObjectReceiver() const { return Receiver.is<Stmt*>(); }
700  bool isSuperReceiver() const { return Receiver.is<const Type*>(); }
701  bool isClassReceiver() const { return Receiver.is<ObjCInterfaceDecl*>(); }
702 
703  /// Determine the type of the base, regardless of the kind of receiver.
704  QualType getReceiverType(const ASTContext &ctx) const;
705 
706  SourceLocation getLocStart() const LLVM_READONLY {
707  return isObjectReceiver() ? getBase()->getLocStart() :getReceiverLocation();
708  }
709  SourceLocation getLocEnd() const LLVM_READONLY { return IdLoc; }
710 
711  static bool classof(const Stmt *T) {
712  return T->getStmtClass() == ObjCPropertyRefExprClass;
713  }
714 
715  // Iterators
717  if (Receiver.is<Stmt*>()) {
718  Stmt **begin = reinterpret_cast<Stmt**>(&Receiver); // hack!
719  return child_range(begin, begin+1);
720  }
722  }
723 
724 private:
725  friend class ASTStmtReader;
726  friend class ASTStmtWriter;
727  void setExplicitProperty(ObjCPropertyDecl *D, unsigned methRefFlags) {
728  PropertyOrGetter.setPointer(D);
729  PropertyOrGetter.setInt(false);
730  SetterAndMethodRefFlags.setPointer(nullptr);
731  SetterAndMethodRefFlags.setInt(methRefFlags);
732  }
733  void setImplicitProperty(ObjCMethodDecl *Getter, ObjCMethodDecl *Setter,
734  unsigned methRefFlags) {
735  PropertyOrGetter.setPointer(Getter);
736  PropertyOrGetter.setInt(true);
737  SetterAndMethodRefFlags.setPointer(Setter);
738  SetterAndMethodRefFlags.setInt(methRefFlags);
739  }
740  void setBase(Expr *Base) { Receiver = Base; }
741  void setSuperReceiver(QualType T) { Receiver = T.getTypePtr(); }
742  void setClassReceiver(ObjCInterfaceDecl *D) { Receiver = D; }
743 
744  void setLocation(SourceLocation L) { IdLoc = L; }
745  void setReceiverLocation(SourceLocation Loc) { ReceiverLoc = Loc; }
746 
747  void setMethodRefFlag(MethodRefFlags flag, bool val) {
748  unsigned f = SetterAndMethodRefFlags.getInt();
749  if (val)
750  f |= flag;
751  else
752  f &= ~flag;
753  SetterAndMethodRefFlags.setInt(f);
754  }
755 };
756 
757 /// ObjCSubscriptRefExpr - used for array and dictionary subscripting.
758 /// array[4] = array[3]; dictionary[key] = dictionary[alt_key];
759 ///
760 class ObjCSubscriptRefExpr : public Expr {
761  // Location of ']' in an indexing expression.
762  SourceLocation RBracket;
763  // array/dictionary base expression.
764  // for arrays, this is a numeric expression. For dictionaries, this is
765  // an objective-c object pointer expression.
766  enum { BASE, KEY, END_EXPR };
767  Stmt* SubExprs[END_EXPR];
768 
769  ObjCMethodDecl *GetAtIndexMethodDecl;
770 
771  // For immutable objects this is null. When ObjCSubscriptRefExpr is to read
772  // an indexed object this is null too.
773  ObjCMethodDecl *SetAtIndexMethodDecl;
774 
775 public:
776 
779  ObjCMethodDecl *getMethod,
780  ObjCMethodDecl *setMethod, SourceLocation RB)
781  : Expr(ObjCSubscriptRefExprClass, T, VK, OK,
782  base->isTypeDependent() || key->isTypeDependent(),
783  base->isValueDependent() || key->isValueDependent(),
787  RBracket(RB),
788  GetAtIndexMethodDecl(getMethod),
789  SetAtIndexMethodDecl(setMethod)
790  {SubExprs[BASE] = base; SubExprs[KEY] = key;}
791 
793  : Expr(ObjCSubscriptRefExprClass, Empty) {}
794 
795  SourceLocation getRBracket() const { return RBracket; }
796  void setRBracket(SourceLocation RB) { RBracket = RB; }
797 
798  SourceLocation getLocStart() const LLVM_READONLY {
799  return SubExprs[BASE]->getLocStart();
800  }
801  SourceLocation getLocEnd() const LLVM_READONLY { return RBracket; }
802 
803  static bool classof(const Stmt *T) {
804  return T->getStmtClass() == ObjCSubscriptRefExprClass;
805  }
806 
807  Expr *getBaseExpr() const { return cast<Expr>(SubExprs[BASE]); }
808  void setBaseExpr(Stmt *S) { SubExprs[BASE] = S; }
809 
810  Expr *getKeyExpr() const { return cast<Expr>(SubExprs[KEY]); }
811  void setKeyExpr(Stmt *S) { SubExprs[KEY] = S; }
812 
814  return GetAtIndexMethodDecl;
815  }
816 
818  return SetAtIndexMethodDecl;
819  }
820 
821  bool isArraySubscriptRefExpr() const {
822  return getKeyExpr()->getType()->isIntegralOrEnumerationType();
823  }
824 
826  return child_range(SubExprs, SubExprs+END_EXPR);
827  }
828 private:
829  friend class ASTStmtReader;
830 };
831 
832 
833 /// \brief An expression that sends a message to the given Objective-C
834 /// object or class.
835 ///
836 /// The following contains two message send expressions:
837 ///
838 /// \code
839 /// [[NSString alloc] initWithString:@"Hello"]
840 /// \endcode
841 ///
842 /// The innermost message send invokes the "alloc" class method on the
843 /// NSString class, while the outermost message send invokes the
844 /// "initWithString" instance method on the object returned from
845 /// NSString's "alloc". In all, an Objective-C message send can take
846 /// on four different (although related) forms:
847 ///
848 /// 1. Send to an object instance.
849 /// 2. Send to a class.
850 /// 3. Send to the superclass instance of the current class.
851 /// 4. Send to the superclass of the current class.
852 ///
853 /// All four kinds of message sends are modeled by the ObjCMessageExpr
854 /// class, and can be distinguished via \c getReceiverKind(). Example:
855 ///
856 /// The "void *" trailing objects are actually ONE void * (the
857 /// receiver pointer), and NumArgs Expr *. But due to the
858 /// implementation of children(), these must be together contiguously.
859 
860 class ObjCMessageExpr final
861  : public Expr,
862  private llvm::TrailingObjects<ObjCMessageExpr, void *, SourceLocation> {
863  /// \brief Stores either the selector that this message is sending
864  /// to (when \c HasMethod is zero) or an \c ObjCMethodDecl pointer
865  /// referring to the method that we type-checked against.
866  uintptr_t SelectorOrMethod;
867 
868  enum { NumArgsBitWidth = 16 };
869 
870  /// \brief The number of arguments in the message send, not
871  /// including the receiver.
872  unsigned NumArgs : NumArgsBitWidth;
873 
874  /// \brief The kind of message send this is, which is one of the
875  /// ReceiverKind values.
876  ///
877  /// We pad this out to a byte to avoid excessive masking and shifting.
878  unsigned Kind : 8;
879 
880  /// \brief Whether we have an actual method prototype in \c
881  /// SelectorOrMethod.
882  ///
883  /// When non-zero, we have a method declaration; otherwise, we just
884  /// have a selector.
885  unsigned HasMethod : 1;
886 
887  /// \brief Whether this message send is a "delegate init call",
888  /// i.e. a call of an init method on self from within an init method.
889  unsigned IsDelegateInitCall : 1;
890 
891  /// \brief Whether this message send was implicitly generated by
892  /// the implementation rather than explicitly written by the user.
893  unsigned IsImplicit : 1;
894 
895  /// \brief Whether the locations of the selector identifiers are in a
896  /// "standard" position, a enum SelectorLocationsKind.
897  unsigned SelLocsKind : 2;
898 
899  /// \brief When the message expression is a send to 'super', this is
900  /// the location of the 'super' keyword.
901  SourceLocation SuperLoc;
902 
903  /// \brief The source locations of the open and close square
904  /// brackets ('[' and ']', respectively).
905  SourceLocation LBracLoc, RBracLoc;
906 
907  size_t numTrailingObjects(OverloadToken<void *>) const { return NumArgs + 1; }
908 
909  void setNumArgs(unsigned Num) {
910  assert((Num >> NumArgsBitWidth) == 0 && "Num of args is out of range!");
911  NumArgs = Num;
912  }
913 
914  ObjCMessageExpr(EmptyShell Empty, unsigned NumArgs)
915  : Expr(ObjCMessageExprClass, Empty), SelectorOrMethod(0), Kind(0),
916  HasMethod(0), IsDelegateInitCall(0), IsImplicit(0), SelLocsKind(0) {
917  setNumArgs(NumArgs);
918  }
919 
921  SourceLocation LBracLoc,
922  SourceLocation SuperLoc,
923  bool IsInstanceSuper,
924  QualType SuperType,
925  Selector Sel,
926  ArrayRef<SourceLocation> SelLocs,
927  SelectorLocationsKind SelLocsK,
928  ObjCMethodDecl *Method,
929  ArrayRef<Expr *> Args,
930  SourceLocation RBracLoc,
931  bool isImplicit);
933  SourceLocation LBracLoc,
934  TypeSourceInfo *Receiver,
935  Selector Sel,
936  ArrayRef<SourceLocation> SelLocs,
937  SelectorLocationsKind SelLocsK,
938  ObjCMethodDecl *Method,
939  ArrayRef<Expr *> Args,
940  SourceLocation RBracLoc,
941  bool isImplicit);
943  SourceLocation LBracLoc,
944  Expr *Receiver,
945  Selector Sel,
946  ArrayRef<SourceLocation> SelLocs,
947  SelectorLocationsKind SelLocsK,
948  ObjCMethodDecl *Method,
949  ArrayRef<Expr *> Args,
950  SourceLocation RBracLoc,
951  bool isImplicit);
952 
953  void initArgsAndSelLocs(ArrayRef<Expr *> Args,
954  ArrayRef<SourceLocation> SelLocs,
955  SelectorLocationsKind SelLocsK);
956 
957  /// \brief Retrieve the pointer value of the message receiver.
958  void *getReceiverPointer() const { return *getTrailingObjects<void *>(); }
959 
960  /// \brief Set the pointer value of the message receiver.
961  void setReceiverPointer(void *Value) {
962  *getTrailingObjects<void *>() = Value;
963  }
964 
965  SelectorLocationsKind getSelLocsKind() const {
966  return (SelectorLocationsKind)SelLocsKind;
967  }
968  bool hasStandardSelLocs() const {
969  return getSelLocsKind() != SelLoc_NonStandard;
970  }
971 
972  /// \brief Get a pointer to the stored selector identifiers locations array.
973  /// No locations will be stored if HasStandardSelLocs is true.
974  SourceLocation *getStoredSelLocs() {
975  return getTrailingObjects<SourceLocation>();
976  }
977  const SourceLocation *getStoredSelLocs() const {
978  return getTrailingObjects<SourceLocation>();
979  }
980 
981  /// \brief Get the number of stored selector identifiers locations.
982  /// No locations will be stored if HasStandardSelLocs is true.
983  unsigned getNumStoredSelLocs() const {
984  if (hasStandardSelLocs())
985  return 0;
986  return getNumSelectorLocs();
987  }
988 
989  static ObjCMessageExpr *alloc(const ASTContext &C,
990  ArrayRef<Expr *> Args,
991  SourceLocation RBraceLoc,
992  ArrayRef<SourceLocation> SelLocs,
993  Selector Sel,
994  SelectorLocationsKind &SelLocsK);
995  static ObjCMessageExpr *alloc(const ASTContext &C,
996  unsigned NumArgs,
997  unsigned NumStoredSelLocs);
998 
999 public:
1000  /// \brief The kind of receiver this message is sending to.
1002  /// \brief The receiver is a class.
1003  Class = 0,
1004  /// \brief The receiver is an object instance.
1006  /// \brief The receiver is a superclass.
1008  /// \brief The receiver is the instance of the superclass object.
1009  SuperInstance
1010  };
1011 
1012  /// \brief Create a message send to super.
1013  ///
1014  /// \param Context The ASTContext in which this expression will be created.
1015  ///
1016  /// \param T The result type of this message.
1017  ///
1018  /// \param VK The value kind of this message. A message returning
1019  /// a l-value or r-value reference will be an l-value or x-value,
1020  /// respectively.
1021  ///
1022  /// \param LBracLoc The location of the open square bracket '['.
1023  ///
1024  /// \param SuperLoc The location of the "super" keyword.
1025  ///
1026  /// \param IsInstanceSuper Whether this is an instance "super"
1027  /// message (otherwise, it's a class "super" message).
1028  ///
1029  /// \param Sel The selector used to determine which method gets called.
1030  ///
1031  /// \param Method The Objective-C method against which this message
1032  /// send was type-checked. May be NULL.
1033  ///
1034  /// \param Args The message send arguments.
1035  ///
1036  /// \param RBracLoc The location of the closing square bracket ']'.
1037  static ObjCMessageExpr *Create(const ASTContext &Context, QualType T,
1038  ExprValueKind VK,
1039  SourceLocation LBracLoc,
1040  SourceLocation SuperLoc,
1041  bool IsInstanceSuper,
1042  QualType SuperType,
1043  Selector Sel,
1044  ArrayRef<SourceLocation> SelLocs,
1045  ObjCMethodDecl *Method,
1046  ArrayRef<Expr *> Args,
1047  SourceLocation RBracLoc,
1048  bool isImplicit);
1049 
1050  /// \brief Create a class message send.
1051  ///
1052  /// \param Context The ASTContext in which this expression will be created.
1053  ///
1054  /// \param T The result type of this message.
1055  ///
1056  /// \param VK The value kind of this message. A message returning
1057  /// a l-value or r-value reference will be an l-value or x-value,
1058  /// respectively.
1059  ///
1060  /// \param LBracLoc The location of the open square bracket '['.
1061  ///
1062  /// \param Receiver The type of the receiver, including
1063  /// source-location information.
1064  ///
1065  /// \param Sel The selector used to determine which method gets called.
1066  ///
1067  /// \param Method The Objective-C method against which this message
1068  /// send was type-checked. May be NULL.
1069  ///
1070  /// \param Args The message send arguments.
1071  ///
1072  /// \param RBracLoc The location of the closing square bracket ']'.
1073  static ObjCMessageExpr *Create(const ASTContext &Context, QualType T,
1074  ExprValueKind VK,
1075  SourceLocation LBracLoc,
1076  TypeSourceInfo *Receiver,
1077  Selector Sel,
1078  ArrayRef<SourceLocation> SelLocs,
1079  ObjCMethodDecl *Method,
1080  ArrayRef<Expr *> Args,
1081  SourceLocation RBracLoc,
1082  bool isImplicit);
1083 
1084  /// \brief Create an instance message send.
1085  ///
1086  /// \param Context The ASTContext in which this expression will be created.
1087  ///
1088  /// \param T The result type of this message.
1089  ///
1090  /// \param VK The value kind of this message. A message returning
1091  /// a l-value or r-value reference will be an l-value or x-value,
1092  /// respectively.
1093  ///
1094  /// \param LBracLoc The location of the open square bracket '['.
1095  ///
1096  /// \param Receiver The expression used to produce the object that
1097  /// will receive this message.
1098  ///
1099  /// \param Sel The selector used to determine which method gets called.
1100  ///
1101  /// \param Method The Objective-C method against which this message
1102  /// send was type-checked. May be NULL.
1103  ///
1104  /// \param Args The message send arguments.
1105  ///
1106  /// \param RBracLoc The location of the closing square bracket ']'.
1107  static ObjCMessageExpr *Create(const ASTContext &Context, QualType T,
1108  ExprValueKind VK,
1109  SourceLocation LBracLoc,
1110  Expr *Receiver,
1111  Selector Sel,
1112  ArrayRef<SourceLocation> SeLocs,
1113  ObjCMethodDecl *Method,
1114  ArrayRef<Expr *> Args,
1115  SourceLocation RBracLoc,
1116  bool isImplicit);
1117 
1118  /// \brief Create an empty Objective-C message expression, to be
1119  /// filled in by subsequent calls.
1120  ///
1121  /// \param Context The context in which the message send will be created.
1122  ///
1123  /// \param NumArgs The number of message arguments, not including
1124  /// the receiver.
1125  static ObjCMessageExpr *CreateEmpty(const ASTContext &Context,
1126  unsigned NumArgs,
1127  unsigned NumStoredSelLocs);
1128 
1129  /// \brief Indicates whether the message send was implicitly
1130  /// generated by the implementation. If false, it was written explicitly
1131  /// in the source code.
1132  bool isImplicit() const { return IsImplicit; }
1133 
1134  /// \brief Determine the kind of receiver that this message is being
1135  /// sent to.
1137 
1138  /// \brief Source range of the receiver.
1139  SourceRange getReceiverRange() const;
1140 
1141  /// \brief Determine whether this is an instance message to either a
1142  /// computed object or to super.
1143  bool isInstanceMessage() const {
1144  return getReceiverKind() == Instance || getReceiverKind() == SuperInstance;
1145  }
1146 
1147  /// \brief Determine whether this is an class message to either a
1148  /// specified class or to super.
1149  bool isClassMessage() const {
1150  return getReceiverKind() == Class || getReceiverKind() == SuperClass;
1151  }
1152 
1153  /// \brief Returns the object expression (receiver) for an instance message,
1154  /// or null for a message that is not an instance message.
1156  if (getReceiverKind() == Instance)
1157  return static_cast<Expr *>(getReceiverPointer());
1158 
1159  return nullptr;
1160  }
1161  const Expr *getInstanceReceiver() const {
1162  return const_cast<ObjCMessageExpr*>(this)->getInstanceReceiver();
1163  }
1164 
1165  /// \brief Turn this message send into an instance message that
1166  /// computes the receiver object with the given expression.
1168  Kind = Instance;
1169  setReceiverPointer(rec);
1170  }
1171 
1172  /// \brief Returns the type of a class message send, or NULL if the
1173  /// message is not a class message.
1175  if (TypeSourceInfo *TSInfo = getClassReceiverTypeInfo())
1176  return TSInfo->getType();
1177 
1178  return QualType();
1179  }
1180 
1181  /// \brief Returns a type-source information of a class message
1182  /// send, or NULL if the message is not a class message.
1184  if (getReceiverKind() == Class)
1185  return reinterpret_cast<TypeSourceInfo *>(getReceiverPointer());
1186  return nullptr;
1187  }
1188 
1190  Kind = Class;
1191  setReceiverPointer(TSInfo);
1192  }
1193 
1194  /// \brief Retrieve the location of the 'super' keyword for a class
1195  /// or instance message to 'super', otherwise an invalid source location.
1197  if (getReceiverKind() == SuperInstance || getReceiverKind() == SuperClass)
1198  return SuperLoc;
1199 
1200  return SourceLocation();
1201  }
1202 
1203  /// \brief Retrieve the receiver type to which this message is being directed.
1204  ///
1205  /// This routine cross-cuts all of the different kinds of message
1206  /// sends to determine what the underlying (statically known) type
1207  /// of the receiver will be; use \c getReceiverKind() to determine
1208  /// whether the message is a class or an instance method, whether it
1209  /// is a send to super or not, etc.
1210  ///
1211  /// \returns The type of the receiver.
1212  QualType getReceiverType() const;
1213 
1214  /// \brief Retrieve the Objective-C interface to which this message
1215  /// is being directed, if known.
1216  ///
1217  /// This routine cross-cuts all of the different kinds of message
1218  /// sends to determine what the underlying (statically known) type
1219  /// of the receiver will be; use \c getReceiverKind() to determine
1220  /// whether the message is a class or an instance method, whether it
1221  /// is a send to super or not, etc.
1222  ///
1223  /// \returns The Objective-C interface if known, otherwise NULL.
1224  ObjCInterfaceDecl *getReceiverInterface() const;
1225 
1226  /// \brief Retrieve the type referred to by 'super'.
1227  ///
1228  /// The returned type will either be an ObjCInterfaceType (for an
1229  /// class message to super) or an ObjCObjectPointerType that refers
1230  /// to a class (for an instance message to super);
1232  if (getReceiverKind() == SuperInstance || getReceiverKind() == SuperClass)
1233  return QualType::getFromOpaquePtr(getReceiverPointer());
1234 
1235  return QualType();
1236  }
1237 
1238  void setSuper(SourceLocation Loc, QualType T, bool IsInstanceSuper) {
1239  Kind = IsInstanceSuper? SuperInstance : SuperClass;
1240  SuperLoc = Loc;
1241  setReceiverPointer(T.getAsOpaquePtr());
1242  }
1243 
1244  Selector getSelector() const;
1245 
1247  HasMethod = false;
1248  SelectorOrMethod = reinterpret_cast<uintptr_t>(S.getAsOpaquePtr());
1249  }
1250 
1251  const ObjCMethodDecl *getMethodDecl() const {
1252  if (HasMethod)
1253  return reinterpret_cast<const ObjCMethodDecl *>(SelectorOrMethod);
1254 
1255  return nullptr;
1256  }
1257 
1259  if (HasMethod)
1260  return reinterpret_cast<ObjCMethodDecl *>(SelectorOrMethod);
1261 
1262  return nullptr;
1263  }
1264 
1266  HasMethod = true;
1267  SelectorOrMethod = reinterpret_cast<uintptr_t>(MD);
1268  }
1269 
1271  if (HasMethod) return getMethodDecl()->getMethodFamily();
1272  return getSelector().getMethodFamily();
1273  }
1274 
1275  /// \brief Return the number of actual arguments in this message,
1276  /// not counting the receiver.
1277  unsigned getNumArgs() const { return NumArgs; }
1278 
1279  /// \brief Retrieve the arguments to this message, not including the
1280  /// receiver.
1282  return reinterpret_cast<Expr **>(getTrailingObjects<void *>() + 1);
1283  }
1284  const Expr * const *getArgs() const {
1285  return reinterpret_cast<const Expr *const *>(getTrailingObjects<void *>() +
1286  1);
1287  }
1288 
1289  /// getArg - Return the specified argument.
1290  Expr *getArg(unsigned Arg) {
1291  assert(Arg < NumArgs && "Arg access out of range!");
1292  return getArgs()[Arg];
1293  }
1294  const Expr *getArg(unsigned Arg) const {
1295  assert(Arg < NumArgs && "Arg access out of range!");
1296  return getArgs()[Arg];
1297  }
1298  /// setArg - Set the specified argument.
1299  void setArg(unsigned Arg, Expr *ArgExpr) {
1300  assert(Arg < NumArgs && "Arg access out of range!");
1301  getArgs()[Arg] = ArgExpr;
1302  }
1303 
1304  /// isDelegateInitCall - Answers whether this message send has been
1305  /// tagged as a "delegate init call", i.e. a call to a method in the
1306  /// -init family on self from within an -init method implementation.
1307  bool isDelegateInitCall() const { return IsDelegateInitCall; }
1308  void setDelegateInitCall(bool isDelegate) { IsDelegateInitCall = isDelegate; }
1309 
1310  SourceLocation getLeftLoc() const { return LBracLoc; }
1311  SourceLocation getRightLoc() const { return RBracLoc; }
1312 
1314  if (isImplicit())
1315  return getLocStart();
1316  return getSelectorLoc(0);
1317  }
1318  SourceLocation getSelectorLoc(unsigned Index) const {
1319  assert(Index < getNumSelectorLocs() && "Index out of range!");
1320  if (hasStandardSelLocs())
1321  return getStandardSelectorLoc(Index, getSelector(),
1322  getSelLocsKind() == SelLoc_StandardWithSpace,
1323  llvm::makeArrayRef(const_cast<Expr**>(getArgs()),
1324  getNumArgs()),
1325  RBracLoc);
1326  return getStoredSelLocs()[Index];
1327  }
1328 
1329  void getSelectorLocs(SmallVectorImpl<SourceLocation> &SelLocs) const;
1330 
1331  unsigned getNumSelectorLocs() const {
1332  if (isImplicit())
1333  return 0;
1334  Selector Sel = getSelector();
1335  if (Sel.isUnarySelector())
1336  return 1;
1337  return Sel.getNumArgs();
1338  }
1339 
1341  LBracLoc = R.getBegin();
1342  RBracLoc = R.getEnd();
1343  }
1344  SourceLocation getLocStart() const LLVM_READONLY { return LBracLoc; }
1345  SourceLocation getLocEnd() const LLVM_READONLY { return RBracLoc; }
1346 
1347  static bool classof(const Stmt *T) {
1348  return T->getStmtClass() == ObjCMessageExprClass;
1349  }
1350 
1351  // Iterators
1353 
1356 
1357  llvm::iterator_range<arg_iterator> arguments() {
1358  return llvm::make_range(arg_begin(), arg_end());
1359  }
1360 
1361  llvm::iterator_range<const_arg_iterator> arguments() const {
1362  return llvm::make_range(arg_begin(), arg_end());
1363  }
1364 
1365  arg_iterator arg_begin() { return reinterpret_cast<Stmt **>(getArgs()); }
1366  arg_iterator arg_end() {
1367  return reinterpret_cast<Stmt **>(getArgs() + NumArgs);
1368  }
1369  const_arg_iterator arg_begin() const {
1370  return reinterpret_cast<Stmt const * const*>(getArgs());
1371  }
1372  const_arg_iterator arg_end() const {
1373  return reinterpret_cast<Stmt const * const*>(getArgs() + NumArgs);
1374  }
1375 
1377  friend class ASTStmtReader;
1378  friend class ASTStmtWriter;
1379 };
1380 
1381 /// ObjCIsaExpr - Represent X->isa and X.isa when X is an ObjC 'id' type.
1382 /// (similar in spirit to MemberExpr).
1383 class ObjCIsaExpr : public Expr {
1384  /// Base - the expression for the base object pointer.
1385  Stmt *Base;
1386 
1387  /// IsaMemberLoc - This is the location of the 'isa'.
1388  SourceLocation IsaMemberLoc;
1389 
1390  /// OpLoc - This is the location of '.' or '->'
1391  SourceLocation OpLoc;
1392 
1393  /// IsArrow - True if this is "X->F", false if this is "X.F".
1394  bool IsArrow;
1395 public:
1396  ObjCIsaExpr(Expr *base, bool isarrow, SourceLocation l, SourceLocation oploc,
1397  QualType ty)
1398  : Expr(ObjCIsaExprClass, ty, VK_LValue, OK_Ordinary,
1399  /*TypeDependent=*/false, base->isValueDependent(),
1400  base->isInstantiationDependent(),
1401  /*ContainsUnexpandedParameterPack=*/false),
1402  Base(base), IsaMemberLoc(l), OpLoc(oploc), IsArrow(isarrow) {}
1403 
1404  /// \brief Build an empty expression.
1405  explicit ObjCIsaExpr(EmptyShell Empty) : Expr(ObjCIsaExprClass, Empty) { }
1406 
1407  void setBase(Expr *E) { Base = E; }
1408  Expr *getBase() const { return cast<Expr>(Base); }
1409 
1410  bool isArrow() const { return IsArrow; }
1411  void setArrow(bool A) { IsArrow = A; }
1412 
1413  /// getMemberLoc - Return the location of the "member", in X->F, it is the
1414  /// location of 'F'.
1415  SourceLocation getIsaMemberLoc() const { return IsaMemberLoc; }
1416  void setIsaMemberLoc(SourceLocation L) { IsaMemberLoc = L; }
1417 
1418  SourceLocation getOpLoc() const { return OpLoc; }
1419  void setOpLoc(SourceLocation L) { OpLoc = L; }
1420 
1421  SourceLocation getLocStart() const LLVM_READONLY {
1422  return getBase()->getLocStart();
1423  }
1424 
1425  SourceLocation getBaseLocEnd() const LLVM_READONLY {
1426  return getBase()->getLocEnd();
1427  }
1428 
1429  SourceLocation getLocEnd() const LLVM_READONLY { return IsaMemberLoc; }
1430 
1431  SourceLocation getExprLoc() const LLVM_READONLY { return IsaMemberLoc; }
1432 
1433  static bool classof(const Stmt *T) {
1434  return T->getStmtClass() == ObjCIsaExprClass;
1435  }
1436 
1437  // Iterators
1438  child_range children() { return child_range(&Base, &Base+1); }
1439 };
1440 
1441 
1442 /// ObjCIndirectCopyRestoreExpr - Represents the passing of a function
1443 /// argument by indirect copy-restore in ARC. This is used to support
1444 /// passing indirect arguments with the wrong lifetime, e.g. when
1445 /// passing the address of a __strong local variable to an 'out'
1446 /// parameter. This expression kind is only valid in an "argument"
1447 /// position to some sort of call expression.
1448 ///
1449 /// The parameter must have type 'pointer to T', and the argument must
1450 /// have type 'pointer to U', where T and U agree except possibly in
1451 /// qualification. If the argument value is null, then a null pointer
1452 /// is passed; otherwise it points to an object A, and:
1453 /// 1. A temporary object B of type T is initialized, either by
1454 /// zero-initialization (used when initializing an 'out' parameter)
1455 /// or copy-initialization (used when initializing an 'inout'
1456 /// parameter).
1457 /// 2. The address of the temporary is passed to the function.
1458 /// 3. If the call completes normally, A is move-assigned from B.
1459 /// 4. Finally, A is destroyed immediately.
1460 ///
1461 /// Currently 'T' must be a retainable object lifetime and must be
1462 /// __autoreleasing; this qualifier is ignored when initializing
1463 /// the value.
1465  Stmt *Operand;
1466 
1467  // unsigned ObjCIndirectCopyRestoreBits.ShouldCopy : 1;
1468 
1469  friend class ASTReader;
1470  friend class ASTStmtReader;
1471 
1472  void setShouldCopy(bool shouldCopy) {
1473  ObjCIndirectCopyRestoreExprBits.ShouldCopy = shouldCopy;
1474  }
1475 
1476  explicit ObjCIndirectCopyRestoreExpr(EmptyShell Empty)
1477  : Expr(ObjCIndirectCopyRestoreExprClass, Empty) { }
1478 
1479 public:
1480  ObjCIndirectCopyRestoreExpr(Expr *operand, QualType type, bool shouldCopy)
1481  : Expr(ObjCIndirectCopyRestoreExprClass, type, VK_LValue, OK_Ordinary,
1482  operand->isTypeDependent(), operand->isValueDependent(),
1483  operand->isInstantiationDependent(),
1484  operand->containsUnexpandedParameterPack()),
1485  Operand(operand) {
1486  setShouldCopy(shouldCopy);
1487  }
1488 
1489  Expr *getSubExpr() { return cast<Expr>(Operand); }
1490  const Expr *getSubExpr() const { return cast<Expr>(Operand); }
1491 
1492  /// shouldCopy - True if we should do the 'copy' part of the
1493  /// copy-restore. If false, the temporary will be zero-initialized.
1494  bool shouldCopy() const { return ObjCIndirectCopyRestoreExprBits.ShouldCopy; }
1495 
1496  child_range children() { return child_range(&Operand, &Operand+1); }
1497 
1498  // Source locations are determined by the subexpression.
1499  SourceLocation getLocStart() const LLVM_READONLY {
1500  return Operand->getLocStart();
1501  }
1502  SourceLocation getLocEnd() const LLVM_READONLY { return Operand->getLocEnd();}
1503 
1504  SourceLocation getExprLoc() const LLVM_READONLY {
1505  return getSubExpr()->getExprLoc();
1506  }
1507 
1508  static bool classof(const Stmt *s) {
1509  return s->getStmtClass() == ObjCIndirectCopyRestoreExprClass;
1510  }
1511 };
1512 
1513 /// \brief An Objective-C "bridged" cast expression, which casts between
1514 /// Objective-C pointers and C pointers, transferring ownership in the process.
1515 ///
1516 /// \code
1517 /// NSString *str = (__bridge_transfer NSString *)CFCreateString();
1518 /// \endcode
1520  : public ExplicitCastExpr,
1521  private llvm::TrailingObjects<ObjCBridgedCastExpr, CXXBaseSpecifier *> {
1522  SourceLocation LParenLoc;
1523  SourceLocation BridgeKeywordLoc;
1524  unsigned Kind : 2;
1525 
1526  friend TrailingObjects;
1527  friend class CastExpr;
1528  friend class ASTStmtReader;
1529  friend class ASTStmtWriter;
1530 
1531 public:
1533  CastKind CK, SourceLocation BridgeKeywordLoc,
1534  TypeSourceInfo *TSInfo, Expr *Operand)
1535  : ExplicitCastExpr(ObjCBridgedCastExprClass, TSInfo->getType(), VK_RValue,
1536  CK, Operand, 0, TSInfo),
1537  LParenLoc(LParenLoc), BridgeKeywordLoc(BridgeKeywordLoc), Kind(Kind) { }
1538 
1539  /// \brief Construct an empty Objective-C bridged cast.
1541  : ExplicitCastExpr(ObjCBridgedCastExprClass, Shell, 0) { }
1542 
1543  SourceLocation getLParenLoc() const { return LParenLoc; }
1544 
1545  /// \brief Determine which kind of bridge is being performed via this cast.
1547  return static_cast<ObjCBridgeCastKind>(Kind);
1548  }
1549 
1550  /// \brief Retrieve the kind of bridge being performed as a string.
1551  StringRef getBridgeKindName() const;
1552 
1553  /// \brief The location of the bridge keyword.
1554  SourceLocation getBridgeKeywordLoc() const { return BridgeKeywordLoc; }
1555 
1556  SourceLocation getLocStart() const LLVM_READONLY { return LParenLoc; }
1557  SourceLocation getLocEnd() const LLVM_READONLY {
1558  return getSubExpr()->getLocEnd();
1559  }
1560 
1561  static bool classof(const Stmt *T) {
1562  return T->getStmtClass() == ObjCBridgedCastExprClass;
1563  }
1564 };
1565 
1566 /// \brief A runtime availability query.
1567 ///
1568 /// There are 2 ways to spell this node:
1569 /// \code
1570 /// @available(macos 10.10, ios 8, *); // Objective-C
1571 /// __builtin_available(macos 10.10, ios 8, *); // C, C++, and Objective-C
1572 /// \endcode
1573 ///
1574 /// Note that we only need to keep track of one \c VersionTuple here, which is
1575 /// the one that corresponds to the current deployment target. This is meant to
1576 /// be used in the condition of an \c if, but it is also usable as top level
1577 /// expressions.
1578 ///
1580  VersionTuple VersionToCheck;
1581  SourceLocation AtLoc, RParen;
1582 
1583  friend class ASTStmtReader;
1584 public:
1586  SourceLocation RParen, QualType Ty)
1587  : Expr(ObjCAvailabilityCheckExprClass, Ty, VK_RValue, OK_Ordinary, false,
1588  false, false, false),
1589  VersionToCheck(VersionToCheck), AtLoc(AtLoc), RParen(RParen) {}
1590 
1592  : Expr(ObjCAvailabilityCheckExprClass, Shell) {}
1593 
1594  SourceLocation getLocStart() const { return AtLoc; }
1595  SourceLocation getLocEnd() const { return RParen; }
1596  SourceRange getSourceRange() const { return {AtLoc, RParen}; }
1597 
1598  /// \brief This may be '*', in which case this should fold to true.
1599  bool hasVersion() const { return !VersionToCheck.empty(); }
1600  VersionTuple getVersion() { return VersionToCheck; }
1601 
1604  }
1605 
1606  static bool classof(const Stmt *T) {
1607  return T->getStmtClass() == ObjCAvailabilityCheckExprClass;
1608  }
1609 };
1610 
1611 } // end namespace clang
1612 
1613 #endif
ObjCPropertyRefExpr - A dot-syntax expression to access an ObjC property.
Definition: ExprObjC.h:539
ObjCIndirectCopyRestoreExpr - Represents the passing of a function argument by indirect copy-restore ...
Definition: ExprObjC.h:1464
For nullary selectors, immediately before the end: "[foo release]" / "-(void)release;" Or with a spac...
ConstExprIterator const_arg_iterator
Definition: ExprObjC.h:130
bool getValue() const
Definition: ExprObjC.h:71
The receiver is an object instance.
Definition: ExprObjC.h:1005
SourceLocation getOpLoc() const
Definition: ExprObjC.h:1418
ObjCDictionaryElement getKeyValueElement(unsigned Index) const
Definition: ExprObjC.h:309
child_range children()
Definition: ExprObjC.h:85
Smart pointer class that efficiently represents Objective-C method names.
SourceLocation getLocStart() const LLVM_READONLY
Definition: ExprObjC.h:462
A (possibly-)qualified type.
Definition: Type.h:614
static bool classof(const Stmt *T)
Definition: ExprObjC.h:330
void * getAsOpaquePtr() const
SourceLocation getLocEnd() const LLVM_READONLY
Definition: ExprObjC.h:801
child_range children()
Definition: ExprObjC.h:716
Represents a version number in the form major[.minor[.subminor[.build]]].
Definition: VersionTuple.h:26
ObjCMethodDecl * getAtIndexMethodDecl() const
Definition: ExprObjC.h:813
SourceLocation getLocEnd() const LLVM_READONLY
Definition: ExprObjC.h:709
Expr(StmtClass SC, QualType T, ExprValueKind VK, ExprObjectKind OK, bool TD, bool VD, bool ID, bool ContainsUnexpandedParameterPack)
Definition: Expr.h:110
SourceLocation EllipsisLoc
The location of the ellipsis, if this element is a pack expansion.
Definition: ExprObjC.h:248
bool isSuperReceiver() const
Definition: ExprObjC.h:700
ObjCBridgeCastKind
The kind of bridging performed by the Objective-C bridge cast.
DominatorTree GraphTraits specialization so the DominatorTree can be iterable by generic graph iterat...
Definition: Dominators.h:26
ObjCProtocolDecl * getProtocol() const
Definition: ExprObjC.h:453
Stmt - This represents one statement.
Definition: Stmt.h:60
ObjCMethodDecl * setAtIndexMethodDecl() const
Definition: ExprObjC.h:817
void setArrow(bool A)
Definition: ExprObjC.h:1411
bool isSpecificPlaceholderType(unsigned K) const
Test for a specific placeholder type.
Definition: Type.h:5950
void setAtLoc(SourceLocation L)
Definition: ExprObjC.h:414
void setRBracket(SourceLocation RB)
Definition: ExprObjC.h:796
SourceLocation getLocEnd() const LLVM_READONLY
Definition: ExprObjC.h:118
ObjCMethodDecl * getImplicitPropertySetter() const
Definition: ExprObjC.h:643
StringRef P
const_arg_iterator arg_end() const
Definition: ExprObjC.h:135
ObjCStringLiteral(EmptyShell Empty)
Definition: ExprObjC.h:37
SourceLocation getExprLoc() const LLVM_READONLY
Definition: ExprObjC.h:1504
void setSuper(SourceLocation Loc, QualType T, bool IsInstanceSuper)
Definition: ExprObjC.h:1238
The base class of the type hierarchy.
Definition: Type.h:1300
SourceLocation getLocStart() const LLVM_READONLY
Definition: ExprObjC.h:326
ObjCSubscriptRefExpr - used for array and dictionary subscripting.
Definition: ExprObjC.h:760
void setValue(bool V)
Definition: ExprObjC.h:72
A container of type source information.
Definition: Decl.h:62
SourceLocation getLocStart() const LLVM_READONLY
Definition: ExprObjC.h:798
void setInstanceReceiver(Expr *rec)
Turn this message send into an instance message that computes the receiver object with the given expr...
Definition: ExprObjC.h:1167
SourceLocation getLocEnd() const LLVM_READONLY
Definition: ExprObjC.h:463
ObjCBoxedExpr(Expr *E, QualType T, ObjCMethodDecl *method, SourceRange R)
Definition: ExprObjC.h:99
void setLocation(SourceLocation L)
Definition: ExprObjC.h:519
void setDelegateInitCall(bool isDelegate)
Definition: ExprObjC.h:1308
void setProtocol(ObjCProtocolDecl *P)
Definition: ExprObjC.h:454
SourceLocation getAtLoc() const
Definition: ExprObjC.h:44
ObjCPropertyRefExpr(ObjCPropertyDecl *PD, QualType t, ExprValueKind VK, ExprObjectKind OK, SourceLocation l, Expr *base)
Definition: ExprObjC.h:573
Selector getSetterSelector() const
Definition: ExprObjC.h:654
ObjCIsaExpr - Represent X->isa and X.isa when X is an ObjC &#39;id&#39; type.
Definition: ExprObjC.h:1383
unsigned NumExpansionsPlusOne
If non-zero, the number of elements that this pack expansion will expand to (+1). ...
Definition: ExprObjC.h:252
SourceLocation getAtLoc() const
Definition: ExprObjC.h:412
void setOpLoc(SourceLocation L)
Definition: ExprObjC.h:1419
ObjCInterfaceDecl * getClassReceiver() const
Definition: ExprObjC.h:696
bool isArrow() const
Definition: ExprObjC.h:1410
ObjCMethodDecl - Represents an instance or class method declaration.
Definition: DeclObjC.h:113
SourceLocation getLeftLoc() const
Definition: ExprObjC.h:1310
ObjCBridgedCastExpr(EmptyShell Shell)
Construct an empty Objective-C bridged cast.
Definition: ExprObjC.h:1540
const StringLiteral * getString() const
Definition: ExprObjC.h:41
static bool classof(const Stmt *T)
Definition: ExprObjC.h:1433
child_range children()
Definition: ExprObjC.h:428
ObjCPropertyRefExpr(EmptyShell Empty)
Definition: ExprObjC.h:627
ReceiverKind
The kind of receiver this message is sending to.
Definition: ExprObjC.h:1001
const_arg_iterator arg_end() const
Definition: ExprObjC.h:1372
SourceRange getSourceRange() const LLVM_READONLY
Definition: ExprObjC.h:119
SourceLocation getLocEnd() const LLVM_READONLY
Definition: ExprObjC.h:384
static bool classof(const Stmt *T)
Definition: ExprObjC.h:529
child_range children()
Definition: ExprObjC.h:534
SourceLocation getLocEnd() const LLVM_READONLY
Definition: ExprObjC.h:418
ObjCPropertyDecl * getExplicitProperty() const
Definition: ExprObjC.h:633
void setAtLoc(SourceLocation L)
Definition: ExprObjC.h:45
SourceLocation getAtLoc() const
Definition: ExprObjC.h:457
TypeSourceInfo * getEncodedTypeSourceInfo() const
Definition: ExprObjC.h:378
SourceLocation getBaseLocEnd() const LLVM_READONLY
Definition: ExprObjC.h:1425
SourceLocation getLocStart() const LLVM_READONLY
Definition: ExprObjC.h:383
An element in an Objective-C dictionary literal.
Definition: ExprObjC.h:212
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition: ASTContext.h:128
Internal struct for storing Key/value pair.
Definition: ExprObjC.h:237
ObjCMethodFamily
A family of Objective-C methods.
void setKeyExpr(Stmt *S)
Definition: ExprObjC.h:811
bool isExplicitProperty() const
Definition: ExprObjC.h:631
ObjCPropertyRefExpr(ObjCMethodDecl *Getter, ObjCMethodDecl *Setter, QualType T, ExprValueKind VK, ExprObjectKind OK, SourceLocation IdLoc, Expr *Base)
Definition: ExprObjC.h:596
child_range children()
Definition: ExprObjC.h:201
StringLiteral * getString()
Definition: ExprObjC.h:40
ObjCEncodeExpr(EmptyShell Empty)
Definition: ExprObjC.h:368
SourceLocation getLocEnd() const LLVM_READONLY
Definition: ExprObjC.h:524
ObjCIndirectCopyRestoreExprBitfields ObjCIndirectCopyRestoreExprBits
Definition: Stmt.h:277
ObjCSubscriptRefExpr(Expr *base, Expr *key, QualType T, ExprValueKind VK, ExprObjectKind OK, ObjCMethodDecl *getMethod, ObjCMethodDecl *setMethod, SourceLocation RB)
Definition: ExprObjC.h:777
bool isClassMessage() const
Determine whether this is an class message to either a specified class or to super.
Definition: ExprObjC.h:1149
ObjCBoxedExpr(EmptyShell Empty)
Definition: ExprObjC.h:105
SourceLocation getLocEnd() const LLVM_READONLY
Definition: ExprObjC.h:48
ObjCArrayLiteral - used for objective-c array containers; as in: @["Hello", NSApp, [NSNumber numberWithInt:42]];.
Definition: ExprObjC.h:144
ObjCSelectorExpr(QualType T, Selector selInfo, SourceLocation at, SourceLocation rp)
Definition: ExprObjC.h:401
An r-value expression (a pr-value in the C++11 taxonomy) produces a temporary value.
Definition: Specifiers.h:107
Selector getSelector() const
Definition: ExprObjC.h:409
bool isUnarySelector() const
SourceLocation getOpLoc() const
Definition: ExprObjC.h:526
bool isArrow() const
Definition: ExprObjC.h:513
const Expr * getElement(unsigned Index) const
Definition: ExprObjC.h:191
Expr * getKeyExpr() const
Definition: ExprObjC.h:810
ObjCBoolLiteralExpr(bool val, QualType Ty, SourceLocation l)
Definition: ExprObjC.h:64
SelectorLocationsKind
Whether all locations of the selector identifiers are in a "standard" position.
bool isMessagingSetter() const
True if the property reference will result in a message to the setter.
Definition: ExprObjC.h:670
Expr * getBaseExpr() const
Definition: ExprObjC.h:807
SourceLocation getLocStart() const LLVM_READONLY
Definition: ExprObjC.h:1421
void setSelector(Selector S)
Definition: ExprObjC.h:410
void setLocation(SourceLocation L)
Definition: ExprObjC.h:78
SourceLocation getIsaMemberLoc() const
getMemberLoc - Return the location of the "member", in X->F, it is the location of &#39;F&#39;...
Definition: ExprObjC.h:1415
unsigned getNumSelectorLocs() const
Definition: ExprObjC.h:1331
bool isClassReceiver() const
Definition: ExprObjC.h:701
const Expr *const * getElements() const
Retrieve elements of array of literals.
Definition: ExprObjC.h:179
SourceLocation getLocEnd() const LLVM_READONLY
Definition: ExprObjC.h:75
void setString(StringLiteral *S)
Definition: ExprObjC.h:42
ObjCStringLiteral, used for Objective-C string literals i.e.
Definition: ExprObjC.h:29
static bool classof(const Stmt *T)
Definition: ExprObjC.h:1347
const Type * getTypePtr() const
Retrieves a pointer to the underlying (unqualified) type.
Definition: Type.h:5543
ObjCIsaExpr(Expr *base, bool isarrow, SourceLocation l, SourceLocation oploc, QualType ty)
Definition: ExprObjC.h:1396
CastExpr - Base class for type casts, including both implicit casts (ImplicitCastExpr) and explicit c...
Definition: Expr.h:2710
Represents an Objective-C protocol declaration.
Definition: DeclObjC.h:1985
Expr * Key
The key for the dictionary element.
Definition: ExprObjC.h:214
ObjCMethodDecl * getArrayWithObjectsMethod() const
Definition: ExprObjC.h:196
SourceLocation getLocStart() const LLVM_READONLY
Definition: ExprObjC.h:167
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:167
void * getAsOpaquePtr() const
Definition: Type.h:662
An ordinary object is located at an address in memory.
Definition: Specifiers.h:123
SourceLocation getLocStart() const LLVM_READONLY
Definition: ExprObjC.h:74
Represents an ObjC class declaration.
Definition: DeclObjC.h:1108
child_range children()
Definition: ExprObjC.h:825
SourceLocation getLocation() const
Definition: ExprObjC.h:77
ExprIterator arg_iterator
Definition: ExprObjC.h:1354
Iterator for iterating over Stmt * arrays that contain only Expr *.
Definition: Stmt.h:315
const Expr *const * getArgs() const
Definition: ExprObjC.h:1284
ObjCMethodDecl * getDictWithObjectsMethod() const
Definition: ExprObjC.h:323
ObjCBoolLiteralExpr(EmptyShell Empty)
Definition: ExprObjC.h:68
ObjCIvarDecl * getDecl()
Definition: ExprObjC.h:505
Const iterator for iterating over Stmt * arrays that contain only Expr *.
Definition: Stmt.h:329
SourceLocation getLocEnd() const
Definition: ExprObjC.h:1595
SourceLocation getLocEnd() const LLVM_READONLY
Definition: ExprObjC.h:1345
static bool classof(const Stmt *T)
Definition: ExprObjC.h:711
SourceLocation getRBracket() const
Definition: ExprObjC.h:795
CastKind
CastKind - The kind of operation required for a conversion.
SourceRange getSourceRange() const LLVM_READONLY
Definition: ExprObjC.h:169
SourceLocation getLocEnd() const LLVM_READONLY
Definition: Stmt.cpp:270
SourceLocation getRParenLoc() const
Definition: ExprObjC.h:413
void setIsMessagingGetter(bool val=true)
Definition: ExprObjC.h:674
ObjCAvailabilityCheckExpr(VersionTuple VersionToCheck, SourceLocation AtLoc, SourceLocation RParen, QualType Ty)
Definition: ExprObjC.h:1585
ObjCEncodeExpr(QualType T, TypeSourceInfo *EncodedType, SourceLocation at, SourceLocation rp)
Definition: ExprObjC.h:359
ObjCMethodDecl * getBoxingMethod() const
Definition: ExprObjC.h:111
Expr - This represents one expression.
Definition: Expr.h:106
const Expr * getInstanceReceiver() const
Definition: ExprObjC.h:1161
ObjCIvarRefExpr(EmptyShell Empty)
Definition: ExprObjC.h:502
ObjCIsaExpr(EmptyShell Empty)
Build an empty expression.
Definition: ExprObjC.h:1405
ExprValueKind
The categorization of expression values, currently following the C++11 scheme.
Definition: Specifiers.h:104
SourceLocation getLocStart() const LLVM_READONLY
Definition: ExprObjC.h:1556
const FunctionProtoType * T
SourceLocation getExprLoc() const LLVM_READONLY
Definition: ExprObjC.h:1431
SourceLocation getStandardSelectorLoc(unsigned Index, Selector Sel, bool WithArgSpace, ArrayRef< Expr *> Args, SourceLocation EndLoc)
Get the "standard" location of a selector identifier, e.g: For nullary selectors, immediately before ...
SourceLocation getLocStart() const LLVM_READONLY
Definition: ExprObjC.h:1499
ObjCDictionaryLiteral - AST node to represent objective-c dictionary literals; as in:"name" : NSUserN...
Definition: ExprObjC.h:257
ObjCSelectorExpr used for @selector in Objective-C.
Definition: ExprObjC.h:397
Expr ** getArgs()
Retrieve the arguments to this message, not including the receiver.
Definition: ExprObjC.h:1281
ObjCPropertyRefExpr(ObjCPropertyDecl *PD, QualType t, ExprValueKind VK, ExprObjectKind OK, SourceLocation l, SourceLocation sl, QualType st)
Definition: ExprObjC.h:585
static bool classof(const Stmt *T)
Definition: ExprObjC.h:803
ObjCStringLiteral(StringLiteral *SL, QualType T, SourceLocation L)
Definition: ExprObjC.h:33
Defines the clang::IdentifierInfo, clang::IdentifierTable, and clang::Selector interfaces.
QualType getType() const
Definition: Expr.h:128
Expr * getElement(unsigned Index)
getExpr - Return the Expr at the specified index.
Definition: ExprObjC.h:187
static OMPLinearClause * CreateEmpty(const ASTContext &C, unsigned NumVars)
Creates an empty clause with the place for NumVars variables.
Optional< unsigned > NumExpansions
The number of elements this pack expansion will expand to, if this is a pack expansion and is known...
Definition: ExprObjC.h:224
void setRParenLoc(SourceLocation L)
Definition: ExprObjC.h:460
QualType getEncodedType() const
Definition: ExprObjC.h:376
An expression that sends a message to the given Objective-C object or class.
Definition: ExprObjC.h:860
void setIsArrow(bool A)
Definition: ExprObjC.h:515
ObjCMethodDecl * getImplicitPropertyGetter() const
Definition: ExprObjC.h:638
SourceLocation getEnd() const
static bool classof(const Stmt *T)
Definition: ExprObjC.h:423
void setAtLoc(SourceLocation L)
Definition: ExprObjC.h:372
ReceiverKind getReceiverKind() const
Determine the kind of receiver that this message is being sent to.
Definition: ExprObjC.h:1136
unsigned getNumArgs() const
void setBase(Expr *base)
Definition: ExprObjC.h:511
void setRParenLoc(SourceLocation L)
Definition: ExprObjC.h:415
The result type of a method or function.
ObjCBridgeCastKind getBridgeKind() const
Determine which kind of bridge is being performed via this cast.
Definition: ExprObjC.h:1546
const_arg_iterator arg_begin() const
Definition: ExprObjC.h:1369
__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 &#39;children&#39; to permit easy iteration over the substatem...
Definition: Stmt.h:419
ObjCIvarRefExpr(ObjCIvarDecl *d, QualType t, SourceLocation l, SourceLocation oploc, Expr *base, bool arrow=false, bool freeIvar=false)
Definition: ExprObjC.h:490
Expr * getArg(unsigned Arg)
getArg - Return the specified argument.
Definition: ExprObjC.h:1290
SourceLocation getLocEnd() const LLVM_READONLY
Definition: ExprObjC.h:1502
ObjCPropertyRefExpr(ObjCMethodDecl *Getter, ObjCMethodDecl *Setter, QualType T, ExprValueKind VK, ExprObjectKind OK, SourceLocation IdLoc, SourceLocation ReceiverLoc, ObjCInterfaceDecl *Receiver)
Definition: ExprObjC.h:617
ConstExprIterator const_arg_iterator
Definition: ExprObjC.h:1355
bool empty() const
Determine whether this version information is empty (e.g., all version components are zero)...
Definition: VersionTuple.h:69
SourceLocation getProtocolIdLoc() const
Definition: ExprObjC.h:456
ObjCSubscriptRefExpr(EmptyShell Empty)
Definition: ExprObjC.h:792
unsigned getNumArgs() const
Return the number of actual arguments in this message, not counting the receiver. ...
Definition: ExprObjC.h:1277
#define false
Definition: stdbool.h:33
ObjCIndirectCopyRestoreExpr(Expr *operand, QualType type, bool shouldCopy)
Definition: ExprObjC.h:1480
Kind
static bool classof(const Stmt *T)
Definition: ExprObjC.h:80
bool isImplicitProperty() const
Definition: ExprObjC.h:630
bool isInstantiationDependent() const
Whether this expression is instantiation-dependent, meaning that it depends in some way on a template...
Definition: Expr.h:191
Encodes a location in the source.
Selector getGetterSelector() const
Definition: ExprObjC.h:648
llvm::iterator_range< child_iterator > child_range
Definition: Stmt.h:422
SourceLocation getLocEnd() const LLVM_READONLY
Definition: ExprObjC.h:1429
SourceLocation getLocStart() const LLVM_READONLY
Definition: ExprObjC.h:117
ObjCSelectorExpr(EmptyShell Empty)
Definition: ExprObjC.h:406
void setIsMessagingSetter(bool val=true)
Definition: ExprObjC.h:678
unsigned getNumElements() const
getNumElements - Return number of elements of objective-c dictionary literal.
Definition: ExprObjC.h:307
ObjCMethodFamily getMethodFamily() const
Definition: ExprObjC.h:1270
SourceRange getSourceRange() const LLVM_READONLY
Definition: ExprObjC.h:328
static bool classof(const Stmt *T)
Definition: ExprObjC.h:123
ExprObjectKind
A further classification of the kind of object referenced by an l-value or x-value.
Definition: Specifiers.h:121
void setClassReceiver(TypeSourceInfo *TSInfo)
Definition: ExprObjC.h:1189
SourceLocation getRParenLoc() const
Definition: ExprObjC.h:373
SourceLocation getSuperLoc() const
Retrieve the location of the &#39;super&#39; keyword for a class or instance message to &#39;super&#39;, otherwise an invalid source location.
Definition: ExprObjC.h:1196
SourceLocation getAtLoc() const
Definition: ExprObjC.h:371
SourceRange getSourceRange() const
Definition: ExprObjC.h:1596
void setIsFreeIvar(bool A)
Definition: ExprObjC.h:516
ObjCProtocolExpr used for protocol expression in Objective-C.
Definition: ExprObjC.h:441
SourceLocation getSelectorLoc(unsigned Index) const
Definition: ExprObjC.h:1318
bool isValueDependent() const
isValueDependent - Determines whether this expression is value-dependent (C++ [temp.dep.constexpr]).
Definition: Expr.h:149
SourceLocation getLocStart() const LLVM_READONLY
Definition: ExprObjC.h:706
bool hasVersion() const
This may be &#39;*&#39;, in which case this should fold to true.
Definition: ExprObjC.h:1599
Represents one property declaration in an Objective-C interface.
Definition: DeclObjC.h:704
const ObjCIvarDecl * getDecl() const
Definition: ExprObjC.h:506
bool isImplicit() const
Indicates whether the message send was implicitly generated by the implementation.
Definition: ExprObjC.h:1132
bool isMessagingGetter() const
True if the property reference will result in a message to the getter.
Definition: ExprObjC.h:663
void setBaseExpr(Stmt *S)
Definition: ExprObjC.h:808
Expr * getSubExpr()
Definition: ExprObjC.h:108
void setEncodedTypeSourceInfo(TypeSourceInfo *EncType)
Definition: ExprObjC.h:379
const ObjCMethodDecl * getMethodDecl() const
Definition: ExprObjC.h:1251
ObjCBoxedExpr - used for generalized expression boxing.
Definition: ExprObjC.h:94
static QualType getFromOpaquePtr(const void *Ptr)
Definition: Type.h:663
llvm::iterator_range< const_arg_iterator > arguments() const
Definition: ExprObjC.h:1361
A placeholder type used to construct an empty shell of a type, that will be filled in later (e...
Definition: Stmt.h:308
Expr * Value
The value of the dictionary element.
Definition: ExprObjC.h:217
Expr ** getElements()
Retrieve elements of array of literals.
Definition: ExprObjC.h:176
Expr * getInstanceReceiver()
Returns the object expression (receiver) for an instance message, or null for a message that is not a...
Definition: ExprObjC.h:1155
An Objective-C "bridged" cast expression, which casts between Objective-C pointers and C pointers...
Definition: ExprObjC.h:1519
arg_iterator arg_end()
Definition: ExprObjC.h:1366
Dataflow Directional Tag Classes.
bool isValid() const
Return true if this is a valid SourceLocation object.
SourceLocation getLocStart() const
Definition: ExprObjC.h:1594
SourceLocation getLocation() const
Definition: ExprObjC.h:689
SourceLocation getLocStart() const LLVM_READONLY
Definition: ExprObjC.h:1344
Reads an AST files chain containing the contents of a translation unit.
Definition: ASTReader.h:328
void setAtLoc(SourceLocation L)
Definition: ExprObjC.h:459
QualType getSuperType() const
Retrieve the type referred to by &#39;super&#39;.
Definition: ExprObjC.h:1231
SourceLocation EllipsisLoc
The location of the ellipsis, if this is a pack expansion.
Definition: ExprObjC.h:220
void setDecl(ObjCIvarDecl *d)
Definition: ExprObjC.h:507
A runtime availability query.
Definition: ExprObjC.h:1579
static bool classof(const Stmt *T)
Definition: ExprObjC.h:465
StmtClass getStmtClass() const
Definition: Stmt.h:361
child_range children()
Definition: ExprObjC.h:128
static bool classof(const Stmt *T)
Definition: ExprObjC.h:1561
ExplicitCastExpr - An explicit cast written in the source code.
Definition: Expr.h:2889
void setSelector(Selector S)
Definition: ExprObjC.h:1246
void setMethodDecl(ObjCMethodDecl *MD)
Definition: ExprObjC.h:1265
SourceLocation getLParenLoc() const
Definition: ExprObjC.h:1543
SourceLocation getRParenLoc() const
Definition: ExprObjC.h:458
child_range children()
Definition: ExprObjC.h:55
QualType getClassReceiver() const
Returns the type of a class message send, or NULL if the message is not a class message.
Definition: ExprObjC.h:1174
const_arg_iterator arg_begin() const
Definition: ExprObjC.h:132
static bool classof(const Stmt *T)
Definition: ExprObjC.h:386
arg_iterator arg_begin()
Definition: ExprObjC.h:1365
SourceLocation getAtLoc() const
Definition: ExprObjC.h:115
Expr * getBase() const
Definition: ExprObjC.h:1408
SourceLocation getLocEnd() const LLVM_READONLY
Definition: ExprObjC.h:1557
ObjCPropertyRefExpr(ObjCMethodDecl *Getter, ObjCMethodDecl *Setter, QualType T, ExprValueKind VK, ExprObjectKind OK, SourceLocation IdLoc, SourceLocation SuperLoc, QualType SuperTy)
Definition: ExprObjC.h:607
unsigned getNumElements() const
getNumElements - Return number of elements of objective-c array literal.
Definition: ExprObjC.h:184
child_range children()
Definition: ExprObjC.h:391
ObjCEncodeExpr, used for @encode in Objective-C.
Definition: ExprObjC.h:355
friend TrailingObjects
Definition: OpenMPClause.h:82
static bool classof(const Stmt *s)
Definition: ExprObjC.h:1508
SourceLocation getLocation() const
Definition: ExprObjC.h:518
ObjCAvailabilityCheckExpr(EmptyShell Shell)
Definition: ExprObjC.h:1591
ObjCBridgedCastExpr(SourceLocation LParenLoc, ObjCBridgeCastKind Kind, CastKind CK, SourceLocation BridgeKeywordLoc, TypeSourceInfo *TSInfo, Expr *Operand)
Definition: ExprObjC.h:1532
bool isDelegateInitCall() const
isDelegateInitCall - Answers whether this message send has been tagged as a "delegate init call"...
Definition: ExprObjC.h:1307
unsigned getNumArgs() const
getNumArgs - Return the number of actual arguments to this call.
Definition: ExprObjC.h:421
child_range children()
Definition: ExprObjC.h:1438
const Expr * getBase() const
Definition: ExprObjC.h:509
ObjCProtocolExpr(EmptyShell Empty)
Definition: ExprObjC.h:450
void setRParenLoc(SourceLocation L)
Definition: ExprObjC.h:374
A bitfield object is a bitfield on a C or C++ record.
Definition: Specifiers.h:126
ObjCIvarRefExpr - A reference to an ObjC instance variable.
Definition: ExprObjC.h:479
bool isFreeIvar() const
Definition: ExprObjC.h:514
QualType getSuperReceiverType() const
Definition: ExprObjC.h:692
llvm::iterator_range< arg_iterator > arguments()
Definition: ExprObjC.h:1357
void setSourceRange(SourceRange R)
Definition: ExprObjC.h:1340
SourceLocation getSelectorStartLoc() const
Definition: ExprObjC.h:1313
bool isPackExpansion() const
Determines whether this dictionary element is a pack expansion.
Definition: ExprObjC.h:227
ObjCIvarDecl - Represents an ObjC instance variable.
Definition: DeclObjC.h:1866
SourceLocation getLocEnd() const LLVM_READONLY
Definition: ExprObjC.h:168
void setIsaMemberLoc(SourceLocation L)
Definition: ExprObjC.h:1416
SourceLocation getLocStart() const LLVM_READONLY
Definition: ExprObjC.h:417
SourceLocation getLocStart() const LLVM_READONLY
Definition: ExprObjC.h:47
bool containsUnexpandedParameterPack() const
Whether this expression contains an unexpanded parameter pack (for C++11 variadic templates)...
Definition: Expr.h:214
bool shouldCopy() const
shouldCopy - True if we should do the &#39;copy&#39; part of the copy-restore.
Definition: ExprObjC.h:1494
StringLiteral - This represents a string literal expression, e.g.
Definition: Expr.h:1509
void setOpLoc(SourceLocation L)
Definition: ExprObjC.h:527
const Expr * getArg(unsigned Arg) const
Definition: ExprObjC.h:1294
Internal struct to describes an element that is a pack expansion, used if any of the elements in the ...
Definition: ExprObjC.h:245
static bool classof(const Stmt *T)
Definition: ExprObjC.h:50
ObjCBoolLiteralExpr - Objective-C Boolean Literal.
Definition: ExprObjC.h:60
bool isObjectReceiver() const
Definition: ExprObjC.h:699
SourceLocation getReceiverLocation() const
Definition: ExprObjC.h:691
SourceLocation getBridgeKeywordLoc() const
The location of the bridge keyword.
Definition: ExprObjC.h:1554
ObjCProtocolExpr(QualType T, ObjCProtocolDecl *protocol, SourceLocation at, SourceLocation protoLoc, SourceLocation rp)
Definition: ExprObjC.h:445
const Expr * getSubExpr() const
Definition: ExprObjC.h:1490
bool isArraySubscriptRefExpr() const
Definition: ExprObjC.h:821
#define true
Definition: stdbool.h:32
static bool classof(const Stmt *T)
Definition: ExprObjC.h:171
An l-value expression is a reference to an object with independent storage.
Definition: Specifiers.h:111
const Expr * getBase() const
Definition: ExprObjC.h:682
A trivial tuple used to represent a source range.
ObjCMethodDecl * getMethodDecl()
Definition: ExprObjC.h:1258
SourceLocation getLocEnd() const LLVM_READONLY
Definition: ExprObjC.h:327
SourceLocation getRightLoc() const
Definition: ExprObjC.h:1311
The receiver is a superclass.
Definition: ExprObjC.h:1007
bool isInstanceMessage() const
Determine whether this is an instance message to either a computed object or to super.
Definition: ExprObjC.h:1143
SourceLocation getLocStart() const LLVM_READONLY
Definition: Stmt.cpp:257
SourceLocation getBegin() const
static bool classof(const Stmt *T)
Definition: ExprObjC.h:1606
void setArg(unsigned Arg, Expr *ArgExpr)
setArg - Set the specified argument.
Definition: ExprObjC.h:1299
void setBase(Expr *E)
Definition: ExprObjC.h:1407
SourceLocation getLocStart() const LLVM_READONLY
Definition: ExprObjC.h:521
const Expr * getSubExpr() const
Definition: ExprObjC.h:109
QualType getType() const
Return the type wrapped by this type source info.
Definition: Decl.h:70
static OMPLinearClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, OpenMPLinearClauseKind Modifier, SourceLocation ModifierLoc, SourceLocation ColonLoc, SourceLocation EndLoc, ArrayRef< Expr *> VL, ArrayRef< Expr *> PL, ArrayRef< Expr *> IL, Expr *Step, Expr *CalcStep, Stmt *PreInit, Expr *PostUpdate)
Creates clause with a list of variables VL and a linear step Step.
child_range children()
Definition: ExprObjC.h:470
TypeSourceInfo * getClassReceiverTypeInfo() const
Returns a type-source information of a class message send, or NULL if the message is not a class mess...
Definition: ExprObjC.h:1183