Keep more precise information in constructor's var_exp_typ

Summary:
No longer allow pointer types to be passed inside var_exp_typ. We used to accept both forms,
but it won't be possible any longer once shared_ptr becomes pointer type.

Reviewed By: dulmarod

Differential Revision: D3593003

fbshipit-source-id: a830914
master
Andrzej Kotulski 9 years ago committed by Facebook Github Bot 6
parent 102f61e2a7
commit 5ed50f5a97

@ -957,10 +957,7 @@ struct
let class_type = CTypes_decl.get_type_from_expr_info ei context.CContext.tenv in let class_type = CTypes_decl.get_type_from_expr_info ei context.CContext.tenv in
Cfg.Procdesc.append_locals procdesc [(Pvar.get_name pvar, class_type)]; Cfg.Procdesc.append_locals procdesc [(Pvar.get_name pvar, class_type)];
Sil.Lvar pvar, class_type in Sil.Lvar pvar, class_type in
let this_type = let this_type = Typ.Tptr (class_type, Typ.Pk_pointer) in
match class_type with
| Typ.Tptr _ -> class_type
| _ -> Typ.Tptr (class_type, Typ.Pk_pointer) in
let this_res_trans = { empty_res_trans with let this_res_trans = { empty_res_trans with
exps = [(var_exp, this_type)]; exps = [(var_exp, this_type)];
initd_exps = [var_exp]; initd_exps = [var_exp];
@ -2028,9 +2025,10 @@ struct
and initListExpr_initializers_trans trans_state var_exp n stmts typ is_dyn_array stmt_info = and initListExpr_initializers_trans trans_state var_exp n stmts typ is_dyn_array stmt_info =
let (var_exp_inside, typ_inside) = match typ with let (var_exp_inside, typ_inside) = match typ with
| Typ.Tarray (t, _) | Typ.Tarray (t, _) when Typ.is_array_of_cpp_class typ ->
| Typ.Tptr (t, _) when Typ.is_array_of_cpp_class typ || is_dyn_array ->
Sil.Lindex (var_exp, Sil.Const (Const.Cint (IntLit.of_int n))), t Sil.Lindex (var_exp, Sil.Const (Const.Cint (IntLit.of_int n))), t
| _ when is_dyn_array ->
Sil.Lindex (var_exp, Sil.Const (Const.Cint (IntLit.of_int n))), typ
| _ -> var_exp, typ in | _ -> var_exp, typ in
let trans_state' = { trans_state with var_exp_typ = Some (var_exp_inside, typ_inside) } in let trans_state' = { trans_state with var_exp_typ = Some (var_exp_inside, typ_inside) } in
match stmts with match stmts with
@ -2086,7 +2084,9 @@ struct
let res_trans_new = cpp_new_trans trans_state_pri sil_loc typ size_exp_opt in let res_trans_new = cpp_new_trans trans_state_pri sil_loc typ size_exp_opt in
let stmt_opt = Ast_utils.get_stmt_opt cxx_new_expr_info.Clang_ast_t.xnei_initializer_expr in let stmt_opt = Ast_utils.get_stmt_opt cxx_new_expr_info.Clang_ast_t.xnei_initializer_expr in
let trans_state_init = { trans_state_pri with succ_nodes = []; } in let trans_state_init = { trans_state_pri with succ_nodes = []; } in
let var_exp_typ = match res_trans_new.exps with [exp] -> exp | _ -> assert false in let var_exp_typ = match res_trans_new.exps with
| [var_exp, Typ.Tptr (t, _)] -> (var_exp, t)
| _ -> assert false in
(* Need a new stmt_info for the translation of the initializer, so that it can create nodes *) (* Need a new stmt_info for the translation of the initializer, so that it can create nodes *)
(* if it needs to, with the same stmt_info it doesn't work. *) (* if it needs to, with the same stmt_info it doesn't work. *)
let init_stmt_info = { stmt_info with let init_stmt_info = { stmt_info with

@ -217,7 +217,7 @@ digraph iCFG {
43 -> 54 ; 43 -> 54 ;
42 [label="42: DeclStmt \n n$2=_fun___new(sizeof(int ):unsigned long ) [line 58]\n *n$2:int *=0 [line 58]\n *&x1:int *=n$2 [line 58]\n " shape="box"] 42 [label="42: DeclStmt \n n$2=_fun___new(sizeof(int ):unsigned long ) [line 58]\n *n$2:int =0 [line 58]\n *&x1:int *=n$2 [line 58]\n " shape="box"]
42 -> 41 ; 42 -> 41 ;

Loading…
Cancel
Save