master-next: Change TransformIterator to work with bidirectional iterators.

The custom DFS implementation for dominators in LLVM r307727 uses a reverse
iterator and so fails to build if SILBasicBlocks do not support that.
This commit is contained in:
Bob Wilson
2017-07-14 10:26:46 -07:00
parent 0b84388947
commit b87f9d0d4e

View File

@@ -392,7 +392,7 @@ makeFilterRange(Range range, Predicate pred) {
return FilterRange<Range, Predicate>(range, pred); return FilterRange<Range, Predicate>(range, pred);
} }
/// An iterator that transforms the result of an underlying forward /// An iterator that transforms the result of an underlying bidirectional
/// iterator with a given operation. /// iterator with a given operation.
/// ///
/// \tparam Iterator the underlying iterator. /// \tparam Iterator the underlying iterator.
@@ -411,7 +411,7 @@ class TransformIterator {
using OpTraits = function_traits<Operation>; using OpTraits = function_traits<Operation>;
public: public:
using iterator_category = std::forward_iterator_tag; using iterator_category = std::bidirectional_iterator_tag;
using value_type = typename OpTraits::result_type; using value_type = typename OpTraits::result_type;
using reference = value_type; using reference = value_type;
using pointer = void; // FIXME: Should provide a pointer proxy. using pointer = void; // FIXME: Should provide a pointer proxy.
@@ -438,6 +438,17 @@ public:
return old; return old;
} }
TransformIterator &operator--() {
--Current;
return *this;
}
TransformIterator operator--(int) {
TransformIterator old = *this;
--*this;
return old;
}
friend bool operator==(TransformIterator lhs, TransformIterator rhs) { friend bool operator==(TransformIterator lhs, TransformIterator rhs) {
return lhs.Current == rhs.Current; return lhs.Current == rhs.Current;
} }