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
includeStd (structtype nonrec t = t let name = name let top_of = top_of let bot_of = bot_of let show = show let equal = equal end)
203
203
204
204
letrangeikbf= (BArith.min ik bf, BArith.max ik bf)
205
-
205
+
206
206
letmaximal (z,o) =
207
207
if (z <Ints_t.zero) <> (o <Ints_t.zero) thenSome o
208
208
elseNone
@@ -240,8 +240,8 @@ module BitfieldFunctor (Ints_t : IntOps.IntOps): SOverflow with type int_t = Int
240
240
(new_bitfield, overflow_info)
241
241
elseif should_ignore_overflow ik then
242
242
(M.warn ~category:M.Category.Integer.overflow "Bitfield: Value was outside of range, indicating overflow, but 'sem.int.signed_overflow' is 'assume_none' -> Returned Top";
243
-
(* (bot (), overflow_info)) *)
244
-
(top_of ik, overflow_info))
243
+
(* (bot (), overflow_info)) *)
244
+
(top_of ik, overflow_info))
245
245
else
246
246
(top_of ik, overflow_info)
247
247
@@ -274,7 +274,7 @@ module BitfieldFunctor (Ints_t : IntOps.IntOps): SOverflow with type int_t = Int
274
274
let (min_ik, max_ik) =Size.range ik in
275
275
let startv =Ints_t.max x (Ints_t.of_bigint min_ik) in
276
276
let endv=Ints_t.min y (Ints_t.of_bigint max_ik) in
277
-
277
+
278
278
letrec analyze_bitspos (acc_z, acc_o) =
279
279
if pos <0then (acc_z, acc_o)
280
280
else
@@ -284,15 +284,15 @@ module BitfieldFunctor (Ints_t : IntOps.IntOps): SOverflow with type int_t = Int
284
284
285
285
let without_remainder =Ints_t.sub startv remainder in
286
286
let bigger_number =Ints_t.add without_remainder position in
287
-
287
+
288
288
let bit_status =
289
289
ifInts_t.compare bigger_number endv <=0then
290
290
`top
291
291
else
292
-
ifInts_t.equal (Ints_t.logand (Ints_t.shift_right startv pos) Ints_t.one) Ints_t.one then
293
-
`one
294
-
else
295
-
`zero
292
+
ifInts_t.equal (Ints_t.logand (Ints_t.shift_right startv pos) Ints_t.one) Ints_t.one then
293
+
`one
294
+
else
295
+
`zero
296
296
in
297
297
298
298
let new_acc =
@@ -365,7 +365,7 @@ module BitfieldFunctor (Ints_t : IntOps.IntOps): SOverflow with type int_t = Int
365
365
(z |:!:mask, o &: mask)
366
366
367
367
letis_invalid_shift_operationikab=BArith.is_invalid b
368
-
||BArith.is_invalid a
368
+
||BArith.is_invalid a
369
369
370
370
letis_undefined_shift_operationikab=
371
371
let some_negatives =BArith.min ik b <Z.zero in
@@ -375,23 +375,23 @@ module BitfieldFunctor (Ints_t : IntOps.IntOps): SOverflow with type int_t = Int
375
375
letshift_rightikab=
376
376
ifM.tracing thenM.trace "bitfield""%a >> %a" pretty a pretty b;
377
377
if is_invalid_shift_operation ik a b
378
-
then
379
-
(bot (), {underflow=false; overflow=false})
378
+
then
379
+
(bot (), {underflow=false; overflow=false})
380
380
elseif is_undefined_shift_operation ik a b
381
-
then
382
-
(top_of ik, {underflow=false; overflow=false})
381
+
then
382
+
(top_of ik, {underflow=false; overflow=false})
383
383
else
384
384
let defined_shifts = cap_bitshifts_to_precision ik b in
385
385
norm ik @@BArith.shift_right ik a defined_shifts
386
386
387
387
letshift_leftikab=
388
388
ifM.tracing thenM.trace "bitfield""%a << %a" pretty a pretty b;
389
389
if is_invalid_shift_operation ik a b
390
-
then
391
-
(bot (), {underflow=false; overflow=false})
390
+
then
391
+
(bot (), {underflow=false; overflow=false})
392
392
elseif is_undefined_shift_operation ik a b
393
-
then
394
-
(top_of ik, {underflow=false; overflow=false})
393
+
then
394
+
(top_of ik, {underflow=false; overflow=false})
395
395
else
396
396
let defined_shifts = cap_bitshifts_to_precision ik b in
397
397
norm ik @@BArith.shift_left ik a defined_shifts
@@ -461,10 +461,10 @@ module BitfieldFunctor (Ints_t : IntOps.IntOps): SOverflow with type int_t = Int
Copy file name to clipboardExpand all lines: src/cdomain/value/cdomains/int/intervalDomain.ml
+45-45Lines changed: 45 additions & 45 deletions
Original file line number
Diff line number
Diff line change
@@ -89,11 +89,11 @@ struct
89
89
if isSigned ik && isNegative thenInts_t.logor signMask (Ints_t.lognot z)
90
90
elseInts_t.lognot z
91
91
inletmaxik (z,o) =
92
-
let signBit =Ints_t.shift_left Ints_t.one ((Size.bit ik) -1) in
93
-
let signMask =Ints_t.of_bigint (snd (Size.range ik)) in
94
-
let isPositive =Ints_t.logand signBit z <>Ints_t.zero in
95
-
if isSigned ik && isPositive thenInts_t.logand signMask o
96
-
else o
92
+
let signBit =Ints_t.shift_left Ints_t.one ((Size.bit ik) -1) in
93
+
let signMask =Ints_t.of_bigint (snd (Size.range ik)) in
94
+
let isPositive =Ints_t.logand signBit z <>Ints_t.zero in
95
+
if isSigned ik && isPositive thenInts_t.logand signMask o
96
+
else o
97
97
in fst (norm ik (Some (min ik x, max ik x)))
98
98
99
99
letof_intik (x: int_t) = of_interval ik (x,x)
@@ -103,53 +103,53 @@ struct
103
103
104
104
letto_bitfieldikz=
105
105
match z withNone -> (Ints_t.lognot Ints_t.zero, Ints_t.lognot Ints_t.zero) |Some (x,y) ->
106
-
let (min_ik, max_ik) =Size.range ik in
107
-
let startv =Ints_t.max x (Ints_t.of_bigint min_ik) in
108
-
let endv=Ints_t.min y (Ints_t.of_bigint max_ik) in
109
-
110
-
letwrapik (z,o) =
111
106
let (min_ik, max_ik) =Size.range ik in
112
-
if isSigned ik then
113
-
let newz =Ints_t.logor (Ints_t.logand z (Ints_t.of_bigint max_ik)) (Ints_t.mul (Ints_t.of_bigint min_ik) (Ints_t.logand Ints_t.one (Ints_t.shift_right z (Size.bit ik -1)))) in
114
-
let newo =Ints_t.logor (Ints_t.logand o (Ints_t.of_bigint max_ik)) (Ints_t.mul (Ints_t.of_bigint min_ik) (Ints_t.logand Ints_t.one (Ints_t.shift_right o (Size.bit ik -1)))) in
115
-
(newz,newo)
116
-
else
117
-
let newz =Ints_t.logor z (Ints_t.lognot (Ints_t.of_bigint max_ik)) in
118
-
let newo =Ints_t.logand o (Ints_t.of_bigint max_ik) in
119
-
(newz,newo)
107
+
let startv =Ints_t.max x (Ints_t.of_bigint min_ik) in
108
+
let endv=Ints_t.min y (Ints_t.of_bigint max_ik) in
109
+
110
+
letwrapik (z,o) =
111
+
let (min_ik, max_ik) =Size.range ik in
112
+
if isSigned ik then
113
+
let newz =Ints_t.logor (Ints_t.logand z (Ints_t.of_bigint max_ik)) (Ints_t.mul (Ints_t.of_bigint min_ik) (Ints_t.logand Ints_t.one (Ints_t.shift_right z (Size.bit ik -1)))) in
114
+
let newo =Ints_t.logor (Ints_t.logand o (Ints_t.of_bigint max_ik)) (Ints_t.mul (Ints_t.of_bigint min_ik) (Ints_t.logand Ints_t.one (Ints_t.shift_right o (Size.bit ik -1)))) in
115
+
(newz,newo)
116
+
else
117
+
let newz =Ints_t.logor z (Ints_t.lognot (Ints_t.of_bigint max_ik)) in
118
+
let newo =Ints_t.logand o (Ints_t.of_bigint max_ik) in
119
+
(newz,newo)
120
120
in
121
-
letrec analyze_bitspos (acc_z, acc_o) =
122
-
if pos <0then (acc_z, acc_o)
123
-
else
124
-
let position =Ints_t.shift_left Ints_t.one pos in
125
-
let mask =Ints_t.sub position Ints_t.one in
126
-
let remainder =Ints_t.logand startv mask in
127
-
128
-
let without_remainder =Ints_t.sub startv remainder in
129
-
let bigger_number =Ints_t.add without_remainder position in
130
-
131
-
let bit_status =
132
-
ifInts_t.compare bigger_number endv <=0then
133
-
`top
134
-
else
121
+
letrec analyze_bitspos (acc_z, acc_o) =
122
+
if pos <0then (acc_z, acc_o)
123
+
else
124
+
let position =Ints_t.shift_left Ints_t.one pos in
125
+
let mask =Ints_t.sub position Ints_t.one in
126
+
let remainder =Ints_t.logand startv mask in
127
+
128
+
let without_remainder =Ints_t.sub startv remainder in
129
+
let bigger_number =Ints_t.add without_remainder position in
130
+
131
+
let bit_status =
132
+
ifInts_t.compare bigger_number endv <=0then
133
+
`top
134
+
else
135
135
ifInts_t.equal (Ints_t.logand (Ints_t.shift_right startv pos) Ints_t.one) Ints_t.one then
136
136
`one
137
137
else
138
138
`zero
139
-
in
139
+
in
140
140
141
-
let new_acc =
142
-
match bit_status with
143
-
|`top -> (Ints_t.logor position acc_z, Ints_t.logor position acc_o)
144
-
|`one -> (Ints_t.logand (Ints_t.lognot position) acc_z, Ints_t.logor position acc_o)
145
-
|`zero -> (Ints_t.logor position acc_z, Ints_t.logand (Ints_t.lognot position) acc_o)
141
+
let new_acc =
142
+
match bit_status with
143
+
|`top -> (Ints_t.logor position acc_z, Ints_t.logor position acc_o)
144
+
|`one -> (Ints_t.logand (Ints_t.lognot position) acc_z, Ints_t.logor position acc_o)
145
+
|`zero -> (Ints_t.logor position acc_z, Ints_t.logand (Ints_t.lognot position) acc_o)
146
146
147
-
in
148
-
analyze_bits (pos -1) new_acc
149
-
in
150
-
let result = analyze_bits (Size.bit ik -1) (Ints_t.zero, Ints_t.zero) in
151
-
let casted = (Ints_t.of_bigint (Size.cast ik ((Ints_t.to_bigint (fst result)))), Ints_t.of_bigint (Size.cast ik ((Ints_t.to_bigint (snd result)))))
152
-
in wrap ik casted
147
+
in
148
+
analyze_bits (pos -1) new_acc
149
+
in
150
+
let result = analyze_bits (Size.bit ik -1) (Ints_t.zero, Ints_t.zero) in
151
+
let casted = (Ints_t.of_bigint (Size.cast ik ((Ints_t.to_bigint (fst result)))), Ints_t.of_bigint (Size.cast ik ((Ints_t.to_bigint (snd result)))))
152
+
in wrap ik casted
153
153
154
154
letof_bool_ik=functiontrue -> one |false -> zero
155
155
letto_bool (a: t) =match a with
@@ -447,7 +447,7 @@ struct
447
447
let refn = refine_with_congruence ik x y in
448
448
ifM.tracing thenM.trace "refine""int_refine_with_congruence %a %a -> %a" pretty x pretty y pretty refn;
0 commit comments