[mlir] Use std::nullopt instead of None (NFC)
authorKazu Hirata <kazu@google.com>
Sun, 4 Dec 2022 21:52:45 +0000 (13:52 -0800)
committerKazu Hirata <kazu@google.com>
Sun, 4 Dec 2022 21:52:46 +0000 (13:52 -0800)
I've verified that every change in this patch affects generated files
and would reduce the number of warnings if None were deprecated.

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

30 files changed:
mlir/include/mlir/Dialect/Affine/IR/AffineOps.td
mlir/include/mlir/Dialect/Async/IR/AsyncOps.td
mlir/include/mlir/Dialect/Bufferization/IR/AllocationOpInterface.td
mlir/include/mlir/Dialect/Func/IR/FuncOps.td
mlir/include/mlir/Dialect/LLVMIR/LLVMIntrinsicOps.td
mlir/include/mlir/Dialect/MLProgram/IR/MLProgramOps.td
mlir/include/mlir/Dialect/PDL/IR/PDLOps.td
mlir/include/mlir/Dialect/SCF/IR/SCFOps.td
mlir/include/mlir/Dialect/SPIRV/IR/SPIRVAvailability.td
mlir/include/mlir/Dialect/Shape/IR/ShapeOps.td
mlir/include/mlir/Dialect/Tensor/IR/TensorOps.td
mlir/include/mlir/Dialect/Vector/IR/VectorOps.td
mlir/include/mlir/Dialect/Vector/Interfaces/MaskableOpInterface.td
mlir/include/mlir/IR/BuiltinAttributeInterfaces.td
mlir/include/mlir/IR/BuiltinAttributes.td
mlir/include/mlir/IR/BuiltinOps.td
mlir/include/mlir/IR/BuiltinTypeInterfaces.td
mlir/include/mlir/IR/BuiltinTypes.td
mlir/include/mlir/IR/OpBase.td
mlir/include/mlir/Interfaces/ControlFlowInterfaces.td
mlir/include/mlir/Interfaces/LoopLikeInterface.td
mlir/include/mlir/Interfaces/SideEffectInterfaceBase.td
mlir/include/mlir/Interfaces/VectorInterfaces.td
mlir/test/mlir-tblgen/attrdefs.td
mlir/test/mlir-tblgen/op-attribute.td
mlir/test/mlir-tblgen/typedefs.td
mlir/tools/mlir-linalg-ods-gen/mlir-linalg-ods-yaml-gen.cpp
mlir/tools/mlir-tblgen/AttrOrTypeDefGen.cpp
mlir/tools/mlir-tblgen/EnumsGen.cpp
mlir/tools/mlir-tblgen/SPIRVUtilsGen.cpp

index 4327922..46b3c90 100644 (file)
@@ -224,12 +224,12 @@ def AffineForOp : Affine_Op<"for",
   let skipDefaultBuilders = 1;
   let builders = [
     OpBuilder<(ins "int64_t":$lowerBound, "int64_t":$upperBound,
-      CArg<"int64_t", "1">:$step, CArg<"ValueRange", "llvm::None">:$iterArgs,
+      CArg<"int64_t", "1">:$step, CArg<"ValueRange", "std::nullopt">:$iterArgs,
       CArg<"function_ref<void(OpBuilder &, Location, Value, ValueRange)>",
            "nullptr">:$bodyBuilder)>,
     OpBuilder<(ins "ValueRange":$lbOperands, "AffineMap":$lbMap,
       "ValueRange":$ubOperands, "AffineMap":$ubMap, CArg<"int64_t", "1">:$step,
-      CArg<"ValueRange", "llvm::None">:$iterArgs,
+      CArg<"ValueRange", "std::nullopt">:$iterArgs,
       CArg<"function_ref<void(OpBuilder &, Location, Value, ValueRange)>",
            "nullptr">:$bodyBuilder)>
   ];
