Coverage Report

Created: 2018-07-19 03:59

/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
50.8k
  uint32_t getCurrentOffset() const {
32
50.8k
    return (isWriting()) ? 
Writer->getOffset()21.9k
:
Reader->getOffset()28.8k
;
33
50.8k
  }
34
35
public:
36
12.8k
  explicit CodeViewRecordIO(BinaryStreamReader &Reader) : Reader(&Reader) {}
37
3.78k
  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
211k
  bool isReading() const { return Reader != nullptr; }
45
199k
  bool isWriting() const { return !isReading(); }
46
47
  uint32_t maxFieldLength() const;
48
49
563
  template <typename T> Error mapObject(T &Value) {
50
563
    if (isWriting())
51
18
      return Writer->writeObject(Value);
52
545
53
545
    const T *ValuePtr;
54
545
    if (auto EC = Reader->readObject(ValuePtr))
55
0
      return EC;
56
545
    Value = *ValuePtr;
57
545
    return Error::success();
58
545
  }
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
410
  template <typename T> Error mapObject(T &Value) {
50
410
    if (isWriting())
51
18
      return Writer->writeObject(Value);
52
392
53
392
    const T *ValuePtr;
54
392
    if (auto EC = Reader->readObject(ValuePtr))
55
0
      return EC;
56
392
    Value = *ValuePtr;
57
392
    return Error::success();
58
392
  }
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
146
  template <typename T> Error mapObject(T &Value) {
50
146
    if (isWriting())
51
0
      return Writer->writeObject(Value);
52
146
53
146
    const T *ValuePtr;
54
146
    if (auto EC = Reader->readObject(ValuePtr))
55
0
      return EC;
56
146
    Value = *ValuePtr;
57
146
    return Error::success();
58
146
  }
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
44.1k
  template <typename T> Error mapInteger(T &Value) {
61
44.1k
    if (isWriting())
62
13.7k
      return Writer->writeInteger(Value);
63
30.4k
64
30.4k
    return Reader->readInteger(Value);
65
30.4k
  }
llvm::Error llvm::codeview::CodeViewRecordIO::mapInteger<unsigned short>(unsigned short&)
Line
Count
Source
60
29.4k
  template <typename T> Error mapInteger(T &Value) {
61
29.4k
    if (isWriting())
62
9.67k
      return Writer->writeInteger(Value);
63
19.7k
64
19.7k
    return Reader->readInteger(Value);
65
19.7k
  }
llvm::Error llvm::codeview::CodeViewRecordIO::mapInteger<unsigned int>(unsigned int&)
Line
Count
Source
60
7.64k
  template <typename T> Error mapInteger(T &Value) {
61
7.64k
    if (isWriting())
62
2.41k
      return Writer->writeInteger(Value);
63
5.23k
64
5.23k
    return Reader->readInteger(Value);
65
5.23k
  }
llvm::Error llvm::codeview::CodeViewRecordIO::mapInteger<unsigned char>(unsigned char&)
Line
Count
Source
60
5.40k
  template <typename T> Error mapInteger(T &Value) {
61
5.40k
    if (isWriting())
62
1.39k
      return Writer->writeInteger(Value);
63
4.00k
64
4.00k
    return Reader->readInteger(Value);
65
4.00k
  }
llvm::Error llvm::codeview::CodeViewRecordIO::mapInteger<int>(int&)
Line
Count
Source
60
1.67k
  template <typename T> Error mapInteger(T &Value) {
61
1.67k
    if (isWriting())
62
259
      return Writer->writeInteger(Value);
63
1.41k
64
1.41k
    return Reader->readInteger(Value);
65
1.41k
  }
