r269282 - clang-format: [JS] respect clang-format off when requoting strings.
Martin Probst via cfe-commits
cfe-commits at lists.llvm.org
Thu May 12 04:20:32 PDT 2016
Author: mprobst
Date: Thu May 12 06:20:32 2016
New Revision: 269282
URL: http://llvm.org/viewvc/llvm-project?rev=269282&view=rev
Log:
clang-format: [JS] respect clang-format off when requoting strings.
Reviewers: djasper
Subscribers: klimek, cfe-commits
Differential Revision: http://reviews.llvm.org/D20200
Modified:
cfe/trunk/lib/Format/Format.cpp
cfe/trunk/unittests/Format/FormatTestJS.cpp
Modified: cfe/trunk/lib/Format/Format.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/Format.cpp?rev=269282&r1=269281&r2=269282&view=diff
==============================================================================
--- cfe/trunk/lib/Format/Format.cpp (original)
+++ cfe/trunk/lib/Format/Format.cpp Thu May 12 06:20:32 2016
@@ -1652,7 +1652,7 @@ private:
for (FormatToken *FormatTok = Line->First; FormatTok;
FormatTok = FormatTok->Next) {
StringRef Input = FormatTok->TokenText;
- if (!FormatTok->isStringLiteral() ||
+ if (FormatTok->Finalized || !FormatTok->isStringLiteral() ||
// NB: testing for not starting with a double quote to avoid
// breaking
// `template strings`.
Modified: cfe/trunk/unittests/Format/FormatTestJS.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestJS.cpp?rev=269282&r1=269281&r2=269282&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTestJS.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTestJS.cpp Thu May 12 06:20:32 2016
@@ -1236,6 +1236,14 @@ TEST_F(FormatTestJS, RequoteStringsSingl
// Code below fits into 15 chars *after* removing the \ escape.
verifyFormat("var x = 'fo\"o';", "var x = \"fo\\\"o\";",
getGoogleJSStyleWithColumns(15));
+ verifyFormat("// clang-format off\n"
+ "let x = \"double\";\n"
+ "// clang-format on\n"
+ "let x = 'single';\n",
+ "// clang-format off\n"
+ "let x = \"double\";\n"
+ "// clang-format on\n"
+ "let x = \"single\";\n");
}
TEST_F(FormatTestJS, RequoteStringsDouble) {
More information about the cfe-commits
mailing list