[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.

llvm-svn: 203937
This commit is contained in:
Aaron Ballman 2014-03-14 15:55:35 +00:00
parent fdbd8e05b2
commit 2205d2a56a
10 changed files with 47 additions and 56 deletions

View File

@ -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>::VisitOMPDefaultClause(OMPDefaultClause *C
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>

View File

@ -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(); }

View File

@ -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(); }

View File

@ -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>::VisitOMPDefaultClause(OMPDefaultClause *C) {
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>

View File

@ -279,10 +279,8 @@ void OMPClauseProfiler::VisitOMPDefaultClause(const OMPDefaultClause *C) { }
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) {

View File

@ -2305,10 +2305,8 @@ Decl *TemplateDeclInstantiator::VisitClassScopeFunctionSpecializationDecl(
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);
}

View File

@ -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>::TransformOMPFirstprivateClause(
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());

View File

@ -1415,10 +1415,8 @@ void ASTDeclWriter::VisitRedeclarable(Redeclarable<T> *D) {
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;
}

View File

@ -1698,28 +1698,22 @@ void OMPClauseWriter::VisitOMPDefaultClause(OMPDefaultClause *C) {
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);
}
//===----------------------------------------------------------------------===//

View File

@ -1936,10 +1936,8 @@ void OMPClauseEnqueue::VisitOMPDefaultClause(const OMPDefaultClause *C) { }
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) {