From be5656486cbf061d09fda56c029aa75cb7b6184d Mon Sep 17 00:00:00 2001 From: Andre Maroneze <andre.maroneze@cea.fr> Date: Mon, 8 Feb 2021 09:24:12 +0100 Subject: [PATCH] [kernel] File: minor refactoring --- src/kernel_services/ast_queries/file.ml | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/kernel_services/ast_queries/file.ml b/src/kernel_services/ast_queries/file.ml index 6e654c7ba99..7c3f748eae6 100644 --- a/src/kernel_services/ast_queries/file.ml +++ b/src/kernel_services/ast_queries/file.ml @@ -1706,20 +1706,18 @@ let check_source_hashes expected actual_table = fp hash (Option.value ~default:("<none> (not in list)") expected_hash) ) actual_table +let print_and_exit cpp_commands = + let print_cpp_cmd (cpp_cmd, _ppf, _) = + Kernel.result "Preprocessing command:@.%s" cpp_cmd + in + List.iter (fun (_f, ocmd) -> Option.iter print_cpp_cmd ocmd) cpp_commands; + raise Cmdline.Exit + let prepare_from_c_files () = init_cil (); let files = Files.get () in (* Allow pre-registration of prolog files *) let cpp_commands = List.map (fun f -> (f, build_cpp_cmd f)) files in - if Kernel.PrintCppCommands.get () then begin - List.iter (fun (_f, opt_cpp_cmd) -> - match opt_cpp_cmd with - | None -> () - | Some (cpp_cmd, _ppf, _) -> - Kernel.result - "Preprocessing command:@.%s" cpp_cmd - ) cpp_commands; - raise Cmdline.Exit - end; + if Kernel.PrintCppCommands.get () then print_and_exit cpp_commands; let audit_check_path = Kernel.AuditCheck.get () in if not (Filepath.Normalized.is_unknown audit_check_path) then begin let all_sources_tbl = compute_sources_table cpp_commands in -- GitLab