Repository navigation
Conversation
- .clang-format tuned to minimize the diff against the current code (measured with clang-format 18.1.8): LLVM base with ColumnLimit: 0, PointerAlignment: Left, cast spacing, no include re-sorting, and one-liner short-block style. - Big generated tables are protected with // clang-format off/on markers placed right around the arrays, inside the files (digit_table.h, d2s_small_table.h, *_full_table.h, generic_128.h, tests/d2fixed_test.cc). Markers are enforced by clang-format itself, so even a manual `clang-format -i` cannot re-pack the tables. - scripts/check-clang-format.sh runs `clang-format --dry-run --Werror` over all C/C++ files under ryu/ (.c/.h/.cc/.cpp/.hh); presubmit gains a clang-format job pinned to clang-format 18.1.8. Co-authored-by: Mistral Vibe <vibe@mistral.ai> Co-authored-by: mbouaziz <mbouaziz@users.noreply.github.com>
One-time reformat with the new .clang-format (clang-format 18.1.8). The // clang-format off/on markers keep the big generated tables byte-identical (except the marker lines themselves); the ~190 changed lines elsewhere are almost all cast spacing and brace/indent normalization. No functional changes (make -C ryu test passes 8/8). Co-authored-by: Mistral Vibe <vibe@mistral.ai> Co-authored-by: mbouaziz <mbouaziz@users.noreply.github.com>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Adds clang-format to the project, enforced in CI:
add .clang-format, CI check, and clang-format-off markers around tables— the config,scripts/check-clang-format.sh(clang-format --dry-run --Werrorover all C/C++ files underryu/), aclang-formatjob inpresubmit.ymlpinned toclang-format==18.1.8, and// clang-format off/onmarkers around the big generated tables.apply clang-format to all ryu C/C++ sources— one-time reformat.Config choice (measured with clang-format 18.1.8, 23 code files / 5,471 lines)
PointerAlignment: Rightchar*→char *)PointerAlignment: Left(adopted)Final
.clang-format:BasedOnStyle: LLVM,ColumnLimit: 0(codebase has lines up to 141 cols;ColumnLimit: 100would change ~570 lines),SpaceAfterCStyleCast: true,AllowShortIfStatementsOnASingleLine: AllIfsAndElse,AllowShortBlocksOnASingleLine: Always,SortIncludes: Never,PointerAlignment: Left.Big tables: markers instead of an exclude list
Tables are protected with
// clang-format off/onmarkers placed right around the arrays, inside the files (digit_table.h,d2s_small_table.h,*_full_table.h,generic_128.h,tests/d2fixed_test.cc) — the pure table headers differ from master by exactly the 2 marker lines — so the CI script simply checks every source file underryu/(.c/.h/.cc/.cpp/.hh) — and even a manualclang-format -icannot re-pack a table (verified: running-ion the table files is a no-op). Cost: 2 marker lines per file; measured impact of formatting tables without markers would be ~98% of their ~41k lines, so markers are the only way to keep them stable. Non-table code in the mixed files (generic_128.h,d2fixed_test.cc) is still formatted and checked.Scope: C/C++ under
ryu/only (Java insrc/, vendoredthird_party/untouched).Verification
./scripts/check-clang-format.shclean; flags violations on unformatted code.clang-format -ion table files changes nothing (markers enforced by the tool).make -C ryu testafter formatting: 8/8 binaries pass — no functional changes.Co-authored-by: Mistral Vibe vibe@mistral.ai