[errlog] reporting asserts checker matches issue-type

Summary:
Add an extra argument everywhere we report about the identity of the
checker doing the reporting. This isn't type safe in any way, i.e. a
checker can masquerade as another. But, hopefully it's enough to ensure
checker writers (and diff reviewers) have a chance to reflect on what
issue type they are reporting.

Reviewed By: ngorogiannis

Differential Revision: D21638823

fbshipit-source-id: b4a4b0c0a
master
Jules Villard 5 years ago committed by Facebook GitHub Bot
parent 248eaf87c7
commit 4e28980c8e

@ -200,8 +200,16 @@ let update errlog_old errlog_new =
let log_issue severity err_log ~loc ~node ~session ~ltr ~linters_def_file ~doc_url ~access ~extras
exn =
checker exn =
let error = Exceptions.recognize_exception exn in
if not (IssueType.checker_can_report checker error.name) then
L.die InternalError
"Issue type \"%s\" cannot be reported by the checker \"%s\". The only checkers that are \
expected to produce this error type are [%a]. If this is incorrect please either update the \
issue in IssueType or create a new issue type for \"%s\"."
error.name.unique_id (Checker.get_name checker) (Pp.seq F.pp_print_string)
(List.map ~f:Checker.get_name error.name.checkers)
(Checker.get_name checker) ;
let severity = Option.value error.severity ~default:severity in
let hide_java_loc_zero =
(* hide java errors at location zero unless in -developer_mode *)

@ -74,8 +74,6 @@ val iter : iter_fun -> t -> unit
val fold : (err_key -> err_data -> 'a -> 'a) -> t -> 'a -> 'a
val pp_loc_trace_elem : Format.formatter -> loc_trace_elem -> unit [@@warning "-32"]
val pp_loc_trace : Format.formatter -> loc_trace -> unit
val pp_errors : Format.formatter -> t -> unit
@ -101,5 +99,6 @@ val log_issue :
-> doc_url:string option
-> access:string option
-> extras:Jsonbug_t.extra option
-> Checker.t
-> exn
-> unit

@ -7,23 +7,25 @@
open! IStd
type log_t = ?ltr:Errlog.loc_trace -> ?extras:Jsonbug_t.extra -> IssueType.t -> string -> unit
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 exn =
let log_issue_from_errlog severity err_log ~loc ~node ~session ~ltr ~access ~extras checker exn =
let issue_type = (Exceptions.recognize_exception exn).name 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 exn
~extras checker exn
let log_frontend_issue severity 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 exn
log_issue_from_errlog severity 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 exn =
let log_issue_from_summary severity 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
@ -46,36 +48,37 @@ let log_issue_from_summary severity proc_desc err_log ~node ~session ~loc ~ltr ?
in
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 exn
else
log_issue_from_errlog severity 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 issue_type
error_message =
let log_issue_from_summary_simplified severity 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 exn
?extras checker 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 attrs err_log ~loc ?ltr ?extras checker issue_type error_message =
log_issue_from_summary_simplified Exceptions.Error attrs err_log ~loc ?ltr ?extras checker
issue_type error_message
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_warning attrs err_log ~loc ?ltr ?extras checker issue_type error_message =
log_issue_from_summary_simplified Exceptions.Warning attrs err_log ~loc ?ltr ?extras checker
issue_type error_message
let log_issue_external procname ~issue_log severity ~loc ~ltr ?access ?extras issue_type
let log_issue_external procname ~issue_log severity ~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 exn ;
log_issue_from_errlog severity errlog ~loc ~node ~session:0 ~ltr ~access ~extras checker exn ;
issue_log

