let process_unreached_annots cfg =
debug "collecting unreachable annotations@.";
let unreached = Cil2cfg.unreachable_nodes cfg in
let kf = Cil2cfg.cfg_kf cfg in
let spec = Kernel_function.get_spec kf in
let add_id id acc =
if filter_status id then id::acc
else acc
in
let do_post b tk acc (termk, _ as p) =
if tk = termk then add_id (WpPropId.mk_fct_post_id kf b p) acc else acc
in
let do_bhv termk acc b = List.fold_left (do_post b termk) acc b.b_post_cond in
let do_annot s a acc =
let ca = match a with User ca | AI (_, ca) -> ca in
add_id (WpPropId.mk_code_annot_id kf s ca) acc
in
let do_node acc n =
debug
"process annotations of unreachable node %a@."
Cil2cfg.pp_node_type n;
match n with
| Cil2cfg.Vstart -> Wp_parameters.fatal "Start must be reachable"
| Cil2cfg.VfctIn -> Wp_parameters.fatal "FctIn must be reachable"
| Cil2cfg.VfctOut -> List.fold_left (do_bhv Normal) acc spec.spec_behavior
| Cil2cfg.Vexit -> List.fold_left (do_bhv Exits) acc spec.spec_behavior
| Cil2cfg.Vstmt s
| Cil2cfg.VblkIn (Cil2cfg.Bstmt s, _) | Cil2cfg.Vcall (s, _, _, _)
| Cil2cfg.Vtest (true, s, _) | Cil2cfg.Vloop (_, s) | Cil2cfg.Vswitch (s,_)
-> Annotations.single_fold_stmt (do_annot s) s acc
| Cil2cfg.Vtest (false, _, _) | Cil2cfg.Vloop2 _
| Cil2cfg.VblkIn _ | Cil2cfg.VblkOut _ | Cil2cfg.Vend -> acc
in
let annots = List.fold_left do_node [] unreached in
debug
"found %d unreachable annotations@." (List.length annots) ;
List.iter (fun pid -> set_unreachable pid) annots