clang 19.0.0git
DeclObjC.h
Go to the documentation of this file.
1//===- DeclObjC.h - Classes for representing declarations -------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This file defines the DeclObjC interface and subclasses.
10//
11//===----------------------------------------------------------------------===//
12
13#ifndef LLVM_CLANG_AST_DECLOBJC_H
14#define LLVM_CLANG_AST_DECLOBJC_H
15
16#include "clang/AST/Decl.h"
17#include "clang/AST/DeclBase.h"
22#include "clang/AST/Type.h"
24#include "clang/Basic/LLVM.h"
27#include "llvm/ADT/ArrayRef.h"
28#include "llvm/ADT/DenseSet.h"
29#include "llvm/ADT/MapVector.h"
30#include "llvm/ADT/PointerIntPair.h"
31#include "llvm/ADT/STLExtras.h"
32#include "llvm/ADT/StringRef.h"
33#include "llvm/ADT/iterator_range.h"
34#include "llvm/Support/Compiler.h"
35#include "llvm/Support/TrailingObjects.h"
36#include <cassert>
37#include <cstddef>
38#include <cstdint>
39#include <iterator>
40#include <string>
41#include <utility>
42
43namespace clang {
44
45class ASTContext;
46class CompoundStmt;
47class CXXCtorInitializer;
48class Expr;
49class ObjCCategoryDecl;
50class ObjCCategoryImplDecl;
51class ObjCImplementationDecl;
52class ObjCInterfaceDecl;
53class ObjCIvarDecl;
54class ObjCPropertyDecl;
55class ObjCPropertyImplDecl;
56class ObjCProtocolDecl;
57class Stmt;
58
60protected:
61 /// List is an array of pointers to objects that are not owned by this object.
62 void **List = nullptr;
63 unsigned NumElts = 0;
64
65public:
66 ObjCListBase() = default;
67 ObjCListBase(const ObjCListBase &) = delete;
69
70 unsigned size() const { return NumElts; }
71 bool empty() const { return NumElts == 0; }
72
73protected:
74 void set(void *const* InList, unsigned Elts, ASTContext &Ctx);
75};
76
77/// ObjCList - This is a simple template class used to hold various lists of
78/// decls etc, which is heavily used by the ObjC front-end. This only use case
79/// this supports is setting the list all at once and then reading elements out
80/// of it.
81template <typename T>
82class ObjCList : public ObjCListBase {
83public:
84 void set(T* const* InList, unsigned Elts, ASTContext &Ctx) {
85 ObjCListBase::set(reinterpret_cast<void*const*>(InList), Elts, Ctx);
86 }
87
88 using iterator = T* const *;
89
90 iterator begin() const { return (iterator)List; }
91 iterator end() const { return (iterator)List+NumElts; }
92
93 T* operator[](unsigned Idx) const {
94 assert(Idx < NumElts && "Invalid access");
95 return (T*)List[Idx];
96 }
97};
98
99/// A list of Objective-C protocols, along with the source
100/// locations at which they were referenced.
101class ObjCProtocolList : public ObjCList<ObjCProtocolDecl> {
102 SourceLocation *Locations = nullptr;
103
105
106public:
107 ObjCProtocolList() = default;
108
110
111 loc_iterator loc_begin() const { return Locations; }
112 loc_iterator loc_end() const { return Locations + size(); }
113
114 void set(ObjCProtocolDecl* const* InList, unsigned Elts,
115 const SourceLocation *Locs, ASTContext &Ctx);
116};
117
119
120/// ObjCMethodDecl - Represents an instance or class method declaration.
121/// ObjC methods can be declared within 4 contexts: class interfaces,
122/// categories, protocols, and class implementations. While C++ member
123/// functions leverage C syntax, Objective-C method syntax is modeled after
124/// Smalltalk (using colons to specify argument types/expressions).
125/// Here are some brief examples:
126///
127/// Setter/getter instance methods:
128/// - (void)setMenu:(NSMenu *)menu;
129/// - (NSMenu *)menu;
130///
131/// Instance method that takes 2 NSView arguments:
132/// - (void)replaceSubview:(NSView *)oldView with:(NSView *)newView;
133///
134/// Getter class method:
135/// + (NSMenu *)defaultMenu;
136///
137/// A selector represents a unique name for a method. The selector names for
138/// the above methods are setMenu:, menu, replaceSubview:with:, and defaultMenu.
139///
140class ObjCMethodDecl : public NamedDecl, public DeclContext {
141 // This class stores some data in DeclContext::ObjCMethodDeclBits
142 // to save some space. Use the provided accessors to access it.
143
144 /// Return type of this method.
145 QualType MethodDeclType;
146
147 /// Type source information for the return type.
148 TypeSourceInfo *ReturnTInfo;
149
150 /// Array of ParmVarDecls for the formal parameters of this method
151 /// and optionally followed by selector locations.
152 void *ParamsAndSelLocs = nullptr;
153 unsigned NumParams = 0;
154
155 /// List of attributes for this method declaration.
156 SourceLocation DeclEndLoc; // the location of the ';' or '{'.
157
158 /// The following are only used for method definitions, null otherwise.
159 LazyDeclStmtPtr Body;
160
161 /// SelfDecl - Decl for the implicit self parameter. This is lazily
162 /// constructed by createImplicitParams.
163 ImplicitParamDecl *SelfDecl = nullptr;
164
165 /// CmdDecl - Decl for the implicit _cmd parameter. This is lazily
166 /// constructed by createImplicitParams.
167 ImplicitParamDecl *CmdDecl = nullptr;
168
170 SourceLocation beginLoc, SourceLocation endLoc, Selector SelInfo,
171 QualType T, TypeSourceInfo *ReturnTInfo, DeclContext *contextDecl,
172 bool isInstance = true, bool isVariadic = false,
173 bool isPropertyAccessor = false, bool isSynthesizedAccessorStub = false,
174 bool isImplicitlyDeclared = false, bool isDefined = false,
176 bool HasRelatedResultType = false);
177
178 SelectorLocationsKind getSelLocsKind() const {
179 return static_cast<SelectorLocationsKind>(ObjCMethodDeclBits.SelLocsKind);
180 }
181
182 void setSelLocsKind(SelectorLocationsKind Kind) {
183 ObjCMethodDeclBits.SelLocsKind = Kind;
184 }
185
186 bool hasStandardSelLocs() const {
187 return getSelLocsKind() != SelLoc_NonStandard;
188 }
189
190 /// Get a pointer to the stored selector identifiers locations array.
191 /// No locations will be stored if HasStandardSelLocs is true.
192 SourceLocation *getStoredSelLocs() {
193 return reinterpret_cast<SourceLocation *>(getParams() + NumParams);
194 }
195 const SourceLocation *getStoredSelLocs() const {
196 return reinterpret_cast<const SourceLocation *>(getParams() + NumParams);
197 }
198
199 /// Get a pointer to the stored selector identifiers locations array.
200 /// No locations will be stored if HasStandardSelLocs is true.
201 ParmVarDecl **getParams() {
202 return reinterpret_cast<ParmVarDecl **>(ParamsAndSelLocs);
203 }
204 const ParmVarDecl *const *getParams() const {
205 return reinterpret_cast<const ParmVarDecl *const *>(ParamsAndSelLocs);
206 }
207
208 /// Get the number of stored selector identifiers locations.
209 /// No locations will be stored if HasStandardSelLocs is true.
210 unsigned getNumStoredSelLocs() const {
211 if (hasStandardSelLocs())
212 return 0;
213 return getNumSelectorLocs();
214 }
215
216 void setParamsAndSelLocs(ASTContext &C,
219
220 /// A definition will return its interface declaration.
221 /// An interface declaration will return its definition.
222 /// Otherwise it will return itself.
223 ObjCMethodDecl *getNextRedeclarationImpl() override;
224
225public:
226 friend class ASTDeclReader;
227 friend class ASTDeclWriter;
228
229 static ObjCMethodDecl *
231 Selector SelInfo, QualType T, TypeSourceInfo *ReturnTInfo,
232 DeclContext *contextDecl, bool isInstance = true,
233 bool isVariadic = false, bool isPropertyAccessor = false,
234 bool isSynthesizedAccessorStub = false,
235 bool isImplicitlyDeclared = false, bool isDefined = false,
237 bool HasRelatedResultType = false);
238
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 ASTDeclReader;
1751 friend class ASTDeclWriter;
1752 friend class ASTReader;
1753
1754 /// Iterator that walks over all of the known extensions.
1758 llvm::iterator_range<known_extensions_iterator>;
1759
1763 }
1764
1765 /// Retrieve an iterator to the beginning of the known-extensions
1766 /// list.
1769 }
1770
1771 /// Retrieve an iterator to the end of the known-extensions list.
1774 }
1775
1776 /// Determine whether the known-extensions list is empty.
1779 }
1780
1781 /// Retrieve the raw pointer to the start of the category/extension
1782 /// list.
1784 // FIXME: Should make sure no callers ever do this.
1785 if (!hasDefinition())
1786 return nullptr;
1787
1788 if (data().ExternallyCompleted)
1789 LoadExternalDefinition();
1790
1791 return data().CategoryList;
1792 }
1793
1794 /// Set the raw pointer to the start of the category/extension
1795 /// list.
1797 data().CategoryList = category;
1798 }
1799
1802 ObjCPropertyQueryKind QueryKind) const;
1803
1804 void collectPropertiesToImplement(PropertyMap &PM) const override;
1805
1806 /// isSuperClassOf - Return true if this class is the specified class or is a
1807 /// super class of the specified interface class.
1808 bool isSuperClassOf(const ObjCInterfaceDecl *I) const {
1809 // If RHS is derived from LHS it is OK; else it is not OK.
1810 while (I != nullptr) {
1811 if (declaresSameEntity(this, I))
1812 return true;
1813
1814 I = I->getSuperClass();
1815 }
1816 return false;
1817 }
1818
1819 /// isArcWeakrefUnavailable - Checks for a class or one of its super classes
1820 /// to be incompatible with __weak references. Returns true if it is.
1821 bool isArcWeakrefUnavailable() const;
1822
1823 /// isObjCRequiresPropertyDefs - Checks that a class or one of its super
1824 /// classes must not be auto-synthesized. Returns class decl. if it must not
1825 /// be; 0, otherwise.
1827
1829 ObjCInterfaceDecl *&ClassDeclared);
1831 ObjCInterfaceDecl *ClassDeclared;
1832 return lookupInstanceVariable(IVarName, ClassDeclared);
1833 }
1834
1836
1837 // Lookup a method. First, we search locally. If a method isn't
1838 // found, we search referenced protocols and class categories.
1839 ObjCMethodDecl *lookupMethod(Selector Sel, bool isInstance,
1840 bool shallowCategoryLookup = false,
1841 bool followSuper = true,
1842 const ObjCCategoryDecl *C = nullptr) const;
1843
1844 /// Lookup an instance method for a given selector.
1846 return lookupMethod(Sel, true/*isInstance*/);
1847 }
1848
1849 /// Lookup a class method for a given selector.
1851 return lookupMethod(Sel, false/*isInstance*/);
1852 }
1853
1855
1856 /// Lookup a method in the classes implementation hierarchy.
1858 bool Instance=true) const;
1859
1861 return lookupPrivateMethod(Sel, false);
1862 }
1863
1864 /// Lookup a setter or getter in the class hierarchy,
1865 /// including in all categories except for category passed
1866 /// as argument.
1868 const ObjCCategoryDecl *Cat,
1869 bool IsClassProperty) const {
1870 return lookupMethod(Sel, !IsClassProperty/*isInstance*/,
1871 false/*shallowCategoryLookup*/,
1872 true /* followsSuper */,
1873 Cat);
1874 }
1875
1877 if (!hasDefinition())
1878 return getLocation();
1879
1880 return data().EndLoc;
1881 }
1882
1883 void setEndOfDefinitionLoc(SourceLocation LE) { data().EndLoc = LE; }
1884
1885 /// Retrieve the starting location of the superclass.
1887
1888 /// isImplicitInterfaceDecl - check that this is an implicitly declared
1889 /// ObjCInterfaceDecl node. This is for legacy objective-c \@implementation
1890 /// declaration without an \@interface declaration.
1892 return hasDefinition() ? data().Definition->isImplicit() : isImplicit();
1893 }
1894
1895 /// ClassImplementsProtocol - Checks that 'lProto' protocol
1896 /// has been implemented in IDecl class, its super class or categories (if
1897 /// lookupCategory is true).
1899 bool lookupCategory,
1900 bool RHSIsQualifiedID = false);
1901
1903 using redecl_iterator = redeclarable_base::redecl_iterator;
1904
1911
1912 /// Retrieves the canonical declaration of this Objective-C class.
1915
1916 // Low-level accessor
1917 const Type *getTypeForDecl() const { return TypeForDecl; }
1918 void setTypeForDecl(const Type *TD) const { TypeForDecl = TD; }
1919
1920 /// Get precomputed ODRHash or add a new one.
1921 unsigned getODRHash();
1922
1923 static bool classof(const Decl *D) { return classofKind(D->getKind()); }
1924 static bool classofKind(Kind K) { return K == ObjCInterface; }
1925
1926private:
1927 /// True if a valid hash is stored in ODRHash.
1928 bool hasODRHash() const;
1929 void setHasODRHash(bool HasHash);
1930
1931 const ObjCInterfaceDecl *findInterfaceWithDesignatedInitializers() const;
1932 bool inheritsDesignatedInitializers() const;
1933};
1934
1935/// ObjCIvarDecl - Represents an ObjC instance variable. In general, ObjC
1936/// instance variables are identical to C. The only exception is Objective-C
1937/// supports C++ style access control. For example:
1938///
1939/// \@interface IvarExample : NSObject
1940/// {
1941/// id defaultToProtected;
1942/// \@public:
1943/// id canBePublic; // same as C++.
1944/// \@protected:
1945/// id canBeProtected; // same as C++.
1946/// \@package:
1947/// id canBePackage; // framework visibility (not available in C++).
1948/// }
1949///
1950class ObjCIvarDecl : public FieldDecl {
1951 void anchor() override;
1952
1953public:
1957
1958private:
1960 SourceLocation IdLoc, const IdentifierInfo *Id, QualType T,
1961 TypeSourceInfo *TInfo, AccessControl ac, Expr *BW,
1962 bool synthesized)
1963 : FieldDecl(ObjCIvar, DC, StartLoc, IdLoc, Id, T, TInfo, BW,
1964 /*Mutable=*/false, /*HasInit=*/ICIS_NoInit),
1965 DeclAccess(ac), Synthesized(synthesized) {}
1966
1967public:
1968 static ObjCIvarDecl *Create(ASTContext &C, ObjCContainerDecl *DC,
1969 SourceLocation StartLoc, SourceLocation IdLoc,
1970 const IdentifierInfo *Id, QualType T,
1971 TypeSourceInfo *TInfo, AccessControl ac,
1972 Expr *BW = nullptr, bool synthesized = false);
1973
1974 static ObjCIvarDecl *CreateDeserialized(ASTContext &C, GlobalDeclID ID);
1975
1976 /// Return the class interface that this ivar is logically contained
1977 /// in; this is either the interface where the ivar was declared, or the
1978 /// interface the ivar is conceptually a part of in the case of synthesized
1979 /// ivars.
1980 ObjCInterfaceDecl *getContainingInterface();
1982 return const_cast<ObjCIvarDecl *>(this)->getContainingInterface();
1983 }
1984
1985 ObjCIvarDecl *getNextIvar() { return NextIvar; }
1986 const ObjCIvarDecl *getNextIvar() const { return NextIvar; }
1987 void setNextIvar(ObjCIvarDecl *ivar) { NextIvar = ivar; }
1988
1990 return cast<ObjCIvarDecl>(FieldDecl::getCanonicalDecl());
1991 }
1993 return const_cast<ObjCIvarDecl *>(this)->getCanonicalDecl();
1994 }
1995
1996 void setAccessControl(AccessControl ac) { DeclAccess = ac; }
1997
1998 AccessControl getAccessControl() const { return AccessControl(DeclAccess); }
1999
2001 return DeclAccess == None ? Protected : AccessControl(DeclAccess);
2002 }
2003
2004 void setSynthesize(bool synth) { Synthesized = synth; }
2005 bool getSynthesize() const { return Synthesized; }
2006
2007 /// Retrieve the type of this instance variable when viewed as a member of a
2008 /// specific object type.
2009 QualType getUsageType(QualType objectType) const;
2010
2011 // Implement isa/cast/dyncast/etc.
2012 static bool classof(const Decl *D) { return classofKind(D->getKind()); }
2013 static bool classofKind(Kind K) { return K == ObjCIvar; }
2014
2015private:
2016 /// NextIvar - Next Ivar in the list of ivars declared in class; class's
2017 /// extensions and class's implementation
2018 ObjCIvarDecl *NextIvar = nullptr;
2019
2020 // NOTE: VC++ treats enums as signed, avoid using the AccessControl enum
2021 LLVM_PREFERRED_TYPE(AccessControl)
2022 unsigned DeclAccess : 3;
2023 LLVM_PREFERRED_TYPE(bool)
2024 unsigned Synthesized : 1;
2025};
2026
2027/// Represents a field declaration created by an \@defs(...).
2031 QualType T, Expr *BW)
2032 : FieldDecl(ObjCAtDefsField, DC, StartLoc, IdLoc, Id, T,
2033 /*TInfo=*/nullptr, // FIXME: Do ObjCAtDefs have declarators ?
2034 BW, /*Mutable=*/false, /*HasInit=*/ICIS_NoInit) {}
2035
2036 void anchor() override;
2037
2038public:
2040 SourceLocation StartLoc,
2042 QualType T, Expr *BW);
2043
2046
2047 // Implement isa/cast/dyncast/etc.
2048 static bool classof(const Decl *D) { return classofKind(D->getKind()); }
2049 static bool classofKind(Kind K) { return K == ObjCAtDefsField; }
2050};
2051
2052/// Represents an Objective-C protocol declaration.
2053///
2054/// Objective-C protocols declare a pure abstract type (i.e., no instance
2055/// variables are permitted). Protocols originally drew inspiration from
2056/// C++ pure virtual functions (a C++ feature with nice semantics and lousy
2057/// syntax:-). Here is an example:
2058///
2059/// \code
2060/// \@protocol NSDraggingInfo <refproto1, refproto2>
2061/// - (NSWindow *)draggingDestinationWindow;
2062/// - (NSImage *)draggedImage;
2063/// \@end
2064/// \endcode
2065///
2066/// This says that NSDraggingInfo requires two methods and requires everything
2067/// that the two "referenced protocols" 'refproto1' and 'refproto2' require as
2068/// well.
2069///
2070/// \code
2071/// \@interface ImplementsNSDraggingInfo : NSObject <NSDraggingInfo>
2072/// \@end
2073/// \endcode
2074///
2075/// ObjC protocols inspired Java interfaces. Unlike Java, ObjC classes and
2076/// protocols are in distinct namespaces. For example, Cocoa defines both
2077/// an NSObject protocol and class (which isn't allowed in Java). As a result,
2078/// protocols are referenced using angle brackets as follows:
2079///
2080/// id <NSDraggingInfo> anyObjectThatImplementsNSDraggingInfo;
2082 public Redeclarable<ObjCProtocolDecl> {
2083 struct DefinitionData {
2084 // The declaration that defines this protocol.
2085 ObjCProtocolDecl *Definition;
2086
2087 /// Referenced protocols
2088 ObjCProtocolList ReferencedProtocols;
2089
2090 /// Tracks whether a ODR hash has been computed for this protocol.
2091 LLVM_PREFERRED_TYPE(bool)
2092 unsigned HasODRHash : 1;
2093
2094 /// A hash of parts of the class to help in ODR checking.
2095 unsigned ODRHash = 0;
2096 };
2097
2098 /// Contains a pointer to the data associated with this class,
2099 /// which will be NULL if this class has not yet been defined.
2100 ///
2101 /// The bit indicates when we don't need to check for out-of-date
2102 /// declarations. It will be set unless modules are enabled.
2103 llvm::PointerIntPair<DefinitionData *, 1, bool> Data;
2104
2106 SourceLocation nameLoc, SourceLocation atStartLoc,
2107 ObjCProtocolDecl *PrevDecl);
2108
2109 void anchor() override;
2110
2111 DefinitionData &data() const {
2112 assert(Data.getPointer() && "Objective-C protocol has no definition!");
2113 return *Data.getPointer();
2114 }
2115
2116 void allocateDefinitionData();
2117
2119
2120 ObjCProtocolDecl *getNextRedeclarationImpl() override {
2121 return getNextRedeclaration();
2122 }
2123
2124 ObjCProtocolDecl *getPreviousDeclImpl() override {
2125 return getPreviousDecl();
2126 }
2127
2128 ObjCProtocolDecl *getMostRecentDeclImpl() override {
2129 return getMostRecentDecl();
2130 }
2131
2132 /// True if a valid hash is stored in ODRHash.
2133 bool hasODRHash() const;
2134 void setHasODRHash(bool HasHash);
2135
2136public:
2137 friend class ASTDeclReader;
2138 friend class ASTDeclWriter;
2139 friend class ASTReader;
2140 friend class ODRDiagsEmitter;
2141
2144 SourceLocation nameLoc,
2145 SourceLocation atStartLoc,
2146 ObjCProtocolDecl *PrevDecl);
2147
2149
2151 assert(hasDefinition() && "No definition available!");
2152 return data().ReferencedProtocols;
2153 }
2154
2156 using protocol_range = llvm::iterator_range<protocol_iterator>;
2157
2160 }
2161
2163 if (!hasDefinition())
2164 return protocol_iterator();
2165
2166 return data().ReferencedProtocols.begin();
2167 }
2168
2170 if (!hasDefinition())
2171 return protocol_iterator();
2172
2173 return data().ReferencedProtocols.end();
2174 }
2175
2177 using protocol_loc_range = llvm::iterator_range<protocol_loc_iterator>;
2178
2181 }
2182
2184 if (!hasDefinition())
2185 return protocol_loc_iterator();
2186
2187 return data().ReferencedProtocols.loc_begin();
2188 }
2189
2191 if (!hasDefinition())
2192 return protocol_loc_iterator();
2193
2194 return data().ReferencedProtocols.loc_end();
2195 }
2196
2197 unsigned protocol_size() const {
2198 if (!hasDefinition())
2199 return 0;
2200
2201 return data().ReferencedProtocols.size();
2202 }
2203
2204 /// setProtocolList - Set the list of protocols that this interface
2205 /// implements.
2206 void setProtocolList(ObjCProtocolDecl *const*List, unsigned Num,
2207 const SourceLocation *Locs, ASTContext &C) {
2208 assert(hasDefinition() && "Protocol is not defined");
2209 data().ReferencedProtocols.set(List, Num, Locs, C);
2210 }
2211
2212 /// This is true iff the protocol is tagged with the
2213 /// `objc_non_runtime_protocol` attribute.
2214 bool isNonRuntimeProtocol() const;
2215
2216 /// Get the set of all protocols implied by this protocols inheritance
2217 /// hierarchy.
2219
2221
2222 // Lookup a method. First, we search locally. If a method isn't
2223 // found, we search referenced protocols and class categories.
2224 ObjCMethodDecl *lookupMethod(Selector Sel, bool isInstance) const;
2225
2227 return lookupMethod(Sel, true/*isInstance*/);
2228 }
2229
2231 return lookupMethod(Sel, false/*isInstance*/);
2232 }
2233
2234 /// Determine whether this protocol has a definition.
2235 bool hasDefinition() const {
2236 // If the name of this protocol is out-of-date, bring it up-to-date, which
2237 // might bring in a definition.
2238 // Note: a null value indicates that we don't have a definition and that
2239 // modules are enabled.
2240 if (!Data.getOpaqueValue())
2242
2243 return Data.getPointer();
2244 }
2245
2246 /// Retrieve the definition of this protocol, if any.
2248 return hasDefinition()? Data.getPointer()->Definition : nullptr;
2249 }
2250
2251 /// Retrieve the definition of this protocol, if any.
2253 return hasDefinition()? Data.getPointer()->Definition : nullptr;
2254 }
2255
2256 /// Determine whether this particular declaration is also the
2257 /// definition.
2259 return getDefinition() == this;
2260 }
2261
2262 /// Starts the definition of this Objective-C protocol.
2263 void startDefinition();
2264
2265 /// Starts the definition without sharing it with other redeclarations.
2266 /// Such definition shouldn't be used for anything but only to compare if
2267 /// a duplicate is compatible with previous definition or if it is
2268 /// a distinct duplicate.
2271
2272 /// Produce a name to be used for protocol's metadata. It comes either via
2273 /// objc_runtime_name attribute or protocol name.
2274 StringRef getObjCRuntimeNameAsString() const;
2275
2276 SourceRange getSourceRange() const override LLVM_READONLY {
2279
2281 }
2282
2284 using redecl_iterator = redeclarable_base::redecl_iterator;
2285
2292
2293 /// Retrieves the canonical declaration of this Objective-C protocol.
2296
2297 void collectPropertiesToImplement(PropertyMap &PM) const override;
2298
2301 PropertyDeclOrder &PO) const;
2302
2303 /// Get precomputed ODRHash or add a new one.
2304 unsigned getODRHash();
2305
2306 static bool classof(const Decl *D) { return classofKind(D->getKind()); }
2307 static bool classofKind(Kind K) { return K == ObjCProtocol; }
2308};
2309
2310/// ObjCCategoryDecl - Represents a category declaration. A category allows
2311/// you to add methods to an existing class (without subclassing or modifying
2312/// the original class interface or implementation:-). Categories don't allow
2313/// you to add instance data. The following example adds "myMethod" to all
2314/// NSView's within a process:
2315///
2316/// \@interface NSView (MyViewMethods)
2317/// - myMethod;
2318/// \@end
2319///
2320/// Categories also allow you to split the implementation of a class across
2321/// several files (a feature more naturally supported in C++).
2322///
2323/// Categories were originally inspired by dynamic languages such as Common
2324/// Lisp and Smalltalk. More traditional class-based languages (C++, Java)
2325/// don't support this level of dynamism, which is both powerful and dangerous.
2327 /// Interface belonging to this category
2328 ObjCInterfaceDecl *ClassInterface;
2329
2330 /// The type parameters associated with this category, if any.
2331 ObjCTypeParamList *TypeParamList = nullptr;
2332
2333 /// referenced protocols in this category.
2334 ObjCProtocolList ReferencedProtocols;
2335
2336 /// Next category belonging to this class.
2337 /// FIXME: this should not be a singly-linked list. Move storage elsewhere.
2338 ObjCCategoryDecl *NextClassCategory = nullptr;
2339
2340 /// The location of the category name in this declaration.
2341 SourceLocation CategoryNameLoc;
2342
2343 /// class extension may have private ivars.
2344 SourceLocation IvarLBraceLoc;
2345 SourceLocation IvarRBraceLoc;
2346
2348 SourceLocation ClassNameLoc, SourceLocation CategoryNameLoc,
2349 const IdentifierInfo *Id, ObjCInterfaceDecl *IDecl,
2350 ObjCTypeParamList *typeParamList,
2351 SourceLocation IvarLBraceLoc = SourceLocation(),
2352 SourceLocation IvarRBraceLoc = SourceLocation());
2353
2354 void anchor() override;
2355
2356public:
2357 friend class ASTDeclReader;
2358 friend class ASTDeclWriter;
2359
2360 static ObjCCategoryDecl *
2362 SourceLocation ClassNameLoc, SourceLocation CategoryNameLoc,
2363 const IdentifierInfo *Id, ObjCInterfaceDecl *IDecl,
2364 ObjCTypeParamList *typeParamList,
2365 SourceLocation IvarLBraceLoc = SourceLocation(),
2366 SourceLocation IvarRBraceLoc = SourceLocation());
2368
2369 ObjCInterfaceDecl *getClassInterface() { return ClassInterface; }
2370 const ObjCInterfaceDecl *getClassInterface() const { return ClassInterface; }
2371
2372 /// Retrieve the type parameter list associated with this category or
2373 /// extension.
2374 ObjCTypeParamList *getTypeParamList() const { return TypeParamList; }
2375
2376 /// Set the type parameters of this category.
2377 ///
2378 /// This function is used by the AST importer, which must import the type
2379 /// parameters after creating their DeclContext to avoid loops.
2381
2382
2385
2386 /// setProtocolList - Set the list of protocols that this interface
2387 /// implements.
2388 void setProtocolList(ObjCProtocolDecl *const*List, unsigned Num,
2389 const SourceLocation *Locs, ASTContext &C) {
2390 ReferencedProtocols.set(List, Num, Locs, C);
2391 }
2392
2394 return ReferencedProtocols;
2395 }
2396
2398 using protocol_range = llvm::iterator_range<protocol_iterator>;
2399
2402 }
2403
2405 return ReferencedProtocols.begin();
2406 }
2407
2408 protocol_iterator protocol_end() const { return ReferencedProtocols.end(); }
2409 unsigned protocol_size() const { return ReferencedProtocols.size(); }
2410
2412 using protocol_loc_range = llvm::iterator_range<protocol_loc_iterator>;
2413
2416 }
2417
2419 return ReferencedProtocols.loc_begin();
2420 }
2421
2423 return ReferencedProtocols.loc_end();
2424 }
2425
2426 ObjCCategoryDecl *getNextClassCategory() const { return NextClassCategory; }
2427
2428 /// Retrieve the pointer to the next stored category (or extension),
2429 /// which may be hidden.
2431 return NextClassCategory;
2432 }
2433
2434 bool IsClassExtension() const { return getIdentifier() == nullptr; }
2435
2437 using ivar_range = llvm::iterator_range<specific_decl_iterator<ObjCIvarDecl>>;
2438
2440
2442 return ivar_iterator(decls_begin());
2443 }
2444
2446 return ivar_iterator(decls_end());
2447 }
2448
2449 unsigned ivar_size() const {
2450 return std::distance(ivar_begin(), ivar_end());
2451 }
2452
2453 bool ivar_empty() const {
2454 return ivar_begin() == ivar_end();
2455 }
2456
2457 SourceLocation getCategoryNameLoc() const { return CategoryNameLoc; }
2458 void setCategoryNameLoc(SourceLocation Loc) { CategoryNameLoc = Loc; }
2459
2460 void setIvarLBraceLoc(SourceLocation Loc) { IvarLBraceLoc = Loc; }
2461 SourceLocation getIvarLBraceLoc() const { return IvarLBraceLoc; }
2462 void setIvarRBraceLoc(SourceLocation Loc) { IvarRBraceLoc = Loc; }
2463 SourceLocation getIvarRBraceLoc() const { return IvarRBraceLoc; }
2464
2465 static bool classof(const Decl *D) { return classofKind(D->getKind()); }
2466 static bool classofKind(Kind K) { return K == ObjCCategory; }
2467};
2468
2470 /// Class interface for this class/category implementation
2471 ObjCInterfaceDecl *ClassInterface;
2472
2473 void anchor() override;
2474
2475protected:
2477 const IdentifierInfo *Id, SourceLocation nameLoc,
2478 SourceLocation atStartLoc)
2479 : ObjCContainerDecl(DK, DC, Id, nameLoc, atStartLoc),
2480 ClassInterface(classInterface) {}
2481
2482public:
2483 const ObjCInterfaceDecl *getClassInterface() const { return ClassInterface; }
2484 ObjCInterfaceDecl *getClassInterface() { return ClassInterface; }
2486
2488 // FIXME: Context should be set correctly before we get here.
2489 method->setLexicalDeclContext(this);
2490 addDecl(method);
2491 }
2492
2494 // FIXME: Context should be set correctly before we get here.
2495 method->setLexicalDeclContext(this);
2496 addDecl(method);
2497 }
2498
2500
2502 ObjCPropertyQueryKind queryKind) const;
2504
2505 // Iterator access to properties.
2508 llvm::iterator_range<specific_decl_iterator<ObjCPropertyImplDecl>>;
2509
2512 }
2513
2516 }
2517
2519 return propimpl_iterator(decls_end());
2520 }
2521
2522 static bool classof(const Decl *D) { return classofKind(D->getKind()); }
2523
2524 static bool classofKind(Kind K) {
2525 return K >= firstObjCImpl && K <= lastObjCImpl;
2526 }
2527};
2528
2529/// ObjCCategoryImplDecl - An object of this class encapsulates a category
2530/// \@implementation declaration. If a category class has declaration of a
2531/// property, its implementation must be specified in the category's
2532/// \@implementation declaration. Example:
2533/// \@interface I \@end
2534/// \@interface I(CATEGORY)
2535/// \@property int p1, d1;
2536/// \@end
2537/// \@implementation I(CATEGORY)
2538/// \@dynamic p1,d1;
2539/// \@end
2540///
2541/// ObjCCategoryImplDecl
2543 // Category name location
2544 SourceLocation CategoryNameLoc;
2545
2547 ObjCInterfaceDecl *classInterface,
2548 SourceLocation nameLoc, SourceLocation atStartLoc,
2549 SourceLocation CategoryNameLoc)
2550 : ObjCImplDecl(ObjCCategoryImpl, DC, classInterface, Id, nameLoc,
2551 atStartLoc),
2552 CategoryNameLoc(CategoryNameLoc) {}
2553
2554 void anchor() override;
2555
2556public:
2557 friend class ASTDeclReader;
2558 friend class ASTDeclWriter;
2559
2560 static ObjCCategoryImplDecl *
2562 ObjCInterfaceDecl *classInterface, SourceLocation nameLoc,
2563 SourceLocation atStartLoc, SourceLocation CategoryNameLoc);
2566
2568
2569 SourceLocation getCategoryNameLoc() const { return CategoryNameLoc; }
2570
2571 static bool classof(const Decl *D) { return classofKind(D->getKind()); }
2572 static bool classofKind(Kind K) { return K == ObjCCategoryImpl;}
2573};
2574
2575raw_ostream &operator<<(raw_ostream &OS, const ObjCCategoryImplDecl &CID);
2576
2577/// ObjCImplementationDecl - Represents a class definition - this is where
2578/// method definitions are specified. For example:
2579///
2580/// @code
2581/// \@implementation MyClass
2582/// - (void)myMethod { /* do something */ }
2583/// \@end
2584/// @endcode
2585///
2586/// In a non-fragile runtime, instance variables can appear in the class
2587/// interface, class extensions (nameless categories), and in the implementation
2588/// itself, as well as being synthesized as backing storage for properties.
2589///
2590/// In a fragile runtime, instance variables are specified in the class
2591/// interface, \em not in the implementation. Nevertheless (for legacy reasons),
2592/// we allow instance variables to be specified in the implementation. When
2593/// specified, they need to be \em identical to the interface.
2595 /// Implementation Class's super class.
2596 ObjCInterfaceDecl *SuperClass;
2597 SourceLocation SuperLoc;
2598
2599 /// \@implementation may have private ivars.
2600 SourceLocation IvarLBraceLoc;
2601 SourceLocation IvarRBraceLoc;
2602
2603 /// Support for ivar initialization.
2604 /// The arguments used to initialize the ivars
2605 LazyCXXCtorInitializersPtr IvarInitializers;
2606 unsigned NumIvarInitializers = 0;
2607
2608 /// Do the ivars of this class require initialization other than
2609 /// zero-initialization?
2610 LLVM_PREFERRED_TYPE(bool)
2611 bool HasNonZeroConstructors : 1;
2612
2613 /// Do the ivars of this class require non-trivial destruction?
2614 LLVM_PREFERRED_TYPE(bool)
2615 bool HasDestructors : 1;
2616
2618 ObjCInterfaceDecl *classInterface,
2619 ObjCInterfaceDecl *superDecl,
2620 SourceLocation nameLoc, SourceLocation atStartLoc,
2621 SourceLocation superLoc = SourceLocation(),
2622 SourceLocation IvarLBraceLoc=SourceLocation(),
2623 SourceLocation IvarRBraceLoc=SourceLocation())
2624 : ObjCImplDecl(ObjCImplementation, DC, classInterface,
2625 classInterface ? classInterface->getIdentifier()
2626 : nullptr,
2627 nameLoc, atStartLoc),
2628 SuperClass(superDecl), SuperLoc(superLoc),
2629 IvarLBraceLoc(IvarLBraceLoc), IvarRBraceLoc(IvarRBraceLoc),
2630 HasNonZeroConstructors(false), HasDestructors(false) {}
2631
2632 void anchor() override;
2633
2634public:
2635 friend class ASTDeclReader;
2636 friend class ASTDeclWriter;
2637
2639 ObjCInterfaceDecl *classInterface,
2640 ObjCInterfaceDecl *superDecl,
2641 SourceLocation nameLoc,
2642 SourceLocation atStartLoc,
2643 SourceLocation superLoc = SourceLocation(),
2644 SourceLocation IvarLBraceLoc=SourceLocation(),
2645 SourceLocation IvarRBraceLoc=SourceLocation());
2646
2649
2650 /// init_iterator - Iterates through the ivar initializer list.
2652
2653 /// init_const_iterator - Iterates through the ivar initializer list.
2655
2656 using init_range = llvm::iterator_range<init_iterator>;
2657 using init_const_range = llvm::iterator_range<init_const_iterator>;
2658
2660
2663 }
2664
2665 /// init_begin() - Retrieve an iterator to the first initializer.
2667 const auto *ConstThis = this;
2668 return const_cast<init_iterator>(ConstThis->init_begin());
2669 }
2670
2671 /// begin() - Retrieve an iterator to the first initializer.
2673
2674 /// init_end() - Retrieve an iterator past the last initializer.
2676 return init_begin() + NumIvarInitializers;
2677 }
2678
2679 /// end() - Retrieve an iterator past the last initializer.
2681 return init_begin() + NumIvarInitializers;
2682 }
2683
2684 /// getNumArgs - Number of ivars which must be initialized.
2685 unsigned getNumIvarInitializers() const {
2686 return NumIvarInitializers;
2687 }
2688
2689 void setNumIvarInitializers(unsigned numNumIvarInitializers) {
2690 NumIvarInitializers = numNumIvarInitializers;
2691 }
2692
2694 CXXCtorInitializer ** initializers,
2695 unsigned numInitializers);
2696
2697 /// Do any of the ivars of this class (not counting its base classes)
2698 /// require construction other than zero-initialization?
2699 bool hasNonZeroConstructors() const { return HasNonZeroConstructors; }
2700 void setHasNonZeroConstructors(bool val) { HasNonZeroConstructors = val; }
2701
2702 /// Do any of the ivars of this class (not counting its base classes)
2703 /// require non-trivial destruction?
2704 bool hasDestructors() const { return HasDestructors; }
2705 void setHasDestructors(bool val) { HasDestructors = val; }
2706
2707 /// getIdentifier - Get the identifier that names the class
2708 /// interface associated with this implementation.
2710 return getClassInterface()->getIdentifier();
2711 }
2712
2713 /// getName - Get the name of identifier for the class interface associated
2714 /// with this implementation as a StringRef.
2715 //
2716 // FIXME: This is a bad API, we are hiding NamedDecl::getName with a different
2717 // meaning.
2718 StringRef getName() const {
2719 assert(getIdentifier() && "Name is not a simple identifier");
2720 return getIdentifier()->getName();
2721 }
2722
2723 /// Get the name of the class associated with this interface.
2724 //
2725 // FIXME: Move to StringRef API.
2726 std::string getNameAsString() const { return std::string(getName()); }
2727
2728 /// Produce a name to be used for class's metadata. It comes either via
2729 /// class's objc_runtime_name attribute or class name.
2730 StringRef getObjCRuntimeNameAsString() const;
2731
2732 const ObjCInterfaceDecl *getSuperClass() const { return SuperClass; }
2733 ObjCInterfaceDecl *getSuperClass() { return SuperClass; }
2734 SourceLocation getSuperClassLoc() const { return SuperLoc; }
2735
2736 void setSuperClass(ObjCInterfaceDecl * superCls) { SuperClass = superCls; }
2737
2738 void setIvarLBraceLoc(SourceLocation Loc) { IvarLBraceLoc = Loc; }
2739 SourceLocation getIvarLBraceLoc() const { return IvarLBraceLoc; }
2740 void setIvarRBraceLoc(SourceLocation Loc) { IvarRBraceLoc = Loc; }
2741 SourceLocation getIvarRBraceLoc() const { return IvarRBraceLoc; }
2742
2744 using ivar_range = llvm::iterator_range<specific_decl_iterator<ObjCIvarDecl>>;
2745
2747
2749 return ivar_iterator(decls_begin());
2750 }
2751
2753 return ivar_iterator(decls_end());
2754 }
2755
2756 unsigned ivar_size() const {
2757 return std::distance(ivar_begin(), ivar_end());
2758 }
2759
2760 bool ivar_empty() const {
2761 return ivar_begin() == ivar_end();
2762 }
2763
2764 static bool classof(const Decl *D) { return classofKind(D->getKind()); }
2765 static bool classofKind(Kind K) { return K == ObjCImplementation; }
2766};
2767
2768raw_ostream &operator<<(raw_ostream &OS, const ObjCImplementationDecl &ID);
2769
2770/// ObjCCompatibleAliasDecl - Represents alias of a class. This alias is
2771/// declared as \@compatibility_alias alias class.
2773 /// Class that this is an alias of.
2774 ObjCInterfaceDecl *AliasedClass;
2775
2777 ObjCInterfaceDecl* aliasedClass)
2778 : NamedDecl(ObjCCompatibleAlias, DC, L, Id), AliasedClass(aliasedClass) {}
2779
2780 void anchor() override;
2781
2782public:
2785 ObjCInterfaceDecl* aliasedClass);
2786
2789
2790 const ObjCInterfaceDecl *getClassInterface() const { return AliasedClass; }
2791 ObjCInterfaceDecl *getClassInterface() { return AliasedClass; }
2792 void setClassInterface(ObjCInterfaceDecl *D) { AliasedClass = D; }
2793
2794 static bool classof(const Decl *D) { return classofKind(D->getKind()); }
2795 static bool classofKind(Kind K) { return K == ObjCCompatibleAlias; }
2796};
2797
2798/// ObjCPropertyImplDecl - Represents implementation declaration of a property
2799/// in a class or category implementation block. For example:
2800/// \@synthesize prop1 = ivar1;
2801///
2803public:
2804 enum Kind {
2806 Dynamic
2808
2809private:
2810 SourceLocation AtLoc; // location of \@synthesize or \@dynamic
2811
2812 /// For \@synthesize, the location of the ivar, if it was written in
2813 /// the source code.
2814 ///
2815 /// \code
2816 /// \@synthesize int a = b
2817 /// \endcode
2818 SourceLocation IvarLoc;
2819
2820 /// Property declaration being implemented
2821 ObjCPropertyDecl *PropertyDecl;
2822
2823 /// Null for \@dynamic. Required for \@synthesize.
2824 ObjCIvarDecl *PropertyIvarDecl;
2825
2826 /// The getter's definition, which has an empty body if synthesized.
2827 ObjCMethodDecl *GetterMethodDecl = nullptr;
2828 /// The getter's definition, which has an empty body if synthesized.
2829 ObjCMethodDecl *SetterMethodDecl = nullptr;
2830
2831 /// Null for \@dynamic. Non-null if property must be copy-constructed in
2832 /// getter.
2833 Expr *GetterCXXConstructor = nullptr;
2834
2835 /// Null for \@dynamic. Non-null if property has assignment operator to call
2836 /// in Setter synthesis.
2837 Expr *SetterCXXAssignment = nullptr;
2838
2840 ObjCPropertyDecl *property,
2841 Kind PK,
2842 ObjCIvarDecl *ivarDecl,
2843 SourceLocation ivarLoc)
2844 : Decl(ObjCPropertyImpl, DC, L), AtLoc(atLoc),
2845 IvarLoc(ivarLoc), PropertyDecl(property), PropertyIvarDecl(ivarDecl) {
2846 assert(PK == Dynamic || PropertyIvarDecl);
2847 }
2848
2849public:
2850 friend class ASTDeclReader;
2851
2854 ObjCPropertyDecl *property,
2855 Kind PK,
2856 ObjCIvarDecl *ivarDecl,
2857 SourceLocation ivarLoc);
2858
2861
2862 SourceRange getSourceRange() const override LLVM_READONLY;
2863
2864 SourceLocation getBeginLoc() const LLVM_READONLY { return AtLoc; }
2865 void setAtLoc(SourceLocation Loc) { AtLoc = Loc; }
2866
2868 return PropertyDecl;
2869 }
2870 void setPropertyDecl(ObjCPropertyDecl *Prop) { PropertyDecl = Prop; }
2871
2873 return PropertyIvarDecl ? Synthesize : Dynamic;
2874 }
2875
2877 return PropertyIvarDecl;
2878 }
2879 SourceLocation getPropertyIvarDeclLoc() const { return IvarLoc; }
2880
2882 SourceLocation IvarLoc) {
2883 PropertyIvarDecl = Ivar;
2884 this->IvarLoc = IvarLoc;
2885 }
2886
2887 /// For \@synthesize, returns true if an ivar name was explicitly
2888 /// specified.
2889 ///
2890 /// \code
2891 /// \@synthesize int a = b; // true
2892 /// \@synthesize int a; // false
2893 /// \endcode
2894 bool isIvarNameSpecified() const {
2895 return IvarLoc.isValid() && IvarLoc != getLocation();
2896 }
2897
2898 ObjCMethodDecl *getGetterMethodDecl() const { return GetterMethodDecl; }
2899 void setGetterMethodDecl(ObjCMethodDecl *MD) { GetterMethodDecl = MD; }
2900
2901 ObjCMethodDecl *getSetterMethodDecl() const { return SetterMethodDecl; }
2902 void setSetterMethodDecl(ObjCMethodDecl *MD) { SetterMethodDecl = MD; }
2903
2905 return GetterCXXConstructor;
2906 }
2907
2908 void setGetterCXXConstructor(Expr *getterCXXConstructor) {
2909 GetterCXXConstructor = getterCXXConstructor;
2910 }
2911
2913 return SetterCXXAssignment;
2914 }
2915
2916 void setSetterCXXAssignment(Expr *setterCXXAssignment) {
2917 SetterCXXAssignment = setterCXXAssignment;
2918 }
2919
2920 static bool classof(const Decl *D) { return classofKind(D->getKind()); }
2921 static bool classofKind(Decl::Kind K) { return K == ObjCPropertyImpl; }
2922};
2923
2924template<bool (*Filter)(ObjCCategoryDecl *)>
2925void
2926ObjCInterfaceDecl::filtered_category_iterator<Filter>::
2927findAcceptableCategory() {
2928 while (Current && !Filter(Current))
2929 Current = Current->getNextClassCategoryRaw();
2930}
2931
2932template<bool (*Filter)(ObjCCategoryDecl *)>
2933inline ObjCInterfaceDecl::filtered_category_iterator<Filter> &
2935 Current = Current->getNextClassCategoryRaw();
2936 findAcceptableCategory();
2937 return *this;
2938}
2939
2940inline bool ObjCInterfaceDecl::isVisibleCategory(ObjCCategoryDecl *Cat) {
2941 return !Cat->isInvalidDecl() && Cat->isUnconditionallyVisible();
2942}
2943
2944inline bool ObjCInterfaceDecl::isVisibleExtension(ObjCCategoryDecl *Cat) {
2945 return !Cat->isInvalidDecl() && Cat->IsClassExtension() &&
2947}
2948
2949inline bool ObjCInterfaceDecl::isKnownExtension(ObjCCategoryDecl *Cat) {
2950 return !Cat->isInvalidDecl() && Cat->IsClassExtension();
2951}
2952
2953} // namespace clang
2954
2955#endif // LLVM_CLANG_AST_DECLOBJC_H
int Id
Definition: ASTDiff.cpp:190
StringRef P
static char ID
Definition: Arena.cpp:183
Defines the clang::IdentifierInfo, clang::IdentifierTable, and clang::Selector interfaces.
#define X(type, name)
Definition: Value.h:143
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified.
Defines the clang::SourceLocation class and associated facilities.
Defines various enumerations that describe declaration and type specifiers.
const char * Data
C Language Family Type Representation.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition: ASTContext.h:182
Reads an AST files chain containing the contents of a translation unit.
Definition: ASTReader.h:366
Represents a C++ base or member initializer.
Definition: DeclCXX.h:2300
CompoundStmt - This represents a group of statements like { stmt stmt }.
Definition: Stmt.h:1606
Iterates over a filtered subrange of declarations stored in a DeclContext.
Definition: DeclBase.h:2418
specific_decl_iterator - Iterates over a subrange of declarations stored in a DeclContext,...
Definition: DeclBase.h:2342
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:2005
ObjCContainerDeclBitfields ObjCContainerDeclBits
Definition: DeclBase.h:2006
void addDecl(Decl *D)
Add the declaration D into this context.
Definition: DeclBase.cpp:1698
decl_iterator decls_end() const
Definition: DeclBase.h:2324
decl_iterator decls_begin() const
Definition: DeclBase.cpp:1554
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:599
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:594
SourceLocation getLocation() const
Definition: DeclBase.h:445
void setLexicalDeclContext(DeclContext *DC)
Definition: DeclBase.cpp:340
Kind getKind() const
Definition: DeclBase.h:448
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:3058
FieldDecl * getCanonicalDecl() override
Retrieves the canonical declaration of this field.
Definition: Decl.h:3282
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:2028
static bool classofKind(Kind K)
Definition: DeclObjC.h:2049
static ObjCAtDefsFieldDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID)
Definition: DeclObjC.cpp:1917
static bool classof(const Decl *D)
Definition: DeclObjC.h:2048
ObjCCategoryDecl - Represents a category declaration.
Definition: DeclObjC.h:2326
llvm::iterator_range< specific_decl_iterator< ObjCIvarDecl > > ivar_range
Definition: DeclObjC.h:2437
ObjCCategoryDecl * getNextClassCategory() const
Definition: DeclObjC.h:2426
unsigned ivar_size() const
Definition: DeclObjC.h:2449
ivar_iterator ivar_begin() const
Definition: DeclObjC.h:2441
void setTypeParamList(ObjCTypeParamList *TPL)
Set the type parameters of this category.
Definition: DeclObjC.cpp:2167
bool ivar_empty() const
Definition: DeclObjC.h:2453
ivar_iterator ivar_end() const
Definition: DeclObjC.h:2445
llvm::iterator_range< protocol_loc_iterator > protocol_loc_range
Definition: DeclObjC.h:2412
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:2388
protocol_loc_range protocol_locs() const
Definition: DeclObjC.h:2414
static ObjCCategoryDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID)
Definition: DeclObjC.cpp:2151
void setIvarLBraceLoc(SourceLocation Loc)
Definition: DeclObjC.h:2460
unsigned protocol_size() const
Definition: DeclObjC.h:2409
ObjCCategoryImplDecl * getImplementation() const
Definition: DeclObjC.cpp:2158
void setCategoryNameLoc(SourceLocation Loc)
Definition: DeclObjC.h:2458
ObjCInterfaceDecl * getClassInterface()
Definition: DeclObjC.h:2369
ObjCCategoryDecl * getNextClassCategoryRaw() const
Retrieve the pointer to the next stored category (or extension), which may be hidden.
Definition: DeclObjC.h:2430
specific_decl_iterator< ObjCIvarDecl > ivar_iterator
Definition: DeclObjC.h:2436
ObjCTypeParamList * getTypeParamList() const
Retrieve the type parameter list associated with this category or extension.
Definition: DeclObjC.h:2374
static bool classofKind(Kind K)
Definition: DeclObjC.h:2466
void setIvarRBraceLoc(SourceLocation Loc)
Definition: DeclObjC.h:2462
protocol_iterator protocol_end() const
Definition: DeclObjC.h:2408
const ObjCInterfaceDecl * getClassInterface() const
Definition: DeclObjC.h:2370
llvm::iterator_range< protocol_iterator > protocol_range
Definition: DeclObjC.h:2398
SourceLocation getIvarLBraceLoc() const
Definition: DeclObjC.h:2461
bool IsClassExtension() const
Definition: DeclObjC.h:2434
SourceLocation getIvarRBraceLoc() const
Definition: DeclObjC.h:2463
protocol_loc_iterator protocol_loc_begin() const
Definition: DeclObjC.h:2418
protocol_iterator protocol_begin() const
Definition: DeclObjC.h:2404
protocol_range protocols() const
Definition: DeclObjC.h:2400
ivar_range ivars() const
Definition: DeclObjC.h:2439
const ObjCProtocolList & getReferencedProtocols() const
Definition: DeclObjC.h:2393
void setImplementation(ObjCCategoryImplDecl *ImplD)
Definition: DeclObjC.cpp:2163
ObjCProtocolList::iterator protocol_iterator
Definition: DeclObjC.h:2397
static bool classof(const Decl *D)
Definition: DeclObjC.h:2465
SourceLocation getCategoryNameLoc() const
Definition: DeclObjC.h:2457
protocol_loc_iterator protocol_loc_end() const
Definition: DeclObjC.h:2422
ObjCCategoryImplDecl - An object of this class encapsulates a category @implementation declaration.
Definition: DeclObjC.h:2542
static bool classofKind(Kind K)
Definition: DeclObjC.h:2572
SourceLocation getCategoryNameLoc() const
Definition: DeclObjC.h:2569
ObjCCategoryDecl * getCategoryDecl() const
Definition: DeclObjC.cpp:2199
static bool classof(const Decl *D)
Definition: DeclObjC.h:2571
static ObjCCategoryImplDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID)
Definition: DeclObjC.cpp:2193
ObjCCompatibleAliasDecl - Represents alias of a class.
Definition: DeclObjC.h:2772
const ObjCInterfaceDecl * getClassInterface() const
Definition: DeclObjC.h:2790
static bool classofKind(Kind K)
Definition: DeclObjC.h:2795
ObjCInterfaceDecl * getClassInterface()
Definition: DeclObjC.h:2791
static bool classof(const Decl *D)
Definition: DeclObjC.h:2794
static ObjCCompatibleAliasDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID)
Definition: DeclObjC.cpp:2343
void setClassInterface(ObjCInterfaceDecl *D)
Definition: DeclObjC.h:2792
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:2506
void addPropertyImplementation(ObjCPropertyImplDecl *property)
Definition: DeclObjC.cpp:2208
void addClassMethod(ObjCMethodDecl *method)
Definition: DeclObjC.h:2493
llvm::iterator_range< specific_decl_iterator< ObjCPropertyImplDecl > > propimpl_range
Definition: DeclObjC.h:2508
ObjCImplDecl(Kind DK, DeclContext *DC, ObjCInterfaceDecl *classInterface, const IdentifierInfo *Id, SourceLocation nameLoc, SourceLocation atStartLoc)
Definition: DeclObjC.h:2476
ObjCInterfaceDecl * getClassInterface()
Definition: DeclObjC.h:2484
propimpl_iterator propimpl_begin() const
Definition: DeclObjC.h:2514
static bool classof(const Decl *D)
Definition: DeclObjC.h:2522
propimpl_range property_impls() const
Definition: DeclObjC.h:2510
void setClassInterface(ObjCInterfaceDecl *IFace)
Definition: DeclObjC.cpp: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:2518
const ObjCInterfaceDecl * getClassInterface() const
Definition: DeclObjC.h:2483
ObjCPropertyImplDecl * FindPropertyImplIvarDecl(IdentifierInfo *ivarId) const
FindPropertyImplIvarDecl - This method lookup the ivar in the list of properties implemented in this ...
Definition: DeclObjC.cpp:2233
static bool classofKind(Kind K)
Definition: DeclObjC.h:2524
void addInstanceMethod(ObjCMethodDecl *method)
Definition: DeclObjC.h:2487
ObjCImplementationDecl - Represents a class definition - this is where method definitions are specifi...
Definition: DeclObjC.h:2594
void setNumIvarInitializers(unsigned numNumIvarInitializers)
Definition: DeclObjC.h:2689
static bool classofKind(Kind K)
Definition: DeclObjC.h:2765
init_iterator init_end()
init_end() - Retrieve an iterator past the last initializer.
Definition: DeclObjC.h:2675
SourceLocation getIvarRBraceLoc() const
Definition: DeclObjC.h:2741
bool hasNonZeroConstructors() const
Do any of the ivars of this class (not counting its base classes) require construction other than zer...
Definition: DeclObjC.h:2699
llvm::iterator_range< init_iterator > init_range
Definition: DeclObjC.h:2656
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:2709
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:2654
std::string getNameAsString() const
Get the name of the class associated with this interface.
Definition: DeclObjC.h:2726
SourceLocation getSuperClassLoc() const
Definition: DeclObjC.h:2734
specific_decl_iterator< ObjCIvarDecl > ivar_iterator
Definition: DeclObjC.h:2743
ivar_range ivars() const
Definition: DeclObjC.h:2746
llvm::iterator_range< specific_decl_iterator< ObjCIvarDecl > > ivar_range
Definition: DeclObjC.h:2744
ivar_iterator ivar_begin() const
Definition: DeclObjC.h:2748
void setIvarLBraceLoc(SourceLocation Loc)
Definition: DeclObjC.h:2738
ObjCInterfaceDecl * getSuperClass()
Definition: DeclObjC.h:2733
StringRef getName() const
getName - Get the name of identifier for the class interface associated with this implementation as a...
Definition: DeclObjC.h:2718
void setSuperClass(ObjCInterfaceDecl *superCls)
Definition: DeclObjC.h:2736
bool hasDestructors() const
Do any of the ivars of this class (not counting its base classes) require non-trivial destruction?
Definition: DeclObjC.h:2704
llvm::iterator_range< init_const_iterator > init_const_range
Definition: DeclObjC.h:2657
init_iterator init_begin()
init_begin() - Retrieve an iterator to the first initializer.
Definition: DeclObjC.h:2666
unsigned getNumIvarInitializers() const
getNumArgs - Number of ivars which must be initialized.
Definition: DeclObjC.h:2685
void setIvarInitializers(ASTContext &C, CXXCtorInitializer **initializers, unsigned numInitializers)
Definition: DeclObjC.cpp:2305
init_const_range inits() const
Definition: DeclObjC.h:2661
ivar_iterator ivar_end() const
Definition: DeclObjC.h:2752
unsigned ivar_size() const
Definition: DeclObjC.h:2756
void setIvarRBraceLoc(SourceLocation Loc)
Definition: DeclObjC.h:2740
init_const_iterator init_end() const
end() - Retrieve an iterator past the last initializer.
Definition: DeclObjC.h:2680
static bool classof(const Decl *D)
Definition: DeclObjC.h:2764
const ObjCInterfaceDecl * getSuperClass() const
Definition: DeclObjC.h:2732
SourceLocation getIvarLBraceLoc() const
Definition: DeclObjC.h:2739
void setHasDestructors(bool val)
Definition: DeclObjC.h:2705
void setHasNonZeroConstructors(bool val)
Definition: DeclObjC.h:2700
Iterator that walks over the list of categories, filtering out those that do not meet specific criter...
Definition: DeclObjC.h: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:2934
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:1850
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:1924
ObjCMethodDecl * getCategoryMethod(Selector Sel, bool isInstance) const
Definition: DeclObjC.h:1350
const ObjCInterfaceDecl * getCanonicalDecl() const
Definition: DeclObjC.h:1914
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:1796
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:1777
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:1891
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:1845
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:1860
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:1783
ObjCIvarDecl * lookupInstanceVariable(IdentifierInfo *IVarName)
Definition: DeclObjC.h:1830
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:1867
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:1917
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:1918
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:1756
ObjCImplementationDecl * getImplementation() const
Definition: DeclObjC.cpp:1629
static bool classof(const Decl *D)
Definition: DeclObjC.h:1923
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:1876
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:1758
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:1772
bool visible_categories_empty() const
Determine whether the visible-categories list is empty.
Definition: DeclObjC.h:1669
void setEndOfDefinitionLoc(SourceLocation LE)
Definition: DeclObjC.h:1883
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:1902
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:1767
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:1913
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:1808
specific_decl_iterator< ObjCIvarDecl > ivar_iterator
Definition: DeclObjC.h:1447
redeclarable_base::redecl_iterator redecl_iterator
Definition: DeclObjC.h:1903
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:1760
ObjCIvarDecl - Represents an ObjC instance variable.
Definition: DeclObjC.h:1950
AccessControl getAccessControl() const
Definition: DeclObjC.h:1998
void setAccessControl(AccessControl ac)
Definition: DeclObjC.h:1996
static bool classof(const Decl *D)
Definition: DeclObjC.h:2012
void setNextIvar(ObjCIvarDecl *ivar)
Definition: DeclObjC.h:1987
bool getSynthesize() const
Definition: DeclObjC.h:2005
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:2004
ObjCIvarDecl * getNextIvar()
Definition: DeclObjC.h:1985
const ObjCIvarDecl * getNextIvar() const
Definition: DeclObjC.h:1986
static ObjCIvarDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID)
Definition: DeclObjC.cpp:1869
const ObjCInterfaceDecl * getContainingInterface() const
Definition: DeclObjC.h:1981
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:2000
const ObjCIvarDecl * getCanonicalDecl() const
Definition: DeclObjC.h:1992
ObjCIvarDecl * getCanonicalDecl() override
Retrieves the canonical declaration of this field.
Definition: DeclObjC.h:1989
static bool classofKind(Kind K)
Definition: DeclObjC.h:2013
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:6750
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:2802
ObjCIvarDecl * getPropertyIvarDecl() const
Definition: DeclObjC.h:2876
SourceLocation getPropertyIvarDeclLoc() const
Definition: DeclObjC.h:2879
void setPropertyIvarDecl(ObjCIvarDecl *Ivar, SourceLocation IvarLoc)
Definition: DeclObjC.h:2881
Kind getPropertyImplementation() const
Definition: DeclObjC.h:2872
bool isIvarNameSpecified() const
For @synthesize, returns true if an ivar name was explicitly specified.
Definition: DeclObjC.h:2894
void setSetterMethodDecl(ObjCMethodDecl *MD)
Definition: DeclObjC.h:2902
Expr * getSetterCXXAssignment() const
Definition: DeclObjC.h:2912
ObjCPropertyDecl * getPropertyDecl() const
Definition: DeclObjC.h:2867
Expr * getGetterCXXConstructor() const
Definition: DeclObjC.h:2904
void setSetterCXXAssignment(Expr *setterCXXAssignment)
Definition: DeclObjC.h:2916
static ObjCPropertyImplDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID)
Definition: DeclObjC.cpp:2397
ObjCMethodDecl * getSetterMethodDecl() const
Definition: DeclObjC.h:2901
static bool classof(const Decl *D)
Definition: DeclObjC.h:2920
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: DeclObjC.h:2864
static bool classofKind(Decl::Kind K)
Definition: DeclObjC.h:2921
void setGetterMethodDecl(ObjCMethodDecl *MD)
Definition: DeclObjC.h:2899
void setAtLoc(SourceLocation Loc)
Definition: DeclObjC.h:2865
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
Definition: DeclObjC.cpp:2403
void setPropertyDecl(ObjCPropertyDecl *Prop)
Definition: DeclObjC.h:2870
void setGetterCXXConstructor(Expr *getterCXXConstructor)
Definition: DeclObjC.h:2908
ObjCMethodDecl * getGetterMethodDecl() const
Definition: DeclObjC.h:2898
Represents an Objective-C protocol declaration.
Definition: DeclObjC.h:2082
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:2235
bool isThisDeclarationADefinition() const
Determine whether this particular declaration is also the definition.
Definition: DeclObjC.h:2258
ObjCMethodDecl * lookupMethod(Selector Sel, bool isInstance) const
Definition: DeclObjC.cpp:1997
const ObjCProtocolList & getReferencedProtocols() const
Definition: DeclObjC.h:2150
const ObjCProtocolDecl * getDefinition() const
Retrieve the definition of this protocol, if any.
Definition: DeclObjC.h:2252
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:2206
redeclarable_base::redecl_iterator redecl_iterator
Definition: DeclObjC.h:2284
protocol_loc_iterator protocol_loc_end() const
Definition: DeclObjC.h:2190
ObjCProtocolDecl * getDefinition()
Retrieve the definition of this protocol, if any.
Definition: DeclObjC.h:2247
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:2179
llvm::iterator_range< protocol_loc_iterator > protocol_loc_range
Definition: DeclObjC.h:2177
llvm::iterator_range< protocol_iterator > protocol_range
Definition: DeclObjC.h:2156
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:2155
void collectInheritedProtocolProperties(const ObjCPropertyDecl *Property, ProtocolPropertySet &PS, PropertyDeclOrder &PO) const
Definition: DeclObjC.cpp:2056
static bool classof(const Decl *D)
Definition: DeclObjC.h:2306
protocol_iterator protocol_begin() const
Definition: DeclObjC.h:2162
ObjCProtocolList::loc_iterator protocol_loc_iterator
Definition: DeclObjC.h:2176
ObjCProtocolDecl * lookupProtocolNamed(IdentifierInfo *PName)
Definition: DeclObjC.cpp:1982
ObjCProtocolDecl * getCanonicalDecl() override
Retrieves the canonical declaration of this Objective-C protocol.
Definition: DeclObjC.h:2294
protocol_range protocols() const
Definition: DeclObjC.h:2158
ObjCMethodDecl * lookupClassMethod(Selector Sel) const
Definition: DeclObjC.h:2230
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
Definition: DeclObjC.h:2276
const ObjCProtocolDecl * getCanonicalDecl() const
Definition: DeclObjC.h:2295
static bool classofKind(Kind K)
Definition: DeclObjC.h:2307
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:2283
unsigned protocol_size() const
Definition: DeclObjC.h:2197
protocol_iterator protocol_end() const
Definition: DeclObjC.h:2169
protocol_loc_iterator protocol_loc_begin() const
Definition: DeclObjC.h:2183
ObjCMethodDecl * lookupInstanceMethod(Selector Sel) const
Definition: DeclObjC.h:2226
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:1761
A (possibly-)qualified type.
Definition: Type.h:940
Provides common interface for the Decls that can be redeclared.
Definition: Redeclarable.h:84
ObjCInterfaceDecl * getFirstDecl()
Return the first declaration of this declaration or itself if this is the only declaration.
Definition: Redeclarable.h:216
ObjCInterfaceDecl * getNextRedeclaration() const
Definition: Redeclarable.h:189
ObjCInterfaceDecl * getPreviousDecl()
Return the previous declaration of this declaration or NULL if this is the first declaration.
Definition: Redeclarable.h:204
llvm::iterator_range< redecl_iterator > redecl_range
Definition: Redeclarable.h:292
ObjCInterfaceDecl * getMostRecentDecl()
Returns the most recent (re)declaration of this declaration.
Definition: Redeclarable.h:226
bool isFirstDecl() const
True if this is the first declaration in its redeclaration chain.
Definition: Redeclarable.h:223
redecl_iterator redecls_begin() const
Definition: Redeclarable.h:302
redecl_range redecls() const
Returns an iterator range for all the redeclarations of the same decl.
Definition: Redeclarable.h:296
Smart pointer class that efficiently represents Objective-C method names.
bool isUnarySelector() const
unsigned getNumArgs() const
Encodes a location in the source.
bool isValid() const
Return true if this is a valid SourceLocation object.
A trivial tuple used to represent a source range.
Stmt - This represents one statement.
Definition: Stmt.h:84
A container of type source information.
Definition: Type.h:7326
The base class of the type hierarchy.
Definition: Type.h:1813
bool isBlockPointerType() const
Definition: Type.h:7616
const T * castAs() const
Member-template castAs<specific type>.
Definition: Type.h:8186
Base class for declarations which introduce a typedef-name.
Definition: Decl.h:3433
QualType getType() const
Definition: Decl.h:717
The JSON file list parser is used to communicate input to InstallAPI.
@ Create
'copyin' clause, allowed on Compute and Combined constructs, plus 'data', 'enter data',...
SelectorLocationsKind
Whether all locations of the selector identifiers are in a "standard" position.
@ SelLoc_StandardWithSpace
For nullary selectors, immediately before the end: "[foo release]" / "-(void)release;" Or with a spac...
@ SelLoc_NonStandard
Non-standard.
ObjCPropertyQueryKind
Definition: DeclObjC.h:718
@ ICIS_NoInit
No in-class initializer.
Definition: Specifiers.h:269
ObjCMethodFamily
A family of Objective-C methods.
const StreamingDiagnostic & operator<<(const StreamingDiagnostic &DB, const ASTContext::SectionInfo &Section)
Insertion operator for diagnostics.
@ Property
The type of a property.
ObjCImplementationControl
Definition: DeclObjC.h:118
SourceLocation getStandardSelectorLoc(unsigned Index, Selector Sel, bool WithArgSpace, ArrayRef< Expr * > Args, SourceLocation EndLoc)
Get the "standard" location of a selector identifier, e.g: For nullary selectors, immediately before ...
const FunctionProtoType * T
bool declaresSameEntity(const Decl *D1, const Decl *D2)
Determine whether two declarations declare the same entity.
Definition: DeclBase.h:1275
@ NumObjCPropertyAttrsBits
Number of bits fitting all the property attributes.
ObjCTypeParamVariance
Describes the variance of a given generic parameter.
Definition: DeclObjC.h:553
@ Invariant
The parameter is invariant: must match exactly.
@ Contravariant
The parameter is contravariant, e.g., X<T> is a subtype of X when the type parameter is covariant and...
@ Covariant
The parameter is covariant, e.g., X<T> is a subtype of X when the type parameter is covariant and T i...
@ None
The alignment was not explicit in code.
#define true
Definition: stdbool.h:21
#define false
Definition: stdbool.h:22
bool isValid() const
Whether this pointer is non-NULL.
QualType operator()(const ParmVarDecl *PD) const
Definition: DeclObjC.h:393