diff options
author | Marc Mutz <marc.mutz@qt.io> | 2023-06-21 21:15:31 +0200 |
---|---|---|
committer | Marc Mutz <marc.mutz@qt.io> | 2023-06-28 20:48:45 +0000 |
commit | 01e1dc273d0fd95e4e4f57ae0af1862196f72bd6 (patch) | |
tree | 21fd684505841f970169a5a4d2f5a45ef0536383 /src/corelib/thread/qorderedmutexlocker_p.h | |
parent | 574a47dd5a89e7cecf4fbf592dd0d5b216c3b0a6 (diff) |
Remove all class-level [[nodiscard]] from the code-base
A class-level [[nodiscard]] used to be the only way to get a waring
for code such as
QMutexLocker(&mutex);
with original C++17 means. This was because a few of our compilers
would warn about the presence of [[nodiscard]] on ctors, which is
really the semantics we want: we don't want to prevent users from
passing QMutexLocker out of functions and users of those functions
from ignoring the return value, if they so choose. That should be the
choice of the author of the function returning such types, not ours.
So QUIP-0019 makes class-level [[nodiscard]] conditional on proper
rationale in the user docs (or the commit message in case of private
API). Since none of the existing uses really strikes this author as
particularly convincing, remove them all.
All these classes have gotten Q_NODISCARD_CTOR on all their ctors, so
we continue to provide the same true positive warnings, minus the
false positives when returning from functions, at least on the
majority of compilers (and it's not as if all compilers interpreted a
class-level [[nodiscard]] as a trigger to warn on the initial example
of this commit message).
Task-number: QTBUG-104164
Pick-to: 6.6
Change-Id: I163356486e7c80f9d69bf67023010a88233fe662
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/thread/qorderedmutexlocker_p.h')
-rw-r--r-- | src/corelib/thread/qorderedmutexlocker_p.h | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/corelib/thread/qorderedmutexlocker_p.h b/src/corelib/thread/qorderedmutexlocker_p.h index 43985a3faa..fb2e223e01 100644 --- a/src/corelib/thread/qorderedmutexlocker_p.h +++ b/src/corelib/thread/qorderedmutexlocker_p.h @@ -28,7 +28,7 @@ QT_BEGIN_NAMESPACE Locks 2 mutexes in a defined order, avoiding a recursive lock if we're trying to lock the same mutex twice. */ -class [[nodiscard]] QOrderedMutexLocker +class QOrderedMutexLocker { public: Q_NODISCARD_CTOR @@ -120,7 +120,7 @@ private: #else -class [[nodiscard]] QOrderedMutexLocker +class QOrderedMutexLocker { public: Q_DISABLE_COPY(QOrderedMutexLocker) |