Files
wasmtime/cranelift/isle/fuzz/fuzz_targets/compile.rs
Nick Fitzgerald a099b2b590 Extend fuzzing to semantic analysis and codegen
* Fix a panic when we are substituting macro args, but we already had an error
  involving the macro.

* Fix a stack overflow when an internal extractor's definition is recursive.
2021-11-11 15:56:55 -08:00

33 lines
789 B
Rust

#![no_main]
use libfuzzer_sys::fuzz_target;
fuzz_target!(|s: &str| {
let _ = env_logger::try_init();
let lexer = isle::lexer::Lexer::from_str(s, "fuzz-input.isle");
log::debug!("lexer = {:?}", lexer);
let lexer = match lexer {
Ok(l) => l,
Err(_) => return,
};
let defs = isle::parser::parse(lexer);
log::debug!("defs = {:?}", defs);
let defs = match defs {
Ok(d) => d,
Err(_) => return,
};
let code = isle::compile::compile(&defs);
log::debug!("code = {:?}", code);
let code = match code {
Ok(c) => c,
Err(_) => return,
};
// TODO: check that the generated code is valid Rust. This will require
// stubbing out extern types, extractors, and constructors.
drop(code);
});