Coverage Report

Created: 2018-09-17 19:50

/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
51.2k
  uint32_t getCurrentOffset() const {
32
51.2k
    return (isWriting()) ? 
Writer->getOffset()22.2k
:
Reader->getOffset()29.0k
;
33
51.2k
  }
34
35
public:
36
12.9k
  explicit CodeViewRecordIO(BinaryStreamReader &Reader) : Reader(&Reader) {}
37
3.89k
  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
212k
  bool isReading() const { return Reader != nullptr; }
45
200k
  bool isWriting() const { return !isReading(); }
46
47
  uint32_t maxFieldLength() const;
48
49
577
  template <typename T> Error mapObject(T &Value) {
50
577
    if (isWriting())
51
30
      return Writer->writeObject(Value);
52
547
53
547
    const T *ValuePtr;
54
547
    if (auto EC = Reader->readObject(ValuePtr))
55
0
      return EC;
56
547
    Value = *ValuePtr;
57
547
    return Error::success();
58
547
  }
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
420
  template <typename T> Error mapObject(T &Value) {
50
420
    if (isWriting())
51
26
      return Writer->writeObject(Value);
52
394
53
394
    const T *ValuePtr;
54
394
    if (auto EC = Reader->readObject(ValuePtr))
55
0
      return EC;
56
394
    Value = *ValuePtr;
57
394
    return Error::success();
58
394
  }
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
150
  template <typename T> Error mapObject(T &Value) {
50
150
    if (isWriting())
51
4
      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.6k
  template <typename T> Error mapInteger(T &Value) {
61
44.6k
    if (isWriting())
62
14.0k
      return Writer->writeInteger(Value);
63
30.5k
64
30.5k
    return Reader->readInteger(Value);
65
30.5k
  }
llvm::Error llvm::codeview::CodeViewRecordIO::mapInteger<unsigned short>(unsigned short&)
Line
Count
Source
60
29.6k
  template <typename T> Error mapInteger(T &Value) {
61
29.6k
    if (isWriting())
62
9.80k
      return Writer->writeInteger(Value);
63
19.8k
64
19.8k
    return Reader->readInteger(Value);
65
19.8k
  }
llvm::Error llvm::codeview::CodeViewRecordIO::mapInteger<unsigned int>(unsigned int&)
Line
Count
Source
60
7.82k
  template <typename T> Error mapInteger(T &Value) {
61
7.82k
    if (isWriting())
62
2.55k
      return Writer->writeInteger(Value);
63
5.27k
64
5.27k
    return Reader->readInteger(Value);
65
5.27k
  }
llvm::Error llvm::codeview::CodeViewRecordIO::mapInteger<unsigned char>(unsigned char&)
Line
Count
Source
60
5.46k
  template <typename T> Error mapInteger(T &Value) {
61
5.46k
    if (isWriting())
62
1.44k
      return Writer->writeInteger(Value);
63
4.02k
64
4.02k
    return Reader->readInteger(Value);
65
4.02k
  }
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
9.09k
  template <typename T> Error mapEnum(T &Value) {
68
9.09k
    if (sizeof(Value) > maxFieldLength())
69
0
      return make_error<CodeViewError>(cv_error_code::insufficient_buffer);
70
9.09k
71
9.09k
    using U = typename std::underlying_type<T>::type;
72
9.09k
    U X;
73
9.09k
    if (isWriting())
74
1.87k
      X = static_cast<U>(Value);
75
9.09k
76
9.09k
    if (auto EC = mapInteger(X))
77
0
      return EC;
78
9.09k
    if (isReading())
79
7.21k
      Value = static_cast<T>(X);
80
9.09k
    return Error::success();
81
9.09k
  }
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
197
  template <typename T> Error mapEnum(T &Value) {
68
197
    if (sizeof(Value) > maxFieldLength())
69
0
      return make_error<CodeViewError>(cv_error_code::insufficient_buffer);
70
197
71
197
    using U = typename std::underlying_type<T>::type;
72
197
    U X;
73
197
    if (isWriting())
74
11
      X = static_cast<U>(Value);
75
197
76
197
    if (auto EC = mapInteger(X))
77
0
      return EC;
78
197
    if (isReading())
79
186
      Value = static_cast<T>(X);
80
197
    return Error::success();
81
197
  }
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
244
  template <typename T> Error mapEnum(T &Value) {
68
244
    if (sizeof(Value) > maxFieldLength())
69
0
      return make_error<CodeViewError>(cv_error_code::insufficient_buffer);
70
244
71
244
    using U = typename std::underlying_type<T>::type;
72
244
    U X;
73
244
    if (isWriting())
74
107
      X = static_cast<U>(Value);
75
244
76
244
    if (auto EC = mapInteger(X))
77
0
      return EC;
78
244
    if (isReading())
79
137
      Value = static_cast<T>(X);
80
244
    return Error::success();
81
244
  }
llvm::Error llvm::codeview::CodeViewRecordIO::mapEnum<llvm::codeview::CompileSym3Flags>(llvm::codeview::CompileSym3Flags&)
Line
Count
Source
67
244
  template <typename T> Error mapEnum(T &Value) {
68
244
    if (sizeof(Value) > maxFieldLength())
69
0
      return make_error<CodeViewError>(cv_error_code::insufficient_buffer);
70
244
71
244
    using U = typename std::underlying_type<T>::type;
72
244
    U X;
73
244
    if (isWriting())
74
107
      X = static_cast<U>(Value);
75
244
76
244
    if (auto EC = mapInteger(X))
77
0
      return EC;
78
244
    if (isReading())
79
137
      Value = static_cast<T>(X);
80
244
    return Error::success();
81
244
  }
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
116
  template <typename T> Error mapEnum(T &Value) {
68
116
    if (sizeof(Value) > maxFieldLength())
69
0
      return make_error<CodeViewError>(cv_error_code::insufficient_buffer);
70
116
71
116
    using U = typename std::underlying_type<T>::type;
72
116
    U X;
73
116
    if (isWriting())
74
45
      X = static_cast<U>(Value);
75
116
76
116
    if (auto EC = mapInteger(X))
77
0
      return EC;
78
116
    if (isReading())
79
71
      Value = static_cast<T>(X);
80
116
    return Error::success();
81
116
  }
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
419
  template <typename T> Error mapEnum(T &Value) {
68
419
    if (sizeof(Value) > maxFieldLength())
69
0
      return make_error<CodeViewError>(cv_error_code::insufficient_buffer);
70
419
71
419
    using U = typename std::underlying_type<T>::type;
72
419
    U X;
73
419
    if (isWriting())
74
205
      X = static_cast<U>(Value);
75
419
76
419
    if (auto EC = mapInteger(X))
77
0
      return EC;
78
419
    if (isReading())
79
214
      Value = static_cast<T>(X);
80
419
    return Error::success();
81
419
  }
llvm::Error llvm::codeview::CodeViewRecordIO::mapEnum<llvm::codeview::ProcSymFlags>(llvm::codeview::ProcSymFlags&)
Line
Count
Source
67
255
  template <typename T> Error mapEnum(T &Value) {
68
255
    if (sizeof(Value) > maxFieldLength())
69
0
      return make_error<CodeViewError>(cv_error_code::insufficient_buffer);
70
255
71
255
    using U = typename std::underlying_type<T>::type;
72
255
    U X;
73
255
    if (isWriting())
74
49
      X = static_cast<U>(Value);
75
255
76
255
    if (auto EC = mapInteger(X))
77
0
      return EC;
78
255
    if (isReading())
79
206
      Value = static_cast<T>(X);
80
255
    return Error::success();
81
255
  }
llvm::Error llvm::codeview::CodeViewRecordIO::mapEnum<llvm::codeview::ModifierOptions>(llvm::codeview::ModifierOptions&)
Line
Count
Source
67
261
  template <typename T> Error mapEnum(T &Value) {
68
261
    if (sizeof(Value) > maxFieldLength())
69
0
      return make_error<CodeViewError>(cv_error_code::insufficient_buffer);
70
261
71
261
    using U = typename std::underlying_type<T>::type;
72
261
    U X;
73
261
    if (isWriting())
74
47
      X = static_cast<U>(Value);
75
261
76
261
    if (auto EC = mapInteger(X))
77
0
      return EC;
78
261
    if (isReading())
79
214
      Value = static_cast<T>(X);
80
261
    return Error::success();
81
261
  }
llvm::Error llvm::codeview::CodeViewRecordIO::mapEnum<llvm::codeview::CallingConvention>(llvm::codeview::CallingConvention&)
Line
Count
Source
67
2.23k
  template <typename T> Error mapEnum(T &Value) {
68
2.23k
    if (sizeof(Value) > maxFieldLength())
69
0
      return make_error<CodeViewError>(cv_error_code::insufficient_buffer);
70
2.23k
71
2.23k
    using U = typename std::underlying_type<T>::type;
72
2.23k
    U X;
73
2.23k
    if (isWriting())
74
439
      X = static_cast<U>(Value);
75
2.23k
76
2.23k
    if (auto EC = mapInteger(X))
77
0
      return EC;
78
2.23k
    if (isReading())
79
1.79k
      Value = static_cast<T>(X);
80
2.23k
    return Error::success();
81
2.23k
  }
llvm::Error llvm::codeview::CodeViewRecordIO::mapEnum<llvm::codeview::FunctionOptions>(llvm::codeview::FunctionOptions&)
Line
Count
Source
67
2.23k
  template <typename T> Error mapEnum(T &Value) {
68
2.23k
    if (sizeof(Value) > maxFieldLength())
69
0
      return make_error<CodeViewError>(cv_error_code::insufficient_buffer);
70
2.23k
71
2.23k
    using U = typename std::underlying_type<T>::type;
72
2.23k
    U X;
73
2.23k
    if (isWriting())
74
439
      X = static_cast<U>(Value);
75
2.23k
76
2.23k
    if (auto EC = mapInteger(X))
77
0
      return EC;
78
2.23k
    if (isReading())
79
1.79k
      Value = static_cast<T>(X);
80
2.23k
    return Error::success();
81
2.23k
  }
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.77k
  template <typename T> Error mapEnum(T &Value) {
68
2.77k
    if (sizeof(Value) > maxFieldLength())
69
0
      return make_error<CodeViewError>(cv_error_code::insufficient_buffer);
70
2.77k
71
2.77k
    using U = typename std::underlying_type<T>::type;
72
2.77k
    U X;
73
2.77k
    if (isWriting())
74
383
      X = static_cast<U>(Value);
75
2.77k
76
2.77k
    if (auto EC = mapInteger(X))
77
0
      return EC;
78
2.77k
    if (isReading())
79
2.39k
      Value = static_cast<T>(X);
80
2.77k
    return Error::success();
81
2.77k
  }
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.35k
  Error mapVectorN(T &Items, const ElementMapper &Mapper) {
93
1.35k
    SizeType Size;
94
1.35k
    if (isWriting()) {
95
444
      Size = static_cast<SizeType>(Items.size());
96
444
      if (auto EC = Writer->writeInteger(Size))
97
0
        return EC;
98
444
99
547
      
for (auto &X : Items)444
{
100
547
        if (auto EC = Mapper(*this, X))
101
0
          return EC;
102
547
      }
103
911
    } else {
104
911
      if (auto EC = Reader->readInteger(Size))
105
0
        return EC;
106
2.48k
      
for (SizeType I = 0; 911
I < Size;
++I1.57k
) {
107
1.57k
        typename T::value_type Item;
108
1.57k
        if (auto EC = Mapper(*this, Item))
109
0
          return EC;
110
1.57k
        Items.push_back(Item);
111
1.57k
      }
112
911
    }
113
1.35k
114
1.35k
    return Error::success();
115
1.35k
  }
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.17k
  Error mapVectorN(T &Items, const ElementMapper &Mapper) {
93
1.17k
    SizeType Size;
94
1.17k
    if (isWriting()) {
95
376
      Size = static_cast<SizeType>(Items.size());
96
376
      if (auto EC = Writer->writeInteger(Size))
97
0
        return EC;
98
376
99
376
      for (auto &X : Items) {
100
348
        if (auto EC = Mapper(*this, X))
101
0
          return EC;
102
348
      }
103
799
    } else {
104
799
      if (auto EC = Reader->readInteger(Size))
105
0
        return EC;
106
2.04k
      
for (SizeType I = 0; 799
I < Size;
++I1.24k
) {
107
1.24k
        typename T::value_type Item;
108
1.24k
        if (auto EC = Mapper(*this, Item))
109
0
          return EC;
110
1.24k
        Items.push_back(Item);
111
1.24k
      }
112
799
    }
113
1.17k
114
1.17k
    return Error::success();
115
1.17k
  }
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
591
  Error mapVectorTail(T &Items, const ElementMapper &Mapper) {
119
591
    if (isWriting()) {
120
134
      for (auto &Item : Items) {
121
134
        if (auto EC = Mapper(*this, Item))
122
0
          return EC;
123
134
      }
124
522
    } else {
125
522
      typename T::value_type Field;
126
522
      // Stop when we run out of bytes or we hit record padding bytes.
127
1.32k
      while (!Reader->empty() && 
Reader->peek() < 0xf0816
/* LF_PAD0 */) {
128
805
        if (auto EC = Mapper(*this, Field))
129
0
          return EC;
130
805
        Items.push_back(Field);
131
805
      }
132
522
    }
133
591
    return Error::success();
134
591
  }
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
211
  Error mapVectorTail(T &Items, const ElementMapper &Mapper) {
119
211
    if (isWriting()) {
120
13
      for (auto &Item : Items) {
121
1
        if (auto EC = Mapper(*this, Item))
122
0
          return EC;
123
1
      }
124
198
    } else {
125
198
      typename T::value_type Field;
126
198
      // Stop when we run out of bytes or we hit record padding bytes.
127
203
      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
198
    }
133
211
    return Error::success();
134
211
  }
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.5k
    Optional<uint32_t> bytesRemaining(uint32_t CurrentOffset) const {
151
25.5k
      if (!MaxLength.hasValue())
152
6.58k
        return None;
153
18.9k
      assert(CurrentOffset >= BeginOffset);
154
18.9k
155
18.9k
      uint32_t BytesUsed = CurrentOffset - BeginOffset;
156
18.9k
      if (BytesUsed >= *MaxLength)
157
0
        return 0;
158
18.9k
      return *MaxLength - BytesUsed;
159
18.9k
    }
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