From c1fa8179d4e5300a67ebdf41916a18f9c6330121 Mon Sep 17 00:00:00 2001 From: Adrian Kuegel Date: Tue, 31 Jan 2023 08:08:44 +0100 Subject: [PATCH] [mlir] Adjust AttributeTest to show skip behavior. walk() skips identical sub-attributes. Adjust the unit test to show this. Differential Revision: https://reviews.llvm.org/D142956 --- mlir/unittests/IR/AttributeTest.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/mlir/unittests/IR/AttributeTest.cpp b/mlir/unittests/IR/AttributeTest.cpp index 7c0572e..94345d00 100644 --- a/mlir/unittests/IR/AttributeTest.cpp +++ b/mlir/unittests/IR/AttributeTest.cpp @@ -432,13 +432,15 @@ TEST(SubElementTest, Nested) { BoolAttr trueAttr = builder.getBoolAttr(true); BoolAttr falseAttr = builder.getBoolAttr(false); - ArrayAttr boolArrayAttr = builder.getArrayAttr({trueAttr, falseAttr}); + ArrayAttr boolArrayAttr = + builder.getArrayAttr({trueAttr, falseAttr, trueAttr}); StringAttr strAttr = builder.getStringAttr("array"); DictionaryAttr dictAttr = builder.getDictionaryAttr(builder.getNamedAttr(strAttr, boolArrayAttr)); SmallVector subAttrs; dictAttr.walk([&](Attribute attr) { subAttrs.push_back(attr); }); + // Note that trueAttr appears only once, identical subattributes are skipped. EXPECT_EQ(llvm::ArrayRef(subAttrs), ArrayRef( {strAttr, trueAttr, falseAttr, boolArrayAttr, dictAttr})); -- 2.7.4