Skip to content

Commit 2a85624

Browse files
authored
Merge pull request #1815 from goblint/suppress_ovwarn
Remove some unnecessary `suppress_ovwarn` arguments
2 parents eba7b0f + 4fb4abe commit 2a85624

File tree

14 files changed

+100
-79
lines changed

14 files changed

+100
-79
lines changed

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

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ module BitfieldFunctor (Ints_t : IntOps.IntOps): Bitfield_SOverflow with type in
253253
let newo = o &: (Ints_t.of_bigint max_ik) in
254254
(newz,newo)
255255

256-
let norm ?(suppress_ovwarn=false) ?(ov=false) ik (z,o) =
256+
let norm ?(ov=false) ik (z,o) =
257257
if BArith.is_invalid (z,o) then
258258
bot ()
259259
else
@@ -263,7 +263,7 @@ module BitfieldFunctor (Ints_t : IntOps.IntOps): Bitfield_SOverflow with type in
263263
else
264264
top_of ik
265265

266-
let cast_to ?(suppress_ovwarn=false) ?torg ?(no_ov=false) ik (z,o) =
266+
let cast_to ?torg ?(no_ov=false) ik (z,o) =
267267
let (min_ik, max_ik) = Size.range ik in
268268
let (underflow, overflow) = match torg with
269269
| None -> (false, false) (* ik does not change *)
@@ -278,10 +278,10 @@ module BitfieldFunctor (Ints_t : IntOps.IntOps): Bitfield_SOverflow with type in
278278
let overflow = (((!:(Ints_t.of_bigint max_ik)) &: o) <>: Ints_t.zero) && isPos in
279279
(underflow, overflow)
280280
in
281-
let overflow_info = if suppress_ovwarn then {underflow=false; overflow=false} else {underflow=underflow; overflow=overflow} in
282-
(norm ~suppress_ovwarn:(suppress_ovwarn) ~ov:(underflow || overflow) ik (z,o), overflow_info)
281+
let overflow_info = {underflow; overflow} in
282+
(norm ~ov:(underflow || overflow) ik (z,o), overflow_info)
283283

284-
let cast_to ?(suppress_ovwarn=false) ?torg ?(no_ov=false) ik (z,o) =
284+
let cast_to ?torg ?(no_ov=false) ik (z,o) =
285285
if ik = GoblintCil.IBool then (
286286
let may_zero =
287287
if Ints_t.equal z BArith.one_mask then (* zero bit may be in every position (one_mask) *)
@@ -298,7 +298,7 @@ module BitfieldFunctor (Ints_t : IntOps.IntOps): Bitfield_SOverflow with type in
298298
(BArith.join may_zero may_one, {underflow=false; overflow=false})
299299
)
300300
else
301-
cast_to ~suppress_ovwarn ?torg ~no_ov ik (z,o)
301+
cast_to ?torg ~no_ov ik (z,o)
302302

303303
let join ik b1 b2 = norm ik @@ (BArith.join b1 b2)
304304

@@ -335,7 +335,7 @@ module BitfieldFunctor (Ints_t : IntOps.IntOps): Bitfield_SOverflow with type in
335335

336336
type bit_status = Zero | One | Top
337337

338-
let of_interval ?(suppress_ovwarn=false) ik (x,y) =
338+
let of_interval ik (x,y) =
339339
let (min_ik, max_ik) = Size.range ik in
340340
let startv = Ints_t.max x (Ints_t.of_bigint min_ik) in
341341
let endv= Ints_t.min y (Ints_t.of_bigint max_ik) in
@@ -638,13 +638,13 @@ module BitfieldFunctor (Ints_t : IntOps.IntOps): Bitfield_SOverflow with type in
638638
let exp1 = Invariant.of_exp (BinOp (Eq, (BinOp (BAnd, e, def1, TInt(ik,[]))), def1, intType)) in
639639
Invariant.meet exp0 exp1
640640

641-
let starting ?(suppress_ovwarn=false) ik n =
641+
let starting ik n =
642642
let (min_ik, max_ik) = Size.range ik in
643-
of_interval ~suppress_ovwarn ik (n, Ints_t.of_bigint max_ik)
643+
of_interval ik (n, Ints_t.of_bigint max_ik)
644644

645-
let ending ?(suppress_ovwarn=false) ik n =
645+
let ending ik n =
646646
let (min_ik, max_ik) = Size.range ik in
647-
of_interval ~suppress_ovwarn ik (Ints_t.of_bigint min_ik, n)
647+
of_interval ik (Ints_t.of_bigint min_ik, n)
648648

