Remove proc_desc from proc_callback_args

Summary:
The record `proc_callback_args` (defined in `callbacks.ml`) contains the fields `proc_desc` and `summary`.

The field `proc_desc` is redundant because it can be obtained from `summary`.

This diff removes `proc_desc` and uses the summary to obtain it where needed.

Reviewed By: ngorogiannis

Differential Revision: D16090783

fbshipit-source-id: 5632d1f4a
master
Phoebe Nichols 5 years ago committed by Facebook Github Bot
parent ae4f7561b3
commit 13c2c84897

@ -14,7 +14,6 @@ type proc_callback_args =
; tenv: Tenv.t
; integer_type_widths: Typ.IntegerWidths.t
; summary: Summary.t
; proc_desc: Procdesc.t
; exe_env: Exe_env.t }
type proc_callback_t = proc_callback_args -> Summary.t
@ -77,9 +76,7 @@ let iterate_procedure_callbacks exe_env summary proc_desc =
log_begin_event logger ~name ~categories:["backend"]
~arguments:[("proc", `String (Typ.Procname.to_string proc_name))]
() )) ;
let summary =
callback {get_procs_in_file; tenv; integer_type_widths; summary; proc_desc; exe_env}
in
let summary = callback {get_procs_in_file; tenv; integer_type_widths; summary; exe_env} in
PerfEvent.(log (fun logger -> log_end_event logger ())) ;
summary )
else summary )

@ -14,7 +14,6 @@ type proc_callback_args =
; tenv: Tenv.t
; integer_type_widths: Typ.IntegerWidths.t
; summary: Summary.t
; proc_desc: Procdesc.t
; exe_env: Exe_env.t }
(** Type of a procedure callback:

@ -1249,7 +1249,8 @@ let analyze_procedure_aux summary exe_env tenv proc_desc : Summary.t =
summary_compact
let analyze_procedure {Callbacks.summary; proc_desc; tenv; exe_env} : Summary.t =
let analyze_procedure {Callbacks.summary; tenv; exe_env} : Summary.t =
let proc_desc = Summary.get_proc_desc summary in
(* make sure models have been registered *)
BuiltinDefn.init () ;
if Topl.is_active () then Topl.instrument tenv proc_desc ;

@ -368,7 +368,8 @@ let compute_summary :
let do_analysis : Callbacks.proc_callback_args -> Summary.t =
fun {proc_desc; tenv; integer_type_widths; summary} ->
fun {tenv; integer_type_widths; summary} ->
let proc_desc = Summary.get_proc_desc summary in
let inv_map = cached_compute_invariant_map proc_desc tenv integer_type_widths in
let locals = get_local_decls proc_desc in
let formals = Procdesc.get_pvar_formals proc_desc in

@ -422,7 +422,8 @@ let get_checks_summary : BufferOverrunAnalysis.local_decls -> checks -> checks_s
let checker : Callbacks.proc_callback_args -> Summary.t =
fun {proc_desc; tenv; integer_type_widths; summary} ->
fun {tenv; integer_type_widths; summary} ->
let proc_desc = Summary.get_proc_desc summary in
let inv_map =
BufferOverrunAnalysis.cached_compute_invariant_map proc_desc tenv integer_type_widths
in

@ -270,7 +270,8 @@ end
module Analyzer = LowerHil.MakeAbstractInterpreter (TransferFunctions (ProcCfg.Exceptional))
let checker {Callbacks.summary; proc_desc; tenv} =
let checker {Callbacks.summary; tenv} =
let proc_desc = Summary.get_proc_desc summary in
let proc_data = ProcData.make_default proc_desc tenv in
match Analyzer.compute_post proc_data ~initial:Domain.empty with
| Some post ->

@ -79,7 +79,8 @@ module Make (Spec : Spec) : S = struct
module Analyzer = AbstractInterpreter.MakeRPO (TransferFunctions (ProcCfg.Exceptional))
let checker {Callbacks.proc_desc; tenv; summary} : Summary.t =
let checker {Callbacks.tenv; summary} : Summary.t =
let proc_desc = Summary.get_proc_desc summary in
let proc_name = Procdesc.get_proc_name proc_desc in
let nodes = Procdesc.get_nodes proc_desc in
let do_reporting node_id state =

@ -264,7 +264,8 @@ let siof_check pdesc gname (summary : Summary.t) =
()
let checker {Callbacks.proc_desc; tenv; summary; get_procs_in_file} : Summary.t =
let checker {Callbacks.tenv; summary; get_procs_in_file} : Summary.t =
let proc_desc = Summary.get_proc_desc summary in
let pname = Procdesc.get_proc_name proc_desc in
let standard_streams_initialized_in_tu =
let includes_iostream tu =

@ -214,7 +214,8 @@ let report_call_stack summary end_of_stack lookup_next_calls report call_site si
sink_map
let report_src_snk_path {Callbacks.proc_desc; tenv; summary} sink_map snk_annot src_annot =
let report_src_snk_path {Callbacks.tenv; summary} sink_map snk_annot src_annot =
let proc_desc = Summary.get_proc_desc summary in
let proc_name = Procdesc.get_proc_name proc_desc in
let loc = Procdesc.get_loc proc_desc in
if method_overrides_annot src_annot tenv proc_name then
@ -374,7 +375,7 @@ module CxxAnnotationSpecs = struct
in
let snk_annot = annotation_of_str snk_name in
let report proc_data annot_map =
let proc_desc = proc_data.Callbacks.proc_desc in
let proc_desc = Summary.get_proc_desc proc_data.Callbacks.summary in
let proc_name = Procdesc.get_proc_name proc_desc in
if src_pred proc_name then
let loc = Procdesc.get_loc proc_desc in
@ -437,7 +438,8 @@ module ExpensiveAnnotationSpec = struct
let method_is_expensive tenv pname = is_modeled_expensive tenv pname || is_expensive tenv pname
let check_expensive_subtyping_rules {Callbacks.proc_desc; tenv; summary} overridden_pname =
let check_expensive_subtyping_rules {Callbacks.tenv; summary} overridden_pname =
let proc_desc = Summary.get_proc_desc summary in
let proc_name = Procdesc.get_proc_name proc_desc in
let loc = Procdesc.get_loc proc_desc in
if not (method_is_expensive tenv overridden_pname) then
@ -463,7 +465,8 @@ module ExpensiveAnnotationSpec = struct
; sanitizer_predicate= default_sanitizer
; sink_annotation= expensive_annot
; report=
(fun ({Callbacks.tenv; proc_desc} as proc_data) astate ->
(fun ({Callbacks.tenv; summary} as proc_data) astate ->
let proc_desc = Summary.get_proc_desc summary in
let proc_name = Procdesc.get_proc_name proc_desc in
if is_expensive tenv proc_name then
PatternMatch.override_iter (check_expensive_subtyping_rules proc_data) tenv proc_name ;
@ -610,7 +613,8 @@ end
module Analyzer = AbstractInterpreter.MakeRPO (TransferFunctions (ProcCfg.Exceptional))
let checker ({Callbacks.proc_desc; tenv; summary} as callback) : Summary.t =
let checker ({Callbacks.tenv; summary} as callback) : Summary.t =
let proc_desc = Summary.get_proc_desc summary in
let initial = (AnnotReachabilityDomain.empty, NonBottom Domain.TrackingVar.empty) in
let specs = get_annot_specs (Procdesc.get_proc_name proc_desc) in
let proc_data = ProcData.make proc_desc tenv specs in

@ -125,7 +125,8 @@ let report_loads proc_desc summary astate =
ClassLoadsDomain.iter report_load astate )
let analyze_procedure {Callbacks.proc_desc; tenv; summary} =
let analyze_procedure {Callbacks.tenv; summary} =
let proc_desc = Summary.get_proc_desc summary in
let proc_name = Procdesc.get_proc_name proc_desc in
L.debug Analysis Verbose "CL: ANALYZING %a@." Typ.Procname.pp proc_name ;
let loc = Procdesc.get_loc proc_desc in

@ -792,7 +792,8 @@ let get_cost_summary astate = CostDomain.{post= astate.WorstCaseCost.costs}
let report_errors proc_desc astate summary = Check.check_and_report astate proc_desc summary
let checker {Callbacks.tenv; proc_desc; integer_type_widths; summary} : Summary.t =
let checker {Callbacks.tenv; integer_type_widths; summary} : Summary.t =
let proc_desc = Summary.get_proc_desc summary in
let inferbo_invariant_map =
BufferOverrunAnalysis.cached_compute_invariant_map proc_desc tenv integer_type_widths
in

@ -161,7 +161,8 @@ end
(* MakeDF *)
(** Example dataflow callback: compute the the distance from a node to the start node. *)
let _callback_test_dataflow {Callbacks.proc_desc; tenv; summary} =
let _callback_test_dataflow {Callbacks.tenv; summary} =
let proc_desc = Summary.get_proc_desc summary in
let verbose = false in
let module DFCount = MakeDF (struct
type t = int

@ -47,7 +47,7 @@ let report_warning class_name fld fld_typ summary =
Reporting.log_warning summary ~loc IssueType.checkers_fragment_retain_view description
let callback_fragment_retains_view_java java_pname {Callbacks.proc_desc; summary; tenv} =
let callback_fragment_retains_view_java java_pname {Callbacks.summary; tenv} =
(* TODO: complain if onDestroyView is not defined, yet the Fragment has View fields *)
(* TODO: handle fields nullified in callees in the same file *)
let is_on_destroy_view =
@ -70,7 +70,7 @@ let callback_fragment_retains_view_java java_pname {Callbacks.proc_desc; summary
match Tenv.lookup tenv class_name with
| Some {fields} when AndroidFramework.is_fragment tenv class_name ->
let declared_view_fields = List.filter ~f:(is_declared_view_typ class_name) fields in
let fields_nullified = PatternMatch.get_fields_nullified proc_desc in
let fields_nullified = PatternMatch.get_fields_nullified (Summary.get_proc_desc summary) in
(* report if a field is declared by C, but not nulled out in C.onDestroyView *)
List.iter
~f:(fun (fname, fld_typ, ia) ->

@ -149,7 +149,8 @@ let report_errors proc_desc tenv get_callee_purity reaching_defs_invariant_map
loop_head_to_inv_instrs
let checker Callbacks.{tenv; summary; proc_desc; integer_type_widths} : Summary.t =
let checker Callbacks.{tenv; summary; integer_type_widths} : Summary.t =
let proc_desc = Summary.get_proc_desc summary in
let cfg = InstrCFG.from_pdesc proc_desc in
(* computes reaching defs: node -> (var -> node set) *)
let reaching_defs_invariant_map = ReachingDefs.compute_invariant_map proc_desc tenv in

@ -78,7 +78,8 @@ let when_dominating_pred_satisfies idom my_node ~f =
match preds with [pred_node] -> f pred_node | _ -> ()
let checker Callbacks.{summary; proc_desc} : Summary.t =
let checker Callbacks.{summary} : Summary.t =
let proc_desc = Summary.get_proc_desc summary in
let cfg = CFG.from_pdesc proc_desc in
let _, loop_head_to_loop_nodes = Loop_control.get_loop_control_maps cfg in
let idom = Dominators.get_idoms proc_desc in

@ -211,7 +211,8 @@ let get_captured_by_ref_invariant_map proc_desc proc_data =
CapturedByRefAnalyzer.exec_cfg cfg proc_data ~initial:VarSet.empty
let checker {Callbacks.tenv; summary; proc_desc} : Summary.t =
let checker {Callbacks.tenv; summary} : Summary.t =
let proc_desc = Summary.get_proc_desc summary in
let proc_data = ProcData.make_default proc_desc tenv in
let captured_by_ref_invariant_map = get_captured_by_ref_invariant_map proc_desc proc_data in
let cfg = CFG.from_pdesc proc_desc in

@ -169,7 +169,8 @@ let check_printf_args_ok tenv (node : Procdesc.Node.t) (instr : Sil.instr)
()
let callback_printf_args {Callbacks.tenv; proc_desc; summary} : Summary.t =
let callback_printf_args {Callbacks.tenv; summary} : Summary.t =
let proc_desc = Summary.get_proc_desc summary in
let proc_name = Procdesc.get_proc_name proc_desc in
Procdesc.iter_instrs
(fun n i -> check_printf_args_ok tenv n i proc_name proc_desc summary)

@ -223,7 +223,8 @@ let compute_summary proc_desc tenv get_callee_summary inferbo_invariant_map =
Analyzer.compute_post proc_data ~initial:PurityDomain.pure
let checker {Callbacks.tenv; summary; proc_desc; integer_type_widths} : Summary.t =
let checker {Callbacks.tenv; summary; integer_type_widths} : Summary.t =
let proc_desc = Summary.get_proc_desc summary in
let inferbo_invariant_map =
BufferOverrunAnalysis.cached_compute_invariant_map proc_desc tenv integer_type_widths
in

@ -339,7 +339,8 @@ module Initial = struct
base_access_expr :: acc )
end
let checker {Callbacks.tenv; summary; proc_desc} : Summary.t =
let checker {Callbacks.tenv; summary} : Summary.t =
let proc_desc = Summary.get_proc_desc summary in
(* start with empty set of uninit local vars and empty set of init formal params *)
let maybe_uninit_vars = Initial.get_locals tenv proc_desc in
let initial =

@ -504,7 +504,8 @@ end
module Analyzer = LowerHil.MakeAbstractInterpreter (TransferFunctions (ProcCfg.Normal))
let analyze_procedure {Callbacks.proc_desc; tenv; summary} =
let analyze_procedure {Callbacks.tenv; summary} =
let proc_desc = Summary.get_proc_desc summary in
let open RacerDModels in
let open ConcurrencyModels in
let method_annotation = (Procdesc.get_attributes proc_desc).method_annotation in

@ -134,7 +134,8 @@ end
module Analyzer = LowerHil.MakeAbstractInterpreter (TransferFunctions (ProcCfg.Normal))
let analyze_procedure {Callbacks.proc_desc; tenv; summary} =
let analyze_procedure {Callbacks.tenv; summary} =
let proc_desc = Summary.get_proc_desc summary in
let open StarvationDomain in
let pname = Procdesc.get_proc_name proc_desc in
if StarvationModels.should_skip_analysis tenv pname [] then summary

@ -86,8 +86,8 @@ module Analyzer = LowerHil.MakeAbstractInterpreter (TransferFunctions (CFG))
let report_if_leak _post _summary (_proc_data : unit ProcData.t) = ()
(* Callback for invoking the checker from the outside--registered in RegisterCheckers *)
let checker {Callbacks.summary; proc_desc; tenv} : Summary.t =
let proc_data = ProcData.make proc_desc tenv () in
let checker {Callbacks.summary; tenv} : Summary.t =
let proc_data = ProcData.make (Summary.get_proc_desc summary) tenv () in
match Analyzer.compute_post proc_data ~initial:ResourceLeakDomain.initial with
| Some post ->
report_if_leak post summary proc_data ;

@ -337,8 +337,8 @@ end
module Analyzer = LowerHil.MakeAbstractInterpreter (TransferFunctions (ProcCfg.Exceptional))
let checker {Callbacks.summary; proc_desc; tenv} =
let checker {Callbacks.summary; tenv} =
let initial = (NullableAP.empty, NullCheckedPname.empty) in
let proc_data = ProcData.make proc_desc tenv summary in
let proc_data = ProcData.make (Summary.get_proc_desc summary) tenv summary in
ignore (Analyzer.compute_post proc_data ~initial) ;
summary

@ -179,7 +179,8 @@ let is_outside_codebase proc_name field_name =
false
let checker {Callbacks.summary; proc_desc; tenv} =
let checker {Callbacks.summary; tenv} =
let proc_desc = Summary.get_proc_desc summary in
let proc_name = Procdesc.get_proc_name proc_desc in
let annotation = Localise.nullable_annotation_name proc_name in
let report astate (proc_data : extras ProcData.t) =

@ -112,9 +112,9 @@ module MkCallback (Extension : ExtensionT) : CallBackT = struct
(!calls_this, None)
let callback2 calls_this checks
{Callbacks.proc_desc= curr_pdesc; summary; tenv; get_procs_in_file} annotated_signature
let callback2 calls_this checks {Callbacks.summary; tenv; get_procs_in_file} annotated_signature
linereader proc_loc : unit =
let curr_pdesc = Summary.get_proc_desc summary in
let idenv = Idenv.create curr_pdesc in
let curr_pname = Summary.get_proc_name summary in
let find_duplicate_nodes = State.mk_find_duplicate_nodes curr_pdesc in
@ -301,7 +301,8 @@ module MkCallback (Extension : ExtensionT) : CallBackT = struct
(** Entry point for the eradicate-based checker infrastructure. *)
let callback checks ({Callbacks.proc_desc; summary} as callback_args) : Summary.t =
let callback checks ({Callbacks.summary} as callback_args) : Summary.t =
let proc_desc = Summary.get_proc_desc summary in
let proc_name = Procdesc.get_proc_name proc_desc in
let calls_this = ref false in
let filter_special_cases () =

@ -214,7 +214,8 @@ module DisjunctiveTransferFunctions =
module DisjunctiveAnalyzer = AbstractInterpreter.MakeWTO (DisjunctiveTransferFunctions)
let checker {Callbacks.proc_desc; tenv; summary} =
let checker {Callbacks.tenv; summary} =
let proc_desc = Summary.get_proc_desc summary in
let proc_data = ProcData.make proc_desc tenv summary in
AbstractAddress.init () ;
let initial =

@ -845,7 +845,8 @@ module Make (TaintSpecification : TaintSpec.S) = struct
TaintSpecification.to_summary_access_tree with_footprint_vars
let checker {Callbacks.tenv; summary; proc_desc} : Summary.t =
let checker {Callbacks.tenv; summary} : Summary.t =
let proc_desc = Summary.get_proc_desc summary in
(* bind parameters to a trace with a tainted source (if applicable) *)
let make_initial pdesc =
let pname = Procdesc.get_proc_name pdesc in

Loading…
Cancel
Save