Skip to content

Commit dc68f48

Browse files
Merge pull request #25 from ManuelLerchner/indent-fixes
fixed all current ocp-indent failures
2 parents 5cf4620 + 898a68e commit dc68f48

File tree

7 files changed

+120
-120
lines changed

7 files changed

+120
-120
lines changed

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

Lines changed: 52 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ module BitfieldArith (Ints_t : IntOps.IntOps) = struct
7878
let bitmask_up_to pos =
7979
let top_bit = Ints_t.one <<: pos in
8080
if top_bit =: Ints_t.zero
81-
then Ints_t.zero
81+
then Ints_t.zero
8282
else
8383
Ints_t.sub top_bit Ints_t.one
8484

@@ -122,27 +122,27 @@ module BitfieldArith (Ints_t : IntOps.IntOps) = struct
122122

123123
let shift_right ik (z1, o1) (z2, o2) =
124124
if is_const (z2, o2)
125-
then
126-
shift_right ik (z1, o1) (Ints_t.to_int o2)
125+
then
126+
shift_right ik (z1, o1) (Ints_t.to_int o2)
127127
else
128128
let shift_counts = concretize (z2, o2) in
129129
List.fold_left (fun acc c ->
130-
let next = shift_right ik (z1, o1) c in join acc next
131-
) (zero_mask, zero_mask) shift_counts
130+
let next = shift_right ik (z1, o1) c in join acc next
131+
) (zero_mask, zero_mask) shift_counts
132132

133133
let shift_left _ (z,o) c =
134134
let zero_mask = bitmask_up_to c in
135135
((z <<: c) |: zero_mask, o <<: c)
136136

137137
let shift_left ik (z1, o1) (z2, o2) =
138138
if is_const (z2, o2)
139-
then
140-
shift_left ik (z1, o1) (Ints_t.to_int o2)
139+
then
140+
shift_left ik (z1, o1) (Ints_t.to_int o2)
141141
else
142142
let shift_counts = concretize (z2, o2) in
143143
List.fold_left (fun acc c ->
144-
let next = shift_left ik (z1, o1) c in join acc next
145-
) (zero_mask, zero_mask) shift_counts
144+
let next = shift_left ik (z1, o1) c in join acc next
145+
) (zero_mask, zero_mask) shift_counts
146146
end
147147

148148
module BitfieldFunctor (Ints_t : IntOps.IntOps): SOverflow with type int_t = Ints_t.t and type t = (Ints_t.t * Ints_t.t) = struct
@@ -161,7 +161,7 @@ module BitfieldFunctor (Ints_t : IntOps.IntOps): SOverflow with type int_t = Int
161161
let top_of ik =
162162
if isSigned ik then top ()
163163
else (BArith.one_mask, Ints_t.of_bigint (snd (Size.range ik)))
164-
164+
165165
let bot_of ik = bot ()
166166

167167
let to_pretty_bits (z,o) =
@@ -171,38 +171,38 @@ module BitfieldFunctor (Ints_t : IntOps.IntOps): SOverflow with type int_t = Int
171171
let z_mask = ref z in
172172

173173
let rec to_pretty_bits' acc =
174-
let current_bit_known = (!known_bitmask &: Ints_t.one) = Ints_t.one in
175-
let current_bit_impossible = (!invalid_bitmask &: Ints_t.one) = Ints_t.one in
176-
177-
let bit_value = !o_mask &: Ints_t.one in
178-
let bit =
179-
if current_bit_impossible then ""
180-
else if not current_bit_known then ""
181-
else Ints_t.to_string bit_value
182-
in
174+
let current_bit_known = (!known_bitmask &: Ints_t.one) = Ints_t.one in
175+
let current_bit_impossible = (!invalid_bitmask &: Ints_t.one) = Ints_t.one in
176+
177+
let bit_value = !o_mask &: Ints_t.one in
178+
let bit =
179+
if current_bit_impossible then ""
180+
else if not current_bit_known then ""
181+
else Ints_t.to_string bit_value
182+
in
183183

