From b3cf7f911ba901b7a5b2268e31fb6af8725feb5b Mon Sep 17 00:00:00 2001 From: Nick Fitzgerald Date: Wed, 2 Oct 2019 15:41:43 -0700 Subject: [PATCH] clif-util: Make the `-t` flag work with the `wasm` subcommand (#1105) * clif-util: Make the `-t` flag work with the `wasm` subcommand The presence of the flag was checked in the code, so it was essentially already supported, but it was not properly configured when constructing the CLI arguments parser. * clif-util: also enable the `-c` flag for the `wasm` subcommand Similar to the parent commit, this functionality is already supported, just a mix up of the CLI parser construction made it not show up. --- cranelift/src/clif-util.rs | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/cranelift/src/clif-util.rs b/cranelift/src/clif-util.rs index 676e9d334f..0c6110f024 100755 --- a/cranelift/src/clif-util.rs +++ b/cranelift/src/clif-util.rs @@ -119,6 +119,18 @@ fn add_enable_multi_value<'a>() -> clap::Arg<'a, 'a> { .help("Enable WASM's multi-value support") } +fn add_just_decode_flag<'a>() -> clap::Arg<'a, 'a> { + Arg::with_name("just-decode") + .short("t") + .help("Just decode into Cranelift IR") +} + +fn add_check_translation_flag<'a>() -> clap::Arg<'a, 'a> { + Arg::with_name("check-translation") + .short("c") + .help("Just checks the correctness of Cranelift IR translated from WebAssembly") +} + /// Returns a vector of clap value options and changes these options into a vector of strings fn get_vec(argument_vec: Option) -> Vec { let mut ret_vec: Vec = Vec::new(); @@ -151,6 +163,8 @@ fn add_wasm_or_compile<'a>(cmd: &str) -> clap::App<'a, 'a> { .arg(add_debug_flag()) .arg(add_enable_simd_flag()) .arg(add_enable_multi_value()) + .arg(add_just_decode_flag()) + .arg(add_check_translation_flag()) } fn handle_debug_flag(debug: bool) { @@ -191,17 +205,7 @@ fn main() { .arg(add_input_file_arg()) .arg(add_debug_flag()), ) - .subcommand( - add_wasm_or_compile("compile") - .arg( - Arg::with_name("just-decode") - .short("t") - .help("Just decode WebAssembly to Cranelift IR"), - ) - .arg(Arg::with_name("check-translation").short("c").help( - "Just checks the correctness of Cranelift IR translated from WebAssembly", - )), - ) + .subcommand(add_wasm_or_compile("compile")) .subcommand( add_wasm_or_compile("wasm").arg( Arg::with_name("value-ranges")