summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenjamin Kramer <benny.kra@googlemail.com>2015-08-31 16:45:35 +0000
committerBenjamin Kramer <benny.kra@googlemail.com>2015-08-31 16:45:35 +0000
commitec5f51ffe475567b260445ca8869d6e4e06c3a8f (patch)
treecc88f03b6aafbad66efbbb70cab440c2ca5b553d
parent36440082f8ea752dcf485ca8a36e0fb05a6bb65e (diff)
downloadbcm5719-llvm-ec5f51ffe475567b260445ca8869d6e4e06c3a8f.tar.gz
bcm5719-llvm-ec5f51ffe475567b260445ca8869d6e4e06c3a8f.zip
[OpenMP] base specific_clause_iterator on iterator_adaptor_base.
Removes some boilerplate code. No functionality change intended. llvm-svn: 246452
-rw-r--r--clang/include/clang/AST/StmtOpenMP.h37
1 files changed, 12 insertions, 25 deletions
diff --git a/clang/include/clang/AST/StmtOpenMP.h b/clang/include/clang/AST/StmtOpenMP.h
index 7e6fb46cfbb..5c1cda8116c 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 <typename SpecificClause>
class specific_clause_iterator
- : public std::iterator<std::forward_iterator_tag, const SpecificClause *,
- ptrdiff_t, const SpecificClause *,
- const SpecificClause *> {
- ArrayRef<OMPClause *>::const_iterator Current;
+ : public llvm::iterator_adaptor_base<
+ specific_clause_iterator<SpecificClause>,
+ ArrayRef<OMPClause *>::const_iterator, std::forward_iterator_tag,
+ const SpecificClause *, ptrdiff_t, const SpecificClause *,
+ const SpecificClause *> {
ArrayRef<OMPClause *>::const_iterator End;
void SkipToNextClause() {
- while (Current != End && !isa<SpecificClause>(*Current))
- ++Current;
+ while (this->I != End && !isa<SpecificClause>(*this->I))
+ ++this->I;
}
public:
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();
}
const SpecificClause *operator*() const {
- return cast<SpecificClause>(*Current);
- }
- const SpecificClause *operator->() const {
- return cast<SpecificClause>(*Current);
+ return cast<SpecificClause>(*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 <typename SpecificClause>
OpenPOWER on IntegriCloud