Add front/back accessors to indexed_accessor_range.

These map to the similar accessors on ArrayRef and other random access containers.

This fixes a compilation error on MLIR ODS for variadic operands/results, which relied on the availability of front in certain situations.
This commit is contained in:
River Riddle 2020-06-29 22:37:05 -07:00
parent f01d9e6fc3
commit 6b9a706200
2 changed files with 14 additions and 0 deletions

View File

@ -1121,6 +1121,14 @@ public:
assert(index < size() && "invalid index for value range");
return DerivedT::dereference_iterator(base, index);
}
ReferenceT front() const {
assert(!empty() && "expected non-empty range");
return (*this)[0];
}
ReferenceT back() const {
assert(!empty() && "expected non-empty range");
return (*this)[size() - 1];
}
/// Compare this range with another.
template <typename OtherT> bool operator==(const OtherT &other) const {

View File

@ -124,6 +124,12 @@ def MixedNormalVariadicOperandOp : TEST_Op<
Variadic<AnyTensor>:$input3
);
}
def VariadicWithSameOperandsResult :
TEST_Op<"variadic_with_same_operand_results",
[SameOperandsAndResultType]> {
let arguments = (ins Variadic<AnySignlessInteger>:$operands);
let results = (outs AnySignlessInteger:$result);
}
//===----------------------------------------------------------------------===//
// Test Results