Add -Wweak-vtables to headersclean

This requires some fixes in several classes that are also included
in this patch.

The QTestEvent hierarchy is all-inline and changes layout depending on
QT_GUI_LIB and QT_WIDGETS_LIB, so we can't just export it. Suppress the
warning in that header for now. Created QTBUG-104486 to track a fix for
the real issue.

The QFutureInterface hierarchy is also all-inline, but templates, so
doesn't trigger, except the <void> specialization. Created
QTBUG-125115 to track a fix for the real issue.

Done-with: Marc Mutz <marc.mutz@qt.io>
Task-number: QTBUG-45582
Change-Id: I96b3e109aa989b70e0d4809b90bd53a369e50d55
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
This commit is contained in:
Jesus Fernandez 2018-10-11 10:37:45 +02:00 committed by Marc Mutz
parent 00099c057c
commit 7c128f8866
12 changed files with 50 additions and 12 deletions

View File

@ -130,7 +130,8 @@ function(qt_internal_add_headersclean_target module_target module_headers)
endif()
if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang|IntelLLVM")
list(APPEND hcleanFLAGS -Wshorten-64-to-32)
list(APPEND hcleanFLAGS -Wshorten-64-to-32
-Wweak-vtables)
endif()
separate_arguments(cxx_flags NATIVE_COMMAND ${CMAKE_CXX_FLAGS})

View File

