19 #include "llvm/ADT/STLExtras.h"
20 #include "llvm/ADT/SmallString.h"
21 using namespace clang;
29 if (Elts == 0)
return;
32 List =
new (Ctx)
void*[Elts];
34 memcpy(
List, InList,
sizeof(
void*)*Elts);
44 set(InList, Elts, Ctx);
51 void ObjCContainerDecl::anchor() { }
59 Ivar != IvarEnd; ++Ivar) {
69 bool AllowHidden)
const {
74 if (Def->isHidden() && !AllowHidden)
88 Meth != MethEnd; ++Meth) {
106 Meth != MethEnd; ++Meth) {
115 for (
const auto *Cat :
ID->visible_categories()) {
117 if (!MD->isImplicit())
119 if (Cat->IsClassExtension())
125 for (
const auto *
P : Cat->properties())
134 for (
const auto *Proto :
ID->all_referenced_protocols())
135 if (Proto->HasUserDeclaredSetterMethod(Property))
147 for (
const auto *PI : PD->protocols())
148 if (PI->HasUserDeclaredSetterMethod(Property))
167 if (
auto *IDecl = dyn_cast<ObjCInterfaceDecl>(DC)) {
168 for (
const auto *Ext : IDecl->visible_extensions())
183 !PD->isClassProperty()) ||
185 PD->isClassProperty()) ||
187 !PD->isClassProperty()))
190 if (PD->isClassProperty())
205 llvm::raw_svector_ostream os(ivarName);
225 if (
const auto *ClassDecl = dyn_cast<ObjCInterfaceDecl>(
this)) {
226 for (
const auto *Ext : ClassDecl->visible_extensions()) {
227 if (
auto *
P = Ext->FindPropertyDeclaration(PropertyId, QueryKind))
240 case Decl::ObjCProtocol: {
248 case Decl::ObjCInterface: {
252 if (!Cat->IsClassExtension())
254 PropertyId, QueryKind))
266 return superClass->FindPropertyDeclaration(PropertyId, QueryKind);
269 case Decl::ObjCCategory: {
283 void ObjCInterfaceDecl::anchor() { }
292 return def->getTypeParamListAsWritten();
310 for (
auto typeParam : *TypeParamList)
311 typeParam->setDeclContext(
this);
319 if (data().ExternallyCompleted)
320 LoadExternalDefinition();
336 return superTInfo->getTypeLoc().getLocStart();
353 if (data().ExternallyCompleted)
354 LoadExternalDefinition();
373 PM[std::make_pair(Prop->getIdentifier(), Prop->isClassProperty())] = Prop;
379 PM[std::make_pair(Prop->getIdentifier(), Prop->isClassProperty())] = Prop;
384 PI->collectPropertiesToImplement(PM, PO);
393 if (Class->
hasAttr<ArcWeakrefUnavailableAttr>())
403 if (Class->
hasAttr<ObjCRequiresPropertyDefsAttr>())
414 if (data().ExternallyCompleted)
415 LoadExternalDefinition();
417 if (data().AllReferencedProtocols.empty() &&
418 data().ReferencedProtocols.empty()) {
419 data().AllReferencedProtocols.set(ExtList, ExtNum, C);
427 for (
unsigned i = 0; i < ExtNum; i++) {
428 bool protocolExists =
false;
432 protocolExists =
true;
439 ProtocolRefs.push_back(ProtoInExtension);
442 if (ProtocolRefs.empty())
449 data().AllReferencedProtocols.set(ProtocolRefs.data(), ProtocolRefs.size(),
C);
453 ObjCInterfaceDecl::findInterfaceWithDesignatedInitializers()
const {
458 if (!IFace->inheritsDesignatedInitializers())
467 if (MD->getMethodFamily() ==
OMF_init && !MD->isOverriding())
471 for (
const auto *MD : Ext->instance_methods()) {
472 if (MD->getMethodFamily() ==
OMF_init && !MD->isOverriding())
477 for (
const auto *MD : ImplD->instance_methods()) {
478 if (MD->getMethodFamily() ==
OMF_init && !MD->isOverriding())
485 bool ObjCInterfaceDecl::inheritsDesignatedInitializers()
const {
486 switch (data().InheritedDesignatedInitializers) {
487 case DefinitionData::IDI_Inherited:
489 case DefinitionData::IDI_NotInherited:
491 case DefinitionData::IDI_Unknown: {
496 data().InheritedDesignatedInitializers = DefinitionData::IDI_NotInherited;
499 data().InheritedDesignatedInitializers =
500 SuperD->declaresOrInheritsDesignatedInitializers() ?
501 DefinitionData::IDI_Inherited :
502 DefinitionData::IDI_NotInherited;
504 data().InheritedDesignatedInitializers =
505 DefinitionData::IDI_NotInherited;
508 assert(data().InheritedDesignatedInitializers
509 != DefinitionData::IDI_Unknown);
510 return data().InheritedDesignatedInitializers ==
511 DefinitionData::IDI_Inherited;
515 llvm_unreachable(
"unexpected InheritedDesignatedInitializers value");
523 if (data().ExternallyCompleted)
524 LoadExternalDefinition();
531 if (MD->isThisDeclarationADesignatedInitializer())
532 Methods.push_back(MD);
534 for (
const auto *MD : Ext->instance_methods())
535 if (MD->isThisDeclarationADesignatedInitializer())
536 Methods.push_back(MD);
548 HasCompleteDef =
true;
554 if (data().ExternallyCompleted)
555 LoadExternalDefinition();
562 if (MD->isThisDeclarationADesignatedInitializer()) {
570 if (MD->isThisDeclarationADesignatedInitializer()) {
580 void ObjCInterfaceDecl::allocateDefinitionData() {
581 assert(!
hasDefinition() &&
"ObjC class already has a definition");
583 Data.getPointer()->Definition =
this;
587 cast<ObjCInterfaceType>(TypeForDecl)->
Decl =
this;
591 allocateDefinitionData();
606 if (data().ExternallyCompleted)
607 LoadExternalDefinition();
610 while (ClassDecl !=
nullptr) {
612 clsDeclared = ClassDecl;
618 clsDeclared = ClassDecl;
637 if (data().ExternallyCompleted)
638 LoadExternalDefinition();
641 while (ClassDecl !=
nullptr) {
652 if (
P->lookupProtocolNamed(Name))
664 bool shallowCategoryLookup,
675 if (data().ExternallyCompleted)
676 LoadExternalDefinition();
680 if ((MethodDecl = ClassDecl->
getMethod(Sel, isInstance)))
685 if ((MethodDecl = Cat->getMethod(Sel, isInstance)))
691 if ((MethodDecl =
I->lookupMethod(Sel, isInstance)))
695 if (!shallowCategoryLookup)
699 Cat->getReferencedProtocols();
701 E = Protocols.
end();
I !=
E; ++
I)
702 if ((MethodDecl = (*I)->lookupMethod(Sel, isInstance)))
722 bool Instance)
const {
727 if (data().ExternallyCompleted)
728 LoadExternalDefinition();
732 Method = Instance ? ImpDecl->getInstanceMethod(Sel)
733 : ImpDecl->getClassMethod(Sel);
762 DeclContext *contextDecl,
bool isInstance,
bool isVariadic,
763 bool isPropertyAccessor,
bool isImplicitlyDeclared,
bool isDefined,
766 beginLoc, endLoc, SelInfo, T, ReturnTInfo, contextDecl, isInstance,
767 isVariadic, isPropertyAccessor, isImplicitlyDeclared, isDefined,
768 impControl, HasRelatedResultType);
778 hasAttr<ObjCDesignatedInitializerAttr>();
786 if (isa<ObjCProtocolDecl>(DC))
789 return ID->isDesignatedInitializer(
getSelector(), InitMethod);
800 IsRedeclaration =
true;
801 PrevMethod->HasRedeclaration =
true;
804 void ObjCMethodDecl::setParamsAndSelLocs(
ASTContext &
C,
807 ParamsAndSelLocs =
nullptr;
808 NumParams = Params.size();
809 if (Params.empty() && SelLocs.empty())
813 "Alignment not sufficient for SourceLocation");
815 unsigned Size =
sizeof(
ParmVarDecl *) * NumParams +
817 ParamsAndSelLocs = C.
Allocate(Size);
818 std::copy(Params.begin(), Params.end(), getParams());
819 std::copy(SelLocs.begin(), SelLocs.end(), getStoredSelLocs());
832 "No selector locs for non-implicit method");
834 return setParamsAndSelLocs(C, Params,
llvm::None);
839 return setParamsAndSelLocs(C, Params,
llvm::None);
841 setParamsAndSelLocs(C, Params, SelLocs);
850 if (HasRedeclaration)
860 if (!ImplD->isInvalidDecl())
865 if (!ImplD->isInvalidDecl())
869 dyn_cast<ObjCImplementationDecl>(CtxD)) {
871 if (!IFD->isInvalidDecl())
875 dyn_cast<ObjCCategoryImplDecl>(CtxD)) {
877 if (!CatD->isInvalidDecl())
890 return cast<ObjCContainerDecl>(CtxD)->getMethod(
getSelector(),
894 return Redecl ? Redecl :
this;
907 dyn_cast<ObjCCategoryImplDecl>(CtxD)) {
917 cast<ObjCContainerDecl>(CtxD)->getMethod(
getSelector(),
919 return MD ? MD :
this;
927 return Body->getLocEnd();
937 if (
const ObjCMethodFamilyAttr *attr = getAttr<ObjCMethodFamilyAttr>()) {
940 switch (attr->getFamily()) {
948 Family =
static_cast<unsigned>(family);
995 if (noParams < 1 || noParams > 3)
1004 while (--noParams) {
1019 Family =
static_cast<unsigned>(family);
1025 bool &selfIsPseudoStrong,
1026 bool &selfIsConsumed) {
1028 selfIsPseudoStrong =
false;
1029 selfIsConsumed =
false;
1044 selfIsConsumed = hasAttr<NSConsumesSelfAttr>();
1055 selfIsPseudoStrong =
true;
1062 selfIsPseudoStrong =
true;
1070 bool selfIsPseudoStrong, selfIsConsumed;
1072 getSelfType(Context, OID, selfIsPseudoStrong, selfIsConsumed);
1079 Self->addAttr(NSConsumedAttr::CreateImplicit(Context));
1081 if (selfIsPseudoStrong)
1082 Self->setARCPseudoStrong(
true);
1093 return CD->getClassInterface();
1095 return IMD->getClassInterface();
1098 llvm_unreachable(
"unknown method context");
1104 return TSI->getTypeLoc().getSourceRange();
1125 bool MovedToSuper) {
1133 Category = dyn_cast<ObjCCategoryDecl>(Container)) {
1141 if (Method != Overridden) {
1144 Methods.push_back(Overridden);
1148 for (
const auto *
P :
Category->protocols())
1158 if (Method != Overridden) {
1161 Methods.push_back(Overridden);
1165 if (
const ObjCProtocolDecl *Protocol = dyn_cast<ObjCProtocolDecl>(Container)){
1166 for (
const auto *
P : Protocol->protocols())
1171 Interface = dyn_cast<ObjCInterfaceDecl>(Container)) {
1172 for (
const auto *
P : Interface->protocols())
1175 for (
const auto *Cat : Interface->known_categories())
1228 Method, overridden);
1243 assert(!Overridden.empty() &&
1244 "ObjCMethodDecl's overriding bit is not as expected");
1257 bool IsGetter = (NumArgs == 0);
1262 auto findMatchingProperty =
1266 Selector NextSel = IsGetter ?
I->getGetterName()
1267 :
I->getSetterName();
1273 Selector NextSel = IsGetter ?
I->getGetterName()
1274 :
I->getSetterName();
1284 if (
const auto *Found = findMatchingProperty(Container))
1289 if (
const auto *
Category = dyn_cast<ObjCCategoryDecl>(Container)) {
1290 ClassDecl =
Category->getClassInterface();
1291 if (
const auto *Found = findMatchingProperty(ClassDecl))
1301 if (Ext == Container)
1304 if (
const auto *Found = findMatchingProperty(Ext))
1309 llvm_unreachable(
"Marked as a property accessor but no property found!");
1312 if (!CheckOverrides)
1316 OverridesTy Overrides;
1318 for (OverridesTy::const_iterator
I = Overrides.begin(),
E = Overrides.end();
1331 void ObjCTypeParamDecl::anchor() { }
1343 nameLoc, name, colonLoc, boundInfo);
1376 : NumParams(typeParams.size())
1380 std::copy(typeParams.begin(), typeParams.end(), begin());
1390 ctx.
Allocate(totalSizeToAlloc<ObjCTypeParamDecl *>(typeParams.size()),
1397 typeArgs.reserve(
size());
1398 for (
auto typeParam : *
this)
1399 typeArgs.push_back(typeParam->getUnderlyingType());
1441 redeclarable_base(C), TypeForDecl(nullptr), TypeParamList(nullptr),
1447 Data = PrevDecl->Data;
1454 void ObjCInterfaceDecl::LoadExternalDefinition()
const {
1455 assert(data().ExternallyCompleted &&
"Class is not externally completed");
1456 data().ExternallyCompleted =
false;
1458 const_cast<ObjCInterfaceDecl *>(
this));
1463 "Class can't be externally completed without an external source");
1465 "Forward declarations can't be externally completed");
1466 data().ExternallyCompleted =
true;
1473 data().HasDesignatedInitializers =
true;
1480 if (data().ExternallyCompleted)
1481 LoadExternalDefinition();
1483 return data().HasDesignatedInitializers;
1488 if (ObjCRuntimeNameAttr *ObjCRTName = getAttr<ObjCRuntimeNameAttr>())
1489 return ObjCRTName->getMetadataName();
1498 return ID->getObjCRuntimeNameAsString();
1505 if (data().ExternallyCompleted)
1506 LoadExternalDefinition();
1509 const_cast<ObjCInterfaceDecl*>(Def));
1521 struct SynthesizeIvarChunk {
1525 : Size(size), Ivar(ivar) {}
1528 bool operator<(
const SynthesizeIvarChunk & LHS,
1529 const SynthesizeIvarChunk &RHS) {
1530 return LHS.Size < RHS.Size;
1549 if (!data().IvarList) {
1552 data().IvarList = *
I; ++
I;
1553 for (curIvar = data().IvarList; I !=
E; curIvar = *
I, ++
I)
1558 if (!Ext->ivar_empty()) {
1560 I = Ext->ivar_begin(),
1561 E = Ext->ivar_end();
1562 if (!data().IvarList) {
1563 data().IvarList = *
I; ++
I;
1564 curIvar = data().IvarList;
1566 for ( ;I !=
E; curIvar = *
I, ++
I)
1570 data().IvarListMissingImplementation =
true;
1574 if (!data().IvarListMissingImplementation)
1575 return data().IvarList;
1578 data().IvarListMissingImplementation =
false;
1579 if (!ImplDecl->ivar_empty()) {
1581 for (
auto *IV : ImplDecl->ivars()) {
1582 if (IV->getSynthesize() && !IV->isInvalidDecl()) {
1583 layout.push_back(SynthesizeIvarChunk(
1584 IV->getASTContext().getTypeSize(IV->getType()), IV));
1587 if (!data().IvarList)
1588 data().IvarList = IV;
1594 if (!layout.empty()) {
1596 std::stable_sort(layout.begin(), layout.end());
1597 unsigned Ix = 0, EIx = layout.size();
1598 if (!data().IvarList) {
1599 data().IvarList = layout[0].Ivar; Ix++;
1600 curIvar = data().IvarList;
1602 for ( ; Ix != EIx; curIvar = layout[Ix].Ivar, Ix++)
1607 return data().IvarList;
1620 if (data().ExternallyCompleted)
1621 LoadExternalDefinition();
1624 if (Cat->getIdentifier() == CategoryId)
1655 bool lookupCategory,
1656 bool RHSIsQualifiedID) {
1671 if (RHSIsQualifiedID &&
1679 for (
auto *PI : Cat->protocols())
1697 void ObjCIvarDecl::anchor() { }
1716 assert((isa<ObjCInterfaceDecl>(DC) || isa<ObjCImplementationDecl>(DC) ||
1717 isa<ObjCCategoryDecl>(DC)) &&
1718 "Invalid ivar decl context!");
1724 ID = IM->getClassInterface();
1726 ID = cast<ObjCCategoryDecl>(DC)->getClassInterface();
1731 return new (C, DC)
ObjCIvarDecl(DC, StartLoc, IdLoc, Id, T, TInfo, ac, BW,
1746 case ObjCCategoryImpl:
1748 llvm_unreachable(
"invalid ivar container!");
1751 case ObjCCategory: {
1757 case ObjCImplementation:
1758 return cast<ObjCImplementationDecl>(DC)->getClassInterface();
1761 return cast<ObjCInterfaceDecl>(DC);
1774 void ObjCAtDefsFieldDecl::anchor() { }
1794 void ObjCProtocolDecl::anchor() { }
1801 redeclarable_base(C), Data() {
1802 setPreviousDecl(PrevDecl);
1804 Data = PrevDecl->Data;
1834 if ((PDecl =
I->lookupProtocolNamed(Name)))
1843 bool isInstance)
const {
1852 if ((MethodDecl =
getMethod(Sel, isInstance)))
1856 if ((MethodDecl =
I->lookupMethod(Sel, isInstance)))
1861 void ObjCProtocolDecl::allocateDefinitionData() {
1862 assert(!Data.getPointer() &&
"Protocol already has a definition!");
1864 Data.getPointer()->Definition =
this;
1868 allocateDefinitionData();
1872 RD->Data = this->Data;
1879 for (
auto *Prop : PDecl->properties()) {
1881 PM.insert(std::make_pair(
1882 std::make_pair(Prop->getIdentifier(), Prop->isClassProperty()),
1887 for (
const auto *PI : PDecl->protocols())
1888 PI->collectPropertiesToImplement(PM, PO);
1896 if (!PS.insert(PDecl).second)
1898 for (
auto *Prop : PDecl->properties()) {
1899 if (Prop == Property)
1907 for (
const auto *PI : PDecl->protocols())
1908 PI->collectInheritedProtocolProperties(Property, PS, PO);
1914 if (ObjCRuntimeNameAttr *ObjCRTName = getAttr<ObjCRuntimeNameAttr>())
1915 return ObjCRTName->getMetadataName();
1924 void ObjCCategoryDecl::anchor() { }
1934 ClassInterface(IDecl), TypeParamList(nullptr),
1935 NextClassCategory(nullptr), CategoryNameLoc(CategoryNameLoc),
1936 IvarLBraceLoc(IvarLBraceLoc), IvarRBraceLoc(IvarRBraceLoc)
1938 setTypeParamList(typeParamList);
1952 IDecl, typeParamList, IvarLBraceLoc,
1960 L->AddedObjCCategoryToInterface(CatDecl, IDecl);
1971 nullptr,
nullptr,
nullptr);
1976 const_cast<ObjCCategoryDecl*>(
this));
1984 TypeParamList = TPL;
1988 for (
auto typeParam : *TypeParamList)
1989 typeParam->setDeclContext(
this);
1997 void ObjCCategoryImplDecl::anchor() { }
2009 atStartLoc, CategoryNameLoc);
2027 void ObjCImplDecl::anchor() { }
2031 property->setLexicalDeclContext(
this);
2039 = dyn_cast_or_null<ObjCImplementationDecl>(
this)) {
2044 dyn_cast_or_null<ObjCCategoryImplDecl>(
this)) {
2049 ClassInterface = IFace;
2059 if (PID->getPropertyIvarDecl() &&
2060 PID->getPropertyIvarDecl()->getIdentifier() == ivarId)
2076 if (PID->getPropertyDecl()->getIdentifier() == Id) {
2078 !PID->getPropertyDecl()->isClassProperty()) ||
2080 PID->getPropertyDecl()->isClassProperty()) ||
2082 !PID->getPropertyDecl()->isClassProperty()))
2085 if (PID->getPropertyDecl()->isClassProperty())
2086 ClassPropImpl = PID;
2091 return ClassPropImpl;
2106 void ObjCImplementationDecl::anchor() { }
2120 nameLoc, atStartLoc, superLoc,
2121 IvarLBraceLoc, IvarRBraceLoc);
2132 unsigned numInitializers) {
2133 if (numInitializers > 0) {
2134 NumIvarInitializers = numInitializers;
2137 memcpy(ivarInitializers, initializers,
2139 IvarInitializers = ivarInitializers;
2158 void ObjCCompatibleAliasDecl::anchor() { }
2178 void ObjCPropertyDecl::anchor() { }
bool isObjCSelType() const
StringRef getObjCRuntimeNameAsString() const
Produce a name to be used for class's metadata.
ObjCMethodDecl * getCategoryMethod(Selector Sel, bool isInstance) const
void setMethodParams(ASTContext &C, ArrayRef< ParmVarDecl * > Params, ArrayRef< SourceLocation > SelLocs=llvm::None)
Sets the method's parameters and selector source locations.
bool hasDefinition() const
Determine whether this class has been defined.
Defines the clang::ASTContext interface.
void setExternallyCompleted()
Indicate that this Objective-C class is complete, but that the external AST source will be responsibl...
void setImplicit(bool I=true)
StringRef getName() const
getName - Get the name of identifier for this declaration as a StringRef.
protocol_range protocols() const
Smart pointer class that efficiently represents Objective-C method names.
A (possibly-)qualified type.
static ObjCIvarDecl * CreateDeserialized(ASTContext &C, unsigned ID)
bool ProtocolCompatibleWithProtocol(ObjCProtocolDecl *lProto, ObjCProtocolDecl *rProto) const
ProtocolCompatibleWithProtocol - return 'true' if 'lProto' is in the inheritance hierarchy of 'rProto...
ObjCInterfaceDecl * getClassInterface()
const ObjCInterfaceDecl * isObjCRequiresPropertyDefs() const
isObjCRequiresPropertyDefs - Checks that a class or one of its super classes must not be auto-synthes...
ObjCInterfaceDecl * getClassInterface()
void startDefinition()
Starts the definition of this Objective-C class, taking it from a forward declaration (@class) to a d...
ObjCMethodDecl * getCategoryClassMethod(Selector Sel) const
void getOverriddenMethods(SmallVectorImpl< const ObjCMethodDecl * > &Overridden) const
Return overridden methods for the given Method.
IdentifierInfo * getIdentifier() const
getIdentifier - Get the identifier that names this declaration, if there is one.
void gatherDefaultTypeArgs(SmallVectorImpl< QualType > &typeArgs) const
Gather the default set of type arguments to be substituted for these type parameters when dealing wit...
QualType getNonLValueExprType(const ASTContext &Context) const
Determine the type of a (typically non-lvalue) expression with the specified result type...
QualType getQualifiedType(SplitQualType split) const
Un-split a SplitQualType.
Stmt - This represents one statement.
void setPreviousDecl(ObjCInterfaceDecl *PrevDecl)
Set the previous declaration.
llvm::DenseMap< std::pair< IdentifierInfo *, unsigned >, ObjCPropertyDecl * > PropertyMap
bool isThisDeclarationADefinition() const
Determine whether this particular declaration of this class is actually also a definition.
void setObjCLifetime(ObjCLifetime type)
CXXCtorInitializer *const * init_const_iterator
init_const_iterator - Iterates through the ivar initializer list.
Decl - This represents one declaration (or definition), e.g.
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
QualType substObjCTypeArgs(ASTContext &ctx, ArrayRef< QualType > typeArgs, ObjCSubstitutionContext context) const
Substitute type arguments for the Objective-C type parameters used in the subject type...
static ObjCProtocolDecl * Create(ASTContext &C, DeclContext *DC, IdentifierInfo *Id, SourceLocation nameLoc, SourceLocation atStartLoc, ObjCProtocolDecl *PrevDecl)
static ObjCPropertyDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, IdentifierInfo *Id, SourceLocation AtLocation, SourceLocation LParenLocation, QualType T, TypeSourceInfo *TSI, PropertyControl propControl=None)
bool isHidden() const
Determine whether this declaration might be hidden from name lookup.
void ** List
List is an array of pointers to objects that are not owned by this object.
const DiagnosticBuilder & operator<<(const DiagnosticBuilder &DB, const Attr *At)
ObjCProtocolDecl * lookupNestedProtocol(IdentifierInfo *Name)
A container of type source information.
bool isArcWeakrefUnavailable() const
isArcWeakrefUnavailable - Checks for a class or one of its super classes to be incompatible with __we...
protocol_range protocols() const
unsigned getRawEncoding() const
When a SourceLocation itself cannot be used, this returns an (opaque) 32-bit integer encoding for it...
void createImplicitParams(ASTContext &Context, const ObjCInterfaceDecl *ID)
createImplicitParams - Used to lazily create the self and cmd implict parameters. ...
const ObjCPropertyDecl * findPropertyDecl(bool CheckOverrides=true) const
Returns the property associated with this method's selector.
ObjCMethodDecl * getMethod(Selector Sel, bool isInstance, bool AllowHidden=false) const
void setImplementation(ObjCCategoryImplDecl *ImplD)
visible_categories_range visible_categories() const
QualType substObjCMemberType(QualType objectType, const DeclContext *dc, ObjCSubstitutionContext context) const
Substitute type arguments from an object type for the Objective-C type parameters used in the subject...
QualType getUsageType(QualType objectType) const
Retrieve the type of this instance variable when viewed as a member of a specific object type...
QualType getObjCClassType() const
Represents the Objective-C Class type.
TypeSourceInfo * getSuperClassTInfo() const
Parameter for Objective-C 'self' argument.
ObjCMethodDecl - Represents an instance or class method declaration.
ObjCImplementationDecl * getObjCImplementation(ObjCInterfaceDecl *D)
Get the implementation of the ObjCInterfaceDecl D, or NULL if none exists.
SourceRange getReturnTypeSourceRange() const
bool ClassImplementsProtocol(ObjCProtocolDecl *lProto, bool lookupCategory, bool RHSIsQualifiedID=false)
ClassImplementsProtocol - Checks that 'lProto' protocol has been implemented in IDecl class...
static ObjCPropertyDecl * findPropertyDecl(const DeclContext *DC, const IdentifierInfo *propertyID, ObjCPropertyQueryKind queryKind)
Lookup a property by name in the specified DeclContext.
void setSelfDecl(ImplicitParamDecl *SD)
void getSelectorLocs(SmallVectorImpl< SourceLocation > &SelLocs) const
unsigned param_size() const
unsigned size() const
Determine the number of type parameters in this list.
ParmVarDecl - Represents a parameter to a function.
The collection of all-type qualifiers we support.
ObjCTypeParamList * getTypeParamListAsWritten() const
Retrieve the type parameters written on this particular declaration of the class. ...
One of these records is kept for each identifier that is lexed.
const ObjCInterfaceDecl * getContainingInterface() const
Return the class interface that this ivar is logically contained in; this is either the interface whe...
Represents a class type in Objective C.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
The results of name lookup within a DeclContext.
ObjCMethodFamily
A family of Objective-C methods.
ObjCPropertyDecl * FindPropertyVisibleInPrimaryClass(IdentifierInfo *PropertyId, ObjCPropertyQueryKind QueryKind) const
FindPropertyVisibleInPrimaryClass - Finds declaration of the property with name 'PropertyId' in the p...
ObjCIvarDecl * getIvarDecl(IdentifierInfo *Id) const
getIvarDecl - This method looks up an ivar in this ContextDecl.
bool isOverriding() const
Whether this method overrides any other in the class hierarchy.
void setTypeParamList(ObjCTypeParamList *TPL)
Set the type parameters of this class.
all_protocol_range all_referenced_protocols() const
const internal::VariadicAllOfMatcher< Decl > decl
Matches declarations.
llvm::SmallDenseSet< const ObjCProtocolDecl *, 8 > ProtocolPropertySet
void startDefinition()
Starts the definition of this Objective-C protocol.
SelectorLocationsKind hasStandardSelectorLocs(Selector Sel, ArrayRef< SourceLocation > SelLocs, ArrayRef< Expr * > Args, SourceLocation EndLoc)
Returns true if all SelLocs are in a "standard" location.
void set(ObjCProtocolDecl *const *InList, unsigned Elts, const SourceLocation *Locs, ASTContext &Ctx)
bool IsClassExtension() const
void collectPropertiesToImplement(PropertyMap &PM, PropertyDeclOrder &PO) const override
This routine collects list of properties to be implemented in the class.
SourceLocation getSelectorLoc(unsigned Index) const
unsigned getNumSelectorLocs() const
static ObjCInterfaceDecl * Create(const ASTContext &C, DeclContext *DC, SourceLocation atLoc, IdentifierInfo *Id, ObjCTypeParamList *typeParamList, ObjCInterfaceDecl *PrevDecl, SourceLocation ClassLoc=SourceLocation(), bool isInternal=false)
void set(void *const *InList, unsigned Elts, ASTContext &Ctx)
ObjCContainerDecl - Represents a container for method declarations.
const LangOptions & getLangOpts() const
bool isImplicit() const
isImplicit - Indicates whether the declaration was implicitly generated by the implementation.
SourceLocation getSuperClassLoc() const
Retrieve the starting location of the superclass.
static ObjCCategoryDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation AtLoc, SourceLocation ClassNameLoc, SourceLocation CategoryNameLoc, IdentifierInfo *Id, ObjCInterfaceDecl *IDecl, ObjCTypeParamList *typeParamList, SourceLocation IvarLBraceLoc=SourceLocation(), SourceLocation IvarRBraceLoc=SourceLocation())
ObjCMethodFamily getMethodFamily() const
Determines the family of this method.
static ObjCPropertyImplDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation atLoc, SourceLocation L, ObjCPropertyDecl *property, Kind PK, ObjCIvarDecl *ivarDecl, SourceLocation ivarLoc)
ObjCPropertyImplDecl * FindPropertyImplIvarDecl(IdentifierInfo *ivarId) const
FindPropertyImplIvarDecl - This method lookup the ivar in the list of properties implemented in this ...
bool hasDesignatedInitializers() const
Returns true if this interface decl contains at least one initializer marked with the 'objc_designate...
static ObjCTypeParamList * create(ASTContext &ctx, SourceLocation lAngleLoc, ArrayRef< ObjCTypeParamDecl * > typeParams, SourceLocation rAngleLoc)
Create a new Objective-C type parameter list.
static ObjCAtDefsFieldDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, QualType T, Expr *BW)
static ObjCCategoryImplDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Selector getSetterName() const
bool isDesignatedInitializerForTheInterface(const ObjCMethodDecl **InitMethod=nullptr) const
Returns true if the method selector resolves to a designated initializer in the class's interface...
ObjCProtocolDecl * getDefinition()
Retrieve the definition of this protocol, if any.
void setAsRedeclaration(const ObjCMethodDecl *PrevMethod)
Represents an Objective-C protocol declaration.
Represents an ObjC class declaration.
SourceLocation getLocEnd() const LLVM_READONLY
propimpl_range property_impls() const
detail::InMemoryDirectory::const_iterator I
ObjCMethodDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
bool hasExplicitBound() const
Whether this type parameter has an explicitly-written type bound, e.g., "T : NSView".
ObjCMethodDecl * lookupPrivateMethod(const Selector &Sel, bool Instance=true) const
Lookup a method in the classes implementation hierarchy.
static ImplicitParamDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation IdLoc, IdentifierInfo *Id, QualType T, ImplicitParamKind ParamKind)
Create implicit parameter.
ObjCPropertyImplDecl - Represents implementation declaration of a property in a class or category imp...
llvm::mapped_iterator< param_const_iterator, GetTypeFn > param_type_iterator
ObjCProtocolDecl * lookupProtocolNamed(IdentifierInfo *PName)
static ObjCCompatibleAliasDecl * CreateDeserialized(ASTContext &C, unsigned ID)
ObjCPropertyImplDecl * FindPropertyImplDecl(IdentifierInfo *propertyId, ObjCPropertyQueryKind queryKind) const
FindPropertyImplDecl - This method looks up a previous ObjCPropertyImplDecl added to the list of thos...
bool isThisDeclarationADesignatedInitializer() const
Returns true if this specific method declaration is marked with the designated initializer attribute...
ObjCPropertyDecl * FindPropertyDeclaration(const IdentifierInfo *PropertyId, ObjCPropertyQueryKind QueryKind) const
FindPropertyDeclaration - Finds declaration of the property given its name in 'PropertyId' and return...
void setTypeParamList(ObjCTypeParamList *TPL)
Set the type parameters of this category.
QualType getObjCInterfaceType(const ObjCInterfaceDecl *Decl, ObjCInterfaceDecl *PrevDecl=nullptr) const
getObjCInterfaceType - Return the unique reference to the type for the specified ObjC interface decl...
void setNextIvar(ObjCIvarDecl *ivar)
ObjCCategoryDecl * getCategoryListRaw() const
Retrieve the raw pointer to the start of the category/extension list.
Expr - This represents one expression.
StringRef getName() const
Return the actual identifier string.
StringRef getObjCRuntimeNameAsString() const
Produce a name to be used for class's metadata.
static ObjCMethodDecl * Create(ASTContext &C, SourceLocation beginLoc, SourceLocation endLoc, Selector SelInfo, QualType T, TypeSourceInfo *ReturnTInfo, DeclContext *contextDecl, bool isInstance=true, bool isVariadic=false, bool isPropertyAccessor=false, bool isImplicitlyDeclared=false, bool isDefined=false, ImplementationControl impControl=None, bool HasRelatedResultType=false)
unsigned getNumArgs() const
StringRef getObjCRuntimeNameAsString() const
Produce a name to be used for protocol's metadata.
void setObjCMethodRedeclaration(const ObjCMethodDecl *MD, const ObjCMethodDecl *Redecl)
ObjCMethodDecl * lookupInstanceMethod(Selector Sel) const
Lookup an instance method for a given selector.
static ObjCTypeParamDecl * Create(ASTContext &ctx, DeclContext *dc, ObjCTypeParamVariance variance, SourceLocation varianceLoc, unsigned index, SourceLocation nameLoc, IdentifierInfo *name, SourceLocation colonLoc, TypeSourceInfo *boundInfo)
DeclContext * getDeclContext()
An abstract interface that should be implemented by listeners that want to be notified when an AST en...
bool isObjCIdType() const
void setObjCImplementation(ObjCInterfaceDecl *IFaceD, ObjCImplementationDecl *ImplD)
Set the implementation of ObjCInterfaceDecl.
void setImplementation(ObjCImplementationDecl *ImplD)
void mergeClassExtensionProtocolList(ObjCProtocolDecl *const *List, unsigned Num, ASTContext &C)
mergeClassExtensionProtocolList - Merge class extension's protocol list into the protocol list for th...
ObjCIvarDecl * lookupInstanceVariable(IdentifierInfo *IVarName, ObjCInterfaceDecl *&ClassDeclared)
bool isInstanceMethod() const
DeclContext * getParent()
getParent - Returns the containing DeclContext.
QualType getObjCIdType() const
Represents the Objective-CC id type.
void getDesignatedInitializers(llvm::SmallVectorImpl< const ObjCMethodDecl * > &Methods) const
Returns the designated initializers for the interface.
The result type of a method or function.
static ObjCTypeParamDecl * CreateDeserialized(ASTContext &ctx, unsigned ID)
ObjCTypeParamVariance
Describes the variance of a given generic parameter.
static bool isIntroducingInitializers(const ObjCInterfaceDecl *D)
static ObjCMethodDecl * CreateDeserialized(ASTContext &C, unsigned ID)
TypeSourceInfo * getReturnTypeSourceInfo() const
ObjCMethodDecl * lookupMethod(Selector Sel, bool isInstance) const
init_iterator init_begin()
init_begin() - Retrieve an iterator to the first initializer.
ivar_iterator ivar_begin() const
ObjCCategoryDecl * getCategoryDecl() const
bool isClassMethod() const
static ObjCCompatibleAliasDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, IdentifierInfo *Id, ObjCInterfaceDecl *aliasedClass)
redecl_range redecls() const
Returns an iterator range for all the redeclarations of the same decl.
static ObjCProtocolDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Assigning into this object requires the old value to be released and the new value to be retained...
QualType getSelfType(ASTContext &Context, const ObjCInterfaceDecl *OID, bool &selfIsPseudoStrong, bool &selfIsConsumed)
static void CollectOverriddenMethodsRecurse(const ObjCContainerDecl *Container, const ObjCMethodDecl *Method, SmallVectorImpl< const ObjCMethodDecl * > &Methods, bool MovedToSuper)
bool isDesignatedInitializer(Selector Sel, const ObjCMethodDecl **InitMethod=nullptr) const
Returns true if the given selector is a designated initializer for the interface. ...
QualType getUsageType(QualType objectType) const
Retrieve the type when this property is used with a specific base object type.
Encodes a location in the source.
IdentifierInfo & get(StringRef Name)
Return the identifier token info for the specified named identifier.
ExternalASTSource * getExternalSource() const
Retrieve a pointer to the external AST source associated with this AST context, if any...
const Type * getTypePtr() const
Retrieves a pointer to the underlying (unqualified) type.
StringRef getName() const
getName - Get the name of identifier for the class interface associated with this implementation as a...
const ObjCMethodDecl * getObjCMethodRedeclaration(const ObjCMethodDecl *MD) const
Get the duplicate declaration of a ObjCMethod in the same interface, or null if none exists...
bool isRedeclaration() const
True if this is a method redeclaration in the same interface.
ivar_iterator ivar_end() const
bool isValid() const
Return true if this is a valid SourceLocation object.
ASTContext & getASTContext() const LLVM_READONLY
Stmt * getBody() const override
Retrieve the body of this method, if it has one.
QualType withConst() const
all_protocol_iterator all_referenced_protocol_end() const
ObjCInterfaceDecl * lookupInheritedClass(const IdentifierInfo *ICName)
lookupInheritedClass - This method returns ObjCInterfaceDecl * of the super class whose name is passe...
ObjCCategoryDecl - Represents a category declaration.
const ObjCInterfaceDecl * getClassInterface() const
bool isPropertyAccessor() const
Represents one property declaration in an Objective-C interface.
QualType getReturnType() const
T * get(ExternalASTSource *Source) const
Retrieve the pointer to the AST node that this lazy pointer.
lookup_result lookup(DeclarationName Name) const
lookup - Find the declarations (if any) with the given Name in this context.
bool operator<(DeclarationName LHS, DeclarationName RHS)
Ordering on two declaration names.
QualType getObjCSelType() const
Retrieve the type that corresponds to the predefined Objective-C 'SEL' type.
instmeth_range instance_methods() const
ObjCCategoryDecl * FindCategoryDeclaration(IdentifierInfo *CategoryId) const
FindCategoryDeclaration - Finds category declaration in the list of categories for this class and ret...
bool HasUserDeclaredSetterMethod(const ObjCPropertyDecl *P) const
This routine returns 'true' if a user declared setter method was found in the class, its protocols, its super classes or categories.
ObjCCategoryImplDecl * getImplementation() const
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
prop_range properties() const
ObjCMethodDecl * getInstanceMethod(Selector Sel, bool AllowHidden=false) const
bool isInvalidDecl() const
ObjCInterfaceDecl * getDefinition()
Retrieve the definition of this class, or NULL if this class has been forward-declared (with @class) ...
void setIvarList(ObjCIvarDecl *ivar)
Represents the declaration of an Objective-C type parameter.
QualType getObjCObjectPointerType(QualType OIT) const
Return a ObjCObjectPointerType type for the given ObjCObjectType.
static ObjCImplementationDecl * Create(ASTContext &C, DeclContext *DC, ObjCInterfaceDecl *classInterface, ObjCInterfaceDecl *superDecl, SourceLocation nameLoc, SourceLocation atStartLoc, SourceLocation superLoc=SourceLocation(), SourceLocation IvarLBraceLoc=SourceLocation(), SourceLocation IvarRBraceLoc=SourceLocation())
static ObjCCategoryDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Selector getSelector() const
detail::InMemoryDirectory::const_iterator E
ObjCMethodFamily getMethodFamily() const
Derive the conventional family of this method.
ObjCMethodDecl * getCategoryInstanceMethod(Selector Sel) const
specific_decl_iterator - Iterates over a subrange of declarations stored in a DeclContext, providing only those that are of type SpecificDecl (or a class derived from it).
known_extensions_range known_extensions() const
static ObjCIvarDecl * Create(ASTContext &C, ObjCContainerDecl *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo, AccessControl ac, Expr *BW=nullptr, bool synthesized=false)
static ObjCAtDefsFieldDecl * CreateDeserialized(ASTContext &C, unsigned ID)
ObjCImplementationDecl - Represents a class definition - this is where method definitions are specifi...
QualType getObjCTypeParamType(const ObjCTypeParamDecl *Decl, ArrayRef< ObjCProtocolDecl * > protocols, QualType Canonical=QualType()) 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, its categories, and its super classes (using a linear search).
ObjCTypeParamList * getTypeParamList() const
Retrieve the type parameters of this class.
Represents a C++ base or member initializer.
instprop_range instance_properties() const
virtual void CompleteType(TagDecl *Tag)
Gives the external AST source an opportunity to complete an incomplete type.
ObjCInterfaceDecl * getCanonicalDecl() override
Retrieves the canonical declaration of this Objective-C class.
void setCategoryListRaw(ObjCCategoryDecl *category)
Set the raw pointer to the start of the category/extension list.
protocol_range protocols() const
ObjCImplementationDecl * getImplementation() const
void addDecl(Decl *D)
Add the declaration D into this context.
static void collectOverriddenMethodsSlow(const ObjCMethodDecl *Method, SmallVectorImpl< const ObjCMethodDecl * > &overridden)
ASTMutationListener * getASTMutationListener() const
Retrieve a pointer to the AST mutation listener associated with this AST context, if any...
No particular method family.
Represents a field declaration created by an @defs(...).
classprop_range class_properties() const
void setIvarInitializers(ASTContext &C, CXXCtorInitializer **initializers, unsigned numInitializers)
static ObjCImplementationDecl * CreateDeserialized(ASTContext &C, unsigned ID)
all_protocol_iterator all_referenced_protocol_begin() const
void setClassInterface(ObjCInterfaceDecl *IFace)
ObjCIvarDecl - Represents an ObjC instance variable.
void * Allocate(size_t Size, unsigned Align=8) const
Stores a list of Objective-C type parameters for a parameterized class or a category/extension thereo...
ObjCInterfaceDecl * getSuperClass() const
Kind
Lists the kind of concrete classes of Decl.
QualType getSendResultType() const
Determine the type of an expression that sends a message to this function.
ObjCInterfaceDecl * getMostRecentDecl()
Returns the most recent (re)declaration of this declaration.
static ObjCInterfaceDecl * CreateDeserialized(const ASTContext &C, unsigned ID)
static ObjCPropertyImplDecl * CreateDeserialized(ASTContext &C, unsigned ID)
void addPropertyImplementation(ObjCPropertyImplDecl *property)
A trivial tuple used to represent a source range.
SourceLocation getLocation() const
ObjCIvarDecl * all_declared_ivar_begin()
all_declared_ivar_begin - return first ivar declared in this class, its extensions and its implementa...
static ObjCCategoryImplDecl * Create(ASTContext &C, DeclContext *DC, IdentifierInfo *Id, ObjCInterfaceDecl *classInterface, SourceLocation nameLoc, SourceLocation atStartLoc, SourceLocation CategoryNameLoc)
void collectInheritedProtocolProperties(const ObjCPropertyDecl *Property, ProtocolPropertySet &PS, PropertyDeclOrder &PO) const
TypeSourceInfo * getTypeSourceInfo() const
static ObjCPropertyDecl * CreateDeserialized(ASTContext &C, unsigned ID)
static void CollectOverriddenMethods(const ObjCContainerDecl *Container, const ObjCMethodDecl *Method, SmallVectorImpl< const ObjCMethodDecl * > &Methods)
void setHasDesignatedInitializers()
Indicate that this interface decl contains at least one initializer marked with the 'objc_designated_...
IdentifierInfo * getDefaultSynthIvarName(ASTContext &Ctx) const
Get the default name of the synthesized ivar.
void collectPropertiesToImplement(PropertyMap &PM, PropertyDeclOrder &PO) const override
This routine collects list of properties to be implemented in the class.
void setCmdDecl(ImplicitParamDecl *CD)
ObjCCategoryImplDecl - An object of this class encapsulates a category @implementation declaration...
The parameter is invariant: must match exactly.
const ObjCObjectType * getSuperClassType() const
Retrieve the superclass type.
visible_extensions_range visible_extensions() const
ObjCCompatibleAliasDecl - Represents alias of a class.
param_type_iterator param_type_begin() const