<commit_before>open Cil
open Pretty
module ID = IntDomain.IntDomTuple
module IndexDomain = ID
module AD = AddressDomain.AddressSet (IndexDomain)
module Addr = Lval.NormalLat (IndexDomain)
module Offs = Lval.Offset (IndexDomain)
module M = Messages
module GU = Goblintutil
module Expp = ExpDomain
module Q = Queries
module AddrSetDomain = SetDomain.ToppedSet(Addr)(struct let topname = "All" end)
module ArrIdxDomain = IndexDomain

module type S =
sig
  include Lattice.S
  type offs
  val eval_offset: Q.ask -> (AD.t -> t) -> t-> offs -> exp option -> lval option -> t
  val update_offset: Q.ask -> t -> offs -> t -> exp option -> lval -> t
  val update_array_lengths: (exp -> t) -> t -> Cil.typ -> t
  val affect_move: ?replace_with_const:bool -> Q.ask -> t -> varinfo -> (exp -> int option) -> t
  val affecting_vars: t -> varinfo list
  val invalidate_value: Q.ask -> typ -> t -> t
  val is_safe_cast: typ -> typ -> bool
  val cast: ?torg:typ -> typ -> t -> t
  val smart_join: (exp -> int64 option) -> (exp -> int64 option) -> t -> t ->  t
  val smart_widen: (exp -> int64 option) -> (exp -> int64 option) ->  t -> t -> t
  val smart_leq: (exp -> int64 option) -> (exp -> int64 option) -> t -> t -> bool
end

module type Blob =
sig
  type value
  type size
  include Lattice.S with type t = value * size

  val make: value -> size -> t
  val value: t -> value
  val size: t -> size
  val invalidate_value: Q.ask -> typ -> t -> t
end

module Blob (Value: S) (Size: IntDomain.S) =
struct
  let name () = "blob"
  include Lattice.Prod (Value) (Size)
  type value = Value.t
  type size = Size.t

  let make v s = v, s
  let value = fst
  let size = snd
  let invalidate_value ask t (v, s) = Value.invalidate_value ask t v, s
end

module rec Compound: S with type t = [
    | `Top
    | `Int of ID.t
    | `Address of AD.t
    | `Struct of Structs.t
    | `Union of Unions.t
    | `Array of CArrays.t
    | `Blob of Blobs.t
    | `List of Lists.t
    | `Bot
  ] and type offs = (fieldinfo,IndexDomain.t) Lval.offs =
struct
  type t = [
    | `Top
    | `Int of ID.t
    | `Address of AD.t
    | `Struct of Structs.t
    | `Union of Unions.t
    | `Array of CArrays.t
    | `Blob of Blobs.t
    | `List of Lists.t
    | `Bot
  ] [@@deriving to_yojson]<commit_msg>Blob: Name size in output instead of intdomtuple<commit_after>open Cil
open Pretty
module ID = IntDomain.IntDomTuple
module IndexDomain = ID
module AD = AddressDomain.AddressSet (IndexDomain)
module Addr = Lval.NormalLat (IndexDomain)
module Offs = Lval.Offset (IndexDomain)
module M = Messages
module GU = Goblintutil
module Expp = ExpDomain
module Q = Queries
module AddrSetDomain = SetDomain.ToppedSet(Addr)(struct let topname = "All" end)
module ArrIdxDomain = IndexDomain

module type S =
sig
  include Lattice.S
  type offs
  val eval_offset: Q.ask -> (AD.t -> t) -> t-> offs -> exp option -> lval option -> t
  val update_offset: Q.ask -> t -> offs -> t -> exp option -> lval -> t
  val update_array_lengths: (exp -> t) -> t -> Cil.typ -> t
  val affect_move: ?replace_with_const:bool -> Q.ask -> t -> varinfo -> (exp -> int option) -> t
  val affecting_vars: t -> varinfo list
  val invalidate_value: Q.ask -> typ -> t -> t
  val is_safe_cast: typ -> typ -> bool
  val cast: ?torg:typ -> typ -> t -> t
  val smart_join: (exp -> int64 option) -> (exp -> int64 option) -> t -> t ->  t
  val smart_widen: (exp -> int64 option) -> (exp -> int64 option) ->  t -> t -> t
  val smart_leq: (exp -> int64 option) -> (exp -> int64 option) -> t -> t -> bool
end

module type Blob =
sig
  type value
  type size
  include Lattice.S with type t = value * size

  val make: value -> size -> t
  val value: t -> value
  val size: t -> size
  val invalidate_value: Q.ask -> typ -> t -> t
end

module Blob (Value: S) (Size: IntDomain.S) =
struct
  let name () = "blob"
  include Lattice.Prod (Value) (Size)
  type value = Value.t
  type size = Size.t

  let printXml f (x,y) =
    BatPrintf.fprintf f "<value>\n<map>\n<key>\n%s\n</key>\n%a<key>\nsize\n</key>\n%a</map>\n</value>\n" (Goblintutil.escape (Value.name ())) Value.printXml x Size.printXml y

  let make v s = v, s
  let value = fst
  let size = snd
  let invalidate_value ask t (v, s) = Value.invalidate_value ask t v, s
end

module rec Compound: S with type t = [
    | `Top
    | `Int of ID.t
    | `Address of AD.t
    | `Struct of Structs.t
    | `Union of Unions.t
    | `Array of CArrays.t
    | `Blob of Blobs.t
    | `List of Lists.t
    | `Bot
  ] and type offs = (fieldinfo,IndexDomain.t) Lval.offs =
struct
  type t = [
    | `Top
    | `Int of ID.t
    | `Address of AD.t
    | `Struct of Structs.t
    | `Union of Unions.t
    | `Array of CArrays.t
    | `Blob of Blobs.t
    | `List of Lists.t
    | `Bot
  ] [@@deriving to_yojson]
{'fraction_non_alphanumeric': 0.1351408154686843, 'fraction_numerical': 0.005044136191677175, 'mean_word_length': 2.6411629686304514, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 125, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '746327', 'n_tokens_mistral': 1741, 'n_tokens_neox': 1723, 'n_words': 597}