aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVitaly Buka <vitalybuka@google.com>2022-05-20 14:35:31 -0700
committerVitaly Buka <vitalybuka@google.com>2022-05-20 14:35:31 -0700
commita304ec48dcf15d942607032151f7e9ee504b5dcf (patch)
treee33780fffebc5091bf36c358008376e2112761a7
parent6fb07304b470964178ba2c66f235dd3c3dc06f15 (diff)
downloadlibprotobuf-mutator-a304ec48dcf15d942607032151f7e9ee504b5dcf.tar.gz
Support -std=c++20
-rw-r--r--src/libfuzzer/libfuzzer_macro.h32
1 files changed, 23 insertions, 9 deletions
diff --git a/src/libfuzzer/libfuzzer_macro.h b/src/libfuzzer/libfuzzer_macro.h
index 1a1fe0a..02ac1c0 100644
--- a/src/libfuzzer/libfuzzer_macro.h
+++ b/src/libfuzzer/libfuzzer_macro.h
@@ -82,14 +82,15 @@
using PostProcessorRegistration = \
protobuf_mutator::libfuzzer::PostProcessorRegistration<Proto>;
-#define DEFINE_PROTO_FUZZER_IMPL(use_binary, arg) \
- static void TestOneProtoInput(arg); \
- using FuzzerProtoType = std::remove_const<std::remove_reference< \
- std::function<decltype(TestOneProtoInput)>::argument_type>::type>::type; \
- DEFINE_CUSTOM_PROTO_MUTATOR_IMPL(use_binary, FuzzerProtoType) \
- DEFINE_CUSTOM_PROTO_CROSSOVER_IMPL(use_binary, FuzzerProtoType) \
- DEFINE_TEST_ONE_PROTO_INPUT_IMPL(use_binary, FuzzerProtoType) \
- DEFINE_POST_PROCESS_PROTO_MUTATION_IMPL(FuzzerProtoType) \
+#define DEFINE_PROTO_FUZZER_IMPL(use_binary, arg) \
+ static void TestOneProtoInput(arg); \
+ using FuzzerProtoType = \
+ protobuf_mutator::libfuzzer::macro_internal::GetFirstParam< \
+ decltype(&TestOneProtoInput)>::type; \
+ DEFINE_CUSTOM_PROTO_MUTATOR_IMPL(use_binary, FuzzerProtoType) \
+ DEFINE_CUSTOM_PROTO_CROSSOVER_IMPL(use_binary, FuzzerProtoType) \
+ DEFINE_TEST_ONE_PROTO_INPUT_IMPL(use_binary, FuzzerProtoType) \
+ DEFINE_POST_PROCESS_PROTO_MUTATION_IMPL(FuzzerProtoType) \
static void TestOneProtoInput(arg)
namespace protobuf_mutator {
@@ -123,7 +124,20 @@ struct PostProcessorRegistration {
}
};
+namespace macro_internal {
+
+template <typename T>
+struct GetFirstParam;
+
+template <class Arg>
+struct GetFirstParam<void (*)(Arg)> {
+ using type = typename std::remove_const<
+ typename std::remove_reference<Arg>::type>::type;
+};
+
+} // namespace macro_internal
+
} // namespace libfuzzer
} // namespace protobuf_mutator
-#endif // SRC_LIBFUZZER_LIBFUZZER_MACRO_H_
+#endif // SRC_LIBFUZZER_LIBFUZZER_MACRO_H_ \ No newline at end of file