diff --git a/infer/src/pulse/PulseBaseAddressAttributes.ml b/infer/src/pulse/PulseBaseAddressAttributes.ml index 7fe17bb5c2..70f10219e8 100644 --- a/infer/src/pulse/PulseBaseAddressAttributes.ml +++ b/infer/src/pulse/PulseBaseAddressAttributes.ml @@ -51,6 +51,8 @@ let empty = Graph.empty let filter = Graph.filter +let map = Graph.map + (* for an abstract value v, where f_keep(v) == false, find an abstract value v_keep, where f_keep(v_keep) == true and where v_keep has taint propagated from v *) let mk_transitive_taint_from_subst f_keep memory = @@ -384,6 +386,8 @@ module type S = sig val filter_with_discarded_addrs : (key -> bool) -> t -> t * AbstractValue.t list + val map : (Attributes.t -> Attributes.t) -> t -> t + val find_opt : key -> t -> Attributes.t option val add_one : key -> Attribute.t -> t -> t diff --git a/infer/src/pulse/PulseBaseAddressAttributes.mli b/infer/src/pulse/PulseBaseAddressAttributes.mli index 9f4cae8157..d22f87e1ec 100644 --- a/infer/src/pulse/PulseBaseAddressAttributes.mli +++ b/infer/src/pulse/PulseBaseAddressAttributes.mli @@ -21,6 +21,8 @@ module type S = sig val filter_with_discarded_addrs : (key -> bool) -> t -> t * AbstractValue.t list + val map : (Attributes.t -> Attributes.t) -> t -> t + val find_opt : key -> t -> Attributes.t option val add_one : key -> Attribute.t -> t -> t diff --git a/infer/src/pulse/PulseBaseDomain.ml b/infer/src/pulse/PulseBaseDomain.ml index 97b0096ec1..2b88a6778c 100644 --- a/infer/src/pulse/PulseBaseDomain.ml +++ b/infer/src/pulse/PulseBaseDomain.ml @@ -28,6 +28,24 @@ let empty = type cell = Memory.Edges.t * Attributes.t let pp fmt {heap; stack; attrs} = + let attrs = + if Language.curr_language_is Python then + let filter_attribute (attr : Attribute.t) = + match attr with + | Attribute.Allocated _ | AwaitedAwaitable | MustNotBeTainted _ | StaticType _ | Tainted _ + -> + true + | _ -> + false + in + let attrs = AddressAttributes.map (Attributes.filter ~f:filter_attribute) attrs in + AddressAttributes.filter + (fun _ attr -> + let set = Attributes.filter attr ~f:filter_attribute in + not (Attributes.is_empty set) ) + attrs + else attrs + in F.fprintf fmt "{@[ roots=@[%a@];@;mem =@[%a@];@;attrs=@[%a@];@]}" Stack.pp stack Memory.pp heap AddressAttributes.pp attrs