Skip to content

Commit 9437f97

Browse files
committed
Classify all castkinds in Goblint
1 parent 4dcbd61 commit 9437f97

File tree

7 files changed

+9
-9
lines changed

7 files changed

+9
-9
lines changed

src/analyses/base.ml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2368,7 +2368,8 @@ struct
23682368
|> AD.type_of in
23692369
(* when src and destination type coincide, take value from the source, otherwise use top *)
23702370
let value = if (typeSig dest_typ = typeSig src_typ) && dest_size_equal_n then
2371-
let src_cast_lval = mkMem ~addr:(Cilfacade.mkCast ~kind:None ~e:src ~newt:(TPtr (dest_typ, []))) ~off:NoOffset in
2371+
(* TODO: why cast if types coincide? *)
2372+
let src_cast_lval = mkMem ~addr:(Cilfacade.mkCast ~kind:Internal ~e:src ~newt:(TPtr (dest_typ, []))) ~off:NoOffset in
23722373
eval_rv ~man st (Lval src_cast_lval)
23732374
else
23742375
VD.top_value (unrollType dest_typ)

src/cdomain/value/cdomains/intDomain0.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ struct
161161
let name () = "IntDomLifter(" ^ (I.name ()) ^ ")"
162162
let to_yojson x = I.to_yojson x.v
163163
let invariant e x =
164-
let e' = Cilfacade.mkCast ~kind:None ~e ~newt:(TInt (x.ikind, [])) in
164+
let e' = Cilfacade.mkCast ~kind:Explicit ~e ~newt:(TInt (x.ikind, [])) in
165165
I.invariant_ikind e' x.ikind x.v
166166
let tag x = I.tag x.v
167167
let arbitrary ik = failwith @@ "Arbitrary not implement for " ^ (name ()) ^ "."

src/cdomain/value/cdomains/offset.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ struct
2727
| CastE (_, TInt (ik, []), Const (CStr ("any_index", No_encoding))) when CilType.Ikind.equal ik (Cilfacade.ptrdiff_ikind ()) -> true
2828
| _ -> false
2929

30-
let all = lazy (CastE (Internal, TInt (Cilfacade.ptrdiff_ikind (), []), mkString "all_index"))
30+
let all = lazy (CastE (Explicit, TInt (Cilfacade.ptrdiff_ikind (), []), mkString "all_index"))
3131
let is_all = function
3232
| CastE (_, TInt (ik, []), Const (CStr ("all_index", No_encoding))) when CilType.Ikind.equal ik (Cilfacade.ptrdiff_ikind ()) -> true
3333
| _ -> false

src/cdomain/value/cdomains/valueDomain.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1361,7 +1361,7 @@ struct
13611361
let offset = Addr.Offs.to_cil offs in
13621362

13631363
let cast_to_void_ptr e =
1364-
Cilfacade.mkCast ~kind:None ~e ~newt:(TPtr (TVoid [], []))
1364+
Cilfacade.mkCast ~kind:Explicit ~e ~newt:(TPtr (TVoid [], []))
13651365
in
13661366
let i =
13671367
if InvariantCil.(exp_is_suitable ~scope c_exp && var_is_suitable ~scope vi && not (var_is_heap vi)) then
@@ -1384,7 +1384,7 @@ struct
13841384
(* Address set for a void* variable contains pointers to values of non-void type,
13851385
so insert pointer cast to make invariant expression valid (no field/index on void). *)
13861386
let newt = TPtr (typ, []) in
1387-
let c_exp = Cilfacade.mkCast ~kind:None ~e:c_exp ~newt in
1387+
let c_exp = Cilfacade.mkCast ~kind:Explicit ~e:c_exp ~newt in
13881388
deref_invariant ~vs vi ~offset ~lval:(Mem c_exp, NoOffset)
13891389
| exception Cilfacade.TypeOfError _ (* typeOffset: Index on a non-array on calloc-ed alloc variables *)
13901390
| _ ->

src/cdomains/apron/sharedFunctions.apron.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ struct
300300
let cil_exp_of_linexpr1_term ~scalewith (c: Coeff.t) v =
301301
match V.to_cil_varinfo v with
302302
| Some vinfo when IntDomain.Size.is_cast_injective ~from_type:vinfo.vtype ~to_type:(TInt(ILongLong,[])) ->
303-
let var = Cilfacade.mkCast ~kind:None ~e:(Lval(Var vinfo,NoOffset)) ~newt:longlong in
303+
let var = Cilfacade.mkCast ~kind:Explicit ~e:(Lval(Var vinfo,NoOffset)) ~newt:longlong in
304304
let i = int_of_coeff_warn ~scalewith c in
305305
if Z.equal i Z.one then
306306
false, var

src/cdomains/unionFind.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,7 @@ module T = struct
463463
| _ ->
464464
let void_ptr_type = TPtr(TVoid [], []) in
465465
let offset_plus_exp = to_cil_sum offset exp in
466-
Lval (Mem (CastE (Internal, void_ptr_type, offset_plus_exp)), NoOffset)
466+
Lval (Mem (CastE (Internal, void_ptr_type, offset_plus_exp)), NoOffset) (* TODO: how can void* be dereferenced? *)
467467
in
468468
if check_valid_pointer res then
469469
res

src/common/util/cilfacade.ml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,6 @@ let mkCast ~kind ~(e: exp) ~(newt: typ) =
424424
with TypeOfError _ -> (* e might involve alloc variables, weird offsets, etc *)
425425
Cil.voidType (* oldt is only used for avoiding duplicate cast, so this falls back to adding cast *)
426426
in
427-
let kind = Option.value kind ~default:Internal in
428427
Cil.mkCastT ~kind ~e ~oldt ~newt
429428

430429
(** @raise TypeOfError
@@ -806,4 +805,4 @@ let add_function_declarations (file: Cil.file): unit =
806805
(** Special index expression for some unknown index.
807806
Weakly updates array in assignment.
808807
Used for [exp.fast_global_inits]. *)
809-
let any_index_exp = lazy (CastE (Internal, TInt (ptrdiff_ikind (), []), mkString "any_index")) (* TODO: move back to Offset *)
808+
let any_index_exp = lazy (CastE (Explicit, TInt (ptrdiff_ikind (), []), mkString "any_index")) (* TODO: move back to Offset *)

0 commit comments

Comments
 (0)