diff options
author | Daniel Jasper <djasper@google.com> | 2014-12-17 09:11:08 +0000 |
---|---|---|
committer | Daniel Jasper <djasper@google.com> | 2014-12-17 09:11:08 +0000 |
commit | 666557c0af578402d4372768452bfb2ac4bf4f1b (patch) | |
tree | c33286d7099dfaba1f06cbc9e51ca7ce2f3b633f | |
parent | 65c422ad3f0e74a95af524bab4bd98eb10615025 (diff) |
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
-rw-r--r-- | lib/Format/Format.cpp | 1 | ||||
-rw-r--r-- | unittests/Format/FormatTestJS.cpp | 2 |
2 files changed, 2 insertions, 1 deletions
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) { |