<commit_before>//==-- llvm/ADT/ilist.h - Intrusive Linked List Template ---------*- C++ -*-==//
//
//                     The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file defines classes to implement an intrusive doubly linked list class
// (i.e. each node of the list must contain a next and previous field for the
// list.
//
// The ilist_traits trait class is used to gain access to the next and previous
// fields of the node type that the list is instantiated with.  If it is not
// specialized, the list defaults to using the getPrev(), getNext() method calls
// to get the next and previous pointers.
//
// The ilist class itself, should be a plug in replacement for list, assuming
// that the nodes contain next/prev pointers.  This list replacement does not
// provide a constant time size() method, so be careful to use empty() when you
// really want to know if it's empty.
//
// The ilist class is implemented by allocating a 'tail' node when the list is
// created (using ilist_traits<>::createSentinel()).  This tail node is
// absolutely required because the user must be able to compute end()-1. Because
// of this, users of the direct next/prev links will see an extra link on the
// end of the list, which should be ignored.
//
// Requirements for a user of this list:
//
//   1. The user must provide {g|s}et{Next|Prev} methods, or specialize
//      ilist_traits to provide an alternate way of getting and setting next and
//      prev links.
//
//===----------------------------------------------------------------------===//

#ifndef LLVM_ADT_ILIST_H
#define LLVM_ADT_ILIST_H

#include "llvm/Support/Compiler.h"
#include <algorithm>
#include <cassert>
#include <cstddef>
#include <iterator>
#include <type_traits>

namespace llvm {

template<typename NodeTy, typename Traits> class iplist;
template<typename NodeTy> class ilist_iterator;

/// An access class for next/prev on ilist_nodes.
///
/// This gives access to the private parts of ilist nodes.  Nodes for an ilist
/// should friend this class if they inherit privately from ilist_node.
///
/// It's strongly discouraged to *use* this class outside of ilist
/// implementation.
struct ilist_node_access {
  template <typename NodeTy> static NodeTy *getPrev(NodeTy *N) {
    return N->getPrev();
  }
  template <typename NodeTy> static NodeTy *getNext(NodeTy *N) {
    return N->getNext();
  }
  template <typename NodeTy> static const NodeTy *getPrev(const NodeTy *N) {
    return N->getPrev();
  }
  template <typename NodeTy> static const NodeTy *getNext(const NodeTy *N) {
    return N->getNext();
  }

