diff --git a/infer/src/backend/ondemand.ml b/infer/src/backend/ondemand.ml index ea0ecddcb..2664708cc 100644 --- a/infer/src/backend/ondemand.ml +++ b/infer/src/backend/ondemand.ml @@ -149,7 +149,8 @@ let run_proc_analysis analyze_proc ~caller_pdesc callee_pdesc = summary in let log_error_and_continue exn (summary: Summary.t) kind = - Reporting.log_error summary exn ; + let loc = State.get_loc () in + Reporting.log_error summary ~loc exn ; let stats = Summary.Stats.update summary.stats ~failure_kind:kind in let payloads = let biabduction = diff --git a/infer/src/backend/reporting.ml b/infer/src/backend/reporting.ml index b505120de..9273b93ca 100644 --- a/infer/src/backend/reporting.ml +++ b/infer/src/backend/reporting.ml @@ -9,8 +9,8 @@ open! IStd module L = Logging type log_t = - ?loc:Location.t -> ?session:int -> ?ltr:Errlog.loc_trace -> ?linters_def_file:string - -> ?doc_url:string -> ?access:string -> ?extras:Jsonbug_t.extra -> exn -> unit + ?session:int -> ?ltr:Errlog.loc_trace -> ?linters_def_file:string -> ?doc_url:string + -> ?access:string -> ?extras:Jsonbug_t.extra -> exn -> unit let log_issue_from_errlog_internal procname ~clang_method_kind severity err_log ~loc ~node_id_key ~session ~ltr ~linters_def_file ~doc_url ~access ~extras exn = @@ -27,7 +27,7 @@ let log_issue_from_errlog procname severity errlog ~loc ~node_id_key ~ltr ~linte ~session ~ltr ~linters_def_file ~doc_url ~access:None ~extras:None exn -let log_issue_from_summary severity summary ~node_id_key ?loc ?session ?ltr ?linters_def_file +let log_issue_from_summary severity summary ~node_id_key ~loc ?session ?ltr ?linters_def_file ?doc_url ?access ?extras exn = let attrs = Summary.get_attributes summary in let procname = attrs.proc_name in @@ -47,7 +47,6 @@ let log_issue_from_summary severity summary ~node_id_key ?loc ?session ?ltr ?lin else let err_log = Summary.get_err_log summary in let clang_method_kind = Some attrs.clang_method_kind in - let loc = match loc with None -> State.get_loc () | Some loc -> loc in let session = match session with None -> (State.get_session () :> int) | Some session -> session in @@ -63,7 +62,8 @@ let log_issue_deprecated severity proc_name ?node_id_key ?loc ?session ?ltr ?lin let node_id_key = match node_id_key with None -> State.get_node_id_key () | Some node_id_key -> node_id_key in - log_issue_from_summary severity summary ~node_id_key ?loc ?session ?ltr ?linters_def_file + let loc = match loc with None -> State.get_loc () | Some loc -> loc in + log_issue_from_summary severity summary ~node_id_key ~loc ?session ?ltr ?linters_def_file ?doc_url ?access exn | None -> L.(die InternalError) @@ -72,10 +72,10 @@ let log_issue_deprecated severity proc_name ?node_id_key ?loc ?session ?ltr ?lin Typ.Procname.pp proc_name Typ.Procname.pp proc_name -let log_issue_from_summary_simplified severity summary ?loc ?session ?ltr ?linters_def_file +let log_issue_from_summary_simplified severity summary ~loc ?session ?ltr ?linters_def_file ?doc_url ?access ?extras exn = let node_id_key = State.get_node_id_key () in - log_issue_from_summary severity summary ~node_id_key ?loc ?session ?ltr ?linters_def_file + log_issue_from_summary severity summary ~node_id_key ~loc ?session ?ltr ?linters_def_file ?doc_url ?access ?extras exn diff --git a/infer/src/backend/reporting.mli b/infer/src/backend/reporting.mli index 8781af508..156b15822 100644 --- a/infer/src/backend/reporting.mli +++ b/infer/src/backend/reporting.mli @@ -10,11 +10,12 @@ open! IStd (** Type of functions to report issues to the error_log in a spec. *) type log_t = - ?loc:Location.t -> ?session:int -> ?ltr:Errlog.loc_trace -> ?linters_def_file:string - -> ?doc_url:string -> ?access:string -> ?extras:Jsonbug_t.extra -> exn -> unit + ?session:int -> ?ltr:Errlog.loc_trace -> ?linters_def_file:string -> ?doc_url:string + -> ?access:string -> ?extras:Jsonbug_t.extra -> exn -> unit val log_issue_deprecated : - Exceptions.severity -> Typ.Procname.t -> ?node_id_key:Errlog.node_id_key -> log_t + Exceptions.severity -> Typ.Procname.t -> ?node_id_key:Errlog.node_id_key -> ?loc:Location.t + -> log_t (** Report an issue in the given procedure. DEPRECATED as it can create race conditions between checkers. Use log_error/warning instead *) @@ -25,10 +26,10 @@ val log_issue_from_errlog : -> doc_url:string option -> exn -> unit (** Report an issue of a given kind in the given error log. *) -val log_error : Summary.t -> log_t +val log_error : Summary.t -> loc:Location.t -> log_t (** Add an error to the given summary. *) -val log_warning : Summary.t -> log_t +val log_warning : Summary.t -> loc:Location.t -> log_t (** Add an warning to the given summary. *) val log_issue_external : diff --git a/infer/src/biabduction/RetainCycles.ml b/infer/src/biabduction/RetainCycles.ml index 117d4a0e6..f9bf8d3f2 100644 --- a/infer/src/biabduction/RetainCycles.ml +++ b/infer/src/biabduction/RetainCycles.ml @@ -242,7 +242,8 @@ let report_cycle tenv summary prop = RetainCyclesType.Set.iter (fun cycle -> let exn = exn_retain_cycle tenv cycle in - Reporting.log_error summary exn ) + let loc = State.get_loc () in + Reporting.log_error summary ~loc exn ) cycles ; (* we report the retain cycles above but need to raise an exception as well to stop the analysis *) raise (Exceptions.Dummy_exception (Localise.verbatim_desc "retain cycle found")) ) diff --git a/infer/src/biabduction/interproc.ml b/infer/src/biabduction/interproc.ml index 8e02ea0a3..16180c53a 100644 --- a/infer/src/biabduction/interproc.ml +++ b/infer/src/biabduction/interproc.ml @@ -1257,5 +1257,6 @@ let analyze_procedure {Callbacks.summary; proc_desc; tenv; exe_env} : Summary.t BuiltinDefn.init () ; try analyze_procedure_aux summary exe_env tenv proc_desc with exn -> IExn.reraise_if exn ~f:(fun () -> not (Exceptions.handle_exception exn)) ; - Reporting.log_error summary exn ; + let loc = State.get_loc () in + Reporting.log_error summary ~loc exn ; summary diff --git a/infer/src/checkers/NullabilitySuggest.ml b/infer/src/checkers/NullabilitySuggest.ml index 980d73ba9..e9d5e420e 100644 --- a/infer/src/checkers/NullabilitySuggest.ml +++ b/infer/src/checkers/NullabilitySuggest.ml @@ -198,7 +198,8 @@ let checker {Callbacks.summary; proc_desc; tenv} = | Some (loc, ltr) -> Reporting.log_warning summary ~loc ~ltr exn | None -> - Reporting.log_warning summary exn ) + let loc = Procdesc.get_loc proc_desc in + Reporting.log_warning summary ~loc exn ) | _ -> () in