]> granicus.if.org Git - clang/commitdiff
[C++11] Replacing ClassTemplateDecl iterators spec_begin() and spec_end() with iterat...
authorAaron Ballman <aaron@aaronballman.com>
Fri, 14 Mar 2014 16:13:33 +0000 (16:13 +0000)
committerAaron Ballman <aaron@aaronballman.com>
Fri, 14 Mar 2014 16:13:33 +0000 (16:13 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@203940 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/AST/DataRecursiveASTVisitor.h
include/clang/AST/DeclTemplate.h
lib/AST/DeclPrinter.cpp

index 84953007684daf167da9881dfabaa6d259ff4ef7..5c6c487c748810877ad0fb1838654157a9a506d9 100644 (file)
@@ -1413,9 +1413,7 @@ template<typename Derived>
 bool DataRecursiveASTVisitor<Derived>::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:
index bbf746375d283e4324ad6812aea847f8bf04f1e4..ef7c63beb4cc642b1c08bde7f6abc2c357e382b2 100644 (file)
@@ -1974,6 +1974,11 @@ public:
   QualType getInjectedClassNameSpecialization();
 
   typedef SpecIterator<ClassTemplateSpecializationDecl> spec_iterator;
+  typedef llvm::iterator_range<spec_iterator> spec_range;
+
+  spec_range specializations() const {
+    return spec_range(spec_begin(), spec_end());
+  }
 
   spec_iterator spec_begin() const {
     return makeSpecIterator(getSpecializations(), false);
index c0df591b3d56c748cd1be25f3b0fc3066bc1eb5c..a57532cb65e5a9d6969819d411d457931d75bea4 100644 (file)
@@ -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';
     }
   }