typedef filtered_decl_iterator<ObjCMethodDecl,
&ObjCMethodDecl::isClassMethod>
classmeth_iterator;
+ typedef llvm::iterator_range<classmeth_iterator> classmeth_range;
+
+ classmeth_range class_methods() const {
+ return classmeth_range(classmeth_begin(), classmeth_end());
+ }
classmeth_iterator classmeth_begin() const {
return classmeth_iterator(decls_begin());
}
SmallVector<llvm::Constant*, 16> ClassMethodTypes;
SmallVector<llvm::Constant*, 16> OptionalClassMethodNames;
SmallVector<llvm::Constant*, 16> OptionalClassMethodTypes;
- for (ObjCProtocolDecl::classmeth_iterator
- iter = PD->classmeth_begin(), endIter = PD->classmeth_end();
- iter != endIter ; iter++) {
+ for (const auto *I : PD->class_methods()) {
std::string TypeStr;
- Context.getObjCEncodingForMethodDecl((*iter),TypeStr);
- if ((*iter)->getImplementationControl() == ObjCMethodDecl::Optional) {
+ Context.getObjCEncodingForMethodDecl(I,TypeStr);
+ if (I->getImplementationControl() == ObjCMethodDecl::Optional) {
OptionalClassMethodNames.push_back(
- MakeConstantString((*iter)->getSelector().getAsString()));
+ MakeConstantString(I->getSelector().getAsString()));
OptionalClassMethodTypes.push_back(MakeConstantString(TypeStr));
} else {
ClassMethodNames.push_back(
- MakeConstantString((*iter)->getSelector().getAsString()));
+ MakeConstantString(I->getSelector().getAsString()));
ClassMethodTypes.push_back(MakeConstantString(TypeStr));
}
}
// Collect information about class methods
SmallVector<Selector, 16> ClassMethodSels;
SmallVector<llvm::Constant*, 16> ClassMethodTypes;
- for (ObjCCategoryImplDecl::classmeth_iterator
- iter = OCD->classmeth_begin(), endIter = OCD->classmeth_end();
- iter != endIter ; iter++) {
- ClassMethodSels.push_back((*iter)->getSelector());
+ for (const auto *I : OCD->class_methods()) {
+ ClassMethodSels.push_back(I->getSelector());
std::string TypeStr;
- CGM.getContext().getObjCEncodingForMethodDecl(*iter,TypeStr);
+ CGM.getContext().getObjCEncodingForMethodDecl(I,TypeStr);
ClassMethodTypes.push_back(MakeConstantString(TypeStr));
}
// Collect information about class methods
SmallVector<Selector, 16> ClassMethodSels;
SmallVector<llvm::Constant*, 16> ClassMethodTypes;
- for (ObjCImplementationDecl::classmeth_iterator
- iter = OID->classmeth_begin(), endIter = OID->classmeth_end();
- iter != endIter ; iter++) {
- ClassMethodSels.push_back((*iter)->getSelector());
+ for (const auto *I : OID->class_methods()) {
+ ClassMethodSels.push_back(I->getSelector());
std::string TypeStr;
- Context.getObjCEncodingForMethodDecl((*iter),TypeStr);
+ Context.getObjCEncodingForMethodDecl(I,TypeStr);
ClassMethodTypes.push_back(MakeConstantString(TypeStr));
}
// Collect the names of referenced protocols
}
}
- for (ObjCProtocolDecl::classmeth_iterator
- i = PD->classmeth_begin(), e = PD->classmeth_end(); i != e; ++i) {
- ObjCMethodDecl *MD = *i;
+ for (const auto *MD : PD->class_methods()) {
llvm::Constant *C = GetMethodDescriptionConstant(MD);
if (!C)
return GetOrEmitProtocolRef(PD);
// Instance methods should always be defined.
InstanceMethods.push_back(GetMethodConstant(I));
- for (ObjCCategoryImplDecl::classmeth_iterator
- i = OCD->classmeth_begin(), e = OCD->classmeth_end(); i != e; ++i) {
+ for (const auto *I : OCD->class_methods())
// Class methods should always be defined.
- ClassMethods.push_back(GetMethodConstant(*i));
- }
+ ClassMethods.push_back(GetMethodConstant(I));
llvm::Constant *Values[7];
Values[0] = GetClassName(OCD->getIdentifier());
// Instance methods should always be defined.
InstanceMethods.push_back(GetMethodConstant(I));
- for (ObjCImplementationDecl::classmeth_iterator
- i = ID->classmeth_begin(), e = ID->classmeth_end(); i != e; ++i) {
+ for (const auto *I : ID->class_methods())
// Class methods should always be defined.
- ClassMethods.push_back(GetMethodConstant(*i));
- }
+ ClassMethods.push_back(GetMethodConstant(I));
for (ObjCImplementationDecl::propimpl_iterator
i = ID->propimpl_begin(), e = ID->propimpl_end(); i != e; ++i) {
std::string MethodListName("\01l_OBJC_$_");
if (flags & NonFragileABI_Class_Meta) {
MethodListName += "CLASS_METHODS_" + ID->getNameAsString();
- for (ObjCImplementationDecl::classmeth_iterator
- i = ID->classmeth_begin(), e = ID->classmeth_end(); i != e; ++i) {
+ for (const auto *I : ID->class_methods())
// Class methods should always be defined.
- Methods.push_back(GetMethodConstant(*i));
- }
+ Methods.push_back(GetMethodConstant(I));
} else {
MethodListName += "INSTANCE_METHODS_" + ID->getNameAsString();
for (const auto *I : ID->instance_methods())
MethodListName += "CLASS_METHODS_" + Interface->getNameAsString() + "_$_" +
OCD->getNameAsString();
Methods.clear();
- for (ObjCCategoryImplDecl::classmeth_iterator
- i = OCD->classmeth_begin(), e = OCD->classmeth_end(); i != e; ++i) {
+ for (const auto *I : OCD->class_methods())
// Class methods should always be defined.
- Methods.push_back(GetMethodConstant(*i));
- }
+ Methods.push_back(GetMethodConstant(I));
Values[3] = EmitMethodList(MethodListName,
"__DATA, __objc_const",
}
}
- for (ObjCProtocolDecl::classmeth_iterator
- i = PD->classmeth_begin(), e = PD->classmeth_end(); i != e; ++i) {
- ObjCMethodDecl *MD = *i;
+ for (const auto *MD : PD->class_methods()) {
llvm::Constant *C = GetMethodDescriptionConstant(MD);
if (!C)
return GetOrEmitProtocolRef(PD);
for (auto *I : CatDecl->instance_methods())
RewriteMethodDeclaration(I);
- for (ObjCCategoryDecl::classmeth_iterator
- I = CatDecl->classmeth_begin(), E = CatDecl->classmeth_end();
- I != E; ++I)
- RewriteMethodDeclaration(*I);
+ for (auto *I : CatDecl->class_methods())
+ RewriteMethodDeclaration(I);
// Lastly, comment out the @end.
ReplaceText(CatDecl->getAtEndRange().getBegin(),
for (auto *I : PDecl->instance_methods())
RewriteMethodDeclaration(I);
- for (ObjCProtocolDecl::classmeth_iterator
- I = PDecl->classmeth_begin(), E = PDecl->classmeth_end();
- I != E; ++I)
- RewriteMethodDeclaration(*I);
-
+ for (auto *I : PDecl->class_methods())
+ RewriteMethodDeclaration(I);
for (auto *I : PDecl->properties())
RewriteProperty(I);
ReplaceText(LocStart, endBuf-startBuf, ResultStr);
}
- for (ObjCCategoryImplDecl::classmeth_iterator
- I = IMD ? IMD->classmeth_begin() : CID->classmeth_begin(),
- E = IMD ? IMD->classmeth_end() : CID->classmeth_end();
- I != E; ++I) {
+ for (auto *OMD : IMD ? IMD->class_methods() : CID->class_methods()) {
std::string ResultStr;
- ObjCMethodDecl *OMD = *I;
RewriteObjCMethodDecl(OMD->getClassInterface(), OMD, ResultStr);
SourceLocation LocStart = OMD->getLocStart();
SourceLocation LocEnd = OMD->getCompoundBody()->getLocStart();
RewriteProperty(I);
for (auto *I : ClassDecl->instance_methods())
RewriteMethodDeclaration(I);
- for (ObjCInterfaceDecl::classmeth_iterator
- I = ClassDecl->classmeth_begin(), E = ClassDecl->classmeth_end();
- I != E; ++I)
- RewriteMethodDeclaration(*I);
+ for (auto *I : ClassDecl->class_methods())
+ RewriteMethodDeclaration(I);
// Lastly, comment out the @end.
ReplaceText(ClassDecl->getAtEndRange().getBegin(), strlen("@end"),
}
}
- for (ObjCProtocolDecl::classmeth_iterator
- I = PDecl->classmeth_begin(), E = PDecl->classmeth_end();
- I != E; ++I) {
- ObjCMethodDecl *MD = *I;
+ for (auto *MD : PDecl->class_methods()) {
if (MD->getImplementationControl() == ObjCMethodDecl::Optional) {
OptClassMethods.push_back(MD);
} else {
"_OBJC_$_INSTANCE_METHODS_",
IDecl->getNameAsString(), true);
- SmallVector<ObjCMethodDecl *, 32>
- ClassMethods(IDecl->classmeth_begin(), IDecl->classmeth_end());
+ SmallVector<ObjCMethodDecl *, 32> ClassMethods(IDecl->class_methods());
Write_method_list_t_initializer(*this, Context, Result, ClassMethods,
"_OBJC_$_CLASS_METHODS_",
"_OBJC_$_CATEGORY_INSTANCE_METHODS_",
FullCategoryName, true);
- SmallVector<ObjCMethodDecl *, 32>
- ClassMethods(IDecl->classmeth_begin(), IDecl->classmeth_end());
+ SmallVector<ObjCMethodDecl *, 32> ClassMethods(IDecl->class_methods());
Write_method_list_t_initializer(*this, Context, Result, ClassMethods,
"_OBJC_$_CATEGORY_CLASS_METHODS_",
ReplaceText(LocStart, 0, "// ");
for (auto *I : CatDecl->properties())
- RewriteProperty(I);
-
+ RewriteProperty(I);
for (auto *I : CatDecl->instance_methods())
RewriteMethodDeclaration(I);
- for (ObjCCategoryDecl::classmeth_iterator
- I = CatDecl->classmeth_begin(), E = CatDecl->classmeth_end();
- I != E; ++I)
- RewriteMethodDeclaration(*I);
+ for (auto *I : CatDecl->class_methods())
+ RewriteMethodDeclaration(I);
// Lastly, comment out the @end.
ReplaceText(CatDecl->getAtEndRange().getBegin(),
for (auto *I : PDecl->instance_methods())
RewriteMethodDeclaration(I);
- for (ObjCProtocolDecl::classmeth_iterator
- I = PDecl->classmeth_begin(), E = PDecl->classmeth_end();
- I != E; ++I)
- RewriteMethodDeclaration(*I);
-
+ for (auto *I : PDecl->class_methods())
+ RewriteMethodDeclaration(I);
for (auto *I : PDecl->properties())
RewriteProperty(I);
ReplaceText(LocStart, endBuf-startBuf, ResultStr);
}
- for (ObjCCategoryImplDecl::classmeth_iterator
- I = IMD ? IMD->classmeth_begin() : CID->classmeth_begin(),
- E = IMD ? IMD->classmeth_end() : CID->classmeth_end();
- I != E; ++I) {
+ for (auto *OMD : IMD ? IMD->class_methods() : CID->class_methods()) {
std::string ResultStr;
- ObjCMethodDecl *OMD = *I;
RewriteObjCMethodDecl(OMD->getClassInterface(), OMD, ResultStr);
SourceLocation LocStart = OMD->getLocStart();
SourceLocation LocEnd = OMD->getCompoundBody()->getLocStart();
RewriteProperty(I);
for (auto *I : ClassDecl->instance_methods())
RewriteMethodDeclaration(I);
- for (ObjCInterfaceDecl::classmeth_iterator
- I = ClassDecl->classmeth_begin(), E = ClassDecl->classmeth_end();
- I != E; ++I)
- RewriteMethodDeclaration(*I);
+ for (auto *I : ClassDecl->class_methods())
+ RewriteMethodDeclaration(I);
// Lastly, comment out the @end.
ReplaceText(ClassDecl->getAtEndRange().getBegin(), strlen("@end"),
}
}
// check unimplemented class methods
- for (ObjCProtocolDecl::classmeth_iterator
- I = PDecl->classmeth_begin(), E = PDecl->classmeth_end();
- I != E; ++I) {
- ObjCMethodDecl *method = *I;
+ for (auto *method : PDecl->class_methods()) {
if (method->getImplementationControl() != ObjCMethodDecl::Optional &&
!ClsMap.count(method->getSelector()) &&
(!Super || !Super->lookupMethod(method->getSelector(),
// Check and see if class methods in class interface have been
// implemented in the implementation class. If so, their types match.
- for (ObjCInterfaceDecl::classmeth_iterator I = CDecl->classmeth_begin(),
- E = CDecl->classmeth_end();
- I != E; ++I) {
- if (!ClsMapSeen.insert((*I)->getSelector()))
+ for (auto *I : CDecl->class_methods()) {
+ if (!ClsMapSeen.insert(I->getSelector()))
continue;
- if (!ClsMap.count((*I)->getSelector())) {
+ if (!ClsMap.count(I->getSelector())) {
if (ImmediateClass)
- WarnUndefinedMethod(*this, IMPDecl->getLocation(), *I, IncompleteImpl,
+ WarnUndefinedMethod(*this, IMPDecl->getLocation(), I, IncompleteImpl,
diag::warn_undef_method_impl);
} else {
ObjCMethodDecl *ImpMethodDecl =
- IMPDecl->getClassMethod((*I)->getSelector());
- assert(CDecl->getClassMethod((*I)->getSelector()) &&
+ IMPDecl->getClassMethod(I->getSelector());
+ assert(CDecl->getClassMethod(I->getSelector()) &&
"Expected to find the method through lookup as well");
- ObjCMethodDecl *MethodDecl = *I;
if (!WarnCategoryMethodImpl)
- WarnConflictingTypedMethods(ImpMethodDecl, MethodDecl,
+ WarnConflictingTypedMethods(ImpMethodDecl, I,
isa<ObjCProtocolDecl>(CDecl));
else
- WarnExactTypedMethods(ImpMethodDecl, MethodDecl,
+ WarnExactTypedMethods(ImpMethodDecl, I,
isa<ObjCProtocolDecl>(CDecl));
}
}
InsMap.insert(Sel);
}
- for (ObjCImplementationDecl::classmeth_iterator
- I = CatIMPDecl->classmeth_begin(),
- E = CatIMPDecl->classmeth_end(); I != E; ++I) {
- Selector Sel = (*I)->getSelector();
+ for (const auto *I : CatIMPDecl->class_methods()) {
+ Selector Sel = I->getSelector();
if (SuperIDecl && SuperIDecl->lookupMethod(Sel, false))
continue;
ClsMap.insert(Sel);
}
SelectorSet ClsMap;
- for (ObjCImplementationDecl::classmeth_iterator
- I = IMPDecl->classmeth_begin(),
- E = IMPDecl->classmeth_end(); I != E; ++I)
- ClsMap.insert((*I)->getSelector());
+ for (const auto *I : IMPDecl->class_methods())
+ ClsMap.insert(I->getSelector());
// Check for type conflict of methods declared in a class/protocol and
// its implementation; if any.