Fixes layout of right braces.
We now decide whether a newline should go before the closing brace
depending on whether a newline was inserted after the opening brace.
For example, we now insert a newline before '};' in:
static SomeClass WithALoooooooooooooooooooongName = {
100000000, \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"
};
... while not inserting a newline here:
static SomeClass = { a, b, c, d, e, f, g, h, i, j,
looooooooooooooooooooooooooooooooooongname,
looooooooooooooooooooooooooooooong };
Also fixes the formating of (column limit 25):
int x = {
avariable,
b(alongervariable)
};
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172076 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp
index 439568e..1d9363d 100644
--- a/unittests/Format/FormatTest.cpp
+++ b/unittests/Format/FormatTest.cpp
@@ -430,7 +430,13 @@
// FIXME: Format like enums if the static initializer does not fit on a line.
verifyFormat(
"static SomeClass WithALoooooooooooooooooooongName = {\n"
- " 100000000, \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\" };");
+ " 100000000, \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"\n"
+ "};");
+
+ verifyFormat(
+ "static SomeClass = { a, b, c, d, e, f, g, h, i, j,\n"
+ " looooooooooooooooooooooooooooooooooongname,\n"
+ " looooooooooooooooooooooooooooooong };");
}
TEST_F(FormatTest, FormatsSmallMacroDefinitionsInSingleLine) {
@@ -1121,7 +1127,8 @@
verifyFormat(
"int x = {\n"
" avariable,\n"
- " b(alongervariable) };", getLLVMStyleWithColumns(25));
+ " b(alongervariable)\n"
+ "};", getLLVMStyleWithColumns(25));
}
TEST_F(FormatTest, LayoutTokensFollowingBlockInParentheses) {