184-
if (!o_mask = Ints_t.of_int (-1) || !o_mask = Ints_t.zero ) && (!z_mask = Ints_t.of_int (-1) || !z_mask = Ints_t.zero) then
185-
let prefix = bit ^ "..." ^ bit in
186-
prefix ^ acc
187-
else
188-
(known_bitmask := !known_bitmask >>: 1;
189-
invalid_bitmask := !invalid_bitmask >>: 1;
190-
o_mask := !o_mask >>: 1;
191-
z_mask := !z_mask >>: 1;
192-
to_pretty_bits' (bit ^ acc))
184+
if (!o_mask = Ints_t.of_int (-1) || !o_mask = Ints_t.zero ) && (!z_mask = Ints_t.of_int (-1) || !z_mask = Ints_t.zero) then
185+
let prefix = bit ^ "..." ^ bit in
186+
prefix ^ acc
187+
else
188+
(known_bitmask := !known_bitmask >>: 1;
189+
invalid_bitmask := !invalid_bitmask >>: 1;
190+
o_mask := !o_mask >>: 1;
191+
z_mask := !z_mask >>: 1;
192+
to_pretty_bits' (bit ^ acc))
193193
in
194194
"0b" ^ to_pretty_bits' ""
195195

196196
let show t =
197197
if t = bot () then "bot" else
198198
if t = top () then "top" else
199199
let (z,o) = t in
200-
Format.sprintf "{%s, (zs:%s, os:%s)}" (to_pretty_bits t) (Ints_t.to_string z) (Ints_t.to_string o)
200+
Format.sprintf "{%s, (zs:%s, os:%s)}" (to_pretty_bits t) (Ints_t.to_string z) (Ints_t.to_string o)
201201

202202
include Std (struct type nonrec t = t let name = name let top_of = top_of let bot_of = bot_of let show = show let equal = equal end)
203203

204204
let range ik bf = (BArith.min ik bf, BArith.max ik bf)
205-
205+
206206
let maximal (z,o) =
207207
if (z < Ints_t.zero) <> (o < Ints_t.zero) then Some o
208208
else None
@@ -240,8 +240,8 @@ module BitfieldFunctor (Ints_t : IntOps.IntOps): SOverflow with type int_t = Int
240240
(new_bitfield, overflow_info)
241241
else if should_ignore_overflow ik then
242242
(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))
245245
else
246246
(top_of ik, overflow_info)
247247

@@ -274,7 +274,7 @@ module BitfieldFunctor (Ints_t : IntOps.IntOps): SOverflow with type int_t = Int
274274
let (min_ik, max_ik) = Size.range ik in
275275
let startv = Ints_t.max x (Ints_t.of_bigint min_ik) in
276276
let endv= Ints_t.min y (Ints_t.of_bigint max_ik) in
277-
277+
278278
let rec analyze_bits pos (acc_z, acc_o) =
279279
if pos < 0 then (acc_z, acc_o)
280280
else
@@ -284,15 +284,15 @@ module BitfieldFunctor (Ints_t : IntOps.IntOps): SOverflow with type int_t = Int
284284

285285
let without_remainder = Ints_t.sub startv remainder in
286286
let bigger_number = Ints_t.add without_remainder position in
287-
287+
288288
let bit_status =
289289
if Ints_t.compare bigger_number endv <= 0 then
290290
`top
291291
else
292-
if Ints_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+
if Ints_t.equal (Ints_t.logand (Ints_t.shift_right startv pos) Ints_t.one) Ints_t.one then
293+
`one
294+
else
295+
`zero
296296
in
297297

298298
let new_acc =
@@ -365,7 +365,7 @@ module BitfieldFunctor (Ints_t : IntOps.IntOps): SOverflow with type int_t = Int
365365
(z |: !:mask, o &: mask)
366366

367367
let is_invalid_shift_operation ik a b = BArith.is_invalid b
368-
|| BArith.is_invalid a
368+
|| BArith.is_invalid a
369369

370370
let is_undefined_shift_operation ik a b =
371371
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
375375
let shift_right ik a b =
376376
if M.tracing then M.trace "bitfield" "%a >> %a" pretty a pretty b;
377377
if is_invalid_shift_operation ik a b
378-
then
379-
(bot (), {underflow=false; overflow=false})
378+
then
379+
(bot (), {underflow=false; overflow=false})
380380
else if 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})
383383
else
384384
let defined_shifts = cap_bitshifts_to_precision ik b in
385385
norm ik @@ BArith.shift_right ik a defined_shifts
386386

387387
let shift_left ik a b =
388388
if M.tracing then M.trace "bitfield" "%a << %a" pretty a pretty b;
389389
if is_invalid_shift_operation ik a b
390-
then
391-
(bot (), {underflow=false; overflow=false})
390+
then
391+
(bot (), {underflow=false; overflow=false})
392392
else if 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})
395395
else
396396
let defined_shifts = cap_bitshifts_to_precision ik b in
397397
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
461461
let signBitDefZ = !:(o1 ^: o2) &: bitmask in
462462
for _ = size downto 0 do
463463
(if !pm &: Ints_t.one == Ints_t.one then
464-
accm := snd(add_paper Ints_t.zero !accm Ints_t.zero (!qv |: !qm))
465-
else if !pv &: Ints_t.one == Ints_t.one then
466-
accv := fst(add_paper !accv Ints_t.zero !qv Ints_t.zero);
467-
accm := snd(add_paper Ints_t.zero !accm Ints_t.zero !qm));
464+
accm := snd(add_paper Ints_t.zero !accm Ints_t.zero (!qv |: !qm))
465+
else if !pv &: Ints_t.one == Ints_t.one then
466+
accv := fst(add_paper !accv Ints_t.zero !qv Ints_t.zero);
467+
accm := snd(add_paper Ints_t.zero !accm Ints_t.zero !qm));
468468

469469
pv := !pv >>: 1;
470470
pm := !pm >>: 1;
@@ -586,7 +586,7 @@ module BitfieldFunctor (Ints_t : IntOps.IntOps): SOverflow with type int_t = Int
586586
QCheck.(set_shrink shrink @@ set_print show @@ map (fun (i1,i2) -> norm ik (i1,i2) |> fst ) pair_arb)
587587

588588
let project ik p t = t
589-
589+
590590
end
591591

592592
module Bitfield = BitfieldFunctor (IntOps.BigIntOps)

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -142,13 +142,13 @@ struct
142142
let to_bitfield ik x =
143143
let is_power_of_two x = (Z.logand x (x -: Z.one) = Z.zero) in
144144
match x with None -> (Z.zero, Z.zero) | Some (c,m) ->
145-
if m = Z.zero then (Z.lognot c, c)
146-
else if is_power_of_two m then
147-
let mod_mask = m -: Z.one in
148-
let z = Z.lognot c in
149-
let o = Z.logor (Z.lognot mod_mask) c in
150-
(z,o)
151-
else (Z.lognot Z.zero, Z.lognot Z.zero)
145+
if m = Z.zero then (Z.lognot c, c)
146+
else if is_power_of_two m then
147+
let mod_mask = m -: Z.one in
148+
let z = Z.lognot c in
149+
let o = Z.logor (Z.lognot mod_mask) c in
150+
(z,o)
151+
else (Z.lognot Z.zero, Z.lognot Z.zero)
152152

153153
let maximal t = match t with
154154
| Some (x, y) when y =: Z.zero -> Some x

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -299,11 +299,11 @@ struct
299299
let ex = if Z.gt x Z.zero || Z.lt y Z.zero then S.singleton Z.zero else S.empty () in
300300
norm ik @@ (`Excluded (ex, r))
301301

