Repository navigation
Add clang-format to pre-commit hooks #3133
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
72728a8
Add clang-format to pre-commit hooks
mdboom 4e9e33d
Fix test
mdboom a86e93a
Address comments in the PR
mdboom 5dd7ad5
Merge remote-tracking branch 'upstream/main' into clang-format
mdboom 3fce667
Modernize clang-format style
mdboom fd13151
Revert lambda layout
mdboom ab52ed1
Use AllDefinitions
mdboom 802b6cf
Merge remote-tracking branch 'upstream/main' into clang-format
mdboom 1ea9e62
Merge branch 'main' into clang-format
mdboom 65bedfb
Merge branch 'main' into clang-format
mdboom File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| # SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| # | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| # A clang-format style derived from Python's PEP 7 (4-space indent, Stroustrup braces, | ||
| # return type on its own line), except that the column limit is 120 rather than 79. | ||
| # Based on https://gist.github.com/pganssle/0e3a5f828b4d07d79447f6ced8e7e4db | ||
| BasedOnStyle: Google | ||
| BreakAfterReturnType: AllDefinitions | ||
| AllowShortIfStatementsOnASingleLine: Never | ||
| BreakBeforeBraces: Stroustrup | ||
| ColumnLimit: 120 | ||
| DerivePointerAlignment: false | ||
| IndentWidth: 4 | ||
| Language: Cpp | ||
| PointerAlignment: Right | ||
| ReflowComments: Always | ||
| SpaceBeforeParens: ControlStatements | ||
| SpacesInParens: Never | ||
| TabWidth: 4 | ||
| UseTab: Never | ||
|
|
||
| # Keep include order as written; reordering can break order-sensitive builds. | ||
| SortIncludes: {Enabled: false} | ||
|
|
||
| # Ruff-like wrapping: break after "(", indent arguments, put ")" on its own line. | ||
| # This does not contradict PEP7, but extends it to the consistent style where | ||
| # calls either fit on a single line or they are broken across multiple lines with | ||
| # one argument per line (indented). | ||
| AlignAfterOpenBracket: true | ||
| BreakAfterOpenBracketBracedList: true | ||
| BreakAfterOpenBracketFunction: true | ||
| BreakAfterOpenBracketIf: true | ||
| BreakBeforeCloseBracketBracedList: true | ||
| BreakBeforeCloseBracketFunction: true | ||
| BreakBeforeCloseBracketIf: true | ||
| PackArguments: {BinPack: OnePerLine} | ||
| PackParameters: {BinPack: OnePerLine} | ||
| AllowAllArgumentsOnNextLine: false | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Optional, a slight preference for
Left. Before this PR,_cpp/rt/and the benchmarks wrotetype* namein nearly every declaration, andLeftkeeps that style. On this branch, the switch changes 696 lines in 34 files. CPython and the PEP 7 examples usetype *name, so keepRightif you prefer to stay with PEP 7.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should stick to PEP7 where we can. For C++ constructs like lambdas that it doesn't address, that's a judgement call for us, of course.