unsigned ContinuationIndenter::breakProtrudingToken(const FormatToken &Current,
LineState &State,
bool DryRun) {
+ if (!Current.isOneOf(tok::string_literal, tok::comment))
+ return 0;
+
llvm::OwningPtr<BreakableToken> Token;
unsigned StartColumn = State.Column - Current.CodePointCount;
unsigned OriginalStartColumn =
SmallVector<unsigned, 8> EndOfLineItemLength;
for (unsigned i = 0, e = Commas.size() + 1; i != e; ++i) {
+ // If there is a trailing comma in the list, the next item will start at the
+ // closing brace. Don't create an extra item for this.
+ if (ItemBegin == Token->MatchingParen)
+ break;
+
// Skip comments on their own line.
while (ItemBegin->HasUnescapedNewline && ItemBegin->isTrailingComment())
ItemBegin = ItemBegin->Next;
" 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1\n"
"};",
getLLVMStyleWithColumns(40));
+
+ // Trailing commas.
+ verifyFormat("vector<int> x = { 1, 1, 1, 1,\n"
+ " 1, 1, 1, 1, };",
+ getLLVMStyleWithColumns(39));
+ verifyFormat("vector<int> x = {\n"
+ " 1, 1, 1, 1, 1, 1, 1, 1, //\n"
+ "};",
+ getLLVMStyleWithColumns(39));
}
TEST_F(FormatTest, PullTrivialFunctionDefinitionsIntoSingleLine) {