Mark qBadAlloc as [[noreturn]]

So that static analyzers don't get confused by its semantics.
In builds with exceptions disabled, it's not actually called
by client code (e.g. Q_CHECK_PTR will just terminate in that case),
but we still need to make it not return -- add another path that
callss std::terminate(), otherwise we'd have a noreturn function
returning.

Change-Id: Ia8c4ce3e9d971f1757e9c273051cb3dedf23c61f
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
bb10
Giuseppe D'Angelo 2021-01-17 19:07:48 +01:00
parent 813a928c7c
commit 790b600840
2 changed files with 5 additions and 1 deletions

View File

@ -3098,7 +3098,11 @@ void qt_check_pointer(const char *n, int l) noexcept
*/
void qBadAlloc()
{
#ifndef QT_NO_EXCEPTIONS
QT_THROW(std::bad_alloc());
#else
std::terminate();
#endif
}
#ifndef QT_NO_EXCEPTIONS

View File

@ -921,7 +921,7 @@ Q_CORE_EXPORT void qt_assert_x(const char *where, const char *what, const char *
#endif
Q_NORETURN Q_CORE_EXPORT void qt_check_pointer(const char *, int) noexcept;
Q_DECL_COLD_FUNCTION
Q_NORETURN Q_DECL_COLD_FUNCTION
Q_CORE_EXPORT void qBadAlloc();
#ifdef QT_NO_EXCEPTIONS