  template <typename NodeTy> static void setPrev(NodeTy *N, NodeTy *Prev) {
    N->setPrev(Prev);
  }
  template <typename NodeTy> static void setNext(NodeTy *N, NodeTy *Next) {
    N->setNext(Next);
  }
  template <typename NodeTy> static void setPrev(NodeTy *N, std::nullptr_t) {
    N->setPrev(nullptr);
  }
  template <typename NodeTy> static void setNext(NodeTy *N, std::nullptr_t) {
    N->setNext(nullptr);
  }
};

namespace ilist_detail {

template <class T> T &make();

/// Type trait to check for a traits class that has a getNext member (as a
/// canary for any of the ilist_nextprev_traits API).
template <class TraitsT, class NodeT> struct HasGetNext {
  typedef char Yes[1];
  typedef char No[2];
  template <size_t N> struct SFINAE {};

  template <class U, class V>
  static Yes &hasGetNext(
      SFINAE<sizeof(static_cast<NodeT *>(make<U>().getNext(&make<NodeT>())))>
          * = 0);
  template <class U, class V> static No &hasGetNext(...);

  static const bool value =
      sizeof(hasGetNext<TraitsT, NodeT>(nullptr)) == sizeof(Yes);
};

} // end namespace ilist_detail

template<typename NodeTy>
struct ilist_traits;

/// ilist_sentinel_traits - A fragment for template traits for intrusive list
/// that provides default sentinel implementations for common operations.
///
/// ilist_sentinel_traits implements a lazy dynamic sentinel allocation
/// strategy. The sentinel is stored in the prev field of ilist's Head.
///
template<typename NodeTy>
struct ilist_sentinel_traits {<commit_msg>Try to appease win7 bots after r278532 by cleaning up type trait<commit_after>//==-- llvm/ADT/ilist.h - Intrusive Linked List Template ---------*- C++ -*-==//
//
//                     The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file defines classes to implement an intrusive doubly linked list class
// (i.e. each node of the list must contain a next and previous field for the
// list.
//
// The ilist_traits trait class is used to gain access to the next and previous
// fields of the node type that the list is instantiated with.  If it is not
// specialized, the list defaults to using the getPrev(), getNext() method calls
// to get the next and previous pointers.
//
// The ilist class itself, should be a plug in replacement for list, assuming
// that the nodes contain next/prev pointers.  This list replacement does not
// provide a constant time size() method, so be careful to use empty() when you
// really want to know if it's empty.
//
// The ilist class is implemented by allocating a 'tail' node when the list is
// created (using ilist_traits<>::createSentinel()).  This tail node is
// absolutely required because the user must be able to compute end()-1. Because
// of this, users of the direct next/prev links will see an extra link on the
// end of the list, which should be ignored.
//
// Requirements for a user of this list:
//
//   1. The user must provide {g|s}et{Next|Prev} methods, or specialize
//      ilist_traits to provide an alternate way of getting and setting next and
//      prev links.
//
//===----------------------------------------------------------------------===//

#ifndef LLVM_ADT_ILIST_H
#define LLVM_ADT_ILIST_H

#include "llvm/Support/Compiler.h"
#include <algorithm>
#include <cassert>
#include <cstddef>
#include <iterator>
#include <type_traits>

namespace llvm {

template<typename NodeTy, typename Traits> class iplist;
template<typename NodeTy> class ilist_iterator;

/// An access class for next/prev on ilist_nodes.
///
/// This gives access to the private parts of ilist nodes.  Nodes for an ilist
/// should friend this class if they inherit privately from ilist_node.
///
/// It's strongly discouraged to *use* this class outside of ilist
/// implementation.
struct ilist_node_access {
  template <typename NodeTy> static NodeTy *getPrev(NodeTy *N) {
    return N->getPrev();
  }
  template <typename NodeTy> static NodeTy *getNext(NodeTy *N) {
    return N->getNext();
  }
  template <typename NodeTy> static const NodeTy *getPrev(const NodeTy *N) {
    return N->getPrev();
  }
  template <typename NodeTy> static const NodeTy *getNext(const NodeTy *N) {
    return N->getNext();
  }

  template <typename NodeTy> static void setPrev(NodeTy *N, NodeTy *Prev) {
    N->setPrev(Prev);
  }
  template <typename NodeTy> static void setNext(NodeTy *N, NodeTy *Next) {
    N->setNext(Next);
  }
  template <typename NodeTy> static void setPrev(NodeTy *N, std::nullptr_t) {
    N->setPrev(nullptr);
  }
  template <typename NodeTy> static void setNext(NodeTy *N, std::nullptr_t) {
    N->setNext(nullptr);
  }
};

namespace ilist_detail {

template <class T> T &make();

/// Type trait to check for a traits class that has a getNext member (as a
/// canary for any of the ilist_nextprev_traits API).
template <class TraitsT, class NodeT> struct HasGetNext {
  typedef char Yes[1];
  typedef char No[2];
  template <size_t N> struct SFINAE {};

  template <class U>
  static Yes &hasGetNext(
      SFINAE<sizeof(static_cast<NodeT *>(make<U>().getNext(&make<NodeT>())))>
          * = 0);
  template <class U> static No &hasGetNext(...);

  static const bool value = sizeof(hasGetNext<TraitsT>(nullptr)) == sizeof(Yes);
};

} // end namespace ilist_detail

template<typename NodeTy>
struct ilist_traits;

/// ilist_sentinel_traits - A fragment for template traits for intrusive list
/// that provides default sentinel implementations for common operations.
///
/// ilist_sentinel_traits implements a lazy dynamic sentinel allocation
/// strategy. The sentinel is stored in the prev field of ilist's Head.
///
template<typename NodeTy>
struct ilist_sentinel_traits {
{'fraction_non_alphanumeric': 0.1400232018561485, 'fraction_numerical': 0.00197215777262181, 'mean_word_length': 3.056941176470588, 'pattern_counts': {'":': 0, '<': 59, '<?xml version=': 0, '>': 75, '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': '4858547', 'n_tokens_mistral': 2520, 'n_tokens_neox': 2454, 'n_words': 1012}