return true;
if (State.NextToken->Parent->is(tok::comma) &&
State.Stack.back().BreakAfterComma &&
- State.NextToken->Type != TT_LineComment)
+ (State.NextToken->isNot(tok::comment) ||
+ !State.NextToken->Children[0].MustBreakBefore))
return true;
if ((State.NextToken->Type == TT_CtorInitializerColon ||
(State.NextToken->Parent->ClosesTemplateDeclaration &&
if (Current.FormatTok.MustBreakBefore) {
Current.MustBreakBefore = true;
+ } else if (Current.Type == TT_LineComment) {
+ Current.MustBreakBefore = Current.FormatTok.NewlinesBefore > 0;
+ } else if ((Current.Parent->is(tok::comment) &&
+ Current.FormatTok.NewlinesBefore > 0) ||
+ (Current.is(tok::string_literal) &&
+ Current.Parent->is(tok::string_literal))) {
+ Current.MustBreakBefore = true;
} else {
- if (Current.Type == TT_LineComment) {
- Current.MustBreakBefore = Current.FormatTok.NewlinesBefore > 0;
- } else if ((Current.Parent->is(tok::comment) &&
- Current.FormatTok.NewlinesBefore > 0) ||
- (Current.is(tok::string_literal) &&
- Current.Parent->is(tok::string_literal))) {
- Current.MustBreakBefore = true;
- } else {
- Current.MustBreakBefore = false;
- }
+ Current.MustBreakBefore = false;
}
Current.CanBreakBefore = Current.MustBreakBefore || canBreakBefore(Current);
if (Current.MustBreakBefore)
" parameter);",
format("#define A\n"
"/* */someCall(parameter);", getLLVMStyleWithColumns(15)));
+
+ EXPECT_EQ("someFunction(1, /* comment 1 */\n"
+ " 2, /* comment 2 */\n"
+ " 3, /* comment 3 */\n"
+ " aaaa);",
+ format("someFunction (1, /* comment 1 */\n"
+ " 2, /* comment 2 */ \n"
+ " 3, /* comment 3 */\n"
+ "aaaa );", getGoogleStyle()));
}
TEST_F(FormatTest, FormatStarDependingOnContext) {