[llvm] 7efb70f - MCSymbolELF: Remove classof

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Sun Aug 3 16:31:24 PDT 2025


Author: Fangrui Song
Date: 2025-08-03T16:31:19-07:00
New Revision: 7efb70ff6f4d061652970fdbef208cfbcaf02198

URL: https://github.com/llvm/llvm-project/commit/7efb70ff6f4d061652970fdbef208cfbcaf02198
DIFF: https://github.com/llvm/llvm-project/commit/7efb70ff6f4d061652970fdbef208cfbcaf02198.diff

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

Added: 
    

Modified: 
    llvm/include/llvm/MC/MCSymbol.h
    llvm/include/llvm/MC/MCSymbolELF.h
    llvm/lib/Target/Mips/MipsAsmPrinter.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/MC/MCSymbol.h b/llvm/include/llvm/MC/MCSymbol.h
index dc191f881921a..ccd37c3ede2d9 100644
--- a/llvm/include/llvm/MC/MCSymbol.h
+++ b/llvm/include/llvm/MC/MCSymbol.h
@@ -281,8 +281,6 @@ class MCSymbol {
   /// Mark the symbol as undefined.
   void setUndefined() { Fragment = nullptr; }
 
-  bool isELF() const { return Kind == SymbolKindELF; }
-
   bool isCOFF() const { return Kind == SymbolKindCOFF; }
 
   bool isGOFF() const { return Kind == SymbolKindGOFF; }

diff  --git a/llvm/include/llvm/MC/MCSymbolELF.h b/llvm/include/llvm/MC/MCSymbolELF.h
index 7c271e777012f..80b37eaf6b6ad 100644
--- a/llvm/include/llvm/MC/MCSymbolELF.h
+++ b/llvm/include/llvm/MC/MCSymbolELF.h
@@ -48,8 +48,6 @@ class MCSymbolELF : public MCSymbol {
   void setMemtag(bool Tagged);
   bool isMemtag() const;
 
-  static bool classof(const MCSymbol *S) { return S->isELF(); }
-
 private:
   void setIsBindingSet() const;
 };

diff  --git a/llvm/lib/Target/Mips/MipsAsmPrinter.cpp b/llvm/lib/Target/Mips/MipsAsmPrinter.cpp
index a2e48abcdd6ae..4530fc60e5e21 100644
--- a/llvm/lib/Target/Mips/MipsAsmPrinter.cpp
+++ b/llvm/lib/Target/Mips/MipsAsmPrinter.cpp
@@ -1052,8 +1052,7 @@ void MipsAsmPrinter::EmitFPCallStub(
   //  __call_stub_fp_xxxx:
   //
   std::string x = "__call_stub_fp_" + std::string(Symbol);
-  MCSymbolELF *Stub =
-      cast<MCSymbolELF>(OutContext.getOrCreateSymbol(StringRef(x)));
+  MCSymbol *Stub = OutContext.getOrCreateSymbol(StringRef(x));
   TS.emitDirectiveEnt(*Stub);
   MCSymbol *MType =
       OutContext.getOrCreateSymbol("__call_stub_fp_" + Twine(Symbol));


        


More information about the llvm-commits mailing list