Coverage Report

Created: 2017-09-21 03:39

/Users/buildslave/jenkins/sharedspace/clang-stage2-coverage-R@2/llvm/tools/llvm-cov/RenderingSupport.h
Line
Count
Source (jump to first uncovered line)
1
//===- RenderingSupport.h - output stream rendering support functions  ----===//
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_COV_RENDERINGSUPPORT_H
11
#define LLVM_COV_RENDERINGSUPPORT_H
12
13
#include "llvm/Support/raw_ostream.h"
14
#include <utility>
15
16
namespace llvm {
17
18
/// \brief A helper class that resets the output stream's color if needed
19
/// when destroyed.
20
class ColoredRawOstream {
21
  ColoredRawOstream(const ColoredRawOstream &OS) = delete;
22
23
public:
24
  raw_ostream &OS;
25
  bool IsColorUsed;
26
27
  ColoredRawOstream(raw_ostream &OS, bool IsColorUsed)
28
3.11k
      : OS(OS), IsColorUsed(IsColorUsed) {}
29
30
  ColoredRawOstream(ColoredRawOstream &&Other)
31
0
      : OS(Other.OS), IsColorUsed(Other.IsColorUsed) {
32
0
    // Reset the other IsColorUsed so that the other object won't reset the
33
0
    // color when destroyed.
34
0
    Other.IsColorUsed = false;
35
0
  }
36
37
3.11k
  ~ColoredRawOstream() {
38
3.11k
    if (IsColorUsed)
39
8
      OS.resetColor();
40
3.11k
  }
41
};
42
43
template <typename T>
44
3.11k
inline raw_ostream &operator<<(const ColoredRawOstream &OS, T &&Value) {
45
3.11k
  return OS.OS << std::forward<T>(Value);
46
3.11k
}
llvm::raw_ostream& llvm::operator<<<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >(llvm::ColoredRawOstream const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&&)
Line
Count
Source
44
70
inline raw_ostream &operator<<(const ColoredRawOstream &OS, T &&Value) {
45
70
  return OS.OS << std::forward<T>(Value);
46
70
}
llvm::raw_ostream& llvm::operator<<<llvm::format_object<unsigned long, unsigned int> >(llvm::ColoredRawOstream const&, llvm::format_object<unsigned long, unsigned int>&&)
Line
Count
Source
44
128
inline raw_ostream &operator<<(const ColoredRawOstream &OS, T &&Value) {
45
128
  return OS.OS << std::forward<T>(Value);
46
128
}
llvm::raw_ostream& llvm::operator<<<llvm::format_object<unsigned long, double> >(llvm::ColoredRawOstream const&, llvm::format_object<unsigned long, double>&&)
Line
Count
Source
44
174
inline raw_ostream &operator<<(const ColoredRawOstream &OS, T &&Value) {
45
174
  return OS.OS << std::forward<T>(Value);
46
174
}
llvm::raw_ostream& llvm::operator<<<char const (&) [2]>(llvm::ColoredRawOstream const&, char const (&&&) [2])
Line
Count
Source
44
6
inline raw_ostream &operator<<(const ColoredRawOstream &OS, T &&Value) {
45
6
  return OS.OS << std::forward<T>(Value);
46
6
}
llvm::raw_ostream& llvm::operator<<<llvm::StringRef>(llvm::ColoredRawOstream const&, llvm::StringRef&&)
Line
Count
Source
44
2.21k
inline raw_ostream &operator<<(const ColoredRawOstream &OS, T &&Value) {
45
2.21k
  return OS.OS << std::forward<T>(Value);
46
2.21k
}
llvm::raw_ostream& llvm::operator<<<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&>(llvm::ColoredRawOstream const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&&&)
Line
Count
Source
44
514
inline raw_ostream &operator<<(const ColoredRawOstream &OS, T &&Value) {
45
514
  return OS.OS << std::forward<T>(Value);
46
514
}
llvm::raw_ostream& llvm::operator<<<char const (&) [27]>(llvm::ColoredRawOstream const&, char const (&&&) [27])
Line
Count
Source
44
6
inline raw_ostream &operator<<(const ColoredRawOstream &OS, T &&Value) {
45
6
  return OS.OS << std::forward<T>(Value);
46
6
}
llvm::raw_ostream& llvm::operator<<<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&>(llvm::ColoredRawOstream const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&&&)
Line
Count
Source
44
5
inline raw_ostream &operator<<(const ColoredRawOstream &OS, T &&Value) {
45
5
  return OS.OS << std::forward<T>(Value);
46
5
}
llvm::raw_ostream& llvm::operator<<<llvm::StringRef&>(llvm::ColoredRawOstream const&, llvm::StringRef&&&)
Line
Count
Source
44
5
inline raw_ostream &operator<<(const ColoredRawOstream &OS, T &&Value) {
45
5
  return OS.OS << std::forward<T>(Value);
46
5
}
47
48
/// \brief Change the color of the output stream if the `IsColorUsed` flag
49
/// is true. Returns an object that resets the color when destroyed.
50
inline ColoredRawOstream colored_ostream(raw_ostream &OS,
51
                                         raw_ostream::Colors Color,
52
                                         bool IsColorUsed = true,
53
3.11k
                                         bool Bold = false, bool BG = false) {
54
3.11k
  if (IsColorUsed)
55
8
    OS.changeColor(Color, Bold, BG);
56
3.11k
  return ColoredRawOstream(OS, IsColorUsed);
57
3.11k
}
58
59
} // namespace llvm
60
61
#endif // LLVM_COV_RENDERINGSUPPORT_H