diff --git a/flang/lib/Optimizer/Dialect/FIROps.cpp b/flang/lib/Optimizer/Dialect/FIROps.cpp index 01c70659bb4e..6db08c93352a 100644 --- a/flang/lib/Optimizer/Dialect/FIROps.cpp +++ b/flang/lib/Optimizer/Dialect/FIROps.cpp @@ -1105,7 +1105,7 @@ mlir::ParseResult fir::DispatchTableOp::parse(mlir::OpAsmParser &parser, // Parse the optional table body. mlir::Region *body = result.addRegion(); mlir::OptionalParseResult parseResult = parser.parseOptionalRegion(*body); - if (parseResult.hasValue() && failed(*parseResult)) + if (parseResult.has_value() && failed(*parseResult)) return mlir::failure(); fir::DispatchTableOp::ensureTerminator(*body, parser.getBuilder(), @@ -1287,7 +1287,7 @@ mlir::ParseResult fir::GlobalOp::parse(mlir::OpAsmParser &parser, // Parse the optional initializer body. auto parseResult = parser.parseOptionalRegion(*result.addRegion(), /*arguments=*/{}); - if (parseResult.hasValue() && mlir::failed(*parseResult)) + if (parseResult.has_value() && mlir::failed(*parseResult)) return mlir::failure(); } return mlir::success(); diff --git a/flang/lib/Optimizer/Dialect/FIRType.cpp b/flang/lib/Optimizer/Dialect/FIRType.cpp index 9f51121679d6..8963fec2f8f6 100644 --- a/flang/lib/Optimizer/Dialect/FIRType.cpp +++ b/flang/lib/Optimizer/Dialect/FIRType.cpp @@ -118,7 +118,7 @@ mlir::Type fir::parseFirType(FIROpsDialect *dialect, mlir::StringRef typeTag; mlir::Type genType; auto parseResult = generatedTypeParser(parser, &typeTag, genType); - if (parseResult.hasValue()) + if (parseResult.has_value()) return genType; parser.emitError(parser.getNameLoc(), "unknown fir type: ") << typeTag; return {}; diff --git a/mlir/include/mlir/IR/OpImplementation.h b/mlir/include/mlir/IR/OpImplementation.h index 5de78883a50b..f479bbce4db6 100644 --- a/mlir/include/mlir/IR/OpImplementation.h +++ b/mlir/include/mlir/IR/OpImplementation.h @@ -605,7 +605,7 @@ public: ParseResult parseInteger(IntT &result) { auto loc = getCurrentLocation(); OptionalParseResult parseResult = parseOptionalInteger(result); - if (!parseResult.hasValue()) + if (!parseResult.has_value()) return emitError(loc, "expected integer value"); return *parseResult; } @@ -620,7 +620,7 @@ public: // Parse the unsigned variant. APInt uintResult; OptionalParseResult parseResult = parseOptionalInteger(uintResult); - if (!parseResult.hasValue() || failed(*parseResult)) + if (!parseResult.has_value() || failed(*parseResult)) return parseResult; // Try to convert to the provided integer type. sextOrTrunc is correct even @@ -976,7 +976,7 @@ public: StringRef attrName, NamedAttrList &attrs) { OptionalParseResult parseResult = parseOptionalAttribute(result, type); - if (parseResult.hasValue() && succeeded(*parseResult)) + if (parseResult.has_value() && succeeded(*parseResult)) attrs.append(attrName, result); return parseResult; } @@ -1502,7 +1502,7 @@ public: ParseResult parseAssignmentList(SmallVectorImpl &lhs, SmallVectorImpl &rhs) { OptionalParseResult result = parseOptionalAssignmentList(lhs, rhs); - if (!result.hasValue()) + if (!result.has_value()) return emitError(getCurrentLocation(), "expected '('"); return result.getValue(); } diff --git a/mlir/lib/AsmParser/AttributeParser.cpp b/mlir/lib/AsmParser/AttributeParser.cpp index a554ad2df6f5..8e827462ee21 100644 --- a/mlir/lib/AsmParser/AttributeParser.cpp +++ b/mlir/lib/AsmParser/AttributeParser.cpp @@ -223,7 +223,7 @@ Attribute Parser::parseAttribute(Type type) { // better error message. Type type; OptionalParseResult result = parseOptionalType(type); - if (!result.hasValue()) + if (!result.has_value()) return emitWrongTokenError("expected attribute value"), Attribute(); return failed(*result) ? Attribute() : TypeAttr::get(type); } @@ -257,7 +257,7 @@ OptionalParseResult Parser::parseOptionalAttribute(Attribute &attribute, // Parse an optional type attribute. Type type; OptionalParseResult result = parseOptionalType(type); - if (result.hasValue() && succeeded(*result)) + if (result.has_value() && succeeded(*result)) attribute = TypeAttr::get(type); return result; } diff --git a/mlir/lib/Dialect/DLTI/DLTI.cpp b/mlir/lib/Dialect/DLTI/DLTI.cpp index 046152a67092..a5f5d4b13e1c 100644 --- a/mlir/lib/Dialect/DLTI/DLTI.cpp +++ b/mlir/lib/Dialect/DLTI/DLTI.cpp @@ -73,11 +73,11 @@ DataLayoutEntryAttr DataLayoutEntryAttr::parse(AsmParser &parser) { std::string identifier; SMLoc idLoc = parser.getCurrentLocation(); OptionalParseResult parsedType = parser.parseOptionalType(type); - if (parsedType.hasValue() && failed(parsedType.getValue())) + if (parsedType.has_value() && failed(parsedType.getValue())) return {}; - if (!parsedType.hasValue()) { + if (!parsedType.has_value()) { OptionalParseResult parsedString = parser.parseOptionalString(&identifier); - if (!parsedString.hasValue() || failed(parsedString.getValue())) { + if (!parsedString.has_value() || failed(parsedString.getValue())) { parser.emitError(idLoc) << "expected a type or a quoted string"; return {}; } diff --git a/mlir/lib/Dialect/EmitC/IR/EmitC.cpp b/mlir/lib/Dialect/EmitC/IR/EmitC.cpp index 7f5e15a9c76e..b005506e3ed5 100644 --- a/mlir/lib/Dialect/EmitC/IR/EmitC.cpp +++ b/mlir/lib/Dialect/EmitC/IR/EmitC.cpp @@ -152,7 +152,7 @@ ParseResult IncludeOp::parse(OpAsmParser &parser, OperationState &result) { StringAttr include; OptionalParseResult includeParseResult = parser.parseOptionalAttribute(include, "include", result.attributes); - if (!includeParseResult.hasValue()) + if (!includeParseResult.has_value()) return parser.emitError(parser.getNameLoc()) << "expected string attribute"; if (standardInclude && parser.parseOptionalGreater()) diff --git a/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp b/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp index 25a64900ad66..7f3ba764c68a 100644 --- a/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp +++ b/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp @@ -341,10 +341,10 @@ static ParseResult parseSwitchOpCases( do { int64_t value = 0; OptionalParseResult integerParseResult = parser.parseOptionalInteger(value); - if (values.empty() && !integerParseResult.hasValue()) + if (values.empty() && !integerParseResult.has_value()) return success(); - if (!integerParseResult.hasValue() || integerParseResult.getValue()) + if (!integerParseResult.has_value() || integerParseResult.getValue()) return failure(); values.push_back(APInt(bitWidth, value)); @@ -541,7 +541,7 @@ parseGEPIndices(OpAsmParser &parser, int32_t constantIndex; OptionalParseResult parsedInteger = parser.parseOptionalInteger(constantIndex); - if (parsedInteger.hasValue()) { + if (parsedInteger.has_value()) { if (failed(parsedInteger.getValue())) return failure(); constantIndices.push_back(constantIndex); @@ -1965,7 +1965,7 @@ ParseResult GlobalOp::parse(OpAsmParser &parser, OperationState &result) { OptionalParseResult parseResult = parser.parseOptionalRegion(initRegion, /*arguments=*/{}, /*argTypes=*/{}); - if (parseResult.hasValue() && failed(*parseResult)) + if (parseResult.has_value() && failed(*parseResult)) return failure(); } @@ -2298,7 +2298,7 @@ ParseResult LLVMFuncOp::parse(OpAsmParser &parser, OperationState &result) { auto *body = result.addRegion(); OptionalParseResult parseResult = parser.parseOptionalRegion(*body, entryArgs); - return failure(parseResult.hasValue() && failed(*parseResult)); + return failure(parseResult.has_value() && failed(*parseResult)); } // Print the LLVMFuncOp. Collects argument and result types and passes them to diff --git a/mlir/lib/Dialect/LLVMIR/IR/LLVMTypeSyntax.cpp b/mlir/lib/Dialect/LLVMIR/IR/LLVMTypeSyntax.cpp index 52d798fe58cb..e9121804a7d3 100644 --- a/mlir/lib/Dialect/LLVMIR/IR/LLVMTypeSyntax.cpp +++ b/mlir/lib/Dialect/LLVMIR/IR/LLVMTypeSyntax.cpp @@ -232,7 +232,7 @@ static LLVMPointerType parsePointerType(AsmParser &parser) { unsigned addressSpace = 0; OptionalParseResult opr = parser.parseOptionalInteger(addressSpace); - if (opr.hasValue()) { + if (opr.has_value()) { if (failed(*opr) || parser.parseGreater()) return LLVMPointerType(); return parser.getChecked(loc, parser.getContext(), @@ -441,7 +441,7 @@ static Type dispatchParse(AsmParser &parser, bool allowAny = true) { // Try parsing any MLIR type. Type type; OptionalParseResult result = parser.parseOptionalType(type); - if (result.hasValue()) { + if (result.has_value()) { if (failed(result.getValue())) return nullptr; if (!allowAny) { diff --git a/mlir/lib/Dialect/Linalg/TransformOps/LinalgTransformOps.cpp b/mlir/lib/Dialect/Linalg/TransformOps/LinalgTransformOps.cpp index 246a23c79bd9..1473efb2ff19 100644 --- a/mlir/lib/Dialect/Linalg/TransformOps/LinalgTransformOps.cpp +++ b/mlir/lib/Dialect/Linalg/TransformOps/LinalgTransformOps.cpp @@ -775,7 +775,7 @@ ParseResult SplitOp::parse(OpAsmParser &parser, OperationState &result) { OptionalParseResult dynamicPointParseResult = parser.parseOptionalOperand(dynamicSplitPoint); - if (!dynamicPointParseResult.hasValue()) { + if (!dynamicPointParseResult.has_value()) { int64_t staticSplitPointValue; if (failed(parser.parseInteger(staticSplitPointValue))) return failure(); diff --git a/mlir/lib/Dialect/OpenACC/IR/OpenACC.cpp b/mlir/lib/Dialect/OpenACC/IR/OpenACC.cpp index ec1b6e942e80..b2960a68144f 100644 --- a/mlir/lib/Dialect/OpenACC/IR/OpenACC.cpp +++ b/mlir/lib/Dialect/OpenACC/IR/OpenACC.cpp @@ -243,7 +243,7 @@ ParseResult ParallelOp::parse(OpAsmParser &parser, OperationState &result) { // async()? async = parseOptionalOperandAndType(parser, ParallelOp::getAsyncKeyword(), result); - if (async.hasValue() && failed(*async)) + if (async.has_value() && failed(*async)) return failure(); // wait()? @@ -254,19 +254,19 @@ ParseResult ParallelOp::parse(OpAsmParser &parser, OperationState &result) { // num_gangs(value)? numGangs = parseOptionalOperandAndType( parser, ParallelOp::getNumGangsKeyword(), result); - if (numGangs.hasValue() && failed(*numGangs)) + if (numGangs.has_value() && failed(*numGangs)) return failure(); // num_workers(value)? numWorkers = parseOptionalOperandAndType( parser, ParallelOp::getNumWorkersKeyword(), result); - if (numWorkers.hasValue() && failed(*numWorkers)) + if (numWorkers.has_value() && failed(*numWorkers)) return failure(); // vector_length(value)? vectorLength = parseOptionalOperandAndType( parser, ParallelOp::getVectorLengthKeyword(), result); - if (vectorLength.hasValue() && failed(*vectorLength)) + if (vectorLength.has_value() && failed(*vectorLength)) return failure(); // if()? @@ -362,11 +362,11 @@ ParseResult ParallelOp::parse(OpAsmParser &parser, OperationState &result) { result.addAttribute( ParallelOp::getOperandSegmentSizeAttr(), builder.getI32VectorAttr( - {static_cast(async.hasValue() ? 1 : 0), + {static_cast(async.has_value() ? 1 : 0), static_cast(waitOperands.size()), - static_cast(numGangs.hasValue() ? 1 : 0), - static_cast(numWorkers.hasValue() ? 1 : 0), - static_cast(vectorLength.hasValue() ? 1 : 0), + static_cast(numGangs.has_value() ? 1 : 0), + static_cast(numWorkers.has_value() ? 1 : 0), + static_cast(vectorLength.has_value() ? 1 : 0), static_cast(hasIfCond ? 1 : 0), static_cast(hasSelfCond ? 1 : 0), static_cast(reductionOperands.size()), @@ -531,13 +531,13 @@ ParseResult LoopOp::parse(OpAsmParser &parser, OperationState &result) { if (succeeded(parser.parseOptionalLParen())) { gangNum = parserOptionalOperandAndTypeWithPrefix( parser, result, LoopOp::getGangNumKeyword()); - if (gangNum.hasValue() && failed(*gangNum)) + if (gangNum.has_value() && failed(*gangNum)) return failure(); // FIXME: Comma should require subsequent operands. (void)parser.parseOptionalComma(); gangStatic = parserOptionalOperandAndTypeWithPrefix( parser, result, LoopOp::getGangStaticKeyword()); - if (gangStatic.hasValue() && failed(*gangStatic)) + if (gangStatic.has_value() && failed(*gangStatic)) return failure(); // FIXME: Why allow optional last commas? (void)parser.parseOptionalComma(); @@ -551,7 +551,7 @@ ParseResult LoopOp::parse(OpAsmParser &parser, OperationState &result) { // optional worker operand worker = parseOptionalOperandAndType(parser, result); - if (worker.hasValue() && failed(*worker)) + if (worker.has_value() && failed(*worker)) return failure(); // vector? @@ -560,7 +560,7 @@ ParseResult LoopOp::parse(OpAsmParser &parser, OperationState &result) { // optional vector operand vector = parseOptionalOperandAndType(parser, result); - if (vector.hasValue() && failed(*vector)) + if (vector.has_value() && failed(*vector)) return failure(); // tile()? @@ -591,10 +591,10 @@ ParseResult LoopOp::parse(OpAsmParser &parser, OperationState &result) { result.addAttribute(LoopOp::getOperandSegmentSizeAttr(), builder.getI32VectorAttr( - {static_cast(gangNum.hasValue() ? 1 : 0), - static_cast(gangStatic.hasValue() ? 1 : 0), - static_cast(worker.hasValue() ? 1 : 0), - static_cast(vector.hasValue() ? 1 : 0), + {static_cast(gangNum.has_value() ? 1 : 0), + static_cast(gangStatic.has_value() ? 1 : 0), + static_cast(worker.has_value() ? 1 : 0), + static_cast(vector.has_value() ? 1 : 0), static_cast(tileOperands.size()), static_cast(privateOperands.size()), static_cast(reductionOperands.size())})); diff --git a/mlir/lib/Dialect/PDL/IR/PDLTypes.cpp b/mlir/lib/Dialect/PDL/IR/PDLTypes.cpp index 5c57f883fd3d..f4dbbfb5b050 100644 --- a/mlir/lib/Dialect/PDL/IR/PDLTypes.cpp +++ b/mlir/lib/Dialect/PDL/IR/PDLTypes.cpp @@ -38,7 +38,7 @@ static Type parsePDLType(AsmParser &parser) { { Type genType; auto parseResult = generatedTypeParser(parser, &typeTag, genType); - if (parseResult.hasValue()) + if (parseResult.has_value()) return genType; } diff --git a/mlir/lib/Dialect/Quant/IR/TypeParser.cpp b/mlir/lib/Dialect/Quant/IR/TypeParser.cpp index 951f62a76c44..91e7ec78aaa5 100644 --- a/mlir/lib/Dialect/Quant/IR/TypeParser.cpp +++ b/mlir/lib/Dialect/Quant/IR/TypeParser.cpp @@ -30,7 +30,7 @@ static IntegerType parseStorageType(DialectAsmParser &parser, bool &isSigned) { StringRef identifier; unsigned storageTypeWidth = 0; OptionalParseResult result = parser.parseOptionalType(type); - if (result.hasValue()) { + if (result.has_value()) { if (!succeeded(*result)) return nullptr; isSigned = !type.isUnsigned(); diff --git a/mlir/lib/Dialect/SCF/IR/SCF.cpp b/mlir/lib/Dialect/SCF/IR/SCF.cpp index 92e798f15f76..1f59b2be39bf 100644 --- a/mlir/lib/Dialect/SCF/IR/SCF.cpp +++ b/mlir/lib/Dialect/SCF/IR/SCF.cpp @@ -2613,7 +2613,7 @@ ParseResult scf::WhileOp::parse(OpAsmParser &parser, OperationState &result) { OptionalParseResult listResult = parser.parseOptionalAssignmentList(regionArgs, operands); - if (listResult.hasValue() && failed(listResult.getValue())) + if (listResult.has_value() && failed(listResult.getValue())) return failure(); FunctionType functionType; diff --git a/mlir/lib/Dialect/SPIRV/IR/SPIRVAttributes.cpp b/mlir/lib/Dialect/SPIRV/IR/SPIRVAttributes.cpp index 90025e97c4e3..add1ebff925e 100644 --- a/mlir/lib/Dialect/SPIRV/IR/SPIRVAttributes.cpp +++ b/mlir/lib/Dialect/SPIRV/IR/SPIRVAttributes.cpp @@ -387,7 +387,7 @@ static Attribute parseInterfaceVarABIAttr(DialectAsmParser &parser) { uint32_t descriptorSet = 0; auto descriptorSetParseResult = parser.parseOptionalInteger(descriptorSet); - if (!descriptorSetParseResult.hasValue() || + if (!descriptorSetParseResult.has_value() || failed(*descriptorSetParseResult)) { parser.emitError(loc, "missing descriptor set"); return {}; @@ -404,7 +404,7 @@ static Attribute parseInterfaceVarABIAttr(DialectAsmParser &parser) { uint32_t binding = 0; auto bindingParseResult = parser.parseOptionalInteger(binding); - if (!bindingParseResult.hasValue() || failed(*bindingParseResult)) { + if (!bindingParseResult.has_value() || failed(*bindingParseResult)) { parser.emitError(loc, "missing binding"); return {}; } @@ -580,7 +580,7 @@ Attribute SPIRVDialect::parseAttribute(DialectAsmParser &parser, Attribute attr; OptionalParseResult result = generatedAttributeParser(parser, &attrKind, type, attr); - if (result.hasValue()) + if (result.has_value()) return attr; if (attrKind == spirv::TargetEnvAttr::getKindName()) diff --git a/mlir/lib/Dialect/SPIRV/IR/SPIRVDialect.cpp b/mlir/lib/Dialect/SPIRV/IR/SPIRVDialect.cpp index 8621281ea017..88bae6bb4326 100644 --- a/mlir/lib/Dialect/SPIRV/IR/SPIRVDialect.cpp +++ b/mlir/lib/Dialect/SPIRV/IR/SPIRVDialect.cpp @@ -573,7 +573,7 @@ static ParseResult parseStructMemberDecorations( SMLoc offsetLoc = parser.getCurrentLocation(); StructType::OffsetInfo offset = 0; OptionalParseResult offsetParseResult = parser.parseOptionalInteger(offset); - if (offsetParseResult.hasValue()) { + if (offsetParseResult.has_value()) { if (failed(*offsetParseResult)) return failure(); @@ -590,7 +590,7 @@ static ParseResult parseStructMemberDecorations( return success(); // If there was an offset, make sure to parse the comma. - if (offsetParseResult.hasValue() && parser.parseComma()) + if (offsetParseResult.has_value() && parser.parseComma()) return failure(); // Check for spirv::Decorations. diff --git a/mlir/lib/Dialect/SPIRV/IR/SPIRVOps.cpp b/mlir/lib/Dialect/SPIRV/IR/SPIRVOps.cpp index dae92ddaf821..5cb451fa46c1 100644 --- a/mlir/lib/Dialect/SPIRV/IR/SPIRVOps.cpp +++ b/mlir/lib/Dialect/SPIRV/IR/SPIRVOps.cpp @@ -2236,7 +2236,7 @@ ParseResult spirv::FuncOp::parse(OpAsmParser &parser, OperationState &state) { // Parse the optional function body. auto *body = state.addRegion(); OptionalParseResult result = parser.parseOptionalRegion(*body, entryArgs); - return failure(result.hasValue() && failed(*result)); + return failure(result.has_value() && failed(*result)); } void spirv::FuncOp::print(OpAsmPrinter &printer) { diff --git a/mlir/lib/IR/FunctionImplementation.cpp b/mlir/lib/IR/FunctionImplementation.cpp index a9160a9bc2e2..7a04a7d5cc78 100644 --- a/mlir/lib/IR/FunctionImplementation.cpp +++ b/mlir/lib/IR/FunctionImplementation.cpp @@ -41,7 +41,7 @@ parseFunctionArgumentList(OpAsmParser &parser, bool allowVariadic, OpAsmParser::Argument argument; auto argPresent = parser.parseOptionalArgument( argument, /*allowType=*/true, /*allowAttrs=*/true); - if (argPresent.hasValue()) { + if (argPresent.has_value()) { if (failed(argPresent.getValue())) return failure(); // Present but malformed. @@ -229,7 +229,7 @@ ParseResult mlir::function_interface_impl::parseFunctionOp( OptionalParseResult parseResult = parser.parseOptionalRegion(*body, entryArgs, /*enableNameShadowing=*/false); - if (parseResult.hasValue()) { + if (parseResult.has_value()) { if (failed(*parseResult)) return failure(); // Function body was parsed, make sure its not empty. diff --git a/mlir/lib/Interfaces/ViewLikeInterface.cpp b/mlir/lib/Interfaces/ViewLikeInterface.cpp index 2d9cce6690b9..eb542a921e12 100644 --- a/mlir/lib/Interfaces/ViewLikeInterface.cpp +++ b/mlir/lib/Interfaces/ViewLikeInterface.cpp @@ -121,7 +121,7 @@ static ParseResult parseOperandsOrIntegersImpl( while (true) { OpAsmParser::UnresolvedOperand operand; auto res = parser.parseOptionalOperand(operand); - if (res.hasValue() && succeeded(res.getValue())) { + if (res.has_value() && succeeded(res.getValue())) { values.push_back(operand); attrVals.push_back(dynVal); } else { diff --git a/mlir/test/lib/Dialect/Test/TestTypeDefs.td b/mlir/test/lib/Dialect/Test/TestTypeDefs.td index 6e5834832e1c..595809474ed1 100644 --- a/mlir/test/lib/Dialect/Test/TestTypeDefs.td +++ b/mlir/test/lib/Dialect/Test/TestTypeDefs.td @@ -292,9 +292,9 @@ class DefaultValuedAPFloat let parser = [{ [&]() -> mlir::FailureOr> { mlir::FloatAttr attr; auto result = $_parser.parseOptionalAttribute(attr); - if (result.hasValue() && mlir::succeeded(*result)) + if (result.has_value() && mlir::succeeded(*result)) return {attr.getValue()}; - if (!result.hasValue()) + if (!result.has_value()) return llvm::Optional(); return mlir::failure(); }() }]; diff --git a/mlir/test/lib/Dialect/Test/TestTypes.cpp b/mlir/test/lib/Dialect/Test/TestTypes.cpp index df5605529438..f54591d62708 100644 --- a/mlir/test/lib/Dialect/Test/TestTypes.cpp +++ b/mlir/test/lib/Dialect/Test/TestTypes.cpp @@ -411,14 +411,14 @@ Type TestDialect::parseTestType(AsmParser &parser, { Type genType; auto parseResult = generatedTypeParser(parser, &typeTag, genType); - if (parseResult.hasValue()) + if (parseResult.has_value()) return genType; } { Type dynType; auto parseResult = parseOptionalDynamicType(typeTag, parser, dynType); - if (parseResult.hasValue()) { + if (parseResult.has_value()) { if (succeeded(parseResult.getValue())) return dynType; return Type(); diff --git a/mlir/test/lib/Dialect/Test/TestTypes.h b/mlir/test/lib/Dialect/Test/TestTypes.h index 2ccf6ddf5f8f..f3cee5236559 100644 --- a/mlir/test/lib/Dialect/Test/TestTypes.h +++ b/mlir/test/lib/Dialect/Test/TestTypes.h @@ -78,7 +78,7 @@ struct FieldParser> { Optional value; value.emplace(); OptionalParseResult result = parser.parseOptionalInteger(*value); - if (result.hasValue()) { + if (result.has_value()) { if (succeeded(*result)) return value; return failure(); diff --git a/mlir/test/lib/Dialect/Transform/TestTransformDialectExtension.cpp b/mlir/test/lib/Dialect/Transform/TestTransformDialectExtension.cpp index e7ad8afa8592..64ae2a114205 100644 --- a/mlir/test/lib/Dialect/Transform/TestTransformDialectExtension.cpp +++ b/mlir/test/lib/Dialect/Transform/TestTransformDialectExtension.cpp @@ -52,7 +52,7 @@ public: static ParseResult parse(OpAsmParser &parser, OperationState &state) { StringAttr message; OptionalParseResult result = parser.parseOptionalAttribute(message); - if (!result.hasValue()) + if (!result.has_value()) return success(); if (result.getValue().succeeded()) diff --git a/mlir/test/mlir-tblgen/default-type-attr-print-parser.td b/mlir/test/mlir-tblgen/default-type-attr-print-parser.td index 1c479f11abbf..c0eedb879bcd 100644 --- a/mlir/test/mlir-tblgen/default-type-attr-print-parser.td +++ b/mlir/test/mlir-tblgen/default-type-attr-print-parser.td @@ -30,7 +30,7 @@ def AttrA : TestAttr<"AttrA"> { // ATTR: { // ATTR: ::mlir::Attribute attr; // ATTR: auto parseResult = generatedAttributeParser(parser, &attrTag, type, attr); -// ATTR: if (parseResult.hasValue()) +// ATTR: if (parseResult.has_value()) // ATTR: return attr; // ATTR: } // ATTR: parser.emitError(typeLoc) << "unknown attribute `" @@ -57,7 +57,7 @@ def TypeA : TestType<"TypeA"> { // TYPE: ::llvm::StringRef mnemonic; // TYPE: ::mlir::Type genType; // TYPE: auto parseResult = generatedTypeParser(parser, &mnemonic, genType); -// TYPE: if (parseResult.hasValue()) +// TYPE: if (parseResult.has_value()) // TYPE: return genType; // TYPE: parser.emitError(typeLoc) << "unknown type `" // TYPE: << mnemonic << "` in dialect `" << getNamespace() << "`"; diff --git a/mlir/tools/mlir-tblgen/AttrOrTypeDefGen.cpp b/mlir/tools/mlir-tblgen/AttrOrTypeDefGen.cpp index 05f73c49bd9f..19c35cbebbbb 100644 --- a/mlir/tools/mlir-tblgen/AttrOrTypeDefGen.cpp +++ b/mlir/tools/mlir-tblgen/AttrOrTypeDefGen.cpp @@ -660,7 +660,7 @@ static const char *const dialectDefaultAttrPrinterParserDispatch = R"( {{ ::mlir::Attribute attr; auto parseResult = generatedAttributeParser(parser, &attrTag, type, attr); - if (parseResult.hasValue()) + if (parseResult.has_value()) return attr; } {1} @@ -682,7 +682,7 @@ static const char *const dialectDynamicAttrParserDispatch = R"( { ::mlir::Attribute genAttr; auto parseResult = parseOptionalDynamicAttr(attrTag, parser, genAttr); - if (parseResult.hasValue()) { + if (parseResult.has_value()) { if (::mlir::succeeded(parseResult.getValue())) return genAttr; return Attribute(); @@ -707,7 +707,7 @@ static const char *const dialectDefaultTypePrinterParserDispatch = R"( ::llvm::StringRef mnemonic; ::mlir::Type genType; auto parseResult = generatedTypeParser(parser, &mnemonic, genType); - if (parseResult.hasValue()) + if (parseResult.has_value()) return genType; {1} parser.emitError(typeLoc) << "unknown type `" diff --git a/mlir/tools/mlir-tblgen/OpFormatGen.cpp b/mlir/tools/mlir-tblgen/OpFormatGen.cpp index c3b9ded76e8b..f52d14d236be 100644 --- a/mlir/tools/mlir-tblgen/OpFormatGen.cpp +++ b/mlir/tools/mlir-tblgen/OpFormatGen.cpp @@ -408,7 +408,7 @@ const char *const optionalAttrParserCode = R"( { ::mlir::OptionalParseResult parseResult = parser.parseOptionalAttribute({0}Attr, {1}, "{0}", result.attributes); - if (parseResult.hasValue() && failed(*parseResult)) + if (parseResult.has_value() && failed(*parseResult)) return ::mlir::failure(); } )"; @@ -445,7 +445,7 @@ const char *const enumAttrParserCode = R"( parser.parseOptionalAttribute(attrVal, parser.getBuilder().getNoneType(), "{0}", attrStorage); - if (parseResult.hasValue()) {{ + if (parseResult.has_value()) {{ if (failed(*parseResult)) return ::mlir::failure(); attrStr = attrVal.getValue(); @@ -479,7 +479,7 @@ const char *const optionalOperandParserCode = R"( ::mlir::OpAsmParser::UnresolvedOperand operand; ::mlir::OptionalParseResult parseResult = parser.parseOptionalOperand(operand); - if (parseResult.hasValue()) { + if (parseResult.has_value()) { if (failed(*parseResult)) return ::mlir::failure(); {0}Operands.push_back(operand); @@ -532,7 +532,7 @@ const char *const optionalTypeParserCode = R"( ::mlir::Type optionalType; ::mlir::OptionalParseResult parseResult = parser.parseOptionalType(optionalType); - if (parseResult.hasValue()) { + if (parseResult.has_value()) { if (failed(*parseResult)) return ::mlir::failure(); {0}Types.push_back(optionalType); @@ -584,7 +584,7 @@ const char *regionListParserCode = R"( { std::unique_ptr<::mlir::Region> region; auto firstRegionResult = parser.parseOptionalRegion(region); - if (firstRegionResult.hasValue()) { + if (firstRegionResult.has_value()) { if (failed(*firstRegionResult)) return ::mlir::failure(); {0}Regions.emplace_back(std::move(region)); @@ -622,7 +622,7 @@ const char *regionListEnsureSingleBlockParserCode = R"( const char *optionalRegionParserCode = R"( { auto parseResult = parser.parseOptionalRegion(*{0}Region); - if (parseResult.hasValue() && failed(*parseResult)) + if (parseResult.has_value() && failed(*parseResult)) return ::mlir::failure(); } )"; @@ -656,7 +656,7 @@ const char *successorListParserCode = R"( { ::mlir::Block *succ; auto firstSucc = parser.parseOptionalSuccessor(succ); - if (firstSucc.hasValue()) { + if (firstSucc.has_value()) { if (failed(*firstSucc)) return ::mlir::failure(); {0}Successors.emplace_back(succ); diff --git a/mlir/unittests/IR/AttributeTest.cpp b/mlir/unittests/IR/AttributeTest.cpp index 8250afd3cb97..1a3342b1c6dc 100644 --- a/mlir/unittests/IR/AttributeTest.cpp +++ b/mlir/unittests/IR/AttributeTest.cpp @@ -224,7 +224,7 @@ static void checkNativeAccess(MLIRContext *ctx, ArrayRef data, // Check that we can access and iterate the data properly. Optional> attrData = attr.tryGetAsArrayRef(); - EXPECT_TRUE(attrData.hasValue()); + EXPECT_TRUE(attrData.has_value()); EXPECT_EQ(*attrData, data); // Check that we cast to this attribute when possible.