let compute cfg strategy =
debug "[wp-cfg] start computing with the strategy for %a"
WpStrategy.pp_info_of_strategy strategy;
if WpStrategy.strategy_has_prop_goal strategy
|| WpStrategy.strategy_has_asgn_goal strategy then
try
let kf = Cil2cfg.cfg_kf cfg in
if WpStrategy.new_loop_computation strategy then
(match Cil2cfg.very_strange_loops cfg with [] -> ()
| _ ->
Wp_error.unsupported "strange loop(s).")
else
(match Cil2cfg.strange_loops cfg with [] -> ()
| _ ->
Wp_error.unsupported
"non natural loop(s): try [-wp-invariants] option");
let lvars = match WpStrategy.strategy_kind strategy with
| WpStrategy.SKfroms info -> info.WpStrategy.more_vars
| _ -> []
in
let wenv = W.new_env ~lvars kf in
let keep = if Wp_parameters.Dot.get () then true else false in
let res = R.empty ~keep cfg in
let env = (kf, cfg, strategy, res, wenv) in
List.iter add_axiom (WpStrategy.global_axioms strategy) ;
let goal = get_weakest_precondition cfg env in
debug "[get_weakest_precondition] %a@." W.pretty goal;
let pp_cfg_edges_annot res fmt e =
try W.pretty fmt (R.find res e)
with Not_found -> Format.fprintf fmt "<released>"
in
let annot_cfg = pp_cfg_edges_annot res in
debug "[wp-cfg] computing done.";
[goal] , annot_cfg
with Wp_error.Error (_, msg) ->
Wp_parameters.warning "@[calculus failed on strategy@ @[for %a@]@ because@ %s (abort)@]"
WpStrategy.pp_info_of_strategy strategy
msg;
let annot_cfg fmt _e = Format.fprintf fmt "" in
[], annot_cfg
else
begin
debug "[wp-cfg] no goal in this strategy : ignore.";
let annot_cfg fmt _e = Format.fprintf fmt "" in
[], annot_cfg
end