Skip to content

Commit a5355a5

Browse files
committed
Use llvm::stable_sort. NFC
llvm-svn: 358897
1 parent 4256cf1 commit a5355a5

File tree

7 files changed

+18
-22
lines changed

7 files changed

+18
-22
lines changed

llvm/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -956,7 +956,7 @@ static int AnalyzeBitcode() {
956956
for (unsigned i = 0, e = Stats.CodeFreq.size(); i != e; ++i)
957957
if (unsigned Freq = Stats.CodeFreq[i].NumInstances)
958958
FreqPairs.push_back(std::make_pair(Freq, i));
959-
std::stable_sort(FreqPairs.begin(), FreqPairs.end());
959+
llvm::stable_sort(FreqPairs);
960960
std::reverse(FreqPairs.begin(), FreqPairs.end());
961961

962962
outs() << "\tRecord Histogram:\n";

llvm/tools/llvm-cov/SourceCoverageView.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,8 +189,8 @@ void SourceCoverageView::print(raw_ostream &OS, bool WholeFile,
189189

190190
// We need the expansions and instantiations sorted so we can go through them
191191
// while we iterate lines.
192-
std::stable_sort(ExpansionSubViews.begin(), ExpansionSubViews.end());
193-
std::stable_sort(InstantiationSubViews.begin(), InstantiationSubViews.end());
192+
llvm::stable_sort(ExpansionSubViews);
193+
llvm::stable_sort(InstantiationSubViews);
194194
auto NextESV = ExpansionSubViews.begin();
195195
auto EndESV = ExpansionSubViews.end();
196196
auto NextISV = InstantiationSubViews.begin();

llvm/tools/llvm-objcopy/ELF/Object.cpp

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1468,11 +1468,9 @@ Error Object::removeSymbols(function_ref<bool(const Symbol &)> ToRemove) {
14681468
void Object::sortSections() {
14691469
// Put all sections in offset order. Maintain the ordering as closely as
14701470
// possible while meeting that demand however.
1471-
auto CompareSections = [](const SecPtr &A, const SecPtr &B) {
1471+
llvm::stable_sort(Sections, [](const SecPtr &A, const SecPtr &B) {
14721472
return A->OriginalOffset < B->OriginalOffset;
1473-
};
1474-
std::stable_sort(std::begin(this->Sections), std::end(this->Sections),
1475-
CompareSections);
1473+
});
14761474
}
14771475

14781476
static uint64_t alignToAddr(uint64_t Offset, uint64_t Addr, uint64_t Align) {
@@ -1490,8 +1488,7 @@ static uint64_t alignToAddr(uint64_t Offset, uint64_t Addr, uint64_t Align) {
14901488

14911489
// Orders segments such that if x = y->ParentSegment then y comes before x.
14921490
static void orderSegments(std::vector<Segment *> &Segments) {
1493-
std::stable_sort(std::begin(Segments), std::end(Segments),
1494-
compareSegmentsByOffset);
1491+
llvm::stable_sort(Segments, compareSegmentsByOffset);
14951492
}
14961493

14971494
// This function finds a consistent layout for a list of segments starting from
@@ -1746,8 +1743,7 @@ Error BinaryWriter::finalize() {
17461743
for (Segment *Seg : OrderedSegments)
17471744
Seg->PAddr = Seg->VAddr;
17481745

1749-
std::stable_sort(std::begin(OrderedSegments), std::end(OrderedSegments),
1750-
compareSegmentsByPAddr);
1746+
llvm::stable_sort(OrderedSegments, compareSegmentsByPAddr);
17511747

17521748
// Because we add a ParentSegment for each section we might have duplicate
17531749
// segments in OrderedSegments. If there were duplicates then LayoutSegments

llvm/tools/llvm-pdbutil/DumpOutputStyle.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -317,10 +317,10 @@ static inline std::string formatModuleDetailKind(SymbolKind K) {
317317
std::vector<StatCollection::KindAndStat>
318318
StatCollection::getStatsSortedBySize() const {
319319
std::vector<KindAndStat> SortedStats(Individual.begin(), Individual.end());
320-
std::stable_sort(SortedStats.begin(), SortedStats.end(),
321-
[](const KindAndStat &LHS, const KindAndStat &RHS) {
322-
return LHS.second.Size > RHS.second.Size;
323-
});
320+
llvm::stable_sort(SortedStats,
321+
[](const KindAndStat &LHS, const KindAndStat &RHS) {
322+
return LHS.second.Size > RHS.second.Size;
323+
});
324324
return SortedStats;
325325
}
326326

@@ -889,10 +889,10 @@ Error DumpOutputStyle::dumpUdtStats() {
889889
std::vector<StrAndStat> NamespacedStatsSorted;
890890
for (const auto &Stat : NamespacedStats)
891891
NamespacedStatsSorted.push_back({Stat.getKey(), Stat.second});
892-
std::stable_sort(NamespacedStatsSorted.begin(), NamespacedStatsSorted.end(),
893-
[](const StrAndStat &L, const StrAndStat &R) {
894-
return L.Stat.Size > R.Stat.Size;
895-
});
892+
llvm::stable_sort(NamespacedStatsSorted,
893+
[](const StrAndStat &L, const StrAndStat &R) {
894+
return L.Stat.Size > R.Stat.Size;
895+
});
896896
for (const auto &Stat : NamespacedStatsSorted) {
897897
std::string Label = formatv("namespace '{0}'", Stat.Key);
898898
P.formatLine("{0} | {1:N} {2:N}",

llvm/tools/llvm-readobj/COFFDumper.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1593,7 +1593,7 @@ void COFFDumper::printNeededLibraries() {
15931593
Libs.push_back(Name);
15941594
}
15951595

1596-
std::stable_sort(Libs.begin(), Libs.end());
1596+
llvm::stable_sort(Libs);
15971597

15981598
for (const auto &L : Libs) {
15991599
outs() << " " << L << "\n";

llvm/tools/llvm-readobj/ELFDumper.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1877,7 +1877,7 @@ void ELFDumper<ELFT>::printNeededLibraries() {
18771877
if (Entry.d_tag == ELF::DT_NEEDED)
18781878
Libs.push_back(getDynamicString(Entry.d_un.d_val));
18791879

1880-
std::stable_sort(Libs.begin(), Libs.end());
1880+
llvm::stable_sort(Libs);
18811881

18821882
for (const auto &L : Libs)
18831883
W.startLine() << L << "\n";

llvm/tools/llvm-readobj/MachODumper.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -694,7 +694,7 @@ void MachODumper::printNeededLibraries() {
694694
}
695695
}
696696

697-
std::stable_sort(Libs.begin(), Libs.end());
697+
llvm::stable_sort(Libs);
698698

699699
for (const auto &L : Libs) {
700700
outs() << " " << L << "\n";

0 commit comments

Comments
 (0)