Skip to content

Commit a93e47b

Browse files
authored
[M68k][NFC] Rename M68kOperand::Kind to KindTy (#112)
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
1 parent e6c5dd4 commit a93e47b

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

llvm/lib/Target/M68k/AsmParser/M68kAsmParser.cpp

+14-14
Original file line numberDiff line numberDiff line change
@@ -117,14 +117,14 @@ struct M68kMemOp {
117117
class M68kOperand : public MCParsedAsmOperand {
118118
typedef MCParsedAsmOperand Base;
119119

120-
enum class Kind {
120+
enum class KindTy {
121121
Invalid,
122122
Token,
123123
Imm,
124124
MemOp,
125125
};
126126

127-
Kind Kind;
127+
KindTy Kind;
128128
SMLoc Start, End;
129129
union {
130130
StringRef Token;
@@ -134,7 +134,7 @@ class M68kOperand : public MCParsedAsmOperand {
134134
};
135135

136136
public:
137-
M68kOperand(enum Kind Kind, SMLoc Start, SMLoc End)
137+
M68kOperand(KindTy Kind, SMLoc Start, SMLoc End)
138138
: Base(), Kind(Kind), Start(Start), End(End) {}
139139

140140
SMLoc getStartLoc() const override { return Start; }
@@ -143,7 +143,7 @@ class M68kOperand : public MCParsedAsmOperand {
143143
void print(raw_ostream &OS) const override;
144144

145145
bool isMem() const override { return false; }
146-
bool isMemOp() const { return Kind == Kind::MemOp; }
146+
bool isMemOp() const { return Kind == KindTy::MemOp; }
147147

148148
static void addExpr(MCInst &Inst, const MCExpr *Expr);
149149

@@ -248,7 +248,7 @@ void M68kOperand::addExpr(MCInst &Inst, const MCExpr *Expr) {
248248

249249
// Reg
250250
bool M68kOperand::isReg() const {
251-
return Kind == Kind::MemOp && MemOp.Op == M68kMemOp::Kind::Reg;
251+
return Kind == KindTy::MemOp && MemOp.Op == M68kMemOp::Kind::Reg;
252252
}
253253

254254
unsigned M68kOperand::getReg() const {
@@ -265,27 +265,27 @@ void M68kOperand::addRegOperands(MCInst &Inst, unsigned N) const {
265265

266266
std::unique_ptr<M68kOperand> M68kOperand::createMemOp(M68kMemOp MemOp,
267267
SMLoc Start, SMLoc End) {
268-
auto Op = std::make_unique<M68kOperand>(Kind::MemOp, Start, End);
268+
auto Op = std::make_unique<M68kOperand>(KindTy::MemOp, Start, End);
269269
Op->MemOp = MemOp;
270270
return Op;
271271
}
272272

273273
// Token
274-
bool M68kOperand::isToken() const { return Kind == Kind::Token; }
274+
bool M68kOperand::isToken() const { return Kind == KindTy::Token; }
275275
StringRef M68kOperand::getToken() const {
276276
assert(isToken());
277277
return Token;
278278
}
279279

280280
std::unique_ptr<M68kOperand> M68kOperand::createToken(StringRef Token,
281281
SMLoc Start, SMLoc End) {
282-
auto Op = std::make_unique<M68kOperand>(Kind::Token, Start, End);
282+
auto Op = std::make_unique<M68kOperand>(KindTy::Token, Start, End);
283283
Op->Token = Token;
284284
return Op;
285285
}
286286

287287
// Imm
288-
bool M68kOperand::isImm() const { return Kind == Kind::Imm; }
288+
bool M68kOperand::isImm() const { return Kind == KindTy::Imm; }
289289
void M68kOperand::addImmOperands(MCInst &Inst, unsigned N) const {
290290
assert(isImm() && "wrong oeprand kind");
291291
assert((N == 1) && "can only handle one register operand");
@@ -295,7 +295,7 @@ void M68kOperand::addImmOperands(MCInst &Inst, unsigned N) const {
295295

296296
std::unique_ptr<M68kOperand> M68kOperand::createImm(const MCExpr *Expr,
297297
SMLoc Start, SMLoc End) {
298-
auto Op = std::make_unique<M68kOperand>(Kind::Imm, Start, End);
298+
auto Op = std::make_unique<M68kOperand>(KindTy::Imm, Start, End);
299299
Op->Expr = Expr;
300300
return Op;
301301
}
@@ -842,19 +842,19 @@ bool M68kAsmParser::MatchAndEmitInstruction(SMLoc Loc, unsigned &Opcode,
842842

843843
void M68kOperand::print(raw_ostream &OS) const {
844844
switch (Kind) {
845-
case Kind::Invalid:
845+
case KindTy::Invalid:
846846
OS << "invalid";
847847
break;
848848

849-
case Kind::Token:
849+
case KindTy::Token:
850850
OS << "token '" << Token << "'";
851851
break;
852852

853-
case Kind::Imm:
853+
case KindTy::Imm:
854854
OS << "immediate " << Imm;
855855
break;
856856

857-
case Kind::MemOp:
857+
case KindTy::MemOp:
858858
MemOp.print(OS);
859859
break;
860860
}

0 commit comments

Comments
 (0)