66
67
8.98k
  template <typename T> Error mapEnum(T &Value) {
68
8.98k
    if (sizeof(Value) > maxFieldLength())
69
0
      return make_error<CodeViewError>(cv_error_code::insufficient_buffer);
70
8.98k
71
8.98k
    using U = typename std::underlying_type<T>::type;
72
8.98k
    U X;
73
8.98k
    if (isWriting())
74
1.81k
      X = static_cast<U>(Value);
75
8.98k
76
8.98k
    if (auto EC = mapInteger(X))
77
0
      return EC;
78
8.98k
    if (isReading())
79
7.16k
      Value = static_cast<T>(X);
80
8.98k
    return Error::success();
81
8.98k
  }
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
193
  template <typename T> Error mapEnum(T &Value) {
68
193
    if (sizeof(Value) > maxFieldLength())
69
0
      return make_error<CodeViewError>(cv_error_code::insufficient_buffer);
70
193
71
193
    using U = typename std::underlying_type<T>::type;
72
193
    U X;
73
193
    if (isWriting())
74
7
      X = static_cast<U>(Value);
75
193
76
193
    if (auto EC = mapInteger(X))
77
0
      return EC;
78
193
    if (isReading())
79
186
      Value = static_cast<T>(X);
80
193
    return Error::success();
81
193
  }
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
234
  template <typename T> Error mapEnum(T &Value) {
68
234
    if (sizeof(Value) > maxFieldLength())
69
0
      return make_error<CodeViewError>(cv_error_code::insufficient_buffer);
70
234
71
234
    using U = typename std::underlying_type<T>::type;
72
234
    U X;
73
234
    if (isWriting())
74
99
      X = static_cast<U>(Value);
75
234
76
234
    if (auto EC = mapInteger(X))
77
0
      return EC;
78
234
    if (isReading())
79
135
      Value = static_cast<T>(X);
80
234
    return Error::success();
81
234
  }
llvm::Error llvm::codeview::CodeViewRecordIO::mapEnum<llvm::codeview::CompileSym3Flags>(llvm::codeview::CompileSym3Flags&)
Line
Count
Source
67
234
  template <typename T> Error mapEnum(T &Value) {
68
234
    if (sizeof(Value) > maxFieldLength())
69
0
      return make_error<CodeViewError>(cv_error_code::insufficient_buffer);
70
234
71
234
    using U = typename std::underlying_type<T>::type;
72
234
    U X;
73
234
    if (isWriting())
74
99
      X = static_cast<U>(Value);
75
234
76
234
    if (auto EC = mapInteger(X))
77
0
      return EC;
78
234
    if (isReading())
79
135
      Value = static_cast<T>(X);
80
234
    return Error::success();
81
234
  }
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
113
  template <typename T> Error mapEnum(T &Value) {
68
113
    if (sizeof(Value) > maxFieldLength())
69
0
      return make_error<CodeViewError>(cv_error_code::insufficient_buffer);
70
113
71
113
    using U = typename std::underlying_type<T>::type;
72
113
    U X;
73
113
    if (isWriting())
74
42
      X = static_cast<U>(Value);
75
113
76
113
    if (auto EC = mapInteger(X))
77
0
      return EC;
78
113
    if (isReading())
79
71
      Value = static_cast<T>(X);
80
113
    return Error::success();
81
113
  }
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
405
  template <typename T> Error mapEnum(T &Value) {
68
405
    if (sizeof(Value) > maxFieldLength())
69
0
      return make_error<CodeViewError>(cv_error_code::insufficient_buffer);
70
405
71
405
    using U = typename std::underlying_type<T>::type;
72
405
    U X;
73
405
    if (isWriting())
74
198
      X = static_cast<U>(Value);
75
405
76
405
    if (auto EC = mapInteger(X))
77
0
      return EC;
78
405
    if (isReading())
79
207
      Value = static_cast<T>(X);
80
405
    return Error::success();
81
405
  }
llvm::Error llvm::codeview::CodeViewRecordIO::mapEnum<llvm::codeview::ProcSymFlags>(llvm::codeview::ProcSymFlags&)
Line
Count
Source
67
249
  template <typename T> Error mapEnum(T &Value) {
68
249
    if (sizeof(Value) > maxFieldLength())
69
0
      return make_error<CodeViewError>(cv_error_code::insufficient_buffer);
70
249
71
249
    using U = typename std::underlying_type<T>::type;
72
249
    U X;
73
249
    if (isWriting())
74
44
      X = static_cast<U>(Value);
75
249
76
249
    if (auto EC = mapInteger(X))
77
0
      return EC;
78
249
    if (isReading())
79
205
      Value = static_cast<T>(X);
80
249
    return Error::success();
81
249
  }
