[closuressubstitution] Flip order of captured variables and actual parameters

Summary: In the frontend captured variables for blocks are added as formal parameters in procdesc at the beginning.

Reviewed By: dulmarod

Differential Revision: D23163619

fbshipit-source-id: 2bcbe9b9c
master
Daiva Naudziuniene 4 years ago committed by Facebook GitHub Bot
parent 2caaa97d2a
commit dcc12d0a42

@ -100,7 +100,7 @@ let replace_instr node (astate : Domain.t) (instr : Sil.instr) : Sil.instr =
let captured_values = let captured_values =
List.map ~f:(fun (id_exp, _, typ, _) -> (id_exp, typ)) c.captured_vars List.map ~f:(fun (id_exp, _, typ, _) -> (id_exp, typ)) c.captured_vars
in in
let actual_params = actual_params @ captured_values in let actual_params = captured_values @ actual_params in
let new_instr = let new_instr =
Sil.Call (ret_id_typ, Const (Cfun c.name), actual_params, loc, call_flags) Sil.Call (ret_id_typ, Const (Cfun c.name), actual_params, loc, call_flags)
in in

@ -17,13 +17,13 @@ int block_captured_var_leak_bad() {
return blk(); return blk();
} }
int block_free_ok() { int block_free_ok(int* y) {
int* x = malloc(sizeof(int)); int* x = malloc(sizeof(int));
*x = 2; *x = 2;
int (^blk)(void) = ^() { int (^blk)(int*) = ^(int* y) {
int i = *x; int i = *x + *y;
free(x); free(x);
return i; return i;
}; };
return blk(); return blk(y);
} }

Loading…
Cancel
Save