Internal change
PiperOrigin-RevId: 477704374
diff --git a/fuzztest/internal/meta.h b/fuzztest/internal/meta.h
index d03d9e5..9a918e1 100644
--- a/fuzztest/internal/meta.h
+++ b/fuzztest/internal/meta.h
@@ -225,7 +225,7 @@
auto BindAggregate(T&, std::integral_constant<int, 0>) {
return std::tie();
}
-// Implement the overloads from 1 to 32.
+// Implement the overloads from 1 to 64.
// There is no "variadic" way of doing this.
#define FUZZTEST_INTERNAL_BIND_AGGREGATE_(n, ...) \
template <typename T> \
@@ -305,18 +305,200 @@
x11, x12, x13, x14, x15, x16, x17, x18, x19,
x20, x21, x22, x23, x24, x25, x26, x27, x28,
x29, x30, x31, x32);
+FUZZTEST_INTERNAL_BIND_AGGREGATE_(33, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10,
+ x11, x12, x13, x14, x15, x16, x17, x18, x19,
+ x20, x21, x22, x23, x24, x25, x26, x27, x28,
+ x29, x30, x31, x32, x33);
+FUZZTEST_INTERNAL_BIND_AGGREGATE_(34, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10,
+ x11, x12, x13, x14, x15, x16, x17, x18, x19,
+ x20, x21, x22, x23, x24, x25, x26, x27, x28,
+ x29, x30, x31, x32, x33, x34);
+FUZZTEST_INTERNAL_BIND_AGGREGATE_(35, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10,
+ x11, x12, x13, x14, x15, x16, x17, x18, x19,
+ x20, x21, x22, x23, x24, x25, x26, x27, x28,
+ x29, x30, x31, x32, x33, x34, x35);
+FUZZTEST_INTERNAL_BIND_AGGREGATE_(36, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10,
+ x11, x12, x13, x14, x15, x16, x17, x18, x19,
+ x20, x21, x22, x23, x24, x25, x26, x27, x28,
+ x29, x30, x31, x32, x33, x34, x35, x36);
+FUZZTEST_INTERNAL_BIND_AGGREGATE_(37, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10,
+ x11, x12, x13, x14, x15, x16, x17, x18, x19,
+ x20, x21, x22, x23, x24, x25, x26, x27, x28,
+ x29, x30, x31, x32, x33, x34, x35, x36, x37);
+FUZZTEST_INTERNAL_BIND_AGGREGATE_(38, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10,
+ x11, x12, x13, x14, x15, x16, x17, x18, x19,
+ x20, x21, x22, x23, x24, x25, x26, x27, x28,
+ x29, x30, x31, x32, x33, x34, x35, x36, x37,
+ x38);
+FUZZTEST_INTERNAL_BIND_AGGREGATE_(39, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10,
+ x11, x12, x13, x14, x15, x16, x17, x18, x19,
+ x20, x21, x22, x23, x24, x25, x26, x27, x28,
+ x29, x30, x31, x32, x33, x34, x35, x36, x37,
+ x38, x39);
+FUZZTEST_INTERNAL_BIND_AGGREGATE_(40, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10,
+ x11, x12, x13, x14, x15, x16, x17, x18, x19,
+ x20, x21, x22, x23, x24, x25, x26, x27, x28,
+ x29, x30, x31, x32, x33, x34, x35, x36, x37,
+ x38, x39, x40);
+FUZZTEST_INTERNAL_BIND_AGGREGATE_(41, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10,
+ x11, x12, x13, x14, x15, x16, x17, x18, x19,
+ x20, x21, x22, x23, x24, x25, x26, x27, x28,
+ x29, x30, x31, x32, x33, x34, x35, x36, x37,
+ x38, x39, x40, x41);
+FUZZTEST_INTERNAL_BIND_AGGREGATE_(42, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10,
+ x11, x12, x13, x14, x15, x16, x17, x18, x19,
+ x20, x21, x22, x23, x24, x25, x26, x27, x28,
+ x29, x30, x31, x32, x33, x34, x35, x36, x37,
+ x38, x39, x40, x41, x42);
+FUZZTEST_INTERNAL_BIND_AGGREGATE_(43, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10,
+ x11, x12, x13, x14, x15, x16, x17, x18, x19,
+ x20, x21, x22, x23, x24, x25, x26, x27, x28,
+ x29, x30, x31, x32, x33, x34, x35, x36, x37,
+ x38, x39, x40, x41, x42, x43);
+FUZZTEST_INTERNAL_BIND_AGGREGATE_(44, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10,
+ x11, x12, x13, x14, x15, x16, x17, x18, x19,
+ x20, x21, x22, x23, x24, x25, x26, x27, x28,
+ x29, x30, x31, x32, x33, x34, x35, x36, x37,
+ x38, x39, x40, x41, x42, x43, x44);
+FUZZTEST_INTERNAL_BIND_AGGREGATE_(45, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10,
+ x11, x12, x13, x14, x15, x16, x17, x18, x19,
+ x20, x21, x22, x23, x24, x25, x26, x27, x28,
+ x29, x30, x31, x32, x33, x34, x35, x36, x37,
+ x38, x39, x40, x41, x42, x43, x44, x45);
+FUZZTEST_INTERNAL_BIND_AGGREGATE_(46, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10,
+ x11, x12, x13, x14, x15, x16, x17, x18, x19,
+ x20, x21, x22, x23, x24, x25, x26, x27, x28,
+ x29, x30, x31, x32, x33, x34, x35, x36, x37,
+ x38, x39, x40, x41, x42, x43, x44, x45, x46);
+FUZZTEST_INTERNAL_BIND_AGGREGATE_(47, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10,
+ x11, x12, x13, x14, x15, x16, x17, x18, x19,
+ x20, x21, x22, x23, x24, x25, x26, x27, x28,
+ x29, x30, x31, x32, x33, x34, x35, x36, x37,
+ x38, x39, x40, x41, x42, x43, x44, x45, x46,
+ x47);
+FUZZTEST_INTERNAL_BIND_AGGREGATE_(48, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10,
+ x11, x12, x13, x14, x15, x16, x17, x18, x19,
+ x20, x21, x22, x23, x24, x25, x26, x27, x28,
+ x29, x30, x31, x32, x33, x34, x35, x36, x37,
+ x38, x39, x40, x41, x42, x43, x44, x45, x46,
+ x47, x48);
+FUZZTEST_INTERNAL_BIND_AGGREGATE_(49, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10,
+ x11, x12, x13, x14, x15, x16, x17, x18, x19,
+ x20, x21, x22, x23, x24, x25, x26, x27, x28,
+ x29, x30, x31, x32, x33, x34, x35, x36, x37,
+ x38, x39, x40, x41, x42, x43, x44, x45, x46,
+ x47, x48, x49);
+FUZZTEST_INTERNAL_BIND_AGGREGATE_(50, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10,
+ x11, x12, x13, x14, x15, x16, x17, x18, x19,
+ x20, x21, x22, x23, x24, x25, x26, x27, x28,
+ x29, x30, x31, x32, x33, x34, x35, x36, x37,
+ x38, x39, x40, x41, x42, x43, x44, x45, x46,
+ x47, x48, x49, x50);
+FUZZTEST_INTERNAL_BIND_AGGREGATE_(51, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10,
+ x11, x12, x13, x14, x15, x16, x17, x18, x19,
+ x20, x21, x22, x23, x24, x25, x26, x27, x28,
+ x29, x30, x31, x32, x33, x34, x35, x36, x37,
+ x38, x39, x40, x41, x42, x43, x44, x45, x46,
+ x47, x48, x49, x50, x51);
+FUZZTEST_INTERNAL_BIND_AGGREGATE_(52, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10,
+ x11, x12, x13, x14, x15, x16, x17, x18, x19,
+ x20, x21, x22, x23, x24, x25, x26, x27, x28,
+ x29, x30, x31, x32, x33, x34, x35, x36, x37,
+ x38, x39, x40, x41, x42, x43, x44, x45, x46,
+ x47, x48, x49, x50, x51, x52);
+FUZZTEST_INTERNAL_BIND_AGGREGATE_(53, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10,
+ x11, x12, x13, x14, x15, x16, x17, x18, x19,
+ x20, x21, x22, x23, x24, x25, x26, x27, x28,
+ x29, x30, x31, x32, x33, x34, x35, x36, x37,
+ x38, x39, x40, x41, x42, x43, x44, x45, x46,
+ x47, x48, x49, x50, x51, x52, x53);
+FUZZTEST_INTERNAL_BIND_AGGREGATE_(54, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10,
+ x11, x12, x13, x14, x15, x16, x17, x18, x19,
+ x20, x21, x22, x23, x24, x25, x26, x27, x28,
+ x29, x30, x31, x32, x33, x34, x35, x36, x37,
+ x38, x39, x40, x41, x42, x43, x44, x45, x46,
+ x47, x48, x49, x50, x51, x52, x53, x54);
+FUZZTEST_INTERNAL_BIND_AGGREGATE_(55, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10,
+ x11, x12, x13, x14, x15, x16, x17, x18, x19,
+ x20, x21, x22, x23, x24, x25, x26, x27, x28,
+ x29, x30, x31, x32, x33, x34, x35, x36, x37,
+ x38, x39, x40, x41, x42, x43, x44, x45, x46,
+ x47, x48, x49, x50, x51, x52, x53, x54, x55);
+FUZZTEST_INTERNAL_BIND_AGGREGATE_(56, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10,
+ x11, x12, x13, x14, x15, x16, x17, x18, x19,
+ x20, x21, x22, x23, x24, x25, x26, x27, x28,
+ x29, x30, x31, x32, x33, x34, x35, x36, x37,
+ x38, x39, x40, x41, x42, x43, x44, x45, x46,
+ x47, x48, x49, x50, x51, x52, x53, x54, x55,
+ x56);
+FUZZTEST_INTERNAL_BIND_AGGREGATE_(57, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10,
+ x11, x12, x13, x14, x15, x16, x17, x18, x19,
+ x20, x21, x22, x23, x24, x25, x26, x27, x28,
+ x29, x30, x31, x32, x33, x34, x35, x36, x37,
+ x38, x39, x40, x41, x42, x43, x44, x45, x46,
+ x47, x48, x49, x50, x51, x52, x53, x54, x55,
+ x56, x57);
+FUZZTEST_INTERNAL_BIND_AGGREGATE_(58, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10,
+ x11, x12, x13, x14, x15, x16, x17, x18, x19,
+ x20, x21, x22, x23, x24, x25, x26, x27, x28,
+ x29, x30, x31, x32, x33, x34, x35, x36, x37,
+ x38, x39, x40, x41, x42, x43, x44, x45, x46,
+ x47, x48, x49, x50, x51, x52, x53, x54, x55,
+ x56, x57, x58);
+FUZZTEST_INTERNAL_BIND_AGGREGATE_(59, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10,
+ x11, x12, x13, x14, x15, x16, x17, x18, x19,
+ x20, x21, x22, x23, x24, x25, x26, x27, x28,
+ x29, x30, x31, x32, x33, x34, x35, x36, x37,
+ x38, x39, x40, x41, x42, x43, x44, x45, x46,
+ x47, x48, x49, x50, x51, x52, x53, x54, x55,
+ x56, x57, x58, x59);
+FUZZTEST_INTERNAL_BIND_AGGREGATE_(60, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10,
+ x11, x12, x13, x14, x15, x16, x17, x18, x19,
+ x20, x21, x22, x23, x24, x25, x26, x27, x28,
+ x29, x30, x31, x32, x33, x34, x35, x36, x37,
+ x38, x39, x40, x41, x42, x43, x44, x45, x46,
+ x47, x48, x49, x50, x51, x52, x53, x54, x55,
+ x56, x57, x58, x59, x60);
+FUZZTEST_INTERNAL_BIND_AGGREGATE_(61, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10,
+ x11, x12, x13, x14, x15, x16, x17, x18, x19,
+ x20, x21, x22, x23, x24, x25, x26, x27, x28,
+ x29, x30, x31, x32, x33, x34, x35, x36, x37,
+ x38, x39, x40, x41, x42, x43, x44, x45, x46,
+ x47, x48, x49, x50, x51, x52, x53, x54, x55,
+ x56, x57, x58, x59, x60, x61);
+FUZZTEST_INTERNAL_BIND_AGGREGATE_(62, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10,
+ x11, x12, x13, x14, x15, x16, x17, x18, x19,
+ x20, x21, x22, x23, x24, x25, x26, x27, x28,
+ x29, x30, x31, x32, x33, x34, x35, x36, x37,
+ x38, x39, x40, x41, x42, x43, x44, x45, x46,
+ x47, x48, x49, x50, x51, x52, x53, x54, x55,
+ x56, x57, x58, x59, x60, x61, x62);
+FUZZTEST_INTERNAL_BIND_AGGREGATE_(63, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10,
+ x11, x12, x13, x14, x15, x16, x17, x18, x19,
+ x20, x21, x22, x23, x24, x25, x26, x27, x28,
+ x29, x30, x31, x32, x33, x34, x35, x36, x37,
+ x38, x39, x40, x41, x42, x43, x44, x45, x46,
+ x47, x48, x49, x50, x51, x52, x53, x54, x55,
+ x56, x57, x58, x59, x60, x61, x62, x63);
+FUZZTEST_INTERNAL_BIND_AGGREGATE_(64, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10,
+ x11, x12, x13, x14, x15, x16, x17, x18, x19,
+ x20, x21, x22, x23, x24, x25, x26, x27, x28,
+ x29, x30, x31, x32, x33, x34, x35, x36, x37,
+ x38, x39, x40, x41, x42, x43, x44, x45, x46,
+ x47, x48, x49, x50, x51, x52, x53, x54, x55,
+ x56, x57, x58, x59, x60, x61, x62, x63, x64);
#undef FUZZTEST_INTERNAL_BIND_AGGREGATE_
-// For N > 32, use std::get<I>.
+// For N > 64, use std::get<I>.
// Some aggregate types like std::tuple provide this protocol, but so can user
// defined types.
template <typename T, int N>
auto BindAggregate(T& value, std::integral_constant<int, N>) {
- static_assert(N > 32);
+ static_assert(N > 64);
if constexpr (std::is_aggregate_v<T> &&
!Requires<T>([](auto v) -> decltype(std::get<0>(v)) {})) {
static_assert(always_false<T>,
- "Aggregate types are only supported up to 32 fields.");
+ "Aggregate types are only supported up to 64 fields.");
}
// For the rest use the tuple API
return ApplyIndex<N>(
@@ -333,8 +515,21 @@
}
};
+// Try to call ApplyIndex from I all the way down to 0.
+template <size_t I, typename F>
+constexpr std::optional<int> ApplyIndexFor(F f) {
+ if constexpr (ApplyIndex<I>(f)) {
+ return I;
+ }
+ if constexpr (I == 0) {
+ return std::nullopt;
+ } else {
+ return ApplyIndexFor<I - 1>(f);
+ }
+}
+
// Try applying aggregate initialization to `T` with different number of
-// arguments. We start at 32 and go down until one works.
+// arguments. We start at 64 and go down until one works.
template <typename T>
constexpr std::optional<int> DetectBraceInitCount() {
constexpr auto can_init_impl =
@@ -344,75 +539,9 @@
};
if constexpr (!std::is_aggregate_v<T>) {
return std::nullopt;
- } else if constexpr (ApplyIndex<32>(can_init)) {
- return 32;
- } else if constexpr (ApplyIndex<31>(can_init)) {
- return 31;
- } else if constexpr (ApplyIndex<30>(can_init)) {
- return 30;
- } else if constexpr (ApplyIndex<29>(can_init)) {
- return 29;
- } else if constexpr (ApplyIndex<28>(can_init)) {
- return 28;
- } else if constexpr (ApplyIndex<27>(can_init)) {
- return 27;
- } else if constexpr (ApplyIndex<26>(can_init)) {
- return 26;
- } else if constexpr (ApplyIndex<25>(can_init)) {
- return 25;
- } else if constexpr (ApplyIndex<24>(can_init)) {
- return 24;
- } else if constexpr (ApplyIndex<23>(can_init)) {
- return 23;
- } else if constexpr (ApplyIndex<22>(can_init)) {
- return 22;
- } else if constexpr (ApplyIndex<21>(can_init)) {
- return 21;
- } else if constexpr (ApplyIndex<20>(can_init)) {
- return 20;
- } else if constexpr (ApplyIndex<19>(can_init)) {
- return 19;
- } else if constexpr (ApplyIndex<18>(can_init)) {
- return 18;
- } else if constexpr (ApplyIndex<17>(can_init)) {
- return 17;
- } else if constexpr (ApplyIndex<16>(can_init)) {
- return 16;
- } else if constexpr (ApplyIndex<15>(can_init)) {
- return 15;
- } else if constexpr (ApplyIndex<14>(can_init)) {
- return 14;
- } else if constexpr (ApplyIndex<13>(can_init)) {
- return 13;
- } else if constexpr (ApplyIndex<12>(can_init)) {
- return 12;
- } else if constexpr (ApplyIndex<11>(can_init)) {
- return 11;
- } else if constexpr (ApplyIndex<10>(can_init)) {
- return 10;
- } else if constexpr (ApplyIndex<9>(can_init)) {
- return 9;
- } else if constexpr (ApplyIndex<8>(can_init)) {
- return 8;
- } else if constexpr (ApplyIndex<7>(can_init)) {
- return 7;
- } else if constexpr (ApplyIndex<6>(can_init)) {
- return 6;
- } else if constexpr (ApplyIndex<5>(can_init)) {
- return 5;
- } else if constexpr (ApplyIndex<4>(can_init)) {
- return 4;
- } else if constexpr (ApplyIndex<3>(can_init)) {
- return 3;
- } else if constexpr (ApplyIndex<2>(can_init)) {
- return 2;
- } else if constexpr (ApplyIndex<1>(can_init)) {
- return 1;
- } else if constexpr (ApplyIndex<0>(can_init)) {
- return 0;
- } else {
- return std::nullopt;
}
+
+ return ApplyIndexFor<64>(can_init);
}
// This allows us to determine whether T has a base class. If it does, it is