Skip to content

fix(lpc): unblock LPC PIO build — drop C++14 digit separators + force gnu++17 (closes #3329) - #3332

Merged
zackees merged 2 commits into
masterfrom
fix/3329-digit-separators
Jun 20, 2026
Merged

zackees merged 2 commits into
masterfrom
fix/3329-digit-separators

Conversation

@zackees

@zackees zackees commented Jun 20, 2026 •

Copy link
Copy Markdown
Member

Summary

Closes #3329 — the bisection blocker against zackees/ArduinoCore-LPC8xx (refs #3325 / #3300).

The PlatformIO LPC845-BRK environment defaults to -std=gnu++11, which chokes on the C++14 digit separators in src/platforms/arm/common/m0clockless_c.h. PIO is the only backend that respects per-commit framework pinning, so this issue blocks the very first bisect step.

Two-part fix

Part A — FastLED-side:

  • src/platforms/arm/common/m0clockless_c.h:358: replaced 999'999'999ULL / 1'000'000'000ULL with plain digits. Added a comment block pointing at the new lint rule.
  • New Rust per-file checker BareDigitSeparatorChecker in ci/lint_cpp_rs/src/checkers/bare_legacy.rs bans \d'\d in src/. Comment-aware (single-line //, doxygen ///<, and inline /* ... */ blocks are all stripped before the regex match — preserves the existing pseudocode comments in delay.h files that document the formula). String literals stripped via a local strip_double_quoted_strings helper (the shared strip_string_literals also blanks single-quoted chars, which would eat the very digit-separator we want to flag). Suppression via // ok digit-separator. Registered at all three sites in processor_registry_cli.rs; 4 inline tests cover positive / comment-skip / string + suppress / scope-exclusion.

Part B — PIO platform side:

  • platformio.ini: added build_unflags = -std=gnu++11 -std=c++11 and build_flags = -std=gnu++17 to [env:lpc845brk], [env:lpc845], [env:lpc804], [env:lpcxpresso845max], [env:lpcxpresso804]. The lpc845brk_ieee754 env extends lpc845brk so inherits.
  • Brings PIO into parity with the fbuild backend (which already defaults to gnu++17 for LPC).

Acceptance criteria from #3329

  • m0clockless_c.h:358 (and any other digit-separator sites) replaced with plain digits.
  • New Rust BareDigitSeparatorChecker flags any future <digit>'<digit> pattern in src/ outside of suppressed sites. Lint passes on master.
  • bash compile lpc845brk --examples AutoResearch --platformio succeeds without manual build_flags plumbing.
  • bash compile lpc845brk --examples AutoResearch (default fbuild backend) still succeeds.

Test plan

  • bash test --cpp → 334/334 passing
  • bash lint --cpp → green (warn-only root-platformio-ini lockdown warnings are unrelated — the diff lines aren't in the lockdown-tracked block)
  • bash compile lpc845brk --examples AutoResearch --platformio → SUCCESS in 1m34s (was failing on master HEAD with the parse error from the issue body)
  • bash compile lpc845brk --examples AutoResearch (default fbuild) → SUCCESS in 1m00s, no regression
  • Inline Rust tests for BareDigitSeparatorChecker → 4/4 passing
  • CI green on this PR

Out of scope

The issue's "open question on Part B" — whether the gnu++17 default belongs in zackees/platform-nxplpc-arduino's platform.json rather than every consumer's platformio.ini — is left as a follow-up. Keeping the flags in platformio.ini for now unblocks the bisection path immediately without coordinating cross-repo changes.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • Added a new linting rule to detect C++14 digit separators, warn about portability risks, and support inline suppression via an ok digit-separator marker. Coverage includes cases inside comments and string literals.
  • Chores
    • Updated LPC8xx build settings to consistently force gnu++17 by removing C++11 flags across canary environments.
    • Replaced C++14 digit-separator numeric literals with plain-digit constants in the ARM common clock header for compatibility.

@coderabbitai

coderabbitai Bot commented Jun 20, 2026 •

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 27b83256-bd06-4a8c-95f8-1dec956f025c

📥 Commits

Reviewing files that changed from the base of the PR and between e1e8e5c and d2204bd.

📒 Files selected for processing (6)
  • ci/lint_cpp_rs/src/checkers/bare_legacy.rs
  • ci/lint_cpp_rs/src/lint_core/processor_registry_cli.rs
  • ci/lint_cpp_rs/src/lint_core/regexes.rs
  • ci/lint_cpp_rs/src/lint_core/tests.rs
  • platformio.ini
  • src/platforms/arm/common/m0clockless_c.h
✅ Files skipped from review due to trivial changes (1)
  • ci/lint_cpp_rs/src/lint_core/regexes.rs
🚧 Files skipped from review as they are similar to previous changes (5)
  • platformio.ini
  • src/platforms/arm/common/m0clockless_c.h
  • ci/lint_cpp_rs/src/lint_core/processor_registry_cli.rs
  • ci/lint_cpp_rs/src/lint_core/tests.rs
  • ci/lint_cpp_rs/src/checkers/bare_legacy.rs

📝 Walkthrough

Walkthrough

Adds a BareDigitSeparatorChecker to the Rust-backed CI linter that bans C++14 digit separators (999'999'999) in src/ C/C++ files outside third_party/, with block-comment stripping, string-literal exclusion, and an inline suppression marker. Wires the checker into the CLI registry. Fixes the existing violation in m0clockless_c.h and upgrades five LPC PlatformIO environments to -std=gnu++17.

Changes

BareDigitSeparatorChecker and code fixes

Layer / File(s) Summary
Regex and checker core logic
ci/lint_cpp_rs/src/lint_core/regexes.rs, ci/lint_cpp_rs/src/checkers/bare_legacy.rs
regex_bare_digit_separator() matches \d'\d via OnceLock. BareDigitSeparatorChecker scopes to src/ C/C++ files outside third_party/, strips block comments with persistent state, removes double-quoted string contents via a state-machine helper, and reports each digit-separator violation with suppression-marker support.
CLI registry wiring and unit tests
ci/lint_cpp_rs/src/lint_core/processor_registry_cli.rs, ci/lint_cpp_rs/src/lint_core/tests.rs
Adds bare_digit_separator to supported_checker_names(), BareDigitSeparatorChecker to supported_python_checker_names(), and the checker construction to create_checkers(). Four unit tests cover detection of digit-separator literals, comment exclusion (single-line, doxygen, block), string-literal exclusion with suppression markers, and path scoping (third_party exclusion).
Fix existing violation and enforce gnu++17 in LPC builds
src/platforms/arm/common/m0clockless_c.h, platformio.ini
Replaces 999'999'999ULL / 1'000'000'000ULL with plain-digit literals in ns_to_cycles. Updates env:lpc845brk and four LPC canary environments (lpc845, lpc804, lpcxpresso845max, lpcxpresso804) to unset -std=gnu++11/-std=c++11 and force -std=gnu++17.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related issues

Possibly related PRs

  • FastLED/FastLED#2689: The new Rust-backed checker and its wiring into the C++ linter infrastructure builds directly on the checker registry and selection infrastructure introduced in this PR.

Poem

🐇 Hop hop, the digits run free,
No apostrophes shall there be!
The linter now watches with care,
For 999'999 hiding in there.
gnu++17 lifts the LPC's plight—
Plain numbers shine, all is right! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 35.29% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: fixing the LPC PIO build by removing C++14 digit separators and forcing gnu++17, which directly matches the primary purpose of the changeset.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/3329-digit-separators

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@ci/lint_cpp_rs/src/checkers/bare_legacy.rs`:
- Around line 452-467: The current implementation has two string-safety issues
that can bypass the checker: the SUPPRESS containment check at line 456 matches
text inside strings or comments, and the split_line_comment call at line 461 can
incorrectly split at // sequences that appear inside string literals like
http://. To fix this, perform string stripping before the SUPPRESS check so
suppression is only detected in actual code, and ensure split_line_comment is
called on a string-safe version of the code. Specifically, call
strip_double_quoted_strings before checking line.contains(SUPPRESS), then apply
split_line_comment to that already-processed code to prevent premature splitting
at // inside strings, so the regex_bare_digit_separator check operates on
properly sanitized code.

In `@platformio.ini`:
- Around line 198-202: Each modified non-comment line in the platformio.ini file
(in the build_unflags section containing -std=gnu++11 and -std=c++11, and the
build_flags section containing -std=gnu++17, as well as lines 238-272) must be
accompanied by adjacent comments providing required metadata. For each modified
line, add a `; justification:` comment explaining the reason for the change and
a `; added-in:` comment with the PR or SHA reference to satisfy the repository's
frozen-surface audit rule for platformio.ini modifications.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 6f295db2-b98c-4eaf-ad1b-f17b874c305f

📥 Commits

Reviewing files that changed from the base of the PR and between 91a11f6 and 3b515ea.

📒 Files selected for processing (6)
  • ci/lint_cpp_rs/src/checkers/bare_legacy.rs
  • ci/lint_cpp_rs/src/lint_core/processor_registry_cli.rs
  • ci/lint_cpp_rs/src/lint_core/regexes.rs
  • ci/lint_cpp_rs/src/lint_core/tests.rs
  • platformio.ini
  • src/platforms/arm/common/m0clockless_c.h

Comment thread platformio.ini Resolved
zackees added a commit that referenced this pull request Jun 20, 2026
1. ci/lint_cpp_rs/src/checkers/bare_legacy.rs — fix two string-safety
   issues CodeRabbit flagged in BareDigitSeparatorChecker:
   - The suppression check `line.contains(SUPPRESS)` previously matched
     text inside string literals or block comments — could false-suppress
     a real violation when a string contained the literal text
     "// ok digit-separator".
   - `split_line_comment(&stripped)` could split at `//` sequences
     inside string literals (e.g. `"http://example.com"`), eating real
     code as a comment.
   Fix: strip double-quoted strings FIRST, then split on `//` only on
   the string-free version. Suppression is only checked against the
   resulting `comment_tail`, not the whole line. The 4 inline tests
   (positive / comment-skip / string + suppress / scope-exclusion) all
   still pass.

2. platformio.ini — add adjacent `; justification:` + `; added-in:`
   comments next to every changed `build_unflags` / `build_flags`
   block for all five LPC envs (lpc845brk, lpc845, lpc804,
   lpcxpresso845max, lpcxpresso804), per the root-platformio.ini
   lockdown rule. The lockdown lint now reports
   "✅ Root platformio.ini lockdown: 47 added line(s) — all justified."

Verification:
- bash lint --cpp -> green
- soldr cargo test ... bare_digit_separator -> 4/4 passing
- root-platformio-ini-lockdown -> all justified

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
zackees and others added 2 commits June 20, 2026 01:30
… gnu++17 (closes #3329)

The PlatformIO LPC845-BRK environment defaults to -std=gnu++11, which
chokes on the C++14 digit separators in
src/platforms/arm/common/m0clockless_c.h (the single quote in
999'999'999ULL is read as a character-literal delimiter and the next
three digits become a stray multibyte char). This blocks the #3325
bisection against zackees/ArduinoCore-LPC8xx — PIO is the only backend
that respects per-commit framework pinning.

Two-part fix mirroring the issue body:

1. FastLED-side — make m0clockless_c.h portable across C++11/14/17:
   - Replaced `999'999'999ULL` / `1'000'000'000ULL` with plain digits on
     line 358 of src/platforms/arm/common/m0clockless_c.h.
   - Added a comment block explaining the gnu++11 portability constraint
     and pointing at the new lint check.
   - Added a new Rust per-file checker `BareDigitSeparatorChecker` in
     ci/lint_cpp_rs/src/checkers/bare_legacy.rs that bans `\d'\d` in
     src/. The check is comment-aware (single-line `//`, doxygen
     `///<`, and inline `/* ... */` block comments are all stripped
     before the regex match — preserves the existing pseudocode
     comments in delay.h files that document the formula). String
     literals stripped via a local `strip_double_quoted_strings`
     helper (the shared `strip_string_literals` also drops single-
     quoted chars, which would eat the very digit-separator we want
     to flag). Suppression via `// ok digit-separator`. Registered at
     all three sites in processor_registry_cli.rs; 4 inline tests in
     lint_core/tests.rs cover positive / comment-skip / string + suppress
     / scope-exclusion (third_party).

2. PIO platform side — default LPC environments to gnu++17:
   - platformio.ini: added `build_unflags = -std=gnu++11 -std=c++11`
     and `build_flags = -std=gnu++17` to `[env:lpc845brk]`, `[env:lpc845]`,
     `[env:lpc804]`, `[env:lpcxpresso845max]`, `[env:lpcxpresso804]`.
     The `[env:lpc845brk_ieee754]` env extends lpc845brk so inherits.
   - Brings PIO into parity with the fbuild backend (which already
     defaults to gnu++17 for LPC) and prevents the class of
     "fbuild builds but PIO doesn't" surprises that blocks bisection
     and CI parity.

Verification:
- bash test --cpp -> 334/334 passing
- bash lint --cpp -> green
- bash compile lpc845brk --examples AutoResearch --platformio -> SUCCESS in 1m34s
  (was failing on master at HEAD with the parse error from the issue body)
- bash compile lpc845brk --examples AutoResearch (default fbuild backend)
  -> SUCCESS in 1m00s, no regression
- Inline Rust tests for BareDigitSeparatorChecker -> 4/4 passing

Out of scope:
- Moving the gnu++17 default into the zackees/platform-nxplpc-arduino
  platform.json (the issue's "open question on Part B"). Keeping it
  in platformio.ini for now keeps the bisection path unblocked
  immediately and lets the platform repo own its own default
  separately. Either home would close #3329.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
1. ci/lint_cpp_rs/src/checkers/bare_legacy.rs — fix two string-safety
   issues CodeRabbit flagged in BareDigitSeparatorChecker:
   - The suppression check `line.contains(SUPPRESS)` previously matched
     text inside string literals or block comments — could false-suppress
     a real violation when a string contained the literal text
     "// ok digit-separator".
   - `split_line_comment(&stripped)` could split at `//` sequences
     inside string literals (e.g. `"http://example.com"`), eating real
     code as a comment.
   Fix: strip double-quoted strings FIRST, then split on `//` only on
   the string-free version. Suppression is only checked against the
   resulting `comment_tail`, not the whole line. The 4 inline tests
   (positive / comment-skip / string + suppress / scope-exclusion) all
   still pass.

2. platformio.ini — add adjacent `; justification:` + `; added-in:`
   comments next to every changed `build_unflags` / `build_flags`
   block for all five LPC envs (lpc845brk, lpc845, lpc804,
   lpcxpresso845max, lpcxpresso804), per the root-platformio.ini
   lockdown rule. The lockdown lint now reports
   "✅ Root platformio.ini lockdown: 47 added line(s) — all justified."

Verification:
- bash lint --cpp -> green
- soldr cargo test ... bare_digit_separator -> 4/4 passing
- root-platformio-ini-lockdown -> all justified

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@zackees
zackees force-pushed the fix/3329-digit-separators branch from e1e8e5c to d2204bd Compare June 20, 2026 08:32
@zackees
zackees merged commit d95b37e into master Jun 20, 2026
6 of 11 checks passed
@fastled-project-sync fastled-project-sync Bot moved this from Triage to Done in FastLED Tracker Jun 20, 2026
@zackees
zackees deleted the fix/3329-digit-separators branch June 20, 2026 09:01
zackees added a commit that referenced this pull request Jun 20, 2026
…3329)

PR #3332 force-set `-std=gnu++17` on all 5 LPC PIO envs to work around
the C++14 digit separators that lived in m0clockless_c.h. That same PR
also dropped those digit separators (and added BareDigitSeparatorChecker
to prevent regression), so the flag override is no longer carrying its
weight — PIO's default `-std=gnu++11` is now sufficient for the LPC
framework.

Reverting the `build_unflags` + `-std=gnu++17` block from:
- env:lpc845brk     (functional `-DRELEASE`/`-DFASTLED_LPC_PWM_DMA=1`/
                     `-DFASTLED_AUTORESEARCH_LOW_MEMORY=1` flags preserved)
- env:lpc845
- env:lpc804
- env:lpcxpresso845max
- env:lpcxpresso804

`env:lpc845brk_ieee754` extends `env:lpc845brk` and tracks automatically.

Rationale (per maintainer):
> we should be able to keep the defaults again now that the fastled
> c++17 / 14 fix landed, it should compile with C++11

This restores parity with the platform's documented default standard
and shrinks the surface that the `zackees/platform-nxplpc-arduino`
maintainer has to consider when revisiting the platform.json default
(open question Part B from #3329 — now moot for FastLED-side builds).

Verification:
- bash compile lpc845brk --examples AutoResearch --platformio
    -> SUCCESS in 49s; Flash 59996/65536 (91.5%), RAM 5924/16384 (36.2%).
- bash compile lpc845brk --examples AutoResearch (fbuild backend)
    -> SUCCESS in 41s; Flash 55140 bytes, RAM 9248 bytes. No regression.

Closes the second-order cleanup tracked under #3329.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
zackees added a commit that referenced this pull request Jun 20, 2026
…3329) (#3331)

PR #3332 force-set `-std=gnu++17` on all 5 LPC PIO envs to work around
the C++14 digit separators that lived in m0clockless_c.h. That same PR
also dropped those digit separators (and added BareDigitSeparatorChecker
to prevent regression), so the flag override is no longer carrying its
weight — PIO's default `-std=gnu++11` is now sufficient for the LPC
framework.

Reverting the `build_unflags` + `-std=gnu++17` block from:
- env:lpc845brk     (functional `-DRELEASE`/`-DFASTLED_LPC_PWM_DMA=1`/
                     `-DFASTLED_AUTORESEARCH_LOW_MEMORY=1` flags preserved)
- env:lpc845
- env:lpc804
- env:lpcxpresso845max
- env:lpcxpresso804

`env:lpc845brk_ieee754` extends `env:lpc845brk` and tracks automatically.

Rationale (per maintainer):
> we should be able to keep the defaults again now that the fastled
> c++17 / 14 fix landed, it should compile with C++11

This restores parity with the platform's documented default standard
and shrinks the surface that the `zackees/platform-nxplpc-arduino`
maintainer has to consider when revisiting the platform.json default
(open question Part B from #3329 — now moot for FastLED-side builds).

Verification:
- bash compile lpc845brk --examples AutoResearch --platformio
    -> SUCCESS in 49s; Flash 59996/65536 (91.5%), RAM 5924/16384 (36.2%).
- bash compile lpc845brk --examples AutoResearch (fbuild backend)
    -> SUCCESS in 41s; Flash 55140 bytes, RAM 9248 bytes. No regression.

Closes the second-order cleanup tracked under #3329.

Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

[BLOCKER-#3325] LPC PIO build fails on C++14 digit separators in m0clockless_c.h — set -std=gnu++17 + drop digit separators

1 participant