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

MyDeveloperDay via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Jul 5 10:08:19 PDT 2023


MyDeveloperDay added inline comments.


================
Comment at: clang/lib/Format/BreakableToken.cpp:199
 
+    if (EscapeSequence && Advance == 2) {
+      switch (Text[1]) {
----------------
sstwcw wrote:
> MyDeveloperDay wrote:
> > Can we add a unit test for escape sequences > \X which I assume this handles
> There are already tests that verify that the string does not get broken inside an escape sequence in `BreaksWideAndNSStringLiterals` and `DoNotBreakStringLiteralsInEscapeSequence`.  And escape sequences longer than 1 character following the backslash should not begin with one of these letters.  So I don't see what tests I should add.
I was thinking about your tests having a test case which shows it shouldn't break, in case someone add case 'x' into your code, i.e. asserting the negative. 


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