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