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