Revert "[llvm][clang][bolt][NFC] Use llvm::less_first() when applicable"
authorBalazs Benics <balazs.benics@sigmatechnology.se>
Fri, 27 May 2022 09:18:05 +0000 (11:18 +0200)
committerBalazs Benics <balazs.benics@sigmatechnology.se>
Fri, 27 May 2022 09:19:18 +0000 (11:19 +0200)
This reverts commit 3988bd13988aad72ec979beb2361e8738584926b.

Did not build on this bot:
https://lab.llvm.org/buildbot#builders/215/builds/6372

/usr/include/c++/9/bits/predefined_ops.h:177:11: error: no match for call to
‘(llvm::less_first) (std::pair<long unsigned int, llvm::bolt::BinaryBasicBlock*>&, const std::pair<long unsigned int, std::nullptr_t>&)’
  177 |  { return bool(_M_comp(*__it, __val)); }

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 b0cc441..24139f2 100644 (file)
@@ -91,10 +91,15 @@ LongJmpPass::createNewStub(BinaryBasicBlock &SourceBB, const MCSymbol *TgtSym,
   // 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),
-                                      llvm::less_first()),
-                     std::make_pair(AtAddress, StubBB.get()));
+    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()));
   };
 
   Stubs[&Func].insert(StubBB.get());
@@ -124,9 +129,12 @@ BinaryBasicBlock *LongJmpPass::lookupStubFromGroup(
   const StubGroupTy &Candidates = CandidatesIter->second;
   if (Candidates.empty())
     return nullptr;
-  auto Cand =
-      std::lower_bound(Candidates.begin(), Candidates.end(),
-                       std::make_pair(DotAddress, nullptr), llvm::less_first());
+  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;
+      });
   if (Cand == Candidates.end())
     return nullptr;
   if (Cand != Candidates.begin()) {
@@ -251,7 +259,11 @@ void LongJmpPass::updateStubGroups() {
     for (auto &KeyVal : StubGroups) {
       for (StubTy &Elem : KeyVal.second)
         Elem.first = BBAddresses[Elem.second];
-      std::sort(KeyVal.second.begin(), KeyVal.second.end(), llvm::less_first());
+      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;
+                });
     }
   };
 
