@ -205,7 +205,12 @@ module CTrans_funct (F : CModule_type.CFrontend) : CModule_type.CTranslation = s
CVar_decl . mk_temp_sil_var_for_expr context ~ name : var_name ~ clang_pointer expr_info
in
let var_data =
ProcAttributes . { name = Pvar . get_name pvar ; typ ; modify_in_block = false ; is_constexpr = false }
ProcAttributes .
{ name = Pvar . get_name pvar
; typ
; modify_in_block = false
; is_constexpr = false
; is_declared_unused = false }
in
Procdesc . append_locals procdesc [ var_data ] ;
( Exp . Lvar pvar , typ )
@ -245,7 +250,8 @@ module CTrans_funct (F : CModule_type.CFrontend) : CModule_type.CTranslation = s
{ name = Pvar . get_name pvar
; typ = return_type
; modify_in_block = false
; is_constexpr = false }
; is_constexpr = false
; is_declared_unused = false }
in
Procdesc . append_locals procdesc [ var_data ] ;
Exp . Lvar pvar
@ -1201,7 +1207,11 @@ module CTrans_funct (F : CModule_type.CFrontend) : CModule_type.CTranslation = s
let pvar = Pvar . mk_tmp " __temp_construct_ " ( Procdesc . get_proc_name procdesc ) in
let class_type = CType_decl . get_type_from_expr_info ei context . CContext . tenv in
let var_data : ProcAttributes . var_data =
{ name = Pvar . get_name pvar ; typ = class_type ; modify_in_block = false ; is_constexpr = false }
{ name = Pvar . get_name pvar
; typ = class_type
; modify_in_block = false
; is_constexpr = false
; is_declared_unused = false }
in
Procdesc . append_locals procdesc [ var_data ] ;
( Exp . Lvar pvar , class_type )
@ -1615,7 +1625,11 @@ module CTrans_funct (F : CModule_type.CFrontend) : CModule_type.CTranslation = s
let pvar = CVar_decl . mk_temp_sil_var procdesc ~ name : " SIL_temp_conditional___ " in
let var_data =
ProcAttributes .
{ name = Pvar . get_name pvar ; typ = var_typ ; modify_in_block = false ; is_constexpr = false }
{ name = Pvar . get_name pvar
; typ = var_typ
; modify_in_block = false
; is_constexpr = false
; is_declared_unused = false }
in
Procdesc . append_locals procdesc [ var_data ] ;
let continuation' = mk_cond_continuation trans_state . continuation in
@ -2435,8 +2449,8 @@ module CTrans_funct (F : CModule_type.CFrontend) : CModule_type.CTranslation = s
| > mk_trans_result ret_exp_typ
and init_expr_trans ? ( is_ var_unused = false ) ? ( is_ initListExpr_builtin = false ) trans_state
var_ exp_typ ? qual_type var_ stmt_info init_expr_opt =
and init_expr_trans ? ( is_ initListExpr_builtin = false ) trans_state var_exp_typ ? qual_type
var_ stmt_info init_expr_opt =
match init_expr_opt with
| None -> (
match Option . bind qual_type ~ f : ( fun qt -> CAst_utils . get_type qt . Clang_ast_t . qt_type_ptr ) with
@ -2464,8 +2478,7 @@ module CTrans_funct (F : CModule_type.CFrontend) : CModule_type.CTranslation = s
in
let assign_trans_control_opt =
if
is_var_unused
| | (* variable might be initialized already - do nothing in that case *)
(* variable might be initialized already - do nothing in that case *)
List . exists ~ f : ( Exp . equal var_exp ) res_trans_ie . control . initd_exps
then None
else
@ -2501,21 +2514,18 @@ module CTrans_funct (F : CModule_type.CFrontend) : CModule_type.CTranslation = s
let context = trans_state . context in
let procdesc = context . CContext . procdesc in
let procname = Procdesc . get_proc_name procdesc in
let do_var_dec ~ is_var_unused var_decl qual_type vdi next_node =
let do_var_dec var_decl qual_type vdi next_node =
let pvar = CVar_decl . sil_var_of_decl context var_decl procname in
let typ = CType_decl . qual_type_to_sil_type context . CContext . tenv qual_type in
CVar_decl . add_var_to_locals procdesc var_decl typ pvar ;
let trans_state' = { trans_state with succ_nodes = next_node } in
init_expr_trans ~ is_var_unused trans_state' ( Exp . Lvar pvar , typ ) ~ qual_type stmt_info
init_expr_trans trans_state' ( Exp . Lvar pvar , typ ) ~ qual_type stmt_info
vdi . Clang_ast_t . vdi_init_expr
in
let has_unused_attr attributes =
List . exists attributes ~ f : ( function ` UnusedAttr _ -> true | _ -> false )
in
let rec aux : decl list -> trans_result option = function
| [] ->
None
| ( VarDecl ( {di _attributes} , _ , qt , vdi ) as var_decl ) :: var_decls' ->
| ( VarDecl ( _, _ , qt , vdi ) as var_decl ) :: var_decls' ->
(* Var are defined when procdesc is created, here we only take care of initialization *)
let res_trans_tl = aux var_decls' in
let root_nodes_tl , instrs_tl , initd_exps_tl =
@ -2525,8 +2535,7 @@ module CTrans_funct (F : CModule_type.CFrontend) : CModule_type.CTranslation = s
| Some { control = { root_nodes ; instrs ; initd_exps } } ->
( root_nodes , instrs , initd_exps )
in
let is_var_unused = has_unused_attr di_attributes in
let res_trans_tmp = do_var_dec ~ is_var_unused var_decl qt vdi root_nodes_tl in
let res_trans_tmp = do_var_dec var_decl qt vdi root_nodes_tl in
(* keep the last return and leaf_nodes from the list *)
let return , leaf_nodes =
match res_trans_tl with
@ -2895,7 +2904,8 @@ module CTrans_funct (F : CModule_type.CFrontend) : CModule_type.CTranslation = s
[ { ProcAttributes . name = Pvar . get_name temp
; typ = array_typ
; modify_in_block = false
; is_constexpr = false } ] ;
; is_constexpr = false
; is_declared_unused = false } ] ;
(* 2. Translate array elements *)
let res_trans_elems = List . mapi ~ f : ( exec_instruction_with_trans_state trans_state None ) stmts in
(* 3. Add array initialization ( elements assignments ) *)
@ -3240,7 +3250,12 @@ module CTrans_funct (F : CModule_type.CFrontend) : CModule_type.CTranslation = s
let res_trans = init_expr_trans trans_state var_exp_typ stmt_info ( Some temp_exp ) in
let _ , typ = res_trans . return in
let var_data =
ProcAttributes . { name = Pvar . get_name pvar ; typ ; modify_in_block = false ; is_constexpr = false }
ProcAttributes .
{ name = Pvar . get_name pvar
; typ
; modify_in_block = false
; is_constexpr = false
; is_declared_unused = false }
in
Procdesc . append_locals procdesc [ var_data ] ;
res_trans