diff options
| author | Daniel Jasper <djasper@google.com> | 2014-05-22 08:36:53 +0000 |
|---|---|---|
| committer | Daniel Jasper <djasper@google.com> | 2014-05-22 08:36:53 +0000 |
| commit | 5f3ea477cf3b48710a5ef839624606311f0c4ab7 (patch) | |
| tree | cc197a160a9f1eabd3b911f487212cf6cdd04829 /clang/unittests/Format/FormatTest.cpp | |
| parent | 0f6272271e77b3b2b6325141c9798aed6ac966b8 (diff) | |
| download | bcm5719-llvm-5f3ea477cf3b48710a5ef839624606311f0c4ab7.tar.gz bcm5719-llvm-5f3ea477cf3b48710a5ef839624606311f0c4ab7.zip | |
clang-format: Correctly calculate line lenghts for nest blocks.
If simple (one-statement) blocks can be inlined, the length needs to be
calculated correctly.
Before (in JavaScript but this also affects lambdas, etc.):
var x = {
valueOf: function() { return 1; }
};
After:
var x = {valueOf: function() { return 1; }};
llvm-svn: 209410
Diffstat (limited to 'clang/unittests/Format/FormatTest.cpp')
| -rw-r--r-- | clang/unittests/Format/FormatTest.cpp | 22 |
1 files changed, 6 insertions, 16 deletions
diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index cff851c4f77..3dbada81f01 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -8586,21 +8586,11 @@ TEST_F(FormatTest, FormatsWithWebKitStyle) { } TEST_F(FormatTest, FormatsLambdas) { - verifyFormat("int c = [b]() mutable {\n" - " return [&b] { return b++; }();\n" - "}();\n"); - verifyFormat("int c = [&] {\n" - " [=] { return b++; }();\n" - "}();\n"); - verifyFormat("int c = [&, &a, a] {\n" - " [=, c, &d] { return b++; }();\n" - "}();\n"); - verifyFormat("int c = [&a, &a, a] {\n" - " [=, a, b, &c] { return b++; }();\n" - "}();\n"); - verifyFormat("auto c = {[&a, &a, a] {\n" - " [=, a, b, &c] { return b++; }();\n" - "}}\n"); + verifyFormat("int c = [b]() mutable { return [&b] { return b++; }(); }();\n"); + verifyFormat("int c = [&] { [=] { return b++; }(); }();\n"); + verifyFormat("int c = [&, &a, a] { [=, c, &d] { return b++; }(); }();\n"); + verifyFormat("int c = [&a, &a, a] { [=, a, b, &c] { return b++; }(); }();\n"); + verifyFormat("auto c = {[&a, &a, a] { [=, a, b, &c] { return b++; }(); }}\n"); verifyFormat("auto c = {[&a, &a, a] { [=, a, b, &c] {}(); }}\n"); verifyFormat("void f() {\n" " other(x.begin(), x.end(), [&](int, int) { return 1; });\n" @@ -8676,7 +8666,7 @@ TEST_F(FormatTest, FormatsBlocks) { verifyFormat("int a = [operation block:^int(int *i) { return 1; }];"); verifyFormat("[myObject doSomethingWith:arg1\n" " aaa:^int(int *a) { return 1; }\n" - " bbb:f(a * b)];"); + " bbb:f(a * bbbbbbbb)];"); verifyFormat("[operation setCompletionBlock:^{\n" " [self.delegate newDataAvailable];\n" |

