[ObjectYAML] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@306925 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Eugene Zelenko 2017-07-01 01:35:55 +00:00
parent f3b91ec06a
commit cd90344c00
22 changed files with 455 additions and 266 deletions

View File

@ -15,14 +15,18 @@
#define LLVM_OBJECTYAML_COFFYAML_H
#include "llvm/ADT/Optional.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/BinaryFormat/COFF.h"
#include "llvm/ObjectYAML/CodeViewYAMLDebugSections.h"
#include "llvm/ObjectYAML/CodeViewYAMLTypes.h"
#include "llvm/ObjectYAML/YAML.h"
#include <cstdint>
#include <vector>
namespace llvm {
namespace COFF {
inline Characteristics operator|(Characteristics a, Characteristics b) {
uint32_t Ret = static_cast<uint32_t>(a) | static_cast<uint32_t>(b);
return static_cast<Characteristics>(Ret);
@ -39,60 +43,67 @@ inline DLLCharacteristics operator|(DLLCharacteristics a,
uint16_t Ret = static_cast<uint16_t>(a) | static_cast<uint16_t>(b);
return static_cast<DLLCharacteristics>(Ret);
}
}
} // end namespace COFF
// The structure of the yaml files is not an exact 1:1 match to COFF. In order
// to use yaml::IO, we use these structures which are closer to the source.
namespace COFFYAML {
LLVM_YAML_STRONG_TYPEDEF(uint8_t, COMDATType)
LLVM_YAML_STRONG_TYPEDEF(uint32_t, WeakExternalCharacteristics)
LLVM_YAML_STRONG_TYPEDEF(uint8_t, AuxSymbolType)
struct Relocation {
uint32_t VirtualAddress;
uint16_t Type;
StringRef SymbolName;
};
LLVM_YAML_STRONG_TYPEDEF(uint8_t, COMDATType)
LLVM_YAML_STRONG_TYPEDEF(uint32_t, WeakExternalCharacteristics)
LLVM_YAML_STRONG_TYPEDEF(uint8_t, AuxSymbolType)
struct Section {
COFF::section Header;
unsigned Alignment = 0;
yaml::BinaryRef SectionData;
std::vector<CodeViewYAML::YAMLDebugSubsection> DebugS;
std::vector<CodeViewYAML::LeafRecord> DebugT;
std::vector<Relocation> Relocations;
StringRef Name;
Section();
};
struct Relocation {
uint32_t VirtualAddress;
uint16_t Type;
StringRef SymbolName;
};
struct Symbol {
COFF::symbol Header;
COFF::SymbolBaseType SimpleType = COFF::IMAGE_SYM_TYPE_NULL;
COFF::SymbolComplexType ComplexType = COFF::IMAGE_SYM_DTYPE_NULL;
Optional<COFF::AuxiliaryFunctionDefinition> FunctionDefinition;
Optional<COFF::AuxiliarybfAndefSymbol> bfAndefSymbol;
Optional<COFF::AuxiliaryWeakExternal> WeakExternal;
StringRef File;
Optional<COFF::AuxiliarySectionDefinition> SectionDefinition;
Optional<COFF::AuxiliaryCLRToken> CLRToken;
StringRef Name;
Symbol();
};
struct Section {
COFF::section Header;
unsigned Alignment = 0;
yaml::BinaryRef SectionData;
std::vector<CodeViewYAML::YAMLDebugSubsection> DebugS;
std::vector<CodeViewYAML::LeafRecord> DebugT;
std::vector<Relocation> Relocations;
StringRef Name;
struct PEHeader {
COFF::PE32Header Header;
Optional<COFF::DataDirectory> DataDirectories[COFF::NUM_DATA_DIRECTORIES];
};
Section();
};
struct Object {
Optional<PEHeader> OptionalHeader;
COFF::header Header;
std::vector<Section> Sections;
std::vector<Symbol> Symbols;
Object();
};
}
}
struct Symbol {
COFF::symbol Header;
COFF::SymbolBaseType SimpleType = COFF::IMAGE_SYM_TYPE_NULL;
COFF::SymbolComplexType ComplexType = COFF::IMAGE_SYM_DTYPE_NULL;
Optional<COFF::AuxiliaryFunctionDefinition> FunctionDefinition;
Optional<COFF::AuxiliarybfAndefSymbol> bfAndefSymbol;
Optional<COFF::AuxiliaryWeakExternal> WeakExternal;
StringRef File;
Optional<COFF::AuxiliarySectionDefinition> SectionDefinition;
Optional<COFF::AuxiliaryCLRToken> CLRToken;
StringRef Name;
Symbol();
};
struct PEHeader {
COFF::PE32Header Header;
Optional<COFF::DataDirectory> DataDirectories[COFF::NUM_DATA_DIRECTORIES];
};
struct Object {
Optional<PEHeader> OptionalHeader;
COFF::header Header;
std::vector<Section> Sections;
std::vector<Symbol> Symbols;
Object();
};
} // end namespace COFFYAML
} // end namespace llvm
LLVM_YAML_IS_SEQUENCE_VECTOR(COFFYAML::Section)
LLVM_YAML_IS_SEQUENCE_VECTOR(COFFYAML::Symbol)
@ -224,4 +235,4 @@ struct MappingTraits<COFFYAML::Object> {
} // end namespace yaml
} // end namespace llvm
#endif
#endif // LLVM_OBJECTYAML_COFFYAML_H

View File

@ -1,4 +1,4 @@
//===- CodeViewYAMLDebugSections.h - CodeView YAMLIO debug sections -------===//
//=- CodeViewYAMLDebugSections.h - CodeView YAMLIO debug sections -*- C++ -*-=//
//
// The LLVM Compiler Infrastructure
//
@ -15,27 +15,33 @@
#ifndef LLVM_OBJECTYAML_CODEVIEWYAMLDEBUGSECTIONS_H
#define LLVM_OBJECTYAML_CODEVIEWYAMLDEBUGSECTIONS_H
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/DebugInfo/CodeView/CodeView.h"
#include "llvm/DebugInfo/CodeView/DebugSubsection.h"
#include "llvm/DebugInfo/CodeView/DebugSubsectionRecord.h"
#include "llvm/ObjectYAML/YAML.h"
#include "llvm/Support/Error.h"
#include "llvm/Support/YAMLTraits.h"
#include <cstdint>
#include <memory>
#include <vector>
namespace llvm {
namespace codeview {
class DebugStringTableSubsection;
class DebugStringTableSubsectionRef;
class DebugChecksumsSubsectionRef;
class DebugStringTableSubsection;
class DebugChecksumsSubsection;
class StringsAndChecksums;
class StringsAndChecksumsRef;
}
} // end namespace codeview
namespace CodeViewYAML {
namespace detail {
struct YAMLSubsectionBase;
}
} // end namespace detail
struct YAMLFrameData {
uint32_t RvaStart;
@ -87,7 +93,6 @@ struct SourceLineInfo {
uint32_t RelocSegment;
codeview::LineFlags Flags;
uint32_t CodeSize;
std::vector<SourceLineBlock> Blocks;
};
@ -124,11 +129,12 @@ fromDebugS(ArrayRef<uint8_t> Data, const codeview::StringsAndChecksumsRef &SC);
void initializeStringsAndChecksums(ArrayRef<YAMLDebugSubsection> Sections,
codeview::StringsAndChecksums &SC);
} // namespace CodeViewYAML
} // namespace llvm
} // end namespace CodeViewYAML
} // end namespace llvm
LLVM_YAML_DECLARE_MAPPING_TRAITS(CodeViewYAML::YAMLDebugSubsection)
LLVM_YAML_IS_SEQUENCE_VECTOR(CodeViewYAML::YAMLDebugSubsection)
#endif
#endif // LLVM_OBJECTYAML_CODEVIEWYAMLDEBUGSECTIONS_H

View File

@ -17,13 +17,18 @@
#include "llvm/DebugInfo/CodeView/CodeView.h"
#include "llvm/DebugInfo/CodeView/SymbolRecord.h"
#include "llvm/ObjectYAML/YAML.h"
#include "llvm/Support/Error.h"
#include "llvm/Support/YAMLTraits.h"
#include <memory>
namespace llvm {
namespace CodeViewYAML {
namespace detail {
struct SymbolRecordBase;
}
} // end namespace detail
struct SymbolRecord {
std::shared_ptr<detail::SymbolRecordBase> Symbol;
@ -31,13 +36,14 @@ struct SymbolRecord {
codeview::CVSymbol
toCodeViewSymbol(BumpPtrAllocator &Allocator,
codeview::CodeViewContainer Container) const;
static Expected<SymbolRecord> fromCodeViewSymbol(codeview::CVSymbol Symbol);
};
} // namespace CodeViewYAML
} // namespace llvm
} // end namespace CodeViewYAML
} // end namespace llvm
LLVM_YAML_DECLARE_MAPPING_TRAITS(CodeViewYAML::SymbolRecord)
LLVM_YAML_IS_SEQUENCE_VECTOR(CodeViewYAML::SymbolRecord)
#endif
#endif // LLVM_OBJECTYAML_CODEVIEWYAMLSYMBOLS_H

View File

