Coverage Report

Created: 2019-02-15 18: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
// 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
16.4k
          Mapping(Reader) {}
33
34
    BinaryByteStream Stream;
35
    BinaryStreamReader Reader;
36
    TypeRecordMapping Mapping;
37
  };
38
39
public:
40
4.59k
  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(static_cast<TypeLeafKind>(K), Data);
62
    if (auto EC = deserializeAs<T>(CVT, Record))
63
      return std::move(EC);
64
    return Record;
65
  }
66
67
11.4k
  Error visitTypeBegin(CVType &Record) override {
68
11.4k
    assert(!Mapping && "Already in a type mapping!");
69
11.4k
    Mapping = llvm::make_unique<MappingInfo>(Record.content());
70
11.4k
    return Mapping->Mapping.visitTypeBegin(Record);
71
11.4k
  }
72
73
11.4k
  Error visitTypeBegin(CVType &Record, TypeIndex Index) override {
74
11.4k
    return visitTypeBegin(Record);
75
11.4k
  }
76
77
11.4k
  Error visitTypeEnd(CVType &Record) override {
78
11.4k
    assert(Mapping && "Not in a type mapping!");
79
11.4k
    auto EC = Mapping->Mapping.visitTypeEnd(Record);
80
11.4k
    Mapping.reset();
81
11.4k
    return EC;
82
11.4k
  }
83
84
#define TYPE_RECORD(EnumName, EnumVal, Name)                                   \
85
11.4k
  Error visitKnownRecord(CVType &CVR, Name##Record &Record) override {         \
86
11.4k
    return visitKnownRecordImpl<Name##Record>(CVR, Record);                    \
87
11.4k
  }
llvm::codeview::TypeDeserializer::visitKnownRecord(llvm::codeview::CVRecord<llvm::codeview::TypeLeafKind>&, llvm::codeview::PointerRecord&)
Line
Count
Source
85
1.46k
  Error visitKnownRecord(CVType &CVR, Name##Record &Record) override {         \
86
1.46k
    return visitKnownRecordImpl<Name##Record>(CVR, Record);                    \
87
1.46k
  }
llvm::codeview::TypeDeserializer::visitKnownRecord(llvm::codeview::CVRecord<llvm::codeview::TypeLeafKind>&, llvm::codeview::ModifierRecord&)
Line
Count
Source
85
227
  Error visitKnownRecord(CVType &CVR, Name##Record &Record) override {         \
86
227
    return visitKnownRecordImpl<Name##Record>(CVR, Record);                    \
87
227
  }
llvm::codeview::TypeDeserializer::visitKnownRecord(llvm::codeview::CVRecord<llvm::codeview::TypeLeafKind>&, llvm::codeview::ProcedureRecord&)
Line
Count
Source
85
481
  Error visitKnownRecord(CVType &CVR, Name##Record &Record) override {         \
86
481
    return visitKnownRecordImpl<Name##Record>(CVR, Record);                    \
87
481
  }
llvm::codeview::TypeDeserializer::visitKnownRecord(llvm::codeview::CVRecord<llvm::codeview::TypeLeafKind>&, llvm::codeview::MemberFunctionRecord&)
Line
Count
Source
85
1.54k
  Error visitKnownRecord(CVType &CVR, Name##Record &Record) override {         \
86
1.54k
    return visitKnownRecordImpl<Name##Record>(CVR, Record);                    \
87
1.54k
  }
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
856
  Error visitKnownRecord(CVType &CVR, Name##Record &Record) override {         \
86
856
    return visitKnownRecordImpl<Name##Record>(CVR, Record);                    \
87
856
  }
llvm::codeview::TypeDeserializer::visitKnownRecord(llvm::codeview::CVRecord<llvm::codeview::TypeLeafKind>&, llvm::codeview::FieldListRecord&)
Line
Count
Source
85
1.32k
  Error visitKnownRecord(CVType &CVR, Name##Record &Record) override {         \
86
1.32k
    return visitKnownRecordImpl<Name##Record>(CVR, Record);                    \
87
1.32k
  }
