forked from qt-creator/qt-creator
Parse link failures in release mode correctly
* Fix the LdParser to handle link failures in release mode correctly * Add unit test for that case Task-number: QTCREATORBUG-1865
This commit is contained in:
@@ -606,6 +606,17 @@ void ProjectExplorerPlugin::testGccOutputParsers_data()
|
|||||||
Constants::TASK_CATEGORY_COMPILE))
|
Constants::TASK_CATEGORY_COMPILE))
|
||||||
<< QString();
|
<< QString();
|
||||||
|
|
||||||
|
QTest::newRow("Linker fail (release build)")
|
||||||
|
<< QString::fromLatin1("release/main.o:main.cpp:(.text+0x42): undefined reference to `MainWindow::doSomething()'")
|
||||||
|
<< OutputParserTester::STDERR
|
||||||
|
<< QString() << QString()
|
||||||
|
<< ( QList<ProjectExplorer::Task>()
|
||||||
|
<< Task(Task::Error,
|
||||||
|
QLatin1String("undefined reference to `MainWindow::doSomething()'"),
|
||||||
|
QLatin1String("main.cpp"), -1,
|
||||||
|
Constants::TASK_CATEGORY_COMPILE))
|
||||||
|
<< QString();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProjectExplorerPlugin::testGccOutputParsers()
|
void ProjectExplorerPlugin::testGccOutputParsers()
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ using namespace ProjectExplorer;
|
|||||||
|
|
||||||
namespace {
|
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+|\\(\\.[a-zA-Z0-9]*.0x[a-fA-F0-9]+\\)):";
|
const char * const POSITION_PATTERN = "(\\d+|\\(\\.[a-zA-Z0-9]*.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)?: ";
|
||||||
@@ -44,7 +44,10 @@ namespace {
|
|||||||
LdParser::LdParser()
|
LdParser::LdParser()
|
||||||
{
|
{
|
||||||
setObjectName(QLatin1String("LdParser"));
|
setObjectName(QLatin1String("LdParser"));
|
||||||
m_regExpLinker.setPattern(QString::fromLatin1(FILE_PATTERN) + '(' + QLatin1String(POSITION_PATTERN) + ")?\\s(.+)$");
|
m_regExpLinker.setPattern(QString('^') +
|
||||||
|
QString::fromLatin1(FILE_PATTERN) + '(' +
|
||||||
|
QString::fromLatin1(FILE_PATTERN) + ")?(" +
|
||||||
|
QLatin1String(POSITION_PATTERN) + ")?\\s(.+)$");
|
||||||
m_regExpLinker.setMinimal(true);
|
m_regExpLinker.setMinimal(true);
|
||||||
|
|
||||||
m_regExpGccNames.setPattern(COMMAND_PATTERN);
|
m_regExpGccNames.setPattern(COMMAND_PATTERN);
|
||||||
@@ -87,14 +90,15 @@ void LdParser::stdError(const QString &line)
|
|||||||
return;
|
return;
|
||||||
} else if (m_regExpLinker.indexIn(lne) > -1) {
|
} else if (m_regExpLinker.indexIn(lne) > -1) {
|
||||||
bool ok;
|
bool ok;
|
||||||
int lineno = m_regExpLinker.cap(4).toInt(&ok);
|
int lineno = m_regExpLinker.cap(7).toInt(&ok);
|
||||||
if (!ok)
|
if (!ok)
|
||||||
lineno = -1;
|
lineno = -1;
|
||||||
QString description = m_regExpLinker.cap(5).trimmed();
|
QString filename = m_regExpLinker.cap(1);
|
||||||
Task task(Task::Error,
|
if (!m_regExpLinker.cap(4).isEmpty()
|
||||||
description,
|
&& !m_regExpLinker.cap(4).startsWith(QLatin1String("(.text+0x")))
|
||||||
m_regExpLinker.cap(1) /* filename */,
|
filename = m_regExpLinker.cap(4);
|
||||||
lineno,
|
QString description = m_regExpLinker.cap(8).trimmed();
|
||||||
|
Task task(Task::Error, description, filename, lineno,
|
||||||
Constants::TASK_CATEGORY_COMPILE);
|
Constants::TASK_CATEGORY_COMPILE);
|
||||||
if (m_regExpInFunction.indexIn(description) > -1 ||
|
if (m_regExpInFunction.indexIn(description) > -1 ||
|
||||||
description.startsWith(QLatin1String("At global scope")) ||
|
description.startsWith(QLatin1String("At global scope")) ||
|
||||||
|
|||||||
Reference in New Issue
Block a user