Skip to content

Commit

Permalink
Exclude witness invariants with __anon structs
Browse files Browse the repository at this point in the history
  • Loading branch information
sim642 committed Mar 1, 2024
1 parent 0aa6a90 commit d3ef633
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 12 deletions.
16 changes: 16 additions & 0 deletions src/cdomain/value/domains/invariantCil.ml
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,22 @@ let exp_contains_tmp e =
ignore (visitCilExpr visitor e);
!acc

class exp_contains_anon_type_visitor = object
inherit nopCilVisitor
method! vtype (t: typ) =
match t with
| TComp ({cname; _}, _) when BatString.starts_with_stdlib ~prefix:"__anon" cname ->
raise Stdlib.Exit
| _ ->
DoChildren
end
let exp_contains_anon_type e = (* TODO: curry to create object only once *)
let visitor = new exp_contains_anon_type_visitor in
match visitCilExpr visitor e with
| _ -> false
| exception Stdlib.Exit -> true


(* TODO: synchronize magic constant with BaseDomain *)
let var_is_heap {vname; _} = BatString.starts_with vname "(alloc@"

Expand Down
1 change: 1 addition & 0 deletions src/witness/witnessUtil.ml
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ struct
in
if GobConfig.get_bool "witness.invariant.split-conjunction" then
ES.elements (pullOutCommonConjuncts inv')
|> List.filter (Fun.negate InvariantCil.exp_contains_anon_type)
else
[inv']
end
Expand Down
13 changes: 1 addition & 12 deletions tests/regression/witness/typedef.t/run.t
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
dead: 0
total lines: 6
[Info][Witness] witness generation summary:
total generation entries: 14
total generation entries: 13

$ yamlWitnessStrip < witness.yml
- entry_type: location_invariant
Expand Down Expand Up @@ -62,17 +62,6 @@
string: '*((int *)p) == 42'
type: assertion
format: C
- entry_type: location_invariant
location:
file_name: typedef.c
file_hash: $FILE_HASH
line: 14
column: 2
function: main
location_invariant:
string: ((struct __anonstruct_s_109580352 *)q)->f == 43
type: assertion
format: C
- entry_type: location_invariant
location:
file_name: typedef.c
Expand Down

0 comments on commit d3ef633

Please sign in to comment.