diff --git a/clang/lib/StaticAnalyzer/Core/WorkList.cpp b/clang/lib/StaticAnalyzer/Core/WorkList.cpp index 348552ba73a9..7042a9020837 100644 --- a/clang/lib/StaticAnalyzer/Core/WorkList.cpp +++ b/clang/lib/StaticAnalyzer/Core/WorkList.cpp @@ -205,12 +205,6 @@ class UnexploredFirstPriorityQueue : public WorkList { using QueuePriority = std::pair; using QueueItem = std::pair; - struct ExplorationComparator { - bool operator() (const QueueItem &LHS, const QueueItem &RHS) { - return LHS.second < RHS.second; - } - }; - // Number of inserted nodes, used to emulate DFS ordering in the priority // queue when insertions are equal. unsigned long Counter = 0; @@ -219,7 +213,7 @@ class UnexploredFirstPriorityQueue : public WorkList { VisitedTimesMap NumReached; // The top item is the largest one. - llvm::PriorityQueue, ExplorationComparator> + llvm::PriorityQueue, llvm::less_second> queue; public: @@ -267,12 +261,6 @@ class UnexploredFirstPriorityLocationQueue : public WorkList { using QueuePriority = std::pair; using QueueItem = std::pair; - struct ExplorationComparator { - bool operator() (const QueueItem &LHS, const QueueItem &RHS) { - return LHS.second < RHS.second; - } - }; - // Number of inserted nodes, used to emulate DFS ordering in the priority // queue when insertions are equal. unsigned long Counter = 0; @@ -281,7 +269,7 @@ class UnexploredFirstPriorityLocationQueue : public WorkList { VisitedTimesMap NumReached; // The top item is the largest one. - llvm::PriorityQueue, ExplorationComparator> + llvm::PriorityQueue, llvm::less_second> queue; public: diff --git a/llvm/lib/Bitcode/Writer/ValueEnumerator.cpp b/llvm/lib/Bitcode/Writer/ValueEnumerator.cpp index 18157d57dcb9..81dc9677a8e0 100644 --- a/llvm/lib/Bitcode/Writer/ValueEnumerator.cpp +++ b/llvm/lib/Bitcode/Writer/ValueEnumerator.cpp @@ -257,9 +257,7 @@ static void predictValueUseListOrderImpl(const Value *V, const Function *F, return LU->getOperandNo() > RU->getOperandNo(); }); - if (llvm::is_sorted(List, [](const Entry &L, const Entry &R) { - return L.second < R.second; - })) + if (llvm::is_sorted(List, llvm::less_second())) // Order is already correct. return; diff --git a/llvm/lib/ExecutionEngine/Orc/LLJIT.cpp b/llvm/lib/ExecutionEngine/Orc/LLJIT.cpp index 26d221100b98..c6442e18fca2 100644 --- a/llvm/lib/ExecutionEngine/Orc/LLJIT.cpp +++ b/llvm/lib/ExecutionEngine/Orc/LLJIT.cpp @@ -521,11 +521,7 @@ GlobalCtorDtorScraper::operator()(ThreadSafeModule TSM, for (auto E : COrDtors) InitsOrDeInits.push_back(std::make_pair(E.Func, E.Priority)); - llvm::sort(InitsOrDeInits, - [](const std::pair &LHS, - const std::pair &RHS) { - return LHS.second < RHS.second; - }); + llvm::sort(InitsOrDeInits, llvm::less_second()); auto *InitOrDeInitFuncEntryBlock = BasicBlock::Create(Ctx, "entry", InitOrDeInitFunc); diff --git a/llvm/lib/IR/AsmWriter.cpp b/llvm/lib/IR/AsmWriter.cpp index 66595bcfb9aa..44096eba86a2 100644 --- a/llvm/lib/IR/AsmWriter.cpp +++ b/llvm/lib/IR/AsmWriter.cpp @@ -223,9 +223,7 @@ predictValueUseListOrder(const Value *V, unsigned ID, const OrderMap &OM) { return LU->getOperandNo() > RU->getOperandNo(); }); - if (llvm::is_sorted(List, [](const Entry &L, const Entry &R) { - return L.second < R.second; - })) + if (llvm::is_sorted(List, llvm::less_second())) // Order is already correct. return {}; diff --git a/llvm/lib/IR/Metadata.cpp b/llvm/lib/IR/Metadata.cpp index b5ea17f77914..55db2d22dcae 100644 --- a/llvm/lib/IR/Metadata.cpp +++ b/llvm/lib/IR/Metadata.cpp @@ -282,9 +282,7 @@ void ReplaceableMetadataImpl::replaceAllUsesWith(Metadata *MD) { // Copy out uses since UseMap will get touched below. using UseTy = std::pair>; SmallVector Uses(UseMap.begin(), UseMap.end()); - llvm::sort(Uses, [](const UseTy &L, const UseTy &R) { - return L.second.second < R.second.second; - }); + llvm::sort(Uses, llvm::less_second()); for (const auto &Pair : Uses) { // Check that this Ref hasn't disappeared after RAUW (when updating a // previous Ref). diff --git a/llvm/lib/Target/AMDGPU/AMDGPUPromoteAlloca.cpp b/llvm/lib/Target/AMDGPU/AMDGPUPromoteAlloca.cpp index 4246ec671a0f..5a4426ba8113 100644 --- a/llvm/lib/Target/AMDGPU/AMDGPUPromoteAlloca.cpp +++ b/llvm/lib/Target/AMDGPU/AMDGPUPromoteAlloca.cpp @@ -778,10 +778,7 @@ bool AMDGPUPromoteAllocaImpl::hasSufficientLocalMem(const Function &F) { // // FIXME: We should really do something to fix the addresses to a more optimal // value instead - llvm::sort(AllocatedSizes, [](std::pair LHS, - std::pair RHS) { - return LHS.second < RHS.second; - }); + llvm::sort(AllocatedSizes, llvm::less_second()); // Check how much local memory is being used by global objects CurrentLocalMemUsage = 0; diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp index 3706f7e5a21b..2636acaf1604 100644 --- a/llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp +++ b/llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp @@ -2131,8 +2131,7 @@ SDValue WebAssemblyTargetLowering::LowerBUILD_VECTOR(SDValue Op, auto GetMostCommon = [](auto &Counts) { auto CommonIt = - std::max_element(Counts.begin(), Counts.end(), - [](auto A, auto B) { return A.second < B.second; }); + std::max_element(Counts.begin(), Counts.end(), llvm::less_second()); assert(CommonIt != Counts.end() && "Unexpected all-undef build_vector"); return *CommonIt; }; diff --git a/llvm/lib/Transforms/IPO/LowerTypeTests.cpp b/llvm/lib/Transforms/IPO/LowerTypeTests.cpp index d089f8c9c7c4..d5f1d291f41f 100644 --- a/llvm/lib/Transforms/IPO/LowerTypeTests.cpp +++ b/llvm/lib/Transforms/IPO/LowerTypeTests.cpp @@ -2200,11 +2200,7 @@ bool LowerTypeTestsModule::lower() { } Sets.emplace_back(I, MaxUniqueId); } - llvm::sort(Sets, - [](const std::pair &S1, - const std::pair &S2) { - return S1.second < S2.second; - }); + llvm::sort(Sets, llvm::less_second()); // For each disjoint set we found... for (const auto &S : Sets) { diff --git a/llvm/lib/Transforms/Scalar/GVNSink.cpp b/llvm/lib/Transforms/Scalar/GVNSink.cpp index 1d0e2ae36ece..720b8e71fd56 100644 --- a/llvm/lib/Transforms/Scalar/GVNSink.cpp +++ b/llvm/lib/Transforms/Scalar/GVNSink.cpp @@ -658,12 +658,7 @@ Optional GVNSink::analyzeInstructionForSinking( VNums[N]++; } unsigned VNumToSink = - std::max_element(VNums.begin(), VNums.end(), - [](const std::pair &I, - const std::pair &J) { - return I.second < J.second; - }) - ->first; + std::max_element(VNums.begin(), VNums.end(), llvm::less_second())->first; if (VNums[VNumToSink] == 1) // Can't sink anything! diff --git a/llvm/lib/Transforms/Scalar/JumpThreading.cpp b/llvm/lib/Transforms/Scalar/JumpThreading.cpp index b4b2b6cacd19..71f757a3c843 100644 --- a/llvm/lib/Transforms/Scalar/JumpThreading.cpp +++ b/llvm/lib/Transforms/Scalar/JumpThreading.cpp @@ -1559,10 +1559,8 @@ findMostPopularDest(BasicBlock *BB, DestPopularity[PredToDest.second]++; // Find the most popular dest. - using VT = decltype(DestPopularity)::value_type; auto MostPopular = std::max_element( - DestPopularity.begin(), DestPopularity.end(), - [](const VT &L, const VT &R) { return L.second < R.second; }); + DestPopularity.begin(), DestPopularity.end(), llvm::less_second()); // Okay, we have finally picked the most popular destination. return MostPopular->first;