summaryrefslogtreecommitdiffstats
path: root/clang/unittests/Format
diff options
context:
space:
mode:
authorDaniel Jasper <djasper@google.com>2016-09-07 22:48:53 +0000
committerDaniel Jasper <djasper@google.com>2016-09-07 22:48:53 +0000
commit496c1999593d9aee2f4ea991561851ba8e712aca (patch)
tree8112d19e5af966cbe7a8e2b4fc0779bb3810c2fa /clang/unittests/Format
parent9b40f983571ae1c0fe8dd83e698060538f5cc845 (diff)
downloadbcm5719-llvm-496c1999593d9aee2f4ea991561851ba8e712aca.tar.gz
bcm5719-llvm-496c1999593d9aee2f4ea991561851ba8e712aca.zip
clang-format: [JavaScript] Do requoting in a separate pass
The attempt to fix requoting behavior in r280487 after changes to tooling::Replacements are incomplete. We essentially need to add to replacements at the same position, one to insert a line break and one to change the quoting and that's incompatible with the new tooling::Replacement API, which does not allow for order-dependent Replacements. To make the order clear, Replacements::merge() has to be used, but that requires the merged Replacement to actually refer to the changed text, which is hard to reproduce for the requoting. This change fixes the behavior by moving the requoting to a completely separate pass. The added benefit is that no weird ColumnWidth calculations are necessary anymore and this should just work even if we implement string literal splitting in the future. llvm-svn: 280874
Diffstat (limited to 'clang/unittests/Format')
-rw-r--r--clang/unittests/Format/FormatTestJS.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/clang/unittests/Format/FormatTestJS.cpp b/clang/unittests/Format/FormatTestJS.cpp
index 569f0657617..22ed04f6304 100644
--- a/clang/unittests/Format/FormatTestJS.cpp
+++ b/clang/unittests/Format/FormatTestJS.cpp
@@ -1342,6 +1342,14 @@ TEST_F(FormatTestJS, RequoteAndIndent) {
" 'double quoted string that needs wrapping');",
"let x = someVeryLongFunctionThatGoesOnAndOn("
"\"double quoted string that needs wrapping\");");
+
+ verifyFormat("let x =\n"
+ " 'foo\\'oo';\n"
+ "let x =\n"
+ " 'foo\\'oo';",
+ "let x=\"foo'oo\";\n"
+ "let x=\"foo'oo\";",
+ getGoogleJSStyleWithColumns(15));
}
TEST_F(FormatTestJS, RequoteStringsDouble) {
OpenPOWER on IntegriCloud