Commit 8c736770 authored by Milian Wolff's avatar Milian Wolff
Browse files

greatly improve performance of our compiler error-detection regexps

errors start at the beginning of a line, by adding this information
to the regexps (^ at the beginning) they can perform much better for
very long lines which can occur during linking of large projects

also adds a unit test with some error messages I found on the net
to "proof" it's still working as intended

BUG: 295361
parent bed56dbc
......@@ -16,13 +16,13 @@
// @todo could get these from emacs compile.el
QList<ErrorFormat> ErrorFormat::errorFormats = QList<ErrorFormat>()
// GCC - another case, eg. for #include "pixmap.xpm" which does not exists
<< ErrorFormat( "([^:\t]+):([0-9]+):([0-9]+):([^0-9]+)", 1, 2, 4, 3 )
<< ErrorFormat( "^([^:\t]+):([0-9]+):([0-9]+):([^0-9]+)", 1, 2, 4, 3 )
// GCC
<< ErrorFormat( "([^:\t]+):([0-9]+):([^0-9]+)", 1, 2, 3 )
<< ErrorFormat( "^([^:\t]+):([0-9]+):([^0-9]+)", 1, 2, 3 )
// ICC
<< ErrorFormat( "([^: \\t]+)\\(([0-9]+)\\):([^0-9]+)", 1, 2, 3, "intel" )
<< ErrorFormat( "^([^: \\t]+)\\(([0-9]+)\\):([^0-9]+)", 1, 2, 3, "intel" )
//libtool link
<< ErrorFormat( "(libtool):( link):( warning): ", 0, 0, 0 )
<< ErrorFormat( "^(libtool):( link):( warning): ", 0, 0, 0 )
// ld
<< ErrorFormat( "undefined reference", 0, 0, 0 )
<< ErrorFormat( "undefined symbol", 0, 0, 0 )
......@@ -33,9 +33,9 @@ QList<ErrorFormat> ErrorFormat::errorFormats = QList<ErrorFormat>()
// Fortran
<< ErrorFormat( "\"(.*)\", line ([0-9]+):(.*)", 1, 2, 3 )
// Jade
<< ErrorFormat( "[a-zA-Z]+:([^: \t]+):([0-9]+):[0-9]+:[a-zA-Z]:(.*)", 1, 2, 3 )
<< ErrorFormat( "^[a-zA-Z]+:([^: \t]+):([0-9]+):[0-9]+:[a-zA-Z]:(.*)", 1, 2, 3 )
// ifort
<< ErrorFormat( "fortcom: Error: (.*), line ([0-9]+):(.*)", 1, 2, 3, "intel" )
<< ErrorFormat( "^fortcom: Error: (.*), line ([0-9]+):(.*)", 1, 2, 3, "intel" )
// PGI
<< ErrorFormat( "PGF9(.*)-(.*)-(.*)-(.*) \\((.*): ([0-9]+)\\)", 5, 6, 4, "pgi" )
// PGI (2)
......
......@@ -22,6 +22,7 @@
#include "test_makeoutputmodel.h"
#include "../makeoutputmodel.h"
#include "../outputfilters.h"
#include <QStringList>
#include <QTest>
......@@ -113,4 +114,56 @@ void TestMakeOutputModel::benchAddLongLine()
QVERIFY(avgUiLockup < 200);
}
void TestMakeOutputModel::testErrors_data()
{
QTest::addColumn<QString>("line");
QTest::addColumn<QString>("file");
QTest::addColumn<int>("lineNr");
QTest::addColumn<int>("column");
QTest::newRow("gcc-with-col")
<< "/path/to/file.cpp:123:45: fatal error: ..."
<< "/path/to/file.cpp" << 123 << 45;
QTest::newRow("gcc-no-col")
<< "/path/to/file.cpp:123: error ..."
<< "/path/to/file.cpp" << 123 << -1;
QTest::newRow("fortcom")
<< "fortcom: Error: Ogive8.f90, line 123: ..."
<< "Ogive8.f90" << 123 << -1;
QTest::newRow("libtool")
<< "libtool: link: warning: ..."
<< "" << -1 << -1;
}
void TestMakeOutputModel::testErrors()
{
QFETCH(QString, line);
QFETCH(QString, file);
QFETCH(int, lineNr);
QFETCH(int, column);
bool matched = false;
foreach(const ErrorFormat& format, ErrorFormat::errorFormats) {
if (format.expression.indexIn(line) != -1) {
matched = true;
if (format.fileGroup > 0) {
QCOMPARE(format.expression.cap( format.fileGroup ), file);
} else {
QVERIFY(file.isEmpty());
}
if (format.lineGroup > 0) {
QCOMPARE(format.expression.cap( format.lineGroup ).toInt(), lineNr);
} else {
QCOMPARE(lineNr, -1);
}
if(format.columnGroup > 0) {
QCOMPARE(format.expression.cap( format.columnGroup ).toInt(), column);
} else {
QCOMPARE(column, -1);
}
break;
}
}
QVERIFY(matched);
}
#include "test_makeoutputmodel.moc"
......@@ -33,6 +33,9 @@ public:
private slots:
void benchAddLongLine();
void benchAddLines();
void testErrors_data();
void testErrors();
};
#endif // TEST_MAKEOUTPUTMODEL_H
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