if (Indent > Style.ColumnLimit)
return 0;
- unsigned Limit = Style.ColumnLimit - Indent;
+ unsigned Limit =
+ Style.ColumnLimit == 0 ? UINT_MAX : Style.ColumnLimit - Indent;
// If we already exceed the column limit, we set 'Limit' to 0. The different
// tryMerge..() functions can then decide whether to still do merging.
Limit = TheLine->Last->TotalLength > Limit
assert(!B.First->Previous);
A.Last->Next = B.First;
B.First->Previous = A.Last;
+ B.First->CanBreakBefore = true;
unsigned LengthA = A.Last->TotalLength + B.First->SpacesRequiredBefore;
for (FormatToken *Tok = B.First; Tok; Tok = Tok->Next) {
Tok->TotalLength += LengthA;
" i++;\n"
"}",
format("if (aaaaaaaaaaaaaaa || bbbbbbbbbbbbbbb) { i++; }", Style));
+
+ // Don't automatically break all macro definitions (llvm.org/PR17842).
+ verifyFormat("#define aNumber 10", Style);
+ // However, generally keep the line breaks that the user authored.
+ EXPECT_EQ("#define aNumber \\\n"
+ " 10",
+ format("#define aNumber \\\n"
+ " 10",
+ Style));
}
TEST_F(FormatTest, FormatsProtocolBufferDefinitions) {