llvm::codeview::TypeDeserializer::visitKnownRecord(llvm::codeview::CVRecord<llvm::codeview::TypeLeafKind>&, llvm::codeview::ArrayRecord&)
Line
Count
Source
85
92
  Error visitKnownRecord(CVType &CVR, Name##Record &Record) override {         \
86
92
    return visitKnownRecordImpl<Name##Record>(CVR, Record);                    \
87
92
  }
llvm::codeview::TypeDeserializer::visitKnownRecord(llvm::codeview::CVRecord<llvm::codeview::TypeLeafKind>&, llvm::codeview::ClassRecord&)
Line
Count
Source
85
2.25k
  Error visitKnownRecord(CVType &CVR, Name##Record &Record) override {         \
86
2.25k
    return visitKnownRecordImpl<Name##Record>(CVR, Record);                    \
87
2.25k
  }
llvm::codeview::TypeDeserializer::visitKnownRecord(llvm::codeview::CVRecord<llvm::codeview::TypeLeafKind>&, llvm::codeview::UnionRecord&)
Line
Count
Source
85
39
  Error visitKnownRecord(CVType &CVR, Name##Record &Record) override {         \
86
39
    return visitKnownRecordImpl<Name##Record>(CVR, Record);                    \
87
39
  }
llvm::codeview::TypeDeserializer::visitKnownRecord(llvm::codeview::CVRecord<llvm::codeview::TypeLeafKind>&, llvm::codeview::EnumRecord&)
Line
Count
Source
85
256
  Error visitKnownRecord(CVType &CVR, Name##Record &Record) override {         \
86
256
    return visitKnownRecordImpl<Name##Record>(CVR, Record);                    \
87
256
  }
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
38
  Error visitKnownRecord(CVType &CVR, Name##Record &Record) override {         \
86
38
    return visitKnownRecordImpl<Name##Record>(CVR, Record);                    \
87
38
  }
llvm::codeview::TypeDeserializer::visitKnownRecord(llvm::codeview::CVRecord<llvm::codeview::TypeLeafKind>&, llvm::codeview::BitFieldRecord&)
Line
Count
Source
85
18
  Error visitKnownRecord(CVType &CVR, Name##Record &Record) override {         \
86
18
    return visitKnownRecordImpl<Name##Record>(CVR, Record);                    \
87
18
  }
llvm::codeview::TypeDeserializer::visitKnownRecord(llvm::codeview::CVRecord<llvm::codeview::TypeLeafKind>&, llvm::codeview::FuncIdRecord&)
Line
Count
Source
85
481
  Error visitKnownRecord(CVType &CVR, Name##Record &Record) override {         \
86
481
    return visitKnownRecordImpl<Name##Record>(CVR, Record);                    \
87
481
  }
llvm::codeview::TypeDeserializer::visitKnownRecord(llvm::codeview::CVRecord<llvm::codeview::TypeLeafKind>&, llvm::codeview::MemberFuncIdRecord&)
Line
Count
Source
85
112
  Error visitKnownRecord(CVType &CVR, Name##Record &Record) override {         \
86
112
    return visitKnownRecordImpl<Name##Record>(CVR, Record);                    \
87
112
  }
llvm::codeview::TypeDeserializer::visitKnownRecord(llvm::codeview::CVRecord<llvm::codeview::TypeLeafKind>&, llvm::codeview::BuildInfoRecord&)
Line
Count
Source
85
274
  Error visitKnownRecord(CVType &CVR, Name##Record &Record) override {         \
86
274
    return visitKnownRecordImpl<Name##Record>(CVR, Record);                    \
87
274
  }
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.07k
  Error visitKnownRecord(CVType &CVR, Name##Record &Record) override {         \
86
1.07k
    return visitKnownRecordImpl<Name##Record>(CVR, Record);                    \
87
1.07k
  }
llvm::codeview::TypeDeserializer::visitKnownRecord(llvm::codeview::CVRecord<llvm::codeview::TypeLeafKind>&, llvm::codeview::UdtSourceLineRecord&)
Line
Count
Source
85
561
  Error visitKnownRecord(CVType &CVR, Name##Record &Record) override {         \
86
561
    return visitKnownRecordImpl<Name##Record>(CVR, Record);                    \
87
561
  }
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
327
  Error visitKnownRecord(CVType &CVR, Name##Record &Record) override {         \
86
327
    return visitKnownRecordImpl<Name##Record>(CVR, Record);                    \
87
327
  }
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
11.4k
  Error visitKnownRecordImpl(CVType &CVR, RecordType &Record) {
96
11.4k
    return Mapping->Mapping.visitKnownRecord(CVR, Record);
97
11.4k
  }
llvm::Error llvm::codeview::TypeDeserializer::visitKnownRecordImpl<llvm::codeview::PointerRecord>(llvm::codeview::CVRecord<llvm::codeview::TypeLeafKind>&, llvm::codeview::PointerRecord&)
Line
Count
Source
95
1.46k
  Error visitKnownRecordImpl(CVType &CVR, RecordType &Record) {
96
1.46k
    return Mapping->Mapping.visitKnownRecord(CVR, Record);
97
1.46k
  }
llvm::Error llvm::codeview::TypeDeserializer::visitKnownRecordImpl<llvm::codeview::ModifierRecord>(llvm::codeview::CVRecord<llvm::codeview::TypeLeafKind>&, llvm::codeview::ModifierRecord&)
Line
Count
Source
95
227
  Error visitKnownRecordImpl(CVType &CVR, RecordType &Record) {
96
227
    return Mapping->Mapping.visitKnownRecord(CVR, Record);
97
227
  }
llvm::Error llvm::codeview::TypeDeserializer::visitKnownRecordImpl<llvm::codeview::ProcedureRecord>(llvm::codeview::CVRecord<llvm::codeview::TypeLeafKind>&, llvm::codeview::ProcedureRecord&)
Line
Count
Source
95
481
  Error visitKnownRecordImpl(CVType &CVR, RecordType &Record) {
96
481
    return Mapping->Mapping.visitKnownRecord(CVR, Record);
97
481
  }
llvm::Error llvm::codeview::TypeDeserializer::visitKnownRecordImpl<llvm::codeview::MemberFunctionRecord>(llvm::codeview::CVRecord<llvm::codeview::TypeLeafKind>&, llvm::codeview::MemberFunctionRecord&)
Line
Count
Source
95
1.54k
  Error visitKnownRecordImpl(CVType &CVR, RecordType &Record) {
96
1.54k
    return Mapping->Mapping.visitKnownRecord(CVR, Record);
97
1.54k
  }
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
856
  Error visitKnownRecordImpl(CVType &CVR, RecordType &Record) {
96
856
    return Mapping->Mapping.visitKnownRecord(CVR, Record);
97
856
  }
llvm::Error llvm::codeview::TypeDeserializer::visitKnownRecordImpl<llvm::codeview::FieldListRecord>(llvm::codeview::CVRecord<llvm::codeview::TypeLeafKind>&, llvm::codeview::FieldListRecord&)
Line
Count
Source
95
1.32k
  Error visitKnownRecordImpl(CVType &CVR, RecordType &Record) {
96
1.32k
    return Mapping->Mapping.visitKnownRecord(CVR, Record);
97
1.32k
  }
llvm::Error llvm::codeview::TypeDeserializer::visitKnownRecordImpl<llvm::codeview::ArrayRecord>(llvm::codeview::CVRecord<llvm::codeview::TypeLeafKind>&, llvm::codeview::ArrayRecord&)
Line
Count
Source
95
92
  Error visitKnownRecordImpl(CVType &CVR, RecordType &Record) {
96
92
    return Mapping->Mapping.visitKnownRecord(CVR, Record);
97
92
  }
llvm::Error llvm::codeview::TypeDeserializer::visitKnownRecordImpl<llvm::codeview::ClassRecord>(llvm::codeview::CVRecord<llvm::codeview::TypeLeafKind>&, llvm::codeview::ClassRecord&)
Line
Count
Source
95
2.25k
  Error visitKnownRecordImpl(CVType &CVR, RecordType &Record) {
96
2.25k
    return Mapping->Mapping.visitKnownRecord(CVR, Record);
97
2.25k
  }
