Skip to content

Commit 96f7f22

Browse files
[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]
1 parent 2910c24 commit 96f7f22

File tree

6 files changed

+8
-8
lines changed

6 files changed

+8
-8
lines changed

mlir/examples/toy/Ch2/mlir/MLIRGen.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ class MLIRGenImpl {
120120
// Arguments type are uniformly unranked tensors.
121121
llvm::SmallVector<mlir::Type, 4> argTypes(proto.getArgs().size(),
122122
getType(VarType{}));
123-
auto funcType = builder.getFunctionType(argTypes, std::nullopt);
123+
auto funcType = builder.getFunctionType(argTypes, {});
124124
return builder.create<mlir::toy::FuncOp>(location, proto.getName(),
125125
funcType);
126126
}

mlir/examples/toy/Ch3/mlir/MLIRGen.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ class MLIRGenImpl {
120120
// Arguments type are uniformly unranked tensors.
121121
llvm::SmallVector<mlir::Type, 4> argTypes(proto.getArgs().size(),
122122
getType(VarType{}));
123-
auto funcType = builder.getFunctionType(argTypes, std::nullopt);
123+
auto funcType = builder.getFunctionType(argTypes, /*results=*/{});
124124
return builder.create<mlir::toy::FuncOp>(location, proto.getName(),
125125
funcType);
126126
}

mlir/examples/toy/Ch4/mlir/MLIRGen.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ class MLIRGenImpl {
120120
// Arguments type are uniformly unranked tensors.
121121
llvm::SmallVector<mlir::Type, 4> argTypes(proto.getArgs().size(),
122122
getType(VarType{}));
123-
auto funcType = builder.getFunctionType(argTypes, std::nullopt);
123+
auto funcType = builder.getFunctionType(argTypes, /*results=*/{});
124124
return builder.create<mlir::toy::FuncOp>(location, proto.getName(),
125125
funcType);
126126
}

mlir/examples/toy/Ch5/mlir/MLIRGen.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ class MLIRGenImpl {
120120
// Arguments type are uniformly unranked tensors.
121121
llvm::SmallVector<mlir::Type, 4> argTypes(proto.getArgs().size(),
122122
getType(VarType{}));
123-
auto funcType = builder.getFunctionType(argTypes, std::nullopt);
123+
auto funcType = builder.getFunctionType(argTypes, /*results=*/{});
124124
return builder.create<mlir::toy::FuncOp>(location, proto.getName(),
125125
funcType);
126126
}

mlir/examples/toy/Ch6/mlir/MLIRGen.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ class MLIRGenImpl {
120120
// Arguments type are uniformly unranked tensors.
121121
llvm::SmallVector<mlir::Type, 4> argTypes(proto.getArgs().size(),
122122
getType(VarType{}));
123-
auto funcType = builder.getFunctionType(argTypes, std::nullopt);
123+
auto funcType = builder.getFunctionType(argTypes, /*results=*/{});
124124
return builder.create<mlir::toy::FuncOp>(location, proto.getName(),
125125
funcType);
126126
}

mlir/examples/toy/Ch7/mlir/MLIRGen.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ class MLIRGenImpl {
182182
return nullptr;
183183
argTypes.push_back(type);
184184
}
185-
auto funcType = builder.getFunctionType(argTypes, std::nullopt);
185+
auto funcType = builder.getFunctionType(argTypes, /*results=*/{});
186186
return builder.create<mlir::toy::FuncOp>(location, proto.getName(),
187187
funcType);
188188
}
@@ -441,10 +441,10 @@ class MLIRGenImpl {
441441
for (auto &var : lit.getValues()) {
442442
if (auto *number = llvm::dyn_cast<NumberExprAST>(var.get())) {
443443
attrElements.push_back(getConstantAttr(*number));
444-
typeElements.push_back(getType(std::nullopt));
444+
typeElements.push_back(getType(/*shape=*/{}));
445445
} else if (auto *lit = llvm::dyn_cast<LiteralExprAST>(var.get())) {
446446
attrElements.push_back(getConstantAttr(*lit));
447-
typeElements.push_back(getType(std::nullopt));
447+
typeElements.push_back(getType(/*shape=*/{}));
448448
} else {
449449
auto *structLit = llvm::cast<StructLiteralExprAST>(var.get());
450450
auto attrTypePair = getConstantAttr(*structLit);

0 commit comments

Comments
 (0)