[cfe-dev] [clang-format] add {} around statement after if() while() for()

Curdeius Curdeius via cfe-dev cfe-dev at lists.llvm.org
Thu Jan 28 00:57:42 PST 2016


Hi,

You need to take a look at clang-tidy check
readability-braces-around-statements.
It's documentation can be found at
http://clang.llvm.org/extra/clang-tidy/checks/readability-braces-around-statements.html
.

Best regards,
Marek Kurdej


> Hi,
>
> I'd like to know if clang-format could be setup to reduce
> non-compound_statement into { 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
> ;
>
> i.e for construct like if(exp)foo=1; I'd like to get if(exp){foo=1;} Then
> the beautifier would indent as needed.
>
> Thanx in advance Cheers, Phi
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20160128/2e44201d/attachment.html>


More information about the cfe-dev mailing list