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->known_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);
545 if (data().ExternallyCompleted)
546 LoadExternalDefinition();
553 if (MD->isThisDeclarationADesignatedInitializer()) {
561 if (MD->isThisDeclarationADesignatedInitializer()) {
571 void ObjCInterfaceDecl::allocateDefinitionData() {
572 assert(!
hasDefinition() &&
"ObjC class already has a definition");
573 Data.setPointer(
new (getASTContext()) DefinitionData());
574 Data.getPointer()->Definition =
this;
578 cast<ObjCInterfaceType>(TypeForDecl)->
Decl =
this;
582 allocateDefinitionData();
597 if (data().ExternallyCompleted)
598 LoadExternalDefinition();
601 while (ClassDecl !=
nullptr) {
603 clsDeclared = ClassDecl;
609 clsDeclared = ClassDecl;
628 if (data().ExternallyCompleted)
629 LoadExternalDefinition();
632 while (ClassDecl !=
nullptr) {
643 if (
P->lookupProtocolNamed(Name))
655 bool shallowCategoryLookup,
666 if (data().ExternallyCompleted)
667 LoadExternalDefinition();
671 if ((MethodDecl = ClassDecl->
getMethod(Sel, isInstance)))
676 if ((MethodDecl = Cat->getMethod(Sel, isInstance)))
677 if (C != Cat || !MethodDecl->isImplicit())
682 if ((MethodDecl =
I->lookupMethod(Sel, isInstance)))
686 if (!shallowCategoryLookup)
690 Cat->getReferencedProtocols();
692 E = Protocols.
end();
I !=
E; ++
I)
693 if ((MethodDecl = (*I)->lookupMethod(Sel, isInstance)))
694 if (C != Cat || !MethodDecl->isImplicit())
713 bool Instance)
const {
718 if (data().ExternallyCompleted)
719 LoadExternalDefinition();
723 Method = Instance ? ImpDecl->getInstanceMethod(Sel)
724 : ImpDecl->getClassMethod(Sel);
753 DeclContext *contextDecl,
bool isInstance,
bool isVariadic,
754 bool isPropertyAccessor,
bool isImplicitlyDeclared,
bool isDefined,
757 beginLoc, endLoc, SelInfo, T, ReturnTInfo, contextDecl, isInstance,
758 isVariadic, isPropertyAccessor, isImplicitlyDeclared, isDefined,
759 impControl, HasRelatedResultType);
769 hasAttr<ObjCDesignatedInitializerAttr>();
777 if (isa<ObjCProtocolDecl>(DC))
780 return ID->isDesignatedInitializer(
getSelector(), InitMethod);
785 return Body.
get(getASTContext().getExternalSource());
790 getASTContext().setObjCMethodRedeclaration(PrevMethod,
this);
791 IsRedeclaration =
true;
792 PrevMethod->HasRedeclaration =
true;
795 void ObjCMethodDecl::setParamsAndSelLocs(
ASTContext &C,
798 ParamsAndSelLocs =
nullptr;
799 NumParams = Params.size();
800 if (Params.empty() && SelLocs.empty())
803 static_assert(llvm::AlignOf<ParmVarDecl *>::Alignment >=
804 llvm::AlignOf<SourceLocation>::Alignment,
805 "Alignment not sufficient for SourceLocation");
807 unsigned Size =
sizeof(
ParmVarDecl *) * NumParams +
809 ParamsAndSelLocs = C.
Allocate(Size);
810 std::copy(Params.begin(), Params.end(), getParams());
811 std::copy(SelLocs.begin(), SelLocs.end(), getStoredSelLocs());
823 assert((!SelLocs.empty() || isImplicit()) &&
824 "No selector locs for non-implicit method");
826 return setParamsAndSelLocs(C, Params,
llvm::None);
831 return setParamsAndSelLocs(C, Params,
llvm::None);
833 setParamsAndSelLocs(C, Params, SelLocs);
842 if (HasRedeclaration)
847 Decl *CtxD = cast<Decl>(getDeclContext());
849 if (!CtxD->isInvalidDecl()) {
852 if (!ImplD->isInvalidDecl())
857 if (!ImplD->isInvalidDecl())
861 dyn_cast<ObjCImplementationDecl>(CtxD)) {
863 if (!IFD->isInvalidDecl())
867 dyn_cast<ObjCCategoryImplDecl>(CtxD)) {
869 if (!CatD->isInvalidDecl())
876 return cast<ObjCContainerDecl>(CtxD)->getMethod(
getSelector(),
880 return Redecl ? Redecl :
this;
884 Decl *CtxD = cast<Decl>(getDeclContext());
893 dyn_cast<ObjCCategoryImplDecl>(CtxD)) {
901 return cast<ObjCContainerDecl>(CtxD)->getMethod(
getSelector(),
909 return Body->getLocEnd();
919 if (
const ObjCMethodFamilyAttr *attr = getAttr<ObjCMethodFamilyAttr>()) {
922 switch (attr->getFamily()) {
930 Family =
static_cast<unsigned>(family);
977 if (noParams < 1 || noParams > 3)
1001 Family =
static_cast<unsigned>(family);
1007 bool &selfIsPseudoStrong,
1008 bool &selfIsConsumed) {
1010 selfIsPseudoStrong =
false;
1011 selfIsConsumed =
false;
1026 selfIsConsumed = hasAttr<NSConsumesSelfAttr>();
1037 selfIsPseudoStrong =
true;
1044 selfIsPseudoStrong =
true;
1052 bool selfIsPseudoStrong, selfIsConsumed;
1054 getSelfType(Context, OID, selfIsPseudoStrong, selfIsConsumed);
1061 self->addAttr(NSConsumedAttr::CreateImplicit(Context));
1063 if (selfIsPseudoStrong)
1064 self->setARCPseudoStrong(
true);
1075 return CD->getClassInterface();
1076 if (
ObjCImplDecl *IMD = dyn_cast<ObjCImplDecl>(getDeclContext()))
1077 return IMD->getClassInterface();
1078 if (isa<ObjCProtocolDecl>(getDeclContext()))
1080 llvm_unreachable(
"unknown method context");
1086 return TSI->getTypeLoc().getSourceRange();
1107 bool MovedToSuper) {
1115 Category = dyn_cast<ObjCCategoryDecl>(Container)) {
1123 if (Method != Overridden) {
1126 Methods.push_back(Overridden);
1130 for (
const auto *
P :
Category->protocols())
1140 if (Method != Overridden) {
1143 Methods.push_back(Overridden);
1147 if (
const ObjCProtocolDecl *Protocol = dyn_cast<ObjCProtocolDecl>(Container)){
1148 for (
const auto *
P : Protocol->protocols())
1153 Interface = dyn_cast<ObjCInterfaceDecl>(Container)) {
1154 for (
const auto *
P : Interface->protocols())
1157 for (
const auto *Cat : Interface->known_categories())
1178 ProtD = dyn_cast<ObjCProtocolDecl>(Method->getDeclContext())) {
1182 IMD = dyn_cast<ObjCImplDecl>(Method->getDeclContext())) {
1195 CatD = dyn_cast<ObjCCategoryDecl>(Method->getDeclContext())) {
1209 dyn_cast_or_null<ObjCContainerDecl>(Method->getDeclContext()),
1210 Method, overridden);
1219 Method = cast<ObjCContainerDecl>(Method->getDeclContext())->
1225 assert(!Overridden.empty() &&
1226 "ObjCMethodDecl's overriding bit is not as expected");
1239 bool IsGetter = (NumArgs == 0);
1244 auto findMatchingProperty =
1248 Selector NextSel = IsGetter ?
I->getGetterName()
1249 :
I->getSetterName();
1255 Selector NextSel = IsGetter ?
I->getGetterName()
1256 :
I->getSetterName();
1266 if (
const auto *Found = findMatchingProperty(Container))
1271 if (
const auto *
Category = dyn_cast<ObjCCategoryDecl>(Container)) {
1272 ClassDecl =
Category->getClassInterface();
1273 if (
const auto *Found = findMatchingProperty(ClassDecl))
1283 if (Ext == Container)
1286 if (
const auto *Found = findMatchingProperty(Ext))
1291 llvm_unreachable(
"Marked as a property accessor but no property found!");
1294 if (!CheckOverrides)
1298 OverridesTy Overrides;
1300 for (OverridesTy::const_iterator
I = Overrides.begin(),
E = Overrides.end();
1313 void ObjCTypeParamDecl::anchor() { }
1324 nameLoc, name, colonLoc, boundInfo);
1338 startLoc = getLocation();
1354 : NumParams(typeParams.size())
1358 std::copy(typeParams.begin(), typeParams.end(),
begin());
1368 ctx.
Allocate(totalSizeToAlloc<ObjCTypeParamDecl *>(typeParams.size()),
1369 llvm::alignOf<ObjCTypeParamList>());
1375 typeArgs.reserve(
size());
1376 for (
auto typeParam : *
this)
1377 typeArgs.push_back(typeParam->getUnderlyingType());
1419 redeclarable_base(C), TypeForDecl(nullptr), TypeParamList(nullptr),
1425 Data = PrevDecl->Data;
1427 setImplicit(IsInternal);
1432 void ObjCInterfaceDecl::LoadExternalDefinition()
const {
1433 assert(data().ExternallyCompleted &&
"Class is not externally completed");
1434 data().ExternallyCompleted =
false;
1435 getASTContext().getExternalSource()->CompleteType(
1436 const_cast<ObjCInterfaceDecl *>(
this));
1440 assert(getASTContext().getExternalSource() &&
1441 "Class can't be externally completed without an external source");
1443 "Forward declarations can't be externally completed");
1444 data().ExternallyCompleted =
true;
1451 data().HasDesignatedInitializers =
true;
1458 if (data().ExternallyCompleted)
1459 LoadExternalDefinition();
1461 return data().HasDesignatedInitializers;
1466 if (ObjCRuntimeNameAttr *ObjCRTName = getAttr<ObjCRuntimeNameAttr>())
1467 return ObjCRTName->getMetadataName();
1476 return ID->getObjCRuntimeNameAsString();
1483 if (data().ExternallyCompleted)
1484 LoadExternalDefinition();
1486 return getASTContext().getObjCImplementation(
1487 const_cast<ObjCInterfaceDecl*>(Def));
1495 getASTContext().setObjCImplementation(
getDefinition(), ImplD);
1499 struct SynthesizeIvarChunk {
1503 : Size(size), Ivar(ivar) {}
1506 bool operator<(
const SynthesizeIvarChunk & LHS,
1507 const SynthesizeIvarChunk &RHS) {
1508 return LHS.Size < RHS.Size;
1527 if (!data().IvarList) {
1530 data().IvarList = *
I; ++
I;
1531 for (curIvar = data().IvarList; I !=
E; curIvar = *
I, ++
I)
1536 if (!Ext->ivar_empty()) {
1538 I = Ext->ivar_begin(),
1539 E = Ext->ivar_end();
1540 if (!data().IvarList) {
1541 data().IvarList = *
I; ++
I;
1542 curIvar = data().IvarList;
1544 for ( ;I !=
E; curIvar = *
I, ++
I)
1548 data().IvarListMissingImplementation =
true;
1552 if (!data().IvarListMissingImplementation)
1553 return data().IvarList;
1556 data().IvarListMissingImplementation =
false;
1557 if (!ImplDecl->ivar_empty()) {
1559 for (
auto *IV : ImplDecl->ivars()) {
1560 if (IV->getSynthesize() && !IV->isInvalidDecl()) {
1561 layout.push_back(SynthesizeIvarChunk(
1562 IV->getASTContext().getTypeSize(IV->getType()), IV));
1565 if (!data().IvarList)
1566 data().IvarList = IV;
1572 if (!layout.empty()) {
1574 std::stable_sort(layout.begin(), layout.end());
1575 unsigned Ix = 0, EIx = layout.size();
1576 if (!data().IvarList) {
1577 data().IvarList = layout[0].Ivar; Ix++;
1578 curIvar = data().IvarList;
1580 for ( ; Ix != EIx; curIvar = layout[Ix].Ivar, Ix++)
1585 return data().IvarList;
1598 if (data().ExternallyCompleted)
1599 LoadExternalDefinition();
1602 if (Cat->getIdentifier() == CategoryId)
1633 bool lookupCategory,
1634 bool RHSIsQualifiedID) {
1641 if (getASTContext().ProtocolCompatibleWithProtocol(lProto, PI))
1649 if (RHSIsQualifiedID &&
1650 getASTContext().ProtocolCompatibleWithProtocol(PI, lProto))
1657 for (
auto *PI : Cat->protocols())
1658 if (getASTContext().ProtocolCompatibleWithProtocol(lProto, PI))
1675 void ObjCIvarDecl::anchor() { }
1694 assert((isa<ObjCInterfaceDecl>(DC) || isa<ObjCImplementationDecl>(DC) ||
1695 isa<ObjCCategoryDecl>(DC)) &&
1696 "Invalid ivar decl context!");
1702 ID = IM->getClassInterface();
1704 ID = cast<ObjCCategoryDecl>(DC)->getClassInterface();
1709 return new (C, DC)
ObjCIvarDecl(DC, StartLoc, IdLoc, Id, T, TInfo, ac, BW,
1722 switch (DC->getKind()) {
1724 case ObjCCategoryImpl:
1726 llvm_unreachable(
"invalid ivar container!");
1729 case ObjCCategory: {
1735 case ObjCImplementation:
1736 return cast<ObjCImplementationDecl>(DC)->getClassInterface();
1739 return cast<ObjCInterfaceDecl>(DC);
1752 void ObjCAtDefsFieldDecl::anchor() { }
1772 void ObjCProtocolDecl::anchor() { }
1779 redeclarable_base(C), Data() {
1780 setPreviousDecl(PrevDecl);
1782 Data = PrevDecl->Data;
1812 if ((PDecl =
I->lookupProtocolNamed(Name)))
1821 bool isInstance)
const {
1830 if ((MethodDecl =
getMethod(Sel, isInstance)))
1834 if ((MethodDecl =
I->lookupMethod(Sel, isInstance)))
1839 void ObjCProtocolDecl::allocateDefinitionData() {
1840 assert(!Data.getPointer() &&
"Protocol already has a definition!");
1841 Data.setPointer(
new (getASTContext()) DefinitionData);
1842 Data.getPointer()->Definition =
this;
1846 allocateDefinitionData();
1850 RD->Data = this->Data;
1857 for (
auto *Prop : PDecl->properties()) {
1859 PM.insert(std::make_pair(
1860 std::make_pair(Prop->getIdentifier(), Prop->isClassProperty()),
1865 for (
const auto *PI : PDecl->protocols())
1866 PI->collectPropertiesToImplement(PM, PO);
1875 bool MatchFound =
false;
1876 for (
auto *Prop : PDecl->properties()) {
1877 if (Prop == Property)
1887 for (
const auto *PI : PDecl->protocols())
1888 PI->collectInheritedProtocolProperties(Property, PM);
1894 if (ObjCRuntimeNameAttr *ObjCRTName = getAttr<ObjCRuntimeNameAttr>())
1895 return ObjCRTName->getMetadataName();
1904 void ObjCCategoryDecl::anchor() { }
1914 ClassInterface(IDecl), TypeParamList(nullptr),
1915 NextClassCategory(nullptr), CategoryNameLoc(CategoryNameLoc),
1916 IvarLBraceLoc(IvarLBraceLoc), IvarRBraceLoc(IvarRBraceLoc)
1918 setTypeParamList(typeParamList);
1932 IDecl, typeParamList, IvarLBraceLoc,
1940 L->AddedObjCCategoryToInterface(CatDecl, IDecl);
1951 nullptr,
nullptr,
nullptr);
1955 return getASTContext().getObjCImplementation(
1956 const_cast<ObjCCategoryDecl*>(
this));
1960 getASTContext().setObjCImplementation(
this, ImplD);
1964 TypeParamList = TPL;
1968 for (
auto typeParam : *TypeParamList)
1969 typeParam->setDeclContext(
this);
1977 void ObjCCategoryImplDecl::anchor() { }
1989 atStartLoc, CategoryNameLoc);
2007 void ObjCImplDecl::anchor() { }
2011 property->setLexicalDeclContext(
this);
2019 = dyn_cast_or_null<ObjCImplementationDecl>(
this)) {
2024 dyn_cast_or_null<ObjCCategoryImplDecl>(
this)) {
2029 ClassInterface = IFace;
2039 if (PID->getPropertyIvarDecl() &&
2040 PID->getPropertyIvarDecl()->getIdentifier() == ivarId)
2056 if (PID->getPropertyDecl()->getIdentifier() == Id) {
2058 !PID->getPropertyDecl()->isClassProperty()) ||
2060 PID->getPropertyDecl()->isClassProperty()) ||
2062 !PID->getPropertyDecl()->isClassProperty()))
2065 if (PID->getPropertyDecl()->isClassProperty())
2066 ClassPropImpl = PID;
2071 return ClassPropImpl;
2086 void ObjCImplementationDecl::anchor() { }
2100 nameLoc, atStartLoc, superLoc,
2101 IvarLBraceLoc, IvarRBraceLoc);
2112 unsigned numInitializers) {
2113 if (numInitializers > 0) {
2114 NumIvarInitializers = numInitializers;
2117 memcpy(ivarInitializers, initializers,
2119 IvarInitializers = ivarInitializers;
2125 return IvarInitializers.
get(getASTContext().getExternalSource());
2138 void ObjCCompatibleAliasDecl::anchor() { }
2158 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...
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.
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.
SourceRange getSourceRange() const override LLVM_READONLY
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)
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...
llvm::DenseMap< const ObjCProtocolDecl *, ObjCPropertyDecl * > ProtocolPropertyMap
QualType getObjCClassType() const
Represents the Objective-C Class type.
TypeSourceInfo * getSuperClassTInfo() const
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.
IdentifierInfo * getIdentifier() const
getIdentifier - Get the identifier that names the category interface associated with this implementat...
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...
class LLVM_ALIGNAS(8) DependentTemplateSpecializationType const IdentifierInfo * Name
Represents a template specialization type whose template cannot be resolved, e.g. ...
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.
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
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
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.
ObjCPropertyImplDecl - Represents implementation declaration of a property in a class or category imp...
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.
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)
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.
class LLVM_ALIGNAS(8) TemplateSpecializationType unsigned NumArgs
Represents a type template specialization; the template must be a class template, a type alias templa...
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.
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.
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.
void collectInheritedProtocolProperties(const ObjCPropertyDecl *Property, ProtocolPropertyMap &PM) const
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
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
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...
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).
static ImplicitParamDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation IdLoc, IdentifierInfo *Id, QualType T)
ObjCTypeParamList * getTypeParamList() const
Retrieve the type parameters of this class.
Represents a C++ base or member initializer.
instprop_range instance_properties() const
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)
StringRef getName() const
getName - Get the name of identifier for the class interface associated with this implementation as a...
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
llvm::mapped_iterator< param_const_iterator, deref_fun > param_type_iterator
Stores a list of Objective-C type parameters for a parameterized class or a category/extension thereo...
ObjCInterfaceDecl * getSuperClass() const
QualType getSendResultType() const
Determine the type of an expression that sends a message to this function.
static Decl::Kind getKind(const Decl *D)
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.
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)
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.
bool isHidden() const
Determine whether this declaration is hidden from name lookup.
param_type_iterator param_type_begin() const