From b105e49f281c64f400c445994fc2ca3d01104bbb Mon Sep 17 00:00:00 2001 From: Aaron Ballman Date: Fri, 7 Mar 2014 14:09:15 +0000 Subject: [PATCH] [C++11] Replacing iterators ddiag_begin() and ddiag_end() with iterator_range ddiags(). Updating all of the usages of the iterators with range-based for loops. llvm-svn: 203240 --- clang/include/clang/AST/DeclBase.h | 5 +++-- clang/include/clang/AST/DependentDiagnostic.h | 10 ++++------ clang/lib/Sema/SemaTemplateInstantiateDecl.cpp | 5 +---- 3 files changed, 8 insertions(+), 12 deletions(-) diff --git a/clang/include/clang/AST/DeclBase.h b/clang/include/clang/AST/DeclBase.h index 8be3b8c..395fb67 100644 --- a/clang/include/clang/AST/DeclBase.h +++ b/clang/include/clang/AST/DeclBase.h @@ -1589,8 +1589,9 @@ public: // These are all defined in DependentDiagnostic.h. class ddiag_iterator; - inline ddiag_iterator ddiag_begin() const; - inline ddiag_iterator ddiag_end() const; + typedef llvm::iterator_range ddiag_range; + + inline ddiag_range ddiags() const; // Low-level accessors diff --git a/clang/include/clang/AST/DependentDiagnostic.h b/clang/include/clang/AST/DependentDiagnostic.h index 004b45d..0c783d2 100644 --- a/clang/include/clang/AST/DependentDiagnostic.h +++ b/clang/include/clang/AST/DependentDiagnostic.h @@ -171,18 +171,16 @@ private: DependentDiagnostic *Ptr; }; -inline DeclContext::ddiag_iterator DeclContext::ddiag_begin() const { +inline DeclContext::ddiag_range DeclContext::ddiags() const { assert(isDependentContext() && "cannot iterate dependent diagnostics of non-dependent context"); const DependentStoredDeclsMap *Map = static_cast(getPrimaryContext()->getLookupPtr()); - if (!Map) return ddiag_iterator(); - return ddiag_iterator(Map->FirstDiagnostic); -} + if (!Map) + return ddiag_range(); -inline DeclContext::ddiag_iterator DeclContext::ddiag_end() const { - return ddiag_iterator(); + return ddiag_range(ddiag_iterator(Map->FirstDiagnostic), ddiag_iterator()); } } diff --git a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp index a912f34..5ce43da 100644 --- a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp +++ b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp @@ -4674,10 +4674,7 @@ void Sema::PerformPendingInstantiations(bool LocalOnly) { void Sema::PerformDependentDiagnostics(const DeclContext *Pattern, const MultiLevelTemplateArgumentList &TemplateArgs) { - for (DeclContext::ddiag_iterator I = Pattern->ddiag_begin(), - E = Pattern->ddiag_end(); I != E; ++I) { - DependentDiagnostic *DD = *I; - + for (auto DD : Pattern->ddiags()) { switch (DD->getKind()) { case DependentDiagnostic::Access: HandleDependentAccessCheck(*DD, TemplateArgs); -- 2.7.4