649649
(* Refinements *)
650650

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,9 +133,10 @@ struct
133133
| x when equal zero x -> Some false
134134
| x -> if leq zero x then None else Some true
135135

136-
let starting ?(suppress_ovwarn=false) ik n = top()
136+
let starting ik n = top()
137137

138138
let ending = starting
139+
let of_interval ik x = of_interval ik x (* cast away optional suppress_ovwarn argument *)
139140

140141
let of_congruence ik (c,m) = normalize ik @@ Some(c,m)
141142

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -298,12 +298,12 @@ struct
298298
| _ -> None
299299
let top_bool = `Excluded (S.empty (), R.of_interval range_ikind (0L, 1L))
300300

301-
let of_interval ?(suppress_ovwarn=false) ik (x,y) =
301+
let of_interval ik (x,y) =
302302
if Z.compare x y = 0 then
303303
of_int ik x
304304
else
305305
let a, b = Size.min_range_sign_agnostic x, Size.min_range_sign_agnostic y in
306-
let r = R.join (R.of_interval ~suppress_ovwarn range_ikind a) (R.of_interval ~suppress_ovwarn range_ikind b) in
306+
let r = R.join (R.of_interval range_ikind a) (R.of_interval range_ikind b) in
307307
let ex = if Z.gt x Z.zero || Z.lt y Z.zero then S.singleton Z.zero else S.empty () in
308308
norm ik @@ (`Excluded (ex, r))
309309

@@ -318,13 +318,13 @@ struct
318318
let ik_mask = snd (Size.range ik) in
319319
(one_mask, ik_mask)
320320

321-
let starting ?(suppress_ovwarn=false) ikind x =
321+
let starting ikind x =
322322
let _,u_ik = Size.range ikind in
323-
of_interval ~suppress_ovwarn ikind (x, u_ik)
323+
of_interval ikind (x, u_ik)
324324

325-
let ending ?(suppress_ovwarn=false) ikind x =
325+
let ending ikind x =
326326
let l_ik,_ = Size.range ikind in
327-
of_interval ~suppress_ovwarn ikind (l_ik, x)
327+
of_interval ikind (l_ik, x)
328328

329329
let of_excl_list t l =
330330
let r = size t in (* elements in l are excluded from the full range of t! *)

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -119,12 +119,12 @@ module Enums : S with type int_t = Z.t = struct
119119

120120
let of_int ikind x = cast_to ikind (Inc (BISet.singleton x))
121121

122-
let of_interval ?(suppress_ovwarn=false) ik (x, y) =
122+
let of_interval ik (x, y) =
123123
if Z.compare x y = 0 then
124124
of_int ik x
125125
else
126126
let a, b = Size.min_range_sign_agnostic x, Size.min_range_sign_agnostic y in
127-
let r = R.join (R.of_interval ~suppress_ovwarn range_ikind a) (R.of_interval ~suppress_ovwarn range_ikind b) in
127+
let r = R.join (R.of_interval range_ikind a) (R.of_interval range_ikind b) in
128128
let ex = if Z.gt x Z.zero || Z.lt y Z.zero then BISet.singleton Z.zero else BISet.empty () in
129129
norm ik @@ (Exc (ex, r))
130130

@@ -380,13 +380,13 @@ module Enums : S with type int_t = Z.t = struct
380380
| _ when Cil.isSigned ik -> (one_mask, one_mask)
381381
| _ -> (one_mask, ik_mask)
382382

383-
let starting ?(suppress_ovwarn=false) ikind x =
383+
let starting ikind x =
384384
let _,u_ik = Size.range ikind in
385-
of_interval ~suppress_ovwarn ikind (x, u_ik)
385+
of_interval ikind (x, u_ik)
386386

387-
let ending ?(suppress_ovwarn=false) ikind x =
387+
let ending ikind x =
388388
let l_ik,_ = Size.range ikind in
389-
of_interval ~suppress_ovwarn ikind (l_ik, x)
389+
of_interval ikind (l_ik, x)
390390

391391
let c_lognot ik x =
392392
if is_bot x

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -76,17 +76,17 @@ module IntDomTupleImpl = struct
7676
);
7777
no_ov
7878

