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))
177 llvm::raw_svector_ostream os(ivarName);
201 case Decl::ObjCProtocol: {
208 case Decl::ObjCInterface: {
212 if (!Cat->IsClassExtension())
224 return superClass->FindPropertyDeclaration(PropertyId);
227 case Decl::ObjCCategory: {
240 void ObjCInterfaceDecl::anchor() { }
249 return def->getTypeParamListAsWritten();
267 for (
auto typeParam : *TypeParamList)
268 typeParam->setDeclContext(
this);
276 if (data().ExternallyCompleted)
277 LoadExternalDefinition();
293 return superTInfo->getTypeLoc().getLocStart();
309 if (data().ExternallyCompleted)
310 LoadExternalDefinition();
327 PM[Prop->getIdentifier()] = Prop;
331 PI->collectPropertiesToImplement(PM, PO);
340 if (Class->
hasAttr<ArcWeakrefUnavailableAttr>())
350 if (Class->
hasAttr<ObjCRequiresPropertyDefsAttr>())
361 if (data().ExternallyCompleted)
362 LoadExternalDefinition();
364 if (data().AllReferencedProtocols.empty() &&
365 data().ReferencedProtocols.empty()) {
366 data().AllReferencedProtocols.set(ExtList, ExtNum, C);
374 for (
unsigned i = 0; i < ExtNum; i++) {
375 bool protocolExists =
false;
379 protocolExists =
true;
386 ProtocolRefs.push_back(ProtoInExtension);
389 if (ProtocolRefs.empty())
396 data().AllReferencedProtocols.set(ProtocolRefs.data(), ProtocolRefs.size(),
C);
400 ObjCInterfaceDecl::findInterfaceWithDesignatedInitializers()
const {
405 if (!IFace->inheritsDesignatedInitializers())
414 if (MD->getMethodFamily() ==
OMF_init && !MD->isOverriding())
418 for (
const auto *MD : Ext->instance_methods()) {
419 if (MD->getMethodFamily() ==
OMF_init && !MD->isOverriding())
424 for (
const auto *MD : ImplD->instance_methods()) {
425 if (MD->getMethodFamily() ==
OMF_init && !MD->isOverriding())
432 bool ObjCInterfaceDecl::inheritsDesignatedInitializers()
const {
433 switch (data().InheritedDesignatedInitializers) {
434 case DefinitionData::IDI_Inherited:
436 case DefinitionData::IDI_NotInherited:
438 case DefinitionData::IDI_Unknown: {
443 data().InheritedDesignatedInitializers = DefinitionData::IDI_NotInherited;
446 data().InheritedDesignatedInitializers =
447 SuperD->declaresOrInheritsDesignatedInitializers() ?
448 DefinitionData::IDI_Inherited :
449 DefinitionData::IDI_NotInherited;
451 data().InheritedDesignatedInitializers =
452 DefinitionData::IDI_NotInherited;
455 assert(data().InheritedDesignatedInitializers
456 != DefinitionData::IDI_Unknown);
457 return data().InheritedDesignatedInitializers ==
458 DefinitionData::IDI_Inherited;
462 llvm_unreachable(
"unexpected InheritedDesignatedInitializers value");
470 if (data().ExternallyCompleted)
471 LoadExternalDefinition();
478 if (MD->isThisDeclarationADesignatedInitializer())
479 Methods.push_back(MD);
481 for (
const auto *MD : Ext->instance_methods())
482 if (MD->isThisDeclarationADesignatedInitializer())
483 Methods.push_back(MD);
492 if (data().ExternallyCompleted)
493 LoadExternalDefinition();
500 if (MD->isThisDeclarationADesignatedInitializer()) {
508 if (MD->isThisDeclarationADesignatedInitializer()) {
518 void ObjCInterfaceDecl::allocateDefinitionData() {
519 assert(!
hasDefinition() &&
"ObjC class already has a definition");
521 Data.getPointer()->Definition =
this;
525 cast<ObjCInterfaceType>(TypeForDecl)->
Decl =
this;
529 allocateDefinitionData();
544 if (data().ExternallyCompleted)
545 LoadExternalDefinition();
548 while (ClassDecl !=
nullptr) {
550 clsDeclared = ClassDecl;
556 clsDeclared = ClassDecl;
575 if (data().ExternallyCompleted)
576 LoadExternalDefinition();
579 while (ClassDecl !=
nullptr) {
590 if (
P->lookupProtocolNamed(Name))
602 bool shallowCategoryLookup,
613 if (data().ExternallyCompleted)
614 LoadExternalDefinition();
618 if ((MethodDecl = ClassDecl->
getMethod(Sel, isInstance)))
623 if ((MethodDecl = Cat->getMethod(Sel, isInstance)))
628 for (
const auto *I : ClassDecl->
protocols())
629 if ((MethodDecl = I->lookupMethod(Sel, isInstance)))
633 if (!shallowCategoryLookup)
637 Cat->getReferencedProtocols();
639 E = Protocols.
end(); I != E; ++I)
640 if ((MethodDecl = (*I)->lookupMethod(Sel, isInstance)))
660 bool Instance)
const {
665 if (data().ExternallyCompleted)
666 LoadExternalDefinition();
670 Method = Instance ? ImpDecl->getInstanceMethod(Sel)
671 : ImpDecl->getClassMethod(Sel);
700 DeclContext *contextDecl,
bool isInstance,
bool isVariadic,
701 bool isPropertyAccessor,
bool isImplicitlyDeclared,
bool isDefined,
704 beginLoc, endLoc, SelInfo, T, ReturnTInfo, contextDecl, isInstance,
705 isVariadic, isPropertyAccessor, isImplicitlyDeclared, isDefined,
706 impControl, HasRelatedResultType);
716 hasAttr<ObjCDesignatedInitializerAttr>();
724 if (isa<ObjCProtocolDecl>(DC))
727 return ID->isDesignatedInitializer(
getSelector(), InitMethod);
738 IsRedeclaration =
true;
739 PrevMethod->HasRedeclaration =
true;
742 void ObjCMethodDecl::setParamsAndSelLocs(
ASTContext &
C,
745 ParamsAndSelLocs =
nullptr;
746 NumParams = Params.size();
747 if (Params.empty() && SelLocs.empty())
750 unsigned Size =
sizeof(
ParmVarDecl *) * NumParams +
752 ParamsAndSelLocs = C.
Allocate(Size);
753 std::copy(Params.begin(), Params.end(), getParams());
754 std::copy(SelLocs.begin(), SelLocs.end(), getStoredSelLocs());
767 "No selector locs for non-implicit method");
769 return setParamsAndSelLocs(C, Params,
llvm::None);
774 return setParamsAndSelLocs(C, Params,
llvm::None);
776 setParamsAndSelLocs(C, Params, SelLocs);
785 if (HasRedeclaration)
795 if (!ImplD->isInvalidDecl())
800 if (!ImplD->isInvalidDecl())
804 dyn_cast<ObjCImplementationDecl>(CtxD)) {
806 if (!IFD->isInvalidDecl())
810 dyn_cast<ObjCCategoryImplDecl>(CtxD)) {
812 if (!CatD->isInvalidDecl())
819 return cast<ObjCContainerDecl>(CtxD)->getMethod(
getSelector(),
823 return Redecl ? Redecl :
this;
836 dyn_cast<ObjCCategoryImplDecl>(CtxD)) {
844 return cast<ObjCContainerDecl>(CtxD)->getMethod(
getSelector(),
852 return Body->getLocEnd();
862 if (
const ObjCMethodFamilyAttr *attr = getAttr<ObjCMethodFamilyAttr>()) {
865 switch (attr->getFamily()) {
873 Family =
static_cast<unsigned>(family);
920 if (noParams < 1 || noParams > 3)
944 Family =
static_cast<unsigned>(family);
950 bool &selfIsPseudoStrong,
951 bool &selfIsConsumed) {
953 selfIsPseudoStrong =
false;
954 selfIsConsumed =
false;
969 selfIsConsumed = hasAttr<NSConsumesSelfAttr>();
980 selfIsPseudoStrong =
true;
987 selfIsPseudoStrong =
true;
995 bool selfIsPseudoStrong, selfIsConsumed;
997 getSelfType(Context, OID, selfIsPseudoStrong, selfIsConsumed);
1004 self->addAttr(NSConsumedAttr::CreateImplicit(Context));
1006 if (selfIsPseudoStrong)
1007 self->setARCPseudoStrong(
true);
1018 return CD->getClassInterface();
1020 return IMD->getClassInterface();
1023 llvm_unreachable(
"unknown method context");
1029 return TSI->getTypeLoc().getSourceRange();
1050 bool MovedToSuper) {
1058 Category = dyn_cast<ObjCCategoryDecl>(Container)) {
1066 if (Method != Overridden) {
1069 Methods.push_back(Overridden);
1073 for (
const auto *
P : Category->protocols())
1083 if (Method != Overridden) {
1086 Methods.push_back(Overridden);
1090 if (
const ObjCProtocolDecl *Protocol = dyn_cast<ObjCProtocolDecl>(Container)){
1091 for (
const auto *
P : Protocol->protocols())
1096 Interface = dyn_cast<ObjCInterfaceDecl>(Container)) {
1097 for (
const auto *
P : Interface->protocols())
1100 for (
const auto *Cat : Interface->known_categories())
1153 Method, overridden);
1168 assert(!Overridden.empty() &&
1169 "ObjCMethodDecl's overriding bit is not as expected");
1186 if (
const ObjCCategoryDecl *CatDecl = dyn_cast<ObjCCategoryDecl>(Container))
1187 if (CatDecl->IsClassExtension())
1188 Container = CatDecl->getClassInterface();
1190 bool IsGetter = (NumArgs == 0);
1192 for (
const auto *I : Container->
properties()) {
1193 Selector NextSel = IsGetter ? I->getGetterName()
1194 : I->getSetterName();
1199 llvm_unreachable(
"Marked as a property accessor but no property found!");
1202 if (!CheckOverrides)
1206 OverridesTy Overrides;
1208 for (OverridesTy::const_iterator I = Overrides.begin(), E = Overrides.end();
1221 void ObjCTypeParamDecl::anchor() { }
1232 nameLoc, name, colonLoc, boundInfo);
1262 : NumParams(typeParams.size())
1266 std::copy(typeParams.begin(), typeParams.end(), begin());
1277 static_assert(llvm::AlignOf<ObjCTypeParamList>::Alignment >=
1278 llvm::AlignOf<ObjCTypeParamDecl *>::Alignment,
1279 "type parameter list needs greater alignment");
1280 unsigned align = llvm::alignOf<ObjCTypeParamList>();
1281 void *mem = ctx.
Allocate(size, align);
1287 typeArgs.reserve(
size());
1288 for (
auto typeParam : *
this)
1289 typeArgs.push_back(typeParam->getUnderlyingType());
1331 redeclarable_base(C), TypeForDecl(nullptr), TypeParamList(nullptr),
1337 Data = PrevDecl->Data;
1344 void ObjCInterfaceDecl::LoadExternalDefinition()
const {
1345 assert(data().ExternallyCompleted &&
"Class is not externally completed");
1346 data().ExternallyCompleted =
false;
1348 const_cast<ObjCInterfaceDecl *>(
this));
1353 "Class can't be externally completed without an external source");
1355 "Forward declarations can't be externally completed");
1356 data().ExternallyCompleted =
true;
1363 data().HasDesignatedInitializers =
true;
1370 if (data().ExternallyCompleted)
1371 LoadExternalDefinition();
1373 return data().HasDesignatedInitializers;
1378 if (ObjCRuntimeNameAttr *ObjCRTName = getAttr<ObjCRuntimeNameAttr>())
1379 return ObjCRTName->getMetadataName();
1388 return ID->getObjCRuntimeNameAsString();
1395 if (data().ExternallyCompleted)
1396 LoadExternalDefinition();
1399 const_cast<ObjCInterfaceDecl*>(Def));
1411 struct SynthesizeIvarChunk {
1415 : Size(size), Ivar(ivar) {}
1418 bool operator<(
const SynthesizeIvarChunk & LHS,
1419 const SynthesizeIvarChunk &RHS) {
1420 return LHS.Size < RHS.Size;
1439 if (!data().IvarList) {
1442 data().IvarList = *I; ++I;
1443 for (curIvar = data().IvarList; I != E; curIvar = *I, ++I)
1448 if (!Ext->ivar_empty()) {
1450 I = Ext->ivar_begin(),
1451 E = Ext->ivar_end();
1452 if (!data().IvarList) {
1453 data().IvarList = *I; ++I;
1454 curIvar = data().IvarList;
1456 for ( ;I != E; curIvar = *I, ++I)
1460 data().IvarListMissingImplementation =
true;
1464 if (!data().IvarListMissingImplementation)
1465 return data().IvarList;
1468 data().IvarListMissingImplementation =
false;
1469 if (!ImplDecl->ivar_empty()) {
1471 for (
auto *IV : ImplDecl->ivars()) {
1472 if (IV->getSynthesize() && !IV->isInvalidDecl()) {
1473 layout.push_back(SynthesizeIvarChunk(
1474 IV->getASTContext().getTypeSize(IV->getType()), IV));
1477 if (!data().IvarList)
1478 data().IvarList = IV;
1484 if (!layout.empty()) {
1486 std::stable_sort(layout.begin(), layout.end());
1487 unsigned Ix = 0, EIx = layout.size();
1488 if (!data().IvarList) {
1489 data().IvarList = layout[0].Ivar; Ix++;
1490 curIvar = data().IvarList;
1492 for ( ; Ix != EIx; curIvar = layout[Ix].Ivar, Ix++)
1497 return data().IvarList;
1510 if (data().ExternallyCompleted)
1511 LoadExternalDefinition();
1514 if (Cat->getIdentifier() == CategoryId)
1545 bool lookupCategory,
1546 bool RHSIsQualifiedID) {
1561 if (RHSIsQualifiedID &&
1569 for (
auto *PI : Cat->protocols())
1587 void ObjCIvarDecl::anchor() { }
1606 assert((isa<ObjCInterfaceDecl>(DC) || isa<ObjCImplementationDecl>(DC) ||
1607 isa<ObjCCategoryDecl>(DC)) &&
1608 "Invalid ivar decl context!");
1614 ID = IM->getClassInterface();
1616 ID = cast<ObjCCategoryDecl>(DC)->getClassInterface();
1621 return new (
C, DC)
ObjCIvarDecl(DC, StartLoc, IdLoc, Id, T, TInfo, ac, BW,
1636 case ObjCCategoryImpl:
1638 llvm_unreachable(
"invalid ivar container!");
1641 case ObjCCategory: {
1647 case ObjCImplementation:
1648 return cast<ObjCImplementationDecl>(DC)->getClassInterface();
1651 return cast<ObjCInterfaceDecl>(DC);
1664 void ObjCAtDefsFieldDecl::anchor() { }
1684 void ObjCProtocolDecl::anchor() { }
1691 redeclarable_base(C), Data() {
1692 setPreviousDecl(PrevDecl);
1694 Data = PrevDecl->Data;
1733 bool isInstance)
const {
1742 if ((MethodDecl =
getMethod(Sel, isInstance)))
1746 if ((MethodDecl = I->lookupMethod(Sel, isInstance)))
1751 void ObjCProtocolDecl::allocateDefinitionData() {
1752 assert(!Data.getPointer() &&
"Protocol already has a definition!");
1754 Data.getPointer()->Definition =
this;
1758 allocateDefinitionData();
1762 RD->Data = this->Data;
1769 for (
auto *Prop : PDecl->properties()) {
1771 PM.insert(std::make_pair(Prop->getIdentifier(), Prop));
1775 for (
const auto *PI : PDecl->protocols())
1776 PI->collectPropertiesToImplement(PM, PO);
1785 bool MatchFound =
false;
1786 for (
auto *Prop : PDecl->properties()) {
1787 if (Prop == Property)
1797 for (
const auto *PI : PDecl->protocols())
1798 PI->collectInheritedProtocolProperties(Property, PM);
1804 if (ObjCRuntimeNameAttr *ObjCRTName = getAttr<ObjCRuntimeNameAttr>())
1805 return ObjCRTName->getMetadataName();
1814 void ObjCCategoryDecl::anchor() { }
1824 ClassInterface(IDecl), TypeParamList(nullptr),
1825 NextClassCategory(nullptr), CategoryNameLoc(CategoryNameLoc),
1826 IvarLBraceLoc(IvarLBraceLoc), IvarRBraceLoc(IvarRBraceLoc)
1828 setTypeParamList(typeParamList);
1842 IDecl, typeParamList, IvarLBraceLoc,
1850 L->AddedObjCCategoryToInterface(CatDecl, IDecl);
1861 nullptr,
nullptr,
nullptr);
1866 const_cast<ObjCCategoryDecl*>(
this));
1874 TypeParamList = TPL;
1878 for (
auto typeParam : *TypeParamList)
1879 typeParam->setDeclContext(
this);
1887 void ObjCCategoryImplDecl::anchor() { }
1899 atStartLoc, CategoryNameLoc);
1917 void ObjCImplDecl::anchor() { }
1921 property->setLexicalDeclContext(
this);
1929 = dyn_cast_or_null<ObjCImplementationDecl>(
this)) {
1934 dyn_cast_or_null<ObjCCategoryImplDecl>(
this)) {
1939 ClassInterface = IFace;
1949 if (PID->getPropertyIvarDecl() &&
1950 PID->getPropertyIvarDecl()->getIdentifier() == ivarId)
1962 if (PID->getPropertyDecl()->getIdentifier() == Id)
1977 void ObjCImplementationDecl::anchor() { }
1991 nameLoc, atStartLoc, superLoc,
1992 IvarLBraceLoc, IvarRBraceLoc);
2003 unsigned numInitializers) {
2004 if (numInitializers > 0) {
2005 NumIvarInitializers = numInitializers;
2008 memcpy(ivarInitializers, initializers,
2010 IvarInitializers = ivarInitializers;
2029 void ObjCCompatibleAliasDecl::anchor() { }
2049 void ObjCPropertyDecl::anchor() { }
bool isObjCSelType() const
StringRef getObjCRuntimeNameAsString() const
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. If the method is implicit (not coming fro...
bool hasDefinition() const
Determine whether this class has been defined.
Defines the clang::ASTContext interface.
void setExternallyCompleted()
Indicate that this Objective-C class is complete, but that the external AST source will be responsibl...
void setImplicit(bool I=true)
StringRef getName() const
protocol_range protocols() const
Smart pointer class that efficiently represents Objective-C method names.
static ObjCIvarDecl * CreateDeserialized(ASTContext &C, unsigned ID)
bool ProtocolCompatibleWithProtocol(ObjCProtocolDecl *lProto, ObjCProtocolDecl *rProto) const
ObjCInterfaceDecl * getClassInterface()
const ObjCInterfaceDecl * isObjCRequiresPropertyDefs() const
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
void gatherDefaultTypeArgs(SmallVectorImpl< QualType > &typeArgs) const
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. If PrevDecl is NULL, set this as the first and only declaration...
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
Source range that this declaration covers.
QualType substObjCTypeArgs(ASTContext &ctx, ArrayRef< QualType > typeArgs, ObjCSubstitutionContext context) const
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
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)
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
QualType getUsageType(QualType objectType) const
llvm::DenseMap< const ObjCProtocolDecl *, ObjCPropertyDecl * > ProtocolPropertyMap
QualType getObjCClassType() const
Represents the Objective-C Class type.
TypeSourceInfo * getSuperClassTInfo() const
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)
ObjCPropertyDecl * FindPropertyVisibleInPrimaryClass(IdentifierInfo *PropertyId) const
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
const ObjCMethodDecl * getObjCMethodRedeclaration(const ObjCMethodDecl *MD) const
Get the duplicate declaration of a ObjCMethod in the same interface, or null if none exists...
ObjCTypeParamList * getTypeParamListAsWritten() const
const ObjCInterfaceDecl * getContainingInterface() const
Return the class interface that this ivar is logically contained in; this is either the interface whe...
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. This is either a single result (with no stable stora...
ObjCMethodFamily
A family of Objective-C methods.
ObjCIvarDecl * getIvarDecl(IdentifierInfo *Id) const
bool isOverriding() const
Whether this method overrides any other in the class hierarchy.
void setTypeParamList(ObjCTypeParamList *TPL)
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
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)
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
bool hasDesignatedInitializers() const
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
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
llvm::DenseMap< IdentifierInfo *, ObjCPropertyDecl * > PropertyMap
ObjCMethodDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
bool hasExplicitBound() const
ObjCMethodDecl * lookupPrivateMethod(const Selector &Sel, bool Instance=true) const
Lookup a method in the classes implementation hierarchy.
static ObjCPropertyDecl * findPropertyDecl(const DeclContext *DC, const IdentifierInfo *propertyID)
Lookup a property by name in the specified DeclContext.
ObjCProtocolDecl * lookupProtocolNamed(IdentifierInfo *PName)
static ObjCCompatibleAliasDecl * CreateDeserialized(ASTContext &C, unsigned ID)
bool isThisDeclarationADesignatedInitializer() const
void setTypeParamList(ObjCTypeParamList *TPL)
ID
Defines the set of possible language-specific address spaces.
QualType getObjCInterfaceType(const ObjCInterfaceDecl *Decl, ObjCInterfaceDecl *PrevDecl=nullptr) const
void setNextIvar(ObjCIvarDecl *ivar)
ObjCCategoryDecl * getCategoryListRaw() const
Retrieve the raw pointer to the start of the category/extension list.
StringRef getName() const
Return the actual identifier string.
StringRef getObjCRuntimeNameAsString() const
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
void setObjCMethodRedeclaration(const ObjCMethodDecl *MD, const ObjCMethodDecl *Redecl)
ObjCMethodDecl * lookupInstanceMethod(Selector Sel) const
Lookup an instance method for a given selector.
static ObjCTypeParamDecl * Create(ASTContext &ctx, DeclContext *dc, ObjCTypeParamVariance variance, SourceLocation varianceLoc, unsigned index, SourceLocation nameLoc, IdentifierInfo *name, SourceLocation colonLoc, TypeSourceInfo *boundInfo)
DeclContext * getDeclContext()
An abstract interface that should be implemented by listeners that want to be notified when an AST en...
bool isObjCIdType() const
void setObjCImplementation(ObjCInterfaceDecl *IFaceD, ObjCImplementationDecl *ImplD)
Set the implementation of ObjCInterfaceDecl.
void setImplementation(ObjCImplementationDecl *ImplD)
void mergeClassExtensionProtocolList(ObjCProtocolDecl *const *List, unsigned Num, ASTContext &C)
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
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)
ObjCPropertyImplDecl * FindPropertyImplDecl(IdentifierInfo *propertyId) const
redecl_range redecls() const
Returns an iterator range for all the redeclarations of the same decl. It will iterate at least once ...
static ObjCProtocolDecl * CreateDeserialized(ASTContext &C, unsigned ID)
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
QualType getUsageType(QualType objectType) const
Encodes a location in the source. The SourceManager can decode this to get at the full include stack...
IdentifierInfo & get(StringRef Name)
Return the identifier token info for the specified named identifier.
ExternalASTSource * getExternalSource() const
Retrieve a pointer to the external AST source associated with this AST context, if any...
StringRef getName() const
bool isRedeclaration() const
True if this is a method redeclaration in the same interface.
ivar_iterator ivar_end() const
bool isValid() const
Return true if this is a valid SourceLocation object.
ASTContext & getASTContext() const LLVM_READONLY
Stmt * getBody() const override
Retrieve the body of this method, if it has one.
QualType withConst() const
all_protocol_iterator all_referenced_protocol_end() const
ObjCInterfaceDecl * lookupInheritedClass(const IdentifierInfo *ICName)
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
bool operator<(DeclarationName LHS, DeclarationName RHS)
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
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. It also returns 'true' if one of its categories has declared a 'readwrite' property. This is because, user must provide a setter method for the category's 'readwrite' property.
ObjCCategoryImplDecl * getImplementation() const
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
prop_range properties() const
ObjCMethodDecl * getInstanceMethod(Selector Sel, bool AllowHidden=false) const
bool isInvalidDecl() const
ObjCInterfaceDecl * getDefinition()
Retrieve the definition of this class, or NULL if this class has been forward-declared (with @class) ...
void setIvarList(ObjCIvarDecl *ivar)
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
ObjCMethodFamily getMethodFamily() const
Derive the conventional family of this method.
ObjCMethodDecl * getCategoryInstanceMethod(Selector Sel) const
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)
ObjCMethodDecl * lookupMethod(Selector Sel, bool isInstance, bool shallowCategoryLookup=false, bool followSuper=true, const ObjCCategoryDecl *C=nullptr) const
static ImplicitParamDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation IdLoc, IdentifierInfo *Id, QualType T)
ObjCTypeParamList * getTypeParamList() const
Represents a C++ base or member initializer.
virtual void CompleteType(TagDecl *Tag)
Gives the external AST source an opportunity to complete an incomplete type.
ObjCPropertyDecl * FindPropertyDeclaration(const IdentifierInfo *PropertyId) 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(...).
void setIvarInitializers(ASTContext &C, CXXCtorInitializer **initializers, unsigned numInitializers)
StringRef getName() const
static ObjCImplementationDecl * CreateDeserialized(ASTContext &C, unsigned ID)
all_protocol_iterator all_referenced_protocol_begin() const
void setClassInterface(ObjCInterfaceDecl *IFace)
void * Allocate(size_t Size, unsigned Align=8) const
llvm::mapped_iterator< param_const_iterator, deref_fun > param_type_iterator
ObjCInterfaceDecl * getSuperClass() const
Kind
Lists the kind of concrete classes of Decl.
QualType getSendResultType() const
Determine the type of an expression that sends a message to this function. This replaces the type par...
ObjCInterfaceDecl * getMostRecentDecl()
Returns the most recent (re)declaration of this declaration.
static ObjCInterfaceDecl * CreateDeserialized(const ASTContext &C, unsigned ID)
static ObjCPropertyImplDecl * CreateDeserialized(ASTContext &C, unsigned ID)
void addPropertyImplementation(ObjCPropertyImplDecl *property)
A trivial tuple used to represent a source range.
SourceLocation getLocation() const
ObjCIvarDecl * all_declared_ivar_begin()
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()
IdentifierInfo * getDefaultSynthIvarName(ASTContext &Ctx) const
Get the default name of the synthesized ivar.
void collectPropertiesToImplement(PropertyMap &PM, PropertyDeclOrder &PO) const override
void setCmdDecl(ImplicitParamDecl *CD)
The parameter is invariant: must match exactly.
const ObjCObjectType * getSuperClassType() const
Retrieve the superclass type.
visible_extensions_range visible_extensions() const
bool isHidden() const
Determine whether this declaration is hidden from name lookup.
param_type_iterator param_type_begin() const