Skip to content

Commit a73fcd8

Browse files
committed
Change torg typ param to from_ik ikind param
1 parent e93610e commit a73fcd8

File tree

9 files changed

+29
-29
lines changed

9 files changed

+29
-29
lines changed

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

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -263,25 +263,25 @@ module BitfieldFunctor (Ints_t : IntOps.IntOps): Bitfield_SOverflow with type in
263263
else
264264
top_of ik
265265

266-
let cast_to ?torg ?(no_ov=false) ik (z,o) =
266+
let cast_to ?from_ik ?(no_ov=false) ik (z,o) =
267267
let (min_ik, max_ik) = Size.range ik in
268-
let (underflow, overflow) = match torg with
268+
let (underflow, overflow) = match from_ik with
269269
| None -> (false, false) (* ik does not change *)
270-
| Some (GoblintCil.Cil.TInt (old_ik, _) | TEnum ({ekind = old_ik; _}, _)) ->
270+
| Some old_ik ->
271271
let underflow = Z.compare (BArith.min old_ik (z,o)) min_ik < 0 in
272272
let overflow = Z.compare max_ik (BArith.max old_ik (z,o)) < 0 in
273273
(underflow, overflow)
274-
| _ ->
275-
let isPos = z <: Ints_t.zero in
276-
let isNeg = o <: Ints_t.zero in
277-
let underflow = if GoblintCil.isSigned ik then (((Ints_t.of_bigint min_ik) &: z) <>: Ints_t.zero) && isNeg else isNeg in
278-
let overflow = (((!:(Ints_t.of_bigint max_ik)) &: o) <>: Ints_t.zero) && isPos in
279-
(underflow, overflow)
274+
(* | _ -> (* TODO: what is this case? was it always dead? *)
275+
let isPos = z <: Ints_t.zero in
276+
let isNeg = o <: Ints_t.zero in
277+
let underflow = if GoblintCil.isSigned ik then (((Ints_t.of_bigint min_ik) &: z) <>: Ints_t.zero) && isNeg else isNeg in
278+
let overflow = (((!:(Ints_t.of_bigint max_ik)) &: o) <>: Ints_t.zero) && isPos in
279+
(underflow, overflow) *)
280280
in
281281
let overflow_info = {underflow; overflow} in
282282
(norm ~ov:(underflow || overflow) ik (z,o), overflow_info)
283283

284-
let cast_to ~kind ?torg ?(no_ov=false) ik (z,o) =
284+
let cast_to ~kind ?from_ik ?(no_ov=false) ik (z,o) =
285285
if ik = GoblintCil.IBool then (
286286
let may_zero =
287287
if Ints_t.equal z BArith.one_mask then (* zero bit may be in every position (one_mask) *)
@@ -298,7 +298,7 @@ module BitfieldFunctor (Ints_t : IntOps.IntOps): Bitfield_SOverflow with type in
298298
(BArith.join may_zero may_one, {underflow=false; overflow=false})
299299
)
300300
else
301-
cast_to ?torg ~no_ov ik (z,o)
301+
cast_to ?from_ik ~no_ov ik (z,o)
302302

303303
let join ik b1 b2 = norm ik @@ (BArith.join b1 b2)
304304

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ struct
166166
| _ -> None
167167

