summaryrefslogtreecommitdiffstats
path: root/clang/lib/Format/ContinuationIndenter.cpp
diff options
context:
space:
mode:
authorDaniel Jasper <djasper@google.com>2014-09-12 16:35:28 +0000
committerDaniel Jasper <djasper@google.com>2014-09-12 16:35:28 +0000
commitd6f17d83a38c4e41b63cfb91aa115b6dcac78c34 (patch)
tree00f965f5f0d05b3c69555e076965bfb2b1863a6c /clang/lib/Format/ContinuationIndenter.cpp
parente9ead73cdbb004d6ae879db904cab1e0a8a47464 (diff)
downloadbcm5719-llvm-d6f17d83a38c4e41b63cfb91aa115b6dcac78c34.tar.gz
bcm5719-llvm-d6f17d83a38c4e41b63cfb91aa115b6dcac78c34.zip
clang-format: Improve line breaks at function calls.
Before: EXPECT_CALL(SomeObject, SomeFunction(Parameter)).Times(2).WillRepeatedly( Return(SomeValue)); After: EXPECT_CALL(SomeObject, SomeFunction(Parameter)) .Times(2) .WillRepeatedly(Return(SomeValue)); llvm-svn: 217687
Diffstat (limited to 'clang/lib/Format/ContinuationIndenter.cpp')
-rw-r--r--clang/lib/Format/ContinuationIndenter.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/clang/lib/Format/ContinuationIndenter.cpp b/clang/lib/Format/ContinuationIndenter.cpp
index afd20b22e3a..0dc65ba28ef 100644
--- a/clang/lib/Format/ContinuationIndenter.cpp
+++ b/clang/lib/Format/ContinuationIndenter.cpp
@@ -302,6 +302,18 @@ void ContinuationIndenter::addTokenOnCurrentLine(LineState &State, bool DryRun,
if (startsSegmentOfBuilderTypeCall(Current))
State.Stack.back().ContainsUnwrappedBuilder = true;
+ if (Current.isMemberAccess() && Previous.is(tok::r_paren) &&
+ (Previous.MatchingParen &&
+ (Previous.TotalLength - Previous.MatchingParen->TotalLength > 10))) {
+ // If there is a function call with long parameters, break before trailing
+ // calls. This prevents things like:
+ // EXPECT_CALL(SomeLongParameter).Times(
+ // 2);
+ // We don't want to do this for short parameters as they can just be
+ // indexes.
+ State.Stack.back().NoLineBreak = true;
+ }
+
State.Column += Spaces;
if (Current.isNot(tok::comment) && Previous.is(tok::l_paren) &&
Previous.Previous && Previous.Previous->isOneOf(tok::kw_if, tok::kw_for))
OpenPOWER on IntegriCloud