r203942 - [C++11] Replacing VarTemplateDecl iterators spec_begin() and spec_end() with iterator_range specializations(). Updating all of the usages of the iterators with range-based for loops.
Duncan P. N. Exon Smith
dexonsmith at apple.com
Fri Mar 14 10:29:01 PDT 2014
On Mar 14, 2014, at 9:29 AM, Aaron Ballman <aaron at aaronballman.com> wrote:
> Author: aaronballman
> Date: Fri Mar 14 11:29:14 2014
> New Revision: 203942
>
> URL: http://llvm.org/viewvc/llvm-project?rev=203942&view=rev
> Log:
> [C++11] Replacing VarTemplateDecl iterators spec_begin() and spec_end() with iterator_range specializations(). Updating all of the usages of the iterators with range-based for loops.
>
> Modified:
> cfe/trunk/include/clang/AST/DataRecursiveASTVisitor.h
> cfe/trunk/include/clang/AST/DeclTemplate.h
> cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
>
> Modified: cfe/trunk/include/clang/AST/DataRecursiveASTVisitor.h
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DataRecursiveASTVisitor.h?rev=203942&r1=203941&r2=203942&view=diff
> ==============================================================================
> --- cfe/trunk/include/clang/AST/DataRecursiveASTVisitor.h (original)
> +++ cfe/trunk/include/clang/AST/DataRecursiveASTVisitor.h Fri Mar 14 11:29:14 2014
> @@ -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:
>
> Modified: cfe/trunk/include/clang/AST/DeclTemplate.h
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclTemplate.h?rev=203942&r1=203941&r2=203942&view=diff
> ==============================================================================
> --- cfe/trunk/include/clang/AST/DeclTemplate.h (original)
> +++ cfe/trunk/include/clang/AST/DeclTemplate.h Fri Mar 14 11:29:14 2014
> @@ -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);
>
> Modified: cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/RecursiveASTVisitor.h?rev=203942&r1=203941&r2=203942&view=diff
> ==============================================================================
> --- cfe/trunk/include/clang/AST/RecursiveASTVisitor.h (original)
> +++ cfe/trunk/include/clang/AST/RecursiveASTVisitor.h Fri Mar 14 11:29:14 2014
> @@ -1501,10 +1501,7 @@ template<typename Derived>
> bool RecursiveASTVisitor<Derived>::TraverseTemplateInstantiations( \
> TMPLDECLKIND##TemplateDecl *D) { \
> TMPLDECLKIND##TemplateDecl::spec_iterator end = D->spec_end(); \
FYI, this (and a few other similar commits) introduced unused variable warnings
because you left end around. Fixed in r203948.
> - 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: \
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
More information about the cfe-commits
mailing list