Author: Kazu Hirata Date: 2022-06-04T21:23:18-07:00 New Revision: 4969a6924dc1644d4fa6cf89a33b598e647f5513
URL: https://github.com/llvm/llvm-project/commit/4969a6924dc1644d4fa6cf89a33b598e647f5513 DIFF: https://github.com/llvm/llvm-project/commit/4969a6924dc1644d4fa6cf89a33b598e647f5513.diff LOG: Use llvm::less_first (NFC) Added: Modified: clang/lib/AST/Interp/Function.cpp clang/lib/Frontend/FrontendAction.cpp clang/lib/Sema/SemaDeclCXX.cpp clang/lib/Sema/SemaStmtAsm.cpp clang/lib/StaticAnalyzer/Frontend/AnalyzerHelpFlags.cpp lldb/source/Plugins/SymbolFile/NativePDB/UdtRecordCompleter.cpp lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp llvm/include/llvm/ExecutionEngine/Orc/Core.h llvm/lib/CodeGen/MIRCanonicalizerPass.cpp llvm/lib/IR/Attributes.cpp llvm/lib/ObjCopy/MachO/MachOWriter.cpp llvm/lib/ObjectYAML/MachOEmitter.cpp llvm/tools/dsymutil/DebugMap.cpp llvm/tools/llvm-reduce/deltas/ReduceAttributes.cpp Removed: ################################################################################ diff --git a/clang/lib/AST/Interp/Function.cpp b/clang/lib/AST/Interp/Function.cpp index 0ed13a92aa38d..6ba97df1cd30e 100644 --- a/clang/lib/AST/Interp/Function.cpp +++ b/clang/lib/AST/Interp/Function.cpp @@ -34,8 +34,7 @@ Function::ParamDescriptor Function::getParamDescriptor(unsigned Offset) const { SourceInfo Function::getSource(CodePtr PC) const { unsigned Offset = PC - getCodeBegin(); using Elem = std::pair<unsigned, SourceInfo>; - auto It = std::lower_bound(SrcMap.begin(), SrcMap.end(), Elem{Offset, {}}, - [](Elem A, Elem B) { return A.first < B.first; }); + auto It = llvm::lower_bound(SrcMap, Elem{Offset, {}}, llvm::less_first()); if (It == SrcMap.end() || It->first != Offset) llvm::report_fatal_error("missing source location"); return It->second; diff --git a/clang/lib/Frontend/FrontendAction.cpp b/clang/lib/Frontend/FrontendAction.cpp index 68c70dda12b9e..6b1f6364b13c3 100644 --- a/clang/lib/Frontend/FrontendAction.cpp +++ b/clang/lib/Frontend/FrontendAction.cpp @@ -413,11 +413,7 @@ static std::error_code collectModuleHeaderIncludes( // Sort header paths and make the header inclusion order deterministic // across diff erent 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); diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp index c470a46f58477..569b226da9233 100644 --- a/clang/lib/Sema/SemaDeclCXX.cpp +++ b/clang/lib/Sema/SemaDeclCXX.cpp @@ -5430,8 +5430,7 @@ static void DiagnoseBaseOrMemInitializerOrder( 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. diff --git a/clang/lib/Sema/SemaStmtAsm.cpp b/clang/lib/Sema/SemaStmtAsm.cpp index fbca36b1216a8..c147d26b2dff3 100644 --- a/clang/lib/Sema/SemaStmtAsm.cpp +++ b/clang/lib/Sema/SemaStmtAsm.cpp @@ -716,10 +716,7 @@ StmtResult Sema::ActOnGCCAsmStmt(SourceLocation AsmLoc, bool IsSimple, NamedOperandList.emplace_back( 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::stable_sort(NamedOperandList, llvm::less_first()); // Find adjacent duplicate operand. SmallVector<NamedOperand, 4>::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 eb6014a0629df..7cd15f0f65954 100644 --- a/clang/lib/StaticAnalyzer/Frontend/AnalyzerHelpFlags.cpp +++ b/clang/lib/StaticAnalyzer/Frontend/AnalyzerHelpFlags.cpp @@ -101,10 +101,7 @@ USAGE: -analyzer-config <OPTION1=VALUE,OPTION2=VALUE,...> #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, diff --git a/lldb/source/Plugins/SymbolFile/NativePDB/UdtRecordCompleter.cpp b/lldb/source/Plugins/SymbolFile/NativePDB/UdtRecordCompleter.cpp index dba304420c552..30d948ae45ce9 100644 --- a/lldb/source/Plugins/SymbolFile/NativePDB/UdtRecordCompleter.cpp +++ b/lldb/source/Plugins/SymbolFile/NativePDB/UdtRecordCompleter.cpp @@ -297,10 +297,7 @@ Error UdtRecordCompleter::visitKnownMember(CVMemberRecord &cvr, void UdtRecordCompleter::complete() { // Ensure the correct order for virtual bases. - std::stable_sort(m_bases.begin(), m_bases.end(), - [](const IndexedBase &lhs, const IndexedBase &rhs) { - return lhs.first < rhs.first; - }); + llvm::stable_sort(m_bases, llvm::less_first()); std::vector<std::unique_ptr<clang::CXXBaseSpecifier>> bases; bases.reserve(m_bases.size()); diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp index cb0e2ed1171f1..d260b5f537a2b 100644 --- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp +++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp @@ -9833,10 +9833,7 @@ void ScratchTypeSystemClang::Dump(llvm::raw_ostream &output) { std::vector<KeyAndTS> sorted_typesystems; for (const auto &a : m_isolated_asts) sorted_typesystems.emplace_back(a.first, a.second.get()); - llvm::stable_sort(sorted_typesystems, - [](const KeyAndTS &lhs, const KeyAndTS &rhs) { - return lhs.first < rhs.first; - }); + llvm::stable_sort(sorted_typesystems, llvm::less_first()); // Dump each sub-AST too. for (const auto &a : sorted_typesystems) { diff --git a/llvm/include/llvm/ExecutionEngine/Orc/Core.h b/llvm/include/llvm/ExecutionEngine/Orc/Core.h index a51776880cde2..df2826b50784d 100644 --- a/llvm/include/llvm/ExecutionEngine/Orc/Core.h +++ b/llvm/include/llvm/ExecutionEngine/Orc/Core.h @@ -339,11 +339,7 @@ class SymbolLookupSet { /// 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. diff --git a/llvm/lib/CodeGen/MIRCanonicalizerPass.cpp b/llvm/lib/CodeGen/MIRCanonicalizerPass.cpp index 3205f2ebbfe2f..eea24d8e93537 100644 --- a/llvm/lib/CodeGen/MIRCanonicalizerPass.cpp +++ b/llvm/lib/CodeGen/MIRCanonicalizerPass.cpp @@ -103,10 +103,7 @@ rescheduleLexographically(std::vector<MachineInstr *> instructions, StringInstrMap.push_back({(i == std::string::npos) ? S : S.substr(i), II}); } - llvm::sort(StringInstrMap, - [](const StringInstrPair &a, const StringInstrPair &b) -> bool { - return (a.first < b.first); - }); + llvm::sort(StringInstrMap, llvm::less_first()); for (auto &II : StringInstrMap) { diff --git a/llvm/lib/IR/Attributes.cpp b/llvm/lib/IR/Attributes.cpp index 11308c33b7db2..2006d2f43b220 100644 --- a/llvm/lib/IR/Attributes.cpp +++ b/llvm/lib/IR/Attributes.cpp @@ -1054,11 +1054,7 @@ AttributeList::get(LLVMContext &C, 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) { @@ -1091,11 +1087,7 @@ AttributeList::get(LLVMContext &C, 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) { diff --git a/llvm/lib/ObjCopy/MachO/MachOWriter.cpp b/llvm/lib/ObjCopy/MachO/MachOWriter.cpp index a94764a9a0349..9b1fd58cc482a 100644 --- a/llvm/lib/ObjCopy/MachO/MachOWriter.cpp +++ b/llvm/lib/ObjCopy/MachO/MachOWriter.cpp @@ -634,9 +634,7 @@ void MachOWriter::writeTail() { } } - 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)(); diff --git a/llvm/lib/ObjectYAML/MachOEmitter.cpp b/llvm/lib/ObjectYAML/MachOEmitter.cpp index c7811520c76ef..3d06f3d0bf862 100644 --- a/llvm/lib/ObjectYAML/MachOEmitter.cpp +++ b/llvm/lib/ObjectYAML/MachOEmitter.cpp @@ -521,9 +521,7 @@ void MachOWriter::writeLinkEditData(raw_ostream &OS) { } } - llvm::sort(WriteQueue, [](const writeOperation &a, const writeOperation &b) { - return a.first < b.first; - }); + llvm::sort(WriteQueue, llvm::less_first()); for (auto writeOp : WriteQueue) { ZeroToOffset(OS, writeOp.first); diff --git a/llvm/tools/dsymutil/DebugMap.cpp b/llvm/tools/dsymutil/DebugMap.cpp index 605c1317b9c87..79b6cb2c80a21 100644 --- a/llvm/tools/dsymutil/DebugMap.cpp +++ b/llvm/tools/dsymutil/DebugMap.cpp @@ -62,9 +62,7 @@ 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, [](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)); diff --git a/llvm/tools/llvm-reduce/deltas/ReduceAttributes.cpp b/llvm/tools/llvm-reduce/deltas/ReduceAttributes.cpp index 3a2397464be76..7b870888b0d48 100644 --- a/llvm/tools/llvm-reduce/deltas/ReduceAttributes.cpp +++ b/llvm/tools/llvm-reduce/deltas/ReduceAttributes.cpp @@ -158,10 +158,7 @@ AttributeList convertAttributeRefVecToAttributeList( 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. - }); + llvm::sort(SetVec, llvm::less_first()); // All values are unique. return AttributeList::get(C, SetVec); } _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits