diff options
| author | Richard-Qin-X <richard.qin.001@gmail.com> | 2026-08-28 23:56:19 +0800 |
|---|---|---|
| committer | Richard-Qin-X <richard.qin.001@gmail.com> | 2026-08-28 23:56:19 +0800 |
| commit | 7ee5d1913c7cfd0261f86b0ff7be6968b8c07d84 (patch) | |
| tree | 446dafb95e2f792fee922602b74709c5b9e0777c /backend/lib/MC/MCSection.cpp | |
| parent | f0cfb240d80cb9f4444fb996350c1f88bc69a142 (diff) | |
| download | rcc-project-7ee5d1913c7cfd0261f86b0ff7be6968b8c07d84.tar.gz rcc-project-7ee5d1913c7cfd0261f86b0ff7be6968b8c07d84.tar.xz | |
[Support] Use standard power-of-two checks
Diffstat (limited to 'backend/lib/MC/MCSection.cpp')
| -rw-r--r-- | backend/lib/MC/MCSection.cpp | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/backend/lib/MC/MCSection.cpp b/backend/lib/MC/MCSection.cpp index 21ba410..464dcc6 100644 --- a/backend/lib/MC/MCSection.cpp +++ b/backend/lib/MC/MCSection.cpp @@ -2,6 +2,7 @@ #include "rcc/MC/MCSection.h" +#include <bit> #include <cstdint> #include <string_view> @@ -19,16 +20,12 @@ namespace { return true; } -[[nodiscard]] bool isPowerOfTwo(std::uint64_t Value) noexcept { - return Value != 0 && (Value & (Value - 1U)) == 0; -} - } // namespace Expected<void> MCSectionDesc::verify() const { if (!isValidAssemblyName(Name)) return makeUnexpected(ErrorCode::InvalidArgument, "MC section has an invalid name"); - if (!isPowerOfTwo(Alignment)) { + if (!std::has_single_bit(Alignment)) { return makeUnexpected(ErrorCode::InvalidArgument, "MC section alignment must be a nonzero power of two"); } |
