Skip to content

Commit bde475c

Browse files
committed
Use int instead of int64 for bit ranges
1 parent 3d7c7b7 commit bde475c

File tree

8 files changed

+19
-19
lines changed

8 files changed

+19
-19
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -641,7 +641,7 @@ module BitfieldFunctor (Ints_t : IntOps.IntOps): Bitfield_SOverflow with type in
641641

642642
let refine_with_bitfield ik x y = meet ik x y
643643

644-
let refine_with_excl_list ik t (excl : (int_t list * (int64 * int64)) option) : t = norm ik t
644+
let refine_with_excl_list ik t (excl : (int_t list * (int * int)) option) : t = norm ik t
645645

646646
let refine_with_incl_list ik t (incl : (int_t list) option) : t =
647647
let joined =match incl with

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ end
1111
(* The module [Exclusion] constains common functionality about handling of exclusion sets between [DefExc] and [Enums] *)
1212
module Exclusion =
1313
struct
14-
module R = IntervalArith (IntOps.Int64Ops)
14+
module R = IntervalArith (IntOps.NIntOps)
1515
(* We use these types for the functions in this module to make the intended meaning more explicit *)
1616
type t = Exc of BISet.t * R.t
1717
type inc = Inc of BISet.t [@@unboxed]
@@ -69,7 +69,7 @@ struct
6969

7070
(* Ikind used for intervals representing the domain *)
7171
let range_ikind = Cil.IInt
72-
let size t = let a,b = Size.bits_i64 t in Int64.neg a,b
72+
let size t = let a,b = Size.bits t in -a,b
7373

7474

