forked from qt-creator/qt-creator
Utils: fix conflict of withSuffix(int) and withSuffix(qsizetype)
qsizetype is equivalent to ssize_t, meaning signed 32bit on 32bit architectures, and thus this overload conflicts with withSuffix(qsizetype) version on 32bit architectures. Also, as qsizetype is a 64bit type on 64bit architectures, the fact that withSuffix(qsizetype) calls withSuffix(int) by downcasting the parameter to int means that there may be a truncation/loss in case the value is large enough. Hence, to fix both the issues: - switch the two implementations, so now withSuffix(int) calls withSuffix(qsizetype) - disable disable withSuffix(int) on 32bit architectures, as its job is already done by withSuffix(qsizetype) Change-Id: Icb82d2ba58362cc10f18cf2c41ad409c39b60863 Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -252,20 +252,24 @@ QStringList Id::toStringList(const QSet<Id> &ids)
|
|||||||
will be generated by appending \a suffix.
|
will be generated by appending \a suffix.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
Id Id::withSuffix(int suffix) const
|
Id Id::withSuffix(qsizetype suffix) const
|
||||||
{
|
{
|
||||||
const QByteArray ba = name() + QByteArray::number(suffix);
|
const QByteArray ba = name() + QByteArray::number(suffix);
|
||||||
return Id(theId(ba.data(), ba.size()));
|
return Id(theId(ba.data(), ba.size()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if QT_POINTER_SIZE != 4
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\overload
|
\overload
|
||||||
*/
|
*/
|
||||||
Id Id::withSuffix(qsizetype suffix) const
|
Id Id::withSuffix(int suffix) const
|
||||||
{
|
{
|
||||||
return withSuffix(int(suffix));
|
return withSuffix(qsizetype(suffix));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\overload
|
\overload
|
||||||
*/
|
*/
|
||||||
|
@@ -30,8 +30,10 @@ public:
|
|||||||
|
|
||||||
static Id generate();
|
static Id generate();
|
||||||
|
|
||||||
Id withSuffix(int suffix) const;
|
|
||||||
Id withSuffix(qsizetype suffix) const;
|
Id withSuffix(qsizetype suffix) const;
|
||||||
|
#if QT_POINTER_SIZE != 4
|
||||||
|
Id withSuffix(int suffix) const;
|
||||||
|
#endif
|
||||||
Id withSuffix(const char suffix) const;
|
Id withSuffix(const char suffix) const;
|
||||||
Id withSuffix(const char *suffix) const;
|
Id withSuffix(const char *suffix) const;
|
||||||
Id withSuffix(const QStringView suffix) const;
|
Id withSuffix(const QStringView suffix) const;
|
||||||
|
Reference in New Issue
Block a user