diff --git a/mlir/include/mlir/IR/OperationSupport.h b/mlir/include/mlir/IR/OperationSupport.h --- a/mlir/include/mlir/IR/OperationSupport.h +++ b/mlir/include/mlir/IR/OperationSupport.h @@ -598,8 +598,8 @@ iterator_range getTypes() const { return {begin(), end()}; } private: - /// See `detail::indexed_accessor_range_base` for details. - static OpResult dereference_iterator(Operation *op, ptrdiff_t index); + /// See `indexed_accessor_range` for details. + static OpResult dereference(Operation *op, ptrdiff_t index); /// Allow access to `dereference_iterator`. friend indexed_accessor_range class indexed_accessor_range : public detail::indexed_accessor_range_base< - indexed_accessor_range, - std::pair, T, PointerT, ReferenceT> { + DerivedT, std::pair, T, PointerT, ReferenceT> { public: using detail::indexed_accessor_range_base< - indexed_accessor_range, - std::pair, T, PointerT, + DerivedT, std::pair, T, PointerT, ReferenceT>::indexed_accessor_range_base; /// Returns the current base of the range. @@ -306,14 +304,6 @@ /// Returns the current start index of the range. ptrdiff_t getStartIndex() const { return this->base.second; } -protected: - indexed_accessor_range(BaseT base, ptrdiff_t startIndex, ptrdiff_t count) - : detail::indexed_accessor_range_base< - indexed_accessor_range, - std::pair, T, PointerT, ReferenceT>( - std::make_pair(base, startIndex), count) {} - -private: /// See `detail::indexed_accessor_range_base` for details. static std::pair offset_base(const std::pair &base, ptrdiff_t index) { @@ -325,13 +315,14 @@ static ReferenceT dereference_iterator(const std::pair &base, ptrdiff_t index) { - return DerivedT::dereference_iterator(base.first, base.second + index); + return DerivedT::dereference(base.first, base.second + index); } - /// Allow access to `offset_base` and `dereference_iterator`. - friend detail::indexed_accessor_range_base< - indexed_accessor_range, - std::pair, T, PointerT, ReferenceT>; +protected: + indexed_accessor_range(BaseT base, ptrdiff_t startIndex, ptrdiff_t count) + : detail::indexed_accessor_range_base< + DerivedT, std::pair, T, PointerT, ReferenceT>( + std::make_pair(base, startIndex), count) {} }; /// Given a container of pairs, return a range over the second elements. diff --git a/mlir/lib/IR/OperationSupport.cpp b/mlir/lib/IR/OperationSupport.cpp --- a/mlir/lib/IR/OperationSupport.cpp +++ b/mlir/lib/IR/OperationSupport.cpp @@ -152,8 +152,8 @@ ResultRange::ResultRange(Operation *op) : ResultRange(op, /*startIndex=*/0, op->getNumResults()) {} -/// See `detail::indexed_accessor_range_base` for details. -OpResult ResultRange::dereference_iterator(Operation *op, ptrdiff_t index) { +/// See `indexed_accessor_range` for details. +OpResult ResultRange::dereference(Operation *op, ptrdiff_t index) { return op->getResult(index); }