diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp index d9952f5d5d6d..3abe569f8770 100644 --- a/clang/lib/Format/Format.cpp +++ b/clang/lib/Format/Format.cpp @@ -34,6 +34,7 @@ #include "clang/Lex/Lexer.h" #include "clang/Tooling/Inclusions/HeaderIncludes.h" #include "llvm/ADT/STLExtras.h" +#include "llvm/ADT/Sequence.h" #include "llvm/ADT/StringRef.h" #include "llvm/Support/Allocator.h" #include "llvm/Support/Debug.h" @@ -44,7 +45,6 @@ #include #include #include -#include #include #include @@ -2521,9 +2521,8 @@ static void sortCppIncludes(const FormatStyle &Style, unsigned IncludesBlockSize = IncludesEndOffset - IncludesBeginOffset; if (!affectsRange(Ranges, IncludesBeginOffset, IncludesEndOffset)) return; - SmallVector Indices; - Indices.resize(Includes.size()); - std::iota(Indices.begin(), Indices.end(), 0); + SmallVector Indices = + llvm::to_vector<16>(llvm::seq(0, Includes.size())); if (Style.SortIncludes == FormatStyle::SI_CaseInsensitive) { llvm::stable_sort(Indices, [&](unsigned LHSI, unsigned RHSI) { @@ -2750,10 +2749,8 @@ static void sortJavaImports(const FormatStyle &Style, if (!affectsRange(Ranges, ImportsBeginOffset, ImportsEndOffset)) return; - SmallVector Indices; - Indices.resize(Imports.size()); - std::iota(Indices.begin(), Indices.end(), 0); - + SmallVector Indices = + llvm::to_vector<16>(llvm::seq(0, Imports.size())); SmallVector JavaImportGroups; JavaImportGroups.reserve(Imports.size()); for (const JavaImportDirective &Import : Imports)