From 7ee5d1913c7cfd0261f86b0ff7be6968b8c07d84 Mon Sep 17 00:00:00 2001 From: Richard-Qin-X Date: Fri, 28 Aug 2026 23:56:19 +0800 Subject: [Support] Use standard power-of-two checks --- backend/lib/MC/MCSection.cpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'backend/lib/MC/MCSection.cpp') 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 #include #include @@ -19,16 +20,12 @@ namespace { return true; } -[[nodiscard]] bool isPowerOfTwo(std::uint64_t Value) noexcept { - return Value != 0 && (Value & (Value - 1U)) == 0; -} - } // namespace Expected 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"); } -- cgit v1.2.3