r203938 - [C++11] Replacing FunctionTemplateDecl iterators spec_begin() and spec_end() with iterator_range specializations(). Updating all of the usages of the iterators with range-based for loops.
Aaron Ballman
aaron at aaronballman.com
Fri Mar 14 09:05:56 PDT 2014
Author: aaronballman
Date: Fri Mar 14 11:05:56 2014
New Revision: 203938
URL: http://llvm.org/viewvc/llvm-project?rev=203938&view=rev
Log:
[C++11] Replacing FunctionTemplateDecl 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
cfe/trunk/lib/AST/DeclPrinter.cpp
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
Modified: cfe/trunk/include/clang/AST/DataRecursiveASTVisitor.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DataRecursiveASTVisitor.h?rev=203938&r1=203937&r2=203938&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/DataRecursiveASTVisitor.h (original)
+++ cfe/trunk/include/clang/AST/DataRecursiveASTVisitor.h Fri Mar 14 11:05:56 2014
@@ -1513,9 +1513,7 @@ template<typename Derived>
bool DataRecursiveASTVisitor<Derived>::TraverseFunctionInstantiations(
FunctionTemplateDecl *D) {
FunctionTemplateDecl::spec_iterator end = D->spec_end();
- for (FunctionTemplateDecl::spec_iterator it = D->spec_begin(); it != end;
- ++it) {
- FunctionDecl* FD = *it;
+ for (auto *FD : D->specializations()) {
switch (FD->getTemplateSpecializationKind()) {
case TSK_Undeclared:
case TSK_ImplicitInstantiation:
Modified: cfe/trunk/include/clang/AST/DeclTemplate.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclTemplate.h?rev=203938&r1=203937&r2=203938&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/DeclTemplate.h (original)
+++ cfe/trunk/include/clang/AST/DeclTemplate.h Fri Mar 14 11:05:56 2014
@@ -713,9 +713,9 @@ public:
}
typedef redeclarable_base::redecl_range redecl_range;
- typedef redeclarable_base::redecl_iterator redecl_iterator;
- using redeclarable_base::redecls_begin;
- using redeclarable_base::redecls_end;
+ typedef redeclarable_base::redecl_iterator redecl_iterator;
+ using redeclarable_base::redecls_begin;
+ using redeclarable_base::redecls_end;
using redeclarable_base::redecls;
using redeclarable_base::getPreviousDecl;
using redeclarable_base::getMostRecentDecl;
@@ -846,7 +846,11 @@ public:
}
typedef SpecIterator<FunctionTemplateSpecializationInfo> 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=203938&r1=203937&r2=203938&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/RecursiveASTVisitor.h (original)
+++ cfe/trunk/include/clang/AST/RecursiveASTVisitor.h Fri Mar 14 11:05:56 2014
@@ -1534,9 +1534,7 @@ template<typename Derived>
bool RecursiveASTVisitor<Derived>::TraverseTemplateInstantiations(
FunctionTemplateDecl *D) {
FunctionTemplateDecl::spec_iterator end = D->spec_end();
- for (FunctionTemplateDecl::spec_iterator it = D->spec_begin(); it != end;
- ++it) {
- FunctionDecl* FD = *it;
+ for (auto *FD : D->specializations()) {
switch (FD->getTemplateSpecializationKind()) {
case TSK_Undeclared:
case TSK_ImplicitInstantiation:
Modified: cfe/trunk/lib/AST/DeclPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclPrinter.cpp?rev=203938&r1=203937&r2=203938&view=diff
==============================================================================
--- cfe/trunk/lib/AST/DeclPrinter.cpp (original)
+++ cfe/trunk/lib/AST/DeclPrinter.cpp Fri Mar 14 11:05:56 2014
@@ -885,10 +885,9 @@ void DeclPrinter::VisitTemplateDecl(cons
void DeclPrinter::VisitFunctionTemplateDecl(FunctionTemplateDecl *D) {
if (PrintInstantiation) {
TemplateParameterList *Params = D->getTemplateParameters();
- for (FunctionTemplateDecl::spec_iterator I = D->spec_begin(), E = D->spec_end();
- I != E; ++I) {
- PrintTemplateParameters(Params, (*I)->getTemplateSpecializationArgs());
- Visit(*I);
+ for (auto *I : D->specializations()) {
+ PrintTemplateParameters(Params, I->getTemplateSpecializationArgs());
+ Visit(I);
}
}
Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=203938&r1=203937&r2=203938&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Fri Mar 14 11:05:56 2014
@@ -1151,11 +1151,9 @@ CollectCXXMemberFunctions(const CXXRecor
// Add any template specializations that have already been seen. Like
// implicit member functions, these may have been added to a declaration
// in the case of vtable-based debug info reduction.
- for (FunctionTemplateDecl::spec_iterator SI = FTD->spec_begin(),
- SE = FTD->spec_end();
- SI != SE; ++SI) {
+ for (const auto *SI : FTD->specializations()) {
llvm::DenseMap<const FunctionDecl *, llvm::WeakVH>::iterator MI =
- SPCache.find(cast<CXXMethodDecl>(*SI)->getCanonicalDecl());
+ SPCache.find(cast<CXXMethodDecl>(SI)->getCanonicalDecl());
if (MI != SPCache.end())
EltTys.push_back(MI->second);
}
More information about the cfe-commits
mailing list