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