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