@@ -398,18 +398,6 @@ module PulseTransferFunctions = struct
398398 astates
399399 in
400400 (PulseReport. report_results tenv proc_desc err_log loc result, path, astate_n)
401- | Prune (condition , loc , _is_then_branch , _if_kind ) ->
402- let results =
403- (let < *> astate = PulseOperations. prune path loc ~condition astate in
404- if PulseArithmetic. is_unsat_cheap astate then
405- (* [condition] is known to be unsatisfiable: prune path *)
406- []
407- else
408- (* [condition] is true or unknown value: go into the branch *)
409- [Ok (ContinueProgram astate)] )
410- |> PulseReport. report_exec_results tenv proc_desc err_log loc
411- in
412- (results, path, astate_n)
413401 | Call (ret , call_exp , actuals , loc , call_flags ) ->
414402 let astates =
415403 dispatch_call analysis_data path ret call_exp actuals loc call_flags astate
@@ -419,6 +407,40 @@ module PulseTransferFunctions = struct
419407 , path
420408 , PulseNonDisjunctiveOperations. add_copies loc call_exp actuals call_flags astates
421409 astate_n )
410+ | Prune (condition , loc , is_then_branch , if_kind ) ->
411+ let result, path =
412+ match PulseOperations. prune path loc ~condition astate with
413+ | Ok (astate , hist ) ->
414+ let path =
415+ if Sil. is_terminated_if_kind if_kind then
416+ let hist =
417+ ValueHistory. ConditionPassed
418+ {if_kind; is_then_branch; location= loc; timestamp}
419+ :: hist
420+ in
421+ {path with conditions= hist :: path .conditions}
422+ else path
423+ in
424+ (Ok astate, path)
425+ | Error _ as err ->
426+ (err, path)
427+ in
428+ let results =
429+ let < *> astate = result in
430+ if PulseArithmetic. is_unsat_cheap astate then
431+ (* [condition] is known to be unsatisfiable: prune path *)
432+ []
433+ else
434+ (* [condition] is true or unknown value: go into the branch *)
435+ [Ok (ContinueProgram astate)]
436+ in
437+ (PulseReport. report_exec_results tenv proc_desc err_log loc results, path, astate_n)
438+ | Metadata EndBranches ->
439+ (* We assume that terminated conditions are well-parenthesised, hence an [EndBranches]
440+ instruction terminates the most recently seen terminated conditional. The empty case
441+ shouldn't happen but let's not crash by the fault of possible errors in frontends. *)
442+ let path = {path with conditions= List. tl path.conditions |> Option. value ~default: [] } in
443+ ([ContinueProgram astate], path, astate_n)
422444 | Metadata (ExitScope (vars , location )) ->
423445 let remove_vars vars astates =
424446 List. map astates ~f: (fun (exec_state : ExecutionDomain.t ) ->
@@ -458,7 +480,6 @@ module PulseTransferFunctions = struct
458480 | Metadata
459481 ( Abstract _
460482 | CatchEntry _
461- | EndBranches
462483 | Nullify _
463484 | Skip
464485 | TryEntry _
0 commit comments