diff --git a/infer/src/checkers/procCfg.ml b/infer/src/checkers/procCfg.ml index d1398f946..37999123c 100644 --- a/infer/src/checkers/procCfg.ml +++ b/infer/src/checkers/procCfg.ml @@ -15,7 +15,7 @@ module F = Format file). Defines useful wrappers that allows us to do tricks like turn a forward cfg into a backward one, or view a cfg as having a single instruction per node. *) -type index = Node_index | Instr_index of int +type index = Node_index | Instr_index of int [@@deriving compare] module type Node = sig type t @@ -25,7 +25,7 @@ module type Node = sig val id : t -> id val loc : t -> Location.t val underlying_id : t -> Procdesc.Node.id - val id_compare : id -> id -> int + val compare_id : id -> id -> int val pp_id : F.formatter -> id -> unit end @@ -37,7 +37,7 @@ module DefaultNode = struct let id = Procdesc.Node.get_id let loc = Procdesc.Node.get_loc let underlying_id = id - let id_compare = Procdesc.Node.compare_id + let compare_id = Procdesc.Node.compare_id let pp_id = Procdesc.Node.pp_id end @@ -53,16 +53,12 @@ module InstrNode = struct let loc t = Procdesc.Node.get_loc t - let index_compare index1 index2 = match index1, index2 with - | Node_index, Node_index -> 0 - | Instr_index i1, Instr_index i2 -> int_compare i1 i2 - | Node_index, Instr_index _ -> 1 - | Instr_index _, Node_index -> -1 + let compare_index = compare_index - let id_compare (id1, index1) (id2, index2) = + let compare_id (id1, index1) (id2, index2) = let n = Procdesc.Node.compare_id id1 id2 in if n <> 0 then n - else index_compare index1 index2 + else compare_index index1 index2 let pp_id fmt (id, index) = match index with | Node_index -> Procdesc.Node.pp_id fmt id @@ -234,10 +230,10 @@ end module NodeIdMap (CFG : S) = Map.Make(struct type t = CFG.id - let compare = CFG.id_compare + let compare = CFG.compare_id end) module NodeIdSet (CFG : S) = Set.Make(struct type t = CFG.id - let compare = CFG.id_compare + let compare = CFG.compare_id end) diff --git a/infer/src/checkers/procCfg.mli b/infer/src/checkers/procCfg.mli index b1544e7ef..9070c83d9 100644 --- a/infer/src/checkers/procCfg.mli +++ b/infer/src/checkers/procCfg.mli @@ -21,7 +21,7 @@ module type Node = sig val id : t -> id val loc : t -> Location.t val underlying_id : t -> Procdesc.Node.id - val id_compare : id -> id -> int + val compare_id : id -> id -> int val pp_id : Format.formatter -> id -> unit end diff --git a/infer/src/unit/schedulerTests.ml b/infer/src/unit/schedulerTests.ml index 805bf58bd..988b97d4f 100644 --- a/infer/src/unit/schedulerTests.ml +++ b/infer/src/unit/schedulerTests.ml @@ -25,7 +25,7 @@ module MockNode = struct let loc _ = assert false let underlying_id _ = assert false let kind _ = Procdesc.Node.Stmt_node "" - let id_compare = int_compare + let compare_id = int_compare let pp_id fmt i = F.fprintf fmt "%i" i end @@ -35,13 +35,13 @@ module MockProcCfg = struct include (MockNode : module type of MockNode with type t := node) type t = (node * node list) list - let id_compare = int_compare + let compare_id = int_compare let succs t n = try let node_id = id n in IList.find - (fun (node, _) -> id_compare (id node) node_id = 0) + (fun (node, _) -> compare_id (id node) node_id = 0) t |> snd with Not_found -> [] @@ -51,7 +51,7 @@ module MockProcCfg = struct let node_id = id n in IList.filter (fun (_, succs) -> - IList.exists (fun node -> id_compare (id node) node_id = 0) succs) + IList.exists (fun node -> compare_id (id node) node_id = 0) succs) t |> IList.map fst with Not_found -> []