Skip to content

style: Normalize insertion of braces after control statements#161

Merged
jcfr merged 2 commits intocommontk:mainfrom
jcfr:clang-format-insert-braces
Aug 26, 2025
Merged

style: Normalize insertion of braces after control statements#161
jcfr merged 2 commits intocommontk:mainfrom
jcfr:clang-format-insert-braces

Conversation

@jcfr
Copy link
Member

@jcfr jcfr commented Aug 25, 2025

Insert braces after control statements (if, else, for, do, and while) in C++ unless the control statements are inside macro definitions or the braces would enclose preprocessor directives.

See https://releases.llvm.org/20.1.0/tools/clang/docs/ClangFormatStyleOptions.html#insertbraces

jcfr added 2 commits August 25, 2025 14:33
This commit applies formatting to C++ source files based on `clang-format`
settings introduced in the following commit.

Running `pre-commit` required updating the `.clang-format` configuration with
the following patch:

```
diff --git a/.clang-format b/.clang-format
index 9c965e3..74a17a6 100644
--- a/.clang-format
+++ b/.clang-format
@@ -15,6 +15,7 @@ AlwaysBreakTemplateDeclarations: true
 BreakBeforeBinaryOperators: NonAssignment
 ConstructorInitializerIndentWidth: 2
 IndentPPDirectives: AfterHash
+InsertBraces: true
 PackConstructorInitializers: Never
 PPIndentWidth: 1
```
Insert braces after control statements (if, else, for, do, and while) in
C++ unless the control statements are inside macro definitions or the
braces would enclose preprocessor directives.
@jcfr jcfr enabled auto-merge (rebase) August 25, 2025 18:35
@jcfr jcfr merged commit 52c0a14 into commontk:main Aug 26, 2025
11 of 13 checks passed
@jcfr jcfr deleted the clang-format-insert-braces branch August 26, 2025 16:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants