[clang] Compute the parameters of a method to be passed to the procname

Reviewed By: mbouaziz

Differential Revision: D8297920

fbshipit-source-id: befb261
master
Dulma Churchill 7 years ago committed by Facebook Github Bot
parent 30a3615fa3
commit cbdb00a710

@ -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

@ -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 *)

@ -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

@ -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

@ -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
| _ ->

Loading…
Cancel
Save