From 9bc5f36099eb163fbd459fe3b0b8e761e0ec9d32 Mon Sep 17 00:00:00 2001 From: Aaron Ballman Date: Thu, 13 Mar 2014 17:35:02 +0000 Subject: [PATCH] [C++11] Replacing ObjCImplementationDecl iterators init_begin() and init_end() with iterator_range inits(). Updating all of the usages of the iterators with range-based for loops. llvm-svn: 203820 --- clang/include/clang/AST/DeclObjC.h | 8 ++++++++ clang/lib/CodeGen/CGObjC.cpp | 6 ++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/clang/include/clang/AST/DeclObjC.h b/clang/include/clang/AST/DeclObjC.h index 7e7e421d9a4d..41d86ffff542 100644 --- a/clang/include/clang/AST/DeclObjC.h +++ b/clang/include/clang/AST/DeclObjC.h @@ -1934,6 +1934,14 @@ public: /// init_const_iterator - Iterates through the ivar initializer list. typedef CXXCtorInitializer * const * init_const_iterator; + typedef llvm::iterator_range init_range; + typedef llvm::iterator_range init_const_range; + + init_range inits() { return init_range(init_begin(), init_end()); } + init_const_range inits() const { + return init_const_range(init_begin(), init_end()); + } + /// init_begin() - Retrieve an iterator to the first initializer. init_iterator init_begin() { return IvarInitializers; } /// begin() - Retrieve an iterator to the first initializer. diff --git a/clang/lib/CodeGen/CGObjC.cpp b/clang/lib/CodeGen/CGObjC.cpp index 5cc2ff3173fd..01ad1f22a2bc 100644 --- a/clang/lib/CodeGen/CGObjC.cpp +++ b/clang/lib/CodeGen/CGObjC.cpp @@ -1362,11 +1362,9 @@ void CodeGenFunction::GenerateObjCCtorDtorMethod(ObjCImplementationDecl *IMP, // Suppress the final autorelease in ARC. AutoreleaseResult = false; - for (ObjCImplementationDecl::init_const_iterator B = IMP->init_begin(), - E = IMP->init_end(); B != E; ++B) { - CXXCtorInitializer *IvarInit = (*B); + for (const auto *IvarInit : IMP->inits()) { FieldDecl *Field = IvarInit->getAnyMember(); - ObjCIvarDecl *Ivar = cast(Field); + ObjCIvarDecl *Ivar = cast(Field); LValue LV = EmitLValueForIvar(TypeOfSelfObject(), LoadObjCSelf(), Ivar, 0); EmitAggExpr(IvarInit->getInit(),