[IR] kill never-true "no_return" flag of Tfun type desc

Summary: Another dead flag that one could mistakenly think is accurate.

Reviewed By: dulmarod

Differential Revision: D18573925

fbshipit-source-id: 129a9cff5
master
Jules Villard 5 years ago committed by Facebook Github Bot
parent 997948914f
commit a9df6a917f

@ -177,7 +177,7 @@ module T = struct
| Tint of ikind (** integer type *)
| Tfloat of fkind (** float type *)
| Tvoid (** void type *)
| Tfun of {no_return: bool} (** function type with noreturn attribute *)
| Tfun (** function type *)
| Tptr of t * ptr_kind (** pointer type *)
| Tstruct of name (** structured value type name *)
| TVar of string (** type variable (ie. C++ template variables) *)
@ -291,11 +291,9 @@ let rec pp_full pe f typ =
F.pp_print_string f (fkind_to_string fk)
| Tvoid ->
F.pp_print_string f "void"
| Tfun {no_return= false} ->
| Tfun ->
F.pp_print_string f "_fn_"
| Tfun {no_return= true} ->
F.pp_print_string f "_fn_noreturn_"
| Tptr (({desc= Tarray _ | Tfun _} as typ), pk) ->
| Tptr (({desc= Tarray _ | Tfun} as typ), pk) ->
F.fprintf f "%a(%s)" (pp_full pe) typ (ptr_kind_string pk |> escape pe)
| Tptr (typ, pk) ->
F.fprintf f "%a%s" (pp_full pe) typ (ptr_kind_string pk |> escape pe)

@ -92,7 +92,7 @@ and desc =
| Tint of ikind (** integer type *)
| Tfloat of fkind (** float type *)
| Tvoid (** void type *)
| Tfun of {no_return: bool} (** function type with noreturn attribute *)
| Tfun (** function type *)
| Tptr of t * ptr_kind (** pointer type *)
| Tstruct of name (** structured value type name *)
| TVar of string (** type variable (ie. C++ template variables) *)

@ -463,7 +463,7 @@ let mk_rules_for_dll tenv (para : Sil.hpara_dll) : rule list =
let typ_get_recursive_flds tenv typ_exp =
let filter typ (_, (t : Typ.t), _) =
match t.desc with
| Tstruct _ | Tint _ | Tfloat _ | Tvoid | Tfun _ | TVar _ ->
| Tstruct _ | Tint _ | Tfloat _ | Tvoid | Tfun | TVar _ ->
false
| Tptr (({desc= Tstruct _} as typ'), _) ->
Typ.equal typ' typ
@ -482,7 +482,7 @@ let typ_get_recursive_flds tenv typ_exp =
"@\ntyp_get_recursive_flds: unexpected %a unknown struct type: %a@." Exp.pp typ_exp
Typ.Name.pp name ;
[] (* ToDo: assert false *) )
| Tint _ | Tvoid | Tfun _ | Tptr _ | Tfloat _ | Tarray _ | TVar _ ->
| Tint _ | Tvoid | Tfun | Tptr _ | Tfloat _ | Tarray _ | TVar _ ->
[] )
| Exp.Var _ ->
[] (* type of |-> not known yet *)

