diff --git a/mlir/test/mlir-tblgen/op-format.td b/mlir/test/mlir-tblgen/op-format.td --- a/mlir/test/mlir-tblgen/op-format.td +++ b/mlir/test/mlir-tblgen/op-format.td @@ -20,7 +20,7 @@ // CHECK-LABEL: CustomStringLiteralA::parse // CHECK: parseFoo({{.*}}, parser.getBuilder().getI1Type()) // CHECK-LABEL: CustomStringLiteralA::print -// CHECK: printFoo({{.*}}, parser.getBuilder().getI1Type()) +// CHECK: printFoo({{.*}}, ::mlir::Builder(getContext()).getI1Type()) def CustomStringLiteralA : TestFormat_Op<[{ custom("$_builder.getI1Type()") attr-dict }]>; @@ -28,7 +28,7 @@ // CHECK-LABEL: CustomStringLiteralB::parse // CHECK: parseFoo({{.*}}, IndexType::get(parser.getContext())) // CHECK-LABEL: CustomStringLiteralB::print -// CHECK: printFoo({{.*}}, IndexType::get(parser.getContext())) +// CHECK: printFoo({{.*}}, IndexType::get(getContext())) def CustomStringLiteralB : TestFormat_Op<[{ custom("IndexType::get($_ctxt)") attr-dict }]>; @@ -36,7 +36,7 @@ // CHECK-LABEL: CustomStringLiteralC::parse // CHECK: parseFoo({{.*}}, parser.getBuilder().getStringAttr("foo")) // CHECK-LABEL: CustomStringLiteralC::print -// CHECK: printFoo({{.*}}, parser.getBuilder().getStringAttr("foo")) +// CHECK: printFoo({{.*}}, ::mlir::Builder(getContext()).getStringAttr("foo")) def CustomStringLiteralC : TestFormat_Op<[{ custom("$_builder.getStringAttr(\"foo\")") attr-dict }]>; diff --git a/mlir/tools/mlir-tblgen/OpFormatGen.cpp b/mlir/tools/mlir-tblgen/OpFormatGen.cpp --- a/mlir/tools/mlir-tblgen/OpFormatGen.cpp +++ b/mlir/tools/mlir-tblgen/OpFormatGen.cpp @@ -1724,8 +1724,8 @@ } else if (auto *string = dyn_cast(element)) { FmtContext ctx; - ctx.withBuilder("parser.getBuilder()"); - ctx.addSubst("_ctxt", "parser.getContext()"); + ctx.withBuilder("::mlir::Builder(getContext())"); + ctx.addSubst("_ctxt", "getContext()"); body << tgfmt(string->getValue(), &ctx); } else {