Reporting cleanup 21: do not keep in-re-execution issues

Reviewed By: jeremydubreil

Differential Revision: D9754854

fbshipit-source-id: f5853bb00
master
Mehdi Bouaziz 6 years ago committed by Facebook Github Bot
parent 9318a22b29
commit 247e785ae4

@ -65,11 +65,7 @@ type node =
| FrontendNode of {node_key: Procdesc.NodeKey.t} | FrontendNode of {node_key: Procdesc.NodeKey.t}
| BackendNode of {node: Procdesc.Node.t} | BackendNode of {node: Procdesc.Node.t}
type err_key = type err_key = {severity: Exceptions.severity; err_name: IssueType.t; err_desc: Localise.error_desc}
{ severity: Exceptions.severity
; in_footprint: bool
; err_name: IssueType.t
; err_desc: Localise.error_desc }
[@@deriving compare] [@@deriving compare]
(** Data associated to a specific error *) (** Data associated to a specific error *)
@ -103,15 +99,11 @@ module ErrLogHash = struct
type t = err_key type t = err_key
(* NOTE: changing the hash function can change the order in which issues are reported. *) (* NOTE: changing the hash function can change the order in which issues are reported. *)
let hash key = let hash key = Hashtbl.hash (key.severity, key.err_name, Localise.error_desc_hash key.err_desc)
Hashtbl.hash
(key.severity, key.in_footprint, key.err_name, Localise.error_desc_hash key.err_desc)
let equal key1 key2 = let equal key1 key2 =
[%compare.equal: Exceptions.severity * bool * IssueType.t] [%compare.equal: Exceptions.severity * IssueType.t] (key1.severity, key1.err_name)
(key1.severity, key1.in_footprint, key1.err_name) (key2.severity, key2.err_name)
(key2.severity, key2.in_footprint, key2.err_name)
&& Localise.error_desc_equal key1.err_desc key2.err_desc && Localise.error_desc_equal key1.err_desc key2.err_desc
end end
@ -147,8 +139,7 @@ let size filter (err_log : t) =
let count = ref 0 in let count = ref 0 in
ErrLogHash.iter ErrLogHash.iter
(fun key err_datas -> (fun key err_datas ->
if filter key.severity key.in_footprint then count := !count + ErrDataSet.cardinal err_datas if filter key.severity then count := !count + ErrDataSet.cardinal err_datas )
)
err_log ; err_log ;
!count !count
@ -180,20 +171,17 @@ let pp_html source path_to_root fmt (errlog : t) =
in in
ErrDataSet.iter (pp_nodeid_session_loc fmt) err_datas ErrDataSet.iter (pp_nodeid_session_loc fmt) err_datas
in in
let pp_err_log do_fp ek key err_datas = let pp_err_log ek key err_datas =
if Exceptions.equal_severity key.severity ek && Bool.equal do_fp key.in_footprint then if Exceptions.equal_severity key.severity ek then
F.fprintf fmt "<br>%a %a %a" IssueType.pp key.err_name Localise.pp_error_desc key.err_desc F.fprintf fmt "<br>%a %a %a" IssueType.pp key.err_name Localise.pp_error_desc key.err_desc
pp_eds err_datas pp_eds err_datas
in in
let pp severity is_footprint phase = let pp severity =
F.fprintf fmt "%a%s DURING %s@\n" Io_infer.Html.pp_hline () F.fprintf fmt "%a%s DURING FOOTPRINT@\n" Io_infer.Html.pp_hline ()
(Exceptions.severity_string severity) (Exceptions.severity_string severity) ;
phase ; ErrLogHash.iter (pp_err_log severity) errlog
ErrLogHash.iter (pp_err_log is_footprint severity) errlog
in in
List.iter List.iter Exceptions.[Advice; Error; Info; Like; Warning] ~f:pp
Exceptions.[Advice; Error; Info; Like; Warning]
~f:(fun severity -> pp severity true "FOOTPRINT" ; pp severity false "RE-EXECUTION")
(** Add an error description to the error log unless there is (** Add an error description to the error log unless there is
@ -286,12 +274,7 @@ let log_issue procname ~clang_method_kind severity err_log ~loc ~node ~session ~
; access ; access
; extras } ; extras }
in in
let err_key = let err_key = {severity; err_name= error.name; err_desc= error.description} in
{ severity
; in_footprint= !Config.footprint
; err_name= error.name
; err_desc= error.description }
in
add_issue err_log err_key (ErrDataSet.singleton err_data) add_issue err_log err_key (ErrDataSet.singleton err_data)
in in
let should_print_now = match exn with Exceptions.Internal_error _ -> true | _ -> added in let should_print_now = match exn with Exceptions.Internal_error _ -> true | _ -> added in

