From: Aaron Ballman Date: Fri, 7 Mar 2014 13:44:44 +0000 (+0000) Subject: [C++11] Updating getUsingDirectives to use iterator_range instead of a std::pair. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=0d72b7c6e6050d1f13f605793c39607d5220a8bd;p=clang [C++11] Updating getUsingDirectives to use iterator_range instead of a std::pair. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@203239 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/AST/DeclBase.h b/include/clang/AST/DeclBase.h index d281f19df8..8be3b8c81a 100644 --- a/include/clang/AST/DeclBase.h +++ b/include/clang/AST/DeclBase.h @@ -1575,16 +1575,16 @@ public: /// within this context. typedef UsingDirectiveDecl * const * udir_iterator; - typedef std::pair udir_iterator_range; + typedef llvm::iterator_range udir_range; - udir_iterator_range getUsingDirectives() const; + udir_range getUsingDirectives() const; udir_iterator using_directives_begin() const { - return getUsingDirectives().first; + return getUsingDirectives().begin(); } udir_iterator using_directives_end() const { - return getUsingDirectives().second; + return getUsingDirectives().end(); } // These are all defined in DependentDiagnostic.h. diff --git a/lib/AST/DeclBase.cpp b/lib/AST/DeclBase.cpp index 00692df46c..2c4df11475 100644 --- a/lib/AST/DeclBase.cpp +++ b/lib/AST/DeclBase.cpp @@ -1528,12 +1528,12 @@ void DeclContext::makeDeclVisibleInContextImpl(NamedDecl *D, bool Internal) { /// Returns iterator range [First, Last) of UsingDirectiveDecls stored within /// this context. -DeclContext::udir_iterator_range +DeclContext::udir_range DeclContext::getUsingDirectives() const { // FIXME: Use something more efficient than normal lookup for using // directives. In C++, using directives are looked up more than anything else. lookup_const_result Result = lookup(UsingDirectiveDecl::getName()); - return udir_iterator_range(reinterpret_cast(Result.begin()), + return udir_range(reinterpret_cast(Result.begin()), reinterpret_cast(Result.end())); } diff --git a/lib/Sema/SemaLookup.cpp b/lib/Sema/SemaLookup.cpp index 059bc1cae7..5c66f077c8 100644 --- a/lib/Sema/SemaLookup.cpp +++ b/lib/Sema/SemaLookup.cpp @@ -153,9 +153,7 @@ namespace { void addUsingDirectives(DeclContext *DC, DeclContext *EffectiveDC) { SmallVector queue; while (true) { - DeclContext::udir_iterator I, End; - for (std::tie(I, End) = DC->getUsingDirectives(); I != End; ++I) { - UsingDirectiveDecl *UD = *I; + for (auto UD : DC->getUsingDirectives()) { DeclContext *NS = UD->getNominatedNamespace(); if (visited.insert(NS)) { addUsingDirective(UD, EffectiveDC); @@ -1515,8 +1513,8 @@ static bool LookupQualifiedNameInUsingDirectives(Sema &S, LookupResult &R, continue; } - for (std::tie(I, E) = ND->getUsingDirectives(); I != E; ++I) { - NamespaceDecl *Nom = (*I)->getNominatedNamespace(); + for (auto I : ND->getUsingDirectives()) { + NamespaceDecl *Nom = I->getNominatedNamespace(); if (Visited.insert(Nom)) Queue.push_back(Nom); } @@ -3085,9 +3083,8 @@ static void LookupVisibleDecls(DeclContext *Ctx, LookupResult &Result, // Traverse using directives for qualified name lookup. if (QualifiedNameLookup) { ShadowContextRAII Shadow(Visited); - DeclContext::udir_iterator I, E; - for (std::tie(I, E) = Ctx->getUsingDirectives(); I != E; ++I) { - LookupVisibleDecls((*I)->getNominatedNamespace(), Result, + for (auto I : Ctx->getUsingDirectives()) { + LookupVisibleDecls(I->getNominatedNamespace(), Result, QualifiedNameLookup, InBaseClass, Consumer, Visited); } }