[llvm] 5fe40b9 - MCExpr: Make print private

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Sun Jun 29 10:38:38 PDT 2025


Author: Fangrui Song
Date: 2025-06-29T10:38:33-07:00
New Revision: 5fe40b9df3b95d49277b43ea1348d7ff61caeeac

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

LOG: MCExpr: Make print private

Printing an expression is error-prone without a MCAsmInfo argument.
Make print private.

Added: 
    

Modified: 
    llvm/include/llvm/MC/MCExpr.h

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/MC/MCExpr.h b/llvm/include/llvm/MC/MCExpr.h
index d73e415f73f44..b3585693afa02 100644
--- a/llvm/include/llvm/MC/MCExpr.h
+++ b/llvm/include/llvm/MC/MCExpr.h
@@ -33,6 +33,10 @@ class MCSymbolRefExpr;
 /// needed for parsing.
 class MCExpr {
 public:
+  // Allow MC classes to access the private `print` function.
+  friend class MCAsmInfo;
+  friend class MCFragment;
+  friend class MCOperand;
   enum ExprKind : uint8_t {
     Binary,    ///< Binary expressions.
     Constant,  ///< Constant expressions.
@@ -53,6 +57,8 @@ class MCExpr {
   unsigned SubclassData : NumSubclassDataBits;
   SMLoc Loc;
 
+  void print(raw_ostream &OS, const MCAsmInfo *MAI,
+             int SurroundingPrec = 0) const;
   bool evaluateAsAbsolute(int64_t &Res, const MCAssembler *Asm,
                           bool InSet) const;
 
@@ -83,9 +89,6 @@ class MCExpr {
   /// \name Utility Methods
   /// @{
 
-  // TODO: Make this private. Users should call MCAsmInfo::printExpr instead.
-  LLVM_ABI void print(raw_ostream &OS, const MCAsmInfo *MAI,
-                      int SurroundingPrec = 0) const;
   LLVM_ABI void dump() const;
 
   /// @}


        


More information about the llvm-commits mailing list