[clang] [clang-format] Skip line splices when sorting C++ includes (PR #120680)

Emilia Kond via cfe-commits cfe-commits at lists.llvm.org
Mon Dec 23 14:59:09 PST 2024


================
@@ -3246,8 +3246,15 @@ tooling::Replacements sortCppIncludes(const FormatStyle &Style, StringRef Code,
   SmallVector<StringRef, 2> RawStringMatches;
   std::string RawStringTermination = ")\"";
 
-  for (;;) {
-    auto Pos = Code.find('\n', SearchFrom);
+  for (const auto Size = Code.size(); SearchFrom < Size;) {
----------------
rymiel wrote:

Why is the extra `Size` variable needed? Why can't it stay as `for (;;)` ?

https://github.com/llvm/llvm-project/pull/120680


More information about the cfe-commits mailing list