diff options
author | Daniel Jasper <djasper@google.com> | 2013-02-14 14:26:07 +0000 |
---|---|---|
committer | Daniel Jasper <djasper@google.com> | 2013-02-14 14:26:07 +0000 |
commit | fc75908a7f58903a92c47e1ae02f9a05c36c9f59 (patch) | |
tree | d67702c82082f18588d408954c76f20b186238cc /lib/Format/TokenAnnotator.cpp | |
parent | 68a932d416c52cef609e2c6c79ae99cbf4b9acd6 (diff) |
Reduce penalty for breaking before ./-> after complex calls.
This gives a clearer separation of the context, e.g. in GMOCK
statements.
Before:
EXPECT_CALL(SomeObject,
SomeFunction(Parameter)).WillRepeatedly(Return(SomeValue));
After:
EXPECT_CALL(SomeObject, SomeFunction(Parameter))
.WillRepeatedly(Return(SomeValue));
Minor format cleanups.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175162 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Format/TokenAnnotator.cpp')
-rw-r--r-- | lib/Format/TokenAnnotator.cpp | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/lib/Format/TokenAnnotator.cpp b/lib/Format/TokenAnnotator.cpp index 22e67df1ec..ace6d25467 100644 --- a/lib/Format/TokenAnnotator.cpp +++ b/lib/Format/TokenAnnotator.cpp @@ -524,11 +524,9 @@ private: struct ScopedContextCreator { AnnotatingParser &P; - ScopedContextCreator(AnnotatingParser &P, unsigned Increase) - : P(P) { - P.Contexts.push_back(Context( - P.Contexts.back().BindingStrength + Increase, - P.Contexts.back().IsExpression)); + ScopedContextCreator(AnnotatingParser &P, unsigned Increase) : P(P) { + P.Contexts.push_back(Context(P.Contexts.back().BindingStrength + Increase, + P.Contexts.back().IsExpression)); } ~ScopedContextCreator() { P.Contexts.pop_back(); } @@ -865,6 +863,9 @@ unsigned TokenAnnotator::splitPenalty(const AnnotatedLine &Line, if (Right.is(tok::arrow) || Right.is(tok::period)) { if (Left.is(tok::r_paren) && Line.Type == LT_BuilderTypeCall) return 5; // Should be smaller than breaking at a nested comma. + if ((Left.is(tok::r_paren) || Left.is(tok::r_square)) && + Left.MatchingParen && Left.MatchingParen->ParameterCount > 0) + return 10; return 150; } |