Skip to content

Code Formatting: Add braces around control statements

Christoph Fischer requested to merge devel_issue_413 into master

Closes #413 (closed).

The InsertBraces option in clang-format (see https://clang.llvm.org/docs/ClangFormatStyleOptions.html) generates braces for one-line control statements (if, for...). So

if (foo) 
    bar();

becomes

if (foo)
{
    bar();
}

Added this to the clang-format file. Note as stated in the documentation that there it can't be guaranteed that this option always works due to clang-format’s lack of complete semantic information.

Edited by Christoph Fischer

Merge request reports