Coverage Report

Created: 2018-09-19 20:53

/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/include/llvm/ADT/Sequence.h
Line
Count
Source
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
3.47M
      : Value(std::move(Arg.Value)) {}
llvm::detail::value_sequence_iterator<int>::value_sequence_iterator(llvm::detail::value_sequence_iterator<int>&&)
Line
Count
Source
45
87.7k
      : Value(std::move(Arg.Value)) {}
llvm::detail::value_sequence_iterator<unsigned int>::value_sequence_iterator(llvm::detail::value_sequence_iterator<unsigned int>&&)
Line
Count
Source
45
3.38M
      : Value(std::move(Arg.Value)) {}
46
47
  template <typename U, typename Enabler = decltype(ValueT(std::declval<U>()))>
48
1.73M
  value_sequence_iterator(U &&Value) : Value(std::forward<U>(Value)) {}
llvm::detail::value_sequence_iterator<int>::value_sequence_iterator<int&, int>(int&&&)
Line
Count
Source
48
43.8k
  value_sequence_iterator(U &&Value) : Value(std::forward<U>(Value)) {}
llvm::detail::value_sequence_iterator<unsigned int>::value_sequence_iterator<unsigned int&, unsigned int>(unsigned int&&&)
Line
Count
Source
48
1.69M
  value_sequence_iterator(U &&Value) : Value(std::forward<U>(Value)) {}
49
50
1.67M
  value_sequence_iterator &operator+=(difference_type N) {
51
1.67M
    Value += N;
52
1.67M
    return *this;
53
1.67M
  }
llvm::detail::value_sequence_iterator<int>::operator+=(long)
Line
Count
Source
50
152k
  value_sequence_iterator &operator+=(difference_type N) {
51
152k
    Value += N;
52
152k
    return *this;
53
152k
  }
llvm::detail::value_sequence_iterator<unsigned int>::operator+=(long)
Line
Count
Source
50
1.52M
  value_sequence_iterator &operator+=(difference_type N) {
51
1.52M
    Value += N;
52
1.52M
    return *this;
53
1.52M
  }
54
  value_sequence_iterator &operator-=(difference_type N) {
55
    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
2.54M
  bool operator==(const value_sequence_iterator &RHS) const {
64
2.54M
    return Value == RHS.Value;
65
2.54M
  }
llvm::detail::value_sequence_iterator<int>::operator==(llvm::detail::value_sequence_iterator<int> const&) const
Line
Count
Source
63
174k
  bool operator==(const value_sequence_iterator &RHS) const {
64
174k
    return Value == RHS.Value;
65
174k
  }
llvm::detail::value_sequence_iterator<unsigned int>::operator==(llvm::detail::value_sequence_iterator<unsigned int> const&) const
Line
Count
Source
63
2.36M
  bool operator==(const value_sequence_iterator &RHS) const {
64
2.36M
    return Value == RHS.Value;
65
2.36M
  }
66
  bool operator<(const value_sequence_iterator &RHS) const {
67
    return Value < RHS.Value;
68
  }
69
70
1.70M
  reference operator*() const { return Value; }
llvm::detail::value_sequence_iterator<int>::operator*() const
Line
Count
Source
70
152k
  reference operator*() const { return Value; }
llvm::detail::value_sequence_iterator<unsigned int>::operator*() const
Line
Count
Source
70
1.54M
  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
869k
                                                            ValueT End) {
78
869k
  return make_range(detail::value_sequence_iterator<ValueT>(Begin),
79
869k
                    detail::value_sequence_iterator<ValueT>(End));
80
869k
}
llvm::iterator_range<llvm::detail::value_sequence_iterator<int> > llvm::seq<int>(int, int)
Line
Count
Source
77
21.9k
                                                            ValueT End) {
78
21.9k
  return make_range(detail::value_sequence_iterator<ValueT>(Begin),
79
21.9k
                    detail::value_sequence_iterator<ValueT>(End));
80
21.9k
}
llvm::iterator_range<llvm::detail::value_sequence_iterator<unsigned int> > llvm::seq<unsigned int>(unsigned int, unsigned int)
Line
Count
Source
77
847k
                                                            ValueT End) {
78
847k
  return make_range(detail::value_sequence_iterator<ValueT>(Begin),
79
847k
                    detail::value_sequence_iterator<ValueT>(End));
80
847k
}
81
82
} // end namespace llvm
83
84
#endif // LLVM_ADT_SEQUENCE_H