Put goto label map into Context instead of one global map

Summary:public
This will allow us to run translation of more than one function at the same time.

Reviewed By: dulmarod

Differential Revision: D3167965

fb-gh-sync-id: 41e9935
fbshipit-source-id: 41e9935
master
Andrzej Kotulski 9 years ago committed by Facebook Github Bot 6
parent e468d3d189
commit 037b27d465

@ -19,6 +19,8 @@ type curr_class =
| ContextProtocol of string (* category name and corresponding class *)
| ContextNoCls
type str_node_map = (string, Cfg.Node.t) Hashtbl.t
type t =
{
tenv : Tenv.t;
@ -31,6 +33,7 @@ type t =
is_callee_expression : bool;
outer_context : t option; (* in case of objc blocks, the context of the method containing the block *)
mutable blocks_static_vars : ((Pvar.t * Sil.typ) list) Procname.Map.t;
label_map : str_node_map;
}
let create_context tenv cg cfg procdesc curr_class return_param_typ is_objc_method context_opt =
@ -43,7 +46,8 @@ let create_context tenv cg cfg procdesc curr_class return_param_typ is_objc_meth
is_callee_expression = false;
is_objc_method = is_objc_method;
outer_context = context_opt;
blocks_static_vars = Procname.Map.empty
blocks_static_vars = Procname.Map.empty;
label_map = Hashtbl.create 17;
}
let get_cfg context = context.cfg

@ -17,6 +17,8 @@ type curr_class =
| ContextProtocol of string (* category name and corresponding class *)
| ContextNoCls
type str_node_map = (string, Cfg.Node.t) Hashtbl.t
type t =
{
tenv : Tenv.t;
@ -29,6 +31,7 @@ type t =
is_callee_expression : bool;
outer_context : t option; (* in case of objc blocks, the context of the method containing the block *)
mutable blocks_static_vars : ((Pvar.t * Sil.typ) list) Procname.Map.t;
label_map : str_node_map;
}
val get_procdesc : t -> Cfg.Procdesc.t

@ -61,8 +61,6 @@ struct
()
let function_decl tenv cfg cg func_decl block_data_opt =
Printing.log_out "\nResetting the goto_labels hashmap...\n";
CTrans_utils.GotoLabel.reset_all_labels (); (* C Language Std 6.8.6.1-1 *)
let captured_vars, outer_context_opt =
match block_data_opt with
| Some (outer_context, _, _, captured_vars) -> captured_vars, Some outer_context

@ -82,23 +82,19 @@ struct
end
type str_node_map = (string, Cfg.Node.t) Hashtbl.t
module GotoLabel =
struct
(* stores goto labels local to a function, with the relative node in the cfg *)
let goto_label_node_map : str_node_map = Hashtbl.create 17
let reset_all_labels () = Hashtbl.reset goto_label_node_map
let goto_label_node_map : CContext.str_node_map = Hashtbl.create 17
let find_goto_label context label sil_loc =
try
Hashtbl.find goto_label_node_map label
Hashtbl.find context.CContext.label_map label
with Not_found ->
let node_name = Format.sprintf "GotoLabel_%s" label in
let new_node = Nodes.create_node (Cfg.Node.Skip_node node_name) [] [] sil_loc context in
Hashtbl.add goto_label_node_map label new_node;
Hashtbl.add context.CContext.label_map label new_node;
new_node
end

@ -177,9 +177,6 @@ end
module GotoLabel :
sig
val find_goto_label : CContext.t -> string -> Location.t -> Cfg.Node.t
val reset_all_labels : unit -> unit
end
(** Module that provides utility functions for translating different types of loops. *)

Loading…
Cancel
Save