clang  9.0.0svn
ExprObjC.h
Go to the documentation of this file.
1 //===- ExprObjC.h - Classes for representing ObjC expressions ---*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file defines the ExprObjC interface and subclasses.
10 //
11 //===----------------------------------------------------------------------===//
12 
13 #ifndef LLVM_CLANG_AST_EXPROBJC_H
14 #define LLVM_CLANG_AST_EXPROBJC_H
15 
16 #include "clang/AST/Decl.h"
17 #include "clang/AST/DeclObjC.h"
18 #include "clang/AST/Expr.h"
21 #include "clang/AST/Stmt.h"
22 #include "clang/AST/Type.h"
24 #include "clang/Basic/LLVM.h"
26 #include "clang/Basic/Specifiers.h"
27 #include "llvm/ADT/ArrayRef.h"
28 #include "llvm/ADT/None.h"
29 #include "llvm/ADT/Optional.h"
30 #include "llvm/ADT/PointerIntPair.h"
31 #include "llvm/ADT/PointerUnion.h"
32 #include "llvm/ADT/StringRef.h"
33 #include "llvm/ADT/iterator_range.h"
34 #include "llvm/Support/Casting.h"
35 #include "llvm/Support/Compiler.h"
36 #include "llvm/Support/TrailingObjects.h"
37 #include "llvm/Support/VersionTuple.h"
38 #include "llvm/Support/type_traits.h"
39 #include <cassert>
40 #include <cstddef>
41 #include <cstdint>
42 
43 namespace clang {
44 
45 class ASTContext;
46 class CXXBaseSpecifier;
47 
48 /// ObjCStringLiteral, used for Objective-C string literals
49 /// i.e. @"foo".
50 class ObjCStringLiteral : public Expr {
51  Stmt *String;
52  SourceLocation AtLoc;
53 
54 public:
56  : Expr(ObjCStringLiteralClass, T, VK_RValue, OK_Ordinary, false, false,
57  false, false),
58  String(SL), AtLoc(L) {}
59  explicit ObjCStringLiteral(EmptyShell Empty)
60  : Expr(ObjCStringLiteralClass, Empty) {}
61 
62  StringLiteral *getString() { return cast<StringLiteral>(String); }
63  const StringLiteral *getString() const { return cast<StringLiteral>(String); }
64  void setString(StringLiteral *S) { String = S; }
65 
66  SourceLocation getAtLoc() const { return AtLoc; }
67  void setAtLoc(SourceLocation L) { AtLoc = L; }
68 
69  SourceLocation getBeginLoc() const LLVM_READONLY { return AtLoc; }
70  SourceLocation getEndLoc() const LLVM_READONLY { return String->getEndLoc(); }
71 
72  // Iterators
73  child_range children() { return child_range(&String, &String+1); }
74 
75  static bool classof(const Stmt *T) {
76  return T->getStmtClass() == ObjCStringLiteralClass;
77  }
78 };
79 
80 /// ObjCBoolLiteralExpr - Objective-C Boolean Literal.
81 class ObjCBoolLiteralExpr : public Expr {
82  bool Value;
83  SourceLocation Loc;
84 
85 public:
87  : Expr(ObjCBoolLiteralExprClass, Ty, VK_RValue, OK_Ordinary, false, false,
88  false, false),
89  Value(val), Loc(l) {}
91  : Expr(ObjCBoolLiteralExprClass, Empty) {}
92 
93  bool getValue() const { return Value; }
94  void setValue(bool V) { Value = V; }
95 
96  SourceLocation getBeginLoc() const LLVM_READONLY { return Loc; }
97  SourceLocation getEndLoc() const LLVM_READONLY { return Loc; }
98 
99  SourceLocation getLocation() const { return Loc; }
100  void setLocation(SourceLocation L) { Loc = L; }
101 
102  // Iterators
105  }
106 
107  static bool classof(const Stmt *T) {
108  return T->getStmtClass() == ObjCBoolLiteralExprClass;
109  }
110 };
111 
112 /// ObjCBoxedExpr - used for generalized expression boxing.
113 /// as in: @(strdup("hello world")), @(random()) or @(view.frame)
114 /// Also used for boxing non-parenthesized numeric literals;
115 /// as in: @42 or \@true (c++/objc++) or \@__objc_yes (c/objc).
116 class ObjCBoxedExpr : public Expr {
117  Stmt *SubExpr;
118  ObjCMethodDecl *BoxingMethod;
119  SourceRange Range;
120 
121 public:
122  friend class ASTStmtReader;
123 
125  SourceRange R)
126  : Expr(ObjCBoxedExprClass, T, VK_RValue, OK_Ordinary,
130  SubExpr(E), BoxingMethod(method), Range(R) {}
131  explicit ObjCBoxedExpr(EmptyShell Empty)
132  : Expr(ObjCBoxedExprClass, Empty) {}
133 
134  Expr *getSubExpr() { return cast<Expr>(SubExpr); }
135  const Expr *getSubExpr() const { return cast<Expr>(SubExpr); }
136 
138  return BoxingMethod;
139  }
140 
141  // Indicates whether this boxed expression can be emitted as a compile-time
142  // constant.
144  return !BoxingMethod && SubExpr;
145  }
146 
147  SourceLocation getAtLoc() const { return Range.getBegin(); }
148 
149  SourceLocation getBeginLoc() const LLVM_READONLY { return Range.getBegin(); }
150  SourceLocation getEndLoc() const LLVM_READONLY { return Range.getEnd(); }
151 
152  SourceRange getSourceRange() const LLVM_READONLY {
153  return Range;
154  }
155 
156  // Iterators
157  child_range children() { return child_range(&SubExpr, &SubExpr+1); }
158 
160 
162  return reinterpret_cast<Stmt const * const*>(&SubExpr);
163  }
164 
166  return reinterpret_cast<Stmt const * const*>(&SubExpr + 1);
167  }
168 
169  static bool classof(const Stmt *T) {
170  return T->getStmtClass() == ObjCBoxedExprClass;
171  }
172 };
173 
174 /// ObjCArrayLiteral - used for objective-c array containers; as in:
175 /// @[@"Hello", NSApp, [NSNumber numberWithInt:42]];
176 class ObjCArrayLiteral final
177  : public Expr,
178  private llvm::TrailingObjects<ObjCArrayLiteral, Expr *> {
179  unsigned NumElements;
180  SourceRange Range;
181  ObjCMethodDecl *ArrayWithObjectsMethod;
182 
184  QualType T, ObjCMethodDecl * Method,
185  SourceRange SR);
186 
187  explicit ObjCArrayLiteral(EmptyShell Empty, unsigned NumElements)
188  : Expr(ObjCArrayLiteralClass, Empty), NumElements(NumElements) {}
189 
190 public:
191  friend class ASTStmtReader;
193 
194  static ObjCArrayLiteral *Create(const ASTContext &C,
195  ArrayRef<Expr *> Elements,
196  QualType T, ObjCMethodDecl * Method,
197  SourceRange SR);
198 
199  static ObjCArrayLiteral *CreateEmpty(const ASTContext &C,
200  unsigned NumElements);
201 
202  SourceLocation getBeginLoc() const LLVM_READONLY { return Range.getBegin(); }
203  SourceLocation getEndLoc() const LLVM_READONLY { return Range.getEnd(); }
204  SourceRange getSourceRange() const LLVM_READONLY { return Range; }
205 
206  /// Retrieve elements of array of literals.
207  Expr **getElements() { return getTrailingObjects<Expr *>(); }
208 
209  /// Retrieve elements of array of literals.
210  const Expr * const *getElements() const {
211  return getTrailingObjects<Expr *>();
212  }
213 
214  /// getNumElements - Return number of elements of objective-c array literal.
215  unsigned getNumElements() const { return NumElements; }
216 
217  /// getElement - Return the Element at the specified index.
218  Expr *getElement(unsigned Index) {
219  assert((Index < NumElements) && "Arg access out of range!");
220  return getElements()[Index];
221  }
222  const Expr *getElement(unsigned Index) const {
223  assert((Index < NumElements) && "Arg access out of range!");
224  return getElements()[Index];
225  }
226 
228  return ArrayWithObjectsMethod;
229  }
230 
231  // Iterators
233  return child_range(reinterpret_cast<Stmt **>(getElements()),
234  reinterpret_cast<Stmt **>(getElements()) + NumElements);
235  }
236 
237  static bool classof(const Stmt *T) {
238  return T->getStmtClass() == ObjCArrayLiteralClass;
239  }
240 };
241 
242 /// An element in an Objective-C dictionary literal.
243 ///
245  /// The key for the dictionary element.
247 
248  /// The value of the dictionary element.
250 
251  /// The location of the ellipsis, if this is a pack expansion.
253 
254  /// The number of elements this pack expansion will expand to, if
255  /// this is a pack expansion and is known.
257 
258  /// Determines whether this dictionary element is a pack expansion.
259  bool isPackExpansion() const { return EllipsisLoc.isValid(); }
260 };
261 
262 } // namespace clang
263 
264 namespace clang {
265 
266 /// Internal struct for storing Key/value pair.
270 };
271 
272 /// Internal struct to describes an element that is a pack
273 /// expansion, used if any of the elements in the dictionary literal
274 /// are pack expansions.
276  /// The location of the ellipsis, if this element is a pack
277  /// expansion.
279 
280  /// If non-zero, the number of elements that this pack
281  /// expansion will expand to (+1).
283 };
284 
285 /// ObjCDictionaryLiteral - AST node to represent objective-c dictionary
286 /// literals; as in: @{@"name" : NSUserName(), @"date" : [NSDate date] };
288  : public Expr,
289  private llvm::TrailingObjects<ObjCDictionaryLiteral,
290  ObjCDictionaryLiteral_KeyValuePair,
291  ObjCDictionaryLiteral_ExpansionData> {
292  /// The number of elements in this dictionary literal.
293  unsigned NumElements : 31;
294 
295  /// Determine whether this dictionary literal has any pack expansions.
296  ///
297  /// If the dictionary literal has pack expansions, then there will
298  /// be an array of pack expansion data following the array of
299  /// key/value pairs, which provide the locations of the ellipses (if
300  /// any) and number of elements in the expansion (if known). If
301  /// there are no pack expansions, we optimize away this storage.
302  unsigned HasPackExpansions : 1;
303 
304  SourceRange Range;
305  ObjCMethodDecl *DictWithObjectsMethod;
306 
309 
311  bool HasPackExpansions,
312  QualType T, ObjCMethodDecl *method,
313  SourceRange SR);
314 
315  explicit ObjCDictionaryLiteral(EmptyShell Empty, unsigned NumElements,
316  bool HasPackExpansions)
317  : Expr(ObjCDictionaryLiteralClass, Empty), NumElements(NumElements),
318  HasPackExpansions(HasPackExpansions) {}
319 
320  size_t numTrailingObjects(OverloadToken<KeyValuePair>) const {
321  return NumElements;
322  }
323 
324 public:
325  friend class ASTStmtReader;
326  friend class ASTStmtWriter;
328 
329  static ObjCDictionaryLiteral *Create(const ASTContext &C,
331  bool HasPackExpansions,
332  QualType T, ObjCMethodDecl *method,
333  SourceRange SR);
334 
336  unsigned NumElements,
337  bool HasPackExpansions);
338 
339  /// getNumElements - Return number of elements of objective-c dictionary
340  /// literal.
341  unsigned getNumElements() const { return NumElements; }
342 
344  assert((Index < NumElements) && "Arg access out of range!");
345  const KeyValuePair &KV = getTrailingObjects<KeyValuePair>()[Index];
347  if (HasPackExpansions) {
348  const ExpansionData &Expansion =
349  getTrailingObjects<ExpansionData>()[Index];
350  Result.EllipsisLoc = Expansion.EllipsisLoc;
351  if (Expansion.NumExpansionsPlusOne > 0)
352  Result.NumExpansions = Expansion.NumExpansionsPlusOne - 1;
353  }
354  return Result;
355  }
356 
358  return DictWithObjectsMethod;
359  }
360 
361  SourceLocation getBeginLoc() const LLVM_READONLY { return Range.getBegin(); }
362  SourceLocation getEndLoc() const LLVM_READONLY { return Range.getEnd(); }
363  SourceRange getSourceRange() const LLVM_READONLY { return Range; }
364 
365  // Iterators
367  // Note: we're taking advantage of the layout of the KeyValuePair struct
368  // here. If that struct changes, this code will need to change as well.
369  static_assert(sizeof(KeyValuePair) == sizeof(Stmt *) * 2,
370  "KeyValuePair is expected size");
371  return child_range(
372  reinterpret_cast<Stmt **>(getTrailingObjects<KeyValuePair>()),
373  reinterpret_cast<Stmt **>(getTrailingObjects<KeyValuePair>()) +
374  NumElements * 2);
375  }
376 
377  static bool classof(const Stmt *T) {
378  return T->getStmtClass() == ObjCDictionaryLiteralClass;
379  }
380 };
381 
382 /// ObjCEncodeExpr, used for \@encode in Objective-C. \@encode has the same
383 /// type and behavior as StringLiteral except that the string initializer is
384 /// obtained from ASTContext with the encoding type as an argument.
385 class ObjCEncodeExpr : public Expr {
386  TypeSourceInfo *EncodedType;
387  SourceLocation AtLoc, RParenLoc;
388 
389 public:
392  : Expr(ObjCEncodeExprClass, T, VK_LValue, OK_Ordinary,
393  EncodedType->getType()->isDependentType(),
394  EncodedType->getType()->isDependentType(),
395  EncodedType->getType()->isInstantiationDependentType(),
396  EncodedType->getType()->containsUnexpandedParameterPack()),
397  EncodedType(EncodedType), AtLoc(at), RParenLoc(rp) {}
398 
399  explicit ObjCEncodeExpr(EmptyShell Empty) : Expr(ObjCEncodeExprClass, Empty){}
400 
401  SourceLocation getAtLoc() const { return AtLoc; }
402  void setAtLoc(SourceLocation L) { AtLoc = L; }
403  SourceLocation getRParenLoc() const { return RParenLoc; }
404  void setRParenLoc(SourceLocation L) { RParenLoc = L; }
405 
406  QualType getEncodedType() const { return EncodedType->getType(); }
407 
408  TypeSourceInfo *getEncodedTypeSourceInfo() const { return EncodedType; }
409 
411  EncodedType = EncType;
412  }
413 
414  SourceLocation getBeginLoc() const LLVM_READONLY { return AtLoc; }
415  SourceLocation getEndLoc() const LLVM_READONLY { return RParenLoc; }
416 
417  // Iterators
420  }
421 
422  static bool classof(const Stmt *T) {
423  return T->getStmtClass() == ObjCEncodeExprClass;
424  }
425 };
426 
427 /// ObjCSelectorExpr used for \@selector in Objective-C.
428 class ObjCSelectorExpr : public Expr {
429  Selector SelName;
430  SourceLocation AtLoc, RParenLoc;
431 
432 public:
435  : Expr(ObjCSelectorExprClass, T, VK_RValue, OK_Ordinary, false, false,
436  false, false),
437  SelName(selInfo), AtLoc(at), RParenLoc(rp) {}
438  explicit ObjCSelectorExpr(EmptyShell Empty)
439  : Expr(ObjCSelectorExprClass, Empty) {}
440 
441  Selector getSelector() const { return SelName; }
442  void setSelector(Selector S) { SelName = S; }
443 
444  SourceLocation getAtLoc() const { return AtLoc; }
445  SourceLocation getRParenLoc() const { return RParenLoc; }
446  void setAtLoc(SourceLocation L) { AtLoc = L; }
447  void setRParenLoc(SourceLocation L) { RParenLoc = L; }
448 
449  SourceLocation getBeginLoc() const LLVM_READONLY { return AtLoc; }
450  SourceLocation getEndLoc() const LLVM_READONLY { return RParenLoc; }
451 
452  /// getNumArgs - Return the number of actual arguments to this call.
453  unsigned getNumArgs() const { return SelName.getNumArgs(); }
454 
455  // Iterators
458  }
459 
460  static bool classof(const Stmt *T) {
461  return T->getStmtClass() == ObjCSelectorExprClass;
462  }
463 };
464 
465 /// ObjCProtocolExpr used for protocol expression in Objective-C.
466 ///
467 /// This is used as: \@protocol(foo), as in:
468 /// \code
469 /// [obj conformsToProtocol:@protocol(foo)]
470 /// \endcode
471 ///
472 /// The return type is "Protocol*".
473 class ObjCProtocolExpr : public Expr {
474  ObjCProtocolDecl *TheProtocol;
475  SourceLocation AtLoc, ProtoLoc, RParenLoc;
476 
477 public:
478  friend class ASTStmtReader;
479  friend class ASTStmtWriter;
480 
483  : Expr(ObjCProtocolExprClass, T, VK_RValue, OK_Ordinary, false, false,
484  false, false),
485  TheProtocol(protocol), AtLoc(at), ProtoLoc(protoLoc), RParenLoc(rp) {}
486  explicit ObjCProtocolExpr(EmptyShell Empty)
487  : Expr(ObjCProtocolExprClass, Empty) {}
488 
489  ObjCProtocolDecl *getProtocol() const { return TheProtocol; }
490  void setProtocol(ObjCProtocolDecl *P) { TheProtocol = P; }
491 
492  SourceLocation getProtocolIdLoc() const { return ProtoLoc; }
493  SourceLocation getAtLoc() const { return AtLoc; }
494  SourceLocation getRParenLoc() const { return RParenLoc; }
495  void setAtLoc(SourceLocation L) { AtLoc = L; }
496  void setRParenLoc(SourceLocation L) { RParenLoc = L; }
497 
498  SourceLocation getBeginLoc() const LLVM_READONLY { return AtLoc; }
499  SourceLocation getEndLoc() const LLVM_READONLY { return RParenLoc; }
500 
501  // Iterators
504  }
505 
506  static bool classof(const Stmt *T) {
507  return T->getStmtClass() == ObjCProtocolExprClass;
508  }
509 };
510 
511 /// ObjCIvarRefExpr - A reference to an ObjC instance variable.
512 class ObjCIvarRefExpr : public Expr {
513  ObjCIvarDecl *D;
514  Stmt *Base;
515  SourceLocation Loc;
516 
517  /// OpLoc - This is the location of '.' or '->'
518  SourceLocation OpLoc;
519 
520  // True if this is "X->F", false if this is "X.F".
521  bool IsArrow : 1;
522 
523  // True if ivar reference has no base (self assumed).
524  bool IsFreeIvar : 1;
525 
526 public:
529  Expr *base,
530  bool arrow = false, bool freeIvar = false)
531  : Expr(ObjCIvarRefExprClass, t, VK_LValue,
532  d->isBitField() ? OK_BitField : OK_Ordinary,
533  /*TypeDependent=*/false, base->isValueDependent(),
534  base->isInstantiationDependent(),
536  D(d), Base(base), Loc(l), OpLoc(oploc), IsArrow(arrow),
537  IsFreeIvar(freeIvar) {}
538 
539  explicit ObjCIvarRefExpr(EmptyShell Empty)
540  : Expr(ObjCIvarRefExprClass, Empty) {}
541 
542  ObjCIvarDecl *getDecl() { return D; }
543  const ObjCIvarDecl *getDecl() const { return D; }
544  void setDecl(ObjCIvarDecl *d) { D = d; }
545 
546  const Expr *getBase() const { return cast<Expr>(Base); }
547  Expr *getBase() { return cast<Expr>(Base); }
548  void setBase(Expr * base) { Base = base; }
549 
550  bool isArrow() const { return IsArrow; }
551  bool isFreeIvar() const { return IsFreeIvar; }
552  void setIsArrow(bool A) { IsArrow = A; }
553  void setIsFreeIvar(bool A) { IsFreeIvar = A; }
554 
555  SourceLocation getLocation() const { return Loc; }
556  void setLocation(SourceLocation L) { Loc = L; }
557 
558  SourceLocation getBeginLoc() const LLVM_READONLY {
559  return isFreeIvar() ? Loc : getBase()->getBeginLoc();
560  }
561  SourceLocation getEndLoc() const LLVM_READONLY { return Loc; }
562 
563  SourceLocation getOpLoc() const { return OpLoc; }
564  void setOpLoc(SourceLocation L) { OpLoc = L; }
565 
566  // Iterators
567  child_range children() { return child_range(&Base, &Base+1); }
568 
569  static bool classof(const Stmt *T) {
570  return T->getStmtClass() == ObjCIvarRefExprClass;
571  }
572 };
573 
574 /// ObjCPropertyRefExpr - A dot-syntax expression to access an ObjC
575 /// property.
576 class ObjCPropertyRefExpr : public Expr {
577 private:
578  /// If the bool is true, this is an implicit property reference; the
579  /// pointer is an (optional) ObjCMethodDecl and Setter may be set.
580  /// if the bool is false, this is an explicit property reference;
581  /// the pointer is an ObjCPropertyDecl and Setter is always null.
582  llvm::PointerIntPair<NamedDecl *, 1, bool> PropertyOrGetter;
583 
584  /// Indicates whether the property reference will result in a message
585  /// to the getter, the setter, or both.
586  /// This applies to both implicit and explicit property references.
587  enum MethodRefFlags {
588  MethodRef_None = 0,
589  MethodRef_Getter = 0x1,
590  MethodRef_Setter = 0x2
591  };
592 
593  /// Contains the Setter method pointer and MethodRefFlags bit flags.
594  llvm::PointerIntPair<ObjCMethodDecl *, 2, unsigned> SetterAndMethodRefFlags;
595 
596  // FIXME: Maybe we should store the property identifier here,
597  // because it's not rederivable from the other data when there's an
598  // implicit property with no getter (because the 'foo' -> 'setFoo:'
599  // transformation is lossy on the first character).
600 
601  SourceLocation IdLoc;
602 
603  /// When the receiver in property access is 'super', this is
604  /// the location of the 'super' keyword. When it's an interface,
605  /// this is that interface.
606  SourceLocation ReceiverLoc;
607  llvm::PointerUnion3<Stmt *, const Type *, ObjCInterfaceDecl *> Receiver;
608 
609 public:
612  SourceLocation l, Expr *base)
613  : Expr(ObjCPropertyRefExprClass, t, VK, OK,
614  /*TypeDependent=*/false, base->isValueDependent(),
615  base->isInstantiationDependent(),
617  PropertyOrGetter(PD, false), IdLoc(l), Receiver(base) {
618  assert(t->isSpecificPlaceholderType(BuiltinType::PseudoObject));
619  }
620 
624  : Expr(ObjCPropertyRefExprClass, t, VK, OK,
625  /*TypeDependent=*/false, false, st->isInstantiationDependentType(),
627  PropertyOrGetter(PD, false), IdLoc(l), ReceiverLoc(sl),
628  Receiver(st.getTypePtr()) {
629  assert(t->isSpecificPlaceholderType(BuiltinType::PseudoObject));
630  }
631 
634  SourceLocation IdLoc, Expr *Base)
635  : Expr(ObjCPropertyRefExprClass, T, VK, OK, false,
638  PropertyOrGetter(Getter, true), SetterAndMethodRefFlags(Setter, 0),
639  IdLoc(IdLoc), Receiver(Base) {
640  assert(T->isSpecificPlaceholderType(BuiltinType::PseudoObject));
641  }
642 
645  SourceLocation IdLoc,
646  SourceLocation SuperLoc, QualType SuperTy)
647  : Expr(ObjCPropertyRefExprClass, T, VK, OK, false, false, false, false),
648  PropertyOrGetter(Getter, true), SetterAndMethodRefFlags(Setter, 0),
649  IdLoc(IdLoc), ReceiverLoc(SuperLoc), Receiver(SuperTy.getTypePtr()) {
650  assert(T->isSpecificPlaceholderType(BuiltinType::PseudoObject));
651  }
652 
655  SourceLocation IdLoc,
656  SourceLocation ReceiverLoc, ObjCInterfaceDecl *Receiver)
657  : Expr(ObjCPropertyRefExprClass, T, VK, OK, false, false, false, false),
658  PropertyOrGetter(Getter, true), SetterAndMethodRefFlags(Setter, 0),
659  IdLoc(IdLoc), ReceiverLoc(ReceiverLoc), Receiver(Receiver) {
660  assert(T->isSpecificPlaceholderType(BuiltinType::PseudoObject));
661  }
662 
664  : Expr(ObjCPropertyRefExprClass, Empty) {}
665 
666  bool isImplicitProperty() const { return PropertyOrGetter.getInt(); }
667  bool isExplicitProperty() const { return !PropertyOrGetter.getInt(); }
668 
670  assert(!isImplicitProperty());
671  return cast<ObjCPropertyDecl>(PropertyOrGetter.getPointer());
672  }
673 
675  assert(isImplicitProperty());
676  return cast_or_null<ObjCMethodDecl>(PropertyOrGetter.getPointer());
677  }
678 
680  assert(isImplicitProperty());
681  return SetterAndMethodRefFlags.getPointer();
682  }
683 
685  if (isImplicitProperty())
686  return getImplicitPropertyGetter()->getSelector();
687  return getExplicitProperty()->getGetterName();
688  }
689 
691  if (isImplicitProperty())
692  return getImplicitPropertySetter()->getSelector();
693  return getExplicitProperty()->getSetterName();
694  }
695 
696  /// True if the property reference will result in a message to the
697  /// getter.
698  /// This applies to both implicit and explicit property references.
699  bool isMessagingGetter() const {
700  return SetterAndMethodRefFlags.getInt() & MethodRef_Getter;
701  }
702 
703  /// True if the property reference will result in a message to the
704  /// setter.
705  /// This applies to both implicit and explicit property references.
706  bool isMessagingSetter() const {
707  return SetterAndMethodRefFlags.getInt() & MethodRef_Setter;
708  }
709 
710  void setIsMessagingGetter(bool val = true) {
711  setMethodRefFlag(MethodRef_Getter, val);
712  }
713 
714  void setIsMessagingSetter(bool val = true) {
715  setMethodRefFlag(MethodRef_Setter, val);
716  }
717 
718  const Expr *getBase() const {
719  return cast<Expr>(Receiver.get<Stmt*>());
720  }
722  return cast<Expr>(Receiver.get<Stmt*>());
723  }
724 
725  SourceLocation getLocation() const { return IdLoc; }
726 
727  SourceLocation getReceiverLocation() const { return ReceiverLoc; }
728 
730  return QualType(Receiver.get<const Type*>(), 0);
731  }
732 
734  return Receiver.get<ObjCInterfaceDecl*>();
735  }
736 
737  bool isObjectReceiver() const { return Receiver.is<Stmt*>(); }
738  bool isSuperReceiver() const { return Receiver.is<const Type*>(); }
739  bool isClassReceiver() const { return Receiver.is<ObjCInterfaceDecl*>(); }
740 
741  /// Determine the type of the base, regardless of the kind of receiver.
742  QualType getReceiverType(const ASTContext &ctx) const;
743 
744  SourceLocation getBeginLoc() const LLVM_READONLY {
745  return isObjectReceiver() ? getBase()->getBeginLoc()
746  : getReceiverLocation();
747  }
748 
749  SourceLocation getEndLoc() 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 getBeginLoc() const LLVM_READONLY {
842  return SubExprs[BASE]->getBeginLoc();
843  }
844 
845  SourceLocation getEndLoc() 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 /// 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  /// 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  /// The number of arguments in the message send, not
914  /// including the receiver.
915  unsigned NumArgs : NumArgsBitWidth;
916 
917  /// 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  /// 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  /// 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  /// Whether this message send was implicitly generated by
935  /// the implementation rather than explicitly written by the user.
936  unsigned IsImplicit : 1;
937 
938  /// Whether the locations of the selector identifiers are in a
939  /// "standard" position, a enum SelectorLocationsKind.
940  unsigned SelLocsKind : 2;
941 
942  /// When the message expression is a send to 'super', this is
943  /// the location of the 'super' keyword.
944  SourceLocation SuperLoc;
945 
946  /// 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  /// Retrieve the pointer value of the message receiver.
1001  void *getReceiverPointer() const { return *getTrailingObjects<void *>(); }
1002 
1003  /// 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  /// 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  /// 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  /// The kind of receiver this message is sending to.
1050  /// The receiver is a class.
1051  Class = 0,
1052 
1053  /// The receiver is an object instance.
1055 
1056  /// The receiver is a superclass.
1058 
1059  /// The receiver is the instance of the superclass object.
1060  SuperInstance
1061  };
1062 
1063  /// 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  /// 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  /// 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  /// 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  /// 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  /// Determine the kind of receiver that this message is being
1186  /// sent to.
1188 
1189  /// \return the return type of the message being sent.
1190  /// This is not always the type of the message expression itself because
1191  /// of references (the expression would not have a reference type).
1192  /// It is also not always the declared return type of the method because
1193  /// of `instancetype` (in that case it's an expression type).
1194  QualType getCallReturnType(ASTContext &Ctx) const;
1195 
1196  /// Source range of the receiver.
1197  SourceRange getReceiverRange() const;
1198 
1199  /// Determine whether this is an instance message to either a
1200  /// computed object or to super.
1201  bool isInstanceMessage() const {
1202  return getReceiverKind() == Instance || getReceiverKind() == SuperInstance;
1203  }
1204 
1205  /// Determine whether this is an class message to either a
1206  /// specified class or to super.
1207  bool isClassMessage() const {
1208  return getReceiverKind() == Class || getReceiverKind() == SuperClass;
1209  }
1210 
1211  /// Returns the object expression (receiver) for an instance message,
1212  /// or null for a message that is not an instance message.
1214  if (getReceiverKind() == Instance)
1215  return static_cast<Expr *>(getReceiverPointer());
1216 
1217  return nullptr;
1218  }
1219  const Expr *getInstanceReceiver() const {
1220  return const_cast<ObjCMessageExpr*>(this)->getInstanceReceiver();
1221  }
1222 
1223  /// Turn this message send into an instance message that
1224  /// computes the receiver object with the given expression.
1226  Kind = Instance;
1227  setReceiverPointer(rec);
1228  }
1229 
1230  /// Returns the type of a class message send, or NULL if the
1231  /// message is not a class message.
1233  if (TypeSourceInfo *TSInfo = getClassReceiverTypeInfo())
1234  return TSInfo->getType();
1235 
1236  return {};
1237  }
1238 
1239  /// Returns a type-source information of a class message
1240  /// send, or nullptr if the message is not a class message.
1242  if (getReceiverKind() == Class)
1243  return reinterpret_cast<TypeSourceInfo *>(getReceiverPointer());
1244  return nullptr;
1245  }
1246 
1248  Kind = Class;
1249  setReceiverPointer(TSInfo);
1250  }
1251 
1252  /// Retrieve the location of the 'super' keyword for a class
1253  /// or instance message to 'super', otherwise an invalid source location.
1255  if (getReceiverKind() == SuperInstance || getReceiverKind() == SuperClass)
1256  return SuperLoc;
1257 
1258  return SourceLocation();
1259  }
1260 
1261  /// Retrieve the receiver type to which this message is being directed.
1262  ///
1263  /// This routine cross-cuts all of the different kinds of message
1264  /// sends to determine what the underlying (statically known) type
1265  /// of the receiver will be; use \c getReceiverKind() to determine
1266  /// whether the message is a class or an instance method, whether it
1267  /// is a send to super or not, etc.
1268  ///
1269  /// \returns The type of the receiver.
1270  QualType getReceiverType() const;
1271 
1272  /// Retrieve the Objective-C interface to which this message
1273  /// is being directed, if known.
1274  ///
1275  /// This routine cross-cuts all of the different kinds of message
1276  /// sends to determine what the underlying (statically known) type
1277  /// of the receiver will be; use \c getReceiverKind() to determine
1278  /// whether the message is a class or an instance method, whether it
1279  /// is a send to super or not, etc.
1280  ///
1281  /// \returns The Objective-C interface if known, otherwise nullptr.
1282  ObjCInterfaceDecl *getReceiverInterface() const;
1283 
1284  /// Retrieve the type referred to by 'super'.
1285  ///
1286  /// The returned type will either be an ObjCInterfaceType (for an
1287  /// class message to super) or an ObjCObjectPointerType that refers
1288  /// to a class (for an instance message to super);
1290  if (getReceiverKind() == SuperInstance || getReceiverKind() == SuperClass)
1291  return QualType::getFromOpaquePtr(getReceiverPointer());
1292 
1293  return QualType();
1294  }
1295 
1296  void setSuper(SourceLocation Loc, QualType T, bool IsInstanceSuper) {
1297  Kind = IsInstanceSuper? SuperInstance : SuperClass;
1298  SuperLoc = Loc;
1299  setReceiverPointer(T.getAsOpaquePtr());
1300  }
1301 
1302  Selector getSelector() const;
1303 
1305  HasMethod = false;
1306  SelectorOrMethod = reinterpret_cast<uintptr_t>(S.getAsOpaquePtr());
1307  }
1308 
1310  if (HasMethod)
1311  return reinterpret_cast<const ObjCMethodDecl *>(SelectorOrMethod);
1312 
1313  return nullptr;
1314  }
1315 
1317  if (HasMethod)
1318  return reinterpret_cast<ObjCMethodDecl *>(SelectorOrMethod);
1319 
1320  return nullptr;
1321  }
1322 
1324  HasMethod = true;
1325  SelectorOrMethod = reinterpret_cast<uintptr_t>(MD);
1326  }
1327 
1329  if (HasMethod) return getMethodDecl()->getMethodFamily();
1330  return getSelector().getMethodFamily();
1331  }
1332 
1333  /// Return the number of actual arguments in this message,
1334  /// not counting the receiver.
1335  unsigned getNumArgs() const { return NumArgs; }
1336 
1337  /// Retrieve the arguments to this message, not including the
1338  /// receiver.
1340  return reinterpret_cast<Expr **>(getTrailingObjects<void *>() + 1);
1341  }
1342  const Expr * const *getArgs() const {
1343  return reinterpret_cast<const Expr *const *>(getTrailingObjects<void *>() +
1344  1);
1345  }
1346 
1347  /// getArg - Return the specified argument.
1348  Expr *getArg(unsigned Arg) {
1349  assert(Arg < NumArgs && "Arg access out of range!");
1350  return getArgs()[Arg];
1351  }
1352  const Expr *getArg(unsigned Arg) const {
1353  assert(Arg < NumArgs && "Arg access out of range!");
1354  return getArgs()[Arg];
1355  }
1356 
1357  /// setArg - Set the specified argument.
1358  void setArg(unsigned Arg, Expr *ArgExpr) {
1359  assert(Arg < NumArgs && "Arg access out of range!");
1360  getArgs()[Arg] = ArgExpr;
1361  }
1362 
1363  /// isDelegateInitCall - Answers whether this message send has been
1364  /// tagged as a "delegate init call", i.e. a call to a method in the
1365  /// -init family on self from within an -init method implementation.
1366  bool isDelegateInitCall() const { return IsDelegateInitCall; }
1367  void setDelegateInitCall(bool isDelegate) { IsDelegateInitCall = isDelegate; }
1368 
1369  SourceLocation getLeftLoc() const { return LBracLoc; }
1370  SourceLocation getRightLoc() const { return RBracLoc; }
1371 
1373  if (isImplicit())
1374  return getBeginLoc();
1375  return getSelectorLoc(0);
1376  }
1377 
1378  SourceLocation getSelectorLoc(unsigned Index) const {
1379  assert(Index < getNumSelectorLocs() && "Index out of range!");
1380  if (hasStandardSelLocs())
1381  return getStandardSelectorLoc(Index, getSelector(),
1382  getSelLocsKind() == SelLoc_StandardWithSpace,
1383  llvm::makeArrayRef(const_cast<Expr**>(getArgs()),
1384  getNumArgs()),
1385  RBracLoc);
1386  return getStoredSelLocs()[Index];
1387  }
1388 
1389  void getSelectorLocs(SmallVectorImpl<SourceLocation> &SelLocs) const;
1390 
1391  unsigned getNumSelectorLocs() const {
1392  if (isImplicit())
1393  return 0;
1394  Selector Sel = getSelector();
1395  if (Sel.isUnarySelector())
1396  return 1;
1397  return Sel.getNumArgs();
1398  }
1399 
1401  LBracLoc = R.getBegin();
1402  RBracLoc = R.getEnd();
1403  }
1404 
1405  SourceLocation getBeginLoc() const LLVM_READONLY { return LBracLoc; }
1406  SourceLocation getEndLoc() const LLVM_READONLY { return RBracLoc; }
1407 
1408  // Iterators
1410 
1413 
1414  llvm::iterator_range<arg_iterator> arguments() {
1415  return llvm::make_range(arg_begin(), arg_end());
1416  }
1417 
1418  llvm::iterator_range<const_arg_iterator> arguments() const {
1419  return llvm::make_range(arg_begin(), arg_end());
1420  }
1421 
1422  arg_iterator arg_begin() { return reinterpret_cast<Stmt **>(getArgs()); }
1423 
1425  return reinterpret_cast<Stmt **>(getArgs() + NumArgs);
1426  }
1427 
1429  return reinterpret_cast<Stmt const * const*>(getArgs());
1430  }
1431 
1433  return reinterpret_cast<Stmt const * const*>(getArgs() + NumArgs);
1434  }
1435 
1436  static bool classof(const Stmt *T) {
1437  return T->getStmtClass() == ObjCMessageExprClass;
1438  }
1439 };
1440 
1441 /// ObjCIsaExpr - Represent X->isa and X.isa when X is an ObjC 'id' type.
1442 /// (similar in spirit to MemberExpr).
1443 class ObjCIsaExpr : public Expr {
1444  /// Base - the expression for the base object pointer.
1445  Stmt *Base;
1446 
1447  /// IsaMemberLoc - This is the location of the 'isa'.
1448  SourceLocation IsaMemberLoc;
1449 
1450  /// OpLoc - This is the location of '.' or '->'
1451  SourceLocation OpLoc;
1452 
1453  /// IsArrow - True if this is "X->F", false if this is "X.F".
1454  bool IsArrow;
1455 
1456 public:
1457  ObjCIsaExpr(Expr *base, bool isarrow, SourceLocation l, SourceLocation oploc,
1458  QualType ty)
1459  : Expr(ObjCIsaExprClass, ty, VK_LValue, OK_Ordinary,
1460  /*TypeDependent=*/false, base->isValueDependent(),
1461  base->isInstantiationDependent(),
1462  /*ContainsUnexpandedParameterPack=*/false),
1463  Base(base), IsaMemberLoc(l), OpLoc(oploc), IsArrow(isarrow) {}
1464 
1465  /// Build an empty expression.
1466  explicit ObjCIsaExpr(EmptyShell Empty) : Expr(ObjCIsaExprClass, Empty) {}
1467 
1468  void setBase(Expr *E) { Base = E; }
1469  Expr *getBase() const { return cast<Expr>(Base); }
1470 
1471  bool isArrow() const { return IsArrow; }
1472  void setArrow(bool A) { IsArrow = A; }
1473 
1474  /// getMemberLoc - Return the location of the "member", in X->F, it is the
1475  /// location of 'F'.
1476  SourceLocation getIsaMemberLoc() const { return IsaMemberLoc; }
1477  void setIsaMemberLoc(SourceLocation L) { IsaMemberLoc = L; }
1478 
1479  SourceLocation getOpLoc() const { return OpLoc; }
1480  void setOpLoc(SourceLocation L) { OpLoc = L; }
1481 
1482  SourceLocation getBeginLoc() const LLVM_READONLY {
1483  return getBase()->getBeginLoc();
1484  }
1485 
1486  SourceLocation getBaseLocEnd() const LLVM_READONLY {
1487  return getBase()->getEndLoc();
1488  }
1489 
1490  SourceLocation getEndLoc() const LLVM_READONLY { return IsaMemberLoc; }
1491 
1492  SourceLocation getExprLoc() const LLVM_READONLY { return IsaMemberLoc; }
1493 
1494  // Iterators
1495  child_range children() { return child_range(&Base, &Base+1); }
1496 
1497  static bool classof(const Stmt *T) {
1498  return T->getStmtClass() == ObjCIsaExprClass;
1499  }
1500 };
1501 
1502 /// ObjCIndirectCopyRestoreExpr - Represents the passing of a function
1503 /// argument by indirect copy-restore in ARC. This is used to support
1504 /// passing indirect arguments with the wrong lifetime, e.g. when
1505 /// passing the address of a __strong local variable to an 'out'
1506 /// parameter. This expression kind is only valid in an "argument"
1507 /// position to some sort of call expression.
1508 ///
1509 /// The parameter must have type 'pointer to T', and the argument must
1510 /// have type 'pointer to U', where T and U agree except possibly in
1511 /// qualification. If the argument value is null, then a null pointer
1512 /// is passed; otherwise it points to an object A, and:
1513 /// 1. A temporary object B of type T is initialized, either by
1514 /// zero-initialization (used when initializing an 'out' parameter)
1515 /// or copy-initialization (used when initializing an 'inout'
1516 /// parameter).
1517 /// 2. The address of the temporary is passed to the function.
1518 /// 3. If the call completes normally, A is move-assigned from B.
1519 /// 4. Finally, A is destroyed immediately.
1520 ///
1521 /// Currently 'T' must be a retainable object lifetime and must be
1522 /// __autoreleasing; this qualifier is ignored when initializing
1523 /// the value.
1525  friend class ASTReader;
1526  friend class ASTStmtReader;
1527 
1528  Stmt *Operand;
1529 
1530  // unsigned ObjCIndirectCopyRestoreBits.ShouldCopy : 1;
1531 
1532  explicit ObjCIndirectCopyRestoreExpr(EmptyShell Empty)
1533  : Expr(ObjCIndirectCopyRestoreExprClass, Empty) {}
1534 
1535  void setShouldCopy(bool shouldCopy) {
1536  ObjCIndirectCopyRestoreExprBits.ShouldCopy = shouldCopy;
1537  }
1538 
1539 public:
1540  ObjCIndirectCopyRestoreExpr(Expr *operand, QualType type, bool shouldCopy)
1541  : Expr(ObjCIndirectCopyRestoreExprClass, type, VK_LValue, OK_Ordinary,
1542  operand->isTypeDependent(), operand->isValueDependent(),
1543  operand->isInstantiationDependent(),
1544  operand->containsUnexpandedParameterPack()),
1545  Operand(operand) {
1546  setShouldCopy(shouldCopy);
1547  }
1548 
1549  Expr *getSubExpr() { return cast<Expr>(Operand); }
1550  const Expr *getSubExpr() const { return cast<Expr>(Operand); }
1551 
1552  /// shouldCopy - True if we should do the 'copy' part of the
1553  /// copy-restore. If false, the temporary will be zero-initialized.
1554  bool shouldCopy() const { return ObjCIndirectCopyRestoreExprBits.ShouldCopy; }
1555 
1556  child_range children() { return child_range(&Operand, &Operand+1); }
1557 
1558  // Source locations are determined by the subexpression.
1559  SourceLocation getBeginLoc() const LLVM_READONLY {
1560  return Operand->getBeginLoc();
1561  }
1562  SourceLocation getEndLoc() const LLVM_READONLY {
1563  return Operand->getEndLoc();
1564  }
1565 
1566  SourceLocation getExprLoc() const LLVM_READONLY {
1567  return getSubExpr()->getExprLoc();
1568  }
1569 
1570  static bool classof(const Stmt *s) {
1571  return s->getStmtClass() == ObjCIndirectCopyRestoreExprClass;
1572  }
1573 };
1574 
1575 /// An Objective-C "bridged" cast expression, which casts between
1576 /// Objective-C pointers and C pointers, transferring ownership in the process.
1577 ///
1578 /// \code
1579 /// NSString *str = (__bridge_transfer NSString *)CFCreateString();
1580 /// \endcode
1582  : public ExplicitCastExpr,
1583  private llvm::TrailingObjects<ObjCBridgedCastExpr, CXXBaseSpecifier *> {
1584  friend class ASTStmtReader;
1585  friend class ASTStmtWriter;
1586  friend class CastExpr;
1587  friend TrailingObjects;
1588 
1589  SourceLocation LParenLoc;
1590  SourceLocation BridgeKeywordLoc;
1591  unsigned Kind : 2;
1592 
1593 public:
1595  CastKind CK, SourceLocation BridgeKeywordLoc,
1596  TypeSourceInfo *TSInfo, Expr *Operand)
1597  : ExplicitCastExpr(ObjCBridgedCastExprClass, TSInfo->getType(), VK_RValue,
1598  CK, Operand, 0, TSInfo),
1599  LParenLoc(LParenLoc), BridgeKeywordLoc(BridgeKeywordLoc), Kind(Kind) {}
1600 
1601  /// Construct an empty Objective-C bridged cast.
1603  : ExplicitCastExpr(ObjCBridgedCastExprClass, Shell, 0) {}
1604 
1605  SourceLocation getLParenLoc() const { return LParenLoc; }
1606 
1607  /// Determine which kind of bridge is being performed via this cast.
1609  return static_cast<ObjCBridgeCastKind>(Kind);
1610  }
1611 
1612  /// Retrieve the kind of bridge being performed as a string.
1613  StringRef getBridgeKindName() const;
1614 
1615  /// The location of the bridge keyword.
1616  SourceLocation getBridgeKeywordLoc() const { return BridgeKeywordLoc; }
1617 
1618  SourceLocation getBeginLoc() const LLVM_READONLY { return LParenLoc; }
1619 
1620  SourceLocation getEndLoc() const LLVM_READONLY {
1621  return getSubExpr()->getEndLoc();
1622  }
1623 
1624  static bool classof(const Stmt *T) {
1625  return T->getStmtClass() == ObjCBridgedCastExprClass;
1626  }
1627 };
1628 
1629 /// A runtime availability query.
1630 ///
1631 /// There are 2 ways to spell this node:
1632 /// \code
1633 /// @available(macos 10.10, ios 8, *); // Objective-C
1634 /// __builtin_available(macos 10.10, ios 8, *); // C, C++, and Objective-C
1635 /// \endcode
1636 ///
1637 /// Note that we only need to keep track of one \c VersionTuple here, which is
1638 /// the one that corresponds to the current deployment target. This is meant to
1639 /// be used in the condition of an \c if, but it is also usable as top level
1640 /// expressions.
1641 ///
1643  friend class ASTStmtReader;
1644 
1645  VersionTuple VersionToCheck;
1646  SourceLocation AtLoc, RParen;
1647 
1648 public:
1649  ObjCAvailabilityCheckExpr(VersionTuple VersionToCheck, SourceLocation AtLoc,
1650  SourceLocation RParen, QualType Ty)
1651  : Expr(ObjCAvailabilityCheckExprClass, Ty, VK_RValue, OK_Ordinary, false,
1652  false, false, false),
1653  VersionToCheck(VersionToCheck), AtLoc(AtLoc), RParen(RParen) {}
1654 
1656  : Expr(ObjCAvailabilityCheckExprClass, Shell) {}
1657 
1658  SourceLocation getBeginLoc() const { return AtLoc; }
1659  SourceLocation getEndLoc() const { return RParen; }
1660  SourceRange getSourceRange() const { return {AtLoc, RParen}; }
1661 
1662  /// This may be '*', in which case this should fold to true.
1663  bool hasVersion() const { return !VersionToCheck.empty(); }
1664  VersionTuple getVersion() { return VersionToCheck; }
1665 
1668  }
1669 
1670  static bool classof(const Stmt *T) {
1671  return T->getStmtClass() == ObjCAvailabilityCheckExprClass;
1672  }
1673 };
1674 
1675 } // namespace clang
1676 
1677 #endif // LLVM_CLANG_AST_EXPROBJC_H
ObjCPropertyRefExpr - A dot-syntax expression to access an ObjC property.
Definition: ExprObjC.h:576
ObjCIndirectCopyRestoreExpr - Represents the passing of a function argument by indirect copy-restore ...
Definition: ExprObjC.h:1524
For nullary selectors, immediately before the end: "[foo release]" / "-(void)release;" Or with a spac...
bool getValue() const
Definition: ExprObjC.h:93
The receiver is an object instance.
Definition: ExprObjC.h:1054
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprObjC.h:841
SourceLocation getOpLoc() const
Definition: ExprObjC.h:1479
ObjCDictionaryElement getKeyValueElement(unsigned Index) const
Definition: ExprObjC.h:343
child_range children()
Definition: ExprObjC.h:103
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprObjC.h:1559
Smart pointer class that efficiently represents Objective-C method names.
A (possibly-)qualified type.
Definition: Type.h:639
static bool classof(const Stmt *T)
Definition: ExprObjC.h:377
void * getAsOpaquePtr() const
child_range children()
Definition: ExprObjC.h:752
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprObjC.h:96
ObjCMethodDecl * getAtIndexMethodDecl() const
Definition: ExprObjC.h:853
Expr(StmtClass SC, QualType T, ExprValueKind VK, ExprObjectKind OK, bool TD, bool VD, bool ID, bool ContainsUnexpandedParameterPack)
Definition: Expr.h:112
SourceLocation EllipsisLoc
The location of the ellipsis, if this element is a pack expansion.
Definition: ExprObjC.h:278
bool isSuperReceiver() const
Definition: ExprObjC.h:738
SourceLocation getEndLoc() const LLVM_READONLY
Definition: ExprObjC.h:499
ObjCBridgeCastKind
The kind of bridging performed by the Objective-C bridge cast.
ObjCProtocolDecl * getProtocol() const
Definition: ExprObjC.h:489
Stmt - This represents one statement.
Definition: Stmt.h:65
ObjCMethodDecl * setAtIndexMethodDecl() const
Definition: ExprObjC.h:857
void setArrow(bool A)
Definition: ExprObjC.h:1472
C Language Family Type Representation.
bool isSpecificPlaceholderType(unsigned K) const
Test for a specific placeholder type.
Definition: Type.h:6545
void setAtLoc(SourceLocation L)
Definition: ExprObjC.h:446
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprObjC.h:498
void setRBracket(SourceLocation RB)
Definition: ExprObjC.h:839
ObjCMethodDecl * getImplicitPropertySetter() const
Definition: ExprObjC.h:679
StringRef P
const_arg_iterator arg_end() const
Definition: ExprObjC.h:165
ObjCStringLiteral(EmptyShell Empty)
Definition: ExprObjC.h:59
SourceLocation getExprLoc() const LLVM_READONLY
Definition: ExprObjC.h:1566
void setSuper(SourceLocation Loc, QualType T, bool IsInstanceSuper)
Definition: ExprObjC.h:1296
The base class of the type hierarchy.
Definition: Type.h:1414
llvm::iterator_range< child_iterator > child_range
Definition: Stmt.h:1108
ObjCSubscriptRefExpr - used for array and dictionary subscripting.
Definition: ExprObjC.h:802
void setValue(bool V)
Definition: ExprObjC.h:94
A container of type source information.
Definition: Decl.h:86
void setInstanceReceiver(Expr *rec)
Turn this message send into an instance message that computes the receiver object with the given expr...
Definition: ExprObjC.h:1225
ObjCBoxedExpr(Expr *E, QualType T, ObjCMethodDecl *method, SourceRange R)
Definition: ExprObjC.h:124
void setLocation(SourceLocation L)
Definition: ExprObjC.h:556
void setDelegateInitCall(bool isDelegate)
Definition: ExprObjC.h:1367
void setProtocol(ObjCProtocolDecl *P)
Definition: ExprObjC.h:490
SourceLocation getAtLoc() const
Definition: ExprObjC.h:66
ObjCPropertyRefExpr(ObjCPropertyDecl *PD, QualType t, ExprValueKind VK, ExprObjectKind OK, SourceLocation l, Expr *base)
Definition: ExprObjC.h:610
Selector getSetterSelector() const
Definition: ExprObjC.h:690
ObjCIsaExpr - Represent X->isa and X.isa when X is an ObjC &#39;id&#39; type.
Definition: ExprObjC.h:1443
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprObjC.h:149
unsigned NumExpansionsPlusOne
If non-zero, the number of elements that this pack expansion will expand to (+1). ...
Definition: ExprObjC.h:282
SourceLocation getAtLoc() const
Definition: ExprObjC.h:444
void setOpLoc(SourceLocation L)
Definition: ExprObjC.h:1480
ObjCInterfaceDecl * getClassReceiver() const
Definition: ExprObjC.h:733
bool isArrow() const
Definition: ExprObjC.h:1471
ObjCMethodDecl - Represents an instance or class method declaration.
Definition: DeclObjC.h:138
SourceLocation getLeftLoc() const
Definition: ExprObjC.h:1369
ObjCBridgedCastExpr(EmptyShell Shell)
Construct an empty Objective-C bridged cast.
Definition: ExprObjC.h:1602
const StringLiteral * getString() const
Definition: ExprObjC.h:63
static bool classof(const Stmt *T)
Definition: ExprObjC.h:1497
child_range children()
Definition: ExprObjC.h:456
ObjCPropertyRefExpr(EmptyShell Empty)
Definition: ExprObjC.h:663
ReceiverKind
The kind of receiver this message is sending to.
Definition: ExprObjC.h:1049
const_arg_iterator arg_end() const
Definition: ExprObjC.h:1432
SourceRange getSourceRange() const LLVM_READONLY
Definition: ExprObjC.h:152
static bool classof(const Stmt *T)
Definition: ExprObjC.h:569
child_range children()
Definition: ExprObjC.h:567
ObjCPropertyDecl * getExplicitProperty() const
Definition: ExprObjC.h:669
void setAtLoc(SourceLocation L)
Definition: ExprObjC.h:67
SourceLocation getAtLoc() const
Definition: ExprObjC.h:493
TypeSourceInfo * getEncodedTypeSourceInfo() const
Definition: ExprObjC.h:408
SourceLocation getBaseLocEnd() const LLVM_READONLY
Definition: ExprObjC.h:1486
An element in an Objective-C dictionary literal.
Definition: ExprObjC.h:244
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition: ASTContext.h:154
ConstCastIterator< Expr > ConstExprIterator
Definition: Stmt.h:1020
Internal struct for storing Key/value pair.
Definition: ExprObjC.h:267
ObjCMethodFamily
A family of Objective-C methods.
void setKeyExpr(Stmt *S)
Definition: ExprObjC.h:851
bool isExplicitProperty() const
Definition: ExprObjC.h:667
ObjCPropertyRefExpr(ObjCMethodDecl *Getter, ObjCMethodDecl *Setter, QualType T, ExprValueKind VK, ExprObjectKind OK, SourceLocation IdLoc, Expr *Base)
Definition: ExprObjC.h:632
child_range children()
Definition: ExprObjC.h:232
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: Stmt.cpp:263
StringLiteral * getString()
Definition: ExprObjC.h:62
ObjCEncodeExpr(EmptyShell Empty)
Definition: ExprObjC.h:399
ObjCIndirectCopyRestoreExprBitfields ObjCIndirectCopyRestoreExprBits
Definition: Stmt.h:966
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:1207
ObjCBoxedExpr(EmptyShell Empty)
Definition: ExprObjC.h:131
ObjCArrayLiteral - used for objective-c array containers; as in: @["Hello", NSApp, [NSNumber numberWithInt:42]];.
Definition: ExprObjC.h:176
ObjCSelectorExpr(QualType T, Selector selInfo, SourceLocation at, SourceLocation rp)
Definition: ExprObjC.h:433
SourceLocation getEndLoc() const LLVM_READONLY
Definition: ExprObjC.h:203
An r-value expression (a pr-value in the C++11 taxonomy) produces a temporary value.
Definition: Specifiers.h:109
Selector getSelector() const
Definition: ExprObjC.h:441
bool isUnarySelector() const
SourceLocation getOpLoc() const
Definition: ExprObjC.h:563
bool isArrow() const
Definition: ExprObjC.h:550
const Expr * getElement(unsigned Index) const
Definition: ExprObjC.h:222
Expr * getKeyExpr() const
Definition: ExprObjC.h:850
ObjCBoolLiteralExpr(bool val, QualType Ty, SourceLocation l)
Definition: ExprObjC.h:86
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:706
Expr * getBaseExpr() const
Definition: ExprObjC.h:847
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified...
void setSelector(Selector S)
Definition: ExprObjC.h:442
void setLocation(SourceLocation L)
Definition: ExprObjC.h:100
SourceLocation getIsaMemberLoc() const
getMemberLoc - Return the location of the "member", in X->F, it is the location of &#39;F&#39;...
Definition: ExprObjC.h:1476
unsigned getNumSelectorLocs() const
Definition: ExprObjC.h:1391
bool isClassReceiver() const
Definition: ExprObjC.h:739
SourceLocation getEndLoc() const LLVM_READONLY
Definition: ExprObjC.h:150
const Expr *const * getElements() const
Retrieve elements of array of literals.
Definition: ExprObjC.h:210
void setString(StringLiteral *S)
Definition: ExprObjC.h:64
ObjCStringLiteral, used for Objective-C string literals i.e.
Definition: ExprObjC.h:50
static bool classof(const Stmt *T)
Definition: ExprObjC.h:1436
const Type * getTypePtr() const
Retrieves a pointer to the underlying (unqualified) type.
Definition: Type.h:6082
ObjCIsaExpr(Expr *base, bool isarrow, SourceLocation l, SourceLocation oploc, QualType ty)
Definition: ExprObjC.h:1457
CastExpr - Base class for type casts, including both implicit casts (ImplicitCastExpr) and explicit c...
Definition: Expr.h:3036
Represents an Objective-C protocol declaration.
Definition: DeclObjC.h:2063
Expr * Key
The key for the dictionary element.
Definition: ExprObjC.h:246
ObjCMethodDecl * getArrayWithObjectsMethod() const
Definition: ExprObjC.h:227
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:169
void * getAsOpaquePtr() const
Definition: Type.h:684
An ordinary object is located at an address in memory.
Definition: Specifiers.h:125
Represents an ObjC class declaration.
Definition: DeclObjC.h:1171
child_range children()
Definition: ExprObjC.h:865
SourceLocation getLocation() const
Definition: ExprObjC.h:99
const Expr *const * getArgs() const
Definition: ExprObjC.h:1342
ObjCMethodDecl * getDictWithObjectsMethod() const
Definition: ExprObjC.h:357
ObjCBoolLiteralExpr(EmptyShell Empty)
Definition: ExprObjC.h:90
ObjCIvarDecl * getDecl()
Definition: ExprObjC.h:542
SourceLocation getEndLoc() const LLVM_READONLY
Definition: ExprObjC.h:749
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprObjC.h:1482
static bool classof(const Stmt *T)
Definition: ExprObjC.h:760
SourceLocation getRBracket() const
Definition: ExprObjC.h:838
SourceLocation getEndLoc() const LLVM_READONLY
Definition: ExprObjC.h:1620
CastKind
CastKind - The kind of operation required for a conversion.
SourceRange getSourceRange() const LLVM_READONLY
Definition: ExprObjC.h:204
SourceLocation getRParenLoc() const
Definition: ExprObjC.h:445
SourceLocation getEndLoc() const LLVM_READONLY
Definition: ExprObjC.h:70
void setIsMessagingGetter(bool val=true)
Definition: ExprObjC.h:710
ObjCAvailabilityCheckExpr(VersionTuple VersionToCheck, SourceLocation AtLoc, SourceLocation RParen, QualType Ty)
Definition: ExprObjC.h:1649
ObjCEncodeExpr(QualType T, TypeSourceInfo *EncodedType, SourceLocation at, SourceLocation rp)
Definition: ExprObjC.h:390
ObjCMethodDecl * getBoxingMethod() const
Definition: ExprObjC.h:137
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprObjC.h:1618
This represents one expression.
Definition: Expr.h:108
const Expr * getInstanceReceiver() const
Definition: ExprObjC.h:1219
ObjCIvarRefExpr(EmptyShell Empty)
Definition: ExprObjC.h:539
ObjCIsaExpr(EmptyShell Empty)
Build an empty expression.
Definition: ExprObjC.h:1466
ExprValueKind
The categorization of expression values, currently following the C++11 scheme.
Definition: Specifiers.h:106
SourceLocation getExprLoc() const LLVM_READONLY
Definition: ExprObjC.h:1492
SourceLocation getEndLoc() const
Definition: ExprObjC.h:1659
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 getEndLoc() const LLVM_READONLY
Definition: ExprObjC.h:1406
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprObjC.h:414
ObjCDictionaryLiteral - AST node to represent objective-c dictionary literals; as in:"name" : NSUserN...
Definition: ExprObjC.h:287
ObjCSelectorExpr used for @selector in Objective-C.
Definition: ExprObjC.h:428
Expr ** getArgs()
Retrieve the arguments to this message, not including the receiver.
Definition: ExprObjC.h:1339
ObjCPropertyRefExpr(ObjCPropertyDecl *PD, QualType t, ExprValueKind VK, ExprObjectKind OK, SourceLocation l, SourceLocation sl, QualType st)
Definition: ExprObjC.h:621
static bool classof(const Stmt *T)
Definition: ExprObjC.h:869
ObjCStringLiteral(StringLiteral *SL, QualType T, SourceLocation L)
Definition: ExprObjC.h:55
Defines the clang::IdentifierInfo, clang::IdentifierTable, and clang::Selector interfaces.
QualType getType() const
Definition: Expr.h:130
Expr * getElement(unsigned Index)
getElement - Return the Element at the specified index.
Definition: ExprObjC.h:218
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:256
void setRParenLoc(SourceLocation L)
Definition: ExprObjC.h:496
QualType getEncodedType() const
Definition: ExprObjC.h:406
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:552
ObjCMethodDecl * getImplicitPropertyGetter() const
Definition: ExprObjC.h:674
SourceLocation getEnd() const
static bool classof(const Stmt *T)
Definition: ExprObjC.h:460
void setAtLoc(SourceLocation L)
Definition: ExprObjC.h:402
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:1105
unsigned getNumArgs() const
void setBase(Expr *base)
Definition: ExprObjC.h:548
void setRParenLoc(SourceLocation L)
Definition: ExprObjC.h:447
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:1608
const_arg_iterator arg_begin() const
Definition: ExprObjC.h:1428
__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:89
ObjCIvarRefExpr(ObjCIvarDecl *d, QualType t, SourceLocation l, SourceLocation oploc, Expr *base, bool arrow=false, bool freeIvar=false)
Definition: ExprObjC.h:527
Expr * getArg(unsigned Arg)
getArg - Return the specified argument.
Definition: ExprObjC.h:1348
SourceLocation getEndLoc() const LLVM_READONLY
Definition: Stmt.cpp:276
ObjCPropertyRefExpr(ObjCMethodDecl *Getter, ObjCMethodDecl *Setter, QualType T, ExprValueKind VK, ExprObjectKind OK, SourceLocation IdLoc, SourceLocation ReceiverLoc, ObjCInterfaceDecl *Receiver)
Definition: ExprObjC.h:653
SourceLocation getProtocolIdLoc() const
Definition: ExprObjC.h:492
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:1335
#define false
Definition: stdbool.h:33
ObjCIndirectCopyRestoreExpr(Expr *operand, QualType type, bool shouldCopy)
Definition: ExprObjC.h:1540
Kind
static bool classof(const Stmt *T)
Definition: ExprObjC.h:107
bool isImplicitProperty() const
Definition: ExprObjC.h:666
bool isInstantiationDependent() const
Whether this expression is instantiation-dependent, meaning that it depends in some way on a template...
Definition: Expr.h:193
bool isExpressibleAsConstantInitializer() const
Definition: ExprObjC.h:143
Encodes a location in the source.
Selector getGetterSelector() const
Definition: ExprObjC.h:684
SourceLocation getEndLoc() const LLVM_READONLY
Definition: ExprObjC.h:362
CastIterator< Expr > ExprIterator
Definition: Stmt.h:1019
ObjCSelectorExpr(EmptyShell Empty)
Definition: ExprObjC.h:438
SourceLocation getEndLoc() const LLVM_READONLY
Definition: ExprObjC.h:97
void setIsMessagingSetter(bool val=true)
Definition: ExprObjC.h:714
unsigned getNumElements() const
getNumElements - Return number of elements of objective-c dictionary literal.
Definition: ExprObjC.h:341
ObjCMethodFamily getMethodFamily() const
Definition: ExprObjC.h:1328
SourceRange getSourceRange() const LLVM_READONLY
Definition: ExprObjC.h:363
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprObjC.h:449
static bool classof(const Stmt *T)
Definition: ExprObjC.h:169
ExprObjectKind
A further classification of the kind of object referenced by an l-value or x-value.
Definition: Specifiers.h:123
void setClassReceiver(TypeSourceInfo *TSInfo)
Definition: ExprObjC.h:1247
SourceLocation getRParenLoc() const
Definition: ExprObjC.h:403
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:1254
SourceLocation getAtLoc() const
Definition: ExprObjC.h:401
SourceLocation getEndLoc() const LLVM_READONLY
Definition: ExprObjC.h:1490
SourceRange getSourceRange() const
Definition: ExprObjC.h:1660
void setIsFreeIvar(bool A)
Definition: ExprObjC.h:553
ObjCProtocolExpr used for protocol expression in Objective-C.
Definition: ExprObjC.h:473
SourceLocation getSelectorLoc(unsigned Index) const
Definition: ExprObjC.h:1378
bool isValueDependent() const
isValueDependent - Determines whether this expression is value-dependent (C++ [temp.dep.constexpr]).
Definition: Expr.h:151
bool hasVersion() const
This may be &#39;*&#39;, in which case this should fold to true.
Definition: ExprObjC.h:1663
Represents one property declaration in an Objective-C interface.
Definition: DeclObjC.h:728
const ObjCIvarDecl * getDecl() const
Definition: ExprObjC.h:543
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:699
void setBaseExpr(Stmt *S)
Definition: ExprObjC.h:848
Expr * getSubExpr()
Definition: ExprObjC.h:134
void setEncodedTypeSourceInfo(TypeSourceInfo *EncType)
Definition: ExprObjC.h:410
const ObjCMethodDecl * getMethodDecl() const
Definition: ExprObjC.h:1309
ObjCBoxedExpr - used for generalized expression boxing.
Definition: ExprObjC.h:116
static QualType getFromOpaquePtr(const void *Ptr)
Definition: Type.h:686
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprObjC.h:202
llvm::iterator_range< const_arg_iterator > arguments() const
Definition: ExprObjC.h:1418
A placeholder type used to construct an empty shell of a type, that will be filled in later (e...
Definition: Stmt.h:994
Expr * Value
The value of the dictionary element.
Definition: ExprObjC.h:249
Expr ** getElements()
Retrieve elements of array of literals.
Definition: ExprObjC.h:207
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:1213
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprObjC.h:744
An Objective-C "bridged" cast expression, which casts between Objective-C pointers and C pointers...
Definition: ExprObjC.h:1581
arg_iterator arg_end()
Definition: ExprObjC.h:1424
Dataflow Directional Tag Classes.
bool isValid() const
Return true if this is a valid SourceLocation object.
SourceLocation getLocation() const
Definition: ExprObjC.h:725
Reads an AST files chain containing the contents of a translation unit.
Definition: ASTReader.h:354
void setAtLoc(SourceLocation L)
Definition: ExprObjC.h:495
QualType getSuperType() const
Retrieve the type referred to by &#39;super&#39;.
Definition: ExprObjC.h:1289
SourceLocation EllipsisLoc
The location of the ellipsis, if this is a pack expansion.
Definition: ExprObjC.h:252
void setDecl(ObjCIvarDecl *d)
Definition: ExprObjC.h:544
SourceLocation getEndLoc() const LLVM_READONLY
Definition: ExprObjC.h:561
A runtime availability query.
Definition: ExprObjC.h:1642
static bool classof(const Stmt *T)
Definition: ExprObjC.h:506
StmtClass getStmtClass() const
Definition: Stmt.h:1041
child_range children()
Definition: ExprObjC.h:157
static bool classof(const Stmt *T)
Definition: ExprObjC.h:1624
ExplicitCastExpr - An explicit cast written in the source code.
Definition: Expr.h:3216
void setSelector(Selector S)
Definition: ExprObjC.h:1304
void setMethodDecl(ObjCMethodDecl *MD)
Definition: ExprObjC.h:1323
SourceLocation getLParenLoc() const
Definition: ExprObjC.h:1605
SourceLocation getRParenLoc() const
Definition: ExprObjC.h:494
child_range children()
Definition: ExprObjC.h:73
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprObjC.h:361
QualType getClassReceiver() const
Returns the type of a class message send, or NULL if the message is not a class message.
Definition: ExprObjC.h:1232
const_arg_iterator arg_begin() const
Definition: ExprObjC.h:161
SourceLocation getEndLoc() const LLVM_READONLY
Definition: ExprObjC.h:450
static bool classof(const Stmt *T)
Definition: ExprObjC.h:422
arg_iterator arg_begin()
Definition: ExprObjC.h:1422
SourceLocation getAtLoc() const
Definition: ExprObjC.h:147
Expr * getBase() const
Definition: ExprObjC.h:1469
SourceLocation getBeginLoc() const
Definition: ExprObjC.h:1658
Iterator for iterating over Stmt * arrays that contain only T *.
Definition: Stmt.h:1002
ObjCPropertyRefExpr(ObjCMethodDecl *Getter, ObjCMethodDecl *Setter, QualType T, ExprValueKind VK, ExprObjectKind OK, SourceLocation IdLoc, SourceLocation SuperLoc, QualType SuperTy)
Definition: ExprObjC.h:643
unsigned getNumElements() const
getNumElements - Return number of elements of objective-c array literal.
Definition: ExprObjC.h:215
child_range children()
Definition: ExprObjC.h:418
ObjCEncodeExpr, used for @encode in Objective-C.
Definition: ExprObjC.h:385
friend TrailingObjects
Definition: OpenMPClause.h:98
static bool classof(const Stmt *s)
Definition: ExprObjC.h:1570
SourceLocation getLocation() const
Definition: ExprObjC.h:555
ObjCAvailabilityCheckExpr(EmptyShell Shell)
Definition: ExprObjC.h:1655
ObjCBridgedCastExpr(SourceLocation LParenLoc, ObjCBridgeCastKind Kind, CastKind CK, SourceLocation BridgeKeywordLoc, TypeSourceInfo *TSInfo, Expr *Operand)
Definition: ExprObjC.h:1594
bool isDelegateInitCall() const
isDelegateInitCall - Answers whether this message send has been tagged as a "delegate init call"...
Definition: ExprObjC.h:1366
unsigned getNumArgs() const
getNumArgs - Return the number of actual arguments to this call.
Definition: ExprObjC.h:453
child_range children()
Definition: ExprObjC.h:1495
const Expr * getBase() const
Definition: ExprObjC.h:546
ObjCProtocolExpr(EmptyShell Empty)
Definition: ExprObjC.h:486
void setRParenLoc(SourceLocation L)
Definition: ExprObjC.h:404
A bitfield object is a bitfield on a C or C++ record.
Definition: Specifiers.h:128
ObjCIvarRefExpr - A reference to an ObjC instance variable.
Definition: ExprObjC.h:512
SourceLocation getEndLoc() const LLVM_READONLY
Definition: ExprObjC.h:845
bool isFreeIvar() const
Definition: ExprObjC.h:551
QualType getSuperReceiverType() const
Definition: ExprObjC.h:729
Defines the clang::SourceLocation class and associated facilities.
llvm::iterator_range< arg_iterator > arguments()
Definition: ExprObjC.h:1414
void setSourceRange(SourceRange R)
Definition: ExprObjC.h:1400
SourceLocation getSelectorStartLoc() const
Definition: ExprObjC.h:1372
SourceLocation getEndLoc() const LLVM_READONLY
Definition: ExprObjC.h:1562
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprObjC.h:1405
bool isPackExpansion() const
Determines whether this dictionary element is a pack expansion.
Definition: ExprObjC.h:259
ObjCIvarDecl - Represents an ObjC instance variable.
Definition: DeclObjC.h:1944
void setIsaMemberLoc(SourceLocation L)
Definition: ExprObjC.h:1477
bool containsUnexpandedParameterPack() const
Whether this expression contains an unexpanded parameter pack (for C++11 variadic templates)...
Definition: Expr.h:216
bool shouldCopy() const
shouldCopy - True if we should do the &#39;copy&#39; part of the copy-restore.
Definition: ExprObjC.h:1554
StringLiteral - This represents a string literal expression, e.g.
Definition: Expr.h:1599
void setOpLoc(SourceLocation L)
Definition: ExprObjC.h:564
const Expr * getArg(unsigned Arg) const
Definition: ExprObjC.h:1352
Internal struct to describes an element that is a pack expansion, used if any of the elements in the ...
Definition: ExprObjC.h:275
static bool classof(const Stmt *T)
Definition: ExprObjC.h:75
ObjCBoolLiteralExpr - Objective-C Boolean Literal.
Definition: ExprObjC.h:81
bool isObjectReceiver() const
Definition: ExprObjC.h:737
SourceLocation getReceiverLocation() const
Definition: ExprObjC.h:727
SourceLocation getBridgeKeywordLoc() const
The location of the bridge keyword.
Definition: ExprObjC.h:1616
ObjCProtocolExpr(QualType T, ObjCProtocolDecl *protocol, SourceLocation at, SourceLocation protoLoc, SourceLocation rp)
Definition: ExprObjC.h:481
const Expr * getSubExpr() const
Definition: ExprObjC.h:1550
bool isArraySubscriptRefExpr() const
Definition: ExprObjC.h:861
#define true
Definition: stdbool.h:32
static bool classof(const Stmt *T)
Definition: ExprObjC.h:237
An l-value expression is a reference to an object with independent storage.
Definition: Specifiers.h:113
const Expr * getBase() const
Definition: ExprObjC.h:718
A trivial tuple used to represent a source range.
ObjCMethodDecl * getMethodDecl()
Definition: ExprObjC.h:1316
SourceLocation getEndLoc() const LLVM_READONLY
Definition: ExprObjC.h:415
SourceLocation getRightLoc() const
Definition: ExprObjC.h:1370
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:1201
SourceLocation getBegin() const
static bool classof(const Stmt *T)
Definition: ExprObjC.h:1670
void setArg(unsigned Arg, Expr *ArgExpr)
setArg - Set the specified argument.
Definition: ExprObjC.h:1358
void setBase(Expr *E)
Definition: ExprObjC.h:1468
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprObjC.h:558
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprObjC.h:69
const Expr * getSubExpr() const
Definition: ExprObjC.h:135
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:502
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:1241