[PATCH] D126068: [llvm][clang][bolt][NFC] Use llvm::less_first() when applicable
lattner added a comment. This patch LGTM other than the apparent build breakage Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D126068/new/ https://reviews.llvm.org/D126068 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D126068: [llvm][clang][bolt][NFC] Use llvm::less_first() when applicable
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 , - const std::pair ) { -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 : Symbols) Entries.push_back(std::make_pair(Sym.getKey(), Sym.getValue())); - llvm::sort(Entries, [](const Entry , const Entry ) { -return LHS.first < RHS.first; - }); + llvm::sort(Entries, llvm::less_first()); for (const auto : 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 , const WriteOperation ) { -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 , -const std::pair ) { - return LHS.first < RHS.first; - }) && + assert(llvm::is_sorted(Attrs, llvm::less_first()) && "Misordered Attributes list!"); assert(llvm::all_of(Attrs, [](const std::pair ) { @@ -1055,11 +1051,7 @@ if (Attrs.empty()) return {}; - assert(llvm::is_sorted(Attrs, - [](const std::pair , -const std::pair ) { - return LHS.first < RHS.first; - }) && + assert(llvm::is_sorted(Attrs, llvm::less_first()) && "Misordered Attributes list!"); assert(llvm::none_of(Attrs, [](const std::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 , const value_type ) { - 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(Result.RangeAccessors); - llvm::sort(ExpectedRanges, [](const auto , const auto ) { -return LHS.first < RHS.first; - }); + llvm::sort(ExpectedRanges, llvm::less_first()); // clang-format off EXPECT_EQ( Index:
[PATCH] D126068: [llvm][clang][bolt][NFC] Use llvm::less_first() when applicable
steakhal created this revision. steakhal added reviewers: aaron.ballman, lattner. Herald added subscribers: ayermolo, jdoerfert, martong, mgrang, hiraditya. Herald added a reviewer: JDevlieghere. Herald added a reviewer: jhenderson. Herald added a reviewer: Szelethus. Herald added a reviewer: rafauler. Herald added a reviewer: Amir. Herald added a reviewer: maksfb. Herald added a project: All. steakhal requested review of this revision. Herald added subscribers: llvm-commits, cfe-commits, yota9, MaskRay. Herald added projects: clang, LLVM. One could reuse this functor instead of rolling out your own version. There were a couple other cases where the code was similar, but not quite the same, such as it might have an assertion in the lambda or other constructs. Thus, I've not touched any of those, as it might change the behavior in some way. As per https://discourse.llvm.org/t/submitting-simple-nfc-patches/62640/3?u=steakhal Chris Lattner > LLVM intentionally has a “yes, you can apply common sense judgement to > things” policy when it comes to code review. If you are doing mechanical > patches (e.g. adopting less_first) that apply to the entire monorepo, > then you don’t need everyone in the monorepo to sign off on it. Having > some +1 validation from someone is useful, but you don’t need everyone > whose code you touch to weigh in. Repository: rG LLVM Github Monorepo 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 , - const std::pair ) { -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 : Symbols) Entries.push_back(std::make_pair(Sym.getKey(), Sym.getValue())); - llvm::sort(Entries, [](const Entry , const Entry ) { -return LHS.first < RHS.first; - }); + llvm::sort(Entries, llvm::less_first()); for (const auto : 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 , const WriteOperation ) { -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 , -const std::pair ) { - return LHS.first < RHS.first; - }) && + assert(llvm::is_sorted(Attrs, llvm::less_first()) && "Misordered Attributes list!"); assert(llvm::all_of(Attrs, [](const std::pair ) { @@ -1055,11 +1051,7 @@ if (Attrs.empty()) return {}; - assert(llvm::is_sorted(Attrs, - [](const std::pair , -const std::pair ) { - return LHS.first < RHS.first; - }) && + assert(llvm::is_sorted(Attrs, llvm::less_first()) && "Misordered Attributes list!"); assert(llvm::none_of(Attrs, [](const std::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 ///