Skip to content

Commit 85aaec9

Browse files
DefExc apply_range: Remove spurious match (Closes #1687)
Earlier, `int64` was used for some computations and one needed to guard against overflows. Now, all operations happen on elements of type `Z.t` and such handling is not needed anymore.
1 parent 4031cb2 commit 85aaec9

File tree

1 file changed

+13
-16
lines changed

1 file changed

+13
-16
lines changed

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

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -299,15 +299,15 @@ struct
299299
let ex = if Z.gt x Z.zero || Z.lt y Z.zero then S.singleton Z.zero else S.empty () in
300300
norm ik @@ (`Excluded (ex, r))
301301

302-
let to_bitfield ik x =
303-
match x with
304-
| `Definite c -> (Z.lognot c, c)
305-
| _ when Cil.isSigned ik ->
306-
let one_mask = Z.lognot Z.zero in
302+
let to_bitfield ik x =
303+
match x with
304+
| `Definite c -> (Z.lognot c, c)
305+
| _ when Cil.isSigned ik ->
306+
let one_mask = Z.lognot Z.zero in
307307
(one_mask, one_mask)
308-
| _ ->
309-
let one_mask = Z.lognot Z.zero in
310-
let ik_mask = snd (Size.range ik) in
308+
| _ ->
309+
let one_mask = Z.lognot Z.zero in
310+
let ik_mask = snd (Size.range ik) in
311311
(one_mask, ik_mask)
312312

313313
let starting ?(suppress_ovwarn=false) ikind x =
@@ -333,12 +333,9 @@ struct
333333
| `Bot -> None
334334

335335
let apply_range f r = (* apply f to the min/max of the old range r to get a new range *)
336-
(* If the Int64 might overflow on us during computation, we instead go to top_range *)
337-
match R.minimal r, R.maximal r with
338-
| _ ->
339-
let rf m = (size % Size.min_for % f) (m r) in
340-
let r1, r2 = rf Exclusion.min_of_range, rf Exclusion.max_of_range in
341-
R.join r1 r2
336+
let rf m = (size % Size.min_for % f) (m r) in
337+
let r1, r2 = rf Exclusion.min_of_range, rf Exclusion.max_of_range in
338+
R.join r1 r2
342339

343340
(* Default behaviour for unary operators, simply maps the function to the
344341
* DefExc data structure. *)
@@ -542,8 +539,8 @@ struct
542539

543540
let refine_with_congruence ik a b = a
544541

545-
let refine_with_bitfield ik x (z,o) =
546-
match BitfieldDomain.Bitfield.to_int (z,o) with
542+
let refine_with_bitfield ik x (z,o) =
543+
match BitfieldDomain.Bitfield.to_int (z,o) with
547544
| Some y ->
548545
meet ik x (`Definite y)
549546
| _ ->

0 commit comments

Comments
 (0)