Skip to content

feat(noexcept): annotate hot-path functions with FL_NOEXCEPT - #2998

Merged
zackees merged 1 commit into
masterfrom
feat/fl-noexcept-macros
Jun 13, 2026
Merged

zackees merged 1 commit into
masterfrom
feat/fl-noexcept-macros

Conversation

@zackees

@zackees zackees commented Jun 13, 2026 •

Copy link
Copy Markdown
Member

Summary

  • Adds FL_NOEXCEPT to CRGB operators, fl::stl containers (span, basic_vector, function, string, strstream), math/gamma helpers, delay routines, and clockless/SPI platform drivers (ARM, ESP32/ESP8266, Teensy, SAM, RP, etc.)
  • Satisfies the FL_NOEXCEPT lint ratchet introduced in ci: ratchet FL_NOEXCEPT lint coverage #2987 and enables noexcept-based codegen optimizations

Test plan

  • bash lint passes (including the check_noexcept.py AST ratchet)
  • bash test --cpp: 309/310 pass; the one failure (parlio_driver mock transmission test, line 1029) is pre-existing on master and unrelated to these changes (verified by reproducing on a clean tree)

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Chores
    • Updated internal code quality and compiler specifications across the library for improved stability and consistency.

Note: This release contains internal maintenance updates with no user-visible feature changes or behavioral modifications.