llvm::Error llvm::codeview::TypeDeserializer::visitKnownRecordImpl<llvm::codeview::UnionRecord>(llvm::codeview::CVRecord<llvm::codeview::TypeLeafKind>&, llvm::codeview::UnionRecord&)
Line
Count
Source
95
39
  Error visitKnownRecordImpl(CVType &CVR, RecordType &Record) {
96
39
    return Mapping->Mapping.visitKnownRecord(CVR, Record);
97
39
  }
llvm::Error llvm::codeview::TypeDeserializer::visitKnownRecordImpl<llvm::codeview::EnumRecord>(llvm::codeview::CVRecord<llvm::codeview::TypeLeafKind>&, llvm::codeview::EnumRecord&)
Line
Count
Source
95
256
  Error visitKnownRecordImpl(CVType &CVR, RecordType &Record) {
96
256
    return Mapping->Mapping.visitKnownRecord(CVR, Record);
97
256
  }
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
38
  Error visitKnownRecordImpl(CVType &CVR, RecordType &Record) {
96
38
    return Mapping->Mapping.visitKnownRecord(CVR, Record);
97
38
  }
llvm::Error llvm::codeview::TypeDeserializer::visitKnownRecordImpl<llvm::codeview::BitFieldRecord>(llvm::codeview::CVRecord<llvm::codeview::TypeLeafKind>&, llvm::codeview::BitFieldRecord&)
Line
Count
Source
95
18
  Error visitKnownRecordImpl(CVType &CVR, RecordType &Record) {
96
18
    return Mapping->Mapping.visitKnownRecord(CVR, Record);
97
18
  }
llvm::Error llvm::codeview::TypeDeserializer::visitKnownRecordImpl<llvm::codeview::FuncIdRecord>(llvm::codeview::CVRecord<llvm::codeview::TypeLeafKind>&, llvm::codeview::FuncIdRecord&)
Line
Count
Source
95
481
  Error visitKnownRecordImpl(CVType &CVR, RecordType &Record) {
96
481
    return Mapping->Mapping.visitKnownRecord(CVR, Record);
97
481
  }
llvm::Error llvm::codeview::TypeDeserializer::visitKnownRecordImpl<llvm::codeview::MemberFuncIdRecord>(llvm::codeview::CVRecord<llvm::codeview::TypeLeafKind>&, llvm::codeview::MemberFuncIdRecord&)
Line
Count
Source
95
112
  Error visitKnownRecordImpl(CVType &CVR, RecordType &Record) {
96
112
    return Mapping->Mapping.visitKnownRecord(CVR, Record);
97
112
  }
llvm::Error llvm::codeview::TypeDeserializer::visitKnownRecordImpl<llvm::codeview::BuildInfoRecord>(llvm::codeview::CVRecord<llvm::codeview::TypeLeafKind>&, llvm::codeview::BuildInfoRecord&)
Line
Count
Source
95
274
  Error visitKnownRecordImpl(CVType &CVR, RecordType &Record) {
96
274
    return Mapping->Mapping.visitKnownRecord(CVR, Record);
97
274
  }
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.07k
  Error visitKnownRecordImpl(CVType &CVR, RecordType &Record) {
96
1.07k
    return Mapping->Mapping.visitKnownRecord(CVR, Record);
97
1.07k
  }
llvm::Error llvm::codeview::TypeDeserializer::visitKnownRecordImpl<llvm::codeview::UdtSourceLineRecord>(llvm::codeview::CVRecord<llvm::codeview::TypeLeafKind>&, llvm::codeview::UdtSourceLineRecord&)
Line
Count
Source
95
561
  Error visitKnownRecordImpl(CVType &CVR, RecordType &Record) {
96
561
    return Mapping->Mapping.visitKnownRecord(CVR, Record);
97
561
  }
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
327
  Error visitKnownRecordImpl(CVType &CVR, RecordType &Record) {
96
327
    return Mapping->Mapping.visitKnownRecord(CVR, Record);
97
327
  }
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.23k
        : Reader(R), Mapping(Reader), StartOffset(0) {}
106
107
    BinaryStreamReader &Reader;
108
    TypeRecordMapping Mapping;
109
    uint32_t StartOffset;
110
  };
