Commit f39a86f7 authored by Daniel Teske's avatar Daniel Teske
Browse files

LdParser: Use QRegularExpression



Change-Id: I0c183894389d92178a469fe2980568b7517a153c
Reviewed-by: default avatarTobias Hunger <tobias.hunger@digia.com>
parent 2407c297
......@@ -39,8 +39,7 @@ namespace {
// opt. drive letter + filename: (2 brackets)
const char * const FILE_PATTERN = "(([A-Za-z]:)?[^:]+\\.[^:]+):";
// line no. or elf segment + offset (1 bracket)
// const char * const POSITION_PATTERN = "(\\d+|\\(\\.[^:]+[+-]0x[a-fA-F0-9]+\\):)";
const char * const POSITION_PATTERN = "(\\d+|\\(\\..+[+-]0x[a-fA-F0-9]+\\)):";
const char * const POSITION_PATTERN = "(\\d+|\\(\\..+?[+-]0x[a-fA-F0-9]+\\)):";
const char * const COMMAND_PATTERN = "^(.*[\\\\/])?([a-z0-9]+-[a-z0-9]+-[a-z0-9]+-)?(ld|gold)(-[0-9\\.]+)?(\\.exe)?: ";
}
......@@ -51,11 +50,9 @@ LdParser::LdParser()
QString::fromLatin1(FILE_PATTERN) + QLatin1Char('(') +
QString::fromLatin1(FILE_PATTERN) + QLatin1String(")?(") +
QLatin1String(POSITION_PATTERN) + QLatin1String(")?\\s(.+)$"));
m_regExpLinker.setMinimal(true);
QTC_CHECK(m_regExpLinker.isValid());
m_regExpGccNames.setPattern(QLatin1String(COMMAND_PATTERN));
m_regExpGccNames.setMinimal(true);
QTC_CHECK(m_regExpGccNames.isValid());
}
......@@ -76,8 +73,11 @@ void LdParser::stdError(const QString &line)
-1 /* linenumber */,
Constants::TASK_CATEGORY_COMPILE));
return;
} else if (m_regExpGccNames.indexIn(lne) > -1) {
QString description = lne.mid(m_regExpGccNames.matchedLength());
}
QRegularExpressionMatch match = m_regExpGccNames.match(lne);
if (match.hasMatch()) {
QString description = lne.mid(match.capturedLength());
Task::TaskType type = Task::Error;
if (description.startsWith(QLatin1String("warning: "))) {
type = Task::Warning;
......@@ -89,19 +89,22 @@ void LdParser::stdError(const QString &line)
Constants::TASK_CATEGORY_COMPILE);
emit addTask(task);
return;
} else if (m_regExpLinker.indexIn(lne) > -1) {
}
match = m_regExpLinker.match(lne);
if (match.hasMatch()) {
bool ok;
int lineno = m_regExpLinker.cap(7).toInt(&ok);
int lineno = match.captured(7).toInt(&ok);
if (!ok)
lineno = -1;
Utils::FileName filename = Utils::FileName::fromUserInput(m_regExpLinker.cap(1));
const QString sourceFileName = m_regExpLinker.cap(4);
Utils::FileName filename = Utils::FileName::fromUserInput(match.captured(1));
const QString sourceFileName = match.captured(4);
if (!sourceFileName.isEmpty()
&& !sourceFileName.startsWith(QLatin1String("(.text"))
&& !sourceFileName.startsWith(QLatin1String("(.data"))) {
filename = Utils::FileName::fromUserInput(sourceFileName);
}
QString description = m_regExpLinker.cap(8).trimmed();
QString description = match.captured(8).trimmed();
Task::TaskType type = Task::Error;
if (description.startsWith(QLatin1String("At global scope")) ||
description.startsWith(QLatin1String("At top level")) ||
......
......@@ -32,7 +32,7 @@
#include "ioutputparser.h"
#include <QRegExp>
#include <QRegularExpression>
namespace ProjectExplorer {
......@@ -45,8 +45,8 @@ public:
void stdError(const QString &line);
private:
QRegExp m_regExpLinker;
QRegExp m_regExpGccNames;
QRegularExpression m_regExpLinker;
QRegularExpression m_regExpGccNames;
};
} // namespace ProjectExplorer
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment