r203239 - [C++11] Updating getUsingDirectives to use iterator_range instead of a std::pair.

Aaron Ballman aaron at aaronballman.com
Fri Mar 7 05:44:45 PST 2014


Author: aaronballman
Date: Fri Mar  7 07:44:44 2014
New Revision: 203239

URL: http://llvm.org/viewvc/llvm-project?rev=203239&view=rev
Log:
[C++11] Updating getUsingDirectives to use iterator_range instead of a std::pair.

Modified:
    cfe/trunk/include/clang/AST/DeclBase.h
    cfe/trunk/lib/AST/DeclBase.cpp
    cfe/trunk/lib/Sema/SemaLookup.cpp

Modified: cfe/trunk/include/clang/AST/DeclBase.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclBase.h?rev=203239&r1=203238&r2=203239&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/DeclBase.h (original)
+++ cfe/trunk/include/clang/AST/DeclBase.h Fri Mar  7 07:44:44 2014
@@ -1575,16 +1575,16 @@ public:
   /// within this context.
   typedef UsingDirectiveDecl * const * udir_iterator;
 
-  typedef std::pair<udir_iterator, udir_iterator> udir_iterator_range;
+  typedef llvm::iterator_range<udir_iterator> 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.

Modified: cfe/trunk/lib/AST/DeclBase.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclBase.cpp?rev=203239&r1=203238&r2=203239&view=diff
==============================================================================
--- cfe/trunk/lib/AST/DeclBase.cpp (original)
+++ cfe/trunk/lib/AST/DeclBase.cpp Fri Mar  7 07:44:44 2014
@@ -1528,12 +1528,12 @@ void DeclContext::makeDeclVisibleInConte
 
 /// 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<udir_iterator>(Result.begin()),
+  return udir_range(reinterpret_cast<udir_iterator>(Result.begin()),
                              reinterpret_cast<udir_iterator>(Result.end()));
 }
 

Modified: cfe/trunk/lib/Sema/SemaLookup.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaLookup.cpp?rev=203239&r1=203238&r2=203239&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaLookup.cpp (original)
+++ cfe/trunk/lib/Sema/SemaLookup.cpp Fri Mar  7 07:44:44 2014
@@ -153,9 +153,7 @@ namespace {
     void addUsingDirectives(DeclContext *DC, DeclContext *EffectiveDC) {
       SmallVector<DeclContext*,4> 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 LookupQualifiedNameInUsingDi
       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(DeclConte
   // 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);
     }
   }





More information about the cfe-commits mailing list