aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/plugins/autotest/qtest/qttestoutputreader.cpp2
-rw-r--r--src/plugins/baremetal/debugservers/uvsc/uvscserverprovider.cpp2
-rw-r--r--src/plugins/baremetal/iarewparser.cpp8
-rw-r--r--src/plugins/baremetal/keilparser.cpp14
-rw-r--r--src/plugins/bazaar/bazaarclient.cpp4
-rw-r--r--src/plugins/bazaar/bazaarcommitwidget.cpp3
-rw-r--r--src/plugins/beautifier/artisticstyle/artisticstyle.cpp3
-rw-r--r--src/plugins/clangcodemodel/clangdclient.cpp2
-rw-r--r--src/plugins/clearcase/clearcaseplugin.cpp13
-rw-r--r--src/plugins/clearcase/clearcasesync.cpp5
-rw-r--r--src/plugins/clearcase/versionselector.cpp6
-rw-r--r--src/plugins/cmakeprojectmanager/cmakeautocompleter.cpp3
-rw-r--r--src/plugins/cmakeprojectmanager/cmakeprojectmanager.cpp2
-rw-r--r--src/plugins/compilationdatabaseprojectmanager/compilationdatabaseutils.cpp7
-rw-r--r--src/plugins/coreplugin/dialogs/externaltoolconfig.cpp3
-rw-r--r--src/plugins/coreplugin/documentmanager.cpp2
-rw-r--r--src/plugins/cpaster/pastebindotcomprotocol.cpp10
-rw-r--r--src/plugins/cppeditor/compileroptionsbuilder.cpp3
-rw-r--r--src/plugins/cppeditor/cpptoolsreuse.cpp3
-rw-r--r--src/plugins/cppeditor/doxygengenerator.cpp5
-rw-r--r--src/plugins/cppeditor/quickfixes/bringidentifierintoscope.cpp4
-rw-r--r--src/plugins/cppeditor/quickfixes/convertnumericliteral.cpp2
-rw-r--r--src/plugins/cppeditor/quickfixes/insertfunctiondefinition.cpp2
-rw-r--r--src/plugins/cvs/cvsutils.cpp4
-rw-r--r--src/plugins/debugger/cdb/cdbengine.cpp6
-rw-r--r--src/plugins/debugger/gdb/gdbengine.cpp6
-rw-r--r--src/plugins/debugger/lldb/lldbengine.cpp6
-rw-r--r--src/plugins/debugger/peripheralregisterhandler.cpp8
-rw-r--r--src/plugins/debugger/qml/qmlinspectoragent.cpp2
-rw-r--r--src/plugins/debugger/simplifytype.cpp6
-rw-r--r--src/plugins/debugger/watchhandler.cpp2
-rw-r--r--src/plugins/diffeditor/diffutils.cpp11
-rw-r--r--src/plugins/fakevim/fakevimhandler.cpp45
-rw-r--r--src/plugins/fossil/fossilclient.cpp8
-rw-r--r--src/plugins/fossil/fossilplugin.cpp3
-rw-r--r--src/plugins/git/gerrit/gerritserver.cpp2
-rw-r--r--src/plugins/git/giteditor.cpp2
-rw-r--r--src/plugins/help/searchwidget.cpp3
-rw-r--r--src/plugins/incredibuild/cmakecommandbuilder.cpp2
-rw-r--r--src/plugins/incredibuild/makecommandbuilder.cpp4
-rw-r--r--src/plugins/ios/iosrunner.cpp6
-rw-r--r--src/plugins/languageclient/languageclientcompletionassist.cpp2
-rw-r--r--src/plugins/lua/bindings/translate.cpp4
-rw-r--r--src/plugins/lua/luaengine.cpp3
44 files changed, 138 insertions, 105 deletions
diff --git a/src/plugins/autotest/qtest/qttestoutputreader.cpp b/src/plugins/autotest/qtest/qttestoutputreader.cpp
index 99693357a05..2208e53075b 100644
--- a/src/plugins/autotest/qtest/qttestoutputreader.cpp
+++ b/src/plugins/autotest/qtest/qttestoutputreader.cpp
@@ -316,7 +316,7 @@ static QStringList extractFunctionInformation(const QString &testClassName,
const QString &lineWithoutResultType,
ResultType resultType)
{
- static QRegularExpression classInformation("^(.+?)\\((.*?)\\)(.*)$");
+ static const QRegularExpression classInformation("^(.+?)\\((.*?)\\)(.*)$");
QStringList result;
const QRegularExpressionMatch match = classInformation.match(lineWithoutResultType);
if (match.hasMatch()) {
diff --git a/src/plugins/baremetal/debugservers/uvsc/uvscserverprovider.cpp b/src/plugins/baremetal/debugservers/uvsc/uvscserverprovider.cpp
index 33e1196623d..0ae7e91c52f 100644
--- a/src/plugins/baremetal/debugservers/uvsc/uvscserverprovider.cpp
+++ b/src/plugins/baremetal/debugservers/uvsc/uvscserverprovider.cpp
@@ -242,7 +242,7 @@ public:
explicit HexValueValidator(QObject *parent = nullptr)
: QRegularExpressionValidator(parent)
{
- const QRegularExpression re("^0x[0-9a-fA-F]{1,8}");
+ static const QRegularExpression re("^0x[0-9a-fA-F]{1,8}");
setRegularExpression(re);
}
};
diff --git a/src/plugins/baremetal/iarewparser.cpp b/src/plugins/baremetal/iarewparser.cpp
index 286cb0e1686..0cc4117d012 100644
--- a/src/plugins/baremetal/iarewparser.cpp
+++ b/src/plugins/baremetal/iarewparser.cpp
@@ -56,7 +56,7 @@ void IarParser::amendFilePath()
bool IarParser::parseErrorOrFatalErrorDetailsMessage1(const QString &lne)
{
- const QRegularExpression re("^(Error|Fatal error)\\[(.+)\\]:\\s(.+)\\s\\[(.+)$");
+ static const QRegularExpression re("^(Error|Fatal error)\\[(.+)\\]:\\s(.+)\\s\\[(.+)$");
const QRegularExpressionMatch match = re.match(lne);
if (!match.hasMatch())
return false;
@@ -79,7 +79,7 @@ bool IarParser::parseErrorOrFatalErrorDetailsMessage1(const QString &lne)
bool IarParser::parseErrorOrFatalErrorDetailsMessage2(const QString &lne)
{
- const QRegularExpression re("^.*(Error|Fatal error)\\[(.+)\\]:\\s(.+)$");
+ static const QRegularExpression re("^.*(Error|Fatal error)\\[(.+)\\]:\\s(.+)$");
const QRegularExpressionMatch match = re.match(lne);
if (!match.hasMatch())
return false;
@@ -99,7 +99,7 @@ bool IarParser::parseErrorOrFatalErrorDetailsMessage2(const QString &lne)
OutputLineParser::Result IarParser::parseWarningOrErrorOrFatalErrorDetailsMessage1(const QString &lne)
{
- const QRegularExpression re("^\"(.+)\",(\\d+)?\\s+(Warning|Error|Fatal error)\\[(.+)\\].+$");
+ static const QRegularExpression re("^\"(.+)\",(\\d+)?\\s+(Warning|Error|Fatal error)\\[(.+)\\].+$");
const QRegularExpressionMatch match = re.match(lne);
if (!match.hasMatch())
return Status::NotHandled;
@@ -132,7 +132,7 @@ bool IarParser::parseErrorInCommandLineMessage(const QString &lne)
bool IarParser::parseErrorMessage1(const QString &lne)
{
- const QRegularExpression re("^(Error)\\[(.+)\\]:\\s(.+)$");
+ static const QRegularExpression re("^(Error)\\[(.+)\\]:\\s(.+)$");
const QRegularExpressionMatch match = re.match(lne);
if (!match.hasMatch())
return false;
diff --git a/src/plugins/baremetal/keilparser.cpp b/src/plugins/baremetal/keilparser.cpp
index 64bf64e46fd..5a5df91ccc7 100644
--- a/src/plugins/baremetal/keilparser.cpp
+++ b/src/plugins/baremetal/keilparser.cpp
@@ -49,7 +49,7 @@ void KeilParser::newTask(const Task &task)
OutputLineParser::Result KeilParser::parseArmWarningOrErrorDetailsMessage(const QString &lne)
{
- const QRegularExpression re("^\"(.+)\", line (\\d+).*:\\s+(Warning|Error):(\\s+|.+)([#|L].+)$");
+ static const QRegularExpression re("^\"(.+)\", line (\\d+).*:\\s+(Warning|Error):(\\s+|.+)([#|L].+)$");
const QRegularExpressionMatch match = re.match(lne);
if (!match.hasMatch())
return Status::NotHandled;
@@ -69,7 +69,7 @@ OutputLineParser::Result KeilParser::parseArmWarningOrErrorDetailsMessage(const
bool KeilParser::parseArmErrorOrFatalErorrMessage(const QString &lne)
{
- const QRegularExpression re("^(Error|Fatal error):\\s(.+)$");
+ static const QRegularExpression re("^(Error|Fatal error):\\s(.+)$");
const QRegularExpressionMatch match = re.match(lne);
if (!match.hasMatch())
return false;
@@ -84,7 +84,7 @@ bool KeilParser::parseArmErrorOrFatalErorrMessage(const QString &lne)
OutputLineParser::Result KeilParser::parseMcs51WarningOrErrorDetailsMessage1(const QString &lne)
{
- const QRegularExpression re("^\\*{3} (WARNING|ERROR) (\\w+) IN LINE (\\d+) OF (.+\\.\\S+): (.+)$");
+ static const QRegularExpression re("^\\*{3} (WARNING|ERROR) (\\w+) IN LINE (\\d+) OF (.+\\.\\S+): (.+)$");
const QRegularExpressionMatch match = re.match(lne);
if (!match.hasMatch())
return Status::NotHandled;
@@ -105,7 +105,7 @@ OutputLineParser::Result KeilParser::parseMcs51WarningOrErrorDetailsMessage1(con
OutputLineParser::Result KeilParser::parseMcs51WarningOrErrorDetailsMessage2(const QString &lne)
{
- const QRegularExpression re("^\\*{3} (WARNING|ERROR) (#\\w+) IN (\\d+) \\((.+), LINE \\d+\\): (.+)$");
+ static const QRegularExpression re("^\\*{3} (WARNING|ERROR) (#\\w+) IN (\\d+) \\((.+), LINE \\d+\\): (.+)$");
const QRegularExpressionMatch match = re.match(lne);
if (!match.hasMatch())
return Status::NotHandled;
@@ -126,7 +126,7 @@ OutputLineParser::Result KeilParser::parseMcs51WarningOrErrorDetailsMessage2(con
bool KeilParser::parseMcs51WarningOrFatalErrorMessage(const QString &lne)
{
- const QRegularExpression re("^\\*{3} (WARNING|FATAL ERROR) (.+)$");
+ static const QRegularExpression re("^\\*{3} (WARNING|FATAL ERROR) (.+)$");
const QRegularExpressionMatch match = re.match(lne);
if (!match.hasMatch())
return false;
@@ -139,7 +139,7 @@ bool KeilParser::parseMcs51WarningOrFatalErrorMessage(const QString &lne)
bool KeilParser::parseMcs51FatalErrorMessage2(const QString &lne)
{
- const QRegularExpression re("^(A|C)51 FATAL[ |-]ERROR");
+ static const QRegularExpression re("^(A|C)51 FATAL[ |-]ERROR");
const QRegularExpressionMatch match = re.match(lne);
if (!match.hasMatch())
return false;
@@ -155,7 +155,7 @@ bool KeilParser::parseMcs51FatalErrorMessage2(const QString &lne)
static bool hasDetailsEntry(const QString &trimmedLine)
{
- const QRegularExpression re("^([0-9A-F]{4})");
+ static const QRegularExpression re("^([0-9A-F]{4})");
const QRegularExpressionMatch match = re.match(trimmedLine);
return match.hasMatch();
}
diff --git a/src/plugins/bazaar/bazaarclient.cpp b/src/plugins/bazaar/bazaarclient.cpp
index 03e882279fb..77005d410b3 100644
--- a/src/plugins/bazaar/bazaarclient.cpp
+++ b/src/plugins/bazaar/bazaarclient.cpp
@@ -95,8 +95,8 @@ BranchInfo BazaarClient::synchronousBranchQuery(const FilePath &repositoryRoot)
QTextStream ts(&branchConfFile);
QString branchLocation;
QString isBranchBound;
- QRegularExpression branchLocationRx("bound_location\\s*=\\s*(.+)$");
- QRegularExpression isBranchBoundRx("bound\\s*=\\s*(.+)$");
+ static const QRegularExpression branchLocationRx("bound_location\\s*=\\s*(.+)$");
+ static const QRegularExpression isBranchBoundRx("bound\\s*=\\s*(.+)$");
while (!ts.atEnd() && (branchLocation.isEmpty() || isBranchBound.isEmpty())) {
const QString line = ts.readLine();
QRegularExpressionMatch match = branchLocationRx.match(line);
diff --git a/src/plugins/bazaar/bazaarcommitwidget.cpp b/src/plugins/bazaar/bazaarcommitwidget.cpp
index 465395e0aef..d0535806651 100644
--- a/src/plugins/bazaar/bazaarcommitwidget.cpp
+++ b/src/plugins/bazaar/bazaarcommitwidget.cpp
@@ -172,7 +172,8 @@ QString BazaarCommitWidget::committer() const
QStringList BazaarCommitWidget::fixedBugs() const
{
- return m_bazaarCommitPanel->fixedBugsLineEdit->text().split(QRegularExpression("\\s+"));
+ static const QRegularExpression regexp("\\s+");
+ return m_bazaarCommitPanel->fixedBugsLineEdit->text().split(regexp);
}
bool BazaarCommitWidget::isLocalOptionEnabled() const
diff --git a/src/plugins/beautifier/artisticstyle/artisticstyle.cpp b/src/plugins/beautifier/artisticstyle/artisticstyle.cpp
index ca8d089410b..af6e28dccd6 100644
--- a/src/plugins/beautifier/artisticstyle/artisticstyle.cpp
+++ b/src/plugins/beautifier/artisticstyle/artisticstyle.cpp
@@ -140,8 +140,9 @@ public:
for (const QString &key : std::as_const(keys))
stream.writeTextElement(Constants::DOCUMENTATION_XMLKEY, key);
stream.writeEndElement();
+ static const QRegularExpression regexp("^\\-");
const QString text = "<p><span class=\"option\">"
- + keys.filter(QRegularExpression("^\\-")).join(", ") + "</span></p><p>"
+ + keys.filter(regexp).join(", ") + "</span></p><p>"
+ (docu.join(' ').toHtmlEscaped()) + "</p>";
stream.writeTextElement(Constants::DOCUMENTATION_XMLDOC, text);
stream.writeEndElement();
diff --git a/src/plugins/clangcodemodel/clangdclient.cpp b/src/plugins/clangcodemodel/clangdclient.cpp
index 1b3cf54f0e0..ecad1dfb167 100644
--- a/src/plugins/clangcodemodel/clangdclient.cpp
+++ b/src/plugins/clangcodemodel/clangdclient.cpp
@@ -799,7 +799,7 @@ QVersionNumber ClangdClient::versionNumber() const
if (d->versionNumber)
return d->versionNumber.value();
- const QRegularExpression versionPattern("^clangd version (\\d+)\\.(\\d+)\\.(\\d+).*$");
+ static const QRegularExpression versionPattern("^clangd version (\\d+)\\.(\\d+)\\.(\\d+).*$");
QTC_CHECK(versionPattern.isValid());
const QRegularExpressionMatch match = versionPattern.match(serverVersion());
if (match.isValid()) {
diff --git a/src/plugins/clearcase/clearcaseplugin.cpp b/src/plugins/clearcase/clearcaseplugin.cpp
index cd9ec09482a..97261aafded 100644
--- a/src/plugins/clearcase/clearcaseplugin.cpp
+++ b/src/plugins/clearcase/clearcaseplugin.cpp
@@ -434,7 +434,8 @@ FileStatus::Status ClearCasePluginPrivate::getFileStatus(const FilePath &fileNam
return FileStatus::Derived;
// find first whitespace. anything before that is not interesting
- const int wspos = buffer.indexOf(QRegularExpression("\\s"));
+ static const QRegularExpression regexp("\\s");
+ const int wspos = buffer.indexOf(regexp);
if (buffer.lastIndexOf(QLatin1String("CHECKEDOUT"), wspos) != -1)
return FileStatus::CheckedOut;
else
@@ -1281,7 +1282,8 @@ void ClearCasePluginPrivate::diffActivity()
// pre-first version. only for the first occurrence
if (filever[file].first.isEmpty()) {
- int verpos = shortver.lastIndexOf(QRegularExpression("[^0-9]")) + 1;
+ static const QRegularExpression regexp("[^0-9]");
+ int verpos = shortver.lastIndexOf(regexp) + 1;
int vernum = shortver.mid(verpos).toInt();
if (vernum)
--vernum;
@@ -1839,7 +1841,7 @@ bool ClearCasePluginPrivate::vcsCheckIn(const FilePath &messageFile, const QStri
}
const CommandResult result = runCleartool(m_checkInView, args, RunFlags::ShowStdOut, nullptr,
10);
- const QRegularExpression checkedIn("Checked in \\\"([^\"]*)\\\"");
+ static const QRegularExpression checkedIn("Checked in \\\"([^\"]*)\\\"");
QRegularExpressionMatch match = checkedIn.match(result.cleanedStdOut());
bool anySucceeded = false;
int offset = match.capturedStart();
@@ -2077,7 +2079,8 @@ bool ClearCasePluginPrivate::ccCheckUcm(const QString &viewname, const FilePath
const QString catcsData = runCleartoolProc(workingDir,
{"catcs", "-tag", viewname}).cleanedStdOut();
// check output for the word "ucm"
- return catcsData.indexOf(QRegularExpression("(^|\\n)ucm\\n")) != -1;
+ static const QRegularExpression regexp("(^|\\n)ucm\\n");
+ return catcsData.indexOf(regexp) != -1;
}
bool ClearCasePluginPrivate::managesFile(const FilePath &workingDirectory, const QString &fileName) const
@@ -2115,7 +2118,7 @@ void ClearCasePluginPrivate::updateStreamAndView()
{"lsstream", "-fmt", "%n\\t%[def_deliver_tgt]Xp"}).cleanedStdOut();
const int tabPos = result.indexOf(QLatin1Char('\t'));
m_stream = result.left(tabPos);
- const QRegularExpression intStreamExp("stream:([^@]*)");
+ static const QRegularExpression intStreamExp("stream:([^@]*)");
const QRegularExpressionMatch match = intStreamExp.match(result.mid(tabPos + 1));
if (match.hasMatch())
m_intStream = match.captured(1);
diff --git a/src/plugins/clearcase/clearcasesync.cpp b/src/plugins/clearcase/clearcasesync.cpp
index a92ab7da7bd..1680391c576 100644
--- a/src/plugins/clearcase/clearcasesync.cpp
+++ b/src/plugins/clearcase/clearcasesync.cpp
@@ -95,14 +95,15 @@ void ClearCaseSync::processCleartoolLsLine(const QDir &viewRootDir, const QStrin
return;
// find first whitespace. anything before that is not interesting
- const int wspos = buffer.indexOf(QRegularExpression("\\s"));
+ static const QRegularExpression regexp("\\s");
+ const int wspos = buffer.indexOf(regexp);
const QString absFile =
viewRootDir.absoluteFilePath(
QDir::fromNativeSeparators(buffer.left(atatpos)));
QTC_CHECK(QFileInfo::exists(absFile));
QTC_CHECK(!absFile.isEmpty());
- const QRegularExpression reState("^\\s*\\[[^\\]]*\\]"); // [hijacked]; [loaded but missing]
+ static const QRegularExpression reState("^\\s*\\[[^\\]]*\\]"); // [hijacked]; [loaded but missing]
const QRegularExpressionMatch match = reState.match(buffer.mid(wspos + 1));
if (match.hasMatch()) {
const QString ccState = match.captured();
diff --git a/src/plugins/clearcase/versionselector.cpp b/src/plugins/clearcase/versionselector.cpp
index 4d3dd16059f..ba329d51b82 100644
--- a/src/plugins/clearcase/versionselector.cpp
+++ b/src/plugins/clearcase/versionselector.cpp
@@ -102,21 +102,21 @@ bool VersionSelector::readValues()
{
QString line;
line = m_stream->readLine();
- const QRegularExpression id("Version ID: (.*)");
+ static const QRegularExpression id("Version ID: (.*)");
const QRegularExpressionMatch idMatch = id.match(line);
if (!idMatch.hasMatch())
return false;
m_versionID = idMatch.captured(1);
line = m_stream->readLine();
- const QRegularExpression owner("Created by: (.*)");
+ static const QRegularExpression owner("Created by: (.*)");
const QRegularExpressionMatch ownerMatch = owner.match(line);
if (!ownerMatch.hasMatch())
return false;
m_createdBy = ownerMatch.captured(1);
line = m_stream->readLine();
- const QRegularExpression dateTimeRE("Created on: (.*)");
+ static const QRegularExpression dateTimeRE("Created on: (.*)");
const QRegularExpressionMatch dateTimeMatch = dateTimeRE.match(line);
if (!dateTimeMatch.hasMatch())
return false;
diff --git a/src/plugins/cmakeprojectmanager/cmakeautocompleter.cpp b/src/plugins/cmakeprojectmanager/cmakeautocompleter.cpp
index 1f520a86bf5..893f3b5e1a6 100644
--- a/src/plugins/cmakeprojectmanager/cmakeautocompleter.cpp
+++ b/src/plugins/cmakeprojectmanager/cmakeautocompleter.cpp
@@ -89,7 +89,8 @@ QString CMakeAutoCompleter::insertMatchingQuote(const QTextCursor &cursor,
int CMakeAutoCompleter::paragraphSeparatorAboutToBeInserted(QTextCursor &cursor)
{
const QString line = cursor.block().text().trimmed();
- if (line.contains(QRegularExpression(QStringLiteral("^(endfunction|endmacro|endif|endforeach|endwhile|endblock)\\w*\\("))))
+ static const QRegularExpression regexp("^(endfunction|endmacro|endif|endforeach|endwhile|endblock)\\w*\\(");
+ if (line.contains(regexp))
tabSettings().indentLine(cursor.block(), tabSettings().indentationColumn(cursor.block().text()));
return 0;
}
diff --git a/src/plugins/cmakeprojectmanager/cmakeprojectmanager.cpp b/src/plugins/cmakeprojectmanager/cmakeprojectmanager.cpp
index 50a849f7a1a..d4b5602c4d6 100644
--- a/src/plugins/cmakeprojectmanager/cmakeprojectmanager.cpp
+++ b/src/plugins/cmakeprojectmanager/cmakeprojectmanager.cpp
@@ -109,7 +109,7 @@ void CMakeManager::openCMakeUrl(const QUrl &url)
{
QString urlPrefix = "https://cmake.org/cmake/help/";
- QRegularExpression version("^.*\\.([0-9])\\.([0-9]+)\\.[0-9]+$");
+ static const QRegularExpression version("^.*\\.([0-9])\\.([0-9]+)\\.[0-9]+$");
auto match = version.match(url.authority());
if (match.hasMatch())
urlPrefix.append(QString("v%1.%2").arg(match.captured(1)).arg(match.captured(2)));
diff --git a/src/plugins/compilationdatabaseprojectmanager/compilationdatabaseutils.cpp b/src/plugins/compilationdatabaseprojectmanager/compilationdatabaseutils.cpp
index 5e07c2c2050..7f68eedb934 100644
--- a/src/plugins/compilationdatabaseprojectmanager/compilationdatabaseutils.cpp
+++ b/src/plugins/compilationdatabaseprojectmanager/compilationdatabaseutils.cpp
@@ -206,7 +206,8 @@ QStringList splitCommandLine(QString commandLine, QSet<QString> &flagsCache)
// Remove escaped quotes.
commandLine.replace("\\\"", "'");
- for (const QString &part : commandLine.split(QRegularExpression("\""))) {
+ static const QRegularExpression splitRegexp("\"");
+ for (const QString &part : commandLine.split(splitRegexp)) {
if (insideQuotes) {
const QString quotedPart = "\"" + part + "\"";
if (result.last().endsWith("=")) {
@@ -217,8 +218,8 @@ QStringList splitCommandLine(QString commandLine, QSet<QString> &flagsCache)
result.append(*flagIt);
}
} else { // If 's' is outside quotes ...
- for (const QString &flag :
- part.split(QRegularExpression("\\s+"), Qt::SkipEmptyParts)) {
+ static const QRegularExpression regexp("\\s+");
+ for (const QString &flag : part.split(regexp, Qt::SkipEmptyParts)) {
auto flagIt = flagsCache.insert(flag);
result.append(*flagIt);
}
diff --git a/src/plugins/coreplugin/dialogs/externaltoolconfig.cpp b/src/plugins/coreplugin/dialogs/externaltoolconfig.cpp
index 95d37354da6..5f57b5719cf 100644
--- a/src/plugins/coreplugin/dialogs/externaltoolconfig.cpp
+++ b/src/plugins/coreplugin/dialogs/externaltoolconfig.cpp
@@ -778,7 +778,8 @@ static FilePath getUserFilePath(const QString &proposalFileName)
static QString idFromDisplayName(const QString &displayName)
{
QString id = displayName;
- id.remove(QRegularExpression("&(?!&)"));
+ static const QRegularExpression regexp("&(?!&)");
+ id.remove(regexp);
QChar *c = id.data();
while (!c->isNull()) {
if (!c->isLetterOrNumber())
diff --git a/src/plugins/coreplugin/documentmanager.cpp b/src/plugins/coreplugin/documentmanager.cpp
index 0ebffb50b20..e2529372be6 100644
--- a/src/plugins/coreplugin/documentmanager.cpp
+++ b/src/plugins/coreplugin/documentmanager.cpp
@@ -803,7 +803,7 @@ FilePath DocumentManager::getSaveFileName(const QString &title, const FilePath &
// first one from the filter is appended.
if (selectedFilter && *selectedFilter != allFilesFilterString()) {
// Mime database creates filter strings like this: Anything here (*.foo *.bar)
- const QRegularExpression regExp(QLatin1String(".*\\s+\\((.*)\\)$"));
+ static const QRegularExpression regExp(QLatin1String(".*\\s+\\((.*)\\)$"));
QRegularExpressionMatchIterator matchIt = regExp.globalMatch(*selectedFilter);
if (matchIt.hasNext()) {
bool suffixOk = false;
diff --git a/src/plugins/cpaster/pastebindotcomprotocol.cpp b/src/plugins/cpaster/pastebindotcomprotocol.cpp
index 639408737ce..bd6113a3369 100644
--- a/src/plugins/cpaster/pastebindotcomprotocol.cpp
+++ b/src/plugins/cpaster/pastebindotcomprotocol.cpp
@@ -220,7 +220,7 @@ struct Attribute {
static QList<Attribute> toAttributes(QStringView attributes)
{
QList<Attribute> result;
- const QRegularExpression att("\\s+([a-zA-Z]+)\\s*=\\s*('.*?'|\".*?\")");
+ static const QRegularExpression att("\\s+([a-zA-Z]+)\\s*=\\s*('.*?'|\".*?\")");
QRegularExpressionMatchIterator it = att.globalMatch(attributes.toString());
while (it.hasNext()) {
const QRegularExpressionMatch match = it.next();
@@ -338,7 +338,7 @@ static inline QStringList parseLists(QIODevice *io, QString *errorMessage)
QString dataStr = QString::fromUtf8(data);
// remove comments if any
- const QRegularExpression comment("<!--.*--!>", QRegularExpression::MultilineOption);
+ static const QRegularExpression comment("<!--.*--!>", QRegularExpression::MultilineOption);
for ( ;; ) {
const QRegularExpressionMatch match = comment.match(dataStr);
if (!match.hasMatch())
@@ -346,9 +346,9 @@ static inline QStringList parseLists(QIODevice *io, QString *errorMessage)
dataStr.remove(match.capturedStart(), match.capturedLength());
}
- const QRegularExpression tag("<(/?)\\s*([a-zA-Z][a-zA-Z0-9]*)(.*?)(/?)\\s*>",
- QRegularExpression::MultilineOption);
- const QRegularExpression wsOnly("^\\s+$", QRegularExpression::MultilineOption);
+ static const QRegularExpression tag("<(/?)\\s*([a-zA-Z][a-zA-Z0-9]*)(.*?)(/?)\\s*>",
+ QRegularExpression::MultilineOption);
+ static const QRegularExpression wsOnly("^\\s+$", QRegularExpression::MultilineOption);
QRegularExpressionMatchIterator it = tag.globalMatch(dataStr);
while (it.hasNext()) {
const QRegularExpressionMatch match = it.next();
diff --git a/src/plugins/cppeditor/compileroptionsbuilder.cpp b/src/plugins/cppeditor/compileroptionsbuilder.cpp
index 8bd1219a5d2..62f1c564746 100644
--- a/src/plugins/cppeditor/compileroptionsbuilder.cpp
+++ b/src/plugins/cppeditor/compileroptionsbuilder.cpp
@@ -342,7 +342,8 @@ void CompilerOptionsBuilder::insertWrappedHeaders(const QStringList &relPaths)
args << (includeUserPathOption + QDir::toNativeSeparators(fullPath));
}
- const int index = m_options.indexOf(QRegularExpression("\\A-I.*\\z"));
+ static const QRegularExpression regexp("\\A-I.*\\z");
+ const int index = m_options.indexOf(regexp);
if (index < 0)
add(args);
else
diff --git a/src/plugins/cppeditor/cpptoolsreuse.cpp b/src/plugins/cppeditor/cpptoolsreuse.cpp
index 109943123b1..a78b7d8d5fd 100644
--- a/src/plugins/cppeditor/cpptoolsreuse.cpp
+++ b/src/plugins/cppeditor/cpptoolsreuse.cpp
@@ -116,7 +116,8 @@ QStringList identifierWordsUnderCursor(const QTextCursor &tc)
break;
QTextCursor temp(endCursor);
temp.setPosition(startCursor.position(), QTextCursor::KeepAnchor);
- results.append(temp.selectedText().remove(QRegularExpression("\\s")));
+ static const QRegularExpression rexgexp("\\s");
+ results.append(temp.selectedText().remove(rexgexp));
// possibly skip ::
temp = startCursor;
skipCharsBackward(&temp, isSpace);
diff --git a/src/plugins/cppeditor/doxygengenerator.cpp b/src/plugins/cppeditor/doxygengenerator.cpp
index d2555ab5643..5857f51785f 100644
--- a/src/plugins/cppeditor/doxygengenerator.cpp
+++ b/src/plugins/cppeditor/doxygengenerator.cpp
@@ -64,11 +64,12 @@ QString DoxygenGenerator::generate(QTextCursor cursor,
// remove attributes like [[nodiscard]] because
// Document::Ptr::parse(Document::ParseDeclaration) fails on attributes
- static QRegularExpression attribute("\\[\\s*\\[.*\\]\\s*\\]");
+ static const QRegularExpression attribute("\\[\\s*\\[.*\\]\\s*\\]");
declCandidate.replace(attribute, "");
declCandidate.replace("Q_INVOKABLE", "");
- declCandidate.remove(QRegularExpression(R"(\s*(public|protected|private)\s*:\s*)"));
+ static const QRegularExpression accessSpecifier(R"(\s*(public|protected|private)\s*:\s*)");
+ declCandidate.remove(accessSpecifier);
declCandidate.replace(QChar::ParagraphSeparator, QLatin1Char('\n'));
// Let's append a closing brace in the case we got content like 'class MyType {'
diff --git a/src/plugins/cppeditor/quickfixes/bringidentifierintoscope.cpp b/src/plugins/cppeditor/quickfixes/bringidentifierintoscope.cpp
index 9b34a09628c..c745ebdffef 100644
--- a/src/plugins/cppeditor/quickfixes/bringidentifierintoscope.cpp
+++ b/src/plugins/cppeditor/quickfixes/bringidentifierintoscope.cpp
@@ -276,9 +276,9 @@ private:
} else if (visitor.firstNamespace()) {
insertPos = file->startOf(visitor.firstNamespace());
} else {
+ static const QRegularExpression regexp("^\\s*#include .*$");
const QTextCursor tc = file->document()->find(
- QRegularExpression("^\\s*#include .*$"),
- m_symbolPos,
+ regexp, m_symbolPos,
QTextDocument::FindBackward | QTextDocument::FindCaseSensitively);
if (!tc.isNull())
insertPos = tc.position() + 1;
diff --git a/src/plugins/cppeditor/quickfixes/convertnumericliteral.cpp b/src/plugins/cppeditor/quickfixes/convertnumericliteral.cpp
index 6fb5becf348..fe50475bc9c 100644
--- a/src/plugins/cppeditor/quickfixes/convertnumericliteral.cpp
+++ b/src/plugins/cppeditor/quickfixes/convertnumericliteral.cpp
@@ -178,7 +178,7 @@ private:
replacement.append('0');
} else {
std::bitset<std::numeric_limits<decltype (value)>::digits> b(value);
- QRegularExpression re("^[0]*");
+ static const QRegularExpression re("^[0]*");
replacement.append(QString::fromStdString(b.to_string()).remove(re));
}
auto op = new ConvertNumericLiteralOp(interface, start, start + numberLength, replacement);
diff --git a/src/plugins/cppeditor/quickfixes/insertfunctiondefinition.cpp b/src/plugins/cppeditor/quickfixes/insertfunctiondefinition.cpp
index 0f9f8461380..9853f10eee4 100644
--- a/src/plugins/cppeditor/quickfixes/insertfunctiondefinition.cpp
+++ b/src/plugins/cppeditor/quickfixes/insertfunctiondefinition.cpp
@@ -172,7 +172,7 @@ public:
QString input = prettyType;
int index = 0;
while (input.startsWith("template")) {
- QRegularExpression templateRegex("template\\s*<[^>]*>");
+ static const QRegularExpression templateRegex("template\\s*<[^>]*>");
QRegularExpressionMatch match = templateRegex.match(input);
if (match.hasMatch()) {
index += match.captured().size() + 1;
diff --git a/src/plugins/cvs/cvsutils.cpp b/src/plugins/cvs/cvsutils.cpp
index 0b5e81e64a7..1287a74ade2 100644
--- a/src/plugins/cvs/cvsutils.cpp
+++ b/src/plugins/cvs/cvsutils.cpp
@@ -43,8 +43,8 @@ QList<CvsLogEntry> parseLogEntries(const QString &o,
ParseState state = FileState;
const QString workingFilePrefix = QLatin1String("Working file: ");
- const QRegularExpression statusPattern(QLatin1String("^date: ([\\d\\-]+) .*commitid: ([^;]+);$"));
- const QRegularExpression revisionPattern(QLatin1String("^revision ([\\d\\.]+)$"));
+ static const QRegularExpression statusPattern(QLatin1String("^date: ([\\d\\-]+) .*commitid: ([^;]+);$"));
+ static const QRegularExpression revisionPattern(QLatin1String("^revision ([\\d\\.]+)$"));
const QChar slash = QLatin1Char('/');
Q_ASSERT(statusPattern.isValid() && revisionPattern.isValid());
const QString fileSeparator = QLatin1String("=============================================================================");
diff --git a/src/plugins/debugger/cdb/cdbengine.cpp b/src/plugins/debugger/cdb/cdbengine.cpp
index 5dbc8948769..16aab0c920c 100644
--- a/src/plugins/debugger/cdb/cdbengine.cpp
+++ b/src/plugins/debugger/cdb/cdbengine.cpp
@@ -2198,7 +2198,7 @@ static inline bool checkCommandToken(const QString &tokenPrefix, const QString &
// and the pdb files are installed in a path discoverable by the debugger
void CdbEngine::checkQtSdkPdbFiles(const QString &module)
{
- const QRegularExpression qtCoreModuleRegExp("(Qt\\dCored).dll");
+ static const QRegularExpression qtCoreModuleRegExp("(Qt\\dCored).dll");
const QRegularExpressionMatch match = qtCoreModuleRegExp.match(module);
if (!match.hasMatch())
return;
@@ -2348,7 +2348,7 @@ void CdbEngine::parseOutputLine(QString line)
}
const char versionString[] = "Microsoft (R) Windows Debugger Version";
if (line.startsWith(versionString)) {
- const QRegularExpression versionRegEx("(\\d+)\\.(\\d+)\\.\\d+\\.\\d+");
+ static const QRegularExpression versionRegEx("(\\d+)\\.(\\d+)\\.\\d+\\.\\d+");
const QRegularExpressionMatch match = versionRegEx.match(line);
if (match.hasMatch()) {
bool ok = true;
@@ -2366,7 +2366,7 @@ void CdbEngine::parseOutputLine(QString line)
} else if (line.startsWith("ModLoad: ")) {
// output(64): ModLoad: 00007ffb`842b0000 00007ffb`843ee000 C:\Windows\system32\KERNEL32.DLL
// output(32): ModLoad: 00007ffb 00007ffb C:\Windows\system32\KERNEL32.DLL
- const QRegularExpression moduleRegExp("[0-9a-fA-F]+(`[0-9a-fA-F]+)? [0-9a-fA-F]+(`[0-9a-fA-F]+)? (.*)");
+ static const QRegularExpression moduleRegExp("[0-9a-fA-F]+(`[0-9a-fA-F]+)? [0-9a-fA-F]+(`[0-9a-fA-F]+)? (.*)");
const QRegularExpressionMatch match = moduleRegExp.match(line);
if (match.hasMatch()) {
const QString module = match.captured(3).trimmed();
diff --git a/src/plugins/debugger/gdb/gdbengine.cpp b/src/plugins/debugger/gdb/gdbengine.cpp
index fa8646d73e0..21cb36f7715 100644
--- a/src/plugins/debugger/gdb/gdbengine.cpp
+++ b/src/plugins/debugger/gdb/gdbengine.cpp
@@ -1408,7 +1408,7 @@ void GdbEngine::handleStop2(const GdbMi &data)
showStatusMessage(bp->msgBreakpointTriggered(threadId));
const QString commands = bp->command().trimmed();
// Can be either c or cont[inue]
- const QRegularExpression contExp("(^|\\n)\\s*c(ont(i(n(ue?)?)?)?)?$");
+ static const QRegularExpression contExp("(^|\\n)\\s*c(ont(i(n(ue?)?)?)?)?$");
QTC_CHECK(contExp.isValid());
if (contExp.match(commands).hasMatch()) {
notifyInferiorRunRequested();
@@ -2371,7 +2371,7 @@ void GdbEngine::handleBreakCondition(const DebuggerResponse &, const Breakpoint
void GdbEngine::updateTracepointCaptures(const Breakpoint &bp)
{
- static QRegularExpression capsRegExp(
+ static const QRegularExpression capsRegExp(
"(^|[^\\\\])(\\$(ADDRESS|CALLER|CALLSTACK|FILEPOS|FUNCTION|PID|PNAME|TICK|TID|TNAME)"
"|{[^}]+})");
QString message = bp->globalBreakpoint()->requestedParameters().message;
@@ -3516,7 +3516,7 @@ void GdbEngine::handlePeripheralRegisterListValues(
const QString output = response.consoleStreamOutput;
// Regexp to match for '0x50060800:\t0\n'.
- const QRegularExpression re("^(0x[0-9A-Fa-f]+):\\t(\\d+)\\n$");
+ static const QRegularExpression re("^(0x[0-9A-Fa-f]+):\\t(\\d+)\\n$");
const QRegularExpressionMatch m = re.match(output);
if (!m.hasMatch())
return;
diff --git a/src/plugins/debugger/lldb/lldbengine.cpp b/src/plugins/debugger/lldb/lldbengine.cpp
index 45cb3f829ba..a3f2c5c32e1 100644
--- a/src/plugins/debugger/lldb/lldbengine.cpp
+++ b/src/plugins/debugger/lldb/lldbengine.cpp
@@ -112,8 +112,10 @@ void LldbEngine::runCommand(const DebuggerCommand &command)
QString token = QString::number(tok);
QString function = cmd.function + "(" + cmd.argsToPython() + ")";
QString msg = token + function + '\n';
- if (cmd.flags == Silent)
- msg.replace(QRegularExpression("\"environment\":.[^]]*."), "<environment suppressed>");
+ if (cmd.flags == Silent) {
+ static const QRegularExpression regexp("\"environment\":.[^]]*.");
+ msg.replace(regexp, "<environment suppressed>");
+ }
if (cmd.flags == NeedsFullStop) {
cmd.flags &= ~NeedsFullStop;
if (state() == InferiorRunOk) {
diff --git a/src/plugins/debugger/peripheralregisterhandler.cpp b/src/plugins/debugger/peripheralregisterhandler.cpp
index 100212c149d..413074cc0d5 100644
--- a/src/plugins/debugger/peripheralregisterhandler.cpp
+++ b/src/plugins/debugger/peripheralregisterhandler.cpp
@@ -118,22 +118,22 @@ static quint64 valueFromString(const QString &string, PeripheralRegisterFormat f
bool *ok)
{
if (fmt == PeripheralRegisterFormat::Hexadecimal) {
- const QRegularExpression re("^(0x)?([0-9A-F]+)$");
+ static const QRegularExpression re("^(0x)?([0-9A-F]+)$");
const QRegularExpressionMatch m = re.match(string);
if (m.hasMatch())
return m.captured(2).toULongLong(ok, 16);
} else if (fmt == PeripheralRegisterFormat::Decimal) {
- const QRegularExpression re("^([0-9]+)$");
+ static const QRegularExpression re("^([0-9]+)$");
const QRegularExpressionMatch m = re.match(string);
if (m.hasMatch())
return m.captured(1).toULongLong(ok, 10);
} else if (fmt == PeripheralRegisterFormat::Octal) {
- const QRegularExpression re("^(0)?([0-7]+)$");
+ static const QRegularExpression re("^(0)?([0-7]+)$");
const QRegularExpressionMatch m = re.match(string);
if (m.hasMatch())
return m.captured(2).toULongLong(ok, 8);
} else if (fmt == PeripheralRegisterFormat::Binary) {
- const QRegularExpression re("^(0b)?([0-1]+)$");
+ static const QRegularExpression re("^(0b)?([0-1]+)$");
const QRegularExpressionMatch m = re.match(string);
if (m.hasMatch())
return m.captured(2).toULongLong(ok, 2);
diff --git a/src/plugins/debugger/qml/qmlinspectoragent.cpp b/src/plugins/debugger/qml/qmlinspectoragent.cpp
index 2769d49cd60..4f02adcfc88 100644
--- a/src/plugins/debugger/qml/qmlinspectoragent.cpp
+++ b/src/plugins/debugger/qml/qmlinspectoragent.cpp
@@ -534,7 +534,7 @@ void QmlInspectorAgent::buildDebugIdHashRecursive(const ObjectReference &ref)
// handle the case where the url contains the revision number encoded.
// (for object created by the debugger)
- const QRegularExpression rx("^(.*)_(\\d+):(\\d+)$");
+ static const QRegularExpression rx("^(.*)_(\\d+):(\\d+)$");
const QRegularExpressionMatch match = rx.match(fileUrl.path());
if (match.hasMatch()) {
fileUrl.setPath(match.captured(1));
diff --git a/src/plugins/debugger/simplifytype.cpp b/src/plugins/debugger/simplifytype.cpp
index 1caa29093a0..56e79ea0433 100644
--- a/src/plugins/debugger/simplifytype.cpp
+++ b/src/plugins/debugger/simplifytype.cpp
@@ -102,7 +102,7 @@ QString simplifyType(const QString &typeIn)
type.replace("std::__cxx11::", "std::");
type.replace("std::__1::", "std::");
type.replace("std::__debug::", "std::");
- QRegularExpression simpleStringRE("std::basic_string<char> ?");
+ static const QRegularExpression simpleStringRE("std::basic_string<char> ?");
type.replace(simpleStringRE, "std::string");
// Normalize space + ptr.
@@ -124,7 +124,7 @@ QString simplifyType(const QString &typeIn)
type = type.mid(16, type.size() - 31);
// std::ifstream
- QRegularExpression ifstreamRE("std::basic_ifstream<char,\\s*?std::char_traits<char>\\s*?>");
+ static const QRegularExpression ifstreamRE("std::basic_ifstream<char,\\s*?std::char_traits<char>\\s*?>");
QTC_ASSERT(ifstreamRE.isValid(), return typeIn);
const QRegularExpressionMatch match = ifstreamRE.match(type);
if (match.hasMatch())
@@ -133,7 +133,7 @@ QString simplifyType(const QString &typeIn)
// std::__1::hash_node<int, void *>::value_type -> int
if (isLibCpp) {
- QRegularExpression hashNodeRE("std::__hash_node<([^<>]*),\\s*void\\s*@>::value_type");
+ static const QRegularExpression hashNodeRE("std::__hash_node<([^<>]*),\\s*void\\s*@>::value_type");
QTC_ASSERT(hashNodeRE.isValid(), return typeIn);
const QRegularExpressionMatch match = hashNodeRE.match(type);
if (match.hasMatch())
diff --git a/src/plugins/debugger/watchhandler.cpp b/src/plugins/debugger/watchhandler.cpp
index a8b49c54b1f..a0fd11af6a7 100644
--- a/src/plugins/debugger/watchhandler.cpp
+++ b/src/plugins/debugger/watchhandler.cpp
@@ -910,7 +910,7 @@ static QString displayName(const WatchItem *item)
// prepend '*'s to indicate where autodereferencing has taken place
if (item->autoDerefCount > 0) {
// add parentheses for everything except simple variable names (e.g. pointer arithmetics,...)
- QRegularExpression variableNameRegex("^[a-zA-Z0-9_]+$");
+ static const QRegularExpression variableNameRegex("^[a-zA-Z0-9_]+$");
bool addParanthesis = !variableNameRegex.match(result).hasMatch();
if (addParanthesis)
result = "(" + result;
diff --git a/src/plugins/diffeditor/diffutils.cpp b/src/plugins/diffeditor/diffutils.cpp
index afb75203037..6a5c579a7c1 100644
--- a/src/plugins/diffeditor/diffutils.cpp
+++ b/src/plugins/diffeditor/diffutils.cpp
@@ -845,15 +845,15 @@ static FileData readDiffHeaderAndChunks(QStringView headerAndChunks, bool *ok)
FileData fileData;
bool readOk = false;
- const QRegularExpression leftFileRegExp(
+ static const QRegularExpression leftFileRegExp(
"(?:\\n|^)-{3} " // "--- "
"([^\\t\\n]+)" // "fileName1"
"(?:\\t[^\\n]*)*\\n"); // optionally followed by: \t anything \t anything ...)
- const QRegularExpression rightFileRegExp(
+ static const QRegularExpression rightFileRegExp(
"^\\+{3} " // "+++ "
"([^\\t\\n]+)" // "fileName2"
"(?:\\t[^\\n]*)*\\n"); // optionally followed by: \t anything \t anything ...)
- const QRegularExpression binaryRegExp(
+ static const QRegularExpression binaryRegExp(
"^Binary files ([^\\t\\n]+) and ([^\\t\\n]+) differ$");
// followed either by leftFileRegExp
@@ -895,7 +895,8 @@ static FileData readDiffHeaderAndChunks(QStringView headerAndChunks, bool *ok)
static void readDiffPatch(QPromise<QList<FileData>> &promise, QStringView patch)
{
- const QRegularExpression diffRegExp("(?:\\n|^)" // new line of the beginning of a patch
+ static const QRegularExpression diffRegExp(
+ "(?:\\n|^)" // new line of the beginning of a patch
"(" // either
"-{3} " // ---
"[^\\t\\n]+" // filename1
@@ -1282,7 +1283,7 @@ void DiffUtils::readPatchWithPromise(QPromise<QList<FileData>> &promise, const Q
promise.setProgressValue(0);
QStringView croppedPatch = QStringView(patch);
// Crop e.g. "-- \n2.10.2.windows.1\n\n" at end of file
- const QRegularExpression formatPatchEndingRegExp("(\\n-- \\n\\S*\\n\\n$)");
+ static const QRegularExpression formatPatchEndingRegExp("(\\n-- \\n\\S*\\n\\n$)");
const QRegularExpressionMatch match = formatPatchEndingRegExp.match(croppedPatch);
if (match.hasMatch())
croppedPatch = croppedPatch.left(match.capturedStart() + 1);
diff --git a/src/plugins/fakevim/fakevimhandler.cpp b/src/plugins/fakevim/fakevimhandler.cpp
index 29257505f21..fe9c28706e8 100644
--- a/src/plugins/fakevim/fakevimhandler.cpp
+++ b/src/plugins/fakevim/fakevimhandler.cpp
@@ -408,8 +408,9 @@ static QRegularExpression vimPatternToQtPattern(const QString &needle)
// FIXME: Option smartcase should be used only if search was typed by user.
const bool smartCaseOption = settings().smartCase();
+ static const QRegularExpression regexp("[A-Z]");
const bool initialIgnoreCase = settings().ignoreCase()
- && !(smartCaseOption && needle.contains(QRegularExpression("[A-Z]")));
+ && !(smartCaseOption && needle.contains(regexp));
bool ignorecase = initialIgnoreCase;
@@ -639,10 +640,11 @@ static void bracketSearchBackward(QTextCursor *tc, const QString &needleExp, int
static void bracketSearchForward(QTextCursor *tc, const QString &needleExp, int repeat,
bool searchWithCommand)
{
- QRegularExpression re(searchWithCommand ? QString("^\\}|^\\{") : needleExp);
+ static const QRegularExpression reWithCommand("^\\}|^\\{");
+ const QRegularExpression reNeedle(needleExp);
QTextCursor tc2 = *tc;
tc2.setPosition(tc2.position() + 1);
- searchForward(&tc2, re, &repeat);
+ searchForward(&tc2, searchWithCommand ? reWithCommand : reNeedle, &repeat);
if (repeat <= 1) {
if (tc2.isNull()) {
tc->setPosition(tc->document()->characterCount() - 1, KeepAnchor);
@@ -2702,7 +2704,8 @@ void FakeVimHandler::Private::commitInsertState()
lastInsertion.prepend(QString("<DELETE>").repeated(insertState.deletes));
// Remove indentation.
- lastInsertion.replace(QRegularExpression("(^|\n)[\\t ]+"), "\\1");
+ static const QRegularExpression regexp("(^|\n)[\\t ]+");
+ lastInsertion.replace(regexp, "\\1");
}
void FakeVimHandler::Private::invalidateInsertState()
@@ -4816,7 +4819,8 @@ bool FakeVimHandler::Private::handleReplaceSubMode(const Input &input)
++range.endPos;
// Replace each character but preserve lines.
transformText(range, [&c](const QString &text) {
- return QString(text).replace(QRegularExpression("[^\\n]"), c);
+ static const QRegularExpression regexp("[^\\n]");
+ return QString(text).replace(regexp, c);
});
} else if (count() <= rightDist()) {
pushUndoState();
@@ -5778,7 +5782,8 @@ bool FakeVimHandler::Private::parseExCommand(QString *line, ExCommand *cmd)
cmd->cmd = line->mid(0, i).trimmed();
// command arguments starts with first non-letter character
- cmd->args = cmd->cmd.section(QRegularExpression("(?=[^a-zA-Z])"), 1);
+ static const QRegularExpression regexp("(?=[^a-zA-Z])");
+ cmd->args = cmd->cmd.section(regexp, 1);
if (!cmd->args.isEmpty()) {
cmd->cmd.chop(cmd->args.size());
cmd->args = cmd->args.trimmed();
@@ -5798,7 +5803,8 @@ bool FakeVimHandler::Private::parseExCommand(QString *line, ExCommand *cmd)
bool FakeVimHandler::Private::parseLineRange(QString *line, ExCommand *cmd)
{
// remove leading colons and spaces
- line->remove(QRegularExpression("^\\s*(:+\\s*)*"));
+ static const QRegularExpression regexp("^\\s*(:+\\s*)*");
+ line->remove(regexp);
// special case ':!...' (use invalid range)
if (line->startsWith('!')) {
@@ -5857,7 +5863,8 @@ bool FakeVimHandler::Private::handleExSubstituteCommand(const ExCommand &cmd)
int count = 1;
QString line = cmd.args;
- const QRegularExpressionMatch match = QRegularExpression("\\d+$").match(line);
+ static const QRegularExpression regexp("\\d+$");
+ const QRegularExpressionMatch match = regexp.match(line);
if (match.hasMatch()) {
count = match.captured().toInt();
line = line.left(match.capturedStart()).trimmed();
@@ -6021,8 +6028,9 @@ bool FakeVimHandler::Private::handleExMapCommand(const ExCommand &cmd0) // :map
break;
}
- const QString lhs = args.section(QRegularExpression("\\s+"), 0, 0);
- const QString rhs = args.section(QRegularExpression("\\s+"), 1);
+ static const QRegularExpression regexp("\\s+");
+ const QString lhs = args.section(regexp, 0, 0);
+ const QString rhs = args.section(regexp, 1);
if ((rhs.isNull() && type != Unmap) || (!rhs.isNull() && type == Unmap)) {
// FIXME: Dump mappings here.
//qDebug() << g.mappings;
@@ -7662,7 +7670,8 @@ void FakeVimHandler::Private::toggleComment(const Range &range)
: commentString.size();
line.replace(line.indexOf(commentString), sizeToReplace, "");
} else {
- const int indexOfFirstNonSpace = line.indexOf(QRegularExpression("[^\\s]"));
+ static const QRegularExpression regexp("[^\\s]");
+ const int indexOfFirstNonSpace = line.indexOf(regexp);
line = line.left(indexOfFirstNonSpace) + commentString + " " + line.right(line.size() - indexOfFirstNonSpace);
}
}
@@ -7903,10 +7912,13 @@ void FakeVimHandler::Private::joinLines(int count, bool preserveSpace)
const int blockNumber = m_cursor.blockNumber();
const QString currentLine = lineContents(blockNumber + 1);
+ static const QRegularExpression cppStyleRegexp("^\\s*\\/\\/");
+ static const QRegularExpression cStyleRegexp("^\\s*\\/?\\*");
+ static const QRegularExpression pythonStyleRegexp("^\\s*#");
const bool startingLineIsComment
- = currentLine.contains(QRegularExpression("^\\s*\\/\\/")) // Cpp-style
- || currentLine.contains(QRegularExpression("^\\s*\\/?\\*")) // C-style
- || currentLine.contains(QRegularExpression("^\\s*#")); // Python/Shell-style
+ = currentLine.contains(cppStyleRegexp)
+ || currentLine.contains(cStyleRegexp)
+ || currentLine.contains(pythonStyleRegexp);
for (int i = qMax(count - 2, 0); i >= 0 && blockNumber < document()->blockCount(); --i) {
moveBehindEndOfLine();
@@ -8988,7 +9000,7 @@ bool FakeVimHandler::Private::changeNumberTextObject(int count)
const int posMin = m_cursor.positionInBlock() + 1;
// find first decimal, hexadecimal or octal number under or after cursor position
- QRegularExpression re("(0[xX])(0*[0-9a-fA-F]+)|(0)(0*[0-7]+)(?=\\D|$)|(\\d+)");
+ static const QRegularExpression re("(0[xX])(0*[0-9a-fA-F]+)|(0)(0*[0-7]+)(?=\\D|$)|(\\d+)");
QRegularExpressionMatch match;
QRegularExpressionMatchIterator it = re.globalMatch(lineText);
while (true) {
@@ -9035,7 +9047,8 @@ bool FakeVimHandler::Private::changeNumberTextObject(int count)
// convert hexadecimal number to upper-case if last letter was upper-case
if (hex) {
- const int lastLetter = num.lastIndexOf(QRegularExpression("[a-fA-F]"));
+ static const QRegularExpression regexp("[a-fA-F]");
+ const int lastLetter = num.lastIndexOf(regexp);
if (lastLetter != -1 && num[lastLetter].isUpper())
repl = repl.toUpper();
}
diff --git a/src/plugins/fossil/fossilclient.cpp b/src/plugins/fossil/fossilclient.cpp
index a0db9820500..843397fa2c4 100644
--- a/src/plugins/fossil/fossilclient.cpp
+++ b/src/plugins/fossil/fossilclient.cpp
@@ -227,7 +227,7 @@ unsigned int FossilClient::synchronousBinaryVersion() const
// fossil version:
// "This is fossil version 1.27 [ccdefa355b] 2013-09-30 11:47:18 UTC"
- QRegularExpression versionPattern("(\\d+)\\.(\\d+)");
+ static const QRegularExpression versionPattern("(\\d+)\\.(\\d+)");
QTC_ASSERT(versionPattern.isValid(), return 0);
QRegularExpressionMatch versionMatch = versionPattern.match(output);
QTC_ASSERT(versionMatch.hasMatch(), return 0);
@@ -317,8 +317,8 @@ QStringList FossilClient::parseRevisionCommentLine(const QString &commentLine)
{
// "comment: This is a (test) commit message (user: the.name)"
- const QRegularExpression commentRx("^comment:\\s+(.*)\\s\\(user:\\s(.*)\\)$",
- QRegularExpression::CaseInsensitiveOption);
+ static const QRegularExpression commentRx("^comment:\\s+(.*)\\s\\(user:\\s(.*)\\)$",
+ QRegularExpression::CaseInsensitiveOption);
QTC_ASSERT(commentRx.isValid(), return {});
const QRegularExpressionMatch match = commentRx.match(commentLine);
@@ -354,7 +354,7 @@ RevisionInfo FossilClient::synchronousRevisionQuery(const FilePath &workingDirec
QString commentMsg;
QString committer;
- const QRegularExpression idRx("([0-9a-f]{5,40})");
+ static const QRegularExpression idRx("([0-9a-f]{5,40})");
QTC_ASSERT(idRx.isValid(), return {});
const QString hashToken =
diff --git a/src/plugins/fossil/fossilplugin.cpp b/src/plugins/fossil/fossilplugin.cpp
index 46b285e5bc4..999e3f2edb8 100644
--- a/src/plugins/fossil/fossilplugin.cpp
+++ b/src/plugins/fossil/fossilplugin.cpp
@@ -744,7 +744,8 @@ bool FossilPluginPrivate::activateCommit()
if (!branch.isEmpty()) {
// @TODO: make enquote utility function
QString enquotedBranch = branch;
- if (branch.contains(QRegularExpression("\\s")))
+ static const QRegularExpression regexp("\\s");
+ if (branch.contains(regexp))
enquotedBranch = QString("\"") + branch + "\"";
extraOptions << "--branch" << enquotedBranch;
}
diff --git a/src/plugins/git/gerrit/gerritserver.cpp b/src/plugins/git/gerrit/gerritserver.cpp
index 869bbc0871d..ab70ae46c05 100644
--- a/src/plugins/git/gerrit/gerritserver.cpp
+++ b/src/plugins/git/gerrit/gerritserver.cpp
@@ -240,7 +240,7 @@ int GerritServer::testConnection()
}
if (result.exitCode() == CertificateError)
return CertificateError;
- const QRegularExpression errorRegexp("returned error: (\\d+)");
+ static const QRegularExpression errorRegexp("returned error: (\\d+)");
QRegularExpressionMatch match = errorRegexp.match(result.cleanedStdErr());
if (match.hasMatch())
return match.captured(1).toInt();
diff --git a/src/plugins/git/giteditor.cpp b/src/plugins/git/giteditor.cpp
index aa5cd86be34..5f1b46e02ab 100644
--- a/src/plugins/git/giteditor.cpp
+++ b/src/plugins/git/giteditor.cpp
@@ -324,7 +324,7 @@ FilePath GitEditorWidget::fileNameForLine(int line) const
// 7971b6e7 share/qtcreator/dumper/dumper.py (hjk
QTextBlock block = document()->findBlockByLineNumber(line - 1);
QTC_ASSERT(block.isValid(), return source());
- static QRegularExpression renameExp("^" CHANGE_PATTERN "\\s+([^(]+)");
+ static const QRegularExpression renameExp("^" CHANGE_PATTERN "\\s+([^(]+)");
const QRegularExpressionMatch match = renameExp.match(block.text());
if (match.hasMatch()) {
const QString fileName = match.captured(1).trimmed();
diff --git a/src/plugins/help/searchwidget.cpp b/src/plugins/help/searchwidget.cpp
index 65da6febb0d..ef932ba15b3 100644
--- a/src/plugins/help/searchwidget.cpp
+++ b/src/plugins/help/searchwidget.cpp
@@ -245,7 +245,8 @@ void SearchWidget::contextMenuEvent(QContextMenuEvent *contextMenuEvent)
QStringList SearchWidget::currentSearchTerms() const
{
- return searchEngine->searchInput().split(QRegularExpression("\\W+"), Qt::SkipEmptyParts);
+ static const QRegularExpression regexp("\\W+");
+ return searchEngine->searchInput().split(regexp, Qt::SkipEmptyParts);
}
// #pragma mark -- SearchSideBarItem
diff --git a/src/plugins/incredibuild/cmakecommandbuilder.cpp b/src/plugins/incredibuild/cmakecommandbuilder.cpp
index 8732601cbc4..7743b3143fd 100644
--- a/src/plugins/incredibuild/cmakecommandbuilder.cpp
+++ b/src/plugins/incredibuild/cmakecommandbuilder.cpp
@@ -53,7 +53,7 @@ QString CMakeCommandBuilder::defaultArguments() const
QString CMakeCommandBuilder::setMultiProcessArg(QString args)
{
- QRegularExpression regExp("\\s*\\-j\\s+\\d+");
+ static const QRegularExpression regExp("\\s*\\-j\\s+\\d+");
args.remove(regExp);
args.append(" -- -j 200");
diff --git a/src/plugins/incredibuild/makecommandbuilder.cpp b/src/plugins/incredibuild/makecommandbuilder.cpp
index f9fb4a59587..bffd0770ee8 100644
--- a/src/plugins/incredibuild/makecommandbuilder.cpp
+++ b/src/plugins/incredibuild/makecommandbuilder.cpp
@@ -51,14 +51,14 @@ QString MakeCommandBuilder::setMultiProcessArg(QString args)
// jom -j 200
if (cmd.baseName().compare("jom", Qt::CaseSensitivity::CaseInsensitive) == 0) {
- QRegularExpression regExp("\\s*\\-j\\s+\\d+");
+ static const QRegularExpression regExp("\\s*\\-j\\s+\\d+");
args.remove(regExp);
args.append(" -j 200");
}
// make -j200
else if ((cmd.baseName().compare("make", Qt::CaseSensitivity::CaseInsensitive) == 0)
|| (cmd.baseName().compare("gmake", Qt::CaseSensitivity::CaseInsensitive) == 0)) {
- QRegularExpression regExp("\\s*\\-j\\d+");
+ static const QRegularExpression regExp("\\s*\\-j\\d+");
args.remove(regExp);
args.append(" -j200");
}
diff --git a/src/plugins/ios/iosrunner.cpp b/src/plugins/ios/iosrunner.cpp
index 7f111ea351e..287210da4c7 100644
--- a/src/plugins/ios/iosrunner.cpp
+++ b/src/plugins/ios/iosrunner.cpp
@@ -60,6 +60,8 @@ using namespace Tasking;
namespace Ios::Internal {
+char QML_DEBUGGER_WAITING[] = "QML Debugger: Waiting for connection on port ([0-9]+)...";
+
static QString identifierForRunControl(RunControl *runControl)
{
const IosDeviceTypeAspect::Data *data = runControl->aspectData<IosDeviceTypeAspect>();
@@ -621,7 +623,7 @@ void IosRunner::handleGotInferiorPid(IosToolHandler *handler, const FilePath &bu
void IosRunner::handleAppOutput(IosToolHandler *handler, const QString &output)
{
Q_UNUSED(handler)
- QRegularExpression qmlPortRe("QML Debugger: Waiting for connection on port ([0-9]+)...");
+ static const QRegularExpression qmlPortRe(QString::fromLatin1(QML_DEBUGGER_WAITING));
const QRegularExpressionMatch match = qmlPortRe.match(output);
QString res(output);
if (match.hasMatch() && m_qmlServerPort.isValid())
@@ -632,7 +634,7 @@ void IosRunner::handleAppOutput(IosToolHandler *handler, const QString &output)
void IosRunner::handleMessage(const QString &msg)
{
QString res(msg);
- QRegularExpression qmlPortRe("QML Debugger: Waiting for connection on port ([0-9]+)...");
+ static const QRegularExpression qmlPortRe(QString::fromLatin1(QML_DEBUGGER_WAITING));
const QRegularExpressionMatch match = qmlPortRe.match(msg);
if (match.hasMatch() && m_qmlServerPort.isValid())
res.replace(match.captured(1), QString::number(m_qmlServerPort.number()));
diff --git a/src/plugins/languageclient/languageclientcompletionassist.cpp b/src/plugins/languageclient/languageclientcompletionassist.cpp
index 7919de0de81..abdd308b51e 100644
--- a/src/plugins/languageclient/languageclientcompletionassist.cpp
+++ b/src/plugins/languageclient/languageclientcompletionassist.cpp
@@ -78,7 +78,7 @@ void LanguageClientCompletionItem::apply(TextEditorWidget *editorWidget,
QTextCursor cursor = editorWidget->textCursorAt(pos);
cursor.movePosition(QTextCursor::StartOfLine, QTextCursor::KeepAnchor);
const QString blockTextUntilPosition = cursor.selectedText();
- static QRegularExpression identifier("[a-zA-Z_][a-zA-Z0-9_]*$");
+ static const QRegularExpression identifier("[a-zA-Z_][a-zA-Z0-9_]*$");
QRegularExpressionMatch match = identifier.match(blockTextUntilPosition);
int matchLength = match.hasMatch() ? match.capturedLength(0) : 0;
length = qMax(length, matchLength);
diff --git a/src/plugins/lua/bindings/translate.cpp b/src/plugins/lua/bindings/translate.cpp
index 7c5cb140166..aec22c23ce1 100644
--- a/src/plugins/lua/bindings/translate.cpp
+++ b/src/plugins/lua/bindings/translate.cpp
@@ -11,8 +11,8 @@ void setupTranslateModule()
{
autoRegister([](sol::state_view lua) {
const ScriptPluginSpec *pluginSpec = lua.get<ScriptPluginSpec *>("PluginSpec");
- const QString trContext
- = QString(pluginSpec->name).replace(QRegularExpression("[^a-zA-Z]"), "_");
+ static const QRegularExpression regexp("[^a-zA-Z]");
+ const QString trContext = QString(pluginSpec->name).replace(regexp, "_");
lua["tr"] = [trContext](const char *text) -> QString {
return QCoreApplication::translate(trContext.toUtf8().constData(), text);
diff --git a/src/plugins/lua/luaengine.cpp b/src/plugins/lua/luaengine.cpp
index dca1bb25733..a641bfbd03b 100644
--- a/src/plugins/lua/luaengine.cpp
+++ b/src/plugins/lua/luaengine.cpp
@@ -116,7 +116,8 @@ void prepareLuaState(
const expected_str<FilePath> tmpDir = HostOsInfo::root().tmpDir();
QTC_ASSERT_EXPECTED(tmpDir, return);
QString id = name;
- id = id.replace(QRegularExpression("[^a-zA-Z0-9_]"), "_").toLower();
+ static const QRegularExpression regexp("[^a-zA-Z0-9_]");
+ id = id.replace(regexp, "_").toLower();
ScriptPluginSpec::setup(lua, id, name, appDataPath, *tmpDir);
for (const auto &[name, func] : d->m_providers.asKeyValueRange()) {