diff --git a/infer/src/clang/CType_decl.ml b/infer/src/clang/CType_decl.ml index 8e07177da..cf71e2c1d 100644 --- a/infer/src/clang/CType_decl.ml +++ b/infer/src/clang/CType_decl.ml @@ -603,9 +603,21 @@ and objc_block_procname outer_proc_opt = Typ.Procname.mangled_objc_block name -(* TODO: get the parameters from BuildMethodSignature.get_parameters and pass it to the method names *) -and procname_from_decl ?tenv ?outer_proc meth_decl = +and procname_from_decl ?tenv ?block_return_type ?outer_proc meth_decl = let open Clang_ast_t in + let _ = + match tenv with + | Some tenv -> + let parameters = + BuildMethodSignature.get_parameters qual_type_to_sil_type ~block_return_type tenv + meth_decl + in + List.map + ~f:(fun ({typ}: CMethodSignature.param_type) -> Typ.Procname.Parameter.of_typ typ) + parameters + | None -> + [] + in match meth_decl with | FunctionDecl (decl_info, name_info, _, fdi) -> let name = CAst_utils.get_qualified_name name_info in diff --git a/infer/src/clang/CType_decl.mli b/infer/src/clang/CType_decl.mli index 4ee60ade6..5cac69c5c 100644 --- a/infer/src/clang/CType_decl.mli +++ b/infer/src/clang/CType_decl.mli @@ -8,7 +8,9 @@ open! IStd module CProcname : sig - val from_decl : ?tenv:Tenv.t -> ?outer_proc:Typ.Procname.t -> Clang_ast_t.decl -> Typ.Procname.t + val from_decl : + ?tenv:Tenv.t -> ?block_return_type:Clang_ast_t.qual_type -> ?outer_proc:Typ.Procname.t + -> Clang_ast_t.decl -> Typ.Procname.t (** Given decl, return its procname. This function should be used for all procedures present in original AST *) diff --git a/infer/src/clang/cAst_utils.ml b/infer/src/clang/cAst_utils.ml index 038410f5e..8774d77bc 100644 --- a/infer/src/clang/cAst_utils.ml +++ b/infer/src/clang/cAst_utils.ml @@ -15,7 +15,8 @@ module L = Logging type qual_type_to_sil_type = Tenv.t -> Clang_ast_t.qual_type -> Typ.t type procname_from_decl = - ?tenv:Tenv.t -> ?outer_proc:Typ.Procname.t -> Clang_ast_t.decl -> Typ.Procname.t + ?tenv:Tenv.t -> ?block_return_type:Clang_ast_t.qual_type -> ?outer_proc:Typ.Procname.t + -> Clang_ast_t.decl -> Typ.Procname.t let sanitize_name s = Str.global_replace (Str.regexp "[/ ]") "_" s diff --git a/infer/src/clang/cAst_utils.mli b/infer/src/clang/cAst_utils.mli index f5db8c425..733a58934 100644 --- a/infer/src/clang/cAst_utils.mli +++ b/infer/src/clang/cAst_utils.mli @@ -65,7 +65,8 @@ val name_opt_of_typedef_qual_type : Clang_ast_t.qual_type -> QualifiedCppName.t type qual_type_to_sil_type = Tenv.t -> Clang_ast_t.qual_type -> Typ.t type procname_from_decl = - ?tenv:Tenv.t -> ?outer_proc:Typ.Procname.t -> Clang_ast_t.decl -> Typ.Procname.t + ?tenv:Tenv.t -> ?block_return_type:Clang_ast_t.qual_type -> ?outer_proc:Typ.Procname.t + -> Clang_ast_t.decl -> Typ.Procname.t val qual_type_of_decl_ptr : Clang_ast_t.pointer -> Clang_ast_t.qual_type diff --git a/infer/src/clang/cTrans.ml b/infer/src/clang/cTrans.ml index b8a44b7b7..0beac5901 100644 --- a/infer/src/clang/cTrans.ml +++ b/infer/src/clang/cTrans.ml @@ -2634,14 +2634,16 @@ module CTrans_funct (F : CModule_type.CFrontend) : CModule_type.CTranslation = s match decl with | Clang_ast_t.BlockDecl (_, block_decl_info) -> let open CContext in - let block_pname = CType_decl.CProcname.from_decl decl ~tenv:context.tenv ~outer_proc in + let block_return_type = expr_info.Clang_ast_t.ei_qual_type in + let block_pname = + CType_decl.CProcname.from_decl decl ~tenv:context.tenv ~block_return_type ~outer_proc + in let captured_pvars = CVar_decl.captured_vars_from_block_info context stmt_info.Clang_ast_t.si_source_range block_decl_info.Clang_ast_t.bdi_captured_variables in let res = closure_trans block_pname captured_pvars context stmt_info expr_info in - let qual_type = expr_info.Clang_ast_t.ei_qual_type in - let block_data = Some (context, qual_type, block_pname, captured_pvars) in + let block_data = Some (context, block_return_type, block_pname, captured_pvars) in F.function_decl context.translation_unit_context context.tenv context.cfg decl block_data ; res | _ ->