r253674 - clang-format: [JS] Make AllowShortFunctionsOnASingle line value "Empty"

Daniel Jasper via cfe-commits cfe-commits at lists.llvm.org
Fri Nov 20 08:44:28 PST 2015


Author: djasper
Date: Fri Nov 20 10:44:28 2015
New Revision: 253674

URL: http://llvm.org/viewvc/llvm-project?rev=253674&view=rev
Log:
clang-format: [JS] Make AllowShortFunctionsOnASingle line value "Empty"
work properly.

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=253674&r1=253673&r2=253674&view=diff
==============================================================================
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Fri Nov 20 10:44:28 2015
@@ -2104,6 +2104,7 @@ bool TokenAnnotator::mustBreakBefore(con
         !Left.Children.empty())
       // Support AllowShortFunctionsOnASingleLine for JavaScript.
       return Style.AllowShortFunctionsOnASingleLine == FormatStyle::SFS_None ||
+             Style.AllowShortFunctionsOnASingleLine == FormatStyle::SFS_Empty ||
              (Left.NestingLevel == 0 && Line.Level == 0 &&
               Style.AllowShortFunctionsOnASingleLine ==
                   FormatStyle::SFS_Inline);

Modified: cfe/trunk/unittests/Format/FormatTestJS.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestJS.cpp?rev=253674&r1=253673&r2=253674&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTestJS.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTestJS.cpp Fri Nov 20 10:44:28 2015
@@ -448,6 +448,12 @@ TEST_F(FormatTestJS, InliningFunctionLit
                "  }\n"
                "}",
                Style);
+
+  Style.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_Empty;
+  verifyFormat("var func = function() {\n"
+               "  return 1;\n"
+               "};",
+               Style);
 }
 
 TEST_F(FormatTestJS, MultipleFunctionLiterals) {




More information about the cfe-commits mailing list