forked from OSchip/llvm-project
[C++11] Replacing ObjCContainerDecl iterators instmeth_begin() and instmeth_end() with iterator_range instance_methods(). Updating all of the usages of the iterators with range-based for loops.
llvm-svn: 203839
This commit is contained in:
parent
514fc61c09
commit
f26acce6f7
|
@ -550,6 +550,11 @@ public:
|
|||
typedef filtered_decl_iterator<ObjCMethodDecl,
|
||||
&ObjCMethodDecl::isInstanceMethod>
|
||||
instmeth_iterator;
|
||||
typedef llvm::iterator_range<instmeth_iterator> instmeth_range;
|
||||
|
||||
instmeth_range instance_methods() const {
|
||||
return instmeth_range(instmeth_begin(), instmeth_end());
|
||||
}
|
||||
instmeth_iterator instmeth_begin() const {
|
||||
return instmeth_iterator(decls_begin());
|
||||
}
|
||||
|
|
|
@ -1585,9 +1585,7 @@ void ObjCMigrateASTConsumer::inferDesignatedInitializers(
|
|||
if (!Ctx.Idents.get("NS_DESIGNATED_INITIALIZER").hasMacroDefinition())
|
||||
return;
|
||||
|
||||
for (ObjCImplementationDecl::instmeth_iterator
|
||||
I = ImplD->instmeth_begin(), E = ImplD->instmeth_end(); I != E; ++I) {
|
||||
const ObjCMethodDecl *MD = *I;
|
||||
for (const auto *MD : ImplD->instance_methods()) {
|
||||
if (MD->isDeprecated() ||
|
||||
MD->getMethodFamily() != OMF_init ||
|
||||
MD->isDesignatedInitializerForTheInterface())
|
||||
|
|
|
@ -210,10 +210,7 @@ static void cleanupDeallocOrFinalize(MigrationPass &pass) {
|
|||
E = impl_iterator(DC->decls_end()); I != E; ++I) {
|
||||
ObjCMethodDecl *DeallocM = 0;
|
||||
ObjCMethodDecl *FinalizeM = 0;
|
||||
for (ObjCImplementationDecl::instmeth_iterator
|
||||
MI = I->instmeth_begin(),
|
||||
ME = I->instmeth_end(); MI != ME; ++MI) {
|
||||
ObjCMethodDecl *MD = *MI;
|
||||
for (auto *MD : I->instance_methods()) {
|
||||
if (!MD->hasBody())
|
||||
continue;
|
||||
|
||||
|
|
|
@ -538,15 +538,12 @@ static void GCRewriteFinalize(MigrationPass &pass) {
|
|||
impl_iterator;
|
||||
for (impl_iterator I = impl_iterator(DC->decls_begin()),
|
||||
E = impl_iterator(DC->decls_end()); I != E; ++I) {
|
||||
for (ObjCImplementationDecl::instmeth_iterator
|
||||
MI = I->instmeth_begin(),
|
||||
ME = I->instmeth_end(); MI != ME; ++MI) {
|
||||
ObjCMethodDecl *MD = *MI;
|
||||
for (const auto *MD : I->instance_methods()) {
|
||||
if (!MD->hasBody())
|
||||
continue;
|
||||
|
||||
if (MD->isInstanceMethod() && MD->getSelector() == FinalizeSel) {
|
||||
ObjCMethodDecl *FinalizeM = MD;
|
||||
const ObjCMethodDecl *FinalizeM = MD;
|
||||
Transaction Trans(TA);
|
||||
TA.insert(FinalizeM->getSourceRange().getBegin(),
|
||||
"#if !__has_feature(objc_arc)\n");
|
||||
|
|
|
@ -386,9 +386,7 @@ bool ObjCInterfaceDecl::inheritsDesignatedInitializers() const {
|
|||
return false;
|
||||
case DefinitionData::IDI_Unknown: {
|
||||
bool isIntroducingInitializers = false;
|
||||
for (instmeth_iterator I = instmeth_begin(),
|
||||
E = instmeth_end(); I != E; ++I) {
|
||||
const ObjCMethodDecl *MD = *I;
|
||||
for (const auto *MD : instance_methods()) {
|
||||
if (MD->getMethodFamily() == OMF_init && !MD->isOverriding()) {
|
||||
isIntroducingInitializers = true;
|
||||
break;
|
||||
|
@ -422,12 +420,9 @@ void ObjCInterfaceDecl::getDesignatedInitializers(
|
|||
if (!IFace)
|
||||
return;
|
||||
|
||||
for (instmeth_iterator I = IFace->instmeth_begin(),
|
||||
E = IFace->instmeth_end(); I != E; ++I) {
|
||||
const ObjCMethodDecl *MD = *I;
|
||||
for (const auto *MD : IFace->instance_methods())
|
||||
if (MD->isThisDeclarationADesignatedInitializer())
|
||||
Methods.push_back(MD);
|
||||
}
|
||||
}
|
||||
|
||||
bool ObjCInterfaceDecl::isDesignatedInitializer(Selector Sel,
|
||||
|
|
|
@ -1762,17 +1762,16 @@ void CGObjCGNU::GenerateProtocol(const ObjCProtocolDecl *PD) {
|
|||
SmallVector<llvm::Constant*, 16> InstanceMethodTypes;
|
||||
SmallVector<llvm::Constant*, 16> OptionalInstanceMethodNames;
|
||||
SmallVector<llvm::Constant*, 16> OptionalInstanceMethodTypes;
|
||||
for (ObjCProtocolDecl::instmeth_iterator iter = PD->instmeth_begin(),
|
||||
E = PD->instmeth_end(); iter != E; iter++) {
|
||||
for (const auto *I : PD->instance_methods()) {
|
||||
std::string TypeStr;
|
||||
Context.getObjCEncodingForMethodDecl(*iter, TypeStr);
|
||||
if ((*iter)->getImplementationControl() == ObjCMethodDecl::Optional) {
|
||||
Context.getObjCEncodingForMethodDecl(I, TypeStr);
|
||||
if (I->getImplementationControl() == ObjCMethodDecl::Optional) {
|
||||
OptionalInstanceMethodNames.push_back(
|
||||
MakeConstantString((*iter)->getSelector().getAsString()));
|
||||
MakeConstantString(I->getSelector().getAsString()));
|
||||
OptionalInstanceMethodTypes.push_back(MakeConstantString(TypeStr));
|
||||
} else {
|
||||
InstanceMethodNames.push_back(
|
||||
MakeConstantString((*iter)->getSelector().getAsString()));
|
||||
MakeConstantString(I->getSelector().getAsString()));
|
||||
InstanceMethodTypes.push_back(MakeConstantString(TypeStr));
|
||||
}
|
||||
}
|
||||
|
@ -2004,12 +2003,10 @@ void CGObjCGNU::GenerateCategory(const ObjCCategoryImplDecl *OCD) {
|
|||
// Collect information about instance methods
|
||||
SmallVector<Selector, 16> InstanceMethodSels;
|
||||
SmallVector<llvm::Constant*, 16> InstanceMethodTypes;
|
||||
for (ObjCCategoryImplDecl::instmeth_iterator
|
||||
iter = OCD->instmeth_begin(), endIter = OCD->instmeth_end();
|
||||
iter != endIter ; iter++) {
|
||||
InstanceMethodSels.push_back((*iter)->getSelector());
|
||||
for (const auto *I : OCD->instance_methods()) {
|
||||
InstanceMethodSels.push_back(I->getSelector());
|
||||
std::string TypeStr;
|
||||
CGM.getContext().getObjCEncodingForMethodDecl(*iter,TypeStr);
|
||||
CGM.getContext().getObjCEncodingForMethodDecl(I,TypeStr);
|
||||
InstanceMethodTypes.push_back(MakeConstantString(TypeStr));
|
||||
}
|
||||
|
||||
|
@ -2237,12 +2234,10 @@ void CGObjCGNU::GenerateClass(const ObjCImplementationDecl *OID) {
|
|||
// Collect information about instance methods
|
||||
SmallVector<Selector, 16> InstanceMethodSels;
|
||||
SmallVector<llvm::Constant*, 16> InstanceMethodTypes;
|
||||
for (ObjCImplementationDecl::instmeth_iterator
|
||||
iter = OID->instmeth_begin(), endIter = OID->instmeth_end();
|
||||
iter != endIter ; iter++) {
|
||||
InstanceMethodSels.push_back((*iter)->getSelector());
|
||||
for (const auto *I : OID->instance_methods()) {
|
||||
InstanceMethodSels.push_back(I->getSelector());
|
||||
std::string TypeStr;
|
||||
Context.getObjCEncodingForMethodDecl((*iter),TypeStr);
|
||||
Context.getObjCEncodingForMethodDecl(I,TypeStr);
|
||||
InstanceMethodTypes.push_back(MakeConstantString(TypeStr));
|
||||
}
|
||||
|
||||
|
|
|
@ -2589,9 +2589,7 @@ llvm::Constant *CGObjCMac::GetOrEmitProtocol(const ObjCProtocolDecl *PD) {
|
|||
std::vector<llvm::Constant*> InstanceMethods, ClassMethods;
|
||||
std::vector<llvm::Constant*> OptInstanceMethods, OptClassMethods;
|
||||
std::vector<llvm::Constant*> MethodTypesExt, OptMethodTypesExt;
|
||||
for (ObjCProtocolDecl::instmeth_iterator
|
||||
i = PD->instmeth_begin(), e = PD->instmeth_end(); i != e; ++i) {
|
||||
ObjCMethodDecl *MD = *i;
|
||||
for (const auto *MD : PD->instance_methods()) {
|
||||
llvm::Constant *C = GetMethodDescriptionConstant(MD);
|
||||
if (!C)
|
||||
return GetOrEmitProtocolRef(PD);
|
||||
|
@ -2939,11 +2937,10 @@ void CGObjCMac::GenerateCategory(const ObjCCategoryImplDecl *OCD) {
|
|||
<< OCD->getName();
|
||||
|
||||
SmallVector<llvm::Constant *, 16> InstanceMethods, ClassMethods;
|
||||
for (ObjCCategoryImplDecl::instmeth_iterator
|
||||
i = OCD->instmeth_begin(), e = OCD->instmeth_end(); i != e; ++i) {
|
||||
for (const auto *I : OCD->instance_methods())
|
||||
// Instance methods should always be defined.
|
||||
InstanceMethods.push_back(GetMethodConstant(*i));
|
||||
}
|
||||
InstanceMethods.push_back(GetMethodConstant(I));
|
||||
|
||||
for (ObjCCategoryImplDecl::classmeth_iterator
|
||||
i = OCD->classmeth_begin(), e = OCD->classmeth_end(); i != e; ++i) {
|
||||
// Class methods should always be defined.
|
||||
|
@ -3067,11 +3064,10 @@ void CGObjCMac::GenerateClass(const ObjCImplementationDecl *ID) {
|
|||
Flags |= FragileABI_Class_Hidden;
|
||||
|
||||
SmallVector<llvm::Constant *, 16> InstanceMethods, ClassMethods;
|
||||
for (ObjCImplementationDecl::instmeth_iterator
|
||||
i = ID->instmeth_begin(), e = ID->instmeth_end(); i != e; ++i) {
|
||||
for (const auto *I : ID->instance_methods())
|
||||
// Instance methods should always be defined.
|
||||
InstanceMethods.push_back(GetMethodConstant(*i));
|
||||
}
|
||||
InstanceMethods.push_back(GetMethodConstant(I));
|
||||
|
||||
for (ObjCImplementationDecl::classmeth_iterator
|
||||
i = ID->classmeth_begin(), e = ID->classmeth_end(); i != e; ++i) {
|
||||
// Class methods should always be defined.
|
||||
|
@ -5664,11 +5660,10 @@ llvm::GlobalVariable * CGObjCNonFragileABIMac::BuildClassRoTInitializer(
|
|||
}
|
||||
} else {
|
||||
MethodListName += "INSTANCE_METHODS_" + ID->getNameAsString();
|
||||
for (ObjCImplementationDecl::instmeth_iterator
|
||||
i = ID->instmeth_begin(), e = ID->instmeth_end(); i != e; ++i) {
|
||||
for (const auto *I : ID->instance_methods())
|
||||
// Instance methods should always be defined.
|
||||
Methods.push_back(GetMethodConstant(*i));
|
||||
}
|
||||
Methods.push_back(GetMethodConstant(I));
|
||||
|
||||
for (ObjCImplementationDecl::propimpl_iterator
|
||||
i = ID->propimpl_begin(), e = ID->propimpl_end(); i != e; ++i) {
|
||||
ObjCPropertyImplDecl *PID = *i;
|
||||
|
@ -5991,11 +5986,9 @@ void CGObjCNonFragileABIMac::GenerateCategory(const ObjCCategoryImplDecl *OCD) {
|
|||
MethodListName += "INSTANCE_METHODS_" + Interface->getNameAsString() +
|
||||
"_$_" + OCD->getNameAsString();
|
||||
|
||||
for (ObjCCategoryImplDecl::instmeth_iterator
|
||||
i = OCD->instmeth_begin(), e = OCD->instmeth_end(); i != e; ++i) {
|
||||
for (const auto *I : OCD->instance_methods())
|
||||
// Instance methods should always be defined.
|
||||
Methods.push_back(GetMethodConstant(*i));
|
||||
}
|
||||
Methods.push_back(GetMethodConstant(I));
|
||||
|
||||
Values[2] = EmitMethodList(MethodListName,
|
||||
"__DATA, __objc_const",
|
||||
|
@ -6282,9 +6275,7 @@ llvm::Constant *CGObjCNonFragileABIMac::GetOrEmitProtocol(
|
|||
std::vector<llvm::Constant*> InstanceMethods, ClassMethods;
|
||||
std::vector<llvm::Constant*> OptInstanceMethods, OptClassMethods;
|
||||
std::vector<llvm::Constant*> MethodTypesExt, OptMethodTypesExt;
|
||||
for (ObjCProtocolDecl::instmeth_iterator
|
||||
i = PD->instmeth_begin(), e = PD->instmeth_end(); i != e; ++i) {
|
||||
ObjCMethodDecl *MD = *i;
|
||||
for (const auto *MD : PD->instance_methods()) {
|
||||
llvm::Constant *C = GetMethodDescriptionConstant(MD);
|
||||
if (!C)
|
||||
return GetOrEmitProtocolRef(PD);
|
||||
|
|
|
@ -1163,10 +1163,8 @@ void RewriteModernObjC::RewriteCategoryDecl(ObjCCategoryDecl *CatDecl) {
|
|||
for (auto *I : CatDecl->properties())
|
||||
RewriteProperty(I);
|
||||
|
||||
for (ObjCCategoryDecl::instmeth_iterator
|
||||
I = CatDecl->instmeth_begin(), E = CatDecl->instmeth_end();
|
||||
I != E; ++I)
|
||||
RewriteMethodDeclaration(*I);
|
||||
for (auto *I : CatDecl->instance_methods())
|
||||
RewriteMethodDeclaration(I);
|
||||
for (ObjCCategoryDecl::classmeth_iterator
|
||||
I = CatDecl->classmeth_begin(), E = CatDecl->classmeth_end();
|
||||
I != E; ++I)
|
||||
|
@ -1184,10 +1182,8 @@ void RewriteModernObjC::RewriteProtocolDecl(ObjCProtocolDecl *PDecl) {
|
|||
// FIXME: handle protocol headers that are declared across multiple lines.
|
||||
ReplaceText(LocStart, 0, "// ");
|
||||
|
||||
for (ObjCProtocolDecl::instmeth_iterator
|
||||
I = PDecl->instmeth_begin(), E = PDecl->instmeth_end();
|
||||
I != E; ++I)
|
||||
RewriteMethodDeclaration(*I);
|
||||
for (auto *I : PDecl->instance_methods())
|
||||
RewriteMethodDeclaration(I);
|
||||
for (ObjCProtocolDecl::classmeth_iterator
|
||||
I = PDecl->classmeth_begin(), E = PDecl->classmeth_end();
|
||||
I != E; ++I)
|
||||
|
@ -1392,12 +1388,8 @@ void RewriteModernObjC::RewriteImplementationDecl(Decl *OID) {
|
|||
else
|
||||
InsertText(CID->getLocStart(), "// ");
|
||||
|
||||
for (ObjCCategoryImplDecl::instmeth_iterator
|
||||
I = IMD ? IMD->instmeth_begin() : CID->instmeth_begin(),
|
||||
E = IMD ? IMD->instmeth_end() : CID->instmeth_end();
|
||||
I != E; ++I) {
|
||||
for (auto *OMD : IMD ? IMD->instance_methods() : CID->instance_methods()) {
|
||||
std::string ResultStr;
|
||||
ObjCMethodDecl *OMD = *I;
|
||||
RewriteObjCMethodDecl(OMD->getClassInterface(), OMD, ResultStr);
|
||||
SourceLocation LocStart = OMD->getLocStart();
|
||||
SourceLocation LocEnd = OMD->getCompoundBody()->getLocStart();
|
||||
|
@ -1453,10 +1445,8 @@ void RewriteModernObjC::RewriteInterfaceDecl(ObjCInterfaceDecl *ClassDecl) {
|
|||
|
||||
for (auto *I : ClassDecl->properties())
|
||||
RewriteProperty(I);
|
||||
for (ObjCInterfaceDecl::instmeth_iterator
|
||||
I = ClassDecl->instmeth_begin(), E = ClassDecl->instmeth_end();
|
||||
I != E; ++I)
|
||||
RewriteMethodDeclaration(*I);
|
||||
for (auto *I : ClassDecl->instance_methods())
|
||||
RewriteMethodDeclaration(I);
|
||||
for (ObjCInterfaceDecl::classmeth_iterator
|
||||
I = ClassDecl->classmeth_begin(), E = ClassDecl->classmeth_end();
|
||||
I != E; ++I)
|
||||
|
@ -7024,10 +7014,7 @@ void RewriteModernObjC::RewriteObjCProtocolMetaData(ObjCProtocolDecl *PDecl,
|
|||
// Construct method lists.
|
||||
std::vector<ObjCMethodDecl *> InstanceMethods, ClassMethods;
|
||||
std::vector<ObjCMethodDecl *> OptInstanceMethods, OptClassMethods;
|
||||
for (ObjCProtocolDecl::instmeth_iterator
|
||||
I = PDecl->instmeth_begin(), E = PDecl->instmeth_end();
|
||||
I != E; ++I) {
|
||||
ObjCMethodDecl *MD = *I;
|
||||
for (auto *MD : PDecl->instance_methods()) {
|
||||
if (MD->getImplementationControl() == ObjCMethodDecl::Optional) {
|
||||
OptInstanceMethods.push_back(MD);
|
||||
} else {
|
||||
|
@ -7248,8 +7235,7 @@ void RewriteModernObjC::RewriteObjCClassMetaData(ObjCImplementationDecl *IDecl,
|
|||
CDecl);
|
||||
|
||||
// Build _objc_method_list for class's instance methods if needed
|
||||
SmallVector<ObjCMethodDecl *, 32>
|
||||
InstanceMethods(IDecl->instmeth_begin(), IDecl->instmeth_end());
|
||||
SmallVector<ObjCMethodDecl *, 32> InstanceMethods(IDecl->instance_methods());
|
||||
|
||||
// If any of our property implementations have associated getters or
|
||||
// setters, produce metadata for them as well.
|
||||
|
@ -7505,8 +7491,7 @@ void RewriteModernObjC::RewriteObjCCategoryImplDecl(ObjCCategoryImplDecl *IDecl,
|
|||
FullCategoryName += CDecl->getNameAsString();
|
||||
|
||||
// Build _objc_method_list for class's instance methods if needed
|
||||
SmallVector<ObjCMethodDecl *, 32>
|
||||
InstanceMethods(IDecl->instmeth_begin(), IDecl->instmeth_end());
|
||||
SmallVector<ObjCMethodDecl *, 32> InstanceMethods(IDecl->instance_methods());
|
||||
|
||||
// If any of our property implementations have associated getters or
|
||||
// setters, produce metadata for them as well.
|
||||
|
|
|
@ -983,10 +983,8 @@ void RewriteObjC::RewriteCategoryDecl(ObjCCategoryDecl *CatDecl) {
|
|||
for (auto *I : CatDecl->properties())
|
||||
RewriteProperty(I);
|
||||
|
||||
for (ObjCCategoryDecl::instmeth_iterator
|
||||
I = CatDecl->instmeth_begin(), E = CatDecl->instmeth_end();
|
||||
I != E; ++I)
|
||||
RewriteMethodDeclaration(*I);
|
||||
for (auto *I : CatDecl->instance_methods())
|
||||
RewriteMethodDeclaration(I);
|
||||
for (ObjCCategoryDecl::classmeth_iterator
|
||||
I = CatDecl->classmeth_begin(), E = CatDecl->classmeth_end();
|
||||
I != E; ++I)
|
||||
|
@ -1004,10 +1002,8 @@ void RewriteObjC::RewriteProtocolDecl(ObjCProtocolDecl *PDecl) {
|
|||
// FIXME: handle protocol headers that are declared across multiple lines.
|
||||
ReplaceText(LocStart, 0, "// ");
|
||||
|
||||
for (ObjCProtocolDecl::instmeth_iterator
|
||||
I = PDecl->instmeth_begin(), E = PDecl->instmeth_end();
|
||||
I != E; ++I)
|
||||
RewriteMethodDeclaration(*I);
|
||||
for (auto *I : PDecl->instance_methods())
|
||||
RewriteMethodDeclaration(I);
|
||||
for (ObjCProtocolDecl::classmeth_iterator
|
||||
I = PDecl->classmeth_begin(), E = PDecl->classmeth_end();
|
||||
I != E; ++I)
|
||||
|
@ -1186,12 +1182,8 @@ void RewriteObjC::RewriteImplementationDecl(Decl *OID) {
|
|||
|
||||
InsertText(IMD ? IMD->getLocStart() : CID->getLocStart(), "// ");
|
||||
|
||||
for (ObjCCategoryImplDecl::instmeth_iterator
|
||||
I = IMD ? IMD->instmeth_begin() : CID->instmeth_begin(),
|
||||
E = IMD ? IMD->instmeth_end() : CID->instmeth_end();
|
||||
I != E; ++I) {
|
||||
for (auto *OMD : IMD ? IMD->instance_methods() : CID->instance_methods()) {
|
||||
std::string ResultStr;
|
||||
ObjCMethodDecl *OMD = *I;
|
||||
RewriteObjCMethodDecl(OMD->getClassInterface(), OMD, ResultStr);
|
||||
SourceLocation LocStart = OMD->getLocStart();
|
||||
SourceLocation LocEnd = OMD->getCompoundBody()->getLocStart();
|
||||
|
@ -1245,10 +1237,8 @@ void RewriteObjC::RewriteInterfaceDecl(ObjCInterfaceDecl *ClassDecl) {
|
|||
|
||||
for (auto *I : ClassDecl->properties())
|
||||
RewriteProperty(I);
|
||||
for (ObjCInterfaceDecl::instmeth_iterator
|
||||
I = ClassDecl->instmeth_begin(), E = ClassDecl->instmeth_end();
|
||||
I != E; ++I)
|
||||
RewriteMethodDeclaration(*I);
|
||||
for (auto *I : ClassDecl->instance_methods())
|
||||
RewriteMethodDeclaration(I);
|
||||
for (ObjCInterfaceDecl::classmeth_iterator
|
||||
I = ClassDecl->classmeth_begin(), E = ClassDecl->classmeth_end();
|
||||
I != E; ++I)
|
||||
|
@ -5447,8 +5437,7 @@ void RewriteObjCFragileABI::RewriteObjCClassMetaData(ObjCImplementationDecl *IDe
|
|||
}
|
||||
|
||||
// Build _objc_method_list for class's instance methods if needed
|
||||
SmallVector<ObjCMethodDecl *, 32>
|
||||
InstanceMethods(IDecl->instmeth_begin(), IDecl->instmeth_end());
|
||||
SmallVector<ObjCMethodDecl *, 32> InstanceMethods(IDecl->instance_methods());
|
||||
|
||||
// If any of our property implementations have associated getters or
|
||||
// setters, produce metadata for them as well.
|
||||
|
@ -5729,8 +5718,7 @@ void RewriteObjCFragileABI::RewriteObjCCategoryImplDecl(ObjCCategoryImplDecl *ID
|
|||
FullCategoryName += IDecl->getNameAsString();
|
||||
|
||||
// Build _objc_method_list for class's instance methods if needed
|
||||
SmallVector<ObjCMethodDecl *, 32>
|
||||
InstanceMethods(IDecl->instmeth_begin(), IDecl->instmeth_end());
|
||||
SmallVector<ObjCMethodDecl *, 32> InstanceMethods(IDecl->instance_methods());
|
||||
|
||||
// If any of our property implementations have associated getters or
|
||||
// setters, produce metadata for them as well.
|
||||
|
|
|
@ -1746,9 +1746,7 @@ static void CheckProtocolMethodDefs(Sema &S,
|
|||
|
||||
// check unimplemented instance methods.
|
||||
if (!NSIDecl)
|
||||
for (ObjCProtocolDecl::instmeth_iterator I = PDecl->instmeth_begin(),
|
||||
E = PDecl->instmeth_end(); I != E; ++I) {
|
||||
ObjCMethodDecl *method = *I;
|
||||
for (auto *method : PDecl->instance_methods()) {
|
||||
if (method->getImplementationControl() != ObjCMethodDecl::Optional &&
|
||||
!method->isPropertyAccessor() &&
|
||||
!InsMap.count(method->getSelector()) &&
|
||||
|
@ -1828,30 +1826,27 @@ void Sema::MatchAllMethodDeclarations(const SelectorSet &InsMap,
|
|||
bool WarnCategoryMethodImpl) {
|
||||
// Check and see if instance methods in class interface have been
|
||||
// implemented in the implementation class. If so, their types match.
|
||||
for (ObjCInterfaceDecl::instmeth_iterator I = CDecl->instmeth_begin(),
|
||||
E = CDecl->instmeth_end(); I != E; ++I) {
|
||||
if (!InsMapSeen.insert((*I)->getSelector()))
|
||||
for (auto *I : CDecl->instance_methods()) {
|
||||
if (!InsMapSeen.insert(I->getSelector()))
|
||||
continue;
|
||||
if (!(*I)->isPropertyAccessor() &&
|
||||
!InsMap.count((*I)->getSelector())) {
|
||||
if (!I->isPropertyAccessor() &&
|
||||
!InsMap.count(I->getSelector())) {
|
||||
if (ImmediateClass)
|
||||
WarnUndefinedMethod(*this, IMPDecl->getLocation(), *I, IncompleteImpl,
|
||||
WarnUndefinedMethod(*this, IMPDecl->getLocation(), I, IncompleteImpl,
|
||||
diag::warn_undef_method_impl);
|
||||
continue;
|
||||
} else {
|
||||
ObjCMethodDecl *ImpMethodDecl =
|
||||
IMPDecl->getInstanceMethod((*I)->getSelector());
|
||||
assert(CDecl->getInstanceMethod((*I)->getSelector()) &&
|
||||
IMPDecl->getInstanceMethod(I->getSelector());
|
||||
assert(CDecl->getInstanceMethod(I->getSelector()) &&
|
||||
"Expected to find the method through lookup as well");
|
||||
ObjCMethodDecl *MethodDecl = *I;
|
||||
// ImpMethodDecl may be null as in a @dynamic property.
|
||||
if (ImpMethodDecl) {
|
||||
if (!WarnCategoryMethodImpl)
|
||||
WarnConflictingTypedMethods(ImpMethodDecl, MethodDecl,
|
||||
WarnConflictingTypedMethods(ImpMethodDecl, I,
|
||||
isa<ObjCProtocolDecl>(CDecl));
|
||||
else if (!MethodDecl->isPropertyAccessor())
|
||||
WarnExactTypedMethods(ImpMethodDecl, MethodDecl,
|
||||
isa<ObjCProtocolDecl>(CDecl));
|
||||
else if (!I->isPropertyAccessor())
|
||||
WarnExactTypedMethods(ImpMethodDecl, I, isa<ObjCProtocolDecl>(CDecl));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1950,10 +1945,8 @@ void Sema::CheckCategoryVsClassMethodMatches(
|
|||
ObjCInterfaceDecl *SuperIDecl = IDecl->getSuperClass();
|
||||
SelectorSet InsMap, ClsMap;
|
||||
|
||||
for (ObjCImplementationDecl::instmeth_iterator
|
||||
I = CatIMPDecl->instmeth_begin(),
|
||||
E = CatIMPDecl->instmeth_end(); I!=E; ++I) {
|
||||
Selector Sel = (*I)->getSelector();
|
||||
for (const auto *I : CatIMPDecl->instance_methods()) {
|
||||
Selector Sel = I->getSelector();
|
||||
// When checking for methods implemented in the category, skip over
|
||||
// those declared in category class's super class. This is because
|
||||
// the super class must implement the method.
|
||||
|
@ -1987,9 +1980,8 @@ void Sema::ImplMethodsVsClassMethods(Scope *S, ObjCImplDecl* IMPDecl,
|
|||
SelectorSet InsMap;
|
||||
// Check and see if instance methods in class interface have been
|
||||
// implemented in the implementation class.
|
||||
for (ObjCImplementationDecl::instmeth_iterator
|
||||
I = IMPDecl->instmeth_begin(), E = IMPDecl->instmeth_end(); I!=E; ++I)
|
||||
InsMap.insert((*I)->getSelector());
|
||||
for (const auto *I : IMPDecl->instance_methods())
|
||||
InsMap.insert(I->getSelector());
|
||||
|
||||
// Check and see if properties declared in the interface have either 1)
|
||||
// an implementation or 2) there is a @synthesize/@dynamic implementation
|
||||
|
@ -3572,10 +3564,7 @@ void Sema::DiagnoseUnusedBackingIvarInAccessor(Scope *S,
|
|||
if (S->hasUnrecoverableErrorOccurred())
|
||||
return;
|
||||
|
||||
for (ObjCImplementationDecl::instmeth_iterator
|
||||
MI = ImplD->instmeth_begin(),
|
||||
ME = ImplD->instmeth_end(); MI != ME; ++MI) {
|
||||
const ObjCMethodDecl *CurMethod = *MI;
|
||||
for (const auto *CurMethod : ImplD->instance_methods()) {
|
||||
unsigned DIAG = diag::warn_unused_property_backing_ivar;
|
||||
SourceLocation Loc = CurMethod->getLocation();
|
||||
if (Diags.getDiagnosticLevel(DIAG, Loc) == DiagnosticsEngine::Ignored)
|
||||
|
|
|
@ -1742,9 +1742,8 @@ void Sema::DiagnoseUnimplementedProperties(Scope *S, ObjCImplDecl* IMPDecl,
|
|||
|
||||
SelectorSet InsMap;
|
||||
// Collect property accessors implemented in current implementation.
|
||||
for (ObjCImplementationDecl::instmeth_iterator
|
||||
I = IMPDecl->instmeth_begin(), E = IMPDecl->instmeth_end(); I!=E; ++I)
|
||||
InsMap.insert((*I)->getSelector());
|
||||
for (const auto *I : IMPDecl->instance_methods())
|
||||
InsMap.insert(I->getSelector());
|
||||
|
||||
ObjCCategoryDecl *C = dyn_cast<ObjCCategoryDecl>(CDecl);
|
||||
ObjCInterfaceDecl *PrimaryClass = 0;
|
||||
|
@ -1755,9 +1754,8 @@ void Sema::DiagnoseUnimplementedProperties(Scope *S, ObjCImplDecl* IMPDecl,
|
|||
// When reporting on missing setter/getters, do not report when
|
||||
// setter/getter is implemented in category's primary class
|
||||
// implementation.
|
||||
for (ObjCImplementationDecl::instmeth_iterator
|
||||
I = IMP->instmeth_begin(), E = IMP->instmeth_end(); I!=E; ++I)
|
||||
InsMap.insert((*I)->getSelector());
|
||||
for (const auto *I : IMP->instance_methods())
|
||||
InsMap.insert(I->getSelector());
|
||||
}
|
||||
|
||||
for (ObjCContainerDecl::PropertyMap::iterator
|
||||
|
@ -1900,10 +1898,9 @@ void Sema::DiagnoseMissingDesignatedInitOverrides(
|
|||
return;
|
||||
|
||||
SelectorSet InitSelSet;
|
||||
for (ObjCImplementationDecl::instmeth_iterator
|
||||
I = ImplD->instmeth_begin(), E = ImplD->instmeth_end(); I!=E; ++I)
|
||||
if ((*I)->getMethodFamily() == OMF_init)
|
||||
InitSelSet.insert((*I)->getSelector());
|
||||
for (const auto *I : ImplD->instance_methods())
|
||||
if (I->getMethodFamily() == OMF_init)
|
||||
InitSelSet.insert(I->getSelector());
|
||||
|
||||
SmallVector<const ObjCMethodDecl *, 8> DesignatedInits;
|
||||
SuperD->getDesignatedInitializers(DesignatedInits);
|
||||
|
|
|
@ -156,14 +156,12 @@ static void checkObjCDealloc(const CheckerBase *Checker,
|
|||
// Get the "dealloc" selector.
|
||||
IdentifierInfo* II = &Ctx.Idents.get("dealloc");
|
||||
Selector S = Ctx.Selectors.getSelector(0, &II);
|
||||
ObjCMethodDecl *MD = 0;
|
||||
const ObjCMethodDecl *MD = 0;
|
||||
|
||||
// Scan the instance methods for "dealloc".
|
||||
for (ObjCImplementationDecl::instmeth_iterator I = D->instmeth_begin(),
|
||||
E = D->instmeth_end(); I!=E; ++I) {
|
||||
|
||||
if ((*I)->getSelector() == S) {
|
||||
MD = *I;
|
||||
for (const auto *I : D->instance_methods()) {
|
||||
if (I->getSelector() == S) {
|
||||
MD = I;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -93,10 +93,7 @@ static void CheckObjCInstMethSignature(const ObjCImplementationDecl *ID,
|
|||
MapTy IMeths;
|
||||
unsigned NumMethods = 0;
|
||||
|
||||
for (ObjCImplementationDecl::instmeth_iterator I=ID->instmeth_begin(),
|
||||
E=ID->instmeth_end(); I!=E; ++I) {
|
||||
|
||||
ObjCMethodDecl *M = *I;
|
||||
for (auto *M : ID->instance_methods()) {
|
||||
IMeths[M->getSelector()] = M;
|
||||
++NumMethods;
|
||||
}
|
||||
|
@ -104,10 +101,7 @@ static void CheckObjCInstMethSignature(const ObjCImplementationDecl *ID,
|
|||
// Now recurse the class hierarchy chain looking for methods with the
|
||||
// same signatures.
|
||||
while (C && NumMethods) {
|
||||
for (ObjCInterfaceDecl::instmeth_iterator I=C->instmeth_begin(),
|
||||
E=C->instmeth_end(); I!=E; ++I) {
|
||||
|
||||
ObjCMethodDecl *M = *I;
|
||||
for (const auto *M : C->instance_methods()) {
|
||||
Selector S = M->getSelector();
|
||||
|
||||
MapTy::iterator MI = IMeths.find(S);
|
||||
|
|
|
@ -139,10 +139,7 @@ void DirectIvarAssignment::checkASTDecl(const ObjCImplementationDecl *D,
|
|||
if (IvarToPropMap.empty())
|
||||
return;
|
||||
|
||||
for (ObjCImplementationDecl::instmeth_iterator I = D->instmeth_begin(),
|
||||
E = D->instmeth_end(); I != E; ++I) {
|
||||
|
||||
ObjCMethodDecl *M = *I;
|
||||
for (const auto *M : D->instance_methods()) {
|
||||
AnalysisDeclContext *DCtx = Mgr.getAnalysisDeclContext(M);
|
||||
|
||||
if ((*ShouldSkipMethod)(M))
|
||||
|
|
|
@ -181,16 +181,12 @@ void ObjCSuperCallChecker::checkASTDecl(const ObjCImplementationDecl *D,
|
|||
|
||||
|
||||
// Iterate over all instance methods.
|
||||
for (ObjCImplementationDecl::instmeth_iterator I = D->instmeth_begin(),
|
||||
E = D->instmeth_end();
|
||||
I != E; ++I) {
|
||||
Selector S = (*I)->getSelector();
|
||||
for (auto *MD : D->instance_methods()) {
|
||||
Selector S = MD->getSelector();
|
||||
// Find out whether this is a selector that we want to check.
|
||||
if (!SelectorsForClass[SuperclassName].count(S))
|
||||
continue;
|
||||
|
||||
ObjCMethodDecl *MD = *I;
|
||||
|
||||
// Check if the method calls its superclass implementation.
|
||||
if (MD->getBody())
|
||||
{
|
||||
|
|
|
@ -77,9 +77,8 @@ static void Scan(IvarUsageMap& M, const ObjCPropertyImplDecl *D) {
|
|||
|
||||
static void Scan(IvarUsageMap& M, const ObjCContainerDecl *D) {
|
||||
// Scan the methods for accesses.
|
||||
for (ObjCContainerDecl::instmeth_iterator I = D->instmeth_begin(),
|
||||
E = D->instmeth_end(); I!=E; ++I)
|
||||
Scan(M, (*I)->getBody());
|
||||
for (const auto *I : D->instance_methods())
|
||||
Scan(M, I->getBody());
|
||||
|
||||
if (const ObjCImplementationDecl *ID = dyn_cast<ObjCImplementationDecl>(D)) {
|
||||
// Scan for @synthesized property methods that act as setters/getters
|
||||
|
|
Loading…
Reference in New Issue