fuzzer_util.h 985 B

123456789101112131415161718192021222324252627282930
  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_EXPLORER_FUZZING_FUZZER_UTIL_H_
  5. #define CARBON_EXPLORER_FUZZING_FUZZER_UTIL_H_
  6. #include "common/error.h"
  7. #include "common/fuzzing/carbon.pb.h"
  8. namespace Carbon {
  9. // Converts `compilation_unit` to Carbon. Adds an default `Main()`
  10. // definition if one is not present in the proto.
  11. auto ProtoToCarbonWithMain(const Fuzzing::CompilationUnit& compilation_unit)
  12. -> std::string;
  13. // Parses and executes a fuzzer-generated program.
  14. void ParseAndExecute(const Fuzzing::CompilationUnit& compilation_unit);
  15. namespace Internal {
  16. // Returns a full path for a file under bazel runfiles.
  17. // Exposed for testing.
  18. auto GetRunfilesFile(const std::string& file) -> ErrorOr<std::string>;
  19. } // namespace Internal
  20. } // namespace Carbon
  21. #endif // CARBON_EXPLORER_FUZZING_FUZZER_UTIL_H_