let test_edge_loop_ok cfg strategy edge =
debug "[test_edge_loop_ok] (%s strategy) for %a"
(match strategy with None -> "without" | Some _ -> "with")
Cil2cfg.pp_edge edge;
let rec collect_edge_preds set e =
let cut =
match strategy with None -> Cil2cfg.is_back_edge e
| Some strategy ->
let e_annots = WpStrategy.get_annots strategy e in
(WpStrategy.get_cut e_annots <> [])
in
if cut then ()
else if Cil2cfg.Eset.mem e set
then
raise (Stop e)
else
let set = Cil2cfg.Eset.add e set in
let preds = Cil2cfg.pred_e cfg (Cil2cfg.edge_src e) in
List.iter (collect_edge_preds set) preds
in
try
let _ = collect_edge_preds Cil2cfg.Eset.empty edge in
debug "[test_edge_loop_ok] ok.";
true
with Stop e ->
begin
debug "[test_edge_loop_ok] loop without cut detected at %a"
Cil2cfg.pp_edge e;
false
end