[lsan] Print direct leaks first.

Direct leaks are higher priority, so it makes sense to have them on top.

llvm-svn: 186819
This commit is contained in:
Sergey Matveev 2013-07-22 11:18:32 +00:00
parent 1a9dafcd6f
commit 1ac4824841
1 changed files with 6 additions and 3 deletions

View File

@ -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;