summaryrefslogtreecommitdiffstats
path: root/unittests/Format/FormatTestJava.cpp
diff options
context:
space:
mode:
authorFrancois Ferrand <thetypz@gmail.com>2017-06-30 20:00:02 +0000
committerFrancois Ferrand <thetypz@gmail.com>2017-06-30 20:00:02 +0000
commitfcf6e44da02732ee08478890bf8ec1a56758ff73 (patch)
treee8b7fab08a94f2b0a496db5348eed3235fa2bb6a /unittests/Format/FormatTestJava.cpp
parent77c1cc560fcefbc6f63434f0dd946fa2190e0411 (diff)
clang-format: Do not binpack initialization lists
Summary: This patch tries to avoid binpacking when initializing lists/arrays, to allow things like: static int types[] = { registerType1(), registerType2(), registerType3(), }; std::map<int, std::string> x = { { 0, "foo fjakfjaklf kljj" }, { 1, "bar fjakfjaklf kljj" }, { 2, "stuff fjakfjaklf kljj" }, }; This is similar to how dictionnaries are formatted, and actually corresponds to the same conditions: when initializing a container (and not just 'calling' a constructor). Such formatting involves 2 things: * Line breaks around the content of the block. This can be forced by adding a comma or comment after the last element * Elements should not be binpacked This patch considers the block is an initializer list if it either ends with a comma, or follows an assignment, which seems to provide a sensible approximation. Reviewers: krasimir, djasper Reviewed By: djasper Subscribers: malcolm.parsons, klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D34238 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@306868 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'unittests/Format/FormatTestJava.cpp')
-rw-r--r--unittests/Format/FormatTestJava.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/unittests/Format/FormatTestJava.cpp b/unittests/Format/FormatTestJava.cpp
index 6e685f6703..b9cfaffb01 100644
--- a/unittests/Format/FormatTestJava.cpp
+++ b/unittests/Format/FormatTestJava.cpp
@@ -237,7 +237,10 @@ TEST_F(FormatTestJava, EnumDeclarations) {
TEST_F(FormatTestJava, ArrayInitializers) {
verifyFormat("new int[] {1, 2, 3, 4};");
verifyFormat("new int[] {\n"
- " 1, 2, 3, 4,\n"
+ " 1,\n"
+ " 2,\n"
+ " 3,\n"
+ " 4,\n"
"};");
FormatStyle Style = getStyleWithColumns(65);