Skip to content

Commit 28d418b

Browse files
committed
[unittest][codegen] Avoid memory leak in recently added FindDebugLocTest unittest
Need to finalize the DIBuilder to avoid leak sanitizer errors like this: Direct leak of 48 byte(s) in 1 object(s) allocated from: #0 0x55c99ea1761d in operator new(unsigned long) #1 0x55c9a518ae49 in operator new #2 0x55c9a518ae49 in llvm::MDTuple::getImpl(...) #3 0x55c9a4f1b1ec in getTemporary #4 0x55c9a4f1b1ec in llvm::DIBuilder::createFunction(...)
1 parent 1826fad commit 28d418b

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

llvm/unittests/CodeGen/MachineBasicBlockTest.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,9 @@ TEST(FindDebugLocTest, DifferentIterators) {
100100
EXPECT_EQ(DL1, MBB.rfindPrevDebugLoc(MI2));
101101
EXPECT_EQ(DL1, MBB.rfindPrevDebugLoc(MI3));
102102
EXPECT_EQ(DL1, MBB.rfindPrevDebugLoc(MBB.instr_rbegin()));
103+
104+
// Finalize DIBuilder to avoid memory leaks.
105+
DIB.finalize();
103106
}
104107

105108
} // end namespace

0 commit comments

Comments
 (0)