7575
type t = [
@@ -81,7 +81,7 @@ struct
8181
let name () = "def_exc"
8282

8383

84-
let overflow_range = (-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. *)
84+
let overflow_range = (-999, 999) (* 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. *)
8585
let top_overflow () = `Excluded (S.empty (), overflow_range)
8686
let bot () = `Bot
8787
let top_of ik = `Excluded (S.empty (), size ik)
@@ -288,7 +288,7 @@ struct
288288
| `Definite x -> Some (IntOps.BigIntOps.to_bool x)
289289
| `Excluded (s,r) when S.mem Z.zero s -> Some true
290290
| _ -> None
291-
let top_bool = `Excluded (S.empty (), (0L, 1L))
291+
let top_bool = `Excluded (S.empty (), (0, 1))
292292

293293
let of_interval ik (x,y) =
294294
if Z.compare x y = 0 then

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ module Enums : S with type int_t = Z.t = struct
99
module R = Exclusion.R (* range for exclusion *)
1010

1111
let range_ikind = Cil.IInt
12-
let size t = let a,b = Size.bits_i64 t in Int64.neg a,b
12+
let size t = let a,b = Size.bits t in -a,b
1313

1414
type t =
1515
| Inc of BISet.t (* Inclusion set. *)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ struct
413413

414414
let refine_with_interval ik a b = meet ik a b
415415

416-
let refine_with_excl_list ik (intv : t) (excl : (int_t list * (int64 * int64)) option) : t =
416+
let refine_with_excl_list ik (intv : t) (excl : (int_t list * (int * int)) option) : t =
417417
match intv, excl with
418418
| None, _ | _, None -> intv
419419
| Some(l, u), Some(ls, (rl, rh)) ->

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,7 @@ struct
529529
let refine_with_excl_list ik (intv : t) = function
530530
| None -> intv
531531
| Some (xs, range) ->
532-
let excl_to_intervalset (ik: ikind) ((rl, rh): (int64 * int64)) (excl: int_t): t =
532+
let excl_to_intervalset (ik: ikind) ((rl, rh): (int * int)) (excl: int_t): t =
533533
excl_range_to_intervalset ik (Ints_t.of_bigint (Size.min_from_bit_range rl),Ints_t.of_bigint (Size.max_from_bit_range rh)) excl
534534
in
535535
let excl_list = List.map (excl_to_intervalset ik range) xs in

src/cdomain/value/cdomains/intDomain0.ml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ module Size = struct (* size in bits as int, range as int64 *)
244244
let bits ik = (* highest bits for neg/pos values *)
245245
let s = bit ik in
246246
if isSigned ik then s-1, s-1 else 0, s
247-
let bits_i64 ik = BatTuple.Tuple2.mapn Int64.of_int (bits ik)
247+
(* let bits_i64 ik = BatTuple.Tuple2.mapn Int64.of_int (bits ik) *)
248248
let range ik =
249249
let a,b = bits ik in
250250
let x = if isSigned ik then Z.neg (Z.shift_left Z.one a) (* -2^a *) else Z.zero in
@@ -275,16 +275,16 @@ module Size = struct (* size in bits as int, range as int64 *)
275275
(** @return Bit range always includes 0. *)
276276
let min_range_sign_agnostic x =
277277
let size ik =
278-
let a,b = bits_i64 ik in
279-
Int64.neg a,b
278+
let a,b = bits ik in
279+
-a,b
280280
in
281281
if sign x = `Signed then
282282
size (min_for x)
283283
else
284284
let a, b = size (min_for x) in
285-
if b <= 64L then
286-
let upper_bound_less = Int64.sub b 1L in
287-
let max_one_less = Z.(pred @@ shift_left Z.one (Int64.to_int upper_bound_less)) in
285+
if b <= 64 then
286+
let upper_bound_less = b - 1 in
287+
let max_one_less = Z.(pred @@ shift_left Z.one upper_bound_less) in
288288
if x <= max_one_less then
289289
a, upper_bound_less
290290
else
@@ -293,10 +293,10 @@ module Size = struct (* size in bits as int, range as int64 *)
293293
a, b
294294

295295
(* From the number of bits used to represent a positive value, determines the maximal representable value *)
296-
let max_from_bit_range pos_bits = Z.(pred @@ shift_left Z.one (to_int (Z.of_int64 pos_bits)))
296+
let max_from_bit_range pos_bits = Z.(pred @@ shift_left Z.one (to_int (Z.of_int pos_bits)))
297297

298298
(* From the number of bits used to represent a non-positive value, determines the minimal representable value *)
299-
let min_from_bit_range neg_bits = Z.(if neg_bits = 0L then Z.zero else neg @@ shift_left Z.one (to_int (neg (Z.of_int64 neg_bits))))
299+
let min_from_bit_range neg_bits = Z.(if neg_bits = 0 then Z.zero else neg @@ shift_left Z.one (to_int (neg (Z.of_int neg_bits))))
300300

301301
end
302302

src/cdomain/value/cdomains/intDomain_intf.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ sig
182182
(** Give a boolean interpretation of an abstract value if possible, otherwise
183183
* don't return anything.*)
184184

185-
val to_excl_list: t -> (int_t list * (int64 * int64)) option
185+
val to_excl_list: t -> (int_t list * (int * int)) option
186186
(** Gives a list representation of the excluded values from included range of bits if possible. *)
187187

188188
val of_excl_list: Cil.ikind -> int_t list -> t
@@ -267,7 +267,7 @@ sig
267267
val refine_with_congruence: Cil.ikind -> t -> (int_t * int_t) option -> t
268268
val refine_with_bitfield: Cil.ikind -> t -> (int_t * int_t) -> t
269269
val refine_with_interval: Cil.ikind -> t -> (int_t * int_t) option -> t
270-
val refine_with_excl_list: Cil.ikind -> t -> (int_t list * (int64 * int64)) option -> t
270+
val refine_with_excl_list: Cil.ikind -> t -> (int_t list * (int * int)) option -> t
271271
val refine_with_incl_list: Cil.ikind -> t -> int_t list option -> t
272272

273273
val project: Cil.ikind -> PrecisionUtil.int_precision -> t -> t

src/domains/intDomainProperties.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ sig
1313
val to_bool: t -> bool option
1414
val of_excl_list: Cil.ikind -> Z.t list -> t
1515
val is_excl_list: t -> bool
16-
val to_excl_list: t -> (Z.t list * (int64 * int64)) option
16+
val to_excl_list: t -> (Z.t list * (int * int)) option
1717
end
1818

1919
module type OldSWithIkind =

0 commit comments

Comments
 (0)