split reporting.ml for dependencies

Summary:
This is a step in disentangling the various analyses: that file used to
make every checker on biabduction because of a few of its functions that
use biabduction datatypes.

Split reporting.ml into:
- Reporting.ml: the functions all checkers need to report errors. This
  is put in absint/ with the other files that are needed by all
  checkers.
- SummaryReporting.ml: functions that need to depend on Summary.ml
  (useful for later). This is put in backend/ where Summary.ml lives.
- BiabductionReporting.ml: for the biabduction analysis

The rest of the changes are renames to use the appropriate module
amongst the above.

Reviewed By: ngorogiannis

Differential Revision: D21257468

fbshipit-source-id: fa28cefbc
master
Jules Villard 5 years ago committed by Facebook GitHub Bot
parent d8e3cea7fd
commit a144c8e4df

@ -6,7 +6,6 @@
*)
open! IStd
module L = Logging
type log_t = ?ltr:Errlog.loc_trace -> ?extras:Jsonbug_t.extra -> IssueType.t -> string -> unit
@ -24,9 +23,8 @@ let log_frontend_issue severity errlog ~loc ~node_key ~ltr exn =
log_issue_from_errlog severity errlog ~loc ~node ~session:0 ~ltr ~access:None ~extras:None exn
let log_issue_from_summary severity summary ~node ~session ~loc ~ltr ?extras exn =
let attrs = Summary.get_attributes summary in
let procname = attrs.proc_name in
let log_issue_from_summary severity proc_attributes err_log ~node ~session ~loc ~ltr ?extras exn =
let procname = proc_attributes.ProcAttributes.proc_name in
let is_java_generated_method =
match procname with
| Procname.Java java_pname ->
@ -43,48 +41,33 @@ let log_issue_from_summary severity summary ~node ~session ~loc ~ltr ?extras exn
in
let should_suppress_lint =
Language.curr_language_is Java
&& Annotations.ia_is_suppress_lint
(Summary.get_attributes summary).ProcAttributes.method_annotation.return
&& Annotations.ia_is_suppress_lint proc_attributes.ProcAttributes.method_annotation.return
in
if should_suppress_lint || is_java_generated_method || is_java_external_package then ()
(* Skip the reporting *)
else
let err_log = Summary.get_err_log summary in
log_issue_from_errlog severity err_log ~loc ~node ~session ~ltr ~access:None ~extras exn
let log_issue_deprecated_using_state severity proc_name ?node ?loc ?ltr exn =
if !BiabductionConfig.footprint then
match Summary.OnDisk.get proc_name with
| Some summary ->
let node =
let node = match node with None -> State.get_node_exn () | Some node -> node in
Errlog.BackendNode {node}
in
let session = State.get_session () in
let loc = match loc with None -> State.get_loc_exn () | Some loc -> loc in
let ltr = match ltr with None -> State.get_loc_trace () | Some ltr -> ltr in
log_issue_from_summary severity summary ~node ~session ~loc ~ltr exn
| None ->
L.(die InternalError)
"Trying to report error on procedure %a, but cannot because no summary exists for this \
procedure. Did you mean to log the error on the caller of %a instead?"
Procname.pp proc_name Procname.pp proc_name
else log_issue_from_errlog severity err_log ~loc ~node ~session ~ltr ~access:None ~extras exn
let checker_exception issue_type error_message =
Exceptions.Checkers (issue_type, Localise.verbatim_desc error_message)
let log_issue_from_summary_simplified severity summary ~loc ?(ltr = []) ?extras issue_type
let log_issue_from_summary_simplified severity attrs err_log ~loc ?(ltr = []) ?extras issue_type
error_message =
let exn = checker_exception issue_type error_message in
log_issue_from_summary severity summary ~node:Errlog.UnknownNode ~session:0 ~loc ~ltr ?extras exn
log_issue_from_summary severity attrs err_log ~node:Errlog.UnknownNode ~session:0 ~loc ~ltr
?extras exn
let log_error attrs err_log ~loc ?ltr ?extras issue_type error_message =
log_issue_from_summary_simplified Exceptions.Error attrs err_log ~loc ?ltr ?extras issue_type
error_message
let log_error = log_issue_from_summary_simplified Exceptions.Error
let log_warning = log_issue_from_summary_simplified Exceptions.Warning
let log_warning attrs err_log ~loc ?ltr ?extras issue_type error_message =
log_issue_from_summary_simplified Exceptions.Warning attrs err_log ~loc ?ltr ?extras issue_type
error_message
let log_issue_external procname ~issue_log severity ~loc ~ltr ?access ?extras issue_type
error_message =
@ -95,22 +78,6 @@ let log_issue_external procname ~issue_log severity ~loc ~ltr ?access ?extras is
issue_log
let log_error_using_state summary exn =
if !BiabductionConfig.footprint then
let node' =
match State.get_node () with
| Some n ->
n
| None ->
Procdesc.get_start_node (Summary.get_proc_desc summary)
in
let node = Errlog.BackendNode {node= node'} in
let session = State.get_session () in
let loc = match State.get_loc () with Some l -> l | None -> Procdesc.Node.get_loc node' in
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 lookup = Tenv.lookup tenv in
let proc_attributes = Procdesc.get_attributes proc_desc in

@ -11,16 +11,17 @@ open! IStd
type log_t = ?ltr:Errlog.loc_trace -> ?extras:Jsonbug_t.extra -> IssueType.t -> string -> unit
val log_issue_deprecated_using_state :
val log_issue_from_summary :
Exceptions.severity
-> Procname.t
-> ?node:Procdesc.Node.t
-> ?loc:Location.t
-> ?ltr:Errlog.loc_trace
-> ProcAttributes.t
-> Errlog.t
-> node:Errlog.node
-> session:int
-> loc:Location.t
-> ltr:Errlog.loc_trace
-> ?extras:Jsonbug_t.extra
-> exn
-> unit
(** Report an issue in the given procedure using biabduction state (DO NOT USE ELSEWHERE).
DEPRECATED as it can create race conditions between checkers. Use log_error/warning instead *)
val log_frontend_issue :
Exceptions.severity
@ -32,14 +33,11 @@ val log_frontend_issue :
-> unit
(** Report a frontend issue of a given kind in the given error log. *)
val log_error : Summary.t -> loc:Location.t -> log_t
(** Add an error to the given summary. *)
val log_warning : Summary.t -> loc:Location.t -> log_t
(** Add an warning to the given summary. *)
val log_error : ProcAttributes.t -> Errlog.t -> loc:Location.t -> log_t
(** Add an error to the given error log. *)
val log_error_using_state : Summary.t -> exn -> unit
(** Add an error to the given summary using biabduction state (DO NOT USE ELSEWHERE). *)
val log_warning : ProcAttributes.t -> Errlog.t -> loc:Location.t -> log_t
(** Add a warning to the given error log. *)
val log_issue_external :
Procname.t

@ -0,0 +1,26 @@
(*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*)
open! IStd
type log_t = Reporting.log_t
let log_error summary ~loc ?ltr ?extras issue_type error_message =
let attrs = Summary.get_attributes summary in
let err_log = Summary.get_err_log summary in
Reporting.log_error attrs err_log ~loc ?ltr ?extras issue_type error_message
let log_warning summary ~loc ?ltr ?extras issue_type error_message =
let attrs = Summary.get_attributes summary in
let err_log = Summary.get_err_log summary in
Reporting.log_warning attrs err_log ~loc ?ltr ?extras issue_type error_message
let log_error_using_state summary exn =
BiabductionReporting.log_error_using_state (Summary.get_proc_desc summary)
(Summary.get_err_log summary) exn

@ -0,0 +1,21 @@
(*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*)
open! IStd
(** convencience functions on top of {!Reporting} *)
type log_t = Reporting.log_t
val log_error : Summary.t -> loc:Location.t -> log_t
(** Add an error to the given summary. *)
val log_warning : Summary.t -> loc:Location.t -> log_t
(** Add a warning to the given summary. *)
val log_error_using_state : Summary.t -> exn -> unit
(** Add an error to the given summary using biabduction state (DO NOT USE ELSEWHERE). *)

@ -189,7 +189,7 @@ let run_proc_analysis ~caller_pdesc callee_pdesc =
summary
in
let log_error_and_continue exn (summary : Summary.t) kind =
Reporting.log_error_using_state summary exn ;
SummaryReporting.log_error_using_state summary exn ;
let stats = Summary.Stats.update summary.stats ~failure_kind:kind in
let payloads =
let biabduction =

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

@ -0,0 +1,41 @@
(*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*)
open! IStd
module L = Logging
let log_issue_deprecated_using_state severity proc_name ?node ?loc ?ltr exn =
if !BiabductionConfig.footprint then
match Summary.OnDisk.get proc_name with
| Some summary ->
let node =
let node = match node with None -> State.get_node_exn () | Some node -> node in
Errlog.BackendNode {node}
in
let session = State.get_session () in
let loc = match loc with None -> State.get_loc_exn () | Some loc -> loc in
let ltr = match ltr with None -> State.get_loc_trace () | Some ltr -> ltr in
Reporting.log_issue_from_summary severity (Summary.get_attributes summary)
summary.Summary.err_log ~node ~session ~loc ~ltr exn
| None ->
L.(die InternalError)
"Trying to report error on procedure %a, but cannot because no summary exists for this \
procedure. Did you mean to log the error on the caller of %a instead?"
Procname.pp proc_name Procname.pp proc_name
let log_error_using_state proc_desc err_log exn =
if !BiabductionConfig.footprint then
let node' =
match State.get_node () with Some n -> n | None -> Procdesc.get_start_node proc_desc
in
let node = Errlog.BackendNode {node= node'} in
let session = State.get_session () in
let loc = match State.get_loc () with Some l -> l | None -> Procdesc.Node.get_loc node' in
let ltr = State.get_loc_trace () in
let attrs = Procdesc.get_attributes proc_desc in
Reporting.log_issue_from_summary Exceptions.Error attrs err_log ~node ~session ~loc ~ltr exn

@ -0,0 +1,22 @@
(*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*)
open! IStd
val log_error_using_state : Procdesc.t -> Errlog.t -> exn -> unit
(** Add an error to the given summary using biabduction state. *)
val log_issue_deprecated_using_state :
Exceptions.severity
-> Procname.t
-> ?node:Procdesc.Node.t
-> ?loc:Location.t
-> ?ltr:Errlog.loc_trace
-> exn
-> unit
(** Report an issue in the given procedure using biabduction state. DEPRECATED as it can create race
conditions between checkers. Use log_error_using_state instead *)

@ -2573,7 +2573,7 @@ let check_implication_base pname tenv check_frame_empty calc_missing prop1 prop2
L.d_printfln "WARNING: footprint failed to find MISSING because: %s" s ;
None
| Exceptions.Abduction_case_not_implemented _ as exn ->
Reporting.log_issue_deprecated_using_state Exceptions.Error pname exn ;
BiabductionReporting.log_issue_deprecated_using_state Exceptions.Error pname exn ;
None

@ -55,7 +55,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_issue_deprecated_using_state Exceptions.Warning pname exn
BiabductionReporting.log_issue_deprecated_using_state 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
@ -63,7 +63,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_issue_deprecated_using_state Exceptions.Warning pname exn
BiabductionReporting.log_issue_deprecated_using_state Exceptions.Warning pname exn
(** Perform bounds checking *)
@ -991,7 +991,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_issue_deprecated_using_state Exceptions.Warning pname exn
BiabductionReporting.log_issue_deprecated_using_state Exceptions.Warning pname exn
| None ->
L.d_str "texp: " ; Exp.d_texp_full texp ; L.d_ln ()

@ -243,7 +243,7 @@ let report_cycle tenv summary prop =
RetainCyclesType.Set.iter
(fun cycle ->
let exn = exn_retain_cycle tenv cycle in
Reporting.log_error_using_state summary exn )
SummaryReporting.log_error_using_state summary exn )
cycles ;
(* we report the retain cycles above but need to raise an exception as well to stop the analysis *)
raise (Exceptions.Dummy_exception (Localise.verbatim_desc "retain cycle found")) )