Add FL_NOEXCEPT to CRGB operators, fl::stl containers, math/gamma
helpers, delay routines, and clockless/SPI platform drivers to satisfy
the FL_NOEXCEPT lint ratchet (#2987) and enable noexcept optimizations.

Co-Authored-By: Claude Opus 4.7 <[email protected]>
@coderabbitai

coderabbitai Bot commented Jun 13, 2026 •

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 84797bcb-b592-45ce-b607-599493857b3a

📥 Commits

Reviewing files that changed from the base of the PR and between 62c9e01 and b6e5a02.

📒 Files selected for processing (38)
  • src/crgb.hpp
  • src/fl/chipsets/clockless_encoder.h
  • src/fl/gfx/gamma_lut.h
  • src/fl/math/math.h
  • src/fl/stl/basic_vector.h
  • src/fl/stl/function.h
  • src/fl/stl/span.h
  • src/fl/stl/string.h
  • src/fl/stl/strstream.h
  • src/fl/system/delay.cpp.hpp
  • src/platforms/arm/d51/clockless_arm_d51.h
  • src/platforms/arm/giga/clockless_arm_giga.h
  • src/platforms/arm/k20/clockless_block_arm_k20.h
  • src/platforms/arm/k66/clockless_arm_k66.h
  • src/platforms/arm/k66/clockless_block_arm_k66.h
  • src/platforms/arm/mgm240/clockless_arm_mgm240.h
  • src/platforms/arm/mxrt1062/block_clockless_arm_mxrt1062.h
  • src/platforms/arm/mxrt1062/clockless_arm_mxrt1062.h
  • src/platforms/arm/renesas/clockless_arm_renesas.h
  • src/platforms/arm/rp/rpcommon/clockless_rp_pio.h
  • src/platforms/arm/sam/clockless_arm_sam.h
  • src/platforms/arm/sam/clockless_block_arm_sam.h
  • src/platforms/arm/teensy/teensy31_32/clockless_arm_k20.h
  • src/platforms/arm/teensy/teensy31_32/clockless_block_arm_k20.h
  • src/platforms/arm/teensy/teensy36/clockless_arm_k66.h
  • src/platforms/arm/teensy/teensy36/clockless_block_arm_k66.h
  • src/platforms/arm/teensy/teensy4_common/block_clockless_arm_mxrt1062.h
  • src/platforms/arm/teensy/teensy4_common/clockless_arm_mxrt1062.h
  • src/platforms/delaycycles_generic.h
  • src/platforms/esp/32/clockless_block_esp32.h
  • src/platforms/esp/32/core/fastspi_esp32_arduino.h
  • src/platforms/esp/8266/clockless_block_esp8266.h
  • src/platforms/esp/8266/clockless_esp8266.h
  • src/platforms/esp/8266/fastspi_esp8266.h
  • src/platforms/shared/rx_device_native.cpp.hpp
  • src/platforms/shared/spi_bitbang/generic_software_spi.h
  • src/platforms/shared/ui/json/ui.cpp.hpp
  • src/platforms/shared/ui/json/ui_manager.cpp.hpp

📝 Walkthrough

Walkthrough

This PR systematically adds or corrects FL_NOEXCEPT qualifiers across 44 files in the FastLED library. The changes mark functions as non-throwing throughout the core color operations, STL utilities, timing primitives, platform-specific controllers, and UI handlers. Where the macro was misplaced in type expressions, it is repositioned to comply with C++ function declaration syntax.

Changes

Comprehensive FL_NOEXCEPT annotation consolidation

Layer / File(s) Summary
CRGB arithmetic and color operations
src/crgb.hpp
All CRGB member and non-member operators (addition, subtraction, scaling, luminance, interpolation) gain FL_NOEXCEPT qualifiers to their function signatures.
STL container and utility template helpers
src/fl/stl/basic_vector.h, src/fl/stl/span.h, src/fl/stl/string.h, src/fl/stl/strstream.h, src/fl/stl/function.h
Function-pointer type syntax corrected and FL_NOEXCEPT applied to template helpers, fixing misplaced macros in SFINAE expressions and function-pointer type declarations (e.g., void(*)(args) FL_NOEXCEPT instead of void(*) FL_NOEXCEPT (args)).
Internal codec and math helpers
src/fl/chipsets/clockless_encoder.h, src/fl/gfx/gamma_lut.h, src/fl/math/math.h
Internal detail functions for encoding, gamma LUT generation, and math template overloads (sqrt, floor, ceil) gain FL_NOEXCEPT applied as trailing qualifiers instead of embedded in SFINAE return-type expressions.
Delay and timing primitives
src/fl/system/delay.cpp.hpp, src/platforms/delaycycles_generic.h
Public delay APIs (delayNanoseconds, delayMillis, delayMicroseconds) and explicit delaycycles<N> template specializations gain FL_NOEXCEPT qualifiers; internal delay_impl helper is updated.
Platform-specific clockless controller helpers
src/platforms/arm/d51/..., src/platforms/arm/giga/..., src/platforms/arm/k20/..., src/platforms/arm/k66/..., src/platforms/arm/mgm240/..., src/platforms/arm/mxrt1062/..., src/platforms/arm/renesas/..., src/platforms/arm/rp/..., src/platforms/arm/sam/..., src/platforms/arm/teensy/..., src/platforms/esp/...
writeBits, writeBitsToBuf, and related helpers across all ARM and ESP platforms have FL_NOEXCEPT repositioned to trailing position after parameter lists or adjusted relative to always_inline attributes for consistent C++ syntax.
SPI output and communication helpers
src/platforms/esp/32/core/fastspi_esp32_arduino.h, src/platforms/esp/8266/fastspi_esp8266.h, src/platforms/shared/spi_bitbang/generic_software_spi.h
SPI writePixels implementations and software SPI bitbang helpers have FL_NOEXCEPT repositioned from prefix to trailing position or newly added to declarations.
UI and callback handlers
src/platforms/shared/rx_device_native.cpp.hpp, src/platforms/shared/ui/json/ui.cpp.hpp, src/platforms/shared/ui/json/ui_manager.cpp.hpp
Lambda expressions and callbacks in UI JSON handlers gain explicit FL_NOEXCEPT on lambda operator() declarations.

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related issues

  • FastLED/FastLED#2984 — This PR implements the exact FL_NOEXCEPT annotations that the proposed CI lint enforcement would require across all owned src/ functions, directly addressing the main goals of the lint proposal.

Poem

🐰 A rabbit hops through FastLED's halls,

Adding noexcept to function calls,

No throwing promises, clean and bright,

The code now declares what it will write!

A systematic sweep, both broad and true,

Making contracts clear in every avenue. 🌟

✨ 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 feat/fl-noexcept-macros

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.

@fastled-project-sync fastled-project-sync Bot moved this to Triage in FastLED Tracker Jun 13, 2026
@zackees
zackees merged commit 43f010a into master Jun 13, 2026
7 of 8 checks passed
@fastled-project-sync fastled-project-sync Bot moved this from Triage to Done in FastLED Tracker Jun 13, 2026
pull Bot pushed a commit to manmuqingshan/FastLED that referenced this pull request Jun 14, 2026
…r real-DMA semantics (FastLED#2992 follow-up)

After FastLED#2992 ("feat: add ISR-backed channel poll wakeups"), `ParlioEngine`
runs `beginTransmission()` in ASYNC mode: the last txDone ISR sets
`mStreamComplete=true` and the *next* `poll()` tick observes that flag
and clears `mTransmitting` (the gate that begins a new transmission).
The old engine cleared `mTransmitting` directly in the ISR, so callers
that issued back-to-back `beginTransmission()` calls without an
intervening `poll()` still worked. After FastLED#2992 they no longer do.

Two `parlio_driver` unit tests issue exactly that pattern and have been
failing on master since 2026-06-09 (every CI run on PRs FastLED#2998, FastLED#3001,
and the just-merged FastLED#3003 fails the same way):

  FAIL: ParlioEngine mock - transmission history clearing at
    tests/platforms/esp/32/drivers/parlio/parlio_driver.cpp:671
      :694: count2 > 0
      :695: mock.getTransmitCount() > count1
  REQUIRE FAILED: parlio_driver.cpp:1029: tx_ok

On real hardware the engine's own line-1845 drain pattern
(`mPeripheral->waitAllDone(100)` at the top of `beginTransmission()`)
gives the ISR a chance to fire and then a `poll()` tick can clear
`mTransmitting`. The mock, by contrast, fires txDone callbacks
synchronously inside `transmit()` and used to noop `waitAllDone()`, so
no `poll()` tick ever ran — `mTransmitting` stayed stuck at true
forever and the second `beginTransmission()` short-circuited with
"transmission already in progress".

Fix the mock, not the test (per the maintainer's "gap in the mock vs
the real thing" framing): drive one `ParlioEngine::poll()` tick from
the mock's `waitAllDone()` and `deinitialize()`. Those are the two
real-hardware-faithful boundaries where "no active DMA" is the
contract — `waitAllDone()` is the engine's own pre-transmission drain
point, and `deinitialize()` is what the engine calls from its
config-match re-init path at parlio_engine.cpp.hpp:1411 (the route
test 1029 takes). A single `mSettlingEngine` re-entrancy flag breaks
the obvious recursion (`poll()` itself calls `waitAllDone(0)`).

The mock stays fully synchronous and single-threaded — no new threads,
no new deferred-callback states, no churn in the existing
pumpDeferredCallbacks/mFiringCallbacks machinery. Only the engine
async-state contract gets one extra tick at each transmit boundary.

No engine changes. No test changes. Verified:
- `bash test parlio_driver` passes (both originally failing tests)
- `bash test parlio_driver --debug` passes (ASAN/LSAN/UBSAN clean)
- `bash lint --cpp` clean

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@zackees
zackees deleted the feat/fl-noexcept-macros branch August 21, 2026 19:15
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.

1 participant