Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exclude Goblint stubs from YAML witnesses #1334

Merged
merged 2 commits into from
Feb 7, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions src/witness/yamlWitness.ml
Original file line number Diff line number Diff line change
Expand Up @@ -193,15 +193,25 @@ struct
in
let task = Entry.task ~input_files ~data_model ~specification in

let is_stub_node n =
let fundec = Node.find_fundec n in
Cil.hasAttribute "goblint_stub" fundec.svar.vattr
in

let is_invariant_node (n : Node.t) =
let loc = Node.location n in
match n with
| Statement _ when not loc.synthetic && WitnessInvariant.is_invariant_node n -> true
| Statement _ when not loc.synthetic && WitnessInvariant.is_invariant_node n ->
not (is_stub_node n)
sim642 marked this conversation as resolved.
Show resolved Hide resolved
| _ ->
(* avoid FunctionEntry/Function, because their locations are not inside the function where asserts could be inserted *)
false
in

let is_loop_head_node n =
WitnessUtil.NH.mem WitnessInvariant.loop_heads n && not (is_stub_node n)
in

let local_lvals n local =
if GobConfig.get_bool "witness.invariant.accessed" then (
match R.ask_local_node n ~local MayAccessed with
Expand Down Expand Up @@ -277,7 +287,7 @@ struct
let entries =
if entry_type_enabled YamlWitnessType.LoopInvariant.entry_type then (
LH.fold (fun loc ns acc ->
if WitnessInvariant.emit_loop_head && List.exists (WitnessUtil.NH.mem WitnessInvariant.loop_heads) ns then (
if WitnessInvariant.emit_loop_head && List.exists is_loop_head_node ns then (
let inv = List.fold_left (fun acc n ->
let local = try NH.find (Lazy.force nh) n with Not_found -> Spec.D.bot () in
Invariant.(acc || R.ask_local_node n ~local (Invariant Invariant.default_context)) [@coverage off] (* bisect_ppx cannot handle redefined (||) *)
Expand Down Expand Up @@ -472,7 +482,7 @@ struct
let invariants =
if invariant_type_enabled YamlWitnessType.InvariantSet.LoopInvariant.invariant_type then (
LH.fold (fun loc ns acc ->
if WitnessInvariant.emit_loop_head && List.exists (WitnessUtil.NH.mem WitnessInvariant.loop_heads) ns then (
if WitnessInvariant.emit_loop_head && List.exists is_loop_head_node ns then (
let inv = List.fold_left (fun acc n ->
let local = try NH.find (Lazy.force nh) n with Not_found -> Spec.D.bot () in
Invariant.(acc || R.ask_local_node n ~local (Invariant Invariant.default_context)) [@coverage off] (* bisect_ppx cannot handle redefined (||) *)
Expand Down