1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-22 02:33:06 +01:00

[M68k][NFC] Rename M68kOperand::Kind to KindTy

Rename the M68kOperand::Type enumeration to KindTy to avoid ambiguity
with the Kind field when referencing enumeration values e.g.
`Kind::Value`.

This works around a compilation error under GCC 5, where GCC won't
lookup enum class values if you have a similarly named field
(see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60994).

The error in question is:
`M68kAsmParser.cpp:857:8: error: 'Kind' is not a class, namespace, or enumeration`

Differential Revision: https://reviews.llvm.org/D108723

(cherry picked from commit f659b6b1fa43ffb8c95dbbf767ef57f6e964e7f6)
This commit is contained in:
Ricky Taylor 2021-08-25 20:48:28 +01:00 committed by Tom Stellard
parent ab550c798f
commit de85b171b7

View File

@ -117,14 +117,14 @@ struct M68kMemOp {
class M68kOperand : public MCParsedAsmOperand {
typedef MCParsedAsmOperand Base;
enum class Kind {
enum class KindTy {
Invalid,
Token,
Imm,
MemOp,
};
Kind Kind;
KindTy Kind;
SMLoc Start, End;
union {
StringRef Token;
@ -134,7 +134,7 @@ class M68kOperand : public MCParsedAsmOperand {
};
public:
M68kOperand(enum Kind Kind, SMLoc Start, SMLoc End)
M68kOperand(KindTy Kind, SMLoc Start, SMLoc End)
: Base(), Kind(Kind), Start(Start), End(End) {}
SMLoc getStartLoc() const override { return Start; }
@ -143,7 +143,7 @@ public:
void print(raw_ostream &OS) const override;
bool isMem() const override { return false; }
bool isMemOp() const { return Kind == Kind::MemOp; }
bool isMemOp() const { return Kind == KindTy::MemOp; }
static void addExpr(MCInst &Inst, const MCExpr *Expr);
@ -248,7 +248,7 @@ void M68kOperand::addExpr(MCInst &Inst, const MCExpr *Expr) {
// Reg
bool M68kOperand::isReg() const {
return Kind == Kind::MemOp && MemOp.Op == M68kMemOp::Kind::Reg;
return Kind == KindTy::MemOp && MemOp.Op == M68kMemOp::Kind::Reg;
}
unsigned M68kOperand::getReg() const {
@ -265,13 +265,13 @@ void M68kOperand::addRegOperands(MCInst &Inst, unsigned N) const {
std::unique_ptr<M68kOperand> M68kOperand::createMemOp(M68kMemOp MemOp,
SMLoc Start, SMLoc End) {
auto Op = std::make_unique<M68kOperand>(Kind::MemOp, Start, End);
auto Op = std::make_unique<M68kOperand>(KindTy::MemOp, Start, End);
Op->MemOp = MemOp;
return Op;
}
// Token
bool M68kOperand::isToken() const { return Kind == Kind::Token; }
bool M68kOperand::isToken() const { return Kind == KindTy::Token; }
StringRef M68kOperand::getToken() const {
assert(isToken());
return Token;
@ -279,13 +279,13 @@ StringRef M68kOperand::getToken() const {
std::unique_ptr<M68kOperand> M68kOperand::createToken(StringRef Token,
SMLoc Start, SMLoc End) {
auto Op = std::make_unique<M68kOperand>(Kind::Token, Start, End);
auto Op = std::make_unique<M68kOperand>(KindTy::Token, Start, End);
Op->Token = Token;
return Op;
}
// Imm
bool M68kOperand::isImm() const { return Kind == Kind::Imm; }
bool M68kOperand::isImm() const { return Kind == KindTy::Imm; }
void M68kOperand::addImmOperands(MCInst &Inst, unsigned N) const {
assert(isImm() && "wrong oeprand kind");
assert((N == 1) && "can only handle one register operand");
@ -295,7 +295,7 @@ void M68kOperand::addImmOperands(MCInst &Inst, unsigned N) const {
std::unique_ptr<M68kOperand> M68kOperand::createImm(const MCExpr *Expr,
SMLoc Start, SMLoc End) {
auto Op = std::make_unique<M68kOperand>(Kind::Imm, Start, End);
auto Op = std::make_unique<M68kOperand>(KindTy::Imm, Start, End);
Op->Expr = Expr;
return Op;
}
@ -842,19 +842,19 @@ bool M68kAsmParser::MatchAndEmitInstruction(SMLoc Loc, unsigned &Opcode,
void M68kOperand::print(raw_ostream &OS) const {
switch (Kind) {
case Kind::Invalid:
case KindTy::Invalid:
OS << "invalid";
break;
case Kind::Token:
case KindTy::Token:
OS << "token '" << Token << "'";
break;
case Kind::Imm:
case KindTy::Imm:
OS << "immediate " << Imm;
break;
case Kind::MemOp:
case KindTy::MemOp:
MemOp.print(OS);
break;
}