Skip to content

Commit f6f10aa

Browse files
joker-ephmemfrob
authored andcommitted
Fix memory leaks in mlir/unittests/MLIRTableGenTests
Trying to get MLIR ASAN-clean.
1 parent ce37b93 commit f6f10aa

File tree

1 file changed

+40
-40
lines changed

1 file changed

+40
-40
lines changed

mlir/unittests/TableGen/OpBuildGen.cpp

Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -73,21 +73,21 @@ class OpBuildGenTest : public ::testing::Test {
7373
template <typename OpTy>
7474
void testSingleVariadicInputInferredType() {
7575
// Test separate arg, separate param build method.
76-
auto op = builder.create<OpTy>(loc, i32Ty, ValueRange{cstI32, cstI32});
77-
verifyOp(std::move(op), {i32Ty}, {cstI32, cstI32}, noAttrs);
76+
auto op = builder.create<OpTy>(loc, i32Ty, ValueRange{*cstI32, *cstI32});
77+
verifyOp(std::move(op), {i32Ty}, {*cstI32, *cstI32}, noAttrs);
7878

7979
// Test collective params build method.
8080
op =
81-
builder.create<OpTy>(loc, TypeRange{i32Ty}, ValueRange{cstI32, cstI32});
82-
verifyOp(std::move(op), {i32Ty}, {cstI32, cstI32}, noAttrs);
81+
builder.create<OpTy>(loc, TypeRange{i32Ty}, ValueRange{*cstI32, *cstI32});
82+
verifyOp(std::move(op), {i32Ty}, {*cstI32, *cstI32}, noAttrs);
8383

8484
// Test build method with no result types, default value of attributes.
85-
op = builder.create<OpTy>(loc, ValueRange{cstI32, cstI32});
86-
verifyOp(std::move(op), {i32Ty}, {cstI32, cstI32}, noAttrs);
85+
op = builder.create<OpTy>(loc, ValueRange{*cstI32, *cstI32});
86+
verifyOp(std::move(op), {i32Ty}, {*cstI32, *cstI32}, noAttrs);
8787

8888
// Test build method with no result types and supplied attributes.
89-
op = builder.create<OpTy>(loc, ValueRange{cstI32, cstI32}, attrs);
90-
verifyOp(std::move(op), {i32Ty}, {cstI32, cstI32}, attrs);
89+
op = builder.create<OpTy>(loc, ValueRange{*cstI32, *cstI32}, attrs);
90+
verifyOp(std::move(op), {i32Ty}, {*cstI32, *cstI32}, attrs);
9191
}
9292

9393
protected:
@@ -96,8 +96,8 @@ class OpBuildGenTest : public ::testing::Test {
9696
Location loc;
9797
Type i32Ty;
9898
Type f32Ty;
99-
test::TableGenConstant cstI32;
100-
test::TableGenConstant cstF32;
99+
OwningOpRef<test::TableGenConstant> cstI32;
100+
OwningOpRef<test::TableGenConstant> cstF32;
101101

102102
ArrayRef<NamedAttribute> noAttrs;
103103
std::vector<NamedAttribute> attrStorage;
@@ -107,22 +107,22 @@ class OpBuildGenTest : public ::testing::Test {
107107
/// Test basic build methods.
108108
TEST_F(OpBuildGenTest, BasicBuildMethods) {
109109
// Test separate args, separate results build method.
110-
auto op = builder.create<test::TableGenBuildOp0>(loc, i32Ty, cstI32);
111-
verifyOp(op, {i32Ty}, {cstI32}, noAttrs);
110+
auto op = builder.create<test::TableGenBuildOp0>(loc, i32Ty, *cstI32);
111+
verifyOp(op, {i32Ty}, {*cstI32}, noAttrs);
112112

113113
// Test separate args, collective results build method.
114-
op = builder.create<test::TableGenBuildOp0>(loc, TypeRange{i32Ty}, cstI32);
115-
verifyOp(op, {i32Ty}, {cstI32}, noAttrs);
114+
op = builder.create<test::TableGenBuildOp0>(loc, TypeRange{i32Ty}, *cstI32);
115+
verifyOp(op, {i32Ty}, {*cstI32}, noAttrs);
116116

117117
// Test collective args, collective params build method.
118118
op = builder.create<test::TableGenBuildOp0>(loc, TypeRange{i32Ty},
119-
ValueRange{cstI32});
120-
verifyOp(op, {i32Ty}, {cstI32}, noAttrs);
119+
ValueRange{*cstI32});
120+
verifyOp(op, {i32Ty}, {*cstI32}, noAttrs);
121121

122122
// Test collective args, collective results, non-empty attributes
123123
op = builder.create<test::TableGenBuildOp0>(loc, TypeRange{i32Ty},
124-
ValueRange{cstI32}, attrs);
125-
verifyOp(op, {i32Ty}, {cstI32}, attrs);
124+
ValueRange{*cstI32}, attrs);
125+
verifyOp(op, {i32Ty}, {*cstI32}, attrs);
126126
}
127127

128128
/// The following 3 tests exercise build methods generated for operations
@@ -139,49 +139,49 @@ TEST_F(OpBuildGenTest, BasicBuildMethods) {
139139
TEST_F(OpBuildGenTest, BuildMethodsSingleVariadicArgAndResult) {
140140
// Test collective args, collective results method, building a unary op.
141141
auto op = builder.create<test::TableGenBuildOp1>(loc, TypeRange{i32Ty},
142-
ValueRange{cstI32});
143-
verifyOp(std::move(op), {i32Ty}, {cstI32}, noAttrs);
142+
ValueRange{*cstI32});
143+
verifyOp(std::move(op), {i32Ty}, {*cstI32}, noAttrs);
144144

145145
// Test collective args, collective results method, building a unary op with
146146
// named attributes.
147147
op = builder.create<test::TableGenBuildOp1>(loc, TypeRange{i32Ty},
148-
ValueRange{cstI32}, attrs);
149-
verifyOp(std::move(op), {i32Ty}, {cstI32}, attrs);
148+
ValueRange{*cstI32}, attrs);
149+
verifyOp(std::move(op), {i32Ty}, {*cstI32}, attrs);
150150

151151
// Test collective args, collective results method, building a binary op.
152152
op = builder.create<test::TableGenBuildOp1>(loc, TypeRange{i32Ty, f32Ty},
153-
ValueRange{cstI32, cstF32});
154-
verifyOp(std::move(op), {i32Ty, f32Ty}, {cstI32, cstF32}, noAttrs);
153+
ValueRange{*cstI32, *cstF32});
154+
verifyOp(std::move(op), {i32Ty, f32Ty}, {*cstI32, *cstF32}, noAttrs);
155155

