[llvm-branch-commits] [mlir] cbda2cb - [mlir] Fully specify removeAttr return type

Tres Popp via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Tue Jan 5 15:57:22 PST 2021


Author: Tres Popp
Date: 2021-01-06T00:52:35+01:00
New Revision: cbda2cba4f8e4d236d56158cecfb008e03341a70

URL: https://github.com/llvm/llvm-project/commit/cbda2cba4f8e4d236d56158cecfb008e03341a70
DIFF: https://github.com/llvm/llvm-project/commit/cbda2cba4f8e4d236d56158cecfb008e03341a70.diff

LOG: [mlir] Fully specify removeAttr return type

This was added without full specification like other generated methods.
This then leads to other downstream dialects failing to compile the
generated code when they are not in the mlir namespace.

Differential Revision: https://reviews.llvm.org/D94132

Added: 
    

Modified: 
    mlir/test/mlir-tblgen/op-attribute.td
    mlir/test/mlir-tblgen/op-decl.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 b4c193c30c51..2f1d44016b62 100644
--- a/mlir/test/mlir-tblgen/op-attribute.td
+++ b/mlir/test/mlir-tblgen/op-attribute.td
@@ -80,7 +80,7 @@ def AOp : NS_Op<"a_op", []> {
 // Test remove methods
 // ---
 
-// DEF: Attribute AOp::removeCAttrAttr() {
+// DEF: ::mlir::Attribute AOp::removeCAttrAttr() {
 // DEF-NEXT: return (*this)->removeAttr("cAttr");
 
 // Test build methods
@@ -271,7 +271,7 @@ def UnitAttrOp : NS_Op<"unit_attr_op", []> {
 // DEF: bool UnitAttrOp::attr() {
 // DEF:   return {{.*}} != nullptr
 
-// DEF: Attribute UnitAttrOp::removeAttrAttr() {
+// DEF: ::mlir::Attribute UnitAttrOp::removeAttrAttr() {
 // DEF-NEXT:   (*this)->removeAttr("attr");
 
 // DEF: build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, /*optional*/::mlir::UnitAttr attr)
@@ -288,7 +288,7 @@ def SomeTypedArrayAttr : TypedArrayAttrBase<SomeAttr, "SomeAttr array">;
 def Test_Dialect_2 : Dialect {
   let name = "dialect_2";
 }
-def MyStruct : StructAttr<"MyStruct", Test_Dialect_2, 
+def MyStruct : StructAttr<"MyStruct", Test_Dialect_2,
 [StructFieldAttr<"potatoes", I64ElementsAttr>]> {
   let description = "A structure describing a number of potatoes.";
 }

diff  --git a/mlir/test/mlir-tblgen/op-decl.td b/mlir/test/mlir-tblgen/op-decl.td
index d4d1a8b012c6..3d4d46ceb42f 100644
--- a/mlir/test/mlir-tblgen/op-decl.td
+++ b/mlir/test/mlir-tblgen/op-decl.td
@@ -81,7 +81,7 @@ def NS_AOp : NS_Op<"a_op", [IsolatedFromAbove, IsolatedFromAbove]> {
 // CHECK:   uint32_t attr1();
 // CHECK:   ::mlir::FloatAttr attr2Attr()
 // CHECK:   ::llvm::Optional< ::llvm::APFloat > attr2();
-// CHECK:   Attribute removeAttr2Attr();
+// CHECK:   ::mlir::Attribute removeAttr2Attr();
 // CHECK:   static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, Value val);
 // CHECK:   static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, int integer = 0);
 // CHECK:   static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type r, ::mlir::TypeRange s, ::mlir::Value a, ::mlir::ValueRange b, ::mlir::IntegerAttr attr1, /*optional*/::mlir::FloatAttr attr2, unsigned someRegionsCount)

diff  --git a/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp b/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp
index 468fd7848d82..b1c86522c6b5 100644
--- a/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp
+++ b/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp
@@ -788,7 +788,7 @@ void OpEmitter::genOptionalAttrRemovers() {
     auto upperInitial = name.take_front().upper();
     auto suffix = name.drop_front();
     auto *method = opClass.addMethodAndPrune(
-        "Attribute", ("remove" + upperInitial + suffix + "Attr").str());
+        "::mlir::Attribute", ("remove" + upperInitial + suffix + "Attr").str());
     if (!method)
       return;
     auto &body = method->body();


        


More information about the llvm-branch-commits mailing list