Skip to content

Commit a304ec4

Browse files
committed
Support -std=c++20
1 parent 6fb0730 commit a304ec4

File tree

1 file changed

+23
-9
lines changed

1 file changed

+23
-9
lines changed

src/libfuzzer/libfuzzer_macro.h

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -82,14 +82,15 @@
8282
using PostProcessorRegistration = \
8383
protobuf_mutator::libfuzzer::PostProcessorRegistration<Proto>;
8484

85-
#define DEFINE_PROTO_FUZZER_IMPL(use_binary, arg) \
86-
static void TestOneProtoInput(arg); \
87-
using FuzzerProtoType = std::remove_const<std::remove_reference< \
88-
std::function<decltype(TestOneProtoInput)>::argument_type>::type>::type; \
89-
DEFINE_CUSTOM_PROTO_MUTATOR_IMPL(use_binary, FuzzerProtoType) \
90-
DEFINE_CUSTOM_PROTO_CROSSOVER_IMPL(use_binary, FuzzerProtoType) \
91-
DEFINE_TEST_ONE_PROTO_INPUT_IMPL(use_binary, FuzzerProtoType) \
92-
DEFINE_POST_PROCESS_PROTO_MUTATION_IMPL(FuzzerProtoType) \
85+
#define DEFINE_PROTO_FUZZER_IMPL(use_binary, arg) \
86+
static void TestOneProtoInput(arg); \
87+
using FuzzerProtoType = \
88+
protobuf_mutator::libfuzzer::macro_internal::GetFirstParam< \
89+
decltype(&TestOneProtoInput)>::type; \
90+
DEFINE_CUSTOM_PROTO_MUTATOR_IMPL(use_binary, FuzzerProtoType) \
91+
DEFINE_CUSTOM_PROTO_CROSSOVER_IMPL(use_binary, FuzzerProtoType) \
92+
DEFINE_TEST_ONE_PROTO_INPUT_IMPL(use_binary, FuzzerProtoType) \
93+
DEFINE_POST_PROCESS_PROTO_MUTATION_IMPL(FuzzerProtoType) \
9394
static void TestOneProtoInput(arg)
9495

9596
namespace protobuf_mutator {
@@ -123,7 +124,20 @@ struct PostProcessorRegistration {
123124
}
124125
};
125126

127+
namespace macro_internal {
128+
129+
template <typename T>
130+
struct GetFirstParam;
131+
132+
template <class Arg>
133+
struct GetFirstParam<void (*)(Arg)> {
134+
using type = typename std::remove_const<
135+
typename std::remove_reference<Arg>::type>::type;
136+
};
137+
138+
} // namespace macro_internal
139+
126140
} // namespace libfuzzer
127141
} // namespace protobuf_mutator
128142

129-
#endif // SRC_LIBFUZZER_LIBFUZZER_MACRO_H_
143+
#endif // SRC_LIBFUZZER_LIBFUZZER_MACRO_H_

0 commit comments

Comments
 (0)