Repository navigation
fix(lpc): unblock LPC PIO build — drop C++14 digit separators + force gnu++17 (closes #3329) - #3332
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (6)
✅ Files skipped from review due to trivial changes (1)
🚧 Files skipped from review as they are similar to previous changes (5)
📝 WalkthroughWalkthroughAdds a ChangesBareDigitSeparatorChecker and code fixes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related issues
Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
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
📒 Files selected for processing (6)
ci/lint_cpp_rs/src/checkers/bare_legacy.rsci/lint_cpp_rs/src/lint_core/processor_registry_cli.rsci/lint_cpp_rs/src/lint_core/regexes.rsci/lint_cpp_rs/src/lint_core/tests.rsplatformio.inisrc/platforms/arm/common/m0clockless_c.h
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]>
… 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]>
e1e8e5c to
d2204bd
Compare
…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]>
…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]>
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 insrc/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: replaced999'999'999ULL/1'000'000'000ULLwith plain digits. Added a comment block pointing at the new lint rule.BareDigitSeparatorCheckerinci/lint_cpp_rs/src/checkers/bare_legacy.rsbans\d'\dinsrc/. Comment-aware (single-line//, doxygen///<, and inline/* ... */blocks are all stripped before the regex match — preserves the existing pseudocode comments indelay.hfiles that document the formula). String literals stripped via a localstrip_double_quoted_stringshelper (the sharedstrip_string_literalsalso 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 inprocessor_registry_cli.rs; 4 inline tests cover positive / comment-skip / string + suppress / scope-exclusion.Part B — PIO platform side:
platformio.ini: addedbuild_unflags = -std=gnu++11 -std=c++11andbuild_flags = -std=gnu++17to[env:lpc845brk],[env:lpc845],[env:lpc804],[env:lpcxpresso845max],[env:lpcxpresso804]. Thelpc845brk_ieee754env extendslpc845brkso inherits.gnu++17for LPC).Acceptance criteria from #3329
m0clockless_c.h:358(and any other digit-separator sites) replaced with plain digits.BareDigitSeparatorCheckerflags any future<digit>'<digit>pattern insrc/outside of suppressed sites. Lint passes on master.bash compile lpc845brk --examples AutoResearch --platformiosucceeds without manualbuild_flagsplumbing.bash compile lpc845brk --examples AutoResearch(default fbuild backend) still succeeds.Test plan
bash test --cpp→ 334/334 passingbash 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 regressionBareDigitSeparatorChecker→ 4/4 passingOut of scope
The issue's "open question on Part B" — whether the
gnu++17default belongs inzackees/platform-nxplpc-arduino'splatform.jsonrather than every consumer'splatformio.ini— is left as a follow-up. Keeping the flags inplatformio.inifor now unblocks the bisection path immediately without coordinating cross-repo changes.🤖 Generated with Claude Code
Summary by CodeRabbit
ok digit-separatormarker. Coverage includes cases inside comments and string literals.gnu++17by removing C++11 flags across canary environments.