diff --git a/infer/src/clang/cContext.ml b/infer/src/clang/cContext.ml index e8ec78010..e47f0b464 100644 --- a/infer/src/clang/cContext.ml +++ b/infer/src/clang/cContext.ml @@ -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 diff --git a/infer/src/clang/cContext.mli b/infer/src/clang/cContext.mli index e10a37149..261cb4fdc 100644 --- a/infer/src/clang/cContext.mli +++ b/infer/src/clang/cContext.mli @@ -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 diff --git a/infer/src/clang/cFrontend_decl.ml b/infer/src/clang/cFrontend_decl.ml index f1f7d6631..9265a2796 100644 --- a/infer/src/clang/cFrontend_decl.ml +++ b/infer/src/clang/cFrontend_decl.ml @@ -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 diff --git a/infer/src/clang/cTrans_utils.ml b/infer/src/clang/cTrans_utils.ml index 9b33a9316..f0d01a8f0 100644 --- a/infer/src/clang/cTrans_utils.ml +++ b/infer/src/clang/cTrans_utils.ml @@ -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 diff --git a/infer/src/clang/cTrans_utils.mli b/infer/src/clang/cTrans_utils.mli index de6ea0f06..b1cbfe7aa 100644 --- a/infer/src/clang/cTrans_utils.mli +++ b/infer/src/clang/cTrans_utils.mli @@ -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. *)