From 6bb429ef63c13cb6ef8f051fe56817b5067b54c6 Mon Sep 17 00:00:00 2001 From: Mehdi Bouaziz Date: Tue, 21 Aug 2018 05:24:13 -0700 Subject: [PATCH] Reporting cleanup 13: log_issue_external Reviewed By: jvillard Differential Revision: D9369295 fbshipit-source-id: faf56b177 --- infer/src/IR/Errlog.ml | 3 +++ infer/src/IR/Errlog.mli | 1 + infer/src/IR/Procdesc.ml | 2 ++ infer/src/IR/Procdesc.mli | 2 ++ infer/src/backend/reporting.ml | 5 +++-- infer/src/backend/reporting.mli | 2 +- infer/src/concurrency/RacerD.ml | 8 ++++---- infer/src/concurrency/starvation.ml | 3 +-- 8 files changed, 17 insertions(+), 9 deletions(-) diff --git a/infer/src/IR/Errlog.ml b/infer/src/IR/Errlog.ml index 9ebb34942..6a4fa1fed 100644 --- a/infer/src/IR/Errlog.ml +++ b/infer/src/IR/Errlog.ml @@ -61,6 +61,7 @@ let compute_local_exception_line loc_trace = type node = + | UnknownNode | FrontendNode of {node_key: Procdesc.NodeKey.t} | BackendNode of {node: Procdesc.Node.t} @@ -264,6 +265,8 @@ let log_issue procname ~clang_method_kind severity err_log ~loc ~node ~session ~ let added = let node_id, node_key = match node with + | UnknownNode -> + (0, Procdesc.NodeKey.dummy) | FrontendNode {node_key} -> (0, node_key) | BackendNode {node} -> diff --git a/infer/src/IR/Errlog.mli b/infer/src/IR/Errlog.mli index 3ee94c2f0..11af2329d 100644 --- a/infer/src/IR/Errlog.mli +++ b/infer/src/IR/Errlog.mli @@ -35,6 +35,7 @@ val compute_local_exception_line : loc_trace -> int option digging into the trace to understand the cause of the report. *) type node = + | UnknownNode | FrontendNode of {node_key: Procdesc.NodeKey.t} | BackendNode of {node: Procdesc.Node.t} diff --git a/infer/src/IR/Procdesc.ml b/infer/src/IR/Procdesc.ml index abac595f5..c2bce4acf 100644 --- a/infer/src/IR/Procdesc.ml +++ b/infer/src/IR/Procdesc.ml @@ -24,6 +24,8 @@ module NodeKey = struct let of_frontend_node_key = Utils.better_hash + + let dummy = Utils.better_hash "DUMMY" end (* =============== START of module Node =============== *) diff --git a/infer/src/IR/Procdesc.mli b/infer/src/IR/Procdesc.mli index b234a961b..4beb51a8e 100644 --- a/infer/src/IR/Procdesc.mli +++ b/infer/src/IR/Procdesc.mli @@ -11,6 +11,8 @@ open! IStd module NodeKey : sig type t + val dummy : t + val to_string : t -> string val of_frontend_node_key : string -> t diff --git a/infer/src/backend/reporting.ml b/infer/src/backend/reporting.ml index 33aae636a..c2a2bd456 100644 --- a/infer/src/backend/reporting.ml +++ b/infer/src/backend/reporting.ml @@ -79,9 +79,10 @@ let log_error = log_issue_from_summary_simplified Exceptions.Error let log_warning = log_issue_from_summary_simplified Exceptions.Warning -let log_issue_external procname severity ~loc ~ltr ?access exn = +let log_issue_external procname severity ~loc ~ltr ?access issue_type error_message = + let exn = Exceptions.Checkers (issue_type, Localise.verbatim_desc error_message) in let errlog = IssueLog.get_errlog procname in - let node = Errlog.BackendNode {node= State.get_node ()} in + let node = Errlog.UnknownNode in log_issue_from_errlog procname ~clang_method_kind:None severity errlog ~loc ~node ~ltr ~linters_def_file:None ~doc_url:None ~access ~extras:None exn diff --git a/infer/src/backend/reporting.mli b/infer/src/backend/reporting.mli index 49d3a9d5f..791a853f4 100644 --- a/infer/src/backend/reporting.mli +++ b/infer/src/backend/reporting.mli @@ -33,7 +33,7 @@ val log_warning : Summary.t -> loc:Location.t -> log_t val log_issue_external : Typ.Procname.t -> Exceptions.severity -> loc:Location.t -> ltr:Errlog.loc_trace -> ?access:string - -> exn -> unit + -> IssueType.t -> string -> unit (** Log an issue to the error log in [IssueLog] associated with the given procname. *) val is_suppressed : diff --git a/infer/src/concurrency/RacerD.ml b/infer/src/concurrency/RacerD.ml index 31a109ba2..5db84aee7 100644 --- a/infer/src/concurrency/RacerD.ml +++ b/infer/src/concurrency/RacerD.ml @@ -914,8 +914,9 @@ let is_contaminated access wobbly_paths = false -let log_issue current_pname ~loc ~ltr ~access exn = - Reporting.log_issue_external current_pname Exceptions.Error ~loc ~ltr ~access exn +let log_issue current_pname ~loc ~ltr ~access issue_type error_message = + Reporting.log_issue_external current_pname Exceptions.Error ~loc ~ltr ~access issue_type + error_message let report_thread_safety_violation tenv pdesc ~make_description ~report_kind access thread @@ -939,10 +940,9 @@ let report_thread_safety_violation tenv pdesc ~make_description ~report_kind acc (* why we are reporting it *) let issue_type, explanation = get_reporting_explanation report_kind tenv pname thread in let error_message = F.sprintf "%s%s" description explanation in - let exn = Exceptions.Checkers (issue_type, Localise.verbatim_desc error_message) in let end_locs = Option.to_list original_end @ Option.to_list conflict_end in let access = IssueAuxData.encode (pname, access, end_locs) in - log_issue pname ~loc ~ltr ~access exn + log_issue pname ~loc ~ltr ~access issue_type error_message in let trace_of_pname = trace_of_pname access pdesc in Option.iter ~f:report_one_path (PathDomain.get_reportable_sink_path access ~trace_of_pname) diff --git a/infer/src/concurrency/starvation.ml b/infer/src/concurrency/starvation.ml index ed65a7a00..449f31df5 100644 --- a/infer/src/concurrency/starvation.ml +++ b/infer/src/concurrency/starvation.ml @@ -225,8 +225,7 @@ end = struct let log map = let log_report issuetype loc {pname; ltr; message} = - let exn = Exceptions.Checkers (issuetype, Localise.verbatim_desc message) in - Reporting.log_issue_external pname Exceptions.Error ~loc ~ltr exn + Reporting.log_issue_external pname Exceptions.Error ~loc ~ltr issuetype message in let mk_deduped_report num_of_reports ({message} as report) = { report with