summaryrefslogtreecommitdiffstats
path: root/clang/unittests/Format
diff options
context:
space:
mode:
authorDaniel Jasper <djasper@google.com>2015-08-21 11:44:57 +0000
committerDaniel Jasper <djasper@google.com>2015-08-21 11:44:57 +0000
commit100ffc632aa1f9d21ffe2cb66dba6afb59b579f6 (patch)
tree21720983f6ab9cd1145e8a97767b7d89becd2f37 /clang/unittests/Format
parentd386a6ccb9c094087f982ffbdcd1d8880a4a462b (diff)
downloadbcm5719-llvm-100ffc632aa1f9d21ffe2cb66dba6afb59b579f6.tar.gz
bcm5719-llvm-100ffc632aa1f9d21ffe2cb66dba6afb59b579f6.zip
clang-format: Be more conservative about specially indenting blocks in C++.
This is a bit of a step back of what we did in r222531, as there are some corner cases in C++, where this kind of formatting is really bad. Example: Before: virtual aaaaaaaaaaaaaaaa(std::function<bool()> IsKindWeWant = [&]() { return true; }, aaaaa aaaaaaaaa); After: virtual aaaaaaaaaaaaaaaa(std::function<bool()> IsKindWeWant = [&]() { return true; }, aaaaa aaaaaaaaa); The block formatting logic in JavaScript will probably go some other changes, too, and we'll potentially be able to make the rules more consistent again. For now, this seems to be the best approach for C++. llvm-svn: 245694
Diffstat (limited to 'clang/unittests/Format')
-rw-r--r--clang/unittests/Format/FormatTest.cpp33
1 files changed, 21 insertions, 12 deletions
diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp
index 17243b70f78..3f1dc59d933 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -3076,10 +3076,12 @@ TEST_F(FormatTest, LayoutBlockInsideParens) {
" int i;\n"
" int j;\n"
"});");
- verifyFormat("functionCall({\n"
- " int i;\n"
- " int j;\n"
- "}, aaaa, bbbb, cccc);");
+ verifyFormat("functionCall(\n"
+ " {\n"
+ " int i;\n"
+ " int j;\n"
+ " },\n"
+ " aaaa, bbbb, cccc);");
verifyFormat("functionA(functionB({\n"
" int i;\n"
" int j;\n"
@@ -3186,9 +3188,11 @@ TEST_F(FormatTest, LayoutNestedBlocks) {
"});");
FormatStyle Style = getGoogleStyle();
Style.ColumnLimit = 45;
- verifyFormat("Debug(aaaaa, {\n"
- " if (aaaaaaaaaaaaaaaaaaaaaaaa) return;\n"
- "}, a);",
+ verifyFormat("Debug(aaaaa,\n"
+ " {\n"
+ " if (aaaaaaaaaaaaaaaaaaaaaaaa) return;\n"
+ " },\n"
+ " a);",
Style);
verifyFormat("SomeFunction({MACRO({ return output; }), b});");
@@ -8100,11 +8104,13 @@ TEST_F(FormatTest, ConfigurableUseOfTab) {
"};",
Tab);
verifyFormat("{\n"
- "\tQ({\n"
- "\t\tint a;\n"
- "\t\tsomeFunction(aaaaaaaa,\n"
- "\t\t bbbbbbb);\n"
- "\t}, p);\n"
+ "\tQ(\n"
+ "\t {\n"
+ "\t\t int a;\n"
+ "\t\t someFunction(aaaaaaaa,\n"
+ "\t\t bbbbbbb);\n"
+ "\t },\n"
+ "\t p);\n"
"}",
Tab);
EXPECT_EQ("{\n"
@@ -9996,6 +10002,9 @@ TEST_F(FormatTest, FormatsLambdas) {
verifyFormat("SomeFunction({[&] {\n"
" // comment\n"
"}});");
+ verifyFormat("virtual aaaaaaaaaaaaaaaa(std::function<bool()> bbbbbbbbbbbb =\n"
+ " [&]() { return true; },\n"
+ " aaaaa aaaaaaaaa);");
// Lambdas with return types.
verifyFormat("int c = []() -> int { return 2; }();\n");
OpenPOWER on IntegriCloud