diff --git a/infer/src/clang/cTrans.ml b/infer/src/clang/cTrans.ml index 5b1de47c8..d0e6b7976 100644 --- a/infer/src/clang/cTrans.ml +++ b/infer/src/clang/cTrans.ml @@ -3245,11 +3245,17 @@ module CTrans_funct (F : CModule_type.CFrontend) : CModule_type.CTranslation = s let trans_state_param = {trans_state_pri with succ_nodes= []} in let res_trans_subexpr_list = List.map ~f:(instruction trans_state_param) stmts in let params = collect_returns res_trans_subexpr_list in - let sil_fun = Exp.Const (Const.Cfun BuiltinDecl.__infer_skip_function) in let ret_id = Ident.create_fresh Ident.knormal in let ret_exp = Exp.Var ret_id in - let call_instr = Sil.Call ((ret_id, typ), sil_fun, params, sil_loc, CallFlags.default) in - let res_trans_call = mk_trans_result (ret_exp, typ) {empty_control with instrs= [call_instr]} in + let res_instr = + match params with + | [(exp, typ)] -> + Sil.Load {id= ret_id; e= exp; root_typ= typ; typ; loc= sil_loc} + | _ -> + let sil_fun = Exp.Const (Const.Cfun BuiltinDecl.__infer_skip_function) in + Sil.Call ((ret_id, typ), sil_fun, params, sil_loc, CallFlags.default) + in + let res_trans_call = mk_trans_result (ret_exp, typ) {empty_control with instrs= [res_instr]} in let all_res_trans = res_trans_subexpr_list @ [res_trans_call] in PriorityNode.compute_results_to_parent trans_state_pri sil_loc ~node_name:CXXStdInitializerListExpr stmt_info ~return:res_trans_call.return all_res_trans diff --git a/infer/tests/codetoanalyze/cpp/shared/constructors/std_init_list.cpp.dot b/infer/tests/codetoanalyze/cpp/shared/constructors/std_init_list.cpp.dot index b089cc33e..5acd8d94e 100644 --- a/infer/tests/codetoanalyze/cpp/shared/constructors/std_init_list.cpp.dot +++ b/infer/tests/codetoanalyze/cpp/shared/constructors/std_init_list.cpp.dot @@ -7,7 +7,7 @@ digraph cfg { "main.fad58de7366495db4650cfefac2fcd61_2" [label="2: Exit main \n " color=yellow style=filled] -"main.fad58de7366495db4650cfefac2fcd61_3" [label="3: DeclStmt \n VARIABLE_DECLARED(x:X); [line 22, column 14]\n VARIABLE_DECLARED(0$?%__sil_tmpSIL_materialize_temp__n$0:int const [5*4] const ); [line 22, column 20]\n *&0$?%__sil_tmpSIL_materialize_temp__n$0[0]:int=1 [line 22, column 20]\n *&0$?%__sil_tmpSIL_materialize_temp__n$0[1]:int=2 [line 22, column 20]\n *&0$?%__sil_tmpSIL_materialize_temp__n$0[2]:int=3 [line 22, column 20]\n *&0$?%__sil_tmpSIL_materialize_temp__n$0[3]:int=4 [line 22, column 20]\n *&0$?%__sil_tmpSIL_materialize_temp__n$0[4]:int=5 [line 22, column 20]\n n$1=_fun___infer_skip_function(&0$?%__sil_tmpSIL_materialize_temp__n$0:int const [5*4] const ) [line 22, column 20]\n n$2=_fun_X::X(&x:X*,n$1:std::initializer_list) [line 22, column 20]\n " shape="box"] +"main.fad58de7366495db4650cfefac2fcd61_3" [label="3: DeclStmt \n VARIABLE_DECLARED(x:X); [line 22, column 14]\n VARIABLE_DECLARED(0$?%__sil_tmpSIL_materialize_temp__n$0:int const [5*4] const ); [line 22, column 20]\n *&0$?%__sil_tmpSIL_materialize_temp__n$0[0]:int=1 [line 22, column 20]\n *&0$?%__sil_tmpSIL_materialize_temp__n$0[1]:int=2 [line 22, column 20]\n *&0$?%__sil_tmpSIL_materialize_temp__n$0[2]:int=3 [line 22, column 20]\n *&0$?%__sil_tmpSIL_materialize_temp__n$0[3]:int=4 [line 22, column 20]\n *&0$?%__sil_tmpSIL_materialize_temp__n$0[4]:int=5 [line 22, column 20]\n n$1=*&0$?%__sil_tmpSIL_materialize_temp__n$0:int const [5*4] const [line 22, column 20]\n n$2=_fun_X::X(&x:X*,n$1:std::initializer_list) [line 22, column 20]\n " shape="box"] "main.fad58de7366495db4650cfefac2fcd61_3" -> "main.fad58de7366495db4650cfefac2fcd61_2" ;