81
81
let name () = " def_exc"
82
82
83
83
84
- let top_range = R. of_interval range_ikind (- 99L , 99L ) (* Since there is no top ikind we use a range that includes both ILongLong [-63,63 ] and IULongLong [0,64 ]. Only needed for intermediate range computation on longs. Correct range is set by cast. *)
85
- let top () = `Excluded (S. empty () , top_range )
84
+ let overflow_range = R. of_interval range_ikind (- 999L , 999L ) (* Since there is no top ikind we use a range that includes both IInt128 [-127,127 ] and IUInt128 [0,128 ]. Only needed for intermediate range computation on longs. Correct range is set by cast. *)
85
+ let top_overflow () = `Excluded (S. empty () , overflow_range )
86
86
let bot () = `Bot
87
87
let top_of ik = `Excluded (S. empty () , size ik)
88
88
let bot_of ik = bot ()
@@ -117,8 +117,6 @@ struct
117
117
let upperb = Exclusion. max_of_range r in
118
118
Z. compare i upperb < = 0
119
119
120
- let is_top x = x = top ()
121
-
122
120
let equal_to i = function
123
121
| `Bot -> failwith " unsupported: equal_to with bottom"
124
122
| `Definite x -> if i = x then `Eq else `Neq
@@ -351,10 +349,10 @@ struct
351
349
(* We don't bother with exclusion sets : * )
352
350
| `Excluded _, `Definite _
353
351
| `Definite _, `Excluded _
354
- | `Excluded _ , `Excluded _ -> top ()
352
+ | `Excluded _ , `Excluded _ -> top_overflow ()
355
353
(* The good case: *)
356
354
| `Definite x , `Definite y ->
357
- (try `Definite (f x y) with | Division_by_zero -> top () )
355
+ (try `Definite (f x y) with | Division_by_zero -> top_overflow () )
358
356
| `Bot , `Bot -> `Bot
359
357
| _ ->
360
358
(* If only one of them is bottom, we raise an exception that eval_rv will catch *)
@@ -367,7 +365,7 @@ struct
367
365
norm ik @@
368
366
match x,y with
369
367
(* If both are exclusion sets , there isn't anything we can do : * )
370
- | `Excluded _ , `Excluded _ -> top ()
368
+ | `Excluded _ , `Excluded _ -> top_overflow ()
371
369
(* A definite value should be applied to all members of the exclusion set *)
372
370
| `Definite x , `Excluded (s ,r ) -> def_exc f x s r
373
371
(* Same thing here, but we should flip the operator to map it properly *)
@@ -382,11 +380,11 @@ struct
382
380
(* The equality check: *)
383
381
let eq ik x y = match x,y with
384
382
(* Not much to do with two exclusion sets : * )
385
- | `Excluded _ , `Excluded _ -> top ()
383
+ | `Excluded _ , `Excluded _ -> top_of IInt
386
384
(* Is x equal to an exclusion set, if it is a member then NO otherwise we
387
385
* don't know: *)
388
- | `Definite x , `Excluded (s ,r ) -> if S. mem x s then of_bool IInt false else top ()
389
- | `Excluded (s ,r ), `Definite x -> if S. mem x s then of_bool IInt false else top ()
386
+ | `Definite x , `Excluded (s ,r ) -> if S. mem x s then of_bool IInt false else top_of IInt
387
+ | `Excluded (s ,r ), `Definite x -> if S. mem x s then of_bool IInt false else top_of IInt
390
388
(* The good case: *)
391
389
| `Definite x , `Definite y -> of_bool IInt (x = y)
392
390
| `Bot , `Bot -> `Bot
@@ -397,11 +395,11 @@ struct
397
395
(* The inequality check: *)
398
396
let ne ik x y = match x,y with
399
397
(* Not much to do with two exclusion sets : * )
400
- | `Excluded _ , `Excluded _ -> top ()
398
+ | `Excluded _ , `Excluded _ -> top_of IInt
401
399
(* Is x unequal to an exclusion set, if it is a member then Yes otherwise we
402
400
* don't know: *)
403
- | `Definite x , `Excluded (s ,r ) -> if S. mem x s then of_bool IInt true else top ()
404
- | `Excluded (s ,r ), `Definite x -> if S. mem x s then of_bool IInt true else top ()
401
+ | `Definite x , `Excluded (s ,r ) -> if S. mem x s then of_bool IInt true else top_of IInt
402
+ | `Excluded (s ,r ), `Definite x -> if S. mem x s then of_bool IInt true else top_of IInt
405
403
(* The good case: *)
406
404
| `Definite x , `Definite y -> of_bool IInt (x <> y)
407
405
| `Bot , `Bot -> `Bot
@@ -460,12 +458,12 @@ struct
460
458
else if Z. equal i Z. one then
461
459
of_interval IBool (Z. zero, Z. one)
462
460
else
463
- top ()
461
+ top_of ik
464
462
| `Definite _, `Excluded _
465
- | `Excluded _ , `Excluded _ -> top ()
463
+ | `Excluded _ , `Excluded _ -> top_of ik
466
464
(* The good case: *)
467
465
| `Definite x , `Definite y ->
468
- (try `Definite (Z. logand x y) with | Division_by_zero -> top () )
466
+ (try `Definite (Z. logand x y) with | Division_by_zero -> top_of ik )
469
467
| `Bot , `Bot -> `Bot
470
468
| _ ->
471
469
(* If only one of them is bottom, we raise an exception that eval_rv will catch *)
0 commit comments