From: Balazs Benics Date: Fri, 27 May 2022 09:18:05 +0000 (+0200) Subject: Revert "[llvm][clang][bolt][NFC] Use llvm::less_first() when applicable" X-Git-Tag: upstream/15.0.7~6528 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a73b50ad0649d635433547ff51cd73d2ce9f085b;p=platform%2Fupstream%2Fllvm.git Revert "[llvm][clang][bolt][NFC] Use llvm::less_first() when applicable" 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&, const std::pair&)’ 177 | { return bool(_M_comp(*__it, __val)); } --- diff --git a/bolt/lib/Passes/LongJmp.cpp b/bolt/lib/Passes/LongJmp.cpp index b0cc441..24139f2 100644 --- a/bolt/lib/Passes/LongJmp.cpp +++ b/bolt/lib/Passes/LongJmp.cpp @@ -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 &LHS, + const std::pair &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 &LHS, + const std::pair &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 &LHS, + const std::pair &RHS) { + return LHS.first < RHS.first; + }); } }; diff --git a/clang/lib/Frontend/FrontendAction.cpp b/clang/lib/Frontend/FrontendAction.cpp index 6b1f636..68c70dd 100644 --- a/clang/lib/Frontend/FrontendAction.cpp +++ b/clang/lib/Frontend/FrontendAction.cpp @@ -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 &LHS, + const std::pair &RHS) { + return LHS.first < RHS.first; + }); for (auto &H : Headers) { // Include this header as part of the umbrella directory. Module->addTopHeader(H.second); diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp index 569b226..c470a46 100644 --- a/clang/lib/Sema/SemaDeclCXX.cpp +++ b/clang/lib/Sema/SemaDeclCXX.cpp @@ -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. diff --git a/clang/lib/Sema/SemaStmtAsm.cpp b/clang/lib/Sema/SemaStmtAsm.cpp index f3c4b4f..fbca36b 100644 --- a/clang/lib/Sema/SemaStmtAsm.cpp +++ b/clang/lib/Sema/SemaStmtAsm.cpp @@ -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::iterator Found = std::adjacent_find(begin(NamedOperandList), end(NamedOperandList), diff --git a/clang/lib/StaticAnalyzer/Frontend/AnalyzerHelpFlags.cpp b/clang/lib/StaticAnalyzer/Frontend/AnalyzerHelpFlags.cpp index 7cd15f0..eb6014a 100644 --- a/clang/lib/StaticAnalyzer/Frontend/AnalyzerHelpFlags.cpp +++ b/clang/lib/StaticAnalyzer/Frontend/AnalyzerHelpFlags.cpp @@ -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, diff --git a/clang/unittests/Introspection/IntrospectionTest.cpp b/clang/unittests/Introspection/IntrospectionTest.cpp index 9f76568..69e4616 100644 --- a/clang/unittests/Introspection/IntrospectionTest.cpp +++ b/clang/unittests/Introspection/IntrospectionTest.cpp @@ -299,7 +299,9 @@ STRING_LOCATION_STDPAIR(MethodDecl, getTypeSpecStartLoc()) auto ExpectedRanges = FormatExpected(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( diff --git a/llvm/include/llvm/ExecutionEngine/Orc/Core.h b/llvm/include/llvm/ExecutionEngine/Orc/Core.h index df2826b..a517768 100644 --- a/llvm/include/llvm/ExecutionEngine/Orc/Core.h +++ b/llvm/include/llvm/ExecutionEngine/Orc/Core.h @@ -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. diff --git a/llvm/lib/IR/Attributes.cpp b/llvm/lib/IR/Attributes.cpp index 31141cf..1aa2d44 100644 --- a/llvm/lib/IR/Attributes.cpp +++ b/llvm/lib/IR/Attributes.cpp @@ -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 &LHS, + const std::pair &RHS) { + return LHS.first < RHS.first; + }) && "Misordered Attributes list!"); assert(llvm::all_of(Attrs, [](const std::pair &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 &LHS, + const std::pair &RHS) { + return LHS.first < RHS.first; + }) && "Misordered Attributes list!"); assert(llvm::none_of(Attrs, [](const std::pair &Pair) { diff --git a/llvm/lib/ObjCopy/MachO/MachOWriter.cpp b/llvm/lib/ObjCopy/MachO/MachOWriter.cpp index 9b1fd58..a94764a 100644 --- a/llvm/lib/ObjCopy/MachO/MachOWriter.cpp +++ b/llvm/lib/ObjCopy/MachO/MachOWriter.cpp @@ -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)(); diff --git a/llvm/tools/dsymutil/DebugMap.cpp b/llvm/tools/dsymutil/DebugMap.cpp index 79b6cb2..605c131 100644 --- a/llvm/tools/dsymutil/DebugMap.cpp +++ b/llvm/tools/dsymutil/DebugMap.cpp @@ -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)); diff --git a/llvm/tools/llvm-reduce/deltas/ReduceAttributes.cpp b/llvm/tools/llvm-reduce/deltas/ReduceAttributes.cpp index e4570dd..3a23974 100644 --- a/llvm/tools/llvm-reduce/deltas/ReduceAttributes.cpp +++ b/llvm/tools/llvm-reduce/deltas/ReduceAttributes.cpp @@ -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 &LHS, + const std::pair &RHS) { + return LHS.first < RHS.first; // All values are unique. + }); return AttributeList::get(C, SetVec); }