@@ -41,6 +41,10 @@ let int_of_scalar ?(scalewith=Z.one) ?round (scalar: Scalar.t) =
4141 | _ ->
4242 failwith (" int_of_scalar: unsupported: " ^ Scalar. show scalar)
4343
44+ let int_of_coeff ?scalewith ?round (coeff : Coeff.union_5 ) =
45+ match coeff with
46+ | Scalar scalar -> int_of_scalar ?scalewith ?round scalar
47+ | Interval _ -> None
4448
4549module type ConvertArg =
4650sig
@@ -272,27 +276,24 @@ struct
272276
273277 (* * Returned boolean indicates whether returned expression should be negated. *)
274278 let coeff_to_const ~scalewith (c :Coeff.union_5 ) =
275- match c with
276- | Scalar c ->
277- (match int_of_scalar ?scalewith c with
278- | Some i ->
279- let ci,truncation = truncateCilint ILongLong i in
280- if truncation = NoTruncation then
281- if Z. compare i Z. zero > = 0 then
282- false , Const (CInt (i,ILongLong ,None ))
283- else
284- (* attempt to negate if that does not cause an overflow *)
285- let cneg, truncation = truncateCilint ILongLong (Z. neg i) in
286- if truncation = NoTruncation then
287- true , Const (CInt ((Z. neg i),ILongLong ,None ))
288- else
289- false , Const (CInt (i,ILongLong ,None ))
290- else
291- raise Unsupported_Linexpr1
292- | None ->
293- M. warn ~category: Analyzer " Invariant Apron: coefficient is not int: %a" Scalar. pretty c;
294- raise Unsupported_Linexpr1 )
295- | _ -> raise Unsupported_Linexpr1
279+ match int_of_coeff ?scalewith c with
280+ | Some i ->
281+ let ci,truncation = truncateCilint ILongLong i in
282+ if truncation = NoTruncation then
283+ if Z. compare i Z. zero > = 0 then
284+ false , Const (CInt (i,ILongLong ,None ))
285+ else
286+ (* attempt to negate if that does not cause an overflow *)
287+ let cneg, truncation = truncateCilint ILongLong (Z. neg i) in
288+ if truncation = NoTruncation then
289+ true , Const (CInt ((Z. neg i),ILongLong ,None ))
290+ else
291+ false , Const (CInt (i,ILongLong ,None ))
292+ else
293+ raise Unsupported_Linexpr1
294+ | None ->
295+ M. warn ~category: Analyzer " Invariant Apron: coefficient is not int: %a" Coeff. pretty c;
296+ raise Unsupported_Linexpr1
296297
297298 (* * Returned boolean indicates whether returned expression should be negated. *)
298299 let cil_exp_of_linexpr1_term ~scalewith (c : Coeff.t ) v =
0 commit comments