diff options
author | Daniel Jasper <djasper@google.com> | 2015-05-11 13:35:40 +0000 |
---|---|---|
committer | Daniel Jasper <djasper@google.com> | 2015-05-11 13:35:40 +0000 |
commit | d57843d4e3f1646ddc3c057b6d8daf6c97978aab (patch) | |
tree | 8b7b5f4da8bcfbc2fa7b42f2c8ed203d8aa77598 /clang/unittests/Format/FormatTest.cpp | |
parent | ff82fce1c09d27f5d11bed76f44eb14d9d764180 (diff) | |
download | bcm5719-llvm-d57843d4e3f1646ddc3c057b6d8daf6c97978aab.tar.gz bcm5719-llvm-d57843d4e3f1646ddc3c057b6d8daf6c97978aab.zip |
clang-format: Improve column layout.
Specifically, calculate the deviation between the shortest and longest
element (which is used to prevent excessive whitespace) per column, not
overall. This automatically handles the corner cases of a single column
and a single row so that the actualy implementation becomes simpler.
Before:
vector<int> x = {1,
aaaaaaaaaaaaaaaaaaaaaa,
2,
bbbbbbbbbbbbbbbbbbbbbb,
3,
cccccccccccccccccccccc};
After:
vector<int> x = {1, aaaaaaaaaaaaaaaaaaaaaa,
2, bbbbbbbbbbbbbbbbbbbbbb,
3, cccccccccccccccccccccc};
llvm-svn: 236992
Diffstat (limited to 'clang/unittests/Format/FormatTest.cpp')
-rw-r--r-- | clang/unittests/Format/FormatTest.cpp | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index 43f94f0ce6d..9098d2b9bf4 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -6305,6 +6305,11 @@ TEST_F(FormatTest, FormatsBracedListsInColumnLayout) { " \"aaaaaaaaaaaa\",\n" " \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\n" "};"); + verifyFormat("vector<int> x = {1, 2, 3, 4, aaaaaaaaaaaaaaaaa, 6};"); + verifyFormat("vector<int> x = {1, aaaaaaaaaaaaaaaaaaaaaa,\n" + " 2, bbbbbbbbbbbbbbbbbbbbbb,\n" + " 3, cccccccccccccccccccccc};", + getLLVMStyleWithColumns(60)); // Trailing commas. verifyFormat("vector<int> x = {\n" |