r253871 - clang-format: If the template list of a variable declaration spans

Daniel Jasper via cfe-commits cfe-commits at lists.llvm.org
Mon Nov 23 07:55:45 PST 2015


Author: djasper
Date: Mon Nov 23 09:55:45 2015
New Revision: 253871

URL: http://llvm.org/viewvc/llvm-project?rev=253871&view=rev
Log:
clang-format: If the template list of a variable declaration spans
multiple lines, also break before the variable name.

Before:
  std::vector<aaaaaa, // wrap
              aa> aaa;

After:
  std::vector<aaaaaa, // wrap
              aa>
      aaa;

Modified:
    cfe/trunk/lib/Format/ContinuationIndenter.cpp
    cfe/trunk/unittests/Format/FormatTest.cpp

Modified: cfe/trunk/lib/Format/ContinuationIndenter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/ContinuationIndenter.cpp?rev=253871&r1=253870&r2=253871&view=diff
==============================================================================
--- cfe/trunk/lib/Format/ContinuationIndenter.cpp (original)
+++ cfe/trunk/lib/Format/ContinuationIndenter.cpp Mon Nov 23 09:55:45 2015
@@ -144,6 +144,7 @@ bool ContinuationIndenter::mustBreak(con
   if (Previous.is(tok::semi) && State.LineContainsContinuedForLoopSection)
     return true;
   if ((startsNextParameter(Current, Style) || Previous.is(tok::semi) ||
+       (Previous.is(TT_TemplateCloser) && Current.is(TT_StartOfName)) ||
        (Style.BreakBeforeTernaryOperators && Current.is(TT_ConditionalExpr) &&
         Previous.isNot(tok::question)) ||
        (!Style.BreakBeforeTernaryOperators &&

Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=253871&r1=253870&r2=253871&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Mon Nov 23 09:55:45 2015
@@ -4080,7 +4080,8 @@ TEST_F(FormatTest, FormatsOneParameterPe
 
   verifyFormat("std::vector<aaaaaaaaaaaaaaaaaaaaaaa,\n"
                "            aaaaaaaaaaaaaaaaaaaaaaa,\n"
-               "            aaaaaaaaaaaaaaaaaaaaaaa> aaaaaaaaaaaaaaaaaa;",
+               "            aaaaaaaaaaaaaaaaaaaaaaa>\n"
+               "    aaaaaaaaaaaaaaaaaa;",
                NoBinPacking);
   verifyFormat("a(\"a\"\n"
                "  \"a\",\n"




More information about the cfe-commits mailing list