diff --git a/infer/src/IR/Errlog.ml b/infer/src/IR/Errlog.ml index 3c5171df2..881850e8e 100644 --- a/infer/src/IR/Errlog.ml +++ b/infer/src/IR/Errlog.ml @@ -60,7 +60,7 @@ let compute_local_exception_line loc_trace = List.fold_until ~init:(None, None) ~f:compute_local_exception_line ~finish:snd loc_trace -type node_id_key = {node_id: int; node_key: NodeKey.t} +type node_id_key = {node_id: int; node_key: Procdesc.NodeKey.t} type err_key = { severity: Exceptions.severity diff --git a/infer/src/IR/Errlog.mli b/infer/src/IR/Errlog.mli index 0c016c95d..9ecc02936 100644 --- a/infer/src/IR/Errlog.mli +++ b/infer/src/IR/Errlog.mli @@ -34,7 +34,7 @@ val compute_local_exception_line : loc_trace -> int option This extra information adds value to the report itself, and may avoid digging into the trace to understand the cause of the report. *) -type node_id_key = {node_id: int; node_key: NodeKey.t} +type node_id_key = {node_id: int; node_key: Procdesc.NodeKey.t} type err_key = private { severity: Exceptions.severity diff --git a/infer/src/IR/NodeKey.ml b/infer/src/IR/NodeKey.ml deleted file mode 100644 index 59d38737d..000000000 --- a/infer/src/IR/NodeKey.ml +++ /dev/null @@ -1,19 +0,0 @@ -(* - * Copyright (c) 2018-present, Facebook, Inc. - * - * 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 t = Caml.Digest.t - -let to_string = Caml.Digest.to_hex - -let compute node ~simple_key ~succs ~preds = - let v = (simple_key node, List.rev_map ~f:simple_key succs, List.rev_map ~f:simple_key preds) in - Utils.better_hash v - - -let of_frontend_node_key = Utils.better_hash diff --git a/infer/src/IR/NodeKey.mli b/infer/src/IR/NodeKey.mli deleted file mode 100644 index feab333ac..000000000 --- a/infer/src/IR/NodeKey.mli +++ /dev/null @@ -1,17 +0,0 @@ -(* - * Copyright (c) 2018-present, Facebook, Inc. - * - * 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 t - -val to_string : t -> string - -val compute : - 'node -> simple_key:('node -> 'simple_key) -> succs:'node list -> preds:'node list -> t - -val of_frontend_node_key : string -> t diff --git a/infer/src/IR/Procdesc.ml b/infer/src/IR/Procdesc.ml index 1c179ded3..abac595f5 100644 --- a/infer/src/IR/Procdesc.ml +++ b/infer/src/IR/Procdesc.ml @@ -11,6 +11,21 @@ module Hashtbl = Caml.Hashtbl module L = Logging module F = Format +module NodeKey = struct + type t = Caml.Digest.t + + let to_string = Caml.Digest.to_hex + + let compute node ~simple_key ~succs ~preds = + let v = + (simple_key node, List.rev_map ~f:simple_key succs, List.rev_map ~f:simple_key preds) + in + Utils.better_hash v + + + let of_frontend_node_key = Utils.better_hash +end + (* =============== START of module Node =============== *) module Node = struct type id = int [@@deriving compare] diff --git a/infer/src/IR/Procdesc.mli b/infer/src/IR/Procdesc.mli index b9693edd5..b234a961b 100644 --- a/infer/src/IR/Procdesc.mli +++ b/infer/src/IR/Procdesc.mli @@ -8,6 +8,14 @@ open! IStd +module NodeKey : sig + type t + + val to_string : t -> string + + val of_frontend_node_key : string -> t +end + (** node of the control flow graph *) module Node : sig (** type of nodes *) diff --git a/infer/src/backend/InferPrint.ml b/infer/src/backend/InferPrint.ml index 26db0fab2..4d99c8e1a 100644 --- a/infer/src/backend/InferPrint.ml +++ b/infer/src/backend/InferPrint.ml @@ -315,7 +315,7 @@ module JsonIssuePrinter = MakeJsonListPrinter (struct ; procedure_start_line ; file ; bug_trace= loc_trace_to_jsonbug_record err_data.loc_trace err_key.severity - ; node_key= err_data.node_id_key.node_key |> NodeKey.to_string + ; node_key= err_data.node_id_key.node_key |> Procdesc.NodeKey.to_string ; key= compute_key bug_type proc_name file ; hash= compute_hash severity bug_type proc_name file qualifier ; dotty= error_desc_to_dotty_string err_key.err_desc diff --git a/infer/src/clang/cFrontend_errors.ml b/infer/src/clang/cFrontend_errors.ml index 6ceb37b63..10d972762 100644 --- a/infer/src/clang/cFrontend_errors.ml +++ b/infer/src/clang/cFrontend_errors.ml @@ -456,7 +456,7 @@ let log_frontend_issue method_decl_opt (node: Ctl_parser_types.ast_node) | Stmt st -> CAst_utils.generate_key_stmt st in - let node_key = NodeKey.of_frontend_node_key key_str in + let node_key = Procdesc.NodeKey.of_frontend_node_key key_str in Reporting.log_issue_from_errlog procname issue_desc.severity errlog exn ~loc:issue_desc.loc ~ltr:trace ~node_id_key:{Errlog.node_id= 0; node_key} ~linters_def_file ~doc_url:issue_desc.doc_url