Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove the Mutate wrapper for the old interface. #1429

Merged
merged 1 commit into from
Nov 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions fuzztest/internal/domains/aggregate_of_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,6 @@ class AggregateOfImpl
using typename AggregateOfImpl::DomainBase::corpus_type;
using typename AggregateOfImpl::DomainBase::value_type;

using AggregateOfImpl::DomainBase::Mutate;

AggregateOfImpl() = default;
explicit AggregateOfImpl(std::in_place_t, Inner... inner)
: inner_(std::move(inner)...) {}
Expand Down
14 changes: 0 additions & 14 deletions fuzztest/internal/domains/arbitrary_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,6 @@ class ArbitraryImpl<T, std::enable_if_t<is_monostate_v<T>>>
public:
using typename ArbitraryImpl::DomainBase::value_type;

using ArbitraryImpl::DomainBase::Mutate;

value_type Init(absl::BitGenRef) { return value_type{}; }

void Mutate(value_type&, absl::BitGenRef,
Expand All @@ -93,8 +91,6 @@ template <>
class ArbitraryImpl<bool>
: public domain_implementor::DomainBase<ArbitraryImpl<bool>> {
public:
using ArbitraryImpl::DomainBase::Mutate;

value_type Init(absl::BitGenRef prng) {
if (auto seed = MaybeGetRandomSeed(prng)) return *seed;
return static_cast<bool>(absl::Uniform(prng, 0, 2));
Expand Down Expand Up @@ -126,8 +122,6 @@ class ArbitraryImpl<T, std::enable_if_t<!std::is_const_v<T> &&
public:
using typename ArbitraryImpl::DomainBase::value_type;

using ArbitraryImpl::DomainBase::Mutate;

static constexpr bool is_memory_dictionary_compatible_v =
sizeof(T) == 1 || sizeof(T) == 2 || sizeof(T) == 4 || sizeof(T) == 8;
using IntegerDictionaryT =
Expand Down Expand Up @@ -226,8 +220,6 @@ class ArbitraryImpl<std::byte>
using typename ArbitraryImpl::DomainBase::corpus_type;
using typename ArbitraryImpl::DomainBase::value_type;

using ArbitraryImpl::DomainBase::Mutate;

value_type Init(absl::BitGenRef prng) {
if (auto seed = this->MaybeGetRandomSeed(prng)) return *seed;
return std::byte{inner_.Init(prng)};
Expand Down Expand Up @@ -260,8 +252,6 @@ class ArbitraryImpl<T, std::enable_if_t<std::is_floating_point_v<T>>>
public:
using typename ArbitraryImpl::DomainBase::value_type;

using ArbitraryImpl::DomainBase::Mutate;

value_type Init(absl::BitGenRef prng) {
if (auto seed = this->MaybeGetRandomSeed(prng)) return *seed;
return ChooseOneOr(SpecialValues<T>::Get(), prng,
Expand Down Expand Up @@ -335,8 +325,6 @@ class ArbitraryImpl<std::basic_string_view<Char>>
using typename ArbitraryImpl::DomainBase::corpus_type;
using typename ArbitraryImpl::DomainBase::value_type;

using ArbitraryImpl::DomainBase::Mutate;

corpus_type Init(absl::BitGenRef prng) {
if (auto seed = this->MaybeGetRandomSeed(prng)) return *seed;
return inner_.Init(prng);
Expand Down Expand Up @@ -396,8 +384,6 @@ class ArbitraryImpl<absl::string_view>
using typename ArbitraryImpl::DomainBase::corpus_type;
using typename ArbitraryImpl::DomainBase::value_type;

using ArbitraryImpl::DomainBase::Mutate;

corpus_type Init(absl::BitGenRef prng) {
if (auto seed = this->MaybeGetRandomSeed(prng)) return *seed;
return inner_.Init(prng);
Expand Down
2 changes: 0 additions & 2 deletions fuzztest/internal/domains/bit_flag_combination_of_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ class BitFlagCombinationOfImpl
public:
using typename BitFlagCombinationOfImpl::DomainBase::value_type;

using BitFlagCombinationOfImpl::DomainBase::Mutate;

explicit BitFlagCombinationOfImpl(absl::Span<const T> flags)
: flags_(flags.begin(), flags.end()), all_flags_combo_{} {
FUZZTEST_INTERNAL_CHECK_PRECONDITION(
Expand Down
2 changes: 0 additions & 2 deletions fuzztest/internal/domains/container_of_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,6 @@ class ContainerOfImplBase : public domain_implementor::DomainBase<
using typename ContainerOfImplBase::DomainBase::corpus_type;
using typename ContainerOfImplBase::DomainBase::value_type;

using ContainerOfImplBase::DomainBase::Mutate;

// Some container mutation only applies to vector or string types which do
// not have a custom corpus type.
static constexpr bool is_vector_or_string =
Expand Down
9 changes: 0 additions & 9 deletions fuzztest/internal/domains/domain_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,15 +131,6 @@ class DomainBase {
}
}

// Mutates `corpus_value` using `prng`, `only_shirnk` and the default mutation
// metadata. This is a temporary wrapper that redirects the call to the real
// interface with an explicit argument for metadata.
void Mutate(corpus_type& corpus_value, absl::BitGenRef prng,
bool only_shrink) {
return derived().Mutate(corpus_value, prng, MutationMetadata{},
only_shrink);
}

// Returns a random user value from the domain. In general, doesn't provide
// guarantees on the distribution of the returned values.
//
Expand Down
2 changes: 0 additions & 2 deletions fuzztest/internal/domains/element_of_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@ class ElementOfImpl
using typename ElementOfImpl::DomainBase::corpus_type;
using typename ElementOfImpl::DomainBase::value_type;

using ElementOfImpl::DomainBase::Mutate;

explicit ElementOfImpl(std::vector<T> values) : values_(values) {
FUZZTEST_INTERNAL_CHECK_PRECONDITION(
!values.empty(), "ElementOf requires a non empty list.");
Expand Down
2 changes: 0 additions & 2 deletions fuzztest/internal/domains/filter_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ class FilterImpl
using typename FilterImpl::DomainBase::corpus_type;
using typename FilterImpl::DomainBase::value_type;

using FilterImpl::DomainBase::Mutate;

FilterImpl() = default;
explicit FilterImpl(std::function<bool(const T&)> predicate, Domain<T> inner)
: predicate_(std::move(predicate)), inner_(std::move(inner)) {}
Expand Down
2 changes: 0 additions & 2 deletions fuzztest/internal/domains/flat_map_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,6 @@ class FlatMapImpl
using typename FlatMapImpl::DomainBase::corpus_type;
using typename FlatMapImpl::DomainBase::value_type;

using FlatMapImpl::DomainBase::Mutate;

FlatMapImpl() = default;
explicit FlatMapImpl(FlatMapper flat_mapper, InputDomain... input_domains)
: flat_mapper_(std::move(flat_mapper)),
Expand Down
2 changes: 0 additions & 2 deletions fuzztest/internal/domains/in_grammar_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -651,8 +651,6 @@ class InGrammarImpl
using typename InGrammarImpl::DomainBase::corpus_type;
using typename InGrammarImpl::DomainBase::value_type;

using InGrammarImpl::DomainBase::Mutate;

ASTNode Init(absl::BitGenRef prng) {
if (auto seed = this->MaybeGetRandomSeed(prng)) return *seed;
return TopDomain::Init(prng);
Expand Down
2 changes: 0 additions & 2 deletions fuzztest/internal/domains/in_range_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ class InRangeImpl : public domain_implementor::DomainBase<InRangeImpl<T>> {
public:
using typename InRangeImpl::DomainBase::value_type;

using InRangeImpl::DomainBase::Mutate;

constexpr static bool T_is_integer = std::numeric_limits<T>::is_integer;
constexpr static bool T_is_signed = std::is_signed<T>::value;
constexpr static bool T_is_memory_dictionary_compatible =
Expand Down
2 changes: 0 additions & 2 deletions fuzztest/internal/domains/in_regexp_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@ class InRegexpImpl
: public domain_implementor::DomainBase<InRegexpImpl, std::string,
DFAPath> {
public:
using InRegexpImpl::DomainBase::Mutate;

explicit InRegexpImpl(std::string_view regex_str)
: regex_str_(regex_str), dfa_(RegexpDFA::Create(regex_str_)) {}

Expand Down
4 changes: 0 additions & 4 deletions fuzztest/internal/domains/map_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@ class MapImpl
using typename MapImpl::DomainBase::corpus_type;
using typename MapImpl::DomainBase::value_type;

using MapImpl::DomainBase::Mutate;

MapImpl() = default;
explicit MapImpl(Mapper mapper, Inner... inner)
: mapper_(std::move(mapper)), inner_(std::move(inner)...) {}
Expand Down Expand Up @@ -123,8 +121,6 @@ class ReversibleMapImpl
using typename ReversibleMapImpl::DomainBase::corpus_type;
using typename ReversibleMapImpl::DomainBase::value_type;

using ReversibleMapImpl::DomainBase::Mutate;

static_assert(
std::is_invocable_v<InvMapper, const value_type&> &&
std::is_same_v<std::invoke_result_t<InvMapper, const value_type&>,
Expand Down
2 changes: 0 additions & 2 deletions fuzztest/internal/domains/one_of_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@ class OneOfImpl
using typename OneOfImpl::DomainBase::corpus_type;
using typename OneOfImpl::DomainBase::value_type;

using OneOfImpl::DomainBase::Mutate;

// All value_types of inner domains must be the same. (Though note that they
// can have different corpus_types!)
static_assert(
Expand Down
2 changes: 0 additions & 2 deletions fuzztest/internal/domains/optional_of_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,6 @@ class OptionalOfImpl
using typename OptionalOfImpl::DomainBase::corpus_type;
using typename OptionalOfImpl::DomainBase::value_type;

using OptionalOfImpl::DomainBase::Mutate;

static_assert(Requires<T>([](auto x) -> std::void_t<decltype(!x, *x),
typename T::value_type> {
}),
Expand Down
2 changes: 0 additions & 2 deletions fuzztest/internal/domains/overlap_of_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ class OverlapOfImpl
using typename OverlapOfImpl::DomainBase::corpus_type;
using typename OverlapOfImpl::DomainBase::value_type;

using OverlapOfImpl::DomainBase::Mutate;

static_assert(
std::conjunction_v<std::is_same<value_type, value_type_t<Inner>>...>,
"All overlapping domains must have the same value_type.");
Expand Down
6 changes: 0 additions & 6 deletions fuzztest/internal/domains/protobuf_domain_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -431,8 +431,6 @@ class ProtobufDomainUntypedImpl
using typename ProtobufDomainUntypedImpl::DomainBase::corpus_type;
using typename ProtobufDomainUntypedImpl::DomainBase::value_type;

using ProtobufDomainUntypedImpl::DomainBase::Mutate;

explicit ProtobufDomainUntypedImpl(PrototypePtr<Message> prototype,
bool use_lazy_initialization)
: prototype_(std::move(prototype)),
Expand Down Expand Up @@ -1796,8 +1794,6 @@ class ProtobufDomainImpl
using typename ProtobufDomainImpl::DomainBase::value_type;
using FieldDescriptor = ProtobufFieldDescriptor<typename T::Message>;

using ProtobufDomainImpl::DomainBase::Mutate;

corpus_type Init(absl::BitGenRef prng) {
if (auto seed = this->MaybeGetRandomSeed(prng)) return *seed;
return inner_.Init(prng);
Expand Down Expand Up @@ -2250,8 +2246,6 @@ class ArbitraryImpl<T, std::enable_if_t<is_protocol_buffer_enum_v<T>>>
public:
using typename ArbitraryImpl::DomainBase::value_type;

using ArbitraryImpl::DomainBase::Mutate;

value_type Init(absl::BitGenRef prng) {
if (auto seed = this->MaybeGetRandomSeed(prng)) return *seed;
const int index = absl::Uniform(prng, 0, descriptor()->value_count());
Expand Down
2 changes: 0 additions & 2 deletions fuzztest/internal/domains/smart_pointer_of_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@ class SmartPointerOfImpl
using typename SmartPointerOfImpl::DomainBase::corpus_type;
using typename SmartPointerOfImpl::DomainBase::value_type;

using SmartPointerOfImpl::DomainBase::Mutate;

static_assert(
Requires<T>(
[](auto x) -> std::enable_if_t<std::is_pointer_v<decltype(x.get())>,
Expand Down
2 changes: 0 additions & 2 deletions fuzztest/internal/domains/unique_elements_container_of_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,6 @@ class UniqueElementsContainerImpl
using typename UniqueElementsContainerImpl::DomainBase::corpus_type;
using typename UniqueElementsContainerImpl::DomainBase::value_type;

using UniqueElementsContainerImpl::DomainBase::Mutate;

UniqueElementsContainerImpl() = default;
explicit UniqueElementsContainerImpl(InnerDomain inner)
: unique_domain_(std::move(inner)) {}
Expand Down
2 changes: 0 additions & 2 deletions fuzztest/internal/domains/variant_of_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ class VariantOfImpl : public domain_implementor::DomainBase<
using typename VariantOfImpl::DomainBase::corpus_type;
using typename VariantOfImpl::DomainBase::value_type;

using VariantOfImpl::DomainBase::Mutate;

VariantOfImpl() = default;
explicit VariantOfImpl(std::in_place_t, Inner... inner)
: inner_(std::move(inner)...) {}
Expand Down
Loading