Coverage Report

Created: 2019-02-20 07:29

/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
// 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
#ifndef LLVM_DEBUGINFO_CODEVIEW_CODEVIEWRECORDIO_H
10
#define LLVM_DEBUGINFO_CODEVIEW_CODEVIEWRECORDIO_H
11
12
#include "llvm/ADT/APSInt.h"
13
#include "llvm/ADT/None.h"
14
#include "llvm/ADT/Optional.h"
15
#include "llvm/ADT/SmallVector.h"
16
#include "llvm/ADT/StringRef.h"
17
#include "llvm/DebugInfo/CodeView/CodeViewError.h"
18
#include "llvm/DebugInfo/CodeView/TypeRecord.h"
19
#include "llvm/Support/BinaryStreamReader.h"
20
#include "llvm/Support/BinaryStreamWriter.h"
21
#include "llvm/Support/Error.h"
22
#include <cassert>
23
#include <cstdint>
24
#include <type_traits>
25
26
namespace llvm {
27
namespace codeview {
28
29
class CodeViewRecordIO {
30
67.4k
  uint32_t getCurrentOffset() const {
31
67.4k
    return (isWriting()) ? 
Writer->getOffset()24.4k
:
Reader->getOffset()43.0k
;
32
67.4k
  }
33
34
public:
35
20.5k
  explicit CodeViewRecordIO(BinaryStreamReader &Reader) : Reader(&Reader) {}
36
4.88k
  explicit CodeViewRecordIO(BinaryStreamWriter &Writer) : Writer(&Writer) {}
37
38
  Error beginRecord(Optional<uint32_t> MaxLength);
39
  Error endRecord();
40
41
  Error mapInteger(TypeIndex &TypeInd);
42
43
294k
  bool isReading() const { return Reader != nullptr; }
44
275k
  bool isWriting() const { return !isReading(); }
45
46
  uint32_t maxFieldLength() const;
47
48
177
  template <typename T> Error mapObject(T &Value) {
49
177
    if (isWriting())
50
30
      return Writer->writeObject(Value);
51
147
52
147
    const T *ValuePtr;
53
147
    if (auto EC = Reader->readObject(ValuePtr))
54
0
      return EC;
55
147
    Value = *ValuePtr;
56
147
    return Error::success();
57
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
48
154
  template <typename T> Error mapObject(T &Value) {
49
154
    if (isWriting())
50
26
      return Writer->writeObject(Value);
51
128
52
128
    const T *ValuePtr;
53
128
    if (auto EC = Reader->readObject(ValuePtr))
54
0
      return EC;
55
128
    Value = *ValuePtr;
56
128
    return Error::success();
57
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
48
16
  template <typename T> Error mapObject(T &Value) {
49
16
    if (isWriting())
50
4
      return Writer->writeObject(Value);
51
12
52
12
    const T *ValuePtr;
53
12
    if (auto EC = Reader->readObject(ValuePtr))
54
0
      return EC;
55
12
    Value = *ValuePtr;
56
12
    return Error::success();
57
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
48
7
  template <typename T> Error mapObject(T &Value) {
49
7
    if (isWriting())
50
0
      return Writer->writeObject(Value);
51
7
52
7
    const T *ValuePtr;
53
7
    if (auto EC = Reader->readObject(ValuePtr))
54
0
      return EC;
55
7
    Value = *ValuePtr;
56
7
    return Error::success();
57
7
  }
58
59
60.1k
  template <typename T> Error mapInteger(T &Value) {
60
60.1k
    if (isWriting())
61
15.3k
      return Writer->writeInteger(Value);
62
44.7k
63
44.7k
    return Reader->readInteger(Value);
64
44.7k
  }
llvm::Error llvm::codeview::CodeViewRecordIO::mapInteger<unsigned short>(unsigned short&)
Line
Count
Source
59
39.7k
  template <typename T> Error mapInteger(T &Value) {
60
39.7k
    if (isWriting())
61
10.3k
      return Writer->writeInteger(Value);
62
29.3k
63
29.3k
    return Reader->readInteger(Value);
64
29.3k
  }
llvm::Error llvm::codeview::CodeViewRecordIO::mapInteger<unsigned int>(unsigned int&)
Line
Count
Source
59
10.8k
  template <typename T> Error mapInteger(T &Value) {
60
10.8k
    if (isWriting())
61
3.04k
      return Writer->writeInteger(Value);
62
7.82k
63
7.82k
    return Reader->readInteger(Value);
64
7.82k
  }
llvm::Error llvm::codeview::CodeViewRecordIO::mapInteger<unsigned char>(unsigned char&)
Line
Count
Source
59
7.12k
  template <typename T> Error mapInteger(T &Value) {
60
7.12k
    if (isWriting())
61
1.69k
      return Writer->writeInteger(Value);
62
5.43k
63
5.43k
    return Reader->readInteger(Value);
64
5.43k
  }
llvm::Error llvm::codeview::CodeViewRecordIO::mapInteger<int>(int&)
Line
Count
Source
59
2.42k
  template <typename T> Error mapInteger(T &Value) {
60
2.42k
    if (isWriting())
61
273
      return Writer->writeInteger(Value);
62
2.15k
63
2.15k
    return Reader->readInteger(Value);
64
2.15k
  }
65
66
14.2k
  template <typename T> Error mapEnum(T &Value) {
67
14.2k
    if (sizeof(Value) > maxFieldLength())
68
0
      return make_error<CodeViewError>(cv_error_code::insufficient_buffer);
69
14.2k
70
14.2k
    using U = typename std::underlying_type<T>::type;
71
14.2k
    U X;
72
14.2k
    if (isWriting())
73
2.12k
      X = static_cast<U>(Value);
74
14.2k
75
14.2k
    if (auto EC = mapInteger(X))
76
0
      return EC;
77
14.2k
    if (isReading())
78
12.1k
      Value = static_cast<T>(X);
79
14.2k
    return Error::success();
80
14.2k
  }
llvm::Error llvm::codeview::CodeViewRecordIO::mapEnum<llvm::codeview::ThunkOrdinal>(llvm::codeview::ThunkOrdinal&)
Line
Count
Source
66
4
  template <typename T> Error mapEnum(T &Value) {
67
4
    if (sizeof(Value) > maxFieldLength())
68
0
      return make_error<CodeViewError>(cv_error_code::insufficient_buffer);
69
4
70
4
    using U = typename std::underlying_type<T>::type;
71
4
    U X;
72
4
    if (isWriting())
73
1
      X = static_cast<U>(Value);
74
4
75
4
    if (auto EC = mapInteger(X))
76
0
      return EC;
77
4
    if (isReading())
78
3
      Value = static_cast<T>(X);
79
4
    return Error::success();
80
4
  }
llvm::Error llvm::codeview::CodeViewRecordIO::mapEnum<llvm::codeview::TrampolineType>(llvm::codeview::TrampolineType&)
Line
Count
Source
66
6
  template <typename T> Error mapEnum(T &Value) {
67
6
    if (sizeof(Value) > maxFieldLength())
68
0
      return make_error<CodeViewError>(cv_error_code::insufficient_buffer);
69
6
70
6
    using U = typename std::underlying_type<T>::type;
71
6
    U X;
72
6
    if (isWriting())
73
1
      X = static_cast<U>(Value);
74
6
75
6
    if (auto EC = mapInteger(X))
76
0
      return EC;
77
6
    if (isReading())
78
5
      Value = static_cast<T>(X);
79
6
    return Error::success();
80
6
  }
llvm::Error llvm::codeview::CodeViewRecordIO::mapEnum<llvm::codeview::LocalSymFlags>(llvm::codeview::LocalSymFlags&)
Line
Count
Source
66
236
  template <typename T> Error mapEnum(T &Value) {
67
236
    if (sizeof(Value) > maxFieldLength())
68
0
      return make_error<CodeViewError>(cv_error_code::insufficient_buffer);
69
236
70
236
    using U = typename std::underlying_type<T>::type;
71
236
    U X;
72
236
    if (isWriting())
73
11
      X = static_cast<U>(Value);
74
236
75
236
    if (auto EC = mapInteger(X))
76
0
      return EC;
77
236
    if (isReading())
78
225
      Value = static_cast<T>(X);
79
236
    return Error::success();
80
236
  }
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
66
293
  template <typename T> Error mapEnum(T &Value) {
67
293
    if (sizeof(Value) > maxFieldLength())
68
0
      return make_error<CodeViewError>(cv_error_code::insufficient_buffer);
69
293
70
293
    using U = typename std::underlying_type<T>::type;
71
293
    U X;
72
293
    if (isWriting())
73
136
      X = static_cast<U>(Value);
74
293
75
293
    if (auto EC = mapInteger(X))
76
0
      return EC;
77
293
    if (isReading())
78
157
      Value = static_cast<T>(X);
79
293
    return Error::success();
80
293
  }
llvm::Error llvm::codeview::CodeViewRecordIO::mapEnum<llvm::codeview::CompileSym3Flags>(llvm::codeview::CompileSym3Flags&)
Line
Count
Source
66
293
  template <typename T> Error mapEnum(T &Value) {
67
293
    if (sizeof(Value) > maxFieldLength())
68
0
      return make_error<CodeViewError>(cv_error_code::insufficient_buffer);
69
293
70
293
    using U = typename std::underlying_type<T>::type;
71
293
    U X;
72
293
    if (isWriting())
73
136
      X = static_cast<U>(Value);
74
293
75
293
    if (auto EC = mapInteger(X))
76
0
      return EC;
77
293
    if (isReading())
78
157
      Value = static_cast<T>(X);
79
293
    return Error::success();
80
293
  }
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
66
279
  template <typename T> Error mapEnum(T &Value) {
67
279
    if (sizeof(Value) > maxFieldLength())
68
0
      return make_error<CodeViewError>(cv_error_code::insufficient_buffer);
69
279
70
279
    using U = typename std::underlying_type<T>::type;
71
279
    U X;
72
279
    if (isWriting())
73
51
      X = static_cast<U>(Value);
74
279
75
279
    if (auto EC = mapInteger(X))
76
0
      return EC;
77
279
    if (isReading())
78
228
      Value = static_cast<T>(X);
79
279
    return Error::success();
80
279
  }
llvm::Error llvm::codeview::CodeViewRecordIO::mapEnum<llvm::codeview::RegisterId>(llvm::codeview::RegisterId&)
Line
Count
Source
66
46
  template <typename T> Error mapEnum(T &Value) {
67
46
    if (sizeof(Value) > maxFieldLength())
68
0
      return make_error<CodeViewError>(cv_error_code::insufficient_buffer);
69
46
70
46
    using U = typename std::underlying_type<T>::type;
71
46
    U X;
72
46
    if (isWriting())
73
21
      X = static_cast<U>(Value);
74
46
75
46
    if (auto EC = mapInteger(X))
76
0
      return EC;
77
46
    if (isReading())
78
25
      Value = static_cast<T>(X);
79
46
    return Error::success();
80
46
  }
llvm::Error llvm::codeview::CodeViewRecordIO::mapEnum<llvm::codeview::PublicSymFlags>(llvm::codeview::PublicSymFlags&)
Line
Count
Source
66
525
  template <typename T> Error mapEnum(T &Value) {
67
525
    if (sizeof(Value) > maxFieldLength())
68
0
      return make_error<CodeViewError>(cv_error_code::insufficient_buffer);
69
525
70
525
    using U = typename std::underlying_type<T>::type;
71
525
    U X;
72
525
    if (isWriting())
73
246
      X = static_cast<U>(Value);
74
525
75
525
    if (auto EC = mapInteger(X))
76
0
      return EC;
77
525
    if (isReading())
78
279
      Value = static_cast<T>(X);
79
525
    return Error::success();
80
525
  }
llvm::Error llvm::codeview::CodeViewRecordIO::mapEnum<llvm::codeview::ProcSymFlags>(llvm::codeview::ProcSymFlags&)
Line
Count
Source
66
303
  template <typename T> Error mapEnum(T &Value) {
67
303
    if (sizeof(Value) > maxFieldLength())
68
0
      return make_error<CodeViewError>(cv_error_code::insufficient_buffer);
69
303
70
303
    using U = typename std::underlying_type<T>::type;
71
303
    U X;
72
303
    if (isWriting())
73
55
      X = static_cast<U>(Value);
74
303
75
303
    if (auto EC = mapInteger(X))
76
0
      return EC;
77
303
    if (isReading())
78
248
      Value = static_cast<T>(X);
79
303
    return Error::success();
80
303
  }
llvm::Error llvm::codeview::CodeViewRecordIO::mapEnum<llvm::codeview::ModifierOptions>(llvm::codeview::ModifierOptions&)
Line
Count
Source
66
343
  template <typename T> Error mapEnum(T &Value) {
67
343
    if (sizeof(Value) > maxFieldLength())
68
0
      return make_error<CodeViewError>(cv_error_code::insufficient_buffer);
69
343
70
343
    using U = typename std::underlying_type<T>::type;
71
343
    U X;
72
343
    if (isWriting())
73
48
      X = static_cast<U>(Value);
74
343
75
343
    if (auto EC = mapInteger(X))
76
0
      return EC;
77
343
    if (isReading())
78
295
      Value = static_cast<T>(X);
79
343
    return Error::success();
80
343
  }
llvm::Error llvm::codeview::CodeViewRecordIO::mapEnum<llvm::codeview::CallingConvention>(llvm::codeview::CallingConvention&)
Line
Count
Source
66
2.96k
  template <typename T> Error mapEnum(T &Value) {
67
2.96k
    if (sizeof(Value) > maxFieldLength())
68
0
      return make_error<CodeViewError>(cv_error_code::insufficient_buffer);
69
2.96k
70
2.96k
    using U = typename std::underlying_type<T>::type;
71
2.96k
    U X;
72
2.96k
    if (isWriting())
73
490
      X = static_cast<U>(Value);
74
2.96k
75
2.96k
    if (auto EC = mapInteger(X))
76
0
      return EC;
77
2.96k
    if (isReading())
78
2.47k
      Value = static_cast<T>(X);
79
2.96k
    return Error::success();
80
2.96k
  }
llvm::Error llvm::codeview::CodeViewRecordIO::mapEnum<llvm::codeview::FunctionOptions>(llvm::codeview::FunctionOptions&)
Line
Count
Source
66
2.96k
  template <typename T> Error mapEnum(T &Value) {
67
2.96k
    if (sizeof(Value) > maxFieldLength())
68
0
      return make_error<CodeViewError>(cv_error_code::insufficient_buffer);
69
2.96k
70
2.96k
    using U = typename std::underlying_type<T>::type;
71
2.96k
    U X;
72
2.96k
    if (isWriting())
73
490
      X = static_cast<U>(Value);
74
2.96k
75
2.96k
    if (auto EC = mapInteger(X))
76
0
      return EC;
77
2.96k
    if (isReading())
78
2.47k
      Value = static_cast<T>(X);
79
2.96k
    return Error::success();
80
2.96k
  }
llvm::Error llvm::codeview::CodeViewRecordIO::mapEnum<llvm::codeview::PointerToMemberRepresentation>(llvm::codeview::PointerToMemberRepresentation&)
Line
Count
Source
66
55
  template <typename T> Error mapEnum(T &Value) {
67
55
    if (sizeof(Value) > maxFieldLength())
68
0
      return make_error<CodeViewError>(cv_error_code::insufficient_buffer);
69
55
70
55
    using U = typename std::underlying_type<T>::type;
71
55
    U X;
72
55
    if (isWriting())
73
18
      X = static_cast<U>(Value);
74
55
75
55
    if (auto EC = mapInteger(X))
76
0
      return EC;
77
55
    if (isReading())
78
37
      Value = static_cast<T>(X);
79
55
    return Error::success();
80
55
  }
llvm::Error llvm::codeview::CodeViewRecordIO::mapEnum<llvm::codeview::ClassOptions>(llvm::codeview::ClassOptions&)
Line
Count
Source
66
5.97k
  template <typename T> Error mapEnum(T &Value) {
67
5.97k
    if (sizeof(Value) > maxFieldLength())
68
0
      return make_error<CodeViewError>(cv_error_code::insufficient_buffer);
69
5.97k
70
5.97k
    using U = typename std::underlying_type<T>::type;
71
5.97k
    U X;
72
5.97k
    if (isWriting())
73
425
      X = static_cast<U>(Value);
74
5.97k
75
5.97k
    if (auto EC = mapInteger(X))
76
0
      return EC;
77
5.97k
    if (isReading())
78
5.55k
      Value = static_cast<T>(X);
79
5.97k
    return Error::success();
80
5.97k
  }
llvm::Error llvm::codeview::CodeViewRecordIO::mapEnum<llvm::codeview::LabelType>(llvm::codeview::LabelType&)
Line
Count
Source
66
1
  template <typename T> Error mapEnum(T &Value) {
67
1
    if (sizeof(Value) > maxFieldLength())
68
0
      return make_error<CodeViewError>(cv_error_code::insufficient_buffer);
69
1
70
1
    using U = typename std::underlying_type<T>::type;
71
1
    U X;
72
1
    if (isWriting())
73
0
      X = static_cast<U>(Value);
74
1
75
1
    if (auto EC = mapInteger(X))
76
0
      return EC;
77
1
    if (isReading())
78
1
      Value = static_cast<T>(X);
79
1
    return Error::success();
80
1
  }
81
82
  Error mapEncodedInteger(int64_t &Value);
83
  Error mapEncodedInteger(uint64_t &Value);
84
  Error mapEncodedInteger(APSInt &Value);
85
  Error mapStringZ(StringRef &Value);
86
  Error mapGuid(GUID &Guid);
87
88
  Error mapStringZVectorZ(std::vector<StringRef> &Value);
89
90
  template <typename SizeType, typename T, typename ElementMapper>
91
2.09k
  Error mapVectorN(T &Items, const ElementMapper &Mapper) {
92
2.09k
    SizeType Size;
93
2.09k
    if (isWriting()) {
94
646
      Size = static_cast<SizeType>(Items.size());
95
646
      if (auto EC = Writer->writeInteger(Size))
96
0
        return EC;
97
646
98
1.30k
      
for (auto &X : Items)646
{
99
1.30k
        if (auto EC = Mapper(*this, X))
100
0
          return EC;
101
1.30k
      }
102
1.44k
    } else {
103
1.44k
      if (auto EC = Reader->readInteger(Size))
104
0
        return EC;
105
4.63k
      
for (SizeType I = 0; 1.44k
I < Size;
++I3.19k
) {
106
3.19k
        typename T::value_type Item;
107
3.19k
        if (auto EC = Mapper(*this, Item))
108
0
          return EC;
109
3.19k
        Items.push_back(Item);
110
3.19k
      }
111
1.44k
    }
112
2.09k
113
2.09k
    return Error::success();
114
2.09k
  }
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
91
15
  Error mapVectorN(T &Items, const ElementMapper &Mapper) {
92
15
    SizeType Size;
93
15
    if (isWriting()) {
94
7
      Size = static_cast<SizeType>(Items.size());
95
7
      if (auto EC = Writer->writeInteger(Size))
96
0
        return EC;
97
7
98
13
      
for (auto &X : Items)7
{
99
13
        if (auto EC = Mapper(*this, X))
100
0
          return EC;
101
13
      }
102
8
    } else {
103
8
      if (auto EC = Reader->readInteger(Size))
104
0
        return EC;
105
17
      
for (SizeType I = 0; 8
I < Size;
++I9
) {
106
9
        typename T::value_type Item;
107
9
        if (auto EC = Mapper(*this, Item))
108
0
          return EC;
109
9
        Items.push_back(Item);
110
9
      }
111
8
    }
112
15
113
15
    return Error::success();
114
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
91
1.52k
  Error mapVectorN(T &Items, const ElementMapper &Mapper) {
92
1.52k
    SizeType Size;
93
1.52k
    if (isWriting()) {
94
427
      Size = static_cast<SizeType>(Items.size());
95
427
      if (auto EC = Writer->writeInteger(Size))
96
0
        return EC;
97
427
98
427
      for (auto &X : Items) {
99
374
        if (auto EC = Mapper(*this, X))
100
0
          return EC;
101
374
      }
102
1.10k
    } else {
103
1.10k
      if (auto EC = Reader->readInteger(Size))
104
0
        return EC;
105
2.80k
      
for (SizeType I = 0; 1.10k
I < Size;
++I1.70k
) {
106
1.70k
        typename T::value_type Item;
107
1.70k
        if (auto EC = Mapper(*this, Item))
108
0
          return EC;
109
1.70k
        Items.push_back(Item);
110
1.70k
      }
111
1.10k
    }
112
1.52k
113
1.52k
    return Error::success();
114
1.52k
  }
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
91
90
  Error mapVectorN(T &Items, const ElementMapper &Mapper) {
92
90
    SizeType Size;
93
90
    if (isWriting()) {
94
37
      Size = static_cast<SizeType>(Items.size());
95
37
      if (auto EC = Writer->writeInteger(Size))
96
0
        return EC;
97
37
98
46
      
for (auto &X : Items)37
{
99
46
        if (auto EC = Mapper(*this, X))
100
0
          return EC;
101
46
      }
102
53
    } else {
103
53
      if (auto EC = Reader->readInteger(Size))
104
0
        return EC;
105
117
      
for (SizeType I = 0; 53
I < Size;
++I64
) {
106
64
        typename T::value_type Item;
107
64
        if (auto EC = Mapper(*this, Item))
108
0
          return EC;
109
64
        Items.push_back(Item);
110
64
      }
111
53
    }
112
90
113
90
    return Error::success();
114
90
  }
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
91
457
  Error mapVectorN(T &Items, const ElementMapper &Mapper) {
92
457
    SizeType Size;
93
457
    if (isWriting()) {
94
175
      Size = static_cast<SizeType>(Items.size());
95
175
      if (auto EC = Writer->writeInteger(Size))
96
0
        return EC;
97
175
98
871
      
for (auto &X : Items)175
{
99
871
        if (auto EC = Mapper(*this, X))
100
0
          return EC;
101
871
      }
102
282
    } else {
103
282
      if (auto EC = Reader->readInteger(Size))
104
0
        return EC;
105
1.69k
      
for (SizeType I = 0; 282
I < Size;
++I1.41k
) {
106
1.41k
        typename T::value_type Item;
107
1.41k
        if (auto EC = Mapper(*this, Item))
108
0
          return EC;
109
1.41k
        Items.push_back(Item);
110
1.41k
      }
111
282
    }
112
457
113
457
    return Error::success();
114
457
  }
115
116
  template <typename T, typename ElementMapper>
117
724
  Error mapVectorTail(T &Items, const ElementMapper &Mapper) {
118
724
    if (isWriting()) {
119
136
      for (auto &Item : Items) {
120
136
        if (auto EC = Mapper(*this, Item))
121
0
          return EC;
122
136
      }
123
654
    } else {
124
654
      typename T::value_type Field;
125
654
      // Stop when we run out of bytes or we hit record padding bytes.
126
1.69k
      while (!Reader->empty() && 
Reader->peek() < 0xf01.05k
/* LF_PAD0 */) {
127
1.04k
        if (auto EC = Mapper(*this, Field))
128
0
          return EC;
129
1.04k
        Items.push_back(Field);
130
1.04k
      }
131
654
    }
132
724
    return Error::success();
133
724
  }
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
117
250
  Error mapVectorTail(T &Items, const ElementMapper &Mapper) {
118
250
    if (isWriting()) {
119
13
      for (auto &Item : Items) {
120
1
        if (auto EC = Mapper(*this, Item))
121
0
          return EC;
122
1
      }
123
237
    } else {
124
237
      typename T::value_type Field;
125
237
      // Stop when we run out of bytes or we hit record padding bytes.
126
242
      while (!Reader->empty() && 
Reader->peek() < 0xf05
/* LF_PAD0 */) {
127
5
        if (auto EC = Mapper(*this, Field))
128
0
          return EC;
129
5
        Items.push_back(Field);
130
5
      }
131
237
    }
132
250
    return Error::success();
133
250
  }
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
117
17
  Error mapVectorTail(T &Items, const ElementMapper &Mapper) {
118
17
    if (isWriting()) {
119
10
      for (auto &Item : Items) {
120
10
        if (auto EC = Mapper(*this, Item))
121
0
          return EC;
122
10
      }
123
11
    } else {
124
11
      typename T::value_type Field;
125
11
      // Stop when we run out of bytes or we hit record padding bytes.
126
39
      while (!Reader->empty() && Reader->peek() < 0xf0 /* LF_PAD0 */) {
127
28
        if (auto EC = Mapper(*this, Field))
128
0
          return EC;
129
28
        Items.push_back(Field);
130
28
      }
131
11
    }
132
17
    return Error::success();
133
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
117
457
  Error mapVectorTail(T &Items, const ElementMapper &Mapper) {
118
457
    if (isWriting()) {
119
125
      for (auto &Item : Items) {
120
125
        if (auto EC = Mapper(*this, Item))
121
0
          return EC;
122
125
      }
123
406
    } else {
124
406
      typename T::value_type Field;
125
406
      // Stop when we run out of bytes or we hit record padding bytes.
126
1.41k
      while (!Reader->empty() && 
Reader->peek() < 0xf01.01k
/* LF_PAD0 */) {
127
1.01k
        if (auto EC = Mapper(*this, Field))
128
0
          return EC;
129
1.01k
        Items.push_back(Field);
130
1.01k
      }
131
406
    }
132
457
    return Error::success();
133
457
  }
134
135
  Error mapByteVectorTail(ArrayRef<uint8_t> &Bytes);
136
  Error mapByteVectorTail(std::vector<uint8_t> &Bytes);
137
138
  Error padToAlignment(uint32_t Align);
139
  Error skipPadding();
140
141
private:
142
  Error writeEncodedSignedInteger(const int64_t &Value);
143
  Error writeEncodedUnsignedInteger(const uint64_t &Value);
144
145
  struct RecordLimit {
146
    uint32_t BeginOffset;
147
    Optional<uint32_t> MaxLength;
148
149
31.6k
    Optional<uint32_t> bytesRemaining(uint32_t CurrentOffset) const {
150
31.6k
      if (!MaxLength.hasValue())
151
6.61k
        return None;
152
25.0k
      assert(CurrentOffset >= BeginOffset);
153
25.0k
154
25.0k
      uint32_t BytesUsed = CurrentOffset - BeginOffset;
155
25.0k
      if (BytesUsed >= *MaxLength)
156
0
        return 0;
157
25.0k
      return *MaxLength - BytesUsed;
158
25.0k
    }
159
  };
160
161
  SmallVector<RecordLimit, 2> Limits;
162
163
  BinaryStreamReader *Reader = nullptr;
164
  BinaryStreamWriter *Writer = nullptr;
165
};
166
167
} // end namespace codeview
168
} // end namespace llvm
169
170
#endif // LLVM_DEBUGINFO_CODEVIEW_CODEVIEWRECORDIO_H