Skip to content

Commit 23e99b5

Browse files
committed
Remove constant do_update_offset arguments
1 parent 541b142 commit 23e99b5

1 file changed

Lines changed: 14 additions & 14 deletions

File tree

src/cdomain/value/cdomains/valueDomain.ml

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -983,7 +983,7 @@ struct
983983
do_eval_offset x offs l o
984984

985985
let update_offset ?(blob_destructive=false) (ask: VDQ.t) (x:t) (offs:offs) (value:t) (exp:exp option) (v:lval) (t:typ): t =
986-
let rec do_update_offset ?(bitfield:int option=None) (ask:VDQ.t) (x:t) (offs:offs) (value:t) (exp:exp option) (l:lval option) (o:offset option) (v:lval) (t:typ):t =
986+
let rec do_update_offset ?(bitfield:int option=None) (x:t) (offs:offs) (l:lval option) (o:offset option) (t:typ):t = (* TODO: why does inner t argument change here, but not in eval_offset? *)
987987
if M.tracing then M.traceli "update_offset" "do_update_offset %a %a (%a) %a" pretty x Offs.pretty offs (Pretty.docOpt (CilType.Exp.pretty ())) exp pretty value;
988988
let mu = function Blob (Blob (y, s', zeroinit), s, _) -> Blob (y, ID.join s s', zeroinit) | x -> x in
989989
let r =
@@ -994,7 +994,7 @@ struct
994994
begin
995995
let l', o' = shift_one_over l o in
996996
let x = zero_init_calloced_memory zeroinit x t in
997-
mu (Blob (join x (do_update_offset ask x ofs value exp l' o' v t), s, zeroinit))
997+
mu (Blob (join x (do_update_offset x ofs l' o' t), s, zeroinit))
998998
end
999999
| Blob (x,s,zeroinit), `Field(f, _) ->
10001000
begin
@@ -1017,9 +1017,9 @@ struct
10171017
| _ -> false
10181018
in
10191019
if do_strong_update then
1020-
Blob ((do_update_offset ask x offs value exp l' o' v t), s, zeroinit)
1020+
Blob ((do_update_offset x offs l' o' t), s, zeroinit)
10211021
else
1022-
mu (Blob (join x (do_update_offset ask x offs value exp l' o' v t), s, zeroinit))
1022+
mu (Blob (join x (do_update_offset x offs l' o' t), s, zeroinit))
10231023
end
10241024
| Blob (x,s,zeroinit), `NoOffset -> (* `NoOffset is only remaining possibility for Blob here *)
10251025
begin
@@ -1043,9 +1043,9 @@ struct
10431043
end
10441044
in
10451045
if do_strong_update then
1046-
Blob ((do_update_offset ask x offs value exp l' o' v t), s, zeroinit)
1046+
Blob ((do_update_offset x offs l' o' t), s, zeroinit)
10471047
else
1048-
mu (Blob (join x (do_update_offset ask x offs value exp l' o' v t), s, zeroinit))
1048+
mu (Blob (join x (do_update_offset x offs l' o' t), s, zeroinit))
10491049
end
10501050
| Thread _, _ ->
10511051
(* hack for pthread_t variables *)
@@ -1088,7 +1088,7 @@ struct
10881088
| Struct str ->
10891089
begin
10901090
let l', o' = shift_one_over l o in
1091-
let value' = do_update_offset ~bitfield:fld.fbitfield ask (Structs.get str fld) offs value exp l' o' v t in
1091+
let value' = do_update_offset ~bitfield:fld.fbitfield (Structs.get str fld) offs l' o' t in
10921092
Struct (Structs.replace str fld value')
10931093
end
10941094
| Bot ->
@@ -1099,7 +1099,7 @@ struct
10991099
in
11001100
let strc = init_comp fld.fcomp in
11011101
let l', o' = shift_one_over l o in
1102-
Struct (Structs.replace strc fld (do_update_offset ask Bot offs value exp l' o' v t))
1102+
Struct (Structs.replace strc fld (do_update_offset Bot offs l' o' t))
11031103
| Top -> M.warn ~category:Imprecise "Trying to update a field, but the struct is unknown"; top ()
11041104
| _ -> M.warn ~category:Imprecise "Trying to update a field, but was not given a struct"; top ()
11051105
end
@@ -1132,8 +1132,8 @@ struct
11321132
top (), offs
11331133
end
11341134
in
1135-
Union (`Lifted fld, do_update_offset ask tempval tempoffs value exp l' o' v t)
1136-
| Bot -> Union (`Lifted fld, do_update_offset ask Bot offs value exp l' o' v t)
1135+
Union (`Lifted fld, do_update_offset tempval tempoffs l' o' t)
1136+
| Bot -> Union (`Lifted fld, do_update_offset Bot offs l' o' t)
11371137
| Top -> M.warn ~category:Imprecise "Trying to update a field, but the union is unknown"; top ()
11381138
| _ -> M.warn ~category:Imprecise "Trying to update a field, but was not given a union"; top ()
11391139
end
@@ -1145,7 +1145,7 @@ struct
11451145
| TArray(t1 ,_,_) -> t1
11461146
| _ -> t) in (* This is necessary because t is not a TArray in case of calloc *)
11471147
let e = determine_offset ask l o exp (Some v) in
1148-
let new_value_at_index = do_update_offset ask (CArrays.get ask x' (e,idx)) offs value exp l' o' v t in
1148+
let new_value_at_index = do_update_offset (CArrays.get ask x' (e,idx)) offs l' o' t in
11491149
let new_array_value = CArrays.set ask x' (e, idx) new_value_at_index in
11501150
Array new_array_value
11511151
| Bot ->
@@ -1154,15 +1154,15 @@ struct
11541154
| _ -> t, None) in (* This is necessary because t is not a TArray in case of calloc *)
11551155
let x' = CArrays.bot () in
11561156
let e = determine_offset ask l o exp (Some v) in
1157-
let new_value_at_index = do_update_offset ask Bot offs value exp l' o' v t in
1157+
let new_value_at_index = do_update_offset Bot offs l' o' t in
11581158
let new_array_value = CArrays.set ask x' (e, idx) new_value_at_index in
11591159
let len_ci = BatOption.bind len (fun e -> Cil.getInteger @@ Cil.constFold true e) in
11601160
let len_id = BatOption.map (IndexDomain.of_int (Cilfacade.ptrdiff_ikind ())) len_ci in
11611161
let newl = BatOption.default (ID.starting (Cilfacade.ptrdiff_ikind ()) Z.zero) len_id in
11621162
let new_array_value = CArrays.update_length newl new_array_value in
11631163
Array new_array_value
11641164
| Top -> M.warn ~category:Imprecise "Trying to update an index, but the array is unknown"; top ()
1165-
| x when GobOption.exists (Z.equal Z.zero) (IndexDomain.to_int idx) -> do_update_offset ask x offs value exp l' o' v t
1165+
| x when GobOption.exists (Z.equal Z.zero) (IndexDomain.to_int idx) -> do_update_offset x offs l' o' t
11661166
| _ -> M.warn ~category:Imprecise "Trying to update an index, but was not given an array(%a)" pretty x; top ()
11671167
end
11681168
in mu result
@@ -1174,7 +1174,7 @@ struct
11741174
| Some(Lval (x,o)) -> Some ((x, NoOffset)), Some(o)
11751175
| _ -> None, None
11761176
in
1177-
do_update_offset ask x offs value exp l o v t
1177+
do_update_offset x offs l o t
11781178

11791179
let rec affect_move ?(replace_with_const=false) ask (x:t) (v:varinfo) movement_for_expr:t =
11801180
let move_fun x = affect_move ~replace_with_const:replace_with_const ask x v movement_for_expr in

0 commit comments

Comments
 (0)