Add new Ident.create_fresh function to avoid clashes specialized objc blocks

Reviewed By: dulmarod

Differential Revision: D8767847

fbshipit-source-id: a731a4a
master
Martin Trojer 6 years ago committed by Facebook Github Bot
parent 2d73494e87
commit a07877dcbb

@ -180,6 +180,13 @@ let create_normal name stamp = create_with_stamp KNormal name stamp
(** Create a fresh identifier with default name for the given kind. *) (** Create a fresh identifier with default name for the given kind. *)
let create_fresh kind = NameGenerator.create_fresh_ident kind (standard_name kind) let create_fresh kind = NameGenerator.create_fresh_ident kind (standard_name kind)
let create_fresh_specialized_with_blocks kind =
let fid = create_fresh kind in
(* The stamps are per-procedure unique, add a big enough number to effectively create
a namespace for vars in objc blocks *)
{fid with stamp= fid.stamp + 10000}
let create_none () = create_fresh KNone let create_none () = create_fresh KNone
(** Generate a footprint identifier with the given name and stamp *) (** Generate a footprint identifier with the given name and stamp *)

@ -94,6 +94,9 @@ val update_name_generator : t list -> unit
val create_fresh : kind -> t val create_fresh : kind -> t
(** Create a fresh identifier with default name for the given kind. *) (** Create a fresh identifier with default name for the given kind. *)
val create_fresh_specialized_with_blocks : kind -> t
(** Create a fresh identifier with default name for the given kind, with a non-clashing id for objc block specialization *)
val create_path : string -> t val create_path : string -> t
(** Generate a normal identifier whose name encodes a path given as a string. *) (** Generate a normal identifier whose name encodes a path given as a string. *)

@ -736,7 +736,7 @@ let specialize_with_block_args_instrs resolved_pdesc substitutions =
let block_name, extra_formals = Mangled.Map.find block_var substitutions in let block_name, extra_formals = Mangled.Map.find block_var substitutions in
let ids, id_exp_typs, load_instrs = let ids, id_exp_typs, load_instrs =
List.map extra_formals ~f:(fun (var, typ) -> List.map extra_formals ~f:(fun (var, typ) ->
let id = Ident.create_fresh Ident.knormal in let id = Ident.create_fresh_specialized_with_blocks Ident.knormal in
let pvar = Pvar.mk var resolved_pname in let pvar = Pvar.mk var resolved_pname in
(id, (Exp.Var id, pvar, typ), Sil.Load (id, Exp.Lvar pvar, typ, loc)) ) (id, (Exp.Var id, pvar, typ), Sil.Load (id, Exp.Lvar pvar, typ, loc)) )
|> List.unzip3 |> List.unzip3

Loading…
Cancel
Save