@ -483,7 +483,7 @@ let keep_only_indices tenv (p : Prop.normal Prop.t) (path : StrexpMatch.path) (i
(** If the type is array, check whether we should do abstraction *)
let array_typ_can_abstract {Typ.desc} =
match desc with
| Tarray {elt= {desc= Tptr ({desc= Tfun _}, _)}} ->
| Tarray {elt= {desc= Tptr ({desc= Tfun}, _)}} ->
false (* don't abstract arrays of pointers *)
| _ ->
true

@ -446,7 +446,7 @@ let rec create_strexp_of_type ~path tenv struct_init_mode (typ : Typ.t) len inst
else create_fresh_var ()
in
match (typ.desc, len) with
| (Tint _ | Tfloat _ | Tvoid | Tfun _ | Tptr _ | TVar _), None ->
| (Tint _ | Tfloat _ | Tvoid | Tfun | Tptr _ | TVar _), None ->
Eexp (init_value (), inst)
| Tstruct name, _ -> (
if List.exists ~f:(fun (n, _) -> Typ.Name.equal n name) path then
@ -476,7 +476,7 @@ let rec create_strexp_of_type ~path tenv struct_init_mode (typ : Typ.t) len inst
Earray (len, [], inst)
| Tarray _, Some len ->
Earray (len, [], inst)
| (Tint _ | Tfloat _ | Tvoid | Tfun _ | Tptr _ | TVar _), Some _ ->
| (Tint _ | Tfloat _ | Tvoid | Tfun | Tptr _ | TVar _), Some _ ->
assert false
@ -532,7 +532,7 @@ let sigma_get_unsigned_exps sigma =
to ensure the soundness of this collapsing. *)
let exp_collapse_consecutive_indices_prop (typ : Typ.t) exp =
let typ_is_base (typ1 : Typ.t) =
match typ1.desc with Tint _ | Tfloat _ | Tstruct _ | Tvoid | Tfun _ -> true | _ -> false
match typ1.desc with Tint _ | Tfloat _ | Tstruct _ | Tvoid | Tfun -> true | _ -> false
in
let typ_is_one_step_from_base =
match typ.desc with Tptr (t, _) | Tarray {elt= t} -> typ_is_base t | _ -> false

@ -148,10 +148,10 @@ let rec create_struct_values pname tenv orig_prop footprint_part kind max_stamp
(Sil.Aeq (e, e') :: atoms', se, res_t)
| Sil.Off_fld _ :: _ ->
assert false )
| Tint _, [] | Tfloat _, [] | Tvoid, [] | Tfun _, [] | Tptr _, [] | TVar _, [] ->
| Tint _, [] | Tfloat _, [] | Tvoid, [] | Tfun, [] | Tptr _, [] | TVar _, [] ->
let id = new_id () in
([], Sil.Eexp (Exp.Var id, inst), t)
| (Tint _ | Tfloat _ | Tvoid | Tfun _ | Tptr _ | TVar _), Off_index e :: off' ->
| (Tint _ | Tfloat _ | Tvoid | Tfun | Tptr _ | TVar _), Off_index e :: off' ->
(* In this case, we lift t to the t array. *)
let t', mk_typ_f =
match t.Typ.desc with
@ -168,7 +168,7 @@ let rec create_struct_values pname tenv orig_prop footprint_part kind max_stamp
let se = Sil.Earray (len, [(e', se')], inst) in
let res_t = mk_typ_f (Tarray {elt= res_t'; length= None; stride= None}) in
(Sil.Aeq (e, e') :: atoms', se, res_t)
| Tint _, _ | Tfloat _, _ | Tvoid, _ | Tfun _, _ | Tptr _, _ | TVar _, _ ->
| Tint _, _ | Tfloat _, _ | Tvoid, _ | Tfun, _ | Tptr _, _ | TVar _, _ ->
fail t off __POS__
in
if Config.trace_rearrange then (
@ -248,7 +248,7 @@ let rec strexp_extend_values_ pname tenv orig_prop footprint_part kind max_stamp
raise (Exceptions.Missing_fld (f, __POS__)) )
| Off_fld _ :: _, _, _ ->
raise (Exceptions.Bad_footprint __POS__)
| Off_index _ :: _, Sil.Eexp _, (Tint _ | Tfloat _ | Tvoid | Tfun _ | Tptr _)
| Off_index _ :: _, Sil.Eexp _, (Tint _ | Tfloat _ | Tvoid | Tfun | Tptr _)
| Off_index _ :: _, Sil.Estruct _, Tstruct _ ->
(* L.d_strln ~color:Orange "turn into an array"; *)
let len =
@ -456,14 +456,14 @@ let mk_ptsto_exp_footprint pname tenv orig_prop (lexp, typ) max_stamp inst :
in
let create_ptsto footprint_part off0 =
match (root, off0, typ.Typ.desc) with
| Exp.Lvar pvar, [], Typ.Tfun _ ->
| Exp.Lvar pvar, [], Typ.Tfun ->
let fun_name = Typ.Procname.from_string_c_fun (Mangled.to_string (Pvar.get_name pvar)) in
let fun_exp = Exp.Const (Const.Cfun fun_name) in
( []
, Prop.mk_ptsto tenv root
(Sil.Eexp (fun_exp, inst))
(Exp.Sizeof {typ; nbytes= None; dynamic_length= None; subtype}) )
| _, [], Typ.Tfun _ ->
| _, [], Typ.Tfun ->
let atoms, se, typ =
create_struct_values pname tenv orig_prop footprint_part Ident.kfootprint max_stamp typ
off0 inst

@ -565,7 +565,7 @@ module Val = struct
let v = itv_val ~non_int:(Language.curr_language_is Java) in
if Language.curr_language_is Java then set_itv_updated_by_unknown v
else set_itv_updated_by_addition v
| Tfloat _ | Tfun _ | TVar _ ->
| Tfloat _ | Tfun | TVar _ ->
itv_val ~non_int:true |> set_itv_updated_by_unknown
| Tint _ | Tvoid ->
itv_val ~non_int:false |> set_itv_updated_by_addition

@ -46,7 +46,7 @@ module TransferFunctions (CFG : ProcCfg.S) = struct
| Sil.Store {e1= Exp.Lfield (Exp.Var lhs_id, name, typ); typ= exp_typ; e2= rhs} -> (
match exp_typ.Typ.desc with
(* block field of a ObjC class *)
| Typ.Tptr ({desc= Tfun _}, _)
| Typ.Tptr ({desc= Tfun}, _)
when Typ.is_objc_class typ && is_self proc_data.extras lhs_id
&& (* lhs is self, rhs is not null *)
not (exp_is_null proc_data.extras rhs) ->

@ -26,7 +26,7 @@ module TransferFunctions (CFG : ProcCfg.S) = struct
let exec_instr astate _ _ = function
| Sil.Load {id= lhs_id} when Ident.is_none lhs_id ->
astate
| Sil.Load {id= lhs_id; e= Exp.Lvar rhs_pvar; typ= Typ.{desc= Tptr ({desc= Tfun _}, _)}} ->
| Sil.Load {id= lhs_id; e= Exp.Lvar rhs_pvar; typ= Typ.{desc= Tptr ({desc= Tfun}, _)}} ->
let fun_ptr =
try Domain.find (Pvar.to_string rhs_pvar) astate
with Caml.Not_found -> ProcnameSet.empty

@ -17,7 +17,7 @@ let objc_classname_of_type typ =
match typ.Typ.desc with
| Typ.Tstruct name ->
name
| Typ.Tfun _ ->
| Typ.Tfun ->
Typ.Name.Objc.from_string CFrontend_config.objc_object
| _ ->
L.(debug Capture Verbose)

@ -424,7 +424,7 @@ module CTrans_funct (F : CModule_type.CFrontend) : CModule_type.CTranslation = s
let zero_exp = Exp.zero_of_type_exn typ in
let instrs = [Sil.Store {e1= exp; root_typ= typ; typ; e2= zero_exp; loc= sil_loc}] in
mk_trans_result (exp, typ) {empty_control with instrs}
| Tfun _ | Tvoid | Tarray _ | TVar _ ->
| Tfun | Tvoid | Tarray _ | TVar _ ->
CFrontend_errors.unimplemented __POS__ stmt_info.Clang_ast_t.si_source_range
"fill_typ_with_zero on type %a" (Typ.pp Pp.text) typ
in

@ -138,7 +138,7 @@ and type_desc_of_c_type translate_decl tenv c_type : Typ.desc =
| ConstantArrayType (_, {arti_element_type; arti_stride}, n) ->
build_array_type translate_decl tenv arti_element_type (Some n) arti_stride
| FunctionProtoType _ | FunctionNoProtoType _ ->
Typ.Tfun {no_return= false}
Typ.Tfun
| ParenType (_, qual_type) ->
(qual_type_to_sil_type translate_decl tenv qual_type).Typ.desc
| DecayedType (_, qual_type) ->

@ -24,7 +24,7 @@ include TaintAnalysis.Make (struct
let handle_generic_unknown ret_typ actuals =
match ((ret_typ.Typ.desc : Typ.desc), List.rev_map actuals ~f:HilExp.ignore_cast) with
(* everything but Tvoid*)
| (Tint _ | Tfloat _ | Tfun _ | Tptr (_, _) | Tstruct _ | TVar _ | Tarray _), _ ->
| (Tint _ | Tfloat _ | Tfun | Tptr _ | Tstruct _ | TVar _ | Tarray _), _ ->
(* propagate taint from actuals to return value *)
[TaintSpec.Propagate_to_return]
| Tvoid, [] ->

@ -14,7 +14,7 @@ let tests =
let assert_empty = invariant "{ }" in
let int_typ = Typ.mk (Tint IInt) in
let int_ptr_typ = Typ.mk (Tptr (int_typ, Pk_pointer)) in
let fun_ptr_typ = Typ.mk (Tptr (Typ.mk (Tfun {no_return= false}), Pk_pointer)) in
let fun_ptr_typ = Typ.mk (Tptr (Typ.mk Tfun, Pk_pointer)) in
let closure_exp captureds =
let mk_captured_var str = (Exp.Var (ident_of_str str), pvar_of_str str, int_ptr_typ) in
let captured_vars = List.map ~f:mk_captured_var captureds in

@ -13,7 +13,7 @@ let tests =
let open OUnit2 in
let open AnalyzerTester.StructuredSil in
let assert_empty = invariant "{ }" in
let fun_ptr_typ = Typ.mk (Tptr (Typ.mk (Tfun {no_return= false}), Pk_pointer)) in
let fun_ptr_typ = Typ.mk (Tptr (Typ.mk Tfun, Pk_pointer)) in
let closure_exp captured_pvars =
let mk_captured_var str = (Exp.Var (ident_of_str str), pvar_of_str str, dummy_typ) in
let captured_vars = List.map ~f:mk_captured_var captured_pvars in

Loading…
Cancel
Save