diff options
| author | NAKAMURA Takumi <geek4civic@gmail.com> | 2024-11-14 22:10:06 +0900 |
|---|---|---|
| committer | NAKAMURA Takumi <geek4civic@gmail.com> | 2024-11-14 22:10:06 +0900 |
| commit | 9f7a0c4524bd95f39ddde9c254920ba7dd13510a (patch) | |
| tree | f07eade2b9f5154b8965549efb0a21248ce9c610 | |
| parent | 6f449538308c796295e78931bc0e27cd6b979122 (diff) | |
Make ELFYAML::Opt non-abstract
| -rw-r--r-- | llvm/include/llvm/ObjectYAML/ELFYAML.h | 12 | ||||
| -rw-r--r-- | llvm/lib/ObjectYAML/ELFYAML.cpp | 13 | ||||
| -rw-r--r-- | llvm/tools/obj2yaml/elf2yaml.cpp | 14 | ||||
| -rw-r--r-- | llvm/tools/yaml2obj/yaml2obj.cpp | 14 |
4 files changed, 21 insertions, 32 deletions
diff --git a/llvm/include/llvm/ObjectYAML/ELFYAML.h b/llvm/include/llvm/ObjectYAML/ELFYAML.h index 983d9fe9c332..59af9ac8851c 100644 --- a/llvm/include/llvm/ObjectYAML/ELFYAML.h +++ b/llvm/include/llvm/ObjectYAML/ELFYAML.h @@ -778,8 +778,8 @@ struct Object { bool shouldAllocateFileSpace(ArrayRef<ProgramHeader> Phdrs, const NoBitsSection &S); -/// ELFYAML::Opt -- Abstract base class for ELFYAML to provide -/// the interface for handling CustomRawConetentSection. +/// ELFYAML::Opt -- Null base class for ELFYAML to provide the +/// interface for handling CustomRawConetentSection. /// /// Users in ELFYAML should obtain the pointer with /// dyn_cast<ELFYAML::Opt> if IO::Opt is the instance from yaml::Opt. @@ -801,15 +801,15 @@ public: /// This is called: /// - Before preMapping for elf2yaml. /// - After preMapping for yaml2elf. + /// Returns nullptr to delegate default actions. virtual std::unique_ptr<CustomRawContentSection> - makeCustomRawContentSection(StringRef Name) const = 0; + makeCustomRawContentSection(StringRef Name) const; /// Called before mapping sections for prettyprinting yaml. - virtual void preMapping(const ELFYAML::Object &Object, bool IsOutputting) = 0; + virtual void preMapping(const ELFYAML::Object &Object, bool IsOutputting); /// Called after mapping sections to gather members for the file format. - virtual void postMapping(const ELFYAML::Object &Object, - bool IsOutputting) = 0; + virtual void postMapping(const ELFYAML::Object &Object, bool IsOutputting); /// Tell IO::OptBase to be this and derivered classes. static bool classof(const yaml::IO::OptBase *Obj) { diff --git a/llvm/lib/ObjectYAML/ELFYAML.cpp b/llvm/lib/ObjectYAML/ELFYAML.cpp index aff2d5e18ce8..83ee88e57d66 100644 --- a/llvm/lib/ObjectYAML/ELFYAML.cpp +++ b/llvm/lib/ObjectYAML/ELFYAML.cpp @@ -32,6 +32,19 @@ ELFYAML::Chunk::~Chunk() = default; ELFYAML::Opt::~Opt() = default; const char ELFYAML::Opt::ID = 'E'; +std::unique_ptr<ELFYAML::CustomRawContentSection> +ELFYAML::Opt::makeCustomRawContentSection(StringRef Name) const { + return nullptr; +} + +/// Called before mapping sections for prettyprinting yaml. +void ELFYAML::Opt::preMapping(const ELFYAML::Object &Object, + bool IsOutputting) {} + +/// Called after mapping sections to gather members for the file format. +void ELFYAML::Opt::postMapping(const ELFYAML::Object &Object, + bool IsOutputting) {} + namespace ELFYAML { ELF_ELFOSABI Object::getOSAbi() const { return Header.OSABI; } diff --git a/llvm/tools/obj2yaml/elf2yaml.cpp b/llvm/tools/obj2yaml/elf2yaml.cpp index 7ef5db512b6b..d3fbe9c2d17c 100644 --- a/llvm/tools/obj2yaml/elf2yaml.cpp +++ b/llvm/tools/obj2yaml/elf2yaml.cpp @@ -22,19 +22,7 @@ using namespace llvm; namespace { -class DumperOpt : public ELFYAML::Opt { -public: - std::unique_ptr<ELFYAML::CustomRawContentSection> - makeCustomRawContentSection(StringRef Name) const override { - return nullptr; - } - void preMapping(const ELFYAML::Object &Object, bool IsOutputting) override { - // Do nothing. - } - void postMapping(const ELFYAML::Object &Object, bool IsOutputting) override { - // Do nothing. - } -}; +struct DumperOpt : public ELFYAML::Opt {}; template <class ELFT> class ELFDumper { diff --git a/llvm/tools/yaml2obj/yaml2obj.cpp b/llvm/tools/yaml2obj/yaml2obj.cpp index 3d356dc7a006..b899b8d7cdf2 100644 --- a/llvm/tools/yaml2obj/yaml2obj.cpp +++ b/llvm/tools/yaml2obj/yaml2obj.cpp @@ -59,19 +59,7 @@ cl::opt<std::string> OutputFilename("o", cl::desc("Output filename"), cl::value_desc("filename"), cl::init("-"), cl::Prefix, cl::cat(Cat)); -class EmitterOpt : public ELFYAML::Opt { -public: - std::unique_ptr<ELFYAML::CustomRawContentSection> - makeCustomRawContentSection(StringRef Name) const override { - return nullptr; - } - void preMapping(const ELFYAML::Object &Object, bool IsOutputting) override { - // Do nothing. - } - void postMapping(const ELFYAML::Object &Object, bool IsOutputting) override { - // Do nothing. - } -}; +struct EmitterOpt : public ELFYAML::Opt {}; } // namespace static std::optional<std::string> preprocess(StringRef Buf, |
