From 143c68436449203e83a3b2f49d9176d0e89d85a0 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 19 Jan 2016 07:45:13 -0800 Subject: Fix the use of R_X86_64_GOTPCREL on a 64-bit field: it should be 32-bit The ABI says that PC-relative displacements should be on 32-bit fields, even on 64-bit builds. For -mcmodel=large, it should use R_X86_64_GOT64 relocations, like 32-bit. Task-number: QTBUG-50537 Change-Id: I1041122c530b4f5bbaabffff142ade5b3cbfc4c5 Reviewed-by: Oswald Buddenhagen Reviewed-by: Olivier Goffart (Woboq GmbH) --- src/corelib/global/qversiontagging.h | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/global/qversiontagging.h b/src/corelib/global/qversiontagging.h index 4a1c01c89d..d6b4a65600 100644 --- a/src/corelib/global/qversiontagging.h +++ b/src/corelib/global/qversiontagging.h @@ -46,7 +46,7 @@ QT_BEGIN_NAMESPACE * qt_version_tag symbol that is present in QtCore. Such symbol is versioned, * so the linker will automatically pull the current Qt version and add it to * the ELF header of the library/application. The assembly produces one section - * called ".qtversion" containing two pointer-sized values. The first is a + * called ".qtversion" containing two 32-bit values. The first is a * relocation to the qt_version_tag symbol (which is what causes the ELF * version to get used). The second value is the current Qt version at the time * of compilation. @@ -58,10 +58,12 @@ QT_BEGIN_NAMESPACE // don't make tags in QtCore, bootstrapped systems or if the user asked not to #elif defined(Q_CC_GNU) && !defined(Q_OS_ANDROID) # if defined(Q_PROCESSOR_X86) && (defined(Q_OS_LINUX) || defined(Q_OS_FREEBSD_KERNEL)) -# ifdef __LP64__ -# define QT_VERSION_TAG_RELOC(sym) ".quad " QT_STRINGIFY(QT_MANGLE_NAMESPACE(sym)) "@GOTPCREL\n" -# elif defined(Q_PROCESSOR_X86_64) // x32 -# define QT_VERSION_TAG_RELOC(sym) ".long " QT_STRINGIFY(QT_MANGLE_NAMESPACE(sym)) "@GOTPCREL\n" +# if defined(Q_PROCESSOR_X86_64) // x86-64 or x32 +# if defined(__code_model_large__) +# define QT_VERSION_TAG_RELOC(sym) ".quad " QT_STRINGIFY(QT_MANGLE_NAMESPACE(sym)) "@GOT\n" +# else +# define QT_VERSION_TAG_RELOC(sym) ".long " QT_STRINGIFY(QT_MANGLE_NAMESPACE(sym)) "@GOTPCREL\n" +# endif # else // x86 # define QT_VERSION_TAG_RELOC(sym) ".long " QT_STRINGIFY(QT_MANGLE_NAMESPACE(sym)) "@GOT\n" # endif -- cgit v1.2.3 From f4502fbaf0d31d08bf08f1685f1d7b30735b72b4 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Wed, 20 Jan 2016 19:33:01 +0100 Subject: [docs] Fix reverse STL iteration example Use reverse_iterator, now that we finally have it. Change-Id: If74ead1a6075c5437c1d111206913481a495a014 Reviewed-by: Olivier Goffart (Woboq GmbH) --- src/corelib/doc/snippets/code/doc_src_containers.cpp | 7 +++---- src/corelib/doc/src/containers.qdoc | 4 +--- 2 files changed, 4 insertions(+), 7 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/doc/snippets/code/doc_src_containers.cpp b/src/corelib/doc/snippets/code/doc_src_containers.cpp index 395e48bc89..5b0d829367 100644 --- a/src/corelib/doc/snippets/code/doc_src_containers.cpp +++ b/src/corelib/doc/snippets/code/doc_src_containers.cpp @@ -156,10 +156,9 @@ for (i = list.begin(); i != list.end(); ++i) QList list; list << "A" << "B" << "C" << "D"; -QList::iterator i = list.end(); -while (i != list.begin()) { - --i; - *i = (*i).toLower(); +QList::reverse_iterator i; +for (i = list.rbegin(); i != list.rend(); ++i) + *i = i->toLower(); } //! [11] diff --git a/src/corelib/doc/src/containers.qdoc b/src/corelib/doc/src/containers.qdoc index 0ae3817ac7..988f728946 100644 --- a/src/corelib/doc/src/containers.qdoc +++ b/src/corelib/doc/src/containers.qdoc @@ -472,9 +472,7 @@ \image stliterators1.png - Iterating backward with an STL-style iterator requires us to - decrement the iterator \e before we access the item. This - requires a \c while loop: + Iterating backward with an STL-style iterator is done with reverse iterators: \snippet code/doc_src_containers.cpp 11 -- cgit v1.2.3 From f05c597ae506ea6163394dbb6b70ecc77fae3b3c Mon Sep 17 00:00:00 2001 From: Maurice Kalinowski Date: Fri, 11 Dec 2015 13:42:28 +0100 Subject: winrt: msvc2015: refactor file handling msvc2015 reintroduced a couple of functions from the win32 API towards WinRT. Enable usage of those and simplify the file system engine. Furthermore update the autotests. Change-Id: I9eafffba0ddfd05917c184c4a6b9e166f86d71d9 Reviewed-by: Oliver Wolff --- src/corelib/io/qdir.cpp | 11 ++++++++++ src/corelib/io/qfileinfo.cpp | 2 +- src/corelib/io/qfilesystemengine_win.cpp | 33 ++++++++++++++++++++++-------- src/corelib/io/qfilesystementry.cpp | 10 +++++++++ src/corelib/io/qfilesystemiterator_win.cpp | 3 ++- src/corelib/io/qfsfileengine_win.cpp | 2 +- 6 files changed, 49 insertions(+), 12 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/io/qdir.cpp b/src/corelib/io/qdir.cpp index 4d2b36632f..2c2bdd579e 100644 --- a/src/corelib/io/qdir.cpp +++ b/src/corelib/io/qdir.cpp @@ -152,7 +152,11 @@ inline void QDirPrivate::setPath(const QString &path) if (p.endsWith(QLatin1Char('/')) && p.length() > 1 #if defined(Q_OS_WIN) +# if defined (Q_OS_WINRT) + && (!(p.toLower() == QDir::rootPath().toLower())) +# else && (!(p.length() == 3 && p.at(1).unicode() == ':' && p.at(0).isLetter())) +# endif #endif ) { p.truncate(p.length() - 1); @@ -885,6 +889,9 @@ bool QDir::cd(const QString &dirName) #if defined (Q_OS_UNIX) //After cleanPath() if path is "/.." or starts with "/../" it means trying to cd above root. if (newPath.startsWith(QLatin1String("/../")) || newPath == QLatin1String("/..")) +#elif defined (Q_OS_WINRT) + const QString rootPath = QDir::rootPath(); + if (newPath.size() < rootPath.size() && rootPath.startsWith(newPath)) #else /* cleanPath() already took care of replacing '\' with '/'. @@ -2187,7 +2194,11 @@ QString QDir::cleanPath(const QString &path) // Strip away last slash except for root directories if (ret.length() > 1 && ret.endsWith(QLatin1Char('/'))) { #if defined (Q_OS_WIN) +# if defined(Q_OS_WINRT) + if (!((ret.length() == 3 || ret.length() == QDir::rootPath().length()) && ret.at(1) == QLatin1Char(':'))) +# else if (!(ret.length() == 3 && ret.at(1) == QLatin1Char(':'))) +# endif #endif ret.chop(1); } diff --git a/src/corelib/io/qfileinfo.cpp b/src/corelib/io/qfileinfo.cpp index 51b39b1114..dd194594c9 100644 --- a/src/corelib/io/qfileinfo.cpp +++ b/src/corelib/io/qfileinfo.cpp @@ -1095,7 +1095,7 @@ bool QFileInfo::isRoot() const return true; if (d->fileEngine == 0) { if (d->fileEntry.isRoot()) { -#if defined(Q_OS_WIN) +#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT) //the path is a drive root, but the drive may not exist //for backward compatibility, return true only if the drive exists if (!d->cache_enabled || !d->metaData.hasFlags(QFileSystemMetaData::ExistsAttribute)) diff --git a/src/corelib/io/qfilesystemengine_win.cpp b/src/corelib/io/qfilesystemengine_win.cpp index 379095a83d..f1a6019094 100644 --- a/src/corelib/io/qfilesystemengine_win.cpp +++ b/src/corelib/io/qfilesystemengine_win.cpp @@ -78,6 +78,11 @@ using namespace Microsoft::WRL::Wrappers; using namespace ABI::Windows::Foundation; using namespace ABI::Windows::Storage; using namespace ABI::Windows::ApplicationModel; + +#if _MSC_VER < 1900 +#define Q_OS_WINRT_WIN81 +#endif + #endif // Q_OS_WINRT #ifndef SPI_GETPLATFORMTYPE @@ -522,7 +527,7 @@ QString QFileSystemEngine::nativeAbsoluteFilePath(const QString &path) { // can be //server or //server/share QString absPath; -#if !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT) +#if !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT_WIN81) QVarLengthArray buf(qMax(MAX_PATH, path.size() + 1)); wchar_t *fileName = 0; DWORD retLen = GetFullPathName((wchar_t*)path.utf16(), buf.size(), buf.data(), &fileName); @@ -532,6 +537,16 @@ QString QFileSystemEngine::nativeAbsoluteFilePath(const QString &path) } if (retLen != 0) absPath = QString::fromWCharArray(buf.data(), retLen); +# if defined(Q_OS_WINRT) + // Win32 returns eg C:/ as root directory with a trailing /. + // WinRT returns the sandbox root without /. + // Also C:/../.. returns C:/ on Win32, while for WinRT it steps outside the package + // and goes beyond package root. Hence force the engine to stay inside + // the package. + const QString rootPath = QDir::toNativeSeparators(QDir::rootPath()); + if (absPath.size() < rootPath.size() && rootPath.startsWith(absPath)) + absPath = rootPath; +# endif // Q_OS_WINRT #elif !defined(Q_OS_WINCE) if (QDir::isRelativePath(path)) absPath = QDir::toNativeSeparators(QDir::cleanPath(QDir::currentPath() + QLatin1Char('/') + path)); @@ -569,7 +584,7 @@ QFileSystemEntry QFileSystemEngine::absoluteName(const QFileSystemEntry &entry) ret = entry.filePath(); #endif } else { -#ifndef Q_OS_WINRT +#ifndef Q_OS_WINRT_WIN81 ret = QDir::cleanPath(QDir::currentPath() + QLatin1Char('/') + entry.filePath()); #else // Some WinRT APIs do not support absolute paths (due to sandboxing). @@ -1218,8 +1233,8 @@ QString QFileSystemEngine::rootPath() if (FAILED(item->get_Path(finalWinPath.GetAddressOf()))) return ret; - ret = QDir::fromNativeSeparators(QString::fromWCharArray(finalWinPath.GetRawBuffer(nullptr))); - + const QString qtWinPath = QDir::fromNativeSeparators(QString::fromWCharArray(finalWinPath.GetRawBuffer(nullptr))); + ret = qtWinPath.endsWith(QLatin1Char('/')) ? qtWinPath : qtWinPath + QLatin1Char('/'); #else QString ret = QString::fromLatin1(qgetenv("SystemDrive")); if (ret.isEmpty()) @@ -1337,7 +1352,7 @@ bool QFileSystemEngine::setCurrentPath(const QFileSystemEntry &entry) if(!(meta.exists() && meta.isDirectory())) return false; -#if !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT) +#if !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT_WIN81) //TODO: this should really be using nativeFilePath(), but that returns a path in long format \\?\c:\foo //which causes many problems later on when it's returned through currentPath() return ::SetCurrentDirectory(reinterpret_cast(QDir::toNativeSeparators(entry.filePath()).utf16())) != 0; @@ -1350,7 +1365,7 @@ bool QFileSystemEngine::setCurrentPath(const QFileSystemEntry &entry) QFileSystemEntry QFileSystemEngine::currentPath() { QString ret; -#if !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT) +#if !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT_WIN81) DWORD size = 0; wchar_t currentName[PATH_MAX]; size = ::GetCurrentDirectory(PATH_MAX, currentName); @@ -1366,17 +1381,17 @@ QFileSystemEntry QFileSystemEngine::currentPath() } if (ret.length() >= 2 && ret[1] == QLatin1Char(':')) ret[0] = ret.at(0).toUpper(); // Force uppercase drive letters. -#else // !Q_OS_WINCE && !Q_OS_WINRT +#else // !Q_OS_WINCE && !Q_OS_WINRT_WIN81 //TODO - a race condition exists when using currentPath / setCurrentPath from multiple threads if (qfsPrivateCurrentDir.isEmpty()) -#ifndef Q_OS_WINRT +#ifndef Q_OS_WINRT_WIN81 qfsPrivateCurrentDir = QCoreApplication::applicationDirPath(); #else qfsPrivateCurrentDir = QDir::rootPath(); #endif ret = qfsPrivateCurrentDir; -#endif // Q_OS_WINCE || Q_OS_WINRT +#endif // Q_OS_WINCE || Q_OS_WINRT_WIN81 return QFileSystemEntry(ret, QFileSystemEntry::FromNativePath()); } diff --git a/src/corelib/io/qfilesystementry.cpp b/src/corelib/io/qfilesystementry.cpp index 709970e3ac..c590d81f7a 100644 --- a/src/corelib/io/qfilesystementry.cpp +++ b/src/corelib/io/qfilesystementry.cpp @@ -166,6 +166,12 @@ void QFileSystemEntry::resolveNativeFilePath() const m_nativeFilePath.remove(0,1); if (m_nativeFilePath.isEmpty()) m_nativeFilePath.append(QLatin1Char('.')); + // WinRT/MSVC2015 allows a maximum of 256 characters for a filepath + // unless //?/ is prepended which extends the rule to have a maximum + // of 256 characters in the filename plus the preprending path +#if _MSC_VER >= 1900 + m_nativeFilePath.prepend("\\\\?\\"); +#endif #endif } } @@ -283,9 +289,13 @@ bool QFileSystemEntry::isAbsolute() const bool QFileSystemEntry::isDriveRoot() const { resolveFilePath(); +#ifndef Q_OS_WINRT return (m_filePath.length() == 3 && m_filePath.at(0).isLetter() && m_filePath.at(1) == QLatin1Char(':') && m_filePath.at(2) == QLatin1Char('/')); +#else // !Q_OS_WINRT + return m_filePath == QDir::rootPath(); +#endif // !Q_OS_WINRT } #endif diff --git a/src/corelib/io/qfilesystemiterator_win.cpp b/src/corelib/io/qfilesystemiterator_win.cpp index 6351a3559d..d7fed87222 100644 --- a/src/corelib/io/qfilesystemiterator_win.cpp +++ b/src/corelib/io/qfilesystemiterator_win.cpp @@ -67,7 +67,8 @@ QFileSystemIterator::QFileSystemIterator(const QFileSystemEntry &entry, QDir::Fi if (!nativePath.endsWith(QLatin1Char('\\'))) nativePath.append(QLatin1Char('\\')); nativePath.append(QLatin1Char('*')); -#ifdef Q_OS_WINRT + // In MSVC2015+ case we prepend //?/ for longer file-name support +#if defined(Q_OS_WINRT) && _MSC_VER < 1900 if (nativePath.startsWith(QLatin1Char('\\'))) nativePath.remove(0, 1); #endif diff --git a/src/corelib/io/qfsfileengine_win.cpp b/src/corelib/io/qfsfileengine_win.cpp index cfd50955a6..886d526fb1 100644 --- a/src/corelib/io/qfsfileengine_win.cpp +++ b/src/corelib/io/qfsfileengine_win.cpp @@ -1037,7 +1037,7 @@ uchar *QFSFileEnginePrivate::map(qint64 offset, qint64 size, offsetHi, offsetLo, size + extra); #else LPVOID mapAddress = ::MapViewOfFileFromApp(mapHandle, access, - (ULONG64(offsetHi) << 32) + offsetLo, size); + (ULONG64(offsetHi) << 32) + offsetLo, size + extra); #endif if (mapAddress) { uchar *address = extra + static_cast(mapAddress); -- cgit v1.2.3 From 1185c28f2f408d858c148062bb0125974905ef22 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Mon, 18 Jan 2016 12:40:41 +0100 Subject: Fix some mis-guided fall-throughs #ifdef QT_BOOTSTRAPPED. A switch had a case whose body was in a #ifndef; when that got elided, this case fell through into an entirely misguided case. Give the #if a #else clause so that it break;s in the defined case. Code review revealed another, then I searched for more following the same pattern. Change-Id: I57fb59b6c8d349604f3fc6c8b1d424fb3c775d50 Reviewed-by: Thiago Macieira --- src/corelib/tools/qdatetime.cpp | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/tools/qdatetime.cpp b/src/corelib/tools/qdatetime.cpp index ff20c57166..491ed99301 100644 --- a/src/corelib/tools/qdatetime.cpp +++ b/src/corelib/tools/qdatetime.cpp @@ -2697,10 +2697,11 @@ qint64 QDateTimePrivate::toMSecsSinceEpoch() const } case Qt::TimeZone: -#ifndef QT_BOOTSTRAPPED +#ifdef QT_BOOTSTRAPPED + break; +#else return zoneMSecsToEpochMSecs(m_msecs, m_timeZone); #endif - break; } Q_UNREACHABLE(); return 0; @@ -3197,7 +3198,9 @@ QString QDateTime::timeZoneAbbreviation() const case Qt::OffsetFromUTC: return QTimeZonePrivate::utcQString() + toOffsetString(Qt::ISODate, d->m_offsetFromUtc); case Qt::TimeZone: -#ifndef QT_BOOTSTRAPPED +#ifdef QT_BOOTSTRAPPED + break; +#else return d->m_timeZone.d->abbreviation(d->toMSecsSinceEpoch()); #endif // QT_BOOTSTRAPPED case Qt::LocalTime: { @@ -3228,7 +3231,9 @@ bool QDateTime::isDaylightTime() const case Qt::OffsetFromUTC: return false; case Qt::TimeZone: -#ifndef QT_BOOTSTRAPPED +#ifdef QT_BOOTSTRAPPED + break; +#else return d->m_timeZone.d->isDaylightTime(toMSecsSinceEpoch()); #endif // QT_BOOTSTRAPPED case Qt::LocalTime: { @@ -4820,10 +4825,8 @@ QDataStream &operator<<(QDataStream &out, const QDateTime &dateTime) out << (qint8)QDateTimePrivate::OffsetFromUTC; break; case Qt::TimeZone: -#ifndef QT_BOOTSTRAPPED out << (qint8)QDateTimePrivate::TimeZone; break; -#endif // QT_BOOTSTRAPPED case Qt::LocalTime: out << (qint8)QDateTimePrivate::LocalUnknown; break; @@ -4896,10 +4899,11 @@ QDataStream &operator>>(QDataStream &in, QDateTime &dateTime) spec = Qt::OffsetFromUTC; break; case QDateTimePrivate::TimeZone: -#ifndef QT_BOOTSTRAPPED spec = Qt::TimeZone; +#ifndef QT_BOOTSTRAPPED + // FIXME: need to use a different constructor ! +#endif break; -#endif // QT_BOOTSTRAPPED case QDateTimePrivate::LocalUnknown: case QDateTimePrivate::LocalStandard: case QDateTimePrivate::LocalDST: @@ -4955,8 +4959,8 @@ QDebug operator<<(QDebug dbg, const QDateTime &date) case Qt::TimeZone: #ifndef QT_BOOTSTRAPPED dbg << ' ' << date.timeZone().id(); - break; #endif // QT_BOOTSTRAPPED + break; case Qt::LocalTime: break; } -- cgit v1.2.3 From c3850dd636ab24c251942fde63f22d8f5b3a639e Mon Sep 17 00:00:00 2001 From: Konstantin Ritt Date: Tue, 24 Nov 2015 10:23:23 +0400 Subject: QString: optimize case conversion code Handle special case mapping of length 1 explicitly; Skip calculating of high surrogate for the same plane; Optimize branch prediction with Q_LIKELY/Q_UNLIKELY; Replace peekNext() + advance() with just next() in the caller function. Change-Id: I0d37969749bd8ca855321242e6a0e72c405c5f8d Reviewed-by: Thiago Macieira --- src/corelib/tools/qstring.cpp | 54 ++++++++++++++++++++++++------------------- 1 file changed, 30 insertions(+), 24 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp index 89d9889b2f..39ec66c7f1 100644 --- a/src/corelib/tools/qstring.cpp +++ b/src/corelib/tools/qstring.cpp @@ -5709,37 +5709,42 @@ static QString detachAndConvertCase(T &str, QStringIterator it) Q_ASSERT(!str.isEmpty()); QString s = qMove(str); // will copy if T is const QString QChar *pp = s.begin() + it.index(); // will detach if necessary - uint uc = it.nextUnchecked(); - forever { + + do { + uint uc = it.nextUnchecked(); + const QUnicodeTables::Properties *prop = qGetProp(uc); signed short caseDiff = Traits::caseDiff(prop); if (Q_UNLIKELY(Traits::caseSpecial(prop))) { - // slow path: the string is growing const ushort *specialCase = specialCaseMap + caseDiff; ushort length = *specialCase++; - int inpos = it.index() - 1; - int outpos = pp - s.constBegin(); - - s.replace(outpos, 1, reinterpret_cast(specialCase), length); - pp = const_cast(s.constBegin()) + outpos + length; - - // do we need to adjust the input iterator too? - // if it is pointing to s's data, str is empty - if (str.isEmpty()) - it = QStringIterator(s.constBegin(), inpos + length, s.constEnd()); - } else if (QChar::requiresSurrogates(uc)) { - *pp++ = QChar::highSurrogate(uc + caseDiff); + + if (Q_LIKELY(length == 1)) { + *pp++ = QChar(*specialCase); + } else { + // slow path: the string is growing + int inpos = it.index() - 1; + int outpos = pp - s.constBegin(); + + s.replace(outpos, 1, reinterpret_cast(specialCase), length); + pp = const_cast(s.constBegin()) + outpos + length; + + // do we need to adjust the input iterator too? + // if it is pointing to s's data, str is empty + if (str.isEmpty()) + it = QStringIterator(s.constBegin(), inpos + length, s.constEnd()); + } + } else if (Q_UNLIKELY(QChar::requiresSurrogates(uc))) { + // so far, case convertion never changes planes (guaranteed by the qunicodetables generator) + pp++; *pp++ = QChar::lowSurrogate(uc + caseDiff); } else { *pp++ = QChar(uc + caseDiff); } + } while (it.hasNext()); - if (!it.hasNext()) - return s; - - uc = it.nextUnchecked(); - } + return s; } template @@ -5752,12 +5757,13 @@ static QString convertCase(T &str) while (e != p && e[-1].isHighSurrogate()) --e; - const QUnicodeTables::Properties *prop; QStringIterator it(p, e); - for ( ; it.hasNext(); it.advanceUnchecked()) { - prop = qGetProp(it.peekNextUnchecked()); - if (Traits::caseDiff(prop)) + while (it.hasNext()) { + uint uc = it.nextUnchecked(); + if (Traits::caseDiff(qGetProp(uc))) { + it.recedeUnchecked(); return detachAndConvertCase(str, it); + } } return qMove(str); } -- cgit v1.2.3 From 684e5587d5024ff9523d76141d0befd1201dc24f Mon Sep 17 00:00:00 2001 From: Rafael Roquetto Date: Mon, 18 Jan 2016 15:37:11 -0200 Subject: QNX: Fix -developer-build -developer-build enables -Werror=undef, which uncovered a bug inside qcompilerdetection.h. According to the Dinkum headers, it is necessary to account for three different states concerning the values of the _HAS_* macros: 1. undefined 2. 0 3. 1 Therefore, it is necessary to check both whether it is defined and if it is not 0. Only checking whether a given macro is 0 will generate a trap by -Werror=undef. (__GLIBCXX__ is the sole exception). Change-Id: Ib95e485698ee38858a1671d930d7e960b75bb041 Reviewed-by: James McDonnell Reviewed-by: Dan Cape Reviewed-by: Thiago Macieira --- src/corelib/global/qcompilerdetection.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/global/qcompilerdetection.h b/src/corelib/global/qcompilerdetection.h index ba830977ad..b11237dce5 100644 --- a/src/corelib/global/qcompilerdetection.h +++ b/src/corelib/global/qcompilerdetection.h @@ -931,8 +931,8 @@ // Older versions (QNX 650) do not support C++11 features // _HAS_* macros are set to 1 by toolchains that actually include // Dinkum C++11 libcpp. -# if !__GLIBCXX__ -# if !_HAS_CPP0X +# if !defined(__GLIBCXX__) +# if !defined(_HAS_CPP0X) || !_HAS_CPP0X // Disable C++11 features that depend on library support # undef Q_COMPILER_INITIALIZER_LISTS # undef Q_COMPILER_RVALUE_REFS @@ -940,10 +940,10 @@ # undef Q_COMPILER_UNICODE_STRINGS # undef Q_COMPILER_NOEXCEPT # endif // !_HAS_CPP0X -# if !_HAS_NULLPTR_T +# if !defined(_HAS_NULLPTR_T) || !_HAS_NULLPTR_T # undef Q_COMPILER_NULLPTR # endif //!_HAS_NULLPTR_T -# if !_HAS_CONSTEXPR +# if !defined(_HAS_CONSTEXPR) || !_HAS_CONSTEXPR // The libcpp is missing constexpr keywords on important functions like std::numeric_limits<>::min() // Disable constexpr support on QNX even if the compiler supports it # undef Q_COMPILER_CONSTEXPR -- cgit v1.2.3 From 2fed43d8438b3fb751230aa2a8115de92789ccf3 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Sat, 23 Jan 2016 02:04:48 +0100 Subject: Q*Application: don't allocate memory just to compare C strings Instead of creating a QByteArray, possibly normalizing a leading '--' (one allocation, plus possibly one copy), simply use the old 'ol str(n)cmp, skipping the first character if the argument starts with '--'. It also fixes parsing of -stylesheet and other options which were erroneously parsed using indexOf() != -1, when they should have used startsWith(). Also saves 504/742/522b in text size for QtCore/QtGui/QtWidgets, resp., on optimized GCC 5.3 Linux AMD64 builds. Change-Id: Ida868badac3fb9b77285417ee537c861ccc4fc06 Reviewed-by: Thiago Macieira --- src/corelib/kernel/qcoreapplication.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp index abc5af94cb..48d70f2747 100644 --- a/src/corelib/kernel/qcoreapplication.cpp +++ b/src/corelib/kernel/qcoreapplication.cpp @@ -182,16 +182,18 @@ void QCoreApplicationPrivate::processCommandLineArguments() { int j = argc ? 1 : 0; for (int i = 1; i < argc; ++i) { - if (argv[i] && *argv[i] != '-') { + if (!argv[i]) + continue; + if (*argv[i] != '-') { argv[j++] = argv[i]; continue; } - QByteArray arg = argv[i]; - if (arg.startsWith("--")) - arg.remove(0, 1); - if (arg.startsWith("-qmljsdebugger=")) { - qmljs_debug_arguments = QString::fromLocal8Bit(arg.right(arg.length() - 15)); - } else if (arg == "-qmljsdebugger" && i < argc - 1) { + const char *arg = argv[i]; + if (arg[1] == '-') // startsWith("--") + ++arg; + if (strncmp(arg, "-qmljsdebugger=", 15) == 0) { + qmljs_debug_arguments = QString::fromLocal8Bit(arg + 15); + } else if (strcmp(arg, "-qmljsdebugger") == 0 && i < argc - 1) { ++i; qmljs_debug_arguments = QString::fromLocal8Bit(argv[i]); } else { -- cgit v1.2.3