r221989 - clang-format: Improve function parameter packing.

Daniel Jasper djasper at google.com
Fri Nov 14 05:14:46 PST 2014


Author: djasper
Date: Fri Nov 14 07:14:45 2014
New Revision: 221989

URL: http://llvm.org/viewvc/llvm-project?rev=221989&view=rev
Log:
clang-format: Improve function parameter packing.

Before:
  void SomeLoooooooooooongFunction(
      std::unique_ptr<aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa>
          aaaaaaaaaaaaaaaaaaaaaaaaaa, int bbbbbbbbbbbbb);

After:
  void SomeLoooooooooooongFunction(
      std::unique_ptr<aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa>
          aaaaaaaaaaaaaaaaaaaaaaaaaa,
      int bbbbbbbbbbbbb);

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=221989&r1=221988&r2=221989&view=diff
==============================================================================
--- cfe/trunk/lib/Format/ContinuationIndenter.cpp (original)
+++ cfe/trunk/lib/Format/ContinuationIndenter.cpp Fri Nov 14 07:14:45 2014
@@ -464,7 +464,8 @@ unsigned ContinuationIndenter::addTokenO
 
   if (PreviousNonComment &&
       !PreviousNonComment->isOneOf(tok::comma, tok::semi) &&
-      PreviousNonComment->Type != TT_TemplateCloser &&
+      (PreviousNonComment->Type != TT_TemplateCloser ||
+       Current.NestingLevel != 0) &&
       PreviousNonComment->Type != TT_BinaryOperator &&
       PreviousNonComment->Type != TT_JavaAnnotation &&
       PreviousNonComment->Type != TT_LeadingJavaAnnotation &&

Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=221989&r1=221988&r2=221989&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Fri Nov 14 07:14:45 2014
@@ -3541,6 +3541,10 @@ TEST_F(FormatTest, BreaksFunctionDeclara
                "    aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n"
                "        aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,\n"
                "    bbbb bbbb);");
+  verifyFormat("void SomeLoooooooooooongFunction(\n"
+               "    std::unique_ptr<aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa>\n"
+               "        aaaaaaaaaaaaaaaaaaaaaaaaaa,\n"
+               "    int bbbbbbbbbbbbb);");
 
   // Treat overloaded operators like other functions.
   verifyFormat("SomeLoooooooooooooooooooooooooogType\n"





More information about the cfe-commits mailing list