explorer_fuzzer.cpp 664 B

123456789101112131415161718
  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. #include <libprotobuf_mutator/src/libfuzzer/libfuzzer_macro.h>
  5. #include "common/error.h"
  6. #include "explorer/fuzzing/fuzzer_util.h"
  7. #include "llvm/Support/raw_ostream.h"
  8. DEFINE_TEXT_PROTO_FUZZER(const Carbon::Fuzzing::Carbon& input) {
  9. const auto result = Carbon::ParseAndExecute(input.compilation_unit());
  10. if (result.ok()) {
  11. llvm::outs() << "Executed OK: " << *result << "\n";
  12. } else {
  13. llvm::errs() << "Execution failed: " << result.error() << "\n";
  14. }
  15. }