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

include/clang/AST/DataRecursiveASTVisitor.h
include/clang/AST/DeclTemplate.h
include/clang/AST/RecursiveASTVisitor.h

index 5c6c487c748810877ad0fb1838654157a9a506d9..7eec752b88b68e49d32d2d088496945507bb731b 100644 (file)
@@ -1460,9 +1460,7 @@ template <typename Derived>
 bool DataRecursiveASTVisitor<Derived>::TraverseVariableInstantiations(
     VarTemplateDecl *D) {
   VarTemplateDecl::spec_iterator end = D->spec_end();
-  for (VarTemplateDecl::spec_iterator it = D->spec_begin(); it != end; ++it) {
-    VarTemplateSpecializationDecl *SD = *it;
-
+  for (auto *SD : D->specializations()) {
     switch (SD->getSpecializationKind()) {
     // Visit the implicit instantiations with the requested pattern.
     case TSK_Undeclared:
index 60e73b6801d099b0f6ddf48fb7c89aee8cd9078f..1be3d253f3a6cf5e2bcdc411292132e7199b1c74 100644 (file)
@@ -2776,6 +2776,11 @@ public:
       VarTemplatePartialSpecializationDecl *D);
 
   typedef SpecIterator<VarTemplateSpecializationDecl> 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 52f61b2bd65afc8d8cf6e76df8040a77391d6f7e..465a53cb6e1ad724bad4f15156ce524a63edfbb1 100644 (file)
@@ -1501,10 +1501,7 @@ template<typename Derived>                                                   \
 bool RecursiveASTVisitor<Derived>::TraverseTemplateInstantiations(           \
     TMPLDECLKIND##TemplateDecl *D) {                                         \
   TMPLDECLKIND##TemplateDecl::spec_iterator end = D->spec_end();             \
-  for (TMPLDECLKIND##TemplateDecl::spec_iterator it = D->spec_begin();       \
-       it != end; ++it) {                                                    \
-    TMPLDECLKIND##TemplateSpecializationDecl* SD = *it;                      \
-                                                                             \
+  for (auto *SD : D->specializations()) {                                    \
     switch (SD->getSpecializationKind()) {                                   \
     /* Visit the implicit instantiations with the requested pattern. */      \
     case TSK_Undeclared:                                                     \