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

Ryan Stringham via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon May 15 08:17:41 PDT 2017


stringham added a comment.

> Probably all of the examples from the original patch description and later comments should be turned into unit tests.

I would like to add some unit tests for this, but was not able to figure out how to run the unit test suite. Where can I find instructions on how to run the unit tests?

I found out how to build clang-format from a combination of https://chromium.googlesource.com/chromium/src/+/master/docs/updating_clang_format_binaries.md and https://github.com/angular/clang-format#compiling-clang-format

I saw step 10 on http://clang.llvm.org/get_started.html says to run `make check-clang` from my build directory, but when I try that I get "No rule to make target" errors.



================
Comment at: docs/ClangFormatStyleOptions.rst:953
 
+**DanglingParenthesis** (``bool``)
+  If there is a break after the opening parenthesis, also break before the closing parenthesis
----------------
djasper wrote:
> Have you auto-generated this with docs/tools/dump_format_style.py? There seem to be subtle differences.
I was not aware the dump_format_style.py existed. I created this manually based on the code around it. I will try running that script.


================
Comment at: include/clang/Format/Format.h:793
+  /// \endcode
+  bool DanglingParenthesis;
+
----------------
djasper wrote:
> I don't think this is a name that anyone will intuitively understand. I understand that the naming is hard here. One thing I am wondering is whether this might ever make sense unless AlignAfterOpenBracket is set to AlwaysBreak?
> 
> Unless that option is set, we could have both in the same file:
> 
>   someFunction(aaaa,
>                bbbb);
> 
> and
> 
>   someFunction(
>       aaaa, bbbb
>   );
> 
> Is that intended, i.e. are you actively using that? Answering this is important, because it influence whether or not we actually need to add another style option and even how to implement this.
The name was based on the configuration option that scalafmt has for their automatic scala formatter, they also have an option to have the closing paren on its own line and they call it `danglingParentheses`. I don't love the name and am open to other options.

That's a good point about AlignAfterOpenBracket being set to AlwaysBreak. In our usage we have that option set, and I'm also unsure if it makes sense without AlwaysBreak.


https://reviews.llvm.org/D33029





More information about the cfe-commits mailing list