Skip to content
Snippets Groups Projects
Commit 330266df authored by Julien Signoles's avatar Julien Signoles
Browse files

[e-acsl] preserve property statuses again

parent dfd5bdf3
No related branches found
No related tags found
No related merge requests found
...@@ -24,17 +24,6 @@ ...@@ -24,17 +24,6 @@
(** {2 Generic code} *) (** {2 Generic code} *)
(* ************************************************************************** *) (* ************************************************************************** *)
let apply_rte f x =
let signed = Kernel.SignedOverflow.get () in
let unsigned = Kernel.UnsignedOverflow.get () in
Kernel.SignedOverflow.off ();
Kernel.UnsignedOverflow.off ();
let finally () =
Kernel.SignedOverflow.set signed;
Kernel.UnsignedOverflow.set unsigned
in
Extlib.try_finally ~finally f x
let warn_rte warn exn = let warn_rte warn exn =
if warn then if warn then
Options.warning "@[@[cannot run RTE:@ %s.@]@ \ Options.warning "@[@[cannot run RTE:@ %s.@]@ \
...@@ -48,30 +37,24 @@ Ignoring potential runtime errors in annotations." ...@@ -48,30 +37,24 @@ Ignoring potential runtime errors in annotations."
open Cil_datatype open Cil_datatype
let stmt ?(warn=true) = let stmt ?(warn=true) =
try try
let f = Dynamic.get
Dynamic.get ~plugin:"RteGen"
~plugin:"RteGen" "stmt_annotations"
"stmt_annotations" (Datatype.func2 Kernel_function.ty Stmt.ty
(Datatype.func2 Kernel_function.ty Stmt.ty (let module L = Datatype.List(Code_annotation) in L.ty))
(let module L = Datatype.List(Code_annotation) in L.ty))
in
(fun x y -> apply_rte (f x) y)
with Failure _ | Dynamic.Unbound_value _ | Dynamic.Incompatible_type _ as exn with Failure _ | Dynamic.Unbound_value _ | Dynamic.Incompatible_type _ as exn
-> ->
warn_rte warn exn; warn_rte warn exn;
fun _ _ -> [] fun _ _ -> []
let exp ?(warn=true) = let exp ?(warn=true) =
try try
let f = Dynamic.get
Dynamic.get ~plugin:"RteGen"
~plugin:"RteGen" "exp_annotations"
"exp_annotations" (Datatype.func3 Kernel_function.ty Stmt.ty Exp.ty
(Datatype.func3 Kernel_function.ty Stmt.ty Exp.ty (let module L = Datatype.List(Code_annotation) in L.ty))
(let module L = Datatype.List(Code_annotation) in L.ty))
in
(fun x y z -> apply_rte (f x y) z)
with Failure _ | Dynamic.Unbound_value _ | Dynamic.Incompatible_type _ as exn with Failure _ | Dynamic.Unbound_value _ | Dynamic.Incompatible_type _ as exn
-> ->
warn_rte warn exn; warn_rte warn exn;
...@@ -79,6 +62,6 @@ let exp ?(warn=true) = ...@@ -79,6 +62,6 @@ let exp ?(warn=true) =
(* (*
Local Variables: Local Variables:
compile-command: "make" compile-command: "make -C ../../../../.."
End: End:
*) *)
...@@ -32,6 +32,6 @@ val exp: ?warn:bool -> kernel_function -> stmt -> exp -> code_annotation list ...@@ -32,6 +32,6 @@ val exp: ?warn:bool -> kernel_function -> stmt -> exp -> code_annotation list
(* (*
Local Variables: Local Variables:
compile-command: "make" compile-command: "make -C ../../../../.."
End: End:
*) *)
...@@ -50,9 +50,6 @@ let generate_code = ...@@ -50,9 +50,6 @@ let generate_code =
(fun name -> (fun name ->
Options.feedback "beginning translation."; Options.feedback "beginning translation.";
Temporal.enable (Options.Temporal_validity.get ()); Temporal.enable (Options.Temporal_validity.get ());
let rtl_prj =
Project.create_by_copy ~last:false "E_ACSL RTL"
in
if Plugin.is_present "variadic" then begin if Plugin.is_present "variadic" then begin
let opt_name = "-variadic-translation" in let opt_name = "-variadic-translation" in
if Dynamic.Parameter.Bool.get opt_name () then begin if Dynamic.Parameter.Bool.get opt_name () then begin
...@@ -64,6 +61,11 @@ let generate_code = ...@@ -64,6 +61,11 @@ let generate_code =
Dynamic.Parameter.Bool.off opt_name (); Dynamic.Parameter.Bool.off opt_name ();
end end
end; end;
(* slightly more efficient to copy the project before computing the AST
if it is not yet computed *)
let rtl_prj = Project.create_by_copy ~last:false "E_ACSL RTL" in
(* TODO: remove [rtl_prj] after use if no debug mode *)
(* force AST computation before copying the project it belongs to *)
Ast.compute (); Ast.compute ();
let copied_prj = Project.create_by_copy ~last:true name in let copied_prj = Project.create_by_copy ~last:true name in
Project.on Project.on
...@@ -72,7 +74,21 @@ let generate_code = ...@@ -72,7 +74,21 @@ let generate_code =
(* preparation of the AST does not concern the E-ACSL RTL *) (* preparation of the AST does not concern the E-ACSL RTL *)
Prepare_ast.prepare (); Prepare_ast.prepare ();
Rtl.link rtl_prj; Rtl.link rtl_prj;
Injector.inject (); (* the E-ACSL type system ensures the soundness of the generated
arithmetic operations. Therefore, deactivate the corresponding
options in order to prevent RTE to generate spurious alarms. *)
let signed = Kernel.SignedOverflow.get () in
let unsigned = Kernel.UnsignedOverflow.get () in
(* we do know that setting these flags does not modify the program's
semantics: using their unsafe variants is thus safe and preserve
all emitted property statuses. *)
Kernel.SignedOverflow.unsafe_set false;
Kernel.UnsignedOverflow.unsafe_set false;
let finally () =
Kernel.SignedOverflow.unsafe_set signed;
Kernel.UnsignedOverflow.unsafe_set unsigned
in
Extlib.try_finally ~finally Injector.inject ();
(* remove the RTE's results computed from E-ACSL: they are partial (* remove the RTE's results computed from E-ACSL: they are partial
and associated with the wrong kernel function (the one of the old and associated with the wrong kernel function (the one of the old
project). *) project). *)
......
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