@ -9,7 +9,8 @@ open! IStd
(** Type of functions to report issues to the error_log in a spec. *)
type log_t = ?ltr:Errlog.loc_trace -> ?extras:Jsonbug_t.extra -> IssueType.t -> string -> unit
type log_t =
?ltr:Errlog.loc_trace -> ?extras:Jsonbug_t.extra -> Checker.t -> IssueType.t -> string -> unit
val log_issue_from_summary :
Exceptions.severity
@ -20,6 +21,7 @@ val log_issue_from_summary :
-> loc:Location.t
-> ltr:Errlog.loc_trace
-> ?extras:Jsonbug_t.extra
-> Checker.t
-> exn
-> unit
@ -47,6 +49,7 @@ val log_issue_external :
-> ltr:Errlog.loc_trace
-> ?access:string
-> ?extras:Jsonbug_t.extra
-> Checker.t
-> IssueType.t
-> string
-> IssueLog.t

@ -273,3 +273,6 @@ let config checker =
; cli_flags= Some {long= "uninit"; deprecated= []; show_in_help= true}
; enabled_by_default= true
; activates= [] }
let get_name c = (config c).name

@ -64,3 +64,6 @@ type config =
; activates: t list (** TODO doc *) }
val config : t -> config
val get_name : t -> string
(** [get_name c] is [(config c).name] *)

@ -497,7 +497,7 @@ let pure_function = register_from_string ~id:"PURE_FUNCTION" [Purity]
let quandary_taint_error = register_from_string ~id:"QUANDARY_TAINT_ERROR" [Quandary]
let registered_observer_being_deallocated =
register_from_string ~id:"REGISTERED_OBSERVER_BEING_DEALLOCATED" [Biabduction]
register_from_string ~id:"REGISTERED_OBSERVER_BEING_DEALLOCATED" [Biabduction; Linters]
let resource_leak = register_from_string ~id:"RESOURCE_LEAK" [Biabduction; ResourceLeakLabExercise]

@ -16,7 +16,8 @@ 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 exn
Reporting.log_issue_from_summary severity proc_desc err_log ~node ~session ~loc ~ltr Biabduction
exn
let log_error_using_state proc_desc err_log exn =
@ -30,4 +31,5 @@ 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 Exceptions.Error proc_desc err_log ~node ~session ~loc ~ltr exn
Reporting.log_issue_from_summary Exceptions.Error proc_desc err_log ~node ~session ~loc ~ltr
Biabduction exn

@ -36,7 +36,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 proc_desc err_log ~loc:location ~ltr issue_type desc
Reporting.log_warning proc_desc err_log ~loc:location ~ltr BufferOverrunChecker issue_type desc
end
module UnusedBranches = struct
@ -53,8 +53,8 @@ module UnreachableStatement = struct
let report {InterproceduralAnalysis.proc_desc; err_log} {location} =
let ltr = [Errlog.make_trace_element 0 location "Here" []] in
Reporting.log_error proc_desc err_log ~loc:location ~ltr IssueType.unreachable_code_after
"Unreachable code after statement"
Reporting.log_error proc_desc err_log ~loc:location ~ltr BufferOverrunChecker
IssueType.unreachable_code_after "Unreachable code after statement"
end
module UnreachableStatements = struct
@ -406,7 +406,7 @@ let report_errors ({InterproceduralAnalysis.proc_desc; err_log} as analysis_data
Trace.Issue.make_err_trace ~description (PO.ConditionTrace.get_val_traces trace)
|> Errlog.concat_traces
in
Reporting.log_error proc_desc err_log ~loc:location ~ltr:trace issue_type
Reporting.log_error proc_desc err_log ~loc:location ~ltr:trace BufferOverrunChecker issue_type
(description ~markup:true)
in
PO.ConditionSet.report_errors ~report cond_set

@ -82,7 +82,8 @@ let report_missing_required_prop proc_desc err_log prop parent_typename ~create_
in
Errlog.make_trace_element 0 location call_msg [] )
in
Reporting.log_error proc_desc err_log ~loc:create_loc ~ltr IssueType.missing_required_prop message
Reporting.log_error proc_desc err_log ~loc:create_loc ~ltr LithoRequiredProps
IssueType.missing_required_prop message
let has_prop prop_set prop =

