if (I[1]->Last->Type == TT_LineComment)
return 0;
do {
- if (Tok->isOneOf(tok::l_brace, tok::r_brace) &&
+ if (Tok->is(tok::l_brace) && Tok->BlockKind != BK_BracedInit &&
!Style.AllowShortBlocksOnASingleLine)
return 0;
Tok = Tok->Next;
ScopedContextCreator ContextCreator(*this, tok::l_brace, 1);
Contexts.back().ColonIsDictLiteral = true;
+ if (Left->BlockKind == BK_BracedInit)
+ Contexts.back().IsExpression = true;
while (CurrentToken) {
if (CurrentToken->is(tok::r_brace)) {
verifyFormat("auto PointerBinding = [](const char *S) {};");
verifyFormat("typedef typeof(int(int, int)) *MyFunc;");
verifyIndependentOfContext("typedef void (*f)(int *a);");
+ verifyIndependentOfContext("int i{a * b};");
verifyIndependentOfContext("InvalidRegions[*R] = 0;");
TEST_F(FormatTest, DoNotPrematurelyEndUnwrappedLineForReturnStatements) {
verifyFormat(
- "void f() {\n"
- " return C{param1, param2}.SomeCall(param1, param2);\n"
- "}\n");
+ "void f() { return C{param1, param2}.SomeCall(param1, param2); }");
}
TEST_F(FormatTest, FormatsClosingBracesInEmptyNestedBlocks) {