[infer][ondemand] The source parameter from the analysis callback was never used

Summary: Some cleanup of the API

Reviewed By: sblackshear

Differential Revision: D4982235

fbshipit-source-id: edd7474
master
Jeremy Dubreil 8 years ago committed by Facebook Github Bot
parent 224c1fea86
commit b3af2ad4b6

@ -130,7 +130,7 @@ let iterate_callbacks call_graph exe_env =
(* analyze all the currently defined procedures *) (* analyze all the currently defined procedures *)
Cg.get_defined_nodes call_graph in Cg.get_defined_nodes call_graph in
let analyze_ondemand _ summary proc_desc = let analyze_ondemand summary proc_desc =
let proc_name = Procdesc.get_proc_name proc_desc in let proc_name = Procdesc.get_proc_name proc_desc in
iterate_procedure_callbacks exe_env summary proc_name in iterate_procedure_callbacks exe_env summary proc_name in

@ -1434,7 +1434,7 @@ let do_analysis_closures exe_env : Tasks.closure list =
Option.bind (Specs.get_summary proc_name) Option.bind (Specs.get_summary proc_name)
(fun summary -> summary.Specs.proc_desc_option) (fun summary -> summary.Specs.proc_desc_option)
| None -> None in | None -> None in
let analyze_ondemand _ _ proc_desc = let analyze_ondemand _ proc_desc =
let proc_name = Procdesc.get_proc_name proc_desc in let proc_name = Procdesc.get_proc_name proc_desc in
let tenv = Exe_env.get_tenv exe_env proc_name in let tenv = Exe_env.get_tenv exe_env proc_name in
if not (Procdesc.did_preanalysis proc_desc) if not (Procdesc.did_preanalysis proc_desc)

@ -27,7 +27,7 @@ let dirs_to_analyze =
changed_files String.Set.empty in changed_files String.Set.empty in
Option.map ~f:process_changed_files SourceFile.changed_files_set Option.map ~f:process_changed_files SourceFile.changed_files_set
type analyze_ondemand = SourceFile.t -> Specs.summary -> Procdesc.t -> Specs.summary type analyze_ondemand = Specs.summary -> Procdesc.t -> Specs.summary
type get_proc_desc = Typ.Procname.t -> Procdesc.t option type get_proc_desc = Typ.Procname.t -> Procdesc.t option
@ -131,28 +131,18 @@ let run_proc_analysis ~propagate_exceptions analyze_proc curr_pdesc callee_pdesc
incr nesting; incr nesting;
let attributes_opt = let attributes_opt =
Specs.proc_resolve_attributes callee_pname in Specs.proc_resolve_attributes callee_pname in
let source =
Option.value_map
~f:(fun (attributes : ProcAttributes.t) ->
let attribute_pname = attributes.proc_name in
if not (Typ.Procname.equal callee_pname attribute_pname) then
failwith ("ERROR: "^(Typ.Procname.to_string callee_pname)
^" not equal to "^(Typ.Procname.to_string attribute_pname));
attributes.loc.file)
~default:SourceFile.invalid
attributes_opt in
let callee_pdesc_option = let callee_pdesc_option =
if Config.dynamic_dispatch = `Lazy if Config.dynamic_dispatch = `Lazy
then Some callee_pdesc then Some callee_pdesc
else None in else None in
let initial_summary = Specs.reset_summary callee_pname attributes_opt callee_pdesc_option in let initial_summary = Specs.reset_summary callee_pname attributes_opt callee_pdesc_option in
Specs.set_status callee_pname Specs.Active; Specs.set_status callee_pname Specs.Active;
source, initial_summary in initial_summary in
let postprocess source summary = let postprocess summary =
decr nesting; decr nesting;
Specs.store_summary summary; Specs.store_summary summary;
Printer.write_proc_html source callee_pdesc; Printer.write_proc_html callee_pdesc;
log_elapsed_time (); log_elapsed_time ();
summary in summary in
@ -167,11 +157,11 @@ let run_proc_analysis ~propagate_exceptions analyze_proc curr_pdesc callee_pdesc
new_summary in new_summary in
let old_state = save_global_state () in let old_state = save_global_state () in
let source, initial_summary = preprocess () in let initial_summary = preprocess () in
try try
let summary = let summary =
analyze_proc source initial_summary callee_pdesc analyze_proc initial_summary callee_pdesc
|> postprocess source in |> postprocess in
restore_global_state old_state; restore_global_state old_state;
summary summary
with exn -> with exn ->

@ -15,7 +15,7 @@ open! IStd
will be analyzed *) will be analyzed *)
val dirs_to_analyze : String.Set.t option val dirs_to_analyze : String.Set.t option
type analyze_ondemand = SourceFile.t -> Specs.summary -> Procdesc.t -> Specs.summary type analyze_ondemand = Specs.summary -> Procdesc.t -> Specs.summary
type get_proc_desc = Typ.Procname.t -> Procdesc.t option type get_proc_desc = Typ.Procname.t -> Procdesc.t option

@ -416,10 +416,11 @@ let node_finish_session node =
(** Write html file for the procedure. (** Write html file for the procedure.
The boolean indicates whether to print whole seconds only *) The boolean indicates whether to print whole seconds only *)
let write_proc_html source pdesc = let write_proc_html pdesc =
if Config.write_html then if Config.write_html then
begin begin
let pname = Procdesc.get_proc_name pdesc in let pname = Procdesc.get_proc_name pdesc in
let source = (Procdesc.get_loc pdesc).file in
let nodes = List.sort ~cmp:Procdesc.Node.compare (Procdesc.get_nodes pdesc) in let nodes = List.sort ~cmp:Procdesc.Node.compare (Procdesc.get_nodes pdesc) in
let linenum = (Procdesc.Node.get_loc (List.hd_exn nodes)).Location.line in let linenum = (Procdesc.Node.get_loc (List.hd_exn nodes)).Location.line in
let fd, fmt = let fd, fmt =

@ -46,7 +46,7 @@ val node_is_visited : Procdesc.Node.t -> bool * bool
val node_start_session : Procdesc.Node.t -> int -> unit val node_start_session : Procdesc.Node.t -> int -> unit
(** Write html file for the procedure. *) (** Write html file for the procedure. *)
val write_proc_html : SourceFile.t -> Procdesc.t -> unit val write_proc_html : Procdesc.t -> unit
(** Create filename.ext.html for each file in the cluster. *) (** Create filename.ext.html for each file in the cluster. *)
val write_all_html_files : Cluster.t -> unit val write_all_html_files : Cluster.t -> unit

@ -110,7 +110,7 @@ let tests =
make_load_fld ~rhs_typ:(Typ.mk Tvoid) lhs_id_str fld_str (Exp.Var (ident_of_str root_str)) in make_load_fld ~rhs_typ:(Typ.mk Tvoid) lhs_id_str fld_str (Exp.Var (ident_of_str root_str)) in
let assert_empty = invariant "{ }" in let assert_empty = invariant "{ }" in
(* hack: register an empty analyze_ondemand to prevent a crash because the callback is unset *) (* hack: register an empty analyze_ondemand to prevent a crash because the callback is unset *)
let analyze_ondemand _ summary _ = summary in let analyze_ondemand summary _ = summary in
let get_proc_desc _ = None in let get_proc_desc _ = None in
let callbacks = let callbacks =
{ {

Loading…
Cancel
Save