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