79-
let create2_ovc ik r x ((p1, p2, p3, p4, p5, p6): int_precision) =
79+
let create2_ovc ?(suppress_ovwarn = false) ik r x ((p1, p2, p3, p4, p5, p6): int_precision) =
8080
let f b g = if b then Some (g x) else None in
8181
let map x = Option.map fst x in
8282
let intv = f p2 @@ r.fi2_ovc (module I2) in
8383
let intv_set = f p5 @@ r.fi2_ovc (module I5) in
8484
let bf = f p6 @@ r.fi2_ovc (module I6) in
85-
ignore (check_ov ~cast:false ik intv intv_set bf);
85+
ignore (check_ov ~suppress_ovwarn ~cast:false ik intv intv_set bf);
8686
map @@ f p1 @@ r.fi2_ovc (module I1), map @@ f p2 @@ r.fi2_ovc (module I2), map @@ f p3 @@ r.fi2_ovc (module I3), map @@ f p4 @@ r.fi2_ovc (module I4), map @@ f p5 @@ r.fi2_ovc (module I5) , map @@ f p6 @@ r.fi2_ovc (module I6)
8787

88-
let create2_ovc ik r x = (* use where values are introduced *)
89-
create2_ovc ik r x (int_precision_from_node_or_config ())
88+
let create2_ovc ?(suppress_ovwarn = false) ik r x = (* use where values are introduced *)
89+
create2_ovc ~suppress_ovwarn ik r x (int_precision_from_node_or_config ())
9090

9191

9292
let opt_map2 f ?no_ov =
@@ -120,9 +120,9 @@ module IntDomTupleImpl = struct
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}
122122
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 }
123-
let starting ?(suppress_ovwarn=false) ik = create2_ovc ik { fi2_ovc = fun (type a) (module I:SOverflow with type t = a and type int_t = int_t) -> I.starting ~suppress_ovwarn ik }
124-
let ending ?(suppress_ovwarn=false) ik = create2_ovc ik { fi2_ovc = fun (type a) (module I:SOverflow with type t = a and type int_t = int_t) -> I.ending ~suppress_ovwarn ik }
125-
let of_interval ?(suppress_ovwarn=false) ik = create2_ovc ik { fi2_ovc = fun (type a) (module I:SOverflow with type t = a and type int_t = int_t) -> I.of_interval ~suppress_ovwarn ik }
123+
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 }
124+
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 }
125+
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 }
126126
let of_congruence ik = create2 { fi2 = fun (type a) (module I:SOverflow with type t = a and type int_t = int_t) -> I.of_congruence ik }
127127
let of_bitfield ik = create2 { fi2 = fun (type a) (module I:SOverflow with type t = a and type int_t = int_t) -> I.of_bitfield ik }
128128

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

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,14 @@ struct
3232
| Some (a, b) ->
3333
if a = b && b = i then `Eq else if Ints_t.compare a i <= 0 && Ints_t.compare i b <=0 then `Top else `Neq
3434

35-
let norm ?(suppress_ovwarn=false) ?(cast=false) ik : (t -> t * overflow_info) = function None -> (None, {underflow=false; overflow=false}) | Some (x,y) ->
35+
let norm ?(cast=false) ik : (t -> t * overflow_info) = function None -> (None, {underflow=false; overflow=false}) | Some (x,y) ->
3636
if Ints_t.compare x y > 0 then
3737
(None,{underflow=false; overflow=false})
3838
else (
3939
let (min_ik, max_ik) = range ik in
4040
let underflow = Ints_t.compare min_ik x > 0 in
4141
let overflow = Ints_t.compare max_ik y < 0 in
42-
let ov_info = { underflow = underflow && not suppress_ovwarn; overflow = overflow && not suppress_ovwarn } in
42+
let ov_info = { underflow; overflow } in
4343
let v =
4444
if underflow || overflow then
4545
if should_wrap ik then (* could add [|| cast], but that's GCC implementation-defined behavior: https://gcc.gnu.org/onlinedocs/gcc/Integers-implementation.html#Integers-implementation *)
@@ -88,7 +88,7 @@ struct
8888

8989
(* TODO: change to_int signature so it returns a big_int *)
9090
let to_int x = Option.bind x (IArith.to_int)
91-
let of_interval ?(suppress_ovwarn=false) ik (x,y) = norm ~suppress_ovwarn ik @@ Some (x,y)
91+
let of_interval ik (x,y) = norm ik @@ Some (x,y)
9292

9393
let of_bitfield ik x =
9494
let min ik (z,o) =
@@ -129,17 +129,17 @@ struct
129129
| Some (l, u) when Ints_t.compare l Ints_t.zero = 0 && Ints_t.compare u Ints_t.zero = 0 -> Some false
130130
| x -> if leq zero x then None else Some true
131131

132-
let starting ?(suppress_ovwarn=false) ik n =
133-
norm ~suppress_ovwarn ik @@ Some (n, snd (range ik))
132+
let starting ik n =
133+
norm ik @@ Some (n, snd (range ik))
134134

135-
let ending ?(suppress_ovwarn=false) ik n =
136-
norm ~suppress_ovwarn ik @@ Some (fst (range ik), n)
135+
let ending ik n =
136+
norm ik @@ Some (fst (range ik), n)
137137

138138
(* TODO: change signature of maximal, minimal to return big_int*)
139139
let maximal = function None -> None | Some (x,y) -> Some y
140140
let minimal = function None -> None | Some (x,y) -> Some x
141141

142-
let cast_to ?(suppress_ovwarn=false) ?torg ?no_ov t = norm ~cast:true t (* norm does all overflow handling *)
142+
let cast_to ?torg ?no_ov t = norm ~cast:true t (* norm does all overflow handling *)
143143

144144
let widen ik x y =
145145
match x, y with
@@ -524,7 +524,7 @@ struct
524524
let l' = if Ints_t.equal l min_ik then l else shrink Ints_t.add l in
525525
let u' = if Ints_t.equal u max_ik then u else shrink Ints_t.sub u in
526526
let intv' = norm ik @@ Some (l', u') |> fst in
527-
let range = norm ~suppress_ovwarn:true ik (Some (Ints_t.of_bigint (Size.min_from_bit_range rl), Ints_t.of_bigint (Size.max_from_bit_range rh))) |> fst in
527+
let range = norm ik (Some (Ints_t.of_bigint (Size.min_from_bit_range rl), Ints_t.of_bigint (Size.max_from_bit_range rh))) |> fst in
528528
meet ik intv' range
529529

530530
let refine_with_incl_list ik (intv: t) (incl : (int_t list) option) : t =

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

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ struct
141141
| ys when List.for_all ((=) `Neq) ys -> `Neq
142142
| _ -> `Top
143143

