[PATCH] D20200: 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:26:48 PDT 2016
This revision was automatically updated to reflect the committed changes.
Closed by commit rL269282: clang-format: [JS] respect clang-format off when requoting strings. (authored by mprobst).
Changed prior to commit:
http://reviews.llvm.org/D20200?vs=57014&id=57018#toc
Repository:
rL LLVM
http://reviews.llvm.org/D20200
Files:
cfe/trunk/lib/Format/Format.cpp
cfe/trunk/unittests/Format/FormatTestJS.cpp
Index: cfe/trunk/lib/Format/Format.cpp
===================================================================
--- cfe/trunk/lib/Format/Format.cpp
+++ cfe/trunk/lib/Format/Format.cpp
@@ -1652,7 +1652,7 @@
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`.
Index: cfe/trunk/unittests/Format/FormatTestJS.cpp
===================================================================
--- cfe/trunk/unittests/Format/FormatTestJS.cpp
+++ cfe/trunk/unittests/Format/FormatTestJS.cpp
@@ -1236,6 +1236,14 @@
// 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) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D20200.57018.patch
Type: text/x-patch
Size: 1390 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160512/b5f59adb/attachment.bin>
More information about the cfe-commits
mailing list