From: Daniel Jasper Date: Wed, 17 Dec 2014 09:11:08 +0000 (+0000) Subject: clang-format: Fix incorrect calculation of token lenghts. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=666557c0af578402d4372768452bfb2ac4bf4f1b;p=clang clang-format: Fix incorrect calculation of token lenghts. This led, e.g. to break JavaScript regex literals too early. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@224419 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Format/Format.cpp b/lib/Format/Format.cpp index ca0cce4085..81c9e130d5 100644 --- a/lib/Format/Format.cpp +++ b/lib/Format/Format.cpp @@ -889,7 +889,6 @@ private: Column += Style.TabWidth - Column % Style.TabWidth; break; case '\\': - ++Column; if (i + 1 == e || (FormatTok->TokenText[i + 1] != '\r' && FormatTok->TokenText[i + 1] != '\n')) FormatTok->Type = TT_ImplicitStringLiteral; diff --git a/unittests/Format/FormatTestJS.cpp b/unittests/Format/FormatTestJS.cpp index 1d12d32044..780b02f746 100644 --- a/unittests/Format/FormatTestJS.cpp +++ b/unittests/Format/FormatTestJS.cpp @@ -482,6 +482,8 @@ TEST_F(FormatTestJS, RegexLiteralLength) { verifyFormat("var regex =\n" " /aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/;", getGoogleJSStyleWithColumns(60)); + verifyFormat("var regex = /\\xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/;", + getGoogleJSStyleWithColumns(50)); } TEST_F(FormatTestJS, RegexLiteralExamples) {