[pulse][isl] remove er spec duplicates when code includes conditionals

Reviewed By: skcho

Differential Revision: D27618383

fbshipit-source-id: 05821e019
master
Loc Le 4 years ago committed by Facebook GitHub Bot
parent 2492a4fd3f
commit dcda9b39b3

@ -274,8 +274,15 @@ module PulseTransferFunctions = struct
({InterproceduralAnalysis.tenv; proc_desc; err_log} as analysis_data) _cfg_node
(instr : Sil.instr) : Domain.t list =
match astate with
| AbortProgram _ | ISLLatentMemoryError _ | LatentAbortProgram _ | LatentInvalidAccess _ ->
| AbortProgram _ | LatentAbortProgram _ | LatentInvalidAccess _ ->
[astate]
| ISLLatentMemoryError _ -> (
(* Note: This is to avoid duplicated error states at join point of branch *)
match instr with
| Prune (_, _, is_then_branch, _) when is_then_branch ->
[]
| _ ->
[astate] )
| ExitProgram _ ->
(* program already exited, simply propagate the exited state upwards *)
[astate]

@ -354,7 +354,6 @@ module AddressAttributes = struct
(astate.post :> BaseDomain.t).attrs
with
| None ->
let is_eq_null = PathCondition.is_known_zero astate.path_condition addr in
let null_astates =
if PathCondition.is_known_not_equal_zero astate.path_condition addr then []
else
@ -365,20 +364,23 @@ module AddressAttributes = struct
let null_astate = abduce_attribute addr null_attr null_astate in
if null_noop then [Ok null_astate] else [Error (`ISLError null_astate)]
in
if is_eq_null then null_astates
else
let valid_astate =
let abdalloc = Attribute.ISLAbduced access_trace in
let valid_attr = Attribute.MustBeValid access_trace in
add_one addr abdalloc astate |> abduce_attribute addr valid_attr
|> abduce_attribute addr abdalloc
in
let invalid_free =
(*C or Cpp?*)
let invalid_attr = Attribute.Invalid (CFree, access_trace) in
abduce_attribute addr invalid_attr astate |> add_one addr invalid_attr
in
Ok valid_astate :: Error (`ISLError invalid_free) :: null_astates
let not_null_astates =
if PathCondition.is_known_zero astate.path_condition addr then []
else
let valid_astate =
let abdalloc = Attribute.ISLAbduced access_trace in
let valid_attr = Attribute.MustBeValid access_trace in
add_one addr abdalloc astate |> abduce_attribute addr valid_attr
|> abduce_attribute addr abdalloc
in
let invalid_free =
(*C or Cpp?*)
let invalid_attr = Attribute.Invalid (CFree, access_trace) in
abduce_attribute addr invalid_attr astate |> add_one addr invalid_attr
in
[Ok valid_astate; Error (`ISLError invalid_free)]
in
not_null_astates @ null_astates
| Some _ ->
[Ok astate] )
| Some (invalidation, invalidation_trace) ->

Loading…
Cancel
Save