forked from qt-creator/qt-creator
LdParser: Use QRegularExpression
Change-Id: I0c183894389d92178a469fe2980568b7517a153c Reviewed-by: Tobias Hunger <tobias.hunger@digia.com>
This commit is contained in:
@@ -39,8 +39,7 @@ namespace {
|
|||||||
// opt. drive letter + filename: (2 brackets)
|
// opt. drive letter + filename: (2 brackets)
|
||||||
const char * const FILE_PATTERN = "(([A-Za-z]:)?[^:]+\\.[^:]+):";
|
const char * const FILE_PATTERN = "(([A-Za-z]:)?[^:]+\\.[^:]+):";
|
||||||
// line no. or elf segment + offset (1 bracket)
|
// 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)?: ";
|
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) + QLatin1Char('(') +
|
||||||
QString::fromLatin1(FILE_PATTERN) + QLatin1String(")?(") +
|
QString::fromLatin1(FILE_PATTERN) + QLatin1String(")?(") +
|
||||||
QLatin1String(POSITION_PATTERN) + QLatin1String(")?\\s(.+)$"));
|
QLatin1String(POSITION_PATTERN) + QLatin1String(")?\\s(.+)$"));
|
||||||
m_regExpLinker.setMinimal(true);
|
|
||||||
QTC_CHECK(m_regExpLinker.isValid());
|
QTC_CHECK(m_regExpLinker.isValid());
|
||||||
|
|
||||||
m_regExpGccNames.setPattern(QLatin1String(COMMAND_PATTERN));
|
m_regExpGccNames.setPattern(QLatin1String(COMMAND_PATTERN));
|
||||||
m_regExpGccNames.setMinimal(true);
|
|
||||||
QTC_CHECK(m_regExpGccNames.isValid());
|
QTC_CHECK(m_regExpGccNames.isValid());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -76,8 +73,11 @@ void LdParser::stdError(const QString &line)
|
|||||||
-1 /* linenumber */,
|
-1 /* linenumber */,
|
||||||
Constants::TASK_CATEGORY_COMPILE));
|
Constants::TASK_CATEGORY_COMPILE));
|
||||||
return;
|
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;
|
Task::TaskType type = Task::Error;
|
||||||
if (description.startsWith(QLatin1String("warning: "))) {
|
if (description.startsWith(QLatin1String("warning: "))) {
|
||||||
type = Task::Warning;
|
type = Task::Warning;
|
||||||
@@ -89,19 +89,22 @@ void LdParser::stdError(const QString &line)
|
|||||||
Constants::TASK_CATEGORY_COMPILE);
|
Constants::TASK_CATEGORY_COMPILE);
|
||||||
emit addTask(task);
|
emit addTask(task);
|
||||||
return;
|
return;
|
||||||
} else if (m_regExpLinker.indexIn(lne) > -1) {
|
}
|
||||||
|
|
||||||
|
match = m_regExpLinker.match(lne);
|
||||||
|
if (match.hasMatch()) {
|
||||||
bool ok;
|
bool ok;
|
||||||
int lineno = m_regExpLinker.cap(7).toInt(&ok);
|
int lineno = match.captured(7).toInt(&ok);
|
||||||
if (!ok)
|
if (!ok)
|
||||||
lineno = -1;
|
lineno = -1;
|
||||||
Utils::FileName filename = Utils::FileName::fromUserInput(m_regExpLinker.cap(1));
|
Utils::FileName filename = Utils::FileName::fromUserInput(match.captured(1));
|
||||||
const QString sourceFileName = m_regExpLinker.cap(4);
|
const QString sourceFileName = match.captured(4);
|
||||||
if (!sourceFileName.isEmpty()
|
if (!sourceFileName.isEmpty()
|
||||||
&& !sourceFileName.startsWith(QLatin1String("(.text"))
|
&& !sourceFileName.startsWith(QLatin1String("(.text"))
|
||||||
&& !sourceFileName.startsWith(QLatin1String("(.data"))) {
|
&& !sourceFileName.startsWith(QLatin1String("(.data"))) {
|
||||||
filename = Utils::FileName::fromUserInput(sourceFileName);
|
filename = Utils::FileName::fromUserInput(sourceFileName);
|
||||||
}
|
}
|
||||||
QString description = m_regExpLinker.cap(8).trimmed();
|
QString description = match.captured(8).trimmed();
|
||||||
Task::TaskType type = Task::Error;
|
Task::TaskType type = Task::Error;
|
||||||
if (description.startsWith(QLatin1String("At global scope")) ||
|
if (description.startsWith(QLatin1String("At global scope")) ||
|
||||||
description.startsWith(QLatin1String("At top level")) ||
|
description.startsWith(QLatin1String("At top level")) ||
|
||||||
|
|||||||
@@ -32,7 +32,7 @@
|
|||||||
|
|
||||||
#include "ioutputparser.h"
|
#include "ioutputparser.h"
|
||||||
|
|
||||||
#include <QRegExp>
|
#include <QRegularExpression>
|
||||||
|
|
||||||
namespace ProjectExplorer {
|
namespace ProjectExplorer {
|
||||||
|
|
||||||
@@ -45,8 +45,8 @@ public:
|
|||||||
void stdError(const QString &line);
|
void stdError(const QString &line);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QRegExp m_regExpLinker;
|
QRegularExpression m_regExpLinker;
|
||||||
QRegExp m_regExpGccNames;
|
QRegularExpression m_regExpGccNames;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace ProjectExplorer
|
} // namespace ProjectExplorer
|
||||||
|
|||||||
Reference in New Issue
Block a user