[llvm] r358897 - Use llvm::stable_sort. NFC

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 22 08:53:43 PDT 2019


Author: maskray
Date: Mon Apr 22 08:53:43 2019
New Revision: 358897

URL: http://llvm.org/viewvc/llvm-project?rev=358897&view=rev
Log:
Use llvm::stable_sort. NFC

Modified:
    llvm/trunk/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp
    llvm/trunk/tools/llvm-cov/SourceCoverageView.cpp
    llvm/trunk/tools/llvm-objcopy/ELF/Object.cpp
    llvm/trunk/tools/llvm-pdbutil/DumpOutputStyle.cpp
    llvm/trunk/tools/llvm-readobj/COFFDumper.cpp
    llvm/trunk/tools/llvm-readobj/ELFDumper.cpp
    llvm/trunk/tools/llvm-readobj/MachODumper.cpp

Modified: llvm/trunk/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp?rev=358897&r1=358896&r2=358897&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp (original)
+++ llvm/trunk/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp Mon Apr 22 08:53:43 2019
@@ -956,7 +956,7 @@ static int AnalyzeBitcode() {
       for (unsigned i = 0, e = Stats.CodeFreq.size(); i != e; ++i)
         if (unsigned Freq = Stats.CodeFreq[i].NumInstances)
           FreqPairs.push_back(std::make_pair(Freq, i));
-      std::stable_sort(FreqPairs.begin(), FreqPairs.end());
+      llvm::stable_sort(FreqPairs);
       std::reverse(FreqPairs.begin(), FreqPairs.end());
 
       outs() << "\tRecord Histogram:\n";

Modified: llvm/trunk/tools/llvm-cov/SourceCoverageView.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-cov/SourceCoverageView.cpp?rev=358897&r1=358896&r2=358897&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-cov/SourceCoverageView.cpp (original)
+++ llvm/trunk/tools/llvm-cov/SourceCoverageView.cpp Mon Apr 22 08:53:43 2019
@@ -189,8 +189,8 @@ void SourceCoverageView::print(raw_ostre
 
   // We need the expansions and instantiations sorted so we can go through them
   // while we iterate lines.
-  std::stable_sort(ExpansionSubViews.begin(), ExpansionSubViews.end());
-  std::stable_sort(InstantiationSubViews.begin(), InstantiationSubViews.end());
+  llvm::stable_sort(ExpansionSubViews);
+  llvm::stable_sort(InstantiationSubViews);
   auto NextESV = ExpansionSubViews.begin();
   auto EndESV = ExpansionSubViews.end();
   auto NextISV = InstantiationSubViews.begin();

Modified: llvm/trunk/tools/llvm-objcopy/ELF/Object.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-objcopy/ELF/Object.cpp?rev=358897&r1=358896&r2=358897&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-objcopy/ELF/Object.cpp (original)
+++ llvm/trunk/tools/llvm-objcopy/ELF/Object.cpp Mon Apr 22 08:53:43 2019
@@ -1468,11 +1468,9 @@ Error Object::removeSymbols(function_ref
 void Object::sortSections() {
   // Put all sections in offset order. Maintain the ordering as closely as
   // possible while meeting that demand however.
-  auto CompareSections = [](const SecPtr &A, const SecPtr &B) {
+  llvm::stable_sort(Sections, [](const SecPtr &A, const SecPtr &B) {
     return A->OriginalOffset < B->OriginalOffset;
-  };
-  std::stable_sort(std::begin(this->Sections), std::end(this->Sections),
-                   CompareSections);
+  });
 }
 
 static uint64_t alignToAddr(uint64_t Offset, uint64_t Addr, uint64_t Align) {
@@ -1490,8 +1488,7 @@ static uint64_t alignToAddr(uint64_t Off
 
 // Orders segments such that if x = y->ParentSegment then y comes before x.
 static void orderSegments(std::vector<Segment *> &Segments) {
-  std::stable_sort(std::begin(Segments), std::end(Segments),
-                   compareSegmentsByOffset);
+  llvm::stable_sort(Segments, compareSegmentsByOffset);
 }
 
 // This function finds a consistent layout for a list of segments starting from
@@ -1746,8 +1743,7 @@ Error BinaryWriter::finalize() {
     for (Segment *Seg : OrderedSegments)
       Seg->PAddr = Seg->VAddr;
 
-  std::stable_sort(std::begin(OrderedSegments), std::end(OrderedSegments),
-                   compareSegmentsByPAddr);
+  llvm::stable_sort(OrderedSegments, compareSegmentsByPAddr);
 
   // Because we add a ParentSegment for each section we might have duplicate
   // segments in OrderedSegments. If there were duplicates then LayoutSegments

Modified: llvm/trunk/tools/llvm-pdbutil/DumpOutputStyle.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-pdbutil/DumpOutputStyle.cpp?rev=358897&r1=358896&r2=358897&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-pdbutil/DumpOutputStyle.cpp (original)
+++ llvm/trunk/tools/llvm-pdbutil/DumpOutputStyle.cpp Mon Apr 22 08:53:43 2019
@@ -317,10 +317,10 @@ static inline std::string formatModuleDe
 std::vector<StatCollection::KindAndStat>
 StatCollection::getStatsSortedBySize() const {
   std::vector<KindAndStat> SortedStats(Individual.begin(), Individual.end());
-  std::stable_sort(SortedStats.begin(), SortedStats.end(),
-                   [](const KindAndStat &LHS, const KindAndStat &RHS) {
-                     return LHS.second.Size > RHS.second.Size;
-                   });
+  llvm::stable_sort(SortedStats,
+                    [](const KindAndStat &LHS, const KindAndStat &RHS) {
+                      return LHS.second.Size > RHS.second.Size;
+                    });
   return SortedStats;
 }
 
@@ -889,10 +889,10 @@ Error DumpOutputStyle::dumpUdtStats() {
   std::vector<StrAndStat> NamespacedStatsSorted;
   for (const auto &Stat : NamespacedStats)
     NamespacedStatsSorted.push_back({Stat.getKey(), Stat.second});
-  std::stable_sort(NamespacedStatsSorted.begin(), NamespacedStatsSorted.end(),
-                   [](const StrAndStat &L, const StrAndStat &R) {
-                     return L.Stat.Size > R.Stat.Size;
-                   });
+  llvm::stable_sort(NamespacedStatsSorted,
+                    [](const StrAndStat &L, const StrAndStat &R) {
+                      return L.Stat.Size > R.Stat.Size;
+                    });
   for (const auto &Stat : NamespacedStatsSorted) {
     std::string Label = formatv("namespace '{0}'", Stat.Key);
     P.formatLine("{0} | {1:N}  {2:N}",

Modified: llvm/trunk/tools/llvm-readobj/COFFDumper.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-readobj/COFFDumper.cpp?rev=358897&r1=358896&r2=358897&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-readobj/COFFDumper.cpp (original)
+++ llvm/trunk/tools/llvm-readobj/COFFDumper.cpp Mon Apr 22 08:53:43 2019
@@ -1593,7 +1593,7 @@ void COFFDumper::printNeededLibraries()
       Libs.push_back(Name);
   }
 
-  std::stable_sort(Libs.begin(), Libs.end());
+  llvm::stable_sort(Libs);
 
   for (const auto &L : Libs) {
     outs() << "  " << L << "\n";

Modified: llvm/trunk/tools/llvm-readobj/ELFDumper.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-readobj/ELFDumper.cpp?rev=358897&r1=358896&r2=358897&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-readobj/ELFDumper.cpp (original)
+++ llvm/trunk/tools/llvm-readobj/ELFDumper.cpp Mon Apr 22 08:53:43 2019
@@ -1877,7 +1877,7 @@ void ELFDumper<ELFT>::printNeededLibrari
     if (Entry.d_tag == ELF::DT_NEEDED)
       Libs.push_back(getDynamicString(Entry.d_un.d_val));
 
-  std::stable_sort(Libs.begin(), Libs.end());
+  llvm::stable_sort(Libs);
 
   for (const auto &L : Libs)
      W.startLine() << L << "\n";

Modified: llvm/trunk/tools/llvm-readobj/MachODumper.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-readobj/MachODumper.cpp?rev=358897&r1=358896&r2=358897&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-readobj/MachODumper.cpp (original)
+++ llvm/trunk/tools/llvm-readobj/MachODumper.cpp Mon Apr 22 08:53:43 2019
@@ -694,7 +694,7 @@ void MachODumper::printNeededLibraries()
     }
   }
 
-  std::stable_sort(Libs.begin(), Libs.end());
+  llvm::stable_sort(Libs);
 
   for (const auto &L : Libs) {
     outs() << "  " << L << "\n";




More information about the llvm-commits mailing list