Fix memory leaks in MLIR unit-tests (NFC)

This commit is contained in:
Mehdi Amini 2021-10-02 21:31:17 +00:00
parent 107198fe7d
commit 57d9adefa0
2 changed files with 5 additions and 2 deletions

View File

@ -189,6 +189,8 @@ void testParsePassPipeline() {
mlirPrintPassPipeline(mlirPassManagerGetAsOpPassManager(pm), printToStderr,
NULL);
fprintf(stderr, "\n");
mlirPassManagerDestroy(pm);
mlirContextDestroy(ctx);
}
int main() {

View File

@ -6,6 +6,7 @@
//
//===----------------------------------------------------------------------===//
#include "mlir/IR/OwningOpRef.h"
#include "mlir/IR/PatternMatch.h"
#include "mlir/Rewrite/PatternApplicator.h"
#include "gtest/gtest.h"
@ -20,7 +21,7 @@ TEST(PatternBenefitTest, BenefitOrder) {
MLIRContext context;
OpBuilder builder(&context);
auto module = ModuleOp::create(builder.getUnknownLoc());
OwningOpRef<ModuleOp> module = ModuleOp::create(builder.getUnknownLoc());
struct Pattern1 : public OpRewritePattern<ModuleOp> {
Pattern1(mlir::MLIRContext *context, bool *called)
@ -71,7 +72,7 @@ TEST(PatternBenefitTest, BenefitOrder) {
};
MyPatternRewriter rewriter(&context);
(void)pa.matchAndRewrite(module, rewriter);
(void)pa.matchAndRewrite(*module, rewriter);
EXPECT_TRUE(called1);
EXPECT_TRUE(called2);