llvm/llvm/lib/ObjectYAML/CodeViewYAMLTypes.cpp

//===- CodeViewYAMLTypes.cpp - CodeView YAMLIO types implementation -------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
//
// This file defines classes for handling the YAML representation of CodeView
// Debug Info.
//
//===----------------------------------------------------------------------===//

#include "llvm/ObjectYAML/CodeViewYAMLTypes.h"
#include "llvm/ADT/APSInt.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/BinaryFormat/COFF.h"
#include "llvm/DebugInfo/CodeView/AppendingTypeTableBuilder.h"
#include "llvm/DebugInfo/CodeView/CVTypeVisitor.h"
#include "llvm/DebugInfo/CodeView/CodeView.h"
#include "llvm/DebugInfo/CodeView/CodeViewError.h"
#include "llvm/DebugInfo/CodeView/ContinuationRecordBuilder.h"
#include "llvm/DebugInfo/CodeView/TypeDeserializer.h"
#include "llvm/DebugInfo/CodeView/TypeIndex.h"
#include "llvm/DebugInfo/CodeView/TypeVisitorCallbacks.h"
#include "llvm/Support/Allocator.h"
#include "llvm/Support/BinaryStreamReader.h"
#include "llvm/Support/BinaryStreamWriter.h"
#include "llvm/Support/Endian.h"
#include "llvm/Support/Error.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/YAMLTraits.h"
#include "llvm/Support/raw_ostream.h"
#include <algorithm>
#include <cassert>
#include <cstdint>
#include <vector>

usingnamespacellvm;
usingnamespacellvm::codeview;
usingnamespacellvm::CodeViewYAML;
usingnamespacellvm::CodeViewYAML::detail;
usingnamespacellvm::yaml;

LLVM_YAML_IS_SEQUENCE_VECTOR(OneMethodRecord)
LLVM_YAML_IS_SEQUENCE_VECTOR(VFTableSlotKind)
LLVM_YAML_IS_FLOW_SEQUENCE_VECTOR(TypeIndex)

LLVM_YAML_DECLARE_SCALAR_TRAITS()
LLVM_YAML_DECLARE_SCALAR_TRAITS()

LLVM_YAML_DECLARE_ENUM_TRAITS(TypeLeafKind)
LLVM_YAML_DECLARE_ENUM_TRAITS(PointerToMemberRepresentation)
LLVM_YAML_DECLARE_ENUM_TRAITS(VFTableSlotKind)
LLVM_YAML_DECLARE_ENUM_TRAITS(CallingConvention)
LLVM_YAML_DECLARE_ENUM_TRAITS(PointerKind)
LLVM_YAML_DECLARE_ENUM_TRAITS(PointerMode)
LLVM_YAML_DECLARE_ENUM_TRAITS(HfaKind)
LLVM_YAML_DECLARE_ENUM_TRAITS(MemberAccess)
LLVM_YAML_DECLARE_ENUM_TRAITS(MethodKind)
LLVM_YAML_DECLARE_ENUM_TRAITS(WindowsRTClassKind)
LLVM_YAML_DECLARE_ENUM_TRAITS(LabelType)

LLVM_YAML_DECLARE_BITSET_TRAITS(PointerOptions)
LLVM_YAML_DECLARE_BITSET_TRAITS(ModifierOptions)
LLVM_YAML_DECLARE_BITSET_TRAITS(FunctionOptions)
LLVM_YAML_DECLARE_BITSET_TRAITS(ClassOptions)
LLVM_YAML_DECLARE_BITSET_TRAITS(MethodOptions)

LLVM_YAML_DECLARE_MAPPING_TRAITS(OneMethodRecord)
LLVM_YAML_DECLARE_MAPPING_TRAITS(MemberPointerInfo)

namespace llvm {
namespace CodeViewYAML {
namespace detail {

struct LeafRecordBase {};

template <typename T> struct LeafRecordImpl : public LeafRecordBase {};

template <> struct LeafRecordImpl<FieldListRecord> : public LeafRecordBase {};

struct MemberRecordBase {};

template <typename T> struct MemberRecordImpl : public MemberRecordBase {};

} // end namespace detail
} // end namespace CodeViewYAML
} // end namespace llvm

