[clang] Add procdescs to cxx method. Forgotten from last commit

master
Dulma Rodriguez 9 years ago
parent 3cddd0489c
commit e5f6df74b0

@ -336,6 +336,19 @@ let create_external_procdesc cfg procname is_objc_inst_method type_opt =
} in } in
() ()
let create_procdesc_with_pointer context pointer_opt callee_name =
let open CContext in
let callee_ms_opt =
match pointer_opt with
| Some pointer ->
(match method_signature_of_pointer None pointer with
| Some callee_ms -> Some callee_ms
| None -> None)
| None -> None in
match callee_ms_opt with
| Some callee_ms -> ignore (create_local_procdesc context.cfg context.tenv callee_ms [] [] false)
| None -> create_external_procdesc context.cfg callee_name false None
let instance_to_method_call_type instance = let instance_to_method_call_type instance =
if instance then MCVirtual if instance then MCVirtual
else MCStatic else MCStatic

@ -36,3 +36,5 @@ val method_signature_of_decl : string option -> Clang_ast_t.decl -> CModule_type
CMethod_signature.method_signature * Clang_ast_t.stmt option * Clang_ast_t.decl list CMethod_signature.method_signature * Clang_ast_t.stmt option * Clang_ast_t.decl list
val method_signature_of_pointer : string option -> Clang_ast_t.pointer -> CMethod_signature.method_signature option val method_signature_of_pointer : string option -> Clang_ast_t.pointer -> CMethod_signature.method_signature option
val create_procdesc_with_pointer : CContext.t -> Clang_ast_t.pointer option -> Procname.t -> unit

@ -325,11 +325,7 @@ struct
| Some v -> | Some v ->
(General_utils.mk_procname_from_function name v, CTypes_decl.parse_func_type name v) (General_utils.mk_procname_from_function name v, CTypes_decl.parse_func_type name v)
| None -> (Procname.from_string_c_fun name, None) in | None -> (Procname.from_string_c_fun name, None) in
(match CMethod_trans.method_signature_of_pointer None pointer with CMethod_trans.create_procdesc_with_pointer context (Some pointer) pname;
| Some callee_ms ->
ignore (CMethod_trans.create_local_procdesc context.cfg context.tenv callee_ms [] [] false)
| None ->
CMethod_trans.create_external_procdesc context.cfg pname false None);
let address_of_function = not context.CContext.is_callee_expression 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.*) (* If we are not translating a callee expression, then the address of the function is being taken.*)
(* As e.g. in fun_ptr = foo; *) (* As e.g. in fun_ptr = foo; *)
@ -620,10 +616,11 @@ struct
| _ -> assert false) (* by construction of red_id, we cannot be in this case *) | _ -> assert false) (* by construction of red_id, we cannot be in this case *)
and cxxMemberCallExpr_trans trans_state si stmt_list expr_info = and cxxMemberCallExpr_trans trans_state si stmt_list expr_info =
let open CContext in
let pln = trans_state.parent_line_number in let pln = trans_state.parent_line_number in
let context = trans_state.context in let context = trans_state.context in
let function_type = CTypes_decl.get_type_from_expr_info expr_info context.CContext.tenv in let function_type = CTypes_decl.get_type_from_expr_info expr_info context.tenv in
let procname = Cfg.Procdesc.get_proc_name context.CContext.procdesc in let procname = Cfg.Procdesc.get_proc_name context.procdesc in
let sil_loc = CLocation.get_sil_location si pln context in let sil_loc = CLocation.get_sil_location si pln context in
(* First stmt is the method+this expr and the rest are params *) (* First stmt is the method+this expr and the rest are params *)
let fun_exp_stmt, params_stmt = (match stmt_list with let fun_exp_stmt, params_stmt = (match stmt_list with
@ -644,6 +641,8 @@ struct
| Sil.Const (Sil.Cfun pn) -> pn | Sil.Const (Sil.Cfun pn) -> pn
| _ -> assert false (* method pointer not implemented, this shouldn't happen *) in | _ -> assert false (* method pointer not implemented, this shouldn't happen *) in
let class_name_opt = Some (Procname.c_get_class callee_pname) in let class_name_opt = Some (Procname.c_get_class callee_pname) in
let pointer_opt = CTrans_utils.pointer_of_call_expr fun_exp_stmt in
CMethod_trans.create_procdesc_with_pointer context pointer_opt callee_pname;
let params_stmt = CTrans_utils.assign_default_params params_stmt class_name_opt fun_exp_stmt ~is_cxx_method:true in let params_stmt = CTrans_utils.assign_default_params params_stmt class_name_opt fun_exp_stmt ~is_cxx_method:true in
(* As we may have nodes coming from different parameters we need to *) (* As we may have nodes coming from different parameters we need to *)
(* call instruction for each parameter and collect the results *) (* call instruction for each parameter and collect the results *)

@ -209,3 +209,5 @@ val assign_default_params : Clang_ast_t.stmt list -> string option -> Clang_ast_
is_cxx_method:bool -> Clang_ast_t.stmt list is_cxx_method:bool -> Clang_ast_t.stmt list
val is_block_enumerate_function : Clang_ast_t.obj_c_message_expr_info -> bool val is_block_enumerate_function : Clang_ast_t.obj_c_message_expr_info -> bool
val pointer_of_call_expr : Clang_ast_t.stmt -> Clang_ast_t.pointer option

Loading…
Cancel
Save