[IR] kill Cfg.set_procname_priority

Summary: That data was never used and removing it can simplify frontends quite a bit.

Reviewed By: jberdine

Differential Revision: D3967389

fbshipit-source-id: d65c3da
master
Andrzej Kotulski 8 years ago committed by Facebook Github Bot
parent 18f6190432
commit 6251aad101

@ -852,14 +852,6 @@ let get_all_procs cfg => {
let get_defined_procs cfg => IList.filter Procdesc.is_defined (get_all_procs cfg); let get_defined_procs cfg => IList.filter Procdesc.is_defined (get_all_procs cfg);
/** get the function names which should be analyzed before the other ones */
let get_priority_procnames cfg => cfg.Node.priority_set;
/** set the function names whose address has been taken in this file */
let set_procname_priority cfg pname =>
cfg.Node.priority_set = Procname.Set.add pname cfg.Node.priority_set;
/** checks whether a cfg is connected or not */ /** checks whether a cfg is connected or not */
let check_cfg_connectedness cfg => { let check_cfg_connectedness cfg => {
let is_exit_node n => let is_exit_node n =>

@ -292,14 +292,6 @@ let get_all_procs: cfg => list Procdesc.t;
let get_defined_procs: cfg => list Procdesc.t; let get_defined_procs: cfg => list Procdesc.t;
/** get the function names which should be analyzed before the other ones */
let get_priority_procnames: cfg => Procname.Set.t;
/** set the function names whose address has been taken in this file */
let set_procname_priority: cfg => Procname.t => unit;
/** checks whether a cfg is connected or not */ /** checks whether a cfg is connected or not */
let check_cfg_connectedness: cfg => unit; let check_cfg_connectedness: cfg => unit;

@ -33,7 +33,6 @@ type t =
is_objc_method : bool; is_objc_method : bool;
curr_class: curr_class; curr_class: curr_class;
return_param_typ : Typ.t option; return_param_typ : Typ.t option;
is_callee_expression : bool;
outer_context : t option; (* in case of objc blocks, the context of the method containing the block *) outer_context : t option; (* in case of objc blocks, the context of the method containing the block *)
mutable blocks_static_vars : ((Pvar.t * Typ.t) list) Procname.Map.t; mutable blocks_static_vars : ((Pvar.t * Typ.t) list) Procname.Map.t;
label_map : str_node_map; label_map : str_node_map;
@ -46,7 +45,6 @@ let create_context tenv cg cfg procdesc curr_class return_param_typ is_objc_meth
procdesc = procdesc; procdesc = procdesc;
curr_class = curr_class; curr_class = curr_class;
return_param_typ = return_param_typ; return_param_typ = return_param_typ;
is_callee_expression = false;
is_objc_method = is_objc_method; is_objc_method = is_objc_method;
outer_context = context_opt; outer_context = context_opt;
blocks_static_vars = Procname.Map.empty; blocks_static_vars = Procname.Map.empty;

@ -31,7 +31,6 @@ type t =
is_objc_method : bool; is_objc_method : bool;
curr_class: curr_class; curr_class: curr_class;
return_param_typ : Typ.t option; return_param_typ : Typ.t option;
is_callee_expression : bool;
outer_context : t option; (* in case of objc blocks, the context of the method containing the block *) outer_context : t option; (* in case of objc blocks, the context of the method containing the block *)
mutable blocks_static_vars : ((Pvar.t * Typ.t) list) Procname.Map.t; mutable blocks_static_vars : ((Pvar.t * Typ.t) list) Procname.Map.t;
label_map : str_node_map; label_map : str_node_map;

@ -460,12 +460,6 @@ struct
let pname = match get_builtin_pname_opt name decl_opt type_ptr with let pname = match get_builtin_pname_opt name decl_opt type_ptr with
| Some builtin_pname -> builtin_pname | Some builtin_pname -> builtin_pname
| None -> CMethod_trans.create_procdesc_with_pointer context decl_ptr None name in | None -> CMethod_trans.create_procdesc_with_pointer context decl_ptr None name in
let address_of_function = not context.CContext.is_callee_expression in
(* If we are not translating a callee expression, *)
(* then the address of the function is being taken.*)
(* As e.g. in fun_ptr = foo; *)
let is_builtin = Builtin.is_registered pname in
if address_of_function && not is_builtin then Cfg.set_procname_priority context.cfg pname;
{ empty_res_trans with exps = [(Exp.Const (Const.Cfun pname), typ)] } { empty_res_trans with exps = [(Exp.Const (Const.Cfun pname), typ)] }
let field_deref_trans trans_state stmt_info pre_trans_result decl_ref ~is_constructor_init = let field_deref_trans trans_state stmt_info pre_trans_result decl_ref ~is_constructor_init =
@ -544,7 +538,6 @@ struct
else else
(* don't add 'this' expression for static methods *) (* don't add 'this' expression for static methods *)
[], [] in [], [] in
(* consider using context.CContext.is_callee_expression to deal with pointers to methods? *)
(* unlike field access, for method calls there is no need to expand class type *) (* unlike field access, for method calls there is no need to expand class type *)
(* use qualified method name for builtin matching, but use unqualified name elsewhere *) (* use qualified method name for builtin matching, but use unqualified name elsewhere *)
@ -552,10 +545,8 @@ struct
let pname = match get_builtin_pname_opt qual_method_name decl_opt type_ptr with let pname = match get_builtin_pname_opt qual_method_name decl_opt type_ptr with
| Some builtin_pname -> builtin_pname | Some builtin_pname -> builtin_pname
| None -> | None ->
let pname = CMethod_trans.create_procdesc_with_pointer context decl_ptr (Some class_name) CMethod_trans.create_procdesc_with_pointer context decl_ptr (Some class_name)
method_name in method_name in
Cfg.set_procname_priority context.CContext.cfg pname;
pname in
let method_exp = (Exp.Const (Const.Cfun pname), method_typ) in let method_exp = (Exp.Const (Const.Cfun pname), method_typ) in
{ pre_trans_result with { pre_trans_result with
is_cpp_call_virtual = is_cpp_virtual; is_cpp_call_virtual = is_cpp_virtual;
@ -832,8 +823,7 @@ struct
| _ -> assert false) in | _ -> assert false) in
let trans_state_pri = PriorityNode.try_claim_priority_node trans_state si in let trans_state_pri = PriorityNode.try_claim_priority_node trans_state si in
(* claim priority if no ancestors has claimed priority before *) (* claim priority if no ancestors has claimed priority before *)
let context_callee = { context with CContext.is_callee_expression = true } in let trans_state_callee = { trans_state_pri with succ_nodes = [] } in
let trans_state_callee = { trans_state_pri with context = context_callee; succ_nodes = [] } in
let res_trans_callee = instruction trans_state_callee fun_exp_stmt in let res_trans_callee = instruction trans_state_callee fun_exp_stmt in
let (sil_fe, _) = extract_exp_from_list res_trans_callee.exps let (sil_fe, _) = extract_exp_from_list res_trans_callee.exps
"WARNING: The translation of fun_exp did not return an expression.\ "WARNING: The translation of fun_exp did not return an expression.\
@ -2014,7 +2004,7 @@ struct
let procname = Cfg.Procdesc.get_proc_name context.CContext.procdesc in let procname = Cfg.Procdesc.get_proc_name context.CContext.procdesc in
let loc = let loc =
(match stmt_info.Clang_ast_t.si_source_range with (l1, _) -> (match stmt_info.Clang_ast_t.si_source_range with (l1, _) ->
CLocation.clang_to_sil_location l1 (Some context.CContext.procdesc)) in CLocation.clang_to_sil_location l1 (Some context.CContext.procdesc)) in
(* Given a captured var, return the instruction to assign it to a temp *) (* Given a captured var, return the instruction to assign it to a temp *)
let assign_captured_var (cvar, typ) = let assign_captured_var (cvar, typ) =
let id = Ident.create_fresh Ident.knormal in let id = Ident.create_fresh Ident.knormal in
@ -2035,7 +2025,6 @@ struct
let ids, instrs = IList.split ids_instrs in let ids, instrs = IList.split ids_instrs in
let block_data = (context, type_ptr, block_pname, captureds) in let block_data = (context, type_ptr, block_pname, captureds) in
F.function_decl context.tenv context.cfg context.cg decl (Some block_data); F.function_decl context.tenv context.cfg context.cg decl (Some block_data);
Cfg.set_procname_priority context.cfg block_pname;
let captured_vars = let captured_vars =
IList.map2 (fun id (pvar, typ) -> (Exp.Var id, pvar, typ)) ids captureds in IList.map2 (fun id (pvar, typ) -> (Exp.Var id, pvar, typ)) ids captureds in
let closure = Exp.Closure { name=block_pname; captured_vars } in let closure = Exp.Closure { name=block_pname; captured_vars } in

@ -107,7 +107,6 @@ let add_cmethod source_file program icfg node cm is_static =
let procname = Cfg.Procdesc.get_proc_name procdesc in let procname = Cfg.Procdesc.get_proc_name procdesc in
add_edges context start_node exn_node [exit_node] method_body_nodes impl false; add_edges context start_node exn_node [exit_node] method_body_nodes impl false;
Cg.add_defined_node icfg.JContext.cg procname; Cg.add_defined_node icfg.JContext.cg procname;
if Procname.is_constructor procname then Cfg.set_procname_priority cfg procname
| JTrans.Called _ -> () | JTrans.Called _ -> ()

Loading…
Cancel
Save