From 351800ace2bbd47e3c1540a934b22c6f46ca59ea Mon Sep 17 00:00:00 2001 From: Ali Can Demiralp Date: Tue, 8 Apr 2025 16:53:42 +0200 Subject: [PATCH] Add nodiscard attribute to QtMiscUtils functions Change-Id: I2039fcaafc478aaac45dce88b5d979a66a2f2424 Reviewed-by: Thiago Macieira --- src/corelib/tools/qtools_p.h | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/corelib/tools/qtools_p.h b/src/corelib/tools/qtools_p.h index 105aa40c025..1fbe43e340c 100644 --- a/src/corelib/tools/qtools_p.h +++ b/src/corelib/tools/qtools_p.h @@ -24,12 +24,12 @@ QT_BEGIN_NAMESPACE namespace QtMiscUtils { -constexpr inline char toHexUpper(char32_t value) noexcept +[[nodiscard]] constexpr inline char toHexUpper(char32_t value) noexcept { return "0123456789ABCDEF"[value & 0xF]; } -constexpr inline char toHexLower(char32_t value) noexcept +[[nodiscard]] constexpr inline char toHexLower(char32_t value) noexcept { return "0123456789abcdef"[value & 0xF]; } @@ -41,7 +41,7 @@ constexpr inline char toHexLower(char32_t value) noexcept || (c >= 'a' && c <= 'f'); } -constexpr inline int fromHex(char32_t c) noexcept +[[nodiscard]] constexpr inline int fromHex(char32_t c) noexcept { return ((c >= '0') && (c <= '9')) ? int(c - '0') : ((c >= 'A') && (c <= 'F')) ? int(c - 'A' + 10) : @@ -49,7 +49,7 @@ constexpr inline int fromHex(char32_t c) noexcept /* otherwise */ -1; } -constexpr inline char toOct(char32_t value) noexcept +[[nodiscard]] constexpr inline char toOct(char32_t value) noexcept { return char('0' + (value & 0x7)); } @@ -59,7 +59,7 @@ constexpr inline char toOct(char32_t value) noexcept return c >= '0' && c <= '7'; } -constexpr inline int fromOct(char32_t c) noexcept +[[nodiscard]] constexpr inline int fromOct(char32_t c) noexcept { return isOctalDigit(c) ? int(c - '0') : -1; } @@ -69,44 +69,44 @@ constexpr inline int fromOct(char32_t c) noexcept return c >= '0' && c <= '9'; } -constexpr inline bool isAsciiUpper(char32_t c) noexcept +[[nodiscard]] constexpr inline bool isAsciiUpper(char32_t c) noexcept { return c >= 'A' && c <= 'Z'; } -constexpr inline bool isAsciiLower(char32_t c) noexcept +[[nodiscard]] constexpr inline bool isAsciiLower(char32_t c) noexcept { return c >= 'a' && c <= 'z'; } -constexpr inline bool isAsciiLetterOrNumber(char32_t c) noexcept +[[nodiscard]] constexpr inline bool isAsciiLetterOrNumber(char32_t c) noexcept { return isAsciiDigit(c) || isAsciiLower(c) || isAsciiUpper(c); } -constexpr inline char toAsciiLower(char ch) noexcept +[[nodiscard]] constexpr inline char toAsciiLower(char ch) noexcept { return isAsciiUpper(ch) ? ch - 'A' + 'a' : ch; } -constexpr inline char toAsciiUpper(char ch) noexcept +[[nodiscard]] constexpr inline char toAsciiUpper(char ch) noexcept { return isAsciiLower(ch) ? ch - 'a' + 'A' : ch; } -constexpr inline int caseCompareAscii(char lhs, char rhs) noexcept +[[nodiscard]] constexpr inline int caseCompareAscii(char lhs, char rhs) noexcept { const char lhsLower = QtMiscUtils::toAsciiLower(lhs); const char rhsLower = QtMiscUtils::toAsciiLower(rhs); return int(uchar(lhsLower)) - int(uchar(rhsLower)); } -constexpr inline int isAsciiPrintable(char32_t ch) noexcept +[[nodiscard]] constexpr inline int isAsciiPrintable(char32_t ch) noexcept { return ch >= ' ' && ch < 0x7f; } -constexpr inline int qt_lencmp(qsizetype lhs, qsizetype rhs) noexcept +[[nodiscard]] constexpr inline int qt_lencmp(qsizetype lhs, qsizetype rhs) noexcept { return lhs == rhs ? 0 : lhs > rhs ? 1 :