From a0f17afcc006033ccebcf7dfeaabc7aee20d9633 Mon Sep 17 00:00:00 2001 From: Aaron Ballman Date: Mon, 17 Mar 2014 17:03:37 +0000 Subject: [PATCH] [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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@204053 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/Sema/Scope.h | 21 +++++---------------- lib/Sema/SemaLookup.cpp | 6 ++---- 2 files changed, 7 insertions(+), 20 deletions(-) diff --git a/include/clang/Sema/Scope.h b/include/clang/Sema/Scope.h index ccc7973c77..54ca2a6bb6 100644 --- a/include/clang/Sema/Scope.h +++ b/include/clang/Sema/Scope.h @@ -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 + 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. diff --git a/lib/Sema/SemaLookup.cpp b/lib/Sema/SemaLookup.cpp index 3adea40387..29671aa65d 100644 --- a/lib/Sema/SemaLookup.cpp +++ b/lib/Sema/SemaLookup.cpp @@ -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); } } } -- 2.40.0