From: Mehdi Amini Date: Fri, 2 Jun 2023 03:54:32 +0000 (-0700) Subject: Fix TableGen emitter: hasValue() has been renamed has_value() X-Git-Tag: upstream/17.0.6~6401 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=3e83426c2fbe761e54978afdee8a1bfa83fa3d2b;p=platform%2Fupstream%2Fllvm.git Fix TableGen emitter: hasValue() has been renamed has_value() This codepath isn't exercised in-tree right now unfortunately, this only happens when a dialect does not use the default entry points for types parsing AND is extensible: both of these aren't the default settings and the combination of them isn't common. Fix #63058 --- diff --git a/mlir/test/mlir-tblgen/attr-or-type-format.td b/mlir/test/mlir-tblgen/attr-or-type-format.td index 9017a639..230fa90 100644 --- a/mlir/test/mlir-tblgen/attr-or-type-format.td +++ b/mlir/test/mlir-tblgen/attr-or-type-format.td @@ -1,5 +1,6 @@ -// RUN: mlir-tblgen -gen-attrdef-defs -I %S/../../include %s | FileCheck %s --check-prefix=ATTR -// RUN: mlir-tblgen -gen-typedef-defs -I %S/../../include %s | FileCheck %s --check-prefix=TYPE +// RUN: sed 's/DEFAULT_TYPE_PARSER/0/' %s | mlir-tblgen -gen-attrdef-defs -I %S/../../include | FileCheck %s --check-prefix=ATTR +// RUN: sed 's/DEFAULT_TYPE_PARSER/0/' %s | mlir-tblgen -gen-typedef-defs -I %S/../../include | FileCheck %s --check-prefix=TYPE +// RUN: sed 's/DEFAULT_TYPE_PARSER/1/' %s | mlir-tblgen -gen-typedef-defs -I %S/../../include | FileCheck %s --check-prefix=TYPE --check-prefix=DEFAULT_TYPE_PARSER include "mlir/IR/AttrTypeBase.td" include "mlir/IR/EnumAttr.td" @@ -9,7 +10,8 @@ include "mlir/IR/OpBase.td" def Test_Dialect : Dialect { let name = "TestDialect"; let cppNamespace = "::test"; - let useDefaultTypePrinterParser = 0; + let useDefaultTypePrinterParser = DEFAULT_TYPE_PARSER; + let isExtensible = 1; } class TestAttr : AttrDef; @@ -642,3 +644,9 @@ def TypeN : TestType<"TestP"> { let mnemonic = "type_n"; let assemblyFormat = "`<` (`?`) : (struct($a, $b)^)? `>`"; } + +// DEFAULT_TYPE_PARSER: TestDialect::parseType(::mlir::DialectAsmParser &parser) +// DEFAULT_TYPE_PARSER: auto parseResult = parseOptionalDynamicType(mnemonic, parser, genType); +// DEFAULT_TYPE_PARSER: if (parseResult.has_value()) { +// DEFAULT_TYPE_PARSER: if (::mlir::succeeded(parseResult.getValue())) +// DEFAULT_TYPE_PARSER: return genType; \ No newline at end of file diff --git a/mlir/tools/mlir-tblgen/AttrOrTypeDefGen.cpp b/mlir/tools/mlir-tblgen/AttrOrTypeDefGen.cpp index 0928512..a23975f 100644 --- a/mlir/tools/mlir-tblgen/AttrOrTypeDefGen.cpp +++ b/mlir/tools/mlir-tblgen/AttrOrTypeDefGen.cpp @@ -734,7 +734,7 @@ void {0}::printType(::mlir::Type type, static const char *const dialectDynamicTypeParserDispatch = R"( { auto parseResult = parseOptionalDynamicType(mnemonic, parser, genType); - if (parseResult.hasValue()) { + if (parseResult.has_value()) { if (::mlir::succeeded(parseResult.getValue())) return genType; return Type();