@ -344,7 +344,7 @@ let check_inherently_dangerous_function caller_pname callee_pname =
Exceptions.Inherently_dangerous_function
(Localise.desc_inherently_dangerous_function callee_pname)
in
Reporting.log_issue_deprecated_using_state Exceptions.Warning caller_pname exn
BiabductionReporting.log_issue_deprecated_using_state Exceptions.Warning caller_pname exn
let reason_to_skip ~callee_desc : string option =
@ -408,7 +408,7 @@ let check_arith_norm_exp tenv pname exp prop =
Errdesc.explain_divide_by_zero tenv div (State.get_node_exn ()) (State.get_loc_exn ())
in
let exn = Exceptions.Divide_by_zero (desc, __POS__) in
Reporting.log_issue_deprecated_using_state Exceptions.Warning pname exn ;
BiabductionReporting.log_issue_deprecated_using_state Exceptions.Warning pname exn ;
(Prop.exp_normalize_prop tenv prop exp, prop')
| Some (Attribute.UminusUnsigned (e, typ)), prop' ->
let desc =
@ -416,7 +416,7 @@ let check_arith_norm_exp tenv pname exp prop =
(State.get_node_exn ()) (State.get_loc_exn ())
in
let exn = Exceptions.Unary_minus_applied_to_unsigned_expression (desc, __POS__) in
Reporting.log_issue_deprecated_using_state Exceptions.Warning pname exn ;
BiabductionReporting.log_issue_deprecated_using_state Exceptions.Warning pname exn ;
(Prop.exp_normalize_prop tenv prop exp, prop')
| None, prop' ->
(Prop.exp_normalize_prop tenv prop exp, prop')
@ -474,7 +474,7 @@ let check_already_dereferenced tenv pname cond prop =
(State.get_loc_exn ())
in
let exn = Exceptions.Null_test_after_dereference (desc, __POS__) in
Reporting.log_issue_deprecated_using_state Exceptions.Warning pname exn
BiabductionReporting.log_issue_deprecated_using_state Exceptions.Warning pname exn
| None ->
()
@ -1206,7 +1206,7 @@ let rec sym_exec exe_env tenv current_summary instr_ (prop_ : Prop.normal Prop.t
ret_id_typ ret_typ actual_args =
let skip_res () =
let exn = Exceptions.Skip_function (Localise.desc_skip_function callee_pname) in
Reporting.log_issue_deprecated_using_state Exceptions.Info current_pname exn ;
BiabductionReporting.log_issue_deprecated_using_state Exceptions.Info current_pname exn ;
L.d_printfln "Skipping function '%a': %s" Procname.pp callee_pname reason ;
unknown_or_scan_call ~is_scan:false ~reason ret_typ ret_annots
Builtin.
@ -1269,7 +1269,8 @@ let rec sym_exec exe_env tenv current_summary instr_ (prop_ : Prop.normal Prop.t
let exn =
Exceptions.Condition_always_true_false (desc, not (IntLit.iszero i), __POS__)
in
Reporting.log_issue_deprecated_using_state Exceptions.Warning current_pname exn
BiabductionReporting.log_issue_deprecated_using_state Exceptions.Warning current_pname
exn
| _ ->
()
in

@ -402,7 +402,8 @@ 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_issue_deprecated_using_state Exceptions.Warning caller_pname exn )
BiabductionReporting.log_issue_deprecated_using_state Exceptions.Warning caller_pname exn
)
| _ ->
()
in
@ -1130,7 +1131,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_issue_deprecated_using_state Exceptions.Warning caller_pname exn
BiabductionReporting.log_issue_deprecated_using_state Exceptions.Warning caller_pname exn
in
let do_split () =
process_splitting actual_pre sub1 sub2 frame missing_pi missing_sigma frame_fld missing_fld

@ -418,7 +418,7 @@ let forward_tabulate summary exe_env tenv proc_cfg wl =
L.d_strln "SIL INSTR:" ;
Procdesc.Node.d_instrs ~highlight:(State.get_instr ()) curr_node ;
L.d_ln () ;
Reporting.log_issue_deprecated_using_state Exceptions.Error pname exn ;
BiabductionReporting.log_issue_deprecated_using_state Exceptions.Error pname exn ;
State.mark_instr_fail exn
in
let exe_iter f pathset =
@ -521,7 +521,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_issue_deprecated_using_state Exceptions.Warning pname exn
BiabductionReporting.log_issue_deprecated_using_state Exceptions.Warning pname exn
in
List.iter ~f:check_pvar pvars ; p'
@ -827,7 +827,7 @@ let perform_analysis_phase exe_env tenv (summary : Summary.t) (proc_cfg : ProcCf
in
let get_results (wl : Worklist.t) () =
State.process_execution_failures
(Reporting.log_issue_deprecated_using_state Exceptions.Warning)
(BiabductionReporting.log_issue_deprecated_using_state Exceptions.Warning)
pname ;
let results = collect_analysis_result tenv wl proc_cfg in
let specs =
@ -837,7 +837,7 @@ let perform_analysis_phase exe_env tenv (summary : Summary.t) (proc_cfg : ProcCf
Exceptions.Internal_error
(Localise.verbatim_desc "Leak_while_collecting_specs_after_footprint")
in
Reporting.log_issue_deprecated_using_state Exceptions.Error pname exn ;
BiabductionReporting.log_issue_deprecated_using_state Exceptions.Error pname exn ;
(* returning no specs *) []
in
(specs, BiabductionSummary.FOOTPRINT)
@ -955,7 +955,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_issue_deprecated_using_state Exceptions.Error pname exn
BiabductionReporting.log_issue_deprecated_using_state Exceptions.Error pname exn
in
List.iter ~f:report error_preconditions
@ -1175,5 +1175,5 @@ let analyze_procedure {Callbacks.summary; exe_env} : Summary.t =
try analyze_procedure_aux summary exe_env tenv
with exn ->
IExn.reraise_if exn ~f:(fun () -> not (Exceptions.handle_exception exn)) ;
Reporting.log_error_using_state summary exn ;
SummaryReporting.log_error_using_state summary exn ;
summary

@ -41,7 +41,7 @@ module UnusedBranch = struct
if true_branch then IssueType.condition_always_false else IssueType.condition_always_true
in
let ltr = [Errlog.make_trace_element 0 location "Here" []] in
Reporting.log_warning summary ~loc:location ~ltr issue_type desc
SummaryReporting.log_warning summary ~loc:location ~ltr issue_type desc
end
module UnusedBranches = struct
@ -58,7 +58,7 @@ module UnreachableStatement = struct
let report summary {location} =
let ltr = [Errlog.make_trace_element 0 location "Here" []] in
Reporting.log_error summary ~loc:location ~ltr IssueType.unreachable_code_after
SummaryReporting.log_error summary ~loc:location ~ltr IssueType.unreachable_code_after
"Unreachable code after statement"
end
@ -411,7 +411,8 @@ let report_errors : Tenv.t -> checks -> Summary.t -> unit =
Trace.Issue.make_err_trace ~description (PO.ConditionTrace.get_val_traces trace)
|> Errlog.concat_traces
in
Reporting.log_error summary ~loc:location ~ltr:trace issue_type (description ~markup:true)
SummaryReporting.log_error summary ~loc:location ~ltr:trace issue_type
(description ~markup:true)
in
PO.ConditionSet.report_errors ~report cond_set

@ -88,7 +88,7 @@ let report_missing_required_prop summary prop parent_typename ~create_loc call_c
in
Errlog.make_trace_element 0 location call_msg [] )
in
Reporting.log_error summary ~loc:create_loc ~ltr IssueType.missing_required_prop message
SummaryReporting.log_error summary ~loc:create_loc ~ltr IssueType.missing_required_prop message
let has_prop prop_set prop =

@ -240,7 +240,7 @@ module TransferFunctions = struct
(Pvar.pp Pp.text) pvar var_use Location.pp loc
in
let ltr = make_trace_unchecked_strongself domain in
Reporting.log_error summary ~ltr ~loc IssueType.strong_self_not_checked message ;
SummaryReporting.log_error summary ~ltr ~loc IssueType.strong_self_not_checked message ;
let strongVars =
StrongEqualToWeakCapturedVars.add pvar
{strongVarElem with reported= true}
@ -434,7 +434,7 @@ let report_mix_self_weakself_issues summary domain (weakSelf : DomainData.t) (se
Location.pp self.loc
in
let ltr = make_trace_use_self_weakself domain in
Reporting.log_error summary ~ltr ~loc:self.loc IssueType.mixed_self_weakself message
SummaryReporting.log_error summary ~ltr ~loc:self.loc IssueType.mixed_self_weakself message
let report_weakself_in_no_escape_block_issues summary domain (weakSelf : DomainData.t) procname
@ -451,7 +451,8 @@ let report_weakself_in_no_escape_block_issues summary domain (weakSelf : DomainD
(Procname.to_simplified_string procname)
in
let ltr = make_trace_use_self_weakself domain in
Reporting.log_error summary ~ltr ~loc:weakSelf.loc IssueType.weak_self_in_noescape_block message ;
SummaryReporting.log_error summary ~ltr ~loc:weakSelf.loc IssueType.weak_self_in_noescape_block
message ;
reported_weak_self_in_noescape_block )
else reported_weak_self_in_noescape_block
@ -468,7 +469,7 @@ let report_weakself_multiple_issue summary domain (weakSelf1 : DomainData.t)
(Pvar.pp Pp.text) weakSelf1.pvar (Pvar.pp Pp.text) weakSelf1.pvar
in
let ltr = make_trace_use_self_weakself domain in
Reporting.log_error summary ~ltr ~loc:weakSelf1.loc IssueType.multiple_weakself message
SummaryReporting.log_error summary ~ltr ~loc:weakSelf1.loc IssueType.multiple_weakself message
let report_captured_strongself_issue domain summary attributes (capturedStrongSelf : DomainData.t)
@ -488,8 +489,8 @@ let report_captured_strongself_issue domain summary attributes (capturedStrongSe
(Pvar.pp Pp.text) capturedStrongSelf.pvar Location.pp capturedStrongSelf.loc
in
let ltr = make_trace_captured_strong_self domain in
Reporting.log_error summary ~ltr ~loc:capturedStrongSelf.loc IssueType.captured_strong_self
message ;
SummaryReporting.log_error summary ~ltr ~loc:capturedStrongSelf.loc
IssueType.captured_strong_self message ;
report_captured_strongself )
else report_captured_strongself

@ -237,7 +237,8 @@ let report_siof summary trace gname loc =
GlobalVar.pp (SiofTrace.Sink.kind final_sink)
in
let ltr = SiofTrace.trace_of_error loc gname trace in
Reporting.log_error summary ~loc ~ltr IssueType.static_initialization_order_fiasco description
SummaryReporting.log_error summary ~loc ~ltr IssueType.static_initialization_order_fiasco
description
in
let reportable_paths = SiofTrace.get_reportable_sink_paths trace ~trace_of_pname in
(* FIXME(T54950303) replace use of filtering with deduplicate *)

@ -91,8 +91,8 @@ let report_allocation_stack src_annot summary fst_call_loc trace constructor_pna
MF.pp_monospaced ("@" ^ src_annot) MF.pp_monospaced constr_str MF.pp_monospaced
("new " ^ constr_str)
in
Reporting.log_error summary ~loc:fst_call_loc ~ltr:final_trace IssueType.checkers_allocates_memory
description
SummaryReporting.log_error summary ~loc:fst_call_loc ~ltr:final_trace
IssueType.checkers_allocates_memory description
let report_annotation_stack src_annot snk_annot src_summary loc trace snk_pname call_loc =
@ -114,7 +114,7 @@ let report_annotation_stack src_annot snk_annot src_summary loc trace snk_pname
IssueType.checkers_calls_expensive_method
else IssueType.checkers_annotation_reachability_error
in
Reporting.log_error src_summary ~loc ~ltr:final_trace issue_type description
SummaryReporting.log_error src_summary ~loc ~ltr:final_trace issue_type description
let report_call_stack summary end_of_stack lookup_next_calls report call_site sink_map =
@ -333,7 +333,7 @@ module CxxAnnotationSpecs = struct
let linters_def_file = Option.value_map ~default:"" ~f:Fn.id Config.inferconfig_file in
IssueType.register_from_string spec_name ~doc_url ~linters_def_file
in
Reporting.log_error src_summary ~loc ~ltr:final_trace issue_type description
SummaryReporting.log_error src_summary ~loc ~ltr:final_trace issue_type description
in
let snk_annot = annotation_of_str snk_name in
let report proc_data annot_map =
@ -412,7 +412,7 @@ module ExpensiveAnnotationSpec = struct
(Procname.to_string overridden_pname)
MF.pp_monospaced ("@" ^ Annotations.expensive)
in
Reporting.log_error summary ~loc IssueType.checkers_expensive_overrides_unexpensive
SummaryReporting.log_error summary ~loc IssueType.checkers_expensive_overrides_unexpensive
description

@ -115,7 +115,7 @@ let report_loads summary astate =
else
let ltr = ClassLoadsDomain.Event.make_loc_trace event in
let msg = Format.asprintf "Class %s loaded" elem in
Reporting.log_warning summary ~loc ~ltr IssueType.class_load msg
SummaryReporting.log_warning summary ~loc ~ltr IssueType.class_load msg
in
let pname = Summary.get_proc_name summary in
Procname.get_class_name pname

@ -43,7 +43,7 @@ let report_warning class_name fld fld_typ summary =
pp_m (Typ.Name.name class_name) pp_m (Fieldname.get_field_name fld) pp_m (format_typ fld_typ)
pp_m (format_method pname) pp_m on_create_view pp_m on_destroy_view
in
Reporting.log_warning summary ~loc IssueType.checkers_fragment_retain_view description
SummaryReporting.log_warning summary ~loc IssueType.checkers_fragment_retain_view description
let callback_fragment_retains_view_java java_pname {Callbacks.summary; exe_env} =

@ -95,7 +95,7 @@ let do_report extract_cost_if_expensive summary (Call.{pname; loc} as call) loop
F.asprintf "%s%s. It can be moved out of the loop at %a." exp_desc cost_msg Location.pp
loop_head_loc
in
Reporting.log_error summary ~loc ~ltr issue message
SummaryReporting.log_error summary ~loc ~ltr issue message
let get_cost_if_expensive tenv integer_type_widths get_callee_cost_summary_and_formals

@ -173,15 +173,15 @@ let checker {exe_env; Callbacks.summary} : Summary.t =
F.asprintf "Impure function %a with no pulse summary" Procname.pp proc_name
in
let impure_fun_ltr = Errlog.make_trace_element 0 pname_loc impure_fun_desc [] in
Reporting.log_error summary ~loc:pname_loc ~ltr:[impure_fun_ltr] IssueType.impure_function
impure_fun_desc
SummaryReporting.log_error summary ~loc:pname_loc ~ltr:[impure_fun_ltr]
IssueType.impure_function impure_fun_desc
| Some [] ->
let impure_fun_desc =
F.asprintf "Impure function %a with empty pulse summary" Procname.pp proc_name
in
let impure_fun_ltr = Errlog.make_trace_element 0 pname_loc impure_fun_desc [] in
Reporting.log_error summary ~loc:pname_loc ~ltr:[impure_fun_ltr] IssueType.impure_function
impure_fun_desc
SummaryReporting.log_error summary ~loc:pname_loc ~ltr:[impure_fun_ltr]
IssueType.impure_function impure_fun_desc
| Some pre_posts ->
let (ImpurityDomain.{modified_globals; modified_params; skipped_calls} as impurity_astate) =
List.fold pre_posts ~init:ImpurityDomain.pure ~f:(fun acc exec_state ->
@ -210,5 +210,6 @@ let checker {exe_env; Callbacks.summary} : Summary.t =
:: modified_ltr Formal modified_params
(modified_ltr Global modified_globals skipped_functions)
in
Reporting.log_error summary ~loc:pname_loc ~ltr IssueType.impure_function impure_fun_desc ) ;
SummaryReporting.log_error summary ~loc:pname_loc ~ltr IssueType.impure_function
impure_fun_desc ) ;
summary

@ -75,8 +75,8 @@ let report_matching_get tenv summary pvar loop_nodes : unit =
in
let loc = Procdesc.Node.get_loc node in
let ltr = [Errlog.make_trace_element 0 loc exp_desc []] in
Reporting.log_error summary ~loc ~ltr IssueType.inefficient_keyset_iterator
exp_desc ) ) )
SummaryReporting.log_error summary ~loc ~ltr
IssueType.inefficient_keyset_iterator exp_desc ) ) )
loop_nodes