111
112
public:
113
1.23k
  explicit FieldListDeserializer(BinaryStreamReader &Reader) : Mapping(Reader) {
114
1.23k
    CVType FieldList;
115
1.23k
    FieldList.Type = TypeLeafKind::LF_FIELDLIST;
116
1.23k
    consumeError(Mapping.Mapping.visitTypeBegin(FieldList));
117
1.23k
  }
118
119
1.23k
  ~FieldListDeserializer() override {
120
1.23k
    CVType FieldList;
121
1.23k
    FieldList.Type = TypeLeafKind::LF_FIELDLIST;
122
1.23k
    consumeError(Mapping.Mapping.visitTypeEnd(FieldList));
123
1.23k
  }
124
125
10.3k
  Error visitMemberBegin(CVMemberRecord &Record) override {
126
10.3k
    Mapping.StartOffset = Mapping.Reader.getOffset();
127
10.3k
    return Mapping.Mapping.visitMemberBegin(Record);
128
10.3k
  }
129
130
10.3k
  Error visitMemberEnd(CVMemberRecord &Record) override {
131
10.3k
    if (auto EC = Mapping.Mapping.visitMemberEnd(Record))
132
0
      return EC;
133
10.3k
    return Error::success();
134
10.3k
  }
135
136
#define TYPE_RECORD(EnumName, EnumVal, Name)
137
#define MEMBER_RECORD(EnumName, EnumVal, Name)                                 \
138
10.2k
  Error visitKnownMember(CVMemberRecord &CVR, Name##Record &Record) override { \
139
10.2k
    return visitKnownMemberImpl<Name##Record>(CVR, Record);                    \
140
10.2k
  }
llvm::codeview::FieldListDeserializer::visitKnownMember(llvm::codeview::CVMemberRecord&, llvm::codeview::BaseClassRecord&)
Line
Count
Source
138
27
  Error visitKnownMember(CVMemberRecord &CVR, Name##Record &Record) override { \
139
27
    return visitKnownMemberImpl<Name##Record>(CVR, Record);                    \
140
27
  }
llvm::codeview::FieldListDeserializer::visitKnownMember(llvm::codeview::CVMemberRecord&, llvm::codeview::VirtualBaseClassRecord&)
Line
Count
Source
138
21
  Error visitKnownMember(CVMemberRecord &CVR, Name##Record &Record) override { \
139
21
    return visitKnownMemberImpl<Name##Record>(CVR, Record);                    \
140
21
  }
llvm::codeview::FieldListDeserializer::visitKnownMember(llvm::codeview::CVMemberRecord&, llvm::codeview::VFPtrRecord&)
Line
Count
Source
138
19
  Error visitKnownMember(CVMemberRecord &CVR, Name##Record &Record) override { \
139
19
    return visitKnownMemberImpl<Name##Record>(CVR, Record);                    \
140
19
  }
llvm::codeview::FieldListDeserializer::visitKnownMember(llvm::codeview::CVMemberRecord&, llvm::codeview::StaticDataMemberRecord&)
Line
Count
Source
138
196
  Error visitKnownMember(CVMemberRecord &CVR, Name##Record &Record) override { \
139
196
    return visitKnownMemberImpl<Name##Record>(CVR, Record);                    \
140
196
  }
llvm::codeview::FieldListDeserializer::visitKnownMember(llvm::codeview::CVMemberRecord&, llvm::codeview::OverloadedMethodRecord&)
Line
Count
Source
138
318
  Error visitKnownMember(CVMemberRecord &CVR, Name##Record &Record) override { \
139
318
    return visitKnownMemberImpl<Name##Record>(CVR, Record);                    \
140
318
  }
llvm::codeview::FieldListDeserializer::visitKnownMember(llvm::codeview::CVMemberRecord&, llvm::codeview::DataMemberRecord&)
Line
Count
Source
138
1.64k
  Error visitKnownMember(CVMemberRecord &CVR, Name##Record &Record) override { \
139
1.64k
    return visitKnownMemberImpl<Name##Record>(CVR, Record);                    \
140
1.64k
  }
