<commit_before>(** Globally accessible flags and utility functions. *)

open Cil
open GobConfig

open Json

(** Outputs information about what the goblin is doing *)
(* let verbose = ref false *)

(** Json files that are given as arguments *)
let jsonFiles : string list ref = ref []

(** If this is true we output messages and collect accesses.
    This is set to true in control.ml before we verify the result (or already before solving if warn = 'early') *)
let should_warn = ref false

let did_overflow = ref false

(** hack to use a special integer to denote synchronized array-based locking *)
let inthack = Int64.of_int (-19012009) (* TODO do we still need this? *)

(** number of times that globals change !CAUTION: This is only set in contain.ml and is not what one would think it is! *)
let globals_changed = ref 0

(** The file where everything is output *)
let out = ref stdout

(** Temp directory, set in maingoblint.ml, but used by the OSEK analysis. *)
let tempDirName = ref "goblint_temp"

(** Command for assigning an id to a varinfo. All varinfos directly created by Goblint should be modified by this method *)
let create_var (var: varinfo) =
  (* TODO Hack: this offset should preempt conflicts with ids generated by CIL *)
  let start_id = 10_000_000_000 in
  let hash = Hashtbl.hash { var with vid = 0 } in
  let hash = if hash < start_id then hash + start_id else hash in
  { var with vid = hash }

(* Type invariant variables. *)
let type_inv_tbl = Hashtbl.create 13
let type_inv (c:compinfo) : varinfo =
  try Hashtbl.find type_inv_tbl c.ckey
  with Not_found ->
    let i = create_var (makeGlobalVar ("{struct "^c.cname^"}") (TComp (c,[]))) in
    Hashtbl.add type_inv_tbl c.ckey i;
    i

let is_blessed (t:typ): varinfo option =
  let me_gusta x = List.mem x (List.map string (get_list "exp.unique")) in
  match unrollType t with
  | TComp (ci,_) when me_gusta ci.cname -> Some (type_inv ci)
  | _ -> (None : varinfo option)


(** Length of summary description in XML output *)
let summary_length = 80

(** A hack to see if we are currently doing global inits *)
let global_initialization = ref false

(** Another hack to see if earlyglobs is enabled *)
let earlyglobs = ref false

(** true if in verifying stage *)
let in_verifying_stage = ref false

(* None if verification is disabled, Some true if verification succeeded, Some false if verification failed *)
let verified : bool option ref = ref None

let escape = XmlUtil.escape (* TODO: inline everywhere *)

let trim (x:string): string =
  let len = String.length x in
  if x.[len-1] = ' ' then String.sub x 0 (len-1) else x


(** Creates a directory and returns the absolute path **)
let create_dir name =
  let dirName = if Filename.is_relative name then Filename.concat (Unix.getcwd ()) name else name in<commit_msg>Remove unused GoblintUtil.summary_length<commit_after>(** Globally accessible flags and utility functions. *)

open Cil
open GobConfig

open Json

(** Outputs information about what the goblin is doing *)
(* let verbose = ref false *)

(** Json files that are given as arguments *)
let jsonFiles : string list ref = ref []

(** If this is true we output messages and collect accesses.
    This is set to true in control.ml before we verify the result (or already before solving if warn = 'early') *)
let should_warn = ref false

let did_overflow = ref false

(** hack to use a special integer to denote synchronized array-based locking *)
let inthack = Int64.of_int (-19012009) (* TODO do we still need this? *)

(** number of times that globals change !CAUTION: This is only set in contain.ml and is not what one would think it is! *)
let globals_changed = ref 0

(** The file where everything is output *)
let out = ref stdout

(** Temp directory, set in maingoblint.ml, but used by the OSEK analysis. *)
let tempDirName = ref "goblint_temp"

(** Command for assigning an id to a varinfo. All varinfos directly created by Goblint should be modified by this method *)
let create_var (var: varinfo) =
  (* TODO Hack: this offset should preempt conflicts with ids generated by CIL *)
  let start_id = 10_000_000_000 in
  let hash = Hashtbl.hash { var with vid = 0 } in
  let hash = if hash < start_id then hash + start_id else hash in
  { var with vid = hash }

(* Type invariant variables. *)
let type_inv_tbl = Hashtbl.create 13
let type_inv (c:compinfo) : varinfo =
  try Hashtbl.find type_inv_tbl c.ckey
  with Not_found ->
    let i = create_var (makeGlobalVar ("{struct "^c.cname^"}") (TComp (c,[]))) in
    Hashtbl.add type_inv_tbl c.ckey i;
    i

let is_blessed (t:typ): varinfo option =
  let me_gusta x = List.mem x (List.map string (get_list "exp.unique")) in
  match unrollType t with
  | TComp (ci,_) when me_gusta ci.cname -> Some (type_inv ci)
  | _ -> (None : varinfo option)


(** A hack to see if we are currently doing global inits *)
let global_initialization = ref false

(** Another hack to see if earlyglobs is enabled *)
let earlyglobs = ref false

(** true if in verifying stage *)
let in_verifying_stage = ref false

(* None if verification is disabled, Some true if verification succeeded, Some false if verification failed *)
let verified : bool option ref = ref None

let escape = XmlUtil.escape (* TODO: inline everywhere *)

let trim (x:string): string =
  let len = String.length x in
  if x.[len-1] = ' ' then String.sub x 0 (len-1) else x


(** Creates a directory and returns the absolute path **)
let create_dir name =
  let dirName = if Filename.is_relative name then Filename.concat (Unix.getcwd ()) name else name in
{'fraction_non_alphanumeric': 0.09084367692030941, 'fraction_numerical': 0.010433531210649397, 'mean_word_length': 3.8686514886164622, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, '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': '2848216', 'n_tokens_mistral': 1749, 'n_tokens_neox': 1659, 'n_words': 763}