@ -465,6 +465,9 @@ std::vector<T> QFutureInterface<T>::takeResults()
}
#endif
QT_WARNING_PUSH
QT_WARNING_DISABLE_CLANG("-Wweak-vtables") // QTBUG-125115
template <>
class QFutureInterface<void> : public QFutureInterfaceBase
{
@ -495,6 +498,8 @@ public:
}
};
QT_WARNING_POP // Clang -Wweak-vtables
template<typename T>
inline void swap(QFutureInterface<T> &a, QFutureInterface<T> &b) noexcept
{

View File

@ -33,6 +33,8 @@ QT_BEGIN_NAMESPACE
Destroys the accessibility bridge object.
*/
QAccessibleBridge::~QAccessibleBridge()
= default;
/*!
\fn void QAccessibleBridge::setRootObject(QAccessibleInterface *object)

View File

@ -16,10 +16,10 @@ QT_BEGIN_NAMESPACE
class QAccessibleInterface;
class QAccessibleEvent;
class QAccessibleBridge
class Q_GUI_EXPORT QAccessibleBridge
{
public:
virtual ~QAccessibleBridge() {}
virtual ~QAccessibleBridge();
virtual void setRootObject(QAccessibleInterface *) = 0;
virtual void notifyAccessibilityUpdate(QAccessibleEvent *event) = 0;
};

View File

@ -53,6 +53,9 @@ namespace {
QTextDocument::ResourceProvider qt_defaultResourceProvider;
};
QAbstractUndoItem::~QAbstractUndoItem()
= default;
/*!
\fn bool Qt::mightBeRichText(QAnyStringView text)

View File

@ -45,15 +45,11 @@ namespace Qt
class Q_GUI_EXPORT QAbstractUndoItem
{
public:
virtual ~QAbstractUndoItem() = 0;
virtual ~QAbstractUndoItem();
virtual void undo() = 0;
virtual void redo() = 0;
};
inline QAbstractUndoItem::~QAbstractUndoItem()
{
}
class QTextDocumentPrivate;
class Q_GUI_EXPORT QTextDocument : public QObject

View File

@ -14,7 +14,7 @@ qt_internal_add_module(PrintSupport
kernel/qplatformprintplugin.cpp kernel/qplatformprintplugin.h
kernel/qprint.cpp kernel/qprint_p.h
kernel/qprintdevice.cpp kernel/qprintdevice_p.h
kernel/qprintengine.h
kernel/qprintengine.cpp kernel/qprintengine.h
kernel/qprintengine_pdf.cpp kernel/qprintengine_pdf_p.h
kernel/qprinter.cpp kernel/qprinter.h kernel/qprinter_p.h
kernel/qprinterinfo.cpp kernel/qprinterinfo.h kernel/qprinterinfo_p.h

View File

@ -0,0 +1,15 @@
// Copyright (C) 2024 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include <QtPrintSupport/qprintengine.h>
QT_BEGIN_NAMESPACE
#ifndef QT_NO_PRINTER
QPrintEngine::~QPrintEngine()
= default;
#endif // QT_NO_PRINTER
QT_END_NAMESPACE

View File

@ -19,7 +19,8 @@ QT_BEGIN_NAMESPACE
class Q_PRINTSUPPORT_EXPORT QPrintEngine
{
public:
virtual ~QPrintEngine() {}
virtual ~QPrintEngine();
enum PrintEnginePropertyKey {
PPK_CollateCopies,
PPK_ColorMode,

View File

@ -239,6 +239,8 @@ void QSqlDatabasePrivate::disable()
Destroys the SQL driver creator object.
*/
QSqlDriverCreatorBase::~QSqlDriverCreatorBase()
= default;
/*!
\fn QSqlDriver *QSqlDriverCreatorBase::createObject() const

View File

@ -23,7 +23,7 @@ class QThread;
class Q_SQL_EXPORT QSqlDriverCreatorBase
{
public:
virtual ~QSqlDriverCreatorBase() {}
virtual ~QSqlDriverCreatorBase();
virtual QSqlDriver *createObject() const = 0;
};

View File

@ -28,6 +28,9 @@ QT_BEGIN_NAMESPACE
# define QT_ONLY_WIDGETLIB_USES Q_DECL_UNUSED_MEMBER
#endif
QT_WARNING_PUSH
QT_WARNING_DISABLE_CLANG("-Wweak-vtables") // QTBUG-1044486
class QTestEvent
{
public:
@ -36,13 +39,15 @@ public:
#endif
virtual QTestEvent *clone() const = 0;
virtual ~QTestEvent() {}
virtual ~QTestEvent() = default; // ### FIXME: weak vtable (QTBUG-104486)
};
#ifdef QT_GUI_LIB
class QTestKeyEvent: public QTestEvent
{
public:
~QTestKeyEvent() override = default; // ### FIXME: weak vtable (QTBUG-104486)
inline QTestKeyEvent(QTest::KeyAction action, Qt::Key key, Qt::KeyboardModifiers modifiers, int delay)
: _action(action), _delay(delay), _modifiers(modifiers), _ascii(0), _key(key) {}
inline QTestKeyEvent(QTest::KeyAction action, char ascii, Qt::KeyboardModifiers modifiers, int delay)
@ -71,6 +76,8 @@ protected:
class QTestKeyClicksEvent: public QTestEvent
{
public:
~QTestKeyClicksEvent() override = default; // ### FIXME: weak vtables (QTBUG-104486)
inline QTestKeyClicksEvent(const QString &keys, Qt::KeyboardModifiers modifiers, int delay)
: _keys(keys), _modifiers(modifiers), _delay(delay) {}
inline QTestEvent *clone() const override { return new QTestKeyClicksEvent(*this); }
@ -91,6 +98,8 @@ private:
class QTestMouseEvent: public QTestEvent
{
public:
~QTestMouseEvent() override = default; // ### FIXME: weak vtables (QTBUG-104486)
inline QTestMouseEvent(QTest::MouseAction action, Qt::MouseButton button,
Qt::KeyboardModifiers modifiers, QPoint position, int delay)
: _action(action), _button(button), _modifiers(modifiers), _pos(position), _delay(delay) {}
@ -117,6 +126,8 @@ class QTestDelayEvent: public QTestEvent
{
public:
inline QTestDelayEvent(int msecs): _delay(msecs) {}
~QTestDelayEvent() override = default; // ### FIXME: weak vtables (QTBUG-104486)
inline QTestEvent *clone() const override { return new QTestDelayEvent(*this); }
#ifdef QT_WIDGETS_LIB
@ -190,6 +201,8 @@ public:
#undef QT_ONLY_WIDGETLIB_USES
QT_WARNING_POP // Clang -Wweak-vtables
QT_END_NAMESPACE
Q_DECLARE_METATYPE(QTestEventList)