diff options
author | Aaron Ballman <aaron@aaronballman.com> | 2014-03-13 21:23:55 +0000 |
---|---|---|
committer | Aaron Ballman <aaron@aaronballman.com> | 2014-03-13 21:23:55 +0000 |
commit | 3fe486a332bc206f9415f9b54e4694115a69b0ab (patch) | |
tree | 1b321402c5a8c60b8aabf381723572a0b4775d75 /clang/lib | |
parent | 8a5c5a016cf07fa71dde21eb128256be7924f216 (diff) | |
download | bcm5719-llvm-3fe486a332bc206f9415f9b54e4694115a69b0ab.tar.gz bcm5719-llvm-3fe486a332bc206f9415f9b54e4694115a69b0ab.zip |
[C++11] Replacing ObjCInterfaceDecl iterators visible_categories_begin() and visible_categories_end() with iterator_range visible_categories(). Updating all of the usages of the iterators with range-based for loops.
llvm-svn: 203851
Diffstat (limited to 'clang/lib')
-rw-r--r-- | clang/lib/AST/ASTContext.cpp | 8 | ||||
-rw-r--r-- | clang/lib/AST/DeclObjC.cpp | 43 | ||||
-rw-r--r-- | clang/lib/Sema/SemaCodeComplete.cpp | 31 | ||||
-rw-r--r-- | clang/lib/Sema/SemaDeclObjC.cpp | 7 | ||||
-rw-r--r-- | clang/lib/Sema/SemaLookup.cpp | 7 | ||||
-rw-r--r-- | clang/lib/StaticAnalyzer/Checkers/ObjCUnusedIVarsChecker.cpp | 5 |
6 files changed, 25 insertions, 76 deletions
diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp index cded2e106d5..64cdda1c18b 100644 --- a/clang/lib/AST/ASTContext.cpp +++ b/clang/lib/AST/ASTContext.cpp @@ -1822,12 +1822,8 @@ void ASTContext::CollectInheritedProtocols(const Decl *CDecl, } // Categories of this Interface. - for (ObjCInterfaceDecl::visible_categories_iterator - Cat = OI->visible_categories_begin(), - CatEnd = OI->visible_categories_end(); - Cat != CatEnd; ++Cat) { - CollectInheritedProtocols(*Cat, Protocols); - } + for (const auto *Cat : OI->visible_categories()) + CollectInheritedProtocols(Cat, Protocols); if (ObjCInterfaceDecl *SD = OI->getSuperClass()) while (SD) { diff --git a/clang/lib/AST/DeclObjC.cpp b/clang/lib/AST/DeclObjC.cpp index 4b60a9eff10..fb337ba1d71 100644 --- a/clang/lib/AST/DeclObjC.cpp +++ b/clang/lib/AST/DeclObjC.cpp @@ -112,11 +112,7 @@ ObjCContainerDecl::HasUserDeclaredSetterMethod(const ObjCPropertyDecl *Property) if (const ObjCInterfaceDecl *ID = dyn_cast<ObjCInterfaceDecl>(this)) { // Also look into categories, including class extensions, looking // for a user declared instance method. - for (ObjCInterfaceDecl::visible_categories_iterator - Cat = ID->visible_categories_begin(), - CatEnd = ID->visible_categories_end(); - Cat != CatEnd; - ++Cat) { + for (const auto *Cat : ID->visible_categories()) { if (ObjCMethodDecl *MD = Cat->getInstanceMethod(Sel)) if (!MD->isImplicit()) return true; @@ -214,10 +210,7 @@ ObjCContainerDecl::FindPropertyDeclaration(IdentifierInfo *PropertyId) const { case Decl::ObjCInterface: { const ObjCInterfaceDecl *OID = cast<ObjCInterfaceDecl>(this); // Look through categories (but not extensions). - for (ObjCInterfaceDecl::visible_categories_iterator - Cat = OID->visible_categories_begin(), - CatEnd = OID->visible_categories_end(); - Cat != CatEnd; ++Cat) { + for (const auto *Cat : OID->visible_categories()) { if (!Cat->IsClassExtension()) if (ObjCPropertyDecl *P = Cat->FindPropertyDeclaration(PropertyId)) return P; @@ -545,12 +538,9 @@ ObjCMethodDecl *ObjCInterfaceDecl::lookupMethod(Selector Sel, return MethodDecl; // Didn't find one yet - now look through categories. - for (ObjCInterfaceDecl::visible_categories_iterator - Cat = ClassDecl->visible_categories_begin(), - CatEnd = ClassDecl->visible_categories_end(); - Cat != CatEnd; ++Cat) { + for (const auto *Cat : ClassDecl->visible_categories()) { if ((MethodDecl = Cat->getMethod(Sel, isInstance))) - if (C != (*Cat) || !MethodDecl->isImplicit()) + if (C != Cat || !MethodDecl->isImplicit()) return MethodDecl; if (!shallowCategoryLookup) { @@ -560,7 +550,7 @@ ObjCMethodDecl *ObjCInterfaceDecl::lookupMethod(Selector Sel, for (ObjCList<ObjCProtocolDecl>::iterator I = Protocols.begin(), E = Protocols.end(); I != E; ++I) if ((MethodDecl = (*I)->lookupMethod(Sel, isInstance))) - if (C != (*Cat) || !MethodDecl->isImplicit()) + if (C != Cat || !MethodDecl->isImplicit()) return MethodDecl; } } @@ -1313,23 +1303,16 @@ ObjCInterfaceDecl::FindCategoryDeclaration(IdentifierInfo *CategoryId) const { if (data().ExternallyCompleted) LoadExternalDefinition(); - for (visible_categories_iterator Cat = visible_categories_begin(), - CatEnd = visible_categories_end(); - Cat != CatEnd; - ++Cat) { + for (auto *Cat : visible_categories()) if (Cat->getIdentifier() == CategoryId) - return *Cat; - } + return Cat; return 0; } ObjCMethodDecl * ObjCInterfaceDecl::getCategoryInstanceMethod(Selector Sel) const { - for (visible_categories_iterator Cat = visible_categories_begin(), - CatEnd = visible_categories_end(); - Cat != CatEnd; - ++Cat) { + for (const auto *Cat : visible_categories()) { if (ObjCCategoryImplDecl *Impl = Cat->getImplementation()) if (ObjCMethodDecl *MD = Impl->getInstanceMethod(Sel)) return MD; @@ -1339,10 +1322,7 @@ ObjCInterfaceDecl::getCategoryInstanceMethod(Selector Sel) const { } ObjCMethodDecl *ObjCInterfaceDecl::getCategoryClassMethod(Selector Sel) const { - for (visible_categories_iterator Cat = visible_categories_begin(), - CatEnd = visible_categories_end(); - Cat != CatEnd; - ++Cat) { + for (const auto *Cat : visible_categories()) { if (ObjCCategoryImplDecl *Impl = Cat->getImplementation()) if (ObjCMethodDecl *MD = Impl->getClassMethod(Sel)) return MD; @@ -1378,10 +1358,7 @@ bool ObjCInterfaceDecl::ClassImplementsProtocol(ObjCProtocolDecl *lProto, // 2nd, look up the category. if (lookupCategory) - for (visible_categories_iterator Cat = visible_categories_begin(), - CatEnd = visible_categories_end(); - Cat != CatEnd; - ++Cat) { + for (const auto *Cat : visible_categories()) { for (ObjCCategoryDecl::protocol_iterator PI = Cat->protocol_begin(), E = Cat->protocol_end(); PI != E; ++PI) diff --git a/clang/lib/Sema/SemaCodeComplete.cpp b/clang/lib/Sema/SemaCodeComplete.cpp index 87a2b4cf0eb..a1adf1fc925 100644 --- a/clang/lib/Sema/SemaCodeComplete.cpp +++ b/clang/lib/Sema/SemaCodeComplete.cpp @@ -5863,12 +5863,8 @@ void Sema::CodeCompleteObjCInterfaceCategory(Scope *S, NamedDecl *CurClass = LookupSingleName(TUScope, ClassName, ClassNameLoc, LookupOrdinaryName); if (ObjCInterfaceDecl *Class = dyn_cast_or_null<ObjCInterfaceDecl>(CurClass)){ - for (ObjCInterfaceDecl::visible_categories_iterator - Cat = Class->visible_categories_begin(), - CatEnd = Class->visible_categories_end(); - Cat != CatEnd; ++Cat) { + for (const auto *Cat : Class->visible_categories()) CategoryNames.insert(Cat->getIdentifier()); - } } // Add all of the categories we know about. @@ -5911,13 +5907,10 @@ void Sema::CodeCompleteObjCImplementationCategory(Scope *S, Results.EnterNewScope(); bool IgnoreImplemented = true; while (Class) { - for (ObjCInterfaceDecl::visible_categories_iterator - Cat = Class->visible_categories_begin(), - CatEnd = Class->visible_categories_end(); - Cat != CatEnd; ++Cat) { + for (const auto *Cat : Class->visible_categories()) { if ((!IgnoreImplemented || !Cat->getImplementation()) && CategoryNames.insert(Cat->getIdentifier())) - Results.AddResult(Result(*Cat, Results.getBasePriority(*Cat), 0), + Results.AddResult(Result(Cat, Results.getBasePriority(Cat), 0), CurContext, 0, false); } @@ -6094,11 +6087,8 @@ static void FindImplementableMethods(ASTContext &Context, KnownMethods, InOriginalClass); // Add methods from any class extensions and categories. - for (ObjCInterfaceDecl::visible_categories_iterator - Cat = IFace->visible_categories_begin(), - CatEnd = IFace->visible_categories_end(); - Cat != CatEnd; ++Cat) { - FindImplementableMethods(Context, *Cat, WantInstanceMethods, ReturnType, + for (auto *Cat : IFace->visible_categories()) { + FindImplementableMethods(Context, Cat, WantInstanceMethods, ReturnType, KnownMethods, false); } @@ -6958,14 +6948,9 @@ void Sema::CodeCompleteObjCMethodDecl(Scope *S, if (ObjCCategoryDecl *Category = dyn_cast<ObjCCategoryDecl>(SearchDecl)) IFace = Category->getClassInterface(); - if (IFace) { - for (ObjCInterfaceDecl::visible_categories_iterator - Cat = IFace->visible_categories_begin(), - CatEnd = IFace->visible_categories_end(); - Cat != CatEnd; ++Cat) { - Containers.push_back(*Cat); - } - } + if (IFace) + for (auto *Cat : IFace->visible_categories()) + Containers.push_back(Cat); for (unsigned I = 0, N = Containers.size(); I != N; ++I) for (auto *P : Containers[I]->properties()) diff --git a/clang/lib/Sema/SemaDeclObjC.cpp b/clang/lib/Sema/SemaDeclObjC.cpp index d337a329591..b2709c547e7 100644 --- a/clang/lib/Sema/SemaDeclObjC.cpp +++ b/clang/lib/Sema/SemaDeclObjC.cpp @@ -1883,12 +1883,9 @@ void Sema::MatchAllMethodDeclarations(const SelectorSet &InsMap, // i.e. when WarnCategoryMethodImpl is false, check declarations in class // extension; as well as those in categories. if (!WarnCategoryMethodImpl) { - for (ObjCInterfaceDecl::visible_categories_iterator - Cat = I->visible_categories_begin(), - CatEnd = I->visible_categories_end(); - Cat != CatEnd; ++Cat) { + for (auto *Cat : I->visible_categories()) { MatchAllMethodDeclarations(InsMap, ClsMap, InsMapSeen, ClsMapSeen, - IMPDecl, *Cat, IncompleteImpl, false, + IMPDecl, Cat, IncompleteImpl, false, WarnCategoryMethodImpl); } } else { diff --git a/clang/lib/Sema/SemaLookup.cpp b/clang/lib/Sema/SemaLookup.cpp index d98b7f85052..4edf80954b4 100644 --- a/clang/lib/Sema/SemaLookup.cpp +++ b/clang/lib/Sema/SemaLookup.cpp @@ -3133,12 +3133,9 @@ static void LookupVisibleDecls(DeclContext *Ctx, LookupResult &Result, // Traverse the contexts of Objective-C classes. if (ObjCInterfaceDecl *IFace = dyn_cast<ObjCInterfaceDecl>(Ctx)) { // Traverse categories. - for (ObjCInterfaceDecl::visible_categories_iterator - Cat = IFace->visible_categories_begin(), - CatEnd = IFace->visible_categories_end(); - Cat != CatEnd; ++Cat) { + for (auto *Cat : IFace->visible_categories()) { ShadowContextRAII Shadow(Visited); - LookupVisibleDecls(*Cat, Result, QualifiedNameLookup, false, + LookupVisibleDecls(Cat, Result, QualifiedNameLookup, false, Consumer, Visited); } diff --git a/clang/lib/StaticAnalyzer/Checkers/ObjCUnusedIVarsChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/ObjCUnusedIVarsChecker.cpp index ebd2ed47b1a..ebfc03e0eb7 100644 --- a/clang/lib/StaticAnalyzer/Checkers/ObjCUnusedIVarsChecker.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/ObjCUnusedIVarsChecker.cpp @@ -88,10 +88,7 @@ static void Scan(IvarUsageMap& M, const ObjCContainerDecl *D) { Scan(M, *I); // Scan the associated categories as well. - for (ObjCInterfaceDecl::visible_categories_iterator - Cat = ID->getClassInterface()->visible_categories_begin(), - CatEnd = ID->getClassInterface()->visible_categories_end(); - Cat != CatEnd; ++Cat) { + for (const auto *Cat : ID->getClassInterface()->visible_categories()) { if (const ObjCCategoryImplDecl *CID = Cat->getImplementation()) Scan(M, CID); } |