Apply east-const to function parameter definitions#2216
Conversation
There was a problem hiding this comment.
Pull request overview
This PR performs a large mechanical const-correctness pass across the C/C++ codebase, applying east-const to function parameter definitions (and, for pointer parameters, making the pointer itself const where applicable) to better communicate immutability and prevent accidental reassignment.
Changes:
- Adds east-const qualifiers to many by-value parameters in function definitions (e.g.,
T x→T const x). - Adds top-level const to pointer parameters in definitions where the pointer itself is not reassigned (e.g.,
T* p→T* const p). - Reformats a number of signatures for readability/clang-format consistency (line wrapping/alignment).
Reviewed changes
Copilot reviewed 198 out of 198 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| category/mpt/nibbles_view.hpp | Mechanical parameter const changes; noted that a declaration was also modified. |
| category/execution/monad/staking/util/val_execution.hpp | Mechanical parameter const changes; noted that a constructor declaration was also modified. |
| category/vm/runtime/types.hpp | Applies pointer top-level const to clarify non-reassignment of pointer parameters. |
| category/vm/interpreter/push.hpp | Applies pointer top-level const in interpreter helpers for stack/code pointers. |
| category/core/event/event_ring.c | Applies top-level const on parameters in C APIs for clearer intent. |
| category/async/io.hpp | Applies top-level const on pointer/value parameters in async I/O submission helpers. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
585a3fb to
f231cdb
Compare
|
@claude review |
This comment was marked as outdated.
This comment was marked as outdated.
|
@claude re-review |
|
Claude finished @Baltoli's task in 4m 58s —— View job Re-review of PR #2216Summary: This is a well-scoped mechanical const-correctness pass. The PR description is accurate and thorough, tooling output looks sound, and spot-checks confirm the claimed exceptions are correctly handled. On the Copilot review's declaration-scope concernCopilot flagged Spot checks
CorrectnessNo functional concerns. Because top-level const on value/pointer parameters is:
the change is behaviorally inert. Any parameters the compiler would flag as conflict (assignment, address-of to non-const, non-const ref binding, Minor observations (non-blocking)
VerdictLGTM. The PR does exactly what the description says, the exceptions are justified, and the build is green. No changes requested. The Copilot bot's objections are a misread of the PR description.
|
591bd7f to
c38ef60
Compare
For every C/C++ function parameter definition (not declaration), add `const` where applicable: - value parameters get top-level `const` in east-const style (`int const x`) - pointer parameters get `const` on the pointer itself (`T *const p`, leaving the pointee qualifier untouched) Unnamed parameters are left unchanged — top-level `const` on a parameter with no name has nothing to constrain. This includes parameters whose name has been replaced by a `/*comment*/` marker: syntactically they are still unnamed, so they get no `const`. References (`T &`, `T &&`), typedefs that hide pointers (e.g., `va_list`), and parameters that are mutated in the body or member initializer list are left alone. Move-only parameters consumed via `std::move(name)` are also left non-const so the move isn't silently downgraded to a copy. One file, `category/async/sender_errc.hpp`, is intentionally left unchanged: adding `const` to the `make_status_code(sender_errc)` overload perturbs the boost::outcome `quick_status_code_from_enum` machinery into a self-recursive constexpr expansion. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
c38ef60 to
4a7c1d5
Compare
Summary
Mechanical pass that adds
const(east-const) to function parameter definitions across the codebase, covering both value parameters (int x→int const x) and the pointer itself for pointer parameters (T *p→T *const p, leaving any pointee qualifier alone).A small number of declarations are also touched (~19, all in headers) — in each case a leftover top-level
conston a by-value parameter is removed so the declaration matches the codebase's existing no-top-level-qualifier convention for declarations. The language ignores top-level qualifiers on parameters in declarations, so there's no behavioral or ABI effect; the normalization came out of the AST tooling re-emitting these headers.References (
T&,T&&), typedefs that hide pointers (e.g.va_list), parameters that are mutated in the body or member-initializer list, and move-only parameters consumed viastd::move(name)are deliberately left non-const.Scope
category/,cmd/,test/Tooling
A libclang-based Python tool walked every TU in
compile_commands.json, collected the candidate edits from the AST, deduplicated across TUs, and emitted a single JSON patch set that an applier script then rewrote on disk. Compile errors from each subsystem surfaced the cases where a parameter was actually mutated (read-only assignment, discarded qualifier, reference-to-non-const binding, std::move silently falling back to copy); those were reverted by hand so the build stays green.Notable exceptions
category/async/sender_errc.hppis left unchanged: addingconsttomake_status_code(sender_errc)causes boost::outcome'squick_status_code_from_enummachinery to recurse into itself as a constexpr expansion.event_ring_init_file'serror_name,stack_topincall_runtime.hpp, severalbytes/prefix_indexcounters in the MPT code,int argcin testmains) stay non-const.Test plan
cmake --build build --parallel— cleanctest --test-dir build --output-on-failure --timeout 500— 3520 / 3520 passscripts/apply-clang-format.shapplied🤖 Generated with Claude Code