diff --git a/infer/src/pulse/Pulse.ml b/infer/src/pulse/Pulse.ml index ad44db671..9387a843f 100644 --- a/infer/src/pulse/Pulse.ml +++ b/infer/src/pulse/Pulse.ml @@ -168,15 +168,14 @@ module PulseTransferFunctions = struct Ok astate in [check_error summary result] - | Prune (condition, loc, _is_then_branch, _if_kind) -> ( + | Prune (condition, loc, _is_then_branch, _if_kind) -> let post, cond_satisfiable = PulseOperations.assert_is_true loc ~condition astate |> check_error summary in - match (cond_satisfiable : PulseOperations.TBool.t) with - | False -> - (* [condition] is known to be unsatisfiable: prune path *) [] - | True | Top -> - (* [condition] is true or unknown value: go into the branch *) [post] ) + if cond_satisfiable then + (* [condition] is true or unknown value: go into the branch *) + [post] + else (* [condition] is known to be unsatisfiable: prune path *) [] | Call (ret, call_exp, actuals, loc, call_flags) -> dispatch_call summary ret call_exp actuals loc call_flags astate |> check_error summary | Metadata (ExitScope (vars, location)) -> diff --git a/infer/src/pulse/PulseOperations.ml b/infer/src/pulse/PulseOperations.ml index 1465ed079..a1f5724ec 100644 --- a/infer/src/pulse/PulseOperations.ml +++ b/infer/src/pulse/PulseOperations.ml @@ -200,7 +200,12 @@ let rec eval_cond ~negated location exp astate = eval_cond ~negated location (Exp.BinOp (Ne, exp, zero)) astate -let assert_is_true location ~condition astate = eval_cond ~negated:false location condition astate +let assert_is_true location ~condition astate = + eval_cond ~negated:false location condition astate + >>| fun (astate, result) -> + let can_go_through = match (result : TBool.t) with Top | True -> true | False -> false in + (astate, can_go_through) + let eval_deref location exp astate = eval location exp astate diff --git a/infer/src/pulse/PulseOperations.mli b/infer/src/pulse/PulseOperations.mli index 37b01b099..223e0a5df 100644 --- a/infer/src/pulse/PulseOperations.mli +++ b/infer/src/pulse/PulseOperations.mli @@ -25,12 +25,7 @@ val eval : Location.t -> Exp.t -> t -> (t * (AbstractValue.t * ValueHistory.t)) Return an error state if it traverses some known invalid address or if the end destination is known to be invalid. *) -module TBool : sig - (** booleans with \top *) - type t = True | False | Top -end - -val assert_is_true : Location.t -> condition:Exp.t -> t -> (t * TBool.t) access_result +val assert_is_true : Location.t -> condition:Exp.t -> t -> (t * bool) access_result val eval_deref : Location.t -> Exp.t -> t -> (t * (AbstractValue.t * ValueHistory.t)) access_result (** Like [eval] but evaluates [*exp]. *)