From 76538aa016299300e2a63bada9af1caea0a832c9 Mon Sep 17 00:00:00 2001 From: Aaron Ballman Date: Fri, 14 Mar 2014 16:13:33 +0000 Subject: [PATCH] [C++11] Replacing ClassTemplateDecl iterators spec_begin() and spec_end() with iterator_range specializations(). Updating all of the usages of the iterators with range-based for loops. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@203940 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/AST/DataRecursiveASTVisitor.h | 4 +--- include/clang/AST/DeclTemplate.h | 5 +++++ lib/AST/DeclPrinter.cpp | 7 +++---- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/include/clang/AST/DataRecursiveASTVisitor.h b/include/clang/AST/DataRecursiveASTVisitor.h index 8495300768..5c6c487c74 100644 --- a/include/clang/AST/DataRecursiveASTVisitor.h +++ b/include/clang/AST/DataRecursiveASTVisitor.h @@ -1413,9 +1413,7 @@ template bool DataRecursiveASTVisitor::TraverseClassInstantiations( ClassTemplateDecl *D) { ClassTemplateDecl::spec_iterator end = D->spec_end(); - for (ClassTemplateDecl::spec_iterator it = D->spec_begin(); it != end; ++it) { - ClassTemplateSpecializationDecl* SD = *it; - + for (auto *SD : D->specializations()) { switch (SD->getSpecializationKind()) { // Visit the implicit instantiations with the requested pattern. case TSK_Undeclared: diff --git a/include/clang/AST/DeclTemplate.h b/include/clang/AST/DeclTemplate.h index bbf746375d..ef7c63beb4 100644 --- a/include/clang/AST/DeclTemplate.h +++ b/include/clang/AST/DeclTemplate.h @@ -1974,6 +1974,11 @@ public: QualType getInjectedClassNameSpecialization(); typedef SpecIterator spec_iterator; + typedef llvm::iterator_range spec_range; + + spec_range specializations() const { + return spec_range(spec_begin(), spec_end()); + } spec_iterator spec_begin() const { return makeSpecIterator(getSpecializations(), false); diff --git a/lib/AST/DeclPrinter.cpp b/lib/AST/DeclPrinter.cpp index c0df591b3d..a57532cb65 100644 --- a/lib/AST/DeclPrinter.cpp +++ b/lib/AST/DeclPrinter.cpp @@ -897,10 +897,9 @@ void DeclPrinter::VisitFunctionTemplateDecl(FunctionTemplateDecl *D) { void DeclPrinter::VisitClassTemplateDecl(ClassTemplateDecl *D) { if (PrintInstantiation) { TemplateParameterList *Params = D->getTemplateParameters(); - for (ClassTemplateDecl::spec_iterator I = D->spec_begin(), E = D->spec_end(); - I != E; ++I) { - PrintTemplateParameters(Params, &(*I)->getTemplateArgs()); - Visit(*I); + for (auto *I : D->specializations()) { + PrintTemplateParameters(Params, &I->getTemplateArgs()); + Visit(I); Out << '\n'; } } -- 2.40.0