Skip to content

Commit c59bd87

Browse files
committed
Remove warn_and_top_on_zero from BaseInvariant for division by zero
1 parent df5edaa commit c59bd87

1 file changed

Lines changed: 0 additions & 10 deletions

File tree

src/analyses/baseInvariant.ml

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -291,12 +291,6 @@ struct
291291
(* inverse values for binary operation a `op` b == c *)
292292
(* ikind is the type of a for limiting ranges of the operands a, b. The only binops which can have different types for a, b are Shiftlt, Shiftrt (not handled below; don't use ikind to limit b there). *)
293293
let inv_bin_int (a, b) ikind c op =
294-
let warn_and_top_on_zero x =
295-
if ID.equal_to Z.zero x = `Eq then
296-
ID.top_of ikind
297-
else
298-
x
299-
in
300294
let meet_bin a' b' = id_meet_down ~old:a ~c:a', id_meet_down ~old:b ~c:b' in
301295
let meet_com oi = (* commutative *)
302296
try
@@ -320,8 +314,6 @@ struct
320314
(refine_by a b, refine_by b a)
321315
| MinusA -> meet_non ID.add ID.sub
322316
| Div ->
323-
(* If b must be zero, we have must UB *)
324-
let b = warn_and_top_on_zero b in
325317
(* Integer division means we need to add the remainder, so instead of just `a = c*b` we have `a = c*b + a%b`.
326318
* However, a%b will give [-b+1, b-1] for a=top, but we only want the positive/negative side depending on the sign of c*b.
327319
* If c*b = 0 or it can be positive or negative, we need the full range for the remainder. *)
@@ -335,8 +327,6 @@ struct
335327
in
336328
meet_bin (ID.add (ID.mul b c) rem) (ID.div (ID.sub a rem) c)
337329
| Mod -> (* a % b == c *)
338-
(* If b must be zero, we have must UB *)
339-
let b = warn_and_top_on_zero b in
340330
(* a' = a/b*b + c and derived from it b' = (a-c)/(a/b)
341331
* The idea is to formulate a' as quotient * divisor + remainder. *)
342332
let a' = ID.add (ID.mul (ID.div a b) b) c in

0 commit comments

Comments
 (0)