From b4a534559811ce82c3300fed9cafbd9d7dcf89d2 Mon Sep 17 00:00:00 2001 From: Aaron Ballman Date: Thu, 13 Mar 2014 21:57:01 +0000 Subject: [PATCH] [C++11] Replacing ObjCInterfaceDecl iterators known_extensions_begin() and known_extensions_end() with iterator_range known_extensions(). Updating all of the usages of the iterators with range-based for loops. llvm-svn: 203857 --- clang/include/clang/AST/DeclObjC.h | 7 +++++++ clang/lib/AST/ASTContext.cpp | 11 ++--------- clang/lib/AST/DeclObjC.cpp | 5 +---- clang/lib/Sema/SemaDecl.cpp | 5 +---- clang/lib/Sema/SemaObjCProperty.cpp | 11 +++-------- 5 files changed, 14 insertions(+), 25 deletions(-) diff --git a/clang/include/clang/AST/DeclObjC.h b/clang/include/clang/AST/DeclObjC.h index 9653ad2ca9f5..17b6dbf62ae5 100644 --- a/clang/include/clang/AST/DeclObjC.h +++ b/clang/include/clang/AST/DeclObjC.h @@ -1196,6 +1196,13 @@ public: /// \brief Iterator that walks over all of the known extensions. typedef filtered_category_iterator known_extensions_iterator; + typedef llvm::iterator_range + known_extensions_range; + + known_extensions_range known_extensions() const { + return known_extensions_range(known_extensions_begin(), + known_extensions_end()); + } /// \brief Retrieve an iterator to the beginning of the known-extensions /// list. diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp index 64cdda1c18be..2f8b8e66185f 100644 --- a/clang/lib/AST/ASTContext.cpp +++ b/clang/lib/AST/ASTContext.cpp @@ -387,10 +387,7 @@ static void addRedeclaredMethods(const ObjCMethodDecl *ObjCMethod, if (!ID) return; // Add redeclared method here. - for (ObjCInterfaceDecl::known_extensions_iterator - Ext = ID->known_extensions_begin(), - ExtEnd = ID->known_extensions_end(); - Ext != ExtEnd; ++Ext) { + for (const auto *Ext : ID->known_extensions()) { if (ObjCMethodDecl *RedeclaredMethod = Ext->getMethod(ObjCMethod->getSelector(), ObjCMethod->isInstanceMethod())) @@ -1854,12 +1851,8 @@ void ASTContext::CollectInheritedProtocols(const Decl *CDecl, unsigned ASTContext::CountNonClassIvars(const ObjCInterfaceDecl *OI) const { unsigned count = 0; // Count ivars declared in class extension. - for (ObjCInterfaceDecl::known_extensions_iterator - Ext = OI->known_extensions_begin(), - ExtEnd = OI->known_extensions_end(); - Ext != ExtEnd; ++Ext) { + for (const auto *Ext : OI->known_extensions()) count += Ext->ivar_size(); - } // Count ivar defined in this class's implementation. This // includes synthesized ivars. diff --git a/clang/lib/AST/DeclObjC.cpp b/clang/lib/AST/DeclObjC.cpp index 2fe7dac95c36..0844a222f8cb 100644 --- a/clang/lib/AST/DeclObjC.cpp +++ b/clang/lib/AST/DeclObjC.cpp @@ -1224,10 +1224,7 @@ ObjCIvarDecl *ObjCInterfaceDecl::all_declared_ivar_begin() { curIvar->setNextIvar(*I); } - for (ObjCInterfaceDecl::known_extensions_iterator - Ext = known_extensions_begin(), - ExtEnd = known_extensions_end(); - Ext != ExtEnd; ++Ext) { + for (const auto *Ext : known_extensions()) { if (!Ext->ivar_empty()) { ObjCCategoryDecl::ivar_iterator I = Ext->ivar_begin(), diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index 876b0785c1d6..5b1815fe2022 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -12249,10 +12249,7 @@ void Sema::ActOnFields(Scope *S, SourceLocation RecLoc, Decl *EnclosingDecl, Diag(ClsIvar->getLocation(), diag::note_previous_definition); continue; } - for (ObjCInterfaceDecl::known_extensions_iterator - Ext = IDecl->known_extensions_begin(), - ExtEnd = IDecl->known_extensions_end(); - Ext != ExtEnd; ++Ext) { + for (const auto *Ext : IDecl->known_extensions()) { if (const ObjCIvarDecl *ClsExtIvar = Ext->getIvarDecl(ClsFields[i]->getIdentifier())) { Diag(ClsFields[i]->getLocation(), diff --git a/clang/lib/Sema/SemaObjCProperty.cpp b/clang/lib/Sema/SemaObjCProperty.cpp index a10e3d83709f..4c2f889a438f 100644 --- a/clang/lib/Sema/SemaObjCProperty.cpp +++ b/clang/lib/Sema/SemaObjCProperty.cpp @@ -343,12 +343,9 @@ Sema::HandlePropertyInClassExtension(Scope *S, if (CCPrimary) { // Check for duplicate declaration of this property in current and // other class extensions. - for (ObjCInterfaceDecl::known_extensions_iterator - Ext = CCPrimary->known_extensions_begin(), - ExtEnd = CCPrimary->known_extensions_end(); - Ext != ExtEnd; ++Ext) { + for (const auto *Ext : CCPrimary->known_extensions()) { if (ObjCPropertyDecl *prevDecl - = ObjCPropertyDecl::findPropertyDecl(*Ext, PropertyId)) { + = ObjCPropertyDecl::findPropertyDecl(Ext, PropertyId)) { Diag(AtLoc, diag::err_duplicate_property); Diag(prevDecl->getLocation(), diag::note_property_declare); return 0; @@ -868,9 +865,7 @@ Decl *Sema::ActOnPropertyImplDecl(Scope *S, bool ReadWriteProperty = false; // Search into the class extensions and see if 'readonly property is // redeclared 'readwrite', then no warning is to be issued. - for (ObjCInterfaceDecl::known_extensions_iterator - Ext = IDecl->known_extensions_begin(), - ExtEnd = IDecl->known_extensions_end(); Ext != ExtEnd; ++Ext) { + for (auto *Ext : IDecl->known_extensions()) { DeclContext::lookup_result R = Ext->lookup(property->getDeclName()); if (!R.empty()) if (ObjCPropertyDecl *ExtProp = dyn_cast(R[0])) {