mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-03 21:05:50 +01:00
Carbon fuzzing 3/3: added actual fuzzer implementation and a fuzzverter utility for investigating crashing protos (#1156)
* finished fuzzer and added fuzzverter util * fixed typo * renamed cmd line params * fixed libproto_mutator download path * small fixes * small fixes * small fixes * renamed sample corpus proto * small fixes * try building on github with LIBCPP_DEBUG enabled * temporarily marked proto fuzzer as a manual test * code review * use a dedicated proto-fuzzer feature to work around LIBCPP_DEBUG=1 crash in proto code * code review comments, added README.md * minor fixes to the text * Update bazel/cc_toolchains/clang_cc_toolchain_config.bzl Co-authored-by: Jon Meow <jperkins@google.com> * use Carbon source representation for "empty Main()" instead of text format proto representation * fixed typo * made FuzzerUtil produce the full carbon source (proto converted + Main if needed) to decrease code duplication a bit * typo * switched to text proto format per code review * Update executable_semantics/prelude.h Co-authored-by: Jon Meow <jperkins@google.com> * Update executable_semantics/fuzzing/README.md Co-authored-by: Jon Meow <jperkins@google.com> * Update executable_semantics/fuzzing/README.md Co-authored-by: Jon Meow <jperkins@google.com> * Update executable_semantics/fuzzing/README.md Co-authored-by: Jon Meow <jperkins@google.com> * Update executable_semantics/fuzzing/README.md Co-authored-by: Jon Meow <jperkins@google.com> * Update executable_semantics/fuzzing/README.md Co-authored-by: Jon Meow <jperkins@google.com> * review comments * removed unnecessary file mode variables * Update executable_semantics/fuzzing/fuzzverter.cpp Co-authored-by: Jon Meow <jperkins@google.com> * Update executable_semantics/fuzzing/README.md Co-authored-by: Jon Meow <jperkins@google.com> * Update executable_semantics/fuzzing/README.md Co-authored-by: Jon Meow <jperkins@google.com> * code review comments * Update executable_semantics/syntax/BUILD Co-authored-by: Jon Meow <jperkins@google.com> * buildifier Co-authored-by: Jon Meow <jperkins@google.com>
This commit is contained in:
committed by
GitHub
co-authored by
Jon Meow
parent
db0de1004f
commit
22462a0d7f
@@ -15,27 +15,10 @@
|
||||
#include "executable_semantics/common/nonnull.h"
|
||||
#include "executable_semantics/interpreter/exec_program.h"
|
||||
#include "executable_semantics/syntax/parse.h"
|
||||
#include "executable_semantics/syntax/prelude.h"
|
||||
#include "llvm/Support/CommandLine.h"
|
||||
#include "llvm/Support/InitLLVM.h"
|
||||
|
||||
// Adds the Carbon prelude to `declarations`.
|
||||
static void AddPrelude(
|
||||
std::string_view prelude_file_name, Carbon::Nonnull<Carbon::Arena*> arena,
|
||||
std::vector<Carbon::Nonnull<Carbon::Declaration*>>* declarations) {
|
||||
Carbon::ErrorOr<Carbon::AST> parse_result =
|
||||
Carbon::Parse(arena, prelude_file_name, false);
|
||||
if (!parse_result.ok()) {
|
||||
// Try again with tracing, to help diagnose the problem.
|
||||
Carbon::ErrorOr<Carbon::AST> trace_parse_result =
|
||||
Carbon::Parse(arena, prelude_file_name, true);
|
||||
FATAL() << "Failed to parse prelude: "
|
||||
<< trace_parse_result.error().message();
|
||||
}
|
||||
const auto& prelude = *parse_result;
|
||||
declarations->insert(declarations->begin(), prelude.declarations.begin(),
|
||||
prelude.declarations.end());
|
||||
}
|
||||
|
||||
// Prints an error message and returns error code value.
|
||||
auto PrintError(const Carbon::Error& error) -> int {
|
||||
llvm::errs() << error.message() << "\n";
|
||||
|
||||
Reference in New Issue
Block a user