[llvm] a365abd - MCExpr: Remove error-prone operator<<

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Sat Jun 28 14:50:33 PDT 2025


Author: Fangrui Song
Date: 2025-06-28T14:50:28-07:00
New Revision: a365abd544fd28d93759b03980b01fd33244fbdd

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

LOG: MCExpr: Remove error-prone operator<<

Printing an expression is error-prone without a MCAsmInfo argument.
The callers have migrated to MCAsmInfo::printExpr or MCExpr::print.

Added: 
    

Modified: 
    llvm/include/llvm/MC/MCExpr.h
    llvm/lib/Target/CSKY/AsmParser/CSKYAsmParser.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/MC/MCExpr.h b/llvm/include/llvm/MC/MCExpr.h
index 29365cdaaa06e..e7f97c627f64e 100644
--- a/llvm/include/llvm/MC/MCExpr.h
+++ b/llvm/include/llvm/MC/MCExpr.h
@@ -134,11 +134,6 @@ class MCExpr {
                                            MCValue &);
 };
 
-inline raw_ostream &operator<<(raw_ostream &OS, const MCExpr &E) {
-  E.print(OS, nullptr);
-  return OS;
-}
-
 ////  Represent a constant integer expression.
 class MCConstantExpr : public MCExpr {
   int64_t Value;

diff  --git a/llvm/lib/Target/CSKY/AsmParser/CSKYAsmParser.cpp b/llvm/lib/Target/CSKY/AsmParser/CSKYAsmParser.cpp
index c74011b164758..727f83d43c8a0 100644
--- a/llvm/lib/Target/CSKY/AsmParser/CSKYAsmParser.cpp
+++ b/llvm/lib/Target/CSKY/AsmParser/CSKYAsmParser.cpp
@@ -441,10 +441,10 @@ struct CSKYOperand : public MCParsedAsmOperand {
 
     switch (Kind) {
     case CPOP:
-      OS << *getConstpoolOp();
+      MAI.printExpr(OS, *getConstpoolOp());
       break;
     case Immediate:
-      OS << *getImm();
+      MAI.printExpr(OS, *getImm());
       break;
     case KindTy::Register:
       OS << "<register " << RegName(getReg()) << ">";


        


More information about the llvm-commits mailing list