[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]
This commit is contained in:
Kazu Hirata 2025-07-03 15:49:43 -07:00 committed by GitHub
parent 2910c24638
commit 96f7f22825
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 8 additions and 8 deletions

View File

@ -120,7 +120,7 @@ private:
// 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);
}

View File

@ -120,7 +120,7 @@ private:
// 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);
}

View File

@ -120,7 +120,7 @@ private:
// 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);
}

View File

@ -120,7 +120,7 @@ private:
// 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);
}

View File

@ -120,7 +120,7 @@ private:
// 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);
}

View File

@ -182,7 +182,7 @@ private:
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 @@ private:
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);