[Mlir-commits] [mlir] [mlir] Deprecate OpPrintingFlags(std::nullopt_t) (NFC) (PR #149546)

Kazu Hirata llvmlistbot at llvm.org
Fri Jul 18 09:15:16 PDT 2025


https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/149546

This patch deprecates OpPrintingFlags(std::nullopt_t) to avoid use of
std::nullopt outside the context of std::optional.


>From a1c7ba1788b8774f071a48835961e55adb34cd13 Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Thu, 17 Jul 2025 16:30:52 -0700
Subject: [PATCH] [mlir] Deprecate OpPrintingFlags(std::nullopt_t) (NFC)

This patch deprecates OpPrintingFlags(std::nullopt_t) to avoid use of
std::nullopt outside the context of std::optional.
---
 mlir/include/mlir/IR/OpDefinition.h     | 2 +-
 mlir/include/mlir/IR/Operation.h        | 2 +-
 mlir/include/mlir/IR/OperationSupport.h | 1 +
 3 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/mlir/include/mlir/IR/OpDefinition.h b/mlir/include/mlir/IR/OpDefinition.h
index 75c3aea0792ac..883ece32967e4 100644
--- a/mlir/include/mlir/IR/OpDefinition.h
+++ b/mlir/include/mlir/IR/OpDefinition.h
@@ -115,7 +115,7 @@ class OpState {
   MLIRContext *getContext() { return getOperation()->getContext(); }
 
   /// Print the operation to the given stream.
-  void print(raw_ostream &os, OpPrintingFlags flags = std::nullopt) {
+  void print(raw_ostream &os, OpPrintingFlags flags = {}) {
     state->print(os, flags);
   }
   void print(raw_ostream &os, AsmState &asmState) {
diff --git a/mlir/include/mlir/IR/Operation.h b/mlir/include/mlir/IR/Operation.h
index 1c2c04e718bf7..fa8a4873572ce 100644
--- a/mlir/include/mlir/IR/Operation.h
+++ b/mlir/include/mlir/IR/Operation.h
@@ -318,7 +318,7 @@ class alignas(8) Operation final
   /// take O(N) where N is the number of operations within the parent block.
   bool isBeforeInBlock(Operation *other);
 
-  void print(raw_ostream &os, const OpPrintingFlags &flags = std::nullopt);
+  void print(raw_ostream &os, const OpPrintingFlags &flags = {});
   void print(raw_ostream &os, AsmState &state);
   void dump();
 
diff --git a/mlir/include/mlir/IR/OperationSupport.h b/mlir/include/mlir/IR/OperationSupport.h
index 65e6d4f64e36c..5741cce509ced 100644
--- a/mlir/include/mlir/IR/OperationSupport.h
+++ b/mlir/include/mlir/IR/OperationSupport.h
@@ -1175,6 +1175,7 @@ class alignas(8) OperandStorage {
 class OpPrintingFlags {
 public:
   OpPrintingFlags();
+  LLVM_DEPRECATED("Use OpPrintingFlags() instead", "OpPrintingFlags()")
   OpPrintingFlags(std::nullopt_t) : OpPrintingFlags() {}
 
   /// Enables the elision of large elements attributes by printing a lexically



More information about the Mlir-commits mailing list