r230942 - clang-format: Prefer wrapping a lambda's body over the lambda's return type.
Daniel Jasper
djasper at google.com
Mon Mar 2 02:35:13 PST 2015
Author: djasper
Date: Mon Mar 2 04:35:13 2015
New Revision: 230942
URL: http://llvm.org/viewvc/llvm-project?rev=230942&view=rev
Log:
clang-format: Prefer wrapping a lambda's body over the lambda's return type.
Before:
aaaaaaaaaaaaaaaaaaaaaa(
[](aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa &aaa)
-> aaaaaaaaaaaaaaaaaaaaa { return aaaaaaaaaaaaaaaaa; });
After:
aaaaaaaaaaaaaaaaaaaaaa(
[](aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa &aaa) -> aaaaaaaaaaaaaaaaaaaaa {
return aaaaaaaaaaaaaaaaa;
});
Modified:
cfe/trunk/lib/Format/TokenAnnotator.cpp
cfe/trunk/unittests/Format/FormatTest.cpp
Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=230942&r1=230941&r2=230942&view=diff
==============================================================================
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Mon Mar 2 04:35:13 2015
@@ -1535,6 +1535,8 @@ unsigned TokenAnnotator::splitPenalty(co
return Style.PenaltyReturnTypeOnItsOwnLine;
return 200;
}
+ if (Right.is(TT_TrailingReturnArrow))
+ return 110;
if (Left.is(tok::equal) && Right.is(tok::l_brace))
return 150;
if (Left.is(TT_CastRParen))
Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=230942&r1=230941&r2=230942&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Mon Mar 2 04:35:13 2015
@@ -9537,6 +9537,12 @@ TEST_F(FormatTest, FormatsLambdas) {
" int j) -> int {\n"
" return ffffffffffffffffffffffffffffffffffffffffffff(i * j);\n"
"};");
+ verifyFormat(
+ "aaaaaaaaaaaaaaaaaaaaaa(\n"
+ " [](aaaaaaaaaaaaaaaaaaaaaaaaaaa &aaa) -> aaaaaaaaaaaaaaaa {\n"
+ " return aaaaaaaaaaaaaaaaa;\n"
+ " });",
+ getLLVMStyleWithColumns(70));
// Multiple lambdas in the same parentheses change indentation rules.
verifyFormat("SomeFunction(\n"
More information about the cfe-commits
mailing list