llvm::Error llvm::codeview::CodeViewRecordIO::mapEnum<llvm::codeview::ModifierOptions>(llvm::codeview::ModifierOptions&)
Line
Count
Source
67
253
  template <typename T> Error mapEnum(T &Value) {
68
253
    if (sizeof(Value) > maxFieldLength())
69
0
      return make_error<CodeViewError>(cv_error_code::insufficient_buffer);
70
253
71
253
    using U = typename std::underlying_type<T>::type;
72
253
    U X;
73
253
    if (isWriting())
74
43
      X = static_cast<U>(Value);
75
253
76
253
    if (auto EC = mapInteger(X))
77
0
      return EC;
78
253
    if (isReading())
79
210
      Value = static_cast<T>(X);
80
253
    return Error::success();
81
253
  }
llvm::Error llvm::codeview::CodeViewRecordIO::mapEnum<llvm::codeview::CallingConvention>(llvm::codeview::CallingConvention&)
Line
Count
Source
67
2.22k
  template <typename T> Error mapEnum(T &Value) {
68
2.22k
    if (sizeof(Value) > maxFieldLength())
69
0
      return make_error<CodeViewError>(cv_error_code::insufficient_buffer);
70
2.22k
71
2.22k
    using U = typename std::underlying_type<T>::type;
72
2.22k
    U X;
73
2.22k
    if (isWriting())
74
432
      X = static_cast<U>(Value);
75
2.22k
76
2.22k
    if (auto EC = mapInteger(X))
77
0
      return EC;
78
2.22k
    if (isReading())
79
1.79k
      Value = static_cast<T>(X);
80
2.22k
    return Error::success();
81
2.22k
  }
llvm::Error llvm::codeview::CodeViewRecordIO::mapEnum<llvm::codeview::FunctionOptions>(llvm::codeview::FunctionOptions&)
Line
Count
Source
67
2.22k
  template <typename T> Error mapEnum(T &Value) {
68
2.22k
    if (sizeof(Value) > maxFieldLength())
69
0
      return make_error<CodeViewError>(cv_error_code::insufficient_buffer);
70
2.22k
71
2.22k
    using U = typename std::underlying_type<T>::type;
72
2.22k
    U X;
73
2.22k
    if (isWriting())
74
432
      X = static_cast<U>(Value);
75
2.22k
76
2.22k
    if (auto EC = mapInteger(X))
77
0
      return EC;
78
2.22k
    if (isReading())
79
1.79k
      Value = static_cast<T>(X);
80
2.22k
    return Error::success();
81
2.22k
  }
llvm::Error llvm::codeview::CodeViewRecordIO::mapEnum<llvm::codeview::PointerToMemberRepresentation>(llvm::codeview::PointerToMemberRepresentation&)
Line
Count
Source
67
49
  template <typename T> Error mapEnum(T &Value) {
68
49
    if (sizeof(Value) > maxFieldLength())
69
0
      return make_error<CodeViewError>(cv_error_code::insufficient_buffer);
70
49
71
49
    using U = typename std::underlying_type<T>::type;
72
49
    U X;
73
49
    if (isWriting())
74
18
      X = static_cast<U>(Value);
75
49
76
49
    if (auto EC = mapInteger(X))
77
0
      return EC;
78
49
    if (isReading())
79
31
      Value = static_cast<T>(X);
80
49
    return Error::success();
81
49
  }
