[HIL] do not crash on confusing function call expressions

Summary:
When the expression resolving to a function to be called could not be
translated to either a proc name or at least an access path, the HIL
translation code would crash. However, this is perfectly possible. Moreover, no
one actually uses the payload of the `Indirect` datatype so no complication
arises from generilising its type to `HilExp.t`, as done in this diff.

Reviewed By: ngorogiannis

Differential Revision: D19691127

fbshipit-source-id: 4c0400ab7
master
Jules Villard 5 years ago committed by Facebook Github Bot
parent 9d9cbdc3d6
commit 81e3dc5069

@ -9,13 +9,13 @@ open! IStd
module F = Format
module L = Logging
type call = Direct of Procname.t | Indirect of HilExp.AccessExpression.t [@@deriving compare]
type call = Direct of Procname.t | Indirect of HilExp.t [@@deriving compare]
let pp_call fmt = function
| Direct pname ->
Procname.pp fmt pname
| Indirect access_expr ->
F.fprintf fmt "*%a" HilExp.AccessExpression.pp access_expr
| Indirect expr ->
F.fprintf fmt "*%a" HilExp.pp expr
type t =
@ -88,10 +88,8 @@ let of_sil ~include_array_indexes ~f_resolve_id (instr : Sil.instr) =
match exp_of_sil call_exp Typ.void with
| Constant (Cfun procname) | Closure (procname, _) ->
Direct procname
| HilExp.AccessExpression access_expr ->
Indirect access_expr
| call_exp ->
L.(die InternalError) "Unexpected call expression %a" HilExp.pp call_exp
Indirect call_exp
in
let formals = List.map ~f:(fun (exp, typ) -> exp_of_sil exp typ) formals in
Instr (Call (hil_ret, hil_call, formals, call_flags, loc))

@ -9,7 +9,7 @@ open! IStd
module F = Format
(** type of a procedure call; either direct or via function pointer *)
type call = Direct of Procname.t | Indirect of HilExp.AccessExpression.t [@@deriving compare]
type call = Direct of Procname.t | Indirect of HilExp.t [@@deriving compare]
val pp_call : F.formatter -> call -> unit [@@warning "-32"]

Loading…
Cancel
Save