Add -Wshorten-64-to-32 to headersclean

Fix existing warnings by casting to the appropriate type.

Change-Id: Ic44d2a71e1a2e508199dbb46bea7a19e183ec42c
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
This commit is contained in:
Tor Arne Vestbø 2022-07-05 16:19:55 +02:00
parent c1086e1fa7
commit 030923c0de
6 changed files with 11 additions and 7 deletions

View File

@ -127,6 +127,10 @@ function(qt_internal_add_headers_clean_target
endif()
endif()
if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang|IntelLLVM")
list(APPEND hcleanFLAGS -Wshorten-64-to-32)
endif()
# Use strict mode C++20, with no GNU extensions (see -pedantic-errors above).
list(APPEND hcleanFLAGS -std=c++2a)

View File

@ -134,7 +134,7 @@ public:
bool toBool(bool defaultValue = false) const
{ return concreteBool(*this, defaultValue); }
int toInt(int defaultValue = 0) const
{ return concreteInt(*this, defaultValue, true); }
{ return int(concreteInt(*this, defaultValue, true)); }
qint64 toInteger(qint64 defaultValue = 0) const
{ return concreteInt(*this, defaultValue, false); }
double toDouble(double defaultValue = 0) const

View File

@ -163,7 +163,7 @@ inline void QPixmap::scroll(int dx, int dy, int ax, int ay, int awidth, int ahei
inline bool QPixmap::loadFromData(const QByteArray &buf, const char *format,
Qt::ImageConversionFlags flags)
{
return loadFromData(reinterpret_cast<const uchar *>(buf.constData()), buf.size(), format, flags);
return loadFromData(reinterpret_cast<const uchar *>(buf.constData()), uint(buf.size()), format, flags);
}

View File

@ -127,7 +127,7 @@ inline QList<QPointF> QRawFont::advancesForGlyphIndexes(const QList<quint32> &gl
QRawFont::LayoutFlags layoutFlags) const
{
QList<QPointF> advances(glyphIndexes.size());
if (advancesForGlyphIndexes(glyphIndexes.constData(), advances.data(), glyphIndexes.size(), layoutFlags))
if (advancesForGlyphIndexes(glyphIndexes.constData(), advances.data(), int(glyphIndexes.size()), layoutFlags))
return advances;
return QList<QPointF>();
}

View File

@ -97,7 +97,7 @@ public:
bool wait(int timeout = 5000)
{
Q_ASSERT(!m_waiting);
const int origCount = count();
const qsizetype origCount = count();
m_waiting = true;
m_loop.enterLoopMSecs(timeout);
m_waiting = false;

View File

@ -148,8 +148,8 @@ public:
executePendingSort();
return children.at(index);
}
inline int childCount() const { return children.count(); }
inline int columnCount() const { return values.count(); }
inline int childCount() const { return int(children.count()); }
inline int columnCount() const { return int(values.count()); }
inline int indexOfChild(QTreeWidgetItem *child) const;
void addChild(QTreeWidgetItem *child);
@ -213,7 +213,7 @@ inline void QTreeWidgetItem::setFont(int column, const QFont &afont)
{ setData(column, Qt::FontRole, afont); }
inline int QTreeWidgetItem::indexOfChild(QTreeWidgetItem *achild) const
{ executePendingSort(); return children.indexOf(achild); }
{ executePendingSort(); return int(children.indexOf(achild)); }
#ifndef QT_NO_DATASTREAM
Q_WIDGETS_EXPORT QDataStream &operator<<(QDataStream &out, const QTreeWidgetItem &item);