get rid of most dynamic severity changes

Summary:
By and large issues of a given type (eg NULL_DEREFERENCE) are always
reported with the same severity (eg ERROR), but that severity is hard to
tease out from the code. This makes it more explicit by favouring the
default in `IssueType.t` in many cases without changing infer's
behaviour. The checkers typically use `Reporting.log_{error,warning}`;
these are taken care of in the next diff.

Reviewed By: skcho

Differential Revision: D21904590

fbshipit-source-id: 47c76cd4c
master
Jules Villard 5 years ago committed by Facebook GitHub Bot
parent c9fc41f97c
commit 682f932150

@ -198,8 +198,8 @@ let update errlog_old errlog_new =
ErrLogHash.iter (fun err_key l -> ignore (add_issue errlog_old err_key l)) errlog_new
let log_issue severity err_log ~loc ~node ~session ~ltr ~linters_def_file ~doc_url ~access ~extras
checker exn =
let log_issue ?severity_override err_log ~loc ~node ~session ~ltr ~linters_def_file ~doc_url ~access
~extras checker exn =
let error = Exceptions.recognize_exception exn in
if not (IssueType.checker_can_report checker error.issue_type) then
L.die InternalError
@ -209,7 +209,7 @@ let log_issue severity err_log ~loc ~node ~session ~ltr ~linters_def_file ~doc_u
error.issue_type.unique_id (Checker.get_name checker)
(Checker.get_name error.issue_type.checker)
(Checker.get_name checker) ;
let severity = Option.value error.severity ~default:severity in
let severity = Option.value severity_override ~default:error.issue_type.default_severity in
let hide_java_loc_zero =
(* hide java errors at location zero unless in -developer_mode *)
(not Config.developer_mode) && Language.curr_language_is Java && Int.equal loc.Location.line 0
@ -254,9 +254,9 @@ let log_issue severity err_log ~loc ~node ~session ~ltr ~linters_def_file ~doc_u
in
let should_print_now = match exn with Exceptions.Internal_error _ -> true | _ -> added in
let print_now () =
L.(debug Analysis Medium)
"@\n%a@\n@?"
(Exceptions.pp_err loc severity error.issue_type error.description error.ocaml_pos)
L.debug Analysis Medium "@\n%a@\n@?"
(Exceptions.pp_err ~severity_override:severity loc error.issue_type error.description
error.ocaml_pos)
() ;
if not (IssueType.equal_severity severity Error) then (
let warn_str =

@ -88,7 +88,7 @@ val update : t -> t -> unit
(** Update an old error log with a new one *)
val log_issue :
IssueType.severity
?severity_override:IssueType.severity
-> t
-> loc:Location.t
-> node:node

@ -100,155 +100,93 @@ exception Wrong_argument_number of L.ocaml_pos
type t =
{ issue_type: IssueType.t
; description: Localise.error_desc
; ocaml_pos: L.ocaml_pos option (** location in the infer source code *)
; severity: IssueType.severity option }
; ocaml_pos: L.ocaml_pos option (** location in the infer source code *) }
let recognize_exception exn =
match exn with
| Abduction_case_not_implemented ocaml_pos ->
{ issue_type= IssueType.abduction_case_not_implemented
; description= Localise.no_desc
; ocaml_pos= Some ocaml_pos
; severity= None }
; ocaml_pos= Some ocaml_pos }
| Analysis_stops (desc, ocaml_pos_opt) ->
{ issue_type= IssueType.biabduction_analysis_stops
; description= desc
; ocaml_pos= ocaml_pos_opt
; severity= None }
{issue_type= IssueType.biabduction_analysis_stops; description= desc; ocaml_pos= ocaml_pos_opt}
| Array_of_pointsto ocaml_pos ->
{ issue_type= IssueType.array_of_pointsto
; description= Localise.no_desc
; ocaml_pos= Some ocaml_pos
; severity= None }
; ocaml_pos= Some ocaml_pos }
| Array_out_of_bounds_l1 (desc, ocaml_pos) ->
{ issue_type= IssueType.array_out_of_bounds_l1
; description= desc
; ocaml_pos= Some ocaml_pos
; severity= Some Error }
{issue_type= IssueType.array_out_of_bounds_l1; description= desc; ocaml_pos= Some ocaml_pos}
| Array_out_of_bounds_l2 (desc, ocaml_pos) ->
{ issue_type= IssueType.array_out_of_bounds_l2
; description= desc
; ocaml_pos= Some ocaml_pos
; severity= None }
{issue_type= IssueType.array_out_of_bounds_l2; description= desc; ocaml_pos= Some ocaml_pos}
| Array_out_of_bounds_l3 (desc, ocaml_pos) ->
{ issue_type= IssueType.array_out_of_bounds_l3
; description= desc
; ocaml_pos= Some ocaml_pos
; severity= None }
{issue_type= IssueType.array_out_of_bounds_l3; description= desc; ocaml_pos= Some ocaml_pos}
| Assert_failure (f, l, c) ->
let ocaml_pos = (f, l, c, c) in
{ issue_type= IssueType.assert_failure
; description= Localise.no_desc
; ocaml_pos= Some ocaml_pos
; severity= None }
; ocaml_pos= Some ocaml_pos }
| Bad_footprint ocaml_pos ->
{ issue_type= IssueType.bad_footprint
; description= Localise.no_desc
; ocaml_pos= Some ocaml_pos
; severity= None }
{issue_type= IssueType.bad_footprint; description= Localise.no_desc; ocaml_pos= Some ocaml_pos}
| Biabd_use_after_free (desc, ocaml_pos) ->
{ issue_type= IssueType.biabd_use_after_free
; description= desc
; ocaml_pos= Some ocaml_pos
; severity= None }
{issue_type= IssueType.biabd_use_after_free; description= desc; ocaml_pos= Some ocaml_pos}
| Cannot_star ocaml_pos ->
{ issue_type= IssueType.cannot_star
; description= Localise.no_desc
; ocaml_pos= Some ocaml_pos
; severity= None }
{issue_type= IssueType.cannot_star; description= Localise.no_desc; ocaml_pos= Some ocaml_pos}
| Class_cast_exception (desc, ocaml_pos) ->
{ issue_type= IssueType.class_cast_exception
; description= desc
; ocaml_pos= Some ocaml_pos
; severity= None }
{issue_type= IssueType.class_cast_exception; description= desc; ocaml_pos= Some ocaml_pos}
| Condition_always_true_false (desc, b, ocaml_pos) ->
let issue_type =
if b then IssueType.biabd_condition_always_true else IssueType.biabd_condition_always_false
in
{issue_type; description= desc; ocaml_pos= Some ocaml_pos; severity= None}
{issue_type; description= desc; ocaml_pos= Some ocaml_pos}
| Custom_error (error_msg, severity, desc) ->
{ issue_type= IssueType.register_from_string ~id:error_msg severity Biabduction
; description= desc
; ocaml_pos= None
; severity= None }
; ocaml_pos= None }
| Dangling_pointer_dereference (user_visible, desc, ocaml_pos) ->
let issue_type =
if user_visible then IssueType.dangling_pointer_dereference
else IssueType.dangling_pointer_dereference_maybe
in
{issue_type; description= desc; ocaml_pos= Some ocaml_pos; severity= None}
{issue_type; description= desc; ocaml_pos= Some ocaml_pos}
| Deallocate_stack_variable desc ->
{ issue_type= IssueType.deallocate_stack_variable
; description= desc
; ocaml_pos= None
; severity= None }
{issue_type= IssueType.deallocate_stack_variable; description= desc; ocaml_pos= None}
| Deallocate_static_memory desc ->
{ issue_type= IssueType.deallocate_static_memory
; description= desc
; ocaml_pos= None
; severity= None }
{issue_type= IssueType.deallocate_static_memory; description= desc; ocaml_pos= None}
| Deallocation_mismatch (desc, ocaml_pos) ->
{ issue_type= IssueType.deallocation_mismatch
; description= desc
; ocaml_pos= Some ocaml_pos
; severity= None }
{issue_type= IssueType.deallocation_mismatch; description= desc; ocaml_pos= Some ocaml_pos}
| Divide_by_zero (desc, ocaml_pos) ->
{ issue_type= IssueType.divide_by_zero
; description= desc
; ocaml_pos= Some ocaml_pos
; severity= Some Error }
{issue_type= IssueType.divide_by_zero; description= desc; ocaml_pos= Some ocaml_pos}
| Empty_vector_access (desc, ocaml_pos) ->
{ issue_type= IssueType.empty_vector_access
; description= desc
; ocaml_pos= Some ocaml_pos
; severity= Some Error }
{issue_type= IssueType.empty_vector_access; description= desc; ocaml_pos= Some ocaml_pos}
| Field_not_null_checked (desc, ocaml_pos) ->
{ issue_type= IssueType.field_not_null_checked
; description= desc
; ocaml_pos= Some ocaml_pos
; severity= Some Warning }
{issue_type= IssueType.field_not_null_checked; description= desc; ocaml_pos= Some ocaml_pos}
| Frontend_warning (issue_type, desc, ocaml_pos) ->
{issue_type; description= desc; ocaml_pos= Some ocaml_pos; severity= None}
{issue_type; description= desc; ocaml_pos= Some ocaml_pos}
| Checkers (kind, desc) ->
{issue_type= kind; description= desc; ocaml_pos= None; severity= None}
{issue_type= kind; description= desc; ocaml_pos= None}
| Null_dereference (desc, ocaml_pos) ->
{ issue_type= IssueType.null_dereference
; description= desc
; ocaml_pos= Some ocaml_pos
; severity= None }
{issue_type= IssueType.null_dereference; description= desc; ocaml_pos= Some ocaml_pos}
| Null_test_after_dereference (desc, ocaml_pos) ->
{ issue_type= IssueType.null_test_after_dereference
; description= desc
; ocaml_pos= Some ocaml_pos
; severity= None }
; ocaml_pos= Some ocaml_pos }
| Pointer_size_mismatch (desc, ocaml_pos) ->
{ issue_type= IssueType.pointer_size_mismatch
; description= desc
; ocaml_pos= Some ocaml_pos
; severity= Some Error }
{issue_type= IssueType.pointer_size_mismatch; description= desc; ocaml_pos= Some ocaml_pos}
| Inherently_dangerous_function desc ->
{ issue_type= IssueType.inherently_dangerous_function
; description= desc
; ocaml_pos= None
; severity= None }
{issue_type= IssueType.inherently_dangerous_function; description= desc; ocaml_pos= None}
| Internal_error desc ->
{issue_type= IssueType.internal_error; description= desc; ocaml_pos= None; severity= None}
{issue_type= IssueType.internal_error; description= desc; ocaml_pos= None}
| Leak (fp_part, (user_visible, error_desc), done_array_abstraction, resource, ocaml_pos) ->
if done_array_abstraction then
{ issue_type= IssueType.leak_after_array_abstraction
; description= error_desc
; ocaml_pos= Some ocaml_pos
; severity= None }
; ocaml_pos= Some ocaml_pos }
else if fp_part then
{ issue_type= IssueType.leak_in_footprint
; description= error_desc
; ocaml_pos= Some ocaml_pos
; severity= None }
{issue_type= IssueType.leak_in_footprint; description= error_desc; ocaml_pos= Some ocaml_pos}
else if not user_visible then
{ issue_type= IssueType.leak_unknown_origin
; description= error_desc
; ocaml_pos= Some ocaml_pos
; severity= None }
; ocaml_pos= Some ocaml_pos }
else
let issue_type =
match resource with
@ -261,83 +199,53 @@ let recognize_exception exn =
| PredSymb.Rignore ->
IssueType.memory_leak
in
{issue_type; description= error_desc; ocaml_pos= Some ocaml_pos; severity= None}
{issue_type; description= error_desc; ocaml_pos= Some ocaml_pos}
| Missing_fld (fld, ocaml_pos) ->
let desc = Localise.verbatim_desc (Fieldname.to_full_string fld) in
{ issue_type= IssueType.missing_fld
; description= desc
; ocaml_pos= Some ocaml_pos
; severity= None }
{issue_type= IssueType.missing_fld; description= desc; ocaml_pos= Some ocaml_pos}
| Premature_nil_termination (desc, ocaml_pos) ->
{ issue_type= IssueType.premature_nil_termination
; description= desc
; ocaml_pos= Some ocaml_pos
; severity= None }
{issue_type= IssueType.premature_nil_termination; description= desc; ocaml_pos= Some ocaml_pos}
| Parameter_not_null_checked (desc, ocaml_pos) ->
{ issue_type= IssueType.parameter_not_null_checked
; description= desc
; ocaml_pos= Some ocaml_pos
; severity= Some Warning }
; ocaml_pos= Some ocaml_pos }
| Precondition_not_found (desc, ocaml_pos) ->
{ issue_type= IssueType.precondition_not_found
; description= desc
; ocaml_pos= Some ocaml_pos
; severity= None }
{issue_type= IssueType.precondition_not_found; description= desc; ocaml_pos= Some ocaml_pos}
| Precondition_not_met (desc, ocaml_pos) ->
{ issue_type= IssueType.precondition_not_met
; description= desc
; ocaml_pos= Some ocaml_pos
; severity= Some Warning }
(* always a warning *)
{issue_type= IssueType.precondition_not_met; description= desc; ocaml_pos= Some ocaml_pos}
| Retain_cycle (desc, ocaml_pos) ->
{ issue_type= IssueType.retain_cycle
; description= desc
; ocaml_pos= Some ocaml_pos
; severity= None }
{issue_type= IssueType.retain_cycle; description= desc; ocaml_pos= Some ocaml_pos}
| Registered_observer_being_deallocated (desc, ocaml_pos) ->
{ issue_type= IssueType.biabd_registered_observer_being_deallocated
; description= desc
; ocaml_pos= Some ocaml_pos
; severity= Some Error }
; ocaml_pos= Some ocaml_pos }
| Stack_variable_address_escape (desc, ocaml_pos) ->
{ issue_type= IssueType.biabd_stack_variable_address_escape
; description= desc
; ocaml_pos= Some ocaml_pos
; severity= Some Error }
; ocaml_pos= Some ocaml_pos }
| SymOp.Analysis_failure_exe _ ->
{ issue_type= IssueType.failure_exe
; description= Localise.no_desc
; ocaml_pos= None
; severity= None }
{issue_type= IssueType.failure_exe; description= Localise.no_desc; ocaml_pos= None}
| Skip_function desc ->
{issue_type= IssueType.skip_function; description= desc; ocaml_pos= None; severity= None}
{issue_type= IssueType.skip_function; description= desc; ocaml_pos= None}
| Skip_pointer_dereference (desc, ocaml_pos) ->
{ issue_type= IssueType.skip_pointer_dereference
; description= desc
; ocaml_pos= Some ocaml_pos
; severity= Some Info }
(* always an info *)
{issue_type= IssueType.skip_pointer_dereference; description= desc; ocaml_pos= Some ocaml_pos}
| Symexec_memory_error ocaml_pos ->
{ issue_type= IssueType.symexec_memory_error
; description= Localise.no_desc
; ocaml_pos= Some ocaml_pos
; severity= None }
; ocaml_pos= Some ocaml_pos }
| Unary_minus_applied_to_unsigned_expression (desc, ocaml_pos) ->
{ issue_type= IssueType.unary_minus_applied_to_unsigned_expression
; description= desc
; ocaml_pos= Some ocaml_pos
; severity= None }
; ocaml_pos= Some ocaml_pos }
| Wrong_argument_number ocaml_pos ->
{ issue_type= IssueType.wrong_argument_number
; description= Localise.no_desc
; ocaml_pos= Some ocaml_pos
; severity= None }
; ocaml_pos= Some ocaml_pos }
| exn ->
{ issue_type= IssueType.failure_exe
; description=
Localise.verbatim_desc (F.asprintf "%a: %s" Exn.pp exn (Caml.Printexc.get_backtrace ()))
; ocaml_pos= None
; severity= None }
; ocaml_pos= None }
(** print a description of the exception to the html output *)
@ -355,7 +263,8 @@ let print_exception_html s exn =
(** pretty print an error *)
let pp_err loc severity issue_type desc ocaml_pos_opt fmt () =
let pp_err ?severity_override loc issue_type desc ocaml_pos_opt fmt () =
let severity = Option.value severity_override ~default:issue_type.IssueType.default_severity in
let kind =
IssueType.string_of_severity
(if IssueType.equal_severity severity Info then Warning else severity)

@ -105,8 +105,8 @@ val print_exception_html : string -> exn -> unit
(** print a description of the exception to the html output *)
val pp_err :
Location.t
-> IssueType.severity
?severity_override:IssueType.severity
-> Location.t
-> IssueType.t
-> Localise.error_desc
-> Logging.ocaml_pos option
@ -118,7 +118,6 @@ val pp_err :
type t =
{ issue_type: IssueType.t
; description: Localise.error_desc
; ocaml_pos: Logging.ocaml_pos option (** location in the infer source code *)
; severity: IssueType.severity option }
; ocaml_pos: Logging.ocaml_pos option (** location in the infer source code *) }
val recognize_exception : exn -> t

@ -10,22 +10,23 @@ open! IStd
type log_t =
?ltr:Errlog.loc_trace -> ?extras:Jsonbug_t.extra -> Checker.t -> IssueType.t -> string -> unit
let log_issue_from_errlog severity err_log ~loc ~node ~session ~ltr ~access ~extras checker exn =
let log_issue_from_errlog ?severity_override err_log ~loc ~node ~session ~ltr ~access ~extras
checker exn =
let issue_type = (Exceptions.recognize_exception exn).issue_type in
if (not Config.filtering) (* no-filtering takes priority *) || issue_type.IssueType.enabled then
let doc_url = issue_type.doc_url in
let linters_def_file = issue_type.linters_def_file in
Errlog.log_issue severity err_log ~loc ~node ~session ~ltr ~linters_def_file ~doc_url ~access
~extras checker exn
Errlog.log_issue ?severity_override err_log ~loc ~node ~session ~ltr ~linters_def_file ~doc_url
~access ~extras checker exn
let log_frontend_issue severity errlog ~loc ~node_key ~ltr exn =
let log_frontend_issue errlog ~loc ~node_key ~ltr exn =
let node = Errlog.FrontendNode {node_key} in
log_issue_from_errlog severity errlog ~loc ~node ~session:0 ~ltr ~access:None ~extras:None Linters
exn
log_issue_from_errlog errlog ~loc ~node ~session:0 ~ltr ~access:None ~extras:None Linters exn
let log_issue_from_summary severity proc_desc err_log ~node ~session ~loc ~ltr ?extras checker exn =
let log_issue_from_summary ?severity_override proc_desc err_log ~node ~session ~loc ~ltr ?extras
checker exn =
let procname = Procdesc.get_proc_name proc_desc in
let is_java_generated_method =
match procname with
@ -49,36 +50,38 @@ let log_issue_from_summary severity proc_desc err_log ~node ~session ~loc ~ltr ?
if should_suppress_lint || is_java_generated_method || is_java_external_package then
Logging.debug Analysis Medium "Reporting is suppressed!@\n" (* Skip the reporting *)
else
log_issue_from_errlog severity err_log ~loc ~node ~session ~ltr ~access:None ~extras checker exn
log_issue_from_errlog ?severity_override err_log ~loc ~node ~session ~ltr ~access:None ~extras
checker exn
let checker_exception issue_type error_message =
Exceptions.Checkers (issue_type, Localise.verbatim_desc error_message)
let log_issue_from_summary_simplified severity attrs err_log ~loc ?(ltr = []) ?extras checker
issue_type error_message =
let log_issue_from_summary_simplified ?severity_override attrs err_log ~loc ?(ltr = []) ?extras
checker issue_type error_message =
let exn = checker_exception issue_type error_message in
log_issue_from_summary severity attrs err_log ~node:Errlog.UnknownNode ~session:0 ~loc ~ltr
?extras checker exn
log_issue_from_summary ?severity_override attrs err_log ~node:Errlog.UnknownNode ~session:0 ~loc
~ltr ?extras checker exn
let log_error attrs err_log ~loc ?ltr ?extras checker issue_type error_message =
log_issue_from_summary_simplified Error attrs err_log ~loc ?ltr ?extras checker issue_type
error_message
log_issue_from_summary_simplified ~severity_override:Error attrs err_log ~loc ?ltr ?extras checker
issue_type error_message
let log_warning attrs err_log ~loc ?ltr ?extras checker issue_type error_message =
log_issue_from_summary_simplified Warning attrs err_log ~loc ?ltr ?extras checker issue_type
error_message
log_issue_from_summary_simplified ~severity_override:Warning attrs err_log ~loc ?ltr ?extras
checker issue_type error_message
let log_issue_external procname ~issue_log severity ~loc ~ltr ?access ?extras checker issue_type
error_message =
let log_issue_external procname ~issue_log ?severity_override ~loc ~ltr ?access ?extras checker
issue_type error_message =
let exn = checker_exception issue_type error_message in
let issue_log, errlog = IssueLog.get_or_add issue_log ~proc:procname in
let node = Errlog.UnknownNode in
log_issue_from_errlog severity errlog ~loc ~node ~session:0 ~ltr ~access ~extras checker exn ;
log_issue_from_errlog ?severity_override errlog ~loc ~node ~session:0 ~ltr ~access ~extras checker
exn ;
issue_log

@ -13,7 +13,7 @@ type log_t =
?ltr:Errlog.loc_trace -> ?extras:Jsonbug_t.extra -> Checker.t -> IssueType.t -> string -> unit
val log_issue_from_summary :
IssueType.severity
?severity_override:IssueType.severity
-> Procdesc.t
-> Errlog.t
-> node:Errlog.node
@ -26,13 +26,7 @@ val log_issue_from_summary :
-> unit
val log_frontend_issue :
IssueType.severity
-> Errlog.t
-> loc:Location.t
-> node_key:Procdesc.NodeKey.t
-> ltr:Errlog.loc_trace
-> exn
-> unit
Errlog.t -> loc:Location.t -> node_key:Procdesc.NodeKey.t -> ltr:Errlog.loc_trace -> exn -> unit
(** Report a frontend issue of a given kind in the given error log. *)
val log_error : Procdesc.t -> Errlog.t -> loc:Location.t -> log_t
@ -44,7 +38,7 @@ val log_warning : Procdesc.t -> Errlog.t -> loc:Location.t -> log_t
val log_issue_external :
Procname.t
-> issue_log:IssueLog.t
-> IssueType.severity
-> ?severity_override:IssueType.severity
-> loc:Location.t
-> ltr:Errlog.loc_trace
-> ?access:string