302-
let to_bitfield ik x =
303-
match x with
302+
let to_bitfield ik x =
303+
match x with
304304
`Definite c -> (Z.lognot c, c) |
305305
_ -> let one_mask = Z.lognot Z.zero
306-
in (one_mask, one_mask)
306+
in (one_mask, one_mask)
307307

308308
let starting ?(suppress_ovwarn=false) ikind x =
309309
let _,u_ik = Size.range ikind in

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -252,13 +252,13 @@ module Enums : S with type int_t = Z.t = struct
252252

253253
let to_bitfield ik x =
254254
match x with
255-
Inc i when BISet.is_empty i -> (Z.zero, Z.zero) |
256-
Inc i when BISet.is_singleton i ->
255+
Inc i when BISet.is_empty i -> (Z.zero, Z.zero) |
256+
Inc i when BISet.is_singleton i ->
257257
let o = BISet.choose i
258258
in (Z.lognot o, o) |
259-
Inc i -> BISet.fold (fun o (az, ao) -> (Z.logor (Z.lognot o) az, Z.logor o ao)) i (Z.zero, Z.zero) |
260-
_ -> let one_mask = Z.lognot Z.zero
261-
in (one_mask, one_mask)
259+
Inc i -> BISet.fold (fun o (az, ao) -> (Z.logor (Z.lognot o) az, Z.logor o ao)) i (Z.zero, Z.zero) |
260+
_ -> let one_mask = Z.lognot Z.zero
261+
in (one_mask, one_mask)
262262

263263
let starting ?(suppress_ovwarn=false) ikind x =
264264
let _,u_ik = Size.range ikind in

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

Lines changed: 45 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -89,11 +89,11 @@ struct
8989
if isSigned ik && isNegative then Ints_t.logor signMask (Ints_t.lognot z)
9090
else Ints_t.lognot z
9191
in let max ik (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 then Ints_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 then Ints_t.logand signMask o
96+
else o
9797
in fst (norm ik (Some (min ik x, max ik x)))
9898

9999
let of_int ik (x: int_t) = of_interval ik (x,x)
@@ -103,53 +103,53 @@ struct
103103

104104
let to_bitfield ik z =
105105
match z with None -> (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-
let wrap ik (z,o) =
111106
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+
let wrap ik (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)
120120
in
121-
let rec analyze_bits pos (acc_z, acc_o) =
122-
if pos < 0 then (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-
if Ints_t.compare bigger_number endv <= 0 then
133-
`top
134-
else
121+
let rec analyze_bits pos (acc_z, acc_o) =
122+
if pos < 0 then (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+
if Ints_t.compare bigger_number endv <= 0 then
133+
`top
134+
else
135135
if Ints_t.equal (Ints_t.logand (Ints_t.shift_right startv pos) Ints_t.one) Ints_t.one then
136136
`one
137137
else
138138
`zero
139-
in
139+
in
140140

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)
146146

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
153153

154154
let of_bool _ik = function true -> one | false -> zero
155155
let to_bool (a: t) = match a with
@@ -447,7 +447,7 @@ struct
447447
let refn = refine_with_congruence ik x y in
448448
if M.tracing then M.trace "refine" "int_refine_with_congruence %a %a -> %a" pretty x pretty y pretty refn;
449449
refn
450-
450+
451451
let refine_with_bitfield ik a b =
452452
let interv = of_bitfield ik b in
453453
meet ik a interv

0 commit comments

Comments
 (0)