clang-format: Fix the counting of leading whitespace in tok::unknown tokens
Previously, all whitespace characters would increase the starting
column, which doesn't make sense. This fixes a problem, e.g. with the
length calculation in JS template strings.
llvm-svn: 257267
diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index 2ea3b07..2689368 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/lib/Format/Format.cpp
@@ -1239,6 +1239,8 @@
FormatTok->Type = TT_ImplicitStringLiteral;
break;
}
+ if (FormatTok->Type == TT_ImplicitStringLiteral)
+ break;
}
if (FormatTok->is(TT_ImplicitStringLiteral))
diff --git a/clang/unittests/Format/FormatTestJS.cpp b/clang/unittests/Format/FormatTestJS.cpp
index a35a86e..4e974d7 100644
--- a/clang/unittests/Format/FormatTestJS.cpp
+++ b/clang/unittests/Format/FormatTestJS.cpp
@@ -956,6 +956,9 @@
"var y;");
verifyFormat("var x = `\"`; // comment with matching quote \"\n"
"var y;");
+ EXPECT_EQ("it(`'aaaaaaaaaaaaaaa `, aaaaaaaaa);",
+ format("it(`'aaaaaaaaaaaaaaa `, aaaaaaaaa) ;",
+ getGoogleJSStyleWithColumns(40)));
// Backticks in a comment - not a template string.
EXPECT_EQ("var x = 1 // `/*a`;\n"
" ;",