I would like to know if clang-format can be set to reduce non- compound_statement to { non-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 ;
Example
Input:
if (exp) foo = 1;
Output:
if (exp) { foo = 1; }
Then, as necessary, the decorator will back off.
source share