[PATCH] D33029: [clang-format] add option for dangling parenthesis

Ryan Stringham via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue May 9 21:47:31 PDT 2017


stringham created this revision.
stringham added a project: clang-tools-extra.
Herald added a subscriber: klimek.

This adds an option to clang-format to support dangling parenthesis.

If you have a parameter list like

Foo(

  param1,
  param2,
  param3,

);

clang-format currently only supports putting the closing paren on the same line as param3:

Foo(

  param1,
  param2,
  param3, );

This makes it difficult to see the change from the function signature to the function body, for example:

class Foo extends Bar {

  constructor(
      param1,
      param2,
      param3, ) {
      super(param1, 'x');
      this.param2 = param2;
  }

}

would now be formatted like:

class Foo extends Bar {

  constructor(
      param1,
      param2,
      param3, 
  ) {
      super(param1, 'x');
      this.param2 = param2;
  }

}

and it is much easier to see the difference between the parameter list and the function body.


https://reviews.llvm.org/D33029

Files:
  docs/ClangFormatStyleOptions.rst
  include/clang/Format/Format.h
  lib/Format/ContinuationIndenter.cpp
  lib/Format/Format.cpp
  lib/Format/TokenAnnotator.cpp
  unittests/Format/FormatTest.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D33029.98399.patch
Type: text/x-patch
Size: 5529 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170510/423b4ee3/attachment.bin>


More information about the cfe-commits mailing list