168168
(* cast from original type to ikind, set to top if the value doesn't fit into the new type *)
169-
let cast_to ?(suppress_ovwarn=false) ~kind ?torg ?(no_ov=false) t x =
169+
let cast_to ?(suppress_ovwarn=false) ~kind ?from_ik ?(no_ov=false) t x =
170170
match x with
171171
| None -> None
172172
| Some (c, m) when m =: Z.zero ->
@@ -183,16 +183,16 @@ struct
183183
let (min_ikorg, max_ikorg) = range ikorg in
184184
ikorg = t || (max_t >=: max_ikorg && min_t <=: min_ikorg)
185185
in
186-
match Option.map Cil.unrollType torg with
187-
| Some (Cil.TInt (ikorg, _) | TEnum ({ekind = ikorg; _}, _)) when p ikorg ->
186+
match from_ik with
187+
| Some ikorg when p ikorg ->
188188
if M.tracing then M.trace "cong-cast" "some case";
189189
x
190190
| _ -> top ()
191191

192192

193-
let cast_to ?(suppress_ovwarn=false) ~kind ?torg ?no_ov (t : Cil.ikind) x =
193+
let cast_to ?(suppress_ovwarn=false) ~kind ?from_ik ?no_ov (t : Cil.ikind) x =
194194
let pretty_bool _ x = Pretty.text (string_of_bool x) in
195-
let res = cast_to ~kind ?torg ?no_ov t x in
195+
let res = cast_to ~kind ?from_ik ?no_ov t x in
196196
if M.tracing then M.trace "cong-cast" "Cast %a to %a (no_ov: %a) = %a" pretty x Cil.d_ikind t (Pretty.docOpt (pretty_bool ())) no_ov pretty res;
197197
res
198198

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ struct
132132
| `Definite x -> if i = x then `Eq else `Neq
133133
| `Excluded (s,r) -> if S.mem i s then `Neq else `Top
134134

135-
let cast_to ?(suppress_ovwarn=false) ~kind ?torg ?no_ov ik = function
135+
let cast_to ?(suppress_ovwarn=false) ~kind ?from_ik ?no_ov ik = function
136136
| `Excluded (s,r) ->
137137
let r' = size ik in
138138
if R.leq r r' then (* upcast -> no change *)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ module Enums : S with type int_t = Z.t = struct
9797
if BISet.mem i x then `Neq
9898
else `Top
9999

100-
let cast_to ?(suppress_ovwarn=false) ~kind ?torg ?no_ov ik v = norm ik @@ match v with
100+
let cast_to ?(suppress_ovwarn=false) ~kind ?from_ik ?no_ov ik v = norm ik @@ match v with
101101
| Exc (s,r) ->
102102
let r' = size ik in
103103
if R.leq r r' then (* upcast -> no change *)

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -363,8 +363,8 @@ module IntDomTupleImpl = struct
363363
let c_lognot ik =
364364
map ik {f1 = (fun (type a) (module I : SOverflow with type t = a) ?no_ov -> I.c_lognot ik)}
365365

366-
let cast_to ?(suppress_ovwarn=false) ~kind ?torg ?no_ov t =
367-
mapovc ~suppress_ovwarn ~op:(Cast kind) t {f1_ovc = (fun (type a) (module I : SOverflow with type t = a) ?no_ov -> I.cast_to ~kind ?torg ?no_ov t)}
366+
let cast_to ?(suppress_ovwarn=false) ~kind ?from_ik ?no_ov t =
367+
mapovc ~suppress_ovwarn ~op:(Cast kind) t {f1_ovc = (fun (type a) (module I : SOverflow with type t = a) ?no_ov -> I.cast_to ~kind ?from_ik ?no_ov t)}
368368

369369
(* fp: projections *)
370370
let equal_to i x =

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ struct
138138
let maximal = function None -> None | Some (x,y) -> Some y
139139
let minimal = function None -> None | Some (x,y) -> Some x
140140

141-
let cast_to ~kind ?torg ?no_ov t = norm ~cast:true t (* norm does all overflow handling *)
141+
let cast_to ~kind ?from_ik ?no_ov t = norm ~cast:true t (* norm does all overflow handling *)
142142

143143
let widen ik x y =
144144
match x, y with

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,7 @@ struct
484484
in
485485
binop x y interval_rem
486486

487-
let cast_to ~kind ?torg ?no_ov ik x = norm_intvs ~cast:true ik x
487+
let cast_to ~kind ?from_ik ?no_ov ik x = norm_intvs ~cast:true ik x
488488

489489
(*
490490
narrows down the extremeties of xs if they are equal to boundary values of the ikind with (possibly) narrower values from ys

src/cdomain/value/cdomains/intDomain0.ml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ struct
234234
let c_logand = lift2 I.c_logand
235235
let c_logor = lift2 I.c_logor
236236

237-
let cast_to ?(suppress_ovwarn=false) ~kind ikind x = {v = I.cast_to ~suppress_ovwarn ~kind ~torg:(TInt(x.ikind,[])) ikind x.v; ikind}
237+
let cast_to ?(suppress_ovwarn=false) ~kind ikind x = {v = I.cast_to ~suppress_ovwarn ~kind ~from_ik:x.ikind ikind x.v; ikind}
238238

239239
let is_top_of ik x = ik = x.ikind && I.is_top_of ik x.v
240240

@@ -537,7 +537,7 @@ module SOverflowUnlifter (D : SOverflow) : S2 with type int_t = D.int_t and type
537537

538538
let neg ?no_ov ik x = fst @@ D.neg ?no_ov ik x
539539

540-
let cast_to ?suppress_ovwarn ~kind ?torg ?no_ov ik x = fst @@ D.cast_to ~kind ?torg ?no_ov ik x
540+
let cast_to ?suppress_ovwarn ~kind ?from_ik ?no_ov ik x = fst @@ D.cast_to ~kind ?from_ik ?no_ov ik x
541541

542542
let of_int ?suppress_ovwarn ik x = fst @@ D.of_int ik x
543543

@@ -789,7 +789,7 @@ module SOverflowLifter (D : S) : SOverflow with type int_t = D.int_t and type t
789789

790790
let neg ?no_ov ik x = lift @@ D.neg ?no_ov ik x
791791

792-
let cast_to ~kind ?torg ?no_ov ik x = lift @@ D.cast_to ~kind ?torg ?no_ov ik x
792+
let cast_to ~kind ?from_ik ?no_ov ik x = lift @@ D.cast_to ~kind ?from_ik ?no_ov ik x
793793

794794
let of_int ik x = lift @@ D.of_int ik x
795795

src/cdomain/value/cdomains/intDomain_intf.ml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -241,10 +241,10 @@ sig
241241
val mul : ?no_ov:bool -> Cil.ikind -> t -> t -> t
242242
val div : ?no_ov:bool -> Cil.ikind -> t -> t -> t
243243
val neg : ?no_ov:bool -> Cil.ikind -> t -> t
244-
val cast_to : ?suppress_ovwarn:bool -> kind:castkind -> ?torg:Cil.typ -> ?no_ov:bool -> Cil.ikind -> t -> t
244+
val cast_to : ?suppress_ovwarn:bool -> kind:castkind -> ?from_ik:Cil.ikind -> ?no_ov:bool -> Cil.ikind -> t -> t
245245
(** Cast to {!Cil.ikind}.
246246
The function is also called to handle overflow/wraparound after operations.
247-
@param torg Only present for actual casts, missing for overflow/wraparound (where the type stays the same).
247+
@param from_ik Only present for actual casts, missing for overflow/wraparound (where the type stays the same).
248248
@param no_ov If true, assume no overflow can occur. *)
249249

250250
val join: Cil.ikind -> t -> t -> t
@@ -303,10 +303,10 @@ sig
303303

304304
val neg : ?no_ov:bool -> Cil.ikind -> t -> t * overflow_info
305305

306-
val cast_to : kind:castkind -> ?torg:Cil.typ -> ?no_ov:bool -> Cil.ikind -> t -> t * overflow_info
306+
val cast_to : kind:castkind -> ?from_ik:Cil.ikind -> ?no_ov:bool -> Cil.ikind -> t -> t * overflow_info
307307
(** Cast to {!Cil.ikind}.
308308
The function is also called to handle overflow/wraparound after operations.
309-
@param torg Only present for actual casts, missing for overflow/wraparound (where the type stays the same).
309+
@param from_ik Only present for actual casts, missing for overflow/wraparound (where the type stays the same).
310310
@param no_ov If true, assume no overflow can occur. *)
311311

312312
val of_int : Cil.ikind -> int_t -> t * overflow_info

0 commit comments

Comments
 (0)