summaryrefslogtreecommitdiffstats
path: root/clang/lib/Format/ContinuationIndenter.cpp
diff options
context:
space:
mode:
authorDaniel Jasper <djasper@google.com>2013-10-24 10:31:50 +0000
committerDaniel Jasper <djasper@google.com>2013-10-24 10:31:50 +0000
commitb596fb2be2e436ac24162c284fdbe3fe6f69be3d (patch)
tree5ba1c922ccdc2393e914a0b21cefcba3b2c93552 /clang/lib/Format/ContinuationIndenter.cpp
parent1ec9df3322d05a5be1144acd4d013865f9eb353f (diff)
downloadbcm5719-llvm-b596fb2be2e436ac24162c284fdbe3fe6f69be3d.tar.gz
bcm5719-llvm-b596fb2be2e436ac24162c284fdbe3fe6f69be3d.zip
clang-format: Cleanup array initializer and dict initializer formatting.
Significant changes: - Also recognize these literals with missing "@" for robustness. - Reorganize tests. llvm-svn: 193325
Diffstat (limited to 'clang/lib/Format/ContinuationIndenter.cpp')
-rw-r--r--clang/lib/Format/ContinuationIndenter.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/clang/lib/Format/ContinuationIndenter.cpp b/clang/lib/Format/ContinuationIndenter.cpp
index 16b1147fd58..68b440dbe3f 100644
--- a/clang/lib/Format/ContinuationIndenter.cpp
+++ b/clang/lib/Format/ContinuationIndenter.cpp
@@ -98,6 +98,7 @@ bool ContinuationIndenter::canBreak(const LineState &State) {
// 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 @@ bool ContinuationIndenter::mustBreak(const LineState &State) {
!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 @@ unsigned ContinuationIndenter::moveStateToNextToken(LineState &State,
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 {
OpenPOWER on IntegriCloud