llvm::codeview::FieldListDeserializer::visitKnownMember(llvm::codeview::CVMemberRecord&, llvm::codeview::NestedTypeRecord&)
Line
Count
Source
138
207
  Error visitKnownMember(CVMemberRecord &CVR, Name##Record &Record) override { \
139
207
    return visitKnownMemberImpl<Name##Record>(CVR, Record);                    \
140
207
  }
llvm::codeview::FieldListDeserializer::visitKnownMember(llvm::codeview::CVMemberRecord&, llvm::codeview::OneMethodRecord&)
Line
Count
Source
138
615
  Error visitKnownMember(CVMemberRecord &CVR, Name##Record &Record) override { \
139
615
    return visitKnownMemberImpl<Name##Record>(CVR, Record);                    \
140
615
  }
llvm::codeview::FieldListDeserializer::visitKnownMember(llvm::codeview::CVMemberRecord&, llvm::codeview::EnumeratorRecord&)
Line
Count
Source
138
7.15k
  Error visitKnownMember(CVMemberRecord &CVR, Name##Record &Record) override { \
139
7.15k
    return visitKnownMemberImpl<Name##Record>(CVR, Record);                    \
140
7.15k
  }
llvm::codeview::FieldListDeserializer::visitKnownMember(llvm::codeview::CVMemberRecord&, llvm::codeview::ListContinuationRecord&)
Line
Count
Source
138
4
  Error visitKnownMember(CVMemberRecord &CVR, Name##Record &Record) override { \
139
4
    return visitKnownMemberImpl<Name##Record>(CVR, Record);                    \
140
4
  }
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
10.2k
  Error visitKnownMemberImpl(CVMemberRecord &CVR, RecordType &Record) {
148
10.2k
    if (auto EC = Mapping.Mapping.visitKnownMember(CVR, Record))
149
0
      return EC;
150
10.2k
151
10.2k
    uint32_t EndOffset = Mapping.Reader.getOffset();
152
10.2k
    uint32_t RecordLength = EndOffset - Mapping.StartOffset;
153
10.2k
    Mapping.Reader.setOffset(Mapping.StartOffset);
154
10.2k
    if (auto EC = Mapping.Reader.readBytes(CVR.Data, RecordLength))
155
0
      return EC;
156
10.2k
    assert(Mapping.Reader.getOffset() == EndOffset);
157
10.2k
    return Error::success();
158
10.2k
  }
llvm::Error llvm::codeview::FieldListDeserializer::visitKnownMemberImpl<llvm::codeview::BaseClassRecord>(llvm::codeview::CVMemberRecord&, llvm::codeview::BaseClassRecord&)
Line
Count
Source
147
27
  Error visitKnownMemberImpl(CVMemberRecord &CVR, RecordType &Record) {
148
27
    if (auto EC = Mapping.Mapping.visitKnownMember(CVR, Record))
149
0
      return EC;
150
27
151
27
    uint32_t EndOffset = Mapping.Reader.getOffset();
152
27
    uint32_t RecordLength = EndOffset - Mapping.StartOffset;
153
27
    Mapping.Reader.setOffset(Mapping.StartOffset);
154
27
    if (auto EC = Mapping.Reader.readBytes(CVR.Data, RecordLength))
155
0
      return EC;
156
27
    assert(Mapping.Reader.getOffset() == EndOffset);
157
27
    return Error::success();
158
27
  }
llvm::Error llvm::codeview::FieldListDeserializer::visitKnownMemberImpl<llvm::codeview::VirtualBaseClassRecord>(llvm::codeview::CVMemberRecord&, llvm::codeview::VirtualBaseClassRecord&)
Line
Count
Source
147
21
  Error visitKnownMemberImpl(CVMemberRecord &CVR, RecordType &Record) {
148
21
    if (auto EC = Mapping.Mapping.visitKnownMember(CVR, Record))
149
0
      return EC;
150
21
151
21
    uint32_t EndOffset = Mapping.Reader.getOffset();
152
21
    uint32_t RecordLength = EndOffset - Mapping.StartOffset;
153
21
    Mapping.Reader.setOffset(Mapping.StartOffset);
154
21
    if (auto EC = Mapping.Reader.readBytes(CVR.Data, RecordLength))
155
0
      return EC;
156
21
    assert(Mapping.Reader.getOffset() == EndOffset);
157
21
    return Error::success();
158
21
  }
