[Mlir-commits] [mlir] 3e83426 - Fix TableGen emitter: hasValue() has been renamed has_value()

Mehdi Amini llvmlistbot at llvm.org
Thu Jun 1 21:36:51 PDT 2023


Author: Mehdi Amini
Date: 2023-06-01T21:36:34-07:00
New Revision: 3e83426c2fbe761e54978afdee8a1bfa83fa3d2b

URL: https://github.com/llvm/llvm-project/commit/3e83426c2fbe761e54978afdee8a1bfa83fa3d2b
DIFF: https://github.com/llvm/llvm-project/commit/3e83426c2fbe761e54978afdee8a1bfa83fa3d2b.diff

LOG: 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

Added: 
    

Modified: 
    mlir/test/mlir-tblgen/attr-or-type-format.td
    mlir/tools/mlir-tblgen/AttrOrTypeDefGen.cpp

Removed: 
    


################################################################################
diff  --git a/mlir/test/mlir-tblgen/attr-or-type-format.td b/mlir/test/mlir-tblgen/attr-or-type-format.td
index 9017a639f268c..230fa90713f1a 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<string name> : AttrDef<Test_Dialect, name>;
@@ -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 09285127f128a..a23975f96cb32 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();


        


More information about the Mlir-commits mailing list