From 4a5ff88fdbd7d8646de3ec6ecfbc5fd1036dcb50 Mon Sep 17 00:00:00 2001 From: Kirill Bobyrev Date: Sun, 7 Oct 2018 14:49:41 +0000 Subject: [clangd] NFC: Migrate to LLVM STLExtras API where possible This patch improves readability by migrating `std::function(ForwardIt start, ForwardIt end, ...)` to LLVM's STLExtras range-based equivalent `llvm::function(RangeT &&Range, ...)`. Similar change in Clang: D52576. Reviewed By: sammccall Differential Revision: https://reviews.llvm.org/D52650 llvm-svn: 343937 --- clang-tools-extra/clangd/CodeComplete.cpp | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) (limited to 'clang-tools-extra/clangd/CodeComplete.cpp') diff --git a/clang-tools-extra/clangd/CodeComplete.cpp b/clang-tools-extra/clangd/CodeComplete.cpp index 9e80afbc538..9c634f5e8c4 100644 --- a/clang-tools-extra/clangd/CodeComplete.cpp +++ b/clang-tools-extra/clangd/CodeComplete.cpp @@ -306,11 +306,10 @@ struct CodeCompletionBuilder { Completion.FixIts.push_back( toTextEdit(FixIt, ASTCtx.getSourceManager(), ASTCtx.getLangOpts())); } - std::sort(Completion.FixIts.begin(), Completion.FixIts.end(), - [](const TextEdit &X, const TextEdit &Y) { - return std::tie(X.range.start.line, X.range.start.character) < - std::tie(Y.range.start.line, Y.range.start.character); - }); + llvm::sort(Completion.FixIts, [](const TextEdit &X, const TextEdit &Y) { + return std::tie(X.range.start.line, X.range.start.character) < + std::tie(Y.range.start.line, Y.range.start.character); + }); Completion.Deprecated |= (C.SemaResult->Availability == CXAvailability_Deprecated); } @@ -861,8 +860,8 @@ public: IndexRequest.IDs.size(), FetchedDocs.size()); } - std::sort( - ScoredSignatures.begin(), ScoredSignatures.end(), + llvm::sort( + ScoredSignatures, [](const ScoredSignature &L, const ScoredSignature &R) { // Ordering follows: // - Less number of parameters is better. @@ -1164,13 +1163,12 @@ llvm::SmallVector getRankedIncludes(const Symbol &Sym) { auto Includes = Sym.IncludeHeaders; // Sort in descending order by reference count and header length. - std::sort(Includes.begin(), Includes.end(), - [](const Symbol::IncludeHeaderWithReferences &LHS, - const Symbol::IncludeHeaderWithReferences &RHS) { - if (LHS.References == RHS.References) - return LHS.IncludeHeader.size() < RHS.IncludeHeader.size(); - return LHS.References > RHS.References; - }); + llvm::sort(Includes, [](const Symbol::IncludeHeaderWithReferences &LHS, + const Symbol::IncludeHeaderWithReferences &RHS) { + if (LHS.References == RHS.References) + return LHS.IncludeHeader.size() < RHS.IncludeHeader.size(); + return LHS.References > RHS.References; + }); llvm::SmallVector Headers; for (const auto &Include : Includes) Headers.push_back(Include.IncludeHeader); -- cgit v1.2.3