[llvm] 7ffe67c - [RemoveDIs] Fix asan-identified leak in unittest (#106723)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 30 06:39:14 PDT 2024
Author: Orlando Cazalet-Hyams
Date: 2024-08-30T15:39:11+02:00
New Revision: 7ffe67c17c524c2d3056c0721a33c7012dce3061
URL: https://github.com/llvm/llvm-project/commit/7ffe67c17c524c2d3056c0721a33c7012dce3061
DIFF: https://github.com/llvm/llvm-project/commit/7ffe67c17c524c2d3056c0721a33c7012dce3061.diff
LOG: [RemoveDIs] Fix asan-identified leak in unittest (#106723)
Fixes issue found here
https://github.com/llvm/llvm-project/pull/106691#issuecomment-2320960847
The issue wasn't in the code change itself, just the unittest; the
trailing marker wasn't properly cleaned up.
Added:
Modified:
llvm/unittests/IR/BasicBlockDbgInfoTest.cpp
Removed:
################################################################################
diff --git a/llvm/unittests/IR/BasicBlockDbgInfoTest.cpp b/llvm/unittests/IR/BasicBlockDbgInfoTest.cpp
index 5615a4493d20a1..5ce14d3f6b9cef 100644
--- a/llvm/unittests/IR/BasicBlockDbgInfoTest.cpp
+++ b/llvm/unittests/IR/BasicBlockDbgInfoTest.cpp
@@ -1569,14 +1569,12 @@ TEST(BasicBlockDbgInfoTest, CloneTrailingRecordsToEmptyBlock) {
// The trailing records should've been absorbed into NewBB.
EXPECT_FALSE(BB.getTrailingDbgRecords());
EXPECT_TRUE(NewBB->getTrailingDbgRecords());
- if (NewBB->getTrailingDbgRecords()) {
- EXPECT_EQ(
- llvm::range_size(NewBB->getTrailingDbgRecords()->getDbgRecordRange()),
- 1u);
+ if (DbgMarker *Trailing = NewBB->getTrailingDbgRecords()) {
+ EXPECT_EQ(llvm::range_size(Trailing->getDbgRecordRange()), 1u);
+ // Drop the trailing records now, to prevent a cleanup assertion.
+ Trailing->eraseFromParent();
+ NewBB->deleteTrailingDbgRecords();
}
-
- // Drop the trailing records now, to prevent a cleanup assertion.
- NewBB->deleteTrailingDbgRecords();
}
} // End anonymous namespace.
More information about the llvm-commits
mailing list