@ -40,10 +40,7 @@ type node =
| BackendNode of {node: Procdesc.Node.t} | BackendNode of {node: Procdesc.Node.t}
type err_key = private type err_key = private
{ severity: Exceptions.severity {severity: Exceptions.severity; err_name: IssueType.t; err_desc: Localise.error_desc}
; in_footprint: bool
; err_name: IssueType.t
; err_desc: Localise.error_desc }
[@@deriving compare] [@@deriving compare]
(** Data associated to a specific error *) (** Data associated to a specific error *)
@ -88,7 +85,7 @@ val pp_warnings : Format.formatter -> t -> unit
val pp_html : SourceFile.t -> DB.Results_dir.path -> Format.formatter -> t -> unit val pp_html : SourceFile.t -> DB.Results_dir.path -> Format.formatter -> t -> unit
(** Print an error log in html format *) (** Print an error log in html format *)
val size : (Exceptions.severity -> bool -> bool) -> t -> int val size : (Exceptions.severity -> bool) -> t -> int
(** Return the number of elements in the error log which satisfy the filter. *) (** Return the number of elements in the error log which satisfy the filter. *)
val update : t -> t -> unit val update : t -> t -> unit

@ -122,11 +122,7 @@ let summary_values summary =
; vspecs= List.length specs ; vspecs= List.length specs
; vto= Summary.Stats.failure_kind_to_string stats ; vto= Summary.Stats.failure_kind_to_string stats
; vsymop= Summary.Stats.symops stats ; vsymop= Summary.Stats.symops stats
; verr= ; verr= Errlog.size (Exceptions.equal_severity Exceptions.Error) err_log
Errlog.size
(fun severity in_footprint ->
Exceptions.equal_severity severity Exceptions.Error && in_footprint )
err_log
; vflags= attributes.ProcAttributes.proc_flags ; vflags= attributes.ProcAttributes.proc_flags
; vfile= SourceFile.to_string attributes.ProcAttributes.loc.Location.file ; vfile= SourceFile.to_string attributes.ProcAttributes.loc.Location.file
; vline= attributes.ProcAttributes.loc.Location.line ; vline= attributes.ProcAttributes.loc.Location.line
@ -264,8 +260,7 @@ module JsonIssuePrinter = MakeJsonListPrinter (struct
(not (SourceFile.is_infer_model source_file)) || Config.debug_mode || Config.debug_exceptions (not (SourceFile.is_infer_model source_file)) || Config.debug_mode || Config.debug_exceptions
in in
if if
err_key.in_footprint error_filter source_file err_key.err_name
&& error_filter source_file err_key.err_name
&& should_report_source_file && should_report_source_file
&& should_report err_key.severity err_key.err_name err_key.err_desc err_data.err_class && should_report err_key.severity err_key.err_name err_key.err_desc err_data.err_class
then then
@ -451,8 +446,7 @@ module IssuesTxt = struct
err_data.loc.Location.file err_data.loc.Location.file
in in
if if
key.in_footprint error_filter source_file key.err_name
&& error_filter source_file key.err_name
&& ((not Config.filtering) || String.is_empty (censored_reason key.err_name source_file)) && ((not Config.filtering) || String.is_empty (censored_reason key.err_name source_file))
then Exceptions.pp_err err_data.loc key.severity key.err_name key.err_desc None fmt () then Exceptions.pp_err err_data.loc key.severity key.err_name key.err_desc None fmt ()
@ -543,7 +537,7 @@ module Stats = struct
let found_errors = ref false in let found_errors = ref false in
let process_row (key : Errlog.err_key) (err_data : Errlog.err_data) = let process_row (key : Errlog.err_key) (err_data : Errlog.err_data) =
let type_str = key.err_name.IssueType.unique_id in let type_str = key.err_name.IssueType.unique_id in
if key.in_footprint && error_filter key.err_name then if error_filter key.err_name then
match key.severity with match key.severity with
| Exceptions.Error -> | Exceptions.Error ->
found_errors := true ; found_errors := true ;

@ -50,21 +50,22 @@ let log_issue_from_summary severity summary ~node ~session ~loc ~ltr ?extras exn
let log_issue_deprecated_using_state severity proc_name ?node ?loc ?ltr exn = let log_issue_deprecated_using_state severity proc_name ?node ?loc ?ltr exn =
match Summary.get proc_name with if !Config.footprint then
| Some summary -> match Summary.get proc_name with
let node = | Some summary ->
let node = match node with None -> State.get_node_exn () | Some node -> node in let node =
Errlog.BackendNode {node} let node = match node with None -> State.get_node_exn () | Some node -> node in
in Errlog.BackendNode {node}
let session = State.get_session () in in
let loc = match loc with None -> State.get_loc_exn () | Some loc -> loc in let session = State.get_session () in
let ltr = match ltr with None -> State.get_loc_trace () | Some ltr -> ltr in let loc = match loc with None -> State.get_loc_exn () | Some loc -> loc in
log_issue_from_summary severity summary ~node ~session ~loc ~ltr exn let ltr = match ltr with None -> State.get_loc_trace () | Some ltr -> ltr in
| None -> log_issue_from_summary severity summary ~node ~session ~loc ~ltr exn
L.(die InternalError) | None ->
"Trying to report error on procedure %a, but cannot because no summary exists for this \ L.(die InternalError)
procedure. Did you mean to log the error on the caller of %a instead?" "Trying to report error on procedure %a, but cannot because no summary exists for this \
Typ.Procname.pp proc_name Typ.Procname.pp proc_name procedure. Did you mean to log the error on the caller of %a instead?"
Typ.Procname.pp proc_name Typ.Procname.pp proc_name
let log_issue_from_summary_simplified severity summary ~loc ?(ltr = []) ?extras exn = let log_issue_from_summary_simplified severity summary ~loc ?(ltr = []) ?extras exn =
@ -84,11 +85,12 @@ let log_issue_external procname severity ~loc ~ltr ?access issue_type error_mess
let log_error_using_state summary exn = let log_error_using_state summary exn =
let node = Errlog.BackendNode {node= State.get_node_exn ()} in if !Config.footprint then
let session = State.get_session () in let node = Errlog.BackendNode {node= State.get_node_exn ()} in
let loc = State.get_loc_exn () in let session = State.get_session () in
let ltr = State.get_loc_trace () in let loc = State.get_loc_exn () in
log_issue_from_summary Exceptions.Error summary ~node ~session ~loc ~ltr exn let ltr = State.get_loc_trace () in
log_issue_from_summary Exceptions.Error summary ~node ~session ~loc ~ltr exn
let is_suppressed ?(field_name = None) tenv proc_desc kind = let is_suppressed ?(field_name = None) tenv proc_desc kind =

@ -74,10 +74,9 @@ module TransferFunctions (CFG : ProcCfg.S) = struct
if not Config.filtering then false if not Config.filtering then false
else else
Errlog.fold Errlog.fold
(fun {Errlog.err_name; err_desc; in_footprint} {Errlog.loc} found_confict -> (fun {Errlog.err_name; err_desc} {Errlog.loc} found_confict ->
found_confict found_confict
|| in_footprint || IssueType.equal err_name IssueType.null_dereference
&& IssueType.equal err_name IssueType.null_dereference
&& Location.equal loc report_location && Location.equal loc report_location
&& Localise.error_desc_is_reportable_bucket err_desc ) && Localise.error_desc_is_reportable_bucket err_desc )
(Summary.get_err_log summary) false (Summary.get_err_log summary) false

Loading…
Cancel
Save