[frontned][clang] Fix the translation of CXXStdInitializerListExpr

Summary: D21155014 replaced `skip` call with a Load but this was not right. Instead, let's add a new builtin function (rather than skip) so that other analyses can freely model it as they want.

Reviewed By: jvillard

Differential Revision: D21178286

fbshipit-source-id: c214ccfb0
master
Ezgi Çiçek 5 years ago committed by Facebook GitHub Bot
parent 209fef2256
commit eed39540f3

@ -72,6 +72,8 @@ let __infer_fail = create_procname "__infer_fail"
let __infer_generic_selection_expr = Procname.from_string_c_fun "__infer_generic_selection_expr"
let __infer_initializer_list = create_procname "__infer_initializer_list"
let __infer_skip = create_procname "__infer_skip"
let __infer_skip_function = Procname.from_string_c_fun "__infer_skip_function"

@ -13,6 +13,8 @@ include BUILTINS.S with type t = Procname.t
val is_declared : Procname.t -> bool
val __infer_initializer_list : Procname.t
val __infer_skip_function : Procname.t
val __infer_skip_gcc_asm_stmt : Procname.t

@ -16,6 +16,7 @@ let pure_builtins =
; BuiltinDecl.__set_array_length
; BuiltinDecl.__get_type_of
; BuiltinDecl.__infer_assume
; BuiltinDecl.__infer_initializer_list
; BuiltinDecl.__infer_skip
; BuiltinDecl.__infer_skip_gcc_asm_stmt
; BuiltinDecl.__infer_generic_selection_expr

@ -3248,12 +3248,8 @@ module CTrans_funct (F : CModule_type.CFrontend) : CModule_type.CTranslation = s
let ret_id = Ident.create_fresh Ident.knormal in
let ret_exp = Exp.Var ret_id 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)
let sil_fun = Exp.Const (Const.Cfun BuiltinDecl.__infer_initializer_list) 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

@ -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=*&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<int>) [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=_fun___infer_initializer_list(&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<int>) [line 22, column 20]\n " shape="box"]
"main.fad58de7366495db4650cfefac2fcd61_3" -> "main.fad58de7366495db4650cfefac2fcd61_2" ;

Loading…
Cancel
Save