[Mlir-commits] [mlir] 4418f0d - [mlir:ODS] Disambiguate getContext call for the rare case of the op having an input called context
Benjamin Kramer
llvmlistbot at llvm.org
Fri Oct 14 17:01:48 PDT 2022
Author: Benjamin Kramer
Date: 2022-10-15T02:01:18+02:00
New Revision: 4418f0db2dc9dad3fa570b8438e78ff09624bfda
URL: https://github.com/llvm/llvm-project/commit/4418f0db2dc9dad3fa570b8438e78ff09624bfda
DIFF: https://github.com/llvm/llvm-project/commit/4418f0db2dc9dad3fa570b8438e78ff09624bfda.diff
LOG: [mlir:ODS] Disambiguate getContext call for the rare case of the op having an input called context
Added:
Modified:
mlir/test/mlir-tblgen/op-attribute.td
mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp
Removed:
################################################################################
diff --git a/mlir/test/mlir-tblgen/op-attribute.td b/mlir/test/mlir-tblgen/op-attribute.td
index 7e7a76227f37..cf76ce0744ca 100644
--- a/mlir/test/mlir-tblgen/op-attribute.td
+++ b/mlir/test/mlir-tblgen/op-attribute.td
@@ -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
diff --git a/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp b/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp
index 5b3d0ad18eec..85326ecfd0c5 100644
--- a/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp
+++ b/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp
@@ -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();
More information about the Mlir-commits
mailing list