before binary/ternary operators.
Basically, it doesn't seem right to indent a nested block aligned to a
binary or ternary operator.
Before:
int i = aaaaaa ? 1 //
: [] {
return 2; //
}();
llvm::errs() << "number of twos is "
<< std::count_if(v.begin(), v.end(), [](int x) {
return x == 2; // force break
});
After:
int i = aaaaaa ? 1 //
: [] {
return 2; //
}();
llvm::errs() << "number of twos is "
<< std::count_if(v.begin(), v.end(), [](int x) {
return x == 2; // force break
});
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@237263
91177308-0d34-0410-b5e6-
96231b3b80d8
State.Stack.back().AvoidBinPacking = true;
State.Stack.back().BreakBeforeParameter = false;
}
+ if (Current.isOneOf(TT_BinaryOperator, TT_ConditionalExpr) && Newline)
+ State.Stack.back().NestedBlockIndent =
+ State.Column + Current.ColumnWidth + 1;
// Insert scopes created by fake parenthesis.
const FormatToken *Previous = Current.getPreviousNonComment();
verifyFormat("auto my_lambda = [](const string &some_parameter) {\n"
" return some_parameter.size();\n"
"};");
+ verifyFormat("int i = aaaaaa ? 1 //\n"
+ " : [] {\n"
+ " return 2; //\n"
+ " }();");
+ verifyFormat("llvm::errs() << \"number of twos is \"\n"
+ " << std::count_if(v.begin(), v.end(), [](int x) {\n"
+ " return x == 2; // force break\n"
+ " });");
// Lambdas with return types.
verifyFormat("int c = []() -> int { return 2; }();\n");