LCOV - code coverage report
Current view: top level - include/llvm/ADT - ilist_base.h (source / functions) Hit Total Coverage
Test: llvm-toolchain.info Lines: 31 31 100.0 %
Date: 2017-09-14 15:23:50 Functions: 1 1 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : //===- llvm/ADT/ilist_base.h - Intrusive List Base --------------*- C++ -*-===//
       2             : //
       3             : //                     The LLVM Compiler Infrastructure
       4             : //
       5             : // This file is distributed under the University of Illinois Open Source
       6             : // License. See LICENSE.TXT for details.
       7             : //
       8             : //===----------------------------------------------------------------------===//
       9             : 
      10             : #ifndef LLVM_ADT_ILIST_BASE_H
      11             : #define LLVM_ADT_ILIST_BASE_H
      12             : 
      13             : #include "llvm/ADT/ilist_node_base.h"
      14             : #include <cassert>
      15             : 
      16             : namespace llvm {
      17             : 
      18             : /// Implementations of list algorithms using ilist_node_base.
      19             : template <bool EnableSentinelTracking> class ilist_base {
      20             : public:
      21             :   using node_base_type = ilist_node_base<EnableSentinelTracking>;
      22             : 
      23             :   static void insertBeforeImpl(node_base_type &Next, node_base_type &N) {
      24    56059744 :     node_base_type &Prev = *Next.getPrev();
      25   112119404 :     N.setNext(&Next);
      26   105663018 :     N.setPrev(&Prev);
      27   112119464 :     Prev.setNext(&N);
      28   105662946 :     Next.setPrev(&N);
      29             :   }
      30             : 
      31             :   static void removeImpl(node_base_type &N) {
      32    50548317 :     node_base_type *Prev = N.getPrev();
      33    50548317 :     node_base_type *Next = N.getNext();
      34    97778853 :     Next->setPrev(Prev);
      35   101096634 :     Prev->setNext(Next);
      36             : 
      37             :     // Not strictly necessary, but helps catch a class of bugs.
      38    97778838 :     N.setPrev(nullptr);
      39   101096619 :     N.setNext(nullptr);
      40             :   }
      41             : 
      42             :   static void removeRangeImpl(node_base_type &First, node_base_type &Last) {
      43           3 :     node_base_type *Prev = First.getPrev();
      44           5 :     node_base_type *Final = Last.getPrev();
      45           8 :     Last.setPrev(Prev);
      46          10 :     Prev->setNext(&Last);
      47             : 
      48             :     // Not strictly necessary, but helps catch a class of bugs.
      49           8 :     First.setPrev(nullptr);
      50          10 :     Final->setNext(nullptr);
      51             :   }
      52             : 
      53     1089145 :   static void transferBeforeImpl(node_base_type &Next, node_base_type &First,
      54             :                                  node_base_type &Last) {
      55     1613577 :     if (&Next == &Last || &First == &Last)
      56             :       return;
      57             : 
      58             :     // Position cannot be contained in the range to be transferred.
      59             :     assert(&Next != &First &&
      60             :            // Check for the most common mistake.
      61             :            "Insertion point can't be one of the transferred nodes");
      62             : 
      63     1613563 :     node_base_type &Final = *Last.getPrev();
      64             : 
      65             :     // Detach from old list/position.
      66     3227126 :     First.getPrev()->setNext(&Last);
      67     3227122 :     Last.setPrev(First.getPrev());
      68             : 
      69             :     // Splice [First, Final] into its new list/position.
      70     1613563 :     node_base_type &Prev = *Next.getPrev();
      71     3227126 :     Final.setNext(&Next);
      72     2137980 :     First.setPrev(&Prev);
      73     3227126 :     Prev.setNext(&First);
      74      524417 :     Next.setPrev(&Final);
      75             :   }
      76             : 
      77             :   template <class T> static void insertBefore(T &Next, T &N) {
      78   112119428 :     insertBeforeImpl(Next, N);
      79             :   }
      80             : 
      81   101096626 :   template <class T> static void remove(T &N) { removeImpl(N); }
      82             :   template <class T> static void removeRange(T &First, T &Last) {
      83           2 :     removeRangeImpl(First, Last);
      84             :   }
      85             : 
      86             :   template <class T> static void transferBefore(T &Next, T &First, T &Last) {
      87     1614334 :     transferBeforeImpl(Next, First, Last);
      88             :   }
      89             : };
      90             : 
      91             : } // end namespace llvm
      92             : 
      93             : #endif // LLVM_ADT_ILIST_BASE_H

Generated by: LCOV version 1.13