[PATCH] D52535: clang-format: [JS] space after parameter naming.

Martin Probst via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Sep 26 01:14:11 PDT 2018


mprobst created this revision.
mprobst added a reviewer: mboehme.

Previously:

  foo(/*bar=*/baz);

Now:

  foo(/*bar=*/ baz);

The run-in parameter naming comment is not intended in JS.


Repository:
  rC Clang

https://reviews.llvm.org/D52535

Files:
  lib/Format/TokenAnnotator.cpp
  unittests/Format/FormatTestJS.cpp


Index: unittests/Format/FormatTestJS.cpp
===================================================================
--- unittests/Format/FormatTestJS.cpp
+++ unittests/Format/FormatTestJS.cpp
@@ -2304,5 +2304,9 @@
              "};"));
 }
 
+TEST_F(FormatTestJS, ParameterNamingComment) {
+  verifyFormat("callFoo(/*spaceAfterParameterNamingComment=*/ 1);");
+}
+
 } // end namespace tooling
 } // end namespace clang
Index: lib/Format/TokenAnnotator.cpp
===================================================================
--- lib/Format/TokenAnnotator.cpp
+++ lib/Format/TokenAnnotator.cpp
@@ -2517,7 +2517,9 @@
        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)))


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D52535.167073.patch
Type: text/x-patch
Size: 1110 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180926/93cc4b71/attachment.bin>


More information about the cfe-commits mailing list