aboutsummaryrefslogtreecommitdiff
path: root/include/llvm/ObjectYAML
diff options
context:
space:
mode:
Diffstat (limited to 'include/llvm/ObjectYAML')
-rw-r--r--include/llvm/ObjectYAML/COFFYAML.h113
-rw-r--r--include/llvm/ObjectYAML/CodeViewYAMLDebugSections.h32
-rw-r--r--include/llvm/ObjectYAML/CodeViewYAMLSymbols.h16
-rw-r--r--include/llvm/ObjectYAML/CodeViewYAMLTypes.h29
-rw-r--r--include/llvm/ObjectYAML/DWARFEmitter.h27
-rw-r--r--include/llvm/ObjectYAML/DWARFYAML.h21
-rw-r--r--include/llvm/ObjectYAML/ELFYAML.h22
-rw-r--r--include/llvm/ObjectYAML/MachOYAML.h45
-rw-r--r--include/llvm/ObjectYAML/ObjectYAML.h9
-rw-r--r--include/llvm/ObjectYAML/WasmYAML.h28
-rw-r--r--include/llvm/ObjectYAML/YAML.h30
11 files changed, 232 insertions, 140 deletions
diff --git a/include/llvm/ObjectYAML/COFFYAML.h b/include/llvm/ObjectYAML/COFFYAML.h
index 719cb1acf6ef..bbceefac3d94 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 <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;
- };
-
- 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 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();
- };
-}
-}
+
+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;
+};
+
+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 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
diff --git a/include/llvm/ObjectYAML/CodeViewYAMLDebugSections.h b/include/llvm/ObjectYAML/CodeViewYAMLDebugSections.h
index 8180e0fc83f4..d620008e22d2 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 <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
diff --git a/include/llvm/ObjectYAML/CodeViewYAMLSymbols.h b/include/llvm/ObjectYAML/CodeViewYAMLSymbols.h
index 9b411e8b074f..791193c78f19 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 <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
diff --git a/include/llvm/ObjectYAML/CodeViewYAMLTypes.h b/include/llvm/ObjectYAML/CodeViewYAMLTypes.h
index e97d5f92bf7f..6746fd60b6cb 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 <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
diff --git a/include/llvm/ObjectYAML/DWARFEmitter.h b/include/llvm/ObjectYAML/DWARFEmitter.h
index ce231cc0ce68..0d7d8b4efbdf 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 <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
+
+} // end namespace llvm
-#endif
+#endif // LLVM_OBJECTYAML_DWARFEMITTER_H
diff --git a/include/llvm/ObjectYAML/DWARFYAML.h b/include/llvm/ObjectYAML/DWARFYAML.h
index 75e9112e121a..2162f0fef852 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 <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,12 +159,10 @@ struct Data {
bool isEmpty() const;
};
-} // namespace llvm::DWARFYAML
-} // namespace llvm
+} // end namespace DWARFYAML
+} // end namespace llvm
-LLVM_YAML_IS_FLOW_SEQUENCE_VECTOR(uint8_t)
LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::yaml::Hex64)
-LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::StringRef)
LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::yaml::Hex8)
LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::DWARFYAML::AttributeAbbrev)
LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::DWARFYAML::Abbrev)
@@ -304,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
diff --git a/include/llvm/ObjectYAML/ELFYAML.h b/include/llvm/ObjectYAML/ELFYAML.h
index 9d62ec27ad31..ed455311696e 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 <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
diff --git a/include/llvm/ObjectYAML/MachOYAML.h b/include/llvm/ObjectYAML/MachOYAML.h
index 59aca9a1ddf2..305497b6aa6a 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 <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,12 +138,11 @@ 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)
-LLVM_YAML_IS_FLOW_SEQUENCE_VECTOR(int64_t)
LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::MachOYAML::RebaseOpcode)
LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::MachOYAML::BindOpcode)
LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::MachOYAML::ExportEntry)
@@ -150,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> {
@@ -251,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);
};
@@ -297,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
diff --git a/include/llvm/ObjectYAML/ObjectYAML.h b/include/llvm/ObjectYAML/ObjectYAML.h
index 36d6ed5417cf..00ce86430fca 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 <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
diff --git a/include/llvm/ObjectYAML/WasmYAML.h b/include/llvm/ObjectYAML/WasmYAML.h
index 74f5664c43ac..6bf08d340eeb 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 <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,16 +153,20 @@ 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";
}
std::vector<SymbolInfo> SymbolInfos;
+ uint32_t DataSize;
+ uint32_t DataAlignment;
};
struct TypeSection : Section {
TypeSection() : Section(wasm::WASM_SEC_TYPE) {}
+
static bool classof(const Section *S) {
return S->Type == wasm::WASM_SEC_TYPE;
}
@@ -167,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;
}
@@ -176,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;
}
@@ -185,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;
}
@@ -194,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;
}
@@ -203,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;
}
@@ -212,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;
}
@@ -221,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;
}
@@ -230,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;
}
@@ -239,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;
}
@@ -248,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;
}
@@ -278,7 +297,6 @@ LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::WasmYAML::LocalDecl)
LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::WasmYAML::Relocation)
LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::WasmYAML::NameEntry)
LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::WasmYAML::SymbolInfo)
-LLVM_YAML_IS_FLOW_SEQUENCE_VECTOR(uint32_t)
namespace llvm {
namespace yaml {
@@ -378,4 +396,4 @@ template <> struct ScalarEnumerationTraits<WasmYAML::RelocType> {
} // 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 7f6836809b6d..29151a269df0 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 <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