From 2f69191c7e087dd09fcc6ee49d27f63988e9d8a2 Mon Sep 17 00:00:00 2001 From: Sam Blackshear Date: Wed, 18 Jan 2017 18:47:21 -0800 Subject: [PATCH] [backend] expose underlying Procdesc.Node from ProcCFG nodes Reviewed By: jeremydubreil Differential Revision: D4432566 fbshipit-source-id: 00530b9 --- infer/src/backend/preanal.ml | 2 +- infer/src/checkers/procCfg.ml | 8 ++++---- infer/src/checkers/procCfg.mli | 2 +- infer/src/unit/procCfgTests.ml | 4 ++-- infer/src/unit/schedulerTests.ml | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/infer/src/backend/preanal.ml b/infer/src/backend/preanal.ml index 9acb3754a..498035e67 100644 --- a/infer/src/backend/preanal.ml +++ b/infer/src/backend/preanal.ml @@ -115,7 +115,7 @@ module NullifyTransferFunctions = struct type extras = LivenessAnalysis.invariant_map let postprocess ((reaching_defs, _) as astate) node { ProcData.extras; } = - let node_id = (CFG.underlying_id node), ProcCfg.Node_index in + let node_id = Procdesc.Node.get_id (CFG.underlying_node node), ProcCfg.Node_index in match LivenessAnalysis.extract_state node_id extras with (* note: because the analysis is backward, post and pre are reversed *) | Some { AbstractInterpreter.post = live_before; pre = live_after; } -> diff --git a/infer/src/checkers/procCfg.ml b/infer/src/checkers/procCfg.ml index 0556cdeee..6ff1ccdb9 100644 --- a/infer/src/checkers/procCfg.ml +++ b/infer/src/checkers/procCfg.ml @@ -24,7 +24,7 @@ module type Node = sig val kind : t -> Procdesc.Node.nodekind val id : t -> id val loc : t -> Location.t - val underlying_id : t -> Procdesc.Node.id + val underlying_node : t -> Procdesc.Node.t val compare_id : id -> id -> int val pp_id : F.formatter -> id -> unit end @@ -36,7 +36,7 @@ module DefaultNode = struct let kind = Procdesc.Node.get_kind let id = Procdesc.Node.get_id let loc = Procdesc.Node.get_loc - let underlying_id = id + let underlying_node t = t let compare_id = Procdesc.Node.compare_id let pp_id = Procdesc.Node.pp_id end @@ -47,9 +47,9 @@ module InstrNode = struct let kind = Procdesc.Node.get_kind - let underlying_id t = Procdesc.Node.get_id t + let underlying_node t = t - let id t = underlying_id t, Node_index + let id t = Procdesc.Node.get_id (underlying_node t), Node_index let loc t = Procdesc.Node.get_loc t diff --git a/infer/src/checkers/procCfg.mli b/infer/src/checkers/procCfg.mli index d29bd4360..499a7f840 100644 --- a/infer/src/checkers/procCfg.mli +++ b/infer/src/checkers/procCfg.mli @@ -22,7 +22,7 @@ module type Node = sig val kind : t -> Procdesc.Node.nodekind val id : t -> id val loc : t -> Location.t - val underlying_id : t -> Procdesc.Node.id + val underlying_node : t -> Procdesc.Node.t val compare_id : id -> id -> int val pp_id : Format.formatter -> id -> unit end diff --git a/infer/src/unit/procCfgTests.ml b/infer/src/unit/procCfgTests.ml index 8318d030f..a5269e17a 100644 --- a/infer/src/unit/procCfgTests.ml +++ b/infer/src/unit/procCfgTests.ml @@ -95,8 +95,8 @@ let tests = | _ -> assert_failure "Expected exactly two instructions with correct indices" end; assert_bool - "underlying_id should return id of underlying CFG type" - (BackwardInstrCfg.underlying_id n1 = BackwardCfg.id n1) in + "underlying_node should return node of underlying CFG type" + (Procdesc.Node.get_id (BackwardInstrCfg.underlying_node n1) = BackwardCfg.id n1) in "instr_test">::instr_test_ in let graph_tests = [ diff --git a/infer/src/unit/schedulerTests.ml b/infer/src/unit/schedulerTests.ml index df4cf78b5..091711488 100644 --- a/infer/src/unit/schedulerTests.ml +++ b/infer/src/unit/schedulerTests.ml @@ -23,7 +23,7 @@ module MockNode = struct let to_instr_nodes _ = assert false let id n = n let loc _ = assert false - let underlying_id _ = assert false + let underlying_node _ = assert false let kind _ = Procdesc.Node.Stmt_node "" let compare_id = Int.compare let pp_id fmt i =