@@ -925,7 +925,7 @@ def AffineYieldOp : Affine_Op<"yield", [Pure, Terminator, ReturnLike,
   let arguments = (ins Variadic<AnyType>:$operands);
 
   let builders = [
-    OpBuilder<(ins), [{ build($_builder, $_state, llvm::None); }]>
+    OpBuilder<(ins), [{ build($_builder, $_state, std::nullopt); }]>
   ];
 
   let assemblyFormat = "attr-dict ($operands^ `:` type($operands))?";
index 678930f..30895e5 100644 (file)
@@ -281,7 +281,7 @@ def Async_ReturnOp : Async_Op<"return",
 
   let arguments = (ins Variadic<AnyType>:$operands);
 
-  let builders = [OpBuilder<(ins), [{build($_builder, $_state, llvm::None);}]>];
+  let builders = [OpBuilder<(ins), [{build($_builder, $_state, std::nullopt);}]>];
 
   let assemblyFormat = "attr-dict ($operands^ `:` type($operands))?";
   let hasVerifier = 1;
@@ -332,7 +332,7 @@ def Async_AwaitOp : Async_Op<"await"> {
 
   let extraClassDeclaration = [{
     Optional<Type> getResultType() {
-      if (getResultTypes().empty()) return None;
+      if (getResultTypes().empty()) return std::nullopt;
       return getResultTypes()[0];
     }
   }];
index b30adae..de63062 100644 (file)
@@ -39,7 +39,7 @@ def AllocationOpInterface : OpInterface<"AllocationOpInterface"> {
       }],
       "::mlir::Optional<::mlir::Operation*>", "buildDealloc",
       (ins "::mlir::OpBuilder&":$builder, "::mlir::Value":$alloc), [{}],
-      /*defaultImplementation=*/[{ return llvm::None; }]
+      /*defaultImplementation=*/[{ return std::nullopt; }]
     >,
     StaticInterfaceMethod<[{
         Builds a clone operation using the provided builder and the current
@@ -50,7 +50,7 @@ def AllocationOpInterface : OpInterface<"AllocationOpInterface"> {
       }],
       "::mlir::Optional<::mlir::Value>", "buildClone",
       (ins "::mlir::OpBuilder&":$builder, "::mlir::Value":$alloc), [{}],
-      /*defaultImplementation=*/[{ return llvm::None; }]
+      /*defaultImplementation=*/[{ return std::nullopt; }]
     >
   ];
 }