@ -240,7 +240,8 @@ 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 proc_desc err_log ~ltr ~loc IssueType.strong_self_not_checked message ;
Reporting.log_error proc_desc err_log ~ltr ~loc SelfInBlock
IssueType.strong_self_not_checked message ;
let strongVars =
StrongEqualToWeakCapturedVars.add pvar
{strongVarElem with reported= true}
@ -436,7 +437,8 @@ let report_mix_self_weakself_issues proc_desc err_log domain (weakSelf : DomainD
Location.pp self.loc
in
let ltr = make_trace_use_self_weakself domain in
Reporting.log_error proc_desc err_log ~ltr ~loc:self.loc IssueType.mixed_self_weakself message
Reporting.log_error proc_desc err_log ~ltr ~loc:self.loc SelfInBlock IssueType.mixed_self_weakself
message
let report_weakself_in_no_escape_block_issues proc_desc err_log domain (weakSelf : DomainData.t)
@ -453,7 +455,7 @@ let report_weakself_in_no_escape_block_issues proc_desc err_log domain (weakSelf
(Procname.to_simplified_string procname)
in
let ltr = make_trace_use_self_weakself domain in
Reporting.log_error proc_desc err_log ~ltr ~loc:weakSelf.loc
Reporting.log_error proc_desc err_log ~ltr ~loc:weakSelf.loc SelfInBlock
IssueType.weak_self_in_noescape_block message ;
reported_weak_self_in_noescape_block )
else reported_weak_self_in_noescape_block
@ -471,7 +473,8 @@ let report_weakself_multiple_issue proc_desc err_log domain (weakSelf1 : DomainD
(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 proc_desc err_log ~ltr ~loc:weakSelf1.loc IssueType.multiple_weakself message
Reporting.log_error proc_desc err_log ~ltr ~loc:weakSelf1.loc SelfInBlock
IssueType.multiple_weakself message
let report_captured_strongself_issue proc_desc err_log domain (capturedStrongSelf : DomainData.t)
@ -492,7 +495,7 @@ let report_captured_strongself_issue proc_desc err_log domain (capturedStrongSel
(Pvar.pp Pp.text) capturedStrongSelf.pvar Location.pp capturedStrongSelf.loc
in
let ltr = make_trace_captured_strong_self domain in
Reporting.log_error proc_desc err_log ~ltr ~loc:capturedStrongSelf.loc
Reporting.log_error proc_desc err_log ~ltr ~loc:capturedStrongSelf.loc SelfInBlock
IssueType.captured_strong_self message ;
report_captured_strongself )
else report_captured_strongself

@ -231,8 +231,8 @@ let report_siof {InterproceduralAnalysis.proc_desc; err_log; analyze_dependency;
GlobalVar.pp (SiofTrace.Sink.kind final_sink)
in
let ltr = SiofTrace.trace_of_error loc gname trace in
Reporting.log_error proc_desc err_log ~loc ~ltr IssueType.static_initialization_order_fiasco
description
Reporting.log_error proc_desc err_log ~loc ~ltr SIOF
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 *)

@ -85,7 +85,7 @@ let report_allocation_stack {InterproceduralAnalysis.proc_desc; err_log} src_ann
MF.pp_monospaced ("@" ^ src_annot) MF.pp_monospaced constr_str MF.pp_monospaced
("new " ^ constr_str)
in
Reporting.log_error proc_desc err_log ~loc:fst_call_loc ~ltr:final_trace
Reporting.log_error proc_desc err_log ~loc:fst_call_loc ~ltr:final_trace AnnotationReachability
IssueType.checkers_allocates_memory description
@ -109,7 +109,8 @@ let report_annotation_stack ({InterproceduralAnalysis.proc_desc; err_log} as ana
IssueType.checkers_calls_expensive_method
else IssueType.checkers_annotation_reachability_error
in
Reporting.log_error proc_desc err_log ~loc ~ltr:final_trace issue_type description
Reporting.log_error proc_desc err_log ~loc ~ltr:final_trace AnnotationReachability issue_type
description
let report_call_stack end_of_stack lookup_next_calls report call_site sink_map =
@ -333,7 +334,8 @@ module CxxAnnotationSpecs = struct
IssueType.register_from_string ~id:spec_name ~doc_url ~linters_def_file
[AnnotationReachability]
in
Reporting.log_error proc_desc err_log ~loc ~ltr:final_trace issue_type description
Reporting.log_error proc_desc err_log ~loc ~ltr:final_trace AnnotationReachability issue_type
description
in
let snk_annot = annotation_of_str snk_name in
let report ({InterproceduralAnalysis.proc_desc} as analysis_data) annot_map =
@ -411,8 +413,8 @@ module ExpensiveAnnotationSpec = struct
(Procname.to_string overridden_pname)
MF.pp_monospaced ("@" ^ Annotations.expensive)
in
Reporting.log_error proc_desc err_log ~loc IssueType.checkers_expensive_overrides_unexpensive
description
Reporting.log_error proc_desc err_log ~loc AnnotationReachability
IssueType.checkers_expensive_overrides_unexpensive description
let spec =

@ -112,7 +112,7 @@ let report_loads {InterproceduralAnalysis.proc_desc; err_log} astate =
else
let ltr = ClassLoadsDomain.Event.make_loc_trace event in
let msg = Format.asprintf "Class %s loaded" elem in
Reporting.log_warning proc_desc err_log ~loc ~ltr IssueType.class_load msg
Reporting.log_warning proc_desc err_log ~loc ~ltr ClassLoads IssueType.class_load msg
in
let pname = Procdesc.get_proc_name proc_desc in
Procname.get_class_name pname

@ -43,7 +43,7 @@ let report_warning proc_desc err_log class_name fld fld_typ =
(format_method (Procdesc.get_proc_name proc_desc))
pp_m on_create_view pp_m on_destroy_view
in
Reporting.log_warning proc_desc err_log ~loc:(Procdesc.get_loc proc_desc)
Reporting.log_warning proc_desc err_log ~loc:(Procdesc.get_loc proc_desc) FragmentRetainsView
IssueType.checkers_fragment_retain_view description

@ -170,14 +170,14 @@ let checker {IntraproceduralAnalysis.proc_desc; tenv; err_log} pulse_summary_opt
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 proc_desc err_log ~loc:pname_loc ~ltr:[impure_fun_ltr]
Reporting.log_error proc_desc err_log ~loc:pname_loc ~ltr:[impure_fun_ltr] Impurity
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 proc_desc err_log ~loc:pname_loc ~ltr:[impure_fun_ltr]
Reporting.log_error proc_desc err_log ~loc:pname_loc ~ltr:[impure_fun_ltr] Impurity
IssueType.impure_function impure_fun_desc
| Some pre_posts ->
let (ImpurityDomain.{modified_globals; modified_params; skipped_calls} as impurity_astate) =
@ -207,5 +207,5 @@ let checker {IntraproceduralAnalysis.proc_desc; tenv; err_log} pulse_summary_opt
:: modified_ltr Formal modified_params
(modified_ltr Global modified_globals skipped_functions)
in
Reporting.log_error proc_desc err_log ~loc:pname_loc ~ltr IssueType.impure_function
Reporting.log_error proc_desc err_log ~loc:pname_loc ~ltr Impurity IssueType.impure_function
impure_fun_desc

@ -75,7 +75,7 @@ let report_matching_get proc_desc err_log tenv 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 proc_desc err_log ~loc ~ltr
Reporting.log_error proc_desc err_log ~loc ~ltr InefficientKeysetIterator
IssueType.inefficient_keyset_iterator exp_desc ) ) )
loop_nodes

@ -256,7 +256,7 @@ let checker {IntraproceduralAnalysis.proc_desc; err_log} =
(Typ.pp_full Pp.text) typ
in
let ltr = [Errlog.make_trace_element 0 loc "Write of unused value" []] in
Reporting.log_error proc_desc err_log ~loc ~ltr IssueType.dead_store message
Reporting.log_error proc_desc err_log ~loc ~ltr Liveness 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,8 +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 proc_desc err_log ~loc:instr_loc IssueType.checkers_printf_args
description
Reporting.log_error proc_desc err_log ~loc:instr_loc PrintfArgs
IssueType.checkers_printf_args description
else check_type_names instr_loc (n_arg + 1) instr_proc_name fs gs
| [], [] ->
()
@ -121,8 +121,8 @@ 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 proc_desc err_log ~loc:instr_loc IssueType.checkers_printf_args
description
Reporting.log_error proc_desc err_log ~loc:instr_loc PrintfArgs
IssueType.checkers_printf_args description
in
(* Get the array ivar for a given nvar *)
let array_ivar instrs nvar =
@ -158,8 +158,8 @@ 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 proc_desc err_log ~loc:cl IssueType.checkers_printf_args
"Format string must be string literal"
Reporting.log_warning proc_desc err_log ~loc:cl PrintfArgs
IssueType.checkers_printf_args "Format string must be string literal"
with e ->
L.internal_error "%s Exception when analyzing %s: %s@."
IssueType.checkers_printf_args.unique_id (Procname.to_string proc_name) (Exn.to_string e)

@ -201,7 +201,7 @@ let report_errors {InterproceduralAnalysis.proc_desc; err_log} astate_opt =
let loc = Procdesc.get_loc proc_desc 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 proc_desc err_log ~loc ~ltr IssueType.pure_function exp_desc
Reporting.log_error proc_desc err_log ~loc ~ltr Purity IssueType.pure_function exp_desc
| None ->
L.internal_error "Analyzer failed to compute purity information for %a@." Procname.pp
proc_name

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

@ -665,7 +665,7 @@ let report_thread_safety_violation ~make_description ~report_kind
let error_message = F.sprintf "%s%s" description explanation in
let end_locs = Option.to_list original_end @ Option.to_list conflict_end in
let access = IssueAuxData.encode end_locs in
log_issue pname ~issue_log ~loc ~ltr ~access issue_type error_message
log_issue pname ~issue_log ~loc ~ltr ~access RacerD issue_type error_message
let report_unannotated_interface_violation reported_pname reported_access issue_log =

@ -467,7 +467,8 @@ 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 Exceptions.Error ~loc ~ltr issue_type message
Reporting.log_issue_external ~issue_log pname Exceptions.Error ~loc ~ltr Starvation issue_type
message
in
let mk_deduped_report ({message} as report) =
{ report with

@ -262,7 +262,7 @@ module Check = struct
in
Reporting.log_error proc_desc err_log ~loc:location
~ltr:(cost_trace_elem :: BasicCost.polynomial_traces cost)
~extras:(compute_errlog_extras cost) report_issue_type message
~extras:(compute_errlog_extras cost) Cost report_issue_type message
let report_top_and_unreachable pname proc_desc err_log loc ~name ~cost
@ -271,7 +271,7 @@ module Check = struct
let message = F.asprintf "%s of the function %a %s" name Procname.pp pname suffix in
Reporting.log_error proc_desc err_log ~loc
~ltr:(BasicCost.polynomial_traces cost)
~extras:(compute_errlog_extras cost) issue message
~extras:(compute_errlog_extras cost) Cost issue message
in
if BasicCost.is_top cost then report infinite_issue "cannot be computed"
else if BasicCost.is_unreachable cost then

@ -96,7 +96,7 @@ let do_report extract_cost_if_expensive proc_desc err_log (Call.{pname; loc} as
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 proc_desc err_log ~loc ~ltr issue message
Reporting.log_error proc_desc err_log ~loc ~ltr LoopHoisting issue message
let get_cost_if_expensive tenv integer_type_widths get_callee_cost_summary_and_formals

@ -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 issue_type
error_message
Reporting.log_issue_external proc_name severity ~issue_log ~loc ~extras ~ltr:trace Eradicate
issue_type error_message
(* If the issue is related to violation of nullability type system rules *)

@ -9,8 +9,9 @@ open! IStd
(** Module for Eradicate-based user-defined checkers. *)
let report_error {IntraproceduralAnalysis.proc_desc; tenv; err_log} kind loc ?(field_name = None)
?(exception_kind = fun k d -> Exceptions.Checkers (k, d)) ~severity description =
let report_error {IntraproceduralAnalysis.proc_desc; tenv; err_log} checker kind loc
?(field_name = None) ?(exception_kind = fun k d -> Exceptions.Checkers (k, d)) ~severity
description =
let suppressed = Reporting.is_suppressed tenv proc_desc kind ~field_name in
if suppressed then Logging.debug Analysis Medium "Reporting is suppressed!@\n"
else
@ -21,4 +22,4 @@ let report_error {IntraproceduralAnalysis.proc_desc; tenv; err_log} kind loc ?(f
let session = AnalysisState.get_session () in
Reporting.log_issue_from_summary severity proc_desc err_log
~node:(BackendNode {node})
~session ~loc ~ltr:trace exn
~session ~loc ~ltr:trace checker exn

@ -11,6 +11,7 @@ open! IStd
val report_error :
IntraproceduralAnalysis.t
-> Checker.t
-> IssueType.t
-> Location.t
-> ?field_name:Fieldname.t option

@ -35,8 +35,8 @@ let check_immutable_cast analysis_data proc_desc typ_expected typ_found_opt loc
(Procname.to_simplified_string (Procdesc.get_proc_name proc_desc))
Typ.Name.pp name_given Typ.Name.pp name_expected
in
EradicateCheckers.report_error analysis_data IssueType.checkers_immutable_cast loc
description ~severity:Exceptions.Warning
EradicateCheckers.report_error analysis_data ImmutableCast
IssueType.checkers_immutable_cast loc description ~severity:Exceptions.Warning
| _ ->
() )
| None ->

@ -334,7 +334,8 @@ let report_now_if_reportable analysis_data err_instance ~nullsafe_mode loc =
Logging.debug Analysis Medium "About to report: %s" err_description ;
let field_name = get_field_name_for_error_suppressing err_instance in
let error_location = Option.value updated_location ~default:loc in
EradicateCheckers.report_error analysis_data infer_issue_type error_location ~field_name
EradicateCheckers.report_error analysis_data Eradicate infer_issue_type error_location
~field_name
~exception_kind:(fun k d -> Exceptions.Eradicate (k, d))
~severity err_description )

@ -15,7 +15,7 @@ open PulseDomainInterface
let report {InterproceduralAnalysis.proc_desc; err_log} diagnostic =
let open Diagnostic in
Reporting.log_error proc_desc err_log ~loc:(get_location diagnostic) ~ltr:(get_trace diagnostic)
(get_issue_type diagnostic) (get_message diagnostic)
Pulse (get_issue_type diagnostic) (get_message diagnostic)
let check_error_transform analysis_data ~f = function

@ -298,7 +298,8 @@ 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_desc err_log ~loc:(CallSite.loc cur_site) ~ltr issue trace_str
Reporting.log_error proc_desc err_log ~loc:(CallSite.loc cur_site) ~ltr Quandary issue
trace_str
in
List.iter ~f:report_one (TraceDomain.get_reports ~cur_site trace)

@ -282,7 +282,7 @@ let add_errors env proc_desc err_log biabduction_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 proc_desc err_log IssueType.topl_error ~loc message )
Reporting.log_error proc_desc err_log TOPL 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