Skip to content

Commit 616e523

Browse files
authored
Fixing memory leaks in tests (llvm#161878)
Fixing the memory leaks introduced (llvm#158376) in the unit tests of FunctionPropertiesAnalysis and IR2Vec.
1 parent 2e67f5c commit 616e523

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

llvm/unittests/Analysis/FunctionPropertiesAnalysisTest.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ class FunctionPropertiesAnalysisTest : public testing::Test {
4646
MAM.registerPass([VocabVector = std::move(VocabVector)]() mutable {
4747
return IR2VecVocabAnalysis(std::move(VocabVector));
4848
});
49-
IR2VecVocab =
50-
new ir2vec::Vocabulary(ir2vec::Vocabulary::createDummyVocabForTest(1));
49+
IR2VecVocab = std::make_unique<ir2vec::Vocabulary>(
50+
ir2vec::Vocabulary::createDummyVocabForTest(1));
5151
MAM.registerPass([&] { return PassInstrumentationAnalysis(); });
5252
FAM.registerPass([&] { return ModuleAnalysisManagerFunctionProxy(MAM); });
5353
FAM.registerPass([&] { return DominatorTreeAnalysis(); });
@@ -69,7 +69,7 @@ class FunctionPropertiesAnalysisTest : public testing::Test {
6969
std::unique_ptr<LoopInfo> LI;
7070
FunctionAnalysisManager FAM;
7171
ModuleAnalysisManager MAM;
72-
ir2vec::Vocabulary *IR2VecVocab;
72+
std::unique_ptr<ir2vec::Vocabulary> IR2VecVocab;
7373

7474
void TearDown() override {
7575
// Restore original IR2Vec weights

llvm/unittests/Analysis/IR2VecTest.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ TEST(IR2VecTest, ZeroDimensionEmbedding) {
295295
// Fixture for IR2Vec tests requiring IR setup.
296296
class IR2VecTestFixture : public ::testing::Test {
297297
protected:
298-
Vocabulary *V;
298+
std::unique_ptr<Vocabulary> V;
299299
LLVMContext Ctx;
300300
std::unique_ptr<Module> M;
301301
Function *F = nullptr;
@@ -304,7 +304,7 @@ class IR2VecTestFixture : public ::testing::Test {
304304
Instruction *RetInst = nullptr;
305305

306306
void SetUp() override {
307-
V = new Vocabulary(Vocabulary::createDummyVocabForTest(2));
307+
V = std::make_unique<Vocabulary>(Vocabulary::createDummyVocabForTest(2));
308308

309309
// Setup IR
310310
M = std::make_unique<Module>("TestM", Ctx);

0 commit comments

Comments
 (0)