clang-format: Cleanup array initializer and dict initializer formatting.
Significant changes:
- Also recognize these literals with missing "@" for robustness.
- Reorganize tests.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@193325 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Format/ContinuationIndenter.cpp b/lib/Format/ContinuationIndenter.cpp
index 16b1147..68b440d 100644
--- a/lib/Format/ContinuationIndenter.cpp
+++ b/lib/Format/ContinuationIndenter.cpp
@@ -98,6 +98,7 @@
// The opening "{" of a braced list has to be on the same line as the first
// element if it is nested in another braced init list or function call.
if (!Current.MustBreakBefore && Previous.is(tok::l_brace) &&
+ Previous.Type != TT_DictLiteral &&
Previous.BlockKind == BK_BracedInit && Previous.Previous &&
Previous.Previous->isOneOf(tok::l_brace, tok::l_paren, tok::comma))
return false;
@@ -134,7 +135,7 @@
!Previous.isOneOf(tok::kw_return, tok::lessless) &&
Previous.Type != TT_InlineASMColon && NextIsMultilineString(State))
return true;
- if (((Previous.Type == TT_ObjCDictLiteral && Previous.is(tok::l_brace)) ||
+ if (((Previous.Type == TT_DictLiteral && Previous.is(tok::l_brace)) ||
Previous.Type == TT_ArrayInitializerLSquare) &&
getLengthToMatchingParen(Previous) + State.Column > getColumnLimit(State))
return true;
@@ -572,7 +573,7 @@
const FormatToken *NextNoComment = Current.getNextNonComment();
AvoidBinPacking = Current.BlockKind == BK_Block ||
Current.Type == TT_ArrayInitializerLSquare ||
- Current.Type == TT_ObjCDictLiteral ||
+ Current.Type == TT_DictLiteral ||
(NextNoComment &&
NextNoComment->Type == TT_DesignatedInitializerPeriod);
} else {