-
Notifications
You must be signed in to change notification settings - Fork 15k
[mlir][examples] Use {} instead of std::nullopt (NFC) #146949
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
kazutakahirata
merged 2 commits into
llvm:main
from
kazutakahirata:cleanup_20250703_mlir_example_fix
Jul 3, 2025
Merged
[mlir][examples] Use {} instead of std::nullopt (NFC) #146949
kazutakahirata
merged 2 commits into
llvm:main
from
kazutakahirata:cleanup_20250703_mlir_example_fix
Jul 3, 2025
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]
|
@llvm/pr-subscribers-mlir Author: Kazu Hirata (kazutakahirata) ChangesThis patch fixes deprecation warnings like: mlir/include/mlir/IR/TypeRange.h:51:19: error: 'ArrayRef' is Full diff: https://github.com/llvm/llvm-project/pull/146949.diff 6 Files Affected:
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..96925bebf07b7 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, {});
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..82955a87e8249 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, {});
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..82955a87e8249 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, {});
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..82955a87e8249 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, {});
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..4e2a4d8a8c28d 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, {});
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({}));
} 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({}));
} else {
auto *structLit = llvm::cast<StructLiteralExprAST>(var.get());
auto attrTypePair = getConstantAttr(*structLit);
|
kuhar
reviewed
Jul 3, 2025
kuhar
approved these changes
Jul 3, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This patch fixes deprecation warnings like:
mlir/include/mlir/IR/TypeRange.h:51:19: error: 'ArrayRef' is
deprecated: Use {} or ArrayRef() instead
[-Werror,-Wdeprecated-declarations]