make Tabulation.prop_get_exn_name return an option type

Summary: So that we no longer have to run `Tabulation.prop_is_exn` before running `Tabulation.prop_get_exn_name`.

Reviewed By: jberdine

Differential Revision: D3222545

fb-gh-sync-id: a7faa06
fbshipit-source-id: a7faa06
master
Jeremy Dubreil 9 years ago committed by Facebook Github Bot 4
parent 214ef205ca
commit 0737b9231d

@ -256,7 +256,7 @@ let propagate
let f prop path edgeset_curr =
let exn_opt =
if is_exception
then Some (Tabulation.prop_get_exn_name pname prop)
then Tabulation.prop_get_exn_name pname prop
else None in
Paths.PathSet.add_renamed_prop
prop
@ -1066,12 +1066,10 @@ let reset_global_values proc_desc =
(* Collect all pairs of the kind (precondition, runtime exception) from a summary *)
let exception_preconditions tenv pname summary =
let collect_exceptions pre exns (prop, _) =
if Tabulation.prop_is_exn pname prop then
let exn_name = Tabulation.prop_get_exn_name pname prop in
if PatternMatch.is_runtime_exception tenv exn_name then
(pre, exn_name):: exns
else exns
else exns in
match Tabulation.prop_get_exn_name pname prop with
| Some exn_name when PatternMatch.is_runtime_exception tenv exn_name ->
(pre, exn_name) :: exns
| _ -> exns in
let collect_spec errors spec =
IList.fold_left (collect_exceptions spec.Specs.pre) errors spec.Specs.posts in
IList.fold_left collect_spec [] (Specs.get_specs_from_payload summary)

@ -627,24 +627,21 @@ let prop_is_exn pname prop =
(** when prop is an exception, return the exception name *)
let prop_get_exn_name pname prop =
let ret_pvar = Sil.Lvar (Pvar.get_ret_pvar pname) in
let exn_name = ref (Typename.Java.from_string "") in
let find_exn_name e =
let do_hpred = function
| Sil.Hpointsto (e1, _, Sil.Sizeof (Sil.Tstruct { Sil.struct_name = Some name }, _))
let rec search_exn e = function
| [] -> None
| Sil.Hpointsto (e1, _, Sil.Sizeof (Sil.Tstruct { Sil.struct_name = Some name }, _)) :: _
when Sil.exp_equal e1 e ->
let found_exn_name = Typename.TN_csu (Csu.Class Csu.Java, name) in
exn_name := found_exn_name
| _ -> () in
IList.iter do_hpred (Prop.get_sigma prop) in
let find_ret () =
let do_hpred = function
| Sil.Hpointsto (e1, Sil.Eexp(Sil.Const (Sil.Cexn e2), _), _)
Some (Typename.TN_csu (Csu.Class Csu.Java, name))
| _ :: tl -> search_exn e tl in
let rec find_exn_name hpreds = function
| [] -> None
| Sil.Hpointsto (e1, Sil.Eexp(Sil.Const (Sil.Cexn e2), _), _) :: _
when Sil.exp_equal e1 ret_pvar ->
find_exn_name e2
| _ -> () in
IList.iter do_hpred (Prop.get_sigma prop) in
find_ret ();
!exn_name
search_exn e2 hpreds
| _ :: tl -> find_exn_name hpreds tl in
let hpreds = Prop.get_sigma prop in
find_exn_name hpreds hpreds
(** search in prop for some assignment of global errors *)
let lookup_custom_errors prop =

@ -34,7 +34,7 @@ val raise_cast_exception :
val prop_is_exn : Procname.t -> 'a Prop.t -> bool
(** when prop is an exception, return the exception name *)
val prop_get_exn_name : Procname.t -> 'a Prop.t -> Typename.t
val prop_get_exn_name : Procname.t -> 'a Prop.t -> Typename.t option
(** search in prop contains an error state *)
val lookup_custom_errors : 'a Prop.t -> string option

Loading…
Cancel
Save