aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Stenger <christian.stenger@qt.io>2020-07-22 14:54:08 +0200
committerChristian Stenger <christian.stenger@qt.io>2020-07-23 14:47:26 +0000
commit36caa1f292ddfd45b877d331e6d68f813563d259 (patch)
tree28b703a7c0beb14466ebc1e2682d3f76837aadbe
parent7401a6bc4e53d920fd7ced3249c735fd232d191c (diff)
Replace QRegExp by QRegularExpression
Change-Id: I6c86565b8464efd0b7aec61c12879d3b95a5871c Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
-rw-r--r--src/app/qbs-create-project/createproject.cpp8
-rw-r--r--src/app/qbs-create-project/createproject.h6
-rw-r--r--src/app/qbs/status.cpp36
-rw-r--r--src/lib/corelib/api/project.cpp4
-rw-r--r--src/lib/corelib/language/language.cpp6
-rw-r--r--src/lib/corelib/language/language.h6
-rw-r--r--src/lib/corelib/language/projectresolver.cpp10
-rw-r--r--src/lib/corelib/tools/codelocation.cpp6
-rw-r--r--src/lib/corelib/tools/fileinfo.cpp13
-rw-r--r--src/lib/corelib/tools/fileinfo.h1
-rw-r--r--src/lib/corelib/tools/jsliterals.cpp4
-rw-r--r--src/lib/corelib/tools/persistence.cpp2
-rw-r--r--src/lib/corelib/tools/persistence.h14
-rw-r--r--src/lib/corelib/tools/shellutils.cpp8
-rw-r--r--src/lib/corelib/tools/version.cpp15
-rw-r--r--tests/auto/blackbox/tst_blackbox.cpp36
-rw-r--r--tests/auto/blackbox/tst_clangdb.cpp8
-rw-r--r--tests/auto/cmdlineparser/tst_cmdlineparser.cpp1
-rw-r--r--tests/auto/language/tst_language.cpp3
19 files changed, 97 insertions, 90 deletions
diff --git a/src/app/qbs-create-project/createproject.cpp b/src/app/qbs-create-project/createproject.cpp
index 26147b484..20338be98 100644
--- a/src/app/qbs-create-project/createproject.cpp
+++ b/src/app/qbs-create-project/createproject.cpp
@@ -62,9 +62,9 @@ void ProjectCreator::run(const QString &topLevelDir, ProjectStructure projectStr
{
m_projectStructure = projectStructure;
for (const QString &s : whiteList)
- m_whiteList.push_back(QRegExp(s, Qt::CaseSensitive, QRegExp::Wildcard));
+ m_whiteList.push_back(QRegularExpression(QRegularExpression::wildcardToRegularExpression(s)));
for (const QString &s : blackList)
- m_blackList.push_back(QRegExp(s, Qt::CaseSensitive, QRegExp::Wildcard));
+ m_blackList.push_back(QRegularExpression(QRegularExpression::wildcardToRegularExpression(s)));
m_topLevelProject.dirPath = topLevelDir;
setupProject(&m_topLevelProject);
serializeProject(m_topLevelProject);
@@ -162,7 +162,9 @@ void ProjectCreator::addGroups(QTextStream &stream, const QDir &baseDir,
bool ProjectCreator::isSourceFile(const QString &fileName)
{
- const auto isMatch = [fileName](const QRegExp &rex) { return rex.exactMatch(fileName); };
+ const auto isMatch = [fileName](const QRegularExpression &rex) {
+ return rex.match(fileName).hasMatch();
+ };
return !std::any_of(m_blackList.cbegin(), m_blackList.cend(), isMatch)
&& (m_whiteList.empty()
|| std::any_of(m_whiteList.cbegin(), m_whiteList.cend(), isMatch));
diff --git a/src/app/qbs-create-project/createproject.h b/src/app/qbs-create-project/createproject.h
index efc217b68..ac7d53e1a 100644
--- a/src/app/qbs-create-project/createproject.h
+++ b/src/app/qbs-create-project/createproject.h
@@ -42,7 +42,7 @@
#include <QtCore/qflags.h>
#include <QtCore/qhash.h>
-#include <QtCore/qregexp.h>
+#include <QtCore/qregularexpression.h>
#include <QtCore/qstringlist.h>
#include <memory>
@@ -83,8 +83,8 @@ private:
};
Project m_topLevelProject;
ProjectStructure m_projectStructure = ProjectStructure::Flat;
- QList<QRegExp> m_whiteList;
- QList<QRegExp> m_blackList;
+ QList<QRegularExpression> m_whiteList;
+ QList<QRegularExpression> m_blackList;
};
#endif // QBS_CREATEPROJECT_H
diff --git a/src/app/qbs/status.cpp b/src/app/qbs/status.cpp
index 01d3451fe..a5e0c8228 100644
--- a/src/app/qbs/status.cpp
+++ b/src/app/qbs/status.cpp
@@ -47,20 +47,20 @@
#include <QtCore/qdir.h>
#include <QtCore/qfile.h>
#include <QtCore/qfileinfo.h>
+#include <QtCore/qregularexpression.h>
#include <QtCore/qstring.h>
-#include <QtCore/qregexp.h>
namespace qbs {
-static QList<QRegExp> createIgnoreList(const QString &projectRootPath)
+static QList<QRegularExpression> createIgnoreList(const QString &projectRootPath)
{
- QList<QRegExp> ignoreRegularExpressionList {
- QRegExp(projectRootPath + QLatin1String("/build.*")),
- QRegExp(QStringLiteral("*.qbs"), Qt::CaseSensitive, QRegExp::Wildcard),
- QRegExp(QStringLiteral("*.pro"), Qt::CaseSensitive, QRegExp::Wildcard),
- QRegExp(QStringLiteral("*Makefile"), Qt::CaseSensitive, QRegExp::Wildcard),
- QRegExp(QStringLiteral("*.so*"), Qt::CaseSensitive, QRegExp::Wildcard),
- QRegExp(QStringLiteral("*.o"), Qt::CaseSensitive, QRegExp::Wildcard)
+ QList<QRegularExpression> ignoreRegularExpressionList {
+ QRegularExpression(QRegularExpression::anchoredPattern(projectRootPath + QLatin1String("/build.*"))),
+ QRegularExpression(QRegularExpression::wildcardToRegularExpression(QStringLiteral("*.qbs"))),
+ QRegularExpression(QRegularExpression::wildcardToRegularExpression(QStringLiteral("*.pro"))),
+ QRegularExpression(QRegularExpression::wildcardToRegularExpression(QStringLiteral("*Makefile"))),
+ QRegularExpression(QRegularExpression::wildcardToRegularExpression(QStringLiteral("*.so*"))),
+ QRegularExpression(QRegularExpression::wildcardToRegularExpression(QStringLiteral("*.o")))
};
QString ignoreFilePath = projectRootPath + QLatin1String("/.qbsignore");
@@ -71,11 +71,12 @@ static QList<QRegExp> createIgnoreList(const QString &projectRootPath)
for (const QByteArray &btoken : ignoreTokenList) {
const QString token = QString::fromLatin1(btoken);
if (token.startsWith(QLatin1String("/")))
- ignoreRegularExpressionList.push_back(QRegExp(projectRootPath
- + token + QLatin1String(".*"),
- Qt::CaseSensitive, QRegExp::RegExp2));
+ ignoreRegularExpressionList.push_back(
+ QRegularExpression(QRegularExpression::anchoredPattern(
+ projectRootPath + token + QLatin1String(".*"))));
else if (!token.isEmpty())
- ignoreRegularExpressionList.push_back(QRegExp(token, Qt::CaseSensitive, QRegExp::RegExp2));
+ ignoreRegularExpressionList.push_back(
+ QRegularExpression(QRegularExpression::anchoredPattern(token)));
}
}
@@ -83,7 +84,8 @@ static QList<QRegExp> createIgnoreList(const QString &projectRootPath)
return ignoreRegularExpressionList;
}
-static QStringList allFilesInDirectoryRecursive(const QDir &rootDirecory, const QList<QRegExp> &ignoreRegularExpressionList)
+static QStringList allFilesInDirectoryRecursive(
+ const QDir &rootDirecory, const QList<QRegularExpression> &ignoreRegularExpressionList)
{
QStringList fileList;
@@ -91,8 +93,8 @@ static QStringList allFilesInDirectoryRecursive(const QDir &rootDirecory, const
for (const QFileInfo &fileInfo : fileInfos) {
QString absoluteFilePath = fileInfo.absoluteFilePath();
bool inIgnoreList = false;
- for (const QRegExp &ignoreRegularExpression : ignoreRegularExpressionList) {
- if (ignoreRegularExpression.exactMatch(absoluteFilePath)) {
+ for (const QRegularExpression &ignoreRegularExpression : ignoreRegularExpressionList) {
+ if (ignoreRegularExpression.match(absoluteFilePath).hasMatch()) {
inIgnoreList = true;
break;
}
@@ -112,7 +114,7 @@ static QStringList allFilesInDirectoryRecursive(const QDir &rootDirecory, const
static QStringList allFilesInProject(const QString &projectRootPath)
{
- QList<QRegExp> ignoreRegularExpressionList = createIgnoreList(projectRootPath);
+ QList<QRegularExpression> ignoreRegularExpressionList = createIgnoreList(projectRootPath);
return allFilesInDirectoryRecursive(QDir(projectRootPath), ignoreRegularExpressionList);
}
diff --git a/src/lib/corelib/api/project.cpp b/src/lib/corelib/api/project.cpp
index f7a9eca09..e6caf1b2b 100644
--- a/src/lib/corelib/api/project.cpp
+++ b/src/lib/corelib/api/project.cpp
@@ -82,7 +82,7 @@
#include <tools/qttools.h>
#include <QtCore/qdir.h>
-#include <QtCore/qregexp.h>
+#include <QtCore/qregularexpression.h>
#include <QtCore/qshareddata.h>
#include <mutex>
@@ -414,7 +414,7 @@ static bool matchesWildcard(const QString &filePath, const GroupConstPtr &group)
}
fullPattern.append(QLatin1Char('/')).append(pattern);
fullPattern = QDir::cleanPath(fullPattern);
- if (QRegExp(fullPattern, Qt::CaseSensitive, QRegExp::Wildcard).exactMatch(filePath))
+ if (QRegularExpression(QRegularExpression::wildcardToRegularExpression(fullPattern)).match(filePath).hasMatch())
return true;
}
return false;
diff --git a/src/lib/corelib/language/language.cpp b/src/lib/corelib/language/language.cpp
index 7b21bc12a..0b472a668 100644
--- a/src/lib/corelib/language/language.cpp
+++ b/src/lib/corelib/language/language.cpp
@@ -102,7 +102,7 @@ void FileTagger::setPatterns(const QStringList &patterns)
m_patterns.clear();
for (const QString &pattern : patterns) {
QBS_CHECK(!pattern.isEmpty());
- m_patterns << QRegExp(pattern, Qt::CaseSensitive, QRegExp::Wildcard);
+ m_patterns << QRegularExpression(QRegularExpression::wildcardToRegularExpression(pattern));
}
}
@@ -347,8 +347,8 @@ FileTags ResolvedProduct::fileTagsForFileName(const QString &fileName) const
FileTags result;
std::unique_ptr<int> priority;
for (const FileTaggerConstPtr &tagger : qAsConst(fileTaggers)) {
- for (const QRegExp &pattern : tagger->patterns()) {
- if (FileInfo::globMatches(pattern, fileName)) {
+ for (const QRegularExpression &pattern : tagger->patterns()) {
+ if (pattern.match(fileName).hasMatch()) {
if (priority) {
if (*priority != tagger->priority()) {
// The taggers are expected to be sorted by priority.
diff --git a/src/lib/corelib/language/language.h b/src/lib/corelib/language/language.h
index bbd851333..23a5f1d1a 100644
--- a/src/lib/corelib/language/language.h
+++ b/src/lib/corelib/language/language.h
@@ -58,7 +58,7 @@
#include <QtCore/qdatastream.h>
#include <QtCore/qhash.h>
#include <QtCore/qprocess.h>
-#include <QtCore/qregexp.h>
+#include <QtCore/qregularexpression.h>
#include <QtCore/qstring.h>
#include <QtCore/qstringlist.h>
#include <QtCore/qvariant.h>
@@ -88,7 +88,7 @@ public:
return FileTaggerPtr(new FileTagger(patterns, fileTags, priority));
}
- const QList<QRegExp> &patterns() const { return m_patterns; }
+ const QList<QRegularExpression> &patterns() const { return m_patterns; }
const FileTags &fileTags() const { return m_fileTags; }
int priority() const { return m_priority; }
@@ -103,7 +103,7 @@ private:
void setPatterns(const QStringList &patterns);
- QList<QRegExp> m_patterns;
+ QList<QRegularExpression> m_patterns;
FileTags m_fileTags;
int m_priority = 0;
};
diff --git a/src/lib/corelib/language/projectresolver.cpp b/src/lib/corelib/language/projectresolver.cpp
index fd6063381..4e8e94b4e 100644
--- a/src/lib/corelib/language/projectresolver.cpp
+++ b/src/lib/corelib/language/projectresolver.cpp
@@ -68,7 +68,7 @@
#include <tools/stringconstants.h>
#include <QtCore/qdir.h>
-#include <QtCore/qregexp.h>
+#include <QtCore/qregularexpression.h>
#include <algorithm>
#include <memory>
@@ -1052,12 +1052,12 @@ void ProjectResolver::setupExportedProperties(const Item *item, const QString &n
std::sort(properties.begin(), properties.end(), less);
}
-static bool usesImport(const ExportedProperty &prop, const QRegExp &regex)
+static bool usesImport(const ExportedProperty &prop, const QRegularExpression &regex)
{
- return regex.indexIn(prop.sourceCode) != -1;
+ return prop.sourceCode.indexOf(regex) != -1;
}
-static bool usesImport(const ExportedItem &item, const QRegExp &regex)
+static bool usesImport(const ExportedItem &item, const QRegularExpression &regex)
{
return any_of(item.properties,
[regex](const ExportedProperty &p) { return usesImport(p, regex); })
@@ -1073,7 +1073,7 @@ static bool usesImport(const ExportedModule &module, const QString &name)
// (3) var obj = DataCollection;
const QString pattern = QStringLiteral("\\b%1\\b");
- const QRegExp regex(pattern.arg(name)); // std::regex is much slower
+ const QRegularExpression regex(pattern.arg(name)); // std::regex is much slower
return any_of(module.m_properties,
[regex](const ExportedProperty &p) { return usesImport(p, regex); })
|| any_of(module.children,
diff --git a/src/lib/corelib/tools/codelocation.cpp b/src/lib/corelib/tools/codelocation.cpp
index 542408795..ebfd5edc6 100644
--- a/src/lib/corelib/tools/codelocation.cpp
+++ b/src/lib/corelib/tools/codelocation.cpp
@@ -47,7 +47,7 @@
#include <QtCore/qdir.h>
#include <QtCore/qjsonobject.h>
#include <QtCore/qjsonvalue.h>
-#include <QtCore/qregexp.h>
+#include <QtCore/qregularexpression.h>
#include <QtCore/qshareddata.h>
#include <QtCore/qstring.h>
@@ -118,9 +118,9 @@ QString CodeLocation::toString() const
if (isValid()) {
str = QDir::toNativeSeparators(filePath());
QString lineAndColumn;
- if (line() > 0 && !str.contains(QRegExp(QStringLiteral(":[0-9]+$"))))
+ if (line() > 0 && !str.contains(QRegularExpression(QStringLiteral(":[0-9]+$"))))
lineAndColumn += QLatin1Char(':') + QString::number(line());
- if (column() > 0 && !str.contains(QRegExp(QStringLiteral(":[0-9]+:[0-9]+$"))))
+ if (column() > 0 && !str.contains(QRegularExpression(QStringLiteral(":[0-9]+:[0-9]+$"))))
lineAndColumn += QLatin1Char(':') + QString::number(column());
str += lineAndColumn;
}
diff --git a/src/lib/corelib/tools/fileinfo.cpp b/src/lib/corelib/tools/fileinfo.cpp
index 8f6b285d4..6fdd90fb1 100644
--- a/src/lib/corelib/tools/fileinfo.cpp
+++ b/src/lib/corelib/tools/fileinfo.cpp
@@ -47,7 +47,7 @@
#include <QtCore/qdatetime.h>
#include <QtCore/qdir.h>
#include <QtCore/qfileinfo.h>
-#include <QtCore/qregexp.h>
+#include <QtCore/qregularexpression.h>
#if defined(Q_OS_UNIX)
#include <cerrno>
@@ -242,17 +242,6 @@ QString FileInfo::resolvePath(const QString &base, const QString &rel, HostOsInf
return r;
}
-bool FileInfo::globMatches(const QRegExp &regexp, const QString &fileName)
-{
- const QString pattern = regexp.pattern();
- // May be it's simple wildcard, i.e. "*.cpp"?
- if (pattern.startsWith(QLatin1Char('*')) && !isPattern(pattern.midRef(1))) {
- // Yes, it's rather simple to just check the extension
- return fileName.endsWith(pattern.midRef(1));
- }
- return regexp.exactMatch(fileName);
-}
-
#ifdef Q_OS_WIN
static QString prependLongPathPrefix(const QString &absolutePath)
{
diff --git a/src/lib/corelib/tools/fileinfo.h b/src/lib/corelib/tools/fileinfo.h
index 9813b69a7..c4ca5931a 100644
--- a/src/lib/corelib/tools/fileinfo.h
+++ b/src/lib/corelib/tools/fileinfo.h
@@ -79,7 +79,6 @@ public:
static bool isPattern(const QString &str);
static QString resolvePath(const QString &base, const QString &rel,
HostOsInfo::HostOs hostOs = HostOsInfo::hostOs());
- static bool globMatches(const QRegExp &pattern, const QString &subject);
static bool isFileCaseCorrect(const QString &filePath);
// Symlink-correct check.
diff --git a/src/lib/corelib/tools/jsliterals.cpp b/src/lib/corelib/tools/jsliterals.cpp
index 74328006c..69d170336 100644
--- a/src/lib/corelib/tools/jsliterals.cpp
+++ b/src/lib/corelib/tools/jsliterals.cpp
@@ -41,7 +41,7 @@
#include <tools/stringconstants.h>
-#include <QtCore/qregexp.h>
+#include <QtCore/qregularexpression.h>
namespace qbs {
@@ -53,7 +53,7 @@ QString toJSLiteral(const bool b)
QString toJSLiteral(const QString &str)
{
QString js = str;
- js.replace(QRegExp(QLatin1String("([\\\\\"])")), QLatin1String("\\\\1"));
+ js.replace(QRegularExpression(QLatin1String("([\\\\\"])")), QLatin1String("\\\\1"));
js.prepend(QLatin1Char('"'));
js.append(QLatin1Char('"'));
return js;
diff --git a/src/lib/corelib/tools/persistence.cpp b/src/lib/corelib/tools/persistence.cpp
index 3f2b57e01..18145eafb 100644
--- a/src/lib/corelib/tools/persistence.cpp
+++ b/src/lib/corelib/tools/persistence.cpp
@@ -48,7 +48,7 @@
namespace qbs {
namespace Internal {
-static const char QBS_PERSISTENCE_MAGIC[] = "QBSPERSISTENCE-128";
+static const char QBS_PERSISTENCE_MAGIC[] = "QBSPERSISTENCE-129";
NoBuildGraphError::NoBuildGraphError(const QString &filePath)
: ErrorInfo(Tr::tr("Build graph not found for configuration '%1'. Expected location was '%2'.")
diff --git a/src/lib/corelib/tools/persistence.h b/src/lib/corelib/tools/persistence.h
index e00310321..f97604b42 100644
--- a/src/lib/corelib/tools/persistence.h
+++ b/src/lib/corelib/tools/persistence.h
@@ -48,7 +48,7 @@
#include <QtCore/qdatastream.h>
#include <QtCore/qflags.h>
#include <QtCore/qprocess.h>
-#include <QtCore/qregexp.h>
+#include <QtCore/qregularexpression.h>
#include <QtCore/qstring.h>
#include <QtCore/qvariant.h>
@@ -426,10 +426,16 @@ template<> struct PPHelper<QVariant>
static void load(QVariant &v, PersistentPool *pool) { v = pool->loadVariant(); }
};
-template<> struct PPHelper<QRegExp>
+template<> struct PPHelper<QRegularExpression>
{
- static void store(const QRegExp &re, PersistentPool *pool) { pool->store(re.pattern()); }
- static void load(QRegExp &re, PersistentPool *pool) { re.setPattern(pool->load<QString>()); }
+ static void store(const QRegularExpression &re, PersistentPool *pool)
+ {
+ pool->store(re.pattern());
+ }
+ static void load(QRegularExpression &re, PersistentPool *pool)
+ {
+ re.setPattern(pool->load<QString>());
+ }
};
template<typename T, typename U> struct PPHelper<std::pair<T, U>>
diff --git a/src/lib/corelib/tools/shellutils.cpp b/src/lib/corelib/tools/shellutils.cpp
index 33ab2c76c..d032aecac 100644
--- a/src/lib/corelib/tools/shellutils.cpp
+++ b/src/lib/corelib/tools/shellutils.cpp
@@ -44,7 +44,7 @@
#include "qttools.h"
#include <QtCore/qfile.h>
-#include <QtCore/qregexp.h>
+#include <QtCore/qregularexpression.h>
#include <QtCore/qtextstream.h>
namespace qbs {
@@ -56,7 +56,7 @@ QString shellInterpreter(const QString &filePath) {
QTextStream ts(&file);
const QString shebang = ts.readLine();
if (shebang.startsWith(QLatin1String("#!"))) {
- return (shebang.mid(2).split(QRegExp(QStringLiteral("\\s")),
+ return (shebang.mid(2).split(QRegularExpression(QStringLiteral("\\s")),
QBS_SKIP_EMPTY_PARTS) << QString()).front();
}
}
@@ -125,9 +125,9 @@ static QString shellQuoteWin(const QString &arg)
// The process-level standard quoting allows escaping quotes with backslashes (note
// that backslashes don't escape themselves, unless they are followed by a quote).
// Consequently, quotes are escaped and their preceding backslashes are doubled.
- ret.replace(QRegExp(QLatin1String("(\\\\*)\"")), QLatin1String("\\1\\1\\\""));
+ ret.replace(QRegularExpression(QLatin1String("(\\\\*)\"")), QLatin1String("\\1\\1\\\""));
// Trailing backslashes must be doubled as well, as they are followed by a quote.
- ret.replace(QRegExp(QLatin1String("(\\\\+)$")), QLatin1String("\\1\\1"));
+ ret.replace(QRegularExpression(QLatin1String("(\\\\+)$")), QLatin1String("\\1\\1"));
// However, the shell also interprets the command, and no backslash-escaping exists
// there - a quote always toggles the quoting state, but is nonetheless passed down
// to the called process verbatim. In the unquoted state, the circumflex escapes
diff --git a/src/lib/corelib/tools/version.cpp b/src/lib/corelib/tools/version.cpp
index f653256b3..719bc386f 100644
--- a/src/lib/corelib/tools/version.cpp
+++ b/src/lib/corelib/tools/version.cpp
@@ -39,7 +39,7 @@
#include "version.h"
-#include <QtCore/qregexp.h>
+#include <QtCore/qregularexpression.h>
#include <QtCore/qstring.h>
namespace qbs {
@@ -51,13 +51,14 @@ Version Version::fromString(const QString &versionString, bool buildNumberAllowe
pattern += QStringLiteral("(?:\\.(\\d+))?"); // Followed by a dot and a number up to two times.
if (buildNumberAllowed)
pattern += QStringLiteral("(?:[-.](\\d+))?"); // And possibly a dash or dot followed by the build number.
- QRegExp rex(pattern);
- if (!rex.exactMatch(versionString))
+ const QRegularExpression rex(QRegularExpression::anchoredPattern(pattern));
+ const QRegularExpressionMatch match = rex.match(versionString);
+ if (!match.hasMatch())
return Version{};
- const int majorNr = rex.cap(1).toInt();
- const int minorNr = rex.captureCount() >= 2 ? rex.cap(2).toInt() : 0;
- const int patchNr = rex.captureCount() >= 3 ? rex.cap(3).toInt() : 0;
- const int buildNr = rex.captureCount() >= 4 ? rex.cap(4).toInt() : 0;
+ const int majorNr = match.captured(1).toInt();
+ const int minorNr = match.lastCapturedIndex() >= 2 ? match.captured(2).toInt() : 0;
+ const int patchNr = match.lastCapturedIndex() >= 3 ? match.captured(3).toInt() : 0;
+ const int buildNr = match.lastCapturedIndex() >= 4 ? match.captured(4).toInt() : 0;
return Version{majorNr, minorNr, patchNr, buildNr};
}
diff --git a/tests/auto/blackbox/tst_blackbox.cpp b/tests/auto/blackbox/tst_blackbox.cpp
index b0d9c2976..c6e8b9731 100644
--- a/tests/auto/blackbox/tst_blackbox.cpp
+++ b/tests/auto/blackbox/tst_blackbox.cpp
@@ -49,7 +49,7 @@
#include <QtCore/qjsonobject.h>
#include <QtCore/qjsonvalue.h>
#include <QtCore/qlocale.h>
-#include <QtCore/qregexp.h>
+#include <QtCore/qregularexpression.h>
#include <QtCore/qsettings.h>
#include <QtCore/qtemporarydir.h>
#include <QtCore/qtemporaryfile.h>
@@ -298,7 +298,7 @@ void TestBlackbox::textTemplate()
static QStringList sortedFileList(const QByteArray &ba)
{
- auto list = QString::fromUtf8(ba).split(QRegExp("[\r\n]"), QBS_SKIP_EMPTY_PARTS);
+ auto list = QString::fromUtf8(ba).split(QRegularExpression("[\r\n]"), QBS_SKIP_EMPTY_PARTS);
std::sort(list.begin(), list.end());
return list;
}
@@ -1072,10 +1072,12 @@ void TestBlackbox::discardUnusedData()
QVERIFY2(m_qbsStdout.contains("is Darwin"), m_qbsStdout.constData());
const bool isDarwin = m_qbsStdout.contains("is Darwin: true");
const QString output = QString::fromLocal8Bit(m_qbsStdout);
- QRegExp pattern(".*---(.*)---.*");
- QVERIFY2(pattern.exactMatch(output), qPrintable(output));
- QCOMPARE(pattern.captureCount(), 1);
- const QString nmPath = pattern.capturedTexts().at(1);
+ const QRegularExpression pattern(QRegularExpression::anchoredPattern(".*---(.*)---.*"),
+ QRegularExpression::DotMatchesEverythingOption);
+ const QRegularExpressionMatch match = pattern.match(output);
+ QVERIFY2(match.hasMatch(), qPrintable(output));
+ QCOMPARE(match.lastCapturedIndex(), 1);
+ const QString nmPath = match.captured(1);
if (!QFile::exists(nmPath))
QSKIP("Cannot check for symbol presence: No nm found.");
QProcess nm;
@@ -1466,10 +1468,12 @@ void TestBlackbox::versionScript()
QCOMPARE(runQbs(QbsRunParameters(QStringList("-q")
<< ("qbs.installRoot:" + QDir::currentPath()))), 0);
const QString output = QString::fromLocal8Bit(m_qbsStderr);
- QRegExp pattern(".*---(.*)---.*");
- QVERIFY2(pattern.exactMatch(output), qPrintable(output));
+ const QRegularExpression pattern(QRegularExpression::anchoredPattern(".*---(.*)---.*"),
+ QRegularExpression::DotMatchesEverythingOption);
+ const QRegularExpressionMatch match = pattern.match(output);
+ QVERIFY2(match.hasMatch(), qPrintable(output));
QCOMPARE(pattern.captureCount(), 1);
- const QString nmPath = pattern.capturedTexts().at(1);
+ const QString nmPath = match.captured(1);
if (!QFile::exists(nmPath))
QSKIP("Cannot check for symbol presence: No nm found.");
QProcess nm;
@@ -3656,7 +3660,7 @@ void TestBlackbox::erroneousFiles()
params.expectFailure = true;
QVERIFY(runQbs(params) != 0);
QString err = QString::fromLocal8Bit(m_qbsStderr);
- if (!err.contains(QRegExp(errorMessage))) {
+ if (!err.contains(QRegularExpression(errorMessage))) {
qDebug().noquote() << "Output: " << err;
qDebug().noquote() << "Expected: " << errorMessage;
QFAIL("Unexpected error message.");
@@ -4932,10 +4936,12 @@ void TestBlackbox::linkerScripts()
QCOMPARE(runQbs(runParams), 0);
const QString output = QString::fromLocal8Bit(m_qbsStderr);
- QRegExp pattern(".*---(.*)---.*");
- QVERIFY2(pattern.exactMatch(output), qPrintable(output));
+ const QRegularExpression pattern(QRegularExpression::anchoredPattern(".*---(.*)---.*"),
+ QRegularExpression::DotMatchesEverythingOption);
+ const QRegularExpressionMatch match = pattern.match(output);
+ QVERIFY2(match.hasMatch(), qPrintable(output));
QCOMPARE(pattern.captureCount(), 1);
- const QString nmPath = pattern.capturedTexts().at(1);
+ const QString nmPath = match.captured(1);
if (!QFile::exists(nmPath))
QSKIP("Cannot check for symbol presence: No nm found.");
@@ -8030,8 +8036,8 @@ void TestBlackbox::badInterpreter()
QbsRunParameters params("run");
params.expectFailure = true;
- const QRegExp reNoSuchFileOrDir("bad interpreter:.* No such file or directory");
- const QRegExp rePermissionDenied("bad interpreter:.* Permission denied");
+ const QRegularExpression reNoSuchFileOrDir("bad interpreter:.* No such file or directory");
+ const QRegularExpression rePermissionDenied("bad interpreter:.* Permission denied");
params.arguments = QStringList() << "-p" << "script-interp-missing";
QCOMPARE(runQbs(params), 1);
diff --git a/tests/auto/blackbox/tst_clangdb.cpp b/tests/auto/blackbox/tst_clangdb.cpp
index 65e562484..c4216ac13 100644
--- a/tests/auto/blackbox/tst_clangdb.cpp
+++ b/tests/auto/blackbox/tst_clangdb.cpp
@@ -36,7 +36,7 @@
#include <QtCore/qdir.h>
#include <QtCore/qfile.h>
-#include <QtCore/qregexp.h>
+#include <QtCore/qregularexpression.h>
#include <QtCore/qjsonarray.h>
#include <QtCore/qjsondocument.h>
@@ -211,8 +211,10 @@ void TestClangDb::checkClangDetectsSourceCodeProblems()
arguments << "-analyze" << "-p" << relativeBuildDir() << sourceFilePath;
QVERIFY(runProcess(executable, arguments, stdErr, stdOut) == 0);
const QString output = QString::fromLocal8Bit(stdErr);
- QVERIFY(output.contains(QRegExp(QStringLiteral("warning.*undefined"), Qt::CaseInsensitive)));
- QVERIFY(output.contains(QRegExp(QStringLiteral("warning.*never read"), Qt::CaseInsensitive)));
+ QVERIFY(output.contains(QRegularExpression(QStringLiteral("warning.*undefined"),
+ QRegularExpression::CaseInsensitiveOption)));
+ QVERIFY(output.contains(QRegularExpression(QStringLiteral("warning.*never read"),
+ QRegularExpression::CaseInsensitiveOption)));
}
QTEST_MAIN(TestClangDb)
diff --git a/tests/auto/cmdlineparser/tst_cmdlineparser.cpp b/tests/auto/cmdlineparser/tst_cmdlineparser.cpp
index 15b9ec382..f617d41c7 100644
--- a/tests/auto/cmdlineparser/tst_cmdlineparser.cpp
+++ b/tests/auto/cmdlineparser/tst_cmdlineparser.cpp
@@ -33,7 +33,6 @@
#include <tools/hostosinfo.h>
#include <QtCore/qdir.h>
-#include <QtCore/qregexp.h>
#include <QtCore/qtemporaryfile.h>
#include <QtTest/qtest.h>
diff --git a/tests/auto/language/tst_language.cpp b/tests/auto/language/tst_language.cpp
index d34069821..78e867fbf 100644
--- a/tests/auto/language/tst_language.cpp
+++ b/tests/auto/language/tst_language.cpp
@@ -955,7 +955,8 @@ void TestLanguage::erroneousFiles()
defaultParameters.setProjectFilePath(testProject("/erroneous/") + fileName);
loader->loadProject(defaultParameters);
} catch (const ErrorInfo &e) {
- if (!e.toString().contains(QRegExp(errorMessage))) {
+ const QRegularExpression reg(errorMessage, QRegularExpression::DotMatchesEverythingOption);
+ if (!e.toString().contains(reg)) {
qDebug() << "Message: " << e.toString();
qDebug() << "Expected: " << errorMessage;
QFAIL("Unexpected error message.");