From f627b1e554679cfc0820f63aab987ce0e2ce4e37 Mon Sep 17 00:00:00 2001 From: Chandler Carruth Date: Thu, 24 Apr 2014 05:33:53 +0000 Subject: [PATCH] Use the shiny new iterator adaptor tool to implement the value_op_iterator. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@207078 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/IR/User.h | 59 +++++------------------------------------- 1 file changed, 6 insertions(+), 53 deletions(-) diff --git a/include/llvm/IR/User.h b/include/llvm/IR/User.h index 66442e82df0..453b6ad1699 100644 --- a/include/llvm/IR/User.h +++ b/include/llvm/IR/User.h @@ -19,6 +19,7 @@ #ifndef LLVM_IR_USER_H #define LLVM_IR_USER_H +#include "llvm/ADT/iterator.h" #include "llvm/ADT/iterator_range.h" #include "llvm/IR/Value.h" #include "llvm/Support/ErrorHandling.h" @@ -129,61 +130,13 @@ public: /// Convenience iterator for directly iterating over the Values in the /// OperandList - class value_op_iterator - : public std::iterator { - op_iterator OI; - public: - explicit value_op_iterator(Use *U = nullptr) : OI(U) {} + struct value_op_iterator + : iterator_adaptor_base { + explicit value_op_iterator(Use *U = nullptr) : iterator_adaptor_base(U) {} - bool operator==(const value_op_iterator &x) const { - return OI == x.OI; - } - bool operator!=(const value_op_iterator &x) const { - return !operator==(x); - } - - value_op_iterator &operator+=(ptrdiff_t n) { - OI += n; - return *this; - } - value_op_iterator &operator-=(ptrdiff_t n) { - OI -= n; - return *this; - } - value_op_iterator operator+(ptrdiff_t n) const { - return value_op_iterator(OI + n); - } - friend value_op_iterator operator+(ptrdiff_t n, - const value_op_iterator &i) { - return i + n; - } - value_op_iterator operator-(ptrdiff_t n) const { - return value_op_iterator(OI - n); - } - ptrdiff_t operator-(const value_op_iterator &RHS) const { - return OI - RHS.OI; - } - bool operator<(const value_op_iterator &RHS) const { return OI < RHS.OI; } - bool operator>(const value_op_iterator &RHS) const { return OI > RHS.OI; } - bool operator<=(const value_op_iterator &RHS) const { return OI <= RHS.OI; } - bool operator>=(const value_op_iterator &RHS) const { return OI >= RHS.OI; } - value_op_iterator &operator++() { return *this += 1; } - value_op_iterator &operator--() { return *this -= 1; } - value_op_iterator operator++(int) { - value_op_iterator tmp = *this; - ++*this; - return tmp; - } - value_op_iterator operator--(int) { - value_op_iterator tmp = *this; - --*this; - return tmp; - } - - Value *operator*() const { return *OI; } + Value *operator*() const { return *I; } Value *operator->() const { return operator*(); } - Value *operator[](ptrdiff_t n) const { return *(*this + n); } }; inline value_op_iterator value_op_begin() {