Skip to content
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
4 changes: 1 addition & 3 deletions tools/fuzzer/constraints.cc
Original file line number Diff line number Diff line change
Expand Up @@ -228,9 +228,7 @@ TypeConstraints TypeConstraints::allowed_to_point_to() const {
}

if (std::holds_alternative<AnyType>(ptr_types_)) {
TypeConstraints retval = TypeConstraints::all();
retval.scalar_types_[ScalarType::Void] = false;
return retval;
return TypeConstraints::all_non_void();
}

const auto* specific_types_ptr =
Expand Down
4 changes: 2 additions & 2 deletions tools/fuzzer/constraints.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,9 @@ class TypeConstraints {
return retval;
}

static TypeConstraints all() {
static TypeConstraints all_non_void() {
TypeConstraints retval;
retval.scalar_types_ = ScalarMask::all_set();
retval.scalar_types_ = ~ScalarMask(ScalarType::Void);
retval.tagged_types_ = AnyType{};
retval.ptr_types_ = AnyType{};
retval.array_types_ = AnyType{};
Expand Down
10 changes: 5 additions & 5 deletions tools/fuzzer/constraints_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ TEST(Constraints, ScalarValues) {
TypeConstraints float_only = FLOAT_TYPES;
TypeConstraints int_only = INT_TYPES;

TypeConstraints any = TypeConstraints::all();
TypeConstraints any = TypeConstraints::all_non_void();
TypeConstraints none;

PointerType void_ptr_type{QualifiedType(ScalarType::Void)};
Expand Down Expand Up @@ -85,7 +85,7 @@ TEST(Constraints, TaggedTypes) {
EXPECT_THAT(test_struct.allows_non_void_pointer(), IsFalse());
EXPECT_THAT(test_struct.allows_void_pointer(), IsFalse());

TypeConstraints any = TypeConstraints::all();
TypeConstraints any = TypeConstraints::all_non_void();
TypeConstraints none;

EXPECT_THAT(any.allows_tagged_types(), IsTrue());
Expand Down Expand Up @@ -159,7 +159,7 @@ TEST(Constraints, PointerTypes) {
// void types :(
EXPECT_THAT(void_constraints.allows_any_of(ScalarType::Void), IsFalse());

TypeConstraints any = TypeConstraints::all();
TypeConstraints any = TypeConstraints::all_non_void();
TypeConstraints none;

EXPECT_THAT(any.allows_type(const_int_ptr), IsTrue());
Expand All @@ -176,7 +176,7 @@ TEST(Constraints, EnumTypes) {
EnumType unscoped_enum("UnscopedEnum", false);
EnumType specific_enum("SpecificEnum", true);

TypeConstraints any = TypeConstraints::all();
TypeConstraints any = TypeConstraints::all_non_void();
TypeConstraints none;
TypeConstraints bool_ctx = TypeConstraints::all_in_bool_ctx();
TypeConstraints only_specific = TypeConstraints(specific_enum);
Expand Down Expand Up @@ -217,7 +217,7 @@ TEST(Constraints, ArrayTypes) {
ArrayType array_of_ptrs = ArrayType(int_ptr, 3);
PointerType ptr_to_array = PointerType(QualifiedType(array_of_three));

TypeConstraints any = TypeConstraints::all();
TypeConstraints any = TypeConstraints::all_non_void();
EXPECT_THAT(any.allows_type(array_of_three), IsTrue());
EXPECT_THAT(any.allows_type(array_of_four), IsTrue());
EXPECT_THAT(any.allows_type(array2d), IsTrue());
Expand Down
2 changes: 1 addition & 1 deletion tools/fuzzer/expr_gen.cc
Original file line number Diff line number Diff line change
Expand Up @@ -903,7 +903,7 @@ std::optional<Expr> ExprGenerator::gen_sizeof_expr_impl(
return SizeofExpr(std::move(maybe_type.value()));
}

auto maybe_expr = gen_with_weights(weights, TypeConstraints::all());
auto maybe_expr = gen_with_weights(weights, TypeConstraints::all_non_void());
if (!maybe_expr.has_value()) {
return {};
}
Expand Down