llvm::Error llvm::codeview::CodeViewRecordIO::mapEnum<llvm::codeview::ClassOptions>(llvm::codeview::ClassOptions&)
Line
Count
Source
67
2.74k
  template <typename T> Error mapEnum(T &Value) {
68
2.74k
    if (sizeof(Value) > maxFieldLength())
69
0
      return make_error<CodeViewError>(cv_error_code::insufficient_buffer);
70
2.74k
71
2.74k
    using U = typename std::underlying_type<T>::type;
72
2.74k
    U X;
73
2.74k
    if (isWriting())
74
381
      X = static_cast<U>(Value);
75
2.74k
76
2.74k
    if (auto EC = mapInteger(X))
77
0
      return EC;
78
2.74k
    if (isReading())
79
2.36k
      Value = static_cast<T>(X);
80
2.74k
    return Error::success();
81
2.74k
  }
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
1.34k
  Error mapVectorN(T &Items, const ElementMapper &Mapper) {
93
1.34k
    SizeType Size;
94
1.34k
    if (isWriting()) {
95
437
      Size = static_cast<SizeType>(Items.size());
96
437
      if (auto EC = Writer->writeInteger(Size))
97
0
        return EC;
98
437
99
537
      
for (auto &X : Items)437
{
100
537
        if (auto EC = Mapper(*this, X))
101
0
          return EC;
102
537
      }
103
904
    } else {
104
904
      if (auto EC = Reader->readInteger(Size))
105
0
        return EC;
106
2.47k
      
for (SizeType I = 0; 904
I < Size;
++I1.56k
) {
107
1.56k
        typename T::value_type Item;
108
1.56k
        if (auto EC = Mapper(*this, Item))
109
0
          return EC;
110
1.56k
        Items.push_back(Item);
111
1.56k
      }
112
904
    }
113
1.34k
114
1.34k
    return Error::success();
115
1.34k
  }
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.16k
  Error mapVectorN(T &Items, const ElementMapper &Mapper) {
93
1.16k
    SizeType Size;
94
1.16k
    if (isWriting()) {
95
369
      Size = static_cast<SizeType>(Items.size());
96
369
      if (auto EC = Writer->writeInteger(Size))
97
0
        return EC;
98
369
99
369
      for (auto &X : Items) {
100
338
        if (auto EC = Mapper(*this, X))
101
0
          return EC;
102
338
      }
103
792
    } else {
104
792
      if (auto EC = Reader->readInteger(Size))
105
0
        return EC;
106
2.02k
      
for (SizeType I = 0; 792
I < Size;
++I1.23k
) {
107
1.23k
        typename T::value_type Item;
108
1.23k
        if (auto EC = Mapper(*this, Item))
109
0
          return EC;
110
1.23k
        Items.push_back(Item);
111
1.23k
      }
112
792
    }
113
1.16k
114
1.16k
    return Error::success();
115
1.16k
  }
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
82
  Error mapVectorN(T &Items, const ElementMapper &Mapper) {
93
82
    SizeType Size;
94
82
    if (isWriting()) {
95
31
      Size = static_cast<SizeType>(Items.size());
96
31
      if (auto EC = Writer->writeInteger(Size))
97
0
        return EC;
98
31
99
40
      
for (auto &X : Items)31
{
100
40
        if (auto EC = Mapper(*this, X))
101
0
          return EC;
102
40
      }
103
51
    } else {
104
51
      if (auto EC = Reader->readInteger(Size))
105
0
        return EC;
106
111
      
for (SizeType I = 0; 51
I < Size;
++I60
) {
107
60
        typename T::value_type Item;
108
60
        if (auto EC = Mapper(*this, Item))
109
0
          return EC;
110
60
        Items.push_back(Item);
111
60
      }
112
51
    }
113
82
114
82
    return Error::success();
115
82
  }