llvm::Error llvm::codeview::FieldListDeserializer::visitKnownMemberImpl<llvm::codeview::VFPtrRecord>(llvm::codeview::CVMemberRecord&, llvm::codeview::VFPtrRecord&)
Line
Count
Source
147
19
  Error visitKnownMemberImpl(CVMemberRecord &CVR, RecordType &Record) {
148
19
    if (auto EC = Mapping.Mapping.visitKnownMember(CVR, Record))
149
0
      return EC;
150
19
151
19
    uint32_t EndOffset = Mapping.Reader.getOffset();
152
19
    uint32_t RecordLength = EndOffset - Mapping.StartOffset;
153
19
    Mapping.Reader.setOffset(Mapping.StartOffset);
154
19
    if (auto EC = Mapping.Reader.readBytes(CVR.Data, RecordLength))
155
0
      return EC;
156
19
    assert(Mapping.Reader.getOffset() == EndOffset);
157
19
    return Error::success();
158
19
  }
llvm::Error llvm::codeview::FieldListDeserializer::visitKnownMemberImpl<llvm::codeview::StaticDataMemberRecord>(llvm::codeview::CVMemberRecord&, llvm::codeview::StaticDataMemberRecord&)
Line
Count
Source
147
196
  Error visitKnownMemberImpl(CVMemberRecord &CVR, RecordType &Record) {
148
196
    if (auto EC = Mapping.Mapping.visitKnownMember(CVR, Record))
149
0
      return EC;
150
196
151
196
    uint32_t EndOffset = Mapping.Reader.getOffset();
152
196
    uint32_t RecordLength = EndOffset - Mapping.StartOffset;
153
196
    Mapping.Reader.setOffset(Mapping.StartOffset);
154
196
    if (auto EC = Mapping.Reader.readBytes(CVR.Data, RecordLength))
155
0
      return EC;
156
196
    assert(Mapping.Reader.getOffset() == EndOffset);
157
196
    return Error::success();
158
196
  }
llvm::Error llvm::codeview::FieldListDeserializer::visitKnownMemberImpl<llvm::codeview::OverloadedMethodRecord>(llvm::codeview::CVMemberRecord&, llvm::codeview::OverloadedMethodRecord&)
Line
Count
Source
147
318
  Error visitKnownMemberImpl(CVMemberRecord &CVR, RecordType &Record) {
148
318
    if (auto EC = Mapping.Mapping.visitKnownMember(CVR, Record))
149
0
      return EC;
150
318
151
318
    uint32_t EndOffset = Mapping.Reader.getOffset();
152
318
    uint32_t RecordLength = EndOffset - Mapping.StartOffset;
153
318
    Mapping.Reader.setOffset(Mapping.StartOffset);
154
318
    if (auto EC = Mapping.Reader.readBytes(CVR.Data, RecordLength))
155
0
      return EC;
156
318
    assert(Mapping.Reader.getOffset() == EndOffset);
157
318
    return Error::success();
158
318
  }
llvm::Error llvm::codeview::FieldListDeserializer::visitKnownMemberImpl<llvm::codeview::DataMemberRecord>(llvm::codeview::CVMemberRecord&, llvm::codeview::DataMemberRecord&)
Line
Count
Source
147
1.64k
  Error visitKnownMemberImpl(CVMemberRecord &CVR, RecordType &Record) {
148
1.64k
    if (auto EC = Mapping.Mapping.visitKnownMember(CVR, Record))
149
0
      return EC;
150
1.64k
151
1.64k
    uint32_t EndOffset = Mapping.Reader.getOffset();
152
1.64k
    uint32_t RecordLength = EndOffset - Mapping.StartOffset;
153
1.64k
    Mapping.Reader.setOffset(Mapping.StartOffset);
154
1.64k
    if (auto EC = Mapping.Reader.readBytes(CVR.Data, RecordLength))
155
0
      return EC;
156
1.64k
    assert(Mapping.Reader.getOffset() == EndOffset);
157
1.64k
    return Error::success();
158
1.64k
  }
