Reporting cleanup 1: log_issue_deprecated

Summary:
- inlined `log_info/warning/error_deprecated` to make calls to `log_issue_deprecated` easier to grep
- removed unused optional `store_summary`
- removed 'not supported severity'

Reviewed By: jvillard

Differential Revision: D9332733

fbshipit-source-id: 821324c21
master
Mehdi Bouaziz 6 years ago committed by Facebook Github Bot
parent ecde8a7660
commit f08ba1c016

@ -62,15 +62,12 @@ let log_issue_from_summary severity summary ?loc ?node_id ?session ?ltr ?linters
?linters_def_file ?doc_url ?access ?extras exn
let log_issue_deprecated ?(store_summary= false) severity proc_name ?loc ?node_id ?session ?ltr
?linters_def_file ?doc_url ?access ?extras:_ exn =
let log_issue_deprecated severity proc_name ?loc ?node_id ?session ?ltr ?linters_def_file ?doc_url
?access ?extras:_ exn =
match Summary.get proc_name with
| Some summary ->
log_issue_from_summary severity summary ?loc ?node_id ?session ?ltr ?linters_def_file
?doc_url ?access exn ;
if store_summary then
(* TODO (#16348004): This is currently needed as ThreadSafety works as a cluster checker *)
Summary.store summary
?doc_url ?access exn
| None ->
L.(die InternalError)
"Trying to report error on procedure %a, but cannot because no summary exists for this \
@ -82,18 +79,6 @@ let log_error = log_issue_from_summary Exceptions.Error
let log_warning = log_issue_from_summary Exceptions.Warning
let log_error_deprecated ?(store_summary= false) =
log_issue_deprecated ~store_summary Exceptions.Error
let log_warning_deprecated ?(store_summary= false) =
log_issue_deprecated ~store_summary Exceptions.Warning
let log_info_deprecated ?(store_summary= false) =
log_issue_deprecated ~store_summary Exceptions.Info
let log_issue_external procname ?clang_method_kind severity ?loc ?node_id ?session ?ltr
?linters_def_file ?doc_url ?access ?extras exn =
let errlog = IssueLog.get_errlog procname in

@ -16,20 +16,10 @@ type log_t =
type log_issue_from_errlog = Errlog.t -> log_t
val log_error_deprecated : ?store_summary:bool -> Typ.Procname.t -> log_t
(** Report an error in the given procedure.
val log_issue_deprecated : Exceptions.severity -> Typ.Procname.t -> log_t
(** Report an issue in the given procedure.
DEPRECATED as it can create race conditions between checkers.
Use log_error instead *)
val log_warning_deprecated : ?store_summary:bool -> Typ.Procname.t -> log_t
(** Report a warning in the given procedure.
DEPRECATED as it can create race conditions between checkers.
Use log_warning instead *)
val log_info_deprecated : ?store_summary:bool -> Typ.Procname.t -> log_t
(** Report an info in the given procedure.
DEPRECATED as it can create race conditions between checkers.
Use log_info instead *)
Use log_error/warning instead *)
val log_issue_from_errlog :
Typ.Procname.t -> ?clang_method_kind:ProcAttributes.clang_method_kind -> Exceptions.severity

@ -1122,7 +1122,7 @@ let check_junk pname tenv prop =
let report_leak () =
if not report_and_continue then raise exn
else (
Reporting.log_error_deprecated pname exn ;
Reporting.log_issue_deprecated Exceptions.Error pname exn ;
leaks_reported := alloc_attribute :: !leaks_reported )
in
if not ignore_leak then report_leak () ;

@ -2620,7 +2620,7 @@ let check_implication_base pname tenv check_frame_empty calc_missing prop1 prop2
L.d_strln ("WARNING: footprint failed to find MISSING because: " ^ s) ;
None
| Exceptions.Abduction_case_not_implemented _ as exn ->
Reporting.log_error_deprecated pname exn ;
Reporting.log_issue_deprecated Exceptions.Error pname exn ;
None

@ -59,7 +59,7 @@ let check_bad_index tenv pname p len index loc =
Exceptions.Array_out_of_bounds_l1
(Errdesc.explain_array_access pname tenv deref_str p loc, __POS__)
in
Reporting.log_warning_deprecated pname exn
Reporting.log_issue_deprecated Exceptions.Warning pname exn
else if len_is_constant then
let deref_str = Localise.deref_str_array_bound len_const_opt index_const_opt in
let desc = Errdesc.explain_array_access pname tenv deref_str p loc in
@ -67,7 +67,7 @@ let check_bad_index tenv pname p len index loc =
if index_has_bounds () then Exceptions.Array_out_of_bounds_l2 (desc, __POS__)
else Exceptions.Array_out_of_bounds_l3 (desc, __POS__)
in
Reporting.log_warning_deprecated pname exn
Reporting.log_issue_deprecated Exceptions.Warning pname exn
(** Perform bounds checking *)
@ -906,7 +906,7 @@ let add_guarded_by_constraints tenv prop lexp pdesc =
let loc = State.get_loc () in
let err_desc = Localise.desc_unsafe_guarded_by_access accessed_fld guarded_by_str loc in
let exn = Exceptions.Unsafe_guarded_by_access (err_desc, __POS__) in
Reporting.log_error_deprecated pname exn
Reporting.log_issue_deprecated Exceptions.Error pname exn
in
let rec is_read_write_lock typ =
let str_is_read_write_lock str =
@ -1351,7 +1351,7 @@ let check_type_size tenv pname prop texp off typ_from_instr =
Exceptions.Pointer_size_mismatch
(Errdesc.explain_dereference pname tenv deref_str prop loc, __POS__)
in
Reporting.log_warning_deprecated pname exn
Reporting.log_issue_deprecated Exceptions.Warning pname exn
| None ->
L.d_str "texp: " ; Sil.d_texp_full texp ; L.d_ln ()

@ -299,9 +299,9 @@ let mark_instr_fail exn =
type log_issue =
?store_summary:bool -> Typ.Procname.t -> ?loc:Location.t -> ?node_id:int * Caml.Digest.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 -> ?loc:Location.t -> ?node_id:int * Caml.Digest.t -> ?session:int
-> ?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 =

@ -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 =
?store_summary:bool -> Typ.Procname.t -> ?loc:Location.t -> ?node_id:int * Caml.Digest.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 -> ?loc:Location.t -> ?node_id:int * Caml.Digest.t -> ?session:int
-> ?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 *)

@ -353,7 +353,7 @@ let check_inherently_dangerous_function caller_pname callee_pname =
Exceptions.Inherently_dangerous_function
(Localise.desc_inherently_dangerous_function callee_pname)
in
Reporting.log_warning_deprecated caller_pname exn
Reporting.log_issue_deprecated Exceptions.Warning caller_pname exn
let reason_to_skip ~callee_desc : string option =
@ -414,7 +414,7 @@ let check_arith_norm_exp tenv pname exp prop =
| Some (Attribute.Div0 div), prop' ->
let desc = Errdesc.explain_divide_by_zero tenv div (State.get_node ()) (State.get_loc ()) in
let exn = Exceptions.Divide_by_zero (desc, __POS__) in
Reporting.log_warning_deprecated pname exn ;
Reporting.log_issue_deprecated Exceptions.Warning pname exn ;
(Prop.exp_normalize_prop tenv prop exp, prop')
| Some (Attribute.UminusUnsigned (e, typ)), prop' ->
let desc =
@ -422,7 +422,7 @@ let check_arith_norm_exp tenv pname exp prop =
(State.get_loc ())
in
let exn = Exceptions.Unary_minus_applied_to_unsigned_expression (desc, __POS__) in
Reporting.log_warning_deprecated pname exn ;
Reporting.log_issue_deprecated Exceptions.Warning pname exn ;
(Prop.exp_normalize_prop tenv prop exp, prop')
| None, prop' ->
(Prop.exp_normalize_prop tenv prop exp, prop')
@ -480,7 +480,7 @@ let check_already_dereferenced tenv pname cond prop =
(State.get_loc ())
in
let exn = Exceptions.Null_test_after_dereference (desc, __POS__) in
Reporting.log_warning_deprecated pname exn
Reporting.log_issue_deprecated Exceptions.Warning pname exn
| None ->
()
@ -1244,7 +1244,7 @@ let rec sym_exec exe_env tenv current_pdesc instr_ (prop_: Prop.normal Prop.t) p
callee_pname ret_annots loc ret_id_typ ret_typ actual_args =
let skip_res () =
let exn = Exceptions.Skip_function (Localise.desc_skip_function callee_pname) in
Reporting.log_info_deprecated current_pname exn ;
Reporting.log_issue_deprecated Exceptions.Info current_pname exn ;
L.d_strln
(F.sprintf "Skipping function '%s': %s" (Typ.Procname.to_string callee_pname) reason) ;
Tabulation.log_call_trace ~caller_name:current_pname ~callee_name:callee_pname
@ -1311,7 +1311,7 @@ let rec sym_exec exe_env tenv current_pdesc instr_ (prop_: Prop.normal Prop.t) p
let exn =
Exceptions.Condition_always_true_false (desc, not (IntLit.iszero i), __POS__)
in
Reporting.log_warning_deprecated current_pname exn
Reporting.log_issue_deprecated Exceptions.Warning current_pname exn
| _ ->
()
in

@ -464,7 +464,7 @@ let check_path_errors_in_post tenv caller_pname post post_path =
in
State.set_path new_path path_pos_opt ;
let exn = Exceptions.Divide_by_zero (desc, __POS__) in
Reporting.log_warning_deprecated caller_pname exn )
Reporting.log_issue_deprecated Exceptions.Warning caller_pname exn )
| _ ->
()
in
@ -1189,7 +1189,7 @@ let exe_spec exe_env tenv ret_id (n, nspecs) caller_pdesc callee_pname loc prop
missing_sigma_objc_class callee_summary ) ;
let log_check_exn check =
let exn = get_check_exn tenv check callee_pname loc __POS__ in
Reporting.log_warning_deprecated caller_pname exn
Reporting.log_issue_deprecated Exceptions.Warning caller_pname exn
in
let do_split () =
process_splitting actual_pre sub1 sub2 frame missing_pi missing_sigma frame_fld missing_fld

@ -417,7 +417,7 @@ let forward_tabulate summary exe_env tenv proc_cfg wl =
L.d_strln "SIL INSTR:" ;
Procdesc.Node.d_instrs ~sub_instrs:true (State.get_instr ()) curr_node ;
L.d_ln () ;
Reporting.log_error_deprecated pname exn ;
Reporting.log_issue_deprecated Exceptions.Error pname exn ;
State.mark_instr_fail exn
in
let exe_iter f pathset =
@ -525,7 +525,7 @@ let remove_locals_formals_and_check tenv proc_cfg p =
let dexp_opt, _ = Errdesc.vpath_find tenv p (Exp.Lvar pvar) in
let desc = Errdesc.explain_stack_variable_address_escape loc pvar dexp_opt in
let exn = Exceptions.Stack_variable_address_escape (desc, __POS__) in
Reporting.log_warning_deprecated pname exn
Reporting.log_issue_deprecated Exceptions.Warning pname exn
in
List.iter ~f:check_pvar pvars ; p'
@ -861,7 +861,7 @@ let perform_analysis_phase exe_env tenv (summary: Summary.t) (proc_cfg: ProcCfg.
forward_tabulate summary exe_env tenv proc_cfg wl
in
let get_results (wl: Worklist.t) () =
State.process_execution_failures Reporting.log_warning_deprecated pname ;
State.process_execution_failures (Reporting.log_issue_deprecated Exceptions.Warning) pname ;
let results = collect_analysis_result tenv wl proc_cfg in
let specs =
try extract_specs tenv (ProcCfg.Exceptional.proc_desc proc_cfg) results
@ -870,7 +870,7 @@ let perform_analysis_phase exe_env tenv (summary: Summary.t) (proc_cfg: ProcCfg.
Exceptions.Internal_error
(Localise.verbatim_desc "Leak_while_collecting_specs_after_footprint")
in
Reporting.log_error_deprecated pname exn ;
Reporting.log_issue_deprecated Exceptions.Error pname exn ;
(* retuning no specs *) []
in
(specs, BiabductionSummary.FOOTPRINT)
@ -1029,7 +1029,7 @@ let report_runtime_exceptions tenv pdesc summary =
in
let exn_desc = Localise.java_unchecked_exn_desc pname runtime_exception pre_str in
let exn = Exceptions.Java_runtime_exception (runtime_exception, pre_str, exn_desc) in
Reporting.log_error_deprecated pname exn
Reporting.log_issue_deprecated Exceptions.Error pname exn
in
List.iter ~f:report exn_preconditions
@ -1042,7 +1042,7 @@ let report_custom_errors tenv summary =
let loc = Summary.get_loc summary in
let err_desc = Localise.desc_custom_error loc in
let exn = Exceptions.Custom_error (custom_error, err_desc) in
Reporting.log_error_deprecated pname exn
Reporting.log_issue_deprecated Exceptions.Error pname exn
in
List.iter ~f:report error_preconditions

@ -6,7 +6,6 @@
*)
open! IStd
module L = Logging
(** Module for user-defined checkers. *)
@ -14,18 +13,10 @@ module ST = struct
let report_error tenv proc_name proc_desc kind loc ?(field_name= None) ?(origin_loc= None)
?(exception_kind= fun k d -> Exceptions.Checkers (k, d)) ?(severity= Exceptions.Warning)
description =
let log =
match severity with
| Exceptions.Warning ->
Reporting.log_warning_deprecated
| Exceptions.Error ->
Reporting.log_error_deprecated
| _ ->
L.(die InternalError) "Severity not supported"
in
let suppressed = Reporting.is_suppressed tenv proc_desc kind ~field_name in
if not suppressed then
let localized_description = Localise.custom_desc description [] in
let exn = exception_kind kind localized_description in
let suppressed = Reporting.is_suppressed tenv proc_desc kind ~field_name in
let trace =
let origin_elements =
match origin_loc with
@ -36,5 +27,5 @@ module ST = struct
in
origin_elements @ [Errlog.make_trace_element 0 loc description []]
in
if not suppressed then log proc_name ~loc ~ltr:trace exn
Reporting.log_issue_deprecated severity proc_name ~loc ~ltr:trace exn
end

Loading…
Cancel
Save