[absint] make InvertedSet/InvertedMap functors consistent non-inverted versions

Reviewed By: mbouaziz

Differential Revision: D5879318

fbshipit-source-id: 278e5ad
master
Sam Blackshear 7 years ago committed by Facebook Github Bot
parent ca51c72f3a
commit 45dbb42705

@ -151,8 +151,8 @@ module FiniteSet (Element : PrettyPrintable.PrintableOrderedType) = struct
let widen ~prev ~next ~num_iters:_ = join prev next let widen ~prev ~next ~num_iters:_ = join prev next
end end
module InvertedSet (S : PrettyPrintable.PPSet) = struct module InvertedSet (Element : PrettyPrintable.PrintableOrderedType) = struct
include S include PrettyPrintable.MakePPSet (Element)
type astate = t type astate = t
@ -210,7 +210,8 @@ module Map (Key : PrettyPrintable.PrintableOrderedType) (ValueDomain : S) = stru
let pp fmt astate = M.pp ~pp_value:ValueDomain.pp fmt astate let pp fmt astate = M.pp ~pp_value:ValueDomain.pp fmt astate
end end
module InvertedMap (M : PrettyPrintable.PPMap) (ValueDomain : S) = struct module InvertedMap (Key : PrettyPrintable.PrintableOrderedType) (ValueDomain : S) = struct
module M = PrettyPrintable.MakePPMap (Key)
include M include M
type astate = ValueDomain.astate M.t type astate = ValueDomain.astate M.t
@ -246,9 +247,6 @@ module InvertedMap (M : PrettyPrintable.PPMap) (ValueDomain : S) = struct
prev next prev next
let pp fmt astate = M.pp ~pp_value:ValueDomain.pp fmt astate let pp fmt astate = M.pp ~pp_value:ValueDomain.pp fmt astate
(* hide empty so we don't accidentally satisfy the WithBottom signature *)
let empty = `This_domain_is_not_pointed
end end
module BooleanAnd = struct module BooleanAnd = struct

@ -71,8 +71,8 @@ module FiniteSet (Element : PrettyPrintable.PrintableOrderedType) : sig
end end
(** Lift a set to a powerset domain ordered by superset, so the join operator is intersection *) (** Lift a set to a powerset domain ordered by superset, so the join operator is intersection *)
module InvertedSet (Set : PrettyPrintable.PPSet) : sig module InvertedSet (Element : PrettyPrintable.PrintableOrderedType) : sig
include PrettyPrintable.PPSet with type t = Set.t and type elt = Set.elt include module type of PrettyPrintable.MakePPSet (Element)
include S with type astate = t include S with type astate = t
end end
@ -87,13 +87,10 @@ end
(** Map domain ordered by intersection over the set of bindings, so the top element is the empty (** Map domain ordered by intersection over the set of bindings, so the top element is the empty
map. Every element implictly maps to top unless it is explicitly bound to something else *) map. Every element implictly maps to top unless it is explicitly bound to something else *)
module InvertedMap (Map : PrettyPrintable.PPMap) (ValueDomain : S) : sig module InvertedMap (Key : PrettyPrintable.PrintableOrderedType) (ValueDomain : S) : sig
include PrettyPrintable.PPMap with type 'a t = 'a Map.t and type key = Map.key include module type of PrettyPrintable.MakePPMap (Key)
include S with type astate = ValueDomain.astate Map.t
val empty : [`This_domain_is_not_pointed] include S with type astate = ValueDomain.astate t
(** this domain doesn't have a natural bottom element *)
end end
(** Boolean domain ordered by p || ~q. Useful when you want a boolean that's true only when it's (** Boolean domain ordered by p || ~q. Useful when you want a boolean that's true only when it's

@ -194,7 +194,7 @@ module Attribute = struct
end) end)
end end
module AttributeSetDomain = AbstractDomain.InvertedSet (Attribute.Set) module AttributeSetDomain = AbstractDomain.InvertedSet (Attribute)
module OwnershipAbstractValue = struct module OwnershipAbstractValue = struct
type astate = Owned | OwnedIf of IntSet.t | Unowned [@@deriving compare] type astate = Owned | OwnedIf of IntSet.t | Unowned [@@deriving compare]
@ -257,7 +257,7 @@ module OwnershipDomain = struct
end end
module AttributeMapDomain = struct module AttributeMapDomain = struct
include AbstractDomain.InvertedMap (AccessPath.Map) (AttributeSetDomain) include AbstractDomain.InvertedMap (AccessPath) (AttributeSetDomain)
let add access_path attribute_set t = let add access_path attribute_set t =
if AttributeSetDomain.is_empty attribute_set then t else add access_path attribute_set t if AttributeSetDomain.is_empty attribute_set then t else add access_path attribute_set t
@ -377,7 +377,7 @@ let empty =
let locks = false in let locks = false in
let accesses = AccessDomain.empty in let accesses = AccessDomain.empty in
let ownership = OwnershipDomain.empty in let ownership = OwnershipDomain.empty in
let attribute_map = AccessPath.Map.empty in let attribute_map = AttributeMapDomain.empty in
let escapees = EscapeeDomain.empty in let escapees = EscapeeDomain.empty in
{thumbs_up; threads; locks; accesses; ownership; attribute_map; escapees} {thumbs_up; threads; locks; accesses; ownership; attribute_map; escapees}

@ -108,10 +108,10 @@ module Attribute : sig
module Set : PrettyPrintable.PPSet with type elt = t module Set : PrettyPrintable.PPSet with type elt = t
end end
module AttributeSetDomain : module type of AbstractDomain.InvertedSet (Attribute.Set) module AttributeSetDomain : module type of AbstractDomain.InvertedSet (Attribute)
module AttributeMapDomain : sig module AttributeMapDomain : sig
include module type of AbstractDomain.InvertedMap (AccessPath.Map) (AttributeSetDomain) include module type of AbstractDomain.InvertedMap (AccessPath) (AttributeSetDomain)
val add : AccessPath.t -> AttributeSetDomain.astate -> astate -> astate val add : AccessPath.t -> AttributeSetDomain.astate -> astate -> astate

Loading…
Cancel
Save