|
|
|
@ -43,6 +43,9 @@ module type S = sig
|
|
|
|
|
decl_sym_val:decl_sym_val -> Typ.Procname.t -> Tenv.t -> CFG.node -> Location.t -> depth:int
|
|
|
|
|
-> Loc.t -> Typ.t -> ?offset:Itv.t -> ?size:Itv.t -> inst_num:int -> new_sym_num:counter
|
|
|
|
|
-> new_alloc_num:counter -> Dom.Mem.astate -> Dom.Mem.astate
|
|
|
|
|
|
|
|
|
|
val init_array_fields :
|
|
|
|
|
Tenv.t -> Typ.Procname.t -> CFG.node -> Typ.t -> PowLoc.t -> Dom.Mem.astate -> Dom.Mem.astate
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
module Check : sig
|
|
|
|
@ -125,6 +128,37 @@ module Make (CFG : ProcCfg.S) = struct
|
|
|
|
|
let mem = Dom.Mem.add_heap loc arr mem in
|
|
|
|
|
let deref_loc = Loc.of_allocsite (Sem.get_allocsite pname node inst_num alloc_num) in
|
|
|
|
|
decl_sym_val pname tenv node location ~depth deref_loc typ mem
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let init_array_fields tenv pname node typ locs mem =
|
|
|
|
|
let rec init_field locs dimension (mem, inst_num) (field_name, field_typ, _) =
|
|
|
|
|
let field_loc = PowLoc.append_field locs ~fn:field_name in
|
|
|
|
|
let mem =
|
|
|
|
|
match field_typ.Typ.desc with
|
|
|
|
|
| Tarray (typ, Some length, stride) ->
|
|
|
|
|
let length = Itv.of_int_lit length in
|
|
|
|
|
let stride = Option.map stride ~f:IntLit.to_int in
|
|
|
|
|
let v =
|
|
|
|
|
Sem.eval_array_alloc pname node typ ?stride Itv.zero length inst_num dimension
|
|
|
|
|
in
|
|
|
|
|
Dom.Mem.strong_update_heap field_loc v mem
|
|
|
|
|
| _ ->
|
|
|
|
|
init_fields field_typ field_loc dimension mem
|
|
|
|
|
in
|
|
|
|
|
(mem, inst_num + 1)
|
|
|
|
|
and init_fields typ locs dimension mem =
|
|
|
|
|
match typ.Typ.desc with
|
|
|
|
|
| Tstruct typename -> (
|
|
|
|
|
match Tenv.lookup tenv typename with
|
|
|
|
|
| Some str ->
|
|
|
|
|
List.fold ~f:(init_field locs (dimension + 1)) ~init:(mem, 1) str.Typ.Struct.fields
|
|
|
|
|
|> fst
|
|
|
|
|
| None ->
|
|
|
|
|
mem )
|
|
|
|
|
| _ ->
|
|
|
|
|
mem
|
|
|
|
|
in
|
|
|
|
|
init_fields typ locs 1 mem
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
module Check = struct
|
|
|
|
|