From fc600dc2ec249a9fa37b7a62847d1477e4b4bb2e Mon Sep 17 00:00:00 2001 From: Benjamin Kramer Date: Sun, 30 Aug 2015 15:12:28 +0000 Subject: [OpenMP] Make the filetered clause iterator a real iterator and type safe. This replaces the filtered generic iterator with a type-specfic one based on dyn_cast instead of comparing the kind enum. This allows us to use range-based for loops and eliminates casts. No functionality change intended. llvm-svn: 246384 --- clang/lib/Sema/SemaOpenMP.cpp | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) (limited to 'clang/lib/Sema') diff --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp index 6b092a80de9..ea31260cc7a 100644 --- a/clang/lib/Sema/SemaOpenMP.cpp +++ b/clang/lib/Sema/SemaOpenMP.cpp @@ -3514,24 +3514,18 @@ CheckOpenMPLoop(OpenMPDirectiveKind DKind, Expr *CollapseLoopCountExpr, } static Expr *getCollapseNumberExpr(ArrayRef Clauses) { - auto &&CollapseFilter = [](const OMPClause *C) -> bool { - return C->getClauseKind() == OMPC_collapse; - }; - OMPExecutableDirective::filtered_clause_iterator I( - Clauses, std::move(CollapseFilter)); - if (I) - return cast(*I)->getNumForLoops(); + auto CollapseClauses = + OMPExecutableDirective::getClausesOfKind(Clauses); + if (CollapseClauses.begin() != CollapseClauses.end()) + return (*CollapseClauses.begin())->getNumForLoops(); return nullptr; } static Expr *getOrderedNumberExpr(ArrayRef Clauses) { - auto &&OrderedFilter = [](const OMPClause *C) -> bool { - return C->getClauseKind() == OMPC_ordered; - }; - OMPExecutableDirective::filtered_clause_iterator I( - Clauses, std::move(OrderedFilter)); - if (I) - return cast(*I)->getNumForLoops(); + auto OrderedClauses = + OMPExecutableDirective::getClausesOfKind(Clauses); + if (OrderedClauses.begin() != OrderedClauses.end()) + return (*OrderedClauses.begin())->getNumForLoops(); return nullptr; } -- cgit v1.2.3