From 5df6aa465ee1857daa98e3c0bd5f30aea5dc602a 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. llvm-svn: 204053 --- clang/include/clang/Sema/Scope.h | 21 +++++---------------- clang/lib/Sema/SemaLookup.cpp | 6 ++---- 2 files changed, 7 insertions(+), 20 deletions(-) diff --git a/clang/include/clang/Sema/Scope.h b/clang/include/clang/Sema/Scope.h index ccc7973c777c..54ca2a6bb64d 100644 --- a/clang/include/clang/Sema/Scope.h +++ b/clang/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(); - } + typedef llvm::iterator_range + using_directives_range; - udir_iterator using_directives_end() { - return UsingDirectives.end(); - } - - const_udir_iterator using_directives_begin() const { - return UsingDirectives.begin(); - } - - 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/clang/lib/Sema/SemaLookup.cpp b/clang/lib/Sema/SemaLookup.cpp index 3adea40387dd..29671aa65d4d 100644 --- a/clang/lib/Sema/SemaLookup.cpp +++ b/clang/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); } } }