From 5eaec804b414c8077120cccc55908e49d7bea2b6 Mon Sep 17 00:00:00 2001 From: Andrew Rogers Date: Mon, 9 Jun 2025 18:00:33 -0700 Subject: [PATCH 1/2] [llvm] IDS auto codemod for ObjectYAML library --- .../ObjectYAML/CodeViewYAMLDebugSections.h | 9 +-- .../llvm/ObjectYAML/CodeViewYAMLSymbols.h | 5 +- .../llvm/ObjectYAML/CodeViewYAMLTypes.h | 9 +-- llvm/include/llvm/ObjectYAML/DWARFEmitter.h | 39 +++++------ llvm/include/llvm/ObjectYAML/DWARFYAML.h | 61 ++++++++--------- .../include/llvm/ObjectYAML/DXContainerYAML.h | 67 ++++++++++--------- llvm/include/llvm/ObjectYAML/YAML.h | 9 +-- llvm/include/llvm/ObjectYAML/yaml2obj.h | 25 +++---- 8 files changed, 116 insertions(+), 108 deletions(-) diff --git a/llvm/include/llvm/ObjectYAML/CodeViewYAMLDebugSections.h b/llvm/include/llvm/ObjectYAML/CodeViewYAMLDebugSections.h index 6c712956dfb5d..ef58c5c650fc4 100644 --- a/llvm/include/llvm/ObjectYAML/CodeViewYAMLDebugSections.h +++ b/llvm/include/llvm/ObjectYAML/CodeViewYAMLDebugSections.h @@ -14,6 +14,7 @@ #ifndef LLVM_OBJECTYAML_CODEVIEWYAMLDEBUGSECTIONS_H #define LLVM_OBJECTYAML_CODEVIEWYAMLDEBUGSECTIONS_H +#include "llvm/Support/Compiler.h" #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/StringRef.h" #include "llvm/DebugInfo/CodeView/CodeView.h" @@ -108,22 +109,22 @@ struct InlineeInfo { }; struct YAMLDebugSubsection { - static Expected + LLVM_ABI static Expected fromCodeViewSubection(const codeview::StringsAndChecksumsRef &SC, const codeview::DebugSubsectionRecord &SS); std::shared_ptr Subsection; }; -Expected>> +LLVM_ABI Expected>> toCodeViewSubsectionList(BumpPtrAllocator &Allocator, ArrayRef Subsections, const codeview::StringsAndChecksums &SC); -std::vector +LLVM_ABI std::vector fromDebugS(ArrayRef Data, const codeview::StringsAndChecksumsRef &SC); -void initializeStringsAndChecksums(ArrayRef Sections, +LLVM_ABI void initializeStringsAndChecksums(ArrayRef Sections, codeview::StringsAndChecksums &SC); } // end namespace CodeViewYAML diff --git a/llvm/include/llvm/ObjectYAML/CodeViewYAMLSymbols.h b/llvm/include/llvm/ObjectYAML/CodeViewYAMLSymbols.h index 7c05c9eea05ed..6a8d6897a3ab8 100644 --- a/llvm/include/llvm/ObjectYAML/CodeViewYAMLSymbols.h +++ b/llvm/include/llvm/ObjectYAML/CodeViewYAMLSymbols.h @@ -14,6 +14,7 @@ #ifndef LLVM_OBJECTYAML_CODEVIEWYAMLSYMBOLS_H #define LLVM_OBJECTYAML_CODEVIEWYAMLSYMBOLS_H +#include "llvm/Support/Compiler.h" #include "llvm/DebugInfo/CodeView/CodeView.h" #include "llvm/DebugInfo/CodeView/SymbolRecord.h" #include "llvm/Support/Error.h" @@ -32,11 +33,11 @@ struct SymbolRecordBase; struct SymbolRecord { std::shared_ptr Symbol; - codeview::CVSymbol + LLVM_ABI codeview::CVSymbol toCodeViewSymbol(BumpPtrAllocator &Allocator, codeview::CodeViewContainer Container) const; - static Expected fromCodeViewSymbol(codeview::CVSymbol Symbol); + LLVM_ABI static Expected fromCodeViewSymbol(codeview::CVSymbol Symbol); }; } // end namespace CodeViewYAML diff --git a/llvm/include/llvm/ObjectYAML/CodeViewYAMLTypes.h b/llvm/include/llvm/ObjectYAML/CodeViewYAMLTypes.h index 04b5e0ba3aa1a..c8a349350cb7b 100644 --- a/llvm/include/llvm/ObjectYAML/CodeViewYAMLTypes.h +++ b/llvm/include/llvm/ObjectYAML/CodeViewYAMLTypes.h @@ -14,6 +14,7 @@ #ifndef LLVM_OBJECTYAML_CODEVIEWYAMLTYPES_H #define LLVM_OBJECTYAML_CODEVIEWYAMLTYPES_H +#include "llvm/Support/Compiler.h" #include "llvm/ADT/ArrayRef.h" #include "llvm/DebugInfo/CodeView/TypeRecord.h" #include "llvm/Support/Allocator.h" @@ -45,14 +46,14 @@ struct MemberRecord { struct LeafRecord { std::shared_ptr Leaf; - codeview::CVType + LLVM_ABI codeview::CVType toCodeViewRecord(codeview::AppendingTypeTableBuilder &Serializer) const; - static Expected fromCodeViewRecord(codeview::CVType Type); + LLVM_ABI static Expected fromCodeViewRecord(codeview::CVType Type); }; -std::vector fromDebugT(ArrayRef DebugTorP, +LLVM_ABI std::vector fromDebugT(ArrayRef DebugTorP, StringRef SectionName); -ArrayRef toDebugT(ArrayRef, BumpPtrAllocator &Alloc, +LLVM_ABI ArrayRef toDebugT(ArrayRef, BumpPtrAllocator &Alloc, StringRef SectionName); } // end namespace CodeViewYAML diff --git a/llvm/include/llvm/ObjectYAML/DWARFEmitter.h b/llvm/include/llvm/ObjectYAML/DWARFEmitter.h index 5e1b88f4fef64..f907bc046837f 100644 --- a/llvm/include/llvm/ObjectYAML/DWARFEmitter.h +++ b/llvm/include/llvm/ObjectYAML/DWARFEmitter.h @@ -12,6 +12,7 @@ #ifndef LLVM_OBJECTYAML_DWARFEMITTER_H #define LLVM_OBJECTYAML_DWARFEMITTER_H +#include "llvm/Support/Compiler.h" #include "llvm/ADT/StringMap.h" #include "llvm/ADT/StringRef.h" #include "llvm/Support/Error.h" @@ -27,26 +28,26 @@ namespace DWARFYAML { struct Data; -Error emitDebugAbbrev(raw_ostream &OS, const Data &DI); -Error emitDebugStr(raw_ostream &OS, const Data &DI); - -Error emitDebugAranges(raw_ostream &OS, const Data &DI); -Error emitDebugRanges(raw_ostream &OS, const Data &DI); -Error emitDebugPubnames(raw_ostream &OS, const Data &DI); -Error emitDebugPubtypes(raw_ostream &OS, const Data &DI); -Error emitDebugGNUPubnames(raw_ostream &OS, const Data &DI); -Error emitDebugGNUPubtypes(raw_ostream &OS, const Data &DI); -Error emitDebugInfo(raw_ostream &OS, const Data &DI); -Error emitDebugLine(raw_ostream &OS, const Data &DI); -Error emitDebugAddr(raw_ostream &OS, const Data &DI); -Error emitDebugStrOffsets(raw_ostream &OS, const Data &DI); -Error emitDebugRnglists(raw_ostream &OS, const Data &DI); -Error emitDebugLoclists(raw_ostream &OS, const Data &DI); -Error emitDebugNames(raw_ostream &OS, const Data &DI); - -std::function +LLVM_ABI Error emitDebugAbbrev(raw_ostream &OS, const Data &DI); +LLVM_ABI Error emitDebugStr(raw_ostream &OS, const Data &DI); + +LLVM_ABI Error emitDebugAranges(raw_ostream &OS, const Data &DI); +LLVM_ABI Error emitDebugRanges(raw_ostream &OS, const Data &DI); +LLVM_ABI Error emitDebugPubnames(raw_ostream &OS, const Data &DI); +LLVM_ABI Error emitDebugPubtypes(raw_ostream &OS, const Data &DI); +LLVM_ABI Error emitDebugGNUPubnames(raw_ostream &OS, const Data &DI); +LLVM_ABI Error emitDebugGNUPubtypes(raw_ostream &OS, const Data &DI); +LLVM_ABI Error emitDebugInfo(raw_ostream &OS, const Data &DI); +LLVM_ABI Error emitDebugLine(raw_ostream &OS, const Data &DI); +LLVM_ABI Error emitDebugAddr(raw_ostream &OS, const Data &DI); +LLVM_ABI Error emitDebugStrOffsets(raw_ostream &OS, const Data &DI); +LLVM_ABI Error emitDebugRnglists(raw_ostream &OS, const Data &DI); +LLVM_ABI Error emitDebugLoclists(raw_ostream &OS, const Data &DI); +LLVM_ABI Error emitDebugNames(raw_ostream &OS, const Data &DI); + +LLVM_ABI std::function getDWARFEmitterByName(StringRef SecName); -Expected>> +LLVM_ABI Expected>> emitDebugSections(StringRef YAMLString, bool IsLittleEndian = sys::IsLittleEndianHost, bool Is64BitAddrSize = true); diff --git a/llvm/include/llvm/ObjectYAML/DWARFYAML.h b/llvm/include/llvm/ObjectYAML/DWARFYAML.h index 69f8c4f27d7a3..803ddf3bf049d 100644 --- a/llvm/include/llvm/ObjectYAML/DWARFYAML.h +++ b/llvm/include/llvm/ObjectYAML/DWARFYAML.h @@ -15,6 +15,7 @@ #ifndef LLVM_OBJECTYAML_DWARFYAML_H #define LLVM_OBJECTYAML_DWARFYAML_H +#include "llvm/Support/Compiler.h" #include "llvm/ADT/SetVector.h" #include "llvm/ADT/StringRef.h" #include "llvm/BinaryFormat/Dwarf.h" @@ -255,16 +256,16 @@ struct Data { std::optional>> DebugLoclists; std::optional DebugNames; - bool isEmpty() const; + LLVM_ABI bool isEmpty() const; - SetVector getNonEmptySectionNames() const; + LLVM_ABI SetVector getNonEmptySectionNames() const; struct AbbrevTableInfo { uint64_t Index; uint64_t Offset; }; - Expected getAbbrevTableInfoByID(uint64_t ID) const; - StringRef getAbbrevTableContentByIndex(uint64_t Index) const; + LLVM_ABI Expected getAbbrevTableInfoByID(uint64_t ID) const; + LLVM_ABI StringRef getAbbrevTableContentByIndex(uint64_t Index) const; private: mutable std::unordered_map AbbrevTableInfoMap; @@ -310,88 +311,88 @@ namespace llvm { namespace yaml { template <> struct MappingTraits { - static void mapping(IO &IO, DWARFYAML::Data &DWARF); + LLVM_ABI static void mapping(IO &IO, DWARFYAML::Data &DWARF); }; template <> struct MappingTraits { - static void mapping(IO &IO, DWARFYAML::AbbrevTable &AbbrevTable); + LLVM_ABI static void mapping(IO &IO, DWARFYAML::AbbrevTable &AbbrevTable); }; template <> struct MappingTraits { - static void mapping(IO &IO, DWARFYAML::Abbrev &Abbrev); + LLVM_ABI static void mapping(IO &IO, DWARFYAML::Abbrev &Abbrev); }; template <> struct MappingTraits { - static void mapping(IO &IO, DWARFYAML::AttributeAbbrev &AttAbbrev); + LLVM_ABI static void mapping(IO &IO, DWARFYAML::AttributeAbbrev &AttAbbrev); }; template <> struct MappingTraits { - static void mapping(IO &IO, DWARFYAML::ARangeDescriptor &Descriptor); + LLVM_ABI static void mapping(IO &IO, DWARFYAML::ARangeDescriptor &Descriptor); }; template <> struct MappingTraits { - static void mapping(IO &IO, DWARFYAML::ARange &ARange); + LLVM_ABI static void mapping(IO &IO, DWARFYAML::ARange &ARange); }; template <> struct MappingTraits { - static void mapping(IO &IO, DWARFYAML::RangeEntry &Entry); + LLVM_ABI static void mapping(IO &IO, DWARFYAML::RangeEntry &Entry); }; template <> struct MappingTraits { - static void mapping(IO &IO, DWARFYAML::Ranges &Ranges); + LLVM_ABI static void mapping(IO &IO, DWARFYAML::Ranges &Ranges); }; template <> struct MappingTraits { - static void mapping(IO &IO, DWARFYAML::PubEntry &Entry); + LLVM_ABI static void mapping(IO &IO, DWARFYAML::PubEntry &Entry); }; template <> struct MappingTraits { - static void mapping(IO &IO, DWARFYAML::PubSection &Section); + LLVM_ABI static void mapping(IO &IO, DWARFYAML::PubSection &Section); }; template <> struct MappingTraits { - static void mapping(IO &IO, DWARFYAML::Unit &Unit); + LLVM_ABI static void mapping(IO &IO, DWARFYAML::Unit &Unit); }; template <> struct MappingTraits { - static void mapping(IO &IO, DWARFYAML::DebugNamesSection &); + LLVM_ABI static void mapping(IO &IO, DWARFYAML::DebugNamesSection &); }; template <> struct MappingTraits { - static void mapping(IO &IO, DWARFYAML::DebugNameEntry &); + LLVM_ABI static void mapping(IO &IO, DWARFYAML::DebugNameEntry &); }; template <> struct MappingTraits { - static void mapping(IO &IO, DWARFYAML::DebugNameAbbreviation &); + LLVM_ABI static void mapping(IO &IO, DWARFYAML::DebugNameAbbreviation &); }; template <> struct MappingTraits { - static void mapping(IO &IO, DWARFYAML::IdxForm &); + LLVM_ABI static void mapping(IO &IO, DWARFYAML::IdxForm &); }; template <> struct MappingTraits { - static void mapping(IO &IO, DWARFYAML::Entry &Entry); + LLVM_ABI static void mapping(IO &IO, DWARFYAML::Entry &Entry); }; template <> struct MappingTraits { - static void mapping(IO &IO, DWARFYAML::FormValue &FormValue); + LLVM_ABI static void mapping(IO &IO, DWARFYAML::FormValue &FormValue); }; template <> struct MappingTraits { - static void mapping(IO &IO, DWARFYAML::File &File); + LLVM_ABI static void mapping(IO &IO, DWARFYAML::File &File); }; template <> struct MappingTraits { - static void mapping(IO &IO, DWARFYAML::LineTableOpcode &LineTableOpcode); + LLVM_ABI static void mapping(IO &IO, DWARFYAML::LineTableOpcode &LineTableOpcode); }; template <> struct MappingTraits { - static void mapping(IO &IO, DWARFYAML::LineTable &LineTable); + LLVM_ABI static void mapping(IO &IO, DWARFYAML::LineTable &LineTable); }; template <> struct MappingTraits { - static void mapping(IO &IO, DWARFYAML::SegAddrPair &SegAddrPair); + LLVM_ABI static void mapping(IO &IO, DWARFYAML::SegAddrPair &SegAddrPair); }; template <> struct MappingTraits { - static void mapping(IO &IO, DWARFYAML::DWARFOperation &DWARFOperation); + LLVM_ABI static void mapping(IO &IO, DWARFYAML::DWARFOperation &DWARFOperation); }; template @@ -407,19 +408,19 @@ struct MappingTraits> { }; template <> struct MappingTraits { - static void mapping(IO &IO, DWARFYAML::RnglistEntry &RnglistEntry); + LLVM_ABI static void mapping(IO &IO, DWARFYAML::RnglistEntry &RnglistEntry); }; template <> struct MappingTraits { - static void mapping(IO &IO, DWARFYAML::LoclistEntry &LoclistEntry); + LLVM_ABI static void mapping(IO &IO, DWARFYAML::LoclistEntry &LoclistEntry); }; template <> struct MappingTraits { - static void mapping(IO &IO, DWARFYAML::AddrTableEntry &AddrTable); + LLVM_ABI static void mapping(IO &IO, DWARFYAML::AddrTableEntry &AddrTable); }; template <> struct MappingTraits { - static void mapping(IO &IO, DWARFYAML::StringOffsetsTable &StrOffsetsTable); + LLVM_ABI static void mapping(IO &IO, DWARFYAML::StringOffsetsTable &StrOffsetsTable); }; template <> struct ScalarEnumerationTraits { diff --git a/llvm/include/llvm/ObjectYAML/DXContainerYAML.h b/llvm/include/llvm/ObjectYAML/DXContainerYAML.h index 8a0dfd8718796..8000b69a34b2d 100644 --- a/llvm/include/llvm/ObjectYAML/DXContainerYAML.h +++ b/llvm/include/llvm/ObjectYAML/DXContainerYAML.h @@ -15,6 +15,7 @@ #ifndef LLVM_OBJECTYAML_DXCONTAINERYAML_H #define LLVM_OBJECTYAML_DXCONTAINERYAML_H +#include "llvm/Support/Compiler.h" #include "llvm/ADT/StringRef.h" #include "llvm/BinaryFormat/DXContainer.h" #include "llvm/Object/DXContainer.h" @@ -59,14 +60,14 @@ struct DXILProgram { #define SHADER_FEATURE_FLAG(Num, DxilModuleNum, Val, Str) bool Val = false; struct ShaderFeatureFlags { ShaderFeatureFlags() = default; - ShaderFeatureFlags(uint64_t FlagData); - uint64_t getEncodedFlags(); + LLVM_ABI ShaderFeatureFlags(uint64_t FlagData); + LLVM_ABI uint64_t getEncodedFlags(); #include "llvm/BinaryFormat/DXContainerConstants.def" }; struct ShaderHash { ShaderHash() = default; - ShaderHash(const dxbc::ShaderHash &Data); + LLVM_ABI ShaderHash(const dxbc::ShaderHash &Data); bool IncludesSource; std::vector Digest; @@ -84,7 +85,7 @@ struct RootDescriptorYaml { uint32_t ShaderRegister; uint32_t RegisterSpace; - uint32_t getEncodedFlags() const; + LLVM_ABI uint32_t getEncodedFlags() const; #define ROOT_DESCRIPTOR_FLAG(Num, Val) bool Val = false; #include "llvm/BinaryFormat/DXContainerConstants.def" @@ -97,7 +98,7 @@ struct DescriptorRangeYaml { uint32_t RegisterSpace; uint32_t OffsetInDescriptorsFromTableStart; - uint32_t getEncodedFlags() const; + LLVM_ABI uint32_t getEncodedFlags() const; #define DESCRIPTOR_RANGE_FLAG(Num, Val) bool Val = false; #include "llvm/BinaryFormat/DXContainerConstants.def" @@ -193,13 +194,13 @@ struct RootSignatureYamlDesc { RootParameterYamlDesc Parameters; SmallVector StaticSamplers; - uint32_t getEncodedFlags(); + LLVM_ABI uint32_t getEncodedFlags(); iterator_range samplers() { return make_range(StaticSamplers.begin(), StaticSamplers.end()); } - static llvm::Expected + LLVM_ABI static llvm::Expected create(const object::DirectX::RootSignature &Data); #define ROOT_ELEMENT_FLAG(Num, Val) bool Val = false; @@ -258,13 +259,13 @@ struct PSVInfo { StringRef EntryName; - void mapInfoForVersion(yaml::IO &IO); + LLVM_ABI void mapInfoForVersion(yaml::IO &IO); - PSVInfo(); - PSVInfo(const dxbc::PSV::v0::RuntimeInfo *P, uint16_t Stage); - PSVInfo(const dxbc::PSV::v1::RuntimeInfo *P); - PSVInfo(const dxbc::PSV::v2::RuntimeInfo *P); - PSVInfo(const dxbc::PSV::v3::RuntimeInfo *P, StringRef StringTable); + LLVM_ABI PSVInfo(); + LLVM_ABI PSVInfo(const dxbc::PSV::v0::RuntimeInfo *P, uint16_t Stage); + LLVM_ABI PSVInfo(const dxbc::PSV::v1::RuntimeInfo *P); + LLVM_ABI PSVInfo(const dxbc::PSV::v2::RuntimeInfo *P); + LLVM_ABI PSVInfo(const dxbc::PSV::v3::RuntimeInfo *P, StringRef StringTable); }; struct SignatureParameter { @@ -328,88 +329,88 @@ class raw_ostream; namespace yaml { template <> struct MappingTraits { - static void mapping(IO &IO, DXContainerYAML::VersionTuple &Version); + LLVM_ABI static void mapping(IO &IO, DXContainerYAML::VersionTuple &Version); }; template <> struct MappingTraits { - static void mapping(IO &IO, DXContainerYAML::FileHeader &Header); + LLVM_ABI static void mapping(IO &IO, DXContainerYAML::FileHeader &Header); }; template <> struct MappingTraits { - static void mapping(IO &IO, DXContainerYAML::DXILProgram &Program); + LLVM_ABI static void mapping(IO &IO, DXContainerYAML::DXILProgram &Program); }; template <> struct MappingTraits { - static void mapping(IO &IO, DXContainerYAML::ShaderFeatureFlags &Flags); + LLVM_ABI static void mapping(IO &IO, DXContainerYAML::ShaderFeatureFlags &Flags); }; template <> struct MappingTraits { - static void mapping(IO &IO, DXContainerYAML::ShaderHash &Hash); + LLVM_ABI static void mapping(IO &IO, DXContainerYAML::ShaderHash &Hash); }; template <> struct MappingTraits { - static void mapping(IO &IO, DXContainerYAML::PSVInfo &PSV); + LLVM_ABI static void mapping(IO &IO, DXContainerYAML::PSVInfo &PSV); }; template <> struct MappingTraits { - static void mapping(IO &IO, DXContainerYAML::Part &Version); + LLVM_ABI static void mapping(IO &IO, DXContainerYAML::Part &Version); }; template <> struct MappingTraits { - static void mapping(IO &IO, DXContainerYAML::Object &Obj); + LLVM_ABI static void mapping(IO &IO, DXContainerYAML::Object &Obj); }; template <> struct MappingTraits { - static void mapping(IO &IO, DXContainerYAML::ResourceFlags &Flags); + LLVM_ABI static void mapping(IO &IO, DXContainerYAML::ResourceFlags &Flags); }; template <> struct MappingTraits { - static void mapping(IO &IO, DXContainerYAML::ResourceBindInfo &Res); + LLVM_ABI static void mapping(IO &IO, DXContainerYAML::ResourceBindInfo &Res); }; template <> struct MappingTraits { - static void mapping(IO &IO, llvm::DXContainerYAML::SignatureElement &El); + LLVM_ABI static void mapping(IO &IO, llvm::DXContainerYAML::SignatureElement &El); }; template <> struct MappingTraits { - static void mapping(IO &IO, llvm::DXContainerYAML::SignatureParameter &El); + LLVM_ABI static void mapping(IO &IO, llvm::DXContainerYAML::SignatureParameter &El); }; template <> struct MappingTraits { - static void mapping(IO &IO, llvm::DXContainerYAML::Signature &El); + LLVM_ABI static void mapping(IO &IO, llvm::DXContainerYAML::Signature &El); }; template <> struct MappingTraits { - static void mapping(IO &IO, + LLVM_ABI static void mapping(IO &IO, DXContainerYAML::RootSignatureYamlDesc &RootSignature); }; template <> struct MappingContextTraits { - static void mapping(IO &IO, + LLVM_ABI static void mapping(IO &IO, llvm::DXContainerYAML::RootParameterLocationYaml &L, DXContainerYAML::RootSignatureYamlDesc &S); }; template <> struct MappingTraits { - static void mapping(IO &IO, llvm::DXContainerYAML::RootConstantsYaml &C); + LLVM_ABI static void mapping(IO &IO, llvm::DXContainerYAML::RootConstantsYaml &C); }; template <> struct MappingTraits { - static void mapping(IO &IO, llvm::DXContainerYAML::RootDescriptorYaml &D); + LLVM_ABI static void mapping(IO &IO, llvm::DXContainerYAML::RootDescriptorYaml &D); }; template <> struct MappingTraits { - static void mapping(IO &IO, llvm::DXContainerYAML::DescriptorTableYaml &D); + LLVM_ABI static void mapping(IO &IO, llvm::DXContainerYAML::DescriptorTableYaml &D); }; template <> struct MappingTraits { - static void mapping(IO &IO, llvm::DXContainerYAML::DescriptorRangeYaml &D); + LLVM_ABI static void mapping(IO &IO, llvm::DXContainerYAML::DescriptorRangeYaml &D); }; template <> struct MappingTraits { - static void mapping(IO &IO, llvm::DXContainerYAML::StaticSamplerYamlDesc &S); + LLVM_ABI static void mapping(IO &IO, llvm::DXContainerYAML::StaticSamplerYamlDesc &S); }; } // namespace yaml diff --git a/llvm/include/llvm/ObjectYAML/YAML.h b/llvm/include/llvm/ObjectYAML/YAML.h index 3bf6527a7e2da..2b686615af3b0 100644 --- a/llvm/include/llvm/ObjectYAML/YAML.h +++ b/llvm/include/llvm/ObjectYAML/YAML.h @@ -9,6 +9,7 @@ #ifndef LLVM_OBJECTYAML_YAML_H #define LLVM_OBJECTYAML_YAML_H +#include "llvm/Support/Compiler.h" #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/StringRef.h" #include "llvm/Support/YAMLTraits.h" @@ -86,13 +87,13 @@ class BinaryRef { /// Write the contents (regardless of whether it is binary or a /// hex string) as binary to the given raw_ostream. /// N can be used to specify the maximum number of bytes. - void writeAsBinary(raw_ostream &OS, uint64_t N = UINT64_MAX) const; + LLVM_ABI void writeAsBinary(raw_ostream &OS, uint64_t N = UINT64_MAX) const; /// Write the contents (regardless of whether it is binary or a /// hex string) as hex to the given raw_ostream. /// /// For example, a possible output could be `DEADBEEFCAFEBABE`. - void writeAsHex(raw_ostream &OS) const; + LLVM_ABI void writeAsHex(raw_ostream &OS) const; }; inline bool operator==(const BinaryRef &LHS, const BinaryRef &RHS) { @@ -104,8 +105,8 @@ inline bool operator==(const BinaryRef &LHS, const BinaryRef &RHS) { } template <> struct ScalarTraits { - static void output(const BinaryRef &, void *, raw_ostream &); - static StringRef input(StringRef, void *, BinaryRef &); + LLVM_ABI static void output(const BinaryRef &, void *, raw_ostream &); + LLVM_ABI static StringRef input(StringRef, void *, BinaryRef &); static QuotingType mustQuote(StringRef S) { return needsQuotes(S); } }; diff --git a/llvm/include/llvm/ObjectYAML/yaml2obj.h b/llvm/include/llvm/ObjectYAML/yaml2obj.h index 3b458c3cd890b..a7961840716e4 100644 --- a/llvm/include/llvm/ObjectYAML/yaml2obj.h +++ b/llvm/include/llvm/ObjectYAML/yaml2obj.h @@ -11,6 +11,7 @@ #ifndef LLVM_OBJECTYAML_YAML2OBJ_H #define LLVM_OBJECTYAML_YAML2OBJ_H +#include "llvm/Support/Compiler.h" #include "llvm/ADT/STLExtras.h" #include @@ -66,25 +67,25 @@ struct YamlObjectFile; using ErrorHandler = llvm::function_ref; -bool yaml2archive(ArchYAML::Archive &Doc, raw_ostream &Out, ErrorHandler EH); -bool yaml2coff(COFFYAML::Object &Doc, raw_ostream &Out, ErrorHandler EH); -bool yaml2goff(GOFFYAML::Object &Doc, raw_ostream &Out, ErrorHandler EH); -bool yaml2elf(ELFYAML::Object &Doc, raw_ostream &Out, ErrorHandler EH, +LLVM_ABI bool yaml2archive(ArchYAML::Archive &Doc, raw_ostream &Out, ErrorHandler EH); +LLVM_ABI bool yaml2coff(COFFYAML::Object &Doc, raw_ostream &Out, ErrorHandler EH); +LLVM_ABI bool yaml2goff(GOFFYAML::Object &Doc, raw_ostream &Out, ErrorHandler EH); +LLVM_ABI bool yaml2elf(ELFYAML::Object &Doc, raw_ostream &Out, ErrorHandler EH, uint64_t MaxSize); -bool yaml2macho(YamlObjectFile &Doc, raw_ostream &Out, ErrorHandler EH); -bool yaml2minidump(MinidumpYAML::Object &Doc, raw_ostream &Out, +LLVM_ABI bool yaml2macho(YamlObjectFile &Doc, raw_ostream &Out, ErrorHandler EH); +LLVM_ABI bool yaml2minidump(MinidumpYAML::Object &Doc, raw_ostream &Out, ErrorHandler EH); -bool yaml2offload(OffloadYAML::Binary &Doc, raw_ostream &Out, ErrorHandler EH); -bool yaml2wasm(WasmYAML::Object &Doc, raw_ostream &Out, ErrorHandler EH); -bool yaml2xcoff(XCOFFYAML::Object &Doc, raw_ostream &Out, ErrorHandler EH); -bool yaml2dxcontainer(DXContainerYAML::Object &Doc, raw_ostream &Out, +LLVM_ABI bool yaml2offload(OffloadYAML::Binary &Doc, raw_ostream &Out, ErrorHandler EH); +LLVM_ABI bool yaml2wasm(WasmYAML::Object &Doc, raw_ostream &Out, ErrorHandler EH); +LLVM_ABI bool yaml2xcoff(XCOFFYAML::Object &Doc, raw_ostream &Out, ErrorHandler EH); +LLVM_ABI bool yaml2dxcontainer(DXContainerYAML::Object &Doc, raw_ostream &Out, ErrorHandler EH); -bool convertYAML(Input &YIn, raw_ostream &Out, ErrorHandler ErrHandler, +LLVM_ABI bool convertYAML(Input &YIn, raw_ostream &Out, ErrorHandler ErrHandler, unsigned DocNum = 1, uint64_t MaxSize = UINT64_MAX); /// Convenience function for tests. -std::unique_ptr +LLVM_ABI std::unique_ptr yaml2ObjectFile(SmallVectorImpl &Storage, StringRef Yaml, ErrorHandler ErrHandler); From ed67dda05390b837bba43cc2a340da1be573dc3f Mon Sep 17 00:00:00 2001 From: Andrew Rogers Date: Wed, 11 Jun 2025 11:09:18 -0700 Subject: [PATCH 2/2] [llvm] clang-format changes to ObjectYAML library --- .../ObjectYAML/CodeViewYAMLDebugSections.h | 7 ++-- .../llvm/ObjectYAML/CodeViewYAMLSymbols.h | 5 +-- .../llvm/ObjectYAML/CodeViewYAMLTypes.h | 11 +++--- llvm/include/llvm/ObjectYAML/DWARFEmitter.h | 2 +- llvm/include/llvm/ObjectYAML/DWARFYAML.h | 11 +++--- .../include/llvm/ObjectYAML/DXContainerYAML.h | 36 +++++++++++-------- llvm/include/llvm/ObjectYAML/YAML.h | 2 +- llvm/include/llvm/ObjectYAML/yaml2obj.h | 31 +++++++++------- 8 files changed, 63 insertions(+), 42 deletions(-) diff --git a/llvm/include/llvm/ObjectYAML/CodeViewYAMLDebugSections.h b/llvm/include/llvm/ObjectYAML/CodeViewYAMLDebugSections.h index ef58c5c650fc4..4e7984c54a72a 100644 --- a/llvm/include/llvm/ObjectYAML/CodeViewYAMLDebugSections.h +++ b/llvm/include/llvm/ObjectYAML/CodeViewYAMLDebugSections.h @@ -14,12 +14,12 @@ #ifndef LLVM_OBJECTYAML_CODEVIEWYAMLDEBUGSECTIONS_H #define LLVM_OBJECTYAML_CODEVIEWYAMLDEBUGSECTIONS_H -#include "llvm/Support/Compiler.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/Support/Compiler.h" #include "llvm/Support/Error.h" #include "llvm/Support/YAMLTraits.h" #include @@ -124,8 +124,9 @@ toCodeViewSubsectionList(BumpPtrAllocator &Allocator, LLVM_ABI std::vector fromDebugS(ArrayRef Data, const codeview::StringsAndChecksumsRef &SC); -LLVM_ABI void initializeStringsAndChecksums(ArrayRef Sections, - codeview::StringsAndChecksums &SC); +LLVM_ABI void +initializeStringsAndChecksums(ArrayRef Sections, + codeview::StringsAndChecksums &SC); } // end namespace CodeViewYAML diff --git a/llvm/include/llvm/ObjectYAML/CodeViewYAMLSymbols.h b/llvm/include/llvm/ObjectYAML/CodeViewYAMLSymbols.h index 6a8d6897a3ab8..dccc77dc1a0c5 100644 --- a/llvm/include/llvm/ObjectYAML/CodeViewYAMLSymbols.h +++ b/llvm/include/llvm/ObjectYAML/CodeViewYAMLSymbols.h @@ -14,9 +14,9 @@ #ifndef LLVM_OBJECTYAML_CODEVIEWYAMLSYMBOLS_H #define LLVM_OBJECTYAML_CODEVIEWYAMLSYMBOLS_H -#include "llvm/Support/Compiler.h" #include "llvm/DebugInfo/CodeView/CodeView.h" #include "llvm/DebugInfo/CodeView/SymbolRecord.h" +#include "llvm/Support/Compiler.h" #include "llvm/Support/Error.h" #include "llvm/Support/YAMLTraits.h" #include @@ -37,7 +37,8 @@ struct SymbolRecord { toCodeViewSymbol(BumpPtrAllocator &Allocator, codeview::CodeViewContainer Container) const; - LLVM_ABI static Expected fromCodeViewSymbol(codeview::CVSymbol Symbol); + LLVM_ABI static Expected + fromCodeViewSymbol(codeview::CVSymbol Symbol); }; } // end namespace CodeViewYAML diff --git a/llvm/include/llvm/ObjectYAML/CodeViewYAMLTypes.h b/llvm/include/llvm/ObjectYAML/CodeViewYAMLTypes.h index c8a349350cb7b..3c239ce507dfc 100644 --- a/llvm/include/llvm/ObjectYAML/CodeViewYAMLTypes.h +++ b/llvm/include/llvm/ObjectYAML/CodeViewYAMLTypes.h @@ -14,10 +14,10 @@ #ifndef LLVM_OBJECTYAML_CODEVIEWYAMLTYPES_H #define LLVM_OBJECTYAML_CODEVIEWYAMLTYPES_H -#include "llvm/Support/Compiler.h" #include "llvm/ADT/ArrayRef.h" #include "llvm/DebugInfo/CodeView/TypeRecord.h" #include "llvm/Support/Allocator.h" +#include "llvm/Support/Compiler.h" #include "llvm/Support/Error.h" #include "llvm/Support/YAMLTraits.h" #include @@ -48,13 +48,14 @@ struct LeafRecord { LLVM_ABI codeview::CVType toCodeViewRecord(codeview::AppendingTypeTableBuilder &Serializer) const; - LLVM_ABI static Expected fromCodeViewRecord(codeview::CVType Type); + LLVM_ABI static Expected + fromCodeViewRecord(codeview::CVType Type); }; LLVM_ABI std::vector fromDebugT(ArrayRef DebugTorP, - StringRef SectionName); -LLVM_ABI ArrayRef toDebugT(ArrayRef, BumpPtrAllocator &Alloc, - StringRef SectionName); + StringRef SectionName); +LLVM_ABI ArrayRef +toDebugT(ArrayRef, BumpPtrAllocator &Alloc, StringRef SectionName); } // end namespace CodeViewYAML diff --git a/llvm/include/llvm/ObjectYAML/DWARFEmitter.h b/llvm/include/llvm/ObjectYAML/DWARFEmitter.h index f907bc046837f..050ff60bcd408 100644 --- a/llvm/include/llvm/ObjectYAML/DWARFEmitter.h +++ b/llvm/include/llvm/ObjectYAML/DWARFEmitter.h @@ -12,9 +12,9 @@ #ifndef LLVM_OBJECTYAML_DWARFEMITTER_H #define LLVM_OBJECTYAML_DWARFEMITTER_H -#include "llvm/Support/Compiler.h" #include "llvm/ADT/StringMap.h" #include "llvm/ADT/StringRef.h" +#include "llvm/Support/Compiler.h" #include "llvm/Support/Error.h" #include "llvm/Support/MemoryBuffer.h" #include "llvm/TargetParser/Host.h" diff --git a/llvm/include/llvm/ObjectYAML/DWARFYAML.h b/llvm/include/llvm/ObjectYAML/DWARFYAML.h index 803ddf3bf049d..c8528686592ab 100644 --- a/llvm/include/llvm/ObjectYAML/DWARFYAML.h +++ b/llvm/include/llvm/ObjectYAML/DWARFYAML.h @@ -15,11 +15,11 @@ #ifndef LLVM_OBJECTYAML_DWARFYAML_H #define LLVM_OBJECTYAML_DWARFYAML_H -#include "llvm/Support/Compiler.h" #include "llvm/ADT/SetVector.h" #include "llvm/ADT/StringRef.h" #include "llvm/BinaryFormat/Dwarf.h" #include "llvm/ObjectYAML/YAML.h" +#include "llvm/Support/Compiler.h" #include "llvm/Support/YAMLTraits.h" #include #include @@ -380,7 +380,8 @@ template <> struct MappingTraits { }; template <> struct MappingTraits { - LLVM_ABI static void mapping(IO &IO, DWARFYAML::LineTableOpcode &LineTableOpcode); + LLVM_ABI static void mapping(IO &IO, + DWARFYAML::LineTableOpcode &LineTableOpcode); }; template <> struct MappingTraits { @@ -392,7 +393,8 @@ template <> struct MappingTraits { }; template <> struct MappingTraits { - LLVM_ABI static void mapping(IO &IO, DWARFYAML::DWARFOperation &DWARFOperation); + LLVM_ABI static void mapping(IO &IO, + DWARFYAML::DWARFOperation &DWARFOperation); }; template @@ -420,7 +422,8 @@ template <> struct MappingTraits { }; template <> struct MappingTraits { - LLVM_ABI static void mapping(IO &IO, DWARFYAML::StringOffsetsTable &StrOffsetsTable); + LLVM_ABI static void mapping(IO &IO, + DWARFYAML::StringOffsetsTable &StrOffsetsTable); }; template <> struct ScalarEnumerationTraits { diff --git a/llvm/include/llvm/ObjectYAML/DXContainerYAML.h b/llvm/include/llvm/ObjectYAML/DXContainerYAML.h index 8000b69a34b2d..c235112dacf7c 100644 --- a/llvm/include/llvm/ObjectYAML/DXContainerYAML.h +++ b/llvm/include/llvm/ObjectYAML/DXContainerYAML.h @@ -15,11 +15,11 @@ #ifndef LLVM_OBJECTYAML_DXCONTAINERYAML_H #define LLVM_OBJECTYAML_DXCONTAINERYAML_H -#include "llvm/Support/Compiler.h" #include "llvm/ADT/StringRef.h" #include "llvm/BinaryFormat/DXContainer.h" #include "llvm/Object/DXContainer.h" #include "llvm/ObjectYAML/YAML.h" +#include "llvm/Support/Compiler.h" #include "llvm/Support/YAMLTraits.h" #include #include @@ -341,7 +341,8 @@ template <> struct MappingTraits { }; template <> struct MappingTraits { - LLVM_ABI static void mapping(IO &IO, DXContainerYAML::ShaderFeatureFlags &Flags); + LLVM_ABI static void mapping(IO &IO, + DXContainerYAML::ShaderFeatureFlags &Flags); }; template <> struct MappingTraits { @@ -369,11 +370,13 @@ template <> struct MappingTraits { }; template <> struct MappingTraits { - LLVM_ABI static void mapping(IO &IO, llvm::DXContainerYAML::SignatureElement &El); + LLVM_ABI static void mapping(IO &IO, + llvm::DXContainerYAML::SignatureElement &El); }; template <> struct MappingTraits { - LLVM_ABI static void mapping(IO &IO, llvm::DXContainerYAML::SignatureParameter &El); + LLVM_ABI static void mapping(IO &IO, + llvm::DXContainerYAML::SignatureParameter &El); }; template <> struct MappingTraits { @@ -381,36 +384,41 @@ template <> struct MappingTraits { }; template <> struct MappingTraits { - LLVM_ABI static void mapping(IO &IO, - DXContainerYAML::RootSignatureYamlDesc &RootSignature); + LLVM_ABI static void + mapping(IO &IO, DXContainerYAML::RootSignatureYamlDesc &RootSignature); }; template <> struct MappingContextTraits { - LLVM_ABI static void mapping(IO &IO, - llvm::DXContainerYAML::RootParameterLocationYaml &L, - DXContainerYAML::RootSignatureYamlDesc &S); + LLVM_ABI static void + mapping(IO &IO, llvm::DXContainerYAML::RootParameterLocationYaml &L, + DXContainerYAML::RootSignatureYamlDesc &S); }; template <> struct MappingTraits { - LLVM_ABI static void mapping(IO &IO, llvm::DXContainerYAML::RootConstantsYaml &C); + LLVM_ABI static void mapping(IO &IO, + llvm::DXContainerYAML::RootConstantsYaml &C); }; template <> struct MappingTraits { - LLVM_ABI static void mapping(IO &IO, llvm::DXContainerYAML::RootDescriptorYaml &D); + LLVM_ABI static void mapping(IO &IO, + llvm::DXContainerYAML::RootDescriptorYaml &D); }; template <> struct MappingTraits { - LLVM_ABI static void mapping(IO &IO, llvm::DXContainerYAML::DescriptorTableYaml &D); + LLVM_ABI static void mapping(IO &IO, + llvm::DXContainerYAML::DescriptorTableYaml &D); }; template <> struct MappingTraits { - LLVM_ABI static void mapping(IO &IO, llvm::DXContainerYAML::DescriptorRangeYaml &D); + LLVM_ABI static void mapping(IO &IO, + llvm::DXContainerYAML::DescriptorRangeYaml &D); }; template <> struct MappingTraits { - LLVM_ABI static void mapping(IO &IO, llvm::DXContainerYAML::StaticSamplerYamlDesc &S); + LLVM_ABI static void mapping(IO &IO, + llvm::DXContainerYAML::StaticSamplerYamlDesc &S); }; } // namespace yaml diff --git a/llvm/include/llvm/ObjectYAML/YAML.h b/llvm/include/llvm/ObjectYAML/YAML.h index 2b686615af3b0..709520c934d7d 100644 --- a/llvm/include/llvm/ObjectYAML/YAML.h +++ b/llvm/include/llvm/ObjectYAML/YAML.h @@ -9,9 +9,9 @@ #ifndef LLVM_OBJECTYAML_YAML_H #define LLVM_OBJECTYAML_YAML_H -#include "llvm/Support/Compiler.h" #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/StringRef.h" +#include "llvm/Support/Compiler.h" #include "llvm/Support/YAMLTraits.h" #include diff --git a/llvm/include/llvm/ObjectYAML/yaml2obj.h b/llvm/include/llvm/ObjectYAML/yaml2obj.h index a7961840716e4..4c9084b790507 100644 --- a/llvm/include/llvm/ObjectYAML/yaml2obj.h +++ b/llvm/include/llvm/ObjectYAML/yaml2obj.h @@ -11,8 +11,8 @@ #ifndef LLVM_OBJECTYAML_YAML2OBJ_H #define LLVM_OBJECTYAML_YAML2OBJ_H -#include "llvm/Support/Compiler.h" #include "llvm/ADT/STLExtras.h" +#include "llvm/Support/Compiler.h" #include namespace llvm { @@ -67,22 +67,29 @@ struct YamlObjectFile; using ErrorHandler = llvm::function_ref; -LLVM_ABI bool yaml2archive(ArchYAML::Archive &Doc, raw_ostream &Out, ErrorHandler EH); -LLVM_ABI bool yaml2coff(COFFYAML::Object &Doc, raw_ostream &Out, ErrorHandler EH); -LLVM_ABI bool yaml2goff(GOFFYAML::Object &Doc, raw_ostream &Out, ErrorHandler EH); +LLVM_ABI bool yaml2archive(ArchYAML::Archive &Doc, raw_ostream &Out, + ErrorHandler EH); +LLVM_ABI bool yaml2coff(COFFYAML::Object &Doc, raw_ostream &Out, + ErrorHandler EH); +LLVM_ABI bool yaml2goff(GOFFYAML::Object &Doc, raw_ostream &Out, + ErrorHandler EH); LLVM_ABI bool yaml2elf(ELFYAML::Object &Doc, raw_ostream &Out, ErrorHandler EH, - uint64_t MaxSize); -LLVM_ABI bool yaml2macho(YamlObjectFile &Doc, raw_ostream &Out, ErrorHandler EH); + uint64_t MaxSize); +LLVM_ABI bool yaml2macho(YamlObjectFile &Doc, raw_ostream &Out, + ErrorHandler EH); LLVM_ABI bool yaml2minidump(MinidumpYAML::Object &Doc, raw_ostream &Out, - ErrorHandler EH); -LLVM_ABI bool yaml2offload(OffloadYAML::Binary &Doc, raw_ostream &Out, ErrorHandler EH); -LLVM_ABI bool yaml2wasm(WasmYAML::Object &Doc, raw_ostream &Out, ErrorHandler EH); -LLVM_ABI bool yaml2xcoff(XCOFFYAML::Object &Doc, raw_ostream &Out, ErrorHandler EH); + ErrorHandler EH); +LLVM_ABI bool yaml2offload(OffloadYAML::Binary &Doc, raw_ostream &Out, + ErrorHandler EH); +LLVM_ABI bool yaml2wasm(WasmYAML::Object &Doc, raw_ostream &Out, + ErrorHandler EH); +LLVM_ABI bool yaml2xcoff(XCOFFYAML::Object &Doc, raw_ostream &Out, + ErrorHandler EH); LLVM_ABI bool yaml2dxcontainer(DXContainerYAML::Object &Doc, raw_ostream &Out, - ErrorHandler EH); + ErrorHandler EH); LLVM_ABI bool convertYAML(Input &YIn, raw_ostream &Out, ErrorHandler ErrHandler, - unsigned DocNum = 1, uint64_t MaxSize = UINT64_MAX); + unsigned DocNum = 1, uint64_t MaxSize = UINT64_MAX); /// Convenience function for tests. LLVM_ABI std::unique_ptr