From 8db09e8e0a3a56b46f58cc09933508de009cdc2a Mon Sep 17 00:00:00 2001 From: Jules Villard Date: Mon, 8 Mar 2021 05:02:11 -0800 Subject: [PATCH] [pulse][minor] use List.concat_map in two places Reviewed By: skcho Differential Revision: D26818060 fbshipit-source-id: bd1ebc026 --- infer/src/pulse/Pulse.ml | 34 ++++++++++++---------------------- 1 file changed, 12 insertions(+), 22 deletions(-) diff --git a/infer/src/pulse/Pulse.ml b/infer/src/pulse/Pulse.ml index aff2518a7..0bbbc5cb9 100644 --- a/infer/src/pulse/Pulse.ml +++ b/infer/src/pulse/Pulse.ml @@ -237,18 +237,13 @@ module PulseTransferFunctions = struct L.d_printfln ~color:Pp.Orange "@\nExecuting injected instr:%a@\n@." (Sil.pp_instr Pp.text ~print_types:true) call_instr ; - List.fold - ~f:(fun astates (astate : Domain.t) -> + List.concat_map astate_list ~f:(fun (astate : Domain.t) -> match astate with | ISLLatentMemoryError _ | AbortProgram _ | ExitProgram _ | LatentAbortProgram _ -> - astate :: astates + [astate] | ContinueProgram astate -> - let astate = - dispatch_call analysis_data ret call_exp actuals location call_flags astate - |> PulseReport.report_results analysis_data - in - List.rev_append astate astates ) - ~init:[] astate_list + dispatch_call analysis_data ret call_exp actuals location call_flags astate + |> PulseReport.report_results analysis_data ) in let dynamic_types_unreachable = PulseOperations.get_dynamic_type_unreachable_values vars astate @@ -363,22 +358,17 @@ module PulseTransferFunctions = struct |> PulseReport.report_results analysis_data | Metadata (ExitScope (vars, location)) -> let remove_vars vars astates = - List.fold - ~f:(fun astates (astate : Domain.t) -> + List.concat_map astates ~f:(fun (astate : Domain.t) -> match astate with | ISLLatentMemoryError _ | AbortProgram _ | ExitProgram _ | LatentAbortProgram _ -> - astate :: astates + [astate] | ContinueProgram astate -> - let astate = - ( match PulseOperations.remove_vars tenv vars location astate with - | Ok astate -> - Ok [astate] - | Error _ as error -> - error ) - |> PulseReport.report_list_result analysis_data - in - List.rev_append astate astates ) - ~init:[] astates + ( match PulseOperations.remove_vars tenv vars location astate with + | Ok astate -> + Ok [astate] + | Error _ as error -> + error ) + |> PulseReport.report_list_result analysis_data ) in if Procname.is_java (Procdesc.get_proc_name proc_desc) then remove_vars vars [ContinueProgram astate]