From c4144ea4186809e6cea44b97a3e5f60a0b2bf07a Mon Sep 17 00:00:00 2001 From: Daniel Jasper Date: Wed, 13 May 2015 16:09:21 +0000 Subject: clang-format: Improve nested block / lambda indentation when wrapping before binary/ternary operators. Basically, it doesn't seem right to indent a nested block aligned to a binary or ternary operator. Before: int i = aaaaaa ? 1 // : [] { return 2; // }(); llvm::errs() << "number of twos is " << std::count_if(v.begin(), v.end(), [](int x) { return x == 2; // force break }); After: int i = aaaaaa ? 1 // : [] { return 2; // }(); llvm::errs() << "number of twos is " << std::count_if(v.begin(), v.end(), [](int x) { return x == 2; // force break }); llvm-svn: 237263 --- clang/unittests/Format/FormatTest.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'clang/unittests/Format/FormatTest.cpp') diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index c44708fbf6c..d5614b84305 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -9992,6 +9992,14 @@ TEST_F(FormatTest, FormatsLambdas) { verifyFormat("auto my_lambda = [](const string &some_parameter) {\n" " return some_parameter.size();\n" "};"); + verifyFormat("int i = aaaaaa ? 1 //\n" + " : [] {\n" + " return 2; //\n" + " }();"); + verifyFormat("llvm::errs() << \"number of twos is \"\n" + " << std::count_if(v.begin(), v.end(), [](int x) {\n" + " return x == 2; // force break\n" + " });"); // Lambdas with return types. verifyFormat("int c = []() -> int { return 2; }();\n"); -- cgit v1.2.3