index 6b1f636..68c70dd 100644 (file)
@@ -413,7 +413,11 @@ static std::error_code collectModuleHeaderIncludes(
 
     // Sort header paths and make the header inclusion order deterministic
     // across different OSs and filesystems.
-    llvm::sort(Headers.begin(), Headers.end(), llvm::less_first());
+    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;
+    });
     for (auto &H : Headers) {
       // Include this header as part of the umbrella directory.
       Module->addTopHeader(H.second);
index 569b226..c470a46 100644 (file)
@@ -5430,7 +5430,8 @@ static void DiagnoseBaseOrMemInitializerOrder(
     return;
 
   // Sort based on the ideal order, first in the pair.
-  llvm::sort(CorrelatedInitOrder, llvm::less_first());
+  llvm::sort(CorrelatedInitOrder,
+             [](auto &LHS, auto &RHS) { return LHS.first < RHS.first; });
 
   // Introduce a new scope as SemaDiagnosticBuilder needs to be destroyed to
   // emit the diagnostic before we can try adding notes.
index f3c4b4f..fbca36b 100644 (file)
@@ -717,7 +717,9 @@ StmtResult Sema::ActOnGCCAsmStmt(SourceLocation AsmLoc, bool IsSimple,
           std::make_pair(Names[i]->getName(), Exprs[i]));
   // Sort NamedOperandList.
   std::stable_sort(NamedOperandList.begin(), NamedOperandList.end(),
-                   llvm::less_first());
+              [](const NamedOperand &LHS, const NamedOperand &RHS) {
+                return LHS.first < RHS.first;
+              });
   // Find adjacent duplicate operand.
   SmallVector<NamedOperand, 4>::iterator Found =
       std::adjacent_find(begin(NamedOperandList), end(NamedOperandList),
index 7cd15f0..eb6014a 100644 (file)
@@ -101,7 +101,10 @@ OPTIONS:
 #undef ANALYZER_OPTION_DEPENDS_ON_USER_MODE
   };
 
-  llvm::sort(PrintableOptions, llvm::less_first());
+  llvm::sort(PrintableOptions, [](const OptionAndDescriptionTy &LHS,
+                                  const OptionAndDescriptionTy &RHS) {
+    return LHS.first < RHS.first;
+  });
 
   for (const auto &Pair : PrintableOptions) {
     AnalyzerOptions::printFormattedEntry(out, Pair, /*InitialPad*/ 2,
index 9f76568..69e4616 100644 (file)
@@ -299,7 +299,9 @@ STRING_LOCATION_STDPAIR(MethodDecl, getTypeSpecStartLoc())
 
   auto ExpectedRanges = FormatExpected<SourceRange>(Result.RangeAccessors);
 
-  llvm::sort(ExpectedRanges, llvm::less_first());
+  llvm::sort(ExpectedRanges, [](const auto &LHS, const auto &RHS) {
+    return LHS.first < RHS.first;
+  });
 
   // clang-format off
   EXPECT_EQ(
index df2826b..a517768 100644 (file)
@@ -339,7 +339,11 @@ public:
   /// 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, llvm::less_first()); }
+  void sortByAddress() {
+    llvm::sort(Symbols, [](const value_type &LHS, const value_type &RHS) {
+      return LHS.first < RHS.first;
+    });
+  }
 
   /// Sort the lookup set lexicographically. This sort is slow but the order
   /// is unaffected by allocation order.
index 31141cf..1aa2d44 100644 (file)
@@ -1018,7 +1018,11 @@ AttributeList::get(LLVMContext &C,
   if (Attrs.empty())
     return {};
 
-  assert(llvm::is_sorted(Attrs, llvm::less_first()) &&
+  assert(llvm::is_sorted(Attrs,
+                         [](const std::pair<unsigned, Attribute> &LHS,
+                            const std::pair<unsigned, Attribute> &RHS) {
+                           return LHS.first < RHS.first;
+                         }) &&
          "Misordered Attributes list!");
   assert(llvm::all_of(Attrs,
                       [](const std::pair<unsigned, Attribute> &Pair) {
@@ -1051,7 +1055,11 @@ AttributeList::get(LLVMContext &C,
   if (Attrs.empty())
     return {};
 
-  assert(llvm::is_sorted(Attrs, llvm::less_first()) &&
+  assert(llvm::is_sorted(Attrs,
+                         [](const std::pair<unsigned, AttributeSet> &LHS,
+                            const std::pair<unsigned, AttributeSet> &RHS) {
+                           return LHS.first < RHS.first;
+                         }) &&
          "Misordered Attributes list!");
   assert(llvm::none_of(Attrs,
                        [](const std::pair<unsigned, AttributeSet> &Pair) {
index 9b1fd58..a94764a 100644 (file)
@@ -634,7 +634,9 @@ void MachOWriter::writeTail() {
     }
   }
 
-  llvm::sort(Queue, llvm::less_first());
+  llvm::sort(Queue, [](const WriteOperation &LHS, const WriteOperation &RHS) {
+    return LHS.first < RHS.first;
+  });
 
   for (auto WriteOp : Queue)
     (this->*WriteOp.second)();
index 79b6cb2..605c131 100644 (file)
@@ -62,7 +62,9 @@ void DebugMapObject::print(raw_ostream &OS) const {
   Entries.reserve(Symbols.getNumItems());
   for (const auto &Sym : Symbols)
     Entries.push_back(std::make_pair(Sym.getKey(), Sym.getValue()));
-  llvm::sort(Entries, llvm::less_first());
+  llvm::sort(Entries, [](const Entry &LHS, const Entry &RHS) {
+    return LHS.first < RHS.first;
+  });
   for (const auto &Sym : Entries) {
     if (Sym.second.ObjectAddress)
       OS << format("\t%016" PRIx64, uint64_t(*Sym.second.ObjectAddress));
index e4570dd..3a23974 100644 (file)
@@ -158,8 +158,10 @@ AttributeList convertAttributeRefVecToAttributeList(
                   V.first, convertAttributeRefToAttributeSet(C, V.second));
             });
 
-  // All values are unique.
-  sort(SetVec, llvm::less_first());
+  sort(SetVec, [](const std::pair<unsigned, AttributeSet> &LHS,
+                  const std::pair<unsigned, AttributeSet> &RHS) {
+    return LHS.first < RHS.first; // All values are unique.
+  });
 
   return AttributeList::get(C, SetVec);
 }