Skip to content

Conversation

@kazutakahirata
Copy link
Contributor

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]

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]
@llvmbot
Copy link
Member

llvmbot commented Jul 3, 2025

@llvm/pr-subscribers-mlir

Author: Kazu Hirata (kazutakahirata)

Changes

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]


Full diff: https://github.com/llvm/llvm-project/pull/146949.diff

6 Files Affected:

  • (modified) mlir/examples/toy/Ch2/mlir/MLIRGen.cpp (+1-1)
  • (modified) mlir/examples/toy/Ch3/mlir/MLIRGen.cpp (+1-1)
  • (modified) mlir/examples/toy/Ch4/mlir/MLIRGen.cpp (+1-1)
  • (modified) mlir/examples/toy/Ch5/mlir/MLIRGen.cpp (+1-1)
  • (modified) mlir/examples/toy/Ch6/mlir/MLIRGen.cpp (+1-1)
  • (modified) mlir/examples/toy/Ch7/mlir/MLIRGen.cpp (+3-3)
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 kuhar changed the title [mlir] Use {} instead of std::nullopt (NFC) [mlir][examples] Use {} instead of std::nullopt (NFC) Jul 3, 2025
@kazutakahirata kazutakahirata merged commit 96f7f22 into llvm:main Jul 3, 2025
9 checks passed
@kazutakahirata kazutakahirata deleted the cleanup_20250703_mlir_example_fix branch July 3, 2025 22:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants