[nullsafe] unused functor argument -> get rid of module-ification

Summary:
OCaml 4.10.0 flagged that the `Extension` functor argument was unused.
Delete it and remove one layer of module in the file too now that it
doesn't need to be a functor.

Reviewed By: mityal

Differential Revision: D20669652

fbshipit-source-id: 089043d7d
master
Jules Villard 5 years ago committed by Facebook GitHub Bot
parent e10e458bee
commit bacb2b3d6e

@ -16,18 +16,6 @@ module Payload = SummaryPayload.Make (struct
let field = Payloads.Fields.nullsafe let field = Payloads.Fields.nullsafe
end) end)
(** Type for a module that provides a main callback function *)
module type CallBackT = sig
val callback : TypeCheck.checks -> Callbacks.proc_callback_t
end
(** Extension to the type checker. *)
module type ExtensionT = sig
val update_payloads : NullsafeSummary.t option -> Payloads.t -> Payloads.t
end
(** Create a module with the toplevel callback. *)
module MkCallback (Extension : ExtensionT) : CallBackT = struct
let callback1 tenv find_canonical_duplicate calls_this checks idenv curr_pname curr_pdesc let callback1 tenv find_canonical_duplicate calls_this checks idenv curr_pname curr_pdesc
annotated_signature linereader proc_loc : bool * TypeState.t option = annotated_signature linereader proc_loc : bool * TypeState.t option =
let add_formal typestate (param_signature : AnnotatedSignature.param_signature) = let add_formal typestate (param_signature : AnnotatedSignature.param_signature) =
@ -53,8 +41,8 @@ module MkCallback (Extension : ExtensionT) : CallBackT = struct
List.fold ~f:add_formal ~init:typestate_empty annotated_signature.AnnotatedSignature.params List.fold ~f:add_formal ~init:typestate_empty annotated_signature.AnnotatedSignature.params
in in
(* Check the nullable flag computed for the return value and report inconsistencies. *) (* Check the nullable flag computed for the return value and report inconsistencies. *)
let check_return find_canonical_duplicate exit_node final_typestate annotated_signature loc : let check_return find_canonical_duplicate exit_node final_typestate annotated_signature loc : unit
unit = =
let AnnotatedSignature.{ret_annotated_type} = annotated_signature.AnnotatedSignature.ret in let AnnotatedSignature.{ret_annotated_type} = annotated_signature.AnnotatedSignature.ret in
let ret_pvar = Procdesc.get_ret_var curr_pdesc in let ret_pvar = Procdesc.get_ret_var curr_pdesc in
let ret_range = TypeState.lookup_pvar ret_pvar final_typestate in let ret_range = TypeState.lookup_pvar ret_pvar final_typestate in
@ -162,8 +150,8 @@ module MkCallback (Extension : ExtensionT) : CallBackT = struct
&& checks.TypeCheck.eradicate && checks.TypeCheck.eradicate
then ( then (
let typestates_for_curr_constructor_and_all_initializer_methods = let typestates_for_curr_constructor_and_all_initializer_methods =
Initializers.final_initializer_typestates_lazy tenv proc_name proc_desc Initializers.final_initializer_typestates_lazy tenv proc_name proc_desc get_procs_in_file
get_procs_in_file typecheck_proc typecheck_proc
in in
let typestates_for_all_constructors_incl_current = let typestates_for_all_constructors_incl_current =
Initializers.final_constructor_typestates_lazy tenv proc_name get_procs_in_file Initializers.final_constructor_typestates_lazy tenv proc_name get_procs_in_file
@ -173,8 +161,7 @@ module MkCallback (Extension : ExtensionT) : CallBackT = struct
proc_desc start_node ~nullsafe_mode:annotated_signature.AnnotatedSignature.nullsafe_mode proc_desc start_node ~nullsafe_mode:annotated_signature.AnnotatedSignature.nullsafe_mode
~typestates_for_curr_constructor_and_all_initializer_methods ~typestates_for_curr_constructor_and_all_initializer_methods
~typestates_for_all_constructors_incl_current proc_loc ; ~typestates_for_all_constructors_incl_current proc_loc ;
if Config.eradicate_verbose then L.result "Final Typestate@\n%a@." TypeState.pp typestate if Config.eradicate_verbose then L.result "Final Typestate@\n%a@." TypeState.pp typestate )
)
in in
match typestate_opt with None -> () | Some typestate -> do_typestate typestate match typestate_opt with None -> () | Some typestate -> do_typestate typestate
in in
@ -227,8 +214,8 @@ module MkCallback (Extension : ExtensionT) : CallBackT = struct
(* The main method - during this the actual analysis will happen and TypeErr will be populated with (* The main method - during this the actual analysis will happen and TypeErr will be populated with
issues (and some of them - reported). issues (and some of them - reported).
*) *)
analyze_procedure tenv proc_name proc_desc calls_this checks callback_args analyze_procedure tenv proc_name proc_desc calls_this checks callback_args annotated_signature
annotated_signature linereader loc ; linereader loc ;
(* Collect issues that were detected during analysis and put them in summary for further processing *) (* Collect issues that were detected during analysis and put them in summary for further processing *)
let issues = TypeErr.get_errors () |> List.map ~f:(fun (issues, _) -> issues) in let issues = TypeErr.get_errors () |> List.map ~f:(fun (issues, _) -> issues) in
(* Report errors of "farall" class - those could not be reported during analysis phase. *) (* Report errors of "farall" class - those could not be reported during analysis phase. *)
@ -236,27 +223,15 @@ module MkCallback (Extension : ExtensionT) : CallBackT = struct
(EradicateCheckers.report_error tenv) (EradicateCheckers.report_error tenv)
~nullsafe_mode:annotated_signature.nullsafe_mode proc_desc ; ~nullsafe_mode:annotated_signature.nullsafe_mode proc_desc ;
Payload.update_summary NullsafeSummary.{issues} summary Payload.update_summary NullsafeSummary.{issues} summary
end
(* MkCallback *)
module EmptyExtension : ExtensionT = struct
let update_payloads new_summary (payloads : Payloads.t) = {payloads with nullsafe= new_summary}
end
module Main = struct
module Callback = MkCallback (EmptyExtension)
let callback = Callback.callback
end
let proc_callback = let proc_callback =
let checks = {TypeCheck.eradicate= true; check_ret_type= []} in let checks = {TypeCheck.eradicate= true; check_ret_type= []} in
Main.callback checks callback checks
let file_callback = FileLevelAnalysis.analyze_file let file_callback = FileLevelAnalysis.analyze_file
let callback_check_return_type check_return_type callback_args = let callback_check_return_type check_return_type callback_args =
let checks = {TypeCheck.eradicate= false; check_ret_type= [check_return_type]} in let checks = {TypeCheck.eradicate= false; check_ret_type= [check_return_type]} in
Main.callback checks callback_args callback checks callback_args

@ -19,13 +19,3 @@ val file_callback : Callbacks.file_callback_t
val callback_check_return_type : TypeCheck.check_return_type -> Callbacks.proc_callback_t val callback_check_return_type : TypeCheck.check_return_type -> Callbacks.proc_callback_t
(** For checkers that explore eradicate/nullsafe infra, but not part of nullsafe.Annot Call the (** For checkers that explore eradicate/nullsafe infra, but not part of nullsafe.Annot Call the
given check_return_type at the end of every procedure. *) given check_return_type at the end of every procedure. *)
(** Type for a module that provides a main callback function *)
module type CallBackT = sig
val callback : TypeCheck.checks -> Callbacks.proc_callback_t
end
(** Extension to the type checker. *)
module type ExtensionT = sig
val update_payloads : NullsafeSummary.t option -> Payloads.t -> Payloads.t
end

Loading…
Cancel
Save