proto_to_carbon.h 1.0 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_PROTO_TO_CARBON_H_
  5. #define CARBON_TESTING_FUZZING_PROTO_TO_CARBON_H_
  6. #include "common/error.h"
  7. #include "testing/fuzzing/carbon.pb.h"
  8. namespace Carbon {
  9. // Builds a Carbon source from `compilation_unit`. The logic tries to produce a
  10. // syntactially valid Carbon source for all cases, even if the input protocol
  11. // buffer is invalid (like a variable declaration with an empty `name` field).
  12. // This is done to reduce the number of inputs the fuzzer framework generates
  13. // when trying to produce lexically valid source.
  14. auto ProtoToCarbon(const Fuzzing::Carbon& proto, bool maybe_add_main)
  15. -> std::string;
  16. // Parses the textproto into a proto object.
  17. auto ParseCarbonTextProto(const std::string& contents)
  18. -> ErrorOr<Fuzzing::Carbon>;
  19. } // namespace Carbon
  20. #endif // CARBON_TESTING_FUZZING_PROTO_TO_CARBON_H_