diff options
Diffstat (limited to 'src/corelib')
-rw-r--r-- | src/corelib/arch/qatomic_msvc.h | 2 | ||||
-rw-r--r-- | src/corelib/global/qcompilerdetection.h | 6 | ||||
-rw-r--r-- | src/corelib/io/qdebug.cpp | 28 | ||||
-rw-r--r-- | src/corelib/io/qdebug.h | 13 | ||||
-rw-r--r-- | src/corelib/kernel/qobject.cpp | 14 | ||||
-rw-r--r-- | src/corelib/kernel/qobject.h | 10 | ||||
-rw-r--r-- | src/corelib/tools/qstring.cpp | 2 | ||||
-rw-r--r-- | src/corelib/tools/qtools_p.h | 8 |
8 files changed, 48 insertions, 35 deletions
diff --git a/src/corelib/arch/qatomic_msvc.h b/src/corelib/arch/qatomic_msvc.h index 85889662fc..fc4d5a466a 100644 --- a/src/corelib/arch/qatomic_msvc.h +++ b/src/corelib/arch/qatomic_msvc.h @@ -42,7 +42,7 @@ // use compiler intrinsics for all atomic functions # define QT_INTERLOCKED_PREFIX _ -# define QT_INTERLOCKED_PROTOTYPE __cdecl +# define QT_INTERLOCKED_PROTOTYPE # define QT_INTERLOCKED_DECLARE_PROTOTYPES # define QT_INTERLOCKED_INTRINSIC # define Q_ATOMIC_INT16_IS_SUPPORTED diff --git a/src/corelib/global/qcompilerdetection.h b/src/corelib/global/qcompilerdetection.h index fa8a529d0c..6958912e67 100644 --- a/src/corelib/global/qcompilerdetection.h +++ b/src/corelib/global/qcompilerdetection.h @@ -173,7 +173,11 @@ # else # define Q_CC_CLANG ((__clang_major__ * 100) + __clang_minor__) # endif -# define Q_ASSUME_IMPL(expr) if (expr){} else __builtin_unreachable() +# if __has_builtin(__builtin_assume) +# define Q_ASSUME_IMPL(expr) __builtin_assume(expr) +# else +# define Q_ASSUME_IMPL(expr) if (expr){} else __builtin_unreachable() +# endif # define Q_UNREACHABLE_IMPL() __builtin_unreachable() # if !defined(__has_extension) # /* Compatibility with older Clang versions */ diff --git a/src/corelib/io/qdebug.cpp b/src/corelib/io/qdebug.cpp index b0ee715c75..f55f68f9b3 100644 --- a/src/corelib/io/qdebug.cpp +++ b/src/corelib/io/qdebug.cpp @@ -40,6 +40,7 @@ #endif #include "qdebug.h" +#include "qmetaobject.h" #include <private/qtextstream_p.h> #include <private/qtools_p.h> @@ -284,12 +285,12 @@ void QDebug::putString(const QChar *begin, size_t length) if (stream->testFlag(Stream::NoQuotes)) { // no quotes, write the string directly too (no pretty-printing) // this respects the QTextStream state, though - stream->ts.d_ptr->putString(begin, length); + stream->ts.d_ptr->putString(begin, int(length)); } else { // we'll reset the QTextStream formatting mechanisms, so save the state QDebugStateSaver saver(*this); stream->ts.d_ptr->params.reset(); - putEscapedString(stream->ts.d_ptr.data(), reinterpret_cast<const ushort *>(begin), length); + putEscapedString(stream->ts.d_ptr.data(), reinterpret_cast<const ushort *>(begin), int(length)); } } @@ -302,14 +303,14 @@ void QDebug::putByteArray(const char *begin, size_t length, Latin1Content conten if (stream->testFlag(Stream::NoQuotes)) { // no quotes, write the string directly too (no pretty-printing) // this respects the QTextStream state, though - QString string = content == ContainsLatin1 ? QString::fromLatin1(begin, length) : QString::fromUtf8(begin, length); + QString string = content == ContainsLatin1 ? QString::fromLatin1(begin, int(length)) : QString::fromUtf8(begin, int(length)); stream->ts.d_ptr->putString(string); } else { // we'll reset the QTextStream formatting mechanisms, so save the state QDebugStateSaver saver(*this); stream->ts.d_ptr->params.reset(); putEscapedString(stream->ts.d_ptr.data(), reinterpret_cast<const uchar *>(begin), - length, content == ContainsLatin1); + int(length), content == ContainsLatin1); } } @@ -643,4 +644,23 @@ QDebugStateSaver::~QDebugStateSaver() d->restoreState(); } +#ifndef QT_NO_QOBJECT +/*! + \internal + */ +QDebug qt_QMetaEnum_debugOperator(QDebug &dbg, int value, const QMetaObject *meta, const char *name) +{ + QDebugStateSaver saver(dbg); + QMetaEnum me = meta->enumerator(meta->indexOfEnumerator(name)); + const char *key = me.valueToKey(value); + dbg.nospace() << meta->className() << "::" << name << '('; + if (key) + dbg << key; + else + dbg << value; + dbg << ')'; + return dbg; +} +#endif + QT_END_NAMESPACE diff --git a/src/corelib/io/qdebug.h b/src/corelib/io/qdebug.h index 56a5e1fa74..435e7450c7 100644 --- a/src/corelib/io/qdebug.h +++ b/src/corelib/io/qdebug.h @@ -261,6 +261,19 @@ inline QDebug operator<<(QDebug debug, const QContiguousCache<T> &cache) return debug.maybeSpace(); } +#ifndef QT_NO_QOBJECT +Q_CORE_EXPORT QDebug qt_QMetaEnum_debugOperator(QDebug&, int value, const QMetaObject *meta, const char *name); + +template<typename T> +typename QtPrivate::QEnableIf<QtPrivate::IsQEnumHelper<T>::Value, QDebug>::Type +operator<<(QDebug dbg, T value) +{ + const QMetaObject *obj = qt_getEnumMetaObject(value); + const char *name = qt_getEnumName(value); + return qt_QMetaEnum_debugOperator(dbg, typename QFlags<T>::Int(value), obj, name); +} +#endif + template <class T> inline QDebug operator<<(QDebug debug, const QFlags<T> &flags) { diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index 98e3f6b5bd..265cc68db5 100644 --- a/src/corelib/kernel/qobject.cpp +++ b/src/corelib/kernel/qobject.cpp @@ -4106,20 +4106,6 @@ QDebug operator<<(QDebug dbg, const QObject *o) dbg << ')'; return dbg; } - -QDebug qt_QMetaEnum_debugOperator(QDebug &dbg, int value, const QMetaObject *meta, const char *name) -{ - QDebugStateSaver saver(dbg); - QMetaEnum me = meta->enumerator(meta->indexOfEnumerator(name)); - const char *key = me.valueToKey(value); - dbg.nospace() << meta->className() << "::" << name << '('; - if (key) - dbg << key; - else - dbg << value; - dbg << ')'; - return dbg; -} #endif /*! diff --git a/src/corelib/kernel/qobject.h b/src/corelib/kernel/qobject.h index ae1c92f127..42d18d6c41 100644 --- a/src/corelib/kernel/qobject.h +++ b/src/corelib/kernel/qobject.h @@ -547,16 +547,6 @@ template <class T> inline const char * qobject_interface_iid() #ifndef QT_NO_DEBUG_STREAM Q_CORE_EXPORT QDebug operator<<(QDebug, const QObject *); -Q_CORE_EXPORT QDebug qt_QMetaEnum_debugOperator(QDebug&, int value, const QMetaObject *meta, const char *name); - -template<typename T> -typename QtPrivate::QEnableIf<QtPrivate::IsQEnumHelper<T>::Value , QDebug>::Type -operator<<(QDebug &dbg, T value) -{ - const QMetaObject *obj = qt_getEnumMetaObject(value); - const char *name = qt_getEnumName(value); - return qt_QMetaEnum_debugOperator(dbg, typename QFlags<T>::Int(value), obj, name); -} #endif class QSignalBlocker diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp index aa35d764fa..beda0f4919 100644 --- a/src/corelib/tools/qstring.cpp +++ b/src/corelib/tools/qstring.cpp @@ -240,7 +240,7 @@ void qt_from_latin1(ushort *dst, const char *str, size_t size) dst += offset; str += offset; # ifdef Q_COMPILER_LAMBDA - return UnrollTailLoop<15>::exec(size, [=](int i) { dst[i] = (uchar)str[i]; }); + return UnrollTailLoop<15>::exec(int(size), [=](int i) { dst[i] = (uchar)str[i]; }); # endif #endif #if defined(__mips_dsp) diff --git a/src/corelib/tools/qtools_p.h b/src/corelib/tools/qtools_p.h index b48ed94236..3a407aea5b 100644 --- a/src/corelib/tools/qtools_p.h +++ b/src/corelib/tools/qtools_p.h @@ -63,9 +63,9 @@ Q_DECL_CONSTEXPR inline char toHexLower(uint value) Q_DECL_NOTHROW Q_DECL_CONSTEXPR inline int fromHex(uint c) Q_DECL_NOTHROW { - return ((c >= '0') && (c <= '9')) ? c - '0' : - ((c >= 'A') && (c <= 'F')) ? c - 'A' + 10 : - ((c >= 'a') && (c <= 'f')) ? c - 'a' + 10 : + return ((c >= '0') && (c <= '9')) ? int(c - '0') : + ((c >= 'A') && (c <= 'F')) ? int(c - 'A' + 10) : + ((c >= 'a') && (c <= 'f')) ? int(c - 'a' + 10) : /* otherwise */ -1; } @@ -76,7 +76,7 @@ Q_DECL_CONSTEXPR inline char toOct(uint value) Q_DECL_NOTHROW Q_DECL_CONSTEXPR inline int fromOct(uint c) Q_DECL_NOTHROW { - return ((c >= '0') && (c <= '7')) ? c - '0' : -1; + return ((c >= '0') && (c <= '7')) ? int(c - '0') : -1; } } |