1717 include Lattice. S
1818 type offs
1919 val eval_offset : Q .ask -> (AD .t -> t ) -> t -> offs -> exp option -> lval option -> t
20- val update_offset : Q .ask -> t -> offs -> t -> exp option -> lval -> typ -> t
20+ val update_offset : Q .ask -> t -> offs -> t -> exp option -> lval -> t
2121 val update_array_lengths : (exp -> t ) -> t -> Cil .typ -> t
2222 val affect_move : ?replace_with_const : bool -> Q .ask -> t -> varinfo -> (exp -> int option ) -> t
2323 val affecting_vars : t -> varinfo list
@@ -739,19 +739,19 @@ struct
739739 in
740740 do_eval_offset ask f x offs exp l o v
741741
742- let update_offset (ask : Q.ask ) (x :t ) (offs :offs ) (value :t ) (exp :exp option ) (v :lval ) ( t :typ ) : t =
743- let rec do_update_offset (ask :Q.ask ) (x :t ) (offs :offs ) (value :t ) (exp :exp option ) (l :lval option ) (o :offset option ) (v :lval ) ( t :typ ) :t =
742+ let update_offset (ask : Q.ask ) (x :t ) (offs :offs ) (value :t ) (exp :exp option ) (v :lval ): t =
743+ let rec do_update_offset (ask :Q.ask ) (x :t ) (offs :offs ) (value :t ) (exp :exp option ) (l :lval option ) (o :offset option ) (v :lval ):t =
744744 let mu = function `Blob (`Blob (y , s' ), s ) -> `Blob (y, ID. join s s') | x -> x in
745745 match x, offs with
746746 | `Blob (x ,s ), `Index (_ ,ofs ) ->
747747 begin
748748 let l', o' = shift_one_over l o in
749- mu (`Blob (join x (do_update_offset ask x ofs value exp l' o' v t ), s))
749+ mu (`Blob (join x (do_update_offset ask x ofs value exp l' o' v), s))
750750 end
751751 | `Blob (x ,s ),_ ->
752752 begin
753753 let l', o' = shift_one_over l o in
754- mu (`Blob (join x (do_update_offset ask x offs value exp l' o' v t ), s))
754+ mu (`Blob (join x (do_update_offset ask x offs value exp l' o' v), s))
755755 end
756756 | _ ->
757757 let result =
@@ -762,12 +762,11 @@ struct
762762 | _ -> value
763763 end
764764 | `Field (fld , offs ) when fld.fcomp.cstruct -> begin
765- let t = fld.ftype in
766765 match x with
767766 | `Struct str ->
768767 begin
769768 let l', o' = shift_one_over l o in
770- let value' = (do_update_offset ask (Structs. get str fld) offs value exp l' o' v t ) in
769+ let value' = (do_update_offset ask (Structs. get str fld) offs value exp l' o' v) in
771770 `Struct (Structs. replace str fld value')
772771 end
773772 | `Bot ->
@@ -778,12 +777,11 @@ struct
778777 in
779778 let strc = init_comp fld.fcomp in
780779 let l', o' = shift_one_over l o in
781- `Struct (Structs. replace strc fld (do_update_offset ask `Bot offs value exp l' o' v t ))
780+ `Struct (Structs. replace strc fld (do_update_offset ask `Bot offs value exp l' o' v))
782781 | `Top -> M. warn " Trying to update a field, but the struct is unknown" ; top ()
783782 | _ -> M. warn " Trying to update a field, but was not given a struct" ; top ()
784783 end
785784 | `Field (fld , offs ) -> begin
786- let t = fld.ftype in
787785 let l', o' = shift_one_over l o in
788786 match x with
789787 | `Union (last_fld , prev_val ) ->
@@ -812,25 +810,22 @@ struct
812810 top () , offs
813811 end
814812 in
815- `Union (`Lifted fld, do_update_offset ask tempval tempoffs value exp l' o' v t )
816- | `Bot -> `Union (`Lifted fld, do_update_offset ask `Bot offs value exp l' o' v t )
813+ `Union (`Lifted fld, do_update_offset ask tempval tempoffs value exp l' o' v)
814+ | `Bot -> `Union (`Lifted fld, do_update_offset ask `Bot offs value exp l' o' v)
817815 | `Top -> M. warn " Trying to update a field, but the union is unknown" ; top ()
818816 | _ -> M. warn_each " Trying to update a field, but was not given a union" ; top ()
819817 end
820818 | `Index (idx , offs ) -> begin
821819 let l', o' = shift_one_over l o in
822820 match x with
823821 | `Array x' ->
824- (match t with
825- | TArray (t1 ,_ ,_ ) ->
826- let e = determine_offset ask l o exp (Some v) in
827- let new_value_at_index = do_update_offset ask (CArrays. get ask x' (e,idx)) offs value exp l' o' v t1 in
828- let new_array_value = CArrays. set ask x' (e, idx) new_value_at_index in
829- `Array new_array_value
830- | _ -> M. warn " Trying to update an array, but the type was not array" ; top () )
822+ let e = determine_offset ask l o exp (Some v) in
823+ let new_value_at_index = do_update_offset ask (CArrays. get ask x' (e,idx)) offs value exp l' o' v in
824+ let new_array_value = CArrays. set ask x' (e, idx) new_value_at_index in
825+ `Array new_array_value
831826 | `Bot -> M. warn_each(" encountered array bot, made array top" ); `Array (CArrays. top () );
832827 | `Top -> M. warn " Trying to update an index, but the array is unknown" ; top ()
833- | x when IndexDomain. to_int idx = Some 0L -> do_update_offset ask x offs value exp l' o' v t
828+ | x when IndexDomain. to_int idx = Some 0L -> do_update_offset ask x offs value exp l' o' v
834829 | _ -> M. warn_each (" Trying to update an index, but was not given an array(" ^ short 80 x^ " )" ); top ()
835830 end
836831 in mu result
@@ -839,7 +834,7 @@ struct
839834 | Some (Lval (x ,o )) -> Some ((x, NoOffset )), Some (o)
840835 | _ -> None , None
841836 in
842- do_update_offset ask x offs value exp l o v t
837+ do_update_offset ask x offs value exp l o v
843838
844839 let rec affect_move ?(replace_with_const =false ) ask (x :t ) (v :varinfo ) movement_for_expr :t =
845840 let move_fun x = affect_move ~replace_with_const: replace_with_const ask x v movement_for_expr in
0 commit comments