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