Tôi muốn biết liệu định dạng clang có thể được thiết lập để giảm không compound_statement
thành { non-compound_statement; }
trong iteration_statement
.định dạng clang thêm {} xung quanh câu lệnh sau if if() while() cho()
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
;
Ví dụ
Input:
if (exp) foo = 1;
Output:
if (exp) { foo = 1; }
Sau đó beautifier sẽ thụt khi cần thiết.
định dạng clang có thể không phải là những gì bạn đang tìm kiếm. Bạn đã thử sử dụng 'clang-tidy' chưa? – PythonJin