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

          Line data    Source code
       1             : //===- Sequence.h - Utility for producing sequences of values ---*- 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             : /// \file
      10             : /// This routine provides some synthesis utilities to produce sequences of
      11             : /// values. The names are intentionally kept very short as they tend to occur
      12             : /// in common and widely used contexts.
      13             : ///
      14             : //===----------------------------------------------------------------------===//
      15             : 
      16             : #ifndef LLVM_ADT_SEQUENCE_H
      17             : #define LLVM_ADT_SEQUENCE_H
      18             : 
      19             : #include "llvm/ADT/iterator.h"
      20             : #include "llvm/ADT/iterator_range.h"
      21             : #include <algorithm>
      22             : #include <iterator>
      23             : #include <utility>
      24             : 
      25             : namespace llvm {
      26             : 
      27             : namespace detail {
      28             : 
      29             : template <typename ValueT>
      30             : class value_sequence_iterator
      31             :     : public iterator_facade_base<value_sequence_iterator<ValueT>,
      32             :                                   std::random_access_iterator_tag,
      33             :                                   const ValueT> {
      34             :   using BaseT = typename value_sequence_iterator::iterator_facade_base;
      35             : 
      36             :   ValueT Value;
      37             : 
      38             : public:
      39             :   using difference_type = typename BaseT::difference_type;
      40             :   using reference = typename BaseT::reference;
      41             : 
      42             :   value_sequence_iterator() = default;
      43             :   value_sequence_iterator(const value_sequence_iterator &) = default;
      44             :   value_sequence_iterator(value_sequence_iterator &&Arg)
      45         120 :       : Value(std::move(Arg.Value)) {}
      46             : 
      47             :   template <typename U, typename Enabler = decltype(ValueT(std::declval<U>()))>
      48          58 :   value_sequence_iterator(U &&Value) : Value(std::forward<U>(Value)) {}
      49             : 
      50             :   value_sequence_iterator &operator+=(difference_type N) {
      51       25957 :     Value += N;
      52             :     return *this;
      53             :   }
      54             :   value_sequence_iterator &operator-=(difference_type N) {
      55           1 :     Value -= N;
      56             :     return *this;
      57             :   }
      58             :   using BaseT::operator-;
      59             :   difference_type operator-(const value_sequence_iterator &RHS) const {
      60             :     return Value - RHS.Value;
      61             :   }
      62             : 
      63             :   bool operator==(const value_sequence_iterator &RHS) const {
      64             :     return Value == RHS.Value;
      65             :   }
      66             :   bool operator<(const value_sequence_iterator &RHS) const {
      67             :     return Value < RHS.Value;
      68             :   }
      69             : 
      70             :   reference operator*() const { return Value; }
      71             : };
      72             : 
      73             : } // end namespace detail
      74             : 
      75             : template <typename ValueT>
      76             : iterator_range<detail::value_sequence_iterator<ValueT>> seq(ValueT Begin,
      77             :                                                             ValueT End) {
      78             :   return make_range(detail::value_sequence_iterator<ValueT>(Begin),
      79          87 :                     detail::value_sequence_iterator<ValueT>(End));
      80             : }
      81             : 
      82             : } // end namespace llvm
      83             : 
      84             : #endif // LLVM_ADT_SEQUENCE_H

Generated by: LCOV version 1.13