From 3e83426c2fbe761e54978afdee8a1bfa83fa3d2b Mon Sep 17 00:00:00 2001 From: Mehdi Amini Date: Thu, 1 Jun 2023 20:54:32 -0700 Subject: [PATCH] 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 --- mlir/test/mlir-tblgen/attr-or-type-format.td | 14 +++++++++++--- mlir/tools/mlir-tblgen/AttrOrTypeDefGen.cpp | 2 +- 2 files changed, 12 insertions(+), 4 deletions(-) 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(); -- 2.7.4