Make modm compileable with Clang for tooling support#1349
Draft
chris-durand wants to merge 7 commits intomodm-io:developfrom
Draft
Make modm compileable with Clang for tooling support#1349chris-durand wants to merge 7 commits intomodm-io:developfrom
chris-durand wants to merge 7 commits intomodm-io:developfrom
Conversation
Clang doesn't provide constexpr built-ins for round, ceil and floor yet. GCC and libstd++ had support for constexpr std::round, std::ceil and std::floor before the feature had been added to C++23.
aa4cbe3 to
e3e9e4e
Compare
Rgb, Rgb565, Hsv and Brightness types all circularly depended on each other. The code is ill-formed, but compiled with gcc because of its non-conforming way of instantiating templates. Especially, the code doesn't compile with Clang. All of those classes implemented converting constructors to convert between each other. The dependency circle is broken up by replacing some of those constructors with conversion operators in the other type. Furthermore, conversions between types of different bit widths were disallowed where they were syntactically possible but yielded nonsensical results. In those cases conversion to a smaller type resulted in bitwise truncation. Conversion to a bigger type was done by simple assignment without scaling. TODO: - strongly consider removing error-prone implicit conversions - validate math for correctness
Functionality is provided by the standard library (std::numeric_limits, std::make_signed_t, std::make_unsigned_t)
The alignment was erroneously 1 instead of 2
Deprecate modm::aligned_storage_t which relies on the deprecated type std::aligned_storage. Remove all usages from modm and replace them with a properly aligned std::byte array as recommended by C++ paper P1413R3.
e3e9e4e to
c650a4d
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Enable modm to be compiled with Clang >= 22 to allow for use of Clang based tooling (e.g. Clang Tidy) in user projects.
Required changes:
typename,templatekeywords)constexprversions ofstd::round,std::floorandstd::ceilas clang still lacksconstexprsupport for more complex math functionsint32_t==inton Cortex-M with Clang instead ofint32_t==longwith GCC__atomic_is_lock_freefor Clang (If Clang was to be used for compiling binaries to run on devices the atomic implementation would need changes)Further changes:
ArithmeticTraitsavailable in the standard librarymodm::aligned_storage_tsincestd::aligned_storageis deprecated in C++23. Also remove all internal uses.TODO: