From ec5f51ffe475567b260445ca8869d6e4e06c3a8f Mon Sep 17 00:00:00 2001 From: Benjamin Kramer Date: Mon, 31 Aug 2015 16:45:35 +0000 Subject: [PATCH] [OpenMP] base specific_clause_iterator on iterator_adaptor_base. Removes some boilerplate code. No functionality change intended. llvm-svn: 246452 --- clang/include/clang/AST/StmtOpenMP.h | 37 +++++++++------------------- 1 file changed, 12 insertions(+), 25 deletions(-) diff --git a/clang/include/clang/AST/StmtOpenMP.h b/clang/include/clang/AST/StmtOpenMP.h index 7e6fb46cfbb4..5c1cda8116c6 100644 --- a/clang/include/clang/AST/StmtOpenMP.h +++ b/clang/include/clang/AST/StmtOpenMP.h @@ -95,48 +95,35 @@ public: /// This iterator visits only clauses of type SpecificClause. template class specific_clause_iterator - : public std::iterator { - ArrayRef::const_iterator Current; + : public llvm::iterator_adaptor_base< + specific_clause_iterator, + ArrayRef::const_iterator, std::forward_iterator_tag, + const SpecificClause *, ptrdiff_t, const SpecificClause *, + const SpecificClause *> { ArrayRef::const_iterator End; void SkipToNextClause() { - while (Current != End && !isa(*Current)) - ++Current; + while (this->I != End && !isa(*this->I)) + ++this->I; } public: explicit specific_clause_iterator(ArrayRef Clauses) - : Current(Clauses.begin()), End(Clauses.end()) { + : specific_clause_iterator::iterator_adaptor_base(Clauses.begin()), + End(Clauses.end()) { SkipToNextClause(); } const SpecificClause *operator*() const { - return cast(*Current); - } - const SpecificClause *operator->() const { - return cast(*Current); + return cast(*this->I); } + const SpecificClause *operator->() const { return **this; } specific_clause_iterator &operator++() { - ++Current; + ++this->I; SkipToNextClause(); return *this; } - specific_clause_iterator operator++(int) { - specific_clause_iterator tmp(*this); - ++(*this); - return tmp; - } - - bool operator==(const specific_clause_iterator &RHS) const { - assert(End == RHS.End && "Comparing iterators of different directives!"); - return Current == RHS.Current; - } - bool operator!=(const specific_clause_iterator &RHS) const { - return !(*this == RHS); - } }; template