Coverage Report

Created: 2019-07-24 05:18

/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
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4
// See https://llvm.org/LICENSE.txt for license information.
5
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6
//
7
//===----------------------------------------------------------------------===//
8
/// \file
9
/// This routine provides some synthesis utilities to produce sequences of
10
/// values. The names are intentionally kept very short as they tend to occur
11
/// in common and widely used contexts.
12
///
13
//===----------------------------------------------------------------------===//
14
15
#ifndef LLVM_ADT_SEQUENCE_H
16
#define LLVM_ADT_SEQUENCE_H
17
18
#include "llvm/ADT/iterator.h"
19
#include "llvm/ADT/iterator_range.h"
20
#include <algorithm>
21
#include <iterator>
22
#include <utility>
23
24
namespace llvm {
25
26
namespace detail {
27
28
template <typename ValueT>
29
class value_sequence_iterator
30
    : public iterator_facade_base<value_sequence_iterator<ValueT>,
31
                                  std::random_access_iterator_tag,
32
                                  const ValueT> {
33
  using BaseT = typename value_sequence_iterator::iterator_facade_base;
34
35
  ValueT Value;
36
37
public:
38
  using difference_type = typename BaseT::difference_type;
39
  using reference = typename BaseT::reference;
40
41
  value_sequence_iterator() = default;
42
  value_sequence_iterator(const value_sequence_iterator &) = default;
43
  value_sequence_iterator(value_sequence_iterator &&Arg)
44
13.9M
      : Value(std::move(Arg.Value)) {}
llvm::detail::value_sequence_iterator<int>::value_sequence_iterator(llvm::detail::value_sequence_iterator<int>&&)
Line
Count
Source
44
75.3k
      : 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
44
13.9M
      : Value(std::move(Arg.Value)) {}
45
46
  template <typename U, typename Enabler = decltype(ValueT(std::declval<U>()))>
47
6.99M
  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
47
37.6k
  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
47
6.95M
  value_sequence_iterator(U &&Value) : Value(std::forward<U>(Value)) {}
48
49
7.22M
  value_sequence_iterator &operator+=(difference_type N) {
50
7.22M
    Value += N;
51
7.22M
    return *this;
52
7.22M
  }
llvm::detail::value_sequence_iterator<int>::operator+=(long)
Line
Count
Source
49
134k
  value_sequence_iterator &operator+=(difference_type N) {
50
134k
    Value += N;
51
134k
    return *this;
52
134k
  }
llvm::detail::value_sequence_iterator<unsigned int>::operator+=(long)
Line
Count
Source
49
7.09M
  value_sequence_iterator &operator+=(difference_type N) {
50
7.09M
    Value += N;
51
7.09M
    return *this;
52
7.09M
  }
53
  value_sequence_iterator &operator-=(difference_type N) {
54
    Value -= N;
55
    return *this;
56
  }
57
  using BaseT::operator-;
58
86
  difference_type operator-(const value_sequence_iterator &RHS) const {
59
86
    return Value - RHS.Value;
60
86
  }
61
62
10.7M
  bool operator==(const value_sequence_iterator &RHS) const {
63
10.7M
    return Value == RHS.Value;
64
10.7M
  }
llvm::detail::value_sequence_iterator<int>::operator==(llvm::detail::value_sequence_iterator<int> const&) const
Line
Count
Source
62
153k
  bool operator==(const value_sequence_iterator &RHS) const {
63
153k
    return Value == RHS.Value;
64
153k
  }
llvm::detail::value_sequence_iterator<unsigned int>::operator==(llvm::detail::value_sequence_iterator<unsigned int> const&) const
Line
Count
Source
62
10.5M
  bool operator==(const value_sequence_iterator &RHS) const {
63
10.5M
    return Value == RHS.Value;
64
10.5M
  }
65
  bool operator<(const value_sequence_iterator &RHS) const {
66
    return Value < RHS.Value;
67
  }
68
69
7.28M
  reference operator*() const { return Value; }
llvm::detail::value_sequence_iterator<int>::operator*() const
Line
Count
Source
69
134k
  reference operator*() const { return Value; }
llvm::detail::value_sequence_iterator<unsigned int>::operator*() const
Line
Count
Source
69
7.14M
  reference operator*() const { return Value; }
70
};
71
72
} // end namespace detail
73
74
template <typename ValueT>
75
iterator_range<detail::value_sequence_iterator<ValueT>> seq(ValueT Begin,
76
3.49M
                                                            ValueT End) {
77
3.49M
  return make_range(detail::value_sequence_iterator<ValueT>(Begin),
78
3.49M
                    detail::value_sequence_iterator<ValueT>(End));
79
3.49M
}
llvm::iterator_range<llvm::detail::value_sequence_iterator<int> > llvm::seq<int>(int, int)
Line
Count
Source
76
18.8k
                                                            ValueT End) {
77
18.8k
  return make_range(detail::value_sequence_iterator<ValueT>(Begin),
78
18.8k
                    detail::value_sequence_iterator<ValueT>(End));
79
18.8k
}
llvm::iterator_range<llvm::detail::value_sequence_iterator<unsigned int> > llvm::seq<unsigned int>(unsigned int, unsigned int)
Line
Count
Source
76
3.47M
                                                            ValueT End) {
77
3.47M
  return make_range(detail::value_sequence_iterator<ValueT>(Begin),
78
3.47M
                    detail::value_sequence_iterator<ValueT>(End));
79
3.47M
}
80
81
} // end namespace llvm
82
83
#endif // LLVM_ADT_SEQUENCE_H