TypeRecordMapping.cpp:llvm::Error llvm::codeview::CodeViewRecordIO::mapVectorN<unsigned short, llvm::SmallVector<llvm::codeview::TypeIndex, 4u>, llvm::codeview::TypeRecordMapping::visitKnownRecord(llvm::codeview::CVRecord<llvm::codeview::TypeLeafKind>&, llvm::codeview::BuildInfoRecord&)::$_3>(llvm::SmallVector<llvm::codeview::TypeIndex, 4u>&, llvm::codeview::TypeRecordMapping::visitKnownRecord(llvm::codeview::CVRecord<llvm::codeview::TypeLeafKind>&, llvm::codeview::BuildInfoRecord&)::$_3 const&)
Line
Count
Source
92
83
  Error mapVectorN(T &Items, const ElementMapper &Mapper) {
93
83
    SizeType Size;
94
83
    if (isWriting()) {
95
30
      Size = static_cast<SizeType>(Items.size());
96
30
      if (auto EC = Writer->writeInteger(Size))
97
0
        return EC;
98
30
99
146
      
for (auto &X : Items)30
{
100
146
        if (auto EC = Mapper(*this, X))
101
0
          return EC;
102
146
      }
103
53
    } else {
104
53
      if (auto EC = Reader->readInteger(Size))
105
0
        return EC;
106
318
      
for (SizeType I = 0; 53
I < Size;
++I265
) {
107
265
        typename T::value_type Item;
108
265
        if (auto EC = Mapper(*this, Item))
109
0
          return EC;
110
265
        Items.push_back(Item);
111
265
      }
112
53
    }
113
83
114
83
    return Error::success();
115
83
  }
116
117
  template <typename T, typename ElementMapper>
118
586
  Error mapVectorTail(T &Items, const ElementMapper &Mapper) {
119
586
    if (isWriting()) {
120
134
      for (auto &Item : Items) {
121
134
        if (auto EC = Mapper(*this, Item))
122
0
          return EC;
123
134
      }
124
521
    } else {
125
521
      typename T::value_type Field;
126
521
      // Stop when we run out of bytes or we hit record padding bytes.
127
1.32k
      while (!Reader->empty() && 
Reader->peek() < 0xf0817
/* LF_PAD0 */) {
128
806
        if (auto EC = Mapper(*this, Field))
129
0
          return EC;
130
806
        Items.push_back(Field);
131
806
      }
132
521
    }
133
586
    return Error::success();
134
586
  }
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
206
  Error mapVectorTail(T &Items, const ElementMapper &Mapper) {
119
206
    if (isWriting()) {
120
9
      for (auto &Item : Items) {
121
1
        if (auto EC = Mapper(*this, Item))
122
0
          return EC;
123
1
      }
124
197
    } else {
125
197
      typename T::value_type Field;
126
197
      // Stop when we run out of bytes or we hit record padding bytes.
127
203
      while (!Reader->empty() && 
Reader->peek() < 0xf06
/* LF_PAD0 */) {
128
6
        if (auto EC = Mapper(*this, Field))
129
0
          return EC;
130
6
        Items.push_back(Field);
131
6
      }
132
197
    }
133
206
    return Error::success();
134
206
  }
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
363
  Error mapVectorTail(T &Items, const ElementMapper &Mapper) {
119
363
    if (isWriting()) {
120
123
      for (auto &Item : Items) {
121
123
        if (auto EC = Mapper(*this, Item))
122
0
          return EC;
123
123
      }
124
313
    } else {
125
313
      typename T::value_type Field;
126
313
      // Stop when we run out of bytes or we hit record padding bytes.
127
1.08k
      while (!Reader->empty() && 
Reader->peek() < 0xf0772
/* LF_PAD0 */) {
128
772
        if (auto EC = Mapper(*this, Field))
129
0
          return EC;
130
772
        Items.push_back(Field);
131
772
      }
132
313
    }
133
363
    return Error::success();
134
363
  }
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
25.2k
    Optional<uint32_t> bytesRemaining(uint32_t CurrentOffset) const {
151
25.2k
      if (!MaxLength.hasValue())
152
6.58k
        return None;
153
18.7k
      assert(CurrentOffset >= BeginOffset);
154
18.7k
155
18.7k
      uint32_t BytesUsed = CurrentOffset - BeginOffset;
156
18.7k
      if (BytesUsed >= *MaxLength)
157
0
        return 0;
158
18.7k
      return *MaxLength - BytesUsed;
159
18.7k
    }
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