Skip to content

Commit 570e090

Browse files
committed
MCSymbolWasm: Remove classof
The object file format specific derived classes are used in context where the type is statically known. We don't use isa/dyn_cast and we want to eliminate MCSymbol::Kind in the base class.
1 parent 45a061b commit 570e090

14 files changed

+75
-71
lines changed

llvm/include/llvm/MC/MCSymbolWasm.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ class MCSymbolWasm : public MCSymbol {
3636
public:
3737
MCSymbolWasm(const MCSymbolTableEntry *Name, bool isTemporary)
3838
: MCSymbol(SymbolKindWasm, Name, isTemporary) {}
39-
static bool classof(const MCSymbol *S) { return S->isWasm(); }
4039

4140
const MCExpr *getSize() const { return SymbolSize; }
4241
void setSize(const MCExpr *SS) { SymbolSize = SS; }

llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -508,7 +508,8 @@ void DwarfCompileUnit::addWasmRelocBaseGlobal(DIELoc *Loc, StringRef GlobalName,
508508
// don't want to depend on target specific headers in this code?
509509
const unsigned TI_GLOBAL_RELOC = 3;
510510
unsigned PointerSize = Asm->getDataLayout().getPointerSize();
511-
auto *Sym = cast<MCSymbolWasm>(Asm->GetExternalSymbolSymbol(GlobalName));
511+
auto *Sym =
512+
static_cast<MCSymbolWasm *>(Asm->GetExternalSymbolSymbol(GlobalName));
512513
// FIXME: this repeats what WebAssemblyMCInstLower::
513514
// GetExternalSymbolSymbol does, since if there's no code that
514515
// refers to this symbol, we have to set it here.

llvm/lib/MC/MCContext.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -817,7 +817,7 @@ MCSectionWasm *MCContext::getWasmSection(const Twine &Section, SectionKind K,
817817
unsigned UniqueID) {
818818
MCSymbolWasm *GroupSym = nullptr;
819819
if (!Group.isTriviallyEmpty() && !Group.str().empty()) {
820-
GroupSym = cast<MCSymbolWasm>(getOrCreateSymbol(Group));
820+
GroupSym = static_cast<MCSymbolWasm *>(getOrCreateSymbol(Group));
821821
GroupSym->setComdat(true);
822822
if (K.isMetadata() && !GroupSym->getType().has_value()) {
823823
// Comdat group symbol associated with a custom section is a section
@@ -848,7 +848,7 @@ MCSectionWasm *MCContext::getWasmSection(const Twine &Section, SectionKind Kind,
848848
MCSymbol *Begin = createRenamableSymbol(CachedName, true, false);
849849
// Begin always has a different name than CachedName... see #48596.
850850
getSymbolTableEntry(Begin->getName()).second.Symbol = Begin;
851-
cast<MCSymbolWasm>(Begin)->setType(wasm::WASM_SYMBOL_TYPE_SECTION);
851+
static_cast<MCSymbolWasm *>(Begin)->setType(wasm::WASM_SYMBOL_TYPE_SECTION);
852852

853853
MCSectionWasm *Result = new (WasmAllocator.Allocate())
854854
MCSectionWasm(CachedName, Kind, Flags, GroupSym, UniqueID, Begin);

llvm/lib/MC/MCParser/WasmAsmParser.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ class WasmAsmParser : public MCAsmParserExtension {
224224
return true;
225225
if (expect(AsmToken::EndOfStatement, "eol"))
226226
return true;
227-
auto WasmSym = cast<MCSymbolWasm>(Sym);
227+
auto WasmSym = static_cast<const MCSymbolWasm *>(Sym);
228228
if (WasmSym->isFunction()) {
229229
// Ignore .size directives for function symbols. They get their size
230230
// set automatically based on their content.
@@ -241,9 +241,9 @@ class WasmAsmParser : public MCAsmParserExtension {
241241
if (!Lexer->is(AsmToken::Identifier))
242242
return error("Expected label after .type directive, got: ",
243243
Lexer->getTok());
244-
auto WasmSym = cast<MCSymbolWasm>(
245-
getStreamer().getContext().getOrCreateSymbol(
246-
Lexer->getTok().getString()));
244+
auto *WasmSym = static_cast<MCSymbolWasm *>(
245+
getStreamer().getContext().getOrCreateSymbol(
246+
Lexer->getTok().getString()));
247247
Lex();
248248
if (!(isNext(AsmToken::Comma) && isNext(AsmToken::At) &&
249249
Lexer->is(AsmToken::Identifier)))

llvm/lib/MC/MCWasmStreamer.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ using namespace llvm;
3636
MCWasmStreamer::~MCWasmStreamer() = default; // anchor.
3737

3838
void MCWasmStreamer::emitLabel(MCSymbol *S, SMLoc Loc) {
39-
auto *Symbol = cast<MCSymbolWasm>(S);
39+
auto *Symbol = static_cast<MCSymbolWasm *>(S);
4040
MCObjectStreamer::emitLabel(Symbol, Loc);
4141

4242
const MCSectionWasm &Section =
@@ -47,7 +47,7 @@ void MCWasmStreamer::emitLabel(MCSymbol *S, SMLoc Loc) {
4747

4848
void MCWasmStreamer::emitLabelAtPos(MCSymbol *S, SMLoc Loc, MCFragment &F,
4949
uint64_t Offset) {
50-
auto *Symbol = cast<MCSymbolWasm>(S);
50+
auto *Symbol = static_cast<MCSymbolWasm *>(S);
5151
MCObjectStreamer::emitLabelAtPos(Symbol, Loc, F, Offset);
5252

5353
const MCSectionWasm &Section =
@@ -69,8 +69,7 @@ void MCWasmStreamer::changeSection(MCSection *Section, uint32_t Subsection) {
6969

7070
bool MCWasmStreamer::emitSymbolAttribute(MCSymbol *S, MCSymbolAttr Attribute) {
7171
assert(Attribute != MCSA_IndirectSymbol && "indirect symbols not supported");
72-
73-
auto *Symbol = cast<MCSymbolWasm>(S);
72+
auto *Symbol = static_cast<MCSymbolWasm *>(S);
7473

7574
// Adding a symbol attribute always introduces the symbol; note that an
7675
// important side effect of calling registerSymbol here is to register the
@@ -135,7 +134,7 @@ void MCWasmStreamer::emitCommonSymbol(MCSymbol *S, uint64_t Size,
135134
}
136135

137136
void MCWasmStreamer::emitELFSize(MCSymbol *Symbol, const MCExpr *Value) {
138-
cast<MCSymbolWasm>(Symbol)->setSize(Value);
137+
static_cast<MCSymbolWasm *>(Symbol)->setSize(Value);
139138
}
140139

141140
void MCWasmStreamer::emitLocalCommonSymbol(MCSymbol *S, uint64_t Size,

llvm/lib/MC/WasmObjectWriter.cpp

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -487,7 +487,7 @@ void WasmObjectWriter::recordRelocation(const MCFragment &F,
487487
bool IsLocRel = false;
488488

489489
if (const auto *RefB = Target.getSubSym()) {
490-
const auto &SymB = cast<MCSymbolWasm>(*RefB);
490+
auto &SymB = static_cast<const MCSymbolWasm &>(*RefB);
491491

492492
if (FixupSection.isText()) {
493493
Ctx.reportError(Fixup.getLoc(),
@@ -515,7 +515,7 @@ void WasmObjectWriter::recordRelocation(const MCFragment &F,
515515
}
516516

517517
// We either rejected the fixup or folded B into C at this point.
518-
const auto *SymA = cast<MCSymbolWasm>(Target.getAddSym());
518+
auto *SymA = static_cast<const MCSymbolWasm *>(Target.getAddSym());
519519

520520
// The .init_array isn't translated as data, so don't do relocations in it.
521521
if (FixupSection.getName().starts_with(".init_array")) {
@@ -561,7 +561,7 @@ void WasmObjectWriter::recordRelocation(const MCFragment &F,
561561
report_fatal_error("section symbol is required for relocation");
562562

563563
C += Asm->getSymbolOffset(*SymA);
564-
SymA = cast<MCSymbolWasm>(SectionSymbol);
564+
SymA = static_cast<const MCSymbolWasm *>(SectionSymbol);
565565
}
566566

567567
if (Type == wasm::R_WASM_TABLE_INDEX_REL_SLEB ||
@@ -573,7 +573,7 @@ void WasmObjectWriter::recordRelocation(const MCFragment &F,
573573
// TABLE_INDEX relocs implicitly use the default indirect function table.
574574
// We require the function table to have already been defined.
575575
auto TableName = "__indirect_function_table";
576-
MCSymbolWasm *Sym = cast_or_null<MCSymbolWasm>(Ctx.lookupSymbol(TableName));
576+
auto *Sym = static_cast<MCSymbolWasm *>(Ctx.lookupSymbol(TableName));
577577
if (!Sym) {
578578
report_fatal_error("missing indirect function table symbol");
579579
} else {
@@ -631,8 +631,8 @@ WasmObjectWriter::getProvisionalValue(const MCAssembler &Asm,
631631
case wasm::R_WASM_TABLE_INDEX_I32:
632632
case wasm::R_WASM_TABLE_INDEX_I64: {
633633
// Provisional value is table address of the resolved symbol itself
634-
const MCSymbolWasm *Base =
635-
cast<MCSymbolWasm>(Asm.getBaseSymbol(*RelEntry.Symbol));
634+
auto *Base =
635+
static_cast<const MCSymbolWasm *>(Asm.getBaseSymbol(*RelEntry.Symbol));
636636
assert(Base->isFunction());
637637
if (RelEntry.Type == wasm::R_WASM_TABLE_INDEX_REL_SLEB ||
638638
RelEntry.Type == wasm::R_WASM_TABLE_INDEX_REL_SLEB64)
@@ -1342,11 +1342,11 @@ void WasmObjectWriter::prepareImports(
13421342
// Register types for all functions, including those with private linkage
13431343
// (because wasm always needs a type signature).
13441344
if (WS.isFunction()) {
1345-
const auto *BS = Asm.getBaseSymbol(S);
1345+
auto *BS = static_cast<const MCSymbolWasm *>(Asm.getBaseSymbol(S));
13461346
if (!BS)
13471347
report_fatal_error(Twine(S.getName()) +
13481348
": absolute addressing not supported!");
1349-
registerFunctionType(*cast<MCSymbolWasm>(BS));
1349+
registerFunctionType(*BS);
13501350
}
13511351

13521352
if (WS.isTag())
@@ -1516,10 +1516,10 @@ uint64_t WasmObjectWriter::writeOneObject(MCAssembler &Asm,
15161516
// For user-defined custom sections, strip the prefix
15171517
Name.consume_front(".custom_section.");
15181518

1519-
MCSymbol *Begin = Sec.getBeginSymbol();
1519+
auto *Begin = static_cast<MCSymbolWasm *>(Sec.getBeginSymbol());
15201520
if (Begin) {
1521-
assert(WasmIndices.count(cast<MCSymbolWasm>(Begin)) == 0);
1522-
WasmIndices[cast<MCSymbolWasm>(Begin)] = CustomSections.size();
1521+
assert(WasmIndices.count(Begin) == 0);
1522+
WasmIndices[Begin] = CustomSections.size();
15231523
}
15241524

15251525
// Separate out the producers and target features sections
@@ -1719,7 +1719,7 @@ uint64_t WasmObjectWriter::writeOneObject(MCAssembler &Asm,
17191719
if (!BS)
17201720
report_fatal_error(Twine(S.getName()) +
17211721
": absolute addressing not supported!");
1722-
const MCSymbolWasm *Base = cast<MCSymbolWasm>(BS);
1722+
const MCSymbolWasm *Base = static_cast<const MCSymbolWasm *>(BS);
17231723

17241724
// Find the target symbol of this weak alias and export that index
17251725
const auto &WS = static_cast<const MCSymbolWasm &>(S);
@@ -1829,8 +1829,8 @@ uint64_t WasmObjectWriter::writeOneObject(MCAssembler &Asm,
18291829
Rel.Type != wasm::R_WASM_TABLE_INDEX_REL_SLEB64)
18301830
return;
18311831
assert(Rel.Symbol->isFunction());
1832-
const MCSymbolWasm *Base =
1833-
cast<MCSymbolWasm>(Asm.getBaseSymbol(*Rel.Symbol));
1832+
auto *Base =
1833+
static_cast<const MCSymbolWasm *>(Asm.getBaseSymbol(*Rel.Symbol));
18341834
uint32_t FunctionIndex = WasmIndices.find(Base)->second;
18351835
uint32_t TableIndex = TableElems.size() + InitialTableOffset;
18361836
if (TableIndices.try_emplace(Base, TableIndex).second) {
@@ -1880,7 +1880,8 @@ uint64_t WasmObjectWriter::writeOneObject(MCAssembler &Asm,
18801880
if (!SymRef)
18811881
report_fatal_error(
18821882
"fixups in .init_array should be symbol references");
1883-
const auto &TargetSym = cast<const MCSymbolWasm>(SymRef->getSymbol());
1883+
auto &TargetSym =
1884+
static_cast<const MCSymbolWasm &>(SymRef->getSymbol());
18841885
if (TargetSym.getIndex() == InvalidIndex)
18851886
report_fatal_error("symbols in .init_array should exist in symtab");
18861887
if (!TargetSym.isFunction())
@@ -1905,7 +1906,7 @@ uint64_t WasmObjectWriter::writeOneObject(MCAssembler &Asm,
19051906
writeExportSection(Exports);
19061907
const MCSymbol *IndirectFunctionTable =
19071908
getContext().lookupSymbol("__indirect_function_table");
1908-
writeElemSection(cast_or_null<const MCSymbolWasm>(IndirectFunctionTable),
1909+
writeElemSection(static_cast<const MCSymbolWasm *>(IndirectFunctionTable),
19091910
TableElems);
19101911
writeDataCountSection();
19111912

llvm/lib/Target/WebAssembly/AsmParser/WebAssemblyAsmParser.cpp

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -212,12 +212,12 @@ static wasm::WasmLimits defaultLimits() {
212212
static MCSymbolWasm *getOrCreateFunctionTableSymbol(MCContext &Ctx,
213213
const StringRef &Name,
214214
bool Is64) {
215-
MCSymbolWasm *Sym = cast_or_null<MCSymbolWasm>(Ctx.lookupSymbol(Name));
215+
auto *Sym = static_cast<MCSymbolWasm *>(Ctx.lookupSymbol(Name));
216216
if (Sym) {
217217
if (!Sym->isFunctionTable())
218218
Ctx.reportError(SMLoc(), "symbol is not a wasm funcref table");
219219
} else {
220-
Sym = cast<MCSymbolWasm>(Ctx.getOrCreateSymbol(Name));
220+
Sym = static_cast<MCSymbolWasm *>(Ctx.getOrCreateSymbol(Name));
221221
Sym->setFunctionTable(Is64);
222222
// The default function table is synthesized by the linker.
223223
Sym->setUndefined();
@@ -703,7 +703,7 @@ class WebAssemblyAsmParser final : public MCTargetAsmParser {
703703
ExpectBlockType = false;
704704
// The "true" here will cause this to be a nameless symbol.
705705
MCSymbol *Sym = Ctx.createTempSymbol("typeindex", true);
706-
auto *WasmSym = cast<MCSymbolWasm>(Sym);
706+
auto *WasmSym = static_cast<MCSymbolWasm *>(Sym);
707707
WasmSym->setSignature(Signature);
708708
WasmSym->setType(wasm::WASM_SYMBOL_TYPE_FUNCTION);
709709
const MCExpr *Expr =
@@ -949,7 +949,8 @@ class WebAssemblyAsmParser final : public MCTargetAsmParser {
949949
return error("Unknown type in .globaltype modifier: ", TypeTok);
950950
}
951951
// Now set this symbol with the correct type.
952-
auto *WasmSym = cast<MCSymbolWasm>(Ctx.getOrCreateSymbol(SymName));
952+
auto *WasmSym =
953+
static_cast<MCSymbolWasm *>(Ctx.getOrCreateSymbol(SymName));
953954
WasmSym->setType(wasm::WASM_SYMBOL_TYPE_GLOBAL);
954955
WasmSym->setGlobalType(wasm::WasmGlobalType{uint8_t(*Type), Mutable});
955956
// And emit the directive again.
@@ -980,7 +981,8 @@ class WebAssemblyAsmParser final : public MCTargetAsmParser {
980981

981982
// Now that we have the name and table type, we can actually create the
982983
// symbol
983-
auto *WasmSym = cast<MCSymbolWasm>(Ctx.getOrCreateSymbol(SymName));
984+
auto *WasmSym =
985+
static_cast<MCSymbolWasm *>(Ctx.getOrCreateSymbol(SymName));
984986
WasmSym->setType(wasm::WASM_SYMBOL_TYPE_TABLE);
985987
if (Is64) {
986988
Limits.Flags |= wasm::WASM_LIMITS_FLAG_IS_64;
@@ -1000,7 +1002,8 @@ class WebAssemblyAsmParser final : public MCTargetAsmParser {
10001002
auto SymName = expectIdent();
10011003
if (SymName.empty())
10021004
return ParseStatus::Failure;
1003-
auto *WasmSym = cast<MCSymbolWasm>(Ctx.getOrCreateSymbol(SymName));
1005+
auto *WasmSym =
1006+
static_cast<MCSymbolWasm *>(Ctx.getOrCreateSymbol(SymName));
10041007
if (WasmSym->isDefined()) {
10051008
// We push 'Function' either when a label is parsed or a .functype
10061009
// directive is parsed. The reason it is not easy to do this uniformly
@@ -1042,7 +1045,8 @@ class WebAssemblyAsmParser final : public MCTargetAsmParser {
10421045
auto ExportName = expectIdent();
10431046
if (ExportName.empty())
10441047
return ParseStatus::Failure;
1045-
auto *WasmSym = cast<MCSymbolWasm>(Ctx.getOrCreateSymbol(SymName));
1048+
auto *WasmSym =
1049+
static_cast<MCSymbolWasm *>(Ctx.getOrCreateSymbol(SymName));
10461050
WasmSym->setExportName(Ctx.allocateString(ExportName));
10471051
TOut.emitExportName(WasmSym, ExportName);
10481052
return expect(AsmToken::EndOfStatement, "EOL");
@@ -1057,7 +1061,8 @@ class WebAssemblyAsmParser final : public MCTargetAsmParser {
10571061
auto ImportModule = expectIdent();
10581062
if (ImportModule.empty())
10591063
return ParseStatus::Failure;
1060-
auto *WasmSym = cast<MCSymbolWasm>(Ctx.getOrCreateSymbol(SymName));
1064+
auto *WasmSym =
1065+
static_cast<MCSymbolWasm *>(Ctx.getOrCreateSymbol(SymName));
10611066
WasmSym->setImportModule(Ctx.allocateString(ImportModule));
10621067
TOut.emitImportModule(WasmSym, ImportModule);
10631068
return expect(AsmToken::EndOfStatement, "EOL");
@@ -1072,7 +1077,8 @@ class WebAssemblyAsmParser final : public MCTargetAsmParser {
10721077
auto ImportName = expectIdent();
10731078
if (ImportName.empty())
10741079
return ParseStatus::Failure;
1075-
auto *WasmSym = cast<MCSymbolWasm>(Ctx.getOrCreateSymbol(SymName));
1080+
auto *WasmSym =
1081+
static_cast<MCSymbolWasm *>(Ctx.getOrCreateSymbol(SymName));
10761082
WasmSym->setImportName(Ctx.allocateString(ImportName));
10771083
TOut.emitImportName(WasmSym, ImportName);
10781084
return expect(AsmToken::EndOfStatement, "EOL");
@@ -1082,7 +1088,8 @@ class WebAssemblyAsmParser final : public MCTargetAsmParser {
10821088
auto SymName = expectIdent();
10831089
if (SymName.empty())
10841090
return ParseStatus::Failure;
1085-
auto *WasmSym = cast<MCSymbolWasm>(Ctx.getOrCreateSymbol(SymName));
1091+
auto *WasmSym =
1092+
static_cast<MCSymbolWasm *>(Ctx.getOrCreateSymbol(SymName));
10861093
auto *Signature = Ctx.createWasmSignature();
10871094
if (parseRegTypeList(Signature->Params))
10881095
return ParseStatus::Failure;
@@ -1224,7 +1231,7 @@ class WebAssemblyAsmParser final : public MCTargetAsmParser {
12241231
if (!CWS->isText())
12251232
return;
12261233

1227-
auto *WasmSym = cast<MCSymbolWasm>(Symbol);
1234+
auto *WasmSym = static_cast<MCSymbolWasm *>(Symbol);
12281235
// Unlike other targets, we don't allow data in text sections (labels
12291236
// declared with .type @object).
12301237
if (WasmSym->getType() == wasm::WASM_SYMBOL_TYPE_DATA) {

llvm/lib/Target/WebAssembly/AsmParser/WebAssemblyAsmTypeCheck.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ bool WebAssemblyAsmTypeCheck::getGlobal(SMLoc ErrorLoc,
258258
const MCSymbolRefExpr *SymRef;
259259
if (getSymRef(ErrorLoc, GlobalOp, SymRef))
260260
return true;
261-
const auto *WasmSym = cast<MCSymbolWasm>(&SymRef->getSymbol());
261+
auto *WasmSym = static_cast<const MCSymbolWasm *>(&SymRef->getSymbol());
262262
switch (WasmSym->getType().value_or(wasm::WASM_SYMBOL_TYPE_DATA)) {
263263
case wasm::WASM_SYMBOL_TYPE_GLOBAL:
264264
Type = static_cast<wasm::ValType>(WasmSym->getGlobalType().Type);
@@ -286,7 +286,7 @@ bool WebAssemblyAsmTypeCheck::getTable(SMLoc ErrorLoc, const MCOperand &TableOp,
286286
const MCSymbolRefExpr *SymRef;
287287
if (getSymRef(ErrorLoc, TableOp, SymRef))
288288
return true;
289-
const auto *WasmSym = cast<MCSymbolWasm>(&SymRef->getSymbol());
289+
auto *WasmSym = static_cast<const MCSymbolWasm *>(&SymRef->getSymbol());
290290
if (WasmSym->getType().value_or(wasm::WASM_SYMBOL_TYPE_DATA) !=
291291
wasm::WASM_SYMBOL_TYPE_TABLE)
292292
return typeError(ErrorLoc, StringRef("symbol ") + WasmSym->getName() +
@@ -302,7 +302,7 @@ bool WebAssemblyAsmTypeCheck::getSignature(SMLoc ErrorLoc,
302302
const MCSymbolRefExpr *SymRef = nullptr;
303303
if (getSymRef(ErrorLoc, SigOp, SymRef))
304304
return true;
305-
const auto *WasmSym = cast<MCSymbolWasm>(&SymRef->getSymbol());
305+
auto *WasmSym = static_cast<const MCSymbolWasm *>(&SymRef->getSymbol());
306306
Sig = WasmSym->getSignature();
307307

308308
if (!Sig || WasmSym->getType() != Type) {

llvm/lib/Target/WebAssembly/Disassembler/WebAssemblyDisassembler.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ MCDisassembler::DecodeStatus WebAssemblyDisassembler::getInstruction(
237237
} else {
238238
// We don't have access to the signature, so create a symbol without one
239239
MCSymbol *Sym = getContext().createTempSymbol("typeindex", true);
240-
auto *WasmSym = cast<MCSymbolWasm>(Sym);
240+
auto *WasmSym = static_cast<MCSymbolWasm *>(Sym);
241241
WasmSym->setType(wasm::WASM_SYMBOL_TYPE_FUNCTION);
242242
const MCExpr *Expr = MCSymbolRefExpr::create(
243243
WasmSym, WebAssembly::S_TYPEINDEX, getContext());

llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyInstPrinter.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ void WebAssemblyInstPrinter::printWebAssemblySignatureOperand(const MCInst *MI,
380380
O << WebAssembly::anyTypeToString(Imm);
381381
} else {
382382
auto Expr = cast<MCSymbolRefExpr>(Op.getExpr());
383-
auto *Sym = cast<MCSymbolWasm>(&Expr->getSymbol());
383+
auto *Sym = static_cast<const MCSymbolWasm *>(&Expr->getSymbol());
384384
if (Sym->getSignature()) {
385385
O << WebAssembly::signatureToString(Sym->getSignature());
386386
} else {
@@ -398,10 +398,10 @@ void WebAssemblyInstPrinter::printCatchList(const MCInst *MI, unsigned OpNo,
398398

399399
auto PrintTagOp = [&](const MCOperand &Op) {
400400
const MCSymbolRefExpr *TagExpr = nullptr;
401-
const MCSymbolWasm *TagSym = nullptr;
401+
const MCSymbol *TagSym = nullptr;
402402
if (Op.isExpr()) {
403403
TagExpr = cast<MCSymbolRefExpr>(Op.getExpr());
404-
TagSym = cast<MCSymbolWasm>(&TagExpr->getSymbol());
404+
TagSym = &TagExpr->getSymbol();
405405
O << TagSym->getName() << " ";
406406
} else {
407407
// When instructions are parsed from the disassembler, we have an

0 commit comments

Comments
 (0)