From ec9f4c2c6a3611c3b62bf89a4cdbe4237c2d14a2 Mon Sep 17 00:00:00 2001 From: Mehdi Bouaziz Date: Wed, 5 Sep 2018 07:28:31 -0700 Subject: [PATCH] node_key: option type Reviewed By: jeremydubreil Differential Revision: D9633551 fbshipit-source-id: b80f38950 --- infer/src/IR/Errlog.ml | 8 ++++---- infer/src/IR/Errlog.mli | 2 +- infer/src/atd/jsonbug.atd | 3 +-- infer/src/backend/DifferentialFilters.ml | 5 +++-- infer/src/backend/InferPrint.ml | 2 +- infer/src/unit/DifferentialTestsUtils.ml | 2 +- 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/infer/src/IR/Errlog.ml b/infer/src/IR/Errlog.ml index b8b61e820..e7aa328ac 100644 --- a/infer/src/IR/Errlog.ml +++ b/infer/src/IR/Errlog.ml @@ -75,7 +75,7 @@ type err_key = (** Data associated to a specific error *) type err_data = { node_id: int - ; node_key: Procdesc.NodeKey.t + ; node_key: Procdesc.NodeKey.t option ; session: int ; loc: Location.t ; loc_in_ml_source: L.ocaml_pos option @@ -266,11 +266,11 @@ let log_issue procname ~clang_method_kind severity err_log ~loc ~node ~session ~ let node_id, node_key = match node with | UnknownNode -> - (0, Procdesc.NodeKey.dummy) + (0, Some Procdesc.NodeKey.dummy) | FrontendNode {node_key} -> - (0, node_key) + (0, Some node_key) | BackendNode {node} -> - ((Procdesc.Node.get_id node :> int), Procdesc.Node.compute_key node) + ((Procdesc.Node.get_id node :> int), Some (Procdesc.Node.compute_key node)) in let err_data = { node_id diff --git a/infer/src/IR/Errlog.mli b/infer/src/IR/Errlog.mli index 270c914a7..513525543 100644 --- a/infer/src/IR/Errlog.mli +++ b/infer/src/IR/Errlog.mli @@ -49,7 +49,7 @@ type err_key = private (** Data associated to a specific error *) type err_data = private { node_id: int - ; node_key: Procdesc.NodeKey.t + ; node_key: Procdesc.NodeKey.t option ; session: int ; loc: Location.t ; loc_in_ml_source: Logging.ocaml_pos option diff --git a/infer/src/atd/jsonbug.atd b/infer/src/atd/jsonbug.atd index fd47529ea..f57008e92 100644 --- a/infer/src/atd/jsonbug.atd +++ b/infer/src/atd/jsonbug.atd @@ -32,7 +32,7 @@ type jsonbug = { file : string; bug_trace : json_trace_item list; key : string; - node_key : string; + ?node_key : string option; hash : string; ?dotty : string option; ?infer_source_loc: loc option; @@ -57,4 +57,3 @@ type cost_item = { } type costs_report = cost_item list - diff --git a/infer/src/backend/DifferentialFilters.ml b/infer/src/backend/DifferentialFilters.ml index 3dad75718..800f0b472 100644 --- a/infer/src/backend/DifferentialFilters.ml +++ b/infer/src/backend/DifferentialFilters.ml @@ -118,7 +118,7 @@ let relative_complements ~compare ~pred l1 l2 = let skip_duplicated_types_on_filenames renamings (diff : Differential.t) : Differential.t = let compare (issue1, previous_file1) (issue2, previous_file2) = - [%compare: Caml.Digest.t * string * string] + [%compare: Caml.Digest.t option * string * string] (issue1.Jsonbug_t.node_key, issue1.Jsonbug_t.bug_type, previous_file1) (issue2.Jsonbug_t.node_key, issue2.Jsonbug_t.bug_type, previous_file2) in @@ -132,7 +132,8 @@ let skip_duplicated_types_on_filenames renamings (diff : Differential.t) : Diffe in let fixed_normalized = List.map diff.fixed ~f:(fun f -> (f, f.Jsonbug_t.file)) in let introduced_normalized', preexisting', fixed_normalized' = - relative_complements ~compare ~pred:(fun _ -> true) introduced_normalized fixed_normalized + let has_node_key ({Jsonbug_t.node_key}, _) = Option.is_some node_key in + relative_complements ~compare ~pred:has_node_key introduced_normalized fixed_normalized in let list_map_fst = List.map ~f:fst in ( list_map_fst introduced_normalized' diff --git a/infer/src/backend/InferPrint.ml b/infer/src/backend/InferPrint.ml index b632efafb..7c1223251 100644 --- a/infer/src/backend/InferPrint.ml +++ b/infer/src/backend/InferPrint.ml @@ -313,7 +313,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= Procdesc.NodeKey.to_string err_data.node_key + ; node_key= Option.map ~f:Procdesc.NodeKey.to_string err_data.node_key ; 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/unit/DifferentialTestsUtils.ml b/infer/src/unit/DifferentialTestsUtils.ml index bd3c5dd9b..a0d45dc6c 100644 --- a/infer/src/unit/DifferentialTestsUtils.ml +++ b/infer/src/unit/DifferentialTestsUtils.ml @@ -10,7 +10,7 @@ open! IStd let create_fake_jsonbug ?(kind = "kind") ?(bug_type = "bug_type") ?(qualifier = "qualifier") ?(severity = "severity") ?(visibility = "visibility") ?(line = 1) ?(column = 1) ?(procedure = "procedure") ?(procedure_start_line = 1) ?(file = "file/at/a/certain/path.java") - ?(bug_trace = []) ?(node_key = "File|method|TYPE") ?(key = "1234") ?(hash = "1") + ?(bug_trace = []) ?(key = "File|method|TYPE") ?(node_key = Some "1234") ?(hash = "1") ?(dotty = None) ?(infer_source_loc = None) ?(linters_def_file = Some "file/at/certain/path.al") ?doc_url () : Jsonbug_t.jsonbug = { kind