Coverage Report

Created: 2018-07-18 22:01

/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/include/llvm/Support/EndianStream.h
Line
Count
Source (jump to first uncovered line)
1
//===- EndianStream.h - Stream ops with endian specific data ----*- 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
//
10
// This file defines utilities for operating on streams that have endian
11
// specific data.
12
//
13
//===----------------------------------------------------------------------===//
14
15
#ifndef LLVM_SUPPORT_ENDIANSTREAM_H
16
#define LLVM_SUPPORT_ENDIANSTREAM_H
17
18
#include "llvm/ADT/ArrayRef.h"
19
#include "llvm/Support/Endian.h"
20
#include "llvm/Support/raw_ostream.h"
21
22
namespace llvm {
23
namespace support {
24
25
namespace endian {
26
27
template <typename value_type>
28
79.1M
inline void write(raw_ostream &os, value_type value, endianness endian) {
29
79.1M
  value = byte_swap<value_type>(value, endian);
30
79.1M
  os.write((const char *)&value, sizeof(value_type));
31
79.1M
}
void llvm::support::endian::write<unsigned int>(llvm::raw_ostream&, unsigned int, llvm::support::endianness)
Line
Count
Source
28
48.6M
inline void write(raw_ostream &os, value_type value, endianness endian) {
29
48.6M
  value = byte_swap<value_type>(value, endian);
30
48.6M
  os.write((const char *)&value, sizeof(value_type));
31
48.6M
}
void llvm::support::endian::write<unsigned long long>(llvm::raw_ostream&, unsigned long long, llvm::support::endianness)
Line
Count
Source
28
3.61M
inline void write(raw_ostream &os, value_type value, endianness endian) {
29
3.61M
  value = byte_swap<value_type>(value, endian);
30
3.61M
  os.write((const char *)&value, sizeof(value_type));
31
3.61M
}
void llvm::support::endian::write<unsigned short>(llvm::raw_ostream&, unsigned short, llvm::support::endianness)
Line
Count
Source
28
26.6M
inline void write(raw_ostream &os, value_type value, endianness endian) {
29
26.6M
  value = byte_swap<value_type>(value, endian);
30
26.6M
  os.write((const char *)&value, sizeof(value_type));
31
26.6M
}
void llvm::support::endian::write<unsigned char>(llvm::raw_ostream&, unsigned char, llvm::support::endianness)
Line
Count
Source
28
184k
inline void write(raw_ostream &os, value_type value, endianness endian) {
29
184k
  value = byte_swap<value_type>(value, endian);
30
184k
  os.write((const char *)&value, sizeof(value_type));
31
184k
}
32
33
template <>
34
0
inline void write<float>(raw_ostream &os, float value, endianness endian) {
35
0
  write(os, FloatToBits(value), endian);
36
0
}
37
38
template <>
39
inline void write<double>(raw_ostream &os, double value,
40
0
                          endianness endian) {
41
0
  write(os, DoubleToBits(value), endian);
42
0
}
43
44
template <typename value_type>
45
inline void write(raw_ostream &os, ArrayRef<value_type> vals,
46
                  endianness endian) {
47
  for (value_type v : vals)
48
    write(os, v, endian);
49
}
50
51
/// Adapter to write values to a stream in a particular byte order.
52
struct Writer {
53
  raw_ostream &OS;
54
  endianness Endian;
55
10.9M
  Writer(raw_ostream &OS, endianness Endian) : OS(OS), Endian(Endian) {}
56
  template <typename value_type> void write(ArrayRef<value_type> Val) {
57
    endian::write(OS, Val, Endian);
58
  }
59
64.9M
  template <typename value_type> void write(value_type Val) {
60
64.9M
    endian::write(OS, Val, Endian);
61
64.9M
  }
void llvm::support::endian::Writer::write<unsigned short>(unsigned short)
Line
Count
Source
59
26.6M
  template <typename value_type> void write(value_type Val) {
60
26.6M
    endian::write(OS, Val, Endian);
61
26.6M
  }
void llvm::support::endian::Writer::write<unsigned int>(unsigned int)
Line
Count
Source
59
34.5M
  template <typename value_type> void write(value_type Val) {
60
34.5M
    endian::write(OS, Val, Endian);
61
34.5M
  }
void llvm::support::endian::Writer::write<unsigned char>(unsigned char)
Line
Count
Source
59
184k
  template <typename value_type> void write(value_type Val) {
60
184k
    endian::write(OS, Val, Endian);
61
184k
  }
void llvm::support::endian::Writer::write<unsigned long long>(unsigned long long)
Line
Count
Source
59
3.61M
  template <typename value_type> void write(value_type Val) {
60
3.61M
    endian::write(OS, Val, Endian);
61
3.61M
  }
62
};
63
64
} // end namespace endian
65
66
} // end namespace support
67
} // end namespace llvm
68
69
#endif