[nullsafe] remove unused `tenv` argument from dataflow framework

Summary:
Easy cleanup. The tenv is now part of the analysis_data that is in the
closure passed to the Dataflow framework.

Reviewed By: dulmarod

Differential Revision: D21351907

fbshipit-source-id: 592542c06
master
Jules Villard 5 years ago committed by Facebook GitHub Bot
parent f86d9193a9
commit c0440f29ae

@ -24,7 +24,7 @@ module type DFStateType = sig
val join : t -> t -> t
(** Join two states (the old one is the first parameter). *)
val do_node : Tenv.t -> Procdesc.Node.t -> t -> t list * t list
val do_node : Procdesc.Node.t -> t -> t list * t list
(** Perform a state transition on a node. *)
val proc_throws : Procname.t -> throws
@ -41,7 +41,7 @@ module type DF = sig
val join : state list -> state -> state
val run : Tenv.t -> Procdesc.t -> state -> Procdesc.Node.t -> transition
val run : Procdesc.t -> state -> Procdesc.Node.t -> transition
end
(** Determine if the node can throw an exception. *)
@ -132,7 +132,7 @@ module MakeDF (St : DFStateType) : DF with type state = St.t = struct
(** Run the worklist-based dataflow algorithm. *)
let run tenv proc_desc state =
let run proc_desc state =
let t =
let start_node = Procdesc.get_start_node proc_desc in
let init_set = S.singleton start_node in
@ -152,7 +152,7 @@ module MakeDF (St : DFStateType) : DF with type state = St.t = struct
t.worklist <- S.remove node t.worklist ;
try
let state = H.find t.pre_states node in
let states_succ, states_exn = St.do_node tenv node state in
let states_succ, states_exn = St.do_node node state in
propagate t node states_succ states_exn (node_throws proc_desc node St.proc_throws)
with Caml.Not_found -> ()
done
@ -167,9 +167,8 @@ end
(* MakeDF *)
(** Example dataflow callback: compute the the distance from a node to the start node. *)
let _callback_test_dataflow {Callbacks.exe_env; summary} =
let _callback_test_dataflow {Callbacks.summary; _} =
let proc_desc = Summary.get_proc_desc summary in
let tenv = Exe_env.get_tenv exe_env (Summary.get_proc_name summary) in
let verbose = false in
let module DFCount = MakeDF (struct
type t = int
@ -178,7 +177,7 @@ let _callback_test_dataflow {Callbacks.exe_env; summary} =
let join n m = if Int.equal n 0 then m else n
let do_node _ n s =
let do_node n s =
if verbose then
L.(debug Analysis Verbose) "visiting node %a with state %d@." Procdesc.Node.pp n s ;
([s + 1], [s + 1])
@ -186,7 +185,7 @@ let _callback_test_dataflow {Callbacks.exe_env; summary} =
let proc_throws _ = DoesNotThrow
end) in
let transitions = DFCount.run tenv proc_desc 0 in
let transitions = DFCount.run proc_desc 0 in
let do_node node =
match transitions node with DFCount.Transition _ -> () | DFCount.Dead_state -> ()
in

@ -23,7 +23,7 @@ module type DFStateType = sig
val join : t -> t -> t
(** Join two states (the old one is the first parameter). *)
val do_node : Tenv.t -> Procdesc.Node.t -> t -> t list * t list
val do_node : Procdesc.Node.t -> t -> t list * t list
(** Perform a state transition on a node. *)
val proc_throws : Procname.t -> throws
@ -40,7 +40,7 @@ module type DF = sig
val join : state list -> state -> state
val run : Tenv.t -> Procdesc.t -> state -> Procdesc.Node.t -> transition
val run : Procdesc.t -> state -> Procdesc.Node.t -> transition
(** Run the dataflow analysis on a procedure starting from the given state. Returns a function to
lookup the results of the analysis on every node *)
end

@ -10,7 +10,7 @@ module L = Logging
module F = Format
open Dataflow
let callback1 ({IntraproceduralAnalysis.proc_desc= curr_pdesc; tenv; _} as analysis_data)
let callback1 ({IntraproceduralAnalysis.proc_desc= curr_pdesc; _} as analysis_data)
find_canonical_duplicate calls_this checks idenv annotated_signature linereader proc_loc :
bool * TypeState.t option =
let curr_pname = Procdesc.get_proc_name curr_pdesc in
@ -75,7 +75,7 @@ let callback1 ({IntraproceduralAnalysis.proc_desc= curr_pdesc; tenv; _} as analy
let pp_name fmt = F.pp_print_string fmt "eradicate"
let do_node _tenv node typestate =
let do_node node typestate =
NodePrinter.with_session ~pp_name node ~f:(fun () ->
AnalysisState.set_node node ;
if Config.write_html then L.d_printfln "before:@\n%a@\n" TypeState.pp typestate ;
@ -93,7 +93,7 @@ let callback1 ({IntraproceduralAnalysis.proc_desc= curr_pdesc; tenv; _} as analy
end) in
let initial_typestate = get_initial_typestate () in
do_before_dataflow initial_typestate ;
let transitions = DFTypeCheck.run tenv curr_pdesc initial_typestate in
let transitions = DFTypeCheck.run curr_pdesc initial_typestate in
match transitions (Procdesc.get_exit_node curr_pdesc) with
| DFTypeCheck.Transition (final_typestate, _, _) ->
do_after_dataflow find_canonical_duplicate final_typestate ;

Loading…
Cancel
Save