[Mlir-commits] [mlir] 96f7f22 - [mlir][examples] Use {} instead of std::nullopt (NFC) (#146949)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Thu Jul 3 15:49:47 PDT 2025
Author: Kazu Hirata
Date: 2025-07-03T15:49:43-07:00
New Revision: 96f7f22825d06323a477344cff32d550c045bc42
URL: https://github.com/llvm/llvm-project/commit/96f7f22825d06323a477344cff32d550c045bc42
DIFF: https://github.com/llvm/llvm-project/commit/96f7f22825d06323a477344cff32d550c045bc42.diff
LOG: [mlir][examples] Use {} instead of std::nullopt (NFC) (#146949)
This patch fixes deprecation warnings like:
mlir/include/mlir/IR/TypeRange.h:51:19: error: 'ArrayRef' is
deprecated: Use {} or ArrayRef<T>() instead
[-Werror,-Wdeprecated-declarations]
Added:
Modified:
mlir/examples/toy/Ch2/mlir/MLIRGen.cpp
mlir/examples/toy/Ch3/mlir/MLIRGen.cpp
mlir/examples/toy/Ch4/mlir/MLIRGen.cpp
mlir/examples/toy/Ch5/mlir/MLIRGen.cpp
mlir/examples/toy/Ch6/mlir/MLIRGen.cpp
mlir/examples/toy/Ch7/mlir/MLIRGen.cpp
Removed:
################################################################################
diff --git a/mlir/examples/toy/Ch2/mlir/MLIRGen.cpp b/mlir/examples/toy/Ch2/mlir/MLIRGen.cpp
index bf4c099fe05d2..96925bebf07b7 100644
--- a/mlir/examples/toy/Ch2/mlir/MLIRGen.cpp
+++ b/mlir/examples/toy/Ch2/mlir/MLIRGen.cpp
@@ -120,7 +120,7 @@ class MLIRGenImpl {
// Arguments type are uniformly unranked tensors.
llvm::SmallVector<mlir::Type, 4> argTypes(proto.getArgs().size(),
getType(VarType{}));
- auto funcType = builder.getFunctionType(argTypes, std::nullopt);
+ auto funcType = builder.getFunctionType(argTypes, {});
return builder.create<mlir::toy::FuncOp>(location, proto.getName(),
funcType);
}
diff --git a/mlir/examples/toy/Ch3/mlir/MLIRGen.cpp b/mlir/examples/toy/Ch3/mlir/MLIRGen.cpp
index bf4c099fe05d2..c8cba82cb63a0 100644
--- a/mlir/examples/toy/Ch3/mlir/MLIRGen.cpp
+++ b/mlir/examples/toy/Ch3/mlir/MLIRGen.cpp
@@ -120,7 +120,7 @@ class MLIRGenImpl {
// Arguments type are uniformly unranked tensors.
llvm::SmallVector<mlir::Type, 4> argTypes(proto.getArgs().size(),
getType(VarType{}));
- auto funcType = builder.getFunctionType(argTypes, std::nullopt);
+ auto funcType = builder.getFunctionType(argTypes, /*results=*/{});
return builder.create<mlir::toy::FuncOp>(location, proto.getName(),
funcType);
}
diff --git a/mlir/examples/toy/Ch4/mlir/MLIRGen.cpp b/mlir/examples/toy/Ch4/mlir/MLIRGen.cpp
index b56e2f7c90086..9371815577b1b 100644
--- a/mlir/examples/toy/Ch4/mlir/MLIRGen.cpp
+++ b/mlir/examples/toy/Ch4/mlir/MLIRGen.cpp
@@ -120,7 +120,7 @@ class MLIRGenImpl {
// Arguments type are uniformly unranked tensors.
llvm::SmallVector<mlir::Type, 4> argTypes(proto.getArgs().size(),
getType(VarType{}));
- auto funcType = builder.getFunctionType(argTypes, std::nullopt);
+ auto funcType = builder.getFunctionType(argTypes, /*results=*/{});
return builder.create<mlir::toy::FuncOp>(location, proto.getName(),
funcType);
}
diff --git a/mlir/examples/toy/Ch5/mlir/MLIRGen.cpp b/mlir/examples/toy/Ch5/mlir/MLIRGen.cpp
index b56e2f7c90086..9371815577b1b 100644
--- a/mlir/examples/toy/Ch5/mlir/MLIRGen.cpp
+++ b/mlir/examples/toy/Ch5/mlir/MLIRGen.cpp
@@ -120,7 +120,7 @@ class MLIRGenImpl {
// Arguments type are uniformly unranked tensors.
llvm::SmallVector<mlir::Type, 4> argTypes(proto.getArgs().size(),
getType(VarType{}));
- auto funcType = builder.getFunctionType(argTypes, std::nullopt);
+ auto funcType = builder.getFunctionType(argTypes, /*results=*/{});
return builder.create<mlir::toy::FuncOp>(location, proto.getName(),
funcType);
}
diff --git a/mlir/examples/toy/Ch6/mlir/MLIRGen.cpp b/mlir/examples/toy/Ch6/mlir/MLIRGen.cpp
index b56e2f7c90086..9371815577b1b 100644
--- a/mlir/examples/toy/Ch6/mlir/MLIRGen.cpp
+++ b/mlir/examples/toy/Ch6/mlir/MLIRGen.cpp
@@ -120,7 +120,7 @@ class MLIRGenImpl {
// Arguments type are uniformly unranked tensors.
llvm::SmallVector<mlir::Type, 4> argTypes(proto.getArgs().size(),
getType(VarType{}));
- auto funcType = builder.getFunctionType(argTypes, std::nullopt);
+ auto funcType = builder.getFunctionType(argTypes, /*results=*/{});
return builder.create<mlir::toy::FuncOp>(location, proto.getName(),
funcType);
}
diff --git a/mlir/examples/toy/Ch7/mlir/MLIRGen.cpp b/mlir/examples/toy/Ch7/mlir/MLIRGen.cpp
index e554e375209f1..2490f17163b80 100644
--- a/mlir/examples/toy/Ch7/mlir/MLIRGen.cpp
+++ b/mlir/examples/toy/Ch7/mlir/MLIRGen.cpp
@@ -182,7 +182,7 @@ class MLIRGenImpl {
return nullptr;
argTypes.push_back(type);
}
- auto funcType = builder.getFunctionType(argTypes, std::nullopt);
+ auto funcType = builder.getFunctionType(argTypes, /*results=*/{});
return builder.create<mlir::toy::FuncOp>(location, proto.getName(),
funcType);
}
@@ -441,10 +441,10 @@ class MLIRGenImpl {
for (auto &var : lit.getValues()) {
if (auto *number = llvm::dyn_cast<NumberExprAST>(var.get())) {
attrElements.push_back(getConstantAttr(*number));
- typeElements.push_back(getType(std::nullopt));
+ typeElements.push_back(getType(/*shape=*/{}));
} else if (auto *lit = llvm::dyn_cast<LiteralExprAST>(var.get())) {
attrElements.push_back(getConstantAttr(*lit));
- typeElements.push_back(getType(std::nullopt));
+ typeElements.push_back(getType(/*shape=*/{}));
} else {
auto *structLit = llvm::cast<StructLiteralExprAST>(var.get());
auto attrTypePair = getConstantAttr(*structLit);
More information about the Mlir-commits
mailing list