Skip to content

lint: finish libc_mirror (#4834) — shared name table, real-header tests, wrapper↔back-stop coverage check #4838

Closed

Description

@zackees

Context

#4834 shipped in #4835 (abf946379): the libc_mirror rule, its 11 unit tests, and the compile back-stop in tests/fl/stl/adl_barrier.cpp. All of these pass on master. An audit against the issue text found these remaining gaps:

# #4834 asked for What shipped
1 Name table in ci/lint_cpp_rs/src/lint_core/ LIBC_RESERVED_NAMES is private to checkers/libc_mirror.rs
2 Linter tests in lint_core/tests_checkers.rs Inline #[cfg(test)] mod libc_mirror_tests in the checker
3 Tests "pass on the current headers and on libc_impl" Synthetic snippets only; real headers are covered only implicitly by bash lint
4 Compile back-stop covers every wrapper Covers the 33 wrappers that exist today. A new, correctly shaped wrapper with no test line is not caught
5 (implicit) wide platform validation No board compile sweep recorded on the PR

Contradictions and how this issue resolves them

  • Gap 2 vs. the size limit. tests_checkers.rs is 795 lines. It is an include!-style split that exists only to stay under the linter's own 1,000-line-per-file ceiling. Moving about 100 lines of libc_mirror tests into it pushes it toward that ceiling. Three other checkers already keep their tests inline. Resolution: keep the tests inline in libc_mirror.rs, which follows existing practice. This issue amends lint: exhaustive libc-name rule for fl:: mirrors (supersedes #4832) #4834's wording rather than moving them.
  • Gap 1 vs. "the table lives with its only user." lint_core/banned_header_data.rs is the existing precedent for data tables kept apart from logic. A shared table can also be reused by gap 4 below. Resolution: move the table to lint_core/libc_reserved_names.rs as pub(crate) const LIBC_RESERVED_NAMES.
  • Gap 4: is it a compile-test problem or a lint problem? A compile test can't enumerate wrappers that don't exist yet. Resolution: make it a lint check. Every FlLibcTag wrapper name declared in src/fl/stl/{cstring,malloc,cstdlib}.h and src/fl/system/exit.h must appear as an unqualified call in tests/fl/stl/adl_barrier.cpp. The reverse also holds: every name the test lists must still exist, so the test can't go stale. This closes the loop without anyone having to remember a manual step.

Plan (one PR)

  1. Table: move LIBC_RESERVED_NAMES into lint_core/libc_reserved_names.rs, register it in lib.rs, and import it from checkers/libc_mirror.rs. No change in behaviour.
  2. Real-header tests: add inline tests that include_str! the real src/fl/stl/cstring.h, malloc.h, cstdlib.h, src/fl/system/exit.h and the libc_impl *.cpp.hpp definitions, then assert libc_mirror_violations(..) is empty. Add a mutation test that rewrites one real wrapper's FASTLED_FORCE_INLINE to inline and asserts it fails, which proves the real-header test is not vacuous.
  3. Back-stop coverage check: add a cross-file check, placed next to the existing structural Python ratchets or as a Rust whole-repo processor, whichever fits agents/docs/linter-architecture.md. It compares the set of wrapper names in the headers with the set of names called in adl_barrier.cpp and fails on any difference in either direction. Red evidence: add a dummy wrapper and confirm the check fails.
  4. Docs: update checkers/README.md and the adl_barrier.cpp header comment to describe the two-way coverage contract.
  5. Validation before merge:
    • bash lint, soldr cargo test in ci/lint_cpp_rs, and bash test adl_barrier (re-run with --debug if it fails).
    • A local compile sweep of Blink and an fl/stl-heavy example on the board names from bash ci-labels list --json: at least uno, attiny85, esp32dev, esp32s3, esp32c6, teensy41, rp2040, an stm32, an nrf52 and wasm.
    • Dispatch ci-full on the PR head SHA.

Out of scope

The same as #4834: math functions, printf-family functions, and adl_barrier generics.

Done when

  • Gaps 1, 3, 4 and 5 are closed, and gap 2 is closed by the amendment above.
  • The negative tests from steps 2 and 3 fail as expected.
  • The PR is merged with ci-full green and the board sweep results posted on it.

Refs #4834, #4835, #4827, #4830, #4833.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions