diff --git a/infer/src/absint/Errlog.ml b/infer/src/absint/Errlog.ml index f67627893..f5b936881 100644 --- a/infer/src/absint/Errlog.ml +++ b/infer/src/absint/Errlog.ml @@ -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 = diff --git a/infer/src/absint/Errlog.mli b/infer/src/absint/Errlog.mli index b2fef3df0..f9effc105 100644 --- a/infer/src/absint/Errlog.mli +++ b/infer/src/absint/Errlog.mli @@ -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 diff --git a/infer/src/absint/Exceptions.ml b/infer/src/absint/Exceptions.ml index 2be75d94b..9b1fc5b96 100644 --- a/infer/src/absint/Exceptions.ml +++ b/infer/src/absint/Exceptions.ml @@ -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) diff --git a/infer/src/absint/Exceptions.mli b/infer/src/absint/Exceptions.mli index 8c964fca4..942c1a543 100644 --- a/infer/src/absint/Exceptions.mli +++ b/infer/src/absint/Exceptions.mli @@ -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 diff --git a/infer/src/absint/Reporting.ml b/infer/src/absint/Reporting.ml index 403898003..8519714a8 100644 --- a/infer/src/absint/Reporting.ml +++ b/infer/src/absint/Reporting.ml @@ -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 diff --git a/infer/src/absint/Reporting.mli b/infer/src/absint/Reporting.mli index 8c503e7d1..5ae6b7fae 100644 --- a/infer/src/absint/Reporting.mli +++ b/infer/src/absint/Reporting.mli @@ -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 diff --git a/infer/src/al/ALIssues.ml b/infer/src/al/ALIssues.ml index b06abb277..224ff168c 100644 --- a/infer/src/al/ALIssues.ml +++ b/infer/src/al/ALIssues.ml @@ -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 = diff --git a/infer/src/backend/ondemand.ml b/infer/src/backend/ondemand.ml index 126cd1f33..4ebcc803d 100644 --- a/infer/src/backend/ondemand.ml +++ b/infer/src/backend/ondemand.ml @@ -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 = diff --git a/infer/src/base/IssueType.mli b/infer/src/base/IssueType.mli index 11fdb0370..24e395d64 100644 --- a/infer/src/base/IssueType.mli +++ b/infer/src/base/IssueType.mli @@ -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 diff --git a/infer/src/biabduction/Abs.ml b/infer/src/biabduction/Abs.ml index 11e415fd9..13f82593f 100644 --- a/infer/src/biabduction/Abs.ml +++ b/infer/src/biabduction/Abs.ml @@ -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 () ; diff --git a/infer/src/biabduction/BiabductionReporting.ml b/infer/src/biabduction/BiabductionReporting.ml index b580471f5..e0c07f3ce 100644 --- a/infer/src/biabduction/BiabductionReporting.ml +++ b/infer/src/biabduction/BiabductionReporting.ml @@ -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 diff --git a/infer/src/biabduction/BiabductionReporting.mli b/infer/src/biabduction/BiabductionReporting.mli index bdf937c25..2306d2a51 100644 --- a/infer/src/biabduction/BiabductionReporting.mli +++ b/infer/src/biabduction/BiabductionReporting.mli @@ -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 diff --git a/infer/src/biabduction/Prover.ml b/infer/src/biabduction/Prover.ml index b23d06797..563ea6806 100644 --- a/infer/src/biabduction/Prover.ml +++ b/infer/src/biabduction/Prover.ml @@ -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 diff --git a/infer/src/biabduction/Rearrange.ml b/infer/src/biabduction/Rearrange.ml index 5a5c0041d..1426cab88 100644 --- a/infer/src/biabduction/Rearrange.ml +++ b/infer/src/biabduction/Rearrange.ml @@ -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 ; diff --git a/infer/src/biabduction/RetainCycles.ml b/infer/src/biabduction/RetainCycles.ml index b527c161f..403f070fa 100644 --- a/infer/src/biabduction/RetainCycles.ml +++ b/infer/src/biabduction/RetainCycles.ml @@ -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__)) ) diff --git a/infer/src/biabduction/SymExec.ml b/infer/src/biabduction/SymExec.ml index 89bca57fa..aeac12083 100644 --- a/infer/src/biabduction/SymExec.ml +++ b/infer/src/biabduction/SymExec.ml @@ -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 diff --git a/infer/src/biabduction/Tabulation.ml b/infer/src/biabduction/Tabulation.ml index 5dd0d25e3..4dbc7bb95 100644 --- a/infer/src/biabduction/Tabulation.ml +++ b/infer/src/biabduction/Tabulation.ml @@ -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 diff --git a/infer/src/biabduction/interproc.ml b/infer/src/biabduction/interproc.ml index 544e08bae..4b47c8491 100644 --- a/infer/src/biabduction/interproc.ml +++ b/infer/src/biabduction/interproc.ml @@ -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 diff --git a/infer/src/concurrency/RacerD.ml b/infer/src/concurrency/RacerD.ml index 6188f1cb3..312657460 100644 --- a/infer/src/concurrency/RacerD.ml +++ b/infer/src/concurrency/RacerD.ml @@ -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 = diff --git a/infer/src/concurrency/starvation.ml b/infer/src/concurrency/starvation.ml index a24f120c6..6eb7c47af 100644 --- a/infer/src/concurrency/starvation.ml +++ b/infer/src/concurrency/starvation.ml @@ -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 diff --git a/infer/src/nullsafe/ClassLevelAnalysis.ml b/infer/src/nullsafe/ClassLevelAnalysis.ml index 3dc600045..2f8d7ee96 100644 --- a/infer/src/nullsafe/ClassLevelAnalysis.ml +++ b/infer/src/nullsafe/ClassLevelAnalysis.ml @@ -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 *) diff --git a/infer/src/nullsafe/EradicateReporting.ml b/infer/src/nullsafe/EradicateReporting.ml index ec35706b9..9693d6ec0 100644 --- a/infer/src/nullsafe/EradicateReporting.ml +++ b/infer/src/nullsafe/EradicateReporting.ml @@ -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