This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG3988bd13988a: [llvm][clang][bolt][NFC] Use 
llvm::less_first() when applicable (authored by steakhal).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D126068/new/

https://reviews.llvm.org/D126068

Files:
  bolt/lib/Passes/LongJmp.cpp
  clang/lib/Frontend/FrontendAction.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/Sema/SemaStmtAsm.cpp
  clang/lib/StaticAnalyzer/Frontend/AnalyzerHelpFlags.cpp
  clang/unittests/Introspection/IntrospectionTest.cpp
  llvm/include/llvm/ExecutionEngine/Orc/Core.h
  llvm/lib/IR/Attributes.cpp
  llvm/lib/ObjCopy/MachO/MachOWriter.cpp
  llvm/tools/dsymutil/DebugMap.cpp
  llvm/tools/llvm-reduce/deltas/ReduceAttributes.cpp

Index: llvm/tools/llvm-reduce/deltas/ReduceAttributes.cpp
===================================================================
--- llvm/tools/llvm-reduce/deltas/ReduceAttributes.cpp
+++ llvm/tools/llvm-reduce/deltas/ReduceAttributes.cpp
@@ -158,10 +158,8 @@
                   V.first, convertAttributeRefToAttributeSet(C, V.second));
             });
 
-  sort(SetVec, [](const std::pair<unsigned, AttributeSet> &LHS,
-                  const std::pair<unsigned, AttributeSet> &RHS) {
-    return LHS.first < RHS.first; // All values are unique.
-  });
+  // All values are unique.
+  sort(SetVec, llvm::less_first());
 
   return AttributeList::get(C, SetVec);
 }
Index: llvm/tools/dsymutil/DebugMap.cpp
===================================================================
--- llvm/tools/dsymutil/DebugMap.cpp
+++ llvm/tools/dsymutil/DebugMap.cpp
@@ -62,9 +62,7 @@
   Entries.reserve(Symbols.getNumItems());
   for (const auto &Sym : Symbols)
     Entries.push_back(std::make_pair(Sym.getKey(), Sym.getValue()));
-  llvm::sort(Entries, [](const Entry &LHS, const Entry &RHS) {
-    return LHS.first < RHS.first;
-  });
+  llvm::sort(Entries, llvm::less_first());
   for (const auto &Sym : Entries) {
     if (Sym.second.ObjectAddress)
       OS << format("\t%016" PRIx64, uint64_t(*Sym.second.ObjectAddress));
Index: llvm/lib/ObjCopy/MachO/MachOWriter.cpp
===================================================================
--- llvm/lib/ObjCopy/MachO/MachOWriter.cpp
+++ llvm/lib/ObjCopy/MachO/MachOWriter.cpp
@@ -634,9 +634,7 @@
     }
   }
 
-  llvm::sort(Queue, [](const WriteOperation &LHS, const WriteOperation &RHS) {
-    return LHS.first < RHS.first;
-  });
+  llvm::sort(Queue, llvm::less_first());
 
   for (auto WriteOp : Queue)
     (this->*WriteOp.second)();
Index: llvm/lib/IR/Attributes.cpp
===================================================================
--- llvm/lib/IR/Attributes.cpp
+++ llvm/lib/IR/Attributes.cpp
@@ -1018,11 +1018,7 @@
   if (Attrs.empty())
     return {};
 
