r318958 - clang-format: [JS] do not wrap before yield.

Martin Probst via cfe-commits cfe-commits at lists.llvm.org
Fri Nov 24 09:05:35 PST 2017


Author: mprobst
Date: Fri Nov 24 09:05:35 2017
New Revision: 318958

URL: http://llvm.org/viewvc/llvm-project?rev=318958&view=rev
Log:
clang-format: [JS] do not wrap before yield.

Summary: The same rules apply as for `return`.

Reviewers: djasper

Subscribers: klimek

Differential Revision: https://reviews.llvm.org/D40431

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=318958&r1=318957&r2=318958&view=diff
==============================================================================
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Fri Nov 24 09:05:35 2017
@@ -2699,8 +2699,8 @@ bool TokenAnnotator::canBreakBefore(cons
   } else if (Style.Language == FormatStyle::LK_JavaScript) {
     const FormatToken *NonComment = Right.getPreviousNonComment();
     if (NonComment &&
-        NonComment->isOneOf(tok::kw_return, tok::kw_continue, tok::kw_break,
-                            tok::kw_throw, Keywords.kw_interface,
+        NonComment->isOneOf(tok::kw_return, Keywords.kw_yield, tok::kw_continue,
+                            tok::kw_break, tok::kw_throw, Keywords.kw_interface,
                             Keywords.kw_type, tok::kw_static, tok::kw_public,
                             tok::kw_private, tok::kw_protected,
                             Keywords.kw_readonly, Keywords.kw_abstract,

Modified: cfe/trunk/unittests/Format/FormatTestJS.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestJS.cpp?rev=318958&r1=318957&r2=318958&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTestJS.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTestJS.cpp Fri Nov 24 09:05:35 2017
@@ -1123,6 +1123,7 @@ TEST_F(FormatTestJS, WrapRespectsAutomat
   // would change due to automatic semicolon insertion.
   // See http://www.ecma-international.org/ecma-262/5.1/#sec-7.9.1.
   verifyFormat("return aaaaa;", getGoogleJSStyleWithColumns(10));
+  verifyFormat("yield aaaaa;", getGoogleJSStyleWithColumns(10));
   verifyFormat("return /* hello! */ aaaaa;", getGoogleJSStyleWithColumns(10));
   verifyFormat("continue aaaaa;", getGoogleJSStyleWithColumns(10));
   verifyFormat("continue /* hello! */ aaaaa;", getGoogleJSStyleWithColumns(10));




More information about the cfe-commits mailing list