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