Convert a chained if-else to a match.

It makes things a little clearer.
This commit is contained in:
Nicholas Nethercote 2020-03-26 13:53:03 +11:00
parent 87ef16c9dc
commit a50cca920d

View file

@ -751,11 +751,13 @@ pub(crate) unsafe fn codegen(
})?;
}
if config_emit_object_code {
match config.emit_obj {
EmitObj::ObjectCode(_) => {
if !config.no_integrated_as {
let _timer = cgcx
.prof
.generic_activity_with_arg("LLVM_module_codegen_emit_obj", &module.name[..]);
let _timer = cgcx.prof.generic_activity_with_arg(
"LLVM_module_codegen_emit_obj",
&module.name[..],
);
with_codegen(tm, llmod, config.no_builtins, |cpm| {
write_output_file(
diag_handler,
@ -767,17 +769,21 @@ pub(crate) unsafe fn codegen(
)
})?;
} else {
let _timer = cgcx
.prof
.generic_activity_with_arg("LLVM_module_codegen_asm_to_obj", &module.name[..]);
let assembly = cgcx.output_filenames.temp_path(OutputType::Assembly, module_name);
let _timer = cgcx.prof.generic_activity_with_arg(
"LLVM_module_codegen_asm_to_obj",
&module.name[..],
);
let assembly =
cgcx.output_filenames.temp_path(OutputType::Assembly, module_name);
run_assembler(cgcx, diag_handler, &assembly, &obj_out);
if !config.emit_asm && !cgcx.save_temps {
drop(fs::remove_file(&assembly));
}
}
} else if config.emit_obj == EmitObj::Bitcode {
}
EmitObj::Bitcode => {
debug!("copying bitcode {:?} to obj {:?}", bc_out, obj_out);
if let Err(e) = link_or_copy(&bc_out, &obj_out) {
diag_handler.err(&format!("failed to copy bitcode to object file: {}", e));
@ -791,6 +797,9 @@ pub(crate) unsafe fn codegen(
}
}
EmitObj::None => {}
}
drop(handlers);
}
Ok(module.into_compiled_module(