[Support] Use a custom base class for FormatVariadicTest.cpp (NFC)
This patch replaces None with a custom base class in FormatVariadicTest.cpp. As part of the migration from llvm::Optional to std::optional, I'd like to define None as std::nullopt, but FormatVariadicTest.cpp blocks that. When you specialize indexed_accessor_range with the base class being None, the template instantiation eventually generates code to compare two instances of None. That's not guaranteed with std::nullopt. Replacing None with a custom base class allows me to define None as std::nullopt. This is part of an effort to migrate from llvm::Optional to std::optional: https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716 Differential Revision: https://reviews.llvm.org/D138381
This commit is contained in:
parent
a59ed8fa86
commit
a365f293dc
|
@ -706,20 +706,21 @@ TEST(FormatVariadicTest, FormatFilterRange) {
|
|||
|
||||
namespace {
|
||||
|
||||
enum class Base { First };
|
||||
|
||||
class IntegerValuesRange final
|
||||
: public indexed_accessor_range<IntegerValuesRange, NoneType, int, int *,
|
||||
int> {
|
||||
: public indexed_accessor_range<IntegerValuesRange, Base, int, int *, int> {
|
||||
public:
|
||||
using indexed_accessor_range<IntegerValuesRange, NoneType, int, int *,
|
||||
using indexed_accessor_range<IntegerValuesRange, Base, int, int *,
|
||||
int>::indexed_accessor_range;
|
||||
|
||||
static int dereference(const NoneType &, ptrdiff_t Index) {
|
||||
static int dereference(const Base &, ptrdiff_t Index) {
|
||||
return static_cast<int>(Index);
|
||||
}
|
||||
};
|
||||
|
||||
TEST(FormatVariadicTest, FormatRangeNonRef) {
|
||||
IntegerValuesRange Range(None, 0, 3);
|
||||
IntegerValuesRange Range(Base(), 0, 3);
|
||||
EXPECT_EQ("0, 1, 2",
|
||||
formatv("{0}", make_range(Range.begin(), Range.end())).str());
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue