QtCore: Disambiguate static variables

They cause clashes in CMake Unity (Jumbo) builds.

Pick-to: 6.5
Task-number: QTBUG-109394
Change-Id: I5f1fbee07872a742a78adc9864fe00c710ca24d0
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
bb10
Friedemann Kleint 2023-01-26 13:46:21 +01:00
parent 9d2f3e63b8
commit d3f8d7fd41
8 changed files with 19 additions and 15 deletions

View File

@ -458,6 +458,8 @@ Q_CORE_EXPORT quint64 qFloatDistance(double a, double b)
Returns true if the absolute value of \a f is within 0.00001f of 0.0.
*/
namespace QtNumericTests {
template <typename T> static constexpr T max = std::numeric_limits<T>::max();
template <typename T> static constexpr T min = std::numeric_limits<T>::min();
@ -489,4 +491,6 @@ static_assert(qt_saturate<int>(min<qint64>) == min<int>);
static_assert(qt_saturate<unsigned>(min<qint64>) == 0);
static_assert(qt_saturate<quint64>(min<qint64>) == 0);
} // namespace QtNumericTests
QT_END_NAMESPACE

View File

@ -53,7 +53,7 @@ Q_CORE_EXPORT bool isBuiltinType(const QByteArray &type)
} // namespace QtPrivate
// copied from qmetaobject.cpp
[[maybe_unused]] static inline const QMetaObjectPrivate *priv(const uint* data)
[[maybe_unused]] static inline const QMetaObjectPrivate *qmobPriv(const uint* data)
{ return reinterpret_cast<const QMetaObjectPrivate*>(data); }
class QMetaMethodBuilderPrivate
@ -704,7 +704,7 @@ void QMetaObjectBuilder::addMetaObject(const QMetaObject *prototype,
}
if ((members & RelatedMetaObjects) != 0) {
Q_ASSERT(priv(prototype->d.data)->revision >= 2);
Q_ASSERT(qmobPriv(prototype->d.data)->revision >= 2);
const auto *objects = prototype->d.relatedMetaObjects;
if (objects) {
while (*objects != nullptr) {
@ -715,7 +715,7 @@ void QMetaObjectBuilder::addMetaObject(const QMetaObject *prototype,
}
if ((members & StaticMetacall) != 0) {
Q_ASSERT(priv(prototype->d.data)->revision >= 6);
Q_ASSERT(qmobPriv(prototype->d.data)->revision >= 6);
if (prototype->d.static_metacall)
setStaticMetacallFunction(prototype->d.static_metacall);
}

View File

@ -2312,7 +2312,7 @@ static QPartialOrdering numericCompare(const QVariant::Private *d1, const QVaria
}
#ifndef QT_BOOTSTRAPPED
static bool canConvertMetaObject(QMetaType fromType, QMetaType toType)
static bool qvCanConvertMetaObject(QMetaType fromType, QMetaType toType)
{
if ((fromType.flags() & QMetaType::PointerToQObject)
&& (toType.flags() & QMetaType::PointerToQObject)) {
@ -2342,7 +2342,7 @@ bool QVariant::equals(const QVariant &v) const
return numericCompare(&d, &v.d) == QPartialOrdering::Equivalent;
#ifndef QT_BOOTSTRAPPED
// if both types are related pointers to QObjects, check if they point to the same object
if (canConvertMetaObject(metatype, v.metaType()))
if (qvCanConvertMetaObject(metatype, v.metaType()))
return pointerCompare(&d, &v.d) == QPartialOrdering::Equivalent;
#endif
return false;
@ -2385,7 +2385,7 @@ QPartialOrdering QVariant::compare(const QVariant &lhs, const QVariant &rhs)
if (canBeNumericallyCompared(lhs.d.type().iface(), rhs.d.type().iface()))
return numericCompare(&lhs.d, &rhs.d);
#ifndef QT_BOOTSTRAPPED
if (canConvertMetaObject(lhs.metaType(), rhs.metaType()))
if (qvCanConvertMetaObject(lhs.metaType(), rhs.metaType()))
return pointerCompare(&lhs.d, &rhs.d);
#endif
return QPartialOrdering::Unordered;

View File

@ -1853,7 +1853,7 @@ void QXmlStreamReaderPrivate::parseError()
int ers = state_stack[tos];
int nexpected = 0;
int expected[nmax];
if (token != ERROR)
if (token != XML_ERROR)
for (int tk = 0; tk < TERMINAL_COUNT; ++tk) {
int k = t_action(ers, tk);
if (k <= 0)

View File

@ -44,7 +44,7 @@ public:
ENTITY = 32,
ENTITY_DONE = 45,
EQ = 14,
ERROR = 43,
XML_ERROR = 43,
FIXED = 39,
HASH = 6,
ID = 48,

View File

@ -140,7 +140,7 @@ bool QXmlStreamReaderPrivate::parse()
} else switch (token_char) {
case 0xfffe:
case 0xffff:
token = ERROR;
token = XML_ERROR;
break;
case '\r':
token = SPACE;

View File

@ -59,7 +59,7 @@ bool QJulianCalendar::isLeapYear(int year) const
// Julian Day 0 was January the first in the proleptic Julian calendar's 4713 BC.
using namespace QRomanCalendrical;
// End a Julian four-year cycle on 1 BC's leap day (Gregorian Feb 27th):
constexpr qint64 BaseJd = LeapDayGregorian1Bce - 2;
constexpr qint64 JulianBaseJd = LeapDayGregorian1Bce - 2;
bool QJulianCalendar::dateToJulianDay(int year, int month, int day, qint64 *jd) const
{
@ -68,13 +68,13 @@ bool QJulianCalendar::dateToJulianDay(int year, int month, int day, qint64 *jd)
return false;
const auto yearDays = yearMonthToYearDays(year, month);
*jd = qDiv<4>(FourYears * yearDays.year) + yearDays.days + day + BaseJd;
*jd = qDiv<4>(FourYears * yearDays.year) + yearDays.days + day + JulianBaseJd;
return true;
}
QCalendar::YearMonthDay QJulianCalendar::julianDayToDate(qint64 jd) const
{
const auto year4Day = qDivMod<FourYears>(4 * (jd - BaseJd) - 1);
const auto year4Day = qDivMod<FourYears>(4 * (jd - JulianBaseJd) - 1);
// Its remainder changes by 4 per day, except at roughly yearly quotient steps.
const auto ymd = dayInYearToYmd(qDiv<4>(year4Day.remainder));
const int y = year4Day.quotient + ymd.year;

View File

@ -65,7 +65,7 @@ bool QMilankovicCalendar::isLeapYear(int year) const
using namespace QRomanCalendrical;
// End a Milankovic nine-century cycle on 1 BC, Feb 28 (Gregorian Feb 29):
constexpr qint64 BaseJd = LeapDayGregorian1Bce;
constexpr qint64 MilankovicBaseJd = LeapDayGregorian1Bce;
// Leap years every 4 years, except for 7 turn-of-century years per nine centuries:
constexpr unsigned NineCenturies = 365 * 900 + 900 / 4 - 7;
// When the turn-of-century is a leap year, the century has 25 leap years in it:
@ -81,13 +81,13 @@ bool QMilankovicCalendar::dateToJulianDay(int year, int month, int day, qint64 *
const auto centuryYear = qDivMod<100>(yearDays.year);
const qint64 fromYear = qDiv<9>(NineCenturies * centuryYear.quotient + 6)
+ qDiv<100>(LeapCentury * centuryYear.remainder);
*jd = fromYear + yearDays.days + day + BaseJd;
*jd = fromYear + yearDays.days + day + MilankovicBaseJd;
return true;
}
QCalendar::YearMonthDay QMilankovicCalendar::julianDayToDate(qint64 jd) const
{
const auto century9Day = qDivMod<NineCenturies>(9 * (jd - BaseJd) - 7);
const auto century9Day = qDivMod<NineCenturies>(9 * (jd - MilankovicBaseJd) - 7);
// Its remainder changes by 9 per day, except roughly once per century.
const auto year100Day = qDivMod<LeapCentury>(100 * qDiv<9>(century9Day.remainder) + 99);
// Its remainder changes by 100 per day, except roughly once per year.