diff --git a/include/llvm/ObjectYAML/COFFYAML.h b/include/llvm/ObjectYAML/COFFYAML.h index 719cb1acf6e..bbceefac3d9 100644 --- a/include/llvm/ObjectYAML/COFFYAML.h +++ b/include/llvm/ObjectYAML/COFFYAML.h @@ -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 +#include namespace llvm { namespace COFF { + inline Characteristics operator|(Characteristics a, Characteristics b) { uint32_t Ret = static_cast(a) | static_cast(b); return static_cast(Ret); @@ -39,60 +43,67 @@ inline DLLCharacteristics operator|(DLLCharacteristics a, uint16_t Ret = static_cast(a) | static_cast(b); return static_cast(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 DebugS; - std::vector DebugT; - std::vector 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 FunctionDefinition; - Optional bfAndefSymbol; - Optional WeakExternal; - StringRef File; - Optional SectionDefinition; - Optional CLRToken; - StringRef Name; - Symbol(); - }; +struct Section { + COFF::section Header; + unsigned Alignment = 0; + yaml::BinaryRef SectionData; + std::vector DebugS; + std::vector DebugT; + std::vector Relocations; + StringRef Name; - struct PEHeader { - COFF::PE32Header Header; - Optional DataDirectories[COFF::NUM_DATA_DIRECTORIES]; - }; + Section(); +}; - struct Object { - Optional OptionalHeader; - COFF::header Header; - std::vector
Sections; - std::vector Symbols; - Object(); - }; -} -} +struct Symbol { + COFF::symbol Header; + COFF::SymbolBaseType SimpleType = COFF::IMAGE_SYM_TYPE_NULL; + COFF::SymbolComplexType ComplexType = COFF::IMAGE_SYM_DTYPE_NULL; + Optional FunctionDefinition; + Optional bfAndefSymbol; + Optional WeakExternal; + StringRef File; + Optional SectionDefinition; + Optional CLRToken; + StringRef Name; + + Symbol(); +}; + +struct PEHeader { + COFF::PE32Header Header; + Optional DataDirectories[COFF::NUM_DATA_DIRECTORIES]; +}; + +struct Object { + Optional OptionalHeader; + COFF::header Header; + std::vector
Sections; + std::vector 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 { } // end namespace yaml } // end namespace llvm -#endif +#endif // LLVM_OBJECTYAML_COFFYAML_H diff --git a/include/llvm/ObjectYAML/CodeViewYAMLDebugSections.h b/include/llvm/ObjectYAML/CodeViewYAMLDebugSections.h index 8180e0fc83f..d620008e22d 100644 --- a/include/llvm/ObjectYAML/CodeViewYAMLDebugSections.h +++ b/include/llvm/ObjectYAML/CodeViewYAMLDebugSections.h @@ -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 +#include +#include 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 Blocks; }; @@ -124,11 +129,12 @@ fromDebugS(ArrayRef Data, const codeview::StringsAndChecksumsRef &SC); void initializeStringsAndChecksums(ArrayRef 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 diff --git a/include/llvm/ObjectYAML/CodeViewYAMLSymbols.h b/include/llvm/ObjectYAML/CodeViewYAMLSymbols.h index 9b411e8b074..791193c78f1 100644 --- a/include/llvm/ObjectYAML/CodeViewYAMLSymbols.h +++ b/include/llvm/ObjectYAML/CodeViewYAMLSymbols.h @@ -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 namespace llvm { namespace CodeViewYAML { + namespace detail { + struct SymbolRecordBase; -} + +} // end namespace detail struct SymbolRecord { std::shared_ptr Symbol; @@ -31,13 +36,14 @@ struct SymbolRecord { codeview::CVSymbol toCodeViewSymbol(BumpPtrAllocator &Allocator, codeview::CodeViewContainer Container) const; + static Expected 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 diff --git a/include/llvm/ObjectYAML/CodeViewYAMLTypes.h b/include/llvm/ObjectYAML/CodeViewYAMLTypes.h index e97d5f92bf7..6746fd60b6c 100644 --- a/include/llvm/ObjectYAML/CodeViewYAMLTypes.h +++ b/include/llvm/ObjectYAML/CodeViewYAMLTypes.h @@ -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 +#include +#include 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 Member; @@ -44,8 +55,10 @@ struct LeafRecord { std::vector fromDebugT(ArrayRef DebugT); ArrayRef toDebugT(ArrayRef, 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 diff --git a/include/llvm/ObjectYAML/DWARFEmitter.h b/include/llvm/ObjectYAML/DWARFEmitter.h index ce231cc0ce6..0d7d8b4efbd 100644 --- a/include/llvm/ObjectYAML/DWARFEmitter.h +++ b/include/llvm/ObjectYAML/DWARFEmitter.h @@ -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 -#include 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>> EmitDebugSections(StringRef YAMLString, bool IsLittleEndian = sys::IsLittleEndianHost); -} // namespace DWARFYAML -} // namespace llvm +} // end namespace DWARFYAML -#endif +} // end namespace llvm + +#endif // LLVM_OBJECTYAML_DWARFEMITTER_H diff --git a/include/llvm/ObjectYAML/DWARFYAML.h b/include/llvm/ObjectYAML/DWARFYAML.h index d451b1537f9..2162f0fef85 100644 --- a/include/llvm/ObjectYAML/DWARFYAML.h +++ b/include/llvm/ObjectYAML/DWARFYAML.h @@ -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 +#include 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 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 { } }; -} // namespace llvm::yaml -} // namespace llvm +} // end namespace yaml +} // end namespace llvm -#endif +#endif // LLVM_OBJECTYAML_DWARFYAML_H diff --git a/include/llvm/ObjectYAML/ELFYAML.h b/include/llvm/ObjectYAML/ELFYAML.h index 9d62ec27ad3..ed455311696 100644 --- a/include/llvm/ObjectYAML/ELFYAML.h +++ b/include/llvm/ObjectYAML/ELFYAML.h @@ -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 +#include +#include 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 Local; std::vector 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 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 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 { } // end namespace yaml } // end namespace llvm -#endif +#endif // LLVM_OBJECTYAML_ELFYAML_H diff --git a/include/llvm/ObjectYAML/MachOYAML.h b/include/llvm/ObjectYAML/MachOYAML.h index 47e065966c1..305497b6aa6 100644 --- a/include/llvm/ObjectYAML/MachOYAML.h +++ b/include/llvm/ObjectYAML/MachOYAML.h @@ -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 +#include +#include namespace llvm { namespace MachOYAML { @@ -51,6 +55,7 @@ struct FileHeader { struct LoadCommand { virtual ~LoadCommand(); + llvm::MachO::macho_load_command Data; std::vector
Sections; std::vector 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 Children; }; @@ -135,8 +138,8 @@ struct UniversalBinary { std::vector 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 { @@ -250,22 +256,20 @@ template <> struct ScalarEnumerationTraits { }; // 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 { - 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 { - 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 { 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 diff --git a/include/llvm/ObjectYAML/ObjectYAML.h b/include/llvm/ObjectYAML/ObjectYAML.h index 36d6ed5417c..00ce86430fc 100644 --- a/include/llvm/ObjectYAML/ObjectYAML.h +++ b/include/llvm/ObjectYAML/ObjectYAML.h @@ -15,10 +15,13 @@ #include "llvm/ObjectYAML/MachOYAML.h" #include "llvm/ObjectYAML/WasmYAML.h" #include "llvm/Support/YAMLTraits.h" +#include namespace llvm { namespace yaml { +class IO; + struct YamlObjectFile { std::unique_ptr Elf; std::unique_ptr Coff; @@ -31,7 +34,7 @@ template <> struct MappingTraits { static void mapping(IO &IO, YamlObjectFile &ObjectFile); }; -} // namespace yaml -} // namespace llvm +} // end namespace yaml +} // end namespace llvm -#endif +#endif // LLVM_OBJECTYAML_OBJECTYAML_H diff --git a/include/llvm/ObjectYAML/WasmYAML.h b/include/llvm/ObjectYAML/WasmYAML.h index cffed7414fd..6bf08d340ee 100644 --- a/include/llvm/ObjectYAML/WasmYAML.h +++ b/include/llvm/ObjectYAML/WasmYAML.h @@ -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 +#include +#include 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 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(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(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 { } // end namespace yaml } // end namespace llvm -#endif +#endif // LLVM_OBJECTYAML_WASMYAML_H diff --git a/include/llvm/ObjectYAML/YAML.h b/include/llvm/ObjectYAML/YAML.h index 7f6836809b6..29151a269df 100644 --- a/include/llvm/ObjectYAML/YAML.h +++ b/include/llvm/ObjectYAML/YAML.h @@ -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 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 Data; + /// \brief Discriminator between the two states of the `Data` member. - bool DataIsHexString; + bool DataIsHexString = true; public: + BinaryRef() = default; BinaryRef(ArrayRef Data) : Data(Data), DataIsHexString(false) {} BinaryRef(StringRef Data) - : Data(reinterpret_cast(Data.data()), Data.size()), - DataIsHexString(true) {} - BinaryRef() : DataIsHexString(true) {} + : Data(reinterpret_cast(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::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 { - 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 diff --git a/lib/ObjectYAML/COFFYAML.cpp b/lib/ObjectYAML/COFFYAML.cpp index c8cbea1490f..1103159fc98 100644 --- a/lib/ObjectYAML/COFFYAML.cpp +++ b/lib/ObjectYAML/COFFYAML.cpp @@ -12,17 +12,25 @@ //===----------------------------------------------------------------------===// #include "llvm/ObjectYAML/COFFYAML.h" +#include "llvm/ADT/StringRef.h" +#include "llvm/Support/YAMLTraits.h" +#include +#include #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::enumeration( IO &IO, COFFYAML::COMDATType &Value) { IO.enumCase(Value, "0", 0); @@ -172,20 +180,20 @@ void ScalarEnumerationTraits::enumeration( void ScalarEnumerationTraits::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::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 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::mapping(IO &IO, COFFYAML::Relocation &Rel) { @@ -509,5 +534,6 @@ void MappingTraits::mapping(IO &IO, COFFYAML::Object &Obj) { IO.mapRequired("symbols", Obj.Symbols); } -} -} +} // end namespace yaml + +} // end namespace llvm diff --git a/lib/ObjectYAML/CodeViewYAMLDebugSections.cpp b/lib/ObjectYAML/CodeViewYAMLDebugSections.cpp index bda43d69943..60b0ea28030 100644 --- a/lib/ObjectYAML/CodeViewYAMLDebugSections.cpp +++ b/lib/ObjectYAML/CodeViewYAMLDebugSections.cpp @@ -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 +#include +#include +#include +#include +#include +#include + 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 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 RVAs; }; -} + +} // end anonymous namespace void ScalarBitSetTraits::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(cv_error_code::operation_unsupported); @@ -863,7 +887,6 @@ Error SubsectionConversionVisitor::visitCOFFSymbolRVAs( Subsection.Subsection = *Result; return Error::success(); } -} Expected YAMLDebugSubsection::fromCodeViewSubection(const StringsAndChecksumsRef &SC, diff --git a/lib/ObjectYAML/CodeViewYAMLSymbols.cpp b/lib/ObjectYAML/CodeViewYAMLSymbols.cpp index 3ddce7ba153..dbe4e2a6d6f 100644 --- a/lib/ObjectYAML/CodeViewYAMLSymbols.cpp +++ b/lib/ObjectYAML/CodeViewYAMLSymbols.cpp @@ -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 +#include +#include +#include +#include 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::input(StringRef S, void *V, TypeName &T) { return ScalarTraits::input(S, V, T.value); } + void ScalarTraits::output(const TypeName &T, void *V, - llvm::raw_ostream &R) { + raw_ostream &R) { ScalarTraits::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 struct SymbolRecordImpl : public SymbolRecordBase { CodeViewContainer Container) const override { return SymbolSerializer::writeOneSymbol(Symbol, Allocator, Container); } + Error fromCodeViewSymbol(codeview::CVSymbol CVS) override { return SymbolDeserializer::deserializeAs(CVS, Symbol); } @@ -217,6 +232,7 @@ struct UnknownSymbolRecord : public SymbolRecordBase { ::memcpy(Buffer + sizeof(RecordPrefix), Data.data(), Data.size()); return CVSymbol(Kind, ArrayRef(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::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 { static void mapping(IO &io, SymbolRecordBase &Record) { Record.map(io); } }; -} -} + +} // end namespace yaml +} // end namespace llvm template static inline Expected diff --git a/lib/ObjectYAML/CodeViewYAMLTypes.cpp b/lib/ObjectYAML/CodeViewYAMLTypes.cpp index f5c53232a56..0b2ea61c5fe 100644 --- a/lib/ObjectYAML/CodeViewYAMLTypes.cpp +++ b/lib/ObjectYAML/CodeViewYAMLTypes.cpp @@ -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 +#include +#include +#include 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 : 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 struct MemberRecordImpl : public MemberRecordBase { explicit MemberRecordImpl(TypeLeafKind K) : MemberRecordBase(K), Record(static_cast(K)) {} + void map(yaml::IO &io) override; void writeTo(FieldListRecordBuilder &FLRB) override { @@ -118,12 +136,13 @@ template struct MemberRecordImpl : public MemberRecordBase { mutable T Record; }; -} -} -} + +} // end namespace detail +} // end namespace CodeViewYAML +} // end namespace llvm void ScalarTraits::output(const TypeIndex &S, void *, - llvm::raw_ostream &OS) { + raw_ostream &OS) { OS << S.getIndex(); } @@ -135,8 +154,7 @@ StringRef ScalarTraits::input(StringRef Scalar, void *Ctx, return Result; } -void ScalarTraits::output(const APSInt &S, void *, - llvm::raw_ostream &OS) { +void ScalarTraits::output(const APSInt &S, void *, raw_ostream &OS) { S.print(OS, S.isSigned()); } @@ -345,6 +363,7 @@ void MappingTraits::mapping(IO &IO, MemberPointerInfo &MPI) { namespace llvm { namespace CodeViewYAML { namespace detail { + template <> void LeafRecordImpl::map(IO &IO) { IO.mapRequired("ModifiedType", Record.ModifiedType); IO.mapRequired("Modifiers", Record.Modifiers); @@ -403,11 +422,13 @@ template <> void LeafRecordImpl::map(IO &IO) { void LeafRecordImpl::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 &Records) @@ -432,7 +453,8 @@ private: std::vector &Records; }; -} + +} // end anonymous namespace Error LeafRecordImpl::fromCodeViewRecord(CVType Type) { MemberRecordConversionVisitor V(Members); @@ -460,13 +482,13 @@ void MappingTraits::mapping(IO &io, OneMethodRecord &Record) { namespace llvm { namespace CodeViewYAML { namespace detail { + template <> void LeafRecordImpl::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::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::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::map(IO &IO) { template <> void MemberRecordImpl::map(IO &IO) { IO.mapRequired("ContinuationIndex", Record.ContinuationIndex); } -} -} -} + +} // end namespace detail +} // end namespace CodeViewYAML +} // end namespace llvm template static inline Expected fromCodeViewRecordImpl(CVType Type) { @@ -627,7 +648,8 @@ Expected 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(cv_error_code::corrupt_record); } @@ -643,6 +665,7 @@ CVType LeafRecord::toCodeViewRecord(TypeTableBuilder &TTB) const { namespace llvm { namespace yaml { + template <> struct MappingTraits { static void mapping(IO &io, LeafRecordBase &Record) { Record.map(io); } }; @@ -650,8 +673,9 @@ template <> struct MappingTraits { template <> struct MappingTraits { static void mapping(IO &io, MemberRecordBase &Record) { Record.map(io); } }; -} -} + +} // end namespace yaml +} // end namespace llvm template static void mapLeafRecordImpl(IO &IO, const char *Class, TypeLeafKind Kind, diff --git a/lib/ObjectYAML/DWARFEmitter.cpp b/lib/ObjectYAML/DWARFEmitter.cpp index 91c928771a6..89fc652035c 100644 --- a/lib/ObjectYAML/DWARFEmitter.cpp +++ b/lib/ObjectYAML/DWARFEmitter.cpp @@ -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 +#include +#include +#include +#include +#include +#include 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, diff --git a/lib/ObjectYAML/DWARFYAML.cpp b/lib/ObjectYAML/DWARFYAML.cpp index edb9545f14b..d6c09e1a35d 100644 --- a/lib/ObjectYAML/DWARFYAML.cpp +++ b/lib/ObjectYAML/DWARFYAML.cpp @@ -171,6 +171,6 @@ void MappingTraits::mapping( IO.mapRequired("TotalLength64", InitialLength.TotalLength64); } -} // namespace llvm::yaml +} // end namespace yaml -} // namespace llvm +} // end namespace llvm diff --git a/lib/ObjectYAML/ELFYAML.cpp b/lib/ObjectYAML/ELFYAML.cpp index 8578997fe57..39741dab327 100644 --- a/lib/ObjectYAML/ELFYAML.cpp +++ b/lib/ObjectYAML/ELFYAML.cpp @@ -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 +#include namespace llvm { -ELFYAML::Section::~Section() {} +ELFYAML::Section::~Section() = default; namespace yaml { @@ -644,6 +650,7 @@ void MappingTraits::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::mapping(IO &IO, ELFYAML::Symbol &Symbol) { IO.mapOptional("Name", Symbol.Name, StringRef()); @@ -778,6 +786,7 @@ StringRef MappingTraits>::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::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 diff --git a/lib/ObjectYAML/MachOYAML.cpp b/lib/ObjectYAML/MachOYAML.cpp index 46168482787..ab452a7bf6e 100644 --- a/lib/ObjectYAML/MachOYAML.cpp +++ b/lib/ObjectYAML/MachOYAML.cpp @@ -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 // For memcpy, memset and strnlen. +#include "llvm/Support/YAMLTraits.h" +#include "llvm/Support/raw_ostream.h" +#include +#include +#include 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::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::input(StringRef Scalar, void *, char_16 &Val) { bool ScalarTraits::mustQuote(StringRef S) { return needsQuotes(S); } -void ScalarTraits::output(const uuid_t &Val, void *, - llvm::raw_ostream &Out) { +void ScalarTraits::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::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::mapping( void MappingTraits::mapping( IO &IO, MachO::dylinker_command &LoadCommand) { - IO.mapRequired("name", LoadCommand.name); } void MappingTraits::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::mapping( void MappingTraits::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::mapping( void MappingTraits::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::mapping( void MappingTraits::mapping( IO &IO, MachO::entry_point_command &LoadCommand) { - IO.mapRequired("entryoff", LoadCommand.entryoff); IO.mapRequired("stacksize", LoadCommand.stacksize); } void MappingTraits::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::mapping(IO &IO, MachO::fvmlib &FVMLib) { void MappingTraits::mapping( IO &IO, MachO::fvmlib_command &LoadCommand) { - IO.mapRequired("fvmlib", LoadCommand.fvmlib); } @@ -383,20 +378,17 @@ void MappingTraits::mapping( void MappingTraits::mapping( IO &IO, MachO::linkedit_data_command &LoadCommand) { - IO.mapRequired("dataoff", LoadCommand.dataoff); IO.mapRequired("datasize", LoadCommand.datasize); } void MappingTraits::mapping( IO &IO, MachO::linker_option_command &LoadCommand) { - IO.mapRequired("count", LoadCommand.count); } void MappingTraits::mapping( IO &IO, MachO::prebind_cksum_command &LoadCommand) { - IO.mapRequired("cksum", LoadCommand.cksum); } @@ -405,7 +397,6 @@ void MappingTraits::mapping( void MappingTraits::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::mapping( void MappingTraits::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::mapping( void MappingTraits::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::mapping( void MappingTraits::mapping( IO &IO, MachO::rpath_command &LoadCommand) { - IO.mapRequired("path", LoadCommand.path); } @@ -475,7 +463,6 @@ void MappingTraits::mapping(IO &IO, void MappingTraits::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::mapping( void MappingTraits::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::mapping( void MappingTraits::mapping( IO &IO, MachO::source_version_command &LoadCommand) { - IO.mapRequired("version", LoadCommand.version); } void MappingTraits::mapping( IO &IO, MachO::sub_client_command &LoadCommand) { - IO.mapRequired("client", LoadCommand.client); } void MappingTraits::mapping( IO &IO, MachO::sub_framework_command &LoadCommand) { - IO.mapRequired("umbrella", LoadCommand.umbrella); } void MappingTraits::mapping( IO &IO, MachO::sub_library_command &LoadCommand) { - IO.mapRequired("sub_library", LoadCommand.sub_library); } void MappingTraits::mapping( IO &IO, MachO::sub_umbrella_command &LoadCommand) { - IO.mapRequired("sub_umbrella", LoadCommand.sub_umbrella); } void MappingTraits::mapping( IO &IO, MachO::symseg_command &LoadCommand) { - IO.mapRequired("offset", LoadCommand.offset); IO.mapRequired("size", LoadCommand.size); } void MappingTraits::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::mapping( void MappingTraits::mapping( IO &IO, MachO::twolevel_hints_command &LoadCommand) { - IO.mapRequired("offset", LoadCommand.offset); IO.mapRequired("nhints", LoadCommand.nhints); } void MappingTraits::mapping( IO &IO, MachO::uuid_command &LoadCommand) { - IO.mapRequired("uuid", LoadCommand.uuid); } void MappingTraits::mapping( IO &IO, MachO::version_min_command &LoadCommand) { - IO.mapRequired("version", LoadCommand.version); IO.mapRequired("sdk", LoadCommand.sdk); } void MappingTraits::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::mapping( void MappingTraits::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 diff --git a/lib/ObjectYAML/ObjectYAML.cpp b/lib/ObjectYAML/ObjectYAML.cpp index 4b7154ebb7c..850c1a5a06c 100644 --- a/lib/ObjectYAML/ObjectYAML.cpp +++ b/lib/ObjectYAML/ObjectYAML.cpp @@ -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 using namespace llvm; using namespace yaml; @@ -53,8 +56,8 @@ void MappingTraits::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("'!")); } } } diff --git a/lib/ObjectYAML/WasmYAML.cpp b/lib/ObjectYAML/WasmYAML.cpp index 11999559d65..2040efdc9d1 100644 --- a/lib/ObjectYAML/WasmYAML.cpp +++ b/lib/ObjectYAML/WasmYAML.cpp @@ -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::enumeration( } } // end namespace yaml + } // end namespace llvm diff --git a/lib/ObjectYAML/YAML.cpp b/lib/ObjectYAML/YAML.cpp index 75cf1fbccc8..67b5764eada 100644 --- a/lib/ObjectYAML/YAML.cpp +++ b/lib/ObjectYAML/YAML.cpp @@ -16,11 +16,12 @@ #include "llvm/ADT/StringExtras.h" #include "llvm/Support/raw_ostream.h" #include +#include using namespace llvm; void yaml::ScalarTraits::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::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 {