index 0129828..f1b7cfd 100644 (file)
@@ -349,7 +349,7 @@ def ReturnOp : Func_Op<"return", [Pure, HasParent<"FuncOp">,
   let arguments = (ins Variadic<AnyType>:$operands);
 
   let builders = [OpBuilder<(ins), [{
-    build($_builder, $_state, llvm::None);
+    build($_builder, $_state, std::nullopt);
   }]>];
 
   let assemblyFormat = "attr-dict ($operands^ `:` type($operands))?";
index d40c6d2..13f4502 100644 (file)
@@ -273,7 +273,7 @@ class LLVM_DbgIntrOp<string name, string argName> : LLVM_IntrOp<name, [], [], []
         llvm::MetadataAsValue::get(ctx,
             llvm::ValueAsMetadata::get(moduleTranslation.lookupValue(opInst.getOperand(0)))),
         llvm::MetadataAsValue::get(ctx, moduleTranslation.translateDebugInfo($varInfo)),
-        llvm::MetadataAsValue::get(ctx, llvm::DIExpression::get(ctx, llvm::None)),
+        llvm::MetadataAsValue::get(ctx, llvm::DIExpression::get(ctx, std::nullopt)),
       });
   }];
   let mlirBuilder = [{
index 82a559a..422680a 100644 (file)
@@ -457,7 +457,7 @@ def MLProgram_OutputOp : MLProgram_Op<"output", [
   let arguments = (ins Variadic<AnyType>:$operands);
 
   let builders = [OpBuilder<(ins), [{
-    build($_builder, $_state, llvm::None);
+    build($_builder, $_state, std::nullopt);
   }]>];
 
   let assemblyFormat = "attr-dict ($operands^ `:` type($operands))?";
@@ -483,7 +483,7 @@ def MLProgram_ReturnOp : MLProgram_Op<"return", [
   let arguments = (ins Variadic<AnyType>:$operands);
 
   let builders = [OpBuilder<(ins), [{
-    build($_builder, $_state, llvm::None);
+    build($_builder, $_state, std::nullopt);
   }]>];
 
   let assemblyFormat = "attr-dict ($operands^ `:` type($operands))?";
index 2332d80..30aa8bd 100644 (file)
@@ -420,7 +420,7 @@ def PDL_PatternOp : PDL_Op<"pattern", [
 
   let builders = [
     OpBuilder<(ins CArg<"Optional<uint16_t>", "1">:$benefit,
-                   CArg<"Optional<StringRef>", "llvm::None">:$name)>,
+                   CArg<"Optional<StringRef>", "std::nullopt">:$name)>,
   ];
   let extraClassDeclaration = [{
     //===------------------------------------------------------------------===//
index 09a4969..60f2548 100644 (file)
@@ -222,7 +222,7 @@ def ForOp : SCF_Op<"for",
   let skipDefaultBuilders = 1;
   let builders = [
     OpBuilder<(ins "Value":$lowerBound, "Value":$upperBound, "Value":$step,
-      CArg<"ValueRange", "llvm::None">:$iterArgs,
+      CArg<"ValueRange", "std::nullopt">:$iterArgs,
       CArg<"function_ref<void(OpBuilder &, Location, Value, ValueRange)>",
            "nullptr">)>
   ];
@@ -276,10 +276,10 @@ def ForOp : SCF_Op<"for",
     /// operand return llvm::None.
     Optional<unsigned> getIterArgNumberForOpOperand(OpOperand &opOperand) {
       if (opOperand.getOwner() != getOperation())
-        return llvm::None;
+        return std::nullopt;
       unsigned operandNumber = opOperand.getOperandNumber();
       if (operandNumber < getNumControlOperands())
-        return llvm::None;
+        return std::nullopt;
       return operandNumber - getNumControlOperands();
     }
 
index 82310cf..3441455 100644 (file)
@@ -68,7 +68,7 @@ class MinVersionBase<string name, EnumAttr scheme, I32EnumAttrCase min>
       "$overall = static_cast<" # scheme.returnType # ">("
                   "std::max(*$overall, $instance)); "
     "} else { $overall = $instance; }}";
-  let initializer = "::llvm::None";
+  let initializer = "::std::nullopt";
   let instanceType = scheme.cppNamespace # "::" # scheme.enum.className;
 
   let instance = scheme.cppNamespace # "::" # scheme.enum.className # "::" #
@@ -87,7 +87,7 @@ class MaxVersionBase<string name, EnumAttr scheme, I32EnumAttrCase max>
       "$overall = static_cast<" # scheme.returnType # ">("
                   "std::min(*$overall, $instance)); "
     "} else { $overall = $instance; }}";
-  let initializer = "::llvm::None";
+  let initializer = "::std::nullopt";
   let instanceType = scheme.cppNamespace # "::" # scheme.enum.className;
 
   let instance = scheme.cppNamespace # "::" # scheme.enum.className # "::" #
index 6c0e784..c3697f0 100644 (file)
@@ -752,7 +752,7 @@ def Shape_YieldOp : Shape_Op<"yield",
   let arguments = (ins Variadic<AnyType>:$operands);
 
   let builders = [OpBuilder<(ins),
-    [{ build($_builder, $_state, llvm::None); }]>
+    [{ build($_builder, $_state, std::nullopt); }]>
   ];
 
   let assemblyFormat = "attr-dict ($operands^ `:` type($operands))?";
index b48284f..ee44862 100644 (file)
@@ -1765,7 +1765,7 @@ def Tensor_PackOp : Tensor_RelayoutOp<"pack", [
     OpBuilder<(ins "Value":$source, "Value":$dest,
       "ArrayRef<int64_t>":$innerDimsPos,
       "ArrayRef<OpFoldResult>":$innerTiles,
-      CArg<"Optional<Value>", "llvm::None">:$paddingValue,
+      CArg<"Optional<Value>", "std::nullopt">:$paddingValue,
       CArg<"ArrayRef<int64_t>", "{}">:$outerDimsPerm)>
   ];
 
index ff7b79b..8d8939e 100644 (file)
@@ -1368,19 +1368,19 @@ def Vector_TransferReadOp :
                    "Value":$source,
                    "ValueRange":$indices,
                    "AffineMap":$permutationMap,
-                   CArg<"Optional<ArrayRef<bool>>", "::llvm::None">:$inBounds)>,
+                   CArg<"Optional<ArrayRef<bool>>", "::std::nullopt">:$inBounds)>,
     /// 3. Builder that sets permutation map to 'getMinorIdentityMap'.
     OpBuilder<(ins "VectorType":$vectorType,
                    "Value":$source,
                    "ValueRange":$indices,
                    "Value":$padding,
-                   CArg<"Optional<ArrayRef<bool>>", "::llvm::None">:$inBounds)>,
+                   CArg<"Optional<ArrayRef<bool>>", "::std::nullopt">:$inBounds)>,
     /// 4. Builder that sets padding to zero and permutation map to
     /// 'getMinorIdentityMap'.
     OpBuilder<(ins "VectorType":$vectorType,
                    "Value":$source,
                    "ValueRange":$indices,
-                   CArg<"Optional<ArrayRef<bool>>", "::llvm::None">:$inBounds)>,
+                   CArg<"Optional<ArrayRef<bool>>", "::std::nullopt">:$inBounds)>,
   ];
 
   let extraClassDeclaration = [{
@@ -1517,13 +1517,13 @@ def Vector_TransferWriteOp :
                    "Value":$dest,
                    "ValueRange":$indices,
                    "AffineMap":$permutationMap,
-                   CArg<"Optional<ArrayRef<bool>>", "::llvm::None">:$inBounds)>,
+                   CArg<"Optional<ArrayRef<bool>>", "::std::nullopt">:$inBounds)>,
     /// 4. Builder with type inference that sets an empty mask and sets permutation
     /// map to 'getMinorIdentityMap'.
     OpBuilder<(ins "Value":$vector,
                    "Value":$dest,
                    "ValueRange":$indices,
-                   CArg<"Optional<ArrayRef<bool>>", "::llvm::None">:$inBounds)>,
+                   CArg<"Optional<ArrayRef<bool>>", "::std::nullopt">:$inBounds)>,
   ];
 
   let extraClassDeclaration = [{
index 7facac8..bbde7bc 100644 (file)
@@ -63,7 +63,7 @@ def MaskableOpInterface : OpInterface<"MaskableOpInterface"> {
       /*defaultImplementation=*/[{
       // Default implementation is only aimed for operations that implement the
       // `getVectorType()` method.
-        return $_op.getVectorType().cloneWith(/*shape=*/llvm::None,
+        return $_op.getVectorType().cloneWith(/*shape=*/std::nullopt,
           IntegerType::get($_op.getContext(), /*width=*/1));
     }]>,
   ];
index eb60977..22e91f1 100644 (file)
@@ -398,7 +398,7 @@ def ElementsAttrInterface : AttrInterface<"ElementsAttr"> {
     DefaultValueCheckT<T, Optional<iterator_range<T>>> tryGetValues() const {
       if (Optional<iterator<T>> beginIt = try_value_begin<T>())
         return iterator_range<T>(getType(), *beginIt, value_end<T>());
-      return llvm::None;
+      return std::nullopt;
     }
     template <typename T>
     DefaultValueCheckT<T, Optional<iterator<T>>> try_value_begin() const;
@@ -409,7 +409,7 @@ def ElementsAttrInterface : AttrInterface<"ElementsAttr"> {
     Optional<DerivedAttrValueIteratorRange<T>> tryGetValues() const {
       auto values = tryGetValues<Attribute>();
       if (!values)
-        return llvm::None;
+        return std::nullopt;
 
       auto castFn = [](Attribute attr) { return attr.template cast<T>(); };
       return DerivedAttrValueIteratorRange<T>(
@@ -421,7 +421,7 @@ def ElementsAttrInterface : AttrInterface<"ElementsAttr"> {
     Optional<DerivedAttrValueIterator<T>> try_value_begin() const {
       if (auto values = tryGetValues<T>())
         return values->begin();
-      return llvm::None;
+      return std::nullopt;
     }
   }] # ElementsAttrInterfaceAccessors;
 }
index 70a535a..fc0f696 100644 (file)
@@ -534,7 +534,7 @@ def Builtin_DictionaryAttr : Builtin_Attr<"Dictionary", [
   }];
   let parameters = (ins ArrayRefParameter<"NamedAttribute", "">:$value);
   let builders = [
-    AttrBuilder<(ins CArg<"ArrayRef<NamedAttribute>", "llvm::None">:$value)>
+    AttrBuilder<(ins CArg<"ArrayRef<NamedAttribute>", "std::nullopt">:$value)>
   ];
   let extraClassDeclaration = [{
     using ValueType = ArrayRef<NamedAttribute>;
index 72ce4cb..68a512c 100644 (file)
@@ -61,7 +61,7 @@ def ModuleOp : Builtin_Op<"module", [
   let builders = [OpBuilder<(ins CArg<"Optional<StringRef>", "{}">:$name)>];
   let extraClassDeclaration = [{
     /// Construct a module from the given location with an optional name.
-    static ModuleOp create(Location loc, Optional<StringRef> name = llvm::None);
+    static ModuleOp create(Location loc, Optional<StringRef> name = std::nullopt);
 
     /// Return the name of this module if present.
     Optional<StringRef> getName() { return getSymName(); }
index 08efe25..cfbf937 100644 (file)
@@ -121,7 +121,7 @@ def ShapedTypeInterface : TypeInterface<"ShapedType"> {
     }
     /// Return a clone of this type with the given new element type.
     auto clone(::mlir::Type elementType) {
-      return $_type.cloneWith(/*shape=*/llvm::None, elementType);
+      return $_type.cloneWith(/*shape=*/std::nullopt, elementType);
     }
 
     /// If an element type is an integer or a float, return its width. Otherwise,
index 15749cf..be9d14d 100644 (file)
@@ -880,7 +880,7 @@ def Builtin_UnrankedMemRef : Builtin_Type<"UnrankedMemRef", [
     using ShapedType::Trait<UnrankedMemRefType>::getDimSize;
     using ShapedType::Trait<UnrankedMemRefType>::getDynamicDimIndex;
 
-    ArrayRef<int64_t> getShape() const { return llvm::None; }
+    ArrayRef<int64_t> getShape() const { return std::nullopt; }
 
     /// [deprecated] Returns the memory space in old raw integer representation.
     /// New `Attribute getMemorySpace()` method should be used instead.
@@ -933,7 +933,7 @@ def Builtin_UnrankedTensor : Builtin_Type<"UnrankedTensor", [
     using ShapedType::Trait<UnrankedTensorType>::getDimSize;
     using ShapedType::Trait<UnrankedTensorType>::getDynamicDimIndex;
 
-    ArrayRef<int64_t> getShape() const { return llvm::None; }
+    ArrayRef<int64_t> getShape() const { return std::nullopt; }
   }];
   let skipDefaultBuilders = 1;
   let genVerifyDecl = 1;
index e74cd00..2affd9a 100644 (file)
@@ -1035,7 +1035,7 @@ class OptionalAttr<Attr attr> : Attr<attr.predicate, attr.summary> {
   let storageType = attr.storageType;
   let returnType = "::llvm::Optional<" # attr.returnType #">";
   let convertFromStorage = "$_self ? " # returnType # "(" #
-                           attr.convertFromStorage # ") : (::llvm::None)";
+                           attr.convertFromStorage # ") : (::std::nullopt)";
   let valueType = attr.valueType;
   let isOptional = 1;
 
index e1d36a8..6e2ed7e 100644 (file)
@@ -79,7 +79,7 @@ def BranchOpInterface : OpInterface<"BranchOpInterface"> {
                 opaqueOp->getSuccessor(i)))
             return arg;
         }
-        return ::llvm::None;
+        return ::std::nullopt;
       }]
     >,
     InterfaceMethod<[{
index 2578b1b..6c89c10 100644 (file)
@@ -57,7 +57,7 @@ def LoopLikeOpInterface : OpInterface<"LoopLikeOpInterface"> {
       /*args=*/(ins),
       /*methodBody=*/"",
       /*defaultImplementation=*/[{
-        return llvm::None;
+        return std::nullopt;
       }]
     >,
     InterfaceMethod<[{
@@ -69,7 +69,7 @@ def LoopLikeOpInterface : OpInterface<"LoopLikeOpInterface"> {
       /*args=*/(ins),
       /*methodBody=*/"",
       /*defaultImplementation=*/[{
-        return llvm::None;
+        return std::nullopt;
       }]
     >,
     InterfaceMethod<[{
@@ -81,7 +81,7 @@ def LoopLikeOpInterface : OpInterface<"LoopLikeOpInterface"> {
       /*args=*/(ins),
       /*methodBody=*/"",
       /*defaultImplementation=*/[{
-        return llvm::None;
+        return std::nullopt;
       }]
     >,
     InterfaceMethod<[{
@@ -93,7 +93,7 @@ def LoopLikeOpInterface : OpInterface<"LoopLikeOpInterface"> {
       /*args=*/(ins),
       /*methodBody=*/"",
       /*defaultImplementation=*/[{
-        return llvm::None;
+        return std::nullopt;
       }]
     >,
   ];
index b703fa5..842b7ff 100644 (file)
@@ -115,7 +115,7 @@ class EffectOpInterfaceBase<string name, string baseEffect>
         return isa<Effect>(it.getEffect()) && it.getValue() == value;
       });
       if (it == effects.end())
-        return llvm::None;
+        return std::nullopt;
       return *it;
     }
 
index 0da3309..645f57f 100644 (file)
@@ -37,7 +37,7 @@ def VectorUnrollOpInterface : OpInterface<"VectorUnrollOpInterface"> {
         auto vt = $_op.getResult().getType().
           template dyn_cast<::mlir::VectorType>();
         if (!vt)
-          return ::mlir::None;
+          return ::std::nullopt;
         ::llvm::SmallVector<int64_t, 4> res(vt.getShape().begin(), vt.getShape().end());
         return res;
       }]
index c5ef651..020cd0c 100644 (file)
@@ -33,7 +33,7 @@ include "mlir/IR/OpBase.td"
 // DEF-NEXT:   return ::mlir::success(!!value);
 // DEF: .Default([&](llvm::StringRef keyword,
 // DEF-NEXT:   *mnemonic = keyword;
-// DEF-NEXT:   return llvm::None;
+// DEF-NEXT:   return std::nullopt;
 
 def Test_Dialect: Dialect {
 // DECL-NOT: TestDialect
index cf76ce0..269d6e1 100644 (file)
@@ -112,7 +112,7 @@ def AOp : NS_Op<"a_op", []> {
 // DEF-NEXT:   ::mlir::impl::getAttrFromSortedRange((*this)->getAttrs().begin() + 1, (*this)->getAttrs().end() - 0, getCAttrAttrName()).dyn_cast_or_null<some-attr-kind>()
 // DEF:      ::llvm::Optional<some-return-type> AOp::getCAttr() {
 // DEF-NEXT:   auto attr = getCAttrAttr()
-// DEF-NEXT:   return attr ? ::llvm::Optional<some-return-type>(attr.some-convert-from-storage()) : (::llvm::None);
+// DEF-NEXT:   return attr ? ::llvm::Optional<some-return-type>(attr.some-convert-from-storage()) : (::std::nullopt);
 
 // DEF:      some-attr-kind AOp::getDAttrAttr()
 // DEF-NEXT:   ::mlir::impl::getAttrFromSortedRange((*this)->getAttrs().begin() + 1, (*this)->getAttrs().end() - 0, getDAttrAttrName()).dyn_cast_or_null<some-attr-kind>()
@@ -249,7 +249,7 @@ def AgetOp : Op<Test2_Dialect, "a_get_op", []> {
 // DEF-NEXT:   return ::mlir::impl::getAttrFromSortedRange({{.*}}).dyn_cast_or_null<some-attr-kind>()
 // DEF:      ::llvm::Optional<some-return-type> AgetOp::getCAttr() {
 // DEF-NEXT:   auto attr = getCAttrAttr()
-// DEF-NEXT:   return attr ? ::llvm::Optional<some-return-type>(attr.some-convert-from-storage()) : (::llvm::None);
+// DEF-NEXT:   return attr ? ::llvm::Optional<some-return-type>(attr.some-convert-from-storage()) : (::std::nullopt);
 
 // Test setter methods
 // ---
index f247264..5100663 100644 (file)
@@ -33,7 +33,7 @@ include "mlir/IR/OpBase.td"
 // DEF-NEXT:   return ::mlir::success(!!value);
 // DEF: .Default([&](llvm::StringRef keyword,
 // DEF-NEXT:   *mnemonic = keyword;
-// DEF-NEXT:   return llvm::None;
+// DEF-NEXT:   return std::nullopt;
 
 def Test_Dialect: Dialect {
 // DECL-NOT: TestDialect
index 476b935..bede051 100644 (file)
@@ -525,7 +525,7 @@ def {0} : LinalgStructuredBase_Op<"{1}", !listconcat([AttrSizedOperandSegments],
       (ins "ValueRange":$inputs, "ValueRange":$outputs,
             CArg<"ArrayRef<NamedAttribute>", "{{}">:$attributes),
       [{{
-        buildStructuredOp($_builder, $_state, llvm::None, inputs, outputs,
+        buildStructuredOp($_builder, $_state, std::nullopt, inputs, outputs,
           attributes, {0}::getRegionBuilder());
       }]>,
       OpBuilder<
index f34aaa3..31e7375 100644 (file)
@@ -815,7 +815,7 @@ void DefGenerator::emitParsePrintDispatch(ArrayRef<AttrOrTypeDef> defs) {
   }
   parse.body() << "    .Default([&](llvm::StringRef keyword, llvm::SMLoc) {\n"
                   "      *mnemonic = keyword;\n"
-                  "      return llvm::None;\n"
+                  "      return std::nullopt;\n"
                   "    });";
   printer.body() << "    .Default([](auto) { return ::mlir::failure(); });";
 
index f4e7566..4543b9d 100644 (file)
@@ -392,7 +392,7 @@ static void emitStrToSymFnForIntEnum(const Record &enumDef, raw_ostream &os) {
     os << formatv("      .Case(\"{1}\", {0}::{2})\n", enumName, str,
                   makeIdentifier(symbol));
   }
-  os << "      .Default(::llvm::None);\n";
+  os << "      .Default(::std::nullopt);\n";
   os << "}\n";
 }
 
@@ -433,9 +433,9 @@ static void emitStrToSymFnForBitEnum(const Record &enumDef, raw_ostream &os) {
     if (auto val = enumerant.getValue())
       os.indent(6) << formatv(".Case(\"{0}\", {1})\n", enumerant.getStr(), val);
   }
-  os.indent(6) << ".Default(::llvm::None);\n";
+  os.indent(6) << ".Default(::std::nullopt);\n";
 
-  os << "    if (bit) { val |= *bit; } else { return ::llvm::None; }\n";
+  os << "    if (bit) { val |= *bit; } else { return ::std::nullopt; }\n";
   os << "  }\n";
 
   os << formatv("  return static_cast<{0}>(val);\n", enumName);
@@ -468,7 +468,7 @@ static void emitUnderlyingToSymFnForIntEnum(const Record &enumDef,
     os << formatv("  case {0}: return {1}::{2};\n", value, enumName,
                   makeIdentifier(symbol));
   }
-  os << "  default: return ::llvm::None;\n"
+  os << "  default: return ::std::nullopt;\n"
      << "  }\n"
      << "}\n\n";
 }
@@ -548,7 +548,7 @@ static void emitUnderlyingToSymFnForBitEnum(const Record &enumDef,
                   makeIdentifier(allBitsUnsetCase->getSymbol()));
   }
   int64_t validBits = enumDef.getValueAsInt("validBits");
-  os << formatv("  if (value & ~static_cast<{0}>({1}u)) return llvm::None;\n",
+  os << formatv("  if (value & ~static_cast<{0}>({1}u)) return std::nullopt;\n",
                 underlyingType, validBits);
   os << formatv("  return static_cast<{0}>(value);\n", enumName);
   os << "}\n";
index 128f4d0..014c947 100644 (file)
@@ -362,7 +362,7 @@ static void emitAvailabilityQueryForIntEnum(const Record &enumDef,
     if (classCasePair.getValue().size() < enumAttr.getAllCases().size())
       os << "  default: break;\n";
     os << "  }\n"
-       << "  return llvm::None;\n"
+       << "  return std::nullopt;\n"
        << "}\n";
   }
 }
@@ -407,7 +407,7 @@ static void emitAvailabilityQueryForBitEnum(const Record &enumDef,
     }
     os << "  default: break;\n";
     os << "  }\n"
-       << "  return llvm::None;\n"
+       << "  return std::nullopt;\n"
        << "}\n";
   }
 }