r257267 - clang-format: Fix the counting of leading whitespace in tok::unknown tokens
Daniel Jasper via cfe-commits
cfe-commits at lists.llvm.org
Sat Jan 9 13:12:45 PST 2016
Author: djasper
Date: Sat Jan 9 15:12:45 2016
New Revision: 257267
URL: http://llvm.org/viewvc/llvm-project?rev=257267&view=rev
Log:
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.
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=257267&r1=257266&r2=257267&view=diff
==============================================================================
--- cfe/trunk/lib/Format/Format.cpp (original)
+++ cfe/trunk/lib/Format/Format.cpp Sat Jan 9 15:12:45 2016
@@ -1239,6 +1239,8 @@ private:
FormatTok->Type = TT_ImplicitStringLiteral;
break;
}
+ if (FormatTok->Type == TT_ImplicitStringLiteral)
+ break;
}
if (FormatTok->is(TT_ImplicitStringLiteral))
Modified: cfe/trunk/unittests/Format/FormatTestJS.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestJS.cpp?rev=257267&r1=257266&r2=257267&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTestJS.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTestJS.cpp Sat Jan 9 15:12:45 2016
@@ -956,6 +956,9 @@ TEST_F(FormatTestJS, TemplateStrings) {
"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"
" ;",
More information about the cfe-commits
mailing list