From: Aaron Ballman Date: Tue, 15 Jul 2014 22:03:49 +0000 (+0000) Subject: Switching some iterator-based for loops to use range-based for loops. No functional... X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=1e606f4d4689c63b6c851aa7d0bbcae781da4f6e;p=platform%2Fupstream%2Fllvm.git Switching some iterator-based for loops to use range-based for loops. No functional changes intended. llvm-svn: 213098 --- diff --git a/clang/lib/Sema/SemaLookup.cpp b/clang/lib/Sema/SemaLookup.cpp index be3cfd9..fe2c816 100644 --- a/clang/lib/Sema/SemaLookup.cpp +++ b/clang/lib/Sema/SemaLookup.cpp @@ -1767,9 +1767,7 @@ bool Sema::LookupQualifiedName(LookupResult &R, DeclContext *LookupCtx, // Lookup in a base class succeeded; return these results. - DeclContext::lookup_result DR = Paths.front().Decls; - for (DeclContext::lookup_iterator I = DR.begin(), E = DR.end(); I != E; ++I) { - NamedDecl *D = *I; + for (auto *D : Paths.front().Decls) { AccessSpecifier AS = CXXRecordDecl::MergeAccess(SubobjectAccess, D->getAccess()); R.addDecl(D, AS); @@ -1877,16 +1875,15 @@ void Sema::DiagnoseAmbiguousLookup(LookupResult &Result) { llvm::SmallPtrSet TagDecls; - LookupResult::iterator DI, DE = Result.end(); - for (DI = Result.begin(); DI != DE; ++DI) - if (TagDecl *TD = dyn_cast(*DI)) { + for (auto *D : Result) + if (TagDecl *TD = dyn_cast(D)) { TagDecls.insert(TD); Diag(TD->getLocation(), diag::note_hidden_tag); } - for (DI = Result.begin(); DI != DE; ++DI) - if (!isa(*DI)) - Diag((*DI)->getLocation(), diag::note_hiding_object); + for (auto *D : Result) + if (!isa(D)) + Diag(D->getLocation(), diag::note_hiding_object); // For recovery purposes, go ahead and implement the hiding. LookupResult::Filter F = Result.makeFilter(); @@ -1901,9 +1898,8 @@ void Sema::DiagnoseAmbiguousLookup(LookupResult &Result) { case LookupResult::AmbiguousReference: { Diag(NameLoc, diag::err_ambiguous_reference) << Name << LookupRange; - LookupResult::iterator DI = Result.begin(), DE = Result.end(); - for (; DI != DE; ++DI) - Diag((*DI)->getLocation(), diag::note_ambiguous_candidate) << *DI; + for (auto *D : Result) + Diag(D->getLocation(), diag::note_ambiguous_candidate) << D; break; } } @@ -2298,10 +2294,9 @@ void Sema::FindAssociatedClassesAndNamespaces( UnresolvedLookupExpr *ULE = dyn_cast(Arg); if (!ULE) continue; - for (UnresolvedSetIterator I = ULE->decls_begin(), E = ULE->decls_end(); - I != E; ++I) { + for (const auto *D : ULE->decls()) { // Look through any using declarations to find the underlying function. - FunctionDecl *FDecl = (*I)->getUnderlyingDecl()->getAsFunction(); + const FunctionDecl *FDecl = D->getUnderlyingDecl()->getAsFunction(); // Add the classes and namespaces associated with the parameter // types and return type of this function. @@ -2472,11 +2467,7 @@ Sema::SpecialMemberOverloadResult *Sema::LookupSpecialMember(CXXRecordDecl *RD, // from an external source and invalidate lookup_result. SmallVector Candidates(R.begin(), R.end()); - for (SmallVectorImpl::iterator I = Candidates.begin(), - E = Candidates.end(); - I != E; ++I) { - NamedDecl *Cand = *I; - + for (auto *Cand : Candidates) { if (Cand->isInvalidDecl()) continue; @@ -2804,9 +2795,7 @@ void Sema::ArgumentDependentLookup(DeclarationName Name, SourceLocation Loc, // // Here, we compute Y and add its members to the overloaded // candidate set. - for (AssociatedNamespaceSet::iterator NS = AssociatedNamespaces.begin(), - NSEnd = AssociatedNamespaces.end(); - NS != NSEnd; ++NS) { + for (auto *NS : AssociatedNamespaces) { // When considering an associated namespace, the lookup is the // same as the lookup performed when the associated namespace is // used as a qualifier (3.4.3.2) except that: @@ -2818,10 +2807,8 @@ void Sema::ArgumentDependentLookup(DeclarationName Name, SourceLocation Loc, // associated classes are visible within their respective // namespaces even if they are not visible during an ordinary // lookup (11.4). - DeclContext::lookup_result R = (*NS)->lookup(Name); - for (DeclContext::lookup_iterator I = R.begin(), E = R.end(); I != E; - ++I) { - NamedDecl *D = *I; + DeclContext::lookup_result R = NS->lookup(Name); + for (auto *D : R) { // If the only declaration here is an ordinary friend, consider // it only if it was declared in an associated classes. if ((D->getIdentifierNamespace() & Decl::IDNS_Ordinary) == 0) { @@ -2938,31 +2925,29 @@ NamedDecl *VisibleDeclsRecord::checkHidden(NamedDecl *ND) { if (Pos == SM->end()) continue; - for (ShadowMapEntry::iterator I = Pos->second.begin(), - IEnd = Pos->second.end(); - I != IEnd; ++I) { + for (auto *D : Pos->second) { // A tag declaration does not hide a non-tag declaration. - if ((*I)->hasTagIdentifierNamespace() && + if (D->hasTagIdentifierNamespace() && (IDNS & (Decl::IDNS_Member | Decl::IDNS_Ordinary | Decl::IDNS_ObjCProtocol))) continue; // Protocols are in distinct namespaces from everything else. - if ((((*I)->getIdentifierNamespace() & Decl::IDNS_ObjCProtocol) + if (((D->getIdentifierNamespace() & Decl::IDNS_ObjCProtocol) || (IDNS & Decl::IDNS_ObjCProtocol)) && - (*I)->getIdentifierNamespace() != IDNS) + D->getIdentifierNamespace() != IDNS) continue; // Functions and function templates in the same scope overload // rather than hide. FIXME: Look for hiding based on function // signatures! - if ((*I)->getUnderlyingDecl()->isFunctionOrFunctionTemplate() && + if (D->getUnderlyingDecl()->isFunctionOrFunctionTemplate() && ND->getUnderlyingDecl()->isFunctionOrFunctionTemplate() && SM == ShadowMaps.rbegin()) continue; // We've found a declaration that hides this one. - return *I; + return D; } } @@ -3787,10 +3772,8 @@ void TypoCorrectionConsumer::NamespaceSpecifierSet::sortNamespaces() { std::sort(sortedDistances.begin(), sortedDistances.end()); Specifiers.clear(); - for (SmallVectorImpl::iterator DI = sortedDistances.begin(), - DIEnd = sortedDistances.end(); - DI != DIEnd; ++DI) { - SpecifierInfoList &SpecList = DistanceMap[*DI]; + for (auto D : sortedDistances) { + SpecifierInfoList &SpecList = DistanceMap[D]; Specifiers.append(SpecList.begin(), SpecList.end()); } @@ -4302,10 +4285,8 @@ TypoCorrection Sema::CorrectTypo(const DeclarationNameInfo &TypoName, // For unqualified lookup, look through all of the names that we have // seen in this translation unit. // FIXME: Re-add the ability to skip very unlikely potential corrections. - for (IdentifierTable::iterator I = Context.Idents.begin(), - IEnd = Context.Idents.end(); - I != IEnd; ++I) - Consumer.FoundName(I->getKey()); + for (const auto &I : Context.Idents) + Consumer.FoundName(I.getKey()); // Walk through identifiers in external identifier sources. // FIXME: Re-add the ability to skip very unlikely potential corrections. @@ -4344,8 +4325,8 @@ TypoCorrection Sema::CorrectTypo(const DeclarationNameInfo &TypoName, SmallVector ExternalKnownNamespaces; LoadedExternalKnownNamespaces = true; ExternalSource->ReadKnownNamespaces(ExternalKnownNamespaces); - for (unsigned I = 0, N = ExternalKnownNamespaces.size(); I != N; ++I) - KnownNamespaces[ExternalKnownNamespaces[I]] = true; + for (auto *N : ExternalKnownNamespaces) + KnownNamespaces[N] = true; } Consumer.addNamespaces(KnownNamespaces); @@ -4488,11 +4469,9 @@ bool FunctionCallFilterCCC::ValidateCandidate(const TypoCorrection &candidate) { if (!candidate.getCorrectionDecl()) return candidate.isKeyword(); - for (TypoCorrection::const_decl_iterator DI = candidate.begin(), - DIEnd = candidate.end(); - DI != DIEnd; ++DI) { + for (auto *C : candidate) { FunctionDecl *FD = nullptr; - NamedDecl *ND = (*DI)->getUnderlyingDecl(); + NamedDecl *ND = C->getUnderlyingDecl(); if (FunctionTemplateDecl *FTD = dyn_cast(ND)) FD = FTD->getTemplatedDecl(); if (!HasExplicitTemplateArgs && !FD) {