It seems like most people see unary operators more like part of the
subsequent identifier and find relative indentation odd.
Before:
aaaaaaaaaa(!
aaaaaaaaaa( // break
aaaaa));
After:
aaaaaaaaaa(!
aaaaaaaaaa( // break
aaaaa));
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@200840
91177308-0d34-0410-b5e6-
96231b3b80d8
State.Stack.back().LastSpace = State.Column;
else if ((Previous.Type == TT_BinaryOperator ||
Previous.Type == TT_ConditionalExpr ||
- Previous.Type == TT_UnaryOperator ||
Previous.Type == TT_CtorInitializerColon) &&
(Previous.getPrecedence() != prec::Assignment ||
Current.StartsBinaryExpression))
verifyFormat("int a = i /* confusing comment */++;");
}
-TEST_F(FormatTest, IndentsRelativeToUnaryOperators) {
+TEST_F(FormatTest, DoesNotIndentRelativeToUnaryOperators) {
verifyFormat("if (!aaaaaaaaaa( // break\n"
- " aaaaa)) {\n"
+ " aaaaa)) {\n"
"}");
verifyFormat("aaaaaaaaaa(!aaaaaaaaaa( // break\n"
- " aaaaa));");
-
- // Only indent relative to unary operators if the expression is nested.
+ " aaaaa));");
verifyFormat("*aaa = aaaaaaa( // break\n"
" bbbbbb);");
}