include "mlir/IR/OpBase.td" def Test_Dialect : Dialect { let name = "test"; } class NS_Op<string mnemonic, list<OpTrait> traits> : Op<Test_Dialect, mnemonic, traits>; def EOp : NS_Op<"e_op", []> { let arguments = (ins AnyInteger: $any_integer, Optional<AnyInteger>: $optioanl_integer ); } def FOp : NS_Op<"f_op", []> { let arguments = (ins AnyInteger: $any_integer, Optional<AnyInteger>: $optioanl_integer ); } // CHECK: if (auto tmpOperand = (*arg0.begin())) { // CHECK: if (auto tmpOperand = (arg1.size() > 0? (*arg1.begin()): nullptr)) { def test5 : Pat<(EOp $arg0, $arg1), (FOp $arg0, $arg1)>;
Without the patch, tblgen would generate cpp code like
arg1 = castedOp0.getODSOperands(1); tblgen_values.push_back(arg1)
and cause compilation error. Here arg1 is type ValueRange and tblgen_values is type SmallVector.
clang-tidy: warning: do not use 'else' after 'return' [llvm-else-after-return]
not useful