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