libfuzzer.h 1.1 KB

123456789101112131415161718192021222324252627
  1. // Part of the Carbon Language project, under the Apache License v2.0 with LLVM
  2. // Exceptions. See /LICENSE for license information.
  3. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. #ifndef CARBON_TESTING_FUZZING_LIBFUZZER_H_
  5. #define CARBON_TESTING_FUZZING_LIBFUZZER_H_
  6. #include <cstddef>
  7. namespace Carbon::Testing {
  8. // Declaration for the LLVM libfuzzer API that we implement in our fuzz tests.
  9. // This is useful to ensure we get the API correct and avoid warnings about
  10. // defining an undeclared extern function due to a Clang warning bug:
  11. // https://github.com/llvm/llvm-project/issues/94138
  12. // NOLINTNEXTLINE: Match the documented fuzzer entry point declaration style.
  13. extern "C" int LLVMFuzzerTestOneInput(const unsigned char* data,
  14. std::size_t size);
  15. // Optional API that can be implemented but isn't required. This allows fuzzers
  16. // to observe the `argv` during initialization.
  17. // NOLINTNEXTLINE: Match the documented fuzzer entry point declaration style.
  18. extern "C" int LLVMFuzzerInitialize(int* argc, char*** argv);
  19. } // namespace Carbon::Testing
  20. #endif // CARBON_TESTING_FUZZING_LIBFUZZER_H_