@ -259,7 +259,7 @@ let checker {Callbacks.exe_env; summary} : Summary.t =
(Typ.pp_full Pp.text) typ
in
let ltr = [Errlog.make_trace_element 0 loc "Write of unused value" []] in
Reporting.log_error summary ~loc ~ltr IssueType.dead_store message
SummaryReporting.log_error summary ~loc ~ltr IssueType.dead_store message
in
let report_dead_store live_vars captured_by_ref_vars = function
| Sil.Store {e1= Lvar pvar; typ; e2= rhs_exp; loc}

@ -111,7 +111,8 @@ let check_printf_args_ok tenv (node : Procdesc.Node.t) (instr : Sil.instr) (proc
"%s at line %s: parameter %d is expected to be of type %s but %s was given."
instr_name instr_line n_arg (default_format_type_name ft) gt
in
Reporting.log_error summary ~loc:instr_loc IssueType.checkers_printf_args description
SummaryReporting.log_error summary ~loc:instr_loc IssueType.checkers_printf_args
description
else check_type_names instr_loc (n_arg + 1) instr_proc_name fs gs
| [], [] ->
()
@ -120,7 +121,7 @@ let check_printf_args_ok tenv (node : Procdesc.Node.t) (instr : Sil.instr) (proc
Printf.sprintf "format string arguments don't mach provided arguments in %s at line %s"
instr_name instr_line
in
Reporting.log_error summary ~loc:instr_loc IssueType.checkers_printf_args description
SummaryReporting.log_error summary ~loc:instr_loc IssueType.checkers_printf_args description
in
(* Get the array ivar for a given nvar *)
let array_ivar instrs nvar =
@ -156,7 +157,7 @@ let check_printf_args_ok tenv (node : Procdesc.Node.t) (instr : Sil.instr) (proc
vararg_ivar_type_names
| None ->
if not (Reporting.is_suppressed tenv proc_desc IssueType.checkers_printf_args) then
Reporting.log_warning summary ~loc:cl IssueType.checkers_printf_args
SummaryReporting.log_warning summary ~loc:cl IssueType.checkers_printf_args
"Format string must be string literal"
with e ->
L.internal_error "%s Exception when analyzing %s: %s@."

@ -207,7 +207,7 @@ let report_errors astate summary =
let loc = Procdesc.get_loc pdesc in
let exp_desc = F.asprintf "Side-effect free function %a" Procname.pp proc_name in
let ltr = [Errlog.make_trace_element 0 loc exp_desc []] in
Reporting.log_error summary ~loc ~ltr IssueType.pure_function exp_desc
SummaryReporting.log_error summary ~loc ~ltr IssueType.pure_function exp_desc
| None ->
L.internal_error "Analyzer failed to compute purity information for %a@." Procname.pp
proc_name

@ -83,7 +83,7 @@ module TransferFunctions (CFG : ProcCfg.S) = struct
access_expr
in
let ltr = [Errlog.make_trace_element 0 loc "" []] in
Reporting.log_error summary ~loc ~ltr IssueType.uninitialized_value message
SummaryReporting.log_error summary ~loc ~ltr IssueType.uninitialized_value message
let is_struct t = match t.Typ.desc with Typ.Tstruct _ -> true | _ -> false

@ -263,7 +263,7 @@ module Check = struct
in
Errlog.make_trace_element 0 location cost_desc []
in
Reporting.log_error summary ~loc:location
SummaryReporting.log_error summary ~loc:location
~ltr:(cost_trace_elem :: BasicCost.polynomial_traces cost)
~extras:(compute_errlog_extras cost) report_issue_type message
@ -272,7 +272,7 @@ module Check = struct
CostIssues.{unreachable_issue; infinite_issue} =
let report issue suffix =
let message = F.asprintf "%s of the function %a %s" name Procname.pp pname suffix in
Reporting.log_error ~loc
SummaryReporting.log_error ~loc
~ltr:(BasicCost.polynomial_traces cost)
~extras:(compute_errlog_extras cost) summary issue message
in

@ -16,4 +16,4 @@ let report_error tenv proc_name proc_desc kind loc ?(field_name = None)
let localized_description = Localise.verbatim_desc description in
let exn = exception_kind kind localized_description in
let trace = [Errlog.make_trace_element 0 loc description []] in
Reporting.log_issue_deprecated_using_state severity proc_name ~loc ~ltr:trace exn
BiabductionReporting.log_issue_deprecated_using_state severity proc_name ~loc ~ltr:trace exn

@ -14,7 +14,7 @@ open PulseDomainInterface
let report summary diagnostic =
let open Diagnostic in
Reporting.log_error summary ~loc:(get_location diagnostic) ~ltr:(get_trace diagnostic)
SummaryReporting.log_error summary ~loc:(get_location diagnostic) ~ltr:(get_trace diagnostic)
(get_issue_type diagnostic) (get_message diagnostic)

@ -303,7 +303,7 @@ module Make (TaintSpecification : TaintSpec.S) = struct
get_short_trace_string initial_source initial_source_caller final_sink final_sink_caller
in
let ltr = source_trace @ List.rev sink_trace in
Reporting.log_error proc_data.extras.summary ~loc:(CallSite.loc cur_site) ~ltr issue
SummaryReporting.log_error proc_data.extras.summary ~loc:(CallSite.loc cur_site) ~ltr issue
trace_str
in
List.iter ~f:report_one (TraceDomain.get_reports ~cur_site trace)

@ -269,7 +269,7 @@ let add_errors exe_env summary =
let property, _vname = ToplAutomaton.vname (Lazy.force automaton) error in
let message = Printf.sprintf "property %s reaches error" property in
tt "WARN@\n" ;
Reporting.log_error summary IssueType.topl_error ~loc message )
SummaryReporting.log_error summary IssueType.topl_error ~loc message )
in
(* Don't warn if [lookup_static_var] fails. *)
Option.iter ~f:handle_state_post_value (lookup_static_var env state_var post)

Loading…
Cancel
Save