[Mlir-commits] [mlir] c3c2585 - [mlir][bytecodegen] Don't emit empty case (NFC)

Jacques Pienaar llvmlistbot at llvm.org
Wed Jun 7 11:28:00 PDT 2023


Author: Jacques Pienaar
Date: 2023-06-07T11:15:06-07:00
New Revision: c3c2585bd5751e8776a187ed2cc0a37b6401f5af

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

LOG: [mlir][bytecodegen] Don't emit empty case (NFC)

Added: 
    

Modified: 
    mlir/tools/mlir-tblgen/BytecodeDialectGen.cpp

Removed: 
    


################################################################################
diff  --git a/mlir/tools/mlir-tblgen/BytecodeDialectGen.cpp b/mlir/tools/mlir-tblgen/BytecodeDialectGen.cpp
index d78bd5f44f214..919a1804eab2d 100644
--- a/mlir/tools/mlir-tblgen/BytecodeDialectGen.cpp
+++ b/mlir/tools/mlir-tblgen/BytecodeDialectGen.cpp
@@ -99,6 +99,12 @@ void Generator::emitParseDispatch(StringRef kind, ArrayRef<Record *> vec) {
   os << formatv(head, capitalize(kind));
   auto funScope = os.scope(" {\n", "}\n\n");
 
+  if (vec.empty()) {
+    os << "return reader.emitError() << \"unknown attribute\", "
+       << capitalize(kind) << "();\n";
+    return;
+  }
+
   os << "uint64_t kind;\n";
   os << "if (failed(reader.readVarInt(kind)))\n"
      << "  return " << capitalize(kind) << "();\n";


        


More information about the Mlir-commits mailing list