diff options
author | Daniel Jasper <djasper@google.com> | 2016-03-17 12:00:22 +0000 |
---|---|---|
committer | Daniel Jasper <djasper@google.com> | 2016-03-17 12:00:22 +0000 |
commit | 710f8493c898a31a36237353b37e39ea9f6a9777 (patch) | |
tree | 9c6f6e087cc39f148fead454729bde581316bf1d /clang/lib | |
parent | 16f2460575e6f65b277cb0000667a83500f5fce3 (diff) | |
download | bcm5719-llvm-710f8493c898a31a36237353b37e39ea9f6a9777.tar.gz bcm5719-llvm-710f8493c898a31a36237353b37e39ea9f6a9777.zip |
clang-format: Slightly weaken AlignAfterOpenBracket=AlwaysBreak.
If a call takes a single argument, using AlwaysBreak can lead to lots
of wasted lines and additional indentation without improving the
readability in a significant way.
Before:
caaaaaaaaaaaall(
caaaaaaaaaaaall(
caaaaaaaaaaaall(
caaaaaaaaaaaaaaaaaaaaaaall(aaaaaaaaaaaaaa, aaaaaaaaa))));
After:
caaaaaaaaaaaall(caaaaaaaaaaaall(caaaaaaaaaaaall(
caaaaaaaaaaaaaaaaaaaaaaall(aaaaaaaaaaaaaa, aaaaaaaaa))));
llvm-svn: 263709
Diffstat (limited to 'clang/lib')
-rw-r--r-- | clang/lib/Format/ContinuationIndenter.cpp | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/clang/lib/Format/ContinuationIndenter.cpp b/clang/lib/Format/ContinuationIndenter.cpp index 4e5a29426a2..9cff34bc3df 100644 --- a/clang/lib/Format/ContinuationIndenter.cpp +++ b/clang/lib/Format/ContinuationIndenter.cpp @@ -356,7 +356,17 @@ void ContinuationIndenter::addTokenOnCurrentLine(LineState &State, bool DryRun, Previous.isOneOf(tok::l_paren, TT_TemplateOpener, tok::l_square) && State.Column > getNewLineColumn(State) && (!Previous.Previous || - !Previous.Previous->isOneOf(tok::kw_for, tok::kw_while, tok::kw_switch))) + !Previous.Previous->isOneOf(tok::kw_for, tok::kw_while, + tok::kw_switch)) && + // Don't do this for simple (no expressions) one-argument function calls + // as that feels like needlessly wasting whitespace, e.g.: + // + // caaaaaaaaaaaall( + // caaaaaaaaaaaall( + // caaaaaaaaaaaall( + // caaaaaaaaaaaaaaaaaaaaaaall(aaaaaaaaaaaaaa, aaaaaaaaa)))); + Current.FakeLParens.size() > 0 && + Current.FakeLParens.back() > prec::Unknown) State.Stack.back().NoLineBreak = true; if (Style.AlignAfterOpenBracket != FormatStyle::BAS_DontAlign && |