r203562 - clang-format: Avoid unnecessary break before lambda return type.
Daniel Jasper
djasper at google.com
Tue Mar 11 04:03:26 PDT 2014
Author: djasper
Date: Tue Mar 11 06:03:26 2014
New Revision: 203562
URL: http://llvm.org/viewvc/llvm-project?rev=203562&view=rev
Log:
clang-format: Avoid unnecessary break before lambda return type.
Before:
auto aaaaaaaa = [](int i, // break
int j)
-> int {
return fffffffffffffffffffffffffffffffffffffff(i * j);
};
After:
auto aaaaaaaa = [](int i, // break
int j) -> int {
return fffffffffffffffffffffffffffffffffffffff(i * j);
};
Modified:
cfe/trunk/lib/Format/ContinuationIndenter.cpp
cfe/trunk/unittests/Format/FormatTest.cpp
Modified: cfe/trunk/lib/Format/ContinuationIndenter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/ContinuationIndenter.cpp?rev=203562&r1=203561&r2=203562&view=diff
==============================================================================
--- cfe/trunk/lib/Format/ContinuationIndenter.cpp (original)
+++ cfe/trunk/lib/Format/ContinuationIndenter.cpp Tue Mar 11 06:03:26 2014
@@ -108,7 +108,8 @@ bool ContinuationIndenter::canBreak(cons
// SomeParameter, OtherParameter).DoSomething(
// ...
// As they hide "DoSomething" and are generally bad for readability.
- if (Previous.opensScope() && State.LowestLevelOnLine < State.StartOfLineLevel)
+ if (Previous.opensScope() && Previous.isNot(tok::l_brace) &&
+ State.LowestLevelOnLine < State.StartOfLineLevel)
return false;
if (Current.isMemberAccess() && State.Stack.back().ContainsUnwrappedBuilder)
return false;
Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=203562&r1=203561&r2=203562&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Tue Mar 11 06:03:26 2014
@@ -7974,6 +7974,10 @@ TEST_F(FormatTest, FormatsLambdas) {
verifyFormat("int c = []() -> int { return 2; }();\n");
verifyFormat("int c = []() -> vector<int> { return {2}; }();\n");
verifyFormat("Foo([]() -> std::vector<int> { return {2}; }());");
+ verifyFormat("auto aaaaaaaa = [](int i, // break for some reason\n"
+ " int j) -> int {\n"
+ " return fffffffffffffffffffffffffffffffffffffff(i * j);\n"
+ "};");
// Not lambdas.
verifyFormat("constexpr char hello[]{\"hello\"};");
More information about the cfe-commits
mailing list