Coverage Report

Created: 2018-11-16 02:38

/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/include/llvm/DebugInfo/CodeView/CodeViewRecordIO.h
Line
Count
Source (jump to first uncovered line)
1
//===- CodeViewRecordIO.h ---------------------------------------*- 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
#ifndef LLVM_DEBUGINFO_CODEVIEW_CODEVIEWRECORDIO_H
11
#define LLVM_DEBUGINFO_CODEVIEW_CODEVIEWRECORDIO_H
12
13
#include "llvm/ADT/APSInt.h"
14
#include "llvm/ADT/None.h"
15
#include "llvm/ADT/Optional.h"
16
#include "llvm/ADT/SmallVector.h"
17
#include "llvm/ADT/StringRef.h"
18
#include "llvm/DebugInfo/CodeView/CodeViewError.h"
19
#include "llvm/DebugInfo/CodeView/TypeRecord.h"
20
#include "llvm/Support/BinaryStreamReader.h"
21
#include "llvm/Support/BinaryStreamWriter.h"
22
#include "llvm/Support/Error.h"
23
#include <cassert>
24
#include <cstdint>
25
#include <type_traits>
26
27
namespace llvm {
28
namespace codeview {
29
30
class CodeViewRecordIO {
31
66.4k
  uint32_t getCurrentOffset() const {
32
66.4k
    return (isWriting()) ? 
Writer->getOffset()23.8k
:
Reader->getOffset()42.6k
;
33
66.4k
  }
34
35
public:
36
20.2k
  explicit CodeViewRecordIO(BinaryStreamReader &Reader) : Reader(&Reader) {}
37
4.67k
  explicit CodeViewRecordIO(BinaryStreamWriter &Writer) : Writer(&Writer) {}
38
39
  Error beginRecord(Optional<uint32_t> MaxLength);
40
  Error endRecord();
41
42
  Error mapInteger(TypeIndex &TypeInd);
43
44
290k
  bool isReading() const { return Reader != nullptr; }
45
272k
  bool isWriting() const { return !isReading(); }
46
47
  uint32_t maxFieldLength() const;
48
49
177
  template <typename T> Error mapObject(T &Value) {
50
177
    if (isWriting())
51
30
      return Writer->writeObject(Value);
52
147
53
147
    const T *ValuePtr;
54
147
    if (auto EC = Reader->readObject(ValuePtr))
55
0
      return EC;
56
147
    Value = *ValuePtr;
57
147
    return Error::success();
58
147
  }
llvm::Error llvm::codeview::CodeViewRecordIO::mapObject<llvm::support::detail::packed_endian_specific_integral<unsigned short, (llvm::support::endianness)1, 1ul> >(llvm::support::detail::packed_endian_specific_integral<unsigned short, (llvm::support::endianness)1, 1ul>&)
Line
Count
Source
49
154
  template <typename T> Error mapObject(T &Value) {
50
154
    if (isWriting())
51
26
      return Writer->writeObject(Value);
52
128
53
128
    const T *ValuePtr;
54
128
    if (auto EC = Reader->readObject(ValuePtr))
55
0
      return EC;
56
128
    Value = *ValuePtr;
57
128
    return Error::success();
58
128
  }
llvm::Error llvm::codeview::CodeViewRecordIO::mapObject<llvm::support::detail::packed_endian_specific_integral<int, (llvm::support::endianness)1, 1ul> >(llvm::support::detail::packed_endian_specific_integral<int, (llvm::support::endianness)1, 1ul>&)
Line
Count
Source
49
16
  template <typename T> Error mapObject(T &Value) {
50
16
    if (isWriting())
51
4
      return Writer->writeObject(Value);
52
12
53
12
    const T *ValuePtr;
54
12
    if (auto EC = Reader->readObject(ValuePtr))
55
0
      return EC;
56
12
    Value = *ValuePtr;
57
12
    return Error::success();
58
12
  }
llvm::Error llvm::codeview::CodeViewRecordIO::mapObject<llvm::support::detail::packed_endian_specific_integral<unsigned int, (llvm::support::endianness)1, 1ul> >(llvm::support::detail::packed_endian_specific_integral<unsigned int, (llvm::support::endianness)1, 1ul>&)
Line
Count
Source
49
7
  template <typename T> Error mapObject(T &Value) {
50
7
    if (isWriting())
51
0
      return Writer->writeObject(Value);
52
7
53
7
    const T *ValuePtr;
54
7
    if (auto EC = Reader->readObject(ValuePtr))
55
0
      return EC;
56
7
    Value = *ValuePtr;
57
7
    return Error::success();
58
7
  }
59
60
59.1k
  template <typename T> Error mapInteger(T &Value) {
61
59.1k
    if (isWriting())
62
14.8k
      return Writer->writeInteger(Value);
63
44.2k
64
44.2k
    return Reader->readInteger(Value);
65
44.2k
  }
llvm::Error llvm::codeview::CodeViewRecordIO::mapInteger<unsigned short>(unsigned short&)
Line
Count
Source
60
39.3k
  template <typename T> Error mapInteger(T &Value) {
61
39.3k
    if (isWriting())
62
10.1k
      return Writer->writeInteger(Value);
63
29.1k
64
29.1k
    return Reader->readInteger(Value);
65
29.1k
  }
llvm::Error llvm::codeview::CodeViewRecordIO::mapInteger<unsigned int>(unsigned int&)
Line
Count
Source
60
10.4k
  template <typename T> Error mapInteger(T &Value) {
61
10.4k
    if (isWriting())
62
2.85k
      return Writer->writeInteger(Value);
63
7.54k
64
7.54k
    return Reader->readInteger(Value);
65
7.54k
  }
llvm::Error llvm::codeview::CodeViewRecordIO::mapInteger<unsigned char>(unsigned char&)
Line
Count
Source
60
6.98k
  template <typename T> Error mapInteger(T &Value) {
61
6.98k
    if (isWriting())
62
1.60k
      return Writer->writeInteger(Value);
63
5.37k
64
5.37k
    return Reader->readInteger(Value);
65
5.37k
  }
llvm::Error llvm::codeview::CodeViewRecordIO::mapInteger<int>(int&)
Line
Count
Source
60
2.39k
  template <typename T> Error mapInteger(T &Value) {
61
2.39k
    if (isWriting())
62
264
      return Writer->writeInteger(Value);
63
2.12k
64
2.12k
    return Reader->readInteger(Value);
65
2.12k
  }
66
67
14.0k
  template <typename T> Error mapEnum(T &Value) {
68
14.0k
    if (sizeof(Value) > maxFieldLength())
69
0
      return make_error<CodeViewError>(cv_error_code::insufficient_buffer);
70
14.0k
71
14.0k
    using U = typename std::underlying_type<T>::type;
72
14.0k
    U X;
73
14.0k
    if (isWriting())
74
2.04k
      X = static_cast<U>(Value);
75
14.0k
76
14.0k
    if (auto EC = mapInteger(X))
77
0
      return EC;
78
14.0k
    if (isReading())
79
12.0k
      Value = static_cast<T>(X);
80
14.0k
    return Error::success();
81
14.0k
  }
llvm::Error llvm::codeview::CodeViewRecordIO::mapEnum<llvm::codeview::ThunkOrdinal>(llvm::codeview::ThunkOrdinal&)
Line
Count
Source
67
4
  template <typename T> Error mapEnum(T &Value) {
68
4
    if (sizeof(Value) > maxFieldLength())
69
0
      return make_error<CodeViewError>(cv_error_code::insufficient_buffer);
70
4
71
4
    using U = typename std::underlying_type<T>::type;
72
4
    U X;
73
4
    if (isWriting())
74
1
      X = static_cast<U>(Value);
75
4
76
4
    if (auto EC = mapInteger(X))
77
0
      return EC;
78
4
    if (isReading())
79
3
      Value = static_cast<T>(X);
80
4
    return Error::success();
81
4
  }
llvm::Error llvm::codeview::CodeViewRecordIO::mapEnum<llvm::codeview::TrampolineType>(llvm::codeview::TrampolineType&)
Line
Count
Source
67
6
  template <typename T> Error mapEnum(T &Value) {
68
6
    if (sizeof(Value) > maxFieldLength())
69
0
      return make_error<CodeViewError>(cv_error_code::insufficient_buffer);
70
6
71
6
    using U = typename std::underlying_type<T>::type;
72
6
    U X;
73
6
    if (isWriting())
74
1
      X = static_cast<U>(Value);
75
6
76
6
    if (auto EC = mapInteger(X))
77
0
      return EC;
78
6
    if (isReading())
79
5
      Value = static_cast<T>(X);
80
6
    return Error::success();
81
6
  }
llvm::Error llvm::codeview::CodeViewRecordIO::mapEnum<llvm::codeview::LocalSymFlags>(llvm::codeview::LocalSymFlags&)
Line
Count
Source
67
225
  template <typename T> Error mapEnum(T &Value) {
68
225
    if (sizeof(Value) > maxFieldLength())
69
0
      return make_error<CodeViewError>(cv_error_code::insufficient_buffer);
70
225
71
225
    using U = typename std::underlying_type<T>::type;
72
225
    U X;
73
225
    if (isWriting())
74
11
      X = static_cast<U>(Value);
75
225
76
225
    if (auto EC = mapInteger(X))
77
0
      return EC;
78
225
    if (isReading())
79
214
      Value = static_cast<T>(X);
80
225
    return Error::success();
81
225
  }
Unexecuted instantiation: llvm::Error llvm::codeview::CodeViewRecordIO::mapEnum<llvm::codeview::ExportFlags>(llvm::codeview::ExportFlags&)
Unexecuted instantiation: llvm::Error llvm::codeview::CodeViewRecordIO::mapEnum<llvm::codeview::CompileSym2Flags>(llvm::codeview::CompileSym2Flags&)
llvm::Error llvm::codeview::CodeViewRecordIO::mapEnum<llvm::codeview::CPUType>(llvm::codeview::CPUType&)
Line
Count
Source
67
277
  template <typename T> Error mapEnum(T &Value) {
68
277
    if (sizeof(Value) > maxFieldLength())
69
0
      return make_error<CodeViewError>(cv_error_code::insufficient_buffer);
70
277
71
277
    using U = typename std::underlying_type<T>::type;
72
277
    U X;
73
277
    if (isWriting())
74
125
      X = static_cast<U>(Value);
75
277
76
277
    if (auto EC = mapInteger(X))
77
0
      return EC;
78
277
    if (isReading())
79
152
      Value = static_cast<T>(X);
80
277
    return Error::success();
81
277
  }
llvm::Error llvm::codeview::CodeViewRecordIO::mapEnum<llvm::codeview::CompileSym3Flags>(llvm::codeview::CompileSym3Flags&)
Line
Count
Source
67
277
  template <typename T> Error mapEnum(T &Value) {
68
277
    if (sizeof(Value) > maxFieldLength())
69
0
      return make_error<CodeViewError>(cv_error_code::insufficient_buffer);
70
277
71
277
    using U = typename std::underlying_type<T>::type;
72
277
    U X;
73
277
    if (isWriting())
74
125
      X = static_cast<U>(Value);
75
277
76
277
    if (auto EC = mapInteger(X))
77
0
      return EC;
78
277
    if (isReading())
79
152
      Value = static_cast<T>(X);
80
277
    return Error::success();
81
277
  }
Unexecuted instantiation: llvm::Error llvm::codeview::CodeViewRecordIO::mapEnum<llvm::codeview::FrameCookieKind>(llvm::codeview::FrameCookieKind&)
llvm::Error llvm::codeview::CodeViewRecordIO::mapEnum<llvm::codeview::FrameProcedureOptions>(llvm::codeview::FrameProcedureOptions&)
Line
Count
Source
67
269
  template <typename T> Error mapEnum(T &Value) {
68
269
    if (sizeof(Value) > maxFieldLength())
69
0
      return make_error<CodeViewError>(cv_error_code::insufficient_buffer);
70
269
71
269
    using U = typename std::underlying_type<T>::type;
72
269
    U X;
73
269
    if (isWriting())
74
49
      X = static_cast<U>(Value);
75
269
76
269
    if (auto EC = mapInteger(X))
77
0
      return EC;
78
269
    if (isReading())
79
220
      Value = static_cast<T>(X);
80
269
    return Error::success();
81
269
  }
llvm::Error llvm::codeview::CodeViewRecordIO::mapEnum<llvm::codeview::RegisterId>(llvm::codeview::RegisterId&)
Line
Count
Source
67
46
  template <typename T> Error mapEnum(T &Value) {
68
46
    if (sizeof(Value) > maxFieldLength())
69
0
      return make_error<CodeViewError>(cv_error_code::insufficient_buffer);
70
46
71
46
    using U = typename std::underlying_type<T>::type;
72
46
    U X;
73
46
    if (isWriting())
74
21
      X = static_cast<U>(Value);
75
46
76
46
    if (auto EC = mapInteger(X))
77
0
      return EC;
78
46
    if (isReading())
79
25
      Value = static_cast<T>(X);
80
46
    return Error::success();
81
46
  }
llvm::Error llvm::codeview::CodeViewRecordIO::mapEnum<llvm::codeview::PublicSymFlags>(llvm::codeview::PublicSymFlags&)
Line
Count
Source
67
488
  template <typename T> Error mapEnum(T &Value) {
68
488
    if (sizeof(Value) > maxFieldLength())
69
0
      return make_error<CodeViewError>(cv_error_code::insufficient_buffer);
70
488
71
488
    using U = typename std::underlying_type<T>::type;
72
488
    U X;
73
488
    if (isWriting())
74
228
      X = static_cast<U>(Value);
75
488
76
488
    if (auto EC = mapInteger(X))
77
0
      return EC;
78
488
    if (isReading())
79
260
      Value = static_cast<T>(X);
80
488
    return Error::success();
81
488
  }
llvm::Error llvm::codeview::CodeViewRecordIO::mapEnum<llvm::codeview::ProcSymFlags>(llvm::codeview::ProcSymFlags&)
Line
Count
Source
67
293
  template <typename T> Error mapEnum(T &Value) {
68
293
    if (sizeof(Value) > maxFieldLength())
69
0
      return make_error<CodeViewError>(cv_error_code::insufficient_buffer);
70
293
71
293
    using U = typename std::underlying_type<T>::type;
72
293
    U X;
73
293
    if (isWriting())
74
53
      X = static_cast<U>(Value);
75
293
76
293
    if (auto EC = mapInteger(X))
77
0
      return EC;
78
293
    if (isReading())
79
240
      Value = static_cast<T>(X);
80
293
    return Error::success();
81
293
  }
llvm::Error llvm::codeview::CodeViewRecordIO::mapEnum<llvm::codeview::ModifierOptions>(llvm::codeview::ModifierOptions&)
Line
Count
Source
67
338
  template <typename T> Error mapEnum(T &Value) {
68
338
    if (sizeof(Value) > maxFieldLength())
69
0
      return make_error<CodeViewError>(cv_error_code::insufficient_buffer);
70
338
71
338
    using U = typename std::underlying_type<T>::type;
72
338
    U X;
73
338
    if (isWriting())
74
47
      X = static_cast<U>(Value);
75
338
76
338
    if (auto EC = mapInteger(X))
77
0
      return EC;
78
338
    if (isReading())
79
291
      Value = static_cast<T>(X);
80
338
    return Error::success();
81
338
  }
llvm::Error llvm::codeview::CodeViewRecordIO::mapEnum<llvm::codeview::CallingConvention>(llvm::codeview::CallingConvention&)
Line
Count
Source
67
2.92k
  template <typename T> Error mapEnum(T &Value) {
68
2.92k
    if (sizeof(Value) > maxFieldLength())
69
0
      return make_error<CodeViewError>(cv_error_code::insufficient_buffer);
70
2.92k
71
2.92k
    using U = typename std::underlying_type<T>::type;
72
2.92k
    U X;
73
2.92k
    if (isWriting())
74
475
      X = static_cast<U>(Value);
75
2.92k
76
2.92k
    if (auto EC = mapInteger(X))
77
0
      return EC;
78
2.92k
    if (isReading())
79
2.45k
      Value = static_cast<T>(X);
80
2.92k
    return Error::success();
81
2.92k
  }
llvm::Error llvm::codeview::CodeViewRecordIO::mapEnum<llvm::codeview::FunctionOptions>(llvm::codeview::FunctionOptions&)
Line
Count
Source
67
2.92k
  template <typename T> Error mapEnum(T &Value) {
68
2.92k
    if (sizeof(Value) > maxFieldLength())
69
0
      return make_error<CodeViewError>(cv_error_code::insufficient_buffer);
70
2.92k
71
2.92k
    using U = typename std::underlying_type<T>::type;
72
2.92k
    U X;
73
2.92k
    if (isWriting())
74
475
      X = static_cast<U>(Value);
75
2.92k
76
2.92k
    if (auto EC = mapInteger(X))
77
0
      return EC;
78
2.92k
    if (isReading())
79
2.45k
      Value = static_cast<T>(X);
80
2.92k
    return Error::success();
81
2.92k
  }
llvm::Error llvm::codeview::CodeViewRecordIO::mapEnum<llvm::codeview::PointerToMemberRepresentation>(llvm::codeview::PointerToMemberRepresentation&)
Line
Count
Source
67
55
  template <typename T> Error mapEnum(T &Value) {
68
55
    if (sizeof(Value) > maxFieldLength())
69
0
      return make_error<CodeViewError>(cv_error_code::insufficient_buffer);
70
55
71
55
    using U = typename std::underlying_type<T>::type;
72
55
    U X;
73
55
    if (isWriting())
74
18
      X = static_cast<U>(Value);
75
55
76
55
    if (auto EC = mapInteger(X))
77
0
      return EC;
78
55
    if (isReading())
79
37
      Value = static_cast<T>(X);
80
55
    return Error::success();
81
55
  }
llvm::Error llvm::codeview::CodeViewRecordIO::mapEnum<llvm::codeview::ClassOptions>(llvm::codeview::ClassOptions&)
Line
Count
Source
67
5.96k
  template <typename T> Error mapEnum(T &Value) {
68
5.96k
    if (sizeof(Value) > maxFieldLength())
69
0
      return make_error<CodeViewError>(cv_error_code::insufficient_buffer);
70
5.96k
71
5.96k
    using U = typename std::underlying_type<T>::type;
72
5.96k
    U X;
73
5.96k
    if (isWriting())
74
413
      X = static_cast<U>(Value);
75
5.96k
76
5.96k
    if (auto EC = mapInteger(X))
77
0
      return EC;
78
5.96k
    if (isReading())
79
5.55k
      Value = static_cast<T>(X);
80
5.96k
    return Error::success();
81
5.96k
  }
llvm::Error llvm::codeview::CodeViewRecordIO::mapEnum<llvm::codeview::LabelType>(llvm::codeview::LabelType&)
Line
Count
Source
67
1
  template <typename T> Error mapEnum(T &Value) {
68
1
    if (sizeof(Value) > maxFieldLength())
69
0
      return make_error<CodeViewError>(cv_error_code::insufficient_buffer);
70
1
71
1
    using U = typename std::underlying_type<T>::type;
72
1
    U X;
73
1
    if (isWriting())
74
0
      X = static_cast<U>(Value);
75
1
76
1
    if (auto EC = mapInteger(X))
77
0
      return EC;
78
1
    if (isReading())
79
1
      Value = static_cast<T>(X);
80
1
    return Error::success();
81
1
  }
82
83
  Error mapEncodedInteger(int64_t &Value);
84
  Error mapEncodedInteger(uint64_t &Value);
85
  Error mapEncodedInteger(APSInt &Value);
86
  Error mapStringZ(StringRef &Value);
87
  Error mapGuid(GUID &Guid);
88
89
  Error mapStringZVectorZ(std::vector<StringRef> &Value);
90
91
  template <typename SizeType, typename T, typename ElementMapper>
92
2.04k
  Error mapVectorN(T &Items, const ElementMapper &Mapper) {
93
2.04k
    SizeType Size;
94
2.04k
    if (isWriting()) {
95
622
      Size = static_cast<SizeType>(Items.size());
96
622
      if (auto EC = Writer->writeInteger(Size))
97
0
        return EC;
98
622
99
1.26k
      
for (auto &X : Items)622
{
100
1.26k
        if (auto EC = Mapper(*this, X))
101
0
          return EC;
102
1.26k
      }
103
1.41k
    } else {
104
1.41k
      if (auto EC = Reader->readInteger(Size))
105
0
        return EC;
106
4.55k
      
for (SizeType I = 0; 1.41k
I < Size;
++I3.13k
) {
107
3.13k
        typename T::value_type Item;
108
3.13k
        if (auto EC = Mapper(*this, Item))
109
0
          return EC;
110
3.13k
        Items.push_back(Item);
111
3.13k
      }
112
1.41k
    }
113
2.04k
114
2.04k
    return Error::success();
115
2.04k
  }
SymbolRecordMapping.cpp:llvm::Error llvm::codeview::CodeViewRecordIO::mapVectorN<unsigned int, std::__1::vector<llvm::codeview::TypeIndex, std::__1::allocator<llvm::codeview::TypeIndex> >, llvm::codeview::SymbolRecordMapping::visitKnownRecord(llvm::codeview::CVRecord<llvm::codeview::SymbolKind>&, llvm::codeview::CallerSym&)::$_0>(std::__1::vector<llvm::codeview::TypeIndex, std::__1::allocator<llvm::codeview::TypeIndex> >&, llvm::codeview::SymbolRecordMapping::visitKnownRecord(llvm::codeview::CVRecord<llvm::codeview::SymbolKind>&, llvm::codeview::CallerSym&)::$_0 const&)
Line
Count
Source
92
15
  Error mapVectorN(T &Items, const ElementMapper &Mapper) {
93
15
    SizeType Size;
94
15
    if (isWriting()) {
95
7
      Size = static_cast<SizeType>(Items.size());
96
7
      if (auto EC = Writer->writeInteger(Size))
97
0
        return EC;
98
7
99
13
      
for (auto &X : Items)7
{
100
13
        if (auto EC = Mapper(*this, X))
101
0
          return EC;
102
13
      }
103
8
    } else {
104
8
      if (auto EC = Reader->readInteger(Size))
105
0
        return EC;
106
17
      
for (SizeType I = 0; 8
I < Size;
++I9
) {
107
9
        typename T::value_type Item;
108
9
        if (auto EC = Mapper(*this, Item))
109
0
          return EC;
110
9
        Items.push_back(Item);
111
9
      }
112
8
    }
113
15
114
15
    return Error::success();
115
15
  }
TypeRecordMapping.cpp:llvm::Error llvm::codeview::CodeViewRecordIO::mapVectorN<unsigned int, std::__1::vector<llvm::codeview::TypeIndex, std::__1::allocator<llvm::codeview::TypeIndex> >, llvm::codeview::TypeRecordMapping::visitKnownRecord(llvm::codeview::CVRecord<llvm::codeview::TypeLeafKind>&, llvm::codeview::ArgListRecord&)::$_0>(std::__1::vector<llvm::codeview::TypeIndex, std::__1::allocator<llvm::codeview::TypeIndex> >&, llvm::codeview::TypeRecordMapping::visitKnownRecord(llvm::codeview::CVRecord<llvm::codeview::TypeLeafKind>&, llvm::codeview::ArgListRecord&)::$_0 const&)
Line
Count
Source
92
1.49k
  Error mapVectorN(T &Items, const ElementMapper &Mapper) {
93
1.49k
    SizeType Size;
94
1.49k
    if (isWriting()) {
95
412
      Size = static_cast<SizeType>(Items.size());
96
412
      if (auto EC = Writer->writeInteger(Size))
97
0
        return EC;
98
412
99
412
      for (auto &X : Items) {
100
369
        if (auto EC = Mapper(*this, X))
101
0
          return EC;
102
369
      }
103
1.08k
    } else {
104
1.08k
      if (auto EC = Reader->readInteger(Size))
105
0
        return EC;
106
2.77k
      
for (SizeType I = 0; 1.08k
I < Size;
++I1.69k
) {
107
1.69k
        typename T::value_type Item;
108
1.69k
        if (auto EC = Mapper(*this, Item))
109
0
          return EC;
110
1.69k
        Items.push_back(Item);
111
1.69k
      }
112
1.08k
    }
113
1.49k
114
1.49k
    return Error::success();
115
1.49k
  }
TypeRecordMapping.cpp:llvm::Error llvm::codeview::CodeViewRecordIO::mapVectorN<unsigned int, std::__1::vector<llvm::codeview::TypeIndex, std::__1::allocator<llvm::codeview::TypeIndex> >, llvm::codeview::TypeRecordMapping::visitKnownRecord(llvm::codeview::CVRecord<llvm::codeview::TypeLeafKind>&, llvm::codeview::StringListRecord&)::$_1>(std::__1::vector<llvm::codeview::TypeIndex, std::__1::allocator<llvm::codeview::TypeIndex> >&, llvm::codeview::TypeRecordMapping::visitKnownRecord(llvm::codeview::CVRecord<llvm::codeview::TypeLeafKind>&, llvm::codeview::StringListRecord&)::$_1 const&)
Line
Count
Source
92
88
  Error mapVectorN(T &Items, const ElementMapper &Mapper) {
93
88
    SizeType Size;
94
88
    if (isWriting()) {
95
35
      Size = static_cast<SizeType>(Items.size());
96
35
      if (auto EC = Writer->writeInteger(Size))
97
0
        return EC;
98
35
99
44
      
for (auto &X : Items)35
{
100
44
        if (auto EC = Mapper(*this, X))
101
0
          return EC;
102
44
      }
103
53
    } else {
104
53
      if (auto EC = Reader->readInteger(Size))
105
0
        return EC;
106
117
      
for (SizeType I = 0; 53
I < Size;
++I64
) {
107
64
        typename T::value_type Item;
108
64
        if (auto EC = Mapper(*this, Item))
109
0
          return EC;
110
64
        Items.push_back(Item);
111
64
      }
112
53
    }
113
88
114
88
    return Error::success();
115
88
  }
TypeRecordMapping.cpp:llvm::Error llvm::codeview::CodeViewRecordIO::mapVectorN<unsigned short, llvm::SmallVector<llvm::codeview::TypeIndex, 5u>, llvm::codeview::TypeRecordMapping::visitKnownRecord(llvm::codeview::CVRecord<llvm::codeview::TypeLeafKind>&, llvm::codeview::BuildInfoRecord&)::$_3>(llvm::SmallVector<llvm::codeview::TypeIndex, 5u>&, llvm::codeview::TypeRecordMapping::visitKnownRecord(llvm::codeview::CVRecord<llvm::codeview::TypeLeafKind>&, llvm::codeview::BuildInfoRecord&)::$_3 const&)
Line
Count
Source
92
442
  Error mapVectorN(T &Items, const ElementMapper &Mapper) {
93
442
    SizeType Size;
94
442
    if (isWriting()) {
95
168
      Size = static_cast<SizeType>(Items.size());
96
168
      if (auto EC = Writer->writeInteger(Size))
97
0
        return EC;
98
168
99
836
      
for (auto &X : Items)168
{
100
836
        if (auto EC = Mapper(*this, X))
101
0
          return EC;
102
836
      }
103
274
    } else {
104
274
      if (auto EC = Reader->readInteger(Size))
105
0
        return EC;
106
1.64k
      
for (SizeType I = 0; 274
I < Size;
++I1.37k
) {
107
1.37k
        typename T::value_type Item;
108
1.37k
        if (auto EC = Mapper(*this, Item))
109
0
          return EC;
110
1.37k
        Items.push_back(Item);
111
1.37k
      }
112
274
    }
113
442
114
442
    return Error::success();
115
442
  }
116
117
  template <typename T, typename ElementMapper>
118
710
  Error mapVectorTail(T &Items, const ElementMapper &Mapper) {
119
710
    if (isWriting()) {
120
134
      for (auto &Item : Items) {
121
134
        if (auto EC = Mapper(*this, Item))
122
0
          return EC;
123
134
      }
124
641
    } else {
125
641
      typename T::value_type Field;
126
641
      // Stop when we run out of bytes or we hit record padding bytes.
127
1.68k
      while (!Reader->empty() && 
Reader->peek() < 0xf01.05k
/* LF_PAD0 */) {
128
1.03k
        if (auto EC = Mapper(*this, Field))
129
0
          return EC;
130
1.03k
        Items.push_back(Field);
131
1.03k
      }
132
641
    }
133
710
    return Error::success();
134
710
  }
SymbolRecordMapping.cpp:llvm::Error llvm::codeview::CodeViewRecordIO::mapVectorTail<std::__1::vector<llvm::codeview::LocalVariableAddrGap, std::__1::allocator<llvm::codeview::LocalVariableAddrGap> >, (anonymous namespace)::MapGap>(std::__1::vector<llvm::codeview::LocalVariableAddrGap, std::__1::allocator<llvm::codeview::LocalVariableAddrGap> >&, (anonymous namespace)::MapGap const&)
Line
Count
Source
118
239
  Error mapVectorTail(T &Items, const ElementMapper &Mapper) {
119
239
    if (isWriting()) {
120
13
      for (auto &Item : Items) {
121
1
        if (auto EC = Mapper(*this, Item))
122
0
          return EC;
123
1
      }
124
226
    } else {
125
226
      typename T::value_type Field;
126
226
      // Stop when we run out of bytes or we hit record padding bytes.
127
231
      while (!Reader->empty() && 
Reader->peek() < 0xf05
/* LF_PAD0 */) {
128
5
        if (auto EC = Mapper(*this, Field))
129
0
          return EC;
130
5
        Items.push_back(Field);
131
5
      }
132
226
    }
133
239
    return Error::success();
134
239
  }
TypeRecordMapping.cpp:llvm::Error llvm::codeview::CodeViewRecordIO::mapVectorTail<std::__1::vector<llvm::StringRef, std::__1::allocator<llvm::StringRef> >, llvm::codeview::TypeRecordMapping::visitKnownRecord(llvm::codeview::CVRecord<llvm::codeview::TypeLeafKind>&, llvm::codeview::VFTableRecord&)::$_2>(std::__1::vector<llvm::StringRef, std::__1::allocator<llvm::StringRef> >&, llvm::codeview::TypeRecordMapping::visitKnownRecord(llvm::codeview::CVRecord<llvm::codeview::TypeLeafKind>&, llvm::codeview::VFTableRecord&)::$_2 const&)
Line
Count
Source
118
17
  Error mapVectorTail(T &Items, const ElementMapper &Mapper) {
119
17
    if (isWriting()) {
120
10
      for (auto &Item : Items) {
121
10
        if (auto EC = Mapper(*this, Item))
122
0
          return EC;
123
10
      }
124
11
    } else {
125
11
      typename T::value_type Field;
126
11
      // Stop when we run out of bytes or we hit record padding bytes.
127
39
      while (!Reader->empty() && Reader->peek() < 0xf0 /* LF_PAD0 */) {
128
28
        if (auto EC = Mapper(*this, Field))
129
0
          return EC;
130
28
        Items.push_back(Field);
131
28
      }
132
11
    }
133
17
    return Error::success();
134
17
  }
TypeRecordMapping.cpp:llvm::Error llvm::codeview::CodeViewRecordIO::mapVectorTail<std::__1::vector<llvm::codeview::OneMethodRecord, std::__1::allocator<llvm::codeview::OneMethodRecord> >, (anonymous namespace)::MapOneMethodRecord>(std::__1::vector<llvm::codeview::OneMethodRecord, std::__1::allocator<llvm::codeview::OneMethodRecord> >&, (anonymous namespace)::MapOneMethodRecord const&)
Line
Count
Source
118
454
  Error mapVectorTail(T &Items, const ElementMapper &Mapper) {
119
454
    if (isWriting()) {
120
123
      for (auto &Item : Items) {
121
123
        if (auto EC = Mapper(*this, Item))
122
0
          return EC;
123
123
      }
124
404
    } else {
125
404
      typename T::value_type Field;
126
404
      // Stop when we run out of bytes or we hit record padding bytes.
127
1.41k
      while (!Reader->empty() && 
Reader->peek() < 0xf01.00k
/* LF_PAD0 */) {
128
1.00k
        if (auto EC = Mapper(*this, Field))
129
0
          return EC;
130
1.00k
        Items.push_back(Field);
131
1.00k
      }
132
404
    }
133
454
    return Error::success();
134
454
  }
135
136
  Error mapByteVectorTail(ArrayRef<uint8_t> &Bytes);
137
  Error mapByteVectorTail(std::vector<uint8_t> &Bytes);
138
139
  Error padToAlignment(uint32_t Align);
140
  Error skipPadding();
141
142
private:
143
  Error writeEncodedSignedInteger(const int64_t &Value);
144
  Error writeEncodedUnsignedInteger(const uint64_t &Value);
145
146
  struct RecordLimit {
147
    uint32_t BeginOffset;
148
    Optional<uint32_t> MaxLength;
149
150
31.2k
    Optional<uint32_t> bytesRemaining(uint32_t CurrentOffset) const {
151
31.2k
      if (!MaxLength.hasValue())
152
6.60k
        return None;
153
24.6k
      assert(CurrentOffset >= BeginOffset);
154
24.6k
155
24.6k
      uint32_t BytesUsed = CurrentOffset - BeginOffset;
156
24.6k
      if (BytesUsed >= *MaxLength)
157
0
        return 0;
158
24.6k
      return *MaxLength - BytesUsed;
159
24.6k
    }
160
  };
161
162
  SmallVector<RecordLimit, 2> Limits;
163
164
  BinaryStreamReader *Reader = nullptr;
165
  BinaryStreamWriter *Writer = nullptr;
166
};
167
168
} // end namespace codeview
169
} // end namespace llvm
170
171
#endif // LLVM_DEBUGINFO_CODEVIEW_CODEVIEWRECORDIO_H