You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
moduleDefExc : Swithtype int_t =Z.t =(* definite or set of excluded values *)
66
66
struct
67
67
moduleS=BISet
68
-
moduleR=Interval32(* range for exclusion *)
68
+
moduleR=Exclusion.R(* range for exclusion *)
69
69
70
70
(* Ikind used for intervals representing the domain *)
71
71
let range_ikind =Cil.IInt
72
-
letsizet=R.of_interval range_ikind (let a,b =Size.bits_i64 t inInt64.neg a,b)
72
+
letsizet=let a,b =Size.bits_i64 t inInt64.neg a,b
73
73
74
74
75
75
typet = [
@@ -81,7 +81,7 @@ struct
81
81
letname()="def_exc"
82
82
83
83
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. *)
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. *)
Copy file name to clipboardExpand all lines: src/cdomain/value/cdomains/int/enumsDomain.ml
+17-14Lines changed: 17 additions & 14 deletions
Original file line number
Diff line number
Diff line change
@@ -6,10 +6,10 @@ open GoblintCil
6
6
7
7
(* Inclusion/Exclusion sets. Go to top on arithmetic operations (except for some easy cases, e.g. multiplication with 0). Joins on widen, i.e. precise integers as long as not derived from arithmetic expressions. *)
8
8
moduleEnums : Swithtype int_t =Z.t =struct
9
-
moduleR=Interval32(* range for exclusion *)
9
+
moduleR=Exclusion.R(* range for exclusion *)
10
10
11
11
let range_ikind =Cil.IInt
12
-
letsizet=R.of_interval range_ikind (let a,b =Size.bits_i64 t inInt64.neg a,b)
12
+
letsizet=let a,b =Size.bits_i64 t inInt64.neg a,b
13
13
14
14
typet =
15
15
| IncofBISet.t(* Inclusion set. *)
@@ -18,8 +18,8 @@ module Enums : S with type int_t = Z.t = struct
18
18
19
19
typeint_t = Z.t
20
20
letname()="enums"
21
-
letbot()=failwith "bot () not implemented for Enums"
22
-
letbot_ofik=Inc (BISet.empty ())
21
+
letbot()=Inc (BISet.empty())
22
+
letbot_ofik=bot ()
23
23
let top_bool =Inc (BISet.of_list [Z.zero; Z.one])
24
24
lettop_ofik=
25
25
match ik with
@@ -113,7 +113,7 @@ module Enums : S with type int_t = Z.t = struct
113
113
of_int ik x
114
114
else
115
115
let a, b =Size.min_range_sign_agnostic x, Size.min_range_sign_agnostic y in
116
-
let r =R.join (R.of_interval range_ikind a) (R.of_interval range_ikind b)in
116
+
let r =R.join a bin
117
117
let ex =ifZ.gt x Z.zero ||Z.lt y Z.zero thenBISet.singleton Z.zero elseBISet.empty ()in
118
118
norm ik @@ (Exc (ex, r))
119
119
@@ -126,22 +126,25 @@ module Enums : S with type int_t = Z.t = struct
126
126
let r =ifBISet.is_empty y
127
127
then r
128
128
else
129
-
let (min_el_range, max_el_range) =Batteries.Tuple2.mapn (funx -> R.of_interval range_ikind (Size.min_range_sign_agnostic x)) (BISet.min_elt y, BISet.max_elt y) in
129
+
let (min_el_range, max_el_range) =Batteries.Tuple2.mapn Size.min_range_sign_agnostic (BISet.min_elt y, BISet.max_elt y) in
130
130
let range =R.join min_el_range max_el_range in
131
131
R.join r range
132
132
in
133
133
Exc (BISet.diff x y, r)
134
134
135
-
letmeet_xy=
135
+
letmeetikxy=
136
136
match x, y with
137
137
|Incx, Incy -> Inc (BISet.inter x y)
138
138
|Exc (x,r1), Exc (y,r2) ->
139
-
let r =R.meet r1 r2 in
140
-
let r_min, r_max =Exclusion.min_of_range r, Exclusion.max_of_range r in
141
-
let filter_by_range =BISet.filter (value_in_range (r_min, r_max)) in
142
-
(* We remove those elements from the exclusion set that do not fit in the range anyway *)
143
-
let excl =BISet.union (filter_by_range x) (filter_by_range y) in
144
-
Exc (excl, r)
139
+
beginmatchR.meet r1 r2 with
140
+
|None -> bot ()
141
+
|Somer ->
142
+
let r_min, r_max =Exclusion.min_of_range r, Exclusion.max_of_range r in
143
+
let filter_by_range =BISet.filter (value_in_range (r_min, r_max)) in
144
+
(* We remove those elements from the exclusion set that do not fit in the range anyway *)
145
+
let excl =BISet.union (filter_by_range x) (filter_by_range y) in
146
+
Exc (excl, r)
147
+
end
145
148
|Inc x, Exc (y,r)
146
149
|Exc (y,r), Incx -> Inc (BISet.diff x y)
147
150
@@ -244,7 +247,7 @@ module Enums : S with type int_t = Z.t = struct
244
247
|_ -> None
245
248
letto_int=functionIncxwhenBISet.is_singleton x -> Some (BISet.choose x) |_ ->None
0 commit comments