Skip to content
Snippets Groups Projects
Commit b88f2d31 authored by Benjamin Kramer's avatar Benjamin Kramer
Browse files

[OpenMP] base specific_clause_iterator on iterator_adaptor_base.

Removes some boilerplate code. No functionality change intended.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@246452 91177308-0d34-0410-b5e6-96231b3b80d8
parent b122d611
No related branches found
No related tags found
No related merge requests found
...@@ -95,48 +95,35 @@ public: ...@@ -95,48 +95,35 @@ public:
/// This iterator visits only clauses of type SpecificClause. /// This iterator visits only clauses of type SpecificClause.
template <typename SpecificClause> template <typename SpecificClause>
class specific_clause_iterator class specific_clause_iterator
: public std::iterator<std::forward_iterator_tag, const SpecificClause *, : public llvm::iterator_adaptor_base<
ptrdiff_t, const SpecificClause *, specific_clause_iterator<SpecificClause>,
const SpecificClause *> { ArrayRef<OMPClause *>::const_iterator, std::forward_iterator_tag,
ArrayRef<OMPClause *>::const_iterator Current; const SpecificClause *, ptrdiff_t, const SpecificClause *,
const SpecificClause *> {
ArrayRef<OMPClause *>::const_iterator End; ArrayRef<OMPClause *>::const_iterator End;
void SkipToNextClause() { void SkipToNextClause() {
while (Current != End && !isa<SpecificClause>(*Current)) while (this->I != End && !isa<SpecificClause>(*this->I))
++Current; ++this->I;
} }
public: public:
explicit specific_clause_iterator(ArrayRef<OMPClause *> Clauses) explicit specific_clause_iterator(ArrayRef<OMPClause *> Clauses)
: Current(Clauses.begin()), End(Clauses.end()) { : specific_clause_iterator::iterator_adaptor_base(Clauses.begin()),
End(Clauses.end()) {
SkipToNextClause(); SkipToNextClause();
} }
const SpecificClause *operator*() const { const SpecificClause *operator*() const {
return cast<SpecificClause>(*Current); return cast<SpecificClause>(*this->I);
}
const SpecificClause *operator->() const {
return cast<SpecificClause>(*Current);
} }
const SpecificClause *operator->() const { return **this; }
specific_clause_iterator &operator++() { specific_clause_iterator &operator++() {
++Current; ++this->I;
SkipToNextClause(); SkipToNextClause();
return *this; 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 <typename SpecificClause> template <typename SpecificClause>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment