diff --git a/infer/src/IR/Errlog.ml b/infer/src/IR/Errlog.ml index 881850e8e..a0898ac4f 100644 --- a/infer/src/IR/Errlog.ml +++ b/infer/src/IR/Errlog.ml @@ -60,7 +60,9 @@ 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: Procdesc.NodeKey.t} +type node_id_key = + | FrontendNode of {node_key: Procdesc.NodeKey.t} + | BackendNode of {node_id: Procdesc.Node.id; node_key: Procdesc.NodeKey.t} type err_key = { severity: Exceptions.severity @@ -171,8 +173,15 @@ let pp_warnings fmt (errlog: t) = let pp_html source path_to_root fmt (errlog: t) = let pp_eds fmt err_datas = let pp_nodeid_session_loc fmt err_data = + let node_id = + match err_data.node_id_key with + | FrontendNode _ -> + 0 + | BackendNode {node_id} -> + (node_id :> int) + in Io_infer.Html.pp_session_link source path_to_root fmt - (err_data.node_id_key.node_id, err_data.session, err_data.loc.Location.line) + (node_id, err_data.session, err_data.loc.Location.line) in ErrDataSet.iter (pp_nodeid_session_loc fmt) err_datas in diff --git a/infer/src/IR/Errlog.mli b/infer/src/IR/Errlog.mli index 9ecc02936..b83080564 100644 --- a/infer/src/IR/Errlog.mli +++ b/infer/src/IR/Errlog.mli @@ -34,7 +34,9 @@ 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: Procdesc.NodeKey.t} +type node_id_key = + | FrontendNode of {node_key: Procdesc.NodeKey.t} + | BackendNode of {node_id: Procdesc.Node.id; node_key: Procdesc.NodeKey.t} type err_key = private { severity: Exceptions.severity diff --git a/infer/src/backend/InferPrint.ml b/infer/src/backend/InferPrint.ml index 4d99c8e1a..112cab1ea 100644 --- a/infer/src/backend/InferPrint.ml +++ b/infer/src/backend/InferPrint.ml @@ -301,6 +301,11 @@ module JsonIssuePrinter = MakeJsonListPrinter (struct | _ -> Typ.Procname.to_string proc_name in + let node_key = + match err_data.node_id_key with + | FrontendNode {node_key} | BackendNode {node_key} -> + Procdesc.NodeKey.to_string node_key + in let bug = { Jsonbug_j.bug_class= Exceptions.err_class_string err_data.err_class ; kind= severity @@ -315,7 +320,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 |> Procdesc.NodeKey.to_string + ; 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/backend/reporting.ml b/infer/src/backend/reporting.ml index 17064b131..317f303a9 100644 --- a/infer/src/backend/reporting.ml +++ b/infer/src/backend/reporting.ml @@ -22,7 +22,7 @@ let log_issue_from_errlog procname ~clang_method_kind severity err_log ~loc ~nod let log_frontend_issue procname severity errlog ~loc ~node_key ~ltr ~linters_def_file ~doc_url exn = - let node_id_key = {Errlog.node_id= 0; node_key} in + let node_id_key = Errlog.FrontendNode {node_key} in log_issue_from_errlog procname ~clang_method_kind:None severity errlog ~loc ~node_id_key ~ltr ~linters_def_file ~doc_url ~access:None ~extras:None exn diff --git a/infer/src/biabduction/State.ml b/infer/src/biabduction/State.ml index 720e3af80..c5c35aea6 100644 --- a/infer/src/biabduction/State.ml +++ b/infer/src/biabduction/State.ml @@ -165,8 +165,8 @@ let mk_find_duplicate_nodes : Procdesc.t -> Procdesc.Node.t -> Procdesc.NodeSet. let get_node_id () = Procdesc.Node.get_id !gs.last_node let get_node_id_key () = - { Errlog.node_id= (Procdesc.Node.get_id !gs.last_node :> int) - ; node_key= Procdesc.Node.compute_key !gs.last_node } + Errlog.BackendNode + {node_id= Procdesc.Node.get_id !gs.last_node; node_key= Procdesc.Node.compute_key !gs.last_node} let get_inst_update pos =