r204053 - [C++11] Replacing Scope iterators using_directives_begin() and using_directives_end() with iterator_range using_directives(). Updating all of the usages of the iterators with range-based for loops, and removing the no-longer-needed iterator versions.

Aaron Ballman aaron at aaronballman.com
Mon Mar 17 10:03:37 PDT 2014


Author: aaronballman
Date: Mon Mar 17 12:03:37 2014
New Revision: 204053

URL: http://llvm.org/viewvc/llvm-project?rev=204053&view=rev
Log:
[C++11] Replacing Scope iterators using_directives_begin() and using_directives_end() with iterator_range using_directives(). Updating all of the usages of the iterators with range-based for loops, and removing the no-longer-needed iterator versions.

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

Modified: cfe/trunk/include/clang/Sema/Scope.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Scope.h?rev=204053&r1=204052&r2=204053&view=diff
==============================================================================
--- cfe/trunk/include/clang/Sema/Scope.h (original)
+++ cfe/trunk/include/clang/Sema/Scope.h Mon Mar 17 12:03:37 2014
@@ -361,27 +361,16 @@ public:
   /// is a FunctionPrototypeScope.
   bool containedInPrototypeScope() const;
 
-  typedef UsingDirectivesTy::iterator udir_iterator;
-  typedef UsingDirectivesTy::const_iterator const_udir_iterator;
-
   void PushUsingDirective(UsingDirectiveDecl *UDir) {
     UsingDirectives.push_back(UDir);
   }
 
-  udir_iterator using_directives_begin() {
-    return UsingDirectives.begin();
-  }
-
-  udir_iterator using_directives_end() {
-    return UsingDirectives.end();
-  }
-
-  const_udir_iterator using_directives_begin() const {
-    return UsingDirectives.begin();
-  }
+  typedef llvm::iterator_range<UsingDirectivesTy::iterator>
+    using_directives_range;
 
-  const_udir_iterator using_directives_end() const {
-    return UsingDirectives.end();
+  using_directives_range using_directives() {
+    return using_directives_range(UsingDirectives.begin(),
+                                  UsingDirectives.end());
   }
 
   /// Init - This is used by the parser to implement scope caching.

Modified: cfe/trunk/lib/Sema/SemaLookup.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaLookup.cpp?rev=204053&r1=204052&r2=204053&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaLookup.cpp (original)
+++ cfe/trunk/lib/Sema/SemaLookup.cpp Mon Mar 17 12:03:37 2014
@@ -113,10 +113,8 @@ namespace {
         if (Ctx && Ctx->isFileContext()) {
           visit(Ctx, Ctx);
         } else if (!Ctx || Ctx->isFunctionOrMethod()) {
-          Scope::udir_iterator I = S->using_directives_begin(),
-                             End = S->using_directives_end();
-          for (; I != End; ++I)
-            visit(*I, InnermostFileDC);
+          for (auto *I : S->using_directives())
+            visit(I, InnermostFileDC);
         }
       }
     }





More information about the cfe-commits mailing list