[clang frontend] Refactor block_data into a record

Summary: Moving this big tuple to a record, because it's cleaner code, and I need to add another element in the next diff.

Reviewed By: ezgicicek

Differential Revision: D19640389

fbshipit-source-id: 86b1576a0
master
Dulma Churchill 5 years ago committed by Facebook Github Bot
parent 43a99745b6
commit 355ff5c202

@ -70,15 +70,15 @@ module CFrontend_decl_funct (T : CModule_type.CTranslation) : CModule_type.CFron
try try
let captured_vars, outer_context_opt = let captured_vars, outer_context_opt =
match block_data_opt with match block_data_opt with
| Some (outer_context, _, _, captured_vars) -> | Some {CModule_type.captured_vars; context= outer_context} ->
(captured_vars, Some outer_context) (captured_vars, Some outer_context)
| None -> | None ->
([], None) ([], None)
in in
let procname, block_return_type = let procname, block_return_type =
match block_data_opt with match block_data_opt with
| Some (_, block_return_type, procname, _) -> | Some {CModule_type.procname; return_type} ->
(procname, Some block_return_type) (procname, Some return_type)
| _ -> | _ ->
(CType_decl.CProcname.from_decl ~tenv func_decl, None) (CType_decl.CProcname.from_decl ~tenv func_decl, None)
in in

@ -7,7 +7,11 @@
open! IStd open! IStd
type block_data = CContext.t * Clang_ast_t.qual_type * Procname.t * (Pvar.t * Typ.t) list type block_data =
{ captured_vars: (Pvar.t * Typ.t) list
; context: CContext.t
; procname: Procname.t
; return_type: Clang_ast_t.qual_type }
type instr_type = type instr_type =
[`ClangStmt of Clang_ast_t.stmt | `CXXConstructorInit of Clang_ast_t.cxx_ctor_initializer] [`ClangStmt of Clang_ast_t.stmt | `CXXConstructorInit of Clang_ast_t.cxx_ctor_initializer]

@ -2776,16 +2776,17 @@ module CTrans_funct (F : CModule_type.CFrontend) : CModule_type.CTranslation = s
match decl with match decl with
| Clang_ast_t.BlockDecl (_, block_decl_info) -> | Clang_ast_t.BlockDecl (_, block_decl_info) ->
let open CContext in let open CContext in
let block_return_type = expr_info.Clang_ast_t.ei_qual_type in let return_type = expr_info.Clang_ast_t.ei_qual_type in
let block_pname = let procname =
CType_decl.CProcname.from_decl decl ~tenv:context.tenv ~block_return_type ~outer_proc CType_decl.CProcname.from_decl decl ~tenv:context.tenv ~block_return_type:return_type
~outer_proc
in in
let captured_pvars = let captured_vars =
CVar_decl.captured_vars_from_block_info context stmt_info.Clang_ast_t.si_source_range 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 block_decl_info.Clang_ast_t.bdi_captured_variables
in in
let res = closure_trans block_pname captured_pvars context stmt_info expr_info in let res = closure_trans procname captured_vars context stmt_info expr_info in
let block_data = Some (context, block_return_type, block_pname, captured_pvars) in let block_data = Some {CModule_type.captured_vars; context; procname; return_type} in
F.function_decl context.translation_unit_context context.tenv context.cfg decl block_data ; F.function_decl context.translation_unit_context context.tenv context.cfg decl block_data ;
res res
| _ -> | _ ->

Loading…
Cancel
Save