@ -1,4 +1,4 @@
//===- CodeViewYAMLTypes.h - CodeView YAMLIO Type Record implementation ---===//
//==- CodeViewYAMLTypes.h - CodeView YAMLIO Type implementation --*- C++ -*-==//
//
// The LLVM Compiler Infrastructure
//
@ -15,20 +15,31 @@
#ifndef LLVM_OBJECTYAML_CODEVIEWYAMLTYPES_H
#define LLVM_OBJECTYAML_CODEVIEWYAMLTYPES_H
#include "llvm/DebugInfo/CodeView/CodeView.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/DebugInfo/CodeView/TypeRecord.h"
#include "llvm/ObjectYAML/YAML.h"
#include "llvm/Support/Allocator.h"
#include "llvm/Support/Error.h"
#include "llvm/Support/YAMLTraits.h"
#include <cstdint>
#include <memory>
#include <vector>
namespace llvm {
namespace codeview {
class TypeTableBuilder;
}
} // end namespace codeview
namespace CodeViewYAML {
namespace detail {
struct LeafRecordBase;
struct MemberRecordBase;
}
} // end namespace detail
struct MemberRecord {
std::shared_ptr<detail::MemberRecordBase> Member;
@ -44,8 +55,10 @@ struct LeafRecord {
std::vector<LeafRecord> fromDebugT(ArrayRef<uint8_t> DebugT);
ArrayRef<uint8_t> toDebugT(ArrayRef<LeafRecord>, BumpPtrAllocator &Alloc);
} // namespace CodeViewYAML
} // namespace llvm
} // end namespace CodeViewYAML
} // end namespace llvm
LLVM_YAML_DECLARE_MAPPING_TRAITS(CodeViewYAML::LeafRecord)
LLVM_YAML_DECLARE_MAPPING_TRAITS(CodeViewYAML::MemberRecord)
@ -53,4 +66,4 @@ LLVM_YAML_DECLARE_MAPPING_TRAITS(CodeViewYAML::MemberRecord)
LLVM_YAML_IS_SEQUENCE_VECTOR(CodeViewYAML::LeafRecord)
LLVM_YAML_IS_SEQUENCE_VECTOR(CodeViewYAML::MemberRecord)
#endif
#endif // LLVM_OBJECTYAML_CODEVIEWYAMLTYPES_H

View File

@ -1,5 +1,4 @@
//===--- DWARFEmitter.h - -------------------------------------------*- C++
//-*-===//
//===--- DWARFEmitter.h - ---------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@ -10,6 +9,7 @@
/// \file
/// \brief Common declarations for yaml2obj
//===----------------------------------------------------------------------===//
#ifndef LLVM_OBJECTYAML_DWARFEMITTER_H
#define LLVM_OBJECTYAML_DWARFEMITTER_H
@ -19,30 +19,31 @@
#include "llvm/Support/Host.h"
#include "llvm/Support/MemoryBuffer.h"
#include <memory>
#include <vector>
namespace llvm {
class raw_ostream;
namespace DWARFYAML {
struct Data;
struct PubSection;
void EmitDebugAbbrev(llvm::raw_ostream &OS, const llvm::DWARFYAML::Data &DI);
void EmitDebugStr(llvm::raw_ostream &OS, const llvm::DWARFYAML::Data &DI);
void EmitDebugAbbrev(raw_ostream &OS, const Data &DI);
void EmitDebugStr(raw_ostream &OS, const Data &DI);
void EmitDebugAranges(llvm::raw_ostream &OS, const llvm::DWARFYAML::Data &DI);
void EmitPubSection(llvm::raw_ostream &OS,
const llvm::DWARFYAML::PubSection &Sect,
void EmitDebugAranges(raw_ostream &OS, const Data &DI);
void EmitPubSection(raw_ostream &OS, const PubSection &Sect,
bool IsLittleEndian);
void EmitDebugInfo(llvm::raw_ostream &OS, const llvm::DWARFYAML::Data &DI);
void EmitDebugLine(llvm::raw_ostream &OS, const llvm::DWARFYAML::Data &DI);
void EmitDebugInfo(raw_ostream &OS, const Data &DI);
void EmitDebugLine(raw_ostream &OS, const Data &DI);
Expected<StringMap<std::unique_ptr<MemoryBuffer>>>
EmitDebugSections(StringRef YAMLString,
bool IsLittleEndian = sys::IsLittleEndianHost);
} // namespace DWARFYAML
} // namespace llvm
} // end namespace DWARFYAML
#endif
} // end namespace llvm
#endif // LLVM_OBJECTYAML_DWARFEMITTER_H

View File

@ -16,8 +16,11 @@
#ifndef LLVM_OBJECTYAML_DWARFYAML_H
#define LLVM_OBJECTYAML_DWARFYAML_H
#include "llvm/ADT/StringRef.h"
#include "llvm/BinaryFormat/Dwarf.h"
#include "llvm/ObjectYAML/YAML.h"
#include "llvm/Support/YAMLTraits.h"
#include <cstdint>
#include <vector>
namespace llvm {
namespace DWARFYAML {
@ -76,13 +79,11 @@ struct PubEntry {
};
struct PubSection {
PubSection() : IsGNUStyle(false) {}
InitialLength Length;
uint16_t Version;
uint32_t UnitOffset;
uint32_t UnitSize;
bool IsGNUStyle;
bool IsGNUStyle = false;
std::vector<PubEntry> Entries;
};
@ -158,8 +159,8 @@ struct Data {
bool isEmpty() const;
};
} // namespace llvm::DWARFYAML
} // namespace llvm
} // end namespace DWARFYAML
} // end namespace llvm
LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::yaml::Hex64)
LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::yaml::Hex8)
@ -302,7 +303,7 @@ template <> struct ScalarEnumerationTraits<dwarf::Constants> {
}
};
} // namespace llvm::yaml
} // namespace llvm
} // end namespace yaml
} // end namespace llvm
#endif
#endif // LLVM_OBJECTYAML_DWARFYAML_H

View File

