Skip to content

Commit 01ac79a

Browse files
committed
Remove type argument from do_update_offset
Makes it consistent with do_eval_offset. This breaks a lot of tests.
1 parent 5df7a36 commit 01ac79a

1 file changed

Lines changed: 14 additions & 19 deletions

File tree

src/cdomain/value/cdomains/valueDomain.ml

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -978,7 +978,7 @@ struct
978978
do_eval_offset x offs l o
979979

980980
let update_offset ?(blob_destructive=false) (ask: VDQ.t) (x:t) (offs:offs) (value:t) (exp:exp option) (v:lval) (t:typ): t =
981-
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? *)
981+
let rec do_update_offset ?(bitfield:int option=None) (x:t) (offs:offs) (l:lval option) (o:offset option):t =
982982
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;
983983
let mu = function Blob (Blob (y, s', zeroinit), s, _) -> Blob (y, ID.join s s', zeroinit) | x -> x in
984984
let r =
@@ -989,7 +989,7 @@ struct
989989
begin
990990
let l', o' = shift_one_over l o in
991991
let x = zero_init_calloced_memory zeroinit x t in
992-
mu (Blob (join x (do_update_offset x ofs l' o' t), s, zeroinit))
992+
mu (Blob (join x (do_update_offset x ofs l' o'), s, zeroinit))
993993
end
994994
| Blob (x,s,zeroinit), `Field(f, _) ->
995995
begin
@@ -1009,9 +1009,9 @@ struct
10091009
| _ -> false
10101010
in
10111011
if do_strong_update then
1012-
Blob ((do_update_offset x offs l' o' t), s, zeroinit)
1012+
Blob ((do_update_offset x offs l' o'), s, zeroinit)
10131013
else
1014-
mu (Blob (join x (do_update_offset x offs l' o' t), s, zeroinit))
1014+
mu (Blob (join x (do_update_offset x offs l' o'), s, zeroinit))
10151015
end
10161016
| Blob (x,s,zeroinit), `NoOffset -> (* `NoOffset is only remaining possibility for Blob here *)
10171017
begin
@@ -1036,9 +1036,9 @@ struct
10361036
end
10371037
in
10381038
if do_strong_update then
1039-
Blob ((do_update_offset x offs l' o' t), s, zeroinit)
1039+
Blob ((do_update_offset x offs l' o'), s, zeroinit)
10401040
else
1041-
mu (Blob (join x (do_update_offset x offs l' o' t), s, zeroinit))
1041+
mu (Blob (join x (do_update_offset x offs l' o'), s, zeroinit))
10421042
end
10431043
| Thread _, _ ->
10441044
(* hack for pthread_t variables *)
@@ -1076,12 +1076,11 @@ struct
10761076
| _ -> value
10771077
end
10781078
| `Field (fld, offs) when fld.fcomp.cstruct -> begin
1079-
let t = fld.ftype in
10801079
match x with
10811080
| Struct str ->
10821081
begin
10831082
let l', o' = shift_one_over l o in
1084-
let value' = do_update_offset ~bitfield:fld.fbitfield (Structs.get str fld) offs l' o' t in
1083+
let value' = do_update_offset ~bitfield:fld.fbitfield (Structs.get str fld) offs l' o' in
10851084
Struct (Structs.replace str fld value')
10861085
end
10871086
| Bot ->
@@ -1092,12 +1091,11 @@ struct
10921091
in
10931092
let strc = init_comp fld.fcomp in
10941093
let l', o' = shift_one_over l o in
1095-
Struct (Structs.replace strc fld (do_update_offset Bot offs l' o' t))
1094+
Struct (Structs.replace strc fld (do_update_offset Bot offs l' o'))
10961095
| Top -> M.warn ~category:Imprecise "Trying to update a field, but the struct is unknown"; top ()
10971096
| _ -> M.warn ~category:Imprecise "Trying to update a field, but was not given a struct"; top ()
10981097
end
10991098
| `Field (fld, offs) -> begin
1100-
let t = fld.ftype in
11011099
let l', o' = shift_one_over l o in
11021100
match x with
11031101
| Union (last_fld, prev_val) ->
@@ -1125,20 +1123,17 @@ struct
11251123
top (), offs
11261124
end
11271125
in
1128-
Union (`Lifted fld, do_update_offset tempval tempoffs l' o' t)
1129-
| Bot -> Union (`Lifted fld, do_update_offset Bot offs l' o' t)
1126+
Union (`Lifted fld, do_update_offset tempval tempoffs l' o')
1127+
| Bot -> Union (`Lifted fld, do_update_offset Bot offs l' o')
11301128
| Top -> M.warn ~category:Imprecise "Trying to update a field, but the union is unknown"; top ()
11311129
| _ -> M.warn ~category:Imprecise "Trying to update a field, but was not given a union"; top ()
11321130
end
11331131
| `Index (idx, offs) -> begin
11341132
let l', o' = shift_one_over l o in
11351133
match x with
11361134
| Array x' ->
1137-
let t = (match Cil.unrollType t with
1138-
| TArray(t1 ,_,_) -> t1
1139-
| _ -> t) in (* This is necessary because t is not a TArray in case of calloc *)
11401135
let e = determine_offset ask l o exp (Some v) in
1141-
let new_value_at_index = do_update_offset (CArrays.get ask x' (e,idx)) offs l' o' t in
1136+
let new_value_at_index = do_update_offset (CArrays.get ask x' (e,idx)) offs l' o' in
11421137
let new_array_value = CArrays.set ask x' (e, idx) new_value_at_index in
11431138
Array new_array_value
11441139
| Bot ->
@@ -1147,15 +1142,15 @@ struct
11471142
| _ -> t, None) in (* This is necessary because t is not a TArray in case of calloc *)
11481143
let x' = CArrays.bot () in
11491144
let e = determine_offset ask l o exp (Some v) in
1150-
let new_value_at_index = do_update_offset Bot offs l' o' t in
1145+
let new_value_at_index = do_update_offset Bot offs l' o' in
11511146
let new_array_value = CArrays.set ask x' (e, idx) new_value_at_index in
11521147
let len_ci = BatOption.bind len (fun e -> Cil.getInteger @@ Cil.constFold true e) in
11531148
let len_id = BatOption.map (IndexDomain.of_int (Cilfacade.ptrdiff_ikind ())) len_ci in
11541149
let newl = BatOption.default (ID.starting (Cilfacade.ptrdiff_ikind ()) Z.zero) len_id in
11551150
let new_array_value = CArrays.update_length newl new_array_value in
11561151
Array new_array_value
11571152
| Top -> M.warn ~category:Imprecise "Trying to update an index, but the array is unknown"; top ()
1158-
| x when GobOption.exists (Z.equal Z.zero) (IndexDomain.to_int idx) -> do_update_offset x offs l' o' t
1153+
| x when GobOption.exists (Z.equal Z.zero) (IndexDomain.to_int idx) -> do_update_offset x offs l' o'
11591154
| _ -> M.warn ~category:Imprecise "Trying to update an index, but was not given an array(%a)" pretty x; top ()
11601155
end
11611156
in mu result
@@ -1167,7 +1162,7 @@ struct
11671162
| Some(Lval (x,o)) -> Some ((x, NoOffset)), Some(o)
11681163
| _ -> None, None
11691164
in
1170-
do_update_offset x offs l o t
1165+
do_update_offset x offs l o
11711166

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

0 commit comments

Comments
 (0)