void ScalarTraits<GUID>::output(const GUID &G, void *, llvm::raw_ostream &OS) {}

StringRef ScalarTraits<GUID>::input(StringRef Scalar, void *Ctx, GUID &S) {}

void ScalarTraits<TypeIndex>::output(const TypeIndex &S, void *,
                                     raw_ostream &OS) {}

StringRef ScalarTraits<TypeIndex>::input(StringRef Scalar, void *Ctx,
                                         TypeIndex &S) {}

void ScalarTraits<APSInt>::output(const APSInt &S, void *, raw_ostream &OS) {}

StringRef ScalarTraits<APSInt>::input(StringRef Scalar, void *Ctx, APSInt &S) {}

void ScalarEnumerationTraits<TypeLeafKind>::enumeration(IO &io,
                                                        TypeLeafKind &Value) {}

void ScalarEnumerationTraits<PointerToMemberRepresentation>::enumeration(
    IO &IO, PointerToMemberRepresentation &Value) {}

void ScalarEnumerationTraits<VFTableSlotKind>::enumeration(
    IO &IO, VFTableSlotKind &Kind) {}

void ScalarEnumerationTraits<CallingConvention>::enumeration(
    IO &IO, CallingConvention &Value) {}

void ScalarEnumerationTraits<PointerKind>::enumeration(IO &IO,
                                                       PointerKind &Kind) {}

void ScalarEnumerationTraits<PointerMode>::enumeration(IO &IO,
                                                       PointerMode &Mode) {}

void ScalarEnumerationTraits<HfaKind>::enumeration(IO &IO, HfaKind &Value) {}

void ScalarEnumerationTraits<MemberAccess>::enumeration(IO &IO,
                                                        MemberAccess &Access) {}

void ScalarEnumerationTraits<MethodKind>::enumeration(IO &IO,
                                                      MethodKind &Kind) {}

void ScalarEnumerationTraits<WindowsRTClassKind>::enumeration(
    IO &IO, WindowsRTClassKind &Value) {}

void ScalarEnumerationTraits<LabelType>::enumeration(IO &IO, LabelType &Value) {}

void ScalarBitSetTraits<PointerOptions>::bitset(IO &IO,
                                                PointerOptions &Options) {}

void ScalarBitSetTraits<ModifierOptions>::bitset(IO &IO,
                                                 ModifierOptions &Options) {}

void ScalarBitSetTraits<FunctionOptions>::bitset(IO &IO,
                                                 FunctionOptions &Options) {}

void ScalarBitSetTraits<ClassOptions>::bitset(IO &IO, ClassOptions &Options) {}

void ScalarBitSetTraits<MethodOptions>::bitset(IO &IO, MethodOptions &Options) {}

void MappingTraits<MemberPointerInfo>::mapping(IO &IO, MemberPointerInfo &MPI) {}

namespace llvm {
namespace CodeViewYAML {
namespace detail {

template <> void LeafRecordImpl<ModifierRecord>::map(IO &IO) {}

template <> void LeafRecordImpl<ProcedureRecord>::map(IO &IO) {}

template <> void LeafRecordImpl<MemberFunctionRecord>::map(IO &IO) {}

template <> void LeafRecordImpl<LabelRecord>::map(IO &IO) {}

template <> void LeafRecordImpl<MemberFuncIdRecord>::map(IO &IO) {}

template <> void LeafRecordImpl<ArgListRecord>::map(IO &IO) {}

template <> void LeafRecordImpl<StringListRecord>::map(IO &IO) {}

template <> void LeafRecordImpl<PointerRecord>::map(IO &IO) {}

template <> void LeafRecordImpl<ArrayRecord>::map(IO &IO) {}

void LeafRecordImpl<FieldListRecord>::map(IO &IO) {}

} // end namespace detail
} // end namespace CodeViewYAML
} // end namespace llvm

namespace {

class MemberRecordConversionVisitor : public TypeVisitorCallbacks {};

} // end anonymous namespace

Error LeafRecordImpl<FieldListRecord>::fromCodeViewRecord(CVType Type) {}

