Skip to content
Snippets Groups Projects
Commit 5715c2fe authored by Virgile Prevosto's avatar Virgile Prevosto
Browse files

[crowbar] again refine oracle

parent 8dfb226a
No related branches found
No related tags found
No related merge requests found
...@@ -279,6 +279,8 @@ let ghost_case_breaks has_default other_cases = ...@@ -279,6 +279,8 @@ let ghost_case_breaks has_default other_cases =
method! vstmt s = method! vstmt s =
match s.skind with match s.skind with
| Break _ -> raise M.Has_break | Break _ -> raise M.Has_break
| Loop _ | Switch _ -> (* a break there won't break the switch *)
Cil.SkipChildren
| _ -> Cil.DoChildren | _ -> Cil.DoChildren
end end
in in
...@@ -288,6 +290,19 @@ let ghost_case_breaks has_default other_cases = ...@@ -288,6 +290,19 @@ let ghost_case_breaks has_default other_cases =
false false
with M.Has_break -> true with M.Has_break -> true
let rec no_ghost_case_breaks = function
| [] -> false (* should not happen, we have at least one non-ghost case before
default. *)
| stmts :: others ->
if (List.hd stmts).ghost then
begin
match (Extlib.last stmts).skind with
| Break _ -> false
| _ -> no_ghost_case_breaks others
end else true
let gen_case ghost should_break my_case cases env = let gen_case ghost should_break my_case cases env =
let (env,default,others) = cases env in let (env,default,others) = cases env in
let ghost = ghost_status env ghost in let ghost = ghost_status env ghost in
...@@ -314,7 +329,7 @@ let gen_case ghost should_break my_case cases env = ...@@ -314,7 +329,7 @@ let gen_case ghost should_break my_case cases env =
| Case_no_default g1, (_, g2)::_ -> | Case_no_default g1, (_, g2)::_ ->
(* fails iff switch is non-ghost, current case is, and doesn't break, (* fails iff switch is non-ghost, current case is, and doesn't break,
going to the next case. *) going to the next case. *)
not g2 && g1 && not should_break not g2 && g1 && not should_break && no_ghost_case_breaks others
| Case g1, (_,g2) :: _ -> | Case g1, (_,g2) :: _ ->
not g2 && g1 (* prevents taking the default clause.*) not g2 && g1 (* prevents taking the default clause.*)
in in
......
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