From 1ac4824841d00c85ef805816a5f84aaf34ad1466 Mon Sep 17 00:00:00 2001 From: Sergey Matveev Date: Mon, 22 Jul 2013 11:18:32 +0000 Subject: [PATCH] [lsan] Print direct leaks first. Direct leaks are higher priority, so it makes sense to have them on top. llvm-svn: 186819 --- compiler-rt/lib/lsan/lsan_common.cc | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/compiler-rt/lib/lsan/lsan_common.cc b/compiler-rt/lib/lsan/lsan_common.cc index 8bb89e7..8f57ae0 100644 --- a/compiler-rt/lib/lsan/lsan_common.cc +++ b/compiler-rt/lib/lsan/lsan_common.cc @@ -438,8 +438,11 @@ void LeakReport::Add(u32 stack_trace_id, uptr leaked_size, ChunkTag tag) { leaks_.push_back(leak); } -static bool IsLarger(const Leak &leak1, const Leak &leak2) { - return leak1.total_size > leak2.total_size; +static bool LeakComparator(const Leak &leak1, const Leak &leak2) { + if (leak1.is_directly_leaked == leak2.is_directly_leaked) + return leak1.total_size > leak2.total_size; + else + return leak1.is_directly_leaked; } void LeakReport::PrintLargest(uptr num_leaks_to_print) { @@ -455,7 +458,7 @@ void LeakReport::PrintLargest(uptr num_leaks_to_print) { if (!leaks_[i].is_suppressed) unsuppressed_count++; if (num_leaks_to_print > 0 && num_leaks_to_print < unsuppressed_count) Printf("The %zu largest leak(s):\n", num_leaks_to_print); - InternalSort(&leaks_, leaks_.size(), IsLarger); + InternalSort(&leaks_, leaks_.size(), LeakComparator); uptr leaks_printed = 0; for (uptr i = 0; i < leaks_.size(); i++) { if (leaks_[i].is_suppressed) continue; -- 2.7.4