Skip to content

Commit 4788d5f

Browse files
[lldb] Use llvm::stable_sort (NFC) (#141352)
1 parent 24c782e commit 4788d5f

File tree

6 files changed

+19
-22
lines changed

6 files changed

+19
-22
lines changed

lldb/include/lldb/Utility/RangeMap.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ template <typename B, typename S, unsigned N = 0> class RangeVector {
216216

217217
void Sort() {
218218
if (m_entries.size() > 1)
219-
std::stable_sort(m_entries.begin(), m_entries.end());
219+
llvm::stable_sort(m_entries);
220220
}
221221

222222
#ifdef ASSERT_RANGEMAP_ARE_SORTED
@@ -484,14 +484,14 @@ class RangeDataVector {
484484

485485
void Sort() {
486486
if (m_entries.size() > 1)
487-
std::stable_sort(m_entries.begin(), m_entries.end(),
488-
[&compare = m_compare](const Entry &a, const Entry &b) {
489-
if (a.base != b.base)
490-
return a.base < b.base;
491-
if (a.size != b.size)
492-
return a.size < b.size;
493-
return compare(a.data, b.data);
494-
});
487+
llvm::stable_sort(m_entries,
488+
[&compare = m_compare](const Entry &a, const Entry &b) {
489+
if (a.base != b.base)
490+
return a.base < b.base;
491+
if (a.size != b.size)
492+
return a.size < b.size;
493+
return compare(a.data, b.data);
494+
});
495495
if (!m_entries.empty())
496496
ComputeUpperBounds(0, m_entries.size());
497497
}

lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -919,8 +919,7 @@ ObjectFilePECOFF::AppendFromExportTable(SectionList *sect_list,
919919
uint32_t idx = symtab.AddSymbol(symbol);
920920
export_list.push_back(std::make_pair(function_rva, idx));
921921
}
922-
std::stable_sort(export_list.begin(), export_list.end(),
923-
RVASymbolListCompareRVA);
922+
llvm::stable_sort(export_list, RVASymbolListCompareRVA);
924923
return export_list;
925924
}
926925

lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2758,11 +2758,10 @@ Status ProcessGDBRemote::WriteObjectFile(
27582758
Status error;
27592759
// Sort the entries by address because some writes, like those to flash
27602760
// memory, must happen in order of increasing address.
2761-
std::stable_sort(
2762-
std::begin(entries), std::end(entries),
2763-
[](const ObjectFile::LoadableData a, const ObjectFile::LoadableData b) {
2764-
return a.Dest < b.Dest;
2765-
});
2761+
llvm::stable_sort(entries, [](const ObjectFile::LoadableData a,
2762+
const ObjectFile::LoadableData b) {
2763+
return a.Dest < b.Dest;
2764+
});
27662765
m_allow_flash_writes = true;
27672766
error = Process::WriteObjectFile(entries);
27682767
if (error.Success())

lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8631,10 +8631,9 @@ static bool DumpEnumValue(const clang::QualType &qual_type, Stream &s,
86318631
// Sort in reverse order of the number of the population count, so that in
86328632
// `enum {A, B, ALL = A|B }` we visit ALL first. Use a stable sort so that
86338633
// A | C where A is declared before C is displayed in this order.
8634-
std::stable_sort(values.begin(), values.end(),
8635-
[](const auto &a, const auto &b) {
8636-
return llvm::popcount(a.first) > llvm::popcount(b.first);
8637-
});
8634+
llvm::stable_sort(values, [](const auto &a, const auto &b) {
8635+
return llvm::popcount(a.first) > llvm::popcount(b.first);
8636+
});
86388637

86398638
for (const auto &val : values) {
86408639
if ((remaining_value & val.first) != val.first)

lldb/source/Symbol/Symtab.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -638,7 +638,7 @@ void Symtab::SortSymbolIndexesByValue(std::vector<uint32_t> &indexes,
638638
std::vector<lldb::addr_t> addr_cache(m_symbols.size(), LLDB_INVALID_ADDRESS);
639639

640640
SymbolIndexComparator comparator(m_symbols, addr_cache);
641-
std::stable_sort(indexes.begin(), indexes.end(), comparator);
641+
llvm::stable_sort(indexes, comparator);
642642

643643
// Remove any duplicates if requested
644644
if (remove_duplicates) {

lldb/source/Utility/DiagnosticsRendering.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ void RenderDiagnosticDetails(Stream &stream,
140140

141141
// Sort the diagnostics.
142142
auto sort = [](std::vector<DiagnosticDetail> &ds) {
143-
std::stable_sort(ds.begin(), ds.end(), [](auto &d1, auto &d2) {
143+
llvm::stable_sort(ds, [](auto &d1, auto &d2) {
144144
auto l1 = d1.source_location.value_or(DiagnosticDetail::SourceLocation{});
145145
auto l2 = d2.source_location.value_or(DiagnosticDetail::SourceLocation{});
146146
return std::tie(l1.line, l1.column) < std::tie(l2.line, l2.column);

0 commit comments

Comments
 (0)