-  assert(llvm::is_sorted(Attrs,
-                         [](const std::pair<unsigned, Attribute> &LHS,
-                            const std::pair<unsigned, Attribute> &RHS) {
-                           return LHS.first < RHS.first;
-                         }) &&
+  assert(llvm::is_sorted(Attrs, llvm::less_first()) &&
          "Misordered Attributes list!");
   assert(llvm::all_of(Attrs,
                       [](const std::pair<unsigned, Attribute> &Pair) {
@@ -1055,11 +1051,7 @@
   if (Attrs.empty())
     return {};
 
-  assert(llvm::is_sorted(Attrs,
-                         [](const std::pair<unsigned, AttributeSet> &LHS,
-                            const std::pair<unsigned, AttributeSet> &RHS) {
-                           return LHS.first < RHS.first;
-                         }) &&
+  assert(llvm::is_sorted(Attrs, llvm::less_first()) &&
          "Misordered Attributes list!");
   assert(llvm::none_of(Attrs,
                        [](const std::pair<unsigned, AttributeSet> &Pair) {
Index: llvm/include/llvm/ExecutionEngine/Orc/Core.h
===================================================================
--- llvm/include/llvm/ExecutionEngine/Orc/Core.h
+++ llvm/include/llvm/ExecutionEngine/Orc/Core.h
@@ -339,11 +339,7 @@
   /// Sort the lookup set by pointer value. This sort is fast but sensitive to
   /// allocation order and so should not be used where a consistent order is
   /// required.
-  void sortByAddress() {
-    llvm::sort(Symbols, [](const value_type &LHS, const value_type &RHS) {
-      return LHS.first < RHS.first;
-    });
-  }
+  void sortByAddress() { llvm::sort(Symbols, llvm::less_first()); }
 
   /// Sort the lookup set lexicographically. This sort is slow but the order
   /// is unaffected by allocation order.
Index: clang/unittests/Introspection/IntrospectionTest.cpp
===================================================================
--- clang/unittests/Introspection/IntrospectionTest.cpp
+++ clang/unittests/Introspection/IntrospectionTest.cpp
@@ -299,9 +299,7 @@
 
   auto ExpectedRanges = FormatExpected<SourceRange>(Result.RangeAccessors);
 
-  llvm::sort(ExpectedRanges, [](const auto &LHS, const auto &RHS) {
-    return LHS.first < RHS.first;
-  });
+  llvm::sort(ExpectedRanges, llvm::less_first());
 
   // clang-format off
   EXPECT_EQ(
Index: clang/lib/StaticAnalyzer/Frontend/AnalyzerHelpFlags.cpp
===================================================================
--- clang/lib/StaticAnalyzer/Frontend/AnalyzerHelpFlags.cpp
+++ clang/lib/StaticAnalyzer/Frontend/AnalyzerHelpFlags.cpp
@@ -101,10 +101,7 @@
 #undef ANALYZER_OPTION_DEPENDS_ON_USER_MODE
   };
 
-  llvm::sort(PrintableOptions, [](const OptionAndDescriptionTy &LHS,
-                                  const OptionAndDescriptionTy &RHS) {
-    return LHS.first < RHS.first;
-  });
+  llvm::sort(PrintableOptions, llvm::less_first());
 
   for (const auto &Pair : PrintableOptions) {
     AnalyzerOptions::printFormattedEntry(out, Pair, /*InitialPad*/ 2,
Index: clang/lib/Sema/SemaStmtAsm.cpp
===================================================================
--- clang/lib/Sema/SemaStmtAsm.cpp
+++ clang/lib/Sema/SemaStmtAsm.cpp
@@ -717,9 +717,7 @@
           std::make_pair(Names[i]->getName(), Exprs[i]));
   // Sort NamedOperandList.
   std::stable_sort(NamedOperandList.begin(), NamedOperandList.end(),
-              [](const NamedOperand &LHS, const NamedOperand &RHS) {
-                return LHS.first < RHS.first;
-              });
+                   llvm::less_first());
   // Find adjacent duplicate operand.
   SmallVector<NamedOperand, 4>::iterator Found =
       std::adjacent_find(begin(NamedOperandList), end(NamedOperandList),
Index: clang/lib/Sema/SemaDeclCXX.cpp
===================================================================
--- clang/lib/Sema/SemaDeclCXX.cpp
+++ clang/lib/Sema/SemaDeclCXX.cpp
@@ -5430,8 +5430,7 @@
     return;
 
   // Sort based on the ideal order, first in the pair.
-  llvm::sort(CorrelatedInitOrder,
-             [](auto &LHS, auto &RHS) { return LHS.first < RHS.first; });
+  llvm::sort(CorrelatedInitOrder, llvm::less_first());
 
   // Introduce a new scope as SemaDiagnosticBuilder needs to be destroyed to
   // emit the diagnostic before we can try adding notes.
Index: clang/lib/Frontend/FrontendAction.cpp
===================================================================
--- clang/lib/Frontend/FrontendAction.cpp
+++ clang/lib/Frontend/FrontendAction.cpp
@@ -413,11 +413,7 @@
 
     // Sort header paths and make the header inclusion order deterministic
     // across different OSs and filesystems.
-    llvm::sort(Headers.begin(), Headers.end(), [](
-      const std::pair<std::string, const FileEntry *> &LHS,
-      const std::pair<std::string, const FileEntry *> &RHS) {
-        return LHS.first < RHS.first;
-    });
+    llvm::sort(Headers.begin(), Headers.end(), llvm::less_first());
     for (auto &H : Headers) {
       // Include this header as part of the umbrella directory.
       Module->addTopHeader(H.second);
Index: bolt/lib/Passes/LongJmp.cpp
===================================================================
--- bolt/lib/Passes/LongJmp.cpp
+++ bolt/lib/Passes/LongJmp.cpp
@@ -91,15 +91,10 @@
   // Register this in stubs maps
   auto registerInMap = [&](StubGroupsTy &Map) {
     StubGroupTy &StubGroup = Map[TgtSym];
-    StubGroup.insert(
-        std::lower_bound(
-            StubGroup.begin(), StubGroup.end(),
-            std::make_pair(AtAddress, nullptr),
-            [&](const std::pair<uint64_t, BinaryBasicBlock *> &LHS,
-                const std::pair<uint64_t, BinaryBasicBlock *> &RHS) {
-              return LHS.first < RHS.first;
-            }),
-        std::make_pair(AtAddress, StubBB.get()));
+    StubGroup.insert(std::lower_bound(StubGroup.begin(), StubGroup.end(),
+                                      std::make_pair(AtAddress, nullptr),
+                                      llvm::less_first()),
+                     std::make_pair(AtAddress, StubBB.get()));
   };
 
   Stubs[&Func].insert(StubBB.get());
@@ -129,12 +124,9 @@
   const StubGroupTy &Candidates = CandidatesIter->second;
   if (Candidates.empty())
     return nullptr;
-  auto Cand = std::lower_bound(
-      Candidates.begin(), Candidates.end(), std::make_pair(DotAddress, nullptr),
-      [&](const std::pair<uint64_t, BinaryBasicBlock *> &LHS,
-          const std::pair<uint64_t, BinaryBasicBlock *> &RHS) {
-        return LHS.first < RHS.first;
-      });
+  auto Cand =
+      std::lower_bound(Candidates.begin(), Candidates.end(),
+                       std::make_pair(DotAddress, nullptr), llvm::less_first());
   if (Cand == Candidates.end())
     return nullptr;
   if (Cand != Candidates.begin()) {
@@ -259,11 +251,7 @@
     for (auto &KeyVal : StubGroups) {
       for (StubTy &Elem : KeyVal.second)
         Elem.first = BBAddresses[Elem.second];
-      std::sort(KeyVal.second.begin(), KeyVal.second.end(),
-                [&](const std::pair<uint64_t, BinaryBasicBlock *> &LHS,
-                    const std::pair<uint64_t, BinaryBasicBlock *> &RHS) {
-                  return LHS.first < RHS.first;
-                });
+      std::sort(KeyVal.second.begin(), KeyVal.second.end(), llvm::less_first());
     }
   };
 
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to