summaryrefslogtreecommitdiffstats
path: root/clang/unittests/Format/FormatTest.cpp
diff options
context:
space:
mode:
authorIlya Biryukov <ibiryukov@google.com>2018-09-17 07:46:20 +0000
committerIlya Biryukov <ibiryukov@google.com>2018-09-17 07:46:20 +0000
commit370eff85b9ea544d9bb15149150676376eb66509 (patch)
tree6e74722fa2570682f73002fb598b6027f0010841 /clang/unittests/Format/FormatTest.cpp
parenta57afd091f294cb4f8ba367d4f3b056d2bc51f3a (diff)
downloadbcm5719-llvm-370eff85b9ea544d9bb15149150676376eb66509.tar.gz
bcm5719-llvm-370eff85b9ea544d9bb15149150676376eb66509.zip
[clang-Format] Fix indentation of member call after block
Summary: before patch: > echo "test() {([]() -> {int b = 32;return 3;}).as("");});" | clang-format -style=Google ``` test() { ([]() -> { int b = 32; return 3; }) .as(); }); ``` after patch: > echo "test() {([]() -> {int b = 32;return 3;}).as("");});" | clang-format -style=Google ``` test() { ([]() -> { int b = 32; return 3; }).as(); }); ``` Patch by Anders Karlsson (ank)! Reviewers: klimek Reviewed By: klimek Subscribers: danilaml, acoomans, klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D45719 llvm-svn: 342363
Diffstat (limited to 'clang/unittests/Format/FormatTest.cpp')
-rw-r--r--clang/unittests/Format/FormatTest.cpp34
1 files changed, 34 insertions, 0 deletions
diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp
index 70bc9e0ed73..db2e226a30e 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -4557,6 +4557,40 @@ TEST_F(FormatTest, FormatsBuilderPattern) {
verifyFormat("aaaa.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(\n"
" aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa)\n"
" .aaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa);");
+
+ // Dont break if only closing statements before member call
+ verifyFormat("test() {\n"
+ " ([]() -> {\n"
+ " int b = 32;\n"
+ " return 3;\n"
+ " }).foo();\n"
+ "}");
+ verifyFormat("test() {\n"
+ " (\n"
+ " []() -> {\n"
+ " int b = 32;\n"
+ " return 3;\n"
+ " },\n"
+ " foo, bar)\n"
+ " .foo();\n"
+ "}");
+ verifyFormat("test() {\n"
+ " ([]() -> {\n"
+ " int b = 32;\n"
+ " return 3;\n"
+ " })\n"
+ " .foo()\n"
+ " .bar();\n"
+ "}");
+ verifyFormat("test() {\n"
+ " ([]() -> {\n"
+ " int b = 32;\n"
+ " return 3;\n"
+ " })\n"
+ " .foo(\"aaaaaaaaaaaaaaaaa\"\n"
+ " \"bbbb\");\n"
+ "}",
+ getLLVMStyleWithColumns(30));
}
TEST_F(FormatTest, BreaksAccordingToOperatorPrecedence) {
OpenPOWER on IntegriCloud