Coverage Report

Created: 2019-07-24 05:18

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