@ -16,8 +16,12 @@
#ifndef LLVM_OBJECTYAML_ELFYAML_H
#define LLVM_OBJECTYAML_ELFYAML_H
#include "llvm/BinaryFormat/ELF.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/ObjectYAML/YAML.h"
#include "llvm/Support/YAMLTraits.h"
#include <cstdint>
#include <memory>
#include <vector>
namespace llvm {
namespace ELFYAML {
@ -66,6 +70,7 @@ struct FileHeader {
ELF_EF Flags;
llvm::yaml::Hex64 Entry;
};
struct Symbol {
StringRef Name;
ELF_STT Type;
@ -74,6 +79,7 @@ struct Symbol {
llvm::yaml::Hex64 Size;
uint8_t Other;
};
struct LocalGlobalWeakSymbols {
std::vector<Symbol> Local;
std::vector<Symbol> Global;
@ -100,13 +106,16 @@ struct Section {
StringRef Link;
StringRef Info;
llvm::yaml::Hex64 AddressAlign;
Section(SectionKind Kind) : Kind(Kind) {}
virtual ~Section();
};
struct RawContentSection : Section {
yaml::BinaryRef Content;
llvm::yaml::Hex64 Size;
RawContentSection() : Section(SectionKind::RawContent) {}
static bool classof(const Section *S) {
return S->Kind == SectionKind::RawContent;
}
@ -114,7 +123,9 @@ struct RawContentSection : Section {
struct NoBitsSection : Section {
llvm::yaml::Hex64 Size;
NoBitsSection() : Section(SectionKind::NoBits) {}
static bool classof(const Section *S) {
return S->Kind == SectionKind::NoBits;
}
@ -124,7 +135,9 @@ struct Group : Section {
// Members of a group contain a flag and a list of section indices
// that are part of the group.
std::vector<SectionOrType> Members;
Group() : Section(SectionKind::Group) {}
static bool classof(const Section *S) {
return S->Kind == SectionKind::Group;
}
@ -136,9 +149,12 @@ struct Relocation {
ELF_REL Type;
StringRef Symbol;
};
struct RelocationSection : Section {
std::vector<Relocation> Relocations;
RelocationSection() : Section(SectionKind::Relocation) {}
static bool classof(const Section *S) {
return S->Kind == SectionKind::Relocation;
}
@ -157,7 +173,9 @@ struct MipsABIFlags : Section {
MIPS_AFL_ASE ASEs;
MIPS_AFL_FLAGS1 Flags1;
llvm::yaml::Hex32 Flags2;
MipsABIFlags() : Section(SectionKind::MipsABIFlags) {}
static bool classof(const Section *S) {
return S->Kind == SectionKind::MipsABIFlags;
}
@ -316,4 +334,4 @@ template <> struct MappingTraits<ELFYAML::SectionOrType> {
} // end namespace yaml
} // end namespace llvm
#endif
#endif // LLVM_OBJECTYAML_ELFYAML_H

View File

@ -16,9 +16,13 @@
#ifndef LLVM_OBJECTYAML_MACHOYAML_H
#define LLVM_OBJECTYAML_MACHOYAML_H
#include "llvm/ADT/StringRef.h"
#include "llvm/BinaryFormat/MachO.h"
#include "llvm/ObjectYAML/DWARFYAML.h"
#include "llvm/ObjectYAML/YAML.h"
#include "llvm/Support/YAMLTraits.h"
#include <cstdint>
#include <string>
#include <vector>
namespace llvm {
namespace MachOYAML {
@ -51,6 +55,7 @@ struct FileHeader {
struct LoadCommand {
virtual ~LoadCommand();
llvm::MachO::macho_load_command Data;
std::vector<Section> Sections;
std::vector<MachO::build_tool_version> Tools;
@ -66,6 +71,7 @@ struct NListEntry {
uint16_t n_desc;
uint64_t n_value;
};
struct RebaseOpcode {
MachO::RebaseOpcode Opcode;
uint8_t Imm;
@ -81,15 +87,12 @@ struct BindOpcode {
};
struct ExportEntry {
ExportEntry()
: TerminalSize(0), NodeOffset(0), Name(), Flags(0), Address(0), Other(0),
ImportName(), Children() {}
uint64_t TerminalSize;
uint64_t NodeOffset;
uint64_t TerminalSize = 0;
uint64_t NodeOffset = 0;
std::string Name;
llvm::yaml::Hex64 Flags;
llvm::yaml::Hex64 Address;
llvm::yaml::Hex64 Other;
llvm::yaml::Hex64 Flags = 0;
llvm::yaml::Hex64 Address = 0;
llvm::yaml::Hex64 Other = 0;
std::string ImportName;
std::vector<MachOYAML::ExportEntry> Children;
};
@ -135,8 +138,8 @@ struct UniversalBinary {
std::vector<Object> Slices;
};
} // namespace llvm::MachOYAML
} // namespace llvm
} // end namespace MachOYAML
} // end namespace llvm
LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::MachOYAML::LoadCommand)
LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::MachOYAML::Section)
@ -149,6 +152,9 @@ LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::MachOYAML::FatArch)
LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::MachO::build_tool_version)
namespace llvm {
class raw_ostream;
namespace yaml {
template <> struct MappingTraits<MachOYAML::FileHeader> {
@ -250,22 +256,20 @@ template <> struct ScalarEnumerationTraits<MachO::BindOpcode> {
};
// This trait is used for 16-byte chars in Mach structures used for strings
typedef char char_16[16];
using char_16 = char[16];
template <> struct ScalarTraits<char_16> {
static void output(const char_16 &Val, void *, llvm::raw_ostream &Out);
static void output(const char_16 &Val, void *, raw_ostream &Out);
static StringRef input(StringRef Scalar, void *, char_16 &Val);
static bool mustQuote(StringRef S);
};
// This trait is used for UUIDs. It reads and writes them matching otool's
// formatting style.
typedef uint8_t uuid_t[16];
using uuid_t = uint8_t[16];
template <> struct ScalarTraits<uuid_t> {
static void output(const uuid_t &Val, void *, llvm::raw_ostream &Out);
static void output(const uuid_t &Val, void *, raw_ostream &Out);
static StringRef input(StringRef Scalar, void *, uuid_t &Val);
static bool mustQuote(StringRef S);
};
@ -296,8 +300,8 @@ template <> struct MappingTraits<MachO::section_64> {
static void mapping(IO &IO, MachO::section_64 &LoadCommand);
};
} // namespace llvm::yaml
} // end namespace yaml
} // namespace llvm
} // end namespace llvm
#endif
#endif // LLVM_OBJECTYAML_MACHOYAML_H

View File

@ -15,10 +15,13 @@
#include "llvm/ObjectYAML/MachOYAML.h"
#include "llvm/ObjectYAML/WasmYAML.h"
#include "llvm/Support/YAMLTraits.h"
#include <memory>
namespace llvm {
namespace yaml {
class IO;
struct YamlObjectFile {
std::unique_ptr<ELFYAML::Object> Elf;
std::unique_ptr<COFFYAML::Object> Coff;
@ -31,7 +34,7 @@ template <> struct MappingTraits<YamlObjectFile> {
static void mapping(IO &IO, YamlObjectFile &ObjectFile);
};
} // namespace yaml
} // namespace llvm
} // end namespace yaml
} // end namespace llvm
#endif
#endif // LLVM_OBJECTYAML_OBJECTYAML_H

View File

@ -16,8 +16,13 @@
#ifndef LLVM_OBJECTYAML_WASMYAML_H
#define LLVM_OBJECTYAML_WASMYAML_H
#include "llvm/ADT/StringRef.h"
#include "llvm/BinaryFormat/Wasm.h"
#include "llvm/ObjectYAML/YAML.h"
#include "llvm/Support/Casting.h"
#include <cstdint>
#include <memory>
#include <vector>
namespace llvm {
namespace WasmYAML {
@ -104,10 +109,8 @@ struct NameEntry {
};
struct Signature {
Signature() : Form(wasm::WASM_TYPE_FUNC) {}
uint32_t Index;
SignatureForm Form;
SignatureForm Form = wasm::WASM_TYPE_FUNC;
std::vector<ValueType> ParamTypes;
ValueType ReturnType;
};
@ -128,6 +131,7 @@ struct Section {
struct CustomSection : Section {
explicit CustomSection(StringRef Name)
: Section(wasm::WASM_SEC_CUSTOM), Name(Name) {}
static bool classof(const Section *S) {
return S->Type == wasm::WASM_SEC_CUSTOM;
}
@ -138,6 +142,7 @@ struct CustomSection : Section {
struct NameSection : CustomSection {
NameSection() : CustomSection("name") {}
static bool classof(const Section *S) {
auto C = dyn_cast<CustomSection>(S);
return C && C->Name == "name";
@ -148,6 +153,7 @@ struct NameSection : CustomSection {
struct LinkingSection : CustomSection {
LinkingSection() : CustomSection("linking") {}
static bool classof(const Section *S) {
auto C = dyn_cast<CustomSection>(S);
return C && C->Name == "linking";
@ -160,6 +166,7 @@ struct LinkingSection : CustomSection {
struct TypeSection : Section {
TypeSection() : Section(wasm::WASM_SEC_TYPE) {}
static bool classof(const Section *S) {
return S->Type == wasm::WASM_SEC_TYPE;
}
@ -169,6 +176,7 @@ struct TypeSection : Section {
struct ImportSection : Section {
ImportSection() : Section(wasm::WASM_SEC_IMPORT) {}
static bool classof(const Section *S) {
return S->Type == wasm::WASM_SEC_IMPORT;
}
@ -178,6 +186,7 @@ struct ImportSection : Section {
struct FunctionSection : Section {
FunctionSection() : Section(wasm::WASM_SEC_FUNCTION) {}
static bool classof(const Section *S) {
return S->Type == wasm::WASM_SEC_FUNCTION;
}
@ -187,6 +196,7 @@ struct FunctionSection : Section {
struct TableSection : Section {
TableSection() : Section(wasm::WASM_SEC_TABLE) {}
static bool classof(const Section *S) {
return S->Type == wasm::WASM_SEC_TABLE;
}
@ -196,6 +206,7 @@ struct TableSection : Section {
struct MemorySection : Section {
MemorySection() : Section(wasm::WASM_SEC_MEMORY) {}
static bool classof(const Section *S) {
return S->Type == wasm::WASM_SEC_MEMORY;
}
@ -205,6 +216,7 @@ struct MemorySection : Section {
struct GlobalSection : Section {
GlobalSection() : Section(wasm::WASM_SEC_GLOBAL) {}
static bool classof(const Section *S) {
return S->Type == wasm::WASM_SEC_GLOBAL;
}
@ -214,6 +226,7 @@ struct GlobalSection : Section {
struct ExportSection : Section {
ExportSection() : Section(wasm::WASM_SEC_EXPORT) {}
static bool classof(const Section *S) {
return S->Type == wasm::WASM_SEC_EXPORT;
}
@ -223,6 +236,7 @@ struct ExportSection : Section {
struct StartSection : Section {
StartSection() : Section(wasm::WASM_SEC_START) {}
static bool classof(const Section *S) {
return S->Type == wasm::WASM_SEC_START;
}
@ -232,6 +246,7 @@ struct StartSection : Section {
struct ElemSection : Section {
ElemSection() : Section(wasm::WASM_SEC_ELEM) {}
static bool classof(const Section *S) {
return S->Type == wasm::WASM_SEC_ELEM;
}
@ -241,6 +256,7 @@ struct ElemSection : Section {
struct CodeSection : Section {
CodeSection() : Section(wasm::WASM_SEC_CODE) {}
static bool classof(const Section *S) {
return S->Type == wasm::WASM_SEC_CODE;
}
@ -250,6 +266,7 @@ struct CodeSection : Section {
struct DataSection : Section {
DataSection() : Section(wasm::WASM_SEC_DATA) {}
static bool classof(const Section *S) {
return S->Type == wasm::WASM_SEC_DATA;
}
@ -379,4 +396,4 @@ template <> struct ScalarEnumerationTraits<WasmYAML::RelocType> {
} // end namespace yaml
} // end namespace llvm
#endif
#endif // LLVM_OBJECTYAML_WASMYAML_H

View File

@ -10,10 +10,17 @@
#ifndef LLVM_OBJECTYAML_YAML_H
#define LLVM_OBJECTYAML_YAML_H
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/YAMLTraits.h"
#include <cstdint>
namespace llvm {
class raw_ostream;
namespace yaml {
/// \brief Specialized YAMLIO scalar type for representing a binary blob.
///
/// A typical use case would be to represent the content of a section in a
@ -56,18 +63,20 @@ namespace yaml {
/// \endcode
class BinaryRef {
friend bool operator==(const BinaryRef &LHS, const BinaryRef &RHS);
/// \brief Either raw binary data, or a string of hex bytes (must always
/// be an even number of characters).
ArrayRef<uint8_t> Data;
/// \brief Discriminator between the two states of the `Data` member.
bool DataIsHexString;
bool DataIsHexString = true;
public:
BinaryRef() = default;
BinaryRef(ArrayRef<uint8_t> Data) : Data(Data), DataIsHexString(false) {}
BinaryRef(StringRef Data)
: Data(reinterpret_cast<const uint8_t *>(Data.data()), Data.size()),
DataIsHexString(true) {}
BinaryRef() : DataIsHexString(true) {}
: Data(reinterpret_cast<const uint8_t *>(Data.data()), Data.size()) {}
/// \brief The number of bytes that are represented by this BinaryRef.
/// This is the number of bytes that writeAsBinary() will write.
ArrayRef<uint8_t>::size_type binary_size() const {
@ -75,9 +84,11 @@ public:
return Data.size() / 2;
return Data.size();
}
/// \brief Write the contents (regardless of whether it is binary or a
/// hex string) as binary to the given raw_ostream.
void writeAsBinary(raw_ostream &OS) const;
/// \brief Write the contents (regardless of whether it is binary or a
/// hex string) as hex to the given raw_ostream.
///
@ -94,10 +105,13 @@ inline bool operator==(const BinaryRef &LHS, const BinaryRef &RHS) {
}
template <> struct ScalarTraits<BinaryRef> {
static void output(const BinaryRef &, void *, llvm::raw_ostream &);
static void output(const BinaryRef &, void *, raw_ostream &);
static StringRef input(StringRef, void *, BinaryRef &);
static bool mustQuote(StringRef S) { return needsQuotes(S); }
};
}
}
#endif
} // end namespace yaml
} // end namespace llvm
#endif // LLVM_OBJECTYAML_YAML_H

View File

@ -12,17 +12,25 @@
//===----------------------------------------------------------------------===//
#include "llvm/ObjectYAML/COFFYAML.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/YAMLTraits.h"
#include <cstdint>
#include <cstring>
#define ECase(X) IO.enumCase(Value, #X, COFF::X);
namespace llvm {
namespace COFFYAML {
Section::Section() { memset(&Header, 0, sizeof(COFF::section)); }
Symbol::Symbol() { memset(&Header, 0, sizeof(COFF::symbol)); }
Object::Object() { memset(&Header, 0, sizeof(COFF::header)); }
}
} // end namespace COFFYAML
namespace yaml {
void ScalarEnumerationTraits<COFFYAML::COMDATType>::enumeration(
IO &IO, COFFYAML::COMDATType &Value) {
IO.enumCase(Value, "0", 0);
@ -172,20 +180,20 @@ void ScalarEnumerationTraits<COFF::RelocationTypeAMD64>::enumeration(
void ScalarEnumerationTraits<COFF::WindowsSubsystem>::enumeration(
IO &IO, COFF::WindowsSubsystem &Value) {
ECase(IMAGE_SUBSYSTEM_UNKNOWN);
ECase(IMAGE_SUBSYSTEM_NATIVE);
ECase(IMAGE_SUBSYSTEM_WINDOWS_GUI);
ECase(IMAGE_SUBSYSTEM_WINDOWS_CUI);
ECase(IMAGE_SUBSYSTEM_OS2_CUI);
ECase(IMAGE_SUBSYSTEM_POSIX_CUI);
ECase(IMAGE_SUBSYSTEM_NATIVE_WINDOWS);
ECase(IMAGE_SUBSYSTEM_WINDOWS_CE_GUI);
ECase(IMAGE_SUBSYSTEM_EFI_APPLICATION);
ECase(IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER);
ECase(IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER);
ECase(IMAGE_SUBSYSTEM_EFI_ROM);
ECase(IMAGE_SUBSYSTEM_XBOX);
ECase(IMAGE_SUBSYSTEM_WINDOWS_BOOT_APPLICATION);
ECase(IMAGE_SUBSYSTEM_UNKNOWN);
ECase(IMAGE_SUBSYSTEM_NATIVE);
ECase(IMAGE_SUBSYSTEM_WINDOWS_GUI);
ECase(IMAGE_SUBSYSTEM_WINDOWS_CUI);
ECase(IMAGE_SUBSYSTEM_OS2_CUI);
ECase(IMAGE_SUBSYSTEM_POSIX_CUI);
ECase(IMAGE_SUBSYSTEM_NATIVE_WINDOWS);
ECase(IMAGE_SUBSYSTEM_WINDOWS_CE_GUI);
ECase(IMAGE_SUBSYSTEM_EFI_APPLICATION);
ECase(IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER);
ECase(IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER);
ECase(IMAGE_SUBSYSTEM_EFI_ROM);
ECase(IMAGE_SUBSYSTEM_XBOX);
ECase(IMAGE_SUBSYSTEM_WINDOWS_BOOT_APPLICATION);
}
#undef ECase
@ -252,12 +260,15 @@ void ScalarBitSetTraits<COFF::DLLCharacteristics>::bitset(
#undef BCase
namespace {
struct NSectionSelectionType {
NSectionSelectionType(IO &)
: SelectionType(COFFYAML::COMDATType(0)) {}
NSectionSelectionType(IO &, uint8_t C)
: SelectionType(COFFYAML::COMDATType(C)) {}
uint8_t denormalize(IO &) { return SelectionType; }
COFFYAML::COMDATType SelectionType;
};
@ -266,7 +277,9 @@ struct NWeakExternalCharacteristics {
: Characteristics(COFFYAML::WeakExternalCharacteristics(0)) {}
NWeakExternalCharacteristics(IO &, uint32_t C)
: Characteristics(COFFYAML::WeakExternalCharacteristics(C)) {}
uint32_t denormalize(IO &) { return Characteristics; }
COFFYAML::WeakExternalCharacteristics Characteristics;
};
@ -275,7 +288,9 @@ struct NSectionCharacteristics {
: Characteristics(COFF::SectionCharacteristics(0)) {}
NSectionCharacteristics(IO &, uint32_t C)
: Characteristics(COFF::SectionCharacteristics(C)) {}
uint32_t denormalize(IO &) { return Characteristics; }
COFF::SectionCharacteristics Characteristics;
};
@ -284,13 +299,16 @@ struct NAuxTokenType {
: AuxType(COFFYAML::AuxSymbolType(0)) {}
NAuxTokenType(IO &, uint8_t C)
: AuxType(COFFYAML::AuxSymbolType(C)) {}
uint32_t denormalize(IO &) { return AuxType; }
COFFYAML::AuxSymbolType AuxType;
};
struct NStorageClass {
NStorageClass(IO &) : StorageClass(COFF::SymbolStorageClass(0)) {}
NStorageClass(IO &, uint8_t S) : StorageClass(COFF::SymbolStorageClass(S)) {}
uint8_t denormalize(IO &) { return StorageClass; }
COFF::SymbolStorageClass StorageClass;
@ -299,7 +317,9 @@ struct NStorageClass {
struct NMachine {
NMachine(IO &) : Machine(COFF::MachineTypes(0)) {}
NMachine(IO &, uint16_t M) : Machine(COFF::MachineTypes(M)) {}
uint16_t denormalize(IO &) { return Machine; }
COFF::MachineTypes Machine;
};
@ -307,6 +327,7 @@ struct NHeaderCharacteristics {
NHeaderCharacteristics(IO &) : Characteristics(COFF::Characteristics(0)) {}
NHeaderCharacteristics(IO &, uint16_t C)
: Characteristics(COFF::Characteristics(C)) {}
uint16_t denormalize(IO &) { return Characteristics; }
COFF::Characteristics Characteristics;
@ -316,13 +337,16 @@ template <typename RelocType>
struct NType {
NType(IO &) : Type(RelocType(0)) {}
NType(IO &, uint16_t T) : Type(RelocType(T)) {}
uint16_t denormalize(IO &) { return Type; }
RelocType Type;
};
struct NWindowsSubsystem {
NWindowsSubsystem(IO &) : Subsystem(COFF::WindowsSubsystem(0)) {}
NWindowsSubsystem(IO &, uint16_t C) : Subsystem(COFF::WindowsSubsystem(C)) {}
uint16_t denormalize(IO &) { return Subsystem; }
COFF::WindowsSubsystem Subsystem;
@ -332,12 +356,13 @@ struct NDLLCharacteristics {
NDLLCharacteristics(IO &) : Characteristics(COFF::DLLCharacteristics(0)) {}
NDLLCharacteristics(IO &, uint16_t C)
: Characteristics(COFF::DLLCharacteristics(C)) {}
uint16_t denormalize(IO &) { return Characteristics; }
COFF::DLLCharacteristics Characteristics;
};
}
} // end anonymous namespace
void MappingTraits<COFFYAML::Relocation>::mapping(IO &IO,
COFFYAML::Relocation &Rel) {
@ -509,5 +534,6 @@ void MappingTraits<COFFYAML::Object>::mapping(IO &IO, COFFYAML::Object &Obj) {
IO.mapRequired("symbols", Obj.Symbols);
}
}
}
} // end namespace yaml
} // end namespace llvm

View File

@ -13,9 +13,11 @@
//===----------------------------------------------------------------------===//
#include "llvm/ObjectYAML/CodeViewYAMLDebugSections.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/StringSwitch.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/BinaryFormat/COFF.h"
#include "llvm/DebugInfo/CodeView/CodeView.h"
#include "llvm/DebugInfo/CodeView/CodeViewError.h"
#include "llvm/DebugInfo/CodeView/DebugChecksumsSubsection.h"
#include "llvm/DebugInfo/CodeView/DebugCrossExSubsection.h"
@ -24,15 +26,29 @@
#include "llvm/DebugInfo/CodeView/DebugInlineeLinesSubsection.h"
#include "llvm/DebugInfo/CodeView/DebugLinesSubsection.h"
#include "llvm/DebugInfo/CodeView/DebugStringTableSubsection.h"
#include "llvm/DebugInfo/CodeView/DebugSubsection.h"
#include "llvm/DebugInfo/CodeView/DebugSubsectionVisitor.h"
#include "llvm/DebugInfo/CodeView/DebugSymbolRVASubsection.h"
#include "llvm/DebugInfo/CodeView/DebugSymbolsSubsection.h"
#include "llvm/DebugInfo/CodeView/EnumTables.h"
#include "llvm/DebugInfo/CodeView/Line.h"
#include "llvm/DebugInfo/CodeView/StringsAndChecksums.h"
#include "llvm/DebugInfo/CodeView/SymbolRecord.h"
#include "llvm/DebugInfo/CodeView/SymbolSerializer.h"
#include "llvm/DebugInfo/CodeView/TypeIndex.h"
#include "llvm/ObjectYAML/CodeViewYAMLSymbols.h"
#include "llvm/Support/BinaryStreamWriter.h"
#include "llvm/Support/Allocator.h"
#include "llvm/Support/BinaryStreamReader.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 <memory>
#include <string>
#include <tuple>
#include <vector>
using namespace llvm;
using namespace llvm::codeview;
using namespace llvm::CodeViewYAML;
@ -68,21 +84,25 @@ LLVM_YAML_DECLARE_MAPPING_TRAITS(InlineeSite)
namespace llvm {
namespace CodeViewYAML {
namespace detail {
struct YAMLSubsectionBase {
explicit YAMLSubsectionBase(DebugSubsectionKind Kind) : Kind(Kind) {}
DebugSubsectionKind Kind;
virtual ~YAMLSubsectionBase() {}
virtual ~YAMLSubsectionBase() = default;
virtual void map(IO &IO) = 0;
virtual std::shared_ptr<DebugSubsection>
toCodeViewSubsection(BumpPtrAllocator &Allocator,
const codeview::StringsAndChecksums &SC) const = 0;
DebugSubsectionKind Kind;
};
}
}
}
} // end namespace detail
} // end namespace CodeViewYAML
} // end namespace llvm
namespace {
struct YAMLChecksumsSubsection : public YAMLSubsectionBase {
YAMLChecksumsSubsection()
: YAMLSubsectionBase(DebugSubsectionKind::FileChecksums) {}
@ -213,7 +233,8 @@ struct YAMLCoffSymbolRVASubsection : public YAMLSubsectionBase {
std::vector<uint32_t> RVAs;
};
}
} // end anonymous namespace
void ScalarBitSetTraits<LineFlags>::bitset(IO &io, LineFlags &Flags) {
io.bitSetCase(Flags, "HasColumnInfo", LF_HaveColumns);
@ -741,8 +762,9 @@ llvm::CodeViewYAML::toCodeViewSubsectionList(
}
namespace {
struct SubsectionConversionVisitor : public DebugSubsectionVisitor {
SubsectionConversionVisitor() {}
SubsectionConversionVisitor() = default;
Error visitUnknown(DebugUnknownSubsectionRef &Unknown) override;
Error visitLines(DebugLinesSubsectionRef &Lines,
@ -767,6 +789,8 @@ struct SubsectionConversionVisitor : public DebugSubsectionVisitor {
YAMLDebugSubsection Subsection;
};
} // end anonymous namespace
Error SubsectionConversionVisitor::visitUnknown(
DebugUnknownSubsectionRef &Unknown) {
return make_error<CodeViewError>(cv_error_code::operation_unsupported);
@ -863,7 +887,6 @@ Error SubsectionConversionVisitor::visitCOFFSymbolRVAs(
Subsection.Subsection = *Result;
return Error::success();
}
}
Expected<YAMLDebugSubsection>
YAMLDebugSubsection::fromCodeViewSubection(const StringsAndChecksumsRef &SC,

View File

@ -13,13 +13,25 @@
//===----------------------------------------------------------------------===//
#include "llvm/ObjectYAML/CodeViewYAMLSymbols.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/StringSwitch.h"
#include "llvm/DebugInfo/CodeView/CVTypeVisitor.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/DebugInfo/CodeView/CodeView.h"
#include "llvm/DebugInfo/CodeView/CodeViewError.h"
#include "llvm/DebugInfo/CodeView/EnumTables.h"
#include "llvm/DebugInfo/CodeView/RecordSerialization.h"
#include "llvm/DebugInfo/CodeView/SymbolDeserializer.h"
#include "llvm/DebugInfo/CodeView/SymbolRecord.h"
#include "llvm/DebugInfo/CodeView/SymbolSerializer.h"
#include "llvm/DebugInfo/CodeView/TypeIndex.h"
#include "llvm/ObjectYAML/YAML.h"
#include "llvm/Support/Allocator.h"
#include "llvm/Support/Error.h"
#include "llvm/Support/YAMLTraits.h"
#include <algorithm>
#include <cstdint>
#include <cstring>
#include <string>
#include <vector>
using namespace llvm;
using namespace llvm::codeview;
@ -48,15 +60,16 @@ LLVM_YAML_DECLARE_ENUM_TRAITS(RegisterId)
LLVM_YAML_DECLARE_ENUM_TRAITS(TrampolineType)
LLVM_YAML_DECLARE_ENUM_TRAITS(ThunkOrdinal)
LLVM_YAML_STRONG_TYPEDEF(llvm::StringRef, TypeName)
LLVM_YAML_STRONG_TYPEDEF(StringRef, TypeName)
LLVM_YAML_DECLARE_SCALAR_TRAITS(TypeName, true)
StringRef ScalarTraits<TypeName>::input(StringRef S, void *V, TypeName &T) {
return ScalarTraits<StringRef>::input(S, V, T.value);
}
void ScalarTraits<TypeName>::output(const TypeName &T, void *V,
llvm::raw_ostream &R) {
raw_ostream &R) {
ScalarTraits<StringRef>::output(T.value, V, R);
}
@ -173,9 +186,10 @@ namespace detail {
struct SymbolRecordBase {
codeview::SymbolKind Kind;
explicit SymbolRecordBase(codeview::SymbolKind K) : Kind(K) {}
virtual ~SymbolRecordBase() {}
explicit SymbolRecordBase(codeview::SymbolKind K) : Kind(K) {}
virtual ~SymbolRecordBase() = default;
virtual void map(yaml::IO &io) = 0;
virtual codeview::CVSymbol
toCodeViewSymbol(BumpPtrAllocator &Allocator,
@ -194,6 +208,7 @@ template <typename T> struct SymbolRecordImpl : public SymbolRecordBase {
CodeViewContainer Container) const override {
return SymbolSerializer::writeOneSymbol(Symbol, Allocator, Container);
}
Error fromCodeViewSymbol(codeview::CVSymbol CVS) override {
return SymbolDeserializer::deserializeAs<T>(CVS, Symbol);
}
@ -217,6 +232,7 @@ struct UnknownSymbolRecord : public SymbolRecordBase {
::memcpy(Buffer + sizeof(RecordPrefix), Data.data(), Data.size());
return CVSymbol(Kind, ArrayRef<uint8_t>(Buffer, TotalLen));
}
Error fromCodeViewSymbol(CVSymbol CVS) override {
this->Kind = CVS.kind();
Data = CVS.RecordData.drop_front(sizeof(RecordPrefix));
@ -496,9 +512,10 @@ template <> void SymbolRecordImpl<ThreadLocalDataSym>::map(IO &IO) {
IO.mapOptional("Segment", Symbol.Segment, uint16_t(0));
IO.mapRequired("DisplayName", Symbol.Name);
}
}
}
}
} // end namespace detail
} // end namespace CodeViewYAML
} // end namespace llvm
CVSymbol CodeViewYAML::SymbolRecord::toCodeViewSymbol(
BumpPtrAllocator &Allocator, CodeViewContainer Container) const {
@ -507,11 +524,13 @@ CVSymbol CodeViewYAML::SymbolRecord::toCodeViewSymbol(
namespace llvm {
namespace yaml {
template <> struct MappingTraits<SymbolRecordBase> {
static void mapping(IO &io, SymbolRecordBase &Record) { Record.map(io); }
};
}
}
} // end namespace yaml
} // end namespace llvm
template <typename SymbolType>
static inline Expected<CodeViewYAML::SymbolRecord>

View File

@ -13,14 +13,29 @@
//===----------------------------------------------------------------------===//
#include "llvm/ObjectYAML/CodeViewYAMLTypes.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/StringSwitch.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/CVTypeVisitor.h"
#include "llvm/DebugInfo/CodeView/CodeView.h"
#include "llvm/DebugInfo/CodeView/CodeViewError.h"
#include "llvm/DebugInfo/CodeView/EnumTables.h"
#include "llvm/DebugInfo/CodeView/TypeDeserializer.h"
#include "llvm/DebugInfo/CodeView/TypeIndex.h"
#include "llvm/DebugInfo/CodeView/TypeTableBuilder.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>
using namespace llvm;
using namespace llvm::codeview;
@ -62,9 +77,10 @@ namespace detail {
struct LeafRecordBase {
TypeLeafKind Kind;
explicit LeafRecordBase(TypeLeafKind K) : Kind(K) {}
virtual ~LeafRecordBase() {}
explicit LeafRecordBase(TypeLeafKind K) : Kind(K) {}
virtual ~LeafRecordBase() = default;
virtual void map(yaml::IO &io) = 0;
virtual CVType toCodeViewRecord(TypeTableBuilder &TTB) const = 0;
virtual Error fromCodeViewRecord(CVType Type) = 0;
@ -100,9 +116,10 @@ template <> struct LeafRecordImpl<FieldListRecord> : public LeafRecordBase {
struct MemberRecordBase {
TypeLeafKind Kind;
explicit MemberRecordBase(TypeLeafKind K) : Kind(K) {}
virtual ~MemberRecordBase() {}
explicit MemberRecordBase(TypeLeafKind K) : Kind(K) {}
virtual ~MemberRecordBase() = default;
virtual void map(yaml::IO &io) = 0;
virtual void writeTo(FieldListRecordBuilder &FLRB) = 0;
};
@ -110,6 +127,7 @@ struct MemberRecordBase {
template <typename T> struct MemberRecordImpl : public MemberRecordBase {
explicit MemberRecordImpl(TypeLeafKind K)
: MemberRecordBase(K), Record(static_cast<TypeRecordKind>(K)) {}
void map(yaml::IO &io) override;
void writeTo(FieldListRecordBuilder &FLRB) override {
@ -118,12 +136,13 @@ template <typename T> struct MemberRecordImpl : public MemberRecordBase {
mutable T Record;
};
}
}
}
} // end namespace detail
} // end namespace CodeViewYAML
} // end namespace llvm
void ScalarTraits<TypeIndex>::output(const TypeIndex &S, void *,
llvm::raw_ostream &OS) {
raw_ostream &OS) {
OS << S.getIndex();
}
@ -135,8 +154,7 @@ StringRef ScalarTraits<TypeIndex>::input(StringRef Scalar, void *Ctx,
return Result;
}
void ScalarTraits<APSInt>::output(const APSInt &S, void *,
llvm::raw_ostream &OS) {
void ScalarTraits<APSInt>::output(const APSInt &S, void *, raw_ostream &OS) {
S.print(OS, S.isSigned());
}
@ -345,6 +363,7 @@ void MappingTraits<MemberPointerInfo>::mapping(IO &IO, MemberPointerInfo &MPI) {
namespace llvm {
namespace CodeViewYAML {
namespace detail {
template <> void LeafRecordImpl<ModifierRecord>::map(IO &IO) {
IO.mapRequired("ModifiedType", Record.ModifiedType);
IO.mapRequired("Modifiers", Record.Modifiers);
@ -403,11 +422,13 @@ template <> void LeafRecordImpl<ArrayRecord>::map(IO &IO) {
void LeafRecordImpl<FieldListRecord>::map(IO &IO) {
IO.mapRequired("FieldList", Members);
}
}
}
}
} // end namespace detail
} // end namespace CodeViewYAML
} // end namespace llvm
namespace {
class MemberRecordConversionVisitor : public TypeVisitorCallbacks {
public:
explicit MemberRecordConversionVisitor(std::vector<MemberRecord> &Records)
@ -432,7 +453,8 @@ private:
std::vector<MemberRecord> &Records;
};
}
} // end anonymous namespace
Error LeafRecordImpl<FieldListRecord>::fromCodeViewRecord(CVType Type) {
MemberRecordConversionVisitor V(Members);
@ -460,13 +482,13 @@ void MappingTraits<OneMethodRecord>::mapping(IO &io, OneMethodRecord &Record) {
namespace llvm {
namespace CodeViewYAML {
namespace detail {
template <> void LeafRecordImpl<ClassRecord>::map(IO &IO) {
IO.mapRequired("MemberCount", Record.MemberCount);
IO.mapRequired("Options", Record.Options);
IO.mapRequired("FieldList", Record.FieldList);
IO.mapRequired("Name", Record.Name);
IO.mapRequired("UniqueName", Record.UniqueName);
IO.mapRequired("DerivationList", Record.DerivationList);
IO.mapRequired("VTableShape", Record.VTableShape);
IO.mapRequired("Size", Record.Size);
@ -478,7 +500,6 @@ template <> void LeafRecordImpl<UnionRecord>::map(IO &IO) {
IO.mapRequired("FieldList", Record.FieldList);
IO.mapRequired("Name", Record.Name);
IO.mapRequired("UniqueName", Record.UniqueName);
IO.mapRequired("Size", Record.Size);
}
@ -488,7 +509,6 @@ template <> void LeafRecordImpl<EnumRecord>::map(IO &IO) {
IO.mapRequired("FieldList", Record.FieldList);
IO.mapRequired("Name", Record.Name);
IO.mapRequired("UniqueName", Record.UniqueName);
IO.mapRequired("UnderlyingType", Record.UnderlyingType);
}
@ -602,9 +622,10 @@ template <> void MemberRecordImpl<VirtualBaseClassRecord>::map(IO &IO) {
template <> void MemberRecordImpl<ListContinuationRecord>::map(IO &IO) {
IO.mapRequired("ContinuationIndex", Record.ContinuationIndex);
}
}
}
}
} // end namespace detail
} // end namespace CodeViewYAML
} // end namespace llvm
template <typename T>
static inline Expected<LeafRecord> fromCodeViewRecordImpl(CVType Type) {
@ -627,7 +648,8 @@ Expected<LeafRecord> LeafRecord::fromCodeViewRecord(CVType Type) {
#define MEMBER_RECORD_ALIAS(EnumName, EnumVal, AliasName, ClassName)
switch (Type.kind()) {
#include "llvm/DebugInfo/CodeView/CodeViewTypes.def"
default: { llvm_unreachable("Unknown leaf kind!"); }
default:
llvm_unreachable("Unknown leaf kind!");
}
return make_error<CodeViewError>(cv_error_code::corrupt_record);
}
@ -643,6 +665,7 @@ CVType LeafRecord::toCodeViewRecord(TypeTableBuilder &TTB) const {
namespace llvm {
namespace yaml {
template <> struct MappingTraits<LeafRecordBase> {
static void mapping(IO &io, LeafRecordBase &Record) { Record.map(io); }
};
@ -650,8 +673,9 @@ template <> struct MappingTraits<LeafRecordBase> {
template <> struct MappingTraits<MemberRecordBase> {
static void mapping(IO &io, MemberRecordBase &Record) { Record.map(io); }
};
}
}
} // end namespace yaml
} // end namespace llvm
template <typename ConcreteType>
static void mapLeafRecordImpl(IO &IO, const char *Class, TypeLeafKind Kind,

View File

@ -13,15 +13,25 @@
//===----------------------------------------------------------------------===//
#include "llvm/ObjectYAML/DWARFEmitter.h"
#include "DWARFVisitor.h"
#include "llvm/ADT/StringMap.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/ObjectYAML/DWARFYAML.h"
#include "llvm/Support/Error.h"
#include "llvm/Support/Host.h"
#include "llvm/Support/LEB128.h"
#include "llvm/Support/MathExtras.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/SwapByteOrder.h"
#include "llvm/Support/YAMLTraits.h"
#include "llvm/Support/raw_ostream.h"
#include "DWARFVisitor.h"
#include <algorithm>
#include <cassert>
#include <cstddef>
#include <cstdint>
#include <memory>
#include <string>
#include <vector>
using namespace llvm;
@ -127,7 +137,7 @@ class DumpVisitor : public DWARFYAML::ConstVisitor {
raw_ostream &OS;
protected:
virtual void onStartCompileUnit(const DWARFYAML::Unit &CU) {
void onStartCompileUnit(const DWARFYAML::Unit &CU) override {
writeInitialLength(CU.Length, OS, DebugInfo.IsLittleEndian);
writeInteger((uint16_t)CU.Version, OS, DebugInfo.IsLittleEndian);
if(CU.Version >= 5) {
@ -141,41 +151,43 @@ protected:
}
virtual void onStartDIE(const DWARFYAML::Unit &CU,
const DWARFYAML::Entry &DIE) {
void onStartDIE(const DWARFYAML::Unit &CU,
const DWARFYAML::Entry &DIE) override {
encodeULEB128(DIE.AbbrCode, OS);
}
virtual void onValue(const uint8_t U) {
void onValue(const uint8_t U) override {
writeInteger(U, OS, DebugInfo.IsLittleEndian);
}
virtual void onValue(const uint16_t U) {
void onValue(const uint16_t U) override {
writeInteger(U, OS, DebugInfo.IsLittleEndian);
}
virtual void onValue(const uint32_t U) {
void onValue(const uint32_t U) override {
writeInteger(U, OS, DebugInfo.IsLittleEndian);
}
virtual void onValue(const uint64_t U, const bool LEB = false) {
void onValue(const uint64_t U, const bool LEB = false) override {
if (LEB)
encodeULEB128(U, OS);
else
writeInteger(U, OS, DebugInfo.IsLittleEndian);
}
virtual void onValue(const int64_t S, const bool LEB = false) {
void onValue(const int64_t S, const bool LEB = false) override {
if (LEB)
encodeSLEB128(S, OS);
else
writeInteger(S, OS, DebugInfo.IsLittleEndian);
}
virtual void onValue(const StringRef String) {
void onValue(const StringRef String) override {
OS.write(String.data(), String.size());
OS.write('\0');
}
virtual void onValue(const MemoryBufferRef MBR) {
void onValue(const MemoryBufferRef MBR) override {
OS.write(MBR.getBufferStart(), MBR.getBufferSize());
}
@ -280,7 +292,7 @@ void DWARFYAML::EmitDebugLine(raw_ostream &OS, const DWARFYAML::Data &DI) {
}
}
typedef void (*EmitFuncType)(raw_ostream &, const DWARFYAML::Data &);
using EmitFuncType = void (*)(raw_ostream &, const DWARFYAML::Data &);
static void
EmitDebugSectionImpl(const DWARFYAML::Data &DI, EmitFuncType EmitFunc,

View File

@ -171,6 +171,6 @@ void MappingTraits<DWARFYAML::InitialLength>::mapping(
IO.mapRequired("TotalLength64", InitialLength.TotalLength64);
}
} // namespace llvm::yaml
} // end namespace yaml
} // namespace llvm
} // end namespace llvm

View File

@ -12,12 +12,18 @@
//===----------------------------------------------------------------------===//
#include "llvm/ObjectYAML/ELFYAML.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/BinaryFormat/ELF.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/MipsABIFlags.h"
#include "llvm/Support/YAMLTraits.h"
#include <cassert>
#include <cstdint>
namespace llvm {
ELFYAML::Section::~Section() {}
ELFYAML::Section::~Section() = default;
namespace yaml {
@ -644,6 +650,7 @@ void MappingTraits<ELFYAML::FileHeader>::mapping(IO &IO,
}
namespace {
struct NormalizedOther {
NormalizedOther(IO &)
: Visibility(ELFYAML::ELF_STV(0)), Other(ELFYAML::ELF_STO(0)) {}
@ -655,7 +662,8 @@ struct NormalizedOther {
ELFYAML::ELF_STV Visibility;
ELFYAML::ELF_STO Other;
};
}
} // end anonymous namespace
void MappingTraits<ELFYAML::Symbol>::mapping(IO &IO, ELFYAML::Symbol &Symbol) {
IO.mapOptional("Name", Symbol.Name, StringRef());
@ -778,6 +786,7 @@ StringRef MappingTraits<std::unique_ptr<ELFYAML::Section>>::validate(
}
namespace {
struct NormalizedMips64RelType {
NormalizedMips64RelType(IO &)
: Type(ELFYAML::ELF_REL(ELF::R_MIPS_NONE)),
@ -798,7 +807,8 @@ struct NormalizedMips64RelType {
ELFYAML::ELF_REL Type3;
ELFYAML::ELF_RSS SpecSym;
};
}
} // end anonymous namespace
void MappingTraits<ELFYAML::Relocation>::mapping(IO &IO,
ELFYAML::Relocation &Rel) {
@ -839,4 +849,5 @@ LLVM_YAML_STRONG_TYPEDEF(uint32_t, MIPS_AFL_ASE)
LLVM_YAML_STRONG_TYPEDEF(uint32_t, MIPS_AFL_FLAGS1)
} // end namespace yaml
} // end namespace llvm

View File

@ -12,16 +12,19 @@
//===----------------------------------------------------------------------===//
#include "llvm/ObjectYAML/MachOYAML.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/BinaryFormat/MachO.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/Format.h"
#include "llvm/Support/Host.h"
#include <string.h> // For memcpy, memset and strnlen.
#include "llvm/Support/YAMLTraits.h"
#include "llvm/Support/raw_ostream.h"
#include <cinttypes>
#include <cstdint>
#include <cstring>
namespace llvm {
MachOYAML::LoadCommand::~LoadCommand() {}
MachOYAML::LoadCommand::~LoadCommand() = default;
bool MachOYAML::LinkEditData::isEmpty() const {
return 0 ==
@ -33,7 +36,7 @@ bool MachOYAML::LinkEditData::isEmpty() const {
namespace yaml {
void ScalarTraits<char_16>::output(const char_16 &Val, void *,
llvm::raw_ostream &Out) {
raw_ostream &Out) {
auto Len = strnlen(&Val[0], 16);
Out << StringRef(&Val[0], Len);
}
@ -51,8 +54,7 @@ StringRef ScalarTraits<char_16>::input(StringRef Scalar, void *, char_16 &Val) {
bool ScalarTraits<char_16>::mustQuote(StringRef S) { return needsQuotes(S); }
void ScalarTraits<uuid_t>::output(const uuid_t &Val, void *,
llvm::raw_ostream &Out) {
void ScalarTraits<uuid_t>::output(const uuid_t &Val, void *, raw_ostream &Out) {
for (int Idx = 0; Idx < 16; ++Idx) {
Out << format("%02" PRIX32, Val[Idx]);
if (Idx == 3 || Idx == 5 || Idx == 7 || Idx == 9)
@ -154,7 +156,7 @@ void MappingTraits<MachOYAML::LinkEditData>::mapping(
IO.mapOptional("BindOpcodes", LinkEditData.BindOpcodes);
IO.mapOptional("WeakBindOpcodes", LinkEditData.WeakBindOpcodes);
IO.mapOptional("LazyBindOpcodes", LinkEditData.LazyBindOpcodes);
if(LinkEditData.ExportTrie.Children.size() > 0 || !IO.outputting())
if (!LinkEditData.ExportTrie.Children.empty() || !IO.outputting())
IO.mapOptional("ExportTrie", LinkEditData.ExportTrie);
IO.mapOptional("NameList", LinkEditData.NameList);
IO.mapOptional("StringTable", LinkEditData.StringTable);
@ -308,13 +310,11 @@ void MappingTraits<MachO::dylib_command>::mapping(
void MappingTraits<MachO::dylinker_command>::mapping(
IO &IO, MachO::dylinker_command &LoadCommand) {
IO.mapRequired("name", LoadCommand.name);
}
void MappingTraits<MachO::dysymtab_command>::mapping(
IO &IO, MachO::dysymtab_command &LoadCommand) {
IO.mapRequired("ilocalsym", LoadCommand.ilocalsym);
IO.mapRequired("nlocalsym", LoadCommand.nlocalsym);
IO.mapRequired("iextdefsym", LoadCommand.iextdefsym);
@ -337,7 +337,6 @@ void MappingTraits<MachO::dysymtab_command>::mapping(
void MappingTraits<MachO::encryption_info_command>::mapping(
IO &IO, MachO::encryption_info_command &LoadCommand) {
IO.mapRequired("cryptoff", LoadCommand.cryptoff);
IO.mapRequired("cryptsize", LoadCommand.cryptsize);
IO.mapRequired("cryptid", LoadCommand.cryptid);
@ -345,7 +344,6 @@ void MappingTraits<MachO::encryption_info_command>::mapping(
void MappingTraits<MachO::encryption_info_command_64>::mapping(
IO &IO, MachO::encryption_info_command_64 &LoadCommand) {
IO.mapRequired("cryptoff", LoadCommand.cryptoff);
IO.mapRequired("cryptsize", LoadCommand.cryptsize);
IO.mapRequired("cryptid", LoadCommand.cryptid);
@ -354,14 +352,12 @@ void MappingTraits<MachO::encryption_info_command_64>::mapping(
void MappingTraits<MachO::entry_point_command>::mapping(
IO &IO, MachO::entry_point_command &LoadCommand) {
IO.mapRequired("entryoff", LoadCommand.entryoff);
IO.mapRequired("stacksize", LoadCommand.stacksize);
}
void MappingTraits<MachO::fvmfile_command>::mapping(
IO &IO, MachO::fvmfile_command &LoadCommand) {
IO.mapRequired("name", LoadCommand.name);
IO.mapRequired("header_addr", LoadCommand.header_addr);
}
@ -374,7 +370,6 @@ void MappingTraits<MachO::fvmlib>::mapping(IO &IO, MachO::fvmlib &FVMLib) {
void MappingTraits<MachO::fvmlib_command>::mapping(
IO &IO, MachO::fvmlib_command &LoadCommand) {
IO.mapRequired("fvmlib", LoadCommand.fvmlib);
}
@ -383,20 +378,17 @@ void MappingTraits<MachO::ident_command>::mapping(
void MappingTraits<MachO::linkedit_data_command>::mapping(
IO &IO, MachO::linkedit_data_command &LoadCommand) {
IO.mapRequired("dataoff", LoadCommand.dataoff);
IO.mapRequired("datasize", LoadCommand.datasize);
}
void MappingTraits<MachO::linker_option_command>::mapping(
IO &IO, MachO::linker_option_command &LoadCommand) {
IO.mapRequired("count", LoadCommand.count);
}
void MappingTraits<MachO::prebind_cksum_command>::mapping(
IO &IO, MachO::prebind_cksum_command &LoadCommand) {
IO.mapRequired("cksum", LoadCommand.cksum);
}
@ -405,7 +397,6 @@ void MappingTraits<MachO::load_command>::mapping(
void MappingTraits<MachO::prebound_dylib_command>::mapping(
IO &IO, MachO::prebound_dylib_command &LoadCommand) {
IO.mapRequired("name", LoadCommand.name);
IO.mapRequired("nmodules", LoadCommand.nmodules);
IO.mapRequired("linked_modules", LoadCommand.linked_modules);
@ -413,7 +404,6 @@ void MappingTraits<MachO::prebound_dylib_command>::mapping(
void MappingTraits<MachO::routines_command>::mapping(
IO &IO, MachO::routines_command &LoadCommand) {
IO.mapRequired("init_address", LoadCommand.init_address);
IO.mapRequired("init_module", LoadCommand.init_module);
IO.mapRequired("reserved1", LoadCommand.reserved1);
@ -426,7 +416,6 @@ void MappingTraits<MachO::routines_command>::mapping(
void MappingTraits<MachO::routines_command_64>::mapping(
IO &IO, MachO::routines_command_64 &LoadCommand) {
IO.mapRequired("init_address", LoadCommand.init_address);
IO.mapRequired("init_module", LoadCommand.init_module);
IO.mapRequired("reserved1", LoadCommand.reserved1);
@ -439,7 +428,6 @@ void MappingTraits<MachO::routines_command_64>::mapping(
void MappingTraits<MachO::rpath_command>::mapping(
IO &IO, MachO::rpath_command &LoadCommand) {
IO.mapRequired("path", LoadCommand.path);
}
@ -475,7 +463,6 @@ void MappingTraits<MachO::section_64>::mapping(IO &IO,
void MappingTraits<MachO::segment_command>::mapping(
IO &IO, MachO::segment_command &LoadCommand) {
IO.mapRequired("segname", LoadCommand.segname);
IO.mapRequired("vmaddr", LoadCommand.vmaddr);
IO.mapRequired("vmsize", LoadCommand.vmsize);
@ -489,7 +476,6 @@ void MappingTraits<MachO::segment_command>::mapping(
void MappingTraits<MachO::segment_command_64>::mapping(
IO &IO, MachO::segment_command_64 &LoadCommand) {
IO.mapRequired("segname", LoadCommand.segname);
IO.mapRequired("vmaddr", LoadCommand.vmaddr);
IO.mapRequired("vmsize", LoadCommand.vmsize);
@ -503,44 +489,37 @@ void MappingTraits<MachO::segment_command_64>::mapping(
void MappingTraits<MachO::source_version_command>::mapping(
IO &IO, MachO::source_version_command &LoadCommand) {
IO.mapRequired("version", LoadCommand.version);
}
void MappingTraits<MachO::sub_client_command>::mapping(
IO &IO, MachO::sub_client_command &LoadCommand) {
IO.mapRequired("client", LoadCommand.client);
}
void MappingTraits<MachO::sub_framework_command>::mapping(
IO &IO, MachO::sub_framework_command &LoadCommand) {
IO.mapRequired("umbrella", LoadCommand.umbrella);
}
void MappingTraits<MachO::sub_library_command>::mapping(
IO &IO, MachO::sub_library_command &LoadCommand) {
IO.mapRequired("sub_library", LoadCommand.sub_library);
}
void MappingTraits<MachO::sub_umbrella_command>::mapping(
IO &IO, MachO::sub_umbrella_command &LoadCommand) {
IO.mapRequired("sub_umbrella", LoadCommand.sub_umbrella);
}
void MappingTraits<MachO::symseg_command>::mapping(
IO &IO, MachO::symseg_command &LoadCommand) {
IO.mapRequired("offset", LoadCommand.offset);
IO.mapRequired("size", LoadCommand.size);
}
void MappingTraits<MachO::symtab_command>::mapping(
IO &IO, MachO::symtab_command &LoadCommand) {
IO.mapRequired("symoff", LoadCommand.symoff);
IO.mapRequired("nsyms", LoadCommand.nsyms);
IO.mapRequired("stroff", LoadCommand.stroff);
@ -552,27 +531,23 @@ void MappingTraits<MachO::thread_command>::mapping(
void MappingTraits<MachO::twolevel_hints_command>::mapping(
IO &IO, MachO::twolevel_hints_command &LoadCommand) {
IO.mapRequired("offset", LoadCommand.offset);
IO.mapRequired("nhints", LoadCommand.nhints);
}
void MappingTraits<MachO::uuid_command>::mapping(
IO &IO, MachO::uuid_command &LoadCommand) {
IO.mapRequired("uuid", LoadCommand.uuid);
}
void MappingTraits<MachO::version_min_command>::mapping(
IO &IO, MachO::version_min_command &LoadCommand) {
IO.mapRequired("version", LoadCommand.version);
IO.mapRequired("sdk", LoadCommand.sdk);
}
void MappingTraits<MachO::note_command>::mapping(
IO &IO, MachO::note_command &LoadCommand) {
IO.mapRequired("data_owner", LoadCommand.data_owner);
IO.mapRequired("offset", LoadCommand.offset);
IO.mapRequired("size", LoadCommand.size);
@ -580,13 +555,12 @@ void MappingTraits<MachO::note_command>::mapping(
void MappingTraits<MachO::build_version_command>::mapping(
IO &IO, MachO::build_version_command &LoadCommand) {
IO.mapRequired("platform", LoadCommand.platform);
IO.mapRequired("minos", LoadCommand.minos);
IO.mapRequired("sdk", LoadCommand.sdk);
IO.mapRequired("ntools", LoadCommand.ntools);
}
} // namespace llvm::yaml
} // end namespace yaml
} // namespace llvm
} // end namespace llvm

View File

@ -12,7 +12,10 @@
//===----------------------------------------------------------------------===//
#include "llvm/ObjectYAML/ObjectYAML.h"
#include "llvm/ObjectYAML/YAML.h"
#include "llvm/ADT/Twine.h"
#include "llvm/Support/YAMLParser.h"
#include "llvm/Support/YAMLTraits.h"
#include <string>
using namespace llvm;
using namespace yaml;
@ -53,8 +56,8 @@ void MappingTraits<YamlObjectFile>::mapping(IO &IO,
IO.setError("YAML Object File missing document type tag!");
else
IO.setError(
llvm::Twine("YAML Object File unsupported document type tag '") +
llvm::Twine(Tag) + llvm::Twine("'!"));
Twine("YAML Object File unsupported document type tag '") +
Twine(Tag) + Twine("'!"));
}
}
}

View File

@ -12,9 +12,10 @@
//===----------------------------------------------------------------------===//
#include "llvm/ObjectYAML/WasmYAML.h"
#include "llvm/Object/Wasm.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/MipsABIFlags.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/YAMLTraits.h"
namespace llvm {
@ -22,7 +23,7 @@ namespace WasmYAML {
// Declared here rather than in the header to comply with:
// http://llvm.org/docs/CodingStandards.html#provide-a-virtual-method-anchor-for-classes-in-headers
Section::~Section() {}
Section::~Section() = default;
} // end namespace WasmYAML
@ -405,4 +406,5 @@ void ScalarEnumerationTraits<WasmYAML::RelocType>::enumeration(
}
} // end namespace yaml
} // end namespace llvm

View File

@ -16,11 +16,12 @@
#include "llvm/ADT/StringExtras.h"
#include "llvm/Support/raw_ostream.h"
#include <cctype>
#include <cstdint>
using namespace llvm;
void yaml::ScalarTraits<yaml::BinaryRef>::output(
const yaml::BinaryRef &Val, void *, llvm::raw_ostream &Out) {
const yaml::BinaryRef &Val, void *, raw_ostream &Out) {
Val.writeAsHex(Out);
}
@ -34,7 +35,7 @@ StringRef yaml::ScalarTraits<yaml::BinaryRef>::input(StringRef Scalar, void *,
if (!isxdigit(Scalar[I]))
return "BinaryRef hex string must contain only hex digits.";
Val = yaml::BinaryRef(Scalar);
return StringRef();
return {};
}
void yaml::BinaryRef::writeAsBinary(raw_ostream &OS) const {