handling Set(Var, _,) as read of var in liveness analysis

Reviewed By: jvillard

Differential Revision: D3264597

fb-gh-sync-id: efe1982
fbshipit-source-id: efe1982
master
Sam Blackshear 9 years ago committed by Facebook Github Bot 7
parent d4521fd70d
commit ebcfae388a

@ -32,8 +32,7 @@ module TransferFunctions = struct
IList.fold_left (fun astate_acc pvar -> Domain.add (ProgramVar pvar) astate_acc) astate' pvars IList.fold_left (fun astate_acc pvar -> Domain.add (ProgramVar pvar) astate_acc) astate' pvars
let exec_instr astate _ = function let exec_instr astate _ = function
| Sil.Letderef (lhs_id, rhs_exp, _, _) | Sil.Letderef (lhs_id, rhs_exp, _, _) ->
| Sil.Set (Sil.Var lhs_id, _, rhs_exp, _) ->
Domain.remove (LogicalVar lhs_id) astate Domain.remove (LogicalVar lhs_id) astate
|> exp_add_live rhs_exp |> exp_add_live rhs_exp
| Sil.Set (Lvar lhs_pvar, _, rhs_exp, _) -> | Sil.Set (Lvar lhs_pvar, _, rhs_exp, _) ->

@ -30,6 +30,11 @@ let tests =
let unknown_cond = let unknown_cond =
(* don't want to use AnalyzerTest.unknown_exp because we'll treat it as a live var! *) (* don't want to use AnalyzerTest.unknown_exp because we'll treat it as a live var! *)
Sil.exp_zero in Sil.exp_zero in
let id_set_id lhs_id rhs_id =
let lhs_exp = Sil.Var (ident_of_str lhs_id) in
let rhs_exp = Sil.Var (ident_of_str rhs_id) in
let rhs_typ = dummy_typ in
make_set ~rhs_typ ~lhs_exp ~rhs_exp in
let test_list = [ let test_list = [
"basic_live", "basic_live",
[ [
@ -73,6 +78,11 @@ let tests =
invariant "{ y$0 }"; invariant "{ y$0 }";
id_assign_id "x" "y" id_assign_id "x" "y"
]; ];
"set_id",
[
invariant "{ x$0, y$0 }";
id_set_id "x" "y" (* this is *x = y, which is a read of both x and y *)
];
"if_exp_live", "if_exp_live",
[ [
assert_empty; assert_empty;

Loading…
Cancel
Save