From ac5633bf5818f6510f071a298986feef866eeede Mon Sep 17 00:00:00 2001 From: Mehdi Bouaziz Date: Wed, 15 Aug 2018 15:28:54 -0700 Subject: [PATCH] Reporting cleanup 7: session Reviewed By: jeremydubreil Differential Revision: D9349672 fbshipit-source-id: 6d33c8e76 --- infer/src/IR/Io_infer.ml | 13 ++++++----- infer/src/backend/reporting.ml | 38 +++++++++++++++------------------ infer/src/backend/reporting.mli | 4 ++-- infer/src/biabduction/State.ml | 6 +++--- infer/src/biabduction/State.mli | 6 +++--- 5 files changed, 33 insertions(+), 34 deletions(-) diff --git a/infer/src/IR/Io_infer.ml b/infer/src/IR/Io_infer.ml index 8c016b12b..71730274e 100644 --- a/infer/src/IR/Io_infer.ml +++ b/infer/src/IR/Io_infer.ml @@ -181,17 +181,20 @@ td.rowname { text-align:right; font-weight:bold; color:#444444; padding-right:2e let pp_session_link ?(with_name= false) ?proc_name source path_to_root fmt (node_id, session, linenum) = let node_name = "node" ^ string_of_int node_id in - let pos = "session" ^ string_of_int session in - let text = F.sprintf "%s#%s" node_name pos in + let text, pos = + if session > 0 then + let pos = "session" ^ string_of_int session in + let text = F.sprintf "%s#%s" node_name pos in + (text, Some pos) + else (node_name, None) + in let path_to_node = let node_fname = match proc_name with Some pname -> node_filename pname node_id | None -> node_name in path_to_root @ ["nodes"; node_fname] in - pp_link - ~name:(if with_name then Some pos else None) - ~pos:(Some pos) ~path:path_to_node fmt text ; + pp_link ~name:(if with_name then pos else None) ~pos ~path:path_to_node fmt text ; F.fprintf fmt "(%a)" (pp_line_link source path_to_root) linenum end diff --git a/infer/src/backend/reporting.ml b/infer/src/backend/reporting.ml index 9273b93ca..2cd8cd7ef 100644 --- a/infer/src/backend/reporting.ml +++ b/infer/src/backend/reporting.ml @@ -9,26 +9,26 @@ open! IStd module L = Logging type log_t = - ?session:int -> ?ltr:Errlog.loc_trace -> ?linters_def_file:string -> ?doc_url:string - -> ?access:string -> ?extras:Jsonbug_t.extra -> exn -> unit + ?ltr:Errlog.loc_trace -> ?linters_def_file:string -> ?doc_url:string -> ?access:string + -> ?extras:Jsonbug_t.extra -> exn -> unit let log_issue_from_errlog_internal procname ~clang_method_kind severity err_log ~loc ~node_id_key - ~session ~ltr ~linters_def_file ~doc_url ~access ~extras exn = + ~ltr ~linters_def_file ~doc_url ~access ~extras exn = let issue_type = (Exceptions.recognize_exception exn).name in if not Config.filtering (* no-filtering takes priority *) || issue_type.IssueType.enabled then + let session = (State.get_session () :> int) in Errlog.log_issue procname ~clang_method_kind severity err_log ~loc ~node_id_key ~session ~ltr ~linters_def_file ~doc_url ~access ~extras exn let log_issue_from_errlog procname severity errlog ~loc ~node_id_key ~ltr ~linters_def_file ~doc_url exn = - let session = (State.get_session () :> int) in log_issue_from_errlog_internal procname ~clang_method_kind:None severity errlog ~loc ~node_id_key - ~session ~ltr ~linters_def_file ~doc_url ~access:None ~extras:None exn + ~ltr ~linters_def_file ~doc_url ~access:None ~extras:None exn -let log_issue_from_summary severity summary ~node_id_key ~loc ?session ?ltr ?linters_def_file - ?doc_url ?access ?extras exn = +let log_issue_from_summary severity summary ~node_id_key ~loc ?ltr ?linters_def_file ?doc_url + ?access ?extras exn = let attrs = Summary.get_attributes summary in let procname = attrs.proc_name in let is_java_generated_method = @@ -47,24 +47,21 @@ let log_issue_from_summary severity summary ~node_id_key ~loc ?session ?ltr ?lin else let err_log = Summary.get_err_log summary in let clang_method_kind = Some attrs.clang_method_kind in - let session = - match session with None -> (State.get_session () :> int) | Some session -> session - in let ltr = match ltr with None -> State.get_loc_trace () | Some ltr -> ltr in log_issue_from_errlog_internal procname ~clang_method_kind severity err_log ~loc ~node_id_key - ~session ~ltr ~linters_def_file ~doc_url ~access ~extras exn + ~ltr ~linters_def_file ~doc_url ~access ~extras exn -let log_issue_deprecated severity proc_name ?node_id_key ?loc ?session ?ltr ?linters_def_file - ?doc_url ?access ?extras:_ exn = +let log_issue_deprecated severity proc_name ?node_id_key ?loc ?ltr ?linters_def_file ?doc_url + ?access ?extras:_ exn = match Summary.get proc_name with | Some summary -> let node_id_key = match node_id_key with None -> State.get_node_id_key () | Some node_id_key -> node_id_key in let loc = match loc with None -> State.get_loc () | Some loc -> loc in - log_issue_from_summary severity summary ~node_id_key ~loc ?session ?ltr ?linters_def_file - ?doc_url ?access exn + log_issue_from_summary severity summary ~node_id_key ~loc ?ltr ?linters_def_file ?doc_url + ?access exn | None -> L.(die InternalError) "Trying to report error on procedure %a, but cannot because no summary exists for this \ @@ -72,11 +69,11 @@ let log_issue_deprecated severity proc_name ?node_id_key ?loc ?session ?ltr ?lin Typ.Procname.pp proc_name Typ.Procname.pp proc_name -let log_issue_from_summary_simplified severity summary ~loc ?session ?ltr ?linters_def_file - ?doc_url ?access ?extras exn = +let log_issue_from_summary_simplified severity summary ~loc ?ltr ?linters_def_file ?doc_url ?access + ?extras exn = let node_id_key = State.get_node_id_key () in - log_issue_from_summary severity summary ~node_id_key ~loc ?session ?ltr ?linters_def_file - ?doc_url ?access ?extras exn + log_issue_from_summary severity summary ~node_id_key ~loc ?ltr ?linters_def_file ?doc_url ?access + ?extras exn let log_error = log_issue_from_summary_simplified Exceptions.Error @@ -86,9 +83,8 @@ let log_warning = log_issue_from_summary_simplified Exceptions.Warning let log_issue_external procname severity ~loc ~ltr ?access exn = let errlog = IssueLog.get_errlog procname in let node_id_key = State.get_node_id_key () in - let session = (State.get_session () :> int) in log_issue_from_errlog_internal procname ~clang_method_kind:None severity errlog ~loc ~node_id_key - ~session ~ltr ~linters_def_file:None ~doc_url:None ~access ~extras:None exn + ~ltr ~linters_def_file:None ~doc_url:None ~access ~extras:None exn let is_suppressed ?(field_name= None) tenv proc_desc kind = diff --git a/infer/src/backend/reporting.mli b/infer/src/backend/reporting.mli index 156b15822..e9aa3e196 100644 --- a/infer/src/backend/reporting.mli +++ b/infer/src/backend/reporting.mli @@ -10,8 +10,8 @@ open! IStd (** Type of functions to report issues to the error_log in a spec. *) type log_t = - ?session:int -> ?ltr:Errlog.loc_trace -> ?linters_def_file:string -> ?doc_url:string - -> ?access:string -> ?extras:Jsonbug_t.extra -> exn -> unit + ?ltr:Errlog.loc_trace -> ?linters_def_file:string -> ?doc_url:string -> ?access:string + -> ?extras:Jsonbug_t.extra -> exn -> unit val log_issue_deprecated : Exceptions.severity -> Typ.Procname.t -> ?node_id_key:Errlog.node_id_key -> ?loc:Location.t diff --git a/infer/src/biabduction/State.ml b/infer/src/biabduction/State.ml index 49e80a126..720e3af80 100644 --- a/infer/src/biabduction/State.ml +++ b/infer/src/biabduction/State.ml @@ -261,9 +261,9 @@ let mark_instr_fail exn = type log_issue = - Typ.Procname.t -> ?node_id_key:Errlog.node_id_key -> ?loc:Location.t -> ?session:int - -> ?ltr:Errlog.loc_trace -> ?linters_def_file:string -> ?doc_url:string -> ?access:string - -> ?extras:Jsonbug_t.extra -> exn -> unit + Typ.Procname.t -> ?node_id_key:Errlog.node_id_key -> ?loc:Location.t -> ?ltr:Errlog.loc_trace + -> ?linters_def_file:string -> ?doc_url:string -> ?access:string -> ?extras:Jsonbug_t.extra + -> exn -> unit let process_execution_failures (log_issue: log_issue) pname = let do_failure _ fs = diff --git a/infer/src/biabduction/State.mli b/infer/src/biabduction/State.mli index 8e1783fdb..0d22fac70 100644 --- a/infer/src/biabduction/State.mli +++ b/infer/src/biabduction/State.mli @@ -75,9 +75,9 @@ val mk_find_duplicate_nodes : Procdesc.t -> Procdesc.Node.t -> Procdesc.NodeSet. and normalized (w.r.t. renaming of let - bound ids) list of instructions. *) type log_issue = - Typ.Procname.t -> ?node_id_key:Errlog.node_id_key -> ?loc:Location.t -> ?session:int - -> ?ltr:Errlog.loc_trace -> ?linters_def_file:string -> ?doc_url:string -> ?access:string - -> ?extras:Jsonbug_t.extra -> exn -> unit + Typ.Procname.t -> ?node_id_key:Errlog.node_id_key -> ?loc:Location.t -> ?ltr:Errlog.loc_trace + -> ?linters_def_file:string -> ?doc_url:string -> ?access:string -> ?extras:Jsonbug_t.extra + -> exn -> unit val process_execution_failures : log_issue -> Typ.Procname.t -> unit (** Process the failures during symbolic execution of a procedure *)