clang  3.9.0
DeclObjC.h
Go to the documentation of this file.
1 //===--- DeclObjC.h - Classes for representing declarations -----*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file defines the DeclObjC interface and subclasses.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #ifndef LLVM_CLANG_AST_DECLOBJC_H
15 #define LLVM_CLANG_AST_DECLOBJC_H
16 
17 #include "clang/AST/Decl.h"
19 #include "llvm/ADT/STLExtras.h"
20 #include "llvm/Support/Compiler.h"
21 
22 namespace clang {
23 class Expr;
24 class Stmt;
25 class FunctionDecl;
26 class RecordDecl;
27 class ObjCIvarDecl;
28 class ObjCMethodDecl;
29 class ObjCProtocolDecl;
30 class ObjCCategoryDecl;
31 class ObjCPropertyDecl;
32 class ObjCPropertyImplDecl;
33 class CXXCtorInitializer;
34 
35 class ObjCListBase {
36  ObjCListBase(const ObjCListBase &) = delete;
37  void operator=(const ObjCListBase &) = delete;
38 protected:
39  /// List is an array of pointers to objects that are not owned by this object.
40  void **List;
41  unsigned NumElts;
42 
43 public:
44  ObjCListBase() : List(nullptr), NumElts(0) {}
45  unsigned size() const { return NumElts; }
46  bool empty() const { return NumElts == 0; }
47 
48 protected:
49  void set(void *const* InList, unsigned Elts, ASTContext &Ctx);
50 };
51 
52 
53 /// ObjCList - This is a simple template class used to hold various lists of
54 /// decls etc, which is heavily used by the ObjC front-end. This only use case
55 /// this supports is setting the list all at once and then reading elements out
56 /// of it.
57 template <typename T>
58 class ObjCList : public ObjCListBase {
59 public:
60  void set(T* const* InList, unsigned Elts, ASTContext &Ctx) {
61  ObjCListBase::set(reinterpret_cast<void*const*>(InList), Elts, Ctx);
62  }
63 
64  typedef T* const * iterator;
65  iterator begin() const { return (iterator)List; }
66  iterator end() const { return (iterator)List+NumElts; }
67 
68  T* operator[](unsigned Idx) const {
69  assert(Idx < NumElts && "Invalid access");
70  return (T*)List[Idx];
71  }
72 };
73 
74 /// \brief A list of Objective-C protocols, along with the source
75 /// locations at which they were referenced.
76 class ObjCProtocolList : public ObjCList<ObjCProtocolDecl> {
77  SourceLocation *Locations;
78 
80 
81 public:
82  ObjCProtocolList() : ObjCList<ObjCProtocolDecl>(), Locations(nullptr) { }
83 
84  typedef const SourceLocation *loc_iterator;
85  loc_iterator loc_begin() const { return Locations; }
86  loc_iterator loc_end() const { return Locations + size(); }
87 
88  void set(ObjCProtocolDecl* const* InList, unsigned Elts,
89  const SourceLocation *Locs, ASTContext &Ctx);
90 };
91 
92 
93 /// ObjCMethodDecl - Represents an instance or class method declaration.
94 /// ObjC methods can be declared within 4 contexts: class interfaces,
95 /// categories, protocols, and class implementations. While C++ member
96 /// functions leverage C syntax, Objective-C method syntax is modeled after
97 /// Smalltalk (using colons to specify argument types/expressions).
98 /// Here are some brief examples:
99 ///
100 /// Setter/getter instance methods:
101 /// - (void)setMenu:(NSMenu *)menu;
102 /// - (NSMenu *)menu;
103 ///
104 /// Instance method that takes 2 NSView arguments:
105 /// - (void)replaceSubview:(NSView *)oldView with:(NSView *)newView;
106 ///
107 /// Getter class method:
108 /// + (NSMenu *)defaultMenu;
109 ///
110 /// A selector represents a unique name for a method. The selector names for
111 /// the above methods are setMenu:, menu, replaceSubview:with:, and defaultMenu.
112 ///
113 class ObjCMethodDecl : public NamedDecl, public DeclContext {
114 public:
116 private:
117  // The conventional meaning of this method; an ObjCMethodFamily.
118  // This is not serialized; instead, it is computed on demand and
119  // cached.
120  mutable unsigned Family : ObjCMethodFamilyBitWidth;
121 
122  /// instance (true) or class (false) method.
123  unsigned IsInstance : 1;
124  unsigned IsVariadic : 1;
125 
126  /// True if this method is the getter or setter for an explicit property.
127  unsigned IsPropertyAccessor : 1;
128 
129  // Method has a definition.
130  unsigned IsDefined : 1;
131 
132  /// \brief Method redeclaration in the same interface.
133  unsigned IsRedeclaration : 1;
134 
135  /// \brief Is redeclared in the same interface.
136  mutable unsigned HasRedeclaration : 1;
137 
138  // NOTE: VC++ treats enums as signed, avoid using ImplementationControl enum
139  /// \@required/\@optional
140  unsigned DeclImplementation : 2;
141 
142  // NOTE: VC++ treats enums as signed, avoid using the ObjCDeclQualifier enum
143  /// in, inout, etc.
144  unsigned objcDeclQualifier : 7;
145 
146  /// \brief Indicates whether this method has a related result type.
147  unsigned RelatedResultType : 1;
148 
149  /// \brief Whether the locations of the selector identifiers are in a
150  /// "standard" position, a enum SelectorLocationsKind.
151  unsigned SelLocsKind : 2;
152 
153  /// \brief Whether this method overrides any other in the class hierarchy.
154  ///
155  /// A method is said to override any method in the class's
156  /// base classes, its protocols, or its categories' protocols, that has
157  /// the same selector and is of the same kind (class or instance).
158  /// A method in an implementation is not considered as overriding the same
159  /// method in the interface or its categories.
160  unsigned IsOverriding : 1;
161 
162  /// \brief Indicates if the method was a definition but its body was skipped.
163  unsigned HasSkippedBody : 1;
164 
165  // Return type of this method.
166  QualType MethodDeclType;
167 
168  // Type source information for the return type.
169  TypeSourceInfo *ReturnTInfo;
170 
171  /// \brief Array of ParmVarDecls for the formal parameters of this method
172  /// and optionally followed by selector locations.
173  void *ParamsAndSelLocs;
174  unsigned NumParams;
175 
176  /// List of attributes for this method declaration.
177  SourceLocation DeclEndLoc; // the location of the ';' or '{'.
178 
179  // The following are only used for method definitions, null otherwise.
180  LazyDeclStmtPtr Body;
181 
182  /// SelfDecl - Decl for the implicit self parameter. This is lazily
183  /// constructed by createImplicitParams.
184  ImplicitParamDecl *SelfDecl;
185  /// CmdDecl - Decl for the implicit _cmd parameter. This is lazily
186  /// constructed by createImplicitParams.
187  ImplicitParamDecl *CmdDecl;
188 
189  SelectorLocationsKind getSelLocsKind() const {
190  return (SelectorLocationsKind)SelLocsKind;
191  }
192  bool hasStandardSelLocs() const {
193  return getSelLocsKind() != SelLoc_NonStandard;
194  }
195 
196  /// \brief Get a pointer to the stored selector identifiers locations array.
197  /// No locations will be stored if HasStandardSelLocs is true.
198  SourceLocation *getStoredSelLocs() {
199  return reinterpret_cast<SourceLocation*>(getParams() + NumParams);
200  }
201  const SourceLocation *getStoredSelLocs() const {
202  return reinterpret_cast<const SourceLocation*>(getParams() + NumParams);
203  }
204 
205  /// \brief Get a pointer to the stored selector identifiers locations array.
206  /// No locations will be stored if HasStandardSelLocs is true.
207  ParmVarDecl **getParams() {
208  return reinterpret_cast<ParmVarDecl **>(ParamsAndSelLocs);
209  }
210  const ParmVarDecl *const *getParams() const {
211  return reinterpret_cast<const ParmVarDecl *const *>(ParamsAndSelLocs);
212  }
213 
214  /// \brief Get the number of stored selector identifiers locations.
215  /// No locations will be stored if HasStandardSelLocs is true.
216  unsigned getNumStoredSelLocs() const {
217  if (hasStandardSelLocs())
218  return 0;
219  return getNumSelectorLocs();
220  }
221 
222  void setParamsAndSelLocs(ASTContext &C,
223  ArrayRef<ParmVarDecl*> Params,
224  ArrayRef<SourceLocation> SelLocs);
225 
226  ObjCMethodDecl(SourceLocation beginLoc, SourceLocation endLoc,
227  Selector SelInfo, QualType T, TypeSourceInfo *ReturnTInfo,
228  DeclContext *contextDecl, bool isInstance = true,
229  bool isVariadic = false, bool isPropertyAccessor = false,
230  bool isImplicitlyDeclared = false, bool isDefined = false,
231  ImplementationControl impControl = None,
232  bool HasRelatedResultType = false)
233  : NamedDecl(ObjCMethod, contextDecl, beginLoc, SelInfo),
234  DeclContext(ObjCMethod), Family(InvalidObjCMethodFamily),
235  IsInstance(isInstance), IsVariadic(isVariadic),
236  IsPropertyAccessor(isPropertyAccessor), IsDefined(isDefined),
237  IsRedeclaration(0), HasRedeclaration(0), DeclImplementation(impControl),
238  objcDeclQualifier(OBJC_TQ_None),
239  RelatedResultType(HasRelatedResultType),
240  SelLocsKind(SelLoc_StandardNoSpace), IsOverriding(0), HasSkippedBody(0),
241  MethodDeclType(T), ReturnTInfo(ReturnTInfo), ParamsAndSelLocs(nullptr),
242  NumParams(0), DeclEndLoc(endLoc), Body(), SelfDecl(nullptr),
243  CmdDecl(nullptr) {
244  setImplicit(isImplicitlyDeclared);
245  }
246 
247  /// \brief A definition will return its interface declaration.
248  /// An interface declaration will return its definition.
249  /// Otherwise it will return itself.
250  ObjCMethodDecl *getNextRedeclarationImpl() override;
251 
252 public:
253  static ObjCMethodDecl *
254  Create(ASTContext &C, SourceLocation beginLoc, SourceLocation endLoc,
255  Selector SelInfo, QualType T, TypeSourceInfo *ReturnTInfo,
256  DeclContext *contextDecl, bool isInstance = true,
257  bool isVariadic = false, bool isPropertyAccessor = false,
258  bool isImplicitlyDeclared = false, bool isDefined = false,
259  ImplementationControl impControl = None,
260  bool HasRelatedResultType = false);
261 
262  static ObjCMethodDecl *CreateDeserialized(ASTContext &C, unsigned ID);
263 
264  ObjCMethodDecl *getCanonicalDecl() override;
266  return const_cast<ObjCMethodDecl*>(this)->getCanonicalDecl();
267  }
268 
269  ObjCDeclQualifier getObjCDeclQualifier() const {
270  return ObjCDeclQualifier(objcDeclQualifier);
271  }
272  void setObjCDeclQualifier(ObjCDeclQualifier QV) { objcDeclQualifier = QV; }
273 
274  /// \brief Determine whether this method has a result type that is related
275  /// to the message receiver's type.
276  bool hasRelatedResultType() const { return RelatedResultType; }
277 
278  /// \brief Note whether this method has a related result type.
279  void SetRelatedResultType(bool RRT = true) { RelatedResultType = RRT; }
280 
281  /// \brief True if this is a method redeclaration in the same interface.
282  bool isRedeclaration() const { return IsRedeclaration; }
283  void setAsRedeclaration(const ObjCMethodDecl *PrevMethod);
284 
285  /// \brief Returns the location where the declarator ends. It will be
286  /// the location of ';' for a method declaration and the location of '{'
287  /// for a method definition.
288  SourceLocation getDeclaratorEndLoc() const { return DeclEndLoc; }
289 
290  // Location information, modeled after the Stmt API.
291  SourceLocation getLocStart() const LLVM_READONLY { return getLocation(); }
292  SourceLocation getLocEnd() const LLVM_READONLY;
293  SourceRange getSourceRange() const override LLVM_READONLY {
294  return SourceRange(getLocation(), getLocEnd());
295  }
296 
298  if (isImplicit())
299  return getLocStart();
300  return getSelectorLoc(0);
301  }
302  SourceLocation getSelectorLoc(unsigned Index) const {
303  assert(Index < getNumSelectorLocs() && "Index out of range!");
304  if (hasStandardSelLocs())
305  return getStandardSelectorLoc(Index, getSelector(),
306  getSelLocsKind() == SelLoc_StandardWithSpace,
307  parameters(),
308  DeclEndLoc);
309  return getStoredSelLocs()[Index];
310  }
311 
313 
314  unsigned getNumSelectorLocs() const {
315  if (isImplicit())
316  return 0;
317  Selector Sel = getSelector();
318  if (Sel.isUnarySelector())
319  return 1;
320  return Sel.getNumArgs();
321  }
322 
325  return const_cast<ObjCMethodDecl*>(this)->getClassInterface();
326  }
327 
329 
330  QualType getReturnType() const { return MethodDeclType; }
331  void setReturnType(QualType T) { MethodDeclType = T; }
333 
334  /// \brief Determine the type of an expression that sends a message to this
335  /// function. This replaces the type parameters with the types they would
336  /// get if the receiver was parameterless (e.g. it may replace the type
337  /// parameter with 'id').
338  QualType getSendResultType() const;
339 
340  /// Determine the type of an expression that sends a message to this
341  /// function with the given receiver type.
342  QualType getSendResultType(QualType receiverType) const;
343 
344  TypeSourceInfo *getReturnTypeSourceInfo() const { return ReturnTInfo; }
345  void setReturnTypeSourceInfo(TypeSourceInfo *TInfo) { ReturnTInfo = TInfo; }
346 
347  // Iterator access to formal parameters.
348  unsigned param_size() const { return NumParams; }
349  typedef const ParmVarDecl *const *param_const_iterator;
350  typedef ParmVarDecl *const *param_iterator;
351  typedef llvm::iterator_range<param_iterator> param_range;
352  typedef llvm::iterator_range<param_const_iterator> param_const_range;
353 
355  return param_const_iterator(getParams());
356  }
358  return param_const_iterator(getParams() + NumParams);
359  }
360  param_iterator param_begin() { return param_iterator(getParams()); }
361  param_iterator param_end() { return param_iterator(getParams() + NumParams); }
362 
363  // This method returns and of the parameters which are part of the selector
364  // name mangling requirements.
366  return param_begin() + getSelector().getNumArgs();
367  }
368 
369  // ArrayRef access to formal parameters. This should eventually
370  // replace the iterator interface above.
372  return llvm::makeArrayRef(const_cast<ParmVarDecl**>(getParams()),
373  NumParams);
374  }
375 
376  /// \brief Sets the method's parameters and selector source locations.
377  /// If the method is implicit (not coming from source) \p SelLocs is
378  /// ignored.
379  void setMethodParams(ASTContext &C,
380  ArrayRef<ParmVarDecl*> Params,
382 
383  // Iterator access to parameter types.
384  typedef std::const_mem_fun_t<QualType, ParmVarDecl> deref_fun;
385  typedef llvm::mapped_iterator<param_const_iterator, deref_fun>
387 
389  return llvm::map_iterator(param_begin(), deref_fun(&ParmVarDecl::getType));
390  }
392  return llvm::map_iterator(param_end(), deref_fun(&ParmVarDecl::getType));
393  }
394 
395  /// createImplicitParams - Used to lazily create the self and cmd
396  /// implict parameters. This must be called prior to using getSelfDecl()
397  /// or getCmdDecl(). The call is ignored if the implicit paramters
398  /// have already been created.
400 
401  /// \return the type for \c self and set \arg selfIsPseudoStrong and
402  /// \arg selfIsConsumed accordingly.
404  bool &selfIsPseudoStrong, bool &selfIsConsumed);
405 
406  ImplicitParamDecl * getSelfDecl() const { return SelfDecl; }
407  void setSelfDecl(ImplicitParamDecl *SD) { SelfDecl = SD; }
408  ImplicitParamDecl * getCmdDecl() const { return CmdDecl; }
409  void setCmdDecl(ImplicitParamDecl *CD) { CmdDecl = CD; }
410 
411  /// Determines the family of this method.
413 
414  bool isInstanceMethod() const { return IsInstance; }
415  void setInstanceMethod(bool isInst) { IsInstance = isInst; }
416  bool isVariadic() const { return IsVariadic; }
417  void setVariadic(bool isVar) { IsVariadic = isVar; }
418 
419  bool isClassMethod() const { return !IsInstance; }
420 
421  bool isPropertyAccessor() const { return IsPropertyAccessor; }
422  void setPropertyAccessor(bool isAccessor) { IsPropertyAccessor = isAccessor; }
423 
424  bool isDefined() const { return IsDefined; }
425  void setDefined(bool isDefined) { IsDefined = isDefined; }
426 
427  /// \brief Whether this method overrides any other in the class hierarchy.
428  ///
429  /// A method is said to override any method in the class's
430  /// base classes, its protocols, or its categories' protocols, that has
431  /// the same selector and is of the same kind (class or instance).
432  /// A method in an implementation is not considered as overriding the same
433  /// method in the interface or its categories.
434  bool isOverriding() const { return IsOverriding; }
435  void setOverriding(bool isOverriding) { IsOverriding = isOverriding; }
436 
437  /// \brief Return overridden methods for the given \p Method.
438  ///
439  /// An ObjC method is considered to override any method in the class's
440  /// base classes (and base's categories), its protocols, or its categories'
441  /// protocols, that has
442  /// the same selector and is of the same kind (class or instance).
443  /// A method in an implementation is not considered as overriding the same
444  /// method in the interface or its categories.
446  SmallVectorImpl<const ObjCMethodDecl *> &Overridden) const;
447 
448  /// \brief True if the method was a definition but its body was skipped.
449  bool hasSkippedBody() const { return HasSkippedBody; }
450  void setHasSkippedBody(bool Skipped = true) { HasSkippedBody = Skipped; }
451 
452  /// \brief Returns the property associated with this method's selector.
453  ///
454  /// Note that even if this particular method is not marked as a property
455  /// accessor, it is still possible for it to match a property declared in a
456  /// superclass. Pass \c false if you only want to check the current class.
457  const ObjCPropertyDecl *findPropertyDecl(bool CheckOverrides = true) const;
458 
459  // Related to protocols declared in \@protocol
461  DeclImplementation = ic;
462  }
464  return ImplementationControl(DeclImplementation);
465  }
466 
467  /// Returns true if this specific method declaration is marked with the
468  /// designated initializer attribute.
470 
471  /// Returns true if the method selector resolves to a designated initializer
472  /// in the class's interface.
473  ///
474  /// \param InitMethod if non-null and the function returns true, it receives
475  /// the method declaration that was marked with the designated initializer
476  /// attribute.
478  const ObjCMethodDecl **InitMethod = nullptr) const;
479 
480  /// \brief Determine whether this method has a body.
481  bool hasBody() const override { return Body.isValid(); }
482 
483  /// \brief Retrieve the body of this method, if it has one.
484  Stmt *getBody() const override;
485 
486  void setLazyBody(uint64_t Offset) { Body = Offset; }
487 
489  void setBody(Stmt *B) { Body = B; }
490 
491  /// \brief Returns whether this specific method is a definition.
492  bool isThisDeclarationADefinition() const { return hasBody(); }
493 
494  // Implement isa/cast/dyncast/etc.
495  static bool classof(const Decl *D) { return classofKind(D->getKind()); }
496  static bool classofKind(Kind K) { return K == ObjCMethod; }
498  return static_cast<DeclContext *>(const_cast<ObjCMethodDecl*>(D));
499  }
501  return static_cast<ObjCMethodDecl *>(const_cast<DeclContext*>(DC));
502  }
503 
504  friend class ASTDeclReader;
505  friend class ASTDeclWriter;
506 };
507 
508 /// Describes the variance of a given generic parameter.
509 enum class ObjCTypeParamVariance : uint8_t {
510  /// The parameter is invariant: must match exactly.
511  Invariant,
512  /// The parameter is covariant, e.g., X<T> is a subtype of X<U> when
513  /// the type parameter is covariant and T is a subtype of U.
514  Covariant,
515  /// The parameter is contravariant, e.g., X<T> is a subtype of X<U>
516  /// when the type parameter is covariant and U is a subtype of T.
518 };
519 
520 /// Represents the declaration of an Objective-C type parameter.
521 ///
522 /// \code
523 /// @interface NSDictionary<Key : id<NSCopying>, Value>
524 /// @end
525 /// \endcode
526 ///
527 /// In the example above, both \c Key and \c Value are represented by
528 /// \c ObjCTypeParamDecl. \c Key has an explicit bound of \c id<NSCopying>,
529 /// while \c Value gets an implicit bound of \c id.
530 ///
531 /// Objective-C type parameters are typedef-names in the grammar,
533  void anchor() override;
534 
535  /// Index of this type parameter in the type parameter list.
536  unsigned Index : 14;
537 
538  /// The variance of the type parameter.
539  unsigned Variance : 2;
540 
541  /// The location of the variance, if any.
542  SourceLocation VarianceLoc;
543 
544  /// The location of the ':', which will be valid when the bound was
545  /// explicitly specified.
546  SourceLocation ColonLoc;
547 
549  ObjCTypeParamVariance variance, SourceLocation varianceLoc,
550  unsigned index,
551  SourceLocation nameLoc, IdentifierInfo *name,
552  SourceLocation colonLoc, TypeSourceInfo *boundInfo)
553  : TypedefNameDecl(ObjCTypeParam, ctx, dc, nameLoc, nameLoc, name,
554  boundInfo),
555  Index(index), Variance(static_cast<unsigned>(variance)),
556  VarianceLoc(varianceLoc), ColonLoc(colonLoc) { }
557 
558 public:
560  ObjCTypeParamVariance variance,
561  SourceLocation varianceLoc,
562  unsigned index,
563  SourceLocation nameLoc,
564  IdentifierInfo *name,
565  SourceLocation colonLoc,
566  TypeSourceInfo *boundInfo);
567  static ObjCTypeParamDecl *CreateDeserialized(ASTContext &ctx, unsigned ID);
568 
569  SourceRange getSourceRange() const override LLVM_READONLY;
570 
571  /// Determine the variance of this type parameter.
573  return static_cast<ObjCTypeParamVariance>(Variance);
574  }
575 
576  /// Set the variance of this type parameter.
578  Variance = static_cast<unsigned>(variance);
579  }
580 
581  /// Retrieve the location of the variance keyword.
582  SourceLocation getVarianceLoc() const { return VarianceLoc; }
583 
584  /// Retrieve the index into its type parameter list.
585  unsigned getIndex() const { return Index; }
586 
587  /// Whether this type parameter has an explicitly-written type bound, e.g.,
588  /// "T : NSView".
589  bool hasExplicitBound() const { return ColonLoc.isValid(); }
590 
591  /// Retrieve the location of the ':' separating the type parameter name
592  /// from the explicitly-specified bound.
593  SourceLocation getColonLoc() const { return ColonLoc; }
594 
595  // Implement isa/cast/dyncast/etc.
596  static bool classof(const Decl *D) { return classofKind(D->getKind()); }
597  static bool classofKind(Kind K) { return K == ObjCTypeParam; }
598 
599  friend class ASTDeclReader;
600  friend class ASTDeclWriter;
601 };
602 
603 /// Stores a list of Objective-C type parameters for a parameterized class
604 /// or a category/extension thereof.
605 ///
606 /// \code
607 /// @interface NSArray<T> // stores the <T>
608 /// @end
609 /// \endcode
610 class ObjCTypeParamList final
611  : private llvm::TrailingObjects<ObjCTypeParamList, ObjCTypeParamDecl *> {
612  /// Stores the components of a SourceRange as a POD.
613  struct PODSourceRange {
614  unsigned Begin;
615  unsigned End;
616  };
617 
618  union {
619  /// Location of the left and right angle brackets.
620  PODSourceRange Brackets;
621 
622  // Used only for alignment.
624  };
625 
626  /// The number of parameters in the list, which are tail-allocated.
627  unsigned NumParams;
628 
631  SourceLocation rAngleLoc);
632 
633 public:
634  /// Create a new Objective-C type parameter list.
635  static ObjCTypeParamList *create(ASTContext &ctx,
636  SourceLocation lAngleLoc,
638  SourceLocation rAngleLoc);
639 
640  /// Iterate through the type parameters in the list.
642 
643  iterator begin() { return getTrailingObjects<ObjCTypeParamDecl *>(); }
644 
645  iterator end() { return begin() + size(); }
646 
647  /// Determine the number of type parameters in this list.
648  unsigned size() const { return NumParams; }
649 
650  // Iterate through the type parameters in the list.
652 
654  return getTrailingObjects<ObjCTypeParamDecl *>();
655  }
656 
657  const_iterator end() const {
658  return begin() + size();
659  }
660 
662  assert(size() > 0 && "empty Objective-C type parameter list");
663  return *begin();
664  }
665 
667  assert(size() > 0 && "empty Objective-C type parameter list");
668  return *(end() - 1);
669  }
670 
673  }
676  }
679  }
680 
681  /// Gather the default set of type arguments to be substituted for
682  /// these type parameters when dealing with an unspecialized type.
683  void gatherDefaultTypeArgs(SmallVectorImpl<QualType> &typeArgs) const;
685 };
686 
687 enum class ObjCPropertyQueryKind : uint8_t {
688  OBJC_PR_query_unknown = 0x00,
691 };
692 
693 /// \brief Represents one property declaration in an Objective-C interface.
694 ///
695 /// For example:
696 /// \code{.mm}
697 /// \@property (assign, readwrite) int MyProperty;
698 /// \endcode
699 class ObjCPropertyDecl : public NamedDecl {
700  void anchor() override;
701 public:
709  OBJC_PR_copy = 0x20,
712  OBJC_PR_atomic = 0x100,
713  OBJC_PR_weak = 0x200,
714  OBJC_PR_strong = 0x400,
716  /// Indicates that the nullability of the type was spelled with a
717  /// property attribute rather than a type qualifier.
720  OBJC_PR_class = 0x4000
721  // Adding a property should change NumPropertyAttrsBits
722  };
723 
724  enum {
725  /// \brief Number of bits fitting all the property attributes.
727  };
728 
731 private:
732  SourceLocation AtLoc; // location of \@property
733  SourceLocation LParenLoc; // location of '(' starting attribute list or null.
734  QualType DeclType;
735  TypeSourceInfo *DeclTypeSourceInfo;
736  unsigned PropertyAttributes : NumPropertyAttrsBits;
737  unsigned PropertyAttributesAsWritten : NumPropertyAttrsBits;
738  // \@required/\@optional
739  unsigned PropertyImplementation : 2;
740 
741  Selector GetterName; // getter name of NULL if no getter
742  Selector SetterName; // setter name of NULL if no setter
743 
744  ObjCMethodDecl *GetterMethodDecl; // Declaration of getter instance method
745  ObjCMethodDecl *SetterMethodDecl; // Declaration of setter instance method
746  ObjCIvarDecl *PropertyIvarDecl; // Synthesize ivar for this property
747 
749  SourceLocation AtLocation, SourceLocation LParenLocation,
750  QualType T, TypeSourceInfo *TSI,
751  PropertyControl propControl)
752  : NamedDecl(ObjCProperty, DC, L, Id), AtLoc(AtLocation),
753  LParenLoc(LParenLocation), DeclType(T), DeclTypeSourceInfo(TSI),
754  PropertyAttributes(OBJC_PR_noattr),
755  PropertyAttributesAsWritten(OBJC_PR_noattr),
756  PropertyImplementation(propControl),
757  GetterName(Selector()),
758  SetterName(Selector()),
759  GetterMethodDecl(nullptr), SetterMethodDecl(nullptr),
760  PropertyIvarDecl(nullptr) {}
761 
762 public:
763  static ObjCPropertyDecl *Create(ASTContext &C, DeclContext *DC,
764  SourceLocation L,
765  IdentifierInfo *Id, SourceLocation AtLocation,
766  SourceLocation LParenLocation,
767  QualType T,
768  TypeSourceInfo *TSI,
769  PropertyControl propControl = None);
770 
771  static ObjCPropertyDecl *CreateDeserialized(ASTContext &C, unsigned ID);
772 
773  SourceLocation getAtLoc() const { return AtLoc; }
774  void setAtLoc(SourceLocation L) { AtLoc = L; }
775 
776  SourceLocation getLParenLoc() const { return LParenLoc; }
777  void setLParenLoc(SourceLocation L) { LParenLoc = L; }
778 
779  TypeSourceInfo *getTypeSourceInfo() const { return DeclTypeSourceInfo; }
780 
781  QualType getType() const { return DeclType; }
782 
784  DeclType = T;
785  DeclTypeSourceInfo = TSI;
786  }
787 
788  /// Retrieve the type when this property is used with a specific base object
789  /// type.
790  QualType getUsageType(QualType objectType) const;
791 
793  return PropertyAttributeKind(PropertyAttributes);
794  }
796  PropertyAttributes |= PRVal;
797  }
798  void overwritePropertyAttributes(unsigned PRVal) {
799  PropertyAttributes = PRVal;
800  }
801 
803  return PropertyAttributeKind(PropertyAttributesAsWritten);
804  }
805 
807  PropertyAttributesAsWritten = PRVal;
808  }
809 
810  // Helper methods for accessing attributes.
811 
812  /// isReadOnly - Return true iff the property has a setter.
813  bool isReadOnly() const {
814  return (PropertyAttributes & OBJC_PR_readonly);
815  }
816 
817  /// isAtomic - Return true if the property is atomic.
818  bool isAtomic() const {
819  return (PropertyAttributes & OBJC_PR_atomic);
820  }
821 
822  /// isRetaining - Return true if the property retains its value.
823  bool isRetaining() const {
824  return (PropertyAttributes &
826  }
827 
828  bool isInstanceProperty() const { return !isClassProperty(); }
829  bool isClassProperty() const { return PropertyAttributes & OBJC_PR_class; }
833  }
835  return isClassProperty ? ObjCPropertyQueryKind::OBJC_PR_query_class :
837  }
838 
839  /// getSetterKind - Return the method used for doing assignment in
840  /// the property setter. This is only valid if the property has been
841  /// defined to have a setter.
843  if (PropertyAttributes & OBJC_PR_strong)
844  return getType()->isBlockPointerType() ? Copy : Retain;
845  if (PropertyAttributes & OBJC_PR_retain)
846  return Retain;
847  if (PropertyAttributes & OBJC_PR_copy)
848  return Copy;
849  if (PropertyAttributes & OBJC_PR_weak)
850  return Weak;
851  return Assign;
852  }
853 
854  Selector getGetterName() const { return GetterName; }
855  void setGetterName(Selector Sel) { GetterName = Sel; }
856 
857  Selector getSetterName() const { return SetterName; }
858  void setSetterName(Selector Sel) { SetterName = Sel; }
859 
860  ObjCMethodDecl *getGetterMethodDecl() const { return GetterMethodDecl; }
861  void setGetterMethodDecl(ObjCMethodDecl *gDecl) { GetterMethodDecl = gDecl; }
862 
863  ObjCMethodDecl *getSetterMethodDecl() const { return SetterMethodDecl; }
864  void setSetterMethodDecl(ObjCMethodDecl *gDecl) { SetterMethodDecl = gDecl; }
865 
866  // Related to \@optional/\@required declared in \@protocol
868  PropertyImplementation = pc;
869  }
871  return PropertyControl(PropertyImplementation);
872  }
873 
875  PropertyIvarDecl = Ivar;
876  }
878  return PropertyIvarDecl;
879  }
880 
881  SourceRange getSourceRange() const override LLVM_READONLY {
882  return SourceRange(AtLoc, getLocation());
883  }
884 
885  /// Get the default name of the synthesized ivar.
887 
888  /// Lookup a property by name in the specified DeclContext.
890  const IdentifierInfo *propertyID,
891  ObjCPropertyQueryKind queryKind);
892 
893  static bool classof(const Decl *D) { return classofKind(D->getKind()); }
894  static bool classofKind(Kind K) { return K == ObjCProperty; }
895 };
896 
897 /// ObjCContainerDecl - Represents a container for method declarations.
898 /// Current sub-classes are ObjCInterfaceDecl, ObjCCategoryDecl,
899 /// ObjCProtocolDecl, and ObjCImplDecl.
900 ///
901 class ObjCContainerDecl : public NamedDecl, public DeclContext {
902  void anchor() override;
903 
904  SourceLocation AtStart;
905 
906  // These two locations in the range mark the end of the method container.
907  // The first points to the '@' token, and the second to the 'end' token.
908  SourceRange AtEnd;
909 public:
910 
912  IdentifierInfo *Id, SourceLocation nameLoc,
913  SourceLocation atStartLoc)
914  : NamedDecl(DK, DC, nameLoc, Id), DeclContext(DK), AtStart(atStartLoc) {}
915 
916  // Iterator access to instance/class properties.
918  typedef llvm::iterator_range<specific_decl_iterator<ObjCPropertyDecl>>
920 
923  return prop_iterator(decls_begin());
924  }
926  return prop_iterator(decls_end());
927  }
928 
929  typedef filtered_decl_iterator<ObjCPropertyDecl,
932  typedef llvm::iterator_range<instprop_iterator> instprop_range;
933 
936  }
938  return instprop_iterator(decls_begin());
939  }
941  return instprop_iterator(decls_end());
942  }
943 
944  typedef filtered_decl_iterator<ObjCPropertyDecl,
947  typedef llvm::iterator_range<classprop_iterator> classprop_range;
948 
951  }
954  }
956  return classprop_iterator(decls_end());
957  }
958 
959  // Iterator access to instance/class methods.
961  typedef llvm::iterator_range<specific_decl_iterator<ObjCMethodDecl>>
963 
965  return method_range(meth_begin(), meth_end());
966  }
968  return method_iterator(decls_begin());
969  }
971  return method_iterator(decls_end());
972  }
973 
974  typedef filtered_decl_iterator<ObjCMethodDecl,
977  typedef llvm::iterator_range<instmeth_iterator> instmeth_range;
978 
981  }
983  return instmeth_iterator(decls_begin());
984  }
986  return instmeth_iterator(decls_end());
987  }
988 
989  typedef filtered_decl_iterator<ObjCMethodDecl,
992  typedef llvm::iterator_range<classmeth_iterator> classmeth_range;
993 
996  }
999  }
1001  return classmeth_iterator(decls_end());
1002  }
1003 
1004  // Get the local instance/class method declared in this interface.
1005  ObjCMethodDecl *getMethod(Selector Sel, bool isInstance,
1006  bool AllowHidden = false) const;
1008  bool AllowHidden = false) const {
1009  return getMethod(Sel, true/*isInstance*/, AllowHidden);
1010  }
1011  ObjCMethodDecl *getClassMethod(Selector Sel, bool AllowHidden = false) const {
1012  return getMethod(Sel, false/*isInstance*/, AllowHidden);
1013  }
1014  bool HasUserDeclaredSetterMethod(const ObjCPropertyDecl *P) const;
1016 
1018  FindPropertyDeclaration(const IdentifierInfo *PropertyId,
1019  ObjCPropertyQueryKind QueryKind) const;
1020 
1021  typedef llvm::DenseMap<std::pair<IdentifierInfo*,
1022  unsigned/*isClassProperty*/>,
1024 
1025  typedef llvm::DenseMap<const ObjCProtocolDecl *, ObjCPropertyDecl*>
1027 
1029 
1030  /// This routine collects list of properties to be implemented in the class.
1031  /// This includes, class's and its conforming protocols' properties.
1032  /// Note, the superclass's properties are not included in the list.
1034  PropertyDeclOrder &PO) const {}
1035 
1036  SourceLocation getAtStartLoc() const { return AtStart; }
1037  void setAtStartLoc(SourceLocation Loc) { AtStart = Loc; }
1038 
1039  // Marks the end of the container.
1041  return AtEnd;
1042  }
1044  AtEnd = atEnd;
1045  }
1046 
1047  SourceRange getSourceRange() const override LLVM_READONLY {
1048  return SourceRange(AtStart, getAtEndRange().getEnd());
1049  }
1050 
1051  // Implement isa/cast/dyncast/etc.
1052  static bool classof(const Decl *D) { return classofKind(D->getKind()); }
1053  static bool classofKind(Kind K) {
1054  return K >= firstObjCContainer &&
1055  K <= lastObjCContainer;
1056  }
1057 
1059  return static_cast<DeclContext *>(const_cast<ObjCContainerDecl*>(D));
1060  }
1062  return static_cast<ObjCContainerDecl *>(const_cast<DeclContext*>(DC));
1063  }
1064 };
1065 
1066 /// \brief Represents an ObjC class declaration.
1067 ///
1068 /// For example:
1069 ///
1070 /// \code
1071 /// // MostPrimitive declares no super class (not particularly useful).
1072 /// \@interface MostPrimitive
1073 /// // no instance variables or methods.
1074 /// \@end
1075 ///
1076 /// // NSResponder inherits from NSObject & implements NSCoding (a protocol).
1077 /// \@interface NSResponder : NSObject <NSCoding>
1078 /// { // instance variables are represented by ObjCIvarDecl.
1079 /// id nextResponder; // nextResponder instance variable.
1080 /// }
1081 /// - (NSResponder *)nextResponder; // return a pointer to NSResponder.
1082 /// - (void)mouseMoved:(NSEvent *)theEvent; // return void, takes a pointer
1083 /// \@end // to an NSEvent.
1084 /// \endcode
1085 ///
1086 /// Unlike C/C++, forward class declarations are accomplished with \@class.
1087 /// Unlike C/C++, \@class allows for a list of classes to be forward declared.
1088 /// Unlike C++, ObjC is a single-rooted class model. In Cocoa, classes
1089 /// typically inherit from NSObject (an exception is NSProxy).
1090 ///
1092  , public Redeclarable<ObjCInterfaceDecl> {
1093  void anchor() override;
1094 
1095  /// TypeForDecl - This indicates the Type object that represents this
1096  /// TypeDecl. It is a cache maintained by ASTContext::getObjCInterfaceType
1097  mutable const Type *TypeForDecl;
1098  friend class ASTContext;
1099 
1100  struct DefinitionData {
1101  /// \brief The definition of this class, for quick access from any
1102  /// declaration.
1103  ObjCInterfaceDecl *Definition;
1104 
1105  /// When non-null, this is always an ObjCObjectType.
1106  TypeSourceInfo *SuperClassTInfo;
1107 
1108  /// Protocols referenced in the \@interface declaration
1109  ObjCProtocolList ReferencedProtocols;
1110 
1111  /// Protocols reference in both the \@interface and class extensions.
1112  ObjCList<ObjCProtocolDecl> AllReferencedProtocols;
1113 
1114  /// \brief List of categories and class extensions defined for this class.
1115  ///
1116  /// Categories are stored as a linked list in the AST, since the categories
1117  /// and class extensions come long after the initial interface declaration,
1118  /// and we avoid dynamically-resized arrays in the AST wherever possible.
1119  ObjCCategoryDecl *CategoryList;
1120 
1121  /// IvarList - List of all ivars defined by this class; including class
1122  /// extensions and implementation. This list is built lazily.
1123  ObjCIvarDecl *IvarList;
1124 
1125  /// \brief Indicates that the contents of this Objective-C class will be
1126  /// completed by the external AST source when required.
1127  mutable unsigned ExternallyCompleted : 1;
1128 
1129  /// \brief Indicates that the ivar cache does not yet include ivars
1130  /// declared in the implementation.
1131  mutable unsigned IvarListMissingImplementation : 1;
1132 
1133  /// Indicates that this interface decl contains at least one initializer
1134  /// marked with the 'objc_designated_initializer' attribute.
1135  unsigned HasDesignatedInitializers : 1;
1136 
1137  enum InheritedDesignatedInitializersState {
1138  /// We didn't calculate whether the designated initializers should be
1139  /// inherited or not.
1140  IDI_Unknown = 0,
1141  /// Designated initializers are inherited for the super class.
1142  IDI_Inherited = 1,
1143  /// The class does not inherit designated initializers.
1144  IDI_NotInherited = 2
1145  };
1146  /// One of the \c InheritedDesignatedInitializersState enumeratos.
1147  mutable unsigned InheritedDesignatedInitializers : 2;
1148 
1149  /// \brief The location of the last location in this declaration, before
1150  /// the properties/methods. For example, this will be the '>', '}', or
1151  /// identifier,
1152  SourceLocation EndLoc;
1153 
1154  DefinitionData() : Definition(), SuperClassTInfo(), CategoryList(), IvarList(),
1155  ExternallyCompleted(),
1156  IvarListMissingImplementation(true),
1157  HasDesignatedInitializers(),
1158  InheritedDesignatedInitializers(IDI_Unknown) { }
1159  };
1160 
1161  ObjCInterfaceDecl(const ASTContext &C, DeclContext *DC, SourceLocation AtLoc,
1162  IdentifierInfo *Id, ObjCTypeParamList *typeParamList,
1163  SourceLocation CLoc, ObjCInterfaceDecl *PrevDecl,
1164  bool IsInternal);
1165 
1166  void LoadExternalDefinition() const;
1167 
1168  /// The type parameters associated with this class, if any.
1169  ObjCTypeParamList *TypeParamList;
1170 
1171  /// \brief Contains a pointer to the data associated with this class,
1172  /// which will be NULL if this class has not yet been defined.
1173  ///
1174  /// The bit indicates when we don't need to check for out-of-date
1175  /// declarations. It will be set unless modules are enabled.
1176  llvm::PointerIntPair<DefinitionData *, 1, bool> Data;
1177 
1178  DefinitionData &data() const {
1179  assert(Data.getPointer() && "Declaration has no definition!");
1180  return *Data.getPointer();
1181  }
1182 
1183  /// \brief Allocate the definition data for this class.
1184  void allocateDefinitionData();
1185 
1186  typedef Redeclarable<ObjCInterfaceDecl> redeclarable_base;
1187  ObjCInterfaceDecl *getNextRedeclarationImpl() override {
1188  return getNextRedeclaration();
1189  }
1190  ObjCInterfaceDecl *getPreviousDeclImpl() override {
1191  return getPreviousDecl();
1192  }
1193  ObjCInterfaceDecl *getMostRecentDeclImpl() override {
1194  return getMostRecentDecl();
1195  }
1196 
1197 public:
1198  static ObjCInterfaceDecl *Create(const ASTContext &C, DeclContext *DC,
1199  SourceLocation atLoc,
1200  IdentifierInfo *Id,
1201  ObjCTypeParamList *typeParamList,
1202  ObjCInterfaceDecl *PrevDecl,
1203  SourceLocation ClassLoc = SourceLocation(),
1204  bool isInternal = false);
1205 
1206  static ObjCInterfaceDecl *CreateDeserialized(const ASTContext &C, unsigned ID);
1207 
1208  /// Retrieve the type parameters of this class.
1209  ///
1210  /// This function looks for a type parameter list for the given
1211  /// class; if the class has been declared (with \c \@class) but not
1212  /// defined (with \c \@interface), it will search for a declaration that
1213  /// has type parameters, skipping any declarations that do not.
1214  ObjCTypeParamList *getTypeParamList() const;
1215 
1216  /// Set the type parameters of this class.
1217  ///
1218  /// This function is used by the AST importer, which must import the type
1219  /// parameters after creating their DeclContext to avoid loops.
1220  void setTypeParamList(ObjCTypeParamList *TPL);
1221 
1222  /// Retrieve the type parameters written on this particular declaration of
1223  /// the class.
1225  return TypeParamList;
1226  }
1227 
1228  SourceRange getSourceRange() const override LLVM_READONLY {
1231 
1232  return SourceRange(getAtStartLoc(), getLocation());
1233  }
1234 
1235  /// \brief Indicate that this Objective-C class is complete, but that
1236  /// the external AST source will be responsible for filling in its contents
1237  /// when a complete class is required.
1238  void setExternallyCompleted();
1239 
1240  /// Indicate that this interface decl contains at least one initializer
1241  /// marked with the 'objc_designated_initializer' attribute.
1243 
1244  /// Returns true if this interface decl contains at least one initializer
1245  /// marked with the 'objc_designated_initializer' attribute.
1246  bool hasDesignatedInitializers() const;
1247 
1248  /// Returns true if this interface decl declares a designated initializer
1249  /// or it inherites one from its super class.
1251  return hasDesignatedInitializers() || inheritsDesignatedInitializers();
1252  }
1253 
1255  assert(hasDefinition() && "Caller did not check for forward reference!");
1256  if (data().ExternallyCompleted)
1257  LoadExternalDefinition();
1258 
1259  return data().ReferencedProtocols;
1260  }
1261 
1264 
1266 
1267  // Get the local instance/class method declared in a category.
1270  ObjCMethodDecl *getCategoryMethod(Selector Sel, bool isInstance) const {
1271  return isInstance ? getCategoryInstanceMethod(Sel)
1272  : getCategoryClassMethod(Sel);
1273  }
1274 
1276  typedef llvm::iterator_range<protocol_iterator> protocol_range;
1277 
1280  }
1282  // FIXME: Should make sure no callers ever do this.
1283  if (!hasDefinition())
1284  return protocol_iterator();
1285 
1286  if (data().ExternallyCompleted)
1287  LoadExternalDefinition();
1288 
1289  return data().ReferencedProtocols.begin();
1290  }
1292  // FIXME: Should make sure no callers ever do this.
1293  if (!hasDefinition())
1294  return protocol_iterator();
1295 
1296  if (data().ExternallyCompleted)
1297  LoadExternalDefinition();
1298 
1299  return data().ReferencedProtocols.end();
1300  }
1301 
1303  typedef llvm::iterator_range<protocol_loc_iterator> protocol_loc_range;
1304 
1307  }
1309  // FIXME: Should make sure no callers ever do this.
1310  if (!hasDefinition())
1311  return protocol_loc_iterator();
1312 
1313  if (data().ExternallyCompleted)
1314  LoadExternalDefinition();
1315 
1316  return data().ReferencedProtocols.loc_begin();
1317  }
1318 
1320  // FIXME: Should make sure no callers ever do this.
1321  if (!hasDefinition())
1322  return protocol_loc_iterator();
1323 
1324  if (data().ExternallyCompleted)
1325  LoadExternalDefinition();
1326 
1327  return data().ReferencedProtocols.loc_end();
1328  }
1329 
1331  typedef llvm::iterator_range<all_protocol_iterator> all_protocol_range;
1332 
1336  }
1338  // FIXME: Should make sure no callers ever do this.
1339  if (!hasDefinition())
1340  return all_protocol_iterator();
1341 
1342  if (data().ExternallyCompleted)
1343  LoadExternalDefinition();
1344 
1345  return data().AllReferencedProtocols.empty()
1346  ? protocol_begin()
1347  : data().AllReferencedProtocols.begin();
1348  }
1350  // FIXME: Should make sure no callers ever do this.
1351  if (!hasDefinition())
1352  return all_protocol_iterator();
1353 
1354  if (data().ExternallyCompleted)
1355  LoadExternalDefinition();
1356 
1357  return data().AllReferencedProtocols.empty()
1358  ? protocol_end()
1359  : data().AllReferencedProtocols.end();
1360  }
1361 
1363  typedef llvm::iterator_range<specific_decl_iterator<ObjCIvarDecl>> ivar_range;
1364 
1365  ivar_range ivars() const { return ivar_range(ivar_begin(), ivar_end()); }
1367  if (const ObjCInterfaceDecl *Def = getDefinition())
1368  return ivar_iterator(Def->decls_begin());
1369 
1370  // FIXME: Should make sure no callers ever do this.
1371  return ivar_iterator();
1372  }
1374  if (const ObjCInterfaceDecl *Def = getDefinition())
1375  return ivar_iterator(Def->decls_end());
1376 
1377  // FIXME: Should make sure no callers ever do this.
1378  return ivar_iterator();
1379  }
1380 
1381  unsigned ivar_size() const {
1382  return std::distance(ivar_begin(), ivar_end());
1383  }
1384 
1385  bool ivar_empty() const { return ivar_begin() == ivar_end(); }
1386 
1389  // Even though this modifies IvarList, it's conceptually const:
1390  // the ivar chain is essentially a cached property of ObjCInterfaceDecl.
1391  return const_cast<ObjCInterfaceDecl *>(this)->all_declared_ivar_begin();
1392  }
1393  void setIvarList(ObjCIvarDecl *ivar) { data().IvarList = ivar; }
1394 
1395  /// setProtocolList - Set the list of protocols that this interface
1396  /// implements.
1397  void setProtocolList(ObjCProtocolDecl *const* List, unsigned Num,
1398  const SourceLocation *Locs, ASTContext &C) {
1399  data().ReferencedProtocols.set(List, Num, Locs, C);
1400  }
1401 
1402  /// mergeClassExtensionProtocolList - Merge class extension's protocol list
1403  /// into the protocol list for this class.
1405  unsigned Num,
1406  ASTContext &C);
1407 
1408  /// Produce a name to be used for class's metadata. It comes either via
1409  /// objc_runtime_name attribute or class name.
1410  StringRef getObjCRuntimeNameAsString() const;
1411 
1412  /// Returns the designated initializers for the interface.
1413  ///
1414  /// If this declaration does not have methods marked as designated
1415  /// initializers then the interface inherits the designated initializers of
1416  /// its super class.
1419 
1420  /// Returns true if the given selector is a designated initializer for the
1421  /// interface.
1422  ///
1423  /// If this declaration does not have methods marked as designated
1424  /// initializers then the interface inherits the designated initializers of
1425  /// its super class.
1426  ///
1427  /// \param InitMethod if non-null and the function returns true, it receives
1428  /// the method that was marked as a designated initializer.
1429  bool
1431  const ObjCMethodDecl **InitMethod = nullptr) const;
1432 
1433  /// \brief Determine whether this particular declaration of this class is
1434  /// actually also a definition.
1436  return getDefinition() == this;
1437  }
1438 
1439  /// \brief Determine whether this class has been defined.
1440  bool hasDefinition() const {
1441  // If the name of this class is out-of-date, bring it up-to-date, which
1442  // might bring in a definition.
1443  // Note: a null value indicates that we don't have a definition and that
1444  // modules are enabled.
1445  if (!Data.getOpaqueValue())
1447 
1448  return Data.getPointer();
1449  }
1450 
1451  /// \brief Retrieve the definition of this class, or NULL if this class
1452  /// has been forward-declared (with \@class) but not yet defined (with
1453  /// \@interface).
1455  return hasDefinition()? Data.getPointer()->Definition : nullptr;
1456  }
1457 
1458  /// \brief Retrieve the definition of this class, or NULL if this class
1459  /// has been forward-declared (with \@class) but not yet defined (with
1460  /// \@interface).
1462  return hasDefinition()? Data.getPointer()->Definition : nullptr;
1463  }
1464 
1465  /// \brief Starts the definition of this Objective-C class, taking it from
1466  /// a forward declaration (\@class) to a definition (\@interface).
1467  void startDefinition();
1468 
1469  /// Retrieve the superclass type.
1471  if (TypeSourceInfo *TInfo = getSuperClassTInfo())
1472  return TInfo->getType()->castAs<ObjCObjectType>();
1473 
1474  return nullptr;
1475  }
1476 
1477  // Retrieve the type source information for the superclass.
1479  // FIXME: Should make sure no callers ever do this.
1480  if (!hasDefinition())
1481  return nullptr;
1482 
1483  if (data().ExternallyCompleted)
1484  LoadExternalDefinition();
1485 
1486  return data().SuperClassTInfo;
1487  }
1488 
1489  // Retrieve the declaration for the superclass of this class, which
1490  // does not include any type arguments that apply to the superclass.
1492 
1493  void setSuperClass(TypeSourceInfo *superClass) {
1494  data().SuperClassTInfo = superClass;
1495  }
1496 
1497  /// \brief Iterator that walks over the list of categories, filtering out
1498  /// those that do not meet specific criteria.
1499  ///
1500  /// This class template is used for the various permutations of category
1501  /// and extension iterators.
1502  template<bool (*Filter)(ObjCCategoryDecl *)>
1504  ObjCCategoryDecl *Current;
1505 
1506  void findAcceptableCategory();
1507 
1508  public:
1513  typedef std::input_iterator_tag iterator_category;
1514 
1515  filtered_category_iterator() : Current(nullptr) { }
1517  : Current(Current)
1518  {
1519  findAcceptableCategory();
1520  }
1521 
1522  reference operator*() const { return Current; }
1523  pointer operator->() const { return Current; }
1524 
1526 
1528  filtered_category_iterator Tmp = *this;
1529  ++(*this);
1530  return Tmp;
1531  }
1532 
1535  return X.Current == Y.Current;
1536  }
1537 
1540  return X.Current != Y.Current;
1541  }
1542  };
1543 
1544 private:
1545  /// \brief Test whether the given category is visible.
1546  ///
1547  /// Used in the \c visible_categories_iterator.
1548  static bool isVisibleCategory(ObjCCategoryDecl *Cat);
1549 
1550 public:
1551  /// \brief Iterator that walks over the list of categories and extensions
1552  /// that are visible, i.e., not hidden in a non-imported submodule.
1553  typedef filtered_category_iterator<isVisibleCategory>
1555 
1556  typedef llvm::iterator_range<visible_categories_iterator>
1558 
1562  }
1563 
1564  /// \brief Retrieve an iterator to the beginning of the visible-categories
1565  /// list.
1568  }
1569 
1570  /// \brief Retrieve an iterator to the end of the visible-categories list.
1572  return visible_categories_iterator();
1573  }
1574 
1575  /// \brief Determine whether the visible-categories list is empty.
1578  }
1579 
1580 private:
1581  /// \brief Test whether the given category... is a category.
1582  ///
1583  /// Used in the \c known_categories_iterator.
1584  static bool isKnownCategory(ObjCCategoryDecl *) { return true; }
1585 
1586 public:
1587  /// \brief Iterator that walks over all of the known categories and
1588  /// extensions, including those that are hidden.
1590  typedef llvm::iterator_range<known_categories_iterator>
1592 
1596  }
1597 
1598  /// \brief Retrieve an iterator to the beginning of the known-categories
1599  /// list.
1602  }
1603 
1604  /// \brief Retrieve an iterator to the end of the known-categories list.
1606  return known_categories_iterator();
1607  }
1608 
1609  /// \brief Determine whether the known-categories list is empty.
1610  bool known_categories_empty() const {
1612  }
1613 
1614 private:
1615  /// \brief Test whether the given category is a visible extension.
1616  ///
1617  /// Used in the \c visible_extensions_iterator.
1618  static bool isVisibleExtension(ObjCCategoryDecl *Cat);
1619 
1620 public:
1621  /// \brief Iterator that walks over all of the visible extensions, skipping
1622  /// any that are known but hidden.
1623  typedef filtered_category_iterator<isVisibleExtension>
1625 
1626  typedef llvm::iterator_range<visible_extensions_iterator>
1628 
1632  }
1633 
1634  /// \brief Retrieve an iterator to the beginning of the visible-extensions
1635  /// list.
1638  }
1639 
1640  /// \brief Retrieve an iterator to the end of the visible-extensions list.
1642  return visible_extensions_iterator();
1643  }
1644 
1645  /// \brief Determine whether the visible-extensions list is empty.
1648  }
1649 
1650 private:
1651  /// \brief Test whether the given category is an extension.
1652  ///
1653  /// Used in the \c known_extensions_iterator.
1654  static bool isKnownExtension(ObjCCategoryDecl *Cat);
1655 
1656 public:
1657  /// \brief Iterator that walks over all of the known extensions.
1658  typedef filtered_category_iterator<isKnownExtension>
1660  typedef llvm::iterator_range<known_extensions_iterator>
1662 
1666  }
1667 
1668  /// \brief Retrieve an iterator to the beginning of the known-extensions
1669  /// list.
1672  }
1673 
1674  /// \brief Retrieve an iterator to the end of the known-extensions list.
1676  return known_extensions_iterator();
1677  }
1678 
1679  /// \brief Determine whether the known-extensions list is empty.
1680  bool known_extensions_empty() const {
1682  }
1683 
1684  /// \brief Retrieve the raw pointer to the start of the category/extension
1685  /// list.
1687  // FIXME: Should make sure no callers ever do this.
1688  if (!hasDefinition())
1689  return nullptr;
1690 
1691  if (data().ExternallyCompleted)
1692  LoadExternalDefinition();
1693 
1694  return data().CategoryList;
1695  }
1696 
1697  /// \brief Set the raw pointer to the start of the category/extension
1698  /// list.
1700  data().CategoryList = category;
1701  }
1702 
1705  ObjCPropertyQueryKind QueryKind) const;
1706 
1708  PropertyDeclOrder &PO) const override;
1709 
1710  /// isSuperClassOf - Return true if this class is the specified class or is a
1711  /// super class of the specified interface class.
1712  bool isSuperClassOf(const ObjCInterfaceDecl *I) const {
1713  // If RHS is derived from LHS it is OK; else it is not OK.
1714  while (I != nullptr) {
1715  if (declaresSameEntity(this, I))
1716  return true;
1717 
1718  I = I->getSuperClass();
1719  }
1720  return false;
1721  }
1722 
1723  /// isArcWeakrefUnavailable - Checks for a class or one of its super classes
1724  /// to be incompatible with __weak references. Returns true if it is.
1725  bool isArcWeakrefUnavailable() const;
1726 
1727  /// isObjCRequiresPropertyDefs - Checks that a class or one of its super
1728  /// classes must not be auto-synthesized. Returns class decl. if it must not
1729  /// be; 0, otherwise.
1731 
1733  ObjCInterfaceDecl *&ClassDeclared);
1735  ObjCInterfaceDecl *ClassDeclared;
1736  return lookupInstanceVariable(IVarName, ClassDeclared);
1737  }
1738 
1740 
1741  // Lookup a method. First, we search locally. If a method isn't
1742  // found, we search referenced protocols and class categories.
1743  ObjCMethodDecl *lookupMethod(Selector Sel, bool isInstance,
1744  bool shallowCategoryLookup = false,
1745  bool followSuper = true,
1746  const ObjCCategoryDecl *C = nullptr) const;
1747 
1748  /// Lookup an instance method for a given selector.
1750  return lookupMethod(Sel, true/*isInstance*/);
1751  }
1752 
1753  /// Lookup a class method for a given selector.
1755  return lookupMethod(Sel, false/*isInstance*/);
1756  }
1758 
1759  /// \brief Lookup a method in the classes implementation hierarchy.
1761  bool Instance=true) const;
1762 
1764  return lookupPrivateMethod(Sel, false);
1765  }
1766 
1767  /// \brief Lookup a setter or getter in the class hierarchy,
1768  /// including in all categories except for category passed
1769  /// as argument.
1771  const ObjCCategoryDecl *Cat,
1772  bool IsClassProperty) const {
1773  return lookupMethod(Sel, !IsClassProperty/*isInstance*/,
1774  false/*shallowCategoryLookup*/,
1775  true /* followsSuper */,
1776  Cat);
1777  }
1778 
1780  if (!hasDefinition())
1781  return getLocation();
1782 
1783  return data().EndLoc;
1784  }
1785 
1786  void setEndOfDefinitionLoc(SourceLocation LE) { data().EndLoc = LE; }
1787 
1788  /// Retrieve the starting location of the superclass.
1790 
1791  /// isImplicitInterfaceDecl - check that this is an implicitly declared
1792  /// ObjCInterfaceDecl node. This is for legacy objective-c \@implementation
1793  /// declaration without an \@interface declaration.
1794  bool isImplicitInterfaceDecl() const {
1795  return hasDefinition() ? data().Definition->isImplicit() : isImplicit();
1796  }
1797 
1798  /// ClassImplementsProtocol - Checks that 'lProto' protocol
1799  /// has been implemented in IDecl class, its super class or categories (if
1800  /// lookupCategory is true).
1802  bool lookupCategory,
1803  bool RHSIsQualifiedID = false);
1804 
1806  typedef redeclarable_base::redecl_iterator redecl_iterator;
1813 
1814  /// Retrieves the canonical declaration of this Objective-C class.
1816  const ObjCInterfaceDecl *getCanonicalDecl() const { return getFirstDecl(); }
1817 
1818  // Low-level accessor
1819  const Type *getTypeForDecl() const { return TypeForDecl; }
1820  void setTypeForDecl(const Type *TD) const { TypeForDecl = TD; }
1821 
1822  static bool classof(const Decl *D) { return classofKind(D->getKind()); }
1823  static bool classofKind(Kind K) { return K == ObjCInterface; }
1824 
1825  friend class ASTReader;
1826  friend class ASTDeclReader;
1827  friend class ASTDeclWriter;
1828 
1829 private:
1830  const ObjCInterfaceDecl *findInterfaceWithDesignatedInitializers() const;
1831  bool inheritsDesignatedInitializers() const;
1832 };
1833 
1834 /// ObjCIvarDecl - Represents an ObjC instance variable. In general, ObjC
1835 /// instance variables are identical to C. The only exception is Objective-C
1836 /// supports C++ style access control. For example:
1837 ///
1838 /// \@interface IvarExample : NSObject
1839 /// {
1840 /// id defaultToProtected;
1841 /// \@public:
1842 /// id canBePublic; // same as C++.
1843 /// \@protected:
1844 /// id canBeProtected; // same as C++.
1845 /// \@package:
1846 /// id canBePackage; // framework visibility (not available in C++).
1847 /// }
1848 ///
1849 class ObjCIvarDecl : public FieldDecl {
1850  void anchor() override;
1851 
1852 public:
1855  };
1856 
1857 private:
1859  SourceLocation IdLoc, IdentifierInfo *Id,
1860  QualType T, TypeSourceInfo *TInfo, AccessControl ac, Expr *BW,
1861  bool synthesized)
1862  : FieldDecl(ObjCIvar, DC, StartLoc, IdLoc, Id, T, TInfo, BW,
1863  /*Mutable=*/false, /*HasInit=*/ICIS_NoInit),
1864  NextIvar(nullptr), DeclAccess(ac), Synthesized(synthesized) {}
1865 
1866 public:
1867  static ObjCIvarDecl *Create(ASTContext &C, ObjCContainerDecl *DC,
1868  SourceLocation StartLoc, SourceLocation IdLoc,
1869  IdentifierInfo *Id, QualType T,
1870  TypeSourceInfo *TInfo,
1871  AccessControl ac, Expr *BW = nullptr,
1872  bool synthesized=false);
1873 
1874  static ObjCIvarDecl *CreateDeserialized(ASTContext &C, unsigned ID);
1875 
1876  /// \brief Return the class interface that this ivar is logically contained
1877  /// in; this is either the interface where the ivar was declared, or the
1878  /// interface the ivar is conceptually a part of in the case of synthesized
1879  /// ivars.
1880  const ObjCInterfaceDecl *getContainingInterface() const;
1881 
1882  ObjCIvarDecl *getNextIvar() { return NextIvar; }
1883  const ObjCIvarDecl *getNextIvar() const { return NextIvar; }
1884  void setNextIvar(ObjCIvarDecl *ivar) { NextIvar = ivar; }
1885 
1886  void setAccessControl(AccessControl ac) { DeclAccess = ac; }
1887 
1888  AccessControl getAccessControl() const { return AccessControl(DeclAccess); }
1889 
1891  return DeclAccess == None ? Protected : AccessControl(DeclAccess);
1892  }
1893 
1894  void setSynthesize(bool synth) { Synthesized = synth; }
1895  bool getSynthesize() const { return Synthesized; }
1896 
1897  /// Retrieve the type of this instance variable when viewed as a member of a
1898  /// specific object type.
1899  QualType getUsageType(QualType objectType) const;
1900 
1901  // Implement isa/cast/dyncast/etc.
1902  static bool classof(const Decl *D) { return classofKind(D->getKind()); }
1903  static bool classofKind(Kind K) { return K == ObjCIvar; }
1904 private:
1905  /// NextIvar - Next Ivar in the list of ivars declared in class; class's
1906  /// extensions and class's implementation
1907  ObjCIvarDecl *NextIvar;
1908 
1909  // NOTE: VC++ treats enums as signed, avoid using the AccessControl enum
1910  unsigned DeclAccess : 3;
1911  unsigned Synthesized : 1;
1912 };
1913 
1914 
1915 /// \brief Represents a field declaration created by an \@defs(...).
1917  void anchor() override;
1919  SourceLocation IdLoc, IdentifierInfo *Id,
1920  QualType T, Expr *BW)
1921  : FieldDecl(ObjCAtDefsField, DC, StartLoc, IdLoc, Id, T,
1922  /*TInfo=*/nullptr, // FIXME: Do ObjCAtDefs have declarators ?
1923  BW, /*Mutable=*/false, /*HasInit=*/ICIS_NoInit) {}
1924 
1925 public:
1927  SourceLocation StartLoc,
1928  SourceLocation IdLoc, IdentifierInfo *Id,
1929  QualType T, Expr *BW);
1930 
1931  static ObjCAtDefsFieldDecl *CreateDeserialized(ASTContext &C, unsigned ID);
1932 
1933  // Implement isa/cast/dyncast/etc.
1934  static bool classof(const Decl *D) { return classofKind(D->getKind()); }
1935  static bool classofKind(Kind K) { return K == ObjCAtDefsField; }
1936 };
1937 
1938 /// \brief Represents an Objective-C protocol declaration.
1939 ///
1940 /// Objective-C protocols declare a pure abstract type (i.e., no instance
1941 /// variables are permitted). Protocols originally drew inspiration from
1942 /// C++ pure virtual functions (a C++ feature with nice semantics and lousy
1943 /// syntax:-). Here is an example:
1944 ///
1945 /// \code
1946 /// \@protocol NSDraggingInfo <refproto1, refproto2>
1947 /// - (NSWindow *)draggingDestinationWindow;
1948 /// - (NSImage *)draggedImage;
1949 /// \@end
1950 /// \endcode
1951 ///
1952 /// This says that NSDraggingInfo requires two methods and requires everything
1953 /// that the two "referenced protocols" 'refproto1' and 'refproto2' require as
1954 /// well.
1955 ///
1956 /// \code
1957 /// \@interface ImplementsNSDraggingInfo : NSObject <NSDraggingInfo>
1958 /// \@end
1959 /// \endcode
1960 ///
1961 /// ObjC protocols inspired Java interfaces. Unlike Java, ObjC classes and
1962 /// protocols are in distinct namespaces. For example, Cocoa defines both
1963 /// an NSObject protocol and class (which isn't allowed in Java). As a result,
1964 /// protocols are referenced using angle brackets as follows:
1965 ///
1966 /// id <NSDraggingInfo> anyObjectThatImplementsNSDraggingInfo;
1967 ///
1969  public Redeclarable<ObjCProtocolDecl> {
1970  void anchor() override;
1971 
1972  struct DefinitionData {
1973  // \brief The declaration that defines this protocol.
1974  ObjCProtocolDecl *Definition;
1975 
1976  /// \brief Referenced protocols
1977  ObjCProtocolList ReferencedProtocols;
1978  };
1979 
1980  /// \brief Contains a pointer to the data associated with this class,
1981  /// which will be NULL if this class has not yet been defined.
1982  ///
1983  /// The bit indicates when we don't need to check for out-of-date
1984  /// declarations. It will be set unless modules are enabled.
1985  llvm::PointerIntPair<DefinitionData *, 1, bool> Data;
1986 
1987  DefinitionData &data() const {
1988  assert(Data.getPointer() && "Objective-C protocol has no definition!");
1989  return *Data.getPointer();
1990  }
1991 
1993  SourceLocation nameLoc, SourceLocation atStartLoc,
1994  ObjCProtocolDecl *PrevDecl);
1995 
1996  void allocateDefinitionData();
1997 
1999  ObjCProtocolDecl *getNextRedeclarationImpl() override {
2000  return getNextRedeclaration();
2001  }
2002  ObjCProtocolDecl *getPreviousDeclImpl() override {
2003  return getPreviousDecl();
2004  }
2005  ObjCProtocolDecl *getMostRecentDeclImpl() override {
2006  return getMostRecentDecl();
2007  }
2008 
2009 public:
2011  IdentifierInfo *Id,
2012  SourceLocation nameLoc,
2013  SourceLocation atStartLoc,
2014  ObjCProtocolDecl *PrevDecl);
2015 
2016  static ObjCProtocolDecl *CreateDeserialized(ASTContext &C, unsigned ID);
2017 
2019  assert(hasDefinition() && "No definition available!");
2020  return data().ReferencedProtocols;
2021  }
2023  typedef llvm::iterator_range<protocol_iterator> protocol_range;
2024 
2027  }
2029  if (!hasDefinition())
2030  return protocol_iterator();
2031 
2032  return data().ReferencedProtocols.begin();
2033  }
2035  if (!hasDefinition())
2036  return protocol_iterator();
2037 
2038  return data().ReferencedProtocols.end();
2039  }
2041  typedef llvm::iterator_range<protocol_loc_iterator> protocol_loc_range;
2042 
2045  }
2047  if (!hasDefinition())
2048  return protocol_loc_iterator();
2049 
2050  return data().ReferencedProtocols.loc_begin();
2051  }
2053  if (!hasDefinition())
2054  return protocol_loc_iterator();
2055 
2056  return data().ReferencedProtocols.loc_end();
2057  }
2058  unsigned protocol_size() const {
2059  if (!hasDefinition())
2060  return 0;
2061 
2062  return data().ReferencedProtocols.size();
2063  }
2064 
2065  /// setProtocolList - Set the list of protocols that this interface
2066  /// implements.
2067  void setProtocolList(ObjCProtocolDecl *const*List, unsigned Num,
2068  const SourceLocation *Locs, ASTContext &C) {
2069  assert(hasDefinition() && "Protocol is not defined");
2070  data().ReferencedProtocols.set(List, Num, Locs, C);
2071  }
2072 
2074 
2075  // Lookup a method. First, we search locally. If a method isn't
2076  // found, we search referenced protocols and class categories.
2077  ObjCMethodDecl *lookupMethod(Selector Sel, bool isInstance) const;
2079  return lookupMethod(Sel, true/*isInstance*/);
2080  }
2082  return lookupMethod(Sel, false/*isInstance*/);
2083  }
2084 
2085  /// \brief Determine whether this protocol has a definition.
2086  bool hasDefinition() const {
2087  // If the name of this protocol is out-of-date, bring it up-to-date, which
2088  // might bring in a definition.
2089  // Note: a null value indicates that we don't have a definition and that
2090  // modules are enabled.
2091  if (!Data.getOpaqueValue())
2093 
2094  return Data.getPointer();
2095  }
2096 
2097  /// \brief Retrieve the definition of this protocol, if any.
2099  return hasDefinition()? Data.getPointer()->Definition : nullptr;
2100  }
2101 
2102  /// \brief Retrieve the definition of this protocol, if any.
2104  return hasDefinition()? Data.getPointer()->Definition : nullptr;
2105  }
2106 
2107  /// \brief Determine whether this particular declaration is also the
2108  /// definition.
2110  return getDefinition() == this;
2111  }
2112 
2113  /// \brief Starts the definition of this Objective-C protocol.
2114  void startDefinition();
2115 
2116  /// Produce a name to be used for protocol's metadata. It comes either via
2117  /// objc_runtime_name attribute or protocol name.
2118  StringRef getObjCRuntimeNameAsString() const;
2119 
2120  SourceRange getSourceRange() const override LLVM_READONLY {
2123 
2124  return SourceRange(getAtStartLoc(), getLocation());
2125  }
2126 
2128  typedef redeclarable_base::redecl_iterator redecl_iterator;
2135 
2136  /// Retrieves the canonical declaration of this Objective-C protocol.
2138  const ObjCProtocolDecl *getCanonicalDecl() const { return getFirstDecl(); }
2139 
2141  PropertyDeclOrder &PO) const override;
2142 
2144  ProtocolPropertyMap &PM) const;
2145 
2146  static bool classof(const Decl *D) { return classofKind(D->getKind()); }
2147  static bool classofKind(Kind K) { return K == ObjCProtocol; }
2148 
2149  friend class ASTReader;
2150  friend class ASTDeclReader;
2151  friend class ASTDeclWriter;
2152 };
2153 
2154 /// ObjCCategoryDecl - Represents a category declaration. A category allows
2155 /// you to add methods to an existing class (without subclassing or modifying
2156 /// the original class interface or implementation:-). Categories don't allow
2157 /// you to add instance data. The following example adds "myMethod" to all
2158 /// NSView's within a process:
2159 ///
2160 /// \@interface NSView (MyViewMethods)
2161 /// - myMethod;
2162 /// \@end
2163 ///
2164 /// Categories also allow you to split the implementation of a class across
2165 /// several files (a feature more naturally supported in C++).
2166 ///
2167 /// Categories were originally inspired by dynamic languages such as Common
2168 /// Lisp and Smalltalk. More traditional class-based languages (C++, Java)
2169 /// don't support this level of dynamism, which is both powerful and dangerous.
2170 ///
2172  void anchor() override;
2173 
2174  /// Interface belonging to this category
2175  ObjCInterfaceDecl *ClassInterface;
2176 
2177  /// The type parameters associated with this category, if any.
2178  ObjCTypeParamList *TypeParamList;
2179 
2180  /// referenced protocols in this category.
2181  ObjCProtocolList ReferencedProtocols;
2182 
2183  /// Next category belonging to this class.
2184  /// FIXME: this should not be a singly-linked list. Move storage elsewhere.
2185  ObjCCategoryDecl *NextClassCategory;
2186 
2187  /// \brief The location of the category name in this declaration.
2188  SourceLocation CategoryNameLoc;
2189 
2190  /// class extension may have private ivars.
2191  SourceLocation IvarLBraceLoc;
2192  SourceLocation IvarRBraceLoc;
2193 
2195  SourceLocation ClassNameLoc, SourceLocation CategoryNameLoc,
2196  IdentifierInfo *Id, ObjCInterfaceDecl *IDecl,
2197  ObjCTypeParamList *typeParamList,
2198  SourceLocation IvarLBraceLoc=SourceLocation(),
2199  SourceLocation IvarRBraceLoc=SourceLocation());
2200 
2201 public:
2202 
2204  SourceLocation AtLoc,
2205  SourceLocation ClassNameLoc,
2206  SourceLocation CategoryNameLoc,
2207  IdentifierInfo *Id,
2208  ObjCInterfaceDecl *IDecl,
2209  ObjCTypeParamList *typeParamList,
2210  SourceLocation IvarLBraceLoc=SourceLocation(),
2211  SourceLocation IvarRBraceLoc=SourceLocation());
2212  static ObjCCategoryDecl *CreateDeserialized(ASTContext &C, unsigned ID);
2213 
2214  ObjCInterfaceDecl *getClassInterface() { return ClassInterface; }
2215  const ObjCInterfaceDecl *getClassInterface() const { return ClassInterface; }
2216 
2217  /// Retrieve the type parameter list associated with this category or
2218  /// extension.
2219  ObjCTypeParamList *getTypeParamList() const { return TypeParamList; }
2220 
2221  /// Set the type parameters of this category.
2222  ///
2223  /// This function is used by the AST importer, which must import the type
2224  /// parameters after creating their DeclContext to avoid loops.
2226 
2227 
2230 
2231  /// setProtocolList - Set the list of protocols that this interface
2232  /// implements.
2233  void setProtocolList(ObjCProtocolDecl *const*List, unsigned Num,
2234  const SourceLocation *Locs, ASTContext &C) {
2235  ReferencedProtocols.set(List, Num, Locs, C);
2236  }
2237 
2239  return ReferencedProtocols;
2240  }
2241 
2243  typedef llvm::iterator_range<protocol_iterator> protocol_range;
2244 
2247  }
2249  return ReferencedProtocols.begin();
2250  }
2251  protocol_iterator protocol_end() const { return ReferencedProtocols.end(); }
2252  unsigned protocol_size() const { return ReferencedProtocols.size(); }
2254  typedef llvm::iterator_range<protocol_loc_iterator> protocol_loc_range;
2255 
2258  }
2260  return ReferencedProtocols.loc_begin();
2261  }
2263  return ReferencedProtocols.loc_end();
2264  }
2265 
2266  ObjCCategoryDecl *getNextClassCategory() const { return NextClassCategory; }
2267 
2268  /// \brief Retrieve the pointer to the next stored category (or extension),
2269  /// which may be hidden.
2271  return NextClassCategory;
2272  }
2273 
2274  bool IsClassExtension() const { return getIdentifier() == nullptr; }
2275 
2277  typedef llvm::iterator_range<specific_decl_iterator<ObjCIvarDecl>> ivar_range;
2278 
2279  ivar_range ivars() const { return ivar_range(ivar_begin(), ivar_end()); }
2281  return ivar_iterator(decls_begin());
2282  }
2284  return ivar_iterator(decls_end());
2285  }
2286  unsigned ivar_size() const {
2287  return std::distance(ivar_begin(), ivar_end());
2288  }
2289  bool ivar_empty() const {
2290  return ivar_begin() == ivar_end();
2291  }
2292 
2293  SourceLocation getCategoryNameLoc() const { return CategoryNameLoc; }
2294  void setCategoryNameLoc(SourceLocation Loc) { CategoryNameLoc = Loc; }
2295 
2296  void setIvarLBraceLoc(SourceLocation Loc) { IvarLBraceLoc = Loc; }
2297  SourceLocation getIvarLBraceLoc() const { return IvarLBraceLoc; }
2298  void setIvarRBraceLoc(SourceLocation Loc) { IvarRBraceLoc = Loc; }
2299  SourceLocation getIvarRBraceLoc() const { return IvarRBraceLoc; }
2300 
2301  static bool classof(const Decl *D) { return classofKind(D->getKind()); }
2302  static bool classofKind(Kind K) { return K == ObjCCategory; }
2303 
2304  friend class ASTDeclReader;
2305  friend class ASTDeclWriter;
2306 };
2307 
2309  void anchor() override;
2310 
2311  /// Class interface for this class/category implementation
2312  ObjCInterfaceDecl *ClassInterface;
2313 
2314 protected:
2316  ObjCInterfaceDecl *classInterface,
2317  SourceLocation nameLoc, SourceLocation atStartLoc)
2318  : ObjCContainerDecl(DK, DC,
2319  classInterface? classInterface->getIdentifier()
2320  : nullptr,
2321  nameLoc, atStartLoc),
2322  ClassInterface(classInterface) {}
2323 
2324 public:
2325  const ObjCInterfaceDecl *getClassInterface() const { return ClassInterface; }
2326  ObjCInterfaceDecl *getClassInterface() { return ClassInterface; }
2327  void setClassInterface(ObjCInterfaceDecl *IFace);
2328 
2330  // FIXME: Context should be set correctly before we get here.
2331  method->setLexicalDeclContext(this);
2332  addDecl(method);
2333  }
2335  // FIXME: Context should be set correctly before we get here.
2336  method->setLexicalDeclContext(this);
2337  addDecl(method);
2338  }
2339 
2341 
2343  ObjCPropertyQueryKind queryKind) const;
2345 
2346  // Iterator access to properties.
2348  typedef llvm::iterator_range<specific_decl_iterator<ObjCPropertyImplDecl>>
2350 
2353  }
2355  return propimpl_iterator(decls_begin());
2356  }
2358  return propimpl_iterator(decls_end());
2359  }
2360 
2361  static bool classof(const Decl *D) { return classofKind(D->getKind()); }
2362  static bool classofKind(Kind K) {
2363  return K >= firstObjCImpl && K <= lastObjCImpl;
2364  }
2365 };
2366 
2367 /// ObjCCategoryImplDecl - An object of this class encapsulates a category
2368 /// \@implementation declaration. If a category class has declaration of a
2369 /// property, its implementation must be specified in the category's
2370 /// \@implementation declaration. Example:
2371 /// \@interface I \@end
2372 /// \@interface I(CATEGORY)
2373 /// \@property int p1, d1;
2374 /// \@end
2375 /// \@implementation I(CATEGORY)
2376 /// \@dynamic p1,d1;
2377 /// \@end
2378 ///
2379 /// ObjCCategoryImplDecl
2381  void anchor() override;
2382 
2383  // Category name
2384  IdentifierInfo *Id;
2385 
2386  // Category name location
2387  SourceLocation CategoryNameLoc;
2388 
2390  ObjCInterfaceDecl *classInterface,
2391  SourceLocation nameLoc, SourceLocation atStartLoc,
2392  SourceLocation CategoryNameLoc)
2393  : ObjCImplDecl(ObjCCategoryImpl, DC, classInterface, nameLoc, atStartLoc),
2394  Id(Id), CategoryNameLoc(CategoryNameLoc) {}
2395 public:
2397  IdentifierInfo *Id,
2398  ObjCInterfaceDecl *classInterface,
2399  SourceLocation nameLoc,
2400  SourceLocation atStartLoc,
2401  SourceLocation CategoryNameLoc);
2402  static ObjCCategoryImplDecl *CreateDeserialized(ASTContext &C, unsigned ID);
2403 
2404  /// getIdentifier - Get the identifier that names the category
2405  /// interface associated with this implementation.
2406  /// FIXME: This is a bad API, we are hiding NamedDecl::getIdentifier()
2407  /// with a different meaning. For example:
2408  /// ((NamedDecl *)SomeCategoryImplDecl)->getIdentifier()
2409  /// returns the class interface name, whereas
2410  /// ((ObjCCategoryImplDecl *)SomeCategoryImplDecl)->getIdentifier()
2411  /// returns the category name.
2413  return Id;
2414  }
2415  void setIdentifier(IdentifierInfo *II) { Id = II; }
2416 
2418 
2419  SourceLocation getCategoryNameLoc() const { return CategoryNameLoc; }
2420 
2421  /// getName - Get the name of identifier for the class interface associated
2422  /// with this implementation as a StringRef.
2423  //
2424  // FIXME: This is a bad API, we are hiding NamedDecl::getName with a different
2425  // meaning.
2426  StringRef getName() const { return Id ? Id->getName() : StringRef(); }
2427 
2428  /// @brief Get the name of the class associated with this interface.
2429  //
2430  // FIXME: Deprecated, move clients to getName().
2431  std::string getNameAsString() const {
2432  return getName();
2433  }
2434 
2435  static bool classof(const Decl *D) { return classofKind(D->getKind()); }
2436  static bool classofKind(Kind K) { return K == ObjCCategoryImpl;}
2437 
2438  friend class ASTDeclReader;
2439  friend class ASTDeclWriter;
2440 };
2441 
2442 raw_ostream &operator<<(raw_ostream &OS, const ObjCCategoryImplDecl &CID);
2443 
2444 /// ObjCImplementationDecl - Represents a class definition - this is where
2445 /// method definitions are specified. For example:
2446 ///
2447 /// @code
2448 /// \@implementation MyClass
2449 /// - (void)myMethod { /* do something */ }
2450 /// \@end
2451 /// @endcode
2452 ///
2453 /// In a non-fragile runtime, instance variables can appear in the class
2454 /// interface, class extensions (nameless categories), and in the implementation
2455 /// itself, as well as being synthesized as backing storage for properties.
2456 ///
2457 /// In a fragile runtime, instance variables are specified in the class
2458 /// interface, \em not in the implementation. Nevertheless (for legacy reasons),
2459 /// we allow instance variables to be specified in the implementation. When
2460 /// specified, they need to be \em identical to the interface.
2462  void anchor() override;
2463  /// Implementation Class's super class.
2464  ObjCInterfaceDecl *SuperClass;
2465  SourceLocation SuperLoc;
2466 
2467  /// \@implementation may have private ivars.
2468  SourceLocation IvarLBraceLoc;
2469  SourceLocation IvarRBraceLoc;
2470 
2471  /// Support for ivar initialization.
2472  /// \brief The arguments used to initialize the ivars
2473  LazyCXXCtorInitializersPtr IvarInitializers;
2474  unsigned NumIvarInitializers;
2475 
2476  /// Do the ivars of this class require initialization other than
2477  /// zero-initialization?
2478  bool HasNonZeroConstructors : 1;
2479 
2480  /// Do the ivars of this class require non-trivial destruction?
2481  bool HasDestructors : 1;
2482 
2484  ObjCInterfaceDecl *classInterface,
2485  ObjCInterfaceDecl *superDecl,
2486  SourceLocation nameLoc, SourceLocation atStartLoc,
2487  SourceLocation superLoc = SourceLocation(),
2488  SourceLocation IvarLBraceLoc=SourceLocation(),
2489  SourceLocation IvarRBraceLoc=SourceLocation())
2490  : ObjCImplDecl(ObjCImplementation, DC, classInterface, nameLoc, atStartLoc),
2491  SuperClass(superDecl), SuperLoc(superLoc), IvarLBraceLoc(IvarLBraceLoc),
2492  IvarRBraceLoc(IvarRBraceLoc),
2493  IvarInitializers(nullptr), NumIvarInitializers(0),
2494  HasNonZeroConstructors(false), HasDestructors(false) {}
2495 public:
2497  ObjCInterfaceDecl *classInterface,
2498  ObjCInterfaceDecl *superDecl,
2499  SourceLocation nameLoc,
2500  SourceLocation atStartLoc,
2501  SourceLocation superLoc = SourceLocation(),
2502  SourceLocation IvarLBraceLoc=SourceLocation(),
2503  SourceLocation IvarRBraceLoc=SourceLocation());
2504 
2506 
2507  /// init_iterator - Iterates through the ivar initializer list.
2509 
2510  /// init_const_iterator - Iterates through the ivar initializer list.
2512 
2513  typedef llvm::iterator_range<init_iterator> init_range;
2514  typedef llvm::iterator_range<init_const_iterator> init_const_range;
2515 
2518  return init_const_range(init_begin(), init_end());
2519  }
2520 
2521  /// init_begin() - Retrieve an iterator to the first initializer.
2523  const auto *ConstThis = this;
2524  return const_cast<init_iterator>(ConstThis->init_begin());
2525  }
2526  /// begin() - Retrieve an iterator to the first initializer.
2528 
2529  /// init_end() - Retrieve an iterator past the last initializer.
2531  return init_begin() + NumIvarInitializers;
2532  }
2533  /// end() - Retrieve an iterator past the last initializer.
2535  return init_begin() + NumIvarInitializers;
2536  }
2537  /// getNumArgs - Number of ivars which must be initialized.
2538  unsigned getNumIvarInitializers() const {
2539  return NumIvarInitializers;
2540  }
2541 
2542  void setNumIvarInitializers(unsigned numNumIvarInitializers) {
2543  NumIvarInitializers = numNumIvarInitializers;
2544  }
2545 
2547  CXXCtorInitializer ** initializers,
2548  unsigned numInitializers);
2549 
2550  /// Do any of the ivars of this class (not counting its base classes)
2551  /// require construction other than zero-initialization?
2552  bool hasNonZeroConstructors() const { return HasNonZeroConstructors; }
2553  void setHasNonZeroConstructors(bool val) { HasNonZeroConstructors = val; }
2554 
2555  /// Do any of the ivars of this class (not counting its base classes)
2556  /// require non-trivial destruction?
2557  bool hasDestructors() const { return HasDestructors; }
2558  void setHasDestructors(bool val) { HasDestructors = val; }
2559 
2560  /// getIdentifier - Get the identifier that names the class
2561  /// interface associated with this implementation.
2563  return getClassInterface()->getIdentifier();
2564  }
2565 
2566  /// getName - Get the name of identifier for the class interface associated
2567  /// with this implementation as a StringRef.
2568  //
2569  // FIXME: This is a bad API, we are hiding NamedDecl::getName with a different
2570  // meaning.
2571  StringRef getName() const {
2572  assert(getIdentifier() && "Name is not a simple identifier");
2573  return getIdentifier()->getName();
2574  }
2575 
2576  /// @brief Get the name of the class associated with this interface.
2577  //
2578  // FIXME: Move to StringRef API.
2579  std::string getNameAsString() const {
2580  return getName();
2581  }
2582 
2583  /// Produce a name to be used for class's metadata. It comes either via
2584  /// class's objc_runtime_name attribute or class name.
2585  StringRef getObjCRuntimeNameAsString() const;
2586 
2587  const ObjCInterfaceDecl *getSuperClass() const { return SuperClass; }
2588  ObjCInterfaceDecl *getSuperClass() { return SuperClass; }
2589  SourceLocation getSuperClassLoc() const { return SuperLoc; }
2590 
2591  void setSuperClass(ObjCInterfaceDecl * superCls) { SuperClass = superCls; }
2592 
2593  void setIvarLBraceLoc(SourceLocation Loc) { IvarLBraceLoc = Loc; }
2594  SourceLocation getIvarLBraceLoc() const { return IvarLBraceLoc; }
2595  void setIvarRBraceLoc(SourceLocation Loc) { IvarRBraceLoc = Loc; }
2596  SourceLocation getIvarRBraceLoc() const { return IvarRBraceLoc; }
2597 
2599  typedef llvm::iterator_range<specific_decl_iterator<ObjCIvarDecl>> ivar_range;
2600 
2601  ivar_range ivars() const { return ivar_range(ivar_begin(), ivar_end()); }
2603  return ivar_iterator(decls_begin());
2604  }
2606  return ivar_iterator(decls_end());
2607  }
2608  unsigned ivar_size() const {
2609  return std::distance(ivar_begin(), ivar_end());
2610  }
2611  bool ivar_empty() const {
2612  return ivar_begin() == ivar_end();
2613  }
2614 
2615  static bool classof(const Decl *D) { return classofKind(D->getKind()); }
2616  static bool classofKind(Kind K) { return K == ObjCImplementation; }
2617 
2618  friend class ASTDeclReader;
2619  friend class ASTDeclWriter;
2620 };
2621 
2622 raw_ostream &operator<<(raw_ostream &OS, const ObjCImplementationDecl &ID);
2623 
2624 /// ObjCCompatibleAliasDecl - Represents alias of a class. This alias is
2625 /// declared as \@compatibility_alias alias class.
2627  void anchor() override;
2628  /// Class that this is an alias of.
2629  ObjCInterfaceDecl *AliasedClass;
2630 
2632  ObjCInterfaceDecl* aliasedClass)
2633  : NamedDecl(ObjCCompatibleAlias, DC, L, Id), AliasedClass(aliasedClass) {}
2634 public:
2637  ObjCInterfaceDecl* aliasedClass);
2638 
2640  unsigned ID);
2641 
2642  const ObjCInterfaceDecl *getClassInterface() const { return AliasedClass; }
2643  ObjCInterfaceDecl *getClassInterface() { return AliasedClass; }
2644  void setClassInterface(ObjCInterfaceDecl *D) { AliasedClass = D; }
2645 
2646  static bool classof(const Decl *D) { return classofKind(D->getKind()); }
2647  static bool classofKind(Kind K) { return K == ObjCCompatibleAlias; }
2648 
2649 };
2650 
2651 /// ObjCPropertyImplDecl - Represents implementation declaration of a property
2652 /// in a class or category implementation block. For example:
2653 /// \@synthesize prop1 = ivar1;
2654 ///
2655 class ObjCPropertyImplDecl : public Decl {
2656 public:
2657  enum Kind {
2660  };
2661 private:
2662  SourceLocation AtLoc; // location of \@synthesize or \@dynamic
2663 
2664  /// \brief For \@synthesize, the location of the ivar, if it was written in
2665  /// the source code.
2666  ///
2667  /// \code
2668  /// \@synthesize int a = b
2669  /// \endcode
2670  SourceLocation IvarLoc;
2671 
2672  /// Property declaration being implemented
2673  ObjCPropertyDecl *PropertyDecl;
2674 
2675  /// Null for \@dynamic. Required for \@synthesize.
2676  ObjCIvarDecl *PropertyIvarDecl;
2677 
2678  /// Null for \@dynamic. Non-null if property must be copy-constructed in
2679  /// getter.
2680  Expr *GetterCXXConstructor;
2681 
2682  /// Null for \@dynamic. Non-null if property has assignment operator to call
2683  /// in Setter synthesis.
2684  Expr *SetterCXXAssignment;
2685 
2687  ObjCPropertyDecl *property,
2688  Kind PK,
2689  ObjCIvarDecl *ivarDecl,
2690  SourceLocation ivarLoc)
2691  : Decl(ObjCPropertyImpl, DC, L), AtLoc(atLoc),
2692  IvarLoc(ivarLoc), PropertyDecl(property), PropertyIvarDecl(ivarDecl),
2693  GetterCXXConstructor(nullptr), SetterCXXAssignment(nullptr) {
2694  assert (PK == Dynamic || PropertyIvarDecl);
2695  }
2696 
2697 public:
2698  static ObjCPropertyImplDecl *Create(ASTContext &C, DeclContext *DC,
2699  SourceLocation atLoc, SourceLocation L,
2700  ObjCPropertyDecl *property,
2701  Kind PK,
2702  ObjCIvarDecl *ivarDecl,
2703  SourceLocation ivarLoc);
2704 
2705  static ObjCPropertyImplDecl *CreateDeserialized(ASTContext &C, unsigned ID);
2706 
2707  SourceRange getSourceRange() const override LLVM_READONLY;
2708 
2709  SourceLocation getLocStart() const LLVM_READONLY { return AtLoc; }
2710  void setAtLoc(SourceLocation Loc) { AtLoc = Loc; }
2711 
2713  return PropertyDecl;
2714  }
2715  void setPropertyDecl(ObjCPropertyDecl *Prop) { PropertyDecl = Prop; }
2716 
2718  return PropertyIvarDecl ? Synthesize : Dynamic;
2719  }
2720 
2722  return PropertyIvarDecl;
2723  }
2724  SourceLocation getPropertyIvarDeclLoc() const { return IvarLoc; }
2725 
2727  SourceLocation IvarLoc) {
2728  PropertyIvarDecl = Ivar;
2729  this->IvarLoc = IvarLoc;
2730  }
2731 
2732  /// \brief For \@synthesize, returns true if an ivar name was explicitly
2733  /// specified.
2734  ///
2735  /// \code
2736  /// \@synthesize int a = b; // true
2737  /// \@synthesize int a; // false
2738  /// \endcode
2739  bool isIvarNameSpecified() const {
2740  return IvarLoc.isValid() && IvarLoc != getLocation();
2741  }
2742 
2744  return GetterCXXConstructor;
2745  }
2746  void setGetterCXXConstructor(Expr *getterCXXConstructor) {
2747  GetterCXXConstructor = getterCXXConstructor;
2748  }
2749 
2751  return SetterCXXAssignment;
2752  }
2753  void setSetterCXXAssignment(Expr *setterCXXAssignment) {
2754  SetterCXXAssignment = setterCXXAssignment;
2755  }
2756 
2757  static bool classof(const Decl *D) { return classofKind(D->getKind()); }
2758  static bool classofKind(Decl::Kind K) { return K == ObjCPropertyImpl; }
2759 
2760  friend class ASTDeclReader;
2761 };
2762 
2763 template<bool (*Filter)(ObjCCategoryDecl *)>
2764 void
2767  while (Current && !Filter(Current))
2768  Current = Current->getNextClassCategoryRaw();
2769 }
2770 
2771 template<bool (*Filter)(ObjCCategoryDecl *)>
2772 inline ObjCInterfaceDecl::filtered_category_iterator<Filter> &
2774  Current = Current->getNextClassCategoryRaw();
2775  findAcceptableCategory();
2776  return *this;
2777 }
2778 
2779 inline bool ObjCInterfaceDecl::isVisibleCategory(ObjCCategoryDecl *Cat) {
2780  return !Cat->isHidden();
2781 }
2782 
2783 inline bool ObjCInterfaceDecl::isVisibleExtension(ObjCCategoryDecl *Cat) {
2784  return Cat->IsClassExtension() && !Cat->isHidden();
2785 }
2786 
2787 inline bool ObjCInterfaceDecl::isKnownExtension(ObjCCategoryDecl *Cat) {
2788  return Cat->IsClassExtension();
2789 }
2790 
2791 } // end namespace clang
2792 #endif
StringRef getObjCRuntimeNameAsString() const
Produce a name to be used for class's metadata.
Definition: DeclObjC.cpp:1465
bool isInstanceProperty() const
Definition: DeclObjC.h:828
ObjCMethodDecl * getCategoryMethod(Selector Sel, bool isInstance) const
Definition: DeclObjC.h:1270
param_const_iterator param_begin() const
Definition: DeclObjC.h:354
void setMethodParams(ASTContext &C, ArrayRef< ParmVarDecl * > Params, ArrayRef< SourceLocation > SelLocs=llvm::None)
Sets the method's parameters and selector source locations.
Definition: DeclObjC.cpp:820
void setCategoryNameLoc(SourceLocation Loc)
Definition: DeclObjC.h:2294
bool hasDefinition() const
Determine whether this class has been defined.
Definition: DeclObjC.h:1440
bool isAtomic() const
isAtomic - Return true if the property is atomic.
Definition: DeclObjC.h:818
For nullary selectors, immediately before the end: "[foo release]" / "-(void)release;" Or with a spac...
ObjCMethodDecl * lookupPrivateClassMethod(const Selector &Sel)
Definition: DeclObjC.h:1763
void setExternallyCompleted()
Indicate that this Objective-C class is complete, but that the external AST source will be responsibl...
Definition: DeclObjC.cpp:1439
llvm::iterator_range< protocol_loc_iterator > protocol_loc_range
Definition: DeclObjC.h:1303
classmeth_iterator classmeth_end() const
Definition: DeclObjC.h:1000
void setEndOfDefinitionLoc(SourceLocation LE)
Definition: DeclObjC.h:1786
IdentifierInfo * getIdentifier() const
getIdentifier - Get the identifier that names the class interface associated with this implementation...
Definition: DeclObjC.h:2562
protocol_range protocols() const
Definition: DeclObjC.h:2025
Smart pointer class that efficiently represents Objective-C method names.
redeclarable_base::redecl_range redecl_range
Definition: DeclObjC.h:1805
A (possibly-)qualified type.
Definition: Type.h:598
static ObjCIvarDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Definition: DeclObjC.cpp:1713
ImplementationControl getImplementationControl() const
Definition: DeclObjC.h:463
static bool classof(const Decl *D)
Definition: DeclObjC.h:495
propimpl_iterator propimpl_begin() const
Definition: DeclObjC.h:2354
visible_categories_iterator visible_categories_end() const
Retrieve an iterator to the end of the visible-categories list.
Definition: DeclObjC.h:1571
ObjCInterfaceDecl * getClassInterface()
Definition: DeclObjC.h:2214
const ObjCInterfaceDecl * isObjCRequiresPropertyDefs() const
isObjCRequiresPropertyDefs - Checks that a class or one of its super classes must not be auto-synthes...
Definition: DeclObjC.cpp:400
ObjCInterfaceDecl * getClassInterface()
Definition: DeclObjC.cpp:1071
void setOverriding(bool isOverriding)
Definition: DeclObjC.h:435
void startDefinition()
Starts the definition of this Objective-C class, taking it from a forward declaration (@class) to a d...
Definition: DeclObjC.cpp:581
redeclarable_base::redecl_iterator redecl_iterator
Definition: DeclObjC.h:1806
ObjCMethodDecl * getCategoryClassMethod(Selector Sel) const
Definition: DeclObjC.cpp:1619
void getOverriddenMethods(SmallVectorImpl< const ObjCMethodDecl * > &Overridden) const
Return overridden methods for the given Method.
Definition: DeclObjC.cpp:1214
void setLParenLoc(SourceLocation L)
Definition: DeclObjC.h:777
static bool classof(const Decl *D)
Definition: DeclObjC.h:893
protocol_iterator protocol_end() const
Definition: DeclObjC.h:2034
ObjCMethodDecl * lookupClassMethod(Selector Sel) const
Definition: DeclObjC.h:2081
IdentifierInfo * getIdentifier() const
getIdentifier - Get the identifier that names this declaration, if there is one.
Definition: Decl.h:232
void gatherDefaultTypeArgs(SmallVectorImpl< QualType > &typeArgs) const
Gather the default set of type arguments to be substituted for these type parameters when dealing wit...
Definition: DeclObjC.cpp:1373
protocol_loc_iterator protocol_loc_end() const
Definition: DeclObjC.h:1319
PropertyControl getPropertyImplementation() const
Definition: DeclObjC.h:870
bool isClassProperty() const
Definition: DeclObjC.h:829
bool isDefined() const
Definition: DeclObjC.h:424
const SourceLocation * loc_iterator
Definition: DeclObjC.h:84
ivar_iterator ivar_end() const
Definition: DeclObjC.h:2283
llvm::DenseMap< std::pair< IdentifierInfo *, unsigned >, ObjCPropertyDecl * > PropertyMap
Definition: DeclObjC.h:1023
bool isThisDeclarationADefinition() const
Determine whether this particular declaration of this class is actually also a definition.
Definition: DeclObjC.h:1435
llvm::iterator_range< protocol_iterator > protocol_range
Definition: DeclObjC.h:2023
CXXCtorInitializer *const * init_const_iterator
init_const_iterator - Iterates through the ivar initializer list.
Definition: DeclObjC.h:2511
instprop_iterator instprop_begin() const
Definition: DeclObjC.h:937
SourceRange getSourceRange() const override LLVM_READONLY
Definition: DeclObjC.cpp:2207
llvm::iterator_range< specific_decl_iterator< ObjCIvarDecl > > ivar_range
Definition: DeclObjC.h:2599
std::const_mem_fun_t< QualType, ParmVarDecl > deref_fun
Definition: DeclObjC.h:384
StringRef P
void setTypeForDecl(const Type *TD) const
Definition: DeclObjC.h:1820
NamedDecl(Kind DK, DeclContext *DC, SourceLocation L, DeclarationName N)
Definition: Decl.h:224
ObjCProtocolList::loc_iterator protocol_loc_iterator
Definition: DeclObjC.h:2040
static ObjCProtocolDecl * Create(ASTContext &C, DeclContext *DC, IdentifierInfo *Id, SourceLocation nameLoc, SourceLocation atStartLoc, ObjCProtocolDecl *PrevDecl)
Definition: DeclObjC.cpp:1785
static bool classofKind(Kind K)
Definition: DeclObjC.h:1053
specific_decl_iterator< ObjCIvarDecl > ivar_iterator
Definition: DeclObjC.h:2276
const ObjCIvarDecl * all_declared_ivar_begin() const
Definition: DeclObjC.h:1388
static ObjCPropertyDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, IdentifierInfo *Id, SourceLocation AtLocation, SourceLocation LParenLocation, QualType T, TypeSourceInfo *TSI, PropertyControl propControl=None)
Definition: DeclObjC.cpp:2160
ObjCInterfaceDecl * getClassInterface()
Definition: DeclObjC.h:2643
void setNumIvarInitializers(unsigned numNumIvarInitializers)
Definition: DeclObjC.h:2542
void ** List
List is an array of pointers to objects that are not owned by this object.
Definition: DeclObjC.h:40
const DiagnosticBuilder & operator<<(const DiagnosticBuilder &DB, const Attr *At)
Definition: Attr.h:198
The base class of the type hierarchy.
Definition: Type.h:1281
ObjCProtocolDecl * lookupNestedProtocol(IdentifierInfo *Name)
Definition: DeclObjC.cpp:641
known_extensions_iterator known_extensions_end() const
Retrieve an iterator to the end of the known-extensions list.
Definition: DeclObjC.h:1675
The parameter is covariant, e.g., X<T> is a subtype of X<U> when the type parameter is covariant and ...
SourceLocation getDeclaratorEndLoc() const
Returns the location where the declarator ends.
Definition: DeclObjC.h:288
ObjCCategoryDecl * getNextClassCategory() const
Definition: DeclObjC.h:2266
llvm::iterator_range< classmeth_iterator > classmeth_range
Definition: DeclObjC.h:992
instmeth_iterator instmeth_begin() const
Definition: DeclObjC.h:982
SourceRange getSourceRange() const override LLVM_READONLY
Definition: DeclObjC.h:1047
protocol_loc_iterator protocol_loc_begin() const
Definition: DeclObjC.h:1308
ObjCMethodDecl * lookupInstanceMethod(Selector Sel) const
Definition: DeclObjC.h:2078
void setPropertyImplementation(PropertyControl pc)
Definition: DeclObjC.h:867
void setPropertyIvarDecl(ObjCIvarDecl *Ivar, SourceLocation IvarLoc)
Definition: DeclObjC.h:2726
static bool classofKind(Kind K)
Definition: DeclObjC.h:2647
A container of type source information.
Definition: Decl.h:62
static ObjCMethodDecl * castFromDeclContext(const DeclContext *DC)
Definition: DeclObjC.h:500
bool isArcWeakrefUnavailable() const
isArcWeakrefUnavailable - Checks for a class or one of its super classes to be incompatible with __we...
Definition: DeclObjC.cpp:390
bool isBlockPointerType() const
Definition: Type.h:5488
void setPropertyAccessor(bool isAccessor)
Definition: DeclObjC.h:422
protocol_range protocols() const
Definition: DeclObjC.h:2245
ObjCProtocolList::iterator protocol_iterator
Definition: DeclObjC.h:2022
Iterates over a filtered subrange of declarations stored in a DeclContext.
Definition: DeclBase.h:1548
static bool classof(const Decl *D)
Definition: DeclObjC.h:2615
float __ovld __cnfn distance(float p0, float p1)
Returns the distance between p0 and p1.
unsigned size() const
Definition: DeclObjC.h:45
void createImplicitParams(ASTContext &Context, const ObjCInterfaceDecl *ID)
createImplicitParams - Used to lazily create the self and cmd implict parameters. ...
Definition: DeclObjC.cpp:1050
static bool classofKind(Decl::Kind K)
Definition: DeclObjC.h:2758
const ObjCPropertyDecl * findPropertyDecl(bool CheckOverrides=true) const
Returns the property associated with this method's selector.
Definition: DeclObjC.cpp:1231
ObjCMethodDecl * getMethod(Selector Sel, bool isInstance, bool AllowHidden=false) const
Definition: DeclObjC.cpp:68
protocol_loc_iterator protocol_loc_begin() const
Definition: DeclObjC.h:2046
ObjCTypeParamVariance getVariance() const
Determine the variance of this type parameter.
Definition: DeclObjC.h:572
static bool classofKind(Kind K)
Definition: DeclObjC.h:597
const Type * getTypeForDecl() const
Definition: DeclObjC.h:1819
void setImplementation(ObjCCategoryImplDecl *ImplD)
Definition: DeclObjC.cpp:1959
visible_categories_range visible_categories() const
Definition: DeclObjC.h:1559
llvm::iterator_range< param_const_iterator > param_const_range
Definition: DeclObjC.h:352
Expr * getSetterCXXAssignment() const
Definition: DeclObjC.h:2750
unsigned getIndex() const
Retrieve the index into its type parameter list.
Definition: DeclObjC.h:585
SourceLocation getIvarRBraceLoc() const
Definition: DeclObjC.h:2299
QualType getUsageType(QualType objectType) const
Retrieve the type of this instance variable when viewed as a member of a specific object type...
Definition: DeclObjC.cpp:1743
SourceLocation getLocStart() const LLVM_READONLY
Definition: DeclObjC.h:291
static bool classof(const Decl *D)
Definition: DeclObjC.h:1902
llvm::DenseMap< const ObjCProtocolDecl *, ObjCPropertyDecl * > ProtocolPropertyMap
Definition: DeclObjC.h:1026
TypeSourceInfo * getSuperClassTInfo() const
Definition: DeclObjC.h:1478
static bool classofKind(Kind K)
Definition: DeclObjC.h:496
ObjCMethodDecl - Represents an instance or class method declaration.
Definition: DeclObjC.h:113
SourceRange getReturnTypeSourceRange() const
Definition: DeclObjC.cpp:1083
bool ClassImplementsProtocol(ObjCProtocolDecl *lProto, bool lookupCategory, bool RHSIsQualifiedID=false)
ClassImplementsProtocol - Checks that 'lProto' protocol has been implemented in IDecl class...
Definition: DeclObjC.cpp:1632
static ObjCPropertyDecl * findPropertyDecl(const DeclContext *DC, const IdentifierInfo *propertyID, ObjCPropertyQueryKind queryKind)
Lookup a property by name in the specified DeclContext.
Definition: DeclObjC.cpp:154
decl_iterator decls_end() const
Definition: DeclBase.h:1455
void setSelfDecl(ImplicitParamDecl *SD)
Definition: DeclObjC.h:407
llvm::iterator_range< protocol_loc_iterator > protocol_loc_range
Definition: DeclObjC.h:2254
void getSelectorLocs(SmallVectorImpl< SourceLocation > &SelLocs) const
Definition: DeclObjC.cpp:814
const ObjCProtocolDecl * getDefinition() const
Retrieve the definition of this protocol, if any.
Definition: DeclObjC.h:2103
unsigned param_size() const
Definition: DeclObjC.h:348
unsigned size() const
Determine the number of type parameters in this list.
Definition: DeclObjC.h:648
ParmVarDecl - Represents a parameter to a function.
Definition: Decl.h:1377
IdentifierInfo * getIdentifier() const
getIdentifier - Get the identifier that names the category interface associated with this implementat...
Definition: DeclObjC.h:2412
QualType getType() const
Definition: DeclObjC.h:781
TypeSourceInfo * getTypeSourceInfo() const
Definition: DeclObjC.h:779
static DeclContext * castToDeclContext(const ObjCMethodDecl *D)
Definition: DeclObjC.h:497
known_categories_iterator known_categories_begin() const
Retrieve an iterator to the beginning of the known-categories list.
Definition: DeclObjC.h:1600
Kind getPropertyImplementation() const
Definition: DeclObjC.h:2717
unsigned ivar_size() const
Definition: DeclObjC.h:1381
ObjCProtocolList::iterator protocol_iterator
Definition: DeclObjC.h:1275
ObjCTypeParamList * getTypeParamListAsWritten() const
Retrieve the type parameters written on this particular declaration of the class. ...
Definition: DeclObjC.h:1224
specific_decl_iterator< ObjCIvarDecl > ivar_iterator
Definition: DeclObjC.h:1362
bool visible_categories_empty() const
Determine whether the visible-categories list is empty.
Definition: DeclObjC.h:1576
Provides common interface for the Decls that can be redeclared.
Definition: Redeclarable.h:27
ObjCProtocolDecl * getCanonicalDecl() override
Retrieves the canonical declaration of this Objective-C protocol.
Definition: DeclObjC.h:2137
param_const_iterator sel_param_end() const
Definition: DeclObjC.h:365
const ObjCInterfaceDecl * getClassInterface() const
Definition: DeclObjC.h:324
One of these records is kept for each identifier that is lexed.
SourceLocation getSelectorStartLoc() const
Definition: DeclObjC.h:297
param_type_iterator param_type_end() const
Definition: DeclObjC.h:391
const ObjCInterfaceDecl * getContainingInterface() const
Return the class interface that this ivar is logically contained in; this is either the interface whe...
Definition: DeclObjC.cpp:1719
Represents a class type in Objective C.
Definition: Type.h:4727
llvm::iterator_range< classprop_iterator > classprop_range
Definition: DeclObjC.h:947
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition: ASTContext.h:92
ObjCPropertyDecl * FindPropertyVisibleInPrimaryClass(IdentifierInfo *PropertyId, ObjCPropertyQueryKind QueryKind) const
FindPropertyVisibleInPrimaryClass - Finds declaration of the property with name 'PropertyId' in the p...
Definition: DeclObjC.cpp:346
ObjCMethodFamily
A family of Objective-C methods.
ObjCIvarDecl * getIvarDecl(IdentifierInfo *Id) const
getIvarDecl - This method looks up an ivar in this ContextDecl.
Definition: DeclObjC.cpp:56
The parameter is contravariant, e.g., X<T> is a subtype of X<U> when the type parameter is covariant ...
protocol_loc_range protocol_locs() const
Definition: DeclObjC.h:2256
void set(T *const *InList, unsigned Elts, ASTContext &Ctx)
Definition: DeclObjC.h:60
protocol_iterator protocol_begin() const
Definition: DeclObjC.h:2248
static SourceLocation getFromRawEncoding(unsigned Encoding)
Turn a raw encoding of a SourceLocation object into a real SourceLocation.
bool isOverriding() const
Whether this method overrides any other in the class hierarchy.
Definition: DeclObjC.h:434
std::string getNameAsString() const
Get the name of the class associated with this interface.
Definition: DeclObjC.h:2579
FieldDecl - An instance of this class is created by Sema::ActOnField to represent a member of a struc...
Definition: Decl.h:2293
void setTypeParamList(ObjCTypeParamList *TPL)
Set the type parameters of this class.
Definition: DeclObjC.cpp:305
ObjCImplDecl(Kind DK, DeclContext *DC, ObjCInterfaceDecl *classInterface, SourceLocation nameLoc, SourceLocation atStartLoc)
Definition: DeclObjC.h:2315
ImplicitParamDecl * getCmdDecl() const
Definition: DeclObjC.h:408
all_protocol_range all_referenced_protocols() const
Definition: DeclObjC.h:1333
redecl_iterator redecls_begin() const
Definition: Redeclarable.h:242
void setSuperClass(TypeSourceInfo *superClass)
Definition: DeclObjC.h:1493
ObjCMethodDecl * getClassMethod(Selector Sel, bool AllowHidden=false) const
Definition: DeclObjC.h:1011
method_range methods() const
Definition: DeclObjC.h:964
static bool classofKind(Kind K)
Definition: DeclObjC.h:894
void setReturnType(QualType T)
Definition: DeclObjC.h:331
void startDefinition()
Starts the definition of this Objective-C protocol.
Definition: DeclObjC.cpp:1845
bool hasSkippedBody() const
True if the method was a definition but its body was skipped.
Definition: DeclObjC.h:449
static bool classof(const Decl *D)
Definition: DeclObjC.h:2757
static bool classof(const Decl *D)
Definition: DeclObjC.h:1934
void setDeclImplementation(ImplementationControl ic)
Definition: DeclObjC.h:460
static ObjCContainerDecl * castFromDeclContext(const DeclContext *DC)
Definition: DeclObjC.h:1061
SourceLocation getCategoryNameLoc() const
Definition: DeclObjC.h:2293
void set(ObjCProtocolDecl *const *InList, unsigned Elts, const SourceLocation *Locs, ASTContext &Ctx)
Definition: DeclObjC.cpp:37
SourceLocation getColonLoc() const
Retrieve the location of the ':' separating the type parameter name from the explicitly-specified bou...
Definition: DeclObjC.h:593
filtered_decl_iterator< ObjCPropertyDecl,&ObjCPropertyDecl::isInstanceProperty > instprop_iterator
Definition: DeclObjC.h:931
bool IsClassExtension() const
Definition: DeclObjC.h:2274
void collectPropertiesToImplement(PropertyMap &PM, PropertyDeclOrder &PO) const override
This routine collects list of properties to be implemented in the class.
Definition: DeclObjC.cpp:370
bool isThisDeclarationADefinition() const
Returns whether this specific method is a definition.
Definition: DeclObjC.h:492
SourceLocation getSelectorLoc(unsigned Index) const
Definition: DeclObjC.h:302
ObjCInterfaceDecl * getNextRedeclaration() const
Definition: Redeclarable.h:134
SelectorLocationsKind
Whether all locations of the selector identifiers are in a "standard" position.
ObjCTypeParamDecl * AlignmentHack
Definition: DeclObjC.h:623
unsigned getNumSelectorLocs() const
Definition: DeclObjC.h:314
static ObjCInterfaceDecl * Create(const ASTContext &C, DeclContext *DC, SourceLocation atLoc, IdentifierInfo *Id, ObjCTypeParamList *typeParamList, ObjCInterfaceDecl *PrevDecl, SourceLocation ClassLoc=SourceLocation(), bool isInternal=false)
Definition: DeclObjC.cpp:1384
void set(void *const *InList, unsigned Elts, ASTContext &Ctx)
Definition: DeclObjC.cpp:27
ObjCContainerDecl - Represents a container for method declarations.
Definition: DeclObjC.h:901
void setAccessControl(AccessControl ac)
Definition: DeclObjC.h:1886
protocol_loc_range protocol_locs() const
Definition: DeclObjC.h:2043
ObjCTypeParamList * getTypeParamList() const
Retrieve the type parameter list associated with this category or extension.
Definition: DeclObjC.h:2219
void setAtLoc(SourceLocation L)
Definition: DeclObjC.h:774
SourceLocation getIvarLBraceLoc() const
Definition: DeclObjC.h:2297
SourceLocation getSuperClassLoc() const
Retrieve the starting location of the superclass.
Definition: DeclObjC.cpp:334
uint32_t Offset
Definition: CacheTokens.cpp:44
static ObjCCategoryDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation AtLoc, SourceLocation ClassNameLoc, SourceLocation CategoryNameLoc, IdentifierInfo *Id, ObjCInterfaceDecl *IDecl, ObjCTypeParamList *typeParamList, SourceLocation IvarLBraceLoc=SourceLocation(), SourceLocation IvarRBraceLoc=SourceLocation())
Definition: DeclObjC.cpp:1921
ObjCMethodFamily getMethodFamily() const
Determines the family of this method.
Definition: DeclObjC.cpp:913
static ObjCPropertyImplDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation atLoc, SourceLocation L, ObjCPropertyDecl *property, Kind PK, ObjCIvarDecl *ivarDecl, SourceLocation ivarLoc)
Definition: DeclObjC.cpp:2188
protocol_iterator protocol_end() const
Definition: DeclObjC.h:2251
SourceRange getSourceRange() const override LLVM_READONLY
Definition: DeclObjC.h:2120
ObjCContainerDecl(Kind DK, DeclContext *DC, IdentifierInfo *Id, SourceLocation nameLoc, SourceLocation atStartLoc)
Definition: DeclObjC.h:911
ObjCPropertyImplDecl * FindPropertyImplIvarDecl(IdentifierInfo *ivarId) const
FindPropertyImplIvarDecl - This method lookup the ivar in the list of properties implemented in this ...
Definition: DeclObjC.cpp:2037
void setSuperClass(ObjCInterfaceDecl *superCls)
Definition: DeclObjC.h:2591
bool hasDesignatedInitializers() const
Returns true if this interface decl contains at least one initializer marked with the 'objc_designate...
Definition: DeclObjC.cpp:1454
static ObjCTypeParamList * create(ASTContext &ctx, SourceLocation lAngleLoc, ArrayRef< ObjCTypeParamDecl * > typeParams, SourceLocation rAngleLoc)
Create a new Objective-C type parameter list.
Definition: DeclObjC.cpp:1362
llvm::iterator_range< init_const_iterator > init_const_range
Definition: DeclObjC.h:2514
Expr * getGetterCXXConstructor() const
Definition: DeclObjC.h:2743
static ObjCAtDefsFieldDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, QualType T, Expr *BW)
Definition: DeclObjC.cpp:1755
const ObjCIvarDecl * getNextIvar() const
Definition: DeclObjC.h:1883
static ObjCCategoryImplDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Definition: DeclObjC.cpp:1992
void setLazyBody(uint64_t Offset)
Definition: DeclObjC.h:486
Selector getSetterName() const
Definition: DeclObjC.h:857
llvm::iterator_range< param_iterator > param_range
Definition: DeclObjC.h:351
void setClassInterface(ObjCInterfaceDecl *D)
Definition: DeclObjC.h:2644
void setIdentifier(IdentifierInfo *II)
Definition: DeclObjC.h:2415
bool isDesignatedInitializerForTheInterface(const ObjCMethodDecl **InitMethod=nullptr) const
Returns true if the method selector resolves to a designated initializer in the class's interface...
Definition: DeclObjC.cpp:772
ObjCProtocolDecl * getDefinition()
Retrieve the definition of this protocol, if any.
Definition: DeclObjC.h:2098
bool declaresSameEntity(const Decl *D1, const Decl *D2)
Determine whether two declarations declare the same entity.
Definition: DeclBase.h:1039
llvm::iterator_range< specific_decl_iterator< ObjCIvarDecl > > ivar_range
Definition: DeclObjC.h:1363
void setAsRedeclaration(const ObjCMethodDecl *PrevMethod)
Definition: DeclObjC.cpp:788
CompoundStmt * getCompoundBody()
Definition: DeclObjC.h:488
bool empty() const
Definition: DeclObjC.h:46
Represents an Objective-C protocol declaration.
Definition: DeclObjC.h:1968
filtered_category_iterator operator++(int)
Definition: DeclObjC.h:1527
ObjCInterfaceDecl * getSuperClass()
Definition: DeclObjC.h:2588
void setProtocolList(ObjCProtocolDecl *const *List, unsigned Num, const SourceLocation *Locs, ASTContext &C)
setProtocolList - Set the list of protocols that this interface implements.
Definition: DeclObjC.h:2067
void addInstanceMethod(ObjCMethodDecl *method)
Definition: DeclObjC.h:2329
Represents an ObjC class declaration.
Definition: DeclObjC.h:1091
SourceLocation getLocEnd() const LLVM_READONLY
Definition: DeclObjC.cpp:907
propimpl_range property_impls() const
Definition: DeclObjC.h:2351
decl_iterator decls_begin() const
Definition: DeclBase.cpp:1206
detail::InMemoryDirectory::const_iterator I
PropertyAttributeKind getPropertyAttributes() const
Definition: DeclObjC.h:792
ObjCInterfaceDecl * getClassInterface()
Definition: DeclObjC.h:2326
known_categories_range known_categories() const
Definition: DeclObjC.h:1593
specific_decl_iterator< ObjCPropertyImplDecl > propimpl_iterator
Definition: DeclObjC.h:2347
CXXCtorInitializer ** init_iterator
init_iterator - Iterates through the ivar initializer list.
Definition: DeclObjC.h:2508
QualType getType() const
Definition: Decl.h:599
const ObjCProtocolDecl * getCanonicalDecl() const
Definition: DeclObjC.h:2138
ObjCMethodDecl * getCanonicalDecl() override
Definition: DeclObjC.cpp:883
specific_decl_iterator< ObjCMethodDecl > method_iterator
Definition: DeclObjC.h:960
bool hasExplicitBound() const
Whether this type parameter has an explicitly-written type bound, e.g., "T : NSView".
Definition: DeclObjC.h:589
SourceLocation getIvarLBraceLoc() const
Definition: DeclObjC.h:2594
ObjCMethodDecl * lookupPrivateMethod(const Selector &Sel, bool Instance=true) const
Lookup a method in the classes implementation hierarchy.
Definition: DeclObjC.cpp:711
SourceLocation getAtStartLoc() const
Definition: DeclObjC.h:1036
void setGetterCXXConstructor(Expr *getterCXXConstructor)
Definition: DeclObjC.h:2746
T *const * iterator
Definition: DeclObjC.h:64
Iterator that walks over the list of categories, filtering out those that do not meet specific criter...
Definition: DeclObjC.h:1503
SourceLocation getAtLoc() const
Definition: DeclObjC.h:773
filtered_category_iterator< isKnownCategory > known_categories_iterator
Iterator that walks over all of the known categories and extensions, including those that are hidden...
Definition: DeclObjC.h:1589
SourceRange getAtEndRange() const
Definition: DeclObjC.h:1040
ObjCPropertyImplDecl - Represents implementation declaration of a property in a class or category imp...
Definition: DeclObjC.h:2655
void setVariadic(bool isVar)
Definition: DeclObjC.h:417
llvm::iterator_range< redecl_iterator > redecl_range
Definition: Redeclarable.h:232
bool isThisDeclarationADefinition() const
Determine whether this particular declaration is also the definition.
Definition: DeclObjC.h:2109
SourceLocation getLocStart() const LLVM_READONLY
Definition: DeclObjC.h:2709
const ParmVarDecl *const * param_const_iterator
Definition: DeclObjC.h:349
visible_categories_iterator visible_categories_begin() const
Retrieve an iterator to the beginning of the visible-categories list.
Definition: DeclObjC.h:1566
llvm::iterator_range< instprop_iterator > instprop_range
Definition: DeclObjC.h:932
method_iterator meth_end() const
Definition: DeclObjC.h:970
CompoundStmt - This represents a group of statements like { stmt stmt }.
Definition: Stmt.h:551
bool isRetaining() const
isRetaining - Return true if the property retains its value.
Definition: DeclObjC.h:823
ObjCProtocolDecl * lookupProtocolNamed(IdentifierInfo *PName)
Definition: DeclObjC.cpp:1805
void setHasDestructors(bool val)
Definition: DeclObjC.h:2558
static ObjCCompatibleAliasDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Definition: DeclObjC.cpp:2149
ObjCPropertyImplDecl * FindPropertyImplDecl(IdentifierInfo *propertyId, ObjCPropertyQueryKind queryKind) const
FindPropertyImplDecl - This method looks up a previous ObjCPropertyImplDecl added to the list of thos...
Definition: DeclObjC.cpp:2050
bool isThisDeclarationADesignatedInitializer() const
Returns true if this specific method declaration is marked with the designated initializer attribute...
Definition: DeclObjC.cpp:767
ObjCProtocolList::loc_iterator protocol_loc_iterator
Definition: DeclObjC.h:2253
ObjCPropertyDecl * FindPropertyDeclaration(const IdentifierInfo *PropertyId, ObjCPropertyQueryKind QueryKind) const
FindPropertyDeclaration - Finds declaration of the property given its name in 'PropertyId' and return...
Definition: DeclObjC.cpp:213
protocol_loc_iterator protocol_loc_begin() const
Definition: DeclObjC.h:2259
ASTContext * Context
ObjCDeclQualifier getObjCDeclQualifier() const
Definition: DeclObjC.h:269
void setTypeParamList(ObjCTypeParamList *TPL)
Set the type parameters of this category.
Definition: DeclObjC.cpp:1963
void setIvarRBraceLoc(SourceLocation Loc)
Definition: DeclObjC.h:2595
const SmallVectorImpl< AnnotatedLine * >::const_iterator End
ivar_range ivars() const
Definition: DeclObjC.h:1365
SourceLocation getSuperClassLoc() const
Definition: DeclObjC.h:2589
filtered_category_iterator< isKnownExtension > known_extensions_iterator
Iterator that walks over all of the known extensions.
Definition: DeclObjC.h:1659
bool isUnarySelector() const
static bool classofKind(Kind K)
Definition: DeclObjC.h:1903
void setNextIvar(ObjCIvarDecl *ivar)
Definition: DeclObjC.h:1884
void setSynthesize(bool synth)
Definition: DeclObjC.h:1894
FieldDecl(Kind DK, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo, Expr *BW, bool Mutable, InClassInitStyle InitStyle)
Definition: Decl.h:2334
filtered_decl_iterator< ObjCPropertyDecl,&ObjCPropertyDecl::isClassProperty > classprop_iterator
Definition: DeclObjC.h:946
visible_extensions_iterator visible_extensions_begin() const
Retrieve an iterator to the beginning of the visible-extensions list.
Definition: DeclObjC.h:1636
void setType(QualType T, TypeSourceInfo *TSI)
Definition: DeclObjC.h:783
bool hasDestructors() const
Do any of the ivars of this class (not counting its base classes) require non-trivial destruction...
Definition: DeclObjC.h:2557
SourceLocation getVarianceLoc() const
Retrieve the location of the variance keyword.
Definition: DeclObjC.h:582
filtered_category_iterator< isVisibleExtension > visible_extensions_iterator
Iterator that walks over all of the visible extensions, skipping any that are known but hidden...
Definition: DeclObjC.h:1624
void setGetterMethodDecl(ObjCMethodDecl *gDecl)
Definition: DeclObjC.h:861
ObjCCategoryDecl * getCategoryListRaw() const
Retrieve the raw pointer to the start of the category/extension list.
Definition: DeclObjC.h:1686
friend class ASTContext
Definition: Type.h:4178
Expr - This represents one expression.
Definition: Expr.h:105
TypedefNameDecl(Kind DK, ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, TypeSourceInfo *TInfo)
Definition: Decl.h:2615
StringRef getName() const
Return the actual identifier string.
StringRef getObjCRuntimeNameAsString() const
Produce a name to be used for class's metadata.
Definition: DeclObjC.cpp:1473
static ObjCMethodDecl * Create(ASTContext &C, SourceLocation beginLoc, SourceLocation endLoc, Selector SelInfo, QualType T, TypeSourceInfo *ReturnTInfo, DeclContext *contextDecl, bool isInstance=true, bool isVariadic=false, bool isPropertyAccessor=false, bool isImplicitlyDeclared=false, bool isDefined=false, ImplementationControl impControl=None, bool HasRelatedResultType=false)
Definition: DeclObjC.cpp:750
static bool classof(const Decl *D)
Definition: DeclObjC.h:2646
unsigned getNumArgs() const
StringRef getObjCRuntimeNameAsString() const
Produce a name to be used for protocol's metadata.
Definition: DeclObjC.cpp:1893
SetterKind getSetterKind() const
getSetterKind - Return the method used for doing assignment in the property setter.
Definition: DeclObjC.h:842
void setSetterMethodDecl(ObjCMethodDecl *gDecl)
Definition: DeclObjC.h:864
static bool classof(const Decl *D)
Definition: DeclObjC.h:2361
ObjCIvarDecl * getPropertyIvarDecl() const
Definition: DeclObjC.h:2721
protocol_iterator protocol_begin() const
Definition: DeclObjC.h:1281
param_iterator param_end()
Definition: DeclObjC.h:361
llvm::iterator_range< visible_categories_iterator > visible_categories_range
Definition: DeclObjC.h:1557
void setAtEndRange(SourceRange atEnd)
Definition: DeclObjC.h:1043
ObjCMethodDecl * lookupInstanceMethod(Selector Sel) const
Lookup an instance method for a given selector.
Definition: DeclObjC.h:1749
prop_iterator prop_end() const
Definition: DeclObjC.h:925
llvm::iterator_range< known_categories_iterator > known_categories_range
Definition: DeclObjC.h:1591
static ObjCTypeParamDecl * Create(ASTContext &ctx, DeclContext *dc, ObjCTypeParamVariance variance, SourceLocation varianceLoc, unsigned index, SourceLocation nameLoc, IdentifierInfo *name, SourceLocation colonLoc, TypeSourceInfo *boundInfo)
Definition: DeclObjC.cpp:1315
bool isFirstDecl() const
True if this is the first declaration in its redeclaration chain.
Definition: Redeclarable.h:163
ObjCMethodDecl * lookupClassMethod(Selector Sel) const
Lookup a class method for a given selector.
Definition: DeclObjC.h:1754
void addClassMethod(ObjCMethodDecl *method)
Definition: DeclObjC.h:2334
ParmVarDecl *const * param_iterator
Definition: DeclObjC.h:350
void setGetterName(Selector Sel)
Definition: DeclObjC.h:855
ImplicitParamDecl * getSelfDecl() const
Definition: DeclObjC.h:406
protocol_iterator protocol_begin() const
Definition: DeclObjC.h:2028
void setDefined(bool isDefined)
Definition: DeclObjC.h:425
classmeth_iterator classmeth_begin() const
Definition: DeclObjC.h:997
ObjCTypeParamDecl * back() const
Definition: DeclObjC.h:666
void setImplementation(ObjCImplementationDecl *ImplD)
Definition: DeclObjC.cpp:1494
void mergeClassExtensionProtocolList(ObjCProtocolDecl *const *List, unsigned Num, ASTContext &C)
mergeClassExtensionProtocolList - Merge class extension's protocol list into the protocol list for th...
Definition: DeclObjC.cpp:410
ObjCIvarDecl * lookupInstanceVariable(IdentifierInfo *IVarName, ObjCInterfaceDecl *&ClassDeclared)
Definition: DeclObjC.cpp:591
bool hasRelatedResultType() const
Determine whether this method has a result type that is related to the message receiver's type...
Definition: DeclObjC.h:276
bool isInstanceMethod() const
Definition: DeclObjC.h:414
static bool classofKind(Kind K)
Definition: DeclObjC.h:2616
SourceLocation getRAngleLoc() const
Definition: DeclObjC.h:674
static bool classof(const Decl *D)
Definition: DeclObjC.h:2435
virtual void collectPropertiesToImplement(PropertyMap &PM, PropertyDeclOrder &PO) const
This routine collects list of properties to be implemented in the class.
Definition: DeclObjC.h:1033
instmeth_iterator instmeth_end() const
Definition: DeclObjC.h:985
void getDesignatedInitializers(llvm::SmallVectorImpl< const ObjCMethodDecl * > &Methods) const
Returns the designated initializers for the interface.
Definition: DeclObjC.cpp:518
DeclarationName getDeclName() const
getDeclName - Get the actual, stored name of the declaration, which may be a special name...
Definition: Decl.h:258
static DeclContext * castToDeclContext(const ObjCContainerDecl *D)
Definition: DeclObjC.h:1058
protocol_loc_range protocol_locs() const
Definition: DeclObjC.h:1305
static bool classof(const Decl *D)
Definition: DeclObjC.h:2146
void setIvarRBraceLoc(SourceLocation Loc)
Definition: DeclObjC.h:2298
llvm::iterator_range< specific_decl_iterator< ObjCPropertyImplDecl > > propimpl_range
Definition: DeclObjC.h:2349
unsigned ivar_size() const
Definition: DeclObjC.h:2608
bool declaresOrInheritsDesignatedInitializers() const
Returns true if this interface decl declares a designated initializer or it inherites one from its su...
Definition: DeclObjC.h:1250
static ObjCTypeParamDecl * CreateDeserialized(ASTContext &ctx, unsigned ID)
Definition: DeclObjC.cpp:1327
ivar_range ivars() const
Definition: DeclObjC.h:2601
llvm::iterator_range< specific_decl_iterator< ObjCPropertyDecl > > prop_range
Definition: DeclObjC.h:919
ObjCMethodDecl * lookupPropertyAccessor(const Selector Sel, const ObjCCategoryDecl *Cat, bool IsClassProperty) const
Lookup a setter or getter in the class hierarchy, including in all categories except for category pas...
Definition: DeclObjC.h:1770
ObjCTypeParamVariance
Describes the variance of a given generic parameter.
Definition: DeclObjC.h:509
void setHasSkippedBody(bool Skipped=true)
Definition: DeclObjC.h:450
bool ivar_empty() const
Definition: DeclObjC.h:2289
static ObjCMethodDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Definition: DeclObjC.cpp:762
init_const_range inits() const
Definition: DeclObjC.h:2517
TypeSourceInfo * getReturnTypeSourceInfo() const
Definition: DeclObjC.h:344
AccessControl getCanonicalAccessControl() const
Definition: DeclObjC.h:1890
ObjCMethodDecl * lookupMethod(Selector Sel, bool isInstance) const
Definition: DeclObjC.cpp:1820
ObjCInterfaceDecl * getFirstDecl()
Return the first declaration of this declaration or itself if this is the only declaration.
Definition: Redeclarable.h:156
init_iterator init_begin()
init_begin() - Retrieve an iterator to the first initializer.
Definition: DeclObjC.h:2522
llvm::iterator_range< specific_decl_iterator< ObjCMethodDecl > > method_range
Definition: DeclObjC.h:962
filtered_category_iterator(ObjCCategoryDecl *Current)
Definition: DeclObjC.h:1516
ivar_iterator ivar_begin() const
Definition: DeclObjC.h:1366
ivar_iterator ivar_begin() const
Definition: DeclObjC.h:2602
ObjCCategoryDecl * getCategoryDecl() const
Definition: DeclObjC.cpp:1999
param_const_iterator param_end() const
Definition: DeclObjC.h:357
filtered_decl_iterator< ObjCMethodDecl,&ObjCMethodDecl::isClassMethod > classmeth_iterator
Definition: DeclObjC.h:991
void setBody(Stmt *B)
Definition: DeclObjC.h:489
bool isClassMethod() const
Definition: DeclObjC.h:419
PODSourceRange Brackets
Location of the left and right angle brackets.
Definition: DeclObjC.h:620
ArrayRef< ParmVarDecl * > parameters() const
Definition: DeclObjC.h:371
ivar_iterator ivar_end() const
Definition: DeclObjC.h:2605
const ObjCMethodDecl * getCanonicalDecl() const
Definition: DeclObjC.h:265
T * operator[](unsigned Idx) const
Definition: DeclObjC.h:68
static ObjCCompatibleAliasDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, IdentifierInfo *Id, ObjCInterfaceDecl *aliasedClass)
Definition: DeclObjC.cpp:2141
redecl_range redecls() const
Returns an iterator range for all the redeclarations of the same decl.
Definition: Redeclarable.h:236
#define false
Definition: stdbool.h:33
static ObjCProtocolDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Definition: DeclObjC.cpp:1796
QualType getSelfType(ASTContext &Context, const ObjCInterfaceDecl *OID, bool &selfIsPseudoStrong, bool &selfIsConsumed)
Definition: DeclObjC.cpp:1005
Kind
filtered_decl_iterator< ObjCMethodDecl,&ObjCMethodDecl::isInstanceMethod > instmeth_iterator
Definition: DeclObjC.h:976
ObjCInterfaceDecl * getPreviousDecl()
Return the previous declaration of this declaration or NULL if this is the first declaration.
Definition: Redeclarable.h:144
bool isDesignatedInitializer(Selector Sel, const ObjCMethodDecl **InitMethod=nullptr) const
Returns true if the given selector is a designated initializer for the interface. ...
Definition: DeclObjC.cpp:540
QualType getUsageType(QualType objectType) const
Retrieve the type when this property is used with a specific base object type.
Definition: DeclObjC.cpp:2179
Encodes a location in the source.
llvm::iterator_range< protocol_iterator > protocol_range
Definition: DeclObjC.h:1276
unsigned protocol_size() const
Definition: DeclObjC.h:2252
bool visible_extensions_empty() const
Determine whether the visible-extensions list is empty.
Definition: DeclObjC.h:1646
classprop_iterator classprop_begin() const
Definition: DeclObjC.h:952
ObjCPropertyQueryKind
Definition: DeclObjC.h:687
StringRef getName() const
getName - Get the name of identifier for the class interface associated with this implementation as a...
Definition: DeclObjC.h:2571
llvm::iterator_range< init_iterator > init_range
Definition: DeclObjC.h:2513
void setIvarLBraceLoc(SourceLocation Loc)
Definition: DeclObjC.h:2296
bool isRedeclaration() const
True if this is a method redeclaration in the same interface.
Definition: DeclObjC.h:282
const ObjCInterfaceDecl * getClassInterface() const
Definition: DeclObjC.h:2642
void setAtStartLoc(SourceLocation Loc)
Definition: DeclObjC.h:1037
ivar_iterator ivar_end() const
Definition: DeclObjC.h:1373
static bool classof(const Decl *D)
Definition: DeclObjC.h:1052
bool isValid() const
Return true if this is a valid SourceLocation object.
const std::string ID
void setObjCDeclQualifier(ObjCDeclQualifier QV)
Definition: DeclObjC.h:272
redeclarable_base::redecl_iterator redecl_iterator
Definition: DeclObjC.h:2128
ObjCList - This is a simple template class used to hold various lists of decls etc, which is heavily used by the ObjC front-end.
Definition: DeclObjC.h:58
void setPropertyAttributesAsWritten(PropertyAttributeKind PRVal)
Definition: DeclObjC.h:806
bool isVariadic() const
Definition: DeclObjC.h:416
ObjCCategoryDecl * getNextClassCategoryRaw() const
Retrieve the pointer to the next stored category (or extension), which may be hidden.
Definition: DeclObjC.h:2270
Stmt * getBody() const override
Retrieve the body of this method, if it has one.
Definition: DeclObjC.cpp:784
ivar_iterator ivar_begin() const
Definition: DeclObjC.h:2280
bool getSynthesize() const
Definition: DeclObjC.h:1895
void setProtocolList(ObjCProtocolDecl *const *List, unsigned Num, const SourceLocation *Locs, ASTContext &C)
setProtocolList - Set the list of protocols that this interface implements.
Definition: DeclObjC.h:1397
all_protocol_iterator all_referenced_protocol_end() const
Definition: DeclObjC.h:1349
const_iterator begin() const
Definition: DeclObjC.h:653
ObjCInterfaceDecl * lookupInheritedClass(const IdentifierInfo *ICName)
lookupInheritedClass - This method returns ObjCInterfaceDecl * of the super class whose name is passe...
Definition: DeclObjC.cpp:622
ObjCCategoryDecl - Represents a category declaration.
Definition: DeclObjC.h:2171
const ObjCInterfaceDecl * getClassInterface() const
Definition: DeclObjC.h:2325
llvm::iterator_range< instmeth_iterator > instmeth_range
Definition: DeclObjC.h:977
bool isPropertyAccessor() const
Definition: DeclObjC.h:421
init_iterator init_end()
init_end() - Retrieve an iterator past the last initializer.
Definition: DeclObjC.h:2530
Represents one property declaration in an Objective-C interface.
Definition: DeclObjC.h:699
void setProtocolList(ObjCProtocolDecl *const *List, unsigned Num, const SourceLocation *Locs, ASTContext &C)
setProtocolList - Set the list of protocols that this interface implements.
Definition: DeclObjC.h:2233
filtered_category_iterator< isVisibleCategory > visible_categories_iterator
Iterator that walks over the list of categories and extensions that are visible, i.e., not hidden in a non-imported submodule.
Definition: DeclObjC.h:1554
ObjCTypeParamDecl ** iterator
Iterate through the type parameters in the list.
Definition: DeclObjC.h:641
void collectInheritedProtocolProperties(const ObjCPropertyDecl *Property, ProtocolPropertyMap &PM) const
Definition: DeclObjC.cpp:1871
Number of bits fitting all the property attributes.
Definition: DeclObjC.h:726
loc_iterator loc_begin() const
Definition: DeclObjC.h:85
QualType getReturnType() const
Definition: DeclObjC.h:330
const T * castAs() const
Member-template castAs<specific type>.
Definition: Type.h:5849
llvm::iterator_range< specific_decl_iterator< ObjCIvarDecl > > ivar_range
Definition: DeclObjC.h:2277
llvm::iterator_range< all_protocol_iterator > all_protocol_range
Definition: DeclObjC.h:1331
prop_iterator prop_begin() const
Definition: DeclObjC.h:922
Indicates that the nullability of the type was spelled with a property attribute rather than a type q...
Definition: DeclObjC.h:718
const ObjCInterfaceDecl * getDefinition() const
Retrieve the definition of this class, or NULL if this class has been forward-declared (with @class) ...
Definition: DeclObjC.h:1461
ObjCTypeParamDecl *const * const_iterator
Definition: DeclObjC.h:651
SourceLocation getLAngleLoc() const
Definition: DeclObjC.h:671
SourceRange getSourceRange() const override LLVM_READONLY
Definition: DeclObjC.h:293
SourceLocation getCategoryNameLoc() const
Definition: DeclObjC.h:2419
__PTRDIFF_TYPE__ ptrdiff_t
A signed integer type that is the result of subtracting two pointers.
Definition: opencl-c.h:61
SourceLocation getLParenLoc() const
Definition: DeclObjC.h:776
specific_decl_iterator< ObjCPropertyDecl > prop_iterator
Definition: DeclObjC.h:917
llvm::SmallVector< ObjCPropertyDecl *, 8 > PropertyDeclOrder
Definition: DeclObjC.h:1028
void setSetterCXXAssignment(Expr *setterCXXAssignment)
Definition: DeclObjC.h:2753
ObjCIvarDecl * getNextIvar()
Definition: DeclObjC.h:1882
bool isSuperClassOf(const ObjCInterfaceDecl *I) const
isSuperClassOf - Return true if this class is the specified class or is a super class of the specifie...
Definition: DeclObjC.h:1712
known_extensions_iterator known_extensions_begin() const
Retrieve an iterator to the beginning of the known-extensions list.
Definition: DeclObjC.h:1670
Base class for declarations which introduce a typedef-name.
Definition: Decl.h:2609
void setPropertyDecl(ObjCPropertyDecl *Prop)
Definition: DeclObjC.h:2715
const ObjCProtocolList & getReferencedProtocols() const
Definition: DeclObjC.h:2018
ObjCProtocolList::loc_iterator protocol_loc_iterator
Definition: DeclObjC.h:1302
instmeth_range instance_methods() const
Definition: DeclObjC.h:979
static bool classofKind(Kind K)
Definition: DeclObjC.h:2147
Selector getObjCSelector() const
getObjCSelector - Get the Objective-C selector stored in this declaration name.
param_iterator param_begin()
Definition: DeclObjC.h:360
ObjCCategoryDecl * FindCategoryDeclaration(IdentifierInfo *CategoryId) const
FindCategoryDeclaration - Finds category declaration in the list of categories for this class and ret...
Definition: DeclObjC.cpp:1593
static bool classofKind(Kind K)
Definition: DeclObjC.h:2362
bool HasUserDeclaredSetterMethod(const ObjCPropertyDecl *P) const
This routine returns 'true' if a user declared setter method was found in the class, its protocols, its super classes or categories.
Definition: DeclObjC.cpp:101
static bool classof(const Decl *D)
Definition: DeclObjC.h:2301
ObjCCategoryImplDecl * getImplementation() const
Definition: DeclObjC.cpp:1954
SourceRange getSourceRange() const override LLVM_READONLY
Definition: DeclObjC.cpp:1335
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
Definition: DeclBase.h:1135
protocol_loc_iterator protocol_loc_end() const
Definition: DeclObjC.h:2052
prop_range properties() const
Definition: DeclObjC.h:921
std::string getNameAsString() const
Get the name of the class associated with this interface.
Definition: DeclObjC.h:2431
ObjCIvarDecl * getPropertyIvarDecl() const
Definition: DeclObjC.h:877
ObjCMethodDecl * getInstanceMethod(Selector Sel, bool AllowHidden=false) const
Definition: DeclObjC.h:1007
SourceRange getSourceRange() const override LLVM_READONLY
Definition: DeclObjC.h:881
protocol_loc_iterator protocol_loc_end() const
Definition: DeclObjC.h:2262
bool isValid() const
Whether this pointer is non-NULL.
Reads an AST files chain containing the contents of a translation unit.
Definition: ASTReader.h:312
ObjCInterfaceDecl * getDefinition()
Retrieve the definition of this class, or NULL if this class has been forward-declared (with @class) ...
Definition: DeclObjC.h:1454
void setIvarList(ObjCIvarDecl *ivar)
Definition: DeclObjC.h:1393
SourceLocation getPropertyIvarDeclLoc() const
Definition: DeclObjC.h:2724
filtered_category_iterator & operator++()
Definition: DeclObjC.h:2773
Represents the declaration of an Objective-C type parameter.
Definition: DeclObjC.h:532
specific_decl_iterator< ObjCIvarDecl > ivar_iterator
Definition: DeclObjC.h:2598
Selector getGetterName() const
Definition: DeclObjC.h:854
bool hasDefinition() const
Determine whether this protocol has a definition.
Definition: DeclObjC.h:2086
static ObjCImplementationDecl * Create(ASTContext &C, DeclContext *DC, ObjCInterfaceDecl *classInterface, ObjCInterfaceDecl *superDecl, SourceLocation nameLoc, SourceLocation atStartLoc, SourceLocation superLoc=SourceLocation(), SourceLocation IvarLBraceLoc=SourceLocation(), SourceLocation IvarRBraceLoc=SourceLocation())
Definition: DeclObjC.cpp:2089
ivar_range ivars() const
Definition: DeclObjC.h:2279
init_const_iterator init_end() const
end() - Retrieve an iterator past the last initializer.
Definition: DeclObjC.h:2534
static ObjCCategoryDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Definition: DeclObjC.cpp:1947
unsigned NumElts
Definition: DeclObjC.h:41
loc_iterator loc_end() const
Definition: DeclObjC.h:86
Selector getSelector() const
Definition: DeclObjC.h:328
friend bool operator!=(filtered_category_iterator X, filtered_category_iterator Y)
Definition: DeclObjC.h:1538
static bool classofKind(Kind K)
Definition: DeclObjC.h:2302
ObjCTypeParamDecl * front() const
Definition: DeclObjC.h:661
SourceLocation getEndOfDefinitionLoc() const
Definition: DeclObjC.h:1779
iterator begin() const
Definition: DeclObjC.h:65
ObjCMethodDecl * getCategoryInstanceMethod(Selector Sel) const
Definition: DeclObjC.cpp:1609
instprop_iterator instprop_end() const
Definition: DeclObjC.h:940
specific_decl_iterator - Iterates over a subrange of declarations stored in a DeclContext, providing only those that are of type SpecificDecl (or a class derived from it).
Definition: DeclBase.h:1473
visible_extensions_iterator visible_extensions_end() const
Retrieve an iterator to the end of the visible-extensions list.
Definition: DeclObjC.h:1641
known_extensions_range known_extensions() const
Definition: DeclObjC.h:1663
static ObjCIvarDecl * Create(ASTContext &C, ObjCContainerDecl *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo, AccessControl ac, Expr *BW=nullptr, bool synthesized=false)
Definition: DeclObjC.cpp:1677
static ObjCAtDefsFieldDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Definition: DeclObjC.cpp:1761
ObjCImplementationDecl - Represents a class definition - this is where method definitions are specifi...
Definition: DeclObjC.h:2461
friend class ASTContext
Definition: DeclObjC.h:1098
ObjCMethodDecl * getGetterMethodDecl() const
Definition: DeclObjC.h:860
bool hasNonZeroConstructors() const
Do any of the ivars of this class (not counting its base classes) require construction other than zer...
Definition: DeclObjC.h:2552
ObjCMethodDecl * lookupMethod(Selector Sel, bool isInstance, bool shallowCategoryLookup=false, bool followSuper=true, const ObjCCategoryDecl *C=nullptr) const
lookupMethod - This method returns an instance/class method by looking in the class, its categories, and its super classes (using a linear search).
Definition: DeclObjC.cpp:653
bool known_extensions_empty() const
Determine whether the known-extensions list is empty.
Definition: DeclObjC.h:1680
void setHasNonZeroConstructors(bool val)
Definition: DeclObjC.h:2553
void overwritePropertyAttributes(unsigned PRVal)
Definition: DeclObjC.h:798
ObjCTypeParamList * getTypeParamList() const
Retrieve the type parameters of this class.
Definition: DeclObjC.cpp:285
Represents a C++ base or member initializer.
Definition: DeclCXX.h:1922
unsigned ivar_size() const
Definition: DeclObjC.h:2286
ObjCMethodDecl * getSetterMethodDecl() const
Definition: DeclObjC.h:863
SourceLocation getStandardSelectorLoc(unsigned Index, Selector Sel, bool WithArgSpace, ArrayRef< Expr * > Args, SourceLocation EndLoc)
Get the "standard" location of a selector identifier, e.g: For nullary selectors, immediately before ']': "[foo release]".
friend TrailingObjects
Definition: OpenMPClause.h:258
instprop_range instance_properties() const
Definition: DeclObjC.h:934
SourceRange getSourceRange() const override LLVM_READONLY
Definition: DeclObjC.h:1228
ObjCProtocolList::iterator protocol_iterator
Definition: DeclObjC.h:2242
friend bool operator==(filtered_category_iterator X, filtered_category_iterator Y)
Definition: DeclObjC.h:1533
bool hasBody() const override
Determine whether this method has a body.
Definition: DeclObjC.h:481
llvm::iterator_range< protocol_iterator > protocol_range
Definition: DeclObjC.h:2243
void setSetterName(Selector Sel)
Definition: DeclObjC.h:858
ObjCInterfaceDecl * getCanonicalDecl() override
Retrieves the canonical declaration of this Objective-C class.
Definition: DeclObjC.h:1815
A list of Objective-C protocols, along with the source locations at which they were referenced...
Definition: DeclObjC.h:76
const ObjCProtocolList & getReferencedProtocols() const
Definition: DeclObjC.h:1254
void setCategoryListRaw(ObjCCategoryDecl *category)
Set the raw pointer to the start of the category/extension list.
Definition: DeclObjC.h:1699
unsigned protocol_size() const
Definition: DeclObjC.h:2058
protocol_range protocols() const
Definition: DeclObjC.h:1278
ObjCImplementationDecl * getImplementation() const
Definition: DeclObjC.cpp:1481
void addDecl(Decl *D)
Add the declaration D into this context.
Definition: DeclBase.cpp:1296
protocol_iterator protocol_end() const
Definition: DeclObjC.h:1291
const ObjCInterfaceDecl * getClassInterface() const
Definition: DeclObjC.h:2215
X
Add a minimal nested name specifier fixit hint to allow lookup of a tag name from an outer enclosing ...
Definition: SemaDecl.cpp:12171
ObjCPropertyDecl * getPropertyDecl() const
Definition: DeclObjC.h:2712
AccessControl getAccessControl() const
Definition: DeclObjC.h:1888
classmeth_range class_methods() const
Definition: DeclObjC.h:994
static bool classofKind(Kind K)
Definition: DeclObjC.h:1935
llvm::iterator_range< known_extensions_iterator > known_extensions_range
Definition: DeclObjC.h:1661
Represents a field declaration created by an @defs(...).
Definition: DeclObjC.h:1916
bool isImplicitInterfaceDecl() const
isImplicitInterfaceDecl - check that this is an implicitly declared ObjCInterfaceDecl node...
Definition: DeclObjC.h:1794
known_categories_iterator known_categories_end() const
Retrieve an iterator to the end of the known-categories list.
Definition: DeclObjC.h:1605
FormatToken * Current
classprop_range class_properties() const
Definition: DeclObjC.h:949
void setIvarInitializers(ASTContext &C, CXXCtorInitializer **initializers, unsigned numInitializers)
Definition: DeclObjC.cpp:2110
llvm::iterator_range< protocol_loc_iterator > protocol_loc_range
Definition: DeclObjC.h:2041
StringRef getName() const
getName - Get the name of identifier for the class interface associated with this implementation as a...
Definition: DeclObjC.h:2426
bool isReadOnly() const
isReadOnly - Return true iff the property has a setter.
Definition: DeclObjC.h:813
static ObjCImplementationDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Definition: DeclObjC.cpp:2105
ObjCIvarDecl * lookupInstanceVariable(IdentifierInfo *IVarName)
Definition: DeclObjC.h:1734
void setInstanceMethod(bool isInst)
Definition: DeclObjC.h:415
void SetRelatedResultType(bool RRT=true)
Note whether this method has a related result type.
Definition: DeclObjC.h:279
method_iterator meth_begin() const
Definition: DeclObjC.h:967
all_protocol_iterator all_referenced_protocol_begin() const
Definition: DeclObjC.h:1337
void setClassInterface(ObjCInterfaceDecl *IFace)
Definition: DeclObjC.cpp:2015
ObjCIvarDecl - Represents an ObjC instance variable.
Definition: DeclObjC.h:1849
llvm::mapped_iterator< param_const_iterator, deref_fun > param_type_iterator
Definition: DeclObjC.h:386
ObjCPropertyQueryKind getQueryKind() const
Definition: DeclObjC.h:830
void setReturnTypeSourceInfo(TypeSourceInfo *TInfo)
Definition: DeclObjC.h:345
void setIvarLBraceLoc(SourceLocation Loc)
Definition: DeclObjC.h:2593
Stores a list of Objective-C type parameters for a parameterized class or a category/extension thereo...
Definition: DeclObjC.h:610
void setPropertyAttributes(PropertyAttributeKind PRVal)
Definition: DeclObjC.h:795
static bool classofKind(Kind K)
Definition: DeclObjC.h:2436
ObjCInterfaceDecl * getSuperClass() const
Definition: DeclObjC.cpp:314
PropertyAttributeKind getPropertyAttributesAsWritten() const
Definition: DeclObjC.h:802
static ObjCPropertyQueryKind getQueryKind(bool isClassProperty)
Definition: DeclObjC.h:834
QualType getSendResultType() const
Determine the type of an expression that sends a message to this function.
Definition: DeclObjC.cpp:1090
SourceLocation getIvarRBraceLoc() const
Definition: DeclObjC.h:2596
ObjCInterfaceDecl * getMostRecentDecl()
Returns the most recent (re)declaration of this declaration.
Definition: Redeclarable.h:166
bool ivar_empty() const
Definition: DeclObjC.h:1385
static ObjCInterfaceDecl * CreateDeserialized(const ASTContext &C, unsigned ID)
Definition: DeclObjC.cpp:1400
For nullary selectors, immediately before the end: "[foo release]" / "-(void)release;" Or immediately...
bool isIvarNameSpecified() const
For @synthesize, returns true if an ivar name was explicitly specified.
Definition: DeclObjC.h:2739
static ObjCPropertyImplDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Definition: DeclObjC.cpp:2200
void addPropertyImplementation(ObjCPropertyImplDecl *property)
Definition: DeclObjC.cpp:2009
void setAtLoc(SourceLocation Loc)
Definition: DeclObjC.h:2710
#define true
Definition: stdbool.h:32
const ObjCInterfaceDecl * getCanonicalDecl() const
Definition: DeclObjC.h:1816
ObjCList< ObjCProtocolDecl >::iterator all_protocol_iterator
Definition: DeclObjC.h:1330
static bool classof(const Decl *D)
Definition: DeclObjC.h:1822
A trivial tuple used to represent a source range.
propimpl_iterator propimpl_end() const
Definition: DeclObjC.h:2357
NamedDecl - This represents a decl with a name.
Definition: Decl.h:213
ObjCIvarDecl * all_declared_ivar_begin()
all_declared_ivar_begin - return first ivar declared in this class, its extensions and its implementa...
Definition: DeclObjC.cpp:1521
static bool classof(const Decl *D)
Definition: DeclObjC.h:596
bool known_categories_empty() const
Determine whether the known-categories list is empty.
Definition: DeclObjC.h:1610
SourceRange getSourceRange() const
Definition: DeclObjC.h:677
static ObjCCategoryImplDecl * Create(ASTContext &C, DeclContext *DC, IdentifierInfo *Id, ObjCInterfaceDecl *classInterface, SourceLocation nameLoc, SourceLocation atStartLoc, SourceLocation CategoryNameLoc)
Definition: DeclObjC.cpp:1980
void setVariance(ObjCTypeParamVariance variance)
Set the variance of this type parameter.
Definition: DeclObjC.h:577
classprop_iterator classprop_end() const
Definition: DeclObjC.h:955
static bool classofKind(Kind K)
Definition: DeclObjC.h:1823
redeclarable_base::redecl_range redecl_range
Definition: DeclObjC.h:2127
static ObjCPropertyDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Definition: DeclObjC.cpp:2172
llvm::iterator_range< visible_extensions_iterator > visible_extensions_range
Definition: DeclObjC.h:1627
void setHasDesignatedInitializers()
Indicate that this interface decl contains at least one initializer marked with the 'objc_designated_...
Definition: DeclObjC.cpp:1447
IdentifierInfo * getDefaultSynthIvarName(ASTContext &Ctx) const
Get the default name of the synthesized ivar.
Definition: DeclObjC.cpp:202
void collectPropertiesToImplement(PropertyMap &PM, PropertyDeclOrder &PO) const override
This routine collects list of properties to be implemented in the class.
Definition: DeclObjC.cpp:1853
void setCmdDecl(ImplicitParamDecl *CD)
Definition: DeclObjC.h:409
ObjCCategoryImplDecl - An object of this class encapsulates a category @implementation declaration...
Definition: DeclObjC.h:2380
No in-class initializer.
Definition: Specifiers.h:225
The parameter is invariant: must match exactly.
const ObjCObjectType * getSuperClassType() const
Retrieve the superclass type.
Definition: DeclObjC.h:1470
visible_extensions_range visible_extensions() const
Definition: DeclObjC.h:1629
iterator end() const
Definition: DeclObjC.h:66
void setPropertyIvarDecl(ObjCIvarDecl *Ivar)
Definition: DeclObjC.h:874
const_iterator end() const
Definition: DeclObjC.h:657
DeclContext(Decl::Kind K)
Definition: DeclBase.h:1197
ObjCCompatibleAliasDecl - Represents alias of a class.
Definition: DeclObjC.h:2626
unsigned getNumIvarInitializers() const
getNumArgs - Number of ivars which must be initialized.
Definition: DeclObjC.h:2538
const ObjCProtocolList & getReferencedProtocols() const
Definition: DeclObjC.h:2238
bool isHidden() const
Determine whether this declaration is hidden from name lookup.
Definition: Decl.h:305
param_type_iterator param_type_begin() const
Definition: DeclObjC.h:388
const ObjCInterfaceDecl * getSuperClass() const
Definition: DeclObjC.h:2587