[PATCH] D154091: [clang-format] Recognize escape sequences when breaking strings

Björn Schäpers via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sat Jul 1 04:44:19 PDT 2023


HazardyKnusperkeks added inline comments.


================
Comment at: clang/lib/Format/BreakableToken.cpp:223
 
-  if (SpaceOffset != 0)
-    return BreakableToken::Split(SpaceOffset + 1, 0);
+  if (NewLine != 0)
+    return BreakableToken::Split(NewLine, 0);
----------------
What if the new line is after the limit?


================
Comment at: clang/lib/Format/BreakableToken.cpp:225
+    return BreakableToken::Split(NewLine, 0);
+  if (AfterSpace >= 2)
+    return BreakableToken::Split(AfterSpace, 0);
----------------
sstwcw wrote:
> Should I change the threshold from 2 to 1?
> 
> It is set to 2 because it is the old behavior.  There is already a test.
> 
> ```
> already in the test:
> "some"
> " tex"
> "t"
> 
> I expect:
> "some"
> " "
> "text"
> ```
Since it was explicit, I'd keep it that way.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D154091/new/

https://reviews.llvm.org/D154091



More information about the cfe-commits mailing list