Skip to content

chore: Exclude vendored and generated sources from clang-format - #920

Open
krlmlr wants to merge 1 commit into
mainfrom
claude/clang-format
Open

krlmlr wants to merge 1 commit into
mainfrom
claude/clang-format

Conversation

@krlmlr

@krlmlr krlmlr commented Nov 29, 2026 •

Copy link
Copy Markdown
Member

The repository already has a .clang-format, and every top-level file in src/ already conforms to it. This PR is configuration only: it adds a root .clang-format-ignore so that the style action on CI, which runs clang-format -i src/*.{c,cc,cpp,h,hpp}, and anyone running clang-format locally leave the vendored and generated code alone, and it build-ignores that file.

Excluded patterns: src/vendor/** (SQLite amalgamation, its extensions and boost, all replaced wholesale by data-raw/upgrade.R) and src/cpp11.cpp (generated by cpp11::cpp_register()). A root file is used rather than a hidden file inside src/vendor/, which the upgrade would replace and which would ship in the tarball. .Rbuildignore already had ^\.clang-format$; this adds ^\.clang-format-ignore$.

The planned formatting commit is empty and therefore omitted: clang-format --dry-run -Werror over the 50 files of the CI set already passes, so nothing is reformatted.

Repo docs consulted: .github/CONTRIBUTING.md, UPDATE.md and data-raw/upgrade.R (no formatting or vendoring conventions beyond the upgrade script; there is no AGENTS.md, CLAUDE.md or handbook/). The upgrade workflow only runs data-raw/upgrade.R, which writes under src/vendor/ and reads patch/, then commits src; it never touches root files, so it cannot delete or conflict with the new file.

How byte-identity was checked

No compiled input changed, so a build comparison is unnecessary. git diff --stat origin/main..HEAD shows only:

 .Rbuildignore        | 1 +
 .clang-format-ignore | 4 ++++
 2 files changed, 5 insertions(+)

With clang-format 21.1.8, clang-format --dry-run -Werror src/*.{c,cc,cpp,h,hpp} exits 0 over the 50 CI files. src/cpp11.cpp, src/vendor/sqlite3/sqlite3.c, src/vendor/boost/tokenizer.hpp and src/vendor/extensions/csv.c named on the command line exit 0 with no output (ignored); without the ignore file, csv.c fails with a formatting violation, so the patterns take effect. R CMD build succeeds, and the tarball contains no .clang-format* file (the only clang matches are boost's own clang.hpp and clang_version.hpp).

https://claude.ai/code/session_01Hr1rd3zHUSUZLRSv2YuHbe


Generated by Claude Code

Add a root .clang-format-ignore for src/vendor/** and src/cpp11.cpp, and build-ignore it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Hr1rd3zHUSUZLRSv2YuHbe

krlmlr commented Nov 29, 2026

Copy link
Copy Markdown
Member Author

Accepted limitations

None. The clean review found nothing above Low; its Low note (the src/cpp11.cpp line duplicates the generated file's own // clang-format off header) needs no change, since the line keeps the exclusion independent of the generator.


Generated by Claude Code

@krlmlr
krlmlr marked this pull request as ready for review November 29, 2026 11:23

This branch has not been deployed

No deployments
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