Codechange: Replace old non-standard attributes with C++17/20 standard attributes.
This commit is contained in:
@@ -17,7 +17,7 @@
|
||||
* Function to exit with an error message after malloc() or calloc() have failed
|
||||
* @param size number of bytes we tried to allocate
|
||||
*/
|
||||
void NORETURN MallocError(size_t size)
|
||||
[[noreturn]] void MallocError(size_t size)
|
||||
{
|
||||
FatalError("Out of memory. Cannot allocate {} bytes", size);
|
||||
}
|
||||
@@ -26,7 +26,7 @@ void NORETURN MallocError(size_t size)
|
||||
* Function to exit with an error message after realloc() have failed
|
||||
* @param size number of bytes we tried to allocate
|
||||
*/
|
||||
void NORETURN ReallocError(size_t size)
|
||||
[[noreturn]] void ReallocError(size_t size)
|
||||
{
|
||||
FatalError("Out of memory. Cannot reallocate {} bytes", size);
|
||||
}
|
||||
|
@@ -17,8 +17,8 @@
|
||||
* binary needlessly large.
|
||||
*/
|
||||
|
||||
void NORETURN MallocError(size_t size);
|
||||
void NORETURN ReallocError(size_t size);
|
||||
[[noreturn]] void MallocError(size_t size);
|
||||
[[noreturn]] void ReallocError(size_t size);
|
||||
|
||||
/**
|
||||
* Checks whether allocating memory would overflow size_t.
|
||||
|
@@ -53,7 +53,7 @@ public:
|
||||
inline constexpr OverflowSafeInt& operator += (const OverflowSafeInt& other)
|
||||
{
|
||||
#ifdef HAS_OVERFLOW_BUILTINS
|
||||
if (unlikely(__builtin_add_overflow(this->m_value, other.m_value, &this->m_value))) {
|
||||
if (__builtin_add_overflow(this->m_value, other.m_value, &this->m_value)) [[unlikely]] {
|
||||
this->m_value = (other.m_value < 0) ? T_MIN : T_MAX;
|
||||
}
|
||||
#else
|
||||
@@ -76,7 +76,7 @@ public:
|
||||
inline constexpr OverflowSafeInt& operator -= (const OverflowSafeInt& other)
|
||||
{
|
||||
#ifdef HAS_OVERFLOW_BUILTINS
|
||||
if (unlikely(__builtin_sub_overflow(this->m_value, other.m_value, &this->m_value))) {
|
||||
if (__builtin_sub_overflow(this->m_value, other.m_value, &this->m_value)) [[unlikely]] {
|
||||
this->m_value = (other.m_value < 0) ? T_MAX : T_MIN;
|
||||
}
|
||||
#else
|
||||
@@ -114,7 +114,7 @@ public:
|
||||
{
|
||||
#ifdef HAS_OVERFLOW_BUILTINS
|
||||
const bool is_result_positive = (this->m_value < 0) == (factor < 0); // -ve * -ve == +ve
|
||||
if (unlikely(__builtin_mul_overflow(this->m_value, factor, &this->m_value))) {
|
||||
if (__builtin_mul_overflow(this->m_value, factor, &this->m_value)) [[unlikely]] {
|
||||
this->m_value = is_result_positive ? T_MAX : T_MIN;
|
||||
}
|
||||
#else
|
||||
|
Reference in New Issue
Block a user