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

[CN-Test-Gen] Fix #802 #803

Merged
Show file tree
Hide file tree
Changes from all commits
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
73 changes: 41 additions & 32 deletions backend/cn/lib/testGeneration/genOptimize.ml
Original file line number Diff line number Diff line change
Expand Up @@ -175,39 +175,48 @@ module Fusion = struct
let gt_rest, constraints =
collect_constraints (Sym.Set.add x vars) x its_bounds gt_rest
in
let gt_inner =
let stmts, gt_last = GS.stmts_of_gt (aux (Sym.Set.add i vars) gt_inner) in
let sym_bt, stmts', gt_last =
match gt_last with
| GT (Return (IT (Sym x, x_bt, _)), _, _) -> ((x, x_bt), [], gt_last)
| GT (Return it, ret_bt, loc_ret) ->
let here = Locations.other __LOC__ in
let y = Sym.fresh () in
( (y, ret_bt),
[ GS.Let (0, (y, GT.return_ it loc_ret)) ],
GT.return_ (IT.sym_ (y, ret_bt, here)) loc_ret )
| _ -> failwith (Pp.plain (GT.pp gt_last) ^ " @ " ^ __LOC__)
in
let here = Locations.other __LOC__ in
let stmts'' =
List.map
(fun (j, lc) : GS.t ->
Assert
(LC.T
(replace_index
x
sym_bt
i
(IT.subst (IT.make_subst [ (j, IT.sym_ (i, i_bt, here)) ]) lc))))
constraints
if List.is_empty constraints then
gt
else (
let gt_inner =
let stmts, gt_last = GS.stmts_of_gt (aux (Sym.Set.add i vars) gt_inner) in
let sym_bt, stmts', gt_last =
match gt_last with
| GT (Return (IT (Sym x, x_bt, _)), _, _) -> ((x, x_bt), [], gt_last)
| GT (Return it, ret_bt, loc_ret) ->
let here = Locations.other __LOC__ in
let y = Sym.fresh () in
( (y, ret_bt),
[ GS.Let (0, (y, GT.return_ it loc_ret)) ],
GT.return_ (IT.sym_ (y, ret_bt, here)) loc_ret )
| gt' ->
let ret_bt = GT.bt gt' in
let here = Locations.other __LOC__ in
let y = Sym.fresh () in
( (y, ret_bt),
[ GS.Let (0, (y, gt')) ],
GT.return_ (IT.sym_ (y, ret_bt, here)) (GT.loc gt') )
in
let here = Locations.other __LOC__ in
let stmts'' =
List.map
(fun (j, lc) : GS.t ->
Assert
(LC.T
(replace_index
x
sym_bt
i
(IT.subst (IT.make_subst [ (j, IT.sym_ (i, i_bt, here)) ]) lc))))
constraints
in
GS.gt_of_stmts (stmts @ stmts' @ stmts'') gt_last
in
GS.gt_of_stmts (stmts @ stmts' @ stmts'') gt_last
in
GT.let_
( backtracks,
(x, GT.map_ ((i, i_bt, it_perm), gt_inner) loc_map),
aux (Sym.Set.add x vars) gt_rest )
loc
GT.let_
( backtracks,
(x, GT.map_ ((i, i_bt, it_perm), gt_inner) loc_map),
aux (Sym.Set.add x vars) gt_rest )
loc)
| Let (backtracks, (x, gt_inner), gt_rest) ->
GT.let_
(backtracks, (x, aux vars gt_inner), aux (Sym.Set.add x vars) gt_rest)
Expand Down
12 changes: 12 additions & 0 deletions tests/cn-test-gen/src/sized_array.pass.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
struct foo {
int bar[16];
};

void test_gen_const_array(struct foo* c)
/*@
requires take Client_in = Owned<struct foo>(c);
ensures take Client_out = Owned<struct foo>(c);
@*/
{
return;
}