@ -503,8 +503,7 @@ let log_frontend_issue method_decl_opt (node : Ctl_parser_types.ast_node) (issue
CAst_utils.generate_key_stmt st
in
let node_key = Procdesc.NodeKey.of_frontend_node_key key_str in
Reporting.log_frontend_issue issue_desc.severity errlog exn ~loc:issue_desc.loc ~ltr:trace
~node_key
Reporting.log_frontend_issue errlog exn ~loc:issue_desc.loc ~ltr:trace ~node_key
let fill_issue_desc_info_and_log context ~witness ~current_node (issue_desc : CIssue.t) loc =

@ -191,7 +191,7 @@ let run_proc_analysis ~caller_pdesc callee_pdesc =
summary
in
let log_error_and_continue exn (summary : Summary.t) kind =
BiabductionReporting.log_error_using_state (Summary.get_proc_desc summary)
BiabductionReporting.log_issue_using_state (Summary.get_proc_desc summary)
(Summary.get_err_log summary) exn ;
let stats = Summary.Stats.update summary.stats ~failure_kind:kind in
let payloads =

@ -24,6 +24,7 @@ type t = private
; checker: Checker.t
; visibility: visibility
; mutable default_severity: severity
(** used for documentation but can be overriden at report time *)
; mutable enabled: bool
; mutable hum: string
; mutable doc_url: string option

@ -1142,7 +1142,7 @@ let check_junk {InterproceduralAnalysis.proc_desc; err_log; tenv} prop =
let report_leak () =
if not report_and_continue then raise exn
else (
BiabductionReporting.log_issue_deprecated_using_state proc_desc err_log Error exn ;
BiabductionReporting.log_issue_deprecated_using_state proc_desc err_log exn ;
leaks_reported := alloc_attribute :: !leaks_reported )
in
if not ignore_leak then report_leak () ;

@ -7,7 +7,7 @@
open! IStd
let log_issue_deprecated_using_state proc_desc err_log severity ?node ?loc ?ltr exn =
let log_issue_deprecated_using_state proc_desc err_log ?node ?loc ?ltr exn =
if !BiabductionConfig.footprint then
let node =
let node = match node with None -> AnalysisState.get_node_exn () | Some node -> node in
@ -16,11 +16,10 @@ let log_issue_deprecated_using_state proc_desc err_log severity ?node ?loc ?ltr
let session = AnalysisState.get_session () in
let loc = match loc with None -> AnalysisState.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 proc_desc err_log ~node ~session ~loc ~ltr Biabduction
exn
Reporting.log_issue_from_summary proc_desc err_log ~node ~session ~loc ~ltr Biabduction exn
let log_error_using_state proc_desc err_log exn =
let log_issue_using_state proc_desc err_log exn =
if !BiabductionConfig.footprint then
let node' =
match AnalysisState.get_node () with Some n -> n | None -> Procdesc.get_start_node proc_desc
@ -31,5 +30,4 @@ let log_error_using_state proc_desc err_log exn =
match AnalysisState.get_loc () with Some l -> l | None -> Procdesc.Node.get_loc node'
in
let ltr = State.get_loc_trace () in
Reporting.log_issue_from_summary Error proc_desc err_log ~node ~session ~loc ~ltr Biabduction
exn
Reporting.log_issue_from_summary proc_desc err_log ~node ~session ~loc ~ltr Biabduction exn

@ -7,13 +7,12 @@
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_using_state : Procdesc.t -> Errlog.t -> exn -> unit
(** Add an issue to the given summary using biabduction state. *)
val log_issue_deprecated_using_state :
Procdesc.t
-> Errlog.t
-> IssueType.severity
-> ?node:Procdesc.Node.t
-> ?loc:Location.t
-> ?ltr:Errlog.loc_trace

@ -2507,7 +2507,7 @@ let check_implication_base {InterproceduralAnalysis.proc_desc; err_log; tenv} ch
L.d_printfln "WARNING: footprint failed to find MISSING because: %s" s ;
None
| Exceptions.Abduction_case_not_implemented _ as exn ->
BiabductionReporting.log_issue_deprecated_using_state proc_desc err_log Error exn ;
BiabductionReporting.log_issue_deprecated_using_state proc_desc err_log exn ;
None

@ -55,7 +55,7 @@ let check_bad_index {InterproceduralAnalysis.proc_desc; err_log; tenv} pname p l
Exceptions.Array_out_of_bounds_l1
(Errdesc.explain_array_access pname tenv deref_str p loc, __POS__)
in
BiabductionReporting.log_issue_deprecated_using_state proc_desc err_log Warning exn
BiabductionReporting.log_issue_deprecated_using_state proc_desc err_log 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 {InterproceduralAnalysis.proc_desc; err_log; tenv} pname p l
if index_has_bounds () then Exceptions.Array_out_of_bounds_l2 (desc, __POS__)
else Exceptions.Array_out_of_bounds_l3 (desc, __POS__)
in
BiabductionReporting.log_issue_deprecated_using_state proc_desc err_log Warning exn
BiabductionReporting.log_issue_deprecated_using_state proc_desc err_log exn
(** Perform bounds checking *)
@ -1014,7 +1014,7 @@ let check_type_size {InterproceduralAnalysis.proc_desc; err_log; tenv} pname pro
Exceptions.Pointer_size_mismatch
(Errdesc.explain_dereference pname tenv deref_str prop loc, __POS__)
in
BiabductionReporting.log_issue_deprecated_using_state proc_desc err_log Warning exn
BiabductionReporting.log_issue_deprecated_using_state proc_desc err_log exn
| None ->
L.d_str "texp: " ;
Exp.d_texp_full texp ;

@ -245,7 +245,7 @@ let report_cycle {InterproceduralAnalysis.proc_desc; tenv; err_log} prop =
RetainCyclesType.Set.iter
(fun cycle ->
let exn = exn_retain_cycle tenv cycle in
BiabductionReporting.log_error_using_state proc_desc err_log exn )
BiabductionReporting.log_issue_using_state proc_desc err_log exn )
cycles ;
(* we report the retain cycles above but need to raise an exception as well to stop the analysis *)
raise (Exceptions.Analysis_stops (Localise.verbatim_desc "retain cycle found", Some __POS__)) )

