我想知道是否可以设置 clang-format 来减少compound_statement
非{ non-compound_statement; }
in iteration_statement
。
statement
: labeled_statement
| compound_statement
| expression_statement
| selection_statement
| iteration_statement
| jump_statement
;
iteration_statement
: WHILE '(' expression ')' statement
| DO statement WHILE '(' expression ')' ';'
| FOR '(' expression_statement expression_statement ')' statement
| FOR '(' expression_statement expression_statement expression ')' statement
;
例子
输入:
if (exp) foo = 1;
输出:
if (exp) { foo = 1; }
然后美化器会根据需要缩进。