llvm::Error llvm::codeview::FieldListDeserializer::visitKnownMemberImpl<llvm::codeview::NestedTypeRecord>(llvm::codeview::CVMemberRecord&, llvm::codeview::NestedTypeRecord&)
Line
Count
Source
147
207
  Error visitKnownMemberImpl(CVMemberRecord &CVR, RecordType &Record) {
148
207
    if (auto EC = Mapping.Mapping.visitKnownMember(CVR, Record))
149
0
      return EC;
150
207
151
207
    uint32_t EndOffset = Mapping.Reader.getOffset();
152
207
    uint32_t RecordLength = EndOffset - Mapping.StartOffset;
153
207
    Mapping.Reader.setOffset(Mapping.StartOffset);
154
207
    if (auto EC = Mapping.Reader.readBytes(CVR.Data, RecordLength))
155
0
      return EC;
156
207
    assert(Mapping.Reader.getOffset() == EndOffset);
157
207
    return Error::success();
158
207
  }
llvm::Error llvm::codeview::FieldListDeserializer::visitKnownMemberImpl<llvm::codeview::OneMethodRecord>(llvm::codeview::CVMemberRecord&, llvm::codeview::OneMethodRecord&)
Line
Count
Source
147
615
  Error visitKnownMemberImpl(CVMemberRecord &CVR, RecordType &Record) {
148
615
    if (auto EC = Mapping.Mapping.visitKnownMember(CVR, Record))
149
0
      return EC;
150
615
151
615
    uint32_t EndOffset = Mapping.Reader.getOffset();
152
615
    uint32_t RecordLength = EndOffset - Mapping.StartOffset;
153
615
    Mapping.Reader.setOffset(Mapping.StartOffset);
154
615
    if (auto EC = Mapping.Reader.readBytes(CVR.Data, RecordLength))
155
0
      return EC;
156
615
    assert(Mapping.Reader.getOffset() == EndOffset);
157
615
    return Error::success();
158
615
  }
llvm::Error llvm::codeview::FieldListDeserializer::visitKnownMemberImpl<llvm::codeview::EnumeratorRecord>(llvm::codeview::CVMemberRecord&, llvm::codeview::EnumeratorRecord&)
Line
Count
Source
147
7.15k
  Error visitKnownMemberImpl(CVMemberRecord &CVR, RecordType &Record) {
148
7.15k
    if (auto EC = Mapping.Mapping.visitKnownMember(CVR, Record))
149
0
      return EC;
150
7.15k
151
7.15k
    uint32_t EndOffset = Mapping.Reader.getOffset();
152
7.15k
    uint32_t RecordLength = EndOffset - Mapping.StartOffset;
153
7.15k
    Mapping.Reader.setOffset(Mapping.StartOffset);
154
7.15k
    if (auto EC = Mapping.Reader.readBytes(CVR.Data, RecordLength))
155
0
      return EC;
156
7.15k
    assert(Mapping.Reader.getOffset() == EndOffset);
157
7.15k
    return Error::success();
158
7.15k
  }
llvm::Error llvm::codeview::FieldListDeserializer::visitKnownMemberImpl<llvm::codeview::ListContinuationRecord>(llvm::codeview::CVMemberRecord&, llvm::codeview::ListContinuationRecord&)
Line
Count
Source
147
4
  Error visitKnownMemberImpl(CVMemberRecord &CVR, RecordType &Record) {
148
4
    if (auto EC = Mapping.Mapping.visitKnownMember(CVR, Record))
149
0
      return EC;
150
4
151
4
    uint32_t EndOffset = Mapping.Reader.getOffset();
152
4
    uint32_t RecordLength = EndOffset - Mapping.StartOffset;
153
4
    Mapping.Reader.setOffset(Mapping.StartOffset);
154
4
    if (auto EC = Mapping.Reader.readBytes(CVR.Data, RecordLength))
155
0
      return EC;
156
4
    assert(Mapping.Reader.getOffset() == EndOffset);
157
4
    return Error::success();
158
4
  }
159
  MappingInfo Mapping;
160
};
161
162
} // end namespace codeview
163
} // end namespace llvm
164
165
#endif // LLVM_DEBUGINFO_CODEVIEW_TYPEDESERIALIZER_H