Coverage Report

Created: 2019-07-24 05:18

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