r343080 - clang-format: [JS] space after parameter naming.
Martin Probst via cfe-commits
cfe-commits at lists.llvm.org
Wed Sep 26 01:28:33 PDT 2018
Author: mprobst
Date: Wed Sep 26 01:28:33 2018
New Revision: 343080
URL: http://llvm.org/viewvc/llvm-project?rev=343080&view=rev
Log:
clang-format: [JS] space after parameter naming.
Summary:
Previously:
foo(/*bar=*/baz);
Now:
foo(/*bar=*/ baz);
The run-in parameter naming comment is not intended in JS.
Reviewers: mboehme
Subscribers: cfe-commits
Differential Revision: https://reviews.llvm.org/D52535
Modified:
cfe/trunk/lib/Format/TokenAnnotator.cpp
cfe/trunk/unittests/Format/FormatTestJS.cpp
Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=343080&r1=343079&r2=343080&view=diff
==============================================================================
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Wed Sep 26 01:28:33 2018
@@ -2517,7 +2517,9 @@ bool TokenAnnotator::spaceRequiredBetwee
Right.MatchingParen->BlockKind != BK_Block))
return !Style.Cpp11BracedListStyle;
if (Left.is(TT_BlockComment))
- return !Left.TokenText.endswith("=*/");
+ // No whitespace in x(/*foo=*/1), except for JavaScript.
+ return Style.Language == FormatStyle::LK_JavaScript ||
+ !Left.TokenText.endswith("=*/");
if (Right.is(tok::l_paren)) {
if ((Left.is(tok::r_paren) && Left.is(TT_AttributeParen)) ||
(Left.is(tok::r_square) && Left.is(TT_AttributeSquare)))
Modified: cfe/trunk/unittests/Format/FormatTestJS.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestJS.cpp?rev=343080&r1=343079&r2=343080&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTestJS.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTestJS.cpp Wed Sep 26 01:28:33 2018
@@ -2304,5 +2304,9 @@ TEST_F(FormatTestJS, AddsLastLinePenalty
"};"));
}
+TEST_F(FormatTestJS, ParameterNamingComment) {
+ verifyFormat("callFoo(/*spaceAfterParameterNamingComment=*/ 1);");
+}
+
} // end namespace tooling
} // end namespace clang
More information about the cfe-commits
mailing list