return true;
}
if ((Previous.isOneOf(tok::comma, tok::semi) || Current.is(tok::question) ||
- Current.Type == TT_ConditionalExpr) &&
+ (Current.Type == TT_ConditionalExpr &&
+ !(Current.is(tok::colon) && Previous.is(tok::question)))) &&
State.Stack.back().BreakBeforeParameter &&
!Current.isTrailingComment() &&
!Current.isOneOf(tok::r_paren, tok::r_brace))
if (Left.is(tok::colon))
return Left.Type != TT_ObjCMethodExpr;
if (Right.is(tok::colon))
- return Right.Type != TT_ObjCMethodExpr;
+ return Right.Type != TT_ObjCMethodExpr && !Left.is(tok::question);
if (Left.is(tok::l_paren))
return false;
if (Right.is(tok::l_paren)) {
return false;
if (Tok.is(tok::colon))
return !Line.First->isOneOf(tok::kw_case, tok::kw_default) &&
- Tok.getNextNonComment() != NULL && Tok.Type != TT_ObjCMethodExpr;
+ Tok.getNextNonComment() != NULL && Tok.Type != TT_ObjCMethodExpr &&
+ !Tok.Previous->is(tok::question);
if (Tok.Previous->Type == TT_UnaryOperator ||
Tok.Previous->Type == TT_CastRParen)
return false;
return true;
if (Left.ClosesTemplateDeclaration)
return true;
- if (Right.Type == TT_ConditionalExpr || Right.is(tok::question))
+ if ((Right.Type == TT_ConditionalExpr &&
+ !(Right.is(tok::colon) && Left.is(tok::question))) ||
+ Right.is(tok::question))
return true;
if (Right.Type == TT_RangeBasedForLoopColon ||
Right.Type == TT_OverloadedOperatorLParen)
" aaaaaaaaaaaaaaaa ? aaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n"
" : aaaaaaaaaaaaaaaaaaaaaaaaaaaa,\n"
" aaaaaaaaaaaaa);");
+ verifyFormat(
+ "aaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaa,\n"
+ " aaaaaaaaaaaaaaaa ?: aaaaaaaaaaaaaaaaaaaaaaaaaaaa,\n"
+ " aaaaaaaaaaaaa);");
verifyFormat("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n"
" ? aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(\n"
" aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa)\n"
" : aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(\n"
" aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa),\n"
" aaaaaaaaaaaaaaaaaaaaaaaaaaa);");
-
+ verifyFormat("aaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,\n"
+ " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n"
+ " ?: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(\n"
+ " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa),\n"
+ " aaaaaaaaaaaaaaaaaaaaaaaaaaa);");
verifyFormat("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n"
" ? aaaaaaaaaaaaaaaaaaaaaaaaaaa\n"
" : aaaaaaaaaaaaaaaaaaaaaaaaaaa;");
" : aaaaaaaaaaaaaaa);\n"
"}",
NoBinPacking);
+ verifyFormat(
+ "void f() {\n"
+ " g(aaa,\n"
+ " aaaaaaaaaa == aaaaaaaaaa ? aaaa : aaaaa,\n"
+ " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa == aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n"
+ " ?: aaaaaaaaaaaaaaa);\n"
+ "}",
+ NoBinPacking);
}
TEST_F(FormatTest, DeclarationsOfMultipleVariables) {