From a337b8360f149313f5bf37dc5867413d846a3a97 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Wed, 13 Dec 2023 12:03:03 -0300 Subject: Suppress clang-tidy mem leak warning on QMetaObject::invokeMethod MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We don't leak, but clang-tidy is printing this warning. Possibly because it sees a new with no matched delete in the same context, ignoring the fact that the pointer was gifted to the called function. Fixes: QTBUG-119972 Pick-to: 6.7 6.6 6.5 Change-Id: I6e2677aad2ab45759db2fffd17a06c57c3a463ba Reviewed-by: Marc Mutz Reviewed-by: MÃ¥rten Nordheim --- src/corelib/kernel/qobjectdefs.h | 1 + src/corelib/kernel/qobjectdefs_impl.h | 1 + 2 files changed, 2 insertions(+) (limited to 'src') diff --git a/src/corelib/kernel/qobjectdefs.h b/src/corelib/kernel/qobjectdefs.h index 1ff4ee80b6..7763cea6ef 100644 --- a/src/corelib/kernel/qobjectdefs.h +++ b/src/corelib/kernel/qobjectdefs.h @@ -622,6 +622,7 @@ private: auto h = QtPrivate::invokeMethodHelper(ret, args...); + // NOLINTNEXTLINE(clang-analyzer-cplusplus.NewDeleteLeaks) auto callable = new QtPrivate::QCallableObject, ActualArguments, typename Callable::ReturnType>(std::forward(function)); return invokeMethodImpl(object, callable, type, h.parameterCount(), h.parameters.data(), diff --git a/src/corelib/kernel/qobjectdefs_impl.h b/src/corelib/kernel/qobjectdefs_impl.h index d45971fc87..ec9f12f5f1 100644 --- a/src/corelib/kernel/qobjectdefs_impl.h +++ b/src/corelib/kernel/qobjectdefs_impl.h @@ -622,6 +622,7 @@ namespace QtPrivate { static_assert(int(ActualSignature::ArgumentCount) <= int(ExpectedSignature::ArgumentCount), "Functor requires more arguments than what can be provided."); + // NOLINTNEXTLINE(clang-analyzer-cplusplus.NewDeleteLeaks) return new QtPrivate::QCallableObject, ActualArguments, ExpectedReturnType>(std::forward(func)); } -- cgit v1.2.3