Skip to content

Commit 9f7a0c4

Browse files
committed
Make ELFYAML::Opt non-abstract
1 parent 6f44953 commit 9f7a0c4

File tree

4 files changed

+21
-32
lines changed

4 files changed

+21
-32
lines changed

llvm/include/llvm/ObjectYAML/ELFYAML.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -778,8 +778,8 @@ struct Object {
778778
bool shouldAllocateFileSpace(ArrayRef<ProgramHeader> Phdrs,
779779
const NoBitsSection &S);
780780

781-
/// ELFYAML::Opt -- Abstract base class for ELFYAML to provide
782-
/// the interface for handling CustomRawConetentSection.
781+
/// ELFYAML::Opt -- Null base class for ELFYAML to provide the
782+
/// interface for handling CustomRawConetentSection.
783783
///
784784
/// Users in ELFYAML should obtain the pointer with
785785
/// dyn_cast<ELFYAML::Opt> if IO::Opt is the instance from yaml::Opt.
@@ -801,15 +801,15 @@ class Opt : public yaml::IO::OptBase {
801801
/// This is called:
802802
/// - Before preMapping for elf2yaml.
803803
/// - After preMapping for yaml2elf.
804+
/// Returns nullptr to delegate default actions.
804805
virtual std::unique_ptr<CustomRawContentSection>
805-
makeCustomRawContentSection(StringRef Name) const = 0;
806+
makeCustomRawContentSection(StringRef Name) const;
806807

807808
/// Called before mapping sections for prettyprinting yaml.
808-
virtual void preMapping(const ELFYAML::Object &Object, bool IsOutputting) = 0;
809+
virtual void preMapping(const ELFYAML::Object &Object, bool IsOutputting);
809810

810811
/// Called after mapping sections to gather members for the file format.
811-
virtual void postMapping(const ELFYAML::Object &Object,
812-
bool IsOutputting) = 0;
812+
virtual void postMapping(const ELFYAML::Object &Object, bool IsOutputting);
813813

814814
/// Tell IO::OptBase to be this and derivered classes.
815815
static bool classof(const yaml::IO::OptBase *Obj) {

llvm/lib/ObjectYAML/ELFYAML.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,19 @@ ELFYAML::Chunk::~Chunk() = default;
3232
ELFYAML::Opt::~Opt() = default;
3333
const char ELFYAML::Opt::ID = 'E';
3434

35+
std::unique_ptr<ELFYAML::CustomRawContentSection>
36+
ELFYAML::Opt::makeCustomRawContentSection(StringRef Name) const {
37+
return nullptr;
38+
}
39+
40+
/// Called before mapping sections for prettyprinting yaml.
41+
void ELFYAML::Opt::preMapping(const ELFYAML::Object &Object,
42+
bool IsOutputting) {}
43+
44+
/// Called after mapping sections to gather members for the file format.
45+
void ELFYAML::Opt::postMapping(const ELFYAML::Object &Object,
46+
bool IsOutputting) {}
47+
3548
namespace ELFYAML {
3649
ELF_ELFOSABI Object::getOSAbi() const { return Header.OSABI; }
3750

llvm/tools/obj2yaml/elf2yaml.cpp

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,7 @@
2222
using namespace llvm;
2323

2424
namespace {
25-
class DumperOpt : public ELFYAML::Opt {
26-
public:
27-
std::unique_ptr<ELFYAML::CustomRawContentSection>
28-
makeCustomRawContentSection(StringRef Name) const override {
29-
return nullptr;
30-
}
31-
void preMapping(const ELFYAML::Object &Object, bool IsOutputting) override {
32-
// Do nothing.
33-
}
34-
void postMapping(const ELFYAML::Object &Object, bool IsOutputting) override {
35-
// Do nothing.
36-
}
37-
};
25+
struct DumperOpt : public ELFYAML::Opt {};
3826

3927
template <class ELFT>
4028
class ELFDumper {

llvm/tools/yaml2obj/yaml2obj.cpp

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -59,19 +59,7 @@ cl::opt<std::string> OutputFilename("o", cl::desc("Output filename"),
5959
cl::value_desc("filename"), cl::init("-"),
6060
cl::Prefix, cl::cat(Cat));
6161

62-
class EmitterOpt : public ELFYAML::Opt {
63-
public:
64-
std::unique_ptr<ELFYAML::CustomRawContentSection>
65-
makeCustomRawContentSection(StringRef Name) const override {
66-
return nullptr;
67-
}
68-
void preMapping(const ELFYAML::Object &Object, bool IsOutputting) override {
69-
// Do nothing.
70-
}
71-
void postMapping(const ELFYAML::Object &Object, bool IsOutputting) override {
72-
// Do nothing.
73-
}
74-
};
62+
struct EmitterOpt : public ELFYAML::Opt {};
7563
} // namespace
7664

7765
static std::optional<std::string> preprocess(StringRef Buf,

0 commit comments

Comments
 (0)