From ff4faaa660e1e9e844f8d6d15f55d810411d9642 Mon Sep 17 00:00:00 2001 From: Jakub Kuderski Date: Mon, 30 Jun 2025 18:14:33 -0400 Subject: [PATCH] [mlir][examples] Fix deprecation warnings for `ArrayRef(std::nullopt)` (#146420) This used to print: ``` llvm-project/mlir/include/mlir/IR/ValueRange.h:401:20: warning: 'ArrayRef' is deprecated: Use {} or ArrayRef() instead [-Wdeprecated-declarations] 401 | : ValueRange(ArrayRef(std::forward(arg))) {} | ^~~~~~~~ | {} build/tools/mlir/examples/toy/Ch7/include/toy/Ops.cpp.inc:2221:30: note: in instantiation of function template specialization 'mlir::ValueRange::ValueRange' requested here 2221 | build(odsBuilder, odsState, std::nullopt); | ^ llvm-project/llvm/include/llvm/ADT/ArrayRef.h:70:18: note: 'ArrayRef' has been explicitly marked deprecated here 70 | /*implicit*/ LLVM_DEPRECATED("Use {} or ArrayRef() instead", "{}") | ^ llvm-project/llvm/include/llvm/Support/Compiler.h:249:50: note: expanded from macro 'LLVM_DEPRECATED' 249 | #define LLVM_DEPRECATED(MSG, FIX) __attribute__((deprecated(MSG, FIX))) ``` --- mlir/examples/toy/Ch2/include/toy/Ops.td | 2 +- mlir/examples/toy/Ch3/include/toy/Ops.td | 2 +- mlir/examples/toy/Ch4/include/toy/Ops.td | 2 +- mlir/examples/toy/Ch5/include/toy/Ops.td | 2 +- mlir/examples/toy/Ch6/include/toy/Ops.td | 2 +- mlir/examples/toy/Ch7/include/toy/Ops.td | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/mlir/examples/toy/Ch2/include/toy/Ops.td b/mlir/examples/toy/Ch2/include/toy/Ops.td index 1a1b136af71f..ef65c9c8d682 100644 --- a/mlir/examples/toy/Ch2/include/toy/Ops.td +++ b/mlir/examples/toy/Ch2/include/toy/Ops.td @@ -297,7 +297,7 @@ def ReturnOp : Toy_Op<"return", [Pure, HasParent<"FuncOp">, // Allow building a ReturnOp with no return operand. let builders = [ - OpBuilder<(ins), [{ build($_builder, $_state, std::nullopt); }]> + OpBuilder<(ins), [{ build($_builder, $_state, {}); }]> ]; // Provide extra utility definitions on the c++ operation class definition. diff --git a/mlir/examples/toy/Ch3/include/toy/Ops.td b/mlir/examples/toy/Ch3/include/toy/Ops.td index 021802b5c4fc..485980420a20 100644 --- a/mlir/examples/toy/Ch3/include/toy/Ops.td +++ b/mlir/examples/toy/Ch3/include/toy/Ops.td @@ -298,7 +298,7 @@ def ReturnOp : Toy_Op<"return", [Pure, HasParent<"FuncOp">, // Allow building a ReturnOp with no return operand. let builders = [ - OpBuilder<(ins), [{ build($_builder, $_state, std::nullopt); }]> + OpBuilder<(ins), [{ build($_builder, $_state, {}); }]> ]; // Provide extra utility definitions on the c++ operation class definition. diff --git a/mlir/examples/toy/Ch4/include/toy/Ops.td b/mlir/examples/toy/Ch4/include/toy/Ops.td index 4441e48ca53c..0b32b1b0c772 100644 --- a/mlir/examples/toy/Ch4/include/toy/Ops.td +++ b/mlir/examples/toy/Ch4/include/toy/Ops.td @@ -335,7 +335,7 @@ def ReturnOp : Toy_Op<"return", [Pure, HasParent<"FuncOp">, // Allow building a ReturnOp with no return operand. let builders = [ - OpBuilder<(ins), [{ build($_builder, $_state, std::nullopt); }]> + OpBuilder<(ins), [{ build($_builder, $_state, {}); }]> ]; // Provide extra utility definitions on the c++ operation class definition. diff --git a/mlir/examples/toy/Ch5/include/toy/Ops.td b/mlir/examples/toy/Ch5/include/toy/Ops.td index 5b7c966de6f0..d11d18dc93cf 100644 --- a/mlir/examples/toy/Ch5/include/toy/Ops.td +++ b/mlir/examples/toy/Ch5/include/toy/Ops.td @@ -335,7 +335,7 @@ def ReturnOp : Toy_Op<"return", [Pure, HasParent<"FuncOp">, // Allow building a ReturnOp with no return operand. let builders = [ - OpBuilder<(ins), [{ build($_builder, $_state, std::nullopt); }]> + OpBuilder<(ins), [{ build($_builder, $_state, {}); }]> ]; // Provide extra utility definitions on the c++ operation class definition. diff --git a/mlir/examples/toy/Ch6/include/toy/Ops.td b/mlir/examples/toy/Ch6/include/toy/Ops.td index fdbc239a171d..63950f467455 100644 --- a/mlir/examples/toy/Ch6/include/toy/Ops.td +++ b/mlir/examples/toy/Ch6/include/toy/Ops.td @@ -335,7 +335,7 @@ def ReturnOp : Toy_Op<"return", [Pure, HasParent<"FuncOp">, // Allow building a ReturnOp with no return operand. let builders = [ - OpBuilder<(ins), [{ build($_builder, $_state, std::nullopt); }]> + OpBuilder<(ins), [{ build($_builder, $_state, {}); }]> ]; // Provide extra utility definitions on the c++ operation class definition. diff --git a/mlir/examples/toy/Ch7/include/toy/Ops.td b/mlir/examples/toy/Ch7/include/toy/Ops.td index 71ab7b0aeebb..bdf8ad0bc21a 100644 --- a/mlir/examples/toy/Ch7/include/toy/Ops.td +++ b/mlir/examples/toy/Ch7/include/toy/Ops.td @@ -360,7 +360,7 @@ def ReturnOp : Toy_Op<"return", [Pure, HasParent<"FuncOp">, // Allow building a ReturnOp with no return operand. let builders = [ - OpBuilder<(ins), [{ build($_builder, $_state, std::nullopt); }]> + OpBuilder<(ins), [{ build($_builder, $_state, {}); }]> ]; // Provide extra utility definitions on the c++ operation class definition.