[mlir:ODS] Disambiguate getContext call for the rare case of the op having an input...
authorBenjamin Kramer <benny.kra@googlemail.com>
Fri, 14 Oct 2022 23:56:01 +0000 (01:56 +0200)
committerBenjamin Kramer <benny.kra@googlemail.com>
Sat, 15 Oct 2022 00:01:18 +0000 (02:01 +0200)
mlir/test/mlir-tblgen/op-attribute.td
mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp

index 7e7a762..cf76ce0 100644 (file)
@@ -128,16 +128,16 @@ def AOp : NS_Op<"a_op", []> {
 // DEF:      void AOp::setAAttrAttr(some-attr-kind attr) {
 // DEF-NEXT:   (*this)->setAttr(getAAttrAttrName(), attr);
 // DEF:      void AOp::setAAttr(some-return-type attrValue) {
-// DEF-NEXT:   (*this)->setAttr(getAAttrAttrName(), some-const-builder-call(::mlir::Builder(getContext()), attrValue));
+// DEF-NEXT:   (*this)->setAttr(getAAttrAttrName(), some-const-builder-call(::mlir::Builder((*this)->getContext()), attrValue));
 // DEF:      void AOp::setBAttrAttr(some-attr-kind attr) {
 // DEF-NEXT:   (*this)->setAttr(getBAttrAttrName(), attr);
 // DEF:      void AOp::setBAttr(some-return-type attrValue) {
-// DEF-NEXT:   (*this)->setAttr(getBAttrAttrName(), some-const-builder-call(::mlir::Builder(getContext()), attrValue));
+// DEF-NEXT:   (*this)->setAttr(getBAttrAttrName(), some-const-builder-call(::mlir::Builder((*this)->getContext()), attrValue));
 // DEF:      void AOp::setCAttrAttr(some-attr-kind attr) {
 // DEF-NEXT:   (*this)->setAttr(getCAttrAttrName(), attr);
 // DEF:      void AOp::setCAttr(::llvm::Optional<some-return-type> attrValue) {
 // DEF-NEXT:   if (attrValue)
-// DEF-NEXT:     return (*this)->setAttr(getCAttrAttrName(), some-const-builder-call(::mlir::Builder(getContext()), *attrValue));
+// DEF-NEXT:     return (*this)->setAttr(getCAttrAttrName(), some-const-builder-call(::mlir::Builder((*this)->getContext()), *attrValue));
 // DEF-NEXT:   (*this)->removeAttr(getCAttrAttrName());
 
 // Test remove methods
index 5b3d0ad..85326ec 100644 (file)
@@ -1116,7 +1116,7 @@ void OpEmitter::genAttrSetters() {
     if (!canUseUnwrappedRawValue(baseAttr))
       return;
     FmtContext fctx;
-    fctx.withBuilder("::mlir::Builder(getContext())");
+    fctx.withBuilder("::mlir::Builder((*this)->getContext())");
     bool isUnitAttr = attr.getAttrDefName() == "UnitAttr";
     bool isOptional = attr.isOptional();