diff options
-rw-r--r-- | clang/lib/Format/Format.cpp | 2 | ||||
-rw-r--r-- | clang/unittests/Format/FormatTestJS.cpp | 8 |
2 files changed, 9 insertions, 1 deletions
diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp index efcecee1401..66077d8832b 100644 --- a/clang/lib/Format/Format.cpp +++ b/clang/lib/Format/Format.cpp @@ -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`. diff --git a/clang/unittests/Format/FormatTestJS.cpp b/clang/unittests/Format/FormatTestJS.cpp index 95fd2e7bb08..72d8948bb7a 100644 --- a/clang/unittests/Format/FormatTestJS.cpp +++ b/clang/unittests/Format/FormatTestJS.cpp @@ -1236,6 +1236,14 @@ TEST_F(FormatTestJS, RequoteStringsSingle) { // 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) { |