27 #include "llvm/ADT/None.h" 28 #include "llvm/ADT/SmallString.h" 29 #include "llvm/ADT/SmallVector.h" 30 #include "llvm/Support/Casting.h" 31 #include "llvm/Support/ErrorHandling.h" 32 #include "llvm/Support/raw_ostream.h" 39 using namespace clang;
47 if (Elts == 0)
return;
49 List =
new (Ctx)
void*[Elts];
51 memcpy(
List, InList,
sizeof(
void*)*Elts);
61 set(InList, Elts, Ctx);
68 void ObjCContainerDecl::anchor() {}
76 Ivar != IvarEnd; ++Ivar) {
86 bool AllowHidden)
const {
91 if (Def->isHidden() && !AllowHidden)
104 Meth != MethEnd; ++Meth) {
122 Meth != MethEnd; ++Meth) {
131 for (
const auto *Cat :
ID->visible_categories()) {
133 if (!MD->isImplicit())
135 if (Cat->IsClassExtension())
141 for (
const auto *
P : Cat->properties())
150 for (
const auto *Proto :
ID->all_referenced_protocols())
151 if (Proto->HasUserDeclaredSetterMethod(Property))
163 for (
const auto *PI : PD->protocols())
164 if (PI->HasUserDeclaredSetterMethod(Property))
183 if (
auto *IDecl = dyn_cast<ObjCInterfaceDecl>(DC)) {
184 for (
const auto *Ext : IDecl->visible_extensions())
199 !PD->isClassProperty()) ||
201 PD->isClassProperty()) ||
203 !PD->isClassProperty()))
206 if (PD->isClassProperty())
221 llvm::raw_svector_ostream os(ivarName);
241 if (
const auto *ClassDecl = dyn_cast<ObjCInterfaceDecl>(
this)) {
242 for (
const auto *Ext : ClassDecl->visible_extensions()) {
243 if (
auto *
P = Ext->FindPropertyDeclaration(PropertyId, QueryKind))
256 case Decl::ObjCProtocol: {
264 case Decl::ObjCInterface: {
268 if (!Cat->IsClassExtension())
270 PropertyId, QueryKind))
282 return superClass->FindPropertyDeclaration(PropertyId, QueryKind);
285 case Decl::ObjCCategory: {
299 void ObjCInterfaceDecl::anchor() {}
308 return def->getTypeParamListAsWritten();
313 for (
auto decl = getMostRecentDecl();
decl;
decl =
decl->getPreviousDecl()) {
326 for (
auto typeParam : *TypeParamList)
327 typeParam->setDeclContext(
this);
335 if (data().ExternallyCompleted)
336 LoadExternalDefinition();
352 return superTInfo->getTypeLoc().getLocStart();
368 if (data().ExternallyCompleted)
369 LoadExternalDefinition();
377 for (
const auto *I : all_referenced_protocols())
387 for (
auto *Prop : properties()) {
388 PM[std::make_pair(Prop->getIdentifier(), Prop->isClassProperty())] = Prop;
391 for (
const auto *Ext : known_extensions()) {
394 PM[std::make_pair(Prop->getIdentifier(), Prop->isClassProperty())] = Prop;
398 for (
const auto *PI : all_referenced_protocols())
399 PI->collectPropertiesToImplement(PM, PO);
408 if (Class->
hasAttr<ArcWeakrefUnavailableAttr>())
418 if (Class->
hasAttr<ObjCRequiresPropertyDefsAttr>())
428 if (data().ExternallyCompleted)
429 LoadExternalDefinition();
431 if (data().AllReferencedProtocols.empty() &&
432 data().ReferencedProtocols.empty()) {
433 data().AllReferencedProtocols.set(ExtList, ExtNum, C);
441 for (
unsigned i = 0; i < ExtNum; i++) {
442 bool protocolExists =
false;
444 for (
auto *Proto : all_referenced_protocols()) {
446 protocolExists =
true;
453 ProtocolRefs.push_back(ProtoInExtension);
456 if (ProtocolRefs.empty())
460 ProtocolRefs.append(all_referenced_protocol_begin(),
461 all_referenced_protocol_end());
463 data().AllReferencedProtocols.set(ProtocolRefs.data(), ProtocolRefs.size(),
C);
467 ObjCInterfaceDecl::findInterfaceWithDesignatedInitializers()
const {
472 if (!IFace->inheritsDesignatedInitializers())
481 if (MD->getMethodFamily() ==
OMF_init && !MD->isOverriding())
485 for (
const auto *MD : Ext->instance_methods()) {
486 if (MD->getMethodFamily() ==
OMF_init && !MD->isOverriding())
491 for (
const auto *MD : ImplD->instance_methods()) {
492 if (MD->getMethodFamily() ==
OMF_init && !MD->isOverriding())
499 bool ObjCInterfaceDecl::inheritsDesignatedInitializers()
const {
500 switch (data().InheritedDesignatedInitializers) {
501 case DefinitionData::IDI_Inherited:
503 case DefinitionData::IDI_NotInherited:
505 case DefinitionData::IDI_Unknown:
510 data().InheritedDesignatedInitializers = DefinitionData::IDI_NotInherited;
512 if (
auto SuperD = getSuperClass()) {
513 data().InheritedDesignatedInitializers =
514 SuperD->declaresOrInheritsDesignatedInitializers() ?
515 DefinitionData::IDI_Inherited :
516 DefinitionData::IDI_NotInherited;
518 data().InheritedDesignatedInitializers =
519 DefinitionData::IDI_NotInherited;
522 assert(data().InheritedDesignatedInitializers
523 != DefinitionData::IDI_Unknown);
524 return data().InheritedDesignatedInitializers ==
525 DefinitionData::IDI_Inherited;
528 llvm_unreachable(
"unexpected InheritedDesignatedInitializers value");
534 if (!isThisDeclarationADefinition())
536 if (data().ExternallyCompleted)
537 LoadExternalDefinition();
544 if (MD->isThisDeclarationADesignatedInitializer())
545 Methods.push_back(MD);
547 for (
const auto *MD : Ext->instance_methods())
548 if (MD->isThisDeclarationADesignatedInitializer())
549 Methods.push_back(MD);
555 bool HasCompleteDef = isThisDeclarationADefinition();
561 HasCompleteDef =
true;
567 if (data().ExternallyCompleted)
568 LoadExternalDefinition();
575 if (MD->isThisDeclarationADesignatedInitializer()) {
583 if (MD->isThisDeclarationADesignatedInitializer()) {
593 void ObjCInterfaceDecl::allocateDefinitionData() {
594 assert(!
hasDefinition() &&
"ObjC class already has a definition");
595 Data.setPointer(
new (getASTContext()) DefinitionData());
596 Data.getPointer()->Definition =
this;
600 cast<ObjCInterfaceType>(TypeForDecl)->
Decl =
this;
604 allocateDefinitionData();
607 for (
auto RD : redecls()) {
619 if (data().ExternallyCompleted)
620 LoadExternalDefinition();
623 while (ClassDecl !=
nullptr) {
625 clsDeclared = ClassDecl;
631 clsDeclared = ClassDecl;
650 if (data().ExternallyCompleted)
651 LoadExternalDefinition();
654 while (ClassDecl !=
nullptr) {
664 for (
auto *
P : all_referenced_protocols())
665 if (
P->lookupProtocolNamed(Name))
677 bool shallowCategoryLookup,
688 if (data().ExternallyCompleted)
689 LoadExternalDefinition();
693 if ((MethodDecl = ClassDecl->
getMethod(Sel, isInstance)))
698 if ((MethodDecl = Cat->getMethod(Sel, isInstance)))
703 for (
const auto *I : ClassDecl->
protocols())
704 if ((MethodDecl = I->lookupMethod(Sel, isInstance)))
708 if (!shallowCategoryLookup)
712 Cat->getReferencedProtocols();
714 E = Protocols.
end(); I != E; ++I)
715 if ((MethodDecl = (*I)->lookupMethod(Sel, isInstance)))
735 bool Instance)
const {
740 if (data().ExternallyCompleted)
741 LoadExternalDefinition();
745 Method = Instance ? ImpDecl->getInstanceMethod(Sel)
746 : ImpDecl->getClassMethod(Sel);
750 Method = getCategoryMethod(Sel, Instance);
755 if (!Instance && !Method && !getSuperClass()) {
756 Method = lookupInstanceMethod(Sel);
760 Method = lookupPrivateMethod(Sel,
true);
763 if (!Method && getSuperClass())
764 return getSuperClass()->lookupPrivateMethod(Sel, Instance);
775 DeclContext *contextDecl,
bool isInstance,
bool isVariadic,
776 bool isPropertyAccessor,
bool isImplicitlyDeclared,
bool isDefined,
779 beginLoc, endLoc, SelInfo, T, ReturnTInfo, contextDecl, isInstance,
780 isVariadic, isPropertyAccessor, isImplicitlyDeclared, isDefined,
781 impControl, HasRelatedResultType);
790 return getMethodFamily() ==
OMF_init &&
791 hasAttr<ObjCDesignatedInitializerAttr>();
799 if (isa<ObjCProtocolDecl>(DC))
802 return ID->isDesignatedInitializer(getSelector(), InitMethod);
807 return Body.get(getASTContext().getExternalSource());
812 getASTContext().setObjCMethodRedeclaration(PrevMethod,
this);
813 IsRedeclaration =
true;
814 PrevMethod->HasRedeclaration =
true;
817 void ObjCMethodDecl::setParamsAndSelLocs(
ASTContext &
C,
820 ParamsAndSelLocs =
nullptr;
821 NumParams = Params.size();
822 if (Params.empty() && SelLocs.empty())
826 "Alignment not sufficient for SourceLocation");
828 unsigned Size =
sizeof(
ParmVarDecl *) * NumParams +
830 ParamsAndSelLocs = C.
Allocate(Size);
831 std::copy(Params.begin(), Params.end(), getParams());
832 std::copy(SelLocs.begin(), SelLocs.end(), getStoredSelLocs());
837 for (
unsigned i = 0, e = getNumSelectorLocs(); i != e; ++i)
838 SelLocs.push_back(getSelectorLoc(i));
844 assert((!SelLocs.empty() || isImplicit()) &&
845 "No selector locs for non-implicit method");
847 return setParamsAndSelLocs(C, Params,
llvm::None);
852 return setParamsAndSelLocs(C, Params,
llvm::None);
854 setParamsAndSelLocs(C, Params, SelLocs);
863 if (HasRedeclaration)
868 Decl *CtxD = cast<Decl>(getDeclContext());
873 if (!ImplD->isInvalidDecl())
878 if (!ImplD->isInvalidDecl())
882 dyn_cast<ObjCImplementationDecl>(CtxD)) {
884 if (!IFD->isInvalidDecl())
888 dyn_cast<ObjCCategoryImplDecl>(CtxD)) {
890 if (!CatD->isInvalidDecl())
898 if (Redecl && cast<Decl>(Redecl->
getDeclContext())->isInvalidDecl())
901 if (!Redecl && isRedeclaration()) {
903 return cast<ObjCContainerDecl>(CtxD)->getMethod(getSelector(),
907 return Redecl ? Redecl :
this;
911 Decl *CtxD = cast<Decl>(getDeclContext());
919 dyn_cast<ObjCCategoryImplDecl>(CtxD)) {
926 if (isRedeclaration()) {
929 cast<ObjCContainerDecl>(CtxD)->getMethod(getSelector(),
931 return MD ? MD :
this;
938 if (
Stmt *Body = getBody())
939 return Body->getLocEnd();
949 if (
const ObjCMethodFamilyAttr *attr = getAttr<ObjCMethodFamilyAttr>()) {
952 switch (attr->getFamily()) {
960 Family =
static_cast<unsigned>(family);
964 family = getSelector().getMethodFamily();
981 if (!getReturnType()->isObjCObjectPointerType())
1006 unsigned noParams = param_size();
1007 if (noParams < 1 || noParams > 3)
1016 while (--noParams) {
1031 Family =
static_cast<unsigned>(family);
1037 bool &selfIsPseudoStrong,
1038 bool &selfIsConsumed) {
1040 selfIsPseudoStrong =
false;
1041 selfIsConsumed =
false;
1056 selfIsConsumed = hasAttr<NSConsumesSelfAttr>();
1065 if (getMethodFamily() !=
OMF_init && !selfIsConsumed) {
1067 selfIsPseudoStrong =
true;
1071 assert(isClassMethod());
1074 selfIsPseudoStrong =
true;
1082 bool selfIsPseudoStrong, selfIsConsumed;
1084 getSelfType(Context, OID, selfIsPseudoStrong, selfIsConsumed);
1091 Self->addAttr(NSConsumedAttr::CreateImplicit(Context));
1093 if (selfIsPseudoStrong)
1094 Self->setARCPseudoStrong(
true);
1105 return CD->getClassInterface();
1106 if (
ObjCImplDecl *IMD = dyn_cast<ObjCImplDecl>(getDeclContext()))
1107 return IMD->getClassInterface();
1108 if (isa<ObjCProtocolDecl>(getDeclContext()))
1110 llvm_unreachable(
"unknown method context");
1114 const auto *TSI = getReturnTypeSourceInfo();
1116 return TSI->getTypeLoc().getSourceRange();
1122 return getReturnType().getNonLValueExprType(Ctx)
1137 bool MovedToSuper) {
1145 Category = dyn_cast<ObjCCategoryDecl>(Container)) {
1153 if (Method != Overridden) {
1156 Methods.push_back(Overridden);
1160 for (
const auto *
P :
Category->protocols())
1170 if (Method != Overridden) {
1173 Methods.push_back(Overridden);
1177 if (
const ObjCProtocolDecl *Protocol = dyn_cast<ObjCProtocolDecl>(Container)){
1178 for (
const auto *
P : Protocol->protocols())
1183 Interface = dyn_cast<ObjCInterfaceDecl>(Container)) {
1184 for (
const auto *
P : Interface->protocols())
1187 for (
const auto *Cat : Interface->known_categories())
1240 Method, overridden);
1255 assert(!Overridden.empty() &&
1256 "ObjCMethodDecl's overriding bit is not as expected");
1267 if (isPropertyAccessor()) {
1269 bool IsGetter = (NumArgs == 0);
1274 auto findMatchingProperty =
1278 Selector NextSel = IsGetter ? I->getGetterName()
1279 : I->getSetterName();
1285 Selector NextSel = IsGetter ? I->getGetterName()
1286 : I->getSetterName();
1296 if (
const auto *Found = findMatchingProperty(Container))
1301 if (
const auto *
Category = dyn_cast<ObjCCategoryDecl>(Container)) {
1302 ClassDecl =
Category->getClassInterface();
1303 if (
const auto *Found = findMatchingProperty(ClassDecl))
1313 if (Ext == Container)
1316 if (
const auto *Found = findMatchingProperty(Ext))
1321 llvm_unreachable(
"Marked as a property accessor but no property found!");
1324 if (!CheckOverrides)
1329 OverridesTy Overrides;
1330 getOverriddenMethods(Overrides);
1331 for (OverridesTy::const_iterator I = Overrides.begin(), E = Overrides.end();
1344 void ObjCTypeParamDecl::anchor() {}
1356 nameLoc, name, colonLoc, boundInfo);
1373 startLoc = getLocation();
1375 if (hasExplicitBound()) {
1377 getTypeSourceInfo()->getTypeLoc().getEndLoc());
1389 : NumParams(typeParams.size()) {
1392 std::copy(typeParams.begin(), typeParams.end(), begin());
1401 ctx.
Allocate(totalSizeToAlloc<ObjCTypeParamDecl *>(typeParams.size()),
1408 typeArgs.reserve(
size());
1409 for (
auto typeParam : *
this)
1410 typeArgs.push_back(typeParam->getUnderlyingType());
1453 setPreviousDecl(PrevDecl);
1457 Data = PrevDecl->Data;
1459 setImplicit(IsInternal);
1461 setTypeParamList(typeParamList);
1464 void ObjCInterfaceDecl::LoadExternalDefinition()
const {
1465 assert(data().ExternallyCompleted &&
"Class is not externally completed");
1466 data().ExternallyCompleted =
false;
1467 getASTContext().getExternalSource()->CompleteType(
1468 const_cast<ObjCInterfaceDecl *>(
this));
1472 assert(getASTContext().getExternalSource() &&
1473 "Class can't be externally completed without an external source");
1475 "Forward declarations can't be externally completed");
1476 data().ExternallyCompleted =
true;
1481 if (!isThisDeclarationADefinition())
1483 data().HasDesignatedInitializers =
true;
1488 if (!isThisDeclarationADefinition())
1490 if (data().ExternallyCompleted)
1491 LoadExternalDefinition();
1493 return data().HasDesignatedInitializers;
1498 if (ObjCRuntimeNameAttr *ObjCRTName = getAttr<ObjCRuntimeNameAttr>())
1499 return ObjCRTName->getMetadataName();
1507 const_cast<ObjCImplementationDecl*>(
this)->getClassInterface())
1508 return ID->getObjCRuntimeNameAsString();
1515 if (data().ExternallyCompleted)
1516 LoadExternalDefinition();
1518 return getASTContext().getObjCImplementation(
1519 const_cast<ObjCInterfaceDecl*>(Def));
1527 getASTContext().setObjCImplementation(
getDefinition(), ImplD);
1532 struct SynthesizeIvarChunk {
1537 : Size(size), Ivar(ivar) {}
1540 bool operator<(
const SynthesizeIvarChunk & LHS,
1541 const SynthesizeIvarChunk &RHS) {
1542 return LHS.Size < RHS.Size;
1562 if (!data().IvarList) {
1563 if (!ivar_empty()) {
1565 data().IvarList = *I; ++I;
1566 for (curIvar = data().IvarList; I != E; curIvar = *I, ++I)
1570 for (
const auto *Ext : known_extensions()) {
1571 if (!Ext->ivar_empty()) {
1573 I = Ext->ivar_begin(),
1574 E = Ext->ivar_end();
1575 if (!data().IvarList) {
1576 data().IvarList = *I; ++I;
1577 curIvar = data().IvarList;
1579 for ( ;I != E; curIvar = *I, ++I)
1583 data().IvarListMissingImplementation =
true;
1587 if (!data().IvarListMissingImplementation)
1588 return data().IvarList;
1591 data().IvarListMissingImplementation =
false;
1592 if (!ImplDecl->ivar_empty()) {
1594 for (
auto *IV : ImplDecl->ivars()) {
1595 if (IV->getSynthesize() && !IV->isInvalidDecl()) {
1596 layout.push_back(SynthesizeIvarChunk(
1597 IV->getASTContext().getTypeSize(IV->getType()), IV));
1600 if (!data().IvarList)
1601 data().IvarList = IV;
1607 if (!layout.empty()) {
1609 std::stable_sort(layout.begin(), layout.end());
1610 unsigned Ix = 0, EIx = layout.size();
1611 if (!data().IvarList) {
1612 data().IvarList = layout[0].Ivar; Ix++;
1613 curIvar = data().IvarList;
1615 for ( ; Ix != EIx; curIvar = layout[Ix].Ivar, Ix++)
1620 return data().IvarList;
1633 if (data().ExternallyCompleted)
1634 LoadExternalDefinition();
1636 for (
auto *Cat : visible_categories())
1637 if (Cat->getIdentifier() == CategoryId)
1645 for (
const auto *Cat : visible_categories()) {
1655 for (
const auto *Cat : visible_categories()) {
1668 bool lookupCategory,
1669 bool RHSIsQualifiedID) {
1676 if (getASTContext().ProtocolCompatibleWithProtocol(lProto, PI))
1684 if (RHSIsQualifiedID &&
1685 getASTContext().ProtocolCompatibleWithProtocol(PI, lProto))
1691 for (
const auto *Cat : visible_categories()) {
1692 for (
auto *PI : Cat->protocols())
1693 if (getASTContext().ProtocolCompatibleWithProtocol(lProto, PI))
1710 void ObjCIvarDecl::anchor() {}
1729 assert((isa<ObjCInterfaceDecl>(DC) || isa<ObjCImplementationDecl>(DC) ||
1730 isa<ObjCCategoryDecl>(DC)) &&
1731 "Invalid ivar decl context!");
1737 ID = IM->getClassInterface();
1739 ID = cast<ObjCCategoryDecl>(DC)->getClassInterface();
1744 return new (
C, DC)
ObjCIvarDecl(DC, StartLoc, IdLoc, Id, T, TInfo, ac, BW,
1759 case ObjCCategoryImpl:
1761 llvm_unreachable(
"invalid ivar container!");
1764 case ObjCCategory: {
1770 case ObjCImplementation:
1771 return cast<ObjCImplementationDecl>(DC)->getClassInterface();
1774 return cast<ObjCInterfaceDecl>(DC);
1787 void ObjCAtDefsFieldDecl::anchor() {}
1807 void ObjCProtocolDecl::anchor() {}
1814 redeclarable_base(C) {
1815 setPreviousDecl(PrevDecl);
1817 Data = PrevDecl->Data;
1846 for (
auto *I : protocols())
1847 if ((PDecl = I->lookupProtocolNamed(Name)))
1856 bool isInstance)
const {
1865 if ((MethodDecl = getMethod(Sel, isInstance)))
1868 for (
const auto *I : protocols())
1869 if ((MethodDecl = I->lookupMethod(Sel, isInstance)))
1874 void ObjCProtocolDecl::allocateDefinitionData() {
1875 assert(!Data.getPointer() &&
"Protocol already has a definition!");
1876 Data.setPointer(
new (getASTContext()) DefinitionData);
1877 Data.getPointer()->Definition =
this;
1881 allocateDefinitionData();
1884 for (
auto RD : redecls())
1885 RD->Data = this->Data;
1891 for (
auto *Prop : PDecl->properties()) {
1893 PM.insert(std::make_pair(
1894 std::make_pair(Prop->getIdentifier(), Prop->isClassProperty()),
1899 for (
const auto *PI : PDecl->protocols())
1900 PI->collectPropertiesToImplement(PM, PO);
1908 if (!PS.insert(PDecl).second)
1910 for (
auto *Prop : PDecl->properties()) {
1911 if (Prop == Property)
1919 for (
const auto *PI : PDecl->protocols())
1920 PI->collectInheritedProtocolProperties(Property, PS, PO);
1926 if (ObjCRuntimeNameAttr *ObjCRTName = getAttr<ObjCRuntimeNameAttr>())
1927 return ObjCRTName->getMetadataName();
1936 void ObjCCategoryDecl::anchor() {}
1946 ClassInterface(IDecl), CategoryNameLoc(CategoryNameLoc),
1947 IvarLBraceLoc(IvarLBraceLoc), IvarRBraceLoc(IvarRBraceLoc) {
1948 setTypeParamList(typeParamList);
1962 IDecl, typeParamList, IvarLBraceLoc,
1970 L->AddedObjCCategoryToInterface(CatDecl, IDecl);
1981 nullptr,
nullptr,
nullptr);
1985 return getASTContext().getObjCImplementation(
1986 const_cast<ObjCCategoryDecl*>(
this));
1990 getASTContext().setObjCImplementation(
this, ImplD);
1994 TypeParamList = TPL;
1998 for (
auto typeParam : *TypeParamList)
1999 typeParam->setDeclContext(
this);
2007 void ObjCCategoryImplDecl::anchor() {}
2019 atStartLoc, CategoryNameLoc);
2036 void ObjCImplDecl::anchor() {}
2040 property->setLexicalDeclContext(
this);
2048 = dyn_cast_or_null<ObjCImplementationDecl>(
this)) {
2053 dyn_cast_or_null<ObjCCategoryImplDecl>(
this)) {
2058 ClassInterface = IFace;
2066 for (
auto *PID : property_impls())
2067 if (PID->getPropertyIvarDecl() &&
2068 PID->getPropertyIvarDecl()->getIdentifier() == ivarId)
2080 for (
auto *PID : property_impls())
2083 if (PID->getPropertyDecl()->getIdentifier() ==
Id) {
2085 !PID->getPropertyDecl()->isClassProperty()) ||
2087 PID->getPropertyDecl()->isClassProperty()) ||
2089 !PID->getPropertyDecl()->isClassProperty()))
2092 if (PID->getPropertyDecl()->isClassProperty())
2093 ClassPropImpl = PID;
2098 return ClassPropImpl;
2113 void ObjCImplementationDecl::anchor() {}
2127 nameLoc, atStartLoc, superLoc,
2128 IvarLBraceLoc, IvarRBraceLoc);
2139 unsigned numInitializers) {
2140 if (numInitializers > 0) {
2141 NumIvarInitializers = numInitializers;
2144 memcpy(ivarInitializers, initializers,
2146 IvarInitializers = ivarInitializers;
2152 return IvarInitializers.get(getASTContext().getExternalSource());
2165 void ObjCCompatibleAliasDecl::anchor() {}
2185 void ObjCPropertyDecl::anchor() {}
2236 if (IvarLoc.isValid())
ObjCMethodDecl * lookupMethod(Selector Sel, bool isInstance) const
Defines the clang::ASTContext interface.
bool hasDefinition() const
Determine whether this class has been defined.
static const Decl * getCanonicalDecl(const Decl *D)
void setExternallyCompleted()
Indicate that this Objective-C class is complete, but that the external AST source will be responsibl...
protocol_range protocols() const
Smart pointer class that efficiently represents Objective-C method names.
QualType getObjCIdType() const
Represents the Objective-CC id type.
unsigned getRawEncoding() const
When a SourceLocation itself cannot be used, this returns an (opaque) 32-bit integer encoding for it...
A (possibly-)qualified type.
static ObjCIvarDecl * CreateDeserialized(ASTContext &C, unsigned ID)
void getDesignatedInitializers(llvm::SmallVectorImpl< const ObjCMethodDecl *> &Methods) const
Returns the designated initializers for the interface.
ObjCInterfaceDecl * getClassInterface()
all_protocol_range all_referenced_protocols() const
ObjCInterfaceDecl * getClassInterface()
void startDefinition()
Starts the definition of this Objective-C class, taking it from a forward declaration (@class) to a d...
Stmt - This represents one statement.
SourceLocation getSuperClassLoc() const
Retrieve the starting location of the superclass.
C Language Family Type Representation.
void setObjCLifetime(ObjCLifetime type)
llvm::mapped_iterator< param_const_iterator, GetTypeFn > param_type_iterator
QualType getQualifiedType(SplitQualType split) const
Un-split a SplitQualType.
Decl - This represents one declaration (or definition), e.g.
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
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)
ObjCTypeParamList * getTypeParamList() const
Retrieve the type parameters of this class.
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)
bool isDesignatedInitializer(Selector Sel, const ObjCMethodDecl **InitMethod=nullptr) const
Returns true if the given selector is a designated initializer for the interface. ...
QualType withConst() const
A container of type source information.
bool isOverriding() const
Whether this method overrides any other in the class hierarchy.
void createImplicitParams(ASTContext &Context, const ObjCInterfaceDecl *ID)
createImplicitParams - Used to lazily create the self and cmd implict parameters. ...
CXXCtorInitializer *const * init_const_iterator
init_const_iterator - Iterates through the ivar initializer list.
void setImplementation(ObjCCategoryImplDecl *ImplD)
ObjCCategoryImplDecl * getImplementation() const
Parameter for Objective-C '_cmd' argument.
ObjCMethodDecl - Represents an instance or class method declaration.
ObjCImplementationDecl * getObjCImplementation(ObjCInterfaceDecl *D)
Get the implementation of the ObjCInterfaceDecl D, or nullptr if none exists.
bool ClassImplementsProtocol(ObjCProtocolDecl *lProto, bool lookupCategory, bool RHSIsQualifiedID=false)
ClassImplementsProtocol - Checks that 'lProto' protocol has been implemented in IDecl class...
bool isInvalidDecl() const
QualType getObjCClassType() const
Represents the Objective-C Class type.
static ObjCPropertyDecl * findPropertyDecl(const DeclContext *DC, const IdentifierInfo *propertyID, ObjCPropertyQueryKind queryKind)
Lookup a property by name in the specified DeclContext.
protocol_range protocols() const
static const NamedDecl * getDefinition(const Decl *D)
ParmVarDecl - Represents a parameter to a function.
The collection of all-type qualifiers we support.
IdentifierInfo * getIdentifier() const
getIdentifier - Get the identifier that names this declaration, if there is one.
instprop_range instance_properties() const
One of these records is kept for each identifier that is lexed.
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.
bool isObjCIdType() const
void setTypeParamList(ObjCTypeParamList *TPL)
Set the type parameters of this class.
SourceRange getReturnTypeSourceRange() const
instmeth_range instance_methods() const
StringRef getObjCRuntimeNameAsString() const
Produce a name to be used for protocol's metadata.
prop_range properties() const
bool isObjCSelType() const
void startDefinition()
Starts the definition of this Objective-C protocol.
visible_categories_range visible_categories() const
void set(ObjCProtocolDecl *const *InList, unsigned Elts, const SourceLocation *Locs, ASTContext &Ctx)
bool ProtocolCompatibleWithProtocol(ObjCProtocolDecl *lProto, ObjCProtocolDecl *rProto) const
ProtocolCompatibleWithProtocol - return 'true' if 'lProto' is in the inheritance hierarchy of 'rProto...
ObjCMethodFamily getMethodFamily() const
Determines the family of this method.
bool isThisDeclarationADesignatedInitializer() const
Returns true if this specific method declaration is marked with the designated initializer attribute...
void collectPropertiesToImplement(PropertyMap &PM, PropertyDeclOrder &PO) const override
This routine collects list of properties to be implemented in the class.
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.
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())
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified...
static ObjCPropertyImplDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation atLoc, SourceLocation L, ObjCPropertyDecl *property, Kind PK, ObjCIvarDecl *ivarDecl, SourceLocation ivarLoc)
const ObjCInterfaceDecl * isObjCRequiresPropertyDefs() const
isObjCRequiresPropertyDefs - Checks that a class or one of its super classes must not be auto-synthes...
static ObjCAtDefsFieldDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, QualType T, Expr *BW)
static ObjCCategoryImplDecl * CreateDeserialized(ASTContext &C, unsigned ID)
ObjCCategoryDecl * getCategoryListRaw() const
Retrieve the raw pointer to the start of the category/extension list.
ObjCProtocolDecl * getDefinition()
Retrieve the definition of this protocol, if any.
const Type * getTypePtr() const
Retrieves a pointer to the underlying (unqualified) type.
void getOverriddenMethods(SmallVectorImpl< const ObjCMethodDecl *> &Overridden) const
Return overridden methods for the given Method.
void setAsRedeclaration(const ObjCMethodDecl *PrevMethod)
Represents an Objective-C protocol declaration.
Represents an ObjC class declaration.
SourceLocation getLocEnd() const LLVM_READONLY
void setMethodParams(ASTContext &C, ArrayRef< ParmVarDecl *> Params, ArrayRef< SourceLocation > SelLocs=llvm::None)
Sets the method's parameters and selector source locations.
ObjCMethodDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
lookup_result lookup(DeclarationName Name) const
lookup - Find the declarations (if any) with the given Name in this context.
void getSelectorLocs(SmallVectorImpl< SourceLocation > &SelLocs) const
static ImplicitParamDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation IdLoc, IdentifierInfo *Id, QualType T, ImplicitParamKind ParamKind)
Create implicit parameter.
ObjCPropertyImplDecl - Represents implementation declaration of a property in a class or category imp...
ObjCMethodDecl * getCategoryInstanceMethod(Selector Sel) const
ObjCMethodDecl * getCategoryClassMethod(Selector Sel) const
visible_extensions_range visible_extensions() const
ObjCProtocolDecl * lookupProtocolNamed(IdentifierInfo *PName)
static ObjCCompatibleAliasDecl * CreateDeserialized(ASTContext &C, unsigned ID)
void setTypeParamList(ObjCTypeParamList *TPL)
Set the type parameters of this category.
QualType getUsageType(QualType objectType) const
Retrieve the type of this instance variable when viewed as a member of a specific object type...
void setNextIvar(ObjCIvarDecl *ivar)
classprop_range class_properties() const
Expr - This represents one expression.
Defines the clang::LangOptions interface.
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)
Selector getSetterName() 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.
IdentifierInfo * getDefaultSynthIvarName(ASTContext &Ctx) const
Get the default name of the synthesized ivar.
const FunctionProtoType * T
static void collectOverriddenMethodsSlow(const ObjCMethodDecl *Method, SmallVectorImpl< const ObjCMethodDecl *> &overridden)
const internal::VariadicAllOfMatcher< Decl > decl
Matches declarations.
bool isImplicit() const
isImplicit - Indicates whether the declaration was implicitly generated by the implementation.
static ObjCTypeParamDecl * Create(ASTContext &ctx, DeclContext *dc, ObjCTypeParamVariance variance, SourceLocation varianceLoc, unsigned index, SourceLocation nameLoc, IdentifierInfo *name, SourceLocation colonLoc, TypeSourceInfo *boundInfo)
DeclContext * getDeclContext()
ObjCInterfaceDecl * getSuperClass() const
An abstract interface that should be implemented by listeners that want to be notified when an AST en...
static ObjCTypeParamList * create(ASTContext &ctx, SourceLocation lAngleLoc, ArrayRef< ObjCTypeParamDecl *> typeParams, SourceLocation rAngleLoc)
Create a new Objective-C type parameter list.
ObjCPropertyDecl * FindPropertyVisibleInPrimaryClass(IdentifierInfo *PropertyId, ObjCPropertyQueryKind QueryKind) const
FindPropertyVisibleInPrimaryClass - Finds declaration of the property with name 'PropertyId' in the p...
Defines the clang::TypeLoc interface and its subclasses.
void setObjCImplementation(ObjCInterfaceDecl *IFaceD, ObjCImplementationDecl *ImplD)
Set the implementation of ObjCInterfaceDecl.
void setImplementation(ObjCImplementationDecl *ImplD)
Defines the clang::IdentifierInfo, clang::IdentifierTable, and clang::Selector interfaces.
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)
const ObjCMethodDecl * getObjCMethodRedeclaration(const ObjCMethodDecl *MD) const
Get the duplicate declaration of a ObjCMethod in the same interface, or null if none exists...
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...
llvm::SmallDenseSet< const ObjCProtocolDecl *, 8 > ProtocolPropertySet
QualType getObjCInterfaceType(const ObjCInterfaceDecl *Decl, ObjCInterfaceDecl *PrevDecl=nullptr) const
getObjCInterfaceType - Return the unique reference to the type for the specified ObjC interface decl...
static bool hasDefinition(const ObjCObjectPointerType *ObjPtr)
bool isInstanceMethod() const
unsigned getNumArgs() const
Selector getSelector() 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 StringRef getIdentifier(const Token &Tok)
static ObjCMethodDecl * CreateDeserialized(ASTContext &C, unsigned ID)
init_iterator init_begin()
init_begin() - Retrieve an iterator to the first initializer.
static ObjCCompatibleAliasDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, IdentifierInfo *Id, ObjCInterfaceDecl *aliasedClass)
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)
Encodes a location in the source.
IdentifierInfo & get(StringRef Name)
Return the identifier token info for the specified named identifier.
ObjCCategoryDecl * getCategoryDecl() const
QualType getObjCSelType() const
Retrieve the type that corresponds to the predefined Objective-C 'SEL' type.
Stmt * getBody() const override
Retrieve the body of this method, if it has one.
static void CollectOverriddenMethodsRecurse(const ObjCContainerDecl *Container, const ObjCMethodDecl *Method, SmallVectorImpl< const ObjCMethodDecl *> &Methods, bool MovedToSuper)
ObjCInterfaceDecl * lookupInheritedClass(const IdentifierInfo *ICName)
lookupInheritedClass - This method returns ObjCInterfaceDecl * of the super class whose name is passe...
ObjCCategoryDecl - Represents a category declaration.
QualType getObjCTypeParamType(const ObjCTypeParamDecl *Decl, ArrayRef< ObjCProtocolDecl *> protocols, QualType Canonical=QualType()) const
Represents one property declaration in an Objective-C interface.
ObjCPropertyImplDecl * FindPropertyImplIvarDecl(IdentifierInfo *ivarId) const
FindPropertyImplIvarDecl - This method lookup the ivar in the list of properties implemented in this ...
bool operator<(DeclarationName LHS, DeclarationName RHS)
Ordering on two declaration names.
ObjCImplementationDecl * getImplementation() const
bool isDesignatedInitializerForTheInterface(const ObjCMethodDecl **InitMethod=nullptr) const
Returns true if the method selector resolves to a designated initializer in the class's interface...
protocol_range protocols() const
void * Allocate(size_t Size, unsigned Align=8) const
QualType getUsageType(QualType objectType) const
Retrieve the type when this property is used with a specific base object type.
void collectInheritedProtocolProperties(const ObjCPropertyDecl *Property, ProtocolPropertySet &PS, PropertyDeclOrder &PO) const
Dataflow Directional Tag Classes.
ObjCMethodDecl * lookupPrivateMethod(const Selector &Sel, bool Instance=true) const
Lookup a method in the classes implementation hierarchy.
ObjCPropertyDecl * FindPropertyDeclaration(const IdentifierInfo *PropertyId, ObjCPropertyQueryKind QueryKind) const
FindPropertyDeclaration - Finds declaration of the property given its name in 'PropertyId' and return...
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
Parameter for Objective-C 'self' argument.
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.
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)
const ObjCInterfaceDecl * getContainingInterface() const
Return the class interface that this ivar is logically contained in; this is either the interface whe...
ObjCIvarDecl * getIvarDecl(IdentifierInfo *Id) const
getIvarDecl - This method looks up an ivar in this ContextDecl.
llvm::DenseMap< std::pair< IdentifierInfo *, unsigned >, ObjCPropertyDecl * > PropertyMap
bool isHidden() const
Determine whether this declaration might be hidden from name lookup.
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).
bool hasDesignatedInitializers() const
Returns true if this interface decl contains at least one initializer marked with the 'objc_designate...
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...
StringRef getObjCRuntimeNameAsString() const
Produce a name to be used for class's metadata.
Represents a C++ base or member initializer.
StringRef getObjCRuntimeNameAsString() const
Produce a name to be used for class's metadata.
void setCategoryListRaw(ObjCCategoryDecl *category)
Set the raw pointer to the start of the category/extension list.
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).
QualType getNonLValueExprType(const ASTContext &Context) const
Determine the type of a (typically non-lvalue) expression with the specified result type...
bool IsClassExtension() const
ASTMutationListener * getASTMutationListener() const
Retrieve a pointer to the AST mutation listener associated with this AST context, if any...
void gatherDefaultTypeArgs(SmallVectorImpl< QualType > &typeArgs) const
Gather the default set of type arguments to be substituted for these type parameters when dealing wit...
No particular method family.
const ObjCPropertyDecl * findPropertyDecl(bool CheckOverrides=true) const
Returns the property associated with this method's selector.
Represents a field declaration created by an @defs(...).
Defines the clang::SourceLocation class and associated facilities.
static bool isInstanceMethod(const Decl *D)
void setIvarInitializers(ASTContext &C, CXXCtorInitializer **initializers, unsigned numInitializers)
ObjCPropertyImplDecl * FindPropertyImplDecl(IdentifierInfo *propertyId, ObjCPropertyQueryKind queryKind) const
FindPropertyImplDecl - This method looks up a previous ObjCPropertyImplDecl added to the list of thos...
static ObjCImplementationDecl * CreateDeserialized(ASTContext &C, unsigned ID)
void setClassInterface(ObjCInterfaceDecl *IFace)
ObjCIvarDecl - Represents an ObjC instance variable.
QualType getSendResultType() const
Determine the type of an expression that sends a message to this function.
Stores a list of Objective-C type parameters for a parameterized class or a category/extension thereo...
StringRef getName() const
getName - Get the name of identifier for this declaration as a StringRef.
Kind
Lists the kind of concrete classes of Decl.
StringRef getName() const
getName - Get the name of identifier for the class interface associated with this implementation as a...
bool isArcWeakrefUnavailable() const
isArcWeakrefUnavailable - Checks for a class or one of its super classes to be incompatible with __we...
static Decl::Kind getKind(const Decl *D)
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.
ObjCMethodDecl * getMethod(Selector Sel, bool isInstance, bool AllowHidden=false) const
bool isRedeclaration() const
True if this is a method redeclaration in the same interface.
ObjCIvarDecl * all_declared_ivar_begin()
all_declared_ivar_begin - return first ivar declared in this class, its extensions and its implementa...
QualType getObjCObjectPointerType(QualType OIT) const
Return a ObjCObjectPointerType type for the given ObjCObjectType.
static ObjCCategoryImplDecl * Create(ASTContext &C, DeclContext *DC, IdentifierInfo *Id, ObjCInterfaceDecl *classInterface, SourceLocation nameLoc, SourceLocation atStartLoc, SourceLocation CategoryNameLoc)
ObjCMethodDecl * getInstanceMethod(Selector Sel, bool AllowHidden=false) const
static ObjCPropertyDecl * CreateDeserialized(ASTContext &C, unsigned ID)
void setHasDesignatedInitializers()
Indicate that this interface decl contains at least one initializer marked with the 'objc_designated_...
void collectPropertiesToImplement(PropertyMap &PM, PropertyDeclOrder &PO) const override
This routine collects list of properties to be implemented in the class.
const LangOptions & getLangOpts() const
ObjCCategoryImplDecl - An object of this class encapsulates a category @implementation declaration...
The parameter is invariant: must match exactly.
ObjCCompatibleAliasDecl - Represents alias of a class.
static void CollectOverriddenMethods(const ObjCContainerDecl *Container, const ObjCMethodDecl *Method, SmallVectorImpl< const ObjCMethodDecl *> &Methods)
ObjCCategoryDecl * FindCategoryDeclaration(IdentifierInfo *CategoryId) const
FindCategoryDeclaration - Finds category declaration in the list of categories for this class and ret...
SelectorLocationsKind hasStandardSelectorLocs(Selector Sel, ArrayRef< SourceLocation > SelLocs, ArrayRef< Expr *> Args, SourceLocation EndLoc)
Returns true if all SelLocs are in a "standard" location.