Skip to content

Commit c2faf6a

Browse files
committed
MCSectionWasm: Remove classof
The object file format specific derived classes are used in context like MCStreamer and MCObjectTargetWriter where the type is statically known. We don't use isa/dyn_cast and we want to eliminate MCSection::SectionVariant in the base class.
1 parent fa3ec0c commit c2faf6a

File tree

5 files changed

+7
-6
lines changed

5 files changed

+7
-6
lines changed

llvm/include/llvm/MC/MCSectionWasm.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,6 @@ class MCSectionWasm final : public MCSection {
8989
assert(isWasmData());
9090
IsPassive = V;
9191
}
92-
static bool classof(const MCSection *S) { return S->getVariant() == SV_Wasm; }
9392
};
9493

9594
} // end namespace llvm

llvm/lib/MC/MCParser/WasmAsmParser.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ class WasmAsmParser : public MCAsmParserExtension {
252252
if (TypeName == "function") {
253253
WasmSym->setType(wasm::WASM_SYMBOL_TYPE_FUNCTION);
254254
auto *Current =
255-
cast<MCSectionWasm>(getStreamer().getCurrentSectionOnly());
255+
static_cast<MCSectionWasm *>(getStreamer().getCurrentSectionOnly());
256256
if (Current->getGroup())
257257
WasmSym->setComdat(true);
258258
} else if (TypeName == "global")

llvm/lib/MC/MCWasmStreamer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ void MCWasmStreamer::emitLabelAtPos(MCSymbol *S, SMLoc Loc, MCFragment &F,
5858

5959
void MCWasmStreamer::changeSection(MCSection *Section, uint32_t Subsection) {
6060
MCAssembler &Asm = getAssembler();
61-
auto *SectionWasm = cast<MCSectionWasm>(Section);
61+
auto *SectionWasm = static_cast<const MCSectionWasm *>(Section);
6262
const MCSymbol *Grp = SectionWasm->getGroup();
6363
if (Grp)
6464
Asm.registerSymbol(*Grp);

llvm/lib/MC/WasmObjectWriter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -480,7 +480,7 @@ void WasmObjectWriter::recordRelocation(const MCFragment &F,
480480
// The WebAssembly backend should never generate FKF_IsPCRel fixups
481481
assert(!Fixup.isPCRel());
482482

483-
const auto &FixupSection = cast<MCSectionWasm>(*F.getParent());
483+
const auto &FixupSection = static_cast<MCSectionWasm &>(*F.getParent());
484484
uint64_t C = Target.getConstant();
485485
uint64_t FixupOffset = Asm->getFragmentOffset(F) + Fixup.getOffset();
486486
MCContext &Ctx = getContext();

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -900,7 +900,8 @@ class WebAssemblyAsmParser final : public MCTargetAsmParser {
900900

901901
bool checkDataSection() {
902902
if (CurrentState != DataSection) {
903-
auto *WS = cast<MCSectionWasm>(getStreamer().getCurrentSectionOnly());
903+
auto *WS = static_cast<const MCSectionWasm *>(
904+
getStreamer().getCurrentSectionOnly());
904905
if (WS && WS->isText())
905906
return error("data directive must occur in a data segment: ",
906907
Lexer.getTok());
@@ -1218,7 +1219,8 @@ class WebAssemblyAsmParser final : public MCTargetAsmParser {
12181219

12191220
void doBeforeLabelEmit(MCSymbol *Symbol, SMLoc IDLoc) override {
12201221
// Code below only applies to labels in text sections.
1221-
auto *CWS = cast<MCSectionWasm>(getStreamer().getCurrentSectionOnly());
1222+
auto *CWS = static_cast<const MCSectionWasm *>(
1223+
getStreamer().getCurrentSectionOnly());
12221224
if (!CWS->isText())
12231225
return;
12241226

0 commit comments

Comments
 (0)