Coverage Report

Created: 2018-07-19 03:59

/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/include/llvm/DebugInfo/CodeView/TypeDeserializer.h
Line
Count
Source (jump to first uncovered line)
1
//===- TypeDeserializer.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_TYPEDESERIALIZER_H
11
#define LLVM_DEBUGINFO_CODEVIEW_TYPEDESERIALIZER_H
12
13
#include "llvm/ADT/ArrayRef.h"
14
#include "llvm/ADT/STLExtras.h"
15
#include "llvm/DebugInfo/CodeView/CodeView.h"
16
#include "llvm/DebugInfo/CodeView/TypeRecord.h"
17
#include "llvm/DebugInfo/CodeView/TypeRecordMapping.h"
18
#include "llvm/DebugInfo/CodeView/TypeVisitorCallbacks.h"
19
#include "llvm/Support/BinaryByteStream.h"
20
#include "llvm/Support/BinaryStreamReader.h"
21
#include "llvm/Support/Error.h"
22
#include <cassert>
23
#include <cstdint>
24
#include <memory>
25
26
namespace llvm {
27
namespace codeview {
28
29
class TypeDeserializer : public TypeVisitorCallbacks {
30
  struct MappingInfo {
31
    explicit MappingInfo(ArrayRef<uint8_t> RecordData)
32
        : Stream(RecordData, llvm::support::little), Reader(Stream),
33
9.76k
          Mapping(Reader) {}
34
35
    BinaryByteStream Stream;
36
    BinaryStreamReader Reader;
37
    TypeRecordMapping Mapping;
38
  };
39
40
public:
41
3.71k
  TypeDeserializer() = default;
42
43
  template <typename T> static Error deserializeAs(CVType &CVT, T &Record) {
44
    Record.Kind = static_cast<TypeRecordKind>(CVT.kind());
45
    MappingInfo I(CVT.content());
46
    if (auto EC = I.Mapping.visitTypeBegin(CVT))
47
      return EC;
48
    if (auto EC = I.Mapping.visitKnownRecord(CVT, Record))
49
      return EC;
50
    if (auto EC = I.Mapping.visitTypeEnd(CVT))
51
      return EC;
52
    return Error::success();
53
  }
54
55
  template <typename T>
56
  static Expected<T> deserializeAs(ArrayRef<uint8_t> Data) {
57
    const RecordPrefix *Prefix =
58
        reinterpret_cast<const RecordPrefix *>(Data.data());
59
    TypeRecordKind K =
60
        static_cast<TypeRecordKind>(uint16_t(Prefix->RecordKind));
61
    T Record(K);
62
    CVType CVT(static_cast<TypeLeafKind>(K), Data);
63
    if (auto EC = deserializeAs<T>(CVT, Record))
64
      return std::move(EC);
65
    return Record;
66
  }
67
68
8.14k
  Error visitTypeBegin(CVType &Record) override {
69
8.14k
    assert(!Mapping && "Already in a type mapping!");
70
8.14k
    Mapping = llvm::make_unique<MappingInfo>(Record.content());
71
8.14k
    return Mapping->Mapping.visitTypeBegin(Record);
72
8.14k
  }
73
74
8.12k
  Error visitTypeBegin(CVType &Record, TypeIndex Index) override {
75
8.12k
    return visitTypeBegin(Record);
76
8.12k
  }
77
78
8.14k
  Error visitTypeEnd(CVType &Record) override {
79
8.14k
    assert(Mapping && "Not in a type mapping!");
80
8.14k
    auto EC = Mapping->Mapping.visitTypeEnd(Record);
81
8.14k
    Mapping.reset();
82
8.14k
    return EC;
83
8.14k
  }
84
85
#define TYPE_RECORD(EnumName, EnumVal, Name)                                   \
86
8.14k
  Error visitKnownRecord(CVType &CVR, Name##Record &Record) override {         \
87
8.14k
    return visitKnownRecordImpl<Name##Record>(CVR, Record);                    \
88
8.14k
  }
llvm::codeview::TypeDeserializer::visitKnownRecord(llvm::codeview::CVRecord<llvm::codeview::TypeLeafKind>&, llvm::codeview::PointerRecord&)
Line
Count
Source
86
1.02k
  Error visitKnownRecord(CVType &CVR, Name##Record &Record) override {         \
87
1.02k
    return visitKnownRecordImpl<Name##Record>(CVR, Record);                    \
88
1.02k
  }
llvm::codeview::TypeDeserializer::visitKnownRecord(llvm::codeview::CVRecord<llvm::codeview::TypeLeafKind>&, llvm::codeview::ModifierRecord&)
Line
Count
Source
86
181
  Error visitKnownRecord(CVType &CVR, Name##Record &Record) override {         \
87
181
    return visitKnownRecordImpl<Name##Record>(CVR, Record);                    \
88
181
  }
llvm::codeview::TypeDeserializer::visitKnownRecord(llvm::codeview::CVRecord<llvm::codeview::TypeLeafKind>&, llvm::codeview::ProcedureRecord&)
Line
Count
Source
86
402
  Error visitKnownRecord(CVType &CVR, Name##Record &Record) override {         \
87
402
    return visitKnownRecordImpl<Name##Record>(CVR, Record);                    \
88
402
  }
llvm::codeview::TypeDeserializer::visitKnownRecord(llvm::codeview::CVRecord<llvm::codeview::TypeLeafKind>&, llvm::codeview::MemberFunctionRecord&)
Line
Count
Source
86
1.07k
  Error visitKnownRecord(CVType &CVR, Name##Record &Record) override {         \
87
1.07k
    return visitKnownRecordImpl<Name##Record>(CVR, Record);                    \
88
1.07k
  }
llvm::codeview::TypeDeserializer::visitKnownRecord(llvm::codeview::CVRecord<llvm::codeview::TypeLeafKind>&, llvm::codeview::LabelRecord&)
Line
Count
Source
86
1
  Error visitKnownRecord(CVType &CVR, Name##Record &Record) override {         \
87
1
    return visitKnownRecordImpl<Name##Record>(CVR, Record);                    \
88
1
  }
llvm::codeview::TypeDeserializer::visitKnownRecord(llvm::codeview::CVRecord<llvm::codeview::TypeLeafKind>&, llvm::codeview::ArgListRecord&)
Line
Count
Source
86
683
  Error visitKnownRecord(CVType &CVR, Name##Record &Record) override {         \
87
683
    return visitKnownRecordImpl<Name##Record>(CVR, Record);                    \
88
683
  }
llvm::codeview::TypeDeserializer::visitKnownRecord(llvm::codeview::CVRecord<llvm::codeview::TypeLeafKind>&, llvm::codeview::FieldListRecord&)
Line
Count
Source
86
959
  Error visitKnownRecord(CVType &CVR, Name##Record &Record) override {         \
87
959
    return visitKnownRecordImpl<Name##Record>(CVR, Record);                    \
88
959
  }
llvm::codeview::TypeDeserializer::visitKnownRecord(llvm::codeview::CVRecord<llvm::codeview::TypeLeafKind>&, llvm::codeview::ArrayRecord&)
Line
Count
Source
86
82
  Error visitKnownRecord(CVType &CVR, Name##Record &Record) override {         \
87
82
    return visitKnownRecordImpl<Name##Record>(CVR, Record);                    \
88
82
  }
llvm::codeview::TypeDeserializer::visitKnownRecord(llvm::codeview::CVRecord<llvm::codeview::TypeLeafKind>&, llvm::codeview::ClassRecord&)
Line
Count
Source
86
1.57k
  Error visitKnownRecord(CVType &CVR, Name##Record &Record) override {         \
87
1.57k
    return visitKnownRecordImpl<Name##Record>(CVR, Record);                    \
88
1.57k
  }
llvm::codeview::TypeDeserializer::visitKnownRecord(llvm::codeview::CVRecord<llvm::codeview::TypeLeafKind>&, llvm::codeview::UnionRecord&)
Line
Count
Source
86
24
  Error visitKnownRecord(CVType &CVR, Name##Record &Record) override {         \
87
24
    return visitKnownRecordImpl<Name##Record>(CVR, Record);                    \
88
24
  }
llvm::codeview::TypeDeserializer::visitKnownRecord(llvm::codeview::CVRecord<llvm::codeview::TypeLeafKind>&, llvm::codeview::EnumRecord&)
Line
Count
Source
86
204
  Error visitKnownRecord(CVType &CVR, Name##Record &Record) override {         \
87
204
    return visitKnownRecordImpl<Name##Record>(CVR, Record);                    \
88
204
  }
Unexecuted instantiation: llvm::codeview::TypeDeserializer::visitKnownRecord(llvm::codeview::CVRecord<llvm::codeview::TypeLeafKind>&, llvm::codeview::TypeServer2Record&)
llvm::codeview::TypeDeserializer::visitKnownRecord(llvm::codeview::CVRecord<llvm::codeview::TypeLeafKind>&, llvm::codeview::VFTableRecord&)
Line
Count
Source
86
11
  Error visitKnownRecord(CVType &CVR, Name##Record &Record) override {         \
87
11
    return visitKnownRecordImpl<Name##Record>(CVR, Record);                    \
88
11
  }
llvm::codeview::TypeDeserializer::visitKnownRecord(llvm::codeview::CVRecord<llvm::codeview::TypeLeafKind>&, llvm::codeview::VFTableShapeRecord&)
Line
Count
Source
86
38
  Error visitKnownRecord(CVType &CVR, Name##Record &Record) override {         \
87
38
    return visitKnownRecordImpl<Name##Record>(CVR, Record);                    \
88
38
  }
llvm::codeview::TypeDeserializer::visitKnownRecord(llvm::codeview::CVRecord<llvm::codeview::TypeLeafKind>&, llvm::codeview::BitFieldRecord&)
Line
Count
Source
86
18
  Error visitKnownRecord(CVType &CVR, Name##Record &Record) override {         \
87
18
    return visitKnownRecordImpl<Name##Record>(CVR, Record);                    \
88
18
  }
llvm::codeview::TypeDeserializer::visitKnownRecord(llvm::codeview::CVRecord<llvm::codeview::TypeLeafKind>&, llvm::codeview::FuncIdRecord&)
Line
Count
Source
86
422
  Error visitKnownRecord(CVType &CVR, Name##Record &Record) override {         \
87
422
    return visitKnownRecordImpl<Name##Record>(CVR, Record);                    \
88
422
  }
llvm::codeview::TypeDeserializer::visitKnownRecord(llvm::codeview::CVRecord<llvm::codeview::TypeLeafKind>&, llvm::codeview::MemberFuncIdRecord&)
Line
Count
Source
86
106
  Error visitKnownRecord(CVType &CVR, Name##Record &Record) override {         \
87
106
    return visitKnownRecordImpl<Name##Record>(CVR, Record);                    \
88
106
  }
llvm::codeview::TypeDeserializer::visitKnownRecord(llvm::codeview::CVRecord<llvm::codeview::TypeLeafKind>&, llvm::codeview::BuildInfoRecord&)
Line
Count
Source
86
48
  Error visitKnownRecord(CVType &CVR, Name##Record &Record) override {         \
87
48
    return visitKnownRecordImpl<Name##Record>(CVR, Record);                    \
88
48
  }
llvm::codeview::TypeDeserializer::visitKnownRecord(llvm::codeview::CVRecord<llvm::codeview::TypeLeafKind>&, llvm::codeview::StringListRecord&)
Line
Count
Source
86
47
  Error visitKnownRecord(CVType &CVR, Name##Record &Record) override {         \
87
47
    return visitKnownRecordImpl<Name##Record>(CVR, Record);                    \
88
47
  }
llvm::codeview::TypeDeserializer::visitKnownRecord(llvm::codeview::CVRecord<llvm::codeview::TypeLeafKind>&, llvm::codeview::StringIdRecord&)
Line
Count
Source
86
471
  Error visitKnownRecord(CVType &CVR, Name##Record &Record) override {         \
87
471
    return visitKnownRecordImpl<Name##Record>(CVR, Record);                    \
88
471
  }
llvm::codeview::TypeDeserializer::visitKnownRecord(llvm::codeview::CVRecord<llvm::codeview::TypeLeafKind>&, llvm::codeview::UdtSourceLineRecord&)
Line
Count
Source
86
524
  Error visitKnownRecord(CVType &CVR, Name##Record &Record) override {         \
87
524
    return visitKnownRecordImpl<Name##Record>(CVR, Record);                    \
88
524
  }
llvm::codeview::TypeDeserializer::visitKnownRecord(llvm::codeview::CVRecord<llvm::codeview::TypeLeafKind>&, llvm::codeview::UdtModSourceLineRecord&)
Line
Count
Source
86
8
  Error visitKnownRecord(CVType &CVR, Name##Record &Record) override {         \
87
8
    return visitKnownRecordImpl<Name##Record>(CVR, Record);                    \
88
8
  }
llvm::codeview::TypeDeserializer::visitKnownRecord(llvm::codeview::CVRecord<llvm::codeview::TypeLeafKind>&, llvm::codeview::MethodOverloadListRecord&)
Line
Count
Source
86
239
  Error visitKnownRecord(CVType &CVR, Name##Record &Record) override {         \
87
239
    return visitKnownRecordImpl<Name##Record>(CVR, Record);                    \
88
239
  }
llvm::codeview::TypeDeserializer::visitKnownRecord(llvm::codeview::CVRecord<llvm::codeview::TypeLeafKind>&, llvm::codeview::PrecompRecord&)
Line
Count
Source
86
2
  Error visitKnownRecord(CVType &CVR, Name##Record &Record) override {         \
87
2
    return visitKnownRecordImpl<Name##Record>(CVR, Record);                    \
88
2
  }
llvm::codeview::TypeDeserializer::visitKnownRecord(llvm::codeview::CVRecord<llvm::codeview::TypeLeafKind>&, llvm::codeview::EndPrecompRecord&)
Line
Count
Source
86
2
  Error visitKnownRecord(CVType &CVR, Name##Record &Record) override {         \
87
2
    return visitKnownRecordImpl<Name##Record>(CVR, Record);                    \
88
2
  }
89
#define MEMBER_RECORD(EnumName, EnumVal, Name)
90
#define TYPE_RECORD_ALIAS(EnumName, EnumVal, Name, AliasName)
91
#define MEMBER_RECORD_ALIAS(EnumName, EnumVal, Name, AliasName)
92
#include "llvm/DebugInfo/CodeView/CodeViewTypes.def"
93
94
private:
95
  template <typename RecordType>
96
8.14k
  Error visitKnownRecordImpl(CVType &CVR, RecordType &Record) {
97
8.14k
    return Mapping->Mapping.visitKnownRecord(CVR, Record);
98
8.14k
  }
llvm::Error llvm::codeview::TypeDeserializer::visitKnownRecordImpl<llvm::codeview::PointerRecord>(llvm::codeview::CVRecord<llvm::codeview::TypeLeafKind>&, llvm::codeview::PointerRecord&)
Line
Count
Source
96
1.02k
  Error visitKnownRecordImpl(CVType &CVR, RecordType &Record) {
97
1.02k
    return Mapping->Mapping.visitKnownRecord(CVR, Record);
98
1.02k
  }
llvm::Error llvm::codeview::TypeDeserializer::visitKnownRecordImpl<llvm::codeview::ModifierRecord>(llvm::codeview::CVRecord<llvm::codeview::TypeLeafKind>&, llvm::codeview::ModifierRecord&)
Line
Count
Source
96
181
  Error visitKnownRecordImpl(CVType &CVR, RecordType &Record) {
97
181
    return Mapping->Mapping.visitKnownRecord(CVR, Record);
98
181
  }
llvm::Error llvm::codeview::TypeDeserializer::visitKnownRecordImpl<llvm::codeview::ProcedureRecord>(llvm::codeview::CVRecord<llvm::codeview::TypeLeafKind>&, llvm::codeview::ProcedureRecord&)
Line
Count
Source
96
402
  Error visitKnownRecordImpl(CVType &CVR, RecordType &Record) {
97
402
    return Mapping->Mapping.visitKnownRecord(CVR, Record);
98
402
  }
llvm::Error llvm::codeview::TypeDeserializer::visitKnownRecordImpl<llvm::codeview::MemberFunctionRecord>(llvm::codeview::CVRecord<llvm::codeview::TypeLeafKind>&, llvm::codeview::MemberFunctionRecord&)
Line
Count
Source
96
1.07k
  Error visitKnownRecordImpl(CVType &CVR, RecordType &Record) {
97
1.07k
    return Mapping->Mapping.visitKnownRecord(CVR, Record);
98
1.07k
  }
llvm::Error llvm::codeview::TypeDeserializer::visitKnownRecordImpl<llvm::codeview::LabelRecord>(llvm::codeview::CVRecord<llvm::codeview::TypeLeafKind>&, llvm::codeview::LabelRecord&)
Line
Count
Source
96
1
  Error visitKnownRecordImpl(CVType &CVR, RecordType &Record) {
97
1
    return Mapping->Mapping.visitKnownRecord(CVR, Record);
98
1
  }
llvm::Error llvm::codeview::TypeDeserializer::visitKnownRecordImpl<llvm::codeview::ArgListRecord>(llvm::codeview::CVRecord<llvm::codeview::TypeLeafKind>&, llvm::codeview::ArgListRecord&)
Line
Count
Source
96
683
  Error visitKnownRecordImpl(CVType &CVR, RecordType &Record) {
97
683
    return Mapping->Mapping.visitKnownRecord(CVR, Record);
98
683
  }
llvm::Error llvm::codeview::TypeDeserializer::visitKnownRecordImpl<llvm::codeview::FieldListRecord>(llvm::codeview::CVRecord<llvm::codeview::TypeLeafKind>&, llvm::codeview::FieldListRecord&)
Line
Count
Source
96
959
  Error visitKnownRecordImpl(CVType &CVR, RecordType &Record) {
97
959
    return Mapping->Mapping.visitKnownRecord(CVR, Record);
98
959
  }
llvm::Error llvm::codeview::TypeDeserializer::visitKnownRecordImpl<llvm::codeview::ArrayRecord>(llvm::codeview::CVRecord<llvm::codeview::TypeLeafKind>&, llvm::codeview::ArrayRecord&)
Line
Count
Source
96
82
  Error visitKnownRecordImpl(CVType &CVR, RecordType &Record) {
97
82
    return Mapping->Mapping.visitKnownRecord(CVR, Record);
98
82
  }
llvm::Error llvm::codeview::TypeDeserializer::visitKnownRecordImpl<llvm::codeview::ClassRecord>(llvm::codeview::CVRecord<llvm::codeview::TypeLeafKind>&, llvm::codeview::ClassRecord&)
Line
Count
Source
96
1.57k
  Error visitKnownRecordImpl(CVType &CVR, RecordType &Record) {
97
1.57k
    return Mapping->Mapping.visitKnownRecord(CVR, Record);
98
1.57k
  }
llvm::Error llvm::codeview::TypeDeserializer::visitKnownRecordImpl<llvm::codeview::UnionRecord>(llvm::codeview::CVRecord<llvm::codeview::TypeLeafKind>&, llvm::codeview::UnionRecord&)
Line
Count
Source
96
24
  Error visitKnownRecordImpl(CVType &CVR, RecordType &Record) {
97
24
    return Mapping->Mapping.visitKnownRecord(CVR, Record);
98
24
  }
llvm::Error llvm::codeview::TypeDeserializer::visitKnownRecordImpl<llvm::codeview::EnumRecord>(llvm::codeview::CVRecord<llvm::codeview::TypeLeafKind>&, llvm::codeview::EnumRecord&)
Line
Count
Source
96
204
  Error visitKnownRecordImpl(CVType &CVR, RecordType &Record) {
97
204
    return Mapping->Mapping.visitKnownRecord(CVR, Record);
98
204
  }
Unexecuted instantiation: llvm::Error llvm::codeview::TypeDeserializer::visitKnownRecordImpl<llvm::codeview::TypeServer2Record>(llvm::codeview::CVRecord<llvm::codeview::TypeLeafKind>&, llvm::codeview::TypeServer2Record&)
llvm::Error llvm::codeview::TypeDeserializer::visitKnownRecordImpl<llvm::codeview::VFTableRecord>(llvm::codeview::CVRecord<llvm::codeview::TypeLeafKind>&, llvm::codeview::VFTableRecord&)
Line
Count
Source
96
11
  Error visitKnownRecordImpl(CVType &CVR, RecordType &Record) {
97
11
    return Mapping->Mapping.visitKnownRecord(CVR, Record);
98
11
  }
llvm::Error llvm::codeview::TypeDeserializer::visitKnownRecordImpl<llvm::codeview::VFTableShapeRecord>(llvm::codeview::CVRecord<llvm::codeview::TypeLeafKind>&, llvm::codeview::VFTableShapeRecord&)
Line
Count
Source
96
38
  Error visitKnownRecordImpl(CVType &CVR, RecordType &Record) {
97
38
    return Mapping->Mapping.visitKnownRecord(CVR, Record);
98
38
  }
llvm::Error llvm::codeview::TypeDeserializer::visitKnownRecordImpl<llvm::codeview::BitFieldRecord>(llvm::codeview::CVRecord<llvm::codeview::TypeLeafKind>&, llvm::codeview::BitFieldRecord&)
Line
Count
Source
96
18
  Error visitKnownRecordImpl(CVType &CVR, RecordType &Record) {
97
18
    return Mapping->Mapping.visitKnownRecord(CVR, Record);
98
18
  }
llvm::Error llvm::codeview::TypeDeserializer::visitKnownRecordImpl<llvm::codeview::FuncIdRecord>(llvm::codeview::CVRecord<llvm::codeview::TypeLeafKind>&, llvm::codeview::FuncIdRecord&)
Line
Count
Source
96
422
  Error visitKnownRecordImpl(CVType &CVR, RecordType &Record) {
97
422
    return Mapping->Mapping.visitKnownRecord(CVR, Record);
98
422
  }
llvm::Error llvm::codeview::TypeDeserializer::visitKnownRecordImpl<llvm::codeview::MemberFuncIdRecord>(llvm::codeview::CVRecord<llvm::codeview::TypeLeafKind>&, llvm::codeview::MemberFuncIdRecord&)
Line
Count
Source
96
106
  Error visitKnownRecordImpl(CVType &CVR, RecordType &Record) {
97
106
    return Mapping->Mapping.visitKnownRecord(CVR, Record);
98
106
  }
llvm::Error llvm::codeview::TypeDeserializer::visitKnownRecordImpl<llvm::codeview::BuildInfoRecord>(llvm::codeview::CVRecord<llvm::codeview::TypeLeafKind>&, llvm::codeview::BuildInfoRecord&)
Line
Count
Source
96
48
  Error visitKnownRecordImpl(CVType &CVR, RecordType &Record) {
97
48
    return Mapping->Mapping.visitKnownRecord(CVR, Record);
98
48
  }
llvm::Error llvm::codeview::TypeDeserializer::visitKnownRecordImpl<llvm::codeview::StringListRecord>(llvm::codeview::CVRecord<llvm::codeview::TypeLeafKind>&, llvm::codeview::StringListRecord&)
Line
Count
Source
96
47
  Error visitKnownRecordImpl(CVType &CVR, RecordType &Record) {
97
47
    return Mapping->Mapping.visitKnownRecord(CVR, Record);
98
47
  }
llvm::Error llvm::codeview::TypeDeserializer::visitKnownRecordImpl<llvm::codeview::StringIdRecord>(llvm::codeview::CVRecord<llvm::codeview::TypeLeafKind>&, llvm::codeview::StringIdRecord&)
Line
Count
Source
96
471
  Error visitKnownRecordImpl(CVType &CVR, RecordType &Record) {
97
471
    return Mapping->Mapping.visitKnownRecord(CVR, Record);
98
471
  }
llvm::Error llvm::codeview::TypeDeserializer::visitKnownRecordImpl<llvm::codeview::UdtSourceLineRecord>(llvm::codeview::CVRecord<llvm::codeview::TypeLeafKind>&, llvm::codeview::UdtSourceLineRecord&)
Line
Count
Source
96
524
  Error visitKnownRecordImpl(CVType &CVR, RecordType &Record) {
97
524
    return Mapping->Mapping.visitKnownRecord(CVR, Record);
98
524
  }
llvm::Error llvm::codeview::TypeDeserializer::visitKnownRecordImpl<llvm::codeview::UdtModSourceLineRecord>(llvm::codeview::CVRecord<llvm::codeview::TypeLeafKind>&, llvm::codeview::UdtModSourceLineRecord&)
Line
Count
Source
96
8
  Error visitKnownRecordImpl(CVType &CVR, RecordType &Record) {
97
8
    return Mapping->Mapping.visitKnownRecord(CVR, Record);
98
8
  }
llvm::Error llvm::codeview::TypeDeserializer::visitKnownRecordImpl<llvm::codeview::MethodOverloadListRecord>(llvm::codeview::CVRecord<llvm::codeview::TypeLeafKind>&, llvm::codeview::MethodOverloadListRecord&)
Line
Count
Source
96
239
  Error visitKnownRecordImpl(CVType &CVR, RecordType &Record) {
97
239
    return Mapping->Mapping.visitKnownRecord(CVR, Record);
98
239
  }
llvm::Error llvm::codeview::TypeDeserializer::visitKnownRecordImpl<llvm::codeview::PrecompRecord>(llvm::codeview::CVRecord<llvm::codeview::TypeLeafKind>&, llvm::codeview::PrecompRecord&)
Line
Count
Source
96
2
  Error visitKnownRecordImpl(CVType &CVR, RecordType &Record) {
97
2
    return Mapping->Mapping.visitKnownRecord(CVR, Record);
98
2
  }
llvm::Error llvm::codeview::TypeDeserializer::visitKnownRecordImpl<llvm::codeview::EndPrecompRecord>(llvm::codeview::CVRecord<llvm::codeview::TypeLeafKind>&, llvm::codeview::EndPrecompRecord&)
Line
Count
Source
96
2
  Error visitKnownRecordImpl(CVType &CVR, RecordType &Record) {
97
2
    return Mapping->Mapping.visitKnownRecord(CVR, Record);
98
2
  }
99
100
  std::unique_ptr<MappingInfo> Mapping;
101
};
102
103
class FieldListDeserializer : public TypeVisitorCallbacks {
104
  struct MappingInfo {
105
    explicit MappingInfo(BinaryStreamReader &R)
106
826
        : Reader(R), Mapping(Reader), StartOffset(0) {}
107
108
    BinaryStreamReader &Reader;
109
    TypeRecordMapping Mapping;
110
    uint32_t StartOffset;
111
  };
112
113
public:
114
826
  explicit FieldListDeserializer(BinaryStreamReader &Reader) : Mapping(Reader) {
115
826
    CVType FieldList;
116
826
    FieldList.Type = TypeLeafKind::LF_FIELDLIST;
117
826
    consumeError(Mapping.Mapping.visitTypeBegin(FieldList));
118
826
  }
119
120
826
  ~FieldListDeserializer() override {
121
826
    CVType FieldList;
122
826
    FieldList.Type = TypeLeafKind::LF_FIELDLIST;
123
826
    consumeError(Mapping.Mapping.visitTypeEnd(FieldList));
124
826
  }
125
126
8.84k
  Error visitMemberBegin(CVMemberRecord &Record) override {
127
8.84k
    Mapping.StartOffset = Mapping.Reader.getOffset();
128
8.84k
    return Mapping.Mapping.visitMemberBegin(Record);
129
8.84k
  }
130
131
8.84k
  Error visitMemberEnd(CVMemberRecord &Record) override {
132
8.84k
    if (auto EC = Mapping.Mapping.visitMemberEnd(Record))
133
0
      return EC;
134
8.84k
    return Error::success();
135
8.84k
  }
136
137
#define TYPE_RECORD(EnumName, EnumVal, Name)
138
#define MEMBER_RECORD(EnumName, EnumVal, Name)                                 \
139
8.84k
  Error visitKnownMember(CVMemberRecord &CVR, Name##Record &Record) override { \
140
8.84k
    return visitKnownMemberImpl<Name##Record>(CVR, Record);                    \
141
8.84k
  }
llvm::codeview::FieldListDeserializer::visitKnownMember(llvm::codeview::CVMemberRecord&, llvm::codeview::BaseClassRecord&)
Line
Count
Source
139
26
  Error visitKnownMember(CVMemberRecord &CVR, Name##Record &Record) override { \
140
26
    return visitKnownMemberImpl<Name##Record>(CVR, Record);                    \
141
26
  }
llvm::codeview::FieldListDeserializer::visitKnownMember(llvm::codeview::CVMemberRecord&, llvm::codeview::VirtualBaseClassRecord&)
Line
Count
Source
139
21
  Error visitKnownMember(CVMemberRecord &CVR, Name##Record &Record) override { \
140
21
    return visitKnownMemberImpl<Name##Record>(CVR, Record);                    \
141
21
  }
llvm::codeview::FieldListDeserializer::visitKnownMember(llvm::codeview::CVMemberRecord&, llvm::codeview::VFPtrRecord&)
Line
Count
Source
139
19
  Error visitKnownMember(CVMemberRecord &CVR, Name##Record &Record) override { \
140
19
    return visitKnownMemberImpl<Name##Record>(CVR, Record);                    \
141
19
  }
llvm::codeview::FieldListDeserializer::visitKnownMember(llvm::codeview::CVMemberRecord&, llvm::codeview::StaticDataMemberRecord&)
Line
Count
Source
139
119
  Error visitKnownMember(CVMemberRecord &CVR, Name##Record &Record) override { \
140
119
    return visitKnownMemberImpl<Name##Record>(CVR, Record);                    \
141
119
  }
llvm::codeview::FieldListDeserializer::visitKnownMember(llvm::codeview::CVMemberRecord&, llvm::codeview::OverloadedMethodRecord&)
Line
Count
Source
139
226
  Error visitKnownMember(CVMemberRecord &CVR, Name##Record &Record) override { \
140
226
    return visitKnownMemberImpl<Name##Record>(CVR, Record);                    \
141
226
  }
llvm::codeview::FieldListDeserializer::visitKnownMember(llvm::codeview::CVMemberRecord&, llvm::codeview::DataMemberRecord&)
Line
Count
Source
139
1.15k
  Error visitKnownMember(CVMemberRecord &CVR, Name##Record &Record) override { \
140
1.15k
    return visitKnownMemberImpl<Name##Record>(CVR, Record);                    \
141
1.15k
  }
llvm::codeview::FieldListDeserializer::visitKnownMember(llvm::codeview::CVMemberRecord&, llvm::codeview::NestedTypeRecord&)
Line
Count
Source
139
162
  Error visitKnownMember(CVMemberRecord &CVR, Name##Record &Record) override { \
140
162
    return visitKnownMemberImpl<Name##Record>(CVR, Record);                    \
141
162
  }
llvm::codeview::FieldListDeserializer::visitKnownMember(llvm::codeview::CVMemberRecord&, llvm::codeview::OneMethodRecord&)
Line
Count
Source
139
408
  Error visitKnownMember(CVMemberRecord &CVR, Name##Record &Record) override { \
140
408
    return visitKnownMemberImpl<Name##Record>(CVR, Record);                    \
141
408
  }
llvm::codeview::FieldListDeserializer::visitKnownMember(llvm::codeview::CVMemberRecord&, llvm::codeview::EnumeratorRecord&)
Line
Count
Source
139
6.69k
  Error visitKnownMember(CVMemberRecord &CVR, Name##Record &Record) override { \
140
6.69k
    return visitKnownMemberImpl<Name##Record>(CVR, Record);                    \
141
6.69k
  }
llvm::codeview::FieldListDeserializer::visitKnownMember(llvm::codeview::CVMemberRecord&, llvm::codeview::ListContinuationRecord&)
Line
Count
Source
139
4
  Error visitKnownMember(CVMemberRecord &CVR, Name##Record &Record) override { \
140
4
    return visitKnownMemberImpl<Name##Record>(CVR, Record);                    \
141
4
  }
142
#define TYPE_RECORD_ALIAS(EnumName, EnumVal, Name, AliasName)
143
#define MEMBER_RECORD_ALIAS(EnumName, EnumVal, Name, AliasName)
144
#include "llvm/DebugInfo/CodeView/CodeViewTypes.def"
145
146
private:
147
  template <typename RecordType>
148
8.84k
  Error visitKnownMemberImpl(CVMemberRecord &CVR, RecordType &Record) {
149
8.84k
    if (auto EC = Mapping.Mapping.visitKnownMember(CVR, Record))
150
0
      return EC;
151
8.84k
152
8.84k
    uint32_t EndOffset = Mapping.Reader.getOffset();
153
8.84k
    uint32_t RecordLength = EndOffset - Mapping.StartOffset;
154
8.84k
    Mapping.Reader.setOffset(Mapping.StartOffset);
155
8.84k
    if (auto EC = Mapping.Reader.readBytes(CVR.Data, RecordLength))
156
0
      return EC;
157
8.84k
    assert(Mapping.Reader.getOffset() == EndOffset);
158
8.84k
    return Error::success();
159
8.84k
  }
llvm::Error llvm::codeview::FieldListDeserializer::visitKnownMemberImpl<llvm::codeview::BaseClassRecord>(llvm::codeview::CVMemberRecord&, llvm::codeview::BaseClassRecord&)
Line
Count
Source
148
26
  Error visitKnownMemberImpl(CVMemberRecord &CVR, RecordType &Record) {
149
26
    if (auto EC = Mapping.Mapping.visitKnownMember(CVR, Record))
150
0
      return EC;
151
26
152
26
    uint32_t EndOffset = Mapping.Reader.getOffset();
153
26
    uint32_t RecordLength = EndOffset - Mapping.StartOffset;
154
26
    Mapping.Reader.setOffset(Mapping.StartOffset);
155
26
    if (auto EC = Mapping.Reader.readBytes(CVR.Data, RecordLength))
156
0
      return EC;
157
26
    assert(Mapping.Reader.getOffset() == EndOffset);
158
26
    return Error::success();
159
26
  }
llvm::Error llvm::codeview::FieldListDeserializer::visitKnownMemberImpl<llvm::codeview::VirtualBaseClassRecord>(llvm::codeview::CVMemberRecord&, llvm::codeview::VirtualBaseClassRecord&)
Line
Count
Source
148
21
  Error visitKnownMemberImpl(CVMemberRecord &CVR, RecordType &Record) {
149
21
    if (auto EC = Mapping.Mapping.visitKnownMember(CVR, Record))
150
0
      return EC;
151
21
152
21
    uint32_t EndOffset = Mapping.Reader.getOffset();
153
21
    uint32_t RecordLength = EndOffset - Mapping.StartOffset;
154
21
    Mapping.Reader.setOffset(Mapping.StartOffset);
155
21
    if (auto EC = Mapping.Reader.readBytes(CVR.Data, RecordLength))
156
0
      return EC;
157
21
    assert(Mapping.Reader.getOffset() == EndOffset);
158
21
    return Error::success();
159
21
  }
llvm::Error llvm::codeview::FieldListDeserializer::visitKnownMemberImpl<llvm::codeview::VFPtrRecord>(llvm::codeview::CVMemberRecord&, llvm::codeview::VFPtrRecord&)
Line
Count
Source
148
19
  Error visitKnownMemberImpl(CVMemberRecord &CVR, RecordType &Record) {
149
19
    if (auto EC = Mapping.Mapping.visitKnownMember(CVR, Record))
150
0
      return EC;
151
19
152
19
    uint32_t EndOffset = Mapping.Reader.getOffset();
153
19
    uint32_t RecordLength = EndOffset - Mapping.StartOffset;
154
19
    Mapping.Reader.setOffset(Mapping.StartOffset);
155
19
    if (auto EC = Mapping.Reader.readBytes(CVR.Data, RecordLength))
156
0
      return EC;
157
19
    assert(Mapping.Reader.getOffset() == EndOffset);
158
19
    return Error::success();
159
19
  }
llvm::Error llvm::codeview::FieldListDeserializer::visitKnownMemberImpl<llvm::codeview::StaticDataMemberRecord>(llvm::codeview::CVMemberRecord&, llvm::codeview::StaticDataMemberRecord&)
Line
Count
Source
148
119
  Error visitKnownMemberImpl(CVMemberRecord &CVR, RecordType &Record) {
149
119
    if (auto EC = Mapping.Mapping.visitKnownMember(CVR, Record))
150
0
      return EC;
151
119
152
119
    uint32_t EndOffset = Mapping.Reader.getOffset();
153
119
    uint32_t RecordLength = EndOffset - Mapping.StartOffset;
154
119
    Mapping.Reader.setOffset(Mapping.StartOffset);
155
119
    if (auto EC = Mapping.Reader.readBytes(CVR.Data, RecordLength))
156
0
      return EC;
157
119
    assert(Mapping.Reader.getOffset() == EndOffset);
158
119
    return Error::success();
159
119
  }
llvm::Error llvm::codeview::FieldListDeserializer::visitKnownMemberImpl<llvm::codeview::OverloadedMethodRecord>(llvm::codeview::CVMemberRecord&, llvm::codeview::OverloadedMethodRecord&)
Line
Count
Source
148
226
  Error visitKnownMemberImpl(CVMemberRecord &CVR, RecordType &Record) {
149
226
    if (auto EC = Mapping.Mapping.visitKnownMember(CVR, Record))
150
0
      return EC;
151
226
152
226
    uint32_t EndOffset = Mapping.Reader.getOffset();
153
226
    uint32_t RecordLength = EndOffset - Mapping.StartOffset;
154
226
    Mapping.Reader.setOffset(Mapping.StartOffset);
155
226
    if (auto EC = Mapping.Reader.readBytes(CVR.Data, RecordLength))
156
0
      return EC;
157
226
    assert(Mapping.Reader.getOffset() == EndOffset);
158
226
    return Error::success();
159
226
  }
llvm::Error llvm::codeview::FieldListDeserializer::visitKnownMemberImpl<llvm::codeview::DataMemberRecord>(llvm::codeview::CVMemberRecord&, llvm::codeview::DataMemberRecord&)
Line
Count
Source
148
1.15k
  Error visitKnownMemberImpl(CVMemberRecord &CVR, RecordType &Record) {
149
1.15k
    if (auto EC = Mapping.Mapping.visitKnownMember(CVR, Record))
150
0
      return EC;
151
1.15k
152
1.15k
    uint32_t EndOffset = Mapping.Reader.getOffset();
153
1.15k
    uint32_t RecordLength = EndOffset - Mapping.StartOffset;
154
1.15k
    Mapping.Reader.setOffset(Mapping.StartOffset);
155
1.15k
    if (auto EC = Mapping.Reader.readBytes(CVR.Data, RecordLength))
156
0
      return EC;
157
1.15k
    assert(Mapping.Reader.getOffset() == EndOffset);
158
1.15k
    return Error::success();
159
1.15k
  }
llvm::Error llvm::codeview::FieldListDeserializer::visitKnownMemberImpl<llvm::codeview::NestedTypeRecord>(llvm::codeview::CVMemberRecord&, llvm::codeview::NestedTypeRecord&)
Line
Count
Source
148
162
  Error visitKnownMemberImpl(CVMemberRecord &CVR, RecordType &Record) {
149
162
    if (auto EC = Mapping.Mapping.visitKnownMember(CVR, Record))
150
0
      return EC;
151
162
152
162
    uint32_t EndOffset = Mapping.Reader.getOffset();
153
162
    uint32_t RecordLength = EndOffset - Mapping.StartOffset;
154
162
    Mapping.Reader.setOffset(Mapping.StartOffset);
155
162
    if (auto EC = Mapping.Reader.readBytes(CVR.Data, RecordLength))
156
0
      return EC;
157
162
    assert(Mapping.Reader.getOffset() == EndOffset);
158
162
    return Error::success();
159
162
  }
llvm::Error llvm::codeview::FieldListDeserializer::visitKnownMemberImpl<llvm::codeview::OneMethodRecord>(llvm::codeview::CVMemberRecord&, llvm::codeview::OneMethodRecord&)
Line
Count
Source
148
408
  Error visitKnownMemberImpl(CVMemberRecord &CVR, RecordType &Record) {
149
408
    if (auto EC = Mapping.Mapping.visitKnownMember(CVR, Record))
150
0
      return EC;
151
408
152
408
    uint32_t EndOffset = Mapping.Reader.getOffset();
153
408
    uint32_t RecordLength = EndOffset - Mapping.StartOffset;
154
408
    Mapping.Reader.setOffset(Mapping.StartOffset);
155
408
    if (auto EC = Mapping.Reader.readBytes(CVR.Data, RecordLength))
156
0
      return EC;
157
408
    assert(Mapping.Reader.getOffset() == EndOffset);
158
408
    return Error::success();
159
408
  }
llvm::Error llvm::codeview::FieldListDeserializer::visitKnownMemberImpl<llvm::codeview::EnumeratorRecord>(llvm::codeview::CVMemberRecord&, llvm::codeview::EnumeratorRecord&)
Line
Count
Source
148
6.69k
  Error visitKnownMemberImpl(CVMemberRecord &CVR, RecordType &Record) {
149
6.69k
    if (auto EC = Mapping.Mapping.visitKnownMember(CVR, Record))
150
0
      return EC;
151
6.69k
152
6.69k
    uint32_t EndOffset = Mapping.Reader.getOffset();
153
6.69k
    uint32_t RecordLength = EndOffset - Mapping.StartOffset;
154
6.69k
    Mapping.Reader.setOffset(Mapping.StartOffset);
155
6.69k
    if (auto EC = Mapping.Reader.readBytes(CVR.Data, RecordLength))
156
0
      return EC;
157
6.69k
    assert(Mapping.Reader.getOffset() == EndOffset);
158
6.69k
    return Error::success();
159
6.69k
  }
llvm::Error llvm::codeview::FieldListDeserializer::visitKnownMemberImpl<llvm::codeview::ListContinuationRecord>(llvm::codeview::CVMemberRecord&, llvm::codeview::ListContinuationRecord&)
Line
Count
Source
148
4
  Error visitKnownMemberImpl(CVMemberRecord &CVR, RecordType &Record) {
149
4
    if (auto EC = Mapping.Mapping.visitKnownMember(CVR, Record))
150
0
      return EC;
151
4
152
4
    uint32_t EndOffset = Mapping.Reader.getOffset();
153
4
    uint32_t RecordLength = EndOffset - Mapping.StartOffset;
154
4
    Mapping.Reader.setOffset(Mapping.StartOffset);
155
4
    if (auto EC = Mapping.Reader.readBytes(CVR.Data, RecordLength))
156
0
      return EC;
157
4
    assert(Mapping.Reader.getOffset() == EndOffset);
158
4
    return Error::success();
159
4
  }
160
  MappingInfo Mapping;
161
};
162
163
} // end namespace codeview
164
} // end namespace llvm
165
166
#endif // LLVM_DEBUGINFO_CODEVIEW_TYPEDESERIALIZER_H