Coverage Report

Created: 2018-08-19 14:04

/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/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
/// 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
4.78k
      : 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
4.78k
  ~ColoredRawOstream() {
38
4.78k
    if (IsColorUsed)
39
8
      OS.resetColor();
40
4.78k
  }
41
};
42
43
template <typename T>
44
4.78k
inline raw_ostream &operator<<(const ColoredRawOstream &OS, T &&Value) {
45
4.78k
  return OS.OS << std::forward<T>(Value);
46
4.78k
}
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
124
inline raw_ostream &operator<<(const ColoredRawOstream &OS, T &&Value) {
45
124
  return OS.OS << std::forward<T>(Value);
46
124
}
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
238
inline raw_ostream &operator<<(const ColoredRawOstream &OS, T &&Value) {
45
238
  return OS.OS << std::forward<T>(Value);
46
238
}
llvm::raw_ostream& llvm::operator<<<llvm::format_object<unsigned long, double> >(llvm::ColoredRawOstream const&, llvm::format_object<unsigned long, double>&&)
Line
Count
Source
44
339
inline raw_ostream &operator<<(const ColoredRawOstream &OS, T &&Value) {
45
339
  return OS.OS << std::forward<T>(Value);
46
339
}
llvm::raw_ostream& llvm::operator<<<char const (&) [2]>(llvm::ColoredRawOstream const&, char const (&&&) [2])
Line
Count
Source
44
13
inline raw_ostream &operator<<(const ColoredRawOstream &OS, T &&Value) {
45
13
  return OS.OS << std::forward<T>(Value);
46
13
}
llvm::raw_ostream& llvm::operator<<<llvm::StringRef>(llvm::ColoredRawOstream const&, llvm::StringRef&&)
Line
Count
Source
44
3.07k
inline raw_ostream &operator<<(const ColoredRawOstream &OS, T &&Value) {
45
3.07k
  return OS.OS << std::forward<T>(Value);
46
3.07k
}
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
946
inline raw_ostream &operator<<(const ColoredRawOstream &OS, T &&Value) {
45
946
  return OS.OS << std::forward<T>(Value);
46
946
}
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
25
inline raw_ostream &operator<<(const ColoredRawOstream &OS, T &&Value) {
45
25
  return OS.OS << std::forward<T>(Value);
46
25
}
llvm::raw_ostream& llvm::operator<<<llvm::StringRef&>(llvm::ColoredRawOstream const&, llvm::StringRef&&&)
Line
Count
Source
44
25
inline raw_ostream &operator<<(const ColoredRawOstream &OS, T &&Value) {
45
25
  return OS.OS << std::forward<T>(Value);
46
25
}
47
48
/// 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
4.78k
                                         bool Bold = false, bool BG = false) {
54
4.78k
  if (IsColorUsed)
55
8
    OS.changeColor(Color, Bold, BG);
56
4.78k
  return ColoredRawOstream(OS, IsColorUsed);
57
4.78k
}
58
59
} // namespace llvm
60
61
#endif // LLVM_COV_RENDERINGSUPPORT_H