r203937 - [C++11] Replacing OMPThreadPrivateDecl and OMPClause iterators varlist_begin() and varlist_end() with iterator_range varlists(). Updating all of the usages of the iterators with range-based for loops.
Aaron Ballman
aaron at aaronballman.com
Fri Mar 14 08:55:35 PDT 2014
Author: aaronballman
Date: Fri Mar 14 10:55:35 2014
New Revision: 203937
URL: http://llvm.org/viewvc/llvm-project?rev=203937&view=rev
Log:
[C++11] Replacing OMPThreadPrivateDecl and OMPClause iterators varlist_begin() and varlist_end() with iterator_range varlists(). 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/DeclOpenMP.h
cfe/trunk/include/clang/AST/OpenMPClause.h
cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
cfe/trunk/lib/AST/StmtProfile.cpp
cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
cfe/trunk/lib/Sema/TreeTransform.h
cfe/trunk/lib/Serialization/ASTWriterDecl.cpp
cfe/trunk/lib/Serialization/ASTWriterStmt.cpp
cfe/trunk/tools/libclang/CIndex.cpp
Modified: cfe/trunk/include/clang/AST/DataRecursiveASTVisitor.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DataRecursiveASTVisitor.h?rev=203937&r1=203936&r2=203937&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/DataRecursiveASTVisitor.h (original)
+++ cfe/trunk/include/clang/AST/DataRecursiveASTVisitor.h Fri Mar 14 10:55:35 2014
@@ -1389,10 +1389,8 @@ DEF_TRAVERSE_DECL(UsingDirectiveDecl, {
DEF_TRAVERSE_DECL(UsingShadowDecl, { })
DEF_TRAVERSE_DECL(OMPThreadPrivateDecl, {
- for (OMPThreadPrivateDecl::varlist_iterator I = D->varlist_begin(),
- E = D->varlist_end();
- I != E; ++I) {
- TRY_TO(TraverseStmt(*I));
+ for (auto *I : D->varlists()) {
+ TRY_TO(TraverseStmt(I));
}
})
@@ -2379,10 +2377,8 @@ bool DataRecursiveASTVisitor<Derived>::V
template<typename Derived>
template<typename T>
void DataRecursiveASTVisitor<Derived>::VisitOMPClauseList(T *Node) {
- for (typename T::varlist_iterator I = Node->varlist_begin(),
- E = Node->varlist_end();
- I != E; ++I)
- TraverseStmt(*I);
+ for (auto *I : Node->varlists())
+ TraverseStmt(I);
}
template<typename Derived>
Modified: cfe/trunk/include/clang/AST/DeclOpenMP.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclOpenMP.h?rev=203937&r1=203936&r2=203937&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/DeclOpenMP.h (original)
+++ cfe/trunk/include/clang/AST/DeclOpenMP.h Fri Mar 14 10:55:35 2014
@@ -64,9 +64,18 @@ public:
typedef llvm::MutableArrayRef<Expr *>::iterator varlist_iterator;
typedef ArrayRef<const Expr *>::iterator varlist_const_iterator;
+ typedef llvm::iterator_range<varlist_iterator> varlist_range;
+ typedef llvm::iterator_range<varlist_const_iterator> varlist_const_range;
unsigned varlist_size() const { return NumVars; }
bool varlist_empty() const { return NumVars == 0; }
+
+ varlist_range varlists() {
+ return varlist_range(varlist_begin(), varlist_end());
+ }
+ varlist_const_range varlists() const {
+ return varlist_const_range(varlist_begin(), varlist_end());
+ }
varlist_iterator varlist_begin() { return getVars().begin(); }
varlist_iterator varlist_end() { return getVars().end(); }
varlist_const_iterator varlist_begin() const { return getVars().begin(); }
Modified: cfe/trunk/include/clang/AST/OpenMPClause.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/OpenMPClause.h?rev=203937&r1=203936&r2=203937&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/OpenMPClause.h (original)
+++ cfe/trunk/include/clang/AST/OpenMPClause.h Fri Mar 14 10:55:35 2014
@@ -110,9 +110,19 @@ protected:
public:
typedef llvm::MutableArrayRef<Expr *>::iterator varlist_iterator;
typedef ArrayRef<const Expr *>::iterator varlist_const_iterator;
+ typedef llvm::iterator_range<varlist_iterator> varlist_range;
+ typedef llvm::iterator_range<varlist_const_iterator> varlist_const_range;
unsigned varlist_size() const { return NumVars; }
bool varlist_empty() const { return NumVars == 0; }
+
+ varlist_range varlists() {
+ return varlist_range(varlist_begin(), varlist_end());
+ }
+ varlist_const_range varlists() const {
+ return varlist_const_range(varlist_begin(), varlist_end());
+ }
+
varlist_iterator varlist_begin() { return getVarRefs().begin(); }
varlist_iterator varlist_end() { return getVarRefs().end(); }
varlist_const_iterator varlist_begin() const { return getVarRefs().begin(); }
Modified: cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/RecursiveASTVisitor.h?rev=203937&r1=203936&r2=203937&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/RecursiveASTVisitor.h (original)
+++ cfe/trunk/include/clang/AST/RecursiveASTVisitor.h Fri Mar 14 10:55:35 2014
@@ -1476,10 +1476,8 @@ DEF_TRAVERSE_DECL(UsingDirectiveDecl, {
DEF_TRAVERSE_DECL(UsingShadowDecl, { })
DEF_TRAVERSE_DECL(OMPThreadPrivateDecl, {
- for (OMPThreadPrivateDecl::varlist_iterator I = D->varlist_begin(),
- E = D->varlist_end();
- I != E; ++I) {
- TRY_TO(TraverseStmt(*I));
+ for (auto *I : D->varlists()) {
+ TRY_TO(TraverseStmt(I));
}
})
@@ -2403,10 +2401,8 @@ bool RecursiveASTVisitor<Derived>::Visit
template<typename Derived>
template<typename T>
void RecursiveASTVisitor<Derived>::VisitOMPClauseList(T *Node) {
- for (typename T::varlist_iterator I = Node->varlist_begin(),
- E = Node->varlist_end();
- I != E; ++I)
- TraverseStmt(*I);
+ for (auto *I : Node->varlists())
+ TraverseStmt(I);
}
template<typename Derived>
Modified: cfe/trunk/lib/AST/StmtProfile.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/StmtProfile.cpp?rev=203937&r1=203936&r2=203937&view=diff
==============================================================================
--- cfe/trunk/lib/AST/StmtProfile.cpp (original)
+++ cfe/trunk/lib/AST/StmtProfile.cpp Fri Mar 14 10:55:35 2014
@@ -279,10 +279,8 @@ void OMPClauseProfiler::VisitOMPDefaultC
template<typename T>
void OMPClauseProfiler::VisitOMPClauseList(T *Node) {
- for (typename T::varlist_const_iterator I = Node->varlist_begin(),
- E = Node->varlist_end();
- I != E; ++I)
- Profiler->VisitStmt(*I);
+ for (auto *I : Node->varlists())
+ Profiler->VisitStmt(I);
}
void OMPClauseProfiler::VisitOMPPrivateClause(const OMPPrivateClause *C) {
Modified: cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp?rev=203937&r1=203936&r2=203937&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp Fri Mar 14 10:55:35 2014
@@ -2305,10 +2305,8 @@ Decl *TemplateDeclInstantiator::VisitCla
Decl *TemplateDeclInstantiator::VisitOMPThreadPrivateDecl(
OMPThreadPrivateDecl *D) {
SmallVector<Expr *, 5> Vars;
- for (ArrayRef<Expr *>::iterator I = D->varlist_begin(),
- E = D->varlist_end();
- I != E; ++I) {
- Expr *Var = SemaRef.SubstExpr(*I, TemplateArgs).take();
+ for (auto *I : D->varlists()) {
+ Expr *Var = SemaRef.SubstExpr(I, TemplateArgs).take();
assert(isa<DeclRefExpr>(Var) && "threadprivate arg is not a DeclRefExpr");
Vars.push_back(Var);
}
Modified: cfe/trunk/lib/Sema/TreeTransform.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/TreeTransform.h?rev=203937&r1=203936&r2=203937&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/TreeTransform.h (original)
+++ cfe/trunk/lib/Sema/TreeTransform.h Fri Mar 14 10:55:35 2014
@@ -6358,10 +6358,8 @@ OMPClause *
TreeTransform<Derived>::TransformOMPPrivateClause(OMPPrivateClause *C) {
llvm::SmallVector<Expr *, 16> Vars;
Vars.reserve(C->varlist_size());
- for (OMPPrivateClause::varlist_iterator I = C->varlist_begin(),
- E = C->varlist_end();
- I != E; ++I) {
- ExprResult EVar = getDerived().TransformExpr(cast<Expr>(*I));
+ for (auto *I : C->varlists()) {
+ ExprResult EVar = getDerived().TransformExpr(cast<Expr>(I));
if (EVar.isInvalid())
return 0;
Vars.push_back(EVar.take());
@@ -6378,10 +6376,8 @@ TreeTransform<Derived>::TransformOMPFirs
OMPFirstprivateClause *C) {
llvm::SmallVector<Expr *, 16> Vars;
Vars.reserve(C->varlist_size());
- for (OMPFirstprivateClause::varlist_iterator I = C->varlist_begin(),
- E = C->varlist_end();
- I != E; ++I) {
- ExprResult EVar = getDerived().TransformExpr(cast<Expr>(*I));
+ for (auto *I : C->varlists()) {
+ ExprResult EVar = getDerived().TransformExpr(cast<Expr>(I));
if (EVar.isInvalid())
return 0;
Vars.push_back(EVar.take());
@@ -6397,10 +6393,8 @@ OMPClause *
TreeTransform<Derived>::TransformOMPSharedClause(OMPSharedClause *C) {
llvm::SmallVector<Expr *, 16> Vars;
Vars.reserve(C->varlist_size());
- for (OMPSharedClause::varlist_iterator I = C->varlist_begin(),
- E = C->varlist_end();
- I != E; ++I) {
- ExprResult EVar = getDerived().TransformExpr(cast<Expr>(*I));
+ for (auto *I : C->varlists()) {
+ ExprResult EVar = getDerived().TransformExpr(cast<Expr>(I));
if (EVar.isInvalid())
return 0;
Vars.push_back(EVar.take());
Modified: cfe/trunk/lib/Serialization/ASTWriterDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTWriterDecl.cpp?rev=203937&r1=203936&r2=203937&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTWriterDecl.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTWriterDecl.cpp Fri Mar 14 10:55:35 2014
@@ -1415,10 +1415,8 @@ void ASTDeclWriter::VisitRedeclarable(Re
void ASTDeclWriter::VisitOMPThreadPrivateDecl(OMPThreadPrivateDecl *D) {
Record.push_back(D->varlist_size());
VisitDecl(D);
- for (OMPThreadPrivateDecl::varlist_iterator I = D->varlist_begin(),
- E = D->varlist_end();
- I != E; ++I)
- Writer.AddStmt(*I);
+ for (auto *I : D->varlists())
+ Writer.AddStmt(I);
Code = serialization::DECL_OMP_THREADPRIVATE;
}
Modified: cfe/trunk/lib/Serialization/ASTWriterStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTWriterStmt.cpp?rev=203937&r1=203936&r2=203937&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTWriterStmt.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTWriterStmt.cpp Fri Mar 14 10:55:35 2014
@@ -1698,28 +1698,22 @@ void OMPClauseWriter::VisitOMPDefaultCla
void OMPClauseWriter::VisitOMPPrivateClause(OMPPrivateClause *C) {
Record.push_back(C->varlist_size());
Writer->Writer.AddSourceLocation(C->getLParenLoc(), Record);
- for (OMPPrivateClause::varlist_iterator I = C->varlist_begin(),
- E = C->varlist_end();
- I != E; ++I)
- Writer->Writer.AddStmt(*I);
+ for (auto *I : C->varlists())
+ Writer->Writer.AddStmt(I);
}
void OMPClauseWriter::VisitOMPFirstprivateClause(OMPFirstprivateClause *C) {
Record.push_back(C->varlist_size());
Writer->Writer.AddSourceLocation(C->getLParenLoc(), Record);
- for (OMPFirstprivateClause::varlist_iterator I = C->varlist_begin(),
- E = C->varlist_end();
- I != E; ++I)
- Writer->Writer.AddStmt(*I);
+ for (auto *I : C->varlists())
+ Writer->Writer.AddStmt(I);
}
void OMPClauseWriter::VisitOMPSharedClause(OMPSharedClause *C) {
Record.push_back(C->varlist_size());
Writer->Writer.AddSourceLocation(C->getLParenLoc(), Record);
- for (OMPSharedClause::varlist_iterator I = C->varlist_begin(),
- E = C->varlist_end();
- I != E; ++I)
- Writer->Writer.AddStmt(*I);
+ for (auto *I : C->varlists())
+ Writer->Writer.AddStmt(I);
}
//===----------------------------------------------------------------------===//
Modified: cfe/trunk/tools/libclang/CIndex.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CIndex.cpp?rev=203937&r1=203936&r2=203937&view=diff
==============================================================================
--- cfe/trunk/tools/libclang/CIndex.cpp (original)
+++ cfe/trunk/tools/libclang/CIndex.cpp Fri Mar 14 10:55:35 2014
@@ -1936,10 +1936,8 @@ void OMPClauseEnqueue::VisitOMPDefaultCl
template<typename T>
void OMPClauseEnqueue::VisitOMPClauseList(T *Node) {
- for (typename T::varlist_const_iterator I = Node->varlist_begin(),
- E = Node->varlist_end();
- I != E; ++I)
- Visitor->AddStmt(*I);
+ for (const auto *I : Node->varlists())
+ Visitor->AddStmt(I);
}
void OMPClauseEnqueue::VisitOMPPrivateClause(const OMPPrivateClause *C) {
More information about the cfe-commits
mailing list