diff --git a/infer/src/bufferoverrun/absLoc.ml b/infer/src/bufferoverrun/absLoc.ml index ff72ae746..2aca99e2e 100644 --- a/infer/src/bufferoverrun/absLoc.ml +++ b/infer/src/bufferoverrun/absLoc.ml @@ -12,20 +12,24 @@ open! IStd module F = Format module Allocsite = struct - include String + type t = Unknown | Known of {proc_name: string; node_hash: int; inst_num: int; dimension: int} + [@@deriving compare] + + let pp fmt = function + | Unknown -> + F.fprintf fmt "Unknown" + | Known {proc_name : string; node_hash : int; inst_num : int; dimension : int} -> + F.fprintf fmt "%s-%d-%d-%d" proc_name node_hash inst_num dimension - let pp fmt s = Format.pp_print_string fmt s + + let to_string x = F.asprintf "%a" pp x let make : Typ.Procname.t -> node_hash:int -> inst_num:int -> dimension:int -> t = fun proc_name ~node_hash ~inst_num ~dimension -> - let proc_name = Typ.Procname.to_string proc_name in - let node_num = string_of_int node_hash in - let inst_num = string_of_int inst_num in - let dimension = string_of_int dimension in - proc_name ^ "-" ^ node_num ^ "-" ^ inst_num ^ "-" ^ dimension + Known {proc_name= Typ.Procname.to_string proc_name; node_hash; inst_num; dimension} - let unknown = "Unknown" + let unknown = Unknown end module Loc = struct