clang 20.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
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);
619
620 SourceRange getSourceRange() const override LLVM_READONLY;
621
622 /// Determine the variance of this type parameter.
624 return static_cast<ObjCTypeParamVariance>(Variance);
625 }
626
627 /// Set the variance of this type parameter.
629 Variance = static_cast<unsigned>(variance);
630 }
631
632 /// Retrieve the location of the variance keyword.
633 SourceLocation getVarianceLoc() const { return VarianceLoc; }
634
635 /// Retrieve the index into its type parameter list.
636 unsigned getIndex() const { return Index; }
637
638 /// Whether this type parameter has an explicitly-written type bound, e.g.,
639 /// "T : NSView".
640 bool hasExplicitBound() const { return ColonLoc.isValid(); }
641
642 /// Retrieve the location of the ':' separating the type parameter name
643 /// from the explicitly-specified bound.
644 SourceLocation getColonLoc() const { return ColonLoc; }
645
646 // Implement isa/cast/dyncast/etc.
647 static bool classof(const Decl *D) { return classofKind(D->getKind()); }
648 static bool classofKind(Kind K) { return K == ObjCTypeParam; }
649};
650
651/// Stores a list of Objective-C type parameters for a parameterized class
652/// or a category/extension thereof.
653///
654/// \code
655/// @interface NSArray<T> // stores the <T>
656/// @end
657/// \endcode
659 : private llvm::TrailingObjects<ObjCTypeParamList, ObjCTypeParamDecl *> {
660 /// Location of the left and right angle brackets.
661 SourceRange Brackets;
662 /// The number of parameters in the list, which are tail-allocated.
663 unsigned NumParams;
664
667 SourceLocation rAngleLoc);
668
669public:
671
672 /// Create a new Objective-C type parameter list.
674 SourceLocation lAngleLoc,
676 SourceLocation rAngleLoc);
677
678 /// Iterate through the type parameters in the list.
680
681 iterator begin() { return getTrailingObjects<ObjCTypeParamDecl *>(); }
682
683 iterator end() { return begin() + size(); }
684
685 /// Determine the number of type parameters in this list.
686 unsigned size() const { return NumParams; }
687
688 // Iterate through the type parameters in the list.
690
692 return getTrailingObjects<ObjCTypeParamDecl *>();
693 }
694
696 return begin() + size();
697 }
698
700 assert(size() > 0 && "empty Objective-C type parameter list");
701 return *begin();
702 }
703
705 assert(size() > 0 && "empty Objective-C type parameter list");
706 return *(end() - 1);
707 }
708
709 SourceLocation getLAngleLoc() const { return Brackets.getBegin(); }
710 SourceLocation getRAngleLoc() const { return Brackets.getEnd(); }
711 SourceRange getSourceRange() const { return Brackets; }
712
713 /// Gather the default set of type arguments to be substituted for
714 /// these type parameters when dealing with an unspecialized type.
716};
717
718enum class ObjCPropertyQueryKind : uint8_t {
722};
723
724/// Represents one property declaration in an Objective-C interface.
725///
726/// For example:
727/// \code{.mm}
728/// \@property (assign, readwrite) int MyProperty;
729/// \endcode
731 void anchor() override;
732
733public:
736
737private:
738 // location of \@property
739 SourceLocation AtLoc;
740
741 // location of '(' starting attribute list or null.
742 SourceLocation LParenLoc;
743
744 QualType DeclType;
745 TypeSourceInfo *DeclTypeSourceInfo;
746 LLVM_PREFERRED_TYPE(ObjCPropertyAttribute::Kind)
747 unsigned PropertyAttributes : NumObjCPropertyAttrsBits;
748 LLVM_PREFERRED_TYPE(ObjCPropertyAttribute::Kind)
749 unsigned PropertyAttributesAsWritten : NumObjCPropertyAttrsBits;
750
751 // \@required/\@optional
752 LLVM_PREFERRED_TYPE(PropertyControl)
753 unsigned PropertyImplementation : 2;
754
755 // getter name of NULL if no getter
756 Selector GetterName;
757
758 // setter name of NULL if no setter
759 Selector SetterName;
760
761 // location of the getter attribute's value
762 SourceLocation GetterNameLoc;
763
764 // location of the setter attribute's value
765 SourceLocation SetterNameLoc;
766
767 // Declaration of getter instance method
768 ObjCMethodDecl *GetterMethodDecl = nullptr;
769
770 // Declaration of setter instance method
771 ObjCMethodDecl *SetterMethodDecl = nullptr;
772
773 // Synthesize ivar for this property
774 ObjCIvarDecl *PropertyIvarDecl = nullptr;
775
777 SourceLocation AtLocation, SourceLocation LParenLocation,
778 QualType T, TypeSourceInfo *TSI, PropertyControl propControl)
779 : NamedDecl(ObjCProperty, DC, L, Id), AtLoc(AtLocation),
780 LParenLoc(LParenLocation), DeclType(T), DeclTypeSourceInfo(TSI),
781 PropertyAttributes(ObjCPropertyAttribute::kind_noattr),
782 PropertyAttributesAsWritten(ObjCPropertyAttribute::kind_noattr),
783 PropertyImplementation(propControl) {}
784
785public:
786 static ObjCPropertyDecl *Create(ASTContext &C, DeclContext *DC,
787 SourceLocation L, const IdentifierInfo *Id,
788 SourceLocation AtLocation,
789 SourceLocation LParenLocation, QualType T,
790 TypeSourceInfo *TSI,
791 PropertyControl propControl = None);
792
793 static ObjCPropertyDecl *CreateDeserialized(ASTContext &C, GlobalDeclID ID);
794
795 SourceLocation getAtLoc() const { return AtLoc; }
796 void setAtLoc(SourceLocation L) { AtLoc = L; }
797
798 SourceLocation getLParenLoc() const { return LParenLoc; }
799 void setLParenLoc(SourceLocation L) { LParenLoc = L; }
800
801 TypeSourceInfo *getTypeSourceInfo() const { return DeclTypeSourceInfo; }
802
803 QualType getType() const { return DeclType; }
804
806 DeclType = T;
807 DeclTypeSourceInfo = TSI;
808 }
809
810 /// Retrieve the type when this property is used with a specific base object
811 /// type.
812 QualType getUsageType(QualType objectType) const;
813
815 return ObjCPropertyAttribute::Kind(PropertyAttributes);
816 }
817
819 PropertyAttributes |= PRVal;
820 }
821
822 void overwritePropertyAttributes(unsigned PRVal) {
823 PropertyAttributes = PRVal;
824 }
825
827 return ObjCPropertyAttribute::Kind(PropertyAttributesAsWritten);
828 }
829
831 PropertyAttributesAsWritten = PRVal;
832 }
833
834 // Helper methods for accessing attributes.
835
836 /// isReadOnly - Return true iff the property has a setter.
837 bool isReadOnly() const {
838 return (PropertyAttributes & ObjCPropertyAttribute::kind_readonly);
839 }
840
841 /// isAtomic - Return true if the property is atomic.
842 bool isAtomic() const {
843 return (PropertyAttributes & ObjCPropertyAttribute::kind_atomic);
844 }
845
846 /// isRetaining - Return true if the property retains its value.
847 bool isRetaining() const {
848 return (PropertyAttributes & (ObjCPropertyAttribute::kind_retain |
851 }
852
853 bool isInstanceProperty() const { return !isClassProperty(); }
854 bool isClassProperty() const {
855 return PropertyAttributes & ObjCPropertyAttribute::kind_class;
856 }
857 bool isDirectProperty() const;
858
862 }
863
867 }
868
869 /// getSetterKind - Return the method used for doing assignment in
870 /// the property setter. This is only valid if the property has been
871 /// defined to have a setter.
873 if (PropertyAttributes & ObjCPropertyAttribute::kind_strong)
874 return getType()->isBlockPointerType() ? Copy : Retain;
875 if (PropertyAttributes & ObjCPropertyAttribute::kind_retain)
876 return Retain;
877 if (PropertyAttributes & ObjCPropertyAttribute::kind_copy)
878 return Copy;
879 if (PropertyAttributes & ObjCPropertyAttribute::kind_weak)
880 return Weak;
881 return Assign;
882 }
883
884 Selector getGetterName() const { return GetterName; }
885 SourceLocation getGetterNameLoc() const { return GetterNameLoc; }
886
888 GetterName = Sel;
889 GetterNameLoc = Loc;
890 }
891
892 Selector getSetterName() const { return SetterName; }
893 SourceLocation getSetterNameLoc() const { return SetterNameLoc; }
894
896 SetterName = Sel;
897 SetterNameLoc = Loc;
898 }
899
900 ObjCMethodDecl *getGetterMethodDecl() const { return GetterMethodDecl; }
901 void setGetterMethodDecl(ObjCMethodDecl *gDecl) { GetterMethodDecl = gDecl; }
902
903 ObjCMethodDecl *getSetterMethodDecl() const { return SetterMethodDecl; }
904 void setSetterMethodDecl(ObjCMethodDecl *gDecl) { SetterMethodDecl = gDecl; }
905
906 // Related to \@optional/\@required declared in \@protocol
908 PropertyImplementation = pc;
909 }
910
912 return PropertyControl(PropertyImplementation);
913 }
914
915 bool isOptional() const {
917 }
918
920 PropertyIvarDecl = Ivar;
921 }
922
924 return PropertyIvarDecl;
925 }
926
927 SourceRange getSourceRange() const override LLVM_READONLY {
928 return SourceRange(AtLoc, getLocation());
929 }
930
931 /// Get the default name of the synthesized ivar.
933
934 /// Lookup a property by name in the specified DeclContext.
936 const IdentifierInfo *propertyID,
937 ObjCPropertyQueryKind queryKind);
938
939 static bool classof(const Decl *D) { return classofKind(D->getKind()); }
940 static bool classofKind(Kind K) { return K == ObjCProperty; }
941};
942
943/// ObjCContainerDecl - Represents a container for method declarations.
944/// Current sub-classes are ObjCInterfaceDecl, ObjCCategoryDecl,
945/// ObjCProtocolDecl, and ObjCImplDecl.
946///
948 // This class stores some data in DeclContext::ObjCContainerDeclBits
949 // to save some space. Use the provided accessors to access it.
950
951 // These two locations in the range mark the end of the method container.
952 // The first points to the '@' token, and the second to the 'end' token.
953 SourceRange AtEnd;
954
955 void anchor() override;
956
957public:
959 SourceLocation nameLoc, SourceLocation atStartLoc);
960
961 // Iterator access to instance/class properties.
964 llvm::iterator_range<specific_decl_iterator<ObjCPropertyDecl>>;
965
967
969 return prop_iterator(decls_begin());
970 }
971
973 return prop_iterator(decls_end());
974 }
975
979 using instprop_range = llvm::iterator_range<instprop_iterator>;
980
983 }
984
987 }
988
991 }
992
996 using classprop_range = llvm::iterator_range<classprop_iterator>;
997
1000 }
1001
1004 }
1005
1007 return classprop_iterator(decls_end());
1008 }
1009
1010 // Iterator access to instance/class methods.
1013 llvm::iterator_range<specific_decl_iterator<ObjCMethodDecl>>;
1014
1016 return method_range(meth_begin(), meth_end());
1017 }
1018
1020 return method_iterator(decls_begin());
1021 }
1022
1024 return method_iterator(decls_end());
1025 }
1026
1030 using instmeth_range = llvm::iterator_range<instmeth_iterator>;
1031
1034 }
1035
1038 }
1039
1041 return instmeth_iterator(decls_end());
1042 }
1043
1047 using classmeth_range = llvm::iterator_range<classmeth_iterator>;
1048
1051 }
1052
1055 }
1056
1058 return classmeth_iterator(decls_end());
1059 }
1060
1061 // Get the local instance/class method declared in this interface.
1062 ObjCMethodDecl *getMethod(Selector Sel, bool isInstance,
1063 bool AllowHidden = false) const;
1064
1066 bool AllowHidden = false) const {
1067 return getMethod(Sel, true/*isInstance*/, AllowHidden);
1068 }
1069
1070 ObjCMethodDecl *getClassMethod(Selector Sel, bool AllowHidden = false) const {
1071 return getMethod(Sel, false/*isInstance*/, AllowHidden);
1072 }
1073
1076
1078 bool IsInstance) const;
1079
1081 FindPropertyDeclaration(const IdentifierInfo *PropertyId,
1082 ObjCPropertyQueryKind QueryKind) const;
1083
1085 llvm::MapVector<std::pair<IdentifierInfo *, unsigned /*isClassProperty*/>,
1087 using ProtocolPropertySet = llvm::SmallDenseSet<const ObjCProtocolDecl *, 8>;
1089
1090 /// This routine collects list of properties to be implemented in the class.
1091 /// This includes, class's and its conforming protocols' properties.
1092 /// Note, the superclass's properties are not included in the list.
1094
1096
1098 ObjCContainerDeclBits.AtStart = Loc;
1099 }
1100
1101 // Marks the end of the container.
1102 SourceRange getAtEndRange() const { return AtEnd; }
1103
1104 void setAtEndRange(SourceRange atEnd) { AtEnd = atEnd; }
1105
1106 SourceRange getSourceRange() const override LLVM_READONLY {
1107 return SourceRange(getAtStartLoc(), getAtEndRange().getEnd());
1108 }
1109
1110 // Implement isa/cast/dyncast/etc.
1111 static bool classof(const Decl *D) { return classofKind(D->getKind()); }
1112
1113 static bool classofKind(Kind K) {
1114 return K >= firstObjCContainer &&
1115 K <= lastObjCContainer;
1116 }
1117
1119 return static_cast<DeclContext *>(const_cast<ObjCContainerDecl*>(D));
1120 }
1121
1123 return static_cast<ObjCContainerDecl *>(const_cast<DeclContext*>(DC));
1124 }
1125};
1126
1127/// Represents an ObjC class declaration.
1128///
1129/// For example:
1130///
1131/// \code
1132/// // MostPrimitive declares no super class (not particularly useful).
1133/// \@interface MostPrimitive
1134/// // no instance variables or methods.
1135/// \@end
1136///
1137/// // NSResponder inherits from NSObject & implements NSCoding (a protocol).
1138/// \@interface NSResponder : NSObject <NSCoding>
1139/// { // instance variables are represented by ObjCIvarDecl.
1140/// id nextResponder; // nextResponder instance variable.
1141/// }
1142/// - (NSResponder *)nextResponder; // return a pointer to NSResponder.
1143/// - (void)mouseMoved:(NSEvent *)theEvent; // return void, takes a pointer
1144/// \@end // to an NSEvent.
1145/// \endcode
1146///
1147/// Unlike C/C++, forward class declarations are accomplished with \@class.
1148/// Unlike C/C++, \@class allows for a list of classes to be forward declared.
1149/// Unlike C++, ObjC is a single-rooted class model. In Cocoa, classes
1150/// typically inherit from NSObject (an exception is NSProxy).
1151///
1153 , public Redeclarable<ObjCInterfaceDecl> {
1154 friend class ASTContext;
1155 friend class ODRDiagsEmitter;
1156
1157 /// TypeForDecl - This indicates the Type object that represents this
1158 /// TypeDecl. It is a cache maintained by ASTContext::getObjCInterfaceType
1159 mutable const Type *TypeForDecl = nullptr;
1160
1161 struct DefinitionData {
1162 /// The definition of this class, for quick access from any
1163 /// declaration.
1164 ObjCInterfaceDecl *Definition = nullptr;
1165
1166 /// When non-null, this is always an ObjCObjectType.
1167 TypeSourceInfo *SuperClassTInfo = nullptr;
1168
1169 /// Protocols referenced in the \@interface declaration
1170 ObjCProtocolList ReferencedProtocols;
1171
1172 /// Protocols reference in both the \@interface and class extensions.
1173 ObjCList<ObjCProtocolDecl> AllReferencedProtocols;
1174
1175 /// List of categories and class extensions defined for this class.
1176 ///
1177 /// Categories are stored as a linked list in the AST, since the categories
1178 /// and class extensions come long after the initial interface declaration,
1179 /// and we avoid dynamically-resized arrays in the AST wherever possible.
1180 ObjCCategoryDecl *CategoryList = nullptr;
1181
1182 /// IvarList - List of all ivars defined by this class; including class
1183 /// extensions and implementation. This list is built lazily.
1184 ObjCIvarDecl *IvarList = nullptr;
1185
1186 /// Indicates that the contents of this Objective-C class will be
1187 /// completed by the external AST source when required.
1188 LLVM_PREFERRED_TYPE(bool)
1189 mutable unsigned ExternallyCompleted : 1;
1190
1191 /// Indicates that the ivar cache does not yet include ivars
1192 /// declared in the implementation.
1193 LLVM_PREFERRED_TYPE(bool)
1194 mutable unsigned IvarListMissingImplementation : 1;
1195
1196 /// Indicates that this interface decl contains at least one initializer
1197 /// marked with the 'objc_designated_initializer' attribute.
1198 LLVM_PREFERRED_TYPE(bool)
1199 unsigned HasDesignatedInitializers : 1;
1200
1201 enum InheritedDesignatedInitializersState {
1202 /// We didn't calculate whether the designated initializers should be
1203 /// inherited or not.
1204 IDI_Unknown = 0,
1205
1206 /// Designated initializers are inherited for the super class.
1207 IDI_Inherited = 1,
1208
1209 /// The class does not inherit designated initializers.
1210 IDI_NotInherited = 2
1211 };
1212
1213 /// One of the \c InheritedDesignatedInitializersState enumeratos.
1214 LLVM_PREFERRED_TYPE(InheritedDesignatedInitializersState)
1215 mutable unsigned InheritedDesignatedInitializers : 2;
1216
1217 /// Tracks whether a ODR hash has been computed for this interface.
1218 LLVM_PREFERRED_TYPE(bool)
1219 unsigned HasODRHash : 1;
1220
1221 /// A hash of parts of the class to help in ODR checking.
1222 unsigned ODRHash = 0;
1223
1224 /// The location of the last location in this declaration, before
1225 /// the properties/methods. For example, this will be the '>', '}', or
1226 /// identifier,
1227 SourceLocation EndLoc;
1228
1229 DefinitionData()
1230 : ExternallyCompleted(false), IvarListMissingImplementation(true),
1231 HasDesignatedInitializers(false),
1232 InheritedDesignatedInitializers(IDI_Unknown), HasODRHash(false) {}
1233 };
1234
1235 /// The type parameters associated with this class, if any.
1236 ObjCTypeParamList *TypeParamList = nullptr;
1237
1238 /// Contains a pointer to the data associated with this class,
1239 /// which will be NULL if this class has not yet been defined.
1240 ///
1241 /// The bit indicates when we don't need to check for out-of-date
1242 /// declarations. It will be set unless modules are enabled.
1243 llvm::PointerIntPair<DefinitionData *, 1, bool> Data;
1244
1245 ObjCInterfaceDecl(const ASTContext &C, DeclContext *DC, SourceLocation AtLoc,
1246 const IdentifierInfo *Id, ObjCTypeParamList *typeParamList,
1247 SourceLocation CLoc, ObjCInterfaceDecl *PrevDecl,
1248 bool IsInternal);
1249
1250 void anchor() override;
1251
1252 void LoadExternalDefinition() const;
1253
1254 DefinitionData &data() const {
1255 assert(Data.getPointer() && "Declaration has no definition!");
1256 return *Data.getPointer();
1257 }
1258
1259 /// Allocate the definition data for this class.
1260 void allocateDefinitionData();
1261
1262 using redeclarable_base = Redeclarable<ObjCInterfaceDecl>;
1263
1264 ObjCInterfaceDecl *getNextRedeclarationImpl() override {
1265 return getNextRedeclaration();
1266 }
1267
1268 ObjCInterfaceDecl *getPreviousDeclImpl() override {
1269 return getPreviousDecl();
1270 }
1271
1272 ObjCInterfaceDecl *getMostRecentDeclImpl() override {
1273 return getMostRecentDecl();
1274 }
1275
1276public:
1277 static ObjCInterfaceDecl *
1278 Create(const ASTContext &C, DeclContext *DC, SourceLocation atLoc,
1279 const IdentifierInfo *Id, ObjCTypeParamList *typeParamList,
1280 ObjCInterfaceDecl *PrevDecl,
1281 SourceLocation ClassLoc = SourceLocation(), bool isInternal = false);
1282
1283 static ObjCInterfaceDecl *CreateDeserialized(const ASTContext &C,
1284 GlobalDeclID ID);
1285
1286 /// Retrieve the type parameters of this class.
1287 ///
1288 /// This function looks for a type parameter list for the given
1289 /// class; if the class has been declared (with \c \@class) but not
1290 /// defined (with \c \@interface), it will search for a declaration that
1291 /// has type parameters, skipping any declarations that do not.
1292 ObjCTypeParamList *getTypeParamList() const;
1293
1294 /// Set the type parameters of this class.
1295 ///
1296 /// This function is used by the AST importer, which must import the type
1297 /// parameters after creating their DeclContext to avoid loops.
1298 void setTypeParamList(ObjCTypeParamList *TPL);
1299
1300 /// Retrieve the type parameters written on this particular declaration of
1301 /// the class.
1303 return TypeParamList;
1304 }
1305
1306 SourceRange getSourceRange() const override LLVM_READONLY {
1309
1311 }
1312
1313 /// Indicate that this Objective-C class is complete, but that
1314 /// the external AST source will be responsible for filling in its contents
1315 /// when a complete class is required.
1317
1318 /// Indicate that this interface decl contains at least one initializer
1319 /// marked with the 'objc_designated_initializer' attribute.
1321
1322 /// Returns true if this interface decl contains at least one initializer
1323 /// marked with the 'objc_designated_initializer' attribute.
1324 bool hasDesignatedInitializers() const;
1325
1326 /// Returns true if this interface decl declares a designated initializer
1327 /// or it inherites one from its super class.
1329 return hasDesignatedInitializers() || inheritsDesignatedInitializers();
1330 }
1331
1333 assert(hasDefinition() && "Caller did not check for forward reference!");
1334 if (data().ExternallyCompleted)
1335 LoadExternalDefinition();
1336
1337 return data().ReferencedProtocols;
1338 }
1339
1342
1344 FindCategoryDeclaration(const IdentifierInfo *CategoryId) const;
1345
1346 // Get the local instance/class method declared in a category.
1349
1350 ObjCMethodDecl *getCategoryMethod(Selector Sel, bool isInstance) const {
1351 return isInstance ? getCategoryInstanceMethod(Sel)
1353 }
1354
1356 using protocol_range = llvm::iterator_range<protocol_iterator>;
1357
1360 }
1361
1363 // FIXME: Should make sure no callers ever do this.
1364 if (!hasDefinition())
1365 return protocol_iterator();
1366
1367 if (data().ExternallyCompleted)
1368 LoadExternalDefinition();
1369
1370 return data().ReferencedProtocols.begin();
1371 }
1372
1374 // FIXME: Should make sure no callers ever do this.
1375 if (!hasDefinition())
1376 return protocol_iterator();
1377
1378 if (data().ExternallyCompleted)
1379 LoadExternalDefinition();
1380
1381 return data().ReferencedProtocols.end();
1382 }
1383
1385 using protocol_loc_range = llvm::iterator_range<protocol_loc_iterator>;
1386
1389 }
1390
1392 // FIXME: Should make sure no callers ever do this.
1393 if (!hasDefinition())
1394 return protocol_loc_iterator();
1395
1396 if (data().ExternallyCompleted)
1397 LoadExternalDefinition();
1398
1399 return data().ReferencedProtocols.loc_begin();
1400 }
1401
1403 // FIXME: Should make sure no callers ever do this.
1404 if (!hasDefinition())
1405 return protocol_loc_iterator();
1406
1407 if (data().ExternallyCompleted)
1408 LoadExternalDefinition();
1409
1410 return data().ReferencedProtocols.loc_end();
1411 }
1412
1414 using all_protocol_range = llvm::iterator_range<all_protocol_iterator>;
1415
1419 }
1420
1422 // FIXME: Should make sure no callers ever do this.
1423 if (!hasDefinition())
1424 return all_protocol_iterator();
1425
1426 if (data().ExternallyCompleted)
1427 LoadExternalDefinition();
1428
1429 return data().AllReferencedProtocols.empty()
1430 ? protocol_begin()
1431 : data().AllReferencedProtocols.begin();
1432 }
1433
1435 // FIXME: Should make sure no callers ever do this.
1436 if (!hasDefinition())
1437 return all_protocol_iterator();
1438
1439 if (data().ExternallyCompleted)
1440 LoadExternalDefinition();
1441
1442 return data().AllReferencedProtocols.empty()
1443 ? protocol_end()
1444 : data().AllReferencedProtocols.end();
1445 }
1446
1448 using ivar_range = llvm::iterator_range<specific_decl_iterator<ObjCIvarDecl>>;
1449
1451
1453 if (const ObjCInterfaceDecl *Def = getDefinition())
1454 return ivar_iterator(Def->decls_begin());
1455
1456 // FIXME: Should make sure no callers ever do this.
1457 return ivar_iterator();
1458 }
1459
1461 if (const ObjCInterfaceDecl *Def = getDefinition())
1462 return ivar_iterator(Def->decls_end());
1463
1464 // FIXME: Should make sure no callers ever do this.
1465 return ivar_iterator();
1466 }
1467
1468 unsigned ivar_size() const {
1469 return std::distance(ivar_begin(), ivar_end());
1470 }
1471
1472 bool ivar_empty() const { return ivar_begin() == ivar_end(); }
1473
1476 // Even though this modifies IvarList, it's conceptually const:
1477 // the ivar chain is essentially a cached property of ObjCInterfaceDecl.
1478 return const_cast<ObjCInterfaceDecl *>(this)->all_declared_ivar_begin();
1479 }
1480 void setIvarList(ObjCIvarDecl *ivar) { data().IvarList = ivar; }
1481
1482 /// setProtocolList - Set the list of protocols that this interface
1483 /// implements.
1484 void setProtocolList(ObjCProtocolDecl *const* List, unsigned Num,
1485 const SourceLocation *Locs, ASTContext &C) {
1486 data().ReferencedProtocols.set(List, Num, Locs, C);
1487 }
1488
1489 /// mergeClassExtensionProtocolList - Merge class extension's protocol list
1490 /// into the protocol list for this class.
1492 unsigned Num,
1493 ASTContext &C);
1494
1495 /// Produce a name to be used for class's metadata. It comes either via
1496 /// objc_runtime_name attribute or class name.
1497 StringRef getObjCRuntimeNameAsString() const;
1498
1499 /// Returns the designated initializers for the interface.
1500 ///
1501 /// If this declaration does not have methods marked as designated
1502 /// initializers then the interface inherits the designated initializers of
1503 /// its super class.
1506
1507 /// Returns true if the given selector is a designated initializer for the
1508 /// interface.
1509 ///
1510 /// If this declaration does not have methods marked as designated
1511 /// initializers then the interface inherits the designated initializers of
1512 /// its super class.
1513 ///
1514 /// \param InitMethod if non-null and the function returns true, it receives
1515 /// the method that was marked as a designated initializer.
1516 bool
1518 const ObjCMethodDecl **InitMethod = nullptr) const;
1519
1520 /// Determine whether this particular declaration of this class is
1521 /// actually also a definition.
1523 return getDefinition() == this;
1524 }
1525
1526 /// Determine whether this class has been defined.
1527 bool hasDefinition() const {
1528 // If the name of this class is out-of-date, bring it up-to-date, which
1529 // might bring in a definition.
1530 // Note: a null value indicates that we don't have a definition and that
1531 // modules are enabled.
1532 if (!Data.getOpaqueValue())
1534
1535 return Data.getPointer();
1536 }
1537
1538 /// Retrieve the definition of this class, or NULL if this class
1539 /// has been forward-declared (with \@class) but not yet defined (with
1540 /// \@interface).
1542 return hasDefinition()? Data.getPointer()->Definition : nullptr;
1543 }
1544
1545 /// Retrieve the definition of this class, or NULL if this class
1546 /// has been forward-declared (with \@class) but not yet defined (with
1547 /// \@interface).
1549 return hasDefinition()? Data.getPointer()->Definition : nullptr;
1550 }
1551
1552 /// Starts the definition of this Objective-C class, taking it from
1553 /// a forward declaration (\@class) to a definition (\@interface).
1554 void startDefinition();
1555
1556 /// Starts the definition without sharing it with other redeclarations.
1557 /// Such definition shouldn't be used for anything but only to compare if
1558 /// a duplicate is compatible with previous definition or if it is
1559 /// a distinct duplicate.
1562
1563 /// Retrieve the superclass type.
1565 if (TypeSourceInfo *TInfo = getSuperClassTInfo())
1566 return TInfo->getType()->castAs<ObjCObjectType>();
1567
1568 return nullptr;
1569 }
1570
1571 // Retrieve the type source information for the superclass.
1573 // FIXME: Should make sure no callers ever do this.
1574 if (!hasDefinition())
1575 return nullptr;
1576
1577 if (data().ExternallyCompleted)
1578 LoadExternalDefinition();
1579
1580 return data().SuperClassTInfo;
1581 }
1582
1583 // Retrieve the declaration for the superclass of this class, which
1584 // does not include any type arguments that apply to the superclass.
1586
1587 void setSuperClass(TypeSourceInfo *superClass) {
1588 data().SuperClassTInfo = superClass;
1589 }
1590
1591 /// Iterator that walks over the list of categories, filtering out
1592 /// those that do not meet specific criteria.
1593 ///
1594 /// This class template is used for the various permutations of category
1595 /// and extension iterators.
1596 template<bool (*Filter)(ObjCCategoryDecl *)>
1598 ObjCCategoryDecl *Current = nullptr;
1599
1600 void findAcceptableCategory();
1601
1602 public:
1606 using difference_type = std::ptrdiff_t;
1607 using iterator_category = std::input_iterator_tag;
1608
1611 : Current(Current) {
1612 findAcceptableCategory();
1613 }
1614
1615 reference operator*() const { return Current; }
1616 pointer operator->() const { return Current; }
1617
1619
1621 filtered_category_iterator Tmp = *this;
1622 ++(*this);
1623 return Tmp;
1624 }
1625
1628 return X.Current == Y.Current;
1629 }
1630
1633 return X.Current != Y.Current;
1634 }
1635 };
1636
1637private:
1638 /// Test whether the given category is visible.
1639 ///
1640 /// Used in the \c visible_categories_iterator.
1641 static bool isVisibleCategory(ObjCCategoryDecl *Cat);
1642
1643public:
1644 /// Iterator that walks over the list of categories and extensions
1645 /// that are visible, i.e., not hidden in a non-imported submodule.
1648
1650 llvm::iterator_range<visible_categories_iterator>;
1651
1655 }
1656
1657 /// Retrieve an iterator to the beginning of the visible-categories
1658 /// list.
1661 }
1662
1663 /// Retrieve an iterator to the end of the visible-categories list.
1666 }
1667
1668 /// Determine whether the visible-categories list is empty.
1671 }
1672
1673private:
1674 /// Test whether the given category... is a category.
1675 ///
1676 /// Used in the \c known_categories_iterator.
1677 static bool isKnownCategory(ObjCCategoryDecl *) { return true; }
1678
1679public:
1680 /// Iterator that walks over all of the known categories and
1681 /// extensions, including those that are hidden.
1684 llvm::iterator_range<known_categories_iterator>;
1685
1689 }
1690
1691 /// Retrieve an iterator to the beginning of the known-categories
1692 /// list.
1695 }
1696
1697 /// Retrieve an iterator to the end of the known-categories list.
1700 }
1701
1702 /// Determine whether the known-categories list is empty.
1705 }
1706
1707private:
1708 /// Test whether the given category is a visible extension.
1709 ///
1710 /// Used in the \c visible_extensions_iterator.
1711 static bool isVisibleExtension(ObjCCategoryDecl *Cat);
1712
1713public:
1714 /// Iterator that walks over all of the visible extensions, skipping
1715 /// any that are known but hidden.
1718
1720 llvm::iterator_range<visible_extensions_iterator>;
1721
1725 }
1726
1727 /// Retrieve an iterator to the beginning of the visible-extensions
1728 /// list.
1731 }
1732
1733 /// Retrieve an iterator to the end of the visible-extensions list.
1736 }
1737
1738 /// Determine whether the visible-extensions list is empty.
1741 }
1742
1743private:
1744 /// Test whether the given category is an extension.
1745 ///
1746 /// Used in the \c known_extensions_iterator.
1747 static bool isKnownExtension(ObjCCategoryDecl *Cat);
1748
1749public:
1750 friend class ASTDeclMerger;
1751 friend class ASTDeclReader;
1752 friend class ASTDeclWriter;
1753 friend class ASTReader;
1754
1755 /// Iterator that walks over all of the known extensions.
1759 llvm::iterator_range<known_extensions_iterator>;
1760
1764 }
1765
1766 /// Retrieve an iterator to the beginning of the known-extensions
1767 /// list.
1770 }
1771
1772 /// Retrieve an iterator to the end of the known-extensions list.
1775 }
1776
1777 /// Determine whether the known-extensions list is empty.
1780 }
1781
1782 /// Retrieve the raw pointer to the start of the category/extension
1783 /// list.
1785 // FIXME: Should make sure no callers ever do this.
1786 if (!hasDefinition())
1787 return nullptr;
1788
1789 if (data().ExternallyCompleted)
1790 LoadExternalDefinition();
1791
1792 return data().CategoryList;
1793 }
1794
1795 /// Set the raw pointer to the start of the category/extension
1796 /// list.
1798 data().CategoryList = category;
1799 }
1800
1803 ObjCPropertyQueryKind QueryKind) const;
1804
1805 void collectPropertiesToImplement(PropertyMap &PM) const override;
1806
1807 /// isSuperClassOf - Return true if this class is the specified class or is a
1808 /// super class of the specified interface class.
1809 bool isSuperClassOf(const ObjCInterfaceDecl *I) const {
1810 // If RHS is derived from LHS it is OK; else it is not OK.
1811 while (I != nullptr) {
1812 if (declaresSameEntity(this, I))
1813 return true;
1814
1815 I = I->getSuperClass();
1816 }
1817 return false;
1818 }
1819
1820 /// isArcWeakrefUnavailable - Checks for a class or one of its super classes
1821 /// to be incompatible with __weak references. Returns true if it is.
1822 bool isArcWeakrefUnavailable() const;
1823
1824 /// isObjCRequiresPropertyDefs - Checks that a class or one of its super
1825 /// classes must not be auto-synthesized. Returns class decl. if it must not
1826 /// be; 0, otherwise.
1828
1830 ObjCInterfaceDecl *&ClassDeclared);
1832 ObjCInterfaceDecl *ClassDeclared;
1833 return lookupInstanceVariable(IVarName, ClassDeclared);
1834 }
1835
1837
1838 // Lookup a method. First, we search locally. If a method isn't
1839 // found, we search referenced protocols and class categories.
1840 ObjCMethodDecl *lookupMethod(Selector Sel, bool isInstance,
1841 bool shallowCategoryLookup = false,
1842 bool followSuper = true,
1843 const ObjCCategoryDecl *C = nullptr) const;
1844
1845 /// Lookup an instance method for a given selector.
1847 return lookupMethod(Sel, true/*isInstance*/);
1848 }
1849
1850 /// Lookup a class method for a given selector.
1852 return lookupMethod(Sel, false/*isInstance*/);
1853 }
1854
1856
1857 /// Lookup a method in the classes implementation hierarchy.
1859 bool Instance=true) const;
1860
1862 return lookupPrivateMethod(Sel, false);
1863 }
1864
1865 /// Lookup a setter or getter in the class hierarchy,
1866 /// including in all categories except for category passed
1867 /// as argument.
1869 const ObjCCategoryDecl *Cat,
1870 bool IsClassProperty) const {
1871 return lookupMethod(Sel, !IsClassProperty/*isInstance*/,
1872 false/*shallowCategoryLookup*/,
1873 true /* followsSuper */,
1874 Cat);
1875 }
1876
1878 if (!hasDefinition())
1879 return getLocation();
1880
1881 return data().EndLoc;
1882 }
1883
1884 void setEndOfDefinitionLoc(SourceLocation LE) { data().EndLoc = LE; }
1885
1886 /// Retrieve the starting location of the superclass.
1888
1889 /// isImplicitInterfaceDecl - check that this is an implicitly declared
1890 /// ObjCInterfaceDecl node. This is for legacy objective-c \@implementation
1891 /// declaration without an \@interface declaration.
1893 return hasDefinition() ? data().Definition->isImplicit() : isImplicit();
1894 }
1895
1896 /// ClassImplementsProtocol - Checks that 'lProto' protocol
1897 /// has been implemented in IDecl class, its super class or categories (if
1898 /// lookupCategory is true).
1900 bool lookupCategory,
1901 bool RHSIsQualifiedID = false);
1902
1904 using redecl_iterator = redeclarable_base::redecl_iterator;
1905
1912
1913 /// Retrieves the canonical declaration of this Objective-C class.
1916
1917 // Low-level accessor
1918 const Type *getTypeForDecl() const { return TypeForDecl; }
1919 void setTypeForDecl(const Type *TD) const { TypeForDecl = TD; }
1920
1921 /// Get precomputed ODRHash or add a new one.
1922 unsigned getODRHash();
1923
1924 static bool classof(const Decl *D) { return classofKind(D->getKind()); }
1925 static bool classofKind(Kind K) { return K == ObjCInterface; }
1926
1927private:
1928 /// True if a valid hash is stored in ODRHash.
1929 bool hasODRHash() const;
1930 void setHasODRHash(bool HasHash);
1931
1932 const ObjCInterfaceDecl *findInterfaceWithDesignatedInitializers() const;
1933 bool inheritsDesignatedInitializers() const;
1934};
1935
1936/// ObjCIvarDecl - Represents an ObjC instance variable. In general, ObjC
1937/// instance variables are identical to C. The only exception is Objective-C
1938/// supports C++ style access control. For example:
1939///
1940/// \@interface IvarExample : NSObject
1941/// {
1942/// id defaultToProtected;
1943/// \@public:
1944/// id canBePublic; // same as C++.
1945/// \@protected:
1946/// id canBeProtected; // same as C++.
1947/// \@package:
1948/// id canBePackage; // framework visibility (not available in C++).
1949/// }
1950///
1951class ObjCIvarDecl : public FieldDecl {
1952 void anchor() override;
1953
1954public:
1958
1959private:
1961 SourceLocation IdLoc, const IdentifierInfo *Id, QualType T,
1962 TypeSourceInfo *TInfo, AccessControl ac, Expr *BW,
1963 bool synthesized)
1964 : FieldDecl(ObjCIvar, DC, StartLoc, IdLoc, Id, T, TInfo, BW,
1965 /*Mutable=*/false, /*HasInit=*/ICIS_NoInit),
1966 DeclAccess(ac), Synthesized(synthesized) {}
1967
1968public:
1969 static ObjCIvarDecl *Create(ASTContext &C, ObjCContainerDecl *DC,
1970 SourceLocation StartLoc, SourceLocation IdLoc,
1971 const IdentifierInfo *Id, QualType T,
1972 TypeSourceInfo *TInfo, AccessControl ac,
1973 Expr *BW = nullptr, bool synthesized = false);
1974
1975 static ObjCIvarDecl *CreateDeserialized(ASTContext &C, GlobalDeclID ID);
1976
1977 /// Return the class interface that this ivar is logically contained
1978 /// in; this is either the interface where the ivar was declared, or the
1979 /// interface the ivar is conceptually a part of in the case of synthesized
1980 /// ivars.
1981 ObjCInterfaceDecl *getContainingInterface();
1983 return const_cast<ObjCIvarDecl *>(this)->getContainingInterface();
1984 }
1985
1986 ObjCIvarDecl *getNextIvar() { return NextIvar; }
1987 const ObjCIvarDecl *getNextIvar() const { return NextIvar; }
1988 void setNextIvar(ObjCIvarDecl *ivar) { NextIvar = ivar; }
1989
1991 return cast<ObjCIvarDecl>(FieldDecl::getCanonicalDecl());
1992 }
1994 return const_cast<ObjCIvarDecl *>(this)->getCanonicalDecl();
1995 }
1996
1997 void setAccessControl(AccessControl ac) { DeclAccess = ac; }
1998
1999 AccessControl getAccessControl() const { return AccessControl(DeclAccess); }
2000
2002 return DeclAccess == None ? Protected : AccessControl(DeclAccess);
2003 }
2004
2005 void setSynthesize(bool synth) { Synthesized = synth; }
2006 bool getSynthesize() const { return Synthesized; }
2007
2008 /// Retrieve the type of this instance variable when viewed as a member of a
2009 /// specific object type.
2010 QualType getUsageType(QualType objectType) const;
2011
2012 // Implement isa/cast/dyncast/etc.
2013 static bool classof(const Decl *D) { return classofKind(D->getKind()); }
2014 static bool classofKind(Kind K) { return K == ObjCIvar; }
2015
2016private:
2017 /// NextIvar - Next Ivar in the list of ivars declared in class; class's
2018 /// extensions and class's implementation
2019 ObjCIvarDecl *NextIvar = nullptr;
2020
2021 // NOTE: VC++ treats enums as signed, avoid using the AccessControl enum
2022 LLVM_PREFERRED_TYPE(AccessControl)
2023 unsigned DeclAccess : 3;
2024 LLVM_PREFERRED_TYPE(bool)
2025 unsigned Synthesized : 1;
2026};
2027
2028/// Represents a field declaration created by an \@defs(...).
2032 QualType T, Expr *BW)
2033 : FieldDecl(ObjCAtDefsField, DC, StartLoc, IdLoc, Id, T,
2034 /*TInfo=*/nullptr, // FIXME: Do ObjCAtDefs have declarators ?
2035 BW, /*Mutable=*/false, /*HasInit=*/ICIS_NoInit) {}
2036
2037 void anchor() override;
2038
2039public:
2041 SourceLocation StartLoc,
2043 QualType T, Expr *BW);
2044
2047
2048 // Implement isa/cast/dyncast/etc.
2049 static bool classof(const Decl *D) { return classofKind(D->getKind()); }
2050 static bool classofKind(Kind K) { return K == ObjCAtDefsField; }
2051};
2052
2053/// Represents an Objective-C protocol declaration.
2054///
2055/// Objective-C protocols declare a pure abstract type (i.e., no instance
2056/// variables are permitted). Protocols originally drew inspiration from
2057/// C++ pure virtual functions (a C++ feature with nice semantics and lousy
2058/// syntax:-). Here is an example:
2059///
2060/// \code
2061/// \@protocol NSDraggingInfo <refproto1, refproto2>
2062/// - (NSWindow *)draggingDestinationWindow;
2063/// - (NSImage *)draggedImage;
2064/// \@end
2065/// \endcode
2066///
2067/// This says that NSDraggingInfo requires two methods and requires everything
2068/// that the two "referenced protocols" 'refproto1' and 'refproto2' require as
2069/// well.
2070///
2071/// \code
2072/// \@interface ImplementsNSDraggingInfo : NSObject <NSDraggingInfo>
2073/// \@end
2074/// \endcode
2075///
2076/// ObjC protocols inspired Java interfaces. Unlike Java, ObjC classes and
2077/// protocols are in distinct namespaces. For example, Cocoa defines both
2078/// an NSObject protocol and class (which isn't allowed in Java). As a result,
2079/// protocols are referenced using angle brackets as follows:
2080///
2081/// id <NSDraggingInfo> anyObjectThatImplementsNSDraggingInfo;
2083 public Redeclarable<ObjCProtocolDecl> {
2084 struct DefinitionData {
2085 // The declaration that defines this protocol.
2086 ObjCProtocolDecl *Definition;
2087
2088 /// Referenced protocols
2089 ObjCProtocolList ReferencedProtocols;
2090
2091 /// Tracks whether a ODR hash has been computed for this protocol.
2092 LLVM_PREFERRED_TYPE(bool)
2093 unsigned HasODRHash : 1;
2094
2095 /// A hash of parts of the class to help in ODR checking.
2096 unsigned ODRHash = 0;
2097 };
2098
2099 /// Contains a pointer to the data associated with this class,
2100 /// which will be NULL if this class has not yet been defined.
2101 ///
2102 /// The bit indicates when we don't need to check for out-of-date
2103 /// declarations. It will be set unless modules are enabled.
2104 llvm::PointerIntPair<DefinitionData *, 1, bool> Data;
2105
2107 SourceLocation nameLoc, SourceLocation atStartLoc,
2108 ObjCProtocolDecl *PrevDecl);
2109
2110 void anchor() override;
2111
2112 DefinitionData &data() const {
2113 assert(Data.getPointer() && "Objective-C protocol has no definition!");
2114 return *Data.getPointer();
2115 }
2116
2117 void allocateDefinitionData();
2118
2120
2121 ObjCProtocolDecl *getNextRedeclarationImpl() override {
2122 return getNextRedeclaration();
2123 }
2124
2125 ObjCProtocolDecl *getPreviousDeclImpl() override {
2126 return getPreviousDecl();
2127 }
2128
2129 ObjCProtocolDecl *getMostRecentDeclImpl() override {
2130 return getMostRecentDecl();
2131 }
2132
2133 /// True if a valid hash is stored in ODRHash.
2134 bool hasODRHash() const;
2135 void setHasODRHash(bool HasHash);
2136
2137public:
2138 friend class ASTDeclMerger;
2139 friend class ASTDeclReader;
2140 friend class ASTDeclWriter;
2141 friend class ASTReader;
2142 friend class ODRDiagsEmitter;
2143
2146 SourceLocation nameLoc,
2147 SourceLocation atStartLoc,
2148 ObjCProtocolDecl *PrevDecl);
2149
2151
2153 assert(hasDefinition() && "No definition available!");
2154 return data().ReferencedProtocols;
2155 }
2156
2158 using protocol_range = llvm::iterator_range<protocol_iterator>;
2159
2162 }
2163
2165 if (!hasDefinition())
2166 return protocol_iterator();
2167
2168 return data().ReferencedProtocols.begin();
2169 }
2170
2172 if (!hasDefinition())
2173 return protocol_iterator();
2174
2175 return data().ReferencedProtocols.end();
2176 }
2177
2179 using protocol_loc_range = llvm::iterator_range<protocol_loc_iterator>;
2180
2183 }
2184
2186 if (!hasDefinition())
2187 return protocol_loc_iterator();
2188
2189 return data().ReferencedProtocols.loc_begin();
2190 }
2191
2193 if (!hasDefinition())
2194 return protocol_loc_iterator();
2195
2196 return data().ReferencedProtocols.loc_end();
2197 }
2198
2199 unsigned protocol_size() const {
2200 if (!hasDefinition())
2201 return 0;
2202
2203 return data().ReferencedProtocols.size();
2204 }
2205
2206 /// setProtocolList - Set the list of protocols that this interface
2207 /// implements.
2208 void setProtocolList(ObjCProtocolDecl *const*List, unsigned Num,
2209 const SourceLocation *Locs, ASTContext &C) {
2210 assert(hasDefinition() && "Protocol is not defined");
2211 data().ReferencedProtocols.set(List, Num, Locs, C);
2212 }
2213
2214 /// This is true iff the protocol is tagged with the
2215 /// `objc_non_runtime_protocol` attribute.
2216 bool isNonRuntimeProtocol() const;
2217
2218 /// Get the set of all protocols implied by this protocols inheritance
2219 /// hierarchy.
2220 void getImpliedProtocols(llvm::DenseSet<const ObjCProtocolDecl *> &IPs) const;
2221
2223
2224 // Lookup a method. First, we search locally. If a method isn't
2225 // found, we search referenced protocols and class categories.
2226 ObjCMethodDecl *lookupMethod(Selector Sel, bool isInstance) const;
2227
2229 return lookupMethod(Sel, true/*isInstance*/);
2230 }
2231
2233 return lookupMethod(Sel, false/*isInstance*/);
2234 }
2235
2236 /// Determine whether this protocol has a definition.
2237 bool hasDefinition() const {
2238 // If the name of this protocol is out-of-date, bring it up-to-date, which
2239 // might bring in a definition.
2240 // Note: a null value indicates that we don't have a definition and that
2241 // modules are enabled.
2242 if (!Data.getOpaqueValue())
2244
2245 return Data.getPointer();
2246 }
2247
2248 /// Retrieve the definition of this protocol, if any.
2250 return hasDefinition()? Data.getPointer()->Definition : nullptr;
2251 }
2252
2253 /// Retrieve the definition of this protocol, if any.
2255 return hasDefinition()? Data.getPointer()->Definition : nullptr;
2256 }
2257
2258 /// Determine whether this particular declaration is also the
2259 /// definition.
2261 return getDefinition() == this;
2262 }
2263
2264 /// Starts the definition of this Objective-C protocol.
2265 void startDefinition();
2266
2267 /// Starts the definition without sharing it with other redeclarations.
2268 /// Such definition shouldn't be used for anything but only to compare if
2269 /// a duplicate is compatible with previous definition or if it is
2270 /// a distinct duplicate.
2273
2274 /// Produce a name to be used for protocol's metadata. It comes either via
2275 /// objc_runtime_name attribute or protocol name.
2276 StringRef getObjCRuntimeNameAsString() const;
2277
2278 SourceRange getSourceRange() const override LLVM_READONLY {
2281
2283 }
2284
2286 using redecl_iterator = redeclarable_base::redecl_iterator;
2287
2294
2295 /// Retrieves the canonical declaration of this Objective-C protocol.
2298
2299 void collectPropertiesToImplement(PropertyMap &PM) const override;
2300
2303 PropertyDeclOrder &PO) const;
2304
2305 /// Get precomputed ODRHash or add a new one.
2306 unsigned getODRHash();
2307
2308 static bool classof(const Decl *D) { return classofKind(D->getKind()); }
2309 static bool classofKind(Kind K) { return K == ObjCProtocol; }
2310};
2311
2312/// ObjCCategoryDecl - Represents a category declaration. A category allows
2313/// you to add methods to an existing class (without subclassing or modifying
2314/// the original class interface or implementation:-). Categories don't allow
2315/// you to add instance data. The following example adds "myMethod" to all
2316/// NSView's within a process:
2317///
2318/// \@interface NSView (MyViewMethods)
2319/// - myMethod;
2320/// \@end
2321///
2322/// Categories also allow you to split the implementation of a class across
2323/// several files (a feature more naturally supported in C++).
2324///
2325/// Categories were originally inspired by dynamic languages such as Common
2326/// Lisp and Smalltalk. More traditional class-based languages (C++, Java)
2327/// don't support this level of dynamism, which is both powerful and dangerous.
2329 /// Interface belonging to this category
2330 ObjCInterfaceDecl *ClassInterface;
2331
2332 /// The type parameters associated with this category, if any.
2333 ObjCTypeParamList *TypeParamList = nullptr;
2334
2335 /// referenced protocols in this category.
2336 ObjCProtocolList ReferencedProtocols;
2337
2338 /// Next category belonging to this class.
2339 /// FIXME: this should not be a singly-linked list. Move storage elsewhere.
2340 ObjCCategoryDecl *NextClassCategory = nullptr;
2341
2342 /// The location of the category name in this declaration.
2343 SourceLocation CategoryNameLoc;
2344
2345 /// class extension may have private ivars.
2346 SourceLocation IvarLBraceLoc;
2347 SourceLocation IvarRBraceLoc;
2348
2350 SourceLocation ClassNameLoc, SourceLocation CategoryNameLoc,
2351 const IdentifierInfo *Id, ObjCInterfaceDecl *IDecl,
2352 ObjCTypeParamList *typeParamList,
2353 SourceLocation IvarLBraceLoc = SourceLocation(),
2354 SourceLocation IvarRBraceLoc = SourceLocation());
2355
2356 void anchor() override;
2357
2358public:
2359 friend class ASTDeclReader;
2360 friend class ASTDeclWriter;
2361
2362 static ObjCCategoryDecl *
2364 SourceLocation ClassNameLoc, SourceLocation CategoryNameLoc,
2365 const IdentifierInfo *Id, ObjCInterfaceDecl *IDecl,
2366 ObjCTypeParamList *typeParamList,
2367 SourceLocation IvarLBraceLoc = SourceLocation(),
2368 SourceLocation IvarRBraceLoc = SourceLocation());
2370
2371 ObjCInterfaceDecl *getClassInterface() { return ClassInterface; }
2372 const ObjCInterfaceDecl *getClassInterface() const { return ClassInterface; }
2373
2374 /// Retrieve the type parameter list associated with this category or
2375 /// extension.
2376 ObjCTypeParamList *getTypeParamList() const { return TypeParamList; }
2377
2378 /// Set the type parameters of this category.
2379 ///
2380 /// This function is used by the AST importer, which must import the type
2381 /// parameters after creating their DeclContext to avoid loops.
2383
2384
2387
2388 /// setProtocolList - Set the list of protocols that this interface
2389 /// implements.
2390 void setProtocolList(ObjCProtocolDecl *const*List, unsigned Num,
2391 const SourceLocation *Locs, ASTContext &C) {
2392 ReferencedProtocols.set(List, Num, Locs, C);
2393 }
2394
2396 return ReferencedProtocols;
2397 }
2398
2400 using protocol_range = llvm::iterator_range<protocol_iterator>;
2401
2404 }
2405
2407 return ReferencedProtocols.begin();
2408 }
2409
2410 protocol_iterator protocol_end() const { return ReferencedProtocols.end(); }
2411 unsigned protocol_size() const { return ReferencedProtocols.size(); }
2412
2414 using protocol_loc_range = llvm::iterator_range<protocol_loc_iterator>;
2415
2418 }
2419
2421 return ReferencedProtocols.loc_begin();
2422 }
2423
2425 return ReferencedProtocols.loc_end();
2426 }
2427
2428 ObjCCategoryDecl *getNextClassCategory() const { return NextClassCategory; }
2429
2430 /// Retrieve the pointer to the next stored category (or extension),
2431 /// which may be hidden.
2433 return NextClassCategory;
2434 }
2435
2436 bool IsClassExtension() const { return getIdentifier() == nullptr; }
2437
2439 using ivar_range = llvm::iterator_range<specific_decl_iterator<ObjCIvarDecl>>;
2440
2442
2444 return ivar_iterator(decls_begin());
2445 }
2446
2448 return ivar_iterator(decls_end());
2449 }
2450
2451 unsigned ivar_size() const {
2452 return std::distance(ivar_begin(), ivar_end());
2453 }
2454
2455 bool ivar_empty() const {
2456 return ivar_begin() == ivar_end();
2457 }
2458
2459 SourceLocation getCategoryNameLoc() const { return CategoryNameLoc; }
2460 void setCategoryNameLoc(SourceLocation Loc) { CategoryNameLoc = Loc; }
2461
2462 void setIvarLBraceLoc(SourceLocation Loc) { IvarLBraceLoc = Loc; }
2463 SourceLocation getIvarLBraceLoc() const { return IvarLBraceLoc; }
2464 void setIvarRBraceLoc(SourceLocation Loc) { IvarRBraceLoc = Loc; }
2465 SourceLocation getIvarRBraceLoc() const { return IvarRBraceLoc; }
2466
2467 static bool classof(const Decl *D) { return classofKind(D->getKind()); }
2468 static bool classofKind(Kind K) { return K == ObjCCategory; }
2469};
2470
2472 /// Class interface for this class/category implementation
2473 ObjCInterfaceDecl *ClassInterface;
2474
2475 void anchor() override;
2476
2477protected:
2479 const IdentifierInfo *Id, SourceLocation nameLoc,
2480 SourceLocation atStartLoc)
2481 : ObjCContainerDecl(DK, DC, Id, nameLoc, atStartLoc),
2482 ClassInterface(classInterface) {}
2483
2484public:
2485 const ObjCInterfaceDecl *getClassInterface() const { return ClassInterface; }
2486 ObjCInterfaceDecl *getClassInterface() { return ClassInterface; }
2488
2490 // FIXME: Context should be set correctly before we get here.
2491 method->setLexicalDeclContext(this);
2492 addDecl(method);
2493 }
2494
2496 // FIXME: Context should be set correctly before we get here.
2497 method->setLexicalDeclContext(this);
2498 addDecl(method);
2499 }
2500
2502
2504 ObjCPropertyQueryKind queryKind) const;
2506
2507 // Iterator access to properties.
2510 llvm::iterator_range<specific_decl_iterator<ObjCPropertyImplDecl>>;
2511
2514 }
2515
2518 }
2519
2521 return propimpl_iterator(decls_end());
2522 }
2523
2524 static bool classof(const Decl *D) { return classofKind(D->getKind()); }
2525
2526 static bool classofKind(Kind K) {
2527 return K >= firstObjCImpl && K <= lastObjCImpl;
2528 }
2529};
2530
2531/// ObjCCategoryImplDecl - An object of this class encapsulates a category
2532/// \@implementation declaration. If a category class has declaration of a
2533/// property, its implementation must be specified in the category's
2534/// \@implementation declaration. Example:
2535/// \@interface I \@end
2536/// \@interface I(CATEGORY)
2537/// \@property int p1, d1;
2538/// \@end
2539/// \@implementation I(CATEGORY)
2540/// \@dynamic p1,d1;
2541/// \@end
2542///
2543/// ObjCCategoryImplDecl
2545 // Category name location
2546 SourceLocation CategoryNameLoc;
2547
2549 ObjCInterfaceDecl *classInterface,
2550 SourceLocation nameLoc, SourceLocation atStartLoc,
2551 SourceLocation CategoryNameLoc)
2552 : ObjCImplDecl(ObjCCategoryImpl, DC, classInterface, Id, nameLoc,
2553 atStartLoc),
2554 CategoryNameLoc(CategoryNameLoc) {}
2555
2556 void anchor() override;
2557
2558public:
2559 friend class ASTDeclReader;
2560 friend class ASTDeclWriter;
2561
2562 static ObjCCategoryImplDecl *
2564 ObjCInterfaceDecl *classInterface, SourceLocation nameLoc,
2565 SourceLocation atStartLoc, SourceLocation CategoryNameLoc);
2568
2570
2571 SourceLocation getCategoryNameLoc() const { return CategoryNameLoc; }
2572
2573 static bool classof(const Decl *D) { return classofKind(D->getKind()); }
2574 static bool classofKind(Kind K) { return K == ObjCCategoryImpl;}
2575};
2576
2577raw_ostream &operator<<(raw_ostream &OS, const ObjCCategoryImplDecl &CID);
2578
2579/// ObjCImplementationDecl - Represents a class definition - this is where
2580/// method definitions are specified. For example:
2581///
2582/// @code
2583/// \@implementation MyClass
2584/// - (void)myMethod { /* do something */ }
2585/// \@end
2586/// @endcode
2587///
2588/// In a non-fragile runtime, instance variables can appear in the class
2589/// interface, class extensions (nameless categories), and in the implementation
2590/// itself, as well as being synthesized as backing storage for properties.
2591///
2592/// In a fragile runtime, instance variables are specified in the class
2593/// interface, \em not in the implementation. Nevertheless (for legacy reasons),
2594/// we allow instance variables to be specified in the implementation. When
2595/// specified, they need to be \em identical to the interface.
2597 /// Implementation Class's super class.
2598 ObjCInterfaceDecl *SuperClass;
2599 SourceLocation SuperLoc;
2600
2601 /// \@implementation may have private ivars.
2602 SourceLocation IvarLBraceLoc;
2603 SourceLocation IvarRBraceLoc;
2604
2605 /// Support for ivar initialization.
2606 /// The arguments used to initialize the ivars
2607 LazyCXXCtorInitializersPtr IvarInitializers;
2608 unsigned NumIvarInitializers = 0;
2609
2610 /// Do the ivars of this class require initialization other than
2611 /// zero-initialization?
2612 LLVM_PREFERRED_TYPE(bool)
2613 bool HasNonZeroConstructors : 1;
2614
2615 /// Do the ivars of this class require non-trivial destruction?
2616 LLVM_PREFERRED_TYPE(bool)
2617 bool HasDestructors : 1;
2618
2620 ObjCInterfaceDecl *classInterface,
2621 ObjCInterfaceDecl *superDecl,
2622 SourceLocation nameLoc, SourceLocation atStartLoc,
2623 SourceLocation superLoc = SourceLocation(),
2624 SourceLocation IvarLBraceLoc=SourceLocation(),
2625 SourceLocation IvarRBraceLoc=SourceLocation())
2626 : ObjCImplDecl(ObjCImplementation, DC, classInterface,
2627 classInterface ? classInterface->getIdentifier()
2628 : nullptr,
2629 nameLoc, atStartLoc),
2630 SuperClass(superDecl), SuperLoc(superLoc),
2631 IvarLBraceLoc(IvarLBraceLoc), IvarRBraceLoc(IvarRBraceLoc),
2632 HasNonZeroConstructors(false), HasDestructors(false) {}
2633
2634 void anchor() override;
2635
2636public:
2637 friend class ASTDeclReader;
2638 friend class ASTDeclWriter;
2639
2641 ObjCInterfaceDecl *classInterface,
2642 ObjCInterfaceDecl *superDecl,
2643 SourceLocation nameLoc,
2644 SourceLocation atStartLoc,
2645 SourceLocation superLoc = SourceLocation(),
2646 SourceLocation IvarLBraceLoc=SourceLocation(),
2647 SourceLocation IvarRBraceLoc=SourceLocation());
2648
2651
2652 /// init_iterator - Iterates through the ivar initializer list.
2654
2655 /// init_const_iterator - Iterates through the ivar initializer list.
2657
2658 using init_range = llvm::iterator_range<init_iterator>;
2659 using init_const_range = llvm::iterator_range<init_const_iterator>;
2660
2662
2665 }
2666
2667 /// init_begin() - Retrieve an iterator to the first initializer.
2669 const auto *ConstThis = this;
2670 return const_cast<init_iterator>(ConstThis->init_begin());
2671 }
2672
2673 /// begin() - Retrieve an iterator to the first initializer.
2675
2676 /// init_end() - Retrieve an iterator past the last initializer.
2678 return init_begin() + NumIvarInitializers;
2679 }
2680
2681 /// end() - Retrieve an iterator past the last initializer.
2683 return init_begin() + NumIvarInitializers;
2684 }
2685
2686 /// getNumArgs - Number of ivars which must be initialized.
2687 unsigned getNumIvarInitializers() const {
2688 return NumIvarInitializers;
2689 }
2690
2691 void setNumIvarInitializers(unsigned numNumIvarInitializers) {
2692 NumIvarInitializers = numNumIvarInitializers;
2693 }
2694
2696 CXXCtorInitializer ** initializers,
2697 unsigned numInitializers);
2698
2699 /// Do any of the ivars of this class (not counting its base classes)
2700 /// require construction other than zero-initialization?
2701 bool hasNonZeroConstructors() const { return HasNonZeroConstructors; }
2702 void setHasNonZeroConstructors(bool val) { HasNonZeroConstructors = val; }
2703
2704 /// Do any of the ivars of this class (not counting its base classes)
2705 /// require non-trivial destruction?
2706 bool hasDestructors() const { return HasDestructors; }
2707 void setHasDestructors(bool val) { HasDestructors = val; }
2708
2709 /// getIdentifier - Get the identifier that names the class
2710 /// interface associated with this implementation.
2712 return getClassInterface()->getIdentifier();
2713 }
2714
2715 /// getName - Get the name of identifier for the class interface associated
2716 /// with this implementation as a StringRef.
2717 //
2718 // FIXME: This is a bad API, we are hiding NamedDecl::getName with a different
2719 // meaning.
2720 StringRef getName() const {
2721 assert(getIdentifier() && "Name is not a simple identifier");
2722 return getIdentifier()->getName();
2723 }
2724
2725 /// Get the name of the class associated with this interface.
2726 //
2727 // FIXME: Move to StringRef API.
2728 std::string getNameAsString() const { return std::string(getName()); }
2729
2730 /// Produce a name to be used for class's metadata. It comes either via
2731 /// class's objc_runtime_name attribute or class name.
2732 StringRef getObjCRuntimeNameAsString() const;
2733
2734 const ObjCInterfaceDecl *getSuperClass() const { return SuperClass; }
2735 ObjCInterfaceDecl *getSuperClass() { return SuperClass; }
2736 SourceLocation getSuperClassLoc() const { return SuperLoc; }
2737
2738 void setSuperClass(ObjCInterfaceDecl * superCls) { SuperClass = superCls; }
2739
2740 void setIvarLBraceLoc(SourceLocation Loc) { IvarLBraceLoc = Loc; }
2741 SourceLocation getIvarLBraceLoc() const { return IvarLBraceLoc; }
2742 void setIvarRBraceLoc(SourceLocation Loc) { IvarRBraceLoc = Loc; }
2743 SourceLocation getIvarRBraceLoc() const { return IvarRBraceLoc; }
2744
2746 using ivar_range = llvm::iterator_range<specific_decl_iterator<ObjCIvarDecl>>;
2747
2749
2751 return ivar_iterator(decls_begin());
2752 }
2753
2755 return ivar_iterator(decls_end());
2756 }
2757
2758 unsigned ivar_size() const {
2759 return std::distance(ivar_begin(), ivar_end());
2760 }
2761
2762 bool ivar_empty() const {
2763 return ivar_begin() == ivar_end();
2764 }
2765
2766 static bool classof(const Decl *D) { return classofKind(D->getKind()); }
2767 static bool classofKind(Kind K) { return K == ObjCImplementation; }
2768};
2769
2770raw_ostream &operator<<(raw_ostream &OS, const ObjCImplementationDecl &ID);
2771
2772/// ObjCCompatibleAliasDecl - Represents alias of a class. This alias is
2773/// declared as \@compatibility_alias alias class.
2775 /// Class that this is an alias of.
2776 ObjCInterfaceDecl *AliasedClass;
2777
2779 ObjCInterfaceDecl* aliasedClass)
2780 : NamedDecl(ObjCCompatibleAlias, DC, L, Id), AliasedClass(aliasedClass) {}
2781
2782 void anchor() override;
2783
2784public:
2787 ObjCInterfaceDecl* aliasedClass);
2788
2791
2792 const ObjCInterfaceDecl *getClassInterface() const { return AliasedClass; }
2793 ObjCInterfaceDecl *getClassInterface() { return AliasedClass; }
2794 void setClassInterface(ObjCInterfaceDecl *D) { AliasedClass = D; }
2795
2796 static bool classof(const Decl *D) { return classofKind(D->getKind()); }
2797 static bool classofKind(Kind K) { return K == ObjCCompatibleAlias; }
2798};
2799
2800/// ObjCPropertyImplDecl - Represents implementation declaration of a property
2801/// in a class or category implementation block. For example:
2802/// \@synthesize prop1 = ivar1;
2803///
2805public:
2806 enum Kind {
2808 Dynamic
2810
2811private:
2812 SourceLocation AtLoc; // location of \@synthesize or \@dynamic
2813
2814 /// For \@synthesize, the location of the ivar, if it was written in
2815 /// the source code.
2816 ///
2817 /// \code
2818 /// \@synthesize int a = b
2819 /// \endcode
2820 SourceLocation IvarLoc;
2821
2822 /// Property declaration being implemented
2823 ObjCPropertyDecl *PropertyDecl;
2824
2825 /// Null for \@dynamic. Required for \@synthesize.
2826 ObjCIvarDecl *PropertyIvarDecl;
2827
2828 /// The getter's definition, which has an empty body if synthesized.
2829 ObjCMethodDecl *GetterMethodDecl = nullptr;
2830 /// The getter's definition, which has an empty body if synthesized.
2831 ObjCMethodDecl *SetterMethodDecl = nullptr;
2832
2833 /// Null for \@dynamic. Non-null if property must be copy-constructed in
2834 /// getter.
2835 Expr *GetterCXXConstructor = nullptr;
2836
2837 /// Null for \@dynamic. Non-null if property has assignment operator to call
2838 /// in Setter synthesis.
2839 Expr *SetterCXXAssignment = nullptr;
2840
2842 ObjCPropertyDecl *property,
2843 Kind PK,
2844 ObjCIvarDecl *ivarDecl,
2845 SourceLocation ivarLoc)
2846 : Decl(ObjCPropertyImpl, DC, L), AtLoc(atLoc),
2847 IvarLoc(ivarLoc), PropertyDecl(property), PropertyIvarDecl(ivarDecl) {
2848 assert(PK == Dynamic || PropertyIvarDecl);
2849 }
2850
2851public:
2852 friend class ASTDeclReader;
2853
2856 ObjCPropertyDecl *property,
2857 Kind PK,
2858 ObjCIvarDecl *ivarDecl,
2859 SourceLocation ivarLoc);
2860
2863
2864 SourceRange getSourceRange() const override LLVM_READONLY;
2865
2866 SourceLocation getBeginLoc() const LLVM_READONLY { return AtLoc; }
2867 void setAtLoc(SourceLocation Loc) { AtLoc = Loc; }
2868
2870 return PropertyDecl;
2871 }
2872 void setPropertyDecl(ObjCPropertyDecl *Prop) { PropertyDecl = Prop; }
2873
2875 return PropertyIvarDecl ? Synthesize : Dynamic;
2876 }
2877
2879 return PropertyIvarDecl;
2880 }
2881 SourceLocation getPropertyIvarDeclLoc() const { return IvarLoc; }
2882
2884 SourceLocation IvarLoc) {
2885 PropertyIvarDecl = Ivar;
2886 this->IvarLoc = IvarLoc;
2887 }
2888
2889 /// For \@synthesize, returns true if an ivar name was explicitly
2890 /// specified.
2891 ///
2892 /// \code
2893 /// \@synthesize int a = b; // true
2894 /// \@synthesize int a; // false
2895 /// \endcode
2896 bool isIvarNameSpecified() const {
2897 return IvarLoc.isValid() && IvarLoc != getLocation();
2898 }
2899
2900 ObjCMethodDecl *getGetterMethodDecl() const { return GetterMethodDecl; }
2901 void setGetterMethodDecl(ObjCMethodDecl *MD) { GetterMethodDecl = MD; }
2902
2903 ObjCMethodDecl *getSetterMethodDecl() const { return SetterMethodDecl; }
2904 void setSetterMethodDecl(ObjCMethodDecl *MD) { SetterMethodDecl = MD; }
2905
2907 return GetterCXXConstructor;
2908 }
2909
2910 void setGetterCXXConstructor(Expr *getterCXXConstructor) {
2911 GetterCXXConstructor = getterCXXConstructor;
2912 }
2913
2915 return SetterCXXAssignment;
2916 }
2917
2918 void setSetterCXXAssignment(Expr *setterCXXAssignment) {
2919 SetterCXXAssignment = setterCXXAssignment;
2920 }
2921
2922 static bool classof(const Decl *D) { return classofKind(D->getKind()); }
2923 static bool classofKind(Decl::Kind K) { return K == ObjCPropertyImpl; }
2924};
2925
2926template<bool (*Filter)(ObjCCategoryDecl *)>
2927void
2928ObjCInterfaceDecl::filtered_category_iterator<Filter>::
2929findAcceptableCategory() {
2930 while (Current && !Filter(Current))
2931 Current = Current->getNextClassCategoryRaw();
2932}
2933
2934template<bool (*Filter)(ObjCCategoryDecl *)>
2935inline ObjCInterfaceDecl::filtered_category_iterator<Filter> &
2937 Current = Current->getNextClassCategoryRaw();
2938 findAcceptableCategory();
2939 return *this;
2940}
2941
2942inline bool ObjCInterfaceDecl::isVisibleCategory(ObjCCategoryDecl *Cat) {
2943 return !Cat->isInvalidDecl() && Cat->isUnconditionallyVisible();
2944}
2945
2946inline bool ObjCInterfaceDecl::isVisibleExtension(ObjCCategoryDecl *Cat) {
2947 return !Cat->isInvalidDecl() && Cat->IsClassExtension() &&
2949}
2950
2951inline bool ObjCInterfaceDecl::isKnownExtension(ObjCCategoryDecl *Cat) {
2952 return !Cat->isInvalidDecl() && Cat->IsClassExtension();
2953}
2954
2955} // namespace clang
2956
2957#endif // LLVM_CLANG_AST_DECLOBJC_H
StringRef P
static char ID
Definition: Arena.cpp:183
const Decl * D
enum clang::sema::@1655::IndirectLocalPathEntry::EntryKind Kind
Defines the clang::IdentifierInfo, clang::IdentifierTable, and clang::Selector interfaces.
#define X(type, name)
Definition: Value.h:143
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified.
uint32_t Id
Definition: SemaARM.cpp:1144
SourceLocation Loc
Definition: SemaObjC.cpp:759
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:187
Reads an AST files chain containing the contents of a translation unit.
Definition: ASTReader.h:378
Represents a C++ base or member initializer.
Definition: DeclCXX.h:2304
CompoundStmt - This represents a group of statements like { stmt stmt }.
Definition: Stmt.h:1611
Iterates over a filtered subrange of declarations stored in a DeclContext.
Definition: DeclBase.h:2446
specific_decl_iterator - Iterates over a subrange of declarations stored in a DeclContext,...
Definition: DeclBase.h:2370
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
Definition: DeclBase.h:1436
ObjCMethodDeclBitfields ObjCMethodDeclBits
Definition: DeclBase.h:2027
ObjCContainerDeclBitfields ObjCContainerDeclBits
Definition: DeclBase.h:2028
void addDecl(Decl *D)
Add the declaration D into this context.
Definition: DeclBase.cpp:1766
decl_iterator decls_end() const
Definition: DeclBase.h:2352
decl_iterator decls_begin() const
Definition: DeclBase.cpp:1622
Decl - This represents one declaration (or definition), e.g.
Definition: DeclBase.h:86
bool isImplicit() const
isImplicit - Indicates whether the declaration was implicitly generated by the implementation.
Definition: DeclBase.h:600
bool isUnconditionallyVisible() const
Determine whether this declaration is definitely visible to name lookup, independent of whether the o...
Definition: DeclBase.h:849
Kind
Lists the kind of concrete classes of Decl.
Definition: DeclBase.h:89
ObjCDeclQualifier
ObjCDeclQualifier - 'Qualifiers' written next to the return and parameter types in method declaration...
Definition: DeclBase.h:198
bool isInvalidDecl() const
Definition: DeclBase.h:595
SourceLocation getLocation() const
Definition: DeclBase.h:446
void setLexicalDeclContext(DeclContext *DC)
Definition: DeclBase.cpp:362
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:3030
FieldDecl * getCanonicalDecl() override
Retrieves the canonical declaration of this field.
Definition: Decl.h:3258
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:2029
static bool classofKind(Kind K)
Definition: DeclObjC.h:2050
static ObjCAtDefsFieldDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID)
Definition: DeclObjC.cpp:1917
static bool classof(const Decl *D)
Definition: DeclObjC.h:2049
ObjCCategoryDecl - Represents a category declaration.
Definition: DeclObjC.h:2328
llvm::iterator_range< specific_decl_iterator< ObjCIvarDecl > > ivar_range
Definition: DeclObjC.h:2439
ObjCCategoryDecl * getNextClassCategory() const
Definition: DeclObjC.h:2428
unsigned ivar_size() const
Definition: DeclObjC.h:2451
ivar_iterator ivar_begin() const
Definition: DeclObjC.h:2443
void setTypeParamList(ObjCTypeParamList *TPL)
Set the type parameters of this category.
Definition: DeclObjC.cpp:2167
bool ivar_empty() const
Definition: DeclObjC.h:2455
ivar_iterator ivar_end() const
Definition: DeclObjC.h:2447
llvm::iterator_range< protocol_loc_iterator > protocol_loc_range
Definition: DeclObjC.h:2414
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:2390
protocol_loc_range protocol_locs() const
Definition: DeclObjC.h:2416
static ObjCCategoryDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID)
Definition: DeclObjC.cpp:2151
void setIvarLBraceLoc(SourceLocation Loc)
Definition: DeclObjC.h:2462
unsigned protocol_size() const
Definition: DeclObjC.h:2411
ObjCCategoryImplDecl * getImplementation() const
Definition: DeclObjC.cpp:2158
void setCategoryNameLoc(SourceLocation Loc)
Definition: DeclObjC.h:2460
ObjCInterfaceDecl * getClassInterface()
Definition: DeclObjC.h:2371
ObjCCategoryDecl * getNextClassCategoryRaw() const
Retrieve the pointer to the next stored category (or extension), which may be hidden.
Definition: DeclObjC.h:2432
specific_decl_iterator< ObjCIvarDecl > ivar_iterator
Definition: DeclObjC.h:2438
ObjCTypeParamList * getTypeParamList() const
Retrieve the type parameter list associated with this category or extension.
Definition: DeclObjC.h:2376
static bool classofKind(Kind K)
Definition: DeclObjC.h:2468
void setIvarRBraceLoc(SourceLocation Loc)
Definition: DeclObjC.h:2464
protocol_iterator protocol_end() const
Definition: DeclObjC.h:2410
const ObjCInterfaceDecl * getClassInterface() const
Definition: DeclObjC.h:2372
llvm::iterator_range< protocol_iterator > protocol_range
Definition: DeclObjC.h:2400
SourceLocation getIvarLBraceLoc() const
Definition: DeclObjC.h:2463
bool IsClassExtension() const
Definition: DeclObjC.h:2436
SourceLocation getIvarRBraceLoc() const
Definition: DeclObjC.h:2465
protocol_loc_iterator protocol_loc_begin() const
Definition: DeclObjC.h:2420
protocol_iterator protocol_begin() const
Definition: DeclObjC.h:2406
protocol_range protocols() const
Definition: DeclObjC.h:2402
ivar_range ivars() const
Definition: DeclObjC.h:2441
const ObjCProtocolList & getReferencedProtocols() const
Definition: DeclObjC.h:2395
void setImplementation(ObjCCategoryImplDecl *ImplD)
Definition: DeclObjC.cpp:2163
ObjCProtocolList::iterator protocol_iterator
Definition: DeclObjC.h:2399
static bool classof(const Decl *D)
Definition: DeclObjC.h:2467
SourceLocation getCategoryNameLoc() const
Definition: DeclObjC.h:2459
protocol_loc_iterator protocol_loc_end() const
Definition: DeclObjC.h:2424
ObjCCategoryImplDecl - An object of this class encapsulates a category @implementation declaration.
Definition: DeclObjC.h:2544
static bool classofKind(Kind K)
Definition: DeclObjC.h:2574
SourceLocation getCategoryNameLoc() const
Definition: DeclObjC.h:2571
ObjCCategoryDecl * getCategoryDecl() const
Definition: DeclObjC.cpp:2199
static bool classof(const Decl *D)
Definition: DeclObjC.h:2573
static ObjCCategoryImplDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID)
Definition: DeclObjC.cpp:2193
ObjCCompatibleAliasDecl - Represents alias of a class.
Definition: DeclObjC.h:2774
const ObjCInterfaceDecl * getClassInterface() const
Definition: DeclObjC.h:2792
static bool classofKind(Kind K)
Definition: DeclObjC.h:2797
ObjCInterfaceDecl * getClassInterface()
Definition: DeclObjC.h:2793
static bool classof(const Decl *D)
Definition: DeclObjC.h:2796
static ObjCCompatibleAliasDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID)
Definition: DeclObjC.cpp:2343
void setClassInterface(ObjCInterfaceDecl *D)
Definition: DeclObjC.h:2794
ObjCContainerDecl - Represents a container for method declarations.
Definition: DeclObjC.h:947
filtered_decl_iterator< ObjCPropertyDecl, &ObjCPropertyDecl::isInstanceProperty > instprop_iterator
Definition: DeclObjC.h:978
ObjCMethodDecl * getMethod(Selector Sel, bool isInstance, bool AllowHidden=false) const
Definition: DeclObjC.cpp:93
filtered_decl_iterator< ObjCPropertyDecl, &ObjCPropertyDecl::isClassProperty > classprop_iterator
Definition: DeclObjC.h:995
llvm::iterator_range< specific_decl_iterator< ObjCMethodDecl > > method_range
Definition: DeclObjC.h:1013
classmeth_iterator classmeth_end() const
Definition: DeclObjC.h:1057
prop_iterator prop_end() const
Definition: DeclObjC.h:972
method_iterator meth_begin() const
Definition: DeclObjC.h:1019
method_range methods() const
Definition: DeclObjC.h:1015
instprop_iterator instprop_end() const
Definition: DeclObjC.h:989
void setAtStartLoc(SourceLocation Loc)
Definition: DeclObjC.h:1097
SourceRange getAtEndRange() const
Definition: DeclObjC.h:1102
classmeth_iterator classmeth_begin() const
Definition: DeclObjC.h:1053
specific_decl_iterator< ObjCPropertyDecl > prop_iterator
Definition: DeclObjC.h:962
prop_iterator prop_begin() const
Definition: DeclObjC.h:968
llvm::iterator_range< instprop_iterator > instprop_range
Definition: DeclObjC.h:979
llvm::MapVector< std::pair< IdentifierInfo *, unsigned >, ObjCPropertyDecl * > PropertyMap
Definition: DeclObjC.h:1086
instmeth_range instance_methods() const
Definition: DeclObjC.h:1032
filtered_decl_iterator< ObjCMethodDecl, &ObjCMethodDecl::isInstanceMethod > instmeth_iterator
Definition: DeclObjC.h:1029
llvm::iterator_range< specific_decl_iterator< ObjCPropertyDecl > > prop_range
Definition: DeclObjC.h:964
llvm::SmallDenseSet< const ObjCProtocolDecl *, 8 > ProtocolPropertySet
Definition: DeclObjC.h:1087
classprop_iterator classprop_end() const
Definition: DeclObjC.h:1006
instmeth_iterator instmeth_end() const
Definition: DeclObjC.h:1040
llvm::iterator_range< classprop_iterator > classprop_range
Definition: DeclObjC.h:996
ObjCPropertyDecl * getProperty(const IdentifierInfo *Id, bool IsInstance) const
Definition: DeclObjC.cpp:236
specific_decl_iterator< ObjCMethodDecl > method_iterator
Definition: DeclObjC.h:1011
static DeclContext * castToDeclContext(const ObjCContainerDecl *D)
Definition: DeclObjC.h:1118
ObjCIvarDecl * getIvarDecl(IdentifierInfo *Id) const
getIvarDecl - This method looks up an ivar in this ContextDecl.
Definition: DeclObjC.cpp:81
classprop_iterator classprop_begin() const
Definition: DeclObjC.h:1002
SourceLocation getAtStartLoc() const
Definition: DeclObjC.h:1095
method_iterator meth_end() const
Definition: DeclObjC.h:1023
static bool classof(const Decl *D)
Definition: DeclObjC.h:1111
instprop_range instance_properties() const
Definition: DeclObjC.h:981
llvm::iterator_range< classmeth_iterator > classmeth_range
Definition: DeclObjC.h:1047
ObjCPropertyDecl * FindPropertyDeclaration(const IdentifierInfo *PropertyId, ObjCPropertyQueryKind QueryKind) const
FindPropertyDeclaration - Finds declaration of the property given its name in 'PropertyId' and return...
Definition: DeclObjC.cpp:250
void setAtEndRange(SourceRange atEnd)
Definition: DeclObjC.h:1104
virtual void collectPropertiesToImplement(PropertyMap &PM) const
This routine collects list of properties to be implemented in the class.
Definition: DeclObjC.h:1093
instmeth_iterator instmeth_begin() const
Definition: DeclObjC.h:1036
classprop_range class_properties() const
Definition: DeclObjC.h:998
instprop_iterator instprop_begin() const
Definition: DeclObjC.h:985
llvm::SmallVector< ObjCPropertyDecl *, 8 > PropertyDeclOrder
Definition: DeclObjC.h:1088
static ObjCContainerDecl * castFromDeclContext(const DeclContext *DC)
Definition: DeclObjC.h:1122
ObjCMethodDecl * getClassMethod(Selector Sel, bool AllowHidden=false) const
Definition: DeclObjC.h:1070
prop_range properties() const
Definition: DeclObjC.h:966
filtered_decl_iterator< ObjCMethodDecl, &ObjCMethodDecl::isClassMethod > classmeth_iterator
Definition: DeclObjC.h:1046
classmeth_range class_methods() const
Definition: DeclObjC.h:1049
static bool classofKind(Kind K)
Definition: DeclObjC.h:1113
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
Definition: DeclObjC.h:1106
ObjCMethodDecl * getInstanceMethod(Selector Sel, bool AllowHidden=false) const
Definition: DeclObjC.h:1065
llvm::iterator_range< instmeth_iterator > instmeth_range
Definition: DeclObjC.h:1030
bool HasUserDeclaredSetterMethod(const ObjCPropertyDecl *P) const
This routine returns 'true' if a user declared setter method was found in the class,...
Definition: DeclObjC.cpp:125
specific_decl_iterator< ObjCPropertyImplDecl > propimpl_iterator
Definition: DeclObjC.h:2508
void addPropertyImplementation(ObjCPropertyImplDecl *property)
Definition: DeclObjC.cpp:2208
void addClassMethod(ObjCMethodDecl *method)
Definition: DeclObjC.h:2495
llvm::iterator_range< specific_decl_iterator< ObjCPropertyImplDecl > > propimpl_range
Definition: DeclObjC.h:2510
ObjCImplDecl(Kind DK, DeclContext *DC, ObjCInterfaceDecl *classInterface, const IdentifierInfo *Id, SourceLocation nameLoc, SourceLocation atStartLoc)
Definition: DeclObjC.h:2478
ObjCInterfaceDecl * getClassInterface()
Definition: DeclObjC.h:2486
propimpl_iterator propimpl_begin() const
Definition: DeclObjC.h:2516
static bool classof(const Decl *D)
Definition: DeclObjC.h:2524
propimpl_range property_impls() const
Definition: DeclObjC.h:2512
void setClassInterface(ObjCInterfaceDecl *IFace)
Definition: DeclObjC.cpp:2214
ObjCPropertyImplDecl * FindPropertyImplDecl(IdentifierInfo *propertyId, ObjCPropertyQueryKind queryKind) const
FindPropertyImplDecl - This method looks up a previous ObjCPropertyImplDecl added to the list of thos...
Definition: DeclObjC.cpp:2245
propimpl_iterator propimpl_end() const
Definition: DeclObjC.h:2520
const ObjCInterfaceDecl * getClassInterface() const
Definition: DeclObjC.h:2485
ObjCPropertyImplDecl * FindPropertyImplIvarDecl(IdentifierInfo *ivarId) const
FindPropertyImplIvarDecl - This method lookup the ivar in the list of properties implemented in this ...
Definition: DeclObjC.cpp:2233
static bool classofKind(Kind K)
Definition: DeclObjC.h:2526
void addInstanceMethod(ObjCMethodDecl *method)
Definition: DeclObjC.h:2489
ObjCImplementationDecl - Represents a class definition - this is where method definitions are specifi...
Definition: DeclObjC.h:2596
void setNumIvarInitializers(unsigned numNumIvarInitializers)
Definition: DeclObjC.h:2691
static bool classofKind(Kind K)
Definition: DeclObjC.h:2767
init_iterator init_end()
init_end() - Retrieve an iterator past the last initializer.
Definition: DeclObjC.h:2677
SourceLocation getIvarRBraceLoc() const
Definition: DeclObjC.h:2743
bool hasNonZeroConstructors() const
Do any of the ivars of this class (not counting its base classes) require construction other than zer...
Definition: DeclObjC.h:2701
llvm::iterator_range< init_iterator > init_range
Definition: DeclObjC.h:2658
static ObjCImplementationDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID)
Definition: DeclObjC.cpp:2300
IdentifierInfo * getIdentifier() const
getIdentifier - Get the identifier that names the class interface associated with this implementation...
Definition: DeclObjC.h:2711
StringRef getObjCRuntimeNameAsString() const
Produce a name to be used for class's metadata.
Definition: DeclObjC.cpp:1621
CXXCtorInitializer *const * init_const_iterator
init_const_iterator - Iterates through the ivar initializer list.
Definition: DeclObjC.h:2656
std::string getNameAsString() const
Get the name of the class associated with this interface.
Definition: DeclObjC.h:2728
SourceLocation getSuperClassLoc() const
Definition: DeclObjC.h:2736
specific_decl_iterator< ObjCIvarDecl > ivar_iterator
Definition: DeclObjC.h:2745
ivar_range ivars() const
Definition: DeclObjC.h:2748
llvm::iterator_range< specific_decl_iterator< ObjCIvarDecl > > ivar_range
Definition: DeclObjC.h:2746
ivar_iterator ivar_begin() const
Definition: DeclObjC.h:2750
void setIvarLBraceLoc(SourceLocation Loc)
Definition: DeclObjC.h:2740
ObjCInterfaceDecl * getSuperClass()
Definition: DeclObjC.h:2735
StringRef getName() const
getName - Get the name of identifier for the class interface associated with this implementation as a...
Definition: DeclObjC.h:2720
void setSuperClass(ObjCInterfaceDecl *superCls)
Definition: DeclObjC.h:2738
bool hasDestructors() const
Do any of the ivars of this class (not counting its base classes) require non-trivial destruction?
Definition: DeclObjC.h:2706
llvm::iterator_range< init_const_iterator > init_const_range
Definition: DeclObjC.h:2659
init_iterator init_begin()
init_begin() - Retrieve an iterator to the first initializer.
Definition: DeclObjC.h:2668
unsigned getNumIvarInitializers() const
getNumArgs - Number of ivars which must be initialized.
Definition: DeclObjC.h:2687
void setIvarInitializers(ASTContext &C, CXXCtorInitializer **initializers, unsigned numInitializers)
Definition: DeclObjC.cpp:2305
init_const_range inits() const
Definition: DeclObjC.h:2663
ivar_iterator ivar_end() const
Definition: DeclObjC.h:2754
unsigned ivar_size() const
Definition: DeclObjC.h:2758
void setIvarRBraceLoc(SourceLocation Loc)
Definition: DeclObjC.h:2742
init_const_iterator init_end() const
end() - Retrieve an iterator past the last initializer.
Definition: DeclObjC.h:2682
static bool classof(const Decl *D)
Definition: DeclObjC.h:2766
const ObjCInterfaceDecl * getSuperClass() const
Definition: DeclObjC.h:2734
SourceLocation getIvarLBraceLoc() const
Definition: DeclObjC.h:2741
void setHasDestructors(bool val)
Definition: DeclObjC.h:2707
void setHasNonZeroConstructors(bool val)
Definition: DeclObjC.h:2702
Iterator that walks over the list of categories, filtering out those that do not meet specific criter...
Definition: DeclObjC.h:1597
filtered_category_iterator(ObjCCategoryDecl *Current)
Definition: DeclObjC.h:1610
friend bool operator!=(filtered_category_iterator X, filtered_category_iterator Y)
Definition: DeclObjC.h:1631
filtered_category_iterator operator++(int)
Definition: DeclObjC.h:1620
friend bool operator==(filtered_category_iterator X, filtered_category_iterator Y)
Definition: DeclObjC.h:1626
filtered_category_iterator & operator++()
Definition: DeclObjC.h:2936
Represents an ObjC class declaration.
Definition: DeclObjC.h:1153
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:442
bool declaresOrInheritsDesignatedInitializers() const
Returns true if this interface decl declares a designated initializer or it inherites one from its su...
Definition: DeclObjC.h:1328
ObjCTypeParamList * getTypeParamList() const
Retrieve the type parameters of this class.
Definition: DeclObjC.cpp:322
all_protocol_iterator all_referenced_protocol_end() const
Definition: DeclObjC.h:1434
ObjCMethodDecl * lookupClassMethod(Selector Sel) const
Lookup a class method for a given selector.
Definition: DeclObjC.h:1851
ObjCInterfaceDecl * lookupInheritedClass(const IdentifierInfo *ICName)
lookupInheritedClass - This method returns ObjCInterfaceDecl * of the super class whose name is passe...
Definition: DeclObjC.cpp:668
ivar_iterator ivar_end() const
Definition: DeclObjC.h:1460
ObjCPropertyDecl * FindPropertyVisibleInPrimaryClass(const IdentifierInfo *PropertyId, ObjCPropertyQueryKind QueryKind) const
FindPropertyVisibleInPrimaryClass - Finds declaration of the property with name 'PropertyId' in the p...
Definition: DeclObjC.cpp:382
static bool classofKind(Kind K)
Definition: DeclObjC.h:1925
ObjCMethodDecl * getCategoryMethod(Selector Sel, bool isInstance) const
Definition: DeclObjC.h:1350
const ObjCInterfaceDecl * getCanonicalDecl() const
Definition: DeclObjC.h:1915
llvm::iterator_range< specific_decl_iterator< ObjCIvarDecl > > ivar_range
Definition: DeclObjC.h:1448
unsigned ivar_size() const
Definition: DeclObjC.h:1468
ObjCIvarDecl * lookupInstanceVariable(IdentifierInfo *IVarName, ObjCInterfaceDecl *&ClassDeclared)
Definition: DeclObjC.cpp:637
void setCategoryListRaw(ObjCCategoryDecl *category)
Set the raw pointer to the start of the category/extension list.
Definition: DeclObjC.h:1797
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:1484
bool known_extensions_empty() const
Determine whether the known-extensions list is empty.
Definition: DeclObjC.h:1778
visible_categories_iterator visible_categories_begin() const
Retrieve an iterator to the beginning of the visible-categories list.
Definition: DeclObjC.h:1659
bool hasDefinition() const
Determine whether this class has been defined.
Definition: DeclObjC.h:1527
ivar_range ivars() const
Definition: DeclObjC.h:1450
all_protocol_range all_referenced_protocols() const
Definition: DeclObjC.h:1416
visible_extensions_range visible_extensions() const
Definition: DeclObjC.h:1722
bool isImplicitInterfaceDecl() const
isImplicitInterfaceDecl - check that this is an implicitly declared ObjCInterfaceDecl node.
Definition: DeclObjC.h:1892
ObjCTypeParamList * getTypeParamListAsWritten() const
Retrieve the type parameters written on this particular declaration of the class.
Definition: DeclObjC.h:1302
protocol_loc_iterator protocol_loc_end() const
Definition: DeclObjC.h:1402
ObjCIvarDecl * all_declared_ivar_begin()
all_declared_ivar_begin - return first ivar declared in this class, its extensions and its implementa...
Definition: DeclObjC.cpp:1672
ObjCCategoryDecl * FindCategoryDeclaration(const IdentifierInfo *CategoryId) const
FindCategoryDeclaration - Finds category declaration in the list of categories for this class and ret...
Definition: DeclObjC.cpp:1748
llvm::iterator_range< all_protocol_iterator > all_protocol_range
Definition: DeclObjC.h:1414
protocol_loc_iterator protocol_loc_begin() const
Definition: DeclObjC.h:1391
ivar_iterator ivar_begin() const
Definition: DeclObjC.h:1452
protocol_range protocols() const
Definition: DeclObjC.h:1358
ObjCMethodDecl * lookupInstanceMethod(Selector Sel) const
Lookup an instance method for a given selector.
Definition: DeclObjC.h:1846
unsigned getODRHash()
Get precomputed ODRHash or add a new one.
Definition: DeclObjC.cpp:791
bool ivar_empty() const
Definition: DeclObjC.h:1472
void setImplementation(ObjCImplementationDecl *ImplD)
Definition: DeclObjC.cpp:1642
protocol_loc_range protocol_locs() const
Definition: DeclObjC.h:1387
known_categories_range known_categories() const
Definition: DeclObjC.h:1686
const ObjCInterfaceDecl * isObjCRequiresPropertyDefs() const
isObjCRequiresPropertyDefs - Checks that a class or one of its super classes must not be auto-synthes...
Definition: DeclObjC.cpp:432
void setSuperClass(TypeSourceInfo *superClass)
Definition: DeclObjC.h:1587
protocol_iterator protocol_end() const
Definition: DeclObjC.h:1373
SourceLocation getSuperClassLoc() const
Retrieve the starting location of the superclass.
Definition: DeclObjC.cpp:372
all_protocol_iterator all_referenced_protocol_begin() const
Definition: DeclObjC.h:1421
ObjCMethodDecl * lookupPrivateClassMethod(const Selector &Sel)
Definition: DeclObjC.h:1861
void setExternallyCompleted()
Indicate that this Objective-C class is complete, but that the external AST source will be responsibl...
Definition: DeclObjC.cpp:1587
ObjCList< ObjCProtocolDecl >::iterator all_protocol_iterator
Definition: DeclObjC.h:1413
ObjCMethodDecl * getCategoryClassMethod(Selector Sel) const
Definition: DeclObjC.cpp:1775
ObjCCategoryDecl * getCategoryListRaw() const
Retrieve the raw pointer to the start of the category/extension list.
Definition: DeclObjC.h:1784
ObjCIvarDecl * lookupInstanceVariable(IdentifierInfo *IVarName)
Definition: DeclObjC.h:1831
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:1717
llvm::iterator_range< visible_categories_iterator > visible_categories_range
Definition: DeclObjC.h:1650
const ObjCIvarDecl * all_declared_ivar_begin() const
Definition: DeclObjC.h:1475
const ObjCInterfaceDecl * getDefinition() const
Retrieve the definition of this class, or NULL if this class has been forward-declared (with @class) ...
Definition: DeclObjC.h:1548
bool isThisDeclarationADefinition() const
Determine whether this particular declaration of this class is actually also a definition.
Definition: DeclObjC.h:1522
friend class ASTContext
Definition: DeclObjC.h:1154
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:1868
ObjCMethodDecl * lookupPrivateMethod(const Selector &Sel, bool Instance=true) const
Lookup a method in the classes implementation hierarchy.
Definition: DeclObjC.cpp:756
const ObjCProtocolList & getReferencedProtocols() const
Definition: DeclObjC.h:1332
void setTypeParamList(ObjCTypeParamList *TPL)
Set the type parameters of this class.
Definition: DeclObjC.cpp:343
filtered_category_iterator< isVisibleCategory > visible_categories_iterator
Iterator that walks over the list of categories and extensions that are visible, i....
Definition: DeclObjC.h:1647
ObjCMethodDecl * getCategoryInstanceMethod(Selector Sel) const
Definition: DeclObjC.cpp:1765
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:699
llvm::iterator_range< visible_extensions_iterator > visible_extensions_range
Definition: DeclObjC.h:1720
llvm::iterator_range< known_categories_iterator > known_categories_range
Definition: DeclObjC.h:1684
ObjCProtocolList::iterator protocol_iterator
Definition: DeclObjC.h:1355
ObjCProtocolDecl * lookupNestedProtocol(IdentifierInfo *Name)
Definition: DeclObjC.cpp:687
const Type * getTypeForDecl() const
Definition: DeclObjC.h:1918
bool ClassImplementsProtocol(ObjCProtocolDecl *lProto, bool lookupCategory, bool RHSIsQualifiedID=false)
ClassImplementsProtocol - Checks that 'lProto' protocol has been implemented in IDecl class,...
Definition: DeclObjC.cpp:1788
void setTypeForDecl(const Type *TD) const
Definition: DeclObjC.h:1919
llvm::iterator_range< protocol_loc_iterator > protocol_loc_range
Definition: DeclObjC.h:1385
StringRef getObjCRuntimeNameAsString() const
Produce a name to be used for class's metadata.
Definition: DeclObjC.cpp:1613
const ObjCObjectType * getSuperClassType() const
Retrieve the superclass type.
Definition: DeclObjC.h:1564
known_categories_iterator known_categories_end() const
Retrieve an iterator to the end of the known-categories list.
Definition: DeclObjC.h:1698
filtered_category_iterator< isKnownExtension > known_extensions_iterator
Iterator that walks over all of the known extensions.
Definition: DeclObjC.h:1757
ObjCImplementationDecl * getImplementation() const
Definition: DeclObjC.cpp:1629
static bool classof(const Decl *D)
Definition: DeclObjC.h:1924
static ObjCInterfaceDecl * CreateDeserialized(const ASTContext &C, GlobalDeclID ID)
Definition: DeclObjC.cpp:1554
bool hasDesignatedInitializers() const
Returns true if this interface decl contains at least one initializer marked with the 'objc_designate...
Definition: DeclObjC.cpp:1602
SourceLocation getEndOfDefinitionLoc() const
Definition: DeclObjC.h:1877
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
Definition: DeclObjC.h:1306
llvm::iterator_range< protocol_iterator > protocol_range
Definition: DeclObjC.h:1356
llvm::iterator_range< known_extensions_iterator > known_extensions_range
Definition: DeclObjC.h:1759
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:1682
void getDesignatedInitializers(llvm::SmallVectorImpl< const ObjCMethodDecl * > &Methods) const
Returns the designated initializers for the interface.
Definition: DeclObjC.cpp:548
visible_extensions_iterator visible_extensions_end() const
Retrieve an iterator to the end of the visible-extensions list.
Definition: DeclObjC.h:1734
bool visible_extensions_empty() const
Determine whether the visible-extensions list is empty.
Definition: DeclObjC.h:1739
protocol_iterator protocol_begin() const
Definition: DeclObjC.h:1362
ObjCProtocolList::loc_iterator protocol_loc_iterator
Definition: DeclObjC.h:1384
known_extensions_iterator known_extensions_end() const
Retrieve an iterator to the end of the known-extensions list.
Definition: DeclObjC.h:1773
bool visible_categories_empty() const
Determine whether the visible-categories list is empty.
Definition: DeclObjC.h:1669
void setEndOfDefinitionLoc(SourceLocation LE)
Definition: DeclObjC.h:1884
known_categories_iterator known_categories_begin() const
Retrieve an iterator to the beginning of the known-categories list.
Definition: DeclObjC.h:1693
void startDefinition()
Starts the definition of this Objective-C class, taking it from a forward declaration (@class) to a d...
Definition: DeclObjC.cpp:616
void collectPropertiesToImplement(PropertyMap &PM) const override
This routine collects list of properties to be implemented in the class.
Definition: DeclObjC.cpp:405
redeclarable_base::redecl_range redecl_range
Definition: DeclObjC.h:1903
bool known_categories_empty() const
Determine whether the known-categories list is empty.
Definition: DeclObjC.h:1703
bool isArcWeakrefUnavailable() const
isArcWeakrefUnavailable - Checks for a class or one of its super classes to be incompatible with __we...
Definition: DeclObjC.cpp:422
known_extensions_iterator known_extensions_begin() const
Retrieve an iterator to the beginning of the known-extensions list.
Definition: DeclObjC.h:1768
visible_categories_range visible_categories() const
Definition: DeclObjC.h:1652
ObjCInterfaceDecl * getCanonicalDecl() override
Retrieves the canonical declaration of this Objective-C class.
Definition: DeclObjC.h:1914
ObjCInterfaceDecl * getSuperClass() const
Definition: DeclObjC.cpp:352
ObjCInterfaceDecl * getDefinition()
Retrieve the definition of this class, or NULL if this class has been forward-declared (with @class) ...
Definition: DeclObjC.h:1541
TypeSourceInfo * getSuperClassTInfo() const
Definition: DeclObjC.h:1572
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:570
void startDuplicateDefinitionForComparison()
Starts the definition without sharing it with other redeclarations.
Definition: DeclObjC.cpp:626
void setHasDesignatedInitializers()
Indicate that this interface decl contains at least one initializer marked with the 'objc_designated_...
Definition: DeclObjC.cpp:1595
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:1809
specific_decl_iterator< ObjCIvarDecl > ivar_iterator
Definition: DeclObjC.h:1447
redeclarable_base::redecl_iterator redecl_iterator
Definition: DeclObjC.h:1904
void setIvarList(ObjCIvarDecl *ivar)
Definition: DeclObjC.h:1480
void mergeDuplicateDefinitionWithCommon(const ObjCInterfaceDecl *Definition)
Definition: DeclObjC.cpp:632
visible_categories_iterator visible_categories_end() const
Retrieve an iterator to the end of the visible-categories list.
Definition: DeclObjC.h:1664
visible_extensions_iterator visible_extensions_begin() const
Retrieve an iterator to the beginning of the visible-extensions list.
Definition: DeclObjC.h:1729
known_extensions_range known_extensions() const
Definition: DeclObjC.h:1761
ObjCIvarDecl - Represents an ObjC instance variable.
Definition: DeclObjC.h:1951
AccessControl getAccessControl() const
Definition: DeclObjC.h:1999
void setAccessControl(AccessControl ac)
Definition: DeclObjC.h:1997
static bool classof(const Decl *D)
Definition: DeclObjC.h:2013
void setNextIvar(ObjCIvarDecl *ivar)
Definition: DeclObjC.h:1988
bool getSynthesize() const
Definition: DeclObjC.h:2006
ObjCInterfaceDecl * getContainingInterface()
Return the class interface that this ivar is logically contained in; this is either the interface whe...
Definition: DeclObjC.cpp:1875
void setSynthesize(bool synth)
Definition: DeclObjC.h:2005
ObjCIvarDecl * getNextIvar()
Definition: DeclObjC.h:1986
const ObjCIvarDecl * getNextIvar() const
Definition: DeclObjC.h:1987
static ObjCIvarDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID)
Definition: DeclObjC.cpp:1869
const ObjCInterfaceDecl * getContainingInterface() const
Definition: DeclObjC.h:1982
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:1899
AccessControl getCanonicalAccessControl() const
Definition: DeclObjC.h:2001
const ObjCIvarDecl * getCanonicalDecl() const
Definition: DeclObjC.h:1993
ObjCIvarDecl * getCanonicalDecl() override
Retrieves the canonical declaration of this field.
Definition: DeclObjC.h:1990
static bool classofKind(Kind K)
Definition: DeclObjC.h:2014
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
static ObjCMethodDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID)
Definition: DeclObjC.cpp:865
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
const ObjCCategoryDecl * getCategory() const
Definition: DeclObjC.h:323
Represents a class type in Objective C.
Definition: Type.h:7145
Represents one property declaration in an Objective-C interface.
Definition: DeclObjC.h:730
void setAtLoc(SourceLocation L)
Definition: DeclObjC.h:796
bool isAtomic() const
isAtomic - Return true if the property is atomic.
Definition: DeclObjC.h:842
ObjCPropertyQueryKind getQueryKind() const
Definition: DeclObjC.h:859
bool isClassProperty() const
Definition: DeclObjC.h:854
void setPropertyImplementation(PropertyControl pc)
Definition: DeclObjC.h:907
void setSetterName(Selector Sel, SourceLocation Loc=SourceLocation())
Definition: DeclObjC.h:895
SourceLocation getGetterNameLoc() const
Definition: DeclObjC.h:885
QualType getUsageType(QualType objectType) const
Retrieve the type when this property is used with a specific base object type.
Definition: DeclObjC.cpp:2370
ObjCMethodDecl * getGetterMethodDecl() const
Definition: DeclObjC.h:900
bool isRetaining() const
isRetaining - Return true if the property retains its value.
Definition: DeclObjC.h:847
bool isInstanceProperty() const
Definition: DeclObjC.h:853
ObjCMethodDecl * getSetterMethodDecl() const
Definition: DeclObjC.h:903
static ObjCPropertyQueryKind getQueryKind(bool isClassProperty)
Definition: DeclObjC.h:864
SourceLocation getSetterNameLoc() const
Definition: DeclObjC.h:893
SourceLocation getAtLoc() const
Definition: DeclObjC.h:795
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
Definition: DeclObjC.h:927
void setPropertyAttributes(ObjCPropertyAttribute::Kind PRVal)
Definition: DeclObjC.h:818
bool isReadOnly() const
isReadOnly - Return true iff the property has a setter.
Definition: DeclObjC.h:837
ObjCIvarDecl * getPropertyIvarDecl() const
Definition: DeclObjC.h:923
static ObjCPropertyDecl * findPropertyDecl(const DeclContext *DC, const IdentifierInfo *propertyID, ObjCPropertyQueryKind queryKind)
Lookup a property by name in the specified DeclContext.
Definition: DeclObjC.cpp:179
bool isOptional() const
Definition: DeclObjC.h:915
static ObjCPropertyDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID)
Definition: DeclObjC.cpp:2363
bool isDirectProperty() const
Definition: DeclObjC.cpp:2375
SetterKind getSetterKind() const
getSetterKind - Return the method used for doing assignment in the property setter.
Definition: DeclObjC.h:872
static bool classofKind(Kind K)
Definition: DeclObjC.h:940
Selector getSetterName() const
Definition: DeclObjC.h:892
TypeSourceInfo * getTypeSourceInfo() const
Definition: DeclObjC.h:801
QualType getType() const
Definition: DeclObjC.h:803
void setPropertyAttributesAsWritten(ObjCPropertyAttribute::Kind PRVal)
Definition: DeclObjC.h:830
void overwritePropertyAttributes(unsigned PRVal)
Definition: DeclObjC.h:822
Selector getGetterName() const
Definition: DeclObjC.h:884
static bool classof(const Decl *D)
Definition: DeclObjC.h:939
void setLParenLoc(SourceLocation L)
Definition: DeclObjC.h:799
void setPropertyIvarDecl(ObjCIvarDecl *Ivar)
Definition: DeclObjC.h:919
SourceLocation getLParenLoc() const
Definition: DeclObjC.h:798
void setSetterMethodDecl(ObjCMethodDecl *gDecl)
Definition: DeclObjC.h:904
ObjCPropertyAttribute::Kind getPropertyAttributesAsWritten() const
Definition: DeclObjC.h:826
IdentifierInfo * getDefaultSynthIvarName(ASTContext &Ctx) const
Get the default name of the synthesized ivar.
Definition: DeclObjC.cpp:227
ObjCPropertyAttribute::Kind getPropertyAttributes() const
Definition: DeclObjC.h:814
void setType(QualType T, TypeSourceInfo *TSI)
Definition: DeclObjC.h:805
void setGetterName(Selector Sel, SourceLocation Loc=SourceLocation())
Definition: DeclObjC.h:887
PropertyControl getPropertyImplementation() const
Definition: DeclObjC.h:911
void setGetterMethodDecl(ObjCMethodDecl *gDecl)
Definition: DeclObjC.h:901
ObjCPropertyImplDecl - Represents implementation declaration of a property in a class or category imp...
Definition: DeclObjC.h:2804
ObjCIvarDecl * getPropertyIvarDecl() const
Definition: DeclObjC.h:2878
SourceLocation getPropertyIvarDeclLoc() const
Definition: DeclObjC.h:2881
void setPropertyIvarDecl(ObjCIvarDecl *Ivar, SourceLocation IvarLoc)
Definition: DeclObjC.h:2883
Kind getPropertyImplementation() const
Definition: DeclObjC.h:2874
bool isIvarNameSpecified() const
For @synthesize, returns true if an ivar name was explicitly specified.
Definition: DeclObjC.h:2896
void setSetterMethodDecl(ObjCMethodDecl *MD)
Definition: DeclObjC.h:2904
Expr * getSetterCXXAssignment() const
Definition: DeclObjC.h:2914
ObjCPropertyDecl * getPropertyDecl() const
Definition: DeclObjC.h:2869
Expr * getGetterCXXConstructor() const
Definition: DeclObjC.h:2906
void setSetterCXXAssignment(Expr *setterCXXAssignment)
Definition: DeclObjC.h:2918
static ObjCPropertyImplDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID)
Definition: DeclObjC.cpp:2397
ObjCMethodDecl * getSetterMethodDecl() const
Definition: DeclObjC.h:2903
static bool classof(const Decl *D)
Definition: DeclObjC.h:2922
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: DeclObjC.h:2866
static bool classofKind(Decl::Kind K)
Definition: DeclObjC.h:2923
void setGetterMethodDecl(ObjCMethodDecl *MD)
Definition: DeclObjC.h:2901
void setAtLoc(SourceLocation Loc)
Definition: DeclObjC.h:2867
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
Definition: DeclObjC.cpp:2403
void setPropertyDecl(ObjCPropertyDecl *Prop)
Definition: DeclObjC.h:2872
void setGetterCXXConstructor(Expr *getterCXXConstructor)
Definition: DeclObjC.h:2910
ObjCMethodDecl * getGetterMethodDecl() const
Definition: DeclObjC.h:2900
Represents an Objective-C protocol declaration.
Definition: DeclObjC.h:2083
void mergeDuplicateDefinitionWithCommon(const ObjCProtocolDecl *Definition)
Definition: DeclObjC.cpp:2037
void startDuplicateDefinitionForComparison()
Starts the definition without sharing it with other redeclarations.
Definition: DeclObjC.cpp:2031
bool hasDefinition() const
Determine whether this protocol has a definition.
Definition: DeclObjC.h:2237
bool isThisDeclarationADefinition() const
Determine whether this particular declaration is also the definition.
Definition: DeclObjC.h:2260
ObjCMethodDecl * lookupMethod(Selector Sel, bool isInstance) const
Definition: DeclObjC.cpp:1997
const ObjCProtocolList & getReferencedProtocols() const
Definition: DeclObjC.h:2152
const ObjCProtocolDecl * getDefinition() const
Retrieve the definition of this protocol, if any.
Definition: DeclObjC.h:2254
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:2208
redeclarable_base::redecl_iterator redecl_iterator
Definition: DeclObjC.h:2286
protocol_loc_iterator protocol_loc_end() const
Definition: DeclObjC.h:2192
ObjCProtocolDecl * getDefinition()
Retrieve the definition of this protocol, if any.
Definition: DeclObjC.h:2249
StringRef getObjCRuntimeNameAsString() const
Produce a name to be used for protocol's metadata.
Definition: DeclObjC.cpp:2077
protocol_loc_range protocol_locs() const
Definition: DeclObjC.h:2181
llvm::iterator_range< protocol_loc_iterator > protocol_loc_range
Definition: DeclObjC.h:2179
llvm::iterator_range< protocol_iterator > protocol_range
Definition: DeclObjC.h:2158
void getImpliedProtocols(llvm::DenseSet< const ObjCProtocolDecl * > &IPs) const
Get the set of all protocols implied by this protocols inheritance hierarchy.
Definition: DeclObjC.cpp:1965
void startDefinition()
Starts the definition of this Objective-C protocol.
Definition: DeclObjC.cpp:2023
static ObjCProtocolDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID)
Definition: DeclObjC.cpp:1952
bool isNonRuntimeProtocol() const
This is true iff the protocol is tagged with the objc_non_runtime_protocol attribute.
Definition: DeclObjC.cpp:1961
ObjCProtocolList::iterator protocol_iterator
Definition: DeclObjC.h:2157
void collectInheritedProtocolProperties(const ObjCPropertyDecl *Property, ProtocolPropertySet &PS, PropertyDeclOrder &PO) const
Definition: DeclObjC.cpp:2056
static bool classof(const Decl *D)
Definition: DeclObjC.h:2308
protocol_iterator protocol_begin() const
Definition: DeclObjC.h:2164
ObjCProtocolList::loc_iterator protocol_loc_iterator
Definition: DeclObjC.h:2178
ObjCProtocolDecl * lookupProtocolNamed(IdentifierInfo *PName)
Definition: DeclObjC.cpp:1982
ObjCProtocolDecl * getCanonicalDecl() override
Retrieves the canonical declaration of this Objective-C protocol.
Definition: DeclObjC.h:2296
protocol_range protocols() const
Definition: DeclObjC.h:2160
ObjCMethodDecl * lookupClassMethod(Selector Sel) const
Definition: DeclObjC.h:2232
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
Definition: DeclObjC.h:2278
const ObjCProtocolDecl * getCanonicalDecl() const
Definition: DeclObjC.h:2297
static bool classofKind(Kind K)
Definition: DeclObjC.h:2309
unsigned getODRHash()
Get precomputed ODRHash or add a new one.
Definition: DeclObjC.cpp:2084
void collectPropertiesToImplement(PropertyMap &PM) const override
This routine collects list of properties to be implemented in the class.
Definition: DeclObjC.cpp:2042
redeclarable_base::redecl_range redecl_range
Definition: DeclObjC.h:2285
unsigned protocol_size() const
Definition: DeclObjC.h:2199
protocol_iterator protocol_end() const
Definition: DeclObjC.h:2171
protocol_loc_iterator protocol_loc_begin() const
Definition: DeclObjC.h:2185
ObjCMethodDecl * lookupInstanceMethod(Selector Sel) const
Definition: DeclObjC.h:2228
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:647
unsigned getIndex() const
Retrieve the index into its type parameter list.
Definition: DeclObjC.h:636
bool hasExplicitBound() const
Whether this type parameter has an explicitly-written type bound, e.g., "T : NSView".
Definition: DeclObjC.h:640
SourceLocation getColonLoc() const
Retrieve the location of the ':' separating the type parameter name from the explicitly-specified bou...
Definition: DeclObjC.h:644
ObjCTypeParamVariance getVariance() const
Determine the variance of this type parameter.
Definition: DeclObjC.h:623
static bool classofKind(Kind K)
Definition: DeclObjC.h:648
void setVariance(ObjCTypeParamVariance variance)
Set the variance of this type parameter.
Definition: DeclObjC.h:628
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:633
static ObjCTypeParamDecl * CreateDeserialized(ASTContext &ctx, GlobalDeclID ID)
Definition: DeclObjC.cpp:1489
Stores a list of Objective-C type parameters for a parameterized class or a category/extension thereo...
Definition: DeclObjC.h:659
SourceRange getSourceRange() const
Definition: DeclObjC.h:711
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:686
const_iterator begin() const
Definition: DeclObjC.h:691
ObjCTypeParamDecl * front() const
Definition: DeclObjC.h:699
const_iterator end() const
Definition: DeclObjC.h:695
SourceLocation getRAngleLoc() const
Definition: DeclObjC.h:710
ObjCTypeParamDecl *const * const_iterator
Definition: DeclObjC.h:689
ObjCTypeParamDecl * back() const
Definition: DeclObjC.h:704
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:709
Represents a parameter to a function.
Definition: Decl.h:1722
A (possibly-)qualified type.
Definition: Type.h:941
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:217
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:205
llvm::iterator_range< redecl_iterator > redecl_range
Definition: Redeclarable.h:293
ObjCInterfaceDecl * getMostRecentDecl()
Returns the most recent (re)declaration of this declaration.
Definition: Redeclarable.h:227
bool isFirstDecl() const
True if this is the first declaration in its redeclaration chain.
Definition: Redeclarable.h:224
redecl_iterator redecls_begin() const
Definition: Redeclarable.h:303
redecl_range redecls() const
Returns an iterator range for all the redeclarations of the same decl.
Definition: Redeclarable.h:297
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:7721
The base class of the type hierarchy.
Definition: Type.h:1829
bool isBlockPointerType() const
Definition: Type.h:8017
const T * castAs() const
Member-template castAs<specific type>.
Definition: Type.h:8607
Base class for declarations which introduce a typedef-name.
Definition: Decl.h:3409
QualType getType() const
Definition: Decl.h:678
The JSON file list parser is used to communicate input to InstallAPI.
@ Create
'create' 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:718
@ ICIS_NoInit
No in-class initializer.
Definition: Specifiers.h:272
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 ...
const FunctionProtoType * T
bool declaresSameEntity(const Decl *D1, const Decl *D2)
Determine whether two declarations declare the same entity.
Definition: DeclBase.h:1275
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.
@ NumObjCPropertyAttrsBits
Number of bits fitting all the property attributes.
#define true
Definition: stdbool.h:25
#define false
Definition: stdbool.h:26
bool isValid() const
Whether this pointer is non-NULL.
QualType operator()(const ParmVarDecl *PD) const
Definition: DeclObjC.h:393