Skip to content

reformat all c++ files with clang-format#48328

Merged
jkarneges merged 1 commit intomainfrom
jkarneges/clang-format
Apr 24, 2026
Merged

reformat all c++ files with clang-format#48328
jkarneges merged 1 commit intomainfrom
jkarneges/clang-format

Conversation

@jkarneges
Copy link
Copy Markdown
Member

We should autoformat the C++ code similar to how we use rustfmt for the Rust code. This PR uses clang-format to reformat all of the C++ code to a consistent, modern style. I did not attempt to preserve the existing style which was doing some things I think we should phase out, such as braces on new lines. This change only contains the reformatting and nothing else. Later, we can add a .clang-format file, update CI to enforce style, etc.

To review, I suggest performing the same mass reformatting locally and confirming the resulting diff is the same as this one. To do that:

  • Install clang-format

  • Add the following .clang-format file to the root of the project:

Language: Cpp
BasedOnStyle: LLVM

# Use 4 spaces to match rustfmt
IndentWidth: 4
ContinuationIndentWidth: 4
ConstructorInitializerIndentWidth: 4

# Keep braces on the same line (Rust/Modern C++ style)
BreakBeforeBraces: Attach

# Clean layout
ConstructorInitializerAllOnOneLineOrOnePerLine: true
AccessModifierOffset: -4
ColumnLimit: 100
  • Run find src -name "*.cpp" -o -name "*.h" | xargs clang-format -i from the project root. As far as I can tell, clang-format can't crawl a project tree on its own so we have to use something like find to hit every file.

@jkarneges jkarneges force-pushed the jkarneges/clang-format branch from d9425f2 to f623bd4 Compare April 24, 2026 14:57
@jkarneges jkarneges requested a review from a team April 24, 2026 15:39
Copy link
Copy Markdown
Member

@deg4uss3r deg4uss3r left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah... LGTM

@jkarneges jkarneges merged commit 87720fa into main Apr 24, 2026
19 checks passed
@jkarneges jkarneges deleted the jkarneges/clang-format branch April 24, 2026 15:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants