Skip to content

Commit 6f44953

Browse files
committed
Move yaml::Opt to yaml::IO::OptBase [-fpermissive]
1 parent 4b47bb2 commit 6f44953

File tree

3 files changed

+28
-23
lines changed

3 files changed

+28
-23
lines changed

llvm/include/llvm/ObjectYAML/ELFYAML.h

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -788,11 +788,11 @@ bool shouldAllocateFileSpace(ArrayRef<ProgramHeader> Phdrs,
788788
///
789789
/// Derivered classes should not modify OptClassID to ensue that
790790
/// dyn_cast<ELFYAML::Opt> can find this interface.
791-
class Opt : public yaml::Opt {
791+
class Opt : public yaml::IO::OptBase {
792792
public:
793793
Opt() {
794+
OptBaseClassID = &ID;
794795
OptClassID = &ID;
795-
ELFOptClassID = &ID;
796796
}
797797
~Opt();
798798

@@ -811,13 +811,15 @@ class Opt : public yaml::Opt {
811811
virtual void postMapping(const ELFYAML::Object &Object,
812812
bool IsOutputting) = 0;
813813

814-
/// Tell IO::Opt to be this and derivered classes.
815-
static bool classof(const yaml::Opt *Obj) { return (Obj->OptClassID == &ID); }
814+
/// Tell IO::OptBase to be this and derivered classes.
815+
static bool classof(const yaml::IO::OptBase *Obj) {
816+
return (Obj->OptBaseClassID == &ID);
817+
}
816818

817819
/// This will be not needed unless the pointer to ELFYAML::Opt would
818820
/// be cast further.
819-
static bool classof(const Opt *Obj) { return (Obj->ELFOptClassID == &ID); }
820-
const char *ELFOptClassID;
821+
static bool classof(const Opt *Obj) { return (Obj->OptClassID == &ID); }
822+
const char *OptClassID;
821823

822824
private:
823825
static const char ID;

llvm/include/llvm/Support/YAMLTraits.h

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -39,18 +39,6 @@ class VersionTuple;
3939

4040
namespace yaml {
4141

42-
/// The base class of options.
43-
class Opt {
44-
public:
45-
virtual ~Opt();
46-
47-
static bool classof(const Opt *Obj) { return (Obj->OptClassID == &ID); }
48-
const char *OptClassID = &ID;
49-
50-
private:
51-
static const char ID;
52-
};
53-
5442
enum class NodeKind : uint8_t {
5543
Scalar,
5644
Map,
@@ -974,13 +962,28 @@ class IO {
974962
}
975963
}
976964

965+
public:
966+
/// The base class of options.
967+
class OptBase {
968+
public:
969+
virtual ~OptBase();
970+
971+
static bool classof(const OptBase *Obj) {
972+
return (Obj->OptBaseClassID == &ID);
973+
}
974+
const char *OptBaseClassID = &ID;
975+
976+
private:
977+
static const char ID;
978+
};
979+
977980
private:
978981
void *Ctxt;
979-
Opt DefaultOpt;
982+
OptBase DefaultOpt;
980983

981984
public:
982985
/// This may be overwritten in derivered classes.
983-
Opt *Opt = &DefaultOpt;
986+
OptBase *Opt = &DefaultOpt;
984987
};
985988

986989
namespace detail {

llvm/lib/Support/YAMLTraits.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,12 @@ using namespace llvm;
3232
using namespace yaml;
3333

3434
//===----------------------------------------------------------------------===//
35-
// Opt
35+
// IO::OptBase
3636
//===----------------------------------------------------------------------===//
3737

38-
Opt::~Opt() = default;
38+
IO::OptBase::~OptBase() = default;
3939

40-
const char Opt::ID = '@';
40+
const char IO::OptBase::ID = '@';
4141

4242
//===----------------------------------------------------------------------===//
4343
// IO

0 commit comments

Comments
 (0)