From aab000e222c2ed5395e34c71487be0a30d58b4c0 Mon Sep 17 00:00:00 2001 From: Christian Kandeler Date: Tue, 18 Feb 2025 15:53:11 +0100 Subject: [PATCH] ProjectExplorer: Remove unneeded capture groups from regex ... in LdParser. Change-Id: I79bad5825ce78dd762dc95739cf01f5f05705036 Reviewed-by: Christian Stenger --- src/plugins/projectexplorer/ldparser.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/plugins/projectexplorer/ldparser.cpp b/src/plugins/projectexplorer/ldparser.cpp index de02a189f14..32516728514 100644 --- a/src/plugins/projectexplorer/ldparser.cpp +++ b/src/plugins/projectexplorer/ldparser.cpp @@ -109,14 +109,14 @@ std::optional LdParser::checkMainRegex( const QString &trimmedLine, const QString &originalLine) { static const auto makePattern = [] { - const QString driveSpec = "([A-Za-z]:)?"; + const QString driveSpec = "(?:[A-Za-z]:)?"; const QString filePattern = QString(R"re((%1[^:]+\.[^:]+):)re").arg(driveSpec); - const QString lineNumber = R"re(\S+)re"; + const QString lineNumber = R"re((\S+))re"; const QString elfSegmentAndOffset = R"re(\(\..+?[+-]0x[a-fA-F0-9]+\))re"; - const QString positionPattern = QString("(%1|%2):").arg(lineNumber, elfSegmentAndOffset); + const QString positionPattern = QString("(?:%1|%2):").arg(lineNumber, elfSegmentAndOffset); - return QString(R"re(^%1(%1)?(%2)?\s(.+)$)re").arg(filePattern, positionPattern); + return QString(R"re(^%1(?:%1)?(?:%2)?\s(.+)$)re").arg(filePattern, positionPattern); }; static const QRegularExpression regex(makePattern()); @@ -125,18 +125,18 @@ std::optional LdParser::checkMainRegex( return {}; bool ok; - int lineno = match.captured(7).toInt(&ok); + int lineno = match.captured(3).toInt(&ok); if (!ok) lineno = -1; FilePath filePath = absoluteFilePath(FilePath::fromUserInput(match.captured(1))); int capIndex = 1; - const QString sourceFileName = match.captured(4); + const QString sourceFileName = match.captured(2); if (!sourceFileName.isEmpty() && !sourceFileName.startsWith(QLatin1String("(.text")) && !sourceFileName.startsWith(QLatin1String("(.data"))) { filePath = absoluteFilePath(FilePath::fromUserInput(sourceFileName)); - capIndex = 4; + capIndex = 2; } - QString description = match.captured(8).trimmed(); + QString description = match.captured(4).trimmed(); static const QStringList keywords{ "File format not recognized", "undefined reference",