[PATCH] D37513: [clang-format] Fix documentation for AllowAllParametersOfDeclarationOnNextLine

Lucja Mazur via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Sep 7 04:45:43 PDT 2017


LuMa updated this revision to Diff 114151.
LuMa added a comment.
Herald added a subscriber: klimek.

I moved changes to correct file.
When it comes to example, it doesn't seem to work with short function.

Example:

.clang-format:

  ColumnLimit: 35
  UseTab:          Never
  BinPackParameters: false
  AllowAllParametersOfDeclarationOnNextLine: true

For input:

  void myFunction(int a, int b, int c);

output is:

  void myFunction(int a,
                  int b,
                  int c);

  				

although it should be:

  void myFunction(
      int a, int b, int c);

I don't know if it's bug or expected behavior. Maybe it's result of other flags or penalties. But i think an example should work for default values, so i suggest using the longer one.


https://reviews.llvm.org/D37513

Files:
  include/clang/Format/Format.h


Index: include/clang/Format/Format.h
===================================================================
--- include/clang/Format/Format.h
+++ include/clang/Format/Format.h
@@ -151,13 +151,20 @@
   /// \endcode
   bool AlignTrailingComments;
 
-  /// \brief Allow putting all parameters of a function declaration onto
+  /// \brief If the function declaration doesn't fit on a line,
+  /// allow putting all parameters of a function declaration onto
   /// the next line even if ``BinPackParameters`` is ``false``.
   /// \code
-  ///   true:                                   false:
-  ///   myFunction(foo,                 vs.     myFunction(foo, bar, plop);
-  ///              bar,
-  ///              plop);
+  ///   true:
+  ///   void myFunction(
+  ///       int a, int b, int c, int d, int e);
+  ///   
+  ///   false:
+  ///   void myFunction(int a,
+  ///                   int b,
+  ///                   int c,
+  ///                   int d,
+  ///                   int e);
   /// \endcode
   bool AllowAllParametersOfDeclarationOnNextLine;
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D37513.114151.patch
Type: text/x-patch
Size: 1059 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170907/f2c221fa/attachment-0001.bin>


More information about the cfe-commits mailing list