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