]> granicus.if.org Git - clang/commitdiff
clang-format: If the template list of a variable declaration spans
authorDaniel Jasper <djasper@google.com>
Mon, 23 Nov 2015 15:55:45 +0000 (15:55 +0000)
committerDaniel Jasper <djasper@google.com>
Mon, 23 Nov 2015 15:55:45 +0000 (15:55 +0000)
multiple lines, also break before the variable name.

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

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@253871 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Format/ContinuationIndenter.cpp
unittests/Format/FormatTest.cpp

index 72157bd64158aa9c0c66c625c48b54f91e02b8b6..e41ae9769aff00dcf32c09d75f7f6d2a2540f0a2 100644 (file)
@@ -144,6 +144,7 @@ bool ContinuationIndenter::mustBreak(const LineState &State) {
   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 &&
index f0646c62e1ee2e7f23da6146593a17f1fc21d176..66b3add302659dae7ffbd3009837e0a7d1034e42 100644 (file)
@@ -4080,7 +4080,8 @@ TEST_F(FormatTest, FormatsOneParameterPerLineIfNecessary) {
 
   verifyFormat("std::vector<aaaaaaaaaaaaaaaaaaaaaaa,\n"
                "            aaaaaaaaaaaaaaaaaaaaaaa,\n"
-               "            aaaaaaaaaaaaaaaaaaaaaaa> aaaaaaaaaaaaaaaaaa;",
+               "            aaaaaaaaaaaaaaaaaaaaaaa>\n"
+               "    aaaaaaaaaaaaaaaaaa;",
                NoBinPacking);
   verifyFormat("a(\"a\"\n"
                "  \"a\",\n"