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

Owen Pan via cfe-commits cfe-commits at lists.llvm.org
Mon Dec 23 19:31:55 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;) {
----------------
owenca wrote:

Because it's used in `SearchFrom < Size`. My previous version using `for (;;)` caused a crash in ToolingTests.

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


More information about the cfe-commits mailing list