// Treat the condition inside an if as if it was a second function
// parameter, i.e. let nested calls have an indent of 4.
State.Stack.back().LastSpace = State.Column + 1; // 1 is length of "(".
- else if (Spaces > 0 && ParenLevel != 0)
+ else if (Previous.is(tok::comma) && ParenLevel != 0)
// Top-level spaces are exempt as that mostly leads to better results.
State.Stack.back().LastSpace = State.Column;
}
if (Right.is(tok::colon) && Right.Type == TT_ObjCMethodExpr)
return 20;
- if (Left.is(tok::l_paren))
+ if (Left.is(tok::l_paren) || Left.Type == TT_TemplateOpener)
return 20;
if (Left.is(tok::question) || Left.Type == TT_ConditionalExpr)
// This test takes VERY long when memoization is broken.
std::string input = "Constructor()\n"
- " : aaaa(a,\n";
+ " : aaaa(a,\n";
for (unsigned i = 0, e = 80; i != e; ++i) {
input += " a,\n";
}
verifyFormat(
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa &&\n"
" aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa);");
+ verifyFormat(
+ "aaaaaa(new Aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(\n"
+ " aaaaaaaaaaaaaaaaaaaaaaaaaaaaa));");
+ verifyFormat(
+ "aaaaaa(aaa, new Aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(\n"
+ " aaaaaaaaaaaaaaaaaaaaaaaaaaaaa));");
// This test case breaks on an incorrect memoization, i.e. an optimization not
// taking into account the StopAt value.
"template <typename T1, typename T2 = char, typename T3 = char,\n"
" typename T4 = char>\n"
"void f();");
+ verifyFormat(
+ "aaaaaaaaaaaaaaaaaaaaaaaa<aaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaa>(\n"
+ " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa);");
}
TEST_F(FormatTest, WrapsAtNestedNameSpecifiers) {
verifyFormat(
"void f() {\n"
" if ((self = [super initWithContentRect:contentRect styleMask:styleMask\n"
- " backing:NSBackingStoreBuffered defer:YES]))");
+ " backing:NSBackingStoreBuffered defer:YES]))");
verifyFormat("[foo checkThatBreakingAfterColonWorksOk:\n"
" [bar ifItDoes:reduceOverallLineLengthLikeInThisCase]];");