144-
let norm_interval ?(suppress_ovwarn=false) ?(cast=false) ik (x,y) : t*overflow_info =
144+
let norm_interval ?(cast=false) ik (x,y) : t*overflow_info =
145145
if x >. y then
146146
([],{underflow=false; overflow=false})
147147
else
@@ -173,10 +173,10 @@ struct
173173
else
174174
[(x,y)]
175175
in
176-
if suppress_ovwarn then (v, {underflow=false; overflow=false}) else (v, {underflow; overflow})
176+
(v, {underflow; overflow})
177177

178-
let norm_intvs ?(suppress_ovwarn=false) ?(cast=false) (ik:ikind) (xs: t) : t*overflow_info =
179-
let res = List.map (norm_interval ~suppress_ovwarn ~cast ik) xs in
178+
let norm_intvs ?(cast=false) (ik:ikind) (xs: t) : t*overflow_info =
179+
let res = List.map (norm_interval ~cast ik) xs in
180180
let intvs = List.concat_map fst res in
181181
let underflow = List.exists (fun (_,{underflow; _}) -> underflow) res in
182182
let overflow = List.exists (fun (_,{overflow; _}) -> overflow) res in
@@ -249,7 +249,7 @@ struct
249249

250250
let of_bool _ = function true -> one | false -> zero
251251

252-
let of_interval ?(suppress_ovwarn=false) ik (x,y) = norm_interval ~suppress_ovwarn ~cast:false ik (x,y)
252+
let of_interval ik (x,y) = norm_interval ~cast:false ik (x,y)
253253

254254
let of_bitfield ik x =
255255
match Interval.of_bitfield ik x with
@@ -484,7 +484,7 @@ struct
484484
in
485485
binop x y interval_rem
486486

487-
let cast_to ?(suppress_ovwarn=false) ?torg ?no_ov ik x = norm_intvs ~cast:true ik x
487+
let cast_to ?torg ?no_ov ik x = norm_intvs ~cast:true ik x
488488

