[cleanup] remove Idenv from checkers callbacks

Summary: Only Eradicate uses this, no need to create it for every checker.

Reviewed By: jeremydubreil

Differential Revision: D5886775

fbshipit-source-id: 7242437
master
Sam Blackshear 7 years ago committed by Facebook Github Bot
parent 6a76bc6c7a
commit 18a9e52752

@ -16,7 +16,6 @@ module L = Logging
type proc_callback_args =
{ get_proc_desc: Typ.Procname.t -> Procdesc.t option
; get_procs_in_file: Typ.Procname.t -> Typ.Procname.t list
; idenv: Idenv.t
; tenv: Tenv.t
; summary: Specs.summary
; proc_desc: Procdesc.t }
@ -25,7 +24,7 @@ type proc_callback_t = proc_callback_args -> Specs.summary
type cluster_callback_t =
Exe_env.t -> Typ.Procname.t list -> (Typ.Procname.t -> Procdesc.t option)
-> (Idenv.t * Tenv.t * Typ.Procname.t * Procdesc.t) list -> unit
-> (Tenv.t * Typ.Procname.t * Procdesc.t) list -> unit
let procedure_callbacks = ref []
@ -42,9 +41,8 @@ let get_procedure_definition exe_env proc_name =
let tenv = Exe_env.get_tenv exe_env proc_name in
Option.map
~f:(fun proc_desc ->
let idenv = Idenv.create proc_desc
and language = (Procdesc.get_attributes proc_desc).ProcAttributes.language in
(idenv, tenv, proc_name, proc_desc, language))
let language = (Procdesc.get_attributes proc_desc).ProcAttributes.language in
(tenv, proc_name, proc_desc, language))
(Exe_env.get_proc_desc exe_env proc_name)
let get_language proc_name = if Typ.Procname.is_java proc_name then Config.Java else Config.Clang
@ -64,7 +62,7 @@ let iterate_procedure_callbacks exe_env summary caller_pname =
match get_procedure_definition exe_env caller_pname with
| None
-> summary
| Some (idenv, tenv, _, proc_desc, _)
| Some (tenv, _, proc_desc, _)
-> List.fold ~init:summary
~f:(fun summary (language_opt, proc_callback) ->
let language_matches =
@ -75,7 +73,7 @@ let iterate_procedure_callbacks exe_env summary caller_pname =
-> true
in
if language_matches then
proc_callback {get_proc_desc; get_procs_in_file; idenv; tenv; summary; proc_desc}
proc_callback {get_proc_desc; get_procs_in_file; tenv; summary; proc_desc}
else summary)
!procedure_callbacks
@ -85,7 +83,7 @@ let iterate_cluster_callbacks all_procs exe_env =
let procedure_definitions = List.filter_map ~f:(get_procedure_definition exe_env) all_procs in
let environment =
List.map
~f:(fun (idenv, tenv, proc_name, proc_desc, _) -> (idenv, tenv, proc_name, proc_desc))
~f:(fun (tenv, proc_name, proc_desc, _) -> (tenv, proc_name, proc_desc))
procedure_definitions
in
(* Procedures matching the given language or all if no language is specified. *)

@ -14,7 +14,6 @@ open! IStd
type proc_callback_args =
{ get_proc_desc: Typ.Procname.t -> Procdesc.t option
; get_procs_in_file: Typ.Procname.t -> Typ.Procname.t list
; idenv: Idenv.t
; tenv: Tenv.t
; summary: Specs.summary
; proc_desc: Procdesc.t }
@ -29,7 +28,7 @@ type proc_callback_t = proc_callback_args -> Specs.summary
type cluster_callback_t =
Exe_env.t -> Typ.Procname.t list -> (Typ.Procname.t -> Procdesc.t option)
-> (Idenv.t * Tenv.t * Typ.Procname.t * Procdesc.t) list -> unit
-> (Tenv.t * Typ.Procname.t * Procdesc.t) list -> unit
val register_procedure_callback : Config.language option -> proc_callback_t -> unit
(** register a procedure callback *)

@ -1638,7 +1638,7 @@ let make_results_table file_env =
(PathDomain.sinks accesses) acc)
accesses acc
in
let aggregate_posts acc (_, tenv, proc_name, proc_desc) =
let aggregate_posts acc (tenv, proc_name, proc_desc) =
match Summary.read_summary proc_desc proc_name with
| Some summary
-> aggregate_post summary tenv proc_desc acc
@ -1651,7 +1651,7 @@ let make_results_table file_env =
each class individually *)
let aggregate_by_class file_env =
List.fold file_env
~f:(fun acc (_, _, pname, _ as proc) ->
~f:(fun acc (_, pname, _ as proc) ->
let classname =
match pname with
| Typ.Procname.Java java_pname

@ -141,8 +141,9 @@ module MkCallback (Extension : ExtensionT) : CallBackT = struct
-> (!calls_this, None)
let callback2 calls_this checks
{Callbacks.proc_desc= curr_pdesc; summary; get_proc_desc; idenv; tenv; get_procs_in_file}
{Callbacks.proc_desc= curr_pdesc; summary; get_proc_desc; tenv; get_procs_in_file}
annotated_signature linereader proc_loc : unit =
let idenv = Idenv.create curr_pdesc in
let curr_pname = Specs.get_proc_name summary in
let find_duplicate_nodes = State.mk_find_duplicate_nodes curr_pdesc in
let find_canonical_duplicate node =

Loading…
Cancel
Save