Skip to content

Commit e2cde87

Browse files
committed
Implement proper naïve unassume in var_eq (issue #1710)
1 parent 62e97b9 commit e2cde87

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

src/analyses/varEq.ml

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -397,8 +397,21 @@ struct
397397
(* Probably ok as is. *)
398398
let body man f = man.local
399399

400+
let rec assume ask exp st =
401+
match exp with
402+
| BinOp (Eq, Lval lval, exp, t)
403+
| BinOp (Eq, exp, Lval lval, t) ->
404+
add_eq ask lval exp st
405+
| BinOp (LAnd, e1, e2, _) ->
406+
assume ask e2 (assume ask e1 st)
407+
| _ -> st
408+
400409
(* Branch could be improved to set invariants like base tries to do. *)
401-
let branch man exp tv = man.local
410+
let branch man exp tv =
411+
if tv then
412+
assume (Analyses.ask_of_man man) exp man.local
413+
else
414+
man.local
402415

403416
(* Just remove things that go out of scope. *)
404417
let return man exp fundec =
@@ -578,6 +591,8 @@ struct
578591
|> List.fold_left (fun st lv ->
579592
remove (Analyses.ask_of_man man) lv st
580593
) man.local
594+
|> assume (Analyses.ask_of_man man) exp
595+
|> D.join man.local
581596
| Events.Escape vars ->
582597
if EscapeDomain.EscapedVars.is_top vars then
583598
D.top ()

0 commit comments

Comments
 (0)