]> granicus.if.org Git - clang/commitdiff
clang-format: Fix incorrect line break in certain configurations.
authorDaniel Jasper <djasper@google.com>
Sat, 9 Jan 2016 15:56:47 +0000 (15:56 +0000)
committerDaniel Jasper <djasper@google.com>
Sat, 9 Jan 2016 15:56:47 +0000 (15:56 +0000)
Before:
  void aaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaaaa,
                          vector<int>
                              bbbbbbbbbbbbbbb);

After:
  void aaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaaaa,
                          vector<int> bbbbbbbbbbbbbbb);

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

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

index 535eac480306be4092640eb306a202300adae5b6..ff2569d41aab8b7a427369eef4413abcd0edf7ff 100644 (file)
@@ -150,7 +150,8 @@ 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)) ||
+       (Previous.is(TT_TemplateCloser) && Current.is(TT_StartOfName) &&
+        Previous.NestingLevel == 1) ||
        (Style.BreakBeforeTernaryOperators && Current.is(TT_ConditionalExpr) &&
         Previous.isNot(tok::question)) ||
        (!Style.BreakBeforeTernaryOperators &&
index 46773a306fd253544f55f5ad30114f7032cb93f6..fe673cc486c0a7202336db99514934373a580037 100644 (file)
@@ -4062,6 +4062,10 @@ TEST_F(FormatTest, FormatsDeclarationsOnePerLine) {
                "       int aaaaaaaaaaaaaaaaaaaa,\n"
                "       int aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) {}",
                NoBinPacking);
+  NoBinPacking.AllowAllParametersOfDeclarationOnNextLine = false;
+  verifyFormat("void aaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaaaa,\n"
+               "                        vector<int> bbbbbbbbbbbbbbb);",
+               NoBinPacking);
 }
 
 TEST_F(FormatTest, FormatsOneParameterPerLineIfNecessary) {