diff --git a/clang-tools-extra/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp b/clang-tools-extra/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp --- a/clang-tools-extra/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp +++ b/clang-tools-extra/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp @@ -193,8 +193,7 @@ // Sort replacements per file to keep consistent behavior when // clang-apply-replacements run on differents machine. for (auto &FileAndReplacements : GroupedReplacements) { - llvm::sort(FileAndReplacements.second.begin(), - FileAndReplacements.second.end()); + llvm::sort(FileAndReplacements.second); } return GroupedReplacements; diff --git a/clang-tools-extra/clang-include-fixer/SymbolIndexManager.cpp b/clang-tools-extra/clang-include-fixer/SymbolIndexManager.cpp --- a/clang-tools-extra/clang-include-fixer/SymbolIndexManager.cpp +++ b/clang-tools-extra/clang-include-fixer/SymbolIndexManager.cpp @@ -59,7 +59,7 @@ } // Sort by the gathered scores. Use file name as a tie breaker so we can // deduplicate. - llvm::sort(Symbols.begin(), Symbols.end(), + llvm::sort(Symbols, [&](const SymbolAndSignals &A, const SymbolAndSignals &B) { auto AS = Score[A.Symbol.getFilePath()]; auto BS = Score[B.Symbol.getFilePath()]; diff --git a/clang-tools-extra/clang-tidy/readability/MagicNumbersCheck.cpp b/clang-tools-extra/clang-tidy/readability/MagicNumbersCheck.cpp --- a/clang-tools-extra/clang-tidy/readability/MagicNumbersCheck.cpp +++ b/clang-tools-extra/clang-tidy/readability/MagicNumbersCheck.cpp @@ -104,10 +104,8 @@ consumeError(StatusOrErr.takeError()); IgnoredDoublePointValues.push_back(DoubleValue.convertToDouble()); } - llvm::sort(IgnoredFloatingPointValues.begin(), - IgnoredFloatingPointValues.end()); - llvm::sort(IgnoredDoublePointValues.begin(), - IgnoredDoublePointValues.end()); + llvm::sort(IgnoredFloatingPointValues); + llvm::sort(IgnoredDoublePointValues); } } diff --git a/clang-tools-extra/clangd/index/StdLib.cpp b/clang-tools-extra/clangd/index/StdLib.cpp --- a/clang-tools-extra/clangd/index/StdLib.cpp +++ b/clang-tools-extra/clangd/index/StdLib.cpp @@ -80,7 +80,7 @@ "#endif\n", Mandatory); - llvm::sort(Headers.begin(), Headers.end()); + llvm::sort(Headers); auto Last = std::unique(Headers.begin(), Headers.end()); for (auto Header = Headers.begin(); Header != Last; ++Header) { OS << llvm::formatv("#if __has_include({0})\n" diff --git a/clang/include/clang/Basic/Attr.td b/clang/include/clang/Basic/Attr.td --- a/clang/include/clang/Basic/Attr.td +++ b/clang/include/clang/Basic/Attr.td @@ -2703,7 +2703,7 @@ template ParsedTargetAttr parse(Compare cmp) const { ParsedTargetAttr Attrs = parse(); - llvm::sort(std::begin(Attrs.Features), std::end(Attrs.Features), cmp); + llvm::sort(Attrs.Features, cmp); return Attrs; } diff --git a/clang/lib/Driver/Multilib.cpp b/clang/lib/Driver/Multilib.cpp --- a/clang/lib/Driver/Multilib.cpp +++ b/clang/lib/Driver/Multilib.cpp @@ -267,10 +267,9 @@ } // Sort multilibs by priority and select the one with the highest priority. - llvm::sort(Filtered.begin(), Filtered.end(), - [](const Multilib &a, const Multilib &b) -> bool { - return a.priority() > b.priority(); - }); + llvm::sort(Filtered, [](const Multilib &a, const Multilib &b) -> bool { + return a.priority() > b.priority(); + }); if (Filtered[0].priority() > Filtered[1].priority()) { M = Filtered[0]; diff --git a/clang/lib/Frontend/FrontendAction.cpp b/clang/lib/Frontend/FrontendAction.cpp --- a/clang/lib/Frontend/FrontendAction.cpp +++ b/clang/lib/Frontend/FrontendAction.cpp @@ -414,7 +414,7 @@ // 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, llvm::less_first()); for (auto &H : Headers) { // Include this header as part of the umbrella directory. Module->addTopHeader(H.second); @@ -1205,4 +1205,3 @@ WrapperFrontendAction::WrapperFrontendAction( std::unique_ptr WrappedAction) : WrappedAction(std::move(WrappedAction)) {} - diff --git a/clang/lib/Sema/AnalysisBasedWarnings.cpp b/clang/lib/Sema/AnalysisBasedWarnings.cpp --- a/clang/lib/Sema/AnalysisBasedWarnings.cpp +++ b/clang/lib/Sema/AnalysisBasedWarnings.cpp @@ -1575,8 +1575,7 @@ // Sort the uses by their SourceLocations. While not strictly // guaranteed to produce them in line/column order, this will provide // a stable ordering. - llvm::sort(vec->begin(), vec->end(), - [](const UninitUse &a, const UninitUse &b) { + llvm::sort(*vec, [](const UninitUse &a, const UninitUse &b) { // Prefer a more confident report over a less confident one. if (a.getKind() != b.getKind()) return a.getKind() > b.getKind(); diff --git a/lldb/source/Interpreter/OptionValueArray.cpp b/lldb/source/Interpreter/OptionValueArray.cpp --- a/lldb/source/Interpreter/OptionValueArray.cpp +++ b/lldb/source/Interpreter/OptionValueArray.cpp @@ -218,7 +218,7 @@ if (num_remove_indexes) { // Sort and then erase in reverse so indexes are always valid if (num_remove_indexes > 1) { - llvm::sort(remove_indexes.begin(), remove_indexes.end()); + llvm::sort(remove_indexes); for (std::vector::const_reverse_iterator pos = remove_indexes.rbegin(), end = remove_indexes.rend(); diff --git a/lldb/source/Interpreter/OptionValueFileSpecList.cpp b/lldb/source/Interpreter/OptionValueFileSpecList.cpp --- a/lldb/source/Interpreter/OptionValueFileSpecList.cpp +++ b/lldb/source/Interpreter/OptionValueFileSpecList.cpp @@ -137,7 +137,7 @@ size_t num_remove_indexes = remove_indexes.size(); if (num_remove_indexes) { // Sort and then erase in reverse so indexes are always valid - llvm::sort(remove_indexes.begin(), remove_indexes.end()); + llvm::sort(remove_indexes); for (size_t j = num_remove_indexes - 1; j < num_remove_indexes; ++j) { m_current_value.Remove(j); } diff --git a/lldb/source/Interpreter/OptionValuePathMappings.cpp b/lldb/source/Interpreter/OptionValuePathMappings.cpp --- a/lldb/source/Interpreter/OptionValuePathMappings.cpp +++ b/lldb/source/Interpreter/OptionValuePathMappings.cpp @@ -174,7 +174,7 @@ } // Sort and then erase in reverse so indexes are always valid - llvm::sort(remove_indexes.begin(), remove_indexes.end()); + llvm::sort(remove_indexes); for (auto index : llvm::reverse(remove_indexes)) m_path_mappings.Remove(index, m_notify_changes); NotifyValueChanged(); diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp --- a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp +++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp @@ -1430,10 +1430,9 @@ std::vector sorted_items; sorted_items.reserve(source_map.size()); sorted_items.assign(source_map.begin(), source_map.end()); - llvm::sort(sorted_items.begin(), sorted_items.end(), - [](const PairType &lhs, const PairType &rhs) { - return lhs.second < rhs.second; - }); + llvm::sort(sorted_items, [](const PairType &lhs, const PairType &rhs) { + return lhs.second < rhs.second; + }); for (const auto &item : sorted_items) { DeclFromUser user_decl(const_cast(item.first)); diff --git a/lldb/source/Symbol/ArmUnwindInfo.cpp b/lldb/source/Symbol/ArmUnwindInfo.cpp --- a/lldb/source/Symbol/ArmUnwindInfo.cpp +++ b/lldb/source/Symbol/ArmUnwindInfo.cpp @@ -65,7 +65,7 @@ // Sort the entries in the exidx section. The entries should be sorted inside // the section but some old compiler isn't sorted them. - llvm::sort(m_exidx_entries.begin(), m_exidx_entries.end()); + llvm::sort(m_exidx_entries); } ArmUnwindInfo::~ArmUnwindInfo() = default; diff --git a/lldb/source/Symbol/CompileUnit.cpp b/lldb/source/Symbol/CompileUnit.cpp --- a/lldb/source/Symbol/CompileUnit.cpp +++ b/lldb/source/Symbol/CompileUnit.cpp @@ -63,7 +63,7 @@ sorted_functions.reserve(m_functions_by_uid.size()); for (auto &p : m_functions_by_uid) sorted_functions.push_back(p.second); - llvm::sort(sorted_functions.begin(), sorted_functions.end(), + llvm::sort(sorted_functions, [](const lldb::FunctionSP &a, const lldb::FunctionSP &b) { return a->GetID() < b->GetID(); }); diff --git a/lldb/source/Symbol/Symtab.cpp b/lldb/source/Symbol/Symtab.cpp --- a/lldb/source/Symbol/Symtab.cpp +++ b/lldb/source/Symbol/Symtab.cpp @@ -1137,7 +1137,7 @@ } if (!symbol_indexes.empty()) { - llvm::sort(symbol_indexes.begin(), symbol_indexes.end()); + llvm::sort(symbol_indexes); symbol_indexes.erase( std::unique(symbol_indexes.begin(), symbol_indexes.end()), symbol_indexes.end()); diff --git a/lldb/source/Target/DynamicRegisterInfo.cpp b/lldb/source/Target/DynamicRegisterInfo.cpp --- a/lldb/source/Target/DynamicRegisterInfo.cpp +++ b/lldb/source/Target/DynamicRegisterInfo.cpp @@ -483,7 +483,7 @@ end = m_invalidate_regs_map.end(); pos != end; ++pos) { if (pos->second.size() > 1) { - llvm::sort(pos->second.begin(), pos->second.end()); + llvm::sort(pos->second); reg_num_collection::iterator unique_end = std::unique(pos->second.begin(), pos->second.end()); if (unique_end != pos->second.end()) diff --git a/lldb/source/Target/Target.cpp b/lldb/source/Target/Target.cpp --- a/lldb/source/Target/Target.cpp +++ b/lldb/source/Target/Target.cpp @@ -776,7 +776,7 @@ for (auto bp_name : m_breakpoint_names) { names.push_back(bp_name.first.AsCString()); } - llvm::sort(names.begin(), names.end()); + llvm::sort(names); } bool Target::ProcessIsValid() { diff --git a/lldb/source/Utility/ReproducerProvider.cpp b/lldb/source/Utility/ReproducerProvider.cpp --- a/lldb/source/Utility/ReproducerProvider.cpp +++ b/lldb/source/Utility/ReproducerProvider.cpp @@ -131,7 +131,7 @@ return; // Remove duplicates. - llvm::sort(m_symbol_files.begin(), m_symbol_files.end()); + llvm::sort(m_symbol_files); m_symbol_files.erase( std::unique(m_symbol_files.begin(), m_symbol_files.end()), m_symbol_files.end()); diff --git a/lldb/source/Utility/Timer.cpp b/lldb/source/Utility/Timer.cpp --- a/lldb/source/Utility/Timer.cpp +++ b/lldb/source/Utility/Timer.cpp @@ -150,7 +150,7 @@ return; // Later code will break without any elements. // Sort by time - llvm::sort(sorted.begin(), sorted.end(), CategoryMapIteratorSortCriterion); + llvm::sort(sorted, CategoryMapIteratorSortCriterion); for (const auto &stats : sorted) s->Printf("%.9f sec (total: %.3fs; child: %.3fs; count: %" PRIu64 diff --git a/llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp b/llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp --- a/llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp +++ b/llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp @@ -544,7 +544,7 @@ } // Dedup and order the sources. - llvm::sort(Sources.begin(), Sources.end()); + llvm::sort(Sources); Sources.erase(std::unique(Sources.begin(), Sources.end()), Sources.end()); for (StringRef Name : Sources) diff --git a/llvm/unittests/ADT/SmallPtrSetTest.cpp b/llvm/unittests/ADT/SmallPtrSetTest.cpp --- a/llvm/unittests/ADT/SmallPtrSetTest.cpp +++ b/llvm/unittests/ADT/SmallPtrSetTest.cpp @@ -299,7 +299,7 @@ // Sort. We should hit the first element just once and the final element N // times. - llvm::sort(std::begin(Found), std::end(Found)); + llvm::sort(Found); for (auto F = std::begin(Found), E = std::end(Found); F != E; ++F) EXPECT_EQ(F - Found + 1, *F); } diff --git a/llvm/unittests/TextAPI/TextStubV1Tests.cpp b/llvm/unittests/TextAPI/TextStubV1Tests.cpp --- a/llvm/unittests/TextAPI/TextStubV1Tests.cpp +++ b/llvm/unittests/TextAPI/TextStubV1Tests.cpp @@ -102,7 +102,7 @@ ExportedSymbol{Sym->getKind(), std::string(Sym->getName()), Sym->isWeakDefined(), Sym->isThreadLocalValue()}); } - llvm::sort(Exports.begin(), Exports.end()); + llvm::sort(Exports); EXPECT_EQ(sizeof(TBDv1Symbols) / sizeof(ExportedSymbol), Exports.size()); EXPECT_TRUE( diff --git a/llvm/unittests/TextAPI/TextStubV2Tests.cpp b/llvm/unittests/TextAPI/TextStubV2Tests.cpp --- a/llvm/unittests/TextAPI/TextStubV2Tests.cpp +++ b/llvm/unittests/TextAPI/TextStubV2Tests.cpp @@ -103,7 +103,7 @@ ExportedSymbol{Sym->getKind(), std::string(Sym->getName()), Sym->isWeakDefined(), Sym->isThreadLocalValue()}); } - llvm::sort(Exports.begin(), Exports.end()); + llvm::sort(Exports); EXPECT_EQ(sizeof(TBDv2Symbols) / sizeof(ExportedSymbol), Exports.size()); EXPECT_TRUE( diff --git a/llvm/unittests/TextAPI/TextStubV3Tests.cpp b/llvm/unittests/TextAPI/TextStubV3Tests.cpp --- a/llvm/unittests/TextAPI/TextStubV3Tests.cpp +++ b/llvm/unittests/TextAPI/TextStubV3Tests.cpp @@ -111,7 +111,7 @@ ExportedSymbol{Sym->getKind(), std::string(Sym->getName()), Sym->isWeakDefined(), Sym->isThreadLocalValue()}); } - llvm::sort(Exports.begin(), Exports.end()); + llvm::sort(Exports); EXPECT_EQ(sizeof(TBDv3Symbols) / sizeof(ExportedSymbol), Exports.size()); EXPECT_TRUE( @@ -203,7 +203,7 @@ Sym->isWeakDefined(), Sym->isThreadLocalValue()}); } - llvm::sort(Exports.begin(), Exports.end()); + llvm::sort(Exports); EXPECT_EQ(sizeof(TBDv3Symbols) / sizeof(ExportedSymbol), Exports.size()); EXPECT_TRUE( @@ -228,7 +228,7 @@ Sym->isWeakDefined(), Sym->isThreadLocalValue()}); } - llvm::sort(Exports.begin(), Exports.end()); + llvm::sort(Exports); ExportedSymbolSeq DocumentSymbols{ {SymbolKind::GlobalSymbol, "_sym5", false, false}, diff --git a/llvm/unittests/TextAPI/TextStubV4Tests.cpp b/llvm/unittests/TextAPI/TextStubV4Tests.cpp --- a/llvm/unittests/TextAPI/TextStubV4Tests.cpp +++ b/llvm/unittests/TextAPI/TextStubV4Tests.cpp @@ -125,9 +125,9 @@ Sym->isReexported() ? Reexports.emplace_back(std::move(temp)) : Exports.emplace_back(std::move(temp)); } - llvm::sort(Exports.begin(), Exports.end()); - llvm::sort(Reexports.begin(), Reexports.end()); - llvm::sort(Undefineds.begin(), Undefineds.end()); + llvm::sort(Exports); + llvm::sort(Reexports); + llvm::sort(Undefineds); static ExportedSymbol ExpectedExportedSymbols[] = { {SymbolKind::GlobalSymbol, "_symA", false, false}, @@ -296,9 +296,9 @@ Sym->isReexported() ? Reexports.emplace_back(std::move(Temp)) : Exports.emplace_back(std::move(Temp)); } - llvm::sort(Exports.begin(), Exports.end()); - llvm::sort(Reexports.begin(), Reexports.end()); - llvm::sort(Undefineds.begin(), Undefineds.end()); + llvm::sort(Exports); + llvm::sort(Reexports); + llvm::sort(Undefineds); static ExportedSymbol ExpectedExportedSymbols[] = { {SymbolKind::GlobalSymbol, "_symA", false, false},