CVType LeafRecordImpl<FieldListRecord>::toCodeViewRecord(
    AppendingTypeTableBuilder &TS) const {}

void MappingTraits<OneMethodRecord>::mapping(IO &io, OneMethodRecord &Record) {}

namespace llvm {
namespace CodeViewYAML {
namespace detail {

template <> void LeafRecordImpl<ClassRecord>::map(IO &IO) {}

template <> void LeafRecordImpl<UnionRecord>::map(IO &IO) {}

template <> void LeafRecordImpl<EnumRecord>::map(IO &IO) {}

template <> void LeafRecordImpl<BitFieldRecord>::map(IO &IO) {}

template <> void LeafRecordImpl<VFTableShapeRecord>::map(IO &IO) {}

template <> void LeafRecordImpl<TypeServer2Record>::map(IO &IO) {}

template <> void LeafRecordImpl<StringIdRecord>::map(IO &IO) {}

template <> void LeafRecordImpl<FuncIdRecord>::map(IO &IO) {}

template <> void LeafRecordImpl<UdtSourceLineRecord>::map(IO &IO) {}

template <> void LeafRecordImpl<UdtModSourceLineRecord>::map(IO &IO) {}

template <> void LeafRecordImpl<BuildInfoRecord>::map(IO &IO) {}

template <> void LeafRecordImpl<VFTableRecord>::map(IO &IO) {}

template <> void LeafRecordImpl<MethodOverloadListRecord>::map(IO &IO) {}

template <> void LeafRecordImpl<PrecompRecord>::map(IO &IO) {}

template <> void LeafRecordImpl<EndPrecompRecord>::map(IO &IO) {}

template <> void MemberRecordImpl<OneMethodRecord>::map(IO &IO) {}

template <> void MemberRecordImpl<OverloadedMethodRecord>::map(IO &IO) {}

template <> void MemberRecordImpl<NestedTypeRecord>::map(IO &IO) {}

template <> void MemberRecordImpl<DataMemberRecord>::map(IO &IO) {}

template <> void MemberRecordImpl<StaticDataMemberRecord>::map(IO &IO) {}

template <> void MemberRecordImpl<EnumeratorRecord>::map(IO &IO) {}

template <> void MemberRecordImpl<VFPtrRecord>::map(IO &IO) {}

template <> void MemberRecordImpl<BaseClassRecord>::map(IO &IO) {}

template <> void MemberRecordImpl<VirtualBaseClassRecord>::map(IO &IO) {}

template <> void MemberRecordImpl<ListContinuationRecord>::map(IO &IO) {}

} // end namespace detail
} // end namespace CodeViewYAML
} // end namespace llvm

template <typename T>
static inline Expected<LeafRecord> fromCodeViewRecordImpl(CVType Type) {}

Expected<LeafRecord> LeafRecord::fromCodeViewRecord(CVType Type) {}

CVType
LeafRecord::toCodeViewRecord(AppendingTypeTableBuilder &Serializer) const {}

namespace llvm {
namespace yaml {

template <> struct MappingTraits<LeafRecordBase> {};

template <> struct MappingTraits<MemberRecordBase> {};

} // end namespace yaml
} // end namespace llvm

template <typename ConcreteType>
static void mapLeafRecordImpl(IO &IO, const char *Class, TypeLeafKind Kind,
                              LeafRecord &Obj) {}

void MappingTraits<LeafRecord>::mapping(IO &IO, LeafRecord &Obj) {}

template <typename ConcreteType>
static void mapMemberRecordImpl(IO &IO, const char *Class, TypeLeafKind Kind,
                                MemberRecord &Obj) {}

void MappingTraits<MemberRecord>::mapping(IO &IO, MemberRecord &Obj) {}

std::vector<LeafRecord>
llvm::CodeViewYAML::fromDebugT(ArrayRef<uint8_t> DebugTorP,
                               StringRef SectionName) {}

ArrayRef<uint8_t> llvm::CodeViewYAML::toDebugT(ArrayRef<LeafRecord> Leafs,
                                               BumpPtrAllocator &Alloc,
                                               StringRef SectionName) {}