clang-format: With ColumnLimit=0, keep short array literals on a line.
Before:
NSArray* a = [[NSArray alloc] initWithArray:@[
@"a"
]
copyItems:YES];
After:
NSArray* a = [[NSArray alloc] initWithArray:@[ @"a" ]
copyItems:YES];
This fixed llvm.org/PR19080.
llvm-svn: 206161
diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp
index 0dc0659..7bae21b 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -8148,6 +8148,20 @@
format("#define aNumber \\\n"
" 10",
Style));
+
+ // Keep empty and one-element array literals on a single line.
+ verifyFormat("NSArray* a = [[NSArray alloc] initWithArray:@[]\n"
+ " copyItems:YES];",
+ Style);
+ verifyFormat("NSArray* a = [[NSArray alloc] initWithArray:@[ @\"a\" ]\n"
+ " copyItems:YES];",
+ Style);
+ verifyFormat("NSArray* a = [[NSArray alloc] initWithArray:@[\n"
+ " @\"a\",\n"
+ " @\"a\"\n"
+ " ]\n"
+ " copyItems:YES];",
+ Style);
}
TEST_F(FormatTest, FormatsLambdas) {