-
-
Notifications
You must be signed in to change notification settings - Fork 472
Made all 'noexcept' statements use ETL_NOEXCEPT macro #1179
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Made all 'noexcept' statements use ETL_NOEXCEPT macro #1179
Conversation
WalkthroughReplaces direct noexcept specifiers with the ETL_NOEXCEPT macro across multiple headers. Affects byte operations, initializer_list, chrono comparisons and literals, variant utilities and helpers, and string_view literal operators. No parameter, return type, or body changes; non-C++11 paths remain unchanged where noted. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10–15 minutes ✨ Finishing Touches
🧪 Generate unit tests
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
Status, Documentation and Community
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
include/etl/private/chrono/year.h (1)
127-142
: Bug: years += / -= use unsigned char, causing wrap at 255.This can corrupt year arithmetic (e.g., adding 300 years wraps). Not introduced by this PR but high-impact.
- value += static_cast<unsigned char>(ys.count()); + value = static_cast<rep>(value + static_cast<rep>(ys.count())); ... - value -= static_cast<unsigned char>(ys.count()); + value = static_cast<rep>(value - static_cast<rep>(ys.count()));
🧹 Nitpick comments (5)
include/etl/private/chrono/month.h (1)
158-164
: Nit: fix range in doc comment (12 months, not 31).Change “valid 1 to 31 range” to “valid 1 to 12 range.”
- /// Returns <b>true</b> if the month is within the valid 1 to 31 range + /// Returns <b>true</b> if the month is within the valid 1 to 12 rangeinclude/etl/private/chrono/day.h (1)
85-91
: Optional: add ETL_NOEXCEPT to templated assignment for consistency.Other mutators are ETL_NOEXCEPT; if duration_cast is noexcept in your config, align this too.
- ETL_CONSTEXPR14 etl::chrono::day& operator =(const etl::chrono::duration<TValue2, TPeriod2>& rhs) + ETL_CONSTEXPR14 etl::chrono::day& operator =(const etl::chrono::duration<TValue2, TPeriod2>& rhs) ETL_NOEXCEPTinclude/etl/private/chrono/year.h (1)
229-256
: Potential ordering bug for negative years: comparisons cast to unsigned.Casting year to unsigned before compare mis-orders negatives. Consider comparing as signed (rep) instead.
- return (static_cast<unsigned>(y1) < static_cast<unsigned>(y2)); + return (static_cast<int>(y1) < static_cast<int>(y2));(Apply similarly to ==, <=, >, >=.)
include/etl/byte.h (1)
79-79
: Remove stray double semicolonMinor formatting nit: extra ';' after the assignment.
- return b = b << shift;; + return b = b << shift;include/etl/private/variant_variadic.h (1)
1417-1420
: Consider marking free swap as ETL_NOEXCEPT to mirror member swapThe member swap() is ETL_NOEXCEPT; the free swap can mirror it for consistency and noexcept propagation.
- void swap(etl::variant<TTypes...>& lhs, etl::variant<TTypes...>& rhs) + void swap(etl::variant<TTypes...>& lhs, etl::variant<TTypes...>& rhs) ETL_NOEXCEPT
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (13)
include/etl/byte.h
(5 hunks)include/etl/initializer_list.h
(7 hunks)include/etl/private/chrono/day.h
(2 hunks)include/etl/private/chrono/month.h
(1 hunks)include/etl/private/chrono/month_day.h
(2 hunks)include/etl/private/chrono/time_point.h
(1 hunks)include/etl/private/chrono/year.h
(2 hunks)include/etl/private/variant_variadic.h
(13 hunks)include/etl/string.h
(1 hunks)include/etl/u16string.h
(1 hunks)include/etl/u32string.h
(1 hunks)include/etl/u8string.h
(1 hunks)include/etl/wstring.h
(1 hunks)
🧰 Additional context used
🧠 Learnings (1)
📓 Common learnings
Learnt from: filipe-cuim
PR: ETLCPP/etl#1174
File: include/etl/type_traits.h:1974-1985
Timestamp: 2025-09-01T14:17:35.337Z
Learning: The current implementation in this PR correctly uses only individual trait flags (like ETL_USING_BUILTIN_IS_ASSIGNABLE) in preprocessor guards, not the global ETL_USE_TYPE_TRAITS_BUILTINS flag, because the global flag automatically defines all individual flags when enabled, making dual checks redundant.
🧬 Code graph analysis (5)
include/etl/private/chrono/month.h (2)
include/etl/private/chrono/day.h (4)
etl
(35-203)etl
(323-332)etl
(337-353)chrono
(37-194)include/etl/private/chrono/operators.h (1)
chrono
(37-110)
include/etl/private/chrono/month_day.h (2)
include/etl/private/chrono/day.h (2)
etl
(35-203)chrono
(37-194)include/etl/private/chrono/month.h (22)
etl
(35-155)etl
(358-358)etl
(359-359)etl
(360-360)etl
(361-361)etl
(362-362)etl
(363-363)etl
(364-364)etl
(365-365)etl
(367-390)etl
(368-370)etl
(377-386)chrono
(37-145)chrono
(344-344)chrono
(345-345)chrono
(346-346)chrono
(347-347)chrono
(348-348)chrono
(349-349)chrono
(350-350)chrono
(351-351)chrono
(352-352)
include/etl/private/chrono/day.h (2)
include/etl/private/chrono/month.h (23)
etl
(35-155)etl
(358-358)etl
(359-359)etl
(360-360)etl
(361-361)etl
(362-362)etl
(363-363)etl
(364-364)etl
(365-365)etl
(367-390)etl
(368-370)etl
(377-386)chrono
(37-145)chrono
(344-344)chrono
(345-345)chrono
(346-346)chrono
(347-347)chrono
(348-348)chrono
(349-349)chrono
(350-350)chrono
(351-351)chrono
(352-352)operator
(379-385)include/etl/private/chrono/duration.h (3)
etl
(42-312)etl
(712-863)chrono
(44-246)
include/etl/private/chrono/year.h (3)
include/etl/private/chrono/day.h (5)
etl
(35-203)etl
(323-332)etl
(337-353)chrono
(37-194)operator
(325-331)include/etl/private/chrono/month.h (23)
etl
(35-155)etl
(358-358)etl
(359-359)etl
(360-360)etl
(361-361)etl
(362-362)etl
(363-363)etl
(364-364)etl
(365-365)etl
(367-390)etl
(368-370)etl
(377-386)chrono
(37-145)chrono
(344-344)chrono
(345-345)chrono
(346-346)chrono
(347-347)chrono
(348-348)chrono
(349-349)chrono
(350-350)chrono
(351-351)chrono
(352-352)operator
(379-385)include/etl/private/chrono/year_month.h (2)
chrono
(37-121)operator
(274-285)
include/etl/private/variant_variadic.h (4)
include/etl/utility.h (4)
operator
(447-450)operator
(482-485)etl
(51-92)etl
(56-59)include/etl/optional.h (4)
etl
(43-636)T
(397-405)T
(410-497)T
(995-1082)include/etl/span.h (6)
etl
(56-333)- `` (447-450)
- `` (496-500)
- `` (853-856)
- `` (870-873)
- `` (907-911)
include/etl/monostate.h (1)
etl
(36-44)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (20)
- GitHub Check: Clang C++20 OSX - No STL - Force C++03 (macos-13)
- GitHub Check: Clang C++20 Linux - No STL - Force C++03 (ubuntu-22.04)
- GitHub Check: Clang C++20 Linux - No STL (ubuntu-22.04)
- GitHub Check: GCC C++20 Linux - No STL - Force C++03 (ubuntu-22.04)
- GitHub Check: GCC C++23 Linux - STL - Force C++03 (ubuntu-22.04)
- GitHub Check: GCC C++20 Linux - STL - Force C++03 (ubuntu-22.04)
- GitHub Check: GCC C++23 Linux - No STL - Force C++03 (ubuntu-22.04)
- GitHub Check: GCC C++23 Linux - STL (ubuntu-22.04)
- GitHub Check: GCC C++17 Linux - STL (ubuntu-22.04)
- GitHub Check: Clang C++14 Linux - STL (ubuntu-22.04)
- GitHub Check: Clang C++14 Linux - No STL (ubuntu-22.04)
- GitHub Check: GCC C++20 Linux - STL (ubuntu-22.04)
- GitHub Check: GCC C++23 Linux - No STL (ubuntu-22.04)
- GitHub Check: Clang C++17 Linux - STL (ubuntu-22.04)
- GitHub Check: Clang C++17 Linux - No STL (ubuntu-22.04)
- GitHub Check: Windows - No STL
- GitHub Check: GCC C++14 Linux - STL (ubuntu-22.04)
- GitHub Check: GCC C++11 Linux - STL (ubuntu-22.04)
- GitHub Check: GCC C++11 Linux - No STL (ubuntu-22.04)
- GitHub Check: GCC C++14 Linux - No STL (ubuntu-22.04)
🔇 Additional comments (19)
include/etl/private/chrono/month.h (1)
264-267
: LGTM: switched spaceship operator to ETL_NOEXCEPT.Matches the PR intent and aligns with surrounding operators already using ETL_NOEXCEPT.
include/etl/private/chrono/month_day.h (2)
195-198
: LGTM: month_day spaceship operator now uses ETL_NOEXCEPT.Consistent with the rest of chrono operators.
324-327
: LGTM: month_day_last spaceship operator now uses ETL_NOEXCEPT.No behavioral changes; spec-only.
include/etl/private/chrono/time_point.h (2)
271-274
: LGTM: time_point spaceship operator moved to ETL_NOEXCEPT.Matches PR goal and surrounding API style.
1-286
: No remaining rawnoexcept
; all occurrences useETL_NOEXCEPT
consistently.include/etl/private/chrono/day.h (2)
262-265
: LGTM: day spaceship operator switched to ETL_NOEXCEPT.Consistent with other comparison operators here.
344-347
: LGTM: chrono day literal operators now use ETL_NOEXCEPT.Keeps literals consistent with macro-based spec.
include/etl/private/chrono/year.h (2)
262-265
: LGTM: year spaceship operator switched to ETL_NOEXCEPT.Matches the rest of the file.
360-363
: LGTM: chrono year literal operators now use ETL_NOEXCEPT.Consistent with other chrono literal updates.
include/etl/byte.h (1)
44-47
: Consistent ETL_NOEXCEPT migration — LGTMAll affected byte APIs now use ETL_NOEXCEPT. Signatures and constexpr qualifiers are preserved; includes ensure the macro is available via platform.h.
Also applies to: 55-58, 66-69, 77-81, 88-91, 96-99, 104-107, 112-115, 120-123, 128-131, 136-139, 144-147
include/etl/initializer_list.h (1)
74-86
: Initializer_list now uniformly uses ETL_NOEXCEPT — LGTMBoth MSVC and GCC/Clang branches are updated consistently (ctors, begin/end, size, and free functions). No behavioral changes.
Also applies to: 90-106, 120-131, 157-161, 165-181, 191-199, 205-215
include/etl/private/variant_variadic.h (2)
271-272
: Variant API ETL_NOEXCEPT alignment — LGTMForward decls/defs of holds_alternative, monostate ops, variant::valueless_by_exception/index/is_type/swap, get_if overloads, and do_visit_helper::fptr are consistently migrated. Matches existing ETL usage elsewhere.
Also applies to: 308-316, 785-797, 815-823, 841-846, 1224-1229, 1235-1238, 1244-1247, 1354-1364, 1369-1379, 1383-1395, 1399-1411, 1564-1567
31-47
: ETL_NOEXCEPT macro verified
ETL_NOEXCEPT is defined ininclude/etl/platform.h
to expand tonoexcept
under C++11 (and empty pre-C++11) and no rawnoexcept
remains outside excluded files.include/etl/string.h (2)
51-54
: UDL now uses ETL_NOEXCEPT — looks goodConsistent with the PR intent and keeps the literal operator in lockstep with platform-specific noexcept handling.
51-54
: Ensure ETL_NOEXCEPT is uniformly defined
ETL_NOEXCEPT is defined both asnoexcept
(platform.h:334) and as an empty macro (platform.h:353, plus test/vs2019/vs2022 hints), so confirm your build-configuration guards (e.g. exception-support flags) produce a single, consistent expansion across all TUs to avoid mismatched function types when taking the_sv
operator’s address.include/etl/u8string.h (1)
52-55
: ETL_NOEXCEPT applied to u8string UDL — OKMatches the macro standardization; no ABI or behavioral changes expected.
include/etl/u32string.h (1)
49-52
: ETL_NOEXCEPT on u32string UDL — OKAligned with the rest of the literals; consistent include of platform.h ensures macro availability.
include/etl/wstring.h (1)
49-52
: wstring UDL switched to ETL_NOEXCEPT — OKChange is scoped to the exception spec only; body unchanged.
include/etl/u16string.h (1)
49-52
: u16string UDL uses ETL_NOEXCEPT — OKConsistent with the broader PR; no further issues spotted here.
Some compilers will fail to build when a
noexexcept
statement is included in code built with exceptions turned off (IAR, for example). This fix replaces the remainingnoexcept
calls that weren't already using theETL_NOEXCEPT
macro to address this issue.Summary by CodeRabbit