Skip to content
Snippets Groups Projects
Commit cb6150a1 authored by Allan Blanchard's avatar Allan Blanchard
Browse files

[wp] Generate RTE before getting cfg infos

parent 00ea6982
No related branches found
No related tags found
No related merge requests found
...@@ -45,6 +45,13 @@ let empty () = { ...@@ -45,6 +45,13 @@ let empty () = {
(* --- Property Guided Selection --- *) (* --- Property Guided Selection --- *)
(* -------------------------------------------------------------------------- *) (* -------------------------------------------------------------------------- *)
let get_kf_infos model kf ?bhv ?prop () =
if WpRTE.missing_guards model kf then
Wp_parameters.warning ~current:false ~once:true "Missing RTE guards"
else if Wp_parameters.RTE.get () then
WpRTE.generate model kf ;
CfgInfos.get kf ?bhv ?prop ()
let empty_default_behavior : funbehavior = { let empty_default_behavior : funbehavior = {
b_name = Cil.default_behavior_name ; b_name = Cil.default_behavior_name ;
b_requires = [] ; b_requires = [] ;
...@@ -73,10 +80,10 @@ let lemma task ?(prop=[]) l = ...@@ -73,10 +80,10 @@ let lemma task ?(prop=[]) l =
(prop=[] || WpPropId.select_by_name prop (WpPropId.mk_lemma_id l)) (prop=[] || WpPropId.select_by_name prop (WpPropId.mk_lemma_id l))
then task.lemmas <- l :: task.lemmas then task.lemmas <- l :: task.lemmas
let apply task ~kf ?infos ?bhvs ?target () = let apply model task ~kf ?infos ?bhvs ?target () =
let infos = match infos with let infos = match infos with
| Some infos -> infos | Some infos -> infos
| None -> CfgInfos.get kf () in | None -> get_kf_infos model kf () in
let bhvs = match bhvs with let bhvs = match bhvs with
| Some bhvs -> bhvs | Some bhvs -> bhvs
| None -> | None ->
...@@ -95,15 +102,15 @@ let notyet prop = ...@@ -95,15 +102,15 @@ let notyet prop =
Wp_parameters.warning ~once:true Wp_parameters.warning ~once:true
"Not yet implemented wp for '%a'" Property.pretty prop "Not yet implemented wp for '%a'" Property.pretty prop
let rec strategy_ip task target = let rec strategy_ip model task target =
let open Property in let open Property in
match target with match target with
| IPLemma { il_name } -> | IPLemma { il_name } ->
lemma task (LogicUsage.logic_lemma il_name) lemma task (LogicUsage.logic_lemma il_name)
| IPAxiomatic { iax_props } -> | IPAxiomatic { iax_props } ->
List.iter (strategy_ip task) iax_props List.iter (strategy_ip model task) iax_props
| IPBehavior { ib_kf = kf ; ib_bhv = bhv } -> | IPBehavior { ib_kf = kf ; ib_bhv = bhv } ->
apply task ~kf ~bhvs:[bhv] () apply model task ~kf ~bhvs:[bhv] ()
| IPPredicate { ip_kf = kf ; ip_kind ; ip_kinstr = ki } -> | IPPredicate { ip_kf = kf ; ip_kind ; ip_kinstr = ki } ->
begin match ip_kind with begin match ip_kind with
| PKAssumes _ -> () | PKAssumes _ -> ()
...@@ -111,37 +118,37 @@ let rec strategy_ip task target = ...@@ -111,37 +118,37 @@ let rec strategy_ip task target =
begin begin
match ki with match ki with
| Kglobal -> (*TODO*) notyet target | Kglobal -> (*TODO*) notyet target
| Kstmt _ -> apply task ~kf ~bhvs:[bhv] ~target () | Kstmt _ -> apply model task ~kf ~bhvs:[bhv] ~target ()
end end
| PKEnsures(bhv,_) -> | PKEnsures(bhv,_) ->
apply task ~kf ~bhvs:[bhv] ~target () apply model task ~kf ~bhvs:[bhv] ~target ()
| PKTerminates -> | PKTerminates ->
apply task ~kf ~bhvs:(default kf) ~target () apply model task ~kf ~bhvs:(default kf) ~target ()
end end
| IPDecrease { id_kf = kf } -> | IPDecrease { id_kf = kf } ->
apply task ~kf ~bhvs:(default kf) ~target () apply model task ~kf ~bhvs:(default kf) ~target ()
| IPAssigns { ias_kf=kf ; ias_bhv=Id_loop ca } | IPAssigns { ias_kf=kf ; ias_bhv=Id_loop ca }
| IPAllocation { ial_kf=kf ; ial_bhv=Id_loop ca } -> | IPAllocation { ial_kf=kf ; ial_bhv=Id_loop ca } ->
let bhvs = match ca.annot_content with let bhvs = match ca.annot_content with
| AAssigns(bhvs,_) | AAllocation(bhvs,_) -> bhvs | AAssigns(bhvs,_) | AAllocation(bhvs,_) -> bhvs
| _ -> [] in | _ -> [] in
apply task ~kf ~bhvs:(select kf bhvs) ~target () apply model task ~kf ~bhvs:(select kf bhvs) ~target ()
| IPAssigns { ias_kf=kf ; ias_bhv=Id_contract(_,bhv) } | IPAssigns { ias_kf=kf ; ias_bhv=Id_contract(_,bhv) }
| IPAllocation { ial_kf=kf ; ial_bhv=Id_contract(_,bhv) } | IPAllocation { ial_kf=kf ; ial_bhv=Id_contract(_,bhv) }
-> apply task ~kf ~bhvs:[bhv] ~target () -> apply model task ~kf ~bhvs:[bhv] ~target ()
| IPCodeAnnot { ica_kf = kf ; ica_ca = ca } -> | IPCodeAnnot { ica_kf = kf ; ica_ca = ca } ->
begin match ca.annot_content with begin match ca.annot_content with
| AExtended _ | APragma _ -> () | AExtended _ | APragma _ -> ()
| AStmtSpec(fors,_) -> | AStmtSpec(fors,_) ->
(*TODO*) notyet target ; (*TODO*) notyet target ;
apply task ~kf ~bhvs:(select kf fors) () apply model task ~kf ~bhvs:(select kf fors) ()
| AVariant _ -> | AVariant _ ->
apply task ~kf ~target () apply model task ~kf ~target ()
| AAssert(fors, _) | AAssert(fors, _)
| AInvariant(fors, _, _) | AInvariant(fors, _, _)
| AAssigns(fors, _) | AAssigns(fors, _)
| AAllocation(fors, _) -> | AAllocation(fors, _) ->
apply task ~kf ~bhvs:(select kf fors) ~target () apply model task ~kf ~bhvs:(select kf fors) ~target ()
end end
| IPComplete _ -> (*TODO*) notyet target | IPComplete _ -> (*TODO*) notyet target
| IPDisjoint _ -> (*TODO*) notyet target | IPDisjoint _ -> (*TODO*) notyet target
...@@ -149,18 +156,18 @@ let rec strategy_ip task target = ...@@ -149,18 +156,18 @@ let rec strategy_ip task target =
| IPPropertyInstance _ -> notyet target (* ? *) | IPPropertyInstance _ -> notyet target (* ? *)
| IPExtended _ | IPAxiom _ | IPOther _ -> () | IPExtended _ | IPAxiom _ | IPOther _ -> ()
let strategy_main task ?(fct=Fct_all) ?(bhv=[]) ?(prop=[]) () = let strategy_main model task ?(fct=Fct_all) ?(bhv=[]) ?(prop=[]) () =
begin begin
if fct = Fct_all && bhv = [] then if fct = Fct_all && bhv = [] then
LogicUsage.iter_lemmas (lemma task ~prop) ; LogicUsage.iter_lemmas (lemma task ~prop) ;
Wp_parameters.iter_fct Wp_parameters.iter_fct
(fun kf -> (fun kf ->
if Kernel_function.has_definition kf then if Kernel_function.has_definition kf then
let infos = CfgInfos.get kf ~bhv ~prop () in let infos = get_kf_infos model kf ~bhv ~prop () in
if CfgInfos.annots infos then if CfgInfos.annots infos then
if bhv=[] if bhv=[]
then apply task ~infos ~kf () then apply model task ~infos ~kf ()
else apply task ~infos ~kf ~bhvs:(select kf bhv) () else apply model task ~infos ~kf ~bhvs:(select kf bhv) ()
) fct ; ) fct ;
task.props <- (if prop=[] then `All else `Names prop); task.props <- (if prop=[] then `All else `Names prop);
end end
...@@ -195,8 +202,6 @@ struct ...@@ -195,8 +202,6 @@ struct
WpContext.on_context (model,WpContext.Kf mode.kf) WpContext.on_context (model,WpContext.Kf mode.kf)
begin fun () -> begin fun () ->
LogicUsage.iter_lemmas VCG.register_lemma ; LogicUsage.iter_lemmas VCG.register_lemma ;
if WpRTE.missing_guards model mode.kf then
warning ~current:false ~once:true "Missing RTE guards" ;
let bhv = let bhv =
if Cil.is_default_behavior mode.bhv then None if Cil.is_default_behavior mode.bhv then None
else Some mode.bhv.b_name in else Some mode.bhv.b_name in
...@@ -214,7 +219,7 @@ struct ...@@ -214,7 +219,7 @@ struct
let compute_ip model ip = let compute_ip model ip =
let task = empty () in let task = empty () in
strategy_ip task ip ; strategy_ip model task ip ;
compute model task compute model task
let compute_call _model _stmt = let compute_call _model _stmt =
...@@ -224,7 +229,7 @@ struct ...@@ -224,7 +229,7 @@ struct
let compute_main model ?fct ?bhv ?prop () = let compute_main model ?fct ?bhv ?prop () =
let task = empty () in let task = empty () in
strategy_main task ?fct ?bhv ?prop () ; strategy_main model task ?fct ?bhv ?prop () ;
compute model task compute model task
end end
...@@ -283,12 +288,12 @@ let dumper setup driver = ...@@ -283,12 +288,12 @@ let dumper setup driver =
method model = model method model = model
method compute_ip ip = method compute_ip ip =
let task = empty () in let task = empty () in
strategy_ip task ip ; strategy_ip model task ip ;
dump task ; Bag.empty dump task ; Bag.empty
method compute_call _ = Bag.empty method compute_call _ = Bag.empty
method compute_main ?fct ?bhv ?prop () = method compute_main ?fct ?bhv ?prop () =
let task = empty () in let task = empty () in
strategy_main task ?fct ?bhv ?prop () ; strategy_main model task ?fct ?bhv ?prop () ;
dump task ; Bag.empty dump task ; Bag.empty
end end
in generator in generator
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment