<commit_before>(*
 * Copyright (c) 2017 - present Facebook, Inc.
 * All rights reserved.
 *
 * This source code is licensed under the BSD style license found in the
 * LICENSE file in the root directory of this source tree. An additional grant
 * of patent rights can be found in the PATENTS file in the same directory.
 *)
type retain_cycle_node = {rc_node_exp: Exp.t; rc_node_typ: Typ.t}

type retain_cycle_field_objc = {rc_field_name: Typ.Fieldname.t; rc_field_inst: Sil.inst}

type retain_cycle_edge = {rc_from: retain_cycle_node; rc_field: retain_cycle_field_objc}

type t = {rc_elements: retain_cycle_edge list; rc_head: retain_cycle_edge}

let create_cycle cycle =
  match cycle with hd :: _ -> Some {rc_elements= cycle; rc_head= hd} | [] -> None


let retain_cycle_node_to_string (node: retain_cycle_node) =
  Format.sprintf "%s : %s" (Exp.to_string node.rc_node_exp) (Typ.to_string node.rc_node_typ)


let retain_cycle_field_to_string (field: retain_cycle_field_objc) =
  Format.sprintf "%s[%s]"
    (Typ.Fieldname.to_string field.rc_field_name)
    (Sil.inst_to_string field.rc_field_inst)


let retain_cycle_edge_to_string (edge: retain_cycle_edge) =
  Format.sprintf "%s ->{%s}"
    (retain_cycle_node_to_string edge.rc_from)
    (retain_cycle_field_to_string edge.rc_field)

<commit_msg>[retain cycles] Remove false positive retain cycles<commit_after>(*
 * Copyright (c) 2017 - present Facebook, Inc.
 * All rights reserved.
 *
 * This source code is licensed under the BSD style license found in the
 * LICENSE file in the root directory of this source tree. An additional grant
 * of patent rights can be found in the PATENTS file in the same directory.
 *)
type retain_cycle_node = {rc_node_exp: Exp.t; rc_node_typ: Typ.t}

type retain_cycle_field_objc = {rc_field_name: Typ.Fieldname.t; rc_field_inst: Sil.inst}

type retain_cycle_edge = {rc_from: retain_cycle_node; rc_field: retain_cycle_field_objc}

type t = {rc_elements: retain_cycle_edge list; rc_head: retain_cycle_edge}

let create_cycle cycle =
  match cycle with
  | [hd] -> (
    match (* cycles of length 1 created at rearrange are not real *)
          hd.rc_field.rc_field_inst with
    | Sil.Irearrange _ ->
        None
    | _ ->
        Some {rc_elements= cycle; rc_head= hd} )
  | hd :: _ ->
      Some {rc_elements= cycle; rc_head= hd}
  | [] ->
      None


let retain_cycle_node_to_string (node: retain_cycle_node) =
  Format.sprintf "%s : %s" (Exp.to_string node.rc_node_exp) (Typ.to_string node.rc_node_typ)


let retain_cycle_field_to_string (field: retain_cycle_field_objc) =
  Format.sprintf "%s[%s]"
    (Typ.Fieldname.to_string field.rc_field_name)
    (Sil.inst_to_string field.rc_field_inst)


let retain_cycle_edge_to_string (edge: retain_cycle_edge) =
  Format.sprintf "%s ->{%s}"
    (retain_cycle_node_to_string edge.rc_from)
    (retain_cycle_field_to_string edge.rc_field)


{'fraction_non_alphanumeric': 0.09447724904480723, 'fraction_numerical': 0.003126085446335533, 'mean_word_length': 4.464895635673624, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 12, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2872292', 'n_tokens_mistral': 1019, 'n_tokens_neox': 997, 'n_words': 267}