156156
// Test collective args, collective results method, building a binary op with
157157
// named attributes.
158158
op = builder.create<test::TableGenBuildOp1>(
159-
loc, TypeRange{i32Ty, f32Ty}, ValueRange{cstI32, cstF32}, attrs);
160-
verifyOp(std::move(op), {i32Ty, f32Ty}, {cstI32, cstF32}, attrs);
159+
loc, TypeRange{i32Ty, f32Ty}, ValueRange{*cstI32, *cstF32}, attrs);
160+
verifyOp(std::move(op), {i32Ty, f32Ty}, {*cstI32, *cstF32}, attrs);
161161
}
162162

163163
/// Test build methods for an Op with a single varadic arg and a non-variadic
164164
/// result.
165165
TEST_F(OpBuildGenTest, BuildMethodsSingleVariadicArgNonVariadicResults) {
166166
// Test separate arg, separate param build method.
167167
auto op =
168-
builder.create<test::TableGenBuildOp1>(loc, i32Ty, ValueRange{cstI32});
169-
verifyOp(std::move(op), {i32Ty}, {cstI32}, noAttrs);
168+
builder.create<test::TableGenBuildOp1>(loc, i32Ty, ValueRange{*cstI32});
169+
verifyOp(std::move(op), {i32Ty}, {*cstI32}, noAttrs);
170170

171171
// Test collective params build method, no attributes.
172172
op = builder.create<test::TableGenBuildOp1>(loc, TypeRange{i32Ty},
173-
ValueRange{cstI32});
174-
verifyOp(std::move(op), {i32Ty}, {cstI32}, noAttrs);
173+
ValueRange{*cstI32});
174+
verifyOp(std::move(op), {i32Ty}, {*cstI32}, noAttrs);
175175

176176
// Test collective params build method no attributes, 2 inputs.
177177
op = builder.create<test::TableGenBuildOp1>(loc, TypeRange{i32Ty},
178-
ValueRange{cstI32, cstF32});
179-
verifyOp(std::move(op), {i32Ty}, {cstI32, cstF32}, noAttrs);
178+
ValueRange{*cstI32, *cstF32});
179+
verifyOp(std::move(op), {i32Ty}, {*cstI32, *cstF32}, noAttrs);
180180

181181
// Test collective params build method, non-empty attributes.
182182
op = builder.create<test::TableGenBuildOp1>(
183-
loc, TypeRange{i32Ty}, ValueRange{cstI32, cstF32}, attrs);
184-
verifyOp(std::move(op), {i32Ty}, {cstI32, cstF32}, attrs);
183+
loc, TypeRange{i32Ty}, ValueRange{*cstI32, *cstF32}, attrs);
184+
verifyOp(std::move(op), {i32Ty}, {*cstI32, *cstF32}, attrs);
185185
}
186186

187187
/// Test build methods for an Op with a single varadic arg and multiple variadic
@@ -190,18 +190,18 @@ TEST_F(OpBuildGenTest,
190190
BuildMethodsSingleVariadicArgAndMultipleVariadicResults) {
191191
// Test separate arg, separate param build method.
192192
auto op = builder.create<test::TableGenBuildOp3>(
193-
loc, TypeRange{i32Ty}, TypeRange{f32Ty}, ValueRange{cstI32});
194-
verifyOp(std::move(op), {i32Ty, f32Ty}, {cstI32}, noAttrs);
193+
loc, TypeRange{i32Ty}, TypeRange{f32Ty}, ValueRange{*cstI32});
194+
verifyOp(std::move(op), {i32Ty, f32Ty}, {*cstI32}, noAttrs);
195195

196196
// Test collective params build method, no attributes.
197197
op = builder.create<test::TableGenBuildOp3>(loc, TypeRange{i32Ty, f32Ty},
198-
ValueRange{cstI32});
199-
verifyOp(std::move(op), {i32Ty, f32Ty}, {cstI32}, noAttrs);
198+
ValueRange{*cstI32});
199+
verifyOp(std::move(op), {i32Ty, f32Ty}, {*cstI32}, noAttrs);
200200

201201
// Test collective params build method, with attributes.
202202
op = builder.create<test::TableGenBuildOp3>(loc, TypeRange{i32Ty, f32Ty},
203-
ValueRange{cstI32}, attrs);
204-
verifyOp(std::move(op), {i32Ty, f32Ty}, {cstI32}, attrs);
203+
ValueRange{*cstI32}, attrs);
204+
verifyOp(std::move(op), {i32Ty, f32Ty}, {*cstI32}, attrs);
205205
}
206206

207207
// The next 2 tests test supression of ambiguous build methods for ops that

0 commit comments

Comments
 (0)