Skip to content

Commit 89a1adf

Browse files
committed
Make Base.get more precise with unknown points during dereference
1 parent c6c62f5 commit 89a1adf

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/analyses/base.ml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ struct
344344
* adding proper dependencies.
345345
* For the exp argument it is always ok to put None. This means not using precise information about
346346
* which part of an array is involved. *)
347-
let rec get ?(full=false) a (gs: glob_fun) (st: store) (addrs:address) (exp:exp option): value =
347+
let rec get ?(top=VD.top ()) ?(full=false) a (gs: glob_fun) (st: store) (addrs:address) (exp:exp option): value =
348348
let at = AD.get_type addrs in
349349
let firstvar = if M.tracing then match AD.to_var_may addrs with [] -> "" | x :: _ -> x.vname else "" in
350350
if M.tracing then M.traceli "get" ~var:firstvar "Address: %a\nState: %a\n" AD.pretty addrs CPA.pretty st.cpa;
@@ -362,7 +362,7 @@ struct
362362
let f = function
363363
| Addr.Addr (x, o) -> f_addr (x, o)
364364
| Addr.NullPtr -> VD.bot () (* TODO: why bot? *)
365-
| Addr.UnknownPtr -> VD.top ()
365+
| Addr.UnknownPtr -> top (* top may be more precise than VD.top, e.g. for address sets, such that known addresses are kept for soundness *)
366366
| Addr.StrPtr _ -> `Int (ID.top_of IChar)
367367
in
368368
(* We form the collecting function by joining *)
@@ -724,7 +724,7 @@ struct
724724
| _ -> false
725725
in
726726
if AD.for_all cast_ok p then
727-
get a gs st p (Some exp) (* downcasts are safe *)
727+
get ~top:(VD.top_value t) a gs st p (Some exp) (* downcasts are safe *)
728728
else
729729
VD.top () (* upcasts not! *)
730730
in

0 commit comments

Comments
 (0)