From f26acce6f74658f8ab7ec3b0325363c228ffc5ae Mon Sep 17 00:00:00 2001 From: Aaron Ballman Date: Thu, 13 Mar 2014 19:50:17 +0000 Subject: [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 --- clang/lib/CodeGen/CGObjCGNU.cpp | 27 +++++++++++---------------- clang/lib/CodeGen/CGObjCMac.cpp | 35 +++++++++++++---------------------- 2 files changed, 24 insertions(+), 38 deletions(-) (limited to 'clang/lib/CodeGen') diff --git a/clang/lib/CodeGen/CGObjCGNU.cpp b/clang/lib/CodeGen/CGObjCGNU.cpp index a8481ed7a82..e55f6056417 100644 --- a/clang/lib/CodeGen/CGObjCGNU.cpp +++ b/clang/lib/CodeGen/CGObjCGNU.cpp @@ -1762,17 +1762,16 @@ void CGObjCGNU::GenerateProtocol(const ObjCProtocolDecl *PD) { SmallVector InstanceMethodTypes; SmallVector OptionalInstanceMethodNames; SmallVector 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 InstanceMethodSels; SmallVector 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 InstanceMethodSels; SmallVector 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)); } diff --git a/clang/lib/CodeGen/CGObjCMac.cpp b/clang/lib/CodeGen/CGObjCMac.cpp index 1ee74f90f28..d763c4af01e 100644 --- a/clang/lib/CodeGen/CGObjCMac.cpp +++ b/clang/lib/CodeGen/CGObjCMac.cpp @@ -2589,9 +2589,7 @@ llvm::Constant *CGObjCMac::GetOrEmitProtocol(const ObjCProtocolDecl *PD) { std::vector InstanceMethods, ClassMethods; std::vector OptInstanceMethods, OptClassMethods; std::vector 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 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 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 InstanceMethods, ClassMethods; std::vector OptInstanceMethods, OptClassMethods; std::vector 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); -- cgit v1.2.3