Summary: This is a step in disentangling the various analyses: that file used to make every checker on biabduction because of a few of its functions that use biabduction datatypes. Split reporting.ml into: - Reporting.ml: the functions all checkers need to report errors. This is put in absint/ with the other files that are needed by all checkers. - SummaryReporting.ml: functions that need to depend on Summary.ml (useful for later). This is put in backend/ where Summary.ml lives. - BiabductionReporting.ml: for the biabduction analysis The rest of the changes are renames to use the appropriate module amongst the above. Reviewed By: ngorogiannis Differential Revision: D21257468 fbshipit-source-id: fa28cefbcmaster
parent
d8e3cea7fd
commit
a144c8e4df
@ -0,0 +1,26 @@
|
||||
(*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*)
|
||||
|
||||
open! IStd
|
||||
|
||||
type log_t = Reporting.log_t
|
||||
|
||||
let log_error summary ~loc ?ltr ?extras issue_type error_message =
|
||||
let attrs = Summary.get_attributes summary in
|
||||
let err_log = Summary.get_err_log summary in
|
||||
Reporting.log_error attrs err_log ~loc ?ltr ?extras issue_type error_message
|
||||
|
||||
|
||||
let log_warning summary ~loc ?ltr ?extras issue_type error_message =
|
||||
let attrs = Summary.get_attributes summary in
|
||||
let err_log = Summary.get_err_log summary in
|
||||
Reporting.log_warning attrs err_log ~loc ?ltr ?extras issue_type error_message
|
||||
|
||||
|
||||
let log_error_using_state summary exn =
|
||||
BiabductionReporting.log_error_using_state (Summary.get_proc_desc summary)
|
||||
(Summary.get_err_log summary) exn
|
@ -0,0 +1,21 @@
|
||||
(*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*)
|
||||
|
||||
open! IStd
|
||||
|
||||
(** convencience functions on top of {!Reporting} *)
|
||||
|
||||
type log_t = Reporting.log_t
|
||||
|
||||
val log_error : Summary.t -> loc:Location.t -> log_t
|
||||
(** Add an error to the given summary. *)
|
||||
|
||||
val log_warning : Summary.t -> loc:Location.t -> log_t
|
||||
(** Add a warning to the given summary. *)
|
||||
|
||||
val log_error_using_state : Summary.t -> exn -> unit
|
||||
(** Add an error to the given summary using biabduction state (DO NOT USE ELSEWHERE). *)
|
@ -0,0 +1,41 @@
|
||||
(*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*)
|
||||
|
||||
open! IStd
|
||||
module L = Logging
|
||||
|
||||
let log_issue_deprecated_using_state severity proc_name ?node ?loc ?ltr exn =
|
||||
if !BiabductionConfig.footprint then
|
||||
match Summary.OnDisk.get proc_name with
|
||||
| Some summary ->
|
||||
let node =
|
||||
let node = match node with None -> State.get_node_exn () | Some node -> node in
|
||||
Errlog.BackendNode {node}
|
||||
in
|
||||
let session = State.get_session () in
|
||||
let loc = match loc with None -> State.get_loc_exn () | Some loc -> loc in
|
||||
let ltr = match ltr with None -> State.get_loc_trace () | Some ltr -> ltr in
|
||||
Reporting.log_issue_from_summary severity (Summary.get_attributes summary)
|
||||
summary.Summary.err_log ~node ~session ~loc ~ltr exn
|
||||
| None ->
|
||||
L.(die InternalError)
|
||||
"Trying to report error on procedure %a, but cannot because no summary exists for this \
|
||||
procedure. Did you mean to log the error on the caller of %a instead?"
|
||||
Procname.pp proc_name Procname.pp proc_name
|
||||
|
||||
|
||||
let log_error_using_state proc_desc err_log exn =
|
||||
if !BiabductionConfig.footprint then
|
||||
let node' =
|
||||
match State.get_node () with Some n -> n | None -> Procdesc.get_start_node proc_desc
|
||||
in
|
||||
let node = Errlog.BackendNode {node= node'} in
|
||||
let session = State.get_session () in
|
||||
let loc = match State.get_loc () with Some l -> l | None -> Procdesc.Node.get_loc node' in
|
||||
let ltr = State.get_loc_trace () in
|
||||
let attrs = Procdesc.get_attributes proc_desc in
|
||||
Reporting.log_issue_from_summary Exceptions.Error attrs err_log ~node ~session ~loc ~ltr exn
|
@ -0,0 +1,22 @@
|
||||
(*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*)
|
||||
|
||||
open! IStd
|
||||
|
||||
val log_error_using_state : Procdesc.t -> Errlog.t -> exn -> unit
|
||||
(** Add an error to the given summary using biabduction state. *)
|
||||
|
||||
val log_issue_deprecated_using_state :
|
||||
Exceptions.severity
|
||||
-> Procname.t
|
||||
-> ?node:Procdesc.Node.t
|
||||
-> ?loc:Location.t
|
||||
-> ?ltr:Errlog.loc_trace
|
||||
-> exn
|
||||
-> unit
|
||||
(** Report an issue in the given procedure using biabduction state. DEPRECATED as it can create race
|
||||
conditions between checkers. Use log_error_using_state instead *)
|
Loading…
Reference in new issue