[mlir] Use std::nullopt instead of None (NFC)

This patch mechanically replaces None with std::nullopt where the
compiler would warn if None were deprecated.  The intent is to reduce
the amount of manual work required in migrating from Optional to
std::optional.

This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
This commit is contained in:
Kazu Hirata
2022-12-03 18:50:27 -08:00
parent 1d650d4f1d
commit 1a36588ec6
197 changed files with 594 additions and 581 deletions

View File

@@ -122,7 +122,7 @@ static Optional<Value> sizeFromTensorAtDim(OpBuilder &builder, Location loc,
Value adaptedValue, unsigned dim) {
auto enc = getSparseTensorEncoding(tensorTp);
if (!enc)
return llvm::None;
return std::nullopt;
// Access into static dimension can query original type directly.
// Note that this is typically already done by DimOp's folding.
@@ -200,7 +200,7 @@ static Optional<LogicalResult>
convertSparseTensorType(Type type, SmallVectorImpl<Type> &fields) {
auto enc = getSparseTensorEncoding(type);
if (!enc)
return llvm::None;
return std::nullopt;
// Construct the basic types.
auto *context = type.getContext();
RankedTensorType rType = type.cast<RankedTensorType>();
@@ -1105,7 +1105,7 @@ mlir::SparseTensorTypeToBufferConverter::SparseTensorTypeToBufferConverter() {
Location loc) -> Optional<Value> {
if (!getSparseTensorEncoding(tp))
// Not a sparse tensor.
return llvm::None;
return std::nullopt;
// Sparse compiler knows how to cancel out these casts.
return genTuple(builder, loc, tp, inputs);
});