r246452 - [OpenMP] base specific_clause_iterator on iterator_adaptor_base.

Benjamin Kramer via cfe-commits cfe-commits at lists.llvm.org
Mon Aug 31 09:45:36 PDT 2015


Author: d0k
Date: Mon Aug 31 11:45:35 2015
New Revision: 246452

URL: http://llvm.org/viewvc/llvm-project?rev=246452&view=rev
Log:
[OpenMP] base specific_clause_iterator on iterator_adaptor_base.

Removes some boilerplate code. No functionality change intended.

Modified:
    cfe/trunk/include/clang/AST/StmtOpenMP.h

Modified: cfe/trunk/include/clang/AST/StmtOpenMP.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/StmtOpenMP.h?rev=246452&r1=246451&r2=246452&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/StmtOpenMP.h (original)
+++ cfe/trunk/include/clang/AST/StmtOpenMP.h Mon Aug 31 11:45:35 2015
@@ -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>




More information about the cfe-commits mailing list