diff --git a/infer/src/backend/preanal.ml b/infer/src/backend/preanal.ml index 632082302..1a0767d9c 100644 --- a/infer/src/backend/preanal.ml +++ b/infer/src/backend/preanal.ml @@ -11,7 +11,7 @@ open! Utils (** mutate the cfg/cg to add dynamic dispatch handling *) -let add_dispatch_calls cfg cg tenv f_translate_typ_opt = +let add_dispatch_calls pdesc cg tenv f_translate_typ_opt = let pname_translate_types pname = match f_translate_typ_opt with | Some f_translate_typ -> @@ -78,12 +78,11 @@ let add_dispatch_calls cfg cg tenv f_translate_typ_opt = if has_dispatch_call instrs then IList.map replace_dispatch_calls instrs |> Cfg.Node.replace_instrs node in - let proc_add_dispach_calls pname pdesc = - Cfg.Procdesc.iter_nodes (node_add_dispatch_calls pname) pdesc in - Cfg.iter_proc_desc cfg proc_add_dispach_calls + let pname = Cfg.Procdesc.get_proc_name pdesc in + Cfg.Procdesc.iter_nodes (node_add_dispatch_calls pname) pdesc (** add instructions to perform abstraction *) -let add_abstraction_instructions cfg = +let add_abstraction_instructions pdesc = let open Cfg in (* true if there is a succ node s.t.: it is an exit node, or the succ of >1 nodes *) let converging_node node = @@ -106,11 +105,10 @@ let add_abstraction_instructions cfg = | Node.Prune_node _ | Node.Skip_node _ -> converging_node node in - let all_nodes = Node.get_all_nodes cfg in let do_node node = let loc = Node.get_last_loc node in if node_requires_abstraction node then Node.append_instrs node [Sil.Abstract loc] in - IList.iter do_node all_nodes + Cfg.Procdesc.iter_nodes do_node pdesc module BackwardCfg = ProcCfg.Backward(ProcCfg.Exceptional) @@ -180,7 +178,7 @@ module NullifyAnalysis = (Scheduler.ReversePostorder (ProcCfg.Exceptional)) (NullifyTransferFunctions) -let add_nullify_instrs tenv _ pdesc = +let add_nullify_instrs pdesc tenv = let liveness_proc_cfg = BackwardCfg.from_pdesc pdesc in let proc_data_no_extras = ProcData.make_default pdesc tenv in let liveness_inv_map = LivenessAnalysis.exec_cfg liveness_proc_cfg proc_data_no_extras in @@ -239,8 +237,8 @@ let add_nullify_instrs tenv _ pdesc = let exit_node = ProcCfg.Exceptional.exit_node nullify_proc_cfg in node_add_nullify_instructions exit_node (AddressTaken.Domain.elements address_taken_vars) -let doit ?(f_translate_typ=None) cfg cg tenv = - Cfg.iter_proc_desc cfg (add_nullify_instrs tenv); +let doit ?(f_translate_typ=None) pdesc cg tenv = + add_nullify_instrs pdesc tenv; if !Config.curr_language = Config.Java - then add_dispatch_calls cfg cg tenv f_translate_typ; - add_abstraction_instructions cfg; + then add_dispatch_calls pdesc cg tenv f_translate_typ; + add_abstraction_instructions pdesc; diff --git a/infer/src/backend/preanal.mli b/infer/src/backend/preanal.mli index 6570e003c..0c4856dda 100644 --- a/infer/src/backend/preanal.mli +++ b/infer/src/backend/preanal.mli @@ -13,5 +13,5 @@ open! Utils (** Preanalysis for eliminating dead local variables *) (** Perform liveness analysis *) -val doit : ?f_translate_typ:(Tenv.t -> string -> unit) option -> Cfg.cfg -> Cg.t -> Tenv.t +val doit : ?f_translate_typ:(Tenv.t -> string -> unit) option -> Cfg.Procdesc.t -> Cg.t -> Tenv.t -> unit diff --git a/infer/src/clang/cFrontend.ml b/infer/src/clang/cFrontend.ml index 6c40c0dd8..5c70a385b 100644 --- a/infer/src/clang/cFrontend.ml +++ b/infer/src/clang/cFrontend.ml @@ -66,7 +66,7 @@ let do_source_file source_file ast = let tenv_file = DB.source_dir_get_internal_file source_dir ".tenv" in let cfg_file = DB.source_dir_get_internal_file source_dir ".cfg" in let cg_file = DB.source_dir_get_internal_file source_dir ".cg" in - Preanal.doit cfg call_graph tenv; + Cfg.iter_proc_desc cfg (fun _ pdesc -> Preanal.doit pdesc call_graph tenv); Cg.store_to_file cg_file call_graph; Cfg.store_cfg_to_file cfg_file true cfg; (*Logging.out "Tenv %a@." Sil.pp_tenv tenv;*) diff --git a/infer/src/java/jMain.ml b/infer/src/java/jMain.ml index e6ad71e63..0dbc6d70f 100644 --- a/infer/src/java/jMain.ml +++ b/infer/src/java/jMain.ml @@ -51,7 +51,9 @@ let store_icfg tenv cg cfg program = let cfg_file = DB.source_dir_get_internal_file source_dir ".cfg" in let cg_file = DB.source_dir_get_internal_file source_dir ".cg" in if Config.create_harness then Harness.create_harness cfg cg tenv; - Preanal.doit ~f_translate_typ:(Some f_translate_typ) cfg cg tenv; + Cfg.iter_proc_desc + cfg + (fun _ pdesc -> Preanal.doit ~f_translate_typ:(Some f_translate_typ) pdesc cg tenv); Cg.store_to_file cg_file cg; Cfg.store_cfg_to_file cfg_file true cfg; if Config.debug_mode then diff --git a/infer/src/llvm/lMain.ml b/infer/src/llvm/lMain.ml index 96fa4e1ca..4f0772582 100644 --- a/infer/src/llvm/lMain.ml +++ b/infer/src/llvm/lMain.ml @@ -35,7 +35,7 @@ let store_icfg tenv cg cfg = let get_internal_file = DB.source_dir_get_internal_file source_dir in let cg_file = get_internal_file ".cg" in let cfg_file = get_internal_file ".cfg" in - Preanal.doit cfg cg tenv; + Cfg.iter_proc_desc cfg (fun _ pdesc -> Preanal.doit pdesc cg tenv); Cg.store_to_file cg_file cg; Cfg.store_cfg_to_file cfg_file true cfg; if Config.debug_mode then