[clang] Remove call to create_local_procdesc and create it only when it's called.

master
Dulma Rodriguez 10 years ago
parent 092e447ce3
commit b79028af32

@ -159,9 +159,7 @@ struct
CMethod_signature.add ms;
add_method tenv cg cfg curr_class procname namespace [body] is_objc_method is_instance
captured_vars is_anonym_block fdecl_info.Clang_ast_t.fdi_parameters attributes
| None, ms ->
CMethod_trans.create_local_procdesc cfg tenv ms [] captured_vars false;
CMethod_signature.add ms
| None, ms -> CMethod_signature.add ms
let process_objc_method_decl tenv cg cfg namespace curr_class decl_info method_name method_decl_info =
let class_name = CContext.get_curr_class_name curr_class in

@ -300,7 +300,6 @@ struct
| Some v ->
CMethod_trans.mk_procname_from_function name v, CTypes_decl.parse_func_type name v
| None -> Procname.from_string name, None in
CMethod_trans.create_external_procdesc context.cfg pname false type_opt;
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; *)
@ -539,28 +538,9 @@ struct
(* verbatim from a call to a different function, and they might be side-effecting *)
(Procname.to_string pn) <> CFrontend_config.builtin_object_size
| _ -> true in
let assign_default_params params_stmt =
match callee_pname_opt with
| None -> params_stmt
| Some callee_pname ->
try
let callee_ms = CMethod_signature.find callee_pname in
let args = CMethod_signature.ms_get_args callee_ms in
let params_args = list_combine params_stmt args in
let replace_default_arg param =
match param with
| CXXDefaultArgExpr(_, _, _), (_, _, Some default_instr) -> default_instr
| instr, _ -> instr in
list_map replace_default_arg params_args
with
| Invalid_argument _ ->
(* list_combine failed because of different list lengths *)
Printing.log_err "Param count doesn't match %s\n" (Procname.to_string callee_pname);
params_stmt
| Not_found -> params_stmt in
let params_stmt = if should_translate_args then assign_default_params params_stmt else [] in
let params_stmt = if should_translate_args then
CTrans_utils.assign_default_params params_stmt callee_pname_opt
else [] in
let res_trans_par =
let l = list_map (fun i -> exec_with_self_exception instruction trans_state_param i) params_stmt in
let rt = collect_res_trans (res_trans_callee :: l) in

@ -659,3 +659,23 @@ let is_dispatch_function stmt_list =
)
| _ -> None))
| _ -> None
let assign_default_params params_stmt callee_pname_opt =
match callee_pname_opt with
| None -> params_stmt
| Some callee_pname ->
try
let callee_ms = CMethod_signature.find callee_pname in
let args = CMethod_signature.ms_get_args callee_ms in
let params_args = list_combine params_stmt args in
let replace_default_arg param =
match param with
| CXXDefaultArgExpr(_, _, _), (_, _, Some default_instr) -> default_instr
| instr, _ -> instr in
list_map replace_default_arg params_args
with
| Invalid_argument _ ->
(* list_combine failed because of different list lengths *)
Printing.log_err "Param count doesn't match %s\n" (Procname.to_string callee_pname);
params_stmt
| Not_found -> params_stmt

@ -196,3 +196,5 @@ val compute_autorelease_pool_vars : CContext.t -> Clang_ast_t.stmt list -> (Sil.
val is_logical_negation_of_int : Sil.tenv -> Clang_ast_t.expr_info -> Clang_ast_t.unary_operator_info -> bool
val is_dispatch_function : Clang_ast_t.stmt list -> int option
val assign_default_params : Clang_ast_t.stmt list -> Procname.t option -> Clang_ast_t.stmt list

Loading…
Cancel
Save