Skip to content

Commit ce62c97

Browse files
committed
Suppress overflow warnings from IntDomTuple.of_const
These should currently never warn anyway, but suppressing them will allow avoiding unnecessary successful checks.
1 parent 77d0264 commit ce62c97

File tree

4 files changed

+7
-5
lines changed

4 files changed

+7
-5
lines changed

src/cdomain/value/cdomains/int/intDomTuple.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ module IntDomTupleImpl = struct
119119
let bot_of = create { fi = fun (type a) (module I:SOverflow with type t = a) -> I.bot_of }
120120
let of_bool ik = create { fi = fun (type a) (module I:SOverflow with type t = a) -> I.of_bool ik }
121121
let of_excl_list ik = create2 { fi2 = fun (type a) (module I:SOverflow with type t = a and type int_t = int_t) -> I.of_excl_list ik}
122-
let of_int ik = create2_ovc ik { fi2_ovc = fun (type a) (module I:SOverflow with type t = a and type int_t = int_t) -> I.of_int ik }
122+
let of_int ?(suppress_ovwarn=false) ik = create2_ovc ~suppress_ovwarn ik { fi2_ovc = fun (type a) (module I:SOverflow with type t = a and type int_t = int_t) -> I.of_int ik }
123123
let starting ?(suppress_ovwarn=false) ik = create2_ovc ~suppress_ovwarn ik { fi2_ovc = fun (type a) (module I:SOverflow with type t = a and type int_t = int_t) -> I.starting ik }
124124
let ending ?(suppress_ovwarn=false) ik = create2_ovc ~suppress_ovwarn ik { fi2_ovc = fun (type a) (module I:SOverflow with type t = a and type int_t = int_t) -> I.ending ik }
125125
let of_interval ?(suppress_ovwarn=false) ik = create2_ovc ~suppress_ovwarn ik { fi2_ovc = fun (type a) (module I:SOverflow with type t = a and type int_t = int_t) -> I.of_interval ik }
@@ -558,4 +558,4 @@ struct
558558
let no_bitfield (x: I.t) = {x with v = IntDomTupleImpl.no_bitfield x.v}
559559
end
560560

561-
let of_const (i, ik, str) = IntDomTuple.of_int ik i
561+
let of_const (i, ik, str) = IntDomTuple.of_int ~suppress_ovwarn:true ik i

src/cdomain/value/cdomains/intDomain0.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ struct
166166
let tag x = I.tag x.v
167167
let arbitrary ik = failwith @@ "Arbitrary not implement for " ^ (name ()) ^ "."
168168
let to_int x = I.to_int x.v
169-
let of_int ikind x = { v = I.of_int ikind x; ikind}
169+
let of_int ?(suppress_ovwarn=false) ikind x = { v = I.of_int ~suppress_ovwarn ikind x; ikind}
170170
let equal_to i x = I.equal_to i x.v
171171
let to_bool x = I.to_bool x.v
172172
let of_bool ikind b = { v = I.of_bool ikind b; ikind}
@@ -480,7 +480,7 @@ module SOverflowUnlifter (D : SOverflow) : S2 with type int_t = D.int_t and type
480480

481481
let cast_to ?suppress_ovwarn ?torg ?no_ov ik x = fst @@ D.cast_to ?torg ?no_ov ik x
482482

483-
let of_int ik x = fst @@ D.of_int ik x
483+
let of_int ?suppress_ovwarn ik x = fst @@ D.of_int ik x
484484

485485
let of_interval ?suppress_ovwarn ik x = fst @@ D.of_interval ik x
486486

src/cdomain/value/cdomains/intDomain_intf.ml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,7 @@ module type S2 =
279279
sig
280280
include S
281281

282+
val of_int: ?suppress_ovwarn:bool -> Cil.ikind -> int_t -> t
282283
val starting : ?suppress_ovwarn:bool -> Cil.ikind -> int_t -> t
283284
val ending : ?suppress_ovwarn:bool -> Cil.ikind -> int_t -> t
284285
val of_interval: ?suppress_ovwarn:bool -> Cil.ikind -> int_t * int_t -> t
@@ -321,7 +322,7 @@ sig
321322
include Lattice.Top with type t := t
322323
include Arith with type t:=t
323324

324-
val of_int: Cil.ikind -> int_t -> t
325+
val of_int: ?suppress_ovwarn:bool -> Cil.ikind -> int_t -> t
325326
(** Transform an integer literal to your internal domain representation with the specified ikind. *)
326327

327328
val of_bool: Cil.ikind -> bool -> t

src/domains/intDomainProperties.ml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ module MakeS2 (I: S): S2 =
2929
struct
3030
include I
3131

32+
let of_int ?suppress_ovwarn ik x = of_int ik x
3233
let starting ?suppress_ovwarn ik x = starting ik x
3334
let ending ?suppress_ovwarn ik x = ending ik x
3435
let of_interval ?suppress_ovwarn ik x = of_interval ik x

0 commit comments

Comments
 (0)