489489
(*
490490
narrows down the extremeties of xs if they are equal to boundary values of the ikind with (possibly) narrower values from ys
@@ -572,9 +572,9 @@ struct
572572
in
573573
interval_sets_to_partitions ik xs ys |> merge_list ik |> widen_left |> widen_right |> List.map snd
574574

575-
let starting ?(suppress_ovwarn=false) ik n = norm_interval ik ~suppress_ovwarn (n, snd (range ik))
575+
let starting ik n = norm_interval ik (n, snd (range ik))
576576

577-
let ending ?(suppress_ovwarn=false) ik n = norm_interval ik ~suppress_ovwarn (fst (range ik), n)
577+
let ending ik n = norm_interval ik (fst (range ik), n)
578578

579579
let invariant_ikind e ik xs =
580580
List.map (fun x -> Interval.invariant_ikind e ik (Some x)) xs |>
@@ -620,7 +620,7 @@ struct
620620
let excl_range_to_intervalset (ik: ikind) ((min, max): int_t * int_t) (excl: int_t): t =
621621
let intv1 = (min, excl -. Ints_t.one) in
622622
let intv2 = (excl +. Ints_t.one, max) in
623-
norm_intvs ik ~suppress_ovwarn:true [intv1 ; intv2] |> fst
623+
norm_intvs ik [intv1 ; intv2] |> fst
624624

625625
let of_excl_list ik (excls: int_t list) =
626626
let excl_list = List.map (excl_range_to_intervalset ik (range ik)) excls in

src/cdomain/value/cdomains/intDomain0.ml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ sig
110110
end
111111

112112

113-
module IntDomLifter (I : S) =
113+
module IntDomLifter (I : S2) =
114114
struct
115115
open Cil
116116
type int_t = I.int_t
@@ -477,7 +477,7 @@ struct
477477
) (Invariant.top ()) ns
478478
end
479479

480-
module SOverflowUnlifter (D : SOverflow) : S with type int_t = D.int_t and type t = D.t = struct
480+
module SOverflowUnlifter (D : SOverflow) : S2 with type int_t = D.int_t and type t = D.t = struct
481481
include D
482482

483483
let add ?no_ov ik x y = fst @@ D.add ?no_ov ik x y
@@ -490,15 +490,15 @@ module SOverflowUnlifter (D : SOverflow) : S with type int_t = D.int_t and type
490490

491491
let neg ?no_ov ik x = fst @@ D.neg ?no_ov ik x
492492

493-
let cast_to ?suppress_ovwarn ?torg ?no_ov ik x = fst @@ D.cast_to ?suppress_ovwarn ?torg ?no_ov ik x
493+
let cast_to ?suppress_ovwarn ?torg ?no_ov ik x = fst @@ D.cast_to ?torg ?no_ov ik x
494494

495495
let of_int ik x = fst @@ D.of_int ik x
496496

497-
let of_interval ?suppress_ovwarn ik x = fst @@ D.of_interval ?suppress_ovwarn ik x
497+
let of_interval ?suppress_ovwarn ik x = fst @@ D.of_interval ik x
498498

499-
let starting ?suppress_ovwarn ik x = fst @@ D.starting ?suppress_ovwarn ik x
499+
let starting ?suppress_ovwarn ik x = fst @@ D.starting ik x
500500

501-
let ending ?suppress_ovwarn ik x = fst @@ D.ending ?suppress_ovwarn ik x
501+
let ending ?suppress_ovwarn ik x = fst @@ D.ending ik x
502502

503503
let shift_left ik x y = fst @@ D.shift_left ik x y
504504

@@ -742,15 +742,15 @@ module SOverflowLifter (D : S) : SOverflow with type int_t = D.int_t and type t
742742

743743
let neg ?no_ov ik x = lift @@ D.neg ?no_ov ik x
744744

745-
let cast_to ?suppress_ovwarn ?torg ?no_ov ik x = lift @@ D.cast_to ?suppress_ovwarn ?torg ?no_ov ik x
745+
let cast_to ?torg ?no_ov ik x = lift @@ D.cast_to ?torg ?no_ov ik x
746746

747747
let of_int ik x = lift @@ D.of_int ik x
748748

749-
let of_interval ?suppress_ovwarn ik x = lift @@ D.of_interval ?suppress_ovwarn ik x
749+
let of_interval ik x = lift @@ D.of_interval ik x
750750

751-
let starting ?suppress_ovwarn ik x = lift @@ D.starting ?suppress_ovwarn ik x
751+
let starting ik x = lift @@ D.starting ik x
752752

753-
let ending ?suppress_ovwarn ik x = lift @@ D.ending ?suppress_ovwarn ik x
753+
let ending ik x = lift @@ D.ending ik x
754754

755755
let shift_left ik x y = lift @@ D.shift_left ik x y
756756

0 commit comments

Comments
 (0)