[Mlir-commits] [mlir] [mlir][OpFormatGen][NFC] Initialize C-style arrays upon creation (PR #85631)

Mehdi Amini llvmlistbot at llvm.org
Mon Mar 18 14:41:04 PDT 2024


================
@@ -842,7 +842,7 @@ static void genElementParserStorage(FormatElement *element, const Operator &op,
       }
     } else {
       body << "  ::mlir::OpAsmParser::UnresolvedOperand " << name
-           << "RawOperands[1];\n"
+           << "RawOperands[1] = {};\n"
            << "  ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> "
            << name << "Operands(" << name << "RawOperands);";
----------------
joker-eph wrote:

Seems to me that we could simplify it here:
```
     body << "  ::mlir::OpAsmParser::UnresolvedOperand " << name
            << "RawOperand;\n"
            << "  ::llvm::ArrayRef "
            << name << "Operands(&" << name << "RawOperand, 1);";
```

Something like this (I haven't tried compiling it)

https://github.com/llvm/llvm-project/pull/85631


More information about the Mlir-commits mailing list