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