From 0c9cc9f791de810b997f181c9cf46915287b9fa8 Mon Sep 17 00:00:00 2001 From: Jules Villard Date: Wed, 27 May 2020 08:24:36 -0700 Subject: [PATCH] kill Exceptions.Eradicate Summary: This is the same as Exceptions.Checkers. Eventual goal is to stop having all issues going through the Exceptions layer. Reviewed By: dulmarod Differential Revision: D21686937 fbshipit-source-id: bd92fd0ff --- infer/src/IR/Exceptions.ml | 8 ++------ infer/src/IR/Exceptions.mli | 6 ++---- .../{eradicateCheckers.ml => EradicateReporting.ml} | 7 ++----- .../{eradicateCheckers.mli => EradicateReporting.mli} | 4 ---- infer/src/nullsafe/immutableChecker.ml | 4 ++-- infer/src/nullsafe/typeErr.ml | 6 ++---- 6 files changed, 10 insertions(+), 25 deletions(-) rename infer/src/nullsafe/{eradicateCheckers.ml => EradicateReporting.ml} (78%) rename infer/src/nullsafe/{eradicateCheckers.mli => EradicateReporting.mli} (72%) diff --git a/infer/src/IR/Exceptions.ml b/infer/src/IR/Exceptions.ml index 21ab496cf..0a011f99d 100644 --- a/infer/src/IR/Exceptions.ml +++ b/infer/src/IR/Exceptions.ml @@ -42,6 +42,8 @@ exception Biabd_use_after_free of Localise.error_desc * L.ocaml_pos exception Cannot_star of L.ocaml_pos +exception Checkers of IssueType.t * Localise.error_desc + exception Class_cast_exception of Localise.error_desc * L.ocaml_pos exception Condition_always_true_false of Localise.error_desc * bool * L.ocaml_pos @@ -61,14 +63,10 @@ exception Divide_by_zero of Localise.error_desc * L.ocaml_pos exception Empty_vector_access of Localise.error_desc * L.ocaml_pos -exception Eradicate of IssueType.t * Localise.error_desc - exception Field_not_null_checked of Localise.error_desc * L.ocaml_pos exception Frontend_warning of IssueType.t * Localise.error_desc * L.ocaml_pos -exception Checkers of IssueType.t * Localise.error_desc - exception Inherently_dangerous_function of Localise.error_desc exception Internal_error of Localise.error_desc @@ -234,8 +232,6 @@ let recognize_exception exn = ; ocaml_pos= Some ocaml_pos ; visibility= Exn_user ; severity= Some Error } - | Eradicate (kind, desc) -> - {issue_type= kind; description= desc; ocaml_pos= None; visibility= Exn_user; severity= None} | Empty_vector_access (desc, ocaml_pos) -> { issue_type= IssueType.empty_vector_access ; description= desc diff --git a/infer/src/IR/Exceptions.mli b/infer/src/IR/Exceptions.mli index 8a36646e4..f52178c3b 100644 --- a/infer/src/IR/Exceptions.mli +++ b/infer/src/IR/Exceptions.mli @@ -42,6 +42,8 @@ exception Biabd_use_after_free of Localise.error_desc * Logging.ocaml_pos exception Cannot_star of Logging.ocaml_pos +exception Checkers of IssueType.t * Localise.error_desc + exception Class_cast_exception of Localise.error_desc * Logging.ocaml_pos exception Condition_always_true_false of Localise.error_desc * bool * Logging.ocaml_pos @@ -64,10 +66,6 @@ exception Field_not_null_checked of Localise.error_desc * Logging.ocaml_pos exception Empty_vector_access of Localise.error_desc * Logging.ocaml_pos -exception Eradicate of IssueType.t * Localise.error_desc - -exception Checkers of IssueType.t * Localise.error_desc - exception Frontend_warning of IssueType.t * Localise.error_desc * Logging.ocaml_pos exception Inherently_dangerous_function of Localise.error_desc diff --git a/infer/src/nullsafe/eradicateCheckers.ml b/infer/src/nullsafe/EradicateReporting.ml similarity index 78% rename from infer/src/nullsafe/eradicateCheckers.ml rename to infer/src/nullsafe/EradicateReporting.ml index 339d23f7a..ec35706b9 100644 --- a/infer/src/nullsafe/eradicateCheckers.ml +++ b/infer/src/nullsafe/EradicateReporting.ml @@ -7,16 +7,13 @@ open! IStd -(** Module for Eradicate-based user-defined checkers. *) - let report_error {IntraproceduralAnalysis.proc_desc; tenv; err_log} checker kind loc - ?(field_name = None) ?(exception_kind = fun k d -> Exceptions.Checkers (k, d)) ~severity - description = + ?(field_name = None) ~severity description = let suppressed = Reporting.is_suppressed tenv proc_desc kind ~field_name in if suppressed then Logging.debug Analysis Medium "Reporting is suppressed!@\n" else let localized_description = Localise.verbatim_desc description in - let exn = exception_kind kind localized_description in + let exn = Exceptions.Checkers (kind, localized_description) in let trace = [Errlog.make_trace_element 0 loc description []] in let node = AnalysisState.get_node_exn () in let session = AnalysisState.get_session () in diff --git a/infer/src/nullsafe/eradicateCheckers.mli b/infer/src/nullsafe/EradicateReporting.mli similarity index 72% rename from infer/src/nullsafe/eradicateCheckers.mli rename to infer/src/nullsafe/EradicateReporting.mli index 084062228..60aca74c3 100644 --- a/infer/src/nullsafe/eradicateCheckers.mli +++ b/infer/src/nullsafe/EradicateReporting.mli @@ -7,16 +7,12 @@ open! IStd -(** Module for Eradicate-based user-defined checkers. *) - val report_error : IntraproceduralAnalysis.t -> Checker.t -> IssueType.t -> Location.t -> ?field_name:Fieldname.t option - -> ?exception_kind:(IssueType.t -> Localise.error_desc -> exn) -> severity:Exceptions.severity -> string -> unit -(** Report an error. *) diff --git a/infer/src/nullsafe/immutableChecker.ml b/infer/src/nullsafe/immutableChecker.ml index 73d0bc9c4..9ceac3267 100644 --- a/infer/src/nullsafe/immutableChecker.ml +++ b/infer/src/nullsafe/immutableChecker.ml @@ -35,8 +35,8 @@ let check_immutable_cast analysis_data proc_desc typ_expected typ_found_opt loc (Procname.to_simplified_string (Procdesc.get_proc_name proc_desc)) Typ.Name.pp name_given Typ.Name.pp name_expected in - EradicateCheckers.report_error analysis_data ImmutableCast - IssueType.checkers_immutable_cast loc description ~severity:Exceptions.Warning + EradicateReporting.report_error analysis_data ImmutableCast + IssueType.checkers_immutable_cast loc description ~severity:Warning | _ -> () ) | None -> diff --git a/infer/src/nullsafe/typeErr.ml b/infer/src/nullsafe/typeErr.ml index dd00ef687..52b27e2ff 100644 --- a/infer/src/nullsafe/typeErr.ml +++ b/infer/src/nullsafe/typeErr.ml @@ -334,10 +334,8 @@ let report_now_if_reportable analysis_data err_instance ~nullsafe_mode loc = Logging.debug Analysis Medium "About to report: %s" err_description ; let field_name = get_field_name_for_error_suppressing err_instance in let error_location = Option.value updated_location ~default:loc in - EradicateCheckers.report_error analysis_data Eradicate infer_issue_type error_location - ~field_name - ~exception_kind:(fun k d -> Exceptions.Eradicate (k, d)) - ~severity err_description ) + EradicateReporting.report_error analysis_data Eradicate infer_issue_type error_location + ~field_name ~severity err_description ) (** Register issue (unless exactly the same issue was already registered). If needed, report this