Protect headers against min/max macros
... using the usual pattern, which, being idiomatic, doesn't need a comment explaining it. Pick-to: 6.3 Change-Id: Id6b12450495a18f89e1f83f2018b6218b03ff6a7 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
parent
a87edb9ae9
commit
b727f2190f
@ -313,9 +313,9 @@ public:
|
||||
}
|
||||
|
||||
static constexpr QSpecialInteger max()
|
||||
{ return QSpecialInteger(std::numeric_limits<T>::max()); }
|
||||
{ return QSpecialInteger((std::numeric_limits<T>::max)()); }
|
||||
static constexpr QSpecialInteger min()
|
||||
{ return QSpecialInteger(std::numeric_limits<T>::min()); }
|
||||
{ return QSpecialInteger((std::numeric_limits<T>::min)()); }
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
|
@ -219,7 +219,7 @@ qMulOverflow(T v1, T v2, T *r)
|
||||
typename LargerInt::Signed, typename LargerInt::Unsigned>;
|
||||
Larger lr = Larger(v1) * Larger(v2);
|
||||
*r = T(lr);
|
||||
return lr > std::numeric_limits<T>::max() || lr < std::numeric_limits<T>::min();
|
||||
return lr > (std::numeric_limits<T>::max)() || lr < (std::numeric_limits<T>::min)();
|
||||
}
|
||||
|
||||
# if defined(Q_INTRINSIC_MUL_OVERFLOW64)
|
||||
@ -324,15 +324,15 @@ template <typename T, T V2> bool qMulOverflow(T v1, std::integral_constant<T, V2
|
||||
} else if constexpr (V2 == -1) {
|
||||
// multiplication by -1 is valid *except* for signed minimum values
|
||||
// (necessary to avoid diving min() by -1, which is an overflow)
|
||||
if (v1 < 0 && v1 == std::numeric_limits<T>::min())
|
||||
if (v1 < 0 && v1 == (std::numeric_limits<T>::min)())
|
||||
return true;
|
||||
*r = -v1;
|
||||
return false;
|
||||
} else {
|
||||
// For 64-bit multiplications on 32-bit platforms, let's instead compare v1
|
||||
// against the bounds that would overflow.
|
||||
constexpr T Highest = std::numeric_limits<T>::max() / V2;
|
||||
constexpr T Lowest = std::numeric_limits<T>::min() / V2;
|
||||
constexpr T Highest = (std::numeric_limits<T>::max)() / V2;
|
||||
constexpr T Lowest = (std::numeric_limits<T>::min)() / V2;
|
||||
if constexpr (Highest > Lowest) {
|
||||
if (v1 > Highest || v1 < Lowest)
|
||||
return true;
|
||||
|
@ -203,8 +203,8 @@ static inline bool convertDoubleTo(double v, T *value, bool allow_precision_upgr
|
||||
return false;
|
||||
}
|
||||
|
||||
constexpr T Tmin = std::numeric_limits<T>::min();
|
||||
constexpr T Tmax = std::numeric_limits<T>::max();
|
||||
constexpr T Tmin = (std::numeric_limits<T>::min)();
|
||||
constexpr T Tmax = (std::numeric_limits<T>::max)();
|
||||
|
||||
// The [conv.fpint] (7.10 Floating-integral conversions) section of the C++
|
||||
// standard says only exact conversions are guaranteed. Converting
|
||||
@ -295,7 +295,7 @@ static inline bool convertDoubleTo(double v, T *value, bool allow_precision_upgr
|
||||
return false;
|
||||
} else {
|
||||
using ST = typename std::make_signed<T>::type;
|
||||
supremum = -2.0 * std::numeric_limits<ST>::min(); // -2 * (-2^63) = 2^64, exact (for T = quint64)
|
||||
supremum = -2.0 * (std::numeric_limits<ST>::min)(); // -2 * (-2^63) = 2^64, exact (for T = quint64)
|
||||
v = fabs(v);
|
||||
}
|
||||
|
||||
|
@ -203,8 +203,8 @@ public:
|
||||
void seed(quint32 s = 1) { *this = { s }; }
|
||||
void seed(std::seed_seq &sseq) noexcept { *this = { sseq }; }
|
||||
Q_CORE_EXPORT void discard(unsigned long long z);
|
||||
static constexpr result_type min() { return std::numeric_limits<result_type>::min(); }
|
||||
static constexpr result_type max() { return std::numeric_limits<result_type>::max(); }
|
||||
static constexpr result_type min() { return (std::numeric_limits<result_type>::min)(); }
|
||||
static constexpr result_type max() { return (std::numeric_limits<result_type>::max)(); }
|
||||
|
||||
static inline Q_DECL_CONST_FUNCTION QRandomGenerator *system();
|
||||
static inline Q_DECL_CONST_FUNCTION QRandomGenerator *global();
|
||||
@ -277,8 +277,8 @@ public:
|
||||
QRandomGenerator::discard(z * 2);
|
||||
}
|
||||
|
||||
static constexpr result_type min() { return std::numeric_limits<result_type>::min(); }
|
||||
static constexpr result_type max() { return std::numeric_limits<result_type>::max(); }
|
||||
static constexpr result_type min() { return (std::numeric_limits<result_type>::min)(); }
|
||||
static constexpr result_type max() { return (std::numeric_limits<result_type>::max)(); }
|
||||
static Q_DECL_CONST_FUNCTION Q_CORE_EXPORT QRandomGenerator64 *system();
|
||||
static Q_DECL_CONST_FUNCTION Q_CORE_EXPORT QRandomGenerator64 *global();
|
||||
static Q_CORE_EXPORT QRandomGenerator64 securelySeeded();
|
||||
|
@ -66,7 +66,7 @@ public:
|
||||
constexpr QDeadlineTimer(Qt::TimerType type_ = Qt::CoarseTimer) noexcept
|
||||
: t1(0), t2(0), type(type_) {}
|
||||
constexpr QDeadlineTimer(ForeverConstant, Qt::TimerType type_ = Qt::CoarseTimer) noexcept
|
||||
: t1(std::numeric_limits<qint64>::max()), t2(0), type(type_) {}
|
||||
: t1((std::numeric_limits<qint64>::max)()), t2(0), type(type_) {}
|
||||
explicit QDeadlineTimer(qint64 msecs, Qt::TimerType type = Qt::CoarseTimer) noexcept;
|
||||
|
||||
void swap(QDeadlineTimer &other) noexcept
|
||||
|
@ -263,7 +263,7 @@ public:
|
||||
{
|
||||
if (qIsInf(d))
|
||||
return float(d);
|
||||
if (std::fabs(d) > std::numeric_limits<float>::max()) {
|
||||
if (std::fabs(d) > (std::numeric_limits<float>::max)()) {
|
||||
if (ok)
|
||||
*ok = false;
|
||||
const float huge = std::numeric_limits<float>::infinity();
|
||||
|
@ -137,10 +137,10 @@ public:
|
||||
virtual void serialize(QDataStream &ds) const;
|
||||
|
||||
// Static Utility Methods
|
||||
static inline qint64 maxMSecs() { return std::numeric_limits<qint64>::max(); }
|
||||
static inline qint64 minMSecs() { return std::numeric_limits<qint64>::min() + 1; }
|
||||
static inline qint64 invalidMSecs() { return std::numeric_limits<qint64>::min(); }
|
||||
static inline qint64 invalidSeconds() { return std::numeric_limits<int>::min(); }
|
||||
static inline qint64 maxMSecs() { return (std::numeric_limits<qint64>::max)(); }
|
||||
static inline qint64 minMSecs() { return (std::numeric_limits<qint64>::min)() + 1; }
|
||||
static inline qint64 invalidMSecs() { return (std::numeric_limits<qint64>::min)(); }
|
||||
static inline qint64 invalidSeconds() { return (std::numeric_limits<int>::min)(); }
|
||||
static Data invalidData();
|
||||
static QTimeZone::OffsetData invalidOffsetData();
|
||||
static QTimeZone::OffsetData toOffsetData(const Data &data);
|
||||
|
@ -117,9 +117,9 @@ static constexpr OO copyData(II input, qsizetype n, OO output)
|
||||
|
||||
template <size_t Highest> constexpr auto minifyValue()
|
||||
{
|
||||
if constexpr (Highest <= std::numeric_limits<quint8>::max()) {
|
||||
if constexpr (Highest <= (std::numeric_limits<quint8>::max)()) {
|
||||
return quint8(Highest);
|
||||
} else if constexpr (Highest <= std::numeric_limits<quint16>::max()) {
|
||||
} else if constexpr (Highest <= (std::numeric_limits<quint16>::max)()) {
|
||||
return quint16(Highest);
|
||||
} else {
|
||||
// int is probably enough for everyone
|
||||
|
@ -123,7 +123,7 @@ public:
|
||||
|
||||
const QXcbEventNode *flushedTail() const { return m_flushedTail; }
|
||||
void waitForNewEvents(const QXcbEventNode *sinceFlushedTail,
|
||||
unsigned long time = std::numeric_limits<unsigned long>::max());
|
||||
unsigned long time = (std::numeric_limits<unsigned long>::max)());
|
||||
|
||||
private:
|
||||
QXcbEventNode *qXcbEventNodeFactory(xcb_generic_event_t *event);
|
||||
|
@ -423,7 +423,7 @@ public:
|
||||
int minimumContentsLength = 0;
|
||||
int indexBeforeChange = -1;
|
||||
int maxVisibleItems = 10;
|
||||
int maxCount = std::numeric_limits<int>::max();
|
||||
int maxCount = (std::numeric_limits<int>::max)();
|
||||
int modelColumn = 0;
|
||||
int placeholderIndex = -1;
|
||||
bool shownOnce : 1;
|
||||
|
Loading…
Reference in New Issue
Block a user