Skip to content

Commit fa4203b

Browse files
Limit size of exclusions in narrow in Enums to 10
1 parent bce9f92 commit fa4203b

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

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

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,21 +130,26 @@ module Enums : S with type int_t = Z.t = struct
130130
in
131131
Exc (BISet.diff x y, r)
132132

133-
let meet _ x y =
133+
let meet bound _ x y =
134134
match x, y with
135135
| Inc x, Inc y -> Inc (BISet.inter x y)
136136
| Exc (x,r1), Exc (y,r2) ->
137137
let r = R.meet r1 r2 in
138138
let r_min, r_max = Exclusion.min_of_range r, Exclusion.max_of_range r in
139139
let filter_by_range = BISet.filter (value_in_range (r_min, r_max)) in
140140
(* We remove those elements from the exclusion set that do not fit in the range anyway *)
141-
let excl = BISet.union (filter_by_range x) (filter_by_range y) in
141+
let xset = filter_by_range x in
142+
let excl = match bound with
143+
| Some b when BISet.cardinal xset >= b -> xset
144+
| _ -> BISet.union xset (filter_by_range y)
145+
in
142146
Exc (excl, r)
143147
| Inc x, Exc (y,r)
144148
| Exc (y,r), Inc x -> Inc (BISet.diff x y)
145149

150+
let narrow = meet (Some 10)
151+
let meet = meet None
146152
let widen = join
147-
let narrow = meet
148153
let leq a b =
149154
match a, b with
150155
| Inc xs, Exc (ys, r) ->
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// PARAM: --set ana.int.refinement fixpoint --enable ana.int.def_exc --enable ana.int.enums --enable ana.int.interval --set sem.int.signed_overflow assume_none
2+
// FIXPOINT: Used to not reach terminate (https://github.com/goblint/analyzer/issues/1671) and (https://github.com/goblint/analyzer/issues/1673)
3+
int main() {
4+
int count = 0;
5+
while (1) {
6+
count++;
7+
count++;
8+
}
9+
}

0 commit comments

Comments
 (0)