[llvm] 1e56686 - MCSectionGOFF: Remove classof

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Sat Jul 26 09:42:41 PDT 2025


Author: Fangrui Song
Date: 2025-07-26T09:42:37-07:00
New Revision: 1e56686f6de2ac76fb47047953915adc11e6491d

URL: https://github.com/llvm/llvm-project/commit/1e56686f6de2ac76fb47047953915adc11e6491d
DIFF: https://github.com/llvm/llvm-project/commit/1e56686f6de2ac76fb47047953915adc11e6491d.diff

LOG: MCSectionGOFF: 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.

Added: 
    

Modified: 
    llvm/include/llvm/MC/MCSectionGOFF.h
    llvm/lib/MC/GOFFObjectWriter.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/MC/MCSectionGOFF.h b/llvm/include/llvm/MC/MCSectionGOFF.h
index b166397b5d370..aa8136871ead3 100644
--- a/llvm/include/llvm/MC/MCSectionGOFF.h
+++ b/llvm/include/llvm/MC/MCSectionGOFF.h
@@ -123,8 +123,6 @@ class LLVM_ABI MCSectionGOFF final : public MCSection {
   bool requiresNonZeroLength() const { return RequiresNonZeroLength; }
 
   void setName(StringRef SectionName) { Name = SectionName; }
-
-  static bool classof(const MCSection *S) { return S->getVariant() == SV_GOFF; }
 };
 } // end namespace llvm
 

diff  --git a/llvm/lib/MC/GOFFObjectWriter.cpp b/llvm/lib/MC/GOFFObjectWriter.cpp
index 1871f5fe507e2..88188f34e96fc 100644
--- a/llvm/lib/MC/GOFFObjectWriter.cpp
+++ b/llvm/lib/MC/GOFFObjectWriter.cpp
@@ -336,7 +336,7 @@ void GOFFWriter::defineSymbols() {
   unsigned Ordinal = 0;
   // Process all sections.
   for (MCSection &S : Asm) {
-    auto &Section = cast<MCSectionGOFF>(S);
+    auto &Section = static_cast<MCSectionGOFF &>(S);
     Section.setOrdinal(++Ordinal);
     defineSectionSymbols(Section);
   }


        


More information about the llvm-commits mailing list