diff --git a/infer/src/bufferoverrun/bufferOverrunChecker.ml b/infer/src/bufferoverrun/bufferOverrunChecker.ml index d133d0f9e..ffa43f8c7 100644 --- a/infer/src/bufferoverrun/bufferOverrunChecker.ml +++ b/infer/src/bufferoverrun/bufferOverrunChecker.ml @@ -625,7 +625,7 @@ module Report = struct | None -> () | Some bucket when Typ.Procname.equal pname caller_pname - -> let description = Dom.Condition.to_string cond in + -> let description = Dom.Condition.description cond in let error_desc = Localise.desc_buffer_overrun bucket description in let exn = Exceptions.Checkers (IssueType.buffer_overrun.unique_id, error_desc) in let trace = diff --git a/infer/src/bufferoverrun/bufferOverrunDomain.ml b/infer/src/bufferoverrun/bufferOverrunDomain.ml index 147e8cce4..9c2a956c2 100644 --- a/infer/src/bufferoverrun/bufferOverrunDomain.ml +++ b/infer/src/bufferoverrun/bufferOverrunDomain.ml @@ -125,19 +125,22 @@ module Condition = struct let invalid : t -> bool = fun x -> Itv.invalid x.idx || Itv.invalid x.size - let to_string : t -> string = - fun c -> - let c = set_size_pos c in - "Offset: " ^ Itv.to_string c.idx ^ " Size: " ^ Itv.to_string c.size - ^ + let pp_trace : F.formatter -> t -> unit = + fun fmt c -> match c.cond_trace with | Inter (_, pname, _) when Config.bo_debug >= 1 || not (SourceFile.is_cpp_model c.loc.Location.file) - -> let loc = pp_location F.str_formatter c ; F.flush_str_formatter () in - " @ " ^ loc ^ " by call " ^ MF.monospaced_to_string (Typ.Procname.to_string pname ^ "()") - ^ " " + -> F.fprintf fmt " %@ %a by call %a " pp_location c MF.pp_monospaced + (Typ.Procname.to_string pname ^ "()") | _ - -> "" + -> () + + let pp_description : F.formatter -> t -> unit = + fun fmt c -> + let c = set_size_pos c in + F.fprintf fmt "Offset: %a Size: %a%a" Itv.pp c.idx Itv.pp c.size pp_trace c + + let description : t -> string = fun c -> Format.asprintf "%a" pp_description c let subst : t -> Itv.Bound.t Itv.SubstMap.t * TraceSet.t Itv.SubstMap.t -> Typ.Procname.t