27#include "llvm/ADT/SmallVector.h"
28#include "llvm/Support/ErrorHandling.h"
29#include "llvm/Support/raw_ostream.h"
44 if (Elts == 0)
return;
46 List =
new (Ctx)
void*[Elts];
58 set(InList, Elts, Ctx);
73void ObjCContainerDecl::anchor() {}
81 Ivar != IvarEnd; ++Ivar) {
82 if (
auto *ivar = dyn_cast<ObjCIvarDecl>(*Ivar))
91 bool AllowHidden)
const {
94 if (
const auto *Proto = dyn_cast<ObjCProtocolDecl>(
this)) {
96 if (!Def->isUnconditionallyVisible() && !AllowHidden)
109 Meth != MethEnd; ++Meth) {
110 auto *MD = dyn_cast<ObjCMethodDecl>(*Meth);
111 if (MD && MD->isInstanceMethod() == isInstance)
127 Meth != MethEnd; ++Meth) {
128 auto *MD = dyn_cast<ObjCMethodDecl>(*Meth);
129 if (MD && MD->isInstanceMethod() && !MD->isImplicit())
133 if (
const auto *ID = dyn_cast<ObjCInterfaceDecl>(
this)) {
136 for (
const auto *Cat : ID->visible_categories()) {
138 if (!MD->isImplicit())
140 if (Cat->IsClassExtension())
146 for (
const auto *P : Cat->properties())
147 if (P->getIdentifier() ==
Property->getIdentifier()) {
148 if (P->getPropertyAttributes() &
156 for (
const auto *Proto : ID->all_referenced_protocols())
157 if (Proto->HasUserDeclaredSetterMethod(
Property))
168 if (
const auto *PD = dyn_cast<ObjCProtocolDecl>(
this))
169 for (
const auto *PI : PD->protocols())
170 if (PI->HasUserDeclaredSetterMethod(
Property))
181 if (
const auto *Proto = dyn_cast<ObjCProtocolDecl>(DC)) {
183 if (!Def->isUnconditionallyVisible())
189 if (
auto *IDecl = dyn_cast<ObjCInterfaceDecl>(DC)) {
190 for (
const auto *Ext : IDecl->visible_extensions())
198 ObjCPropertyDecl *classProp =
nullptr;
201 if (
auto *PD = dyn_cast<ObjCPropertyDecl>(*I)) {
205 !PD->isClassProperty()) ||
207 PD->isClassProperty()) ||
209 !PD->isClassProperty()))
212 if (PD->isClassProperty())
227 llvm::raw_svector_ostream os(ivarName);
234 bool IsInstance)
const {
236 if (
auto *Prop = dyn_cast<ObjCPropertyDecl>(
LookupResult)) {
237 if (Prop->isInstanceProperty() == IsInstance) {
251 if (
const auto *Proto = dyn_cast<ObjCProtocolDecl>(
this)) {
253 if (!Def->isUnconditionallyVisible())
259 if (
const auto *ClassDecl = dyn_cast<ObjCInterfaceDecl>(
this)) {
260 for (
const auto *Ext : ClassDecl->visible_extensions()) {
261 if (
auto *P = Ext->FindPropertyDeclaration(PropertyId, QueryKind))
274 case Decl::ObjCProtocol: {
276 for (
const auto *I : PID->protocols())
282 case Decl::ObjCInterface: {
285 for (
const auto *Cat : OID->visible_categories()) {
286 if (!Cat->IsClassExtension())
288 PropertyId, QueryKind))
293 for (
const auto *I : OID->all_referenced_protocols())
300 return superClass->FindPropertyDeclaration(PropertyId, QueryKind);
303 case Decl::ObjCCategory: {
306 if (!OCD->IsClassExtension())
307 for (
const auto *I : OCD->protocols())
317void ObjCInterfaceDecl::anchor() {}
326 return def->getTypeParamListAsWritten();
345 for (
auto *typeParam : *TypeParamList)
346 typeParam->setDeclContext(
this);
354 if (data().ExternallyCompleted)
355 LoadExternalDefinition();
358 if (ObjCInterfaceDecl *superDecl = superType->getInterface()) {
359 if (ObjCInterfaceDecl *superDef = superDecl->getDefinition())
371 return superTInfo->getTypeLoc().getBeginLoc();
385 if (data().ExternallyCompleted)
386 LoadExternalDefinition();
404 PM[std::make_pair(Prop->getIdentifier(), Prop->isClassProperty())] = Prop;
409 PM[std::make_pair(Prop->getIdentifier(), Prop->isClassProperty())] = Prop;
413 PI->collectPropertiesToImplement(PM);
420 const ObjCInterfaceDecl *
Class =
this;
422 if (
Class->hasAttr<ArcWeakrefUnavailableAttr>())
430 const ObjCInterfaceDecl *
Class =
this;
432 if (
Class->hasAttr<ObjCRequiresPropertyDefsAttr>())
442 if (data().ExternallyCompleted)
443 LoadExternalDefinition();
445 if (data().AllReferencedProtocols.empty() &&
446 data().ReferencedProtocols.empty()) {
447 data().AllReferencedProtocols.set(ExtList, ExtNum,
C);
455 for (
unsigned i = 0; i < ExtNum; i++) {
456 bool protocolExists =
false;
459 if (
C.ProtocolCompatibleWithProtocol(ProtoInExtension, Proto)) {
460 protocolExists =
true;
467 ProtocolRefs.push_back(ProtoInExtension);
470 if (ProtocolRefs.empty())
477 data().AllReferencedProtocols.set(ProtocolRefs.data(), ProtocolRefs.size(),
C);
481ObjCInterfaceDecl::findInterfaceWithDesignatedInitializers()
const {
486 if (!IFace->inheritsDesignatedInitializers())
495 if (MD->getMethodFamily() ==
OMF_init && !MD->isOverriding())
499 for (
const auto *MD : Ext->instance_methods()) {
500 if (MD->getMethodFamily() ==
OMF_init && !MD->isOverriding())
505 for (
const auto *MD : ImplD->instance_methods()) {
506 if (MD->getMethodFamily() ==
OMF_init && !MD->isOverriding())
513bool ObjCInterfaceDecl::inheritsDesignatedInitializers()
const {
514 switch (data().InheritedDesignatedInitializers) {
515 case DefinitionData::IDI_Inherited:
517 case DefinitionData::IDI_NotInherited:
519 case DefinitionData::IDI_Unknown:
524 data().InheritedDesignatedInitializers = DefinitionData::IDI_NotInherited;
527 data().InheritedDesignatedInitializers =
528 SuperD->declaresOrInheritsDesignatedInitializers() ?
529 DefinitionData::IDI_Inherited :
530 DefinitionData::IDI_NotInherited;
532 data().InheritedDesignatedInitializers =
533 DefinitionData::IDI_NotInherited;
536 assert(data().InheritedDesignatedInitializers
537 != DefinitionData::IDI_Unknown);
538 return data().InheritedDesignatedInitializers ==
539 DefinitionData::IDI_Inherited;
542 llvm_unreachable(
"unexpected InheritedDesignatedInitializers value");
550 if (data().ExternallyCompleted)
551 LoadExternalDefinition();
553 const ObjCInterfaceDecl *IFace= findInterfaceWithDesignatedInitializers();
558 if (MD->isThisDeclarationADesignatedInitializer())
559 Methods.push_back(MD);
561 for (
const auto *MD : Ext->instance_methods())
562 if (MD->isThisDeclarationADesignatedInitializer())
563 Methods.push_back(MD);
575 HasCompleteDef =
true;
581 if (data().ExternallyCompleted)
582 LoadExternalDefinition();
584 const ObjCInterfaceDecl *IFace= findInterfaceWithDesignatedInitializers();
589 if (MD->isThisDeclarationADesignatedInitializer()) {
597 if (MD->isThisDeclarationADesignatedInitializer()) {
607void ObjCInterfaceDecl::allocateDefinitionData() {
608 assert(!
hasDefinition() &&
"ObjC class already has a definition");
610 Data.getPointer()->Definition =
this;
614 allocateDefinitionData();
624 Data.setPointer(
nullptr);
625 allocateDefinitionData();
635 ObjCInterfaceDecl *&clsDeclared) {
640 if (data().ExternallyCompleted)
641 LoadExternalDefinition();
643 ObjCInterfaceDecl* ClassDecl =
this;
644 while (ClassDecl !=
nullptr) {
646 clsDeclared = ClassDecl;
652 clsDeclared = ClassDecl;
671 if (data().ExternallyCompleted)
672 LoadExternalDefinition();
674 ObjCInterfaceDecl* ClassDecl =
this;
675 while (ClassDecl !=
nullptr) {
686 if (P->lookupProtocolNamed(Name))
698 bool shallowCategoryLookup,
706 const ObjCInterfaceDecl* ClassDecl =
this;
709 if (data().ExternallyCompleted)
710 LoadExternalDefinition();
714 if ((MethodDecl = ClassDecl->
getMethod(Sel, isInstance)))
719 if ((MethodDecl = Cat->getMethod(Sel, isInstance)))
724 for (
const auto *I : ClassDecl->
protocols())
725 if ((MethodDecl = I->lookupMethod(Sel, isInstance)))
729 if (!shallowCategoryLookup)
733 Cat->getReferencedProtocols();
734 for (
auto *Protocol : Protocols)
735 if ((MethodDecl = Protocol->lookupMethod(Sel, isInstance)))
755 bool Instance)
const {
760 if (data().ExternallyCompleted)
761 LoadExternalDefinition();
765 Method = Instance ? ImpDecl->getInstanceMethod(Sel)
766 : ImpDecl->getClassMethod(Sel);
789 assert(
hasDefinition() &&
"ODRHash only for records with definitions");
793 return data().ODRHash;
801 return data().ODRHash;
804bool ObjCInterfaceDecl::hasODRHash()
const {
807 return data().HasODRHash;
810void ObjCInterfaceDecl::setHasODRHash(
bool HasHash) {
811 assert(
hasDefinition() &&
"Cannot set ODRHash without definition");
812 data().HasODRHash = HasHash;
819ObjCMethodDecl::ObjCMethodDecl(
822 bool isInstance,
bool isVariadic,
bool isPropertyAccessor,
823 bool isSynthesizedAccessorStub,
bool isImplicitlyDeclared,
bool isDefined,
825 :
NamedDecl(ObjCMethod, contextDecl, beginLoc, SelInfo),
826 DeclContext(ObjCMethod), MethodDeclType(
T), ReturnTInfo(ReturnTInfo),
832 setInstanceMethod(isInstance);
833 setVariadic(isVariadic);
834 setPropertyAccessor(isPropertyAccessor);
835 setSynthesizedAccessorStub(isSynthesizedAccessorStub);
836 setDefined(isDefined);
837 setIsRedeclaration(
false);
838 setHasRedeclaration(
false);
839 setDeclImplementation(impControl);
841 setRelatedResultType(HasRelatedResultType);
843 setOverriding(
false);
844 setHasSkippedBody(
false);
854 bool isImplicitlyDeclared,
bool isDefined,
856 return new (
C, contextDecl) ObjCMethodDecl(
857 beginLoc, endLoc, SelInfo,
T, ReturnTInfo, contextDecl, isInstance,
859 isImplicitlyDeclared,
isDefined, impControl, HasRelatedResultType);
880 }
else if (
const auto *PD = dyn_cast<ObjCProtocolDecl>(
getDeclContext())) {
883 assert(
false &&
"Context should be set for ObjCMethodDecl");
900 if (
const auto *PD = dyn_cast<const ObjCProtocolDecl>(
getDeclContext()))
902 if (
const auto *ID = dyn_cast<const ObjCInterfaceDecl>(
getDeclContext()))
908 const ObjCMethodDecl **InitMethod)
const {
915 return ID->isDesignatedInitializer(
getSelector(), InitMethod);
921 if (param->isDestroyedInCallee())
938void ObjCMethodDecl::setParamsAndSelLocs(
ASTContext &
C,
941 ParamsAndSelLocs =
nullptr;
942 NumParams = Params.size();
943 if (Params.empty() && SelLocs.empty())
947 "Alignment not sufficient for SourceLocation");
949 unsigned Size =
sizeof(
ParmVarDecl *) * NumParams +
951 ParamsAndSelLocs =
C.Allocate(Size);
952 llvm::uninitialized_copy(Params, getParams());
953 llvm::uninitialized_copy(SelLocs, getStoredSelLocs());
966 "No selector locs for non-implicit method");
968 return setParamsAndSelLocs(
C, Params, {});
973 return setParamsAndSelLocs(
C, Params, {});
975 setParamsAndSelLocs(
C, Params, SelLocs);
991 if (!CtxD->isInvalidDecl()) {
992 if (
auto *IFD = dyn_cast<ObjCInterfaceDecl>(CtxD)) {
994 if (!ImplD->isInvalidDecl())
997 }
else if (
auto *CD = dyn_cast<ObjCCategoryDecl>(CtxD)) {
999 if (!ImplD->isInvalidDecl())
1002 }
else if (
auto *ImplD = dyn_cast<ObjCImplementationDecl>(CtxD)) {
1003 if (ObjCInterfaceDecl *IFD = ImplD->getClassInterface())
1004 if (!IFD->isInvalidDecl())
1007 }
else if (
auto *CImplD = dyn_cast<ObjCCategoryImplDecl>(CtxD)) {
1008 if (ObjCCategoryDecl *CatD = CImplD->getCategoryDecl())
1009 if (!CatD->isInvalidDecl())
1027 return Redecl ? Redecl :
this;
1034 if (
auto *ImplD = dyn_cast<ObjCImplementationDecl>(CtxD)) {
1044 for (
auto *Ext : IFD->known_extensions())
1048 }
else if (
auto *CImplD = dyn_cast<ObjCCategoryImplDecl>(CtxD)) {
1056 ObjCMethodDecl *MD =
1059 return MD ? MD :
this;
1067 return Body->getEndLoc();
1080 switch (
attr->getFamily()) {
1081 case ObjCMethodFamilyAttr::OMF_None: family =
OMF_None;
break;
1082 case ObjCMethodFamilyAttr::OMF_alloc: family =
OMF_alloc;
break;
1083 case ObjCMethodFamilyAttr::OMF_copy: family =
OMF_copy;
break;
1084 case ObjCMethodFamilyAttr::OMF_init: family =
OMF_init;
break;
1085 case ObjCMethodFamilyAttr::OMF_mutableCopy: family =
OMF_mutableCopy;
break;
1086 case ObjCMethodFamilyAttr::OMF_new: family =
OMF_new;
break;
1135 if (noParams < 1 || noParams > 3)
1144 while (--noParams) {
1165 bool &selfIsPseudoStrong,
1166 bool &selfIsConsumed)
const {
1168 selfIsPseudoStrong =
false;
1169 selfIsConsumed =
false;
1174 selfTy = Context.getObjCInterfaceType(OID);
1175 selfTy = Context.getObjCObjectPointerType(selfTy);
1177 selfTy = Context.getObjCIdType();
1180 selfTy = Context.getObjCClassType();
1182 if (Context.getLangOpts().ObjCAutoRefCount) {
1190 selfTy = Context.getQualifiedType(selfTy, qs);
1195 selfIsPseudoStrong =
true;
1202 selfIsPseudoStrong =
true;
1210 bool selfIsPseudoStrong, selfIsConsumed;
1212 getSelfType(Context, OID, selfIsPseudoStrong, selfIsConsumed);
1214 &Context.Idents.get(
"self"), selfTy,
1219 Self->addAttr(NSConsumedAttr::CreateImplicit(Context));
1221 if (selfIsPseudoStrong)
1222 Self->setARCPseudoStrong(
true);
1234 return CD->getClassInterface();
1236 return IMD->getClassInterface();
1239 llvm_unreachable(
"unknown method context");
1245 if (
auto *IMD = dyn_cast<ObjCCategoryImplDecl>(
getDeclContext()))
1246 return IMD->getCategoryDecl();
1253 return TSI->getTypeLoc().getSourceRange();
1274 bool MovedToSuper) {
1281 if (
const auto *Category = dyn_cast<ObjCCategoryDecl>(Container)) {
1286 Overridden = Container->
getMethod(Method->getSelector(),
1287 Method->isInstanceMethod(),
1289 if (Method != Overridden) {
1292 Methods.push_back(Overridden);
1296 for (
const auto *P : Category->protocols())
1303 Overridden = Container->
getMethod(Method->getSelector(),
1304 Method->isInstanceMethod(),
1306 if (Method != Overridden) {
1309 Methods.push_back(Overridden);
1313 if (
const auto *Protocol = dyn_cast<ObjCProtocolDecl>(Container)){
1314 for (
const auto *P : Protocol->protocols())
1318 if (
const auto *
Interface = dyn_cast<ObjCInterfaceDecl>(Container)) {
1319 for (
const auto *P :
Interface->protocols())
1322 for (
const auto *Cat :
Interface->known_categories())
1340 assert(Method->isOverriding());
1342 if (
const auto *ProtD =
1343 dyn_cast<ObjCProtocolDecl>(Method->getDeclContext())) {
1346 }
else if (
const auto *IMD =
1347 dyn_cast<ObjCImplDecl>(Method->getDeclContext())) {
1353 if (
const ObjCMethodDecl *IFaceMeth = ID->getMethod(Method->getSelector(),
1354 Method->isInstanceMethod(),
1359 }
else if (
const auto *CatD =
1360 dyn_cast<ObjCCategoryDecl>(Method->getDeclContext())) {
1366 if (
const ObjCMethodDecl *IFaceMeth = ID->getMethod(Method->getSelector(),
1367 Method->isInstanceMethod(),
1374 dyn_cast_or_null<ObjCContainerDecl>(Method->getDeclContext()),
1375 Method, overridden);
1381 const ObjCMethodDecl *
Method =
this;
1383 if (
Method->isRedeclaration()) {
1385 ->getMethod(
Method->getSelector(),
Method->isInstanceMethod(),
1389 if (
Method->isOverriding()) {
1391 assert(!Overridden.empty() &&
1392 "ObjCMethodDecl's overriding bit is not as expected");
1406 if (
auto *ImplDecl = dyn_cast<ObjCImplDecl>(Container))
1408 Container = ImplDecl->getClassInterface();
1410 bool IsGetter = (NumArgs == 0);
1415 auto findMatchingProperty =
1418 for (
const auto *I : Container->instance_properties()) {
1419 Selector NextSel = IsGetter ? I->getGetterName()
1420 : I->getSetterName();
1425 for (
const auto *I : Container->class_properties()) {
1426 Selector NextSel = IsGetter ? I->getGetterName()
1427 : I->getSetterName();
1437 if (
const auto *
Found = findMatchingProperty(Container))
1442 if (
const auto *Category = dyn_cast<ObjCCategoryDecl>(Container)) {
1443 ClassDecl = Category->getClassInterface();
1444 if (
const auto *
Found = findMatchingProperty(ClassDecl))
1450 assert(ClassDecl &&
"Failed to find main class");
1454 if (Ext == Container)
1456 if (
const auto *
Found = findMatchingProperty(Ext))
1463 if (Cat == Container)
1465 if (
const auto *
Found = findMatchingProperty(Cat))
1469 llvm_unreachable(
"Marked as a property accessor but no property found!");
1472 if (!CheckOverrides)
1477 OverridesTy Overrides;
1479 for (
const auto *
Override : Overrides)
1490void ObjCTypeParamDecl::anchor() {}
1501 new (ctx, dc) ObjCTypeParamDecl(ctx, dc, variance, varianceLoc,
index,
1502 nameLoc, name, colonLoc, boundInfo);
1510 return new (ctx, ID) ObjCTypeParamDecl(ctx,
nullptr,
1535 : Brackets(lAngleLoc, rAngleLoc), NumParams(typeParams.size()) {
1536 llvm::copy(typeParams, begin());
1545 ctx.
Allocate(totalSizeToAlloc<ObjCTypeParamDecl *>(typeParams.size()),
1546 alignof(ObjCTypeParamList));
1547 return new (mem) ObjCTypeParamList(lAngleLoc, typeParams, rAngleLoc);
1552 typeArgs.reserve(
size());
1553 for (
auto *typeParam : *
this)
1554 typeArgs.push_back(typeParam->getUnderlyingType());
1564 ObjCInterfaceDecl *PrevDecl,
SourceLocation ClassLoc,
bool isInternal) {
1566 ObjCInterfaceDecl(
C, DC, atLoc, Id, typeParamList, ClassLoc, PrevDecl,
1568 Result->Data.setInt(!
C.getLangOpts().Modules);
1569 C.getObjCInterfaceType(
Result, PrevDecl);
1578 Result->Data.setInt(!
C.getLangOpts().Modules);
1582ObjCInterfaceDecl::ObjCInterfaceDecl(
1587 redeclarable_base(
C) {
1592 Data = PrevDecl->Data;
1599void ObjCInterfaceDecl::LoadExternalDefinition()
const {
1600 assert(data().ExternallyCompleted &&
"Class is not externally completed");
1601 data().ExternallyCompleted =
false;
1608 "Class can't be externally completed without an external source");
1610 "Forward declarations can't be externally completed");
1611 data().ExternallyCompleted =
true;
1618 data().HasDesignatedInitializers =
true;
1625 if (data().ExternallyCompleted)
1626 LoadExternalDefinition();
1628 return data().HasDesignatedInitializers;
1634 return ObjCRTName->getMetadataName();
1643 return ID->getObjCRuntimeNameAsString();
1650 if (data().ExternallyCompleted)
1651 LoadExternalDefinition();
1654 const_cast<ObjCInterfaceDecl*
>(Def));
1667struct SynthesizeIvarChunk {
1672 : Size(size), Ivar(ivar) {}
1675bool operator<(
const SynthesizeIvarChunk & LHS,
1676 const SynthesizeIvarChunk &RHS) {
1677 return LHS.Size < RHS.Size;
1697 if (!data().IvarList) {
1701 (void)Ext->ivar_empty();
1705 data().IvarList = *I; ++I;
1706 for (curIvar = data().IvarList; I != E; curIvar = *I, ++I)
1711 if (!Ext->ivar_empty()) {
1713 I = Ext->ivar_begin(),
1714 E = Ext->ivar_end();
1715 if (!data().IvarList) {
1716 data().IvarList = *I; ++I;
1717 curIvar = data().IvarList;
1719 for ( ;I != E; curIvar = *I, ++I)
1723 data().IvarListMissingImplementation =
true;
1727 if (!data().IvarListMissingImplementation)
1728 return data().IvarList;
1731 data().IvarListMissingImplementation =
false;
1732 if (!ImplDecl->ivar_empty()) {
1734 for (
auto *IV : ImplDecl->ivars()) {
1735 if (IV->getSynthesize() && !IV->isInvalidDecl()) {
1736 layout.push_back(SynthesizeIvarChunk(
1737 IV->getASTContext().getTypeSize(IV->getType()), IV));
1740 if (!data().IvarList)
1741 data().IvarList = IV;
1747 if (!layout.empty()) {
1749 llvm::stable_sort(layout);
1750 unsigned Ix = 0, EIx = layout.size();
1751 if (!data().IvarList) {
1752 data().IvarList = layout[0].Ivar; Ix++;
1753 curIvar = data().IvarList;
1755 for ( ; Ix != EIx; curIvar = layout[Ix].Ivar, Ix++)
1760 return data().IvarList;
1773 if (data().ExternallyCompleted)
1774 LoadExternalDefinition();
1777 if (Cat->getIdentifier() == CategoryId)
1808 bool lookupCategory,
1809 bool RHSIsQualifiedID) {
1813 ObjCInterfaceDecl *IDecl =
this;
1816 if (
getASTContext().ProtocolCompatibleWithProtocol(lProto, PI))
1824 if (RHSIsQualifiedID &&
1832 for (
auto *PI : Cat->protocols())
1833 if (
getASTContext().ProtocolCompatibleWithProtocol(lProto, PI))
1850void ObjCIvarDecl::anchor() {}
1857 Expr *BW,
bool synthesized) {
1871 "Invalid ivar decl context!");
1874 auto *ID = dyn_cast<ObjCInterfaceDecl>(DC);
1876 if (
auto *IM = dyn_cast<ObjCImplementationDecl>(DC))
1877 ID = IM->getClassInterface();
1881 ID->setIvarList(
nullptr);
1884 return new (
C, DC) ObjCIvarDecl(DC, StartLoc, IdLoc, Id,
T, TInfo, ac, BW,
1897 switch (DC->getKind()) {
1899 case ObjCCategoryImpl:
1901 llvm_unreachable(
"invalid ivar container!");
1904 case ObjCCategory: {
1906 assert(CD->IsClassExtension() &&
"invalid container for ivar!");
1907 return CD->getClassInterface();
1910 case ObjCImplementation:
1927void ObjCAtDefsFieldDecl::anchor() {}
1933 return new (
C, DC) ObjCAtDefsFieldDecl(DC, StartLoc, IdLoc, Id,
T, BW);
1947void ObjCProtocolDecl::anchor() {}
1954 redeclarable_base(
C) {
1955 setPreviousDecl(PrevDecl);
1957 Data = PrevDecl->Data;
1964 ObjCProtocolDecl *PrevDecl) {
1966 new (
C, DC) ObjCProtocolDecl(
C, DC, Id, nameLoc, atStartLoc, PrevDecl);
1967 Result->Data.setInt(!
C.getLangOpts().Modules);
1973 ObjCProtocolDecl *
Result =
1976 Result->Data.setInt(!
C.getLangOpts().Modules);
1985 llvm::DenseSet<const ObjCProtocolDecl *> &IPs)
const {
1986 std::queue<const ObjCProtocolDecl *> WorkQueue;
1987 WorkQueue.push(
this);
1989 while (!WorkQueue.empty()) {
1990 const auto *PD = WorkQueue.front();
1992 for (
const auto *Parent : PD->protocols()) {
1993 const auto *Can = Parent->getCanonicalDecl();
1994 auto Result = IPs.insert(Can);
1996 WorkQueue.push(Parent);
2002 ObjCProtocolDecl *PDecl =
this;
2017 bool isInstance)
const {
2026 if ((MethodDecl =
getMethod(Sel, isInstance)))
2030 if ((MethodDecl = I->lookupMethod(Sel, isInstance)))
2035void ObjCProtocolDecl::allocateDefinitionData() {
2036 assert(!
Data.getPointer() &&
"Protocol already has a definition!");
2038 Data.getPointer()->Definition =
this;
2039 Data.getPointer()->HasODRHash =
false;
2043 allocateDefinitionData();
2047 RD->Data = this->Data;
2051 Data.setPointer(
nullptr);
2052 allocateDefinitionData();
2063 for (
auto *Prop : PDecl->properties()) {
2065 PM.insert(std::make_pair(
2066 std::make_pair(Prop->getIdentifier(), Prop->isClassProperty()),
2070 for (
const auto *PI : PDecl->protocols())
2071 PI->collectPropertiesToImplement(PM);
2079 if (!PS.insert(PDecl).second)
2081 for (
auto *Prop : PDecl->properties()) {
2084 if (Prop->getIdentifier() ==
Property->getIdentifier()) {
2090 for (
const auto *PI : PDecl->protocols())
2091 PI->collectInheritedProtocolProperties(
Property, PS, PO);
2098 return ObjCRTName->getMetadataName();
2104 assert(
hasDefinition() &&
"ODRHash only for records with definitions");
2108 return data().ODRHash;
2114 setHasODRHash(
true);
2116 return data().ODRHash;
2119bool ObjCProtocolDecl::hasODRHash()
const {
2122 return data().HasODRHash;
2125void ObjCProtocolDecl::setHasODRHash(
bool HasHash) {
2126 assert(
hasDefinition() &&
"Cannot set ODRHash without definition");
2127 data().HasODRHash = HasHash;
2134void ObjCCategoryDecl::anchor() {}
2136ObjCCategoryDecl::ObjCCategoryDecl(
2142 ClassInterface(IDecl), CategoryNameLoc(CategoryNameLoc),
2143 IvarLBraceLoc(IvarLBraceLoc), IvarRBraceLoc(IvarRBraceLoc) {
2144 setTypeParamList(typeParamList);
2154 new (
C, DC) ObjCCategoryDecl(DC, AtLoc, ClassNameLoc, CategoryNameLoc, Id,
2155 IDecl, typeParamList, IvarLBraceLoc,
2163 L->AddedObjCCategoryToInterface(CatDecl, IDecl);
2174 nullptr,
nullptr,
nullptr);
2179 const_cast<ObjCCategoryDecl*
>(
this));
2187 TypeParamList = TPL;
2191 for (
auto *typeParam : *TypeParamList)
2192 typeParam->setDeclContext(
this);
2199void ObjCCategoryImplDecl::anchor() {}
2205 if (ClassInterface && ClassInterface->hasDefinition())
2206 ClassInterface = ClassInterface->getDefinition();
2207 return new (
C, DC) ObjCCategoryImplDecl(DC, Id, ClassInterface, nameLoc,
2208 atStartLoc, CategoryNameLoc);
2213 return new (
C, ID) ObjCCategoryImplDecl(
nullptr,
nullptr,
nullptr,
2225void ObjCImplDecl::anchor() {}
2236 if (
auto *ImplD = dyn_cast_or_null<ObjCImplementationDecl>(
this)) {
2240 }
else if (
auto *ImplD = dyn_cast_or_null<ObjCCategoryImplDecl>(
this)) {
2245 ClassInterface = IFace;
2254 if (PID->getPropertyIvarDecl() &&
2255 PID->getPropertyIvarDecl()->getIdentifier() == ivarId)
2270 if (PID->getPropertyDecl()->getIdentifier() == Id) {
2272 !PID->getPropertyDecl()->isClassProperty()) ||
2274 PID->getPropertyDecl()->isClassProperty()) ||
2276 !PID->getPropertyDecl()->isClassProperty()))
2279 if (PID->getPropertyDecl()->isClassProperty())
2280 ClassPropImpl = PID;
2285 return ClassPropImpl;
2300void ObjCImplementationDecl::anchor() {}
2311 if (ClassInterface && ClassInterface->hasDefinition())
2312 ClassInterface = ClassInterface->getDefinition();
2313 return new (
C, DC) ObjCImplementationDecl(DC, ClassInterface, SuperDecl,
2314 nameLoc, atStartLoc, superLoc,
2315 IvarLBraceLoc, IvarRBraceLoc);
2320 return new (
C, ID) ObjCImplementationDecl(
nullptr,
nullptr,
nullptr,
2326 unsigned numInitializers) {
2327 if (numInitializers > 0) {
2328 NumIvarInitializers = numInitializers;
2330 memcpy(ivarInitializers, initializers,
2332 IvarInitializers = ivarInitializers;
2338 return IvarInitializers.get(
getASTContext().getExternalSource());
2351void ObjCCompatibleAliasDecl::anchor() {}
2358 return new (
C, DC) ObjCCompatibleAliasDecl(DC, L, Id, AliasedClass);
2371void ObjCPropertyDecl::anchor() {}
2378 return new (
C, DC) ObjCPropertyDecl(DC, L, Id, AtLoc, LParenLoc,
T, TSI,
2384 return new (
C, ID) ObjCPropertyDecl(
nullptr,
SourceLocation(),
nullptr,
2401 Parent = MD->getClassInterface();
2403 Parent = dyn_cast<ObjCProtocolDecl>(MD->getDeclContext());
2412 assert(
false &&
"Parent should not be null");
2416 OS <<
' ' <<
getName() <<
']';
2441 return new (
C, DC) ObjCPropertyImplDecl(DC, atLoc, L, property, PK, ivar,
2454 if (IvarLoc.isValid())
Defines the clang::ASTContext interface.
static void CollectOverriddenMethodsRecurse(const ObjCContainerDecl *Container, const ObjCMethodDecl *Method, SmallVectorImpl< const ObjCMethodDecl * > &Methods, bool MovedToSuper)
static bool isIntroducingInitializers(const ObjCInterfaceDecl *D)
static void collectOverriddenMethodsSlow(const ObjCMethodDecl *Method, SmallVectorImpl< const ObjCMethodDecl * > &overridden)
static void CollectOverriddenMethods(const ObjCContainerDecl *Container, const ObjCMethodDecl *Method, SmallVectorImpl< const ObjCMethodDecl * > &Methods)
Defines the clang::IdentifierInfo, clang::IdentifierTable, and clang::Selector interfaces.
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified.
Defines the clang::LangOptions interface.
This file contains the declaration of the ODRHash class, which calculates a hash based on AST nodes,...
Defines the clang::SourceLocation class and associated facilities.
Defines the clang::TypeLoc interface and its subclasses.
C Language Family Type Representation.
__DEVICE__ void * memcpy(void *__a, const void *__b, size_t __c)
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
void setObjCImplementation(ObjCInterfaceDecl *IFaceD, ObjCImplementationDecl *ImplD)
Set the implementation of ObjCInterfaceDecl.
const LangOptions & getLangOpts() const
IdentifierInfo * getNSObjectName() const
Retrieve the identifier 'NSObject'.
const ObjCMethodDecl * getObjCMethodRedeclaration(const ObjCMethodDecl *MD) const
Get the duplicate declaration of a ObjCMethod in the same interface, or null if none exists.
void * Allocate(size_t Size, unsigned Align=8) const
QualType getObjCTypeParamType(const ObjCTypeParamDecl *Decl, ArrayRef< ObjCProtocolDecl * > protocols) const
ExternalASTSource * getExternalSource() const
Retrieve a pointer to the external AST source associated with this AST context, if any.
ObjCImplementationDecl * getObjCImplementation(ObjCInterfaceDecl *D)
Get the implementation of the ObjCInterfaceDecl D, or nullptr if none exists.
void setObjCMethodRedeclaration(const ObjCMethodDecl *MD, const ObjCMethodDecl *Redecl)
An abstract interface that should be implemented by listeners that want to be notified when an AST en...
Represents a C++ base or member initializer.
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
DeclContext * getParent()
getParent - Returns the containing DeclContext.
lookup_result::iterator lookup_iterator
DeclContextLookupResult lookup_result
ObjCMethodDeclBitfields ObjCMethodDeclBits
lookup_result lookup(DeclarationName Name) const
lookup - Find the declarations (if any) with the given Name in this context.
DeclContext(Decl::Kind K)
void addDecl(Decl *D)
Add the declaration D into this context.
SourceLocation getEndLoc() const LLVM_READONLY
ASTContext & getASTContext() const LLVM_READONLY
bool isImplicit() const
isImplicit - Indicates whether the declaration was implicitly generated by the implementation.
bool isUnconditionallyVisible() const
Determine whether this declaration is definitely visible to name lookup, independent of whether the o...
Kind
Lists the kind of concrete classes of Decl.
virtual Decl * getNextRedeclarationImpl()
Returns the next redeclaration or itself if this is the only decl.
SourceLocation getLocation() const
void setImplicit(bool I=true)
DeclContext * getDeclContext()
void setLexicalDeclContext(DeclContext *DC)
This represents one expression.
virtual void CompleteType(TagDecl *Tag)
Gives the external AST source an opportunity to complete an incomplete type.
One of these records is kept for each identifier that is lexed.
StringRef getName() const
Return the actual identifier string.
IdentifierInfo & get(StringRef Name)
Return the identifier token info for the specified named identifier.
static ImplicitParamDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation IdLoc, const IdentifierInfo *Id, QualType T, ImplicitParamKind ParamKind)
Create implicit parameter.
Represents the results of name lookup.
This represents a decl that may have a name.
IdentifierInfo * getIdentifier() const
Get the identifier that names this declaration, if there is one.
NamedDecl(Kind DK, DeclContext *DC, SourceLocation L, DeclarationName N)
StringRef getName() const
Get the name of identifier for this declaration as a StringRef.
virtual void printName(raw_ostream &OS, const PrintingPolicy &Policy) const
Pretty-print the unqualified name of this declaration.
void AddObjCProtocolDecl(const ObjCProtocolDecl *P)
void AddObjCInterfaceDecl(const ObjCInterfaceDecl *Record)
Represents a field declaration created by an @defs(...).
static ObjCAtDefsFieldDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID)
static ObjCAtDefsFieldDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, QualType T, Expr *BW)
ObjCCategoryDecl - Represents a category declaration.
static ObjCCategoryDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation AtLoc, SourceLocation ClassNameLoc, SourceLocation CategoryNameLoc, const IdentifierInfo *Id, ObjCInterfaceDecl *IDecl, ObjCTypeParamList *typeParamList, SourceLocation IvarLBraceLoc=SourceLocation(), SourceLocation IvarRBraceLoc=SourceLocation())
void setTypeParamList(ObjCTypeParamList *TPL)
Set the type parameters of this category.
static ObjCCategoryDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID)
ObjCCategoryImplDecl * getImplementation() const
specific_decl_iterator< ObjCIvarDecl > ivar_iterator
void setImplementation(ObjCCategoryImplDecl *ImplD)
ObjCCategoryImplDecl - An object of this class encapsulates a category @implementation declaration.
ObjCCategoryDecl * getCategoryDecl() const
static ObjCCategoryImplDecl * Create(ASTContext &C, DeclContext *DC, const IdentifierInfo *Id, ObjCInterfaceDecl *classInterface, SourceLocation nameLoc, SourceLocation atStartLoc, SourceLocation CategoryNameLoc)
static ObjCCategoryImplDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID)
ObjCCompatibleAliasDecl - Represents alias of a class.
static ObjCCompatibleAliasDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, IdentifierInfo *Id, ObjCInterfaceDecl *aliasedClass)
static ObjCCompatibleAliasDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID)
ObjCContainerDecl - Represents a container for method declarations.
ObjCMethodDecl * getMethod(Selector Sel, bool isInstance, bool AllowHidden=false) const
void setAtStartLoc(SourceLocation Loc)
instmeth_range instance_methods() const
llvm::SmallDenseSet< const ObjCProtocolDecl *, 8 > ProtocolPropertySet
ObjCPropertyDecl * getProperty(const IdentifierInfo *Id, bool IsInstance) const
ObjCIvarDecl * getIvarDecl(IdentifierInfo *Id) const
getIvarDecl - This method looks up an ivar in this ContextDecl.
llvm::MapVector< std::pair< IdentifierInfo *, unsigned >, ObjCPropertyDecl * > PropertyMap
ObjCPropertyDecl * FindPropertyDeclaration(const IdentifierInfo *PropertyId, ObjCPropertyQueryKind QueryKind) const
FindPropertyDeclaration - Finds declaration of the property given its name in 'PropertyId' and return...
llvm::SmallVector< ObjCPropertyDecl *, 8 > PropertyDeclOrder
prop_range properties() const
ObjCMethodDecl * getInstanceMethod(Selector Sel, bool AllowHidden=false) const
ObjCContainerDecl(Kind DK, DeclContext *DC, const IdentifierInfo *Id, SourceLocation nameLoc, SourceLocation atStartLoc)
bool HasUserDeclaredSetterMethod(const ObjCPropertyDecl *P) const
This routine returns 'true' if a user declared setter method was found in the class,...
void addPropertyImplementation(ObjCPropertyImplDecl *property)
propimpl_range property_impls() const
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...
const ObjCInterfaceDecl * getClassInterface() const
ObjCPropertyImplDecl * FindPropertyImplIvarDecl(IdentifierInfo *ivarId) const
FindPropertyImplIvarDecl - This method lookup the ivar in the list of properties implemented in this ...
ObjCImplementationDecl - Represents a class definition - this is where method definitions are specifi...
static ObjCImplementationDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID)
static ObjCImplementationDecl * Create(ASTContext &C, DeclContext *DC, ObjCInterfaceDecl *classInterface, ObjCInterfaceDecl *superDecl, SourceLocation nameLoc, SourceLocation atStartLoc, SourceLocation superLoc=SourceLocation(), SourceLocation IvarLBraceLoc=SourceLocation(), SourceLocation IvarRBraceLoc=SourceLocation())
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.
StringRef getName() const
getName - Get the name of identifier for the class interface associated with this implementation as a...
init_iterator init_begin()
init_begin() - Retrieve an iterator to the first initializer.
void setIvarInitializers(ASTContext &C, CXXCtorInitializer **initializers, unsigned numInitializers)
Represents an ObjC class declaration.
void mergeClassExtensionProtocolList(ObjCProtocolDecl *const *List, unsigned Num, ASTContext &C)
mergeClassExtensionProtocolList - Merge class extension's protocol list into the protocol list for th...
ObjCTypeParamList * getTypeParamList() const
Retrieve the type parameters of this class.
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...
ivar_iterator ivar_end() const
ObjCPropertyDecl * FindPropertyVisibleInPrimaryClass(const IdentifierInfo *PropertyId, ObjCPropertyQueryKind QueryKind) const
FindPropertyVisibleInPrimaryClass - Finds declaration of the property with name 'PropertyId' in the p...
ObjCMethodDecl * getCategoryMethod(Selector Sel, bool isInstance) const
static ObjCInterfaceDecl * Create(const ASTContext &C, DeclContext *DC, SourceLocation atLoc, const IdentifierInfo *Id, ObjCTypeParamList *typeParamList, ObjCInterfaceDecl *PrevDecl, SourceLocation ClassLoc=SourceLocation(), bool isInternal=false)
ObjCIvarDecl * lookupInstanceVariable(IdentifierInfo *IVarName, ObjCInterfaceDecl *&ClassDeclared)
void setCategoryListRaw(ObjCCategoryDecl *category)
Set the raw pointer to the start of the category/extension list.
redecl_range redecls() const
Returns an iterator range for all the redeclarations of the same decl.
bool hasDefinition() const
Determine whether this class has been defined.
all_protocol_range all_referenced_protocols() const
visible_extensions_range visible_extensions() const
ObjCTypeParamList * getTypeParamListAsWritten() const
Retrieve the type parameters written on this particular declaration of the class.
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...
ivar_iterator ivar_begin() const
protocol_range protocols() const
ObjCMethodDecl * lookupInstanceMethod(Selector Sel) const
Lookup an instance method for a given selector.
unsigned getODRHash()
Get precomputed ODRHash or add a new one.
void setImplementation(ObjCImplementationDecl *ImplD)
known_categories_range known_categories() const
const ObjCInterfaceDecl * isObjCRequiresPropertyDefs() const
isObjCRequiresPropertyDefs - Checks that a class or one of its super classes must not be auto-synthes...
SourceLocation getSuperClassLoc() const
Retrieve the starting location of the superclass.
all_protocol_iterator all_referenced_protocol_begin() const
void setExternallyCompleted()
Indicate that this Objective-C class is complete, but that the external AST source will be responsibl...
ObjCMethodDecl * getCategoryClassMethod(Selector Sel) const
ObjCCategoryDecl * getCategoryListRaw() const
Retrieve the raw pointer to the start of the category/extension list.
bool isThisDeclarationADefinition() const
Determine whether this particular declaration of this class is actually also a definition.
ObjCMethodDecl * lookupPrivateMethod(const Selector &Sel, bool Instance=true) const
Lookup a method in the classes implementation hierarchy.
void setTypeParamList(ObjCTypeParamList *TPL)
Set the type parameters of this class.
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,...
ObjCProtocolDecl * lookupNestedProtocol(IdentifierInfo *Name)
bool ClassImplementsProtocol(ObjCProtocolDecl *lProto, bool lookupCategory, bool RHSIsQualifiedID=false)
ClassImplementsProtocol - Checks that 'lProto' protocol has been implemented in IDecl class,...
StringRef getObjCRuntimeNameAsString() const
Produce a name to be used for class's metadata.
const ObjCObjectType * getSuperClassType() const
Retrieve the superclass type.
ObjCImplementationDecl * getImplementation() const
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...
void getDesignatedInitializers(llvm::SmallVectorImpl< const ObjCMethodDecl * > &Methods) const
Returns the designated initializers for the interface.
void startDefinition()
Starts the definition of this Objective-C class, taking it from a forward declaration (@class) to a d...
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.
bool isArcWeakrefUnavailable() const
isArcWeakrefUnavailable - Checks for a class or one of its super classes to be incompatible with __we...
visible_categories_range visible_categories() const
ObjCInterfaceDecl * getCanonicalDecl() override
Retrieves the canonical declaration of this Objective-C class.
ObjCInterfaceDecl * getSuperClass() const
ObjCInterfaceDecl * getDefinition()
Retrieve the definition of this class, or NULL if this class has been forward-declared (with @class) ...
TypeSourceInfo * getSuperClassTInfo() const
bool isDesignatedInitializer(Selector Sel, const ObjCMethodDecl **InitMethod=nullptr) const
Returns true if the given selector is a designated initializer for the interface.
void startDuplicateDefinitionForComparison()
Starts the definition without sharing it with other redeclarations.
void setHasDesignatedInitializers()
Indicate that this interface decl contains at least one initializer marked with the 'objc_designated_...
specific_decl_iterator< ObjCIvarDecl > ivar_iterator
void mergeDuplicateDefinitionWithCommon(const ObjCInterfaceDecl *Definition)
known_extensions_range known_extensions() const
ObjCIvarDecl - Represents an ObjC instance variable.
void setNextIvar(ObjCIvarDecl *ivar)
ObjCInterfaceDecl * getContainingInterface()
Return the class interface that this ivar is logically contained in; this is either the interface whe...
static ObjCIvarDecl * Create(ASTContext &C, ObjCContainerDecl *DC, SourceLocation StartLoc, SourceLocation IdLoc, const IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo, AccessControl ac, Expr *BW=nullptr, bool synthesized=false)
static ObjCIvarDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID)
QualType getUsageType(QualType objectType) const
Retrieve the type of this instance variable when viewed as a member of a specific object type.
void ** List
List is an array of pointers to objects that are not owned by this object.
void set(void *const *InList, unsigned Elts, ASTContext &Ctx)
ObjCList - This is a simple template class used to hold various lists of decls etc,...
ObjCMethodDecl - Represents an instance or class method declaration.
bool isDesignatedInitializerForTheInterface(const ObjCMethodDecl **InitMethod=nullptr) const
Returns true if the method selector resolves to a designated initializer in the class's interface.
ArrayRef< ParmVarDecl * > parameters() const
unsigned param_size() const
void setSelfDecl(ImplicitParamDecl *SD)
bool isPropertyAccessor() const
void getOverriddenMethods(SmallVectorImpl< const ObjCMethodDecl * > &Overridden) const
Return overridden methods for the given Method.
static ObjCMethodDecl * Create(ASTContext &C, SourceLocation beginLoc, SourceLocation endLoc, Selector SelInfo, QualType T, TypeSourceInfo *ReturnTInfo, DeclContext *contextDecl, bool isInstance=true, bool isVariadic=false, bool isPropertyAccessor=false, bool isSynthesizedAccessorStub=false, bool isImplicitlyDeclared=false, bool isDefined=false, ObjCImplementationControl impControl=ObjCImplementationControl::None, bool HasRelatedResultType=false)
void setHasRedeclaration(bool HRD) const
const ObjCPropertyDecl * findPropertyDecl(bool CheckOverrides=true) const
Returns the property associated with this method's selector.
QualType getSendResultType() const
Determine the type of an expression that sends a message to this function.
bool hasParamDestroyedInCallee() const
True if the method has a parameter that's destroyed in the callee.
void setIsRedeclaration(bool RD)
void setCmdDecl(ImplicitParamDecl *CD)
Stmt * getBody() const override
Retrieve the body of this method, if it has one.
ObjCMethodDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
SourceLocation getEndLoc() const LLVM_READONLY
TypeSourceInfo * getReturnTypeSourceInfo() const
QualType getSelfType(ASTContext &Context, const ObjCInterfaceDecl *OID, bool &selfIsPseudoStrong, bool &selfIsConsumed) const
bool hasRedeclaration() const
True if redeclared in the same interface.
void setMethodParams(ASTContext &C, ArrayRef< ParmVarDecl * > Params, ArrayRef< SourceLocation > SelLocs={})
Sets the method's parameters and selector source locations.
void setAsRedeclaration(const ObjCMethodDecl *PrevMethod)
param_type_iterator param_type_begin() const
bool isSynthesizedAccessorStub() const
SourceLocation getSelectorLoc(unsigned Index) const
SourceRange getReturnTypeSourceRange() const
bool isRedeclaration() const
True if this is a method redeclaration in the same interface.
bool isDirectMethod() const
True if the method is tagged as objc_direct.
Selector getSelector() const
bool isInstanceMethod() const
static ObjCMethodDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID)
bool isThisDeclarationADesignatedInitializer() const
Returns true if this specific method declaration is marked with the designated initializer attribute.
llvm::mapped_iterator< param_const_iterator, GetTypeFn > param_type_iterator
void getNameForDiagnostic(raw_ostream &OS, const PrintingPolicy &Policy, bool Qualified) const override
Appends a human-readable name for this declaration into the given stream.
ObjCCategoryDecl * getCategory()
If this method is declared or implemented in a category, return that category.
bool definedInNSObject(const ASTContext &) const
Is this method defined in the NSObject base class?
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
unsigned getNumSelectorLocs() const
bool isClassMethod() const
ObjCInterfaceDecl * getClassInterface()
void getSelectorLocs(SmallVectorImpl< SourceLocation > &SelLocs) const
Represents one property declaration in an Objective-C interface.
void getNameForDiagnostic(raw_ostream &OS, const PrintingPolicy &Policy, bool Qualified) const override
Appends a human-readable name for this declaration into the given stream.
QualType getUsageType(QualType objectType) const
Retrieve the type when this property is used with a specific base object type.
ObjCMethodDecl * getGetterMethodDecl() const
bool isInstanceProperty() const
static ObjCPropertyDecl * findPropertyDecl(const DeclContext *DC, const IdentifierInfo *propertyID, ObjCPropertyQueryKind queryKind)
Lookup a property by name in the specified DeclContext.
static ObjCPropertyDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID)
bool isDirectProperty() const
IdentifierInfo * getDefaultSynthIvarName(ASTContext &Ctx) const
Get the default name of the synthesized ivar.
static ObjCPropertyDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, const IdentifierInfo *Id, SourceLocation AtLocation, SourceLocation LParenLocation, QualType T, TypeSourceInfo *TSI, PropertyControl propControl=None)
ObjCPropertyImplDecl - Represents implementation declaration of a property in a class or category imp...
static ObjCPropertyImplDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID)
static ObjCPropertyImplDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation atLoc, SourceLocation L, ObjCPropertyDecl *property, Kind PK, ObjCIvarDecl *ivarDecl, SourceLocation ivarLoc)
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
Represents an Objective-C protocol declaration.
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.
ObjCMethodDecl * lookupMethod(Selector Sel, bool isInstance) const
static ObjCProtocolDecl * Create(ASTContext &C, DeclContext *DC, IdentifierInfo *Id, SourceLocation nameLoc, SourceLocation atStartLoc, ObjCProtocolDecl *PrevDecl)
ObjCProtocolDecl * getDefinition()
Retrieve the definition of this protocol, if any.
StringRef getObjCRuntimeNameAsString() const
Produce a name to be used for protocol's metadata.
redecl_range redecls() const
Returns an iterator range for all the redeclarations of the same decl.
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.
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.
void collectInheritedProtocolProperties(const ObjCPropertyDecl *Property, ProtocolPropertySet &PS, PropertyDeclOrder &PO) const
ObjCProtocolDecl * lookupProtocolNamed(IdentifierInfo *PName)
protocol_range protocols() const
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.
void set(ObjCProtocolDecl *const *InList, unsigned Elts, const SourceLocation *Locs, ASTContext &Ctx)
static ObjCTypeParamDecl * Create(ASTContext &ctx, DeclContext *dc, ObjCTypeParamVariance variance, SourceLocation varianceLoc, unsigned index, SourceLocation nameLoc, IdentifierInfo *name, SourceLocation colonLoc, TypeSourceInfo *boundInfo)
bool hasExplicitBound() const
Whether this type parameter has an explicitly-written type bound, e.g., "T : NSView".
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
static ObjCTypeParamDecl * CreateDeserialized(ASTContext &ctx, GlobalDeclID ID)
Stores a list of Objective-C type parameters for a parameterized class or a category/extension thereo...
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.
static ObjCTypeParamList * create(ASTContext &ctx, SourceLocation lAngleLoc, ArrayRef< ObjCTypeParamDecl * > typeParams, SourceLocation rAngleLoc)
Create a new Objective-C type parameter list.
Represents a parameter to a function.
A (possibly-)qualified type.
QualType getNonLValueExprType(const ASTContext &Context) const
Determine the type of a (typically non-lvalue) expression with the specified result type.
QualType withConst() const
const Type * getTypePtr() const
Retrieves a pointer to the underlying (unqualified) type.
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 substObjCTypeArgs(ASTContext &ctx, ArrayRef< QualType > typeArgs, ObjCSubstitutionContext context) const
Substitute type arguments for the Objective-C type parameters used in the subject type.
The collection of all-type qualifiers we support.
@ OCL_Strong
Assigning into this object requires the old value to be released and the new value to be retained.
void setObjCLifetime(ObjCLifetime type)
void setPreviousDecl(ObjCInterfaceDecl *PrevDecl)
Smart pointer class that efficiently represents Objective-C method names.
ObjCMethodFamily getMethodFamily() const
Derive the conventional family of this method.
unsigned getNumArgs() const
Encodes a location in the source.
A trivial tuple used to represent a source range.
Stmt - This represents one statement.
A container of type source information.
bool isObjCSelType() const
bool isObjCIdType() const
TypeSourceInfo * getTypeSourceInfo() const
const internal::VariadicAllOfMatcher< Decl > decl
Matches declarations.
Top level wrappers for InstallAPI frontend operations.
bool isa(CodeGen::Address addr)
@ SelLoc_NonStandard
Non-standard.
@ SelLoc_StandardNoSpace
For nullary selectors, immediately before the end: "[foo release]" / "-(void)release;" Or immediately...
@ InvalidObjCMethodFamily
@ Override
Merge availability attributes for an override, which requires an exact match or a weakening of constr...
@ Self
'self' clause, allowed on Compute and Combined Constructs, plus 'update'.
bool operator<(DeclarationName LHS, DeclarationName RHS)
Ordering on two declaration names.
ObjCMethodFamily
A family of Objective-C methods.
@ OMF_None
No particular method family.
SelectorLocationsKind hasStandardSelectorLocs(Selector Sel, ArrayRef< SourceLocation > SelLocs, ArrayRef< Expr * > Args, SourceLocation EndLoc)
Returns true if all SelLocs are in a "standard" location.
@ Property
The type of a property.
@ Result
The result type of a method or function.
const FunctionProtoType * T
ObjCImplementationControl
const StreamingDiagnostic & operator<<(const StreamingDiagnostic &DB, const ConceptReference *C)
Insertion operator for diagnostics.
ObjCTypeParamVariance
Describes the variance of a given generic parameter.
@ Invariant
The parameter is invariant: must match exactly.
U cast(CodeGen::Address addr)
@ Interface
The "__interface" keyword introduces the elaborated-type-specifier.
@ Class
The "class" keyword introduces the elaborated-type-specifier.
@ ObjCSelf
Parameter for Objective-C 'self' argument.
@ ObjCCmd
Parameter for Objective-C '_cmd' argument.
Describes how types, statements, expressions, and declarations should be printed.