From 5c1b5f8d06ddedb5154ef7ff51b6238ebf4489ff Mon Sep 17 00:00:00 2001 From: Daniel Jasper Date: Thu, 2 Jul 2015 14:01:34 +0000 Subject: [PATCH] clang-format: [JS] Fix bug in regex literal parsing. The lexer wasn't properly reset leading to unexpected deletions. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@241262 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Format/Format.cpp | 1 + unittests/Format/FormatTestJS.cpp | 1 + 2 files changed, 2 insertions(+) diff --git a/lib/Format/Format.cpp b/lib/Format/Format.cpp index b4ec445b55..6e2012eb0f 100644 --- a/lib/Format/Format.cpp +++ b/lib/Format/Format.cpp @@ -1227,6 +1227,7 @@ private: getFormattingLangOpts(Style), Buffer.begin(), Buffer.begin() + Offset, Buffer.end())); Lex->SetKeepWhitespaceMode(true); + TrailingWhitespace = 0; } }; diff --git a/unittests/Format/FormatTestJS.cpp b/unittests/Format/FormatTestJS.cpp index 83c21183df..40a2a1ffe6 100644 --- a/unittests/Format/FormatTestJS.cpp +++ b/unittests/Format/FormatTestJS.cpp @@ -631,6 +631,7 @@ TEST_F(FormatTestJS, RegexLiteralSpecialCharacters) { "var x = 0;", format("var regex = /\\/*/;\n" "var x=0;")); + EXPECT_EQ("var x = /a\\//;", format("var x = /a\\// \n;")); verifyFormat("var regex = /\"/;", getGoogleJSStyleWithColumns(16)); verifyFormat("var regex =\n" " /\"/;", -- 2.40.0