diff options
author | Daniel Jasper <djasper@google.com> | 2014-08-08 12:00:13 +0000 |
---|---|---|
committer | Daniel Jasper <djasper@google.com> | 2014-08-08 12:00:13 +0000 |
commit | a5621202c4445d101d6b295536e8ccec81dddb46 (patch) | |
tree | 4503c24c2bc64c6bc147218f8d48d2cae27a1602 /clang | |
parent | b911bf84dc9a3ff566a50945bb59df4bd3020572 (diff) | |
download | bcm5719-llvm-a5621202c4445d101d6b295536e8ccec81dddb46.tar.gz bcm5719-llvm-a5621202c4445d101d6b295536e8ccec81dddb46.zip |
clang-format: Prefer not to put lambdas on a single line.
Before:
string abc =
SomeFunction(aaaaaaaaaaaaa, aaaaa,
[]() { SomeOtherFunctioooooooooooooooooooooooooon(); });
After:
string abc = SomeFunction(aaaaaaaaaaaaa, aaaaa, []() {
SomeOtherFunctioooooooooooooooooooooooooon();
});
llvm-svn: 215197
Diffstat (limited to 'clang')
-rw-r--r-- | clang/lib/Format/TokenAnnotator.cpp | 2 | ||||
-rw-r--r-- | clang/unittests/Format/FormatTest.cpp | 3 |
2 files changed, 5 insertions, 0 deletions
diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp index 54644ad768e..f817224e195 100644 --- a/clang/lib/Format/TokenAnnotator.cpp +++ b/clang/lib/Format/TokenAnnotator.cpp @@ -1420,6 +1420,8 @@ unsigned TokenAnnotator::splitPenalty(const AnnotatedLine &Line, return 100; if (Left.is(tok::equal) && InFunctionDecl) return 110; + if (Right.is(tok::r_brace)) + return 1; if (Left.opensScope()) return Left.ParameterCount > 1 ? Style.PenaltyBreakBeforeFirstCallParameter : 19; diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index bd55c9ef219..a171066fa37 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -8819,6 +8819,9 @@ TEST_F(FormatTest, FormatsLambdas) { "}"); verifyFormat("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(\n" " [](const aaaaaaaaaa &a) { return a; });"); + verifyFormat("string abc = SomeFunction(aaaaaaaaaaaaa, aaaaa, []() {\n" + " SomeOtherFunctioooooooooooooooooooooooooon();\n" + "});"); // Lambdas with return types. verifyFormat("int c = []() -> int { return 2; }();\n"); |