@ -345,7 +345,7 @@ let check_inherently_dangerous_function {InterproceduralAnalysis.proc_desc; err_
Exceptions.Inherently_dangerous_function
(Localise.desc_inherently_dangerous_function callee_pname)
in
BiabductionReporting.log_issue_deprecated_using_state proc_desc err_log Warning exn
BiabductionReporting.log_issue_deprecated_using_state proc_desc err_log exn
let reason_to_skip ~callee_desc : string option =
@ -410,7 +410,7 @@ let check_arith_norm_exp {InterproceduralAnalysis.proc_desc; err_log; tenv} exp
(AnalysisState.get_loc_exn ())
in
let exn = Exceptions.Divide_by_zero (desc, __POS__) in
BiabductionReporting.log_issue_deprecated_using_state proc_desc err_log Warning exn ;
BiabductionReporting.log_issue_deprecated_using_state proc_desc err_log exn ;
(Prop.exp_normalize_prop tenv prop exp, prop')
| Some (Attribute.UminusUnsigned (e, typ)), prop' ->
let desc =
@ -418,7 +418,7 @@ let check_arith_norm_exp {InterproceduralAnalysis.proc_desc; err_log; tenv} exp
(AnalysisState.get_node_exn ()) (AnalysisState.get_loc_exn ())
in
let exn = Exceptions.Unary_minus_applied_to_unsigned_expression (desc, __POS__) in
BiabductionReporting.log_issue_deprecated_using_state proc_desc err_log Warning exn ;
BiabductionReporting.log_issue_deprecated_using_state proc_desc err_log exn ;
(Prop.exp_normalize_prop tenv prop exp, prop')
| None, prop' ->
(Prop.exp_normalize_prop tenv prop exp, prop')
@ -476,7 +476,7 @@ let check_already_dereferenced {InterproceduralAnalysis.proc_desc; err_log; tenv
(AnalysisState.get_node_exn ()) n (AnalysisState.get_loc_exn ())
in
let exn = Exceptions.Null_test_after_dereference (desc, __POS__) in
BiabductionReporting.log_issue_deprecated_using_state proc_desc err_log Warning exn
BiabductionReporting.log_issue_deprecated_using_state proc_desc err_log exn
| None ->
()
@ -1206,7 +1206,7 @@ let rec sym_exec
ret_id_typ ret_typ actual_args =
let skip_res () =
let exn = Exceptions.Skip_function (Localise.desc_skip_function callee_pname) in
BiabductionReporting.log_issue_deprecated_using_state current_pdesc err_log Info exn ;
BiabductionReporting.log_issue_deprecated_using_state current_pdesc err_log 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.instr
@ -1257,8 +1257,7 @@ let rec sym_exec
let exn =
Exceptions.Condition_always_true_false (desc, not (IntLit.iszero i), __POS__)
in
BiabductionReporting.log_issue_deprecated_using_state current_pdesc err_log Warning
exn
BiabductionReporting.log_issue_deprecated_using_state current_pdesc err_log exn
| _ ->
()
in

@ -401,7 +401,7 @@ let check_path_errors_in_post {InterproceduralAnalysis.proc_desc= caller_pdesc;
in
State.set_path new_path path_pos_opt ;
let exn = Exceptions.Divide_by_zero (desc, __POS__) in
BiabductionReporting.log_issue_deprecated_using_state caller_pdesc err_log Warning exn )
BiabductionReporting.log_issue_deprecated_using_state caller_pdesc err_log exn )
| _ ->
()
in
@ -1132,7 +1132,7 @@ let exe_spec
missing_sigma_objc_class callee_summary ) ;
let log_check_exn check =
let exn = get_check_exn tenv check callee_pname loc __POS__ in
BiabductionReporting.log_issue_deprecated_using_state caller_pdesc err_log Warning exn
BiabductionReporting.log_issue_deprecated_using_state caller_pdesc err_log exn
in
let do_split () =
process_splitting actual_pre sub1 sub2 frame missing_pi missing_sigma frame_fld missing_fld

@ -404,7 +404,7 @@ let forward_tabulate ({InterproceduralAnalysis.proc_desc; err_log; tenv; _} as a
L.d_strln "SIL INSTR:" ;
Procdesc.Node.d_instrs ~highlight:(AnalysisState.get_instr ()) curr_node ;
L.d_ln () ;
BiabductionReporting.log_issue_deprecated_using_state proc_desc err_log Error exn ;
BiabductionReporting.log_issue_deprecated_using_state proc_desc err_log exn ;
State.mark_instr_fail exn
in
let exe_iter f pathset =
@ -493,7 +493,7 @@ let remove_locals_formals_and_check {InterproceduralAnalysis.proc_desc; err_log;
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
BiabductionReporting.log_issue_deprecated_using_state proc_desc err_log Warning exn
BiabductionReporting.log_issue_deprecated_using_state proc_desc err_log exn
in
List.iter ~f:check_pvar pvars ;
p'
@ -803,7 +803,7 @@ let perform_analysis_phase ({InterproceduralAnalysis.proc_desc; err_log; tenv} a
in
let get_results (wl : Worklist.t) () =
State.process_execution_failures
(BiabductionReporting.log_issue_deprecated_using_state proc_desc err_log Warning) ;
(BiabductionReporting.log_issue_deprecated_using_state proc_desc err_log) ;
let results = collect_analysis_result analysis_data wl proc_cfg in
let specs =
try extract_specs analysis_data (ProcCfg.Exceptional.proc_desc proc_cfg) results
@ -812,7 +812,7 @@ let perform_analysis_phase ({InterproceduralAnalysis.proc_desc; err_log; tenv} a
Exceptions.Internal_error
(Localise.verbatim_desc "Leak_while_collecting_specs_after_footprint")
in
BiabductionReporting.log_issue_deprecated_using_state proc_desc err_log Error exn ;
BiabductionReporting.log_issue_deprecated_using_state proc_desc err_log exn ;
(* returning no specs *) []
in
(specs, BiabductionSummary.FOOTPRINT)
@ -928,7 +928,7 @@ let report_custom_errors {InterproceduralAnalysis.proc_desc; err_log; tenv} summ
let loc = Procdesc.get_loc proc_desc in
let err_desc = Localise.desc_custom_error loc in
let exn = Exceptions.Custom_error (custom_error, Error, err_desc) in
BiabductionReporting.log_issue_deprecated_using_state proc_desc err_log Error exn
BiabductionReporting.log_issue_deprecated_using_state proc_desc err_log exn
in
List.iter ~f:report error_preconditions
@ -1124,5 +1124,5 @@ let analyze_procedure ({InterproceduralAnalysis.proc_desc; err_log} as analysis_
try Some (analyze_procedure_aux analysis_data)
with exn ->
IExn.reraise_if exn ~f:(fun () -> not (Exceptions.handle_exception exn)) ;
BiabductionReporting.log_error_using_state proc_desc err_log exn ;
BiabductionReporting.log_issue_using_state proc_desc err_log exn ;
None

@ -640,8 +640,7 @@ let make_trace ~report_kind original_exp =
let log_issue current_pname ~issue_log ~loc ~ltr ~access issue_type error_message =
Reporting.log_issue_external current_pname Warning ~issue_log ~loc ~ltr ~access issue_type
error_message
Reporting.log_issue_external current_pname ~issue_log ~loc ~ltr ~access issue_type error_message
type reported_access =

@ -470,7 +470,7 @@ end = struct
let issue_log_of loc_map =
let log_report ~issue_log loc {problem; pname; ltr; message} =
let issue_type = issue_type_of_problem problem in
Reporting.log_issue_external ~issue_log pname Error ~loc ~ltr Starvation issue_type message
Reporting.log_issue_external ~issue_log pname ~loc ~ltr Starvation issue_type message
in
let mk_deduped_report ({message} as report) =
{ report with

@ -13,8 +13,8 @@ let log_issue ?proc_name ~issue_log ~loc ~severity ~nullsafe_extra issue_type er
in
let proc_name = Option.value proc_name ~default:Procname.Linters_dummy_method in
let trace = [Errlog.make_trace_element 0 loc error_message []] in
Reporting.log_issue_external proc_name severity ~issue_log ~loc ~extras ~ltr:trace Eradicate
issue_type error_message
Reporting.log_issue_external proc_name ~severity_override:severity ~issue_log ~loc ~extras
~ltr:trace Eradicate issue_type error_message
(* If the issue is related to violation of nullability type system rules *)

@ -17,6 +17,6 @@ let report_error {IntraproceduralAnalysis.proc_desc; tenv; err_log} checker kind
let trace = [Errlog.make_trace_element 0 loc description []] in
let node = AnalysisState.get_node_exn () in
let session = AnalysisState.get_session () in
Reporting.log_issue_from_summary severity proc_desc err_log
Reporting.log_issue_from_summary ~severity_override:severity proc_desc err_log
~node:(BackendNode {node})
~session ~loc ~ltr:trace checker exn

Loading…
Cancel
Save