From b49f39b80ef8600d23f515977aab944cbbe48b3c Mon Sep 17 00:00:00 2001 From: Sungkeun Cho Date: Fri, 20 Dec 2019 02:09:57 -0800 Subject: [PATCH] [cost] Add a cost model Reviewed By: jvillard Differential Revision: D19178193 fbshipit-source-id: 25510bca2 --- infer/src/checkers/costUtils.ml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/infer/src/checkers/costUtils.ml b/infer/src/checkers/costUtils.ml index 5f58e3c58..88de6a5f0 100644 --- a/infer/src/checkers/costUtils.ml +++ b/infer/src/checkers/costUtils.ml @@ -11,6 +11,11 @@ open BufferOverrunUtils.ModelEnv type model = model_env -> ret:Ident.t * Typ.t -> BufferOverrunDomain.Mem.t -> BasicCost.t +let unit_cost_of ~of_function loc = + Bounds.NonNegativeBound.of_modeled_function of_function loc Bounds.Bound.one + |> BasicCost.of_non_negative_bound ~degree_kind:Polynomials.DegreeKind.Linear + + let of_itv ~(itv : Itv.t) ~degree_kind ~of_function loc = let upper_bound = match itv with Bottom -> Bounds.Bound.pinf | NonBottom itv_pure -> Itv.ItvPure.ub itv_pure