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