summaryrefslogtreecommitdiffstats
path: root/clang/lib/Format/TokenAnnotator.cpp
diff options
context:
space:
mode:
authorDaniel Jasper <djasper@google.com>2015-02-27 08:41:05 +0000
committerDaniel Jasper <djasper@google.com>2015-02-27 08:41:05 +0000
commit308062bd0dae3f25463a36d4208267422cc083da (patch)
tree6e48cb455869f778315fec3962868d147bcf11cf /clang/lib/Format/TokenAnnotator.cpp
parent7fe82ad80bb9c002db66c65ec39219969cfccf3d (diff)
downloadbcm5719-llvm-308062bd0dae3f25463a36d4208267422cc083da.tar.gz
bcm5719-llvm-308062bd0dae3f25463a36d4208267422cc083da.zip
clang-format: Make trailing commas in array inits force one per line.
Before: NSArray *array = @[ @"a", @"a", ]; After: NSArray *array = @[ @"a", @"a", ]; llvm-svn: 230741
Diffstat (limited to 'clang/lib/Format/TokenAnnotator.cpp')
-rw-r--r--clang/lib/Format/TokenAnnotator.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp
index fa086a9773f..7c35545b50f 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -1870,9 +1870,12 @@ bool TokenAnnotator::mustBreakBefore(const AnnotatedLine &Line,
// intention is to insert a line break after it in order to make shuffling
// around entries easier.
const FormatToken *BeforeClosingBrace = nullptr;
- if (Left.is(tok::l_brace) && Left.BlockKind != BK_Block && Left.MatchingParen)
+ if (Left.isOneOf(tok::l_brace, TT_ArrayInitializerLSquare) &&
+ Left.BlockKind != BK_Block && Left.MatchingParen)
BeforeClosingBrace = Left.MatchingParen->Previous;
- else if (Right.is(tok::r_brace) && Right.BlockKind != BK_Block)
+ else if (Right.MatchingParen &&
+ Right.MatchingParen->isOneOf(tok::l_brace,
+ TT_ArrayInitializerLSquare))
BeforeClosingBrace = &Left;
if (BeforeClosingBrace && (BeforeClosingBrace->is(tok::comma) ||
BeforeClosingBrace->isTrailingComment()))
OpenPOWER on IntegriCloud